@agile-team/mach-report 2.2.0 → 2.3.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.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { D as $e, r as U, L as Se, a as ee, m as et, b as Z, c as pe, p as fe, d as tt, e as Fe, f as nt, g as rt, P as he } from "./grid-geometry-DONcjshk.js";
2
- import { C as nn, h as rn, i as on, M as sn, S as an, j as ln, k as cn } from "./grid-geometry-DONcjshk.js";
3
- import { h as ke, R as ve, w as oe, i as it, a as Le } from "./textwrap-DdaewxAd.js";
4
- import { c as mn, b as fn, d as hn, m as gn } from "./textwrap-DdaewxAd.js";
5
- import { c as ot } from "./page-window-index-CIuT4BAv.js";
6
- import { g as st } from "./report-params-B3Fia6JO.js";
7
- function je(e) {
1
+ import { D as ve, r as K, L as Te, a as Ie, b as ne, m as rt, c as te, d as ye, p as he, e as st, f as je, g as at, P as ge } from "./grid-geometry-CWmJ9c9y.js";
2
+ import { C as an, h as ln, i as dn, M as cn, S as mn, j as fn, k as hn } from "./grid-geometry-CWmJ9c9y.js";
3
+ import { h as ke, R as Ae, w as le, i as lt, a as De } from "./textwrap-BQyrpYSR.js";
4
+ import { c as un, b as pn, d as yn, m as Mn } from "./textwrap-BQyrpYSR.js";
5
+ import { c as dt } from "./page-window-index-CIuT4BAv.js";
6
+ import { g as ct } from "./report-params-B3Fia6JO.js";
7
+ function _e(e) {
8
8
  if (!e || e.kind === "date") return;
9
9
  const t = e.digits;
10
10
  if (!(t !== void 0 && (!Number.isInteger(t) || t < 0 || t > 100))) {
@@ -15,56 +15,56 @@ function je(e) {
15
15
  return t === void 0 ? e.thousands ? "#,##0.###############" : void 0 : `${e.thousands ? "#,##0" : "0"}${t ? `.${"0".repeat(t)}` : ""}`;
16
16
  }
17
17
  }
18
- function at(e) {
18
+ function mt(e) {
19
19
  const t = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());
20
20
  if (t) {
21
- const r = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
22
- return Number.isNaN(r.getTime()) ? null : r;
21
+ const i = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
22
+ return Number.isNaN(i.getTime()) ? null : i;
23
23
  }
24
24
  const n = new Date(e);
25
25
  return Number.isNaN(n.getTime()) ? null : n;
26
26
  }
27
- function be(e, t) {
27
+ function $e(e, t) {
28
28
  return e.toLocaleString("en-US", {
29
29
  minimumFractionDigits: t,
30
30
  maximumFractionDigits: t
31
31
  });
32
32
  }
33
- function lt(e, t) {
34
- const n = (r) => String(r).padStart(2, "0");
33
+ function ft(e, t) {
34
+ const n = (i) => String(i).padStart(2, "0");
35
35
  return t.replace(/YYYY/g, String(e.getFullYear())).replace(/MM/g, n(e.getMonth() + 1)).replace(/DD/g, n(e.getDate())).replace(/hh/g, n(e.getHours())).replace(/mm/g, n(e.getMinutes())).replace(/ss/g, n(e.getSeconds()));
36
36
  }
37
- function ct(e, t, n) {
38
- return n != null ? t ? be(e, n) : e.toFixed(n) : t ? be(e) : String(e);
37
+ function ht(e, t, n) {
38
+ return n != null ? t ? $e(e, n) : e.toFixed(n) : t ? $e(e) : String(e);
39
39
  }
40
- function we(e) {
40
+ function Se(e) {
41
41
  const t = typeof e == "number" ? e : Number(String(e).replace(/,/g, ""));
42
42
  return Number.isFinite(t) ? t : null;
43
43
  }
44
- function _e(e, t) {
44
+ function ze(e, t) {
45
45
  if (e == null || e === "" || !t) return String(e ?? "");
46
46
  switch (t.kind) {
47
47
  case "number": {
48
- const n = we(e);
49
- return n == null ? String(e) : ct(n, t.thousands === !0, t.digits);
48
+ const n = Se(e);
49
+ return n == null ? String(e) : ht(n, t.thousands === !0, t.digits);
50
50
  }
51
51
  case "percent": {
52
- const n = we(e);
53
- return n == null ? String(e) : `${be(n * 100, t.digits ?? 2)}%`;
52
+ const n = Se(e);
53
+ return n == null ? String(e) : `${$e(n * 100, t.digits ?? 2)}%`;
54
54
  }
55
55
  case "date": {
56
- const n = t.pattern ?? "YYYY-MM-DD", r = e instanceof Date ? e : at(String(e));
57
- return r ? lt(r, n) : String(e);
56
+ const n = t.pattern ?? "YYYY-MM-DD", i = e instanceof Date ? e : mt(String(e));
57
+ return i ? ft(i, n) : String(e);
58
58
  }
59
59
  default:
60
60
  return String(e);
61
61
  }
62
62
  }
63
- function dt(e, t) {
63
+ function gt(e, t) {
64
64
  const n = e[t.field];
65
65
  if (n == null || n === "") return !1;
66
66
  if (typeof t.value == "number") {
67
- const s = we(n);
67
+ const s = Se(n);
68
68
  if (s == null) return !1;
69
69
  switch (t.op) {
70
70
  case ">":
@@ -81,24 +81,24 @@ function dt(e, t) {
81
81
  return s !== t.value;
82
82
  }
83
83
  }
84
- const r = String(n), i = String(t.value);
84
+ const i = String(n), o = String(t.value);
85
85
  switch (t.op) {
86
86
  case "==":
87
- return r === i;
87
+ return i === o;
88
88
  case "!=":
89
- return r !== i;
89
+ return i !== o;
90
90
  case ">":
91
- return r > i;
91
+ return i > o;
92
92
  case ">=":
93
- return r >= i;
93
+ return i >= o;
94
94
  case "<":
95
- return r < i;
95
+ return i < o;
96
96
  case "<=":
97
- return r <= i;
97
+ return i <= o;
98
98
  }
99
99
  return !1;
100
100
  }
101
- const mt = /* @__PURE__ */ new Set([
101
+ const ut = /* @__PURE__ */ new Set([
102
102
  "text",
103
103
  "image",
104
104
  "barcode",
@@ -111,86 +111,98 @@ const mt = /* @__PURE__ */ new Set([
111
111
  function q(e) {
112
112
  return typeof e == "object" && e !== null && !Array.isArray(e);
113
113
  }
114
- function ft(e, t, n, r) {
115
- const i = e[t];
116
- (typeof i != "number" || !Number.isFinite(i)) && r.push({ path: `${n}.${t}`, message: `应为有限数字,实际 ${JSON.stringify(i)}` });
114
+ function pt(e, t, n, i) {
115
+ const o = e[t];
116
+ (typeof o != "number" || !Number.isFinite(o)) && i.push({ path: `${n}.${t}`, message: `应为有限数字,实际 ${JSON.stringify(o)}` });
117
117
  }
118
- function Te(e, t, n, r = []) {
118
+ function Ee(e, t, n, i = []) {
119
119
  if (!q(e)) {
120
120
  n.push({ path: t, message: "组件应为对象" });
121
121
  return;
122
122
  }
123
- const i = e.kind;
124
- typeof i != "string" ? n.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : mt.has(i) || r.push({
123
+ const o = e.kind;
124
+ typeof o != "string" ? n.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : ut.has(o) || i.push({
125
125
  path: `${t}.kind`,
126
- message: `未知组件类型 ${JSON.stringify(i)},将以兜底方式渲染`
126
+ message: `未知组件类型 ${JSON.stringify(o)},将以兜底方式渲染`
127
127
  });
128
- for (const a of ["leftMm", "topMm", "widthMm", "heightMm"])
129
- ft(e, a, t, n);
128
+ for (const l of ["leftMm", "topMm", "widthMm", "heightMm"])
129
+ pt(e, l, t, n);
130
130
  typeof e.leftMm == "number" && e.leftMm < -100 && n.push({ path: `${t}.leftMm`, message: "几何数值异常(leftMm<-100)" });
131
- for (const a of ["widthMm", "heightMm"])
132
- typeof e[a] == "number" && e[a] < 0 && n.push({ path: `${t}.${a}`, message: "组件尺寸不能为负数" });
133
- const s = e.grid;
134
- s !== void 0 && (!q(s) || !Array.isArray(s.cells) ? n.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((a, l) => {
135
- if (!Array.isArray(a)) {
136
- n.push({ path: `${t}.grid.cells.${l}`, message: "行应为数组" });
131
+ for (const l of ["widthMm", "heightMm"])
132
+ typeof e[l] == "number" && e[l] < 0 && n.push({ path: `${t}.${l}`, message: "组件尺寸不能为负数" });
133
+ const s = e.table;
134
+ if (s !== void 0) {
135
+ const l = `${t}.table`;
136
+ if (!q(s)) n.push({ path: l, message: "逻辑表来源应为对象" });
137
+ else {
138
+ (typeof s.id != "string" || !s.id.trim()) && n.push({ path: `${l}.id`, message: "逻辑表 ID 应为非空字符串" });
139
+ const d = s.role;
140
+ ["header", "body", "group-header", "subtotal", "grand-total"].includes(d) || n.push({ path: `${l}.role`, message: "未知逻辑表行角色" });
141
+ const m = s.rowIndex;
142
+ (typeof m != "number" || !Number.isInteger(m) || (d === "header" ? m !== -1 : m < 0)) && n.push({ path: `${l}.rowIndex`, message: "表头索引应为 -1,内容行索引应为非负整数" }), (!Array.isArray(s.columnKeys) || s.columnKeys.some((h) => typeof h != "string")) && n.push({ path: `${l}.columnKeys`, message: "逻辑列字段应为字符串数组" }), s.layout !== void 0 && s.layout !== "page" && s.layout !== "wide" && n.push({ path: `${l}.layout`, message: "布局应为 page 或 wide" }), s.title !== void 0 && typeof s.title != "string" && n.push({ path: `${l}.title`, message: "逻辑表名称应为字符串" });
143
+ }
144
+ }
145
+ const r = e.grid;
146
+ r !== void 0 && (!q(r) || !Array.isArray(r.cells) ? n.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" }) : r.cells.forEach((l, d) => {
147
+ if (!Array.isArray(l)) {
148
+ n.push({ path: `${t}.grid.cells.${d}`, message: "行应为数组" });
137
149
  return;
138
150
  }
139
- a.forEach((c, f) => {
140
- c != null && q(c) && Array.isArray(c.children) && c.children.forEach((h, m) => {
141
- Te(h, `${t}.grid.cells.${l}.${f}.children.${m}`, n, r);
151
+ l.forEach((m, h) => {
152
+ m != null && q(m) && Array.isArray(m.children) && m.children.forEach((f, g) => {
153
+ Ee(f, `${t}.grid.cells.${d}.${h}.children.${g}`, n, i);
142
154
  });
143
155
  });
144
156
  }));
145
- const o = e.richParagraphs;
146
- o !== void 0 && (Array.isArray(o) ? o.forEach((a, l) => {
147
- (!q(a) || !Array.isArray(a.segments)) && n.push({ path: `${t}.richParagraphs.${l}`, message: "段落缺少 segments 数组" });
157
+ const a = e.richParagraphs;
158
+ a !== void 0 && (Array.isArray(a) ? a.forEach((l, d) => {
159
+ (!q(l) || !Array.isArray(l.segments)) && n.push({ path: `${t}.richParagraphs.${d}`, message: "段落缺少 segments 数组" });
148
160
  }) : n.push({ path: `${t}.richParagraphs`, message: "richParagraphs 应为数组" }));
149
161
  }
150
- function ht(e, t, n, r = []) {
162
+ function yt(e, t, n, i = []) {
151
163
  if (!q(e)) {
152
164
  n.push({ path: t, message: "页应为对象" });
153
165
  return;
154
166
  }
155
- const i = e.pageWidthMm, s = e.pageHeightMm;
156
- (typeof i != "number" || !(i > 0 && i < 3e3)) && n.push({ path: `${t}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(i)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && n.push({ path: `${t}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` });
157
- const o = e.components;
158
- Array.isArray(o) ? Array.isArray(o) && o.forEach(
159
- (a, l) => Te(a, `${t}.components.${l}`, n, r)
167
+ const o = e.pageWidthMm, s = e.pageHeightMm;
168
+ (typeof o != "number" || !Number.isFinite(o) || o <= 0) && n.push({ path: `${t}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(o)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && n.push({ path: `${t}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" });
169
+ const r = e.components;
170
+ Array.isArray(r) ? Array.isArray(r) && r.forEach(
171
+ (a, l) => Ee(a, `${t}.components.${l}`, n, i)
160
172
  ) : n.push({ path: `${t}.components`, message: "components 应为数组" });
161
173
  }
162
- function De(e) {
163
- const t = [], n = [], r = q(e) ? e.pages : void 0;
164
- if (!Array.isArray(r))
174
+ function We(e) {
175
+ const t = [], n = [], i = q(e) ? e.pages : void 0;
176
+ if (!Array.isArray(i))
165
177
  t.push({
166
178
  path: "$.pages",
167
179
  message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
168
180
  });
169
181
  else {
170
- r.forEach((s, o) => ht(s, `$.pages.${o}`, t, n)), r.length > 2e3 && n.push({
182
+ i.forEach((s, r) => yt(s, `$.pages.${r}`, t, n)), i.length > 2e3 && n.push({
171
183
  path: "$.pages",
172
- message: `页数异常大(${r.length} 页),渲染与打印耗时可能显著增加`
184
+ message: `页数异常大(${i.length} 页),渲染与打印耗时可能显著增加`
173
185
  });
174
- const i = r.reduce(
175
- (s, o) => s + (q(o) && Array.isArray(o.components) ? o.components.length : 0),
186
+ const o = i.reduce(
187
+ (s, r) => s + (q(r) && Array.isArray(r.components) ? r.components.length : 0),
176
188
  0
177
189
  );
178
- i > 5e4 && n.push({
190
+ o > 5e4 && n.push({
179
191
  path: "$.pages",
180
- message: `组件总数异常大(${i} 个),可能触发浏览器性能限制`
192
+ message: `组件总数异常大(${o} 个),可能触发浏览器性能限制`
181
193
  });
182
194
  }
183
195
  return { ok: t.length === 0, errors: t, warnings: n };
184
196
  }
185
- function zt(e) {
186
- const t = De(e);
197
+ function Jt(e) {
198
+ const t = We(e);
187
199
  if (!t.ok) {
188
- const n = t.errors.slice(0, 3).map((r) => `${r.path}: ${r.message}`).join("; ");
200
+ const n = t.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ");
189
201
  throw new Error(`渲染计划校验失败(${t.errors.length} 处): ${n}`);
190
202
  }
191
203
  return e.pages;
192
204
  }
193
- function Re(e) {
205
+ function Be(e) {
194
206
  return {
195
207
  widthMm: e.widthMm,
196
208
  heightMm: e.heightMm,
@@ -201,10 +213,10 @@ function Re(e) {
201
213
  components: []
202
214
  };
203
215
  }
204
- function gt(e, t) {
205
- return t.heightMm - (e.marginBottomMm ?? t.marginBottomMm);
216
+ function Mt(e, t) {
217
+ return t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
206
218
  }
207
- function ze(e) {
219
+ function Ve(e) {
208
220
  if (e == null) return "";
209
221
  if (typeof e == "string") return e;
210
222
  if (typeof e == "number") return String(e);
@@ -216,296 +228,312 @@ function ze(e) {
216
228
  return String(e);
217
229
  }
218
230
  }
219
- function Ie(e, t) {
231
+ function Je(e, t) {
220
232
  let n = e.textMetrics.get(t);
221
233
  if (!n) {
222
- const r = U(t).fontSizePt;
234
+ const i = K(t).fontSizePt;
223
235
  n = {
224
236
  measureOptions: {
225
- fontSizePt: r,
237
+ fontSizePt: i,
226
238
  bold: t.bold,
227
239
  letterSpacingPt: t.letterSpacing === void 0 ? void 0 : t.letterSpacing * 72 / 96
228
240
  },
229
- lineMm: r * (t.lineHeight ?? Se) * 25.4 / 72
241
+ lineMm: i * (t.lineHeight ?? Te) * 25.4 / 72
230
242
  }, e.textMetrics.set(t, n);
231
243
  }
232
244
  return n;
233
245
  }
234
- function We(e, t) {
246
+ function Ge(e, t) {
235
247
  return t?.kind === "number" || t?.kind === "percent" ? "right" : t?.kind === "date" || e instanceof Date || typeof e == "boolean" ? "center" : typeof e == "number" && Number.isFinite(e) ? "right" : "left";
236
248
  }
237
- function ut(e) {
249
+ function bt(e) {
238
250
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
239
251
  }
240
- function pt(e, t) {
241
- const n = e.fontSizePt ?? $e, r = e.paddingMm ?? 1, i = e.columns.map((d) => d.align ?? d.style?.align ?? e.align ?? "left"), s = e.columns.map((d, u) => ({
252
+ function wt(e, t) {
253
+ const n = e.fontSizePt ?? ve, i = e.paddingMm ?? 1, o = e.columns.map((c) => c.align ?? c.style?.align ?? e.align ?? "left"), s = e.columns.map((c, b) => ({
242
254
  fontSize: n,
243
255
  verticalAlign: "middle",
244
- ...d.style,
245
- align: i[u] === "auto" ? "left" : i[u]
246
- })), o = s.map((d, u) => i[u] === "auto" ? { left: d, center: { ...d, align: "center" }, right: { ...d, align: "right" } } : void 0), a = e.columns.map((d, u) => d.rules?.map((w) => {
247
- const S = o[u];
248
- if (S) return {
249
- left: { ...S.left, ...w.style },
250
- center: { ...S.center, ...w.style },
251
- right: { ...S.right, ...w.style }
256
+ ...c.style,
257
+ align: o[b] === "auto" ? "left" : o[b]
258
+ })), r = s.map((c, b) => o[b] === "auto" ? { left: c, center: { ...c, align: "center" }, right: { ...c, align: "right" } } : void 0), a = e.columns.map((c, b) => c.rules?.map((y) => {
259
+ const T = r[b];
260
+ if (T) return {
261
+ left: { ...T.left, ...y.style },
262
+ center: { ...T.center, ...y.style },
263
+ right: { ...T.right, ...y.style }
252
264
  };
253
- const g = { ...s[u], ...w.style };
254
- return { left: g, center: g, right: g };
265
+ const $ = { ...s[b], ...y.style };
266
+ return { left: $, center: $, right: $ };
255
267
  })), l = e.columns.map(
256
- (d) => ({
268
+ (c) => ({
257
269
  fontSize: n,
258
270
  bold: e.headerBold ?? !0,
259
271
  align: "center",
260
272
  verticalAlign: "middle",
261
273
  backgroundColor: e.headerBackgroundColor,
262
- ...d.style || {},
274
+ ...c.style || {},
263
275
  ...e.headerAlign === void 0 ? {} : { align: e.headerAlign },
264
276
  ...e.headerStyle,
265
- ...d.headerAlign === void 0 ? {} : { align: d.headerAlign },
266
- ...d.headerStyle
277
+ ...c.headerAlign === void 0 ? {} : { align: c.headerAlign },
278
+ ...c.headerStyle
267
279
  })
268
- ), c = e.columns.map((d) => d.header);
269
- let f = e.rowHeightMm ?? 0;
270
- for (let d = 0; d < c.length; d++) {
271
- const u = l[d], w = U(u).fontSizePt, S = oe(
272
- c[d],
273
- e.columns[d].widthMm - r * 2,
274
- { fontSizePt: w, bold: u.bold },
280
+ ), d = e.columns.map((c) => c.header);
281
+ let m = e.rowHeightMm ?? 0;
282
+ for (let c = 0; c < d.length; c++) {
283
+ const b = l[c], y = K(b).fontSizePt, T = le(
284
+ d[c],
285
+ e.columns[c].widthMm - i * 2,
286
+ { fontSizePt: y, bold: b.bold },
275
287
  t
276
- ), g = w * (u.lineHeight ?? Se) * 25.4 / 72;
277
- f = Math.max(f, Math.max(S.length, 1) * g + r * 2);
288
+ ), $ = y * (b.lineHeight ?? Te) * 25.4 / 72;
289
+ m = Math.max(m, Math.max(T.length, 1) * $ + i * 2);
278
290
  }
279
- const h = c.map((d, u) => ({
280
- text: d,
281
- style: l[u]
282
- })), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, b = e.columns.map((d) => d.widthMm);
291
+ const h = d.map((c, b) => ({
292
+ text: c,
293
+ style: l[b]
294
+ })), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, g = e.columns.map((c) => c.widthMm);
283
295
  return {
284
296
  fontSizePt: n,
285
- paddingMm: r,
297
+ paddingMm: i,
286
298
  cellStyles: s,
287
- autoStyles: o,
299
+ autoStyles: r,
288
300
  ruleStyles: a,
289
301
  textMetrics: /* @__PURE__ */ new WeakMap(),
290
- numberFormats: e.columns.map((d) => je(d.format)),
291
- borderStyle: m,
292
- headerHeightMm: f,
302
+ numberFormats: e.columns.map((c) => _e(c.format)),
303
+ borderStyle: f,
304
+ headerHeightMm: m,
293
305
  headerGrid: {
294
306
  cells: [h],
295
- colWidthsMm: b,
296
- rowHeightsMm: [f]
307
+ colWidthsMm: g,
308
+ rowHeightsMm: [m]
297
309
  },
298
- colWidthsMm: b,
310
+ colWidthsMm: g,
299
311
  columns: e.columns
300
312
  };
301
313
  }
302
- function He(e, t, n) {
303
- const r = e.columns;
304
- let i = e.rowHeightFloorMm;
305
- const s = new Array(r.length);
306
- for (let o = 0; o < r.length; o++) {
307
- const a = r[o], l = t[a.field], c = e.autoStyles[o] ? We(l, a.format) : "left";
308
- let f = e.autoStyles[o]?.[c] ?? e.cellStyles[o];
314
+ function Oe(e, t, n) {
315
+ const i = e.columns;
316
+ let o = e.rowHeightFloorMm;
317
+ const s = new Array(i.length);
318
+ for (let r = 0; r < i.length; r++) {
319
+ const a = i[r], l = t[a.field], d = e.autoStyles[r] ? Ge(l, a.format) : "left";
320
+ let m = e.autoStyles[r]?.[d] ?? e.cellStyles[r];
309
321
  if (a.rules)
310
- for (let w = 0; w < a.rules.length; w++) {
311
- const S = a.rules[w];
312
- if (dt(t, S.when)) {
313
- f = e.ruleStyles[o][w][c];
322
+ for (let y = 0; y < a.rules.length; y++) {
323
+ const T = a.rules[y];
324
+ if (gt(t, T.when)) {
325
+ m = e.ruleStyles[r][y][d];
314
326
  break;
315
327
  }
316
328
  }
317
- const h = a.format ? _e(l, a.format) : ze(l), m = Ie(e, f), b = oe(h, a.widthMm - e.paddingMm * 2, m.measureOptions, n);
318
- i = Math.max(i, b.length * m.lineMm + e.paddingMm * 2);
319
- const d = ut(l), u = { text: h, style: f };
320
- d !== void 0 && (u.value = d), typeof d == "number" && e.numberFormats[o] !== void 0 && (u.numberFormat = e.numberFormats[o]), s[o] = u;
329
+ const h = a.format ? ze(l, a.format) : Ve(l), f = Je(e, m), g = le(h, a.widthMm - e.paddingMm * 2, f.measureOptions, n);
330
+ o = Math.max(o, g.length * f.lineMm + e.paddingMm * 2);
331
+ const c = bt(l), b = { text: h, style: m };
332
+ c !== void 0 && (b.value = c), typeof c == "number" && e.numberFormats[r] !== void 0 && (b.numberFormat = e.numberFormats[r]), s[r] = b;
321
333
  }
322
334
  return {
323
- grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [i] },
324
- heightMm: i
335
+ grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [o] },
336
+ heightMm: o
325
337
  };
326
338
  }
327
- function yt(e, t, n = {}) {
328
- const r = typeof n == "number" ? { mmPerRow: n } : n, i = r.mmPerRow ?? 0, s = r.measurer ?? ke, o = [], a = [];
339
+ function $t(e, t, n = {}) {
340
+ const i = typeof n == "number" ? { mmPerRow: n } : n, o = i.mmPerRow ?? 0, s = i.measurer ?? ke, r = [], a = [];
329
341
  let l = 0;
330
- const c = (h) => `${h}_${(++l).toString(36)}`, f = [];
331
- for (const h of e.pages) {
332
- const m = Re(h), b = () => gt(h, m), d = m.marginTopMm, u = [], w = () => {
342
+ const d = (h) => `${h}_${(++l).toString(36)}`, m = [];
343
+ for (const [h, f] of e.pages.entries()) {
344
+ const g = Be(f), c = () => Mt(f, g), b = g.marginTopMm, y = [], T = ($ = !1) => {
333
345
  if (a.push({
334
- pageWidthMm: m.widthMm,
335
- pageHeightMm: m.heightMm,
336
- marginTopMm: m.marginTopMm,
337
- marginBottomMm: m.marginBottomMm,
338
- marginLeftMm: m.marginLeftMm,
339
- marginRightMm: m.marginRightMm,
340
- components: m.components
341
- }), u.length > 0) {
342
- const S = a.length;
343
- for (const g of u) {
344
- const E = {
345
- ...g,
346
- text: String(g.text ?? "").replace(/\{page\}/g, String(S))
346
+ pageWidthMm: g.widthMm,
347
+ pageHeightMm: g.heightMm,
348
+ ...f.layout === void 0 ? {} : { layout: f.layout },
349
+ marginTopMm: g.marginTopMm,
350
+ marginBottomMm: g.marginBottomMm,
351
+ marginLeftMm: g.marginLeftMm,
352
+ marginRightMm: g.marginRightMm,
353
+ components: g.components
354
+ }), y.length > 0) {
355
+ const E = a.length;
356
+ for (const S of y) {
357
+ const R = {
358
+ ...S,
359
+ text: String(S.text ?? "").replace(/\{page\}/g, String(E))
347
360
  };
348
- a[a.length - 1].components.push(E), E.text.includes("{totalPages}") && f.push(E);
361
+ a[a.length - 1].components.push(R), R.text.includes("{totalPages}") && m.push(R);
349
362
  }
350
363
  }
364
+ if (f.layout === "wide") {
365
+ const E = a[a.length - 1], S = E.components.reduce((F, k) => Math.max(F, k.topMm + k.heightMm), 0), R = $ ? f.marginBottomMm ?? 0 : 0;
366
+ E.pageHeightMm = Math.max(1, S + R), E.marginBottomMm = R;
367
+ }
351
368
  };
352
- for (const S of h.components) {
353
- if (S.kind !== "list") {
354
- if (S.kind === "text" && typeof S.text == "string") {
355
- const $ = S.text;
356
- if ($.includes("{page}") || $.includes("{totalPages}")) {
357
- u.push(S);
369
+ for (const [$, E] of f.components.entries()) {
370
+ if (E.kind !== "list") {
371
+ if (E.kind === "text" && typeof E.text == "string") {
372
+ const w = E.text;
373
+ if (w.includes("{page}") || w.includes("{totalPages}")) {
374
+ y.push(E);
358
375
  continue;
359
376
  }
360
377
  }
361
- m.components.push(S);
378
+ g.components.push(E);
362
379
  continue;
363
380
  }
364
- const g = S, E = t[g.dataset];
365
- Array.isArray(E) || o.push(`数据集 ${g.dataset} 未提供数据,列表 ${g.id ?? ""} 输出为空`);
366
- const A = Array.isArray(E) ? E : [], v = g.columns.reduce(($, y) => $ + y.widthMm, 0), I = v > g.widthMm ? g.widthMm / v : 1, p = I === 1 ? g : { ...g, columns: g.columns.map(($) => ({ ...$, widthMm: $.widthMm * I })) }, k = {
367
- ...pt(p, s),
368
- rowHeightFloorMm: p.rowHeightMm ?? 0
369
- }, X = {
381
+ const S = E, R = t[S.dataset];
382
+ Array.isArray(R) || r.push(`数据集 ${S.dataset} 未提供数据,列表 ${S.id ?? ""} 输出为空`);
383
+ const F = Array.isArray(R) ? R : [], k = S.columns.reduce((w, M) => w + M.widthMm, 0), v = k > S.widthMm ? S.widthMm / k : 1, u = v === 1 ? S : { ...S, columns: S.columns.map((w) => ({ ...w, widthMm: w.widthMm * v })) }, p = {
384
+ id: `table:${h}:${$}`,
385
+ columnKeys: S.columns.map((w) => w.field),
386
+ ...S.layout === void 0 ? {} : { layout: S.layout },
387
+ ...S.title === void 0 ? {} : { title: S.title }
388
+ };
389
+ let B = 0;
390
+ const A = {
391
+ ...wt(u, s),
392
+ rowHeightFloorMm: u.rowHeightMm ?? 0
393
+ }, P = {
370
394
  kind: "rect",
371
- leftMm: g.leftMm,
395
+ leftMm: S.leftMm,
372
396
  topMm: 0,
373
- widthMm: g.widthMm,
374
- heightMm: k.headerHeightMm,
375
- grid: k.headerGrid,
376
- nid: c("listh"),
377
- style: k.borderStyle
397
+ widthMm: S.widthMm,
398
+ heightMm: A.headerHeightMm,
399
+ grid: A.headerGrid,
400
+ nid: d("listh"),
401
+ table: { ...p, role: "header", rowIndex: -1 },
402
+ style: A.borderStyle
378
403
  };
379
- let M = g.topMm;
380
- const R = ($, y) => {
381
- $.components.push({ ...X, topMm: y });
404
+ let N = S.topMm;
405
+ const L = (w, M) => {
406
+ w.components.push({ ...P, topMm: M });
382
407
  };
383
- R(m, M), M += k.headerHeightMm + i;
384
- const L = ($) => {
385
- if (M + $ > b()) {
386
- w();
387
- const y = Re(h);
388
- m.components = y.components, m.heightMm = y.heightMm, p.headerEveryPage !== !1 ? (R(m, g.topMm), M = g.topMm + k.headerHeightMm) : M = d;
408
+ L(g, N), N += A.headerHeightMm + o;
409
+ const J = (w) => {
410
+ if (N + w > c()) {
411
+ T();
412
+ const M = Be(f);
413
+ g.components = M.components, g.heightMm = M.heightMm, f.layout === "wide" && (g.marginTopMm = 0, g.marginBottomMm = 0);
414
+ const x = f.layout === "wide" ? 0 : S.topMm;
415
+ u.headerEveryPage !== !1 ? (L(g, x), N = x + A.headerHeightMm) : N = f.layout === "wide" ? 0 : b;
389
416
  }
390
- }, T = ($, y, P) => {
391
- const x = p.headerEveryPage !== !1 ? g.topMm + k.headerHeightMm : d, O = b() - x;
392
- y > O && o.push(
393
- `列表 ${g.id ?? g.dataset} 行高 ${y.toFixed(2)}mm 超出单页可用高度 ${O.toFixed(2)}mm,预览与打印可能截断内容`
394
- ), L(y), m.components.push({
417
+ }, Q = (w, M, x, C) => {
418
+ const I = f.layout === "wide" ? 0 : S.topMm, Z = u.headerEveryPage !== !1 ? I + A.headerHeightMm : f.layout === "wide" ? 0 : b, oe = c() - Z;
419
+ M > oe && r.push(
420
+ `列表 ${S.id ?? S.dataset} 行高 ${M.toFixed(2)}mm 超出单页可用高度 ${oe.toFixed(2)}mm,预览与打印可能截断内容`
421
+ ), J(M), g.components.push({
395
422
  kind: "rect",
396
- leftMm: g.leftMm,
397
- topMm: M,
398
- widthMm: g.widthMm,
399
- heightMm: y,
400
- grid: $,
401
- nid: c(P),
402
- style: k.borderStyle
403
- }), M += y;
404
- }, H = () => He(k, {}, s).heightMm, C = ($, y, P, x) => {
405
- const O = [], ae = Math.max(1, Math.min(x, p.columns.length)), Ce = { fontSize: k.fontSizePt, ...P };
406
- O.push({ text: $, colSpan: ae, style: { bold: !0, ...Ce } });
407
- for (let W = ae; W < p.columns.length; W++) {
408
- const ne = p.columns[W], re = y.get(ne.field), de = k.autoStyles[W]?.[We(re?.value, ne.format)] ?? k.cellStyles[W];
409
- O.push({ ...re, text: re?.text ?? "", style: { ...de, ...Ce } });
423
+ leftMm: S.leftMm,
424
+ topMm: N,
425
+ widthMm: S.widthMm,
426
+ heightMm: M,
427
+ grid: w,
428
+ nid: d(x),
429
+ table: { ...p, role: C, rowIndex: B++ },
430
+ style: A.borderStyle
431
+ }), N += M;
432
+ }, nt = () => Oe(A, {}, s).heightMm, be = (w, M, x, C) => {
433
+ const I = [], Z = Math.max(1, Math.min(C, u.columns.length)), oe = { fontSize: A.fontSizePt, ...x };
434
+ I.push({ text: w, colSpan: Z, style: { bold: !0, ...oe } });
435
+ for (let G = Z; G < u.columns.length; G++) {
436
+ const re = u.columns[G], se = M.get(re.field), me = A.autoStyles[G]?.[Ge(se?.value, re.format)] ?? A.cellStyles[G];
437
+ I.push({ ...se, text: se?.text ?? "", style: { ...me, ...oe } });
410
438
  }
411
- let le = k.rowHeightFloorMm, ce = 0;
412
- for (const W of O) {
413
- let ne = 0;
414
- const re = ce + (W.colSpan ?? 1);
415
- for (; ce < re; ce++) ne += k.colWidthsMm[ce] ?? 0;
416
- const de = Ie(k, W.style), Ze = oe(W.text ?? "", ne - k.paddingMm * 2, de.measureOptions, s);
417
- le = Math.max(le, Ze.length * de.lineMm + k.paddingMm * 2);
439
+ let de = A.rowHeightFloorMm, ce = 0;
440
+ for (const G of I) {
441
+ let re = 0;
442
+ const se = ce + (G.colSpan ?? 1);
443
+ for (; ce < se; ce++) re += A.colWidthsMm[ce] ?? 0;
444
+ const me = Je(A, G.style), ot = le(G.text ?? "", re - A.paddingMm * 2, me.measureOptions, s);
445
+ de = Math.max(de, ot.length * me.lineMm + A.paddingMm * 2);
418
446
  }
419
447
  return {
420
- grid: { cells: [O], colWidthsMm: k.colWidthsMm, rowHeightsMm: [le] },
421
- heightMm: le
448
+ grid: { cells: [I], colWidthsMm: A.colWidthsMm, rowHeightsMm: [de] },
449
+ heightMm: de
422
450
  };
423
- }, G = ($, y) => {
424
- let P = 0;
425
- for (const x of $) {
426
- const O = typeof x[y] == "number" ? x[y] : Number(x[y]);
427
- Number.isFinite(O) && (P += O);
451
+ }, it = (w, M) => {
452
+ let x = 0;
453
+ for (const C of w) {
454
+ const I = typeof C[M] == "number" ? C[M] : Number(C[M]);
455
+ Number.isFinite(I) && (x += I);
428
456
  }
429
- return P;
430
- }, se = ($, y) => {
431
- const x = p.columns.find((ae) => ae.field === y)?.format ?? { kind: "number", thousands: !0 }, O = G($, y);
432
- return { text: _e(O, x), value: O, numberFormat: je(x) };
433
- }, D = p.groupBy, xe = ($) => {
434
- const y = p.columns.findIndex((P) => $.includes(P.field));
435
- return y > 0 ? y : 1;
436
- }, te = [];
437
- if (D) {
438
- const $ = /* @__PURE__ */ new Map();
439
- for (const y of A) {
440
- const P = ze(y[D.field]), x = $.get(P);
441
- x ? x.push(y) : $.set(P, [y]);
457
+ return x;
458
+ }, Ce = (w, M) => {
459
+ const C = u.columns.find((Z) => Z.field === M)?.format ?? { kind: "number", thousands: !0 }, I = it(w, M);
460
+ return { text: ze(I, C), value: I, numberFormat: _e(C) };
461
+ }, z = u.groupBy, Re = (w) => {
462
+ const M = u.columns.findIndex((x) => w.includes(x.field));
463
+ return M > 0 ? M : 1;
464
+ }, ie = [];
465
+ if (z) {
466
+ const w = /* @__PURE__ */ new Map();
467
+ for (const M of F) {
468
+ const x = Ve(M[z.field]), C = w.get(x);
469
+ C ? C.push(M) : w.set(x, [M]);
442
470
  }
443
- for (const [y, P] of $) {
444
- te.push({
471
+ for (const [M, x] of w) {
472
+ ie.push({
445
473
  kind: "groupHeader",
446
- label: (D.headerTemplate ?? "{value}").replace(/\{value\}/g, y)
474
+ label: (z.headerTemplate ?? "{value}").replace(/\{value\}/g, M)
447
475
  });
448
- for (const x of P) te.push({ kind: "row", row: x });
449
- D.subtotal && D.subtotal.length > 0 && te.push({
476
+ for (const C of x) ie.push({ kind: "row", row: C });
477
+ z.subtotal && z.subtotal.length > 0 && ie.push({
450
478
  kind: "subtotal",
451
- label: D.subtotalLabel ?? "小计",
452
- rows: P
479
+ label: z.subtotalLabel ?? "小计",
480
+ rows: x
453
481
  });
454
482
  }
455
483
  } else
456
- for (const $ of A) te.push({ kind: "row", row: $ });
457
- const Ne = H();
458
- for (const $ of te)
459
- if ($.kind === "row") {
460
- const y = He(k, $.row, s);
461
- T(y.grid, y.heightMm, "listr");
462
- } else if ($.kind === "groupHeader") {
463
- const y = C(
464
- $.label,
484
+ for (const w of F) ie.push({ kind: "row", row: w });
485
+ const He = nt();
486
+ for (const w of ie)
487
+ if (w.kind === "row") {
488
+ const M = Oe(A, w.row, s);
489
+ Q(M.grid, M.heightMm, "listr", "body");
490
+ } else if (w.kind === "groupHeader") {
491
+ const M = be(
492
+ w.label,
465
493
  /* @__PURE__ */ new Map(),
466
- D?.headerStyle ?? {},
467
- p.columns.length
494
+ z?.headerStyle ?? {},
495
+ u.columns.length
468
496
  );
469
- D?.keepWithNext !== !1 && M + y.heightMm + Ne > b() && L(y.heightMm + Ne), T(y.grid, y.heightMm, "listg");
470
- } else if ($.kind === "subtotal") {
471
- const y = /* @__PURE__ */ new Map();
472
- for (const x of D.subtotal ?? []) y.set(x, se($.rows, x));
473
- const P = C(
474
- $.label,
475
- y,
476
- D?.subtotalStyle ?? {},
477
- xe(D.subtotal ?? [])
497
+ z?.keepWithNext !== !1 && N + M.heightMm + He > c() && J(M.heightMm + He), Q(M.grid, M.heightMm, "listg", "group-header");
498
+ } else if (w.kind === "subtotal") {
499
+ const M = /* @__PURE__ */ new Map();
500
+ for (const C of z.subtotal ?? []) M.set(C, Ce(w.rows, C));
501
+ const x = be(
502
+ w.label,
503
+ M,
504
+ z?.subtotalStyle ?? {},
505
+ Re(z.subtotal ?? [])
478
506
  );
479
- T(P.grid, P.heightMm, "listst");
507
+ Q(x.grid, x.heightMm, "listst", "subtotal");
480
508
  }
481
- if (p.grandTotal) {
482
- const $ = typeof p.grandTotal == "object" ? p.grandTotal : void 0, y = $?.fields ?? D?.subtotal ?? [];
483
- if (y.length > 0) {
484
- const P = /* @__PURE__ */ new Map();
485
- for (const O of y) P.set(O, se(A, O));
486
- const x = C(
487
- $?.label ?? "合计",
488
- P,
489
- $?.style ?? {},
490
- xe(y)
509
+ if (u.grandTotal) {
510
+ const w = typeof u.grandTotal == "object" ? u.grandTotal : void 0, M = w?.fields ?? z?.subtotal ?? [];
511
+ if (M.length > 0) {
512
+ const x = /* @__PURE__ */ new Map();
513
+ for (const I of M) x.set(I, Ce(F, I));
514
+ const C = be(
515
+ w?.label ?? "合计",
516
+ x,
517
+ w?.style ?? {},
518
+ Re(M)
491
519
  );
492
- T(x.grid, x.heightMm, "listgt");
520
+ Q(C.grid, C.heightMm, "listgt", "grand-total");
493
521
  } else
494
- o.push(`列表 ${g.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
522
+ r.push(`列表 ${S.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
495
523
  }
496
524
  }
497
- w();
525
+ T(!0);
498
526
  }
499
- for (const h of f) {
500
- const m = h.text;
501
- typeof m == "string" && m.includes("{totalPages}") && (h.text = m.replace(/\{totalPages\}/g, String(a.length)));
527
+ for (const h of m) {
528
+ const f = h.text;
529
+ typeof f == "string" && f.includes("{totalPages}") && (h.text = f.replace(/\{totalPages\}/g, String(a.length)));
502
530
  }
503
531
  return {
504
- plan: { schemaVersion: ve, pages: a },
505
- warnings: o
532
+ plan: { schemaVersion: Ae, pages: a },
533
+ warnings: r
506
534
  };
507
535
  }
508
- const Mt = {
536
+ const St = {
509
537
  root: "mr-root",
510
538
  page: "mr-page",
511
539
  comp: "mr-comp",
@@ -522,23 +550,23 @@ const Mt = {
522
550
  cell: "mr-cell",
523
551
  unknown: "mr-unknown"
524
552
  };
525
- function F(e, t) {
526
- return t?.classNames?.[e] ?? Mt[e];
553
+ function j(e, t) {
554
+ return t?.classNames?.[e] ?? St[e];
527
555
  }
528
- class z {
556
+ class V {
529
557
  constructor() {
530
558
  this.props = [];
531
559
  }
532
560
  add(t, n) {
533
561
  return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
534
562
  }
535
- mm(t, n, r, i = 2) {
536
- return this.add(t, `${ee(et(n, r), i)}px`);
563
+ mm(t, n, i, o = 2) {
564
+ return this.add(t, `${ne(rt(n, i), o)}px`);
537
565
  }
538
566
  toString() {
539
567
  let t = "";
540
- for (const [n, r] of this.props)
541
- t += `${n}:${r};`;
568
+ for (const [n, i] of this.props)
569
+ t += `${n}:${i};`;
542
570
  return t;
543
571
  }
544
572
  applyTo(t) {
@@ -546,361 +574,361 @@ class z {
546
574
  n && (t.style.cssText = n);
547
575
  }
548
576
  }
549
- function Ve(e, t, n) {
550
- const r = t.style || {};
551
- e.add("color", r.color).add("background-color", r.backgroundColor).add("font-family", r.fontFamily).add("font-weight", r.bold ? "700" : void 0).add("font-style", r.italic ? "italic" : void 0).add("text-decoration", r.underline ? "underline" : void 0).add("letter-spacing", r.letterSpacing != null ? `${r.letterSpacing}pt` : void 0).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
552
- const i = U(r, n);
553
- e.add("font-size", `${ee(i.fontSizePx, 2)}px`);
554
- }
555
- function bt(e, t, n, r, i) {
556
- const s = i.createElement("table");
557
- if (s.className = F("grid", r), new z().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", e.colWidthsMm ? "fixed" : "auto").applyTo(s), e.colWidthsMm) {
558
- const c = i.createElement("colgroup");
559
- for (const f of e.colWidthsMm) {
560
- const h = i.createElement("col");
561
- new z().mm("width", f, n).applyTo(h), c.appendChild(h);
577
+ function Ye(e, t, n) {
578
+ const i = t.style || {};
579
+ e.add("color", i.color).add("background-color", i.backgroundColor).add("font-family", i.fontFamily).add("font-weight", i.bold ? "700" : void 0).add("font-style", i.italic ? "italic" : void 0).add("text-decoration", i.underline ? "underline" : void 0).add("letter-spacing", i.letterSpacing != null ? `${i.letterSpacing}pt` : void 0).add("opacity", i.opacity != null ? String(i.opacity) : void 0).add("transform", i.rotateDeg ? `rotate(${i.rotateDeg}deg)` : void 0);
580
+ const o = K(i, n);
581
+ e.add("font-size", `${ne(o.fontSizePx, 2)}px`);
582
+ }
583
+ function vt(e, t, n, i, o) {
584
+ const s = o.createElement("table");
585
+ if (s.className = j("grid", i), new V().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", e.colWidthsMm ? "fixed" : "auto").applyTo(s), e.colWidthsMm) {
586
+ const d = o.createElement("colgroup");
587
+ for (const m of e.colWidthsMm) {
588
+ const h = o.createElement("col");
589
+ new V().mm("width", m, n).applyTo(h), d.appendChild(h);
562
590
  }
563
- s.appendChild(c);
591
+ s.appendChild(d);
564
592
  }
565
- const o = pe(t.style), a = Z(t.style), l = o.inner ? `${ee(a.widthPt * n / 72, 2)}px solid ${a.color}` : "";
566
- return e.cells.forEach((c, f) => {
567
- const h = i.createElement("tr");
568
- h.className = F("row", r), e.rowHeightsMm?.[f] != null && new z().mm("height", e.rowHeightsMm[f], n).applyTo(h), (c || []).forEach((m) => {
569
- const b = i.createElement("td");
570
- b.className = F("cell", r), m?.colSpan && (b.colSpan = m.colSpan), m?.rowSpan && (b.rowSpan = m.rowSpan);
571
- const d = new z();
572
- if (l && d.add("border", l), m?.style) {
573
- const u = m.style;
574
- d.add("text-align", u.align).add("vertical-align", u.verticalAlign).add("background-color", u.backgroundColor).add("color", u.color).add("font-weight", u.bold ? "700" : void 0), d.add("font-size", `${ee(U(u, n).fontSizePx, 2)}px`);
593
+ const r = ye(t.style), a = te(t.style), l = r.inner ? `${ne(a.widthPt * n / 72, 2)}px solid ${a.color}` : "";
594
+ return e.cells.forEach((d, m) => {
595
+ const h = o.createElement("tr");
596
+ h.className = j("row", i), e.rowHeightsMm?.[m] != null && new V().mm("height", e.rowHeightsMm[m], n).applyTo(h), (d || []).forEach((f) => {
597
+ const g = o.createElement("td");
598
+ g.className = j("cell", i), f?.colSpan && (g.colSpan = f.colSpan), f?.rowSpan && (g.rowSpan = f.rowSpan);
599
+ const c = new V();
600
+ if (l && c.add("border", l), f?.style) {
601
+ const b = f.style;
602
+ c.add("text-align", b.align).add("vertical-align", b.verticalAlign).add("background-color", b.backgroundColor).add("color", b.color).add("font-weight", b.bold ? "700" : void 0), c.add("font-size", `${ne(K(b, n).fontSizePx, 2)}px`);
575
603
  }
576
- if (d.applyTo(b), m?.text != null && (b.textContent = m.text), m?.children?.length)
577
- for (const u of m.children)
578
- b.appendChild(Je(u, n, r, i));
579
- h.appendChild(b);
604
+ if (c.applyTo(g), f?.text != null && (g.textContent = f.text), f?.children?.length)
605
+ for (const b of f.children)
606
+ g.appendChild(Ue(b, n, i, o));
607
+ h.appendChild(g);
580
608
  }), s.appendChild(h);
581
609
  }), s;
582
610
  }
583
- function wt(e, t, n, r) {
584
- const i = r.createElement("div");
585
- i.className = F("text", n);
586
- const s = e.style || {}, o = new z().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
611
+ function Tt(e, t, n, i) {
612
+ const o = i.createElement("div");
613
+ o.className = j("text", n);
614
+ const s = e.style || {}, r = new V().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
587
615
  "justify-content",
588
616
  s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start"
589
617
  ).add("overflow", "hidden");
590
- if (Ve(o, e, t), o.applyTo(i), Le(e)) {
591
- const a = r.createElement("div");
592
- a.className = F("rich", n);
618
+ if (Ye(r, e, t), r.applyTo(o), De(e)) {
619
+ const a = i.createElement("div");
620
+ a.className = j("rich", n);
593
621
  for (const l of e.richParagraphs) {
594
- const c = r.createElement("div");
595
- c.className = F("paragraph", n), new z().add("text-align", l.align).add("line-height", l.lineHeight != null ? String(l.lineHeight) : void 0).mm("margin-top", l.spaceBeforeMm ?? 0, t).mm("margin-bottom", l.spaceAfterMm ?? 0, t).mm("text-indent", l.indentMm ?? 0, t).applyTo(c);
622
+ const d = i.createElement("div");
623
+ d.className = j("paragraph", n), new V().add("text-align", l.align).add("line-height", l.lineHeight != null ? String(l.lineHeight) : void 0).mm("margin-top", l.spaceBeforeMm ?? 0, t).mm("margin-bottom", l.spaceAfterMm ?? 0, t).mm("text-indent", l.indentMm ?? 0, t).applyTo(d);
596
624
  for (const h of l.segments || []) {
597
- const m = r.createElement("span");
598
- if (m.className = F("segment", n), m.textContent = h.kind === "field" ? h.field ?? "" : h.text ?? "", h.style) {
599
- const b = new z().add("color", h.style.color).add("font-weight", h.style.bold ? "700" : void 0);
600
- b.add("font-size", `${ee(U(h.style, t).fontSizePx, 2)}px`), b.applyTo(m);
625
+ const f = i.createElement("span");
626
+ if (f.className = j("segment", n), f.textContent = h.kind === "field" ? h.field ?? "" : h.text ?? "", h.style) {
627
+ const g = new V().add("color", h.style.color).add("font-weight", h.style.bold ? "700" : void 0);
628
+ g.add("font-size", `${ne(K(h.style, t).fontSizePx, 2)}px`), g.applyTo(f);
601
629
  }
602
- c.appendChild(m);
630
+ d.appendChild(f);
603
631
  }
604
- a.appendChild(c);
632
+ a.appendChild(d);
605
633
  }
606
- return i.appendChild(a), i;
634
+ return o.appendChild(a), o;
607
635
  }
608
636
  if (Array.isArray(e.lines) && e.lines.length > 0) {
609
- const a = r.createElement("div");
610
- a.className = F("lines", n), s.lineHeight != null && new z().add("line-height", String(s.lineHeight)).applyTo(a);
637
+ const a = i.createElement("div");
638
+ a.className = j("lines", n), s.lineHeight != null && new V().add("line-height", String(s.lineHeight)).applyTo(a);
611
639
  for (const l of e.lines) {
612
- const c = r.createElement("div");
613
- c.className = F("line", n), c.textContent = l, a.appendChild(c);
640
+ const d = i.createElement("div");
641
+ d.className = j("line", n), d.textContent = l, a.appendChild(d);
614
642
  }
615
- return i.appendChild(a), i;
643
+ return o.appendChild(a), o;
616
644
  }
617
- return i.textContent = e.text ?? "", i;
618
- }
619
- function $t(e, t, n) {
620
- const r = n.createElement("img");
621
- return r.className = F("image", t), r.src = e.imageData, new z().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(r), r.alt = e.kind, r;
622
- }
623
- function Oe(e, t, n, r) {
624
- const i = r.createElement("div");
625
- i.className = F("shape", n);
626
- const s = e.style || {}, o = Z(s), a = pe(s), l = `${ee(o.widthPt * t / 72, 2)}px solid ${o.color}`, c = new z();
627
- return e.grid || e.kind === "rect" ? (a.top && c.add("border-top", l), a.right && c.add("border-right", l), a.bottom && c.add("border-bottom", l), a.left && c.add("border-left", l)) : e.kind === "ellipse" ? (a.inner && c.add("border", l).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", l), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
628
- }
629
- function Je(e, t, n, r) {
630
- const i = r.createElement("div");
631
- i.className = `${F("comp", n)} mr-kind-${e.kind}`;
632
- const s = new z().add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
633
- if (Ve(s, e, t), s.applyTo(i), it(e))
634
- return i.appendChild($t(e, n, r)), i;
645
+ return o.textContent = e.text ?? "", o;
646
+ }
647
+ function kt(e, t, n) {
648
+ const i = n.createElement("img");
649
+ return i.className = j("image", t), i.src = e.imageData, new V().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(i), i.alt = e.kind, i;
650
+ }
651
+ function Fe(e, t, n, i) {
652
+ const o = i.createElement("div");
653
+ o.className = j("shape", n);
654
+ const s = e.style || {}, r = te(s), a = ye(s), l = `${ne(r.widthPt * t / 72, 2)}px solid ${r.color}`, d = new V();
655
+ return e.grid || e.kind === "rect" ? (a.top && d.add("border-top", l), a.right && d.add("border-right", l), a.bottom && d.add("border-bottom", l), a.left && d.add("border-left", l)) : e.kind === "ellipse" ? (a.inner && d.add("border", l).add("border-radius", "50%"), s.backgroundColor && d.add("background-color", s.backgroundColor)) : e.kind === "line" && d.add("height", "0").add("border-top", l), d.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), d.applyTo(o), o;
656
+ }
657
+ function Ue(e, t, n, i) {
658
+ const o = i.createElement("div");
659
+ o.className = `${j("comp", n)} mr-kind-${e.kind}`;
660
+ const s = new V().add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
661
+ if (Ye(s, e, t), s.applyTo(o), lt(e))
662
+ return o.appendChild(kt(e, n, i)), o;
635
663
  if (e.kind === "text")
636
- return i.appendChild(wt(e, t, n, r)), i;
664
+ return o.appendChild(Tt(e, t, n, i)), o;
637
665
  if (e.grid) {
638
- const a = Oe(e, t, n, r);
639
- return a.appendChild(bt(e.grid, e, t, n, r)), i.appendChild(a), i;
666
+ const a = Fe(e, t, n, i);
667
+ return a.appendChild(vt(e.grid, e, t, n, i)), o.appendChild(a), o;
640
668
  }
641
669
  if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse" || e.kind === "chart")
642
- return i.appendChild(Oe(e, t, n, r)), i;
643
- const o = r.createElement("div");
644
- return o.className = F("unknown", n), o.textContent = e.fallbackText ?? "", i.appendChild(o), i;
670
+ return o.appendChild(Fe(e, t, n, i)), o;
671
+ const r = i.createElement("div");
672
+ return r.className = j("unknown", n), r.textContent = e.fallbackText ?? "", o.appendChild(r), o;
645
673
  }
646
- function St(e, t, n, r) {
647
- const i = r.createElement("div");
648
- i.className = F("page", n), new z().add("position", "relative").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i);
674
+ function At(e, t, n, i) {
675
+ const o = i.createElement("div");
676
+ o.className = j("page", n), new V().add("position", "relative").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", Ie).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(o);
649
677
  for (const s of e.components)
650
- i.appendChild(Je(s, t, n, r));
651
- return i;
678
+ o.appendChild(Ue(s, t, n, i));
679
+ return o;
652
680
  }
653
- function It(e, t, n = {}) {
654
- const r = n.dpi ?? 96, i = t.createElement("div");
655
- return i.className = F("root", n), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((s) => {
656
- i.appendChild(St(s, r, n, t));
657
- }), i;
681
+ function Gt(e, t, n = {}) {
682
+ const i = n.dpi ?? 96, o = t.createElement("div");
683
+ return o.className = j("root", n), o.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((s) => {
684
+ o.appendChild(At(s, i, n, t));
685
+ }), o;
658
686
  }
659
- function kt(e) {
660
- return ot(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
687
+ function Et(e) {
688
+ return dt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
661
689
  }
662
- const Ae = 96 / 25.4;
663
- function Ge(e, t = 96) {
664
- const n = t / 96 * Ae;
690
+ const Pe = 96 / 25.4;
691
+ function qe(e, t = 96) {
692
+ const n = t / 96 * Pe;
665
693
  return {
666
694
  widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
667
695
  heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
668
696
  };
669
697
  }
670
- function vt(e, t, n) {
671
- const r = document.createElement("canvas"), { widthPx: i, heightPx: s } = Ge(e, n);
672
- r.width = Math.round(i * t), r.height = Math.round(s * t), r.style.width = `${i}px`, r.style.height = `${s}px`;
673
- const o = r.getContext("2d");
674
- if (!o)
698
+ function Pt(e, t, n) {
699
+ const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = qe(e, n);
700
+ i.width = Math.round(o * t), i.height = Math.round(s * t), i.style.width = `${o}px`, i.style.height = `${s}px`;
701
+ const r = i.getContext("2d");
702
+ if (!r)
675
703
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
676
- return o.scale(t, t), o.fillStyle = "#ffffff", o.fillRect(0, 0, i, s), { canvas: r, ctx: o };
704
+ return r.scale(t, t), r.fillStyle = "#ffffff", r.fillRect(0, 0, o, s), { canvas: i, ctx: r };
677
705
  }
678
- function Wt(e, t = 96) {
679
- return U(e, t).fontSizePx;
706
+ function Yt(e, t = 96) {
707
+ return K(e, t).fontSizePx;
680
708
  }
681
- function Ye(e, t, n, r, i, s, o, a = "top") {
682
- e.font = `${t.bold ? "bold " : ""}${t.fontSizePx}px ${o}`, e.fillStyle = t.color, e.textBaseline = "alphabetic";
683
- const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
684
- `), f = c.length * l;
685
- let h = r;
686
- a === "middle" ? h = r + (s - f) / 2 : a === "bottom" && (h = r + s - f), c.forEach((m, b) => {
709
+ function Ke(e, t, n, i, o, s, r, a = "top") {
710
+ e.font = `${t.bold ? "bold " : ""}${t.fontSizePx}px ${r}`, e.fillStyle = t.color, e.textBaseline = "alphabetic";
711
+ const l = t.fontSizePx * t.lineHeight, d = t.text === "" ? [""] : t.text.split(`
712
+ `), m = d.length * l;
713
+ let h = i;
714
+ a === "middle" ? h = i + (s - m) / 2 : a === "bottom" && (h = i + s - m), d.forEach((f, g) => {
687
715
  e.textAlign = t.align === "center" ? "center" : t.align === "right" ? "right" : "left";
688
- const d = t.align === "center" ? n + i / 2 : t.align === "right" ? n + i : n;
689
- e.fillText(m, d, h + b * l + t.fontSizePx * 0.8, i);
716
+ const c = t.align === "center" ? n + o / 2 : t.align === "right" ? n + o : n;
717
+ e.fillText(f, c, h + g * l + t.fontSizePx * 0.8, o);
690
718
  }), e.textAlign = "left";
691
719
  }
692
- function Tt(e, t, n, r, i, s, o, a, l, c, f) {
693
- const h = nt(t, s / a, o / a), m = pe(n.style), b = Z(n.style);
694
- for (const d of h.cells) {
695
- const u = d.cell.style?.backgroundColor;
696
- u && (e.fillStyle = u, e.fillRect(
697
- r + d.xMm * a,
698
- i + d.yMm * a,
699
- d.widthMm * a,
700
- d.heightMm * a
720
+ function xt(e, t, n, i, o, s, r, a, l, d, m) {
721
+ const h = at(t, s / a, r / a), f = ye(n.style), g = te(n.style);
722
+ for (const c of h.cells) {
723
+ const b = c.cell.style?.backgroundColor;
724
+ b && (e.fillStyle = b, e.fillRect(
725
+ i + c.xMm * a,
726
+ o + c.yMm * a,
727
+ c.widthMm * a,
728
+ c.heightMm * a
701
729
  ));
702
730
  }
703
- if (m.inner) {
704
- e.strokeStyle = b.color, e.lineWidth = fe(b.widthPt, l);
705
- for (const d of h.edges)
706
- e.beginPath(), d.kind === "v" ? (e.moveTo(r + d.pos * a, i + d.from * a), e.lineTo(r + d.pos * a, i + d.to * a)) : (e.moveTo(r + d.from * a, i + d.pos * a), e.lineTo(r + d.to * a, i + d.pos * a)), e.stroke();
707
- e.beginPath(), m.top && (e.moveTo(r, i), e.lineTo(r + s, i)), m.right && (e.moveTo(r + s, i), e.lineTo(r + s, i + o)), m.bottom && (e.moveTo(r + s, i + o), e.lineTo(r, i + o)), m.left && (e.moveTo(r, i + o), e.lineTo(r, i)), e.stroke();
731
+ if (f.inner) {
732
+ e.strokeStyle = g.color, e.lineWidth = he(g.widthPt, l);
733
+ for (const c of h.edges)
734
+ e.beginPath(), c.kind === "v" ? (e.moveTo(i + c.pos * a, o + c.from * a), e.lineTo(i + c.pos * a, o + c.to * a)) : (e.moveTo(i + c.from * a, o + c.pos * a), e.lineTo(i + c.to * a, o + c.pos * a)), e.stroke();
735
+ e.beginPath(), f.top && (e.moveTo(i, o), e.lineTo(i + s, o)), f.right && (e.moveTo(i + s, o), e.lineTo(i + s, o + r)), f.bottom && (e.moveTo(i + s, o + r), e.lineTo(i, o + r)), f.left && (e.moveTo(i, o + r), e.lineTo(i, o)), e.stroke();
708
736
  }
709
- for (const d of h.cells) {
710
- const u = typeof d.cell.text == "string" ? d.cell.text : "";
711
- if (!u) continue;
712
- const w = d.cell.style, S = w?.fontSize ?? $e, g = oe(
713
- u,
714
- d.widthMm - 1,
715
- { fontSizePt: S },
716
- f
737
+ for (const c of h.cells) {
738
+ const b = typeof c.cell.text == "string" ? c.cell.text : "";
739
+ if (!b) continue;
740
+ const y = c.cell.style, T = y?.fontSize ?? ve, $ = le(
741
+ b,
742
+ c.widthMm - 1,
743
+ { fontSizePt: T },
744
+ m
717
745
  ).join(`
718
746
  `);
719
- Ye(
747
+ Ke(
720
748
  e,
721
749
  {
722
- text: g,
723
- fontSizePx: U(w, l).fontSizePx,
724
- bold: w?.bold ?? !1,
725
- color: w?.color ?? Fe(n.style, rt),
726
- align: w?.align ?? "left",
727
- lineHeight: Se
750
+ text: $,
751
+ fontSizePx: K(y, l).fontSizePx,
752
+ bold: y?.bold ?? !1,
753
+ color: y?.color ?? je(n.style, Ie),
754
+ align: y?.align ?? "left",
755
+ lineHeight: Te
728
756
  },
729
- r + (d.xMm + 0.5) * a,
730
- i + d.yMm * a,
731
- Math.max(0, (d.widthMm - 1) * a),
732
- d.heightMm * a,
733
- c,
734
- w?.verticalAlign ?? "middle"
757
+ i + (c.xMm + 0.5) * a,
758
+ o + c.yMm * a,
759
+ Math.max(0, (c.widthMm - 1) * a),
760
+ c.heightMm * a,
761
+ d,
762
+ y?.verticalAlign ?? "middle"
735
763
  );
736
764
  }
737
765
  }
738
- function Ue(e, t, n, r, i, s) {
739
- const o = t.leftMm * n, a = t.topMm * n, l = t.widthMm * n, c = t.heightMm * n, f = t.style ?? {};
766
+ function Xe(e, t, n, i, o, s) {
767
+ const r = t.leftMm * n, a = t.topMm * n, l = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
740
768
  if (t.grid) {
741
- Tt(e, t.grid, t, o, a, l, c, n, r, i, s);
769
+ xt(e, t.grid, t, r, a, l, d, n, i, o, s);
742
770
  return;
743
771
  }
744
772
  switch (t.kind) {
745
773
  case "text": {
746
- const h = f.fontSize ?? $e, m = Le(t) ? t.richParagraphs.map((b) => (b.segments ?? []).map((d) => d.text ?? d.field ?? "").join("")).join(`
774
+ const h = m.fontSize ?? ve, f = De(t) ? t.richParagraphs.map((g) => (g.segments ?? []).map((c) => c.text ?? c.field ?? "").join("")).join(`
747
775
  `) : Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
748
- `) : oe(t.text ?? "", t.widthMm, { fontSizePt: h }, s).join(`
776
+ `) : le(t.text ?? "", t.widthMm, { fontSizePt: h }, s).join(`
749
777
  `);
750
- Ye(
778
+ Ke(
751
779
  e,
752
780
  {
753
- text: m,
754
- fontSizePx: U(f, r).fontSizePx,
755
- bold: f.bold ?? !1,
756
- color: Fe(f),
757
- align: f.align ?? "left",
758
- lineHeight: tt(f)
781
+ text: f,
782
+ fontSizePx: K(m, i).fontSizePx,
783
+ bold: m.bold ?? !1,
784
+ color: je(m),
785
+ align: m.align ?? "left",
786
+ lineHeight: st(m)
759
787
  },
760
- o,
788
+ r,
761
789
  a,
762
790
  l,
763
- c,
764
- i,
765
- f.verticalAlign
791
+ d,
792
+ o,
793
+ m.verticalAlign
766
794
  );
767
795
  break;
768
796
  }
769
797
  case "rect": {
770
- const h = Z(f), m = pe(f);
771
- f.backgroundColor && (e.fillStyle = f.backgroundColor, e.fillRect(o, a, l, c)), m.inner && (e.strokeStyle = h.color, e.lineWidth = fe(h.widthPt, r), e.beginPath(), m.top && (e.moveTo(o, a), e.lineTo(o + l, a)), m.right && (e.moveTo(o + l, a), e.lineTo(o + l, a + c)), m.bottom && (e.moveTo(o + l, a + c), e.lineTo(o, a + c)), m.left && (e.moveTo(o, a + c), e.lineTo(o, a)), e.stroke());
798
+ const h = te(m), f = ye(m);
799
+ m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(r, a, l, d)), f.inner && (e.strokeStyle = h.color, e.lineWidth = he(h.widthPt, i), e.beginPath(), f.top && (e.moveTo(r, a), e.lineTo(r + l, a)), f.right && (e.moveTo(r + l, a), e.lineTo(r + l, a + d)), f.bottom && (e.moveTo(r + l, a + d), e.lineTo(r, a + d)), f.left && (e.moveTo(r, a + d), e.lineTo(r, a)), e.stroke());
772
800
  break;
773
801
  }
774
802
  case "line": {
775
- const h = Z({ ...f, borderColor: f.lineColor ?? f.borderColor });
776
- e.strokeStyle = h.color, e.lineWidth = fe(h.widthPt, r), e.beginPath(), e.moveTo(o, a + c / 2), e.lineTo(o + l, a + c / 2), e.stroke();
803
+ const h = te({ ...m, borderColor: m.lineColor ?? m.borderColor });
804
+ e.strokeStyle = h.color, e.lineWidth = he(h.widthPt, i), e.beginPath(), e.moveTo(r, a + d / 2), e.lineTo(r + l, a + d / 2), e.stroke();
777
805
  break;
778
806
  }
779
807
  case "ellipse": {
780
- const h = Z(f);
781
- e.strokeStyle = h.color, e.lineWidth = fe(h.widthPt, r), f.backgroundColor && (e.fillStyle = f.backgroundColor, e.beginPath(), e.ellipse(o + l / 2, a + c / 2, l / 2, c / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(o + l / 2, a + c / 2, l / 2, c / 2, 0, 0, Math.PI * 2), e.stroke();
808
+ const h = te(m);
809
+ e.strokeStyle = h.color, e.lineWidth = he(h.widthPt, i), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(r + l / 2, a + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(r + l / 2, a + d / 2, l / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
782
810
  break;
783
811
  }
784
812
  }
785
813
  }
786
- async function Vt(e, t = {}) {
814
+ async function Ut(e, t = {}) {
787
815
  if (typeof document > "u")
788
816
  throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
789
- const { format: n = "png", quality: r = 0.92, ...i } = t, { canvases: s } = At(e, i), o = n === "jpeg" ? "image/jpeg" : "image/png", a = [];
817
+ const { format: n = "png", quality: i = 0.92, ...o } = t, { canvases: s } = Nt(e, o), r = n === "jpeg" ? "image/jpeg" : "image/png", a = [];
790
818
  for (const l of s)
791
819
  a.push(
792
820
  await new Promise(
793
- (c) => l.toBlob((f) => c(f), o, r)
794
- ) ?? new Blob([], { type: o })
821
+ (d) => l.toBlob((m) => d(m), r, i)
822
+ ) ?? new Blob([], { type: r })
795
823
  );
796
824
  return { blobs: a };
797
825
  }
798
- function At(e, t = {}) {
826
+ function Nt(e, t = {}) {
799
827
  if (typeof document > "u")
800
828
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
801
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * Ae, s = t.fontFamily ?? '"Microsoft YaHei", sans-serif', o = t.measurer ?? ke, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [];
802
- for (let f = a; f <= l; f++) {
803
- const h = e.pages[f], { canvas: m, ctx: b } = vt(h, n, r);
804
- for (const d of h.components)
805
- Ue(b, d, i, r, s, o);
806
- c.push(m);
829
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), i = t.dpi ?? 96, o = i / 96 * Pe, s = t.fontFamily ?? '"Microsoft YaHei", sans-serif', r = t.measurer ?? ke, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), d = [];
830
+ for (let m = a; m <= l; m++) {
831
+ const h = e.pages[m], { canvas: f, ctx: g } = Pt(h, n, i);
832
+ for (const c of h.components)
833
+ Xe(g, c, o, i, s, r);
834
+ d.push(f);
807
835
  }
808
- return { canvases: c };
809
- }
810
- function Jt(e, t = {}) {
811
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * Ae, s = t.fontFamily ?? '"Microsoft YaHei", sans-serif', o = t.measurer ?? ke, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, f = e.pages.map((M) => M.pageHeightMm * i), h = Math.max(1, ...e.pages.map((M) => M.pageWidthMm * i)), m = { start: 0, end: -1 };
812
- let b = null, d = null, u = null, w = null, S = [], g = 0, E = [];
813
- function A() {
814
- const M = b;
815
- M.innerHTML = "", d = document.createElement("div"), d.style.cssText = `width:${h}px;margin:0 auto;`, u = document.createElement("div"), w = document.createElement("div"), d.appendChild(u), S = [];
816
- const R = Math.min(e.pages.length, 3 + a * 2);
817
- for (let L = 0; L < R; L++) {
818
- const T = document.createElement("div");
819
- T.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, d.appendChild(T), S.push(T);
836
+ return { canvases: d };
837
+ }
838
+ function qt(e, t = {}) {
839
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), i = t.dpi ?? 96, o = i / 96 * Pe, s = t.fontFamily ?? '"Microsoft YaHei", sans-serif', r = t.measurer ?? ke, a = t.overscan ?? 1, l = t.gapPx ?? 18, d = t.pagesPerFrame ?? 1, m = e.pages.map((p) => p.pageHeightMm * o), h = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * o)), f = { start: 0, end: -1 };
840
+ let g = null, c = null, b = null, y = null, T = [], $ = 0, E = [];
841
+ function S() {
842
+ const p = g;
843
+ p.innerHTML = "", c = document.createElement("div"), c.style.cssText = `width:${h}px;margin:0 auto;`, b = document.createElement("div"), y = document.createElement("div"), c.appendChild(b), T = [];
844
+ const B = Math.min(e.pages.length, 3 + a * 2);
845
+ for (let A = 0; A < B; A++) {
846
+ const P = document.createElement("div");
847
+ P.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, c.appendChild(P), T.push(P);
820
848
  }
821
- d.appendChild(w), M.appendChild(d);
849
+ c.appendChild(y), p.appendChild(c);
822
850
  }
823
- function v(M, R) {
824
- const L = e.pages[R], { widthPx: T, heightPx: H } = Ge(L, r);
825
- let C = M.firstElementChild;
826
- (!C || C.tagName !== "CANVAS") && (C = document.createElement("canvas"), M.innerHTML = "", M.appendChild(C)), C.width = Math.round(T * n), C.height = Math.round(H * n), C.style.width = `${T}px`, C.style.height = `${H}px`;
827
- const G = C.getContext("2d");
828
- if (G) {
829
- G.setTransform(1, 0, 0, 1, 0, 0), G.scale(n, n), G.fillStyle = "#ffffff", G.fillRect(0, 0, T, H);
830
- for (const se of L.components)
831
- Ue(G, se, i, r, s, o);
832
- C.dataset.canvasPage = String(R), M.style.height = `${H}px`, M.style.width = `${T}px`;
851
+ function R(p, B) {
852
+ const A = e.pages[B], { widthPx: P, heightPx: N } = qe(A, i);
853
+ let L = p.firstElementChild;
854
+ (!L || L.tagName !== "CANVAS") && (L = document.createElement("canvas"), p.innerHTML = "", p.appendChild(L)), L.width = Math.round(P * n), L.height = Math.round(N * n), L.style.width = `${P}px`, L.style.height = `${N}px`;
855
+ const J = L.getContext("2d");
856
+ if (J) {
857
+ J.setTransform(1, 0, 0, 1, 0, 0), J.scale(n, n), J.fillStyle = "#ffffff", J.fillRect(0, 0, P, N);
858
+ for (const Q of A.components)
859
+ Xe(J, Q, o, i, s, r);
860
+ L.dataset.canvasPage = String(B), p.style.height = `${N}px`, p.style.width = `${P}px`;
833
861
  }
834
862
  }
835
- function I(M) {
836
- m.start = M.start, m.end = M.end, u.style.height = `${M.start * l + f.slice(0, M.start).reduce((T, H) => T + H, 0)}px`;
837
- const R = e.pages.length - 1 - M.end;
838
- w.style.height = `${R * l + f.slice(M.end + 1).reduce((T, H) => T + H, 0)}px`;
839
- const L = M.end - M.start + 1;
840
- S.forEach((T, H) => {
841
- if (H < L) {
842
- T.style.display = "";
843
- const C = M.start + H;
844
- T.style.height = `${f[C] ?? 0}px`;
863
+ function F(p) {
864
+ f.start = p.start, f.end = p.end, b.style.height = `${p.start * l + m.slice(0, p.start).reduce((P, N) => P + N, 0)}px`;
865
+ const B = e.pages.length - 1 - p.end;
866
+ y.style.height = `${B * l + m.slice(p.end + 1).reduce((P, N) => P + N, 0)}px`;
867
+ const A = p.end - p.start + 1;
868
+ T.forEach((P, N) => {
869
+ if (N < A) {
870
+ P.style.display = "";
871
+ const L = p.start + N;
872
+ P.style.height = `${m[L] ?? 0}px`;
845
873
  } else
846
- T.style.display = "none";
874
+ P.style.display = "none";
847
875
  }), E = [];
848
- for (let T = M.start; T <= M.end; T++) {
849
- const H = S[T - M.start];
850
- if (!H) continue;
851
- H.firstElementChild?.dataset?.canvasPage !== String(T) && E.push(T);
876
+ for (let P = p.start; P <= p.end; P++) {
877
+ const N = T[P - p.start];
878
+ if (!N) continue;
879
+ N.firstElementChild?.dataset?.canvasPage !== String(P) && E.push(P);
852
880
  }
853
- p();
881
+ k();
854
882
  }
855
- function p() {
856
- g || E.length === 0 || (g = requestAnimationFrame(() => {
857
- g = 0;
858
- let M = Math.max(1, c);
859
- for (; E.length > 0 && M-- > 0; ) {
860
- const R = E.shift(), L = S[R - m.start];
861
- L && v(L, R);
883
+ function k() {
884
+ $ || E.length === 0 || ($ = requestAnimationFrame(() => {
885
+ $ = 0;
886
+ let p = Math.max(1, d);
887
+ for (; E.length > 0 && p-- > 0; ) {
888
+ const B = E.shift(), A = T[B - f.start];
889
+ A && R(A, B);
862
890
  }
863
- E.length > 0 && p();
891
+ E.length > 0 && k();
864
892
  }));
865
893
  }
866
- function k() {
867
- g || (g = requestAnimationFrame(() => {
868
- g = 0;
869
- const M = b, R = kt({
870
- pageHeightsPx: f,
871
- viewportHeightPx: M.clientHeight,
872
- scrollTopPx: M.scrollTop,
894
+ function v() {
895
+ $ || ($ = requestAnimationFrame(() => {
896
+ $ = 0;
897
+ const p = g, B = Et({
898
+ pageHeightsPx: m,
899
+ viewportHeightPx: p.clientHeight,
900
+ scrollTopPx: p.scrollTop,
873
901
  overscan: a,
874
902
  gapPx: l
875
903
  });
876
- R.start !== m.start || R.end !== m.end ? I(R) : p();
904
+ B.start !== f.start || B.end !== f.end ? F(B) : k();
877
905
  }));
878
906
  }
879
- let X = null;
907
+ let u = null;
880
908
  return {
881
- attach(M) {
909
+ attach(p) {
882
910
  if (typeof document > "u")
883
911
  throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
884
- b = M, A(), M.addEventListener("scroll", k, { passive: !0 }), typeof ResizeObserver < "u" && (X = new ResizeObserver(() => k()), X.observe(M)), k();
912
+ g = p, S(), p.addEventListener("scroll", v, { passive: !0 }), typeof ResizeObserver < "u" && (u = new ResizeObserver(() => v()), u.observe(p)), v();
885
913
  },
886
914
  destroy() {
887
- g && cancelAnimationFrame(g), g = 0, X?.disconnect(), X = null, b?.removeEventListener("scroll", k), E = [], d?.remove(), b = null;
915
+ $ && cancelAnimationFrame($), $ = 0, u?.disconnect(), u = null, g?.removeEventListener("scroll", v), E = [], c?.remove(), g = null;
888
916
  },
889
917
  window() {
890
- return { ...m };
918
+ return { ...f };
891
919
  }
892
920
  };
893
921
  }
894
- function qe(e, t, n) {
895
- let r, i;
922
+ function Qe(e, t, n) {
923
+ let i, o;
896
924
  if (typeof e == "string") {
897
- const s = he[e];
898
- if (!s) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(he).join("/")})`);
899
- r = s.widthMm, i = s.heightMm;
900
- } else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
901
- return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
925
+ const s = ge[e];
926
+ if (!s) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(ge).join("/")})`);
927
+ i = s.widthMm, o = s.heightMm;
928
+ } else typeof e == "number" ? (i = e, o = t ?? 297) : (i = e.widthMm, o = e.heightMm);
929
+ return n ? { widthMm: o, heightMm: i } : { widthMm: i, heightMm: o };
902
930
  }
903
- class Et {
931
+ class Ct {
904
932
  constructor() {
905
933
  this.pages = [], this.pending = null, this.templateParams = void 0;
906
934
  }
@@ -927,15 +955,15 @@ class Et {
927
955
  * - 数字:.page(210, 297)(第三参数兼容旧 margins 对象或新 options)
928
956
  * - 对象:.page({ widthMm: 210, heightMm: 297 })
929
957
  */
930
- page(t = "a4", n = {}, r) {
958
+ page(t = "a4", n = {}, i) {
931
959
  this.collect();
932
- const s = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: o, heightMm: a } = qe(
960
+ const s = i != null && !("margins" in i) && !("landscape" in i) && ("marginTopMm" in i || "marginBottomMm" in i || "marginLeftMm" in i || "marginRightMm" in i) ? { margins: i } : typeof n == "number" ? i ?? {} : n, { widthMm: r, heightMm: a } = Qe(
933
961
  t,
934
962
  typeof n == "number" ? n : void 0,
935
963
  s.landscape
936
964
  ), l = s.margins ?? {};
937
- return this.pending = new Pt(this, {
938
- widthMm: o,
965
+ return this.pending = new Rt(this, {
966
+ widthMm: r,
939
967
  heightMm: a,
940
968
  marginTopMm: l.marginTopMm ?? 10,
941
969
  marginBottomMm: l.marginBottomMm ?? 10,
@@ -952,11 +980,11 @@ class Et {
952
980
  return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
953
981
  }
954
982
  }
955
- class Pt {
983
+ class Rt {
956
984
  constructor(t, n) {
957
985
  this.parent = t, this.page = n, this.components = [];
958
986
  }
959
- text(t, n = {}, r = {}) {
987
+ text(t, n = {}, i = {}) {
960
988
  return this.components.push({
961
989
  kind: "text",
962
990
  leftMm: n.leftMm ?? 0,
@@ -964,31 +992,31 @@ class Pt {
964
992
  widthMm: n.widthMm ?? 60,
965
993
  heightMm: n.heightMm ?? 8,
966
994
  text: t,
967
- style: r
995
+ style: i
968
996
  }), this;
969
997
  }
970
- list(t, n, r, i = {}) {
998
+ list(t, n, i, o = {}) {
971
999
  return this.components.push({
972
1000
  kind: "list",
973
1001
  leftMm: n.leftMm ?? 10,
974
1002
  topMm: n.topMm ?? 30,
975
1003
  widthMm: n.widthMm ?? 180,
976
1004
  dataset: t,
977
- columns: r,
978
- ...i
1005
+ columns: i,
1006
+ ...o
979
1007
  }), this;
980
1008
  }
981
1009
  rect(t, n = {}) {
982
1010
  return this.components.push({ kind: "rect", ...t, style: n }), this;
983
1011
  }
984
- line(t, n, r, i = {}) {
1012
+ line(t, n, i, o = {}) {
985
1013
  return this.components.push({
986
1014
  kind: "line",
987
1015
  leftMm: t,
988
1016
  topMm: n,
989
- widthMm: r,
1017
+ widthMm: i,
990
1018
  heightMm: 0.5,
991
- style: i
1019
+ style: o
992
1020
  }), this;
993
1021
  }
994
1022
  barcode(t, n) {
@@ -1001,11 +1029,11 @@ class Pt {
1001
1029
  fallbackText: t
1002
1030
  }), this;
1003
1031
  }
1004
- qrcode(t, n, r, i) {
1032
+ qrcode(t, n, i, o) {
1005
1033
  return this.components.push({
1006
1034
  kind: "qrcode",
1007
- leftMm: r,
1008
- topMm: i,
1035
+ leftMm: i,
1036
+ topMm: o,
1009
1037
  widthMm: n,
1010
1038
  heightMm: n,
1011
1039
  fallbackText: t
@@ -1021,118 +1049,134 @@ class Pt {
1021
1049
  return this.done().build();
1022
1050
  }
1023
1051
  }
1024
- function Gt() {
1025
- return new Et();
1052
+ function Kt() {
1053
+ return new Ct();
1026
1054
  }
1027
- function V(e, t, n = !1) {
1055
+ function W(e, t, n = !1) {
1028
1056
  if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
1029
1057
  throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
1030
1058
  }
1031
- function me(e, t, n) {
1059
+ function fe(e, t, n) {
1032
1060
  if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
1033
1061
  throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
1034
1062
  }
1035
- function Yt(e) {
1063
+ function Xt(e) {
1036
1064
  if (!e || typeof e != "object")
1037
1065
  throw new Error("标准明细模板需要 options 对象");
1038
1066
  if (!Array.isArray(e.columns) || e.columns.length === 0)
1039
1067
  throw new Error("columns 至少需要一列");
1040
- const t = e.paper === void 0 ? "a4" : e.paper;
1041
- if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
1068
+ const t = e.layout ?? "page";
1069
+ if (t !== "page" && t !== "wide")
1070
+ throw new Error("layout 必须是 page 或 wide");
1071
+ if (t === "wide" && (e.paper !== void 0 || e.landscape !== void 0))
1072
+ throw new Error('宽表布局不能同时指定 paper 或 landscape;标准纸型请使用 layout: "page"');
1073
+ if (t !== "wide" && e.columnWidthMm !== void 0)
1074
+ throw new Error('columnWidthMm 仅适用于 layout: "wide"');
1075
+ const n = e.columnWidthMm ?? 30;
1076
+ W(n, "columnWidthMm");
1077
+ const i = e.paper === void 0 ? "a4" : e.paper;
1078
+ if (typeof i != "string" && (typeof i != "object" || i === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
1042
1079
  throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
1043
- if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(he, t))
1044
- throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(he).join("/")})`);
1045
- const { widthMm: n, heightMm: r } = qe(t, void 0, e.landscape);
1046
- if (V(n, "纸张 widthMm"), V(r, "纸张 heightMm"), e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
1080
+ if (typeof i == "string" && !Object.prototype.hasOwnProperty.call(ge, i))
1081
+ throw new Error(`未知纸张预设 "${i}"(可用:${Object.keys(ge).join("/")})`);
1082
+ const o = Qe(i, void 0, e.landscape);
1083
+ let s = o.widthMm;
1084
+ const r = o.heightMm;
1085
+ if (W(s, "纸张 widthMm"), W(r, "纸张 heightMm"), e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
1047
1086
  throw new Error("margins 必须是页边距对象");
1048
- const i = e.margins ?? {}, s = {
1049
- marginTopMm: i.marginTopMm === void 0 ? 10 : i.marginTopMm,
1050
- marginBottomMm: i.marginBottomMm === void 0 ? 10 : i.marginBottomMm,
1051
- marginLeftMm: i.marginLeftMm === void 0 ? 10 : i.marginLeftMm,
1052
- marginRightMm: i.marginRightMm === void 0 ? 10 : i.marginRightMm
1087
+ const a = e.margins ?? {}, l = {
1088
+ marginTopMm: a.marginTopMm === void 0 ? 10 : a.marginTopMm,
1089
+ marginBottomMm: a.marginBottomMm === void 0 ? 10 : a.marginBottomMm,
1090
+ marginLeftMm: a.marginLeftMm === void 0 ? 10 : a.marginLeftMm,
1091
+ marginRightMm: a.marginRightMm === void 0 ? 10 : a.marginRightMm
1053
1092
  };
1054
- for (const [A, v] of Object.entries(s)) V(v, A, !0);
1055
- const o = n - s.marginLeftMm - s.marginRightMm, a = r - s.marginTopMm - s.marginBottomMm;
1056
- if (o <= 0 || a <= 0)
1093
+ for (const [k, v] of Object.entries(l)) W(v, k, !0);
1094
+ let d = s - l.marginLeftMm - l.marginRightMm;
1095
+ const m = r - l.marginTopMm - l.marginBottomMm;
1096
+ if (t === "page" && d <= 0 || m <= 0)
1057
1097
  throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
1058
- const l = e.dataset === void 0 ? "detail" : e.dataset;
1059
- if (typeof l != "string" || !l.trim())
1098
+ const h = e.dataset === void 0 ? "detail" : e.dataset;
1099
+ if (typeof h != "string" || !h.trim())
1060
1100
  throw new Error("dataset 必须是非空字符串");
1061
1101
  if (e.title !== void 0 && typeof e.title != "string")
1062
1102
  throw new Error("title 必须是字符串");
1063
- const c = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, f = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
1064
- V(c, "titleHeightMm"), V(f, "titleGapMm", !0);
1065
- const h = e.title !== void 0 && e.title.length > 0, m = h ? c + f : 0;
1066
- if (m >= a)
1103
+ const f = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, g = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
1104
+ W(f, "titleHeightMm"), W(g, "titleGapMm", !0);
1105
+ const c = e.title !== void 0 && e.title.length > 0, b = c ? f + g : 0;
1106
+ if (b >= m)
1067
1107
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
1068
1108
  if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
1069
1109
  throw new Error("listOptions 必须是列表配置对象");
1070
- const b = e.listOptions ?? {};
1071
- me(b.align, "listOptions.align", !0), me(b.headerAlign, "listOptions.headerAlign", !1);
1072
- for (const A of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
1073
- const v = b[A];
1074
- v !== void 0 && V(v, `listOptions.${A}`, A === "paddingMm");
1110
+ const y = e.listOptions ?? {};
1111
+ fe(y.align, "listOptions.align", !0), fe(y.headerAlign, "listOptions.headerAlign", !1);
1112
+ for (const k of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
1113
+ const v = y[k];
1114
+ v !== void 0 && W(v, `listOptions.${k}`, k === "paddingMm");
1075
1115
  }
1076
- let d = 0, u = 0;
1077
- for (const [A, v] of e.columns.entries()) {
1116
+ let T = 0, $ = 0;
1117
+ for (const [k, v] of e.columns.entries()) {
1078
1118
  if (!v || typeof v.header != "string" || typeof v.field != "string" || !v.field.trim())
1079
- throw new Error(`columns[${A}] 需要字符串 header 与非空 field`);
1080
- me(v.align, `columns[${A}].align`, !0), me(v.headerAlign, `columns[${A}].headerAlign`, !1), v.flex !== void 0 && V(v.flex, `columns[${A}].flex`), v.widthMm !== void 0 ? (V(v.widthMm, `columns[${A}].widthMm`), d += v.widthMm) : u = Math.max(u, v.flex ?? 1);
1119
+ throw new Error(`columns[${k}] 需要字符串 header 与非空 field`);
1120
+ fe(v.align, `columns[${k}].align`, !0), fe(v.headerAlign, `columns[${k}].headerAlign`, !1), v.flex !== void 0 && W(v.flex, `columns[${k}].flex`), v.widthMm !== void 0 ? (W(v.widthMm, `columns[${k}].widthMm`), T += v.widthMm) : $ = Math.max($, v.flex ?? 1);
1081
1121
  }
1082
- if (d > o)
1083
- throw new Error(`固定列宽 ${d}mm 超出页面可用宽度 ${o}mm`);
1084
- const w = o - d;
1085
- if (u > 0 && w <= 0)
1122
+ if (t === "page" && T > d)
1123
+ throw new Error(`固定列宽 ${T}mm 超出页面可用宽度 ${d}mm`);
1124
+ const E = d - T;
1125
+ if (t === "page" && $ > 0 && E <= 0)
1086
1126
  throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
1087
- const S = u > 0 ? e.columns.reduce((A, v) => A + (v.widthMm === void 0 ? (v.flex ?? 1) / u : 0), 0) : 0, g = e.columns.map(({ widthMm: A, flex: v, ...I }, p) => {
1088
- const k = A ?? w * ((v ?? 1) / u) / S;
1089
- return V(k, `columns[${p}] 分配后的 widthMm`), { ...I, widthMm: k };
1090
- }), E = { widthMm: n, heightMm: r, ...s, components: [] };
1091
- return h && E.components.push({
1127
+ const S = $ > 0 ? e.columns.reduce((k, v) => k + (v.widthMm === void 0 ? (v.flex ?? 1) / $ : 0), 0) : 0, R = e.columns.map(({ widthMm: k, flex: v, ...u }, p) => {
1128
+ const B = k ?? (t === "wide" ? n * (v ?? 1) : E * ((v ?? 1) / $) / S);
1129
+ return W(B, `columns[${p}] 分配后的 widthMm`), { ...u, widthMm: B };
1130
+ });
1131
+ t === "wide" && (d = R.reduce((k, v) => k + v.widthMm, 0), W(d, "宽表总列宽"), s = d + l.marginLeftMm + l.marginRightMm, W(s, "宽表总宽度"));
1132
+ const F = { widthMm: s, heightMm: r, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
1133
+ return c && F.components.push({
1092
1134
  kind: "text",
1093
1135
  text: e.title,
1094
- leftMm: s.marginLeftMm,
1095
- topMm: s.marginTopMm,
1096
- widthMm: o,
1097
- heightMm: c,
1136
+ leftMm: l.marginLeftMm,
1137
+ topMm: l.marginTopMm,
1138
+ widthMm: d,
1139
+ heightMm: f,
1098
1140
  style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
1099
- }), E.components.push({
1141
+ }), F.components.push({
1100
1142
  align: "auto",
1101
1143
  headerAlign: "center",
1102
- ...b,
1144
+ ...y,
1103
1145
  kind: "list",
1104
- dataset: l,
1105
- columns: g,
1106
- leftMm: s.marginLeftMm,
1107
- topMm: s.marginTopMm + m,
1108
- widthMm: u > 0 ? o : d
1109
- }), e.params === void 0 ? { pages: [E] } : { params: e.params, pages: [E] };
1110
- }
1111
- const Ke = "1.0";
1112
- class K extends Error {
1146
+ ...t === "wide" ? { layout: t } : {},
1147
+ ...c ? { title: e.title } : {},
1148
+ dataset: h,
1149
+ columns: R,
1150
+ leftMm: l.marginLeftMm,
1151
+ topMm: l.marginTopMm + b,
1152
+ widthMm: t === "wide" || $ > 0 ? d : T
1153
+ }), e.params === void 0 ? { pages: [F] } : { params: e.params, pages: [F] };
1154
+ }
1155
+ const Ze = "1.0";
1156
+ class X extends Error {
1113
1157
  constructor(t) {
1114
1158
  super(`模板校验失败:${t.slice(0, 3).map((n) => `${n.path}: ${n.message}`).join("; ")}`), this.errors = t, this.name = "ReportTemplateError";
1115
1159
  }
1116
1160
  }
1117
- const xt = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Nt = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), Ct = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), Me = 2e5, Rt = 64, Ee = 1e7;
1118
- function N(e) {
1161
+ const Ht = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Bt = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), Ot = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), we = 2e5, Ft = 64, xe = 1e7;
1162
+ function H(e) {
1119
1163
  return !!e && typeof e == "object" && !Array.isArray(e);
1120
1164
  }
1121
- function Pe(e, t) {
1165
+ function Ne(e, t) {
1122
1166
  const n = /* @__PURE__ */ new Set();
1123
- let r = 0, i = 0, s = !1;
1124
- const o = (a, l, c) => {
1167
+ let i = 0, o = 0, s = !1;
1168
+ const r = (a, l, d) => {
1125
1169
  if (s) return;
1126
- if (++r > Me) {
1127
- r === Me + 1 && t.push({ path: l, message: "模板超过 JSON 节点安全上限" });
1170
+ if (++i > we) {
1171
+ i === we + 1 && t.push({ path: l, message: "模板超过 JSON 节点安全上限" });
1128
1172
  return;
1129
1173
  }
1130
- if (c > Rt) {
1174
+ if (d > Ft) {
1131
1175
  t.push({ path: l, message: "模板嵌套层级过深" });
1132
1176
  return;
1133
1177
  }
1134
1178
  if (typeof a == "string") {
1135
- i += a.length, i > Ee && (s = !0, t.push({ path: l, message: "模板文本超过 1000 万字符的安全上限" }));
1179
+ o += a.length, o > xe && (s = !0, t.push({ path: l, message: "模板文本超过 1000 万字符的安全上限" }));
1136
1180
  return;
1137
1181
  }
1138
1182
  if (a === null || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) return;
@@ -1144,8 +1188,8 @@ function Pe(e, t) {
1144
1188
  t.push({ path: l, message: "模板不能包含循环引用" });
1145
1189
  return;
1146
1190
  }
1147
- const f = Object.getPrototypeOf(a);
1148
- if (Array.isArray(a) && f !== Array.prototype || !Array.isArray(a) && f !== Object.prototype && f !== null) {
1191
+ const m = Object.getPrototypeOf(a);
1192
+ if (Array.isArray(a) && m !== Array.prototype || !Array.isArray(a) && m !== Object.prototype && m !== null) {
1149
1193
  t.push({ path: l, message: "模板对象必须使用普通 JSON 对象原型" });
1150
1194
  return;
1151
1195
  }
@@ -1158,391 +1202,401 @@ function Pe(e, t) {
1158
1202
  return;
1159
1203
  }
1160
1204
  n.add(a);
1161
- for (const [h, m] of Object.entries(Object.getOwnPropertyDescriptors(a)))
1162
- if (!(Array.isArray(a) && h === "length") && (xt.has(h) ? t.push({ path: `${l}.${h}`, message: "模板不能包含可能污染原型的键" }) : m.get || m.set || !m.enumerable ? t.push({ path: `${l}.${h}`, message: "模板不能包含访问器或不可枚举字段" }) : o(m.value, `${l}.${h}`, c + 1), r > Me || s))
1205
+ for (const [h, f] of Object.entries(Object.getOwnPropertyDescriptors(a)))
1206
+ if (!(Array.isArray(a) && h === "length") && (Ht.has(h) ? t.push({ path: `${l}.${h}`, message: "模板不能包含可能污染原型的键" }) : f.get || f.set || !f.enumerable ? t.push({ path: `${l}.${h}`, message: "模板不能包含访问器或不可枚举字段" }) : r(f.value, `${l}.${h}`, d + 1), i > we || s))
1163
1207
  break;
1164
1208
  n.delete(a);
1165
1209
  };
1166
- o(e, "$", 0);
1210
+ r(e, "$", 0);
1167
1211
  }
1168
- function B(e, t, n, r, i = !1) {
1212
+ function O(e, t, n, i, o = !1) {
1169
1213
  const s = e[t];
1170
- s === void 0 && !i || (typeof s != "string" || i && !s.trim()) && r.push({ path: `${n}.${t}`, message: i ? "应为非空字符串" : "应为字符串" });
1214
+ s === void 0 && !o || (typeof s != "string" || o && !s.trim()) && i.push({ path: `${n}.${t}`, message: o ? "应为非空字符串" : "应为字符串" });
1171
1215
  }
1172
- function _(e, t, n, r, i = 0, s = !1) {
1173
- const o = e[t];
1174
- o === void 0 && !s || (typeof o != "number" || !Number.isFinite(o) || o < i) && r.push({ path: `${n}.${t}`, message: `应为大于等于 ${i} 的有限数字` });
1216
+ function _(e, t, n, i, o = 0, s = !1) {
1217
+ const r = e[t];
1218
+ r === void 0 && !s || (typeof r != "number" || !Number.isFinite(r) || r < o) && i.push({ path: `${n}.${t}`, message: `应为大于等于 ${o} 的有限数字` });
1175
1219
  }
1176
- function ie(e, t, n, r) {
1177
- e[t] !== void 0 && typeof e[t] != "boolean" && r.push({ path: `${n}.${t}`, message: "应为布尔值" });
1220
+ function ae(e, t, n, i) {
1221
+ e[t] !== void 0 && typeof e[t] != "boolean" && i.push({ path: `${n}.${t}`, message: "应为布尔值" });
1178
1222
  }
1179
- function Q(e, t, n, r = !1) {
1180
- e !== void 0 && !Ct.has(e) && !(r && e === "auto") && n.push({ path: t, message: `未知对齐方式${r ? "(支持 auto)" : ""}` });
1223
+ function ee(e, t, n, i = !1) {
1224
+ e !== void 0 && !Ot.has(e) && !(i && e === "auto") && n.push({ path: t, message: `未知对齐方式${i ? "(支持 auto)" : ""}` });
1181
1225
  }
1182
- function J(e, t, n) {
1226
+ function Y(e, t, n) {
1183
1227
  if (e !== void 0) {
1184
- if (!N(e)) {
1228
+ if (!H(e)) {
1185
1229
  n.push({ path: t, message: "样式应为对象" });
1186
1230
  return;
1187
1231
  }
1188
- Q(e.align, `${t}.align`, n), e.verticalAlign !== void 0 && !["top", "middle", "bottom"].includes(e.verticalAlign) && n.push({ path: `${t}.verticalAlign`, message: "未知垂直对齐方式" });
1189
- for (const r of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) _(e, r, t, n);
1190
- for (const r of ["letterSpacing", "rotateDeg"]) _(e, r, t, n, -1 / 0);
1232
+ ee(e.align, `${t}.align`, n), e.verticalAlign !== void 0 && !["top", "middle", "bottom"].includes(e.verticalAlign) && n.push({ path: `${t}.verticalAlign`, message: "未知垂直对齐方式" });
1233
+ for (const i of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) _(e, i, t, n);
1234
+ for (const i of ["letterSpacing", "rotateDeg"]) _(e, i, t, n, -1 / 0);
1191
1235
  _(e, "opacity", t, n), typeof e.opacity == "number" && e.opacity > 1 && n.push({ path: `${t}.opacity`, message: "透明度不能大于 1" });
1192
- for (const r of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) ie(e, r, t, n);
1193
- for (const r of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) B(e, r, t, n);
1236
+ for (const i of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) ae(e, i, t, n);
1237
+ for (const i of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) O(e, i, t, n);
1194
1238
  }
1195
1239
  }
1196
- function Ht(e, t, n) {
1240
+ function Lt(e, t, n) {
1197
1241
  if (e === void 0) return;
1198
1242
  if (!Array.isArray(e)) {
1199
1243
  n.push({ path: t, message: "参数定义应为数组" });
1200
1244
  return;
1201
1245
  }
1202
- const r = /* @__PURE__ */ new Set();
1203
- e.forEach((i, s) => {
1204
- const o = `${t}.${s}`;
1205
- if (!N(i)) {
1206
- n.push({ path: o, message: "参数定义应为对象" });
1246
+ const i = /* @__PURE__ */ new Set();
1247
+ e.forEach((o, s) => {
1248
+ const r = `${t}.${s}`;
1249
+ if (!H(o)) {
1250
+ n.push({ path: r, message: "参数定义应为对象" });
1207
1251
  return;
1208
1252
  }
1209
- B(i, "field", o, n, !0), typeof i.field == "string" && (r.has(i.field) && n.push({ path: `${o}.field`, message: "参数名重复" }), r.add(i.field)), i.type !== void 0 && !["text", "number", "date", "select"].includes(i.type) && n.push({ path: `${o}.type`, message: "未知参数类型" });
1210
- for (const a of ["label", "defaultValue", "placeholder"]) B(i, a, o, n);
1211
- ie(i, "required", o, n), i.options !== void 0 && (Array.isArray(i.options) ? i.options.forEach((a, l) => {
1212
- const c = `${o}.options.${l}`;
1213
- if (!N(a)) n.push({ path: c, message: "选项应为对象" });
1253
+ O(o, "field", r, n, !0), typeof o.field == "string" && (i.has(o.field) && n.push({ path: `${r}.field`, message: "参数名重复" }), i.add(o.field)), o.type !== void 0 && !["text", "number", "date", "select"].includes(o.type) && n.push({ path: `${r}.type`, message: "未知参数类型" });
1254
+ for (const a of ["label", "defaultValue", "placeholder"]) O(o, a, r, n);
1255
+ ae(o, "required", r, n), o.options !== void 0 && (Array.isArray(o.options) ? o.options.forEach((a, l) => {
1256
+ const d = `${r}.options.${l}`;
1257
+ if (!H(a)) n.push({ path: d, message: "选项应为对象" });
1214
1258
  else
1215
- for (const f of ["label", "value"]) typeof a[f] != "string" && n.push({ path: `${c}.${f}`, message: "选项标签与值应为字符串(允许空白选项)" });
1216
- }) : n.push({ path: `${o}.options`, message: "选项应为数组" }));
1259
+ for (const m of ["label", "value"]) typeof a[m] != "string" && n.push({ path: `${d}.${m}`, message: "选项标签与值应为字符串(允许空白选项)" });
1260
+ }) : n.push({ path: `${r}.options`, message: "选项应为数组" }));
1217
1261
  });
1218
1262
  }
1219
- function Ot(e, t, n) {
1220
- for (const r of ["leftMm", "topMm"]) _(e, r, t, n, -1 / 0, !0);
1221
- _(e, "widthMm", t, n, Number.MIN_VALUE, !0), B(e, "dataset", t, n, !0), !Array.isArray(e.columns) || e.columns.length === 0 ? n.push({ path: `${t}.columns`, message: "列表至少需要一列" }) : e.columns.forEach((r, i) => {
1222
- const s = `${t}.columns.${i}`;
1223
- if (!N(r)) {
1263
+ function It(e, t, n) {
1264
+ for (const i of ["leftMm", "topMm"]) _(e, i, t, n, -1 / 0, !0);
1265
+ _(e, "widthMm", t, n, Number.MIN_VALUE, !0), O(e, "dataset", t, n, !0), O(e, "title", t, n), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" }), !Array.isArray(e.columns) || e.columns.length === 0 ? n.push({ path: `${t}.columns`, message: "列表至少需要一列" }) : e.columns.forEach((i, o) => {
1266
+ const s = `${t}.columns.${o}`;
1267
+ if (!H(i)) {
1224
1268
  n.push({ path: s, message: "列应为对象" });
1225
1269
  return;
1226
1270
  }
1227
- if (typeof r.header != "string" && n.push({ path: `${s}.header`, message: "表头应为字符串(允许空白表头)" }), B(r, "field", s, n, !0), _(r, "widthMm", s, n, Number.MIN_VALUE, !0), J(r.style, `${s}.style`, n), J(r.headerStyle, `${s}.headerStyle`, n), Q(r.align, `${s}.align`, n, !0), Q(r.headerAlign, `${s}.headerAlign`, n), r.format !== void 0)
1228
- if (!N(r.format) || !["number", "percent", "date"].includes(r.format.kind))
1271
+ if (typeof i.header != "string" && n.push({ path: `${s}.header`, message: "表头应为字符串(允许空白表头)" }), O(i, "field", s, n, !0), _(i, "widthMm", s, n, Number.MIN_VALUE, !0), Y(i.style, `${s}.style`, n), Y(i.headerStyle, `${s}.headerStyle`, n), ee(i.align, `${s}.align`, n, !0), ee(i.headerAlign, `${s}.headerAlign`, n), i.format !== void 0)
1272
+ if (!H(i.format) || !["number", "percent", "date"].includes(i.format.kind))
1229
1273
  n.push({ path: `${s}.format`, message: "未知列格式" });
1230
1274
  else {
1231
- const o = r.format.digits;
1232
- o !== void 0 && (typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 100) && n.push({ path: `${s}.format.digits`, message: "小数位应为 0–100 的整数" }), ie(r.format, "thousands", `${s}.format`, n), B(r.format, "pattern", `${s}.format`, n);
1275
+ const r = i.format.digits;
1276
+ r !== void 0 && (typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 100) && n.push({ path: `${s}.format.digits`, message: "小数位应为 0–100 的整数" }), ae(i.format, "thousands", `${s}.format`, n), O(i.format, "pattern", `${s}.format`, n);
1233
1277
  }
1234
- r.rules !== void 0 && (Array.isArray(r.rules) ? r.rules.forEach((o, a) => {
1278
+ i.rules !== void 0 && (Array.isArray(i.rules) ? i.rules.forEach((r, a) => {
1235
1279
  const l = `${s}.rules.${a}`;
1236
- if (!N(o) || !N(o.when)) {
1280
+ if (!H(r) || !H(r.when)) {
1237
1281
  n.push({ path: l, message: "条件格式缺少 when 对象" });
1238
1282
  return;
1239
1283
  }
1240
- B(o.when, "field", `${l}.when`, n, !0), [">", ">=", "<", "<=", "==", "!="].includes(o.when.op) || n.push({ path: `${l}.when.op`, message: "未知条件运算符" }), typeof o.when.value != "number" && typeof o.when.value != "string" && n.push({ path: `${l}.when.value`, message: "条件值应为数字或字符串" }), J(o.style, `${l}.style`, n);
1284
+ O(r.when, "field", `${l}.when`, n, !0), [">", ">=", "<", "<=", "==", "!="].includes(r.when.op) || n.push({ path: `${l}.when.op`, message: "未知条件运算符" }), typeof r.when.value != "number" && typeof r.when.value != "string" && n.push({ path: `${l}.when.value`, message: "条件值应为数字或字符串" }), Y(r.style, `${l}.style`, n);
1241
1285
  }) : n.push({ path: `${s}.rules`, message: "条件格式应为数组" }));
1242
1286
  });
1243
- for (const r of ["fontSizePt", "rowHeightMm"]) _(e, r, t, n, Number.MIN_VALUE);
1287
+ for (const i of ["fontSizePt", "rowHeightMm"]) _(e, i, t, n, Number.MIN_VALUE);
1244
1288
  _(e, "paddingMm", t, n);
1245
- for (const r of ["headerBold", "headerEveryPage", "border"]) ie(e, r, t, n);
1246
- if (B(e, "headerBackgroundColor", t, n), Q(e.align, `${t}.align`, n, !0), Q(e.headerAlign, `${t}.headerAlign`, n), J(e.headerStyle, `${t}.headerStyle`, n), e.groupBy !== void 0)
1247
- if (!N(e.groupBy)) n.push({ path: `${t}.groupBy`, message: "分组应为对象" });
1289
+ for (const i of ["headerBold", "headerEveryPage", "border"]) ae(e, i, t, n);
1290
+ if (O(e, "headerBackgroundColor", t, n), ee(e.align, `${t}.align`, n, !0), ee(e.headerAlign, `${t}.headerAlign`, n), Y(e.headerStyle, `${t}.headerStyle`, n), e.groupBy !== void 0)
1291
+ if (!H(e.groupBy)) n.push({ path: `${t}.groupBy`, message: "分组应为对象" });
1248
1292
  else {
1249
- B(e.groupBy, "field", `${t}.groupBy`, n, !0);
1250
- for (const r of ["headerTemplate", "subtotalLabel"]) B(e.groupBy, r, `${t}.groupBy`, n);
1251
- for (const r of ["headerStyle", "subtotalStyle"]) J(e.groupBy[r], `${t}.groupBy.${r}`, n);
1252
- ie(e.groupBy, "keepWithNext", `${t}.groupBy`, n), e.groupBy.subtotal !== void 0 && (!Array.isArray(e.groupBy.subtotal) || e.groupBy.subtotal.some((r) => typeof r != "string")) && n.push({ path: `${t}.groupBy.subtotal`, message: "小计字段应为字符串数组" });
1293
+ O(e.groupBy, "field", `${t}.groupBy`, n, !0);
1294
+ for (const i of ["headerTemplate", "subtotalLabel"]) O(e.groupBy, i, `${t}.groupBy`, n);
1295
+ for (const i of ["headerStyle", "subtotalStyle"]) Y(e.groupBy[i], `${t}.groupBy.${i}`, n);
1296
+ ae(e.groupBy, "keepWithNext", `${t}.groupBy`, n), e.groupBy.subtotal !== void 0 && (!Array.isArray(e.groupBy.subtotal) || e.groupBy.subtotal.some((i) => typeof i != "string")) && n.push({ path: `${t}.groupBy.subtotal`, message: "小计字段应为字符串数组" });
1253
1297
  }
1254
- e.grandTotal !== void 0 && typeof e.grandTotal != "boolean" && (N(e.grandTotal) ? (B(e.grandTotal, "label", `${t}.grandTotal`, n), J(e.grandTotal.style, `${t}.grandTotal.style`, n), e.grandTotal.fields !== void 0 && (!Array.isArray(e.grandTotal.fields) || e.grandTotal.fields.some((r) => typeof r != "string")) && n.push({ path: `${t}.grandTotal.fields`, message: "合计字段应为字符串数组" })) : n.push({ path: `${t}.grandTotal`, message: "合计应为布尔值或对象" }));
1255
- }
1256
- function Xe(e, t, n) {
1257
- J(e.style, `${t}.style`, n);
1258
- for (const i of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) B(e, i, t, n);
1259
- if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((i) => typeof i != "string")) && n.push({ path: `${t}.lines`, message: "文本行应为字符串数组" }), Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((i, s) => {
1260
- if (!N(i)) return;
1261
- const o = `${t}.richParagraphs.${s}`;
1262
- Q(i.align, `${o}.align`, n);
1263
- for (const a of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) _(i, a, o, n);
1264
- Array.isArray(i.segments) && i.segments.forEach((a, l) => {
1265
- const c = `${o}.segments.${l}`;
1266
- if (!N(a)) {
1267
- n.push({ path: c, message: "富文本片段应为对象" });
1298
+ e.grandTotal !== void 0 && typeof e.grandTotal != "boolean" && (H(e.grandTotal) ? (O(e.grandTotal, "label", `${t}.grandTotal`, n), Y(e.grandTotal.style, `${t}.grandTotal.style`, n), e.grandTotal.fields !== void 0 && (!Array.isArray(e.grandTotal.fields) || e.grandTotal.fields.some((i) => typeof i != "string")) && n.push({ path: `${t}.grandTotal.fields`, message: "合计字段应为字符串数组" })) : n.push({ path: `${t}.grandTotal`, message: "合计应为布尔值或对象" }));
1299
+ }
1300
+ function et(e, t, n) {
1301
+ Y(e.style, `${t}.style`, n);
1302
+ for (const o of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) O(e, o, t, n);
1303
+ if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((o) => typeof o != "string")) && n.push({ path: `${t}.lines`, message: "文本行应为字符串数组" }), Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((o, s) => {
1304
+ if (!H(o)) return;
1305
+ const r = `${t}.richParagraphs.${s}`;
1306
+ ee(o.align, `${r}.align`, n);
1307
+ for (const a of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) _(o, a, r, n);
1308
+ Array.isArray(o.segments) && o.segments.forEach((a, l) => {
1309
+ const d = `${r}.segments.${l}`;
1310
+ if (!H(a)) {
1311
+ n.push({ path: d, message: "富文本片段应为对象" });
1268
1312
  return;
1269
1313
  }
1270
- a.kind !== void 0 && a.kind !== "text" && a.kind !== "field" && n.push({ path: `${c}.kind`, message: "未知富文本片段类型" });
1271
- for (const f of ["text", "field"]) B(a, f, c, n);
1272
- J(a.style, `${c}.style`, n);
1314
+ a.kind !== void 0 && a.kind !== "text" && a.kind !== "field" && n.push({ path: `${d}.kind`, message: "未知富文本片段类型" });
1315
+ for (const m of ["text", "field"]) O(a, m, d, n);
1316
+ Y(a.style, `${d}.style`, n);
1273
1317
  });
1274
- }), !N(e.grid)) return;
1275
- const r = e.grid;
1276
- _(r, "gapMm", `${t}.grid`, n);
1277
- for (const i of ["colWidthsMm", "rowHeightsMm"]) {
1278
- const s = r[i];
1279
- s !== void 0 && (!Array.isArray(s) || s.some((o) => typeof o != "number" || !Number.isFinite(o) || o < 0)) && n.push({ path: `${t}.grid.${i}`, message: "网格尺寸应为有限非负数字数组" });
1318
+ }), !H(e.grid)) return;
1319
+ const i = e.grid;
1320
+ _(i, "gapMm", `${t}.grid`, n);
1321
+ for (const o of ["colWidthsMm", "rowHeightsMm"]) {
1322
+ const s = i[o];
1323
+ s !== void 0 && (!Array.isArray(s) || s.some((r) => typeof r != "number" || !Number.isFinite(r) || r < 0)) && n.push({ path: `${t}.grid.${o}`, message: "网格尺寸应为有限非负数字数组" });
1280
1324
  }
1281
- Array.isArray(r.cells) && r.cells.forEach((i, s) => {
1282
- Array.isArray(i) && i.forEach((o, a) => {
1325
+ Array.isArray(i.cells) && i.cells.forEach((o, s) => {
1326
+ Array.isArray(o) && o.forEach((r, a) => {
1283
1327
  const l = `${t}.grid.cells.${s}.${a}`;
1284
- if (o !== null) {
1285
- if (!N(o)) {
1328
+ if (r !== null) {
1329
+ if (!H(r)) {
1286
1330
  n.push({ path: l, message: "网格单元格应为对象或 null" });
1287
1331
  return;
1288
1332
  }
1289
- for (const c of ["text", "rawText", "numberFormat"]) B(o, c, l, n);
1290
- for (const c of ["colSpan", "rowSpan"]) {
1291
- const f = o[c];
1292
- f !== void 0 && (typeof f != "number" || !Number.isInteger(f) || f <= 0) && n.push({ path: `${l}.${c}`, message: "跨度应为正整数" });
1333
+ for (const d of ["text", "rawText", "numberFormat"]) O(r, d, l, n);
1334
+ for (const d of ["colSpan", "rowSpan"]) {
1335
+ const m = r[d];
1336
+ m !== void 0 && (typeof m != "number" || !Number.isInteger(m) || m <= 0) && n.push({ path: `${l}.${d}`, message: "跨度应为正整数" });
1293
1337
  }
1294
- o.value !== void 0 && o.value !== null && !["string", "number", "boolean"].includes(typeof o.value) && n.push({ path: `${l}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), J(o.style, `${l}.style`, n), o.children !== void 0 && (Array.isArray(o.children) ? o.children.forEach((c, f) => {
1295
- N(c) && Xe(c, `${l}.children.${f}`, n);
1338
+ r.value !== void 0 && r.value !== null && !["string", "number", "boolean"].includes(typeof r.value) && n.push({ path: `${l}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), Y(r.style, `${l}.style`, n), r.children !== void 0 && (Array.isArray(r.children) ? r.children.forEach((d, m) => {
1339
+ H(d) && et(d, `${l}.children.${m}`, n);
1296
1340
  }) : n.push({ path: `${l}.children`, message: "嵌套组件应为数组" }));
1297
1341
  }
1298
1342
  });
1299
1343
  });
1300
1344
  }
1301
- function Qe(e) {
1345
+ function tt(e) {
1302
1346
  const t = [], n = [];
1303
- return Pe(e, t), t.length ? { ok: !1, errors: t, warnings: n } : (N(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== ve && t.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), Ht(e.params, "$.params", t), !Array.isArray(e.pages) || e.pages.length === 0 ? t.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((r, i) => {
1304
- const s = `$.pages.${i}`;
1305
- if (!N(r)) {
1347
+ return Ne(e, t), t.length ? { ok: !1, errors: t, warnings: n } : (H(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== Ae && t.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), Lt(e.params, "$.params", t), !Array.isArray(e.pages) || e.pages.length === 0 ? t.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((i, o) => {
1348
+ const s = `$.pages.${o}`;
1349
+ if (!H(i)) {
1306
1350
  t.push({ path: s, message: "页应为对象" });
1307
1351
  return;
1308
1352
  }
1309
- _(r, "widthMm", s, t, Number.MIN_VALUE, !0), _(r, "heightMm", s, t, Number.MIN_VALUE, !0), typeof r.widthMm == "number" && r.widthMm >= 3e3 && t.push({ path: `${s}.widthMm`, message: "页宽应小于 3000mm" }), typeof r.heightMm == "number" && r.heightMm >= 5e3 && t.push({ path: `${s}.heightMm`, message: "页高应小于 5000mm" });
1310
- for (const o of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) _(r, o, s, t);
1311
- typeof r.widthMm == "number" && Number(r.marginLeftMm ?? 0) + Number(r.marginRightMm ?? 0) >= r.widthMm && t.push({ path: s, message: "横向页边距占满页面" }), typeof r.heightMm == "number" && Number(r.marginTopMm ?? 0) + Number(r.marginBottomMm ?? 0) >= r.heightMm && t.push({ path: s, message: "纵向页边距占满页面" }), Array.isArray(r.components) ? r.components.forEach((o, a) => {
1353
+ _(i, "widthMm", s, t, Number.MIN_VALUE, !0), _(i, "heightMm", s, t, Number.MIN_VALUE, !0), i.layout !== void 0 && i.layout !== "page" && i.layout !== "wide" && t.push({ path: `${s}.layout`, message: "布局应为 page 或 wide" }), typeof i.heightMm == "number" && i.heightMm >= 5e3 && t.push({ path: `${s}.heightMm`, message: "页高应小于 5000mm" });
1354
+ for (const r of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) _(i, r, s, t);
1355
+ typeof i.widthMm == "number" && Number(i.marginLeftMm ?? 0) + Number(i.marginRightMm ?? 0) >= i.widthMm && t.push({ path: s, message: "横向页边距占满页面" }), typeof i.heightMm == "number" && Number(i.marginTopMm ?? 0) + Number(i.marginBottomMm ?? 0) >= i.heightMm && t.push({ path: s, message: "纵向页边距占满页面" }), Array.isArray(i.components) ? i.components.forEach((r, a) => {
1312
1356
  const l = `${s}.components.${a}`;
1313
- N(o) && o.kind === "list" ? Ot(o, l, t) : (Te(o, l, t, n), N(o) && Xe(o, l, t));
1357
+ H(r) && r.kind === "list" ? It(r, l, t) : (Ee(r, l, t, n), H(r) && et(r, l, t));
1314
1358
  }) : t.push({ path: `${s}.components`, message: "组件应为数组" });
1315
1359
  })) : t.push({ path: "$", message: "模板应为对象" }), { ok: t.length === 0, errors: t, warnings: n });
1316
1360
  }
1317
- function Bt(e) {
1361
+ function jt(e) {
1318
1362
  const t = [], n = [];
1319
- if (Pe(e, t), t.length) return { ok: !1, errors: t, warnings: n };
1320
- if (!N(e)) t.push({ path: "$", message: "模板文档应为对象" });
1363
+ if (Ne(e, t), t.length) return { ok: !1, errors: t, warnings: n };
1364
+ if (!H(e)) t.push({ path: "$", message: "模板文档应为对象" });
1321
1365
  else {
1322
- for (const i of Object.keys(e))
1323
- Nt.has(i) || t.push({ path: `$.${i}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
1324
- e.schemaVersion !== Ke && t.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
1325
- for (const i of ["id", "name"]) B(e, i, "$", t, !0);
1326
- for (const i of ["revision", "description"]) B(e, i, "$", t);
1327
- const r = Qe(e.template);
1328
- t.push(...r.errors.map((i) => ({ ...i, path: `$.template${i.path.slice(1)}` }))), n.push(...r.warnings.map((i) => ({ ...i, path: `$.template${i.path.slice(1)}` })));
1366
+ for (const o of Object.keys(e))
1367
+ Bt.has(o) || t.push({ path: `$.${o}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
1368
+ e.schemaVersion !== Ze && t.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
1369
+ for (const o of ["id", "name"]) O(e, o, "$", t, !0);
1370
+ for (const o of ["revision", "description"]) O(e, o, "$", t);
1371
+ const i = tt(e.template);
1372
+ t.push(...i.errors.map((o) => ({ ...o, path: `$.template${o.path.slice(1)}` }))), n.push(...i.warnings.map((o) => ({ ...o, path: `$.template${o.path.slice(1)}` })));
1329
1373
  }
1330
1374
  return { ok: t.length === 0, errors: t, warnings: n };
1331
1375
  }
1332
- function ye(e) {
1333
- const t = Bt(e);
1334
- if (!t.ok) throw new K(t.errors);
1376
+ function Me(e) {
1377
+ const t = jt(e);
1378
+ if (!t.ok) throw new X(t.errors);
1335
1379
  }
1336
- function Ut(e) {
1380
+ function Qt(e) {
1337
1381
  const t = [];
1338
- if (Pe(e, t), t.length) throw new K(t);
1339
- const n = { ...e, schemaVersion: e.schemaVersion ?? Ke };
1340
- return ye(n), ge(n);
1382
+ if (Ne(e, t), t.length) throw new X(t);
1383
+ const n = { ...e, schemaVersion: e.schemaVersion ?? Ze };
1384
+ return Me(n), ue(n);
1341
1385
  }
1342
- function qt(e) {
1386
+ function Zt(e) {
1343
1387
  let t = e;
1344
1388
  if (typeof e == "string") {
1345
- if (e.length > Ee)
1346
- throw new K([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1389
+ if (e.length > xe)
1390
+ throw new X([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1347
1391
  try {
1348
1392
  t = JSON.parse(e);
1349
1393
  } catch {
1350
- throw new K([{ path: "$", message: "模板 JSON 语法无效" }]);
1394
+ throw new X([{ path: "$", message: "模板 JSON 语法无效" }]);
1351
1395
  }
1352
1396
  }
1353
- return ye(t), ge(t);
1397
+ return Me(t), ue(t);
1354
1398
  }
1355
- function Kt(e) {
1356
- ye(e);
1399
+ function en(e) {
1400
+ Me(e);
1357
1401
  const t = JSON.stringify(e, null, 2);
1358
- if (t.length > Ee) throw new K([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1402
+ if (t.length > xe) throw new X([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
1359
1403
  return t;
1360
1404
  }
1361
- function ge(e) {
1405
+ function ue(e) {
1362
1406
  return JSON.parse(JSON.stringify(e));
1363
1407
  }
1364
- function Xt(e = []) {
1408
+ function tn(e = []) {
1365
1409
  const t = /* @__PURE__ */ new Map(), n = {
1366
- get: (r) => {
1367
- const i = t.get(r);
1368
- return i ? ge(i) : void 0;
1410
+ get: (i) => {
1411
+ const o = t.get(i);
1412
+ return o ? ue(o) : void 0;
1369
1413
  },
1370
- list: () => Array.from(t.values(), ({ template: r, ...i }) => ({ ...i })),
1371
- register: (r, i = {}) => {
1372
- if (ye(r), t.has(r.id) && !i.replace) throw new K([{ path: "$.id", message: `模板 ID ${r.id} 已注册;更新需显式 replace:true` }]);
1373
- t.set(r.id, ge(r));
1414
+ list: () => Array.from(t.values(), ({ template: i, ...o }) => ({ ...o })),
1415
+ register: (i, o = {}) => {
1416
+ if (Me(i), t.has(i.id) && !o.replace) throw new X([{ path: "$.id", message: `模板 ID ${i.id} 已注册;更新需显式 replace:true` }]);
1417
+ t.set(i.id, ue(i));
1374
1418
  },
1375
- remove: (r) => t.delete(r)
1419
+ remove: (i) => t.delete(i)
1376
1420
  };
1377
- for (const r of e) n.register(r);
1421
+ for (const i of e) n.register(i);
1378
1422
  return n;
1379
1423
  }
1380
- function Qt(e) {
1424
+ function nn(e) {
1381
1425
  if (!("mapData" in e)) return e;
1382
- const { load: t, mapData: n, ...r } = e;
1383
- return { ...r, load: async (i) => {
1384
- const s = await t(i);
1385
- Y(i.signal);
1426
+ const { load: t, mapData: n, ...i } = e;
1427
+ return { ...i, load: async (o) => {
1428
+ const s = await t(o);
1429
+ U(o.signal);
1386
1430
  try {
1387
- return n(s, i);
1388
- } catch (o) {
1389
- throw new j("validate", `报表 ${i.reportId} 数据映射失败`, o);
1431
+ return n(s, o);
1432
+ } catch (r) {
1433
+ throw new D("validate", `报表 ${o.reportId} 数据映射失败`, r);
1390
1434
  }
1391
1435
  } };
1392
1436
  }
1393
- class j extends Error {
1394
- constructor(t, n, r) {
1395
- super(n), this.name = "ReportSourceError", this.code = t, this.cause = r;
1437
+ class D extends Error {
1438
+ constructor(t, n, i) {
1439
+ super(n), this.name = "ReportSourceError", this.code = t, this.cause = i;
1396
1440
  }
1397
1441
  }
1398
- function ue(e) {
1442
+ function pe(e) {
1399
1443
  const t = new Error("报表加载已取消");
1400
1444
  return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
1401
1445
  }
1402
- function Y(e) {
1403
- if (e?.aborted) throw ue(e);
1446
+ function U(e) {
1447
+ if (e?.aborted) throw pe(e);
1404
1448
  }
1405
- function Be(e, t) {
1406
- return t ? new Promise((n, r) => {
1407
- const i = () => t.removeEventListener("abort", s), s = () => {
1408
- i(), r(ue(t));
1449
+ function Le(e, t) {
1450
+ return t ? new Promise((n, i) => {
1451
+ const o = () => t.removeEventListener("abort", s), s = () => {
1452
+ o(), i(pe(t));
1409
1453
  };
1410
1454
  t.addEventListener("abort", s, { once: !0 }), t.aborted && s(), Promise.resolve(e).then(
1411
- (o) => {
1412
- i(), n(o);
1455
+ (r) => {
1456
+ o(), n(r);
1413
1457
  },
1414
- (o) => {
1415
- i(), r(o);
1458
+ (r) => {
1459
+ o(), i(r);
1416
1460
  }
1417
1461
  );
1418
1462
  }) : Promise.resolve(e);
1419
1463
  }
1420
- function Ft(e, t) {
1464
+ function Dt(e, t) {
1421
1465
  if (!e || typeof e != "object" || Array.isArray(e))
1422
- throw new j("validate", `报表 ${t} 的数据集应为对象`);
1423
- for (const [n, r] of Object.entries(e))
1424
- if (!Array.isArray(r) || r.some((i) => !i || typeof i != "object" || Array.isArray(i)))
1425
- throw new j("validate", `报表 ${t} 的数据集 ${n} 应为对象数组`);
1426
- }
1427
- function Zt(e, t = {}) {
1428
- function n(i) {
1429
- const s = Object.prototype.hasOwnProperty.call(e, i) ? e[i] : void 0;
1430
- if (!s) throw new j("config", `未注册报表 ${i}`);
1466
+ throw new D("validate", `报表 ${t} 的数据集应为对象`);
1467
+ for (const [n, i] of Object.entries(e))
1468
+ if (!Array.isArray(i) || i.some((o) => !o || typeof o != "object" || Array.isArray(o)))
1469
+ throw new D("validate", `报表 ${t} 的数据集 ${n} 应为对象数组`);
1470
+ }
1471
+ function on(e, t = {}) {
1472
+ function n(o) {
1473
+ const s = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
1474
+ if (!s) throw new D("config", `未注册报表 ${o}`);
1431
1475
  return s;
1432
1476
  }
1433
- return Object.assign(async ({ reportIds: i, params: s, signal: o, onWarning: a }) => {
1434
- Y(o);
1435
- const l = [...i], c = { ...s };
1436
- if (l.length === 0) throw new j("config", "缺少报表 ID");
1437
- const f = l.map(n), h = [], m = [];
1438
- for (const [w, S] of f.entries()) {
1439
- Y(o);
1440
- const g = l[w], E = { reportId: g, params: { ...c }, signal: o };
1441
- let A;
1442
- if (typeof S.template == "function")
1477
+ return Object.assign(async ({ reportIds: o, params: s, signal: r, onWarning: a }) => {
1478
+ U(r);
1479
+ const l = [...o], d = { ...s };
1480
+ if (l.length === 0) throw new D("config", "缺少报表 ID");
1481
+ const m = l.map(n), h = [], f = [];
1482
+ for (const [y, T] of m.entries()) {
1483
+ U(r);
1484
+ const $ = l[y], E = { reportId: $, params: { ...d }, signal: r };
1485
+ let S;
1486
+ if (typeof T.template == "function")
1443
1487
  try {
1444
- A = await Be(S.template(E), o), Y(o);
1445
- const p = Qe(A);
1446
- if (!p.ok)
1447
- throw new j("validate", `报表 ${g} 模板校验失败:${p.errors.slice(0, 3).map((k) => `${k.path}: ${k.message}`).join("; ")}`);
1448
- m.push(...p.warnings.map((k) => `${g}: ${k.path}: ${k.message}`));
1449
- } catch (p) {
1450
- throw o?.aborted ? ue(o) : p instanceof j ? p : p instanceof K ? new j("validate", `报表 ${g} 模板校验失败:${p.message}`, p) : new j("fetch", `报表 ${g} 模板加载失败:${p instanceof Error ? p.message : String(p)}`, p);
1488
+ S = await Le(T.template(E), r), U(r);
1489
+ const u = tt(S);
1490
+ if (!u.ok)
1491
+ throw new D("validate", `报表 ${$} 模板校验失败:${u.errors.slice(0, 3).map((p) => `${p.path}: ${p.message}`).join("; ")}`);
1492
+ f.push(...u.warnings.map((p) => `${$}: ${p.path}: ${p.message}`));
1493
+ } catch (u) {
1494
+ throw r?.aborted ? pe(r) : u instanceof D ? u : u instanceof X ? new D("validate", `报表 ${$} 模板校验失败:${u.message}`, u) : new D("fetch", `报表 ${$} 模板加载失败:${u instanceof Error ? u.message : String(u)}`, u);
1451
1495
  }
1452
- else A = S.template;
1453
- let v;
1496
+ else S = T.template;
1497
+ let R;
1454
1498
  try {
1455
- v = await Be(S.load ? S.load(E) : S.datasets ?? {}, o);
1456
- } catch (p) {
1457
- throw o?.aborted ? ue(o) : p instanceof j ? p : new j("fetch", `报表 ${g} 取数失败:${p instanceof Error ? p.message : String(p)}`, p);
1499
+ R = await Le(T.load ? T.load(E) : T.datasets ?? {}, r);
1500
+ } catch (u) {
1501
+ throw r?.aborted ? pe(r) : u instanceof D ? u : new D("fetch", `报表 ${$} 取数失败:${u instanceof Error ? u.message : String(u)}`, u);
1458
1502
  }
1459
- Y(o), Ft(v, g);
1460
- let I;
1503
+ U(r), Dt(R, $);
1504
+ let F;
1461
1505
  try {
1462
- I = yt(A, v, S.pagination);
1463
- } catch (p) {
1464
- throw new j("validate", `报表 ${g} 排版失败:${p instanceof Error ? p.message : String(p)}`, p);
1506
+ F = $t(S, R, T.pagination);
1507
+ } catch (u) {
1508
+ throw new D("validate", `报表 ${$} 排版失败:${u instanceof Error ? u.message : String(u)}`, u);
1465
1509
  }
1466
- for (const p of I.plan.pages) h.push(p);
1467
- m.push(...I.warnings.map((p) => `${g}: ${p}`));
1510
+ const k = /* @__PURE__ */ new Map(), v = (u) => {
1511
+ let p = k.get(u);
1512
+ return p === void 0 && (p = JSON.stringify([y, $, u]), k.set(u, p)), p;
1513
+ };
1514
+ for (const u of F.plan.pages) h.push({
1515
+ ...u,
1516
+ components: u.components.map((p) => p.table ? {
1517
+ ...p,
1518
+ table: { ...p.table, id: v(p.table.id) }
1519
+ } : p)
1520
+ });
1521
+ f.push(...F.warnings.map((u) => `${$}: ${u}`));
1468
1522
  }
1469
- Y(o);
1470
- const b = { schemaVersion: ve, pages: h }, d = De(b);
1471
- if (!d.ok)
1472
- throw new j("validate", `渲染计划校验失败:${d.errors.slice(0, 3).map((w) => `${w.path}: ${w.message}`).join("; ")}`);
1473
- m.push(...d.warnings.map((w) => `${w.path}: ${w.message}`));
1474
- const u = a ?? t.onWarning ?? ((w) => console.warn("[mach-report]", w));
1475
- for (const w of m)
1476
- Y(o), u(w);
1477
- return Y(o), b;
1523
+ U(r);
1524
+ const g = { schemaVersion: Ae, pages: h }, c = We(g);
1525
+ if (!c.ok)
1526
+ throw new D("validate", `渲染计划校验失败:${c.errors.slice(0, 3).map((y) => `${y.path}: ${y.message}`).join("; ")}`);
1527
+ f.push(...c.warnings.map((y) => `${y.path}: ${y.message}`));
1528
+ const b = a ?? t.onWarning ?? ((y) => console.warn("[mach-report]", y));
1529
+ for (const y of f)
1530
+ U(r), b(y);
1531
+ return U(r), g;
1478
1532
  }, {
1479
- getParamDefs: (i) => st(e, i)
1533
+ getParamDefs: (o) => ct(e, o)
1480
1534
  });
1481
1535
  }
1482
1536
  export {
1483
- nn as CSS_DPI,
1484
- rn as DEFAULT_BORDER_PT,
1485
- $e as DEFAULT_FONT_PT,
1486
- on as DEFAULT_STROKE_COLOR,
1487
- rt as DEFAULT_TEXT_COLOR,
1488
- Se as LINE_HEIGHT,
1489
- sn as MM_PER_INCH,
1490
- he as PAPER_SIZES,
1491
- Pt as PageBuilder,
1492
- ve as RENDER_PLAN_SCHEMA_VERSION,
1493
- Ke as REPORT_TEMPLATE_DOCUMENT_VERSION,
1494
- j as ReportSourceError,
1495
- K as ReportTemplateError,
1496
- an as SCHEMA_VERSION_MACH,
1497
- Et as TemplateBuilder,
1498
- zt as assertRenderPlan,
1499
- mn as charWidthEm,
1500
- F as classOf,
1501
- kt as computePageWindow,
1502
- fn as createCanvasMeasurer,
1503
- Jt as createCanvasPager,
1504
- hn as createHeuristicMeasurer,
1505
- Zt as createReportSource,
1506
- Yt as createTableTemplate,
1507
- Gt as createTemplate,
1508
- Xt as createTemplateRegistry,
1509
- Qt as defineReport,
1510
- Ut as defineReportTemplate,
1511
- dt as evalStyleRule,
1512
- _e as formatValue,
1537
+ an as CSS_DPI,
1538
+ ln as DEFAULT_BORDER_PT,
1539
+ ve as DEFAULT_FONT_PT,
1540
+ dn as DEFAULT_STROKE_COLOR,
1541
+ Ie as DEFAULT_TEXT_COLOR,
1542
+ Te as LINE_HEIGHT,
1543
+ cn as MM_PER_INCH,
1544
+ ge as PAPER_SIZES,
1545
+ Rt as PageBuilder,
1546
+ Ae as RENDER_PLAN_SCHEMA_VERSION,
1547
+ Ze as REPORT_TEMPLATE_DOCUMENT_VERSION,
1548
+ D as ReportSourceError,
1549
+ X as ReportTemplateError,
1550
+ mn as SCHEMA_VERSION_MACH,
1551
+ Ct as TemplateBuilder,
1552
+ Jt as assertRenderPlan,
1553
+ un as charWidthEm,
1554
+ j as classOf,
1555
+ Et as computePageWindow,
1556
+ pn as createCanvasMeasurer,
1557
+ qt as createCanvasPager,
1558
+ yn as createHeuristicMeasurer,
1559
+ on as createReportSource,
1560
+ Xt as createTableTemplate,
1561
+ Kt as createTemplate,
1562
+ tn as createTemplateRegistry,
1563
+ nn as defineReport,
1564
+ Qt as defineReportTemplate,
1565
+ gt as evalStyleRule,
1566
+ ze as formatValue,
1513
1567
  ke as heuristicMeasurer,
1514
- it as isImageBackedComponent,
1515
- Le as isRichText,
1516
- Ge as measurePageSizePx,
1517
- gn as measureTextMm,
1518
- et as mmToPx,
1519
- ln as mmToPxFactor,
1520
- yt as paginateTemplate,
1521
- at as parseDateLocal,
1522
- qt as parseReportTemplate,
1523
- Wt as planFontSizePx,
1524
- fe as ptToPx,
1525
- cn as pxToMm,
1526
- Je as renderComponent,
1527
- St as renderPage,
1528
- It as renderPlan,
1529
- At as renderPlanToCanvas,
1530
- Vt as renderPlanToImages,
1531
- pe as resolveBoxBorders,
1532
- U as resolveFontSize,
1533
- nt as resolveGridLayout,
1534
- tt as resolveLineHeight,
1535
- qe as resolvePaper,
1536
- Z as resolveStroke,
1537
- Fe as resolveTextColor,
1538
- ee as round,
1539
- Kt as serializeReportTemplate,
1540
- je as toExcelNumberFormat,
1541
- we as toNumber,
1542
- Te as validateComponent,
1543
- ht as validatePage,
1544
- De as validateRenderPlan,
1545
- Qe as validateReportTemplate,
1546
- Bt as validateReportTemplateDocument,
1547
- oe as wrapText
1568
+ lt as isImageBackedComponent,
1569
+ De as isRichText,
1570
+ qe as measurePageSizePx,
1571
+ Mn as measureTextMm,
1572
+ rt as mmToPx,
1573
+ fn as mmToPxFactor,
1574
+ $t as paginateTemplate,
1575
+ mt as parseDateLocal,
1576
+ Zt as parseReportTemplate,
1577
+ Yt as planFontSizePx,
1578
+ he as ptToPx,
1579
+ hn as pxToMm,
1580
+ Ue as renderComponent,
1581
+ At as renderPage,
1582
+ Gt as renderPlan,
1583
+ Nt as renderPlanToCanvas,
1584
+ Ut as renderPlanToImages,
1585
+ ye as resolveBoxBorders,
1586
+ K as resolveFontSize,
1587
+ at as resolveGridLayout,
1588
+ st as resolveLineHeight,
1589
+ Qe as resolvePaper,
1590
+ te as resolveStroke,
1591
+ je as resolveTextColor,
1592
+ ne as round,
1593
+ en as serializeReportTemplate,
1594
+ _e as toExcelNumberFormat,
1595
+ Se as toNumber,
1596
+ Ee as validateComponent,
1597
+ yt as validatePage,
1598
+ We as validateRenderPlan,
1599
+ tt as validateReportTemplate,
1600
+ jt as validateReportTemplateDocument,
1601
+ le as wrapText
1548
1602
  };