@agile-team/mach-report 2.9.1 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +11 -7
  2. package/dist/ExcelBindingWizard-CjIiVox-.cjs +1 -0
  3. package/dist/ExcelBindingWizard-Dxm-K5HL.js +1240 -0
  4. package/dist/ParamEditor-D-Hf5xfO.cjs +1 -0
  5. package/dist/ParamEditor-DRGxzxeO.js +381 -0
  6. package/dist/ReportBatchPanel-BYgg0EDB.cjs +1 -0
  7. package/dist/ReportBatchPanel-Bby5yLzU.js +287 -0
  8. package/dist/ReportPreview-DWXROHBP.cjs +6 -0
  9. package/dist/ReportPreview-DiNXhQI0.js +4138 -0
  10. package/dist/ReportTemplateLibrary-C6CO7YCT.cjs +1 -0
  11. package/dist/ReportTemplateLibrary-DfzDXRvr.js +260 -0
  12. package/dist/RuleEditor-C2QsOHOs.cjs +1 -0
  13. package/dist/RuleEditor-D9wQHrkf.js +2024 -0
  14. package/dist/TemplateReviewPanel-BKofGrV9.js +222 -0
  15. package/dist/TemplateReviewPanel-DwtOcLue.cjs +1 -0
  16. package/dist/analytics.cjs +1 -1
  17. package/dist/analytics.d.cts +4 -0
  18. package/dist/analytics.d.ts +4 -0
  19. package/dist/analytics.js +40 -39
  20. package/dist/{assets-ahTRUXRk.cjs → assets-Bu6UohJx.cjs} +1 -1
  21. package/dist/{assets-DDsfEi8R.js → assets-DegqDNqY.js} +1 -1
  22. package/dist/batch-Bt3Fd27Z.cjs +1 -0
  23. package/dist/batch-mRqhhhjt.js +364 -0
  24. package/dist/{capabilities-Cm9hZ3uV.js → capabilities-CK_7hizc.js} +16 -16
  25. package/dist/capabilities-CsZ-pNHR.cjs +1 -0
  26. package/dist/computed-Bvk0W15F.js +521 -0
  27. package/dist/computed-CGV2a809.cjs +1 -0
  28. package/dist/config-B612mw0x.js +525 -0
  29. package/dist/config-BRoLo2oj.cjs +1 -0
  30. package/dist/designer.cjs +2 -2
  31. package/dist/designer.d.cts +695 -50
  32. package/dist/designer.d.ts +695 -50
  33. package/dist/designer.js +2213 -1748
  34. package/dist/index.cjs +8 -8
  35. package/dist/index.d.cts +205 -6
  36. package/dist/index.d.ts +205 -6
  37. package/dist/index.js +808 -1033
  38. package/dist/injection-keys-Db_DyLkm.cjs +1 -0
  39. package/dist/injection-keys-e85udZCp.js +7 -0
  40. package/dist/list-cell-BuYn4tGF.cjs +1 -0
  41. package/dist/list-cell-ClFra1zS.js +173 -0
  42. package/dist/matrix-DVyWiYsd.cjs +1 -0
  43. package/dist/matrix-yZsGnldA.js +227 -0
  44. package/dist/param-validation-BlHHXs6u.js +153 -0
  45. package/dist/param-validation-DCK039V1.cjs +1 -0
  46. package/dist/pdf.cjs +49 -49
  47. package/dist/pdf.d.cts +31 -1
  48. package/dist/pdf.d.ts +31 -1
  49. package/dist/pdf.js +4797 -4650
  50. package/dist/plugin-BDTU4D94.cjs +1 -0
  51. package/dist/plugin-Cd5G2QQn.js +22 -0
  52. package/dist/region-binding-workflow-CXDmt9Bs.js +977 -0
  53. package/dist/region-binding-workflow-DhQvu1co.cjs +3 -0
  54. package/dist/{report-params-B_VCihAh.js → report-params-B44imUd4.js} +1 -1
  55. package/dist/{report-params-CjWrjPl6.cjs → report-params-SJfhKgaX.cjs} +1 -1
  56. package/dist/server/node.d.cts +48 -5
  57. package/dist/server/node.d.ts +48 -5
  58. package/dist/server-node.cjs +1 -1
  59. package/dist/server-node.js +503 -317
  60. package/dist/server.cjs +1 -1
  61. package/dist/server.d.cts +252 -4
  62. package/dist/server.d.ts +252 -4
  63. package/dist/server.js +567 -469
  64. package/dist/style.css +1 -1
  65. package/dist/template-registry-WNXdkiET.js +506 -0
  66. package/dist/template-registry-ukBGlm8N.cjs +1 -0
  67. package/dist/template-review-BXp2oyqg.cjs +1 -0
  68. package/dist/template-review-BdcXSYbx.js +1616 -0
  69. package/dist/tree-BX380Rr7.cjs +1 -0
  70. package/dist/tree-CqcQ99NM.js +172 -0
  71. package/dist/useLocalDraft-C07SYRnC.js +11 -0
  72. package/dist/useLocalDraft-Yiw1wFgI.cjs +1 -0
  73. package/dist/{validate-DWPF7icl.js → validate-7s0yn6ii.js} +26 -26
  74. package/dist/validate-DsRiNw8h.cjs +1 -0
  75. package/dist/vue/async.d.cts +118 -6
  76. package/dist/vue/async.d.ts +118 -6
  77. package/dist/vue/index.d.cts +177 -11
  78. package/dist/vue/index.d.ts +177 -11
  79. package/dist/vue-async.cjs +1 -1
  80. package/dist/vue-async.js +5 -5
  81. package/dist/vue.cjs +1 -1
  82. package/dist/vue.js +116 -113
  83. package/dist/{import-template-CNMLJSQw.js → workbook-session-BKOTwcoq.js} +4290 -4227
  84. package/dist/{import-template-CpxunKVp.cjs → workbook-session-CLYLhZWu.cjs} +17 -17
  85. package/dist/worker.cjs +1 -1
  86. package/dist/worker.d.cts +9 -2
  87. package/dist/worker.d.ts +9 -2
  88. package/dist/worker.js +1 -1
  89. package/dist/xlsx.cjs +4 -2
  90. package/dist/xlsx.d.cts +159 -3
  91. package/dist/xlsx.d.ts +159 -3
  92. package/dist/xlsx.js +354 -192
  93. package/package.json +1 -1
  94. package/dist/ExcelBindingWizard-DiaxvWpQ.cjs +0 -1
  95. package/dist/ExcelBindingWizard-RLJIXKKG.js +0 -816
  96. package/dist/ReportPreview-B5ZNEasW.js +0 -4439
  97. package/dist/ReportPreview-DRtVPUYo.cjs +0 -6
  98. package/dist/RuleEditor-CskN5Fr3.cjs +0 -1
  99. package/dist/RuleEditor-CtJFzKuY.js +0 -1578
  100. package/dist/TemplateReviewPanel-C_Lmzis6.cjs +0 -1
  101. package/dist/TemplateReviewPanel-Cn32OY4_.js +0 -173
  102. package/dist/binding-preview-B5834rml.cjs +0 -2
  103. package/dist/binding-preview-ChXjN5L5.js +0 -649
  104. package/dist/capabilities-DYzWL7KS.cjs +0 -1
  105. package/dist/matrix-CNPDJxED.js +0 -745
  106. package/dist/matrix-Div9Ilh3.cjs +0 -1
  107. package/dist/param-validation-BWNjLcN0.js +0 -116
  108. package/dist/param-validation-CiTxFeZ8.cjs +0 -1
  109. package/dist/plugin-BWwIgZXV.js +0 -25
  110. package/dist/plugin-Dg-J1Rbm.cjs +0 -1
  111. package/dist/template-registry-CHMYZ7SD.cjs +0 -1
  112. package/dist/template-registry-R61AMCr0.js +0 -433
  113. package/dist/template-review-hvWWQFsi.js +0 -1027
  114. package/dist/template-review-jEcOfmGr.cjs +0 -1
  115. package/dist/validate-BDiMqkJC.cjs +0 -1
@@ -1,4439 +0,0 @@
1
- import { computed as F, unref as d, ref as W, onScopeDispose as Oe, watch as oe, getCurrentScope as Ra, shallowRef as le, nextTick as Fe, onMounted as bt, onBeforeUnmount as Ma, defineComponent as be, openBlock as E, createElementBlock as I, createElementVNode as b, createVNode as X, createTextVNode as re, toDisplayString as x, Fragment as fe, renderList as me, createCommentVNode as j, withModifiers as nt, withDirectives as Zt, withKeys as Ht, vModelText as Yt, createBlock as Ie, normalizeClass as pe, renderSlot as at, getCurrentInstance as Xt, onUnmounted as Qt, createStaticVNode as Ta, isRef as On, inject as gt, provide as Ln, watchEffect as Da, normalizeStyle as De, createSlots as Aa, withCtx as Ot } from "vue";
2
- import { renderPage as zn, renderPlanToImages as Fa, calculateReportSelection as Oa, ReportCalculationError as La, ReportParamValidationError as za, ReportSourceError as qa, inspectOutputCapabilities as Ba, validateReportParams as qn, summarizeReportCellEdits as Cn, createReportCellEditBatch as Na, ReportCellEditError as ze, createReportCellResolver as Kt, parseReportCellFieldInput as ja, applyReportEditResult as Ha, applyReportCellEditBatch as Ka, reportCellEditKey as $n, getReportCellContext as ct, validateReportCellFieldDefinition as Wa, parseReportClipboard as Ua, formatReportClipboard as Va, resolvePlanAssets as Ga, paginateTemplate as Ja, validateRenderPlan as Za, renderPlanToCanvas as Ya } from "@agile-team/mach-report";
3
- import { c as Bn } from "./page-window-index-CIuT4BAv.js";
4
- import { a as Ae, n as In, w as Ge, f as Xa } from "./progress-7OSZbFok.js";
5
- import { i as Qa, a as _a } from "./render-plan-Ck6koX9L.js";
6
- import { a as ee, _ as ye } from "./_plugin-vue_export-helper-8SL1F89S.js";
7
- import { r as Nn } from "./grid-geometry-BNptEcMm.js";
8
- import { b as Wt, c as es, d as ts, a as ns } from "./plugin-BWwIgZXV.js";
9
- function jn(e) {
10
- return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
11
- }
12
- function Fi(e) {
13
- return jn(e).join(",");
14
- }
15
- class Lt extends Error {
16
- constructor(t) {
17
- super(t), this.name = "PlanLoadError";
18
- }
19
- }
20
- function Oi(e = {}) {
21
- const { baseUrl: t = "", headers: n, credentials: a, timeoutMs: s = 3e4 } = e, o = t.replace(/\/+$/, "");
22
- return async ({ url: r, method: l, params: c, signal: v }) => {
23
- let h = `${o}${r}`;
24
- if (c && Object.keys(c).length > 0) {
25
- const i = h.indexOf("#"), k = i >= 0 ? h.slice(i) : "", R = i >= 0 ? h.slice(0, i) : h, D = R.indexOf("?"), A = D >= 0 ? R.slice(0, D) : R, z = new URLSearchParams(D >= 0 ? R.slice(D + 1) : "");
26
- for (const [H, J] of Object.entries(c)) z.set(H, J);
27
- h = `${A}?${z}${k}`;
28
- }
29
- const f = (i, k) => {
30
- const R = new Lt(i);
31
- return Object.defineProperty(R, "cause", { value: k, configurable: !0, writable: !0 }), R;
32
- };
33
- if (v?.aborted)
34
- throw f(`请求已取消: ${r}`, v.reason);
35
- const m = new AbortController();
36
- let w;
37
- const p = () => {
38
- m.signal.aborted || (w = "external", m.abort(v?.reason));
39
- };
40
- v?.addEventListener("abort", p, { once: !0 });
41
- const u = setTimeout(() => {
42
- m.signal.aborted || (w = "timeout", m.abort());
43
- }, s);
44
- try {
45
- const i = await fetch(h, {
46
- method: l.toUpperCase(),
47
- headers: { Accept: "application/json", ...n },
48
- credentials: a,
49
- signal: m.signal
50
- });
51
- if (!i.ok)
52
- throw new Lt(`HTTP ${i.status} ${r}`);
53
- return await i.json();
54
- } catch (i) {
55
- throw w === "timeout" ? f(`请求超时(${s}ms): ${r}`, i) : w === "external" ? f(`请求已取消: ${r}`, i) : i instanceof Lt ? i : f(`请求失败(${r}): ${i instanceof Error ? i.message : String(i)}`, i);
56
- } finally {
57
- clearTimeout(u), v?.removeEventListener("abort", p);
58
- }
59
- };
60
- }
61
- function as(e, t, n = {}) {
62
- const a = n.pxPerMm ?? 3.7795275590551185, s = F(() => Math.max(0, d(n.gapPx) ?? 18)), o = W(0), r = W(800), l = F(() => {
63
- const i = e.value?.pages ?? [];
64
- return Bn(i.map((k) => k.pageHeightMm * a), s.value);
65
- }), c = F(() => {
66
- let i = 0;
67
- for (const k of e.value?.pages ?? []) i = Math.max(i, k.pageWidthMm * a);
68
- return { w: i, h: l.value.totalHeightPx };
69
- }), v = F(() => l.value.window(
70
- r.value / t.value,
71
- o.value / t.value,
72
- d(n.overscan) ?? 1
73
- )), h = F(() => {
74
- const i = e.value;
75
- if (!i) return [];
76
- const { start: k, end: R } = v.value;
77
- return i.pages.slice(k, R + 1).map((D, A) => ({ page: D, index: k + A }));
78
- });
79
- let f = 0, m = !1;
80
- function w(i) {
81
- i && (o.value = i.scrollTop, r.value = i.clientHeight || 800);
82
- }
83
- function p(i, k) {
84
- return (R) => {
85
- f || m || (f = requestAnimationFrame(() => {
86
- if (f = 0, m || (w(R), k.value <= 0)) return;
87
- const D = Math.max(0, R.scrollTop + 32) / t.value;
88
- i.value = Math.min(k.value, l.value.pageAt(D) + 1);
89
- }));
90
- };
91
- }
92
- function u() {
93
- m = !0, f && cancelAnimationFrame(f), f = 0;
94
- }
95
- return Oe(u), {
96
- contentSize: c,
97
- windowRange: v,
98
- visiblePages: h,
99
- makeScrollHandler: p,
100
- refreshViewport: w,
101
- pageOffsetPx: (i) => l.value.offsetAt(i),
102
- destroy: u
103
- };
104
- }
105
- const Pn = 96 / 25.4;
106
- function ss(e) {
107
- const t = /* @__PURE__ */ new WeakMap(), n = W(0);
108
- let a, s = 0, o = 0, r = !1;
109
- function l() {
110
- s++, o && cancelAnimationFrame(o), o = 0;
111
- }
112
- function c(u, i, k, R) {
113
- return !r && i === s && e.plan.value === k && e.root.value === R && R.contains(u.holder) && Number(u.holder.dataset.page) === u.index + 1;
114
- }
115
- function v(u) {
116
- const { holder: i, page: k } = u;
117
- t.delete(i), i.style.width = `${k.pageWidthMm * Pn}px`, i.style.height = `${k.pageHeightMm * Pn}px`, i.setAttribute("aria-busy", "true");
118
- const R = i.ownerDocument.createElement("div");
119
- R.className = "mrp-page-loading";
120
- const D = i.ownerDocument.createElement("span");
121
- D.textContent = e.loading(), D.style.transform = `scale(${1 / Math.max(1e-4, e.zoom())})`, R.append(D), i.replaceChildren(R);
122
- }
123
- function h(u) {
124
- const i = t.get(u.holder);
125
- return !i || i.page !== u.page || i.element.parentElement !== u.holder ? !1 : (i.query !== e.query() && (e.clear(i.element), e.highlight(i.element), i.query = e.query()), !0);
126
- }
127
- function f(u, i, k, R) {
128
- if (c(u, i, k, R))
129
- try {
130
- const D = zn(u.page, 96, {}, u.holder.ownerDocument);
131
- if (e.highlight(D), !c(u, i, k, R)) return;
132
- u.holder.replaceChildren(D), u.holder.removeAttribute("aria-busy"), t.set(u.holder, { page: u.page, element: D, query: e.query() }), e.mounted(u.holder), e.ready();
133
- } catch (D) {
134
- if (!c(u, i, k, R)) return;
135
- u.holder.removeAttribute("aria-busy");
136
- const A = u.holder.ownerDocument.createElement("div");
137
- A.className = "mrp-page-render-error", A.setAttribute("role", "alert"), A.textContent = D instanceof Error ? D.message : String(D), u.holder.replaceChildren(A), e.error(D);
138
- }
139
- }
140
- function m(u, i, k, R) {
141
- u.length && (o = requestAnimationFrame(() => {
142
- if (i !== s || r) return;
143
- o = 0;
144
- const D = u.shift();
145
- D && f(D, i, k, R), i === s && e.plan.value === k && e.root.value === R && m(u, i, k, R);
146
- }));
147
- }
148
- function w() {
149
- l();
150
- const u = e.plan.value, i = e.root.value;
151
- if (r || !u || !i) {
152
- a = void 0;
153
- return;
154
- }
155
- const k = s, R = a?.plan === u ? a.index : e.priority();
156
- a = void 0;
157
- const D = [];
158
- i.querySelectorAll(".mrp-page-holder").forEach((H) => {
159
- const J = Number(H.dataset.page) - 1, Z = u.pages[J];
160
- if (!Z) return;
161
- const Y = { holder: H, page: Z, index: J };
162
- h(Y) || (v(Y), D.push(Y));
163
- });
164
- const A = D.findIndex((H) => H.index === R), z = A < 0 ? void 0 : D.splice(A, 1)[0];
165
- z && f(z, k, u, i), e.ready(), m(D, k, u, i);
166
- }
167
- function p(u) {
168
- r || !e.plan.value || (a = { plan: e.plan.value, index: u }, n.value++);
169
- }
170
- return oe([e.plan, e.root, e.pages, e.priority, e.focusToken, e.query, e.zoom, e.loading, n], w, { flush: "post", immediate: !0 }), Oe(() => {
171
- r = !0, a = void 0, l();
172
- }), { prioritize: p, cancel: l };
173
- }
174
- function os(e) {
175
- const t = W(1), n = W("fit");
176
- let a = 0;
177
- function s() {
178
- a && cancelAnimationFrame(a), a = 0;
179
- }
180
- function o() {
181
- s(), a = requestAnimationFrame(() => {
182
- if (a = 0, n.value !== "fit") return;
183
- const l = e();
184
- !l?.viewport || l.viewport.clientWidth <= 48 || !Number.isFinite(l.pageWidthPx) || (t.value = Math.min(1, (l.viewport.clientWidth - 48) / Math.max(1, l.pageWidthPx)));
185
- });
186
- }
187
- function r(l) {
188
- if (l === "fit")
189
- n.value = "fit", o();
190
- else {
191
- if (!Number.isFinite(l)) return;
192
- s(), n.value = "raw", t.value = Math.min(3, Math.max(0.3, l / 100));
193
- }
194
- }
195
- return Ra() && Oe(s), { zoom: t, zoomMode: n, applyFitZoom: o, setZoom: r };
196
- }
197
- let rs = 0;
198
- function Sn(e, t) {
199
- const n = new AbortController();
200
- let a = { taskId: `mr-output-${Date.now().toString(36)}-${++rs}`, kind: e, stage: e === "print" ? "print" : "encode", status: "running", cancellable: !0 };
201
- function s() {
202
- try {
203
- t?.(Object.freeze({ ...a }));
204
- } catch {
205
- }
206
- }
207
- return {
208
- controller: n,
209
- get task() {
210
- return a;
211
- },
212
- start: s,
213
- update(o, r, l) {
214
- n.signal.aborted || a.status !== "running" || (a = { ...a, stage: o, completed: r, total: l }, s());
215
- },
216
- finish(o = "completed") {
217
- a.status === "running" && (a = { ...a, status: o, cancellable: !1 }, s(), o === "cancelled" && n.abort());
218
- }
219
- };
220
- }
221
- const Ve = 8;
222
- function tt() {
223
- return new Promise((e) => setTimeout(e, 0));
224
- }
225
- function dt(e) {
226
- return `p${e.pageWidthMm}x${e.pageHeightMm}`.replace(/[.+]/g, "_");
227
- }
228
- function pt(e) {
229
- const t = /* @__PURE__ */ new Map();
230
- return e.pages.forEach((s) => {
231
- t.has(dt(s)) || t.set(dt(s), s);
232
- }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
233
- .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
234
- .mr-comp{break-inside:avoid;page-break-inside:avoid;}
235
- ${[...t.values()].map(
236
- (s) => `@page ${dt(s)}{size:${s.pageWidthMm}mm ${s.pageHeightMm}mm;margin:0;}`
237
- ).join(`
238
- `)}
239
- body{margin:0;background:#fff;}`}</style></head><body>`;
240
- }
241
- function vt(e) {
242
- const t = zn(e, 96, {}, document);
243
- return t.style.page = dt(e), t.outerHTML;
244
- }
245
- function ls(e) {
246
- return { head: pt(e), pageChunks: e.pages.map(vt) };
247
- }
248
- async function Li(e, t = {}) {
249
- const n = {
250
- schemaVersion: "mach-report-batch-print",
251
- pages: e.flatMap((r) => r.pages)
252
- };
253
- if (n.pages.length === 0) return;
254
- const a = pt(n), s = document.createElement("iframe");
255
- s.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(s);
256
- let o = !1;
257
- try {
258
- const r = s.contentDocument;
259
- r.open(), r.write(a);
260
- for (let l = 0; l < n.pages.length; l++)
261
- Ae(t.signal), r.write(vt(n.pages[l])), l % Ve === Ve - 1 && (In(t, l + 1, n.pages.length), await tt());
262
- r.write("</body></html>"), r.close(), await tt(), In(t, n.pages.length, n.pages.length), o = !0, s.contentWindow?.focus(), s.contentWindow?.print();
263
- } catch (r) {
264
- if (t.signal?.aborted) throw r;
265
- t.onError?.(r instanceof Error ? `批量打印失败: ${r.message}` : "批量打印失败");
266
- } finally {
267
- o ? setTimeout(() => s.remove(), 6e4) : s.remove();
268
- }
269
- }
270
- function Hn(e) {
271
- return `<!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]-->${e.replace(/^<!doctype html><html><head>/, "")}`;
272
- }
273
- function zi(e) {
274
- const { head: t, pageChunks: n } = ls(e);
275
- return {
276
- html: `${Hn(t)}${n.join("")}</body></html>`,
277
- filename: "mach-report.doc"
278
- };
279
- }
280
- function is(e, t) {
281
- let n = null, a = !1, s = !1, o = 0;
282
- const r = /* @__PURE__ */ new Map();
283
- let l = null;
284
- const c = /* @__PURE__ */ new Map();
285
- let v = null, h = null, f = null, m = null, w = null;
286
- function p($, P) {
287
- return !s && e.value === $ && o === P;
288
- }
289
- function u() {
290
- if (s) return;
291
- const $ = [...r.values()].reverse().find((P) => p(P.plan, P.epoch))?.format ?? null;
292
- $ !== v && (v = $, t.onBusy?.($));
293
- }
294
- function i($, P, q) {
295
- const T = {};
296
- return r.set(T, { plan: $, epoch: P, format: q, run: Sn("export", t.onTask) }), r.get(T).run.start(), u(), T;
297
- }
298
- function k($) {
299
- r.get($)?.run.finish(), r.delete($), u();
300
- }
301
- function R() {
302
- for (const [$, P] of c)
303
- p(P.plan, P.epoch) || ($.close(), c.delete($));
304
- }
305
- function D() {
306
- for (const $ of r.values()) $.run.finish("cancelled");
307
- l?.finish("cancelled"), o++, z(), u(), R();
308
- }
309
- const A = oe(e, D, { flush: "sync" });
310
- function z() {
311
- n?.remove(), n = null;
312
- }
313
- function H() {
314
- D(), s = !0, o++, A(), z(), R(), r.clear(), t.onPrinting?.(!1);
315
- }
316
- function J($, P) {
317
- const q = URL.createObjectURL($);
318
- setTimeout(() => URL.revokeObjectURL(q), 1e4);
319
- const T = document.createElement("a");
320
- T.href = q, T.download = P, T.click();
321
- }
322
- function Z($, P, q, T, V) {
323
- q.update("download"), p($, P) && !q.controller.signal.aborted && J(T, V);
324
- }
325
- async function Y($, P, q, T) {
326
- const V = $.contentDocument;
327
- V.open(), V.write(pt(P));
328
- for (let Q = 0; Q < P.pages.length; Q++)
329
- if (T.controller.signal.aborted || (V.write(vt(P.pages[Q])), T.update("print", Q + 1, P.pages.length), Q % Ve === Ve - 1 && await tt(), $ !== n)) return !1;
330
- return V.write("</body></html>"), V.close(), await tt(), !(!p(P, q) || $ !== n);
331
- }
332
- async function te() {
333
- if (a) return;
334
- const $ = e.value;
335
- if (s || !$ || $.pages.length === 0) return;
336
- const P = o;
337
- a = !0;
338
- const q = Sn("print", t.onTask);
339
- l = q, q.start(), t.onPrinting?.(!0), z(), n = document.createElement("iframe"), n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
340
- const T = n;
341
- try {
342
- if (!p($, P) || q.controller.signal.aborted) {
343
- z();
344
- return;
345
- }
346
- if (!await Y(T, $, P, q)) return;
347
- T.contentWindow?.focus(), T.contentWindow?.print();
348
- } catch {
349
- q.finish("failed"), T === n && z(), p($, P) && t.onError("调用打印失败,请改用导出 PDF", "print");
350
- } finally {
351
- q.finish(), l === q && (l = null), a = !1, s || t.onPrinting?.(!1);
352
- }
353
- }
354
- function ne($, P, q) {
355
- return {
356
- signal: q.controller.signal,
357
- onDiagnostic: (T) => {
358
- p($, P) && !q.controller.signal.aborted && t.onDiagnostic?.(T);
359
- },
360
- onProgress: (T, V) => q.update("encode", T, V)
361
- };
362
- }
363
- function y($, P, q) {
364
- if (h?.plan === $ && h.epoch === P) return h.promise;
365
- const T = Promise.resolve().then(() => {
366
- if (!p($, P)) throw new Error("报表已切换或卸载");
367
- return Ge(t.getPdfExporter()($, (V) => {
368
- p($, P) && t.onWarning?.(V);
369
- }, q ? ne($, P, q) : void 0), q?.controller.signal);
370
- }).finally(() => {
371
- h?.promise === T && (h = null);
372
- });
373
- return h = { plan: $, epoch: P, promise: T }, T;
374
- }
375
- async function C() {
376
- const $ = e.value;
377
- if (s || !$ || $.pages.length === 0) return;
378
- const P = o;
379
- if (f?.plan === $ && f.epoch === P) return f.promise;
380
- const q = i($, P, "PDF"), T = (async () => {
381
- try {
382
- const V = r.get(q).run, Q = await y($, P, V);
383
- if (!p($, P)) return;
384
- Z($, P, V, new Blob([Q], { type: "application/pdf" }), "mach-report.pdf");
385
- } catch (V) {
386
- r.get(q)?.run.finish("failed"), p($, P) && t.onError(V instanceof Error ? `PDF 导出失败: ${V.message}` : "PDF 导出失败", "pdf");
387
- } finally {
388
- k(q), f?.token === q && (f = null);
389
- }
390
- })();
391
- return f = { plan: $, epoch: P, promise: T, token: q }, T;
392
- }
393
- async function M() {
394
- const $ = e.value;
395
- if (s || !$ || $.pages.length === 0) return;
396
- const P = o;
397
- if (m?.plan === $ && m.epoch === P) return m.promise;
398
- const q = { ...t.getXlsxOptions?.() }, T = i($, P, "Excel"), V = (async () => {
399
- try {
400
- const { renderPlanToXlsx: Q } = await import("@agile-team/mach-report/xlsx");
401
- if (!p($, P)) return;
402
- const ie = r.get(T).run, { buffer: Ee, warnings: we } = await Ge(Q($, { ...q, ...ne($, P, ie) }), ie.controller.signal);
403
- if (!p($, P) || (we.length > 0 && t.onWarning?.(`Excel 导出有 ${we.length} 条提示:${we.slice(0, 2).join(";")}`), !p($, P))) return;
404
- Z($, P, ie, new Blob([Ee], {
405
- type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
406
- }), "mach-report.xlsx");
407
- } catch (Q) {
408
- r.get(T)?.run.finish("failed"), p($, P) && t.onError(Q instanceof Error ? `Excel 导出失败: ${Q.message}` : "Excel 导出失败", "export");
409
- } finally {
410
- k(T), m?.token === T && (m = null);
411
- }
412
- })();
413
- return m = { plan: $, epoch: P, promise: V, token: T }, V;
414
- }
415
- async function O() {
416
- const $ = e.value;
417
- if (s || !$ || $.pages.length === 0) return;
418
- const P = o;
419
- if (w?.plan === $ && w.epoch === P) return w.promise;
420
- const q = i($, P, "图片"), T = (async () => {
421
- try {
422
- const V = r.get(q).run, { blobs: Q } = await Ge(Fa($, {
423
- ...ne($, P, V),
424
- dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
425
- }), V.controller.signal);
426
- if (!p($, P)) return;
427
- Q.forEach((ie, Ee) => {
428
- Z($, P, V, ie, Q.length > 1 ? `mach-report-page-${Ee + 1}.png` : "mach-report.png");
429
- });
430
- } catch (V) {
431
- r.get(q)?.run.finish("failed"), p($, P) && t.onError(
432
- V instanceof Error ? `图片导出失败: ${V.message}` : "图片导出失败",
433
- "export"
434
- );
435
- } finally {
436
- k(q), w?.token === q && (w = null);
437
- }
438
- })();
439
- return w = { plan: $, epoch: P, promise: T, token: q }, T;
440
- }
441
- async function N($) {
442
- const P = e.value;
443
- if (s || !P || !P.pages.length) return;
444
- const q = o, T = i(P, q, $ === "word" ? "Word" : "HTML"), V = r.get(T).run;
445
- try {
446
- const Q = [];
447
- for (const [we, st] of P.pages.entries()) {
448
- if (!p(P, q)) return;
449
- Q.push(vt(st)), V.update("encode", we + 1, P.pages.length), we % Ve === Ve - 1 && await tt();
450
- }
451
- if (!p(P, q)) return;
452
- const ie = pt(P), Ee = `${$ === "word" ? Hn(ie) : ie}${Q.join("")}</body></html>`;
453
- Z(P, q, V, new Blob([Ee], { type: $ === "word" ? "application/msword;charset=utf-8" : "text/html;charset=utf-8" }), $ === "word" ? "mach-report.doc" : "mach-report.html");
454
- } catch (Q) {
455
- V.finish("failed"), p(P, q) && t.onError(Q instanceof Error ? `导出失败: ${Q.message}` : "导出失败", "export");
456
- } finally {
457
- k(T);
458
- }
459
- }
460
- async function K() {
461
- await N("word");
462
- }
463
- async function G($) {
464
- const P = e.value;
465
- if (!(s || !P || P.pages.length === 0)) {
466
- if ($ === "pdf") {
467
- await C();
468
- return;
469
- }
470
- if ($ === "xlsx" || $ === "excel") {
471
- await M();
472
- return;
473
- }
474
- if ($ === "png" || $ === "image") {
475
- await O();
476
- return;
477
- }
478
- if ($ === "word" || $ === "doc") {
479
- await K();
480
- return;
481
- }
482
- if ($ !== "html") {
483
- t.onError(`不支持的导出格式:${$}`, "export");
484
- return;
485
- }
486
- await N("html");
487
- }
488
- }
489
- function B() {
490
- const $ = e.value;
491
- if (s || !$ || $.pages.length === 0) return;
492
- const P = o, q = window.open("", "_blank");
493
- if (!q) {
494
- t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
495
- return;
496
- }
497
- c.set(q, { plan: $, epoch: P });
498
- const T = i($, P, "PDF");
499
- y($, P, r.get(T).run).then((V) => {
500
- if (!p($, P) || q.closed) {
501
- c.delete(q) && q.close();
502
- return;
503
- }
504
- const Q = URL.createObjectURL(new Blob([V], { type: "application/pdf" }));
505
- setTimeout(() => URL.revokeObjectURL(Q), 6e4);
506
- const ie = q.document;
507
- ie.title = "PDF 预览", ie.documentElement.style.height = "100%", ie.body.style.cssText = "margin:0;height:100%;";
508
- const Ee = ie.createElement("iframe");
509
- Ee.title = "PDF 预览", Ee.style.cssText = "display:block;width:100%;height:100%;border:0;", Ee.src = Q, ie.body.replaceChildren(Ee), c.delete(q);
510
- }).catch((V) => {
511
- r.get(T)?.run.finish("failed"), q.close(), c.delete(q), p($, P) && t.onError(V instanceof Error ? `PDF 预览失败: ${V.message}` : "PDF 预览失败", "pdf");
512
- }).finally(() => k(T));
513
- }
514
- return {
515
- print: te,
516
- exportAs: G,
517
- exportImages: O,
518
- exportWord: K,
519
- openPdfWindow: B,
520
- invalidatePending: D,
521
- cancel: D,
522
- releasePrintFrame: z,
523
- dispose: H
524
- };
525
- }
526
- const Kn = "mrp-hit";
527
- function us(e) {
528
- e.querySelectorAll(`mark.${Kn}`).forEach((n) => {
529
- const a = n.parentNode;
530
- if (a) {
531
- for (; n.firstChild; ) a.insertBefore(n.firstChild, n);
532
- n.remove(), a.normalize();
533
- }
534
- });
535
- }
536
- function cs(e, t) {
537
- const n = t.trim();
538
- if (!n) return 0;
539
- const a = n.toLowerCase(), s = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
540
- acceptNode(l) {
541
- const c = l.parentElement;
542
- return !c || c.closest("mark") || /^(SCRIPT|STYLE)$/.test(c.tagName) ? NodeFilter.FILTER_REJECT : (l.nodeValue ?? "").toLowerCase().includes(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
543
- }
544
- }), o = [];
545
- for (let l = s.nextNode(); l; l = s.nextNode()) o.push(l);
546
- let r = 0;
547
- for (const l of o) {
548
- const c = l.nodeValue ?? "", v = c.toLowerCase(), h = l.parentElement;
549
- if (!h) continue;
550
- const f = document.createDocumentFragment();
551
- let m = 0, w = v.indexOf(a);
552
- for (; w >= 0; ) {
553
- w > m && f.appendChild(document.createTextNode(c.slice(m, w)));
554
- const p = document.createElement("mark");
555
- p.className = Kn, p.textContent = c.slice(w, w + n.length), f.appendChild(p), r++, m = w + n.length, w = v.indexOf(a, m);
556
- }
557
- m < c.length && f.appendChild(document.createTextNode(c.slice(m))), h.replaceChild(f, l);
558
- }
559
- return r;
560
- }
561
- const ds = /* @__PURE__ */ new Set(["line", "rect", "ellipse", "chart"]);
562
- function* fs(e) {
563
- for (const t of e.cells ?? [])
564
- for (const n of t ?? [])
565
- yield n?.text ?? "", yield* n?.children ?? [];
566
- }
567
- function* ms(e) {
568
- if (_a(e))
569
- for (const t of e.richParagraphs)
570
- for (const n of t.segments ?? [])
571
- yield (n.kind === "field" ? n.field : n.text) ?? "";
572
- else e.lines?.length ? yield* e.lines : yield e.text ?? "";
573
- }
574
- function* gs(e) {
575
- const t = [e.values()];
576
- for (; t.length > 0; ) {
577
- const n = t[t.length - 1].next();
578
- if (n.done) {
579
- t.pop();
580
- continue;
581
- }
582
- const a = n.value;
583
- if (typeof a == "string") {
584
- yield a;
585
- continue;
586
- }
587
- yield "", !Qa(a) && (a.kind === "text" ? t.push(ms(a)) : a.grid ? t.push(fs(a.grid)) : ds.has(a.kind) || (yield a.fallbackText ?? ""));
588
- }
589
- }
590
- function* ps(e) {
591
- for (let t = 0; t < e.pages.length; t++) {
592
- for (const n of gs(e.pages[t].components)) yield { text: n, pageIndex: t };
593
- yield { text: "", pageIndex: t };
594
- }
595
- }
596
- function vs(e, t) {
597
- const n = e.toLowerCase();
598
- let a = 0;
599
- for (let s = n.indexOf(t); s >= 0; s = n.indexOf(t, s + t.length)) a++;
600
- return a;
601
- }
602
- function hs(e) {
603
- const { plan: t, gotoPage: n, highlight: a, clearHighlights: s } = e, o = W(!1), r = W(""), l = W(0), c = W(0), v = W(!1);
604
- let h = [];
605
- const f = F(() => {
606
- if (c.value === 0) return null;
607
- const A = l.value;
608
- let z = 0, H = h.length - 1;
609
- for (; z < H; ) {
610
- const Z = z + H >>> 1;
611
- h[Z].cumulative <= A ? z = Z + 1 : H = Z;
612
- }
613
- const J = h[z];
614
- return J ? { pageIndex: J.pageIndex, occurrence: A - (h[z - 1]?.cumulative ?? 0) } : null;
615
- });
616
- let m = null, w = null, p = 0;
617
- function u() {
618
- p++, m && clearTimeout(m), w && clearTimeout(w), m = w = null, v.value = !1;
619
- }
620
- function i(A) {
621
- r.value = A, l.value = 0, c.value = 0, h = [], v.value = !1;
622
- const z = A.trim().toLowerCase(), H = t.value;
623
- if (!z || !H) return;
624
- v.value = !0;
625
- const J = p, Z = ps(H), Y = [];
626
- let te = 0;
627
- function ne() {
628
- if (w = null, J !== p || H !== t.value) return;
629
- const y = performance.now();
630
- let C = 0;
631
- for (; C < 5e3 && performance.now() - y < 4; ) {
632
- const M = Z.next();
633
- if (M.done) {
634
- h = Y, c.value = te, v.value = !1, h[0] && n(h[0].pageIndex + 1);
635
- return;
636
- }
637
- const O = vs(M.value.text, z);
638
- if (O > 0) {
639
- te += O;
640
- const N = Y[Y.length - 1];
641
- N?.pageIndex === M.value.pageIndex ? N.cumulative = te : Y.push({ pageIndex: M.value.pageIndex, cumulative: te });
642
- }
643
- C++;
644
- }
645
- w = setTimeout(ne, 0);
646
- }
647
- ne();
648
- }
649
- function k(A) {
650
- if (u(), r.value = A, l.value = c.value = 0, h = [], !A.trim()) {
651
- i("");
652
- return;
653
- }
654
- v.value = !0, m = setTimeout(() => {
655
- m = null, i(A);
656
- }, Math.max(0, d(e.debounceMs) ?? 200));
657
- }
658
- function R(A) {
659
- const z = c.value;
660
- if (z === 0 || v.value) return;
661
- l.value = (l.value + A + z) % z;
662
- const H = f.value;
663
- H && n(H.pageIndex + 1);
664
- }
665
- function D() {
666
- u(), r.value = "", l.value = c.value = 0, h = [];
667
- }
668
- return oe(t, D, { flush: "sync" }), Oe(D), {
669
- visible: o,
670
- query: r,
671
- matchIndex: l,
672
- matchCount: c,
673
- activeMatch: f,
674
- searching: v,
675
- toggle: () => {
676
- o.value = !o.value;
677
- },
678
- onInput: k,
679
- onNav: R,
680
- apply: (A) => {
681
- r.value.trim() && a(A, r.value.trim());
682
- },
683
- clear: (A) => {
684
- s(A);
685
- },
686
- reset: D
687
- };
688
- }
689
- function bs(e, t) {
690
- const n = F(() => {
691
- if (e.value) return !0;
692
- if (typeof location > "u") return !1;
693
- try {
694
- return new URLSearchParams(location.search).get("mrp-debug") === "1";
695
- } catch {
696
- return !1;
697
- }
698
- }), a = F(() => !n.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), s = F(() => !n.value || !t.plan.value ? null : {
699
- pages: t.pageCount.value,
700
- window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
701
- zoom: `${Math.round(t.zoom.value * 100)}%`,
702
- loadMs: `${t.loadMs.value}ms`,
703
- planKB: a.value
704
- });
705
- return { enabled: n, debugStats: s };
706
- }
707
- function ys(e, t) {
708
- const { thumbsRoot: n, visible: a, renderThumbCanvas: s } = t, o = W(0), r = W(800), l = F(() => (e.value?.pages ?? []).map(
709
- (R) => Math.round(R.pageHeightMm / R.pageWidthMm * 116)
710
- )), c = F(() => Bn(l.value.map((R) => R + 20), 8)), v = F(() => c.value.window(r.value, o.value, 1)), h = F(() => {
711
- if (!a.value) return [];
712
- const { start: R, end: D } = v.value;
713
- return l.value.slice(R, D + 1).map((A, z) => ({ index: R + z, height: A }));
714
- });
715
- let f = 0, m = 0, w = !1;
716
- function p() {
717
- const R = n.value;
718
- R && (o.value = R.scrollTop, r.value = R.clientHeight || 800);
719
- }
720
- function u() {
721
- w || m || (m = requestAnimationFrame(() => {
722
- m = 0, p();
723
- }));
724
- }
725
- function i() {
726
- if (h.value, f && cancelAnimationFrame(f), f = 0, w || !a.value || !e.value || !n.value) return;
727
- p();
728
- const R = h.value, D = e.value, A = n.value;
729
- let z = 0;
730
- function H() {
731
- if (f = 0, !(w || !a.value || e.value !== D || n.value !== A)) {
732
- for (let J = 0; z < R.length && J < 2; J++, z++) {
733
- const Z = R[z].index, Y = A.querySelector(`[data-thumb="${Z + 1}"]`);
734
- if (!Y || Y.childElementCount > 0) continue;
735
- const te = s(Z);
736
- te && (te.style.width = "100%", te.style.height = "100%", te.style.display = "block", Y.appendChild(te));
737
- }
738
- z < R.length && (f = requestAnimationFrame(H));
739
- }
740
- }
741
- f = requestAnimationFrame(H);
742
- }
743
- function k() {
744
- w = !0, f && cancelAnimationFrame(f), m && cancelAnimationFrame(m), f = m = 0;
745
- }
746
- return Oe(k), { schedule: i, destroy: k, onScroll: u, windowRange: v, visibleThumbs: h };
747
- }
748
- function ws() {
749
- const e = le(0);
750
- return {
751
- loadMs: e,
752
- start() {
753
- return typeof performance < "u" ? performance.now() : 0;
754
- },
755
- end(t) {
756
- e.value = t ? Math.round(performance.now() - t) : 0;
757
- }
758
- };
759
- }
760
- function xs(e) {
761
- const t = W(null), n = W(null);
762
- function a() {
763
- t.value?.focus(), t.value?.select();
764
- }
765
- oe(e.visible, (r) => {
766
- r && Fe(a);
767
- });
768
- function s() {
769
- e.close(), Fe(() => n.value?.focus());
770
- }
771
- function o(r) {
772
- r.isComposing || r.keyCode === 229 || r.key !== "Enter" && r.key !== "Escape" || (r.preventDefault(), r.stopPropagation(), r.key === "Escape" ? s() : e.navigate(r.shiftKey ? -1 : 1));
773
- }
774
- return { input: t, toggle: n, focus: a, close: s, onKeydown: o };
775
- }
776
- function Wn() {
777
- const e = W(!1), t = W(null), n = W(null), a = W(null);
778
- function s(l = !1) {
779
- e.value = !1, l && Fe(() => n.value?.focus());
780
- }
781
- function o(l) {
782
- l.target instanceof Node && !t.value?.contains(l.target) && s();
783
- }
784
- function r(l) {
785
- l.key !== "Escape" || !e.value || l.isComposing || (l.preventDefault(), l.stopPropagation(), s(!0));
786
- }
787
- return oe(e, (l) => {
788
- l && Fe(() => (a.value?.querySelector("input") ?? a.value?.querySelector("button:not(:disabled)"))?.focus());
789
- }), bt(() => {
790
- document.addEventListener("pointerdown", o), document.addEventListener("focusin", o);
791
- }), Ma(() => {
792
- document.removeEventListener("pointerdown", o), document.removeEventListener("focusin", o);
793
- }), { opened: e, root: t, trigger: n, panel: a, close: s, onKeydown: r };
794
- }
795
- const ks = ["disabled", "aria-expanded"], Es = ["aria-label"], Cs = ["aria-label", "disabled", "onClick"], $s = { "aria-hidden": "true" }, Is = /* @__PURE__ */ be({
796
- __name: "ReportExportMenu",
797
- props: {
798
- messages: {},
799
- formats: {},
800
- busy: { type: Boolean }
801
- },
802
- emits: ["export"],
803
- setup(e, { emit: t }) {
804
- const n = e, a = t, { opened: s, root: o, trigger: r, panel: l, close: c, onKeydown: v } = Wn(), h = F(() => [
805
- { format: "xlsx", label: n.messages.exportExcel, extension: ".xlsx" },
806
- { format: "pdf", label: n.messages.exportPdf, extension: ".pdf" },
807
- { format: "png", label: n.messages.exportImage, extension: ".png" },
808
- { format: "word", label: n.messages.exportWord, extension: ".doc" },
809
- { format: "html", label: n.messages.exportHtml, extension: ".html" }
810
- ].filter((p) => !n.formats || n.formats.includes(p.format)));
811
- oe(() => n.busy, (p) => {
812
- p && c();
813
- });
814
- function f(p) {
815
- n.busy || (a("export", p), c(!0));
816
- }
817
- function m(p) {
818
- p.key !== "ArrowDown" && p.key !== "ArrowUp" || (p.preventDefault(), s.value = !0, p.key === "ArrowUp" && Fe(() => l.value?.querySelector("button:last-child")?.focus()));
819
- }
820
- function w(p) {
821
- if (p.key === "Tab") {
822
- c();
823
- return;
824
- }
825
- if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(p.key)) return;
826
- p.preventDefault(), p.stopPropagation();
827
- const i = [...l.value?.querySelectorAll("button:not(:disabled)") ?? []], k = i.indexOf(document.activeElement), R = p.key === "Home" ? 0 : p.key === "End" ? i.length - 1 : (k + (p.key === "ArrowDown" ? 1 : -1) + i.length) % i.length;
828
- i[R]?.focus();
829
- }
830
- return (p, u) => h.value.length ? (E(), I("div", {
831
- key: 0,
832
- ref_key: "root",
833
- ref: o,
834
- class: "mrp-export-menu",
835
- onKeydown: u[1] || (u[1] = //@ts-ignore
836
- (...i) => d(v) && d(v)(...i))
837
- }, [
838
- b("button", {
839
- ref_key: "trigger",
840
- ref: r,
841
- type: "button",
842
- class: "mrp-nav mrp-export-trigger",
843
- disabled: e.busy,
844
- "aria-haspopup": "menu",
845
- "aria-expanded": d(s),
846
- onClick: u[0] || (u[0] = (i) => s.value = !d(s)),
847
- onKeydown: m
848
- }, [
849
- X(ee, { name: "download" }),
850
- re(x(e.messages.exportMenu ?? "导出"), 1),
851
- X(ee, {
852
- name: "chevron-down",
853
- size: 12
854
- })
855
- ], 40, ks),
856
- d(s) ? (E(), I("div", {
857
- key: 0,
858
- ref_key: "panel",
859
- ref: l,
860
- class: "mrp-export-panel",
861
- role: "menu",
862
- "aria-label": e.messages.exportMenu ?? "导出",
863
- onKeydown: w
864
- }, [
865
- b("p", null, x(e.messages.exportMenuDescription ?? "选择文件格式"), 1),
866
- (E(!0), I(fe, null, me(h.value, (i) => (E(), I("button", {
867
- key: i.format,
868
- type: "button",
869
- role: "menuitem",
870
- tabindex: "-1",
871
- "aria-label": i.label,
872
- disabled: e.busy,
873
- onClick: (k) => f(i.format)
874
- }, [
875
- X(ee, { name: "file" }),
876
- b("span", null, x(i.label), 1),
877
- b("small", $s, x(i.extension), 1)
878
- ], 8, Cs))), 128))
879
- ], 40, Es)) : j("", !0)
880
- ], 544)) : j("", !0);
881
- }
882
- }), Ps = /* @__PURE__ */ ye(Is, [["__scopeId", "data-v-83a57a3c"]]), Ss = ["aria-label"], Rs = {
883
- class: "mrp-pageinfo",
884
- "aria-live": "polite"
885
- }, Ms = { class: "mrp-page-buttons" }, Ts = ["aria-label", "title", "disabled"], Ds = ["aria-label", "title", "disabled"], As = ["aria-label", "title", "aria-invalid", "disabled"], Fs = ["aria-label", "disabled"], Os = {
886
- key: 1,
887
- class: "mrp-page-error",
888
- role: "alert"
889
- }, Ls = /* @__PURE__ */ be({
890
- __name: "ReportPagination",
891
- props: {
892
- pageCount: {},
893
- currentPage: {},
894
- messages: {},
895
- busy: { type: Boolean }
896
- },
897
- emits: ["goto"],
898
- setup(e, { emit: t }) {
899
- const n = e, a = t, s = W(String(n.currentPage)), o = W(!1), r = F(() => n.messages.pageInfo.replace("{cur}", String(n.currentPage)).replace("{total}", String(n.pageCount)));
900
- oe(() => [n.currentPage, n.pageCount], () => {
901
- s.value = String(n.currentPage), o.value = !1;
902
- });
903
- function l() {
904
- if (n.busy) return;
905
- const c = s.value.trim(), v = Number(c);
906
- o.value = !/^\d+$/.test(c) || !Number.isSafeInteger(v) || v < 1 || v > n.pageCount, !o.value && v !== n.currentPage && a("goto", v);
907
- }
908
- return (c, v) => e.pageCount > 0 ? (E(), I("nav", {
909
- key: 0,
910
- class: "mrp-pagination",
911
- role: "navigation",
912
- "aria-label": e.messages.pagination ?? "报表分页"
913
- }, [
914
- b("span", Rs, x(r.value), 1),
915
- b("div", Ms, [
916
- b("button", {
917
- class: "mrp-nav",
918
- type: "button",
919
- "aria-label": e.messages.prevPage,
920
- title: e.messages.prevPage,
921
- disabled: e.busy || e.currentPage <= 1,
922
- onClick: v[0] || (v[0] = (h) => a("goto", e.currentPage - 1))
923
- }, [
924
- X(ee, { name: "chevron-left" })
925
- ], 8, Ts),
926
- b("button", {
927
- class: "mrp-nav",
928
- type: "button",
929
- "aria-label": e.messages.nextPage,
930
- title: e.messages.nextPage,
931
- disabled: e.busy || e.currentPage >= e.pageCount,
932
- onClick: v[1] || (v[1] = (h) => a("goto", e.currentPage + 1))
933
- }, [
934
- X(ee, { name: "chevron-right" })
935
- ], 8, Ds)
936
- ]),
937
- e.pageCount > 1 ? (E(), I("form", {
938
- key: 0,
939
- class: "mrp-page-jump",
940
- onSubmit: nt(l, ["prevent"])
941
- }, [
942
- b("label", null, [
943
- b("span", null, x(e.messages.pageJump ?? "跳至页"), 1),
944
- Zt(b("input", {
945
- "onUpdate:modelValue": v[2] || (v[2] = (h) => s.value = h),
946
- type: "text",
947
- inputmode: "numeric",
948
- autocomplete: "off",
949
- "aria-label": e.messages.pageJump ?? "跳至页",
950
- title: e.messages.pageJumpHint ?? "Enter 跳转",
951
- "aria-invalid": o.value,
952
- disabled: e.busy,
953
- onInput: v[3] || (v[3] = (h) => o.value = !1),
954
- onKeydown: v[4] || (v[4] = Ht((h) => {
955
- s.value = String(e.currentPage), o.value = !1;
956
- }, ["esc"]))
957
- }, null, 40, As), [
958
- [Yt, s.value]
959
- ])
960
- ]),
961
- b("button", {
962
- class: "mrp-nav",
963
- type: "submit",
964
- "aria-label": e.messages.pageJump ?? "跳至页",
965
- disabled: e.busy
966
- }, [
967
- X(ee, {
968
- name: "arrow-right",
969
- size: 14
970
- })
971
- ], 8, Fs)
972
- ], 32)) : j("", !0),
973
- o.value ? (E(), I("span", Os, x(e.messages.pageJumpInvalid ?? "请输入有效页码"), 1)) : j("", !0)
974
- ], 8, Ss)) : j("", !0);
975
- }
976
- }), Un = /* @__PURE__ */ ye(Ls, [["__scopeId", "data-v-0db4fbd3"]]), zs = ["aria-label"], qs = { class: "mrp-title" }, Bs = ["aria-label"], Ns = ["aria-label", "aria-pressed"], js = ["aria-pressed"], Hs = ["aria-pressed"], Ks = ["aria-label"], Ws = ["aria-pressed"], Us = ["aria-pressed", "onClick"], Vs = ["aria-label"], Gs = ["disabled"], Js = ["disabled"], Zs = ["disabled"], Ys = ["aria-label", "aria-expanded"], Xs = ["aria-label"], Qs = ["placeholder", "aria-label", "value"], _s = ["aria-label"], eo = {
977
- key: 1,
978
- class: "mrp-search-count",
979
- role: "status",
980
- "aria-live": "polite"
981
- }, to = ["disabled", "aria-label"], no = ["disabled", "aria-label"], ao = ["aria-label"], so = {
982
- class: "mrp-search-hint",
983
- role: "status"
984
- }, oo = /* @__PURE__ */ be({
985
- __name: "ReportToolbar",
986
- props: {
987
- pageCount: {},
988
- currentPage: {},
989
- zoomMode: {},
990
- zoom: {},
991
- showExport: { type: Boolean },
992
- showPrint: { type: Boolean },
993
- showPdfWindow: { type: Boolean },
994
- messages: {},
995
- search: {},
996
- thumbsVisible: { type: Boolean },
997
- showImport: { type: Boolean },
998
- showSearch: { type: Boolean, default: !0 },
999
- showThumbnails: { type: Boolean, default: !0 },
1000
- showZoom: { type: Boolean, default: !0 },
1001
- exportFormats: { default: void 0 },
1002
- showSettings: { type: Boolean },
1003
- settingsOpen: { type: Boolean },
1004
- busy: { type: Boolean },
1005
- showPagination: { type: Boolean }
1006
- },
1007
- emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle", "import-excel", "settings-toggle"],
1008
- setup(e, { expose: t, emit: n }) {
1009
- const a = e, s = n, o = xs({
1010
- visible: () => a.search.visible,
1011
- navigate: (h) => {
1012
- !a.search.searching && a.search.matchCount > 0 && s("search-nav", h);
1013
- },
1014
- close: () => {
1015
- a.search.visible && s("search-toggle");
1016
- }
1017
- }), { input: r, toggle: l } = o;
1018
- t({ focusSearch: o.focus });
1019
- function c() {
1020
- const h = a.search.matchCount > 0 ? a.search.matchIndex + 1 : 0;
1021
- return a.messages.matchInfo.replace("{cur}", String(h)).replace("{total}", String(a.search.matchCount));
1022
- }
1023
- function v() {
1024
- s("search-input", ""), o.focus();
1025
- }
1026
- return (h, f) => (E(), I("div", {
1027
- class: "mrp-toolbar",
1028
- role: "toolbar",
1029
- "aria-label": e.messages.title
1030
- }, [
1031
- b("span", qs, [
1032
- X(ee, { name: "file" }),
1033
- re(x(e.messages.title), 1)
1034
- ]),
1035
- e.showPagination ? (E(), Ie(Un, {
1036
- key: 0,
1037
- "page-count": e.pageCount,
1038
- "current-page": e.currentPage,
1039
- messages: e.messages,
1040
- busy: e.busy,
1041
- onGoto: f[0] || (f[0] = (m) => s("goto", m))
1042
- }, null, 8, ["page-count", "current-page", "messages", "busy"])) : j("", !0),
1043
- f[15] || (f[15] = b("span", { class: "mrp-spacer" }, null, -1)),
1044
- e.showSearch !== !1 ? (E(), I("div", {
1045
- key: 1,
1046
- class: "mrp-read-tools",
1047
- role: "group",
1048
- "aria-label": e.messages.search ?? "内容搜索"
1049
- }, [
1050
- b("button", {
1051
- ref_key: "searchToggleRef",
1052
- ref: l,
1053
- class: pe(["mrp-nav mrp-search-toggle mrp-icon-button", { "mrp-active": e.search.visible }]),
1054
- type: "button",
1055
- title: "Ctrl+F",
1056
- "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
1057
- "aria-pressed": e.search.visible,
1058
- onClick: f[1] || (f[1] = (m) => s("search-toggle"))
1059
- }, [
1060
- X(ee, { name: "search" })
1061
- ], 10, Ns),
1062
- e.showThumbnails !== !1 ? (E(), I("button", {
1063
- key: 0,
1064
- class: pe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
1065
- type: "button",
1066
- "aria-pressed": e.thumbsVisible,
1067
- onClick: f[2] || (f[2] = (m) => s("thumbs-toggle"))
1068
- }, [
1069
- X(ee, { name: "grid" }),
1070
- re(x(e.messages.thumbnails), 1)
1071
- ], 10, js)) : j("", !0)
1072
- ], 8, Bs)) : e.showThumbnails !== !1 ? (E(), I("button", {
1073
- key: 2,
1074
- class: pe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
1075
- type: "button",
1076
- "aria-pressed": e.thumbsVisible,
1077
- onClick: f[3] || (f[3] = (m) => s("thumbs-toggle"))
1078
- }, [
1079
- X(ee, { name: "grid" }),
1080
- re(x(e.messages.thumbnails), 1)
1081
- ], 10, Hs)) : j("", !0),
1082
- at(h.$slots, "navigation", {}, void 0, !0),
1083
- e.showZoom !== !1 ? (E(), I("div", {
1084
- key: 3,
1085
- class: "mrp-zoom-tools",
1086
- role: "group",
1087
- "aria-label": e.messages.zoom ?? "缩放工具"
1088
- }, [
1089
- b("button", {
1090
- class: pe(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
1091
- "aria-pressed": e.zoomMode === "fit",
1092
- type: "button",
1093
- onClick: f[4] || (f[4] = (m) => s("zoom", "fit"))
1094
- }, [
1095
- X(ee, { name: "fit" }),
1096
- re(x(e.messages.fitWidth), 1)
1097
- ], 10, Ws),
1098
- (E(), I(fe, null, me([100, 150], (m) => b("button", {
1099
- key: m,
1100
- class: pe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === m }]),
1101
- "aria-pressed": e.zoomMode === "raw" && Math.round(e.zoom * 100) === m,
1102
- type: "button",
1103
- onClick: (w) => s("zoom", m)
1104
- }, x(m) + "%", 11, Us)), 64))
1105
- ], 8, Ks)) : j("", !0),
1106
- e.showImport || e.showExport || e.showPrint || e.showPdfWindow ? (E(), I("div", {
1107
- key: 4,
1108
- class: "mrp-output-tools",
1109
- role: "group",
1110
- "aria-label": e.messages.settingsExport ?? "导出与打印"
1111
- }, [
1112
- e.showImport ? (E(), I("button", {
1113
- key: 0,
1114
- class: "mrp-nav mrp-import-excel",
1115
- type: "button",
1116
- disabled: e.busy,
1117
- onClick: f[5] || (f[5] = (m) => s("import-excel"))
1118
- }, [
1119
- X(ee, { name: "upload" }),
1120
- re(x(e.messages.importExcel ?? "导入 Excel 模板"), 1)
1121
- ], 8, Gs)) : j("", !0),
1122
- e.showExport ? (E(), Ie(Ps, {
1123
- key: 1,
1124
- messages: e.messages,
1125
- formats: e.exportFormats,
1126
- busy: e.busy,
1127
- onExport: f[6] || (f[6] = (m) => s("export", m))
1128
- }, null, 8, ["messages", "formats", "busy"])) : j("", !0),
1129
- e.showPrint ? (E(), I("button", {
1130
- key: 2,
1131
- class: "mrp-nav",
1132
- type: "button",
1133
- disabled: e.busy,
1134
- onClick: f[7] || (f[7] = (m) => s("print"))
1135
- }, [
1136
- X(ee, { name: "print" }),
1137
- re(x(e.messages.print), 1)
1138
- ], 8, Js)) : j("", !0),
1139
- e.showPdfWindow ? (E(), I("button", {
1140
- key: 3,
1141
- class: "mrp-nav",
1142
- type: "button",
1143
- disabled: e.busy,
1144
- onClick: f[8] || (f[8] = (m) => s("pdf-window"))
1145
- }, [
1146
- X(ee, { name: "external" }),
1147
- re(x(e.messages.pdfWindow), 1)
1148
- ], 8, Zs)) : j("", !0)
1149
- ], 8, Vs)) : j("", !0),
1150
- e.showSettings ? (E(), I("button", {
1151
- key: 5,
1152
- class: pe(["mrp-nav mrp-settings-toggle", { "mrp-active": e.settingsOpen }]),
1153
- type: "button",
1154
- "aria-label": e.messages.settings ?? "设置",
1155
- "aria-haspopup": "dialog",
1156
- "aria-expanded": !!e.settingsOpen,
1157
- onClick: f[9] || (f[9] = (m) => s("settings-toggle"))
1158
- }, [
1159
- X(ee, { name: "settings" }),
1160
- re(x(e.messages.settings ?? "设置"), 1)
1161
- ], 10, Ys)) : j("", !0),
1162
- e.showSearch !== !1 && e.search.visible ? (E(), I("div", {
1163
- key: 6,
1164
- class: "mrp-search-panel",
1165
- role: "search",
1166
- "aria-label": e.messages.search ?? "内容搜索"
1167
- }, [
1168
- b("div", {
1169
- class: pe(["mrp-search", { "mrp-search-no-results": e.search.query && !e.search.searching && !e.search.matchCount }])
1170
- }, [
1171
- X(ee, { name: "search" }),
1172
- b("input", {
1173
- ref_key: "searchInputRef",
1174
- ref: r,
1175
- class: "mrp-search-input",
1176
- type: "text",
1177
- autocomplete: "off",
1178
- spellcheck: "false",
1179
- placeholder: e.messages.searchPlaceholder,
1180
- "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
1181
- value: e.search.query,
1182
- onInput: f[10] || (f[10] = (m) => s("search-input", m.target.value)),
1183
- onKeydown: f[11] || (f[11] = //@ts-ignore
1184
- (...m) => d(o).onKeydown && d(o).onKeydown(...m))
1185
- }, null, 40, Qs),
1186
- e.search.query ? (E(), I("button", {
1187
- key: 0,
1188
- class: "mrp-nav mrp-search-clear mrp-icon-button",
1189
- type: "button",
1190
- "aria-label": e.messages.clearSearch ?? "清除搜索",
1191
- onClick: v
1192
- }, [
1193
- X(ee, {
1194
- name: "close",
1195
- size: 13
1196
- })
1197
- ], 8, _s)) : j("", !0),
1198
- e.search.query ? (E(), I("span", eo, x(e.search.searching ? e.messages.searching ?? "搜索中…" : c()), 1)) : j("", !0),
1199
- b("button", {
1200
- class: "mrp-nav mrp-icon-button",
1201
- type: "button",
1202
- disabled: e.search.matchCount === 0 || e.search.searching,
1203
- "aria-label": e.messages.prevSearchMatch ?? "上一个匹配",
1204
- onClick: f[12] || (f[12] = (m) => s("search-nav", -1))
1205
- }, [
1206
- X(ee, {
1207
- name: "chevron-up",
1208
- size: 14
1209
- })
1210
- ], 8, to),
1211
- b("button", {
1212
- class: "mrp-nav mrp-icon-button",
1213
- type: "button",
1214
- disabled: e.search.matchCount === 0 || e.search.searching,
1215
- "aria-label": e.messages.nextSearchMatch ?? "下一个匹配",
1216
- onClick: f[13] || (f[13] = (m) => s("search-nav", 1))
1217
- }, [
1218
- X(ee, {
1219
- name: "chevron-down",
1220
- size: 14
1221
- })
1222
- ], 8, no),
1223
- b("button", {
1224
- class: "mrp-nav mrp-search-close mrp-icon-button",
1225
- type: "button",
1226
- "aria-label": e.messages.closeSearch ?? "关闭搜索",
1227
- onClick: f[14] || (f[14] = //@ts-ignore
1228
- (...m) => d(o).close && d(o).close(...m))
1229
- }, [
1230
- X(ee, {
1231
- name: "close",
1232
- size: 14
1233
- })
1234
- ], 8, ao)
1235
- ], 2),
1236
- b("span", so, x(e.search.query && !e.search.searching && !e.search.matchCount ? e.messages.searchNoMatches ?? "没有匹配内容" : e.messages.searchHint ?? "Enter 下一个 · Shift+Enter 上一个"), 1)
1237
- ], 8, Xs)) : j("", !0)
1238
- ], 8, zs));
1239
- }
1240
- }), ro = /* @__PURE__ */ ye(oo, [["__scopeId", "data-v-5f4b04d8"]]), lo = ["aria-label", "aria-busy"], io = { class: "mrp-calculation-heading" }, uo = { class: "mrp-calculation-controls" }, co = ["aria-label", "value", "disabled"], fo = ["value"], mo = { class: "mrp-calculation-precision" }, go = ["aria-label", "value", "disabled"], po = {
1241
- key: 0,
1242
- class: "mrp-calculation-expression"
1243
- }, vo = ["aria-label", "value", "disabled"], ho = { class: "mrp-calculation-actions" }, bo = {
1244
- key: 1,
1245
- class: "mrp-calculation-diagnostic",
1246
- role: "alert"
1247
- }, yo = {
1248
- key: 2,
1249
- class: "mrp-calculation-result",
1250
- role: "status",
1251
- "aria-live": "polite"
1252
- }, wo = { key: 0 }, xo = {
1253
- key: 3,
1254
- class: "mrp-calculation-empty"
1255
- }, ko = { class: "mrp-calculation-local" }, Eo = /* @__PURE__ */ be({
1256
- __name: "ReportCalculationPanel",
1257
- props: {
1258
- state: {},
1259
- messages: {}
1260
- },
1261
- setup(e) {
1262
- const t = e, n = `mrp-calculation-expression-hint-${Xt()?.uid ?? 0}`, a = F(() => [
1263
- ["sum", t.messages.calculationSum],
1264
- ["average", t.messages.calculationAverage],
1265
- ["min", t.messages.calculationMin],
1266
- ["max", t.messages.calculationMax],
1267
- ["count", t.messages.calculationCount],
1268
- ["median", t.messages.calculationMedian],
1269
- ["expression", t.messages.calculationCustom]
1270
- ]), s = F(() => {
1271
- const o = t.state.error.value;
1272
- if (!o) return "";
1273
- const r = t.messages;
1274
- return { selection: r.calculationErrorSelection, limit: r.calculationErrorLimit, expression: r.calculationErrorExpression, division: r.calculationErrorDivision, overflow: r.calculationErrorOverflow, precision: r.calculationErrorPrecision }[o];
1275
- });
1276
- return (o, r) => (E(), I("section", {
1277
- class: "mrp-calculation",
1278
- "aria-label": e.messages.calculationTitle,
1279
- "aria-busy": e.state.busy.value
1280
- }, [
1281
- b("header", io, [
1282
- r[5] || (r[5] = b("span", {
1283
- class: "mrp-calculation-symbol",
1284
- "aria-hidden": "true"
1285
- }, "∑", -1)),
1286
- b("div", null, [
1287
- b("strong", null, x(e.messages.calculationTitle), 1),
1288
- b("p", null, x(e.messages.calculationHint), 1)
1289
- ])
1290
- ]),
1291
- b("div", uo, [
1292
- b("label", null, [
1293
- b("span", null, x(e.messages.calculationFormula), 1),
1294
- b("select", {
1295
- "aria-label": e.messages.calculationFormula,
1296
- value: e.state.operation.value,
1297
- onChange: r[0] || (r[0] = (l) => e.state.setOperation(l.target.value)),
1298
- disabled: e.state.busy.value
1299
- }, [
1300
- (E(!0), I(fe, null, me(a.value, ([l, c]) => (E(), I("option", {
1301
- key: l,
1302
- value: l
1303
- }, x(c), 9, fo))), 128))
1304
- ], 40, co)
1305
- ]),
1306
- b("label", mo, [
1307
- b("span", null, x(e.messages.calculationPrecision), 1),
1308
- b("input", {
1309
- "aria-label": e.messages.calculationPrecision,
1310
- value: e.state.precision.value,
1311
- onChange: r[1] || (r[1] = (l) => e.state.setPrecision(Number(l.target.value))),
1312
- type: "number",
1313
- min: "0",
1314
- max: "12",
1315
- step: "1",
1316
- disabled: e.state.busy.value
1317
- }, null, 40, go)
1318
- ])
1319
- ]),
1320
- e.state.operation.value === "expression" ? (E(), I("label", po, [
1321
- b("span", null, x(e.messages.calculationExpression), 1),
1322
- b("input", {
1323
- "aria-label": e.messages.calculationExpression,
1324
- "aria-describedby": n,
1325
- value: e.state.expression.value,
1326
- onInput: r[2] || (r[2] = (l) => e.state.setExpression(l.target.value)),
1327
- type: "text",
1328
- maxlength: "256",
1329
- spellcheck: "false",
1330
- disabled: e.state.busy.value,
1331
- placeholder: "SUM / COUNT"
1332
- }, null, 40, vo),
1333
- b("small", { id: n }, x(e.messages.calculationExpressionHint), 1)
1334
- ])) : j("", !0),
1335
- b("div", ho, [
1336
- e.state.busy.value ? (E(), I("button", {
1337
- key: 0,
1338
- type: "button",
1339
- onClick: r[3] || (r[3] = (l) => e.state.cancel())
1340
- }, x(e.messages.calculationCancel), 1)) : (E(), I("button", {
1341
- key: 1,
1342
- class: "mrp-calculation-run",
1343
- type: "button",
1344
- onClick: r[4] || (r[4] = (l) => e.state.run())
1345
- }, x(e.messages.calculationRun), 1))
1346
- ]),
1347
- s.value ? (E(), I("p", bo, x(s.value), 1)) : e.state.result.value ? (E(), I("div", yo, [
1348
- b("span", null, x(e.messages.calculationResult), 1),
1349
- b("output", null, x(e.state.result.value.formatted), 1),
1350
- b("small", null, [
1351
- b("span", null, x(e.messages.calculationIncluded) + " " + x(e.state.result.value.numericCells), 1),
1352
- b("span", null, x(e.messages.calculationExcluded) + " " + x(e.state.result.value.excludedCells), 1)
1353
- ]),
1354
- e.state.result.value.numericCells === 0 ? (E(), I("p", wo, x(e.messages.calculationEmpty), 1)) : j("", !0)
1355
- ])) : (E(), I("p", xo, x(e.messages.calculationNoSelection), 1)),
1356
- b("p", ko, x(e.messages.calculationLocal), 1)
1357
- ], 8, lo));
1358
- }
1359
- }), Co = /* @__PURE__ */ ye(Eo, [["__scopeId", "data-v-ee359251"]]);
1360
- function $o(e) {
1361
- const t = W("sum"), n = W("SUM / COUNT"), a = W(2), s = W(!1), o = le(null), r = W(null);
1362
- let l = null, c = 0;
1363
- function v() {
1364
- c++, l?.abort(), l = null, s.value = !1;
1365
- }
1366
- function h() {
1367
- v(), o.value = null, r.value = null;
1368
- }
1369
- async function f() {
1370
- if (h(), !e.enabled()) return;
1371
- const u = e.plan.value, i = e.selection.value;
1372
- if (!u || !i) {
1373
- r.value = "selection";
1374
- return;
1375
- }
1376
- const k = ++c, R = new AbortController();
1377
- l = R, s.value = !0;
1378
- try {
1379
- const D = await Oa(u, i, { operation: t.value, expression: n.value, precision: a.value, signal: R.signal });
1380
- k === c && e.plan.value === u && e.selection.value === i && e.enabled() && (o.value = D);
1381
- } catch (D) {
1382
- k === c && !R.signal.aborted && (r.value = D instanceof La ? D.code : "expression");
1383
- } finally {
1384
- k === c && (s.value = !1, l = null);
1385
- }
1386
- }
1387
- oe([e.plan, e.selection, () => e.enabled(), t, n, a], h, { flush: "sync" }), Oe(h);
1388
- function m(u) {
1389
- t.value = u;
1390
- }
1391
- function w(u) {
1392
- n.value = u;
1393
- }
1394
- function p(u) {
1395
- a.value = u;
1396
- }
1397
- return { operation: t, expression: n, precision: a, busy: s, result: o, error: r, run: f, cancel: v, clear: h, setOperation: m, setExpression: w, setPrecision: p };
1398
- }
1399
- const Io = ["aria-label"], Po = { class: "mrp-settings-header" }, So = ["aria-label"], Ro = ["aria-label"], Mo = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], To = { class: "mrp-settings-content" }, Do = ["id", "aria-labelledby", "hidden"], Ao = { key: 0 }, Fo = { class: "mrp-settings-option" }, Oo = ["checked", "disabled"], Lo = { class: "mrp-settings-option" }, zo = ["value", "disabled"], qo = ["id", "aria-labelledby", "hidden"], Bo = { key: 0 }, No = ["checked", "disabled", "onChange"], jo = {
1400
- key: 0,
1401
- class: "mrp-settings-note"
1402
- }, Ho = {
1403
- key: 1,
1404
- class: "mrp-settings-note"
1405
- }, Ko = ["id", "aria-labelledby", "hidden"], Wo = { class: "mrp-settings-intro" }, Uo = { class: "mrp-settings-option mrp-settings-feature" }, Vo = ["id"], Go = ["aria-label", "aria-describedby", "checked", "disabled"], Jo = ["disabled"], Zo = /* @__PURE__ */ be({
1406
- __name: "ReportSettings",
1407
- props: {
1408
- available: {},
1409
- enabled: {},
1410
- messages: {},
1411
- persistedEditing: { type: Boolean },
1412
- busy: { type: Boolean },
1413
- interaction: {},
1414
- section: {}
1415
- },
1416
- emits: ["change", "reset", "close", "interaction", "section"],
1417
- setup(e, { emit: t }) {
1418
- const n = e, a = t, s = W(null), o = F(() => n.section ?? "general"), r = "mrp-settings-" + Xt()?.uid, l = F(() => [
1419
- { key: "general", label: n.messages.settingsGeneral ?? "常规" },
1420
- { key: "tools", label: n.messages.settingsTools ?? "工具" },
1421
- { key: "advanced", label: n.messages.settingsAdvanced ?? "高级" }
1422
- ]);
1423
- function c(u, i) {
1424
- const R = { ArrowRight: (i + 1) % 3, ArrowLeft: (i + 2) % 3, Home: 0, End: 2 }[u.key];
1425
- R !== void 0 && (u.preventDefault(), a("section", l.value[R].key), s.value?.querySelector("#" + r + "-tab-" + l.value[R].key)?.focus());
1426
- }
1427
- const v = W(null);
1428
- let h = null;
1429
- const f = F(() => [
1430
- { label: n.messages.settingsDisplay, tools: [
1431
- ["search", n.messages.search],
1432
- ["thumbnails", n.messages.thumbnails],
1433
- ["zoom", n.messages.zoom]
1434
- ] },
1435
- { label: n.messages.settingsExport, tools: [
1436
- ["html", n.messages.exportHtml],
1437
- ["pdf", n.messages.exportPdf],
1438
- ["xlsx", n.messages.exportExcel],
1439
- ["png", n.messages.exportImage],
1440
- ["word", n.messages.exportWord],
1441
- ["print", n.messages.print],
1442
- ["pdfWindow", n.messages.pdfWindow]
1443
- ] },
1444
- { label: n.messages.settingsData, tools: [
1445
- ["editing", n.messages.editCell],
1446
- ["import", n.messages.importExcel]
1447
- ] }
1448
- ].map((u) => ({ ...u, tools: u.tools.map(([i, k]) => ({ key: i, label: k })) })));
1449
- function m(u, i) {
1450
- const k = u.target, R = k.checked;
1451
- k.checked = n.enabled[i], a("change", i, R);
1452
- }
1453
- function w(u) {
1454
- return !s.value || u.defaultPrevented ? !1 : u.target instanceof Node && s.value.contains(u.target) ? !0 : u.target instanceof Element && u.target.closest('[role="dialog"],dialog[open]') ? !1 : !Array.from(document.querySelectorAll('[aria-modal="true"],dialog[open]')).some((i) => i !== s.value && !s.value.contains(i));
1455
- }
1456
- function p(u) {
1457
- if (!w(u)) return;
1458
- if (u.key === "Escape") {
1459
- u.preventDefault(), u.stopPropagation(), a("close");
1460
- return;
1461
- }
1462
- if (u.key !== "Tab") return;
1463
- const i = Array.from(s.value?.querySelectorAll("a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex='0']") ?? []).filter((A) => !A.closest("[hidden]") && A.tabIndex !== -1), k = i?.[0], R = i?.[i.length - 1];
1464
- (!s.value?.contains(document.activeElement) || u.shiftKey && document.activeElement === k || !u.shiftKey && document.activeElement === R) && (u.preventDefault(), u.stopPropagation(), (u.shiftKey ? R : k)?.focus());
1465
- }
1466
- return bt(() => {
1467
- const u = s.value?.closest(".mach-report-preview")?.querySelector(".mrp-settings-toggle"), i = document.activeElement;
1468
- h = i instanceof HTMLElement && i !== document.body && !s.value?.contains(i) ? i : u ?? null, v.value?.focus(), document.addEventListener("keydown", p);
1469
- }), Qt(() => {
1470
- document.removeEventListener("keydown", p), h?.isConnected && h.focus();
1471
- }), (u, i) => (E(), I("div", {
1472
- class: "mrp-settings-backdrop",
1473
- onClick: i[5] || (i[5] = nt((k) => u.$emit("close"), ["self"]))
1474
- }, [
1475
- b("section", {
1476
- ref_key: "panel",
1477
- ref: s,
1478
- class: "mrp-settings-panel",
1479
- role: "dialog",
1480
- "aria-modal": "true",
1481
- "aria-label": e.messages.settings
1482
- }, [
1483
- b("header", Po, [
1484
- b("div", null, [
1485
- i[6] || (i[6] = b("span", { class: "mrp-settings-eyebrow" }, "MACH REPORT", -1)),
1486
- b("strong", null, x(e.messages.settings), 1),
1487
- b("p", null, x(e.messages.settingsLocal), 1)
1488
- ]),
1489
- b("button", {
1490
- ref_key: "closeButton",
1491
- ref: v,
1492
- class: "mrp-settings-close",
1493
- type: "button",
1494
- "aria-label": e.messages.settingsClose,
1495
- onClick: i[0] || (i[0] = (k) => u.$emit("close"))
1496
- }, [...i[7] || (i[7] = [
1497
- b("svg", {
1498
- width: "16",
1499
- height: "16",
1500
- viewBox: "0 0 20 20",
1501
- fill: "none",
1502
- "aria-hidden": "true"
1503
- }, [
1504
- b("path", {
1505
- d: "m5 5 10 10M15 5 5 15",
1506
- stroke: "currentColor",
1507
- "stroke-width": "1.6",
1508
- "stroke-linecap": "round"
1509
- })
1510
- ], -1)
1511
- ])], 8, So)
1512
- ]),
1513
- b("div", {
1514
- class: "mrp-settings-tabs",
1515
- role: "tablist",
1516
- "aria-label": e.messages.settings
1517
- }, [
1518
- (E(!0), I(fe, null, me(l.value, (k, R) => (E(), I("button", {
1519
- id: r + "-tab-" + k.key,
1520
- key: k.key,
1521
- type: "button",
1522
- role: "tab",
1523
- "aria-selected": o.value === k.key,
1524
- "aria-controls": r + "-panel-" + k.key,
1525
- tabindex: o.value === k.key ? 0 : -1,
1526
- onClick: (D) => u.$emit("section", k.key),
1527
- onKeydown: (D) => c(D, R)
1528
- }, x(k.label), 41, Mo))), 128))
1529
- ], 8, Ro),
1530
- b("div", To, [
1531
- b("section", {
1532
- id: r + "-panel-general",
1533
- role: "tabpanel",
1534
- "aria-labelledby": r + "-tab-general",
1535
- hidden: o.value !== "general"
1536
- }, [
1537
- at(u.$slots, "default", {}, void 0, !0),
1538
- e.interaction ? (E(), I("fieldset", Ao, [
1539
- b("legend", null, x(e.messages.settingsPanes), 1),
1540
- b("label", Fo, [
1541
- b("span", null, x(e.messages.freezeHeaders), 1),
1542
- b("input", {
1543
- type: "checkbox",
1544
- checked: e.interaction.freezeHeaders,
1545
- disabled: e.busy,
1546
- onChange: i[1] || (i[1] = (k) => u.$emit("interaction", { freezeHeaders: k.target.checked }))
1547
- }, null, 40, Oo)
1548
- ]),
1549
- b("label", Lo, [
1550
- b("span", null, x(e.messages.frozenColumns), 1),
1551
- b("input", {
1552
- class: "mrp-frozen-count",
1553
- type: "number",
1554
- min: "0",
1555
- max: "20",
1556
- value: e.interaction.frozenColumns ?? 0,
1557
- disabled: e.busy,
1558
- onChange: i[2] || (i[2] = (k) => u.$emit("interaction", { frozenColumns: Math.max(0, Math.min(20, Number(k.target.value) || 0)) }))
1559
- }, null, 40, zo)
1560
- ])
1561
- ])) : j("", !0)
1562
- ], 8, Do),
1563
- b("section", {
1564
- id: r + "-panel-tools",
1565
- role: "tabpanel",
1566
- "aria-labelledby": r + "-tab-tools",
1567
- hidden: o.value !== "tools"
1568
- }, [
1569
- (E(!0), I(fe, null, me(f.value, (k) => (E(), I("fieldset", {
1570
- key: k.label
1571
- }, [
1572
- b("legend", null, x(k.label), 1),
1573
- (E(!0), I(fe, null, me(k.tools, (R) => (E(), I("label", {
1574
- key: R.key,
1575
- class: pe(["mrp-settings-option", { "mrp-settings-unavailable": !e.available[R.key] }])
1576
- }, [
1577
- b("span", null, [
1578
- re(x(R.label), 1),
1579
- e.available[R.key] ? j("", !0) : (E(), I("small", Bo, x(e.messages.settingsUnavailable), 1))
1580
- ]),
1581
- b("input", {
1582
- type: "checkbox",
1583
- checked: e.enabled[R.key],
1584
- disabled: e.busy || !e.available[R.key],
1585
- onChange: (D) => m(D, R.key)
1586
- }, null, 40, No)
1587
- ], 2))), 128))
1588
- ]))), 128)),
1589
- e.available.editing ? (E(), I("p", jo, x(e.persistedEditing ? e.messages.editingSaved : e.messages.editingLocal), 1)) : j("", !0),
1590
- e.available.import ? (E(), I("p", Ho, x(e.messages.importLocal), 1)) : j("", !0)
1591
- ], 8, qo),
1592
- b("section", {
1593
- id: r + "-panel-advanced",
1594
- role: "tabpanel",
1595
- "aria-labelledby": r + "-tab-advanced",
1596
- hidden: o.value !== "advanced"
1597
- }, [
1598
- b("p", Wo, x(e.messages.settingsAdvancedDescription), 1),
1599
- b("label", Uo, [
1600
- b("span", null, [
1601
- re(x(e.messages.settingsCalculations), 1),
1602
- b("small", {
1603
- id: r + "-calculation-description"
1604
- }, x(e.messages.settingsCalculationsDescription), 9, Vo)
1605
- ]),
1606
- b("input", {
1607
- type: "checkbox",
1608
- "aria-label": e.messages.settingsCalculations,
1609
- "aria-describedby": r + "-calculation-description",
1610
- checked: e.interaction?.calculations === !0,
1611
- disabled: e.busy,
1612
- onChange: i[3] || (i[3] = (k) => u.$emit("interaction", { calculations: k.target.checked }))
1613
- }, null, 40, Go)
1614
- ]),
1615
- e.interaction?.calculations ? at(u.$slots, "advanced", {}, void 0, !0, 0) : j("", !0)
1616
- ], 8, Ko)
1617
- ]),
1618
- b("footer", null, [
1619
- b("button", {
1620
- type: "button",
1621
- disabled: e.busy,
1622
- onClick: i[4] || (i[4] = (k) => u.$emit("reset"))
1623
- }, x(e.messages.settingsReset), 9, Jo),
1624
- b("span", null, x(e.messages.settingsLocal), 1)
1625
- ])
1626
- ], 8, Io)
1627
- ]));
1628
- }
1629
- }), Yo = /* @__PURE__ */ ye(Zo, [["__scopeId", "data-v-36723612"]]), Xo = {
1630
- class: "mrp-empty",
1631
- role: "status"
1632
- }, Qo = { key: 0 }, _o = /* @__PURE__ */ be({
1633
- __name: "ReportEmpty",
1634
- props: {
1635
- title: {},
1636
- description: {}
1637
- },
1638
- setup(e) {
1639
- return (t, n) => (E(), I("div", Xo, [
1640
- n[0] || (n[0] = Ta('<svg class="mrp-empty-art" viewBox="0 0 160 112" fill="none" aria-hidden="true" data-v-3e16b87e><ellipse cx="80" cy="100" rx="54" ry="7" fill="currentColor" opacity=".05" data-v-3e16b87e></ellipse><rect x="34" y="15" width="92" height="78" rx="9" fill="currentColor" opacity=".10" data-v-3e16b87e></rect><rect x="42" y="9" width="76" height="78" rx="7" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".2" stroke-width="1.5" data-v-3e16b87e></rect><path d="M55 27H105M55 42H105M55 57H85M55 72H76M71 27V72M89 27V57" stroke="currentColor" stroke-opacity=".4" stroke-width="1.5" stroke-linecap="round" data-v-3e16b87e></path><circle cx="112" cy="76" r="16" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".35" stroke-width="2" data-v-3e16b87e></circle><path d="M124 88L137 101M106 76H118" stroke="currentColor" stroke-opacity=".45" stroke-width="3" stroke-linecap="round" data-v-3e16b87e></path><circle cx="27" cy="38" r="3" fill="currentColor" opacity=".12" data-v-3e16b87e></circle><circle cx="132" cy="24" r="2" fill="currentColor" opacity=".2" data-v-3e16b87e></circle></svg>', 1)),
1641
- b("strong", null, x(e.title), 1),
1642
- e.description ? (E(), I("p", Qo, x(e.description), 1)) : j("", !0)
1643
- ]));
1644
- }
1645
- }), Rn = /* @__PURE__ */ ye(_o, [["__scopeId", "data-v-3e16b87e"]]), er = ["aria-label"], tr = /* @__PURE__ */ be({
1646
- __name: "ReportDiscardDialog",
1647
- props: {
1648
- messages: {}
1649
- },
1650
- emits: ["answer"],
1651
- setup(e, { emit: t }) {
1652
- const n = t, a = W(null), s = W(null);
1653
- let o = null;
1654
- function r(l) {
1655
- l.key === "Escape" && (l.preventDefault(), n("answer", !1)), l.key === "Tab" && (l.preventDefault(), document.activeElement === a.value ? s.value?.focus() : a.value?.focus());
1656
- }
1657
- return bt(() => {
1658
- o = document.activeElement instanceof HTMLElement ? document.activeElement : null, a.value?.focus();
1659
- }), Qt(() => {
1660
- o?.isConnected && o.focus();
1661
- }), (l, c) => (E(), I("div", {
1662
- class: "mrp-discard-backdrop",
1663
- onKeydown: r,
1664
- onClick: c[2] || (c[2] = nt((v) => n("answer", !1), ["self"]))
1665
- }, [
1666
- b("section", {
1667
- class: "mrp-discard-dialog",
1668
- role: "alertdialog",
1669
- "aria-modal": "true",
1670
- "aria-label": e.messages.discardTitle
1671
- }, [
1672
- b("strong", null, x(e.messages.discardTitle), 1),
1673
- b("p", null, x(e.messages.discardDescription), 1),
1674
- b("footer", null, [
1675
- b("button", {
1676
- ref_key: "keep",
1677
- ref: a,
1678
- type: "button",
1679
- onClick: c[0] || (c[0] = (v) => n("answer", !1))
1680
- }, x(e.messages.discardKeep), 513),
1681
- b("button", {
1682
- ref_key: "discard",
1683
- ref: s,
1684
- type: "button",
1685
- onClick: c[1] || (c[1] = (v) => n("answer", !0))
1686
- }, x(e.messages.discardProceed), 513)
1687
- ])
1688
- ], 8, er)
1689
- ], 32));
1690
- }
1691
- }), nr = /* @__PURE__ */ ye(tr, [["__scopeId", "data-v-f7590294"]]), ar = {
1692
- key: 0,
1693
- class: "mrp-task-status",
1694
- role: "status",
1695
- "aria-live": "polite"
1696
- }, sr = { key: 0 }, or = ["value", "max", "aria-label"], rr = /* @__PURE__ */ be({
1697
- __name: "ReportTaskStatus",
1698
- props: {
1699
- task: {},
1700
- messages: {}
1701
- },
1702
- emits: ["cancel"],
1703
- setup(e) {
1704
- const t = e, n = F(() => ({ query: t.messages.taskQuery, validate: t.messages.taskValidate, layout: t.messages.taskLayout, assets: t.messages.taskAssets, import: t.messages.importing, encode: t.messages.taskEncode, download: t.messages.taskDownload, print: t.messages.taskPrint })), a = F(() => t.task?.total === void 0 ? "" : `${t.task.completed ?? 0} / ${t.task.total}`);
1705
- return (s, o) => e.task && (e.task.status === "running" || e.task.status === "cancelled") ? (E(), I("div", ar, [
1706
- b("span", null, [
1707
- re(x(e.task.status === "cancelled" ? e.messages.taskCancelled : n.value[e.task.stage]) + " ", 1),
1708
- e.task.status === "running" ? (E(), I("small", sr, x(a.value), 1)) : j("", !0)
1709
- ]),
1710
- e.task.status === "running" && e.task.total !== void 0 ? (E(), I("progress", {
1711
- key: 0,
1712
- value: e.task.completed ?? 0,
1713
- max: e.task.total,
1714
- "aria-label": n.value[e.task.stage]
1715
- }, null, 8, or)) : j("", !0),
1716
- e.task.status === "running" && e.task.cancellable ? (E(), I("button", {
1717
- key: 1,
1718
- type: "button",
1719
- onClick: o[0] || (o[0] = (r) => s.$emit("cancel"))
1720
- }, x(e.messages.taskCancel), 1)) : j("", !0)
1721
- ])) : j("", !0);
1722
- }
1723
- }), lr = /* @__PURE__ */ ye(rr, [["__scopeId", "data-v-657ac599"]]), ir = {
1724
- key: 0,
1725
- class: "mrp-diagnostics"
1726
- }, ur = ["aria-label", "placeholder"], cr = { key: 0 }, dr = ["onClick"], fr = { key: 0 }, mr = /* @__PURE__ */ be({
1727
- __name: "ReportDiagnostics",
1728
- props: {
1729
- entries: {},
1730
- messages: {}
1731
- },
1732
- emits: ["locate"],
1733
- setup(e) {
1734
- const t = e, n = W(""), a = F(() => ({
1735
- "unsupported-style": t.messages.diagnosticUnsupportedStyle,
1736
- "missing-image": t.messages.diagnosticMissingImage,
1737
- "unsupported-component": t.messages.diagnosticUnsupported,
1738
- "unsupported-image-format": t.messages.diagnosticImageFormat,
1739
- "rich-text-flattened": t.messages.diagnosticRichText,
1740
- "nested-components-omitted": t.messages.diagnosticNested,
1741
- "async-image-required": t.messages.diagnosticImageAsync,
1742
- "image-decode-failed": t.messages.diagnosticImageDecode,
1743
- "asset-render-failed": t.messages.diagnosticAssetFailed,
1744
- "asset-budget-exceeded": t.messages.diagnosticAssetBudget
1745
- })), s = F(() => {
1746
- const l = n.value.trim().toLocaleLowerCase();
1747
- return l ? t.entries.filter((c) => `${c.code} ${c.message} ${a.value[c.code] ?? ""} ${c.path ?? ""} ${r(c)} ${c.format ?? ""}`.toLocaleLowerCase().includes(l)) : t.entries;
1748
- }), o = F(() => s.value.slice(0, 100));
1749
- function r(l) {
1750
- return l.pageIndex === void 0 ? l.path ?? "" : (t.messages.diagnosticsLocation ?? "").replace("{page}", String(l.pageIndex + 1)).replace("{component}", String((l.componentIndex ?? 0) + 1));
1751
- }
1752
- return (l, c) => e.entries.length ? (E(), I("details", ir, [
1753
- b("summary", null, [
1754
- re(x(e.messages.diagnosticsTitle) + " ", 1),
1755
- b("span", null, x(e.entries.length), 1)
1756
- ]),
1757
- Zt(b("input", {
1758
- "onUpdate:modelValue": c[0] || (c[0] = (v) => n.value = v),
1759
- type: "search",
1760
- "aria-label": e.messages.diagnosticsSearch,
1761
- placeholder: e.messages.diagnosticsSearch
1762
- }, null, 8, ur), [
1763
- [Yt, n.value]
1764
- ]),
1765
- b("ol", null, [
1766
- (E(!0), I(fe, null, me(o.value, (v, h) => (E(), I("li", { key: h }, [
1767
- b("div", null, [
1768
- b("b", null, x(v.format?.toUpperCase() ?? v.severity) + " · " + x(v.code), 1),
1769
- b("p", null, x(a.value[v.code] ?? v.message), 1),
1770
- a.value[v.code] ? (E(), I("details", cr, [
1771
- b("summary", null, x(e.messages.diagnosticsDetails), 1),
1772
- re(x(v.message), 1)
1773
- ])) : j("", !0),
1774
- b("small", null, x(r(v)), 1)
1775
- ]),
1776
- v.pageIndex !== void 0 ? (E(), I("button", {
1777
- key: 0,
1778
- type: "button",
1779
- onClick: (f) => l.$emit("locate", v)
1780
- }, x(e.messages.diagnosticsLocate), 9, dr)) : j("", !0)
1781
- ]))), 128))
1782
- ]),
1783
- s.value.length > o.value.length ? (E(), I("small", fr, x((e.messages.diagnosticsMore ?? "").replace("{count}", String(s.value.length))), 1)) : j("", !0)
1784
- ])) : j("", !0);
1785
- }
1786
- }), gr = /* @__PURE__ */ ye(mr, [["__scopeId", "data-v-3b7804ce"]]);
1787
- class ke extends Error {
1788
- constructor(t, n, a) {
1789
- super(n), this.name = "MachReportError", this.code = t, this.cause = a;
1790
- }
1791
- }
1792
- function pr(e) {
1793
- return e instanceof ke ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
1794
- }
1795
- function vr(e) {
1796
- if (e instanceof ke) return e;
1797
- if (e instanceof za) return new ke("param", e.message, e);
1798
- if (e instanceof qa) return new ke(e.code, e.message, e.cause);
1799
- if (e instanceof Error) {
1800
- const t = { params: "param", config: "config", validate: "validate", fetch: "fetch" }, n = e.code;
1801
- if (typeof n == "string" && Object.prototype.hasOwnProperty.call(t, n)) return new ke(t[n], e.message, e);
1802
- }
1803
- return new ke("fetch", e instanceof Error ? e.message : "预览加载失败", e);
1804
- }
1805
- const Mn = /* @__PURE__ */ new Map(), Ue = /* @__PURE__ */ new Map(), hr = 15e3;
1806
- function Ut(e, t) {
1807
- return Object.assign(new Error(e), { cause: t });
1808
- }
1809
- function et(e, t) {
1810
- return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
1811
- }
1812
- function ht(e) {
1813
- if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
1814
- const t = Ut("PDF 字体检查已取消", e?.reason);
1815
- return t.name = "AbortError", t;
1816
- }
1817
- async function br(e, t) {
1818
- let n = !1;
1819
- const a = setTimeout(() => {
1820
- n = !0, t.abort();
1821
- }, hr);
1822
- try {
1823
- const s = await fetch(e, { method: "HEAD", signal: t.signal });
1824
- if (t.signal.aborted) throw ht(t.signal);
1825
- if (s.status === 405 || s.status === 501 || s.type === "opaque")
1826
- return {
1827
- status: "unverified",
1828
- fontUrl: e,
1829
- message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
1830
- };
1831
- if (!s.ok) {
1832
- const r = new Error(`字体请求返回 HTTP ${s.status}`);
1833
- return { status: "error", fontUrl: e, message: et(e, r.message), cause: r };
1834
- }
1835
- const o = s.headers.get("content-type") ?? "";
1836
- if (/text\/html|application\/xhtml\+xml/i.test(o)) {
1837
- const r = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
1838
- return { status: "error", fontUrl: e, message: et(e, r.message), cause: r };
1839
- }
1840
- if (/^text\//i.test(o) || /(?:\/|\+)json(?:\s*;|$)/i.test(o)) {
1841
- const r = new Error(`字体 URL 返回 ${o} 文本响应,不是字体文件`);
1842
- return { status: "error", fontUrl: e, message: et(e, r.message), cause: r };
1843
- }
1844
- return {
1845
- status: "available",
1846
- fontUrl: e,
1847
- message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
1848
- };
1849
- } catch (s) {
1850
- if (t.signal.aborted && !n) throw ht(t.signal);
1851
- return {
1852
- status: "error",
1853
- fontUrl: e,
1854
- message: et(e, n ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
1855
- cause: s
1856
- };
1857
- } finally {
1858
- clearTimeout(a);
1859
- }
1860
- }
1861
- function yr(e, t) {
1862
- if (t?.aborted) return Promise.reject(ht(t));
1863
- if (!e)
1864
- return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
1865
- const n = Mn.get(e);
1866
- if (n) return Promise.resolve(n);
1867
- let a = Ue.get(e);
1868
- if (!a) {
1869
- const o = new AbortController();
1870
- a = { controller: o, promise: br(e, o), subscribers: 0 };
1871
- const r = a;
1872
- Ue.set(e, r), r.promise = r.promise.then((l) => (!o.signal.aborted && l.status === "available" && Mn.set(e, l), l)).finally(() => {
1873
- Ue.get(e) === r && Ue.delete(e);
1874
- });
1875
- }
1876
- const s = a;
1877
- return s.subscribers++, new Promise((o, r) => {
1878
- let l = !1;
1879
- const c = () => l ? !1 : (l = !0, s.subscribers--, t?.removeEventListener("abort", v), !0), v = () => {
1880
- c() && (s.subscribers === 0 && (Ue.get(e) === s && Ue.delete(e), s.controller.abort()), r(ht(t)));
1881
- };
1882
- t?.addEventListener("abort", v, { once: !0 }), s.promise.then(
1883
- (h) => {
1884
- c() && o(h);
1885
- },
1886
- (h) => {
1887
- c() && r(h);
1888
- }
1889
- ), t?.aborted && v();
1890
- });
1891
- }
1892
- function wr(e = { fontUrl: "/simhei.ttf" }) {
1893
- let t = null;
1894
- const n = async (a, s, o = {}) => {
1895
- Ae(o.signal), t || (t = await import("@agile-team/mach-report/pdf")), Ae(o.signal);
1896
- let r = null;
1897
- if (e.fontUrl)
1898
- try {
1899
- if (r = await Ge(t.loadFontWithCache(e.fontUrl, { strict: !0 }), o.signal), !r?.byteLength) throw new Error("字体文件为空或加载失败");
1900
- } catch (m) {
1901
- const w = m instanceof Error ? m.message : String(m);
1902
- throw Ut(et(e.fontUrl, w), m);
1903
- }
1904
- let l;
1905
- try {
1906
- Ae(o.signal), l = await t.renderPlanToPdf(a, { ...o, ...r ? { customFontBytes: r } : {} });
1907
- } catch (m) {
1908
- if (!r) throw m;
1909
- const w = m instanceof Error ? m.message : String(m);
1910
- throw Ut(`PDF 生成失败:${w}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, m);
1911
- }
1912
- Ae(o.signal), l.diagnostics?.forEach((m) => {
1913
- try {
1914
- o.onDiagnostic?.(m);
1915
- } catch {
1916
- }
1917
- });
1918
- const { bytes: c, unsupportedTextCount: v, pageErrors: h, fidelityWarnings: f } = l;
1919
- if (v > 0)
1920
- throw new Error(`PDF 中有 ${v} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
1921
- if (h.length > 0)
1922
- throw new Error(`PDF 有 ${h.length} 页渲染失败:${h[0]}`);
1923
- return f.length > 0 && s?.(`PDF 有 ${f.length} 处版式降级:${f.slice(0, 2).join(";")}`), c;
1924
- };
1925
- return n.checkFont = (a) => yr(e.fontUrl, a), n;
1926
- }
1927
- function xr(e) {
1928
- const t = le(Object.freeze({ status: "unchecked", fontUrl: "" }));
1929
- let n = null, a = null, s = 0, o = null;
1930
- function r() {
1931
- if (e.injectedExporter) return e.injectedExporter;
1932
- const h = e.fontUrl();
1933
- return (!a || n !== h) && (n = h, a = wr({ fontUrl: h })), a;
1934
- }
1935
- function l() {
1936
- s++, o?.abort(), o = null;
1937
- }
1938
- async function c() {
1939
- if (e.destroyed()) throw new ke("config", "报表预览已卸载");
1940
- l();
1941
- const h = s, f = new AbortController();
1942
- o = f;
1943
- const m = e.fontUrl();
1944
- t.value = Object.freeze({ status: "checking", fontUrl: m });
1945
- try {
1946
- const w = r(), p = w.checkFont ? await w.checkFont(f.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
1947
- return !e.destroyed() && h === s && !f.signal.aborted && (t.value = Object.freeze({ ...p })), p;
1948
- } catch (w) {
1949
- if (f.signal.aborted) throw w;
1950
- const p = { status: "error", fontUrl: m, message: w instanceof Error ? w.message : "PDF 字体检查失败", cause: w };
1951
- return !e.destroyed() && h === s && (t.value = Object.freeze(p)), p;
1952
- } finally {
1953
- o === f && (o = null);
1954
- }
1955
- }
1956
- function v() {
1957
- c().catch(() => {
1958
- });
1959
- }
1960
- return oe([e.plan, F(e.fontUrl), F(e.enabled)], () => {
1961
- const h = t.value.fontUrl === e.fontUrl();
1962
- h && t.value.status === "available" || (l(), (!h || t.value.status === "checking") && (t.value = Object.freeze({ status: "unchecked", fontUrl: e.fontUrl() })), !e.destroyed() && e.plan.value?.pages.length && e.enabled() && v());
1963
- }, { immediate: !0 }), { pdfFont: t, getPdfExporter: r, checkPdfFont: c, retryPdfFont: v, cancelFontCheck: l };
1964
- }
1965
- function kr(e) {
1966
- const t = le(null), n = le(!1);
1967
- let a = 0, s = null;
1968
- function o(c) {
1969
- const v = s;
1970
- s = null, t.value = null, n.value = !1, v?.(c);
1971
- }
1972
- function r() {
1973
- a++, o(!1);
1974
- }
1975
- async function l(c) {
1976
- if (r(), !e.enabled() || !e.pending()) return !0;
1977
- const v = a, h = [...e.snapshot?.() ?? []];
1978
- n.value = !0;
1979
- const f = Object.freeze({ reason: c, reportIds: Object.freeze([...e.reportIds()]), pendingLocalChanges: !0 });
1980
- try {
1981
- const m = e.hook(), w = await new Promise((u) => {
1982
- if (s = u, !m) {
1983
- t.value = f;
1984
- return;
1985
- }
1986
- Promise.resolve().then(() => m(f)).then((i) => {
1987
- v === a && o(i === !0);
1988
- }, (i) => {
1989
- if (v === a) {
1990
- try {
1991
- e.error(i);
1992
- } catch {
1993
- }
1994
- o(!1);
1995
- }
1996
- });
1997
- }), p = e.snapshot?.() ?? [];
1998
- return v === a && w === !0 && p.length === h.length && h.every((u, i) => Object.is(u, p[i]));
1999
- } catch (m) {
2000
- if (v === a) {
2001
- try {
2002
- e.error(m);
2003
- } catch {
2004
- }
2005
- o(!1);
2006
- }
2007
- return !1;
2008
- }
2009
- }
2010
- return { request: t, pending: n, check: l, settle: o, cancel: r };
2011
- }
2012
- let Er = 0;
2013
- function Cr(e) {
2014
- const t = le(null), n = /* @__PURE__ */ new Set();
2015
- let a = null;
2016
- function s(c) {
2017
- t.value = Object.freeze(c);
2018
- try {
2019
- e(t.value);
2020
- } catch {
2021
- }
2022
- }
2023
- function o(c, v, h) {
2024
- const f = `mr-task-${Date.now().toString(36)}-${++Er}`;
2025
- n.add(f), a = h, s({ taskId: f, kind: c, stage: v, status: "running", cancellable: !0 });
2026
- function m(p, u, i) {
2027
- t.value?.taskId !== f || t.value.status !== "running" || s({ ...t.value, stage: p, completed: u, total: i });
2028
- }
2029
- function w(p = "completed") {
2030
- t.value?.taskId !== f || t.value.status !== "running" || (a = null, s({ ...t.value, status: p, cancellable: !1 }));
2031
- }
2032
- return { taskId: f, update: m, finish: w };
2033
- }
2034
- function r() {
2035
- if (t.value?.status !== "running") return;
2036
- const c = a;
2037
- a = null, s({ ...t.value, status: "cancelled", cancellable: !1 }), c?.();
2038
- }
2039
- function l(c, v) {
2040
- t.value?.taskId !== c.taskId && (c.status !== "running" || n.has(c.taskId)) || (n.add(c.taskId), n.size > 100 && n.delete(n.values().next().value), a = c.status === "running" ? v : null, s({ ...c }));
2041
- }
2042
- return { state: t, start: o, cancel: r, receive: l };
2043
- }
2044
- function $r(e) {
2045
- const t = le(Object.freeze([])), n = /* @__PURE__ */ new Set();
2046
- let a = 0;
2047
- function s() {
2048
- a++, t.value = Object.freeze([]), n.clear();
2049
- }
2050
- function o(c) {
2051
- const v = a, h = [];
2052
- for (const f of c) {
2053
- const m = JSON.stringify([f.code, f.format, f.pageIndex, f.componentIndex, f.componentPath, f.path, f.message]);
2054
- if (n.has(m)) continue;
2055
- n.add(m);
2056
- const w = Object.freeze({ ...f, ...f.componentPath ? { componentPath: Object.freeze([...f.componentPath]) } : {} });
2057
- h.push(w);
2058
- }
2059
- h.length && (t.value = Object.freeze([...t.value, ...h]));
2060
- for (const f of h) {
2061
- if (v !== a) break;
2062
- try {
2063
- e(f);
2064
- } catch {
2065
- }
2066
- }
2067
- }
2068
- function r(c) {
2069
- o([c]);
2070
- }
2071
- function l(c, v) {
2072
- const h = Ba(c, v);
2073
- return o(h), h;
2074
- }
2075
- return { entries: t, reset: s, add: r, addMany: o, inspect: l };
2076
- }
2077
- let Ir = 0;
2078
- function Pr() {
2079
- return `mrp-params-${++Ir}`;
2080
- }
2081
- function Vn(e, t, n) {
2082
- const a = (Array.isArray(t) ? t.find((s) => s?.field === e.field)?.label : void 0) ?? e.field;
2083
- return e.code === "required" ? n.paramRequired.replace("{label}", a) : (n.paramInvalid ?? "{label}:{message}").replace("{label}", a).replace("{message}", e.message);
2084
- }
2085
- function Sr(e) {
2086
- const t = W({}), n = W(!1);
2087
- function a() {
2088
- const l = {};
2089
- for (const c of Array.isArray(e.defs.value) ? e.defs.value : [])
2090
- typeof c?.field == "string" && Object.defineProperty(l, c.field, { value: e.params()[c.field] ?? c.defaultValue ?? "", writable: !0, enumerable: !0, configurable: !0 });
2091
- t.value = l, n.value = !1;
2092
- }
2093
- a(), oe(e.defs, a), oe(e.reportIds, a), oe(() => JSON.stringify(e.params()), a);
2094
- const s = F(() => qn(e.defs.value, { ...e.params(), ...t.value })), o = F(() => !n.value && s.value.issues.length > 0 && s.value.issues.every((l) => l.code === "required"));
2095
- function r() {
2096
- const l = s.value;
2097
- if (!l.ok) {
2098
- const h = l.issues[0];
2099
- return { quiet: o.value, error: new ke(h.code === "definition" ? "config" : "param", Vn(h, e.defs.value, e.messages()), { issues: l.issues }) };
2100
- }
2101
- const c = { ...l.values }, v = new Set(e.defs.value.filter((h) => h.defaultValue !== void 0).map((h) => h.field));
2102
- for (const [h, f] of Object.entries(c)) f === "" && !v.has(h) && delete c[h];
2103
- return { params: c, quiet: !1 };
2104
- }
2105
- return { values: t, attempted: n, validation: s, pendingRequired: o, reset: a, query: r };
2106
- }
2107
- const Rr = { class: "mrp-params-title" }, Mr = { class: "mrp-params-grid" }, Tr = ["id"], Dr = {
2108
- key: 0,
2109
- class: "mrp-param-star"
2110
- }, Ar = ["value", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onChange"], Fr = ["disabled", "hidden"], Or = ["value"], Lr = ["type", "placeholder", "value", "min", "max", "step", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onInput"], zr = ["id"], qr = { class: "mrp-params-actions" }, Br = /* @__PURE__ */ be({
2111
- __name: "ReportParamPanel",
2112
- props: {
2113
- defs: {},
2114
- modelValue: {},
2115
- messages: {},
2116
- attempted: { type: Boolean },
2117
- issues: {}
2118
- },
2119
- emits: ["update:modelValue", "query", "reset"],
2120
- setup(e, { expose: t, emit: n }) {
2121
- const a = e, s = n, o = W({ ...a.modelValue }), r = W(null), l = Pr();
2122
- oe(
2123
- () => a.modelValue,
2124
- (w) => {
2125
- o.value = { ...w };
2126
- }
2127
- );
2128
- const c = F(() => a.issues ?? qn(a.defs, o.value).issues), v = F(
2129
- () => (Array.isArray(a.defs) ? a.defs : []).filter((w) => w && typeof w.field == "string").map((w, p) => ({
2130
- def: w,
2131
- id: `${l}-${p}`,
2132
- label: w.label ?? w.field,
2133
- value: o.value[w.field] ?? "",
2134
- error: a.attempted ? c.value.find((u) => u.field === w.field) : void 0
2135
- }))
2136
- );
2137
- function h(w, p) {
2138
- o.value = { ...o.value, [w]: p }, s("update:modelValue", { ...o.value });
2139
- }
2140
- function f(w) {
2141
- w.isComposing || s("query");
2142
- }
2143
- function m() {
2144
- r.value?.querySelector('[aria-invalid="true"]')?.focus();
2145
- }
2146
- return t({ focusInvalid: m }), (w, p) => (E(), I("div", {
2147
- ref_key: "root",
2148
- ref: r,
2149
- class: "mrp-params"
2150
- }, [
2151
- b("span", Rr, x(e.messages.paramsTitle), 1),
2152
- b("div", Mr, [
2153
- (E(!0), I(fe, null, me(v.value, (u) => (E(), I("label", {
2154
- key: u.id,
2155
- class: pe(["mrp-param", { "mrp-param-missing": !!u.error }])
2156
- }, [
2157
- b("span", {
2158
- id: `${u.id}-label`,
2159
- class: "mrp-param-label"
2160
- }, [
2161
- re(x(u.label), 1),
2162
- u.def.required ? (E(), I("i", Dr, "*")) : j("", !0)
2163
- ], 8, Tr),
2164
- (u.def.type ?? "text") === "select" ? (E(), I("select", {
2165
- key: 0,
2166
- class: "mrp-param-input",
2167
- value: u.value,
2168
- "aria-labelledby": `${u.id}-label`,
2169
- "aria-invalid": u.error ? !0 : void 0,
2170
- "aria-describedby": u.error ? `${u.id}-error` : void 0,
2171
- "aria-required": u.def.required || void 0,
2172
- onChange: (i) => h(u.def.field, i.target.value),
2173
- onKeydown: Ht(f, ["enter"])
2174
- }, [
2175
- b("option", {
2176
- value: "",
2177
- disabled: u.def.required,
2178
- hidden: u.def.required
2179
- }, x(u.def.placeholder ?? (e.messages.paramSelectPlaceholder ?? "请选择{label}").replace("{label}", u.label)), 9, Fr),
2180
- (E(!0), I(fe, null, me(u.def.options ?? [], (i) => (E(), I("option", {
2181
- key: i.value,
2182
- value: i.value
2183
- }, x(i.label), 9, Or))), 128))
2184
- ], 40, Ar)) : (E(), I("input", {
2185
- key: 1,
2186
- class: "mrp-param-input",
2187
- type: u.def.type === "number" ? "number" : u.def.type === "date" ? "date" : "text",
2188
- placeholder: u.def.placeholder ?? (e.messages.paramTextPlaceholder ?? "请输入{label}").replace("{label}", u.label),
2189
- value: u.value,
2190
- min: u.def.min,
2191
- max: u.def.max,
2192
- step: u.def.type === "number" ? "any" : void 0,
2193
- "aria-labelledby": `${u.id}-label`,
2194
- "aria-invalid": u.error ? !0 : void 0,
2195
- "aria-describedby": u.error ? `${u.id}-error` : void 0,
2196
- "aria-required": u.def.required || void 0,
2197
- onInput: (i) => h(u.def.field, i.target.value),
2198
- onKeydown: Ht(f, ["enter"])
2199
- }, null, 40, Lr)),
2200
- u.error ? (E(), I("small", {
2201
- key: 2,
2202
- id: `${u.id}-error`,
2203
- class: "mrp-param-error",
2204
- role: "status"
2205
- }, x(d(Vn)(u.error, e.defs, e.messages)), 9, zr)) : j("", !0)
2206
- ], 2))), 128))
2207
- ]),
2208
- b("div", qr, [
2209
- b("button", {
2210
- class: "mrp-nav mrp-param-query",
2211
- type: "button",
2212
- onClick: p[0] || (p[0] = (u) => w.$emit("query"))
2213
- }, x(e.messages.query), 1),
2214
- b("button", {
2215
- class: "mrp-nav",
2216
- type: "button",
2217
- onClick: p[1] || (p[1] = (u) => w.$emit("reset"))
2218
- }, x(e.messages.reset), 1)
2219
- ])
2220
- ], 512));
2221
- }
2222
- }), Nr = /* @__PURE__ */ ye(Br, [["__scopeId", "data-v-156737bc"]]), jr = { class: "mrp-edit-bar" }, Hr = ["disabled"], Kr = ["disabled"], Wr = { class: "mrp-changes" }, Ur = ["aria-label"], Vr = { key: 0 }, Gr = { key: 1 }, Jr = ["onClick"], Zr = ["title"], Yr = ["title"], Xr = ["disabled"], Qr = {
2223
- key: 0,
2224
- role: "status"
2225
- }, _r = {
2226
- key: 1,
2227
- role: "status"
2228
- }, el = {
2229
- key: 2,
2230
- class: "mrp-conflicts",
2231
- open: ""
2232
- }, tl = /* @__PURE__ */ be({
2233
- __name: "ReportEditBar",
2234
- props: {
2235
- differences: {},
2236
- conflicts: {},
2237
- messages: {},
2238
- saving: { type: Boolean },
2239
- canUndo: { type: Boolean },
2240
- canRedo: { type: Boolean },
2241
- busy: { type: Boolean },
2242
- persisted: { type: Boolean }
2243
- },
2244
- emits: ["undo", "redo", "restore", "locate"],
2245
- setup(e) {
2246
- function t(n) {
2247
- return n.source ? `${n.source.rowKey} · ${n.source.field}` : `${n.address.pageIndex + 1} / ${n.address.rowIndex + 1}:${n.address.columnIndex + 1}`;
2248
- }
2249
- return (n, a) => (E(), I("div", jr, [
2250
- b("button", {
2251
- type: "button",
2252
- disabled: e.busy || e.saving || !e.canUndo,
2253
- onClick: a[0] || (a[0] = (s) => n.$emit("undo"))
2254
- }, x(e.messages.undo), 9, Hr),
2255
- b("button", {
2256
- type: "button",
2257
- disabled: e.busy || e.saving || !e.canRedo,
2258
- onClick: a[1] || (a[1] = (s) => n.$emit("redo"))
2259
- }, x(e.messages.redo), 9, Kr),
2260
- b("details", Wr, [
2261
- b("summary", null, x(e.messages.changes) + " · " + x(e.messages.changesCount?.replace("{count}", String(e.differences.length))), 1),
2262
- b("section", {
2263
- "aria-label": e.messages.changes
2264
- }, [
2265
- e.differences.length ? (E(), I("ol", Gr, [
2266
- (E(!0), I(fe, null, me(e.differences, (s, o) => (E(), I("li", { key: o }, [
2267
- b("button", {
2268
- type: "button",
2269
- onClick: (r) => n.$emit("locate", s)
2270
- }, x(t(s)), 9, Jr),
2271
- b("span", null, [
2272
- b("s", {
2273
- title: e.messages.changesBefore
2274
- }, x(s.previousText || "∅"), 9, Zr),
2275
- a[3] || (a[3] = re(" → ", -1)),
2276
- b("strong", {
2277
- title: e.messages.changesAfter
2278
- }, x(s.text || "∅"), 9, Yr)
2279
- ])
2280
- ]))), 128))
2281
- ])) : (E(), I("p", Vr, x(e.messages.changesEmpty), 1))
2282
- ], 8, Ur)
2283
- ]),
2284
- b("button", {
2285
- type: "button",
2286
- disabled: e.busy || e.saving || !e.differences.length,
2287
- onClick: a[2] || (a[2] = (s) => n.$emit("restore"))
2288
- }, x(e.messages.restoreChanges), 9, Xr),
2289
- e.saving ? (E(), I("span", Qr, x(e.messages.saving), 1)) : e.differences.length && !e.conflicts.length ? (E(), I("span", _r, x(e.persisted ? e.messages.editSaved : e.messages.editingLocal), 1)) : j("", !0),
2290
- e.conflicts.length ? (E(), I("details", el, [
2291
- b("summary", null, x(e.messages.conflicts) + " · " + x(e.conflicts.length), 1),
2292
- b("ul", null, [
2293
- (E(!0), I(fe, null, me(e.conflicts, (s, o) => (E(), I("li", { key: o }, x(s.message), 1))), 128))
2294
- ])
2295
- ])) : j("", !0)
2296
- ]));
2297
- }
2298
- }), nl = /* @__PURE__ */ ye(tl, [["__scopeId", "data-v-df1c7b86"]]);
2299
- function al(e) {
2300
- const t = e.table?.columnKeys ?? [], n = t.map(() => []);
2301
- if (!e.grid) return t;
2302
- for (const { ci: a, cell: s } of Nn(e.grid, e.widthMm, e.heightMm).cells) {
2303
- const o = (s.text ?? s.rawText ?? "").trim();
2304
- if (o)
2305
- for (let r = a; r < Math.min(t.length, a + (s.colSpan ?? 1)); r++)
2306
- n[r].includes(o) || n[r].push(o);
2307
- }
2308
- return t.map((a, s) => n[s].join(" / ") || a);
2309
- }
2310
- function sl(e, t = []) {
2311
- const n = /* @__PURE__ */ new Set(), a = [];
2312
- for (const [s, o] of (e?.pages ?? []).entries())
2313
- for (const r of o.components) {
2314
- const l = r.table;
2315
- if (!l || l.role !== "header" || n.has(l.id)) continue;
2316
- n.add(l.id);
2317
- const c = al(r), v = t.filter((w) => w.pageIndex <= s), h = v[v.length - 1]?.label, f = l.source?.datasetId, m = [...new Set([h, l.title, f].filter(Boolean))].join(" · ") || l.id;
2318
- l.columnKeys.forEach((w, p) => {
2319
- w && a.push({ key: JSON.stringify([l.id, p]), field: w, label: c[p], group: m, pageIndex: s, tableId: l.id, ...f ? { datasetId: f } : {} });
2320
- });
2321
- }
2322
- return a;
2323
- }
2324
- function ol(e, t) {
2325
- const n = t.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
2326
- return e.filter((a) => {
2327
- const s = `${a.label} ${a.field} ${a.group}`.toLocaleLowerCase();
2328
- return n.every((o) => s.includes(o));
2329
- });
2330
- }
2331
- function rl(e) {
2332
- const t = Wn(), n = W(""), a = W(0), s = `mrp-column-list-${Xt()?.uid ?? 0}`, o = F(() => sl(e.plan(), e.sections())), r = F(() => ol(o.value, n.value)), l = F(() => r.value.slice(0, 100)), c = F(() => [...new Set(l.value.map((p) => p.group))].map((p) => ({ label: p, items: l.value.filter((u) => u.group === p) })));
2333
- oe(n, () => {
2334
- a.value = 0;
2335
- }), oe(e.busy, (p) => {
2336
- p && t.close();
2337
- }), oe(o, () => {
2338
- a.value = 0;
2339
- });
2340
- function v(p) {
2341
- e.busy() || (e.locate(p), t.close(!0));
2342
- }
2343
- function h() {
2344
- if (e.busy()) return;
2345
- const p = l.value[a.value];
2346
- p ? v(p) : n.value.trim() && (e.locateField(n.value.trim()), t.close(!0));
2347
- }
2348
- function f() {
2349
- n.value = "", t.panel.value?.querySelector("input")?.focus();
2350
- }
2351
- function m(p) {
2352
- if (!(p.isComposing || p.keyCode === 229 || !["ArrowDown", "ArrowUp", "Enter"].includes(p.key))) {
2353
- if (p.preventDefault(), p.stopPropagation(), p.key === "Enter") {
2354
- h();
2355
- return;
2356
- }
2357
- l.value.length && (a.value = (a.value + (p.key === "ArrowDown" ? 1 : -1) + l.value.length) % l.value.length, Fe(() => t.panel.value?.querySelector(`[id="${s}-${a.value}"]`)?.scrollIntoView?.({ block: "nearest" })));
2358
- }
2359
- }
2360
- function w(p) {
2361
- return l.value.findIndex((u) => u.key === p);
2362
- }
2363
- return { ...t, field: n, active: a, listId: s, directory: o, matches: r, candidates: l, groups: c, choose: v, submit: h, clear: f, onSearchKeydown: m, candidateIndex: w };
2364
- }
2365
- const ll = ["aria-label"], il = {
2366
- key: 0,
2367
- class: "mrp-section-tabs"
2368
- }, ul = ["aria-current", "disabled", "onClick"], cl = ["aria-expanded", "disabled"], dl = {
2369
- key: 0,
2370
- class: "mrp-column-count"
2371
- }, fl = ["aria-label"], ml = { class: "mrp-column-heading" }, gl = ["aria-label"], pl = ["aria-label", "placeholder", "aria-controls", "aria-activedescendant", "disabled"], vl = ["aria-label"], hl = ["id", "aria-label"], bl = {
2372
- key: 0,
2373
- class: "mrp-column-empty",
2374
- role: "status"
2375
- }, yl = ["aria-label"], wl = ["id", "aria-selected", "disabled", "onPointermove", "onClick"], xl = ["title"], kl = {
2376
- class: "mrp-column-help",
2377
- role: "status"
2378
- }, El = /* @__PURE__ */ be({
2379
- __name: "ReportNavigation",
2380
- props: {
2381
- sections: {},
2382
- currentPage: {},
2383
- messages: {},
2384
- busy: { type: Boolean },
2385
- plan: {},
2386
- compact: { type: Boolean }
2387
- },
2388
- emits: ["goto", "locate", "locate-target"],
2389
- setup(e, { emit: t }) {
2390
- const n = e, a = t, s = rl({ plan: () => n.plan, sections: () => n.sections, busy: () => n.busy, locate: (D) => a("locate-target", D), locateField: (D) => a("locate", D) }), { root: o, trigger: r, panel: l, opened: c, field: v, active: h, directory: f, matches: m, candidates: w, groups: p, listId: u } = s, i = F(() => ({ columnDirectory: "字段目录", columnSearch: "搜索列名或字段", columnNoMatches: "未找到匹配字段", columnResults: "匹配字段", ...n.messages })), k = F(() => (n.messages.columnResultsMore ?? "{count} 个匹配字段,显示前 {limit} 个;继续输入可缩小范围").replace("{count}", String(m.value.length)).replace("{limit}", String(w.value.length)));
2391
- function R(D) {
2392
- const A = n.sections[D];
2393
- return !!A && n.currentPage >= A.pageIndex + 1 && (!n.sections[D + 1] || n.currentPage <= n.sections[D + 1].pageIndex);
2394
- }
2395
- return (D, A) => (E(), I("nav", {
2396
- class: pe(["mrp-section-nav", { "mrp-compact": e.compact }]),
2397
- "aria-label": e.messages.sections ?? "工作表与章节"
2398
- }, [
2399
- e.sections.length > 1 ? (E(), I("div", il, [
2400
- (E(!0), I(fe, null, me(e.sections, (z, H) => (E(), I("button", {
2401
- key: H,
2402
- type: "button",
2403
- class: pe({ active: R(H) }),
2404
- "aria-current": R(H) ? "page" : void 0,
2405
- disabled: e.busy,
2406
- onClick: (J) => a("goto", z.pageIndex + 1)
2407
- }, x(z.label), 11, ul))), 128))
2408
- ])) : j("", !0),
2409
- b("div", {
2410
- ref_key: "root",
2411
- ref: o,
2412
- class: "mrp-column-locator",
2413
- onKeydown: A[7] || (A[7] = //@ts-ignore
2414
- (...z) => d(s).onKeydown && d(s).onKeydown(...z))
2415
- }, [
2416
- b("button", {
2417
- ref_key: "trigger",
2418
- ref: r,
2419
- type: "button",
2420
- class: pe(["mrp-directory-trigger", { active: d(c) }]),
2421
- "aria-expanded": d(c),
2422
- "aria-haspopup": "dialog",
2423
- disabled: e.busy,
2424
- onClick: A[0] || (A[0] = (z) => c.value = !d(c))
2425
- }, [
2426
- X(ee, { name: "columns" }),
2427
- b("span", null, x(i.value.columnDirectory), 1),
2428
- d(f).length ? (E(), I("span", dl, x(d(f).length), 1)) : j("", !0),
2429
- X(ee, {
2430
- name: "chevron-down",
2431
- size: 12
2432
- })
2433
- ], 10, cl),
2434
- d(c) ? (E(), I("div", {
2435
- key: 0,
2436
- ref_key: "panel",
2437
- ref: l,
2438
- class: "mrp-column-directory",
2439
- role: "dialog",
2440
- "aria-label": i.value.columnDirectory
2441
- }, [
2442
- b("div", ml, [
2443
- b("span", null, [
2444
- X(ee, { name: "columns" }),
2445
- re(x(i.value.columnDirectory), 1)
2446
- ]),
2447
- b("button", {
2448
- type: "button",
2449
- class: "mrp-column-close",
2450
- "aria-label": e.messages.closeColumnDirectory ?? "关闭字段目录",
2451
- onClick: A[1] || (A[1] = (z) => d(s).close(!0))
2452
- }, [
2453
- X(ee, {
2454
- name: "close",
2455
- size: 15
2456
- })
2457
- ], 8, gl)
2458
- ]),
2459
- b("form", {
2460
- class: "mrp-column-search",
2461
- onSubmit: A[5] || (A[5] = nt(
2462
- //@ts-ignore
2463
- (...z) => d(s).submit && d(s).submit(...z),
2464
- ["prevent"]
2465
- ))
2466
- }, [
2467
- X(ee, { name: "search" }),
2468
- Zt(b("input", {
2469
- "onUpdate:modelValue": A[2] || (A[2] = (z) => On(v) ? v.value = z : null),
2470
- type: "search",
2471
- autocomplete: "off",
2472
- spellcheck: "false",
2473
- role: "combobox",
2474
- "aria-label": i.value.columnSearch,
2475
- placeholder: i.value.columnSearch,
2476
- "aria-autocomplete": "list",
2477
- "aria-expanded": "true",
2478
- "aria-controls": d(u),
2479
- "aria-activedescendant": d(w).length ? `${d(u)}-${d(h)}` : void 0,
2480
- disabled: e.busy,
2481
- onKeydown: A[3] || (A[3] = //@ts-ignore
2482
- (...z) => d(s).onSearchKeydown && d(s).onSearchKeydown(...z))
2483
- }, null, 40, pl), [
2484
- [Yt, d(v)]
2485
- ]),
2486
- d(v) ? (E(), I("button", {
2487
- key: 0,
2488
- class: "mrp-column-clear",
2489
- type: "button",
2490
- "aria-label": e.messages.clearSearch ?? "清除搜索",
2491
- onClick: A[4] || (A[4] = //@ts-ignore
2492
- (...z) => d(s).clear && d(s).clear(...z))
2493
- }, [
2494
- X(ee, {
2495
- name: "close",
2496
- size: 13
2497
- })
2498
- ], 8, vl)) : j("", !0)
2499
- ], 32),
2500
- b("div", {
2501
- id: d(u),
2502
- class: "mrp-column-results",
2503
- role: "listbox",
2504
- "aria-label": i.value.columnResults
2505
- }, [
2506
- d(w).length ? j("", !0) : (E(), I("p", bl, [
2507
- X(ee, {
2508
- name: "search",
2509
- size: 22
2510
- }),
2511
- re(x(i.value.columnNoMatches), 1)
2512
- ])),
2513
- (E(!0), I(fe, null, me(d(p), (z) => (E(), I("section", {
2514
- key: z.label,
2515
- role: "group",
2516
- "aria-label": z.label
2517
- }, [
2518
- b("strong", null, x(z.label), 1),
2519
- (E(!0), I(fe, null, me(z.items, (H) => (E(), I("button", {
2520
- id: `${d(u)}-${d(s).candidateIndex(H.key)}`,
2521
- key: H.key,
2522
- type: "button",
2523
- role: "option",
2524
- tabindex: "-1",
2525
- class: pe({ "mrp-column-active": d(s).candidateIndex(H.key) === d(h) }),
2526
- "aria-selected": d(s).candidateIndex(H.key) === d(h),
2527
- disabled: e.busy,
2528
- onPointermove: (J) => h.value = d(s).candidateIndex(H.key),
2529
- onMousedown: A[6] || (A[6] = nt(() => {
2530
- }, ["prevent"])),
2531
- onClick: (J) => d(s).choose(H)
2532
- }, [
2533
- b("span", null, [
2534
- re(x(H.label), 1),
2535
- b("code", {
2536
- title: H.field
2537
- }, x(H.field), 9, xl)
2538
- ]),
2539
- X(ee, {
2540
- name: "arrow-right",
2541
- size: 14
2542
- })
2543
- ], 42, wl))), 128))
2544
- ], 8, yl))), 128))
2545
- ], 8, hl),
2546
- b("p", kl, x(d(m).length > d(w).length ? k.value : e.messages.columnSearchShortcut ?? "↑ ↓ 选择 · Enter 定位"), 1)
2547
- ], 8, fl)) : j("", !0)
2548
- ], 544)
2549
- ], 10, ll));
2550
- }
2551
- }), Tn = /* @__PURE__ */ ye(El, [["__scopeId", "data-v-b47639d9"]]), Cl = { class: "mrp-import-summary" }, $l = { key: 0 }, Il = { key: 0 }, Pl = /* @__PURE__ */ be({
2552
- __name: "ReportImportSummary",
2553
- props: {
2554
- result: {},
2555
- messages: {}
2556
- },
2557
- setup(e) {
2558
- return (t, n) => (E(), I("details", Cl, [
2559
- b("summary", null, [
2560
- re(x(e.messages.importSummary) + " · " + x(e.messages.importPreserved?.replace("{sheets}", String(e.result.sheets.length))) + " ", 1),
2561
- e.result.warnings.length ? (E(), I("span", $l, " · " + x(e.result.warnings.length) + " " + x(e.messages.importWarnings), 1)) : j("", !0)
2562
- ]),
2563
- b("p", null, x(e.messages.importReadOnly), 1),
2564
- b("ul", null, [
2565
- (E(!0), I(fe, null, me(e.result.sheets, (a) => (E(), I("li", {
2566
- key: a.index
2567
- }, x(a.name) + " · " + x(a.range) + " · " + x(a.rowCount) + " × " + x(a.columnCount), 1))), 128))
2568
- ]),
2569
- e.result.warnings.length ? (E(), I("ul", Il, [
2570
- (E(!0), I(fe, null, me(e.result.warnings, (a, s) => (E(), I("li", { key: s }, x(a), 1))), 128))
2571
- ])) : j("", !0)
2572
- ]));
2573
- }
2574
- }), Sl = /* @__PURE__ */ ye(Pl, [["__scopeId", "data-v-54f275e8"]]), Gn = {
2575
- calculationTitle: "选区计算",
2576
- calculationLocal: "仅本地分析,不写回实绩、不重算原公式。请选取同一单位与量纲的数值。",
2577
- calculationHint: "点击起点,Shift + 点击终点或方向键扩选。",
2578
- calculationFormula: "计算方式",
2579
- calculationExpression: "组合公式",
2580
- calculationExpressionHint: "支持 SUM、AVERAGE/AVG、MIN、MAX、COUNT、MEDIAN 及 + - * / 和括号,不执行 Excel 公式;采用浮点数,精度仅用于展示。",
2581
- calculationPrecision: "展示小数位",
2582
- calculationRun: "计算选区",
2583
- calculationCancel: "取消计算",
2584
- calculationResult: "计算结果",
2585
- calculationIncluded: "参与数值",
2586
- calculationExcluded: "排除单元格",
2587
- calculationEmpty: "选区没有可计算数值,计数为 0,其余结果为空。",
2588
- calculationNoSelection: "先关闭设置并选择数据,再从底部工具栏打开选区计算。",
2589
- calculationSum: "求和 SUM",
2590
- calculationAverage: "平均值 AVERAGE",
2591
- calculationMin: "最小值 MIN",
2592
- calculationMax: "最大值 MAX",
2593
- calculationCount: "数值计数 COUNT",
2594
- calculationMedian: "中位数 MEDIAN",
2595
- calculationCustom: "组合公式",
2596
- calculationErrorSelection: "请选择同一明细区域中的数据。",
2597
- calculationErrorLimit: "选区超过计算预算,请缩小范围后重试。",
2598
- calculationErrorExpression: "公式无效,请使用支持的摘要名称、运算符与括号。",
2599
- calculationErrorDivision: "除数不能为 0。",
2600
- calculationErrorOverflow: "结果超出有效数值范围。",
2601
- calculationErrorPrecision: "数值超出安全精度,或展示小数位不是 0 至 12 的整数。"
2602
- };
2603
- function Rl(e) {
2604
- const t = { ...Gn };
2605
- for (const n of Object.keys(t)) {
2606
- const a = e[n];
2607
- typeof a == "string" && (t[n] = a);
2608
- }
2609
- return t;
2610
- }
2611
- const Ml = {
2612
- ...Gn,
2613
- exportMenu: "导出",
2614
- exportMenuDescription: "选择文件格式",
2615
- clearSearch: "清除搜索",
2616
- searchHint: "Enter 下一个 · Shift+Enter 上一个",
2617
- searchNoMatches: "没有匹配内容",
2618
- pageJump: "跳至页",
2619
- pageJumpInvalid: "请输入有效页码",
2620
- pageJumpHint: "Enter 跳转",
2621
- pagination: "报表分页",
2622
- columnSearchHint: "输入列名或字段标识",
2623
- columnSearchShortcut: "↑ ↓ 选择 · Enter 定位",
2624
- closeColumnDirectory: "关闭字段目录",
2625
- columnResultsMore: "{count} 个匹配字段,显示前 {limit} 个;继续输入可缩小范围",
2626
- columnCount: "{count} 个字段",
2627
- settingsGeneral: "常规",
2628
- settingsTools: "工具",
2629
- settingsAdvanced: "高级",
2630
- settingsAdvancedDescription: "按需开启分析能力,保持日常阅读简洁。",
2631
- settingsCalculations: "启用选区计算",
2632
- settingsCalculationsDescription: "选取数值后计算求和、平均值或组合公式,仅用于本地分析。",
2633
- title: "报表预览",
2634
- prevPage: "‹ 上一页",
2635
- nextPage: "下一页 ›",
2636
- pageInfo: "{cur} / {total}",
2637
- fitWidth: "适宽",
2638
- exportHtml: "导出 HTML",
2639
- exportPdf: "导出 PDF",
2640
- exportExcel: "导出 Excel",
2641
- exportImage: "导出图片",
2642
- exportWord: "导出 Word",
2643
- exporting: "正在生成 {format}…",
2644
- print: "打印",
2645
- pdfWindow: "PDF 窗口",
2646
- loading: "报表渲染中…",
2647
- empty: "暂无预览数据",
2648
- errorPrefix: "",
2649
- retry: "重试",
2650
- pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
2651
- searchPlaceholder: "搜索报表内容",
2652
- matchInfo: "{cur}/{total}",
2653
- prevMatch: "‹",
2654
- nextMatch: "›",
2655
- thumbnails: "缩略图",
2656
- paramsTitle: "查询条件",
2657
- query: "查 询",
2658
- reset: "重 置",
2659
- paramRequired: "请填写{label}",
2660
- paramInvalid: "{label}:{message}",
2661
- paramPrompt: "请先完善查询条件",
2662
- paramPromptDescription: "填写必填条件后点击查询,即可生成报表。",
2663
- paramSelectPlaceholder: "请选择{label}",
2664
- paramTextPlaceholder: "请输入{label}",
2665
- searching: "搜索中…",
2666
- importExcel: "导入 Excel 模板",
2667
- importing: "正在导入 Excel…",
2668
- editCell: "编辑单元格",
2669
- editingHint: "双击单元格编辑 · Enter 确认 · Esc 取消",
2670
- saving: "正在保存修改…",
2671
- editInvalidNumber: "请输入有效数字;清空表示无值",
2672
- editInvalidBoolean: "请输入 true / false、是 / 否或 1 / 0",
2673
- editConflict: "该单元格已变化,请重新打开编辑",
2674
- settings: "设置",
2675
- settingsDisplay: "阅读工具",
2676
- settingsExport: "导出与打印",
2677
- settingsData: "数据操作",
2678
- settingsUnavailable: "需由接入方配置启用",
2679
- settingsReset: "恢复默认",
2680
- settingsClose: "关闭设置",
2681
- search: "内容搜索",
2682
- closeSearch: "关闭搜索",
2683
- prevSearchMatch: "上一个匹配",
2684
- nextSearchMatch: "下一个匹配",
2685
- zoom: "缩放工具",
2686
- settingsLocal: "按需启用工具,仅作用于当前预览。",
2687
- editingLocal: "修改为本地草稿;不会自动写入业务数据库。",
2688
- editingSaved: "修改将通过接入方配置的保存回调提交。",
2689
- importLocal: "导入仅生成本地预览,不自动替换业务数据。",
2690
- emptyDescription: "当前查询没有明细,请调整查询条件后重试。",
2691
- undo: "撤销",
2692
- redo: "重做",
2693
- restoreChanges: "恢复来源值",
2694
- changes: "修改明细",
2695
- changesCount: "{count} 处修改",
2696
- changesEmpty: "尚无修改",
2697
- changesBefore: "来源值",
2698
- changesAfter: "当前值",
2699
- editAtomicRequired: "批量保存需要接入方提供原子 saveBatch 回调;本次未写入任何单元格。",
2700
- clipboardLimit: "单次最多粘贴 10000 个单元格,请分批处理。",
2701
- preferencesError: "偏好存储不可用,设置仍在当前预览中生效。",
2702
- freezeHeaders: "冻结表头",
2703
- frozenColumns: "冻结前列",
2704
- sections: "工作表与章节",
2705
- locateField: "定位字段",
2706
- locateFieldPlaceholder: "输入字段标识,Enter 定位",
2707
- locateFieldMissing: "未找到该字段,请核对字段标识。",
2708
- importSummary: "Excel 导入摘要",
2709
- importPreserved: "已导入 {sheets} 个工作表,保留内容、合并和样式。",
2710
- importWarnings: "兼容性提示",
2711
- importReadOnly: "公式、日期及受保护单元格保持只读;公式不重算。",
2712
- conflicts: "保存冲突",
2713
- editReadOnly: "选区包含只读或无权限单元格,本次修改未应用。",
2714
- editMissing: "选区超出报表范围或缺少业务来源,请重新选择。",
2715
- editDuplicate: "选区包含同一业务字段的重复单元格,请缩小选区。",
2716
- clipboardInvalid: "剪贴板内容无法识别,请使用矩形表格文本重新粘贴。",
2717
- editSaved: "修改已通过保存回调确认",
2718
- settingsPanes: "冻结窗格",
2719
- columnDirectory: "字段目录",
2720
- columnSearch: "搜索列名或字段",
2721
- columnNoMatches: "未找到匹配字段",
2722
- columnResults: "匹配字段",
2723
- columnGroup: "明细区域",
2724
- discardTitle: "保留当前修改?",
2725
- discardDescription: "当前报表有尚未保存的输入或本地草稿,继续操作将替换这些内容。",
2726
- discardKeep: "继续编辑",
2727
- discardProceed: "放弃修改并继续",
2728
- taskQuery: "正在获取数据…",
2729
- taskValidate: "正在校验数据…",
2730
- taskLayout: "正在生成版式…",
2731
- taskAssets: "正在准备图片和字体…",
2732
- taskEncode: "正在生成文件…",
2733
- taskDownload: "正在准备下载…",
2734
- taskPrint: "正在准备打印…",
2735
- taskCancel: "取消任务",
2736
- taskCancelled: "任务已取消,可重新操作。",
2737
- diagnosticsSearch: "搜索提示、错误码或位置",
2738
- diagnosticsMore: "共 {count} 条匹配,当前展示前 100 条;请搜索缩小范围。",
2739
- diagnosticsTitle: "输出兼容性提示",
2740
- diagnosticsLocate: "定位",
2741
- diagnosticsLocation: "第 {page} 页 · 组件 {component}",
2742
- diagnosticsStrict: "当前格式存在已知内容降级,请查看兼容性提示或选择其他输出格式。",
2743
- diagnosticsDetails: "查看技术详情",
2744
- diagnosticMissingImage: "图片或图表资源尚未准备完成,请重试或联系管理员。",
2745
- diagnosticUnsupported: "当前输出格式会省略此内容,建议选择 PDF 或图片格式。",
2746
- diagnosticUnsupportedStyle: "当前格式无法保留部分样式,请查看位置并选择适合的输出格式。",
2747
- diagnosticImageFormat: "当前图片格式无法直接导出,请转换资源后重试。",
2748
- diagnosticRichText: "文字内容会保留,部分字体与段落样式将简化。",
2749
- diagnosticNested: "单元格中的嵌套内容会省略,单元格文字会保留。",
2750
- diagnosticImageAsync: "图片需要完成加载后才能输出。",
2751
- diagnosticImageDecode: "图片加载失败,请检查资源后重试。",
2752
- diagnosticAssetFailed: "图表或图片生成失败,请重试或联系管理员。",
2753
- diagnosticAssetBudget: "图片资源超出处理范围,请减少资源或缩小报表范围。"
2754
- }, Tl = {
2755
- emptyAccent: "#79a7e8",
2756
- shellBg: "#f4f7fc",
2757
- shellFg: "#334155",
2758
- toolbarBg: "#ffffff",
2759
- toolbarBorder: "#e4eaf3",
2760
- toolbarFg: "#334155",
2761
- btnFg: "#526078",
2762
- btnBorder: "#dbe3ef",
2763
- btnHoverBg: "#edf3ff",
2764
- btnHoverFg: "#315fba",
2765
- btnActiveBg: "#3569d4"
2766
- };
2767
- function Dl(e = {}) {
2768
- return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
2769
- }
2770
- function qi(e) {
2771
- return e;
2772
- }
2773
- const Le = {
2774
- showExport: !0,
2775
- showPrint: !0,
2776
- showPdfWindow: !0,
2777
- showSettings: !0,
2778
- showParams: !0,
2779
- gapPx: 18,
2780
- pdfFontUrl: "/simhei.ttf",
2781
- logger: console
2782
- }, Bi = { warn: () => {
2783
- }, info: () => {
2784
- } };
2785
- function ft(e, t) {
2786
- return {
2787
- ...e,
2788
- ...t,
2789
- theme: { ...e?.theme, ...t?.theme },
2790
- messages: { ...e?.messages, ...t?.messages },
2791
- preview: { ...e?.preview, ...t?.preview },
2792
- xlsx: { ...e?.xlsx, ...t?.xlsx },
2793
- toolbar: { ...e?.toolbar, ...t?.toolbar },
2794
- interaction: { ...e?.interaction, ...t?.interaction },
2795
- output: { ...e?.output, ...t?.output }
2796
- };
2797
- }
2798
- function Al(e) {
2799
- return {
2800
- showExport: e.showExport ?? Le.showExport,
2801
- showPrint: e.showPrint ?? Le.showPrint,
2802
- showPdfWindow: e.showPdfWindow ?? Le.showPdfWindow,
2803
- showSettings: e.showSettings ?? Le.showSettings,
2804
- showParams: e.showParams ?? Le.showParams,
2805
- gapPx: e.gapPx ?? Le.gapPx
2806
- };
2807
- }
2808
- function Fl(e, t) {
2809
- const n = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, a = ft(e?.defaults, n);
2810
- return {
2811
- ...Al(a),
2812
- pdfFontUrl: a.pdfFontUrl ?? Le.pdfFontUrl,
2813
- theme: { ...Tl, ...a.theme },
2814
- messages: { ...Ml, ...a.messages },
2815
- logger: a.logger ?? Le.logger,
2816
- preview: {
2817
- overscanPages: Dn(a.preview?.overscanPages, 1, 10, !0),
2818
- searchDebounceMs: Dn(a.preview?.searchDebounceMs, 200, 2e3)
2819
- },
2820
- xlsx: { ...a.xlsx },
2821
- editable: a.editable ?? !1,
2822
- excelImport: a.excelImport ?? !1,
2823
- toolbar: { ...a.toolbar },
2824
- interaction: { ...a.interaction },
2825
- preferences: a.preferences,
2826
- assets: a.assets,
2827
- guardChanges: a.guardChanges ?? !0,
2828
- beforeDiscard: a.beforeDiscard,
2829
- output: { ...a.output }
2830
- };
2831
- }
2832
- function Dn(e, t, n, a = !1) {
2833
- if (e == null || !Number.isFinite(e)) return t;
2834
- const s = Math.max(0, Math.min(n, e));
2835
- return a ? Math.floor(s) : s;
2836
- }
2837
- function Ol(e) {
2838
- const t = {};
2839
- return e.emptyAccent != null && (t["--mrp-empty-accent"] = e.emptyAccent), 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;
2840
- }
2841
- function Ni(e) {
2842
- const t = gt(Wt, null), n = F(() => {
2843
- const a = t?.value ?? null, s = "defaults" in e || "presets" in e || "defaultPreset" in e ? Dl(e) : { defaults: e, presets: {} };
2844
- if (!a) return s;
2845
- const o = { ...a.presets, ...s.presets };
2846
- for (const r of Object.keys(o))
2847
- o[r] = ft(
2848
- ft(a.presets[r], s.defaults),
2849
- s.presets[r]
2850
- );
2851
- return {
2852
- defaults: ft(a.defaults, s.defaults),
2853
- presets: o,
2854
- defaultPreset: s.defaultPreset ?? a.defaultPreset
2855
- };
2856
- });
2857
- Ln(Wt, n);
2858
- }
2859
- function Ll() {
2860
- return gt(Wt, F(() => null));
2861
- }
2862
- function Ce(e) {
2863
- return JSON.parse(JSON.stringify(e));
2864
- }
2865
- function Jn(e, t) {
2866
- const n = t.fields;
2867
- if (typeof n == "function") return n(e);
2868
- const a = e.source?.field ?? e.table?.columnKey;
2869
- return a === void 0 || !n || !Object.prototype.hasOwnProperty.call(n, a) ? void 0 : n[a];
2870
- }
2871
- class zl extends Error {
2872
- constructor(t) {
2873
- super(t.map((n) => n.message).join(";")), this.conflicts = t, this.name = "ReportEditConflictError";
2874
- }
2875
- }
2876
- function ql() {
2877
- return globalThis.crypto?.randomUUID?.() ?? `mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2878
- }
2879
- function Bl(e) {
2880
- const t = le([]), n = le([]), a = le([]), s = le([]), o = le(!1), r = le(null), l = le([]), c = F(() => l.value.length > 0), v = F(() => Cn(t.value)), h = F(() => !!e.options.value && !o.value && !e.blocked() && n.value.length > 0), f = F(() => !!e.options.value && !o.value && !e.blocked() && a.value.length > 0);
2881
- let m = null, w = null, p = 0, u = null;
2882
- function i() {
2883
- m?.abort(), m = null, o.value = !1, w = null;
2884
- }
2885
- function k() {
2886
- p++, i(), u = null, t.value = [], n.value = [], a.value = [], s.value = [], l.value = [], r.value = null;
2887
- }
2888
- function R() {
2889
- const y = e.options.value;
2890
- return y ? typeof y == "object" ? y : {} : null;
2891
- }
2892
- function D(y, C, M) {
2893
- if (!e.options.value || e.blocked()) throw new ze("readonly");
2894
- const O = Kt(y);
2895
- for (const N of C.edits) {
2896
- const K = O(N.address);
2897
- if (!K?.editable || M.canEdit?.(K) === !1) throw new ze("readonly");
2898
- if (M.requireSource && !K.source) throw new ze("missing");
2899
- const G = Jn(K, M);
2900
- G && ja(K, N.value, G);
2901
- }
2902
- }
2903
- async function A(y, C, M) {
2904
- if (C.saveBatch) return C.saveBatch(Ce(y), M);
2905
- if (C.save && y.edits.length > 1) throw new ze("atomic");
2906
- if (y.edits[0]) return C.save?.(Ce(y.edits[0]), M);
2907
- }
2908
- async function z(y, C, M) {
2909
- for (const O of y.edits) {
2910
- const N = await C.validate?.(Ce(O), M);
2911
- if (N) throw new Error(N);
2912
- if (M.signal.aborted) return;
2913
- }
2914
- }
2915
- function H(y, C, M, O, N) {
2916
- if (e.plan.value = Ha(Ka(y, C), C, M), t.value = [...t.value, ...C.edits], N) {
2917
- const G = new Set(C.edits.map($n));
2918
- l.value = l.value.filter((B) => !G.has($n(B)));
2919
- } else l.value = Cn([...l.value, ...C.edits]);
2920
- O === "edit" && (n.value = [...n.value, C.edits], a.value = []), s.value = [], u = null;
2921
- const K = p;
2922
- for (const G of C.edits) {
2923
- if (p !== K) break;
2924
- e.onChange(Ce(G));
2925
- }
2926
- }
2927
- async function J(y, C) {
2928
- const M = e.plan.value, O = R();
2929
- if (!M || !O || e.blocked()) return !1;
2930
- const N = new AbortController(), K = p;
2931
- m = N, o.value = !0, r.value = null;
2932
- const G = () => m === N && !N.signal.aborted && e.plan.value === M && e.options.value !== !1;
2933
- try {
2934
- const B = Na(M, y, ql());
2935
- if (D(M, B, O), B.edits = B.edits.filter((T) => !Object.is(T.previousValue, T.value)), !B.edits.length) return !0;
2936
- const $ = JSON.stringify([C, B.edits]);
2937
- u?.plan === M && u.signature === $ ? B.requestId = u.requestId : u = { plan: M, signature: $, requestId: B.requestId }, D(M, B, O);
2938
- const P = { signal: N.signal, requestId: B.requestId, action: C };
2939
- if (await z(B, O, P), !G()) return !1;
2940
- D(M, B, O);
2941
- const q = await A(B, O, P);
2942
- if (!G()) return !1;
2943
- if (q?.conflicts?.length)
2944
- throw s.value = Ce(q.conflicts), new zl(q.conflicts);
2945
- return D(M, B, O), H(M, B, q, C, !!(O.save || O.saveBatch)), K === p;
2946
- } catch (B) {
2947
- return G() && (r.value = e.errorMessage?.(B) ?? (B instanceof Error ? B.message : "Cell edit failed"), e.onError(r.value, B)), !1;
2948
- } finally {
2949
- m === N && (m = null, o.value = !1);
2950
- }
2951
- }
2952
- async function Z(y, C = "edit") {
2953
- if (w) return w;
2954
- const M = J(y, C);
2955
- w = M;
2956
- const O = await M;
2957
- return w === M && (w = null), O;
2958
- }
2959
- async function Y() {
2960
- const y = p, C = n.value[n.value.length - 1];
2961
- return !C || o.value || !await Z(C.map((M) => ({ address: M.address, value: M.previousValue })), "undo") || y !== p ? !1 : (n.value = n.value.slice(0, -1), a.value = [...a.value, C], !0);
2962
- }
2963
- async function te() {
2964
- const y = p, C = a.value[a.value.length - 1];
2965
- return !C || o.value || !await Z(C.map((M) => ({ address: M.address, value: M.value })), "redo") || y !== p ? !1 : (a.value = a.value.slice(0, -1), n.value = [...n.value, C], !0);
2966
- }
2967
- async function ne() {
2968
- const y = p;
2969
- return !v.value.length || o.value || !await Z(v.value.map((C) => ({ address: C.address, value: C.previousValue })), "restore") || y !== p ? !1 : (n.value = [], a.value = [], !0);
2970
- }
2971
- return { changes: t, differences: v, localDifferences: l, hasLocalDrafts: c, lastError: r, conflicts: s, saving: o, canUndo: h, canRedo: f, apply: Z, undo: Y, redo: te, restore: ne, cancel: i, reset: k };
2972
- }
2973
- let Nl = 0;
2974
- const jl = "position:absolute;inset:0;width:100%;height:100%;min-height:20px;box-sizing:border-box;z-index:10;resize:none;margin:0;padding:2px 4px;border:2px solid var(--mrp-btn-active-bg,#2563eb);outline:none;background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font:inherit;line-height:1.25;white-space:pre-wrap;";
2975
- function Hl(e) {
2976
- return e.type === "boolean" ? [{ value: !0, label: e.trueLabel ?? "是" }, { value: !1, label: e.falseLabel ?? "否" }] : e.type === "enum" ? e.options.map((t) => ({ value: t.value, label: t.label ?? String(t.value) })) : [];
2977
- }
2978
- function Kl(e, t, n) {
2979
- const a = e.createElement("select"), s = [{ value: null, label: "—" }, ...Hl(t)];
2980
- if (s.forEach((o, r) => {
2981
- const l = e.createElement("option");
2982
- l.value = String(r), l.textContent = o.label, (Object.is(n.value, o.value) || n.value === "" && o.value === null) && (l.selected = !0), a.append(l);
2983
- }), !s.some((o) => Object.is(n.value, o.value) || n.value === "" && o.value === null)) {
2984
- const o = e.createElement("option");
2985
- o.value = "unknown", o.textContent = n.cell.text ?? String(n.value), o.selected = !0, a.append(o);
2986
- }
2987
- return { input: a, value: () => a.value === "unknown" ? n.value : s[Number(a.value)]?.value ?? null };
2988
- }
2989
- function Wl(e, t, n) {
2990
- const a = t?.type === "number" || t?.type === "date" ? e.createElement("input") : e.createElement("textarea");
2991
- return a.value = n.value == null ? "" : String(n.value), a instanceof HTMLInputElement && (a.type = t?.type === "date" ? "date" : "text", t?.type === "number" && (a.inputMode = "decimal"), t?.type === "date" && (t.min && (a.min = t.min), t.max && (a.max = t.max))), { input: a, value: () => t?.type === "date" && a instanceof HTMLInputElement && a.validity.badInput ? "invalid-date" : a.value };
2992
- }
2993
- function Ul(e) {
2994
- if (!e) return "";
2995
- const t = [e.hint, e.unit];
2996
- return (e.type === "number" || e.type === "date") && (e.min !== void 0 && t.push(`≥ ${e.min}`), e.max !== void 0 && t.push(`≤ ${e.max}`)), e.type === "number" && e.precision !== void 0 && t.push(`最多 ${e.precision} 位小数`), e.type === "text" && e.maxLength !== void 0 && t.push(`最多 ${e.maxLength} 字符`), t.filter(Boolean).join(" · ");
2997
- }
2998
- function Vl(e, t, n, a) {
2999
- const s = e.ownerDocument, o = a?.type === "boolean" || a?.type === "enum" ? Kl(s, a, n) : Wl(s, a, n), r = o.input, l = s.createElement("span");
3000
- l.className = "mrp-cell-editor-host", l.style.cssText = "position:absolute;inset:0;z-index:10;", r.className = "mrp-cell-editor", r.style.cssText = jl, r.setAttribute("aria-label", a?.label ?? t), a?.required && r.setAttribute("aria-required", "true");
3001
- const c = s.createElement("span");
3002
- c.id = `mrp-cell-hint-${++Nl}`, c.className = "mrp-cell-editor-hint", c.style.cssText = "position:absolute;top:100%;left:0;min-width:100%;width:max-content;max-width:320px;box-sizing:border-box;padding:4px 8px;white-space:normal;border:1px solid var(--mrp-toolbar-border,#ddd);background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font-size:12px;line-height:1.4;box-shadow:0 3px 10px #0002;z-index:11;";
3003
- const v = Ul(a);
3004
- return c.textContent = v, c.hidden = !v, r.setAttribute("aria-describedby", c.id), l.append(r, c), e.append(l), {
3005
- input: r,
3006
- root: l,
3007
- initialInput: r.value,
3008
- value: o.value,
3009
- focus: () => {
3010
- r.focus(), (r instanceof HTMLTextAreaElement || r instanceof HTMLInputElement && r.type !== "date") && r.select();
3011
- },
3012
- feedback: (h) => {
3013
- c.textContent = h ?? v, c.hidden = !c.textContent, r.setAttribute("aria-invalid", h ? "true" : "false");
3014
- }
3015
- };
3016
- }
3017
- function Vt(e) {
3018
- const t = e.closest(".mrp-page-holder"), n = e.closest("[data-mr-component-index]");
3019
- if (!t || !n) return null;
3020
- const a = {
3021
- pageIndex: Number(t.dataset.page) - 1,
3022
- componentIndex: Number(n.dataset.mrComponentIndex),
3023
- rowIndex: Number(e.dataset.mrRowIndex),
3024
- columnIndex: Number(e.dataset.mrColumnIndex)
3025
- };
3026
- return Object.values(a).every((s) => Number.isInteger(s) && s >= 0) ? a : null;
3027
- }
3028
- function Gl(e) {
3029
- const t = le(null), n = Bl(e), { saving: a, changes: s } = n, o = le(!1), r = F(() => o.value || n.hasLocalDrafts.value);
3030
- let l = null;
3031
- function c() {
3032
- const i = t.value;
3033
- t.value = null, o.value = !1, n.cancel(), l = null, i?.editor.root.remove();
3034
- }
3035
- function v() {
3036
- c(), n.reset();
3037
- }
3038
- function h(i) {
3039
- return t.value === i && e.plan.value === i.plan;
3040
- }
3041
- async function f(i) {
3042
- return await n.apply([{ address: i.address, value: i.editor.value() }]) ? (t.value = null, o.value = !1, i.editor.root.remove(), !0) : (t.value === i && (i.editor.input.disabled = !1, i.editor.feedback(n.lastError.value ?? void 0), i.editor.input.focus()), !1);
3043
- }
3044
- async function m() {
3045
- if (l) return l;
3046
- const i = t.value;
3047
- if (!i) return !0;
3048
- if (!h(i))
3049
- return c(), !1;
3050
- o.value = i.editor.input.value !== i.editor.initialInput, i.editor.input.disabled = !0;
3051
- const k = f(i);
3052
- l = k;
3053
- const R = await k;
3054
- return l === k && (l = null), R;
3055
- }
3056
- function w(i) {
3057
- if (i.stopPropagation(), !i.isComposing && (i.key === "Escape" && (i.preventDefault(), c()), i.key === "Enter" && !i.shiftKey || i.key === "Tab")) {
3058
- i.preventDefault();
3059
- const k = t.value?.address;
3060
- m().then((R) => {
3061
- R && k && e.onNavigate?.(k, i.key, i.shiftKey);
3062
- });
3063
- }
3064
- }
3065
- async function p(i) {
3066
- if (!e.options.value || e.blocked() || !await m() || !i.isConnected) return;
3067
- const k = e.plan.value, R = Vt(i);
3068
- if (!k || !R || !e.options.value || e.blocked()) return;
3069
- const D = typeof e.options.value == "object" ? e.options.value : {};
3070
- try {
3071
- const A = ct(k, R);
3072
- if (!A?.editable || D.canEdit?.(A) === !1) return;
3073
- const z = Jn(A, D);
3074
- z && Wa(A, z);
3075
- const H = Vl(i, e.label(), A, z), J = H.input;
3076
- t.value = { plan: k, address: R, editor: H }, o.value = !1, J.addEventListener("keydown", (Z) => w(Z)), J.addEventListener("input", () => {
3077
- o.value = J.value !== H.initialInput, H.feedback();
3078
- }), J.addEventListener("change", () => {
3079
- o.value = J.value !== H.initialInput;
3080
- }), J.addEventListener("blur", () => {
3081
- !a.value && !e.suspendBlur?.() && m();
3082
- }), H.focus();
3083
- } catch (A) {
3084
- e.onError(A instanceof Error ? A.message : "无法编辑单元格", A);
3085
- }
3086
- }
3087
- async function u(i) {
3088
- const k = i.target;
3089
- if (!(k instanceof Element) || k.closest(".mrp-cell-editor")) return;
3090
- const R = k.closest("td[data-mr-row-index]");
3091
- R && await p(R);
3092
- }
3093
- return oe(e.options, (i, k) => {
3094
- (!i || i !== k) && c();
3095
- }, { flush: "sync" }), oe(e.plan, () => {
3096
- t.value && e.plan.value !== t.value.plan && (t.value.editor.root.remove(), t.value = null, o.value = !1);
3097
- }, { flush: "sync" }), Oe(v), {
3098
- ...n,
3099
- active: t,
3100
- saving: a,
3101
- changes: s,
3102
- pendingLocalChanges: r,
3103
- cancel: c,
3104
- reset: v,
3105
- commit: m,
3106
- onDoubleClick: u,
3107
- editCell: p,
3108
- getChanges: () => Ce(s.value)
3109
- };
3110
- }
3111
- const Gt = ["html", "pdf", "xlsx", "png", "word"], An = ["search", "thumbnails", "zoom", ...Gt, "print", "pdfWindow", "editing", "import"];
3112
- function ji(e) {
3113
- return {
3114
- load: (t) => JSON.parse(e.getItem(t) ?? "null"),
3115
- save: (t, n) => e.setItem(t, JSON.stringify(n)),
3116
- remove: (t) => e.removeItem(t)
3117
- };
3118
- }
3119
- function Jl(e, t, n, a) {
3120
- const s = W({});
3121
- let o = 0, r = 0, l = Promise.resolve();
3122
- const c = F(() => Object.fromEntries(An.map((m) => [
3123
- m,
3124
- e.value[m] && (s.value[m] ?? t.value[m] ?? !0)
3125
- ])));
3126
- function v(m, w) {
3127
- e.value[m] && (r++, s.value = { ...s.value, [m]: w }, h());
3128
- }
3129
- function h() {
3130
- const m = n?.value;
3131
- if (!m) return;
3132
- const w = { ...s.value };
3133
- l = l.then(() => m.adapter.save(m.key, w)).catch((p) => {
3134
- a?.(p);
3135
- });
3136
- }
3137
- function f() {
3138
- r++, s.value = {}, h();
3139
- }
3140
- return n && oe(n, async (m) => {
3141
- const w = ++o, p = r;
3142
- if (s.value = {}, !!m)
3143
- try {
3144
- const u = await m.adapter.load(m.key);
3145
- if (w !== o || p !== r || !u || typeof u != "object") return;
3146
- s.value = Object.fromEntries(An.flatMap((i) => typeof u[i] == "boolean" ? [[i, u[i]]] : []));
3147
- } catch (u) {
3148
- w === o && a?.(u);
3149
- }
3150
- }, { immediate: !0 }), Oe(() => {
3151
- o++;
3152
- }), { enabled: c, setEnabled: v, reset: f };
3153
- }
3154
- function Zl(e, t, n) {
3155
- const a = W({}), s = Ll(), o = F(() => Fl(s.value, e.preset)), r = F(() => ({
3156
- ...o.value.messages,
3157
- ...e.messages
3158
- })), l = F(() => e.showExport ?? o.value.showExport), c = F(() => e.showPrint ?? o.value.showPrint), v = F(() => e.showPdfWindow ?? o.value.showPdfWindow), h = F(() => e.showSettings ?? o.value.showSettings), f = F(() => e.guardChanges ?? o.value.guardChanges), m = F(() => ({ ...o.value.output, ...e.output })), w = F(() => ({ ...o.value.toolbar, ...e.toolbar })), p = F(() => ({ ...o.value.interaction, ...e.interaction, ...a.value })), u = F(() => e.preferences ?? o.value.preferences), i = F(() => e.assets ?? o.value.assets), k = F(() => e.gapPx ?? (t.value ? 0 : o.value.gapPx)), R = F(() => e.showParams ?? o.value.showParams), D = F(() => e.editable ?? o.value.editable), A = F(() => e.excelImport ?? o.value.excelImport), z = F(() => ({
3159
- search: w.value.search !== !1,
3160
- thumbnails: w.value.thumbnails !== !1,
3161
- zoom: w.value.zoom !== !1,
3162
- ...Object.fromEntries(Gt.map((C) => [
3163
- C,
3164
- l.value && (w.value.exportFormats?.includes(C) ?? !0)
3165
- ])),
3166
- print: c.value,
3167
- pdfWindow: v.value,
3168
- editing: !!D.value,
3169
- import: !!A.value
3170
- })), H = Jl(z, F(() => ({
3171
- editing: w.value.editing,
3172
- import: w.value.excelImport
3173
- })), u, () => n(r.value.preferencesError ?? "Preferences storage unavailable")), J = H.enabled, Z = F(() => Gt.filter((C) => J.value[C])), Y = F(() => J.value.editing ? D.value : !1), te = F(() => J.value.import ? A.value : !1), ne = F(() => typeof D.value == "object" && (typeof D.value.save == "function" || typeof D.value.saveBatch == "function")), y = F(() => typeof e.emptyState == "object" ? e.emptyState : {});
3174
- return { resolved: o, resolvedMessages: r, effectiveShowExport: l, effectiveShowPrint: c, effectiveShowPdfWindow: v, effectiveShowSettings: h, effectiveGuardChanges: f, effectiveOutput: m, effectiveInteraction: p, effectiveAssets: i, effectiveGapPx: k, effectiveShowParams: R, availableTools: z, tools: H, toolState: J, visibleExportFormats: Z, effectiveEditable: Y, effectiveExcelImport: te, persistedEditing: ne, emptyStateContent: y, sessionInteraction: a };
3175
- }
3176
- function Zn(e) {
3177
- return e.table.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table.rowIndex;
3178
- }
3179
- function Me(e, t, n = t) {
3180
- const a = e.pages[t.pageIndex]?.components[t.componentIndex], s = a?.table, o = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
3181
- return s && o && s.id === o.id ? {
3182
- grid: s.id,
3183
- row: Zn(a) + t.rowIndex,
3184
- column: o.columnKeys.indexOf(s.columnKeys[t.columnIndex] ?? "")
3185
- } : { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
3186
- }
3187
- function Fn(e, t) {
3188
- const n = e.pages[t.pageIndex]?.components[t.componentIndex]?.table;
3189
- if (!n) return (s, o) => ({ ...t, rowIndex: s, columnIndex: o });
3190
- const a = /* @__PURE__ */ new Map();
3191
- return e.pages.forEach((s, o) => s.components.forEach((r, l) => {
3192
- r.table?.id !== n.id || !r.grid || r.grid.cells.forEach((c, v) => {
3193
- const h = Zn(r) + v;
3194
- a.set(h, [...a.get(h) ?? [], { address: { pageIndex: o, componentIndex: l, rowIndex: v, columnIndex: 0 }, keys: r.table.columnKeys }]);
3195
- });
3196
- })), (s, o) => {
3197
- const r = n.columnKeys[o];
3198
- if (r === void 0) return null;
3199
- const l = a.get(s)?.find((c) => c.keys.includes(r));
3200
- return l ? { ...l.address, columnIndex: l.keys.indexOf(r) } : null;
3201
- };
3202
- }
3203
- function Yl(e, t) {
3204
- const n = [...e.ownerDocument.querySelectorAll("a[href],button,input,textarea,select,[tabindex]:not([tabindex='-1'])")].filter((o) => o.tabIndex >= 0 && !o.matches(":disabled,[hidden],input[type='hidden']") && !o.closest("[inert],[aria-hidden='true']") && o.getClientRects().length > 0).map((o, r) => ({ element: o, order: r })).sort((o, r) => (o.element.tabIndex || 1 / 0) - (r.element.tabIndex || 1 / 0) || o.order - r.order), a = n.findIndex(({ element: o }) => o === e);
3205
- if (a < 0) return !1;
3206
- const s = n[a + (t ? -1 : 1)]?.element;
3207
- return s ? (s.focus(), e.ownerDocument.activeElement === s) : !1;
3208
- }
3209
- function Xl(e, t) {
3210
- const n = e?.source;
3211
- return !Ql(e, t.field) || t.tableId !== void 0 && e?.table?.id !== t.tableId || t.datasetId !== void 0 && (n?.datasetId ?? e?.component.table?.source?.datasetId) !== t.datasetId ? !1 : t.rowKey === void 0 || n?.rowKey === t.rowKey;
3212
- }
3213
- function Ql(e, t) {
3214
- if ((e?.source?.field ?? e?.table?.columnKey) === t) return !0;
3215
- if (!e || e.table?.role !== "header") return !1;
3216
- const n = e.address.columnIndex;
3217
- return e.component.table?.columnKeys.slice(n, n + (e.cell.colSpan ?? 1)).includes(t) ?? !1;
3218
- }
3219
- function _l(e, t) {
3220
- return e.pageIndex === t.pageIndex && e.componentIndex === t.componentIndex;
3221
- }
3222
- function ei(e, t) {
3223
- return _l(e, t) && e.rowIndex === t.rowIndex && e.columnIndex === t.columnIndex;
3224
- }
3225
- function zt(e) {
3226
- return `[data-page="${e.pageIndex + 1}"] [data-mr-component-index="${e.componentIndex}"] td[data-mr-row-index="${e.rowIndex}"][data-mr-column-index="${e.columnIndex}"]`;
3227
- }
3228
- function Jt(e) {
3229
- return `${e.pageIndex}:${e.componentIndex}:${e.rowIndex}:${e.columnIndex}`;
3230
- }
3231
- function ti(e, t) {
3232
- const n = Me(e, t.anchor), a = Me(e, t.focus, t.anchor);
3233
- return { grid: n.grid, minRow: Math.min(n.row, a.row), maxRow: Math.max(n.row, a.row), minColumn: Math.min(n.column, a.column), maxColumn: Math.max(n.column, a.column), focusKey: Jt(t.focus), origin: e.pages[t.anchor.pageIndex]?.components[t.anchor.componentIndex]?.table };
3234
- }
3235
- function ni(e, t, n) {
3236
- const a = t?.table;
3237
- if (!a || !n.origin || a.id !== n.origin.id) return { grid: `${e.pageIndex}:${e.componentIndex}`, rowOffset: 0, missingColumn: -1 };
3238
- const s = /* @__PURE__ */ new Map();
3239
- return n.origin.columnKeys.forEach((o, r) => {
3240
- s.has(o) || s.set(o, r);
3241
- }), { grid: a.id, rowOffset: a.role === "header" ? -Math.max(1, t.grid?.cells.length ?? 1) : a.rowIndex, columns: a.columnKeys.map((o) => s.get(o) ?? -1), missingColumn: s.get("") ?? -1 };
3242
- }
3243
- function ai(e, t, n) {
3244
- if (!n || !t || t.grid !== n.grid) return !1;
3245
- const a = t.rowOffset + e.row, s = t.columns ? t.columns[e.column] ?? t.missingColumn : e.column;
3246
- return a >= n.minRow && a <= n.maxRow && s >= n.minColumn && s <= n.maxColumn;
3247
- }
3248
- function mt(e, t, n) {
3249
- e.getAttribute(t) !== n && e.setAttribute(t, n);
3250
- }
3251
- function qt(e, t, n) {
3252
- e.classList.contains(t) !== n && e.classList.toggle(t, n);
3253
- }
3254
- function si(e, t, n, a, s, o) {
3255
- t.role !== n && (mt(e, "role", n), t.role = n), t.selected !== a && (qt(e, "mrp-cell-selected", a), mt(e, "aria-selected", String(a)), t.selected = a), t.focused !== s && (qt(e, "mrp-cell-focus", s), mt(e, "tabindex", s ? "0" : "-1"), t.focused = s), t.modified !== o && (qt(e, "mrp-cell-modified", o), t.modified = o);
3256
- }
3257
- function oi(e) {
3258
- const t = () => e.editable?.() ?? e.enabled(), n = le(null), a = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap();
3259
- let o = null, r = /* @__PURE__ */ new Set();
3260
- function l(y = e.root.value ?? void 0) {
3261
- if (!y) return;
3262
- const C = n.value, M = e.plan.value, O = e.differences();
3263
- O !== o && (o = O, r = new Set(O.map((K) => Jt(K.address))));
3264
- const N = C && M ? ti(M, C) : null;
3265
- y instanceof HTMLTableElement && h(y, M, N);
3266
- for (const K of y.querySelectorAll("table")) h(K, M, N);
3267
- }
3268
- function c(y) {
3269
- const C = a.get(y);
3270
- if (C) return C;
3271
- const M = y.closest("[data-mr-component-index]"), O = M?.closest(".mrp-page-holder"), N = { pageIndex: Number(O?.dataset.page) - 1, componentIndex: Number(M?.dataset.mrComponentIndex) };
3272
- return Object.values(N).every((K) => Number.isInteger(K) && K >= 0) ? (a.set(y, N), N) : null;
3273
- }
3274
- function v(y, C) {
3275
- const M = s.get(y);
3276
- if (M) return M;
3277
- const O = Number(y.dataset.mrRowIndex), N = Number(y.dataset.mrColumnIndex);
3278
- if (![O, N].every((G) => Number.isInteger(G) && G >= 0)) return null;
3279
- const K = { row: O, column: N, key: Jt({ ...C, rowIndex: O, columnIndex: N }) };
3280
- return s.set(y, K), K;
3281
- }
3282
- function h(y, C, M) {
3283
- const O = c(y);
3284
- if (!O) return;
3285
- const N = C?.pages[O.pageIndex]?.components[O.componentIndex], K = N?.table?.role === "header" ? "columnheader" : "gridcell", G = M ? ni(O, N, M) : null;
3286
- mt(y, "role", "grid");
3287
- for (const B of y.rows) for (const $ of B.cells) {
3288
- const P = v($, O);
3289
- P && si($, P, K, ai(P, G, M), M?.focusKey === P.key, r.size > 0 && r.has(P.key));
3290
- }
3291
- }
3292
- async function f(y, C = !1) {
3293
- if (!e.plan.value || !ct(e.plan.value, y)) return !1;
3294
- const M = n.value, O = C && M && Me(e.plan.value, M.anchor).grid === Me(e.plan.value, y, M.anchor).grid;
3295
- n.value = { anchor: O ? M.anchor : { ...y }, focus: { ...y } }, e.root.value?.querySelector(zt(y)) || e.gotoPage(y.pageIndex + 1), await Fe(), l();
3296
- const N = e.root.value?.querySelector(zt(y));
3297
- return N?.focus({ preventScroll: !0 }), N?.scrollIntoView?.({ block: "nearest", inline: "nearest" }), !!N;
3298
- }
3299
- function m(y) {
3300
- const C = y.target;
3301
- if (!(C instanceof Element) || C.closest("textarea,input,button,select")) return;
3302
- const M = C.closest("td[data-mr-row-index]"), O = M && Vt(M);
3303
- if (!O || e.busy() || !e.plan.value || !ct(e.plan.value, O)) return;
3304
- const N = n.value, K = y.shiftKey && N && Me(e.plan.value, N.anchor).grid === Me(e.plan.value, O, N.anchor).grid;
3305
- n.value = { anchor: K ? N.anchor : { ...O }, focus: { ...O } }, l(), M.focus({ preventScroll: !0 });
3306
- }
3307
- function w(y) {
3308
- const C = e.plan.value?.pages[y.pageIndex]?.components[y.componentIndex];
3309
- return C?.grid ? Nn(C.grid, C.widthMm, C.heightMm).cells.map((M) => ({ ...y, rowIndex: M.ri, columnIndex: M.ci })) : [];
3310
- }
3311
- function p(y, C, M) {
3312
- const O = w(y), N = M ? -1 : 1;
3313
- if (C === "Tab") return O[O.findIndex((B) => ei(B, y)) + N];
3314
- const K = C === "ArrowUp" || C === "ArrowDown" || C === "Enter", G = C === "ArrowUp" || C === "ArrowLeft" ? -1 : N;
3315
- return O.filter((B) => K ? B.columnIndex === y.columnIndex && (B.rowIndex - y.rowIndex) * G > 0 : B.rowIndex === y.rowIndex && (B.columnIndex - y.columnIndex) * G > 0).sort((B, $) => K ? (B.rowIndex - $.rowIndex) * G : (B.columnIndex - $.columnIndex) * G)[0];
3316
- }
3317
- function u(y, C, M) {
3318
- if (C === "ArrowLeft" || C === "ArrowRight") return;
3319
- const O = e.plan.value;
3320
- if (!O.pages[y.pageIndex]?.components[y.componentIndex]?.table) return;
3321
- const K = C === "ArrowUp" || M ? -1 : 1;
3322
- for (let G = y.pageIndex; G >= 0 && G < O.pages.length; G += K) {
3323
- const B = O.pages[G].components, $ = G === y.pageIndex ? y.componentIndex + K : K === 1 ? 0 : B.length - 1;
3324
- for (let P = $; P >= 0 && P < B.length; P += K) {
3325
- const q = i(y, { ...y, pageIndex: G, componentIndex: P }, C, K);
3326
- if (q) return q;
3327
- }
3328
- }
3329
- }
3330
- function i(y, C, M, O) {
3331
- const N = e.plan.value, K = N.pages[y.pageIndex].components[y.componentIndex].table, G = N.pages[C.pageIndex].components[C.componentIndex]?.table;
3332
- if (G?.id !== K.id || G.role === "header" && K.role !== "header" && (O > 0 || K.rowIndex + y.rowIndex > 0)) return;
3333
- const B = w(C), $ = M === "Tab" ? B : B.filter((P) => P.columnIndex === y.columnIndex);
3334
- return O === 1 ? $[0] : $[$.length - 1];
3335
- }
3336
- function k(y, C, M = !1, O = !1, N = !1) {
3337
- const K = p(y, C, M) ?? u(y, C, M);
3338
- return K ? (f(K, O), !0) : ((C !== "Tab" || !N) && f(y), !1);
3339
- }
3340
- function R(y) {
3341
- const C = n.value;
3342
- if (e.busy() || y.target instanceof Element && y.target.closest("textarea,input,select,button,a[href],[contenteditable]")) return !1;
3343
- if (!C) return z(y);
3344
- const M = y.key;
3345
- if (D(y) || A(y, C.focus)) return !0;
3346
- if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Enter"].includes(M)) return !1;
3347
- const O = k(C.focus, M, M === "Tab" && y.shiftKey, y.shiftKey && M !== "Tab", !0);
3348
- if (M === "Tab" && !O) {
3349
- const N = e.root.value?.ownerDocument.activeElement;
3350
- if (!(N instanceof HTMLElement) || !Yl(N, y.shiftKey)) return !1;
3351
- }
3352
- return y.preventDefault(), !0;
3353
- }
3354
- function D(y) {
3355
- if (!t() || !(y.ctrlKey || y.metaKey)) return !1;
3356
- const C = y.key.toLowerCase();
3357
- return C !== "z" && C !== "y" ? !1 : (y.preventDefault(), C === "y" || y.shiftKey ? e.redo() : e.undo(), !0);
3358
- }
3359
- function A(y, C) {
3360
- if (!t() || !e.plan.value || y.key !== "F2" && !(y.key === "Enter" && ct(e.plan.value, C)?.editable)) return !1;
3361
- const M = e.root.value?.querySelector(zt(C));
3362
- return M && (y.preventDefault(), e.edit(M)), !0;
3363
- }
3364
- function z(y) {
3365
- if (!["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft", "Enter"].includes(y.key)) return !1;
3366
- const C = e.root.value?.querySelector("td[data-mr-row-index]"), M = C && Vt(C);
3367
- return M ? (y.preventDefault(), f(M), !0) : !1;
3368
- }
3369
- function H() {
3370
- const y = n.value, C = e.plan.value;
3371
- if (!y || !C) return "";
3372
- const M = [], O = Me(C, y.anchor), N = Me(C, y.focus, y.anchor), K = Fn(C, y.anchor), G = Kt(C), B = Math.min(O.column, N.column), $ = Math.max(O.column, N.column);
3373
- if ((Math.abs(O.row - N.row) + 1) * ($ - B + 1) > 1e4)
3374
- return e.error(new ze("limit")), "";
3375
- for (let P = Math.min(O.row, N.row); P <= Math.max(O.row, N.row); P++) {
3376
- const q = [];
3377
- for (let T = B; T <= $; T++) {
3378
- const V = K(P, T);
3379
- q.push(V ? G(V)?.cell.text ?? "" : "");
3380
- }
3381
- M.push(q);
3382
- }
3383
- return Va(M);
3384
- }
3385
- function J(y) {
3386
- !n.value || y.target instanceof Element && y.target.closest("textarea,input,select") || (y.clipboardData?.setData("text/plain", H()), y.preventDefault());
3387
- }
3388
- async function Z(y) {
3389
- const C = n.value;
3390
- if (!C || !t() || e.busy()) return !1;
3391
- try {
3392
- let M;
3393
- try {
3394
- M = Ua(y);
3395
- } catch ($) {
3396
- throw new ze($ instanceof Error && $.message.includes("limit") ? "limit" : "clipboard");
3397
- }
3398
- const O = e.plan.value, N = Me(O, C.anchor), K = Me(O, C.focus, C.anchor), G = Fn(O, C.anchor), B = M.flatMap(($, P) => $.map((q, T) => {
3399
- const V = G(Math.min(N.row, K.row) + P, Math.min(N.column, K.column) + T);
3400
- if (!V) throw new ze("missing");
3401
- return { address: V, value: q };
3402
- }));
3403
- return await e.apply(B);
3404
- } catch (M) {
3405
- return e.error(M), !1;
3406
- }
3407
- }
3408
- function Y(y) {
3409
- if (!n.value || !t() || y.target instanceof Element && y.target.closest("textarea,input,select,button,a[href],[contenteditable]") || !y.clipboardData?.types.includes("text/plain")) return;
3410
- const C = y.clipboardData?.getData("text/plain");
3411
- C && (y.preventDefault(), Z(C));
3412
- }
3413
- async function te(y) {
3414
- const C = e.plan.value;
3415
- if (!C) return !1;
3416
- const M = Kt(C);
3417
- for (let O = 0; O < C.pages.length; O++) {
3418
- const N = C.pages[O];
3419
- for (let K = 0; K < N.components.length; K++)
3420
- for (const G of w({ pageIndex: O, componentIndex: K, rowIndex: 0, columnIndex: 0 })) {
3421
- const B = M(G);
3422
- if (Xl(B, y))
3423
- return f(G);
3424
- }
3425
- }
3426
- return !1;
3427
- }
3428
- function ne() {
3429
- n.value = null, l();
3430
- }
3431
- return { selection: n, refresh: l, reset: ne, focusCell: f, focusField: te, navigate: k, onClick: m, onKeydown: R, onCopy: J, onPaste: Y, copySelection: H, pasteSelection: Z };
3432
- }
3433
- function ri(e) {
3434
- let t = 0, n = !1;
3435
- function a() {
3436
- const o = e.viewport.value, r = e.root.value, l = e.plan.value;
3437
- if (!o || !r || !l) return;
3438
- const c = e.options(), v = Math.max(0, Math.min(20, Math.floor(c.frozenColumns ?? 0)));
3439
- if (!c.freezeHeaders && v === 0 && !n) return;
3440
- const h = e.zoom.value || 1, f = o.getBoundingClientRect();
3441
- r.querySelectorAll("[data-mr-component-index]").forEach((m) => {
3442
- const w = m.closest("[data-page]"), p = Number(w?.dataset.page) - 1, u = l.pages[p]?.components[Number(m.dataset.mrComponentIndex)];
3443
- if (!u?.grid || !w) return;
3444
- m.style.transform = "", m.style.zIndex = "";
3445
- const i = m.getBoundingClientRect(), k = w.getBoundingClientRect().bottom, R = Math.max(0, (f.left - i.left) / h), D = c.freezeHeaders ? Math.max(0, Math.min((f.top - i.top) / h, (k - i.bottom) / h)) : 0;
3446
- R > 0 && v > 0 && (m.style.zIndex = "1"), u.table?.role === "header" && D > 0 && (m.style.transform = `translateY(${D}px)`, m.style.zIndex = "5"), m.querySelectorAll(".mrp-cell-frozen").forEach((z) => {
3447
- z.style.transform = "", z.style.zIndex = "", z.classList.remove("mrp-cell-frozen");
3448
- });
3449
- const A = Array.from({ length: v }, (z, H) => `td[data-mr-column-index="${H}"]`);
3450
- !u.table && c.freezeHeaders && A.push('td[data-mr-row-index="0"]'), A.length && m.querySelectorAll(A.join(",")).forEach((z) => {
3451
- const H = Number(z.dataset.mrColumnIndex) < v, J = !u.table && Number(z.dataset.mrRowIndex) === 0 && !!c.freezeHeaders, Z = H ? R : 0, Y = J ? D : 0;
3452
- z.style.transform = Z || Y ? `translate(${Z}px, ${Y}px)` : "", z.classList.toggle("mrp-cell-frozen", !!(Z || Y)), z.style.zIndex = Z || Y ? J ? "7" : "6" : "";
3453
- });
3454
- }), n = !!c.freezeHeaders || v > 0;
3455
- }
3456
- function s() {
3457
- t || (t = requestAnimationFrame(() => {
3458
- t = 0, a();
3459
- }));
3460
- }
3461
- return Oe(() => {
3462
- t && cancelAnimationFrame(t);
3463
- }), { refresh: a, schedule: s };
3464
- }
3465
- async function Yn(e, t, n, a) {
3466
- if (!t?.assetRenderers || !Object.keys(t.assetRenderers).length) return e;
3467
- try {
3468
- return (await Ga(e, { ...t, signal: n, format: "dom", onDiagnostic: (o) => {
3469
- n.aborted || (t.onDiagnostic?.(o), a(o.message));
3470
- } })).plan;
3471
- } catch (s) {
3472
- throw n.aborted ? s : new ke("render", s instanceof Error ? s.message : "Report asset preparation failed", s);
3473
- }
3474
- }
3475
- function Xn(e, t) {
3476
- const n = Za(e);
3477
- if (!n.ok) throw new ke("validate", `渲染计划校验失败(${n.errors.length} 处): ${n.errors.slice(0, 3).map((a) => `${a.path}: ${a.message}`).join("; ")}`);
3478
- n.warnings.forEach((a) => t(`${a.path}: ${a.message}`));
3479
- }
3480
- async function li(e, t, n, a) {
3481
- const s = await Ge(e(t), t.signal);
3482
- return Ae(t.signal), a("validate"), Xn(s, t.onWarning ?? (() => {
3483
- })), Ae(t.signal), a("assets"), Yn(s, n, t.signal, t.onWarning ?? (() => {
3484
- }));
3485
- }
3486
- async function ii(e, t, n, a, s, o) {
3487
- const { importExcelTemplate: r } = await import("@agile-team/mach-report/xlsx");
3488
- Ae(a);
3489
- const l = await Ge(r(e, { ...t, signal: a }), a);
3490
- o("layout");
3491
- const c = Ja(Ce(l.template), {}).plan;
3492
- Xn(c, s), Ae(a), o("assets");
3493
- const v = await Yn(c, n, a, s);
3494
- return { result: l, plan: v };
3495
- }
3496
- const ui = {
3497
- key: 7,
3498
- class: "mrp-edit-hint",
3499
- role: "status"
3500
- }, ci = {
3501
- key: 9,
3502
- class: "mrp-export-notice mrp-export-warning",
3503
- role: "status"
3504
- }, di = { class: "mrp-main" }, fi = {
3505
- key: 0,
3506
- class: "mrp-state"
3507
- }, mi = {
3508
- key: 1,
3509
- class: "mrp-state mrp-error"
3510
- }, gi = ["data-page"], pi = ["aria-label", "aria-current", "onClick"], vi = ["data-thumb"], hi = { class: "mrp-thumb-no" }, bi = {
3511
- key: 10,
3512
- class: "mrp-footer"
3513
- }, yi = { class: "mrp-footer-context" }, wi = ["aria-label"], xi = { key: 0 }, ki = { class: "mrp-overlay" }, Ei = {
3514
- key: 11,
3515
- class: "mrp-debug",
3516
- "aria-hidden": "true"
3517
- }, Bt = 96 / 25.4, Nt = "mach-report:ui", jt = "mach-report:ui:wide", Ci = /* @__PURE__ */ be({
3518
- __name: "ReportPreview",
3519
- props: {
3520
- reportId: {
3521
- type: [String, Array],
3522
- default: null
3523
- },
3524
- params: {
3525
- type: Object,
3526
- default: () => ({})
3527
- },
3528
- height: { type: String, default: "100vh" },
3529
- autoLoad: { type: Boolean, default: !0 },
3530
- /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
3531
- showExport: { type: Boolean, default: void 0 },
3532
- showPrint: { type: Boolean, default: void 0 },
3533
- showPdfWindow: { type: Boolean, default: void 0 },
3534
- showSettings: { type: Boolean, default: void 0 },
3535
- toolbar: { type: Object, default: void 0 },
3536
- interaction: { type: Object, default: void 0 },
3537
- preferences: { type: Object, default: void 0 },
3538
- guardChanges: { type: Boolean, default: void 0 },
3539
- beforeDiscard: { type: Function, default: void 0 },
3540
- output: { type: Object, default: void 0 },
3541
- assets: { type: Object, default: void 0 },
3542
- /** 保留表头的零行业务结果;不改变计划和导出内容。 */
3543
- emptyState: { type: [Boolean, Object], default: !1 },
3544
- /** 页间距(px);不传走配置中心 */
3545
- gapPx: { type: Number, default: void 0 },
3546
- /** 工具栏/状态文案覆写(不传走配置中心 messages) */
3547
- messages: { type: Object, default: void 0 },
3548
- /** 启用的 preset 名(不传用配置中心 defaultPreset) */
3549
- preset: { type: String, default: void 0 },
3550
- /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
3551
- debug: { type: Boolean, default: !1 },
3552
- /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
3553
- paramDefs: {
3554
- type: Array,
3555
- default: void 0
3556
- },
3557
- /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
3558
- showParams: { type: Boolean, default: void 0 },
3559
- editable: { type: [Boolean, Object], default: void 0 },
3560
- excelImport: { type: [Boolean, Object], default: void 0 },
3561
- fetcher: {
3562
- type: Function,
3563
- default: null
3564
- }
3565
- },
3566
- emits: ["loaded", "task", "diagnostic", "error", "warning", "cell-edit", "template-import", "preferences-change"],
3567
- setup(e, { expose: t, emit: n }) {
3568
- const a = e, s = n, o = le(null), r = W(!1), l = W(""), c = le(null), v = W(null), h = W(!1), f = W(null), m = W(1), w = W(null), p = W(null), u = W(null), i = W(!1), k = W(!1), R = W(!1), D = W("general"), A = le(null), z = W(null), H = W(null), J = ws();
3569
- let Z = null, Y = !1;
3570
- const te = Cr((g) => s("task", g)), ne = $r((g) => s("diagnostic", g)), y = le(null), C = F(() => !!o.value?.pages.length && o.value.pages.every((g) => g.layout === "wide"));
3571
- let M = Nt;
3572
- const O = gt(es, null), N = gt(ts, null), K = F(() => jn(a.reportId)), G = F(() => a.fetcher ?? O), B = F(() => o.value?.pages.length ?? 0), $ = F(() => Object.freeze({
3573
- loading: r.value,
3574
- hasPlan: B.value > 0,
3575
- pageCount: B.value,
3576
- currentPage: m.value,
3577
- exporting: v.value,
3578
- printing: h.value,
3579
- canExport: !r.value && !k.value && !U.saving.value && B.value > 0 && v.value === null,
3580
- canPrint: !r.value && !k.value && !U.saving.value && B.value > 0 && !h.value,
3581
- error: c.value,
3582
- pdfFont: an.value,
3583
- editing: U.active.value !== null,
3584
- saving: U.saving.value,
3585
- importing: k.value,
3586
- dirty: U.differences.value.length > 0,
3587
- pendingLocalChanges: U.pendingLocalChanges.value,
3588
- task: te.state.value,
3589
- diagnostics: ne.entries.value,
3590
- reportIds: y.value?.reportIds ?? [],
3591
- params: y.value?.params ?? {},
3592
- canUndo: U.canUndo.value,
3593
- canRedo: U.canRedo.value,
3594
- changeCount: U.differences.value.length,
3595
- selection: ae.selection.value ? Ce(ae.selection.value) : null
3596
- }));
3597
- function P(g, S, L) {
3598
- c.value = Object.freeze({ message: g, code: S, cause: L }), s("error", g, { code: S, cause: L });
3599
- }
3600
- const {
3601
- resolved: q,
3602
- resolvedMessages: T,
3603
- effectiveShowExport: V,
3604
- effectiveShowSettings: Q,
3605
- effectiveGuardChanges: ie,
3606
- effectiveOutput: Ee,
3607
- effectiveInteraction: we,
3608
- effectiveAssets: st,
3609
- effectiveGapPx: _t,
3610
- effectiveShowParams: Qn,
3611
- availableTools: _n,
3612
- tools: en,
3613
- toolState: ge,
3614
- visibleExportFormats: ea,
3615
- effectiveEditable: Je,
3616
- effectiveExcelImport: ot,
3617
- persistedEditing: tn,
3618
- emptyStateContent: yt,
3619
- sessionInteraction: wt
3620
- } = Zl(a, C, (g) => s("warning", g)), nn = F(() => ge.value.pdf || ge.value.pdfWindow), xt = F(() => we.value.calculations === !0), kt = F(() => Rl(T.value)), { pdfFont: an, getPdfExporter: ta, checkPdfFont: na, retryPdfFont: sn, cancelFontCheck: aa } = xr({
3621
- plan: o,
3622
- fontUrl: () => q.value.pdfFontUrl,
3623
- enabled: () => nn.value,
3624
- injectedExporter: N,
3625
- destroyed: () => Y
3626
- });
3627
- async function sa(g, S) {
3628
- g === "editing" && !S && !await U.commit() || (en.setEnabled(g, S), s("preferences-change", Object.freeze({ ...ge.value })));
3629
- }
3630
- async function oa() {
3631
- await U.commit() && (en.reset(), wt.value = {}, s("preferences-change", Object.freeze({ ...ge.value })));
3632
- }
3633
- async function on(g = "general") {
3634
- if (R.value) {
3635
- R.value = !1;
3636
- return;
3637
- }
3638
- !await U.commit() || Y || !Q.value || (D.value = g, R.value = !0);
3639
- }
3640
- function rn(g) {
3641
- return g instanceof ze ? {
3642
- number: T.value.editInvalidNumber,
3643
- boolean: T.value.editInvalidBoolean,
3644
- conflict: T.value.editConflict,
3645
- atomic: T.value.editAtomicRequired,
3646
- limit: T.value.clipboardLimit,
3647
- readonly: T.value.editReadOnly,
3648
- missing: T.value.editMissing,
3649
- duplicate: T.value.editDuplicate,
3650
- clipboard: T.value.clipboardInvalid
3651
- }[g.code] ?? g.message : g instanceof Error ? g.message : "单元格保存失败";
3652
- }
3653
- const U = Gl({
3654
- plan: o,
3655
- options: Je,
3656
- blocked: () => r.value || k.value || v.value !== null || h.value || Pe.pending.value,
3657
- label: () => T.value.editCell ?? "编辑单元格",
3658
- errorMessage: rn,
3659
- suspendBlur: () => Pe.request.value !== null,
3660
- onChange: (g) => {
3661
- c.value = null, f.value = null, s("cell-edit", g);
3662
- },
3663
- onError: (g, S) => {
3664
- f.value = { kind: "error", message: g }, P(g, "edit", S);
3665
- },
3666
- onNavigate: (g, S, L) => ae.navigate(g, S, L)
3667
- }), ae = oi({
3668
- plan: o,
3669
- root: w,
3670
- enabled: () => !!Je.value || xt.value,
3671
- editable: () => !!Je.value,
3672
- busy: () => r.value || k.value || U.saving.value || !!v.value || h.value || Pe.pending.value,
3673
- differences: () => U.differences.value,
3674
- gotoPage: xe,
3675
- edit: U.editCell,
3676
- apply: U.apply,
3677
- undo: U.undo,
3678
- redo: U.redo,
3679
- error: (g) => {
3680
- const S = rn(g);
3681
- f.value = { kind: "error", message: S }, P(S, "edit", g);
3682
- }
3683
- }), Et = $o({ plan: o, selection: ae.selection, enabled: () => xt.value });
3684
- function ra() {
3685
- on("advanced");
3686
- }
3687
- const Pe = kr({
3688
- pending: () => U.pendingLocalChanges.value,
3689
- reportIds: () => y.value?.reportIds ?? K.value,
3690
- hook: () => a.beforeDiscard ?? q.value.beforeDiscard,
3691
- enabled: () => ie.value,
3692
- snapshot: () => [o.value, U.active.value?.editor.input.value],
3693
- error: (g) => P(g instanceof Error ? g.message : "修改保护回调失败", "config", g)
3694
- });
3695
- async function la(g = "leave") {
3696
- return Pe.check(g);
3697
- }
3698
- function ln(g) {
3699
- !ie.value || !U.pendingLocalChanges.value || (g.preventDefault(), g.returnValue = "");
3700
- }
3701
- function un() {
3702
- te.cancel();
3703
- }
3704
- async function cn(g) {
3705
- await ae.focusField(g) || (f.value = { kind: "warning", message: T.value.locateFieldMissing ?? "Field not found" });
3706
- }
3707
- function ia(g) {
3708
- if (g.pageIndex === void 0) return;
3709
- xe(g.pageIndex + 1);
3710
- const S = g.componentPath;
3711
- g.componentIndex !== void 0 && S && S.length === 2 && ae.focusCell({ pageIndex: g.pageIndex, componentIndex: g.componentIndex, rowIndex: S[0], columnIndex: S[1] });
3712
- }
3713
- function Ct(g) {
3714
- const S = o.value;
3715
- if (!S) return !1;
3716
- const L = { excel: "xlsx", image: "png", doc: "word" }[g] ?? g, ue = L === "pdf" ? "pdf" : L === "xlsx" ? "xlsx" : L === "png" ? "canvas" : "dom", _ = ne.inspect(S, ue);
3717
- return o.value !== S ? !1 : _.length && Ee.value.fidelity === "strict" ? (f.value = { kind: "error", message: T.value.diagnosticsStrict ?? "输出存在已知降级" }, P(f.value.message, "export", { diagnostics: _ }), !1) : !0;
3718
- }
3719
- function ua(g) {
3720
- return o.value ? ne.inspect(o.value, g) : [];
3721
- }
3722
- const rt = F(() => {
3723
- if (A.value) return A.value.sheets.map((S) => ({ label: S.name, pageIndex: S.pageStart }));
3724
- const g = /* @__PURE__ */ new Set();
3725
- return o.value?.pages.flatMap((S, L) => S.components.flatMap((ue) => {
3726
- const _ = ue.table;
3727
- return !_?.title || g.has(_.id) ? [] : (g.add(_.id), [{ label: _.title, pageIndex: L }]);
3728
- })) ?? [];
3729
- });
3730
- async function dn(g) {
3731
- g && !await ae.focusField({ field: g }) && (f.value = { kind: "warning", message: T.value.locateFieldMissing ?? "Field not found" });
3732
- }
3733
- const $t = F(() => {
3734
- try {
3735
- return { defs: a.paramDefs ?? G.value?.getParamDefs?.(K.value) ?? [], error: null };
3736
- } catch (g) {
3737
- return { defs: [], error: new ke("config", g instanceof Error ? g.message : "查询参数配置无效", g) };
3738
- }
3739
- }), It = F(() => $t.value.defs), Ze = Sr({ defs: It, reportIds: K, params: () => a.params, messages: () => T.value }), { values: Ye, attempted: lt, pendingRequired: fn } = Ze, mn = W(null);
3740
- function ca() {
3741
- lt.value = !0, Ze.validation.value.ok || Fe(() => mn.value?.focusInvalid()), Ne();
3742
- }
3743
- function da() {
3744
- Ze.reset(), l.value = "", c.value = null;
3745
- }
3746
- const fa = F(() => ({
3747
- height: a.height,
3748
- "--mrp-page-gap": `${Math.max(0, _t.value)}px`,
3749
- ...Ol(q.value.theme)
3750
- })), { zoom: ve, zoomMode: Xe, applyFitZoom: gn, setZoom: Qe } = os(() => ({
3751
- viewport: p.value,
3752
- pageWidthPx: Pt.contentSize.value.w || 210 * Bt
3753
- })), Pt = as(o, ve, {
3754
- pxPerMm: Bt,
3755
- gapPx: _t,
3756
- overscan: F(() => q.value.preview.overscanPages)
3757
- }), { contentSize: St, windowRange: _e, visiblePages: pn, makeScrollHandler: ma, refreshViewport: Rt } = Pt, ga = ma(m, B), Mt = ri({ root: w, viewport: p, plan: o, zoom: ve, options: () => we.value });
3758
- oe([we, ve], () => Mt.schedule(), { flush: "post" });
3759
- function Tt(g) {
3760
- Qe(g * 100);
3761
- }
3762
- function Be() {
3763
- k.value = !1, U.reset(), ae.reset(), A.value = null, hn(), o.value = null, y.value = null, ne.reset(), m.value = 1, se.reset();
3764
- }
3765
- let ce = 0, de = null;
3766
- function it(g, S) {
3767
- return g === ce && !S.signal.aborted && !Y;
3768
- }
3769
- function vn() {
3770
- p.value && (p.value.scrollTop = 0, p.value.scrollLeft = 0);
3771
- }
3772
- function pa(g, S) {
3773
- for (const L of g) {
3774
- if (S !== ce) return !1;
3775
- s("warning", L);
3776
- }
3777
- return S === ce;
3778
- }
3779
- function va() {
3780
- if ($t.value.error) {
3781
- const S = $t.value.error;
3782
- return Be(), l.value = S.message, P(S.message, S.code, S.cause), null;
3783
- }
3784
- const g = Ze.query();
3785
- return g.params ? g.params : (Be(), l.value = g.quiet ? "" : g.error.message, g.quiet || (lt.value = !0, P(g.error.message, g.error.code, g.error.cause)), null);
3786
- }
3787
- async function Ne() {
3788
- if (Y || ie.value && U.pendingLocalChanges.value && !await Pe.check("reload") || Y) return;
3789
- const g = ++ce;
3790
- k.value = !1, de?.abort(), de = null;
3791
- const S = G.value;
3792
- if (r.value = !1, c.value = null, K.value.length === 0) {
3793
- l.value = "缺少报表 ID", Be(), P(l.value, "param");
3794
- return;
3795
- }
3796
- if (!S) {
3797
- l.value = "未提供渲染数据源 fetcher", Be(), P(l.value, "config");
3798
- return;
3799
- }
3800
- const L = va();
3801
- if (!L) return;
3802
- r.value = !0, l.value = "", f.value = null, Be();
3803
- const ue = J.start(), _ = new AbortController();
3804
- de = _;
3805
- const Re = te.start("query", "query", () => {
3806
- de === _ && (_.abort(), ce++, de = null, r.value = !1);
3807
- }), ut = [...K.value], $e = Object.freeze({ ...L }), Te = /* @__PURE__ */ new Set();
3808
- function Ke(he) {
3809
- g !== ce || _.signal.aborted || Te.has(he) || (Te.add(he), q.value.logger.warn("[mach-report] 报表告警:", he), ne.add({ code: "layout", severity: "warning", message: he }), s("warning", he));
3810
- }
3811
- try {
3812
- const he = await li(S, {
3813
- reportIds: ut,
3814
- params: L,
3815
- taskId: Re.taskId,
3816
- onEvent: (qe) => {
3817
- g === ce && !_.signal.aborted && Re.update(qe.stage, qe.completed, qe.total);
3818
- },
3819
- onQueryResult: (qe, Sa) => {
3820
- g === ce && !_.signal.aborted && ne.addMany(Sa.diagnostics ?? []);
3821
- },
3822
- signal: _.signal,
3823
- onWarning: Ke
3824
- }, st.value, Re.update);
3825
- if (!it(g, _) || (o.value = he, y.value = Object.freeze({ reportIds: Object.freeze(ut), params: $e }), ne.inspect(he, "dom"), !it(g, _))) return;
3826
- Re.finish(), m.value = 1, J.end(ue), vn();
3827
- const We = C.value ? jt : Nt;
3828
- We !== M && (M = We, Ft()), Xe.value === "fit" && gn(), s("loaded", he.pages.length);
3829
- } catch (he) {
3830
- if (g !== ce) return;
3831
- if (_.signal.aborted) {
3832
- Re.finish("cancelled");
3833
- return;
3834
- }
3835
- Re.finish("failed");
3836
- const We = vr(he);
3837
- l.value = We.message;
3838
- const qe = pr(We);
3839
- P(We.message, qe.code, qe.cause);
3840
- } finally {
3841
- g === ce && (r.value = !1), de === _ && (de = null);
3842
- }
3843
- }
3844
- function xe(g) {
3845
- if (Y || B.value <= 0) return;
3846
- const S = Math.max(1, Math.min(B.value, g));
3847
- m.value = S;
3848
- const L = p.value;
3849
- L && (L.scrollTop = Pt.pageOffsetPx(S - 1) * ve.value, Rt(L), Ia.prioritize(S - 1));
3850
- }
3851
- const je = is(o, {
3852
- getPdfExporter: ta,
3853
- onTask: (g) => te.receive(g, () => je.cancel()),
3854
- onDiagnostic: ne.add,
3855
- getXlsxOptions: () => q.value.xlsx,
3856
- onError: (g, S) => {
3857
- f.value = { kind: "error", message: g }, P(g, S ?? "print");
3858
- },
3859
- onWarning: (g) => {
3860
- f.value = { kind: "warning", message: g }, ne.add({ code: "output", severity: "warning", message: g }), s("warning", g);
3861
- },
3862
- onBusy: (g) => {
3863
- v.value = g, g ? f.value = {
3864
- kind: "progress",
3865
- message: T.value.exporting.replace("{format}", g)
3866
- } : f.value?.kind === "progress" && (f.value = null);
3867
- },
3868
- onPrinting: (g) => {
3869
- h.value = g;
3870
- }
3871
- }), { releasePrintFrame: hn, dispose: ha } = je;
3872
- async function bn() {
3873
- r.value || k.value || U.active.value && !await U.commit() || (c.value = null, Ct("html") && await je.print());
3874
- }
3875
- async function yn(g) {
3876
- r.value || k.value || U.active.value && !await U.commit() || (c.value = null, Ct(g) && await je.exportAs(g));
3877
- }
3878
- function wn() {
3879
- if (r.value || k.value || U.active.value) {
3880
- f.value = { kind: "warning", message: T.value.editingHint ?? "请先确认单元格修改" };
3881
- return;
3882
- }
3883
- c.value = null, Ct("pdf") && je.openPdfWindow();
3884
- }
3885
- async function ba(g, S = {}) {
3886
- Y || (Ye.value = { ...Ye.value, ...g }, S.reload !== !1 && (lt.value = !0, await Ne()));
3887
- }
3888
- const xn = {
3889
- reload: Ne,
3890
- print: bn,
3891
- exportAs: yn,
3892
- openPdfWindow: wn,
3893
- gotoPage: xe,
3894
- setParams: ba,
3895
- checkPdfFont: na,
3896
- importExcel: kn,
3897
- getPlan: ya,
3898
- cancelTask: un,
3899
- confirmDiscard: la,
3900
- getOutputDiagnostics: ua,
3901
- getChanges: U.getChanges,
3902
- undo: U.undo,
3903
- redo: U.redo,
3904
- restoreChanges: U.restore,
3905
- getDifferences: () => Ce(U.differences.value),
3906
- getSelection: () => ae.selection.value ? Ce(ae.selection.value) : null,
3907
- focusCell: ae.focusCell,
3908
- focusField: ae.focusField,
3909
- copySelection: ae.copySelection,
3910
- pasteSelection: ae.pasteSelection,
3911
- get state() {
3912
- return $.value;
3913
- }
3914
- };
3915
- Ln(ns, xn);
3916
- function ya() {
3917
- return o.value ? Ce(o.value) : null;
3918
- }
3919
- function wa(g) {
3920
- const S = typeof ot.value == "object" ? ot.value : {};
3921
- return { ...S, ...g, limits: { ...S.limits, ...g?.limits } };
3922
- }
3923
- function xa(g, S) {
3924
- U.reset(), ae.reset(), hn(), se.reset(), o.value = g, y.value = null, ne.reset(), A.value = { sheets: Ce(S.sheets), warnings: [...S.warnings] }, m.value = 1, l.value = "", f.value = S.warnings.length ? { kind: "warning", message: S.warnings.join(";") } : null, vn(), M = C.value ? jt : Nt, Ft(), ne.addMany(S.warnings.map((L) => ({ code: "excel-import", severity: "warning", message: L }))), o.value === g && ne.inspect(g, "dom");
3925
- }
3926
- async function kn(g, S) {
3927
- if (Y) throw new ke("config", "报表预览已卸载");
3928
- if (ie.value && U.pendingLocalChanges.value && !await Pe.check("import") || Y) return null;
3929
- const L = ++ce;
3930
- de?.abort(), de = null, r.value = !1, U.cancel(), je.invalidatePending(), k.value = !0;
3931
- const ue = new AbortController();
3932
- de = ue, c.value = null, f.value = { kind: "progress", message: T.value.importing ?? "正在导入 Excel…" };
3933
- const _ = te.start("import", "import", () => {
3934
- de === ue && (ue.abort(), ce++, de = null, k.value = !1, f.value = null);
3935
- }), Re = wa(S), ut = Xa(Re.signal, ue);
3936
- try {
3937
- const { result: $e, plan: Te } = await ii(g, {
3938
- ...Re,
3939
- onProgress: (Ke, he) => {
3940
- _.update("import", Ke, he), Re.onProgress?.(Ke, he);
3941
- }
3942
- }, st.value, ue.signal, (Ke) => {
3943
- L === ce && s("warning", Ke);
3944
- }, _.update);
3945
- return !it(L, ue) || !pa($e.warnings, L) || (xa(Te, $e), !it(L, ue)) ? null : (_.finish(), s("template-import", $e), L === ce && s("loaded", Te.pages.length), $e);
3946
- } catch ($e) {
3947
- if (L !== ce) return null;
3948
- if (ue.signal.aborted)
3949
- return _.finish("cancelled"), null;
3950
- _.finish("failed");
3951
- const Te = new ke("import", $e instanceof Error ? $e.message : "Excel 模板导入失败", $e);
3952
- throw f.value = { kind: "error", message: Te.message }, P(Te.message, "import", $e), Te;
3953
- } finally {
3954
- ut(), L === ce && (k.value = !1), de === ue && (de = null);
3955
- }
3956
- }
3957
- function ka(g) {
3958
- const S = g.target, L = S.files?.[0];
3959
- S.value = "", L && kn(L).catch(() => {
3960
- });
3961
- }
3962
- const se = hs({
3963
- plan: o,
3964
- gotoPage: xe,
3965
- debounceMs: F(() => q.value.preview.searchDebounceMs),
3966
- highlight: cs,
3967
- clearHighlights: us
3968
- });
3969
- oe(() => ge.value.search, (g) => {
3970
- g || (se.reset(), se.visible.value = !1);
3971
- });
3972
- function Ea(g) {
3973
- !g.ctrlKey || !ge.value.zoom || (g.preventDefault(), Tt(ve.value * (g.deltaY < 0 ? 1.1 : 1 / 1.1)));
3974
- }
3975
- function Ca(g) {
3976
- if (!ae.onKeydown(g) && !(g.target instanceof Element && g.target.closest("input,textarea,select,[contenteditable='true']"))) {
3977
- if (ge.value.search && (g.ctrlKey || g.metaKey) && g.key.toLowerCase() === "f") {
3978
- g.preventDefault(), se.visible.value || se.toggle(), Fe(() => H.value?.focusSearch());
3979
- return;
3980
- }
3981
- switch (g.key) {
3982
- case "PageDown":
3983
- g.preventDefault(), xe(m.value + 1);
3984
- break;
3985
- case "PageUp":
3986
- g.preventDefault(), xe(m.value - 1);
3987
- break;
3988
- case "Home":
3989
- g.preventDefault(), xe(1);
3990
- break;
3991
- case "End":
3992
- g.preventDefault(), xe(B.value);
3993
- break;
3994
- case "+":
3995
- case "=":
3996
- g.preventDefault(), ge.value.zoom && Tt(ve.value * 1.1);
3997
- break;
3998
- case "-":
3999
- g.preventDefault(), ge.value.zoom && Tt(ve.value / 1.1);
4000
- break;
4001
- }
4002
- }
4003
- }
4004
- function $a() {
4005
- try {
4006
- localStorage.setItem(
4007
- M,
4008
- JSON.stringify({ zoomMode: Xe.value === "fit" ? "fit" : Math.round(ve.value * 100) })
4009
- );
4010
- } catch {
4011
- }
4012
- }
4013
- oe([Xe, ve], $a);
4014
- let Dt = "";
4015
- function En(g = !1) {
4016
- const S = se.activeMatch.value;
4017
- if (!C.value || !S) return;
4018
- const L = `${se.query.value}:${se.matchIndex.value}:${S.pageIndex}`;
4019
- if (!g && L === Dt) return;
4020
- const _ = w.value?.querySelector(`[data-page="${S.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[S.occurrence];
4021
- _ && (_.scrollIntoView?.({ block: "nearest", inline: "nearest" }), Dt = L);
4022
- }
4023
- const Ia = ss({
4024
- plan: o,
4025
- root: w,
4026
- pages: () => pn.value,
4027
- priority: () => se.activeMatch.value?.pageIndex ?? m.value - 1,
4028
- focusToken: () => se.activeMatch.value,
4029
- query: () => se.query.value,
4030
- zoom: () => ve.value,
4031
- loading: () => T.value.loading,
4032
- clear: se.clear,
4033
- highlight: se.apply,
4034
- mounted: (g) => {
4035
- ae.refresh(g), Mt.schedule();
4036
- },
4037
- ready: () => {
4038
- se.activeMatch.value || (Dt = ""), En();
4039
- },
4040
- error: (g) => {
4041
- l.value = g instanceof Error ? g.message : String(g), P(l.value, "render", g);
4042
- }
4043
- });
4044
- oe(() => ae.selection.value, () => {
4045
- ae.refresh();
4046
- }, { flush: "post" }), oe(() => se.query.value, (g) => {
4047
- g || w.value?.querySelectorAll(".mrp-page-holder").forEach((S) => {
4048
- se.clear(S);
4049
- });
4050
- });
4051
- const Se = ys(o, {
4052
- thumbsRoot: u,
4053
- visible: i,
4054
- renderThumbCanvas: (g) => {
4055
- try {
4056
- const S = o.value.pages[g], L = Math.min(0.2, 116 / Math.max(1, S.pageWidthMm * Bt)), { canvases: ue } = Ya(o.value, { start: g, end: g, dpr: L });
4057
- return ue[0] ?? null;
4058
- } catch {
4059
- return null;
4060
- }
4061
- }
4062
- });
4063
- Da(() => {
4064
- Se.schedule();
4065
- }, { flush: "post" });
4066
- const Pa = F(() => a.debug), { debugStats: He } = bs(Pa, {
4067
- plan: o,
4068
- pageCount: B,
4069
- windowRange: _e,
4070
- zoom: ve,
4071
- loadMs: J.loadMs
4072
- });
4073
- function At() {
4074
- Rt(p.value), Se.schedule(), Xe.value === "fit" && gn(), En(!0);
4075
- }
4076
- function Ft() {
4077
- Qe(M === jt ? 100 : "fit");
4078
- try {
4079
- const g = JSON.parse(localStorage.getItem(M) ?? "{}");
4080
- g.zoomMode === "fit" ? Qe("fit") : typeof g.zoomMode == "number" && Qe(g.zoomMode);
4081
- } catch {
4082
- }
4083
- }
4084
- return bt(() => {
4085
- window.addEventListener("resize", At), window.addEventListener("beforeunload", ln), typeof ResizeObserver < "u" && p.value && (Z = new ResizeObserver(At), Z.observe(p.value)), Rt(p.value), Ft(), a.autoLoad && Ne();
4086
- }), Qt(() => {
4087
- Y = !0, Pe.cancel(), te.cancel(), U.reset(), k.value = !1, aa(), ce++, de?.abort(), de = null, window.removeEventListener("resize", At), window.removeEventListener("beforeunload", ln), Z?.disconnect(), Z = null, Se.destroy(), se.reset(), ha();
4088
- }), oe(
4089
- () => [JSON.stringify(K.value), JSON.stringify(a.params), G.value],
4090
- async () => {
4091
- if (a.autoLoad) {
4092
- Ne();
4093
- return;
4094
- }
4095
- !await Pe.check("replace") || Y || (ce++, de?.abort(), de = null, r.value = !1, l.value = "", c.value = null, f.value = null, Be());
4096
- }
4097
- ), t({ ...xn, state: $ }), (g, S) => (E(), I("div", {
4098
- class: pe(["mach-report-preview", { "mrp-wide-report": C.value }]),
4099
- style: De(fa.value)
4100
- }, [
4101
- d(Qn) && It.value.length > 0 ? (E(), Ie(Nr, {
4102
- key: 0,
4103
- ref_key: "paramPanelRef",
4104
- ref: mn,
4105
- defs: It.value,
4106
- modelValue: d(Ye),
4107
- "onUpdate:modelValue": S[0] || (S[0] = (L) => On(Ye) ? Ye.value = L : null),
4108
- messages: d(T),
4109
- attempted: d(lt),
4110
- issues: d(Ze).validation.value.issues,
4111
- onQuery: ca,
4112
- onReset: da
4113
- }, null, 8, ["defs", "modelValue", "messages", "attempted", "issues"])) : j("", !0),
4114
- X(ro, {
4115
- ref_key: "toolbarRef",
4116
- ref: H,
4117
- "page-count": B.value,
4118
- "current-page": m.value,
4119
- "zoom-mode": d(Xe),
4120
- zoom: d(ve),
4121
- "show-export": d(V),
4122
- "show-print": d(ge).print,
4123
- "show-pdf-window": d(ge).pdfWindow,
4124
- "show-search": d(ge).search,
4125
- "show-thumbnails": d(ge).thumbnails,
4126
- "show-zoom": d(ge).zoom,
4127
- "export-formats": d(ea),
4128
- "show-settings": d(Q),
4129
- "settings-open": R.value,
4130
- messages: d(T),
4131
- search: { visible: d(se).visible.value, query: d(se).query.value, matchIndex: d(se).matchIndex.value, matchCount: d(se).matchCount.value, searching: d(se).searching.value },
4132
- "thumbs-visible": i.value,
4133
- "show-import": !!d(ot),
4134
- busy: r.value || k.value || d(U).saving.value,
4135
- onGoto: xe,
4136
- onZoom: d(Qe),
4137
- onExport: S[1] || (S[1] = (L) => yn(L)),
4138
- onPrint: bn,
4139
- onPdfWindow: wn,
4140
- onSearchInput: d(se).onInput,
4141
- onSearchNav: d(se).onNav,
4142
- onSearchToggle: d(se).toggle,
4143
- onThumbsToggle: S[2] || (S[2] = (L) => i.value = !i.value),
4144
- onImportExcel: S[3] || (S[3] = (L) => z.value?.click()),
4145
- onSettingsToggle: on
4146
- }, Aa({ _: 2 }, [
4147
- rt.value.length <= 1 ? {
4148
- name: "navigation",
4149
- fn: Ot(() => [
4150
- B.value > 0 && d(we).navigation !== !1 ? (E(), Ie(Tn, {
4151
- key: 0,
4152
- plan: o.value,
4153
- compact: "",
4154
- sections: rt.value,
4155
- "current-page": m.value,
4156
- messages: d(T),
4157
- busy: r.value || k.value || d(U).saving.value,
4158
- onLocateTarget: cn,
4159
- onGoto: xe,
4160
- onLocate: dn
4161
- }, null, 8, ["plan", "sections", "current-page", "messages", "busy"])) : j("", !0)
4162
- ]),
4163
- key: "0"
4164
- } : void 0
4165
- ]), 1032, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "show-search", "show-thumbnails", "show-zoom", "export-formats", "show-settings", "settings-open", "messages", "search", "thumbs-visible", "show-import", "busy", "onZoom", "onSearchInput", "onSearchNav", "onSearchToggle"]),
4166
- d(Pe).request.value ? (E(), Ie(nr, {
4167
- key: 1,
4168
- messages: d(T),
4169
- onAnswer: d(Pe).settle
4170
- }, null, 8, ["messages", "onAnswer"])) : j("", !0),
4171
- X(lr, {
4172
- task: d(te).state.value,
4173
- messages: d(T),
4174
- onCancel: un
4175
- }, null, 8, ["task", "messages"]),
4176
- X(gr, {
4177
- entries: d(ne).entries.value,
4178
- messages: d(T),
4179
- onLocate: ia
4180
- }, null, 8, ["entries", "messages"]),
4181
- R.value && d(Q) ? (E(), Ie(Yo, {
4182
- key: 2,
4183
- available: d(_n),
4184
- enabled: d(ge),
4185
- messages: d(T),
4186
- "persisted-editing": d(tn),
4187
- interaction: d(we),
4188
- section: D.value,
4189
- busy: r.value || k.value || d(U).saving.value || !!v.value || h.value,
4190
- onSection: S[4] || (S[4] = (L) => D.value = L),
4191
- onInteraction: S[5] || (S[5] = (L) => wt.value = { ...d(wt), ...L }),
4192
- onChange: sa,
4193
- onReset: oa,
4194
- onClose: S[6] || (S[6] = (L) => R.value = !1)
4195
- }, {
4196
- advanced: Ot(() => [
4197
- X(Co, {
4198
- state: d(Et),
4199
- messages: kt.value
4200
- }, null, 8, ["state", "messages"])
4201
- ]),
4202
- default: Ot(() => [
4203
- at(g.$slots, "settings", {}, void 0, !0)
4204
- ]),
4205
- _: 3
4206
- }, 8, ["available", "enabled", "messages", "persisted-editing", "interaction", "section", "busy"])) : j("", !0),
4207
- rt.value.length > 1 && B.value > 0 && d(we).navigation !== !1 ? (E(), Ie(Tn, {
4208
- key: 3,
4209
- plan: o.value,
4210
- onLocateTarget: cn,
4211
- sections: rt.value,
4212
- "current-page": m.value,
4213
- messages: d(T),
4214
- busy: r.value || k.value || d(U).saving.value,
4215
- onGoto: xe,
4216
- onLocate: dn
4217
- }, null, 8, ["plan", "sections", "current-page", "messages", "busy"])) : j("", !0),
4218
- A.value ? (E(), Ie(Sl, {
4219
- key: 4,
4220
- result: A.value,
4221
- messages: d(T)
4222
- }, null, 8, ["result", "messages"])) : j("", !0),
4223
- d(Je) && B.value > 0 ? (E(), Ie(nl, {
4224
- key: 5,
4225
- differences: d(U).differences.value,
4226
- conflicts: d(U).conflicts.value,
4227
- messages: d(T),
4228
- saving: d(U).saving.value,
4229
- "can-undo": d(U).canUndo.value,
4230
- "can-redo": d(U).canRedo.value,
4231
- persisted: d(tn),
4232
- busy: !!v.value || h.value,
4233
- onUndo: d(U).undo,
4234
- onRedo: d(U).redo,
4235
- onRestore: d(U).restore,
4236
- onLocate: S[7] || (S[7] = (L) => d(ae).focusCell(L.address))
4237
- }, null, 8, ["differences", "conflicts", "messages", "saving", "can-undo", "can-redo", "persisted", "busy", "onUndo", "onRedo", "onRestore"])) : j("", !0),
4238
- d(ot) ? (E(), I("input", {
4239
- key: 6,
4240
- ref_key: "importInputRef",
4241
- ref: z,
4242
- class: "mrp-import-input",
4243
- type: "file",
4244
- accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4245
- hidden: "",
4246
- onChange: ka
4247
- }, null, 544)) : j("", !0),
4248
- d(Je) && B.value > 0 ? (E(), I("div", ui, x(d(U).saving.value ? d(T).saving : d(T).editingHint), 1)) : j("", !0),
4249
- f.value ? (E(), I("div", {
4250
- key: 8,
4251
- class: pe(["mrp-export-notice", `mrp-export-${f.value.kind}`]),
4252
- role: "alert"
4253
- }, x(f.value.message), 3)) : j("", !0),
4254
- d(an).status === "error" && nn.value ? (E(), I("div", ci, [
4255
- re(x(d(T).pdfFontUnavailable) + " ", 1),
4256
- b("button", {
4257
- type: "button",
4258
- onClick: S[8] || (S[8] = //@ts-ignore
4259
- (...L) => d(sn) && d(sn)(...L))
4260
- }, x(d(T).retry), 1)
4261
- ])) : j("", !0),
4262
- b("div", di, [
4263
- b("div", {
4264
- ref_key: "viewportRef",
4265
- ref: p,
4266
- class: "mrp-body",
4267
- tabindex: "0",
4268
- onWheel: Ea,
4269
- onKeydown: Ca,
4270
- onDblclick: S[9] || (S[9] = //@ts-ignore
4271
- (...L) => d(U).onDoubleClick && d(U).onDoubleClick(...L)),
4272
- onClick: S[10] || (S[10] = //@ts-ignore
4273
- (...L) => d(ae).onClick && d(ae).onClick(...L)),
4274
- onCopy: S[11] || (S[11] = //@ts-ignore
4275
- (...L) => d(ae).onCopy && d(ae).onCopy(...L)),
4276
- onPaste: S[12] || (S[12] = //@ts-ignore
4277
- (...L) => d(ae).onPaste && d(ae).onPaste(...L)),
4278
- onScrollPassive: S[13] || (S[13] = (L) => {
4279
- d(ga)(L.target), d(Mt).schedule();
4280
- })
4281
- }, [
4282
- r.value ? (E(), I("div", fi, x(d(T).loading), 1)) : l.value ? (E(), I("div", mi, [
4283
- re(x(l.value) + " ", 1),
4284
- b("button", {
4285
- class: "mrp-retry",
4286
- type: "button",
4287
- onClick: Ne
4288
- }, x(d(T).retry), 1)
4289
- ])) : !o.value || B.value === 0 ? (E(), Ie(Rn, {
4290
- key: 2,
4291
- title: d(fn) ? d(T).paramPrompt ?? d(T).paramsTitle : d(T).empty,
4292
- description: d(fn) ? d(T).paramPromptDescription : d(yt).description ?? d(T).emptyDescription
4293
- }, null, 8, ["title", "description"])) : (E(), I("div", {
4294
- key: 3,
4295
- class: "mrp-scale",
4296
- style: De({ width: `${d(St).w * d(ve)}px`, height: `${d(St).h * d(ve)}px` })
4297
- }, [
4298
- b("div", {
4299
- ref_key: "containerRef",
4300
- ref: w,
4301
- class: "mrp-scale-inner",
4302
- style: De({ transform: `scale(${d(ve)})`, transformOrigin: "top left", width: `${d(St).w}px` })
4303
- }, [
4304
- d(_e).padTopPx > 0 ? (E(), I("div", {
4305
- key: 0,
4306
- class: "mrp-spacer-top",
4307
- style: De({ height: `${d(_e).padTopPx}px` }),
4308
- "aria-hidden": "true"
4309
- }, null, 4)) : j("", !0),
4310
- (E(!0), I(fe, null, me(d(pn), (L) => (E(), I("div", {
4311
- key: L.index,
4312
- class: "mrp-page-holder",
4313
- "data-page": L.index + 1
4314
- }, null, 8, gi))), 128)),
4315
- d(_e).padBottomPx > 0 ? (E(), I("div", {
4316
- key: 1,
4317
- class: "mrp-spacer-bottom",
4318
- style: De({ height: `${d(_e).padBottomPx}px` }),
4319
- "aria-hidden": "true"
4320
- }, null, 4)) : j("", !0)
4321
- ], 4)
4322
- ], 4)),
4323
- !r.value && !l.value && o.value && B.value > 0 && e.emptyState ? (E(), Ie(Rn, {
4324
- key: 4,
4325
- title: d(yt).title ?? d(T).empty,
4326
- description: d(yt).description ?? d(T).emptyDescription
4327
- }, null, 8, ["title", "description"])) : j("", !0)
4328
- ], 544),
4329
- d(ge).thumbnails && i.value && B.value > 0 ? (E(), I("aside", {
4330
- key: 0,
4331
- ref_key: "thumbsRef",
4332
- ref: u,
4333
- class: "mrp-thumbs",
4334
- onScrollPassive: S[14] || (S[14] = //@ts-ignore
4335
- (...L) => d(Se).onScroll && d(Se).onScroll(...L))
4336
- }, [
4337
- d(Se).windowRange.value.padTopPx > 0 ? (E(), I("div", {
4338
- key: 0,
4339
- class: "mrp-thumb-spacer",
4340
- style: De({ height: `${d(Se).windowRange.value.padTopPx}px` }),
4341
- "aria-hidden": "true"
4342
- }, null, 4)) : j("", !0),
4343
- (E(!0), I(fe, null, me(d(Se).visibleThumbs.value, (L) => (E(), I("button", {
4344
- key: L.index,
4345
- class: pe(["mrp-thumb", { "mrp-thumb-active": L.index + 1 === m.value }]),
4346
- type: "button",
4347
- "aria-label": `${d(T).thumbnails} · ${d(T).pageInfo.replace("{cur}", String(L.index + 1)).replace("{total}", String(B.value))}`,
4348
- "aria-current": L.index + 1 === m.value ? "page" : void 0,
4349
- style: De({ height: `${L.height + 20}px` }),
4350
- onClick: (ue) => xe(L.index + 1)
4351
- }, [
4352
- b("span", {
4353
- class: "mrp-thumb-box",
4354
- "data-thumb": L.index + 1,
4355
- style: De({ height: `${L.height}px` })
4356
- }, null, 12, vi),
4357
- b("span", hi, x(L.index + 1), 1)
4358
- ], 14, pi))), 128)),
4359
- d(Se).windowRange.value.padBottomPx > 0 ? (E(), I("div", {
4360
- key: 1,
4361
- class: "mrp-thumb-spacer",
4362
- style: De({ height: `${d(Se).windowRange.value.padBottomPx}px` }),
4363
- "aria-hidden": "true"
4364
- }, null, 4)) : j("", !0)
4365
- ], 544)) : j("", !0)
4366
- ]),
4367
- B.value > 0 ? (E(), I("footer", bi, [
4368
- b("div", yi, [
4369
- xt.value && d(Q) ? (E(), I("button", {
4370
- key: 0,
4371
- class: "mrp-calculation-toggle",
4372
- type: "button",
4373
- "aria-label": kt.value.calculationTitle,
4374
- onClick: ra
4375
- }, [
4376
- S[15] || (S[15] = b("span", { "aria-hidden": "true" }, "∑", -1)),
4377
- re(x(kt.value.calculationTitle), 1),
4378
- d(Et).result.value ? (E(), I("strong", xi, x(d(Et).result.value.formatted), 1)) : j("", !0)
4379
- ], 8, wi)) : j("", !0)
4380
- ]),
4381
- X(Un, {
4382
- "page-count": B.value,
4383
- "current-page": m.value,
4384
- messages: d(T),
4385
- busy: r.value || k.value || d(U).saving.value,
4386
- onGoto: xe
4387
- }, null, 8, ["page-count", "current-page", "messages", "busy"])
4388
- ])) : j("", !0),
4389
- b("div", ki, [
4390
- at(g.$slots, "default", {}, void 0, !0)
4391
- ]),
4392
- d(He) ? (E(), I("div", Ei, [
4393
- S[16] || (S[16] = b("div", null, "mach-report debug", -1)),
4394
- b("div", null, "pages: " + x(d(He).pages) + " | window: [" + x(d(He).window) + "]", 1),
4395
- b("div", null, "zoom: " + x(d(He).zoom) + " | load: " + x(d(He).loadMs), 1),
4396
- b("div", null, "plan: " + x(d(He).planKB) + "KB", 1)
4397
- ])) : j("", !0)
4398
- ], 6));
4399
- }
4400
- }), $i = /* @__PURE__ */ ye(Ci, [["__scopeId", "data-v-7b74ffd9"]]), Hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4401
- __proto__: null,
4402
- default: $i
4403
- }, Symbol.toStringTag, { value: "Module" }));
4404
- export {
4405
- is as A,
4406
- os as B,
4407
- Hi as C,
4408
- Gn as D,
4409
- ke as M,
4410
- Lt as P,
4411
- Gt as R,
4412
- Bi as S,
4413
- Ml as a,
4414
- Tl as b,
4415
- Ce as c,
4416
- An as d,
4417
- Un as e,
4418
- Nr as f,
4419
- $i as g,
4420
- ro as h,
4421
- ls as i,
4422
- zi as j,
4423
- wr as k,
4424
- Oi as l,
4425
- ji as m,
4426
- Dl as n,
4427
- qi as o,
4428
- Fi as p,
4429
- jn as q,
4430
- vr as r,
4431
- Li as s,
4432
- Ni as t,
4433
- Rl as u,
4434
- Fl as v,
4435
- Ol as w,
4436
- pr as x,
4437
- Ll as y,
4438
- as as z
4439
- };