@agile-team/mach-report 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +6 -2
  2. package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
  4. package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
  5. package/dist/ParamEditor-DRGxzxeO.js +381 -0
  6. package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
  7. package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +2 -0
  18. package/dist/analytics.d.ts +2 -0
  19. package/dist/analytics.js +29 -29
  20. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  21. package/dist/batch-mRqhhhjt.js +364 -0
  22. package/dist/computed-Bvk0W15F.js +521 -0
  23. package/dist/computed-CGV2a809.cjs +1 -0
  24. package/dist/config-B612mw0x.js +525 -0
  25. package/dist/config-BRoLo2oj.cjs +1 -0
  26. package/dist/designer.cjs +2 -2
  27. package/dist/designer.d.cts +659 -9
  28. package/dist/designer.d.ts +659 -9
  29. package/dist/designer.js +2030 -1824
  30. package/dist/index.cjs +8 -8
  31. package/dist/index.d.cts +147 -3
  32. package/dist/index.d.ts +147 -3
  33. package/dist/index.js +639 -592
  34. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  35. package/dist/injection-keys-e85udZCp.js +7 -0
  36. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  37. package/dist/{list-cell-Dxyi7DOw.js → list-cell-ClFra1zS.js} +54 -40
  38. package/dist/matrix-DVyWiYsd.cjs +1 -0
  39. package/dist/matrix-yZsGnldA.js +227 -0
  40. package/dist/param-validation-BlHHXs6u.js +153 -0
  41. package/dist/param-validation-DCK039V1.cjs +1 -0
  42. package/dist/pdf.cjs +25 -25
  43. package/dist/pdf.d.cts +3 -0
  44. package/dist/pdf.d.ts +3 -0
  45. package/dist/pdf.js +677 -677
  46. package/dist/plugin-BDTU4D94.cjs +1 -0
  47. package/dist/plugin-Cd5G2QQn.js +22 -0
  48. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  49. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  50. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  51. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  52. package/dist/server/node.d.cts +5 -2
  53. package/dist/server/node.d.ts +5 -2
  54. package/dist/server-node.cjs +1 -1
  55. package/dist/server-node.js +87 -87
  56. package/dist/server.cjs +1 -1
  57. package/dist/server.d.cts +201 -2
  58. package/dist/server.d.ts +201 -2
  59. package/dist/server.js +557 -658
  60. package/dist/style.css +1 -1
  61. package/dist/template-registry-WNXdkiET.js +506 -0
  62. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  63. package/dist/template-review-BXp2oyqg.cjs +1 -0
  64. package/dist/template-review-BdcXSYbx.js +1616 -0
  65. package/dist/tree-BX380Rr7.cjs +1 -0
  66. package/dist/tree-CqcQ99NM.js +172 -0
  67. package/dist/{validate-UUy9yP4K.js → validate-7s0yn6ii.js} +44 -44
  68. package/dist/validate-DsRiNw8h.cjs +1 -0
  69. package/dist/vue/async.d.cts +93 -4
  70. package/dist/vue/async.d.ts +93 -4
  71. package/dist/vue/index.d.cts +145 -7
  72. package/dist/vue/index.d.ts +145 -7
  73. package/dist/vue-async.cjs +1 -1
  74. package/dist/vue-async.js +5 -5
  75. package/dist/vue.cjs +1 -1
  76. package/dist/vue.js +116 -113
  77. package/dist/{workbook-session-B-bW5_yR.js → workbook-session-BKOTwcoq.js} +1 -1
  78. package/dist/{workbook-session-D7RtdNo0.cjs → workbook-session-CLYLhZWu.cjs} +1 -1
  79. package/dist/worker.cjs +1 -1
  80. package/dist/worker.d.cts +5 -2
  81. package/dist/worker.d.ts +5 -2
  82. package/dist/worker.js +1 -1
  83. package/dist/xlsx.cjs +3 -3
  84. package/dist/xlsx.d.cts +129 -2
  85. package/dist/xlsx.d.ts +129 -2
  86. package/dist/xlsx.js +336 -242
  87. package/package.json +1 -1
  88. package/dist/ExcelBindingWizard-CF7RplWm.cjs +0 -1
  89. package/dist/ExcelBindingWizard-qhwEderR.js +0 -842
  90. package/dist/ReportPreview-BE1tCHqE.js +0 -4604
  91. package/dist/ReportPreview-QKRKQOe3.cjs +0 -6
  92. package/dist/RuleEditor-BA36yIV6.js +0 -1723
  93. package/dist/RuleEditor-CczJ6mJm.cjs +0 -1
  94. package/dist/TemplateReviewPanel-CHi4Alqa.cjs +0 -1
  95. package/dist/TemplateReviewPanel-Dz0G5o83.js +0 -217
  96. package/dist/binding-preview-BWsdf_z2.cjs +0 -2
  97. package/dist/binding-preview-DILq0-0f.js +0 -649
  98. package/dist/decimal-CI1OAczk.js +0 -87
  99. package/dist/decimal-CQA0xJex.cjs +0 -1
  100. package/dist/list-cell-CyM1ZlRN.cjs +0 -1
  101. package/dist/matrix-BbXarwyk.js +0 -661
  102. package/dist/matrix-Cm65WLLP.cjs +0 -1
  103. package/dist/param-validation-BWNjLcN0.js +0 -116
  104. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  105. package/dist/plugin-CThk42vJ.cjs +0 -1
  106. package/dist/plugin-tGn7-5oF.js +0 -25
  107. package/dist/template-registry-CGWTLtIA.cjs +0 -1
  108. package/dist/template-registry-DzlQs3OF.js +0 -434
  109. package/dist/template-review-D1RoNCPw.cjs +0 -1
  110. package/dist/template-review-fnteXRng.js +0 -1473
  111. package/dist/validate-Bf6ccFr2.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,28 +1,29 @@
1
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";
2
+ import { b as kn, c as In, d as $n, L as Nn, S as Ln } from "./defaults-DXhiM1ZD.js";
3
+ import { e as Fn, f as On, p as zn, t as Hn, c as Wn } 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 jn, M as Bn, g as Gn, h as Un } from "./style-CQ1PK8ZB.js";
6
+ import { i as ee, a as Se } from "./render-plan-Ck6koX9L.js";
7
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";
8
+ import { a as Kn, v as Xn, b as Jn, c as Zn } 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 er } from "./dataset-H5pFuQGU.js";
11
+ import { h as ae, w as Te } from "./textwrap-DE1kgcJB.js";
12
+ import { c as nr, a as rr, b as ir, m as ar } from "./textwrap-DE1kgcJB.js";
13
+ import { R as Be, p as Ge } from "./template-review-BdcXSYbx.js";
14
+ import { P as sr, a as lr, b as cr, c as dr, d as mr, e as hr, f as gr, g as ur, h as fr, i as pr, j as wr, k as br, l as yr, m as vr, n as Mr, o as xr, q as Er, r as Sr, s as Tr, t as Cr, u as Rr, v as Pr, w as Ar, x as kr, y as Ir, z as $r } from "./template-review-BdcXSYbx.js";
15
+ import { r as Ce } from "./grid-geometry-BNptEcMm.js";
16
+ import { r as Re, a as oe } from "./assets-DegqDNqY.js";
17
+ import { O as Lr } from "./assets-DegqDNqY.js";
18
+ import { r as G, n as Pe, O as Ue } from "./capabilities-CK_7hizc.js";
19
+ import { i as Fr } 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 D } from "./template-registry-WNXdkiET.js";
23
+ import { R as zr, a as Hr, c as Wr, d as _r, s as jr, v as Br, b as Gr } from "./template-registry-WNXdkiET.js";
24
+ import { R as Vr, a as qr, f as Yr, i as Kr, b as Xr, c as Jr, p as Zr, r as Qr, v as ei, d as ti } from "./param-validation-BlHHXs6u.js";
25
+ import { T as ri, c as ii, 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 = "";
@@ -63,176 +64,176 @@ class Ye {
63
64
  n && (t.style.cssText = n);
64
65
  }
65
66
  }
66
- function y(e, t = "unset") {
67
- return new Ye().add("all", t).add("display", e).add("box-sizing", "border-box");
67
+ function v(e, t = "unset") {
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
- const s = e.cell, a = o.createElement("td");
80
- 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);
79
+ function Je(e, t, n, r, i, o) {
80
+ const l = e.cell, a = o.createElement("td");
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"), l.colSpan && (a.colSpan = l.colSpan), l.rowSpan && (a.rowSpan = l.rowSpan);
82
+ const s = xe(t.style, l.style), c = v("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", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
83
+ Ae(c, s, 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", v("flex").add("position", "absolute").mm("left", n + (l.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), l.text != null && d.append(l.text);
86
+ for (const m of l.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");
91
- s.className = "mr-grid-edge", s.setAttribute("aria-hidden", "true");
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}`, l = r.createElement("div");
92
+ l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
92
93
  const a = i.kind === "h";
93
- 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
+ return v("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(l), l;
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
- 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
- y("contents").applyTo(a), o.appendChild(a);
101
- const l = e.cells.map(() => {
99
+ o.className = E("grid", r), o.setAttribute("role", "table"), v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
100
+ const l = Ce(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
101
+ v("contents").applyTo(a), o.appendChild(a);
102
+ const s = e.cells.map(() => {
102
103
  const d = i.createElement("tr");
103
- return d.className = E("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
104
+ return d.className = E("row", r), d.setAttribute("role", "row"), v("contents").applyTo(d), a.appendChild(d), d;
104
105
  });
105
- for (const d of s.cells)
106
- l[d.ri].appendChild(Xe(d, t, e.paddingMm ?? 0.5, n, r, i));
106
+ for (const d of l.cells)
107
+ s[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 v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Ze(l, 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
- 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
+ i.className = E("paragraph", n), v("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 || []) {
114
- const s = r.createElement("span");
115
- s.className = E("segment", n), s.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
116
- const a = y("inline");
115
+ const l = r.createElement("span");
116
+ l.className = E("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
117
+ const a = v("inline");
117
118
  if (o.style) {
118
- 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`);
119
+ const s = o.style;
120
+ a.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${H(W(s, t).fontSizePx, 2)}px`);
120
121
  }
121
- a.applyTo(s), i.appendChild(s);
122
+ a.applyTo(l), i.appendChild(l);
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
- i.className = E("rich", n), y("block").applyTo(i);
129
- for (const o of e.richParagraphs) i.appendChild(Qe(o, t, n, r));
129
+ i.className = E("rich", n), v("block").applyTo(i);
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) {
133
134
  const i = r.createElement("div");
134
- i.className = E("lines", n), y("block").applyTo(i);
135
+ i.className = E("lines", n), v("block").applyTo(i);
135
136
  for (const o of e.lines) {
136
- const s = r.createElement("div");
137
- s.className = E("line", n), s.textContent = o, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(s), i.appendChild(s);
137
+ const l = r.createElement("div");
138
+ l.className = E("line", n), l.textContent = o, v("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
138
139
  }
139
140
  return i;
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 v("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
- 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
+ return r.className = E("image", t), r.src = e.imageData, v("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
152
153
  }
153
- function ge(e, t, n, r) {
154
+ function ue(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
- 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;
157
+ const o = e.style || {}, l = j(o), a = Me(o), s = `${H(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = v("block");
158
+ return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", s), a.right && c.add("border-right", s), a.bottom && c.add("border-bottom", s), a.left && c.add("border-left", s)) : e.kind === "ellipse" ? (a.inner && c.add("border", s).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), 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
- const s = n.createElementNS("http://www.w3.org/2000/svg", "line");
163
- 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
- return s.setAttribute("stroke", a.color), s.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(s), r;
163
+ const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
164
+ l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
165
+ const a = j({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
166
+ return l.setAttribute("stroke", a.color), l.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(l), 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
- 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;
171
+ const o = v("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");
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
- const a = ge(e, t, n, r);
177
- return a.appendChild(Ze(e.grid, e, t, n, r)), i.appendChild(a), i;
177
+ const a = ue(e, t, n, r);
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
- return i.appendChild(ge(e, t, n, r)), i;
183
- const s = r.createElement("div");
184
- 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;
183
+ return i.appendChild(ue(e, t, n, r)), i;
184
+ const l = r.createElement("div");
185
+ return l.className = E("unknown", n), v("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), i.appendChild(l), i;
185
186
  }
186
- function it(e, t, n, r) {
187
+ function at(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);
190
- a.dataset.mrComponentIndex = String(s), i.appendChild(a);
189
+ return i.className = E("page", n), v("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", ve).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, l) => {
190
+ const a = ke(o, t, n, r);
191
+ a.dataset.mrComponentIndex = String(l), i.appendChild(a);
191
192
  }), i;
192
193
  }
193
- function cn(e, t, n = {}) {
194
+ function dn(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
- 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));
198
+ return i.className = E("root", n), v("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
199
+ i.appendChild(at(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 ot = (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
- i.onload = null, i.onerror = null, t?.removeEventListener("abort", s);
207
- }, s = () => {
207
+ i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
208
+ }, l = () => {
208
209
  o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
209
210
  };
210
211
  i.onload = () => {
211
212
  o(), n(i);
212
213
  }, i.onerror = () => {
213
214
  o(), r(new Error("Image could not be decoded for Canvas output."));
214
- }, t?.addEventListener("abort", s, { once: !0 }), i.src = e;
215
+ }, t?.addEventListener("abort", l, { 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
- const s = t, a = s.naturalWidth ?? s.width ?? i, l = s.naturalHeight ?? s.height ?? o;
230
- if (a <= 0 || l <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
231
- const c = Math.min(i / a, o / l), d = a * c, m = l * c;
229
+ function ct(e, t, n, r, i, o) {
230
+ const l = t, a = l.naturalWidth ?? l.width ?? i, s = l.naturalHeight ?? l.height ?? o;
231
+ if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
232
+ const c = Math.min(i / a, o / s), d = a * c, m = s * 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,204 +243,204 @@ 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
- const i = le(e, n), o = Math.round(i.widthPx * t), s = Math.round(i.heightPx * t);
249
- if (!Number.isSafeInteger(o) || !Number.isSafeInteger(s) || o * s > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
250
- return { width: o, height: s };
251
- }
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);
254
- i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${s}px`;
255
- const l = i.getContext("2d");
256
- if (!l)
249
+ const i = le(e, n), o = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
250
+ if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
251
+ return { width: o, height: l };
252
+ }
253
+ function $e(e, t, n, r) {
254
+ const i = document.createElement("canvas"), { widthPx: o, heightPx: l } = le(e, n), a = Ie(e, t, n, r);
255
+ i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${l}px`;
256
+ const s = i.getContext("2d");
257
+ if (!s)
257
258
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
258
- return l.scale(t, t), l.fillStyle = "#ffffff", l.fillRect(0, 0, o, s), { canvas: i, ctx: l };
259
+ return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: i, ctx: s };
259
260
  }
260
- function dn(e, t = 96) {
261
- return H(e, t).fontSizePx;
261
+ function mn(e, t = 96) {
262
+ return W(e, t).fontSizePx;
262
263
  }
263
- function $e(e, t, n, r, i, o, s, a = "top") {
264
- 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
- const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
266
- `), d = c.length * l;
264
+ function Ne(e, t, n, r, i, o, l, a = "top") {
265
+ e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${l}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
266
+ const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
267
+ `), d = c.length * s;
267
268
  let m = r;
268
- 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);
269
+ a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, g) => {
270
+ mt(e, h, t, n, m + g * s + t.fontSizePx * 0.8, i);
270
271
  }), e.textAlign = "left";
271
272
  }
272
- function dt(e, t, n, r, i, o) {
273
- const s = Array.from(t), a = n.letterSpacingPx ?? 0;
273
+ function mt(e, t, n, r, i, o) {
274
+ const l = Array.from(t), a = n.letterSpacingPx ?? 0;
274
275
  if (!a) {
275
276
  e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
276
277
  const m = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
277
278
  e.fillText(t, m, i);
278
279
  return;
279
280
  }
280
- const l = e.measureText(t).width + Math.max(0, s.length - 1) * a, c = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
281
+ const s = e.measureText(t).width + Math.max(0, l.length - 1) * a, c = n.align === "center" ? r + (o - s) / 2 : n.align === "right" ? r + o - s : r;
281
282
  e.textAlign = "left";
282
283
  let d = "";
283
- s.forEach((m, h) => {
284
+ l.forEach((m, h) => {
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, l) {
289
+ for (const a of Re(t, n))
290
+ e.strokeStyle = a.color, e.lineWidth = O(a.widthPt, l), 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 gt(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);
296
- for (const u of m.cells) {
297
- const f = u.cell.style?.backgroundColor ?? n.style?.backgroundColor;
298
- f && (e.fillStyle = f, e.fillRect(r + u.xMm * a, i + u.yMm * a, u.widthMm * a, u.heightMm * a));
295
+ function ut(e, t, n, r, i, o, l, a, s, c, d) {
296
+ const m = Ce(t, o / a, l / a);
297
+ for (const g of m.cells) {
298
+ const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
299
+ f && (e.fillStyle = f, e.fillRect(r + g.xMm * a, i + g.yMm * a, g.widthMm * a, g.heightMm * a));
299
300
  }
300
- mt(e, m, n, r, i, a, l);
301
+ ht(e, m, n, r, i, a, s);
301
302
  const h = t.paddingMm ?? 0.5;
302
- for (const u of m.cells) {
303
- const f = u.cell.text ?? "";
303
+ for (const g of m.cells) {
304
+ const f = g.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, g.cell.style), I = W(b, s), C = g.cell.indentMm ?? 0, S = Math.max(0, g.widthMm - 2 * h - C), A = Te(f, S, { fontSizePt: I.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: I.fontSizePx,
312
313
  bold: b.bold ?? !1,
313
314
  italic: b.italic,
314
- color: xe(b, ve),
315
+ color: Ee(b, ve),
315
316
  align: b.align ?? "left",
316
317
  lineHeight: Q(b),
317
- letterSpacingPx: F(b.letterSpacing ?? 0, l)
318
+ letterSpacingPx: O(b.letterSpacing ?? 0, s)
318
319
  },
319
- r + (u.xMm + h) * a,
320
- i + (u.yMm + h) * a,
321
- T * a,
322
- Math.max(0, u.heightMm - 2 * h) * a,
320
+ r + (g.xMm + h + C) * a,
321
+ i + (g.yMm + h) * a,
322
+ S * a,
323
+ Math.max(0, g.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, l, a, s) {
330
+ const c = t.style ?? {}, d = W(c, l), m = Se(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.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 }, s).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, l)
342
343
  }, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
343
344
  }
344
- function ce(e, t, n, r, i, o, s) {
345
- const a = t.leftMm * n, l = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
345
+ function ce(e, t, n, r, i, o, l) {
346
+ const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
346
347
  if (ee(t)) {
347
- const h = s?.get(t.imageData);
348
- h ? lt(e, h, a, l, c, d) : fe(e, t, a, l, c, d);
348
+ const h = l?.get(t.imageData);
349
+ h ? ct(e, h, a, s, c, d) : fe(e, t, a, s, 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
+ ut(e, t.grid, t, a, s, 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, s, 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), g = Me(m);
363
+ m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, s, c, d)), g.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), gt(e, g, a, s, 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();
368
- 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
- e.moveTo(a, u), e.lineTo(a + c, f), e.stroke();
367
+ const h = j({ ...m, borderColor: m.lineColor ?? m.borderColor });
368
+ e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), e.beginPath();
369
+ const g = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2, f = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + d : s + d / 2;
370
+ e.moveTo(a, g), 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, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
375
376
  break;
376
377
  }
377
378
  default:
378
- fe(e, t, a, l, c, d);
379
+ fe(e, t, a, s, c, d);
379
380
  break;
380
381
  }
381
382
  }
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 hn(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
+ R(t.signal);
392
393
  const o = await oe(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 l = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], 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, l);
398
399
  try {
399
- l.push(await ft(m, a, r, t.signal));
400
+ s.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, s.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: s, diagnostics: l };
406
407
  }
407
- function ft(e, t, n, r) {
408
- return P(r), new Promise((i, o) => {
409
- const s = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
410
- r?.addEventListener("abort", s, { once: !0 });
408
+ function pt(e, t, n, r) {
409
+ return R(r), new Promise((i, o) => {
410
+ const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
411
+ r?.addEventListener("abort", l, { once: !0 });
411
412
  try {
412
413
  e.toBlob((a) => {
413
- r?.removeEventListener("abort", s), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
414
+ r?.removeEventListener("abort", l), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
414
415
  }, t, n);
415
416
  } catch (a) {
416
- r?.removeEventListener("abort", s), o(a);
417
+ r?.removeEventListener("abort", l), o(a);
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, l = t.measurer ?? ae, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = wt(e, a, s);
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
- 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);
427
+ if (t.fidelity === "strict" && m.length) throw new Ue(d);
428
+ for (let h = a; h <= s; h++) {
429
+ R(t.signal);
430
+ const g = e.pages[h], { canvas: f, ctx: b } = $e(g, n, r, t.maxCanvasPixels);
431
+ for (const I of g.components)
432
+ ce(b, I, i, r, o, l);
432
433
  c.push(f);
433
434
  }
434
435
  return { canvases: c, diagnostics: d };
435
436
  }
436
- function pt(e, t, n) {
437
- return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, s) => ee(o) ? [{
437
+ function wt(e, t, n) {
438
+ return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, l) => ee(o) ? [{
438
439
  code: "async-image-required",
439
440
  severity: "warning",
440
441
  format: "canvas",
441
442
  pageIndex: t + i,
442
- componentIndex: s,
443
+ componentIndex: l,
443
444
  kind: o.kind,
444
445
  nid: o.nid,
445
446
  message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
@@ -447,129 +448,129 @@ function pt(e, t, n) {
447
448
  }
448
449
  async function un(e, t = {}) {
449
450
  if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
450
- P(t.signal);
451
+ R(t.signal);
451
452
  const n = await oe(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
- for (let s = Math.max(0, t.start ?? 0); s <= o; s++)
455
- i.push(await Ne(e.pages[s], s, t, r));
454
+ const r = [...n.diagnostics, ...G(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
455
+ for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
456
+ i.push(await Le(e.pages[l], l, 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);
463
- return l;
464
- }
465
459
  async function Le(e, t, n, r) {
466
- const i = n.imageLoader ?? at;
467
- return st(e, async (o, s) => {
460
+ const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? Z, a = await De(e, t, n, r);
461
+ R(n.signal);
462
+ const { canvas: s, ctx: c } = $e(e, i, o, n.maxCanvasPixels);
463
+ for (const d of e.components) ce(c, d, o / 25.4, o, l, n.measurer ?? ae, a);
464
+ return s;
465
+ }
466
+ async function De(e, t, n, r) {
467
+ const i = n.imageLoader ?? ot;
468
+ return lt(e, async (o, l) => {
468
469
  try {
469
- return await i(o, s);
470
+ return await i(o, l);
470
471
  } catch (a) {
471
- if (s?.aborted) throw a;
472
- const l = e.components.findIndex((m) => m.imageData === o), c = e.components[l], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: l, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
472
+ if (l?.aborted) throw a;
473
+ const s = e.components.findIndex((m) => m.imageData === o), c = e.components[s], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: s, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
473
474
  throw r.push(d), Pe(d, n), a;
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 fn(e, t = {}) {
479
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, l = t.measurer ?? ae, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((u) => u.pageHeightMm * i), m = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * i)), h = { start: 0, end: -1 };
480
+ let g = null, f = null, b = null, I = null, C = [], S = 0, A = [], U = 0, _ = new AbortController();
480
481
  const me = [];
481
- function Oe() {
482
- 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 = [];
482
+ function ze() {
483
+ const u = g;
484
+ u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), I = document.createElement("div"), f.appendChild(b), C = [];
484
485
  const M = Math.min(e.pages.length, 3 + a * 2);
485
486
  for (let L = 0; L < M; L++) {
486
- 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);
487
+ const y = document.createElement("div");
488
+ y.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(y), C.push(y);
488
489
  }
489
- f.appendChild(k), g.appendChild(f);
490
+ f.appendChild(I), u.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 });
493
- 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`;
492
+ async function He(u, M) {
493
+ const L = U, y = await oe(e, { ...t, signal: _.signal, format: "canvas", start: M, end: M });
494
+ me.push(...y.diagnostics);
495
+ const T = y.plan.pages[M], Y = await De(T, M, { ...t, signal: _.signal }, me);
496
+ if (L !== U || !g) return;
497
+ const { widthPx: ne, heightPx: re } = le(T, r);
498
+ let $ = u.firstElementChild;
499
+ (!$ || $.tagName !== "CANVAS") && ($ = document.createElement("canvas"), u.innerHTML = "", u.appendChild($));
500
+ const ge = Ie(T, n, r, t.maxCanvasPixels);
501
+ $.width = ge.width, $.height = ge.height, $.style.width = `${ne}px`, $.style.height = `${re}px`;
502
+ const F = $.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, l, Y);
507
+ $.dataset.canvasPage = String(M), u.style.height = `${re}px`, u.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`;
511
- 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) {
516
- v.style.display = "";
517
- const Y = g.start + S;
518
- v.style.height = `${d[Y] ?? 0}px`;
510
+ function We(u) {
511
+ U++, h.start = u.start, h.end = u.end, b.style.height = `${u.start * s + d.slice(0, u.start).reduce((y, T) => y + T, 0)}px`;
512
+ const M = e.pages.length - 1 - u.end;
513
+ I.style.height = `${M * s + d.slice(u.end + 1).reduce((y, T) => y + T, 0)}px`;
514
+ const L = u.end - u.start + 1;
515
+ C.forEach((y, T) => {
516
+ if (T < L) {
517
+ y.style.display = "";
518
+ const Y = u.start + T;
519
+ y.style.height = `${d[Y] ?? 0}px`;
519
520
  } else
520
- v.style.display = "none";
521
- }), N = [];
522
- 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);
521
+ y.style.display = "none";
522
+ }), A = [];
523
+ for (let y = u.start; y <= u.end; y++) {
524
+ const T = C[y - u.start];
525
+ if (!T) continue;
526
+ T.firstElementChild?.dataset?.canvasPage !== String(y) && A.push(y);
526
527
  }
527
528
  te();
528
529
  }
529
530
  function te() {
530
- C || N.length === 0 || (C = requestAnimationFrame(() => {
531
- C = 0;
532
- 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(() => {
531
+ S || A.length === 0 || (S = requestAnimationFrame(() => {
532
+ S = 0;
533
+ let u = Math.max(1, c);
534
+ for (; A.length > 0 && u-- > 0; ) {
535
+ const M = A.shift(), L = C[M - h.start];
536
+ L && He(L, 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 u = g, M = dt({
545
546
  pageHeightsPx: d,
546
- viewportHeightPx: g.clientHeight,
547
- scrollTopPx: g.scrollTop,
547
+ viewportHeightPx: u.clientHeight,
548
+ scrollTopPx: u.scrollTop,
548
549
  overscan: a,
549
- gapPx: l
550
+ gapPx: s
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
- attach(g) {
557
+ attach(u) {
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), g = u, ze(), u.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(u)), 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, g?.removeEventListener("scroll", V), A = [], f?.remove(), g = 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,18 +608,18 @@ 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: l, heightMm: a } = Fe(
611
612
  t,
612
613
  typeof n == "number" ? n : void 0,
613
614
  o.landscape
614
- ), l = o.margins ?? {};
615
- return this.pending = new bt(this, {
616
- widthMm: s,
615
+ ), s = o.margins ?? {};
616
+ return this.pending = new yt(this, {
617
+ widthMm: l,
617
618
  heightMm: a,
618
- marginTopMm: l.marginTopMm ?? 10,
619
- marginBottomMm: l.marginBottomMm ?? 10,
620
- marginLeftMm: l.marginLeftMm ?? 10,
621
- marginRightMm: l.marginRightMm ?? 10
619
+ marginTopMm: s.marginTopMm ?? 10,
620
+ marginBottomMm: s.marginBottomMm ?? 10,
621
+ marginLeftMm: s.marginLeftMm ?? 10,
622
+ marginRightMm: s.marginRightMm ?? 10
622
623
  }), this.pending;
623
624
  }
624
625
  collect() {
@@ -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 yt {
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 pn() {
704
+ return new bt();
704
705
  }
705
- function pn(e, t = {}) {
706
+ function wn(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
  }
@@ -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,101 +748,101 @@ 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
- const o = e.title !== void 0 && e.title.length > 0, s = o ? r + i : 0;
762
- if (s >= t)
761
+ P(r, "titleHeightMm"), P(i, "titleGapMm", !0);
762
+ const o = e.title !== void 0 && e.title.length > 0, l = o ? r + i : 0;
763
+ if (l >= t)
763
764
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
764
- return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: s };
765
+ return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
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
- const s = r - i;
791
- if (t === "page" && o > 0 && s <= 0)
791
+ const l = r - i;
792
+ if (t === "page" && o > 0 && l <= 0)
792
793
  throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
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
- const u = c ?? (t === "wide" ? n * (d ?? 1) : s * ((d ?? 1) / o) / a);
796
- return R(u, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: u };
796
+ const g = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / o) / a);
797
+ return P(g, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: g };
797
798
  }), fixedWidthMm: i, maxFlex: o };
798
799
  }
799
- function wn(e) {
800
+ function bn(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 } = vt(e), r = Mt(e);
805
806
  let i = r.widthMm;
806
- const o = r.heightMm, s = Mt(e);
807
- let a = i - s.marginLeftMm - s.marginRightMm;
808
- const l = o - s.marginTopMm - s.marginBottomMm;
809
- if (t === "page" && a <= 0 || l <= 0)
807
+ const o = r.heightMm, l = xt(e);
808
+ let a = i - l.marginLeftMm - l.marginRightMm;
809
+ const s = o - l.marginTopMm - l.marginBottomMm;
810
+ if (t === "page" && a <= 0 || s <= 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, s), g = St(e), { columns: f, fixedWidthMm: b, maxFlex: I } = Ct(e, t, n, a);
813
+ t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a + l.marginLeftMm + l.marginRightMm, P(i, "宽表总宽度"));
814
+ const C = { widthMm: i, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
815
+ return m && C.components.push({
815
816
  kind: "text",
816
817
  text: e.title,
817
- leftMm: s.marginLeftMm,
818
- topMm: s.marginTopMm,
818
+ leftMm: l.marginLeftMm,
819
+ topMm: l.marginTopMm,
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
- ...u,
826
+ ...g,
826
827
  kind: "list",
827
828
  ...t === "wide" ? { layout: t } : {},
828
829
  ...m ? { title: e.title } : {},
829
830
  dataset: c,
830
831
  columns: f,
831
- leftMm: s.marginLeftMm,
832
- topMm: s.marginTopMm + h,
833
- widthMm: t === "wide" || k > 0 ? a : b
834
- }), e.params === void 0 ? { pages: [T] } : { params: e.params, pages: [T] };
832
+ leftMm: l.marginLeftMm,
833
+ topMm: l.marginTopMm + h,
834
+ widthMm: t === "wide" || I > 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 N 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,127 +852,164 @@ 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 N("history", "修订号无效或已达上限");
855
856
  return String(t + 1);
856
857
  }
857
858
  function vn(e, t = {}) {
858
- const n = async (s, a) => {
859
+ const n = async (l, a) => {
859
860
  x(a);
860
- const l = await e.read(s, a);
861
- return x(a), l ? A(l) : void 0;
862
- }, r = async (s, a) => {
863
- const l = await n(s, a.signal);
864
- if ((l?.revision ?? null) !== a.expectedRevision) throw new $("conflict", "模板已变化,请重新读取后提交");
865
- return l;
866
- }, 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);
869
- }, o = async (s, a, l, c) => {
861
+ const s = await e.read(l, a);
862
+ return x(a), s ? k(s) : void 0;
863
+ }, r = async (l, a) => {
864
+ const s = await n(l, a.signal);
865
+ if ((s?.revision ?? null) !== a.expectedRevision) throw new N("conflict", "模板已变化,请重新读取后提交");
866
+ return s;
867
+ }, i = async (l, a, s) => {
868
+ if (x(a.signal), !await e.compareAndSwap(l.id, a.expectedRevision, k(l), { signal: a.signal, ...s ? { publication: k(s) } : {} })) throw new N("conflict", "模板已被其他请求更新");
869
+ return k(l);
870
+ }, o = async (l, a, s, c) => {
870
871
  if (t.beforePublish) {
871
- 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 ?? "模板发布检查未通过");
874
- x(l.signal);
872
+ x(s.signal);
873
+ const g = await t.beforePublish({ document: D(a), previous: l.published ? D(l.published) : void 0, signal: s.signal });
874
+ if (!g || g.ok !== !0) throw new N("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
875
+ x(s.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
- return c !== void 0 && (h.restoredFrom = c), i({ id: s.id, revision: d, publishedRevision: d, published: m }, l, h);
877
+ const d = pe(l), m = D({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
878
+ return c !== void 0 && (h.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: m }, s, h);
878
879
  };
879
880
  return {
880
- list: async (s) => {
881
- x(s);
882
- const a = await e.list(s);
883
- return x(s), A(a);
881
+ list: async (l) => {
882
+ x(l);
883
+ const a = await e.list(l);
884
+ return x(l), k(a);
884
885
  },
885
- get: async (s, a = {}) => {
886
- const l = await n(s, a.signal), c = a.draft ? l?.draft : l?.published;
887
- return c ? j(c) : void 0;
886
+ get: async (l, a = {}) => {
887
+ const s = await n(l, a.signal), c = a.draft ? s?.draft : s?.published;
888
+ return c ? D(c) : void 0;
888
889
  },
889
- history: async (s, a) => {
890
+ history: async (l, a) => {
890
891
  x(a);
891
- const l = await e.history(s, a);
892
- return x(a), A(l);
892
+ const s = await e.history(l, a);
893
+ return x(a), k(s);
893
894
  },
894
- saveDraft: async (s, a) => {
895
+ saveDraft: async (l, 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 s = D(t.migrate ? await t.migrate(l) : l), c = await r(s.id, a), d = pe(c);
897
898
  return i({
898
- id: l.id,
899
+ id: s.id,
899
900
  revision: d,
900
- draft: { ...l, revision: d },
901
+ draft: { ...s, revision: d },
901
902
  ...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
902
903
  }, a);
903
904
  },
904
- publish: async (s, a) => {
905
+ publish: async (l, a) => {
905
906
  a = { ...a };
906
- const l = await r(s, a);
907
- if (!l) throw new $("missing", "模板不存在");
908
- if (!l.draft) throw new $("draft", "没有可发布的草稿");
909
- return o(l, l.draft, a);
907
+ const s = await r(l, a);
908
+ if (!s) throw new N("missing", "模板不存在");
909
+ if (!s.draft) throw new N("draft", "没有可发布的草稿");
910
+ return o(s, s.draft, a);
910
911
  },
911
- rollback: async (s, a, l) => {
912
- l = { ...l };
913
- const c = await r(s, l);
914
- if (!c) throw new $("missing", "模板不存在");
915
- x(l.signal);
916
- const d = await e.getVersion(s, a, l.signal);
917
- if (!d) throw new $("history", "历史修订不存在");
918
- return o(c, d.document, l, a);
912
+ rollback: async (l, a, s) => {
913
+ s = { ...s };
914
+ const c = await r(l, s);
915
+ if (!c) throw new N("missing", "模板不存在");
916
+ x(s.signal);
917
+ const d = await e.getVersion(l, a, s.signal);
918
+ if (!d) throw new N("history", "历史修订不存在");
919
+ return o(c, d.document, s, a);
919
920
  }
920
921
  };
921
922
  }
922
- function yn() {
923
+ function Mn() {
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 N("history", "状态 ID 与存储 ID 不一致");
941
+ const l = k(i), a = o.publication;
941
942
  if (a) {
942
- 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);
943
+ const s = t.get(n) ?? /* @__PURE__ */ new Map();
944
+ if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new N("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
945
+ s.set(a.revision, k(a)), t.set(n, s);
945
946
  }
946
- return e.set(n, s), !0;
947
+ return e.set(n, l), !0;
947
948
  }
948
949
  };
949
950
  }
950
- function Mn(e) {
951
+ function xn(e, t) {
952
+ const n = D(e);
953
+ if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
954
+ const { revision: r, ...i } = n;
955
+ return D({ ...i, id: t.id, name: t.name });
956
+ }
957
+ function En(e) {
958
+ if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
959
+ const t = /* @__PURE__ */ new Map(), n = [];
960
+ for (const r of e) {
961
+ const i = D(r.document);
962
+ if (t.has(i.id)) throw new Error(`模板 ID 重复:${i.id}`);
963
+ if (r.category !== void 0 && (typeof r.category != "string" || r.category.length > 128) || r.tags !== void 0 && (!Array.isArray(r.tags) || r.tags.length > 20 || r.tags.some((a) => typeof a != "string" || a.length > 128))) throw new TypeError("模板分类和标签无效");
964
+ const { template: o, ...l } = i;
965
+ t.set(i.id, i), n.push({ ...l, ...r.category ? { category: r.category } : {}, ...r.tags ? { tags: [...r.tags] } : {} });
966
+ }
967
+ return n.sort((r, i) => r.id < i.id ? -1 : 1), {
968
+ search: async (r) => {
969
+ we(r.signal);
970
+ const i = r.limit ?? 30;
971
+ if (!Number.isSafeInteger(i) || i < 1 || i > 100) throw new RangeError("模板每页数量应为 1–100");
972
+ const o = r.query?.trim().toLocaleLowerCase() ?? "", l = n.filter((s) => (!r.category || s.category === r.category) && (!r.cursor || s.id > r.cursor) && (!o || [s.id, s.name, s.description, ...s.tags ?? []].some((c) => c?.toLocaleLowerCase().includes(o)))), a = /* @__PURE__ */ new Map();
973
+ for (const s of n) s.category && a.set(s.category, (a.get(s.category) ?? 0) + 1);
974
+ return JSON.parse(JSON.stringify({ items: l.slice(0, i), ...l.length > i ? { next: l[i - 1].id } : {}, categories: Array.from(a, ([s, c]) => ({ id: s, label: s, count: c })) }));
975
+ },
976
+ get: async (r, i) => {
977
+ we(i.signal);
978
+ const o = t.get(r);
979
+ return o ? D(o) : void 0;
980
+ }
981
+ };
982
+ }
983
+ function we(e) {
984
+ if (!e?.aborted) return;
985
+ const t = new Error("模板目录操作已取消");
986
+ throw t.name = "AbortError", t;
987
+ }
988
+ function Sn(e) {
951
989
  return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
952
990
  `);
953
991
  }
954
- function Ct(e, t) {
992
+ function Rt(e, t) {
955
993
  const n = e[e.length - 1];
956
994
  e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
957
995
  }
958
- function xn(e, t = 1e4) {
996
+ function Tn(e, t = 1e4) {
959
997
  if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
960
998
  const n = [[]];
961
- let r = "", i = !1, o = !1, s = 0;
999
+ let r = "", i = !1, o = !1, l = 0;
962
1000
  function a() {
963
- if (++s > t) throw new Error("Clipboard cell limit exceeded");
1001
+ if (++l > t) throw new Error("Clipboard cell limit exceeded");
964
1002
  n[n.length - 1].push(r), r = "", o = !1;
965
1003
  }
966
- for (let l = 0; l < e.length; l++) {
967
- const c = e[l];
1004
+ for (let s = 0; s < e.length; s++) {
1005
+ const c = e[s];
968
1006
  if (i) {
969
1007
  if (c !== '"') {
970
1008
  r += c;
971
1009
  continue;
972
1010
  }
973
- if (e[l + 1] === '"') {
974
- r += '"', l++;
1011
+ if (e[s + 1] === '"') {
1012
+ r += '"', s++;
975
1013
  continue;
976
1014
  }
977
1015
  i = !1, o = !0;
@@ -987,15 +1025,15 @@ function xn(e, t = 1e4) {
987
1025
  }
988
1026
  if (c === "\r" || c === `
989
1027
  `) {
990
- a(), n.push([]), c === "\r" && e[l + 1] === `
991
- ` && l++;
1028
+ a(), n.push([]), c === "\r" && e[s + 1] === `
1029
+ ` && s++;
992
1030
  continue;
993
1031
  }
994
1032
  if (o) throw new Error("Invalid quoted clipboard value");
995
1033
  r += c;
996
1034
  }
997
1035
  if (i) throw new Error("Unclosed clipboard quote");
998
- return a(), Ct(n, e), n;
1036
+ return a(), Rt(n, e), n;
999
1037
  }
1000
1038
  class Pt extends Error {
1001
1039
  constructor(t, n, r) {
@@ -1016,51 +1054,51 @@ class Pt extends Error {
1016
1054
  function p(e, t, n) {
1017
1055
  throw new Pt(t, e, n);
1018
1056
  }
1019
- function Fe(e) {
1057
+ function Oe(e) {
1020
1058
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
1021
1059
  const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
1022
1060
  return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
1023
1061
  }
1024
- function Rt(e) {
1062
+ function At(e) {
1025
1063
  const [t = "", n = "0"] = String(e).toLowerCase().split("e");
1026
1064
  return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
1027
1065
  }
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);
1030
- }
1031
1066
  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);
1067
+ 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 && At(t) > e.precision && p(e, "precision", e.precision);
1033
1068
  }
1034
- function It(e) {
1035
- [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");
1069
+ function It(e, t) {
1070
+ 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);
1036
1071
  }
1037
1072
  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");
1073
+ [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");
1039
1074
  }
1040
- function Nt(e, t) {
1075
+ function Nt(e) {
1076
+ [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");
1077
+ }
1078
+ function Lt(e, t) {
1041
1079
  (!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
1042
1080
  const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
1043
1081
  for (const i of t.options)
1044
1082
  (!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
1083
  }
1046
- function Lt(e) {
1084
+ function Dt(e) {
1047
1085
  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
1086
  }
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);
1087
+ function Ft(e, t) {
1088
+ (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Dt(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" && $t(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Nt(t), t.type === "enum" && Lt(e, t);
1051
1089
  }
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;
1090
+ function Cn(e, t, n) {
1091
+ if (!e.editable) throw new Be("readonly");
1092
+ n && Ft(e, n);
1093
+ const r = Ge(e, t);
1094
+ return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && kt(n, r), n.type === "date" && It(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
1095
  }
1058
1096
  class w extends Error {
1059
1097
  constructor(t) {
1060
1098
  super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
1061
1099
  }
1062
1100
  }
1063
- function O(e) {
1101
+ function z(e) {
1064
1102
  if (!e?.aborted) return;
1065
1103
  const t = new Error("Calculation cancelled");
1066
1104
  throw t.name = "AbortError", t;
@@ -1068,95 +1106,95 @@ function O(e) {
1068
1106
  async function J(e, t = 1) {
1069
1107
  const n = Math.floor(e.scanned / 2048);
1070
1108
  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));
1109
+ z(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), z(e.signal));
1072
1110
  }
1073
1111
  function de(e) {
1074
1112
  return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
1075
1113
  }
1076
- function we(e, t, n) {
1114
+ function be(e, t, n) {
1077
1115
  if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
1078
1116
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1079
1117
  if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
1080
- const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, l) => Math.max(a, l.length), 1);
1118
+ const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, s) => Math.max(a, s.length), 1);
1081
1119
  if (t.columnIndex >= i) throw new w("selection");
1082
- const o = r.table, s = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
1083
- if (o && s && o.id === s.id) {
1084
- const a = s.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1120
+ const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
1121
+ if (o && l && o.id === l.id) {
1122
+ const a = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1085
1123
  if (a < 0) throw new w("selection");
1086
1124
  return { grid: o.id, row: de(r) + t.rowIndex, column: a };
1087
1125
  }
1088
1126
  return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
1089
1127
  }
1090
- function Ft(e, t, n) {
1091
- const r = we(e, t.anchor, t.anchor), i = we(e, t.focus, t.anchor);
1128
+ function Ot(e, t, n) {
1129
+ const r = be(e, t.anchor, t.anchor), i = be(e, t.focus, t.anchor);
1092
1130
  if (r.grid !== i.grid) throw new w("selection");
1093
1131
  const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
1094
1132
  if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
1095
1133
  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
1134
  }
1097
- function Ot(e) {
1135
+ function zt(e) {
1098
1136
  if (!e) return !1;
1099
1137
  const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
1100
1138
  return /[ymdhs]/i.test(t);
1101
1139
  }
1102
- function zt(e) {
1103
- if (e.valueType === "text" || e.valueType === "boolean" || Ot(e.numberFormat)) return null;
1140
+ function Ht(e) {
1141
+ if (e.valueType === "text" || e.valueType === "boolean" || zt(e.numberFormat)) return null;
1104
1142
  const t = e.value;
1105
1143
  if (typeof t != "number" || !Number.isFinite(t)) return null;
1106
1144
  if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
1107
1145
  return t;
1108
1146
  }
1109
- function Ht(e, t, n) {
1147
+ function Wt(e, t, n) {
1110
1148
  if (e.seen.has(n)) return;
1111
1149
  e.seen.add(n), e.selected++;
1112
- const r = t ? zt(t) : null;
1150
+ const r = t ? Ht(t) : null;
1113
1151
  r === null ? e.excluded++ : e.values.push(r);
1114
1152
  }
1115
- function Wt(e, t, n, r) {
1153
+ function _t(e, t, n, r) {
1116
1154
  return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
1117
1155
  }
1118
1156
  function jt(e, t, n) {
1119
1157
  return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
1120
1158
  }
1121
- function _t(e, t, n, r) {
1159
+ function Bt(e, t, n, r) {
1122
1160
  const i = r.origin ? de(e) + t : t, o = jt(e, n, r);
1123
1161
  return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
1124
1162
  }
1125
- function Bt(e, t) {
1163
+ function Gt(e, t) {
1126
1164
  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
1165
  return i > r ? i : 0;
1128
1166
  }
1129
- async function qt(e, t, n, r, i) {
1167
+ async function Ut(e, t, n, r, i) {
1130
1168
  const o = e.grid;
1131
1169
  if (t > r.maxScanned) throw new w("limit");
1132
- const s = o.colWidthsMm?.length ?? o.cells.reduce((l, c) => Math.max(l, c.length), 1);
1133
- if (s > r.maxScanned) throw new w("limit");
1170
+ const l = o.colWidthsMm?.length ?? o.cells.reduce((s, c) => Math.max(s, c.length), 1);
1171
+ if (l > r.maxScanned) throw new w("limit");
1134
1172
  const a = /* @__PURE__ */ new Map();
1135
- for (let l = 0; l < t; l++) {
1136
- l > 0 && l % 2048 === 0 && (await r.yieldToHost(), O(r.signal));
1173
+ for (let s = 0; s < t; s++) {
1174
+ s > 0 && s % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
1137
1175
  let c = 0;
1138
- for (const d of o.cells[l]) {
1139
- for (await J(r); c < s && (a.get(c) ?? 0) > l; ) c++;
1140
- if (c >= s) break;
1141
- 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));
1176
+ for (const d of o.cells[s]) {
1177
+ for (await J(r); c < l && (a.get(c) ?? 0) > s; ) c++;
1178
+ if (c >= l) break;
1179
+ const m = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), h = Math.min(o.cells.length, s + Math.max(1, d?.rowSpan ?? 1));
1142
1180
  m > 1 && await J(r, m - 1);
1143
1181
  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;
1182
+ const g = Bt(e, s, c, n);
1183
+ g && Wt(i, d, g), c += m;
1146
1184
  }
1147
1185
  }
1148
1186
  }
1149
- async function Gt(e, t, n) {
1187
+ async function Vt(e, t, n) {
1150
1188
  const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
1151
1189
  for (let i = 0; i < e.pages.length; i++) {
1152
1190
  await J(n);
1153
1191
  const o = e.pages[i];
1154
- for (let s = 0; s < o.components.length; s++) {
1192
+ for (let l = 0; l < o.components.length; l++) {
1155
1193
  await J(n);
1156
- 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);
1194
+ const a = o.components[l];
1195
+ if (!a.grid || !_t(a, i, l, t) || a.table && a.table.role !== "body") continue;
1196
+ const s = Gt(a, t);
1197
+ s && await Ut(a, s, t, n, r);
1160
1198
  }
1161
1199
  }
1162
1200
  return r;
@@ -1165,7 +1203,7 @@ function B(e) {
1165
1203
  if (!Number.isFinite(e)) throw new w("overflow");
1166
1204
  return e;
1167
1205
  }
1168
- function Ut(e) {
1206
+ function qt(e) {
1169
1207
  let t = 0, n = 0;
1170
1208
  for (const r of e) {
1171
1209
  const i = r - n, o = B(t + i);
@@ -1173,200 +1211,209 @@ function Ut(e) {
1173
1211
  }
1174
1212
  return t;
1175
1213
  }
1176
- async function be(e, t) {
1214
+ async function ye(e, t) {
1177
1215
  let n = [...e], r = new Array(e.length);
1178
1216
  for (let o = 1; o < e.length; o *= 2) {
1179
- for (let s = 0; s < e.length; s += o * 2) {
1180
- const a = Math.min(s + o, e.length), l = Math.min(s + o * 2, e.length);
1181
- let c = s, d = a;
1182
- 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));
1217
+ for (let l = 0; l < e.length; l += o * 2) {
1218
+ const a = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
1219
+ let c = l, d = a;
1220
+ for (let m = l; m < s; m++)
1221
+ r[m] = d >= s || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
1184
1222
  }
1185
1223
  [n, r] = [r, n];
1186
1224
  }
1187
1225
  const i = Math.floor(n.length / 2);
1188
1226
  return n.length % 2 ? n[i] : B(n[i - 1] / 2 + n[i] / 2);
1189
1227
  }
1190
- function Vt(e) {
1191
- const t = Ut(e);
1228
+ function Yt(e) {
1229
+ const t = qt(e);
1192
1230
  let n = 1 / 0, r = -1 / 0;
1193
1231
  for (const i of e)
1194
1232
  n = Math.min(n, i), r = Math.max(r, i);
1195
1233
  return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
1196
1234
  }
1197
- function Yt(e, t) {
1235
+ function Kt(e, t) {
1198
1236
  if (typeof e != "string" || e.length > 256) throw new w("expression");
1199
1237
  const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
1200
1238
  if (!n.length || n.length > 64) throw new w("expression");
1201
1239
  let r = 0;
1202
1240
  function i(a) {
1203
1241
  if (a > 16) throw new w("expression");
1204
- const l = n[r++];
1205
- if (l === "+" || l === "-") return (l === "-" ? -1 : 1) * i(a + 1);
1206
- if (l === "(") {
1242
+ const s = n[r++];
1243
+ if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * i(a + 1);
1244
+ if (s === "(") {
1207
1245
  const c = o(0, a + 1);
1208
1246
  if (n[r++] !== ")") throw new w("expression");
1209
1247
  return c;
1210
1248
  }
1211
- if (l && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(l) && Object.prototype.hasOwnProperty.call(t, l)) return B(t[l]);
1212
- if (l && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(l)) return B(Number(l));
1249
+ if (s && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(s) && Object.prototype.hasOwnProperty.call(t, s)) return B(t[s]);
1250
+ if (s && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(s)) return B(Number(s));
1213
1251
  throw new w("expression");
1214
1252
  }
1215
- function o(a, l) {
1216
- let c = i(l);
1253
+ function o(a, s) {
1254
+ let c = i(s);
1217
1255
  for (; r < n.length; ) {
1218
1256
  const d = n[r], m = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
1219
1257
  if (!m || m < a) break;
1220
1258
  r++;
1221
- const h = o(m + 1, l + 1);
1259
+ const h = o(m + 1, s + 1);
1222
1260
  if (d === "/" && h === 0) throw new w("division");
1223
1261
  c = B(d === "+" ? c + h : d === "-" ? c - h : d === "*" ? c * h : c / h);
1224
1262
  }
1225
1263
  return c;
1226
1264
  }
1227
- const s = o(1, 0);
1265
+ const l = o(1, 0);
1228
1266
  if (r !== n.length) throw new w("expression");
1229
- return s;
1267
+ return l;
1230
1268
  }
1231
- function Kt(e) {
1269
+ function Xt(e) {
1232
1270
  const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
1233
1271
  if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
1234
1272
  if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
1235
1273
  return { maxCells: t, maxScanned: n, precision: r };
1236
1274
  }
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";
1241
- if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(s)) throw new w("expression");
1275
+ async function Rn(e, t, n = {}) {
1276
+ const r = Xt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
1277
+ z(i.signal);
1278
+ const o = await Vt(e, Ot(e, t, r.maxCells), i), l = n.operation ?? "sum";
1279
+ if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new w("expression");
1242
1280
  let a = null;
1243
- if (s === "count") a = o.values.length;
1281
+ if (l === "count") a = o.values.length;
1244
1282
  else if (o.values.length)
1245
- if (s === "median") a = await be(o.values, i);
1283
+ if (l === "median") a = await ye(o.values, i);
1246
1284
  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()];
1285
+ const s = Yt(o.values);
1286
+ l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await ye(o.values, i)), a = Kt(n.expression ?? "", s)) : a = s[l.toUpperCase()];
1249
1287
  }
1250
- if (O(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1288
+ if (z(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1251
1289
  return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
1252
1290
  }
1253
1291
  export {
1254
- Hn as CSS_DPI,
1255
- Pn as DEFAULT_BORDER_PT,
1292
+ jn as CSS_DPI,
1293
+ kn as DEFAULT_BORDER_PT,
1256
1294
  Z as DEFAULT_FONT_FAMILY,
1257
- Rn as DEFAULT_FONT_PT,
1258
- An as DEFAULT_STROKE_COLOR,
1295
+ In as DEFAULT_FONT_PT,
1296
+ $n as DEFAULT_STROKE_COLOR,
1259
1297
  ve as DEFAULT_TEXT_COLOR,
1260
- kn as LINE_HEIGHT,
1261
- Wn as MM_PER_INCH,
1262
- Ir as OutputAssetError,
1263
- qe as OutputFidelityError,
1298
+ Nn as LINE_HEIGHT,
1299
+ Bn as MM_PER_INCH,
1300
+ Lr as OutputAssetError,
1301
+ Ue as OutputFidelityError,
1264
1302
  K as PAPER_SIZES,
1265
- bt as PageBuilder,
1266
- ir as PaginateCellLimitError,
1267
- ar as PaginatePageLimitError,
1303
+ yt as PageBuilder,
1304
+ sr as PaginateCellLimitError,
1305
+ lr as PaginatePageLimitError,
1268
1306
  qn as RENDER_PLAN_SCHEMA_VERSION,
1269
- Dr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1307
+ zr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1270
1308
  w as ReportCalculationError,
1271
- _e as ReportCellEditError,
1309
+ Be as ReportCellEditError,
1272
1310
  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,
1311
+ Vr as ReportParamValidationError,
1312
+ cr as ReportSourceError,
1313
+ Hr as ReportTemplateError,
1314
+ N as ReportTemplateStoreError,
1315
+ Ln as SCHEMA_VERSION_MACH,
1316
+ bt as TemplateBuilder,
1317
+ ri as TreeRowLimitError,
1318
+ dr as applyReportCellEdit,
1319
+ mr as applyReportCellEditBatch,
1320
+ hr as applyReportEditResult,
1321
+ Kn as assertRenderPlan,
1283
1322
  qr as assertReportParams,
1284
- Sn as calculateReportSelection,
1285
- Qn as charWidthEm,
1323
+ Rn as calculateReportSelection,
1324
+ nr as charWidthEm,
1286
1325
  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,
1326
+ xn as cloneReportTemplate,
1327
+ wn as columnsFromContract,
1328
+ dt as computePageWindow,
1329
+ gr as countTemplatePages,
1330
+ rr as createCanvasMeasurer,
1331
+ fn as createCanvasPager,
1332
+ ir as createHeuristicMeasurer,
1333
+ En as createLocalTemplateCatalog,
1334
+ Mn as createMemoryTemplateStore,
1335
+ yn as createProviderReport,
1336
+ ur as createReportCellEdit,
1337
+ fr as createReportCellEditBatch,
1338
+ pr as createReportCellResolver,
1339
+ wr as createReportEditSession,
1340
+ br as createReportSource,
1341
+ bn as createTableTemplate,
1342
+ pn as createTemplate,
1302
1343
  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,
1344
+ Wr as createTemplateRegistry,
1345
+ ii as createTreeTable,
1346
+ er as datasetJsonSchema,
1347
+ yr as defineReport,
1348
+ _r as defineReportTemplate,
1349
+ vr as diffReportTemplates,
1350
+ Mr as estimateListLayoutCells,
1351
+ Fn as evalStyleRule,
1352
+ Kt as evaluateReportAggregateExpression,
1353
+ xr as formatReportCellEdit,
1354
+ Sn as formatReportClipboard,
1355
+ Yr as formatReportDateRange,
1356
+ On as formatValue,
1357
+ Er as getReportCellContext,
1358
+ Sr as getReportEditSession,
1316
1359
  ae as heuristicMeasurer,
1317
- Nr as inspectOutputCapabilities,
1360
+ Fr as inspectOutputCapabilities,
1318
1361
  ee as isImageBackedComponent,
1319
- Gr as isReportDate,
1320
- Ee as isRichText,
1362
+ Kr as isReportDate,
1363
+ Xr as isReportMonth,
1364
+ Jr as isReportYear,
1365
+ Se as isRichText,
1321
1366
  le as measurePageSizePx,
1322
- nr as measureTextMm,
1323
- Me as mergeComponentStyles,
1367
+ ar as measureTextMm,
1368
+ xe as mergeComponentStyles,
1324
1369
  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,
1370
+ Gn as mmToPxFactor,
1371
+ Tr as paginateTemplate,
1372
+ Cr as paginateTemplatePages,
1373
+ zn as parseDateLocal,
1374
+ Cn as parseReportCellFieldInput,
1375
+ Ge as parseReportCellInput,
1376
+ Tn as parseReportClipboard,
1377
+ Zr as parseReportDateRange,
1378
+ D as parseReportTemplate,
1379
+ mn as planFontSizePx,
1380
+ Rr as projectListColumns,
1381
+ O as ptToPx,
1382
+ Un as pxToMm,
1383
+ Pr as registerReportEditSession,
1384
+ Ar as relocateReportCellEdits,
1385
+ ke as renderComponent,
1386
+ at as renderPage,
1387
+ dn as renderPlan,
1388
+ gn as renderPlanToCanvas,
1343
1389
  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,
1390
+ hn as renderPlanToImages,
1391
+ kr as reportCellEditKey,
1392
+ G as reportOutputDiagnostics,
1393
+ Qr as reportParamsJsonSchema,
1394
+ Me as resolveBoxBorders,
1395
+ W as resolveFontSize,
1396
+ Ce as resolveGridLayout,
1351
1397
  Q as resolveLineHeight,
1352
- De as resolvePaper,
1398
+ Fe as resolvePaper,
1353
1399
  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,
1400
+ j as resolveStroke,
1401
+ Ee as resolveTextColor,
1402
+ Ir as reviewReportTemplate,
1403
+ H as round,
1404
+ jr as serializeReportTemplate,
1405
+ $r as summarizeReportCellEdits,
1406
+ Hn as toExcelNumberFormat,
1407
+ Wn as toNumber,
1408
+ Xn as validateComponent,
1363
1409
  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
1410
+ Jn as validatePage,
1411
+ Zn as validateRenderPlan,
1412
+ Ft as validateReportCellFieldDefinition,
1413
+ ei as validateReportParamDefinitions,
1414
+ ti as validateReportParams,
1415
+ Br as validateReportTemplate,
1416
+ Gr as validateReportTemplateDocument,
1417
+ ai as validateTreeOptions,
1418
+ Te as wrapText
1372
1419
  };