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