@agile-team/mach-report 2.12.0 → 2.14.0

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