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