@agile-team/mach-report 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +54 -10
  2. package/dist/ReportPreview-B-mwUSk9.cjs +6 -0
  3. package/dist/ReportPreview-DKjr4cwO.js +1688 -0
  4. package/dist/defaults-D4o0NCLo.js +9 -0
  5. package/dist/defaults-DOO1yHwx.cjs +1 -0
  6. package/dist/grid-geometry-Dw7BlENr.js +130 -0
  7. package/dist/grid-geometry-bkciiZ4Q.cjs +1 -0
  8. package/dist/index.cjs +6 -6
  9. package/dist/index.d.cts +37 -5
  10. package/dist/index.d.ts +37 -5
  11. package/dist/index.js +1163 -1037
  12. package/dist/pdf.cjs +48 -48
  13. package/dist/pdf.d.cts +18 -0
  14. package/dist/pdf.d.ts +18 -0
  15. package/dist/pdf.js +5605 -5575
  16. package/dist/{plugin-BMoMUxrw.cjs → plugin-2lqgTX26.cjs} +1 -1
  17. package/dist/{plugin-CAcNe0FT.js → plugin-5R00MJQs.js} +1 -1
  18. package/dist/render-plan-CfJ3wf1l.cjs +1 -0
  19. package/dist/render-plan-I9AHvQv7.js +13 -0
  20. package/dist/sql.cjs +42 -42
  21. package/dist/sql.js +1366 -1363
  22. package/dist/style.css +1 -1
  23. package/dist/textwrap-nH0UYU6D.js +108 -0
  24. package/dist/textwrap-oD-t4b4B.cjs +4 -0
  25. package/dist/vue/async.d.cts +33 -7
  26. package/dist/vue/async.d.ts +33 -7
  27. package/dist/vue/index.d.cts +36 -10
  28. package/dist/vue/index.d.ts +36 -10
  29. package/dist/vue-async.cjs +1 -1
  30. package/dist/vue-async.js +3 -3
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.js +4 -4
  33. package/dist/xlsx.cjs +24 -24
  34. package/dist/xlsx.d.cts +24 -4
  35. package/dist/xlsx.d.ts +24 -4
  36. package/dist/xlsx.js +8287 -8166
  37. package/package.json +1 -1
  38. package/dist/ReportPreview-BWrQCj9M.js +0 -1643
  39. package/dist/ReportPreview-DY0PGGqF.cjs +0 -6
  40. package/dist/grid-geometry-DBH9ExuY.cjs +0 -1
  41. package/dist/grid-geometry-DONcjshk.js +0 -130
  42. package/dist/textwrap-DdaewxAd.js +0 -117
  43. package/dist/textwrap-DqiFwAV3.cjs +0 -3
@@ -0,0 +1,1688 @@
1
+ import { computed as k, unref as x, ref as B, onScopeDispose as He, getCurrentScope as Ht, watch as Q, shallowRef as Ie, defineComponent as rt, nextTick as qt, openBlock as P, createElementBlock as $, createElementVNode as F, toDisplayString as C, Fragment as Ee, createCommentVNode as H, normalizeClass as oe, renderList as We, createTextVNode as et, withKeys as mt, inject as Be, provide as yt, useCssVars as Nt, watchEffect as vt, onMounted as jt, onUnmounted as Ut, normalizeStyle as re, createBlock as Vt, createVNode as Kt, renderSlot as Yt } from "vue";
2
+ import { renderPlanToImages as Zt, renderPage as xt, validateRenderPlan as Jt, ReportSourceError as Gt, renderPlanToCanvas as Xt } from "@agile-team/mach-report";
3
+ import { c as Pt } from "./page-window-index-CIuT4BAv.js";
4
+ import { i as Qt, a as _t } from "./render-plan-I9AHvQv7.js";
5
+ import { b as tt, c as en, d as tn, a as nn } from "./plugin-5R00MJQs.js";
6
+ function Et(e) {
7
+ return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
8
+ }
9
+ function yr(e) {
10
+ return Et(e).join(",");
11
+ }
12
+ class _e extends Error {
13
+ constructor(t) {
14
+ super(t), this.name = "PlanLoadError";
15
+ }
16
+ }
17
+ function xr(e = {}) {
18
+ const { baseUrl: t = "", headers: a, credentials: r, timeoutMs: n = 3e4 } = e, o = t.replace(/\/+$/, "");
19
+ return async ({ url: l, method: u, params: p, signal: m }) => {
20
+ let d = `${o}${l}`;
21
+ if (p && Object.keys(p).length > 0) {
22
+ const b = d.indexOf("#"), I = b >= 0 ? d.slice(b) : "", E = b >= 0 ? d.slice(0, b) : d, D = E.indexOf("?"), S = D >= 0 ? E.slice(0, D) : E, M = new URLSearchParams(D >= 0 ? E.slice(D + 1) : "");
23
+ for (const [q, K] of Object.entries(p)) M.set(q, K);
24
+ d = `${S}?${M}${I}`;
25
+ }
26
+ const f = (b, I) => {
27
+ const E = new _e(b);
28
+ return Object.defineProperty(E, "cause", { value: I, configurable: !0, writable: !0 }), E;
29
+ };
30
+ if (m?.aborted)
31
+ throw f(`请求已取消: ${l}`, m.reason);
32
+ const h = new AbortController();
33
+ let v;
34
+ const A = () => {
35
+ h.signal.aborted || (v = "external", h.abort(m?.reason));
36
+ };
37
+ m?.addEventListener("abort", A, { once: !0 });
38
+ const W = setTimeout(() => {
39
+ h.signal.aborted || (v = "timeout", h.abort());
40
+ }, n);
41
+ try {
42
+ const b = await fetch(d, {
43
+ method: u.toUpperCase(),
44
+ headers: { Accept: "application/json", ...a },
45
+ credentials: r,
46
+ signal: h.signal
47
+ });
48
+ if (!b.ok)
49
+ throw new _e(`HTTP ${b.status} ${l}`);
50
+ return await b.json();
51
+ } catch (b) {
52
+ throw v === "timeout" ? f(`请求超时(${n}ms): ${l}`, b) : v === "external" ? f(`请求已取消: ${l}`, b) : b instanceof _e ? b : f(`请求失败(${l}): ${b instanceof Error ? b.message : String(b)}`, b);
53
+ } finally {
54
+ clearTimeout(W), m?.removeEventListener("abort", A);
55
+ }
56
+ };
57
+ }
58
+ function rn(e, t, a = {}) {
59
+ const r = a.pxPerMm ?? 3.7795275590551185, n = k(() => Math.max(0, x(a.gapPx) ?? 18)), o = B(0), l = B(800), u = k(() => {
60
+ const b = e.value?.pages ?? [];
61
+ return Pt(b.map((I) => I.pageHeightMm * r), n.value);
62
+ }), p = k(() => {
63
+ let b = 0;
64
+ for (const I of e.value?.pages ?? []) b = Math.max(b, I.pageWidthMm * r);
65
+ return { w: b, h: u.value.totalHeightPx };
66
+ }), m = k(() => u.value.window(
67
+ l.value / t.value,
68
+ o.value / t.value,
69
+ x(a.overscan) ?? 1
70
+ )), d = k(() => {
71
+ const b = e.value;
72
+ if (!b) return [];
73
+ const { start: I, end: E } = m.value;
74
+ return b.pages.slice(I, E + 1).map((D, S) => ({ page: D, index: I + S }));
75
+ });
76
+ let f = 0, h = !1;
77
+ function v(b) {
78
+ b && (o.value = b.scrollTop, l.value = b.clientHeight || 800);
79
+ }
80
+ function A(b, I) {
81
+ return (E) => {
82
+ f || h || (f = requestAnimationFrame(() => {
83
+ if (f = 0, h || (v(E), I.value <= 0)) return;
84
+ const D = Math.max(0, E.scrollTop + 32) / t.value;
85
+ b.value = Math.min(I.value, u.value.pageAt(D) + 1);
86
+ }));
87
+ };
88
+ }
89
+ function W() {
90
+ h = !0, f && cancelAnimationFrame(f), f = 0;
91
+ }
92
+ return He(W), {
93
+ contentSize: p,
94
+ windowRange: m,
95
+ visiblePages: d,
96
+ makeScrollHandler: A,
97
+ refreshViewport: v,
98
+ pageOffsetPx: (b) => u.value.offsetAt(b),
99
+ destroy: W
100
+ };
101
+ }
102
+ function on(e) {
103
+ const t = B(1), a = B("fit");
104
+ let r = 0;
105
+ function n() {
106
+ r && cancelAnimationFrame(r), r = 0;
107
+ }
108
+ function o() {
109
+ n(), r = requestAnimationFrame(() => {
110
+ if (r = 0, a.value !== "fit") return;
111
+ const u = e();
112
+ !u?.viewport || u.viewport.clientWidth <= 48 || !Number.isFinite(u.pageWidthPx) || (t.value = Math.min(1, (u.viewport.clientWidth - 48) / Math.max(1, u.pageWidthPx)));
113
+ });
114
+ }
115
+ function l(u) {
116
+ if (u === "fit")
117
+ a.value = "fit", o();
118
+ else {
119
+ if (!Number.isFinite(u)) return;
120
+ n(), a.value = "raw", t.value = Math.min(3, Math.max(0.3, u / 100));
121
+ }
122
+ }
123
+ return Ht() && He(n), { zoom: t, zoomMode: a, applyFitZoom: o, setZoom: l };
124
+ }
125
+ const Ae = 8;
126
+ function Le() {
127
+ return new Promise((e) => setTimeout(e, 0));
128
+ }
129
+ function De(e) {
130
+ return `p${e.pageWidthMm}x${e.pageHeightMm}`.replace(/[.+]/g, "_");
131
+ }
132
+ function ot(e) {
133
+ const t = /* @__PURE__ */ new Map();
134
+ return e.pages.forEach((n) => {
135
+ t.has(De(n)) || t.set(De(n), n);
136
+ }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
137
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
138
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
139
+ ${[...t.values()].map(
140
+ (n) => `@page ${De(n)}{size:${n.pageWidthMm}mm ${n.pageHeightMm}mm;margin:0;}`
141
+ ).join(`
142
+ `)}
143
+ body{margin:0;background:#fff;}`}</style></head><body>`;
144
+ }
145
+ function at(e) {
146
+ const t = xt(e, 96, {}, document);
147
+ return t.style.page = De(e), t.outerHTML;
148
+ }
149
+ function $t(e) {
150
+ return { head: ot(e), pageChunks: e.pages.map(at) };
151
+ }
152
+ async function Pr(e, t = {}) {
153
+ const a = {
154
+ schemaVersion: "mach-report-batch-print",
155
+ pages: e.flatMap((l) => l.pages)
156
+ };
157
+ if (a.pages.length === 0) return;
158
+ const r = ot(a), n = document.createElement("iframe");
159
+ n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
160
+ let o = !1;
161
+ try {
162
+ const l = n.contentDocument;
163
+ l.open(), l.write(r);
164
+ for (let u = 0; u < a.pages.length; u++)
165
+ l.write(at(a.pages[u])), u % Ae === Ae - 1 && (t.onProgress?.(u + 1, a.pages.length), await Le());
166
+ l.write("</body></html>"), l.close(), await Le(), t.onProgress?.(a.pages.length, a.pages.length), o = !0, n.contentWindow?.focus(), n.contentWindow?.print();
167
+ } catch (l) {
168
+ t.onError?.(l instanceof Error ? `批量打印失败: ${l.message}` : "批量打印失败");
169
+ } finally {
170
+ o ? setTimeout(() => n.remove(), 6e4) : n.remove();
171
+ }
172
+ }
173
+ function an(e) {
174
+ const { head: t, pageChunks: a } = $t(e);
175
+ return {
176
+ html: `${`<!doctype html><html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View><w:Zoom>100</w:Zoom></w:WordDocument></xml><![endif]-->${t.replace(/^<!doctype html><html><head>/, "")}`}${a.join("")}</body></html>`,
177
+ filename: "mach-report.doc"
178
+ };
179
+ }
180
+ function sn(e, t) {
181
+ let a = null, r = !1, n = !1, o = 0;
182
+ const l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
183
+ let p = null, m = null, d = null, f = null, h = null;
184
+ function v(s, c) {
185
+ return !n && e.value === s && o === c;
186
+ }
187
+ function A() {
188
+ if (n) return;
189
+ const s = [...l.values()].reverse().find((c) => v(c.plan, c.epoch))?.format ?? null;
190
+ s !== p && (p = s, t.onBusy?.(s));
191
+ }
192
+ function W(s, c, y) {
193
+ const R = {};
194
+ return l.set(R, { plan: s, epoch: c, format: y }), A(), R;
195
+ }
196
+ function b(s) {
197
+ l.delete(s), A();
198
+ }
199
+ function I() {
200
+ for (const [s, c] of u)
201
+ v(c.plan, c.epoch) || (s.close(), u.delete(s));
202
+ }
203
+ const E = Q(e, () => {
204
+ o++, D(), A(), I();
205
+ }, { flush: "sync" });
206
+ function D() {
207
+ a?.remove(), a = null;
208
+ }
209
+ function S() {
210
+ n = !0, o++, E(), D(), I(), l.clear(), t.onPrinting?.(!1);
211
+ }
212
+ function M(s, c) {
213
+ const y = URL.createObjectURL(s);
214
+ setTimeout(() => URL.revokeObjectURL(y), 1e4);
215
+ const R = document.createElement("a");
216
+ R.href = y, R.download = c, R.click();
217
+ }
218
+ async function q() {
219
+ if (r) return;
220
+ const s = e.value;
221
+ if (n || !s || s.pages.length === 0) return;
222
+ const c = o;
223
+ r = !0, t.onPrinting?.(!0), D();
224
+ const y = ot(s);
225
+ a = document.createElement("iframe"), a.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(a);
226
+ const R = a;
227
+ try {
228
+ const T = R.contentDocument;
229
+ T.open(), T.write(y);
230
+ for (let U = 0; U < s.pages.length; U++)
231
+ if (T.write(at(s.pages[U])), U % Ae === Ae - 1 && await Le(), R !== a) return;
232
+ if (T.write("</body></html>"), T.close(), await Le(), !v(s, c) || R !== a) return;
233
+ R.contentWindow?.focus(), R.contentWindow?.print();
234
+ } catch {
235
+ R === a && D(), v(s, c) && t.onError("调用打印失败,请改用导出 PDF", "print");
236
+ } finally {
237
+ r = !1, n || t.onPrinting?.(!1);
238
+ }
239
+ }
240
+ function K(s, c) {
241
+ if (m?.plan === s && m.epoch === c) return m.promise;
242
+ const y = Promise.resolve().then(() => {
243
+ if (!v(s, c)) throw new Error("报表已切换或卸载");
244
+ return t.getPdfExporter()(s, (R) => {
245
+ v(s, c) && t.onWarning?.(R);
246
+ });
247
+ }).finally(() => {
248
+ m?.promise === y && (m = null);
249
+ });
250
+ return m = { plan: s, epoch: c, promise: y }, y;
251
+ }
252
+ async function V() {
253
+ const s = e.value;
254
+ if (n || !s || s.pages.length === 0) return;
255
+ const c = o;
256
+ if (d?.plan === s && d.epoch === c) return d.promise;
257
+ const y = W(s, c, "PDF"), R = (async () => {
258
+ try {
259
+ const T = await K(s, c);
260
+ if (!v(s, c)) return;
261
+ M(new Blob([T], { type: "application/pdf" }), "mach-report.pdf");
262
+ } catch (T) {
263
+ v(s, c) && t.onError(T instanceof Error ? `PDF 导出失败: ${T.message}` : "PDF 导出失败", "pdf");
264
+ } finally {
265
+ b(y), d?.token === y && (d = null);
266
+ }
267
+ })();
268
+ return d = { plan: s, epoch: c, promise: R, token: y }, R;
269
+ }
270
+ async function Y() {
271
+ const s = e.value;
272
+ if (n || !s || s.pages.length === 0) return;
273
+ const c = o;
274
+ if (f?.plan === s && f.epoch === c) return f.promise;
275
+ const y = { ...t.getXlsxOptions?.() }, R = W(s, c, "Excel"), T = (async () => {
276
+ try {
277
+ const { renderPlanToXlsx: U } = await import("@agile-team/mach-report/xlsx");
278
+ if (!v(s, c)) return;
279
+ const { buffer: J, warnings: G } = await U(s, y);
280
+ if (!v(s, c) || (G.length > 0 && t.onWarning?.(`Excel 导出有 ${G.length} 条提示:${G.slice(0, 2).join(";")}`), !v(s, c))) return;
281
+ M(new Blob([J], {
282
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
283
+ }), "mach-report.xlsx");
284
+ } catch (U) {
285
+ v(s, c) && t.onError(U instanceof Error ? `Excel 导出失败: ${U.message}` : "Excel 导出失败", "export");
286
+ } finally {
287
+ b(R), f?.token === R && (f = null);
288
+ }
289
+ })();
290
+ return f = { plan: s, epoch: c, promise: T, token: R }, T;
291
+ }
292
+ async function O() {
293
+ const s = e.value;
294
+ if (n || !s || s.pages.length === 0) return;
295
+ const c = o;
296
+ if (h?.plan === s && h.epoch === c) return h.promise;
297
+ const y = W(s, c, "图片"), R = (async () => {
298
+ try {
299
+ const { blobs: T } = await Zt(s, {
300
+ dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
301
+ });
302
+ if (!v(s, c)) return;
303
+ T.forEach((U, J) => {
304
+ M(U, T.length > 1 ? `mach-report-page-${J + 1}.png` : "mach-report.png");
305
+ });
306
+ } catch (T) {
307
+ v(s, c) && t.onError(
308
+ T instanceof Error ? `图片导出失败: ${T.message}` : "图片导出失败",
309
+ "export"
310
+ );
311
+ } finally {
312
+ b(y), h?.token === y && (h = null);
313
+ }
314
+ })();
315
+ return h = { plan: s, epoch: c, promise: R, token: y }, R;
316
+ }
317
+ function ae() {
318
+ const s = e.value;
319
+ if (!(n || !s || s.pages.length === 0))
320
+ try {
321
+ const { html: c, filename: y } = an(s);
322
+ M(new Blob([c], { type: "application/msword;charset=utf-8" }), y);
323
+ } catch (c) {
324
+ t.onError(
325
+ c instanceof Error ? `Word 导出失败: ${c.message}` : "Word 导出失败",
326
+ "export"
327
+ );
328
+ }
329
+ }
330
+ async function ee(s) {
331
+ const c = e.value;
332
+ if (!(n || !c || c.pages.length === 0)) {
333
+ if (s === "pdf") {
334
+ await V();
335
+ return;
336
+ }
337
+ if (s === "xlsx" || s === "excel") {
338
+ await Y();
339
+ return;
340
+ }
341
+ if (s === "png" || s === "image") {
342
+ await O();
343
+ return;
344
+ }
345
+ if (s === "word" || s === "doc") {
346
+ ae();
347
+ return;
348
+ }
349
+ if (s !== "html") {
350
+ t.onError(`不支持的导出格式:${s}`, "export");
351
+ return;
352
+ }
353
+ try {
354
+ const { head: y, pageChunks: R } = $t(c), T = `${y}${R.join("")}</body></html>`;
355
+ M(new Blob([T], { type: "text/html;charset=utf-8" }), "mach-report.html");
356
+ } catch (y) {
357
+ t.onError(y instanceof Error ? `HTML 导出失败: ${y.message}` : "HTML 导出失败", "export");
358
+ }
359
+ }
360
+ }
361
+ function pe() {
362
+ const s = e.value;
363
+ if (n || !s || s.pages.length === 0) return;
364
+ const c = o, y = window.open("", "_blank");
365
+ if (!y) {
366
+ t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
367
+ return;
368
+ }
369
+ u.set(y, { plan: s, epoch: c });
370
+ const R = W(s, c, "PDF");
371
+ K(s, c).then((T) => {
372
+ if (!v(s, c) || y.closed) {
373
+ u.delete(y) && y.close();
374
+ return;
375
+ }
376
+ const U = URL.createObjectURL(new Blob([T], { type: "application/pdf" }));
377
+ setTimeout(() => URL.revokeObjectURL(U), 6e4);
378
+ const J = y.document;
379
+ J.title = "PDF 预览", J.documentElement.style.height = "100%", J.body.style.cssText = "margin:0;height:100%;";
380
+ const G = J.createElement("iframe");
381
+ G.title = "PDF 预览", G.style.cssText = "display:block;width:100%;height:100%;border:0;", G.src = U, J.body.replaceChildren(G), u.delete(y);
382
+ }).catch((T) => {
383
+ y.close(), u.delete(y), v(s, c) && t.onError(T instanceof Error ? `PDF 预览失败: ${T.message}` : "PDF 预览失败", "pdf");
384
+ }).finally(() => b(R));
385
+ }
386
+ return {
387
+ print: q,
388
+ exportAs: ee,
389
+ exportImages: O,
390
+ exportWord: ae,
391
+ openPdfWindow: pe,
392
+ releasePrintFrame: D,
393
+ dispose: S
394
+ };
395
+ }
396
+ const kt = "mrp-hit";
397
+ function ln(e) {
398
+ e.querySelectorAll(`mark.${kt}`).forEach((a) => {
399
+ const r = a.parentNode;
400
+ if (r) {
401
+ for (; a.firstChild; ) r.insertBefore(a.firstChild, a);
402
+ a.remove(), r.normalize();
403
+ }
404
+ });
405
+ }
406
+ function un(e, t) {
407
+ const a = t.trim();
408
+ if (!a) return 0;
409
+ const r = a.toLowerCase(), n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
410
+ acceptNode(u) {
411
+ const p = u.parentElement;
412
+ return !p || p.closest("mark") || /^(SCRIPT|STYLE)$/.test(p.tagName) ? NodeFilter.FILTER_REJECT : (u.nodeValue ?? "").toLowerCase().includes(r) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
413
+ }
414
+ }), o = [];
415
+ for (let u = n.nextNode(); u; u = n.nextNode()) o.push(u);
416
+ let l = 0;
417
+ for (const u of o) {
418
+ const p = u.nodeValue ?? "", m = p.toLowerCase(), d = u.parentElement;
419
+ if (!d) continue;
420
+ const f = document.createDocumentFragment();
421
+ let h = 0, v = m.indexOf(r);
422
+ for (; v >= 0; ) {
423
+ v > h && f.appendChild(document.createTextNode(p.slice(h, v)));
424
+ const A = document.createElement("mark");
425
+ A.className = kt, A.textContent = p.slice(v, v + a.length), f.appendChild(A), l++, h = v + a.length, v = m.indexOf(r, h);
426
+ }
427
+ h < p.length && f.appendChild(document.createTextNode(p.slice(h))), d.replaceChild(f, u);
428
+ }
429
+ return l;
430
+ }
431
+ const cn = /* @__PURE__ */ new Set(["line", "rect", "ellipse", "chart"]);
432
+ function* dn(e) {
433
+ for (const t of e.cells ?? [])
434
+ for (const a of t ?? [])
435
+ yield a?.text ?? "", yield* a?.children ?? [];
436
+ }
437
+ function* fn(e) {
438
+ if (_t(e))
439
+ for (const t of e.richParagraphs)
440
+ for (const a of t.segments ?? [])
441
+ yield (a.kind === "field" ? a.field : a.text) ?? "";
442
+ else e.lines?.length ? yield* e.lines : yield e.text ?? "";
443
+ }
444
+ function* pn(e) {
445
+ const t = [e.values()];
446
+ for (; t.length > 0; ) {
447
+ const a = t[t.length - 1].next();
448
+ if (a.done) {
449
+ t.pop();
450
+ continue;
451
+ }
452
+ const r = a.value;
453
+ if (typeof r == "string") {
454
+ yield r;
455
+ continue;
456
+ }
457
+ yield "", !Qt(r) && (r.kind === "text" ? t.push(fn(r)) : r.grid ? t.push(dn(r.grid)) : cn.has(r.kind) || (yield r.fallbackText ?? ""));
458
+ }
459
+ }
460
+ function* mn(e) {
461
+ for (let t = 0; t < e.pages.length; t++) {
462
+ for (const a of pn(e.pages[t].components)) yield { text: a, pageIndex: t };
463
+ yield { text: "", pageIndex: t };
464
+ }
465
+ }
466
+ function vn(e, t) {
467
+ const a = e.toLowerCase();
468
+ let r = 0;
469
+ for (let n = a.indexOf(t); n >= 0; n = a.indexOf(t, n + t.length)) r++;
470
+ return r;
471
+ }
472
+ function hn(e) {
473
+ const { plan: t, gotoPage: a, highlight: r, clearHighlights: n } = e, o = B(!1), l = B(""), u = B(0), p = B(0), m = B(!1);
474
+ let d = [];
475
+ const f = k(() => {
476
+ if (p.value === 0) return null;
477
+ const S = u.value;
478
+ let M = 0, q = d.length - 1;
479
+ for (; M < q; ) {
480
+ const V = M + q >>> 1;
481
+ d[V].cumulative <= S ? M = V + 1 : q = V;
482
+ }
483
+ const K = d[M];
484
+ return K ? { pageIndex: K.pageIndex, occurrence: S - (d[M - 1]?.cumulative ?? 0) } : null;
485
+ });
486
+ let h = null, v = null, A = 0;
487
+ function W() {
488
+ A++, h && clearTimeout(h), v && clearTimeout(v), h = v = null, m.value = !1;
489
+ }
490
+ function b(S) {
491
+ l.value = S, u.value = 0, p.value = 0, d = [], m.value = !1;
492
+ const M = S.trim().toLowerCase(), q = t.value;
493
+ if (!M || !q) return;
494
+ m.value = !0;
495
+ const K = A, V = mn(q), Y = [];
496
+ let O = 0;
497
+ function ae() {
498
+ if (v = null, K !== A || q !== t.value) return;
499
+ const ee = performance.now();
500
+ let pe = 0;
501
+ for (; pe < 5e3 && performance.now() - ee < 4; ) {
502
+ const s = V.next();
503
+ if (s.done) {
504
+ d = Y, p.value = O, m.value = !1, d[0] && a(d[0].pageIndex + 1);
505
+ return;
506
+ }
507
+ const c = vn(s.value.text, M);
508
+ if (c > 0) {
509
+ O += c;
510
+ const y = Y[Y.length - 1];
511
+ y?.pageIndex === s.value.pageIndex ? y.cumulative = O : Y.push({ pageIndex: s.value.pageIndex, cumulative: O });
512
+ }
513
+ pe++;
514
+ }
515
+ v = setTimeout(ae, 0);
516
+ }
517
+ ae();
518
+ }
519
+ function I(S) {
520
+ if (W(), l.value = S, u.value = p.value = 0, d = [], !S.trim()) {
521
+ b("");
522
+ return;
523
+ }
524
+ m.value = !0, h = setTimeout(() => {
525
+ h = null, b(S);
526
+ }, Math.max(0, x(e.debounceMs) ?? 200));
527
+ }
528
+ function E(S) {
529
+ const M = p.value;
530
+ if (M === 0 || m.value) return;
531
+ u.value = (u.value + S + M) % M;
532
+ const q = f.value;
533
+ q && a(q.pageIndex + 1);
534
+ }
535
+ function D() {
536
+ W(), l.value = "", u.value = p.value = 0, d = [];
537
+ }
538
+ return Q(t, D, { flush: "sync" }), He(D), {
539
+ visible: o,
540
+ query: l,
541
+ matchIndex: u,
542
+ matchCount: p,
543
+ activeMatch: f,
544
+ searching: m,
545
+ toggle: () => {
546
+ o.value = !o.value;
547
+ },
548
+ onInput: I,
549
+ onNav: E,
550
+ apply: (S) => {
551
+ l.value.trim() && r(S, l.value.trim());
552
+ },
553
+ clear: (S) => {
554
+ n(S);
555
+ },
556
+ reset: D
557
+ };
558
+ }
559
+ function gn(e, t) {
560
+ const a = k(() => {
561
+ if (e.value) return !0;
562
+ if (typeof location > "u") return !1;
563
+ try {
564
+ return new URLSearchParams(location.search).get("mrp-debug") === "1";
565
+ } catch {
566
+ return !1;
567
+ }
568
+ }), r = k(() => !a.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), n = k(() => !a.value || !t.plan.value ? null : {
569
+ pages: t.pageCount.value,
570
+ window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
571
+ zoom: `${Math.round(t.zoom.value * 100)}%`,
572
+ loadMs: `${t.loadMs.value}ms`,
573
+ planKB: r.value
574
+ });
575
+ return { enabled: a, debugStats: n };
576
+ }
577
+ function bn(e, t) {
578
+ const { thumbsRoot: a, visible: r, renderThumbCanvas: n } = t, o = B(0), l = B(800), u = k(() => (e.value?.pages ?? []).map(
579
+ (E) => Math.round(E.pageHeightMm / E.pageWidthMm * 116)
580
+ )), p = k(() => Pt(u.value.map((E) => E + 20), 8)), m = k(() => p.value.window(l.value, o.value, 1)), d = k(() => {
581
+ if (!r.value) return [];
582
+ const { start: E, end: D } = m.value;
583
+ return u.value.slice(E, D + 1).map((S, M) => ({ index: E + M, height: S }));
584
+ });
585
+ let f = 0, h = 0, v = !1;
586
+ function A() {
587
+ const E = a.value;
588
+ E && (o.value = E.scrollTop, l.value = E.clientHeight || 800);
589
+ }
590
+ function W() {
591
+ v || h || (h = requestAnimationFrame(() => {
592
+ h = 0, A();
593
+ }));
594
+ }
595
+ function b() {
596
+ if (d.value, f && cancelAnimationFrame(f), f = 0, v || !r.value || !e.value || !a.value) return;
597
+ A();
598
+ const E = d.value, D = e.value, S = a.value;
599
+ let M = 0;
600
+ function q() {
601
+ if (f = 0, !(v || !r.value || e.value !== D || a.value !== S)) {
602
+ for (let K = 0; M < E.length && K < 2; K++, M++) {
603
+ const V = E[M].index, Y = S.querySelector(`[data-thumb="${V + 1}"]`);
604
+ if (!Y || Y.childElementCount > 0) continue;
605
+ const O = n(V);
606
+ O && (O.style.width = "100%", O.style.height = "100%", O.style.display = "block", Y.appendChild(O));
607
+ }
608
+ M < E.length && (f = requestAnimationFrame(q));
609
+ }
610
+ }
611
+ f = requestAnimationFrame(q);
612
+ }
613
+ function I() {
614
+ v = !0, f && cancelAnimationFrame(f), h && cancelAnimationFrame(h), f = h = 0;
615
+ }
616
+ return He(I), { schedule: b, destroy: I, onScroll: W, windowRange: m, visibleThumbs: d };
617
+ }
618
+ function wn() {
619
+ const e = Ie(0);
620
+ return {
621
+ loadMs: e,
622
+ start() {
623
+ return typeof performance < "u" ? performance.now() : 0;
624
+ },
625
+ end(t) {
626
+ e.value = t ? Math.round(performance.now() - t) : 0;
627
+ }
628
+ };
629
+ }
630
+ const yn = { class: "mrp-toolbar" }, xn = { class: "mrp-title" }, Pn = ["disabled"], En = { class: "mrp-pageinfo" }, $n = ["disabled"], kn = {
631
+ key: 1,
632
+ class: "mrp-search"
633
+ }, Cn = ["placeholder", "value"], Mn = {
634
+ key: 0,
635
+ class: "mrp-search-count",
636
+ role: "status"
637
+ }, Fn = ["disabled"], Rn = ["disabled"], Tn = /* @__PURE__ */ rt({
638
+ __name: "ReportToolbar",
639
+ props: {
640
+ pageCount: {},
641
+ currentPage: {},
642
+ zoomMode: {},
643
+ zoom: {},
644
+ showExport: { type: Boolean },
645
+ showPrint: { type: Boolean },
646
+ showPdfWindow: { type: Boolean },
647
+ messages: {},
648
+ search: {},
649
+ thumbsVisible: { type: Boolean }
650
+ },
651
+ emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle"],
652
+ setup(e) {
653
+ const t = e, a = B(null);
654
+ Q(
655
+ () => t.search.visible,
656
+ (n) => {
657
+ n && qt(() => a.value?.focus());
658
+ }
659
+ );
660
+ function r(n, o, l) {
661
+ return n.replace("{cur}", String(o)).replace("{total}", String(l));
662
+ }
663
+ return (n, o) => (P(), $("div", yn, [
664
+ F("span", xn, C(e.messages.title), 1),
665
+ e.pageCount > 0 ? (P(), $(Ee, { key: 0 }, [
666
+ F("button", {
667
+ class: "mrp-nav",
668
+ type: "button",
669
+ disabled: e.currentPage <= 1,
670
+ onClick: o[0] || (o[0] = (l) => n.$emit("goto", e.currentPage - 1))
671
+ }, C(e.messages.prevPage), 9, Pn),
672
+ F("span", En, C(r(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
673
+ F("button", {
674
+ class: "mrp-nav",
675
+ type: "button",
676
+ disabled: e.currentPage >= e.pageCount,
677
+ onClick: o[1] || (o[1] = (l) => n.$emit("goto", e.currentPage + 1))
678
+ }, C(e.messages.nextPage), 9, $n)
679
+ ], 64)) : H("", !0),
680
+ o[17] || (o[17] = F("span", { class: "mrp-spacer" }, null, -1)),
681
+ e.search.visible ? (P(), $("div", kn, [
682
+ F("input", {
683
+ ref_key: "searchInputRef",
684
+ ref: a,
685
+ class: "mrp-search-input",
686
+ type: "text",
687
+ placeholder: e.messages.searchPlaceholder,
688
+ value: e.search.query,
689
+ onInput: o[2] || (o[2] = (l) => n.$emit("search-input", l.target.value))
690
+ }, null, 40, Cn),
691
+ e.search.query ? (P(), $("span", Mn, C(e.search.searching ? e.messages.searching ?? "搜索中…" : r(e.messages.matchInfo, e.search.matchCount > 0 ? e.search.matchIndex + 1 : 0, e.search.matchCount)), 1)) : H("", !0),
692
+ F("button", {
693
+ class: "mrp-nav",
694
+ type: "button",
695
+ disabled: e.search.matchCount === 0,
696
+ onClick: o[3] || (o[3] = (l) => n.$emit("search-nav", -1))
697
+ }, C(e.messages.prevMatch), 9, Fn),
698
+ F("button", {
699
+ class: "mrp-nav",
700
+ type: "button",
701
+ disabled: e.search.matchCount === 0,
702
+ onClick: o[4] || (o[4] = (l) => n.$emit("search-nav", 1))
703
+ }, C(e.messages.nextMatch), 9, Rn)
704
+ ])) : H("", !0),
705
+ F("button", {
706
+ class: oe(["mrp-nav", { "mrp-active": e.search.visible }]),
707
+ type: "button",
708
+ title: "Ctrl+F",
709
+ onClick: o[5] || (o[5] = (l) => n.$emit("search-toggle"))
710
+ }, " 🔍 ", 2),
711
+ F("button", {
712
+ class: oe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
713
+ type: "button",
714
+ onClick: o[6] || (o[6] = (l) => n.$emit("thumbs-toggle"))
715
+ }, " ▦ " + C(e.messages.thumbnails), 3),
716
+ F("button", {
717
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
718
+ type: "button",
719
+ onClick: o[7] || (o[7] = (l) => n.$emit("zoom", "fit"))
720
+ }, C(e.messages.fitWidth), 3),
721
+ F("button", {
722
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
723
+ type: "button",
724
+ onClick: o[8] || (o[8] = (l) => n.$emit("zoom", 100))
725
+ }, " 100% ", 2),
726
+ F("button", {
727
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
728
+ type: "button",
729
+ onClick: o[9] || (o[9] = (l) => n.$emit("zoom", 150))
730
+ }, " 150% ", 2),
731
+ e.showExport ? (P(), $("button", {
732
+ key: 2,
733
+ class: "mrp-nav",
734
+ type: "button",
735
+ onClick: o[10] || (o[10] = (l) => n.$emit("export", "html"))
736
+ }, C(e.messages.exportHtml), 1)) : H("", !0),
737
+ e.showExport ? (P(), $("button", {
738
+ key: 3,
739
+ class: "mrp-nav",
740
+ type: "button",
741
+ onClick: o[11] || (o[11] = (l) => n.$emit("export", "pdf"))
742
+ }, C(e.messages.exportPdf), 1)) : H("", !0),
743
+ e.showExport ? (P(), $("button", {
744
+ key: 4,
745
+ class: "mrp-nav",
746
+ type: "button",
747
+ onClick: o[12] || (o[12] = (l) => n.$emit("export", "xlsx"))
748
+ }, C(e.messages.exportExcel), 1)) : H("", !0),
749
+ e.showExport ? (P(), $("button", {
750
+ key: 5,
751
+ class: "mrp-nav",
752
+ type: "button",
753
+ onClick: o[13] || (o[13] = (l) => n.$emit("export", "png"))
754
+ }, C(e.messages.exportImage), 1)) : H("", !0),
755
+ e.showExport ? (P(), $("button", {
756
+ key: 6,
757
+ class: "mrp-nav",
758
+ type: "button",
759
+ onClick: o[14] || (o[14] = (l) => n.$emit("export", "word"))
760
+ }, C(e.messages.exportWord), 1)) : H("", !0),
761
+ e.showPrint ? (P(), $("button", {
762
+ key: 7,
763
+ class: "mrp-nav",
764
+ type: "button",
765
+ onClick: o[15] || (o[15] = (l) => n.$emit("print"))
766
+ }, C(e.messages.print), 1)) : H("", !0),
767
+ e.showPdfWindow ? (P(), $("button", {
768
+ key: 8,
769
+ class: "mrp-nav",
770
+ type: "button",
771
+ onClick: o[16] || (o[16] = (l) => n.$emit("pdf-window"))
772
+ }, C(e.messages.pdfWindow), 1)) : H("", !0)
773
+ ]));
774
+ }
775
+ }), st = (e, t) => {
776
+ const a = e.__vccOpts || e;
777
+ for (const [r, n] of t)
778
+ a[r] = n;
779
+ return a;
780
+ }, Sn = /* @__PURE__ */ st(Tn, [["__scopeId", "data-v-601f8fa8"]]), In = { class: "mrp-params" }, Dn = { class: "mrp-params-title" }, On = { class: "mrp-params-grid" }, Wn = { class: "mrp-param-label" }, Bn = {
781
+ key: 0,
782
+ class: "mrp-param-star"
783
+ }, An = ["value", "onChange"], Ln = {
784
+ value: "",
785
+ disabled: "",
786
+ hidden: ""
787
+ }, zn = ["value"], Hn = ["type", "placeholder", "value", "onInput"], qn = { class: "mrp-params-actions" }, Nn = /* @__PURE__ */ rt({
788
+ __name: "ReportParamPanel",
789
+ props: {
790
+ defs: {},
791
+ modelValue: {},
792
+ messages: {},
793
+ attempted: { type: Boolean }
794
+ },
795
+ emits: ["update:modelValue", "query", "reset"],
796
+ setup(e, { emit: t }) {
797
+ const a = e, r = t, n = B({ ...a.modelValue });
798
+ Q(
799
+ () => a.modelValue,
800
+ (p) => {
801
+ n.value = { ...p };
802
+ }
803
+ );
804
+ const o = k(
805
+ () => a.defs.map((p) => ({
806
+ def: p,
807
+ label: p.label ?? p.field,
808
+ value: n.value[p.field] ?? ""
809
+ }))
810
+ );
811
+ function l(p, m) {
812
+ n.value = { ...n.value, [p]: m }, r("update:modelValue", { ...n.value });
813
+ }
814
+ function u(p) {
815
+ const m = a.defs.find((d) => d.field === p);
816
+ return a.attempted && m?.required === !0 && !(n.value[p] ?? "").trim();
817
+ }
818
+ return (p, m) => (P(), $("div", In, [
819
+ F("span", Dn, C(e.messages.paramsTitle), 1),
820
+ F("div", On, [
821
+ (P(!0), $(Ee, null, We(o.value, (d) => (P(), $("label", {
822
+ key: d.def.field,
823
+ class: oe(["mrp-param", { "mrp-param-missing": u(d.def.field) }])
824
+ }, [
825
+ F("span", Wn, [
826
+ et(C(d.label), 1),
827
+ d.def.required ? (P(), $("i", Bn, "*")) : H("", !0)
828
+ ]),
829
+ (d.def.type ?? "text") === "select" ? (P(), $("select", {
830
+ key: 0,
831
+ class: "mrp-param-input",
832
+ value: d.value,
833
+ onChange: (f) => l(d.def.field, f.target.value),
834
+ onKeydown: m[0] || (m[0] = mt((f) => p.$emit("query"), ["enter"]))
835
+ }, [
836
+ F("option", Ln, C(d.def.placeholder ?? `请选择${d.label}`), 1),
837
+ (P(!0), $(Ee, null, We(d.def.options ?? [], (f) => (P(), $("option", {
838
+ key: f.value,
839
+ value: f.value
840
+ }, C(f.label), 9, zn))), 128))
841
+ ], 40, An)) : (P(), $("input", {
842
+ key: 1,
843
+ class: "mrp-param-input",
844
+ type: d.def.type === "number" ? "number" : d.def.type === "date" ? "date" : "text",
845
+ placeholder: d.def.placeholder ?? `请输入${d.label}`,
846
+ value: d.value,
847
+ onInput: (f) => l(d.def.field, f.target.value),
848
+ onKeydown: m[1] || (m[1] = mt((f) => p.$emit("query"), ["enter"]))
849
+ }, null, 40, Hn))
850
+ ], 2))), 128))
851
+ ]),
852
+ F("div", qn, [
853
+ F("button", {
854
+ class: "mrp-nav mrp-param-query",
855
+ type: "button",
856
+ onClick: m[2] || (m[2] = (d) => p.$emit("query"))
857
+ }, C(e.messages.query), 1),
858
+ F("button", {
859
+ class: "mrp-nav",
860
+ type: "button",
861
+ onClick: m[3] || (m[3] = (d) => p.$emit("reset"))
862
+ }, C(e.messages.reset), 1)
863
+ ])
864
+ ]));
865
+ }
866
+ }), jn = /* @__PURE__ */ st(Nn, [["__scopeId", "data-v-aafce92d"]]), Un = {
867
+ title: "报表预览",
868
+ prevPage: "‹ 上一页",
869
+ nextPage: "下一页 ›",
870
+ pageInfo: "{cur} / {total}",
871
+ fitWidth: "适宽",
872
+ exportHtml: "导出 HTML",
873
+ exportPdf: "导出 PDF",
874
+ exportExcel: "导出 Excel",
875
+ exportImage: "导出图片",
876
+ exportWord: "导出 Word",
877
+ exporting: "正在生成 {format}…",
878
+ print: "打印",
879
+ pdfWindow: "PDF 窗口",
880
+ loading: "报表渲染中…",
881
+ empty: "暂无预览数据",
882
+ errorPrefix: "",
883
+ retry: "重试",
884
+ pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
885
+ searchPlaceholder: "搜索报表内容",
886
+ matchInfo: "{cur}/{total}",
887
+ prevMatch: "‹",
888
+ nextMatch: "›",
889
+ thumbnails: "缩略图",
890
+ paramsTitle: "查询条件",
891
+ query: "查 询",
892
+ reset: "重 置",
893
+ paramRequired: "请填写{label}",
894
+ searching: "搜索中…"
895
+ }, Vn = {
896
+ shellBg: "#525659",
897
+ shellFg: "#e8e8e8",
898
+ toolbarBg: "#323639",
899
+ toolbarBorder: "#22252a",
900
+ toolbarFg: "#e8e8e8",
901
+ btnFg: "#cfcfcf",
902
+ btnBorder: "#4a4d52",
903
+ btnHoverBg: "#414549",
904
+ btnHoverFg: "#ffffff",
905
+ btnActiveBg: "#2d5fb8"
906
+ };
907
+ function Kn(e = {}) {
908
+ return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
909
+ }
910
+ function Er(e) {
911
+ return e;
912
+ }
913
+ const fe = {
914
+ showExport: !0,
915
+ showPrint: !0,
916
+ showPdfWindow: !0,
917
+ showParams: !0,
918
+ gapPx: 18,
919
+ pdfFontUrl: "/simhei.ttf",
920
+ logger: console
921
+ }, $r = { warn: () => {
922
+ }, info: () => {
923
+ } };
924
+ function Oe(e, t) {
925
+ return {
926
+ ...e,
927
+ ...t,
928
+ theme: { ...e?.theme, ...t?.theme },
929
+ messages: { ...e?.messages, ...t?.messages },
930
+ preview: { ...e?.preview, ...t?.preview },
931
+ xlsx: { ...e?.xlsx, ...t?.xlsx }
932
+ };
933
+ }
934
+ function Yn(e, t) {
935
+ const a = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, r = Oe(e?.defaults, a);
936
+ return {
937
+ showExport: r.showExport ?? fe.showExport,
938
+ showPrint: r.showPrint ?? fe.showPrint,
939
+ showPdfWindow: r.showPdfWindow ?? fe.showPdfWindow,
940
+ showParams: r.showParams ?? fe.showParams,
941
+ gapPx: r.gapPx ?? fe.gapPx,
942
+ pdfFontUrl: r.pdfFontUrl ?? fe.pdfFontUrl,
943
+ theme: { ...Vn, ...r.theme },
944
+ messages: { ...Un, ...r.messages },
945
+ logger: r.logger ?? fe.logger,
946
+ preview: {
947
+ overscanPages: ht(r.preview?.overscanPages, 1, 10, !0),
948
+ searchDebounceMs: ht(r.preview?.searchDebounceMs, 200, 2e3)
949
+ },
950
+ xlsx: { ...r.xlsx }
951
+ };
952
+ }
953
+ function ht(e, t, a, r = !1) {
954
+ if (e == null || !Number.isFinite(e)) return t;
955
+ const n = Math.max(0, Math.min(a, e));
956
+ return r ? Math.floor(n) : n;
957
+ }
958
+ function Zn(e) {
959
+ const t = {};
960
+ return e.shellBg != null && (t["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (t["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (t["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (t["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (t["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (t["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (t["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (t["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (t["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (t["--mrp-btn-active-bg"] = e.btnActiveBg), t;
961
+ }
962
+ function kr(e) {
963
+ const t = Be(tt, null), a = k(() => {
964
+ const r = t?.value ?? null, n = "defaults" in e || "presets" in e || "defaultPreset" in e ? Kn(e) : { defaults: e, presets: {} };
965
+ if (!r) return n;
966
+ const o = { ...r.presets, ...n.presets };
967
+ for (const l of Object.keys(o))
968
+ o[l] = Oe(
969
+ Oe(r.presets[l], n.defaults),
970
+ n.presets[l]
971
+ );
972
+ return {
973
+ defaults: Oe(r.defaults, n.defaults),
974
+ presets: o,
975
+ defaultPreset: n.defaultPreset ?? r.defaultPreset
976
+ };
977
+ });
978
+ yt(tt, a);
979
+ }
980
+ function Jn() {
981
+ return Be(tt, k(() => null));
982
+ }
983
+ const gt = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map(), Gn = 15e3;
984
+ function nt(e, t) {
985
+ return Object.assign(new Error(e), { cause: t });
986
+ }
987
+ function Pe(e, t) {
988
+ return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
989
+ }
990
+ function ze(e) {
991
+ if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
992
+ const t = nt("PDF 字体检查已取消", e?.reason);
993
+ return t.name = "AbortError", t;
994
+ }
995
+ async function Xn(e, t) {
996
+ let a = !1;
997
+ const r = setTimeout(() => {
998
+ a = !0, t.abort();
999
+ }, Gn);
1000
+ try {
1001
+ const n = await fetch(e, { method: "HEAD", signal: t.signal });
1002
+ if (t.signal.aborted) throw ze(t.signal);
1003
+ if (n.status === 405 || n.status === 501 || n.type === "opaque")
1004
+ return {
1005
+ status: "unverified",
1006
+ fontUrl: e,
1007
+ message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
1008
+ };
1009
+ if (!n.ok) {
1010
+ const l = new Error(`字体请求返回 HTTP ${n.status}`);
1011
+ return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
1012
+ }
1013
+ const o = n.headers.get("content-type") ?? "";
1014
+ if (/text\/html|application\/xhtml\+xml/i.test(o)) {
1015
+ const l = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
1016
+ return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
1017
+ }
1018
+ if (/^text\//i.test(o) || /(?:\/|\+)json(?:\s*;|$)/i.test(o)) {
1019
+ const l = new Error(`字体 URL 返回 ${o} 文本响应,不是字体文件`);
1020
+ return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
1021
+ }
1022
+ return {
1023
+ status: "available",
1024
+ fontUrl: e,
1025
+ message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
1026
+ };
1027
+ } catch (n) {
1028
+ if (t.signal.aborted && !a) throw ze(t.signal);
1029
+ return {
1030
+ status: "error",
1031
+ fontUrl: e,
1032
+ message: Pe(e, a ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
1033
+ cause: n
1034
+ };
1035
+ } finally {
1036
+ clearTimeout(r);
1037
+ }
1038
+ }
1039
+ function Qn(e, t) {
1040
+ if (t?.aborted) return Promise.reject(ze(t));
1041
+ if (!e)
1042
+ return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
1043
+ const a = gt.get(e);
1044
+ if (a) return Promise.resolve(a);
1045
+ let r = ve.get(e);
1046
+ if (!r) {
1047
+ const o = new AbortController();
1048
+ r = { controller: o, promise: Xn(e, o), subscribers: 0 };
1049
+ const l = r;
1050
+ ve.set(e, l), l.promise = l.promise.then((u) => (!o.signal.aborted && u.status === "available" && gt.set(e, u), u)).finally(() => {
1051
+ ve.get(e) === l && ve.delete(e);
1052
+ });
1053
+ }
1054
+ const n = r;
1055
+ return n.subscribers++, new Promise((o, l) => {
1056
+ let u = !1;
1057
+ const p = () => u ? !1 : (u = !0, n.subscribers--, t?.removeEventListener("abort", m), !0), m = () => {
1058
+ p() && (n.subscribers === 0 && (ve.get(e) === n && ve.delete(e), n.controller.abort()), l(ze(t)));
1059
+ };
1060
+ t?.addEventListener("abort", m, { once: !0 }), n.promise.then(
1061
+ (d) => {
1062
+ p() && o(d);
1063
+ },
1064
+ (d) => {
1065
+ p() && l(d);
1066
+ }
1067
+ ), t?.aborted && m();
1068
+ });
1069
+ }
1070
+ function _n(e = { fontUrl: "/simhei.ttf" }) {
1071
+ let t = null;
1072
+ const a = async (r, n) => {
1073
+ t || (t = await import("@agile-team/mach-report/pdf"));
1074
+ let o = null;
1075
+ if (e.fontUrl)
1076
+ try {
1077
+ if (o = await t.loadFontWithCache(e.fontUrl, { strict: !0 }), !o?.byteLength) throw new Error("字体文件为空或加载失败");
1078
+ } catch (f) {
1079
+ const h = f instanceof Error ? f.message : String(f);
1080
+ throw nt(Pe(e.fontUrl, h), f);
1081
+ }
1082
+ let l;
1083
+ try {
1084
+ l = await t.renderPlanToPdf(r, o ? { customFontBytes: o } : {});
1085
+ } catch (f) {
1086
+ if (!o) throw f;
1087
+ const h = f instanceof Error ? f.message : String(f);
1088
+ throw nt(`PDF 生成失败:${h}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, f);
1089
+ }
1090
+ const { bytes: u, unsupportedTextCount: p, pageErrors: m, fidelityWarnings: d } = l;
1091
+ if (p > 0)
1092
+ throw new Error(`PDF 中有 ${p} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
1093
+ if (m.length > 0)
1094
+ throw new Error(`PDF 有 ${m.length} 页渲染失败:${m[0]}`);
1095
+ return d.length > 0 && n?.(`PDF 有 ${d.length} 处版式降级:${d.slice(0, 2).join(";")}`), u;
1096
+ };
1097
+ return a.checkFont = (r) => Qn(e.fontUrl, r), a;
1098
+ }
1099
+ class he extends Error {
1100
+ constructor(t, a, r) {
1101
+ super(a), this.name = "MachReportError", this.code = t, this.cause = r;
1102
+ }
1103
+ }
1104
+ function er(e) {
1105
+ return e instanceof he ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
1106
+ }
1107
+ const tr = {
1108
+ key: 2,
1109
+ class: "mrp-export-notice mrp-export-warning",
1110
+ role: "status"
1111
+ }, nr = { class: "mrp-main" }, rr = {
1112
+ key: 0,
1113
+ class: "mrp-state"
1114
+ }, or = {
1115
+ key: 1,
1116
+ class: "mrp-state mrp-error"
1117
+ }, ar = {
1118
+ key: 2,
1119
+ class: "mrp-state"
1120
+ }, sr = ["data-page"], lr = ["onClick"], ir = ["data-thumb"], ur = { class: "mrp-thumb-no" }, cr = { class: "mrp-overlay" }, dr = {
1121
+ key: 3,
1122
+ class: "mrp-debug",
1123
+ "aria-hidden": "true"
1124
+ }, Se = 96 / 25.4, bt = "mach-report:ui", wt = "mach-report:ui:wide", fr = /* @__PURE__ */ rt({
1125
+ __name: "ReportPreview",
1126
+ props: {
1127
+ reportId: {
1128
+ type: [String, Array],
1129
+ default: null
1130
+ },
1131
+ params: {
1132
+ type: Object,
1133
+ default: () => ({})
1134
+ },
1135
+ height: { type: String, default: "100vh" },
1136
+ autoLoad: { type: Boolean, default: !0 },
1137
+ /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
1138
+ showExport: { type: Boolean, default: void 0 },
1139
+ showPrint: { type: Boolean, default: void 0 },
1140
+ showPdfWindow: { type: Boolean, default: void 0 },
1141
+ /** 页间距(px);不传走配置中心 */
1142
+ gapPx: { type: Number, default: void 0 },
1143
+ /** 工具栏/状态文案覆写(不传走配置中心 messages) */
1144
+ messages: { type: Object, default: void 0 },
1145
+ /** 启用的 preset 名(不传用配置中心 defaultPreset) */
1146
+ preset: { type: String, default: void 0 },
1147
+ /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
1148
+ debug: { type: Boolean, default: !1 },
1149
+ /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
1150
+ paramDefs: {
1151
+ type: Array,
1152
+ default: void 0
1153
+ },
1154
+ /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
1155
+ showParams: { type: Boolean, default: void 0 },
1156
+ fetcher: {
1157
+ type: Function,
1158
+ default: null
1159
+ }
1160
+ },
1161
+ emits: ["loaded", "error", "warning"],
1162
+ setup(e, { expose: t, emit: a }) {
1163
+ Nt((i) => ({
1164
+ v8eb72344: S.value + "px"
1165
+ }));
1166
+ const r = e, n = a, o = Ie(null), l = B(!1), u = B(""), p = Ie(null), m = B(null), d = B(!1), f = Ie(Object.freeze({ status: "unchecked", fontUrl: "" })), h = B(null), v = B(1), A = B(null), W = B(null), b = B(null), I = B(!1), E = wn(), D = k(() => !!o.value?.pages.length && o.value.pages.every((i) => i.layout === "wide")), S = k(() => Math.max(0, U.value));
1167
+ let M = bt;
1168
+ const q = Be(en, null), K = Be(tn, null), V = k(() => Et(r.reportId)), Y = k(() => r.fetcher ?? q), O = k(() => o.value?.pages.length ?? 0), ae = k(() => Object.freeze({
1169
+ loading: l.value,
1170
+ hasPlan: O.value > 0,
1171
+ pageCount: O.value,
1172
+ currentPage: v.value,
1173
+ exporting: m.value,
1174
+ printing: d.value,
1175
+ canExport: !l.value && O.value > 0 && m.value === null,
1176
+ canPrint: !l.value && O.value > 0 && !d.value,
1177
+ error: p.value,
1178
+ pdfFont: f.value
1179
+ }));
1180
+ function ee(i, g, w) {
1181
+ p.value = Object.freeze({ message: i, code: g, cause: w }), n("error", i, { code: g, cause: w });
1182
+ }
1183
+ const pe = Jn(), s = k(() => Yn(pe.value, r.preset)), c = k(() => ({
1184
+ ...s.value.messages,
1185
+ ...r.messages
1186
+ })), y = k(() => r.showExport ?? s.value.showExport), R = k(() => r.showPrint ?? s.value.showPrint), T = k(() => r.showPdfWindow ?? s.value.showPdfWindow), U = k(() => r.gapPx ?? (D.value ? 0 : s.value.gapPx)), J = k(() => r.showParams ?? s.value.showParams);
1187
+ let G = null, qe = null;
1188
+ function lt() {
1189
+ if (K) return K;
1190
+ const i = s.value.pdfFontUrl;
1191
+ return (!qe || G !== i) && (G = i, qe = _n({ fontUrl: i })), qe;
1192
+ }
1193
+ let $e = 0, ge = null, ke = null, se = !1;
1194
+ function Ne() {
1195
+ $e++, ge?.abort(), ge = null;
1196
+ }
1197
+ async function Ce() {
1198
+ if (se) throw new he("config", "报表预览已卸载");
1199
+ Ne();
1200
+ const i = $e, g = new AbortController();
1201
+ ge = g;
1202
+ const w = s.value.pdfFontUrl;
1203
+ f.value = Object.freeze({ status: "checking", fontUrl: w });
1204
+ try {
1205
+ const N = lt(), j = N.checkFont ? await N.checkFont(g.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
1206
+ return !se && i === $e && !g.signal.aborted && (f.value = Object.freeze({ ...j })), j;
1207
+ } catch (N) {
1208
+ if (g.signal.aborted) throw N;
1209
+ const j = {
1210
+ status: "error",
1211
+ fontUrl: w,
1212
+ message: N instanceof Error ? N.message : "PDF 字体检查失败",
1213
+ cause: N
1214
+ };
1215
+ return !se && i === $e && (f.value = Object.freeze(j)), j;
1216
+ } finally {
1217
+ ge === g && (ge = null);
1218
+ }
1219
+ }
1220
+ function Ct() {
1221
+ Ce().catch(() => {
1222
+ });
1223
+ }
1224
+ Q(
1225
+ [o, () => s.value.pdfFontUrl, y, T],
1226
+ () => {
1227
+ const i = f.value.fontUrl === s.value.pdfFontUrl;
1228
+ Ne(), (!i || f.value.status === "checking") && (f.value = Object.freeze({ status: "unchecked", fontUrl: s.value.pdfFontUrl })), !se && O.value > 0 && (y.value || T.value) && Ce().catch(() => {
1229
+ });
1230
+ },
1231
+ { immediate: !0 }
1232
+ );
1233
+ const le = k(
1234
+ () => r.paramDefs ?? Y.value?.getParamDefs?.(V.value) ?? []
1235
+ ), ce = B({}), je = B(!1);
1236
+ function be(i) {
1237
+ const g = {};
1238
+ for (const w of i)
1239
+ g[w.field] = r.params[w.field] ?? w.defaultValue ?? "";
1240
+ ce.value = g, je.value = !1;
1241
+ }
1242
+ be(le.value), Q(le, (i) => be(i)), Q(V, () => be(le.value)), Q(() => JSON.stringify(r.params), () => be(le.value));
1243
+ const Mt = k(() => {
1244
+ const i = { ...r.params };
1245
+ for (const [g, w] of Object.entries(ce.value))
1246
+ w === "" ? delete i[g] : i[g] = w;
1247
+ return i;
1248
+ });
1249
+ function Ft() {
1250
+ return le.value.filter(
1251
+ (i) => i.required === !0 && !(ce.value[i.field] ?? "").trim()
1252
+ );
1253
+ }
1254
+ function Rt() {
1255
+ je.value = !0;
1256
+ const i = Ft();
1257
+ if (i.length > 0) {
1258
+ const g = i[0].label ?? i[0].field, w = c.value.paramRequired.replace("{label}", g);
1259
+ u.value = w, ee(w, "param");
1260
+ return;
1261
+ }
1262
+ de();
1263
+ }
1264
+ function Tt() {
1265
+ be(le.value);
1266
+ }
1267
+ const St = k(() => ({
1268
+ height: r.height,
1269
+ ...Zn(s.value.theme)
1270
+ })), { zoom: Z, zoomMode: we, applyFitZoom: it, setZoom: ye } = on(() => ({
1271
+ viewport: W.value,
1272
+ pageWidthPx: Ue.contentSize.value.w || 210 * Se
1273
+ })), Ue = rn(o, Z, {
1274
+ pxPerMm: Se,
1275
+ gapPx: U,
1276
+ overscan: k(() => s.value.preview.overscanPages)
1277
+ }), { contentSize: Ve, windowRange: xe, visiblePages: ut, makeScrollHandler: It, refreshViewport: Ke } = Ue, Dt = It(v, O);
1278
+ function Ye(i) {
1279
+ ye(i * 100);
1280
+ }
1281
+ function Me() {
1282
+ Ot(), o.value = null, v.value = 1, L.reset();
1283
+ }
1284
+ let ie = 0, te = null;
1285
+ async function de() {
1286
+ if (se) return;
1287
+ const i = ++ie;
1288
+ te?.abort(), te = null;
1289
+ const g = Y.value;
1290
+ if (l.value = !1, p.value = null, V.value.length === 0) {
1291
+ u.value = "缺少报表 ID", Me(), ee(u.value, "param");
1292
+ return;
1293
+ }
1294
+ if (!g) {
1295
+ u.value = "未提供渲染数据源 fetcher", Me(), ee(u.value, "config");
1296
+ return;
1297
+ }
1298
+ l.value = !0, u.value = "", h.value = null, Me();
1299
+ const w = E.start(), N = new AbortController();
1300
+ te = N;
1301
+ const j = /* @__PURE__ */ new Set();
1302
+ function Re(z) {
1303
+ i !== ie || N.signal.aborted || j.has(z) || (j.add(z), s.value.logger.warn("[mach-report] 报表告警:", z), n("warning", z));
1304
+ }
1305
+ try {
1306
+ const z = await g({
1307
+ reportIds: V.value,
1308
+ params: { ...Mt.value },
1309
+ signal: N.signal,
1310
+ onWarning: Re
1311
+ });
1312
+ if (i !== ie) return;
1313
+ const X = Jt(z);
1314
+ if (!X.ok) {
1315
+ const Te = X.errors.slice(0, 3).map((pt) => `${pt.path}: ${pt.message}`).join("; ");
1316
+ throw new he(
1317
+ "validate",
1318
+ `渲染计划校验失败(${X.errors.length} 处): ${Te}`
1319
+ );
1320
+ }
1321
+ if (X.warnings.forEach((Te) => Re(`${Te.path}: ${Te.message}`)), i !== ie || N.signal.aborted) return;
1322
+ o.value = z, v.value = 1, E.end(w), W.value && (W.value.scrollTop = 0, W.value.scrollLeft = 0);
1323
+ const ue = D.value ? wt : bt;
1324
+ ue !== M && (M = ue, ft()), we.value === "fit" && it(), n("loaded", z.pages.length);
1325
+ } catch (z) {
1326
+ if (i !== ie) return;
1327
+ const X = z instanceof he ? z : z instanceof Gt ? new he(z.code, z.message, z.cause) : new he(
1328
+ "fetch",
1329
+ z instanceof Error ? z.message : "预览加载失败",
1330
+ z
1331
+ );
1332
+ u.value = X.message;
1333
+ const ue = er(X);
1334
+ ee(X.message, ue.code, ue.cause);
1335
+ } finally {
1336
+ i === ie && (l.value = !1), te === N && (te = null);
1337
+ }
1338
+ }
1339
+ function ne(i) {
1340
+ if (se || O.value <= 0) return;
1341
+ const g = Math.max(1, Math.min(O.value, i));
1342
+ v.value = g;
1343
+ const w = W.value;
1344
+ w && (w.scrollTop = Ue.pageOffsetPx(g - 1) * Z.value, Ke(w));
1345
+ }
1346
+ const Fe = sn(o, {
1347
+ getPdfExporter: lt,
1348
+ getXlsxOptions: () => s.value.xlsx,
1349
+ onError: (i, g) => {
1350
+ h.value = { kind: "error", message: i }, ee(i, g ?? "print");
1351
+ },
1352
+ onWarning: (i) => {
1353
+ h.value = { kind: "warning", message: i }, n("warning", i);
1354
+ },
1355
+ onBusy: (i) => {
1356
+ m.value = i, i ? h.value = {
1357
+ kind: "progress",
1358
+ message: c.value.exporting.replace("{format}", i)
1359
+ } : h.value?.kind === "progress" && (h.value = null);
1360
+ },
1361
+ onPrinting: (i) => {
1362
+ d.value = i;
1363
+ }
1364
+ }), { releasePrintFrame: Ot, dispose: Wt } = Fe;
1365
+ async function Ze() {
1366
+ p.value = null, await Fe.print();
1367
+ }
1368
+ async function Je(i) {
1369
+ p.value = null, await Fe.exportAs(i);
1370
+ }
1371
+ function Ge() {
1372
+ p.value = null, Fe.openPdfWindow();
1373
+ }
1374
+ async function ct(i, g = {}) {
1375
+ se || (ce.value = { ...ce.value, ...i }, g.reload !== !1 && await de());
1376
+ }
1377
+ yt(nn, {
1378
+ reload: de,
1379
+ print: Ze,
1380
+ exportAs: Je,
1381
+ openPdfWindow: Ge,
1382
+ gotoPage: ne,
1383
+ setParams: ct,
1384
+ checkPdfFont: Ce,
1385
+ get state() {
1386
+ return ae.value;
1387
+ }
1388
+ });
1389
+ const L = hn({
1390
+ plan: o,
1391
+ gotoPage: ne,
1392
+ debounceMs: k(() => s.value.preview.searchDebounceMs),
1393
+ highlight: un,
1394
+ clearHighlights: ln
1395
+ });
1396
+ function Bt(i) {
1397
+ i.ctrlKey && (i.preventDefault(), Ye(Z.value * (i.deltaY < 0 ? 1.1 : 1 / 1.1)));
1398
+ }
1399
+ function At(i) {
1400
+ if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "f") {
1401
+ i.preventDefault(), L.visible.value || L.toggle();
1402
+ return;
1403
+ }
1404
+ switch (i.key) {
1405
+ case "PageDown":
1406
+ i.preventDefault(), ne(v.value + 1);
1407
+ break;
1408
+ case "PageUp":
1409
+ i.preventDefault(), ne(v.value - 1);
1410
+ break;
1411
+ case "Home":
1412
+ i.preventDefault(), ne(1);
1413
+ break;
1414
+ case "End":
1415
+ i.preventDefault(), ne(O.value);
1416
+ break;
1417
+ case "+":
1418
+ case "=":
1419
+ i.preventDefault(), Ye(Z.value * 1.1);
1420
+ break;
1421
+ case "-":
1422
+ i.preventDefault(), Ye(Z.value / 1.1);
1423
+ break;
1424
+ }
1425
+ }
1426
+ function Lt() {
1427
+ try {
1428
+ localStorage.setItem(
1429
+ M,
1430
+ JSON.stringify({ zoomMode: we.value === "fit" ? "fit" : Math.round(Z.value * 100) })
1431
+ );
1432
+ } catch {
1433
+ }
1434
+ }
1435
+ Q([we, Z], Lt);
1436
+ let Xe = "";
1437
+ function dt(i = !1) {
1438
+ const g = L.activeMatch.value;
1439
+ if (!D.value || !g) return;
1440
+ const w = `${L.query.value}:${L.matchIndex.value}:${g.pageIndex}`;
1441
+ if (!i && w === Xe) return;
1442
+ const j = A.value?.querySelector(`[data-page="${g.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[g.occurrence];
1443
+ j && (j.scrollIntoView?.({ block: "nearest", inline: "nearest" }), Xe = w);
1444
+ }
1445
+ vt(() => {
1446
+ const i = o.value;
1447
+ if (!i) return;
1448
+ const g = L.activeMatch.value;
1449
+ L.matchIndex.value, g || (Xe = ""), ut.value;
1450
+ const w = A.value;
1451
+ if (!w) return;
1452
+ w.querySelectorAll(".mrp-page-holder").forEach((j) => {
1453
+ const Re = Number(j.dataset.page ?? 0) - 1, z = i.pages[Re];
1454
+ if (!z || j.childElementCount > 0) {
1455
+ if (j.firstElementChild) {
1456
+ const ue = j.firstElementChild;
1457
+ L.clear(ue), L.apply(ue);
1458
+ }
1459
+ return;
1460
+ }
1461
+ j.style.width = `${z.pageWidthMm * Se}px`;
1462
+ const X = xt(z, 96, {}, document);
1463
+ L.apply(X), j.appendChild(X);
1464
+ }), dt();
1465
+ }, { flush: "post" }), Q(() => L.query.value, (i) => {
1466
+ i || A.value?.querySelectorAll(".mrp-page-holder").forEach((g) => {
1467
+ L.clear(g);
1468
+ });
1469
+ });
1470
+ const _ = bn(o, {
1471
+ thumbsRoot: b,
1472
+ visible: I,
1473
+ renderThumbCanvas: (i) => {
1474
+ try {
1475
+ const g = o.value.pages[i], w = Math.min(0.2, 116 / Math.max(1, g.pageWidthMm * Se)), { canvases: N } = Xt(o.value, { start: i, end: i, dpr: w });
1476
+ return N[0] ?? null;
1477
+ } catch {
1478
+ return null;
1479
+ }
1480
+ }
1481
+ });
1482
+ vt(() => {
1483
+ _.schedule();
1484
+ }, { flush: "post" });
1485
+ const zt = k(() => r.debug), { debugStats: me } = gn(zt, {
1486
+ plan: o,
1487
+ pageCount: O,
1488
+ windowRange: xe,
1489
+ zoom: Z,
1490
+ loadMs: E.loadMs
1491
+ });
1492
+ function Qe() {
1493
+ Ke(W.value), _.schedule(), we.value === "fit" && it(), dt(!0);
1494
+ }
1495
+ function ft() {
1496
+ ye(M === wt ? 100 : "fit");
1497
+ try {
1498
+ const i = JSON.parse(localStorage.getItem(M) ?? "{}");
1499
+ i.zoomMode === "fit" ? ye("fit") : typeof i.zoomMode == "number" && ye(i.zoomMode);
1500
+ } catch {
1501
+ }
1502
+ }
1503
+ return jt(() => {
1504
+ window.addEventListener("resize", Qe), typeof ResizeObserver < "u" && W.value && (ke = new ResizeObserver(Qe), ke.observe(W.value)), Ke(W.value), ft(), r.autoLoad && de();
1505
+ }), Ut(() => {
1506
+ se = !0, Ne(), ie++, te?.abort(), te = null, window.removeEventListener("resize", Qe), ke?.disconnect(), ke = null, _.destroy(), L.reset(), Wt();
1507
+ }), Q(
1508
+ () => [JSON.stringify(V.value), JSON.stringify(r.params), Y.value],
1509
+ () => {
1510
+ if (r.autoLoad) {
1511
+ de();
1512
+ return;
1513
+ }
1514
+ ie++, te?.abort(), te = null, l.value = !1, u.value = "", p.value = null, h.value = null, Me();
1515
+ }
1516
+ ), t({ reload: de, print: Ze, exportAs: Je, openPdfWindow: Ge, gotoPage: ne, setParams: ct, checkPdfFont: Ce, state: ae }), (i, g) => (P(), $("div", {
1517
+ class: oe(["mach-report-preview", { "mrp-wide-report": D.value }]),
1518
+ style: re(St.value)
1519
+ }, [
1520
+ J.value && le.value.length > 0 ? (P(), Vt(jn, {
1521
+ key: 0,
1522
+ defs: le.value,
1523
+ modelValue: ce.value,
1524
+ "onUpdate:modelValue": g[0] || (g[0] = (w) => ce.value = w),
1525
+ messages: c.value,
1526
+ attempted: je.value,
1527
+ onQuery: Rt,
1528
+ onReset: Tt
1529
+ }, null, 8, ["defs", "modelValue", "messages", "attempted"])) : H("", !0),
1530
+ Kt(Sn, {
1531
+ "page-count": O.value,
1532
+ "current-page": v.value,
1533
+ "zoom-mode": x(we),
1534
+ zoom: x(Z),
1535
+ "show-export": y.value,
1536
+ "show-print": R.value,
1537
+ "show-pdf-window": T.value,
1538
+ messages: c.value,
1539
+ search: { visible: x(L).visible.value, query: x(L).query.value, matchIndex: x(L).matchIndex.value, matchCount: x(L).matchCount.value, searching: x(L).searching.value },
1540
+ "thumbs-visible": I.value,
1541
+ onGoto: ne,
1542
+ onZoom: x(ye),
1543
+ onExport: g[1] || (g[1] = (w) => Je(w)),
1544
+ onPrint: Ze,
1545
+ onPdfWindow: Ge,
1546
+ onSearchInput: x(L).onInput,
1547
+ onSearchNav: x(L).onNav,
1548
+ onSearchToggle: x(L).toggle,
1549
+ onThumbsToggle: g[2] || (g[2] = (w) => I.value = !I.value)
1550
+ }, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "search", "thumbs-visible", "onZoom", "onSearchInput", "onSearchNav", "onSearchToggle"]),
1551
+ h.value ? (P(), $("div", {
1552
+ key: 1,
1553
+ class: oe(["mrp-export-notice", `mrp-export-${h.value.kind}`]),
1554
+ role: "alert"
1555
+ }, C(h.value.message), 3)) : H("", !0),
1556
+ f.value.status === "error" && (y.value || T.value) ? (P(), $("div", tr, [
1557
+ et(C(c.value.pdfFontUnavailable) + " ", 1),
1558
+ F("button", {
1559
+ type: "button",
1560
+ onClick: Ct
1561
+ }, C(c.value.retry), 1)
1562
+ ])) : H("", !0),
1563
+ F("div", nr, [
1564
+ F("div", {
1565
+ ref_key: "viewportRef",
1566
+ ref: W,
1567
+ class: "mrp-body",
1568
+ tabindex: "0",
1569
+ onWheel: Bt,
1570
+ onKeydown: At,
1571
+ onScrollPassive: g[3] || (g[3] = (w) => x(Dt)(w.target))
1572
+ }, [
1573
+ l.value ? (P(), $("div", rr, C(c.value.loading), 1)) : u.value ? (P(), $("div", or, [
1574
+ et(C(u.value) + " ", 1),
1575
+ F("button", {
1576
+ class: "mrp-retry",
1577
+ type: "button",
1578
+ onClick: de
1579
+ }, C(c.value.retry), 1)
1580
+ ])) : !o.value || O.value === 0 ? (P(), $("div", ar, C(c.value.empty), 1)) : (P(), $("div", {
1581
+ key: 3,
1582
+ class: "mrp-scale",
1583
+ style: re({ width: `${x(Ve).w * x(Z)}px`, height: `${x(Ve).h * x(Z)}px` })
1584
+ }, [
1585
+ F("div", {
1586
+ ref_key: "containerRef",
1587
+ ref: A,
1588
+ class: "mrp-scale-inner",
1589
+ style: re({ transform: `scale(${x(Z)})`, transformOrigin: "top left", width: `${x(Ve).w}px` })
1590
+ }, [
1591
+ x(xe).padTopPx > 0 ? (P(), $("div", {
1592
+ key: 0,
1593
+ class: "mrp-spacer-top",
1594
+ style: re({ height: `${x(xe).padTopPx}px` }),
1595
+ "aria-hidden": "true"
1596
+ }, null, 4)) : H("", !0),
1597
+ (P(!0), $(Ee, null, We(x(ut), (w) => (P(), $("div", {
1598
+ key: w.index,
1599
+ class: "mrp-page-holder",
1600
+ "data-page": w.index + 1
1601
+ }, null, 8, sr))), 128)),
1602
+ x(xe).padBottomPx > 0 ? (P(), $("div", {
1603
+ key: 1,
1604
+ class: "mrp-spacer-bottom",
1605
+ style: re({ height: `${x(xe).padBottomPx}px` }),
1606
+ "aria-hidden": "true"
1607
+ }, null, 4)) : H("", !0)
1608
+ ], 4)
1609
+ ], 4))
1610
+ ], 544),
1611
+ I.value && O.value > 0 ? (P(), $("aside", {
1612
+ key: 0,
1613
+ ref_key: "thumbsRef",
1614
+ ref: b,
1615
+ class: "mrp-thumbs",
1616
+ onScrollPassive: g[4] || (g[4] = //@ts-ignore
1617
+ (...w) => x(_).onScroll && x(_).onScroll(...w))
1618
+ }, [
1619
+ x(_).windowRange.value.padTopPx > 0 ? (P(), $("div", {
1620
+ key: 0,
1621
+ class: "mrp-thumb-spacer",
1622
+ style: re({ height: `${x(_).windowRange.value.padTopPx}px` }),
1623
+ "aria-hidden": "true"
1624
+ }, null, 4)) : H("", !0),
1625
+ (P(!0), $(Ee, null, We(x(_).visibleThumbs.value, (w) => (P(), $("div", {
1626
+ key: w.index,
1627
+ class: oe(["mrp-thumb", { "mrp-thumb-active": w.index + 1 === v.value }]),
1628
+ style: re({ height: `${w.height + 20}px` }),
1629
+ onClick: (N) => ne(w.index + 1)
1630
+ }, [
1631
+ F("div", {
1632
+ class: "mrp-thumb-box",
1633
+ "data-thumb": w.index + 1,
1634
+ style: re({ height: `${w.height}px` })
1635
+ }, null, 12, ir),
1636
+ F("span", ur, C(w.index + 1), 1)
1637
+ ], 14, lr))), 128)),
1638
+ x(_).windowRange.value.padBottomPx > 0 ? (P(), $("div", {
1639
+ key: 1,
1640
+ class: "mrp-thumb-spacer",
1641
+ style: re({ height: `${x(_).windowRange.value.padBottomPx}px` }),
1642
+ "aria-hidden": "true"
1643
+ }, null, 4)) : H("", !0)
1644
+ ], 544)) : H("", !0)
1645
+ ]),
1646
+ F("div", cr, [
1647
+ Yt(i.$slots, "default", {}, void 0, !0)
1648
+ ]),
1649
+ x(me) ? (P(), $("div", dr, [
1650
+ g[5] || (g[5] = F("div", null, "mach-report debug", -1)),
1651
+ F("div", null, "pages: " + C(x(me).pages) + " | window: [" + C(x(me).window) + "]", 1),
1652
+ F("div", null, "zoom: " + C(x(me).zoom) + " | load: " + C(x(me).loadMs), 1),
1653
+ F("div", null, "plan: " + C(x(me).planKB) + "KB", 1)
1654
+ ])) : H("", !0)
1655
+ ], 6));
1656
+ }
1657
+ }), pr = /* @__PURE__ */ st(fr, [["__scopeId", "data-v-48919dc8"]]), Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1658
+ __proto__: null,
1659
+ default: pr
1660
+ }, Symbol.toStringTag, { value: "Module" }));
1661
+ export {
1662
+ Un as D,
1663
+ he as M,
1664
+ _e as P,
1665
+ jn as R,
1666
+ $r as S,
1667
+ Vn as a,
1668
+ pr as b,
1669
+ Sn as c,
1670
+ $t as d,
1671
+ an as e,
1672
+ _n as f,
1673
+ xr as g,
1674
+ Kn as h,
1675
+ Er as i,
1676
+ yr as j,
1677
+ kr as k,
1678
+ er as l,
1679
+ rn as m,
1680
+ Et as n,
1681
+ sn as o,
1682
+ Pr as p,
1683
+ on as q,
1684
+ Yn as r,
1685
+ Cr as s,
1686
+ Zn as t,
1687
+ Jn as u
1688
+ };