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