@agile-team/mach-report 1.2.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/LICENSE +2 -4
  2. package/LICENSING.md +15 -0
  3. package/README.md +240 -92
  4. package/dist/ReportPreview-Dwdsyk9b.js +1558 -0
  5. package/dist/ReportPreview-VHAIfsz1.cjs +6 -0
  6. package/dist/index.cjs +5 -5
  7. package/dist/index.d.cts +738 -14
  8. package/dist/index.d.ts +738 -14
  9. package/dist/index.js +858 -805
  10. package/dist/pdf.cjs +47 -47
  11. package/dist/pdf.d.cts +155 -6
  12. package/dist/pdf.d.ts +155 -6
  13. package/dist/pdf.js +3542 -3466
  14. package/dist/plugin-Bl00j_CP.cjs +1 -0
  15. package/dist/plugin-DVScnZ4C.js +25 -0
  16. package/dist/report-params-BB85g7mg.js +10 -0
  17. package/dist/report-params-D1NeY-eR.cjs +1 -0
  18. package/dist/sql.cjs +65 -64
  19. package/dist/sql.d.cts +109 -5
  20. package/dist/sql.d.ts +109 -5
  21. package/dist/sql.js +7947 -7922
  22. package/dist/style-CFZ-HE2s.cjs +3 -0
  23. package/dist/{style-6ihHKVCM.js → style-DnmtG7Gl.js} +69 -81
  24. package/dist/style.css +1 -1
  25. package/dist/vue/async.d.cts +769 -335
  26. package/dist/vue/async.d.ts +769 -335
  27. package/dist/vue/index.d.cts +1321 -14
  28. package/dist/vue/index.d.ts +1321 -14
  29. package/dist/vue-async.cjs +1 -1
  30. package/dist/vue-async.js +11 -12
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.js +130 -50
  33. package/dist/xlsx.cjs +20 -20
  34. package/dist/xlsx.d.cts +2292 -5
  35. package/dist/xlsx.d.ts +2292 -5
  36. package/dist/xlsx.js +5452 -5443
  37. package/package.json +7 -13
  38. package/dist/ReportPreview-CJLvkTVn.cjs +0 -6
  39. package/dist/ReportPreview-mZiGtf0L.js +0 -1231
  40. package/dist/builder/template-builder.d.ts +0 -69
  41. package/dist/compat/jh4j-template.d.ts +0 -12
  42. package/dist/defaults.d.ts +0 -27
  43. package/dist/format.d.ts +0 -48
  44. package/dist/layout/paginate.d.ts +0 -97
  45. package/dist/layout/textwrap.d.ts +0 -36
  46. package/dist/manager/api.d.ts +0 -45
  47. package/dist/manager/index.d.ts +0 -2
  48. package/dist/manager/types.d.ts +0 -50
  49. package/dist/manager.cjs +0 -1
  50. package/dist/manager.d.cts +0 -5
  51. package/dist/manager.d.ts +0 -5
  52. package/dist/manager.js +0 -104
  53. package/dist/pdf/font-loader.d.ts +0 -6
  54. package/dist/pdf/index.d.ts +0 -2
  55. package/dist/pdf/render-pdf.d.ts +0 -25
  56. package/dist/plugin-C4qpbdMJ.cjs +0 -1
  57. package/dist/plugin-DcmAPK_K.js +0 -85
  58. package/dist/render/canvas.d.ts +0 -76
  59. package/dist/render/dom.d.ts +0 -10
  60. package/dist/render/grid-geometry.d.ts +0 -41
  61. package/dist/render/style.d.ts +0 -33
  62. package/dist/render/window.d.ts +0 -23
  63. package/dist/schema/render-plan.d.ts +0 -96
  64. package/dist/schema/validate.d.ts +0 -15
  65. package/dist/sql/ast-check.d.ts +0 -14
  66. package/dist/sql/compile.d.ts +0 -31
  67. package/dist/sql/expr.d.ts +0 -21
  68. package/dist/sql/index.d.ts +0 -4
  69. package/dist/sql/tokenizer.d.ts +0 -25
  70. package/dist/style-Xq08-IsV.cjs +0 -3
  71. package/dist/units.d.ts +0 -11
  72. package/dist/vue/ReportParamPanel.d.ts +0 -19
  73. package/dist/vue/ReportPreview.d.ts +0 -209
  74. package/dist/vue/ReportToolbar.d.ts +0 -42
  75. package/dist/vue/adapters.d.ts +0 -40
  76. package/dist/vue/composables/useHighlight.d.ts +0 -8
  77. package/dist/vue/composables/usePageWindow.d.ts +0 -25
  78. package/dist/vue/composables/usePrintExport.d.ts +0 -40
  79. package/dist/vue/composables/useReportSearch.d.ts +0 -73
  80. package/dist/vue/composables/useZoom.d.ts +0 -15
  81. package/dist/vue/config.d.ts +0 -108
  82. package/dist/vue/controller.d.ts +0 -29
  83. package/dist/vue/errors.d.ts +0 -16
  84. package/dist/vue/injection-keys.d.ts +0 -14
  85. package/dist/vue/local-adapter.d.ts +0 -12
  86. package/dist/vue/pdf-exporter.d.ts +0 -13
  87. package/dist/vue/plugin.d.ts +0 -354
  88. package/dist/xlsx/render-xlsx.d.ts +0 -20
@@ -1,1231 +0,0 @@
1
- import { computed as M, unref as P, ref as F, shallowRef as He, defineComponent as xe, watch as N, nextTick as at, openBlock as b, createElementBlock as y, createElementVNode as x, toDisplayString as w, Fragment as ee, createCommentVNode as B, normalizeClass as q, renderList as ie, createTextVNode as Oe, withKeys as We, inject as ue, provide as Ne, useCssVars as lt, watchEffect as De, onMounted as st, onUnmounted as it, normalizeStyle as Y, createBlock as ut, createVNode as ct, renderSlot as dt } from "vue";
2
- import { computePageWindow as ft, renderPlanToImages as pt, renderPage as qe, validateRenderPlan as mt, renderPlanToCanvas as vt } from "@agile-team/mach-report";
3
- import { a as Pe, b as gt, c as ht, n as bt, M as wt } from "./plugin-DcmAPK_K.js";
4
- function yt(e, t, a = {}) {
5
- const o = a.pxPerMm ?? 3.7795275590551185, r = M(() => Math.max(0, P(a.gapPx) ?? 18)), n = F(0), s = F(800), f = M(
6
- () => (e.value?.pages ?? []).map((k) => k.pageHeightMm * o)
7
- ), u = M(() => {
8
- const k = e.value?.pages ?? [];
9
- let E = 0, T = 0;
10
- for (const S of k)
11
- E += S.pageHeightMm * o + r.value, T = Math.max(T, S.pageWidthMm * o);
12
- return { w: T, h: E };
13
- }), p = M(
14
- () => ft({
15
- pageHeightsPx: f.value,
16
- viewportHeightPx: s.value / t.value,
17
- scrollTopPx: n.value / t.value,
18
- overscan: 1,
19
- gapPx: r.value
20
- })
21
- ), d = M(() => {
22
- const k = e.value;
23
- if (!k) return [];
24
- const { start: E, end: T } = p.value;
25
- return T < E ? [] : k.pages.slice(E, T + 1).map((S, L) => ({ page: S, index: E + L }));
26
- });
27
- function v(k, E) {
28
- let T = 0;
29
- return (S) => {
30
- T || (T = requestAnimationFrame(() => {
31
- if (T = 0, n.value = S.scrollTop, s.value = S.clientHeight || 800, E.value <= 0) return;
32
- const L = S.querySelectorAll(".mrp-page-holder");
33
- if (!L.length) return;
34
- const i = S.getBoundingClientRect().top + 56;
35
- let g = 1;
36
- L.forEach((c) => {
37
- c.getBoundingClientRect().top <= i && (g = Number(c.dataset.page ?? 1));
38
- }), k.value = Math.max(1, Math.min(E.value, g));
39
- }));
40
- };
41
- }
42
- return {
43
- contentSize: u,
44
- windowRange: p,
45
- visiblePages: d,
46
- makeScrollHandler: v,
47
- refreshViewport(k) {
48
- k && (s.value = k.clientHeight || 800);
49
- }
50
- };
51
- }
52
- function Pt(e) {
53
- const t = F(1), a = F("fit");
54
- function o() {
55
- requestAnimationFrame(() => {
56
- const n = e();
57
- !n || !n.viewport || (t.value = Math.min(
58
- 1,
59
- Math.max(0.3, (n.viewport.clientWidth - 48) / Math.max(1, n.pageWidthPx))
60
- ));
61
- });
62
- }
63
- function r(n) {
64
- n === "fit" ? (a.value = "fit", o()) : (a.value = "raw", t.value = n / 100);
65
- }
66
- return { zoom: t, zoomMode: a, applyFitZoom: o, setZoom: r };
67
- }
68
- const ce = 8;
69
- function de() {
70
- return new Promise((e) => setTimeout(e, 0));
71
- }
72
- function le(e) {
73
- return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
74
- }
75
- function Ee(e) {
76
- const t = /* @__PURE__ */ new Map();
77
- return e.pages.forEach((r) => {
78
- t.has(le(r)) || t.set(le(r), r);
79
- }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
80
- .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
81
- .mr-comp{break-inside:avoid;page-break-inside:avoid;}
82
- ${[...t.values()].map(
83
- (r) => `@page ${le(r)}{size:${Math.round(r.pageWidthMm)}mm ${Math.round(r.pageHeightMm)}mm;margin:0;}`
84
- ).join(`
85
- `)}
86
- body{margin:0;background:#fff;}`}</style></head><body>`;
87
- }
88
- function $e(e) {
89
- const t = qe(e, 96, {}, document);
90
- return t.style.page = le(e), t.outerHTML;
91
- }
92
- function Ae(e) {
93
- return { head: Ee(e), pageChunks: e.pages.map($e) };
94
- }
95
- async function $n(e, t = {}) {
96
- const a = {
97
- schemaVersion: "mach-report-batch-print",
98
- pages: e.flatMap((s) => s.pages)
99
- };
100
- if (a.pages.length === 0) return;
101
- const o = Ee(a), r = document.createElement("iframe");
102
- r.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(r);
103
- let n = !1;
104
- try {
105
- const s = r.contentDocument;
106
- s.open(), s.write(o);
107
- for (let f = 0; f < a.pages.length; f++)
108
- s.write($e(a.pages[f])), f % ce === ce - 1 && (t.onProgress?.(f + 1, a.pages.length), await de());
109
- s.write("</body></html>"), s.close(), await de(), t.onProgress?.(a.pages.length, a.pages.length), n = !0, r.contentWindow?.focus(), r.contentWindow?.print();
110
- } catch (s) {
111
- t.onError?.(s instanceof Error ? `批量打印失败: ${s.message}` : "批量打印失败");
112
- } finally {
113
- n ? setTimeout(() => r.remove(), 6e4) : r.remove();
114
- }
115
- }
116
- function xt(e) {
117
- const { head: t, pageChunks: a } = Ae(e);
118
- return {
119
- 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>`,
120
- filename: "mach-report.doc"
121
- };
122
- }
123
- function Et(e, t) {
124
- let a = null, o = !1, r = null, n = null, s = null;
125
- function f() {
126
- a?.remove(), a = null;
127
- }
128
- function u(i, g) {
129
- const c = URL.createObjectURL(i), m = document.createElement("a");
130
- m.href = c, m.download = g, m.click(), setTimeout(() => URL.revokeObjectURL(c), 1e4);
131
- }
132
- async function p() {
133
- if (o) return;
134
- const i = e.value;
135
- if (!i || i.pages.length === 0) return;
136
- o = !0, f();
137
- const g = Ee(i);
138
- 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);
139
- const c = a;
140
- try {
141
- const m = c.contentDocument;
142
- m.open(), m.write(g);
143
- for (let $ = 0; $ < i.pages.length; $++)
144
- if (m.write($e(i.pages[$])), $ % ce === ce - 1 && await de(), c !== a) return;
145
- m.write("</body></html>"), m.close(), await de(), c.contentWindow?.focus(), c.contentWindow?.print();
146
- } catch {
147
- t.onError("调用打印失败,请改用导出 PDF");
148
- } finally {
149
- o = !1;
150
- }
151
- }
152
- function d(i) {
153
- if (r?.plan === i) return r.promise;
154
- const g = t.getPdfExporter()(i, t.onWarning).finally(() => {
155
- r?.promise === g && (r = null);
156
- });
157
- return r = { plan: i, promise: g }, g;
158
- }
159
- async function v() {
160
- const i = e.value;
161
- if (!i || i.pages.length === 0) return;
162
- if (n?.plan === i) return n.promise;
163
- t.onBusy?.("PDF");
164
- const g = {}, c = (async () => {
165
- try {
166
- const m = await d(i);
167
- if (e.value !== i) return;
168
- u(new Blob([m], { type: "application/pdf" }), "mach-report.pdf");
169
- } catch (m) {
170
- t.onError(m instanceof Error ? `PDF 导出失败: ${m.message}` : "PDF 导出失败", "pdf");
171
- } finally {
172
- t.onBusy?.(null), n?.token === g && (n = null);
173
- }
174
- })();
175
- return n = { plan: i, promise: c, token: g }, c;
176
- }
177
- async function k() {
178
- const i = e.value;
179
- if (!(!i || i.pages.length === 0)) {
180
- t.onBusy?.("Excel");
181
- try {
182
- const { renderPlanToXlsx: g } = await import("@agile-team/mach-report/xlsx"), { buffer: c, warnings: m } = await g(i);
183
- if (e.value !== i) return;
184
- m.length > 0 && t.onWarning?.(`Excel 有 ${m.length} 处内容未导出:${m.slice(0, 2).join(";")}`), u(new Blob([c], {
185
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
186
- }), "mach-report.xlsx");
187
- } catch (g) {
188
- t.onError(g instanceof Error ? `Excel 导出失败: ${g.message}` : "Excel 导出失败", "export");
189
- } finally {
190
- t.onBusy?.(null);
191
- }
192
- }
193
- }
194
- async function E() {
195
- const i = e.value;
196
- if (!i || i.pages.length === 0) return;
197
- if (s?.plan === i) return s.promise;
198
- t.onBusy?.("图片");
199
- const g = {}, c = (async () => {
200
- try {
201
- const { blobs: m } = await pt(i, {
202
- dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
203
- });
204
- if (e.value !== i) return;
205
- m.forEach(($, I) => {
206
- u($, m.length > 1 ? `mach-report-page-${I + 1}.png` : "mach-report.png");
207
- });
208
- } catch (m) {
209
- t.onError(
210
- m instanceof Error ? `图片导出失败: ${m.message}` : "图片导出失败",
211
- "export"
212
- );
213
- } finally {
214
- t.onBusy?.(null), s?.token === g && (s = null);
215
- }
216
- })();
217
- return s = { plan: i, promise: c, token: g }, c;
218
- }
219
- function T() {
220
- const i = e.value;
221
- if (!(!i || i.pages.length === 0))
222
- try {
223
- const { html: g, filename: c } = xt(i);
224
- u(new Blob([g], { type: "application/msword;charset=utf-8" }), c);
225
- } catch (g) {
226
- t.onError(
227
- g instanceof Error ? `Word 导出失败: ${g.message}` : "Word 导出失败",
228
- "export"
229
- );
230
- }
231
- }
232
- function S(i) {
233
- const g = e.value;
234
- if (!g || g.pages.length === 0) return;
235
- if (i === "pdf") {
236
- v();
237
- return;
238
- }
239
- if (i === "xlsx" || i === "excel") {
240
- k();
241
- return;
242
- }
243
- if (i === "png" || i === "image") {
244
- E();
245
- return;
246
- }
247
- if (i === "word" || i === "doc") {
248
- T();
249
- return;
250
- }
251
- if (i !== "html") {
252
- t.onError(`不支持的导出格式:${i}`, "export");
253
- return;
254
- }
255
- const { head: c, pageChunks: m } = Ae(g), $ = `${c}${m.join("")}</body></html>`;
256
- u(new Blob([$], { type: "text/html;charset=utf-8" }), "mach-report.html");
257
- }
258
- function L() {
259
- const i = e.value;
260
- if (!i || i.pages.length === 0) return;
261
- const g = window.open("", "_blank");
262
- if (!g) {
263
- t.onError("浏览器拦截了弹窗,请允许弹窗后重试");
264
- return;
265
- }
266
- d(i).then((c) => {
267
- if (e.value !== i) {
268
- g.close();
269
- return;
270
- }
271
- const m = URL.createObjectURL(new Blob([c], { type: "application/pdf" })), $ = g.document;
272
- $.title = "PDF 预览", $.documentElement.style.height = "100%", $.body.style.cssText = "margin:0;height:100%;";
273
- const I = $.createElement("iframe");
274
- I.title = "PDF 预览", I.style.cssText = "display:block;width:100%;height:100%;border:0;", I.src = m, $.body.replaceChildren(I), setTimeout(() => URL.revokeObjectURL(m), 6e4);
275
- }).catch((c) => {
276
- g.close(), t.onError(c instanceof Error ? `PDF 预览失败: ${c.message}` : "PDF 预览失败", "pdf");
277
- });
278
- }
279
- return {
280
- print: p,
281
- exportAs: S,
282
- exportImages: E,
283
- exportWord: T,
284
- openPdfWindow: L,
285
- releasePrintFrame: f
286
- };
287
- }
288
- const Ve = "mrp-hit";
289
- function $t(e) {
290
- e.querySelectorAll(`mark.${Ve}`).forEach((a) => {
291
- const o = a.parentNode;
292
- if (o) {
293
- for (; a.firstChild; ) o.insertBefore(a.firstChild, a);
294
- a.remove(), o.normalize();
295
- }
296
- });
297
- }
298
- function Ct(e, t) {
299
- const a = t.trim();
300
- if (!a) return 0;
301
- const o = a.toLowerCase(), r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
302
- acceptNode(f) {
303
- const u = f.parentElement;
304
- return !u || u.closest("mark") || /^(SCRIPT|STYLE)$/.test(u.tagName) ? NodeFilter.FILTER_REJECT : (f.nodeValue ?? "").toLowerCase().includes(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
305
- }
306
- }), n = [];
307
- for (let f = r.nextNode(); f; f = r.nextNode()) n.push(f);
308
- let s = 0;
309
- for (const f of n) {
310
- const u = f.nodeValue ?? "", p = u.toLowerCase(), d = f.parentElement;
311
- if (!d) continue;
312
- const v = document.createDocumentFragment();
313
- let k = 0, E = p.indexOf(o);
314
- for (; E >= 0; ) {
315
- E > k && v.appendChild(document.createTextNode(u.slice(k, E)));
316
- const T = document.createElement("mark");
317
- T.className = Ve, T.textContent = u.slice(E, E + a.length), v.appendChild(T), s++, k = E + a.length, E = p.indexOf(o, k);
318
- }
319
- k < u.length && v.appendChild(document.createTextNode(u.slice(k))), d.replaceChild(v, f);
320
- }
321
- return s;
322
- }
323
- function ze(e, t) {
324
- let a = 0, o = e.toLowerCase().indexOf(t);
325
- for (; o >= 0; )
326
- a++, o = e.toLowerCase().indexOf(t, o + t.length);
327
- return a;
328
- }
329
- function Mt(e) {
330
- const { plan: t, gotoPage: a, highlight: o, clearHighlights: r } = e, n = e.debounceMs ?? 200, s = F(!1), f = F(""), u = F(""), p = F(0);
331
- let d = null;
332
- const v = M(() => {
333
- const c = f.value.trim().toLowerCase(), m = t.value;
334
- if (!c || !m) return [];
335
- const $ = [];
336
- return m.pages.forEach((I, te) => {
337
- for (const A of I.components)
338
- if (A.grid) {
339
- for (const K of A.grid.cells ?? [])
340
- for (const J of K ?? [])
341
- if (typeof J?.text == "string")
342
- for (let ne = 0; ne < ze(J.text, c); ne++) $.push(te);
343
- } else if (A.kind === "text" && typeof A.text == "string")
344
- for (let K = 0; K < ze(A.text, c); K++) $.push(te);
345
- }), $;
346
- }), k = M(() => v.value.length);
347
- function E(c) {
348
- if (u.value = c, d && clearTimeout(d), c.trim() === "") {
349
- d = null, f.value = "", p.value = 0;
350
- return;
351
- }
352
- d = setTimeout(() => {
353
- d = null, f.value = u.value, p.value = 0;
354
- const m = v.value[0];
355
- m != null && a(m + 1);
356
- }, n);
357
- }
358
- function T(c) {
359
- const m = v.value.length;
360
- m !== 0 && (p.value = (p.value + c + m) % m, a(v.value[p.value] + 1));
361
- }
362
- function S() {
363
- s.value = !s.value;
364
- }
365
- function L(c) {
366
- const m = f.value.trim();
367
- m && o(c, m);
368
- }
369
- function i(c) {
370
- r(c);
371
- }
372
- function g() {
373
- u.value = "", f.value = "", p.value = 0, d && clearTimeout(d), d = null;
374
- }
375
- return {
376
- visible: s,
377
- query: f,
378
- matchIndex: p,
379
- matchCount: k,
380
- toggle: S,
381
- onInput: E,
382
- onNav: T,
383
- apply: L,
384
- clear: i,
385
- reset: g
386
- };
387
- }
388
- function kt(e, t) {
389
- const a = M(() => {
390
- if (e.value) return !0;
391
- if (typeof location > "u") return !1;
392
- try {
393
- return new URLSearchParams(location.search).get("mrp-debug") === "1";
394
- } catch {
395
- return !1;
396
- }
397
- }), o = M(() => !a.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), r = M(() => !a.value || !t.plan.value ? null : {
398
- pages: t.pageCount.value,
399
- window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
400
- zoom: `${Math.round(t.zoom.value * 100)}%`,
401
- loadMs: `${t.loadMs.value}ms`,
402
- planKB: o.value
403
- });
404
- return { enabled: a, debugStats: r };
405
- }
406
- function Rt(e, t) {
407
- const { thumbsRoot: a, visible: o, renderThumbCanvas: r } = t;
408
- let n = null;
409
- function s(p, d) {
410
- if (!e.value || p.childElementCount > 0) return;
411
- const v = r(d);
412
- v && (v.style.width = "100%", v.style.height = "100%", v.style.display = "block", p.appendChild(v));
413
- }
414
- return { schedule: () => {
415
- !o.value || !e.value || !a.value || typeof IntersectionObserver > "u" || (n?.disconnect(), n = new IntersectionObserver(
416
- (p) => {
417
- for (const d of p) {
418
- if (!d.isIntersecting) continue;
419
- const v = d.target;
420
- s(v, Number(v.dataset.thumb ?? 1) - 1), n?.unobserve(v);
421
- }
422
- },
423
- { root: a.value, rootMargin: "200px" }
424
- ), a.value.querySelectorAll("[data-thumb]").forEach((p) => {
425
- n.observe(p);
426
- }));
427
- }, destroy: () => {
428
- n?.disconnect(), n = null;
429
- } };
430
- }
431
- function Tt() {
432
- const e = He(0);
433
- return {
434
- loadMs: e,
435
- start() {
436
- return typeof performance < "u" ? performance.now() : 0;
437
- },
438
- end(t) {
439
- e.value = t ? Math.round(performance.now() - t) : 0;
440
- }
441
- };
442
- }
443
- const Ft = { class: "mrp-toolbar" }, Bt = { class: "mrp-title" }, St = ["disabled"], It = { class: "mrp-pageinfo" }, Wt = ["disabled"], Dt = {
444
- key: 1,
445
- class: "mrp-search"
446
- }, zt = ["placeholder", "value"], Lt = {
447
- key: 0,
448
- class: "mrp-search-count"
449
- }, Ht = ["disabled"], Ot = ["disabled"], Nt = /* @__PURE__ */ xe({
450
- __name: "ReportToolbar",
451
- props: {
452
- pageCount: {},
453
- currentPage: {},
454
- zoomMode: {},
455
- zoom: {},
456
- showExport: { type: Boolean },
457
- showPrint: { type: Boolean },
458
- showPdfWindow: { type: Boolean },
459
- messages: {},
460
- search: {},
461
- thumbsVisible: { type: Boolean }
462
- },
463
- emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle"],
464
- setup(e) {
465
- const t = e, a = F(null);
466
- N(
467
- () => t.search.visible,
468
- (r) => {
469
- r && at(() => a.value?.focus());
470
- }
471
- );
472
- function o(r, n, s) {
473
- return r.replace("{cur}", String(n)).replace("{total}", String(s));
474
- }
475
- return (r, n) => (b(), y("div", Ft, [
476
- x("span", Bt, w(e.messages.title), 1),
477
- e.pageCount > 0 ? (b(), y(ee, { key: 0 }, [
478
- x("button", {
479
- class: "mrp-nav",
480
- type: "button",
481
- disabled: e.currentPage <= 1,
482
- onClick: n[0] || (n[0] = (s) => r.$emit("goto", e.currentPage - 1))
483
- }, w(e.messages.prevPage), 9, St),
484
- x("span", It, w(o(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
485
- x("button", {
486
- class: "mrp-nav",
487
- type: "button",
488
- disabled: e.currentPage >= e.pageCount,
489
- onClick: n[1] || (n[1] = (s) => r.$emit("goto", e.currentPage + 1))
490
- }, w(e.messages.nextPage), 9, Wt)
491
- ], 64)) : B("", !0),
492
- n[17] || (n[17] = x("span", { class: "mrp-spacer" }, null, -1)),
493
- e.search.visible ? (b(), y("div", Dt, [
494
- x("input", {
495
- ref_key: "searchInputRef",
496
- ref: a,
497
- class: "mrp-search-input",
498
- type: "text",
499
- placeholder: e.messages.searchPlaceholder,
500
- value: e.search.query,
501
- onInput: n[2] || (n[2] = (s) => r.$emit("search-input", s.target.value))
502
- }, null, 40, zt),
503
- e.search.query ? (b(), y("span", Lt, w(o(e.messages.matchInfo, e.search.matchIndex + 1, e.search.matchCount)), 1)) : B("", !0),
504
- x("button", {
505
- class: "mrp-nav",
506
- type: "button",
507
- disabled: e.search.matchCount === 0,
508
- onClick: n[3] || (n[3] = (s) => r.$emit("search-nav", -1))
509
- }, w(e.messages.prevMatch), 9, Ht),
510
- x("button", {
511
- class: "mrp-nav",
512
- type: "button",
513
- disabled: e.search.matchCount === 0,
514
- onClick: n[4] || (n[4] = (s) => r.$emit("search-nav", 1))
515
- }, w(e.messages.nextMatch), 9, Ot)
516
- ])) : B("", !0),
517
- x("button", {
518
- class: q(["mrp-nav", { "mrp-active": e.search.visible }]),
519
- type: "button",
520
- title: "Ctrl+F",
521
- onClick: n[5] || (n[5] = (s) => r.$emit("search-toggle"))
522
- }, " 🔍 ", 2),
523
- x("button", {
524
- class: q(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
525
- type: "button",
526
- onClick: n[6] || (n[6] = (s) => r.$emit("thumbs-toggle"))
527
- }, " ▦ " + w(e.messages.thumbnails), 3),
528
- x("button", {
529
- class: q(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
530
- type: "button",
531
- onClick: n[7] || (n[7] = (s) => r.$emit("zoom", "fit"))
532
- }, w(e.messages.fitWidth), 3),
533
- x("button", {
534
- class: q(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
535
- type: "button",
536
- onClick: n[8] || (n[8] = (s) => r.$emit("zoom", 100))
537
- }, " 100% ", 2),
538
- x("button", {
539
- class: q(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
540
- type: "button",
541
- onClick: n[9] || (n[9] = (s) => r.$emit("zoom", 150))
542
- }, " 150% ", 2),
543
- e.showExport ? (b(), y("button", {
544
- key: 2,
545
- class: "mrp-nav",
546
- type: "button",
547
- onClick: n[10] || (n[10] = (s) => r.$emit("export", "html"))
548
- }, w(e.messages.exportHtml), 1)) : B("", !0),
549
- e.showExport ? (b(), y("button", {
550
- key: 3,
551
- class: "mrp-nav",
552
- type: "button",
553
- onClick: n[11] || (n[11] = (s) => r.$emit("export", "pdf"))
554
- }, w(e.messages.exportPdf), 1)) : B("", !0),
555
- e.showExport ? (b(), y("button", {
556
- key: 4,
557
- class: "mrp-nav",
558
- type: "button",
559
- onClick: n[12] || (n[12] = (s) => r.$emit("export", "xlsx"))
560
- }, w(e.messages.exportExcel), 1)) : B("", !0),
561
- e.showExport ? (b(), y("button", {
562
- key: 5,
563
- class: "mrp-nav",
564
- type: "button",
565
- onClick: n[13] || (n[13] = (s) => r.$emit("export", "png"))
566
- }, w(e.messages.exportImage), 1)) : B("", !0),
567
- e.showExport ? (b(), y("button", {
568
- key: 6,
569
- class: "mrp-nav",
570
- type: "button",
571
- onClick: n[14] || (n[14] = (s) => r.$emit("export", "word"))
572
- }, w(e.messages.exportWord), 1)) : B("", !0),
573
- e.showPrint ? (b(), y("button", {
574
- key: 7,
575
- class: "mrp-nav",
576
- type: "button",
577
- onClick: n[15] || (n[15] = (s) => r.$emit("print"))
578
- }, w(e.messages.print), 1)) : B("", !0),
579
- e.showPdfWindow ? (b(), y("button", {
580
- key: 8,
581
- class: "mrp-nav",
582
- type: "button",
583
- onClick: n[16] || (n[16] = (s) => r.$emit("pdf-window"))
584
- }, w(e.messages.pdfWindow), 1)) : B("", !0)
585
- ]));
586
- }
587
- }), Ce = (e, t) => {
588
- const a = e.__vccOpts || e;
589
- for (const [o, r] of t)
590
- a[o] = r;
591
- return a;
592
- }, qt = /* @__PURE__ */ Ce(Nt, [["__scopeId", "data-v-48cc0980"]]), At = { class: "mrp-params" }, Vt = { class: "mrp-params-title" }, Ut = { class: "mrp-params-grid" }, jt = { class: "mrp-param-label" }, Kt = {
593
- key: 0,
594
- class: "mrp-param-star"
595
- }, Zt = ["value", "onChange"], Gt = {
596
- value: "",
597
- disabled: "",
598
- hidden: ""
599
- }, Yt = ["value"], Jt = ["type", "placeholder", "value", "onInput"], Xt = { class: "mrp-params-actions" }, Qt = /* @__PURE__ */ xe({
600
- __name: "ReportParamPanel",
601
- props: {
602
- defs: {},
603
- modelValue: {},
604
- messages: {},
605
- attempted: { type: Boolean }
606
- },
607
- emits: ["update:modelValue", "query", "reset"],
608
- setup(e, { emit: t }) {
609
- const a = e, o = t, r = F({ ...a.modelValue });
610
- N(
611
- () => a.modelValue,
612
- (u) => {
613
- r.value = { ...u };
614
- }
615
- );
616
- const n = M(
617
- () => a.defs.map((u) => ({
618
- def: u,
619
- label: u.label ?? u.field,
620
- value: r.value[u.field] ?? ""
621
- }))
622
- );
623
- function s(u, p) {
624
- r.value = { ...r.value, [u]: p }, o("update:modelValue", { ...r.value });
625
- }
626
- function f(u) {
627
- const p = a.defs.find((d) => d.field === u);
628
- return a.attempted && p?.required === !0 && !(r.value[u] ?? "").trim();
629
- }
630
- return (u, p) => (b(), y("div", At, [
631
- x("span", Vt, w(e.messages.paramsTitle), 1),
632
- x("div", Ut, [
633
- (b(!0), y(ee, null, ie(n.value, (d) => (b(), y("label", {
634
- key: d.def.field,
635
- class: q(["mrp-param", { "mrp-param-missing": f(d.def.field) }])
636
- }, [
637
- x("span", jt, [
638
- Oe(w(d.label), 1),
639
- d.def.required ? (b(), y("i", Kt, "*")) : B("", !0)
640
- ]),
641
- (d.def.type ?? "text") === "select" ? (b(), y("select", {
642
- key: 0,
643
- class: "mrp-param-input",
644
- value: d.value,
645
- onChange: (v) => s(d.def.field, v.target.value),
646
- onKeydown: p[0] || (p[0] = We((v) => u.$emit("query"), ["enter"]))
647
- }, [
648
- x("option", Gt, w(d.def.placeholder ?? `请选择${d.label}`), 1),
649
- (b(!0), y(ee, null, ie(d.def.options ?? [], (v) => (b(), y("option", {
650
- key: v.value,
651
- value: v.value
652
- }, w(v.label), 9, Yt))), 128))
653
- ], 40, Zt)) : (b(), y("input", {
654
- key: 1,
655
- class: "mrp-param-input",
656
- type: d.def.type === "number" ? "number" : d.def.type === "date" ? "date" : "text",
657
- placeholder: d.def.placeholder ?? `请输入${d.label}`,
658
- value: d.value,
659
- onInput: (v) => s(d.def.field, v.target.value),
660
- onKeydown: p[1] || (p[1] = We((v) => u.$emit("query"), ["enter"]))
661
- }, null, 40, Jt))
662
- ], 2))), 128))
663
- ]),
664
- x("div", Xt, [
665
- x("button", {
666
- class: "mrp-nav mrp-param-query",
667
- type: "button",
668
- onClick: p[2] || (p[2] = (d) => u.$emit("query"))
669
- }, w(e.messages.query), 1),
670
- x("button", {
671
- class: "mrp-nav",
672
- type: "button",
673
- onClick: p[3] || (p[3] = (d) => u.$emit("reset"))
674
- }, w(e.messages.reset), 1)
675
- ])
676
- ]));
677
- }
678
- }), _t = /* @__PURE__ */ Ce(Qt, [["__scopeId", "data-v-aafce92d"]]), en = {
679
- title: "报表预览",
680
- prevPage: "‹ 上一页",
681
- nextPage: "下一页 ›",
682
- pageInfo: "{cur} / {total}",
683
- fitWidth: "适宽",
684
- exportHtml: "导出 HTML",
685
- exportPdf: "导出 PDF",
686
- exportExcel: "导出 Excel",
687
- exportImage: "导出图片",
688
- exportWord: "导出 Word",
689
- exporting: "正在生成 {format}…",
690
- print: "打印",
691
- pdfWindow: "PDF 窗口",
692
- loading: "报表渲染中…",
693
- empty: "暂无预览数据",
694
- errorPrefix: "",
695
- retry: "重试",
696
- searchPlaceholder: "搜索报表内容",
697
- matchInfo: "{cur}/{total}",
698
- prevMatch: "‹",
699
- nextMatch: "›",
700
- thumbnails: "缩略图",
701
- paramsTitle: "查询条件",
702
- query: "查 询",
703
- reset: "重 置",
704
- paramRequired: "请填写{label}"
705
- }, tn = {
706
- shellBg: "#525659",
707
- shellFg: "#e8e8e8",
708
- toolbarBg: "#323639",
709
- toolbarBorder: "#22252a",
710
- toolbarFg: "#e8e8e8",
711
- btnFg: "#cfcfcf",
712
- btnBorder: "#4a4d52",
713
- btnHoverBg: "#414549",
714
- btnHoverFg: "#ffffff",
715
- btnActiveBg: "#2d5fb8"
716
- };
717
- function Cn(e) {
718
- return e;
719
- }
720
- function Mn(e) {
721
- return e;
722
- }
723
- const j = {
724
- showExport: !0,
725
- showPrint: !0,
726
- showPdfWindow: !0,
727
- showParams: !0,
728
- gapPx: 18,
729
- pdfFontUrl: "/simhei.ttf",
730
- logger: console
731
- }, kn = { warn: () => {
732
- }, info: () => {
733
- } };
734
- function nn(e, t) {
735
- const a = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, o = { ...e?.defaults, ...a };
736
- return {
737
- showExport: o.showExport ?? j.showExport,
738
- showPrint: o.showPrint ?? j.showPrint,
739
- showPdfWindow: o.showPdfWindow ?? j.showPdfWindow,
740
- showParams: o.showParams ?? j.showParams,
741
- gapPx: o.gapPx ?? j.gapPx,
742
- pdfFontUrl: o.pdfFontUrl ?? j.pdfFontUrl,
743
- theme: { ...tn, ...o.theme },
744
- messages: { ...en, ...o.messages },
745
- logger: o.logger ?? j.logger
746
- };
747
- }
748
- function on(e) {
749
- const t = {};
750
- 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;
751
- }
752
- function Rn(e) {
753
- const t = ue(Pe, null), a = M(() => {
754
- const o = t?.value ?? null, r = "defaults" in e && "presets" in e ? e : { defaults: e, presets: {} };
755
- return o ? {
756
- defaults: { ...o.defaults, ...r.defaults },
757
- presets: { ...o.presets, ...r.presets },
758
- defaultPreset: r.defaultPreset ?? o.defaultPreset
759
- } : r;
760
- });
761
- Ne(Pe, a);
762
- }
763
- function rn() {
764
- return ue(Pe, M(() => null));
765
- }
766
- function an(e = { fontUrl: "/simhei.ttf" }) {
767
- let t = null;
768
- return async (a, o) => {
769
- t || (t = await import("@agile-team/mach-report/pdf"));
770
- const r = e.fontUrl ? await t.loadFontWithCache(e.fontUrl) : null, { bytes: n, unsupportedTextCount: s, pageErrors: f, fidelityWarnings: u } = await t.renderPlanToPdf(a, r ? { customFontBytes: r } : {});
771
- if (s > 0)
772
- throw new Error(`PDF 中有 ${s} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
773
- if (f.length > 0)
774
- throw new Error(`PDF 有 ${f.length} 页渲染失败:${f[0]}`);
775
- return u.length > 0 && o?.(`PDF 有 ${u.length} 处版式降级:${u.slice(0, 2).join(";")}`), n;
776
- };
777
- }
778
- class se extends Error {
779
- constructor(t, a, o) {
780
- super(a), this.name = "MachReportError", this.code = t, this.cause = o;
781
- }
782
- }
783
- function ln(e) {
784
- return e instanceof se ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
785
- }
786
- const sn = { class: "mrp-main" }, un = {
787
- key: 0,
788
- class: "mrp-state"
789
- }, cn = {
790
- key: 1,
791
- class: "mrp-state mrp-error"
792
- }, dn = {
793
- key: 2,
794
- class: "mrp-state"
795
- }, fn = ["data-page"], pn = ["onClick"], mn = ["data-thumb"], vn = { class: "mrp-thumb-no" }, gn = { class: "mrp-overlay" }, hn = {
796
- key: 2,
797
- class: "mrp-debug",
798
- "aria-hidden": "true"
799
- }, ae = 96 / 25.4, Le = "mach-report:ui", bn = /* @__PURE__ */ xe({
800
- __name: "ReportPreview",
801
- props: {
802
- tempId: {
803
- type: [String, Array],
804
- default: null
805
- },
806
- furnitureTempId: { type: String, default: "" },
807
- params: {
808
- type: Object,
809
- default: () => ({})
810
- },
811
- height: { type: String, default: "100vh" },
812
- autoLoad: { type: Boolean, default: !0 },
813
- /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
814
- showExport: { type: Boolean, default: void 0 },
815
- showPrint: { type: Boolean, default: void 0 },
816
- showPdfWindow: { type: Boolean, default: void 0 },
817
- /** 页间距(px);不传走配置中心 */
818
- gapPx: { type: Number, default: void 0 },
819
- /** 工具栏/状态文案覆写(不传走配置中心 messages) */
820
- messages: { type: Object, default: void 0 },
821
- /** 启用的 preset 名(不传用配置中心 defaultPreset) */
822
- preset: { type: String, default: void 0 },
823
- /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
824
- debug: { type: Boolean, default: !1 },
825
- /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
826
- paramDefs: {
827
- type: Array,
828
- default: void 0
829
- },
830
- /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
831
- showParams: { type: Boolean, default: void 0 },
832
- fetcher: {
833
- type: Function,
834
- default: null
835
- }
836
- },
837
- emits: ["loaded", "error", "warning"],
838
- setup(e, { expose: t, emit: a }) {
839
- lt((l) => ({
840
- a2716f8c: S.value + "px"
841
- }));
842
- const o = e, r = a, n = He(null), s = F(!1), f = F(""), u = F(null), p = F(1), d = F(null), v = F(null), k = F(null), E = F(!1), T = Tt(), S = M(() => Math.max(0, J.value)), L = ue(gt, null), i = ue(ht, null), g = M(() => bt(o.tempId)), c = M(() => n.value?.pages.length ?? 0), m = rn(), $ = M(() => nn(m.value, o.preset)), I = M(() => ({
843
- ...$.value.messages,
844
- ...o.messages
845
- })), te = M(() => o.showExport ?? $.value.showExport), A = M(() => o.showPrint ?? $.value.showPrint), K = M(() => o.showPdfWindow ?? $.value.showPdfWindow), J = M(() => o.gapPx ?? $.value.gapPx), ne = M(() => o.showParams ?? $.value.showParams);
846
- let Me = null, fe = null;
847
- function Ue() {
848
- if (i) return i;
849
- const l = $.value.pdfFontUrl;
850
- return (!fe || Me !== l) && (Me = l, fe = an({ fontUrl: l })), fe;
851
- }
852
- const V = M(() => o.paramDefs ?? []), U = F({}), pe = F(!1);
853
- function oe(l) {
854
- const h = {};
855
- for (const C of l)
856
- h[C.field] = o.params[C.field] ?? C.defaultValue ?? "";
857
- U.value = h, pe.value = !1;
858
- }
859
- oe(V.value), N(V, (l) => oe(l)), N(() => JSON.stringify(o.params), () => oe(V.value));
860
- const je = M(() => {
861
- const l = { ...o.params };
862
- for (const [h, C] of Object.entries(U.value))
863
- C === "" ? delete l[h] : l[h] = C;
864
- return l;
865
- });
866
- function Ke() {
867
- return V.value.filter(
868
- (l) => l.required === !0 && !(U.value[l.field] ?? "").trim()
869
- );
870
- }
871
- function Ze() {
872
- pe.value = !0;
873
- const l = Ke();
874
- if (l.length > 0) {
875
- const h = l[0].label ?? l[0].field, C = I.value.paramRequired.replace("{label}", h);
876
- f.value = C, r("error", C, { code: "param" });
877
- return;
878
- }
879
- O();
880
- }
881
- function Ge() {
882
- oe(V.value);
883
- }
884
- const Ye = M(() => ({
885
- height: o.height,
886
- ...on($.value.theme)
887
- })), { zoom: z, zoomMode: Z, applyFitZoom: ke, setZoom: me } = Pt(() => ({
888
- viewport: v.value,
889
- pageWidthPx: (n.value?.pages[0]?.pageWidthMm ?? 210) * ae
890
- })), Je = yt(n, z, {
891
- pxPerMm: ae,
892
- gapPx: J
893
- }), { contentSize: ve, windowRange: X, visiblePages: Xe, makeScrollHandler: Qe, refreshViewport: Re } = Je, _e = Qe(p, c);
894
- function ge(l) {
895
- Z.value = "raw", z.value = Math.min(3, Math.max(0.3, l));
896
- }
897
- function he() {
898
- Te(), n.value = null, p.value = 1, W.reset();
899
- }
900
- let re = 0;
901
- async function O() {
902
- const l = ++re, h = o.fetcher ?? L;
903
- if (g.value.length === 0) {
904
- f.value = "缺少报表模板 ID", he(), r("error", f.value, { code: "param" });
905
- return;
906
- }
907
- if (!h) {
908
- f.value = "未提供渲染数据源 fetcher", he(), r("error", f.value, { code: "config" });
909
- return;
910
- }
911
- s.value = !0, f.value = "", u.value = null, he();
912
- const C = T.start();
913
- try {
914
- const R = await h({
915
- tempIds: g.value,
916
- furnitureTempId: o.furnitureTempId || void 0,
917
- params: { ...je.value }
918
- });
919
- if (l !== re) return;
920
- const D = mt(R);
921
- if (!D.ok) {
922
- const Q = D.errors.slice(0, 3).map((_) => `${_.path}: ${_.message}`).join("; ");
923
- throw new se(
924
- "validate",
925
- `渲染计划校验失败(${D.errors.length} 处): ${Q}`
926
- );
927
- }
928
- D.warnings.length > 0 && $.value.logger.warn("[mach-report] 渲染计划告警:", D.warnings), n.value = R, p.value = 1, T.end(C), v.value && (v.value.scrollTop = 0), Z.value === "fit" && ke(), r("loaded", R.pages.length);
929
- } catch (R) {
930
- if (l !== re) return;
931
- const D = R instanceof se ? R : new se(
932
- "fetch",
933
- R instanceof Error ? R.message : "预览加载失败",
934
- R
935
- );
936
- f.value = D.message, r("error", D.message, ln(D));
937
- } finally {
938
- l === re && (s.value = !1);
939
- }
940
- }
941
- function H(l) {
942
- if (c.value <= 0) return;
943
- const h = Math.max(1, Math.min(c.value, l));
944
- p.value = h;
945
- const C = v.value;
946
- if (!C) return;
947
- let R = 0;
948
- for (let D = 0; D < h - 1; D++)
949
- R += (n.value?.pages[D]?.pageHeightMm ?? 0) * ae + S.value;
950
- C.scrollTop = R * z.value;
951
- }
952
- const { print: be, exportAs: we, openPdfWindow: ye, releasePrintFrame: Te } = Et(n, {
953
- getPdfExporter: Ue,
954
- onError: (l, h) => {
955
- u.value = { kind: "error", message: l }, r("error", l, { code: h ?? "print" });
956
- },
957
- onWarning: (l) => {
958
- u.value = { kind: "warning", message: l }, r("warning", l);
959
- },
960
- onBusy: (l) => {
961
- l ? u.value = {
962
- kind: "progress",
963
- message: I.value.exporting.replace("{format}", l)
964
- } : u.value?.kind === "progress" && (u.value = null);
965
- }
966
- });
967
- function Fe(l, h = {}) {
968
- U.value = { ...U.value, ...l }, h.reload !== !1 && O();
969
- }
970
- Ne(wt, { reload: O, print: be, exportAs: we, openPdfWindow: ye, gotoPage: H, setParams: Fe });
971
- const W = Mt({
972
- plan: n,
973
- gotoPage: H,
974
- highlight: Ct,
975
- clearHighlights: $t
976
- });
977
- function et(l) {
978
- l.ctrlKey && (l.preventDefault(), ge(z.value * (l.deltaY < 0 ? 1.1 : 1 / 1.1)));
979
- }
980
- function tt(l) {
981
- if ((l.ctrlKey || l.metaKey) && l.key.toLowerCase() === "f") {
982
- l.preventDefault(), W.visible.value || W.toggle();
983
- return;
984
- }
985
- switch (l.key) {
986
- case "PageDown":
987
- l.preventDefault(), H(p.value + 1);
988
- break;
989
- case "PageUp":
990
- l.preventDefault(), H(p.value - 1);
991
- break;
992
- case "Home":
993
- l.preventDefault(), H(1);
994
- break;
995
- case "End":
996
- l.preventDefault(), H(c.value);
997
- break;
998
- case "+":
999
- case "=":
1000
- l.preventDefault(), ge(z.value * 1.1);
1001
- break;
1002
- case "-":
1003
- l.preventDefault(), ge(z.value / 1.1);
1004
- break;
1005
- }
1006
- }
1007
- function nt() {
1008
- try {
1009
- localStorage.setItem(
1010
- Le,
1011
- JSON.stringify({ zoomMode: Z.value === "fit" ? "fit" : Math.round(z.value * 100) })
1012
- );
1013
- } catch {
1014
- }
1015
- }
1016
- N([Z, z], nt), De(() => {
1017
- const l = n.value;
1018
- if (!l) return;
1019
- const h = d.value;
1020
- if (!h) return;
1021
- h.querySelectorAll(".mrp-page-holder").forEach((R) => {
1022
- const D = Number(R.dataset.page ?? 0) - 1, Q = l.pages[D];
1023
- if (!Q || R.childElementCount > 0) {
1024
- if (R.firstElementChild) {
1025
- const Ie = R.firstElementChild;
1026
- W.clear(Ie), W.apply(Ie);
1027
- }
1028
- return;
1029
- }
1030
- R.style.width = `${Q.pageWidthMm * ae}px`;
1031
- const _ = qe(Q, 96, {}, document);
1032
- W.apply(_), R.appendChild(_);
1033
- });
1034
- }, { flush: "post" }), N(() => W.query.value, (l) => {
1035
- l || d.value?.querySelectorAll(".mrp-page-holder").forEach((h) => {
1036
- W.clear(h);
1037
- });
1038
- });
1039
- const Be = Rt(n, {
1040
- thumbsRoot: k,
1041
- visible: E,
1042
- renderThumbCanvas: (l) => {
1043
- try {
1044
- const { canvases: h } = vt(n.value, { start: l, end: l, dpr: 0.2 });
1045
- return h[0] ?? null;
1046
- } catch {
1047
- return null;
1048
- }
1049
- }
1050
- });
1051
- De(() => {
1052
- Be.schedule();
1053
- }, { flush: "post" });
1054
- const ot = M(() => o.debug), { debugStats: G } = kt(ot, {
1055
- plan: n,
1056
- pageCount: c,
1057
- windowRange: X,
1058
- zoom: z,
1059
- loadMs: T.loadMs
1060
- });
1061
- function Se() {
1062
- Re(v.value), Z.value === "fit" && ke();
1063
- }
1064
- function rt() {
1065
- try {
1066
- const l = JSON.parse(localStorage.getItem(Le) ?? "{}");
1067
- l.zoomMode === "fit" ? me("fit") : typeof l.zoomMode == "number" && me(l.zoomMode);
1068
- } catch {
1069
- }
1070
- }
1071
- return st(() => {
1072
- window.addEventListener("resize", Se), Re(v.value), rt(), o.autoLoad && O();
1073
- }), it(() => {
1074
- window.removeEventListener("resize", Se), Be.destroy(), W.reset(), Te();
1075
- }), N(
1076
- () => [o.tempId, o.furnitureTempId, JSON.stringify(o.params)],
1077
- () => {
1078
- o.autoLoad && O();
1079
- }
1080
- ), N(
1081
- () => o.fetcher ?? L,
1082
- () => {
1083
- o.autoLoad && O();
1084
- }
1085
- ), t({ reload: O, print: be, exportAs: we, openPdfWindow: ye, gotoPage: H, setParams: Fe }), (l, h) => (b(), y("div", {
1086
- class: "mach-report-preview",
1087
- style: Y(Ye.value)
1088
- }, [
1089
- ne.value && V.value.length > 0 ? (b(), ut(_t, {
1090
- key: 0,
1091
- defs: V.value,
1092
- modelValue: U.value,
1093
- "onUpdate:modelValue": h[0] || (h[0] = (C) => U.value = C),
1094
- messages: I.value,
1095
- attempted: pe.value,
1096
- onQuery: Ze,
1097
- onReset: Ge
1098
- }, null, 8, ["defs", "modelValue", "messages", "attempted"])) : B("", !0),
1099
- ct(qt, {
1100
- "page-count": c.value,
1101
- "current-page": p.value,
1102
- "zoom-mode": P(Z),
1103
- zoom: P(z),
1104
- "show-export": te.value,
1105
- "show-print": A.value,
1106
- "show-pdf-window": K.value,
1107
- messages: I.value,
1108
- search: { visible: P(W).visible.value, query: P(W).query.value, matchIndex: P(W).matchIndex.value, matchCount: P(W).matchCount.value },
1109
- "thumbs-visible": E.value,
1110
- onGoto: H,
1111
- onZoom: P(me),
1112
- onExport: h[1] || (h[1] = (C) => P(we)(C)),
1113
- onPrint: P(be),
1114
- onPdfWindow: P(ye),
1115
- onSearchInput: P(W).onInput,
1116
- onSearchNav: P(W).onNav,
1117
- onSearchToggle: P(W).toggle,
1118
- onThumbsToggle: h[2] || (h[2] = (C) => E.value = !E.value)
1119
- }, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "search", "thumbs-visible", "onZoom", "onPrint", "onPdfWindow", "onSearchInput", "onSearchNav", "onSearchToggle"]),
1120
- u.value ? (b(), y("div", {
1121
- key: 1,
1122
- class: q(["mrp-export-notice", `mrp-export-${u.value.kind}`]),
1123
- role: "alert"
1124
- }, w(u.value.message), 3)) : B("", !0),
1125
- x("div", sn, [
1126
- x("div", {
1127
- ref_key: "viewportRef",
1128
- ref: v,
1129
- class: "mrp-body",
1130
- tabindex: "0",
1131
- onWheel: et,
1132
- onKeydown: tt,
1133
- onScrollPassive: h[3] || (h[3] = (C) => P(_e)(C.target))
1134
- }, [
1135
- s.value ? (b(), y("div", un, w(I.value.loading), 1)) : f.value ? (b(), y("div", cn, [
1136
- Oe(w(f.value) + " ", 1),
1137
- x("button", {
1138
- class: "mrp-retry",
1139
- type: "button",
1140
- onClick: O
1141
- }, w(I.value.retry), 1)
1142
- ])) : !n.value || c.value === 0 ? (b(), y("div", dn, w(I.value.empty), 1)) : (b(), y("div", {
1143
- key: 3,
1144
- class: "mrp-scale",
1145
- style: Y({ width: `${P(ve).w * P(z)}px`, height: `${P(ve).h * P(z)}px` })
1146
- }, [
1147
- x("div", {
1148
- ref_key: "containerRef",
1149
- ref: d,
1150
- class: "mrp-scale-inner",
1151
- style: Y({ transform: `scale(${P(z)})`, transformOrigin: "top left", width: `${P(ve).w}px` })
1152
- }, [
1153
- P(X).padTopPx > 0 ? (b(), y("div", {
1154
- key: 0,
1155
- class: "mrp-spacer-top",
1156
- style: Y({ height: `${P(X).padTopPx}px` }),
1157
- "aria-hidden": "true"
1158
- }, null, 4)) : B("", !0),
1159
- (b(!0), y(ee, null, ie(P(Xe), (C) => (b(), y("div", {
1160
- key: C.index,
1161
- class: "mrp-page-holder",
1162
- "data-page": C.index + 1
1163
- }, null, 8, fn))), 128)),
1164
- P(X).padBottomPx > 0 ? (b(), y("div", {
1165
- key: 1,
1166
- class: "mrp-spacer-bottom",
1167
- style: Y({ height: `${P(X).padBottomPx}px` }),
1168
- "aria-hidden": "true"
1169
- }, null, 4)) : B("", !0)
1170
- ], 4)
1171
- ], 4))
1172
- ], 544),
1173
- E.value && c.value > 0 ? (b(), y("aside", {
1174
- key: 0,
1175
- ref_key: "thumbsRef",
1176
- ref: k,
1177
- class: "mrp-thumbs"
1178
- }, [
1179
- (b(!0), y(ee, null, ie(n.value?.pages ?? [], (C, R) => (b(), y("div", {
1180
- key: R,
1181
- class: q(["mrp-thumb", { "mrp-thumb-active": R + 1 === p.value }]),
1182
- onClick: (D) => H(R + 1)
1183
- }, [
1184
- x("div", {
1185
- class: "mrp-thumb-box",
1186
- "data-thumb": R + 1,
1187
- style: Y({ height: `${Math.round(C.pageHeightMm / C.pageWidthMm * 116)}px` })
1188
- }, null, 12, mn),
1189
- x("span", vn, w(R + 1), 1)
1190
- ], 10, pn))), 128))
1191
- ], 512)) : B("", !0)
1192
- ]),
1193
- x("div", gn, [
1194
- dt(l.$slots, "default", {}, void 0, !0)
1195
- ]),
1196
- P(G) ? (b(), y("div", hn, [
1197
- h[4] || (h[4] = x("div", null, "mach-report debug", -1)),
1198
- x("div", null, "pages: " + w(P(G).pages) + " | window: [" + w(P(G).window) + "]", 1),
1199
- x("div", null, "zoom: " + w(P(G).zoom) + " | load: " + w(P(G).loadMs), 1),
1200
- x("div", null, "plan: " + w(P(G).planKB) + "KB", 1)
1201
- ])) : B("", !0)
1202
- ], 4));
1203
- }
1204
- }), wn = /* @__PURE__ */ Ce(bn, [["__scopeId", "data-v-a0054844"]]), Tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1205
- __proto__: null,
1206
- default: wn
1207
- }, Symbol.toStringTag, { value: "Module" }));
1208
- export {
1209
- en as D,
1210
- se as M,
1211
- _t as R,
1212
- kn as S,
1213
- tn as a,
1214
- wn as b,
1215
- qt as c,
1216
- Ae as d,
1217
- xt as e,
1218
- an as f,
1219
- Cn as g,
1220
- Mn as h,
1221
- Rn as i,
1222
- ln as j,
1223
- yt as k,
1224
- Et as l,
1225
- Pt as m,
1226
- Tn as n,
1227
- $n as p,
1228
- nn as r,
1229
- on as t,
1230
- rn as u
1231
- };