@agile-team/mach-report 2.24.0 → 2.25.1

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