@agile-team/mach-report 2.20.0 → 2.21.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 (112) hide show
  1. package/README.md +6 -2
  2. package/dist/{ExcelBindingWizard-B7aeRg46.cjs → ExcelBindingWizard-B2xXBOJu.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-Chn6ZC2-.js → ExcelBindingWizard-CixTPQAL.js} +3 -3
  4. package/dist/{ParamEditor-BdFMa1CX.cjs → ParamEditor-DhHlNxai.cjs} +1 -1
  5. package/dist/{ParamEditor-o-7E7WZZ.js → ParamEditor-gKhvEsnr.js} +1 -1
  6. package/dist/{ReportBatchPanel-DVpmB7tG.cjs → ReportBatchPanel-BUdUfTdm.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-CNJ4Useq.js → ReportBatchPanel-D-lyWKyf.js} +1 -1
  8. package/dist/ReportLabelStudio-BcjQt73a.cjs +1 -0
  9. package/dist/ReportLabelStudio-N2w6DdaZ.js +764 -0
  10. package/dist/{ReportPreview-CGcxwkAn.js → ReportPreview-BBJNlu2U.js} +8 -8
  11. package/dist/{ReportPreview-hlwvZ1wf.cjs → ReportPreview-nf4Dk1Jc.cjs} +2 -2
  12. package/dist/{ReportTemplateLibrary-DjjyZnZB.cjs → ReportTemplateLibrary-Cs9WKneQ.cjs} +1 -1
  13. package/dist/{ReportTemplateLibrary-DyIJhJjX.js → ReportTemplateLibrary-WZl-AK-2.js} +1 -1
  14. package/dist/{RuleEditor-BeknHHOD.js → RuleEditor-DGpmjCko.js} +3 -3
  15. package/dist/RuleEditor-Dtcq-7LO.cjs +1 -0
  16. package/dist/{TemplateOutlinePanel-D6TXg1aV.cjs → TemplateOutlinePanel-CkCh506f.cjs} +1 -1
  17. package/dist/{TemplateOutlinePanel-Bv8CxbXS.js → TemplateOutlinePanel-cxp95OT9.js} +1 -1
  18. package/dist/{TemplateReusePanel-CfousvPY.js → TemplateReusePanel-BZ8VTtrO.js} +2 -2
  19. package/dist/{TemplateReusePanel-wrSbd_mr.cjs → TemplateReusePanel-CwttuSta.cjs} +1 -1
  20. package/dist/{TemplateReviewPanel-BKFcSbTh.cjs → TemplateReviewPanel-C2YjiaEC.cjs} +1 -1
  21. package/dist/{TemplateReviewPanel-F2tqWNLO.js → TemplateReviewPanel-C9cTvsRs.js} +1 -1
  22. package/dist/artifact-integrity.json +90 -92
  23. package/dist/{assets-2eC3mOcV.js → assets-CxHunY_9.js} +2 -2
  24. package/dist/{assets-B0Hxn4l6.cjs → assets-vbjAGgk8.cjs} +1 -1
  25. package/dist/{auto-BlchZ1b8.js → auto-BkdGiNtr.js} +4 -4
  26. package/dist/{auto-B0EZFIK1.cjs → auto-Tq7ReIC1.cjs} +1 -1
  27. package/dist/{component-tree-CvW4lzpv.js → component-tree-1_QCiQJX.js} +1 -1
  28. package/dist/component-tree-BjZIp6w9.cjs +1 -0
  29. package/dist/{data-bar-PtjXhMgN.js → data-bar-8baGYEZ9.js} +1 -1
  30. package/dist/{data-bar-Ce38juRZ.cjs → data-bar-YltqGTaC.cjs} +1 -1
  31. package/dist/designer-CDqok4S5.cjs +2 -0
  32. package/dist/designer-CIDHt5xz.js +6869 -0
  33. package/dist/designer.cjs +1 -1
  34. package/dist/designer.d.cts +25 -3
  35. package/dist/designer.d.ts +25 -3
  36. package/dist/designer.js +1 -1
  37. package/dist/{encoding-B--eZpp1.cjs → encoding-B79hW4zq.cjs} +1 -1
  38. package/dist/{encoding-mctOLocI.js → encoding-BSeUwrN7.js} +2 -2
  39. package/dist/{font-loader-DBBJ5KE9.cjs → font-loader-BB372_XN.cjs} +1 -1
  40. package/dist/{font-loader-DW8tIaNp.js → font-loader-Di0lQKFf.js} +1 -1
  41. package/dist/grid-geometry-D3SJgWFv.js +136 -0
  42. package/dist/grid-geometry-D8ReblRV.cjs +1 -0
  43. package/dist/index.cjs +6 -6
  44. package/dist/index.js +194 -195
  45. package/dist/json-snapshot-I5VI84Vp.cjs +2 -0
  46. package/dist/{json-snapshot-By4ZVVUt.js → json-snapshot-Kgn459Oj.js} +895 -879
  47. package/dist/{pdf-DqyxJ96U.cjs → pdf-CARdBcuw.cjs} +45 -45
  48. package/dist/{pdf-CKROKygt.js → pdf-DmlnL5eB.js} +13 -14
  49. package/dist/pdf.cjs +1 -1
  50. package/dist/pdf.js +2 -2
  51. package/dist/{plugin-BMsIIJDh.cjs → plugin-BaRUGORD.cjs} +1 -1
  52. package/dist/{plugin-Co1oKD7T.js → plugin-D4kAxfLG.js} +1 -1
  53. package/dist/{prefill-D7EswyTI.cjs → prefill-Bpyn58AZ.cjs} +1 -1
  54. package/dist/{prefill-B8H9qwE4.js → prefill-CJSazcVY.js} +2 -2
  55. package/dist/{prepared-CGVphji3.cjs → prepared-BiSz_9vN.cjs} +1 -1
  56. package/dist/{prepared-BE-4jfX5.js → prepared-BwjwEzFz.js} +1 -1
  57. package/dist/{protocol-Cr81vFSQ.js → protocol-Bs9-ohHN.js} +3 -3
  58. package/dist/{protocol-ByRVzzQG.cjs → protocol-C8VWF9An.cjs} +1 -1
  59. package/dist/record-bindings-Ct1HkPrc.cjs +1 -0
  60. package/dist/{record-bindings-DEJtmo3p.js → record-bindings-VZGS-Qd8.js} +1 -1
  61. package/dist/{region-binding-workflow-CBg0l_tj.js → region-binding-workflow-Cy4GIOUo.js} +2 -2
  62. package/dist/{region-binding-workflow-D05tOYn3.cjs → region-binding-workflow-JNowHd0A.cjs} +1 -1
  63. package/dist/report-encoding-worker.cjs +1 -1
  64. package/dist/report-encoding-worker.js +1 -1
  65. package/dist/rich-text-layout-K48VHUoW.cjs +3 -0
  66. package/dist/{rich-text-layout-Ct5WrY1g.js → rich-text-layout-wxBhnAS7.js} +1 -1
  67. package/dist/{runtime-CEMvybO7.js → runtime-BDf5x1i1.js} +5 -5
  68. package/dist/runtime-DsJt1PIf.cjs +1 -0
  69. package/dist/sbom.cdx.json +1 -1
  70. package/dist/server-node.cjs +4 -4
  71. package/dist/server-node.js +1272 -1274
  72. package/dist/server.cjs +1 -1
  73. package/dist/server.js +8 -8
  74. package/dist/style.css +1 -1
  75. package/dist/{template-catalog-CmbWOJqy.js → template-catalog-DFwIS9aN.js} +3 -3
  76. package/dist/{template-catalog-Utu4GP09.cjs → template-catalog-D_2jdnkL.cjs} +1 -1
  77. package/dist/template-fragments-DZVUBhuB.cjs +1 -0
  78. package/dist/{template-fragments-DWgo9tlZ.js → template-fragments-Dng-AlHk.js} +11 -11
  79. package/dist/{template-registry-BIhIHOab.js → template-registry-DhBqoD7W.js} +120 -118
  80. package/dist/template-registry-DpLUSLwF.cjs +1 -0
  81. package/dist/{column-visual-BpgQVWwT.js → template-serialization-Cc3h-miv.js} +74 -65
  82. package/dist/{column-visual-CtYxnBCP.cjs → template-serialization-D1R5oAqh.cjs} +1 -1
  83. package/dist/{textwrap-BEIg2w8y.js → textwrap-CkGjRFT3.js} +1 -1
  84. package/dist/textwrap-OTOUMr4f.cjs +4 -0
  85. package/dist/vue-async.cjs +1 -1
  86. package/dist/vue-async.js +3 -3
  87. package/dist/vue.cjs +1 -1
  88. package/dist/vue.js +4 -4
  89. package/dist/{workbook-session-B94EwVa_.cjs → workbook-session-NYv01LHe.cjs} +1 -1
  90. package/dist/{workbook-session-BoScoOg-.js → workbook-session-oinxX3qo.js} +2 -2
  91. package/dist/worker.cjs +1 -1
  92. package/dist/worker.js +4 -4
  93. package/dist/xlsx.cjs +4 -4
  94. package/dist/xlsx.js +204 -205
  95. package/package.json +1 -1
  96. package/dist/ReportLabelStudio-Drsm9sAS.cjs +0 -1
  97. package/dist/ReportLabelStudio-r8VFnhGQ.js +0 -589
  98. package/dist/RuleEditor-BVuRn_OQ.cjs +0 -1
  99. package/dist/component-tree-6TV7W6Yj.cjs +0 -1
  100. package/dist/designer-B52ddmHO.js +0 -6676
  101. package/dist/designer-Dtsw_rh7.cjs +0 -2
  102. package/dist/grid-geometry-BNptEcMm.js +0 -65
  103. package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
  104. package/dist/json-snapshot-jiXff4lc.cjs +0 -2
  105. package/dist/record-bindings-ehjnCDHt.cjs +0 -1
  106. package/dist/rich-text-layout-ALlMoYOG.cjs +0 -3
  107. package/dist/runtime-CDA6d263.cjs +0 -1
  108. package/dist/style-67OqfNed.js +0 -73
  109. package/dist/style-C22Pbv3T.cjs +0 -1
  110. package/dist/template-fragments-C_zSHJAa.cjs +0 -1
  111. package/dist/template-registry-DzWswQI5.cjs +0 -1
  112. package/dist/textwrap-BI-yJ6Wt.cjs +0 -4
@@ -1,28 +1,27 @@
1
- import { R as te } from "./component-tree-CvW4lzpv.js";
2
- import { r as re, L as ve, b as Gt, i as Vt, f as N, D as Ve } from "./style-67OqfNed.js";
3
- import { w as z, h as We } from "./textwrap-BEIg2w8y.js";
4
- import { e as Me, k as L, b as Se, n as K, o as Wt, q as Jt } from "./computed-C8NRZQss.js";
5
- import { c as Je, R as I, g as ze, b as zt, i as _t, l as xe, t as _e, h as qe, f as Ue, j as qt, k as Ut } from "./record-bindings-DEJtmo3p.js";
6
- import { a as Xt, c as Yt } from "./charts-Dlv8j2AG.js";
7
- import { b as Qt, c as Zt, e as er } from "./matrix-Dy-tyY7E.js";
8
- import { r as oe } from "./grid-geometry-BNptEcMm.js";
9
- import { f as Xe, b as tr, d as rr, c as Ye } from "./column-visual-BpgQVWwT.js";
10
- import { i as or, r as nr, j as ar, b as Qe, v as sr, R as ir } from "./template-registry-BIhIHOab.js";
11
- import { g as cr } from "./report-params-D9tBuM9B.js";
12
- import { a as Oe } from "./param-validation-CnDEd2l-.js";
13
- import { f as lr, i as dr } from "./number-format-BA_KwrZe.js";
14
- import { v as Ze, d as ur } from "./dataset-DL83majE.js";
15
- const fr = 4096, Ae = 128 * 1024;
16
- function mr(e) {
1
+ import { R as be } from "./component-tree-1_QCiQJX.js";
2
+ import { r as re, a as ne, L as ve, c as Vt, j as Jt, g as j, D as Ve } from "./grid-geometry-D3SJgWFv.js";
3
+ import { w as _, h as Je } from "./textwrap-CkGjRFT3.js";
4
+ import { e as Me, k as H, b as Se, n as K, o as zt, q as _t } from "./computed-C8NRZQss.js";
5
+ import { c as ze, R as I, g as _e, b as qt, i as Ut, l as xe, t as qe, h as Ue, f as Xe, j as Xt, k as Yt } from "./record-bindings-VZGS-Qd8.js";
6
+ import { a as Qt, c as Zt } from "./charts-Dlv8j2AG.js";
7
+ import { b as er, c as tr, e as rr } from "./matrix-Dy-tyY7E.js";
8
+ import { f as Ye, b as nr, d as or, c as Qe } from "./template-serialization-Cc3h-miv.js";
9
+ import { i as ar, r as sr, j as ir, b as Ze, v as cr, R as lr } from "./template-registry-DhBqoD7W.js";
10
+ import { g as dr } from "./report-params-D9tBuM9B.js";
11
+ import { a as Ae } from "./param-validation-CnDEd2l-.js";
12
+ import { f as ur, i as fr } from "./number-format-BA_KwrZe.js";
13
+ import { v as et, d as mr } from "./dataset-DL83majE.js";
14
+ const hr = 4096, Ne = 128 * 1024;
15
+ function gr(e) {
17
16
  const t = /* @__PURE__ */ new Map();
18
17
  let r = 0;
19
- return { measureMm(o, n) {
20
- const a = JSON.stringify([o, n.fontSizePt, n.fontFamily, n.bold, n.italic, n.letterSpacingPt]), s = t.get(a);
18
+ return { measureMm(n, o) {
19
+ const a = JSON.stringify([n, o.fontSizePt, o.fontFamily, o.bold, o.italic, o.letterSpacingPt]), s = t.get(a);
21
20
  if (s !== void 0)
22
21
  return t.delete(a), t.set(a, s), s;
23
- const i = e.measureMm(o, n);
24
- if (Number.isFinite(i) && a.length <= Ae) {
25
- for (; t.size >= fr || r + a.length > Ae; ) {
22
+ const i = e.measureMm(n, o);
23
+ if (Number.isFinite(i) && a.length <= Ne) {
24
+ for (; t.size >= hr || r + a.length > Ne; ) {
26
25
  const c = t.keys().next().value;
27
26
  r -= c.length, t.delete(c);
28
27
  }
@@ -31,65 +30,65 @@ function mr(e) {
31
30
  return i;
32
31
  } };
33
32
  }
34
- class G extends Error {
33
+ class W extends Error {
35
34
  constructor(t, r) {
36
35
  super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
37
36
  }
38
37
  }
39
- class X extends Error {
38
+ class Y extends Error {
40
39
  constructor(t, r) {
41
40
  super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
42
41
  }
43
42
  }
44
- class Y extends Error {
43
+ class Q extends Error {
45
44
  constructor(t, r) {
46
45
  super(`报表图表图元数量预计超出上限 ${t}(本次估算 ${r})`), this.limit = t, this.estimated = r, this.code = "chart-component-limit", this.name = "PaginateChartComponentLimitError";
47
46
  }
48
47
  }
49
48
  const Ce = 5e4;
50
- function ne(e = Ce) {
49
+ function oe(e = Ce) {
51
50
  if (!Number.isSafeInteger(e) || e < 1 || e > 1e6) throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数");
52
51
  }
53
- function hr(e, t, r) {
54
- const o = e.chartBinding;
52
+ function pr(e, t, r) {
53
+ const n = e.chartBinding;
55
54
  if (e.kind !== "chart" || e.grid || e.imageData || e.binding || e.pageAnchor) throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");
56
- const n = Object.prototype.hasOwnProperty.call(t, o.dataset) ? t[o.dataset] : void 0;
57
- if (!Array.isArray(n)) throw new TypeError(`图表数据集 ${o.dataset} 未提供`);
58
- return { ...Qt(n, o, r), type: o.type, leftMm: e.leftMm, topMm: e.topMm, widthMm: e.widthMm, heightMm: e.heightMm, title: o.title, showValues: o.showValues };
55
+ const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
56
+ if (!Array.isArray(o)) throw new TypeError(`图表数据集 ${n.dataset} 未提供`);
57
+ return { ...er(o, n, r), type: n.type, leftMm: e.leftMm, topMm: e.topMm, widthMm: e.widthMm, heightMm: e.heightMm, title: n.title, showValues: n.showValues };
59
58
  }
60
- function gr(e, t, r = Ce) {
61
- ne(r);
62
- let o = 0;
59
+ function wr(e, t, r = Ce) {
60
+ oe(r);
61
+ let n = 0;
63
62
  return Object.assign((a) => {
64
63
  if (!a.chartBinding) return [a];
65
- const s = hr(a, e, t), i = o + (s.categories.length ? Xt(s) : 1);
64
+ const s = pr(a, e, t), i = n + (s.categories.length ? Qt(s) : 1);
66
65
  if (!Number.isSafeInteger(i)) throw new RangeError("图表图元估算应为有限安全整数");
67
- if (i > r) throw new Y(r, i);
68
- const c = s.categories.length ? Yt(s) : [{ kind: "text", leftMm: a.leftMm, topMm: a.topMm, widthMm: a.widthMm, heightMm: a.heightMm, text: "—", style: { align: "center", verticalAlign: "middle", color: "#94a3b8", fontSize: 10 } }];
69
- return o += c.length, c;
70
- }, { used: () => o });
66
+ if (i > r) throw new Q(r, i);
67
+ const c = s.categories.length ? Zt(s) : [{ kind: "text", leftMm: a.leftMm, topMm: a.topMm, widthMm: a.widthMm, heightMm: a.heightMm, text: "—", style: { align: "center", verticalAlign: "middle", color: "#94a3b8", fontSize: 10 } }];
68
+ return n += c.length, c;
69
+ }, { used: () => n });
71
70
  }
72
- function pr(e, t) {
71
+ function yr(e, t) {
73
72
  return { member: "body", subtotal: "subtotal", total: "grand-total" }[e?.rows.get(t)?.kind ?? "member"];
74
73
  }
75
- function wr(e) {
74
+ function br(e) {
76
75
  const t = e.matrix;
77
76
  if (!t.hierarchy) return t;
78
- const r = new Map(e.columns.map((n) => [n.field, n.header])), o = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
77
+ const r = new Map(e.columns.map((o) => [o.field, o.header])), n = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
79
78
  return { ...t, hierarchy: {
80
79
  ...t.hierarchy,
81
- row: { ...t.hierarchy.row, labels: t.hierarchy.row?.labels ?? t.rowFields.map((n) => r.get(n) ?? n) },
82
- column: { ...t.hierarchy.column, labels: t.hierarchy.column?.labels ?? t.columnFields.map((n) => r.get(n) ?? n) }
83
- }, measures: t.measures.map((n) => {
84
- const a = r.get(n.field) ?? r.get(n.valueField ?? n.field);
85
- return n.label === void 0 && a ? { ...n, label: `${a}(${o[n.op]})` } : n;
80
+ row: { ...t.hierarchy.row, labels: t.hierarchy.row?.labels ?? t.rowFields.map((o) => r.get(o) ?? o) },
81
+ column: { ...t.hierarchy.column, labels: t.hierarchy.column?.labels ?? t.columnFields.map((o) => r.get(o) ?? o) }
82
+ }, measures: t.measures.map((o) => {
83
+ const a = r.get(o.field) ?? r.get(o.valueField ?? o.field);
84
+ return o.label === void 0 && a ? { ...o, label: `${a}(${n[o.op]})` } : o;
86
85
  }) };
87
86
  }
88
- function yr(e, t) {
87
+ function vr(e, t) {
89
88
  if (!e.matrix) return { list: e, rows: t };
90
89
  if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
91
- const r = Zt(t, wr(e)), o = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), n = { ...e, columns: o, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
92
- e.layout === "wide" && (n.widthMm = o.reduce((i, c) => i + c.widthMm, 0));
90
+ const r = tr(t, br(e)), n = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
91
+ e.layout === "wide" && (o.widthMm = n.reduce((i, c) => i + c.widthMm, 0));
93
92
  const a = r.metadata, s = a ? { rows: new WeakMap(r.rows.map((i, c) => [i, a.rows[c]])), header: {
94
93
  columns: a.columns,
95
94
  rowFields: a.rowFields,
@@ -97,92 +96,92 @@ function yr(e, t) {
97
96
  columnFields: a.columnFields,
98
97
  columnLabels: a.columnLabels
99
98
  } } : void 0;
100
- return { list: n, rows: r.rows, ...s ? { matrix: s } : {} };
99
+ return { list: o, rows: r.rows, ...s ? { matrix: s } : {} };
101
100
  }
102
- function br(e, t) {
101
+ function Mr(e, t) {
103
102
  if (!e.matrix?.hierarchy || !e.headerGrid) return e.headerGrid;
104
- const r = e.paddingMm ?? 1, o = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), n = e.columns.map((c) => c.widthMm), a = oe({ ...e.headerGrid, colWidthsMm: n }, n.reduce((c, l) => c + l, 0), o.length), s = /* @__PURE__ */ new WeakMap();
103
+ const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a = re({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, l) => c + l, 0), n.length), s = /* @__PURE__ */ new WeakMap();
105
104
  for (const { cell: c, ci: l, ri: d, widthMm: f } of a.cells) {
106
- const u = { ...Je(e, e.columns[l]), ...c.style }, h = re(u).fontSizePt, v = (z(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: h, fontFamily: u.fontFamily, bold: u.bold, italic: u.italic, letterSpacingPt: u.letterSpacing }, t).length * h * (u.lineHeight ?? ve) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
107
- for (let y = d; y < d + (c.rowSpan ?? 1); y++) o[y] = Math.max(o[y] ?? 0, v);
105
+ const u = { ...ze(e, e.columns[l]), ...c.style }, h = ne(u).fontSizePt, v = (_(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: h, fontFamily: u.fontFamily, bold: u.bold, italic: u.italic, letterSpacingPt: u.letterSpacing }, t).length * h * (u.lineHeight ?? ve) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
106
+ for (let y = d; y < d + (c.rowSpan ?? 1); y++) n[y] = Math.max(n[y] ?? 0, v);
108
107
  s.set(c, u);
109
108
  }
110
109
  const i = e.headerGrid.cells.map((c) => c.map((l) => l ? { ...l, style: s.get(l) } : null));
111
- return { ...e.headerGrid, cells: i, rowHeightsMm: o };
110
+ return { ...e.headerGrid, cells: i, rowHeightsMm: n };
112
111
  }
113
- function vr(e, t, r) {
114
- const o = /* @__PURE__ */ new Set(), n = e.cells.map((a, s) => {
112
+ function Sr(e, t, r) {
113
+ const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
115
114
  const i = [];
116
115
  let c = 0;
117
116
  for (const l of a) {
118
- for (; o.has(`${s}:${c}`); ) c++;
117
+ for (; n.has(`${s}:${c}`); ) c++;
119
118
  const d = l?.colSpan ?? 1, f = l?.rowSpan ?? 1;
120
119
  let u = 0;
121
120
  for (let h = c; h < c + d; h++) {
122
121
  t.has(h) && u++;
123
122
  for (let m = s + 1; m < s + f; m++)
124
- o.add(`${m}:${h}`);
123
+ n.add(`${m}:${h}`);
125
124
  }
126
125
  u && i.push(l ? { ...l, colSpan: u } : null), c += d;
127
126
  }
128
127
  return i;
129
128
  });
130
- return { ...e, cells: n, colWidthsMm: r };
129
+ return { ...e, cells: o, colWidthsMm: r };
131
130
  }
132
- function Mr(e) {
133
- if (!e.columns.some((o) => o.hidden)) return e;
134
- const t = /* @__PURE__ */ new Set(), r = e.columns.filter((o, n) => o.hidden ? !1 : (t.add(n), !0));
131
+ function xr(e) {
132
+ if (!e.columns.some((n) => n.hidden)) return e;
133
+ const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
135
134
  if (!r.length) throw new Error("列表至少需要一列可见列");
136
135
  return {
137
136
  ...e,
138
137
  columns: r,
139
138
  ...e.headerGrid ? {
140
- headerGrid: vr(
139
+ headerGrid: Sr(
141
140
  e.headerGrid,
142
141
  t,
143
- r.map((o) => o.widthMm)
142
+ r.map((n) => n.widthMm)
144
143
  )
145
144
  } : {}
146
145
  };
147
146
  }
148
- function* Sr(e) {
147
+ function* Cr(e) {
149
148
  const { page: t } = e;
150
- or(t.components, t.flow);
151
- let r = 0, o = 0;
152
- for (const n of nr(t.components, t.flow)) {
149
+ ar(t.components, t.flow);
150
+ let r = 0, n = 0;
151
+ for (const o of sr(t.components, t.flow)) {
153
152
  e.active();
154
- const a = n.band, s = n.components.some((d) => d.kind === "list" && d.cardinality !== "record"), i = s ? 0 : n.components.reduce((d, f) => Math.max(d, f.topMm - a.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), a.heightMm);
155
- let c = Math.max(e.top(), o + a.topMm - r);
153
+ const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), i = s ? 0 : o.components.reduce((d, f) => Math.max(d, f.topMm - a.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), a.heightMm);
154
+ let c = Math.max(e.top(), n + a.topMm - r);
156
155
  if (!s && i > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
157
156
  !s && c + i > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), c = e.top());
158
157
  let l = c + i;
159
- for (const d of n.components) {
158
+ for (const d of o.components) {
160
159
  const f = c + d.topMm - a.topMm;
161
160
  d.kind === "list" ? (yield* e.list(d, f, (u) => {
162
161
  l = s ? u : Math.max(l, u);
163
162
  }), e.active()) : e.append({ ...d, topMm: f });
164
163
  }
165
- o = l, r = a.topMm + a.heightMm;
164
+ n = l, r = a.topMm + a.heightMm;
166
165
  }
167
166
  }
168
- function xr(e) {
167
+ function kr(e) {
169
168
  return !!(e.computed?.length || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen || e.matrix || e.tree || e.detail || e.columns.some((t) => t.rules?.length || t.visibleWhen || t.visual));
170
169
  }
171
- function ae(e) {
172
- return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? xr(r) : !!r.chartBinding));
170
+ function ke(e) {
171
+ return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? kr(r) : !!r.chartBinding));
173
172
  }
174
- const Cr = 512, Ne = 256 * 1024;
175
- function kr() {
173
+ const Tr = 512, je = 256 * 1024;
174
+ function Pr() {
176
175
  const e = /* @__PURE__ */ new Map();
177
176
  let t = 0, r;
178
- return (o, n, a, s) => {
177
+ return (n, o, a, s) => {
179
178
  s !== r && (e.clear(), t = 0, r = s);
180
- const i = JSON.stringify([o, n, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), c = e.get(i);
179
+ const i = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), c = e.get(i);
181
180
  if (c)
182
181
  return e.delete(i), e.set(i, c), c.lines.slice();
183
- const l = z(o, n, a, s), d = i.length + l.reduce((f, u) => f + u.length, 0);
184
- if (d <= Ne) {
185
- for (; e.size >= Cr || t + d > Ne; ) {
182
+ const l = _(n, o, a, s), d = i.length + l.reduce((f, u) => f + u.length, 0);
183
+ if (d <= je) {
184
+ for (; e.size >= Tr || t + d > je; ) {
186
185
  const f = e.keys().next().value;
187
186
  t -= e.get(f).units, e.delete(f);
188
187
  }
@@ -192,97 +191,97 @@ function kr() {
192
191
  };
193
192
  }
194
193
  const Er = 1e4, Ke = 25e4;
195
- function ke(e) {
194
+ function Te(e) {
196
195
  if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
197
196
  }
198
- function et(e, t, r) {
199
- const o = typeof e.copies == "object" ? ze(t, e.copies.field, r) : e.copies ?? 1;
200
- if (typeof o != "number" || !Number.isSafeInteger(o) || o < 1 || o > 1e3) throw new I(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
201
- return o;
202
- }
203
197
  function tt(e, t, r) {
198
+ const n = typeof e.copies == "object" ? _e(t, e.copies.field, r) : e.copies ?? 1;
199
+ if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new I(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
200
+ return n;
201
+ }
202
+ function rt(e, t, r) {
204
203
  if (e.rowKey === void 0) return;
205
- const o = ze(t, e.rowKey, r);
206
- if (typeof o == "string" && o.trim() || typeof o == "number" && Number.isFinite(o)) return o;
204
+ const n = _e(t, e.rowKey, r);
205
+ if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
207
206
  throw new I(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
208
207
  }
209
- function Tr(e) {
210
- const t = (r) => 1 + (r.grid?.cells.reduce((o, n) => o + 1 + n.length + n.reduce((a, s) => a + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
211
- return e.pages.reduce((r, o) => r + o.components.reduce((n, a) => n + t(a), 0), 0);
208
+ function Rr(e) {
209
+ const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
210
+ return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
212
211
  }
213
- function Pr(e, t, r) {
214
- const o = e.repeat, n = Object.prototype.hasOwnProperty.call(t, o.dataset) ? t[o.dataset] : void 0;
215
- if (!Array.isArray(n)) throw new I(`$.datasets.${o.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
216
- const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Er, i = Tr(e);
212
+ function $r(e, t, r) {
213
+ const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
214
+ if (!Array.isArray(o)) throw new I(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
215
+ const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Er, i = Rr(e);
217
216
  let c = 0, l = 0;
218
- for (const [d, f] of n.entries()) {
219
- if (ke(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new I(`$.datasets.${o.dataset}[${d}]`, "标签记录应为对象", d);
220
- const u = { rowIndex: d, dataset: o.dataset }, h = tt(o, f, u);
217
+ for (const [d, f] of o.entries()) {
218
+ if (Te(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new I(`$.datasets.${n.dataset}[${d}]`, "标签记录应为对象", d);
219
+ const u = { rowIndex: d, dataset: n.dataset }, h = rt(n, f, u);
221
220
  if (h !== void 0) {
222
221
  const v = JSON.stringify([typeof h, h]);
223
- if (a.has(v)) throw new I(`$.datasets.${o.dataset}[${d}].${o.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, o.rowKey);
222
+ if (a.has(v)) throw new I(`$.datasets.${n.dataset}[${d}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, n.rowKey);
224
223
  a.add(v);
225
224
  }
226
- const m = et(o, f, u);
227
- if (c += m * e.pages.length, l += m * i, c > s) throw new G(s, c);
225
+ const m = tt(n, f, u);
226
+ if (c += m * e.pages.length, l += m * i, c > s) throw new W(s, c);
228
227
  if (l > Ke) throw new I("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Ke},请分批生成`, d);
229
228
  }
230
- return n;
229
+ return o;
231
230
  }
232
- function Rr(e, t, r) {
231
+ function Ir(e, t, r) {
233
232
  if (!e.binding) return e;
234
- const { binding: o, ...n } = e, a = zt(o, t.row, t);
233
+ const { binding: n, ...o } = e, a = qt(n, t.row, t);
235
234
  if (e.kind === "image") {
236
235
  if (!a) return;
237
- if (!_t(a)) throw new I(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, o.field);
238
- return { ...n, imageData: a };
236
+ if (!Ut(a)) throw new I(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
237
+ return { ...o, imageData: a };
239
238
  }
240
- return e.kind === "barcode" || e.kind === "qrcode" ? (delete n.imageData, { ...n, code: { ...n.code, value: a }, fallbackText: a }) : (delete n.lines, delete n.richParagraphs, { ...n, text: a });
239
+ return e.kind === "barcode" || e.kind === "qrcode" ? (delete o.imageData, { ...o, code: { ...o.code, value: a }, fallbackText: a }) : (delete o.lines, delete o.richParagraphs, { ...o, text: a });
241
240
  }
242
- function $r(e, t, r) {
241
+ function Fr(e, t, r) {
243
242
  if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
244
- const o = e.style ?? {}, n = re(o).fontSizePt, a = e.text ?? e.lines?.join(`
243
+ const n = e.style ?? {}, o = ne(n).fontSizePt, a = e.text ?? e.lines?.join(`
245
244
  `) ?? "";
246
245
  if (a.length > 16384) throw new I(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
247
- const s = t.wrapText(a, e.widthMm, { fontSizePt: n, bold: o.bold, italic: o.italic, fontFamily: o.fontFamily, letterSpacingPt: o.letterSpacing }, t.options.measurer ?? We), i = s.length * n * Gt(o) * 25.4 / 72;
246
+ const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Je), i = s.length * o * Vt(n) * 25.4 / 72;
248
247
  if (i > e.heightMm + 0.05) throw new I(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
249
248
  return { ...e, lines: s };
250
249
  }
251
- function rt(e, t, r) {
252
- ke(t.options.signal);
253
- const o = Rr(e, t, r);
254
- if (!o) return;
255
- let n = o.grid;
256
- return n && (n = { ...n, cells: n.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l, d) => {
257
- const f = rt(l, t, `${r}.grid.cells.${s}.${c}.children.${d}`);
250
+ function nt(e, t, r) {
251
+ Te(t.options.signal);
252
+ const n = Ir(e, t, r);
253
+ if (!n) return;
254
+ let o = n.grid;
255
+ return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l, d) => {
256
+ const f = nt(l, t, `${r}.grid.cells.${s}.${c}.children.${d}`);
258
257
  return f ? [f] : [];
259
- }) } : i)) }), $r(n === o.grid ? o : { ...o, grid: n }, t, r);
258
+ }) } : i)) }), Fr(o === n.grid ? n : { ...n, grid: o }, t, r);
260
259
  }
261
- function Ir(e, t, r, o, n, a) {
260
+ function Or(e, t, r, n, o, a) {
262
261
  return {
263
262
  ...e,
264
263
  components: e.components.flatMap((s, i) => {
265
- const c = rt(s, r, `$.pages.${t}.components.${i}`);
264
+ const c = nt(s, r, `$.pages.${t}.components.${i}`);
266
265
  return c ? [{ ...c, meta: { ...c.meta, labelSource: { pageIndex: t, componentIndex: i } } }] : [];
267
266
  }),
268
- meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: o, copyCount: n, templatePageIndex: t } }
267
+ meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
269
268
  };
270
269
  }
271
- function* Fr(e, t, r) {
272
- const o = [];
273
- if (ar(e, o), o.length) throw new I(o[0].path, o[0].message);
270
+ function* Ar(e, t, r) {
271
+ const n = [];
272
+ if (ir(e, n), n.length) throw new I(n[0].path, n[0].message);
274
273
  if (!e.repeat) {
275
274
  for (const [i, c] of e.pages.entries()) yield { page: c, pageIndex: i };
276
275
  return;
277
276
  }
278
- const n = e.repeat, a = Pr(e, t, r), s = kr();
277
+ const o = e.repeat, a = $r(e, t, r), s = Pr();
279
278
  for (const [i, c] of a.entries()) {
280
- const l = { row: c, rowIndex: i, dataset: n.dataset, options: r, wrapText: s }, d = et(n, c, l), f = tt(n, c, l);
279
+ const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s }, d = tt(o, c, l), f = rt(o, c, l);
281
280
  for (let u = 0; u < d; u++) for (const [h, m] of e.pages.entries())
282
- ke(r.signal), yield { page: Ir(m, h, l, u, d, f), pageIndex: h };
281
+ Te(r.signal), yield { page: Or(m, h, l, u, d, f), pageIndex: h };
283
282
  }
284
283
  }
285
- function Or(e) {
284
+ function Nr(e) {
286
285
  return {
287
286
  widthMm: e.widthMm,
288
287
  heightMm: e.heightMm,
@@ -293,9 +292,9 @@ function Or(e) {
293
292
  components: []
294
293
  };
295
294
  }
296
- function Q(e, t) {
295
+ function Z(e, t) {
297
296
  const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
298
- return e.components.reduce((o, n) => n.kind !== "list" && n.pageAnchor === "footer" ? Math.min(o, n.topMm) : o, r);
297
+ return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
299
298
  }
300
299
  function V(e) {
301
300
  return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
@@ -303,70 +302,70 @@ function V(e) {
303
302
  function ot(e, t) {
304
303
  let r = e.textMetrics.get(t);
305
304
  if (!r) {
306
- const o = re(t).fontSizePt;
305
+ const n = ne(t).fontSizePt;
307
306
  r = {
308
307
  measureOptions: {
309
- fontSizePt: o,
308
+ fontSizePt: n,
310
309
  fontFamily: t.fontFamily ?? Ve,
311
310
  italic: t.italic,
312
311
  bold: t.bold,
313
312
  letterSpacingPt: t.letterSpacing
314
313
  },
315
- lineMm: o * (t.lineHeight ?? ve) * 25.4 / 72
314
+ lineMm: n * (t.lineHeight ?? ve) * 25.4 / 72
316
315
  }, e.textMetrics.set(t, r);
317
316
  }
318
317
  return r;
319
318
  }
320
- function Ar(e) {
319
+ function jr(e) {
321
320
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
322
321
  }
323
- function Ee(e, t, r = [], o) {
324
- const n = e.fontSizePt ?? Vt, a = e.paddingMm ?? 1, s = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), i = e.columns.map((g, w) => ({
325
- ...N({
326
- fontSize: n,
322
+ function Pe(e, t, r = [], n) {
323
+ const o = e.fontSizePt ?? Jt, a = e.paddingMm ?? 1, s = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), i = e.columns.map((g, w) => ({
324
+ ...j({
325
+ fontSize: o,
327
326
  verticalAlign: "middle"
328
327
  }, g.style),
329
328
  align: s[w] === "auto" ? "left" : s[w]
330
329
  })), c = i.map((g, w) => s[w] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), l = e.columns.map((g, w) => g.rules?.map((x) => {
331
- const P = c[w];
332
- if (P) return {
333
- left: N(P.left, x.style),
334
- center: N(P.center, x.style),
335
- right: N(P.right, x.style)
330
+ const E = c[w];
331
+ if (E) return {
332
+ left: j(E.left, x.style),
333
+ center: j(E.center, x.style),
334
+ right: j(E.right, x.style)
336
335
  };
337
- const E = N(i[w], x.style);
338
- return { left: E, center: E, right: E };
339
- })), d = e.columns.map((g) => Je(e, g)), f = e.columns.map((g) => g.header);
336
+ const k = j(i[w], x.style);
337
+ return { left: k, center: k, right: k };
338
+ })), d = e.columns.map((g) => ze(e, g)), f = e.columns.map((g) => g.header);
340
339
  let u = e.rowHeightMm ?? 0;
341
340
  for (let g = 0; g < f.length; g++) {
342
- const w = d[g], x = re(w).fontSizePt, P = z(
341
+ const w = d[g], x = ne(w).fontSizePt, E = _(
343
342
  f[g],
344
343
  e.columns[g].widthMm - a * 2,
345
344
  { fontSizePt: x, fontFamily: w.fontFamily ?? Ve, italic: w.italic, bold: w.bold, letterSpacingPt: w.letterSpacing },
346
345
  t
347
- ), E = x * (w.lineHeight ?? ve) * 25.4 / 72;
348
- u = Math.max(u, Math.max(P.length, 1) * E + a * 2);
346
+ ), k = x * (w.lineHeight ?? ve) * 25.4 / 72;
347
+ u = Math.max(u, Math.max(E.length, 1) * k + a * 2);
349
348
  }
350
349
  const h = f.map((g, w) => ({
351
350
  text: g,
352
351
  style: d[w]
353
- })), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((g) => g.widthMm), y = Nr(br(e, t), v, {
352
+ })), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((g) => g.widthMm), y = Kr(Mr(e, t), v, {
354
353
  cells: [h],
355
354
  colWidthsMm: v,
356
355
  rowHeightsMm: [u],
357
356
  paddingMm: a
358
357
  });
359
358
  return {
360
- fontSizePt: n,
359
+ fontSizePt: o,
361
360
  paddingMm: a,
362
- visuals: rr(e.columns, r, o),
363
- visibility: e.columns.map((g) => g.visibleWhen ? L(g.visibleWhen) : void 0),
364
- ruleReaders: e.columns.map((g) => g.rules?.map((w) => L(w.when))),
361
+ visuals: or(e.columns, r, n),
362
+ visibility: e.columns.map((g) => g.visibleWhen ? H(g.visibleWhen) : void 0),
363
+ ruleReaders: e.columns.map((g) => g.rules?.map((w) => H(w.when))),
365
364
  cellStyles: i,
366
365
  autoStyles: c,
367
366
  ruleStyles: l,
368
367
  textMetrics: /* @__PURE__ */ new WeakMap(),
369
- numberFormats: e.columns.map((g) => _e(g.format)),
368
+ numberFormats: e.columns.map((g) => qe(g.format)),
370
369
  derivedFields: new Set(e.computed?.map((g) => g.field)),
371
370
  borderStyle: m,
372
371
  headerHeightMm: y.rowHeightsMm.reduce((g, w) => g + w, 0),
@@ -375,23 +374,23 @@ function Ee(e, t, r = [], o) {
375
374
  columns: e.columns
376
375
  };
377
376
  }
378
- function Nr(e, t, r) {
377
+ function Kr(e, t, r) {
379
378
  if (!e) return r;
380
379
  if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
381
- const o = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
382
- if (o.length !== e.cells.length || o.some((n) => !Number.isFinite(n) || n <= 0)) throw new Error("自定义列表表头行高无效");
383
- return { ...e, colWidthsMm: t, rowHeightsMm: o };
380
+ const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
381
+ if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
382
+ return { ...e, colWidthsMm: t, rowHeightsMm: n };
384
383
  }
385
- function Kr(e, t, r) {
386
- const o = t.format?.kind === "number" || t.format?.kind === "percent";
387
- t.valueType !== void 0 ? e.valueType = t.valueType : o && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
384
+ function Lr(e, t, r) {
385
+ const n = t.format?.kind === "number" || t.format?.kind === "percent";
386
+ t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
388
387
  }
389
- function W(e, t, r) {
390
- const o = e.columns, n = e.tree?.rows.get(t);
388
+ function J(e, t, r) {
389
+ const n = e.columns, o = e.tree?.rows.get(t);
391
390
  let a = e.rowHeightFloorMm;
392
- const s = new Array(o.length);
393
- for (let i = 0; i < o.length; i++) {
394
- const c = o[i], l = e.visibility[i]?.(t) !== !1, d = l ? t[c.field] : null, f = e.autoStyles[i] ? qe(d, c.format, c.semanticRole) : "left";
391
+ const s = new Array(n.length);
392
+ for (let i = 0; i < n.length; i++) {
393
+ const c = n[i], l = e.visibility[i]?.(t) !== !1, d = l ? t[c.field] : null, f = e.autoStyles[i] ? Ue(d, c.format, c.semanticRole) : "left";
395
394
  let u = e.autoStyles[i]?.[f] ?? e.cellStyles[i];
396
395
  if (c.rules) {
397
396
  for (let x = 0; x < c.rules.length; x++)
@@ -400,12 +399,12 @@ function W(e, t, r) {
400
399
  break;
401
400
  }
402
401
  }
403
- const h = c.format ? Ue(d, c.format) : xe(d), m = jr(e, c, n);
404
- u = Lr(e, c, u, n);
405
- const v = ot(e, u), y = z(h, Math.max(1, c.widthMm - e.paddingMm * 2 - m), v.measureOptions, r);
402
+ const h = c.format ? Xe(d, c.format) : xe(d), m = Hr(e, c, o);
403
+ u = Dr(e, c, u, o);
404
+ const v = ot(e, u), y = _(h, Math.max(1, c.widthMm - e.paddingMm * 2 - m), v.measureOptions, r);
406
405
  a = Math.max(a, y.length * v.lineMm + e.paddingMm * 2);
407
- const g = Ar(d), w = { text: h, style: u };
408
- d != null && e.visuals[i]?.apply(w, t), g !== void 0 && (w.value = g), Kr(w, c, e.numberFormats[i]), Hr(w, c, e, n, m), e.derivedFields.has(c.field) && (w.derived = !0, w.editable = !1), l || (w.editable = !1), s[i] = w;
406
+ const g = jr(d), w = { text: h, style: u };
407
+ d != null && e.visuals[i]?.apply(w, t), g !== void 0 && (w.value = g), Lr(w, c, e.numberFormats[i]), Br(w, c, e, o, m), e.derivedFields.has(c.field) && (w.derived = !0, w.editable = !1), l || (w.editable = !1), s[i] = w;
409
408
  }
410
409
  return {
411
410
  grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
@@ -413,70 +412,70 @@ function W(e, t, r) {
413
412
  ...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
414
413
  };
415
414
  }
416
- function jr(e, t, r) {
417
- return !r || t.field !== e.tree.list.tree.labelField ? 0 : qt(e.tree.list, t, r, e.paddingMm);
415
+ function Hr(e, t, r) {
416
+ return !r || t.field !== e.tree.list.tree.labelField ? 0 : Xt(e.tree.list, t, r, e.paddingMm);
418
417
  }
419
- function Lr(e, t, r, o) {
420
- return !o || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
418
+ function Dr(e, t, r, n) {
419
+ return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
421
420
  }
422
- function Hr(e, t, r, o, n = 0) {
423
- o && (n && (e.indentMm = n), Ut(e, t, o, r.tree.list));
421
+ function Br(e, t, r, n, o = 0) {
422
+ n && (o && (e.indentMm = o), Yt(e, t, n, r.tree.list));
424
423
  }
425
- function nt(e) {
424
+ function at(e) {
426
425
  if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
427
426
  return JSON.stringify([typeof e, e ?? null]);
428
427
  }
429
- function* at(e, t, r = 0) {
430
- const o = t[r];
431
- if (!o) {
428
+ function* st(e, t, r = 0) {
429
+ const n = t[r];
430
+ if (!n) {
432
431
  for (const a of e) yield { kind: "row", row: a };
433
432
  return;
434
433
  }
435
- const n = /* @__PURE__ */ new Map();
434
+ const o = /* @__PURE__ */ new Map();
436
435
  for (const a of e) {
437
- const s = nt(a[o.field]), i = n.get(s);
438
- i ? i.push(a) : n.set(s, [a]);
436
+ const s = at(a[n.field]), i = o.get(s);
437
+ i ? i.push(a) : o.set(s, [a]);
439
438
  }
440
- for (const a of n.values())
441
- yield { kind: "groupHeader", label: (o.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][o.field])), firstRow: a[0], group: o, depth: r, rows: a }, yield* at(a, t, r + 1), (o.subtotal?.length || o.aggregates?.length) && (yield { kind: "subtotal", label: o.subtotalLabel ?? "小计", rows: a, group: o, depth: r }), yield { kind: "groupEnd", depth: r };
439
+ for (const a of o.values())
440
+ yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* st(a, t, r + 1), (n.subtotal?.length || n.aggregates?.length) && (yield { kind: "subtotal", label: n.subtotalLabel ?? "小计", rows: a, group: n, depth: r }), yield { kind: "groupEnd", depth: r };
442
441
  }
443
- function st(e, t, r, o = []) {
444
- const n = [...r.filter((a) => !o.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...o];
445
- return new Map(n.map((a) => {
442
+ function it(e, t, r, n = []) {
443
+ const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
444
+ return new Map(o.map((a) => {
446
445
  const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i = Se(t, { ...a, field: a.valueField ?? a.field });
447
- return [a.field, { text: Ue(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: _e(s) } : {} }];
446
+ return [a.field, { text: Xe(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: qe(s) } : {} }];
448
447
  }));
449
448
  }
450
- function it(e, t) {
451
- const r = e.findIndex((o) => t.includes(o.field));
449
+ function ct(e, t) {
450
+ const r = e.findIndex((n) => t.includes(n.field));
452
451
  return r < 0 ? 1 : r;
453
452
  }
454
- function B(e, t, r, o, n, a) {
455
- const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = N({ fontSize: e.fontSizePt }, n);
453
+ function G(e, t, r, n, o, a) {
454
+ const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = j({ fontSize: e.fontSizePt }, o);
456
455
  i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
457
456
  for (let u = i; u < e.columns.length; u++) {
458
- const h = e.columns[u], m = o.get(h.field), v = e.autoStyles[u]?.[qe(m?.value, h.format)] ?? e.cellStyles[u];
459
- s.push({ ...m, text: m?.text ?? "", style: N(v, n) });
457
+ const h = e.columns[u], m = n.get(h.field), v = e.autoStyles[u]?.[Ue(m?.value, h.format)] ?? e.cellStyles[u];
458
+ s.push({ ...m, text: m?.text ?? "", style: j(v, o) });
460
459
  }
461
- const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, d = i ? [s] : [[l], s], f = d.map((u) => Dr(e, u, t));
460
+ const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, d = i ? [s] : [[l], s], f = d.map((u) => Gr(e, u, t));
462
461
  return {
463
462
  grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
464
463
  heightMm: f.reduce((u, h) => u + h, 0)
465
464
  };
466
465
  }
467
- function Dr(e, t, r) {
468
- let o = e.rowHeightFloorMm, n = 0;
466
+ function Gr(e, t, r) {
467
+ let n = e.rowHeightFloorMm, o = 0;
469
468
  for (const a of t) {
470
469
  let s = 0;
471
- const i = n + (a.colSpan ?? 1);
472
- for (; n < i; n++) s += e.colWidthsMm[n] ?? 0;
473
- const c = ot(e, a.style), l = z(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
474
- o = Math.max(o, l.length * c.lineMm + e.paddingMm * 2);
470
+ const i = o + (a.colSpan ?? 1);
471
+ for (; o < i; o++) s += e.colWidthsMm[o] ?? 0;
472
+ const c = ot(e, a.style), l = _(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
473
+ n = Math.max(n, l.length * c.lineMm + e.paddingMm * 2);
475
474
  }
476
- return o;
475
+ return n;
477
476
  }
478
- function Br(e, t, r) {
479
- const { templatePage: o, current: n, warnings: a, nextId: s, pushCurrent: i } = r, c = () => Q(o, n), l = Math.max(n.marginTopMm, V(o)), d = o.layout === "wide" ? V(o) : l, f = {
477
+ function Wr(e, t, r) {
478
+ const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () => Z(n, o), l = Math.max(o.marginTopMm, V(n)), d = n.layout === "wide" ? V(n) : l, f = {
480
479
  id: r.tableId,
481
480
  columnKeys: e.columns.map((p) => p.field),
482
481
  ...e.layout === void 0 ? {} : { layout: e.layout },
@@ -492,33 +491,33 @@ function Br(e, t, r) {
492
491
  table: { ...f, role: "header", rowIndex: -1 },
493
492
  style: t.borderStyle,
494
493
  ...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
495
- }, v = (p) => n.components.push({ ...m, topMm: p });
494
+ }, v = (p) => o.components.push({ ...m, topMm: p });
496
495
  if (r.flow && e.header !== !1 && t.headerHeightMm > c() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
497
496
  let y = Math.max(r.startTop ?? e.topMm, l);
498
497
  e.header !== !1 && (v(y), y += t.headerHeightMm + r.mmPerRow);
499
498
  function g() {
500
- const p = Math.max(r.flow || o.layout === "wide" ? 0 : e.topMm, d);
501
- return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...h.values()].reduce((S, T) => S + T.heightMm, 0);
499
+ const p = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
500
+ return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...h.values()].reduce((S, P) => S + P.heightMm, 0);
502
501
  }
503
502
  function w() {
504
- const p = o.layout === "wide" ? 0 : n.marginBottomMm;
505
- return Math.min(o.heightMm - p, Q(o, n)) - g();
503
+ const p = n.layout === "wide" ? 0 : o.marginBottomMm;
504
+ return Math.min(n.heightMm - p, Z(n, o)) - g();
506
505
  }
507
506
  function x(p) {
508
507
  if (y + p <= c()) return;
509
- i(), n.components = [], n.heightMm = o.heightMm, o.layout === "wide" && (n.marginTopMm = 0, n.marginBottomMm = 0);
510
- const b = Math.max(r.flow || o.layout === "wide" ? 0 : e.topMm, d);
508
+ i(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
509
+ const b = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
511
510
  e.header !== !1 && e.headerEveryPage !== !1 ? (v(b), y = b + t.headerHeightMm) : y = d;
512
- for (const S of h.values()) E(S, "listgr", "group-header");
511
+ for (const S of h.values()) k(S, "listgr", "group-header");
513
512
  }
514
- function P(p, b, S, T) {
515
- const k = w();
516
- if (r.flow && p.heightMm > k + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
517
- p.heightMm > k && a.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${k.toFixed(2)}mm,预览与打印可能截断内容`), x(p.heightMm), E(p, b, S, T);
513
+ function E(p, b, S, P) {
514
+ const T = w();
515
+ if (r.flow && p.heightMm > T + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
516
+ p.heightMm > T && a.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${T.toFixed(2)}mm,预览与打印可能截断内容`), x(p.heightMm), k(p, b, S, P);
518
517
  }
519
- function E(p, b, S, T) {
520
- const k = p.table?.id ?? f.id, R = S === "header" ? -1 : u.get(k) ?? 0;
521
- S !== "header" && u.set(k, R + p.grid.cells.length), n.components.push({
518
+ function k(p, b, S, P) {
519
+ const T = p.table?.id ?? f.id, R = S === "header" ? -1 : u.get(T) ?? 0;
520
+ S !== "header" && u.set(T, R + p.grid.cells.length), o.components.push({
522
521
  kind: "rect",
523
522
  leftMm: e.leftMm,
524
523
  topMm: y,
@@ -526,7 +525,7 @@ function Br(e, t, r) {
526
525
  heightMm: p.heightMm,
527
526
  grid: p.grid,
528
527
  nid: s(b),
529
- table: { ...f, ...p.table, role: S, rowIndex: R, ...T ? { source: T } : {} },
528
+ table: { ...f, ...p.table, role: S, rowIndex: R, ...P ? { source: P } : {} },
530
529
  style: t.borderStyle,
531
530
  ...e.meta || p.meta ? { meta: { ...e.meta, ...p.meta } } : {}
532
531
  }), y += p.heightMm;
@@ -534,182 +533,182 @@ function Br(e, t, r) {
534
533
  function O(p) {
535
534
  p <= w() && x(p);
536
535
  }
537
- return { keepTogether: O, placeGridRow: P, setGroupHeader: (p, b) => {
536
+ return { keepTogether: O, placeGridRow: E, setGroupHeader: (p, b) => {
538
537
  b ? h.set(p, b) : h.delete(p);
539
538
  }, bottom: () => y };
540
539
  }
541
- function Gr(e, t) {
540
+ function Vr(e, t) {
542
541
  if (!e.rowKey) return;
543
542
  const r = t[e.rowKey];
544
543
  if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
545
544
  throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);
546
- const o = e.revisionField ? t[e.revisionField] : void 0, n = e.sourceTokenField ? t[e.sourceTokenField] : void 0;
547
- if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("业务修订号应为字符串或有限数字");
548
- if (n !== void 0 && typeof n != "string") throw new Error("来源令牌应为字符串");
549
- return { datasetId: e.dataset, rowKey: r, ...o === void 0 ? {} : { revision: o }, ...n === void 0 ? {} : { sourceToken: n } };
545
+ const n = e.revisionField ? t[e.revisionField] : void 0, o = e.sourceTokenField ? t[e.sourceTokenField] : void 0;
546
+ if (n !== void 0 && typeof n != "string" && !(typeof n == "number" && Number.isFinite(n))) throw new Error("业务修订号应为字符串或有限数字");
547
+ if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
548
+ return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
550
549
  }
551
- function se(e, t) {
550
+ function ae(e, t) {
552
551
  const r = /* @__PURE__ */ new Map();
553
552
  if (!e.rowKey) return r;
554
- const o = /* @__PURE__ */ new Set();
555
- for (const n of t) {
556
- const a = Gr(e, n), s = JSON.stringify(a.rowKey);
557
- if (o.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
558
- o.add(s), r.set(n, a);
553
+ const n = /* @__PURE__ */ new Set();
554
+ for (const o of t) {
555
+ const a = Vr(e, o), s = JSON.stringify(a.rowKey);
556
+ if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
557
+ n.add(s), r.set(o, a);
559
558
  }
560
559
  return r;
561
560
  }
562
- function Vr(e, t, r, o, n) {
561
+ function Jr(e, t, r, n, o) {
563
562
  if (!e.grandTotal) return;
564
- const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = ie(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
563
+ const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = se(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
565
564
  if (i.length === 0 && c.length === 0) {
566
- o.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
565
+ n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
567
566
  return;
568
567
  }
569
- const l = B(r, o.measurer, a?.label ?? "合计", st(e.columns, t, i, c), a?.style ?? {}, it(e.columns, [...i, ...c.map((d) => d.field)]));
570
- n.placeGridRow(l, "listgt", "grand-total");
568
+ const l = G(r, n.measurer, a?.label ?? "合计", it(e.columns, t, i, c), a?.style ?? {}, ct(e.columns, [...i, ...c.map((d) => d.field)]));
569
+ o.placeGridRow(l, "listgt", "grand-total");
571
570
  }
572
- function J(e) {
571
+ function N(e) {
573
572
  if (e?.aborted) {
574
573
  const t = new Error("报表排版已取消");
575
574
  throw t.name = "AbortError", t;
576
575
  }
577
576
  }
578
- function ie(e) {
577
+ function se(e) {
579
578
  const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
580
579
  if (t.length > 16) throw new Error("列表最多支持 16 级分组");
581
580
  return t;
582
581
  }
583
- function Te(e) {
584
- const t = Mr(e), r = t.columns.reduce((n, a) => n + a.widthMm, 0), o = r > t.widthMm ? t.widthMm / r : 1;
585
- return o === 1 ? t : { ...t, columns: t.columns.map((n) => ({ ...n, widthMm: n.widthMm * o })) };
582
+ function Ee(e) {
583
+ const t = xr(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
584
+ return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
586
585
  }
587
- function Wr(e, t, r) {
588
- const o = e.detail;
589
- if (!o) return;
590
- const n = /* @__PURE__ */ new Set();
586
+ function zr(e, t, r) {
587
+ const n = e.detail;
588
+ if (!n) return;
589
+ const o = /* @__PURE__ */ new Set();
591
590
  for (const l of t) {
592
- const d = he(l[o.parentKey]);
593
- if (n.has(d)) throw new Error("主从明细的主表关联键重复");
594
- n.add(d);
591
+ const d = he(l[n.parentKey]);
592
+ if (o.has(d)) throw new Error("主从明细的主表关联键重复");
593
+ o.add(d);
595
594
  }
596
- const a = r.datasets[o.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
595
+ const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
597
596
  for (const l of a) {
598
- const d = l[o.foreignKey];
599
- if (!ct(d) && o.unmatched === "ignore") continue;
597
+ const d = l[n.foreignKey];
598
+ if (!lt(d) && n.unmatched === "ignore") continue;
600
599
  const f = he(d);
601
- if (!n.has(f)) {
602
- if (o.unmatched !== "ignore") throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);
600
+ if (!o.has(f)) {
601
+ if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
603
602
  continue;
604
603
  }
605
604
  const u = s.get(f);
606
605
  u ? u.push(l) : s.set(f, [l]), i.push(l);
607
606
  }
608
- const c = Te({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: o.dataset, rowKey: o.rowKey, revisionField: o.revisionField, sourceTokenField: o.sourceTokenField, computed: void 0, columns: o.columns, headerGrid: void 0, rowHeightMm: o.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
609
- return { list: c, inter: { ...Ee(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: se(c, i) };
607
+ const c = Ee({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: n.dataset, rowKey: n.rowKey, revisionField: n.revisionField, sourceTokenField: n.sourceTokenField, computed: void 0, columns: n.columns, headerGrid: void 0, rowHeightMm: n.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
608
+ return { list: c, inter: { ...Pe(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: ae(c, i) };
610
609
  }
611
- function ct(e) {
610
+ function lt(e) {
612
611
  return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
613
612
  }
614
613
  function he(e) {
615
- if (!ct(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
616
- return nt(e);
614
+ if (!lt(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
615
+ return at(e);
617
616
  }
618
- function* Jr(e, t, r, o, n) {
617
+ function* _r(e, t, r, n, o) {
619
618
  if (!r) return;
620
619
  const a = r.rows.get(he(t[e.detail.parentKey])) ?? [];
621
620
  if (!a.length) return;
622
- const s = { id: `${o.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
623
- e.detail.label && n.placeGridRow({ ...B(r.inter, o.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && n.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* o.takePages();
621
+ const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
622
+ e.detail.label && o.placeGridRow({ ...G(r.inter, n.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && o.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* n.takePages();
624
623
  for (const i of a)
625
- J(o.signal), n.placeGridRow({ ...W(r.inter, i, o.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* o.takePages();
624
+ N(n.signal), o.placeGridRow({ ...J(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
626
625
  }
627
- function lt(e) {
626
+ function dt(e) {
628
627
  if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
629
628
  if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
630
629
  if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
631
- tr(e.tree, e.computed);
630
+ nr(e.tree, e.computed);
632
631
  }
633
- function zr(e, t, r) {
634
- lt(e);
635
- const o = Ye(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), n = { ...e, rowKey: e.tree.idField }, a = se(n, o.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
636
- for (const c of o.entries)
632
+ function qr(e, t, r) {
633
+ dt(e);
634
+ const n = Qe(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, a = ae(o, n.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
635
+ for (const c of n.entries)
637
636
  s.set(c.row, a.get(c.original)), i.set(c.row, c);
638
- return { list: n, rows: o.rows, sources: s, treeRows: i, totalRows: o.leaves };
637
+ return { list: o, rows: n.rows, sources: s, treeRows: i, totalRows: n.leaves };
639
638
  }
640
- function _r(e, t) {
639
+ function Ur(e, t) {
641
640
  if (e.cardinality === "record") {
642
641
  if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
643
642
  if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
644
643
  if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
645
644
  }
646
645
  }
647
- function dt(e, t, r) {
648
- const o = r.prepared.get(e);
649
- if (o) return o;
650
- const n = _r(e, t);
651
- if (n)
652
- return r.prepared.set(e, n), n;
646
+ function ut(e, t, r) {
647
+ const n = r.prepared.get(e);
648
+ if (n) return n;
649
+ const o = Ur(e, t);
650
+ if (o)
651
+ return r.prepared.set(e, o), o;
653
652
  if (e.tree) {
654
- const c = zr(e, t, r);
653
+ const c = qr(e, t, r);
655
654
  return r.prepared.set(e, c), c;
656
655
  }
657
656
  let a = e.computed?.length ? Me(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
658
657
  const s = a === t ? void 0 : new Map(a.map((c, l) => [c, t[l]]));
659
- e.rowVisibleWhen && (a = a.filter(L(e.rowVisibleWhen)));
660
- const i = yr(e, a);
658
+ e.rowVisibleWhen && (a = a.filter(H(e.rowVisibleWhen)));
659
+ const i = vr(e, a);
661
660
  if (!e.matrix) {
662
- const c = se(e, s ? a.map((l) => s.get(l)) : a);
661
+ const c = ae(e, s ? a.map((l) => s.get(l)) : a);
663
662
  i.sources = s ? new Map(a.map((l) => [l, c.get(s.get(l))])) : c;
664
663
  }
665
664
  return r.prepared.set(e, i), i;
666
665
  }
667
- function qr(e, t, r, o) {
668
- if (!o.flow) return;
669
- const { current: n, templatePage: a } = o, s = Math.max(n.marginTopMm, V(a)), i = Math.max(o.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? W(t, r[0], o.measurer).heightMm : 0);
670
- i + c <= Q(a, n) + 1e-3 || i <= s + 1e-3 || (o.pushCurrent(), n.components = [], n.heightMm = a.heightMm, a.layout === "wide" && (n.marginTopMm = 0, n.marginBottomMm = 0), o.startTop = Math.max(n.marginTopMm, V(a)));
671
- }
672
- function* Ur(e, t, r) {
673
- const o = dt(e, t, r), n = o.rows;
674
- e = o.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
675
- const a = o.sources ?? se(e, n), s = Te(e), i = ie(s), c = { ...Ee(s, r.measurer, n, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: o.matrix, ...o.treeRows ? { tree: { list: s, rows: o.treeRows } } : {} };
676
- qr(s, c, n, r);
677
- const l = Br(s, c, r), d = Wr(s, n, r);
666
+ function Xr(e, t, r, n) {
667
+ if (!n.flow) return;
668
+ const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, V(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? J(t, r[0], n.measurer).heightMm : 0);
669
+ i + c <= Z(a, o) + 1e-3 || i <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = a.heightMm, a.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, V(a)));
670
+ }
671
+ function* Yr(e, t, r) {
672
+ const n = ut(e, t, r), o = n.rows;
673
+ e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
674
+ const a = n.sources ?? ae(e, o), s = Ee(e), i = se(s), c = { ...Pe(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
675
+ Xr(s, c, o, r);
676
+ const l = Wr(s, c, r), d = zr(s, o, r);
678
677
  let f;
679
- for (const u of at(n, i)) {
680
- if (J(r.signal), u.kind === "row")
681
- l.placeGridRow(f ?? W(c, u.row, r.measurer), "listr", pr(o.matrix, u.row), a.get(u.row)), f = void 0, yield* r.takePages(), yield* Jr(s, u.row, d, r, l);
678
+ for (const u of st(o, i)) {
679
+ if (N(r.signal), u.kind === "row")
680
+ l.placeGridRow(f ?? J(c, u.row, r.measurer), "listr", yr(n.matrix, u.row), a.get(u.row)), f = void 0, yield* r.takePages(), yield* _r(s, u.row, d, r, l);
682
681
  else if (u.kind === "groupHeader") {
683
- const h = B(c, r.measurer, u.label, /* @__PURE__ */ new Map(), u.group.headerStyle ?? {}, s.columns.length);
684
- f ??= W(c, u.firstRow, r.measurer);
685
- const m = i.slice(u.depth + 1).reduce((v, y) => v + B(c, r.measurer, (y.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(u.firstRow[y.field])), /* @__PURE__ */ new Map(), y.headerStyle ?? {}, s.columns.length).heightMm, 0);
682
+ const h = G(c, r.measurer, u.label, /* @__PURE__ */ new Map(), u.group.headerStyle ?? {}, s.columns.length);
683
+ f ??= J(c, u.firstRow, r.measurer);
684
+ const m = i.slice(u.depth + 1).reduce((v, y) => v + G(c, r.measurer, (y.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(u.firstRow[y.field])), /* @__PURE__ */ new Map(), y.headerStyle ?? {}, s.columns.length).heightMm, 0);
686
685
  u.group.keepWithNext !== !1 && l.keepTogether(h.heightMm + m + f.heightMm), l.placeGridRow(h, "listg", "group-header"), u.group.repeatHeader && l.setGroupHeader(u.depth, h);
687
686
  } else if (u.kind === "subtotal") {
688
- const h = u.group.subtotal ?? [], m = u.group.aggregates ?? [], v = B(c, r.measurer, u.label, st(s.columns, u.rows, h, m), u.group.subtotalStyle ?? {}, it(s.columns, [...h, ...m.map((y) => y.field)]));
687
+ const h = u.group.subtotal ?? [], m = u.group.aggregates ?? [], v = G(c, r.measurer, u.label, it(s.columns, u.rows, h, m), u.group.subtotalStyle ?? {}, ct(s.columns, [...h, ...m.map((y) => y.field)]));
689
688
  l.placeGridRow(v, "listst", "subtotal");
690
689
  } else l.setGroupHeader(u.depth);
691
690
  yield* r.takePages();
692
691
  }
693
- Vr(s, o.totalRows ?? n, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
692
+ Jr(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
694
693
  }
695
- function ce(e) {
694
+ function ie(e) {
696
695
  return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
697
696
  }
698
- function le(e, t) {
697
+ function ce(e, t) {
699
698
  return {
700
699
  ...e,
701
700
  ...e.text === void 0 ? {} : { text: t(e.text) },
702
701
  ...e.lines ? { lines: e.lines.map(t) } : {},
703
- ...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((o) => ({ ...o, ...o.text === void 0 ? {} : { text: t(o.text) } })) })) } : {},
704
- ...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((o) => o ? { ...o, ...o.text === void 0 ? {} : { text: t(o.text) }, ...o.children ? { children: o.children.map((n) => le(n, t)) } : {} } : null)) } } : {}
702
+ ...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
703
+ ...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((n) => n ? { ...n, ...n.text === void 0 ? {} : { text: t(n.text) }, ...n.children ? { children: n.children.map((o) => ce(o, t)) } : {} } : null)) } } : {}
705
704
  };
706
705
  }
707
- function Xr(e) {
706
+ function Qr(e) {
708
707
  let t = !1;
709
- for (const r of e.pages) for (const o of r.components) ce(o) && le(o, (n) => (n.includes("{totalPages}") && (t = !0), n));
708
+ for (const r of e.pages) for (const n of r.components) ie(n) && ce(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
710
709
  return t;
711
710
  }
712
- function Yr(e, t, r, o, n, a) {
711
+ function Zr(e, t, r, n, o, a) {
713
712
  const s = {
714
713
  pageWidthMm: t.widthMm,
715
714
  pageHeightMm: t.heightMm,
@@ -721,41 +720,41 @@ function Yr(e, t, r, o, n, a) {
721
720
  components: t.components,
722
721
  ...e.meta ? { meta: e.meta } : {}
723
722
  }, i = (c) => {
724
- const l = c.replace(/\{page\}/g, String(o));
723
+ const l = c.replace(/\{page\}/g, String(n));
725
724
  return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
726
725
  };
727
- for (const c of r) s.components.push(le(c, i));
726
+ for (const c of r) s.components.push(ce(c, i));
728
727
  if (e.layout === "wide") {
729
728
  const c = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
730
- s.marginBottomMm = n ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
729
+ s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
731
730
  }
732
731
  return s;
733
732
  }
734
- function Pe(e) {
735
- return e.cells.reduce((t, r) => t + r.reduce((o, n) => o + (n ? 1 + (n.children?.reduce((a, s) => a + ut(s), 0) ?? 0) : 0), 0), 0);
733
+ function Re(e) {
734
+ return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + ft(s), 0) ?? 0) : 0), 0), 0);
736
735
  }
737
- function ut(e) {
738
- return e.grid ? Pe(e.grid) : 0;
736
+ function ft(e) {
737
+ return e.grid ? Re(e.grid) : 0;
739
738
  }
740
- function Re(e) {
739
+ function le(e) {
741
740
  for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
742
- ne(e.maxChartComponents);
741
+ oe(e.maxChartComponents);
743
742
  }
744
- function Qr(e, t) {
745
- const r = dt(e, t.datasets[e.dataset] ?? [], t), o = Te(r.list), n = { ...Ee(o, t.measurer, r.rows, t.signal), rowHeightFloorMm: o.rowHeightMm ?? 0 };
746
- return (o.header === !1 ? 0 : n.headerHeightMm) + r.rows.reduce((a, s) => a + W(n, s, t.measurer).heightMm, 0);
743
+ function en(e, t) {
744
+ const r = ut(e, t.datasets[e.dataset] ?? [], t), n = Ee(r.list), o = { ...Pe(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
745
+ return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + J(o, s, t.measurer).heightMm, 0);
747
746
  }
748
- function* Zr(e) {
749
- const { templatePage: t, current: r } = e, o = new Map(t.components.map((a, s) => [a, s])), n = (a, s, i) => {
747
+ function* tn(e) {
748
+ const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, i) => {
750
749
  const c = e.datasets[a.dataset];
751
- return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), Ur(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${o.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
750
+ return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), Yr(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
752
751
  };
753
752
  if (t.flow) {
754
- yield* Sr({
753
+ yield* Cr({
755
754
  page: t,
756
- active: () => J(e.signal),
755
+ active: () => N(e.signal),
757
756
  top: () => Math.max(r.marginTopMm, V(t)),
758
- bottom: () => Q(t, r),
757
+ bottom: () => Z(t, r),
759
758
  append: (a) => {
760
759
  r.components.push(...e.resolveChart(a));
761
760
  },
@@ -763,34 +762,34 @@ function* Zr(e) {
763
762
  e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
764
763
  },
765
764
  takePages: e.takePages,
766
- height: (a) => Qr(a, e),
767
- list: n
765
+ height: (a) => en(a, e),
766
+ list: o
768
767
  });
769
768
  return;
770
769
  }
771
770
  for (const a of t.components)
772
- ce(a) || (a.kind === "list" ? yield* n(a) : r.components.push(...e.resolveChart(a)));
771
+ ie(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
773
772
  }
774
- function* Z(e, t, r, o, n, a = /* @__PURE__ */ new WeakMap(), s) {
773
+ function* z(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
775
774
  let i = 0, c = 0, l = 0;
776
- const d = mr(r.measurer ?? We), f = gr(t, r.signal, r.maxChartComponents), u = (h) => `${h}_${(++i).toString(36)}`;
777
- for (const { pageIndex: h, page: m } of Fr(e, t, r)) {
778
- J(r.signal);
779
- const v = Or(m), y = m.components.filter(ce);
775
+ const d = gr(r.measurer ?? Je), f = wr(t, r.signal, r.maxChartComponents), u = (h) => `${h}_${(++i).toString(36)}`;
776
+ for (const { pageIndex: h, page: m } of Ar(e, t, r)) {
777
+ N(r.signal);
778
+ const v = Nr(m), y = m.components.filter(ie);
780
779
  let g = [];
781
- const w = (P = !1) => {
782
- if (J(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new G(r.maxPages, c + 1);
783
- if (r.maxCells !== void 0 && (l += [...v.components, ...y].reduce((E, O) => E + ut(O), 0), l > r.maxCells))
784
- throw new X(r.maxCells, l);
785
- g.push(Yr(m, v, y, ++c, P, n));
780
+ const w = (E = !1) => {
781
+ if (N(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new W(r.maxPages, c + 1);
782
+ if (r.maxCells !== void 0 && (l += [...v.components, ...y].reduce((k, O) => k + ft(O), 0), l > r.maxCells))
783
+ throw new Y(r.maxCells, l);
784
+ g.push(Zr(m, v, y, ++c, E, o));
786
785
  }, x = () => {
787
- const P = g;
788
- return g = [], P;
786
+ const E = g;
787
+ return g = [], E;
789
788
  };
790
- yield* Zr({
789
+ yield* tn({
791
790
  templatePage: m,
792
791
  current: v,
793
- warnings: o,
792
+ warnings: n,
794
793
  nextId: u,
795
794
  pushCurrent: w,
796
795
  takePages: x,
@@ -806,75 +805,86 @@ function* Z(e, t, r, o, n, a = /* @__PURE__ */ new WeakMap(), s) {
806
805
  }
807
806
  s && (s.chartComponents = f.used());
808
807
  }
809
- function dn(e, t, r = {}) {
810
- Re(r);
811
- let o = 0;
812
- for (const n of Z(e, t, { ...r, onWarning: void 0 }, [])) o++;
813
- return o;
808
+ function mo(e, t, r = {}) {
809
+ le(r);
810
+ let n = 0;
811
+ for (const o of z(e, t, { ...r, onWarning: void 0 }, [])) n++;
812
+ return n;
814
813
  }
815
- function* un(e, t, r = {}) {
816
- yield* ft(e, t, r);
814
+ function* ho(e, t, r = {}) {
815
+ yield* rn(e, t, r);
817
816
  }
818
- function* ft(e, t, r, o) {
819
- Re(r);
820
- const n = Xr(e), a = /* @__PURE__ */ new WeakMap();
817
+ function* rn(e, t, r, n) {
818
+ le(r);
819
+ const o = Qr(e), a = /* @__PURE__ */ new WeakMap();
821
820
  let s = r.knownTotalPages;
822
- if (n && s === void 0) {
821
+ if (o && s === void 0) {
823
822
  s = 0;
824
- for (const l of Z(e, t, r, [], void 0, a)) s++;
823
+ for (const l of z(e, t, r, [], void 0, a)) s++;
825
824
  }
826
825
  const i = [];
827
826
  let c = 0;
828
- for (const l of Z(e, t, r, i, s, a, o)) {
827
+ for (const l of z(e, t, r, i, s, a, n)) {
829
828
  for (; c < i.length; c++) r.onWarning?.(i[c]);
830
829
  yield l;
831
830
  }
832
831
  }
833
832
  function mt(e, t, r = {}) {
834
- const o = typeof r == "number" ? { mmPerRow: r } : r;
835
- Re(o);
836
- const n = [], a = { chartComponents: 0 }, s = [...Z(e, t, o, n, o.knownTotalPages, void 0, a)];
837
- for (const i of s) i.components = i.components.map((c) => ce(c) ? le(c, (l) => l.replace(/\{totalPages\}/g, String(s.length))) : c);
838
- return n.forEach((i) => o.onWarning?.(i)), { plan: { schemaVersion: te, ...ae(e) ? { requiresRecalculation: !0 } : {}, pages: s }, warnings: n, ...a };
839
- }
840
- function eo(e) {
833
+ const n = typeof r == "number" ? { mmPerRow: r } : r;
834
+ le(n);
835
+ const o = [], a = { chartComponents: 0 }, s = [...z(e, t, n, o, n.knownTotalPages, void 0, a)];
836
+ return gt(e, n, s, o, a);
837
+ }
838
+ async function ht(e, t, r = {}) {
839
+ le(r), N(r.signal);
840
+ const n = [], o = [], a = { chartComponents: 0 };
841
+ let s = performance.now(), i = 0;
842
+ for (const c of z(e, t, r, n, r.knownTotalPages, void 0, a))
843
+ o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)), N(r.signal), s = performance.now(), i = 0);
844
+ return N(r.signal), gt(e, r, o, n, a);
845
+ }
846
+ function gt(e, t, r, n, o) {
847
+ for (const a of r) a.components = a.components.map((s) => ie(s) ? ce(s, (i) => i.replace(/\{totalPages\}/g, String(r.length))) : s);
848
+ return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: be, ...ke(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
849
+ }
850
+ function nn(e) {
841
851
  const t = e.columns.find((a) => !a.hidden)?.field;
842
852
  if (!t) return { groups: 0, total: 0 };
843
- const r = ie(e), o = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), n = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
844
- return { groups: r.filter((a) => o(a.subtotal, a.aggregates)).length, total: Number(o(n?.fields ?? r[0]?.subtotal, n?.aggregates ?? r[0]?.aggregates)) };
853
+ const r = se(e), n = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
854
+ return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
845
855
  }
846
- function to(e, t, r) {
847
- lt(e);
848
- const o = Xe(t[e.dataset] ?? [], e.tree, r), n = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Pe(e.headerGrid) : n;
849
- return o.length * n + a + +!!e.grandTotal * 2 * n;
856
+ function on(e, t, r) {
857
+ dt(e);
858
+ const n = Ye(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Re(e.headerGrid) : o;
859
+ return n.length * o + a + +!!e.grandTotal * 2 * o;
850
860
  }
851
- function fn(e, t, r = {}) {
852
- if (e.tree) return to(e, t, r.signal);
861
+ function go(e, t, r = {}) {
862
+ if (e.tree) return on(e, t, r.signal);
853
863
  if (e.matrix) {
854
864
  let c = t[e.dataset] ?? [];
855
- e.computed?.length && (c = Me(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(L(e.rowVisibleWhen)));
856
- const l = er(c, e.matrix);
865
+ e.computed?.length && (c = Me(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(H(e.rowVisibleWhen)));
866
+ const l = rr(c, e.matrix);
857
867
  return l.cells + (e.header === !1 ? 0 : l.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
858
868
  }
859
- const o = t[e.dataset]?.length ?? 0, n = e.columns.filter((c) => !c.hidden).length, a = ie(e).length, s = eo(e);
860
- let i = (o * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * n;
861
- if (i += e.header === !1 ? 0 : e.headerGrid ? Pe(e.headerGrid) : n, e.cardinality === "record" && o === 0 && (i += n), e.detail) {
869
+ const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a = se(e).length, s = nn(e);
870
+ let i = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
871
+ if (i += e.header === !1 ? 0 : e.headerGrid ? Re(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
862
872
  const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
863
- i += (c + o * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
873
+ i += (c + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
864
874
  }
865
875
  if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
866
876
  return i;
867
877
  }
868
- class ro extends Error {
878
+ class an extends Error {
869
879
  constructor(t) {
870
880
  super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
871
881
  }
872
882
  }
873
- function je(e, t, r) {
883
+ function Le(e, t, r) {
874
884
  if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
875
885
  return e;
876
886
  }
877
- function oo(e) {
887
+ function sn(e) {
878
888
  if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
879
889
  if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
880
890
  const t = /* @__PURE__ */ new Set();
@@ -883,7 +893,7 @@ function oo(e) {
883
893
  t.add(r.field), r.valueField !== void 0 && K(r.valueField), r.weightField !== void 0 && K(r.weightField), Se([], { ...r, field: r.valueField ?? r.field });
884
894
  }
885
895
  }
886
- function ht(e) {
896
+ function pt(e) {
887
897
  if (!Array.isArray(e) || e.length > 256 || Object.keys(e).length !== e.length) throw new Error("校验规则最多 256 条且不允许空位");
888
898
  const t = /* @__PURE__ */ new Set();
889
899
  return e.map((r) => {
@@ -892,118 +902,118 @@ function ht(e) {
892
902
  if (t.add(r.id), r.field !== void 0 && K(r.field), r.dataset !== void 0 && K(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
893
903
  if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
894
904
  if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
895
- oo(r);
896
- const o = { nodes: 0 }, n = L(r.assert, o), a = r.when ? L(r.when, o) : void 0;
897
- return { rule: r, assert: n, when: a, checks: o.nodes };
905
+ sn(r);
906
+ const n = { nodes: 0 }, o = H(r.assert, n), a = r.when ? H(r.when, n) : void 0;
907
+ return { rule: r, assert: o, when: a, checks: n.nodes };
898
908
  });
899
909
  }
900
- function Le(e) {
910
+ function He(e) {
901
911
  if (e?.aborted) {
902
912
  const t = new Error("报表校验已取消");
903
913
  throw t.name = "AbortError", t;
904
914
  }
905
915
  }
906
- function no(e, t, r, o) {
907
- const n = o && Object.prototype.hasOwnProperty.call(t, o) ? t[o] : void 0;
908
- if (n !== void 0 && typeof n != "string" && !(typeof n == "number" && Number.isFinite(n))) throw new Error("校验定位需要稳定的文本或数值业务键");
909
- return { ruleId: e.id, rowIndex: r, ...n === void 0 ? {} : { rowKey: n }, field: e.field, severity: e.severity ?? "error", message: e.message };
916
+ function cn(e, t, r, n) {
917
+ const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
918
+ if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
919
+ return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
910
920
  }
911
- function ao(e, t) {
921
+ function ln(e, t) {
912
922
  const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
913
923
  if (t.tree) {
914
- const n = Ye(e, t.tree, { signal: t.signal, computed: r });
915
- if (n.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
916
- return { rows: n.rows, summaryRows: n.leaves, rowKey: t.tree.idField };
924
+ const o = Qe(e, t.tree, { signal: t.signal, computed: r });
925
+ if (o.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
926
+ return { rows: o.rows, summaryRows: o.leaves, rowKey: t.tree.idField };
917
927
  }
918
- const o = r ? Me(e, r).rows : e;
919
- return { rows: o, summaryRows: o, rowKey: t.rowKey };
928
+ const n = r ? Me(e, r).rows : e;
929
+ return { rows: n, summaryRows: n, rowKey: t.rowKey };
920
930
  }
921
- function so(e, t) {
931
+ function dn(e, t) {
922
932
  const r = /* @__PURE__ */ new Set();
923
- e.forEach((o) => {
924
- if (!o || typeof o != "object" || Array.isArray(o)) throw new Error("校验数据行应为对象");
933
+ e.forEach((n) => {
934
+ if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
925
935
  if (!t) return;
926
- const n = Object.prototype.hasOwnProperty.call(o, t) ? o[t] : void 0;
927
- if (!(typeof n == "string" && n.trim()) && !(typeof n == "number" && Number.isFinite(n))) throw new Error("校验定位需要稳定业务键");
928
- if (r.has(n)) throw new Error("校验业务键重复");
929
- r.add(n);
936
+ const o = Object.prototype.hasOwnProperty.call(n, t) ? n[t] : void 0;
937
+ if (!(typeof o == "string" && o.trim()) && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定业务键");
938
+ if (r.has(o)) throw new Error("校验业务键重复");
939
+ r.add(o);
930
940
  });
931
941
  }
932
- function mn(e, t) {
933
- return gt(e, t, { checks: 0 });
942
+ function po(e, t) {
943
+ return wt(e, t, { checks: 0 });
934
944
  }
935
- function gt(e, t, r) {
945
+ function wt(e, t, r) {
936
946
  if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
937
- Le(t.signal);
938
- const o = je(t.maxChecks ?? 2e6, "maxChecks", 1e7), n = je(t.maxIssues ?? 1e3, "maxIssues", 1e4);
947
+ He(t.signal);
948
+ const n = Le(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = Le(t.maxIssues ?? 1e3, "maxIssues", 1e4);
939
949
  t.rowKey !== void 0 && K(t.rowKey);
940
- const a = ao(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
941
- so(s, c);
942
- const l = ht(t.rules), d = l.reduce((u, h) => u + (h.rule.scope === "dataset" ? h.checks + i.length * (h.rule.aggregates?.length ?? 0) : s.length * h.checks), 0);
943
- if (r.checks += d, r.checks > o) throw new Error("整批校验超出 maxChecks 预算");
950
+ const a = ln(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
951
+ dn(s, c);
952
+ const l = pt(t.rules), d = l.reduce((u, h) => u + (h.rule.scope === "dataset" ? h.checks + i.length * (h.rule.aggregates?.length ?? 0) : s.length * h.checks), 0);
953
+ if (r.checks += d, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
944
954
  const f = [];
945
955
  for (const u of l)
946
956
  (u.rule.scope === "dataset" ? [Object.fromEntries((u.rule.aggregates ?? []).map((m) => [m.field, Se(i, { ...m, field: m.valueField ?? m.field })]))] : s).forEach((m, v) => {
947
- if (Le(t.signal), !m || typeof m != "object" || Array.isArray(m)) throw new Error("校验数据行应为对象");
957
+ if (He(t.signal), !m || typeof m != "object" || Array.isArray(m)) throw new Error("校验数据行应为对象");
948
958
  if (!(u.when && !u.when(m) || u.assert(m))) {
949
- if (f.length >= n) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
950
- f.push(no(u.rule, m, u.rule.scope === "dataset" ? void 0 : v, u.rule.scope === "dataset" ? void 0 : c));
959
+ if (f.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
960
+ f.push(cn(u.rule, m, u.rule.scope === "dataset" ? void 0 : v, u.rule.scope === "dataset" ? void 0 : c));
951
961
  }
952
962
  });
953
963
  return f;
954
964
  }
955
- function io(e, t = "allow") {
965
+ function un(e, t = "allow") {
956
966
  if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
957
967
  if (!Array.isArray(e) || e.length > 1e4 || e.some((r) => !r || !["error", "warning"].includes(r.severity) || typeof r.ruleId != "string" || !r.ruleId.trim() || typeof r.message != "string" || !r.message.trim())) throw new Error("校验问题结构无效");
958
- if (e.some((r) => r.severity === "error" || t === "block")) throw new ro(e);
968
+ if (e.some((r) => r.severity === "error" || t === "block")) throw new an(e);
959
969
  }
960
- function He(e, t, r) {
961
- const o = e.get(t);
962
- if (o && JSON.stringify(o) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
970
+ function De(e, t, r) {
971
+ const n = e.get(t);
972
+ if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
963
973
  e.set(t, r);
964
974
  }
965
- function co(e, t, r, o = []) {
966
- ht(t.rules);
967
- const n = [], a = { checks: 0 };
975
+ function fn(e, t, r, n = []) {
976
+ pt(t.rules);
977
+ const o = [], a = { checks: 0 };
968
978
  for (const [i, c] of e.entries()) {
969
979
  const l = /* @__PURE__ */ new Map();
970
980
  for (const d of c.template.pages) for (const f of d.components)
971
- f.kind === "list" && (He(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && He(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
981
+ f.kind === "list" && (De(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && De(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
972
982
  for (const [d, f] of l) {
973
983
  const u = t.rules.filter((h) => !h.dataset || h.dataset === d);
974
- if (u.length && (n.push(...gt(c.datasets[d] ?? [], { ...t, rules: u, ...f, formula: o[i], signal: r }, a).map((h) => ({ ...h, dataset: d, sourceScope: c.sourceScope }))), n.length > (t.maxIssues ?? 1e3)))
984
+ if (u.length && (o.push(...wt(c.datasets[d] ?? [], { ...t, rules: u, ...f, formula: n[i], signal: r }, a).map((h) => ({ ...h, dataset: d, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
975
985
  throw new Error("整批候选校验问题超出 maxIssues 预算");
976
986
  }
977
987
  }
978
988
  const s = new Set(e.flatMap((i) => i.template.pages.flatMap((c) => c.components.flatMap((l) => l.kind === "list" ? [l.dataset, ...l.detail ? [l.detail.dataset] : []] : []))));
979
989
  if (t.rules.some((i) => i.dataset && !s.has(i.dataset))) throw new Error("校验目标数据集不存在");
980
- return n;
990
+ return o;
981
991
  }
982
- function pt(e) {
992
+ function yt(e) {
983
993
  return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
984
994
  }
985
- function wt(e, t, r) {
986
- const o = e.grid;
987
- if (!o) return null;
988
- const n = o.cells[t];
995
+ function bt(e, t, r) {
996
+ const n = e.grid;
989
997
  if (!n) return null;
990
- const s = oe(o, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = n[s];
998
+ const o = n.cells[t];
999
+ if (!o) return null;
1000
+ const s = re(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
991
1001
  return i ? { cell: i, sourceColumnIndex: s } : null;
992
1002
  }
993
- function lo(e) {
1003
+ function mn(e) {
994
1004
  return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
995
1005
  }
996
- function uo(e, t) {
1006
+ function hn(e, t) {
997
1007
  return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
998
1008
  }
999
- function fo(e, t) {
1009
+ function gn(e, t) {
1000
1010
  if (e.derived) return "derived";
1001
1011
  if (e.editable === !1) return "cell";
1002
1012
  if (e.formula !== void 0) return "formula";
1003
1013
  if (e.children?.length || e.richParagraphs?.length) return "complex";
1004
1014
  if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
1005
1015
  }
1006
- function mo(e, t) {
1016
+ function pn(e, t) {
1007
1017
  const r = e.table;
1008
1018
  if (r)
1009
1019
  return {
@@ -1013,54 +1023,54 @@ function mo(e, t) {
1013
1023
  columnKey: r.columnKeys[t.columnIndex]
1014
1024
  };
1015
1025
  }
1016
- function ho(e, t, r) {
1026
+ function wn(e, t, r) {
1017
1027
  if (e.derived) return;
1018
1028
  if (e.source) return { ...e.source };
1019
- const o = t.table?.source, n = t.table?.columnKeys[r.columnIndex];
1020
- if (!(!o || o.rowKey === void 0 || n === void 0))
1021
- return { ...o, rowKey: o.rowKey, field: n };
1029
+ const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
1030
+ if (!(!n || n.rowKey === void 0 || o === void 0))
1031
+ return { ...n, rowKey: n.rowKey, field: o };
1022
1032
  }
1023
- function yt(e, t, r) {
1024
- const o = lo(r), n = fo(r, e);
1033
+ function vt(e, t, r) {
1034
+ const n = mn(r), o = gn(r, e);
1025
1035
  return {
1026
1036
  address: { ...t },
1027
1037
  cell: r,
1028
1038
  component: e,
1029
- value: o,
1030
- valueType: uo(r, o),
1031
- table: mo(e, t),
1032
- source: ho(r, e, t),
1033
- editable: n === void 0,
1034
- readOnlyReason: n
1039
+ value: n,
1040
+ valueType: hn(r, n),
1041
+ table: pn(e, t),
1042
+ source: wn(r, e, t),
1043
+ editable: o === void 0,
1044
+ readOnlyReason: o
1035
1045
  };
1036
1046
  }
1037
1047
  function $e(e, t) {
1038
- if (!pt(t)) return null;
1048
+ if (!yt(t)) return null;
1039
1049
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1040
1050
  if (!r) return null;
1041
- const o = wt(r, t.rowIndex, t.columnIndex);
1042
- return o ? yt(r, t, o.cell) : null;
1051
+ const n = bt(r, t.rowIndex, t.columnIndex);
1052
+ return n ? vt(r, t, n.cell) : null;
1043
1053
  }
1044
- function H(e) {
1054
+ function D(e) {
1045
1055
  const t = /* @__PURE__ */ new Map();
1046
1056
  return (r) => {
1047
- if (!pt(r)) return null;
1048
- const o = e.pages[r.pageIndex]?.components[r.componentIndex];
1049
- if (!o?.grid) return null;
1050
- let n = t.get(o);
1051
- if (!n) {
1057
+ if (!yt(r)) return null;
1058
+ const n = e.pages[r.pageIndex]?.components[r.componentIndex];
1059
+ if (!n?.grid) return null;
1060
+ let o = t.get(n);
1061
+ if (!o) {
1052
1062
  const s = /* @__PURE__ */ new Map();
1053
- n = /* @__PURE__ */ new Map();
1054
- for (const i of oe(o.grid, o.widthMm, o.heightMm).cells) {
1063
+ o = /* @__PURE__ */ new Map();
1064
+ for (const i of re(n.grid, n.widthMm, n.heightMm).cells) {
1055
1065
  const c = s.get(i.ri) ?? 0;
1056
1066
  s.set(i.ri, c + 1);
1057
- const l = o.grid.cells[i.ri]?.[c];
1058
- l && n.set(`${i.ri}:${i.ci}`, l);
1067
+ const l = n.grid.cells[i.ri]?.[c];
1068
+ l && o.set(`${i.ri}:${i.ci}`, l);
1059
1069
  }
1060
- t.set(o, n);
1070
+ t.set(n, o);
1061
1071
  }
1062
- const a = n.get(`${r.rowIndex}:${r.columnIndex}`);
1063
- return a ? yt(o, r, a) : null;
1072
+ const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
1073
+ return a ? vt(n, r, a) : null;
1064
1074
  };
1065
1075
  }
1066
1076
  class M extends Error {
@@ -1068,20 +1078,20 @@ class M extends Error {
1068
1078
  super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
1069
1079
  }
1070
1080
  }
1071
- function go(e, t) {
1081
+ function yn(e, t) {
1072
1082
  let r = e.trim();
1073
- const o = t && r.endsWith("%");
1074
- if (o && (r = r.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r) && (r = r.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) throw new M("number");
1075
- return Number(r) / (o ? 100 : 1);
1083
+ const n = t && r.endsWith("%");
1084
+ if (n && (r = r.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r) && (r = r.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) throw new M("number");
1085
+ return Number(r) / (n ? 100 : 1);
1076
1086
  }
1077
- function po(e, t) {
1087
+ function bn(e, t) {
1078
1088
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1079
1089
  if (typeof e != "string" && typeof e != "number") throw new M("number");
1080
- const r = typeof e == "number" ? e : go(e, dr(t.cell.numberFormat));
1090
+ const r = typeof e == "number" ? e : yn(e, fr(t.cell.numberFormat));
1081
1091
  if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new M("number");
1082
1092
  return r;
1083
1093
  }
1084
- function wo(e) {
1094
+ function vn(e) {
1085
1095
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1086
1096
  if (typeof e == "boolean") return e;
1087
1097
  const t = String(e).trim().toLowerCase();
@@ -1089,24 +1099,24 @@ function wo(e) {
1089
1099
  if (["false", "no", "否", "0"].includes(t)) return !1;
1090
1100
  throw new M("boolean");
1091
1101
  }
1092
- function bt(e, t) {
1093
- return e.valueType === "number" ? po(t, e) : e.valueType === "boolean" ? wo(t) : t === null ? null : String(t);
1102
+ function Mt(e, t) {
1103
+ return e.valueType === "number" ? bn(t, e) : e.valueType === "boolean" ? vn(t) : t === null ? null : String(t);
1094
1104
  }
1095
- function yo(e, t) {
1096
- const r = t.cell.text, n = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
1097
- return n ? n[e ? 0 : 1] : String(e);
1105
+ function Mn(e, t) {
1106
+ const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
1107
+ return o ? o[e ? 0 : 1] : String(e);
1098
1108
  }
1099
- function _(e, t) {
1100
- return t === null ? "" : typeof t == "boolean" ? yo(t, e) : typeof t == "number" ? lr(t, e.cell.numberFormat) : String(t);
1109
+ function q(e, t) {
1110
+ return t === null ? "" : typeof t == "boolean" ? Mn(t, e) : typeof t == "number" ? ur(t, e.cell.numberFormat) : String(t);
1101
1111
  }
1102
- function hn(e, t, r) {
1103
- const o = $e(e, t);
1104
- if (!o) throw new M("missing");
1105
- return q(o, r);
1112
+ function wo(e, t, r) {
1113
+ const n = $e(e, t);
1114
+ if (!n) throw new M("missing");
1115
+ return U(n, r);
1106
1116
  }
1107
- function q(e, t) {
1117
+ function U(e, t) {
1108
1118
  if (!e.editable) throw new M("readonly");
1109
- const r = bt(e, t);
1119
+ const r = Mt(e, t);
1110
1120
  return {
1111
1121
  address: { ...e.address },
1112
1122
  table: e.table,
@@ -1114,136 +1124,136 @@ function q(e, t) {
1114
1124
  previousValue: e.value,
1115
1125
  previousText: e.cell.text ?? "",
1116
1126
  value: r,
1117
- text: _(e, r)
1127
+ text: q(e, r)
1118
1128
  };
1119
1129
  }
1120
- function bo(e, t) {
1121
- const r = e.table, o = t.table;
1122
- return !r || !o || r.columnKey === void 0 ? !1 : r.id === o.id && r.rowIndex === o.rowIndex && r.role === o.role && r.columnKey === o.columnKey;
1130
+ function Sn(e, t) {
1131
+ const r = e.table, n = t.table;
1132
+ return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
1123
1133
  }
1124
- function vt(e, t, r) {
1125
- const o = e.grid, { rowIndex: n, columnIndex: a } = t.address, s = wt(e, n, a), i = [...o.cells], c = [...i[n]], l = _(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
1126
- return c[s.sourceColumnIndex] = d, i[n] = c, { ...e, grid: { ...o, cells: i } };
1134
+ function St(e, t, r) {
1135
+ const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = bt(e, o, a), i = [...n.cells], c = [...i[o]], l = q(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
1136
+ return c[s.sourceColumnIndex] = d, i[o] = c, { ...e, grid: { ...n, cells: i } };
1127
1137
  }
1128
- function vo(e, t) {
1129
- const r = e.table?.columnKeys, o = t.table?.columnKey;
1130
- return r && o !== void 0 ? r.flatMap((n, a) => n === o ? [a] : []) : [];
1138
+ function xn(e, t) {
1139
+ const r = e.table?.columnKeys, n = t.table?.columnKey;
1140
+ return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
1131
1141
  }
1132
- function Mo(e, t, r, o, n, a) {
1133
- const s = t.table, i = n.table;
1142
+ function Cn(e, t, r, n, o, a) {
1143
+ const s = t.table, i = o.table;
1134
1144
  if (!s || !i || s.id !== i.id || s.role !== i.role || !t.grid) return t;
1135
1145
  const c = i.rowIndex - s.rowIndex;
1136
1146
  if (c < 0 || c >= t.grid.cells.length) return t;
1137
1147
  let l = t;
1138
- for (const d of vo(t, n)) {
1139
- const f = $e(e, { pageIndex: r, componentIndex: o, rowIndex: c, columnIndex: d });
1140
- f?.editable && bo(n, f) && (l = vt(l, f, a));
1148
+ for (const d of xn(t, o)) {
1149
+ const f = $e(e, { pageIndex: r, componentIndex: n, rowIndex: c, columnIndex: d });
1150
+ f?.editable && Sn(o, f) && (l = St(l, f, a));
1141
1151
  }
1142
1152
  return l;
1143
1153
  }
1144
- function So(e, t, r, o, n, a) {
1145
- const s = n.address;
1146
- return n.table?.columnKey !== void 0 ? Mo(e, t, r, o, n, a) : s.pageIndex === r && s.componentIndex === o ? vt(t, n, a) : t;
1154
+ function kn(e, t, r, n, o, a) {
1155
+ const s = o.address;
1156
+ return o.table?.columnKey !== void 0 ? Cn(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? St(t, o, a) : t;
1147
1157
  }
1148
1158
  function Ie(e, t) {
1149
1159
  const r = t.source;
1150
1160
  if (!r) return !1;
1151
- const o = e.source;
1152
- return !o || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((n) => !Object.is(o[n], r[n]));
1161
+ const n = e.source;
1162
+ return !n || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
1153
1163
  }
1154
- function gn(e, t) {
1164
+ function yo(e, t) {
1155
1165
  const r = $e(e, t.address);
1156
1166
  if (!r) throw new M("missing");
1157
1167
  if (!r.editable) throw new M("readonly");
1158
1168
  if (Ie(r, t)) throw new M("conflict");
1159
1169
  if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new M("conflict");
1160
- const o = bt(r, t.value), n = { ...t, value: o, text: _(r, o) };
1161
- if (Object.is(o, r.value) && n.text === r.cell.text) return e;
1170
+ const n = Mt(r, t.value), o = { ...t, value: n, text: q(r, n) };
1171
+ if (Object.is(n, r.value) && o.text === r.cell.text) return e;
1162
1172
  const a = e.pages.map((s, i) => {
1163
- const c = s.components.map((l, d) => So(e, l, i, d, r, n));
1173
+ const c = s.components.map((l, d) => kn(e, l, i, d, r, o));
1164
1174
  return c.every((l, d) => l === s.components[d]) ? s : { ...s, components: c };
1165
1175
  });
1166
1176
  return { ...e, pages: a };
1167
1177
  }
1168
- function Mt(e) {
1178
+ function xt(e) {
1169
1179
  const t = [];
1170
- for (const r of e.template.pages) for (const o of r.components)
1171
- o.kind === "list" && (t.push(o.tree ? { ...o, rowKey: o.tree.idField } : o), o.detail && t.push({ ...o.detail, relation: { detail: o.detail, parentRows: e.datasets[o.dataset] ?? [] } }));
1180
+ for (const r of e.template.pages) for (const n of r.components)
1181
+ n.kind === "list" && (t.push(n.tree ? { ...n, rowKey: n.tree.idField } : n), n.detail && t.push({ ...n.detail, relation: { detail: n.detail, parentRows: e.datasets[n.dataset] ?? [] } }));
1172
1182
  return t;
1173
1183
  }
1174
- function D(e) {
1184
+ function B(e) {
1175
1185
  return JSON.stringify([e.sourceScope, e.datasetId]);
1176
1186
  }
1177
- function De(e) {
1187
+ function Be(e) {
1178
1188
  return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
1179
1189
  }
1180
- function St(e) {
1190
+ function Ct(e) {
1181
1191
  const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
1182
- return e.forEach((o, n) => {
1183
- for (const a of Mt(o)) {
1192
+ return e.forEach((n, o) => {
1193
+ for (const a of xt(n)) {
1184
1194
  if (!a.rowKey) continue;
1185
1195
  const s = a.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
1186
- (o.datasets[a.dataset] ?? []).forEach((c, l) => {
1196
+ (n.datasets[a.dataset] ?? []).forEach((c, l) => {
1187
1197
  if (s && !i.has(JSON.stringify(c[s.detail.foreignKey]))) return;
1188
1198
  const d = c[a.rowKey];
1189
1199
  if (typeof d != "string" && typeof d != "number") return;
1190
- const f = `${n}:${a.dataset}:${l}:${a.rowKey}`;
1200
+ const f = `${o}:${a.dataset}:${l}:${a.rowKey}`;
1191
1201
  if (r.has(f)) return;
1192
1202
  r.add(f);
1193
- const u = De({ sourceScope: o.sourceScope, datasetId: a.dataset, rowKey: d }), h = t.get(u) ?? [];
1194
- h.push({ partIndex: n, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(u, h);
1203
+ const u = Be({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: d }), h = t.get(u) ?? [];
1204
+ h.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(u, h);
1195
1205
  });
1196
1206
  }
1197
- }), (o) => {
1198
- const n = t.get(De(o));
1199
- if (!n?.length) throw new M("missing");
1200
- if (new Set(n.map((a) => `${a.partIndex}:${a.dataset}`)).size !== n.length) throw new M("conflict");
1201
- return n;
1207
+ }), (n) => {
1208
+ const o = t.get(Be(n));
1209
+ if (!o?.length) throw new M("missing");
1210
+ if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new M("conflict");
1211
+ return o;
1202
1212
  };
1203
1213
  }
1204
- function xt(e, t) {
1205
- const r = e.map((n) => ({ ...n, datasets: { ...n.datasets } })), o = /* @__PURE__ */ new Set();
1206
- for (const { row: n, field: a, value: s } of t) {
1207
- const i = r[n.partIndex], c = JSON.stringify([n.partIndex, n.dataset]);
1208
- o.has(c) || (i.datasets[n.dataset] = [...i.datasets[n.dataset]], o.add(c)), i.datasets[n.dataset][n.rowIndex] = { ...i.datasets[n.dataset][n.rowIndex], [a]: s };
1214
+ function kt(e, t) {
1215
+ const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
1216
+ for (const { row: o, field: a, value: s } of t) {
1217
+ const i = r[o.partIndex], c = JSON.stringify([o.partIndex, o.dataset]);
1218
+ n.has(c) || (i.datasets[o.dataset] = [...i.datasets[o.dataset]], n.add(c)), i.datasets[o.dataset][o.rowIndex] = { ...i.datasets[o.dataset][o.rowIndex], [a]: s };
1209
1219
  }
1210
- for (const n of o) {
1211
- const [a, s] = JSON.parse(n);
1212
- Wt(e[a].datasets[s], r[a].datasets[s]);
1220
+ for (const o of n) {
1221
+ const [a, s] = JSON.parse(o);
1222
+ zt(e[a].datasets[s], r[a].datasets[s]);
1213
1223
  }
1214
1224
  return r;
1215
1225
  }
1216
- function xo(e, t, r) {
1217
- const o = [], n = /* @__PURE__ */ new Set();
1226
+ function Tn(e, t, r) {
1227
+ const n = [], o = /* @__PURE__ */ new Set();
1218
1228
  return e.forEach((a, s) => {
1219
- for (const i of Mt(a))
1220
- t.has(D({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
1229
+ for (const i of xt(a))
1230
+ t.has(B({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
1221
1231
  const d = { partIndex: s, dataset: i.dataset, rowIndex: l, row: c, binding: i };
1222
1232
  for (const [f, u] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
1223
1233
  if (!f || u === void 0) continue;
1224
1234
  const h = `${s}:${i.dataset}:${l}:${f}`;
1225
- n.has(h) || (n.add(h), o.push({ row: d, field: f, value: u }));
1235
+ o.has(h) || (o.add(h), n.push({ row: d, field: f, value: u }));
1226
1236
  }
1227
1237
  });
1228
- }), o;
1238
+ }), n;
1229
1239
  }
1230
- function Co(e, t, r) {
1240
+ function Pn(e, t, r) {
1231
1241
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
1232
- const o = new Set(t.edits.flatMap((n) => n.source ? [D(n.source)] : []));
1233
- return Ct(e, new Map([...o].map((n) => [n, r])));
1242
+ const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
1243
+ return Tt(e, new Map([...n].map((o) => [o, r])));
1234
1244
  }
1235
- function Ct(e, t) {
1245
+ function Tt(e, t) {
1236
1246
  if (!t.size) return e;
1237
1247
  function r(a) {
1238
- const s = a.datasetId && t.get(D({ ...a, datasetId: a.datasetId }));
1248
+ const s = a.datasetId && t.get(B({ ...a, datasetId: a.datasetId }));
1239
1249
  return !s || (s.revision === void 0 || Object.is(s.revision, a.revision)) && (s.sourceToken === void 0 || s.sourceToken === a.sourceToken) ? a : { ...a, ...s.revision !== void 0 ? { revision: s.revision } : {}, ...s.sourceToken !== void 0 ? { sourceToken: s.sourceToken } : {} };
1240
1250
  }
1241
- function o(a) {
1251
+ function n(a) {
1242
1252
  const s = a.map((i) => {
1243
1253
  const c = i.table?.source ? r(i.table.source) : void 0, l = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, d = i.grid?.cells.map((u) => {
1244
1254
  const h = u.map((m) => {
1245
1255
  if (!m) return m;
1246
- const v = m.source ? r(m.source) : void 0, y = m.children ? o(m.children) : void 0;
1256
+ const v = m.source ? r(m.source) : void 0, y = m.children ? n(m.children) : void 0;
1247
1257
  return v === m.source && y === m.children ? m : { ...m, source: v, children: y };
1248
1258
  });
1249
1259
  return h.some((m, v) => m !== u[v]) ? h : u;
@@ -1252,32 +1262,32 @@ function Ct(e, t) {
1252
1262
  });
1253
1263
  return s.some((i, c) => i !== a[c]) ? s : a;
1254
1264
  }
1255
- const n = e.pages.map((a) => {
1256
- const s = o(a.components);
1265
+ const o = e.pages.map((a) => {
1266
+ const s = n(a.components);
1257
1267
  return s !== a.components ? { ...a, components: s } : a;
1258
1268
  });
1259
- return n.some((a, s) => a !== e.pages[s]) ? { ...e, pages: n } : e;
1269
+ return o.some((a, s) => a !== e.pages[s]) ? { ...e, pages: o } : e;
1260
1270
  }
1261
- function ko(e) {
1271
+ function En(e) {
1262
1272
  return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
1263
1273
  }
1264
- function Be(e) {
1274
+ function Ge(e) {
1265
1275
  const t = e.table;
1266
- return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : ko(e.address);
1276
+ return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : En(e.address);
1267
1277
  }
1268
- function Eo(e, t) {
1278
+ function Rn(e, t) {
1269
1279
  if (!t.length) return e;
1270
- const r = new Map(t.map((c) => [Be(c), c])), o = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), n = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = H(e);
1280
+ const r = new Map(t.map((c) => [Ge(c), c])), n = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), o = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = D(e);
1271
1281
  function s(c, l, d) {
1272
1282
  const f = c.grid;
1273
- if (!f || !n.has(`${l}:${d}`) && !o.has(c.table?.id ?? "")) return c;
1283
+ if (!f || !o.has(`${l}:${d}`) && !n.has(c.table?.id ?? "")) return c;
1274
1284
  const u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
1275
- for (const m of oe(f, c.widthMm, c.heightMm).cells) {
1285
+ for (const m of re(f, c.widthMm, c.heightMm).cells) {
1276
1286
  const v = h.get(m.ri) ?? 0;
1277
1287
  h.set(m.ri, v + 1);
1278
- const y = a({ pageIndex: l, componentIndex: d, rowIndex: m.ri, columnIndex: m.ci }), g = y && r.get(Be(y));
1288
+ const y = a({ pageIndex: l, componentIndex: d, rowIndex: m.ri, columnIndex: m.ci }), g = y && r.get(Ge(y));
1279
1289
  if (!g || !y.editable) continue;
1280
- const w = u.get(m.ri) ?? [...f.cells[m.ri]], x = _(y, g.value);
1290
+ const w = u.get(m.ri) ?? [...f.cells[m.ri]], x = q(y, g.value);
1281
1291
  Object.is(y.value, g.value) && x === y.cell.text || (w[v] = { ...m.cell, value: g.value, text: x, rawText: x }, u.set(m.ri, w));
1282
1292
  }
1283
1293
  return u.size ? { ...c, grid: { ...f, cells: f.cells.map((m, v) => u.get(v) ?? m) } } : c;
@@ -1293,55 +1303,55 @@ function F(e) {
1293
1303
  if (t) return JSON.stringify([t.sourceScope, t.datasetId, t.rowKey, t.field]);
1294
1304
  const r = e.table;
1295
1305
  if (r?.columnKey !== void 0) return JSON.stringify([r.id, r.role, r.rowIndex, r.columnKey]);
1296
- const o = e.address;
1297
- return JSON.stringify([o.pageIndex, o.componentIndex, o.rowIndex, o.columnIndex]);
1306
+ const n = e.address;
1307
+ return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
1298
1308
  }
1299
- function pn(e, t, r) {
1309
+ function bo(e, t, r) {
1300
1310
  if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new M("missing");
1301
1311
  if (t.length > 1e4) throw new M("limit");
1302
- const o = /* @__PURE__ */ new Set(), n = H(e), a = t.map(({ address: s, value: i }) => {
1303
- const c = n(s);
1312
+ const n = /* @__PURE__ */ new Set(), o = D(e), a = t.map(({ address: s, value: i }) => {
1313
+ const c = o(s);
1304
1314
  if (!c) throw new M("missing");
1305
- const l = q(c, i), d = F(l);
1306
- if (o.has(d)) throw new M("duplicate");
1307
- return o.add(d), l;
1315
+ const l = U(c, i), d = F(l);
1316
+ if (n.has(d)) throw new M("duplicate");
1317
+ return n.add(d), l;
1308
1318
  });
1309
1319
  return { requestId: r, edits: a };
1310
1320
  }
1311
- function wn(e, t) {
1321
+ function vo(e, t) {
1312
1322
  if (t.edits.length > 1e4) throw new M("limit");
1313
- const r = H(e), o = /* @__PURE__ */ new Set(), n = t.edits.map((a) => {
1323
+ const r = D(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
1314
1324
  const s = r(a.address);
1315
1325
  if (!s) throw new M("missing");
1316
1326
  const i = F(a);
1317
- if (o.has(i)) throw new M("duplicate");
1318
- if (o.add(i), Ie(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
1319
- return q(s, a.value);
1327
+ if (n.has(i)) throw new M("duplicate");
1328
+ if (n.add(i), Ie(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
1329
+ return U(s, a.value);
1320
1330
  });
1321
- return Eo(e, n);
1331
+ return Rn(e, o);
1322
1332
  }
1323
- function yn(e) {
1333
+ function Mo(e) {
1324
1334
  const t = /* @__PURE__ */ new Map();
1325
1335
  for (const r of e) {
1326
- const o = F(r), n = t.get(o), a = n ? { ...r, previousValue: n.previousValue, previousText: n.previousText } : { ...r };
1327
- Object.is(a.previousValue, a.value) ? t.delete(o) : t.set(o, a);
1336
+ const n = F(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
1337
+ Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
1328
1338
  }
1329
1339
  return [...t.values()];
1330
1340
  }
1331
- function kt(e) {
1332
- const t = /* @__PURE__ */ new Map(), r = H(e);
1333
- return e.pages.forEach((o, n) => o.components.forEach((a, s) => {
1341
+ function Pt(e) {
1342
+ const t = /* @__PURE__ */ new Map(), r = D(e);
1343
+ return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
1334
1344
  if (!(!a.grid || a.table?.role !== "body"))
1335
1345
  for (let i = 0; i < a.grid.cells.length; i++) for (let c = 0; c < a.table.columnKeys.length; c++) {
1336
- const l = r({ pageIndex: n, componentIndex: s, rowIndex: i, columnIndex: c });
1346
+ const l = r({ pageIndex: o, componentIndex: s, rowIndex: i, columnIndex: c });
1337
1347
  l?.source && l.editable && t.set(F(l), l);
1338
1348
  }
1339
1349
  })), t;
1340
1350
  }
1341
- function bn(e, t, r) {
1342
- const o = kt(e), n = H(e);
1351
+ function So(e, t, r) {
1352
+ const n = Pt(e), o = D(e);
1343
1353
  return t.map((a) => {
1344
- const s = a.source ? o.get(F(a)) : n(a.address);
1354
+ const s = a.source ? n.get(F(a)) : o(a.address);
1345
1355
  if (!s || F(s) !== F(a)) throw new M("missing");
1346
1356
  return { address: { ...s.address }, value: a[r] };
1347
1357
  });
@@ -1354,7 +1364,7 @@ function ee(e, t) {
1354
1364
  if (!r || r.get || r.set) throw new M("conflict");
1355
1365
  return r.value;
1356
1366
  }
1357
- function Tt(e) {
1367
+ function Fe(e) {
1358
1368
  if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new M("conflict");
1359
1369
  const t = Object.getPrototypeOf(e);
1360
1370
  if (Array.isArray(e) && (t !== Array.prototype || Object.keys(e).length !== e.length)) throw new M("conflict");
@@ -1365,10 +1375,10 @@ function Tt(e) {
1365
1375
  if (e instanceof Date || Array.isArray(e) && !/^(0|[1-9]\d*)$/.test(r)) throw new M("conflict");
1366
1376
  }
1367
1377
  }
1368
- function Pt(e, t, r, o, n) {
1369
- if (Et(o, n), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1378
+ function Rt(e, t, r, n, o) {
1379
+ if (Et(n, o), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1370
1380
  if (e === null || typeof e != "object") return;
1371
- if (Tt(e), r.has(e)) throw new M("conflict");
1381
+ if (Fe(e), r.has(e)) throw new M("conflict");
1372
1382
  r.add(e);
1373
1383
  const a = Object.keys(e), s = a.map((i) => ee(e, i));
1374
1384
  t.push({
@@ -1379,139 +1389,139 @@ function Pt(e, t, r, o, n) {
1379
1389
  ...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
1380
1390
  ...Array.isArray(e) ? { length: e.length } : {}
1381
1391
  });
1382
- for (const i of s) Pt(i, t, r, o, n + 1);
1392
+ for (const i of s) Rt(i, t, r, n, o + 1);
1383
1393
  r.delete(e);
1384
1394
  }
1385
- function To(e) {
1386
- const { object: t, keys: r, values: o } = e;
1387
- if (Tt(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
1388
- const n = Object.keys(t);
1389
- return n.length === r.length && r.every((a, s) => n[s] === a && Object.is(ee(t, a), o[s]));
1395
+ function $n(e) {
1396
+ const { object: t, keys: r, values: n } = e;
1397
+ if (Fe(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
1398
+ const o = Object.keys(t);
1399
+ return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(ee(t, a), n[s]));
1390
1400
  }
1391
- function Po(e) {
1401
+ function In(e) {
1392
1402
  const t = [];
1393
- return Pt(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
1403
+ return Rt(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
1394
1404
  try {
1395
- return t.every(To);
1405
+ return t.every($n);
1396
1406
  } catch {
1397
1407
  return !1;
1398
1408
  }
1399
1409
  };
1400
1410
  }
1401
- function ge(e, t, r) {
1402
- if (Et(t, r), e === null || typeof e != "object") return e;
1411
+ function te(e, t, r, n = !1) {
1412
+ if (Et(t, r), n) {
1413
+ if (typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1414
+ e !== null && typeof e == "object" && Fe(e);
1415
+ }
1416
+ if (e === null || typeof e != "object") return e;
1403
1417
  if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
1404
1418
  if (Array.isArray(e)) {
1405
1419
  const o = [];
1406
- for (let n = 0; n < e.length; n++) o[n] = ge(ee(e, String(n)), t, r + 1);
1420
+ for (let a = 0; a < e.length; a++) o[a] = te(ee(e, String(a)), t, r + 1, n);
1407
1421
  return o;
1408
1422
  }
1409
- return Object.fromEntries(Object.keys(e).map((o) => [o, ge(ee(e, o), t, r + 1)]));
1423
+ return Object.fromEntries(Object.keys(e).map((o) => [o, te(ee(e, o), t, r + 1, n)]));
1424
+ }
1425
+ function Fn(e) {
1426
+ return te(e, { nodes: 0 }, 0, !0);
1410
1427
  }
1411
- function Ro(e) {
1412
- const t = ge(e, { nodes: 0 }, 0);
1413
- for (const r of t) for (const o of Object.values(r.datasets)) Jt(o);
1428
+ function On(e) {
1429
+ const t = te(e, { nodes: 0 }, 0);
1430
+ for (const r of t) for (const n of Object.values(r.datasets)) _t(n);
1414
1431
  return t;
1415
1432
  }
1416
- async function $o(e, t, r = {}) {
1417
- return (await Rt(e, t, r)).plan;
1433
+ async function An(e, t, r = {}) {
1434
+ return (await $t(e, t, r)).plan;
1418
1435
  }
1419
- async function Rt(e, t, r = {}) {
1420
- const o = [], n = { chartComponents: 0 }, a = { ...r, knownTotalPages: void 0 };
1421
- for (const s of ft(e, t, a, n))
1422
- o.push(s), o.length % 8 === 0 && await new Promise((i) => setTimeout(i, 0));
1423
- if (r.signal?.aborted) {
1424
- const s = new Error("报表重算已取消");
1425
- throw s.name = "AbortError", s;
1426
- }
1427
- return { plan: { schemaVersion: te, ...ae(e) ? { requiresRecalculation: !0 } : {}, pages: o }, ...n };
1436
+ async function $t(e, t, r = {}) {
1437
+ return ht(e, t, { ...r, knownTotalPages: void 0 });
1428
1438
  }
1429
- const pe = /* @__PURE__ */ new WeakMap();
1430
- function vn(e) {
1431
- return pe.get(e);
1439
+ const ge = /* @__PURE__ */ new WeakMap();
1440
+ function xo(e) {
1441
+ return ge.get(e);
1432
1442
  }
1433
- function U(e) {
1443
+ function X(e) {
1434
1444
  if (e?.aborted) {
1435
1445
  const t = new Error("报表重算已取消");
1436
1446
  throw t.name = "AbortError", t;
1437
1447
  }
1438
1448
  }
1439
- function $t(e, t) {
1449
+ function It(e, t) {
1440
1450
  return e[t] === void 0 ? "" : e[t];
1441
1451
  }
1442
- function Io(e, t) {
1452
+ function Nn(e, t) {
1443
1453
  if (t.edits.length > 1e4) throw new M("limit");
1444
- const r = H(e), o = /* @__PURE__ */ new Set(), n = [], a = t.edits.map((s) => {
1454
+ const r = D(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
1445
1455
  const i = r(s.address);
1446
1456
  if (!i?.source) throw new M("missing");
1447
1457
  const c = F(s);
1448
- if (o.has(c)) throw new M("duplicate");
1449
- if (o.add(c), Ie(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new M("conflict");
1450
- return n.push(i), q(i, s.value);
1458
+ if (n.has(c)) throw new M("duplicate");
1459
+ if (n.add(c), Ie(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new M("conflict");
1460
+ return o.push(i), U(i, s.value);
1451
1461
  });
1452
- return { batch: { requestId: t.requestId, edits: a }, contexts: n };
1453
- }
1454
- function Fo(e, t) {
1455
- const r = St(e);
1456
- return t.flatMap((o) => {
1457
- if (!o.source) throw new M("missing");
1458
- return r(o.source).map((n) => {
1459
- if (!Object.is($t(n.row, o.source.field), o.previousValue)) throw new M("conflict");
1460
- if (n.binding.rowKey === o.source.field) throw new M("readonly");
1461
- return { row: n, field: o.source.field, value: o.value };
1462
+ return { batch: { requestId: t.requestId, edits: a }, contexts: o };
1463
+ }
1464
+ function jn(e, t) {
1465
+ const r = Ct(e);
1466
+ return t.flatMap((n) => {
1467
+ if (!n.source) throw new M("missing");
1468
+ return r(n.source).map((o) => {
1469
+ if (!Object.is(It(o.row, n.source.field), n.previousValue)) throw new M("conflict");
1470
+ if (o.binding.rowKey === n.source.field) throw new M("readonly");
1471
+ return { row: o, field: n.source.field, value: n.value };
1462
1472
  });
1463
1473
  });
1464
1474
  }
1465
1475
  function fe(e, t, r) {
1466
- const o = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
1467
- return o.cell = { ...e.cell, value: o.value, text: _(o, o.value) }, o;
1476
+ const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
1477
+ return n.cell = { ...e.cell, value: n.value, text: q(n, n.value) }, n;
1468
1478
  }
1469
- function Oo(e, t, r) {
1479
+ function Kn(e, t, r) {
1470
1480
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
1471
- const o = new Set(t.edits.flatMap((n) => n.source ? [D(n.source)] : []));
1472
- return xt(e, xo(e, o, r));
1481
+ const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
1482
+ return kt(e, Tn(e, n, r));
1473
1483
  }
1474
- function Ao(e, t, r) {
1475
- const o = new Set(t.edits.map((n) => D(n.source)));
1476
- for (const n of o) e.set(n, {
1477
- ...e.get(n),
1484
+ function Ln(e, t, r) {
1485
+ const n = new Set(t.edits.map((o) => B(o.source)));
1486
+ for (const o of n) e.set(o, {
1487
+ ...e.get(o),
1478
1488
  ...r.revision !== void 0 ? { revision: r.revision } : {},
1479
1489
  ...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {}
1480
1490
  });
1481
- return o;
1491
+ return n;
1482
1492
  }
1483
- function It(e, t) {
1493
+ function Ft(e, t) {
1484
1494
  let r = t.parts;
1485
- const o = t.rebuild, n = [...t.validationFormulas ?? []];
1486
- let a = Po(r), s = e, i;
1495
+ const n = t.rebuild, o = [...t.validationFormulas ?? []];
1496
+ let a = In(r), s = e, i;
1487
1497
  const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
1488
1498
  function d(h) {
1489
1499
  if (h !== s) throw new M("conflict");
1490
1500
  if (i) return i;
1491
1501
  if (!a?.()) throw new M("conflict");
1492
- return Ro(r);
1502
+ return On(r);
1493
1503
  }
1494
1504
  async function f(h, m, v, y = {}) {
1495
- U(y.signal), m = { requestId: m.requestId, edits: m.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, v = v.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0, cell: { ...b.cell } })), await new Promise((b) => setTimeout(b, 0)), U(y.signal);
1496
- const g = d(h), w = xt(g, Fo(g, m.edits)), x = Ct(await o(w, y.signal), l);
1497
- U(y.signal);
1498
- let P = !1, E = [], O = "allow", A = !1;
1505
+ X(y.signal), m = { requestId: m.requestId, edits: m.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, v = v.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0, cell: { ...b.cell } })), await new Promise((b) => setTimeout(b, 0)), X(y.signal);
1506
+ const g = d(h), w = kt(g, jn(g, m.edits)), x = Tt(await n(w, y.signal), l);
1507
+ X(y.signal);
1508
+ let E = !1, k = [], O = "allow", A = !1;
1499
1509
  function p(b) {
1500
- return A = !0, E = Object.freeze(co(w, b, y.signal, n).map((S) => Object.freeze({ ...S }))), A = !1, O = b.warningPolicy ?? "allow", E;
1510
+ return A = !0, k = Object.freeze(fn(w, b, y.signal, o).map((S) => Object.freeze({ ...S }))), A = !1, O = b.warningPolicy ?? "allow", k;
1501
1511
  }
1502
1512
  return y.validation && p(y.validation), { plan: x, get validationIssues() {
1503
- return E;
1513
+ return k;
1504
1514
  }, validate: p, commit(b) {
1505
- if (U(y.signal), P || s !== h) throw new M("conflict");
1515
+ if (X(y.signal), E || s !== h) throw new M("conflict");
1506
1516
  if (b?.conflicts?.length) throw new M("conflict");
1507
1517
  if (A) throw new Error("候选规则校验未完成,不能提交");
1508
- io(E, O);
1509
- const S = Oo(w, m, b), T = Co(x, m, b);
1518
+ un(k, O);
1519
+ const S = Kn(w, m, b), P = Pn(x, m, b);
1510
1520
  if (b) {
1511
- const k = Ao(l, m, b);
1512
- for (const [R, j] of c) k.has(D(j.source)) && c.set(R, fe(j, j.value, b));
1521
+ const T = Ln(l, m, b);
1522
+ for (const [R, L] of c) T.has(B(L.source)) && c.set(R, fe(L, L.value, b));
1513
1523
  }
1514
- return v.forEach((k, R) => c.set(F(k), fe(k, m.edits[R].value, b))), P = !0, i = S, r = void 0, a = void 0, s = T, pe.set(s, u), s;
1524
+ return v.forEach((T, R) => c.set(F(T), fe(T, m.edits[R].value, b))), E = !0, i = S, r = void 0, a = void 0, s = P, ge.set(s, u), s;
1515
1525
  } };
1516
1526
  }
1517
1527
  const u = {
@@ -1519,194 +1529,194 @@ function It(e, t) {
1519
1529
  return s;
1520
1530
  },
1521
1531
  async prepare(h, m, v) {
1522
- const y = Io(h, m);
1532
+ const y = Nn(h, m);
1523
1533
  return f(h, y.batch, y.contexts, v);
1524
1534
  },
1525
1535
  async prepareHistory(h, m, v, y, g) {
1526
1536
  if (!y.trim() || m.length > 1e4) throw new M("limit");
1527
- const w = d(h), x = St(w), P = kt(h), E = /* @__PURE__ */ new Set(), A = m.map((S) => {
1537
+ const w = d(h), x = Ct(w), E = Pt(h), k = /* @__PURE__ */ new Set(), A = m.map((S) => {
1528
1538
  if (!S.source) throw new M("missing");
1529
- const T = F(S);
1530
- if (E.has(T)) throw new M("duplicate");
1531
- E.add(T);
1532
- const k = P.get(T) ?? c.get(T);
1533
- if (!k?.source) throw new M("missing");
1534
- const R = x(k.source)[0];
1535
- return fe(k, $t(R.row, k.source.field));
1536
- }).map((S, T) => ({ context: S, edit: q(S, m[T][v]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), p = { requestId: y, edits: A.map(({ edit: S }) => S) }, b = A.map(({ context: S }) => S);
1539
+ const P = F(S);
1540
+ if (k.has(P)) throw new M("duplicate");
1541
+ k.add(P);
1542
+ const T = E.get(P) ?? c.get(P);
1543
+ if (!T?.source) throw new M("missing");
1544
+ const R = x(T.source)[0];
1545
+ return fe(T, It(R.row, T.source.field));
1546
+ }).map((S, P) => ({ context: S, edit: U(S, m[P][v]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), p = { requestId: y, edits: A.map(({ edit: S }) => S) }, b = A.map(({ context: S }) => S);
1537
1547
  return { batch: p, contexts: b, prepared: await f(h, p, b, g) };
1538
1548
  }
1539
1549
  };
1540
- return pe.set(e, u), u;
1550
+ return ge.set(e, u), u;
1541
1551
  }
1542
- function Mn(e) {
1552
+ function Co(e) {
1543
1553
  const t = mt(e.template, e.datasets, e.pagination).plan;
1544
- return It(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, o) => $o(r[0].template, r[0].datasets, { ...e.pagination, signal: o }) });
1554
+ return Ft(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => An(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
1545
1555
  }
1546
- let No = 0;
1547
- function Ko() {
1548
- return `report-${Date.now()}-${++No}`;
1556
+ let Hn = 0;
1557
+ function Dn() {
1558
+ return `report-${Date.now()}-${++Hn}`;
1549
1559
  }
1550
- function Ge(e, t, r) {
1560
+ function We(e, t, r) {
1551
1561
  if (!r?.aborted)
1552
1562
  try {
1553
- const o = e?.({ ...t });
1554
- o && typeof o.then == "function" && Promise.resolve(o).catch(() => {
1563
+ const n = e?.({ ...t });
1564
+ n && typeof n.then == "function" && Promise.resolve(n).catch(() => {
1555
1565
  });
1556
1566
  } catch {
1557
1567
  }
1558
1568
  }
1559
- function jo(e) {
1560
- const t = e.taskId ?? Ko(), r = (o, n, a) => {
1561
- Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: o, status: n, ...a === void 0 ? {} : { reportId: a } }, e.signal);
1569
+ function Bn(e) {
1570
+ const t = e.taskId ?? Dn(), r = (n, o, a) => {
1571
+ We(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: o, ...a === void 0 ? {} : { reportId: a } }, e.signal);
1562
1572
  };
1563
1573
  return {
1564
1574
  taskId: t,
1565
- progress(o, n, a) {
1566
- Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: o, status: "started", completed: n, total: a }, e.signal);
1575
+ progress(n, o, a) {
1576
+ We(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
1567
1577
  },
1568
- async run(o, n, a) {
1569
- r(o, "started", a);
1578
+ async run(n, o, a) {
1579
+ r(n, "started", a);
1570
1580
  try {
1571
- const s = await n();
1572
- return r(o, "completed", a), s;
1581
+ const s = await o();
1582
+ return r(n, "completed", a), s;
1573
1583
  } catch (s) {
1574
- throw r(o, "failed", a), s;
1584
+ throw r(n, "failed", a), s;
1575
1585
  }
1576
1586
  },
1577
- runSync(o, n, a) {
1578
- r(o, "started", a);
1587
+ runSync(n, o, a) {
1588
+ r(n, "started", a);
1579
1589
  try {
1580
- const s = n();
1581
- return r(o, "completed", a), s;
1590
+ const s = o();
1591
+ return r(n, "completed", a), s;
1582
1592
  } catch (s) {
1583
- throw r(o, "failed", a), s;
1593
+ throw r(n, "failed", a), s;
1584
1594
  }
1585
1595
  }
1586
1596
  };
1587
1597
  }
1588
- function Ft(e) {
1598
+ function Ot(e) {
1589
1599
  if (!e || typeof e != "object" || Array.isArray(e)) return !1;
1590
- const t = e, r = (o) => typeof o == "string" && o.trim().length > 0 && o.length <= 256;
1600
+ const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
1591
1601
  return !r(t.datasetId) || !r(t.field) || t.tableId !== void 0 && !r(t.tableId) || t.reportScope !== void 0 && (typeof t.reportScope != "string" || !t.reportScope.trim() || t.reportScope.length > 4096) ? !1 : t.rowKey === void 0 ? !0 : typeof t.rowKey == "string" ? t.rowKey.trim().length > 0 && t.rowKey.length <= 1024 : typeof t.rowKey == "number" && Number.isFinite(t.rowKey);
1592
1602
  }
1593
- function Lo(e) {
1603
+ function Gn(e) {
1594
1604
  return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
1595
1605
  }
1596
- function Ho(e) {
1597
- return e.target !== void 0 && !Ft(e.target) ? !1 : e.valueState === void 0 || Lo(e.valueState) && e.target !== void 0;
1606
+ function Wn(e) {
1607
+ return e.target !== void 0 && !Ot(e.target) ? !1 : e.valueState === void 0 || Gn(e.valueState) && e.target !== void 0;
1598
1608
  }
1599
- function Sn(e, t) {
1600
- if (Ze([], e), !Ft(t)) throw new Error("数据说明目标无效");
1601
- const r = e.fields.find((n) => n.field === t.field);
1609
+ function ko(e, t) {
1610
+ if (et([], e), !Ot(t)) throw new Error("数据说明目标无效");
1611
+ const r = e.fields.find((o) => o.field === t.field);
1602
1612
  if (!r) throw new Error("数据说明字段未在契约中声明");
1603
- const o = [];
1604
- return r.description && o.push({ code: "field-definition", severity: "info", message: r.description, target: { ...t } }), r.calculation && o.push({ code: "field-calculation", severity: "info", message: r.calculation.description, target: { ...t } }), o;
1613
+ const n = [];
1614
+ return r.description && n.push({ code: "field-definition", severity: "info", message: r.description, target: { ...t } }), r.calculation && n.push({ code: "field-calculation", severity: "info", message: r.calculation.description, target: { ...t } }), n;
1605
1615
  }
1606
- function Ot(e, t, r = {}) {
1607
- const o = /* @__PURE__ */ new Map();
1616
+ function At(e, t, r = {}) {
1617
+ const n = /* @__PURE__ */ new Map();
1608
1618
  for (const a of e.pages) for (const s of a.components) {
1609
1619
  if (s.kind !== "list" || s.tree?.input !== "nested") continue;
1610
- const i = o.get(s.dataset);
1620
+ const i = n.get(s.dataset);
1611
1621
  if (i && (i.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
1612
- o.set(s.dataset, s.tree);
1622
+ n.set(s.dataset, s.tree);
1613
1623
  }
1614
- if (!o.size) return t;
1615
- const n = { ...t };
1616
- for (const [a, s] of o) {
1624
+ if (!n.size) return t;
1625
+ const o = { ...t };
1626
+ for (const [a, s] of n) {
1617
1627
  const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
1618
- n[a] = Xe(t[a] ?? [], { ...s, maxRows: i }, r.signal);
1628
+ o[a] = Ye(t[a] ?? [], { ...s, maxRows: i }, r.signal);
1619
1629
  }
1620
- return n;
1630
+ return o;
1621
1631
  }
1622
- function xn(e, t, r = {}) {
1623
- return Object.values(Ot(e, t, r)).reduce((o, n) => o + n.length, 0);
1632
+ function To(e, t, r = {}) {
1633
+ return Object.values(At(e, t, r)).reduce((n, o) => n + o.length, 0);
1624
1634
  }
1625
- function Cn(e, t, r) {
1626
- const o = ur(r), n = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
1627
- if (!n || n.kind !== "list" || !n.tree) return o;
1628
- const a = o.items, s = n.tree.childrenField ?? "children";
1629
- return { ...o, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
1635
+ function Po(e, t, r) {
1636
+ const n = mr(r), o = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
1637
+ if (!o || o.kind !== "list" || !o.tree) return n;
1638
+ const a = n.items, s = o.tree.childrenField ?? "children";
1639
+ return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
1630
1640
  }
1631
- function At(e, t) {
1641
+ function Nt(e, t) {
1632
1642
  return JSON.stringify([e, t]);
1633
1643
  }
1634
- function Nt(e, t, r) {
1635
- return r === void 0 ? At(e, t) : JSON.stringify(["shared", r]);
1644
+ function jt(e, t, r) {
1645
+ return r === void 0 ? Nt(e, t) : JSON.stringify(["shared", r]);
1636
1646
  }
1637
1647
  function Kt(e, t, r) {
1638
- return e.map((o) => {
1639
- const n = o.table ? {
1640
- ...o.table,
1641
- id: r(o.table.id),
1642
- ...o.table.source ? { source: { ...o.table.source, sourceScope: t } } : {}
1643
- } : void 0, a = o.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
1648
+ return e.map((n) => {
1649
+ const o = n.table ? {
1650
+ ...n.table,
1651
+ id: r(n.table.id),
1652
+ ...n.table.source ? { source: { ...n.table.source, sourceScope: t } } : {}
1653
+ } : void 0, a = n.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
1644
1654
  ...i,
1645
1655
  ...i.source ? { source: { ...i.source, sourceScope: t } } : {},
1646
1656
  ...i.children ? { children: Kt(i.children, t, r) } : {}
1647
1657
  }));
1648
- return n || a ? {
1649
- ...o,
1650
- ...n ? { table: n } : {},
1651
- ...a ? { grid: { ...o.grid, cells: a } } : {}
1652
- } : o;
1658
+ return o || a ? {
1659
+ ...n,
1660
+ ...o ? { table: o } : {},
1661
+ ...a ? { grid: { ...n.grid, cells: a } } : {}
1662
+ } : n;
1653
1663
  });
1654
1664
  }
1655
- function we(e) {
1656
- return ne(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Ce, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
1665
+ function pe(e) {
1666
+ return oe(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Ce, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
1657
1667
  }
1658
- function Do(e, t) {
1668
+ function Vn(e, t) {
1659
1669
  if (!e.repeat) return !1;
1660
1670
  const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
1661
1671
  return Array.isArray(r) && r.length === 0;
1662
1672
  }
1663
- function Bo(e) {
1664
- const t = (r) => r.grid?.cells.reduce((o, n) => o + n.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
1665
- return e.pages.reduce((r, o) => r + o.components.reduce((n, a) => n + t(a), 0), 0);
1673
+ function Jn(e) {
1674
+ const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
1675
+ return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
1666
1676
  }
1667
- function ye(e, t) {
1677
+ function we(e, t) {
1668
1678
  return e === void 0 ? void 0 : e - t;
1669
1679
  }
1670
1680
  function me(e, t) {
1671
1681
  return e === void 0 ? t : Math.max(1, Math.min(e, t ?? e));
1672
1682
  }
1673
- function jt(e, t, r, o, n) {
1674
- ne(e?.maxChartComponents);
1675
- const a = ye(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
1676
- if (a !== void 0 && a < 1 && r.pages.length && !Do(r, o)) throw new G(0, 1);
1677
- if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new Y(s, 1);
1683
+ function Lt(e, t, r, n, o) {
1684
+ oe(e?.maxChartComponents);
1685
+ const a = we(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
1686
+ if (a !== void 0 && a < 1 && r.pages.length && !Vn(r, n)) throw new W(0, 1);
1687
+ if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new Q(s, 1);
1678
1688
  return {
1679
1689
  ...e,
1680
- signal: n ?? e?.signal,
1690
+ signal: o ?? e?.signal,
1681
1691
  maxPages: me(a, e?.maxPages),
1682
- maxCells: me(ye(t.maxCells, t.usedCells), e?.maxCells),
1692
+ maxCells: me(we(t.maxCells, t.usedCells), e?.maxCells),
1683
1693
  maxChartComponents: me(s, e?.maxChartComponents)
1684
1694
  };
1685
1695
  }
1686
- function Lt(e, t) {
1687
- const r = Bo(t.plan), o = ye(e.maxCells, e.usedCells);
1688
- if (o !== void 0 && r > o) throw new X(o, r);
1696
+ function Ht(e, t) {
1697
+ const r = Jn(t.plan), n = we(e.maxCells, e.usedCells);
1698
+ if (n !== void 0 && r > n) throw new Y(n, r);
1689
1699
  e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
1690
1700
  }
1691
- function Ht(e, t) {
1692
- return e instanceof G && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new G(t.maxPages, t.usedPages + e.actual) : e instanceof X && t.maxCells !== void 0 ? new X(t.maxCells, t.usedCells + e.actual) : e instanceof Y && e.limit === t.maxChartComponents - t.usedChartComponents ? new Y(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
1701
+ function Dt(e, t) {
1702
+ return e instanceof W && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new W(t.maxPages, t.usedPages + e.actual) : e instanceof Y && t.maxCells !== void 0 ? new Y(t.maxCells, t.usedCells + e.actual) : e instanceof Q && e.limit === t.maxChartComponents - t.usedChartComponents ? new Q(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
1693
1703
  }
1694
- function kn(e) {
1704
+ function Eo(e) {
1695
1705
  if (!("mapData" in e)) return e;
1696
- const { load: t, mapData: r, ...o } = e;
1697
- return { ...o, load: async (n) => {
1698
- const a = await t(n);
1699
- $(n.signal);
1706
+ const { load: t, mapData: r, ...n } = e;
1707
+ return { ...n, load: async (o) => {
1708
+ const a = await t(o);
1709
+ $(o.signal);
1700
1710
  try {
1701
- return r(a, n);
1711
+ return r(a, o);
1702
1712
  } catch (s) {
1703
- throw new C("validate", `报表 ${n.reportId} 数据映射失败`, s);
1713
+ throw new C("validate", `报表 ${o.reportId} 数据映射失败`, s);
1704
1714
  }
1705
1715
  } };
1706
1716
  }
1707
1717
  class C extends Error {
1708
- constructor(t, r, o) {
1709
- super(r), this.name = "ReportSourceError", this.code = t, this.cause = o;
1718
+ constructor(t, r, n) {
1719
+ super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
1710
1720
  }
1711
1721
  }
1712
1722
  function de(e) {
@@ -1716,158 +1726,164 @@ function de(e) {
1716
1726
  function $(e) {
1717
1727
  if (e?.aborted) throw de(e);
1718
1728
  }
1719
- function be(e, t) {
1720
- return t ? new Promise((r, o) => {
1721
- const n = () => t.removeEventListener("abort", a), a = () => {
1722
- n(), o(de(t));
1729
+ function ye(e, t) {
1730
+ return t ? new Promise((r, n) => {
1731
+ const o = () => t.removeEventListener("abort", a), a = () => {
1732
+ o(), n(de(t));
1723
1733
  };
1724
1734
  t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
1725
1735
  (s) => {
1726
- n(), r(s);
1736
+ o(), r(s);
1727
1737
  },
1728
1738
  (s) => {
1729
- n(), o(s);
1739
+ o(), n(s);
1730
1740
  }
1731
1741
  );
1732
1742
  }) : Promise.resolve(e);
1733
1743
  }
1734
- function Go(e, t) {
1744
+ function zn(e, t) {
1735
1745
  if (!e || typeof e != "object" || Array.isArray(e))
1736
1746
  throw new C("validate", `报表 ${t} 的数据集应为对象`);
1737
- for (const [r, o] of Object.entries(e))
1738
- if (!Array.isArray(o) || o.some((n) => !n || typeof n != "object" || Array.isArray(n)))
1747
+ for (const [r, n] of Object.entries(e))
1748
+ if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
1739
1749
  throw new C("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
1740
1750
  }
1741
- async function Vo(e, t, r) {
1742
- const { reportId: o, signal: n } = t;
1751
+ async function _n(e, t, r) {
1752
+ const { reportId: n, signal: o } = t;
1743
1753
  try {
1744
- const a = await be(e(t), n);
1745
- $(n);
1746
- const s = sr(a);
1754
+ const a = await ye(e(t), o);
1755
+ $(o);
1756
+ const s = cr(a);
1747
1757
  if (!s.ok)
1748
- throw new C("validate", `报表 ${o} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
1749
- return r.push(...s.warnings.map((i) => `${o}: ${i.path}: ${i.message}`)), a;
1758
+ throw new C("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
1759
+ return r.push(...s.warnings.map((i) => `${n}: ${i.path}: ${i.message}`)), a;
1750
1760
  } catch (a) {
1751
- throw n?.aborted ? de(n) : a instanceof C ? a : a instanceof ir ? new C("validate", `报表 ${o} 模板校验失败:${a.message}`, a) : new C("fetch", `报表 ${o} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1761
+ throw o?.aborted ? de(o) : a instanceof C ? a : a instanceof lr ? new C("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new C("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1752
1762
  }
1753
1763
  }
1754
- async function Wo(e, t, r, o) {
1755
- const n = t.signal;
1764
+ async function qn(e, t, r, n) {
1765
+ const o = t.signal;
1756
1766
  let a;
1757
1767
  try {
1758
- if (e.load) a = await be(e.load(t), n);
1768
+ if (e.load) a = await ye(e.load(t), o);
1759
1769
  else if (e.provider) {
1760
- const s = await be(e.provider.query(t), n);
1761
- $(n), Jo(s, r), a = s.datasets, o?.(r, s);
1770
+ const s = await ye(e.provider.query(t), o);
1771
+ $(o), Un(s, r), a = s.datasets, n?.(r, s);
1762
1772
  } else a = e.datasets ?? {};
1763
1773
  } catch (s) {
1764
- throw n?.aborted ? de(n) : s instanceof C ? s : new C("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1774
+ throw o?.aborted ? de(o) : s instanceof C ? s : new C("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1765
1775
  }
1766
- return $(n), a;
1776
+ return $(o), a;
1767
1777
  }
1768
- function Jo(e, t) {
1778
+ function Un(e, t) {
1769
1779
  if (!e || typeof e != "object" || Array.isArray(e)) throw new C("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
1770
1780
  for (const r of ["revision", "sourceToken"])
1771
1781
  if (e[r] !== void 0 && typeof e[r] != "string") throw new C("validate", `报表 ${t} Provider ${r} 应为字符串`);
1772
1782
  if (e.diagnostics !== void 0 && (!Array.isArray(e.diagnostics) || e.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity))))
1773
1783
  throw new C("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
1774
- if (e.diagnostics?.some((r) => !Ho(r)))
1784
+ if (e.diagnostics?.some((r) => !Wn(r)))
1775
1785
  throw new C("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
1776
1786
  }
1777
- function zo(e, t, r, o, n) {
1787
+ function Xn(e, t, r, n, o) {
1778
1788
  try {
1779
- t = Ot(o, t, { maxRows: e.dataValidation?.maxRows, signal: n });
1789
+ t = At(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
1780
1790
  } catch (a) {
1781
1791
  throw new C("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
1782
1792
  }
1783
1793
  for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
1784
1794
  let i;
1785
1795
  try {
1786
- i = Ze(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1796
+ i = et(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1787
1797
  } catch (c) {
1788
1798
  throw new C("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
1789
1799
  }
1790
1800
  if (!i.ok) throw new C("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
1791
1801
  }
1792
1802
  }
1793
- function _o(e, t, r, o, n, a) {
1803
+ async function Yn(e, t, r, n, o) {
1794
1804
  try {
1795
- const s = jt(r.pagination, n, e, t, a), i = mt(e, t, s);
1796
- return Lt(n, i), i;
1797
- } catch (s) {
1798
- const i = Ht(s, n);
1799
- throw new C("validate", `报表 ${o} 排版失败:${i instanceof Error ? i.message : String(i)}`, i);
1805
+ let a;
1806
+ try {
1807
+ a = Fn(e);
1808
+ } catch {
1809
+ }
1810
+ const s = a ?? e, i = Lt(t.pagination, n, s.template, s.datasets, o), c = a ? await ht(s.template, s.datasets, i) : mt(s.template, s.datasets, i);
1811
+ return Ht(n, c), { result: c, part: s };
1812
+ } catch (a) {
1813
+ $(o);
1814
+ const s = Dt(a, n);
1815
+ throw new C("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
1800
1816
  }
1801
1817
  }
1802
- function Dt(e, t, r, o, n) {
1818
+ function Bt(e, t, r, n, o) {
1803
1819
  const a = /* @__PURE__ */ new Map(), s = (i) => {
1804
1820
  let c = a.get(i);
1805
- return c === void 0 && (c = JSON.stringify([r, o, i]), a.set(i, c)), c;
1821
+ return c === void 0 && (c = JSON.stringify([r, n, i]), a.set(i, c)), c;
1806
1822
  };
1807
1823
  for (const i of t.pages) e.push({
1808
1824
  ...i,
1809
- meta: { ...i.meta, reportScope: At(r, o) },
1810
- components: Kt(i.components, n ?? Nt(r, o), s)
1825
+ meta: { ...i.meta, reportScope: Nt(r, n) },
1826
+ components: Kt(i.components, o ?? jt(r, n), s)
1811
1827
  });
1812
1828
  }
1813
- async function qo(e, t, r, o, n) {
1814
- const a = [], s = we(o);
1829
+ async function Qn(e, t, r, n, o) {
1830
+ const a = [], s = pe(n);
1815
1831
  for (const [l, d] of e.entries()) {
1816
- $(n);
1832
+ $(o);
1817
1833
  try {
1818
- const f = await Rt(d.template, d.datasets, jt(t[l]?.pagination, s, d.template, d.datasets, n));
1819
- Lt(s, f), Dt(a, f.plan, l, r[l], d.sourceScope);
1834
+ const f = await $t(d.template, d.datasets, Lt(t[l]?.pagination, s, d.template, d.datasets, o));
1835
+ Ht(s, f), Bt(a, f.plan, l, r[l], d.sourceScope);
1820
1836
  } catch (f) {
1821
- throw Ht(f, s);
1837
+ throw Dt(f, s);
1822
1838
  }
1823
1839
  }
1824
- const i = { schemaVersion: te, ...e.some((l) => ae(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Qe(i);
1840
+ const i = { schemaVersion: be, ...e.some((l) => ke(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Ze(i);
1825
1841
  if (!c.ok) throw new C("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
1826
1842
  return i;
1827
1843
  }
1828
- function En(e, t = {}) {
1844
+ function Ro(e, t = {}) {
1829
1845
  if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new C("config", "maxPages 应为正安全整数");
1830
1846
  if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new C("config", "maxCells 应为正安全整数");
1831
1847
  try {
1832
- we(t);
1833
- } catch (n) {
1834
- throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", n);
1848
+ pe(t);
1849
+ } catch (o) {
1850
+ throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
1835
1851
  }
1836
- function r(n) {
1837
- const a = Object.prototype.hasOwnProperty.call(e, n) ? e[n] : void 0;
1838
- if (!a) throw new C("config", `未注册报表 ${n}`);
1852
+ function r(o) {
1853
+ const a = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
1854
+ if (!a) throw new C("config", `未注册报表 ${o}`);
1839
1855
  if (a.sourceScope !== void 0 && (typeof a.sourceScope != "string" || !a.sourceScope.trim() || a.sourceScope.length > 512)) throw new C("config", "sourceScope 应为不超过 512 字符的非空字符串");
1840
1856
  return a;
1841
1857
  }
1842
- return Object.assign(async ({ reportIds: n, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
1858
+ return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
1843
1859
  $(s);
1844
- const d = jo({ ...l, signal: s }), f = [...n], u = { ...a };
1860
+ const d = Bn({ ...l, signal: s }), f = [...o], u = { ...a };
1845
1861
  if (f.length === 0) throw new C("config", "缺少报表 ID");
1846
- const h = f.map(r), m = d.runSync("validate", () => h.map((p) => Oe(
1862
+ const h = f.map(r), m = d.runSync("validate", () => h.map((p) => Ae(
1847
1863
  p.params ?? (typeof p.template == "function" ? [] : p.template.params) ?? [],
1848
1864
  u
1849
- ))), v = [], y = [], g = we(t), w = [];
1865
+ ))), v = [], y = [], g = pe(t), w = [];
1850
1866
  for (const [p, b] of h.entries()) {
1851
1867
  $(s);
1852
- const S = f[p], T = { reportId: S, params: m[p], signal: s }, k = typeof b.template == "function" ? await d.run("query", () => Vo(b.template, T, w), S) : b.template;
1853
- T.params = d.runSync("validate", () => Oe(b.params ?? k.params ?? [], T.params), S);
1854
- const R = await d.run("query", () => Wo(b, T, S, (ue, Bt) => c?.(ue, Bt, p)), S);
1868
+ const S = f[p], P = { reportId: S, params: m[p], signal: s }, T = typeof b.template == "function" ? await d.run("query", () => _n(b.template, P, w), S) : b.template;
1869
+ P.params = d.runSync("validate", () => Ae(b.params ?? T.params ?? [], P.params), S);
1870
+ const R = await d.run("query", () => qn(b, P, S, (ue, Wt) => c?.(ue, Wt, p)), S);
1855
1871
  d.runSync("validate", () => {
1856
- Go(R, S), t.onDatasets?.(S, R, k), zo(b, R, S, k, s);
1872
+ zn(R, S), t.onDatasets?.(S, R, T), Xn(b, R, S, T, s);
1857
1873
  }, S), $(s);
1858
- const j = d.runSync("layout", () => _o(k, R, b, S, g, s), S), Fe = Nt(p, S, b.sourceScope);
1859
- y.push({ template: k, datasets: R, sourceScope: Fe }), Dt(v, j.plan, p, S, Fe), w.push(...j.warnings.map((ue) => `${S}: ${ue}`));
1874
+ const L = jt(p, S, b.sourceScope), { result: Oe, part: Gt } = await d.run("layout", () => Yn({ template: T, datasets: R, sourceScope: L }, b, S, g, s), S);
1875
+ y.push(Gt), Bt(v, Oe.plan, p, S, L), w.push(...Oe.warnings.map((ue) => `${S}: ${ue}`));
1860
1876
  }
1861
1877
  $(s);
1862
- const x = { schemaVersion: te, ...y.some((p) => ae(p.template)) ? { requiresRecalculation: !0 } : {}, pages: v }, P = d.runSync("validate", () => {
1863
- const p = Qe(x);
1878
+ const x = { schemaVersion: be, ...y.some((p) => ke(p.template)) ? { requiresRecalculation: !0 } : {}, pages: v }, E = d.runSync("validate", () => {
1879
+ const p = Ze(x);
1864
1880
  if (!p.ok) throw new C("validate", `渲染计划校验失败:${p.errors.slice(0, 3).map((b) => `${b.path}: ${b.message}`).join("; ")}`);
1865
1881
  return p;
1866
1882
  });
1867
- w.push(...P.warnings.map((p) => `${p.path}: ${p.message}`));
1868
- const E = h.map((p) => ({ ...p, pagination: { ...p.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
1883
+ w.push(...E.warnings.map((p) => `${p.path}: ${p.message}`));
1884
+ const k = h.map((p) => ({ ...p, pagination: { ...p.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
1869
1885
  try {
1870
- It(x, { parts: y, validationFormulas: E.map((p) => p.pagination?.formula), rebuild: (p, b) => qo(p, E, f, O, b) });
1886
+ Ft(x, { parts: y, validationFormulas: k.map((p) => p.pagination?.formula), rebuild: (p, b) => Qn(p, k, f, O, b) });
1871
1887
  } catch {
1872
1888
  w.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
1873
1889
  }
@@ -1876,20 +1892,20 @@ function En(e, t = {}) {
1876
1892
  $(s), A(p);
1877
1893
  return $(s), x;
1878
1894
  }, {
1879
- getParamDefs: (n) => cr(e, n)
1895
+ getParamDefs: (o) => dr(e, o)
1880
1896
  });
1881
1897
  }
1882
- function Tn(e, t) {
1898
+ function $o(e, t) {
1883
1899
  const r = t.maxNodes ?? 1e6;
1884
1900
  if (![t.maxBytes, r].every((d) => Number.isSafeInteger(d) && d > 0)) throw t.error("budget", "快照预算应为正安全整数");
1885
- let o = 0, n = 0;
1901
+ let n = 0, o = 0;
1886
1902
  const a = /* @__PURE__ */ new Set();
1887
1903
  function s(d) {
1888
- if (n += d, n > t.maxBytes) throw t.error("budget", "快照超过字节预算");
1904
+ if (o += d, o > t.maxBytes) throw t.error("budget", "快照超过字节预算");
1889
1905
  }
1890
1906
  function i(d, f) {
1891
- if (++o > r || f > 64) throw t.error("budget", "快照节点或深度超过预算");
1892
- if (o % 1024 === 0 && t.check?.(), typeof d == "string")
1907
+ if (++n > r || f > 64) throw t.error("budget", "快照节点或深度超过预算");
1908
+ if (n % 1024 === 0 && t.check?.(), typeof d == "string")
1893
1909
  return s(d.length + 2), d;
1894
1910
  if (d === null || typeof d == "boolean" || typeof d == "number" && Number.isFinite(d))
1895
1911
  return s(String(d).length), d;
@@ -1918,50 +1934,50 @@ function Tn(e, t) {
1918
1934
  }
1919
1935
  export {
1920
1936
  mt as A,
1921
- un as B,
1922
- Mr as C,
1937
+ ho as B,
1938
+ xr as C,
1923
1939
  Er as D,
1924
- It as E,
1925
- bn as F,
1940
+ Ft as E,
1941
+ So as F,
1926
1942
  F as G,
1927
- yn as H,
1928
- mn as I,
1929
- Ge as J,
1930
- Ot as K,
1931
- xn as L,
1932
- Nt as M,
1943
+ Mo as H,
1944
+ po as I,
1945
+ We as J,
1946
+ At as K,
1947
+ To as L,
1948
+ jt as M,
1933
1949
  Ie as N,
1934
- q as O,
1935
- X as P,
1936
- jo as Q,
1950
+ U as O,
1951
+ Y as P,
1952
+ Bn as Q,
1937
1953
  C as R,
1938
- Cn as S,
1939
- Ko as T,
1940
- At as U,
1954
+ Po as S,
1955
+ Dn as T,
1956
+ Nt as U,
1941
1957
  M as a,
1942
- Y as b,
1943
- G as c,
1944
- kn as d,
1945
- ro as e,
1946
- gn as f,
1947
- wn as g,
1948
- Co as h,
1949
- Ct as i,
1950
- io as j,
1951
- dn as k,
1952
- hn as l,
1953
- pn as m,
1954
- H as n,
1955
- Mn as o,
1956
- bt as p,
1957
- En as q,
1958
- fn as r,
1959
- Tn as s,
1960
- Sn as t,
1961
- _ as u,
1958
+ Q as b,
1959
+ W as c,
1960
+ Eo as d,
1961
+ an as e,
1962
+ yo as f,
1963
+ vo as g,
1964
+ Pn as h,
1965
+ Tt as i,
1966
+ un as j,
1967
+ mo as k,
1968
+ wo as l,
1969
+ bo as m,
1970
+ D as n,
1971
+ Co as o,
1972
+ Mt as p,
1973
+ Ro as q,
1974
+ go as r,
1975
+ $o as s,
1976
+ ko as t,
1977
+ q as u,
1962
1978
  $e as v,
1963
- vn as w,
1964
- Ho as x,
1965
- Ft as y,
1966
- Lo as z
1979
+ xo as w,
1980
+ Wn as x,
1981
+ Ot as y,
1982
+ Gn as z
1967
1983
  };