@agile-team/mach-report 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +6 -2
  2. package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
  4. package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
  5. package/dist/ParamEditor-DRGxzxeO.js +381 -0
  6. package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
  7. package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +2 -0
  18. package/dist/analytics.d.ts +2 -0
  19. package/dist/analytics.js +29 -29
  20. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  21. package/dist/batch-mRqhhhjt.js +364 -0
  22. package/dist/computed-Bvk0W15F.js +521 -0
  23. package/dist/computed-CGV2a809.cjs +1 -0
  24. package/dist/config-B612mw0x.js +525 -0
  25. package/dist/config-BRoLo2oj.cjs +1 -0
  26. package/dist/designer.cjs +2 -2
  27. package/dist/designer.d.cts +659 -9
  28. package/dist/designer.d.ts +659 -9
  29. package/dist/designer.js +2030 -1824
  30. package/dist/index.cjs +8 -8
  31. package/dist/index.d.cts +147 -3
  32. package/dist/index.d.ts +147 -3
  33. package/dist/index.js +639 -592
  34. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  35. package/dist/injection-keys-e85udZCp.js +7 -0
  36. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  37. package/dist/{list-cell-Dxyi7DOw.js → list-cell-ClFra1zS.js} +54 -40
  38. package/dist/matrix-DVyWiYsd.cjs +1 -0
  39. package/dist/matrix-yZsGnldA.js +227 -0
  40. package/dist/param-validation-BlHHXs6u.js +153 -0
  41. package/dist/param-validation-DCK039V1.cjs +1 -0
  42. package/dist/pdf.cjs +25 -25
  43. package/dist/pdf.d.cts +3 -0
  44. package/dist/pdf.d.ts +3 -0
  45. package/dist/pdf.js +677 -677
  46. package/dist/plugin-BDTU4D94.cjs +1 -0
  47. package/dist/plugin-Cd5G2QQn.js +22 -0
  48. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  49. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  50. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  51. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  52. package/dist/server/node.d.cts +5 -2
  53. package/dist/server/node.d.ts +5 -2
  54. package/dist/server-node.cjs +1 -1
  55. package/dist/server-node.js +87 -87
  56. package/dist/server.cjs +1 -1
  57. package/dist/server.d.cts +201 -2
  58. package/dist/server.d.ts +201 -2
  59. package/dist/server.js +557 -658
  60. package/dist/style.css +1 -1
  61. package/dist/template-registry-WNXdkiET.js +506 -0
  62. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  63. package/dist/template-review-BXp2oyqg.cjs +1 -0
  64. package/dist/template-review-BdcXSYbx.js +1616 -0
  65. package/dist/tree-BX380Rr7.cjs +1 -0
  66. package/dist/tree-CqcQ99NM.js +172 -0
  67. package/dist/{validate-UUy9yP4K.js → validate-7s0yn6ii.js} +44 -44
  68. package/dist/validate-DsRiNw8h.cjs +1 -0
  69. package/dist/vue/async.d.cts +93 -4
  70. package/dist/vue/async.d.ts +93 -4
  71. package/dist/vue/index.d.cts +145 -7
  72. package/dist/vue/index.d.ts +145 -7
  73. package/dist/vue-async.cjs +1 -1
  74. package/dist/vue-async.js +5 -5
  75. package/dist/vue.cjs +1 -1
  76. package/dist/vue.js +116 -113
  77. package/dist/{workbook-session-B-bW5_yR.js → workbook-session-BKOTwcoq.js} +1 -1
  78. package/dist/{workbook-session-D7RtdNo0.cjs → workbook-session-CLYLhZWu.cjs} +1 -1
  79. package/dist/worker.cjs +1 -1
  80. package/dist/worker.d.cts +5 -2
  81. package/dist/worker.d.ts +5 -2
  82. package/dist/worker.js +1 -1
  83. package/dist/xlsx.cjs +3 -3
  84. package/dist/xlsx.d.cts +129 -2
  85. package/dist/xlsx.d.ts +129 -2
  86. package/dist/xlsx.js +336 -242
  87. package/package.json +1 -1
  88. package/dist/ExcelBindingWizard-CF7RplWm.cjs +0 -1
  89. package/dist/ExcelBindingWizard-qhwEderR.js +0 -842
  90. package/dist/ReportPreview-BE1tCHqE.js +0 -4604
  91. package/dist/ReportPreview-QKRKQOe3.cjs +0 -6
  92. package/dist/RuleEditor-BA36yIV6.js +0 -1723
  93. package/dist/RuleEditor-CczJ6mJm.cjs +0 -1
  94. package/dist/TemplateReviewPanel-CHi4Alqa.cjs +0 -1
  95. package/dist/TemplateReviewPanel-Dz0G5o83.js +0 -217
  96. package/dist/binding-preview-BWsdf_z2.cjs +0 -2
  97. package/dist/binding-preview-DILq0-0f.js +0 -649
  98. package/dist/decimal-CI1OAczk.js +0 -87
  99. package/dist/decimal-CQA0xJex.cjs +0 -1
  100. package/dist/list-cell-CyM1ZlRN.cjs +0 -1
  101. package/dist/matrix-BbXarwyk.js +0 -661
  102. package/dist/matrix-Cm65WLLP.cjs +0 -1
  103. package/dist/param-validation-BWNjLcN0.js +0 -116
  104. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  105. package/dist/plugin-CThk42vJ.cjs +0 -1
  106. package/dist/plugin-tGn7-5oF.js +0 -25
  107. package/dist/template-registry-CGWTLtIA.cjs +0 -1
  108. package/dist/template-registry-DzlQs3OF.js +0 -434
  109. package/dist/template-review-D1RoNCPw.cjs +0 -1
  110. package/dist/template-review-fnteXRng.js +0 -1473
  111. package/dist/validate-Bf6ccFr2.cjs +0 -1
package/dist/xlsx.js CHANGED
@@ -1,328 +1,422 @@
1
- import { a as w, o as W } from "./progress-7OSZbFok.js";
2
- import { e as z, E as I, m as v } from "./workbook-session-B-bW5_yR.js";
3
- import { i as pe, a as xe, o as Ee } from "./workbook-session-B-bW5_yR.js";
4
- import { i as C } from "./render-plan-Ck6koX9L.js";
5
- import { r as T } from "./grid-geometry-BNptEcMm.js";
6
- import { e as A, r as P } from "./style-CQ1PK8ZB.js";
7
- import { r as F } from "./capabilities-CK_7hizc.js";
8
- import { b as Me, c as ve, a as Ce, e as Se, g as ye, p as $e, v as ke, d as We, f as ze } from "./binding-preview-DILq0-0f.js";
9
- function E(t, e) {
10
- const i = t ?? e;
11
- if (!Number.isSafeInteger(i) || i <= 0) throw new Error("Excel 图片字节预算应为正安全整数");
12
- return i;
13
- }
14
- function R(t, e) {
15
- const i = t.imageData;
16
- if (!i || !/^data:image\/(png|jpe?g);base64,/i.test(i)) return;
17
- if (i.length > Math.ceil(e / 3) * 4 + 64) throw new Error("Excel 单张图片超过字节预算");
18
- const n = i.indexOf(","), r = i.slice(n + 1);
19
- if (!/^[A-Za-z0-9+/]+={0,2}$/.test(r) || r.length % 4 !== 0) throw new Error("Excel 图片不是有效的 base64 数据");
20
- const o = r.length / 4 * 3 - (r.endsWith("==") ? 2 : r.endsWith("=") ? 1 : 0);
21
- if (o > e) throw new Error("Excel 单张图片超过字节预算");
22
- const a = /^data:image\/png;/i.test(i) ? "png" : "jpeg", s = atob(r.slice(0, 12));
23
- if (a === "png" ? !s.startsWith(`‰PNG\r
1
+ import { a as x, o as z } from "./progress-7OSZbFok.js";
2
+ import { e as P, E as B, m as C } from "./workbook-session-BKOTwcoq.js";
3
+ import { i as ke, a as We, o as Ae } from "./workbook-session-BKOTwcoq.js";
4
+ import { i as $ } from "./render-plan-Ck6koX9L.js";
5
+ import { r as k } from "./grid-geometry-BNptEcMm.js";
6
+ import { e as W, r as N } from "./style-CQ1PK8ZB.js";
7
+ import { r as G } from "./capabilities-CK_7hizc.js";
8
+ import { b as Fe, c as Re, a as Te, d as ze, e as Pe, f as Be, g as Ne, h as Ge, p as Le, i as Oe, v as je, j as De, k as _e, l as He, m as Ke, n as Xe } from "./region-binding-workflow-CXDmt9Bs.js";
9
+ function y(e, t) {
10
+ const r = e ?? t;
11
+ if (!Number.isSafeInteger(r) || r <= 0) throw new Error("Excel 图片字节预算应为正安全整数");
12
+ return r;
13
+ }
14
+ function L(e, t) {
15
+ const r = e.imageData;
16
+ if (!r || !/^data:image\/(png|jpe?g);base64,/i.test(r)) return;
17
+ if (r.length > Math.ceil(t / 3) * 4 + 64) throw new Error("Excel 单张图片超过字节预算");
18
+ const n = r.indexOf(","), i = r.slice(n + 1);
19
+ if (!/^[A-Za-z0-9+/]+={0,2}$/.test(i) || i.length % 4 !== 0) throw new Error("Excel 图片不是有效的 base64 数据");
20
+ const o = i.length / 4 * 3 - (i.endsWith("==") ? 2 : i.endsWith("=") ? 1 : 0);
21
+ if (o > t) throw new Error("Excel 单张图片超过字节预算");
22
+ const s = /^data:image\/png;/i.test(r) ? "png" : "jpeg", a = atob(i.slice(0, 12));
23
+ if (s === "png" ? !a.startsWith(`‰PNG\r
24
24
  
25
- `) : !s.startsWith("ÿØÿ")) throw new Error("Excel 图片内容与 PNG/JPEG 类型不一致");
26
- return { base64: `data:image/${a};base64,${r}`, key: `${a}:${r}`, extension: a, bytes: o };
25
+ `) : !a.startsWith("ÿØÿ")) throw new Error("Excel 图片内容与 PNG/JPEG 类型不一致");
26
+ return { base64: `data:image/${s};base64,${i}`, key: `${s}:${i}`, extension: s, bytes: o };
27
27
  }
28
- function B(t, e, i) {
29
- let n = i * 72 / 25.4;
30
- if (!Number.isFinite(n) || e + Math.ceil(n / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
28
+ function O(e, t, r) {
29
+ let n = r * 72 / 25.4;
30
+ if (!Number.isFinite(n) || t + Math.ceil(n / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
31
31
  for (; n > 0; ) {
32
- if (e > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
33
- const r = Math.min(409, n);
34
- t.getRow(e++).height = r, n -= r;
32
+ if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
33
+ const i = Math.min(409, n);
34
+ e.getRow(t++).height = i, n -= i;
35
35
  }
36
- return e;
36
+ return t;
37
37
  }
38
- function L(t, e, i) {
39
- let n = Math.round(e * 36e3), r = 0;
38
+ function j(e, t, r) {
39
+ let n = Math.round(t * 36e3), i = 0;
40
40
  if (!Number.isSafeInteger(n)) throw new Error("Excel 图片锚点超出安全坐标范围");
41
- for (t.properties.defaultColWidth ??= 8.43; r < 16384; ) {
42
- const o = t.getColumn(r + 1).width ?? t.properties.defaultColWidth, a = Math.round(z(o) * 36e3);
43
- if (!Number.isSafeInteger(a) || a <= 0) throw new Error("Excel 图片锚点所在列宽无效");
44
- if (n < a) return { col: r + n / a, row: i - 1, nativeCol: r, nativeColOff: n, nativeRow: i - 1, nativeRowOff: 0 };
45
- n -= a, r++;
41
+ for (e.properties.defaultColWidth ??= 8.43; i < 16384; ) {
42
+ const o = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, s = Math.round(P(o) * 36e3);
43
+ if (!Number.isSafeInteger(s) || s <= 0) throw new Error("Excel 图片锚点所在列宽无效");
44
+ if (n < s) return { col: i + n / s, row: r - 1, nativeCol: i, nativeColOff: n, nativeRow: r - 1, nativeRowOff: 0 };
45
+ n -= s, i++;
46
46
  }
47
47
  throw new Error("Excel 图片锚点超过16384列上限");
48
48
  }
49
- function N(t, e, i) {
50
- const n = E(e.maxImageBytes, 16777216), r = E(e.maxTotalImageBytes, 32 * 1024 * 1024), o = E(e.maxImages, 1e3), a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
49
+ function D(e, t, r) {
50
+ const n = y(t.maxImageBytes, 16777216), i = y(t.maxTotalImageBytes, 32 * 1024 * 1024), o = y(t.maxImages, 1e3), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
51
51
  let l = 0;
52
52
  return { write(h, c, d) {
53
53
  if (![c.widthMm, c.heightMm, c.leftMm].every(Number.isFinite) || c.widthMm < 0 || c.heightMm < 0 || c.leftMm < 0) throw new Error("Excel 图片尺寸无效");
54
54
  if (!c.widthMm || !c.heightMm) return d;
55
- const g = s.get(c.imageData) ?? R(c, n);
56
- if (g && s.set(c.imageData, g), !g)
57
- return i.push(`${c.nid ?? c.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), d;
58
- let f = a.get(g.key);
59
- if (f === void 0) {
60
- if (a.size >= o) throw new Error("Excel 唯一图片数量超过预算");
61
- if (l + g.bytes > r) throw new Error("Excel 图片总字节数超过预算");
62
- f = t.addImage({ base64: g.base64, extension: g.extension }), a.set(g.key, f), l += g.bytes;
55
+ const f = a.get(c.imageData) ?? L(c, n);
56
+ if (f && a.set(c.imageData, f), !f)
57
+ return r.push(`${c.nid ?? c.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), d;
58
+ let g = s.get(f.key);
59
+ if (g === void 0) {
60
+ if (s.size >= o) throw new Error("Excel 唯一图片数量超过预算");
61
+ if (l + f.bytes > i) throw new Error("Excel 图片总字节数超过预算");
62
+ g = e.addImage({ base64: f.base64, extension: f.extension }), s.set(f.key, g), l += f.bytes;
63
63
  }
64
- const m = B(h, d, c.heightMm);
65
- return h.addImage(f, {
66
- tl: L(h, c.leftMm, d),
64
+ const u = O(h, d, c.heightMm);
65
+ return h.addImage(g, {
66
+ tl: j(h, c.leftMm, d),
67
67
  ext: { width: c.widthMm * 96 / 25.4, height: c.heightMm * 96 / 25.4 },
68
68
  editAs: "oneCell"
69
- }), m;
69
+ }), u;
70
70
  } };
71
71
  }
72
- const S = 72 / 25.4, O = 32767, G = 253;
73
- function p(t, e) {
74
- if (typeof t != "string") return;
75
- if (t.length > O)
76
- throw new Error(`Excel 单元格 ${e} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
77
- let i = 0;
78
- for (let n = 0; n < t.length; n++)
79
- if (t.charCodeAt(n) === 10 && ++i > G)
80
- throw new Error(`Excel 单元格 ${e} 最多支持 253 个换行,无法无损导出;内容未改写`);
81
- }
82
- function u(t) {
83
- if (!t) return;
84
- const e = t.replace("#", "");
85
- return /^[0-9a-fA-F]{6}$/.test(e) ? `FF${e.toUpperCase()}` : void 0;
86
- }
87
- function y(t, e = {}) {
88
- t.font = {
89
- name: e.fontFamily,
90
- bold: e.bold === !0,
91
- italic: e.italic === !0,
92
- underline: e.underline === !0,
93
- size: P(e).fontSizePt,
94
- color: u(e.color) ? { argb: u(e.color) } : void 0
72
+ function A(e) {
73
+ return !!e && typeof e == "object" && !Array.isArray(e);
74
+ }
75
+ function I(e, t) {
76
+ const r = e.meta?.xlsxFlow;
77
+ if (r === void 0) return;
78
+ if (!A(r) || r.version !== "1.0" || !Number.isSafeInteger(r.columnStart) || Number(r.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
79
+ if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
80
+ const n = r, i = e.grid.colWidthsMm;
81
+ if (!i?.length || n.columnStart + i.length > t.length || i.some((o, s) => Math.abs(o - t[n.columnStart + s]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
82
+ return n;
83
+ }
84
+ function F(e) {
85
+ const t = e.meta?.xlsxFlow;
86
+ if (t === void 0) {
87
+ if (e.components.some((n) => n.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
88
+ return;
89
+ }
90
+ const r = _(t, e.meta?.reportScope);
91
+ for (const n of e.components) {
92
+ const i = I(n, r.widths);
93
+ if (!i) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
94
+ const o = r.widths.slice(0, i.columnStart).reduce((a, l) => a + l, e.marginLeftMm ?? 0), s = n.grid.colWidthsMm.reduce((a, l) => a + l, 0);
95
+ if (Math.abs(o - n.leftMm) > 0.01 || Math.abs(s - n.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
96
+ }
97
+ return r;
98
+ }
99
+ function _(e, t) {
100
+ if (!A(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
101
+ if (!Array.isArray(e.fullWidthsMm) || !e.fullWidthsMm.length || e.fullWidthsMm.length > 16384 || e.fullWidthsMm.some((r) => typeof r != "number" || !Number.isFinite(r) || r <= 0 || r > 2e3)) throw new Error("Excel 多区域完整列宽无效");
102
+ if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
103
+ return { key: JSON.stringify([t ?? e.templateId, e.sheet]), sheet: e.sheet, widths: e.fullWidthsMm };
104
+ }
105
+ function b(e) {
106
+ return Math.round(e * 1e6) / 1e6;
107
+ }
108
+ function H(e, t, r, n, i) {
109
+ return e.components.filter((o) => n ? o.pageAnchor === "header" ? t === 0 : o.pageAnchor === "footer" ? t === r - 1 : o.table?.role !== "header" ? !0 : i.has(o.table.id) ? !1 : (i.add(o.table.id), !0) : !0);
110
+ }
111
+ function K(e, t, r, n) {
112
+ const i = e.components.filter((s) => !t.includes(s) && s.table?.role === "header"), o = t.filter((s) => !s.pageAnchor).reduce((s, a) => Math.max(s, a.topMm + a.heightMm), e.marginTopMm ?? 0);
113
+ return t.map((s) => {
114
+ let a = s.topMm;
115
+ return r && s.pageAnchor === "footer" && (a = o), a -= i.filter((l) => l.topMm + l.heightMm <= a + 1e-3).reduce((l, h) => l + h.heightMm, 0), { component: s, layout: k(s.grid, s.widthMm, s.heightMm), top: a, column: I(s, n).columnStart };
116
+ });
117
+ }
118
+ function X(e, t, r) {
119
+ const n = t.length - 1;
120
+ if (n * r.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
121
+ const i = new Map(t.map((a, l) => [a, l])), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
122
+ for (const a of e) for (const l of a.layout.cells) {
123
+ if (!Object.keys(l.cell).length) continue;
124
+ const h = i.get(b(a.top + l.yMm)), c = i.get(b(a.top + l.yMm + l.heightMm)), d = a.column + l.ci, f = d + (l.cell.colSpan ?? 1), g = `${h}:${d}`;
125
+ for (let u = h; u < c; u++) for (let m = d; m < f; m++) {
126
+ const p = `${u}:${m}`;
127
+ if (s.has(p)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
128
+ s.set(p, g);
129
+ }
130
+ o.set(g, { ...l.cell, style: W(a.component.style, l.cell.style), rowSpan: c - h, colSpan: f - d });
131
+ }
132
+ return Array.from({ length: n }, (a, l) => {
133
+ const h = [];
134
+ for (let c = 0; c < r.length; c++) {
135
+ const d = `${l}:${c}`, f = o.get(d);
136
+ f ? (h.push(f), c += (f.colSpan ?? 1) - 1) : s.has(d) || h.push(null);
137
+ }
138
+ return h;
139
+ });
140
+ }
141
+ function J(e, t) {
142
+ const r = /* @__PURE__ */ new Set(), n = [];
143
+ let i;
144
+ for (const [o, { page: s }] of e.entries()) {
145
+ const a = F(s);
146
+ if (i && (a.key !== i.key || a.widths.length !== i.widths.length || a.widths.some((g, u) => Math.abs(g - i.widths[u]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
147
+ i ??= a;
148
+ const l = H(s, o, e.length, t, r), h = K(s, l, t, a.widths);
149
+ if (!h.length) continue;
150
+ const c = [...new Set(h.flatMap((g) => [...g.layout.rows.map((u) => b(g.top + u.pos)), b(g.top + g.component.heightMm)]))].sort((g, u) => g - u), d = X(h, c, a.widths), f = c.slice(1).map((g, u) => g - c[u]);
151
+ n.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: a.widths.reduce((g, u) => g + u, 0), heightMm: f.reduce((g, u) => g + u, 0), grid: { cells: d, colWidthsMm: a.widths, rowHeightsMm: f } });
152
+ }
153
+ return n;
154
+ }
155
+ const R = 72 / 25.4, U = 32767, V = 253;
156
+ function E(e, t) {
157
+ if (typeof e != "string") return;
158
+ if (e.length > U)
159
+ throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
160
+ let r = 0;
161
+ for (let n = 0; n < e.length; n++)
162
+ if (e.charCodeAt(n) === 10 && ++r > V)
163
+ throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
164
+ }
165
+ function w(e) {
166
+ if (!e) return;
167
+ const t = e.replace("#", "");
168
+ return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
169
+ }
170
+ function T(e, t = {}) {
171
+ e.font = {
172
+ name: t.fontFamily,
173
+ bold: t.bold === !0,
174
+ italic: t.italic === !0,
175
+ underline: t.underline === !0,
176
+ size: N(t).fontSizePt,
177
+ color: w(t.color) ? { argb: w(t.color) } : void 0
95
178
  };
96
179
  }
97
- const x = {
180
+ const M = {
98
181
  a3: { width: 297, height: 420, code: 8 },
99
182
  a4: { width: 210, height: 297, code: 9 },
100
183
  a5: { width: 148, height: 210, code: 11 }
101
184
  };
102
- function D(t, e, i, n) {
103
- if (e && e !== "auto") return x[e].code;
104
- const r = Math.min(t.pageWidthMm, t.pageHeightMm), o = Math.max(t.pageWidthMm, t.pageHeightMm), a = Object.values(x).find((s) => Math.abs(r - s.width) <= 1 && Math.abs(o - s.height) <= 1);
105
- return a ? a.code : (n.push(`page ${i + 1}: 自定义纸张 ${t.pageWidthMm}×${t.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), x.a4.code);
106
- }
107
- function _(t, e, i, n) {
108
- const r = typeof e.text == "string" ? e.text : "";
109
- if (i !== "raw" || !Object.prototype.hasOwnProperty.call(e, "value")) {
110
- p(r, t.address), t.value = r;
185
+ function Z(e, t, r, n) {
186
+ if (t && t !== "auto") return M[t].code;
187
+ const i = Math.min(e.pageWidthMm, e.pageHeightMm), o = Math.max(e.pageWidthMm, e.pageHeightMm), s = Object.values(M).find((a) => Math.abs(i - a.width) <= 1 && Math.abs(o - a.height) <= 1);
188
+ return s ? s.code : (n.push(`page ${r + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), M.a4.code);
189
+ }
190
+ function q(e, t, r, n) {
191
+ const i = typeof t.text == "string" ? t.text : "";
192
+ if (r !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
193
+ E(i, e.address), e.value = i;
111
194
  return;
112
195
  }
113
- const o = e.value;
196
+ const o = t.value;
114
197
  if (o === null || typeof o == "string" || typeof o == "boolean" || typeof o == "number" && Number.isFinite(o)) {
115
- p(o, t.address), t.value = o, e.numberFormat && (t.numFmt = e.numberFormat);
198
+ E(o, e.address), e.value = o, t.numberFormat && (e.numFmt = t.numberFormat);
116
199
  return;
117
200
  }
118
- p(r, t.address), t.value = r, n.push(`原始单元格值无效,已保留显示文本:${t.address}`);
201
+ E(i, e.address), e.value = i, n.push(`原始单元格值无效,已保留显示文本:${e.address}`);
202
+ }
203
+ function Q(e) {
204
+ const t = F(e);
205
+ return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : Y(e);
119
206
  }
120
- function H(t) {
121
- const i = t.components.filter((n) => n.table !== void 0)[0]?.table;
122
- if (!(!i || typeof i.id != "string" || !i.id.trim() || !Array.isArray(i.columnKeys) || !i.columnKeys.length)) {
123
- for (const n of t.components) {
207
+ function Y(e) {
208
+ const r = e.components.filter((n) => n.table !== void 0)[0]?.table;
209
+ if (!(!r || typeof r.id != "string" || !r.id.trim() || !Array.isArray(r.columnKeys) || !r.columnKeys.length)) {
210
+ for (const n of e.components) {
124
211
  if (n.table) {
125
- if (!n.grid || n.table.id !== i.id) return;
212
+ if (!n.grid || n.table.id !== r.id) return;
126
213
  continue;
127
214
  }
128
- if (n.grid || n.kind !== "text" && !C(n) || n.richParagraphs?.length && !n.text && !n.lines?.length) return;
215
+ if (n.grid || n.kind !== "text" && !$(n) || n.richParagraphs?.length && !n.text && !n.lines?.length) return;
129
216
  }
130
- return { id: i.id, title: i.title, wide: i.layout === "wide" || t.layout === "wide" };
217
+ return { id: r.id, title: r.title, wide: r.layout === "wide" || e.layout === "wide" };
131
218
  }
132
219
  }
133
- function j(t, e) {
134
- const i = /* @__PURE__ */ new Set();
135
- for (const [n, r] of t.pages.entries())
136
- if (!e[n])
137
- for (const o of r.components)
138
- typeof o.table?.id == "string" && i.add(o.table.id);
139
- return i;
140
- }
141
- function b(t) {
142
- return t.layout === "wide" || t.components.some((e) => e.table?.layout === "wide");
143
- }
144
- function K(t, e, i) {
145
- const n = [], r = t.pages.map(H), o = j(t, r);
146
- for (const [a, s] of t.pages.entries()) {
147
- const l = r[a], h = l && !o.has(l.id), c = e === "pages" || !h ? void 0 : l;
148
- if (e === "continuous" && !c)
149
- throw new Error(`page ${a + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
150
- const d = c !== void 0 && (e === "continuous" || c.wide);
151
- !d && e !== "pages" && b(s) && i.push(`page ${a + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
152
- const g = n[n.length - 1];
153
- d && g?.continuous && g.tableId === c.id ? g.pages.push({ page: s, index: a }) : n.push({ pages: [{ page: s, index: a }], continuous: d, ...d ? { tableId: c.id, title: c.title } : {} });
220
+ function ee(e, t) {
221
+ const r = /* @__PURE__ */ new Set();
222
+ for (const [n, i] of e.pages.entries())
223
+ if (!t[n])
224
+ for (const o of i.components)
225
+ typeof o.table?.id == "string" && r.add(o.table.id);
226
+ return r;
227
+ }
228
+ function S(e) {
229
+ return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
230
+ }
231
+ function te(e, t, r) {
232
+ const n = [], i = e.pages.map(Q), o = ee(e, i);
233
+ for (const [s, a] of e.pages.entries()) {
234
+ const l = i[s], h = l && !o.has(l.id), c = t === "pages" || !h ? void 0 : l;
235
+ if (t === "continuous" && !c)
236
+ throw new Error(`page ${s + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
237
+ const d = c !== void 0 && (t === "continuous" || c.wide);
238
+ !d && t !== "pages" && S(a) && r.push(`page ${s + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
239
+ const f = n[n.length - 1];
240
+ d && f?.continuous && f.tableId === c.id ? f.pages.push({ page: a, index: s }) : n.push({ pages: [{ page: a, index: s }], continuous: d, ...d ? { tableId: c.id, title: c.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
154
241
  }
155
242
  return n;
156
243
  }
157
- function M(t, e, i) {
158
- return !t || t.length === e.length && t.every((n, r) => i(n, e[r]));
244
+ function v(e, t, r) {
245
+ return !e || e.length === t.length && e.every((n, i) => r(n, t[i]));
159
246
  }
160
- function X(t, e, i, n) {
161
- const r = t.table, o = e.columns.map((l) => l.size), a = M(n.keys, r.columnKeys, (l, h) => l === h), s = M(n.widths, o, (l, h) => Math.abs(l - h) <= 1e-3);
162
- if (r.columnKeys.length !== o.length || !a || !s)
163
- throw new Error(`page ${i + 1}: 连续 Excel 逻辑表 ${r.id} 的列结构或列宽不一致`);
164
- if (n.keys ??= r.columnKeys, n.widths ??= o, r.role === "header") {
165
- if (r.rowIndex !== -1) throw new Error(`page ${i + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
247
+ function ne(e, t, r, n) {
248
+ const i = e.table, o = t.columns.map((l) => l.size), s = v(n.keys, i.columnKeys, (l, h) => l === h), a = v(n.widths, o, (l, h) => Math.abs(l - h) <= 1e-3);
249
+ if (i.columnKeys.length !== o.length || !s || !a)
250
+ throw new Error(`page ${r + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
251
+ if (n.keys ??= i.columnKeys, n.widths ??= o, i.role === "header") {
252
+ if (i.rowIndex !== -1) throw new Error(`page ${r + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
166
253
  n.headerSeen = !0;
167
254
  } else {
168
- if (!["body", "group-header", "subtotal", "grand-total"].includes(r.role) || r.rowIndex !== n.expectedRow)
169
- throw new Error(`page ${i + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
170
- n.expectedRow += e.rows.length;
255
+ if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== n.expectedRow)
256
+ throw new Error(`page ${r + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
257
+ n.expectedRow += t.rows.length;
171
258
  }
172
- if (e.cells.some((l) => l.cell.children?.length))
173
- throw new Error(`page ${i + 1}: 连续 Excel 暂不支持嵌套组件;请使用独立 Sheet 导出并检查告警`);
259
+ if (t.cells.some((l) => l.cell.children?.length))
260
+ throw new Error(`page ${r + 1}: 连续 Excel 暂不支持嵌套组件;请使用独立 Sheet 导出并检查告警`);
174
261
  }
175
- function J(t, e) {
176
- const i = { expectedRow: 0, headerSeen: !1 };
177
- for (const { page: n, index: r } of t.pages)
262
+ function re(e, t) {
263
+ const r = { expectedRow: 0, headerSeen: !1 };
264
+ for (const { page: n, index: i } of e.pages)
178
265
  for (const o of n.components) {
179
- const a = e.get(o);
180
- o.table && a && X(o, a, r, i);
266
+ const s = t.get(o);
267
+ o.table && s && ne(o, s, i, r);
181
268
  }
182
- if (!i.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
269
+ if (!r.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
183
270
  }
184
- function U(t, e, i) {
185
- let n = (t?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${e + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${e + 1}`;
271
+ function ie(e, t, r) {
272
+ let n = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
186
273
  n.toLowerCase() === "history" && (n += " 报表");
187
- let r = n, o = 1;
188
- for (; i.has(r.toLowerCase()); ) {
189
- const a = ` (${++o})`;
190
- r = n.slice(0, 31 - a.length) + a;
274
+ let i = n, o = 1;
275
+ for (; r.has(i.toLowerCase()); ) {
276
+ const s = ` (${++o})`;
277
+ i = n.slice(0, 31 - s.length) + s;
191
278
  }
192
- return i.add(r.toLowerCase()), r;
279
+ return r.add(i.toLowerCase()), i;
193
280
  }
194
- function V(t) {
195
- const e = /* @__PURE__ */ new Set();
196
- function i(n, r, o, a) {
197
- return n <= r ? n : (e.has(o) || (t.push(a), e.add(o)), r);
281
+ function oe(e) {
282
+ const t = /* @__PURE__ */ new Set();
283
+ function r(n, i, o, s) {
284
+ return n <= i ? n : (t.has(o) || (e.push(s), t.add(o)), i);
198
285
  }
199
286
  return {
200
- column: (n) => i(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
201
- row: (n) => i(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
287
+ column: (n) => r(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
288
+ row: (n) => r(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
202
289
  };
203
290
  }
204
- function Z(t) {
205
- const e = t.pages.flatMap(({ page: o, index: a }, s) => o.components.filter((l) => !t.continuous || (l.pageAnchor !== "header" || s === 0) && (l.pageAnchor !== "footer" || s === t.pages.length - 1)).map((l) => ({ comp: l, pageIndex: a }))), i = /* @__PURE__ */ new Map();
206
- let n = 1, r = 0;
207
- for (const { comp: o } of e)
291
+ function se(e) {
292
+ const t = e.flow ? J(e.pages, e.continuous).map((o) => ({ comp: o, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: o, index: s }, a) => o.components.filter((l) => !e.continuous || (l.pageAnchor !== "header" || a === 0) && (l.pageAnchor !== "footer" || a === e.pages.length - 1)).map((l) => ({ comp: l, pageIndex: s }))), r = /* @__PURE__ */ new Map();
293
+ let n = 1, i = 0;
294
+ for (const { comp: o } of t)
208
295
  if (o.grid) {
209
- const a = T(o.grid, o.widthMm, o.heightMm);
210
- i.set(o, a), n = Math.max(n, a.columns.length);
211
- } else o.kind === "text" && (r = Math.max(r, o.widthMm));
296
+ const s = k(o.grid, o.widthMm, o.heightMm);
297
+ r.set(o, s), n = Math.max(n, s.columns.length);
298
+ } else o.kind === "text" && (i = Math.max(i, o.widthMm));
212
299
  if (n > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
213
- return { components: e, grids: i, columnCount: n, textWidthMm: r };
300
+ return { components: t, grids: r, columnCount: n, textWidthMm: i };
214
301
  }
215
- function q(t, e, i) {
216
- const { page: n, index: r } = t.pages[0], o = e !== void 0 && e !== "auto";
217
- return (t.continuous || b(n)) && !o ? {} : { pageSetup: {
218
- paperSize: D(n, e, r, i),
302
+ function ae(e, t, r) {
303
+ const { page: n, index: i } = e.pages[0], o = t !== void 0 && t !== "auto";
304
+ return (e.continuous || S(n)) && !o ? {} : { pageSetup: {
305
+ paperSize: Z(n, t, i, r),
219
306
  orientation: n.pageWidthMm > n.pageHeightMm ? "landscape" : "portrait",
220
307
  fitToPage: !0,
221
- ...t.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
308
+ ...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
222
309
  } };
223
310
  }
224
- function Q(t) {
225
- const e = u(t.borderColor ?? t.lineColor), i = { style: "thin", ...e ? { color: { argb: e } } : {} };
311
+ function le(e) {
312
+ const t = w(e.borderColor ?? e.lineColor), r = { style: "thin", ...t ? { color: { argb: t } } : {} };
226
313
  return {
227
- ...t.borderTop !== !1 ? { top: i } : {},
228
- ...t.borderLeft !== !1 ? { left: i } : {},
229
- ...t.borderBottom !== !1 ? { bottom: i } : {},
230
- ...t.borderRight !== !1 ? { right: i } : {}
314
+ ...e.borderTop !== !1 ? { top: r } : {},
315
+ ...e.borderLeft !== !1 ? { left: r } : {},
316
+ ...e.borderBottom !== !1 ? { bottom: r } : {},
317
+ ...e.borderRight !== !1 ? { right: r } : {}
231
318
  };
232
319
  }
233
- function Y(t, e) {
234
- t.alignment = { horizontal: e.align ?? "left", vertical: e.verticalAlign ?? "middle", wrapText: !0 };
235
- const i = u(e.backgroundColor);
236
- i && (t.fill = { type: "pattern", pattern: "solid", fgColor: { argb: i } }), t.border = Q(e), y(t, e);
320
+ function ce(e, t) {
321
+ e.alignment = { horizontal: t.align ?? "left", vertical: t.verticalAlign ?? "middle", wrapText: !0 };
322
+ const r = w(t.backgroundColor);
323
+ r && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: r } }), e.border = le(t), T(e, t);
237
324
  }
238
- function ee(t, e) {
239
- for (const [i, n] of e.columns.entries()) {
240
- const r = t.sheet.getColumn(i + 1), o = t.limits.column(v(n.size));
241
- (r.width == null || r.width < o) && (r.width = o);
325
+ function he(e, t) {
326
+ for (const [r, n] of t.columns.entries()) {
327
+ const i = e.sheet.getColumn(r + 1), o = e.limits.column(C(n.size));
328
+ (i.width == null || i.width < o) && (i.width = o);
242
329
  }
243
330
  }
244
- function te(t, e, i) {
245
- for (const [n, r] of e.rows.entries()) {
246
- const o = t.sheet.getRow(i + n), a = t.limits.row(r.size * S);
247
- (o.height == null || o.height < a) && (o.height = a);
331
+ function de(e, t, r) {
332
+ for (const [n, i] of t.rows.entries()) {
333
+ const o = e.sheet.getRow(r + n), s = e.limits.row(i.size * R);
334
+ (o.height == null || o.height < s) && (o.height = s);
248
335
  }
249
336
  }
250
- function ne(t, e, i, n) {
251
- const r = Math.max(1, Math.min(e.cell.colSpan ?? 1, i.columns.length - e.ci)), o = Math.max(1, Math.min(e.cell.rowSpan ?? 1, i.rows.length - e.ri));
252
- (r > 1 || o > 1) && t.mergeCells(n + e.ri, e.ci + 1, n + e.ri + o - 1, e.ci + r);
337
+ function fe(e, t, r, n) {
338
+ const i = Math.max(1, Math.min(t.cell.colSpan ?? 1, r.columns.length - t.ci)), o = Math.max(1, Math.min(t.cell.rowSpan ?? 1, r.rows.length - t.ri));
339
+ (i > 1 || o > 1) && e.mergeCells(n + t.ri, t.ci + 1, n + t.ri + o - 1, t.ci + i);
253
340
  }
254
- function ie(t, e, i, n, r) {
255
- if (n + i.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
256
- te(t, i, n);
257
- for (const o of i.cells) {
258
- const a = t.sheet.getCell(n + o.ri, o.ci + 1);
259
- _(a, o.cell, t.valueMode, t.warnings), o.cell.children?.length && t.warnings.push(`page ${r + 1} ${e.nid ?? e.kind} cell ${o.ri + 1}:${o.ci + 1}: 嵌套组件内容暂不支持 xlsx 导出,已跳过`), Y(a, A(e.style, o.cell.style)), ne(t.sheet, o, i, n);
341
+ function ge(e, t, r, n, i) {
342
+ if (n + r.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
343
+ de(e, r, n);
344
+ for (const o of r.cells) {
345
+ const s = e.sheet.getCell(n + o.ri, o.ci + 1);
346
+ q(s, o.cell, e.valueMode, e.warnings), o.cell.children?.length && e.warnings.push(`page ${i + 1} ${t.nid ?? t.kind} cell ${o.ri + 1}:${o.ci + 1}: 嵌套组件内容暂不支持 xlsx 导出,已跳过`), ce(s, W(t.style, o.cell.style)), o.cell.indentMm && (s.alignment = { ...s.alignment, indent: Math.min(250, Math.max(1, Math.round(o.cell.indentMm / 2.5))) }), fe(e.sheet, o, r, n);
260
347
  }
261
- return n + i.rows.length;
348
+ return n + r.rows.length;
262
349
  }
263
- function re(t, e, i, n, r) {
264
- const o = Array.isArray(e.lines) && e.lines.length > 0 ? e.lines.join(`
265
- `) : e.text ?? "";
266
- if (e.richParagraphs?.length) {
350
+ function ue(e, t, r, n, i) {
351
+ const o = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
352
+ `) : t.text ?? "";
353
+ if (t.richParagraphs?.length) {
267
354
  const h = o.length === 0 ? "富文本内容暂不支持 xlsx 导出,已跳过" : "富文本按已有文本回退导出,内联样式未保留";
268
- t.warnings.push(`page ${r + 1} ${e.nid ?? e.kind}: ${h}`);
355
+ e.warnings.push(`page ${i + 1} ${t.nid ?? t.kind}: ${h}`);
269
356
  }
270
- const a = t.sheet.getRow(i), s = a.getCell(1);
271
- p(o, s.address), s.value = o, s.alignment = { horizontal: e.style?.align ?? "left", vertical: e.style?.verticalAlign ?? "middle", wrapText: !0 };
272
- const l = u(e.style?.backgroundColor);
273
- return l && (s.fill = { type: "pattern", pattern: "solid", fgColor: { argb: l } }), y(s, e.style), n > 1 && t.sheet.mergeCells(i, 1, i, n), a.height = t.limits.row(e.heightMm * S), i + 1;
274
- }
275
- function oe(t, e, i) {
276
- const n = e + i - 1;
277
- t.views = [{ state: "frozen", ySplit: n, xSplit: 0 }], t.pageSetup.printTitlesRow = `1:${n}`;
278
- }
279
- function ae(t, e, i, n) {
280
- !e.grids.size && e.textWidthMm > 0 && (t.sheet.getColumn(1).width = t.limits.column(v(e.textWidthMm)));
281
- for (const a of e.grids.values()) ee(t, a);
282
- let r = 1, o = !1;
283
- for (const { comp: a, pageIndex: s } of e.components) {
284
- const l = i && a.table?.role === "header";
357
+ const s = e.sheet.getRow(r), a = s.getCell(1);
358
+ E(o, a.address), a.value = o, a.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
359
+ const l = w(t.style?.backgroundColor);
360
+ return l && (a.fill = { type: "pattern", pattern: "solid", fgColor: { argb: l } }), T(a, t.style), n > 1 && e.sheet.mergeCells(r, 1, r, n), s.height = e.limits.row(t.heightMm * R), r + 1;
361
+ }
362
+ function me(e, t, r) {
363
+ const n = t + r - 1;
364
+ e.views = [{ state: "frozen", ySplit: n, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${n}`;
365
+ }
366
+ function we(e, t, r, n) {
367
+ !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(C(t.textWidthMm)));
368
+ for (const s of t.grids.values()) he(e, s);
369
+ let i = 1, o = !1;
370
+ for (const { comp: s, pageIndex: a } of t.components) {
371
+ const l = r && s.table?.role === "header";
285
372
  if (l && o) continue;
286
- if (r > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
287
- const h = e.grids.get(a);
288
- h ? (l && (oe(t.sheet, r, h.rows.length), o = !0), r = ie(t, a, h, r, s)) : a.kind === "text" ? r = re(t, a, r, e.columnCount, s) : C(a) ? r = n.write(t.sheet, a, r) : t.warnings.push(`page ${s + 1} ${a.nid ?? a.kind}: 组件类型 ${a.kind} 暂不支持 xlsx 导出,已跳过`);
373
+ if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
374
+ const h = t.grids.get(s);
375
+ h ? (l && (me(e.sheet, i, h.rows.length), o = !0), i = ge(e, s, h, i, a)) : s.kind === "text" ? i = ue(e, s, i, t.columnCount, a) : $(s) ? i = n.write(e.sheet, s, i) : e.warnings.push(`page ${a + 1} ${s.nid ?? s.kind}: 组件类型 ${s.kind} 暂不支持 xlsx 导出,已跳过`);
289
376
  }
290
377
  }
291
- function se(t) {
292
- if (t.valueMode !== void 0 && t.valueMode !== "text" && t.valueMode !== "raw")
378
+ function pe(e) {
379
+ if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
293
380
  throw new Error("xlsx valueMode 必须是 text 或 raw");
294
- if (t.paperSize !== void 0 && t.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(x, t.paperSize))
381
+ if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(M, e.paperSize))
295
382
  throw new Error("xlsx paperSize 必须是 auto、a3、a4 或 a5");
296
- if (t.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(t.sheetMode))
383
+ if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
297
384
  throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
298
385
  }
299
- async function ue(t, e = {}) {
300
- se(e), w(e.signal);
301
- const i = F(t, "xlsx", e), n = new I.Workbook(), r = [], o = N(n, e, r), a = V(r), s = K(t, e.sheetMode, r), l = /* @__PURE__ */ new Set();
302
- for (const [c, d] of s.entries()) {
303
- const g = Z(d);
304
- d.continuous && J(d, g.grids);
305
- const f = d.pages[0].page, m = e.sheetName?.(c) ?? U(d.title, c, l);
306
- l.add(m.toLowerCase());
307
- const $ = n.addWorksheet(m, q(d, e.paperSize, r)), k = e.valueMode ?? (b(f) || d.continuous ? "raw" : "text");
308
- w(e.signal), ae({ sheet: $, warnings: r, limits: a, valueMode: k }, g, d.continuous, o), await W(e, c + 1, s.length);
386
+ async function ve(e, t = {}) {
387
+ pe(t), x(t.signal);
388
+ const r = G(e, "xlsx", t), n = new B.Workbook(), i = [], o = D(n, t, i), s = oe(i), a = te(e, t.sheetMode, i), l = /* @__PURE__ */ new Set();
389
+ for (const [c, d] of a.entries()) {
390
+ const f = se(d);
391
+ d.continuous && !d.flow && re(d, f.grids);
392
+ const g = d.pages[0].page, u = t.sheetName?.(c) ?? ie(d.title, c, l);
393
+ l.add(u.toLowerCase());
394
+ const m = n.addWorksheet(u, ae(d, t.paperSize, i)), p = t.valueMode ?? (S(g) || d.continuous || d.flow ? "raw" : "text");
395
+ x(t.signal), we({ sheet: m, warnings: i, limits: s, valueMode: p }, f, d.continuous, o), await z(t, c + 1, a.length);
309
396
  }
310
- w(e.signal);
397
+ x(t.signal);
311
398
  const h = await n.xlsx.writeBuffer();
312
- return w(e.signal), { workbook: n, buffer: h, warnings: r, diagnostics: i };
399
+ return x(t.signal), { workbook: n, buffer: h, warnings: i, diagnostics: r };
313
400
  }
314
401
  export {
315
- Me as bindExcelTemplate,
316
- ve as createExcelBindingDocument,
317
- Ce as createExcelBindingSession,
318
- Se as excelBindingRowRange,
319
- ye as getExcelSheetWindow,
320
- pe as importExcelTemplate,
321
- xe as inspectExcelWorkbook,
322
- Ee as openExcelWorkbook,
323
- $e as parseExcelBindingSession,
324
- ue as renderPlanToXlsx,
325
- ke as validateExcelBindingFields,
326
- We as validateExcelBindingRecipe,
327
- ze as validateExcelBindingRegions
402
+ Fe as bindExcelTemplate,
403
+ Re as createExcelBindingDocument,
404
+ Te as createExcelBindingSession,
405
+ ze as createExcelRegionBindingDocument,
406
+ Pe as createExcelRegionBindingSession,
407
+ Be as excelBindingCellRange,
408
+ Ne as excelBindingRowRange,
409
+ Ge as getExcelSheetWindow,
410
+ ke as importExcelTemplate,
411
+ We as inspectExcelWorkbook,
412
+ Ae as openExcelWorkbook,
413
+ Le as parseExcelBindingSession,
414
+ Oe as parseExcelRegionBindingSession,
415
+ ve as renderPlanToXlsx,
416
+ je as validateExcelBindingFields,
417
+ De as validateExcelBindingRecipe,
418
+ _e as validateExcelBindingRegions,
419
+ He as validateExcelRegionBindings,
420
+ Ke as validateExcelRegionFields,
421
+ Xe as validateExcelRegionGeometry
328
422
  };