@agile-team/mach-report 2.21.0 → 2.22.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 (110) hide show
  1. package/README.md +16 -2
  2. package/dist/{ExcelBindingWizard-B2xXBOJu.cjs → ExcelBindingWizard-CW79I6Gl.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-CixTPQAL.js → ExcelBindingWizard-CZyppD7I.js} +3 -3
  4. package/dist/{ParamEditor-DhHlNxai.cjs → ParamEditor-CiYCJI0b.cjs} +1 -1
  5. package/dist/{ParamEditor-gKhvEsnr.js → ParamEditor-DQit-Gdf.js} +2 -2
  6. package/dist/{ReportBatchPanel-D-lyWKyf.js → ReportBatchPanel-DKTpV7MU.js} +2 -2
  7. package/dist/{ReportBatchPanel-BUdUfTdm.cjs → ReportBatchPanel-Db6TAfG5.cjs} +1 -1
  8. package/dist/ReportLabelStudio-B0i9ohQj.cjs +1 -0
  9. package/dist/ReportLabelStudio-BYnRqmje.js +780 -0
  10. package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-BHSKVL8k.js} +231 -224
  11. package/dist/ReportParamPanel-lngONOEz.cjs +1 -0
  12. package/dist/ReportPreview-BDgKssYR.js +5887 -0
  13. package/dist/ReportPreview-Dw-4icG6.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-WZl-AK-2.js → ReportTemplateLibrary-BZuKn0YK.js} +1 -1
  15. package/dist/{ReportTemplateLibrary-Cs9WKneQ.cjs → ReportTemplateLibrary-DEXH07ND.cjs} +1 -1
  16. package/dist/{RuleEditor-DGpmjCko.js → RuleEditor-CIQn547x.js} +3 -3
  17. package/dist/{RuleEditor-Dtcq-7LO.cjs → RuleEditor-zSUmPjKa.cjs} +1 -1
  18. package/dist/{TemplateOutlinePanel-CkCh506f.cjs → TemplateOutlinePanel-B5SfGYVN.cjs} +1 -1
  19. package/dist/{TemplateOutlinePanel-cxp95OT9.js → TemplateOutlinePanel-D0PgOSQE.js} +2 -2
  20. package/dist/{TemplateReusePanel-BZ8VTtrO.js → TemplateReusePanel-BKlAEF8-.js} +2 -2
  21. package/dist/{TemplateReusePanel-CwttuSta.cjs → TemplateReusePanel-DAy_Hwqz.cjs} +1 -1
  22. package/dist/TemplateReviewPanel-CowmHaQQ.cjs +1 -0
  23. package/dist/{TemplateReviewPanel-C9cTvsRs.js → TemplateReviewPanel-div-EH_m.js} +2 -2
  24. package/dist/artifact-integrity.json +76 -76
  25. package/dist/{auto-Tq7ReIC1.cjs → auto-DcUHlKob.cjs} +1 -1
  26. package/dist/{auto-BkdGiNtr.js → auto-moShblh1.js} +4 -4
  27. package/dist/{designer-CIDHt5xz.js → designer-B7jJeAeG.js} +1500 -1455
  28. package/dist/{designer-CDqok4S5.cjs → designer-BWQVpJeN.cjs} +2 -2
  29. package/dist/designer.cjs +1 -1
  30. package/dist/designer.d.cts +149 -2
  31. package/dist/designer.d.ts +149 -2
  32. package/dist/designer.js +13 -12
  33. package/dist/{encoding-BSeUwrN7.js → encoding-DbnhbwI8.js} +2 -2
  34. package/dist/{encoding-B79hW4zq.cjs → encoding-ncQAvyOv.cjs} +1 -1
  35. package/dist/index.cjs +5 -5
  36. package/dist/index.d.cts +38 -0
  37. package/dist/index.d.ts +38 -0
  38. package/dist/index.js +299 -279
  39. package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-DvQbZlD7.js} +2 -2
  40. package/dist/{json-snapshot-I5VI84Vp.cjs → json-snapshot-nyV63AbB.cjs} +1 -1
  41. package/dist/{plugin-BaRUGORD.cjs → plugin-AcAQ2m9X.cjs} +1 -1
  42. package/dist/{plugin-D4kAxfLG.js → plugin-w5Nyt08U.js} +1 -1
  43. package/dist/{prefill-CJSazcVY.js → prefill-BXBxx5We.js} +1 -1
  44. package/dist/{prefill-Bpyn58AZ.cjs → prefill-DUvejVt1.cjs} +1 -1
  45. package/dist/prepared-YXy-fVLw.cjs +1 -0
  46. package/dist/{prepared-BwjwEzFz.js → prepared-rXCKqdHY.js} +35 -34
  47. package/dist/{protocol-C8VWF9An.cjs → protocol-C9ZaylID.cjs} +1 -1
  48. package/dist/{protocol-Bs9-ohHN.js → protocol-fjaeKkjf.js} +3 -3
  49. package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-BiJQ7NU6.cjs} +1 -1
  50. package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-aA8nxmkZ.js} +1 -1
  51. package/dist/report-encoding-worker.cjs +1 -1
  52. package/dist/report-encoding-worker.js +1 -1
  53. package/dist/{runtime-BDf5x1i1.js → runtime-BTtpjF3D.js} +4 -4
  54. package/dist/{runtime-DsJt1PIf.cjs → runtime-Dq0LUsyS.cjs} +1 -1
  55. package/dist/sbom.cdx.json +1 -1
  56. package/dist/server/node.d.cts +9 -0
  57. package/dist/server/node.d.ts +9 -0
  58. package/dist/server-node.cjs +5 -4
  59. package/dist/server-node.js +1838 -1760
  60. package/dist/server.cjs +1 -1
  61. package/dist/server.d.cts +81 -0
  62. package/dist/server.d.ts +81 -0
  63. package/dist/server.js +6 -6
  64. package/dist/style.css +1 -1
  65. package/dist/template-catalog-CLAM4w7H.cjs +1 -0
  66. package/dist/{template-catalog-DFwIS9aN.js → template-catalog-JSxSqk5y.js} +3 -3
  67. package/dist/template-fragments-Ca25Jt7e.cjs +1 -0
  68. package/dist/{template-fragments-Dng-AlHk.js → template-fragments-D2JFj7Du.js} +18 -18
  69. package/dist/{template-outline-DiADphlq.js → template-outline-CDWXptuj.js} +1 -1
  70. package/dist/template-outline-K4jGhATu.cjs +1 -0
  71. package/dist/template-registry-CWnuGqyP.cjs +1 -0
  72. package/dist/{template-registry-DhBqoD7W.js → template-registry-Do1Uav2Z.js} +333 -261
  73. package/dist/template-serialization-CU4n_Miu.js +307 -0
  74. package/dist/template-serialization-CgqBo6s-.cjs +1 -0
  75. package/dist/vue/async.d.cts +97 -2
  76. package/dist/vue/async.d.ts +97 -2
  77. package/dist/vue/index.d.cts +197 -4
  78. package/dist/vue/index.d.ts +197 -4
  79. package/dist/vue-async.cjs +1 -1
  80. package/dist/vue-async.js +3 -3
  81. package/dist/vue.cjs +1 -1
  82. package/dist/vue.js +75 -70
  83. package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-BvEBRRMz.cjs} +1 -1
  84. package/dist/{workbook-session-oinxX3qo.js → workbook-session-f0wVlzst.js} +1 -1
  85. package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
  86. package/dist/workbook-sheets-D4M7XXBh.js +44 -0
  87. package/dist/worker.cjs +1 -1
  88. package/dist/worker.d.cts +9 -0
  89. package/dist/worker.d.ts +9 -0
  90. package/dist/worker.js +4 -4
  91. package/dist/xlsx.cjs +4 -4
  92. package/dist/xlsx.d.cts +39 -2
  93. package/dist/xlsx.d.ts +39 -2
  94. package/dist/xlsx.js +290 -270
  95. package/package.json +1 -1
  96. package/dist/ReportLabelStudio-BcjQt73a.cjs +0 -1
  97. package/dist/ReportLabelStudio-N2w6DdaZ.js +0 -764
  98. package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
  99. package/dist/ReportPreview-BBJNlu2U.js +0 -5740
  100. package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
  101. package/dist/TemplateReviewPanel-C2YjiaEC.cjs +0 -1
  102. package/dist/prepared-BiSz_9vN.cjs +0 -1
  103. package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
  104. package/dist/template-bindings-TKnXM7ll.js +0 -62
  105. package/dist/template-catalog-D_2jdnkL.cjs +0 -1
  106. package/dist/template-fragments-DZVUBhuB.cjs +0 -1
  107. package/dist/template-outline-DWkzZXVC.cjs +0 -1
  108. package/dist/template-registry-DpLUSLwF.cjs +0 -1
  109. package/dist/template-serialization-Cc3h-miv.js +0 -247
  110. package/dist/template-serialization-D1R5oAqh.cjs +0 -1
package/dist/xlsx.js CHANGED
@@ -1,110 +1,111 @@
1
- import { c as B, b as E, o as L } from "./progress-Hc2vxoCs.js";
2
- import { e as j } from "./index-CPh6tqge.js";
3
- import { d as G } from "./data-bar-8baGYEZ9.js";
4
- import { g as w, a as $, r as A } from "./grid-geometry-D3SJgWFv.js";
5
- import { e as H, E as _, m as F, i as U } from "./workbook-session-oinxX3qo.js";
6
- import { a as He, b as _e, o as Ue } from "./workbook-session-oinxX3qo.js";
7
- import { i as S } from "./component-tree-1_QCiQJX.js";
8
- import { c as X } from "./media-Y90dHK9z.js";
9
- import { a as K, r as J } from "./assets-CxHunY_9.js";
10
- import { b as Ke, c as Je, a as Ve, d as qe, e as Qe, f as Ye, g as Ze, h as et, p as tt, i as nt, v as rt, j as it, k as ot, l as at, m as st, n as lt } from "./region-binding-workflow-Cy4GIOUo.js";
11
- function V(e) {
12
- const t = j({ width: 1, height: 1, channels: 4, depth: 8, data: new Uint8Array([1, 3, 5].map((o) => parseInt(e.slice(o, o + 2), 16)).concat(89)) });
1
+ import { c as S, b as M, o as j } from "./progress-Hc2vxoCs.js";
2
+ import { e as G } from "./index-CPh6tqge.js";
3
+ import { d as H } from "./data-bar-8baGYEZ9.js";
4
+ import { g as p, a as A, r as W } from "./grid-geometry-D3SJgWFv.js";
5
+ import { e as _, E as U, m as T, i as X } from "./workbook-session-f0wVlzst.js";
6
+ import { a as Ve, b as qe, o as Qe } from "./workbook-session-f0wVlzst.js";
7
+ import { i as v } from "./component-tree-1_QCiQJX.js";
8
+ import { c as K } from "./media-Y90dHK9z.js";
9
+ import { a as J, r as V } from "./assets-CxHunY_9.js";
10
+ import { s as q, a as Q } from "./workbook-sheets-D4M7XXBh.js";
11
+ import { b as Ze, c as et, a as tt, d as nt, e as rt, f as it, g as ot, h as at, p as st, i as lt, v as ct, j as ht, k as dt, l as ft, m as gt, n as ut } from "./region-binding-workflow-aA8nxmkZ.js";
12
+ function Y(e) {
13
+ const t = G({ width: 1, height: 1, channels: 4, depth: 8, data: new Uint8Array([1, 3, 5].map((o) => parseInt(e.slice(o, o + 2), 16)).concat(89)) });
13
14
  return `data:image/png;base64,${btoa(String.fromCharCode(...t))}`;
14
15
  }
15
- function q(e, t, o) {
16
- const n = /* @__PURE__ */ new Map();
16
+ function Z(e, t, o) {
17
+ const r = /* @__PURE__ */ new Map();
17
18
  let i = 0;
18
- return (a, r, s, l) => {
19
- const c = G(r.cell.dataBar, r.widthMm, r.heightMm, l);
19
+ return (a, n, s, l) => {
20
+ const c = H(n.cell.dataBar, n.widthMm, n.heightMm, l);
20
21
  if (!c) return;
21
22
  if (++i > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
22
- let h = n.get(c.color);
23
- h || (h = V(c.color), n.set(c.color, h)), i === 1 && o.push("数据条为静态半透明视觉快照,保留原始单元格值;Excel 编辑不会重算条形,绘图叠加文字的混色与预览可能略有差异。"), e.write(a, { kind: "image", leftMm: 0, topMm: 0, widthMm: c.width, heightMm: c.height, imageData: h }, s, { leftMm: r.xMm + c.x, offsetMm: c.y });
23
+ let h = r.get(c.color);
24
+ h || (h = Y(c.color), r.set(c.color, h)), i === 1 && o.push("数据条为静态半透明视觉快照,保留原始单元格值;Excel 编辑不会重算条形,绘图叠加文字的混色与预览可能略有差异。"), e.write(a, { kind: "image", leftMm: 0, topMm: 0, widthMm: c.width, heightMm: c.height, imageData: h }, s, { leftMm: n.xMm + c.x, offsetMm: c.y });
24
25
  };
25
26
  }
26
- async function Q(e, t, o) {
27
- const n = e.pages.flatMap((r) => r.components), i = B(o);
27
+ async function ee(e, t, o) {
28
+ const r = e.pages.flatMap((n) => n.components), i = S(o);
28
29
  let a = 0;
29
- for (; n.length; ) {
30
- const r = n.pop();
31
- for (const s of r.grid?.cells ?? []) for (const l of s) {
30
+ for (; r.length; ) {
31
+ const n = r.pop();
32
+ for (const s of n.grid?.cells ?? []) for (const l of s) {
32
33
  if (l?.dataBar && l.dataBar.end > l.dataBar.start && ++a > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
33
- l?.children && n.push(...l.children);
34
+ l?.children && r.push(...l.children);
34
35
  const c = i();
35
36
  c && await c;
36
37
  }
37
38
  }
38
39
  }
39
40
  function P(e, t) {
40
- return { richText: e.flatMap((o, n) => [
41
- ...n ? [{ text: `
41
+ return { richText: e.flatMap((o, r) => [
42
+ ...r ? [{ text: `
42
43
  ` }] : [],
43
44
  ...o.segments.map((i) => {
44
- const a = w(t, i.style), r = a.color?.replace(/^#/, "");
45
- return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: $(a).fontSizePt, .../^[a-f\d]{6}$/i.test(r ?? "") ? { color: { argb: `FF${r.toUpperCase()}` } } : {} } };
45
+ const a = p(t, i.style), n = a.color?.replace(/^#/, "");
46
+ return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: A(a).fontSizePt, .../^[a-f\d]{6}$/i.test(n ?? "") ? { color: { argb: `FF${n.toUpperCase()}` } } : {} } };
46
47
  })
47
48
  ]) };
48
49
  }
49
- function Y(e, t) {
50
+ function te(e, t) {
50
51
  const o = e.children?.filter((a) => a.kind === "text" && !a.grid) ?? [];
51
52
  if (!e.richParagraphs?.length && !o.length) return;
52
- const n = w(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
53
+ const r = p(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
53
54
  for (const a of o) {
54
- const r = w(n, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
55
+ const n = p(r, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
55
56
  `) ?? a.text ?? "" }] }];
56
- for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: w(r, c.style) })) });
57
+ for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: p(n, c.style) })) });
57
58
  }
58
- return P(i, n);
59
+ return P(i, r);
59
60
  }
60
- function Z(e, t, o) {
61
- let n = o * 72 / 25.4;
62
- if (!Number.isFinite(n) || t + Math.ceil(n / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
63
- for (; n > 0; ) {
61
+ function ne(e, t, o) {
62
+ let r = o * 72 / 25.4;
63
+ if (!Number.isFinite(r) || t + Math.ceil(r / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
64
+ for (; r > 0; ) {
64
65
  if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
65
- const i = Math.min(409, n);
66
- e.getRow(t++).height = i, n -= i;
66
+ const i = Math.min(409, r);
67
+ e.getRow(t++).height = i, r -= i;
67
68
  }
68
69
  return t;
69
70
  }
70
- function ee(e, t, o) {
71
- let n = Math.round(t * 36e3), i = 0;
72
- if (!Number.isSafeInteger(n)) throw new Error("Excel 图片锚点超出安全坐标范围");
71
+ function re(e, t, o) {
72
+ let r = Math.round(t * 36e3), i = 0;
73
+ if (!Number.isSafeInteger(r)) throw new Error("Excel 图片锚点超出安全坐标范围");
73
74
  for (e.properties.defaultColWidth ??= 8.43; i < 16384; ) {
74
- const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, r = Math.round(H(a) * 36e3);
75
- if (!Number.isSafeInteger(r) || r <= 0) throw new Error("Excel 图片锚点所在列宽无效");
76
- if (n < r) return { col: i + n / r, row: o - 1, nativeCol: i, nativeColOff: n, nativeRow: o - 1, nativeRowOff: 0 };
77
- n -= r, i++;
75
+ const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, n = Math.round(_(a) * 36e3);
76
+ if (!Number.isSafeInteger(n) || n <= 0) throw new Error("Excel 图片锚点所在列宽无效");
77
+ if (r < n) return { col: i + r / n, row: o - 1, nativeCol: i, nativeColOff: r, nativeRow: o - 1, nativeRowOff: 0 };
78
+ r -= n, i++;
78
79
  }
79
80
  throw new Error("Excel 图片锚点超过16384列上限");
80
81
  }
81
- function te(e, t, o) {
82
- let n = o * 72 / 25.4;
83
- if (!Number.isFinite(n) || Math.abs(n) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
82
+ function ie(e, t, o) {
83
+ let r = o * 72 / 25.4;
84
+ if (!Number.isFinite(r) || Math.abs(r) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
84
85
  const i = (a) => {
85
- const r = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
86
- if (!Number.isFinite(r) || r <= 0) throw new Error("Excel 图片锚点所在行高无效");
87
- return r;
86
+ const n = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
87
+ if (!Number.isFinite(n) || n <= 0) throw new Error("Excel 图片锚点所在行高无效");
88
+ return n;
88
89
  };
89
- for (; n < 0 && t > 1; ) n += i(--t);
90
- for (; t <= 1048576 && n >= i(t); ) n -= i(t++);
91
- if (t > 1048576 || n < 0) throw new Error("Excel 图片移动到工作表边界之外");
92
- return { nativeRow: t - 1, nativeRowOff: Math.round(n * 25.4 / 72 * 36e3) };
93
- }
94
- function ne(e, t, o) {
95
- const n = X(t), i = /* @__PURE__ */ new Map();
96
- return { write(a, r, s, l) {
97
- if (![r.widthMm, r.heightMm, r.leftMm].every(Number.isFinite) || r.widthMm < 0 || r.heightMm < 0 || r.leftMm < 0) throw new Error("Excel 图片尺寸无效");
98
- if (!r.widthMm || !r.heightMm) return s;
99
- if (!r.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(r.imageData))
100
- return o.push(`${r.nid ?? r.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
101
- const c = n(r.imageData);
90
+ for (; r < 0 && t > 1; ) r += i(--t);
91
+ for (; t <= 1048576 && r >= i(t); ) r -= i(t++);
92
+ if (t > 1048576 || r < 0) throw new Error("Excel 图片移动到工作表边界之外");
93
+ return { nativeRow: t - 1, nativeRowOff: Math.round(r * 25.4 / 72 * 36e3) };
94
+ }
95
+ function oe(e, t, o) {
96
+ const r = K(t), i = /* @__PURE__ */ new Map();
97
+ return { write(a, n, s, l) {
98
+ if (![n.widthMm, n.heightMm, n.leftMm].every(Number.isFinite) || n.widthMm < 0 || n.heightMm < 0 || n.leftMm < 0) throw new Error("Excel 图片尺寸无效");
99
+ if (!n.widthMm || !n.heightMm) return s;
100
+ if (!n.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(n.imageData))
101
+ return o.push(`${n.nid ?? n.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
102
+ const c = r(n.imageData);
102
103
  let h = i.get(c.dataUrl);
103
104
  h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), i.set(c.dataUrl, h));
104
- const d = l ? s : Z(a, s, r.heightMm);
105
+ const d = l ? s : ne(a, s, n.heightMm);
105
106
  return a.addImage(h, {
106
- tl: { ...ee(a, l?.leftMm ?? r.leftMm, s), ...l ? te(a, s, l.offsetMm) : {} },
107
- ext: { width: r.widthMm * 96 / 25.4, height: r.heightMm * 96 / 25.4 },
107
+ tl: { ...re(a, l?.leftMm ?? n.leftMm, s), ...l ? ie(a, s, l.offsetMm) : {} },
108
+ ext: { width: n.widthMm * 96 / 25.4, height: n.heightMm * 96 / 25.4 },
108
109
  editAs: "oneCell"
109
110
  }), d;
110
111
  } };
@@ -112,31 +113,31 @@ function ne(e, t, o) {
112
113
  function R(e) {
113
114
  return !!e && typeof e == "object" && !Array.isArray(e);
114
115
  }
115
- function I(e, t) {
116
+ function F(e, t) {
116
117
  const o = e.meta?.xlsxFlow;
117
118
  if (o === void 0) return;
118
119
  if (!R(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
119
120
  if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
120
- const n = o, i = e.grid.colWidthsMm;
121
- 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 多区域列位置与网格列宽不一致");
122
- return n;
121
+ const r = o, i = e.grid.colWidthsMm;
122
+ if (!i?.length || r.columnStart + i.length > t.length || i.some((a, n) => Math.abs(a - t[r.columnStart + n]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
123
+ return r;
123
124
  }
124
- function T(e) {
125
+ function I(e) {
125
126
  const t = e.meta?.xlsxFlow;
126
127
  if (t === void 0) {
127
- if (e.components.some((n) => n.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
128
+ if (e.components.some((r) => r.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
128
129
  return;
129
130
  }
130
- const o = re(t, e.meta?.reportScope);
131
- for (const n of e.components) {
132
- const i = I(n, o.widths);
131
+ const o = ae(t, e.meta?.reportScope);
132
+ for (const r of e.components) {
133
+ const i = F(r, o.widths);
133
134
  if (!i) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
134
- 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);
135
- if (Math.abs(a - n.leftMm) > 0.01 || Math.abs(r - n.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
135
+ const a = o.widths.slice(0, i.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0), n = r.grid.colWidthsMm.reduce((s, l) => s + l, 0);
136
+ if (Math.abs(a - r.leftMm) > 0.01 || Math.abs(n - r.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
136
137
  }
137
138
  return o;
138
139
  }
139
- function re(e, t) {
140
+ function ae(e, t) {
140
141
  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 多区域工作表标识无效");
141
142
  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 多区域完整列宽无效");
142
143
  if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
@@ -145,76 +146,76 @@ function re(e, t) {
145
146
  function y(e) {
146
147
  return Math.round(e * 1e6) / 1e6;
147
148
  }
148
- function ie(e, t, o, n, i) {
149
- 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);
149
+ function se(e, t, o, r, i) {
150
+ return e.components.filter((a) => r ? 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);
150
151
  }
151
- function oe(e, t, o, n) {
152
- 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);
153
- return t.map((r) => {
154
- let s = r.topMm;
155
- 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: I(r, n).columnStart };
152
+ function le(e, t, o, r) {
153
+ const i = e.components.filter((n) => !t.includes(n) && n.table?.role === "header"), a = t.filter((n) => !n.pageAnchor).reduce((n, s) => Math.max(n, s.topMm + s.heightMm), e.marginTopMm ?? 0);
154
+ return t.map((n) => {
155
+ let s = n.topMm;
156
+ return o && n.pageAnchor === "footer" && (s = a), s -= i.filter((l) => l.topMm + l.heightMm <= s + 1e-3).reduce((l, c) => l + c.heightMm, 0), { component: n, layout: W(n.grid, n.widthMm, n.heightMm), top: s, column: F(n, r).columnStart };
156
157
  });
157
158
  }
158
- function ae(e, t, o) {
159
- const n = t.length - 1;
160
- if (n * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
161
- const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
159
+ function ce(e, t, o) {
160
+ const r = t.length - 1;
161
+ if (r * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
162
+ const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
162
163
  for (const s of e) for (const l of s.layout.cells) {
163
164
  if (!Object.keys(l.cell).length) continue;
164
165
  const c = i.get(y(s.top + l.yMm)), h = i.get(y(s.top + l.yMm + l.heightMm)), d = s.column + l.ci, u = d + (l.cell.colSpan ?? 1), f = `${c}:${d}`;
165
- for (let g = c; g < h; g++) for (let m = d; m < u; m++) {
166
- const x = `${g}:${m}`;
167
- if (r.has(x)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
168
- r.set(x, f);
166
+ for (let g = c; g < h; g++) for (let w = d; w < u; w++) {
167
+ const m = `${g}:${w}`;
168
+ if (n.has(m)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
169
+ n.set(m, f);
169
170
  }
170
- a.set(f, { ...l.cell, style: w(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - d });
171
+ a.set(f, { ...l.cell, style: p(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - d });
171
172
  }
172
- return Array.from({ length: n }, (s, l) => {
173
+ return Array.from({ length: r }, (s, l) => {
173
174
  const c = [];
174
175
  for (let h = 0; h < o.length; h++) {
175
176
  const d = `${l}:${h}`, u = a.get(d);
176
- u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : r.has(d) || c.push(null);
177
+ u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : n.has(d) || c.push(null);
177
178
  }
178
179
  return c;
179
180
  });
180
181
  }
181
- function se(e, t) {
182
- const o = /* @__PURE__ */ new Set(), n = [];
182
+ function he(e, t) {
183
+ const o = /* @__PURE__ */ new Set(), r = [];
183
184
  let i;
184
- for (const [a, { page: r }] of e.entries()) {
185
- const s = T(r);
185
+ for (const [a, { page: n }] of e.entries()) {
186
+ const s = I(n);
186
187
  if (i && (s.key !== i.key || s.widths.length !== i.widths.length || s.widths.some((f, g) => Math.abs(f - i.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
187
188
  i ??= s;
188
- const l = ie(r, a, e.length, t, o), c = oe(r, l, t, s.widths);
189
+ const l = se(n, a, e.length, t, o), c = le(n, l, t, s.widths);
189
190
  if (!c.length) continue;
190
- const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => y(f.top + g.pos)), y(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d = ae(c, h, s.widths), u = h.slice(1).map((f, g) => f - h[g]);
191
- n.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((f, g) => f + g, 0), heightMm: u.reduce((f, g) => f + g, 0), grid: { cells: d, colWidthsMm: s.widths, rowHeightsMm: u } });
191
+ const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => y(f.top + g.pos)), y(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d = ce(c, h, s.widths), u = h.slice(1).map((f, g) => f - h[g]);
192
+ r.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((f, g) => f + g, 0), heightMm: u.reduce((f, g) => f + g, 0), grid: { cells: d, colWidthsMm: s.widths, rowHeightsMm: u } });
192
193
  }
193
- return n;
194
+ return r;
194
195
  }
195
- const W = 72 / 25.4, le = 32767, ce = 253;
196
- function p(e, t) {
196
+ const z = 72 / 25.4, de = 32767, fe = 253;
197
+ function x(e, t) {
197
198
  if (typeof e != "string") return;
198
- if (e.length > le)
199
+ if (e.length > de)
199
200
  throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
200
201
  let o = 0;
201
- for (let n = 0; n < e.length; n++)
202
- if (e.charCodeAt(n) === 10 && ++o > ce)
202
+ for (let r = 0; r < e.length; r++)
203
+ if (e.charCodeAt(r) === 10 && ++o > fe)
203
204
  throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
204
205
  }
205
- function M(e) {
206
+ function E(e) {
206
207
  if (!e) return;
207
208
  const t = e.replace("#", "");
208
209
  return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
209
210
  }
210
- function z(e, t = {}) {
211
+ function D(e, t = {}) {
211
212
  e.font = {
212
213
  name: t.fontFamily,
213
214
  bold: t.bold === !0,
214
215
  italic: t.italic === !0,
215
216
  underline: t.underline === !0,
216
- size: $(t).fontSizePt,
217
- color: M(t.color) ? { argb: M(t.color) } : void 0
217
+ size: A(t).fontSizePt,
218
+ color: E(t.color) ? { argb: E(t.color) } : void 0
218
219
  };
219
220
  }
220
221
  const b = {
@@ -222,134 +223,134 @@ const b = {
222
223
  a4: { width: 210, height: 297, code: 9 },
223
224
  a5: { width: 148, height: 210, code: 11 }
224
225
  };
225
- function he(e, t, o, n) {
226
+ function ge(e, t, o, r) {
226
227
  if (t && t !== "auto") return b[t].code;
227
- 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);
228
- return r ? r.code : (n.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
228
+ const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), n = Object.values(b).find((s) => Math.abs(i - s.width) <= 1 && Math.abs(a - s.height) <= 1);
229
+ return n ? n.code : (r.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
229
230
  }
230
- function de(e, t, o, n) {
231
+ function ue(e, t, o, r) {
231
232
  const i = typeof t.text == "string" ? t.text : "";
232
233
  if (o !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
233
- p(i, e.address), e.value = i;
234
+ x(i, e.address), e.value = i;
234
235
  return;
235
236
  }
236
237
  const a = t.value;
237
238
  if (a === null || typeof a == "string" || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) {
238
- p(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
239
+ x(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
239
240
  return;
240
241
  }
241
- p(i, e.address), e.value = i, n.push(`原始单元格值无效,已保留显示文本:${e.address}`);
242
+ x(i, e.address), e.value = i, r.push(`原始单元格值无效,已保留显示文本:${e.address}`);
242
243
  }
243
- function fe(e) {
244
- const t = T(e);
245
- return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : ge(e);
244
+ function me(e) {
245
+ const t = I(e);
246
+ return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : we(e);
246
247
  }
247
- function ge(e) {
248
- const o = e.components.filter((n) => n.table !== void 0)[0]?.table;
248
+ function we(e) {
249
+ const o = e.components.filter((r) => r.table !== void 0)[0]?.table;
249
250
  if (!(!o || typeof o.id != "string" || !o.id.trim() || !Array.isArray(o.columnKeys) || !o.columnKeys.length)) {
250
- for (const n of e.components) {
251
- if (n.table) {
252
- if (!n.grid || n.table.id !== o.id) return;
251
+ for (const r of e.components) {
252
+ if (r.table) {
253
+ if (!r.grid || r.table.id !== o.id) return;
253
254
  continue;
254
255
  }
255
- if (n.grid || n.kind !== "text" && !S(n)) return;
256
+ if (r.grid || r.kind !== "text" && !v(r)) return;
256
257
  }
257
258
  return { id: o.id, title: o.title, wide: o.layout === "wide" || e.layout === "wide" };
258
259
  }
259
260
  }
260
- function ue(e, t) {
261
+ function pe(e, t) {
261
262
  const o = /* @__PURE__ */ new Set();
262
- for (const [n, i] of e.pages.entries())
263
- if (!t[n])
263
+ for (const [r, i] of e.pages.entries())
264
+ if (!t[r])
264
265
  for (const a of i.components)
265
266
  typeof a.table?.id == "string" && o.add(a.table.id);
266
267
  return o;
267
268
  }
268
- function v(e) {
269
+ function C(e) {
269
270
  return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
270
271
  }
271
- function me(e, t, o) {
272
- const n = [], i = e.pages.map(fe), a = ue(e, i);
273
- for (const [r, s] of e.pages.entries()) {
274
- const l = i[r], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
272
+ function xe(e, t, o) {
273
+ const r = [], i = e.pages.map(me), a = pe(e, i);
274
+ for (const [n, s] of e.pages.entries()) {
275
+ const l = i[n], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
275
276
  if (t === "continuous" && !h)
276
- throw new Error(`page ${r + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
277
+ throw new Error(`page ${n + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
277
278
  const d = h !== void 0 && (t === "continuous" || h.wide);
278
- !d && t !== "pages" && v(s) && o.push(`page ${r + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
279
- const u = n[n.length - 1];
280
- d && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index: r }) : n.push({ pages: [{ page: s, index: r }], continuous: d, ...d ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
279
+ !d && t !== "pages" && C(s) && o.push(`page ${n + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
280
+ const u = r[r.length - 1];
281
+ d && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index: n }) : r.push({ pages: [{ page: s, index: n }], continuous: d, ...d ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
281
282
  }
282
- return n;
283
+ return r;
283
284
  }
284
- function k(e, t, o) {
285
- return !e || e.length === t.length && e.every((n, i) => o(n, t[i]));
285
+ function $(e, t, o) {
286
+ return !e || e.length === t.length && e.every((r, i) => o(r, t[i]));
286
287
  }
287
- function we(e, t, o, n) {
288
- const i = e.table, a = t.columns.map((l) => l.size), r = k(n.keys, i.columnKeys, (l, c) => l === c), s = k(n.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
289
- if (i.columnKeys.length !== a.length || !r || !s)
288
+ function Me(e, t, o, r) {
289
+ const i = e.table, a = t.columns.map((l) => l.size), n = $(r.keys, i.columnKeys, (l, c) => l === c), s = $(r.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
290
+ if (i.columnKeys.length !== a.length || !n || !s)
290
291
  throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
291
- if (n.keys ??= i.columnKeys, n.widths ??= a, i.role === "header") {
292
+ if (r.keys ??= i.columnKeys, r.widths ??= a, i.role === "header") {
292
293
  if (i.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
293
- n.headerSeen = !0;
294
+ r.headerSeen = !0;
294
295
  } else {
295
- if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== n.expectedRow)
296
- throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
297
- n.expectedRow += t.rows.length;
296
+ if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== r.expectedRow)
297
+ throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${r.expectedRow})`);
298
+ r.expectedRow += t.rows.length;
298
299
  }
299
300
  }
300
- function pe(e, t) {
301
+ function Ee(e, t) {
301
302
  const o = { expectedRow: 0, headerSeen: !1 };
302
- for (const { page: n, index: i } of e.pages)
303
- for (const a of n.components) {
304
- const r = t.get(a);
305
- a.table && r && we(a, r, i, o);
303
+ for (const { page: r, index: i } of e.pages)
304
+ for (const a of r.components) {
305
+ const n = t.get(a);
306
+ a.table && n && Me(a, n, i, o);
306
307
  }
307
308
  if (!o.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
308
309
  }
309
- function xe(e, t, o) {
310
- let n = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
311
- n.toLowerCase() === "history" && (n += " 报表");
312
- let i = n, a = 1;
310
+ function be(e, t, o) {
311
+ let r = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
312
+ r.toLowerCase() === "history" && (r += " 报表");
313
+ let i = r, a = 1;
313
314
  for (; o.has(i.toLowerCase()); ) {
314
- const r = ` (${++a})`;
315
- i = n.slice(0, 31 - r.length) + r;
315
+ const n = ` (${++a})`;
316
+ i = r.slice(0, 31 - n.length) + n;
316
317
  }
317
318
  return o.add(i.toLowerCase()), i;
318
319
  }
319
- function Me(e) {
320
+ function ye(e) {
320
321
  const t = /* @__PURE__ */ new Set();
321
- function o(n, i, a, r) {
322
- return n <= i ? n : (t.has(a) || (e.push(r), t.add(a)), i);
322
+ function o(r, i, a, n) {
323
+ return r <= i ? r : (t.has(a) || (e.push(n), t.add(a)), i);
323
324
  }
324
325
  return {
325
- column: (n) => o(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
326
- row: (n) => o(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
326
+ column: (r) => o(r, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
327
+ row: (r) => o(r, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
327
328
  };
328
329
  }
329
- async function Ee(e, t) {
330
- const o = e.flow ? se(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();
330
+ async function Se(e, t) {
331
+ const o = e.flow ? he(e.pages, e.continuous).map((n) => ({ comp: n, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: n, index: s }, l) => n.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || l === 0) && (c.pageAnchor !== "footer" || l === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: s }))), r = /* @__PURE__ */ new Map();
331
332
  let i = 1, a = 0;
332
- for (const { comp: r } of o)
333
- if (r.grid) {
334
- const s = A(r.grid, r.widthMm, r.heightMm);
335
- n.set(r, s), i = Math.max(i, s.columns.length);
333
+ for (const { comp: n } of o)
334
+ if (n.grid) {
335
+ const s = W(n.grid, n.widthMm, n.heightMm);
336
+ r.set(n, s), i = Math.max(i, s.columns.length);
336
337
  const l = t(s.cells.length);
337
338
  l && await l;
338
- } else r.kind === "text" && (a = Math.max(a, r.widthMm));
339
+ } else n.kind === "text" && (a = Math.max(a, n.widthMm));
339
340
  if (i > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
340
- return { components: o, grids: n, columnCount: i, textWidthMm: a };
341
+ return { components: o, grids: r, columnCount: i, textWidthMm: a };
341
342
  }
342
- function be(e, t, o) {
343
- const { page: n, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
344
- return (e.continuous || v(n)) && !a ? {} : { pageSetup: {
345
- paperSize: he(n, t, i, o),
346
- orientation: n.pageWidthMm > n.pageHeightMm ? "landscape" : "portrait",
343
+ function ve(e, t, o) {
344
+ const { page: r, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
345
+ return (e.continuous || C(r)) && !a ? {} : { pageSetup: {
346
+ paperSize: ge(r, t, i, o),
347
+ orientation: r.pageWidthMm > r.pageHeightMm ? "landscape" : "portrait",
347
348
  fitToPage: !0,
348
349
  ...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
349
350
  } };
350
351
  }
351
- function ye(e) {
352
- const t = M(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
352
+ function Ce(e) {
353
+ const t = E(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
353
354
  return {
354
355
  ...e.borderTop !== !1 ? { top: o } : {},
355
356
  ...e.borderLeft !== !1 ? { left: o } : {},
@@ -357,81 +358,81 @@ function ye(e) {
357
358
  ...e.borderRight !== !1 ? { right: o } : {}
358
359
  };
359
360
  }
360
- function Se(e, t) {
361
+ function ke(e, t) {
361
362
  e.alignment = { horizontal: t.align ?? "left", vertical: t.verticalAlign ?? "middle", wrapText: !0 };
362
- const o = M(t.backgroundColor);
363
- o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = ye(t), z(e, t);
363
+ const o = E(t.backgroundColor);
364
+ o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = Ce(t), D(e, t);
364
365
  }
365
- function ve(e, t) {
366
- for (const [o, n] of t.columns.entries()) {
367
- const i = e.sheet.getColumn(o + 1), a = e.limits.column(F(n.size));
366
+ function Be(e, t) {
367
+ for (const [o, r] of t.columns.entries()) {
368
+ const i = e.sheet.getColumn(o + 1), a = e.limits.column(T(r.size));
368
369
  (i.width == null || i.width < a) && (i.width = a);
369
370
  }
370
371
  }
371
- function Ce(e, t, o) {
372
- for (const [n, i] of t.rows.entries()) {
373
- const a = e.sheet.getRow(o + n), r = e.limits.row(i.size * W);
374
- (a.height == null || a.height < r) && (a.height = r);
372
+ function $e(e, t, o) {
373
+ for (const [r, i] of t.rows.entries()) {
374
+ const a = e.sheet.getRow(o + r), n = e.limits.row(i.size * z);
375
+ (a.height == null || a.height < n) && (a.height = n);
375
376
  }
376
377
  }
377
- function ke(e, t, o, n) {
378
+ function Ae(e, t, o, r) {
378
379
  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));
379
- (i > 1 || a > 1) && e.mergeCells(n + t.ri, t.ci + 1, n + t.ri + a - 1, t.ci + i);
380
+ (i > 1 || a > 1) && e.mergeCells(r + t.ri, t.ci + 1, r + t.ri + a - 1, t.ci + i);
380
381
  }
381
- async function Be(e, t, o, n) {
382
- if (n + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
383
- Ce(e, o, n);
382
+ async function We(e, t, o, r) {
383
+ if (r + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
384
+ $e(e, o, r);
384
385
  for (const i of o.cells) {
385
- const a = e.sheet.getCell(n + i.ri, i.ci + 1);
386
- de(a, i.cell, e.valueMode, e.warnings);
387
- const r = Y(i.cell, t.style);
388
- r && (p(r.richText.map((c) => c.text).join(""), a.address), a.value = r);
386
+ const a = e.sheet.getCell(r + i.ri, i.ci + 1);
387
+ ue(a, i.cell, e.valueMode, e.warnings);
388
+ const n = te(i.cell, t.style);
389
+ n && (x(n.richText.map((c) => c.text).join(""), a.address), a.value = n);
389
390
  const s = t.grid?.paddingMm ?? 0.5;
390
- e.dataBars(e.sheet, i, n + i.ri, s);
391
+ e.dataBars(e.sheet, i, r + i.ri, s);
391
392
  for (const c of i.cell.children ?? [])
392
- 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 });
393
- Se(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))) }), ke(e.sheet, i, o, n);
393
+ v(c) && !c.grid && e.images.write(e.sheet, c, r + i.ri, { leftMm: i.xMm + s + (i.cell.indentMm ?? 0) + c.leftMm, offsetMm: s + c.topMm });
394
+ ke(a, p(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))) }), Ae(e.sheet, i, o, r);
394
395
  const l = e.schedule();
395
396
  l && await l;
396
397
  }
397
- return n + o.rows.length;
398
+ return r + o.rows.length;
398
399
  }
399
- function $e(e, t, o, n) {
400
+ function Te(e, t, o, r) {
400
401
  const i = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
401
- `) : t.text ?? "", a = e.sheet.getRow(o), r = a.getCell(1);
402
- t.richParagraphs?.length || p(i, r.address), r.value = t.richParagraphs?.length ? P(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 };
403
- const s = M(t.style?.backgroundColor);
404
- return s && (r.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), z(r, t.style), n > 1 && e.sheet.mergeCells(o, 1, o, n), a.height = e.limits.row(t.heightMm * W), o + 1;
405
- }
406
- function Ae(e, t, o) {
407
- const n = t + o - 1;
408
- e.views = [{ state: "frozen", ySplit: n, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${n}`;
409
- }
410
- async function Fe(e, t, o, n) {
411
- !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(F(t.textWidthMm)));
412
- for (const r of t.grids.values()) {
413
- ve(e, r);
414
- const s = e.schedule(r.columns.length);
402
+ `) : t.text ?? "", a = e.sheet.getRow(o), n = a.getCell(1);
403
+ t.richParagraphs?.length || x(i, n.address), n.value = t.richParagraphs?.length ? P(t.richParagraphs, t.style) : i, typeof n.value == "object" && n.value && "richText" in n.value && x(n.value.richText.map((l) => l.text).join(""), n.address), n.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
404
+ const s = E(t.style?.backgroundColor);
405
+ return s && (n.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), D(n, t.style), r > 1 && e.sheet.mergeCells(o, 1, o, r), a.height = e.limits.row(t.heightMm * z), o + 1;
406
+ }
407
+ function Pe(e, t, o) {
408
+ const r = t + o - 1;
409
+ e.views = [{ state: "frozen", ySplit: r, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${r}`;
410
+ }
411
+ async function Re(e, t, o, r) {
412
+ !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(T(t.textWidthMm)));
413
+ for (const n of t.grids.values()) {
414
+ Be(e, n);
415
+ const s = e.schedule(n.columns.length);
415
416
  s && await s;
416
417
  }
417
418
  let i = 1, a = !1;
418
- for (const { comp: r, pageIndex: s } of t.components) {
419
- const l = o && r.table?.role === "header";
419
+ for (const { comp: n, pageIndex: s } of t.components) {
420
+ const l = o && n.table?.role === "header";
420
421
  if (l && a) continue;
421
422
  if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
422
- const c = t.grids.get(r);
423
+ const c = t.grids.get(n);
423
424
  if (c)
424
- l && (Ae(e.sheet, i, c.rows.length), a = !0), i = await Be(e, r, c, i);
425
- else if (r.kind === "text")
426
- i = $e(e, r, i, t.columnCount);
427
- else if (S(r)) {
428
- const h = U(r, o), d = n.write(e.sheet, r, h?.row ?? i, h);
425
+ l && (Pe(e.sheet, i, c.rows.length), a = !0), i = await We(e, n, c, i);
426
+ else if (n.kind === "text")
427
+ i = Te(e, n, i, t.columnCount);
428
+ else if (v(n)) {
429
+ const h = X(n, o), d = r.write(e.sheet, n, h?.row ?? i, h);
429
430
  h || (i = d);
430
431
  } else
431
- e.warnings.push(`page ${s + 1} ${r.nid ?? r.kind}: 组件类型 ${r.kind} 暂不支持 xlsx 导出,已跳过`);
432
+ e.warnings.push(`page ${s + 1} ${n.nid ?? n.kind}: 组件类型 ${n.kind} 暂不支持 xlsx 导出,已跳过`);
432
433
  }
433
434
  }
434
- function Pe(e) {
435
+ function Fe(e) {
435
436
  if (e.maxDataBars !== void 0 && (!Number.isSafeInteger(e.maxDataBars) || e.maxDataBars < 0 || e.maxDataBars > 1e5)) throw new Error("xlsx maxDataBars 必须是 0–100000 的整数");
436
437
  if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
437
438
  throw new Error("xlsx valueMode 必须是 text 或 raw");
@@ -440,44 +441,63 @@ function Pe(e) {
440
441
  if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
441
442
  throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
442
443
  }
443
- async function Le(e, t = {}) {
444
- Pe(t), E(t.signal);
445
- const o = t.assetRegistry || t.assetRenderers ? await K(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
446
- e = o.plan;
447
- const n = [...o.diagnostics, ...J(e, "xlsx", t)];
448
- await Q(e, t.maxDataBars ?? 1e4, t);
449
- const i = new _.Workbook(), a = [], r = ne(i, t, a), s = [], l = q(r, t.maxDataBars ?? 1e4, s), c = Me(a), h = me(e, t.sheetMode, a), d = /* @__PURE__ */ new Set(), u = B(t);
450
- for (const [g, m] of h.entries()) {
451
- const x = await Ee(m, u);
452
- m.continuous && !m.flow && pe(m, x.grids);
453
- const D = m.pages[0].page, C = t.sheetName?.(g) ?? xe(m.title, g, d);
454
- d.add(C.toLowerCase());
455
- const N = i.addWorksheet(C, be(m, t.paperSize, a)), O = t.valueMode ?? (v(D) || m.continuous || m.flow ? "raw" : "text");
456
- E(t.signal), await Fe({ sheet: N, warnings: a, limits: c, valueMode: O, schedule: u, images: r, dataBars: l }, x, m.continuous, r), await L(t, g + 1, h.length);
444
+ async function Ie(e, t = {}) {
445
+ const o = q(t.additionalSheets), r = Q(t.sheetNames);
446
+ Fe(t), M(t.signal);
447
+ const i = t.assetRegistry || t.assetRenderers ? await J(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
448
+ e = i.plan;
449
+ const a = [...i.diagnostics, ...V(e, "xlsx", t)];
450
+ await ee(e, t.maxDataBars ?? 1e4, t);
451
+ const n = new U.Workbook(), s = [], l = oe(n, t, s), c = [], h = Z(l, t.maxDataBars ?? 1e4, c), d = ye(s), u = xe(e, t.sheetMode, s), f = /* @__PURE__ */ new Set(), g = S(t);
452
+ for (const [w, m] of u.entries()) {
453
+ const k = await Se(m, g);
454
+ m.continuous && !m.flow && Ee(m, k.grids);
455
+ const N = m.pages[0].page, B = r?.[w] ?? t.sheetName?.(w) ?? be(m.title, w, f);
456
+ f.add(B.toLowerCase());
457
+ const L = n.addWorksheet(B, ve(m, t.paperSize, s)), O = t.valueMode ?? (C(N) || m.continuous || m.flow ? "raw" : "text");
458
+ M(t.signal), await Re({ sheet: L, warnings: s, limits: d, valueMode: O, schedule: g, images: l, dataBars: h }, k, m.continuous, l), await j(t, w + 1, u.length);
459
+ }
460
+ return await ze(n, o, t), { workbook: n, warnings: s, diagnostics: a, ...c.length ? { notes: c } : {} };
461
+ }
462
+ async function ze(e, t = [], o) {
463
+ const r = S(o);
464
+ for (const i of t) {
465
+ if (M(o.signal), e.worksheets.some((n) => n.name.toLowerCase() === i.name.toLowerCase())) throw new TypeError(`附加工作表名称已被报表使用 ${i.name}`);
466
+ const a = e.addWorksheet(i.name);
467
+ i.columnWidths && (a.columns = i.columnWidths.map((n) => ({ width: n })));
468
+ for (const n of i.rows) {
469
+ const s = a.addRow([...n]);
470
+ s.alignment = { vertical: "top", wrapText: !0 }, await r(n.length);
471
+ }
457
472
  }
458
- E(t.signal);
459
- const f = await i.xlsx.writeBuffer();
460
- return E(t.signal), { workbook: i, buffer: f, warnings: a, diagnostics: n, ...s.length ? { notes: s } : {} };
473
+ M(o.signal);
474
+ }
475
+ async function Xe(e, t = {}) {
476
+ const o = await Ie(e, t);
477
+ M(t.signal);
478
+ const r = await o.workbook.xlsx.writeBuffer();
479
+ return M(t.signal), { ...o, buffer: r };
461
480
  }
462
481
  export {
463
- Ke as bindExcelTemplate,
464
- Je as createExcelBindingDocument,
465
- Ve as createExcelBindingSession,
466
- qe as createExcelRegionBindingDocument,
467
- Qe as createExcelRegionBindingSession,
468
- Ye as excelBindingCellRange,
469
- Ze as excelBindingRowRange,
470
- et as getExcelSheetWindow,
471
- He as importExcelTemplate,
472
- _e as inspectExcelWorkbook,
473
- Ue as openExcelWorkbook,
474
- tt as parseExcelBindingSession,
475
- nt as parseExcelRegionBindingSession,
476
- Le as renderPlanToXlsx,
477
- rt as validateExcelBindingFields,
478
- it as validateExcelBindingRecipe,
479
- ot as validateExcelBindingRegions,
480
- at as validateExcelRegionBindings,
481
- st as validateExcelRegionFields,
482
- lt as validateExcelRegionGeometry
482
+ Ze as bindExcelTemplate,
483
+ et as createExcelBindingDocument,
484
+ tt as createExcelBindingSession,
485
+ nt as createExcelRegionBindingDocument,
486
+ rt as createExcelRegionBindingSession,
487
+ it as excelBindingCellRange,
488
+ ot as excelBindingRowRange,
489
+ at as getExcelSheetWindow,
490
+ Ve as importExcelTemplate,
491
+ qe as inspectExcelWorkbook,
492
+ Qe as openExcelWorkbook,
493
+ st as parseExcelBindingSession,
494
+ lt as parseExcelRegionBindingSession,
495
+ Ie as renderPlanToWorkbook,
496
+ Xe as renderPlanToXlsx,
497
+ ct as validateExcelBindingFields,
498
+ ht as validateExcelBindingRecipe,
499
+ dt as validateExcelBindingRegions,
500
+ ft as validateExcelRegionBindings,
501
+ gt as validateExcelRegionFields,
502
+ ut as validateExcelRegionGeometry
483
503
  };