@agile-team/mach-report 2.10.0 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +6 -2
  2. package/dist/ExcelBindingWizard-LWX6G1A2.js +1465 -0
  3. package/dist/ExcelBindingWizard-a4kslPHF.cjs +1 -0
  4. package/dist/ParamEditor-BLaE5q5W.js +522 -0
  5. package/dist/ParamEditor-MBBC7lUE.cjs +1 -0
  6. package/dist/ReportBatchPanel-B5ClP9tm.js +350 -0
  7. package/dist/ReportBatchPanel-Dc-SDkYA.cjs +1 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-BZB-XWjj.js +311 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +2 -0
  18. package/dist/analytics.d.ts +2 -0
  19. package/dist/analytics.js +29 -29
  20. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  21. package/dist/batch-mRqhhhjt.js +364 -0
  22. package/dist/computed-Bvk0W15F.js +521 -0
  23. package/dist/computed-CGV2a809.cjs +1 -0
  24. package/dist/config-B612mw0x.js +525 -0
  25. package/dist/config-BRoLo2oj.cjs +1 -0
  26. package/dist/designer.cjs +2 -2
  27. package/dist/designer.d.cts +730 -9
  28. package/dist/designer.d.ts +730 -9
  29. package/dist/designer.js +2093 -1785
  30. package/dist/index.cjs +8 -8
  31. package/dist/index.d.cts +161 -3
  32. package/dist/index.d.ts +161 -3
  33. package/dist/index.js +486 -431
  34. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  35. package/dist/injection-keys-e85udZCp.js +7 -0
  36. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  37. package/dist/{list-cell-Dxyi7DOw.js → list-cell-ClFra1zS.js} +54 -40
  38. package/dist/matrix-DVyWiYsd.cjs +1 -0
  39. package/dist/matrix-yZsGnldA.js +227 -0
  40. package/dist/param-validation-BlHHXs6u.js +153 -0
  41. package/dist/param-validation-DCK039V1.cjs +1 -0
  42. package/dist/pdf.cjs +25 -25
  43. package/dist/pdf.d.cts +3 -0
  44. package/dist/pdf.d.ts +3 -0
  45. package/dist/pdf.js +677 -677
  46. package/dist/plugin-BDTU4D94.cjs +1 -0
  47. package/dist/plugin-Cd5G2QQn.js +22 -0
  48. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  49. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  50. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  51. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  52. package/dist/server/node.d.cts +5 -2
  53. package/dist/server/node.d.ts +5 -2
  54. package/dist/server-node.cjs +1 -1
  55. package/dist/server-node.js +87 -87
  56. package/dist/server.cjs +1 -1
  57. package/dist/server.d.cts +201 -2
  58. package/dist/server.d.ts +201 -2
  59. package/dist/server.js +557 -658
  60. package/dist/style.css +1 -1
  61. package/dist/template-registry-WNXdkiET.js +506 -0
  62. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  63. package/dist/template-review-BXp2oyqg.cjs +1 -0
  64. package/dist/template-review-BdcXSYbx.js +1616 -0
  65. package/dist/tree-BX380Rr7.cjs +1 -0
  66. package/dist/tree-CqcQ99NM.js +172 -0
  67. package/dist/{validate-UUy9yP4K.js → validate-7s0yn6ii.js} +44 -44
  68. package/dist/validate-DsRiNw8h.cjs +1 -0
  69. package/dist/vue/async.d.cts +93 -4
  70. package/dist/vue/async.d.ts +93 -4
  71. package/dist/vue/index.d.cts +145 -7
  72. package/dist/vue/index.d.ts +145 -7
  73. package/dist/vue-async.cjs +1 -1
  74. package/dist/vue-async.js +5 -5
  75. package/dist/vue.cjs +1 -1
  76. package/dist/vue.js +116 -113
  77. package/dist/{workbook-session-B-bW5_yR.js → workbook-session-BKOTwcoq.js} +1 -1
  78. package/dist/{workbook-session-D7RtdNo0.cjs → workbook-session-CLYLhZWu.cjs} +1 -1
  79. package/dist/worker.cjs +1 -1
  80. package/dist/worker.d.cts +5 -2
  81. package/dist/worker.d.ts +5 -2
  82. package/dist/worker.js +1 -1
  83. package/dist/xlsx.cjs +3 -3
  84. package/dist/xlsx.d.cts +129 -2
  85. package/dist/xlsx.d.ts +129 -2
  86. package/dist/xlsx.js +336 -242
  87. package/package.json +1 -1
  88. package/dist/ExcelBindingWizard-CF7RplWm.cjs +0 -1
  89. package/dist/ExcelBindingWizard-qhwEderR.js +0 -842
  90. package/dist/ReportPreview-BE1tCHqE.js +0 -4604
  91. package/dist/ReportPreview-QKRKQOe3.cjs +0 -6
  92. package/dist/RuleEditor-BA36yIV6.js +0 -1723
  93. package/dist/RuleEditor-CczJ6mJm.cjs +0 -1
  94. package/dist/TemplateReviewPanel-CHi4Alqa.cjs +0 -1
  95. package/dist/TemplateReviewPanel-Dz0G5o83.js +0 -217
  96. package/dist/binding-preview-BWsdf_z2.cjs +0 -2
  97. package/dist/binding-preview-DILq0-0f.js +0 -649
  98. package/dist/decimal-CI1OAczk.js +0 -87
  99. package/dist/decimal-CQA0xJex.cjs +0 -1
  100. package/dist/list-cell-CyM1ZlRN.cjs +0 -1
  101. package/dist/matrix-BbXarwyk.js +0 -661
  102. package/dist/matrix-Cm65WLLP.cjs +0 -1
  103. package/dist/param-validation-BWNjLcN0.js +0 -116
  104. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  105. package/dist/plugin-CThk42vJ.cjs +0 -1
  106. package/dist/plugin-tGn7-5oF.js +0 -25
  107. package/dist/template-registry-CGWTLtIA.cjs +0 -1
  108. package/dist/template-registry-DzlQs3OF.js +0 -434
  109. package/dist/template-review-D1RoNCPw.cjs +0 -1
  110. package/dist/template-review-fnteXRng.js +0 -1473
  111. package/dist/validate-Bf6ccFr2.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,28 +1,29 @@
1
- import { D as Z, a as ve } from "./defaults-DXhiM1ZD.js";
2
- import { b as Pn, c as Rn, d as An, L as kn, S as In } from "./defaults-DXhiM1ZD.js";
3
- import { e as Nn, f as Ln, p as Dn, t as Fn, b as On } from "./list-cell-Dxyi7DOw.js";
4
- import { a as z, r as H, b as Q, c as _, d as ye, m as ie, e as Me, p as F, f as xe, P as K } from "./style-CQ1PK8ZB.js";
5
- import { C as Hn, M as Wn, g as jn, h as _n } from "./style-CQ1PK8ZB.js";
6
- import { i as ee, a as Ee } from "./render-plan-Ck6koX9L.js";
7
- import { R as qn } from "./render-plan-Ck6koX9L.js";
8
- import { a as Un, v as Vn, b as Yn, c as Kn } from "./validate-UUy9yP4K.js";
1
+ import { D as Z, a as ye } from "./defaults-DXhiM1ZD.js";
2
+ import { b as In, c as $n, d as Nn, L as Ln, S as Dn } from "./defaults-DXhiM1ZD.js";
3
+ import { e as On, f as zn, p as Hn, t as Wn, c as _n } from "./list-cell-ClFra1zS.js";
4
+ import { a as H, r as W, b as Q, c as j, d as Me, m as ie, e as xe, p as O, f as Ee, P as K } from "./style-CQ1PK8ZB.js";
5
+ import { C as Bn, M as Gn, g as Un, h as Vn } from "./style-CQ1PK8ZB.js";
6
+ import { i as ee, a as Se } from "./render-plan-Ck6koX9L.js";
7
+ import { R as Yn } from "./render-plan-Ck6koX9L.js";
8
+ import { a as Xn, v as Jn, b as Zn, c as Qn } from "./validate-7s0yn6ii.js";
9
9
  import { v as je } from "./dataset-H5pFuQGU.js";
10
- import { d as Jn } from "./dataset-H5pFuQGU.js";
11
- import { h as ae, w as Se } from "./textwrap-DE1kgcJB.js";
12
- import { c as Qn, a as er, b as tr, m as nr } from "./textwrap-DE1kgcJB.js";
13
- import { R as _e, p as Be } from "./template-review-fnteXRng.js";
14
- import { P as ir, a as ar, b as or, c as sr, d as lr, e as cr, f as dr, g as mr, h as hr, i as ur, j as gr, k as fr, l as pr, m as wr, n as br, o as vr, q as yr, r as Mr, s as xr, t as Er, u as Sr, v as Tr, w as Cr, x as Pr, y as Rr, z as Ar } from "./template-review-fnteXRng.js";
15
- import { r as Te } from "./grid-geometry-BNptEcMm.js";
16
- import { r as Ce, a as oe } from "./assets-DegqDNqY.js";
17
- import { O as Ir } from "./assets-DegqDNqY.js";
18
- import { r as q, n as Pe, O as qe } from "./capabilities-CK_7hizc.js";
19
- import { i as Nr } from "./capabilities-CK_7hizc.js";
20
- import { o as Ge } from "./progress-7OSZbFok.js";
21
- import { c as Ue } from "./page-window-index-CIuT4BAv.js";
22
- import { p as j } from "./template-registry-DzlQs3OF.js";
23
- import { R as Dr, a as Fr, c as Or, d as zr, s as Hr, v as Wr, b as jr } from "./template-registry-DzlQs3OF.js";
24
- import { R as Br, a as qr, i as Gr, r as Ur, v as Vr, b as Yr } from "./param-validation-BWNjLcN0.js";
25
- const Ve = {
10
+ import { d as tr } from "./dataset-H5pFuQGU.js";
11
+ import { h as oe, w as Te } from "./textwrap-DE1kgcJB.js";
12
+ import { c as rr, a as ir, b as or, m as ar } from "./textwrap-DE1kgcJB.js";
13
+ import { R as Be, p as Ge } from "./template-review-BdcXSYbx.js";
14
+ import { P as lr, a as cr, b as dr, c as mr, d as hr, e as ur, f as gr, g as fr, h as pr, i as wr, j as br, k as vr, l as yr, m as Mr, n as xr, o as Er, q as Sr, r as Tr, s as Cr, t as Rr, u as Pr, v as Ar, w as kr, x as Ir, y as $r, z as Nr } from "./template-review-BdcXSYbx.js";
15
+ import { r as Ce } from "./grid-geometry-BNptEcMm.js";
16
+ import { r as Re, a as ae } from "./assets-DegqDNqY.js";
17
+ import { O as Dr } from "./assets-DegqDNqY.js";
18
+ import { r as G, n as Pe, O as Ue } from "./capabilities-CK_7hizc.js";
19
+ import { i as Or } from "./capabilities-CK_7hizc.js";
20
+ import { o as Ve } from "./progress-7OSZbFok.js";
21
+ import { c as qe } from "./page-window-index-CIuT4BAv.js";
22
+ import { p as I } from "./template-registry-WNXdkiET.js";
23
+ import { R as Hr, a as Wr, c as _r, d as jr, s as Br, v as Gr, b as Ur } from "./template-registry-WNXdkiET.js";
24
+ import { R as qr, a as Yr, f as Kr, i as Xr, b as Jr, c as Zr, p as Qr, r as ei, v as ti, d as ni } from "./param-validation-BlHHXs6u.js";
25
+ import { T as ii, c as oi, v as ai } from "./tree-CqcQ99NM.js";
26
+ const Ye = {
26
27
  root: "mr-root",
27
28
  page: "mr-page",
28
29
  comp: "mr-comp",
@@ -40,9 +41,9 @@ const Ve = {
40
41
  unknown: "mr-unknown"
41
42
  };
42
43
  function E(e, t) {
43
- return t?.classNames?.[e] ?? Ve[e];
44
+ return t?.classNames?.[e] ?? Ye[e];
44
45
  }
45
- class Ye {
46
+ class Ke {
46
47
  constructor() {
47
48
  this.props = [];
48
49
  }
@@ -50,7 +51,7 @@ class Ye {
50
51
  return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
51
52
  }
52
53
  mm(t, n, r, i = 2) {
53
- return this.add(t, `${z(ie(n, r), i)}px`);
54
+ return this.add(t, `${H(ie(n, r), i)}px`);
54
55
  }
55
56
  toString() {
56
57
  let t = "";
@@ -64,50 +65,50 @@ class Ye {
64
65
  }
65
66
  }
66
67
  function y(e, t = "unset") {
67
- return new Ye().add("all", t).add("display", e).add("box-sizing", "border-box");
68
+ return new Ke().add("all", t).add("display", e).add("box-sizing", "border-box");
68
69
  }
69
- function Re(e, t, n) {
70
+ function Ae(e, t, n) {
70
71
  e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(Q(t))).add("text-align", t.align);
71
- const r = H(t, n);
72
- e.add("font-size", `${z(r.fontSizePx, 2)}px`);
72
+ const r = W(t, n);
73
+ e.add("font-size", `${H(r.fontSizePx, 2)}px`);
73
74
  }
74
- function Ke(e, t, n) {
75
+ function Xe(e, t, n) {
75
76
  const r = t.style ?? {};
76
- Re(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
77
+ Ae(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
77
78
  }
78
- function Xe(e, t, n, r, i, o) {
79
+ function Je(e, t, n, r, i, o) {
79
80
  const s = e.cell, a = o.createElement("td");
80
81
  a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), s.colSpan && (a.colSpan = s.colSpan), s.rowSpan && (a.rowSpan = s.rowSpan);
81
- const l = Me(t.style, s.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
82
- Re(c, l, r), c.applyTo(a);
82
+ const l = xe(t.style, s.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
83
+ Ae(c, l, r), c.applyTo(a);
83
84
  const d = o.createElement("div");
84
- d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n, r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", l.verticalAlign === "top" ? "flex-start" : l.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), s.text != null && d.append(s.text);
85
- for (const m of s.children ?? []) d.appendChild(Ae(m, r, i, o));
85
+ d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n + (s.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", l.verticalAlign === "top" ? "flex-start" : l.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), s.text != null && d.append(s.text);
86
+ for (const m of s.children ?? []) d.appendChild(ke(m, r, i, o));
86
87
  return a.appendChild(d), a;
87
88
  }
88
- function Je(e, t, n, r) {
89
- return Ce(e, t).map((i) => {
90
- const o = `${z(i.widthPt * n / 72, 2)}px solid ${i.color}`, s = r.createElement("div");
89
+ function Ze(e, t, n, r) {
90
+ return Re(e, t).map((i) => {
91
+ const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, s = r.createElement("div");
91
92
  s.className = "mr-grid-edge", s.setAttribute("aria-hidden", "true");
92
93
  const a = i.kind === "h";
93
94
  return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(s), s;
94
95
  });
95
96
  }
96
- function Ze(e, t, n, r, i) {
97
+ function Qe(e, t, n, r, i) {
97
98
  const o = i.createElement("table");
98
99
  o.className = E("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
99
- const s = Te(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
100
+ const s = Ce(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
100
101
  y("contents").applyTo(a), o.appendChild(a);
101
102
  const l = e.cells.map(() => {
102
103
  const d = i.createElement("tr");
103
104
  return d.className = E("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
104
105
  });
105
106
  for (const d of s.cells)
106
- l[d.ri].appendChild(Xe(d, t, e.paddingMm ?? 0.5, n, r, i));
107
+ l[d.ri].appendChild(Je(d, t, e.paddingMm ?? 0.5, n, r, i));
107
108
  const c = i.createElement("div");
108
- return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Je(s, t, n, i)), c;
109
+ return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Ze(s, t, n, i)), c;
109
110
  }
110
- function Qe(e, t, n, r) {
111
+ function et(e, t, n, r) {
111
112
  const i = r.createElement("div");
112
113
  i.className = E("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
113
114
  for (const o of e.segments || []) {
@@ -116,17 +117,17 @@ function Qe(e, t, n, r) {
116
117
  const a = y("inline");
117
118
  if (o.style) {
118
119
  const l = o.style;
119
- a.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && a.add("font-size", `${z(H(l, t).fontSizePx, 2)}px`);
120
+ a.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && a.add("font-size", `${H(W(l, t).fontSizePx, 2)}px`);
120
121
  }
121
122
  a.applyTo(s), i.appendChild(s);
122
123
  }
123
124
  return i;
124
125
  }
125
- function et(e, t, n, r) {
126
- if (Ee(e)) {
126
+ function tt(e, t, n, r) {
127
+ if (Se(e)) {
127
128
  const i = r.createElement("div");
128
129
  i.className = E("rich", n), y("block").applyTo(i);
129
- for (const o of e.richParagraphs) i.appendChild(Qe(o, t, n, r));
130
+ for (const o of e.richParagraphs) i.appendChild(et(o, t, n, r));
130
131
  return i;
131
132
  }
132
133
  if (Array.isArray(e.lines) && e.lines.length > 0) {
@@ -140,68 +141,68 @@ function et(e, t, n, r) {
140
141
  }
141
142
  return e.text ?? "";
142
143
  }
143
- function tt(e, t, n, r) {
144
+ function nt(e, t, n, r) {
144
145
  const i = r.createElement("div");
145
146
  i.className = E("text", n);
146
147
  const o = e.style || {};
147
- return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(et(e, t, n, r)), i;
148
+ return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(tt(e, t, n, r)), i;
148
149
  }
149
- function nt(e, t, n) {
150
+ function rt(e, t, n) {
150
151
  const r = n.createElement("img");
151
152
  return r.className = E("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
152
153
  }
153
154
  function ge(e, t, n, r) {
154
155
  const i = r.createElement("div");
155
156
  i.className = E("shape", n);
156
- const o = e.style || {}, s = _(o), a = ye(o), l = `${z(s.widthPt * t / 72, 2)}px solid ${s.color}`, c = y("block");
157
+ const o = e.style || {}, s = j(o), a = Me(o), l = `${H(s.widthPt * t / 72, 2)}px solid ${s.color}`, c = y("block");
157
158
  return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", l), a.right && c.add("border-right", l), a.bottom && c.add("border-bottom", l), a.left && c.add("border-left", l)) : e.kind === "ellipse" ? (a.inner && c.add("border", l).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", l), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
158
159
  }
159
- function rt(e, t, n) {
160
+ function it(e, t, n) {
160
161
  const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = ie(e.widthMm, t), o = ie(e.heightMm, t);
161
162
  r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
162
163
  const s = n.createElementNS("http://www.w3.org/2000/svg", "line");
163
164
  s.setAttribute("x1", "0"), s.setAttribute("x2", String(i)), s.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), s.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
164
- const a = _({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
165
+ const a = j({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
165
166
  return s.setAttribute("stroke", a.color), s.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(s), r;
166
167
  }
167
- function Ae(e, t, n, r) {
168
+ function ke(e, t, n, r) {
168
169
  const i = r.createElement("div");
169
170
  i.className = `${E("comp", n)} mr-kind-${e.kind}`;
170
171
  const o = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
171
- if (Ke(o, e, t), o.applyTo(i), ee(e))
172
- return i.appendChild(nt(e, n, r)), i;
172
+ if (Xe(o, e, t), o.applyTo(i), ee(e))
173
+ return i.appendChild(rt(e, n, r)), i;
173
174
  if (e.kind === "text")
174
- return i.appendChild(tt(e, t, n, r)), i;
175
+ return i.appendChild(nt(e, t, n, r)), i;
175
176
  if (e.grid) {
176
177
  const a = ge(e, t, n, r);
177
- return a.appendChild(Ze(e.grid, e, t, n, r)), i.appendChild(a), i;
178
+ return a.appendChild(Qe(e.grid, e, t, n, r)), i.appendChild(a), i;
178
179
  }
179
180
  if (e.kind === "line" && e.lineDirection)
180
- return i.appendChild(rt(e, t, r)), i;
181
+ return i.appendChild(it(e, t, r)), i;
181
182
  if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
182
183
  return i.appendChild(ge(e, t, n, r)), i;
183
184
  const s = r.createElement("div");
184
185
  return s.className = E("unknown", n), y("block").applyTo(s), s.textContent = e.fallbackText ?? `[${e.kind}]`, s.dataset.mrUnsupported = e.kind, s.setAttribute("role", "note"), i.appendChild(s), i;
185
186
  }
186
- function it(e, t, n, r) {
187
+ function ot(e, t, n, r) {
187
188
  const i = r.createElement("div");
188
- return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${z(H(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", ve).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, s) => {
189
- const a = Ae(o, t, n, r);
189
+ return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(W(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", ye).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, s) => {
190
+ const a = ke(o, t, n, r);
190
191
  a.dataset.mrComponentIndex = String(s), i.appendChild(a);
191
192
  }), i;
192
193
  }
193
- function cn(e, t, n = {}) {
194
+ function mn(e, t, n = {}) {
194
195
  const r = n.dpi ?? 96;
195
- q(e, "dom", n);
196
+ G(e, "dom", n);
196
197
  const i = t.createElement("div");
197
198
  return i.className = E("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
198
- i.appendChild(it(o, r, n, t));
199
+ i.appendChild(ot(o, r, n, t));
199
200
  }), i;
200
201
  }
201
- function P(e) {
202
+ function R(e) {
202
203
  if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
203
204
  }
204
- const at = (e, t) => (P(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
205
+ const at = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
205
206
  const i = new Image(), o = () => {
206
207
  i.onload = null, i.onerror = null, t?.removeEventListener("abort", s);
207
208
  }, s = () => {
@@ -213,26 +214,26 @@ const at = (e, t) => (P(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.
213
214
  o(), r(new Error("Image could not be decoded for Canvas output."));
214
215
  }, t?.addEventListener("abort", s, { once: !0 }), i.src = e;
215
216
  }) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
216
- function ot(e, t, n) {
217
- return P(n), n ? new Promise((r, i) => {
217
+ function st(e, t, n) {
218
+ return R(n), n ? new Promise((r, i) => {
218
219
  const o = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
219
220
  n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", o));
220
221
  }) : e(t);
221
222
  }
222
- async function st(e, t, n) {
223
+ async function lt(e, t, n) {
223
224
  const r = /* @__PURE__ */ new Map();
224
225
  for (const i of e.components)
225
- !ee(i) || r.has(i.imageData) || r.set(i.imageData, await ot(t, i.imageData, n));
226
- return P(n), r;
226
+ !ee(i) || r.has(i.imageData) || r.set(i.imageData, await st(t, i.imageData, n));
227
+ return R(n), r;
227
228
  }
228
- function lt(e, t, n, r, i, o) {
229
+ function ct(e, t, n, r, i, o) {
229
230
  const s = t, a = s.naturalWidth ?? s.width ?? i, l = s.naturalHeight ?? s.height ?? o;
230
231
  if (a <= 0 || l <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
231
232
  const c = Math.min(i / a, o / l), d = a * c, m = l * c;
232
233
  e.drawImage(t, n + (i - d) / 2, r + (o - m) / 2, d, m);
233
234
  }
234
- function ct(e) {
235
- return Ue(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
235
+ function dt(e) {
236
+ return qe(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
236
237
  }
237
238
  const se = 96 / 25.4;
238
239
  function le(e, t = 96) {
@@ -242,34 +243,34 @@ function le(e, t = 96) {
242
243
  heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
243
244
  };
244
245
  }
245
- function ke(e, t, n, r = 64e6) {
246
+ function Ie(e, t, n, r = 64e6) {
246
247
  if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
247
248
  if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
248
249
  const i = le(e, n), o = Math.round(i.widthPx * t), s = Math.round(i.heightPx * t);
249
250
  if (!Number.isSafeInteger(o) || !Number.isSafeInteger(s) || o * s > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
250
251
  return { width: o, height: s };
251
252
  }
252
- function Ie(e, t, n, r) {
253
- const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = le(e, n), a = ke(e, t, n, r);
253
+ function $e(e, t, n, r) {
254
+ const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = le(e, n), a = Ie(e, t, n, r);
254
255
  i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${s}px`;
255
256
  const l = i.getContext("2d");
256
257
  if (!l)
257
258
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
258
259
  return l.scale(t, t), l.fillStyle = "#ffffff", l.fillRect(0, 0, o, s), { canvas: i, ctx: l };
259
260
  }
260
- function dn(e, t = 96) {
261
- return H(e, t).fontSizePx;
261
+ function hn(e, t = 96) {
262
+ return W(e, t).fontSizePx;
262
263
  }
263
- function $e(e, t, n, r, i, o, s, a = "top") {
264
+ function Ne(e, t, n, r, i, o, s, a = "top") {
264
265
  e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${s}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
265
266
  const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
266
267
  `), d = c.length * l;
267
268
  let m = r;
268
269
  a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, u) => {
269
- dt(e, h, t, n, m + u * l + t.fontSizePx * 0.8, i);
270
+ mt(e, h, t, n, m + u * l + t.fontSizePx * 0.8, i);
270
271
  }), e.textAlign = "left";
271
272
  }
272
- function dt(e, t, n, r, i, o) {
273
+ function mt(e, t, n, r, i, o) {
273
274
  const s = Array.from(t), a = n.letterSpacingPx ?? 0;
274
275
  if (!a) {
275
276
  e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
@@ -284,94 +285,94 @@ function dt(e, t, n, r, i, o) {
284
285
  e.fillText(m, c + e.measureText(d).width + h * a, i), d += m;
285
286
  });
286
287
  }
287
- function mt(e, t, n, r, i, o, s) {
288
- for (const a of Ce(t, n))
289
- e.strokeStyle = a.color, e.lineWidth = F(a.widthPt, s), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
288
+ function ht(e, t, n, r, i, o, s) {
289
+ for (const a of Re(t, n))
290
+ e.strokeStyle = a.color, e.lineWidth = O(a.widthPt, s), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
290
291
  }
291
- function ht(e, t, n, r, i, o) {
292
+ function ut(e, t, n, r, i, o) {
292
293
  e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + o)), t.bottom && (e.moveTo(n + i, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
293
294
  }
294
- function ut(e, t, n, r, i, o, s, a, l, c, d) {
295
- const m = Te(t, o / a, s / a);
295
+ function gt(e, t, n, r, i, o, s, a, l, c, d) {
296
+ const m = Ce(t, o / a, s / a);
296
297
  for (const u of m.cells) {
297
298
  const f = u.cell.style?.backgroundColor ?? n.style?.backgroundColor;
298
299
  f && (e.fillStyle = f, e.fillRect(r + u.xMm * a, i + u.yMm * a, u.widthMm * a, u.heightMm * a));
299
300
  }
300
- mt(e, m, n, r, i, a, l);
301
+ ht(e, m, n, r, i, a, l);
301
302
  const h = t.paddingMm ?? 0.5;
302
303
  for (const u of m.cells) {
303
304
  const f = u.cell.text ?? "";
304
305
  if (!f) continue;
305
- const b = Me(n.style, u.cell.style), k = H(b, l), T = Math.max(0, u.widthMm - 2 * h), C = Se(f, T, { fontSizePt: k.fontSizePt, bold: b.bold, italic: b.italic, fontFamily: b.fontFamily ?? c, letterSpacingPt: b.letterSpacing }, d).join(`
306
+ const b = xe(n.style, u.cell.style), $ = W(b, l), C = u.cell.indentMm ?? 0, S = Math.max(0, u.widthMm - 2 * h - C), A = Te(f, S, { fontSizePt: $.fontSizePt, bold: b.bold, italic: b.italic, fontFamily: b.fontFamily ?? c, letterSpacingPt: b.letterSpacing }, d).join(`
306
307
  `);
307
- $e(
308
+ Ne(
308
309
  e,
309
310
  {
310
- text: C,
311
- fontSizePx: k.fontSizePx,
311
+ text: A,
312
+ fontSizePx: $.fontSizePx,
312
313
  bold: b.bold ?? !1,
313
314
  italic: b.italic,
314
- color: xe(b, ve),
315
+ color: Ee(b, ye),
315
316
  align: b.align ?? "left",
316
317
  lineHeight: Q(b),
317
- letterSpacingPx: F(b.letterSpacing ?? 0, l)
318
+ letterSpacingPx: O(b.letterSpacing ?? 0, l)
318
319
  },
319
- r + (u.xMm + h) * a,
320
+ r + (u.xMm + h + C) * a,
320
321
  i + (u.yMm + h) * a,
321
- T * a,
322
+ S * a,
322
323
  Math.max(0, u.heightMm - 2 * h) * a,
323
324
  b.fontFamily ?? c,
324
325
  b.verticalAlign ?? "middle"
325
326
  );
326
327
  }
327
328
  }
328
- function gt(e, t, n, r, i, o, s, a, l) {
329
- const c = t.style ?? {}, d = H(c, s), m = Ee(t) ? t.richParagraphs.map((h) => h.segments.map((u) => u.text ?? u.field ?? "").join("")).join(`
329
+ function ft(e, t, n, r, i, o, s, a, l) {
330
+ const c = t.style ?? {}, d = W(c, s), m = Se(t) ? t.richParagraphs.map((h) => h.segments.map((u) => u.text ?? u.field ?? "").join("")).join(`
330
331
  `) : t.lines?.length ? t.lines.join(`
331
- `) : Se(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
332
+ `) : Te(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
332
333
  `);
333
- $e(e, {
334
+ Ne(e, {
334
335
  text: m,
335
336
  fontSizePx: d.fontSizePx,
336
337
  bold: c.bold ?? !1,
337
338
  italic: c.italic,
338
- color: xe(c),
339
+ color: Ee(c),
339
340
  align: c.align ?? "left",
340
341
  lineHeight: Q(c),
341
- letterSpacingPx: F(c.letterSpacing ?? 0, s)
342
+ letterSpacingPx: O(c.letterSpacing ?? 0, s)
342
343
  }, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
343
344
  }
344
345
  function ce(e, t, n, r, i, o, s) {
345
346
  const a = t.leftMm * n, l = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
346
347
  if (ee(t)) {
347
348
  const h = s?.get(t.imageData);
348
- h ? lt(e, h, a, l, c, d) : fe(e, t, a, l, c, d);
349
+ h ? ct(e, h, a, l, c, d) : fe(e, t, a, l, c, d);
349
350
  return;
350
351
  }
351
352
  if (t.grid) {
352
- ut(e, t.grid, t, a, l, c, d, n, r, i, o);
353
+ gt(e, t.grid, t, a, l, c, d, n, r, i, o);
353
354
  return;
354
355
  }
355
356
  switch (t.kind) {
356
357
  case "text": {
357
- gt(e, t, a, l, c, d, r, i, o);
358
+ ft(e, t, a, l, c, d, r, i, o);
358
359
  break;
359
360
  }
360
361
  case "rect": {
361
- const h = _(m), u = ye(m);
362
- m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)), u.inner && (e.strokeStyle = h.color, e.lineWidth = F(h.widthPt, r), ht(e, u, a, l, c, d));
362
+ const h = j(m), u = Me(m);
363
+ m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)), u.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), ut(e, u, a, l, c, d));
363
364
  break;
364
365
  }
365
366
  case "line": {
366
- const h = _({ ...m, borderColor: m.lineColor ?? m.borderColor });
367
- e.strokeStyle = h.color, e.lineWidth = F(h.widthPt, r), e.beginPath();
367
+ const h = j({ ...m, borderColor: m.lineColor ?? m.borderColor });
368
+ e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), e.beginPath();
368
369
  const u = t.lineDirection === "up" ? l + d : t.lineDirection === "down" ? l : l + d / 2, f = t.lineDirection === "up" ? l : t.lineDirection === "down" ? l + d : l + d / 2;
369
370
  e.moveTo(a, u), e.lineTo(a + c, f), e.stroke();
370
371
  break;
371
372
  }
372
373
  case "ellipse": {
373
- const h = _(m);
374
- e.strokeStyle = h.color, e.lineWidth = F(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
374
+ const h = j(m);
375
+ e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
375
376
  break;
376
377
  }
377
378
  default:
@@ -382,30 +383,30 @@ function ce(e, t, n, r, i, o, s) {
382
383
  function fe(e, t, n, r, i, o) {
383
384
  e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
384
385
  }
385
- async function mn(e, t = {}) {
386
+ async function un(e, t = {}) {
386
387
  if (typeof document > "u")
387
388
  throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
388
389
  const { format: n = "png", quality: r = 0.92, ...i } = t;
389
390
  if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
390
391
  if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
391
- P(t.signal);
392
- const o = await oe(e, { ...t, format: "canvas" });
392
+ R(t.signal);
393
+ const o = await ae(e, { ...t, format: "canvas" });
393
394
  e = o.plan;
394
- const s = [...o.diagnostics, ...q(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", l = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
395
+ const s = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", l = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
395
396
  for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
396
- P(t.signal);
397
- const m = await Ne(e.pages[d], d, i, s);
397
+ R(t.signal);
398
+ const m = await Le(e.pages[d], d, i, s);
398
399
  try {
399
- l.push(await ft(m, a, r, t.signal));
400
+ l.push(await pt(m, a, r, t.signal));
400
401
  } finally {
401
402
  m.width = 0, m.height = 0;
402
403
  }
403
- await Ge(t, l.length, c - Math.max(0, t.start ?? 0) + 1);
404
+ await Ve(t, l.length, c - Math.max(0, t.start ?? 0) + 1);
404
405
  }
405
- return P(t.signal), { blobs: l, diagnostics: s };
406
+ return R(t.signal), { blobs: l, diagnostics: s };
406
407
  }
407
- function ft(e, t, n, r) {
408
- return P(r), new Promise((i, o) => {
408
+ function pt(e, t, n, r) {
409
+ return R(r), new Promise((i, o) => {
409
410
  const s = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
410
411
  r?.addEventListener("abort", s, { once: !0 });
411
412
  try {
@@ -417,23 +418,23 @@ function ft(e, t, n, r) {
417
418
  }
418
419
  });
419
420
  }
420
- function hn(e, t = {}) {
421
- if (P(t.signal), typeof document > "u")
421
+ function gn(e, t = {}) {
422
+ if (R(t.signal), typeof document > "u")
422
423
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
423
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? ae, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = q(e, "canvas", t), m = pt(e, a, l);
424
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = wt(e, a, l);
424
425
  for (const h of m)
425
426
  Pe(h, t), d.push(h);
426
- if (t.fidelity === "strict" && m.length) throw new qe(d);
427
+ if (t.fidelity === "strict" && m.length) throw new Ue(d);
427
428
  for (let h = a; h <= l; h++) {
428
- P(t.signal);
429
- const u = e.pages[h], { canvas: f, ctx: b } = Ie(u, n, r, t.maxCanvasPixels);
430
- for (const k of u.components)
431
- ce(b, k, i, r, o, s);
429
+ R(t.signal);
430
+ const u = e.pages[h], { canvas: f, ctx: b } = $e(u, n, r, t.maxCanvasPixels);
431
+ for (const $ of u.components)
432
+ ce(b, $, i, r, o, s);
432
433
  c.push(f);
433
434
  }
434
435
  return { canvases: c, diagnostics: d };
435
436
  }
436
- function pt(e, t, n) {
437
+ function wt(e, t, n) {
437
438
  return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, s) => ee(o) ? [{
438
439
  code: "async-image-required",
439
440
  severity: "warning",
@@ -445,26 +446,26 @@ function pt(e, t, n) {
445
446
  message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
446
447
  }] : []));
447
448
  }
448
- async function un(e, t = {}) {
449
+ async function fn(e, t = {}) {
449
450
  if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
450
- P(t.signal);
451
- const n = await oe(e, { ...t, format: "canvas" });
451
+ R(t.signal);
452
+ const n = await ae(e, { ...t, format: "canvas" });
452
453
  e = n.plan;
453
- const r = [...n.diagnostics, ...q(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
454
+ const r = [...n.diagnostics, ...G(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
454
455
  for (let s = Math.max(0, t.start ?? 0); s <= o; s++)
455
- i.push(await Ne(e.pages[s], s, t, r));
456
+ i.push(await Le(e.pages[s], s, t, r));
456
457
  return { canvases: i, diagnostics: r };
457
458
  }
458
- async function Ne(e, t, n, r) {
459
- const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await Le(e, t, n, r);
460
- P(n.signal);
461
- const { canvas: l, ctx: c } = Ie(e, i, o, n.maxCanvasPixels);
462
- for (const d of e.components) ce(c, d, o / 25.4, o, s, n.measurer ?? ae, a);
459
+ async function Le(e, t, n, r) {
460
+ const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await De(e, t, n, r);
461
+ R(n.signal);
462
+ const { canvas: l, ctx: c } = $e(e, i, o, n.maxCanvasPixels);
463
+ for (const d of e.components) ce(c, d, o / 25.4, o, s, n.measurer ?? oe, a);
463
464
  return l;
464
465
  }
465
- async function Le(e, t, n, r) {
466
+ async function De(e, t, n, r) {
466
467
  const i = n.imageLoader ?? at;
467
- return st(e, async (o, s) => {
468
+ return lt(e, async (o, s) => {
468
469
  try {
469
470
  return await i(o, s);
470
471
  } catch (a) {
@@ -474,102 +475,102 @@ async function Le(e, t, n, r) {
474
475
  }
475
476
  }, n.signal);
476
477
  }
477
- function gn(e, t = {}) {
478
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? ae, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((g) => g.pageHeightMm * i), m = Math.max(1, ...e.pages.map((g) => g.pageWidthMm * i)), h = { start: 0, end: -1 };
479
- let u = null, f = null, b = null, k = null, T = [], C = 0, N = [], G = 0, W = new AbortController();
478
+ function pn(e, t = {}) {
479
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((g) => g.pageHeightMm * i), m = Math.max(1, ...e.pages.map((g) => g.pageWidthMm * i)), h = { start: 0, end: -1 };
480
+ let u = null, f = null, b = null, $ = null, C = [], S = 0, A = [], U = 0, _ = new AbortController();
480
481
  const me = [];
481
- function Oe() {
482
+ function ze() {
482
483
  const g = u;
483
- g.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), k = document.createElement("div"), f.appendChild(b), T = [];
484
+ g.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), $ = document.createElement("div"), f.appendChild(b), C = [];
484
485
  const M = Math.min(e.pages.length, 3 + a * 2);
485
- for (let L = 0; L < M; L++) {
486
+ for (let D = 0; D < M; D++) {
486
487
  const v = document.createElement("div");
487
- v.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(v), T.push(v);
488
+ v.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(v), C.push(v);
488
489
  }
489
- f.appendChild(k), g.appendChild(f);
490
+ f.appendChild($), g.appendChild(f);
490
491
  }
491
- async function ze(g, M) {
492
- const L = G, v = await oe(e, { ...t, signal: W.signal, format: "canvas", start: M, end: M });
492
+ async function He(g, M) {
493
+ const D = U, v = await ae(e, { ...t, signal: _.signal, format: "canvas", start: M, end: M });
493
494
  me.push(...v.diagnostics);
494
- const S = v.plan.pages[M], Y = await Le(S, M, { ...t, signal: W.signal }, me);
495
- if (L !== G || !u) return;
496
- const { widthPx: ne, heightPx: re } = le(S, r);
497
- let I = g.firstElementChild;
498
- (!I || I.tagName !== "CANVAS") && (I = document.createElement("canvas"), g.innerHTML = "", g.appendChild(I));
499
- const ue = ke(S, n, r, t.maxCanvasPixels);
500
- I.width = ue.width, I.height = ue.height, I.style.width = `${ne}px`, I.style.height = `${re}px`;
501
- const D = I.getContext("2d");
502
- if (D) {
503
- D.setTransform(1, 0, 0, 1, 0, 0), D.scale(n, n), D.fillStyle = "#ffffff", D.fillRect(0, 0, ne, re);
504
- for (const We of S.components)
505
- ce(D, We, i, r, o, s, Y);
506
- I.dataset.canvasPage = String(M), g.style.height = `${re}px`, g.style.width = `${ne}px`;
495
+ const T = v.plan.pages[M], Y = await De(T, M, { ...t, signal: _.signal }, me);
496
+ if (D !== U || !u) return;
497
+ const { widthPx: ne, heightPx: re } = le(T, r);
498
+ let N = g.firstElementChild;
499
+ (!N || N.tagName !== "CANVAS") && (N = document.createElement("canvas"), g.innerHTML = "", g.appendChild(N));
500
+ const ue = Ie(T, n, r, t.maxCanvasPixels);
501
+ N.width = ue.width, N.height = ue.height, N.style.width = `${ne}px`, N.style.height = `${re}px`;
502
+ const F = N.getContext("2d");
503
+ if (F) {
504
+ F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ne, re);
505
+ for (const _e of T.components)
506
+ ce(F, _e, i, r, o, s, Y);
507
+ N.dataset.canvasPage = String(M), g.style.height = `${re}px`, g.style.width = `${ne}px`;
507
508
  }
508
509
  }
509
- function He(g) {
510
- G++, h.start = g.start, h.end = g.end, b.style.height = `${g.start * l + d.slice(0, g.start).reduce((v, S) => v + S, 0)}px`;
510
+ function We(g) {
511
+ U++, h.start = g.start, h.end = g.end, b.style.height = `${g.start * l + d.slice(0, g.start).reduce((v, T) => v + T, 0)}px`;
511
512
  const M = e.pages.length - 1 - g.end;
512
- k.style.height = `${M * l + d.slice(g.end + 1).reduce((v, S) => v + S, 0)}px`;
513
- const L = g.end - g.start + 1;
514
- T.forEach((v, S) => {
515
- if (S < L) {
513
+ $.style.height = `${M * l + d.slice(g.end + 1).reduce((v, T) => v + T, 0)}px`;
514
+ const D = g.end - g.start + 1;
515
+ C.forEach((v, T) => {
516
+ if (T < D) {
516
517
  v.style.display = "";
517
- const Y = g.start + S;
518
+ const Y = g.start + T;
518
519
  v.style.height = `${d[Y] ?? 0}px`;
519
520
  } else
520
521
  v.style.display = "none";
521
- }), N = [];
522
+ }), A = [];
522
523
  for (let v = g.start; v <= g.end; v++) {
523
- const S = T[v - g.start];
524
- if (!S) continue;
525
- S.firstElementChild?.dataset?.canvasPage !== String(v) && N.push(v);
524
+ const T = C[v - g.start];
525
+ if (!T) continue;
526
+ T.firstElementChild?.dataset?.canvasPage !== String(v) && A.push(v);
526
527
  }
527
528
  te();
528
529
  }
529
530
  function te() {
530
- C || N.length === 0 || (C = requestAnimationFrame(() => {
531
- C = 0;
531
+ S || A.length === 0 || (S = requestAnimationFrame(() => {
532
+ S = 0;
532
533
  let g = Math.max(1, c);
533
- for (; N.length > 0 && g-- > 0; ) {
534
- const M = N.shift(), L = T[M - h.start];
535
- L && ze(L, M).catch(() => {
534
+ for (; A.length > 0 && g-- > 0; ) {
535
+ const M = A.shift(), D = C[M - h.start];
536
+ D && He(D, M).catch(() => {
536
537
  });
537
538
  }
538
- N.length > 0 && te();
539
+ A.length > 0 && te();
539
540
  }));
540
541
  }
541
- function U() {
542
- C || (C = requestAnimationFrame(() => {
543
- C = 0;
544
- const g = u, M = ct({
542
+ function V() {
543
+ S || (S = requestAnimationFrame(() => {
544
+ S = 0;
545
+ const g = u, M = dt({
545
546
  pageHeightsPx: d,
546
547
  viewportHeightPx: g.clientHeight,
547
548
  scrollTopPx: g.scrollTop,
548
549
  overscan: a,
549
550
  gapPx: l
550
551
  });
551
- M.start !== h.start || M.end !== h.end ? He(M) : te();
552
+ M.start !== h.start || M.end !== h.end ? We(M) : te();
552
553
  }));
553
554
  }
554
- let V = null;
555
+ let q = null;
555
556
  return {
556
557
  attach(g) {
557
558
  if (typeof document > "u")
558
559
  throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
559
- P(t.signal), W = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), q(e, "canvas", t), u = g, Oe(), g.addEventListener("scroll", U, { passive: !0 }), typeof ResizeObserver < "u" && (V = new ResizeObserver(() => U()), V.observe(g)), U();
560
+ R(t.signal), _ = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), G(e, "canvas", t), u = g, ze(), g.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(g)), V();
560
561
  },
561
562
  destroy() {
562
- G++, W.abort(), t.signal?.removeEventListener("abort", he), C && cancelAnimationFrame(C), C = 0, V?.disconnect(), V = null, u?.removeEventListener("scroll", U), N = [], f?.remove(), u = null;
563
+ U++, _.abort(), t.signal?.removeEventListener("abort", he), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, u?.removeEventListener("scroll", V), A = [], f?.remove(), u = null;
563
564
  },
564
565
  window() {
565
566
  return { ...h };
566
567
  }
567
568
  };
568
569
  function he() {
569
- W.abort(t.signal?.reason);
570
+ _.abort(t.signal?.reason);
570
571
  }
571
572
  }
572
- function De(e, t, n) {
573
+ function Fe(e, t, n) {
573
574
  let r, i;
574
575
  if (typeof e == "string") {
575
576
  const o = K[e];
@@ -578,7 +579,7 @@ function De(e, t, n) {
578
579
  } else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
579
580
  return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
580
581
  }
581
- class wt {
582
+ class bt {
582
583
  constructor() {
583
584
  this.pages = [], this.pending = null, this.templateParams = void 0;
584
585
  }
@@ -607,12 +608,12 @@ class wt {
607
608
  */
608
609
  page(t = "a4", n = {}, r) {
609
610
  this.collect();
610
- const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: s, heightMm: a } = De(
611
+ const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: s, heightMm: a } = Fe(
611
612
  t,
612
613
  typeof n == "number" ? n : void 0,
613
614
  o.landscape
614
615
  ), l = o.margins ?? {};
615
- return this.pending = new bt(this, {
616
+ return this.pending = new vt(this, {
616
617
  widthMm: s,
617
618
  heightMm: a,
618
619
  marginTopMm: l.marginTopMm ?? 10,
@@ -630,7 +631,7 @@ class wt {
630
631
  return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
631
632
  }
632
633
  }
633
- class bt {
634
+ class vt {
634
635
  constructor(t, n) {
635
636
  this.parent = t, this.page = n, this.components = [];
636
637
  }
@@ -699,10 +700,10 @@ class bt {
699
700
  return this.done().build();
700
701
  }
701
702
  }
702
- function fn() {
703
- return new wt();
703
+ function wn() {
704
+ return new bt();
704
705
  }
705
- function pn(e, t = {}) {
706
+ function bn(e, t = {}) {
706
707
  return je([], e), e.fields.map((n) => ({
707
708
  field: n.field,
708
709
  header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
@@ -710,7 +711,7 @@ function pn(e, t = {}) {
710
711
  ...t[n.field]
711
712
  }));
712
713
  }
713
- function R(e, t, n = !1) {
714
+ function P(e, t, n = !1) {
714
715
  if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
715
716
  throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
716
717
  }
@@ -718,7 +719,7 @@ function X(e, t, n) {
718
719
  if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
719
720
  throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
720
721
  }
721
- function vt(e) {
722
+ function yt(e) {
722
723
  const t = e.layout ?? "page";
723
724
  if (t !== "page" && t !== "wide")
724
725
  throw new Error("layout 必须是 page 或 wide");
@@ -727,18 +728,18 @@ function vt(e) {
727
728
  if (t !== "wide" && e.columnWidthMm !== void 0)
728
729
  throw new Error('columnWidthMm 仅适用于 layout: "wide"');
729
730
  const n = e.columnWidthMm ?? 30;
730
- return R(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
731
+ return P(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
731
732
  }
732
- function yt(e) {
733
+ function Mt(e) {
733
734
  const t = e.paper === void 0 ? "a4" : e.paper;
734
735
  if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
735
736
  throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
736
737
  if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(K, t))
737
738
  throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(K).join("/")})`);
738
- const n = De(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
739
- return R(r, "纸张 widthMm"), R(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
739
+ const n = Fe(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
740
+ return P(r, "纸张 widthMm"), P(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
740
741
  }
741
- function Mt(e) {
742
+ function xt(e) {
742
743
  if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
743
744
  throw new Error("margins 必须是页边距对象");
744
745
  const t = e.margins ?? {}, n = {
@@ -747,44 +748,44 @@ function Mt(e) {
747
748
  marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
748
749
  marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
749
750
  };
750
- for (const [r, i] of Object.entries(n)) R(i, r, !0);
751
+ for (const [r, i] of Object.entries(n)) P(i, r, !0);
751
752
  return n;
752
753
  }
753
- function xt(e, t) {
754
+ function Et(e, t) {
754
755
  const n = e.dataset === void 0 ? "detail" : e.dataset;
755
756
  if (typeof n != "string" || !n.trim())
756
757
  throw new Error("dataset 必须是非空字符串");
757
758
  if (e.title !== void 0 && typeof e.title != "string")
758
759
  throw new Error("title 必须是字符串");
759
760
  const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
760
- R(r, "titleHeightMm"), R(i, "titleGapMm", !0);
761
+ P(r, "titleHeightMm"), P(i, "titleGapMm", !0);
761
762
  const o = e.title !== void 0 && e.title.length > 0, s = o ? r + i : 0;
762
763
  if (s >= t)
763
764
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
764
765
  return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: s };
765
766
  }
766
- function Et(e) {
767
+ function St(e) {
767
768
  if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
768
769
  throw new Error("listOptions 必须是列表配置对象");
769
770
  const t = e.listOptions ?? {};
770
771
  X(t.align, "listOptions.align", !0), X(t.headerAlign, "listOptions.headerAlign", !1);
771
772
  for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
772
773
  const r = t[n];
773
- r !== void 0 && R(r, `listOptions.${n}`, n === "paddingMm");
774
+ r !== void 0 && P(r, `listOptions.${n}`, n === "paddingMm");
774
775
  }
775
776
  return t;
776
777
  }
777
- function St(e) {
778
+ function Tt(e) {
778
779
  let t = 0, n = 0;
779
780
  for (const [r, i] of e.entries()) {
780
781
  if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
781
782
  throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
782
- X(i.align, `columns[${r}].align`, !0), X(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && R(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (R(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
783
+ X(i.align, `columns[${r}].align`, !0), X(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && P(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (P(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
783
784
  }
784
785
  return { fixedWidthMm: t, maxFlex: n };
785
786
  }
786
- function Tt(e, t, n, r) {
787
- const { fixedWidthMm: i, maxFlex: o } = St(e.columns);
787
+ function Ct(e, t, n, r) {
788
+ const { fixedWidthMm: i, maxFlex: o } = Tt(e.columns);
788
789
  if (t === "page" && i > r)
789
790
  throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
790
791
  const s = r - i;
@@ -793,25 +794,25 @@ function Tt(e, t, n, r) {
793
794
  const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
794
795
  return { columns: e.columns.map(({ widthMm: c, flex: d, ...m }, h) => {
795
796
  const u = c ?? (t === "wide" ? n * (d ?? 1) : s * ((d ?? 1) / o) / a);
796
- return R(u, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: u };
797
+ return P(u, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: u };
797
798
  }), fixedWidthMm: i, maxFlex: o };
798
799
  }
799
- function wn(e) {
800
+ function vn(e) {
800
801
  if (!e || typeof e != "object")
801
802
  throw new Error("标准明细模板需要 options 对象");
802
803
  if (!Array.isArray(e.columns) || e.columns.length === 0)
803
804
  throw new Error("columns 至少需要一列");
804
- const { layout: t, columnWidthMm: n } = vt(e), r = yt(e);
805
+ const { layout: t, columnWidthMm: n } = yt(e), r = Mt(e);
805
806
  let i = r.widthMm;
806
- const o = r.heightMm, s = Mt(e);
807
+ const o = r.heightMm, s = xt(e);
807
808
  let a = i - s.marginLeftMm - s.marginRightMm;
808
809
  const l = o - s.marginTopMm - s.marginBottomMm;
809
810
  if (t === "page" && a <= 0 || l <= 0)
810
811
  throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
811
- const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = xt(e, l), u = Et(e), { columns: f, fixedWidthMm: b, maxFlex: k } = Tt(e, t, n, a);
812
- t === "wide" && (a = f.reduce((C, N) => C + N.widthMm, 0), R(a, "宽表总列宽"), i = a + s.marginLeftMm + s.marginRightMm, R(i, "宽表总宽度"));
813
- const T = { widthMm: i, heightMm: o, ...s, components: [], ...t === "wide" ? { layout: t } : {} };
814
- return m && T.components.push({
812
+ const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Et(e, l), u = St(e), { columns: f, fixedWidthMm: b, maxFlex: $ } = Ct(e, t, n, a);
813
+ t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a + s.marginLeftMm + s.marginRightMm, P(i, "宽表总宽度"));
814
+ const C = { widthMm: i, heightMm: o, ...s, components: [], ...t === "wide" ? { layout: t } : {} };
815
+ return m && C.components.push({
815
816
  kind: "text",
816
817
  text: e.title,
817
818
  leftMm: s.marginLeftMm,
@@ -819,7 +820,7 @@ function wn(e) {
819
820
  widthMm: a,
820
821
  heightMm: d,
821
822
  style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
822
- }), T.components.push({
823
+ }), C.components.push({
823
824
  align: "auto",
824
825
  headerAlign: "center",
825
826
  ...u,
@@ -830,18 +831,18 @@ function wn(e) {
830
831
  columns: f,
831
832
  leftMm: s.marginLeftMm,
832
833
  topMm: s.marginTopMm + h,
833
- widthMm: t === "wide" || k > 0 ? a : b
834
- }), e.params === void 0 ? { pages: [T] } : { params: e.params, pages: [T] };
834
+ widthMm: t === "wide" || $ > 0 ? a : b
835
+ }), e.params === void 0 ? { pages: [C] } : { params: e.params, pages: [C] };
835
836
  }
836
- function bn(e) {
837
+ function yn(e) {
837
838
  return e;
838
839
  }
839
- class $ extends Error {
840
+ class L extends Error {
840
841
  constructor(t, n) {
841
842
  super(n), this.code = t, this.name = "ReportTemplateStoreError";
842
843
  }
843
844
  }
844
- function A(e) {
845
+ function k(e) {
845
846
  return JSON.parse(JSON.stringify(e));
846
847
  }
847
848
  function x(e) {
@@ -851,49 +852,49 @@ function x(e) {
851
852
  }
852
853
  function pe(e) {
853
854
  const t = e ? Number(e.revision) : 0;
854
- if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new $("history", "修订号无效或已达上限");
855
+ if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
855
856
  return String(t + 1);
856
857
  }
857
- function vn(e, t = {}) {
858
+ function Mn(e, t = {}) {
858
859
  const n = async (s, a) => {
859
860
  x(a);
860
861
  const l = await e.read(s, a);
861
- return x(a), l ? A(l) : void 0;
862
+ return x(a), l ? k(l) : void 0;
862
863
  }, r = async (s, a) => {
863
864
  const l = await n(s, a.signal);
864
- if ((l?.revision ?? null) !== a.expectedRevision) throw new $("conflict", "模板已变化,请重新读取后提交");
865
+ if ((l?.revision ?? null) !== a.expectedRevision) throw new L("conflict", "模板已变化,请重新读取后提交");
865
866
  return l;
866
867
  }, i = async (s, a, l) => {
867
- if (x(a.signal), !await e.compareAndSwap(s.id, a.expectedRevision, A(s), { signal: a.signal, ...l ? { publication: A(l) } : {} })) throw new $("conflict", "模板已被其他请求更新");
868
- return A(s);
868
+ if (x(a.signal), !await e.compareAndSwap(s.id, a.expectedRevision, k(s), { signal: a.signal, ...l ? { publication: k(l) } : {} })) throw new L("conflict", "模板已被其他请求更新");
869
+ return k(s);
869
870
  }, o = async (s, a, l, c) => {
870
871
  if (t.beforePublish) {
871
872
  x(l.signal);
872
- const u = await t.beforePublish({ document: j(a), previous: s.published ? j(s.published) : void 0, signal: l.signal });
873
- if (!u || u.ok !== !0) throw new $("review", u?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
873
+ const u = await t.beforePublish({ document: I(a), previous: s.published ? I(s.published) : void 0, signal: l.signal });
874
+ if (!u || u.ok !== !0) throw new L("review", u?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
874
875
  x(l.signal);
875
876
  }
876
- const d = pe(s), m = j({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
877
+ const d = pe(s), m = I({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
877
878
  return c !== void 0 && (h.restoredFrom = c), i({ id: s.id, revision: d, publishedRevision: d, published: m }, l, h);
878
879
  };
879
880
  return {
880
881
  list: async (s) => {
881
882
  x(s);
882
883
  const a = await e.list(s);
883
- return x(s), A(a);
884
+ return x(s), k(a);
884
885
  },
885
886
  get: async (s, a = {}) => {
886
887
  const l = await n(s, a.signal), c = a.draft ? l?.draft : l?.published;
887
- return c ? j(c) : void 0;
888
+ return c ? I(c) : void 0;
888
889
  },
889
890
  history: async (s, a) => {
890
891
  x(a);
891
892
  const l = await e.history(s, a);
892
- return x(a), A(l);
893
+ return x(a), k(l);
893
894
  },
894
895
  saveDraft: async (s, a) => {
895
896
  a = { ...a }, x(a.signal);
896
- const l = j(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d = pe(c);
897
+ const l = I(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d = pe(c);
897
898
  return i({
898
899
  id: l.id,
899
900
  revision: d,
@@ -904,58 +905,103 @@ function vn(e, t = {}) {
904
905
  publish: async (s, a) => {
905
906
  a = { ...a };
906
907
  const l = await r(s, a);
907
- if (!l) throw new $("missing", "模板不存在");
908
- if (!l.draft) throw new $("draft", "没有可发布的草稿");
908
+ if (!l) throw new L("missing", "模板不存在");
909
+ if (!l.draft) throw new L("draft", "没有可发布的草稿");
909
910
  return o(l, l.draft, a);
910
911
  },
911
912
  rollback: async (s, a, l) => {
912
913
  l = { ...l };
913
914
  const c = await r(s, l);
914
- if (!c) throw new $("missing", "模板不存在");
915
+ if (!c) throw new L("missing", "模板不存在");
915
916
  x(l.signal);
916
917
  const d = await e.getVersion(s, a, l.signal);
917
- if (!d) throw new $("history", "历史修订不存在");
918
+ if (!d) throw new L("history", "历史修订不存在");
918
919
  return o(c, d.document, l, a);
919
920
  }
920
921
  };
921
922
  }
922
- function yn() {
923
+ function xn() {
923
924
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
924
925
  return {
925
926
  read: async (n, r) => {
926
927
  x(r);
927
928
  const i = e.get(n);
928
- return i ? A(i) : void 0;
929
+ return i ? k(i) : void 0;
929
930
  },
930
931
  list: async (n) => (x(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: o }) => ({ id: r, revision: i, ...o ? { publishedRevision: o } : {} }))),
931
- history: async (n, r) => (x(r), Array.from(t.get(n)?.values() ?? [], (i) => A(i))),
932
+ history: async (n, r) => (x(r), Array.from(t.get(n)?.values() ?? [], (i) => k(i))),
932
933
  getVersion: async (n, r, i) => {
933
934
  x(i);
934
935
  const o = t.get(n)?.get(r);
935
- return o ? A(o) : void 0;
936
+ return o ? k(o) : void 0;
936
937
  },
937
938
  compareAndSwap: async (n, r, i, o) => {
938
939
  if (x(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
939
- if (i.id !== n) throw new $("history", "状态 ID 与存储 ID 不一致");
940
- const s = A(i), a = o.publication;
940
+ if (i.id !== n) throw new L("history", "状态 ID 与存储 ID 不一致");
941
+ const s = k(i), a = o.publication;
941
942
  if (a) {
942
943
  const l = t.get(n) ?? /* @__PURE__ */ new Map();
943
- if (l.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new $("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
944
- l.set(a.revision, A(a)), t.set(n, l);
944
+ if (l.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new L("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
945
+ l.set(a.revision, k(a)), t.set(n, l);
945
946
  }
946
947
  return e.set(n, s), !0;
947
948
  }
948
949
  };
949
950
  }
950
- function Mn(e) {
951
+ function Rt(e, t) {
952
+ const n = e.publishedRevision ?? e.published?.revision;
953
+ for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
954
+ if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
955
+ if (e.published && (e.published.id !== t.id || e.published.revision !== n)) throw new TypeError("发布文档身份或修订不一致");
956
+ if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
957
+ return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
958
+ }
959
+ function En(e, t) {
960
+ const n = I(e);
961
+ if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
962
+ const { revision: r, ...i } = n;
963
+ return I({ ...i, id: t.id, name: t.name });
964
+ }
965
+ function Sn(e) {
966
+ if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
967
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
968
+ for (const i of e) {
969
+ const o = I(i.document);
970
+ if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
971
+ if (i.category !== void 0 && (typeof i.category != "string" || i.category.length > 128) || i.tags !== void 0 && (!Array.isArray(i.tags) || i.tags.length > 20 || i.tags.some((c) => typeof c != "string" || c.length > 128))) throw new TypeError("模板分类和标签无效");
972
+ const s = Rt(i, o), { template: a, ...l } = o;
973
+ t.set(o.id, o), i.published ? n.set(o.id, I(i.published)) : s.publishedRevision && n.set(o.id, I(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
974
+ }
975
+ return r.sort((i, o) => i.id < o.id ? -1 : 1), {
976
+ search: async (i) => {
977
+ we(i.signal);
978
+ const o = i.limit ?? 30;
979
+ if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
980
+ const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((d) => d?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
981
+ for (const c of r) c.category && l.set(c.category, (l.get(c.category) ?? 0) + 1);
982
+ return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, d]) => ({ id: c, label: c, count: d })) }));
983
+ },
984
+ get: async (i, o) => {
985
+ we(o.signal);
986
+ const s = o.mode === "published" ? n.get(i) : t.get(i);
987
+ return s ? I(s) : void 0;
988
+ }
989
+ };
990
+ }
991
+ function we(e) {
992
+ if (!e?.aborted) return;
993
+ const t = new Error("模板目录操作已取消");
994
+ throw t.name = "AbortError", t;
995
+ }
996
+ function Tn(e) {
951
997
  return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
952
998
  `);
953
999
  }
954
- function Ct(e, t) {
1000
+ function Pt(e, t) {
955
1001
  const n = e[e.length - 1];
956
1002
  e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
957
1003
  }
958
- function xn(e, t = 1e4) {
1004
+ function Cn(e, t = 1e4) {
959
1005
  if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
960
1006
  const n = [[]];
961
1007
  let r = "", i = !1, o = !1, s = 0;
@@ -995,9 +1041,9 @@ function xn(e, t = 1e4) {
995
1041
  r += c;
996
1042
  }
997
1043
  if (i) throw new Error("Unclosed clipboard quote");
998
- return a(), Ct(n, e), n;
1044
+ return a(), Pt(n, e), n;
999
1045
  }
1000
- class Pt extends Error {
1046
+ class At extends Error {
1001
1047
  constructor(t, n, r) {
1002
1048
  const i = typeof n.label == "string" ? n.label : "单元格", o = {
1003
1049
  definition: `${i}的编辑器配置无效`,
@@ -1014,53 +1060,53 @@ class Pt extends Error {
1014
1060
  }
1015
1061
  }
1016
1062
  function p(e, t, n) {
1017
- throw new Pt(t, e, n);
1063
+ throw new At(t, e, n);
1018
1064
  }
1019
- function Fe(e) {
1065
+ function Oe(e) {
1020
1066
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
1021
1067
  const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
1022
1068
  return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
1023
1069
  }
1024
- function Rt(e) {
1070
+ function kt(e) {
1025
1071
  const [t = "", n = "0"] = String(e).toLowerCase().split("e");
1026
1072
  return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
1027
1073
  }
1028
- function At(e, t) {
1029
- e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && Rt(t) > e.precision && p(e, "precision", e.precision);
1074
+ function It(e, t) {
1075
+ e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && kt(t) > e.precision && p(e, "precision", e.precision);
1030
1076
  }
1031
- function kt(e, t) {
1032
- Fe(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
1077
+ function $t(e, t) {
1078
+ Oe(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
1033
1079
  }
1034
- function It(e) {
1080
+ function Nt(e) {
1035
1081
  [e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && p(e, "definition");
1036
1082
  }
1037
- function $t(e) {
1038
- [e.min, e.max].some((t) => t !== void 0 && !Fe(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
1083
+ function Lt(e) {
1084
+ [e.min, e.max].some((t) => t !== void 0 && !Oe(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
1039
1085
  }
1040
- function Nt(e, t) {
1086
+ function Dt(e, t) {
1041
1087
  (!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
1042
1088
  const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
1043
1089
  for (const i of t.options)
1044
1090
  (!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && p(t, "definition"), i.label !== void 0 && typeof i.label != "string" && p(t, "definition"), r.has(i.value) && p(t, "definition"), r.add(i.value);
1045
1091
  }
1046
- function Lt(e) {
1092
+ function Ft(e) {
1047
1093
  e.required !== void 0 && typeof e.required != "boolean" && p(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition");
1048
1094
  }
1049
- function Dt(e, t) {
1050
- (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Lt(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && It(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && $t(t), t.type === "enum" && Nt(e, t);
1095
+ function Ot(e, t) {
1096
+ (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Ft(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && Nt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Lt(t), t.type === "enum" && Dt(e, t);
1051
1097
  }
1052
- function En(e, t, n) {
1053
- if (!e.editable) throw new _e("readonly");
1054
- n && Dt(e, n);
1055
- const r = Be(e, t);
1056
- return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && At(n, r), n.type === "date" && kt(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
1098
+ function Rn(e, t, n) {
1099
+ if (!e.editable) throw new Be("readonly");
1100
+ n && Ot(e, n);
1101
+ const r = Ge(e, t);
1102
+ return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && It(n, r), n.type === "date" && $t(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
1057
1103
  }
1058
1104
  class w extends Error {
1059
1105
  constructor(t) {
1060
1106
  super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
1061
1107
  }
1062
1108
  }
1063
- function O(e) {
1109
+ function z(e) {
1064
1110
  if (!e?.aborted) return;
1065
1111
  const t = new Error("Calculation cancelled");
1066
1112
  throw t.name = "AbortError", t;
@@ -1068,12 +1114,12 @@ function O(e) {
1068
1114
  async function J(e, t = 1) {
1069
1115
  const n = Math.floor(e.scanned / 2048);
1070
1116
  if (e.scanned += t, e.scanned > e.maxScanned) throw new w("limit");
1071
- O(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), O(e.signal));
1117
+ z(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), z(e.signal));
1072
1118
  }
1073
1119
  function de(e) {
1074
1120
  return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
1075
1121
  }
1076
- function we(e, t, n) {
1122
+ function be(e, t, n) {
1077
1123
  if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
1078
1124
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1079
1125
  if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
@@ -1087,53 +1133,53 @@ function we(e, t, n) {
1087
1133
  }
1088
1134
  return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
1089
1135
  }
1090
- function Ft(e, t, n) {
1091
- const r = we(e, t.anchor, t.anchor), i = we(e, t.focus, t.anchor);
1136
+ function zt(e, t, n) {
1137
+ const r = be(e, t.anchor, t.anchor), i = be(e, t.focus, t.anchor);
1092
1138
  if (r.grid !== i.grid) throw new w("selection");
1093
1139
  const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
1094
1140
  if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
1095
1141
  return { grid: r.grid, rowStart: Math.min(r.row, i.row), rowEnd: Math.max(r.row, i.row), columnStart: Math.min(r.column, i.column), columnEnd: Math.max(r.column, i.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
1096
1142
  }
1097
- function Ot(e) {
1143
+ function Ht(e) {
1098
1144
  if (!e) return !1;
1099
1145
  const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
1100
1146
  return /[ymdhs]/i.test(t);
1101
1147
  }
1102
- function zt(e) {
1103
- if (e.valueType === "text" || e.valueType === "boolean" || Ot(e.numberFormat)) return null;
1148
+ function Wt(e) {
1149
+ if (e.valueType === "text" || e.valueType === "boolean" || Ht(e.numberFormat)) return null;
1104
1150
  const t = e.value;
1105
1151
  if (typeof t != "number" || !Number.isFinite(t)) return null;
1106
1152
  if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
1107
1153
  return t;
1108
1154
  }
1109
- function Ht(e, t, n) {
1155
+ function _t(e, t, n) {
1110
1156
  if (e.seen.has(n)) return;
1111
1157
  e.seen.add(n), e.selected++;
1112
- const r = t ? zt(t) : null;
1158
+ const r = t ? Wt(t) : null;
1113
1159
  r === null ? e.excluded++ : e.values.push(r);
1114
1160
  }
1115
- function Wt(e, t, n, r) {
1161
+ function jt(e, t, n, r) {
1116
1162
  return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
1117
1163
  }
1118
- function jt(e, t, n) {
1164
+ function Bt(e, t, n) {
1119
1165
  return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
1120
1166
  }
1121
- function _t(e, t, n, r) {
1122
- const i = r.origin ? de(e) + t : t, o = jt(e, n, r);
1167
+ function Gt(e, t, n, r) {
1168
+ const i = r.origin ? de(e) + t : t, o = Bt(e, n, r);
1123
1169
  return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
1124
1170
  }
1125
- function Bt(e, t) {
1171
+ function Ut(e, t) {
1126
1172
  const n = t.origin ? de(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
1127
1173
  return i > r ? i : 0;
1128
1174
  }
1129
- async function qt(e, t, n, r, i) {
1175
+ async function Vt(e, t, n, r, i) {
1130
1176
  const o = e.grid;
1131
1177
  if (t > r.maxScanned) throw new w("limit");
1132
1178
  const s = o.colWidthsMm?.length ?? o.cells.reduce((l, c) => Math.max(l, c.length), 1);
1133
1179
  if (s > r.maxScanned) throw new w("limit");
1134
1180
  const a = /* @__PURE__ */ new Map();
1135
1181
  for (let l = 0; l < t; l++) {
1136
- l > 0 && l % 2048 === 0 && (await r.yieldToHost(), O(r.signal));
1182
+ l > 0 && l % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
1137
1183
  let c = 0;
1138
1184
  for (const d of o.cells[l]) {
1139
1185
  for (await J(r); c < s && (a.get(c) ?? 0) > l; ) c++;
@@ -1141,12 +1187,12 @@ async function qt(e, t, n, r, i) {
1141
1187
  const m = Math.max(1, Math.min(d?.colSpan ?? 1, s - c)), h = Math.min(o.cells.length, l + Math.max(1, d?.rowSpan ?? 1));
1142
1188
  m > 1 && await J(r, m - 1);
1143
1189
  for (let f = c; f < c + m; f++) a.set(f, h);
1144
- const u = _t(e, l, c, n);
1145
- u && Ht(i, d, u), c += m;
1190
+ const u = Gt(e, l, c, n);
1191
+ u && _t(i, d, u), c += m;
1146
1192
  }
1147
1193
  }
1148
1194
  }
1149
- async function Gt(e, t, n) {
1195
+ async function qt(e, t, n) {
1150
1196
  const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
1151
1197
  for (let i = 0; i < e.pages.length; i++) {
1152
1198
  await J(n);
@@ -1154,9 +1200,9 @@ async function Gt(e, t, n) {
1154
1200
  for (let s = 0; s < o.components.length; s++) {
1155
1201
  await J(n);
1156
1202
  const a = o.components[s];
1157
- if (!a.grid || !Wt(a, i, s, t) || a.table && a.table.role !== "body") continue;
1158
- const l = Bt(a, t);
1159
- l && await qt(a, l, t, n, r);
1203
+ if (!a.grid || !jt(a, i, s, t) || a.table && a.table.role !== "body") continue;
1204
+ const l = Ut(a, t);
1205
+ l && await Vt(a, l, t, n, r);
1160
1206
  }
1161
1207
  }
1162
1208
  return r;
@@ -1165,7 +1211,7 @@ function B(e) {
1165
1211
  if (!Number.isFinite(e)) throw new w("overflow");
1166
1212
  return e;
1167
1213
  }
1168
- function Ut(e) {
1214
+ function Yt(e) {
1169
1215
  let t = 0, n = 0;
1170
1216
  for (const r of e) {
1171
1217
  const i = r - n, o = B(t + i);
@@ -1173,28 +1219,28 @@ function Ut(e) {
1173
1219
  }
1174
1220
  return t;
1175
1221
  }
1176
- async function be(e, t) {
1222
+ async function ve(e, t) {
1177
1223
  let n = [...e], r = new Array(e.length);
1178
1224
  for (let o = 1; o < e.length; o *= 2) {
1179
1225
  for (let s = 0; s < e.length; s += o * 2) {
1180
1226
  const a = Math.min(s + o, e.length), l = Math.min(s + o * 2, e.length);
1181
1227
  let c = s, d = a;
1182
1228
  for (let m = s; m < l; m++)
1183
- r[m] = d >= l || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), O(t.signal));
1229
+ r[m] = d >= l || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
1184
1230
  }
1185
1231
  [n, r] = [r, n];
1186
1232
  }
1187
1233
  const i = Math.floor(n.length / 2);
1188
1234
  return n.length % 2 ? n[i] : B(n[i - 1] / 2 + n[i] / 2);
1189
1235
  }
1190
- function Vt(e) {
1191
- const t = Ut(e);
1236
+ function Kt(e) {
1237
+ const t = Yt(e);
1192
1238
  let n = 1 / 0, r = -1 / 0;
1193
1239
  for (const i of e)
1194
1240
  n = Math.min(n, i), r = Math.max(r, i);
1195
1241
  return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
1196
1242
  }
1197
- function Yt(e, t) {
1243
+ function Xt(e, t) {
1198
1244
  if (typeof e != "string" || e.length > 256) throw new w("expression");
1199
1245
  const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
1200
1246
  if (!n.length || n.length > 64) throw new w("expression");
@@ -1228,145 +1274,154 @@ function Yt(e, t) {
1228
1274
  if (r !== n.length) throw new w("expression");
1229
1275
  return s;
1230
1276
  }
1231
- function Kt(e) {
1277
+ function Jt(e) {
1232
1278
  const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
1233
1279
  if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
1234
1280
  if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
1235
1281
  return { maxCells: t, maxScanned: n, precision: r };
1236
1282
  }
1237
- async function Sn(e, t, n = {}) {
1238
- const r = Kt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((l) => setTimeout(l, 0))) };
1239
- O(i.signal);
1240
- const o = await Gt(e, Ft(e, t, r.maxCells), i), s = n.operation ?? "sum";
1283
+ async function Pn(e, t, n = {}) {
1284
+ const r = Jt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((l) => setTimeout(l, 0))) };
1285
+ z(i.signal);
1286
+ const o = await qt(e, zt(e, t, r.maxCells), i), s = n.operation ?? "sum";
1241
1287
  if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(s)) throw new w("expression");
1242
1288
  let a = null;
1243
1289
  if (s === "count") a = o.values.length;
1244
1290
  else if (o.values.length)
1245
- if (s === "median") a = await be(o.values, i);
1291
+ if (s === "median") a = await ve(o.values, i);
1246
1292
  else {
1247
- const l = Vt(o.values);
1248
- s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await be(o.values, i)), a = Yt(n.expression ?? "", l)) : a = l[s.toUpperCase()];
1293
+ const l = Kt(o.values);
1294
+ s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await ve(o.values, i)), a = Xt(n.expression ?? "", l)) : a = l[s.toUpperCase()];
1249
1295
  }
1250
- if (O(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1296
+ if (z(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1251
1297
  return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
1252
1298
  }
1253
1299
  export {
1254
- Hn as CSS_DPI,
1255
- Pn as DEFAULT_BORDER_PT,
1300
+ Bn as CSS_DPI,
1301
+ In as DEFAULT_BORDER_PT,
1256
1302
  Z as DEFAULT_FONT_FAMILY,
1257
- Rn as DEFAULT_FONT_PT,
1258
- An as DEFAULT_STROKE_COLOR,
1259
- ve as DEFAULT_TEXT_COLOR,
1260
- kn as LINE_HEIGHT,
1261
- Wn as MM_PER_INCH,
1262
- Ir as OutputAssetError,
1263
- qe as OutputFidelityError,
1303
+ $n as DEFAULT_FONT_PT,
1304
+ Nn as DEFAULT_STROKE_COLOR,
1305
+ ye as DEFAULT_TEXT_COLOR,
1306
+ Ln as LINE_HEIGHT,
1307
+ Gn as MM_PER_INCH,
1308
+ Dr as OutputAssetError,
1309
+ Ue as OutputFidelityError,
1264
1310
  K as PAPER_SIZES,
1265
- bt as PageBuilder,
1266
- ir as PaginateCellLimitError,
1267
- ar as PaginatePageLimitError,
1268
- qn as RENDER_PLAN_SCHEMA_VERSION,
1269
- Dr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1311
+ vt as PageBuilder,
1312
+ lr as PaginateCellLimitError,
1313
+ cr as PaginatePageLimitError,
1314
+ Yn as RENDER_PLAN_SCHEMA_VERSION,
1315
+ Hr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1270
1316
  w as ReportCalculationError,
1271
- _e as ReportCellEditError,
1272
- Pt as ReportCellFieldError,
1273
- Br as ReportParamValidationError,
1274
- or as ReportSourceError,
1275
- Fr as ReportTemplateError,
1276
- $ as ReportTemplateStoreError,
1277
- In as SCHEMA_VERSION_MACH,
1278
- wt as TemplateBuilder,
1279
- sr as applyReportCellEdit,
1280
- lr as applyReportCellEditBatch,
1281
- cr as applyReportEditResult,
1282
- Un as assertRenderPlan,
1283
- qr as assertReportParams,
1284
- Sn as calculateReportSelection,
1285
- Qn as charWidthEm,
1317
+ Be as ReportCellEditError,
1318
+ At as ReportCellFieldError,
1319
+ qr as ReportParamValidationError,
1320
+ dr as ReportSourceError,
1321
+ Wr as ReportTemplateError,
1322
+ L as ReportTemplateStoreError,
1323
+ Dn as SCHEMA_VERSION_MACH,
1324
+ bt as TemplateBuilder,
1325
+ ii as TreeRowLimitError,
1326
+ mr as applyReportCellEdit,
1327
+ hr as applyReportCellEditBatch,
1328
+ ur as applyReportEditResult,
1329
+ Xn as assertRenderPlan,
1330
+ Yr as assertReportParams,
1331
+ Pn as calculateReportSelection,
1332
+ rr as charWidthEm,
1286
1333
  E as classOf,
1287
- pn as columnsFromContract,
1288
- ct as computePageWindow,
1289
- dr as countTemplatePages,
1290
- er as createCanvasMeasurer,
1291
- gn as createCanvasPager,
1292
- tr as createHeuristicMeasurer,
1293
- yn as createMemoryTemplateStore,
1294
- bn as createProviderReport,
1295
- mr as createReportCellEdit,
1296
- hr as createReportCellEditBatch,
1297
- ur as createReportCellResolver,
1298
- gr as createReportEditSession,
1299
- fr as createReportSource,
1300
- wn as createTableTemplate,
1301
- fn as createTemplate,
1302
- vn as createTemplateManager,
1303
- Or as createTemplateRegistry,
1304
- Jn as datasetJsonSchema,
1305
- pr as defineReport,
1306
- zr as defineReportTemplate,
1307
- wr as diffReportTemplates,
1308
- br as estimateListLayoutCells,
1309
- Nn as evalStyleRule,
1310
- Yt as evaluateReportAggregateExpression,
1311
- vr as formatReportCellEdit,
1312
- Mn as formatReportClipboard,
1313
- Ln as formatValue,
1314
- yr as getReportCellContext,
1315
- Mr as getReportEditSession,
1316
- ae as heuristicMeasurer,
1317
- Nr as inspectOutputCapabilities,
1334
+ En as cloneReportTemplate,
1335
+ bn as columnsFromContract,
1336
+ dt as computePageWindow,
1337
+ gr as countTemplatePages,
1338
+ ir as createCanvasMeasurer,
1339
+ pn as createCanvasPager,
1340
+ or as createHeuristicMeasurer,
1341
+ Sn as createLocalTemplateCatalog,
1342
+ xn as createMemoryTemplateStore,
1343
+ yn as createProviderReport,
1344
+ fr as createReportCellEdit,
1345
+ pr as createReportCellEditBatch,
1346
+ wr as createReportCellResolver,
1347
+ br as createReportEditSession,
1348
+ vr as createReportSource,
1349
+ vn as createTableTemplate,
1350
+ wn as createTemplate,
1351
+ Mn as createTemplateManager,
1352
+ _r as createTemplateRegistry,
1353
+ oi as createTreeTable,
1354
+ tr as datasetJsonSchema,
1355
+ yr as defineReport,
1356
+ jr as defineReportTemplate,
1357
+ Mr as diffReportTemplates,
1358
+ xr as estimateListLayoutCells,
1359
+ On as evalStyleRule,
1360
+ Xt as evaluateReportAggregateExpression,
1361
+ Er as formatReportCellEdit,
1362
+ Tn as formatReportClipboard,
1363
+ Kr as formatReportDateRange,
1364
+ zn as formatValue,
1365
+ Sr as getReportCellContext,
1366
+ Tr as getReportEditSession,
1367
+ oe as heuristicMeasurer,
1368
+ Or as inspectOutputCapabilities,
1318
1369
  ee as isImageBackedComponent,
1319
- Gr as isReportDate,
1320
- Ee as isRichText,
1370
+ Xr as isReportDate,
1371
+ Jr as isReportMonth,
1372
+ Zr as isReportYear,
1373
+ Se as isRichText,
1321
1374
  le as measurePageSizePx,
1322
- nr as measureTextMm,
1323
- Me as mergeComponentStyles,
1375
+ ar as measureTextMm,
1376
+ xe as mergeComponentStyles,
1324
1377
  ie as mmToPx,
1325
- jn as mmToPxFactor,
1326
- xr as paginateTemplate,
1327
- Er as paginateTemplatePages,
1328
- Dn as parseDateLocal,
1329
- En as parseReportCellFieldInput,
1330
- Be as parseReportCellInput,
1331
- xn as parseReportClipboard,
1332
- j as parseReportTemplate,
1333
- dn as planFontSizePx,
1334
- Sr as projectListColumns,
1335
- F as ptToPx,
1336
- _n as pxToMm,
1337
- Tr as registerReportEditSession,
1338
- Cr as relocateReportCellEdits,
1339
- Ae as renderComponent,
1340
- it as renderPage,
1341
- cn as renderPlan,
1342
- hn as renderPlanToCanvas,
1343
- un as renderPlanToCanvasAsync,
1344
- mn as renderPlanToImages,
1345
- Pr as reportCellEditKey,
1346
- q as reportOutputDiagnostics,
1347
- Ur as reportParamsJsonSchema,
1348
- ye as resolveBoxBorders,
1349
- H as resolveFontSize,
1350
- Te as resolveGridLayout,
1378
+ Un as mmToPxFactor,
1379
+ Cr as paginateTemplate,
1380
+ Rr as paginateTemplatePages,
1381
+ Hn as parseDateLocal,
1382
+ Rn as parseReportCellFieldInput,
1383
+ Ge as parseReportCellInput,
1384
+ Cn as parseReportClipboard,
1385
+ Qr as parseReportDateRange,
1386
+ I as parseReportTemplate,
1387
+ hn as planFontSizePx,
1388
+ Pr as projectListColumns,
1389
+ O as ptToPx,
1390
+ Vn as pxToMm,
1391
+ Ar as registerReportEditSession,
1392
+ kr as relocateReportCellEdits,
1393
+ ke as renderComponent,
1394
+ ot as renderPage,
1395
+ mn as renderPlan,
1396
+ gn as renderPlanToCanvas,
1397
+ fn as renderPlanToCanvasAsync,
1398
+ un as renderPlanToImages,
1399
+ Ir as reportCellEditKey,
1400
+ G as reportOutputDiagnostics,
1401
+ ei as reportParamsJsonSchema,
1402
+ Me as resolveBoxBorders,
1403
+ W as resolveFontSize,
1404
+ Ce as resolveGridLayout,
1351
1405
  Q as resolveLineHeight,
1352
- De as resolvePaper,
1353
- oe as resolvePlanAssets,
1354
- _ as resolveStroke,
1355
- xe as resolveTextColor,
1356
- Rr as reviewReportTemplate,
1357
- z as round,
1358
- Hr as serializeReportTemplate,
1359
- Ar as summarizeReportCellEdits,
1360
- Fn as toExcelNumberFormat,
1361
- On as toNumber,
1362
- Vn as validateComponent,
1406
+ Fe as resolvePaper,
1407
+ ae as resolvePlanAssets,
1408
+ j as resolveStroke,
1409
+ Ee as resolveTextColor,
1410
+ $r as reviewReportTemplate,
1411
+ H as round,
1412
+ Br as serializeReportTemplate,
1413
+ Nr as summarizeReportCellEdits,
1414
+ Wn as toExcelNumberFormat,
1415
+ _n as toNumber,
1416
+ Jn as validateComponent,
1363
1417
  je as validateDatasetRows,
1364
- Yn as validatePage,
1365
- Kn as validateRenderPlan,
1366
- Dt as validateReportCellFieldDefinition,
1367
- Vr as validateReportParamDefinitions,
1368
- Yr as validateReportParams,
1369
- Wr as validateReportTemplate,
1370
- jr as validateReportTemplateDocument,
1371
- Se as wrapText
1418
+ Zn as validatePage,
1419
+ Qn as validateRenderPlan,
1420
+ Ot as validateReportCellFieldDefinition,
1421
+ ti as validateReportParamDefinitions,
1422
+ ni as validateReportParams,
1423
+ Gr as validateReportTemplate,
1424
+ Ur as validateReportTemplateDocument,
1425
+ ai as validateTreeOptions,
1426
+ Te as wrapText
1372
1427
  };