@agile-team/mach-report 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +14 -9
  2. package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
  4. package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-CUQLgoxa.cjs} +1 -1
  5. package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-OKesP_nO.js} +1 -1
  6. package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-ruxcbfY6.js} +3 -3
  8. package/dist/ReportPreview-BcDKCLiK.js +4834 -0
  9. package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
  12. package/dist/{RuleEditor-XhGHK8DE.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
  13. package/dist/{RuleEditor-C_Clasvd.js → RuleEditor-CGl9XY2s.js} +2 -2
  14. package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-SXCjaPKR.js} +1 -1
  16. package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
  17. package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
  18. package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-CJ9PLc48.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
  20. package/dist/analytics.d.cts +2 -0
  21. package/dist/analytics.d.ts +2 -0
  22. package/dist/artifact-integrity.json +99 -91
  23. package/dist/{assets-DEaz4qsp.js → assets-CqIbfbTr.js} +24 -22
  24. package/dist/assets-e4YSke8n.cjs +1 -0
  25. package/dist/auto-YR7a4BtF.js +240 -0
  26. package/dist/auto-uVBjX1j5.cjs +1 -0
  27. package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
  28. package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
  29. package/dist/capabilities-DDwXr_cA.js +103 -0
  30. package/dist/capabilities-DNLyZdNw.cjs +1 -0
  31. package/dist/codes.d.cts +2 -0
  32. package/dist/codes.d.ts +2 -0
  33. package/dist/component-tree-Ca6YYfHq.js +61 -0
  34. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  35. package/dist/config-Dg_o8e7m.cjs +1 -0
  36. package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
  37. package/dist/designer-BfQSahxq.js +5163 -0
  38. package/dist/designer-CPPdeM5_.cjs +2 -0
  39. package/dist/designer.cjs +1 -1
  40. package/dist/designer.d.cts +53 -0
  41. package/dist/designer.d.ts +53 -0
  42. package/dist/designer.js +1 -1
  43. package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
  44. package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
  45. package/dist/drill-CsdjgkRM.cjs +1 -0
  46. package/dist/{drill-ByJviLXS.js → drill-DIGsZfyB.js} +11 -11
  47. package/dist/encoding-BOGq4qYL.js +21 -0
  48. package/dist/encoding-BYF9ZTl9.cjs +1 -0
  49. package/dist/{font-loader-Q3bQjmrI.js → font-loader-CzI1GuBc.js} +1 -1
  50. package/dist/{font-loader-B_UkxpzC.cjs → font-loader-EKLzOJxf.cjs} +1 -1
  51. package/dist/index.cjs +7 -8
  52. package/dist/index.d.cts +2 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +865 -834
  55. package/dist/json-snapshot-D6ioHth9.js +1702 -0
  56. package/dist/json-snapshot-DknkjvxP.cjs +2 -0
  57. package/dist/{pdf-CvvrjPQg.cjs → pdf-ByVCb1i6.cjs} +48 -50
  58. package/dist/{pdf-BwNyeGpt.js → pdf-DJ5S6ukC.js} +2737 -2749
  59. package/dist/pdf.cjs +1 -1
  60. package/dist/pdf.d.cts +2 -0
  61. package/dist/pdf.d.ts +2 -0
  62. package/dist/pdf.js +2 -2
  63. package/dist/{plugin-Ca_XZG3l.js → plugin-C2j5_mhx.js} +1 -1
  64. package/dist/{plugin-DHO7X8z2.cjs → plugin-Dr39GBRG.cjs} +1 -1
  65. package/dist/prepared-DdrjLC7L.cjs +1 -0
  66. package/dist/prepared-DqtpvRTn.js +87 -0
  67. package/dist/progress-BXzlVbIp.js +29 -0
  68. package/dist/progress-DJBd9Rb9.cjs +1 -0
  69. package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
  70. package/dist/protocol-BzwMP4Vw.cjs +1 -0
  71. package/dist/protocol-kt4Iy6-3.js +90 -0
  72. package/dist/{record-bindings-Do_b3h4V.js → record-bindings-CZWBJ1fU.js} +9 -10
  73. package/dist/record-bindings-DUX1VMlR.cjs +1 -0
  74. package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-CWNvIjkV.js} +1 -1
  75. package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
  76. package/dist/report-encoding-worker.cjs +1 -0
  77. package/dist/report-encoding-worker.d.ts +1 -0
  78. package/dist/report-encoding-worker.js +2 -0
  79. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  80. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  81. package/dist/runtime-BjKBI530.js +168 -0
  82. package/dist/runtime-CBFEPKEs.cjs +1 -0
  83. package/dist/sbom.cdx.json +2 -2
  84. package/dist/server/node.d.cts +86 -1
  85. package/dist/server/node.d.ts +86 -1
  86. package/dist/server-node.cjs +5 -1
  87. package/dist/server-node.js +4558 -473
  88. package/dist/server.cjs +1 -1
  89. package/dist/server.d.cts +8 -1
  90. package/dist/server.d.ts +8 -1
  91. package/dist/server.js +634 -792
  92. package/dist/sha256-BshdOkCC.cjs +1 -0
  93. package/dist/sha256-DTG-Gq8i.js +157 -0
  94. package/dist/style-67OqfNed.js +73 -0
  95. package/dist/style-C22Pbv3T.cjs +1 -0
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-j2B1MJlL.js → template-catalog-BtR2JmCL.js} +9 -9
  98. package/dist/{template-catalog-FJE_c9Qe.cjs → template-catalog-C2NLdrwB.cjs} +1 -1
  99. package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
  100. package/dist/{template-fragments-BGbQLGlV.js → template-fragments-By0aZC1D.js} +2 -2
  101. package/dist/template-registry-C62vpv4a.cjs +1 -0
  102. package/dist/{template-registry-BtaKPELV.js → template-registry-Cw3vRTX2.js} +389 -321
  103. package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
  104. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  105. package/dist/vue/async.d.cts +66 -0
  106. package/dist/vue/async.d.ts +66 -0
  107. package/dist/vue/index.d.cts +89 -1
  108. package/dist/vue/index.d.ts +89 -1
  109. package/dist/vue-async.cjs +1 -1
  110. package/dist/vue-async.js +3 -3
  111. package/dist/vue.cjs +1 -1
  112. package/dist/vue.js +7 -7
  113. package/dist/{workbook-session-BvToI-Fd.js → workbook-session-BeSO8PFB.js} +153 -140
  114. package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-Cbts-22R.cjs} +12 -12
  115. package/dist/worker.cjs +1 -1
  116. package/dist/worker.d.cts +84 -1
  117. package/dist/worker.d.ts +84 -1
  118. package/dist/worker.js +12 -157
  119. package/dist/xlsx-node.cjs +33 -33
  120. package/dist/xlsx-node.js +1282 -1289
  121. package/dist/xlsx.cjs +4 -3
  122. package/dist/xlsx.d.cts +2 -0
  123. package/dist/xlsx.d.ts +2 -0
  124. package/dist/xlsx.js +297 -279
  125. package/package.json +6 -3
  126. package/dist/ReportPreview-ChV19HBp.js +0 -4619
  127. package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
  128. package/dist/assets-B9ImAi6_.cjs +0 -1
  129. package/dist/batch-BaP6pWDE.cjs +0 -1
  130. package/dist/batch-CGyt-b2W.js +0 -273
  131. package/dist/capabilities-CAh2Nrue.cjs +0 -1
  132. package/dist/capabilities-DskCHs3V.js +0 -69
  133. package/dist/config-D10us76d.cjs +0 -1
  134. package/dist/data-explanation-B8MZRYVS.js +0 -16
  135. package/dist/data-explanation-DE55G30w.cjs +0 -1
  136. package/dist/defaults-DXhiM1ZD.js +0 -10
  137. package/dist/defaults-xhmcLLrf.cjs +0 -1
  138. package/dist/designer-2bDlcNXQ.js +0 -5136
  139. package/dist/designer-BT7XCdbW.cjs +0 -2
  140. package/dist/drill-DYTxuL3A.cjs +0 -1
  141. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  142. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  143. package/dist/json-snapshot-DFb2eWkf.js +0 -1416
  144. package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
  145. package/dist/prepared-CFy9B75C.cjs +0 -1
  146. package/dist/prepared-ajM-H-9B.js +0 -69
  147. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  148. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  149. package/dist/render-plan-Ck6koX9L.js +0 -13
  150. package/dist/sha256-ArEYjaTI.cjs +0 -1
  151. package/dist/sha256-DPEuJ3nh.js +0 -155
  152. package/dist/style-CQ1PK8ZB.js +0 -67
  153. package/dist/style-UgIJSA1F.cjs +0 -1
  154. package/dist/template-registry-Co1zPq5e.cjs +0 -1
  155. package/dist/textwrap-CWHyzkBH.cjs +0 -4
package/dist/index.js CHANGED
@@ -1,36 +1,32 @@
1
- import { D as te, a as Te } from "./defaults-DXhiM1ZD.js";
2
- import { b as Yn, c as Kn, d as Jn, L as Xn, S as Zn } from "./defaults-DXhiM1ZD.js";
3
- import { R as er, e as tr, f as nr, p as rr, b as ar, t as ir, d as or } from "./record-bindings-Do_b3h4V.js";
4
- import { a as j, r as _, b as ne, c as G, d as Ce, m as se, e as Re, p as W, f as Pe, P as Z } from "./style-CQ1PK8ZB.js";
5
- import { C as lr, M as cr, g as mr, h as dr } from "./style-CQ1PK8ZB.js";
6
- import { i as re, a as Ae } from "./render-plan-Ck6koX9L.js";
7
- import { R as gr } from "./render-plan-Ck6koX9L.js";
8
- import { v as $e, R as ke, p as U, a as Je } from "./template-registry-BtaKPELV.js";
9
- import { b as ur, c as pr, d as wr, e as br, s as Mr, f as yr, g as vr, h as xr } from "./template-registry-BtaKPELV.js";
10
- import { v as Xe } from "./dataset-H5pFuQGU.js";
11
- import { d as Sr } from "./dataset-H5pFuQGU.js";
12
- import { h as le, w as Ie } from "./textwrap-DE1kgcJB.js";
13
- import { c as Cr, a as Rr, b as Pr, m as Ar } from "./textwrap-DE1kgcJB.js";
14
- import { R as ce, d as Ze, s as Qe } from "./json-snapshot-DFb2eWkf.js";
15
- import { D as kr, P as Ir, a as Nr, b as Lr, c as Dr, e as Fr, f as Or, g as Hr, h as zr, i as Wr, p as Br, j as jr, k as _r, r as Ur, l as Gr } from "./json-snapshot-DFb2eWkf.js";
16
- import { r as Ne } from "./grid-geometry-BNptEcMm.js";
17
- import { r as Le } from "./grid-strokes-DyyG1q_o.js";
18
- import { r as q, n as De, O as et } from "./capabilities-DskCHs3V.js";
19
- import { i as qr } from "./capabilities-DskCHs3V.js";
20
- import { o as tt } from "./progress-D-OTpEav.js";
21
- import { r as me } from "./assets-DEaz4qsp.js";
22
- import { O as Kr } from "./assets-DEaz4qsp.js";
23
- import { c as nt } from "./drill-ByJviLXS.js";
24
- import { R as Xr, a as Zr, m as Qr, r as ea, v as ta } from "./drill-ByJviLXS.js";
25
- import { R as ra, a as aa, f as ia, i as oa, b as sa, c as la, p as ca, r as ma, v as da, d as ha } from "./param-validation-Do7Eg8Zv.js";
26
- import { c as fa, a as ua, d as pa, r as wa, b as ba } from "./template-catalog-j2B1MJlL.js";
27
- import { h as ya, i as va, a as xa } from "./data-explanation-B8MZRYVS.js";
28
- import { c as Sa, i as Ta, t as Ca } from "./template-outline-cnWfT_LK.js";
29
- import { a as Pa, c as Aa, i as $a, b as ka } from "./template-fragments-BGbQLGlV.js";
30
- import { R as rt, p as at } from "./batch-CGyt-b2W.js";
31
- import { a as Na, b as La, c as Da, d as Fa, e as Oa, f as Ha, g as za, r as Wa, s as Ba } from "./batch-CGyt-b2W.js";
32
- import { T as _a, c as Ua, v as Ga } from "./tree-CjVZLRw7.js";
33
- const it = {
1
+ import { D as ne, a as U, r as z, b as _, c as Pe, d as q, e as Ae, m as le, f as ke, g as ce, p as W, P as Q } from "./style-67OqfNed.js";
2
+ import { C as Zn, h as Qn, i as er, j as tr, L as nr, M as rr, S as ir, k as ar, l as or } from "./style-67OqfNed.js";
3
+ import { R as lr, e as cr, f as dr, p as mr, b as hr, t as gr, d as fr } from "./record-bindings-CZWBJ1fU.js";
4
+ import { i as re, a as $e } from "./component-tree-Ca6YYfHq.js";
5
+ import { R as pr } from "./component-tree-Ca6YYfHq.js";
6
+ import { v as Ie, R as Ne, p as G, a as Qe } from "./template-registry-Cw3vRTX2.js";
7
+ import { b as br, c as Mr, d as vr, e as yr, s as xr, f as Sr, g as Er, h as Tr } from "./template-registry-Cw3vRTX2.js";
8
+ import { v as et } from "./dataset-H5pFuQGU.js";
9
+ import { d as Rr } from "./dataset-H5pFuQGU.js";
10
+ import { h as de, w as Le } from "./textwrap-BEIg2w8y.js";
11
+ import { c as Ar, a as kr, b as $r, m as Ir } from "./textwrap-BEIg2w8y.js";
12
+ import { R as me, d as tt, a as nt, p as rt, s as it } from "./json-snapshot-D6ioHth9.js";
13
+ import { D as Lr, P as Dr, b as Fr, c as Or, e as zr, f as Hr, g as Br, h as Wr, i as _r, j as jr, k as Ur, l as Gr, m as qr, n as Vr, o as Yr, q as Kr, r as Jr, t as Xr, u as Zr, v as Qr, w as ei, x as ti, y as ni, z as ri, A as ii, B as ai, C as oi } from "./json-snapshot-D6ioHth9.js";
14
+ import { r as De } from "./grid-geometry-BNptEcMm.js";
15
+ import { r as Fe, d as at } from "./rich-text-layout-Ct5WrY1g.js";
16
+ import { r as Y, O as ot } from "./capabilities-DDwXr_cA.js";
17
+ import { i as li } from "./capabilities-DDwXr_cA.js";
18
+ import { o as st } from "./progress-Hc2vxoCs.js";
19
+ import { n as Oe } from "./diagnostic-notification-qGAYZdkB.js";
20
+ import { r as he } from "./assets-CqIbfbTr.js";
21
+ import { O as di } from "./assets-CqIbfbTr.js";
22
+ import { c as lt } from "./drill-DIGsZfyB.js";
23
+ import { R as hi, a as gi, m as fi, r as ui, v as pi } from "./drill-DIGsZfyB.js";
24
+ import { R as bi, a as Mi, f as vi, i as yi, b as xi, c as Si, p as Ei, r as Ti, v as Ci, d as Ri } from "./param-validation-Do7Eg8Zv.js";
25
+ import { c as Ai, a as ki, d as $i, r as Ii, b as Ni } from "./template-catalog-BtR2JmCL.js";
26
+ import { c as Di, i as Fi, t as Oi } from "./template-outline-cnWfT_LK.js";
27
+ import { a as Hi, c as Bi, i as Wi, b as _i } from "./template-fragments-By0aZC1D.js";
28
+ import { T as Ui, c as Gi, v as qi } from "./tree-CjVZLRw7.js";
29
+ const ct = {
34
30
  root: "mr-root",
35
31
  page: "mr-page",
36
32
  comp: "mr-comp",
@@ -47,18 +43,18 @@ const it = {
47
43
  cell: "mr-cell",
48
44
  unknown: "mr-unknown"
49
45
  };
50
- function T(e, t) {
51
- return t?.classNames?.[e] ?? it[e];
46
+ function E(e, t) {
47
+ return t?.classNames?.[e] ?? ct[e];
52
48
  }
53
- class ot {
49
+ class dt {
54
50
  constructor() {
55
51
  this.props = [];
56
52
  }
57
53
  add(t, n) {
58
54
  return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
59
55
  }
60
- mm(t, n, r, a = 2) {
61
- return this.add(t, `${j(se(n, r), a)}px`);
56
+ mm(t, n, r, i = 2) {
57
+ return this.add(t, `${U(le(n, r), i)}px`);
62
58
  }
63
59
  toString() {
64
60
  let t = "";
@@ -71,522 +67,557 @@ class ot {
71
67
  n && (t.style.cssText = n);
72
68
  }
73
69
  }
74
- function y(e, t = "unset") {
75
- return new ot().add("all", t).add("display", e).add("box-sizing", "border-box");
70
+ function v(e, t = "unset") {
71
+ return new dt().add("all", t).add("display", e).add("box-sizing", "border-box");
76
72
  }
77
- function Fe(e, t, n) {
78
- 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(ne(t))).add("text-align", t.align);
79
- const r = _(t, n);
80
- e.add("font-size", `${j(r.fontSizePx, 2)}px`);
73
+ function ze(e, t, n) {
74
+ 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(_(t))).add("text-align", t.align);
75
+ const r = z(t, n);
76
+ e.add("font-size", `${U(r.fontSizePx, 2)}px`);
81
77
  }
82
- function st(e, t, n) {
78
+ function mt(e, t, n) {
83
79
  const r = t.style ?? {};
84
- Fe(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);
85
- }
86
- function lt(e, t, n, r, a, o) {
87
- const l = e.cell, i = o.createElement("td");
88
- i.className = T("cell", a), i.dataset.mrRowIndex = String(e.ri), i.dataset.mrColumnIndex = String(e.ci), i.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (i.colSpan = l.colSpan), l.rowSpan && (i.rowSpan = l.rowSpan);
89
- const s = Re(t.style, l.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", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
90
- Fe(c, s, r), c.applyTo(i);
91
- const m = o.createElement("div");
92
- m.className = "mr-cell-content", y("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(m), l.text != null && m.append(l.text);
93
- for (const d of l.children ?? []) m.appendChild(Oe(d, r, a, o));
94
- return i.appendChild(m), i;
95
- }
96
- function ct(e, t, n, r) {
97
- return Le(e, t).map((a) => {
98
- const o = `${j(a.widthPt * n / 72, 2)}px solid ${a.color}`, l = r.createElement("div");
80
+ ze(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);
81
+ }
82
+ function ht(e, t, n, r, i, o) {
83
+ const l = e.cell, a = o.createElement("td");
84
+ 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);
85
+ const s = ke(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");
86
+ ze(c, s, r), c.applyTo(a);
87
+ const d = o.createElement("div");
88
+ 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.richParagraphs?.length ? d.appendChild(He({ ...t, kind: "text", richParagraphs: l.richParagraphs }, r, i, o)) : l.text != null && d.append(l.text);
89
+ for (const h of l.children ?? []) d.appendChild(Be(h, r, i, o));
90
+ return a.appendChild(d), a;
91
+ }
92
+ function gt(e, t, n, r) {
93
+ return Fe(e, t).map((i) => {
94
+ const o = `${U(i.widthPt * n / 72, 2)}px solid ${i.color}`, l = r.createElement("div");
99
95
  l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
100
- const i = a.kind === "h";
101
- return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", i ? a.from : a.pos, n).mm("top", i ? a.pos : a.from, n).mm("width", i ? a.to - a.from : 0, n).mm("height", i ? 0 : a.to - a.from, n).add(i ? "border-top" : "border-left", o).applyTo(l), l;
96
+ const a = i.kind === "h";
97
+ 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;
102
98
  });
103
99
  }
104
- function mt(e, t, n, r, a) {
105
- const o = a.createElement("table");
106
- o.className = T("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
107
- const l = Ne(e, t.widthMm, t.heightMm), i = a.createElement("tbody");
108
- y("contents").applyTo(i), o.appendChild(i);
100
+ function ft(e, t, n, r, i) {
101
+ const o = i.createElement("table");
102
+ o.className = E("grid", r), o.setAttribute("role", "table"), v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
103
+ const l = De(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
104
+ v("contents").applyTo(a), o.appendChild(a);
109
105
  const s = e.cells.map(() => {
110
- const m = a.createElement("tr");
111
- return m.className = T("row", r), m.setAttribute("role", "row"), y("contents").applyTo(m), i.appendChild(m), m;
106
+ const d = i.createElement("tr");
107
+ return d.className = E("row", r), d.setAttribute("role", "row"), v("contents").applyTo(d), a.appendChild(d), d;
112
108
  });
113
- for (const m of l.cells)
114
- s[m.ri].appendChild(lt(m, t, e.paddingMm ?? 0.5, n, r, a));
115
- const c = a.createElement("div");
116
- return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...ct(l, t, n, a)), c;
117
- }
118
- function dt(e, t, n, r) {
119
- const a = r.createElement("div");
120
- a.className = T("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(a);
109
+ for (const d of l.cells)
110
+ s[d.ri].appendChild(ht(d, t, e.paddingMm ?? 0.5, n, r, i));
111
+ const c = i.createElement("div");
112
+ return v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...gt(l, t, n, i)), c;
113
+ }
114
+ function ut(e, t, n, r) {
115
+ const i = r.createElement("div");
116
+ 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);
121
117
  for (const o of e.segments || []) {
122
118
  const l = r.createElement("span");
123
- l.className = T("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
124
- const i = y("inline");
119
+ l.className = E("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
120
+ const a = v("inline");
125
121
  if (o.style) {
126
122
  const s = o.style;
127
- i.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) && i.add("font-size", `${j(_(s, t).fontSizePx, 2)}px`);
123
+ a.add("color", s.color).add("background-color", s.backgroundColor).add("font-family", s.fontFamily).add("line-height", s.lineHeight).add("letter-spacing", s.letterSpacing == null ? void 0 : `${s.letterSpacing * t / 72}px`).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", `${U(z(s, t).fontSizePx, 2)}px`);
128
124
  }
129
- i.applyTo(l), a.appendChild(l);
125
+ a.applyTo(l), i.appendChild(l);
130
126
  }
131
- return a;
132
- }
133
- function ht(e, t, n, r) {
134
- if (Ae(e)) {
135
- const a = r.createElement("div");
136
- a.className = T("rich", n), y("block").applyTo(a);
137
- for (const o of e.richParagraphs) a.appendChild(dt(o, t, n, r));
138
- return a;
127
+ return i;
128
+ }
129
+ function He(e, t, n, r) {
130
+ if ($e(e)) {
131
+ const i = r.createElement("div");
132
+ i.className = E("rich", n), v("block").applyTo(i);
133
+ for (const o of e.richParagraphs) i.appendChild(ut(o, t, n, r));
134
+ return i;
139
135
  }
140
136
  if (Array.isArray(e.lines) && e.lines.length > 0) {
141
- const a = r.createElement("div");
142
- a.className = T("lines", n), y("block").applyTo(a);
137
+ const i = r.createElement("div");
138
+ i.className = E("lines", n), v("block").applyTo(i);
143
139
  for (const o of e.lines) {
144
140
  const l = r.createElement("div");
145
- l.className = T("line", n), l.textContent = o, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), a.appendChild(l);
141
+ l.className = E("line", n), l.textContent = o, v("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
146
142
  }
147
- return a;
143
+ return i;
148
144
  }
149
145
  return e.text ?? "";
150
146
  }
151
- function gt(e, t, n, r) {
152
- const a = r.createElement("div");
153
- a.className = T("text", n);
147
+ function pt(e, t, n, r) {
148
+ const i = r.createElement("div");
149
+ i.className = E("text", n);
154
150
  const o = e.style || {};
155
- 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(a), a.append(ht(e, t, n, r)), a;
151
+ 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(He(e, t, n, r)), i;
156
152
  }
157
- function ft(e, t, n) {
153
+ function wt(e, t, n) {
158
154
  const r = n.createElement("img");
159
- return r.className = T("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;
155
+ 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;
160
156
  }
161
- function be(e, t, n, r) {
162
- const a = r.createElement("div");
163
- a.className = T("shape", n);
164
- const o = e.style || {}, l = G(o), i = Ce(o), s = `${j(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = y("block");
165
- return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (i.top && c.add("border-top", s), i.right && c.add("border-right", s), i.bottom && c.add("border-bottom", s), i.left && c.add("border-left", s)) : e.kind === "ellipse" ? (i.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(a), a;
157
+ function ye(e, t, n, r) {
158
+ const i = r.createElement("div");
159
+ i.className = E("shape", n);
160
+ const o = e.style || {}, l = q(o), a = Ae(o), s = `${U(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = v("block");
161
+ 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;
166
162
  }
167
- function ut(e, t, n) {
168
- const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), a = se(e.widthMm, t), o = se(e.heightMm, t);
169
- r.setAttribute("width", String(Math.max(1, a))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
163
+ function bt(e, t, n) {
164
+ const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = le(e.widthMm, t), o = le(e.heightMm, t);
165
+ 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";
170
166
  const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
171
- l.setAttribute("x1", "0"), l.setAttribute("x2", String(a)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
172
- const i = G({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
173
- return l.setAttribute("stroke", i.color), l.setAttribute("stroke-width", String(i.widthPt * t / 72)), r.appendChild(l), r;
174
- }
175
- function Oe(e, t, n, r) {
176
- const a = r.createElement("div");
177
- a.className = `${T("comp", n)} mr-kind-${e.kind}`;
178
- 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");
179
- if (st(o, e, t), o.applyTo(a), re(e))
180
- return a.appendChild(ft(e, n, r)), a;
167
+ 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));
168
+ const a = q({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
169
+ return l.setAttribute("stroke", a.color), l.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(l), r;
170
+ }
171
+ function Be(e, t, n, r) {
172
+ const i = r.createElement("div");
173
+ i.className = `${E("comp", n)} mr-kind-${e.kind}`;
174
+ 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");
175
+ if (mt(o, e, t), o.applyTo(i), re(e))
176
+ return i.appendChild(wt(e, n, r)), i;
181
177
  if (e.kind === "text")
182
- return a.appendChild(gt(e, t, n, r)), a;
178
+ return i.appendChild(pt(e, t, n, r)), i;
183
179
  if (e.grid) {
184
- const i = be(e, t, n, r);
185
- return i.appendChild(mt(e.grid, e, t, n, r)), a.appendChild(i), a;
180
+ const a = ye(e, t, n, r);
181
+ return a.appendChild(ft(e.grid, e, t, n, r)), i.appendChild(a), i;
186
182
  }
187
183
  if (e.kind === "line" && e.lineDirection)
188
- return a.appendChild(ut(e, t, r)), a;
184
+ return i.appendChild(bt(e, t, r)), i;
189
185
  if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
190
- return a.appendChild(be(e, t, n, r)), a;
186
+ return i.appendChild(ye(e, t, n, r)), i;
191
187
  const l = r.createElement("div");
192
- return l.className = T("unknown", n), y("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), a.appendChild(l), a;
188
+ 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;
193
189
  }
194
- function pt(e, t, n, r) {
195
- const a = r.createElement("div");
196
- return a.className = T("page", n), y("block", "initial").add("position", "relative").add("font-family", te).add("font-size", `${j(_(void 0, t).fontSizePx, 2)}px`).add("line-height", String(ne(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", Te).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(a), e.components.forEach((o, l) => {
197
- const i = Oe(o, t, n, r);
198
- i.dataset.mrComponentIndex = String(l), a.appendChild(i);
199
- }), a;
190
+ function Mt(e, t, n, r) {
191
+ const i = r.createElement("div");
192
+ return i.className = E("page", n), v("block", "initial").add("position", "relative").add("font-family", ne).add("font-size", `${U(z(void 0, t).fontSizePx, 2)}px`).add("line-height", String(_(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", Pe).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, l) => {
193
+ const a = Be(o, t, n, r);
194
+ a.dataset.mrComponentIndex = String(l), i.appendChild(a);
195
+ }), i;
200
196
  }
201
- function Rn(e, t, n = {}) {
197
+ function $n(e, t, n = {}) {
202
198
  const r = n.dpi ?? 96;
203
- q(e, "dom", n);
204
- const a = t.createElement("div");
205
- return a.className = T("root", n), y("block").applyTo(a), a.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
206
- a.appendChild(pt(o, r, n, t));
207
- }), a;
199
+ Y(e, "dom", n);
200
+ const i = t.createElement("div");
201
+ return i.className = E("root", n), v("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
202
+ i.appendChild(Mt(o, r, n, t));
203
+ }), i;
204
+ }
205
+ function ge(e, t, n, r, i, o, l, a = "top") {
206
+ 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";
207
+ const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
208
+ `), d = c.length * s;
209
+ let h = r;
210
+ a === "middle" ? h = r + (o - d) / 2 : a === "bottom" && (h = r + o - d), c.forEach((m, g) => {
211
+ const f = h + g * s + t.fontSizePx * 0.8;
212
+ vt(e, m, t, n, f, i), t.underline && m && yt(e, m, t, n, f, i);
213
+ }), e.textAlign = "left";
214
+ }
215
+ function vt(e, t, n, r, i, o) {
216
+ const l = Array.from(t), a = n.letterSpacingPx ?? 0;
217
+ if (!a) {
218
+ e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
219
+ const h = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
220
+ e.fillText(t, h, i);
221
+ return;
222
+ }
223
+ 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;
224
+ e.textAlign = "left";
225
+ let d = "";
226
+ l.forEach((h, m) => {
227
+ e.fillText(h, c + e.measureText(d).width + m * a, i), d += h;
228
+ });
229
+ }
230
+ function yt(e, t, n, r, i, o) {
231
+ const l = e.measureText(t).width + Math.max(0, Array.from(t).length - 1) * (n.letterSpacingPx ?? 0), a = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
232
+ e.strokeStyle = n.color, e.lineWidth = Math.max(0.5, n.fontSizePx / 20), e.beginPath(), e.moveTo(a, i + 1), e.lineTo(a + l, i + 1), e.stroke();
233
+ }
234
+ function We(e, t, n, r, i) {
235
+ const o = r / 72, l = (a) => {
236
+ e.font = `${a.italic ? "italic " : ""}${a.bold ? "bold " : ""}${z(a, r).fontSizePx}px ${a.fontFamily ?? i}`, "letterSpacing" in e && (e.letterSpacing = "0px");
237
+ };
238
+ at(t, { x: n.x / o, yTop: -n.y / o, width: n.width / o, height: n.height / o }, {
239
+ measure(a, s) {
240
+ return l(s), e.measureText(a).width / o + (s.letterSpacing ?? 0);
241
+ },
242
+ draw(a, s, c, d, h) {
243
+ const m = z(s, r).fontSizePx, g = -d * o - m * 0.8;
244
+ s.backgroundColor && (e.fillStyle = s.backgroundColor, e.fillRect(c * o, g, h * o, m * _(s))), ge(e, { text: a, fontSizePx: m, bold: !!s.bold, italic: s.italic, underline: s.underline, color: ce(s), align: "left", lineHeight: _(s), letterSpacingPx: (s.letterSpacing ?? 0) * o }, c * o, g, h * o, m, s.fontFamily ?? i);
245
+ }
246
+ });
208
247
  }
209
- function $(e) {
248
+ function k(e) {
210
249
  if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
211
250
  }
212
- const wt = (e, t) => ($(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
213
- const a = new Image(), o = () => {
214
- a.onload = null, a.onerror = null, t?.removeEventListener("abort", l);
251
+ const xt = (e, t) => (k(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
252
+ const i = new Image(), o = () => {
253
+ i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
215
254
  }, l = () => {
216
- o(), a.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
255
+ o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
217
256
  };
218
- a.onload = () => {
219
- o(), n(a);
220
- }, a.onerror = () => {
257
+ i.onload = () => {
258
+ o(), n(i);
259
+ }, i.onerror = () => {
221
260
  o(), r(new Error("Image could not be decoded for Canvas output."));
222
- }, t?.addEventListener("abort", l, { once: !0 }), a.src = e;
261
+ }, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
223
262
  }) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
224
- function bt(e, t, n) {
225
- return $(n), n ? new Promise((r, a) => {
226
- const o = () => a(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
227
- n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, a).finally(() => n.removeEventListener("abort", o));
263
+ function St(e, t, n) {
264
+ return k(n), n ? new Promise((r, i) => {
265
+ const o = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
266
+ n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", o));
228
267
  }) : e(t);
229
268
  }
230
- async function Mt(e, t, n) {
269
+ function* fe(e) {
270
+ function* t(n, r, i, o) {
271
+ if (o.has(n)) throw new TypeError("Cyclic grid children cannot be rendered.");
272
+ re(n) && (yield { component: n, componentIndex: r, componentPath: i });
273
+ const l = new Set(o).add(n);
274
+ for (const [a, s] of (n.grid?.cells ?? []).entries()) for (const [c, d] of s.entries()) for (const [h, m] of (d?.children ?? []).entries()) yield* t(m, r, [...i, a, c, h], l);
275
+ }
276
+ for (const [n, r] of e.components.entries()) yield* t(r, n, [], /* @__PURE__ */ new Set());
277
+ }
278
+ async function Et(e, t, n) {
231
279
  const r = /* @__PURE__ */ new Map();
232
- for (const a of e.components)
233
- !re(a) || r.has(a.imageData) || r.set(a.imageData, await bt(t, a.imageData, n));
234
- return $(n), r;
235
- }
236
- function yt(e, t, n, r, a, o) {
237
- const l = t, i = l.naturalWidth ?? l.width ?? a, s = l.naturalHeight ?? l.height ?? o;
238
- if (i <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
239
- const c = Math.min(a / i, o / s), m = i * c, d = s * c;
240
- e.drawImage(t, n + (a - m) / 2, r + (o - d) / 2, m, d);
241
- }
242
- function vt(e) {
243
- return nt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
244
- }
245
- const de = 96 / 25.4;
246
- function he(e, t = 96) {
247
- const n = t / 96 * de;
280
+ for (const { component: i } of fe(e))
281
+ !re(i) || r.has(i.imageData) || r.set(i.imageData, await St(t, i.imageData, n));
282
+ return k(n), r;
283
+ }
284
+ function Tt(e, t, n, r, i, o) {
285
+ const l = t, a = l.naturalWidth ?? l.width ?? i, s = l.naturalHeight ?? l.height ?? o;
286
+ if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
287
+ const c = Math.min(i / a, o / s), d = a * c, h = s * c;
288
+ e.drawImage(t, n + (i - d) / 2, r + (o - h) / 2, d, h);
289
+ }
290
+ function Ct(e) {
291
+ return lt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
292
+ }
293
+ const ue = 96 / 25.4;
294
+ function pe(e, t = 96) {
295
+ const n = t / 96 * ue;
248
296
  return {
249
297
  widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
250
298
  heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
251
299
  };
252
300
  }
253
- function He(e, t, n, r = 64e6) {
301
+ function _e(e, t, n, r = 64e6) {
254
302
  if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
255
303
  if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
256
- const a = he(e, n), o = Math.round(a.widthPx * t), l = Math.round(a.heightPx * t);
304
+ const i = pe(e, n), o = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
257
305
  if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
258
306
  return { width: o, height: l };
259
307
  }
260
- function ze(e, t, n, r) {
261
- const a = document.createElement("canvas"), { widthPx: o, heightPx: l } = he(e, n), i = He(e, t, n, r);
262
- a.width = i.width, a.height = i.height, a.style.width = `${o}px`, a.style.height = `${l}px`;
263
- const s = a.getContext("2d");
308
+ function je(e, t, n, r) {
309
+ const i = document.createElement("canvas"), { widthPx: o, heightPx: l } = pe(e, n), a = _e(e, t, n, r);
310
+ i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${l}px`;
311
+ const s = i.getContext("2d");
264
312
  if (!s)
265
313
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
266
- return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: a, ctx: s };
267
- }
268
- function Pn(e, t = 96) {
269
- return _(e, t).fontSizePx;
270
- }
271
- function We(e, t, n, r, a, o, l, i = "top") {
272
- 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";
273
- const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
274
- `), m = c.length * s;
275
- let d = r;
276
- i === "middle" ? d = r + (o - m) / 2 : i === "bottom" && (d = r + o - m), c.forEach((h, g) => {
277
- xt(e, h, t, n, d + g * s + t.fontSizePx * 0.8, a);
278
- }), e.textAlign = "left";
314
+ return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: i, ctx: s };
279
315
  }
280
- function xt(e, t, n, r, a, o) {
281
- const l = Array.from(t), i = n.letterSpacingPx ?? 0;
282
- if (!i) {
283
- e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
284
- const d = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
285
- e.fillText(t, d, a);
286
- return;
287
- }
288
- const s = e.measureText(t).width + Math.max(0, l.length - 1) * i, c = n.align === "center" ? r + (o - s) / 2 : n.align === "right" ? r + o - s : r;
289
- e.textAlign = "left";
290
- let m = "";
291
- l.forEach((d, h) => {
292
- e.fillText(d, c + e.measureText(m).width + h * i, a), m += d;
293
- });
316
+ function In(e, t = 96) {
317
+ return z(e, t).fontSizePx;
294
318
  }
295
- function Et(e, t, n, r, a, o, l) {
296
- for (const i of Le(t, n))
297
- e.strokeStyle = i.color, e.lineWidth = W(i.widthPt, l), e.beginPath(), i.kind === "v" ? (e.moveTo(r + i.pos * o, a + i.from * o), e.lineTo(r + i.pos * o, a + i.to * o)) : (e.moveTo(r + i.from * o, a + i.pos * o), e.lineTo(r + i.to * o, a + i.pos * o)), e.stroke();
319
+ function Rt(e, t, n, r, i, o, l) {
320
+ for (const a of Fe(t, n))
321
+ e.strokeStyle = a.color, e.lineWidth = W(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();
298
322
  }
299
- function St(e, t, n, r, a, o) {
300
- e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + a, r)), t.right && (e.moveTo(n + a, r), e.lineTo(n + a, r + o)), t.bottom && (e.moveTo(n + a, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
323
+ function Pt(e, t, n, r, i, o) {
324
+ 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();
301
325
  }
302
- function Tt(e, t, n, r, a, o, l, i, s, c, m) {
303
- const d = Ne(t, o / i, l / i);
304
- for (const g of d.cells) {
326
+ function At(e, t, n, r, i, o, l, a, s, c, d, h) {
327
+ const m = De(t, o / a, l / a);
328
+ for (const g of m.cells) {
305
329
  const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
306
- f && (e.fillStyle = f, e.fillRect(r + g.xMm * i, a + g.yMm * i, g.widthMm * i, g.heightMm * i));
330
+ f && (e.fillStyle = f, e.fillRect(r + g.xMm * a, i + g.yMm * a, g.widthMm * a, g.heightMm * a));
307
331
  }
308
- Et(e, d, n, r, a, i, s);
309
- const h = t.paddingMm ?? 0.5;
310
- for (const g of d.cells) {
311
- const f = g.cell.text ?? "";
312
- if (!f) continue;
313
- const w = Re(n.style, g.cell.style), C = _(w, s), x = g.cell.indentMm ?? 0, v = Math.max(0, g.widthMm - 2 * h - x), R = Ie(f, v, { fontSizePt: C.fontSizePt, bold: w.bold, italic: w.italic, fontFamily: w.fontFamily ?? c, letterSpacingPt: w.letterSpacing }, m).join(`
314
- `);
315
- We(
316
- e,
317
- {
318
- text: R,
319
- fontSizePx: C.fontSizePx,
320
- bold: w.bold ?? !1,
321
- italic: w.italic,
322
- color: Pe(w, Te),
323
- align: w.align ?? "left",
324
- lineHeight: ne(w),
325
- letterSpacingPx: W(w.letterSpacing ?? 0, s)
326
- },
327
- r + (g.xMm + h + x) * i,
328
- a + (g.yMm + h) * i,
329
- v * i,
330
- Math.max(0, g.heightMm - 2 * h) * i,
331
- w.fontFamily ?? c,
332
- w.verticalAlign ?? "middle"
333
- );
332
+ Rt(e, m, n, r, i, a, s);
333
+ for (const g of m.cells) kt(e, g, n, r, i, a, s, c, d, h);
334
+ }
335
+ function kt(e, t, n, r, i, o, l, a, s, c) {
336
+ const d = n.grid?.paddingMm ?? 0.5, h = t.cell.text ?? "", m = ke(n.style, t.cell.style), g = z(m, l), f = t.cell.indentMm ?? 0, T = Math.max(0, t.widthMm - 2 * d - f), R = Le(h, T, { fontSizePt: g.fontSizePt, bold: m.bold, italic: m.italic, fontFamily: m.fontFamily ?? a, letterSpacingPt: m.letterSpacing }, s).join(`
337
+ `), b = { x: r + (t.xMm + d + f) * o, y: i + (t.yMm + d) * o, width: T * o, height: Math.max(0, t.heightMm - 2 * d) * o };
338
+ e.save(), e.beginPath(), e.rect(b.x, b.y, b.width, b.height), e.clip(), t.cell.richParagraphs?.length ? We(e, { ...n, richParagraphs: t.cell.richParagraphs, style: { verticalAlign: "middle", ...m } }, b, l, a) : ge(
339
+ e,
340
+ {
341
+ text: R,
342
+ fontSizePx: g.fontSizePx,
343
+ bold: m.bold ?? !1,
344
+ italic: m.italic,
345
+ underline: m.underline,
346
+ color: ce(m, Pe),
347
+ align: m.align ?? "left",
348
+ lineHeight: _(m),
349
+ letterSpacingPx: W(m.letterSpacing ?? 0, l)
350
+ },
351
+ r + (t.xMm + d + f) * o,
352
+ i + (t.yMm + d) * o,
353
+ T * o,
354
+ Math.max(0, t.heightMm - 2 * d) * o,
355
+ m.fontFamily ?? a,
356
+ m.verticalAlign ?? "middle"
357
+ );
358
+ for (const y of t.cell.children ?? []) ie(e, { ...y, leftMm: y.leftMm + b.x / o, topMm: y.topMm + b.y / o }, o, l, a, s, c);
359
+ e.restore();
360
+ }
361
+ function $t(e, t, n, r, i, o, l, a, s) {
362
+ const c = t.style ?? {}, d = z(c, l);
363
+ if ($e(t)) {
364
+ We(e, t, { x: n, y: r, width: i, height: o }, l, a);
365
+ return;
334
366
  }
335
- }
336
- function Ct(e, t, n, r, a, o, l, i, s) {
337
- const c = t.style ?? {}, m = _(c, l), d = Ae(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
338
- `) : t.lines?.length ? t.lines.join(`
339
- `) : Ie(t.text ?? "", t.widthMm, { fontSizePt: m.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? i, letterSpacingPt: c.letterSpacing }, s).join(`
367
+ const h = t.lines?.length ? t.lines.join(`
368
+ `) : Le(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, s).join(`
340
369
  `);
341
- We(e, {
342
- text: d,
343
- fontSizePx: m.fontSizePx,
370
+ ge(e, {
371
+ text: h,
372
+ fontSizePx: d.fontSizePx,
344
373
  bold: c.bold ?? !1,
345
374
  italic: c.italic,
346
- color: Pe(c),
375
+ underline: c.underline,
376
+ color: ce(c),
347
377
  align: c.align ?? "left",
348
- lineHeight: ne(c),
378
+ lineHeight: _(c),
349
379
  letterSpacingPx: W(c.letterSpacing ?? 0, l)
350
- }, n, r, a, o, c.fontFamily ?? i, c.verticalAlign);
380
+ }, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
351
381
  }
352
- function ge(e, t, n, r, a, o, l) {
353
- const i = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, m = t.heightMm * n, d = t.style ?? {};
382
+ function ie(e, t, n, r, i, o, l) {
383
+ const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, h = t.style ?? {};
354
384
  if (re(t)) {
355
- const h = l?.get(t.imageData);
356
- h ? yt(e, h, i, s, c, m) : Me(e, t, i, s, c, m);
385
+ const m = l?.get(t.imageData);
386
+ m ? Tt(e, m, a, s, c, d) : xe(e, t, a, s, c, d);
357
387
  return;
358
388
  }
359
389
  if (t.grid) {
360
- Tt(e, t.grid, t, i, s, c, m, n, r, a, o);
390
+ At(e, t.grid, t, a, s, c, d, n, r, i, o, l);
361
391
  return;
362
392
  }
363
393
  switch (t.kind) {
364
394
  case "text": {
365
- Ct(e, t, i, s, c, m, r, a, o);
395
+ $t(e, t, a, s, c, d, r, i, o);
366
396
  break;
367
397
  }
368
398
  case "rect": {
369
- const h = G(d), g = Ce(d);
370
- d.backgroundColor && (e.fillStyle = d.backgroundColor, e.fillRect(i, s, c, m)), g.inner && (e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), St(e, g, i, s, c, m));
399
+ const m = q(h), g = Ae(h);
400
+ h.backgroundColor && (e.fillStyle = h.backgroundColor, e.fillRect(a, s, c, d)), g.inner && (e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), Pt(e, g, a, s, c, d));
371
401
  break;
372
402
  }
373
403
  case "line": {
374
- const h = G({ ...d, borderColor: d.lineColor ?? d.borderColor });
375
- e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), e.beginPath();
376
- const g = t.lineDirection === "up" ? s + m : t.lineDirection === "down" ? s : s + m / 2, f = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + m : s + m / 2;
377
- e.moveTo(i, g), e.lineTo(i + c, f), e.stroke();
404
+ const m = q({ ...h, borderColor: h.lineColor ?? h.borderColor });
405
+ e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), e.beginPath();
406
+ 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;
407
+ e.moveTo(a, g), e.lineTo(a + c, f), e.stroke();
378
408
  break;
379
409
  }
380
410
  case "ellipse": {
381
- const h = G(d);
382
- e.strokeStyle = h.color, e.lineWidth = W(h.widthPt, r), d.backgroundColor && (e.fillStyle = d.backgroundColor, e.beginPath(), e.ellipse(i + c / 2, s + m / 2, c / 2, m / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(i + c / 2, s + m / 2, c / 2, m / 2, 0, 0, Math.PI * 2), e.stroke();
411
+ const m = q(h);
412
+ e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), h.backgroundColor && (e.fillStyle = h.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();
383
413
  break;
384
414
  }
385
415
  default:
386
- Me(e, t, i, s, c, m);
416
+ xe(e, t, a, s, c, d);
387
417
  break;
388
418
  }
389
419
  }
390
- function Me(e, t, n, r, a, o) {
391
- e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, a, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
420
+ function xe(e, t, n, r, i, o) {
421
+ 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();
392
422
  }
393
- async function An(e, t = {}) {
423
+ async function Nn(e, t = {}) {
394
424
  if (typeof document > "u")
395
425
  throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
396
- const { format: n = "png", quality: r = 0.92, ...a } = t;
426
+ const { format: n = "png", quality: r = 0.92, ...i } = t;
397
427
  if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
398
428
  if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
399
- $(t.signal);
400
- const o = await me(e, { ...t, format: "canvas" });
429
+ k(t.signal);
430
+ const o = await he(e, { ...t, format: "canvas" });
401
431
  e = o.plan;
402
- const l = [...o.diagnostics, ...q(e, "canvas", t)], i = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
403
- for (let m = Math.max(0, t.start ?? 0); m <= c; m++) {
404
- $(t.signal);
405
- const d = await Be(e.pages[m], m, a, l);
432
+ const l = [...o.diagnostics, ...Y(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
433
+ for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
434
+ k(t.signal);
435
+ const h = await Ue(e.pages[d], d, i, l);
406
436
  try {
407
- s.push(await Rt(d, i, r, t.signal));
437
+ s.push(await It(h, a, r, t.signal));
408
438
  } finally {
409
- d.width = 0, d.height = 0;
439
+ h.width = 0, h.height = 0;
410
440
  }
411
- await tt(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
441
+ await st(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
412
442
  }
413
- return $(t.signal), { blobs: s, diagnostics: l };
443
+ return k(t.signal), { blobs: s, diagnostics: l };
414
444
  }
415
- function Rt(e, t, n, r) {
416
- return $(r), new Promise((a, o) => {
445
+ function It(e, t, n, r) {
446
+ return k(r), new Promise((i, o) => {
417
447
  const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
418
448
  r?.addEventListener("abort", l, { once: !0 });
419
449
  try {
420
- e.toBlob((i) => {
421
- r?.removeEventListener("abort", l), i ? a(i) : o(new Error("Canvas encoding failed; no empty image was emitted."));
450
+ e.toBlob((a) => {
451
+ r?.removeEventListener("abort", l), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
422
452
  }, t, n);
423
- } catch (i) {
424
- r?.removeEventListener("abort", l), o(i);
453
+ } catch (a) {
454
+ r?.removeEventListener("abort", l), o(a);
425
455
  }
426
456
  });
427
457
  }
428
- function $n(e, t = {}) {
429
- if ($(t.signal), typeof document > "u")
458
+ function Ln(e, t = {}) {
459
+ if (k(t.signal), typeof document > "u")
430
460
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
431
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, a = r / 96 * de, o = t.fontFamily ?? te, l = t.measurer ?? le, i = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], m = q(e, "canvas", t), d = Pt(e, i, s);
432
- for (const h of d)
433
- De(h, t), m.push(h);
434
- if (t.fidelity === "strict" && d.length) throw new et(m);
435
- for (let h = i; h <= s; h++) {
436
- $(t.signal);
437
- const g = e.pages[h], { canvas: f, ctx: w } = ze(g, n, r, t.maxCanvasPixels);
438
- for (const C of g.components)
439
- ge(w, C, a, r, o, l);
461
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ue, o = t.fontFamily ?? ne, l = t.measurer ?? de, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = Y(e, "canvas", t), h = Nt(e, a, s);
462
+ for (const m of h)
463
+ Oe(m, t), d.push(m);
464
+ if (t.fidelity === "strict" && h.length) throw new ot(d);
465
+ for (let m = a; m <= s; m++) {
466
+ k(t.signal);
467
+ const g = e.pages[m], { canvas: f, ctx: T } = je(g, n, r, t.maxCanvasPixels);
468
+ for (const R of g.components)
469
+ ie(T, R, i, r, o, l);
440
470
  c.push(f);
441
471
  }
442
- return { canvases: c, diagnostics: m };
472
+ return { canvases: c, diagnostics: d };
443
473
  }
444
- function Pt(e, t, n) {
445
- return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, a) => r.components.flatMap((o, l) => re(o) ? [{
474
+ function Nt(e, t, n) {
475
+ return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => [...fe(r)].map(({ component: o, componentIndex: l, componentPath: a }) => ({
446
476
  code: "async-image-required",
447
477
  severity: "warning",
448
478
  format: "canvas",
449
- pageIndex: t + a,
479
+ pageIndex: t + i,
450
480
  componentIndex: l,
481
+ componentPath: a,
451
482
  kind: o.kind,
452
483
  nid: o.nid,
453
484
  message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
454
- }] : []));
485
+ })));
455
486
  }
456
- async function kn(e, t = {}) {
487
+ async function Dn(e, t = {}) {
457
488
  if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
458
- $(t.signal);
459
- const n = await me(e, { ...t, format: "canvas" });
489
+ k(t.signal);
490
+ const n = await he(e, { ...t, format: "canvas" });
460
491
  e = n.plan;
461
- const r = [...n.diagnostics, ...q(e, "canvas", t)], a = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
492
+ const r = [...n.diagnostics, ...Y(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
462
493
  for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
463
- a.push(await Be(e.pages[l], l, t, r));
464
- return { canvases: a, diagnostics: r };
465
- }
466
- async function Be(e, t, n, r) {
467
- const a = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? te, i = await je(e, t, n, r);
468
- $(n.signal);
469
- const { canvas: s, ctx: c } = ze(e, a, o, n.maxCanvasPixels);
470
- for (const m of e.components) ge(c, m, o / 25.4, o, l, n.measurer ?? le, i);
494
+ i.push(await Ue(e.pages[l], l, t, r));
495
+ return { canvases: i, diagnostics: r };
496
+ }
497
+ async function Ue(e, t, n, r) {
498
+ const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? ne, a = await Ge(e, t, n, r);
499
+ k(n.signal);
500
+ const { canvas: s, ctx: c } = je(e, i, o, n.maxCanvasPixels);
501
+ for (const d of e.components) ie(c, d, o / 25.4, o, l, n.measurer ?? de, a);
471
502
  return s;
472
503
  }
473
- async function je(e, t, n, r) {
474
- const a = n.imageLoader ?? wt;
475
- return Mt(e, async (o, l) => {
504
+ async function Ge(e, t, n, r) {
505
+ const i = n.imageLoader ?? xt;
506
+ return Et(e, async (o, l) => {
476
507
  try {
477
- return await a(o, l);
478
- } catch (i) {
479
- if (l?.aborted) throw i;
480
- const s = e.components.findIndex((d) => d.imageData === o), c = e.components[s], m = { 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." };
481
- throw r.push(m), De(m, n), i;
508
+ return await i(o, l);
509
+ } catch (a) {
510
+ if (l?.aborted) throw a;
511
+ const s = [...fe(e)].find(({ component: g }) => g.imageData === o), { component: c, componentIndex: d, componentPath: h } = s, m = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: d, componentPath: h, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
512
+ throw r.push(m), Oe(m, n), a;
482
513
  }
483
514
  }, n.signal);
484
515
  }
485
- function In(e, t = {}) {
486
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, a = r / 96 * de, o = t.fontFamily ?? te, l = t.measurer ?? le, i = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, m = e.pages.map((u) => u.pageHeightMm * a), d = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * a)), h = { start: 0, end: -1 };
487
- let g = null, f = null, w = null, C = null, x = [], v = 0, R = [], H = 0, N = new AbortController();
488
- const ue = [];
489
- function Ve() {
516
+ function Fn(e, t = {}) {
517
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ue, o = t.fontFamily ?? ne, l = t.measurer ?? de, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((u) => u.pageHeightMm * i), h = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * i)), m = { start: 0, end: -1 };
518
+ let g = null, f = null, T = null, R = null, b = [], y = 0, P = [], H = 0, N = new AbortController();
519
+ const be = [];
520
+ function Ke() {
490
521
  const u = g;
491
- u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${d}px;margin:0 auto;`, w = document.createElement("div"), C = document.createElement("div"), f.appendChild(w), x = [];
492
- const E = Math.min(e.pages.length, 3 + i * 2);
493
- for (let F = 0; F < E; F++) {
522
+ u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${h}px;margin:0 auto;`, T = document.createElement("div"), R = document.createElement("div"), f.appendChild(T), b = [];
523
+ const x = Math.min(e.pages.length, 3 + a * 2);
524
+ for (let F = 0; F < x; F++) {
494
525
  const M = document.createElement("div");
495
- M.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(M), x.push(M);
526
+ M.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(M), b.push(M);
496
527
  }
497
- f.appendChild(C), u.appendChild(f);
528
+ f.appendChild(R), u.appendChild(f);
498
529
  }
499
- async function qe(u, E) {
500
- const F = H, M = await me(e, { ...t, signal: N.signal, format: "canvas", start: E, end: E });
501
- ue.push(...M.diagnostics);
502
- const P = M.plan.pages[E], J = await je(P, E, { ...t, signal: N.signal }, ue);
530
+ async function Je(u, x) {
531
+ const F = H, M = await he(e, { ...t, signal: N.signal, format: "canvas", start: x, end: x });
532
+ be.push(...M.diagnostics);
533
+ const C = M.plan.pages[x], X = await Ge(C, x, { ...t, signal: N.signal }, be);
503
534
  if (F !== H || !g) return;
504
- const { widthPx: ie, heightPx: oe } = he(P, r);
535
+ const { widthPx: oe, heightPx: se } = pe(C, r);
505
536
  let L = u.firstElementChild;
506
537
  (!L || L.tagName !== "CANVAS") && (L = document.createElement("canvas"), u.innerHTML = "", u.appendChild(L));
507
- const we = He(P, n, r, t.maxCanvasPixels);
508
- L.width = we.width, L.height = we.height, L.style.width = `${ie}px`, L.style.height = `${oe}px`;
509
- const z = L.getContext("2d");
510
- if (z) {
511
- z.setTransform(1, 0, 0, 1, 0, 0), z.scale(n, n), z.fillStyle = "#ffffff", z.fillRect(0, 0, ie, oe);
512
- for (const Ke of P.components)
513
- ge(z, Ke, a, r, o, l, J);
514
- L.dataset.canvasPage = String(E), u.style.height = `${oe}px`, u.style.width = `${ie}px`;
538
+ const ve = _e(C, n, r, t.maxCanvasPixels);
539
+ L.width = ve.width, L.height = ve.height, L.style.width = `${oe}px`, L.style.height = `${se}px`;
540
+ const B = L.getContext("2d");
541
+ if (B) {
542
+ B.setTransform(1, 0, 0, 1, 0, 0), B.scale(n, n), B.fillStyle = "#ffffff", B.fillRect(0, 0, oe, se);
543
+ for (const Ze of C.components)
544
+ ie(B, Ze, i, r, o, l, X);
545
+ L.dataset.canvasPage = String(x), u.style.height = `${se}px`, u.style.width = `${oe}px`;
515
546
  }
516
547
  }
517
- function Ye(u) {
518
- H++, h.start = u.start, h.end = u.end, w.style.height = `${u.start * s + m.slice(0, u.start).reduce((M, P) => M + P, 0)}px`;
519
- const E = e.pages.length - 1 - u.end;
520
- C.style.height = `${E * s + m.slice(u.end + 1).reduce((M, P) => M + P, 0)}px`;
548
+ function Xe(u) {
549
+ H++, m.start = u.start, m.end = u.end, T.style.height = `${u.start * s + d.slice(0, u.start).reduce((M, C) => M + C, 0)}px`;
550
+ const x = e.pages.length - 1 - u.end;
551
+ R.style.height = `${x * s + d.slice(u.end + 1).reduce((M, C) => M + C, 0)}px`;
521
552
  const F = u.end - u.start + 1;
522
- x.forEach((M, P) => {
523
- if (P < F) {
553
+ b.forEach((M, C) => {
554
+ if (C < F) {
524
555
  M.style.display = "";
525
- const J = u.start + P;
526
- M.style.height = `${m[J] ?? 0}px`;
556
+ const X = u.start + C;
557
+ M.style.height = `${d[X] ?? 0}px`;
527
558
  } else
528
559
  M.style.display = "none";
529
- }), R = [];
560
+ }), P = [];
530
561
  for (let M = u.start; M <= u.end; M++) {
531
- const P = x[M - u.start];
532
- if (!P) continue;
533
- P.firstElementChild?.dataset?.canvasPage !== String(M) && R.push(M);
562
+ const C = b[M - u.start];
563
+ if (!C) continue;
564
+ C.firstElementChild?.dataset?.canvasPage !== String(M) && P.push(M);
534
565
  }
535
566
  ae();
536
567
  }
537
568
  function ae() {
538
- v || R.length === 0 || (v = requestAnimationFrame(() => {
539
- v = 0;
569
+ y || P.length === 0 || (y = requestAnimationFrame(() => {
570
+ y = 0;
540
571
  let u = Math.max(1, c);
541
- for (; R.length > 0 && u-- > 0; ) {
542
- const E = R.shift(), F = x[E - h.start];
543
- F && qe(F, E).catch(() => {
572
+ for (; P.length > 0 && u-- > 0; ) {
573
+ const x = P.shift(), F = b[x - m.start];
574
+ F && Je(F, x).catch(() => {
544
575
  });
545
576
  }
546
- R.length > 0 && ae();
577
+ P.length > 0 && ae();
547
578
  }));
548
579
  }
549
- function Y() {
550
- v || (v = requestAnimationFrame(() => {
551
- v = 0;
552
- const u = g, E = vt({
553
- pageHeightsPx: m,
580
+ function K() {
581
+ y || (y = requestAnimationFrame(() => {
582
+ y = 0;
583
+ const u = g, x = Ct({
584
+ pageHeightsPx: d,
554
585
  viewportHeightPx: u.clientHeight,
555
586
  scrollTopPx: u.scrollTop,
556
- overscan: i,
587
+ overscan: a,
557
588
  gapPx: s
558
589
  });
559
- E.start !== h.start || E.end !== h.end ? Ye(E) : ae();
590
+ x.start !== m.start || x.end !== m.end ? Xe(x) : ae();
560
591
  }));
561
592
  }
562
- let K = null;
593
+ let J = null;
563
594
  return {
564
595
  attach(u) {
565
596
  if (typeof document > "u")
566
597
  throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
567
- $(t.signal), N = new AbortController(), t.signal?.addEventListener("abort", pe, { once: !0 }), q(e, "canvas", t), g = u, Ve(), u.addEventListener("scroll", Y, { passive: !0 }), typeof ResizeObserver < "u" && (K = new ResizeObserver(() => Y()), K.observe(u)), Y();
598
+ k(t.signal), N = new AbortController(), t.signal?.addEventListener("abort", Me, { once: !0 }), Y(e, "canvas", t), g = u, Ke(), u.addEventListener("scroll", K, { passive: !0 }), typeof ResizeObserver < "u" && (J = new ResizeObserver(() => K()), J.observe(u)), K();
568
599
  },
569
600
  destroy() {
570
- H++, N.abort(), t.signal?.removeEventListener("abort", pe), v && cancelAnimationFrame(v), v = 0, K?.disconnect(), K = null, g?.removeEventListener("scroll", Y), R = [], f?.remove(), g = null;
601
+ H++, N.abort(), t.signal?.removeEventListener("abort", Me), y && cancelAnimationFrame(y), y = 0, J?.disconnect(), J = null, g?.removeEventListener("scroll", K), P = [], f?.remove(), g = null;
571
602
  },
572
603
  window() {
573
- return { ...h };
604
+ return { ...m };
574
605
  }
575
606
  };
576
- function pe() {
607
+ function Me() {
577
608
  N.abort(t.signal?.reason);
578
609
  }
579
610
  }
580
- function _e(e, t, n) {
581
- let r, a;
611
+ function qe(e, t, n) {
612
+ let r, i;
582
613
  if (typeof e == "string") {
583
- const o = Z[e];
584
- if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Z).join("/")})`);
585
- r = o.widthMm, a = o.heightMm;
586
- } else typeof e == "number" ? (r = e, a = t ?? 297) : (r = e.widthMm, a = e.heightMm);
587
- return n ? { widthMm: a, heightMm: r } : { widthMm: r, heightMm: a };
614
+ const o = Q[e];
615
+ if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Q).join("/")})`);
616
+ r = o.widthMm, i = o.heightMm;
617
+ } else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
618
+ return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
588
619
  }
589
- class At {
620
+ class Lt {
590
621
  constructor() {
591
622
  this.pages = [], this.pending = null, this.templateParams = void 0;
592
623
  }
@@ -619,14 +650,14 @@ class At {
619
650
  */
620
651
  page(t = "a4", n = {}, r) {
621
652
  this.collect();
622
- 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: i } = _e(
653
+ 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 } = qe(
623
654
  t,
624
655
  typeof n == "number" ? n : void 0,
625
656
  o.landscape
626
657
  ), s = o.margins ?? {};
627
- return this.pending = new $t(this, {
658
+ return this.pending = new Dt(this, {
628
659
  widthMm: l,
629
- heightMm: i,
660
+ heightMm: a,
630
661
  marginTopMm: s.marginTopMm ?? 10,
631
662
  marginBottomMm: s.marginBottomMm ?? 10,
632
663
  marginLeftMm: s.marginLeftMm ?? 10,
@@ -646,7 +677,7 @@ class At {
646
677
  };
647
678
  }
648
679
  }
649
- class $t {
680
+ class Dt {
650
681
  constructor(t, n) {
651
682
  this.parent = t, this.page = n, this.components = [];
652
683
  }
@@ -661,7 +692,7 @@ class $t {
661
692
  style: r
662
693
  }), this;
663
694
  }
664
- list(t, n, r, a = {}) {
695
+ list(t, n, r, i = {}) {
665
696
  return this.components.push({
666
697
  kind: "list",
667
698
  leftMm: n.leftMm ?? 10,
@@ -669,20 +700,20 @@ class $t {
669
700
  widthMm: n.widthMm ?? 180,
670
701
  dataset: t,
671
702
  columns: r,
672
- ...a
703
+ ...i
673
704
  }), this;
674
705
  }
675
706
  rect(t, n = {}) {
676
707
  return this.components.push({ kind: "rect", ...t, style: n }), this;
677
708
  }
678
- line(t, n, r, a = {}) {
709
+ line(t, n, r, i = {}) {
679
710
  return this.components.push({
680
711
  kind: "line",
681
712
  leftMm: t,
682
713
  topMm: n,
683
714
  widthMm: r,
684
715
  heightMm: 0.5,
685
- style: a
716
+ style: i
686
717
  }), this;
687
718
  }
688
719
  barcode(t, n) {
@@ -695,11 +726,11 @@ class $t {
695
726
  fallbackText: t
696
727
  }), this;
697
728
  }
698
- qrcode(t, n, r, a) {
729
+ qrcode(t, n, r, i) {
699
730
  return this.components.push({
700
731
  kind: "qrcode",
701
732
  leftMm: r,
702
- topMm: a,
733
+ topMm: i,
703
734
  widthMm: n,
704
735
  heightMm: n,
705
736
  fallbackText: t
@@ -715,26 +746,26 @@ class $t {
715
746
  return this.done().build();
716
747
  }
717
748
  }
718
- function Nn() {
719
- return new At();
749
+ function On() {
750
+ return new Lt();
720
751
  }
721
- function Ln(e, t = {}) {
722
- return Xe([], e), e.fields.map((n) => ({
752
+ function zn(e, t = {}) {
753
+ return et([], e), e.fields.map((n) => ({
723
754
  field: n.field,
724
755
  header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
725
756
  semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
726
757
  ...t[n.field]
727
758
  }));
728
759
  }
729
- function k(e, t, n = !1) {
760
+ function $(e, t, n = !1) {
730
761
  if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
731
762
  throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
732
763
  }
733
- function Q(e, t, n) {
764
+ function ee(e, t, n) {
734
765
  if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
735
766
  throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
736
767
  }
737
- function kt(e) {
768
+ function Ft(e) {
738
769
  const t = e.layout ?? "page";
739
770
  if (t !== "page" && t !== "wide")
740
771
  throw new Error("layout 必须是 page 或 wide");
@@ -743,18 +774,18 @@ function kt(e) {
743
774
  if (t !== "wide" && e.columnWidthMm !== void 0)
744
775
  throw new Error('columnWidthMm 仅适用于 layout: "wide"');
745
776
  const n = e.columnWidthMm ?? 30;
746
- return k(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
777
+ return $(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
747
778
  }
748
- function It(e) {
779
+ function Ot(e) {
749
780
  const t = e.paper === void 0 ? "a4" : e.paper;
750
781
  if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
751
782
  throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
752
- if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Z, t))
753
- throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Z).join("/")})`);
754
- const n = _e(t, void 0, e.landscape), r = n.widthMm, a = n.heightMm;
755
- return k(r, "纸张 widthMm"), k(a, "纸张 heightMm"), { widthMm: r, heightMm: a };
783
+ if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Q, t))
784
+ throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Q).join("/")})`);
785
+ const n = qe(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
786
+ return $(r, "纸张 widthMm"), $(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
756
787
  }
757
- function Nt(e) {
788
+ function zt(e) {
758
789
  if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
759
790
  throw new Error("margins 必须是页边距对象");
760
791
  const t = e.margins ?? {}, n = {
@@ -763,97 +794,97 @@ function Nt(e) {
763
794
  marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
764
795
  marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
765
796
  };
766
- for (const [r, a] of Object.entries(n)) k(a, r, !0);
797
+ for (const [r, i] of Object.entries(n)) $(i, r, !0);
767
798
  return n;
768
799
  }
769
- function Lt(e, t) {
800
+ function Ht(e, t) {
770
801
  const n = e.dataset === void 0 ? "detail" : e.dataset;
771
802
  if (typeof n != "string" || !n.trim())
772
803
  throw new Error("dataset 必须是非空字符串");
773
804
  if (e.title !== void 0 && typeof e.title != "string")
774
805
  throw new Error("title 必须是字符串");
775
- const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, a = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
776
- k(r, "titleHeightMm"), k(a, "titleGapMm", !0);
777
- const o = e.title !== void 0 && e.title.length > 0, l = o ? r + a : 0;
806
+ const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
807
+ $(r, "titleHeightMm"), $(i, "titleGapMm", !0);
808
+ const o = e.title !== void 0 && e.title.length > 0, l = o ? r + i : 0;
778
809
  if (l >= t)
779
810
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
780
811
  return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
781
812
  }
782
- function Dt(e) {
813
+ function Bt(e) {
783
814
  if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
784
815
  throw new Error("listOptions 必须是列表配置对象");
785
816
  const t = e.listOptions ?? {};
786
- Q(t.align, "listOptions.align", !0), Q(t.headerAlign, "listOptions.headerAlign", !1);
817
+ ee(t.align, "listOptions.align", !0), ee(t.headerAlign, "listOptions.headerAlign", !1);
787
818
  for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
788
819
  const r = t[n];
789
- r !== void 0 && k(r, `listOptions.${n}`, n === "paddingMm");
820
+ r !== void 0 && $(r, `listOptions.${n}`, n === "paddingMm");
790
821
  }
791
822
  return t;
792
823
  }
793
- function Ft(e) {
824
+ function Wt(e) {
794
825
  let t = 0, n = 0;
795
- for (const [r, a] of e.entries()) {
796
- if (!a || typeof a.header != "string" || typeof a.field != "string" || !a.field.trim())
826
+ for (const [r, i] of e.entries()) {
827
+ if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
797
828
  throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
798
- Q(a.align, `columns[${r}].align`, !0), Q(a.headerAlign, `columns[${r}].headerAlign`, !1), a.flex !== void 0 && k(a.flex, `columns[${r}].flex`), a.widthMm !== void 0 ? (k(a.widthMm, `columns[${r}].widthMm`), t += a.widthMm) : n = Math.max(n, a.flex ?? 1);
829
+ ee(i.align, `columns[${r}].align`, !0), ee(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && $(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? ($(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
799
830
  }
800
831
  return { fixedWidthMm: t, maxFlex: n };
801
832
  }
802
- function Ot(e, t, n, r) {
803
- const { fixedWidthMm: a, maxFlex: o } = Ft(e.columns);
804
- if (t === "page" && a > r)
805
- throw new Error(`固定列宽 ${a}mm 超出页面可用宽度 ${r}mm`);
806
- const l = r - a;
833
+ function _t(e, t, n, r) {
834
+ const { fixedWidthMm: i, maxFlex: o } = Wt(e.columns);
835
+ if (t === "page" && i > r)
836
+ throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
837
+ const l = r - i;
807
838
  if (t === "page" && o > 0 && l <= 0)
808
839
  throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
809
- const i = o > 0 ? e.columns.reduce((c, m) => c + (m.widthMm === void 0 ? (m.flex ?? 1) / o : 0), 0) : 0;
810
- return { columns: e.columns.map(({ widthMm: c, flex: m, ...d }, h) => {
811
- const g = c ?? (t === "wide" ? n * (m ?? 1) : l * ((m ?? 1) / o) / i);
812
- return k(g, `columns[${h}] 分配后的 widthMm`), { ...d, widthMm: g };
813
- }), fixedWidthMm: a, maxFlex: o };
840
+ const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
841
+ return { columns: e.columns.map(({ widthMm: c, flex: d, ...h }, m) => {
842
+ const g = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / o) / a);
843
+ return $(g, `columns[${m}] 分配后的 widthMm`), { ...h, widthMm: g };
844
+ }), fixedWidthMm: i, maxFlex: o };
814
845
  }
815
- function Dn(e) {
846
+ function Hn(e) {
816
847
  if (!e || typeof e != "object")
817
848
  throw new Error("标准明细模板需要 options 对象");
818
849
  if (!Array.isArray(e.columns) || e.columns.length === 0)
819
850
  throw new Error("columns 至少需要一列");
820
- const { layout: t, columnWidthMm: n } = kt(e), r = It(e);
821
- let a = r.widthMm;
822
- const o = r.heightMm, l = Nt(e);
823
- let i = a - l.marginLeftMm - l.marginRightMm;
851
+ const { layout: t, columnWidthMm: n } = Ft(e), r = Ot(e);
852
+ let i = r.widthMm;
853
+ const o = r.heightMm, l = zt(e);
854
+ let a = i - l.marginLeftMm - l.marginRightMm;
824
855
  const s = o - l.marginTopMm - l.marginBottomMm;
825
- if (t === "page" && i <= 0 || s <= 0)
856
+ if (t === "page" && a <= 0 || s <= 0)
826
857
  throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
827
- const { dataset: c, titleHeightMm: m, hasTitle: d, titleSpaceMm: h } = Lt(e, s), g = Dt(e), { columns: f, fixedWidthMm: w, maxFlex: C } = Ot(e, t, n, i);
828
- t === "wide" && (i = f.reduce((v, R) => v + R.widthMm, 0), k(i, "宽表总列宽"), a = i + l.marginLeftMm + l.marginRightMm, k(a, "宽表总宽度"));
829
- const x = { widthMm: a, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
830
- return d && x.components.push({
858
+ const { dataset: c, titleHeightMm: d, hasTitle: h, titleSpaceMm: m } = Ht(e, s), g = Bt(e), { columns: f, fixedWidthMm: T, maxFlex: R } = _t(e, t, n, a);
859
+ t === "wide" && (a = f.reduce((y, P) => y + P.widthMm, 0), $(a, "宽表总列宽"), i = a + l.marginLeftMm + l.marginRightMm, $(i, "宽表总宽度"));
860
+ const b = { widthMm: i, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
861
+ return h && b.components.push({
831
862
  kind: "text",
832
863
  text: e.title,
833
864
  leftMm: l.marginLeftMm,
834
865
  topMm: l.marginTopMm,
835
- widthMm: i,
836
- heightMm: m,
866
+ widthMm: a,
867
+ heightMm: d,
837
868
  style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
838
- }), x.components.push({
869
+ }), b.components.push({
839
870
  align: "auto",
840
871
  headerAlign: "center",
841
872
  ...g,
842
873
  kind: "list",
843
874
  ...t === "wide" ? { layout: t } : {},
844
- ...d ? { title: e.title } : {},
875
+ ...h ? { title: e.title } : {},
845
876
  dataset: c,
846
877
  columns: f,
847
878
  leftMm: l.marginLeftMm,
848
- topMm: l.marginTopMm + h,
849
- widthMm: t === "wide" || C > 0 ? i : w
850
- }), e.params === void 0 ? { pages: [x] } : { params: e.params, pages: [x] };
879
+ topMm: l.marginTopMm + m,
880
+ widthMm: t === "wide" || R > 0 ? a : T
881
+ }), e.params === void 0 ? { pages: [b] } : { params: e.params, pages: [b] };
851
882
  }
852
- function Fn(e) {
883
+ function Bn(e) {
853
884
  if (e.components !== void 0 && e.pages !== void 0) throw new TypeError("标签 components 与 pages 只能选择一种");
854
- const { dataset: t, rowKey: n, copies: r, params: a } = e, o = e.pages ?? [{ components: e.components ?? [] }], l = {
885
+ const { dataset: t, rowKey: n, copies: r, params: i } = e, o = e.pages ?? [{ components: e.components ?? [] }], l = {
855
886
  repeat: { dataset: t, ...n === void 0 ? {} : { rowKey: n }, ...r === void 0 ? {} : { copies: r } },
856
- ...a === void 0 ? {} : { params: a },
887
+ ...i === void 0 ? {} : { params: i },
857
888
  pages: o.map((s) => ({
858
889
  widthMm: s.widthMm ?? e.widthMm ?? 80,
859
890
  heightMm: s.heightMm ?? e.heightMm ?? 55,
@@ -864,29 +895,29 @@ function Fn(e) {
864
895
  components: s.components,
865
896
  ...s.meta === void 0 ? {} : { meta: s.meta }
866
897
  }))
867
- }, i = $e(l);
868
- if (!i.ok) throw new ke(i.errors);
898
+ }, a = Ie(l);
899
+ if (!a.ok) throw new Ne(a.errors);
869
900
  return JSON.parse(JSON.stringify(l));
870
901
  }
871
- function Ht(e) {
902
+ function jt(e) {
872
903
  if (!e || typeof e != "object" || !e.repeat)
873
- throw new ce("config", "defineLabelReport 需要带 repeat 的固定标签模板");
874
- const t = $e(e);
875
- if (!t.ok) throw new ke(t.errors);
904
+ throw new me("config", "defineLabelReport 需要带 repeat 的固定标签模板");
905
+ const t = Ie(e);
906
+ if (!t.ok) throw new Ne(t.errors);
876
907
  return e.repeat.dataset;
877
908
  }
878
- function ye(e, t) {
879
- if (!Array.isArray(e)) throw new ce("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
909
+ function Se(e, t) {
910
+ if (!Array.isArray(e)) throw new me("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
880
911
  return { [t]: e };
881
912
  }
882
- function On(e) {
883
- const { template: t, rows: n, load: r, dataSchema: a, params: o, pagination: l, dataValidation: i } = e, s = Ht(t);
913
+ function Wn(e) {
914
+ const { template: t, rows: n, load: r, dataSchema: i, params: o, pagination: l, dataValidation: a } = e, s = jt(t);
884
915
  if (n !== void 0 == (r !== void 0) || r !== void 0 && typeof r != "function")
885
- throw new ce("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
886
- const c = { template: t, params: o, pagination: l, dataValidation: i, ...a === void 0 ? {} : { dataSchema: { [s]: a } } };
887
- return r ? Ze({ ...c, load: r, mapData: (m) => ye(m, s) }) : { ...c, datasets: ye(n, s) };
916
+ throw new me("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
917
+ const c = { template: t, params: o, pagination: l, dataValidation: a, ...i === void 0 ? {} : { dataSchema: { [s]: i } } };
918
+ return r ? tt({ ...c, load: r, mapData: (d) => Se(d, s) }) : { ...c, datasets: Se(n, s) };
888
919
  }
889
- function Hn(e) {
920
+ function _n(e) {
890
921
  return e;
891
922
  }
892
923
  class D extends Error {
@@ -902,123 +933,123 @@ function S(e) {
902
933
  const t = new Error("模板操作已取消");
903
934
  throw t.name = "AbortError", t;
904
935
  }
905
- function ve(e) {
936
+ function Ee(e) {
906
937
  const t = e ? Number(e.revision) : 0;
907
938
  if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new D("history", "修订号无效或已达上限");
908
939
  return String(t + 1);
909
940
  }
910
- function zn(e, t = {}) {
911
- const n = async (l, i) => {
912
- S(i);
913
- const s = await e.read(l, i);
914
- return S(i), s ? I(s) : void 0;
915
- }, r = async (l, i) => {
916
- const s = await n(l, i.signal);
917
- if ((s?.revision ?? null) !== i.expectedRevision) throw new D("conflict", "模板已变化,请重新读取后提交");
941
+ function jn(e, t = {}) {
942
+ const n = async (l, a) => {
943
+ S(a);
944
+ const s = await e.read(l, a);
945
+ return S(a), s ? I(s) : void 0;
946
+ }, r = async (l, a) => {
947
+ const s = await n(l, a.signal);
948
+ if ((s?.revision ?? null) !== a.expectedRevision) throw new D("conflict", "模板已变化,请重新读取后提交");
918
949
  return s;
919
- }, a = async (l, i, s) => {
920
- if (S(i.signal), !await e.compareAndSwap(l.id, i.expectedRevision, I(l), { signal: i.signal, ...s ? { publication: I(s) } : {} })) throw new D("conflict", "模板已被其他请求更新");
950
+ }, i = async (l, a, s) => {
951
+ if (S(a.signal), !await e.compareAndSwap(l.id, a.expectedRevision, I(l), { signal: a.signal, ...s ? { publication: I(s) } : {} })) throw new D("conflict", "模板已被其他请求更新");
921
952
  return I(l);
922
- }, o = async (l, i, s, c) => {
953
+ }, o = async (l, a, s, c) => {
923
954
  if (t.beforePublish) {
924
955
  S(s.signal);
925
- const g = await t.beforePublish({ document: U(i), previous: l.published ? U(l.published) : void 0, signal: s.signal });
956
+ const g = await t.beforePublish({ document: G(a), previous: l.published ? G(l.published) : void 0, signal: s.signal });
926
957
  if (!g || g.ok !== !0) throw new D("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
927
958
  S(s.signal);
928
959
  }
929
- const m = ve(l), d = U({ ...i, revision: m }), h = { revision: m, document: d, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
930
- return c !== void 0 && (h.restoredFrom = c), a({ id: l.id, revision: m, publishedRevision: m, published: d }, s, h);
960
+ const d = Ee(l), h = G({ ...a, revision: d }), m = { revision: d, document: h, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
961
+ return c !== void 0 && (m.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: h }, s, m);
931
962
  };
932
963
  return {
933
964
  list: async (l) => {
934
965
  S(l);
935
- const i = await e.list(l);
936
- return S(l), I(i);
966
+ const a = await e.list(l);
967
+ return S(l), I(a);
937
968
  },
938
- get: async (l, i = {}) => {
939
- const s = await n(l, i.signal), c = i.draft ? s?.draft : s?.published;
940
- return c ? U(c) : void 0;
969
+ get: async (l, a = {}) => {
970
+ const s = await n(l, a.signal), c = a.draft ? s?.draft : s?.published;
971
+ return c ? G(c) : void 0;
941
972
  },
942
- history: async (l, i) => {
943
- S(i);
944
- const s = await e.history(l, i);
945
- return S(i), I(s);
973
+ history: async (l, a) => {
974
+ S(a);
975
+ const s = await e.history(l, a);
976
+ return S(a), I(s);
946
977
  },
947
- saveDraft: async (l, i) => {
948
- i = { ...i }, S(i.signal);
949
- const s = U(t.migrate ? await t.migrate(l) : l), c = await r(s.id, i), m = ve(c);
950
- return a({
978
+ saveDraft: async (l, a) => {
979
+ a = { ...a }, S(a.signal);
980
+ const s = G(t.migrate ? await t.migrate(l) : l), c = await r(s.id, a), d = Ee(c);
981
+ return i({
951
982
  id: s.id,
952
- revision: m,
953
- draft: { ...s, revision: m },
983
+ revision: d,
984
+ draft: { ...s, revision: d },
954
985
  ...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
955
- }, i);
986
+ }, a);
956
987
  },
957
- publish: async (l, i) => {
958
- i = { ...i };
959
- const s = await r(l, i);
988
+ publish: async (l, a) => {
989
+ a = { ...a };
990
+ const s = await r(l, a);
960
991
  if (!s) throw new D("missing", "模板不存在");
961
992
  if (!s.draft) throw new D("draft", "没有可发布的草稿");
962
- return o(s, s.draft, i);
993
+ return o(s, s.draft, a);
963
994
  },
964
- rollback: async (l, i, s) => {
995
+ rollback: async (l, a, s) => {
965
996
  s = { ...s };
966
997
  const c = await r(l, s);
967
998
  if (!c) throw new D("missing", "模板不存在");
968
999
  S(s.signal);
969
- const m = await e.getVersion(l, i, s.signal);
970
- if (!m) throw new D("history", "历史修订不存在");
971
- return o(c, m.document, s, i);
1000
+ const d = await e.getVersion(l, a, s.signal);
1001
+ if (!d) throw new D("history", "历史修订不存在");
1002
+ return o(c, d.document, s, a);
972
1003
  }
973
1004
  };
974
1005
  }
975
- function Wn() {
1006
+ function Un() {
976
1007
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
977
1008
  return {
978
1009
  read: async (n, r) => {
979
1010
  S(r);
980
- const a = e.get(n);
981
- return a ? I(a) : void 0;
1011
+ const i = e.get(n);
1012
+ return i ? I(i) : void 0;
982
1013
  },
983
- list: async (n) => (S(n), Array.from(e.values(), ({ id: r, revision: a, publishedRevision: o }) => ({ id: r, revision: a, ...o ? { publishedRevision: o } : {} }))),
984
- history: async (n, r) => (S(r), Array.from(t.get(n)?.values() ?? [], (a) => I(a))),
985
- getVersion: async (n, r, a) => {
986
- S(a);
1014
+ list: async (n) => (S(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: o }) => ({ id: r, revision: i, ...o ? { publishedRevision: o } : {} }))),
1015
+ history: async (n, r) => (S(r), Array.from(t.get(n)?.values() ?? [], (i) => I(i))),
1016
+ getVersion: async (n, r, i) => {
1017
+ S(i);
987
1018
  const o = t.get(n)?.get(r);
988
1019
  return o ? I(o) : void 0;
989
1020
  },
990
- compareAndSwap: async (n, r, a, o) => {
1021
+ compareAndSwap: async (n, r, i, o) => {
991
1022
  if (S(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
992
- if (a.id !== n) throw new D("history", "状态 ID 与存储 ID 不一致");
993
- const l = I(a), i = o.publication;
994
- if (i) {
1023
+ if (i.id !== n) throw new D("history", "状态 ID 与存储 ID 不一致");
1024
+ const l = I(i), a = o.publication;
1025
+ if (a) {
995
1026
  const s = t.get(n) ?? /* @__PURE__ */ new Map();
996
- if (s.has(i.revision) || i.revision !== a.revision || i.document.id !== n) throw new D("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
997
- s.set(i.revision, I(i)), t.set(n, s);
1027
+ if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new D("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
1028
+ s.set(a.revision, I(a)), t.set(n, s);
998
1029
  }
999
1030
  return e.set(n, l), !0;
1000
1031
  }
1001
1032
  };
1002
1033
  }
1003
- function Bn(e) {
1034
+ function Gn(e) {
1004
1035
  return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
1005
1036
  `);
1006
1037
  }
1007
- function zt(e, t) {
1038
+ function Ut(e, t) {
1008
1039
  const n = e[e.length - 1];
1009
1040
  e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
1010
1041
  }
1011
- function jn(e, t = 1e4) {
1042
+ function qn(e, t = 1e4) {
1012
1043
  if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
1013
1044
  const n = [[]];
1014
- let r = "", a = !1, o = !1, l = 0;
1015
- function i() {
1045
+ let r = "", i = !1, o = !1, l = 0;
1046
+ function a() {
1016
1047
  if (++l > t) throw new Error("Clipboard cell limit exceeded");
1017
1048
  n[n.length - 1].push(r), r = "", o = !1;
1018
1049
  }
1019
1050
  for (let s = 0; s < e.length; s++) {
1020
1051
  const c = e[s];
1021
- if (a) {
1052
+ if (i) {
1022
1053
  if (c !== '"') {
1023
1054
  r += c;
1024
1055
  continue;
@@ -1027,288 +1058,288 @@ function jn(e, t = 1e4) {
1027
1058
  r += '"', s++;
1028
1059
  continue;
1029
1060
  }
1030
- a = !1, o = !0;
1061
+ i = !1, o = !0;
1031
1062
  continue;
1032
1063
  }
1033
1064
  if (c === '"' && !r && !o) {
1034
- a = !0;
1065
+ i = !0;
1035
1066
  continue;
1036
1067
  }
1037
1068
  if (c === " ") {
1038
- i();
1069
+ a();
1039
1070
  continue;
1040
1071
  }
1041
1072
  if (c === "\r" || c === `
1042
1073
  `) {
1043
- i(), n.push([]), c === "\r" && e[s + 1] === `
1074
+ a(), n.push([]), c === "\r" && e[s + 1] === `
1044
1075
  ` && s++;
1045
1076
  continue;
1046
1077
  }
1047
1078
  if (o) throw new Error("Invalid quoted clipboard value");
1048
1079
  r += c;
1049
1080
  }
1050
- if (a) throw new Error("Unclosed clipboard quote");
1051
- return i(), zt(n, e), n;
1081
+ if (i) throw new Error("Unclosed clipboard quote");
1082
+ return a(), Ut(n, e), n;
1052
1083
  }
1053
- class Wt extends Error {
1084
+ class Gt extends Error {
1054
1085
  constructor(t, n, r) {
1055
- const a = typeof n.label == "string" ? n.label : "单元格", o = {
1056
- definition: `${a}的编辑器配置无效`,
1057
- type: `${a}的编辑器与数据类型不一致`,
1058
- required: `${a}不能为空`,
1059
- min: `${a}不能小于 ${r}`,
1060
- max: `${a}不能大于 ${r}`,
1061
- precision: `${a}最多保留 ${r} 位小数`,
1062
- length: `${a}最多允许 ${r} 个字符`,
1063
- choice: `${a}请选择有效选项`,
1064
- date: `${a}请输入有效日期(YYYY-MM-DD)`
1086
+ const i = typeof n.label == "string" ? n.label : "单元格", o = {
1087
+ definition: `${i}的编辑器配置无效`,
1088
+ type: `${i}的编辑器与数据类型不一致`,
1089
+ required: `${i}不能为空`,
1090
+ min: `${i}不能小于 ${r}`,
1091
+ max: `${i}不能大于 ${r}`,
1092
+ precision: `${i}最多保留 ${r} 位小数`,
1093
+ length: `${i}最多允许 ${r} 个字符`,
1094
+ choice: `${i}请选择有效选项`,
1095
+ date: `${i}请输入有效日期(YYYY-MM-DD)`
1065
1096
  };
1066
1097
  super(o[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
1067
1098
  }
1068
1099
  }
1069
1100
  function p(e, t, n) {
1070
- throw new Wt(t, e, n);
1101
+ throw new Gt(t, e, n);
1071
1102
  }
1072
- function Ue(e) {
1103
+ function Ve(e) {
1073
1104
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
1074
1105
  const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
1075
1106
  return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
1076
1107
  }
1077
- function Bt(e) {
1108
+ function qt(e) {
1078
1109
  const [t = "", n = "0"] = String(e).toLowerCase().split("e");
1079
1110
  return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
1080
1111
  }
1081
- function jt(e, t) {
1082
- 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 && Bt(t) > e.precision && p(e, "precision", e.precision);
1112
+ function Vt(e, t) {
1113
+ 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 && qt(t) > e.precision && p(e, "precision", e.precision);
1083
1114
  }
1084
- function _t(e, t) {
1085
- Ue(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);
1115
+ function Yt(e, t) {
1116
+ Ve(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);
1086
1117
  }
1087
- function Ut(e) {
1118
+ function Kt(e) {
1088
1119
  [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");
1089
1120
  }
1090
- function Gt(e) {
1091
- [e.min, e.max].some((t) => t !== void 0 && !Ue(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
1121
+ function Jt(e) {
1122
+ [e.min, e.max].some((t) => t !== void 0 && !Ve(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
1092
1123
  }
1093
- function Vt(e, t) {
1124
+ function Xt(e, t) {
1094
1125
  (!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
1095
1126
  const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
1096
- for (const a of t.options)
1097
- (!a || typeof a.value !== n || typeof a.value == "number" && !Number.isFinite(a.value)) && p(t, "definition"), a.label !== void 0 && typeof a.label != "string" && p(t, "definition"), r.has(a.value) && p(t, "definition"), r.add(a.value);
1127
+ for (const i of t.options)
1128
+ (!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);
1098
1129
  }
1099
- function qt(e) {
1130
+ function Zt(e) {
1100
1131
  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");
1101
1132
  }
1102
- function Yt(e, t) {
1103
- (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), qt(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" && Ut(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Gt(t), t.type === "enum" && Vt(e, t);
1133
+ function Qt(e, t) {
1134
+ (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Zt(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" && Kt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Jt(t), t.type === "enum" && Xt(e, t);
1104
1135
  }
1105
- function _n(e, t, n) {
1106
- if (!e.editable) throw new rt("readonly");
1107
- n && Yt(e, n);
1108
- const r = at(e, t);
1109
- return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && jt(n, r), n.type === "date" && _t(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((a) => Object.is(a.value, r)) && p(n, "choice"), r)) : r;
1136
+ function Vn(e, t, n) {
1137
+ if (!e.editable) throw new nt("readonly");
1138
+ n && Qt(e, n);
1139
+ const r = rt(e, t);
1140
+ return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && Vt(n, r), n.type === "date" && Yt(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;
1110
1141
  }
1111
- class b extends Error {
1142
+ class w extends Error {
1112
1143
  constructor(t) {
1113
1144
  super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
1114
1145
  }
1115
1146
  }
1116
- function B(e) {
1147
+ function j(e) {
1117
1148
  if (!e?.aborted) return;
1118
1149
  const t = new Error("Calculation cancelled");
1119
1150
  throw t.name = "AbortError", t;
1120
1151
  }
1121
- async function ee(e, t = 1) {
1152
+ async function te(e, t = 1) {
1122
1153
  const n = Math.floor(e.scanned / 2048);
1123
- if (e.scanned += t, e.scanned > e.maxScanned) throw new b("limit");
1124
- B(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), B(e.signal));
1154
+ if (e.scanned += t, e.scanned > e.maxScanned) throw new w("limit");
1155
+ j(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), j(e.signal));
1125
1156
  }
1126
- function fe(e) {
1157
+ function we(e) {
1127
1158
  return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
1128
1159
  }
1129
- function xe(e, t, n) {
1130
- if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((i) => Number.isSafeInteger(i) && i >= 0)) throw new b("selection");
1160
+ function Te(e, t, n) {
1161
+ if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
1131
1162
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1132
- if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new b("selection");
1133
- const a = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((i, s) => Math.max(i, s.length), 1);
1134
- if (t.columnIndex >= a) throw new b("selection");
1163
+ if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
1164
+ const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, s) => Math.max(a, s.length), 1);
1165
+ if (t.columnIndex >= i) throw new w("selection");
1135
1166
  const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
1136
1167
  if (o && l && o.id === l.id) {
1137
- const i = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1138
- if (i < 0) throw new b("selection");
1139
- return { grid: o.id, row: fe(r) + t.rowIndex, column: i };
1168
+ const a = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1169
+ if (a < 0) throw new w("selection");
1170
+ return { grid: o.id, row: we(r) + t.rowIndex, column: a };
1140
1171
  }
1141
1172
  return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
1142
1173
  }
1143
- function Kt(e, t, n) {
1144
- const r = xe(e, t.anchor, t.anchor), a = xe(e, t.focus, t.anchor);
1145
- if (r.grid !== a.grid) throw new b("selection");
1146
- const o = (Math.abs(r.row - a.row) + 1) * (Math.abs(r.column - a.column) + 1);
1147
- if (!Number.isSafeInteger(o) || o > n) throw new b("limit");
1148
- return { grid: r.grid, rowStart: Math.min(r.row, a.row), rowEnd: Math.max(r.row, a.row), columnStart: Math.min(r.column, a.column), columnEnd: Math.max(r.column, a.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
1174
+ function en(e, t, n) {
1175
+ const r = Te(e, t.anchor, t.anchor), i = Te(e, t.focus, t.anchor);
1176
+ if (r.grid !== i.grid) throw new w("selection");
1177
+ const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
1178
+ if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
1179
+ 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 };
1149
1180
  }
1150
- function Jt(e) {
1181
+ function tn(e) {
1151
1182
  if (!e) return !1;
1152
1183
  const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
1153
1184
  return /[ymdhs]/i.test(t);
1154
1185
  }
1155
- function Xt(e) {
1156
- if (e.valueType === "text" || e.valueType === "boolean" || Jt(e.numberFormat)) return null;
1186
+ function nn(e) {
1187
+ if (e.valueType === "text" || e.valueType === "boolean" || tn(e.numberFormat)) return null;
1157
1188
  const t = e.value;
1158
1189
  if (typeof t != "number" || !Number.isFinite(t)) return null;
1159
- if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new b("precision");
1190
+ if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
1160
1191
  return t;
1161
1192
  }
1162
- function Zt(e, t, n) {
1193
+ function rn(e, t, n) {
1163
1194
  if (e.seen.has(n)) return;
1164
1195
  e.seen.add(n), e.selected++;
1165
- const r = t ? Xt(t) : null;
1196
+ const r = t ? nn(t) : null;
1166
1197
  r === null ? e.excluded++ : e.values.push(r);
1167
1198
  }
1168
- function Qt(e, t, n, r) {
1199
+ function an(e, t, n, r) {
1169
1200
  return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
1170
1201
  }
1171
- function en(e, t, n) {
1202
+ function on(e, t, n) {
1172
1203
  return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
1173
1204
  }
1174
- function tn(e, t, n, r) {
1175
- const a = r.origin ? fe(e) + t : t, o = en(e, n, r);
1176
- return a < r.rowStart || a > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${a}:${o}`;
1205
+ function sn(e, t, n, r) {
1206
+ const i = r.origin ? we(e) + t : t, o = on(e, n, r);
1207
+ return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
1177
1208
  }
1178
- function nn(e, t) {
1179
- const n = t.origin ? fe(e) : 0, r = Math.max(0, t.rowStart - n), a = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
1180
- return a > r ? a : 0;
1209
+ function ln(e, t) {
1210
+ const n = t.origin ? we(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
1211
+ return i > r ? i : 0;
1181
1212
  }
1182
- async function rn(e, t, n, r, a) {
1213
+ async function cn(e, t, n, r, i) {
1183
1214
  const o = e.grid;
1184
- if (t > r.maxScanned) throw new b("limit");
1215
+ if (t > r.maxScanned) throw new w("limit");
1185
1216
  const l = o.colWidthsMm?.length ?? o.cells.reduce((s, c) => Math.max(s, c.length), 1);
1186
- if (l > r.maxScanned) throw new b("limit");
1187
- const i = /* @__PURE__ */ new Map();
1217
+ if (l > r.maxScanned) throw new w("limit");
1218
+ const a = /* @__PURE__ */ new Map();
1188
1219
  for (let s = 0; s < t; s++) {
1189
- s > 0 && s % 2048 === 0 && (await r.yieldToHost(), B(r.signal));
1220
+ s > 0 && s % 2048 === 0 && (await r.yieldToHost(), j(r.signal));
1190
1221
  let c = 0;
1191
- for (const m of o.cells[s]) {
1192
- for (await ee(r); c < l && (i.get(c) ?? 0) > s; ) c++;
1222
+ for (const d of o.cells[s]) {
1223
+ for (await te(r); c < l && (a.get(c) ?? 0) > s; ) c++;
1193
1224
  if (c >= l) break;
1194
- const d = Math.max(1, Math.min(m?.colSpan ?? 1, l - c)), h = Math.min(o.cells.length, s + Math.max(1, m?.rowSpan ?? 1));
1195
- d > 1 && await ee(r, d - 1);
1196
- for (let f = c; f < c + d; f++) i.set(f, h);
1197
- const g = tn(e, s, c, n);
1198
- g && Zt(a, m, g), c += d;
1225
+ const h = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), m = Math.min(o.cells.length, s + Math.max(1, d?.rowSpan ?? 1));
1226
+ h > 1 && await te(r, h - 1);
1227
+ for (let f = c; f < c + h; f++) a.set(f, m);
1228
+ const g = sn(e, s, c, n);
1229
+ g && rn(i, d, g), c += h;
1199
1230
  }
1200
1231
  }
1201
1232
  }
1202
- async function an(e, t, n) {
1233
+ async function dn(e, t, n) {
1203
1234
  const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
1204
- for (let a = 0; a < e.pages.length; a++) {
1205
- await ee(n);
1206
- const o = e.pages[a];
1235
+ for (let i = 0; i < e.pages.length; i++) {
1236
+ await te(n);
1237
+ const o = e.pages[i];
1207
1238
  for (let l = 0; l < o.components.length; l++) {
1208
- await ee(n);
1209
- const i = o.components[l];
1210
- if (!i.grid || !Qt(i, a, l, t) || i.table && i.table.role !== "body") continue;
1211
- const s = nn(i, t);
1212
- s && await rn(i, s, t, n, r);
1239
+ await te(n);
1240
+ const a = o.components[l];
1241
+ if (!a.grid || !an(a, i, l, t) || a.table && a.table.role !== "body") continue;
1242
+ const s = ln(a, t);
1243
+ s && await cn(a, s, t, n, r);
1213
1244
  }
1214
1245
  }
1215
1246
  return r;
1216
1247
  }
1217
1248
  function V(e) {
1218
- if (!Number.isFinite(e)) throw new b("overflow");
1249
+ if (!Number.isFinite(e)) throw new w("overflow");
1219
1250
  return e;
1220
1251
  }
1221
- function on(e) {
1252
+ function mn(e) {
1222
1253
  let t = 0, n = 0;
1223
1254
  for (const r of e) {
1224
- const a = r - n, o = V(t + a);
1225
- n = o - t - a, t = o;
1255
+ const i = r - n, o = V(t + i);
1256
+ n = o - t - i, t = o;
1226
1257
  }
1227
1258
  return t;
1228
1259
  }
1229
- async function Ee(e, t) {
1260
+ async function Ce(e, t) {
1230
1261
  let n = [...e], r = new Array(e.length);
1231
1262
  for (let o = 1; o < e.length; o *= 2) {
1232
1263
  for (let l = 0; l < e.length; l += o * 2) {
1233
- const i = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
1234
- let c = l, m = i;
1235
- for (let d = l; d < s; d++)
1236
- r[d] = m >= s || c < i && n[c] <= n[m] ? n[c++] : n[m++], d % 2048 === 0 && (await t.yieldToHost(), B(t.signal));
1264
+ const a = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
1265
+ let c = l, d = a;
1266
+ for (let h = l; h < s; h++)
1267
+ r[h] = d >= s || c < a && n[c] <= n[d] ? n[c++] : n[d++], h % 2048 === 0 && (await t.yieldToHost(), j(t.signal));
1237
1268
  }
1238
1269
  [n, r] = [r, n];
1239
1270
  }
1240
- const a = Math.floor(n.length / 2);
1241
- return n.length % 2 ? n[a] : V(n[a - 1] / 2 + n[a] / 2);
1271
+ const i = Math.floor(n.length / 2);
1272
+ return n.length % 2 ? n[i] : V(n[i - 1] / 2 + n[i] / 2);
1242
1273
  }
1243
- function sn(e) {
1244
- const t = on(e);
1274
+ function hn(e) {
1275
+ const t = mn(e);
1245
1276
  let n = 1 / 0, r = -1 / 0;
1246
- for (const a of e)
1247
- n = Math.min(n, a), r = Math.max(r, a);
1277
+ for (const i of e)
1278
+ n = Math.min(n, i), r = Math.max(r, i);
1248
1279
  return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
1249
1280
  }
1250
- function ln(e, t) {
1251
- if (typeof e != "string" || e.length > 256) throw new b("expression");
1281
+ function gn(e, t) {
1282
+ if (typeof e != "string" || e.length > 256) throw new w("expression");
1252
1283
  const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
1253
- if (!n.length || n.length > 64) throw new b("expression");
1284
+ if (!n.length || n.length > 64) throw new w("expression");
1254
1285
  let r = 0;
1255
- function a(i) {
1256
- if (i > 16) throw new b("expression");
1286
+ function i(a) {
1287
+ if (a > 16) throw new w("expression");
1257
1288
  const s = n[r++];
1258
- if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * a(i + 1);
1289
+ if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * i(a + 1);
1259
1290
  if (s === "(") {
1260
- const c = o(0, i + 1);
1261
- if (n[r++] !== ")") throw new b("expression");
1291
+ const c = o(0, a + 1);
1292
+ if (n[r++] !== ")") throw new w("expression");
1262
1293
  return c;
1263
1294
  }
1264
1295
  if (s && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(s) && Object.prototype.hasOwnProperty.call(t, s)) return V(t[s]);
1265
1296
  if (s && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(s)) return V(Number(s));
1266
- throw new b("expression");
1297
+ throw new w("expression");
1267
1298
  }
1268
- function o(i, s) {
1269
- let c = a(s);
1299
+ function o(a, s) {
1300
+ let c = i(s);
1270
1301
  for (; r < n.length; ) {
1271
- const m = n[r], d = m === "+" || m === "-" ? 1 : m === "*" || m === "/" ? 2 : 0;
1272
- if (!d || d < i) break;
1302
+ const d = n[r], h = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
1303
+ if (!h || h < a) break;
1273
1304
  r++;
1274
- const h = o(d + 1, s + 1);
1275
- if (m === "/" && h === 0) throw new b("division");
1276
- c = V(m === "+" ? c + h : m === "-" ? c - h : m === "*" ? c * h : c / h);
1305
+ const m = o(h + 1, s + 1);
1306
+ if (d === "/" && m === 0) throw new w("division");
1307
+ c = V(d === "+" ? c + m : d === "-" ? c - m : d === "*" ? c * m : c / m);
1277
1308
  }
1278
1309
  return c;
1279
1310
  }
1280
1311
  const l = o(1, 0);
1281
- if (r !== n.length) throw new b("expression");
1312
+ if (r !== n.length) throw new w("expression");
1282
1313
  return l;
1283
1314
  }
1284
- function cn(e) {
1315
+ function fn(e) {
1285
1316
  const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
1286
- if (![t, n].every((a) => Number.isSafeInteger(a) && a >= 1 && a <= 2e6)) throw new b("limit");
1287
- if (!Number.isInteger(r) || r < 0 || r > 12) throw new b("precision");
1317
+ if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
1318
+ if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
1288
1319
  return { maxCells: t, maxScanned: n, precision: r };
1289
1320
  }
1290
- async function Un(e, t, n = {}) {
1291
- const r = cn(n), a = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
1292
- B(a.signal);
1293
- const o = await an(e, Kt(e, t, r.maxCells), a), l = n.operation ?? "sum";
1294
- if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new b("expression");
1295
- let i = null;
1296
- if (l === "count") i = o.values.length;
1321
+ async function Yn(e, t, n = {}) {
1322
+ const r = fn(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
1323
+ j(i.signal);
1324
+ const o = await dn(e, en(e, t, r.maxCells), i), l = n.operation ?? "sum";
1325
+ if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new w("expression");
1326
+ let a = null;
1327
+ if (l === "count") a = o.values.length;
1297
1328
  else if (o.values.length)
1298
- if (l === "median") i = await Ee(o.values, a);
1329
+ if (l === "median") a = await Ce(o.values, i);
1299
1330
  else {
1300
- const s = sn(o.values);
1301
- l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await Ee(o.values, a)), i = ln(n.expression ?? "", s)) : i = s[l.toUpperCase()];
1331
+ const s = hn(o.values);
1332
+ l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await Ce(o.values, i)), a = gn(n.expression ?? "", s)) : a = s[l.toUpperCase()];
1302
1333
  }
1303
- if (B(a.signal), i !== null && Number.isInteger(i) && !Number.isSafeInteger(i)) throw new b("precision");
1304
- return { value: i, formatted: i === null ? "—" : i.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
1334
+ if (j(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1335
+ return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
1305
1336
  }
1306
1337
  class A extends Error {
1307
1338
  constructor(t, n) {
1308
1339
  super(t), this.path = n, this.code = "label-sheet", this.name = "LabelSheetError";
1309
1340
  }
1310
1341
  }
1311
- function X(e) {
1342
+ function Z(e) {
1312
1343
  if (e?.aborted) {
1313
1344
  const t = new Error("标签拼版已取消");
1314
1345
  throw t.name = "AbortError", t;
@@ -1318,205 +1349,205 @@ function O(e, t, n = !1) {
1318
1349
  if (!Number.isFinite(e) || e <= 0 || n && !Number.isSafeInteger(e)) throw new A("应为正有限数字,数量应为安全整数", t);
1319
1350
  return e;
1320
1351
  }
1321
- function Se(e, t) {
1352
+ function Re(e, t) {
1322
1353
  if (!Number.isFinite(e) || e < 0) throw new A("应为非负有限数字", t);
1323
1354
  return e;
1324
1355
  }
1325
- function mn(e) {
1356
+ function un(e) {
1326
1357
  const t = typeof e.marginMm == "object" ? e.marginMm : { top: e.marginMm ?? 0, left: e.marginMm ?? 0, bottom: e.marginMm ?? 0, right: e.marginMm ?? 0 }, n = typeof e.gapMm == "object" ? e.gapMm : { horizontal: e.gapMm ?? 0, vertical: e.gapMm ?? 0 };
1327
- for (const r of ["top", "left", "bottom", "right"]) Se(t?.[r], `$.marginMm.${r}`);
1328
- for (const r of ["horizontal", "vertical"]) Se(n?.[r], `$.gapMm.${r}`);
1358
+ for (const r of ["top", "left", "bottom", "right"]) Re(t?.[r], `$.marginMm.${r}`);
1359
+ for (const r of ["horizontal", "vertical"]) Re(n?.[r], `$.gapMm.${r}`);
1329
1360
  return { margin: t, gap: n };
1330
1361
  }
1331
- function dn(e) {
1362
+ function pn(e) {
1332
1363
  const t = e.paper === void 0 || e.paper === "a4" ? { widthMm: 210, heightMm: 297 } : e.paper;
1333
1364
  O(t.widthMm, "$.paper.widthMm"), O(t.heightMm, "$.paper.heightMm");
1334
- const n = O(e.columns, "$.columns", !0), r = O(e.rows, "$.rows", !0), a = n * r;
1335
- if (a > 1e3) throw new A("每张纸不能超过 1000 个位置", "$.columns");
1336
- const { margin: o, gap: l } = mn(e), i = e.startSlot ?? 0, s = e.offsetMm ?? { x: 0, y: 0 };
1337
- if (!Number.isSafeInteger(i) || i < 0 || i >= a) throw new A("起始位置应在首张纸的有效位置内", "$.startSlot");
1365
+ const n = O(e.columns, "$.columns", !0), r = O(e.rows, "$.rows", !0), i = n * r;
1366
+ if (i > 1e3) throw new A("每张纸不能超过 1000 个位置", "$.columns");
1367
+ const { margin: o, gap: l } = un(e), a = e.startSlot ?? 0, s = e.offsetMm ?? { x: 0, y: 0 };
1368
+ if (!Number.isSafeInteger(a) || a < 0 || a >= i) throw new A("起始位置应在首张纸的有效位置内", "$.startSlot");
1338
1369
  if (!Number.isFinite(s.x) || !Number.isFinite(s.y)) throw new A("校准偏移应为有限毫米值", "$.offsetMm");
1339
- return { paper: t, columns: n, rows: r, capacity: a, margin: o, gap: l, startSlot: i, offset: s };
1370
+ return { paper: t, columns: n, rows: r, capacity: i, margin: o, gap: l, startSlot: a, offset: s };
1340
1371
  }
1341
- function Ge(e) {
1342
- return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, a) => r + (a?.children?.reduce((o, l) => o + Ge(l), 0) ?? 0), 0), 0) ?? 0);
1372
+ function Ye(e) {
1373
+ return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, i) => r + (i?.children?.reduce((o, l) => o + Ye(l), 0) ?? 0), 0), 0) ?? 0);
1343
1374
  }
1344
- function hn(e, t, n) {
1345
- if (!Je(e).ok) throw new A("标签计划无效", "$.plan");
1375
+ function wn(e, t, n) {
1376
+ if (!Qe(e).ok) throw new A("标签计划无效", "$.plan");
1346
1377
  const r = e.pages[0];
1347
1378
  if (!r) return;
1348
- const { paper: a, columns: o, rows: l, margin: i, gap: s, offset: c } = n;
1349
- if (i.left + c.x < 0 || i.top + c.y < 0 || i.left + c.x + o * r.pageWidthMm + (o - 1) * s.horizontal + i.right > a.widthMm + 1e-6 || i.top + c.y + l * r.pageHeightMm + (l - 1) * s.vertical + i.bottom > a.heightMm + 1e-6) throw new A("标签、间距、边距及校准偏移超过纸张尺寸;不会自动缩小标签", "$.paper");
1350
- let m = 0;
1351
- for (const [d, h] of e.pages.entries()) {
1352
- if (X(t.signal), h.layout === "wide" || h.pageWidthMm !== r.pageWidthMm || h.pageHeightMm !== r.pageHeightMm) throw new A("拼版需要尺寸相同的固定标签页面", `$.pages.${d}`);
1353
- if (m += h.components.reduce((g, f) => g + Ge(f), 0), m > O(t.maxComponents ?? 25e4, "$.maxComponents", !0)) throw new A("拼版组件总量超过预算", "$.maxComponents");
1354
- for (const g of h.components) if (g.leftMm < 0 || g.topMm < 0 || g.leftMm + g.widthMm > h.pageWidthMm + 1e-6 || g.topMm + g.heightMm > h.pageHeightMm + 1e-6) throw new A("标签内容超出标签边界", `$.pages.${d}.components`);
1379
+ const { paper: i, columns: o, rows: l, margin: a, gap: s, offset: c } = n;
1380
+ if (a.left + c.x < 0 || a.top + c.y < 0 || a.left + c.x + o * r.pageWidthMm + (o - 1) * s.horizontal + a.right > i.widthMm + 1e-6 || a.top + c.y + l * r.pageHeightMm + (l - 1) * s.vertical + a.bottom > i.heightMm + 1e-6) throw new A("标签、间距、边距及校准偏移超过纸张尺寸;不会自动缩小标签", "$.paper");
1381
+ let d = 0;
1382
+ for (const [h, m] of e.pages.entries()) {
1383
+ if (Z(t.signal), m.layout === "wide" || m.pageWidthMm !== r.pageWidthMm || m.pageHeightMm !== r.pageHeightMm) throw new A("拼版需要尺寸相同的固定标签页面", `$.pages.${h}`);
1384
+ if (d += m.components.reduce((g, f) => g + Ye(f), 0), d > O(t.maxComponents ?? 25e4, "$.maxComponents", !0)) throw new A("拼版组件总量超过预算", "$.maxComponents");
1385
+ for (const g of m.components) if (g.leftMm < 0 || g.topMm < 0 || g.leftMm + g.widthMm > m.pageWidthMm + 1e-6 || g.topMm + g.heightMm > m.pageHeightMm + 1e-6) throw new A("标签内容超出标签边界", `$.pages.${h}.components`);
1355
1386
  }
1356
1387
  }
1357
- function Gn(e, t) {
1358
- X(t.signal);
1359
- const n = dn(t), { paper: r, columns: a, capacity: o, margin: l, gap: i, startSlot: s, offset: c } = n, m = e.pages.length ? Math.ceil((s + e.pages.length) / o) : 0;
1360
- if (m > O(t.maxSheets ?? 1e4, "$.maxSheets", !0)) throw new A("拼版纸张数量超过预算", "$.maxSheets");
1361
- O(t.maxComponents ?? 25e4, "$.maxComponents", !0), hn(e, t, n);
1362
- const d = Qe(e, { maxBytes: O(t.maxSnapshotBytes ?? 64e6, "$.maxSnapshotBytes", !0), check: () => X(t.signal), error: (g, f) => new A(f, "$.maxSnapshotBytes") }), h = Array.from({ length: m }, () => ({ pageWidthMm: r.widthMm, pageHeightMm: r.heightMm, components: [], meta: { labelSheet: { columns: a, rows: n.rows, slots: [] } } }));
1363
- for (const [g, f] of d.pages.entries()) {
1364
- X(t.signal);
1365
- const w = s + g, C = w % o, x = h[Math.floor(w / o)], v = l.left + c.x + C % a * (f.pageWidthMm + i.horizontal), R = l.top + c.y + Math.floor(C / a) * (f.pageHeightMm + i.vertical), H = { sourcePageIndex: g, slotIndex: C, xMm: v, yMm: R, widthMm: f.pageWidthMm, heightMm: f.pageHeightMm, ...f.meta ? { sourceMeta: f.meta } : {} };
1366
- x.meta.labelSheet.slots.push(H), x.components.push(...f.components.map((N) => ({ ...N, leftMm: N.leftMm + v, topMm: N.topMm + R, meta: { ...N.meta, labelSheet: H } })));
1388
+ function Kn(e, t) {
1389
+ Z(t.signal);
1390
+ const n = pn(t), { paper: r, columns: i, capacity: o, margin: l, gap: a, startSlot: s, offset: c } = n, d = e.pages.length ? Math.ceil((s + e.pages.length) / o) : 0;
1391
+ if (d > O(t.maxSheets ?? 1e4, "$.maxSheets", !0)) throw new A("拼版纸张数量超过预算", "$.maxSheets");
1392
+ O(t.maxComponents ?? 25e4, "$.maxComponents", !0), wn(e, t, n);
1393
+ const h = it(e, { maxBytes: O(t.maxSnapshotBytes ?? 64e6, "$.maxSnapshotBytes", !0), check: () => Z(t.signal), error: (g, f) => new A(f, "$.maxSnapshotBytes") }), m = Array.from({ length: d }, () => ({ pageWidthMm: r.widthMm, pageHeightMm: r.heightMm, components: [], meta: { labelSheet: { columns: i, rows: n.rows, slots: [] } } }));
1394
+ for (const [g, f] of h.pages.entries()) {
1395
+ Z(t.signal);
1396
+ const T = s + g, R = T % o, b = m[Math.floor(T / o)], y = l.left + c.x + R % i * (f.pageWidthMm + a.horizontal), P = l.top + c.y + Math.floor(R / i) * (f.pageHeightMm + a.vertical), H = { sourcePageIndex: g, slotIndex: R, xMm: y, yMm: P, widthMm: f.pageWidthMm, heightMm: f.pageHeightMm, ...f.meta ? { sourceMeta: f.meta } : {} };
1397
+ b.meta.labelSheet.slots.push(H), b.components.push(...f.components.map((N) => ({ ...N, leftMm: N.leftMm + y, topMm: N.topMm + P, meta: { ...N.meta, labelSheet: H } })));
1367
1398
  }
1368
- return { ...d, pages: h };
1399
+ return { ...h, pages: m };
1369
1400
  }
1370
1401
  export {
1371
- lr as CSS_DPI,
1372
- Yn as DEFAULT_BORDER_PT,
1373
- te as DEFAULT_FONT_FAMILY,
1374
- Kn as DEFAULT_FONT_PT,
1375
- kr as DEFAULT_LABEL_PAGE_LIMIT,
1376
- Jn as DEFAULT_STROKE_COLOR,
1377
- Te as DEFAULT_TEXT_COLOR,
1378
- Xn as LINE_HEIGHT,
1402
+ Zn as CSS_DPI,
1403
+ Qn as DEFAULT_BORDER_PT,
1404
+ ne as DEFAULT_FONT_FAMILY,
1405
+ er as DEFAULT_FONT_PT,
1406
+ Lr as DEFAULT_LABEL_PAGE_LIMIT,
1407
+ tr as DEFAULT_STROKE_COLOR,
1408
+ Pe as DEFAULT_TEXT_COLOR,
1409
+ nr as LINE_HEIGHT,
1379
1410
  A as LabelSheetError,
1380
- cr as MM_PER_INCH,
1381
- Kr as OutputAssetError,
1382
- et as OutputFidelityError,
1383
- Z as PAPER_SIZES,
1384
- $t as PageBuilder,
1385
- Ir as PaginateCellLimitError,
1386
- Nr as PaginatePageLimitError,
1387
- gr as RENDER_PLAN_SCHEMA_VERSION,
1388
- ur as REPORT_TEMPLATE_DOCUMENT_VERSION,
1389
- er as ReportBindingError,
1390
- b as ReportCalculationError,
1391
- rt as ReportCellEditError,
1392
- Wt as ReportCellFieldError,
1393
- Xr as ReportDrillError,
1394
- ra as ReportParamValidationError,
1395
- ce as ReportSourceError,
1396
- ke as ReportTemplateError,
1411
+ rr as MM_PER_INCH,
1412
+ di as OutputAssetError,
1413
+ ot as OutputFidelityError,
1414
+ Q as PAPER_SIZES,
1415
+ Dt as PageBuilder,
1416
+ Dr as PaginateCellLimitError,
1417
+ Fr as PaginatePageLimitError,
1418
+ pr as RENDER_PLAN_SCHEMA_VERSION,
1419
+ br as REPORT_TEMPLATE_DOCUMENT_VERSION,
1420
+ lr as ReportBindingError,
1421
+ w as ReportCalculationError,
1422
+ nt as ReportCellEditError,
1423
+ Gt as ReportCellFieldError,
1424
+ hi as ReportDrillError,
1425
+ bi as ReportParamValidationError,
1426
+ me as ReportSourceError,
1427
+ Ne as ReportTemplateError,
1397
1428
  D as ReportTemplateStoreError,
1398
- Zn as SCHEMA_VERSION_MACH,
1399
- At as TemplateBuilder,
1400
- _a as TreeRowLimitError,
1401
- Na as applyReportCellEdit,
1402
- La as applyReportCellEditBatch,
1403
- Pa as applyReportDocumentStyle,
1404
- Lr as applyReportEditResult,
1405
- Dr as applyReportSourceMetadata,
1406
- pr as assertRenderPlan,
1407
- aa as assertReportParams,
1408
- Un as calculateReportSelection,
1409
- Aa as captureTemplateFragment,
1410
- Cr as charWidthEm,
1411
- T as classOf,
1412
- fa as cloneReportTemplate,
1413
- Sa as collectTemplateOutline,
1414
- Ln as columnsFromContract,
1415
- vt as computePageWindow,
1416
- Fr as countTemplatePages,
1417
- Rr as createCanvasMeasurer,
1418
- In as createCanvasPager,
1419
- Pr as createHeuristicMeasurer,
1420
- Fn as createLabelTemplate,
1421
- ua as createLocalTemplateCatalog,
1422
- Wn as createMemoryTemplateStore,
1423
- Hn as createProviderReport,
1424
- Da as createReportCellEdit,
1425
- Fa as createReportCellEditBatch,
1426
- Oa as createReportCellResolver,
1427
- Zr as createReportDrillRequest,
1428
- Or as createReportEditSession,
1429
- Hr as createReportSource,
1430
- Dn as createTableTemplate,
1431
- Nn as createTemplate,
1432
- zn as createTemplateManager,
1433
- wr as createTemplateRegistry,
1434
- Ua as createTreeTable,
1435
- Sr as datasetJsonSchema,
1436
- On as defineLabelReport,
1437
- Ze as defineReport,
1438
- br as defineReportTemplate,
1439
- pa as diffReportTemplates,
1440
- zr as estimateListLayoutCells,
1441
- tr as evalStyleRule,
1442
- ln as evaluateReportAggregateExpression,
1443
- Ha as formatReportCellEdit,
1444
- Bn as formatReportClipboard,
1445
- ia as formatReportDateRange,
1446
- nr as formatValue,
1447
- za as getReportCellContext,
1448
- Wr as getReportEditSession,
1449
- ya as hasValidDataExplanation,
1450
- le as heuristicMeasurer,
1451
- Gn as imposeLabelSheets,
1452
- $a as insertTemplateFragment,
1453
- qr as inspectOutputCapabilities,
1454
- Ta as inspectTemplateFieldUsage,
1455
- ka as inspectTemplateFragmentBindings,
1429
+ ir as SCHEMA_VERSION_MACH,
1430
+ Lt as TemplateBuilder,
1431
+ Ui as TreeRowLimitError,
1432
+ Or as applyReportCellEdit,
1433
+ zr as applyReportCellEditBatch,
1434
+ Hi as applyReportDocumentStyle,
1435
+ Hr as applyReportEditResult,
1436
+ Br as applyReportSourceMetadata,
1437
+ Mr as assertRenderPlan,
1438
+ Mi as assertReportParams,
1439
+ Yn as calculateReportSelection,
1440
+ Bi as captureTemplateFragment,
1441
+ Ar as charWidthEm,
1442
+ E as classOf,
1443
+ Ai as cloneReportTemplate,
1444
+ Di as collectTemplateOutline,
1445
+ zn as columnsFromContract,
1446
+ Ct as computePageWindow,
1447
+ Wr as countTemplatePages,
1448
+ kr as createCanvasMeasurer,
1449
+ Fn as createCanvasPager,
1450
+ $r as createHeuristicMeasurer,
1451
+ Bn as createLabelTemplate,
1452
+ ki as createLocalTemplateCatalog,
1453
+ Un as createMemoryTemplateStore,
1454
+ _n as createProviderReport,
1455
+ _r as createReportCellEdit,
1456
+ jr as createReportCellEditBatch,
1457
+ Ur as createReportCellResolver,
1458
+ gi as createReportDrillRequest,
1459
+ Gr as createReportEditSession,
1460
+ qr as createReportSource,
1461
+ Hn as createTableTemplate,
1462
+ On as createTemplate,
1463
+ jn as createTemplateManager,
1464
+ vr as createTemplateRegistry,
1465
+ Gi as createTreeTable,
1466
+ Rr as datasetJsonSchema,
1467
+ Wn as defineLabelReport,
1468
+ tt as defineReport,
1469
+ yr as defineReportTemplate,
1470
+ $i as diffReportTemplates,
1471
+ Vr as estimateListLayoutCells,
1472
+ cr as evalStyleRule,
1473
+ gn as evaluateReportAggregateExpression,
1474
+ Yr as formatReportCellEdit,
1475
+ Gn as formatReportClipboard,
1476
+ vi as formatReportDateRange,
1477
+ dr as formatValue,
1478
+ Kr as getReportCellContext,
1479
+ Jr as getReportEditSession,
1480
+ Xr as hasValidDataExplanation,
1481
+ de as heuristicMeasurer,
1482
+ Kn as imposeLabelSheets,
1483
+ Wi as insertTemplateFragment,
1484
+ li as inspectOutputCapabilities,
1485
+ Fi as inspectTemplateFieldUsage,
1486
+ _i as inspectTemplateFragmentBindings,
1456
1487
  re as isImageBackedComponent,
1457
- va as isReportDataTarget,
1458
- oa as isReportDate,
1459
- sa as isReportMonth,
1460
- xa as isReportValueState,
1461
- la as isReportYear,
1462
- Ae as isRichText,
1463
- Qr as matchReportDrillActions,
1464
- he as measurePageSizePx,
1465
- Ar as measureTextMm,
1466
- Re as mergeComponentStyles,
1467
- se as mmToPx,
1468
- mr as mmToPxFactor,
1469
- Br as paginateTemplate,
1470
- jr as paginateTemplatePages,
1471
- rr as parseDateLocal,
1472
- _n as parseReportCellFieldInput,
1473
- at as parseReportCellInput,
1474
- jn as parseReportClipboard,
1475
- ca as parseReportDateRange,
1476
- U as parseReportTemplate,
1477
- Pn as planFontSizePx,
1478
- _r as projectListColumns,
1488
+ Zr as isReportDataTarget,
1489
+ yi as isReportDate,
1490
+ xi as isReportMonth,
1491
+ Qr as isReportValueState,
1492
+ Si as isReportYear,
1493
+ $e as isRichText,
1494
+ fi as matchReportDrillActions,
1495
+ pe as measurePageSizePx,
1496
+ Ir as measureTextMm,
1497
+ ke as mergeComponentStyles,
1498
+ le as mmToPx,
1499
+ ar as mmToPxFactor,
1500
+ ei as paginateTemplate,
1501
+ ti as paginateTemplatePages,
1502
+ mr as parseDateLocal,
1503
+ Vn as parseReportCellFieldInput,
1504
+ rt as parseReportCellInput,
1505
+ qn as parseReportClipboard,
1506
+ Ei as parseReportDateRange,
1507
+ G as parseReportTemplate,
1508
+ In as planFontSizePx,
1509
+ ni as projectListColumns,
1479
1510
  W as ptToPx,
1480
- dr as pxToMm,
1481
- Ur as registerReportEditSession,
1482
- Gr as relocateReportCellEdits,
1483
- Oe as renderComponent,
1484
- pt as renderPage,
1485
- Rn as renderPlan,
1486
- $n as renderPlanToCanvas,
1487
- kn as renderPlanToCanvasAsync,
1488
- An as renderPlanToImages,
1489
- Wa as reportCellEditKey,
1490
- q as reportOutputDiagnostics,
1491
- ma as reportParamsJsonSchema,
1492
- Ce as resolveBoxBorders,
1493
- ar as resolveComponentBinding,
1494
- _ as resolveFontSize,
1495
- Ne as resolveGridLayout,
1496
- ne as resolveLineHeight,
1497
- _e as resolvePaper,
1498
- me as resolvePlanAssets,
1499
- ea as resolveReportDrillReturn,
1500
- G as resolveStroke,
1501
- Pe as resolveTextColor,
1502
- wa as reviewReportTemplate,
1503
- ba as reviewReportTemplateAsync,
1504
- j as round,
1505
- Mr as serializeReportTemplate,
1506
- Ba as summarizeReportCellEdits,
1507
- Ca as templatePathLocation,
1508
- ir as toExcelNumberFormat,
1509
- or as toNumber,
1510
- yr as validateComponent,
1511
- Xe as validateDatasetRows,
1512
- vr as validatePage,
1513
- Je as validateRenderPlan,
1514
- Yt as validateReportCellFieldDefinition,
1515
- ta as validateReportDrillActions,
1516
- da as validateReportParamDefinitions,
1517
- ha as validateReportParams,
1518
- $e as validateReportTemplate,
1519
- xr as validateReportTemplateDocument,
1520
- Ga as validateTreeOptions,
1521
- Ie as wrapText
1511
+ or as pxToMm,
1512
+ ri as registerReportEditSession,
1513
+ ii as relocateReportCellEdits,
1514
+ Be as renderComponent,
1515
+ Mt as renderPage,
1516
+ $n as renderPlan,
1517
+ Ln as renderPlanToCanvas,
1518
+ Dn as renderPlanToCanvasAsync,
1519
+ Nn as renderPlanToImages,
1520
+ ai as reportCellEditKey,
1521
+ Y as reportOutputDiagnostics,
1522
+ Ti as reportParamsJsonSchema,
1523
+ Ae as resolveBoxBorders,
1524
+ hr as resolveComponentBinding,
1525
+ z as resolveFontSize,
1526
+ De as resolveGridLayout,
1527
+ _ as resolveLineHeight,
1528
+ qe as resolvePaper,
1529
+ he as resolvePlanAssets,
1530
+ ui as resolveReportDrillReturn,
1531
+ q as resolveStroke,
1532
+ ce as resolveTextColor,
1533
+ Ii as reviewReportTemplate,
1534
+ Ni as reviewReportTemplateAsync,
1535
+ U as round,
1536
+ xr as serializeReportTemplate,
1537
+ oi as summarizeReportCellEdits,
1538
+ Oi as templatePathLocation,
1539
+ gr as toExcelNumberFormat,
1540
+ fr as toNumber,
1541
+ Sr as validateComponent,
1542
+ et as validateDatasetRows,
1543
+ Er as validatePage,
1544
+ Qe as validateRenderPlan,
1545
+ Qt as validateReportCellFieldDefinition,
1546
+ pi as validateReportDrillActions,
1547
+ Ci as validateReportParamDefinitions,
1548
+ Ri as validateReportParams,
1549
+ Ie as validateReportTemplate,
1550
+ Tr as validateReportTemplateDocument,
1551
+ qi as validateTreeOptions,
1552
+ Le as wrapText
1522
1553
  };