@agile-team/mach-report 2.21.1 → 2.23.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 (169) hide show
  1. package/README.md +20 -5
  2. package/dist/{ExcelBindingWizard-mnAO2qOX.js → ExcelBindingWizard-D4FLind-.js} +3 -3
  3. package/dist/{ExcelBindingWizard-Bu0LUlzl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
  4. package/dist/{ParamEditor-38ZfNrPU.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
  5. package/dist/{ParamEditor-C8l0EC8m.js → ParamEditor-CASZt-Ma.js} +2 -2
  6. package/dist/{ReportBatchPanel-CfUVhvkO.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
  7. package/dist/{ReportBatchPanel-nCC06Nfp.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
  8. package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
  9. package/dist/ReportLabelStudio-Dj7GXhuv.js +783 -0
  10. package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
  11. package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-Dgmqro1Y.js} +265 -244
  12. package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
  13. package/dist/ReportPreview-FFIryrIr.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-DVlsf72p.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-B5t_EcIs.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
  16. package/dist/{RuleEditor-kT1JsZ9f.js → RuleEditor-D2UwQGF6.js} +59 -59
  17. package/dist/{RuleEditor-xFkCVlii.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
  18. package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
  19. package/dist/{TemplateOutlinePanel-BesgGR1P.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
  20. package/dist/{TemplateReusePanel-BNFU6V-W.js → TemplateReusePanel-4eejkNqi.js} +2 -2
  21. package/dist/{TemplateReusePanel-BG9Or5-P.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
  22. package/dist/{TemplateReviewPanel-CwvwyCSs.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
  23. package/dist/TemplateReviewPanel-DnYImiXu.cjs +1 -0
  24. package/dist/analytics.cjs +1 -1
  25. package/dist/analytics.js +26 -26
  26. package/dist/artifact-integrity.json +108 -106
  27. package/dist/assets-D2gHc4Mz.cjs +1 -0
  28. package/dist/assets-T_gDeFaz.js +132 -0
  29. package/dist/auto-4pK9HePf.cjs +1 -0
  30. package/dist/auto-CTIJ6PnR.js +257 -0
  31. package/dist/capabilities-DiBj4Qgl.cjs +1 -0
  32. package/dist/capabilities-pg7j7VLT.js +106 -0
  33. package/dist/charts-Cjw5AYkg.cjs +1 -0
  34. package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
  35. package/dist/computed-DK6BruFz.cjs +1 -0
  36. package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
  37. package/dist/data-bar-CeZuFmYl.cjs +1 -0
  38. package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
  39. package/dist/designer-DhrE7jzw.js +7169 -0
  40. package/dist/designer-IAZu6kBX.cjs +2 -0
  41. package/dist/designer.cjs +1 -1
  42. package/dist/designer.d.cts +246 -46
  43. package/dist/designer.d.ts +246 -46
  44. package/dist/designer.js +15 -14
  45. package/dist/dom-ChE5D-L-.cjs +1 -0
  46. package/dist/dom-JWrchIre.js +452 -0
  47. package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
  48. package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
  49. package/dist/{encoding-B79hW4zq.cjs → encoding-BefcaHdp.cjs} +1 -1
  50. package/dist/{encoding-BSeUwrN7.js → encoding-CL6rXEkR.js} +2 -2
  51. package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
  52. package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
  53. package/dist/grid-strokes-Be24LGuV.cjs +1 -0
  54. package/dist/grid-strokes-EoY66L2f.js +53 -0
  55. package/dist/index.cjs +8 -8
  56. package/dist/index.d.cts +44 -1
  57. package/dist/index.d.ts +44 -1
  58. package/dist/index.js +961 -1256
  59. package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
  60. package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-OqkPyUk5.js} +763 -776
  61. package/dist/matrix-B8QWbsGM.cjs +1 -0
  62. package/dist/matrix-C6e_r_vp.js +302 -0
  63. package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
  64. package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
  65. package/dist/pdf.cjs +1 -1
  66. package/dist/pdf.js +2 -2
  67. package/dist/{plugin-BaRUGORD.cjs → plugin-BFANt-i8.cjs} +1 -1
  68. package/dist/{plugin-D4kAxfLG.js → plugin-DeYYAL6F.js} +1 -1
  69. package/dist/{prefill-CJSazcVY.js → prefill-Dk4C6S5R.js} +21 -21
  70. package/dist/prefill-DsUD5OoK.cjs +1 -0
  71. package/dist/prepared-DCIxhKFo.js +94 -0
  72. package/dist/prepared-Dv-XM3i1.cjs +1 -0
  73. package/dist/progress-ByiOxUD3.js +250 -0
  74. package/dist/progress-WomPRP3B.cjs +1 -0
  75. package/dist/{protocol-C8VWF9An.cjs → protocol-B9YgfQ_d.cjs} +1 -1
  76. package/dist/{protocol-Bs9-ohHN.js → protocol-DxeUKGYG.js} +3 -3
  77. package/dist/record-bindings-DatJZv_e.js +200 -0
  78. package/dist/record-bindings-MBxbeBsi.cjs +1 -0
  79. package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-DjrXuR1q.js} +2 -2
  80. package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-l7NGfagJ.cjs} +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-Ciwa6D2o.js +52 -0
  84. package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
  85. package/dist/{runtime-BDf5x1i1.js → runtime-75Y5Oq5B.js} +52 -51
  86. package/dist/runtime-DKlGd_D4.cjs +1 -0
  87. package/dist/sbom.cdx.json +1 -1
  88. package/dist/server/node.d.cts +9 -0
  89. package/dist/server/node.d.ts +9 -0
  90. package/dist/server-node.cjs +5 -4
  91. package/dist/server-node.js +2178 -2044
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.d.cts +81 -0
  94. package/dist/server.d.ts +81 -0
  95. package/dist/server.js +24 -24
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-DFwIS9aN.js → template-catalog--cjxzgH7.js} +17 -17
  98. package/dist/template-catalog-CoT7jm_6.cjs +1 -0
  99. package/dist/{template-fragments-Dng-AlHk.js → template-fragments-CPpGpQoz.js} +24 -24
  100. package/dist/{template-fragments-DZVUBhuB.cjs → template-fragments-GVjpew_q.cjs} +1 -1
  101. package/dist/template-registry-DI59PXVK.cjs +1 -0
  102. package/dist/{template-registry-DhBqoD7W.js → template-registry-O0hNIOfB.js} +333 -261
  103. package/dist/template-serialization-CWmHq7lX.js +307 -0
  104. package/dist/template-serialization-CqQY4zDg.cjs +1 -0
  105. package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
  106. package/dist/textwrap-Cy7o1hIR.cjs +4 -0
  107. package/dist/vue/async.d.cts +121 -2
  108. package/dist/vue/async.d.ts +121 -2
  109. package/dist/vue/index.d.cts +222 -5
  110. package/dist/vue/index.d.ts +222 -5
  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 +101 -91
  115. package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
  116. package/dist/{workbook-session-oinxX3qo.js → workbook-session-C9ZmCBwY.js} +15 -16
  117. package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
  118. package/dist/workbook-sheets-D4M7XXBh.js +44 -0
  119. package/dist/worker.cjs +1 -1
  120. package/dist/worker.d.cts +9 -0
  121. package/dist/worker.d.ts +9 -0
  122. package/dist/worker.js +4 -4
  123. package/dist/xlsx.cjs +4 -4
  124. package/dist/xlsx.d.cts +39 -2
  125. package/dist/xlsx.d.ts +39 -2
  126. package/dist/xlsx.js +300 -275
  127. package/package.json +1 -1
  128. package/dist/ReportLabelStudio-CaEvYuSK.cjs +0 -1
  129. package/dist/ReportLabelStudio-DQPBmh4v.js +0 -765
  130. package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
  131. package/dist/ReportPreview-BBJNlu2U.js +0 -5740
  132. package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
  133. package/dist/TemplateOutlinePanel-CDI6mfWx.cjs +0 -1
  134. package/dist/TemplateReviewPanel-BmBrjt6P.cjs +0 -1
  135. package/dist/assets-CxHunY_9.js +0 -232
  136. package/dist/assets-vbjAGgk8.cjs +0 -1
  137. package/dist/auto-BkdGiNtr.js +0 -240
  138. package/dist/auto-Tq7ReIC1.cjs +0 -1
  139. package/dist/charts-aCtoswXq.cjs +0 -1
  140. package/dist/component-tree-1_QCiQJX.js +0 -67
  141. package/dist/component-tree-BjZIp6w9.cjs +0 -1
  142. package/dist/computed-4TnxzgIh.cjs +0 -1
  143. package/dist/data-bar-YltqGTaC.cjs +0 -1
  144. package/dist/designer-DU3yDWgs.cjs +0 -2
  145. package/dist/designer-HQi-03R6.js +0 -6869
  146. package/dist/grid-geometry-D3SJgWFv.js +0 -136
  147. package/dist/grid-geometry-D8ReblRV.cjs +0 -1
  148. package/dist/json-snapshot-I5VI84Vp.cjs +0 -2
  149. package/dist/matrix-0hywp0-F.cjs +0 -1
  150. package/dist/matrix-Dy-tyY7E.js +0 -381
  151. package/dist/prefill-Bpyn58AZ.cjs +0 -1
  152. package/dist/prepared-BiSz_9vN.cjs +0 -1
  153. package/dist/prepared-BwjwEzFz.js +0 -87
  154. package/dist/progress-B0ctFpKf.cjs +0 -1
  155. package/dist/progress-Hc2vxoCs.js +0 -52
  156. package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
  157. package/dist/record-bindings-VZGS-Qd8.js +0 -155
  158. package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
  159. package/dist/rich-text-layout-wxBhnAS7.js +0 -102
  160. package/dist/runtime-DsJt1PIf.cjs +0 -1
  161. package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
  162. package/dist/template-bindings-TKnXM7ll.js +0 -62
  163. package/dist/template-catalog-D_2jdnkL.cjs +0 -1
  164. package/dist/template-outline-DWkzZXVC.cjs +0 -1
  165. package/dist/template-outline-DiADphlq.js +0 -88
  166. package/dist/template-registry-DpLUSLwF.cjs +0 -1
  167. package/dist/template-serialization-Cc3h-miv.js +0 -247
  168. package/dist/template-serialization-D1R5oAqh.cjs +0 -1
  169. package/dist/textwrap-OTOUMr4f.cjs +0 -4
@@ -0,0 +1,307 @@
1
+ import { e as V, c as v } from "./computed-f3pOqWLX.js";
2
+ function c(e) {
3
+ return !!e && typeof e == "object" && !Array.isArray(e);
4
+ }
5
+ function a(e, r, i) {
6
+ typeof e == "string" ? i.push({ field: e, path: r }) : Array.isArray(e) && e.forEach((n, t) => a(n, `${r}[${t}]`, i));
7
+ }
8
+ function w(e, r, i) {
9
+ if (Array.isArray(e)) {
10
+ e.forEach((n, t) => w(n, `${r}[${t}]`, i));
11
+ return;
12
+ }
13
+ if (c(e))
14
+ for (const [n, t] of Object.entries(e))
15
+ ["field", "weightField"].includes(n) ? a(t, `${r}.${n}`, i) : n !== "value" && n !== "style" && w(t, `${r}.${n}`, i);
16
+ }
17
+ function p(e, r, i) {
18
+ Array.isArray(e) && e.forEach((n, t) => {
19
+ if (!c(n)) return;
20
+ typeof n.field == "string" && n.valueField !== void 0 && n.valueField !== n.field && i.summaries.add(n.field);
21
+ const o = n.valueField === void 0 ? "field" : "valueField";
22
+ a(n[o], `${r}[${t}].${o}`, i.fields), n.valueField !== void 0 && n.valueField === n.field && a(n.field, `${r}[${t}].field`, i.fields), a(n.weightField, `${r}[${t}].weightField`, i.fields);
23
+ });
24
+ }
25
+ function j(e, r, i) {
26
+ for (const t of ["rowKey", "revisionField", "sourceTokenField"]) a(e[t], `${r}.${t}`, i.fields);
27
+ if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((t, o) => {
28
+ c(t) && (typeof t.field == "string" && i.fields.push({ field: t.field, path: `${r}.columns[${o}].field`, summary: !0 }), w(t.rules, `${r}.columns[${o}].rules`, i.fields), w(t.visibleWhen, `${r}.columns[${o}].visibleWhen`, i.fields));
29
+ }), w(e.rowVisibleWhen, `${r}.rowVisibleWhen`, i.fields), Array.isArray(e.computed) && e.computed.forEach((t, o) => {
30
+ c(t) && (typeof t.field == "string" && i.generated.add(t.field), w(t.expression, `${r}.computed[${o}].expression`, i.fields), a(t.dependsOn, `${r}.computed[${o}].dependsOn`, i.fields), a(t.groupBy, `${r}.computed[${o}].groupBy`, i.fields));
31
+ }), (Array.isArray(e.groups) ? e.groups.map((t, o) => ({ group: t, path: `${r}.groups[${o}]` })) : e.groupBy ? [{ group: e.groupBy, path: `${r}.groupBy` }] : []).forEach(({ group: t, path: o }) => {
32
+ c(t) && (a(t.field, `${o}.field`, i.fields), a(t.subtotal, `${o}.subtotal`, i.fields), p(t.aggregates, `${o}.aggregates`, i));
33
+ }), c(e.grandTotal) && (a(e.grandTotal.fields, `${r}.grandTotal.fields`, i.fields), p(e.grandTotal.aggregates, `${r}.grandTotal.aggregates`, i)), c(e.matrix) && (a(e.matrix.rowFields, `${r}.matrix.rowFields`, i.fields), a(e.matrix.columnFields, `${r}.matrix.columnFields`, i.fields), p(e.matrix.measures, `${r}.matrix.measures`, i)), c(e.tree)) {
34
+ for (const t of ["idField", "parentField", "labelField"]) a(e.tree[t], `${r}.tree.${t}`, i.fields);
35
+ p(e.tree.aggregates, `${r}.tree.aggregates`, i);
36
+ }
37
+ c(e.detail) && a(e.detail.parentKey, `${r}.detail.parentKey`, i.fields);
38
+ }
39
+ function U(e) {
40
+ const r = [], i = e.repeat, n = i ? { dataset: i.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
41
+ n && i && (a(i.rowKey, "$.template.repeat.rowKey", n.fields), typeof i.copies == "object" && a(i.copies.field, "$.template.repeat.copies.field", n.fields), r.push(n));
42
+ function t(o, s) {
43
+ if (Array.isArray(o)) {
44
+ o.forEach((f, l) => t(f, `${s}[${l}]`));
45
+ return;
46
+ }
47
+ if (c(o)) {
48
+ if (n && c(o.binding) && a(o.binding.field, `${s}.binding.field`, n.fields), c(o.chartBinding) && typeof o.chartBinding.dataset == "string") {
49
+ const f = `${s}.chartBinding`, l = o.chartBinding, d = { dataset: l.dataset, path: f, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
50
+ a(l.categoryField, `${f}.categoryField`, d.fields), w(l.measures, `${f}.measures`, d.fields), r.push(d);
51
+ }
52
+ if (typeof o.dataset == "string" && Array.isArray(o.columns)) {
53
+ const f = { dataset: o.dataset, path: s, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
54
+ j(o, s, f), typeof o.foreignKey == "string" && a(o.foreignKey, `${s}.foreignKey`, f.fields), r.push(f);
55
+ }
56
+ for (const [f, l] of Object.entries(o)) t(l, `${s}.${f}`);
57
+ }
58
+ }
59
+ return t(e, "$.template"), r;
60
+ }
61
+ class K extends Error {
62
+ constructor(r) {
63
+ super(`树节点超出行数预算 ${r}`), this.limit = r, this.code = "tree-row-limit", this.name = "TreeRowLimitError";
64
+ }
65
+ }
66
+ function E(e, r, i, n) {
67
+ const t = e ?? r;
68
+ if (!Number.isInteger(t) || t < 1 || t > i) throw new Error(`${n}应为 1–${i} 的整数`);
69
+ return t;
70
+ }
71
+ function b(e) {
72
+ return { rows: E(e.maxRows, 1e5, 1e6, "树行数预算"), depth: E(e.maxDepth, 64, 256, "树深度预算"), visits: E(e.maxAggregationVisits, 1e6, 1e7, "树聚合访问预算") };
73
+ }
74
+ function M(e) {
75
+ return typeof e == "string" && !!e.trim();
76
+ }
77
+ function g(e) {
78
+ return M(e) && !["__proto__", "prototype", "constructor"].includes(e);
79
+ }
80
+ function N(e) {
81
+ if (M(e) || typeof e == "number" && Number.isFinite(e)) return e;
82
+ throw new Error("树节点业务键应为非空字符串或有限数字");
83
+ }
84
+ function S(e) {
85
+ return JSON.stringify([typeof e, e]);
86
+ }
87
+ function x(e) {
88
+ return [e.idField, ...e.input === "flat" ? [e.parentField ?? ""] : [e.childrenField ?? "children"]];
89
+ }
90
+ function R(e, r) {
91
+ const i = x(e);
92
+ if (r?.some((n) => n.scope && n.scope !== "row" || i.includes(n.field))) throw new Error("树形布局仅支持不覆盖结构键的当前行计算");
93
+ }
94
+ function m(e) {
95
+ if (!e?.aborted) return;
96
+ const r = new Error("树报表处理已取消");
97
+ throw r.name = "AbortError", r;
98
+ }
99
+ function I(e) {
100
+ const r = e.aggregates ?? [];
101
+ if (!Array.isArray(r) || r.length > 32) throw new Error("树聚合最多 32 项");
102
+ if (e.parentValues !== "leaf-aggregate" && r.length) throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");
103
+ if (e.parentValues === "leaf-aggregate" && !r.length) throw new Error("叶子聚合策略至少需要一个聚合字段");
104
+ const i = /* @__PURE__ */ new Set();
105
+ for (const n of r) {
106
+ if (!n || !g(n.field) || i.has(n.field)) throw new Error("树聚合输出字段应安全、非空且唯一");
107
+ for (const t of [n.valueField, n.weightField]) if (t !== void 0 && !g(t)) throw new Error("树聚合来源字段应安全且非空");
108
+ if ([...x(e), e.labelField].includes(n.field)) throw new Error("树聚合不能覆盖结构键或标签字段");
109
+ i.add(n.field), v({ ...n, field: n.valueField ?? n.field });
110
+ }
111
+ }
112
+ function _(e) {
113
+ if (!g(e.idField) || !g(e.labelField)) throw new Error("树需要安全的业务键和标签字段");
114
+ if (e.input === "flat" && (!g(e.parentField) || e.parentField === e.idField)) throw new Error("扁平树需要独立的父键字段");
115
+ if (e.childrenField !== void 0 && !g(e.childrenField)) throw new Error("子节点字段应安全且非空");
116
+ if (e.input === "nested" && [e.idField, e.labelField].includes(e.childrenField ?? "children")) throw new Error("子节点字段不能覆盖业务键或标签字段");
117
+ }
118
+ function W(e) {
119
+ if (!e || typeof e != "object" || !["flat", "nested"].includes(e.input)) throw new Error("树输入应为 flat 或 nested");
120
+ if (_(e), e.orphan !== void 0 && !["error", "root"].includes(e.orphan)) throw new Error("树孤儿策略应为 error 或 root");
121
+ if (e.parentValues !== void 0 && !["source", "leaf-aggregate"].includes(e.parentValues)) throw new Error("未知树父级取值策略");
122
+ if (e.indentMm !== void 0 && (!Number.isFinite(e.indentMm) || e.indentMm < 0 || e.indentMm > 20)) throw new Error("树每级缩进应为 0–20 mm");
123
+ b(e), I(e);
124
+ }
125
+ function C(e, r, i, n) {
126
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("树节点应为对象");
127
+ if (i.size >= n.rows) throw new K(n.rows);
128
+ const t = N(e[r.idField]), o = S(t);
129
+ if (i.has(o)) throw new Error(`树节点业务键重复:${String(t)}`);
130
+ const s = { original: e, row: e, key: t, depth: 0, children: [] };
131
+ return i.set(o, s), s;
132
+ }
133
+ function D(e, r, i, n, t) {
134
+ for (const s of e)
135
+ m(t), C(s, r, i, n);
136
+ const o = [];
137
+ for (const s of i.values()) {
138
+ m(t);
139
+ const f = s.row[r.parentField];
140
+ if (f == null) {
141
+ o.push(s);
142
+ continue;
143
+ }
144
+ const l = i.get(S(N(f)));
145
+ if (!l) {
146
+ if (r.orphan !== "root") throw new Error(`树节点 ${String(s.key)} 的父节点不存在`);
147
+ o.push(s);
148
+ continue;
149
+ }
150
+ if (l === s) throw new Error("树节点不能以自身为父节点");
151
+ s.parent = l, l.children.push(s);
152
+ }
153
+ return o;
154
+ }
155
+ function J(e, r, i, n, t) {
156
+ const o = [], s = [{ rows: e, next: 0 }];
157
+ for (; s.length; ) {
158
+ m(t);
159
+ const f = s[s.length - 1];
160
+ if (f.next >= f.rows.length) {
161
+ s.pop();
162
+ continue;
163
+ }
164
+ const l = C(f.rows[f.next++], r, i, n);
165
+ if (l.parent = f.parent, l.depth = s.length - 1, s.length > n.depth) throw new Error(`树节点超出深度预算 ${n.depth}`);
166
+ (f.parent?.children ?? o).push(l);
167
+ const d = l.row[r.childrenField ?? "children"];
168
+ if (d != null) {
169
+ if (!Array.isArray(d)) throw new Error("嵌套树 children 字段应为数组");
170
+ d.length && s.push({ rows: d, next: 0, parent: l });
171
+ }
172
+ }
173
+ return o;
174
+ }
175
+ function L(e, r, i, n) {
176
+ const t = [], o = [{ nodes: e, next: 0 }];
177
+ for (; o.length; ) {
178
+ m(n);
179
+ const s = o[o.length - 1];
180
+ if (s.next >= s.nodes.length) {
181
+ o.pop();
182
+ continue;
183
+ }
184
+ if (o.length > i.depth) throw new Error(`树节点超出深度预算 ${i.depth}`);
185
+ const f = s.nodes[s.next++];
186
+ f.depth = o.length - 1, t.push(f), f.children.length && o.push({ nodes: f.children, next: 0 });
187
+ }
188
+ if (t.length !== r) throw new Error("树父子关系存在循环");
189
+ return t;
190
+ }
191
+ function z(e, r, i, n) {
192
+ if (r.parentValues !== "leaf-aggregate") return;
193
+ const t = r.aggregates, o = /* @__PURE__ */ new Map();
194
+ for (const f of e) f.children.length && o.set(f, t.map((l) => v({ ...l, field: l.valueField ?? l.field })));
195
+ let s = 0;
196
+ for (const f of e)
197
+ if (!f.children.length)
198
+ for (let l = f.parent; l; l = l.parent) {
199
+ if (m(n), s += t.length, s > i.visits) throw new Error(`树聚合超出访问预算 ${i.visits}`);
200
+ for (const d of o.get(l)) d.add(f.row);
201
+ }
202
+ for (const [f, l] of o)
203
+ f.row = { ...f.row }, t.forEach((d, u) => {
204
+ f.row[d.field] = l[u].value();
205
+ });
206
+ }
207
+ function O(e, r, i) {
208
+ if (W(r), m(i), !Array.isArray(e)) throw new Error("树数据应为节点数组");
209
+ const n = b(r), t = /* @__PURE__ */ new Map(), o = r.input === "flat" ? D(e, r, t, n, i) : J(e, r, t, n, i);
210
+ return L(o, t.size, n, i);
211
+ }
212
+ function Y(e, r, i) {
213
+ return O(e, r, i).map((n) => n.original);
214
+ }
215
+ function Z(e, r, i = {}) {
216
+ const n = O(e, r, i.signal);
217
+ if (R(r, i.computed?.fields), i.computed?.fields.length) {
218
+ const t = V(n.map((o) => o.row), { ...i.computed, signal: i.signal }).rows;
219
+ n.forEach((o, s) => {
220
+ o.row = t[s];
221
+ });
222
+ }
223
+ return z(n, r, b(r), i.signal), { rows: n.map((t) => t.row), entries: n.map((t) => ({ row: t.row, original: t.original, key: t.key, depth: t.depth, hasChildren: !!t.children.length })), leaves: n.filter((t) => !t.children.length).map((t) => t.row) };
224
+ }
225
+ const H = /^#[0-9a-f]{6}$/i;
226
+ function X(e) {
227
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
228
+ const r = e;
229
+ return r.kind !== "colorScale" && r.kind !== "dataBar" || r.field !== void 0 && (typeof r.field != "string" || !r.field.trim()) || r.numeric !== void 0 && !["number", "decimal"].includes(r.numeric) || [r.min, r.max].some((i) => i !== void 0 && (typeof i != "number" || !Number.isFinite(i))) || r.min !== void 0 && r.max !== void 0 && r.min > r.max ? !1 : Object.entries(r).every(([i, n]) => !["color", "negativeColor", "lowColor", "highColor"].includes(i) || typeof n == "string" && H.test(n));
230
+ }
231
+ function B(e, r) {
232
+ if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
233
+ if (r !== "decimal" || typeof e != "string" || e.length > 1024 || !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e)) return;
234
+ const i = Number(e);
235
+ return Number.isFinite(i) ? i : void 0;
236
+ }
237
+ function q(e, r, i) {
238
+ let n = "#";
239
+ for (const t of [1, 3, 5]) {
240
+ const o = parseInt(e.slice(t, t + 2), 16), s = parseInt(r.slice(t, t + 2), 16);
241
+ n += Math.round(o + (s - o) * i).toString(16).padStart(2, "0");
242
+ }
243
+ return n;
244
+ }
245
+ function A(e, r, i) {
246
+ if (r === i) return e < r ? 0 : e > i ? 1 : 0.5;
247
+ if (e <= r) return 0;
248
+ if (e >= i) return 1;
249
+ const n = i - r;
250
+ return Number.isFinite(n) ? (e - r) / n : (e / 2 - r / 2) / (i / 2 - r / 2);
251
+ }
252
+ function G(e, r, i, n) {
253
+ const t = /* @__PURE__ */ new WeakMap();
254
+ return { apply(o, s) {
255
+ const f = B(s[r], e.numeric);
256
+ if (f === void 0) return;
257
+ if (e.kind === "dataBar") {
258
+ const h = Math.min(i, 0), $ = Math.max(n, 0), F = A(0, h, $), k = h === $ ? F : A(f, h, $);
259
+ o.dataBar = { start: Math.min(F, k), end: Math.max(F, k), color: f < 0 ? e.negativeColor ?? "#f3bcc3" : e.color ?? "#bad8fa" };
260
+ return;
261
+ }
262
+ const l = q(e.lowColor ?? "#f0f7ff", e.highColor ?? "#8bbcf1", A(f, i, n)), d = o.style ?? {}, u = t.get(d) ?? /* @__PURE__ */ new Map();
263
+ t.set(d, u);
264
+ let y = u.get(l);
265
+ y || (y = { ...d, backgroundColor: l }, u.set(l, y)), o.style = y;
266
+ } };
267
+ }
268
+ function ee(e, r, i) {
269
+ return e.map((n) => {
270
+ T(i);
271
+ const t = n.visual;
272
+ if (!t) return;
273
+ if (!X(t)) throw new TypeError("Invalid column visual rule");
274
+ const o = t.field ?? n.field;
275
+ let s = 1 / 0, f = -1 / 0, l = 0;
276
+ if (t.min === void 0 || t.max === void 0) for (const y of r) {
277
+ (l++ & 1023) === 0 && T(i);
278
+ const h = B(y[o], t.numeric);
279
+ h !== void 0 && (s = Math.min(s, h), f = Math.max(f, h));
280
+ }
281
+ let d = t.min ?? s, u = t.max ?? f;
282
+ if (!(!Number.isFinite(d) || !Number.isFinite(u)))
283
+ return d > u && (t.min !== void 0 ? u = d : d = u), G(t, o, d, u);
284
+ });
285
+ }
286
+ function T(e) {
287
+ if (e?.aborted) throw e.reason ?? new DOMException("Aborted", "AbortError");
288
+ }
289
+ const P = 1e7;
290
+ function re(e) {
291
+ const r = JSON.stringify(e, null, 2);
292
+ if (r.length > P)
293
+ throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");
294
+ return r;
295
+ }
296
+ export {
297
+ P as M,
298
+ K as T,
299
+ W as a,
300
+ U as b,
301
+ Z as c,
302
+ R as d,
303
+ ee as e,
304
+ Y as f,
305
+ re as s,
306
+ X as v
307
+ };
@@ -0,0 +1 @@
1
+ "use strict";const b=require("./computed-DK6BruFz.cjs");function c(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function a(e,r,i){typeof e=="string"?i.push({field:e,path:r}):Array.isArray(e)&&e.forEach((n,t)=>a(n,`${r}[${t}]`,i))}function w(e,r,i){if(Array.isArray(e)){e.forEach((n,t)=>w(n,`${r}[${t}]`,i));return}if(c(e))for(const[n,t]of Object.entries(e))["field","weightField"].includes(n)?a(t,`${r}.${n}`,i):n!=="value"&&n!=="style"&&w(t,`${r}.${n}`,i)}function p(e,r,i){Array.isArray(e)&&e.forEach((n,t)=>{if(!c(n))return;typeof n.field=="string"&&n.valueField!==void 0&&n.valueField!==n.field&&i.summaries.add(n.field);const o=n.valueField===void 0?"field":"valueField";a(n[o],`${r}[${t}].${o}`,i.fields),n.valueField!==void 0&&n.valueField===n.field&&a(n.field,`${r}[${t}].field`,i.fields),a(n.weightField,`${r}[${t}].weightField`,i.fields)})}function I(e,r,i){for(const t of["rowKey","revisionField","sourceTokenField"])a(e[t],`${r}.${t}`,i.fields);if(!e.matrix&&Array.isArray(e.columns)&&e.columns.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.fields.push({field:t.field,path:`${r}.columns[${o}].field`,summary:!0}),w(t.rules,`${r}.columns[${o}].rules`,i.fields),w(t.visibleWhen,`${r}.columns[${o}].visibleWhen`,i.fields))}),w(e.rowVisibleWhen,`${r}.rowVisibleWhen`,i.fields),Array.isArray(e.computed)&&e.computed.forEach((t,o)=>{c(t)&&(typeof t.field=="string"&&i.generated.add(t.field),w(t.expression,`${r}.computed[${o}].expression`,i.fields),a(t.dependsOn,`${r}.computed[${o}].dependsOn`,i.fields),a(t.groupBy,`${r}.computed[${o}].groupBy`,i.fields))}),(Array.isArray(e.groups)?e.groups.map((t,o)=>({group:t,path:`${r}.groups[${o}]`})):e.groupBy?[{group:e.groupBy,path:`${r}.groupBy`}]:[]).forEach(({group:t,path:o})=>{c(t)&&(a(t.field,`${o}.field`,i.fields),a(t.subtotal,`${o}.subtotal`,i.fields),p(t.aggregates,`${o}.aggregates`,i))}),c(e.grandTotal)&&(a(e.grandTotal.fields,`${r}.grandTotal.fields`,i.fields),p(e.grandTotal.aggregates,`${r}.grandTotal.aggregates`,i)),c(e.matrix)&&(a(e.matrix.rowFields,`${r}.matrix.rowFields`,i.fields),a(e.matrix.columnFields,`${r}.matrix.columnFields`,i.fields),p(e.matrix.measures,`${r}.matrix.measures`,i)),c(e.tree)){for(const t of["idField","parentField","labelField"])a(e.tree[t],`${r}.tree.${t}`,i.fields);p(e.tree.aggregates,`${r}.tree.aggregates`,i)}c(e.detail)&&a(e.detail.parentKey,`${r}.detail.parentKey`,i.fields)}function L(e){const r=[],i=e.repeat,n=i?{dataset:i.dataset,path:"$.template.repeat",fields:[],generated:new Set,summaries:new Set}:void 0;n&&i&&(a(i.rowKey,"$.template.repeat.rowKey",n.fields),typeof i.copies=="object"&&a(i.copies.field,"$.template.repeat.copies.field",n.fields),r.push(n));function t(o,s){if(Array.isArray(o)){o.forEach((f,l)=>t(f,`${s}[${l}]`));return}if(c(o)){if(n&&c(o.binding)&&a(o.binding.field,`${s}.binding.field`,n.fields),c(o.chartBinding)&&typeof o.chartBinding.dataset=="string"){const f=`${s}.chartBinding`,l=o.chartBinding,d={dataset:l.dataset,path:f,fields:[],generated:new Set,summaries:new Set};a(l.categoryField,`${f}.categoryField`,d.fields),w(l.measures,`${f}.measures`,d.fields),r.push(d)}if(typeof o.dataset=="string"&&Array.isArray(o.columns)){const f={dataset:o.dataset,path:s,fields:[],generated:new Set,summaries:new Set};I(o,s,f),typeof o.foreignKey=="string"&&a(o.foreignKey,`${s}.foreignKey`,f.fields),r.push(f)}for(const[f,l]of Object.entries(o))t(l,`${s}.${f}`)}}return t(e,"$.template"),r}class M extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function F(e,r,i,n){const t=e??r;if(!Number.isInteger(t)||t<1||t>i)throw new Error(`${n}应为 1–${i} 的整数`);return t}function T(e){return{rows:F(e.maxRows,1e5,1e6,"树行数预算"),depth:F(e.maxDepth,64,256,"树深度预算"),visits:F(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function S(e){return typeof e=="string"&&!!e.trim()}function m(e){return S(e)&&!["__proto__","prototype","constructor"].includes(e)}function C(e){if(S(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function N(e){return JSON.stringify([typeof e,e])}function O(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function V(e,r){const i=O(e);if(r?.some(n=>n.scope&&n.scope!=="row"||i.includes(n.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function g(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function D(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const i=new Set;for(const n of r){if(!n||!m(n.field)||i.has(n.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const t of[n.valueField,n.weightField])if(t!==void 0&&!m(t))throw new Error("树聚合来源字段应安全且非空");if([...O(e),e.labelField].includes(n.field))throw new Error("树聚合不能覆盖结构键或标签字段");i.add(n.field),b.createAggregateAccumulator({...n,field:n.valueField??n.field})}}function J(e){if(!m(e.idField)||!m(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!m(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!m(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function x(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(J(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");T(e),D(e)}function B(e,r,i,n){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(i.size>=n.rows)throw new M(n.rows);const t=C(e[r.idField]),o=N(t);if(i.has(o))throw new Error(`树节点业务键重复:${String(t)}`);const s={original:e,row:e,key:t,depth:0,children:[]};return i.set(o,s),s}function W(e,r,i,n,t){for(const s of e)g(t),B(s,r,i,n);const o=[];for(const s of i.values()){g(t);const f=s.row[r.parentField];if(f==null){o.push(s);continue}const l=i.get(N(C(f)));if(!l){if(r.orphan!=="root")throw new Error(`树节点 ${String(s.key)} 的父节点不存在`);o.push(s);continue}if(l===s)throw new Error("树节点不能以自身为父节点");s.parent=l,l.children.push(s)}return o}function z(e,r,i,n,t){const o=[],s=[{rows:e,next:0}];for(;s.length;){g(t);const f=s[s.length-1];if(f.next>=f.rows.length){s.pop();continue}const l=B(f.rows[f.next++],r,i,n);if(l.parent=f.parent,l.depth=s.length-1,s.length>n.depth)throw new Error(`树节点超出深度预算 ${n.depth}`);(f.parent?.children??o).push(l);const d=l.row[r.childrenField??"children"];if(d!=null){if(!Array.isArray(d))throw new Error("嵌套树 children 字段应为数组");d.length&&s.push({rows:d,next:0,parent:l})}}return o}function H(e,r,i,n){const t=[],o=[{nodes:e,next:0}];for(;o.length;){g(n);const s=o[o.length-1];if(s.next>=s.nodes.length){o.pop();continue}if(o.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);const f=s.nodes[s.next++];f.depth=o.length-1,t.push(f),f.children.length&&o.push({nodes:f.children,next:0})}if(t.length!==r)throw new Error("树父子关系存在循环");return t}function X(e,r,i,n){if(r.parentValues!=="leaf-aggregate")return;const t=r.aggregates,o=new Map;for(const f of e)f.children.length&&o.set(f,t.map(l=>b.createAggregateAccumulator({...l,field:l.valueField??l.field})));let s=0;for(const f of e)if(!f.children.length)for(let l=f.parent;l;l=l.parent){if(g(n),s+=t.length,s>i.visits)throw new Error(`树聚合超出访问预算 ${i.visits}`);for(const d of o.get(l))d.add(f.row)}for(const[f,l]of o)f.row={...f.row},t.forEach((d,u)=>{f.row[d.field]=l[u].value()})}function R(e,r,i){if(x(r),g(i),!Array.isArray(e))throw new Error("树数据应为节点数组");const n=T(r),t=new Map,o=r.input==="flat"?W(e,r,t,n,i):z(e,r,t,n,i);return H(o,t.size,n,i)}function q(e,r,i){return R(e,r,i).map(n=>n.original)}function P(e,r,i={}){const n=R(e,r,i.signal);if(V(r,i.computed?.fields),i.computed?.fields.length){const t=b.computeDataset(n.map(o=>o.row),{...i.computed,signal:i.signal}).rows;n.forEach((o,s)=>{o.row=t[s]})}return X(n,r,T(r),i.signal),{rows:n.map(t=>t.row),entries:n.map(t=>({row:t.row,original:t.original,key:t.key,depth:t.depth,hasChildren:!!t.children.length})),leaves:n.filter(t=>!t.children.length).map(t=>t.row)}}const G=/^#[0-9a-f]{6}$/i;function j(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(i=>i!==void 0&&(typeof i!="number"||!Number.isFinite(i)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([i,n])=>!["color","negativeColor","lowColor","highColor"].includes(i)||typeof n=="string"&&G.test(n))}function _(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const i=Number(e);return Number.isFinite(i)?i:void 0}function Q(e,r,i){let n="#";for(const t of[1,3,5]){const o=parseInt(e.slice(t,t+2),16),s=parseInt(r.slice(t,t+2),16);n+=Math.round(o+(s-o)*i).toString(16).padStart(2,"0")}return n}function A(e,r,i){if(r===i)return e<r?0:e>i?1:.5;if(e<=r)return 0;if(e>=i)return 1;const n=i-r;return Number.isFinite(n)?(e-r)/n:(e/2-r/2)/(i/2-r/2)}function U(e,r,i,n){const t=new WeakMap;return{apply(o,s){const f=_(s[r],e.numeric);if(f===void 0)return;if(e.kind==="dataBar"){const h=Math.min(i,0),$=Math.max(n,0),E=A(0,h,$),v=h===$?E:A(f,h,$);o.dataBar={start:Math.min(E,v),end:Math.max(E,v),color:f<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const l=Q(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",A(f,i,n)),d=o.style??{},u=t.get(d)??new Map;t.set(d,u);let y=u.get(l);y||(y={...d,backgroundColor:l},u.set(l,y)),o.style=y}}}function Y(e,r,i){return e.map(n=>{k(i);const t=n.visual;if(!t)return;if(!j(t))throw new TypeError("Invalid column visual rule");const o=t.field??n.field;let s=1/0,f=-1/0,l=0;if(t.min===void 0||t.max===void 0)for(const y of r){(l++&1023)===0&&k(i);const h=_(y[o],t.numeric);h!==void 0&&(s=Math.min(s,h),f=Math.max(f,h))}let d=t.min??s,u=t.max??f;if(!(!Number.isFinite(d)||!Number.isFinite(u)))return d>u&&(t.min!==void 0?u=d:d=u),U(t,o,d,u)})}function k(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}const K=1e7;function Z(e){const r=JSON.stringify(e,null,2);if(r.length>K)throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");return r}exports.MAX_TEMPLATE_JSON_CHARACTERS=K;exports.TreeRowLimitError=M;exports.collectTemplateDatasetBindings=L;exports.createColumnVisualResolvers=Y;exports.createTreeTable=P;exports.flattenTreeInput=q;exports.stringifyValidatedTemplate=Z;exports.validColumnVisual=j;exports.validateTreeComputed=V;exports.validateTreeOptions=x;
@@ -1,4 +1,4 @@
1
- import { D as M } from "./grid-geometry-D3SJgWFv.js";
1
+ import { D as M } from "./progress-ByiOxUD3.js";
2
2
  const d = /[\u3000-\u9fff\uff00-\uffef]/, s = new Uint8Array(128);
3
3
  {
4
4
  for (const t of "iljtf.,:;'`|!()[]") s[t.charCodeAt(0)] = 1;
@@ -0,0 +1,4 @@
1
+ "use strict";const g=require("./progress-WomPRP3B.cjs"),M=/[\u3000-\u9fff\uff00-\uffef]/,s=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")s[t.charCodeAt(0)]=1;for(const t of"mwMW@")s[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)s[t]=3;for(let t=65;t<=90;t++)s[t]=4;s[32]=5}const w=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?w[s[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const o={measureMm(t,e){const{fontSizePt:i,bold:c=!1,letterSpacingPt:u=0}=e,r=25.4/72;let n=0;for(const h of t)n+=d(h);return c&&(n*=1.04),(n*i+u*Math.max(0,Array.from(t).length-1))*r}};function p(){return o}function A(t,e){return o.measureMm(t,e)}function x(t){let e;return{measureMm(i,c){if(e===void 0&&(e=t()),!e)return o.measureMm(i,c);const u=c.fontSizePt*96/72;e.font=`${c.italic?"italic ":""}${c.bold?"bold ":""}${u}px ${c.fontFamily??g.DEFAULT_FONT_FAMILY}`,"letterSpacing"in e&&(e.letterSpacing="0px");const r=(c.letterSpacingPt??0)*Math.max(0,Array.from(i).length-1);return e.measureText(i).width*25.4/96+r*25.4/72}}}function T(t,e,i){const c=[];let u="";const r=()=>{u&&(c.push({text:u,widthMm:i.measureMm(u,e),cjk:!1}),u="")};for(const n of t){if(n===`
2
+ `){r(),c.push({text:`
3
+ `,widthMm:0,cjk:!1,br:!0});continue}if(n===" "){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!1,space:!0});continue}if(M.test(n)){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!0});continue}u+=n}return r(),c}function S(t,e,i,c=o){if(!t)return[""];t=t.replace(/\r\n?/g,`
4
+ `);const u=[];let r="",n=0;const h=(i.letterSpacingPt??0)*25.4/72,a=()=>{u.push(r),r="",n=0};for(const f of T(t,i,c)){if(f.br){a();continue}const m=r.length>0?h:0;if(n+m+f.widthMm<=e){r+=f.text,n+=m+f.widthMm;continue}if(f.space){a();continue}if(f.cjk){r.length>0&&a(),r=f.text,n=f.widthMm;continue}if(r.length>0&&a(),f.widthMm<=e){r=f.text,n=f.widthMm;continue}for(const l of f.text)c.measureMm(r+l,i)>e&&r.length>0&&a(),r+=l,n=c.measureMm(r,i)}return a(),u}exports.charWidthEm=d;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=p;exports.heuristicMeasurer=o;exports.measureTextMm=A;exports.wrapText=S;
@@ -878,6 +878,7 @@ declare interface MachReportDefaults {
878
878
  toolbar?: MachReportToolbarOptions;
879
879
  interaction?: ReportInteractionOptions;
880
880
  preferences?: ReportPreferencesOptions;
881
+ refresh?: ReportRefreshOptions;
881
882
  /** Protect local input and drafts before replacing a report. Default true. */
882
883
  guardChanges?: boolean;
883
884
  beforeDiscard?: ReportBeforeDiscard;
@@ -921,6 +922,7 @@ declare type MachReportLogger = Pick<Console, "warn" | "info">;
921
922
  */
922
923
  /** 工具栏与状态文案(默认简体中文;出海场景覆写) */
923
924
  declare interface MachReportMessages extends Partial<ReportCalculationMessages>, Partial<ReportDataReviewMessages>, ReportPrintMessages, ReportParamOptionsMessages {
925
+ previousSnapshot?: string;
924
926
  reviewTools?: string;
925
927
  validationTitle?: string;
926
928
  validationError?: string;
@@ -1013,6 +1015,20 @@ declare interface MachReportMessages extends Partial<ReportCalculationMessages>,
1013
1015
  importing?: string;
1014
1016
  editCell?: string;
1015
1017
  editingHint?: string;
1018
+ editCellEditable?: string;
1019
+ editCellReadOnly?: string;
1020
+ editCellFormula?: string;
1021
+ editCellProtected?: string;
1022
+ editCellComplex?: string;
1023
+ editCellStructure?: string;
1024
+ editCellDerived?: string;
1025
+ editCellPermission?: string;
1026
+ editCellBusy?: string;
1027
+ editHistoryLimited?: string;
1028
+ changesSearch?: string;
1029
+ changesAllDatasets?: string;
1030
+ changesNoMatches?: string;
1031
+ changesRange?: string;
1016
1032
  saving?: string;
1017
1033
  editInvalidNumber?: string;
1018
1034
  editInvalidBoolean?: string;
@@ -1129,6 +1145,8 @@ declare interface MachReportPreviewOptions {
1129
1145
  /** 只读快照,由组件的同一套状态驱动;无需通过事件另建状态。 */
1130
1146
  declare interface MachReportState {
1131
1147
  readonly loading: boolean;
1148
+ /** A retained previous snapshot is readable while writes/output remain blocked. */
1149
+ readonly stale?: boolean;
1132
1150
  readonly hasPlan: boolean;
1133
1151
  readonly pageCount: number;
1134
1152
  readonly currentPage: number;
@@ -1175,6 +1193,8 @@ declare interface MachReportTheme {
1175
1193
  btnActiveBg: string;
1176
1194
  }
1177
1195
  declare interface MachReportToolbarOptions {
1196
+ /** Reasons explain host restrictions without granting capabilities. */
1197
+ unavailableReasons?: Partial<Record<ReportPreviewTool, string>>;
1178
1198
  search?: boolean;
1179
1199
  thumbnails?: boolean;
1180
1200
  zoom?: boolean;
@@ -2062,11 +2082,21 @@ declare interface ReportEditConflict {
2062
2082
  currentValue?: ReportCellValue_2;
2063
2083
  revision?: string | number;
2064
2084
  }
2085
+ declare interface ReportEditHistoryOptions {
2086
+ /** Retained undo/redo transactions. Default 100. Zero disables undo retention. */
2087
+ maxSteps?: number;
2088
+ /** Conservative retained transaction size in bytes. Default 8 MiB. */
2089
+ maxBytes?: number;
2090
+ }
2065
2091
  /** Opt in with true for local drafts, or provide host validation and persistence. */
2066
2092
  declare interface ReportEditingOptions {
2067
2093
  /** Optional field controls, keyed by source.field / table.columnKey; a resolver supports dataset-specific rules. */
2068
2094
  fields?: Readonly<Record<string, ReportCellFieldOptions>> | ((context: ReportCellContext) => ReportCellFieldOptions | undefined);
2069
2095
  canEdit?(context: ReportCellContext): boolean;
2096
+ /** Optional explanation when canEdit rejects a cell. Does not grant editing access. */
2097
+ readOnlyReason?(context: ReportCellContext): string | undefined;
2098
+ /** Bounds undo/redo retention. Net differences and getChanges remain complete. */
2099
+ history?: ReportEditHistoryOptions;
2070
2100
  /** Return an error message or throw to reject the edit. */
2071
2101
  validate?(edit: Readonly<ReportCellEdit_2>, operation: ReportEditOperation): void | string | Promise<void | string>;
2072
2102
  /** Same declarative rules can be run in Node via validateReportDataset. Requires a source-backed session. */
@@ -2188,11 +2218,17 @@ declare interface ReportFetchInput extends ReportTaskMonitoring {
2188
2218
  onQueryResult?: (reportId: string, result: ReportQueryResult, reportIndex?: number) => void;
2189
2219
  }
2190
2220
  declare type ReportFieldAggregation = "sum" | "avg" | "min" | "max" | "count" | "none";
2221
+ declare type ReportFieldAggregation_2 = "sum" | "avg" | "min" | "max" | "count" | "none";
2191
2222
  declare interface ReportFieldCalculation {
2192
2223
  /** Business-owned explanation, never executable JavaScript or an inferred business formula. */
2193
2224
  description: string;
2194
2225
  dependsOn: readonly string[];
2195
2226
  }
2227
+ declare interface ReportFieldCalculation_2 {
2228
+ /** Business-owned explanation, never executable JavaScript or an inferred business formula. */
2229
+ description: string;
2230
+ dependsOn: readonly string[];
2231
+ }
2196
2232
  declare interface ReportFieldContract extends ReportFieldSemantics {
2197
2233
  field: string;
2198
2234
  label?: string;
@@ -2207,6 +2243,20 @@ declare interface ReportFieldContract extends ReportFieldSemantics {
2207
2243
  semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
2208
2244
  unit?: string;
2209
2245
  }
2246
+ declare interface ReportFieldContract_2 extends ReportFieldSemantics_2 {
2247
+ field: string;
2248
+ label?: string;
2249
+ type: "text" | "number" | "boolean" | "date" | "decimal";
2250
+ required?: boolean;
2251
+ nullable?: boolean;
2252
+ enum?: readonly (string | number | boolean)[];
2253
+ min?: number;
2254
+ max?: number;
2255
+ minLength?: number;
2256
+ maxLength?: number;
2257
+ semanticRole?: "identifier" | "dimension" | "measure" | "date" | "text";
2258
+ unit?: string;
2259
+ }
2210
2260
  declare interface ReportFieldSemantics {
2211
2261
  description?: string;
2212
2262
  /** Explicit meaning of null/missing; does not convert blanks into zero. */
@@ -2217,6 +2267,16 @@ declare interface ReportFieldSemantics {
2217
2267
  format?: ColumnFormat;
2218
2268
  calculation?: ReportFieldCalculation;
2219
2269
  }
2270
+ declare interface ReportFieldSemantics_2 {
2271
+ description?: string;
2272
+ /** Explicit meaning of null/missing; does not convert blanks into zero. */
2273
+ missingMeaning?: string;
2274
+ /** Recommended aggregation; none marks non-additive measures such as ratios. No aggregation runs implicitly. */
2275
+ aggregation?: ReportFieldAggregation_2;
2276
+ /** Shared presentation only; raw values and calculation precision remain unchanged. */
2277
+ format?: ColumnFormat_3;
2278
+ calculation?: ReportFieldCalculation_2;
2279
+ }
2220
2280
  declare interface ReportFieldTarget {
2221
2281
  field: string;
2222
2282
  datasetId?: string;
@@ -2410,8 +2470,8 @@ declare type ReportPredicateScalar = string | number | boolean | null;
2410
2470
  declare type ReportPredicateScalar_2 = string | number | boolean | null;
2411
2471
  declare type ReportPredicateScalar_3 = string | number | boolean | null;
2412
2472
  declare interface ReportPreferencesAdapter {
2413
- load(key: string): Partial<ReportPreviewPreferences> | null | Promise<Partial<ReportPreviewPreferences> | null>;
2414
- save(key: string, value: Readonly<Partial<ReportPreviewPreferences>>): void | Promise<void>;
2473
+ load(key: string): ReportStoredPreferences | null | Promise<ReportStoredPreferences | null>;
2474
+ save(key: string, value: Readonly<ReportStoredPreferences>): void | Promise<void>;
2415
2475
  remove?(key: string): void | Promise<void>;
2416
2476
  }
2417
2477
  declare interface ReportPreferencesOptions {
@@ -2509,6 +2569,17 @@ declare interface ReportQueryResult {
2509
2569
  sourceToken?: string;
2510
2570
  diagnostics?: ReportDiagnostic[];
2511
2571
  }
2572
+ /** Explicit refresh policy. The key identifies template/layout revisions outside query parameters. */
2573
+ declare interface ReportRefreshOptions {
2574
+ retainPrevious?: boolean;
2575
+ key?: string;
2576
+ /** Host API request preceding the preview reload. Blocks edits and output without discarding drafts. */
2577
+ pending?: boolean;
2578
+ /** The host retained an earlier snapshot after its own query failed or was cancelled. */
2579
+ stale?: boolean;
2580
+ /** Retry the host HTTP query when it owns the stale snapshot. The host updates its own state. */
2581
+ retry?(): void | Promise<void>;
2582
+ }
2512
2583
  declare type ReportRegistry = Record<string, ReportDefinition>;
2513
2584
  declare interface ReportRuntimeBudget {
2514
2585
  maxRows?: number;
@@ -2538,6 +2609,10 @@ declare interface ReportSaveResult {
2538
2609
  }>;
2539
2610
  diagnostics?: ReportDiagnostic[];
2540
2611
  }
2612
+ declare interface ReportStoredPreferences extends Partial<ReportPreviewPreferences> {
2613
+ zoomMode?: "fit" | number;
2614
+ wideZoomMode?: "fit" | number;
2615
+ }
2541
2616
  /** 阶段事件只包含可序列化值;不表示估算百分比,也不包含业务数据。 */
2542
2617
  declare interface ReportTaskEvent {
2543
2618
  taskId: string;
@@ -2556,6 +2631,8 @@ declare interface ReportTaskMonitoring {
2556
2631
  declare type ReportTaskObserver = (event: ReportTaskEvent) => void;
2557
2632
  declare interface ReportTemplate {
2558
2633
  schemaVersion?: string;
2634
+ /** Optional source identity and stable field meanings for safe stored-template reuse. */
2635
+ dataContract?: ReportTemplateDataContract;
2559
2636
  /** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
2560
2637
  params?: ReportParamDef[];
2561
2638
  /** Fixed label pages repeat in record → copy → template-page order. */
@@ -2564,12 +2641,28 @@ declare interface ReportTemplate {
2564
2641
  }
2565
2642
  declare interface ReportTemplate_2 {
2566
2643
  schemaVersion?: string;
2644
+ /** Optional source identity and stable field meanings for safe stored-template reuse. */
2645
+ dataContract?: ReportTemplateDataContract_2;
2567
2646
  /** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
2568
2647
  params?: ReportParamDef_2[];
2569
2648
  /** Fixed label pages repeat in record → copy → template-page order. */
2570
2649
  repeat?: ReportTemplateRepeat_2;
2571
2650
  pages: TemplatePage_2[];
2572
2651
  }
2652
+ declare interface ReportTemplateDataContract {
2653
+ /** Host-owned report/domain identity, without a query date or tenant credentials. */
2654
+ source?: string;
2655
+ datasets: Readonly<Record<string, {
2656
+ fields: readonly ReportTemplateFieldBinding[];
2657
+ }>>;
2658
+ }
2659
+ declare interface ReportTemplateDataContract_2 {
2660
+ /** Host-owned report/domain identity, without a query date or tenant credentials. */
2661
+ source?: string;
2662
+ datasets: Readonly<Record<string, {
2663
+ fields: readonly ReportTemplateFieldBinding_2[];
2664
+ }>>;
2665
+ }
2573
2666
  /** 可存入数据库/文件的纯 JSON 模板;数据、接口与鉴权仍由宿主提供。 */
2574
2667
  declare interface ReportTemplateDocument {
2575
2668
  schemaVersion: "1.0";
@@ -2580,6 +2673,22 @@ declare interface ReportTemplateDocument {
2580
2673
  description?: string;
2581
2674
  template: ReportTemplate;
2582
2675
  }
2676
+ /** Stable business meaning is independent of a column's position and editable caption. */
2677
+ declare interface ReportTemplateFieldBinding {
2678
+ field: string;
2679
+ label?: string;
2680
+ semanticKey?: string;
2681
+ type?: ReportFieldContract["type"];
2682
+ unit?: string;
2683
+ }
2684
+ /** Stable business meaning is independent of a column's position and editable caption. */
2685
+ declare interface ReportTemplateFieldBinding_2 {
2686
+ field: string;
2687
+ label?: string;
2688
+ semanticKey?: string;
2689
+ type?: ReportFieldContract_2["type"];
2690
+ unit?: string;
2691
+ }
2583
2692
  declare type ReportTemplateLoader = (context: ReportLoadContext) => ReportTemplate | Promise<ReportTemplate>;
2584
2693
  declare interface ReportTemplateProvider {
2585
2694
  list(context: {
@@ -2800,6 +2909,12 @@ declare type ValueFormat = ColumnFormat;
2800
2909
  declare type ValueFormat_2 = ColumnFormat_2;
2801
2910
  /** The same declarative formatting used by list columns, before any output backend. */
2802
2911
  declare type ValueFormat_3 = ColumnFormat_3;
2912
+ /** 可序列化的附加工作表在编码前写入,浏览器与 Worker 共用同一声明。 */
2913
+ declare interface XlsxAdditionalSheet {
2914
+ name: string;
2915
+ rows: readonly (readonly (string | number | boolean | null)[])[];
2916
+ columnWidths?: readonly number[];
2917
+ }
2803
2918
  declare type XlsxImageOptions = ImageMediaOptions_2;
2804
2919
  /**
2805
2920
  * RenderPlan → xlsx 导出(B 端第二出口,对齐家族 @agile-team/mach-table-xlsx 路线):
@@ -2812,6 +2927,8 @@ declare type XlsxImageOptions = ImageMediaOptions_2;
2812
2927
  declare interface XlsxRenderOptions extends AssetRenderOptions_2, XlsxImageOptions {
2813
2928
  /** 工作表命名(连续表默认使用标题,其余默认 "Sheet1" 起序)。 */
2814
2929
  sheetName?: (sheetIndex: number) => string;
2930
+ /** 可序列化命名,用于 Worker;未提供的项沿用默认名称。 */
2931
+ sheetNames?: readonly string[];
2815
2932
  /** auto 默认将 wide 逻辑表合并为连续 Sheet;pages 保留逐页;continuous 要求明确的表来源。 */
2816
2933
  sheetMode?: "auto" | "pages" | "continuous";
2817
2934
  /** 宽表或连续表默认 raw,其余默认 text;显式配置可覆盖默认值。 */
@@ -2820,5 +2937,7 @@ declare interface XlsxRenderOptions extends AssetRenderOptions_2, XlsxImageOptio
2820
2937
  maxDataBars?: number;
2821
2938
  /** 连续表默认不限制打印纸型;显式 A3/A4/A5 仅设置打印适配,不改变 Excel 列宽。 */
2822
2939
  paperSize?: "auto" | "a3" | "a4" | "a5";
2940
+ /** 在最终编码前追加说明、审计等标量工作表,可直接交给 Worker。 */
2941
+ additionalSheets?: readonly XlsxAdditionalSheet[];
2823
2942
  }
2824
2943
  export {};