@agile-team/mach-report 2.9.1 → 2.11.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 (115) hide show
  1. package/README.md +11 -7
  2. package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
  4. package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
  5. package/dist/ParamEditor-DRGxzxeO.js +381 -0
  6. package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
  7. package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +4 -0
  18. package/dist/analytics.d.ts +4 -0
  19. package/dist/analytics.js +40 -39
  20. package/dist/{assets-ahTRUXRk.cjs → assets-Bu6UohJx.cjs} +1 -1
  21. package/dist/{assets-DDsfEi8R.js → assets-DegqDNqY.js} +1 -1
  22. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  23. package/dist/batch-mRqhhhjt.js +364 -0
  24. package/dist/{capabilities-Cm9hZ3uV.js → capabilities-CK_7hizc.js} +16 -16
  25. package/dist/capabilities-CsZ-pNHR.cjs +1 -0
  26. package/dist/computed-Bvk0W15F.js +521 -0
  27. package/dist/computed-CGV2a809.cjs +1 -0
  28. package/dist/config-B612mw0x.js +525 -0
  29. package/dist/config-BRoLo2oj.cjs +1 -0
  30. package/dist/designer.cjs +2 -2
  31. package/dist/designer.d.cts +695 -50
  32. package/dist/designer.d.ts +695 -50
  33. package/dist/designer.js +2213 -1748
  34. package/dist/index.cjs +8 -8
  35. package/dist/index.d.cts +205 -6
  36. package/dist/index.d.ts +205 -6
  37. package/dist/index.js +808 -1033
  38. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  39. package/dist/injection-keys-e85udZCp.js +7 -0
  40. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  41. package/dist/list-cell-ClFra1zS.js +173 -0
  42. package/dist/matrix-DVyWiYsd.cjs +1 -0
  43. package/dist/matrix-yZsGnldA.js +227 -0
  44. package/dist/param-validation-BlHHXs6u.js +153 -0
  45. package/dist/param-validation-DCK039V1.cjs +1 -0
  46. package/dist/pdf.cjs +49 -49
  47. package/dist/pdf.d.cts +31 -1
  48. package/dist/pdf.d.ts +31 -1
  49. package/dist/pdf.js +4797 -4650
  50. package/dist/plugin-BDTU4D94.cjs +1 -0
  51. package/dist/plugin-Cd5G2QQn.js +22 -0
  52. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  53. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  54. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  55. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  56. package/dist/server/node.d.cts +48 -5
  57. package/dist/server/node.d.ts +48 -5
  58. package/dist/server-node.cjs +1 -1
  59. package/dist/server-node.js +503 -317
  60. package/dist/server.cjs +1 -1
  61. package/dist/server.d.cts +252 -4
  62. package/dist/server.d.ts +252 -4
  63. package/dist/server.js +567 -469
  64. package/dist/style.css +1 -1
  65. package/dist/template-registry-WNXdkiET.js +506 -0
  66. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  67. package/dist/template-review-BXp2oyqg.cjs +1 -0
  68. package/dist/template-review-BdcXSYbx.js +1616 -0
  69. package/dist/tree-BX380Rr7.cjs +1 -0
  70. package/dist/tree-CqcQ99NM.js +172 -0
  71. package/dist/useLocalDraft-C07SYRnC.js +11 -0
  72. package/dist/useLocalDraft-Yiw1wFgI.cjs +1 -0
  73. package/dist/{validate-DWPF7icl.js → validate-7s0yn6ii.js} +26 -26
  74. package/dist/validate-DsRiNw8h.cjs +1 -0
  75. package/dist/vue/async.d.cts +118 -6
  76. package/dist/vue/async.d.ts +118 -6
  77. package/dist/vue/index.d.cts +177 -11
  78. package/dist/vue/index.d.ts +177 -11
  79. package/dist/vue-async.cjs +1 -1
  80. package/dist/vue-async.js +5 -5
  81. package/dist/vue.cjs +1 -1
  82. package/dist/vue.js +116 -113
  83. package/dist/{import-template-CNMLJSQw.js → workbook-session-BKOTwcoq.js} +4290 -4227
  84. package/dist/{import-template-CpxunKVp.cjs → workbook-session-CLYLhZWu.cjs} +17 -17
  85. package/dist/worker.cjs +1 -1
  86. package/dist/worker.d.cts +9 -2
  87. package/dist/worker.d.ts +9 -2
  88. package/dist/worker.js +1 -1
  89. package/dist/xlsx.cjs +4 -2
  90. package/dist/xlsx.d.cts +159 -3
  91. package/dist/xlsx.d.ts +159 -3
  92. package/dist/xlsx.js +354 -192
  93. package/package.json +1 -1
  94. package/dist/ExcelBindingWizard-DiaxvWpQ.cjs +0 -1
  95. package/dist/ExcelBindingWizard-RLJIXKKG.js +0 -816
  96. package/dist/ReportPreview-B5ZNEasW.js +0 -4439
  97. package/dist/ReportPreview-DRtVPUYo.cjs +0 -6
  98. package/dist/RuleEditor-CskN5Fr3.cjs +0 -1
  99. package/dist/RuleEditor-CtJFzKuY.js +0 -1578
  100. package/dist/TemplateReviewPanel-C_Lmzis6.cjs +0 -1
  101. package/dist/TemplateReviewPanel-Cn32OY4_.js +0 -173
  102. package/dist/binding-preview-B5834rml.cjs +0 -2
  103. package/dist/binding-preview-ChXjN5L5.js +0 -649
  104. package/dist/capabilities-DYzWL7KS.cjs +0 -1
  105. package/dist/matrix-CNPDJxED.js +0 -745
  106. package/dist/matrix-Div9Ilh3.cjs +0 -1
  107. package/dist/param-validation-BWNjLcN0.js +0 -116
  108. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  109. package/dist/plugin-BWwIgZXV.js +0 -25
  110. package/dist/plugin-Dg-J1Rbm.cjs +0 -1
  111. package/dist/template-registry-CHMYZ7SD.cjs +0 -1
  112. package/dist/template-registry-R61AMCr0.js +0 -433
  113. package/dist/template-review-hvWWQFsi.js +0 -1027
  114. package/dist/template-review-jEcOfmGr.cjs +0 -1
  115. package/dist/validate-BDiMqkJC.cjs +0 -1
@@ -1,433 +0,0 @@
1
- import { v as T, o as V, e as D } from "./matrix-CNPDJxED.js";
2
- import { R as J } from "./render-plan-Ck6koX9L.js";
3
- import { v as O, d as C } from "./validate-DWPF7icl.js";
4
- import { v as F, i as I } from "./param-validation-BWNjLcN0.js";
5
- function x(e) {
6
- return !!e && typeof e == "object" && !Array.isArray(e);
7
- }
8
- function S(e, s, t) {
9
- if (e !== void 0) {
10
- if (!x(e)) {
11
- t.push({ path: s, message: "条件应为对象" });
12
- return;
13
- }
14
- (typeof e.field != "string" || !e.field.trim()) && t.push({ path: `${s}.field`, message: "条件需要字段" }), e.numeric !== void 0 && e.numeric !== "number" && e.numeric !== "decimal" && t.push({ path: `${s}.numeric`, message: "未知条件数值模式" }), [">", ">=", "<", "<=", "==", "!="].includes(e.op) || t.push({ path: `${s}.op`, message: "未知条件运算符" }), typeof e.value != "string" && !(typeof e.value == "number" && Number.isFinite(e.value)) && t.push({
15
- path: `${s}.value`,
16
- message: "条件值应为字符串或有限数字"
17
- });
18
- }
19
- }
20
- function L(e, s, t) {
21
- if (e === void 0) return;
22
- if (!Array.isArray(e) || e.length > 2048) {
23
- t.push({ path: s, message: "聚合应为数组且最多 2048 项" });
24
- return;
25
- }
26
- const i = /* @__PURE__ */ new Set();
27
- e.forEach((n, a) => {
28
- const f = `${s}.${a}`;
29
- if (!x(n)) {
30
- t.push({ path: f, message: "聚合应为对象" });
31
- return;
32
- }
33
- const o = n.field;
34
- typeof o != "string" || !o.trim() || i.has(o) ? t.push({
35
- path: `${f}.field`,
36
- message: "聚合输出字段应非空且唯一"
37
- }) : i.add(o), n.numeric !== void 0 && n.numeric !== "number" && n.numeric !== "decimal" && t.push({
38
- path: `${f}.numeric`,
39
- message: "数值模式应为 number 或 decimal"
40
- }), n.digits !== void 0 && (!Number.isInteger(n.digits) || Number(n.digits) < 0 || Number(n.digits) > 100) && t.push({
41
- path: `${f}.digits`,
42
- message: "小数位应为 0–100 的整数"
43
- });
44
- try {
45
- D({
46
- ...n,
47
- field: n.valueField ?? o
48
- });
49
- } catch (m) {
50
- t.push({
51
- path: f,
52
- message: m instanceof Error ? m.message : String(m)
53
- });
54
- }
55
- });
56
- }
57
- function j(e, s, t) {
58
- if (e === void 0) return;
59
- const i = T(e);
60
- for (const n of i.errors) t.push({ path: s, message: n });
61
- }
62
- function H(e, s, t) {
63
- if (e !== void 0)
64
- try {
65
- V(e);
66
- } catch (i) {
67
- t.push({
68
- path: s,
69
- message: i instanceof Error ? i.message : String(i)
70
- });
71
- }
72
- }
73
- const R = "1.0";
74
- class $ extends Error {
75
- constructor(s) {
76
- super(`模板校验失败:${s.slice(0, 3).map((t) => `${t.path}: ${t.message}`).join("; ")}`), this.errors = s, this.name = "ReportTemplateError";
77
- }
78
- }
79
- const W = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), U = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), K = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), M = 2e5, G = 64, v = 1e7;
80
- function u(e) {
81
- return !!e && typeof e == "object" && !Array.isArray(e);
82
- }
83
- function Y(e, s, t) {
84
- const i = Object.getPrototypeOf(e), n = Array.isArray(e);
85
- if (n ? i !== Array.prototype : i !== Object.prototype && i !== null)
86
- return t.push({ path: s, message: "模板对象必须使用普通 JSON 对象原型" }), !1;
87
- if (n) {
88
- const a = Object.keys(e);
89
- if (a.length !== e.length || a.some((f) => !/^(0|[1-9]\d*)$/.test(f) || Number(f) >= e.length))
90
- return t.push({ path: s, message: "模板数组不能包含空位或额外属性" }), !1;
91
- }
92
- return Object.getOwnPropertySymbols(e).length > 0 ? (t.push({ path: s, message: "模板不能包含 Symbol 键" }), !1) : !0;
93
- }
94
- function z(e, s, t, i) {
95
- return W.has(e) ? (i.push({ path: t, message: "模板不能包含可能污染原型的键" }), !1) : s.get || s.set || !s.enumerable ? (i.push({ path: t, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
96
- }
97
- function X(e) {
98
- return e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e);
99
- }
100
- function E(e, s) {
101
- const t = /* @__PURE__ */ new Set();
102
- let i = 0, n = 0, a = !1;
103
- const f = (o, m, h) => {
104
- if (!a) {
105
- if (++i > M) {
106
- i === M + 1 && s.push({ path: m, message: "模板超过 JSON 节点安全上限" });
107
- return;
108
- }
109
- if (h > G) {
110
- s.push({ path: m, message: "模板嵌套层级过深" });
111
- return;
112
- }
113
- if (typeof o == "string") {
114
- n += o.length, n > v && (a = !0, s.push({ path: m, message: "模板文本超过 1000 万字符的安全上限" }));
115
- return;
116
- }
117
- if (!X(o)) {
118
- if (!o || typeof o != "object") {
119
- s.push({ path: m, message: "模板只允许 JSON 值,不允许函数、undefined 或非有限数字" });
120
- return;
121
- }
122
- if (t.has(o)) {
123
- s.push({ path: m, message: "模板不能包含循环引用" });
124
- return;
125
- }
126
- if (Y(o, m, s)) {
127
- t.add(o);
128
- for (const [d, l] of Object.entries(Object.getOwnPropertyDescriptors(o))) {
129
- if (Array.isArray(o) && d === "length") continue;
130
- const p = `${m}.${d}`;
131
- if (z(d, l, p, s) && f(l.value, p, h + 1), i > M || a) break;
132
- }
133
- t.delete(o);
134
- }
135
- }
136
- }
137
- };
138
- f(e, "$", 0);
139
- }
140
- function g(e, s, t, i, n = !1) {
141
- const a = e[s];
142
- a === void 0 && !n || (typeof a != "string" || n && !a.trim()) && i.push({ path: `${t}.${s}`, message: n ? "应为非空字符串" : "应为字符串" });
143
- }
144
- function r(e, s, t, i, n = 0, a = !1) {
145
- const f = e[s];
146
- f === void 0 && !a || (typeof f != "number" || !Number.isFinite(f) || f < n) && i.push({ path: `${t}.${s}`, message: `应为大于等于 ${n} 的有限数字` });
147
- }
148
- function y(e, s, t, i) {
149
- e[s] !== void 0 && typeof e[s] != "boolean" && i.push({ path: `${t}.${s}`, message: "应为布尔值" });
150
- }
151
- function b(e, s, t, i = !1) {
152
- e !== void 0 && !K.has(e) && !(i && e === "auto") && t.push({ path: s, message: `未知对齐方式${i ? "(支持 auto)" : ""}` });
153
- }
154
- function c(e, s, t) {
155
- if (e !== void 0) {
156
- if (!u(e)) {
157
- t.push({ path: s, message: "样式应为对象" });
158
- return;
159
- }
160
- b(e.align, `${s}.align`, t), e.verticalAlign !== void 0 && !["top", "middle", "bottom"].includes(e.verticalAlign) && t.push({ path: `${s}.verticalAlign`, message: "未知垂直对齐方式" });
161
- for (const i of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) r(e, i, s, t);
162
- for (const i of ["letterSpacing", "rotateDeg"]) r(e, i, s, t, -1 / 0);
163
- r(e, "opacity", s, t), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${s}.opacity`, message: "透明度不能大于 1" });
164
- for (const i of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) y(e, i, s, t);
165
- for (const i of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) g(e, i, s, t);
166
- }
167
- }
168
- function B(e, s, t) {
169
- if (e === void 0) return;
170
- if (!Array.isArray(e)) {
171
- t.push({ path: s, message: "参数定义应为数组" });
172
- return;
173
- }
174
- const i = /* @__PURE__ */ new Set(), n = t.length;
175
- e.forEach((a, f) => {
176
- const o = `${s}.${f}`;
177
- if (!u(a)) {
178
- t.push({ path: o, message: "参数定义应为对象" });
179
- return;
180
- }
181
- g(a, "field", o, t, !0), typeof a.field == "string" && (i.has(a.field) && t.push({ path: `${o}.field`, message: "参数名重复" }), i.add(a.field)), a.type !== void 0 && !["text", "number", "date", "select"].includes(a.type) && t.push({ path: `${o}.type`, message: "未知参数类型" });
182
- for (const m of ["label", "defaultValue", "placeholder"]) g(a, m, o, t);
183
- y(a, "required", o, t);
184
- for (const m of ["minLength", "maxLength"]) {
185
- const h = a[m];
186
- h !== void 0 && (typeof h != "number" || !Number.isSafeInteger(h) || h < 0) && t.push({ path: `${o}.${m}`, message: "长度边界应为非负整数" });
187
- }
188
- Q(a, o, t), a.options !== void 0 && (Array.isArray(a.options) ? a.options.forEach((m, h) => {
189
- const d = `${o}.options.${h}`;
190
- if (!u(m)) t.push({ path: d, message: "选项应为对象" });
191
- else
192
- for (const l of ["label", "value"]) typeof m[l] != "string" && t.push({ path: `${d}.${l}`, message: "选项标签与值应为字符串(允许空白选项)" });
193
- }) : t.push({ path: `${o}.options`, message: "选项应为数组" }));
194
- }), t.length === n && t.push(...F(e).map((a) => ({ path: a.path.replace("$.paramDefs", s), message: a.message })));
195
- }
196
- function Q(e, s, t) {
197
- for (const a of ["min", "max"]) {
198
- const f = e[a];
199
- if (f === void 0) continue;
200
- (e.type === "date" ? typeof f == "string" && I(f) : e.type === "number" && typeof f == "number" && Number.isFinite(f)) || t.push({ path: `${s}.${a}`, message: "number 使用有限数字边界,date 使用有效 YYYY-MM-DD 日期边界" });
201
- }
202
- const i = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, n = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
203
- (i || n) && t.push({ path: s, message: "最小边界不能大于最大边界" }), typeof e.minLength == "number" && typeof e.maxLength == "number" && e.minLength > e.maxLength && t.push({ path: s, message: "最小长度不能大于最大长度" });
204
- }
205
- function _(e, s, t) {
206
- if (!Array.isArray(e) || e.length === 0) {
207
- t.push({ path: s, message: "列表至少需要一列" });
208
- return;
209
- }
210
- e.every((i) => u(i) && i.hidden === !0) && t.push({ path: s, message: "列表至少需要一列可见列" }), e.forEach((i, n) => {
211
- const a = `${s}.${n}`;
212
- if (!u(i)) {
213
- t.push({ path: a, message: "列应为对象" });
214
- return;
215
- }
216
- if (C(i, a, t), y(i, "hidden", a, t), S(i.visibleWhen, `${a}.visibleWhen`, t), typeof i.header != "string" && t.push({ path: `${a}.header`, message: "表头应为字符串(允许空白表头)" }), g(i, "field", a, t, !0), r(i, "widthMm", a, t, Number.MIN_VALUE, !0), c(i.style, `${a}.style`, t), c(i.headerStyle, `${a}.headerStyle`, t), b(i.align, `${a}.align`, t, !0), b(i.headerAlign, `${a}.headerAlign`, t), i.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(i.semanticRole) && t.push({ path: `${a}.semanticRole`, message: "未知列语义" }), i.format !== void 0)
217
- if (!u(i.format) || !["number", "percent", "date"].includes(i.format.kind))
218
- t.push({ path: `${a}.format`, message: "未知列格式" });
219
- else {
220
- const f = i.format.digits;
221
- f !== void 0 && (typeof f != "number" || !Number.isInteger(f) || f < 0 || f > 100) && t.push({ path: `${a}.format.digits`, message: "小数位应为 0–100 的整数" }), y(i.format, "thousands", `${a}.format`, t), g(i.format, "pattern", `${a}.format`, t);
222
- }
223
- i.rules !== void 0 && (Array.isArray(i.rules) ? i.rules.forEach((f, o) => {
224
- const m = `${a}.rules.${o}`;
225
- if (!u(f) || !u(f.when)) {
226
- t.push({ path: m, message: "条件格式缺少 when 对象" });
227
- return;
228
- }
229
- S(f.when, `${m}.when`, t), g(f.when, "field", `${m}.when`, t, !0), [">", ">=", "<", "<=", "==", "!="].includes(f.when.op) || t.push({ path: `${m}.when.op`, message: "未知条件运算符" }), typeof f.when.value != "number" && typeof f.when.value != "string" && t.push({ path: `${m}.when.value`, message: "条件值应为数字或字符串" }), c(f.style, `${m}.style`, t);
230
- }) : t.push({ path: `${a}.rules`, message: "条件格式应为数组" }));
231
- });
232
- }
233
- function P(e, s, t) {
234
- if (e !== void 0) {
235
- if (!u(e)) {
236
- t.push({ path: s, message: "分组应为对象" });
237
- return;
238
- }
239
- g(e, "field", s, t, !0);
240
- for (const i of ["headerTemplate", "subtotalLabel"]) g(e, i, s, t);
241
- for (const i of ["headerStyle", "subtotalStyle"]) c(e[i], `${s}.${i}`, t);
242
- y(e, "keepWithNext", s, t), y(e, "repeatHeader", s, t), L(e.aggregates, `${s}.aggregates`, t), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((i) => typeof i != "string")) && t.push({ path: `${s}.subtotal`, message: "小计字段应为字符串数组" });
243
- }
244
- }
245
- function Z(e, s, t) {
246
- if (!(e === void 0 || typeof e == "boolean")) {
247
- if (!u(e)) {
248
- t.push({ path: s, message: "合计应为布尔值或对象" });
249
- return;
250
- }
251
- g(e, "label", s, t), L(e.aggregates, `${s}.aggregates`, t), c(e.style, `${s}.style`, t), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((i) => typeof i != "string")) && t.push({ path: `${s}.fields`, message: "合计字段应为字符串数组" });
252
- }
253
- }
254
- function q(e, s, t, i) {
255
- const n = { kind: "rect", leftMm: 0, topMm: 0, widthMm: 1, heightMm: 1, grid: e };
256
- if (O(n, t, i, []), k(n, t, i), !u(e) || !Array.isArray(e.cells)) return;
257
- const a = e.cells, f = Array.isArray(s) ? s.length : 0;
258
- if (a.length * f > M) {
259
- i.push({ path: t, message: "表头逻辑网格超过 20 万格安全上限" });
260
- return;
261
- }
262
- e.cells.length || i.push({ path: `${t}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== f && i.push({ path: `${t}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && i.push({ path: `${t}.rowHeightsMm`, message: "表头行高数量应与行数一致" }), ee(a, f, t, i);
263
- }
264
- function ee(e, s, t, i) {
265
- const n = /* @__PURE__ */ new Set();
266
- e.forEach((a, f) => {
267
- if (!Array.isArray(a)) return;
268
- let o = 0;
269
- a.forEach((m, h) => {
270
- for (; n.has(`${f}:${o}`); ) o++;
271
- const d = u(m) && typeof m.colSpan == "number" ? m.colSpan : 1, l = u(m) && typeof m.rowSpan == "number" ? m.rowSpan : 1;
272
- (o + d > s || f + l > e.length) && i.push({ path: `${t}.cells.${f}.${h}`, message: "表头合并区域超出表头边界" });
273
- for (let p = f; p < Math.min(e.length, f + l); p++)
274
- for (let A = o; A < Math.min(s, o + d); A++)
275
- n.has(`${p}:${A}`) && i.push({ path: `${t}.cells.${f}.${h}`, message: "表头合并区域重叠" }), n.add(`${p}:${A}`);
276
- o += d;
277
- });
278
- });
279
- }
280
- function te(e, s, t) {
281
- if (j(e.computed, `${s}.computed`, t), H(e.matrix, `${s}.matrix`, t), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && t.push({ path: `${s}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), S(e.rowVisibleWhen, `${s}.rowVisibleWhen`, t), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? t.push({ path: `${s}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((a, f) => P(a, `${s}.groups.${f}`, t))), e.detail === void 0) return;
282
- const i = e.detail, n = `${s}.detail`;
283
- if (!u(i)) {
284
- t.push({ path: n, message: "主从关联应为对象" });
285
- return;
286
- }
287
- for (const a of ["dataset", "parentKey", "foreignKey"]) g(i, a, n, t, !0);
288
- g(i, "rowKey", n, t, i.rowKey !== void 0), g(i, "label", n, t), y(i, "header", n, t), r(i, "rowHeightMm", n, t, Number.MIN_VALUE), _(i.columns, `${n}.columns`, t), i.unmatched !== void 0 && i.unmatched !== "error" && i.unmatched !== "ignore" && t.push({ path: `${n}.unmatched`, message: "未关联明细策略应为 error 或 ignore" });
289
- }
290
- function se(e, s, t) {
291
- for (const i of ["leftMm", "topMm"]) r(e, i, s, t, -1 / 0, !0);
292
- r(e, "widthMm", s, t, Number.MIN_VALUE, !0), g(e, "dataset", s, t, !0), g(e, "title", s, t);
293
- for (const i of ["rowKey", "revisionField", "sourceTokenField"]) g(e, i, s, t, e[i] !== void 0);
294
- e.headerGrid !== void 0 && q(e.headerGrid, e.columns, `${s}.headerGrid`, t), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${s}.layout`, message: "布局应为 page 或 wide" }), _(e.columns, `${s}.columns`, t);
295
- for (const i of ["fontSizePt", "rowHeightMm"]) r(e, i, s, t, Number.MIN_VALUE);
296
- r(e, "paddingMm", s, t);
297
- for (const i of ["headerBold", "headerEveryPage", "border"]) y(e, i, s, t);
298
- g(e, "headerBackgroundColor", s, t), b(e.align, `${s}.align`, t, !0), b(e.headerAlign, `${s}.headerAlign`, t), c(e.headerStyle, `${s}.headerStyle`, t), te(e, s, t), P(e.groupBy, `${s}.groupBy`, t), Z(e.grandTotal, `${s}.grandTotal`, t);
299
- }
300
- function k(e, s, t) {
301
- c(e.style, `${s}.style`, t);
302
- for (const n of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) g(e, n, s, t);
303
- if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((n) => typeof n != "string")) && t.push({ path: `${s}.lines`, message: "文本行应为字符串数组" }), Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((n, a) => {
304
- if (!u(n)) return;
305
- const f = `${s}.richParagraphs.${a}`;
306
- b(n.align, `${f}.align`, t);
307
- for (const o of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) r(n, o, f, t);
308
- Array.isArray(n.segments) && n.segments.forEach((o, m) => {
309
- const h = `${f}.segments.${m}`;
310
- if (!u(o)) {
311
- t.push({ path: h, message: "富文本片段应为对象" });
312
- return;
313
- }
314
- o.kind !== void 0 && o.kind !== "text" && o.kind !== "field" && t.push({ path: `${h}.kind`, message: "未知富文本片段类型" });
315
- for (const d of ["text", "field"]) g(o, d, h, t);
316
- c(o.style, `${h}.style`, t);
317
- });
318
- }), !u(e.grid)) return;
319
- const i = e.grid;
320
- r(i, "gapMm", `${s}.grid`, t), r(i, "paddingMm", `${s}.grid`, t);
321
- for (const n of ["colWidthsMm", "rowHeightsMm"]) {
322
- const a = i[n];
323
- a !== void 0 && (!Array.isArray(a) || a.some((f) => typeof f != "number" || !Number.isFinite(f) || f < 0)) && t.push({ path: `${s}.grid.${n}`, message: "网格尺寸应为有限非负数字数组" });
324
- }
325
- Array.isArray(i.cells) && i.cells.forEach((n, a) => {
326
- Array.isArray(n) && n.forEach((f, o) => {
327
- const m = `${s}.grid.cells.${a}.${o}`;
328
- if (f !== null) {
329
- if (!u(f)) {
330
- t.push({ path: m, message: "网格单元格应为对象或 null" });
331
- return;
332
- }
333
- for (const h of ["text", "rawText", "numberFormat"]) g(f, h, m, t);
334
- for (const h of ["colSpan", "rowSpan"]) {
335
- const d = f[h];
336
- d !== void 0 && (typeof d != "number" || !Number.isInteger(d) || d <= 0) && t.push({ path: `${m}.${h}`, message: "跨度应为正整数" });
337
- }
338
- f.value !== void 0 && f.value !== null && !["string", "number", "boolean"].includes(typeof f.value) && t.push({ path: `${m}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), c(f.style, `${m}.style`, t), f.children !== void 0 && (Array.isArray(f.children) ? f.children.forEach((h, d) => {
339
- u(h) && k(h, `${m}.children.${d}`, t);
340
- }) : t.push({ path: `${m}.children`, message: "嵌套组件应为数组" }));
341
- }
342
- });
343
- });
344
- }
345
- function ie(e) {
346
- const s = [], t = [];
347
- return E(e, s), s.length ? { ok: !1, errors: s, warnings: t } : (u(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== J && s.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), B(e.params, "$.params", s), !Array.isArray(e.pages) || e.pages.length === 0 ? s.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((i, n) => {
348
- const a = `$.pages.${n}`;
349
- if (!u(i)) {
350
- s.push({ path: a, message: "页应为对象" });
351
- return;
352
- }
353
- r(i, "widthMm", a, s, Number.MIN_VALUE, !0), r(i, "heightMm", a, s, Number.MIN_VALUE, !0), i.layout !== void 0 && i.layout !== "page" && i.layout !== "wide" && s.push({ path: `${a}.layout`, message: "布局应为 page 或 wide" }), typeof i.heightMm == "number" && i.heightMm >= 5e3 && s.push({ path: `${a}.heightMm`, message: "页高应小于 5000mm" });
354
- for (const f of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) r(i, f, a, s);
355
- typeof i.widthMm == "number" && Number(i.marginLeftMm ?? 0) + Number(i.marginRightMm ?? 0) >= i.widthMm && s.push({ path: a, message: "横向页边距占满页面" }), typeof i.heightMm == "number" && Number(i.marginTopMm ?? 0) + Number(i.marginBottomMm ?? 0) >= i.heightMm && s.push({ path: a, message: "纵向页边距占满页面" }), Array.isArray(i.components) ? i.components.forEach((f, o) => {
356
- const m = `${a}.components.${o}`;
357
- u(f) && f.kind === "list" ? se(f, m, s) : (O(f, m, s, t), u(f) && k(f, m, s));
358
- }) : s.push({ path: `${a}.components`, message: "组件应为数组" });
359
- })) : s.push({ path: "$", message: "模板应为对象" }), { ok: s.length === 0, errors: s, warnings: t });
360
- }
361
- function ne(e) {
362
- const s = [], t = [];
363
- if (E(e, s), s.length) return { ok: !1, errors: s, warnings: t };
364
- if (!u(e)) s.push({ path: "$", message: "模板文档应为对象" });
365
- else {
366
- for (const n of Object.keys(e))
367
- U.has(n) || s.push({ path: `$.${n}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
368
- e.schemaVersion !== R && s.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
369
- for (const n of ["id", "name"]) g(e, n, "$", s, !0);
370
- for (const n of ["revision", "description"]) g(e, n, "$", s);
371
- const i = ie(e.template);
372
- s.push(...i.errors.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` }))), t.push(...i.warnings.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` })));
373
- }
374
- return { ok: s.length === 0, errors: s, warnings: t };
375
- }
376
- function N(e) {
377
- const s = ne(e);
378
- if (!s.ok) throw new $(s.errors);
379
- }
380
- function he(e) {
381
- const s = [];
382
- if (E(e, s), s.length) throw new $(s);
383
- const t = { ...e, schemaVersion: e.schemaVersion ?? R };
384
- return N(t), w(t);
385
- }
386
- function ue(e) {
387
- let s = e;
388
- if (typeof e == "string") {
389
- if (e.length > v)
390
- throw new $([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
391
- try {
392
- s = JSON.parse(e);
393
- } catch {
394
- throw new $([{ path: "$", message: "模板 JSON 语法无效" }]);
395
- }
396
- }
397
- return N(s), w(s);
398
- }
399
- function ge(e) {
400
- N(e);
401
- const s = JSON.stringify(e, null, 2);
402
- if (s.length > v) throw new $([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
403
- return s;
404
- }
405
- function w(e) {
406
- return JSON.parse(JSON.stringify(e));
407
- }
408
- function de(e = []) {
409
- const s = /* @__PURE__ */ new Map(), t = {
410
- get: (i) => {
411
- const n = s.get(i);
412
- return n ? w(n) : void 0;
413
- },
414
- list: () => Array.from(s.values(), ({ template: i, ...n }) => ({ ...n })),
415
- register: (i, n = {}) => {
416
- if (N(i), s.has(i.id) && !n.replace) throw new $([{ path: "$.id", message: `模板 ID ${i.id} 已注册;更新需显式 replace:true` }]);
417
- s.set(i.id, w(i));
418
- },
419
- remove: (i) => s.delete(i)
420
- };
421
- for (const i of e) t.register(i);
422
- return t;
423
- }
424
- export {
425
- R,
426
- $ as a,
427
- ne as b,
428
- de as c,
429
- he as d,
430
- ue as p,
431
- ge as s,
432
- ie as v
433
- };