@agile-team/mach-report 2.15.0 → 2.16.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 (155) hide show
  1. package/README.md +14 -9
  2. package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
  4. package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-CUQLgoxa.cjs} +1 -1
  5. package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-OKesP_nO.js} +1 -1
  6. package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-ruxcbfY6.js} +3 -3
  8. package/dist/ReportPreview-BcDKCLiK.js +4834 -0
  9. package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
  12. package/dist/{RuleEditor-XhGHK8DE.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
  13. package/dist/{RuleEditor-C_Clasvd.js → RuleEditor-CGl9XY2s.js} +2 -2
  14. package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-SXCjaPKR.js} +1 -1
  16. package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
  17. package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
  18. package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-CJ9PLc48.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
  20. package/dist/analytics.d.cts +2 -0
  21. package/dist/analytics.d.ts +2 -0
  22. package/dist/artifact-integrity.json +99 -91
  23. package/dist/{assets-DEaz4qsp.js → assets-CqIbfbTr.js} +24 -22
  24. package/dist/assets-e4YSke8n.cjs +1 -0
  25. package/dist/auto-YR7a4BtF.js +240 -0
  26. package/dist/auto-uVBjX1j5.cjs +1 -0
  27. package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
  28. package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
  29. package/dist/capabilities-DDwXr_cA.js +103 -0
  30. package/dist/capabilities-DNLyZdNw.cjs +1 -0
  31. package/dist/codes.d.cts +2 -0
  32. package/dist/codes.d.ts +2 -0
  33. package/dist/component-tree-Ca6YYfHq.js +61 -0
  34. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  35. package/dist/config-Dg_o8e7m.cjs +1 -0
  36. package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
  37. package/dist/designer-BfQSahxq.js +5163 -0
  38. package/dist/designer-CPPdeM5_.cjs +2 -0
  39. package/dist/designer.cjs +1 -1
  40. package/dist/designer.d.cts +53 -0
  41. package/dist/designer.d.ts +53 -0
  42. package/dist/designer.js +1 -1
  43. package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
  44. package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
  45. package/dist/drill-CsdjgkRM.cjs +1 -0
  46. package/dist/{drill-ByJviLXS.js → drill-DIGsZfyB.js} +11 -11
  47. package/dist/encoding-BOGq4qYL.js +21 -0
  48. package/dist/encoding-BYF9ZTl9.cjs +1 -0
  49. package/dist/{font-loader-Q3bQjmrI.js → font-loader-CzI1GuBc.js} +1 -1
  50. package/dist/{font-loader-B_UkxpzC.cjs → font-loader-EKLzOJxf.cjs} +1 -1
  51. package/dist/index.cjs +7 -8
  52. package/dist/index.d.cts +2 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +865 -834
  55. package/dist/json-snapshot-D6ioHth9.js +1702 -0
  56. package/dist/json-snapshot-DknkjvxP.cjs +2 -0
  57. package/dist/{pdf-CvvrjPQg.cjs → pdf-ByVCb1i6.cjs} +48 -50
  58. package/dist/{pdf-BwNyeGpt.js → pdf-DJ5S6ukC.js} +2737 -2749
  59. package/dist/pdf.cjs +1 -1
  60. package/dist/pdf.d.cts +2 -0
  61. package/dist/pdf.d.ts +2 -0
  62. package/dist/pdf.js +2 -2
  63. package/dist/{plugin-Ca_XZG3l.js → plugin-C2j5_mhx.js} +1 -1
  64. package/dist/{plugin-DHO7X8z2.cjs → plugin-Dr39GBRG.cjs} +1 -1
  65. package/dist/prepared-DdrjLC7L.cjs +1 -0
  66. package/dist/prepared-DqtpvRTn.js +87 -0
  67. package/dist/progress-BXzlVbIp.js +29 -0
  68. package/dist/progress-DJBd9Rb9.cjs +1 -0
  69. package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
  70. package/dist/protocol-BzwMP4Vw.cjs +1 -0
  71. package/dist/protocol-kt4Iy6-3.js +90 -0
  72. package/dist/{record-bindings-Do_b3h4V.js → record-bindings-CZWBJ1fU.js} +9 -10
  73. package/dist/record-bindings-DUX1VMlR.cjs +1 -0
  74. package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-CWNvIjkV.js} +1 -1
  75. package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
  76. package/dist/report-encoding-worker.cjs +1 -0
  77. package/dist/report-encoding-worker.d.ts +1 -0
  78. package/dist/report-encoding-worker.js +2 -0
  79. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  80. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  81. package/dist/runtime-BjKBI530.js +168 -0
  82. package/dist/runtime-CBFEPKEs.cjs +1 -0
  83. package/dist/sbom.cdx.json +2 -2
  84. package/dist/server/node.d.cts +86 -1
  85. package/dist/server/node.d.ts +86 -1
  86. package/dist/server-node.cjs +5 -1
  87. package/dist/server-node.js +4558 -473
  88. package/dist/server.cjs +1 -1
  89. package/dist/server.d.cts +8 -1
  90. package/dist/server.d.ts +8 -1
  91. package/dist/server.js +634 -792
  92. package/dist/sha256-BshdOkCC.cjs +1 -0
  93. package/dist/sha256-DTG-Gq8i.js +157 -0
  94. package/dist/style-67OqfNed.js +73 -0
  95. package/dist/style-C22Pbv3T.cjs +1 -0
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-j2B1MJlL.js → template-catalog-BtR2JmCL.js} +9 -9
  98. package/dist/{template-catalog-FJE_c9Qe.cjs → template-catalog-C2NLdrwB.cjs} +1 -1
  99. package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
  100. package/dist/{template-fragments-BGbQLGlV.js → template-fragments-By0aZC1D.js} +2 -2
  101. package/dist/template-registry-C62vpv4a.cjs +1 -0
  102. package/dist/{template-registry-BtaKPELV.js → template-registry-Cw3vRTX2.js} +389 -321
  103. package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
  104. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  105. package/dist/vue/async.d.cts +66 -0
  106. package/dist/vue/async.d.ts +66 -0
  107. package/dist/vue/index.d.cts +89 -1
  108. package/dist/vue/index.d.ts +89 -1
  109. package/dist/vue-async.cjs +1 -1
  110. package/dist/vue-async.js +3 -3
  111. package/dist/vue.cjs +1 -1
  112. package/dist/vue.js +7 -7
  113. package/dist/{workbook-session-BvToI-Fd.js → workbook-session-BeSO8PFB.js} +153 -140
  114. package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-Cbts-22R.cjs} +12 -12
  115. package/dist/worker.cjs +1 -1
  116. package/dist/worker.d.cts +84 -1
  117. package/dist/worker.d.ts +84 -1
  118. package/dist/worker.js +12 -157
  119. package/dist/xlsx-node.cjs +33 -33
  120. package/dist/xlsx-node.js +1282 -1289
  121. package/dist/xlsx.cjs +4 -3
  122. package/dist/xlsx.d.cts +2 -0
  123. package/dist/xlsx.d.ts +2 -0
  124. package/dist/xlsx.js +297 -279
  125. package/package.json +6 -3
  126. package/dist/ReportPreview-ChV19HBp.js +0 -4619
  127. package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
  128. package/dist/assets-B9ImAi6_.cjs +0 -1
  129. package/dist/batch-BaP6pWDE.cjs +0 -1
  130. package/dist/batch-CGyt-b2W.js +0 -273
  131. package/dist/capabilities-CAh2Nrue.cjs +0 -1
  132. package/dist/capabilities-DskCHs3V.js +0 -69
  133. package/dist/config-D10us76d.cjs +0 -1
  134. package/dist/data-explanation-B8MZRYVS.js +0 -16
  135. package/dist/data-explanation-DE55G30w.cjs +0 -1
  136. package/dist/defaults-DXhiM1ZD.js +0 -10
  137. package/dist/defaults-xhmcLLrf.cjs +0 -1
  138. package/dist/designer-2bDlcNXQ.js +0 -5136
  139. package/dist/designer-BT7XCdbW.cjs +0 -2
  140. package/dist/drill-DYTxuL3A.cjs +0 -1
  141. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  142. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  143. package/dist/json-snapshot-DFb2eWkf.js +0 -1416
  144. package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
  145. package/dist/prepared-CFy9B75C.cjs +0 -1
  146. package/dist/prepared-ajM-H-9B.js +0 -69
  147. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  148. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  149. package/dist/render-plan-Ck6koX9L.js +0 -13
  150. package/dist/sha256-ArEYjaTI.cjs +0 -1
  151. package/dist/sha256-DPEuJ3nh.js +0 -155
  152. package/dist/style-CQ1PK8ZB.js +0 -67
  153. package/dist/style-UgIJSA1F.cjs +0 -1
  154. package/dist/template-registry-Co1zPq5e.cjs +0 -1
  155. package/dist/textwrap-CWHyzkBH.cjs +0 -4
package/dist/xlsx.js CHANGED
@@ -1,74 +1,95 @@
1
- import { a as M, o as P, c as B } from "./progress-D-OTpEav.js";
2
- import { e as N, E as O, m as C, i as L } from "./workbook-session-BvToI-Fd.js";
3
- import { a as We, b as Ie, o as Te } from "./workbook-session-BvToI-Fd.js";
4
- import { i as k } from "./render-plan-Ck6koX9L.js";
5
- import { c as j } from "./media-Y90dHK9z.js";
6
- import { r as $ } from "./grid-geometry-BNptEcMm.js";
7
- import { e as y, r as A } from "./style-CQ1PK8ZB.js";
8
- import { r as G } from "./capabilities-DskCHs3V.js";
9
- import { b as Pe, c as Be, a as Ne, d as Oe, e as Le, f as je, g as Ge, h as He, p as _e, i as De, v as Ue, j as Ke, k as Xe, l as Je, m as Ve, n as qe } from "./region-binding-workflow-BMhK_TjP.js";
10
- function H(e, t, r) {
11
- let n = r * 72 / 25.4;
1
+ import { f as w, r as k } from "./style-67OqfNed.js";
2
+ import { b as E, o as B, c as N } from "./progress-Hc2vxoCs.js";
3
+ import { e as O, E as L, m as $, i as j } from "./workbook-session-BeSO8PFB.js";
4
+ import { a as Ie, b as Pe, o as ze } from "./workbook-session-BeSO8PFB.js";
5
+ import { i as S } from "./component-tree-Ca6YYfHq.js";
6
+ import { c as G } from "./media-Y90dHK9z.js";
7
+ import { r as A } from "./grid-geometry-BNptEcMm.js";
8
+ import { r as H } from "./capabilities-DDwXr_cA.js";
9
+ import { b as Ne, c as Oe, a as Le, d as je, e as Ge, f as He, g as _e, h as De, p as Ue, i as Ke, v as Xe, j as Je, k as Ve, l as qe, m as Qe, n as Ye } from "./region-binding-workflow-CWNvIjkV.js";
10
+ function F(e, t) {
11
+ return { richText: e.flatMap((o, n) => [
12
+ ...n ? [{ text: `
13
+ ` }] : [],
14
+ ...o.segments.map((i) => {
15
+ const a = w(t, i.style), r = a.color?.replace(/^#/, "");
16
+ return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: k(a).fontSizePt, .../^[a-f\d]{6}$/i.test(r ?? "") ? { color: { argb: `FF${r.toUpperCase()}` } } : {} } };
17
+ })
18
+ ]) };
19
+ }
20
+ function _(e, t) {
21
+ const o = e.children?.filter((a) => a.kind === "text" && !a.grid) ?? [];
22
+ if (!e.richParagraphs?.length && !o.length) return;
23
+ const n = w(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
24
+ for (const a of o) {
25
+ const r = w(n, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
26
+ `) ?? a.text ?? "" }] }];
27
+ for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: w(r, c.style) })) });
28
+ }
29
+ return F(i, n);
30
+ }
31
+ function D(e, t, o) {
32
+ let n = o * 72 / 25.4;
12
33
  if (!Number.isFinite(n) || t + Math.ceil(n / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
13
34
  for (; n > 0; ) {
14
35
  if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
15
- const o = Math.min(409, n);
16
- e.getRow(t++).height = o, n -= o;
36
+ const i = Math.min(409, n);
37
+ e.getRow(t++).height = i, n -= i;
17
38
  }
18
39
  return t;
19
40
  }
20
- function _(e, t, r) {
21
- let n = Math.round(t * 36e3), o = 0;
41
+ function U(e, t, o) {
42
+ let n = Math.round(t * 36e3), i = 0;
22
43
  if (!Number.isSafeInteger(n)) throw new Error("Excel 图片锚点超出安全坐标范围");
23
- for (e.properties.defaultColWidth ??= 8.43; o < 16384; ) {
24
- const a = e.getColumn(o + 1).width ?? e.properties.defaultColWidth, i = Math.round(N(a) * 36e3);
25
- if (!Number.isSafeInteger(i) || i <= 0) throw new Error("Excel 图片锚点所在列宽无效");
26
- if (n < i) return { col: o + n / i, row: r - 1, nativeCol: o, nativeColOff: n, nativeRow: r - 1, nativeRowOff: 0 };
27
- n -= i, o++;
44
+ for (e.properties.defaultColWidth ??= 8.43; i < 16384; ) {
45
+ const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, r = Math.round(O(a) * 36e3);
46
+ if (!Number.isSafeInteger(r) || r <= 0) throw new Error("Excel 图片锚点所在列宽无效");
47
+ if (n < r) return { col: i + n / r, row: o - 1, nativeCol: i, nativeColOff: n, nativeRow: o - 1, nativeRowOff: 0 };
48
+ n -= r, i++;
28
49
  }
29
50
  throw new Error("Excel 图片锚点超过16384列上限");
30
51
  }
31
- function D(e, t, r) {
32
- let n = r * 72 / 25.4;
52
+ function K(e, t, o) {
53
+ let n = o * 72 / 25.4;
33
54
  if (!Number.isFinite(n) || Math.abs(n) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
34
- const o = (a) => {
35
- const i = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
36
- if (!Number.isFinite(i) || i <= 0) throw new Error("Excel 图片锚点所在行高无效");
37
- return i;
55
+ const i = (a) => {
56
+ const r = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
57
+ if (!Number.isFinite(r) || r <= 0) throw new Error("Excel 图片锚点所在行高无效");
58
+ return r;
38
59
  };
39
- for (; n < 0 && t > 1; ) n += o(--t);
40
- for (; t <= 1048576 && n >= o(t); ) n -= o(t++);
60
+ for (; n < 0 && t > 1; ) n += i(--t);
61
+ for (; t <= 1048576 && n >= i(t); ) n -= i(t++);
41
62
  if (t > 1048576 || n < 0) throw new Error("Excel 图片移动到工作表边界之外");
42
63
  return { nativeRow: t - 1, nativeRowOff: Math.round(n * 25.4 / 72 * 36e3) };
43
64
  }
44
- function U(e, t, r) {
45
- const n = j(t), o = /* @__PURE__ */ new Map();
46
- return { write(a, i, l, s) {
47
- if (![i.widthMm, i.heightMm, i.leftMm].every(Number.isFinite) || i.widthMm < 0 || i.heightMm < 0 || i.leftMm < 0) throw new Error("Excel 图片尺寸无效");
48
- if (!i.widthMm || !i.heightMm) return l;
49
- if (!i.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(i.imageData))
50
- return r.push(`${i.nid ?? i.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), l;
51
- const c = n(i.imageData);
52
- let d = o.get(c.dataUrl);
53
- d === void 0 && (d = e.addImage({ base64: c.dataUrl, extension: c.extension }), o.set(c.dataUrl, d));
54
- const h = s ? l : H(a, l, i.heightMm);
55
- return a.addImage(d, {
56
- tl: { ..._(a, s?.leftMm ?? i.leftMm, l), ...s ? D(a, l, s.offsetMm) : {} },
57
- ext: { width: i.widthMm * 96 / 25.4, height: i.heightMm * 96 / 25.4 },
65
+ function X(e, t, o) {
66
+ const n = G(t), i = /* @__PURE__ */ new Map();
67
+ return { write(a, r, s, l) {
68
+ if (![r.widthMm, r.heightMm, r.leftMm].every(Number.isFinite) || r.widthMm < 0 || r.heightMm < 0 || r.leftMm < 0) throw new Error("Excel 图片尺寸无效");
69
+ if (!r.widthMm || !r.heightMm) return s;
70
+ if (!r.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(r.imageData))
71
+ return o.push(`${r.nid ?? r.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
72
+ const c = n(r.imageData);
73
+ let h = i.get(c.dataUrl);
74
+ h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), i.set(c.dataUrl, h));
75
+ const f = l ? s : D(a, s, r.heightMm);
76
+ return a.addImage(h, {
77
+ tl: { ...U(a, l?.leftMm ?? r.leftMm, s), ...l ? K(a, s, l.offsetMm) : {} },
78
+ ext: { width: r.widthMm * 96 / 25.4, height: r.heightMm * 96 / 25.4 },
58
79
  editAs: "oneCell"
59
- }), h;
80
+ }), f;
60
81
  } };
61
82
  }
62
- function F(e) {
83
+ function R(e) {
63
84
  return !!e && typeof e == "object" && !Array.isArray(e);
64
85
  }
65
- function R(e, t) {
66
- const r = e.meta?.xlsxFlow;
67
- if (r === void 0) return;
68
- if (!F(r) || r.version !== "1.0" || !Number.isSafeInteger(r.columnStart) || Number(r.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
86
+ function T(e, t) {
87
+ const o = e.meta?.xlsxFlow;
88
+ if (o === void 0) return;
89
+ if (!R(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
69
90
  if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
70
- const n = r, o = e.grid.colWidthsMm;
71
- if (!o?.length || n.columnStart + o.length > t.length || o.some((a, i) => Math.abs(a - t[n.columnStart + i]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
91
+ const n = o, i = e.grid.colWidthsMm;
92
+ if (!i?.length || n.columnStart + i.length > t.length || i.some((a, r) => Math.abs(a - t[n.columnStart + r]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
72
93
  return n;
73
94
  }
74
95
  function W(e) {
@@ -77,110 +98,110 @@ function W(e) {
77
98
  if (e.components.some((n) => n.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
78
99
  return;
79
100
  }
80
- const r = K(t, e.meta?.reportScope);
101
+ const o = J(t, e.meta?.reportScope);
81
102
  for (const n of e.components) {
82
- const o = R(n, r.widths);
83
- if (!o) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
84
- const a = r.widths.slice(0, o.columnStart).reduce((l, s) => l + s, e.marginLeftMm ?? 0), i = n.grid.colWidthsMm.reduce((l, s) => l + s, 0);
85
- if (Math.abs(a - n.leftMm) > 0.01 || Math.abs(i - n.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
103
+ const i = T(n, o.widths);
104
+ if (!i) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
105
+ const a = o.widths.slice(0, i.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0), r = n.grid.colWidthsMm.reduce((s, l) => s + l, 0);
106
+ if (Math.abs(a - n.leftMm) > 0.01 || Math.abs(r - n.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
86
107
  }
87
- return r;
108
+ return o;
88
109
  }
89
- function K(e, t) {
90
- if (!F(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
91
- 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 多区域完整列宽无效");
110
+ function J(e, t) {
111
+ if (!R(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
112
+ if (!Array.isArray(e.fullWidthsMm) || !e.fullWidthsMm.length || e.fullWidthsMm.length > 16384 || e.fullWidthsMm.some((o) => typeof o != "number" || !Number.isFinite(o) || o <= 0 || o > 2e3)) throw new Error("Excel 多区域完整列宽无效");
92
113
  if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
93
114
  return { key: JSON.stringify([t ?? e.templateId, e.sheet]), sheet: e.sheet, widths: e.fullWidthsMm };
94
115
  }
95
- function b(e) {
116
+ function y(e) {
96
117
  return Math.round(e * 1e6) / 1e6;
97
118
  }
98
- function X(e, t, r, n, o) {
99
- return e.components.filter((a) => n ? a.pageAnchor === "header" ? t === 0 : a.pageAnchor === "footer" ? t === r - 1 : a.table?.role !== "header" ? !0 : o.has(a.table.id) ? !1 : (o.add(a.table.id), !0) : !0);
119
+ function V(e, t, o, n, i) {
120
+ return e.components.filter((a) => n ? a.pageAnchor === "header" ? t === 0 : a.pageAnchor === "footer" ? t === o - 1 : a.table?.role !== "header" ? !0 : i.has(a.table.id) ? !1 : (i.add(a.table.id), !0) : !0);
100
121
  }
101
- function J(e, t, r, n) {
102
- const o = e.components.filter((i) => !t.includes(i) && i.table?.role === "header"), a = t.filter((i) => !i.pageAnchor).reduce((i, l) => Math.max(i, l.topMm + l.heightMm), e.marginTopMm ?? 0);
103
- return t.map((i) => {
104
- let l = i.topMm;
105
- return r && i.pageAnchor === "footer" && (l = a), l -= o.filter((s) => s.topMm + s.heightMm <= l + 1e-3).reduce((s, c) => s + c.heightMm, 0), { component: i, layout: $(i.grid, i.widthMm, i.heightMm), top: l, column: R(i, n).columnStart };
122
+ function q(e, t, o, n) {
123
+ const i = e.components.filter((r) => !t.includes(r) && r.table?.role === "header"), a = t.filter((r) => !r.pageAnchor).reduce((r, s) => Math.max(r, s.topMm + s.heightMm), e.marginTopMm ?? 0);
124
+ return t.map((r) => {
125
+ let s = r.topMm;
126
+ return o && r.pageAnchor === "footer" && (s = a), s -= i.filter((l) => l.topMm + l.heightMm <= s + 1e-3).reduce((l, c) => l + c.heightMm, 0), { component: r, layout: A(r.grid, r.widthMm, r.heightMm), top: s, column: T(r, n).columnStart };
106
127
  });
107
128
  }
108
- function V(e, t, r) {
129
+ function Q(e, t, o) {
109
130
  const n = t.length - 1;
110
- if (n * r.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
111
- const o = new Map(t.map((l, s) => [l, s])), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
112
- for (const l of e) for (const s of l.layout.cells) {
113
- if (!Object.keys(s.cell).length) continue;
114
- const c = o.get(b(l.top + s.yMm)), d = o.get(b(l.top + s.yMm + s.heightMm)), h = l.column + s.ci, f = h + (s.cell.colSpan ?? 1), u = `${c}:${h}`;
115
- for (let g = c; g < d; g++) for (let w = h; w < f; w++) {
116
- const x = `${g}:${w}`;
117
- if (i.has(x)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
118
- i.set(x, u);
131
+ if (n * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
132
+ const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
133
+ for (const s of e) for (const l of s.layout.cells) {
134
+ if (!Object.keys(l.cell).length) continue;
135
+ const c = i.get(y(s.top + l.yMm)), h = i.get(y(s.top + l.yMm + l.heightMm)), f = s.column + l.ci, d = f + (l.cell.colSpan ?? 1), u = `${c}:${f}`;
136
+ for (let g = c; g < h; g++) for (let m = f; m < d; m++) {
137
+ const M = `${g}:${m}`;
138
+ if (r.has(M)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
139
+ r.set(M, u);
119
140
  }
120
- a.set(u, { ...s.cell, style: y(l.component.style, s.cell.style), rowSpan: d - c, colSpan: f - h });
141
+ a.set(u, { ...l.cell, style: w(s.component.style, l.cell.style), rowSpan: h - c, colSpan: d - f });
121
142
  }
122
- return Array.from({ length: n }, (l, s) => {
143
+ return Array.from({ length: n }, (s, l) => {
123
144
  const c = [];
124
- for (let d = 0; d < r.length; d++) {
125
- const h = `${s}:${d}`, f = a.get(h);
126
- f ? (c.push(f), d += (f.colSpan ?? 1) - 1) : i.has(h) || c.push(null);
145
+ for (let h = 0; h < o.length; h++) {
146
+ const f = `${l}:${h}`, d = a.get(f);
147
+ d ? (c.push(d), h += (d.colSpan ?? 1) - 1) : r.has(f) || c.push(null);
127
148
  }
128
149
  return c;
129
150
  });
130
151
  }
131
- function q(e, t) {
132
- const r = /* @__PURE__ */ new Set(), n = [];
133
- let o;
134
- for (const [a, { page: i }] of e.entries()) {
135
- const l = W(i);
136
- if (o && (l.key !== o.key || l.widths.length !== o.widths.length || l.widths.some((u, g) => Math.abs(u - o.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
137
- o ??= l;
138
- const s = X(i, a, e.length, t, r), c = J(i, s, t, l.widths);
152
+ function Y(e, t) {
153
+ const o = /* @__PURE__ */ new Set(), n = [];
154
+ let i;
155
+ for (const [a, { page: r }] of e.entries()) {
156
+ const s = W(r);
157
+ if (i && (s.key !== i.key || s.widths.length !== i.widths.length || s.widths.some((u, g) => Math.abs(u - i.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
158
+ i ??= s;
159
+ const l = V(r, a, e.length, t, o), c = q(r, l, t, s.widths);
139
160
  if (!c.length) continue;
140
- const d = [...new Set(c.flatMap((u) => [...u.layout.rows.map((g) => b(u.top + g.pos)), b(u.top + u.component.heightMm)]))].sort((u, g) => u - g), h = V(c, d, l.widths), f = d.slice(1).map((u, g) => u - d[g]);
141
- n.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: l.widths.reduce((u, g) => u + g, 0), heightMm: f.reduce((u, g) => u + g, 0), grid: { cells: h, colWidthsMm: l.widths, rowHeightsMm: f } });
161
+ const h = [...new Set(c.flatMap((u) => [...u.layout.rows.map((g) => y(u.top + g.pos)), y(u.top + u.component.heightMm)]))].sort((u, g) => u - g), f = Q(c, h, s.widths), d = h.slice(1).map((u, g) => u - h[g]);
162
+ n.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((u, g) => u + g, 0), heightMm: d.reduce((u, g) => u + g, 0), grid: { cells: f, colWidthsMm: s.widths, rowHeightsMm: d } });
142
163
  }
143
164
  return n;
144
165
  }
145
- const I = 72 / 25.4, Q = 32767, Y = 253;
166
+ const I = 72 / 25.4, Z = 32767, ee = 253;
146
167
  function p(e, t) {
147
168
  if (typeof e != "string") return;
148
- if (e.length > Q)
169
+ if (e.length > Z)
149
170
  throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
150
- let r = 0;
171
+ let o = 0;
151
172
  for (let n = 0; n < e.length; n++)
152
- if (e.charCodeAt(n) === 10 && ++r > Y)
173
+ if (e.charCodeAt(n) === 10 && ++o > ee)
153
174
  throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
154
175
  }
155
- function m(e) {
176
+ function x(e) {
156
177
  if (!e) return;
157
178
  const t = e.replace("#", "");
158
179
  return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
159
180
  }
160
- function T(e, t = {}) {
181
+ function P(e, t = {}) {
161
182
  e.font = {
162
183
  name: t.fontFamily,
163
184
  bold: t.bold === !0,
164
185
  italic: t.italic === !0,
165
186
  underline: t.underline === !0,
166
- size: A(t).fontSizePt,
167
- color: m(t.color) ? { argb: m(t.color) } : void 0
187
+ size: k(t).fontSizePt,
188
+ color: x(t.color) ? { argb: x(t.color) } : void 0
168
189
  };
169
190
  }
170
- const E = {
191
+ const b = {
171
192
  a3: { width: 297, height: 420, code: 8 },
172
193
  a4: { width: 210, height: 297, code: 9 },
173
194
  a5: { width: 148, height: 210, code: 11 }
174
195
  };
175
- function Z(e, t, r, n) {
176
- if (t && t !== "auto") return E[t].code;
177
- const o = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), i = Object.values(E).find((l) => Math.abs(o - l.width) <= 1 && Math.abs(a - l.height) <= 1);
178
- return i ? i.code : (n.push(`page ${r + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), E.a4.code);
179
- }
180
- function ee(e, t, r, n) {
181
- const o = typeof t.text == "string" ? t.text : "";
182
- if (r !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
183
- p(o, e.address), e.value = o;
196
+ function te(e, t, o, n) {
197
+ if (t && t !== "auto") return b[t].code;
198
+ const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), r = Object.values(b).find((s) => Math.abs(i - s.width) <= 1 && Math.abs(a - s.height) <= 1);
199
+ return r ? r.code : (n.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
200
+ }
201
+ function ne(e, t, o, n) {
202
+ const i = typeof t.text == "string" ? t.text : "";
203
+ if (o !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
204
+ p(i, e.address), e.value = i;
184
205
  return;
185
206
  }
186
207
  const a = t.value;
@@ -188,243 +209,240 @@ function ee(e, t, r, n) {
188
209
  p(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
189
210
  return;
190
211
  }
191
- p(o, e.address), e.value = o, n.push(`原始单元格值无效,已保留显示文本:${e.address}`);
212
+ p(i, e.address), e.value = i, n.push(`原始单元格值无效,已保留显示文本:${e.address}`);
192
213
  }
193
- function te(e) {
214
+ function ie(e) {
194
215
  const t = W(e);
195
- return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : ne(e);
216
+ return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : re(e);
196
217
  }
197
- function ne(e) {
198
- const r = e.components.filter((n) => n.table !== void 0)[0]?.table;
199
- if (!(!r || typeof r.id != "string" || !r.id.trim() || !Array.isArray(r.columnKeys) || !r.columnKeys.length)) {
218
+ function re(e) {
219
+ const o = e.components.filter((n) => n.table !== void 0)[0]?.table;
220
+ if (!(!o || typeof o.id != "string" || !o.id.trim() || !Array.isArray(o.columnKeys) || !o.columnKeys.length)) {
200
221
  for (const n of e.components) {
201
222
  if (n.table) {
202
- if (!n.grid || n.table.id !== r.id) return;
223
+ if (!n.grid || n.table.id !== o.id) return;
203
224
  continue;
204
225
  }
205
- if (n.grid || n.kind !== "text" && !k(n)) return;
226
+ if (n.grid || n.kind !== "text" && !S(n)) return;
206
227
  }
207
- return { id: r.id, title: r.title, wide: r.layout === "wide" || e.layout === "wide" };
228
+ return { id: o.id, title: o.title, wide: o.layout === "wide" || e.layout === "wide" };
208
229
  }
209
230
  }
210
- function ie(e, t) {
211
- const r = /* @__PURE__ */ new Set();
212
- for (const [n, o] of e.pages.entries())
231
+ function oe(e, t) {
232
+ const o = /* @__PURE__ */ new Set();
233
+ for (const [n, i] of e.pages.entries())
213
234
  if (!t[n])
214
- for (const a of o.components)
215
- typeof a.table?.id == "string" && r.add(a.table.id);
216
- return r;
235
+ for (const a of i.components)
236
+ typeof a.table?.id == "string" && o.add(a.table.id);
237
+ return o;
217
238
  }
218
- function S(e) {
239
+ function v(e) {
219
240
  return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
220
241
  }
221
- function re(e, t, r) {
222
- const n = [], o = e.pages.map(te), a = ie(e, o);
223
- for (const [i, l] of e.pages.entries()) {
224
- const s = o[i], c = s && !a.has(s.id), d = t === "pages" || !c ? void 0 : s;
225
- if (t === "continuous" && !d)
226
- throw new Error(`page ${i + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
227
- const h = d !== void 0 && (t === "continuous" || d.wide);
228
- !h && t !== "pages" && S(l) && r.push(`page ${i + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
229
- const f = n[n.length - 1];
230
- h && f?.continuous && f.tableId === d.id ? f.pages.push({ page: l, index: i }) : n.push({ pages: [{ page: l, index: i }], continuous: h, ...h ? { tableId: d.id, title: d.title } : {}, ...s?.flow ? { flow: !0, title: s.title } : {} });
242
+ function ae(e, t, o) {
243
+ const n = [], i = e.pages.map(ie), a = oe(e, i);
244
+ for (const [r, s] of e.pages.entries()) {
245
+ const l = i[r], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
246
+ if (t === "continuous" && !h)
247
+ throw new Error(`page ${r + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
248
+ const f = h !== void 0 && (t === "continuous" || h.wide);
249
+ !f && t !== "pages" && v(s) && o.push(`page ${r + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
250
+ const d = n[n.length - 1];
251
+ f && d?.continuous && d.tableId === h.id ? d.pages.push({ page: s, index: r }) : n.push({ pages: [{ page: s, index: r }], continuous: f, ...f ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
231
252
  }
232
253
  return n;
233
254
  }
234
- function v(e, t, r) {
235
- return !e || e.length === t.length && e.every((n, o) => r(n, t[o]));
255
+ function C(e, t, o) {
256
+ return !e || e.length === t.length && e.every((n, i) => o(n, t[i]));
236
257
  }
237
- function oe(e, t, r, n) {
238
- const o = e.table, a = t.columns.map((s) => s.size), i = v(n.keys, o.columnKeys, (s, c) => s === c), l = v(n.widths, a, (s, c) => Math.abs(s - c) <= 1e-3);
239
- if (o.columnKeys.length !== a.length || !i || !l)
240
- throw new Error(`page ${r + 1}: 连续 Excel 逻辑表 ${o.id} 的列结构或列宽不一致`);
241
- if (n.keys ??= o.columnKeys, n.widths ??= a, o.role === "header") {
242
- if (o.rowIndex !== -1) throw new Error(`page ${r + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
258
+ function se(e, t, o, n) {
259
+ const i = e.table, a = t.columns.map((l) => l.size), r = C(n.keys, i.columnKeys, (l, c) => l === c), s = C(n.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
260
+ if (i.columnKeys.length !== a.length || !r || !s)
261
+ throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
262
+ if (n.keys ??= i.columnKeys, n.widths ??= a, i.role === "header") {
263
+ if (i.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
243
264
  n.headerSeen = !0;
244
265
  } else {
245
- if (!["body", "group-header", "subtotal", "grand-total"].includes(o.role) || o.rowIndex !== n.expectedRow)
246
- throw new Error(`page ${r + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
266
+ if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== n.expectedRow)
267
+ throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
247
268
  n.expectedRow += t.rows.length;
248
269
  }
249
- if (t.cells.some((s) => s.cell.children?.length))
250
- throw new Error(`page ${r + 1}: 连续 Excel 暂不支持嵌套组件;请使用独立 Sheet 导出并检查告警`);
251
270
  }
252
- function ae(e, t) {
253
- const r = { expectedRow: 0, headerSeen: !1 };
254
- for (const { page: n, index: o } of e.pages)
271
+ function le(e, t) {
272
+ const o = { expectedRow: 0, headerSeen: !1 };
273
+ for (const { page: n, index: i } of e.pages)
255
274
  for (const a of n.components) {
256
- const i = t.get(a);
257
- a.table && i && oe(a, i, o, r);
275
+ const r = t.get(a);
276
+ a.table && r && se(a, r, i, o);
258
277
  }
259
- if (!r.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
278
+ if (!o.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
260
279
  }
261
- function le(e, t, r) {
280
+ function ce(e, t, o) {
262
281
  let n = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
263
282
  n.toLowerCase() === "history" && (n += " 报表");
264
- let o = n, a = 1;
265
- for (; r.has(o.toLowerCase()); ) {
266
- const i = ` (${++a})`;
267
- o = n.slice(0, 31 - i.length) + i;
283
+ let i = n, a = 1;
284
+ for (; o.has(i.toLowerCase()); ) {
285
+ const r = ` (${++a})`;
286
+ i = n.slice(0, 31 - r.length) + r;
268
287
  }
269
- return r.add(o.toLowerCase()), o;
288
+ return o.add(i.toLowerCase()), i;
270
289
  }
271
- function se(e) {
290
+ function he(e) {
272
291
  const t = /* @__PURE__ */ new Set();
273
- function r(n, o, a, i) {
274
- return n <= o ? n : (t.has(a) || (e.push(i), t.add(a)), o);
292
+ function o(n, i, a, r) {
293
+ return n <= i ? n : (t.has(a) || (e.push(r), t.add(a)), i);
275
294
  }
276
295
  return {
277
- column: (n) => r(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
278
- row: (n) => r(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
296
+ column: (n) => o(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
297
+ row: (n) => o(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
279
298
  };
280
299
  }
281
- async function ce(e, t) {
282
- const r = e.flow ? q(e.pages, e.continuous).map((i) => ({ comp: i, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: i, index: l }, s) => i.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || s === 0) && (c.pageAnchor !== "footer" || s === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: l }))), n = /* @__PURE__ */ new Map();
283
- let o = 1, a = 0;
284
- for (const { comp: i } of r)
285
- if (i.grid) {
286
- const l = $(i.grid, i.widthMm, i.heightMm);
287
- n.set(i, l), o = Math.max(o, l.columns.length);
288
- const s = t(l.cells.length);
289
- s && await s;
290
- } else i.kind === "text" && (a = Math.max(a, i.widthMm));
291
- if (o > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
292
- return { components: r, grids: n, columnCount: o, textWidthMm: a };
293
- }
294
- function de(e, t, r) {
295
- const { page: n, index: o } = e.pages[0], a = t !== void 0 && t !== "auto";
296
- return (e.continuous || S(n)) && !a ? {} : { pageSetup: {
297
- paperSize: Z(n, t, o, r),
300
+ async function de(e, t) {
301
+ const o = e.flow ? Y(e.pages, e.continuous).map((r) => ({ comp: r, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: r, index: s }, l) => r.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || l === 0) && (c.pageAnchor !== "footer" || l === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: s }))), n = /* @__PURE__ */ new Map();
302
+ let i = 1, a = 0;
303
+ for (const { comp: r } of o)
304
+ if (r.grid) {
305
+ const s = A(r.grid, r.widthMm, r.heightMm);
306
+ n.set(r, s), i = Math.max(i, s.columns.length);
307
+ const l = t(s.cells.length);
308
+ l && await l;
309
+ } else r.kind === "text" && (a = Math.max(a, r.widthMm));
310
+ if (i > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
311
+ return { components: o, grids: n, columnCount: i, textWidthMm: a };
312
+ }
313
+ function fe(e, t, o) {
314
+ const { page: n, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
315
+ return (e.continuous || v(n)) && !a ? {} : { pageSetup: {
316
+ paperSize: te(n, t, i, o),
298
317
  orientation: n.pageWidthMm > n.pageHeightMm ? "landscape" : "portrait",
299
318
  fitToPage: !0,
300
319
  ...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
301
320
  } };
302
321
  }
303
- function he(e) {
304
- const t = m(e.borderColor ?? e.lineColor), r = { style: "thin", ...t ? { color: { argb: t } } : {} };
322
+ function ue(e) {
323
+ const t = x(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
305
324
  return {
306
- ...e.borderTop !== !1 ? { top: r } : {},
307
- ...e.borderLeft !== !1 ? { left: r } : {},
308
- ...e.borderBottom !== !1 ? { bottom: r } : {},
309
- ...e.borderRight !== !1 ? { right: r } : {}
325
+ ...e.borderTop !== !1 ? { top: o } : {},
326
+ ...e.borderLeft !== !1 ? { left: o } : {},
327
+ ...e.borderBottom !== !1 ? { bottom: o } : {},
328
+ ...e.borderRight !== !1 ? { right: o } : {}
310
329
  };
311
330
  }
312
- function fe(e, t) {
331
+ function ge(e, t) {
313
332
  e.alignment = { horizontal: t.align ?? "left", vertical: t.verticalAlign ?? "middle", wrapText: !0 };
314
- const r = m(t.backgroundColor);
315
- r && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: r } }), e.border = he(t), T(e, t);
333
+ const o = x(t.backgroundColor);
334
+ o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = ue(t), P(e, t);
316
335
  }
317
- function ue(e, t) {
318
- for (const [r, n] of t.columns.entries()) {
319
- const o = e.sheet.getColumn(r + 1), a = e.limits.column(C(n.size));
320
- (o.width == null || o.width < a) && (o.width = a);
336
+ function me(e, t) {
337
+ for (const [o, n] of t.columns.entries()) {
338
+ const i = e.sheet.getColumn(o + 1), a = e.limits.column($(n.size));
339
+ (i.width == null || i.width < a) && (i.width = a);
321
340
  }
322
341
  }
323
- function ge(e, t, r) {
324
- for (const [n, o] of t.rows.entries()) {
325
- const a = e.sheet.getRow(r + n), i = e.limits.row(o.size * I);
326
- (a.height == null || a.height < i) && (a.height = i);
342
+ function we(e, t, o) {
343
+ for (const [n, i] of t.rows.entries()) {
344
+ const a = e.sheet.getRow(o + n), r = e.limits.row(i.size * I);
345
+ (a.height == null || a.height < r) && (a.height = r);
327
346
  }
328
347
  }
329
- function me(e, t, r, n) {
330
- const o = Math.max(1, Math.min(t.cell.colSpan ?? 1, r.columns.length - t.ci)), a = Math.max(1, Math.min(t.cell.rowSpan ?? 1, r.rows.length - t.ri));
331
- (o > 1 || a > 1) && e.mergeCells(n + t.ri, t.ci + 1, n + t.ri + a - 1, t.ci + o);
332
- }
333
- async function we(e, t, r, n, o) {
334
- if (n + r.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
335
- ge(e, r, n);
336
- for (const a of r.cells) {
337
- const i = e.sheet.getCell(n + a.ri, a.ci + 1);
338
- ee(i, a.cell, e.valueMode, e.warnings), a.cell.children?.length && e.warnings.push(`page ${o + 1} ${t.nid ?? t.kind} cell ${a.ri + 1}:${a.ci + 1}: 嵌套组件内容暂不支持 xlsx 导出,已跳过`), fe(i, y(t.style, a.cell.style)), a.cell.indentMm && (i.alignment = { ...i.alignment, indent: Math.min(250, Math.max(1, Math.round(a.cell.indentMm / 2.5))) }), me(e.sheet, a, r, n);
348
+ function pe(e, t, o, n) {
349
+ const i = Math.max(1, Math.min(t.cell.colSpan ?? 1, o.columns.length - t.ci)), a = Math.max(1, Math.min(t.cell.rowSpan ?? 1, o.rows.length - t.ri));
350
+ (i > 1 || a > 1) && e.mergeCells(n + t.ri, t.ci + 1, n + t.ri + a - 1, t.ci + i);
351
+ }
352
+ async function xe(e, t, o, n) {
353
+ if (n + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
354
+ we(e, o, n);
355
+ for (const i of o.cells) {
356
+ const a = e.sheet.getCell(n + i.ri, i.ci + 1);
357
+ ne(a, i.cell, e.valueMode, e.warnings);
358
+ const r = _(i.cell, t.style);
359
+ r && (p(r.richText.map((c) => c.text).join(""), a.address), a.value = r);
360
+ const s = t.grid?.paddingMm ?? 0.5;
361
+ for (const c of i.cell.children ?? [])
362
+ S(c) && !c.grid && e.images.write(e.sheet, c, n + i.ri, { leftMm: i.xMm + s + (i.cell.indentMm ?? 0) + c.leftMm, offsetMm: s + c.topMm });
363
+ ge(a, w(t.style, i.cell.style)), i.cell.indentMm && (a.alignment = { ...a.alignment, indent: Math.min(250, Math.max(1, Math.round(i.cell.indentMm / 2.5))) }), pe(e.sheet, i, o, n);
339
364
  const l = e.schedule();
340
365
  l && await l;
341
366
  }
342
- return n + r.rows.length;
367
+ return n + o.rows.length;
343
368
  }
344
- function pe(e, t, r, n) {
345
- const o = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
346
- `) : t.text ?? "", a = e.sheet.getRow(r), i = a.getCell(1);
347
- t.richParagraphs?.length || p(o, i.address), i.value = t.richParagraphs?.length ? { richText: t.richParagraphs.flatMap((s, c) => [
348
- ...c ? [{ text: `
349
- ` }] : [],
350
- ...s.segments.map((d) => {
351
- const h = y(t.style, d.style);
352
- return { text: d.kind === "field" ? d.field ?? "" : d.text ?? "", font: { name: h.fontFamily, bold: h.bold, italic: h.italic, underline: h.underline, size: A(h).fontSizePt, ...m(h.color) ? { color: { argb: m(h.color) } } : {} } };
353
- })
354
- ]) } : o, typeof i.value == "object" && i.value && "richText" in i.value && p(i.value.richText.map((s) => s.text).join(""), i.address), i.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
355
- const l = m(t.style?.backgroundColor);
356
- return l && (i.fill = { type: "pattern", pattern: "solid", fgColor: { argb: l } }), T(i, t.style), n > 1 && e.sheet.mergeCells(r, 1, r, n), a.height = e.limits.row(t.heightMm * I), r + 1;
369
+ function Me(e, t, o, n) {
370
+ const i = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
371
+ `) : t.text ?? "", a = e.sheet.getRow(o), r = a.getCell(1);
372
+ t.richParagraphs?.length || p(i, r.address), r.value = t.richParagraphs?.length ? F(t.richParagraphs, t.style) : i, typeof r.value == "object" && r.value && "richText" in r.value && p(r.value.richText.map((l) => l.text).join(""), r.address), r.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
373
+ const s = x(t.style?.backgroundColor);
374
+ return s && (r.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), P(r, t.style), n > 1 && e.sheet.mergeCells(o, 1, o, n), a.height = e.limits.row(t.heightMm * I), o + 1;
357
375
  }
358
- function xe(e, t, r) {
359
- const n = t + r - 1;
376
+ function Ee(e, t, o) {
377
+ const n = t + o - 1;
360
378
  e.views = [{ state: "frozen", ySplit: n, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${n}`;
361
379
  }
362
- async function Me(e, t, r, n) {
363
- !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(C(t.textWidthMm)));
364
- for (const i of t.grids.values()) {
365
- ue(e, i);
366
- const l = e.schedule(i.columns.length);
367
- l && await l;
380
+ async function be(e, t, o, n) {
381
+ !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column($(t.textWidthMm)));
382
+ for (const r of t.grids.values()) {
383
+ me(e, r);
384
+ const s = e.schedule(r.columns.length);
385
+ s && await s;
368
386
  }
369
- let o = 1, a = !1;
370
- for (const { comp: i, pageIndex: l } of t.components) {
371
- const s = r && i.table?.role === "header";
372
- if (s && a) continue;
373
- if (o > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
374
- const c = t.grids.get(i);
387
+ let i = 1, a = !1;
388
+ for (const { comp: r, pageIndex: s } of t.components) {
389
+ const l = o && r.table?.role === "header";
390
+ if (l && a) continue;
391
+ if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
392
+ const c = t.grids.get(r);
375
393
  if (c)
376
- s && (xe(e.sheet, o, c.rows.length), a = !0), o = await we(e, i, c, o, l);
377
- else if (i.kind === "text")
378
- o = pe(e, i, o, t.columnCount);
379
- else if (k(i)) {
380
- const d = L(i, r), h = n.write(e.sheet, i, d?.row ?? o, d);
381
- d || (o = h);
394
+ l && (Ee(e.sheet, i, c.rows.length), a = !0), i = await xe(e, r, c, i);
395
+ else if (r.kind === "text")
396
+ i = Me(e, r, i, t.columnCount);
397
+ else if (S(r)) {
398
+ const h = j(r, o), f = n.write(e.sheet, r, h?.row ?? i, h);
399
+ h || (i = f);
382
400
  } else
383
- e.warnings.push(`page ${l + 1} ${i.nid ?? i.kind}: 组件类型 ${i.kind} 暂不支持 xlsx 导出,已跳过`);
401
+ e.warnings.push(`page ${s + 1} ${r.nid ?? r.kind}: 组件类型 ${r.kind} 暂不支持 xlsx 导出,已跳过`);
384
402
  }
385
403
  }
386
- function Ee(e) {
404
+ function ye(e) {
387
405
  if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
388
406
  throw new Error("xlsx valueMode 必须是 text 或 raw");
389
- if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(E, e.paperSize))
407
+ if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(b, e.paperSize))
390
408
  throw new Error("xlsx paperSize 必须是 auto、a3、a4 或 a5");
391
409
  if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
392
410
  throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
393
411
  }
394
- async function Ae(e, t = {}) {
395
- Ee(t), M(t.signal);
396
- const r = G(e, "xlsx", t), n = new O.Workbook(), o = [], a = U(n, t, o), i = se(o), l = re(e, t.sheetMode, o), s = /* @__PURE__ */ new Set(), c = B(t);
397
- for (const [h, f] of l.entries()) {
398
- const u = await ce(f, c);
399
- f.continuous && !f.flow && ae(f, u.grids);
400
- const g = f.pages[0].page, w = t.sheetName?.(h) ?? le(f.title, h, s);
401
- s.add(w.toLowerCase());
402
- const x = n.addWorksheet(w, de(f, t.paperSize, o)), z = t.valueMode ?? (S(g) || f.continuous || f.flow ? "raw" : "text");
403
- M(t.signal), await Me({ sheet: x, warnings: o, limits: i, valueMode: z, schedule: c }, u, f.continuous, a), await P(t, h + 1, l.length);
412
+ async function Re(e, t = {}) {
413
+ ye(t), E(t.signal);
414
+ const o = H(e, "xlsx", t), n = new L.Workbook(), i = [], a = X(n, t, i), r = he(i), s = ae(e, t.sheetMode, i), l = /* @__PURE__ */ new Set(), c = N(t);
415
+ for (const [f, d] of s.entries()) {
416
+ const u = await de(d, c);
417
+ d.continuous && !d.flow && le(d, u.grids);
418
+ const g = d.pages[0].page, m = t.sheetName?.(f) ?? ce(d.title, f, l);
419
+ l.add(m.toLowerCase());
420
+ const M = n.addWorksheet(m, fe(d, t.paperSize, i)), z = t.valueMode ?? (v(g) || d.continuous || d.flow ? "raw" : "text");
421
+ E(t.signal), await be({ sheet: M, warnings: i, limits: r, valueMode: z, schedule: c, images: a }, u, d.continuous, a), await B(t, f + 1, s.length);
404
422
  }
405
- M(t.signal);
406
- const d = await n.xlsx.writeBuffer();
407
- return M(t.signal), { workbook: n, buffer: d, warnings: o, diagnostics: r };
423
+ E(t.signal);
424
+ const h = await n.xlsx.writeBuffer();
425
+ return E(t.signal), { workbook: n, buffer: h, warnings: i, diagnostics: o };
408
426
  }
409
427
  export {
410
- Pe as bindExcelTemplate,
411
- Be as createExcelBindingDocument,
412
- Ne as createExcelBindingSession,
413
- Oe as createExcelRegionBindingDocument,
414
- Le as createExcelRegionBindingSession,
415
- je as excelBindingCellRange,
416
- Ge as excelBindingRowRange,
417
- He as getExcelSheetWindow,
418
- We as importExcelTemplate,
419
- Ie as inspectExcelWorkbook,
420
- Te as openExcelWorkbook,
421
- _e as parseExcelBindingSession,
422
- De as parseExcelRegionBindingSession,
423
- Ae as renderPlanToXlsx,
424
- Ue as validateExcelBindingFields,
425
- Ke as validateExcelBindingRecipe,
426
- Xe as validateExcelBindingRegions,
427
- Je as validateExcelRegionBindings,
428
- Ve as validateExcelRegionFields,
429
- qe as validateExcelRegionGeometry
428
+ Ne as bindExcelTemplate,
429
+ Oe as createExcelBindingDocument,
430
+ Le as createExcelBindingSession,
431
+ je as createExcelRegionBindingDocument,
432
+ Ge as createExcelRegionBindingSession,
433
+ He as excelBindingCellRange,
434
+ _e as excelBindingRowRange,
435
+ De as getExcelSheetWindow,
436
+ Ie as importExcelTemplate,
437
+ Pe as inspectExcelWorkbook,
438
+ ze as openExcelWorkbook,
439
+ Ue as parseExcelBindingSession,
440
+ Ke as parseExcelRegionBindingSession,
441
+ Re as renderPlanToXlsx,
442
+ Xe as validateExcelBindingFields,
443
+ Je as validateExcelBindingRecipe,
444
+ Ve as validateExcelBindingRegions,
445
+ qe as validateExcelRegionBindings,
446
+ Qe as validateExcelRegionFields,
447
+ Ye as validateExcelRegionGeometry
430
448
  };