report-studio 1.0.0 → 1.1.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.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +129 -4
  3. package/dist/designer-qy59eEux.js +3416 -0
  4. package/dist/designer.js +2 -3209
  5. package/dist/index.js +2 -2
  6. package/dist/react-designer.js +41 -0
  7. package/dist/react.js +60 -0
  8. package/dist/{viewer-D-c0lKzQ.js → viewer-xa17tyMJ.js} +682 -537
  9. package/package.json +80 -66
  10. package/src/cli/serve.js +135 -135
  11. package/src/designer/designer.js +2054 -1900
  12. package/src/designer/dialog.js +708 -708
  13. package/src/designer/fields.js +51 -2
  14. package/src/designer/icons.js +5 -0
  15. package/src/designer/index.html +28 -28
  16. package/src/designer/main.js +39 -39
  17. package/src/designer/menu.js +2 -2
  18. package/src/designer/panel.js +21 -1
  19. package/src/designer/sample-data.js +180 -9
  20. package/src/designer/structure.js +87 -6
  21. package/src/designer/styles.css +1654 -1616
  22. package/src/designer/tokens.js +9 -0
  23. package/src/engine/csv.js +350 -315
  24. package/src/engine/group.js +128 -65
  25. package/src/engine/index.js +35 -34
  26. package/src/engine/measure.js +13 -12
  27. package/src/engine/paginate.js +8 -4
  28. package/src/engine/resolve.js +37 -0
  29. package/src/engine/tables.js +87 -0
  30. package/src/engine/validate.js +97 -22
  31. package/src/index.html +79 -79
  32. package/src/index.js +51 -50
  33. package/src/preview/chrome.css +505 -505
  34. package/src/preview/chrome.js +147 -147
  35. package/src/preview/index.html +28 -28
  36. package/src/preview/viewer.js +763 -745
  37. package/src/react/designer.js +87 -0
  38. package/src/react/index.js +117 -0
  39. package/src/render/items.js +94 -1
  40. package/src/render/report.css +30 -0
  41. package/src/server/routes.js +331 -331
  42. package/src/shared/brand.css +29 -29
  43. package/src/shared/dropdown.css +136 -136
  44. package/src/shared/modal.css +125 -125
  45. package/src/shared/store.js +145 -145
  46. package/src/shared/theme.css +72 -72
  47. package/src/shared/window.js +138 -138
@@ -1,5 +1,197 @@
1
+ //#region src/engine/tables.js
2
+ function e(e) {
3
+ let t = [];
4
+ for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of Array.isArray(n?.items) ? n.items : []) e?.type === "table" && t.push(e);
5
+ return t;
6
+ }
7
+ function t(e, t) {
8
+ return (typeof e?.dataset == "string" && e.dataset !== "" ? e.dataset : null) ?? t?.dataset ?? null;
9
+ }
10
+ function n(e) {
11
+ return typeof e?.groupBy == "string" && e.groupBy !== "";
12
+ }
13
+ function r(t) {
14
+ let r = e(t), i = r.find(n);
15
+ return i ? {
16
+ table: i,
17
+ by: i.groupBy
18
+ } : t?.groupBy != null && r.length > 0 ? {
19
+ table: r[0],
20
+ by: t.groupBy
21
+ } : null;
22
+ }
23
+ //#endregion
24
+ //#region src/engine/text-metrics.js
25
+ var i = 1.3, a = /* @__PURE__ */ new Map(), o = 1e4, s, c = !1;
26
+ function l() {
27
+ if (c) return s;
28
+ c = !0;
29
+ try {
30
+ s = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
31
+ } catch {
32
+ s = null;
33
+ }
34
+ return s;
35
+ }
36
+ function u(e = {}) {
37
+ return `${e.fontStyle || "normal"} ${e.fontWeight || "normal"} ${e.fontSize ?? 12}px ${e.fontFamily || "Helvetica, Arial, sans-serif"}`;
38
+ }
39
+ function d(e, t) {
40
+ let n = String(e ?? "");
41
+ if (n === "") return 0;
42
+ let r = u(t), i = `${r}\u0000${n}`, s = a.get(i);
43
+ if (s !== void 0) return s;
44
+ let c = l(), d;
45
+ return c ? (c.font = r, d = c.measureText(n).width) : d = f(n, t), a.size >= o && a.clear(), a.set(i, d), d;
46
+ }
47
+ function f(e, t = {}) {
48
+ let n = t.fontSize ?? 12, r = String(t.fontWeight) === "bold" || Number(t.fontWeight) >= 600, i = /mono|courier|consolas/i.test(t.fontFamily || ""), a = 0;
49
+ for (let t of e) {
50
+ if (i) {
51
+ a += .6;
52
+ continue;
53
+ }
54
+ t === " " ? a += .26 : /[iljI.,:;'`|!\[\]()]/.test(t) ? a += .28 : /[ftr]/.test(t) ? a += .34 : /[A-Z]/.test(t) ? a += .68 : /[mwMW@]/.test(t) ? a += .88 : /[0-9]/.test(t) ? a += .56 : a += .52;
55
+ }
56
+ return a * n * (r ? 1.06 : 1);
57
+ }
58
+ function p(e, t, n) {
59
+ let r = String(e ?? "").split("\n");
60
+ if (!(t > 0)) return r;
61
+ let i = [];
62
+ for (let e of r) {
63
+ let r = e.split(/(\s+)/).filter((e) => e !== "");
64
+ if (r.length === 0) {
65
+ i.push("");
66
+ continue;
67
+ }
68
+ let a = "";
69
+ for (let e of r) {
70
+ let r = a + e;
71
+ for (a !== "" && d(r, n) > t ? (i.push(a.trimEnd()), a = e.trimStart()) : a = r; d(a, n) > t && a.trim().length > 1;) {
72
+ let e = a.length;
73
+ for (; e > 1 && d(a.slice(0, e), n) > t;) e--;
74
+ if (e >= a.length) break;
75
+ i.push(a.slice(0, e)), a = a.slice(e);
76
+ }
77
+ }
78
+ i.push(a.trimEnd());
79
+ }
80
+ return i;
81
+ }
82
+ function m(e, t, n) {
83
+ let r = Math.ceil((n?.fontSize ?? 12) * i);
84
+ return p(e, t, n).length * r;
85
+ }
86
+ function h(e) {
87
+ return {
88
+ fontSize: e.style?.fontSize ?? 12,
89
+ fontFamily: e.style?.fontFamily,
90
+ fontWeight: "normal",
91
+ fontStyle: "normal"
92
+ };
93
+ }
94
+ function g(e) {
95
+ let t = (e.columns ?? []).map((e) => e.width ?? 0), n = t.reduce((e, t) => e + t, 0), r = e.w ?? n, i = n > 0 && r > n ? r / n : 1;
96
+ return t.map((e) => e * i);
97
+ }
98
+ function _(e) {
99
+ if (e.style?.borderStyle === "none") return 0;
100
+ let t = Number(e.style?.borderWidth);
101
+ return Number.isFinite(t) && t > 0 ? t : 1;
102
+ }
103
+ function v(e) {
104
+ let t = g(e), n = _(e), r = t.length - 1;
105
+ return t.map((e, t) => e - 16 - n * (t === r ? 2 : 1));
106
+ }
107
+ function y(e, t) {
108
+ let n = e.rowHeight ?? 0, r = t ?? [];
109
+ if (e.wrap === !1) return r.map(() => n);
110
+ let i = h(e), a = e.columns ?? [], o = v(e);
111
+ return r.map((e) => {
112
+ let t = n;
113
+ for (let [n, r] of a.entries()) {
114
+ let a = o[n];
115
+ if (!(a > 0)) continue;
116
+ let s = e?.[r.field];
117
+ s == null || s === "" || (t = Math.max(t, m(String(s), a, i)));
118
+ }
119
+ return t;
120
+ });
121
+ }
122
+ function b(e) {
123
+ if (!e.showHeader) return 0;
124
+ let t = e.headerHeight ?? e.rowHeight ?? 0;
125
+ if (e.wrap === !1) return t;
126
+ let n = (e.columns ?? []).map((e, t) => ({
127
+ ...e,
128
+ field: `label${t}`
129
+ })), r = Object.fromEntries((e.columns ?? []).map((e, t) => [`label${t}`, e.label])), [i] = y({
130
+ ...e,
131
+ rowHeight: t,
132
+ columns: n
133
+ }, [r]);
134
+ return i ?? t;
135
+ }
136
+ function x(e) {
137
+ if (e.type !== "table") return e.h ?? 0;
138
+ let t = e.rowHeight ?? 0;
139
+ return (e.showHeader ? e.headerHeight ?? t : 0) + 3 * t;
140
+ }
141
+ function S(e) {
142
+ let t = structuredClone(e);
143
+ for (let e of t.bands) e.items && C(e, t);
144
+ return t;
145
+ }
146
+ function C(e, t) {
147
+ let n = 0;
148
+ for (let r of e.items) r.measuredHeight = T(r, t), n = Math.max(n, (r.y ?? 0) + r.measuredHeight);
149
+ return e.contentHeight = n, e.measuredHeight = w(e) ? n : Math.max(e.height ?? 0, n), e;
150
+ }
151
+ function w(e) {
152
+ return e.items.some((e) => e.type === "table");
153
+ }
154
+ function T(e, t) {
155
+ switch (e.type) {
156
+ case "text": return E(e);
157
+ case "table": return O(e, t);
158
+ case "line": return D(e);
159
+ case "box":
160
+ case "image": return e.h ?? 0;
161
+ default: return console.warn(`Unknown item type "${e.type}" on item "${e.id}"; treating as zero height.`), 0;
162
+ }
163
+ }
164
+ function E(e) {
165
+ let t = e.h ?? 0, n = m(e.text ?? e.value ?? "", e.w ?? 0, e.style);
166
+ return Math.max(t, n);
167
+ }
168
+ function D(e) {
169
+ let t = e.h ?? 0;
170
+ return e.orientation === "vertical" ? t : Math.max(t, e.style?.thickness ?? 0);
171
+ }
172
+ function O(e, t) {
173
+ let n = b(e);
174
+ if (e.headerMeasured = n, !Array.isArray(e.groups)) return e.rowHeights = y(e, e.row), n + k(e.rowHeights);
175
+ let r = e.groups ?? [], i = A(t, "groupHeader"), a = A(t, "groupFooter"), o = 0;
176
+ for (let t of r) t.rowHeights = y(e, t.rows), o += n + i + k(t.rowHeights) + a;
177
+ return o;
178
+ }
179
+ function k(e) {
180
+ return (e ?? []).reduce((e, t) => e + t, 0);
181
+ }
182
+ function A(e, t) {
183
+ let n = e.bands.find((e) => e.type === t);
184
+ if (!n?.items) return 0;
185
+ let r = 0;
186
+ for (let e of n.items) {
187
+ let t = e.type === "text" ? E(e) : 0;
188
+ r = Math.max(r, (e.y ?? 0) + t);
189
+ }
190
+ return Math.max(n.height ?? 0, r);
191
+ }
192
+ //#endregion
1
193
  //#region src/engine/validate.js
2
- var e = [
194
+ var ee = [
3
195
  "reportHeader",
4
196
  "pageHeader",
5
197
  "groupHeader",
@@ -7,46 +199,64 @@ var e = [
7
199
  "groupFooter",
8
200
  "reportFooter",
9
201
  "pageFooter"
10
- ], t = [
202
+ ], j = [
11
203
  "text",
12
204
  "table",
13
205
  "line",
14
- "box"
15
- ], n = ["horizontal", "vertical"], r = [
206
+ "box",
207
+ "image"
208
+ ], te = ["horizontal", "vertical"], M = [
16
209
  "solid",
17
210
  "dashed",
18
211
  "dotted",
19
212
  "double"
20
- ], i = [...r, "none"], a = class extends Error {
213
+ ], N = [...M, "none"], P = [
214
+ "contain",
215
+ "cover",
216
+ "fill"
217
+ ], F = class extends Error {
21
218
  constructor(e, t = []) {
22
219
  super(t.length ? `${e}\n - ${t.join("\n - ")}` : e), this.name = "ReportError", this.issues = t;
23
220
  }
24
221
  };
25
- function o(t) {
26
- let n = [];
27
- if (typeof t != "object" || !t || Array.isArray(t)) return ["layout must be an object"];
28
- if (c(t.page, n), !Array.isArray(t.bands)) return n.push("layout.bands must be an array"), n;
29
- t.bands.length === 0 && n.push("layout.bands is empty - there is nothing to render"), t.groupBy != null && typeof t.groupBy != "string" && n.push("layout.groupBy must be a field name or null");
30
- let r = /* @__PURE__ */ new Set();
31
- return t.bands.forEach((t, i) => {
32
- let a = `bands[${i}]`;
33
- if (typeof t != "object" || !t) {
34
- n.push(`${a} must be an object`);
222
+ function I(e) {
223
+ let t = [];
224
+ if (typeof e != "object" || !e || Array.isArray(e)) return ["layout must be an object"];
225
+ if (L(e.page, t), !Array.isArray(e.bands)) return t.push("layout.bands must be an array"), t;
226
+ e.bands.length === 0 && t.push("layout.bands is empty - there is nothing to render"), e.groupBy != null && typeof e.groupBy != "string" && t.push("layout.groupBy must be a field name or null");
227
+ let n = /* @__PURE__ */ new Set();
228
+ return e.bands.forEach((e, r) => {
229
+ let i = `bands[${r}]`;
230
+ if (typeof e != "object" || !e) {
231
+ t.push(`${i} must be an object`);
35
232
  return;
36
233
  }
37
- if (e.includes(t.type) ? r.has(t.type) ? n.push(`${a}.type "${t.type}" appears more than once; the engine places one band of each type`) : r.add(t.type) : n.push(`${a}.type "${t.type}" is not one of: ${e.join(", ")}`), !Array.isArray(t.items)) {
38
- n.push(`${a}.items must be an array`);
234
+ if (ee.includes(e.type) ? n.has(e.type) ? t.push(`${i}.type "${e.type}" appears more than once; the engine places one band of each type`) : n.add(e.type) : t.push(`${i}.type "${e.type}" is not one of: ${ee.join(", ")}`), !Array.isArray(e.items)) {
235
+ t.push(`${i}.items must be an array`);
39
236
  return;
40
237
  }
41
- t.items.forEach((e, t) => l(e, `${a}.items[${t}]`, n));
42
- }), t.groupBy != null && !r.has("groupHeader") && !r.has("groupFooter") && n.push("layout.groupBy is set but there is no groupHeader or groupFooter band to show it"), s(t.bands, n), n;
43
- }
44
- function s(e, t) {
45
- let n = [];
46
- for (let t of e) if (Array.isArray(t?.items)) for (let e of t.items) e?.type === "table" && n.push(e.id ?? "(unnamed)");
47
- n.length > 1 && t.push(`layout has ${n.length} tables (${n.map((e) => `"${e}"`).join(", ")}); a report binds one - the rest would print their header and no rows`);
238
+ e.items.forEach((e, n) => R(e, `${i}.items[${n}]`, t));
239
+ }), e.groupBy != null && !n.has("groupHeader") && !n.has("groupFooter") && t.push("layout.groupBy is set but there is no groupHeader or groupFooter band to show it"), ne(e, e.bands, t), t;
240
+ }
241
+ function ne(t, r, i) {
242
+ let a = e(t);
243
+ for (let e of a) e.groupBy != null && typeof e.groupBy != "string" && i.push(`table "${e.id}".groupBy must be a field name or null`), e.dataset != null && typeof e.dataset != "string" && i.push(`table "${e.id}".dataset must be a dataset name or null`);
244
+ let o = a.filter(n);
245
+ o.length > 1 && i.push(`${o.length} tables are grouped (${o.map((e) => `"${e.id}"`).join(", ")}); a report groups one, because groupHeader and groupFooter are shared`), o.length > 0 && t.groupBy == null && !r.some((e) => e?.type === "groupHeader" || e?.type === "groupFooter") && i.push(`table "${o[0].id}" is grouped by "${o[0].groupBy}" but there is no groupHeader or groupFooter band to show it`);
246
+ for (let e of r) {
247
+ if (!Array.isArray(e?.items)) continue;
248
+ let t = e.items.filter((e) => e?.type === "table").map((e) => ({
249
+ item: e,
250
+ top: Number(e.y) || 0,
251
+ bottom: (Number(e.y) || 0) + x(e)
252
+ })).sort((e, t) => e.top - t.top);
253
+ for (let n = 1; n < t.length; n++) {
254
+ let r = t[n - 1], a = t[n];
255
+ a.top < r.bottom && i.push(`tables "${r.item.id}" and "${a.item.id}" overlap in the ${e.type} band; move "${a.item.id}" to y ${Math.ceil(r.bottom)} or lower - tables are stacked, one under another, not placed side by side`);
256
+ }
257
+ }
48
258
  }
49
- function c(e, t) {
259
+ function L(e, t) {
50
260
  if (typeof e != "object" || !e) {
51
261
  t.push("layout.page must be an object with width, height and margin");
52
262
  return;
@@ -65,169 +275,223 @@ function c(e, t) {
65
275
  let n = e.height - (e.margin.top + e.margin.bottom);
66
276
  n <= 0 && t.push(`layout.page margins leave no printable height (${n}px)`);
67
277
  }
68
- function l(e, n, r) {
278
+ function R(e, t, n) {
69
279
  if (typeof e != "object" || !e) {
70
- r.push(`${n} must be an object`);
280
+ n.push(`${t} must be an object`);
71
281
  return;
72
282
  }
73
- if (!t.includes(e.type)) {
74
- r.push(`${n}.type "${e.type}" is not one of: ${t.join(", ")}`);
283
+ if (!j.includes(e.type)) {
284
+ n.push(`${t}.type "${e.type}" is not one of: ${j.join(", ")}`);
75
285
  return;
76
286
  }
77
- if ((typeof e.id != "string" || e.id === "") && r.push(`${n}.id must be a non-empty string`), e.type === "text") {
78
- typeof e.value != "string" && r.push(`${n}.value must be a string`);
287
+ if ((typeof e.id != "string" || e.id === "") && n.push(`${t}.id must be a non-empty string`), e.type === "text") {
288
+ typeof e.value != "string" && n.push(`${t}.value must be a string`);
79
289
  return;
80
290
  }
81
291
  if (e.type === "line") {
82
- d(e, n, r);
292
+ V(e, t, n);
83
293
  return;
84
294
  }
85
295
  if (e.type === "box") {
86
- u(e, n, r);
296
+ z(e, t, n);
87
297
  return;
88
298
  }
89
- if (typeof e.rowHeight == "number" && e.rowHeight > 0 || r.push(`${n}.rowHeight must be a positive number`), e.style?.borderStyle != null && !i.includes(e.style.borderStyle) && r.push(`${n}.style.borderStyle "${e.style.borderStyle}" is not one of: ` + i.join(", ")), e.style?.borderWidth != null && !(typeof e.style.borderWidth == "number" && e.style.borderWidth > 0) && r.push(`${n}.style.borderWidth must be a positive number of pixels`), !Array.isArray(e.columns) || e.columns.length === 0) {
90
- r.push(`${n}.columns must be a non-empty array`);
299
+ if (e.type === "image") {
300
+ B(e, t, n);
91
301
  return;
92
302
  }
93
- e.columns.forEach((e, t) => {
94
- (e == null || typeof e.field != "string" || e.field === "") && r.push(`${n}.columns[${t}].field must be a non-empty string`);
303
+ if (typeof e.rowHeight == "number" && e.rowHeight > 0 || n.push(`${t}.rowHeight must be a positive number`), e.style?.borderStyle != null && !N.includes(e.style.borderStyle) && n.push(`${t}.style.borderStyle "${e.style.borderStyle}" is not one of: ` + N.join(", ")), e.style?.borderWidth != null && !(typeof e.style.borderWidth == "number" && e.style.borderWidth > 0) && n.push(`${t}.style.borderWidth must be a positive number of pixels`), !Array.isArray(e.columns) || e.columns.length === 0) {
304
+ n.push(`${t}.columns must be a non-empty array`);
305
+ return;
306
+ }
307
+ e.columns.forEach((e, r) => {
308
+ (e == null || typeof e.field != "string" || e.field === "") && n.push(`${t}.columns[${r}].field must be a non-empty string`);
95
309
  });
96
310
  }
97
- function u(e, t, n) {
311
+ function z(e, t, n) {
98
312
  let r = e.style;
99
313
  if (r != null) {
100
314
  if (typeof r != "object" || Array.isArray(r)) {
101
315
  n.push(`${t}.style must be an object`);
102
316
  return;
103
317
  }
104
- r.borderStyle != null && !i.includes(r.borderStyle) && n.push(`${t}.style.borderStyle "${r.borderStyle}" is not one of: ` + i.join(", "));
318
+ r.borderStyle != null && !N.includes(r.borderStyle) && n.push(`${t}.style.borderStyle "${r.borderStyle}" is not one of: ` + N.join(", "));
105
319
  for (let e of ["borderWidth", "radius"]) {
106
320
  let i = r[e], a = e === "radius" ? 0 : 1;
107
321
  i != null && !(typeof i == "number" && i >= a) && n.push(`${t}.style.${e} must be a number of pixels` + (a ? " greater than zero" : " of zero or more"));
108
322
  }
109
323
  }
110
324
  }
111
- function d(e, t, i) {
112
- e.orientation != null && !n.includes(e.orientation) && i.push(`${t}.orientation "${e.orientation}" is not one of: ` + n.join(", "));
113
- let a = e.style;
114
- if (a != null) {
115
- if (typeof a != "object" || Array.isArray(a)) {
116
- i.push(`${t}.style must be an object`);
325
+ function B(e, t, n) {
326
+ e.src != null && typeof e.src != "string" && n.push(`${t}.src must be a string - a URL or a data: URI`), e.field != null && typeof e.field != "string" && n.push(`${t}.field must be a data path such as "company.logo"`), e.fit != null && !P.includes(e.fit) && n.push(`${t}.fit "${e.fit}" is not one of: ${P.join(", ")}`), e.alt != null && typeof e.alt != "string" && n.push(`${t}.alt must be a string`);
327
+ }
328
+ function V(e, t, n) {
329
+ e.orientation != null && !te.includes(e.orientation) && n.push(`${t}.orientation "${e.orientation}" is not one of: ` + te.join(", "));
330
+ let r = e.style;
331
+ if (r != null) {
332
+ if (typeof r != "object" || Array.isArray(r)) {
333
+ n.push(`${t}.style must be an object`);
117
334
  return;
118
335
  }
119
- a.thickness != null && !(typeof a.thickness == "number" && a.thickness > 0) && i.push(`${t}.style.thickness must be a positive number of pixels`), a.lineStyle != null && !r.includes(a.lineStyle) && i.push(`${t}.style.lineStyle "${a.lineStyle}" is not one of: ` + r.join(", "));
336
+ r.thickness != null && !(typeof r.thickness == "number" && r.thickness > 0) && n.push(`${t}.style.thickness must be a positive number of pixels`), r.lineStyle != null && !M.includes(r.lineStyle) && n.push(`${t}.style.lineStyle "${r.lineStyle}" is not one of: ` + M.join(", "));
120
337
  }
121
338
  }
122
- function f(e, t) {
123
- let n = o(e);
124
- if (n.length) throw new a(`${t}: the layout file is not usable`, n);
339
+ function re(e, t) {
340
+ let n = I(e);
341
+ if (n.length) throw new F(`${t}: the layout file is not usable`, n);
125
342
  }
126
- function p(e, t) {
127
- if (typeof e != "object" || !e || Array.isArray(e)) throw new a(`${t}: data must be an object keyed by dataset name`);
343
+ function ie(e, t) {
344
+ if (typeof e != "object" || !e || Array.isArray(e)) throw new F(`${t}: data must be an object keyed by dataset name`);
128
345
  }
129
346
  //#endregion
130
347
  //#region src/engine/resolve.js
131
- var m = /\{([^{}]+)\}/g, h = /^\w+\(.*\)$/, g = ["page", "totalPages"], _ = ["groupHeader", "groupFooter"], v = m;
132
- function y(e) {
133
- return h.test(e) || g.includes(e) || e === "today";
348
+ var H = /\{([^{}]+)\}/g, U = /^\w+\(.*\)$/, W = ["page", "totalPages"], ae = ["groupHeader", "groupFooter"], oe = H;
349
+ function se(e) {
350
+ return U.test(e) || W.includes(e) || e === "today";
134
351
  }
135
- function b(e) {
136
- return _.includes(e);
352
+ function ce(e) {
353
+ return ae.includes(e);
137
354
  }
138
- function x(e, t) {
139
- f(e, "resolve"), p(t, "resolve");
355
+ function le(e, t) {
356
+ re(e, "resolve"), ie(t, "resolve");
140
357
  let n = structuredClone(e);
141
358
  for (let e of n.bands) {
142
- let n = _.includes(e.type);
143
- for (let r of e.items) r.type == "text" && (r.text = S(r, t, n));
359
+ let n = ae.includes(e.type);
360
+ for (let r of e.items) r.type == "text" && (r.text = de(r, t, n)), r.type == "image" && (r.resolvedSrc = ue(r, t));
144
361
  }
145
362
  return n;
146
363
  }
147
- function S(e, t, n) {
148
- return e.value.replace(m, (r, i) => C(r, i.trim(), t, e, n));
364
+ function ue(e, t) {
365
+ let n = typeof e.field == "string" ? e.field.trim() : "";
366
+ if (n) {
367
+ let r = pe(n, t);
368
+ if (typeof r == "string" && r !== "") return r;
369
+ e.src || console.warn(`Unresolved image field "${n}" on item "${e.id}".`);
370
+ }
371
+ return typeof e.src == "string" ? e.src : "";
372
+ }
373
+ function de(e, t, n) {
374
+ return e.value.replace(H, (r, i) => fe(r, i.trim(), t, e, n));
149
375
  }
150
- function C(e, t, n, r, i) {
151
- if (h.test(t) || g.includes(t)) return e;
376
+ function fe(e, t, n, r, i) {
377
+ if (U.test(t) || W.includes(t)) return e;
152
378
  if (t == "today") return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
153
- let a = w(t, n);
379
+ let a = pe(t, n);
154
380
  return a == null ? i ? e : (console.warn(`Unresolved placeholder "{${t}}" on item "${r.id}".`), "") : String(a);
155
381
  }
156
- function w(e, t) {
382
+ function pe(e, t) {
157
383
  return e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((e) => e !== "").reduce((e, t) => e?.[t], t);
158
384
  }
159
385
  //#endregion
160
386
  //#region src/engine/group.js
161
- var T = /\{([^{}]+)\}/g;
162
- function E(e, t) {
163
- let n = structuredClone(e);
164
- return n.groupBy == null ? O(n, t) : D(n, t);
165
- }
166
- function D(e, t) {
167
- let n = e.bands, r = ee(n);
168
- if (!r) throw new a(`group: layout.groupBy is "${e.groupBy}" but no band contains a table to group`);
169
- let i = k(r, e, t), o = P(i, e.groupBy), s = M(n, o);
170
- return r.groups = Object.entries(o).map(([e, t]) => ({
387
+ var me = /\{([^{}]+)\}/g;
388
+ function he(n, i) {
389
+ let a = structuredClone(n), o = a.bands, s = e(a);
390
+ if (a.groupBy != null && s.length === 0) throw new F(`group: layout.groupBy is "${a.groupBy}" but no band contains a table to group`);
391
+ let c = r(a), l = _e(i), u = s.map((e) => {
392
+ let n = ve(e, a, i);
393
+ return l.set(t(e, a), n), {
394
+ table: e,
395
+ rows: n
396
+ };
397
+ });
398
+ for (let { table: e, rows: n } of u) e === c?.table ? ge(e, n, c.by, o, t(e, a)) : e.row = n;
399
+ return be(o, {
400
+ rows: u[0]?.rows ?? [],
401
+ named: l
402
+ }), a;
403
+ }
404
+ function ge(e, t, n, r, i) {
405
+ let a = De(t, n), o = we(r, a, i);
406
+ e.groups = Object.entries(a).map(([e, t]) => ({
171
407
  key: e,
172
408
  rows: t,
173
- aggregates: s[e]
174
- })), te(n, i), e;
175
- }
176
- function O(e, t) {
177
- let n = e.bands, r = ee(n), i = r ? k(r, e, t) : [];
178
- return r && (r.row = i), te(n, i), e;
409
+ aggregates: o[e]
410
+ }));
179
411
  }
180
- function k(e, t, n) {
181
- let r = e.dataset ?? t.dataset, i = n[r];
182
- if (i === void 0) throw new a(`group: table "${e.id}" is bound to dataset "${r}", which is not present in the data`);
183
- if (!Array.isArray(i)) throw new a(`group: dataset "${r}" must be an array of rows, got ${typeof i}`);
184
- return i;
412
+ function _e(e) {
413
+ let t = /* @__PURE__ */ new Map();
414
+ for (let [n, r] of Object.entries(e ?? {})) Array.isArray(r) && t.set(n, r);
415
+ return t;
185
416
  }
186
- function ee(e) {
187
- for (let t of e) for (let e of t.items) if (e.type == "table") return e;
417
+ function ve(e, n, r) {
418
+ let i = t(e, n), a = i == null ? void 0 : r[i];
419
+ if (a === void 0) throw new F(`group: table "${e.id}" is bound to dataset "${i}", which is not present in the data`);
420
+ if (!Array.isArray(a)) throw new F(`group: dataset "${i}" must be an array of rows, got ${typeof a}`);
421
+ return a;
188
422
  }
189
- var A = ["groupHeader", "groupFooter"];
190
- function te(e, t) {
191
- for (let n of e) if (!A.includes(n.type)) for (let e of n.items) e.type == "text" && (e.text = ne(e.text ?? e.value, t));
423
+ var ye = ["groupHeader", "groupFooter"];
424
+ function be(e, t) {
425
+ for (let n of e) if (!ye.includes(n.type)) for (let e of n.items) e.type == "text" && (e.text = xe(e.text ?? e.value, t));
192
426
  }
193
- function ne(e, t) {
194
- return e.replace(T, (e, n) => {
195
- let r = j(n.trim());
427
+ function xe(e, t) {
428
+ return e.replace(me, (e, n) => {
429
+ let r = Ce(n.trim());
196
430
  if (!r) return e;
197
- let i = F(r, t);
198
- return i == null ? "" : String(i);
431
+ let { rows: i, field: a } = Se(r.field, t), o = Oe({
432
+ key: r.key,
433
+ field: a
434
+ }, i);
435
+ return o == null ? "" : String(o);
199
436
  });
200
437
  }
201
- function j(e) {
438
+ function Se(e, t) {
439
+ if (t.named.has(e)) return {
440
+ rows: t.named.get(e),
441
+ field: ""
442
+ };
443
+ let n = e.indexOf(".");
444
+ if (n > 0) {
445
+ let r = e.slice(0, n);
446
+ if (t.named.has(r)) return {
447
+ rows: t.named.get(r),
448
+ field: e.slice(n + 1)
449
+ };
450
+ }
451
+ return {
452
+ rows: t.rows,
453
+ field: e
454
+ };
455
+ }
456
+ function Ce(e) {
202
457
  let t = e.match(/^(\w+)\((.*?)\)$/);
203
458
  return t ? {
204
459
  key: t[1],
205
460
  field: t[2].trim()
206
461
  } : null;
207
462
  }
208
- function M(e, t) {
209
- let n = {};
210
- for (let e of Object.keys(t)) n[e] = {};
211
- for (let r of e) if (A.includes(r.type)) {
212
- for (let e of r.items) if (e.type == "text") for (let r of N(e.value)) for (let [e, i] of Object.entries(t)) n[e][r.field] || (n[e][r.field] = {
213
- count: null,
214
- sum: null,
215
- avg: null,
216
- min: null,
217
- max: null
218
- }), n[e][r.field][r.key] = F(r, i);
463
+ function we(e, t, n) {
464
+ let r = {};
465
+ for (let e of Object.keys(t)) r[e] = {};
466
+ for (let i of e) if (ye.includes(i.type)) {
467
+ for (let e of i.items) if (e.type == "text") for (let i of Ee(e.value)) {
468
+ let e = Te(i.field, n);
469
+ for (let [n, a] of Object.entries(t)) r[n][i.field] || (r[n][i.field] = {
470
+ count: null,
471
+ sum: null,
472
+ avg: null,
473
+ min: null,
474
+ max: null
475
+ }), r[n][i.field][i.key] = Oe({
476
+ key: i.key,
477
+ field: e
478
+ }, a);
479
+ }
219
480
  }
220
- return n;
481
+ return r;
482
+ }
483
+ function Te(e, t) {
484
+ return t == null ? e : e === t ? "" : e.startsWith(`${t}.`) ? e.slice(t.length + 1) : e;
221
485
  }
222
- function N(e) {
486
+ function Ee(e) {
223
487
  let t = [];
224
- for (let [, n] of e.matchAll(T)) {
225
- let e = j(n.trim());
488
+ for (let [, n] of e.matchAll(me)) {
489
+ let e = Ce(n.trim());
226
490
  e && t.push(e);
227
491
  }
228
492
  return t;
229
493
  }
230
- function P(e, t) {
494
+ function De(e, t) {
231
495
  let n = {};
232
496
  for (let r of e) {
233
497
  let e = r[t];
@@ -235,201 +499,33 @@ function P(e, t) {
235
499
  }
236
500
  return n;
237
501
  }
238
- function F(e, t) {
502
+ function Oe(e, t) {
239
503
  if (e.key === "count") return t.length;
240
504
  let n = t.map((t) => t?.[e.field]).filter((e) => e != null && e !== "").map(Number).filter((e) => Number.isFinite(e));
241
505
  switch (e.key) {
242
- case "sum": return n.length ? I(n.reduce((e, t) => e + t, 0)) : null;
243
- case "avg": return n.length ? I(n.reduce((e, t) => e + t, 0) / n.length) : null;
506
+ case "sum": return n.length ? ke(n.reduce((e, t) => e + t, 0)) : null;
507
+ case "avg": return n.length ? ke(n.reduce((e, t) => e + t, 0) / n.length) : null;
244
508
  case "max": return n.length ? Math.max(...n) : null;
245
509
  case "min": return n.length ? Math.min(...n) : null;
246
510
  default: return console.warn(`Unknown aggregate "${e.key}()"; it has no value.`), null;
247
511
  }
248
512
  }
249
- function I(e) {
513
+ function ke(e) {
250
514
  return Number(e.toPrecision(12));
251
515
  }
252
516
  //#endregion
253
- //#region src/engine/text-metrics.js
254
- var L = 1.3, R = /* @__PURE__ */ new Map(), z = 1e4, B, re = !1;
255
- function ie() {
256
- if (re) return B;
257
- re = !0;
258
- try {
259
- B = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
260
- } catch {
261
- B = null;
262
- }
263
- return B;
264
- }
265
- function ae(e = {}) {
266
- return `${e.fontStyle || "normal"} ${e.fontWeight || "normal"} ${e.fontSize ?? 12}px ${e.fontFamily || "Helvetica, Arial, sans-serif"}`;
267
- }
268
- function V(e, t) {
269
- let n = String(e ?? "");
270
- if (n === "") return 0;
271
- let r = ae(t), i = `${r}\u0000${n}`, a = R.get(i);
272
- if (a !== void 0) return a;
273
- let o = ie(), s;
274
- return o ? (o.font = r, s = o.measureText(n).width) : s = oe(n, t), R.size >= z && R.clear(), R.set(i, s), s;
275
- }
276
- function oe(e, t = {}) {
277
- let n = t.fontSize ?? 12, r = String(t.fontWeight) === "bold" || Number(t.fontWeight) >= 600, i = /mono|courier|consolas/i.test(t.fontFamily || ""), a = 0;
278
- for (let t of e) {
279
- if (i) {
280
- a += .6;
281
- continue;
282
- }
283
- t === " " ? a += .26 : /[iljI.,:;'`|!\[\]()]/.test(t) ? a += .28 : /[ftr]/.test(t) ? a += .34 : /[A-Z]/.test(t) ? a += .68 : /[mwMW@]/.test(t) ? a += .88 : /[0-9]/.test(t) ? a += .56 : a += .52;
284
- }
285
- return a * n * (r ? 1.06 : 1);
286
- }
287
- function H(e, t, n) {
288
- let r = String(e ?? "").split("\n");
289
- if (!(t > 0)) return r;
290
- let i = [];
291
- for (let e of r) {
292
- let r = e.split(/(\s+)/).filter((e) => e !== "");
293
- if (r.length === 0) {
294
- i.push("");
295
- continue;
296
- }
297
- let a = "";
298
- for (let e of r) {
299
- let r = a + e;
300
- for (a !== "" && V(r, n) > t ? (i.push(a.trimEnd()), a = e.trimStart()) : a = r; V(a, n) > t && a.trim().length > 1;) {
301
- let e = a.length;
302
- for (; e > 1 && V(a.slice(0, e), n) > t;) e--;
303
- if (e >= a.length) break;
304
- i.push(a.slice(0, e)), a = a.slice(e);
305
- }
306
- }
307
- i.push(a.trimEnd());
308
- }
309
- return i;
310
- }
311
- function se(e, t, n) {
312
- let r = Math.ceil((n?.fontSize ?? 12) * L);
313
- return H(e, t, n).length * r;
314
- }
315
- function ce(e) {
316
- return {
317
- fontSize: e.style?.fontSize ?? 12,
318
- fontFamily: e.style?.fontFamily,
319
- fontWeight: "normal",
320
- fontStyle: "normal"
321
- };
322
- }
323
- function le(e) {
324
- let t = (e.columns ?? []).map((e) => e.width ?? 0), n = t.reduce((e, t) => e + t, 0), r = e.w ?? n, i = n > 0 && r > n ? r / n : 1;
325
- return t.map((e) => e * i);
326
- }
327
- function ue(e) {
328
- if (e.style?.borderStyle === "none") return 0;
329
- let t = Number(e.style?.borderWidth);
330
- return Number.isFinite(t) && t > 0 ? t : 1;
331
- }
332
- function de(e) {
333
- let t = le(e), n = ue(e), r = t.length - 1;
334
- return t.map((e, t) => e - 16 - n * (t === r ? 2 : 1));
335
- }
336
- function fe(e, t) {
337
- let n = e.rowHeight ?? 0, r = t ?? [];
338
- if (e.wrap === !1) return r.map(() => n);
339
- let i = ce(e), a = e.columns ?? [], o = de(e);
340
- return r.map((e) => {
341
- let t = n;
342
- for (let [n, r] of a.entries()) {
343
- let a = o[n];
344
- if (!(a > 0)) continue;
345
- let s = e?.[r.field];
346
- s == null || s === "" || (t = Math.max(t, se(String(s), a, i)));
347
- }
348
- return t;
349
- });
350
- }
351
- function U(e) {
352
- if (!e.showHeader) return 0;
353
- let t = e.headerHeight ?? e.rowHeight ?? 0;
354
- if (e.wrap === !1) return t;
355
- let n = (e.columns ?? []).map((e, t) => ({
356
- ...e,
357
- field: `label${t}`
358
- })), r = Object.fromEntries((e.columns ?? []).map((e, t) => [`label${t}`, e.label])), [i] = fe({
359
- ...e,
360
- rowHeight: t,
361
- columns: n
362
- }, [r]);
363
- return i ?? t;
364
- }
365
- function pe(e) {
366
- if (e.type !== "table") return e.h ?? 0;
367
- let t = e.rowHeight ?? 0;
368
- return (e.showHeader ? e.headerHeight ?? t : 0) + 3 * t;
369
- }
370
- function me(e) {
371
- let t = structuredClone(e), n = t.groupBy != null;
372
- for (let e of t.bands) e.items && he(e, n, t);
373
- return t;
374
- }
375
- function he(e, t, n) {
376
- let r = 0;
377
- for (let i of e.items) i.measuredHeight = _e(i, t, n), r = Math.max(r, (i.y ?? 0) + i.measuredHeight);
378
- return e.contentHeight = r, e.measuredHeight = ge(e) ? r : Math.max(e.height ?? 0, r), e;
379
- }
380
- function ge(e) {
381
- return e.items.some((e) => e.type === "table");
382
- }
383
- function _e(e, t, n) {
384
- switch (e.type) {
385
- case "text": return ve(e);
386
- case "table": return be(e, t, n);
387
- case "line": return ye(e);
388
- case "box": return e.h ?? 0;
389
- default: return console.warn(`Unknown item type "${e.type}" on item "${e.id}"; treating as zero height.`), 0;
390
- }
391
- }
392
- function ve(e) {
393
- let t = e.h ?? 0, n = se(e.text ?? e.value ?? "", e.w ?? 0, e.style);
394
- return Math.max(t, n);
395
- }
396
- function ye(e) {
397
- let t = e.h ?? 0;
398
- return e.orientation === "vertical" ? t : Math.max(t, e.style?.thickness ?? 0);
399
- }
400
- function be(e, t, n) {
401
- let r = U(e);
402
- if (e.headerMeasured = r, !t) return e.rowHeights = fe(e, e.row), r + W(e.rowHeights);
403
- let i = e.groups ?? [], a = xe(n, "groupHeader"), o = xe(n, "groupFooter"), s = 0;
404
- for (let t of i) t.rowHeights = fe(e, t.rows), s += r + a + W(t.rowHeights) + o;
405
- return s;
406
- }
407
- function W(e) {
408
- return (e ?? []).reduce((e, t) => e + t, 0);
409
- }
410
- function xe(e, t) {
411
- let n = e.bands.find((e) => e.type === t);
412
- if (!n?.items) return 0;
413
- let r = 0;
414
- for (let e of n.items) {
415
- let t = e.type === "text" ? ve(e) : 0;
416
- r = Math.max(r, (e.y ?? 0) + t);
417
- }
418
- return Math.max(n.height ?? 0, r);
419
- }
420
- //#endregion
421
517
  //#region src/engine/regions.js
422
- var Se = {
518
+ var Ae = {
423
519
  pageHeader: "10%",
424
520
  reportHeader: "10%",
425
521
  reportFooter: "10%",
426
522
  pageFooter: "10%"
427
- }, Ce = ["pageHeader", "reportHeader"], we = ["reportFooter", "pageFooter"];
428
- function Te(e, t, n) {
429
- let r = Ee(e, t);
430
- return r === null ? Ee(n, t) ?? 0 : r;
523
+ }, je = ["pageHeader", "reportHeader"], Me = ["reportFooter", "pageFooter"];
524
+ function Ne(e, t, n) {
525
+ let r = Pe(e, t);
526
+ return r === null ? Pe(n, t) ?? 0 : r;
431
527
  }
432
- function Ee(e, t) {
528
+ function Pe(e, t) {
433
529
  if (typeof e == "number" && Number.isFinite(e) && e >= 0) return e;
434
530
  if (typeof e == "string") {
435
531
  let n = e.trim().match(/^(-?[\d.]+)\s*%$/);
@@ -444,12 +540,12 @@ function Ee(e, t) {
444
540
  }
445
541
  function G(e, t) {
446
542
  if (!e) return 0;
447
- let n = Te(e.height, t, Se[e.type]), r = e.measuredHeight ?? 0;
543
+ let n = Ne(e.height, t, Ae[e.type]), r = e.measuredHeight ?? 0;
448
544
  return r > n ? (console.warn(`Band "${e.type}" needs ${Math.ceil(r)}px but its zone is ${Math.round(n)}px; the zone has been grown to fit.`), r) : n;
449
545
  }
450
- function De({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
546
+ function Fe({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
451
547
  let i = {}, a = (e) => e === "reportHeader" ? n : e !== "reportFooter" || r, o = 0;
452
- for (let n of Ce) {
548
+ for (let n of je) {
453
549
  let r = e[n];
454
550
  if (!r || !a(n)) continue;
455
551
  let s = G(r, t);
@@ -459,7 +555,7 @@ function De({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
459
555
  }, o += s;
460
556
  }
461
557
  let s = o, c = t;
462
- for (let n of [...we].reverse()) {
558
+ for (let n of [...Me].reverse()) {
463
559
  let r = e[n];
464
560
  if (!r || !a(n)) continue;
465
561
  let o = G(r, t);
@@ -475,12 +571,11 @@ function De({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
475
571
  }
476
572
  //#endregion
477
573
  //#region src/engine/paginate.js
478
- var Oe = /\{([^{}]+)\}/g, ke = ["page", "totalPages"];
479
- function Ae(e) {
574
+ var Ie = /\{([^{}]+)\}/g, Le = ["page", "totalPages"];
575
+ function Re(e) {
480
576
  let t = structuredClone(e), n = {
481
577
  page: t.page,
482
578
  bands: t.bands,
483
- group: t.groupBy,
484
579
  assignedBands: {
485
580
  reportHeader: t.bands.find((e) => e.type === "reportHeader"),
486
581
  reportFooter: t.bands.find((e) => e.type === "reportFooter"),
@@ -491,12 +586,12 @@ function Ae(e) {
491
586
  groupFooter: t.bands.find((e) => e.type === "groupFooter") || null
492
587
  }
493
588
  };
494
- return n.availableHeight = ze(t.page), n.regionsFor = (e, t) => De({
589
+ return n.availableHeight = qe(t.page), n.regionsFor = (e, t) => Fe({
495
590
  bands: n.assignedBands,
496
591
  contentHeight: n.availableHeight,
497
592
  isFirstPage: e === 1,
498
593
  isLastPage: t
499
- }), t.pages = Be(Pe(t.bands.filter((e) => ![
594
+ }), t.pages = Je(He(t.bands.filter((e) => ![
500
595
  "reportHeader",
501
596
  "reportFooter",
502
597
  "pageHeader",
@@ -505,7 +600,7 @@ function Ae(e) {
505
600
  "groupFooter"
506
601
  ].includes(e.type)), n)), t;
507
602
  }
508
- function je(e, t, n, r = Infinity) {
603
+ function ze(e, t, n, r = Infinity) {
509
604
  let i = 0, a = 0;
510
605
  for (; t + a < e.length && a < r;) {
511
606
  let r = i + e[t + a];
@@ -514,111 +609,111 @@ function je(e, t, n, r = Infinity) {
514
609
  }
515
610
  return a;
516
611
  }
517
- function Me(e, t, n) {
518
- return W(e.slice(t, t + n));
612
+ function Be(e, t, n) {
613
+ return k(e.slice(t, t + n));
519
614
  }
520
- function Ne(e, t, n) {
615
+ function Ve(e, t, n) {
521
616
  return Array.isArray(n) && n.length === (t ?? []).length ? n : (t ?? []).map(() => e.rowHeight ?? 0);
522
617
  }
523
- function Pe(e, t) {
524
- let n = [], r = Re(1, t);
618
+ function He(e, t) {
619
+ let n = [], r = Ke(1, t);
525
620
  n.push(r);
526
- let { assignedBands: i, availableHeight: a, group: o } = t, { reportFooter: s, reportHeader: c, groupHeader: l, groupFooter: u, pageHeader: d, pageFooter: f } = i, p = t.regionsFor(2, !1).detail.height;
527
- c && r.regions.detail.height <= 0 && console.warn("The header zones leave no room for detail on page 1. Reduce the reportHeader or pageHeader height.");
528
- let m = 0, h = 0, g = [], _ = () => r.regions.detail.height, v = (e, i, a) => (e.items.length > 0 && r.bands.push(e), r = Re(n.length + 1, t), n.push(r), m = 0, h = a, g = [], {
621
+ let { assignedBands: i, availableHeight: a } = t, { reportFooter: o, reportHeader: s, groupHeader: c, groupFooter: l, pageHeader: u, pageFooter: d } = i, f = t.regionsFor(2, !1).detail.height;
622
+ s && r.regions.detail.height <= 0 && console.warn("The header zones leave no room for detail on page 1. Reduce the reportHeader or pageHeader height.");
623
+ let p = 0, m = 0, h = [], g = () => r.regions.detail.height, _ = (e, i, a) => (e.items.length > 0 && r.bands.push(e), r = Ke(n.length + 1, t), n.push(r), p = 0, m = a, h = [], {
529
624
  ...i,
530
625
  items: []
531
- }), y = (e, t) => {
532
- e.items.push(t), m = Math.max(m, (t.y ?? 0) + (t.measuredHeight ?? 0)), e.measuredHeight = m, r.usedHeight = a - _() + m;
533
- }, b = (e) => {
626
+ }), v = (e, t) => {
627
+ e.items.push(t), p = Math.max(p, (t.y ?? 0) + (t.measuredHeight ?? 0)), e.measuredHeight = p, r.usedHeight = a - g() + p;
628
+ }, y = (e) => {
534
629
  let t = -Infinity, n = -Infinity;
535
- for (let r of g) r.designBottom > e || (t = Math.max(t, r.designBottom), n = Math.max(n, r.actualBottom));
630
+ for (let r of h) r.designBottom > e || (t = Math.max(t, r.designBottom), n = Math.max(n, r.actualBottom));
536
631
  return t === -Infinity ? 0 : n - t;
537
- }, x = (e) => {
538
- let t = e - h;
539
- return t + b(t);
632
+ }, S = (e) => {
633
+ let t = e - m;
634
+ return t + y(t);
540
635
  };
541
636
  for (let t of e) {
542
637
  let e = {
543
638
  ...t,
544
639
  items: []
545
640
  };
546
- h = 0, g = [];
641
+ m = 0, h = [];
547
642
  let n = [...t.items].sort((e, t) => (e.y ?? 0) - (t.y ?? 0));
548
643
  for (let r of n) {
549
- let n = r.y ?? 0, i = x(n) + r.measuredHeight;
550
- if (i > _() && r.type != "table") r.measuredHeight > p ? console.warn(`Item "${r.id}" is ${Math.ceil(r.measuredHeight)}px tall, past the ${p}px detail zone of an empty page; it will overflow.`) : e = v(e, t, n), y(e, {
644
+ let n = r.y ?? 0, i = S(n) + r.measuredHeight;
645
+ if (i > g() && r.type != "table") r.measuredHeight > f ? console.warn(`Item "${r.id}" is ${Math.ceil(r.measuredHeight)}px tall, past the ${f}px detail zone of an empty page; it will overflow.`) : e = _(e, t, n), v(e, {
551
646
  ...structuredClone(r),
552
- y: x(n)
647
+ y: S(n)
553
648
  });
554
- else if (i > _() && r.type == "table") {
555
- let i = n - h;
556
- if (o !== null) {
557
- let a = l?.measuredHeight ?? 0, o = u?.measuredHeight ?? 0, s = r.headerMeasured ?? U(r), c = Math.max(r.rowHeight ?? 0, ...(r.groups ?? []).flatMap((e) => Ne(r, e.rows, e.rowHeights))), d = s + a + c + o;
558
- d <= p || console.warn(`Table "${r.id}": table header + group header + one row + group footer (${d}px) exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`);
559
- let f = (e, t, n, r) => {
649
+ else if (i > g() && r.type == "table") {
650
+ let i = S(n);
651
+ if (r.groups) {
652
+ let a = c?.measuredHeight ?? 0, o = l?.measuredHeight ?? 0, s = r.headerMeasured ?? b(r), u = Math.max(r.rowHeight ?? 0, ...(r.groups ?? []).flatMap((e) => Ve(r, e.rows, e.rowHeights))), d = s + a + u + o;
653
+ d <= f || console.warn(`Table "${r.id}": table header + group header + one row + group footer (${d}px) exceeds the ${f}px printable page. Falling back to one row per page; rows will overflow their page.`);
654
+ let p = (e, t, n, r) => {
560
655
  let i = n - a - s;
561
- return r <= je(e, t, i - o, r) ? r : Math.min(je(e, t, i, r), r - 1);
656
+ return r <= ze(e, t, i - o, r) ? r : Math.min(ze(e, t, i, r), r - 1);
562
657
  }, m = [], h = 0;
563
- for (let c of r.groups) {
564
- let d = 0, g = c.rows.length, b = Ne(r, c.rows, c.rowHeights);
565
- for (; d < g;) {
566
- let x = _() - i - h, S = m.length === 0 && e.items.length === 0 && i === 0 && _() >= p, C = f(b, d, x, g - d);
658
+ for (let u of r.groups) {
659
+ let d = 0, y = u.rows.length, b = Ve(r, u.rows, u.rowHeights);
660
+ for (; d < y;) {
661
+ let x = g() - i - h, S = m.length === 0 && e.items.length === 0 && i === 0 && g() >= f, C = p(b, d, x, y - d);
567
662
  if (C < 1 && S && (C = 1), C < 1) {
568
663
  if (m.length > 0) {
569
664
  let t = structuredClone(r);
570
- t.groups = m, t.y = i, t.measuredHeight = h, y(e, t);
665
+ t.groups = m, t.y = i, t.measuredHeight = h, v(e, t);
571
666
  }
572
- e = v(e, t, n), m = [], h = 0, i = 0;
667
+ e = _(e, t, n), m = [], h = 0, i = 0;
573
668
  continue;
574
669
  }
575
- let w = c.rows.slice(d, d + C), T = b.slice(d, d + C);
670
+ let w = u.rows.slice(d, d + C), T = b.slice(d, d + C);
576
671
  d += w.length;
577
- let E = d < g, D = W(T) + (a + s) + (E ? 0 : o);
672
+ let E = d < y, D = k(T) + (a + s) + (E ? 0 : o);
578
673
  h += D;
579
674
  let O = {
580
- key: c.key,
675
+ key: u.key,
581
676
  rows: w,
582
677
  rowHeights: T,
583
- aggregates: c.aggregates,
678
+ aggregates: u.aggregates,
584
679
  showHeader: !0,
585
680
  showFooter: !E,
586
- headerBand: K(l, c, w[0]),
587
- footerBand: E ? null : K(u, c, w[0])
681
+ headerBand: K(c, u, w[0]),
682
+ footerBand: E ? null : K(l, u, w[0])
588
683
  };
589
684
  m.push(O);
590
685
  }
591
686
  }
592
687
  if (m.length > 0) {
593
688
  let t = structuredClone(r);
594
- t.groups = m, t.y = i, t.measuredHeight = h, y(e, t), m = [];
689
+ t.groups = m, t.y = i, t.measuredHeight = h, v(e, t), m = [];
595
690
  }
596
691
  } else {
597
- let a = r.row.length, o = 0, s = r.headerMeasured ?? U(r), c = Ne(r, r.row, r.rowHeights), l = Math.max(r.rowHeight ?? 0, ...c);
598
- for (p - s >= l || console.warn(`Table "${r.id}": its tallest row is ${Math.ceil(l)}px, which with the ${s}px header exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`); o < a;) {
599
- let l = _() - i, u = je(c, o, l - s, a - o), d = e.items.length === 0 && i === 0 && _() >= p;
692
+ let a = r.row.length, o = 0, s = r.headerMeasured ?? b(r), c = Ve(r, r.row, r.rowHeights), l = Math.max(r.rowHeight ?? 0, ...c);
693
+ for (f - s >= l || console.warn(`Table "${r.id}": its tallest row is ${Math.ceil(l)}px, which with the ${s}px header exceeds the ${f}px printable page. Falling back to one row per page; rows will overflow their page.`); o < a;) {
694
+ let l = g() - i, u = ze(c, o, l - s, a - o), d = e.items.length === 0 && i === 0 && g() >= f;
600
695
  if (u < 1 && d && (u = 1), u < 1) {
601
- e = v(e, t, n), i = 0;
696
+ e = _(e, t, n), i = 0;
602
697
  continue;
603
698
  }
604
699
  u = Math.min(u, a - o);
605
- let f = structuredClone(r), m = r.row.slice(o, o + u), h = Me(c, o, u) + s;
606
- f.row = m, f.rowHeights = c.slice(o, o + u), f.y = i, f.measuredHeight = h, y(e, f), o += m.length, o < a && (e = v(e, t, n), i = 0);
700
+ let p = structuredClone(r), m = r.row.slice(o, o + u), h = Be(c, o, u) + s;
701
+ p.row = m, p.rowHeights = c.slice(o, o + u), p.y = i, p.measuredHeight = h, v(e, p), o += m.length, o < a && (e = _(e, t, n), i = 0);
607
702
  }
608
703
  }
609
704
  } else {
610
705
  let t = r.type === "table" && r.groups ? {
611
706
  ...r,
612
- groups: Ie(r, l, u)
707
+ groups: We(r, c, l)
613
708
  } : r;
614
- y(e, {
709
+ v(e, {
615
710
  ...structuredClone(t),
616
- y: x(n)
711
+ y: S(n)
617
712
  });
618
713
  }
619
714
  let a = [...e.items].reverse().find((e) => e.id === r.id);
620
- a && g.push({
621
- designBottom: n - h + pe(r),
715
+ a && h.push({
716
+ designBottom: n - m + x(r),
622
717
  actualBottom: (a.y ?? 0) + (a.measuredHeight ?? 0)
623
718
  });
624
719
  }
@@ -627,20 +722,20 @@ function Pe(e, t) {
627
722
  items: []
628
723
  });
629
724
  }
630
- if (s) {
631
- let e = G(s, a);
632
- r.usedHeight + e > a && (r = Re(n.length + 1, t), n.push(r)), r.bands.push(structuredClone(s)), r.usedHeight += e;
725
+ if (o) {
726
+ let e = G(o, a);
727
+ r.usedHeight + e > a && (r = Ke(n.length + 1, t), n.push(r)), r.bands.push(structuredClone(o)), r.usedHeight += e;
633
728
  }
634
- let S = n[n.length - 1];
635
- return S.regions = t.regionsFor(S.pageNO, !!s), Fe(n), n;
729
+ let C = n[n.length - 1];
730
+ return C.regions = t.regionsFor(C.pageNO, !!o), Ue(n), n;
636
731
  }
637
- function Fe(e) {
732
+ function Ue(e) {
638
733
  for (let t of e) for (let e of t.bands) {
639
734
  let n = t.regions[e.type] ?? t.regions.detail;
640
735
  e.top = n.top, e.zoneHeight = n.height;
641
736
  }
642
737
  }
643
- function Ie(e, t, n) {
738
+ function We(e, t, n) {
644
739
  return e.groups.map((e) => ({
645
740
  key: e.key,
646
741
  rows: e.rows,
@@ -655,11 +750,11 @@ function Ie(e, t, n) {
655
750
  function K(e, t, n) {
656
751
  if (!e) return null;
657
752
  let r = structuredClone(e);
658
- for (let e of r.items) e.type === "text" && (e.text = (e.text ?? e.value).replace(Oe, (e, r) => Le(e, r.trim(), t, n)));
753
+ for (let e of r.items) e.type === "text" && (e.text = (e.text ?? e.value).replace(Ie, (e, r) => Ge(e, r.trim(), t, n)));
659
754
  return r;
660
755
  }
661
- function Le(e, t, n, r) {
662
- if (ke.includes(t)) return e;
756
+ function Ge(e, t, n, r) {
757
+ if (Le.includes(t)) return e;
663
758
  let i = t.match(/^(\w+)\((.*?)\)$/);
664
759
  if (i) {
665
760
  let [, e, t] = i, r = n.aggregates?.[t]?.[e.trim()];
@@ -668,7 +763,7 @@ function Le(e, t, n, r) {
668
763
  let a = r?.[t];
669
764
  return a == null ? "" : String(a);
670
765
  }
671
- function Re(e, t) {
766
+ function Ke(e, t) {
672
767
  let { pageHeader: n, pageFooter: r, reportHeader: i } = t.assignedBands, a = t.regionsFor(e, !1), o = [];
673
768
  return n && o.push(structuredClone(n)), r && o.push(structuredClone(r)), i && e === 1 && o.push(structuredClone(i)), {
674
769
  pageNO: e,
@@ -677,19 +772,19 @@ function Re(e, t) {
677
772
  usedHeight: t.availableHeight - a.detail.height
678
773
  };
679
774
  }
680
- function ze(e) {
775
+ function qe(e) {
681
776
  return e.height - (e.margin.top + e.margin.bottom);
682
777
  }
683
- function Be(e) {
684
- for (let t of e) for (let n of t.bands) Ve(n, t.pageNO, e.length);
778
+ function Je(e) {
779
+ for (let t of e) for (let n of t.bands) Ye(n, t.pageNO, e.length);
685
780
  return e;
686
781
  }
687
- function Ve(e, t, n) {
782
+ function Ye(e, t, n) {
688
783
  for (let r of e?.items ?? []) {
689
784
  if (r.type === "text") {
690
785
  let e = r.text ?? r.value ?? "";
691
786
  if (!e.includes("{")) continue;
692
- r.text = e.replace(Oe, (e, r) => {
787
+ r.text = e.replace(Ie, (e, r) => {
693
788
  switch (r.trim()) {
694
789
  case "page": return t;
695
790
  case "totalPages": return n;
@@ -698,25 +793,25 @@ function Ve(e, t, n) {
698
793
  });
699
794
  continue;
700
795
  }
701
- if (r.type === "table" && r.groups) for (let e of r.groups) Ve(e.headerBand, t, n), Ve(e.footerBand, t, n);
796
+ if (r.type === "table" && r.groups) for (let e of r.groups) Ye(e.headerBand, t, n), Ye(e.footerBand, t, n);
702
797
  }
703
798
  }
704
799
  //#endregion
705
800
  //#region src/engine/search.js
706
- function He(e, t, { caseSensitive: n = !1 } = {}) {
801
+ function Xe(e, t, { caseSensitive: n = !1 } = {}) {
707
802
  let r = String(t ?? "");
708
803
  if (r === "") return [];
709
804
  let i = [];
710
- for (let t of e ?? []) for (let e of t.bands ?? []) We(e, t.pageNO, e.type, r, n, i);
805
+ for (let t of e ?? []) for (let e of t.bands ?? []) Qe(e, t.pageNO, e.type, r, n, i);
711
806
  return i;
712
807
  }
713
- function Ue(e, t, n) {
714
- return [...new Set(He(e, t, n).map((e) => e.pageNO))];
808
+ function Ze(e, t, n) {
809
+ return [...new Set(Xe(e, t, n).map((e) => e.pageNO))];
715
810
  }
716
- function We(e, t, n, r, i, a) {
811
+ function Qe(e, t, n, r, i, a) {
717
812
  for (let o of e?.items ?? []) {
718
813
  if (o.type === "text") {
719
- qe(a, o.text, {
814
+ tt(a, o.text, {
720
815
  pageNO: t,
721
816
  bandType: n,
722
817
  itemId: o.id,
@@ -724,32 +819,32 @@ function We(e, t, n, r, i, a) {
724
819
  }, r, i);
725
820
  continue;
726
821
  }
727
- o.type === "table" && Ge(o, t, n, r, i, a);
822
+ o.type === "table" && $e(o, t, n, r, i, a);
728
823
  }
729
824
  }
730
- function Ge(e, t, n, r, i, a) {
825
+ function $e(e, t, n, r, i, a) {
731
826
  let o = e.columns ?? [];
732
- if (e.showHeader) for (let s of o) qe(a, s.label, {
827
+ if (e.showHeader) for (let s of o) tt(a, s.label, {
733
828
  pageNO: t,
734
829
  bandType: n,
735
830
  itemId: e.id,
736
831
  field: s.field
737
832
  }, r, i);
738
833
  if (e.row) {
739
- Ke(e.row, o, e.id, t, n, r, i, a);
834
+ et(e.row, o, e.id, t, n, r, i, a);
740
835
  return;
741
836
  }
742
- for (let s of e.groups ?? []) We(s.headerBand, t, "groupHeader", r, i, a), Ke(s.rows, o, e.id, t, n, r, i, a), s.showFooter && We(s.footerBand, t, "groupFooter", r, i, a);
837
+ for (let s of e.groups ?? []) Qe(s.headerBand, t, "groupHeader", r, i, a), et(s.rows, o, e.id, t, n, r, i, a), s.showFooter && Qe(s.footerBand, t, "groupFooter", r, i, a);
743
838
  }
744
- function Ke(e, t, n, r, i, a, o, s) {
745
- for (let c of e ?? []) for (let e of t) qe(s, c?.[e.field], {
839
+ function et(e, t, n, r, i, a, o, s) {
840
+ for (let c of e ?? []) for (let e of t) tt(s, c?.[e.field], {
746
841
  pageNO: r,
747
842
  bandType: i,
748
843
  itemId: n,
749
844
  field: e.field
750
845
  }, a, o);
751
846
  }
752
- function qe(e, t, n, r, i) {
847
+ function tt(e, t, n, r, i) {
753
848
  if (t == null) return;
754
849
  let a = String(t), o = i ? a : a.toLowerCase(), s = i ? r : r.toLowerCase(), c = 0;
755
850
  for (; c <= o.length - s.length;) {
@@ -765,36 +860,36 @@ function qe(e, t, n, r, i) {
765
860
  }
766
861
  //#endregion
767
862
  //#region src/engine/csv.js
768
- var Je = /^[=+\-@\t\r]/;
769
- function Ye(e, t = {}) {
770
- let { delimiter: n = ",", newline: r = "\r\n", header: i = !0, groupColumn: a = !0, groupLabel: o = "Group", neutraliseFormulas: s = !0 } = t, c = nt(e);
771
- if (!c) return "";
772
- let l = a && c.rows.some((e) => e.group !== null), u = c.columns.map((e) => e.label ?? e.field), d = [];
773
- i && d.push(rt(l ? [o, ...u] : u, n, s));
774
- for (let { group: e, row: t } of c.rows) {
775
- let r = c.columns.map((e) => t?.[e.field]);
776
- d.push(rt(l ? [e, ...r] : r, n, s));
777
- }
778
- return d.join(r);
779
- }
780
- function Xe(e, t = {}) {
863
+ var nt = /^[=+\-@\t\r]/;
864
+ function rt(e, t = {}) {
865
+ let { delimiter: n = ",", newline: r = "\r\n", header: i = !0, groupColumn: a = !0, groupLabel: o = "Group", neutraliseFormulas: s = !0, table: c = null } = t, l = dt(e, c);
866
+ if (!l) return "";
867
+ let u = a && l.rows.some((e) => e.group !== null), d = l.columns.map((e) => e.label ?? e.field), f = [];
868
+ i && f.push(ft(u ? [o, ...d] : d, n, s));
869
+ for (let { group: e, row: t } of l.rows) {
870
+ let r = l.columns.map((e) => t?.[e.field]);
871
+ f.push(ft(u ? [e, ...r] : r, n, s));
872
+ }
873
+ return f.join(r);
874
+ }
875
+ function it(e, t = {}) {
781
876
  let { delimiter: n = ",", newline: r = "\r\n", neutraliseFormulas: i = !0 } = t, a = [];
782
- for (let t of e ?? []) for (let e of Ze(t?.bands)) Qe(e, a);
783
- return a.length === 0 ? "" : a.map((e) => rt(e, n, i)).join(r);
877
+ for (let t of e ?? []) for (let e of at(t?.bands)) ot(e, a);
878
+ return a.length === 0 ? "" : a.map((e) => ft(e, n, i)).join(r);
784
879
  }
785
- function Ze(e) {
880
+ function at(e) {
786
881
  return [...e ?? []].sort((e, t) => (e?.top ?? 0) - (t?.top ?? 0));
787
882
  }
788
- function Qe(e, t) {
883
+ function ot(e, t) {
789
884
  let n = (e?.items ?? []).filter((e) => e?.type === "text" || e?.type === "table").sort((e, t) => (e.y ?? 0) - (t.y ?? 0) || (e.x ?? 0) - (t.x ?? 0)), r = null, i = () => {
790
885
  r && t.push(r.cells), r = null;
791
886
  };
792
887
  for (let e of n) {
793
888
  if (e.type === "table") {
794
- i(), et(e, t);
889
+ i(), ct(e, t);
795
890
  continue;
796
891
  }
797
- if (r && $e(r.anchor, e)) {
892
+ if (r && st(r.anchor, e)) {
798
893
  r.cells.push(e.text);
799
894
  continue;
800
895
  }
@@ -805,14 +900,14 @@ function Qe(e, t) {
805
900
  }
806
901
  i();
807
902
  }
808
- function $e(e, t) {
903
+ function st(e, t) {
809
904
  let n = (e) => {
810
905
  let t = e.y ?? 0;
811
906
  return [t, t + (e.measuredHeight ?? e.h ?? 0)];
812
907
  }, [r, i] = n(e), [a, o] = n(t);
813
908
  return Math.min(i, o) - Math.max(r, a) >= Math.min(i - r, o - a) / 2;
814
909
  }
815
- function et(e, t) {
910
+ function ct(e, t) {
816
911
  let n = () => e.columns.map((e) => e.label ?? e.field), r = (t) => e.columns.map((e) => t?.[e.field]);
817
912
  if (!e.groups) {
818
913
  e.showHeader && t.push(n());
@@ -820,46 +915,54 @@ function et(e, t) {
820
915
  return;
821
916
  }
822
917
  for (let i of e.groups) {
823
- i.showHeader && e.showHeader && t.push(n()), i.headerBand && Qe(i.headerBand, t);
918
+ i.showHeader && e.showHeader && t.push(n()), i.headerBand && ot(i.headerBand, t);
824
919
  for (let e of i.rows) t.push(r(e));
825
- i.showFooter && i.footerBand && Qe(i.footerBand, t);
920
+ i.showFooter && i.footerBand && ot(i.footerBand, t);
826
921
  }
827
922
  }
828
- function tt(e, t = "csv") {
923
+ function lt(e, t = "csv") {
829
924
  return `${String(e?.name ?? "report").replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim() || "report"}.${t}`;
830
925
  }
831
- function nt(e) {
832
- let t = null, n = null, r = [];
833
- for (let i of e ?? []) for (let e of i.bands ?? []) for (let i of e.items ?? []) if (i.type === "table" && !(n !== null && i.id !== n)) {
834
- if (t === null && (n = i.id, t = i.columns ?? []), i.row) {
835
- for (let e of i.row) r.push({
926
+ function ut(e) {
927
+ let t = /* @__PURE__ */ new Map();
928
+ for (let n of e ?? []) for (let e of n.bands ?? []) for (let n of e.items ?? []) n.type !== "table" || t.has(n.id) || t.set(n.id, {
929
+ id: n.id,
930
+ columns: (n.columns ?? []).map((e) => e.label ?? e.field)
931
+ });
932
+ return [...t.values()];
933
+ }
934
+ function dt(e, t = null) {
935
+ let n = null, r = t, i = [];
936
+ for (let t of e ?? []) for (let e of t.bands ?? []) for (let t of e.items ?? []) if (t.type === "table" && !(r !== null && t.id !== r)) {
937
+ if (n === null && (r = t.id, n = t.columns ?? []), t.row) {
938
+ for (let e of t.row) i.push({
836
939
  group: null,
837
940
  row: e
838
941
  });
839
942
  continue;
840
943
  }
841
- for (let e of i.groups ?? []) for (let t of e.rows) r.push({
944
+ for (let e of t.groups ?? []) for (let t of e.rows) i.push({
842
945
  group: e.key,
843
946
  row: t
844
947
  });
845
948
  }
846
- return t === null ? null : {
847
- columns: t,
848
- rows: r
949
+ return n === null ? null : {
950
+ columns: n,
951
+ rows: i
849
952
  };
850
953
  }
851
- function rt(e, t, n) {
852
- return e.map((e) => it(e, t, n)).join(t);
954
+ function ft(e, t, n) {
955
+ return e.map((e) => pt(e, t, n)).join(t);
853
956
  }
854
- function it(e, t, n) {
957
+ function pt(e, t, n) {
855
958
  if (e == null) return "";
856
959
  let r = String(e);
857
- return n && Je.test(r) && (r = `\t${r}`), r.includes(t) || r.includes("\"") || r.includes("\n") || r.includes("\r") ? `"${r.replace(/"/g, "\"\"")}"` : r;
960
+ return n && nt.test(r) && (r = `\t${r}`), r.includes(t) || r.includes("\"") || r.includes("\n") || r.includes("\r") ? `"${r.replace(/"/g, "\"\"")}"` : r;
858
961
  }
859
962
  //#endregion
860
963
  //#region src/engine/index.js
861
- function at(e, t) {
862
- return Ae(me(E(x(e, t), t)));
964
+ function mt(e, t) {
965
+ return Re(S(he(le(e, t), t)));
863
966
  }
864
967
  //#endregion
865
968
  //#region src/render/items.js
@@ -876,18 +979,19 @@ function Y(e, t = "") {
876
979
  function X(e) {
877
980
  return e == null ? "" : String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
878
981
  }
879
- function ot(e) {
982
+ function ht(e) {
880
983
  return (e || []).map((e) => {
881
984
  switch (e.type) {
882
- case "text": return st(e);
883
- case "table": return ht(e);
884
- case "line": return ut(e);
885
- case "box": return ct(e);
985
+ case "text": return gt(e);
986
+ case "table": return kt(e);
987
+ case "line": return wt(e);
988
+ case "box": return _t(e);
989
+ case "image": return St(e);
886
990
  default: return console.warn(`Unknown item type "${e?.type}"; it is not drawn.`), "";
887
991
  }
888
992
  }).join("");
889
993
  }
890
- function st(e) {
994
+ function gt(e) {
891
995
  let t = e.style ?? {};
892
996
  return `
893
997
  <p id="${X(e.id)}" style="
@@ -903,8 +1007,8 @@ function st(e) {
903
1007
  " data-item-id="${X(e.id)}" data-item-type="text">${X(e.text)}</p>
904
1008
  `;
905
1009
  }
906
- function ct(e) {
907
- let t = e.style ?? {}, n = `${Math.max(0, Number(t.borderWidth ?? 1)) || 1}px ${ft.includes(t.borderStyle) ? t.borderStyle : "solid"} ${Y(t.borderColor, "#000000")}`, r = Math.max(0, Number(t.radius ?? 0)) || 0, i = Y(t.background);
1010
+ function _t(e) {
1011
+ let t = e.style ?? {}, n = `${Math.max(0, Number(t.borderWidth ?? 1)) || 1}px ${Et.includes(t.borderStyle) ? t.borderStyle : "solid"} ${Y(t.borderColor, "#000000")}`, r = Math.max(0, Number(t.radius ?? 0)) || 0, i = Y(t.background);
908
1012
  return `
909
1013
  <div id="${X(e.id)}" class="box" style="
910
1014
  width:${J(e.w)}px;
@@ -916,11 +1020,44 @@ function ct(e) {
916
1020
  " data-item-id="${X(e.id)}" data-item-type="box"></div>
917
1021
  `;
918
1022
  }
919
- function lt(e) {
920
- return `${Math.max(0, Number(e?.thickness ?? 1)) || 1}px ${dt.includes(e?.lineStyle) ? e.lineStyle : "solid"} ${Y(e?.color, "#000000")}`;
1023
+ var vt = [
1024
+ "contain",
1025
+ "cover",
1026
+ "fill"
1027
+ ], yt = /^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]*$/i, bt = [
1028
+ "http:",
1029
+ "https:",
1030
+ "blob:"
1031
+ ];
1032
+ function xt(e) {
1033
+ if (typeof e != "string") return "";
1034
+ let t = e.trim();
1035
+ if (t === "") return "";
1036
+ let n = t.replace(/[\u0000-\u0020\u007f]+/g, "");
1037
+ if (/^data:/i.test(n)) return yt.test(n) ? n : "";
1038
+ let r = n.match(/^([a-z][a-z0-9+.-]*:)/i)?.[1]?.toLowerCase();
1039
+ return r == null || bt.includes(r) ? t : "";
1040
+ }
1041
+ function St(e) {
1042
+ let t = Object.prototype.hasOwnProperty.call(e, "resolvedSrc"), n = xt(t ? e.resolvedSrc : e.src), r = vt.includes(e.fit) ? e.fit : "contain", i = "";
1043
+ if (n) i = `<img src="${X(n)}" alt="${X(e.alt ?? "")}" style="object-fit:${r}" draggable="false">`;
1044
+ else if (!t) {
1045
+ let t = typeof e.field == "string" ? e.field.trim() : "";
1046
+ i = `<span class="image-empty">${t ? X(`{${t}}`) : "Image"}</span>`;
1047
+ }
1048
+ return `
1049
+ <div id="${X(e.id)}" class="image" style="
1050
+ width:${J(e.w)}px;
1051
+ height:${J(e.h)}px;
1052
+ ${q(e)}
1053
+ " data-item-id="${X(e.id)}" data-item-type="image">${i}</div>
1054
+ `;
1055
+ }
1056
+ function Ct(e) {
1057
+ return `${Math.max(0, Number(e?.thickness ?? 1)) || 1}px ${Tt.includes(e?.lineStyle) ? e.lineStyle : "solid"} ${Y(e?.color, "#000000")}`;
921
1058
  }
922
- function ut(e) {
923
- let t = e.orientation === "vertical", n = lt(e.style);
1059
+ function wt(e) {
1060
+ let t = e.orientation === "vertical", n = Ct(e.style);
924
1061
  return `
925
1062
  <div id="${X(e.id)}" class="line${t ? " is-vertical" : ""}" style="
926
1063
  width:${J(e.w)}px;
@@ -930,106 +1067,106 @@ function ut(e) {
930
1067
  style="${t ? `border-left:${n}` : `border-top:${n}`}"></span></div>
931
1068
  `;
932
1069
  }
933
- var dt = [
1070
+ var Tt = [
934
1071
  "solid",
935
1072
  "dashed",
936
1073
  "dotted",
937
1074
  "double"
938
- ], ft = [...dt, "none"];
939
- function pt(e) {
1075
+ ], Et = [...Tt, "none"];
1076
+ function Dt(e) {
940
1077
  let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
941
1078
  return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
942
1079
  }
943
- function mt(e) {
1080
+ function Ot(e) {
944
1081
  let t = e.style ?? {}, n = [];
945
- ft.includes(t.borderStyle) && n.push(`--rs-rule-style:${t.borderStyle}`), t.borderColor && n.push(`--rs-rule-color:${Y(t.borderColor)}`), t.headerBackground && n.push(`--rs-head-bg:${Y(t.headerBackground)}`), t.headerColor && n.push(`--rs-head-color:${Y(t.headerColor)}`), t.fontFamily && n.push(`--rs-cell-family:${Y(t.fontFamily)}`);
1082
+ Et.includes(t.borderStyle) && n.push(`--rs-rule-style:${t.borderStyle}`), t.borderColor && n.push(`--rs-rule-color:${Y(t.borderColor)}`), t.headerBackground && n.push(`--rs-head-bg:${Y(t.headerBackground)}`), t.headerColor && n.push(`--rs-head-color:${Y(t.headerColor)}`), t.fontFamily && n.push(`--rs-cell-family:${Y(t.fontFamily)}`);
946
1083
  let r = Number(t.fontSize);
947
1084
  Number.isFinite(r) && r > 0 && n.push(`--rs-cell-size:${r}px`), t.color && n.push(`--rs-cell-color:${Y(t.color)}`), e.wrap === !1 && n.push("--rs-cell-wrap:nowrap");
948
1085
  let i = Number(t.borderWidth);
949
- return Number.isFinite(i) && i > 0 && n.push(`--rs-rule-width:${Math.min(i, pt(e))}px`), n.length ? `${n.join(";")};` : "";
1086
+ return Number.isFinite(i) && i > 0 && n.push(`--rs-rule-width:${Math.min(i, Dt(e))}px`), n.length ? `${n.join(";")};` : "";
950
1087
  }
951
- function ht(e) {
1088
+ function kt(e) {
952
1089
  return `
953
- <table id="${X(e.id)}" style="width:${J(e.w)}px;height:${J(e.measuredHeight)}px;${q(e)}${mt(e)}" data-item-id="${X(e.id)}" data-item-type="table">
954
- ${e.groups ? xt(e) : bt(e)}
1090
+ <table id="${X(e.id)}" style="width:${J(e.w)}px;height:${J(e.measuredHeight)}px;${q(e)}${Ot(e)}" data-item-id="${X(e.id)}" data-item-type="table">
1091
+ ${e.groups ? Ft(e) : Pt(e)}
955
1092
  </table>
956
1093
  `;
957
1094
  }
958
- function gt(e, t, n) {
1095
+ function At(e, t, n) {
959
1096
  return `<div class="cell" style="height:${J(e)}px;text-align:${Y(t, "left")}">${X(n)}</div>`;
960
1097
  }
961
- function _t(e) {
1098
+ function jt(e) {
962
1099
  let t = e.headerMeasured ?? e.headerHeight ?? e.rowHeight;
963
1100
  return `<thead>
964
1101
  <tr style="height:${J(t)}px">
965
- ${e.columns.map((e) => `<th style="width:${J(e.width)}px;">${gt(t, e.align, e.label)}</th>`).join("")}
1102
+ ${e.columns.map((e) => `<th style="width:${J(e.width)}px;">${At(t, e.align, e.label)}</th>`).join("")}
966
1103
  </tr>
967
1104
  </thead>`;
968
1105
  }
969
- function vt(e, t, n) {
1106
+ function Mt(e, t, n) {
970
1107
  return (t || []).map((t, r) => {
971
1108
  let i = n?.[r] ?? e.rowHeight;
972
1109
  return `<tr style="height:${J(i)}px">
973
- ${e.columns.map((e) => `<td style="width:${J(e.width)}px;">${gt(i, e.align, t[e.field])}</td>`).join("")}
1110
+ ${e.columns.map((e) => `<td style="width:${J(e.width)}px;">${At(i, e.align, t[e.field])}</td>`).join("")}
974
1111
  </tr>`;
975
1112
  }).join("");
976
1113
  }
977
- function yt(e, t, n) {
1114
+ function Nt(e, t, n) {
978
1115
  return e ? `<tr class="${n}">
979
1116
  <td colspan="${t}" class="group-band-cell">
980
- <div class="band" style="position:relative;height:${J(e.measuredHeight > 0 ? e.measuredHeight : e.height ?? 0)}px">${ot(e.items)}</div>
1117
+ <div class="band" style="position:relative;height:${J(e.measuredHeight > 0 ? e.measuredHeight : e.height ?? 0)}px">${ht(e.items)}</div>
981
1118
  </td>
982
1119
  </tr>` : "";
983
1120
  }
984
- function bt(e) {
1121
+ function Pt(e) {
985
1122
  return `
986
- ${e.showHeader ? _t(e) : ""}
1123
+ ${e.showHeader ? jt(e) : ""}
987
1124
  <tbody>
988
- ${vt(e, e.row, e.rowHeights)}
1125
+ ${Mt(e, e.row, e.rowHeights)}
989
1126
  </tbody>
990
1127
  `;
991
1128
  }
992
- function xt(e) {
1129
+ function Ft(e) {
993
1130
  let t = e.columns.length;
994
1131
  return e.groups.map((n) => `
995
- ${n.showHeader && e.showHeader ? _t(e) : ""}
1132
+ ${n.showHeader && e.showHeader ? jt(e) : ""}
996
1133
  <tbody>
997
- ${yt(n.headerBand, t, "group-header")}
998
- ${vt(e, n.rows, n.rowHeights)}
999
- ${n.showFooter ? yt(n.footerBand, t, "group-footer") : ""}
1134
+ ${Nt(n.headerBand, t, "group-header")}
1135
+ ${Mt(e, n.rows, n.rowHeights)}
1136
+ ${n.showFooter ? Nt(n.footerBand, t, "group-footer") : ""}
1000
1137
  </tbody>
1001
1138
  `).join("");
1002
1139
  }
1003
1140
  //#endregion
1004
1141
  //#region src/render/render.js
1005
- var St = (e) => `padding-top:${J(e?.top)}px;padding-left:${J(e?.left)}px;padding-bottom:${J(e?.bottom)}px;padding-right:${J(e?.right)}px;`, Ct = [
1142
+ var It = (e) => `padding-top:${J(e?.top)}px;padding-left:${J(e?.left)}px;padding-bottom:${J(e?.bottom)}px;padding-right:${J(e?.right)}px;`, Lt = [
1006
1143
  "pageHeader",
1007
1144
  "reportHeader",
1008
1145
  "detail",
1009
1146
  "reportFooter",
1010
1147
  "pageFooter"
1011
1148
  ];
1012
- function wt(e) {
1149
+ function Rt(e) {
1013
1150
  let t = e.page;
1014
1151
  return `
1015
1152
  <main id="main-page">
1016
1153
  ${e.pages.map((e) => `
1017
- <section id="page-${X(e.pageNO)}" class="page" style="height:${J(t.height)}px; width:${J(t.width)}px; ${St(t.margin)};position:relative">
1018
- ${Tt(e, t)}
1154
+ <section id="page-${X(e.pageNO)}" class="page" style="height:${J(t.height)}px; width:${J(t.width)}px; ${It(t.margin)};position:relative">
1155
+ ${zt(e, t)}
1019
1156
  </section>
1020
1157
  `).join("")}
1021
1158
  </main>
1022
1159
  `;
1023
1160
  }
1024
- function Tt(e, t) {
1161
+ function zt(e, t) {
1025
1162
  let n = (e) => {
1026
- let t = Ct.indexOf(e);
1027
- return t === -1 ? Ct.length : t;
1163
+ let t = Lt.indexOf(e);
1164
+ return t === -1 ? Lt.length : t;
1028
1165
  }, r = [...e.bands].sort(({ type: e }, { type: t }) => n(e) - n(t)), i = [];
1029
- for (let n of r) i.push(Et(n, e.pageNO, t));
1166
+ for (let n of r) i.push(Bt(n, e.pageNO, t));
1030
1167
  return i.join("");
1031
1168
  }
1032
- function Et(e, t, n) {
1169
+ function Bt(e, t, n) {
1033
1170
  let r = Number.isFinite(e.top), i = n?.margin ?? {
1034
1171
  top: 0,
1035
1172
  left: 0,
@@ -1037,14 +1174,14 @@ function Et(e, t, n) {
1037
1174
  }, a = r ? `position:absolute;top:${J(e.top) + J(i.top)}px;left:${J(i.left)}px;right:${J(i.right)}px;` : "position:relative;", o = Math.max(e.zoneHeight ?? 0, e.measuredHeight ?? 0);
1038
1175
  return `
1039
1176
  <div class="band" id="${X(e.type)}-${X(t)}" style="${a}${o > 0 ? `height:${J(o)}px` : ""}" data-band-type="${X(e.type)}">
1040
- ${ot(e.items)}
1177
+ ${ht(e.items)}
1041
1178
  </div>
1042
1179
  `;
1043
1180
  }
1044
1181
  //#endregion
1045
1182
  //#region src/shared/window.js
1046
- var Dt = 1280, Ot = 900;
1047
- function kt(e, t) {
1183
+ var Vt = 1280, Ht = 900;
1184
+ function Ut(e, t) {
1048
1185
  for (let n of e.querySelectorAll("link[rel=\"stylesheet\"], style")) {
1049
1186
  if (n.tagName === "LINK") {
1050
1187
  let e = t.createElement("link");
@@ -1055,11 +1192,11 @@ function kt(e, t) {
1055
1192
  e.textContent = n.textContent, t.head.appendChild(e);
1056
1193
  }
1057
1194
  }
1058
- function At({ title: e = "Report Studio", width: t = Dt, height: n = Ot, features: r, opener: i = globalThis } = {}) {
1195
+ function Wt({ title: e = "Report Studio", width: t = Vt, height: n = Ht, features: r, opener: i = globalThis } = {}) {
1059
1196
  let a = r ?? `width=${t},height=${n},resizable=yes,scrollbars=yes`, o = i.open?.("", "_blank", a);
1060
1197
  if (!o || !o.document) return null;
1061
1198
  let s = o.document;
1062
- s.open(), s.write("<!doctype html><html><head><meta charset=\"utf-8\"></head><body></body></html>"), s.close(), s.title = e, kt(i.document, s);
1199
+ s.open(), s.write("<!doctype html><html><head><meta charset=\"utf-8\"></head><body></body></html>"), s.close(), s.title = e, Ut(i.document, s);
1063
1200
  let c = s.createElement("div");
1064
1201
  return c.id = "report-studio", c.style.height = "100vh", s.body.style.margin = "0", s.body.appendChild(c), {
1065
1202
  window: o,
@@ -1068,7 +1205,7 @@ function At({ title: e = "Report Studio", width: t = Dt, height: n = Ot, feature
1068
1205
  close: () => o.close()
1069
1206
  };
1070
1207
  }
1071
- function jt(e, t, n = () => {}) {
1208
+ function Gt(e, t, n = () => {}) {
1072
1209
  let r = () => {
1073
1210
  n(), t.close();
1074
1211
  };
@@ -1076,7 +1213,7 @@ function jt(e, t, n = () => {}) {
1076
1213
  }
1077
1214
  //#endregion
1078
1215
  //#region src/shared/dropdown.js
1079
- function Mt(e) {
1216
+ function Kt(e) {
1080
1217
  let t = e.querySelector(".dropdown-trigger"), n = e.querySelector(".dropdown-value"), r = e.querySelector(".dropdown-menu"), i = [...r.querySelectorAll(".dropdown-item")], a = /* @__PURE__ */ new Set(), o = () => t.ownerDocument, s = i.find((e) => e.dataset.selected === "true")?.dataset.value ?? i[0]?.dataset.value ?? "", c = Math.max(i.findIndex((e) => e.dataset.value === s), 0);
1081
1218
  function l() {
1082
1219
  i.forEach((e, t) => {
@@ -1156,7 +1293,7 @@ function Mt(e) {
1156
1293
  }
1157
1294
  //#endregion
1158
1295
  //#region src/preview/chrome.js
1159
- function Nt({ title: e = "Report Studio" } = {}) {
1296
+ function qt({ title: e = "Report Studio" } = {}) {
1160
1297
  return `
1161
1298
  <!--
1162
1299
  A header, not role="toolbar": that role promises arrow-key roving focus
@@ -1294,20 +1431,20 @@ var Z = [
1294
1431
  2,
1295
1432
  3
1296
1433
  ], Q = Z[0], $ = Z[Z.length - 1];
1297
- function Pt({ paginated: e, title: t, width: n, height: r, features: i, ...a } = {}) {
1298
- let o = At({
1434
+ function Jt({ paginated: e, title: t, width: n, height: r, features: i, ...a } = {}) {
1435
+ let o = Wt({
1299
1436
  title: t ?? "Report",
1300
1437
  width: n,
1301
1438
  height: r,
1302
1439
  features: i
1303
1440
  });
1304
1441
  if (!o) return null;
1305
- let s = Ft({
1442
+ let s = Yt({
1306
1443
  ...a,
1307
1444
  mount: o.mount,
1308
1445
  paginated: e,
1309
1446
  title: t
1310
- }), c = jt(globalThis, o.window, s.destroy);
1447
+ }), c = Gt(globalThis, o.window, s.destroy);
1311
1448
  return {
1312
1449
  ...s,
1313
1450
  window: o.window,
@@ -1316,20 +1453,20 @@ function Pt({ paginated: e, title: t, width: n, height: r, features: i, ...a } =
1316
1453
  }
1317
1454
  };
1318
1455
  }
1319
- function Ft({ mount: e, paginated: t, title: n } = {}) {
1456
+ function Yt({ mount: e, paginated: t, title: n } = {}) {
1320
1457
  let r = typeof e == "string" ? document.querySelector(e) : e;
1321
1458
  if (!r) throw Error(`createViewer: no element for mount ${JSON.stringify(e)}. Add <div id="report"></div> to the page first.`);
1322
1459
  let i = r.ownerDocument, a = i.defaultView ?? globalThis;
1323
1460
  if (!t?.pages) throw Error("createViewer: paginated must be a buildPages(layout, data) result.");
1324
- r.classList.add("report-viewer"), r.innerHTML = Nt({ title: n });
1461
+ r.classList.add("report-viewer"), r.innerHTML = qt({ title: n });
1325
1462
  let o = r.querySelector("[data-role=\"viewport\"]");
1326
- o.innerHTML = wt(t);
1463
+ o.innerHTML = Rt(t);
1327
1464
  let s = [...o.querySelectorAll(".page")], c = s.length, l = o.querySelector("#main-page"), u = o, d = r.querySelector("[data-role=\"export-modal\"]"), f = (e) => r.querySelector(`[data-role="${e}"]`), p = {
1328
1465
  prev: f("prev"),
1329
1466
  next: f("next"),
1330
1467
  current: f("current"),
1331
1468
  total: f("total"),
1332
- zoom: Mt(f("zoom-dropdown")),
1469
+ zoom: Kt(f("zoom-dropdown")),
1333
1470
  zoomIn: f("zoom-in"),
1334
1471
  zoomOut: f("zoom-out"),
1335
1472
  print: f("print"),
@@ -1349,7 +1486,7 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1349
1486
  } : null, h = 0, g = [], _ = -1, v = 1, y = !1, b = null, x = a.onafterprint !== void 0;
1350
1487
  p.total.textContent = String(c), p.current.max = String(c);
1351
1488
  function S(e) {
1352
- h = Math.min(Math.max(e, 0), c - 1), s.forEach((e, t) => e.classList.toggle("is-current", t === h)), p.current.value = String(h + 1), p.prev.disabled = h === 0, p.next.disabled = h === c - 1, B(), u.scrollTo?.({ top: 0 });
1489
+ h = Math.min(Math.max(e, 0), c - 1), s.forEach((e, t) => e.classList.toggle("is-current", t === h)), p.current.value = String(h + 1), p.prev.disabled = h === 0, p.next.disabled = h === c - 1, V(), u.scrollTo?.({ top: 0 });
1353
1490
  }
1354
1491
  function C() {
1355
1492
  if (u.style.setProperty("--zoom", String(v)), l && (l.style.width = `${t.page.width * v}px`, l.style.height = `${t.page.height * v}px`), !y) {
@@ -1377,33 +1514,41 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1377
1514
  run: () => O()
1378
1515
  },
1379
1516
  csv: {
1380
- available: () => Xe(t.pages) !== "",
1381
- summary: () => D.csv.available() ? `Downloads ${tt(t, "csv")}.` : "This report has nothing to write out.",
1382
- run: () => A()
1517
+ available: () => it(t.pages) !== "",
1518
+ summary: () => D.csv.available() ? `Downloads ${lt(t, "csv")}.` : "This report has nothing to write out.",
1519
+ run: () => j()
1383
1520
  }
1384
1521
  };
1385
1522
  function O() {
1386
- z(), a.print(), x || k();
1523
+ let e = [...o.querySelectorAll("img")].filter((e) => !e.complete);
1524
+ if (e.length > 0) {
1525
+ Promise.all(e.map((e) => e.decode().catch(() => {}))).then(k);
1526
+ return;
1527
+ }
1528
+ k();
1387
1529
  }
1388
1530
  function k() {
1389
- p.query.value.trim() !== "" && B();
1531
+ B(), a.print(), x || A();
1532
+ }
1533
+ function A() {
1534
+ p.query.value.trim() !== "" && V();
1390
1535
  }
1391
1536
  function ee() {
1392
1537
  let { width: e, height: n } = t.page, r = i.getElementById("report-page-size");
1393
1538
  r || (r = i.createElement("style"), r.id = "report-page-size", i.head.appendChild(r)), r.textContent = `@page { size: ${e}px ${n}px; margin: 0; }`;
1394
1539
  }
1395
- function A() {
1396
- let e = Xe(t.pages);
1397
- return e === "" ? !1 : (te(new Blob(["", e], { type: "text/csv;charset=utf-8" }), tt(t, "csv")), !0);
1540
+ function j() {
1541
+ let e = it(t.pages);
1542
+ return e === "" ? !1 : (te(new Blob(["", e], { type: "text/csv;charset=utf-8" }), lt(t, "csv")), !0);
1398
1543
  }
1399
1544
  function te(e, t) {
1400
1545
  let n = URL.createObjectURL(e), r = i.createElement("a");
1401
1546
  r.href = n, r.download = t, i.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
1402
1547
  }
1403
- function ne() {
1548
+ function M() {
1404
1549
  return m?.formats.find((e) => e.checked)?.value ?? "pdf";
1405
1550
  }
1406
- function j() {
1551
+ function N() {
1407
1552
  if (!m) return;
1408
1553
  for (let e of m.formats) {
1409
1554
  let t = D[e.value];
@@ -1413,55 +1558,55 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1413
1558
  let e = m.formats.find((e) => !e.disabled);
1414
1559
  e && (e.checked = !0);
1415
1560
  }
1416
- let e = D[ne()];
1561
+ let e = D[M()];
1417
1562
  m.summary.textContent = e ? e.summary() : "", m.confirm.disabled = !e || !e.available();
1418
1563
  }
1419
- function M() {
1420
- m && (b = i.activeElement, m.root.hidden = !1, j(), (m.formats.find((e) => e.checked && !e.disabled) ?? m.formats.find((e) => !e.disabled) ?? m.cancel).focus());
1564
+ function P() {
1565
+ m && (b = i.activeElement, m.root.hidden = !1, N(), (m.formats.find((e) => e.checked && !e.disabled) ?? m.formats.find((e) => !e.disabled) ?? m.cancel).focus());
1421
1566
  }
1422
- function N() {
1567
+ function F() {
1423
1568
  !m || m.root.hidden || (m.root.hidden = !0, b?.focus?.(), b = null);
1424
1569
  }
1425
- function P() {
1426
- let e = D[ne()];
1427
- e?.available() && (N(), e.run());
1570
+ function I() {
1571
+ let e = D[M()];
1572
+ e?.available() && (F(), e.run());
1428
1573
  }
1429
- function F(e) {
1574
+ function ne(e) {
1430
1575
  let t = [...m.card.querySelectorAll("button, input")].filter((e) => !e.disabled);
1431
1576
  if (!t.length) return;
1432
1577
  let n = t[0], r = t[t.length - 1];
1433
1578
  e.shiftKey && i.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && i.activeElement === r && (e.preventDefault(), n.focus());
1434
1579
  }
1435
- function I() {
1580
+ function L() {
1436
1581
  let e = p.query.value.trim();
1437
- if (z(), e === "") {
1438
- g = [], _ = -1, p.hits.textContent = "", p.hits.dataset.state = "idle", R();
1582
+ if (B(), e === "") {
1583
+ g = [], _ = -1, p.hits.textContent = "", p.hits.dataset.state = "idle", z();
1439
1584
  return;
1440
1585
  }
1441
- if (g = He(t.pages, e), _ = g.length ? 0 : -1, p.hits.dataset.state = g.length ? "found" : "empty", R(), !g.length) {
1586
+ if (g = Xe(t.pages, e), _ = g.length ? 0 : -1, p.hits.dataset.state = g.length ? "found" : "empty", z(), !g.length) {
1442
1587
  p.hits.textContent = "no matches";
1443
1588
  return;
1444
1589
  }
1445
- let n = Ue(t.pages, e).length;
1446
- p.hits.textContent = `${g.length} on ${n} page${n === 1 ? "" : "s"}`, L(0);
1590
+ let n = Ze(t.pages, e).length;
1591
+ p.hits.textContent = `${g.length} on ${n} page${n === 1 ? "" : "s"}`, R(0);
1447
1592
  }
1448
- function L(e) {
1593
+ function R(e) {
1449
1594
  if (!g.length) return;
1450
1595
  _ = (e + g.length) % g.length;
1451
1596
  let t = g[_].pageNO - 1;
1452
- t === h ? B() : S(t), p.hits.textContent = `${_ + 1} of ${g.length}`, ie();
1597
+ t === h ? V() : S(t), p.hits.textContent = `${_ + 1} of ${g.length}`, ie();
1453
1598
  }
1454
- function R() {
1599
+ function z() {
1455
1600
  p.hitPrev.disabled = g.length === 0, p.hitNext.disabled = g.length === 0;
1456
1601
  }
1457
- function z() {
1602
+ function B() {
1458
1603
  for (let e of u.querySelectorAll("mark.hit")) {
1459
1604
  let t = e.parentNode;
1460
1605
  t.replaceChild(i.createTextNode(e.textContent), e), t.normalize();
1461
1606
  }
1462
1607
  }
1463
- function B() {
1464
- z();
1608
+ function V() {
1609
+ B();
1465
1610
  let e = p.query.value.trim();
1466
1611
  if (e === "") return;
1467
1612
  let t = s[h];
@@ -1496,29 +1641,29 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1496
1641
  if (p.prev.addEventListener("click", () => S(h - 1)), p.next.addEventListener("click", () => S(h + 1)), p.current.addEventListener("change", () => {
1497
1642
  let e = Number(p.current.value);
1498
1643
  Number.isFinite(e) ? S(e - 1) : p.current.value = String(h + 1);
1499
- }), p.print?.addEventListener("click", O), p.exportOpen.addEventListener("click", M), m) {
1500
- m.cancel.addEventListener("click", N), m.backdrop.addEventListener("click", N), m.confirm.addEventListener("click", P);
1501
- for (let e of m.formats) e.addEventListener("change", j);
1644
+ }), p.print?.addEventListener("click", O), p.exportOpen.addEventListener("click", P), m) {
1645
+ m.cancel.addEventListener("click", F), m.backdrop.addEventListener("click", F), m.confirm.addEventListener("click", I);
1646
+ for (let e of m.formats) e.addEventListener("change", N);
1502
1647
  m.root.addEventListener("keydown", (e) => {
1503
- e.key === "Tab" && F(e), e.key === "Enter" && (e.preventDefault(), P());
1648
+ e.key === "Tab" && ne(e), e.key === "Enter" && (e.preventDefault(), I());
1504
1649
  });
1505
1650
  }
1506
1651
  p.zoomIn.addEventListener("click", () => E(1)), p.zoomOut.addEventListener("click", () => E(-1)), p.zoom.addEventListener("change", () => {
1507
1652
  p.zoom.value === "fit" ? T() : w(Number(p.zoom.value));
1508
1653
  });
1509
- let ae = () => {
1654
+ let H = () => {
1510
1655
  y && T();
1511
1656
  };
1512
- a.addEventListener("resize", ae), p.hitPrev.addEventListener("click", () => L(_ - 1)), p.hitNext.addEventListener("click", () => L(_ + 1));
1513
- let V;
1657
+ a.addEventListener("resize", H), p.hitPrev.addEventListener("click", () => R(_ - 1)), p.hitNext.addEventListener("click", () => R(_ + 1));
1658
+ let U;
1514
1659
  p.query.addEventListener("input", () => {
1515
- clearTimeout(V), V = setTimeout(I, 150);
1660
+ clearTimeout(U), U = setTimeout(L, 150);
1516
1661
  }), p.query.addEventListener("keydown", (e) => {
1517
- e.key === "Enter" && (e.preventDefault(), g.length ? L(_ + (e.shiftKey ? -1 : 1)) : I());
1662
+ e.key === "Enter" && (e.preventDefault(), g.length ? R(_ + (e.shiftKey ? -1 : 1)) : L());
1518
1663
  });
1519
- let oe = (e) => {
1664
+ let W = (e) => {
1520
1665
  if (m && !m.root.hidden) {
1521
- e.key === "Escape" && (e.preventDefault(), N());
1666
+ e.key === "Escape" && (e.preventDefault(), F());
1522
1667
  return;
1523
1668
  }
1524
1669
  if ((e.ctrlKey || e.metaKey) && ["k", "f"].includes(e.key.toLowerCase())) {
@@ -1531,29 +1676,29 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1531
1676
  }
1532
1677
  if (!(e.target === p.query || e.target === p.current)) {
1533
1678
  if ((e.ctrlKey || e.metaKey) && ["x", "s"].includes(e.key.toLowerCase())) {
1534
- e.preventDefault(), M();
1679
+ e.preventDefault(), P();
1535
1680
  return;
1536
1681
  }
1537
1682
  (e.key === "ArrowRight" || e.key === "PageDown") && S(h + 1), (e.key === "ArrowLeft" || e.key === "PageUp") && S(h - 1), e.key === "Home" && S(0), e.key === "End" && S(c - 1), (e.ctrlKey || e.metaKey) && ((e.key === "+" || e.key === "=") && (e.preventDefault(), E(1)), e.key === "-" && (e.preventDefault(), E(-1)), e.key === "0" && (e.preventDefault(), w(1)));
1538
1683
  }
1539
1684
  };
1540
- i.addEventListener("keydown", oe), x && a.addEventListener("afterprint", k);
1541
- function H() {
1542
- p.zoom.destroy(), i.removeEventListener("keydown", oe), a.removeEventListener("resize", ae), a.removeEventListener("afterprint", k), r.innerHTML = "", r.classList.remove("report-viewer");
1685
+ i.addEventListener("keydown", W), x && a.addEventListener("afterprint", A);
1686
+ function ae() {
1687
+ p.zoom.destroy(), i.removeEventListener("keydown", W), a.removeEventListener("resize", H), a.removeEventListener("afterprint", A), r.innerHTML = "", r.classList.remove("report-viewer");
1543
1688
  }
1544
- return ee(), C(), S(0), R(), {
1689
+ return ee(), C(), S(0), z(), {
1545
1690
  show: S,
1546
1691
  next: () => S(h + 1),
1547
1692
  prev: () => S(h - 1),
1548
1693
  find: (e) => {
1549
- p.query.value = e, I();
1694
+ p.query.value = e, L();
1550
1695
  },
1551
1696
  print: O,
1552
- downloadCSV: A,
1553
- openExport: M,
1554
- closeExport: N,
1555
- confirmExport: P,
1556
- destroy: H,
1697
+ downloadCSV: j,
1698
+ openExport: P,
1699
+ closeExport: F,
1700
+ confirmExport: I,
1701
+ destroy: ae,
1557
1702
  get exportOpen() {
1558
1703
  return m ? !m.root.hidden : !1;
1559
1704
  },
@@ -1573,4 +1718,4 @@ function Ft({ mount: e, paginated: t, title: n } = {}) {
1573
1718
  };
1574
1719
  }
1575
1720
  //#endregion
1576
- export { b as A, L as C, E as D, H as E, a as M, o as N, v as O, me as S, se as T, Ue as _, Pt as a, De as b, At as c, ot as d, at as f, He as g, Xe as h, Ft as i, x as j, y as k, wt as l, Ye as m, Q as n, Mt as o, tt as p, Z as r, jt as s, $ as t, X as u, Ae as v, V as w, pe as x, G as y };
1721
+ export { x as A, he as C, le as D, ce as E, p as F, t as I, r as L, i as M, d as N, F as O, m as P, Fe as S, se as T, it as _, Jt as a, Re as b, Wt as c, xt as d, ht as f, rt as g, ut as h, Yt as i, S as j, I as k, Rt as l, lt as m, Q as n, Kt as o, mt as p, Z as r, Gt as s, $ as t, X as u, Xe as v, oe as w, G as x, Ze as y };