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