@agile-team/mach-report 2.5.0 → 2.7.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 (86) hide show
  1. package/README.md +126 -16
  2. package/dist/ReportPreview-BdvoqdOd.cjs +6 -0
  3. package/dist/ReportPreview-COFkbeEM.js +3719 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-B9qJku3V.js +160 -0
  11. package/dist/assets-RZan7EyL.cjs +1 -0
  12. package/dist/capabilities-joSutDF8.js +63 -0
  13. package/dist/capabilities-xGTpnPjJ.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +869 -0
  16. package/dist/designer.d.ts +869 -0
  17. package/dist/designer.js +628 -0
  18. package/dist/index.cjs +8 -5
  19. package/dist/index.d.cts +497 -9
  20. package/dist/index.d.ts +497 -9
  21. package/dist/index.js +1088 -1499
  22. package/dist/param-validation-BWNjLcN0.js +116 -0
  23. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  24. package/dist/pdf.cjs +48 -48
  25. package/dist/pdf.d.cts +119 -1
  26. package/dist/pdf.d.ts +119 -1
  27. package/dist/pdf.js +3932 -3868
  28. package/dist/{plugin-DMPLDpBY.cjs → plugin-9t_ZFwhz.cjs} +1 -1
  29. package/dist/{plugin-DDLcFWlk.js → plugin-s8Ay8kKk.js} +2 -2
  30. package/dist/progress-DD964VAB.js +102 -0
  31. package/dist/progress-KvhwXZ1Q.cjs +1 -0
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-BXHNy_AD.js +755 -0
  37. package/dist/report-source-CCAvFE3t.cjs +1 -0
  38. package/dist/server/node.d.cts +320 -0
  39. package/dist/server/node.d.ts +320 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +303 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +668 -0
  44. package/dist/server.d.ts +668 -0
  45. package/dist/server.js +245 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/task-events-DQ276fn2.cjs +1 -0
  50. package/dist/task-events-Dpsvf_t2.js +47 -0
  51. package/dist/template-registry-DWExx0gU.cjs +1 -0
  52. package/dist/template-registry-NpOakidD.js +354 -0
  53. package/dist/textwrap-CnGsEum6.cjs +4 -0
  54. package/dist/textwrap-DOl04hCQ.js +110 -0
  55. package/dist/validate-DfHPD8wX.cjs +1 -0
  56. package/dist/validate-S6CgIm5d.js +148 -0
  57. package/dist/vue/async.d.cts +1507 -1538
  58. package/dist/vue/async.d.ts +1507 -1538
  59. package/dist/vue/index.d.cts +2376 -2347
  60. package/dist/vue/index.d.ts +2376 -2347
  61. package/dist/vue-async.cjs +1 -1
  62. package/dist/vue-async.js +3 -3
  63. package/dist/vue.cjs +1 -1
  64. package/dist/vue.js +184 -75
  65. package/dist/worker.cjs +1 -0
  66. package/dist/worker.d.cts +325 -0
  67. package/dist/worker.d.ts +325 -0
  68. package/dist/worker.js +158 -0
  69. package/dist/xlsx/node.d.cts +47 -0
  70. package/dist/xlsx/node.d.ts +47 -0
  71. package/dist/xlsx-node.cjs +221 -0
  72. package/dist/xlsx-node.js +36409 -0
  73. package/dist/xlsx.cjs +20 -20
  74. package/dist/xlsx.d.cts +87 -2
  75. package/dist/xlsx.d.ts +87 -2
  76. package/dist/xlsx.js +5987 -5840
  77. package/package.json +63 -3
  78. package/dist/ReportPreview-CBKLI--k.js +0 -2188
  79. package/dist/ReportPreview-ClM8h0pM.cjs +0 -6
  80. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  81. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  82. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  83. package/dist/report-params-B3Fia6JO.js +0 -10
  84. package/dist/report-params-D1gZ1DME.cjs +0 -1
  85. package/dist/textwrap-nH0UYU6D.js +0 -108
  86. package/dist/textwrap-oD-t4b4B.cjs +0 -4
package/dist/index.js CHANGED
@@ -1,555 +1,23 @@
1
- import { R as ce, D as qe, L as ve, i as Xe, a as Se, b as xe } from "./render-plan-CXBWRog4.js";
2
- import { c as Zn, d as ei, S as ti } from "./render-plan-CXBWRog4.js";
3
- import { m as R, r as D, a as K, b as ne, c as G, d as ie, e as me, f as Qe, p as Q, g as ke, P as Z } from "./grid-geometry-C8hGoe9o.js";
4
- import { C as ii, M as ri, h as oi, i as ai } from "./grid-geometry-C8hGoe9o.js";
5
- import { h as fe, w as U } from "./textwrap-nH0UYU6D.js";
6
- import { c as li, a as di, b as ci, m as mi } from "./textwrap-nH0UYU6D.js";
7
- import { c as Ze } from "./page-window-index-CIuT4BAv.js";
8
- import { g as et } from "./report-params-B3Fia6JO.js";
9
- import { f as tt, i as nt } from "./number-format-BA_KwrZe.js";
10
- function Te(e) {
11
- if (!e || e.kind === "date") return;
12
- const t = e.digits;
13
- if (!(t !== void 0 && (!Number.isInteger(t) || t < 0 || t > 100))) {
14
- if (e.kind === "percent") {
15
- const n = t ?? 2;
16
- return `0${n ? `.${"0".repeat(n)}` : ""}%`;
17
- }
18
- return t === void 0 ? e.thousands ? "#,##0.###############" : void 0 : `${e.thousands ? "#,##0" : "0"}${t ? `.${"0".repeat(t)}` : ""}`;
19
- }
20
- }
21
- function it(e) {
22
- const t = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());
23
- if (t) {
24
- const i = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
25
- return Number.isNaN(i.getTime()) ? null : i;
26
- }
27
- const n = new Date(e);
28
- return Number.isNaN(n.getTime()) ? null : n;
29
- }
30
- function se(e, t) {
31
- return e.toLocaleString("en-US", {
32
- minimumFractionDigits: t,
33
- maximumFractionDigits: t
34
- });
35
- }
36
- function rt(e, t) {
37
- const n = (i) => String(i).padStart(2, "0");
38
- return t.replace(/YYYY/g, String(e.getFullYear())).replace(/MM/g, n(e.getMonth() + 1)).replace(/DD/g, n(e.getDate())).replace(/hh/g, n(e.getHours())).replace(/mm/g, n(e.getMinutes())).replace(/ss/g, n(e.getSeconds()));
39
- }
40
- function ot(e, t, n) {
41
- return n != null ? t ? se(e, n) : e.toFixed(n) : t ? se(e) : String(e);
42
- }
43
- function le(e) {
44
- const t = typeof e == "number" ? e : Number(String(e).replace(/,/g, ""));
45
- return Number.isFinite(t) ? t : null;
46
- }
47
- function Ee(e, t) {
48
- if (e == null || e === "" || !t) return String(e ?? "");
49
- switch (t.kind) {
50
- case "number": {
51
- const n = le(e);
52
- return n == null ? String(e) : ot(n, t.thousands === !0, t.digits);
53
- }
54
- case "percent": {
55
- const n = le(e);
56
- return n == null ? String(e) : `${se(n * 100, t.digits ?? 2)}%`;
57
- }
58
- case "date": {
59
- const n = t.pattern ?? "YYYY-MM-DD", i = e instanceof Date ? e : it(String(e));
60
- return i ? rt(i, n) : String(e);
61
- }
62
- default:
63
- return String(e);
64
- }
65
- }
66
- function at(e, t) {
67
- const n = e[t.field];
68
- if (n == null || n === "") return !1;
69
- if (typeof t.value == "number") {
70
- const o = le(n);
71
- if (o == null) return !1;
72
- switch (t.op) {
73
- case ">":
74
- return o > t.value;
75
- case ">=":
76
- return o >= t.value;
77
- case "<":
78
- return o < t.value;
79
- case "<=":
80
- return o <= t.value;
81
- case "==":
82
- return o === t.value;
83
- case "!=":
84
- return o !== t.value;
85
- }
86
- }
87
- const i = String(n), r = String(t.value);
88
- switch (t.op) {
89
- case "==":
90
- return i === r;
91
- case "!=":
92
- return i !== r;
93
- case ">":
94
- return i > r;
95
- case ">=":
96
- return i >= r;
97
- case "<":
98
- return i < r;
99
- case "<=":
100
- return i <= r;
101
- }
102
- return !1;
103
- }
104
- function Ae(e, t, n) {
105
- e.editable !== void 0 && typeof e.editable != "boolean" && n.push({ path: `${t}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && n.push({ path: `${t}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
106
- }
107
- function st(e, t, n) {
108
- Ae(e, t, n), e.formula !== void 0 && typeof e.formula != "string" && n.push({ path: `${t}.formula`, message: "单元格公式应为字符串" });
109
- }
110
- const lt = /* @__PURE__ */ new Set([
111
- "text",
112
- "image",
113
- "barcode",
114
- "qrcode",
115
- "chart",
116
- "line",
117
- "rect",
118
- "ellipse"
119
- ]);
120
- function z(e) {
121
- return typeof e == "object" && e !== null && !Array.isArray(e);
122
- }
123
- function dt(e, t, n, i) {
124
- const r = e[t];
125
- (typeof r != "number" || !Number.isFinite(r)) && i.push({ path: `${n}.${t}`, message: `应为有限数字,实际 ${JSON.stringify(r)}` });
126
- }
127
- function ct(e, t, n) {
128
- if (e !== void 0) {
129
- const i = `${t}.table`;
130
- if (!z(e)) n.push({ path: i, message: "逻辑表来源应为对象" });
131
- else {
132
- (typeof e.id != "string" || !e.id.trim()) && n.push({ path: `${i}.id`, message: "逻辑表 ID 应为非空字符串" });
133
- const r = e.role;
134
- ["header", "body", "group-header", "subtotal", "grand-total"].includes(r) || n.push({ path: `${i}.role`, message: "未知逻辑表行角色" });
135
- const o = e.rowIndex;
136
- (typeof o != "number" || !Number.isInteger(o) || (r === "header" ? o !== -1 : o < 0)) && n.push({ path: `${i}.rowIndex`, message: "表头索引应为 -1,内容行索引应为非负整数" }), (!Array.isArray(e.columnKeys) || e.columnKeys.some((a) => typeof a != "string")) && n.push({ path: `${i}.columnKeys`, message: "逻辑列字段应为字符串数组" }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" }), e.title !== void 0 && typeof e.title != "string" && n.push({ path: `${i}.title`, message: "逻辑表名称应为字符串" });
137
- }
138
- }
139
- }
140
- function mt(e, t, n, i) {
141
- if (e !== void 0)
142
- if (!z(e) || !Array.isArray(e.cells))
143
- n.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" });
144
- else {
145
- const r = e.paddingMm;
146
- r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r < 0) && n.push({ path: `${t}.grid.paddingMm`, message: "单元格内距应为有限非负数" }), e.cells.forEach((o, a) => {
147
- if (!Array.isArray(o)) {
148
- n.push({ path: `${t}.grid.cells.${a}`, message: "行应为数组" });
149
- return;
150
- }
151
- o.forEach((s, l) => {
152
- if (s == null) return;
153
- const d = `${t}.grid.cells.${a}.${l}`;
154
- if (!z(s)) {
155
- n.push({ path: d, message: "网格单元格应为对象或 null" });
156
- return;
157
- }
158
- st(s, d, n), Array.isArray(s.children) && s.children.forEach((c, m) => {
159
- ue(c, `${t}.grid.cells.${a}.${l}.children.${m}`, n, i);
160
- });
161
- });
162
- });
163
- }
164
- }
165
- function ft(e, t, n) {
166
- e !== void 0 && (Array.isArray(e) ? e.forEach((i, r) => {
167
- (!z(i) || !Array.isArray(i.segments)) && n.push({ path: `${t}.richParagraphs.${r}`, message: "段落缺少 segments 数组" });
168
- }) : n.push({ path: `${t}.richParagraphs`, message: "richParagraphs 应为数组" }));
169
- }
170
- function ue(e, t, n, i = []) {
171
- if (!z(e)) {
172
- n.push({ path: t, message: "组件应为对象" });
173
- return;
174
- }
175
- const r = e.kind;
176
- typeof r != "string" ? n.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : lt.has(r) || i.push({
177
- path: `${t}.kind`,
178
- message: `未知组件类型 ${JSON.stringify(r)},将以兜底方式渲染`
179
- });
180
- for (const o of ["leftMm", "topMm", "widthMm", "heightMm"])
181
- dt(e, o, t, n);
182
- typeof e.leftMm == "number" && e.leftMm < -100 && n.push({ path: `${t}.leftMm`, message: "几何数值异常(leftMm<-100)" });
183
- for (const o of ["widthMm", "heightMm"])
184
- typeof e[o] == "number" && e[o] < 0 && n.push({ path: `${t}.${o}`, message: "组件尺寸不能为负数" });
185
- ct(e.table, t, n), mt(e.grid, t, n, i), ft(e.richParagraphs, t, n);
186
- }
187
- function ut(e, t, n, i = []) {
188
- if (!z(e)) {
189
- n.push({ path: t, message: "页应为对象" });
190
- return;
191
- }
192
- const r = e.pageWidthMm, o = e.pageHeightMm;
193
- (typeof r != "number" || !Number.isFinite(r) || r <= 0) && n.push({ path: `${t}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(r)}` }), (typeof o != "number" || !(o > 0 && o < 5e3)) && n.push({ path: `${t}.pageHeightMm`, message: `页高非法: ${JSON.stringify(o)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" });
194
- const a = e.components;
195
- Array.isArray(a) ? Array.isArray(a) && a.forEach(
196
- (s, l) => ue(s, `${t}.components.${l}`, n, i)
197
- ) : n.push({ path: `${t}.components`, message: "components 应为数组" });
198
- }
199
- function Pe(e) {
200
- const t = [], n = [], i = z(e) ? e.pages : void 0;
201
- if (!Array.isArray(i))
202
- t.push({
203
- path: "$.pages",
204
- message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
205
- });
206
- else {
207
- i.forEach((o, a) => ut(o, `$.pages.${a}`, t, n)), i.length > 2e3 && n.push({
208
- path: "$.pages",
209
- message: `页数异常大(${i.length} 页),渲染与打印耗时可能显著增加`
210
- });
211
- const r = i.reduce(
212
- (o, a) => o + (z(a) && Array.isArray(a.components) ? a.components.length : 0),
213
- 0
214
- );
215
- r > 5e4 && n.push({
216
- path: "$.pages",
217
- message: `组件总数异常大(${r} 个),可能触发浏览器性能限制`
218
- });
219
- }
220
- return { ok: t.length === 0, errors: t, warnings: n };
221
- }
222
- function Hn(e) {
223
- const t = Pe(e);
224
- if (!t.ok) {
225
- const n = t.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ");
226
- throw new Error(`渲染计划校验失败(${t.errors.length} 处): ${n}`);
227
- }
228
- return e.pages;
229
- }
230
- function ht(e) {
231
- return {
232
- widthMm: e.widthMm,
233
- heightMm: e.heightMm,
234
- marginTopMm: e.marginTopMm ?? 0,
235
- marginBottomMm: e.marginBottomMm ?? 0,
236
- marginLeftMm: e.marginLeftMm ?? 0,
237
- marginRightMm: e.marginRightMm ?? 0,
238
- components: []
239
- };
240
- }
241
- function gt(e, t) {
242
- return t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
243
- }
244
- function Ce(e) {
245
- if (e == null) return "";
246
- if (typeof e == "string") return e;
247
- if (typeof e == "number") return String(e);
248
- if (typeof e == "boolean") return e ? "是" : "否";
249
- if (e instanceof Date) return e.toISOString().slice(0, 10);
250
- try {
251
- return JSON.stringify(e);
252
- } catch {
253
- return String(e);
254
- }
255
- }
256
- function Ne(e, t) {
257
- let n = e.textMetrics.get(t);
258
- if (!n) {
259
- const i = D(t).fontSizePt;
260
- n = {
261
- measureOptions: {
262
- fontSizePt: i,
263
- bold: t.bold,
264
- letterSpacingPt: t.letterSpacing
265
- },
266
- lineMm: i * (t.lineHeight ?? ve) * 25.4 / 72
267
- }, e.textMetrics.set(t, n);
268
- }
269
- return n;
270
- }
271
- function Re(e, t) {
272
- return t?.kind === "number" || t?.kind === "percent" ? "right" : t?.kind === "date" || e instanceof Date || typeof e == "boolean" ? "center" : typeof e == "number" && Number.isFinite(e) ? "right" : "left";
273
- }
274
- function pt(e) {
275
- if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
276
- }
277
- function yt(e, t) {
278
- const n = e.fontSizePt ?? qe, i = e.paddingMm ?? 1, r = e.columns.map((f) => f.align ?? f.style?.align ?? e.align ?? "left"), o = e.columns.map((f, u) => ({
279
- ...R({
280
- fontSize: n,
281
- verticalAlign: "middle"
282
- }, f.style),
283
- align: r[u] === "auto" ? "left" : r[u]
284
- })), a = o.map((f, u) => r[u] === "auto" ? { left: f, center: { ...f, align: "center" }, right: { ...f, align: "right" } } : void 0), s = e.columns.map((f, u) => f.rules?.map((p) => {
285
- const b = a[u];
286
- if (b) return {
287
- left: R(b.left, p.style),
288
- center: R(b.center, p.style),
289
- right: R(b.right, p.style)
290
- };
291
- const M = R(o[u], p.style);
292
- return { left: M, center: M, right: M };
293
- })), l = e.columns.map((f) => {
294
- let u = R({
295
- fontSize: n,
296
- bold: e.headerBold ?? !0,
297
- align: "center",
298
- verticalAlign: "middle",
299
- backgroundColor: e.headerBackgroundColor
300
- }, f.style);
301
- return e.headerAlign !== void 0 && (u.align = e.headerAlign), u = R(u, e.headerStyle), f.headerAlign !== void 0 && (u.align = f.headerAlign), R(u, f.headerStyle);
302
- }), d = e.columns.map((f) => f.header);
303
- let c = e.rowHeightMm ?? 0;
304
- for (let f = 0; f < d.length; f++) {
305
- const u = l[f], p = D(u).fontSizePt, b = U(
306
- d[f],
307
- e.columns[f].widthMm - i * 2,
308
- { fontSizePt: p, bold: u.bold, letterSpacingPt: u.letterSpacing },
309
- t
310
- ), M = p * (u.lineHeight ?? ve) * 25.4 / 72;
311
- c = Math.max(c, Math.max(b.length, 1) * M + i * 2);
312
- }
313
- const m = d.map((f, u) => ({
314
- text: f,
315
- style: l[u]
316
- })), g = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, h = e.columns.map((f) => f.widthMm);
317
- return {
318
- fontSizePt: n,
319
- paddingMm: i,
320
- cellStyles: o,
321
- autoStyles: a,
322
- ruleStyles: s,
323
- textMetrics: /* @__PURE__ */ new WeakMap(),
324
- numberFormats: e.columns.map((f) => Te(f.format)),
325
- borderStyle: g,
326
- headerHeightMm: c,
327
- headerGrid: {
328
- cells: [m],
329
- colWidthsMm: h,
330
- rowHeightsMm: [c],
331
- paddingMm: i
332
- },
333
- colWidthsMm: h,
334
- columns: e.columns
335
- };
336
- }
337
- function bt(e, t, n) {
338
- const i = t.format?.kind === "number" || t.format?.kind === "percent";
339
- t.valueType !== void 0 ? e.valueType = t.valueType : i && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && n !== void 0 && (e.numberFormat = n);
340
- }
341
- function Me(e, t, n) {
342
- const i = e.columns;
343
- let r = e.rowHeightFloorMm;
344
- const o = new Array(i.length);
345
- for (let a = 0; a < i.length; a++) {
346
- const s = i[a], l = t[s.field], d = e.autoStyles[a] ? Re(l, s.format) : "left";
347
- let c = e.autoStyles[a]?.[d] ?? e.cellStyles[a];
348
- if (s.rules)
349
- for (let p = 0; p < s.rules.length; p++) {
350
- const b = s.rules[p];
351
- if (at(t, b.when)) {
352
- c = e.ruleStyles[a][p][d];
353
- break;
354
- }
355
- }
356
- const m = s.format ? Ee(l, s.format) : Ce(l), g = Ne(e, c), h = U(m, s.widthMm - e.paddingMm * 2, g.measureOptions, n);
357
- r = Math.max(r, h.length * g.lineMm + e.paddingMm * 2);
358
- const f = pt(l), u = { text: m, style: c };
359
- f !== void 0 && (u.value = f), bt(u, s, e.numberFormats[a]), o[a] = u;
360
- }
361
- return {
362
- grid: { cells: [o], colWidthsMm: e.colWidthsMm, rowHeightsMm: [r], paddingMm: e.paddingMm },
363
- heightMm: r
364
- };
365
- }
366
- function* Mt(e, t) {
367
- if (!t) {
368
- for (const i of e) yield { kind: "row", row: i };
369
- return;
370
- }
371
- const n = /* @__PURE__ */ new Map();
372
- for (const i of e) {
373
- const r = Ce(i[t.field]), o = n.get(r);
374
- o ? o.push(i) : n.set(r, [i]);
375
- }
376
- for (const [i, r] of n) {
377
- yield { kind: "groupHeader", label: (t.headerTemplate ?? "{value}").replace(/\{value\}/g, i), firstRow: r[0] };
378
- for (const o of r) yield { kind: "row", row: o };
379
- t.subtotal?.length && (yield { kind: "subtotal", label: t.subtotalLabel ?? "小计", rows: r });
380
- }
381
- }
382
- function wt(e, t) {
383
- let n = 0;
384
- for (const i of e) {
385
- const r = typeof i[t] == "number" ? i[t] : Number(i[t]);
386
- Number.isFinite(r) && (n += r);
387
- }
388
- return n;
389
- }
390
- function Ie(e, t, n) {
391
- return new Map(n.map((i) => {
392
- const r = e.find((a) => a.field === i)?.format ?? { kind: "number", thousands: !0 }, o = wt(t, i);
393
- return [i, { text: Ee(o, r), value: o, numberFormat: Te(r) }];
394
- }));
395
- }
396
- function Oe(e, t) {
397
- const n = e.findIndex((i) => t.includes(i.field));
398
- return n > 0 ? n : 1;
399
- }
400
- function de(e, t, n, i, r, o) {
401
- const a = [], s = Math.max(1, Math.min(o, e.columns.length)), l = R({ fontSize: e.fontSizePt }, r);
402
- a.push({ text: n, colSpan: s, style: { bold: !0, ...l } });
403
- for (let m = s; m < e.columns.length; m++) {
404
- const g = e.columns[m], h = i.get(g.field), f = e.autoStyles[m]?.[Re(h?.value, g.format)] ?? e.cellStyles[m];
405
- a.push({ ...h, text: h?.text ?? "", style: R(f, r) });
406
- }
407
- let d = e.rowHeightFloorMm, c = 0;
408
- for (const m of a) {
409
- let g = 0;
410
- const h = c + (m.colSpan ?? 1);
411
- for (; c < h; c++) g += e.colWidthsMm[c] ?? 0;
412
- const f = Ne(e, m.style), u = U(m.text ?? "", g - e.paddingMm * 2, f.measureOptions, t);
413
- d = Math.max(d, u.length * f.lineMm + e.paddingMm * 2);
414
- }
415
- return {
416
- grid: { cells: [a], colWidthsMm: e.colWidthsMm, rowHeightsMm: [d], paddingMm: e.paddingMm },
417
- heightMm: d
418
- };
419
- }
420
- function $t(e, t, n) {
421
- const { templatePage: i, current: r, warnings: o, nextId: a, pushCurrent: s } = n, l = () => gt(i, r), d = r.marginTopMm, c = {
422
- id: n.tableId,
423
- columnKeys: e.columns.map((w) => w.field),
424
- ...e.layout === void 0 ? {} : { layout: e.layout },
425
- ...e.title === void 0 ? {} : { title: e.title }
426
- };
427
- let m = 0;
428
- const g = {
429
- kind: "rect",
430
- leftMm: e.leftMm,
431
- topMm: 0,
432
- widthMm: e.widthMm,
433
- heightMm: t.headerHeightMm,
434
- grid: t.headerGrid,
435
- nid: a("listh"),
436
- table: { ...c, role: "header", rowIndex: -1 },
437
- style: t.borderStyle
438
- }, h = (w) => r.components.push({ ...g, topMm: w });
439
- let f = e.topMm;
440
- h(f), f += t.headerHeightMm + n.mmPerRow;
441
- function u() {
442
- const w = i.layout === "wide" ? 0 : e.topMm;
443
- return e.headerEveryPage !== !1 ? w + t.headerHeightMm : i.layout === "wide" ? 0 : d;
444
- }
445
- function p() {
446
- const w = i.layout === "wide" ? 0 : r.marginBottomMm;
447
- return i.heightMm - w - u();
448
- }
449
- function b(w) {
450
- if (f + w <= l()) return;
451
- s(), r.components = [], r.heightMm = i.heightMm, i.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
452
- const B = i.layout === "wide" ? 0 : e.topMm;
453
- e.headerEveryPage !== !1 ? (h(B), f = B + t.headerHeightMm) : f = i.layout === "wide" ? 0 : d;
454
- }
455
- function M(w, B, _) {
456
- const j = p();
457
- w.heightMm > j && o.push(`列表 ${e.id ?? e.dataset} 行高 ${w.heightMm.toFixed(2)}mm 超出单页可用高度 ${j.toFixed(2)}mm,预览与打印可能截断内容`), b(w.heightMm), r.components.push({
458
- kind: "rect",
459
- leftMm: e.leftMm,
460
- topMm: f,
461
- widthMm: e.widthMm,
462
- heightMm: w.heightMm,
463
- grid: w.grid,
464
- nid: a(B),
465
- table: { ...c, role: _, rowIndex: m++ },
466
- style: t.borderStyle
467
- }), f += w.heightMm;
468
- }
469
- function T(w) {
470
- w <= p() && b(w);
471
- }
472
- return { keepTogether: T, placeGridRow: M };
473
- }
474
- function vt(e, t, n, i, r) {
475
- if (!e.grandTotal) return;
476
- const o = typeof e.grandTotal == "object" ? e.grandTotal : void 0, a = o?.fields ?? e.groupBy?.subtotal ?? [];
477
- if (a.length === 0) {
478
- i.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
479
- return;
480
- }
481
- const s = de(n, i.measurer, o?.label ?? "合计", Ie(e.columns, t, a), o?.style ?? {}, Oe(e.columns, a));
482
- r.placeGridRow(s, "listgt", "grand-total");
483
- }
484
- function St(e, t, n) {
485
- const i = e.columns.reduce((d, c) => d + c.widthMm, 0), r = i > e.widthMm ? e.widthMm / i : 1, o = r === 1 ? e : { ...e, columns: e.columns.map((d) => ({ ...d, widthMm: d.widthMm * r })) }, a = { ...yt(o, n.measurer), rowHeightFloorMm: o.rowHeightMm ?? 0 }, s = $t(o, a, n);
486
- let l;
487
- for (const d of Mt(t, o.groupBy))
488
- if (d.kind === "row")
489
- s.placeGridRow(l ?? Me(a, d.row, n.measurer), "listr", "body"), l = void 0;
490
- else if (d.kind === "groupHeader") {
491
- const c = de(a, n.measurer, d.label, /* @__PURE__ */ new Map(), o.groupBy?.headerStyle ?? {}, o.columns.length);
492
- l = Me(a, d.firstRow, n.measurer), o.groupBy?.keepWithNext !== !1 && s.keepTogether(c.heightMm + l.heightMm), s.placeGridRow(c, "listg", "group-header");
493
- } else {
494
- const c = o.groupBy?.subtotal ?? [], m = de(a, n.measurer, d.label, Ie(o.columns, d.rows, c), o.groupBy?.subtotalStyle ?? {}, Oe(o.columns, c));
495
- s.placeGridRow(m, "listst", "subtotal");
496
- }
497
- vt(o, t, a, n, s);
498
- }
499
- function we(e) {
500
- return e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}"));
501
- }
502
- function xt(e, t, n, i, r, o) {
503
- const a = {
504
- pageWidthMm: t.widthMm,
505
- pageHeightMm: t.heightMm,
506
- ...e.layout === void 0 ? {} : { layout: e.layout },
507
- marginTopMm: t.marginTopMm,
508
- marginBottomMm: t.marginBottomMm,
509
- marginLeftMm: t.marginLeftMm,
510
- marginRightMm: t.marginRightMm,
511
- components: t.components
512
- };
513
- i.push(a);
514
- for (const s of n) {
515
- const l = { ...s, text: String(s.text ?? "").replace(/\{page\}/g, String(i.length)) };
516
- a.components.push(l), l.text.includes("{totalPages}") && r.push(l);
517
- }
518
- if (e.layout === "wide") {
519
- const s = a.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
520
- a.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, a.pageHeightMm = Math.max(1, s + a.marginBottomMm);
521
- }
522
- }
523
- function kt(e, t, n = {}) {
524
- const i = typeof n == "number" ? { mmPerRow: n } : n, r = [], o = [], a = [];
525
- let s = 0;
526
- const l = (d) => `${d}_${(++s).toString(36)}`;
527
- for (const [d, c] of e.pages.entries()) {
528
- const m = ht(c), g = c.components.filter(we), h = (f = !1) => xt(c, m, g, o, a, f);
529
- for (const [f, u] of c.components.entries()) {
530
- if (we(u)) continue;
531
- if (u.kind !== "list") {
532
- m.components.push(u);
533
- continue;
534
- }
535
- const p = t[u.dataset];
536
- Array.isArray(p) || r.push(`数据集 ${u.dataset} 未提供数据,列表 ${u.id ?? ""} 输出为空`), St(u, Array.isArray(p) ? p : [], {
537
- templatePage: c,
538
- current: m,
539
- warnings: r,
540
- nextId: l,
541
- pushCurrent: h,
542
- measurer: i.measurer ?? fe,
543
- mmPerRow: i.mmPerRow ?? 0,
544
- tableId: `table:${d}:${f}`
545
- });
546
- }
547
- h(!0);
548
- }
549
- for (const d of a) d.text = d.text.replace(/\{totalPages\}/g, String(o.length));
550
- return { plan: { schemaVersion: ce, pages: o }, warnings: r };
551
- }
552
- const Tt = {
1
+ import { i as J, D as Y, a as Me, b as xe } from "./render-plan-uzZYYSy1.js";
2
+ import { c as On, d as zn, e as jn, L as Hn, R as Wn, S as Bn } from "./render-plan-uzZYYSy1.js";
3
+ import { v as Ge } from "./report-source-BXHNy_AD.js";
4
+ import { P as Kn, R as Vn, c as qn, d as Gn, a as Un, e as Jn, f as Yn, p as Xn, b as Qn, t as Zn, g as er } from "./report-source-BXHNy_AD.js";
5
+ import { r as O, a as z, b as X, c as H, d as Te, m as re, e as Ee, p as D, f as Se, P as G } from "./style-Dv5o_x6b.js";
6
+ import { C as nr, M as rr, g as ir, h as or } from "./style-Dv5o_x6b.js";
7
+ import { a as sr, v as lr, b as cr, c as dr } from "./validate-S6CgIm5d.js";
8
+ import { h as ie, w as Ce } from "./textwrap-DOl04hCQ.js";
9
+ import { c as mr, a as fr, b as hr, m as gr } from "./textwrap-DOl04hCQ.js";
10
+ import { r as W, o as Ue } from "./progress-DD964VAB.js";
11
+ import { r as Pe, a as oe } from "./assets-B9qJku3V.js";
12
+ import { O as wr } from "./assets-B9qJku3V.js";
13
+ import { r as B, n as ke, O as Je } from "./capabilities-joSutDF8.js";
14
+ import { i as vr } from "./capabilities-joSutDF8.js";
15
+ import { c as Ye } from "./page-window-index-CIuT4BAv.js";
16
+ import { p as ne } from "./template-registry-NpOakidD.js";
17
+ import { R as Mr, a as xr, c as Tr, d as Er, s as Sr, v as Cr, b as Pr } from "./template-registry-NpOakidD.js";
18
+ import { R as Rr, a as Ir, i as Ar, r as $r, v as Nr, b as Lr } from "./param-validation-BWNjLcN0.js";
19
+ import { f as Xe, i as Qe } from "./number-format-BA_KwrZe.js";
20
+ const Ze = {
553
21
  root: "mr-root",
554
22
  page: "mr-page",
555
23
  comp: "mr-comp",
@@ -566,23 +34,23 @@ const Tt = {
566
34
  cell: "mr-cell",
567
35
  unknown: "mr-unknown"
568
36
  };
569
- function k(e, t) {
570
- return t?.classNames?.[e] ?? Tt[e];
37
+ function S(e, t) {
38
+ return t?.classNames?.[e] ?? Ze[e];
571
39
  }
572
- class Et {
40
+ class et {
573
41
  constructor() {
574
42
  this.props = [];
575
43
  }
576
44
  add(t, n) {
577
45
  return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
578
46
  }
579
- mm(t, n, i, r = 2) {
580
- return this.add(t, `${K(Qe(n, i), r)}px`);
47
+ mm(t, n, r, i = 2) {
48
+ return this.add(t, `${O(re(n, r), i)}px`);
581
49
  }
582
50
  toString() {
583
51
  let t = "";
584
- for (const [n, i] of this.props)
585
- t += `${n}:${i};`;
52
+ for (const [n, r] of this.props)
53
+ t += `${n}:${r};`;
586
54
  return t;
587
55
  }
588
56
  applyTo(t) {
@@ -590,371 +58,522 @@ class Et {
590
58
  n && (t.style.cssText = n);
591
59
  }
592
60
  }
593
- function S(e, t = "unset") {
594
- return new Et().add("all", t).add("display", e).add("box-sizing", "border-box");
595
- }
596
- function Fe(e, t, n) {
597
- e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(ne(t))).add("text-align", t.align);
598
- const i = D(t, n);
599
- e.add("font-size", `${K(i.fontSizePx, 2)}px`);
600
- }
601
- function At(e, t, n) {
602
- const i = t.style ?? {};
603
- Fe(e, i, n), e.add("background-color", i.backgroundColor).add("opacity", i.opacity != null ? String(i.opacity) : void 0).add("transform", i.rotateDeg ? `rotate(${i.rotateDeg}deg)` : void 0);
604
- }
605
- function Pt(e, t, n, i, r, o) {
606
- const a = e.cell, s = o.createElement("td");
607
- s.className = k("cell", r), s.dataset.mrRowIndex = String(e.ri), s.dataset.mrColumnIndex = String(e.ci), s.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), a.colSpan && (s.colSpan = a.colSpan), a.rowSpan && (s.rowSpan = a.rowSpan);
608
- const l = R(t.style, a.style), d = S("block").add("position", "absolute").mm("left", e.xMm, i).mm("top", e.yMm, i).mm("width", e.widthMm, i).mm("height", e.heightMm, i).add("background-color", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
609
- Fe(d, l, i), d.applyTo(s);
610
- const c = o.createElement("div");
611
- c.className = "mr-cell-content", S("flex").add("position", "absolute").mm("left", n, i).mm("right", n, i).mm("top", n, i).mm("bottom", n, i).add("flex-direction", "column").add("justify-content", l.verticalAlign === "top" ? "flex-start" : l.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(c), a.text != null && c.append(a.text);
612
- for (const m of a.children ?? []) c.appendChild(He(m, i, r, o));
613
- return s.appendChild(c), s;
614
- }
615
- function Ct(e, t, n, i) {
616
- const r = ie(t.style), o = r.inner ? [...e.edges] : [];
617
- r.top && o.push({ kind: "h", pos: 0, from: 0, to: t.widthMm }), r.bottom && o.push({ kind: "h", pos: t.heightMm, from: 0, to: t.widthMm }), r.left && o.push({ kind: "v", pos: 0, from: 0, to: t.heightMm }), r.right && o.push({ kind: "v", pos: t.widthMm, from: 0, to: t.heightMm });
618
- const a = G(t.style), s = `${K(a.widthPt * n / 72, 2)}px solid ${a.color}`;
619
- return o.map((l) => {
620
- const d = i.createElement("div");
621
- d.className = "mr-grid-edge", d.setAttribute("aria-hidden", "true");
622
- const c = l.kind === "h";
623
- return S("block").add("position", "absolute").add("pointer-events", "none").mm("left", c ? l.from : l.pos, n).mm("top", c ? l.pos : l.from, n).mm("width", c ? l.to - l.from : 0, n).mm("height", c ? 0 : l.to - l.from, n).add(c ? "border-top" : "border-left", s).applyTo(d), d;
61
+ function y(e, t = "unset") {
62
+ return new et().add("all", t).add("display", e).add("box-sizing", "border-box");
63
+ }
64
+ function Re(e, t, n) {
65
+ e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(X(t))).add("text-align", t.align);
66
+ const r = z(t, n);
67
+ e.add("font-size", `${O(r.fontSizePx, 2)}px`);
68
+ }
69
+ function tt(e, t, n) {
70
+ const r = t.style ?? {};
71
+ Re(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
72
+ }
73
+ function nt(e, t, n, r, i, l) {
74
+ const o = e.cell, a = l.createElement("td");
75
+ a.className = S("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), o.colSpan && (a.colSpan = o.colSpan), o.rowSpan && (a.rowSpan = o.rowSpan);
76
+ const s = Ee(t.style, o.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
77
+ Re(c, s, r), c.applyTo(a);
78
+ const d = l.createElement("div");
79
+ d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n, r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), o.text != null && d.append(o.text);
80
+ for (const u of o.children ?? []) d.appendChild(Ie(u, r, i, l));
81
+ return a.appendChild(d), a;
82
+ }
83
+ function rt(e, t, n, r) {
84
+ return Pe(e, t).map((i) => {
85
+ const l = `${O(i.widthPt * n / 72, 2)}px solid ${i.color}`, o = r.createElement("div");
86
+ o.className = "mr-grid-edge", o.setAttribute("aria-hidden", "true");
87
+ const a = i.kind === "h";
88
+ return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", l).applyTo(o), o;
624
89
  });
625
90
  }
626
- function Nt(e, t, n, i, r) {
627
- const o = r.createElement("table");
628
- o.className = k("grid", i), o.setAttribute("role", "table"), S("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
629
- const a = me(e, t.widthMm, t.heightMm), s = r.createElement("tbody");
630
- S("contents").applyTo(s), o.appendChild(s);
631
- const l = e.cells.map(() => {
632
- const c = r.createElement("tr");
633
- return c.className = k("row", i), c.setAttribute("role", "row"), S("contents").applyTo(c), s.appendChild(c), c;
91
+ function it(e, t, n, r, i) {
92
+ const l = i.createElement("table");
93
+ l.className = S("grid", r), l.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(l);
94
+ const o = W(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
95
+ y("contents").applyTo(a), l.appendChild(a);
96
+ const s = e.cells.map(() => {
97
+ const d = i.createElement("tr");
98
+ return d.className = S("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
634
99
  });
635
- for (const c of a.cells)
636
- l[c.ri].appendChild(Pt(c, t, e.paddingMm ?? 0.5, n, i, r));
637
- const d = r.createElement("div");
638
- return S("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(d), d.append(o, ...Ct(a, t, n, r)), d;
639
- }
640
- function Rt(e, t, n, i) {
641
- const r = i.createElement("div");
642
- r.className = k("paragraph", n), S("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(r);
643
- for (const o of e.segments || []) {
644
- const a = i.createElement("span");
645
- a.className = k("segment", n), a.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
646
- const s = S("inline");
647
- if (o.style) {
648
- const l = o.style;
649
- s.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && s.add("font-size", `${K(D(l, t).fontSizePx, 2)}px`);
100
+ for (const d of o.cells)
101
+ s[d.ri].appendChild(nt(d, t, e.paddingMm ?? 0.5, n, r, i));
102
+ const c = i.createElement("div");
103
+ return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(l, ...rt(o, t, n, i)), c;
104
+ }
105
+ function ot(e, t, n, r) {
106
+ const i = r.createElement("div");
107
+ i.className = S("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
108
+ for (const l of e.segments || []) {
109
+ const o = r.createElement("span");
110
+ o.className = S("segment", n), o.textContent = l.kind === "field" ? l.field ?? "" : l.text ?? "";
111
+ const a = y("inline");
112
+ if (l.style) {
113
+ const s = l.style;
114
+ a.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${O(z(s, t).fontSizePx, 2)}px`);
650
115
  }
651
- s.applyTo(a), r.appendChild(a);
116
+ a.applyTo(o), i.appendChild(o);
652
117
  }
653
- return r;
118
+ return i;
654
119
  }
655
- function It(e, t, n, i) {
120
+ function at(e, t, n, r) {
656
121
  if (xe(e)) {
657
- const r = i.createElement("div");
658
- r.className = k("rich", n), S("block").applyTo(r);
659
- for (const o of e.richParagraphs) r.appendChild(Rt(o, t, n, i));
660
- return r;
122
+ const i = r.createElement("div");
123
+ i.className = S("rich", n), y("block").applyTo(i);
124
+ for (const l of e.richParagraphs) i.appendChild(ot(l, t, n, r));
125
+ return i;
661
126
  }
662
127
  if (Array.isArray(e.lines) && e.lines.length > 0) {
663
- const r = i.createElement("div");
664
- r.className = k("lines", n), S("block").applyTo(r);
665
- for (const o of e.lines) {
666
- const a = i.createElement("div");
667
- a.className = k("line", n), a.textContent = o, S("block").add("white-space", "pre").add("min-height", "1lh").applyTo(a), r.appendChild(a);
128
+ const i = r.createElement("div");
129
+ i.className = S("lines", n), y("block").applyTo(i);
130
+ for (const l of e.lines) {
131
+ const o = r.createElement("div");
132
+ o.className = S("line", n), o.textContent = l, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(o), i.appendChild(o);
668
133
  }
669
- return r;
134
+ return i;
670
135
  }
671
136
  return e.text ?? "";
672
137
  }
673
- function Ot(e, t, n, i) {
674
- const r = i.createElement("div");
675
- r.className = k("text", n);
676
- const o = e.style || {};
677
- return S("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(r), r.append(It(e, t, n, i)), r;
678
- }
679
- function Ft(e, t, n) {
680
- const i = n.createElement("img");
681
- return i.className = k("image", t), i.src = e.imageData, S("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(i), i.alt = e.kind, i;
682
- }
683
- function $e(e, t, n, i) {
684
- const r = i.createElement("div");
685
- r.className = k("shape", n);
686
- const o = e.style || {}, a = G(o), s = ie(o), l = `${K(a.widthPt * t / 72, 2)}px solid ${a.color}`, d = S("block");
687
- return e.grid ? d.add("position", "relative") : e.kind === "rect" ? (s.top && d.add("border-top", l), s.right && d.add("border-right", l), s.bottom && d.add("border-bottom", l), s.left && d.add("border-left", l)) : e.kind === "ellipse" ? (s.inner && d.add("border", l).add("border-radius", "50%"), o.backgroundColor && d.add("background-color", o.backgroundColor)) : e.kind === "line" && d.add("height", "0").add("border-top", l), d.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), d.applyTo(r), r;
688
- }
689
- function He(e, t, n, i) {
690
- const r = i.createElement("div");
691
- r.className = `${k("comp", n)} mr-kind-${e.kind}`;
692
- const o = S("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
693
- if (At(o, e, t), o.applyTo(r), Xe(e))
694
- return r.appendChild(Ft(e, n, i)), r;
138
+ function st(e, t, n, r) {
139
+ const i = r.createElement("div");
140
+ i.className = S("text", n);
141
+ const l = e.style || {};
142
+ return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", l.verticalAlign === "middle" ? "center" : l.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(at(e, t, n, r)), i;
143
+ }
144
+ function lt(e, t, n) {
145
+ const r = n.createElement("img");
146
+ return r.className = S("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
147
+ }
148
+ function we(e, t, n, r) {
149
+ const i = r.createElement("div");
150
+ i.className = S("shape", n);
151
+ const l = e.style || {}, o = H(l), a = Te(l), s = `${O(o.widthPt * t / 72, 2)}px solid ${o.color}`, c = y("block");
152
+ return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", s), a.right && c.add("border-right", s), a.bottom && c.add("border-bottom", s), a.left && c.add("border-left", s)) : e.kind === "ellipse" ? (a.inner && c.add("border", s).add("border-radius", "50%"), l.backgroundColor && c.add("background-color", l.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
153
+ }
154
+ function ct(e, t, n) {
155
+ const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = re(e.widthMm, t), l = re(e.heightMm, t);
156
+ r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, l))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
157
+ const o = n.createElementNS("http://www.w3.org/2000/svg", "line");
158
+ o.setAttribute("x1", "0"), o.setAttribute("x2", String(i)), o.setAttribute("y1", e.lineDirection === "up" ? String(l) : "0"), o.setAttribute("y2", e.lineDirection === "up" ? "0" : String(l));
159
+ const a = H({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
160
+ return o.setAttribute("stroke", a.color), o.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(o), r;
161
+ }
162
+ function Ie(e, t, n, r) {
163
+ const i = r.createElement("div");
164
+ i.className = `${S("comp", n)} mr-kind-${e.kind}`;
165
+ const l = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
166
+ if (tt(l, e, t), l.applyTo(i), J(e))
167
+ return i.appendChild(lt(e, n, r)), i;
695
168
  if (e.kind === "text")
696
- return r.appendChild(Ot(e, t, n, i)), r;
169
+ return i.appendChild(st(e, t, n, r)), i;
697
170
  if (e.grid) {
698
- const s = $e(e, t, n, i);
699
- return s.appendChild(Nt(e.grid, e, t, n, i)), r.appendChild(s), r;
700
- }
701
- if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse" || e.kind === "chart")
702
- return r.appendChild($e(e, t, n, i)), r;
703
- const a = i.createElement("div");
704
- return a.className = k("unknown", n), S("block").applyTo(a), a.textContent = e.fallbackText ?? "", r.appendChild(a), r;
705
- }
706
- function Ht(e, t, n, i) {
707
- const r = i.createElement("div");
708
- return r.className = k("page", n), S("block", "initial").add("position", "relative").add("font-family", '"Microsoft YaHei", sans-serif').add("font-size", `${K(D(void 0, t).fontSizePx, 2)}px`).add("line-height", String(ne(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", Se).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(r), e.components.forEach((o, a) => {
709
- const s = He(o, t, n, i);
710
- s.dataset.mrComponentIndex = String(a), r.appendChild(s);
711
- }), r;
712
- }
713
- function Ln(e, t, n = {}) {
714
- const i = n.dpi ?? 96, r = t.createElement("div");
715
- return r.className = k("root", n), S("block").applyTo(r), r.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
716
- r.appendChild(Ht(o, i, n, t));
717
- }), r;
718
- }
719
- function Lt(e) {
720
- return Ze(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
721
- }
722
- const he = 96 / 25.4;
723
- function Le(e, t = 96) {
724
- const n = t / 96 * he;
171
+ const a = we(e, t, n, r);
172
+ return a.appendChild(it(e.grid, e, t, n, r)), i.appendChild(a), i;
173
+ }
174
+ if (e.kind === "line" && e.lineDirection)
175
+ return i.appendChild(ct(e, t, r)), i;
176
+ if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
177
+ return i.appendChild(we(e, t, n, r)), i;
178
+ const o = r.createElement("div");
179
+ return o.className = S("unknown", n), y("block").applyTo(o), o.textContent = e.fallbackText ?? `[${e.kind}]`, o.dataset.mrUnsupported = e.kind, o.setAttribute("role", "note"), i.appendChild(o), i;
180
+ }
181
+ function dt(e, t, n, r) {
182
+ const i = r.createElement("div");
183
+ return i.className = S("page", n), y("block", "initial").add("position", "relative").add("font-family", Y).add("font-size", `${O(z(void 0, t).fontSizePx, 2)}px`).add("line-height", String(X(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", Me).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((l, o) => {
184
+ const a = Ie(l, t, n, r);
185
+ a.dataset.mrComponentIndex = String(o), i.appendChild(a);
186
+ }), i;
187
+ }
188
+ function hn(e, t, n = {}) {
189
+ const r = n.dpi ?? 96;
190
+ B(e, "dom", n);
191
+ const i = t.createElement("div");
192
+ return i.className = S("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((l) => {
193
+ i.appendChild(dt(l, r, n, t));
194
+ }), i;
195
+ }
196
+ function R(e) {
197
+ if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
198
+ }
199
+ const ut = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
200
+ const i = new Image(), l = () => {
201
+ i.onload = null, i.onerror = null, t?.removeEventListener("abort", o);
202
+ }, o = () => {
203
+ l(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
204
+ };
205
+ i.onload = () => {
206
+ l(), n(i);
207
+ }, i.onerror = () => {
208
+ l(), r(new Error("Image could not be decoded for Canvas output."));
209
+ }, t?.addEventListener("abort", o, { once: !0 }), i.src = e;
210
+ }) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
211
+ function mt(e, t, n) {
212
+ return R(n), n ? new Promise((r, i) => {
213
+ const l = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
214
+ n.addEventListener("abort", l, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", l));
215
+ }) : e(t);
216
+ }
217
+ async function ft(e, t, n) {
218
+ const r = /* @__PURE__ */ new Map();
219
+ for (const i of e.components)
220
+ !J(i) || r.has(i.imageData) || r.set(i.imageData, await mt(t, i.imageData, n));
221
+ return R(n), r;
222
+ }
223
+ function ht(e, t, n, r, i, l) {
224
+ const o = t, a = o.naturalWidth ?? o.width ?? i, s = o.naturalHeight ?? o.height ?? l;
225
+ if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
226
+ const c = Math.min(i / a, l / s), d = a * c, u = s * c;
227
+ e.drawImage(t, n + (i - d) / 2, r + (l - u) / 2, d, u);
228
+ }
229
+ function gt(e) {
230
+ return Ye(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
231
+ }
232
+ const ae = 96 / 25.4;
233
+ function se(e, t = 96) {
234
+ const n = t / 96 * ae;
725
235
  return {
726
236
  widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
727
237
  heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
728
238
  };
729
239
  }
730
- function Bt(e, t, n) {
731
- const i = document.createElement("canvas"), { widthPx: r, heightPx: o } = Le(e, n);
732
- i.width = Math.round(r * t), i.height = Math.round(o * t), i.style.width = `${r}px`, i.style.height = `${o}px`;
733
- const a = i.getContext("2d");
734
- if (!a)
240
+ function Ae(e, t, n, r = 64e6) {
241
+ if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
242
+ if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
243
+ const i = se(e, n), l = Math.round(i.widthPx * t), o = Math.round(i.heightPx * t);
244
+ if (!Number.isSafeInteger(l) || !Number.isSafeInteger(o) || l * o > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
245
+ return { width: l, height: o };
246
+ }
247
+ function $e(e, t, n, r) {
248
+ const i = document.createElement("canvas"), { widthPx: l, heightPx: o } = se(e, n), a = Ae(e, t, n, r);
249
+ i.width = a.width, i.height = a.height, i.style.width = `${l}px`, i.style.height = `${o}px`;
250
+ const s = i.getContext("2d");
251
+ if (!s)
735
252
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
736
- return a.scale(t, t), a.fillStyle = "#ffffff", a.fillRect(0, 0, r, o), { canvas: i, ctx: a };
737
- }
738
- function Bn(e, t = 96) {
739
- return D(e, t).fontSizePx;
740
- }
741
- function Be(e, t, n, i, r, o, a, s = "top") {
742
- e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${a}`, e.fillStyle = t.color, e.textBaseline = "alphabetic";
743
- const l = t.fontSizePx * t.lineHeight, d = t.text === "" ? [""] : t.text.split(`
744
- `), c = d.length * l;
745
- let m = i;
746
- s === "middle" ? m = i + (o - c) / 2 : s === "bottom" && (m = i + o - c), d.forEach((g, h) => {
747
- e.textAlign = t.align === "center" ? "center" : t.align === "right" ? "right" : "left";
748
- const f = t.align === "center" ? n + r / 2 : t.align === "right" ? n + r : n;
749
- e.fillText(g, f, m + h * l + t.fontSizePx * 0.8, r);
253
+ return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, l, o), { canvas: i, ctx: s };
254
+ }
255
+ function gn(e, t = 96) {
256
+ return z(e, t).fontSizePx;
257
+ }
258
+ function Ne(e, t, n, r, i, l, o, a = "top") {
259
+ e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${o}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
260
+ const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
261
+ `), d = c.length * s;
262
+ let u = r;
263
+ a === "middle" ? u = r + (l - d) / 2 : a === "bottom" && (u = r + l - d), c.forEach((m, f) => {
264
+ pt(e, m, t, n, u + f * s + t.fontSizePx * 0.8, i);
750
265
  }), e.textAlign = "left";
751
266
  }
752
- function jt(e, t, n, i, r, o, a, s, l) {
753
- const d = ie(n.style);
754
- if (!d.inner) return;
755
- const c = G(n.style);
756
- e.strokeStyle = c.color, e.lineWidth = Q(c.widthPt, l);
757
- for (const m of t.edges)
758
- e.beginPath(), m.kind === "v" ? (e.moveTo(i + m.pos * s, r + m.from * s), e.lineTo(i + m.pos * s, r + m.to * s)) : (e.moveTo(i + m.from * s, r + m.pos * s), e.lineTo(i + m.to * s, r + m.pos * s)), e.stroke();
759
- je(e, d, i, r, o, a);
760
- }
761
- function je(e, t, n, i, r, o) {
762
- e.beginPath(), t.top && (e.moveTo(n, i), e.lineTo(n + r, i)), t.right && (e.moveTo(n + r, i), e.lineTo(n + r, i + o)), t.bottom && (e.moveTo(n + r, i + o), e.lineTo(n, i + o)), t.left && (e.moveTo(n, i + o), e.lineTo(n, i)), e.stroke();
763
- }
764
- function zt(e, t, n, i, r, o, a, s, l, d, c) {
765
- const m = me(t, o / s, a / s);
766
- for (const h of m.cells) {
767
- const f = h.cell.style?.backgroundColor ?? n.style?.backgroundColor;
768
- f && (e.fillStyle = f, e.fillRect(i + h.xMm * s, r + h.yMm * s, h.widthMm * s, h.heightMm * s));
267
+ function pt(e, t, n, r, i, l) {
268
+ const o = Array.from(t), a = n.letterSpacingPx ?? 0;
269
+ if (!a) {
270
+ e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
271
+ const u = n.align === "center" ? r + l / 2 : n.align === "right" ? r + l : r;
272
+ e.fillText(t, u, i);
273
+ return;
769
274
  }
770
- jt(e, m, n, i, r, o, a, s, l);
771
- const g = t.paddingMm ?? 0.5;
772
- for (const h of m.cells) {
773
- const f = h.cell.text ?? "";
774
- if (!f) continue;
775
- const u = R(n.style, h.cell.style), p = D(u, l), b = Math.max(0, h.widthMm - 2 * g), M = U(f, b, { fontSizePt: p.fontSizePt, bold: u.bold }, c).join(`
275
+ const s = e.measureText(t).width + Math.max(0, o.length - 1) * a, c = n.align === "center" ? r + (l - s) / 2 : n.align === "right" ? r + l - s : r;
276
+ e.textAlign = "left";
277
+ let d = "";
278
+ o.forEach((u, m) => {
279
+ e.fillText(u, c + e.measureText(d).width + m * a, i), d += u;
280
+ });
281
+ }
282
+ function wt(e, t, n, r, i, l, o) {
283
+ for (const a of Pe(t, n))
284
+ e.strokeStyle = a.color, e.lineWidth = D(a.widthPt, o), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * l, i + a.from * l), e.lineTo(r + a.pos * l, i + a.to * l)) : (e.moveTo(r + a.from * l, i + a.pos * l), e.lineTo(r + a.to * l, i + a.pos * l)), e.stroke();
285
+ }
286
+ function bt(e, t, n, r, i, l) {
287
+ e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + l)), t.bottom && (e.moveTo(n + i, r + l), e.lineTo(n, r + l)), t.left && (e.moveTo(n, r + l), e.lineTo(n, r)), e.stroke();
288
+ }
289
+ function vt(e, t, n, r, i, l, o, a, s, c, d) {
290
+ const u = W(t, l / a, o / a);
291
+ for (const f of u.cells) {
292
+ const h = f.cell.style?.backgroundColor ?? n.style?.backgroundColor;
293
+ h && (e.fillStyle = h, e.fillRect(r + f.xMm * a, i + f.yMm * a, f.widthMm * a, f.heightMm * a));
294
+ }
295
+ wt(e, u, n, r, i, a, s);
296
+ const m = t.paddingMm ?? 0.5;
297
+ for (const f of u.cells) {
298
+ const h = f.cell.text ?? "";
299
+ if (!h) continue;
300
+ const g = Ee(n.style, f.cell.style), b = z(g, s), x = Math.max(0, f.widthMm - 2 * m), T = Ce(h, x, { fontSizePt: b.fontSizePt, bold: g.bold, italic: g.italic, fontFamily: g.fontFamily ?? c, letterSpacingPt: g.letterSpacing }, d).join(`
776
301
  `);
777
- Be(
302
+ Ne(
778
303
  e,
779
304
  {
780
- text: M,
781
- fontSizePx: p.fontSizePx,
782
- bold: u.bold ?? !1,
783
- italic: u.italic,
784
- color: ke(u, Se),
785
- align: u.align ?? "left",
786
- lineHeight: ne(u)
305
+ text: T,
306
+ fontSizePx: b.fontSizePx,
307
+ bold: g.bold ?? !1,
308
+ italic: g.italic,
309
+ color: Se(g, Me),
310
+ align: g.align ?? "left",
311
+ lineHeight: X(g),
312
+ letterSpacingPx: D(g.letterSpacing ?? 0, s)
787
313
  },
788
- i + (h.xMm + g) * s,
789
- r + (h.yMm + g) * s,
790
- b * s,
791
- Math.max(0, h.heightMm - 2 * g) * s,
792
- u.fontFamily ?? d,
793
- u.verticalAlign ?? "middle"
314
+ r + (f.xMm + m) * a,
315
+ i + (f.yMm + m) * a,
316
+ x * a,
317
+ Math.max(0, f.heightMm - 2 * m) * a,
318
+ g.fontFamily ?? c,
319
+ g.verticalAlign ?? "middle"
794
320
  );
795
321
  }
796
322
  }
797
- function Dt(e, t, n, i, r, o, a, s, l) {
798
- const d = t.style ?? {}, c = D(d, a), m = xe(t) ? t.richParagraphs.map((g) => g.segments.map((h) => h.text ?? h.field ?? "").join("")).join(`
323
+ function yt(e, t, n, r, i, l, o, a, s) {
324
+ const c = t.style ?? {}, d = z(c, o), u = xe(t) ? t.richParagraphs.map((m) => m.segments.map((f) => f.text ?? f.field ?? "").join("")).join(`
799
325
  `) : t.lines?.length ? t.lines.join(`
800
- `) : U(t.text ?? "", t.widthMm, { fontSizePt: c.fontSizePt, bold: d.bold }, l).join(`
326
+ `) : Ce(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, s).join(`
801
327
  `);
802
- Be(e, {
803
- text: m,
804
- fontSizePx: c.fontSizePx,
805
- bold: d.bold ?? !1,
806
- italic: d.italic,
807
- color: ke(d),
808
- align: d.align ?? "left",
809
- lineHeight: ne(d)
810
- }, n, i, r, o, d.fontFamily ?? s, d.verticalAlign);
811
- }
812
- function ze(e, t, n, i, r, o) {
813
- const a = t.leftMm * n, s = t.topMm * n, l = t.widthMm * n, d = t.heightMm * n, c = t.style ?? {};
328
+ Ne(e, {
329
+ text: u,
330
+ fontSizePx: d.fontSizePx,
331
+ bold: c.bold ?? !1,
332
+ italic: c.italic,
333
+ color: Se(c),
334
+ align: c.align ?? "left",
335
+ lineHeight: X(c),
336
+ letterSpacingPx: D(c.letterSpacing ?? 0, o)
337
+ }, n, r, i, l, c.fontFamily ?? a, c.verticalAlign);
338
+ }
339
+ function le(e, t, n, r, i, l, o) {
340
+ const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, u = t.style ?? {};
341
+ if (J(t)) {
342
+ const m = o?.get(t.imageData);
343
+ m ? ht(e, m, a, s, c, d) : be(e, t, a, s, c, d);
344
+ return;
345
+ }
814
346
  if (t.grid) {
815
- zt(e, t.grid, t, a, s, l, d, n, i, r, o);
347
+ vt(e, t.grid, t, a, s, c, d, n, r, i, l);
816
348
  return;
817
349
  }
818
350
  switch (t.kind) {
819
351
  case "text": {
820
- Dt(e, t, a, s, l, d, i, r, o);
352
+ yt(e, t, a, s, c, d, r, i, l);
821
353
  break;
822
354
  }
823
355
  case "rect": {
824
- const m = G(c), g = ie(c);
825
- c.backgroundColor && (e.fillStyle = c.backgroundColor, e.fillRect(a, s, l, d)), g.inner && (e.strokeStyle = m.color, e.lineWidth = Q(m.widthPt, i), je(e, g, a, s, l, d));
356
+ const m = H(u), f = Te(u);
357
+ u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(a, s, c, d)), f.inner && (e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), bt(e, f, a, s, c, d));
826
358
  break;
827
359
  }
828
360
  case "line": {
829
- const m = G({ ...c, borderColor: c.lineColor ?? c.borderColor });
830
- e.strokeStyle = m.color, e.lineWidth = Q(m.widthPt, i), e.beginPath(), e.moveTo(a, s + d / 2), e.lineTo(a + l, s + d / 2), e.stroke();
361
+ const m = H({ ...u, borderColor: u.lineColor ?? u.borderColor });
362
+ e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), e.beginPath();
363
+ const f = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2, h = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + d : s + d / 2;
364
+ e.moveTo(a, f), e.lineTo(a + c, h), e.stroke();
831
365
  break;
832
366
  }
833
367
  case "ellipse": {
834
- const m = G(c);
835
- e.strokeStyle = m.color, e.lineWidth = Q(m.widthPt, i), c.backgroundColor && (e.fillStyle = c.backgroundColor, e.beginPath(), e.ellipse(a + l / 2, s + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + l / 2, s + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
368
+ const m = H(u);
369
+ e.strokeStyle = m.color, e.lineWidth = D(m.widthPt, r), u.backgroundColor && (e.fillStyle = u.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
836
370
  break;
837
371
  }
372
+ default:
373
+ be(e, t, a, s, c, d);
374
+ break;
838
375
  }
839
376
  }
840
- async function jn(e, t = {}) {
377
+ function be(e, t, n, r, i, l) {
378
+ e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, l), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
379
+ }
380
+ async function pn(e, t = {}) {
841
381
  if (typeof document > "u")
842
382
  throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
843
- const { format: n = "png", quality: i = 0.92, ...r } = t, { canvases: o } = Wt(e, r), a = n === "jpeg" ? "image/jpeg" : "image/png", s = [];
844
- for (const l of o)
845
- s.push(
846
- await new Promise(
847
- (d) => l.toBlob((c) => d(c), a, i)
848
- ) ?? new Blob([], { type: a })
849
- );
850
- return { blobs: s };
383
+ const { format: n = "png", quality: r = 0.92, ...i } = t;
384
+ if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
385
+ if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
386
+ R(t.signal);
387
+ const l = await oe(e, { ...t, format: "canvas" });
388
+ e = l.plan;
389
+ const o = [...l.diagnostics, ...B(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
390
+ for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
391
+ R(t.signal);
392
+ const u = await Le(e.pages[d], d, i, o);
393
+ try {
394
+ s.push(await Mt(u, a, r, t.signal));
395
+ } finally {
396
+ u.width = 0, u.height = 0;
397
+ }
398
+ await Ue(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
399
+ }
400
+ return R(t.signal), { blobs: s, diagnostics: o };
851
401
  }
852
- function Wt(e, t = {}) {
853
- if (typeof document > "u")
402
+ function Mt(e, t, n, r) {
403
+ return R(r), new Promise((i, l) => {
404
+ const o = () => l(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
405
+ r?.addEventListener("abort", o, { once: !0 });
406
+ try {
407
+ e.toBlob((a) => {
408
+ r?.removeEventListener("abort", o), a ? i(a) : l(new Error("Canvas encoding failed; no empty image was emitted."));
409
+ }, t, n);
410
+ } catch (a) {
411
+ r?.removeEventListener("abort", o), l(a);
412
+ }
413
+ });
414
+ }
415
+ function wn(e, t = {}) {
416
+ if (R(t.signal), typeof document > "u")
854
417
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
855
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), i = t.dpi ?? 96, r = i / 96 * he, o = t.fontFamily ?? '"Microsoft YaHei", sans-serif', a = t.measurer ?? fe, s = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), d = [];
856
- for (let c = s; c <= l; c++) {
857
- const m = e.pages[c], { canvas: g, ctx: h } = Bt(m, n, i);
858
- for (const f of m.components)
859
- ze(h, f, r, i, o, a);
860
- d.push(g);
861
- }
862
- return { canvases: d };
863
- }
864
- function zn(e, t = {}) {
865
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), i = t.dpi ?? 96, r = i / 96 * he, o = t.fontFamily ?? '"Microsoft YaHei", sans-serif', a = t.measurer ?? fe, s = t.overscan ?? 1, l = t.gapPx ?? 18, d = t.pagesPerFrame ?? 1, c = e.pages.map((y) => y.pageHeightMm * r), m = Math.max(1, ...e.pages.map((y) => y.pageWidthMm * r)), g = { start: 0, end: -1 };
866
- let h = null, f = null, u = null, p = null, b = [], M = 0, T = [];
867
- function w() {
868
- const y = h;
869
- y.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, u = document.createElement("div"), p = document.createElement("div"), f.appendChild(u), b = [];
870
- const P = Math.min(e.pages.length, 3 + s * 2);
871
- for (let O = 0; O < P; O++) {
872
- const $ = document.createElement("div");
873
- $.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild($), b.push($);
418
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ae, l = t.fontFamily ?? Y, o = t.measurer ?? ie, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = B(e, "canvas", t), u = xt(e, a, s);
419
+ for (const m of u)
420
+ ke(m, t), d.push(m);
421
+ if (t.fidelity === "strict" && u.length) throw new Je(d);
422
+ for (let m = a; m <= s; m++) {
423
+ R(t.signal);
424
+ const f = e.pages[m], { canvas: h, ctx: g } = $e(f, n, r, t.maxCanvasPixels);
425
+ for (const b of f.components)
426
+ le(g, b, i, r, l, o);
427
+ c.push(h);
428
+ }
429
+ return { canvases: c, diagnostics: d };
430
+ }
431
+ function xt(e, t, n) {
432
+ return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((l, o) => J(l) ? [{
433
+ code: "async-image-required",
434
+ severity: "warning",
435
+ format: "canvas",
436
+ pageIndex: t + i,
437
+ componentIndex: o,
438
+ kind: l.kind,
439
+ nid: l.nid,
440
+ message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
441
+ }] : []));
442
+ }
443
+ async function bn(e, t = {}) {
444
+ if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
445
+ R(t.signal);
446
+ const n = await oe(e, { ...t, format: "canvas" });
447
+ e = n.plan;
448
+ const r = [...n.diagnostics, ...B(e, "canvas", t)], i = [], l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
449
+ for (let o = Math.max(0, t.start ?? 0); o <= l; o++)
450
+ i.push(await Le(e.pages[o], o, t, r));
451
+ return { canvases: i, diagnostics: r };
452
+ }
453
+ async function Le(e, t, n, r) {
454
+ const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), l = n.dpi ?? 96, o = n.fontFamily ?? Y, a = await Fe(e, t, n, r);
455
+ R(n.signal);
456
+ const { canvas: s, ctx: c } = $e(e, i, l, n.maxCanvasPixels);
457
+ for (const d of e.components) le(c, d, l / 25.4, l, o, n.measurer ?? ie, a);
458
+ return s;
459
+ }
460
+ async function Fe(e, t, n, r) {
461
+ const i = n.imageLoader ?? ut;
462
+ return ft(e, async (l, o) => {
463
+ try {
464
+ return await i(l, o);
465
+ } catch (a) {
466
+ if (o?.aborted) throw a;
467
+ const s = e.components.findIndex((u) => u.imageData === l), c = e.components[s], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: s, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
468
+ throw r.push(d), ke(d, n), a;
874
469
  }
875
- f.appendChild(p), y.appendChild(f);
876
- }
877
- function B(y, P) {
878
- const O = e.pages[P], { widthPx: $, heightPx: E } = Le(O, i);
879
- let C = y.firstElementChild;
880
- (!C || C.tagName !== "CANVAS") && (C = document.createElement("canvas"), y.innerHTML = "", y.appendChild(C)), C.width = Math.round($ * n), C.height = Math.round(E * n), C.style.width = `${$}px`, C.style.height = `${E}px`;
881
- const V = C.getContext("2d");
882
- if (V) {
883
- V.setTransform(1, 0, 0, 1, 0, 0), V.scale(n, n), V.fillStyle = "#ffffff", V.fillRect(0, 0, $, E);
884
- for (const Ye of O.components)
885
- ze(V, Ye, r, i, o, a);
886
- C.dataset.canvasPage = String(P), y.style.height = `${E}px`, y.style.width = `${$}px`;
470
+ }, n.signal);
471
+ }
472
+ function vn(e, t = {}) {
473
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ae, l = t.fontFamily ?? Y, o = t.measurer ?? ie, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((p) => p.pageHeightMm * i), u = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * i)), m = { start: 0, end: -1 };
474
+ let f = null, h = null, g = null, b = null, x = [], T = 0, k = [], _ = 0, j = new AbortController();
475
+ const he = [];
476
+ function _e() {
477
+ const p = f;
478
+ p.innerHTML = "", h = document.createElement("div"), h.style.cssText = `width:${u}px;margin:0 auto;`, g = document.createElement("div"), b = document.createElement("div"), h.appendChild(g), x = [];
479
+ const E = Math.min(e.pages.length, 3 + a * 2);
480
+ for (let N = 0; N < E; N++) {
481
+ const v = document.createElement("div");
482
+ v.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, h.appendChild(v), x.push(v);
483
+ }
484
+ h.appendChild(b), p.appendChild(h);
485
+ }
486
+ async function Ke(p, E) {
487
+ const N = _, v = await oe(e, { ...t, signal: j.signal, format: "canvas", start: E, end: E });
488
+ he.push(...v.diagnostics);
489
+ const C = v.plan.pages[E], q = await Fe(C, E, { ...t, signal: j.signal }, he);
490
+ if (N !== _ || !f) return;
491
+ const { widthPx: ee, heightPx: te } = se(C, r);
492
+ let $ = p.firstElementChild;
493
+ (!$ || $.tagName !== "CANVAS") && ($ = document.createElement("canvas"), p.innerHTML = "", p.appendChild($));
494
+ const pe = Ae(C, n, r, t.maxCanvasPixels);
495
+ $.width = pe.width, $.height = pe.height, $.style.width = `${ee}px`, $.style.height = `${te}px`;
496
+ const F = $.getContext("2d");
497
+ if (F) {
498
+ F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ee, te);
499
+ for (const qe of C.components)
500
+ le(F, qe, i, r, l, o, q);
501
+ $.dataset.canvasPage = String(E), p.style.height = `${te}px`, p.style.width = `${ee}px`;
887
502
  }
888
503
  }
889
- function _(y) {
890
- g.start = y.start, g.end = y.end, u.style.height = `${y.start * l + c.slice(0, y.start).reduce(($, E) => $ + E, 0)}px`;
891
- const P = e.pages.length - 1 - y.end;
892
- p.style.height = `${P * l + c.slice(y.end + 1).reduce(($, E) => $ + E, 0)}px`;
893
- const O = y.end - y.start + 1;
894
- b.forEach(($, E) => {
895
- if (E < O) {
896
- $.style.display = "";
897
- const C = y.start + E;
898
- $.style.height = `${c[C] ?? 0}px`;
504
+ function Ve(p) {
505
+ _++, m.start = p.start, m.end = p.end, g.style.height = `${p.start * s + d.slice(0, p.start).reduce((v, C) => v + C, 0)}px`;
506
+ const E = e.pages.length - 1 - p.end;
507
+ b.style.height = `${E * s + d.slice(p.end + 1).reduce((v, C) => v + C, 0)}px`;
508
+ const N = p.end - p.start + 1;
509
+ x.forEach((v, C) => {
510
+ if (C < N) {
511
+ v.style.display = "";
512
+ const q = p.start + C;
513
+ v.style.height = `${d[q] ?? 0}px`;
899
514
  } else
900
- $.style.display = "none";
901
- }), T = [];
902
- for (let $ = y.start; $ <= y.end; $++) {
903
- const E = b[$ - y.start];
904
- if (!E) continue;
905
- E.firstElementChild?.dataset?.canvasPage !== String($) && T.push($);
515
+ v.style.display = "none";
516
+ }), k = [];
517
+ for (let v = p.start; v <= p.end; v++) {
518
+ const C = x[v - p.start];
519
+ if (!C) continue;
520
+ C.firstElementChild?.dataset?.canvasPage !== String(v) && k.push(v);
906
521
  }
907
- j();
908
- }
909
- function j() {
910
- M || T.length === 0 || (M = requestAnimationFrame(() => {
911
- M = 0;
912
- let y = Math.max(1, d);
913
- for (; T.length > 0 && y-- > 0; ) {
914
- const P = T.shift(), O = b[P - g.start];
915
- O && B(O, P);
522
+ Z();
523
+ }
524
+ function Z() {
525
+ T || k.length === 0 || (T = requestAnimationFrame(() => {
526
+ T = 0;
527
+ let p = Math.max(1, c);
528
+ for (; k.length > 0 && p-- > 0; ) {
529
+ const E = k.shift(), N = x[E - m.start];
530
+ N && Ke(N, E).catch(() => {
531
+ });
916
532
  }
917
- T.length > 0 && j();
533
+ k.length > 0 && Z();
918
534
  }));
919
535
  }
920
- function q() {
921
- M || (M = requestAnimationFrame(() => {
922
- M = 0;
923
- const y = h, P = Lt({
924
- pageHeightsPx: c,
925
- viewportHeightPx: y.clientHeight,
926
- scrollTopPx: y.scrollTop,
927
- overscan: s,
928
- gapPx: l
536
+ function K() {
537
+ T || (T = requestAnimationFrame(() => {
538
+ T = 0;
539
+ const p = f, E = gt({
540
+ pageHeightsPx: d,
541
+ viewportHeightPx: p.clientHeight,
542
+ scrollTopPx: p.scrollTop,
543
+ overscan: a,
544
+ gapPx: s
929
545
  });
930
- P.start !== g.start || P.end !== g.end ? _(P) : j();
546
+ E.start !== m.start || E.end !== m.end ? Ve(E) : Z();
931
547
  }));
932
548
  }
933
- let X = null;
549
+ let V = null;
934
550
  return {
935
- attach(y) {
551
+ attach(p) {
936
552
  if (typeof document > "u")
937
553
  throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
938
- h = y, w(), y.addEventListener("scroll", q, { passive: !0 }), typeof ResizeObserver < "u" && (X = new ResizeObserver(() => q()), X.observe(y)), q();
554
+ R(t.signal), j = new AbortController(), t.signal?.addEventListener("abort", ge, { once: !0 }), B(e, "canvas", t), f = p, _e(), p.addEventListener("scroll", K, { passive: !0 }), typeof ResizeObserver < "u" && (V = new ResizeObserver(() => K()), V.observe(p)), K();
939
555
  },
940
556
  destroy() {
941
- M && cancelAnimationFrame(M), M = 0, X?.disconnect(), X = null, h?.removeEventListener("scroll", q), T = [], f?.remove(), h = null;
557
+ _++, j.abort(), t.signal?.removeEventListener("abort", ge), T && cancelAnimationFrame(T), T = 0, V?.disconnect(), V = null, f?.removeEventListener("scroll", K), k = [], h?.remove(), f = null;
942
558
  },
943
559
  window() {
944
- return { ...g };
560
+ return { ...m };
945
561
  }
946
562
  };
563
+ function ge() {
564
+ j.abort(t.signal?.reason);
565
+ }
947
566
  }
948
567
  function De(e, t, n) {
949
- let i, r;
568
+ let r, i;
950
569
  if (typeof e == "string") {
951
- const o = Z[e];
952
- if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Z).join("/")})`);
953
- i = o.widthMm, r = o.heightMm;
954
- } else typeof e == "number" ? (i = e, r = t ?? 297) : (i = e.widthMm, r = e.heightMm);
955
- return n ? { widthMm: r, heightMm: i } : { widthMm: i, heightMm: r };
570
+ const l = G[e];
571
+ if (!l) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(G).join("/")})`);
572
+ r = l.widthMm, i = l.heightMm;
573
+ } else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
574
+ return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
956
575
  }
957
- class _t {
576
+ class Tt {
958
577
  constructor() {
959
578
  this.pages = [], this.pending = null, this.templateParams = void 0;
960
579
  }
@@ -981,20 +600,20 @@ class _t {
981
600
  * - 数字:.page(210, 297)(第三参数兼容旧 margins 对象或新 options)
982
601
  * - 对象:.page({ widthMm: 210, heightMm: 297 })
983
602
  */
984
- page(t = "a4", n = {}, i) {
603
+ page(t = "a4", n = {}, r) {
985
604
  this.collect();
986
- const o = i != null && !("margins" in i) && !("landscape" in i) && ("marginTopMm" in i || "marginBottomMm" in i || "marginLeftMm" in i || "marginRightMm" in i) ? { margins: i } : typeof n == "number" ? i ?? {} : n, { widthMm: a, heightMm: s } = De(
605
+ const l = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: o, heightMm: a } = De(
987
606
  t,
988
607
  typeof n == "number" ? n : void 0,
989
- o.landscape
990
- ), l = o.margins ?? {};
991
- return this.pending = new Vt(this, {
992
- widthMm: a,
993
- heightMm: s,
994
- marginTopMm: l.marginTopMm ?? 10,
995
- marginBottomMm: l.marginBottomMm ?? 10,
996
- marginLeftMm: l.marginLeftMm ?? 10,
997
- marginRightMm: l.marginRightMm ?? 10
608
+ l.landscape
609
+ ), s = l.margins ?? {};
610
+ return this.pending = new Et(this, {
611
+ widthMm: o,
612
+ heightMm: a,
613
+ marginTopMm: s.marginTopMm ?? 10,
614
+ marginBottomMm: s.marginBottomMm ?? 10,
615
+ marginLeftMm: s.marginLeftMm ?? 10,
616
+ marginRightMm: s.marginRightMm ?? 10
998
617
  }), this.pending;
999
618
  }
1000
619
  collect() {
@@ -1006,11 +625,11 @@ class _t {
1006
625
  return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
1007
626
  }
1008
627
  }
1009
- class Vt {
628
+ class Et {
1010
629
  constructor(t, n) {
1011
630
  this.parent = t, this.page = n, this.components = [];
1012
631
  }
1013
- text(t, n = {}, i = {}) {
632
+ text(t, n = {}, r = {}) {
1014
633
  return this.components.push({
1015
634
  kind: "text",
1016
635
  leftMm: n.leftMm ?? 0,
@@ -1018,31 +637,31 @@ class Vt {
1018
637
  widthMm: n.widthMm ?? 60,
1019
638
  heightMm: n.heightMm ?? 8,
1020
639
  text: t,
1021
- style: i
640
+ style: r
1022
641
  }), this;
1023
642
  }
1024
- list(t, n, i, r = {}) {
643
+ list(t, n, r, i = {}) {
1025
644
  return this.components.push({
1026
645
  kind: "list",
1027
646
  leftMm: n.leftMm ?? 10,
1028
647
  topMm: n.topMm ?? 30,
1029
648
  widthMm: n.widthMm ?? 180,
1030
649
  dataset: t,
1031
- columns: i,
1032
- ...r
650
+ columns: r,
651
+ ...i
1033
652
  }), this;
1034
653
  }
1035
654
  rect(t, n = {}) {
1036
655
  return this.components.push({ kind: "rect", ...t, style: n }), this;
1037
656
  }
1038
- line(t, n, i, r = {}) {
657
+ line(t, n, r, i = {}) {
1039
658
  return this.components.push({
1040
659
  kind: "line",
1041
660
  leftMm: t,
1042
661
  topMm: n,
1043
- widthMm: i,
662
+ widthMm: r,
1044
663
  heightMm: 0.5,
1045
- style: r
664
+ style: i
1046
665
  }), this;
1047
666
  }
1048
667
  barcode(t, n) {
@@ -1055,11 +674,11 @@ class Vt {
1055
674
  fallbackText: t
1056
675
  }), this;
1057
676
  }
1058
- qrcode(t, n, i, r) {
677
+ qrcode(t, n, r, i) {
1059
678
  return this.components.push({
1060
679
  kind: "qrcode",
1061
- leftMm: i,
1062
- topMm: r,
680
+ leftMm: r,
681
+ topMm: i,
1063
682
  widthMm: n,
1064
683
  heightMm: n,
1065
684
  fallbackText: t
@@ -1075,18 +694,26 @@ class Vt {
1075
694
  return this.done().build();
1076
695
  }
1077
696
  }
1078
- function Dn() {
1079
- return new _t();
697
+ function yn() {
698
+ return new Tt();
699
+ }
700
+ function Mn(e, t = {}) {
701
+ return Ge([], e), e.fields.map((n) => ({
702
+ field: n.field,
703
+ header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
704
+ semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
705
+ ...t[n.field]
706
+ }));
1080
707
  }
1081
708
  function I(e, t, n = !1) {
1082
709
  if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
1083
710
  throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
1084
711
  }
1085
- function ee(e, t, n) {
712
+ function U(e, t, n) {
1086
713
  if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
1087
714
  throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
1088
715
  }
1089
- function Gt(e) {
716
+ function St(e) {
1090
717
  const t = e.layout ?? "page";
1091
718
  if (t !== "page" && t !== "wide")
1092
719
  throw new Error("layout 必须是 page 或 wide");
@@ -1097,16 +724,16 @@ function Gt(e) {
1097
724
  const n = e.columnWidthMm ?? 30;
1098
725
  return I(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
1099
726
  }
1100
- function Jt(e) {
727
+ function Ct(e) {
1101
728
  const t = e.paper === void 0 ? "a4" : e.paper;
1102
729
  if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
1103
730
  throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
1104
- if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Z, t))
1105
- throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Z).join("/")})`);
1106
- const n = De(t, void 0, e.landscape), i = n.widthMm, r = n.heightMm;
1107
- return I(i, "纸张 widthMm"), I(r, "纸张 heightMm"), { widthMm: i, heightMm: r };
731
+ if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(G, t))
732
+ throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(G).join("/")})`);
733
+ const n = De(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
734
+ return I(r, "纸张 widthMm"), I(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
1108
735
  }
1109
- function Kt(e) {
736
+ function Pt(e) {
1110
737
  if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
1111
738
  throw new Error("margins 必须是页边距对象");
1112
739
  const t = e.margins ?? {}, n = {
@@ -1115,535 +742,222 @@ function Kt(e) {
1115
742
  marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
1116
743
  marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
1117
744
  };
1118
- for (const [i, r] of Object.entries(n)) I(r, i, !0);
745
+ for (const [r, i] of Object.entries(n)) I(i, r, !0);
1119
746
  return n;
1120
747
  }
1121
- function Ut(e, t) {
748
+ function kt(e, t) {
1122
749
  const n = e.dataset === void 0 ? "detail" : e.dataset;
1123
750
  if (typeof n != "string" || !n.trim())
1124
751
  throw new Error("dataset 必须是非空字符串");
1125
752
  if (e.title !== void 0 && typeof e.title != "string")
1126
753
  throw new Error("title 必须是字符串");
1127
- const i = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, r = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
1128
- I(i, "titleHeightMm"), I(r, "titleGapMm", !0);
1129
- const o = e.title !== void 0 && e.title.length > 0, a = o ? i + r : 0;
1130
- if (a >= t)
754
+ const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
755
+ I(r, "titleHeightMm"), I(i, "titleGapMm", !0);
756
+ const l = e.title !== void 0 && e.title.length > 0, o = l ? r + i : 0;
757
+ if (o >= t)
1131
758
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
1132
- return { dataset: n, titleHeightMm: i, hasTitle: o, titleSpaceMm: a };
759
+ return { dataset: n, titleHeightMm: r, hasTitle: l, titleSpaceMm: o };
1133
760
  }
1134
- function Yt(e) {
761
+ function Rt(e) {
1135
762
  if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
1136
763
  throw new Error("listOptions 必须是列表配置对象");
1137
764
  const t = e.listOptions ?? {};
1138
- ee(t.align, "listOptions.align", !0), ee(t.headerAlign, "listOptions.headerAlign", !1);
765
+ U(t.align, "listOptions.align", !0), U(t.headerAlign, "listOptions.headerAlign", !1);
1139
766
  for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
1140
- const i = t[n];
1141
- i !== void 0 && I(i, `listOptions.${n}`, n === "paddingMm");
767
+ const r = t[n];
768
+ r !== void 0 && I(r, `listOptions.${n}`, n === "paddingMm");
1142
769
  }
1143
770
  return t;
1144
771
  }
1145
- function qt(e) {
772
+ function It(e) {
1146
773
  let t = 0, n = 0;
1147
- for (const [i, r] of e.entries()) {
1148
- if (!r || typeof r.header != "string" || typeof r.field != "string" || !r.field.trim())
1149
- throw new Error(`columns[${i}] 需要字符串 header 与非空 field`);
1150
- ee(r.align, `columns[${i}].align`, !0), ee(r.headerAlign, `columns[${i}].headerAlign`, !1), r.flex !== void 0 && I(r.flex, `columns[${i}].flex`), r.widthMm !== void 0 ? (I(r.widthMm, `columns[${i}].widthMm`), t += r.widthMm) : n = Math.max(n, r.flex ?? 1);
774
+ for (const [r, i] of e.entries()) {
775
+ if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
776
+ throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
777
+ U(i.align, `columns[${r}].align`, !0), U(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && I(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (I(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
1151
778
  }
1152
779
  return { fixedWidthMm: t, maxFlex: n };
1153
780
  }
1154
- function Xt(e, t, n, i) {
1155
- const { fixedWidthMm: r, maxFlex: o } = qt(e.columns);
1156
- if (t === "page" && r > i)
1157
- throw new Error(`固定列宽 ${r}mm 超出页面可用宽度 ${i}mm`);
1158
- const a = i - r;
1159
- if (t === "page" && o > 0 && a <= 0)
781
+ function At(e, t, n, r) {
782
+ const { fixedWidthMm: i, maxFlex: l } = It(e.columns);
783
+ if (t === "page" && i > r)
784
+ throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
785
+ const o = r - i;
786
+ if (t === "page" && l > 0 && o <= 0)
1160
787
  throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
1161
- const s = o > 0 ? e.columns.reduce((d, c) => d + (c.widthMm === void 0 ? (c.flex ?? 1) / o : 0), 0) : 0;
1162
- return { columns: e.columns.map(({ widthMm: d, flex: c, ...m }, g) => {
1163
- const h = d ?? (t === "wide" ? n * (c ?? 1) : a * ((c ?? 1) / o) / s);
1164
- return I(h, `columns[${g}] 分配后的 widthMm`), { ...m, widthMm: h };
1165
- }), fixedWidthMm: r, maxFlex: o };
788
+ const a = l > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / l : 0), 0) : 0;
789
+ return { columns: e.columns.map(({ widthMm: c, flex: d, ...u }, m) => {
790
+ const f = c ?? (t === "wide" ? n * (d ?? 1) : o * ((d ?? 1) / l) / a);
791
+ return I(f, `columns[${m}] 分配后的 widthMm`), { ...u, widthMm: f };
792
+ }), fixedWidthMm: i, maxFlex: l };
1166
793
  }
1167
- function Wn(e) {
794
+ function xn(e) {
1168
795
  if (!e || typeof e != "object")
1169
796
  throw new Error("标准明细模板需要 options 对象");
1170
797
  if (!Array.isArray(e.columns) || e.columns.length === 0)
1171
798
  throw new Error("columns 至少需要一列");
1172
- const { layout: t, columnWidthMm: n } = Gt(e), i = Jt(e);
1173
- let r = i.widthMm;
1174
- const o = i.heightMm, a = Kt(e);
1175
- let s = r - a.marginLeftMm - a.marginRightMm;
1176
- const l = o - a.marginTopMm - a.marginBottomMm;
1177
- if (t === "page" && s <= 0 || l <= 0)
799
+ const { layout: t, columnWidthMm: n } = St(e), r = Ct(e);
800
+ let i = r.widthMm;
801
+ const l = r.heightMm, o = Pt(e);
802
+ let a = i - o.marginLeftMm - o.marginRightMm;
803
+ const s = l - o.marginTopMm - o.marginBottomMm;
804
+ if (t === "page" && a <= 0 || s <= 0)
1178
805
  throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
1179
- const { dataset: d, titleHeightMm: c, hasTitle: m, titleSpaceMm: g } = Ut(e, l), h = Yt(e), { columns: f, fixedWidthMm: u, maxFlex: p } = Xt(e, t, n, s);
1180
- t === "wide" && (s = f.reduce((M, T) => M + T.widthMm, 0), I(s, "宽表总列宽"), r = s + a.marginLeftMm + a.marginRightMm, I(r, "宽表总宽度"));
1181
- const b = { widthMm: r, heightMm: o, ...a, components: [], ...t === "wide" ? { layout: t } : {} };
1182
- return m && b.components.push({
806
+ const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } = kt(e, s), f = Rt(e), { columns: h, fixedWidthMm: g, maxFlex: b } = At(e, t, n, a);
807
+ t === "wide" && (a = h.reduce((T, k) => T + k.widthMm, 0), I(a, "宽表总列宽"), i = a + o.marginLeftMm + o.marginRightMm, I(i, "宽表总宽度"));
808
+ const x = { widthMm: i, heightMm: l, ...o, components: [], ...t === "wide" ? { layout: t } : {} };
809
+ return u && x.components.push({
1183
810
  kind: "text",
1184
811
  text: e.title,
1185
- leftMm: a.marginLeftMm,
1186
- topMm: a.marginTopMm,
1187
- widthMm: s,
1188
- heightMm: c,
812
+ leftMm: o.marginLeftMm,
813
+ topMm: o.marginTopMm,
814
+ widthMm: a,
815
+ heightMm: d,
1189
816
  style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
1190
- }), b.components.push({
817
+ }), x.components.push({
1191
818
  align: "auto",
1192
819
  headerAlign: "center",
1193
- ...h,
820
+ ...f,
1194
821
  kind: "list",
1195
822
  ...t === "wide" ? { layout: t } : {},
1196
- ...m ? { title: e.title } : {},
1197
- dataset: d,
1198
- columns: f,
1199
- leftMm: a.marginLeftMm,
1200
- topMm: a.marginTopMm + g,
1201
- widthMm: t === "wide" || p > 0 ? s : u
1202
- }), e.params === void 0 ? { pages: [b] } : { params: e.params, pages: [b] };
1203
- }
1204
- const We = "1.0";
1205
- class W extends Error {
1206
- constructor(t) {
1207
- super(`模板校验失败:${t.slice(0, 3).map((n) => `${n.path}: ${n.message}`).join("; ")}`), this.errors = t, this.name = "ReportTemplateError";
1208
- }
1209
- }
1210
- const Qt = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Zt = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), en = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), ae = 2e5, tn = 64, ge = 1e7;
1211
- function v(e) {
1212
- return !!e && typeof e == "object" && !Array.isArray(e);
1213
- }
1214
- function nn(e, t, n) {
1215
- const i = Object.getPrototypeOf(e), r = Array.isArray(e);
1216
- if (r ? i !== Array.prototype : i !== Object.prototype && i !== null)
1217
- return n.push({ path: t, message: "模板对象必须使用普通 JSON 对象原型" }), !1;
1218
- if (r) {
1219
- const o = Object.keys(e);
1220
- if (o.length !== e.length || o.some((a) => !/^(0|[1-9]\d*)$/.test(a) || Number(a) >= e.length))
1221
- return n.push({ path: t, message: "模板数组不能包含空位或额外属性" }), !1;
1222
- }
1223
- return Object.getOwnPropertySymbols(e).length > 0 ? (n.push({ path: t, message: "模板不能包含 Symbol 键" }), !1) : !0;
1224
- }
1225
- function rn(e, t, n, i) {
1226
- return Qt.has(e) ? (i.push({ path: n, message: "模板不能包含可能污染原型的键" }), !1) : t.get || t.set || !t.enumerable ? (i.push({ path: n, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
1227
- }
1228
- function on(e) {
1229
- return e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e);
1230
- }
1231
- function pe(e, t) {
1232
- const n = /* @__PURE__ */ new Set();
1233
- let i = 0, r = 0, o = !1;
1234
- const a = (s, l, d) => {
1235
- if (!o) {
1236
- if (++i > ae) {
1237
- i === ae + 1 && t.push({ path: l, message: "模板超过 JSON 节点安全上限" });
1238
- return;
1239
- }
1240
- if (d > tn) {
1241
- t.push({ path: l, message: "模板嵌套层级过深" });
1242
- return;
1243
- }
1244
- if (typeof s == "string") {
1245
- r += s.length, r > ge && (o = !0, t.push({ path: l, message: "模板文本超过 1000 万字符的安全上限" }));
1246
- return;
1247
- }
1248
- if (!on(s)) {
1249
- if (!s || typeof s != "object") {
1250
- t.push({ path: l, message: "模板只允许 JSON 值,不允许函数、undefined 或非有限数字" });
1251
- return;
1252
- }
1253
- if (n.has(s)) {
1254
- t.push({ path: l, message: "模板不能包含循环引用" });
1255
- return;
1256
- }
1257
- if (nn(s, l, t)) {
1258
- n.add(s);
1259
- for (const [c, m] of Object.entries(Object.getOwnPropertyDescriptors(s))) {
1260
- if (Array.isArray(s) && c === "length") continue;
1261
- const g = `${l}.${c}`;
1262
- if (rn(c, m, g, t) && a(m.value, g, d + 1), i > ae || o) break;
1263
- }
1264
- n.delete(s);
1265
- }
1266
- }
1267
- }
1268
- };
1269
- a(e, "$", 0);
1270
- }
1271
- function x(e, t, n, i, r = !1) {
1272
- const o = e[t];
1273
- o === void 0 && !r || (typeof o != "string" || r && !o.trim()) && i.push({ path: `${n}.${t}`, message: r ? "应为非空字符串" : "应为字符串" });
1274
- }
1275
- function A(e, t, n, i, r = 0, o = !1) {
1276
- const a = e[t];
1277
- a === void 0 && !o || (typeof a != "number" || !Number.isFinite(a) || a < r) && i.push({ path: `${n}.${t}`, message: `应为大于等于 ${r} 的有限数字` });
1278
- }
1279
- function Y(e, t, n, i) {
1280
- e[t] !== void 0 && typeof e[t] != "boolean" && i.push({ path: `${n}.${t}`, message: "应为布尔值" });
1281
- }
1282
- function J(e, t, n, i = !1) {
1283
- e !== void 0 && !en.has(e) && !(i && e === "auto") && n.push({ path: t, message: `未知对齐方式${i ? "(支持 auto)" : ""}` });
1284
- }
1285
- function H(e, t, n) {
1286
- if (e !== void 0) {
1287
- if (!v(e)) {
1288
- n.push({ path: t, message: "样式应为对象" });
1289
- return;
1290
- }
1291
- J(e.align, `${t}.align`, n), e.verticalAlign !== void 0 && !["top", "middle", "bottom"].includes(e.verticalAlign) && n.push({ path: `${t}.verticalAlign`, message: "未知垂直对齐方式" });
1292
- for (const i of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) A(e, i, t, n);
1293
- for (const i of ["letterSpacing", "rotateDeg"]) A(e, i, t, n, -1 / 0);
1294
- A(e, "opacity", t, n), typeof e.opacity == "number" && e.opacity > 1 && n.push({ path: `${t}.opacity`, message: "透明度不能大于 1" });
1295
- for (const i of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) Y(e, i, t, n);
1296
- for (const i of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) x(e, i, t, n);
1297
- }
1298
- }
1299
- function an(e, t, n) {
1300
- if (e === void 0) return;
1301
- if (!Array.isArray(e)) {
1302
- n.push({ path: t, message: "参数定义应为数组" });
1303
- return;
1304
- }
1305
- const i = /* @__PURE__ */ new Set();
1306
- e.forEach((r, o) => {
1307
- const a = `${t}.${o}`;
1308
- if (!v(r)) {
1309
- n.push({ path: a, message: "参数定义应为对象" });
1310
- return;
1311
- }
1312
- x(r, "field", a, n, !0), typeof r.field == "string" && (i.has(r.field) && n.push({ path: `${a}.field`, message: "参数名重复" }), i.add(r.field)), r.type !== void 0 && !["text", "number", "date", "select"].includes(r.type) && n.push({ path: `${a}.type`, message: "未知参数类型" });
1313
- for (const s of ["label", "defaultValue", "placeholder"]) x(r, s, a, n);
1314
- Y(r, "required", a, n), r.options !== void 0 && (Array.isArray(r.options) ? r.options.forEach((s, l) => {
1315
- const d = `${a}.options.${l}`;
1316
- if (!v(s)) n.push({ path: d, message: "选项应为对象" });
1317
- else
1318
- for (const c of ["label", "value"]) typeof s[c] != "string" && n.push({ path: `${d}.${c}`, message: "选项标签与值应为字符串(允许空白选项)" });
1319
- }) : n.push({ path: `${a}.options`, message: "选项应为数组" }));
1320
- });
1321
- }
1322
- function sn(e, t, n) {
1323
- if (!Array.isArray(e) || e.length === 0) {
1324
- n.push({ path: t, message: "列表至少需要一列" });
1325
- return;
1326
- }
1327
- e.forEach((i, r) => {
1328
- const o = `${t}.${r}`;
1329
- if (!v(i)) {
1330
- n.push({ path: o, message: "列应为对象" });
1331
- return;
1332
- }
1333
- if (Ae(i, o, n), typeof i.header != "string" && n.push({ path: `${o}.header`, message: "表头应为字符串(允许空白表头)" }), x(i, "field", o, n, !0), A(i, "widthMm", o, n, Number.MIN_VALUE, !0), H(i.style, `${o}.style`, n), H(i.headerStyle, `${o}.headerStyle`, n), J(i.align, `${o}.align`, n, !0), J(i.headerAlign, `${o}.headerAlign`, n), i.format !== void 0)
1334
- if (!v(i.format) || !["number", "percent", "date"].includes(i.format.kind))
1335
- n.push({ path: `${o}.format`, message: "未知列格式" });
1336
- else {
1337
- const a = i.format.digits;
1338
- a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0 || a > 100) && n.push({ path: `${o}.format.digits`, message: "小数位应为 0–100 的整数" }), Y(i.format, "thousands", `${o}.format`, n), x(i.format, "pattern", `${o}.format`, n);
1339
- }
1340
- i.rules !== void 0 && (Array.isArray(i.rules) ? i.rules.forEach((a, s) => {
1341
- const l = `${o}.rules.${s}`;
1342
- if (!v(a) || !v(a.when)) {
1343
- n.push({ path: l, message: "条件格式缺少 when 对象" });
1344
- return;
1345
- }
1346
- x(a.when, "field", `${l}.when`, n, !0), [">", ">=", "<", "<=", "==", "!="].includes(a.when.op) || n.push({ path: `${l}.when.op`, message: "未知条件运算符" }), typeof a.when.value != "number" && typeof a.when.value != "string" && n.push({ path: `${l}.when.value`, message: "条件值应为数字或字符串" }), H(a.style, `${l}.style`, n);
1347
- }) : n.push({ path: `${o}.rules`, message: "条件格式应为数组" }));
1348
- });
1349
- }
1350
- function ln(e, t, n) {
1351
- if (e !== void 0) {
1352
- if (!v(e)) {
1353
- n.push({ path: t, message: "分组应为对象" });
1354
- return;
1355
- }
1356
- x(e, "field", t, n, !0);
1357
- for (const i of ["headerTemplate", "subtotalLabel"]) x(e, i, t, n);
1358
- for (const i of ["headerStyle", "subtotalStyle"]) H(e[i], `${t}.${i}`, n);
1359
- Y(e, "keepWithNext", t, n), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((i) => typeof i != "string")) && n.push({ path: `${t}.subtotal`, message: "小计字段应为字符串数组" });
1360
- }
1361
- }
1362
- function dn(e, t, n) {
1363
- if (!(e === void 0 || typeof e == "boolean")) {
1364
- if (!v(e)) {
1365
- n.push({ path: t, message: "合计应为布尔值或对象" });
1366
- return;
1367
- }
1368
- x(e, "label", t, n), H(e.style, `${t}.style`, n), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((i) => typeof i != "string")) && n.push({ path: `${t}.fields`, message: "合计字段应为字符串数组" });
1369
- }
823
+ ...u ? { title: e.title } : {},
824
+ dataset: c,
825
+ columns: h,
826
+ leftMm: o.marginLeftMm,
827
+ topMm: o.marginTopMm + m,
828
+ widthMm: t === "wide" || b > 0 ? a : g
829
+ }), e.params === void 0 ? { pages: [x] } : { params: e.params, pages: [x] };
1370
830
  }
1371
- function cn(e, t, n) {
1372
- for (const i of ["leftMm", "topMm"]) A(e, i, t, n, -1 / 0, !0);
1373
- A(e, "widthMm", t, n, Number.MIN_VALUE, !0), x(e, "dataset", t, n, !0), x(e, "title", t, n), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" }), sn(e.columns, `${t}.columns`, n);
1374
- for (const i of ["fontSizePt", "rowHeightMm"]) A(e, i, t, n, Number.MIN_VALUE);
1375
- A(e, "paddingMm", t, n);
1376
- for (const i of ["headerBold", "headerEveryPage", "border"]) Y(e, i, t, n);
1377
- x(e, "headerBackgroundColor", t, n), J(e.align, `${t}.align`, n, !0), J(e.headerAlign, `${t}.headerAlign`, n), H(e.headerStyle, `${t}.headerStyle`, n), ln(e.groupBy, `${t}.groupBy`, n), dn(e.grandTotal, `${t}.grandTotal`, n);
1378
- }
1379
- function _e(e, t, n) {
1380
- H(e.style, `${t}.style`, n);
1381
- for (const r of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) x(e, r, t, n);
1382
- if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((r) => typeof r != "string")) && n.push({ path: `${t}.lines`, message: "文本行应为字符串数组" }), Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((r, o) => {
1383
- if (!v(r)) return;
1384
- const a = `${t}.richParagraphs.${o}`;
1385
- J(r.align, `${a}.align`, n);
1386
- for (const s of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) A(r, s, a, n);
1387
- Array.isArray(r.segments) && r.segments.forEach((s, l) => {
1388
- const d = `${a}.segments.${l}`;
1389
- if (!v(s)) {
1390
- n.push({ path: d, message: "富文本片段应为对象" });
1391
- return;
1392
- }
1393
- s.kind !== void 0 && s.kind !== "text" && s.kind !== "field" && n.push({ path: `${d}.kind`, message: "未知富文本片段类型" });
1394
- for (const c of ["text", "field"]) x(s, c, d, n);
1395
- H(s.style, `${d}.style`, n);
1396
- });
1397
- }), !v(e.grid)) return;
1398
- const i = e.grid;
1399
- A(i, "gapMm", `${t}.grid`, n), A(i, "paddingMm", `${t}.grid`, n);
1400
- for (const r of ["colWidthsMm", "rowHeightsMm"]) {
1401
- const o = i[r];
1402
- o !== void 0 && (!Array.isArray(o) || o.some((a) => typeof a != "number" || !Number.isFinite(a) || a < 0)) && n.push({ path: `${t}.grid.${r}`, message: "网格尺寸应为有限非负数字数组" });
1403
- }
1404
- Array.isArray(i.cells) && i.cells.forEach((r, o) => {
1405
- Array.isArray(r) && r.forEach((a, s) => {
1406
- const l = `${t}.grid.cells.${o}.${s}`;
1407
- if (a !== null) {
1408
- if (!v(a)) {
1409
- n.push({ path: l, message: "网格单元格应为对象或 null" });
1410
- return;
1411
- }
1412
- for (const d of ["text", "rawText", "numberFormat"]) x(a, d, l, n);
1413
- for (const d of ["colSpan", "rowSpan"]) {
1414
- const c = a[d];
1415
- c !== void 0 && (typeof c != "number" || !Number.isInteger(c) || c <= 0) && n.push({ path: `${l}.${d}`, message: "跨度应为正整数" });
1416
- }
1417
- a.value !== void 0 && a.value !== null && !["string", "number", "boolean"].includes(typeof a.value) && n.push({ path: `${l}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), H(a.style, `${l}.style`, n), a.children !== void 0 && (Array.isArray(a.children) ? a.children.forEach((d, c) => {
1418
- v(d) && _e(d, `${l}.children.${c}`, n);
1419
- }) : n.push({ path: `${l}.children`, message: "嵌套组件应为数组" }));
1420
- }
1421
- });
1422
- });
1423
- }
1424
- function Ve(e) {
1425
- const t = [], n = [];
1426
- return pe(e, t), t.length ? { ok: !1, errors: t, warnings: n } : (v(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== ce && t.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), an(e.params, "$.params", t), !Array.isArray(e.pages) || e.pages.length === 0 ? t.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((i, r) => {
1427
- const o = `$.pages.${r}`;
1428
- if (!v(i)) {
1429
- t.push({ path: o, message: "页应为对象" });
1430
- return;
1431
- }
1432
- A(i, "widthMm", o, t, Number.MIN_VALUE, !0), A(i, "heightMm", o, t, Number.MIN_VALUE, !0), i.layout !== void 0 && i.layout !== "page" && i.layout !== "wide" && t.push({ path: `${o}.layout`, message: "布局应为 page 或 wide" }), typeof i.heightMm == "number" && i.heightMm >= 5e3 && t.push({ path: `${o}.heightMm`, message: "页高应小于 5000mm" });
1433
- for (const a of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) A(i, a, o, t);
1434
- typeof i.widthMm == "number" && Number(i.marginLeftMm ?? 0) + Number(i.marginRightMm ?? 0) >= i.widthMm && t.push({ path: o, message: "横向页边距占满页面" }), typeof i.heightMm == "number" && Number(i.marginTopMm ?? 0) + Number(i.marginBottomMm ?? 0) >= i.heightMm && t.push({ path: o, message: "纵向页边距占满页面" }), Array.isArray(i.components) ? i.components.forEach((a, s) => {
1435
- const l = `${o}.components.${s}`;
1436
- v(a) && a.kind === "list" ? cn(a, l, t) : (ue(a, l, t, n), v(a) && _e(a, l, t));
1437
- }) : t.push({ path: `${o}.components`, message: "组件应为数组" });
1438
- })) : t.push({ path: "$", message: "模板应为对象" }), { ok: t.length === 0, errors: t, warnings: n });
1439
- }
1440
- function mn(e) {
1441
- const t = [], n = [];
1442
- if (pe(e, t), t.length) return { ok: !1, errors: t, warnings: n };
1443
- if (!v(e)) t.push({ path: "$", message: "模板文档应为对象" });
1444
- else {
1445
- for (const r of Object.keys(e))
1446
- Zt.has(r) || t.push({ path: `$.${r}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
1447
- e.schemaVersion !== We && t.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
1448
- for (const r of ["id", "name"]) x(e, r, "$", t, !0);
1449
- for (const r of ["revision", "description"]) x(e, r, "$", t);
1450
- const i = Ve(e.template);
1451
- t.push(...i.errors.map((r) => ({ ...r, path: `$.template${r.path.slice(1)}` }))), n.push(...i.warnings.map((r) => ({ ...r, path: `$.template${r.path.slice(1)}` })));
1452
- }
1453
- return { ok: t.length === 0, errors: t, warnings: n };
831
+ function Tn(e) {
832
+ return e;
1454
833
  }
1455
- function re(e) {
1456
- const t = mn(e);
1457
- if (!t.ok) throw new W(t.errors);
1458
- }
1459
- function _n(e) {
1460
- const t = [];
1461
- if (pe(e, t), t.length) throw new W(t);
1462
- const n = { ...e, schemaVersion: e.schemaVersion ?? We };
1463
- return re(n), te(n);
1464
- }
1465
- function Vn(e) {
1466
- let t = e;
1467
- if (typeof e == "string") {
1468
- if (e.length > ge)
1469
- throw new W([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1470
- try {
1471
- t = JSON.parse(e);
1472
- } catch {
1473
- throw new W([{ path: "$", message: "模板 JSON 语法无效" }]);
1474
- }
834
+ class L extends Error {
835
+ constructor(t, n) {
836
+ super(n), this.code = t, this.name = "ReportTemplateStoreError";
1475
837
  }
1476
- return re(t), te(t);
1477
- }
1478
- function Gn(e) {
1479
- re(e);
1480
- const t = JSON.stringify(e, null, 2);
1481
- if (t.length > ge) throw new W([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1482
- return t;
1483
838
  }
1484
- function te(e) {
839
+ function A(e) {
1485
840
  return JSON.parse(JSON.stringify(e));
1486
841
  }
1487
- function Jn(e = []) {
1488
- const t = /* @__PURE__ */ new Map(), n = {
1489
- get: (i) => {
1490
- const r = t.get(i);
1491
- return r ? te(r) : void 0;
842
+ function P(e) {
843
+ if (!e?.aborted) return;
844
+ const t = new Error("模板操作已取消");
845
+ throw t.name = "AbortError", t;
846
+ }
847
+ function ve(e) {
848
+ const t = e ? Number(e.revision) : 0;
849
+ if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
850
+ return String(t + 1);
851
+ }
852
+ function En(e, t = {}) {
853
+ const n = async (o, a) => {
854
+ P(a);
855
+ const s = await e.read(o, a);
856
+ return P(a), s ? A(s) : void 0;
857
+ }, r = async (o, a) => {
858
+ const s = await n(o, a.signal);
859
+ if ((s?.revision ?? null) !== a.expectedRevision) throw new L("conflict", "模板已变化,请重新读取后提交");
860
+ return s;
861
+ }, i = async (o, a, s) => {
862
+ if (P(a.signal), !await e.compareAndSwap(o.id, a.expectedRevision, A(o), { signal: a.signal, ...s ? { publication: A(s) } : {} })) throw new L("conflict", "模板已被其他请求更新");
863
+ return A(o);
864
+ }, l = (o, a, s, c) => {
865
+ const d = ve(o), u = ne({ ...a, revision: d }), m = { revision: d, document: u, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
866
+ return c !== void 0 && (m.restoredFrom = c), i({ id: o.id, revision: d, publishedRevision: d, published: u }, s, m);
867
+ };
868
+ return {
869
+ list: async (o) => {
870
+ P(o);
871
+ const a = await e.list(o);
872
+ return P(o), A(a);
1492
873
  },
1493
- list: () => Array.from(t.values(), ({ template: i, ...r }) => ({ ...r })),
1494
- register: (i, r = {}) => {
1495
- if (re(i), t.has(i.id) && !r.replace) throw new W([{ path: "$.id", message: `模板 ID ${i.id} 已注册;更新需显式 replace:true` }]);
1496
- t.set(i.id, te(i));
874
+ get: async (o, a = {}) => {
875
+ const s = await n(o, a.signal), c = a.draft ? s?.draft : s?.published;
876
+ return c ? ne(c) : void 0;
1497
877
  },
1498
- remove: (i) => t.delete(i)
1499
- };
1500
- for (const i of e) n.register(i);
1501
- return n;
1502
- }
1503
- function Kn(e) {
1504
- if (!("mapData" in e)) return e;
1505
- const { load: t, mapData: n, ...i } = e;
1506
- return { ...i, load: async (r) => {
1507
- const o = await t(r);
1508
- F(r.signal);
1509
- try {
1510
- return n(o, r);
1511
- } catch (a) {
1512
- throw new N("validate", `报表 ${r.reportId} 数据映射失败`, a);
878
+ history: async (o, a) => {
879
+ P(a);
880
+ const s = await e.history(o, a);
881
+ return P(a), A(s);
882
+ },
883
+ saveDraft: async (o, a) => {
884
+ P(a.signal);
885
+ const s = ne(t.migrate ? await t.migrate(o) : o), c = await r(s.id, a), d = ve(c);
886
+ return i({
887
+ id: s.id,
888
+ revision: d,
889
+ draft: { ...s, revision: d },
890
+ ...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
891
+ }, a);
892
+ },
893
+ publish: async (o, a) => {
894
+ const s = await r(o, a);
895
+ if (!s) throw new L("missing", "模板不存在");
896
+ if (!s.draft) throw new L("draft", "没有可发布的草稿");
897
+ return l(s, s.draft, a);
898
+ },
899
+ rollback: async (o, a, s) => {
900
+ const c = await r(o, s);
901
+ if (!c) throw new L("missing", "模板不存在");
902
+ P(s.signal);
903
+ const d = await e.getVersion(o, a, s.signal);
904
+ if (!d) throw new L("history", "历史修订不存在");
905
+ return l(c, d.document, s, a);
1513
906
  }
1514
- } };
1515
- }
1516
- class N extends Error {
1517
- constructor(t, n, i) {
1518
- super(n), this.name = "ReportSourceError", this.code = t, this.cause = i;
1519
- }
1520
- }
1521
- function oe(e) {
1522
- const t = new Error("报表加载已取消");
1523
- return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
1524
- }
1525
- function F(e) {
1526
- if (e?.aborted) throw oe(e);
1527
- }
1528
- function Ge(e, t) {
1529
- return t ? new Promise((n, i) => {
1530
- const r = () => t.removeEventListener("abort", o), o = () => {
1531
- r(), i(oe(t));
1532
- };
1533
- t.addEventListener("abort", o, { once: !0 }), t.aborted && o(), Promise.resolve(e).then(
1534
- (a) => {
1535
- r(), n(a);
1536
- },
1537
- (a) => {
1538
- r(), i(a);
1539
- }
1540
- );
1541
- }) : Promise.resolve(e);
1542
- }
1543
- function fn(e, t) {
1544
- if (!e || typeof e != "object" || Array.isArray(e))
1545
- throw new N("validate", `报表 ${t} 的数据集应为对象`);
1546
- for (const [n, i] of Object.entries(e))
1547
- if (!Array.isArray(i) || i.some((r) => !r || typeof r != "object" || Array.isArray(r)))
1548
- throw new N("validate", `报表 ${t} 的数据集 ${n} 应为对象数组`);
1549
- }
1550
- async function un(e, t, n) {
1551
- const { reportId: i, signal: r } = t;
1552
- try {
1553
- const o = await Ge(e(t), r);
1554
- F(r);
1555
- const a = Ve(o);
1556
- if (!a.ok)
1557
- throw new N("validate", `报表 ${i} 模板校验失败:${a.errors.slice(0, 3).map((s) => `${s.path}: ${s.message}`).join("; ")}`);
1558
- return n.push(...a.warnings.map((s) => `${i}: ${s.path}: ${s.message}`)), o;
1559
- } catch (o) {
1560
- throw r?.aborted ? oe(r) : o instanceof N ? o : o instanceof W ? new N("validate", `报表 ${i} 模板校验失败:${o.message}`, o) : new N("fetch", `报表 ${i} 模板加载失败:${o instanceof Error ? o.message : String(o)}`, o);
1561
- }
1562
- }
1563
- async function hn(e, t, n, i) {
1564
- let r;
1565
- try {
1566
- r = await Ge(e.load ? e.load(t) : e.datasets ?? {}, i);
1567
- } catch (o) {
1568
- throw i?.aborted ? oe(i) : o instanceof N ? o : new N("fetch", `报表 ${n} 取数失败:${o instanceof Error ? o.message : String(o)}`, o);
1569
- }
1570
- return F(i), fn(r, n), r;
1571
- }
1572
- function gn(e, t, n, i) {
1573
- try {
1574
- return kt(e, t, n.pagination);
1575
- } catch (r) {
1576
- throw new N("validate", `报表 ${i} 排版失败:${r instanceof Error ? r.message : String(r)}`, r);
1577
- }
1578
- }
1579
- function pn(e, t, n, i) {
1580
- const r = /* @__PURE__ */ new Map(), o = (a) => {
1581
- let s = r.get(a);
1582
- return s === void 0 && (s = JSON.stringify([n, i, a]), r.set(a, s)), s;
1583
907
  };
1584
- for (const a of t.pages) e.push({
1585
- ...a,
1586
- components: a.components.map((s) => s.table ? {
1587
- ...s,
1588
- table: { ...s.table, id: o(s.table.id) }
1589
- } : s)
1590
- });
1591
908
  }
1592
- function Un(e, t = {}) {
1593
- function n(r) {
1594
- const o = Object.prototype.hasOwnProperty.call(e, r) ? e[r] : void 0;
1595
- if (!o) throw new N("config", `未注册报表 ${r}`);
1596
- return o;
1597
- }
1598
- return Object.assign(async ({ reportIds: r, params: o, signal: a, onWarning: s }) => {
1599
- F(a);
1600
- const l = [...r], d = { ...o };
1601
- if (l.length === 0) throw new N("config", "缺少报表 ID");
1602
- const c = l.map(n), m = [], g = [];
1603
- for (const [p, b] of c.entries()) {
1604
- F(a);
1605
- const M = l[p], T = { reportId: M, params: { ...d }, signal: a }, w = typeof b.template == "function" ? await un(b.template, T, g) : b.template, B = await hn(b, T, M, a);
1606
- F(a);
1607
- const _ = gn(w, B, b, M);
1608
- pn(m, _.plan, p, M), g.push(..._.warnings.map((j) => `${M}: ${j}`));
909
+ function Sn() {
910
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
911
+ return {
912
+ read: async (n, r) => {
913
+ P(r);
914
+ const i = e.get(n);
915
+ return i ? A(i) : void 0;
916
+ },
917
+ list: async (n) => (P(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: l }) => ({ id: r, revision: i, ...l ? { publishedRevision: l } : {} }))),
918
+ history: async (n, r) => (P(r), Array.from(t.get(n)?.values() ?? [], (i) => A(i))),
919
+ getVersion: async (n, r, i) => {
920
+ P(i);
921
+ const l = t.get(n)?.get(r);
922
+ return l ? A(l) : void 0;
923
+ },
924
+ compareAndSwap: async (n, r, i, l) => {
925
+ if (P(l.signal), (e.get(n)?.revision ?? null) !== r) return !1;
926
+ if (i.id !== n) throw new L("history", "状态 ID 与存储 ID 不一致");
927
+ const o = A(i), a = l.publication;
928
+ if (a) {
929
+ const s = t.get(n) ?? /* @__PURE__ */ new Map();
930
+ if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new L("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
931
+ s.set(a.revision, A(a)), t.set(n, s);
932
+ }
933
+ return e.set(n, o), !0;
1609
934
  }
1610
- F(a);
1611
- const h = { schemaVersion: ce, pages: m }, f = Pe(h);
1612
- if (!f.ok)
1613
- throw new N("validate", `渲染计划校验失败:${f.errors.slice(0, 3).map((p) => `${p.path}: ${p.message}`).join("; ")}`);
1614
- g.push(...f.warnings.map((p) => `${p.path}: ${p.message}`));
1615
- const u = s ?? t.onWarning ?? ((p) => console.warn("[mach-report]", p));
1616
- for (const p of g)
1617
- F(a), u(p);
1618
- return F(a), h;
1619
- }, {
1620
- getParamDefs: (r) => et(e, r)
1621
- });
935
+ };
1622
936
  }
1623
- function yn(e) {
1624
- return [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
937
+ function Oe(e) {
938
+ return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
1625
939
  }
1626
- function Je(e, t, n) {
1627
- const i = e.grid;
1628
- if (!i) return null;
1629
- const r = i.cells[t];
940
+ function ze(e, t, n) {
941
+ const r = e.grid;
1630
942
  if (!r) return null;
1631
- const a = me(i, e.widthMm, e.heightMm).cells.filter((l) => l.ri === t).findIndex((l) => l.ci === n), s = r[a];
1632
- return s ? { cell: s, sourceColumnIndex: a } : null;
943
+ const i = r.cells[t];
944
+ if (!i) return null;
945
+ const o = W(r, e.widthMm, e.heightMm).cells.filter((s) => s.ri === t).findIndex((s) => s.ci === n), a = i[o];
946
+ return a ? { cell: a, sourceColumnIndex: o } : null;
1633
947
  }
1634
- function bn(e) {
948
+ function $t(e) {
1635
949
  return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
1636
950
  }
1637
- function Mn(e, t) {
951
+ function Nt(e, t) {
1638
952
  return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
1639
953
  }
1640
- function wn(e, t) {
954
+ function Lt(e, t) {
1641
955
  if (e.editable === !1) return "cell";
1642
956
  if (e.formula !== void 0) return "formula";
1643
957
  if (e.children?.length) return "complex";
1644
958
  if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
1645
959
  }
1646
- function $n(e, t) {
960
+ function Ft(e, t) {
1647
961
  const n = e.table;
1648
962
  if (n)
1649
963
  return {
@@ -1653,186 +967,461 @@ function $n(e, t) {
1653
967
  columnKey: n.columnKeys[t.columnIndex]
1654
968
  };
1655
969
  }
1656
- function ye(e, t) {
1657
- if (!yn(t)) return null;
1658
- const n = e.pages[t.pageIndex]?.components[t.componentIndex];
1659
- if (!n) return null;
1660
- const i = Je(n, t.rowIndex, t.columnIndex);
1661
- if (!i) return null;
1662
- const { cell: r } = i, o = bn(r), a = wn(r, n);
970
+ function Dt(e, t, n) {
971
+ if (e.source) return { ...e.source };
972
+ const r = t.table?.source, i = t.table?.columnKeys[n.columnIndex];
973
+ if (!(!r || r.rowKey === void 0 || i === void 0))
974
+ return { ...r, rowKey: r.rowKey, field: i };
975
+ }
976
+ function je(e, t, n) {
977
+ const r = $t(n), i = Lt(n, e);
1663
978
  return {
1664
979
  address: { ...t },
1665
- cell: r,
1666
- component: n,
1667
- value: o,
1668
- valueType: Mn(r, o),
1669
- table: $n(n, t),
1670
- editable: a === void 0,
1671
- readOnlyReason: a
980
+ cell: n,
981
+ component: e,
982
+ value: r,
983
+ valueType: Nt(n, r),
984
+ table: Ft(e, t),
985
+ source: Dt(n, e, t),
986
+ editable: i === void 0,
987
+ readOnlyReason: i
1672
988
  };
1673
989
  }
1674
- class L extends Error {
990
+ function ce(e, t) {
991
+ if (!Oe(t)) return null;
992
+ const n = e.pages[t.pageIndex]?.components[t.componentIndex];
993
+ if (!n) return null;
994
+ const r = ze(n, t.rowIndex, t.columnIndex);
995
+ return r ? je(n, t, r.cell) : null;
996
+ }
997
+ function de(e) {
998
+ const t = /* @__PURE__ */ new Map();
999
+ return (n) => {
1000
+ if (!Oe(n)) return null;
1001
+ const r = e.pages[n.pageIndex]?.components[n.componentIndex];
1002
+ if (!r?.grid) return null;
1003
+ let i = t.get(r);
1004
+ if (!i) {
1005
+ const o = /* @__PURE__ */ new Map();
1006
+ i = /* @__PURE__ */ new Map();
1007
+ for (const a of W(r.grid, r.widthMm, r.heightMm).cells) {
1008
+ const s = o.get(a.ri) ?? 0;
1009
+ o.set(a.ri, s + 1);
1010
+ const c = r.grid.cells[a.ri]?.[s];
1011
+ c && i.set(`${a.ri}:${a.ci}`, c);
1012
+ }
1013
+ t.set(r, i);
1014
+ }
1015
+ const l = i.get(`${n.rowIndex}:${n.columnIndex}`);
1016
+ return l ? je(r, n, l) : null;
1017
+ };
1018
+ }
1019
+ class M extends Error {
1675
1020
  constructor(t) {
1676
1021
  super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
1677
1022
  }
1678
1023
  }
1679
- function vn(e, t) {
1024
+ function Ot(e, t) {
1680
1025
  let n = e.trim();
1681
- const i = t && n.endsWith("%");
1682
- if (i && (n = n.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n) && (n = n.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n)) throw new L("number");
1683
- return Number(n) / (i ? 100 : 1);
1026
+ const r = t && n.endsWith("%");
1027
+ if (r && (n = n.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n) && (n = n.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n)) throw new M("number");
1028
+ return Number(n) / (r ? 100 : 1);
1684
1029
  }
1685
- function Sn(e, t) {
1030
+ function zt(e, t) {
1686
1031
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1687
- if (typeof e != "string" && typeof e != "number") throw new L("number");
1688
- const n = typeof e == "number" ? e : vn(e, nt(t.cell.numberFormat));
1689
- if (!Number.isFinite(n) || Number.isInteger(n) && !Number.isSafeInteger(n)) throw new L("number");
1032
+ if (typeof e != "string" && typeof e != "number") throw new M("number");
1033
+ const n = typeof e == "number" ? e : Ot(e, Qe(t.cell.numberFormat));
1034
+ if (!Number.isFinite(n) || Number.isInteger(n) && !Number.isSafeInteger(n)) throw new M("number");
1690
1035
  return n;
1691
1036
  }
1692
- function xn(e) {
1037
+ function jt(e) {
1693
1038
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1694
1039
  if (typeof e == "boolean") return e;
1695
1040
  const t = String(e).trim().toLowerCase();
1696
1041
  if (["true", "yes", "是", "1"].includes(t)) return !0;
1697
1042
  if (["false", "no", "否", "0"].includes(t)) return !1;
1698
- throw new L("boolean");
1043
+ throw new M("boolean");
1699
1044
  }
1700
- function Ke(e, t) {
1701
- return e.valueType === "number" ? Sn(t, e) : e.valueType === "boolean" ? xn(t) : t === null ? null : String(t);
1045
+ function ue(e, t) {
1046
+ return e.valueType === "number" ? zt(t, e) : e.valueType === "boolean" ? jt(t) : t === null ? null : String(t);
1702
1047
  }
1703
- function kn(e, t) {
1704
- const n = t.cell.text, r = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((o) => o.includes(n ?? ""));
1705
- return r ? r[e ? 0 : 1] : String(e);
1048
+ function Ht(e, t) {
1049
+ const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((l) => l.includes(n ?? ""));
1050
+ return i ? i[e ? 0 : 1] : String(e);
1706
1051
  }
1707
- function be(e, t) {
1708
- return t === null ? "" : typeof t == "boolean" ? kn(t, e) : typeof t == "number" ? tt(t, e.cell.numberFormat) : String(t);
1052
+ function Q(e, t) {
1053
+ return t === null ? "" : typeof t == "boolean" ? Ht(t, e) : typeof t == "number" ? Xe(t, e.cell.numberFormat) : String(t);
1709
1054
  }
1710
- function Yn(e, t, n) {
1711
- const i = ye(e, t);
1712
- if (!i) throw new L("missing");
1713
- if (!i.editable) throw new L("readonly");
1714
- const r = Ke(i, n);
1055
+ function Cn(e, t, n) {
1056
+ const r = ce(e, t);
1057
+ if (!r) throw new M("missing");
1058
+ return me(r, n);
1059
+ }
1060
+ function me(e, t) {
1061
+ if (!e.editable) throw new M("readonly");
1062
+ const n = ue(e, t);
1715
1063
  return {
1716
- address: { ...t },
1717
- table: i.table,
1718
- previousValue: i.value,
1719
- previousText: i.cell.text ?? "",
1720
- value: r,
1721
- text: be(i, r)
1064
+ address: { ...e.address },
1065
+ table: e.table,
1066
+ source: e.source,
1067
+ previousValue: e.value,
1068
+ previousText: e.cell.text ?? "",
1069
+ value: n,
1070
+ text: Q(e, n)
1722
1071
  };
1723
1072
  }
1724
- function Tn(e, t) {
1725
- const n = e.table, i = t.table;
1726
- return !n || !i || n.columnKey === void 0 ? !1 : n.id === i.id && n.rowIndex === i.rowIndex && n.role === i.role && n.columnKey === i.columnKey;
1727
- }
1728
- function Ue(e, t, n) {
1729
- const i = e.grid, { rowIndex: r, columnIndex: o } = t.address, a = Je(e, r, o), s = [...i.cells], l = [...s[r]], d = be(t, n.value), c = { ...a.cell, value: n.value, text: d, rawText: d };
1730
- return l[a.sourceColumnIndex] = c, s[r] = l, { ...e, grid: { ...i, cells: s } };
1731
- }
1732
- function En(e, t) {
1733
- const n = e.table?.columnKeys, i = t.table?.columnKey;
1734
- return n && i !== void 0 ? n.flatMap((r, o) => r === i ? [o] : []) : [];
1735
- }
1736
- function An(e, t, n, i, r, o) {
1737
- const a = t.table, s = r.table;
1738
- if (!a || !s || a.id !== s.id || a.role !== s.role || !t.grid) return t;
1739
- const l = s.rowIndex - a.rowIndex;
1740
- if (l < 0 || l >= t.grid.cells.length) return t;
1741
- let d = t;
1742
- for (const c of En(t, r)) {
1743
- const m = ye(e, { pageIndex: n, componentIndex: i, rowIndex: l, columnIndex: c });
1744
- m?.editable && Tn(r, m) && (d = Ue(d, m, o));
1073
+ function Wt(e, t) {
1074
+ const n = e.table, r = t.table;
1075
+ return !n || !r || n.columnKey === void 0 ? !1 : n.id === r.id && n.rowIndex === r.rowIndex && n.role === r.role && n.columnKey === r.columnKey;
1076
+ }
1077
+ function He(e, t, n) {
1078
+ const r = e.grid, { rowIndex: i, columnIndex: l } = t.address, o = ze(e, i, l), a = [...r.cells], s = [...a[i]], c = Q(t, n.value), d = { ...o.cell, value: n.value, text: c, rawText: c };
1079
+ return s[o.sourceColumnIndex] = d, a[i] = s, { ...e, grid: { ...r, cells: a } };
1080
+ }
1081
+ function Bt(e, t) {
1082
+ const n = e.table?.columnKeys, r = t.table?.columnKey;
1083
+ return n && r !== void 0 ? n.flatMap((i, l) => i === r ? [l] : []) : [];
1084
+ }
1085
+ function _t(e, t, n, r, i, l) {
1086
+ const o = t.table, a = i.table;
1087
+ if (!o || !a || o.id !== a.id || o.role !== a.role || !t.grid) return t;
1088
+ const s = a.rowIndex - o.rowIndex;
1089
+ if (s < 0 || s >= t.grid.cells.length) return t;
1090
+ let c = t;
1091
+ for (const d of Bt(t, i)) {
1092
+ const u = ce(e, { pageIndex: n, componentIndex: r, rowIndex: s, columnIndex: d });
1093
+ u?.editable && Wt(i, u) && (c = He(c, u, l));
1094
+ }
1095
+ return c;
1096
+ }
1097
+ function Kt(e, t, n, r, i, l) {
1098
+ const o = i.address;
1099
+ return i.table?.columnKey !== void 0 ? _t(e, t, n, r, i, l) : o.pageIndex === n && o.componentIndex === r ? He(t, i, l) : t;
1100
+ }
1101
+ function We(e, t) {
1102
+ const n = t.source;
1103
+ if (!n) return !1;
1104
+ const r = e.source;
1105
+ return !r || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((i) => !Object.is(r[i], n[i]));
1106
+ }
1107
+ function Pn(e, t) {
1108
+ const n = ce(e, t.address);
1109
+ if (!n) throw new M("missing");
1110
+ if (!n.editable) throw new M("readonly");
1111
+ if (We(n, t)) throw new M("conflict");
1112
+ if (!Object.is(n.value, t.previousValue) || (n.cell.text ?? "") !== t.previousText) throw new M("conflict");
1113
+ const r = ue(n, t.value), i = { ...t, value: r, text: Q(n, r) };
1114
+ if (Object.is(r, n.value) && i.text === n.cell.text) return e;
1115
+ const l = e.pages.map((o, a) => {
1116
+ const s = o.components.map((c, d) => Kt(e, c, a, d, n, i));
1117
+ return s.every((c, d) => c === o.components[d]) ? o : { ...o, components: s };
1118
+ });
1119
+ return { ...e, pages: l };
1120
+ }
1121
+ function Vt(e) {
1122
+ return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
1123
+ }
1124
+ function ye(e) {
1125
+ const t = e.table;
1126
+ return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Vt(e.address);
1127
+ }
1128
+ function qt(e, t) {
1129
+ if (!t.length) return e;
1130
+ const n = new Map(t.map((s) => [ye(s), s])), r = new Set(t.flatMap((s) => s.table ? [s.table.id] : [])), i = new Set(t.map((s) => `${s.address.pageIndex}:${s.address.componentIndex}`)), l = de(e);
1131
+ function o(s, c, d) {
1132
+ const u = s.grid;
1133
+ if (!u || !i.has(`${c}:${d}`) && !r.has(s.table?.id ?? "")) return s;
1134
+ const m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1135
+ for (const h of W(u, s.widthMm, s.heightMm).cells) {
1136
+ const g = f.get(h.ri) ?? 0;
1137
+ f.set(h.ri, g + 1);
1138
+ const b = l({ pageIndex: c, componentIndex: d, rowIndex: h.ri, columnIndex: h.ci }), x = b && n.get(ye(b));
1139
+ if (!x || !b.editable) continue;
1140
+ const T = m.get(h.ri) ?? [...u.cells[h.ri]], k = Q(b, x.value);
1141
+ Object.is(b.value, x.value) && k === b.cell.text || (T[g] = { ...h.cell, value: x.value, text: k, rawText: k }, m.set(h.ri, T));
1142
+ }
1143
+ return m.size ? { ...s, grid: { ...u, cells: u.cells.map((h, g) => m.get(g) ?? h) } } : s;
1144
+ }
1145
+ const a = e.pages.map((s, c) => {
1146
+ const d = s.components.map((u, m) => o(u, c, m));
1147
+ return d.every((u, m) => u === s.components[m]) ? s : { ...s, components: d };
1148
+ });
1149
+ return a.every((s, c) => s === e.pages[c]) ? e : { ...e, pages: a };
1150
+ }
1151
+ function fe(e) {
1152
+ const t = e.source;
1153
+ if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
1154
+ const n = e.table;
1155
+ if (n?.columnKey !== void 0) return JSON.stringify([n.id, n.role, n.rowIndex, n.columnKey]);
1156
+ const r = e.address;
1157
+ return JSON.stringify([r.pageIndex, r.componentIndex, r.rowIndex, r.columnIndex]);
1158
+ }
1159
+ function kn(e, t, n) {
1160
+ if (typeof n != "string" || !n.trim() || !Array.isArray(t)) throw new M("missing");
1161
+ if (t.length > 1e4) throw new M("limit");
1162
+ const r = /* @__PURE__ */ new Set(), i = de(e), l = t.map(({ address: o, value: a }) => {
1163
+ const s = i(o);
1164
+ if (!s) throw new M("missing");
1165
+ const c = me(s, a), d = fe(c);
1166
+ if (r.has(d)) throw new M("duplicate");
1167
+ return r.add(d), c;
1168
+ });
1169
+ return { requestId: n, edits: l };
1170
+ }
1171
+ function Rn(e, t) {
1172
+ if (t.edits.length > 1e4) throw new M("limit");
1173
+ const n = de(e), r = /* @__PURE__ */ new Set(), i = t.edits.map((l) => {
1174
+ const o = n(l.address);
1175
+ if (!o) throw new M("missing");
1176
+ const a = fe(l);
1177
+ if (r.has(a)) throw new M("duplicate");
1178
+ if (r.add(a), We(o, l) || !Object.is(o.value, l.previousValue) || (o.cell.text ?? "") !== l.previousText) throw new M("conflict");
1179
+ return me(o, l.value);
1180
+ });
1181
+ return qt(e, i);
1182
+ }
1183
+ function In(e) {
1184
+ const t = /* @__PURE__ */ new Map();
1185
+ for (const n of e) {
1186
+ const r = fe(n), i = t.get(r), l = i ? { ...n, previousValue: i.previousValue, previousText: i.previousText } : { ...n };
1187
+ Object.is(l.previousValue, l.value) ? t.delete(r) : t.set(r, l);
1745
1188
  }
1746
- return d;
1747
- }
1748
- function Pn(e, t, n, i, r, o) {
1749
- const a = r.address;
1750
- return r.table?.columnKey !== void 0 ? An(e, t, n, i, r, o) : a.pageIndex === n && a.componentIndex === i ? Ue(t, r, o) : t;
1751
- }
1752
- function qn(e, t) {
1753
- const n = ye(e, t.address);
1754
- if (!n) throw new L("missing");
1755
- if (!n.editable) throw new L("readonly");
1756
- if (!Object.is(n.value, t.previousValue) || (n.cell.text ?? "") !== t.previousText) throw new L("conflict");
1757
- const i = Ke(n, t.value), r = { ...t, value: i, text: be(n, i) };
1758
- if (Object.is(i, n.value) && r.text === n.cell.text) return e;
1759
- const o = e.pages.map((a, s) => {
1760
- const l = a.components.map((d, c) => Pn(e, d, s, c, n, r));
1761
- return l.every((d, c) => d === a.components[c]) ? a : { ...a, components: l };
1189
+ return [...t.values()];
1190
+ }
1191
+ function An(e) {
1192
+ return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
1193
+ `);
1194
+ }
1195
+ function Gt(e, t) {
1196
+ const n = e[e.length - 1];
1197
+ e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
1198
+ }
1199
+ function $n(e, t = 1e4) {
1200
+ if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
1201
+ const n = [[]];
1202
+ let r = "", i = !1, l = !1, o = 0;
1203
+ function a() {
1204
+ if (++o > t) throw new Error("Clipboard cell limit exceeded");
1205
+ n[n.length - 1].push(r), r = "", l = !1;
1206
+ }
1207
+ for (let s = 0; s < e.length; s++) {
1208
+ const c = e[s];
1209
+ if (i) {
1210
+ if (c !== '"') {
1211
+ r += c;
1212
+ continue;
1213
+ }
1214
+ if (e[s + 1] === '"') {
1215
+ r += '"', s++;
1216
+ continue;
1217
+ }
1218
+ i = !1, l = !0;
1219
+ continue;
1220
+ }
1221
+ if (c === '"' && !r && !l) {
1222
+ i = !0;
1223
+ continue;
1224
+ }
1225
+ if (c === " ") {
1226
+ a();
1227
+ continue;
1228
+ }
1229
+ if (c === "\r" || c === `
1230
+ `) {
1231
+ a(), n.push([]), c === "\r" && e[s + 1] === `
1232
+ ` && s++;
1233
+ continue;
1234
+ }
1235
+ if (l) throw new Error("Invalid quoted clipboard value");
1236
+ r += c;
1237
+ }
1238
+ if (i) throw new Error("Unclosed clipboard quote");
1239
+ return a(), Gt(n, e), n;
1240
+ }
1241
+ function Nn(e, t, n) {
1242
+ if (!n || n.revision === void 0 && n.sourceToken === void 0) return e;
1243
+ const r = new Set(t.edits.flatMap((o) => o.source ? [o.source.datasetId] : []));
1244
+ if (!r.size) return e;
1245
+ function i(o) {
1246
+ return !o.datasetId || !r.has(o.datasetId) || (n.revision === void 0 || Object.is(n.revision, o.revision)) && (n.sourceToken === void 0 || n.sourceToken === o.sourceToken) ? o : { ...o, ...n.revision !== void 0 ? { revision: n.revision } : {}, ...n.sourceToken !== void 0 ? { sourceToken: n.sourceToken } : {} };
1247
+ }
1248
+ const l = e.pages.map((o) => {
1249
+ const a = o.components.map((s) => {
1250
+ const c = s.table?.source ? i(s.table.source) : void 0, d = s.table && c !== s.table.source ? { ...s.table, source: c } : s.table, u = s.grid?.cells.map((f) => {
1251
+ const h = f.map((g) => {
1252
+ if (!g?.source) return g;
1253
+ const b = i(g.source);
1254
+ return b === g.source ? g : { ...g, source: b };
1255
+ });
1256
+ return h.some((g, b) => g !== f[b]) ? h : f;
1257
+ }), m = s.grid && u?.some((f, h) => f !== s.grid.cells[h]) ? { ...s.grid, cells: u } : s.grid;
1258
+ return d !== s.table || m !== s.grid ? { ...s, table: d, grid: m } : s;
1259
+ });
1260
+ return a.some((s, c) => s !== o.components[c]) ? { ...o, components: a } : o;
1762
1261
  });
1763
- return { ...e, pages: o };
1262
+ return l.some((o, a) => o !== e.pages[a]) ? { ...e, pages: l } : e;
1263
+ }
1264
+ class Ut extends Error {
1265
+ constructor(t, n, r) {
1266
+ const i = typeof n.label == "string" ? n.label : "单元格", l = {
1267
+ definition: `${i}的编辑器配置无效`,
1268
+ type: `${i}的编辑器与数据类型不一致`,
1269
+ required: `${i}不能为空`,
1270
+ min: `${i}不能小于 ${r}`,
1271
+ max: `${i}不能大于 ${r}`,
1272
+ precision: `${i}最多保留 ${r} 位小数`,
1273
+ length: `${i}最多允许 ${r} 个字符`,
1274
+ choice: `${i}请选择有效选项`,
1275
+ date: `${i}请输入有效日期(YYYY-MM-DD)`
1276
+ };
1277
+ super(l[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
1278
+ }
1279
+ }
1280
+ function w(e, t, n) {
1281
+ throw new Ut(t, e, n);
1282
+ }
1283
+ function Be(e) {
1284
+ if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
1285
+ const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
1286
+ return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
1287
+ }
1288
+ function Jt(e) {
1289
+ const [t = "", n = "0"] = String(e).toLowerCase().split("e");
1290
+ return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
1291
+ }
1292
+ function Yt(e, t) {
1293
+ e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max), e.precision !== void 0 && Jt(t) > e.precision && w(e, "precision", e.precision);
1294
+ }
1295
+ function Xt(e, t) {
1296
+ Be(t) || w(e, "date"), e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max);
1297
+ }
1298
+ function Qt(e) {
1299
+ [e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && w(e, "definition");
1300
+ }
1301
+ function Zt(e) {
1302
+ [e.min, e.max].some((t) => t !== void 0 && !Be(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition");
1303
+ }
1304
+ function en(e, t) {
1305
+ (!Array.isArray(t.options) || !t.options.length) && w(t, "definition");
1306
+ const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
1307
+ for (const i of t.options)
1308
+ (!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && w(t, "definition"), i.label !== void 0 && typeof i.label != "string" && w(t, "definition"), r.has(i.value) && w(t, "definition"), r.add(i.value);
1309
+ }
1310
+ function tn(e) {
1311
+ e.required !== void 0 && typeof e.required != "boolean" && w(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition");
1312
+ }
1313
+ function nn(e, t) {
1314
+ (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && w(t ?? { type: "text" }, "definition"), tn(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && w(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && w(t, "type"), t.type === "number" && Qt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && w(t, "definition"), t.type === "date" && Zt(t), t.type === "enum" && en(e, t);
1315
+ }
1316
+ function Ln(e, t, n) {
1317
+ if (!e.editable) throw new M("readonly");
1318
+ n && nn(e, n);
1319
+ const r = ue(e, t);
1320
+ return n ? (n.required && typeof r == "string" && !r.trim() && w(n, "required"), r === null || r === "" ? (n.required && w(n, "required"), r) : (n.type === "number" && Yt(n, r), n.type === "date" && Xt(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && w(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && w(n, "choice"), r)) : r;
1764
1321
  }
1765
1322
  export {
1766
- ii as CSS_DPI,
1767
- Zn as DEFAULT_BORDER_PT,
1768
- qe as DEFAULT_FONT_PT,
1769
- ei as DEFAULT_STROKE_COLOR,
1770
- Se as DEFAULT_TEXT_COLOR,
1771
- ve as LINE_HEIGHT,
1772
- ri as MM_PER_INCH,
1773
- Z as PAPER_SIZES,
1774
- Vt as PageBuilder,
1775
- ce as RENDER_PLAN_SCHEMA_VERSION,
1776
- We as REPORT_TEMPLATE_DOCUMENT_VERSION,
1777
- L as ReportCellEditError,
1778
- N as ReportSourceError,
1779
- W as ReportTemplateError,
1780
- ti as SCHEMA_VERSION_MACH,
1781
- _t as TemplateBuilder,
1782
- qn as applyReportCellEdit,
1783
- Hn as assertRenderPlan,
1784
- li as charWidthEm,
1785
- k as classOf,
1786
- Lt as computePageWindow,
1787
- di as createCanvasMeasurer,
1788
- zn as createCanvasPager,
1789
- ci as createHeuristicMeasurer,
1790
- Yn as createReportCellEdit,
1791
- Un as createReportSource,
1792
- Wn as createTableTemplate,
1793
- Dn as createTemplate,
1794
- Jn as createTemplateRegistry,
1795
- Kn as defineReport,
1796
- _n as defineReportTemplate,
1797
- at as evalStyleRule,
1798
- be as formatReportCellEdit,
1799
- Ee as formatValue,
1800
- ye as getReportCellContext,
1801
- fe as heuristicMeasurer,
1802
- Xe as isImageBackedComponent,
1323
+ nr as CSS_DPI,
1324
+ On as DEFAULT_BORDER_PT,
1325
+ Y as DEFAULT_FONT_FAMILY,
1326
+ zn as DEFAULT_FONT_PT,
1327
+ jn as DEFAULT_STROKE_COLOR,
1328
+ Me as DEFAULT_TEXT_COLOR,
1329
+ Hn as LINE_HEIGHT,
1330
+ rr as MM_PER_INCH,
1331
+ wr as OutputAssetError,
1332
+ Je as OutputFidelityError,
1333
+ G as PAPER_SIZES,
1334
+ Et as PageBuilder,
1335
+ Kn as PaginatePageLimitError,
1336
+ Wn as RENDER_PLAN_SCHEMA_VERSION,
1337
+ Mr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1338
+ M as ReportCellEditError,
1339
+ Ut as ReportCellFieldError,
1340
+ Rr as ReportParamValidationError,
1341
+ Vn as ReportSourceError,
1342
+ xr as ReportTemplateError,
1343
+ L as ReportTemplateStoreError,
1344
+ Bn as SCHEMA_VERSION_MACH,
1345
+ Tt as TemplateBuilder,
1346
+ Pn as applyReportCellEdit,
1347
+ Rn as applyReportCellEditBatch,
1348
+ Nn as applyReportEditResult,
1349
+ sr as assertRenderPlan,
1350
+ Ir as assertReportParams,
1351
+ mr as charWidthEm,
1352
+ S as classOf,
1353
+ Mn as columnsFromContract,
1354
+ gt as computePageWindow,
1355
+ fr as createCanvasMeasurer,
1356
+ vn as createCanvasPager,
1357
+ hr as createHeuristicMeasurer,
1358
+ Sn as createMemoryTemplateStore,
1359
+ Tn as createProviderReport,
1360
+ Cn as createReportCellEdit,
1361
+ kn as createReportCellEditBatch,
1362
+ de as createReportCellResolver,
1363
+ qn as createReportSource,
1364
+ xn as createTableTemplate,
1365
+ yn as createTemplate,
1366
+ En as createTemplateManager,
1367
+ Tr as createTemplateRegistry,
1368
+ Gn as datasetJsonSchema,
1369
+ Un as defineReport,
1370
+ Er as defineReportTemplate,
1371
+ Jn as evalStyleRule,
1372
+ Q as formatReportCellEdit,
1373
+ An as formatReportClipboard,
1374
+ Yn as formatValue,
1375
+ ce as getReportCellContext,
1376
+ ie as heuristicMeasurer,
1377
+ vr as inspectOutputCapabilities,
1378
+ J as isImageBackedComponent,
1379
+ Ar as isReportDate,
1803
1380
  xe as isRichText,
1804
- Le as measurePageSizePx,
1805
- mi as measureTextMm,
1806
- R as mergeComponentStyles,
1807
- Qe as mmToPx,
1808
- oi as mmToPxFactor,
1809
- kt as paginateTemplate,
1810
- it as parseDateLocal,
1811
- Ke as parseReportCellInput,
1812
- Vn as parseReportTemplate,
1813
- Bn as planFontSizePx,
1814
- Q as ptToPx,
1815
- ai as pxToMm,
1816
- He as renderComponent,
1817
- Ht as renderPage,
1818
- Ln as renderPlan,
1819
- Wt as renderPlanToCanvas,
1820
- jn as renderPlanToImages,
1821
- ie as resolveBoxBorders,
1822
- D as resolveFontSize,
1823
- me as resolveGridLayout,
1824
- ne as resolveLineHeight,
1381
+ se as measurePageSizePx,
1382
+ gr as measureTextMm,
1383
+ Ee as mergeComponentStyles,
1384
+ re as mmToPx,
1385
+ ir as mmToPxFactor,
1386
+ Xn as paginateTemplate,
1387
+ Qn as parseDateLocal,
1388
+ Ln as parseReportCellFieldInput,
1389
+ ue as parseReportCellInput,
1390
+ $n as parseReportClipboard,
1391
+ ne as parseReportTemplate,
1392
+ gn as planFontSizePx,
1393
+ D as ptToPx,
1394
+ or as pxToMm,
1395
+ Ie as renderComponent,
1396
+ dt as renderPage,
1397
+ hn as renderPlan,
1398
+ wn as renderPlanToCanvas,
1399
+ bn as renderPlanToCanvasAsync,
1400
+ pn as renderPlanToImages,
1401
+ fe as reportCellEditKey,
1402
+ B as reportOutputDiagnostics,
1403
+ $r as reportParamsJsonSchema,
1404
+ Te as resolveBoxBorders,
1405
+ z as resolveFontSize,
1406
+ W as resolveGridLayout,
1407
+ X as resolveLineHeight,
1825
1408
  De as resolvePaper,
1826
- G as resolveStroke,
1827
- ke as resolveTextColor,
1828
- K as round,
1829
- Gn as serializeReportTemplate,
1830
- Te as toExcelNumberFormat,
1831
- le as toNumber,
1832
- ue as validateComponent,
1833
- ut as validatePage,
1834
- Pe as validateRenderPlan,
1835
- Ve as validateReportTemplate,
1836
- mn as validateReportTemplateDocument,
1837
- U as wrapText
1409
+ oe as resolvePlanAssets,
1410
+ H as resolveStroke,
1411
+ Se as resolveTextColor,
1412
+ O as round,
1413
+ Sr as serializeReportTemplate,
1414
+ In as summarizeReportCellEdits,
1415
+ Zn as toExcelNumberFormat,
1416
+ er as toNumber,
1417
+ lr as validateComponent,
1418
+ Ge as validateDatasetRows,
1419
+ cr as validatePage,
1420
+ dr as validateRenderPlan,
1421
+ nn as validateReportCellFieldDefinition,
1422
+ Nr as validateReportParamDefinitions,
1423
+ Lr as validateReportParams,
1424
+ Cr as validateReportTemplate,
1425
+ Pr as validateReportTemplateDocument,
1426
+ Ce as wrapText
1838
1427
  };