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