@agile-team/mach-report 2.6.1 → 2.8.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.
- package/README.md +59 -8
- package/dist/ReportPreview-BKKDAv8e.js +4481 -0
- package/dist/ReportPreview-E3cm67Tk.cjs +6 -0
- package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
- package/dist/assets-RZan7EyL.cjs +1 -0
- package/dist/capabilities-joSutDF8.js +63 -0
- package/dist/capabilities-xGTpnPjJ.cjs +1 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +922 -753
- package/dist/designer.d.ts +922 -753
- package/dist/designer.js +490 -234
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +128 -3
- package/dist/index.d.ts +128 -3
- package/dist/index.js +971 -699
- package/dist/pdf.cjs +30 -30
- package/dist/pdf.d.cts +11 -3
- package/dist/pdf.d.ts +11 -3
- package/dist/pdf.js +1501 -1500
- package/dist/{plugin-Ds10VnQO.js → plugin-PCgxBVB2.js} +1 -1
- package/dist/{plugin-BqBkn_kI.cjs → plugin-mAfvgSey.cjs} +1 -1
- package/dist/progress-DD964VAB.js +102 -0
- package/dist/progress-KvhwXZ1Q.cjs +1 -0
- package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
- package/dist/report-source-CCAvFE3t.cjs +1 -0
- package/dist/server/node.d.cts +26 -3
- package/dist/server/node.d.ts +26 -3
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +125 -92
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +28 -3
- package/dist/server.d.ts +28 -3
- package/dist/server.js +172 -164
- package/dist/style.css +1 -1
- package/dist/task-events-DQ276fn2.cjs +1 -0
- package/dist/task-events-Dpsvf_t2.js +47 -0
- package/dist/vue/async.d.cts +1553 -2083
- package/dist/vue/async.d.ts +1553 -2083
- package/dist/vue/index.d.cts +2465 -3310
- package/dist/vue/index.d.ts +2465 -3310
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +159 -132
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +26 -3
- package/dist/worker.d.ts +26 -3
- package/dist/worker.js +110 -85
- package/dist/xlsx.cjs +14 -14
- package/dist/xlsx.d.cts +11 -3
- package/dist/xlsx.d.ts +11 -3
- package/dist/xlsx.js +656 -652
- package/package.json +2 -2
- package/dist/ReportPreview-Dk-28QAi.js +0 -2946
- package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
- package/dist/assets-66UBlhES.cjs +0 -1
- package/dist/capabilities-CNjIirfo.js +0 -36
- package/dist/capabilities-D4xeVYSR.cjs +0 -1
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/report-source-BbNkkBDy.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { c as
|
|
3
|
-
import { v as
|
|
4
|
-
import { P as
|
|
5
|
-
import { r as
|
|
6
|
-
import { C as
|
|
7
|
-
import { a as
|
|
8
|
-
import { h as
|
|
9
|
-
import { c as
|
|
10
|
-
import { r as
|
|
11
|
-
import { r as
|
|
12
|
-
import { O as
|
|
13
|
-
import { r as
|
|
14
|
-
import { i as
|
|
15
|
-
import { c as
|
|
16
|
-
import { p as
|
|
17
|
-
import { R as
|
|
18
|
-
import { R as
|
|
19
|
-
import { f as
|
|
20
|
-
const
|
|
1
|
+
import { i as Q, D as ee, a as Pe, b as Re } from "./render-plan-uzZYYSy1.js";
|
|
2
|
+
import { c as or, d as ar, e as sr, L as lr, R as cr, S as dr } from "./render-plan-uzZYYSy1.js";
|
|
3
|
+
import { v as et } from "./report-source-BXHNy_AD.js";
|
|
4
|
+
import { P as mr, R as fr, c as hr, d as gr, a as pr, e as wr, f as br, p as vr, b as yr, t as xr, g as Mr } from "./report-source-BXHNy_AD.js";
|
|
5
|
+
import { r as H, a as j, b as te, c as B, d as Ae, m as se, e as ke, p as L, f as $e, P as Y } from "./style-Dv5o_x6b.js";
|
|
6
|
+
import { C as Sr, M as Tr, g as Cr, h as Ir } from "./style-Dv5o_x6b.js";
|
|
7
|
+
import { a as Rr, v as Ar, b as kr, c as $r } from "./validate-S6CgIm5d.js";
|
|
8
|
+
import { h as le, w as Ne } from "./textwrap-DOl04hCQ.js";
|
|
9
|
+
import { c as Fr, a as Or, b as Dr, m as Lr } from "./textwrap-DOl04hCQ.js";
|
|
10
|
+
import { r as K, o as tt } from "./progress-DD964VAB.js";
|
|
11
|
+
import { r as Fe, a as ce } from "./assets-B9qJku3V.js";
|
|
12
|
+
import { O as Hr } from "./assets-B9qJku3V.js";
|
|
13
|
+
import { r as V, n as Oe, O as nt } from "./capabilities-joSutDF8.js";
|
|
14
|
+
import { i as Wr } from "./capabilities-joSutDF8.js";
|
|
15
|
+
import { c as rt } from "./page-window-index-CIuT4BAv.js";
|
|
16
|
+
import { p as ae } from "./template-registry-NpOakidD.js";
|
|
17
|
+
import { R as _r, a as Kr, c as Vr, d as Gr, s as Ur, v as qr, b as Jr } from "./template-registry-NpOakidD.js";
|
|
18
|
+
import { R as Xr, a as Zr, i as Qr, r as ei, v as ti, b as ni } from "./param-validation-BWNjLcN0.js";
|
|
19
|
+
import { f as it, i as ot } from "./number-format-BA_KwrZe.js";
|
|
20
|
+
const at = {
|
|
21
21
|
root: "mr-root",
|
|
22
22
|
page: "mr-page",
|
|
23
23
|
comp: "mr-comp",
|
|
@@ -34,10 +34,10 @@ const Je = {
|
|
|
34
34
|
cell: "mr-cell",
|
|
35
35
|
unknown: "mr-unknown"
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
return t?.classNames?.[e] ??
|
|
37
|
+
function C(e, t) {
|
|
38
|
+
return t?.classNames?.[e] ?? at[e];
|
|
39
39
|
}
|
|
40
|
-
class
|
|
40
|
+
class st {
|
|
41
41
|
constructor() {
|
|
42
42
|
this.props = [];
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class qe {
|
|
|
45
45
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
46
46
|
}
|
|
47
47
|
mm(t, n, r, i = 2) {
|
|
48
|
-
return this.add(t, `${
|
|
48
|
+
return this.add(t, `${H(se(n, r), i)}px`);
|
|
49
49
|
}
|
|
50
50
|
toString() {
|
|
51
51
|
let t = "";
|
|
@@ -58,510 +58,522 @@ class qe {
|
|
|
58
58
|
n && (t.style.cssText = n);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return new
|
|
61
|
+
function x(e, t = "unset") {
|
|
62
|
+
return new st().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
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(
|
|
66
|
-
const r =
|
|
67
|
-
e.add("font-size", `${
|
|
64
|
+
function De(e, t, n) {
|
|
65
|
+
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(te(t))).add("text-align", t.align);
|
|
66
|
+
const r = j(t, n);
|
|
67
|
+
e.add("font-size", `${H(r.fontSizePx, 2)}px`);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function lt(e, t, n) {
|
|
70
70
|
const r = t.style ?? {};
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const d =
|
|
79
|
-
d.className = "mr-cell-content",
|
|
80
|
-
for (const u of
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
return
|
|
71
|
+
De(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);
|
|
72
|
+
}
|
|
73
|
+
function ct(e, t, n, r, i, s) {
|
|
74
|
+
const l = e.cell, o = s.createElement("td");
|
|
75
|
+
o.className = C("cell", i), o.dataset.mrRowIndex = String(e.ri), o.dataset.mrColumnIndex = String(e.ci), o.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (o.colSpan = l.colSpan), l.rowSpan && (o.rowSpan = l.rowSpan);
|
|
76
|
+
const a = ke(t.style, l.style), c = x("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", a.backgroundColor).add("vertical-align", a.verticalAlign ?? "middle");
|
|
77
|
+
De(c, a, r), c.applyTo(o);
|
|
78
|
+
const d = s.createElement("div");
|
|
79
|
+
d.className = "mr-cell-content", x("flex").add("position", "absolute").mm("left", n, r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", a.verticalAlign === "top" ? "flex-start" : a.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), l.text != null && d.append(l.text);
|
|
80
|
+
for (const u of l.children ?? []) d.appendChild(Le(u, r, i, s));
|
|
81
|
+
return o.appendChild(d), o;
|
|
82
|
+
}
|
|
83
|
+
function dt(e, t, n, r) {
|
|
84
|
+
return Fe(e, t).map((i) => {
|
|
85
|
+
const s = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, l = r.createElement("div");
|
|
86
|
+
l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
|
|
87
|
+
const o = i.kind === "h";
|
|
88
|
+
return x("block").add("position", "absolute").add("pointer-events", "none").mm("left", o ? i.from : i.pos, n).mm("top", o ? i.pos : i.from, n).mm("width", o ? i.to - i.from : 0, n).mm("height", o ? 0 : i.to - i.from, n).add(o ? "border-top" : "border-left", s).applyTo(l), l;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
91
|
+
function ut(e, t, n, r, i) {
|
|
92
|
+
const s = i.createElement("table");
|
|
93
|
+
s.className = C("grid", r), s.setAttribute("role", "table"), x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(s);
|
|
94
|
+
const l = K(e, t.widthMm, t.heightMm), o = i.createElement("tbody");
|
|
95
|
+
x("contents").applyTo(o), s.appendChild(o);
|
|
96
|
+
const a = e.cells.map(() => {
|
|
97
97
|
const d = i.createElement("tr");
|
|
98
|
-
return d.className =
|
|
98
|
+
return d.className = C("row", r), d.setAttribute("role", "row"), x("contents").applyTo(d), o.appendChild(d), d;
|
|
99
99
|
});
|
|
100
|
-
for (const d of
|
|
101
|
-
|
|
100
|
+
for (const d of l.cells)
|
|
101
|
+
a[d.ri].appendChild(ct(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
102
102
|
const c = i.createElement("div");
|
|
103
|
-
return
|
|
103
|
+
return x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(s, ...dt(l, t, n, i)), c;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function mt(e, t, n, r) {
|
|
106
106
|
const i = r.createElement("div");
|
|
107
|
-
i.className =
|
|
108
|
-
for (const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
|
|
107
|
+
i.className = C("paragraph", n), x("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);
|
|
108
|
+
for (const s of e.segments || []) {
|
|
109
|
+
const l = r.createElement("span");
|
|
110
|
+
l.className = C("segment", n), l.textContent = s.kind === "field" ? s.field ?? "" : s.text ?? "";
|
|
111
|
+
const o = x("inline");
|
|
112
|
+
if (s.style) {
|
|
113
|
+
const a = s.style;
|
|
114
|
+
o.add("color", a.color).add("font-family", a.fontFamily).add("font-weight", a.bold != null ? a.bold ? "700" : "400" : void 0).add("font-style", a.italic != null ? a.italic ? "italic" : "normal" : void 0).add("text-decoration", a.underline != null ? a.underline ? "underline" : "none" : void 0), (a.fontSize != null || a.fontSizePx != null) && o.add("font-size", `${H(j(a, t).fontSizePx, 2)}px`);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
o.applyTo(l), i.appendChild(l);
|
|
117
117
|
}
|
|
118
118
|
return i;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
120
|
+
function ft(e, t, n, r) {
|
|
121
|
+
if (Re(e)) {
|
|
122
122
|
const i = r.createElement("div");
|
|
123
|
-
i.className =
|
|
124
|
-
for (const
|
|
123
|
+
i.className = C("rich", n), x("block").applyTo(i);
|
|
124
|
+
for (const s of e.richParagraphs) i.appendChild(mt(s, t, n, r));
|
|
125
125
|
return i;
|
|
126
126
|
}
|
|
127
127
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
128
128
|
const i = r.createElement("div");
|
|
129
|
-
i.className =
|
|
130
|
-
for (const
|
|
131
|
-
const
|
|
132
|
-
|
|
129
|
+
i.className = C("lines", n), x("block").applyTo(i);
|
|
130
|
+
for (const s of e.lines) {
|
|
131
|
+
const l = r.createElement("div");
|
|
132
|
+
l.className = C("line", n), l.textContent = s, x("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
|
|
133
133
|
}
|
|
134
134
|
return i;
|
|
135
135
|
}
|
|
136
136
|
return e.text ?? "";
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function ht(e, t, n, r) {
|
|
139
139
|
const i = r.createElement("div");
|
|
140
|
-
i.className =
|
|
141
|
-
const
|
|
142
|
-
return
|
|
140
|
+
i.className = C("text", n);
|
|
141
|
+
const s = e.style || {};
|
|
142
|
+
return x("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(ft(e, t, n, r)), i;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function gt(e, t, n) {
|
|
145
145
|
const r = n.createElement("img");
|
|
146
|
-
return r.className =
|
|
146
|
+
return r.className = C("image", t), r.src = e.imageData, x("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Me(e, t, n, r) {
|
|
149
149
|
const i = r.createElement("div");
|
|
150
|
-
i.className =
|
|
151
|
-
const
|
|
152
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (
|
|
153
|
-
}
|
|
154
|
-
function
|
|
155
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i =
|
|
156
|
-
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1,
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
function
|
|
150
|
+
i.className = C("shape", n);
|
|
151
|
+
const s = e.style || {}, l = B(s), o = Ae(s), a = `${H(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = x("block");
|
|
152
|
+
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (o.top && c.add("border-top", a), o.right && c.add("border-right", a), o.bottom && c.add("border-bottom", a), o.left && c.add("border-left", a)) : e.kind === "ellipse" ? (o.inner && c.add("border", a).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", a), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
|
|
153
|
+
}
|
|
154
|
+
function pt(e, t, n) {
|
|
155
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = se(e.widthMm, t), s = se(e.heightMm, t);
|
|
156
|
+
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, s))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
157
|
+
const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
158
|
+
l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(s) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(s));
|
|
159
|
+
const o = B({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
160
|
+
return l.setAttribute("stroke", o.color), l.setAttribute("stroke-width", String(o.widthPt * t / 72)), r.appendChild(l), r;
|
|
161
|
+
}
|
|
162
|
+
function Le(e, t, n, r) {
|
|
163
163
|
const i = r.createElement("div");
|
|
164
|
-
i.className = `${
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
return i.appendChild(
|
|
164
|
+
i.className = `${C("comp", n)} mr-kind-${e.kind}`;
|
|
165
|
+
const s = x("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");
|
|
166
|
+
if (lt(s, e, t), s.applyTo(i), Q(e))
|
|
167
|
+
return i.appendChild(gt(e, n, r)), i;
|
|
168
168
|
if (e.kind === "text")
|
|
169
|
-
return i.appendChild(
|
|
169
|
+
return i.appendChild(ht(e, t, n, r)), i;
|
|
170
170
|
if (e.grid) {
|
|
171
|
-
const
|
|
172
|
-
return
|
|
171
|
+
const o = Me(e, t, n, r);
|
|
172
|
+
return o.appendChild(ut(e.grid, e, t, n, r)), i.appendChild(o), i;
|
|
173
173
|
}
|
|
174
174
|
if (e.kind === "line" && e.lineDirection)
|
|
175
|
-
return i.appendChild(
|
|
175
|
+
return i.appendChild(pt(e, t, r)), i;
|
|
176
176
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
177
|
-
return i.appendChild(
|
|
178
|
-
const
|
|
179
|
-
return
|
|
177
|
+
return i.appendChild(Me(e, t, n, r)), i;
|
|
178
|
+
const l = r.createElement("div");
|
|
179
|
+
return l.className = C("unknown", n), x("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), i.appendChild(l), i;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function wt(e, t, n, r) {
|
|
182
182
|
const i = r.createElement("div");
|
|
183
|
-
return i.className =
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
return i.className = C("page", n), x("block", "initial").add("position", "relative").add("font-family", ee).add("font-size", `${H(j(void 0, t).fontSizePx, 2)}px`).add("line-height", String(te(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((s, l) => {
|
|
184
|
+
const o = Le(s, t, n, r);
|
|
185
|
+
o.dataset.mrComponentIndex = String(l), i.appendChild(o);
|
|
186
186
|
}), i;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function On(e, t, n = {}) {
|
|
189
189
|
const r = n.dpi ?? 96;
|
|
190
|
-
|
|
190
|
+
V(e, "dom", n);
|
|
191
191
|
const i = t.createElement("div");
|
|
192
|
-
return i.className =
|
|
193
|
-
i.appendChild(
|
|
192
|
+
return i.className = C("root", n), x("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((s) => {
|
|
193
|
+
i.appendChild(wt(s, r, n, t));
|
|
194
194
|
}), i;
|
|
195
195
|
}
|
|
196
196
|
function A(e) {
|
|
197
197
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
198
198
|
}
|
|
199
|
-
const
|
|
200
|
-
const i = new Image(),
|
|
201
|
-
i.onload = null, i.onerror = null, t?.removeEventListener("abort",
|
|
202
|
-
},
|
|
203
|
-
|
|
199
|
+
const bt = (e, t) => (A(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
200
|
+
const i = new Image(), s = () => {
|
|
201
|
+
i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
|
|
202
|
+
}, l = () => {
|
|
203
|
+
s(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
204
204
|
};
|
|
205
205
|
i.onload = () => {
|
|
206
|
-
|
|
206
|
+
s(), n(i);
|
|
207
207
|
}, i.onerror = () => {
|
|
208
|
-
|
|
209
|
-
}, t?.addEventListener("abort",
|
|
208
|
+
s(), r(new Error("Image could not be decoded for Canvas output."));
|
|
209
|
+
}, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
|
|
210
210
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
211
|
-
function
|
|
211
|
+
function vt(e, t, n) {
|
|
212
212
|
return A(n), n ? new Promise((r, i) => {
|
|
213
|
-
const
|
|
214
|
-
n.addEventListener("abort",
|
|
213
|
+
const s = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
214
|
+
n.addEventListener("abort", s, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", s));
|
|
215
215
|
}) : e(t);
|
|
216
216
|
}
|
|
217
|
-
async function
|
|
217
|
+
async function yt(e, t, n) {
|
|
218
218
|
const r = /* @__PURE__ */ new Map();
|
|
219
219
|
for (const i of e.components)
|
|
220
|
-
!
|
|
220
|
+
!Q(i) || r.has(i.imageData) || r.set(i.imageData, await vt(t, i.imageData, n));
|
|
221
221
|
return A(n), r;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const c = Math.min(i /
|
|
227
|
-
e.drawImage(t, n + (i - d) / 2, r + (
|
|
223
|
+
function xt(e, t, n, r, i, s) {
|
|
224
|
+
const l = t, o = l.naturalWidth ?? l.width ?? i, a = l.naturalHeight ?? l.height ?? s;
|
|
225
|
+
if (o <= 0 || a <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
226
|
+
const c = Math.min(i / o, s / a), d = o * c, u = a * c;
|
|
227
|
+
e.drawImage(t, n + (i - d) / 2, r + (s - u) / 2, d, u);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
return
|
|
229
|
+
function Mt(e) {
|
|
230
|
+
return rt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
231
231
|
}
|
|
232
|
-
const
|
|
233
|
-
function
|
|
234
|
-
const n = t / 96 *
|
|
232
|
+
const de = 96 / 25.4;
|
|
233
|
+
function ue(e, t = 96) {
|
|
234
|
+
const n = t / 96 * de;
|
|
235
235
|
return {
|
|
236
236
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
237
237
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function ze(e, t, n, r = 64e6) {
|
|
241
241
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
242
242
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
243
|
-
const i =
|
|
244
|
-
if (!Number.isSafeInteger(
|
|
245
|
-
return { width:
|
|
246
|
-
}
|
|
247
|
-
function
|
|
248
|
-
const i = document.createElement("canvas"), { widthPx:
|
|
249
|
-
i.width =
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
243
|
+
const i = ue(e, n), s = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
|
|
244
|
+
if (!Number.isSafeInteger(s) || !Number.isSafeInteger(l) || s * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
245
|
+
return { width: s, height: l };
|
|
246
|
+
}
|
|
247
|
+
function He(e, t, n, r) {
|
|
248
|
+
const i = document.createElement("canvas"), { widthPx: s, heightPx: l } = ue(e, n), o = ze(e, t, n, r);
|
|
249
|
+
i.width = o.width, i.height = o.height, i.style.width = `${s}px`, i.style.height = `${l}px`;
|
|
250
|
+
const a = i.getContext("2d");
|
|
251
|
+
if (!a)
|
|
252
252
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
253
|
-
return
|
|
253
|
+
return a.scale(t, t), a.fillStyle = "#ffffff", a.fillRect(0, 0, s, l), { canvas: i, ctx: a };
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function Dn(e, t = 96) {
|
|
256
|
+
return j(e, t).fontSizePx;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${
|
|
260
|
-
const
|
|
261
|
-
`), d = c.length *
|
|
258
|
+
function je(e, t, n, r, i, s, l, o = "top") {
|
|
259
|
+
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";
|
|
260
|
+
const a = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
261
|
+
`), d = c.length * a;
|
|
262
262
|
let u = r;
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
o === "middle" ? u = r + (s - d) / 2 : o === "bottom" && (u = r + s - d), c.forEach((m, f) => {
|
|
264
|
+
Et(e, m, t, n, u + f * a + t.fontSizePx * 0.8, i);
|
|
265
265
|
}), e.textAlign = "left";
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
const
|
|
269
|
-
if (!
|
|
267
|
+
function Et(e, t, n, r, i, s) {
|
|
268
|
+
const l = Array.from(t), o = n.letterSpacingPx ?? 0;
|
|
269
|
+
if (!o) {
|
|
270
270
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
271
|
-
const u = n.align === "center" ? r +
|
|
271
|
+
const u = n.align === "center" ? r + s / 2 : n.align === "right" ? r + s : r;
|
|
272
272
|
e.fillText(t, u, i);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const a = e.measureText(t).width + Math.max(0, l.length - 1) * o, c = n.align === "center" ? r + (s - a) / 2 : n.align === "right" ? r + s - a : r;
|
|
276
276
|
e.textAlign = "left";
|
|
277
277
|
let d = "";
|
|
278
|
-
|
|
279
|
-
e.fillText(u, c + e.measureText(d).width + m *
|
|
278
|
+
l.forEach((u, m) => {
|
|
279
|
+
e.fillText(u, c + e.measureText(d).width + m * o, i), d += u;
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
for (const
|
|
284
|
-
e.strokeStyle =
|
|
282
|
+
function St(e, t, n, r, i, s, l) {
|
|
283
|
+
for (const o of Fe(t, n))
|
|
284
|
+
e.strokeStyle = o.color, e.lineWidth = L(o.widthPt, l), e.beginPath(), o.kind === "v" ? (e.moveTo(r + o.pos * s, i + o.from * s), e.lineTo(r + o.pos * s, i + o.to * s)) : (e.moveTo(r + o.from * s, i + o.pos * s), e.lineTo(r + o.to * s, i + o.pos * s)), e.stroke();
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
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 +
|
|
286
|
+
function Tt(e, t, n, r, i, s) {
|
|
287
|
+
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 + s)), t.bottom && (e.moveTo(n + i, r + s), e.lineTo(n, r + s)), t.left && (e.moveTo(n, r + s), e.lineTo(n, r)), e.stroke();
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
const u =
|
|
289
|
+
function Ct(e, t, n, r, i, s, l, o, a, c, d) {
|
|
290
|
+
const u = K(t, s / o, l / o);
|
|
291
291
|
for (const f of u.cells) {
|
|
292
|
-
const
|
|
293
|
-
|
|
292
|
+
const h = f.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
293
|
+
h && (e.fillStyle = h, e.fillRect(r + f.xMm * o, i + f.yMm * o, f.widthMm * o, f.heightMm * o));
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
St(e, u, n, r, i, o, a);
|
|
296
296
|
const m = t.paddingMm ?? 0.5;
|
|
297
297
|
for (const f of u.cells) {
|
|
298
|
-
const
|
|
299
|
-
if (!
|
|
300
|
-
const
|
|
298
|
+
const h = f.cell.text ?? "";
|
|
299
|
+
if (!h) continue;
|
|
300
|
+
const g = ke(n.style, f.cell.style), b = j(g, a), E = Math.max(0, f.widthMm - 2 * m), S = Ne(h, E, { fontSizePt: b.fontSizePt, bold: g.bold, italic: g.italic, fontFamily: g.fontFamily ?? c, letterSpacingPt: g.letterSpacing }, d).join(`
|
|
301
301
|
`);
|
|
302
|
-
|
|
302
|
+
je(
|
|
303
303
|
e,
|
|
304
304
|
{
|
|
305
|
-
text:
|
|
306
|
-
fontSizePx:
|
|
307
|
-
bold:
|
|
308
|
-
italic:
|
|
309
|
-
color:
|
|
310
|
-
align:
|
|
311
|
-
lineHeight:
|
|
312
|
-
letterSpacingPx:
|
|
305
|
+
text: S,
|
|
306
|
+
fontSizePx: b.fontSizePx,
|
|
307
|
+
bold: g.bold ?? !1,
|
|
308
|
+
italic: g.italic,
|
|
309
|
+
color: $e(g, Pe),
|
|
310
|
+
align: g.align ?? "left",
|
|
311
|
+
lineHeight: te(g),
|
|
312
|
+
letterSpacingPx: L(g.letterSpacing ?? 0, a)
|
|
313
313
|
},
|
|
314
|
-
r + (f.xMm + m) *
|
|
315
|
-
i + (f.yMm + m) *
|
|
316
|
-
|
|
317
|
-
Math.max(0, f.heightMm - 2 * m) *
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
r + (f.xMm + m) * o,
|
|
315
|
+
i + (f.yMm + m) * o,
|
|
316
|
+
E * o,
|
|
317
|
+
Math.max(0, f.heightMm - 2 * m) * o,
|
|
318
|
+
g.fontFamily ?? c,
|
|
319
|
+
g.verticalAlign ?? "middle"
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
const c = t.style ?? {}, d =
|
|
323
|
+
function It(e, t, n, r, i, s, l, o, a) {
|
|
324
|
+
const c = t.style ?? {}, d = j(c, l), u = Re(t) ? t.richParagraphs.map((m) => m.segments.map((f) => f.text ?? f.field ?? "").join("")).join(`
|
|
325
325
|
`) : t.lines?.length ? t.lines.join(`
|
|
326
|
-
`) :
|
|
326
|
+
`) : Ne(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? o, letterSpacingPt: c.letterSpacing }, a).join(`
|
|
327
327
|
`);
|
|
328
|
-
|
|
328
|
+
je(e, {
|
|
329
329
|
text: u,
|
|
330
330
|
fontSizePx: d.fontSizePx,
|
|
331
331
|
bold: c.bold ?? !1,
|
|
332
332
|
italic: c.italic,
|
|
333
|
-
color:
|
|
333
|
+
color: $e(c),
|
|
334
334
|
align: c.align ?? "left",
|
|
335
|
-
lineHeight:
|
|
336
|
-
letterSpacingPx:
|
|
337
|
-
}, n, r, i,
|
|
338
|
-
}
|
|
339
|
-
function
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
const m =
|
|
343
|
-
m ?
|
|
335
|
+
lineHeight: te(c),
|
|
336
|
+
letterSpacingPx: L(c.letterSpacing ?? 0, l)
|
|
337
|
+
}, n, r, i, s, c.fontFamily ?? o, c.verticalAlign);
|
|
338
|
+
}
|
|
339
|
+
function me(e, t, n, r, i, s, l) {
|
|
340
|
+
const o = t.leftMm * n, a = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, u = t.style ?? {};
|
|
341
|
+
if (Q(t)) {
|
|
342
|
+
const m = l?.get(t.imageData);
|
|
343
|
+
m ? xt(e, m, o, a, c, d) : Ee(e, t, o, a, c, d);
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
346
|
if (t.grid) {
|
|
347
|
-
|
|
347
|
+
Ct(e, t.grid, t, o, a, c, d, n, r, i, s);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
switch (t.kind) {
|
|
351
351
|
case "text": {
|
|
352
|
-
|
|
352
|
+
It(e, t, o, a, c, d, r, i, s);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
355
355
|
case "rect": {
|
|
356
|
-
const m =
|
|
357
|
-
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(
|
|
356
|
+
const m = B(u), f = Ae(u);
|
|
357
|
+
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(o, a, c, d)), f.inner && (e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), Tt(e, f, o, a, c, d));
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
case "line": {
|
|
361
|
-
const m =
|
|
362
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
363
|
-
const f = t.lineDirection === "up" ?
|
|
364
|
-
e.moveTo(
|
|
361
|
+
const m = B({ ...u, borderColor: u.lineColor ?? u.borderColor });
|
|
362
|
+
e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), e.beginPath();
|
|
363
|
+
const f = t.lineDirection === "up" ? a + d : t.lineDirection === "down" ? a : a + d / 2, h = t.lineDirection === "up" ? a : t.lineDirection === "down" ? a + d : a + d / 2;
|
|
364
|
+
e.moveTo(o, f), e.lineTo(o + c, h), e.stroke();
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
case "ellipse": {
|
|
368
|
-
const m =
|
|
369
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
368
|
+
const m = B(u);
|
|
369
|
+
e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), u.backgroundColor && (e.fillStyle = u.backgroundColor, e.beginPath(), e.ellipse(o + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(o + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
372
|
default:
|
|
373
|
-
|
|
373
|
+
Ee(e, t, o, a, c, d);
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
function
|
|
378
|
-
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i,
|
|
377
|
+
function Ee(e, t, n, r, i, s) {
|
|
378
|
+
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, s), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
380
|
+
async function Ln(e, t = {}) {
|
|
381
381
|
if (typeof document > "u")
|
|
382
382
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
383
383
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
384
384
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
385
385
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
386
386
|
A(t.signal);
|
|
387
|
-
const
|
|
388
|
-
e =
|
|
389
|
-
const
|
|
387
|
+
const s = await ce(e, { ...t, format: "canvas" });
|
|
388
|
+
e = s.plan;
|
|
389
|
+
const l = [...s.diagnostics, ...V(e, "canvas", t)], o = n === "jpeg" ? "image/jpeg" : "image/png", a = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
390
390
|
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
391
391
|
A(t.signal);
|
|
392
|
-
const u = await
|
|
392
|
+
const u = await We(e.pages[d], d, i, l);
|
|
393
393
|
try {
|
|
394
|
-
|
|
394
|
+
a.push(await Pt(u, o, r, t.signal));
|
|
395
395
|
} finally {
|
|
396
396
|
u.width = 0, u.height = 0;
|
|
397
397
|
}
|
|
398
|
+
await tt(t, a.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
398
399
|
}
|
|
399
|
-
return A(t.signal), { blobs:
|
|
400
|
+
return A(t.signal), { blobs: a, diagnostics: l };
|
|
400
401
|
}
|
|
401
|
-
function
|
|
402
|
-
return A(r), new Promise((i,
|
|
403
|
-
const
|
|
404
|
-
r?.addEventListener("abort",
|
|
402
|
+
function Pt(e, t, n, r) {
|
|
403
|
+
return A(r), new Promise((i, s) => {
|
|
404
|
+
const l = () => s(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
405
|
+
r?.addEventListener("abort", l, { once: !0 });
|
|
405
406
|
try {
|
|
406
|
-
e.toBlob((
|
|
407
|
-
r?.removeEventListener("abort",
|
|
407
|
+
e.toBlob((o) => {
|
|
408
|
+
r?.removeEventListener("abort", l), o ? i(o) : s(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
408
409
|
}, t, n);
|
|
409
|
-
} catch (
|
|
410
|
-
r?.removeEventListener("abort",
|
|
410
|
+
} catch (o) {
|
|
411
|
+
r?.removeEventListener("abort", l), s(o);
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
}
|
|
414
|
-
function
|
|
415
|
-
if (typeof document > "u")
|
|
415
|
+
function zn(e, t = {}) {
|
|
416
|
+
if (A(t.signal), typeof document > "u")
|
|
416
417
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
417
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
418
|
-
for (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
c.push(f);
|
|
418
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * de, s = t.fontFamily ?? ee, l = t.measurer ?? le, o = Math.max(0, t.start ?? 0), a = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = V(e, "canvas", t), u = Rt(e, o, a);
|
|
419
|
+
for (const m of u)
|
|
420
|
+
Oe(m, t), d.push(m);
|
|
421
|
+
if (t.fidelity === "strict" && u.length) throw new nt(d);
|
|
422
|
+
for (let m = o; m <= a; m++) {
|
|
423
|
+
A(t.signal);
|
|
424
|
+
const f = e.pages[m], { canvas: h, ctx: g } = He(f, n, r, t.maxCanvasPixels);
|
|
425
|
+
for (const b of f.components)
|
|
426
|
+
me(g, b, i, r, s, l);
|
|
427
|
+
c.push(h);
|
|
428
428
|
}
|
|
429
429
|
return { canvases: c, diagnostics: d };
|
|
430
430
|
}
|
|
431
|
-
|
|
431
|
+
function Rt(e, t, n) {
|
|
432
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((s, l) => Q(s) ? [{
|
|
433
|
+
code: "async-image-required",
|
|
434
|
+
severity: "warning",
|
|
435
|
+
format: "canvas",
|
|
436
|
+
pageIndex: t + i,
|
|
437
|
+
componentIndex: l,
|
|
438
|
+
kind: s.kind,
|
|
439
|
+
nid: s.nid,
|
|
440
|
+
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
441
|
+
}] : []));
|
|
442
|
+
}
|
|
443
|
+
async function Hn(e, t = {}) {
|
|
432
444
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
433
445
|
A(t.signal);
|
|
434
|
-
const n = await
|
|
446
|
+
const n = await ce(e, { ...t, format: "canvas" });
|
|
435
447
|
e = n.plan;
|
|
436
|
-
const r = [...n.diagnostics, ...
|
|
437
|
-
for (let
|
|
438
|
-
i.push(await
|
|
448
|
+
const r = [...n.diagnostics, ...V(e, "canvas", t)], i = [], s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
449
|
+
for (let l = Math.max(0, t.start ?? 0); l <= s; l++)
|
|
450
|
+
i.push(await We(e.pages[l], l, t, r));
|
|
439
451
|
return { canvases: i, diagnostics: r };
|
|
440
452
|
}
|
|
441
|
-
async function
|
|
442
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1),
|
|
453
|
+
async function We(e, t, n, r) {
|
|
454
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), s = n.dpi ?? 96, l = n.fontFamily ?? ee, o = await Be(e, t, n, r);
|
|
443
455
|
A(n.signal);
|
|
444
|
-
const { canvas:
|
|
445
|
-
for (const d of e.components)
|
|
446
|
-
return
|
|
456
|
+
const { canvas: a, ctx: c } = He(e, i, s, n.maxCanvasPixels);
|
|
457
|
+
for (const d of e.components) me(c, d, s / 25.4, s, l, n.measurer ?? le, o);
|
|
458
|
+
return a;
|
|
447
459
|
}
|
|
448
|
-
async function
|
|
449
|
-
const i = n.imageLoader ??
|
|
450
|
-
return
|
|
460
|
+
async function Be(e, t, n, r) {
|
|
461
|
+
const i = n.imageLoader ?? bt;
|
|
462
|
+
return yt(e, async (s, l) => {
|
|
451
463
|
try {
|
|
452
|
-
return await i(
|
|
453
|
-
} catch (
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
throw r.push(d),
|
|
464
|
+
return await i(s, l);
|
|
465
|
+
} catch (o) {
|
|
466
|
+
if (l?.aborted) throw o;
|
|
467
|
+
const a = e.components.findIndex((u) => u.imageData === s), c = e.components[a], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: a, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
468
|
+
throw r.push(d), Oe(d, n), o;
|
|
457
469
|
}
|
|
458
470
|
}, n.signal);
|
|
459
471
|
}
|
|
460
|
-
function
|
|
461
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
462
|
-
let f = null,
|
|
463
|
-
const
|
|
464
|
-
function
|
|
472
|
+
function jn(e, t = {}) {
|
|
473
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * de, s = t.fontFamily ?? ee, l = t.measurer ?? le, o = t.overscan ?? 1, a = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((p) => p.pageHeightMm * i), u = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * i)), m = { start: 0, end: -1 };
|
|
474
|
+
let f = null, h = null, g = null, b = null, E = [], S = 0, R = [], G = 0, W = new AbortController();
|
|
475
|
+
const ve = [];
|
|
476
|
+
function Ye() {
|
|
465
477
|
const p = f;
|
|
466
|
-
p.innerHTML = "",
|
|
467
|
-
const
|
|
468
|
-
for (let
|
|
469
|
-
const
|
|
470
|
-
|
|
478
|
+
p.innerHTML = "", h = document.createElement("div"), h.style.cssText = `width:${u}px;margin:0 auto;`, g = document.createElement("div"), b = document.createElement("div"), h.appendChild(g), E = [];
|
|
479
|
+
const T = Math.min(e.pages.length, 3 + o * 2);
|
|
480
|
+
for (let F = 0; F < T; F++) {
|
|
481
|
+
const y = document.createElement("div");
|
|
482
|
+
y.style.cssText = `margin:0 auto ${a}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, h.appendChild(y), E.push(y);
|
|
471
483
|
}
|
|
472
|
-
|
|
484
|
+
h.appendChild(b), p.appendChild(h);
|
|
473
485
|
}
|
|
474
|
-
async function
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
const { widthPx:
|
|
480
|
-
let
|
|
481
|
-
(!
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
|
|
487
|
-
for (const
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
async function Xe(p, T) {
|
|
487
|
+
const F = G, y = await ce(e, { ...t, signal: W.signal, format: "canvas", start: T, end: T });
|
|
488
|
+
ve.push(...y.diagnostics);
|
|
489
|
+
const I = y.plan.pages[T], J = await Be(I, T, { ...t, signal: W.signal }, ve);
|
|
490
|
+
if (F !== G || !f) return;
|
|
491
|
+
const { widthPx: ie, heightPx: oe } = ue(I, r);
|
|
492
|
+
let N = p.firstElementChild;
|
|
493
|
+
(!N || N.tagName !== "CANVAS") && (N = document.createElement("canvas"), p.innerHTML = "", p.appendChild(N));
|
|
494
|
+
const xe = ze(I, n, r, t.maxCanvasPixels);
|
|
495
|
+
N.width = xe.width, N.height = xe.height, N.style.width = `${ie}px`, N.style.height = `${oe}px`;
|
|
496
|
+
const D = N.getContext("2d");
|
|
497
|
+
if (D) {
|
|
498
|
+
D.setTransform(1, 0, 0, 1, 0, 0), D.scale(n, n), D.fillStyle = "#ffffff", D.fillRect(0, 0, ie, oe);
|
|
499
|
+
for (const Qe of I.components)
|
|
500
|
+
me(D, Qe, i, r, s, l, J);
|
|
501
|
+
N.dataset.canvasPage = String(T), p.style.height = `${oe}px`, p.style.width = `${ie}px`;
|
|
490
502
|
}
|
|
491
503
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
if (
|
|
499
|
-
|
|
500
|
-
const
|
|
501
|
-
|
|
504
|
+
function Ze(p) {
|
|
505
|
+
G++, m.start = p.start, m.end = p.end, g.style.height = `${p.start * a + d.slice(0, p.start).reduce((y, I) => y + I, 0)}px`;
|
|
506
|
+
const T = e.pages.length - 1 - p.end;
|
|
507
|
+
b.style.height = `${T * a + d.slice(p.end + 1).reduce((y, I) => y + I, 0)}px`;
|
|
508
|
+
const F = p.end - p.start + 1;
|
|
509
|
+
E.forEach((y, I) => {
|
|
510
|
+
if (I < F) {
|
|
511
|
+
y.style.display = "";
|
|
512
|
+
const J = p.start + I;
|
|
513
|
+
y.style.height = `${d[J] ?? 0}px`;
|
|
502
514
|
} else
|
|
503
|
-
|
|
504
|
-
}),
|
|
505
|
-
for (let
|
|
506
|
-
const
|
|
507
|
-
if (!
|
|
508
|
-
|
|
515
|
+
y.style.display = "none";
|
|
516
|
+
}), R = [];
|
|
517
|
+
for (let y = p.start; y <= p.end; y++) {
|
|
518
|
+
const I = E[y - p.start];
|
|
519
|
+
if (!I) continue;
|
|
520
|
+
I.firstElementChild?.dataset?.canvasPage !== String(y) && R.push(y);
|
|
509
521
|
}
|
|
510
|
-
|
|
522
|
+
re();
|
|
511
523
|
}
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
524
|
+
function re() {
|
|
525
|
+
S || R.length === 0 || (S = requestAnimationFrame(() => {
|
|
526
|
+
S = 0;
|
|
515
527
|
let p = Math.max(1, c);
|
|
516
|
-
for (;
|
|
517
|
-
const
|
|
518
|
-
|
|
528
|
+
for (; R.length > 0 && p-- > 0; ) {
|
|
529
|
+
const T = R.shift(), F = E[T - m.start];
|
|
530
|
+
F && Xe(F, T).catch(() => {
|
|
519
531
|
});
|
|
520
532
|
}
|
|
521
|
-
|
|
533
|
+
R.length > 0 && re();
|
|
522
534
|
}));
|
|
523
535
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const p = f,
|
|
536
|
+
function U() {
|
|
537
|
+
S || (S = requestAnimationFrame(() => {
|
|
538
|
+
S = 0;
|
|
539
|
+
const p = f, T = Mt({
|
|
528
540
|
pageHeightsPx: d,
|
|
529
541
|
viewportHeightPx: p.clientHeight,
|
|
530
542
|
scrollTopPx: p.scrollTop,
|
|
531
|
-
overscan:
|
|
532
|
-
gapPx:
|
|
543
|
+
overscan: o,
|
|
544
|
+
gapPx: a
|
|
533
545
|
});
|
|
534
|
-
|
|
546
|
+
T.start !== m.start || T.end !== m.end ? Ze(T) : re();
|
|
535
547
|
}));
|
|
536
548
|
}
|
|
537
|
-
let
|
|
549
|
+
let q = null;
|
|
538
550
|
return {
|
|
539
551
|
attach(p) {
|
|
540
552
|
if (typeof document > "u")
|
|
541
553
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
542
|
-
A(t.signal),
|
|
554
|
+
A(t.signal), W = new AbortController(), t.signal?.addEventListener("abort", ye, { once: !0 }), V(e, "canvas", t), f = p, Ye(), p.addEventListener("scroll", U, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => U()), q.observe(p)), U();
|
|
543
555
|
},
|
|
544
556
|
destroy() {
|
|
545
|
-
|
|
557
|
+
G++, W.abort(), t.signal?.removeEventListener("abort", ye), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, f?.removeEventListener("scroll", U), R = [], h?.remove(), f = null;
|
|
546
558
|
},
|
|
547
559
|
window() {
|
|
548
560
|
return { ...m };
|
|
549
561
|
}
|
|
550
562
|
};
|
|
551
|
-
function
|
|
552
|
-
|
|
563
|
+
function ye() {
|
|
564
|
+
W.abort(t.signal?.reason);
|
|
553
565
|
}
|
|
554
566
|
}
|
|
555
|
-
function
|
|
567
|
+
function _e(e, t, n) {
|
|
556
568
|
let r, i;
|
|
557
569
|
if (typeof e == "string") {
|
|
558
|
-
const
|
|
559
|
-
if (!
|
|
560
|
-
r =
|
|
570
|
+
const s = Y[e];
|
|
571
|
+
if (!s) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Y).join("/")})`);
|
|
572
|
+
r = s.widthMm, i = s.heightMm;
|
|
561
573
|
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
562
574
|
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
563
575
|
}
|
|
564
|
-
class
|
|
576
|
+
class At {
|
|
565
577
|
constructor() {
|
|
566
578
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
567
579
|
}
|
|
@@ -590,18 +602,18 @@ class wt {
|
|
|
590
602
|
*/
|
|
591
603
|
page(t = "a4", n = {}, r) {
|
|
592
604
|
this.collect();
|
|
593
|
-
const
|
|
605
|
+
const s = 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: o } = _e(
|
|
594
606
|
t,
|
|
595
607
|
typeof n == "number" ? n : void 0,
|
|
596
|
-
|
|
597
|
-
),
|
|
598
|
-
return this.pending = new
|
|
599
|
-
widthMm:
|
|
600
|
-
heightMm:
|
|
601
|
-
marginTopMm:
|
|
602
|
-
marginBottomMm:
|
|
603
|
-
marginLeftMm:
|
|
604
|
-
marginRightMm:
|
|
608
|
+
s.landscape
|
|
609
|
+
), a = s.margins ?? {};
|
|
610
|
+
return this.pending = new kt(this, {
|
|
611
|
+
widthMm: l,
|
|
612
|
+
heightMm: o,
|
|
613
|
+
marginTopMm: a.marginTopMm ?? 10,
|
|
614
|
+
marginBottomMm: a.marginBottomMm ?? 10,
|
|
615
|
+
marginLeftMm: a.marginLeftMm ?? 10,
|
|
616
|
+
marginRightMm: a.marginRightMm ?? 10
|
|
605
617
|
}), this.pending;
|
|
606
618
|
}
|
|
607
619
|
collect() {
|
|
@@ -613,7 +625,7 @@ class wt {
|
|
|
613
625
|
return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
|
|
614
626
|
}
|
|
615
627
|
}
|
|
616
|
-
class
|
|
628
|
+
class kt {
|
|
617
629
|
constructor(t, n) {
|
|
618
630
|
this.parent = t, this.page = n, this.components = [];
|
|
619
631
|
}
|
|
@@ -682,11 +694,11 @@ class bt {
|
|
|
682
694
|
return this.done().build();
|
|
683
695
|
}
|
|
684
696
|
}
|
|
685
|
-
function
|
|
686
|
-
return new
|
|
697
|
+
function Wn() {
|
|
698
|
+
return new At();
|
|
687
699
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
700
|
+
function Bn(e, t = {}) {
|
|
701
|
+
return et([], e), e.fields.map((n) => ({
|
|
690
702
|
field: n.field,
|
|
691
703
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
692
704
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
@@ -697,11 +709,11 @@ function k(e, t, n = !1) {
|
|
|
697
709
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
698
710
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
699
711
|
}
|
|
700
|
-
function
|
|
712
|
+
function X(e, t, n) {
|
|
701
713
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
702
714
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
703
715
|
}
|
|
704
|
-
function
|
|
716
|
+
function $t(e) {
|
|
705
717
|
const t = e.layout ?? "page";
|
|
706
718
|
if (t !== "page" && t !== "wide")
|
|
707
719
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -712,16 +724,16 @@ function vt(e) {
|
|
|
712
724
|
const n = e.columnWidthMm ?? 30;
|
|
713
725
|
return k(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
714
726
|
}
|
|
715
|
-
function
|
|
727
|
+
function Nt(e) {
|
|
716
728
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
717
729
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
718
730
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
719
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
720
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
721
|
-
const n =
|
|
731
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Y, t))
|
|
732
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Y).join("/")})`);
|
|
733
|
+
const n = _e(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
722
734
|
return k(r, "纸张 widthMm"), k(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
723
735
|
}
|
|
724
|
-
function
|
|
736
|
+
function Ft(e) {
|
|
725
737
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
726
738
|
throw new Error("margins 必须是页边距对象");
|
|
727
739
|
const t = e.margins ?? {}, n = {
|
|
@@ -733,7 +745,7 @@ function Mt(e) {
|
|
|
733
745
|
for (const [r, i] of Object.entries(n)) k(i, r, !0);
|
|
734
746
|
return n;
|
|
735
747
|
}
|
|
736
|
-
function
|
|
748
|
+
function Ot(e, t) {
|
|
737
749
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
738
750
|
if (typeof n != "string" || !n.trim())
|
|
739
751
|
throw new Error("dataset 必须是非空字符串");
|
|
@@ -741,68 +753,68 @@ function xt(e, t) {
|
|
|
741
753
|
throw new Error("title 必须是字符串");
|
|
742
754
|
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
743
755
|
k(r, "titleHeightMm"), k(i, "titleGapMm", !0);
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
756
|
+
const s = e.title !== void 0 && e.title.length > 0, l = s ? r + i : 0;
|
|
757
|
+
if (l >= t)
|
|
746
758
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
747
|
-
return { dataset: n, titleHeightMm: r, hasTitle:
|
|
759
|
+
return { dataset: n, titleHeightMm: r, hasTitle: s, titleSpaceMm: l };
|
|
748
760
|
}
|
|
749
|
-
function
|
|
761
|
+
function Dt(e) {
|
|
750
762
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
751
763
|
throw new Error("listOptions 必须是列表配置对象");
|
|
752
764
|
const t = e.listOptions ?? {};
|
|
753
|
-
|
|
765
|
+
X(t.align, "listOptions.align", !0), X(t.headerAlign, "listOptions.headerAlign", !1);
|
|
754
766
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
755
767
|
const r = t[n];
|
|
756
768
|
r !== void 0 && k(r, `listOptions.${n}`, n === "paddingMm");
|
|
757
769
|
}
|
|
758
770
|
return t;
|
|
759
771
|
}
|
|
760
|
-
function
|
|
772
|
+
function Lt(e) {
|
|
761
773
|
let t = 0, n = 0;
|
|
762
774
|
for (const [r, i] of e.entries()) {
|
|
763
775
|
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
764
776
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
765
|
-
|
|
777
|
+
X(i.align, `columns[${r}].align`, !0), X(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && k(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (k(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
766
778
|
}
|
|
767
779
|
return { fixedWidthMm: t, maxFlex: n };
|
|
768
780
|
}
|
|
769
|
-
function
|
|
770
|
-
const { fixedWidthMm: i, maxFlex:
|
|
781
|
+
function zt(e, t, n, r) {
|
|
782
|
+
const { fixedWidthMm: i, maxFlex: s } = Lt(e.columns);
|
|
771
783
|
if (t === "page" && i > r)
|
|
772
784
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
773
|
-
const
|
|
774
|
-
if (t === "page" &&
|
|
785
|
+
const l = r - i;
|
|
786
|
+
if (t === "page" && s > 0 && l <= 0)
|
|
775
787
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
776
|
-
const
|
|
788
|
+
const o = s > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / s : 0), 0) : 0;
|
|
777
789
|
return { columns: e.columns.map(({ widthMm: c, flex: d, ...u }, m) => {
|
|
778
|
-
const f = c ?? (t === "wide" ? n * (d ?? 1) :
|
|
790
|
+
const f = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / s) / o);
|
|
779
791
|
return k(f, `columns[${m}] 分配后的 widthMm`), { ...u, widthMm: f };
|
|
780
|
-
}), fixedWidthMm: i, maxFlex:
|
|
792
|
+
}), fixedWidthMm: i, maxFlex: s };
|
|
781
793
|
}
|
|
782
|
-
function
|
|
794
|
+
function _n(e) {
|
|
783
795
|
if (!e || typeof e != "object")
|
|
784
796
|
throw new Error("标准明细模板需要 options 对象");
|
|
785
797
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
786
798
|
throw new Error("columns 至少需要一列");
|
|
787
|
-
const { layout: t, columnWidthMm: n } =
|
|
799
|
+
const { layout: t, columnWidthMm: n } = $t(e), r = Nt(e);
|
|
788
800
|
let i = r.widthMm;
|
|
789
|
-
const
|
|
790
|
-
let
|
|
791
|
-
const
|
|
792
|
-
if (t === "page" &&
|
|
801
|
+
const s = r.heightMm, l = Ft(e);
|
|
802
|
+
let o = i - l.marginLeftMm - l.marginRightMm;
|
|
803
|
+
const a = s - l.marginTopMm - l.marginBottomMm;
|
|
804
|
+
if (t === "page" && o <= 0 || a <= 0)
|
|
793
805
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
794
|
-
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } =
|
|
795
|
-
t === "wide" && (
|
|
796
|
-
const
|
|
797
|
-
return u &&
|
|
806
|
+
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } = Ot(e, a), f = Dt(e), { columns: h, fixedWidthMm: g, maxFlex: b } = zt(e, t, n, o);
|
|
807
|
+
t === "wide" && (o = h.reduce((S, R) => S + R.widthMm, 0), k(o, "宽表总列宽"), i = o + l.marginLeftMm + l.marginRightMm, k(i, "宽表总宽度"));
|
|
808
|
+
const E = { widthMm: i, heightMm: s, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
809
|
+
return u && E.components.push({
|
|
798
810
|
kind: "text",
|
|
799
811
|
text: e.title,
|
|
800
|
-
leftMm:
|
|
801
|
-
topMm:
|
|
802
|
-
widthMm:
|
|
812
|
+
leftMm: l.marginLeftMm,
|
|
813
|
+
topMm: l.marginTopMm,
|
|
814
|
+
widthMm: o,
|
|
803
815
|
heightMm: d,
|
|
804
816
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
805
|
-
}),
|
|
817
|
+
}), E.components.push({
|
|
806
818
|
align: "auto",
|
|
807
819
|
headerAlign: "center",
|
|
808
820
|
...f,
|
|
@@ -810,142 +822,142 @@ function sn(e) {
|
|
|
810
822
|
...t === "wide" ? { layout: t } : {},
|
|
811
823
|
...u ? { title: e.title } : {},
|
|
812
824
|
dataset: c,
|
|
813
|
-
columns:
|
|
814
|
-
leftMm:
|
|
815
|
-
topMm:
|
|
816
|
-
widthMm: t === "wide" ||
|
|
817
|
-
}), e.params === void 0 ? { pages: [
|
|
825
|
+
columns: h,
|
|
826
|
+
leftMm: l.marginLeftMm,
|
|
827
|
+
topMm: l.marginTopMm + m,
|
|
828
|
+
widthMm: t === "wide" || b > 0 ? o : g
|
|
829
|
+
}), e.params === void 0 ? { pages: [E] } : { params: e.params, pages: [E] };
|
|
818
830
|
}
|
|
819
|
-
function
|
|
831
|
+
function Kn(e) {
|
|
820
832
|
return e;
|
|
821
833
|
}
|
|
822
|
-
class
|
|
834
|
+
class O extends Error {
|
|
823
835
|
constructor(t, n) {
|
|
824
836
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
825
837
|
}
|
|
826
838
|
}
|
|
827
|
-
function
|
|
839
|
+
function $(e) {
|
|
828
840
|
return JSON.parse(JSON.stringify(e));
|
|
829
841
|
}
|
|
830
|
-
function
|
|
842
|
+
function P(e) {
|
|
831
843
|
if (!e?.aborted) return;
|
|
832
844
|
const t = new Error("模板操作已取消");
|
|
833
845
|
throw t.name = "AbortError", t;
|
|
834
846
|
}
|
|
835
|
-
function
|
|
847
|
+
function Se(e) {
|
|
836
848
|
const t = e ? Number(e.revision) : 0;
|
|
837
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
849
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new O("history", "修订号无效或已达上限");
|
|
838
850
|
return String(t + 1);
|
|
839
851
|
}
|
|
840
|
-
function
|
|
841
|
-
const n = async (
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
return
|
|
845
|
-
}, r = async (
|
|
846
|
-
const
|
|
847
|
-
if ((
|
|
848
|
-
return
|
|
849
|
-
}, i = async (o, a
|
|
850
|
-
if (
|
|
851
|
-
return
|
|
852
|
-
},
|
|
853
|
-
const d =
|
|
854
|
-
return c !== void 0 && (m.restoredFrom = c), i({ id:
|
|
852
|
+
function Vn(e, t = {}) {
|
|
853
|
+
const n = async (l, o) => {
|
|
854
|
+
P(o);
|
|
855
|
+
const a = await e.read(l, o);
|
|
856
|
+
return P(o), a ? $(a) : void 0;
|
|
857
|
+
}, r = async (l, o) => {
|
|
858
|
+
const a = await n(l, o.signal);
|
|
859
|
+
if ((a?.revision ?? null) !== o.expectedRevision) throw new O("conflict", "模板已变化,请重新读取后提交");
|
|
860
|
+
return a;
|
|
861
|
+
}, i = async (l, o, a) => {
|
|
862
|
+
if (P(o.signal), !await e.compareAndSwap(l.id, o.expectedRevision, $(l), { signal: o.signal, ...a ? { publication: $(a) } : {} })) throw new O("conflict", "模板已被其他请求更新");
|
|
863
|
+
return $(l);
|
|
864
|
+
}, s = (l, o, a, c) => {
|
|
865
|
+
const d = Se(l), u = ae({ ...o, revision: d }), m = { revision: d, document: u, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
866
|
+
return c !== void 0 && (m.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: u }, a, m);
|
|
855
867
|
};
|
|
856
868
|
return {
|
|
857
|
-
list: async (
|
|
858
|
-
|
|
859
|
-
const
|
|
860
|
-
return
|
|
869
|
+
list: async (l) => {
|
|
870
|
+
P(l);
|
|
871
|
+
const o = await e.list(l);
|
|
872
|
+
return P(l), $(o);
|
|
861
873
|
},
|
|
862
|
-
get: async (
|
|
863
|
-
const
|
|
864
|
-
return c ?
|
|
874
|
+
get: async (l, o = {}) => {
|
|
875
|
+
const a = await n(l, o.signal), c = o.draft ? a?.draft : a?.published;
|
|
876
|
+
return c ? ae(c) : void 0;
|
|
865
877
|
},
|
|
866
|
-
history: async (
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
return
|
|
878
|
+
history: async (l, o) => {
|
|
879
|
+
P(o);
|
|
880
|
+
const a = await e.history(l, o);
|
|
881
|
+
return P(o), $(a);
|
|
870
882
|
},
|
|
871
|
-
saveDraft: async (
|
|
872
|
-
|
|
873
|
-
const
|
|
883
|
+
saveDraft: async (l, o) => {
|
|
884
|
+
P(o.signal);
|
|
885
|
+
const a = ae(t.migrate ? await t.migrate(l) : l), c = await r(a.id, o), d = Se(c);
|
|
874
886
|
return i({
|
|
875
|
-
id:
|
|
887
|
+
id: a.id,
|
|
876
888
|
revision: d,
|
|
877
|
-
draft: { ...
|
|
889
|
+
draft: { ...a, revision: d },
|
|
878
890
|
...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
|
|
879
|
-
},
|
|
891
|
+
}, o);
|
|
880
892
|
},
|
|
881
|
-
publish: async (
|
|
882
|
-
const
|
|
883
|
-
if (!
|
|
884
|
-
if (!
|
|
885
|
-
return
|
|
893
|
+
publish: async (l, o) => {
|
|
894
|
+
const a = await r(l, o);
|
|
895
|
+
if (!a) throw new O("missing", "模板不存在");
|
|
896
|
+
if (!a.draft) throw new O("draft", "没有可发布的草稿");
|
|
897
|
+
return s(a, a.draft, o);
|
|
886
898
|
},
|
|
887
|
-
rollback: async (o, a
|
|
888
|
-
const c = await r(
|
|
889
|
-
if (!c) throw new
|
|
890
|
-
|
|
891
|
-
const d = await e.getVersion(o, a
|
|
892
|
-
if (!d) throw new
|
|
893
|
-
return
|
|
899
|
+
rollback: async (l, o, a) => {
|
|
900
|
+
const c = await r(l, a);
|
|
901
|
+
if (!c) throw new O("missing", "模板不存在");
|
|
902
|
+
P(a.signal);
|
|
903
|
+
const d = await e.getVersion(l, o, a.signal);
|
|
904
|
+
if (!d) throw new O("history", "历史修订不存在");
|
|
905
|
+
return s(c, d.document, a, o);
|
|
894
906
|
}
|
|
895
907
|
};
|
|
896
908
|
}
|
|
897
|
-
function
|
|
909
|
+
function Gn() {
|
|
898
910
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
899
911
|
return {
|
|
900
912
|
read: async (n, r) => {
|
|
901
|
-
|
|
913
|
+
P(r);
|
|
902
914
|
const i = e.get(n);
|
|
903
|
-
return i ?
|
|
915
|
+
return i ? $(i) : void 0;
|
|
904
916
|
},
|
|
905
|
-
list: async (n) => (
|
|
906
|
-
history: async (n, r) => (
|
|
917
|
+
list: async (n) => (P(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: s }) => ({ id: r, revision: i, ...s ? { publishedRevision: s } : {} }))),
|
|
918
|
+
history: async (n, r) => (P(r), Array.from(t.get(n)?.values() ?? [], (i) => $(i))),
|
|
907
919
|
getVersion: async (n, r, i) => {
|
|
908
|
-
|
|
909
|
-
const
|
|
910
|
-
return
|
|
920
|
+
P(i);
|
|
921
|
+
const s = t.get(n)?.get(r);
|
|
922
|
+
return s ? $(s) : void 0;
|
|
911
923
|
},
|
|
912
|
-
compareAndSwap: async (n, r, i,
|
|
913
|
-
if (
|
|
914
|
-
if (i.id !== n) throw new
|
|
915
|
-
const
|
|
916
|
-
if (
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
919
|
-
|
|
924
|
+
compareAndSwap: async (n, r, i, s) => {
|
|
925
|
+
if (P(s.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
926
|
+
if (i.id !== n) throw new O("history", "状态 ID 与存储 ID 不一致");
|
|
927
|
+
const l = $(i), o = s.publication;
|
|
928
|
+
if (o) {
|
|
929
|
+
const a = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
930
|
+
if (a.has(o.revision) || o.revision !== i.revision || o.document.id !== n) throw new O("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
931
|
+
a.set(o.revision, $(o)), t.set(n, a);
|
|
920
932
|
}
|
|
921
|
-
return e.set(n,
|
|
933
|
+
return e.set(n, l), !0;
|
|
922
934
|
}
|
|
923
935
|
};
|
|
924
936
|
}
|
|
925
|
-
function
|
|
937
|
+
function Ke(e) {
|
|
926
938
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
927
939
|
}
|
|
928
|
-
function
|
|
940
|
+
function Ve(e, t, n) {
|
|
929
941
|
const r = e.grid;
|
|
930
942
|
if (!r) return null;
|
|
931
943
|
const i = r.cells[t];
|
|
932
944
|
if (!i) return null;
|
|
933
|
-
const
|
|
934
|
-
return
|
|
945
|
+
const l = K(r, e.widthMm, e.heightMm).cells.filter((a) => a.ri === t).findIndex((a) => a.ci === n), o = i[l];
|
|
946
|
+
return o ? { cell: o, sourceColumnIndex: l } : null;
|
|
935
947
|
}
|
|
936
|
-
function
|
|
948
|
+
function Ht(e) {
|
|
937
949
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
938
950
|
}
|
|
939
|
-
function
|
|
951
|
+
function jt(e, t) {
|
|
940
952
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
941
953
|
}
|
|
942
|
-
function
|
|
954
|
+
function Wt(e, t) {
|
|
943
955
|
if (e.editable === !1) return "cell";
|
|
944
956
|
if (e.formula !== void 0) return "formula";
|
|
945
957
|
if (e.children?.length) return "complex";
|
|
946
958
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
947
959
|
}
|
|
948
|
-
function
|
|
960
|
+
function Bt(e, t) {
|
|
949
961
|
const n = e.table;
|
|
950
962
|
if (n)
|
|
951
963
|
return {
|
|
@@ -955,53 +967,53 @@ function Rt(e, t) {
|
|
|
955
967
|
columnKey: n.columnKeys[t.columnIndex]
|
|
956
968
|
};
|
|
957
969
|
}
|
|
958
|
-
function
|
|
970
|
+
function _t(e, t, n) {
|
|
959
971
|
if (e.source) return { ...e.source };
|
|
960
972
|
const r = t.table?.source, i = t.table?.columnKeys[n.columnIndex];
|
|
961
973
|
if (!(!r || r.rowKey === void 0 || i === void 0))
|
|
962
974
|
return { ...r, rowKey: r.rowKey, field: i };
|
|
963
975
|
}
|
|
964
|
-
function
|
|
965
|
-
const r =
|
|
976
|
+
function Ge(e, t, n) {
|
|
977
|
+
const r = Ht(n), i = Wt(n, e);
|
|
966
978
|
return {
|
|
967
979
|
address: { ...t },
|
|
968
980
|
cell: n,
|
|
969
981
|
component: e,
|
|
970
982
|
value: r,
|
|
971
|
-
valueType:
|
|
972
|
-
table:
|
|
973
|
-
source:
|
|
983
|
+
valueType: jt(n, r),
|
|
984
|
+
table: Bt(e, t),
|
|
985
|
+
source: _t(n, e, t),
|
|
974
986
|
editable: i === void 0,
|
|
975
987
|
readOnlyReason: i
|
|
976
988
|
};
|
|
977
989
|
}
|
|
978
|
-
function
|
|
979
|
-
if (!
|
|
990
|
+
function fe(e, t) {
|
|
991
|
+
if (!Ke(t)) return null;
|
|
980
992
|
const n = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
981
993
|
if (!n) return null;
|
|
982
|
-
const r =
|
|
983
|
-
return r ?
|
|
994
|
+
const r = Ve(n, t.rowIndex, t.columnIndex);
|
|
995
|
+
return r ? Ge(n, t, r.cell) : null;
|
|
984
996
|
}
|
|
985
|
-
function
|
|
997
|
+
function he(e) {
|
|
986
998
|
const t = /* @__PURE__ */ new Map();
|
|
987
999
|
return (n) => {
|
|
988
|
-
if (!
|
|
1000
|
+
if (!Ke(n)) return null;
|
|
989
1001
|
const r = e.pages[n.pageIndex]?.components[n.componentIndex];
|
|
990
1002
|
if (!r?.grid) return null;
|
|
991
1003
|
let i = t.get(r);
|
|
992
1004
|
if (!i) {
|
|
993
|
-
const
|
|
1005
|
+
const l = /* @__PURE__ */ new Map();
|
|
994
1006
|
i = /* @__PURE__ */ new Map();
|
|
995
|
-
for (const
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
const c = r.grid.cells[
|
|
999
|
-
c && i.set(`${
|
|
1007
|
+
for (const o of K(r.grid, r.widthMm, r.heightMm).cells) {
|
|
1008
|
+
const a = l.get(o.ri) ?? 0;
|
|
1009
|
+
l.set(o.ri, a + 1);
|
|
1010
|
+
const c = r.grid.cells[o.ri]?.[a];
|
|
1011
|
+
c && i.set(`${o.ri}:${o.ci}`, c);
|
|
1000
1012
|
}
|
|
1001
1013
|
t.set(r, i);
|
|
1002
1014
|
}
|
|
1003
|
-
const
|
|
1004
|
-
return
|
|
1015
|
+
const s = i.get(`${n.rowIndex}:${n.columnIndex}`);
|
|
1016
|
+
return s ? Ge(r, n, s) : null;
|
|
1005
1017
|
};
|
|
1006
1018
|
}
|
|
1007
1019
|
class M extends Error {
|
|
@@ -1009,20 +1021,20 @@ class M extends Error {
|
|
|
1009
1021
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1010
1022
|
}
|
|
1011
1023
|
}
|
|
1012
|
-
function
|
|
1024
|
+
function Kt(e, t) {
|
|
1013
1025
|
let n = e.trim();
|
|
1014
1026
|
const r = t && n.endsWith("%");
|
|
1015
1027
|
if (r && (n = n.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n) && (n = n.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n)) throw new M("number");
|
|
1016
1028
|
return Number(n) / (r ? 100 : 1);
|
|
1017
1029
|
}
|
|
1018
|
-
function
|
|
1030
|
+
function Vt(e, t) {
|
|
1019
1031
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1020
1032
|
if (typeof e != "string" && typeof e != "number") throw new M("number");
|
|
1021
|
-
const n = typeof e == "number" ? e :
|
|
1033
|
+
const n = typeof e == "number" ? e : Kt(e, ot(t.cell.numberFormat));
|
|
1022
1034
|
if (!Number.isFinite(n) || Number.isInteger(n) && !Number.isSafeInteger(n)) throw new M("number");
|
|
1023
1035
|
return n;
|
|
1024
1036
|
}
|
|
1025
|
-
function
|
|
1037
|
+
function Gt(e) {
|
|
1026
1038
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1027
1039
|
if (typeof e == "boolean") return e;
|
|
1028
1040
|
const t = String(e).trim().toLowerCase();
|
|
@@ -1030,24 +1042,24 @@ function Nt(e) {
|
|
|
1030
1042
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1031
1043
|
throw new M("boolean");
|
|
1032
1044
|
}
|
|
1033
|
-
function
|
|
1034
|
-
return e.valueType === "number" ?
|
|
1045
|
+
function ge(e, t) {
|
|
1046
|
+
return e.valueType === "number" ? Vt(t, e) : e.valueType === "boolean" ? Gt(t) : t === null ? null : String(t);
|
|
1035
1047
|
}
|
|
1036
|
-
function
|
|
1037
|
-
const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((
|
|
1048
|
+
function Ut(e, t) {
|
|
1049
|
+
const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((s) => s.includes(n ?? ""));
|
|
1038
1050
|
return i ? i[e ? 0 : 1] : String(e);
|
|
1039
1051
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
1052
|
+
function ne(e, t) {
|
|
1053
|
+
return t === null ? "" : typeof t == "boolean" ? Ut(t, e) : typeof t == "number" ? it(t, e.cell.numberFormat) : String(t);
|
|
1042
1054
|
}
|
|
1043
|
-
function
|
|
1044
|
-
const r =
|
|
1055
|
+
function Un(e, t, n) {
|
|
1056
|
+
const r = fe(e, t);
|
|
1045
1057
|
if (!r) throw new M("missing");
|
|
1046
|
-
return
|
|
1058
|
+
return pe(r, n);
|
|
1047
1059
|
}
|
|
1048
|
-
function
|
|
1060
|
+
function pe(e, t) {
|
|
1049
1061
|
if (!e.editable) throw new M("readonly");
|
|
1050
|
-
const n =
|
|
1062
|
+
const n = ge(e, t);
|
|
1051
1063
|
return {
|
|
1052
1064
|
address: { ...e.address },
|
|
1053
1065
|
table: e.table,
|
|
@@ -1055,88 +1067,88 @@ function de(e, t) {
|
|
|
1055
1067
|
previousValue: e.value,
|
|
1056
1068
|
previousText: e.cell.text ?? "",
|
|
1057
1069
|
value: n,
|
|
1058
|
-
text:
|
|
1070
|
+
text: ne(e, n)
|
|
1059
1071
|
};
|
|
1060
1072
|
}
|
|
1061
|
-
function
|
|
1073
|
+
function qt(e, t) {
|
|
1062
1074
|
const n = e.table, r = t.table;
|
|
1063
1075
|
return !n || !r || n.columnKey === void 0 ? !1 : n.id === r.id && n.rowIndex === r.rowIndex && n.role === r.role && n.columnKey === r.columnKey;
|
|
1064
1076
|
}
|
|
1065
|
-
function
|
|
1066
|
-
const r = e.grid, { rowIndex: i, columnIndex:
|
|
1067
|
-
return
|
|
1077
|
+
function Ue(e, t, n) {
|
|
1078
|
+
const r = e.grid, { rowIndex: i, columnIndex: s } = t.address, l = Ve(e, i, s), o = [...r.cells], a = [...o[i]], c = ne(t, n.value), d = { ...l.cell, value: n.value, text: c, rawText: c };
|
|
1079
|
+
return a[l.sourceColumnIndex] = d, o[i] = a, { ...e, grid: { ...r, cells: o } };
|
|
1068
1080
|
}
|
|
1069
|
-
function
|
|
1081
|
+
function Jt(e, t) {
|
|
1070
1082
|
const n = e.table?.columnKeys, r = t.table?.columnKey;
|
|
1071
|
-
return n && r !== void 0 ? n.flatMap((i,
|
|
1083
|
+
return n && r !== void 0 ? n.flatMap((i, s) => i === r ? [s] : []) : [];
|
|
1072
1084
|
}
|
|
1073
|
-
function
|
|
1074
|
-
const
|
|
1075
|
-
if (!
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1085
|
+
function Yt(e, t, n, r, i, s) {
|
|
1086
|
+
const l = t.table, o = i.table;
|
|
1087
|
+
if (!l || !o || l.id !== o.id || l.role !== o.role || !t.grid) return t;
|
|
1088
|
+
const a = o.rowIndex - l.rowIndex;
|
|
1089
|
+
if (a < 0 || a >= t.grid.cells.length) return t;
|
|
1078
1090
|
let c = t;
|
|
1079
|
-
for (const d of
|
|
1080
|
-
const u =
|
|
1081
|
-
u?.editable &&
|
|
1091
|
+
for (const d of Jt(t, i)) {
|
|
1092
|
+
const u = fe(e, { pageIndex: n, componentIndex: r, rowIndex: a, columnIndex: d });
|
|
1093
|
+
u?.editable && qt(i, u) && (c = Ue(c, u, s));
|
|
1082
1094
|
}
|
|
1083
1095
|
return c;
|
|
1084
1096
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const
|
|
1087
|
-
return i.table?.columnKey !== void 0 ?
|
|
1097
|
+
function Xt(e, t, n, r, i, s) {
|
|
1098
|
+
const l = i.address;
|
|
1099
|
+
return i.table?.columnKey !== void 0 ? Yt(e, t, n, r, i, s) : l.pageIndex === n && l.componentIndex === r ? Ue(t, i, s) : t;
|
|
1088
1100
|
}
|
|
1089
|
-
function
|
|
1101
|
+
function qe(e, t) {
|
|
1090
1102
|
const n = t.source;
|
|
1091
1103
|
if (!n) return !1;
|
|
1092
1104
|
const r = e.source;
|
|
1093
1105
|
return !r || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((i) => !Object.is(r[i], n[i]));
|
|
1094
1106
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const n =
|
|
1107
|
+
function qn(e, t) {
|
|
1108
|
+
const n = fe(e, t.address);
|
|
1097
1109
|
if (!n) throw new M("missing");
|
|
1098
1110
|
if (!n.editable) throw new M("readonly");
|
|
1099
|
-
if (
|
|
1111
|
+
if (qe(n, t)) throw new M("conflict");
|
|
1100
1112
|
if (!Object.is(n.value, t.previousValue) || (n.cell.text ?? "") !== t.previousText) throw new M("conflict");
|
|
1101
|
-
const r =
|
|
1113
|
+
const r = ge(n, t.value), i = { ...t, value: r, text: ne(n, r) };
|
|
1102
1114
|
if (Object.is(r, n.value) && i.text === n.cell.text) return e;
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1105
|
-
return
|
|
1115
|
+
const s = e.pages.map((l, o) => {
|
|
1116
|
+
const a = l.components.map((c, d) => Xt(e, c, o, d, n, i));
|
|
1117
|
+
return a.every((c, d) => c === l.components[d]) ? l : { ...l, components: a };
|
|
1106
1118
|
});
|
|
1107
|
-
return { ...e, pages:
|
|
1119
|
+
return { ...e, pages: s };
|
|
1108
1120
|
}
|
|
1109
|
-
function
|
|
1121
|
+
function Zt(e) {
|
|
1110
1122
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1111
1123
|
}
|
|
1112
|
-
function
|
|
1124
|
+
function Te(e) {
|
|
1113
1125
|
const t = e.table;
|
|
1114
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
1126
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Zt(e.address);
|
|
1115
1127
|
}
|
|
1116
|
-
function
|
|
1128
|
+
function Qt(e, t) {
|
|
1117
1129
|
if (!t.length) return e;
|
|
1118
|
-
const n = new Map(t.map((
|
|
1119
|
-
function
|
|
1120
|
-
const u =
|
|
1121
|
-
if (!u || !i.has(`${c}:${d}`) && !r.has(
|
|
1130
|
+
const n = new Map(t.map((a) => [Te(a), a])), r = new Set(t.flatMap((a) => a.table ? [a.table.id] : [])), i = new Set(t.map((a) => `${a.address.pageIndex}:${a.address.componentIndex}`)), s = he(e);
|
|
1131
|
+
function l(a, c, d) {
|
|
1132
|
+
const u = a.grid;
|
|
1133
|
+
if (!u || !i.has(`${c}:${d}`) && !r.has(a.table?.id ?? "")) return a;
|
|
1122
1134
|
const m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1123
|
-
for (const
|
|
1124
|
-
const
|
|
1125
|
-
f.set(
|
|
1126
|
-
const
|
|
1127
|
-
if (!
|
|
1128
|
-
const
|
|
1129
|
-
Object.is(
|
|
1135
|
+
for (const h of K(u, a.widthMm, a.heightMm).cells) {
|
|
1136
|
+
const g = f.get(h.ri) ?? 0;
|
|
1137
|
+
f.set(h.ri, g + 1);
|
|
1138
|
+
const b = s({ pageIndex: c, componentIndex: d, rowIndex: h.ri, columnIndex: h.ci }), E = b && n.get(Te(b));
|
|
1139
|
+
if (!E || !b.editable) continue;
|
|
1140
|
+
const S = m.get(h.ri) ?? [...u.cells[h.ri]], R = ne(b, E.value);
|
|
1141
|
+
Object.is(b.value, E.value) && R === b.cell.text || (S[g] = { ...h.cell, value: E.value, text: R, rawText: R }, m.set(h.ri, S));
|
|
1130
1142
|
}
|
|
1131
|
-
return m.size ? { ...
|
|
1143
|
+
return m.size ? { ...a, grid: { ...u, cells: u.cells.map((h, g) => m.get(g) ?? h) } } : a;
|
|
1132
1144
|
}
|
|
1133
|
-
const
|
|
1134
|
-
const d =
|
|
1135
|
-
return d.every((u, m) => u ===
|
|
1145
|
+
const o = e.pages.map((a, c) => {
|
|
1146
|
+
const d = a.components.map((u, m) => l(u, c, m));
|
|
1147
|
+
return d.every((u, m) => u === a.components[m]) ? a : { ...a, components: d };
|
|
1136
1148
|
});
|
|
1137
|
-
return
|
|
1149
|
+
return o.every((a, c) => a === e.pages[c]) ? e : { ...e, pages: o };
|
|
1138
1150
|
}
|
|
1139
|
-
function
|
|
1151
|
+
function we(e) {
|
|
1140
1152
|
const t = e.source;
|
|
1141
1153
|
if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
|
|
1142
1154
|
const n = e.table;
|
|
@@ -1144,210 +1156,470 @@ function ue(e) {
|
|
|
1144
1156
|
const r = e.address;
|
|
1145
1157
|
return JSON.stringify([r.pageIndex, r.componentIndex, r.rowIndex, r.columnIndex]);
|
|
1146
1158
|
}
|
|
1147
|
-
function
|
|
1159
|
+
function Jn(e, t, n) {
|
|
1148
1160
|
if (typeof n != "string" || !n.trim() || !Array.isArray(t)) throw new M("missing");
|
|
1149
1161
|
if (t.length > 1e4) throw new M("limit");
|
|
1150
|
-
const r = /* @__PURE__ */ new Set(), i =
|
|
1151
|
-
const
|
|
1152
|
-
if (!
|
|
1153
|
-
const c =
|
|
1162
|
+
const r = /* @__PURE__ */ new Set(), i = he(e), s = t.map(({ address: l, value: o }) => {
|
|
1163
|
+
const a = i(l);
|
|
1164
|
+
if (!a) throw new M("missing");
|
|
1165
|
+
const c = pe(a, o), d = we(c);
|
|
1154
1166
|
if (r.has(d)) throw new M("duplicate");
|
|
1155
1167
|
return r.add(d), c;
|
|
1156
1168
|
});
|
|
1157
|
-
return { requestId: n, edits:
|
|
1169
|
+
return { requestId: n, edits: s };
|
|
1158
1170
|
}
|
|
1159
|
-
function
|
|
1171
|
+
function Yn(e, t) {
|
|
1160
1172
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1161
|
-
const n =
|
|
1162
|
-
const
|
|
1163
|
-
if (!
|
|
1164
|
-
const
|
|
1165
|
-
if (r.has(
|
|
1166
|
-
if (r.add(
|
|
1167
|
-
return
|
|
1173
|
+
const n = he(e), r = /* @__PURE__ */ new Set(), i = t.edits.map((s) => {
|
|
1174
|
+
const l = n(s.address);
|
|
1175
|
+
if (!l) throw new M("missing");
|
|
1176
|
+
const o = we(s);
|
|
1177
|
+
if (r.has(o)) throw new M("duplicate");
|
|
1178
|
+
if (r.add(o), qe(l, s) || !Object.is(l.value, s.previousValue) || (l.cell.text ?? "") !== s.previousText) throw new M("conflict");
|
|
1179
|
+
return pe(l, s.value);
|
|
1168
1180
|
});
|
|
1169
|
-
return
|
|
1181
|
+
return Qt(e, i);
|
|
1170
1182
|
}
|
|
1171
|
-
function
|
|
1183
|
+
function Xn(e) {
|
|
1172
1184
|
const t = /* @__PURE__ */ new Map();
|
|
1173
1185
|
for (const n of e) {
|
|
1174
|
-
const r =
|
|
1175
|
-
Object.is(
|
|
1186
|
+
const r = we(n), i = t.get(r), s = i ? { ...n, previousValue: i.previousValue, previousText: i.previousText } : { ...n };
|
|
1187
|
+
Object.is(s.previousValue, s.value) ? t.delete(r) : t.set(r, s);
|
|
1176
1188
|
}
|
|
1177
1189
|
return [...t.values()];
|
|
1178
1190
|
}
|
|
1179
|
-
function
|
|
1191
|
+
function Zn(e) {
|
|
1180
1192
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1181
1193
|
`);
|
|
1182
1194
|
}
|
|
1183
|
-
function
|
|
1195
|
+
function en(e, t) {
|
|
1184
1196
|
const n = e[e.length - 1];
|
|
1185
1197
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1186
1198
|
}
|
|
1187
|
-
function
|
|
1199
|
+
function Qn(e, t = 1e4) {
|
|
1188
1200
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1189
1201
|
const n = [[]];
|
|
1190
|
-
let r = "", i = !1,
|
|
1191
|
-
function
|
|
1192
|
-
if (++
|
|
1193
|
-
n[n.length - 1].push(r), r = "",
|
|
1202
|
+
let r = "", i = !1, s = !1, l = 0;
|
|
1203
|
+
function o() {
|
|
1204
|
+
if (++l > t) throw new Error("Clipboard cell limit exceeded");
|
|
1205
|
+
n[n.length - 1].push(r), r = "", s = !1;
|
|
1194
1206
|
}
|
|
1195
|
-
for (let
|
|
1196
|
-
const c = e[
|
|
1207
|
+
for (let a = 0; a < e.length; a++) {
|
|
1208
|
+
const c = e[a];
|
|
1197
1209
|
if (i) {
|
|
1198
1210
|
if (c !== '"') {
|
|
1199
1211
|
r += c;
|
|
1200
1212
|
continue;
|
|
1201
1213
|
}
|
|
1202
|
-
if (e[
|
|
1203
|
-
r += '"',
|
|
1214
|
+
if (e[a + 1] === '"') {
|
|
1215
|
+
r += '"', a++;
|
|
1204
1216
|
continue;
|
|
1205
1217
|
}
|
|
1206
|
-
i = !1,
|
|
1218
|
+
i = !1, s = !0;
|
|
1207
1219
|
continue;
|
|
1208
1220
|
}
|
|
1209
|
-
if (c === '"' && !r && !
|
|
1221
|
+
if (c === '"' && !r && !s) {
|
|
1210
1222
|
i = !0;
|
|
1211
1223
|
continue;
|
|
1212
1224
|
}
|
|
1213
1225
|
if (c === " ") {
|
|
1214
|
-
|
|
1226
|
+
o();
|
|
1215
1227
|
continue;
|
|
1216
1228
|
}
|
|
1217
1229
|
if (c === "\r" || c === `
|
|
1218
1230
|
`) {
|
|
1219
|
-
|
|
1220
|
-
` &&
|
|
1231
|
+
o(), n.push([]), c === "\r" && e[a + 1] === `
|
|
1232
|
+
` && a++;
|
|
1221
1233
|
continue;
|
|
1222
1234
|
}
|
|
1223
|
-
if (
|
|
1235
|
+
if (s) throw new Error("Invalid quoted clipboard value");
|
|
1224
1236
|
r += c;
|
|
1225
1237
|
}
|
|
1226
1238
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1227
|
-
return
|
|
1239
|
+
return o(), en(n, e), n;
|
|
1228
1240
|
}
|
|
1229
|
-
function
|
|
1241
|
+
function er(e, t, n) {
|
|
1230
1242
|
if (!n || n.revision === void 0 && n.sourceToken === void 0) return e;
|
|
1231
|
-
const r = new Set(t.edits.flatMap((
|
|
1243
|
+
const r = new Set(t.edits.flatMap((l) => l.source ? [l.source.datasetId] : []));
|
|
1232
1244
|
if (!r.size) return e;
|
|
1233
|
-
function i(
|
|
1234
|
-
return !
|
|
1245
|
+
function i(l) {
|
|
1246
|
+
return !l.datasetId || !r.has(l.datasetId) || (n.revision === void 0 || Object.is(n.revision, l.revision)) && (n.sourceToken === void 0 || n.sourceToken === l.sourceToken) ? l : { ...l, ...n.revision !== void 0 ? { revision: n.revision } : {}, ...n.sourceToken !== void 0 ? { sourceToken: n.sourceToken } : {} };
|
|
1235
1247
|
}
|
|
1236
|
-
const
|
|
1237
|
-
const
|
|
1238
|
-
const c =
|
|
1239
|
-
const
|
|
1240
|
-
if (!
|
|
1241
|
-
const
|
|
1242
|
-
return
|
|
1248
|
+
const s = e.pages.map((l) => {
|
|
1249
|
+
const o = l.components.map((a) => {
|
|
1250
|
+
const c = a.table?.source ? i(a.table.source) : void 0, d = a.table && c !== a.table.source ? { ...a.table, source: c } : a.table, u = a.grid?.cells.map((f) => {
|
|
1251
|
+
const h = f.map((g) => {
|
|
1252
|
+
if (!g?.source) return g;
|
|
1253
|
+
const b = i(g.source);
|
|
1254
|
+
return b === g.source ? g : { ...g, source: b };
|
|
1243
1255
|
});
|
|
1244
|
-
return
|
|
1245
|
-
}), m =
|
|
1246
|
-
return d !==
|
|
1256
|
+
return h.some((g, b) => g !== f[b]) ? h : f;
|
|
1257
|
+
}), m = a.grid && u?.some((f, h) => f !== a.grid.cells[h]) ? { ...a.grid, cells: u } : a.grid;
|
|
1258
|
+
return d !== a.table || m !== a.grid ? { ...a, table: d, grid: m } : a;
|
|
1247
1259
|
});
|
|
1248
|
-
return
|
|
1260
|
+
return o.some((a, c) => a !== l.components[c]) ? { ...l, components: o } : l;
|
|
1249
1261
|
});
|
|
1250
|
-
return
|
|
1262
|
+
return s.some((l, o) => l !== e.pages[o]) ? { ...e, pages: s } : e;
|
|
1263
|
+
}
|
|
1264
|
+
class tn extends Error {
|
|
1265
|
+
constructor(t, n, r) {
|
|
1266
|
+
const i = typeof n.label == "string" ? n.label : "单元格", s = {
|
|
1267
|
+
definition: `${i}的编辑器配置无效`,
|
|
1268
|
+
type: `${i}的编辑器与数据类型不一致`,
|
|
1269
|
+
required: `${i}不能为空`,
|
|
1270
|
+
min: `${i}不能小于 ${r}`,
|
|
1271
|
+
max: `${i}不能大于 ${r}`,
|
|
1272
|
+
precision: `${i}最多保留 ${r} 位小数`,
|
|
1273
|
+
length: `${i}最多允许 ${r} 个字符`,
|
|
1274
|
+
choice: `${i}请选择有效选项`,
|
|
1275
|
+
date: `${i}请输入有效日期(YYYY-MM-DD)`
|
|
1276
|
+
};
|
|
1277
|
+
super(s[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function w(e, t, n) {
|
|
1281
|
+
throw new tn(t, e, n);
|
|
1282
|
+
}
|
|
1283
|
+
function Je(e) {
|
|
1284
|
+
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1285
|
+
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1286
|
+
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1287
|
+
}
|
|
1288
|
+
function nn(e) {
|
|
1289
|
+
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1290
|
+
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1291
|
+
}
|
|
1292
|
+
function rn(e, t) {
|
|
1293
|
+
e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max), e.precision !== void 0 && nn(t) > e.precision && w(e, "precision", e.precision);
|
|
1294
|
+
}
|
|
1295
|
+
function on(e, t) {
|
|
1296
|
+
Je(t) || w(e, "date"), e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max);
|
|
1297
|
+
}
|
|
1298
|
+
function an(e) {
|
|
1299
|
+
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && w(e, "definition");
|
|
1300
|
+
}
|
|
1301
|
+
function sn(e) {
|
|
1302
|
+
[e.min, e.max].some((t) => t !== void 0 && !Je(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition");
|
|
1303
|
+
}
|
|
1304
|
+
function ln(e, t) {
|
|
1305
|
+
(!Array.isArray(t.options) || !t.options.length) && w(t, "definition");
|
|
1306
|
+
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1307
|
+
for (const i of t.options)
|
|
1308
|
+
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && w(t, "definition"), i.label !== void 0 && typeof i.label != "string" && w(t, "definition"), r.has(i.value) && w(t, "definition"), r.add(i.value);
|
|
1309
|
+
}
|
|
1310
|
+
function cn(e) {
|
|
1311
|
+
e.required !== void 0 && typeof e.required != "boolean" && w(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition");
|
|
1312
|
+
}
|
|
1313
|
+
function dn(e, t) {
|
|
1314
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && w(t ?? { type: "text" }, "definition"), cn(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && w(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && w(t, "type"), t.type === "number" && an(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && w(t, "definition"), t.type === "date" && sn(t), t.type === "enum" && ln(e, t);
|
|
1315
|
+
}
|
|
1316
|
+
function tr(e, t, n) {
|
|
1317
|
+
if (!e.editable) throw new M("readonly");
|
|
1318
|
+
n && dn(e, n);
|
|
1319
|
+
const r = ge(e, t);
|
|
1320
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && w(n, "required"), r === null || r === "" ? (n.required && w(n, "required"), r) : (n.type === "number" && rn(n, r), n.type === "date" && on(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && w(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && w(n, "choice"), r)) : r;
|
|
1321
|
+
}
|
|
1322
|
+
class v extends Error {
|
|
1323
|
+
constructor(t) {
|
|
1324
|
+
super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function z(e) {
|
|
1328
|
+
if (!e?.aborted) return;
|
|
1329
|
+
const t = new Error("Calculation cancelled");
|
|
1330
|
+
throw t.name = "AbortError", t;
|
|
1331
|
+
}
|
|
1332
|
+
async function Z(e, t = 1) {
|
|
1333
|
+
const n = Math.floor(e.scanned / 2048);
|
|
1334
|
+
if (e.scanned += t, e.scanned > e.maxScanned) throw new v("limit");
|
|
1335
|
+
z(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), z(e.signal));
|
|
1336
|
+
}
|
|
1337
|
+
function be(e) {
|
|
1338
|
+
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1339
|
+
}
|
|
1340
|
+
function Ce(e, t, n) {
|
|
1341
|
+
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((o) => Number.isSafeInteger(o) && o >= 0)) throw new v("selection");
|
|
1342
|
+
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1343
|
+
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new v("selection");
|
|
1344
|
+
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((o, a) => Math.max(o, a.length), 1);
|
|
1345
|
+
if (t.columnIndex >= i) throw new v("selection");
|
|
1346
|
+
const s = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1347
|
+
if (s && l && s.id === l.id) {
|
|
1348
|
+
const o = l.columnKeys.indexOf(s.columnKeys[t.columnIndex] ?? "");
|
|
1349
|
+
if (o < 0) throw new v("selection");
|
|
1350
|
+
return { grid: s.id, row: be(r) + t.rowIndex, column: o };
|
|
1351
|
+
}
|
|
1352
|
+
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1353
|
+
}
|
|
1354
|
+
function un(e, t, n) {
|
|
1355
|
+
const r = Ce(e, t.anchor, t.anchor), i = Ce(e, t.focus, t.anchor);
|
|
1356
|
+
if (r.grid !== i.grid) throw new v("selection");
|
|
1357
|
+
const s = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1358
|
+
if (!Number.isSafeInteger(s) || s > n) throw new v("limit");
|
|
1359
|
+
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 };
|
|
1360
|
+
}
|
|
1361
|
+
function mn(e) {
|
|
1362
|
+
if (!e) return !1;
|
|
1363
|
+
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1364
|
+
return /[ymdhs]/i.test(t);
|
|
1365
|
+
}
|
|
1366
|
+
function fn(e) {
|
|
1367
|
+
if (e.valueType === "text" || e.valueType === "boolean" || mn(e.numberFormat)) return null;
|
|
1368
|
+
const t = e.value;
|
|
1369
|
+
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1370
|
+
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new v("precision");
|
|
1371
|
+
return t;
|
|
1372
|
+
}
|
|
1373
|
+
function hn(e, t, n) {
|
|
1374
|
+
if (e.seen.has(n)) return;
|
|
1375
|
+
e.seen.add(n), e.selected++;
|
|
1376
|
+
const r = t ? fn(t) : null;
|
|
1377
|
+
r === null ? e.excluded++ : e.values.push(r);
|
|
1378
|
+
}
|
|
1379
|
+
function gn(e, t, n, r) {
|
|
1380
|
+
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1381
|
+
}
|
|
1382
|
+
function pn(e, t, n) {
|
|
1383
|
+
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1384
|
+
}
|
|
1385
|
+
function wn(e, t, n, r) {
|
|
1386
|
+
const i = r.origin ? be(e) + t : t, s = pn(e, n, r);
|
|
1387
|
+
return i < r.rowStart || i > r.rowEnd || s < r.columnStart || s > r.columnEnd ? null : `${r.grid}:${i}:${s}`;
|
|
1388
|
+
}
|
|
1389
|
+
function bn(e, t) {
|
|
1390
|
+
const n = t.origin ? be(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1391
|
+
return i > r ? i : 0;
|
|
1392
|
+
}
|
|
1393
|
+
async function vn(e, t, n, r, i) {
|
|
1394
|
+
const s = e.grid;
|
|
1395
|
+
if (t > r.maxScanned) throw new v("limit");
|
|
1396
|
+
const l = s.colWidthsMm?.length ?? s.cells.reduce((a, c) => Math.max(a, c.length), 1);
|
|
1397
|
+
if (l > r.maxScanned) throw new v("limit");
|
|
1398
|
+
const o = /* @__PURE__ */ new Map();
|
|
1399
|
+
for (let a = 0; a < t; a++) {
|
|
1400
|
+
a > 0 && a % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
|
|
1401
|
+
let c = 0;
|
|
1402
|
+
for (const d of s.cells[a]) {
|
|
1403
|
+
for (await Z(r); c < l && (o.get(c) ?? 0) > a; ) c++;
|
|
1404
|
+
if (c >= l) break;
|
|
1405
|
+
const u = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), m = Math.min(s.cells.length, a + Math.max(1, d?.rowSpan ?? 1));
|
|
1406
|
+
u > 1 && await Z(r, u - 1);
|
|
1407
|
+
for (let h = c; h < c + u; h++) o.set(h, m);
|
|
1408
|
+
const f = wn(e, a, c, n);
|
|
1409
|
+
f && hn(i, d, f), c += u;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
async function yn(e, t, n) {
|
|
1414
|
+
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1415
|
+
for (let i = 0; i < e.pages.length; i++) {
|
|
1416
|
+
await Z(n);
|
|
1417
|
+
const s = e.pages[i];
|
|
1418
|
+
for (let l = 0; l < s.components.length; l++) {
|
|
1419
|
+
await Z(n);
|
|
1420
|
+
const o = s.components[l];
|
|
1421
|
+
if (!o.grid || !gn(o, i, l, t) || o.table && o.table.role !== "body") continue;
|
|
1422
|
+
const a = bn(o, t);
|
|
1423
|
+
a && await vn(o, a, t, n, r);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return r;
|
|
1427
|
+
}
|
|
1428
|
+
function _(e) {
|
|
1429
|
+
if (!Number.isFinite(e)) throw new v("overflow");
|
|
1430
|
+
return e;
|
|
1431
|
+
}
|
|
1432
|
+
function xn(e) {
|
|
1433
|
+
let t = 0, n = 0;
|
|
1434
|
+
for (const r of e) {
|
|
1435
|
+
const i = r - n, s = _(t + i);
|
|
1436
|
+
n = s - t - i, t = s;
|
|
1437
|
+
}
|
|
1438
|
+
return t;
|
|
1439
|
+
}
|
|
1440
|
+
async function Ie(e, t) {
|
|
1441
|
+
let n = [...e], r = new Array(e.length);
|
|
1442
|
+
for (let s = 1; s < e.length; s *= 2) {
|
|
1443
|
+
for (let l = 0; l < e.length; l += s * 2) {
|
|
1444
|
+
const o = Math.min(l + s, e.length), a = Math.min(l + s * 2, e.length);
|
|
1445
|
+
let c = l, d = o;
|
|
1446
|
+
for (let u = l; u < a; u++)
|
|
1447
|
+
r[u] = d >= a || c < o && n[c] <= n[d] ? n[c++] : n[d++], u % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
|
|
1448
|
+
}
|
|
1449
|
+
[n, r] = [r, n];
|
|
1450
|
+
}
|
|
1451
|
+
const i = Math.floor(n.length / 2);
|
|
1452
|
+
return n.length % 2 ? n[i] : _(n[i - 1] / 2 + n[i] / 2);
|
|
1453
|
+
}
|
|
1454
|
+
function Mn(e) {
|
|
1455
|
+
const t = xn(e);
|
|
1456
|
+
let n = 1 / 0, r = -1 / 0;
|
|
1457
|
+
for (const i of e)
|
|
1458
|
+
n = Math.min(n, i), r = Math.max(r, i);
|
|
1459
|
+
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1460
|
+
}
|
|
1461
|
+
function En(e, t) {
|
|
1462
|
+
if (typeof e != "string" || e.length > 256) throw new v("expression");
|
|
1463
|
+
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1464
|
+
if (!n.length || n.length > 64) throw new v("expression");
|
|
1465
|
+
let r = 0;
|
|
1466
|
+
function i(o) {
|
|
1467
|
+
if (o > 16) throw new v("expression");
|
|
1468
|
+
const a = n[r++];
|
|
1469
|
+
if (a === "+" || a === "-") return (a === "-" ? -1 : 1) * i(o + 1);
|
|
1470
|
+
if (a === "(") {
|
|
1471
|
+
const c = s(0, o + 1);
|
|
1472
|
+
if (n[r++] !== ")") throw new v("expression");
|
|
1473
|
+
return c;
|
|
1474
|
+
}
|
|
1475
|
+
if (a && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(a) && Object.prototype.hasOwnProperty.call(t, a)) return _(t[a]);
|
|
1476
|
+
if (a && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(a)) return _(Number(a));
|
|
1477
|
+
throw new v("expression");
|
|
1478
|
+
}
|
|
1479
|
+
function s(o, a) {
|
|
1480
|
+
let c = i(a);
|
|
1481
|
+
for (; r < n.length; ) {
|
|
1482
|
+
const d = n[r], u = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
|
|
1483
|
+
if (!u || u < o) break;
|
|
1484
|
+
r++;
|
|
1485
|
+
const m = s(u + 1, a + 1);
|
|
1486
|
+
if (d === "/" && m === 0) throw new v("division");
|
|
1487
|
+
c = _(d === "+" ? c + m : d === "-" ? c - m : d === "*" ? c * m : c / m);
|
|
1488
|
+
}
|
|
1489
|
+
return c;
|
|
1490
|
+
}
|
|
1491
|
+
const l = s(1, 0);
|
|
1492
|
+
if (r !== n.length) throw new v("expression");
|
|
1493
|
+
return l;
|
|
1494
|
+
}
|
|
1495
|
+
function Sn(e) {
|
|
1496
|
+
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1497
|
+
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new v("limit");
|
|
1498
|
+
if (!Number.isInteger(r) || r < 0 || r > 12) throw new v("precision");
|
|
1499
|
+
return { maxCells: t, maxScanned: n, precision: r };
|
|
1500
|
+
}
|
|
1501
|
+
async function nr(e, t, n = {}) {
|
|
1502
|
+
const r = Sn(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((a) => setTimeout(a, 0))) };
|
|
1503
|
+
z(i.signal);
|
|
1504
|
+
const s = await yn(e, un(e, t, r.maxCells), i), l = n.operation ?? "sum";
|
|
1505
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new v("expression");
|
|
1506
|
+
let o = null;
|
|
1507
|
+
if (l === "count") o = s.values.length;
|
|
1508
|
+
else if (s.values.length)
|
|
1509
|
+
if (l === "median") o = await Ie(s.values, i);
|
|
1510
|
+
else {
|
|
1511
|
+
const a = Mn(s.values);
|
|
1512
|
+
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (a.MEDIAN = await Ie(s.values, i)), o = En(n.expression ?? "", a)) : o = a[l.toUpperCase()];
|
|
1513
|
+
}
|
|
1514
|
+
if (z(i.signal), o !== null && Number.isInteger(o) && !Number.isSafeInteger(o)) throw new v("precision");
|
|
1515
|
+
return { value: o, formatted: o === null ? "—" : o.toFixed(r.precision), numericCells: s.values.length, excludedCells: s.excluded, selectedCells: s.selected, precision: r.precision };
|
|
1251
1516
|
}
|
|
1252
1517
|
export {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1518
|
+
Sr as CSS_DPI,
|
|
1519
|
+
or as DEFAULT_BORDER_PT,
|
|
1520
|
+
ee as DEFAULT_FONT_FAMILY,
|
|
1521
|
+
ar as DEFAULT_FONT_PT,
|
|
1522
|
+
sr as DEFAULT_STROKE_COLOR,
|
|
1523
|
+
Pe as DEFAULT_TEXT_COLOR,
|
|
1524
|
+
lr as LINE_HEIGHT,
|
|
1525
|
+
Tr as MM_PER_INCH,
|
|
1526
|
+
Hr as OutputAssetError,
|
|
1527
|
+
nt as OutputFidelityError,
|
|
1528
|
+
Y as PAPER_SIZES,
|
|
1529
|
+
kt as PageBuilder,
|
|
1530
|
+
mr as PaginatePageLimitError,
|
|
1531
|
+
cr as RENDER_PLAN_SCHEMA_VERSION,
|
|
1532
|
+
_r as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1533
|
+
v as ReportCalculationError,
|
|
1267
1534
|
M as ReportCellEditError,
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1535
|
+
tn as ReportCellFieldError,
|
|
1536
|
+
Xr as ReportParamValidationError,
|
|
1537
|
+
fr as ReportSourceError,
|
|
1538
|
+
Kr as ReportTemplateError,
|
|
1539
|
+
O as ReportTemplateStoreError,
|
|
1540
|
+
dr as SCHEMA_VERSION_MACH,
|
|
1541
|
+
At as TemplateBuilder,
|
|
1542
|
+
qn as applyReportCellEdit,
|
|
1543
|
+
Yn as applyReportCellEditBatch,
|
|
1544
|
+
er as applyReportEditResult,
|
|
1545
|
+
Rr as assertRenderPlan,
|
|
1546
|
+
Zr as assertReportParams,
|
|
1547
|
+
nr as calculateReportSelection,
|
|
1548
|
+
Fr as charWidthEm,
|
|
1549
|
+
C as classOf,
|
|
1550
|
+
Bn as columnsFromContract,
|
|
1551
|
+
Mt as computePageWindow,
|
|
1552
|
+
Or as createCanvasMeasurer,
|
|
1553
|
+
jn as createCanvasPager,
|
|
1554
|
+
Dr as createHeuristicMeasurer,
|
|
1555
|
+
Gn as createMemoryTemplateStore,
|
|
1556
|
+
Kn as createProviderReport,
|
|
1557
|
+
Un as createReportCellEdit,
|
|
1558
|
+
Jn as createReportCellEditBatch,
|
|
1559
|
+
he as createReportCellResolver,
|
|
1560
|
+
hr as createReportSource,
|
|
1561
|
+
_n as createTableTemplate,
|
|
1562
|
+
Wn as createTemplate,
|
|
1563
|
+
Vn as createTemplateManager,
|
|
1564
|
+
Vr as createTemplateRegistry,
|
|
1565
|
+
gr as datasetJsonSchema,
|
|
1566
|
+
pr as defineReport,
|
|
1567
|
+
Gr as defineReportTemplate,
|
|
1568
|
+
wr as evalStyleRule,
|
|
1569
|
+
En as evaluateReportAggregateExpression,
|
|
1570
|
+
ne as formatReportCellEdit,
|
|
1571
|
+
Zn as formatReportClipboard,
|
|
1572
|
+
br as formatValue,
|
|
1573
|
+
fe as getReportCellContext,
|
|
1574
|
+
le as heuristicMeasurer,
|
|
1575
|
+
Wr as inspectOutputCapabilities,
|
|
1576
|
+
Q as isImageBackedComponent,
|
|
1577
|
+
Qr as isReportDate,
|
|
1578
|
+
Re as isRichText,
|
|
1579
|
+
ue as measurePageSizePx,
|
|
1580
|
+
Lr as measureTextMm,
|
|
1581
|
+
ke as mergeComponentStyles,
|
|
1582
|
+
se as mmToPx,
|
|
1583
|
+
Cr as mmToPxFactor,
|
|
1584
|
+
vr as paginateTemplate,
|
|
1585
|
+
yr as parseDateLocal,
|
|
1586
|
+
tr as parseReportCellFieldInput,
|
|
1587
|
+
ge as parseReportCellInput,
|
|
1588
|
+
Qn as parseReportClipboard,
|
|
1589
|
+
ae as parseReportTemplate,
|
|
1590
|
+
Dn as planFontSizePx,
|
|
1591
|
+
L as ptToPx,
|
|
1592
|
+
Ir as pxToMm,
|
|
1593
|
+
Le as renderComponent,
|
|
1594
|
+
wt as renderPage,
|
|
1595
|
+
On as renderPlan,
|
|
1596
|
+
zn as renderPlanToCanvas,
|
|
1597
|
+
Hn as renderPlanToCanvasAsync,
|
|
1598
|
+
Ln as renderPlanToImages,
|
|
1599
|
+
we as reportCellEditKey,
|
|
1600
|
+
V as reportOutputDiagnostics,
|
|
1601
|
+
ei as reportParamsJsonSchema,
|
|
1602
|
+
Ae as resolveBoxBorders,
|
|
1603
|
+
j as resolveFontSize,
|
|
1604
|
+
K as resolveGridLayout,
|
|
1605
|
+
te as resolveLineHeight,
|
|
1606
|
+
_e as resolvePaper,
|
|
1607
|
+
ce as resolvePlanAssets,
|
|
1608
|
+
B as resolveStroke,
|
|
1609
|
+
$e as resolveTextColor,
|
|
1610
|
+
H as round,
|
|
1611
|
+
Ur as serializeReportTemplate,
|
|
1612
|
+
Xn as summarizeReportCellEdits,
|
|
1613
|
+
xr as toExcelNumberFormat,
|
|
1614
|
+
Mr as toNumber,
|
|
1615
|
+
Ar as validateComponent,
|
|
1616
|
+
et as validateDatasetRows,
|
|
1617
|
+
kr as validatePage,
|
|
1618
|
+
$r as validateRenderPlan,
|
|
1619
|
+
dn as validateReportCellFieldDefinition,
|
|
1620
|
+
ti as validateReportParamDefinitions,
|
|
1621
|
+
ni as validateReportParams,
|
|
1622
|
+
qr as validateReportTemplate,
|
|
1623
|
+
Jr as validateReportTemplateDocument,
|
|
1624
|
+
Ne as wrapText
|
|
1353
1625
|
};
|