@eternalheart/react-file-preview 1.3.13 → 1.4.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 (107) hide show
  1. package/lib/FilePreviewContent.d.ts +3 -17
  2. package/lib/FilePreviewContent.d.ts.map +1 -1
  3. package/lib/FilePreviewEmbed.d.ts +2 -0
  4. package/lib/FilePreviewEmbed.d.ts.map +1 -1
  5. package/lib/chunks/RendererError-D5i8eSpN.mjs +15 -0
  6. package/lib/chunks/RendererError-D5i8eSpN.mjs.map +1 -0
  7. package/lib/chunks/{index-CIqtwqgy.mjs → index-0v5STX5f.mjs} +18 -18
  8. package/lib/chunks/index-0v5STX5f.mjs.map +1 -0
  9. package/lib/chunks/{index-p4mew8Hx.mjs → index-10O8tfTH.mjs} +7 -7
  10. package/lib/chunks/index-10O8tfTH.mjs.map +1 -0
  11. package/lib/chunks/{index-CRn7LdHD.mjs → index-BCyv1HM9.mjs} +6 -6
  12. package/lib/chunks/index-BCyv1HM9.mjs.map +1 -0
  13. package/lib/chunks/{index-B2IlXQPc.mjs → index-Bo90aGhy.mjs} +3 -3
  14. package/lib/chunks/{index-B2IlXQPc.mjs.map → index-Bo90aGhy.mjs.map} +1 -1
  15. package/lib/chunks/index-CEeKt7L3.mjs +2808 -0
  16. package/lib/chunks/index-CEeKt7L3.mjs.map +1 -0
  17. package/lib/chunks/{index-DtZwBUd0.mjs → index-CWKbnvW6.mjs} +3 -3
  18. package/lib/chunks/{index-DtZwBUd0.mjs.map → index-CWKbnvW6.mjs.map} +1 -1
  19. package/lib/chunks/{index-B0QA380T.mjs → index-C_BJatqr.mjs} +14 -14
  20. package/lib/chunks/index-C_BJatqr.mjs.map +1 -0
  21. package/lib/chunks/index-Cbz5Z6ZK.mjs +263 -0
  22. package/lib/chunks/index-Cbz5Z6ZK.mjs.map +1 -0
  23. package/lib/chunks/{index-DYNPnFww.mjs → index-Cp68OevR.mjs} +3 -3
  24. package/lib/chunks/{index-DYNPnFww.mjs.map → index-Cp68OevR.mjs.map} +1 -1
  25. package/lib/chunks/{index-_EpQHlUY.mjs → index-CzM2mxrD.mjs} +4 -4
  26. package/lib/chunks/{index-_EpQHlUY.mjs.map → index-CzM2mxrD.mjs.map} +1 -1
  27. package/lib/chunks/{index-DfkP0zX3.mjs → index-DTYBFuAH.mjs} +4 -4
  28. package/lib/chunks/{index-DfkP0zX3.mjs.map → index-DTYBFuAH.mjs.map} +1 -1
  29. package/lib/chunks/{index-DqXfw2eb.mjs → index-DaAXRBWL.mjs} +3 -3
  30. package/lib/chunks/{index-DqXfw2eb.mjs.map → index-DaAXRBWL.mjs.map} +1 -1
  31. package/lib/chunks/{index-BgMhDDkd.mjs → index-DoFsoBKL.mjs} +3 -3
  32. package/lib/chunks/{index-BgMhDDkd.mjs.map → index-DoFsoBKL.mjs.map} +1 -1
  33. package/lib/chunks/{index-sft0uUd7.mjs → index-DuP0Tlpo.mjs} +3 -3
  34. package/lib/chunks/{index-sft0uUd7.mjs.map → index-DuP0Tlpo.mjs.map} +1 -1
  35. package/lib/chunks/index-Dv3RQz86.mjs +270 -0
  36. package/lib/chunks/index-Dv3RQz86.mjs.map +1 -0
  37. package/lib/chunks/{index-8pqs-pW7.mjs → index-QfpHck8N.mjs} +5 -5
  38. package/lib/chunks/{index-8pqs-pW7.mjs.map → index-QfpHck8N.mjs.map} +1 -1
  39. package/lib/chunks/{index-DN4Lc1dx.mjs → index-gjSQeou7.mjs} +3 -3
  40. package/lib/chunks/{index-DN4Lc1dx.mjs.map → index-gjSQeou7.mjs.map} +1 -1
  41. package/lib/chunks/{index-DZxzCMp2.mjs → index-kALp0tqz.mjs} +3 -3
  42. package/lib/chunks/{index-DZxzCMp2.mjs.map → index-kALp0tqz.mjs.map} +1 -1
  43. package/lib/chunks/{index-C8r2-Evl.mjs → index-kCeSnFs-.mjs} +9 -9
  44. package/lib/chunks/{index-C8r2-Evl.mjs.map → index-kCeSnFs-.mjs.map} +1 -1
  45. package/lib/chunks/{useShikiHighlight-CDDi36pF.mjs → useShikiHighlight-BA9qgdGA.mjs} +2 -2
  46. package/lib/chunks/{useShikiHighlight-CDDi36pF.mjs.map → useShikiHighlight-BA9qgdGA.mjs.map} +1 -1
  47. package/lib/components/preview/FilePreviewRenderer.d.ts +18 -0
  48. package/lib/components/preview/FilePreviewRenderer.d.ts.map +1 -0
  49. package/lib/components/preview/FilePreviewToolbar.d.ts +19 -0
  50. package/lib/components/preview/FilePreviewToolbar.d.ts.map +1 -0
  51. package/lib/components/preview/NavArrows.d.ts +18 -0
  52. package/lib/components/preview/NavArrows.d.ts.map +1 -0
  53. package/lib/components/preview/RendererError.d.ts +15 -0
  54. package/lib/components/preview/RendererError.d.ts.map +1 -0
  55. package/lib/components/preview/RendererErrorBoundary.d.ts +23 -0
  56. package/lib/components/preview/RendererErrorBoundary.d.ts.map +1 -0
  57. package/lib/components/preview/ToolbarButton.d.ts +14 -0
  58. package/lib/components/preview/ToolbarButton.d.ts.map +1 -0
  59. package/lib/components/preview/index.d.ts +7 -0
  60. package/lib/components/preview/index.d.ts.map +1 -0
  61. package/lib/hooks/index.d.ts +9 -0
  62. package/lib/hooks/index.d.ts.map +1 -0
  63. package/lib/hooks/rendererReducer.d.ts +10 -0
  64. package/lib/hooks/rendererReducer.d.ts.map +1 -0
  65. package/lib/hooks/types.d.ts +152 -0
  66. package/lib/hooks/types.d.ts.map +1 -0
  67. package/lib/hooks/useBookRenderer.d.ts +14 -0
  68. package/lib/hooks/useBookRenderer.d.ts.map +1 -0
  69. package/lib/hooks/useFilePreviewState.d.ts +10 -0
  70. package/lib/hooks/useFilePreviewState.d.ts.map +1 -0
  71. package/lib/hooks/useImageAutoFit.d.ts +13 -0
  72. package/lib/hooks/useImageAutoFit.d.ts.map +1 -0
  73. package/lib/hooks/useKeyboardNavigation.d.ts +15 -0
  74. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
  75. package/lib/hooks/useThemeMode.d.ts +7 -0
  76. package/lib/hooks/useThemeMode.d.ts.map +1 -0
  77. package/lib/hooks/useToolbarConfig.d.ts +25 -0
  78. package/lib/hooks/useToolbarConfig.d.ts.map +1 -0
  79. package/lib/index.cjs +30 -30
  80. package/lib/index.cjs.map +1 -1
  81. package/lib/index.css +1 -1
  82. package/lib/index.mjs +1 -1
  83. package/lib/renderers/Epub/index.d.ts.map +1 -1
  84. package/lib/renderers/Markdown/index.d.ts.map +1 -1
  85. package/lib/renderers/Pdf/index.d.ts +2 -0
  86. package/lib/renderers/Pdf/index.d.ts.map +1 -1
  87. package/lib/renderers/Pdf/toolbar.d.ts +5 -0
  88. package/lib/renderers/Pdf/toolbar.d.ts.map +1 -1
  89. package/lib/renderers/toolbar.types.d.ts +1 -0
  90. package/lib/renderers/toolbar.types.d.ts.map +1 -1
  91. package/lib/toolbar/registry.d.ts +51 -0
  92. package/lib/toolbar/registry.d.ts.map +1 -0
  93. package/lib/toolbar/renderItems.d.ts +8 -0
  94. package/lib/toolbar/renderItems.d.ts.map +1 -0
  95. package/package.json +1 -1
  96. package/lib/chunks/RendererError-BH6fzLrN.mjs +0 -15
  97. package/lib/chunks/RendererError-BH6fzLrN.mjs.map +0 -1
  98. package/lib/chunks/index-B0QA380T.mjs.map +0 -1
  99. package/lib/chunks/index-BvjPzMFc.mjs +0 -161
  100. package/lib/chunks/index-BvjPzMFc.mjs.map +0 -1
  101. package/lib/chunks/index-CIqtwqgy.mjs.map +0 -1
  102. package/lib/chunks/index-CRn7LdHD.mjs.map +0 -1
  103. package/lib/chunks/index-CWCNvV2X.mjs +0 -2323
  104. package/lib/chunks/index-CWCNvV2X.mjs.map +0 -1
  105. package/lib/chunks/index-Ctf8mG_u.mjs +0 -240
  106. package/lib/chunks/index-Ctf8mG_u.mjs.map +0 -1
  107. package/lib/chunks/index-p4mew8Hx.mjs.map +0 -1
@@ -0,0 +1,2808 @@
1
+ var et = Object.defineProperty;
2
+ var tt = (e, t, o) => t in e ? et(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var ce = (e, t, o) => tt(e, typeof t != "symbol" ? t + "" : t, o);
4
+ import { jsx as p, jsxs as k, Fragment as ot } from "react/jsx-runtime";
5
+ import _e, { useMemo as D, useContext as Z, createContext as ee, useState as z, useRef as $, useEffect as S, useReducer as rt, useCallback as F, Suspense as at, lazy as E } from "react";
6
+ import { createPortal as nt } from "react-dom";
7
+ import { motion as G, AnimatePresence as it } from "framer-motion";
8
+ import lt from "jszip";
9
+ import { FileQuestion as st, Download as te, ZoomOut as Fe, ZoomIn as Te, Scan as pt, RotateCcw as ft, RotateCw as Pe, RefreshCw as ke, List as oe, ChevronLeft as q, ChevronRight as K, Minimize2 as Ee, Maximize2 as Ne, WrapText as ct, Code as Ce, Eye as Re, X as dt, AlertCircle as ut } from "lucide-react";
10
+ import * as mt from "pdfjs-dist/build/pdf.mjs";
11
+ const ht = "1.4.0", gt = {
12
+ version: ht
13
+ }, nr = [
14
+ "image",
15
+ "pdf",
16
+ "docx",
17
+ "xlsx",
18
+ "pptx",
19
+ "msg",
20
+ "epub",
21
+ "mobi",
22
+ "video",
23
+ "audio",
24
+ "markdown",
25
+ "json",
26
+ "csv",
27
+ "xml",
28
+ "subtitle",
29
+ "zip",
30
+ "text",
31
+ "font"
32
+ ];
33
+ function bt(e) {
34
+ try {
35
+ const t = new URL(e).pathname.split("/").pop() || "file";
36
+ return decodeURIComponent(t);
37
+ } catch {
38
+ const t = e.split("/").pop() || "file";
39
+ return decodeURIComponent(t);
40
+ }
41
+ }
42
+ function X(e) {
43
+ var t;
44
+ const o = ((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "";
45
+ return {
46
+ // 图片
47
+ jpg: "image/jpeg",
48
+ jpeg: "image/jpeg",
49
+ png: "image/png",
50
+ gif: "image/gif",
51
+ webp: "image/webp",
52
+ svg: "image/svg+xml",
53
+ bmp: "image/bmp",
54
+ ico: "image/x-icon",
55
+ // 视频
56
+ mp4: "video/mp4",
57
+ webm: "video/webm",
58
+ ogg: "video/ogg",
59
+ ogv: "video/ogg",
60
+ mov: "video/quicktime",
61
+ avi: "video/x-msvideo",
62
+ mkv: "video/x-matroska",
63
+ m4v: "video/x-m4v",
64
+ "3gp": "video/3gpp",
65
+ flv: "video/x-flv",
66
+ // 音频
67
+ mp3: "audio/mpeg",
68
+ wav: "audio/wav",
69
+ m4a: "audio/mp4",
70
+ aac: "audio/aac",
71
+ flac: "audio/flac",
72
+ // 文档
73
+ pdf: "application/pdf",
74
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
75
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
76
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
77
+ ppt: "application/vnd.ms-powerpoint",
78
+ msg: "application/vnd.ms-outlook",
79
+ mobi: "application/x-mobipocket-ebook",
80
+ azw: "application/vnd.amazon.ebook",
81
+ azw3: "application/vnd.amazon.ebook",
82
+ kf8: "application/vnd.amazon.ebook",
83
+ // 文本
84
+ txt: "text/plain",
85
+ md: "text/markdown",
86
+ markdown: "text/markdown",
87
+ json: "application/json",
88
+ xml: "application/xml",
89
+ html: "text/html",
90
+ css: "text/css",
91
+ js: "text/javascript",
92
+ ts: "text/typescript",
93
+ jsx: "text/javascript",
94
+ tsx: "text/typescript",
95
+ py: "text/x-python",
96
+ java: "text/x-java",
97
+ cpp: "text/x-c++src",
98
+ c: "text/x-csrc",
99
+ cs: "text/x-csharp",
100
+ php: "text/x-php",
101
+ rb: "text/x-ruby",
102
+ go: "text/x-go",
103
+ rs: "text/x-rust",
104
+ yaml: "text/yaml",
105
+ yml: "text/yaml",
106
+ toml: "text/toml",
107
+ ini: "text/plain",
108
+ env: "text/plain",
109
+ diff: "text/x-diff",
110
+ patch: "text/x-diff",
111
+ log: "text/plain",
112
+ csv: "text/csv",
113
+ tsv: "text/tab-separated-values",
114
+ srt: "application/x-subrip",
115
+ vtt: "text/vtt",
116
+ zip: "application/zip"
117
+ }[o] || "application/octet-stream";
118
+ }
119
+ function wt(e, t = 0) {
120
+ if (e instanceof File)
121
+ return {
122
+ id: `file-${Date.now()}-${t}`,
123
+ name: e.name,
124
+ url: URL.createObjectURL(e),
125
+ type: e.type || X(e.name),
126
+ size: e.size
127
+ };
128
+ if (typeof e == "string") {
129
+ const o = bt(e);
130
+ return {
131
+ id: `url-${Date.now()}-${t}`,
132
+ name: o,
133
+ url: e,
134
+ type: X(o)
135
+ };
136
+ }
137
+ return {
138
+ id: e.id || `link-${Date.now()}-${t}`,
139
+ name: e.name,
140
+ url: e.url,
141
+ type: e.type || X(e.name),
142
+ size: e.size
143
+ };
144
+ }
145
+ function vt(e) {
146
+ return e.map((t, o) => wt(t, o));
147
+ }
148
+ function yt(e) {
149
+ var t;
150
+ const o = ((t = e.name.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "", r = e.type.toLowerCase();
151
+ if (r.startsWith("image/") || [
152
+ "jpg",
153
+ "jpeg",
154
+ "png",
155
+ "gif",
156
+ "webp",
157
+ "svg",
158
+ "bmp",
159
+ "ico",
160
+ // 高级图片格式
161
+ "heic",
162
+ "heif",
163
+ "avif",
164
+ "tif",
165
+ "tiff",
166
+ // RAW 格式
167
+ "cr2",
168
+ "nef",
169
+ "arw",
170
+ "dng",
171
+ "raf",
172
+ "orf",
173
+ // 其他专业格式
174
+ "psd",
175
+ "jp2",
176
+ "jpx",
177
+ "j2k"
178
+ ].includes(o))
179
+ return "image";
180
+ if (r.includes("pdf") || o === "pdf")
181
+ return "pdf";
182
+ if (r.includes("wordprocessingml") || o === "docx")
183
+ return "docx";
184
+ if (r.includes("spreadsheetml") || o === "xlsx")
185
+ return "xlsx";
186
+ if (r.includes("presentationml") || o === "pptx" || o === "ppt")
187
+ return "pptx";
188
+ if (r.includes("ms-outlook") || o === "msg")
189
+ return "msg";
190
+ if (r.includes("epub") || o === "epub")
191
+ return "epub";
192
+ if (["mobi", "azw", "azw3", "kf8"].includes(o) || r === "application/x-mobipocket-ebook" || r === "application/vnd.amazon.ebook")
193
+ return "mobi";
194
+ if (["csv", "tsv"].includes(o) || r === "text/csv" || r === "text/tab-separated-values")
195
+ return "csv";
196
+ if (o === "xml" || r === "application/xml" || r === "text/xml")
197
+ return "xml";
198
+ if (["srt", "vtt", "lrc", "elrc", "ass", "ssa", "ttml", "dfxp"].includes(o) || r === "text/vtt" || r === "application/x-subrip" || r === "application/ttml+xml")
199
+ return "subtitle";
200
+ if (o === "zip" || r === "application/zip" || r === "application/x-zip-compressed")
201
+ return "zip";
202
+ if (["ttf", "otf", "woff", "woff2"].includes(o) || r.startsWith("font/") || r === "application/font-woff" || r === "application/font-woff2" || r === "application/x-font-ttf" || r === "application/x-font-otf" || r === "application/font-sfnt")
203
+ return "font";
204
+ if (r.startsWith("video/") || ["mp4", "webm", "ogg", "ogv", "mov", "avi", "mkv", "m4v", "3gp", "flv"].includes(o))
205
+ return "video";
206
+ if (r.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac", "aac"].includes(o))
207
+ return "audio";
208
+ if (o === "md" || o === "markdown")
209
+ return "markdown";
210
+ if (r === "application/json" || o === "json" || o === "jsonc")
211
+ return "json";
212
+ const n = [
213
+ "txt",
214
+ "log",
215
+ "lock",
216
+ "js",
217
+ "jsx",
218
+ "ts",
219
+ "tsx",
220
+ "py",
221
+ "java",
222
+ "cpp",
223
+ "c",
224
+ "h",
225
+ "cs",
226
+ "php",
227
+ "rb",
228
+ "go",
229
+ "mod",
230
+ "rs",
231
+ "swift",
232
+ "kt",
233
+ "lua",
234
+ "vim",
235
+ "html",
236
+ "css",
237
+ "scss",
238
+ "sass",
239
+ "less",
240
+ "yaml",
241
+ "yml",
242
+ "toml",
243
+ "ini",
244
+ "conf",
245
+ "env",
246
+ "diff",
247
+ "patch",
248
+ "sh",
249
+ "bash",
250
+ "zsh",
251
+ "sql"
252
+ ];
253
+ return r.startsWith("text/") || n.includes(o) ? "text" : "unsupported";
254
+ }
255
+ function ir(e) {
256
+ var t;
257
+ const o = ((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "";
258
+ return {
259
+ js: "javascript",
260
+ jsx: "jsx",
261
+ ts: "typescript",
262
+ tsx: "tsx",
263
+ py: "python",
264
+ java: "java",
265
+ cpp: "cpp",
266
+ c: "c",
267
+ cs: "csharp",
268
+ php: "php",
269
+ rb: "ruby",
270
+ go: "go",
271
+ mod: "go",
272
+ rs: "rust",
273
+ swift: "swift",
274
+ kt: "kotlin",
275
+ lua: "lua",
276
+ vim: "vim",
277
+ scala: "scala",
278
+ sh: "bash",
279
+ bash: "bash",
280
+ zsh: "bash",
281
+ json: "json",
282
+ jsonc: "json",
283
+ xml: "xml",
284
+ html: "html",
285
+ css: "css",
286
+ scss: "scss",
287
+ sass: "sass",
288
+ less: "less",
289
+ sql: "sql",
290
+ yaml: "yaml",
291
+ yml: "yaml",
292
+ toml: "toml",
293
+ ini: "ini",
294
+ env: "bash",
295
+ conf: "nginx",
296
+ diff: "diff",
297
+ patch: "diff",
298
+ log: "log",
299
+ md: "markdown",
300
+ txt: "text"
301
+ }[o] || "text";
302
+ }
303
+ function xt(e) {
304
+ return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
305
+ }
306
+ function lr(e) {
307
+ var t;
308
+ return (((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "") === "tsv" ? " " : ",";
309
+ }
310
+ function sr(e, t = {}) {
311
+ const o = t.delimiter ?? ",", r = t.firstRowAsHeader ?? !0, n = [];
312
+ let a = [], i = "", l = !1, s = 0;
313
+ const f = e.length;
314
+ for (; s < f; ) {
315
+ const u = e[s];
316
+ if (l) {
317
+ if (u === '"') {
318
+ if (e[s + 1] === '"') {
319
+ i += '"', s += 2;
320
+ continue;
321
+ }
322
+ l = !1, s += 1;
323
+ continue;
324
+ }
325
+ i += u, s += 1;
326
+ continue;
327
+ }
328
+ if (u === '"') {
329
+ l = !0, s += 1;
330
+ continue;
331
+ }
332
+ if (u === o) {
333
+ a.push(i), i = "", s += 1;
334
+ continue;
335
+ }
336
+ if (u === "\r") {
337
+ e[s + 1] === `
338
+ ` && (s += 1), a.push(i), n.push(a), a = [], i = "", s += 1;
339
+ continue;
340
+ }
341
+ if (u === `
342
+ `) {
343
+ a.push(i), n.push(a), a = [], i = "", s += 1;
344
+ continue;
345
+ }
346
+ i += u, s += 1;
347
+ }
348
+ for ((i.length > 0 || a.length > 0) && (a.push(i), n.push(a)); n.length > 0; ) {
349
+ const u = n[n.length - 1];
350
+ if (u.length === 1 && u[0] === "")
351
+ n.pop();
352
+ else
353
+ break;
354
+ }
355
+ let c = [], d = n;
356
+ r && n.length > 0 && (c = n[0], d = n.slice(1));
357
+ const m = Math.max(
358
+ c.length,
359
+ ...d.map((u) => u.length),
360
+ 0
361
+ );
362
+ for (const u of d)
363
+ for (; u.length < m; ) u.push("");
364
+ return {
365
+ header: c,
366
+ rows: d,
367
+ columnCount: m,
368
+ delimiter: o
369
+ };
370
+ }
371
+ function _t(e) {
372
+ const t = e instanceof Uint8Array ? e : new Uint8Array(e);
373
+ if (t.length >= 3 && t[0] === 239 && t[1] === 187 && t[2] === 191)
374
+ return new TextDecoder("utf-8").decode(t);
375
+ if (t.length >= 2 && t[0] === 255 && t[1] === 254)
376
+ return new TextDecoder("utf-16le").decode(t);
377
+ if (t.length >= 2 && t[0] === 254 && t[1] === 255)
378
+ return new TextDecoder("utf-16be").decode(t);
379
+ try {
380
+ return new TextDecoder("utf-8", { fatal: !0 }).decode(t);
381
+ } catch {
382
+ }
383
+ try {
384
+ return new TextDecoder("gbk").decode(t);
385
+ } catch {
386
+ }
387
+ return new TextDecoder("utf-8", { fatal: !1 }).decode(t);
388
+ }
389
+ async function pr(e, t) {
390
+ const o = !!t && ("fetcher" in t || "init" in t || "signal" in t), r = o ? t.fetcher ?? fetch : fetch, n = o ? t.signal : void 0, a = o ? t.init : t, i = n ? { ...a, signal: n } : a, l = await r(e, i);
391
+ if (!l.ok) throw new Error(`请求失败: ${l.status}`);
392
+ const s = await l.arrayBuffer();
393
+ return _t(s);
394
+ }
395
+ async function Ft(e, t) {
396
+ if (e)
397
+ return typeof e == "function" ? await e(t) : e;
398
+ }
399
+ function Tt(e, t) {
400
+ if (!e && !t) return;
401
+ if (!e) return t;
402
+ if (!t) return e;
403
+ const o = new Headers(e.headers || {});
404
+ return t.headers && new Headers(t.headers).forEach((r, n) => {
405
+ o.set(n, r);
406
+ }), {
407
+ ...e,
408
+ ...t,
409
+ headers: o
410
+ };
411
+ }
412
+ function Pt(e) {
413
+ const t = (e == null ? void 0 : e.requestHandler) ?? ((r, n) => fetch(r, n)), o = e == null ? void 0 : e.requestInit;
414
+ return async (r, n) => {
415
+ const a = await Ft(o, r), i = Tt(a, n);
416
+ return t(r, i);
417
+ };
418
+ }
419
+ async function kt(e, t = fetch, o) {
420
+ const r = await t(e, o);
421
+ if (!r.ok) throw new Error(`请求失败: ${r.status}`);
422
+ const n = await r.blob();
423
+ return URL.createObjectURL(n);
424
+ }
425
+ async function Et(e, t, o = fetch, r) {
426
+ const n = await o(e, r);
427
+ if (!n.ok) throw new Error(`请求失败: ${n.status}`);
428
+ const a = await n.blob(), i = URL.createObjectURL(a);
429
+ try {
430
+ const l = document.createElement("a");
431
+ l.href = i, l.download = t, l.style.display = "none", document.body.appendChild(l), l.click(), document.body.removeChild(l);
432
+ } finally {
433
+ setTimeout(() => URL.revokeObjectURL(i), 1e3);
434
+ }
435
+ }
436
+ function de(e) {
437
+ const t = e.trim().replace(",", "."), o = t.split(":").map((r) => r.trim());
438
+ if (o.length === 3) {
439
+ const [r, n, a] = o;
440
+ return Number(r) * 3600 + Number(n) * 60 + Number(a);
441
+ }
442
+ if (o.length === 2) {
443
+ const [r, n] = o;
444
+ return Number(r) * 60 + Number(n);
445
+ }
446
+ return Number(t) || 0;
447
+ }
448
+ function fr(e) {
449
+ if (!isFinite(e) || e < 0) return "00:00:00.000";
450
+ const t = Math.floor(e * 1e3), o = t % 1e3, r = Math.floor(t / 1e3) % 60, n = Math.floor(t / 6e4) % 60, a = Math.floor(t / 36e5), i = (l, s = 2) => l.toString().padStart(s, "0");
451
+ return `${i(a)}:${i(n)}:${i(r)}.${i(o, 3)}`;
452
+ }
453
+ const ue = /(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}\s*-->\s*(\d{1,2}:)?\d{1,2}:\d{1,2}[.,]\d{1,3}/, Nt = /^\s*\[\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?\]/;
454
+ function Ct(e) {
455
+ const t = e.replace(/^\uFEFF/, "").trimStart();
456
+ return /^WEBVTT/.test(t) ? "vtt" : /^<\?xml/i.test(t) || /<tt\b[^>]*>/i.test(t) ? "ttml" : /^\[Script Info\]/im.test(t) || /^Dialogue:/m.test(t) ? /ScriptType:\s*v4\.00\s*$/im.test(t) ? "ssa" : "ass" : Nt.test(t) || /^\[(ti|ar|al|au|by|length|offset|re|ve):/im.test(t) ? /<\d{1,2}:\d{1,2}(?:[.:]\d{1,3})?>/.test(t) ? "elrc" : "lrc" : "srt";
457
+ }
458
+ function me(e, t) {
459
+ const o = e.replace(/\r\n?/g, `
460
+ `).replace(/^\uFEFF/, "").split(`
461
+ `), r = [];
462
+ let n, a = 0;
463
+ if (t === "vtt") {
464
+ const i = [];
465
+ for (; a < o.length && o[a].trim() !== ""; )
466
+ i.push(o[a]), a++;
467
+ for (n = i.join(`
468
+ `); a < o.length && o[a].trim() === ""; ) a++;
469
+ }
470
+ for (; a < o.length; ) {
471
+ for (; a < o.length && o[a].trim() === ""; ) a++;
472
+ if (a >= o.length) break;
473
+ let i, l = null;
474
+ if (ue.test(o[a]))
475
+ l = o[a], a++;
476
+ else if (i = o[a].trim() || void 0, a++, a < o.length && ue.test(o[a]))
477
+ l = o[a], a++;
478
+ else
479
+ continue;
480
+ if (!l) continue;
481
+ const s = l.match(/([\d:.,]+)\s*-->\s*([\d:.,]+)/);
482
+ if (!s) continue;
483
+ const f = de(s[1]), c = de(s[2]), d = [];
484
+ for (; a < o.length && o[a].trim() !== ""; )
485
+ d.push(o[a]), a++;
486
+ r.push({ id: i, start: f, end: c, text: d.join(`
487
+ `) });
488
+ }
489
+ return { format: t, cues: r, header: n };
490
+ }
491
+ function Q(e, t, o) {
492
+ const r = Number(e), n = Number(t);
493
+ let a = 0;
494
+ if (o) {
495
+ const i = (o + "000").slice(0, 3);
496
+ a = Number(i);
497
+ }
498
+ return r * 60 + n + a / 1e3;
499
+ }
500
+ function Se(e, t) {
501
+ const o = /^\[(ti|ar|al|au|by|length|offset|re|ve):(.*)\]$/i.exec(e.trim());
502
+ if (!o) return !1;
503
+ const r = o[1].toLowerCase(), n = o[2].trim();
504
+ if (t.metadata[r] = n, r === "offset") {
505
+ const a = Number(n);
506
+ isNaN(a) || (t.offsetMs = a);
507
+ }
508
+ return !0;
509
+ }
510
+ function Rt(e) {
511
+ const t = e.replace(/\r\n?/g, `
512
+ `).replace(/^\uFEFF/, "").split(`
513
+ `), o = { metadata: {}, offsetMs: 0 }, r = /\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g, n = [];
514
+ for (const i of t) {
515
+ const l = i.trim();
516
+ if (!l || Se(l, o)) continue;
517
+ const s = [];
518
+ let f = 0;
519
+ r.lastIndex = 0;
520
+ let c;
521
+ for (; (c = r.exec(l)) !== null && c.index === f; )
522
+ s.push(Q(c[1], c[2], c[3])), f = c.index + c[0].length;
523
+ if (s.length === 0) continue;
524
+ const d = l.slice(f).trim();
525
+ for (const m of s)
526
+ n.push({ start: m, text: d });
527
+ }
528
+ n.sort((i, l) => i.start - l.start);
529
+ const a = o.offsetMs / 1e3;
530
+ return { format: "lrc", cues: n.map((i, l) => {
531
+ const s = Math.max(0, i.start - a), f = n[l + 1], c = f ? Math.max(s, f.start - a) : s + 5;
532
+ return { start: s, end: c, text: i.text };
533
+ }), metadata: o.metadata };
534
+ }
535
+ function St(e) {
536
+ const t = e.replace(/\r\n?/g, `
537
+ `).replace(/^\uFEFF/, "").split(`
538
+ `), o = { metadata: {}, offsetMs: 0 }, r = /\[(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g, n = /<(\d{1,2}):(\d{1,2})(?:[.:](\d{1,3}))?>/g, a = [];
539
+ for (const l of t) {
540
+ const s = l.trim();
541
+ if (!s || Se(s, o)) continue;
542
+ const f = [];
543
+ let c = 0;
544
+ r.lastIndex = 0;
545
+ let d;
546
+ for (; (d = r.exec(s)) !== null && d.index === c; )
547
+ f.push(Q(d[1], d[2], d[3])), c = d.index + d[0].length;
548
+ if (f.length === 0) continue;
549
+ const m = s.slice(c);
550
+ for (const u of f)
551
+ a.push({ start: u, raw: m });
552
+ }
553
+ a.sort((l, s) => l.start - s.start);
554
+ const i = o.offsetMs / 1e3;
555
+ return { format: "elrc", cues: a.map((l, s) => {
556
+ const f = [];
557
+ let c = "", d = 0, m = null;
558
+ n.lastIndex = 0;
559
+ let u;
560
+ for (; (u = n.exec(l.raw)) !== null; ) {
561
+ const P = l.raw.slice(d, u.index);
562
+ m !== null && P && f.push({ start: Math.max(0, m - i), text: P }), c += P, m = Q(u[1], u[2], u[3]), d = u.index + u[0].length;
563
+ }
564
+ const _ = l.raw.slice(d);
565
+ m !== null && _ && f.push({ start: Math.max(0, m - i), text: _ }), c += _;
566
+ const T = Math.max(0, l.start - i), C = a[s + 1], y = C ? Math.max(T, C.start - i) : T + 5;
567
+ return {
568
+ start: T,
569
+ end: y,
570
+ text: c.trim(),
571
+ words: f.length ? f : void 0
572
+ };
573
+ }), metadata: o.metadata };
574
+ }
575
+ function he(e) {
576
+ const t = e.trim().split(":");
577
+ return t.length !== 3 ? 0 : Number(t[0]) * 3600 + Number(t[1]) * 60 + Number(t[2].replace(",", "."));
578
+ }
579
+ function ge(e, t) {
580
+ const o = e.replace(/\r\n?/g, `
581
+ `).replace(/^\uFEFF/, "").split(`
582
+ `);
583
+ let r = "", n = [];
584
+ const a = [], i = [];
585
+ for (const l of o) {
586
+ const s = l.replace(/\s+$/, ""), f = s.trim(), c = /^\[([^\]]+)\]\s*$/.exec(f);
587
+ if (c) {
588
+ r = c[1].toLowerCase(), i.push(s);
589
+ continue;
590
+ }
591
+ if (r !== "events") {
592
+ i.push(s);
593
+ continue;
594
+ }
595
+ const d = /^Format:\s*(.+)$/i.exec(f);
596
+ if (d) {
597
+ n = d[1].split(",").map((N) => N.trim());
598
+ continue;
599
+ }
600
+ const m = /^(Dialogue|Comment):\s*(.+)$/i.exec(f);
601
+ if (!m || m[1].toLowerCase() === "comment" || n.length === 0) continue;
602
+ const u = n.length, _ = m[2].split(","), T = _.slice(0, u - 1), C = _.slice(u - 1).join(","), y = {};
603
+ n.forEach((N, R) => {
604
+ y[N] = R === u - 1 ? C : T[R] ?? "";
605
+ });
606
+ const P = he(y.Start || ""), h = he(y.End || ""), w = (y.Text || "").replace(/\\N/g, `
607
+ `).replace(/\\n/g, `
608
+ `).replace(/\\h/g, " ").replace(/\{[^}]*\}/g, "");
609
+ a.push({ start: P, end: h, text: w, style: y.Style });
610
+ }
611
+ return a.sort((l, s) => l.start - s.start), {
612
+ format: t,
613
+ cues: a,
614
+ header: i.join(`
615
+ `).trim() || void 0
616
+ };
617
+ }
618
+ function I(e) {
619
+ const t = e.trim();
620
+ if (!t) return 0;
621
+ const o = /^(\d+(?:\.\d+)?)(h|m|s|ms|f|t)$/i.exec(t);
622
+ if (o) {
623
+ const n = Number(o[1]), a = o[2].toLowerCase();
624
+ return a === "h" ? n * 3600 : a === "m" ? n * 60 : a === "ms" ? n / 1e3 : n;
625
+ }
626
+ const r = t.split(":");
627
+ return r.length === 3 ? Number(r[0]) * 3600 + Number(r[1]) * 60 + Number(r[2]) : r.length === 2 ? Number(r[0]) * 60 + Number(r[1]) : Number(t) || 0;
628
+ }
629
+ function Mt(e) {
630
+ return e.replace(/&#x([0-9a-fA-F]+);/g, (t, o) => String.fromCharCode(parseInt(o, 16))).replace(/&#(\d+);/g, (t, o) => String.fromCharCode(Number(o))).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&");
631
+ }
632
+ function zt(e) {
633
+ var t, o, r;
634
+ const n = [], a = /<(?:[\w-]+:)?p\b([^>]*)>([\s\S]*?)<\/(?:[\w-]+:)?p\s*>/gi;
635
+ let i;
636
+ for (; (i = a.exec(e)) !== null; ) {
637
+ const l = i[1], s = i[2], f = ((t = /\bbegin\s*=\s*["']([^"']+)["']/i.exec(l)) == null ? void 0 : t[1]) || "", c = ((o = /\bend\s*=\s*["']([^"']+)["']/i.exec(l)) == null ? void 0 : o[1]) || "", d = ((r = /\bdur\s*=\s*["']([^"']+)["']/i.exec(l)) == null ? void 0 : r[1]) || "", m = I(f);
638
+ let u;
639
+ c ? u = I(c) : d ? u = m + I(d) : u = m + 5;
640
+ const _ = Mt(
641
+ s.replace(/<(?:[\w-]+:)?br\s*\/?>/gi, `
642
+ `).replace(/<[^>]+>/g, "")
643
+ ).replace(/[ \t]+/g, " ").replace(/\n /g, `
644
+ `).trim();
645
+ (_ || m || u) && n.push({ start: m, end: u, text: _ });
646
+ }
647
+ return n.sort((l, s) => l.start - s.start), { format: "ttml", cues: n };
648
+ }
649
+ function Wt(e) {
650
+ const t = e.replace(/^\uFEFF/, "");
651
+ if (typeof DOMParser < "u") {
652
+ const o = new DOMParser().parseFromString(t, "application/xml");
653
+ if (o.getElementsByTagName("parsererror").length === 0) {
654
+ const r = o.getElementsByTagNameNS ? o.getElementsByTagNameNS("*", "p") : o.getElementsByTagName("p");
655
+ if (r.length > 0) {
656
+ const n = [];
657
+ for (let a = 0; a < r.length; a++) {
658
+ const i = r[a], l = i.getAttribute("begin") || "", s = i.getAttribute("end") || "", f = i.getAttribute("dur") || "", c = I(l);
659
+ let d;
660
+ s ? d = I(s) : f ? d = c + I(f) : d = c + 5;
661
+ let m = "";
662
+ i.childNodes.forEach((_) => {
663
+ if (_.nodeType === 3)
664
+ m += _.nodeValue || "";
665
+ else if (_.nodeType === 1) {
666
+ const T = _;
667
+ (T.localName || T.tagName).toLowerCase() === "br" ? m += `
668
+ ` : m += T.textContent || "";
669
+ }
670
+ });
671
+ const u = m.replace(/[ \t]+/g, " ").replace(/\n /g, `
672
+ `).trim();
673
+ (u || c || d) && n.push({ start: c, end: d, text: u });
674
+ }
675
+ return n.sort((a, i) => a.start - i.start), { format: "ttml", cues: n };
676
+ }
677
+ }
678
+ }
679
+ return zt(t);
680
+ }
681
+ function cr(e, t) {
682
+ switch (t ?? Ct(e)) {
683
+ case "lrc":
684
+ return Rt(e);
685
+ case "elrc":
686
+ return St(e);
687
+ case "ass":
688
+ return ge(e, "ass");
689
+ case "ssa":
690
+ return ge(e, "ssa");
691
+ case "ttml":
692
+ return Wt(e);
693
+ case "vtt":
694
+ return me(e, "vtt");
695
+ case "srt":
696
+ default:
697
+ return me(e, "srt");
698
+ }
699
+ }
700
+ async function dr(e) {
701
+ return lt.loadAsync(e);
702
+ }
703
+ function ur(e) {
704
+ const t = [];
705
+ return e.forEach((o, r) => {
706
+ var n;
707
+ const a = r.dir, i = a && !o.endsWith("/") ? o + "/" : o, l = a ? i.replace(/\/$/, "") : i, s = l.lastIndexOf("/"), f = s >= 0 ? l.slice(s + 1) : l, c = s >= 0 ? l.slice(0, s) : "", d = a ? 0 : ((n = r._data) == null ? void 0 : n.uncompressedSize) ?? 0;
708
+ t.push({
709
+ path: i,
710
+ name: f,
711
+ dir: c,
712
+ isDir: a,
713
+ size: d,
714
+ date: r.date
715
+ });
716
+ }), t;
717
+ }
718
+ function mr(e) {
719
+ const t = { name: "", path: "", isDir: !0, children: [], size: 0 }, o = /* @__PURE__ */ new Map();
720
+ o.set("", t);
721
+ const r = (a) => {
722
+ if (o.has(a)) return o.get(a);
723
+ const i = a.split("/").filter(Boolean);
724
+ let l = t, s = "";
725
+ for (const f of i) {
726
+ s = s ? `${s}/${f}` : f;
727
+ let c = o.get(s);
728
+ c || (c = { name: f, path: s + "/", isDir: !0, children: [], size: 0 }, l.children.push(c), o.set(s, c)), l = c;
729
+ }
730
+ return l;
731
+ };
732
+ for (const a of e) {
733
+ if (a.isDir) {
734
+ r(a.path.replace(/\/$/, ""));
735
+ continue;
736
+ }
737
+ r(a.dir).children.push({
738
+ name: a.name,
739
+ path: a.path,
740
+ isDir: !1,
741
+ size: a.size
742
+ });
743
+ }
744
+ const n = (a) => {
745
+ if (a.children) {
746
+ a.children.sort((i, l) => i.isDir !== l.isDir ? i.isDir ? -1 : 1 : i.name.localeCompare(l.name));
747
+ for (const i of a.children) n(i);
748
+ }
749
+ };
750
+ return n(t), t;
751
+ }
752
+ async function hr(e, t, o) {
753
+ const r = e.file(t);
754
+ if (!r) throw new Error(`ZIP entry not found: ${t}`);
755
+ const n = await r.async("arraybuffer");
756
+ return new Blob([n], o ? { type: o } : void 0);
757
+ }
758
+ function jt(e) {
759
+ return e ? e.startsWith("#") ? e : e.length === 8 ? "#" + e.substring(2) : e.length === 6 ? "#" + e : "#000000" : "#000000";
760
+ }
761
+ const Ot = [
762
+ "FFFFFF",
763
+ "000000",
764
+ "E7E6E6",
765
+ "44546A",
766
+ "4472C4",
767
+ "ED7D31",
768
+ "A5A5A5",
769
+ "FFC000",
770
+ "5B9BD5",
771
+ "70AD47"
772
+ ], Lt = [
773
+ "000000",
774
+ "FFFFFF",
775
+ "FF0000",
776
+ "00FF00",
777
+ "0000FF",
778
+ "FFFF00",
779
+ "FF00FF",
780
+ "00FFFF",
781
+ "000000",
782
+ "FFFFFF",
783
+ "FF0000",
784
+ "00FF00",
785
+ "0000FF",
786
+ "FFFF00",
787
+ "FF00FF",
788
+ "00FFFF",
789
+ "800000",
790
+ "008000",
791
+ "000080",
792
+ "808000",
793
+ "800080",
794
+ "008080",
795
+ "C0C0C0",
796
+ "808080",
797
+ "9999FF",
798
+ "993366",
799
+ "FFFFCC",
800
+ "CCFFFF",
801
+ "660066",
802
+ "FF8080",
803
+ "0066CC",
804
+ "CCCCFF",
805
+ "000080",
806
+ "FF00FF",
807
+ "FFFF00",
808
+ "00FFFF",
809
+ "800080",
810
+ "800000",
811
+ "008080",
812
+ "0000FF",
813
+ "00CCFF",
814
+ "CCFFFF",
815
+ "CCFFCC",
816
+ "FFFF99",
817
+ "99CCFF",
818
+ "FF99CC",
819
+ "CC99FF",
820
+ "FFCC99",
821
+ "3366FF",
822
+ "33CCCC",
823
+ "99CC00",
824
+ "FFCC00",
825
+ "FF9900",
826
+ "FF6600",
827
+ "666699",
828
+ "969696",
829
+ "003366",
830
+ "339966",
831
+ "003300",
832
+ "333300",
833
+ "993300",
834
+ "993366",
835
+ "333399",
836
+ "333333"
837
+ ];
838
+ function At(e, t) {
839
+ const o = parseInt(e.substring(0, 2), 16), r = parseInt(e.substring(2, 4), 16), n = parseInt(e.substring(4, 6), 16), a = (f) => t < 0 ? Math.round(f * (1 + t)) : Math.round(f + (255 - f) * t), i = Math.min(255, Math.max(0, a(o))), l = Math.min(255, Math.max(0, a(r))), s = Math.min(255, Math.max(0, a(n)));
840
+ return i.toString(16).padStart(2, "0") + l.toString(16).padStart(2, "0") + s.toString(16).padStart(2, "0");
841
+ }
842
+ function Dt(e) {
843
+ if (e && e.type === "pattern" && e.pattern === "solid") {
844
+ const t = e.fgColor;
845
+ if (t)
846
+ return re(t);
847
+ }
848
+ }
849
+ function re(e) {
850
+ if (e) {
851
+ if ("argb" in e && typeof e.argb == "string" && e.argb)
852
+ return jt(e.argb);
853
+ if ("theme" in e && typeof e.theme == "number") {
854
+ const t = Ot[e.theme] || "000000", o = "tint" in e && typeof e.tint == "number" ? e.tint : 0;
855
+ return "#" + (o !== 0 ? At(t, o) : t);
856
+ }
857
+ if ("indexed" in e && typeof e.indexed == "number") {
858
+ const t = Lt[e.indexed];
859
+ if (t) return "#" + t;
860
+ }
861
+ }
862
+ }
863
+ function It(e) {
864
+ if (!e || !e.style) return;
865
+ const t = re(e.color) || "#000000";
866
+ return [e.style, t];
867
+ }
868
+ function $t(e) {
869
+ const t = {};
870
+ let o = !1;
871
+ if (e.font) {
872
+ const n = e.font;
873
+ if ((n.name || n.size || n.bold || n.italic) && (o = !0, t.font = {}, n.name && (t.font.name = n.name), n.size && (t.font.size = n.size), n.bold && (t.font.bold = !0), n.italic && (t.font.italic = !0)), n.color) {
874
+ const a = re(n.color);
875
+ a && (o = !0, t.color = a);
876
+ }
877
+ n.underline && (o = !0, t.underline = !0), n.strike && (o = !0, t.strike = !0);
878
+ }
879
+ const r = Dt(e.fill);
880
+ if (r && (o = !0, t.bgcolor = r), e.alignment) {
881
+ const n = e.alignment;
882
+ n.horizontal && (o = !0, t.align = n.horizontal), n.vertical && (o = !0, t.valign = n.vertical), n.wrapText && (o = !0, t.textwrap = !0);
883
+ }
884
+ if (e.border) {
885
+ const n = {};
886
+ let a = !1;
887
+ const i = ["top", "bottom", "left", "right"];
888
+ for (const l of i) {
889
+ const s = It(e.border[l]);
890
+ s && (n[l] = s, a = !0);
891
+ }
892
+ a && (o = !0, t.border = n);
893
+ }
894
+ return o ? t : null;
895
+ }
896
+ function Zt(e) {
897
+ return JSON.stringify(e);
898
+ }
899
+ function Ut(e, t, o) {
900
+ const r = $t(e);
901
+ if (!r) return -1;
902
+ const n = Zt(r), a = o.get(n);
903
+ if (a !== void 0) return a;
904
+ const i = t.length;
905
+ return t.push(r), o.set(n, i), i;
906
+ }
907
+ function Ht(e) {
908
+ const t = e.value;
909
+ if (t == null) return "";
910
+ if (typeof t == "string") return t;
911
+ if (typeof t == "number") return String(t);
912
+ if (typeof t == "boolean") return t ? "TRUE" : "FALSE";
913
+ if (t instanceof Date)
914
+ return t.toLocaleDateString();
915
+ if (typeof t == "object" && "formula" in t) {
916
+ const o = t.result;
917
+ return o != null ? String(o) : "";
918
+ }
919
+ return typeof t == "object" && "richText" in t ? t.richText.map((o) => o.text).join("") : typeof t == "object" && "hyperlink" in t ? t.text || "" : typeof t == "object" && "error" in t ? String(t.error) : String(t);
920
+ }
921
+ function Bt(e) {
922
+ const t = e.split(":"), o = be(t[0]), r = t[1] ? be(t[1]) : o;
923
+ return {
924
+ top: o.row,
925
+ left: o.col,
926
+ bottom: r.row,
927
+ right: r.col
928
+ };
929
+ }
930
+ function be(e) {
931
+ const t = e.match(/^([A-Z]+)(\d+)$/);
932
+ if (!t) return { row: 1, col: 1 };
933
+ const o = t[1], r = parseInt(t[2], 10);
934
+ let n = 0;
935
+ for (let a = 0; a < o.length; a++)
936
+ n = n * 26 + (o.charCodeAt(a) - 64);
937
+ return { row: r, col: n };
938
+ }
939
+ function gr(e) {
940
+ const t = [];
941
+ return e.eachSheet((o) => {
942
+ const r = [], n = /* @__PURE__ */ new Map(), a = [], i = {}, l = {}, s = o.columnCount;
943
+ for (let m = 1; m <= s; m++) {
944
+ const u = o.getColumn(m);
945
+ u.width && (l[String(m - 1)] = { width: Math.round(u.width * 7.5) });
946
+ }
947
+ l.len = Math.max(s, 26);
948
+ const f = /* @__PURE__ */ new Map(), c = o.model, d = (c == null ? void 0 : c.merges) || [];
949
+ for (const m of d) {
950
+ a.push(m);
951
+ const { top: u, left: _, bottom: T, right: C } = Bt(m), y = T - u, P = C - _;
952
+ f.set(`${u - 1},${_ - 1}`, [y, P]);
953
+ }
954
+ o.eachRow({ includeEmpty: !0 }, (m, u) => {
955
+ const _ = u - 1, T = {};
956
+ m.eachCell({ includeEmpty: !1 }, (y, P) => {
957
+ const h = P - 1;
958
+ if (y.isMerged && y.master !== y) return;
959
+ const w = Ht(y), N = Ut(y, r, n), R = { text: w };
960
+ N !== -1 && (R.style = N);
961
+ const x = `${_},${h}`;
962
+ f.has(x) && (R.merge = f.get(x)), T[String(h)] = R;
963
+ });
964
+ const C = { cells: T };
965
+ m.height && (C.height = Math.round(m.height * 1.333)), i[String(_)] = C;
966
+ }), t.push({
967
+ name: o.name,
968
+ styles: r,
969
+ merges: a,
970
+ rows: i,
971
+ cols: l
972
+ });
973
+ }), t;
974
+ }
975
+ function br(e, t, o = "Sheet1") {
976
+ const r = e.length > 0, n = r ? [{ font: { bold: !0 } }] : [], a = {};
977
+ if (r) {
978
+ const l = {};
979
+ e.forEach((s, f) => {
980
+ l[String(f)] = { text: s, style: 0 };
981
+ }), a[0] = { cells: l };
982
+ }
983
+ const i = r ? 1 : 0;
984
+ return t.forEach((l, s) => {
985
+ const f = {};
986
+ l.forEach((c, d) => {
987
+ c !== void 0 && c !== "" && (f[String(d)] = { text: c });
988
+ }), a[String(s + i)] = { cells: f };
989
+ }), [{ name: o, styles: n, rows: a }];
990
+ }
991
+ function Vt(e, t) {
992
+ var o;
993
+ if (typeof window > "u") return;
994
+ const r = (e == null ? void 0 : e.version) || ((o = e == null ? void 0 : e.GlobalWorkerOptions) == null ? void 0 : o.version) || "", {
995
+ workerSrc: n = `https://unpkg.com/pdfjs-dist@${r}/build/pdf.worker.min.mjs`,
996
+ cMapUrl: a = `https://unpkg.com/pdfjs-dist@${r}/cmaps/`,
997
+ cMapPacked: i = !0
998
+ } = t || {};
999
+ e.GlobalWorkerOptions && (e.GlobalWorkerOptions.workerSrc = n, e.GlobalWorkerOptions.cMapUrl = a, e.GlobalWorkerOptions.cMapPacked = i);
1000
+ }
1001
+ const Gt = {
1002
+ // ─────── common ───────
1003
+ "common.download": "下载",
1004
+ "common.close": "关闭",
1005
+ "common.loading": "加载中",
1006
+ "common.unknown_error": "未知错误",
1007
+ "common.unsupported_preview": "不支持预览此文件类型 ({type})",
1008
+ "common.retry": "重试",
1009
+ // ─────── accessibility ───────
1010
+ "accessibility.previousFile": "上一个文件",
1011
+ "accessibility.nextFile": "下一个文件",
1012
+ "accessibility.closePreview": "关闭预览",
1013
+ "accessibility.downloadFile": "下载文件",
1014
+ // ─────── toolbar ───────
1015
+ "toolbar.zoom_in": "放大",
1016
+ "toolbar.zoom_out": "缩小",
1017
+ "toolbar.rotate_left": "向左旋转",
1018
+ "toolbar.rotate_right": "向右旋转",
1019
+ "toolbar.reset": "复原",
1020
+ "toolbar.fit_to_window": "适应窗口",
1021
+ "toolbar.original_size": "原始尺寸",
1022
+ "toolbar.toc": "目录",
1023
+ "toolbar.outline": "大纲",
1024
+ "toolbar.prev_page": "上一页",
1025
+ "toolbar.next_page": "下一页",
1026
+ "toolbar.full_width": "全屏宽度",
1027
+ "toolbar.normal_width": "正常宽度",
1028
+ "toolbar.wrap_on": "自动换行",
1029
+ "toolbar.wrap_off": "不换行",
1030
+ "toolbar.source": "源码",
1031
+ "toolbar.preview": "预览",
1032
+ // ─────── image ───────
1033
+ "image.load_failed": "图片加载失败",
1034
+ "image.decode_failed": "图片解码失败",
1035
+ // ─────── pdf ───────
1036
+ "pdf.load_failed": "PDF 文件加载失败",
1037
+ // ─────── docx ───────
1038
+ "docx.parse_failed": "Word 文档解析失败",
1039
+ // ─────── xlsx ───────
1040
+ "xlsx.loading": "加载 Excel 中...",
1041
+ "xlsx.load_failed": "Excel 加载失败",
1042
+ "xlsx.parse_failed": "Excel 文件解析失败",
1043
+ "xlsx.not_found": "Excel 文件不存在",
1044
+ // ─────── pptx ───────
1045
+ "pptx.loading": "加载 PPT 中...",
1046
+ "pptx.load_failed": "PPT 加载失败",
1047
+ "pptx.parse_failed": "PPT 文件解析失败",
1048
+ "pptx.not_found": "PPT 文件不存在",
1049
+ "pptx.invalid_format": "PPT 文件格式错误或已损坏",
1050
+ "pptx.no_pages": "PPT 文件无有效页面",
1051
+ "pptx.timeout": "加载超时,请检查网络或稍后重试",
1052
+ // ─────── msg ───────
1053
+ "msg.parse_failed": "Outlook 邮件解析失败",
1054
+ "msg.parse_failed_short": "邮件解析失败",
1055
+ "msg.empty_body": "(无邮件正文)",
1056
+ // ─────── epub ───────
1057
+ "epub.load_failed": "EPUB 文件加载失败",
1058
+ // ─────── mobi ───────
1059
+ "mobi.load_failed": "电子书加载失败,文件可能已损坏或带有 DRM 保护",
1060
+ // ─────── video ───────
1061
+ "video.loading": "加载视频中...",
1062
+ "video.load_failed": "视频加载失败",
1063
+ "video.load_failed_with_error": "视频加载失败: {error}",
1064
+ "video.format_not_supported": "浏览器不支持 {format} 格式,建议转换为 MP4/WebM 格式",
1065
+ "video.unsupported_title": "该视频格式无法在浏览器中直接播放",
1066
+ "video.unsupported_detail": "{format} 是浏览器原生不支持的容器/编码(常见于 AVI / WMV / FLV 及部分 MKV)。请下载到本地播放器观看,或转换为 MP4(H.264 + AAC)。",
1067
+ "video.codec_not_supported_detail": "视频或音频编码 {codecs} 浏览器无法解码。请转换为 MP4(H.264 + AAC)后再预览。",
1068
+ // ─────── audio (aria-label) ───────
1069
+ "audio.aria.play": "播放",
1070
+ "audio.aria.pause": "暂停",
1071
+ "audio.aria.forward_10": "前进 10 秒",
1072
+ "audio.aria.backward_10": "后退 10 秒",
1073
+ "audio.aria.mute": "静音",
1074
+ "audio.aria.unmute": "取消静音",
1075
+ "audio.aria.loop_on": "开启循环",
1076
+ "audio.aria.loop_off": "关闭循环",
1077
+ "audio.aria.progress": "播放进度",
1078
+ "audio.aria.volume": "音量",
1079
+ // ─────── markdown ───────
1080
+ "markdown.load_failed": "Markdown 文件加载失败",
1081
+ "markdown.copy_code": "复制代码",
1082
+ "markdown.copied": "已复制",
1083
+ // ─────── json ───────
1084
+ "json.load_failed": "JSON 文件加载失败",
1085
+ "json.items": "items",
1086
+ "json.keys": "keys",
1087
+ // ─────── csv ───────
1088
+ "csv.loading": "加载 CSV 中...",
1089
+ "csv.load_failed": "CSV 文件加载失败",
1090
+ "csv.parse_failed": "CSV 解析失败",
1091
+ // ─────── xml ───────
1092
+ "xml.load_failed": "XML 文件加载失败",
1093
+ // ─────── subtitle / lyric ───────
1094
+ "subtitle.load_failed": "字幕文件加载失败",
1095
+ "subtitle.parse_failed": "字幕解析失败",
1096
+ "subtitle.lines": "lines",
1097
+ "subtitle.cues": "cues",
1098
+ "subtitle.meta.title": "标题",
1099
+ "subtitle.meta.artist": "艺术家",
1100
+ "subtitle.meta.album": "专辑",
1101
+ "subtitle.meta.author": "作者",
1102
+ "subtitle.meta.by": "制作",
1103
+ "subtitle.meta.length": "时长",
1104
+ "subtitle.meta.offset": "偏移",
1105
+ "subtitle.meta.editor": "编辑器",
1106
+ "subtitle.meta.version": "版本",
1107
+ // ─────── zip ───────
1108
+ "zip.load_failed": "ZIP 文件加载失败",
1109
+ "zip.parse_failed": "ZIP 解析失败",
1110
+ // ─────── text ───────
1111
+ "text.load_failed": "文本文件加载失败",
1112
+ // ─────── font ───────
1113
+ "font.loading": "加载字体中...",
1114
+ "font.load_failed": "字体文件加载失败",
1115
+ "font.parse_failed": "字体解析失败",
1116
+ "font.metadata_loading": "解析元数据中...",
1117
+ "font.metadata_unavailable": "元数据不可用",
1118
+ "font.meta.family": "字体家族",
1119
+ "font.meta.subfamily": "子系列",
1120
+ "font.meta.version": "版本",
1121
+ "font.meta.designer": "设计师",
1122
+ "font.meta.glyphs": "字形数量",
1123
+ "font.meta.format": "格式",
1124
+ "font.sample_text_placeholder": "输入自定义文本..."
1125
+ }, qt = {
1126
+ // ─────── common ───────
1127
+ "common.download": "Download",
1128
+ "common.close": "Close",
1129
+ "common.loading": "Loading",
1130
+ "common.unknown_error": "Unknown error",
1131
+ "common.unsupported_preview": "Preview not supported for this file type ({type})",
1132
+ "common.retry": "Retry",
1133
+ // ─────── accessibility ───────
1134
+ "accessibility.previousFile": "Previous file",
1135
+ "accessibility.nextFile": "Next file",
1136
+ "accessibility.closePreview": "Close preview",
1137
+ "accessibility.downloadFile": "Download file",
1138
+ // ─────── toolbar ───────
1139
+ "toolbar.zoom_in": "Zoom in",
1140
+ "toolbar.zoom_out": "Zoom out",
1141
+ "toolbar.rotate_left": "Rotate left",
1142
+ "toolbar.rotate_right": "Rotate right",
1143
+ "toolbar.reset": "Reset",
1144
+ "toolbar.fit_to_window": "Fit to window",
1145
+ "toolbar.original_size": "Original size",
1146
+ "toolbar.toc": "Table of contents",
1147
+ "toolbar.outline": "Outline",
1148
+ "toolbar.prev_page": "Previous page",
1149
+ "toolbar.next_page": "Next page",
1150
+ "toolbar.full_width": "Full width",
1151
+ "toolbar.normal_width": "Normal width",
1152
+ "toolbar.wrap_on": "Word wrap",
1153
+ "toolbar.wrap_off": "No wrap",
1154
+ "toolbar.source": "Source",
1155
+ "toolbar.preview": "Preview",
1156
+ // ─────── image ───────
1157
+ "image.load_failed": "Failed to load image",
1158
+ "image.decode_failed": "Failed to decode image",
1159
+ // ─────── pdf ───────
1160
+ "pdf.load_failed": "Failed to load PDF",
1161
+ // ─────── docx ───────
1162
+ "docx.parse_failed": "Failed to parse Word document",
1163
+ // ─────── xlsx ───────
1164
+ "xlsx.loading": "Loading Excel...",
1165
+ "xlsx.load_failed": "Failed to load Excel",
1166
+ "xlsx.parse_failed": "Failed to parse Excel file",
1167
+ "xlsx.not_found": "Excel file not found",
1168
+ // ─────── pptx ───────
1169
+ "pptx.loading": "Loading PPT...",
1170
+ "pptx.load_failed": "Failed to load PPT",
1171
+ "pptx.parse_failed": "Failed to parse PPT file",
1172
+ "pptx.not_found": "PPT file not found",
1173
+ "pptx.invalid_format": "PPT file format is invalid or corrupted",
1174
+ "pptx.no_pages": "PPT file has no valid pages",
1175
+ "pptx.timeout": "Loading timed out, please check your network and retry",
1176
+ // ─────── msg ───────
1177
+ "msg.parse_failed": "Failed to parse Outlook message",
1178
+ "msg.parse_failed_short": "Failed to parse message",
1179
+ "msg.empty_body": "(No message body)",
1180
+ // ─────── epub ───────
1181
+ "epub.load_failed": "Failed to load EPUB",
1182
+ // ─────── mobi ───────
1183
+ "mobi.load_failed": "Failed to load ebook — file may be corrupted or DRM-protected",
1184
+ // ─────── video ───────
1185
+ "video.loading": "Loading video...",
1186
+ "video.load_failed": "Failed to load video",
1187
+ "video.load_failed_with_error": "Failed to load video: {error}",
1188
+ "video.format_not_supported": "Browser does not support {format} format. Please convert to MP4/WebM",
1189
+ "video.unsupported_title": "This video format cannot be played in the browser",
1190
+ "video.unsupported_detail": "{format} is a container/codec that browsers do not natively support (typical for AVI / WMV / FLV and some MKV files). Please download and play it in a local player, or convert to MP4 (H.264 + AAC).",
1191
+ "video.codec_not_supported_detail": "The video or audio codec ({codecs}) cannot be decoded by the browser. Please convert to MP4 (H.264 + AAC) before previewing.",
1192
+ // ─────── audio (aria-label) ───────
1193
+ "audio.aria.play": "Play",
1194
+ "audio.aria.pause": "Pause",
1195
+ "audio.aria.forward_10": "Forward 10 seconds",
1196
+ "audio.aria.backward_10": "Back 10 seconds",
1197
+ "audio.aria.mute": "Mute",
1198
+ "audio.aria.unmute": "Unmute",
1199
+ "audio.aria.loop_on": "Enable loop",
1200
+ "audio.aria.loop_off": "Disable loop",
1201
+ "audio.aria.progress": "Playback progress",
1202
+ "audio.aria.volume": "Volume",
1203
+ // ─────── markdown ───────
1204
+ "markdown.load_failed": "Failed to load Markdown",
1205
+ "markdown.copy_code": "Copy code",
1206
+ "markdown.copied": "Copied",
1207
+ // ─────── json ───────
1208
+ "json.load_failed": "Failed to load JSON",
1209
+ "json.items": "items",
1210
+ "json.keys": "keys",
1211
+ // ─────── csv ───────
1212
+ "csv.loading": "Loading CSV...",
1213
+ "csv.load_failed": "Failed to load CSV",
1214
+ "csv.parse_failed": "Failed to parse CSV",
1215
+ // ─────── xml ───────
1216
+ "xml.load_failed": "Failed to load XML",
1217
+ // ─────── subtitle / lyric ───────
1218
+ "subtitle.load_failed": "Failed to load subtitle",
1219
+ "subtitle.parse_failed": "Failed to parse subtitle",
1220
+ "subtitle.lines": "lines",
1221
+ "subtitle.cues": "cues",
1222
+ "subtitle.meta.title": "Title",
1223
+ "subtitle.meta.artist": "Artist",
1224
+ "subtitle.meta.album": "Album",
1225
+ "subtitle.meta.author": "Author",
1226
+ "subtitle.meta.by": "By",
1227
+ "subtitle.meta.length": "Length",
1228
+ "subtitle.meta.offset": "Offset",
1229
+ "subtitle.meta.editor": "Editor",
1230
+ "subtitle.meta.version": "Version",
1231
+ // ─────── zip ───────
1232
+ "zip.load_failed": "Failed to load ZIP",
1233
+ "zip.parse_failed": "Failed to parse ZIP",
1234
+ // ─────── text ───────
1235
+ "text.load_failed": "Failed to load text file",
1236
+ // ─────── font ───────
1237
+ "font.loading": "Loading font...",
1238
+ "font.load_failed": "Failed to load font",
1239
+ "font.parse_failed": "Failed to parse font",
1240
+ "font.metadata_loading": "Parsing metadata...",
1241
+ "font.metadata_unavailable": "Metadata unavailable",
1242
+ "font.meta.family": "Family",
1243
+ "font.meta.subfamily": "Subfamily",
1244
+ "font.meta.version": "Version",
1245
+ "font.meta.designer": "Designer",
1246
+ "font.meta.glyphs": "Glyphs",
1247
+ "font.meta.format": "Format",
1248
+ "font.sample_text_placeholder": "Type custom text..."
1249
+ }, B = {
1250
+ "zh-CN": Gt,
1251
+ "en-US": qt
1252
+ }, Kt = /\{(\w+)\}/g;
1253
+ function Xt(e, t) {
1254
+ return t ? e.replace(Kt, (o, r) => {
1255
+ const n = t[r];
1256
+ return n === void 0 ? `{${r}}` : String(n);
1257
+ }) : e;
1258
+ }
1259
+ function ae(e) {
1260
+ var t;
1261
+ const o = e.fallbackLocale ?? "zh-CN", r = B[e.locale] ?? B[o] ?? B["zh-CN"], n = (t = e.messages) == null ? void 0 : t[e.locale], a = n ? { ...r, ...n } : r, i = B["zh-CN"];
1262
+ return (l, s) => {
1263
+ const f = a[l] ?? i[l] ?? l;
1264
+ return Xt(f, s);
1265
+ };
1266
+ }
1267
+ const Jt = {
1268
+ // 标准图片格式
1269
+ jpg: "image/jpeg",
1270
+ jpeg: "image/jpeg",
1271
+ png: "image/png",
1272
+ gif: "image/gif",
1273
+ webp: "image/webp",
1274
+ svg: "image/svg+xml",
1275
+ bmp: "image/bmp",
1276
+ ico: "image/x-icon",
1277
+ // 高级图片格式
1278
+ heic: "image/heic",
1279
+ heif: "image/heif",
1280
+ avif: "image/avif",
1281
+ tif: "image/tiff",
1282
+ tiff: "image/tiff",
1283
+ // RAW 格式
1284
+ cr2: "image/x-canon-cr2",
1285
+ nef: "image/x-nikon-nef",
1286
+ arw: "image/x-sony-arw",
1287
+ dng: "image/x-adobe-dng",
1288
+ raf: "image/x-fuji-raf",
1289
+ orf: "image/x-olympus-orf",
1290
+ // 其他专业格式
1291
+ psd: "image/vnd.adobe.photoshop",
1292
+ jp2: "image/jp2",
1293
+ jpx: "image/jpx",
1294
+ j2k: "image/jp2",
1295
+ // 文档格式
1296
+ pdf: "application/pdf",
1297
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
1298
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1299
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
1300
+ ppt: "application/vnd.ms-powerpoint",
1301
+ // 其他
1302
+ msg: "application/vnd.ms-outlook",
1303
+ epub: "application/epub+zip",
1304
+ mobi: "application/x-mobipocket-ebook",
1305
+ azw: "application/vnd.amazon.ebook",
1306
+ azw3: "application/vnd.amazon.ebook",
1307
+ kf8: "application/vnd.amazon.ebook",
1308
+ csv: "text/csv",
1309
+ tsv: "text/tab-separated-values",
1310
+ xml: "application/xml",
1311
+ json: "application/json",
1312
+ md: "text/markdown",
1313
+ markdown: "text/markdown",
1314
+ txt: "text/plain",
1315
+ zip: "application/zip",
1316
+ // 字体
1317
+ ttf: "font/ttf",
1318
+ otf: "font/otf",
1319
+ woff: "font/woff",
1320
+ woff2: "font/woff2",
1321
+ // 视频
1322
+ mp4: "video/mp4",
1323
+ webm: "video/webm",
1324
+ ogg: "video/ogg",
1325
+ ogv: "video/ogg",
1326
+ mov: "video/quicktime",
1327
+ avi: "video/x-msvideo",
1328
+ mkv: "video/x-matroska",
1329
+ m4v: "video/mp4",
1330
+ "3gp": "video/3gpp",
1331
+ flv: "video/x-flv",
1332
+ // 音频
1333
+ mp3: "audio/mpeg",
1334
+ wav: "audio/wav",
1335
+ m4a: "audio/mp4",
1336
+ flac: "audio/flac",
1337
+ aac: "audio/aac",
1338
+ // 字幕
1339
+ srt: "application/x-subrip",
1340
+ vtt: "text/vtt",
1341
+ lrc: "application/x-lrc",
1342
+ elrc: "application/x-lrc",
1343
+ ass: "text/x-ssa",
1344
+ ssa: "text/x-ssa",
1345
+ ttml: "application/ttml+xml",
1346
+ dfxp: "application/ttml+xml"
1347
+ };
1348
+ function Yt(e) {
1349
+ const t = e.toLowerCase();
1350
+ return Jt[t] || "application/octet-stream";
1351
+ }
1352
+ function Qt(e) {
1353
+ var t;
1354
+ const o = ((t = e.split(".").pop()) == null ? void 0 : t.toLowerCase()) || "";
1355
+ return Yt(o);
1356
+ }
1357
+ function eo(e) {
1358
+ return [
1359
+ "image/heic",
1360
+ "image/heif",
1361
+ "image/avif",
1362
+ "image/tiff",
1363
+ "image/x-canon-cr2",
1364
+ "image/x-nikon-nef",
1365
+ "image/x-sony-arw",
1366
+ "image/x-adobe-dng",
1367
+ "image/x-fuji-raf",
1368
+ "image/x-olympus-orf",
1369
+ "image/vnd.adobe.photoshop",
1370
+ "image/jp2",
1371
+ "image/jpx"
1372
+ ].includes(e);
1373
+ }
1374
+ const J = /* @__PURE__ */ new Map();
1375
+ async function wr(e) {
1376
+ if (J.has(e))
1377
+ return J.get(e);
1378
+ if (!eo(e))
1379
+ return null;
1380
+ try {
1381
+ let t = null;
1382
+ return e === "image/heic" || e === "image/heif" ? t = (await import("./heicLoader-CH_raQNn-1fBLaICM.mjs")).default : e === "image/avif" ? t = (await import("./avifLoader-BP3fgcMm-BnpxLhxp.mjs")).default : e === "image/tiff" ? t = (await import("./tiffLoader-CTFKVLqJ-B84NfwhR.mjs")).default : e === "image/x-canon-cr2" || e === "image/x-nikon-nef" || e === "image/x-sony-arw" || e === "image/x-adobe-dng" || e === "image/x-fuji-raf" || e === "image/x-olympus-orf" ? t = (await import("./rawLoader-0mLvxCNp-CJmERiK7.mjs")).default : e === "image/vnd.adobe.photoshop" ? t = (await import("./psdLoader-Doxw3mWm-DVOGFSlh.mjs")).default : (e === "image/jp2" || e === "image/jpx") && (t = (await import("./jp2Loader-Bn-qPMbD-Bn-qPMbD.mjs")).default), t && J.set(e, t), t;
1383
+ } catch (t) {
1384
+ return console.warn(`Failed to load image decoder for ${e}:`, t), null;
1385
+ }
1386
+ }
1387
+ async function vr(e) {
1388
+ if (e.type && e.type !== "application/octet-stream")
1389
+ return e.type;
1390
+ const t = Qt(e.name);
1391
+ if (t !== "application/octet-stream")
1392
+ return t;
1393
+ if (e instanceof Blob || e instanceof File) {
1394
+ const o = await to(e);
1395
+ if (o !== "application/octet-stream")
1396
+ return o;
1397
+ }
1398
+ return "application/octet-stream";
1399
+ }
1400
+ async function to(e) {
1401
+ try {
1402
+ const t = new Uint8Array(await e.slice(0, 12).arrayBuffer());
1403
+ if (t[4] === 102 && t[5] === 116 && t[6] === 121 && t[7] === 112) {
1404
+ const o = String.fromCharCode(...t.slice(8, 12));
1405
+ if (o === "heic" || o === "heix" || o === "mif1")
1406
+ return "image/heic";
1407
+ }
1408
+ if (t[0] === 73 && t[1] === 73 && t[2] === 42 && t[3] === 0 || t[0] === 77 && t[1] === 77 && t[2] === 0 && t[3] === 42)
1409
+ return "image/tiff";
1410
+ if (t[4] === 102 && t[5] === 116 && t[6] === 121 && t[7] === 112 && String.fromCharCode(...t.slice(8, 12)) === "avif")
1411
+ return "image/avif";
1412
+ if (t[0] === 56 && t[1] === 66 && t[2] === 80 && t[3] === 83)
1413
+ return "image/vnd.adobe.photoshop";
1414
+ if (t[0] === 255 && t[1] === 79 && t[2] === 255 && t[3] === 81)
1415
+ return "image/jp2";
1416
+ } catch (t) {
1417
+ console.warn("Failed to detect image format by magic number:", t);
1418
+ }
1419
+ return "application/octet-stream";
1420
+ }
1421
+ const ne = ee(null), oo = ({
1422
+ locale: e = "zh-CN",
1423
+ messages: t,
1424
+ children: o
1425
+ }) => {
1426
+ const r = D(() => {
1427
+ const n = ae({ locale: e, messages: t });
1428
+ return { locale: e, t: n };
1429
+ }, [e, t]);
1430
+ return /* @__PURE__ */ p(ne.Provider, { value: r, children: o });
1431
+ };
1432
+ let Y = null;
1433
+ function ro() {
1434
+ return Y || (Y = ae({ locale: "zh-CN" })), Y;
1435
+ }
1436
+ function Me() {
1437
+ const e = Z(ne);
1438
+ return (e == null ? void 0 : e.t) ?? ro();
1439
+ }
1440
+ function yr() {
1441
+ const e = Z(ne);
1442
+ return (e == null ? void 0 : e.locale) ?? "zh-CN";
1443
+ }
1444
+ const ze = ee(null), ao = ({ theme: e, children: t }) => /* @__PURE__ */ p(ze.Provider, { value: e, children: t });
1445
+ function xr() {
1446
+ return Z(ze) ?? "dark";
1447
+ }
1448
+ const no = {
1449
+ fetcher: (e, t) => fetch(e, t)
1450
+ }, ie = ee(no), io = ({
1451
+ requestInit: e,
1452
+ requestHandler: t,
1453
+ shouldFetchAsBlob: o,
1454
+ children: r
1455
+ }) => {
1456
+ const n = D(
1457
+ () => ({
1458
+ fetcher: Pt({ requestInit: e, requestHandler: t }),
1459
+ shouldFetchAsBlob: o
1460
+ }),
1461
+ [e, t, o]
1462
+ );
1463
+ return /* @__PURE__ */ p(ie.Provider, { value: n, children: r });
1464
+ };
1465
+ function lo() {
1466
+ return Z(ie).fetcher;
1467
+ }
1468
+ function so(e) {
1469
+ const { fetcher: t, shouldFetchAsBlob: o } = Z(ie), r = !!(e && (o != null && o(e))), [n, a] = z(""), i = $(null);
1470
+ return S(() => {
1471
+ if (!e || !r) {
1472
+ i.current && (URL.revokeObjectURL(i.current), i.current = null), a("");
1473
+ return;
1474
+ }
1475
+ let l = !1;
1476
+ return a(""), kt(e.url, t).then((s) => {
1477
+ if (l) {
1478
+ URL.revokeObjectURL(s);
1479
+ return;
1480
+ }
1481
+ i.current && URL.revokeObjectURL(i.current), i.current = s, a(s);
1482
+ }).catch((s) => {
1483
+ l || (console.error("[file-preview] resolve blob url failed:", s), a(e.url));
1484
+ }), () => {
1485
+ l = !0;
1486
+ };
1487
+ }, [e == null ? void 0 : e.id, e == null ? void 0 : e.url, r, t]), S(() => () => {
1488
+ i.current && (URL.revokeObjectURL(i.current), i.current = null);
1489
+ }, []), e ? r ? n : e.url : "";
1490
+ }
1491
+ const we = ({
1492
+ fileName: e,
1493
+ fileType: t,
1494
+ onDownload: o
1495
+ }) => {
1496
+ const r = Me();
1497
+ return /* @__PURE__ */ k("div", { className: "rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-p-6 rfp-gap-4", children: [
1498
+ /* @__PURE__ */ p("div", { className: "rfp-w-20 rfp-h-20 rfp-rounded-full rfp-bg-surface-2 rfp-flex rfp-items-center rfp-justify-center", children: /* @__PURE__ */ p(st, { className: "rfp-w-10 rfp-h-10 rfp-text-fg-secondary" }) }),
1499
+ /* @__PURE__ */ k("div", { className: "rfp-text-fg-primary rfp-text-center", children: [
1500
+ /* @__PURE__ */ p("p", { className: "rfp-text-lg rfp-font-medium rfp-mb-2", children: e }),
1501
+ /* @__PURE__ */ p("p", { className: "rfp-text-fg-secondary", children: r("common.unsupported_preview", { type: t }) })
1502
+ ] }),
1503
+ /* @__PURE__ */ k(
1504
+ "button",
1505
+ {
1506
+ onClick: o,
1507
+ className: "rfp-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-backdrop-blur-sm rfp-rounded-lg rfp-text-fg-primary rfp-font-medium rfp-transition-all",
1508
+ children: [
1509
+ /* @__PURE__ */ p(te, { className: "rfp-w-5 rfp-h-5" }),
1510
+ r("common.download")
1511
+ ]
1512
+ }
1513
+ )
1514
+ ] });
1515
+ }, We = {
1516
+ common: {
1517
+ zoom: 1,
1518
+ rotation: 0
1519
+ },
1520
+ image: {
1521
+ naturalWidth: 0,
1522
+ naturalHeight: 0,
1523
+ resetKey: 0
1524
+ },
1525
+ pdf: {
1526
+ currentPage: 1,
1527
+ totalPages: 0,
1528
+ showOutline: !1
1529
+ },
1530
+ epub: {
1531
+ current: 0,
1532
+ total: 0,
1533
+ fullWidth: !1
1534
+ },
1535
+ mobi: {
1536
+ current: 0,
1537
+ total: 0,
1538
+ fullWidth: !1
1539
+ },
1540
+ zip: {
1541
+ stats: null
1542
+ },
1543
+ text: {
1544
+ wordWrap: !0,
1545
+ htmlPreview: !1
1546
+ },
1547
+ markdown: {
1548
+ viewMode: "preview"
1549
+ }
1550
+ };
1551
+ function po(e, t) {
1552
+ switch (t.type) {
1553
+ case "RESET":
1554
+ return We;
1555
+ case "SET_ZOOM":
1556
+ return {
1557
+ ...e,
1558
+ common: { ...e.common, zoom: t.payload }
1559
+ };
1560
+ case "SET_ROTATION":
1561
+ return {
1562
+ ...e,
1563
+ common: { ...e.common, rotation: t.payload }
1564
+ };
1565
+ case "SET_IMAGE_NATURAL_SIZE":
1566
+ return {
1567
+ ...e,
1568
+ image: {
1569
+ ...e.image,
1570
+ naturalWidth: t.payload.width,
1571
+ naturalHeight: t.payload.height
1572
+ }
1573
+ };
1574
+ case "RESET_IMAGE":
1575
+ return {
1576
+ ...e,
1577
+ common: { ...e.common, zoom: 1, rotation: 0 },
1578
+ image: { ...e.image, resetKey: e.image.resetKey + 1 }
1579
+ };
1580
+ case "SET_PDF_PAGE":
1581
+ return {
1582
+ ...e,
1583
+ pdf: { ...e.pdf, currentPage: t.payload }
1584
+ };
1585
+ case "SET_PDF_TOTAL_PAGES":
1586
+ return {
1587
+ ...e,
1588
+ pdf: { ...e.pdf, totalPages: t.payload }
1589
+ };
1590
+ case "SET_PDF_OUTLINE":
1591
+ return {
1592
+ ...e,
1593
+ pdf: { ...e.pdf, showOutline: t.payload }
1594
+ };
1595
+ case "SET_EPUB_CHAPTER":
1596
+ return {
1597
+ ...e,
1598
+ epub: {
1599
+ ...e.epub,
1600
+ current: t.payload.current,
1601
+ total: t.payload.total
1602
+ }
1603
+ };
1604
+ case "SET_EPUB_FULL_WIDTH":
1605
+ return {
1606
+ ...e,
1607
+ epub: { ...e.epub, fullWidth: t.payload }
1608
+ };
1609
+ case "SET_MOBI_CHAPTER":
1610
+ return {
1611
+ ...e,
1612
+ mobi: {
1613
+ ...e.mobi,
1614
+ current: t.payload.current,
1615
+ total: t.payload.total
1616
+ }
1617
+ };
1618
+ case "SET_MOBI_FULL_WIDTH":
1619
+ return {
1620
+ ...e,
1621
+ mobi: { ...e.mobi, fullWidth: t.payload }
1622
+ };
1623
+ case "SET_ZIP_STATS":
1624
+ return {
1625
+ ...e,
1626
+ zip: { stats: t.payload }
1627
+ };
1628
+ case "SET_TEXT_WORD_WRAP":
1629
+ return {
1630
+ ...e,
1631
+ text: { ...e.text, wordWrap: t.payload }
1632
+ };
1633
+ case "SET_TEXT_HTML_PREVIEW":
1634
+ return {
1635
+ ...e,
1636
+ text: { ...e.text, htmlPreview: t.payload }
1637
+ };
1638
+ case "SET_MARKDOWN_VIEW_MODE":
1639
+ return {
1640
+ ...e,
1641
+ markdown: { viewMode: t.payload }
1642
+ };
1643
+ default:
1644
+ return e;
1645
+ }
1646
+ }
1647
+ function fo(e) {
1648
+ const [t, o] = rt(po, We);
1649
+ return S(() => {
1650
+ o({ type: "RESET" });
1651
+ }, [e]), { state: t, dispatch: o };
1652
+ }
1653
+ function co({
1654
+ mode: e,
1655
+ currentIndex: t,
1656
+ totalFiles: o,
1657
+ onNavigate: r,
1658
+ onClose: n,
1659
+ rootRef: a
1660
+ }) {
1661
+ const i = $({ onNavigate: r, onClose: n });
1662
+ S(() => {
1663
+ i.current = { onNavigate: r, onClose: n };
1664
+ }, [r, n]), S(() => {
1665
+ const l = (s) => {
1666
+ const { onNavigate: f, onClose: c } = i.current;
1667
+ s.key === "Escape" && e === "modal" ? c == null || c() : s.key === "ArrowLeft" && t > 0 ? f == null || f(t - 1) : s.key === "ArrowRight" && t < o - 1 && (f == null || f(t + 1));
1668
+ };
1669
+ if (e === "modal")
1670
+ return window.addEventListener("keydown", l), () => window.removeEventListener("keydown", l);
1671
+ {
1672
+ const s = a == null ? void 0 : a.current;
1673
+ return s ? (s.addEventListener("keydown", l), () => s.removeEventListener("keydown", l)) : void 0;
1674
+ }
1675
+ }, [e, t, o, a]);
1676
+ }
1677
+ function ve(e) {
1678
+ const t = $(null), [o, r] = z(0), [n, a] = z(0), [i, l] = z(!1), s = F(
1679
+ (f, c) => {
1680
+ r(f), a(c);
1681
+ },
1682
+ [e]
1683
+ );
1684
+ return {
1685
+ ref: t,
1686
+ current: o,
1687
+ total: n,
1688
+ fullWidth: i,
1689
+ setFullWidth: l,
1690
+ handleChapterChange: s
1691
+ };
1692
+ }
1693
+ function uo(e) {
1694
+ const [t, o] = z(
1695
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
1696
+ );
1697
+ return S(() => {
1698
+ if (e !== "auto") return;
1699
+ const r = window.matchMedia("(prefers-color-scheme: dark)"), n = (a) => o(a.matches);
1700
+ return r.addEventListener("change", n), () => r.removeEventListener("change", n);
1701
+ }, [e]), e === "auto" ? t ? "dark" : "light" : e;
1702
+ }
1703
+ function mo({
1704
+ enabled: e,
1705
+ naturalWidth: t,
1706
+ naturalHeight: o,
1707
+ containerRef: r,
1708
+ onZoomChange: n
1709
+ }) {
1710
+ S(() => {
1711
+ if (!e || t <= 0 || o <= 0 || !r.current)
1712
+ return;
1713
+ const a = r.current.clientWidth, i = r.current.clientHeight, l = a / t, s = i / o, f = Math.min(l, s);
1714
+ n(Math.max(0.01, Math.min(10, f)));
1715
+ }, [e, t, o, r, n]);
1716
+ }
1717
+ const ho = ({ className: e }) => /* @__PURE__ */ p(
1718
+ "svg",
1719
+ {
1720
+ xmlns: "http://www.w3.org/2000/svg",
1721
+ viewBox: "0 0 24 24",
1722
+ fill: "none",
1723
+ stroke: "currentColor",
1724
+ strokeWidth: "2",
1725
+ strokeLinecap: "round",
1726
+ strokeLinejoin: "round",
1727
+ className: e,
1728
+ children: /* @__PURE__ */ p("text", { x: "12", y: "17.5", textAnchor: "middle", fontSize: "20", fontWeight: "bold", fill: "currentColor", stroke: "none", children: "1:1" })
1729
+ }
1730
+ );
1731
+ function go(e) {
1732
+ return [
1733
+ {
1734
+ items: [
1735
+ { type: "button", icon: /* @__PURE__ */ p(Fe, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.zoom_out"), action: e.onZoomOut, disabled: e.zoom <= 0.01 },
1736
+ { type: "text", content: `${Math.round(e.zoom * 100)}%`, minWidth: "3rem" },
1737
+ { type: "button", icon: /* @__PURE__ */ p(Te, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.zoom_in"), action: e.onZoomIn, disabled: e.zoom >= 10 }
1738
+ ]
1739
+ },
1740
+ {
1741
+ items: [
1742
+ { type: "button", icon: /* @__PURE__ */ p(pt, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.fit_to_window"), action: e.onFitToWidth },
1743
+ { type: "button", icon: /* @__PURE__ */ p(ho, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.original_size"), action: e.onOriginalSize }
1744
+ ]
1745
+ },
1746
+ {
1747
+ items: [
1748
+ { type: "button", icon: /* @__PURE__ */ p(ft, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.rotate_left"), action: e.onRotateLeft },
1749
+ { type: "button", icon: /* @__PURE__ */ p(Pe, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.rotate_right"), action: e.onRotateRight }
1750
+ ]
1751
+ },
1752
+ {
1753
+ items: [
1754
+ { type: "button", icon: /* @__PURE__ */ p(ke, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.reset"), action: e.onReset }
1755
+ ]
1756
+ }
1757
+ ];
1758
+ }
1759
+ function bo(e) {
1760
+ const t = [];
1761
+ return e.onToggleOutline && t.push({
1762
+ items: [
1763
+ { type: "button", icon: /* @__PURE__ */ p(oe, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.outline"), action: e.onToggleOutline }
1764
+ ]
1765
+ }), t.push({
1766
+ items: [
1767
+ { type: "button", icon: /* @__PURE__ */ p(q, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.prev_page"), action: e.onPrevPage, disabled: e.currentPage <= 1 },
1768
+ { type: "text", content: `${e.currentPage} / ${e.totalPages}`, minWidth: "4rem" },
1769
+ { type: "button", icon: /* @__PURE__ */ p(K, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.next_page"), action: e.onNextPage, disabled: e.currentPage >= e.totalPages }
1770
+ ]
1771
+ }), t.push({
1772
+ items: [
1773
+ { type: "button", icon: /* @__PURE__ */ p(Fe, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.zoom_out"), action: e.onZoomOut, disabled: e.zoom <= 0.01 },
1774
+ { type: "text", content: `${Math.round(e.zoom * 100)}%`, minWidth: "3rem" },
1775
+ { type: "button", icon: /* @__PURE__ */ p(Te, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.zoom_in"), action: e.onZoomIn, disabled: e.zoom >= 10 }
1776
+ ]
1777
+ }), t.push({
1778
+ items: [
1779
+ { type: "button", icon: /* @__PURE__ */ p(ke, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.reset"), action: e.onReset }
1780
+ ]
1781
+ }), t;
1782
+ }
1783
+ function wo(e) {
1784
+ return [
1785
+ {
1786
+ items: [
1787
+ { type: "button", icon: /* @__PURE__ */ p(oe, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.toc"), action: () => {
1788
+ var t;
1789
+ return (t = e.epubRef.current) == null ? void 0 : t.toggleToc();
1790
+ } }
1791
+ ]
1792
+ },
1793
+ {
1794
+ items: [
1795
+ { type: "button", icon: /* @__PURE__ */ p(q, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.prev_page"), action: () => {
1796
+ var t;
1797
+ return (t = e.epubRef.current) == null ? void 0 : t.prevPage();
1798
+ } },
1799
+ { type: "text", content: `${e.current} / ${e.total}`, minWidth: "4rem" },
1800
+ { type: "button", icon: /* @__PURE__ */ p(K, { className: "rfp-w-4 rfp-h-4" }), tooltip: e.t("toolbar.next_page"), action: () => {
1801
+ var t;
1802
+ return (t = e.epubRef.current) == null ? void 0 : t.nextPage();
1803
+ } }
1804
+ ]
1805
+ },
1806
+ {
1807
+ items: [
1808
+ {
1809
+ type: "button",
1810
+ icon: e.fullWidth ? /* @__PURE__ */ p(Ee, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(Ne, { className: "rfp-w-4 rfp-h-4" }),
1811
+ tooltip: e.fullWidth ? e.t("toolbar.normal_width") : e.t("toolbar.full_width"),
1812
+ action: () => {
1813
+ var t;
1814
+ return (t = e.epubRef.current) == null ? void 0 : t.toggleFullWidth();
1815
+ }
1816
+ }
1817
+ ]
1818
+ }
1819
+ ];
1820
+ }
1821
+ function vo(e) {
1822
+ return [
1823
+ {
1824
+ items: [
1825
+ {
1826
+ type: "button",
1827
+ icon: /* @__PURE__ */ p(oe, { className: "rfp-w-4 rfp-h-4" }),
1828
+ tooltip: e.t("toolbar.toc"),
1829
+ action: () => {
1830
+ var t;
1831
+ return (t = e.mobiRef.current) == null ? void 0 : t.toggleToc();
1832
+ }
1833
+ }
1834
+ ]
1835
+ },
1836
+ {
1837
+ items: [
1838
+ {
1839
+ type: "button",
1840
+ icon: /* @__PURE__ */ p(q, { className: "rfp-w-4 rfp-h-4" }),
1841
+ tooltip: e.t("toolbar.prev_page"),
1842
+ action: () => {
1843
+ var t;
1844
+ return (t = e.mobiRef.current) == null ? void 0 : t.prevPage();
1845
+ }
1846
+ },
1847
+ {
1848
+ type: "text",
1849
+ content: `${e.current} / ${e.total}`,
1850
+ minWidth: "4rem"
1851
+ },
1852
+ {
1853
+ type: "button",
1854
+ icon: /* @__PURE__ */ p(K, { className: "rfp-w-4 rfp-h-4" }),
1855
+ tooltip: e.t("toolbar.next_page"),
1856
+ action: () => {
1857
+ var t;
1858
+ return (t = e.mobiRef.current) == null ? void 0 : t.nextPage();
1859
+ }
1860
+ }
1861
+ ]
1862
+ },
1863
+ {
1864
+ items: [
1865
+ {
1866
+ type: "button",
1867
+ icon: e.fullWidth ? /* @__PURE__ */ p(Ee, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(Ne, { className: "rfp-w-4 rfp-h-4" }),
1868
+ tooltip: e.fullWidth ? e.t("toolbar.normal_width") : e.t("toolbar.full_width"),
1869
+ action: () => {
1870
+ var t;
1871
+ return (t = e.mobiRef.current) == null ? void 0 : t.toggleFullWidth();
1872
+ }
1873
+ }
1874
+ ]
1875
+ }
1876
+ ];
1877
+ }
1878
+ function yo({ stats: e }) {
1879
+ return e ? [
1880
+ {
1881
+ items: [
1882
+ {
1883
+ type: "text",
1884
+ content: `${e.files} files · ${e.dirs} dirs · ${xt(e.size)}`,
1885
+ minWidth: "10rem"
1886
+ }
1887
+ ]
1888
+ }
1889
+ ] : [];
1890
+ }
1891
+ function xo(e) {
1892
+ const t = [
1893
+ {
1894
+ items: [
1895
+ {
1896
+ type: "button",
1897
+ icon: /* @__PURE__ */ p(ct, { className: "rfp-w-4 rfp-h-4" }),
1898
+ tooltip: e.wordWrap ? e.t("toolbar.wrap_off") : e.t("toolbar.wrap_on"),
1899
+ action: e.onToggleWrap
1900
+ }
1901
+ ]
1902
+ }
1903
+ ];
1904
+ return e.isHtml && t.push({
1905
+ items: [
1906
+ {
1907
+ type: "button",
1908
+ icon: e.htmlPreview ? /* @__PURE__ */ p(Ce, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(Re, { className: "rfp-w-4 rfp-h-4" }),
1909
+ tooltip: e.htmlPreview ? e.t("toolbar.source") : e.t("toolbar.preview"),
1910
+ action: e.onToggleHtmlPreview
1911
+ }
1912
+ ]
1913
+ }), t;
1914
+ }
1915
+ function _o(e) {
1916
+ return [
1917
+ {
1918
+ items: [
1919
+ {
1920
+ type: "button",
1921
+ icon: e.viewMode === "preview" ? /* @__PURE__ */ p(Ce, { className: "rfp-w-4 rfp-h-4" }) : /* @__PURE__ */ p(Re, { className: "rfp-w-4 rfp-h-4" }),
1922
+ tooltip: e.viewMode === "preview" ? e.t("toolbar.source") : e.t("toolbar.preview"),
1923
+ action: e.onToggleViewMode
1924
+ }
1925
+ ]
1926
+ }
1927
+ ];
1928
+ }
1929
+ const Fo = {
1930
+ image: (e) => go({
1931
+ zoom: e.state.common.zoom,
1932
+ onZoomIn: e.onZoomIn,
1933
+ onZoomOut: e.onZoomOut,
1934
+ onFitToWidth: e.onFitToWidth,
1935
+ onOriginalSize: e.onOriginalSize,
1936
+ onRotateLeft: e.onRotateLeft,
1937
+ onRotateRight: e.onRotateRight,
1938
+ onReset: e.onReset,
1939
+ t: e.t
1940
+ }),
1941
+ pdf: (e) => bo({
1942
+ zoom: e.state.common.zoom,
1943
+ currentPage: e.state.pdf.currentPage,
1944
+ totalPages: e.state.pdf.totalPages || 0,
1945
+ onZoomIn: e.onZoomIn,
1946
+ onZoomOut: e.onZoomOut,
1947
+ onReset: e.onReset,
1948
+ onPrevPage: e.onPrevPage,
1949
+ onNextPage: e.onNextPage,
1950
+ onToggleOutline: e.onToggleOutline,
1951
+ t: e.t
1952
+ }),
1953
+ epub: (e) => wo({
1954
+ epubRef: e.epubRef,
1955
+ current: e.epubCurrent ?? e.state.epub.current,
1956
+ total: e.epubTotal ?? e.state.epub.total,
1957
+ fullWidth: e.epubFullWidth ?? e.state.epub.fullWidth,
1958
+ t: e.t
1959
+ }),
1960
+ mobi: (e) => vo({
1961
+ mobiRef: e.mobiRef,
1962
+ current: e.mobiCurrent ?? e.state.mobi.current,
1963
+ total: e.mobiTotal ?? e.state.mobi.total,
1964
+ fullWidth: e.mobiFullWidth ?? e.state.mobi.fullWidth,
1965
+ t: e.t
1966
+ }),
1967
+ zip: (e) => yo({ stats: e.state.zip.stats, t: e.t }),
1968
+ text: (e) => {
1969
+ var o;
1970
+ const t = ((o = e.fileName.split(".").pop()) == null ? void 0 : o.toLowerCase()) || "";
1971
+ return xo({
1972
+ wordWrap: e.state.text.wordWrap,
1973
+ onToggleWrap: e.onToggleWrap,
1974
+ isHtml: t === "html" || t === "htm",
1975
+ htmlPreview: e.state.text.htmlPreview,
1976
+ onToggleHtmlPreview: e.onToggleHtmlPreview,
1977
+ t: e.t
1978
+ });
1979
+ },
1980
+ markdown: (e) => _o({
1981
+ viewMode: e.state.markdown.viewMode,
1982
+ onToggleViewMode: e.onToggleViewMode,
1983
+ t: e.t
1984
+ })
1985
+ };
1986
+ function To(e, t) {
1987
+ const o = Fo[e];
1988
+ return o ? o(t) : [];
1989
+ }
1990
+ function Po({
1991
+ fileType: e,
1992
+ fileName: t,
1993
+ state: o,
1994
+ handlers: r,
1995
+ t: n,
1996
+ customRenderer: a,
1997
+ currentFile: i,
1998
+ customRendererContext: l
1999
+ }) {
2000
+ return D(() => {
2001
+ var s;
2002
+ return a ? ((s = a.getToolbarGroups) == null ? void 0 : s.call(a, i, l)) ?? [] : To(e, {
2003
+ state: o,
2004
+ t: n,
2005
+ fileName: t,
2006
+ ...r
2007
+ });
2008
+ }, [e, t, o, r, n, a, i, l]);
2009
+ }
2010
+ const ko = ({
2011
+ icon: e,
2012
+ label: t,
2013
+ onClick: o,
2014
+ disabled: r,
2015
+ ariaKeyshortcuts: n
2016
+ }) => /* @__PURE__ */ k(
2017
+ "button",
2018
+ {
2019
+ onClick: o,
2020
+ disabled: r,
2021
+ "aria-label": t,
2022
+ "aria-keyshortcuts": n,
2023
+ "aria-disabled": r,
2024
+ className: `rfp-relative rfp-group rfp-p-2 md:rfp-p-1.5 rfp-rounded-md rfp-transition-all rfp-select-none ${r ? "rfp-text-fg-disabled rfp-cursor-not-allowed" : "rfp-text-fg-primary hover:rfp-bg-surface-2 active:rfp-bg-surface-3"}`,
2025
+ children: [
2026
+ e,
2027
+ /* @__PURE__ */ k("span", { className: "rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 rfp-top-full rfp-mt-1.5 rfp-px-2 rfp-py-1 rfp-text-xs rfp-rounded rfp-whitespace-nowrap rfp-pointer-events-none rfp-opacity-0 rfp-invisible group-hover:rfp-opacity-100 group-hover:rfp-visible rfp-transition-opacity rfp-duration-200 rfp-z-50 rfp-bg-fg-primary rfp-text-fg-inverse max-[1023px]:!rfp-hidden", children: [
2028
+ /* @__PURE__ */ p("span", { className: "rfp-absolute rfp-left-1/2 -rfp-translate-x-1/2 -rfp-top-1 rfp-w-2 rfp-h-2 rfp-rotate-45 rfp-bg-fg-primary" }),
2029
+ /* @__PURE__ */ p("span", { className: "rfp-relative", children: t })
2030
+ ] })
2031
+ ]
2032
+ }
2033
+ );
2034
+ function V(e, t) {
2035
+ return e.map((o, r, n) => /* @__PURE__ */ k(_e.Fragment, { children: [
2036
+ o.items.map(
2037
+ (a, i) => a.type === "button" ? /* @__PURE__ */ p(
2038
+ ko,
2039
+ {
2040
+ icon: a.icon,
2041
+ label: a.tooltip,
2042
+ onClick: a.action,
2043
+ disabled: a.disabled,
2044
+ ariaKeyshortcuts: a.ariaKeyshortcuts
2045
+ },
2046
+ `${r}-${i}`
2047
+ ) : /* @__PURE__ */ p(
2048
+ "span",
2049
+ {
2050
+ className: "rfp-text-xs rfp-text-center rfp-font-medium rfp-tabular-nums rfp-text-fg-tertiary",
2051
+ style: { minWidth: a.minWidth || "auto" },
2052
+ children: a.content
2053
+ },
2054
+ `${r}-${i}`
2055
+ )
2056
+ ),
2057
+ r < n.length - 1 && /* @__PURE__ */ p("div", { className: `rfp-w-px rfp-h-4 rfp-bg-divide ${t}` })
2058
+ ] }, r));
2059
+ }
2060
+ const Eo = ({
2061
+ fileName: e,
2062
+ currentIndex: t,
2063
+ totalFiles: o,
2064
+ toolGroups: r,
2065
+ t: n,
2066
+ onDownload: a,
2067
+ onClose: i
2068
+ }) => {
2069
+ const l = !!i, s = [
2070
+ {
2071
+ items: [
2072
+ {
2073
+ type: "button",
2074
+ icon: /* @__PURE__ */ p(te, { className: "rfp-w-4 rfp-h-4" }),
2075
+ tooltip: n("accessibility.downloadFile"),
2076
+ action: a
2077
+ }
2078
+ ]
2079
+ },
2080
+ ...l ? [
2081
+ {
2082
+ items: [
2083
+ {
2084
+ type: "button",
2085
+ icon: /* @__PURE__ */ p(dt, { className: "rfp-w-4 rfp-h-4" }),
2086
+ tooltip: n("accessibility.closePreview"),
2087
+ action: i,
2088
+ ariaKeyshortcuts: "Escape"
2089
+ }
2090
+ ]
2091
+ }
2092
+ ] : []
2093
+ ];
2094
+ return /* @__PURE__ */ k(
2095
+ G.div,
2096
+ {
2097
+ initial: { opacity: 0 },
2098
+ animate: { opacity: 1 },
2099
+ exit: { opacity: 0 },
2100
+ className: "rfp-flex-shrink-0 rfp-z-10 rfp-backdrop-blur-md rfp-border-b rfp-bg-surface-toolbar rfp-border-line",
2101
+ style: { paddingTop: "env(safe-area-inset-top, 0px)" },
2102
+ children: [
2103
+ /* @__PURE__ */ k("div", { className: "rfp-flex rfp-items-center rfp-justify-between rfp-px-3 md:rfp-px-5 rfp-py-1.5 md:rfp-py-2.5", children: [
2104
+ /* @__PURE__ */ k("div", { className: "rfp-flex rfp-items-center rfp-flex-1 rfp-min-w-0 rfp-mr-2 md:rfp-mr-3", children: [
2105
+ /* @__PURE__ */ p("h2", { className: "rfp-font-medium rfp-text-xs md:rfp-text-sm rfp-truncate rfp-text-fg-primary", children: e }),
2106
+ /* @__PURE__ */ k(
2107
+ "span",
2108
+ {
2109
+ className: "rfp-text-xs rfp-ml-2 rfp-flex-shrink-0 rfp-text-fg-muted",
2110
+ "aria-live": "polite",
2111
+ "aria-atomic": "true",
2112
+ children: [
2113
+ t + 1,
2114
+ "/",
2115
+ o
2116
+ ]
2117
+ }
2118
+ )
2119
+ ] }),
2120
+ /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-gap-1 md:rfp-hidden rfp-flex-shrink-0", children: V(s, "rfp-mx-0.5") }),
2121
+ /* @__PURE__ */ k("div", { className: "rfp-hidden md:rfp-flex rfp-items-center rfp-gap-1 rfp-flex-shrink-0", children: [
2122
+ V(r, "rfp-mx-1"),
2123
+ r.length > 0 && /* @__PURE__ */ p("div", { className: "rfp-w-px rfp-h-4 rfp-mx-1 rfp-bg-divide" }),
2124
+ V(s, "rfp-mx-1")
2125
+ ] })
2126
+ ] }),
2127
+ r.length > 0 && /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-gap-1 rfp-px-3 rfp-pb-1.5 rfp-overflow-x-auto scrollbar-hide md:rfp-hidden", children: V(r, "rfp-mx-0.5") })
2128
+ ]
2129
+ }
2130
+ );
2131
+ }, ye = ({
2132
+ error: e,
2133
+ fileName: t,
2134
+ t: o,
2135
+ onRetry: r,
2136
+ onDownload: n
2137
+ }) => /* @__PURE__ */ k("div", { className: "rfp-flex rfp-flex-col rfp-items-center rfp-justify-center rfp-h-full rfp-px-4 rfp-text-fg-primary", children: [
2138
+ /* @__PURE__ */ p(ut, { className: "rfp-w-16 rfp-h-16 rfp-mb-4 rfp-text-error" }),
2139
+ /* @__PURE__ */ p("h3", { className: "rfp-text-lg rfp-font-semibold rfp-mb-2", children: o("common.unknown_error") }),
2140
+ /* @__PURE__ */ p("p", { className: "rfp-text-sm rfp-text-fg-secondary rfp-mb-1 rfp-max-w-md rfp-text-center", children: e.message }),
2141
+ /* @__PURE__ */ p("p", { className: "rfp-text-xs rfp-text-fg-tertiary rfp-mb-6 rfp-max-w-md rfp-text-center", children: t }),
2142
+ /* @__PURE__ */ k("div", { className: "rfp-flex rfp-gap-3", children: [
2143
+ /* @__PURE__ */ k(
2144
+ "button",
2145
+ {
2146
+ onClick: r,
2147
+ "aria-label": o("common.retry"),
2148
+ className: "rfp-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-rounded-md rfp-text-sm rfp-font-medium rfp-transition-colors",
2149
+ children: [
2150
+ /* @__PURE__ */ p(Pe, { className: "rfp-w-4 rfp-h-4" }),
2151
+ o("common.retry")
2152
+ ]
2153
+ }
2154
+ ),
2155
+ /* @__PURE__ */ k(
2156
+ "button",
2157
+ {
2158
+ onClick: n,
2159
+ "aria-label": o("accessibility.downloadFile"),
2160
+ className: "rfp-flex rfp-items-center rfp-gap-2 rfp-px-4 rfp-py-2 rfp-bg-surface-2 hover:rfp-bg-surface-3 rfp-rounded-md rfp-text-sm rfp-font-medium rfp-transition-colors",
2161
+ children: [
2162
+ /* @__PURE__ */ p(te, { className: "rfp-w-4 rfp-h-4" }),
2163
+ o("common.download")
2164
+ ]
2165
+ }
2166
+ )
2167
+ ] })
2168
+ ] });
2169
+ class xe extends _e.Component {
2170
+ constructor(o) {
2171
+ super(o);
2172
+ ce(this, "reset", () => {
2173
+ this.setState({ hasError: !1, error: null });
2174
+ });
2175
+ this.state = { hasError: !1, error: null };
2176
+ }
2177
+ static getDerivedStateFromError(o) {
2178
+ return { hasError: !0, error: o };
2179
+ }
2180
+ componentDidCatch(o, r) {
2181
+ var n, a;
2182
+ console.error("[file-preview] Renderer error:", o, r), (a = (n = this.props).onError) == null || a.call(n, o, r);
2183
+ }
2184
+ render() {
2185
+ return this.state.hasError && this.state.error ? this.props.fallback(this.state.error, this.reset) : this.props.children;
2186
+ }
2187
+ }
2188
+ const No = () => {
2189
+ const e = Me();
2190
+ return /* @__PURE__ */ p("div", { className: "rfp-flex rfp-items-center rfp-justify-center rfp-w-full rfp-h-full rfp-text-fg-muted", children: /* @__PURE__ */ k("div", { className: "rfp-flex rfp-flex-col rfp-items-center rfp-gap-3", children: [
2191
+ /* @__PURE__ */ p("div", { className: "rfp-w-8 rfp-h-8 rfp-rounded-full rfp-border-2 rfp-border-fg-muted rfp-border-t-transparent rfp-animate-spin" }),
2192
+ /* @__PURE__ */ p("span", { className: "rfp-text-sm", children: e("common.loading") ?? "Loading..." })
2193
+ ] }) });
2194
+ }, Co = ({
2195
+ currentFile: e,
2196
+ customRenderer: t,
2197
+ customRendererContext: o,
2198
+ t: r,
2199
+ onDownload: n,
2200
+ onError: a,
2201
+ children: i
2202
+ }) => t ? /* @__PURE__ */ p(
2203
+ xe,
2204
+ {
2205
+ fallback: (l, s) => /* @__PURE__ */ p(
2206
+ ye,
2207
+ {
2208
+ error: l,
2209
+ fileName: e.name,
2210
+ t: r,
2211
+ onRetry: s,
2212
+ onDownload: n
2213
+ }
2214
+ ),
2215
+ onError: a,
2216
+ children: t.render(e, o)
2217
+ }
2218
+ ) : /* @__PURE__ */ p(at, { fallback: /* @__PURE__ */ p(No, {}), children: /* @__PURE__ */ p(
2219
+ xe,
2220
+ {
2221
+ fallback: (l, s) => /* @__PURE__ */ p(
2222
+ ye,
2223
+ {
2224
+ error: l,
2225
+ fileName: e.name,
2226
+ t: r,
2227
+ onRetry: s,
2228
+ onDownload: n
2229
+ }
2230
+ ),
2231
+ onError: a,
2232
+ children: i
2233
+ }
2234
+ ) }, e.url), Ro = 2e3, So = ({
2235
+ containerRef: e,
2236
+ hasPrev: t,
2237
+ hasNext: o,
2238
+ onPrev: r,
2239
+ onNext: n,
2240
+ resetKey: a,
2241
+ t: i
2242
+ }) => {
2243
+ const [l, s] = z(!0), f = $(null), c = F(() => {
2244
+ f.current && clearTimeout(f.current), f.current = window.setTimeout(() => s(!1), Ro);
2245
+ }, []), d = F(() => {
2246
+ s((m) => m || !0), c();
2247
+ }, [c]);
2248
+ return S(() => {
2249
+ const m = e.current;
2250
+ if (!m) return;
2251
+ const u = () => d();
2252
+ return m.addEventListener("mousemove", u), () => {
2253
+ m.removeEventListener("mousemove", u);
2254
+ };
2255
+ }, [e, d]), S(() => (s(!0), c(), () => {
2256
+ f.current && clearTimeout(f.current);
2257
+ }), [a, c]), /* @__PURE__ */ k(ot, { children: [
2258
+ t && /* @__PURE__ */ p(
2259
+ G.button,
2260
+ {
2261
+ initial: { opacity: 0 },
2262
+ animate: { opacity: l ? 1 : 0, x: l ? 0 : -20 },
2263
+ transition: { duration: 0.2 },
2264
+ onClick: r,
2265
+ onMouseEnter: d,
2266
+ style: { pointerEvents: l ? "auto" : "none" },
2267
+ "aria-label": i("accessibility.previousFile") || "上一个文件",
2268
+ "aria-keyshortcuts": "ArrowLeft",
2269
+ className: "rfp-absolute rfp-z-20 rfp-left-2 md:rfp-left-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",
2270
+ children: /* @__PURE__ */ p(q, { className: "rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6" })
2271
+ }
2272
+ ),
2273
+ o && /* @__PURE__ */ p(
2274
+ G.button,
2275
+ {
2276
+ initial: { opacity: 0 },
2277
+ animate: { opacity: l ? 1 : 0, x: l ? 0 : 20 },
2278
+ transition: { duration: 0.2 },
2279
+ onClick: n,
2280
+ onMouseEnter: d,
2281
+ style: { pointerEvents: l ? "auto" : "none" },
2282
+ "aria-label": i("accessibility.nextFile") || "下一个文件",
2283
+ "aria-keyshortcuts": "ArrowRight",
2284
+ className: "rfp-absolute rfp-z-20 rfp-right-2 md:rfp-right-4 rfp-top-1/2 -rfp-translate-y-1/2 rfp-w-10 rfp-h-10 md:rfp-w-12 md:rfp-h-12 rfp-rounded-full rfp-backdrop-blur-xl rfp-border rfp-flex rfp-items-center rfp-justify-center rfp-transition-colors rfp-shadow-2xl rfp-bg-surface-nav rfp-border-line hover:rfp-bg-surface-nav-hover rfp-text-fg-primary",
2285
+ children: /* @__PURE__ */ p(K, { className: "rfp-w-5 rfp-h-5 md:rfp-w-6 md:rfp-h-6" })
2286
+ }
2287
+ )
2288
+ ] });
2289
+ }, Mo = E(
2290
+ () => import("./index-CWKbnvW6.mjs").then((e) => ({ default: e.ImageRenderer }))
2291
+ ), zo = E(
2292
+ () => import("./index-Dv3RQz86.mjs").then((e) => ({ default: e.PdfRenderer }))
2293
+ ), Wo = E(
2294
+ () => import("./index-0v5STX5f.mjs").then((e) => ({ default: e.DocxRenderer }))
2295
+ ), jo = E(
2296
+ () => import("./index-DuP0Tlpo.mjs").then((e) => ({ default: e.XlsxRenderer }))
2297
+ ), Oo = E(
2298
+ () => import("./index-DoFsoBKL.mjs").then((e) => ({ default: e.PptxRenderer }))
2299
+ ), Lo = E(
2300
+ () => import("./index-DaAXRBWL.mjs").then((e) => ({ default: e.MsgRenderer }))
2301
+ ), Ao = E(
2302
+ () => import("./index-Cbz5Z6ZK.mjs").then((e) => ({ default: e.EpubRenderer }))
2303
+ ), Do = E(
2304
+ () => import("./index-gjSQeou7.mjs").then((e) => ({ default: e.MobiRenderer }))
2305
+ ), Io = E(
2306
+ () => import("./index-Bo90aGhy.mjs").then((e) => ({ default: e.VideoRenderer }))
2307
+ ), $o = E(
2308
+ () => import("./index-10O8tfTH.mjs").then((e) => ({ default: e.AudioRenderer }))
2309
+ ), Zo = E(
2310
+ () => import("./index-BCyv1HM9.mjs").then((e) => ({ default: e.MarkdownRenderer }))
2311
+ ), Uo = E(
2312
+ () => import("./index-CzM2mxrD.mjs").then((e) => ({ default: e.JsonRenderer }))
2313
+ ), Ho = E(
2314
+ () => import("./index-kALp0tqz.mjs").then((e) => ({ default: e.CsvRenderer }))
2315
+ ), Bo = E(
2316
+ () => import("./index-kCeSnFs-.mjs").then((e) => ({ default: e.XmlRenderer }))
2317
+ ), Vo = E(
2318
+ () => import("./index-C_BJatqr.mjs").then((e) => ({ default: e.SubtitleRenderer }))
2319
+ ), Go = E(
2320
+ () => import("./index-DTYBFuAH.mjs").then((e) => ({ default: e.ZipRenderer }))
2321
+ ), qo = E(
2322
+ () => import("./index-QfpHck8N.mjs").then((e) => ({ default: e.TextRenderer }))
2323
+ ), Ko = E(
2324
+ () => import("./index-Cp68OevR.mjs").then((e) => ({ default: e.FontRenderer }))
2325
+ ), Xo = 3, le = (e) => {
2326
+ const { requestInit: t, requestHandler: o, shouldFetchAsBlob: r } = e;
2327
+ return /* @__PURE__ */ p(
2328
+ io,
2329
+ {
2330
+ requestInit: t,
2331
+ requestHandler: o,
2332
+ shouldFetchAsBlob: r,
2333
+ children: /* @__PURE__ */ p(Jo, { ...e })
2334
+ }
2335
+ );
2336
+ }, Jo = ({
2337
+ files: e,
2338
+ currentIndex: t,
2339
+ onNavigate: o,
2340
+ customRenderers: r = [],
2341
+ mode: n = "modal",
2342
+ onClose: a,
2343
+ zipNestingDepth: i = 0,
2344
+ locale: l = "zh-CN",
2345
+ messages: s,
2346
+ headless: f = !1,
2347
+ theme: c = "dark",
2348
+ onCustomEvent: d,
2349
+ onDownload: m,
2350
+ onError: u,
2351
+ requestInit: _,
2352
+ requestHandler: T,
2353
+ shouldFetchAsBlob: C
2354
+ }) => {
2355
+ const y = D(
2356
+ () => ae({ locale: l, messages: s }),
2357
+ [l, s]
2358
+ ), P = D(() => vt(e), [e]), h = P[t], w = so(h), N = lo(), R = D(() => h ? r.find((v) => v.test(h)) : null, [h, r]), x = h ? yt(h) : "unsupported", U = uo(c), { state: g, dispatch: b } = fo(t), M = $(null), se = $(null), W = ve(), j = ve();
2359
+ co({
2360
+ mode: n,
2361
+ currentIndex: t,
2362
+ totalFiles: P.length,
2363
+ onNavigate: o,
2364
+ onClose: a,
2365
+ rootRef: se
2366
+ }), mo({
2367
+ enabled: x === "image",
2368
+ naturalWidth: g.image.naturalWidth,
2369
+ naturalHeight: g.image.naturalHeight,
2370
+ containerRef: M,
2371
+ onZoomChange: (v) => b({ type: "SET_ZOOM", payload: v })
2372
+ });
2373
+ const pe = F(
2374
+ (v, O) => {
2375
+ h && (d == null || d({ name: v, payload: O, file: h }));
2376
+ },
2377
+ [h, d]
2378
+ ), fe = D(
2379
+ () => ({ emit: pe, t: y, theme: U, locale: l }),
2380
+ [pe, y, U, l]
2381
+ ), je = F(() => {
2382
+ b({ type: "SET_ZOOM", payload: Math.min(g.common.zoom + 0.1, 10) });
2383
+ }, [g.common.zoom, b]), Oe = F(() => {
2384
+ b({ type: "SET_ZOOM", payload: Math.max(g.common.zoom - 0.1, 0.01) });
2385
+ }, [g.common.zoom, b]), Le = F(() => {
2386
+ b({ type: "SET_ROTATION", payload: g.common.rotation - 90 });
2387
+ }, [g.common.rotation, b]), Ae = F(() => {
2388
+ b({ type: "SET_ROTATION", payload: g.common.rotation + 90 });
2389
+ }, [g.common.rotation, b]), De = F(() => {
2390
+ if (M.current && g.image.naturalWidth > 0 && g.image.naturalHeight > 0) {
2391
+ const v = M.current.clientWidth, O = M.current.clientHeight, L = v / g.image.naturalWidth, A = O / g.image.naturalHeight, Qe = Math.min(L, A);
2392
+ b({ type: "SET_ZOOM", payload: Math.max(0.01, Math.min(10, Qe)) });
2393
+ } else
2394
+ b({ type: "SET_ZOOM", payload: 1 });
2395
+ b({ type: "SET_ROTATION", payload: 0 }), b({ type: "RESET_IMAGE" });
2396
+ }, [g.image.naturalWidth, g.image.naturalHeight, b]), Ie = F(() => {
2397
+ b({ type: "SET_ZOOM", payload: 1 }), b({ type: "SET_ROTATION", payload: 0 }), b({ type: "RESET_IMAGE" });
2398
+ }, [b]), $e = F(() => {
2399
+ b({ type: "SET_ZOOM", payload: 1 }), b({ type: "SET_ROTATION", payload: 0 }), b({ type: "RESET_IMAGE" });
2400
+ }, [b]), Ze = F(() => {
2401
+ var A;
2402
+ if (!M.current) return;
2403
+ const v = (A = M.current.querySelector(".rfp-overflow-auto [data-page-number]")) == null ? void 0 : A.parentElement;
2404
+ if (!v) return;
2405
+ const L = v.querySelectorAll("[data-page-number]")[Math.max(0, g.pdf.currentPage - 2)];
2406
+ L && L.scrollIntoView({ behavior: "smooth", block: "start" });
2407
+ }, [g.pdf.currentPage]), Ue = F(() => {
2408
+ var A;
2409
+ if (!M.current) return;
2410
+ const v = (A = M.current.querySelector(".rfp-overflow-auto [data-page-number]")) == null ? void 0 : A.parentElement;
2411
+ if (!v) return;
2412
+ const O = v.querySelectorAll("[data-page-number]"), L = O[Math.min(O.length - 1, g.pdf.currentPage)];
2413
+ L && L.scrollIntoView({ behavior: "smooth", block: "start" });
2414
+ }, [g.pdf.currentPage]), H = F(async () => {
2415
+ if (h) {
2416
+ if (m) {
2417
+ await m(h);
2418
+ return;
2419
+ }
2420
+ try {
2421
+ await Et(h.url, h.name, N);
2422
+ } catch (v) {
2423
+ console.error("[file-preview] download failed:", v);
2424
+ }
2425
+ }
2426
+ }, [h, m, N]), He = F(
2427
+ (v) => b({ type: "SET_PDF_PAGE", payload: v }),
2428
+ [b]
2429
+ ), Be = F(
2430
+ (v) => b({ type: "SET_PDF_TOTAL_PAGES", payload: v }),
2431
+ [b]
2432
+ ), Ve = F(
2433
+ (v) => b({
2434
+ type: "SET_IMAGE_NATURAL_SIZE",
2435
+ payload: { width: v, height: g.image.naturalHeight }
2436
+ }),
2437
+ [g.image.naturalHeight, b]
2438
+ ), Ge = F(
2439
+ () => b({ type: "SET_PDF_OUTLINE", payload: !g.pdf.showOutline }),
2440
+ [g.pdf.showOutline, b]
2441
+ ), qe = F(
2442
+ (v) => b({ type: "SET_ZOOM", payload: v }),
2443
+ [b]
2444
+ ), Ke = F(
2445
+ (v) => b({
2446
+ type: "SET_IMAGE_NATURAL_SIZE",
2447
+ payload: { width: v, height: g.image.naturalHeight }
2448
+ }),
2449
+ [g.image.naturalHeight, b]
2450
+ ), Xe = F(
2451
+ (v) => b({
2452
+ type: "SET_IMAGE_NATURAL_SIZE",
2453
+ payload: { width: g.image.naturalWidth, height: v }
2454
+ }),
2455
+ [g.image.naturalWidth, b]
2456
+ );
2457
+ if (!h) return null;
2458
+ const Je = {
2459
+ onZoomIn: je,
2460
+ onZoomOut: Oe,
2461
+ onRotateLeft: Le,
2462
+ onRotateRight: Ae,
2463
+ onReset: $e,
2464
+ onFitToWidth: De,
2465
+ onOriginalSize: Ie,
2466
+ onPrevPage: Ze,
2467
+ onNextPage: Ue,
2468
+ onToggleOutline: () => b({ type: "SET_PDF_OUTLINE", payload: !g.pdf.showOutline }),
2469
+ onToggleWrap: () => b({ type: "SET_TEXT_WORD_WRAP", payload: !g.text.wordWrap }),
2470
+ onToggleHtmlPreview: () => b({ type: "SET_TEXT_HTML_PREVIEW", payload: !g.text.htmlPreview }),
2471
+ onToggleViewMode: () => b({
2472
+ type: "SET_MARKDOWN_VIEW_MODE",
2473
+ payload: g.markdown.viewMode === "preview" ? "source" : "preview"
2474
+ }),
2475
+ epubRef: W.ref,
2476
+ mobiRef: j.ref,
2477
+ epubCurrent: W.current,
2478
+ epubTotal: W.total,
2479
+ epubFullWidth: W.fullWidth,
2480
+ mobiCurrent: j.current,
2481
+ mobiTotal: j.total,
2482
+ mobiFullWidth: j.fullWidth
2483
+ }, Ye = Po({
2484
+ fileType: x,
2485
+ fileName: h.name,
2486
+ state: g,
2487
+ handlers: Je,
2488
+ t: y,
2489
+ customRenderer: R,
2490
+ currentFile: h,
2491
+ customRendererContext: fe
2492
+ });
2493
+ return /* @__PURE__ */ p(oo, { locale: l, messages: s, children: /* @__PURE__ */ p(ao, { theme: U, children: /* @__PURE__ */ k(
2494
+ "div",
2495
+ {
2496
+ ref: se,
2497
+ tabIndex: n === "embed" ? 0 : -1,
2498
+ "data-theme": U,
2499
+ className: "rfp-relative rfp-w-full rfp-h-full rfp-flex rfp-flex-col rfp-overflow-hidden rfp-outline-none",
2500
+ children: [
2501
+ !f && /* @__PURE__ */ p(
2502
+ Eo,
2503
+ {
2504
+ fileName: h.name,
2505
+ currentIndex: t,
2506
+ totalFiles: P.length,
2507
+ toolGroups: Ye,
2508
+ t: y,
2509
+ onDownload: H,
2510
+ onClose: a
2511
+ }
2512
+ ),
2513
+ /* @__PURE__ */ p(
2514
+ "div",
2515
+ {
2516
+ ref: M,
2517
+ className: "rfp-flex-1 rfp-flex rfp-items-center rfp-justify-center rfp-overflow-auto",
2518
+ children: /* @__PURE__ */ k(
2519
+ Co,
2520
+ {
2521
+ currentFile: h,
2522
+ customRenderer: R,
2523
+ customRendererContext: fe,
2524
+ t: y,
2525
+ onDownload: H,
2526
+ onError: u,
2527
+ children: [
2528
+ x === "image" && /* @__PURE__ */ p(
2529
+ Mo,
2530
+ {
2531
+ url: w,
2532
+ zoom: g.common.zoom,
2533
+ rotation: g.common.rotation,
2534
+ resetKey: g.image.resetKey,
2535
+ fileSize: h.size,
2536
+ file: h,
2537
+ onZoomChange: qe,
2538
+ onNaturalWidthChange: Ke,
2539
+ onNaturalHeightChange: Xe
2540
+ }
2541
+ ),
2542
+ x === "pdf" && /* @__PURE__ */ p(
2543
+ zo,
2544
+ {
2545
+ url: w,
2546
+ zoom: g.common.zoom,
2547
+ currentPage: g.pdf.currentPage,
2548
+ showOutline: g.pdf.showOutline,
2549
+ onPageChange: He,
2550
+ onTotalPagesChange: Be,
2551
+ onPageWidthChange: Ve,
2552
+ onToggleOutline: Ge
2553
+ }
2554
+ ),
2555
+ x === "docx" && /* @__PURE__ */ p(Wo, { url: w }),
2556
+ x === "xlsx" && /* @__PURE__ */ p(jo, { url: w }),
2557
+ x === "pptx" && /* @__PURE__ */ p(Oo, { url: w }),
2558
+ x === "msg" && /* @__PURE__ */ p(Lo, { url: w }),
2559
+ x === "epub" && /* @__PURE__ */ p(
2560
+ Ao,
2561
+ {
2562
+ ref: W.ref,
2563
+ url: w,
2564
+ onChapterChange: W.handleChapterChange,
2565
+ onFullWidthChange: W.setFullWidth
2566
+ }
2567
+ ),
2568
+ x === "mobi" && /* @__PURE__ */ p(
2569
+ Do,
2570
+ {
2571
+ ref: j.ref,
2572
+ url: w,
2573
+ onChapterChange: j.handleChapterChange,
2574
+ onFullWidthChange: j.setFullWidth
2575
+ }
2576
+ ),
2577
+ x === "video" && /* @__PURE__ */ p(Io, { url: w, fileName: h.name }),
2578
+ x === "audio" && /* @__PURE__ */ p($o, { url: w, fileName: h.name }),
2579
+ x === "markdown" && /* @__PURE__ */ p(Zo, { url: w, viewMode: g.markdown.viewMode }),
2580
+ x === "json" && /* @__PURE__ */ p(Uo, { url: w, fileName: h.name }),
2581
+ x === "csv" && /* @__PURE__ */ p(Ho, { url: w, fileName: h.name }),
2582
+ x === "xml" && /* @__PURE__ */ p(Bo, { url: w, fileName: h.name }),
2583
+ x === "subtitle" && /* @__PURE__ */ p(Vo, { url: w, fileName: h.name }),
2584
+ x === "zip" && (i >= Xo ? /* @__PURE__ */ p(
2585
+ we,
2586
+ {
2587
+ fileName: h.name,
2588
+ fileType: h.type,
2589
+ onDownload: H
2590
+ }
2591
+ ) : /* @__PURE__ */ p(
2592
+ Go,
2593
+ {
2594
+ url: w,
2595
+ onStatsChange: (v) => b({ type: "SET_ZIP_STATS", payload: v }),
2596
+ nestingDepth: i
2597
+ }
2598
+ )),
2599
+ x === "text" && /* @__PURE__ */ p(
2600
+ qo,
2601
+ {
2602
+ url: w,
2603
+ fileName: h.name,
2604
+ wordWrap: g.text.wordWrap,
2605
+ htmlPreview: g.text.htmlPreview
2606
+ }
2607
+ ),
2608
+ x === "font" && /* @__PURE__ */ p(Ko, { url: w }),
2609
+ x === "unsupported" && /* @__PURE__ */ p(
2610
+ we,
2611
+ {
2612
+ fileName: h.name,
2613
+ fileType: h.type,
2614
+ onDownload: H
2615
+ }
2616
+ )
2617
+ ]
2618
+ }
2619
+ )
2620
+ }
2621
+ ),
2622
+ !f && P.length > 1 && /* @__PURE__ */ p(
2623
+ So,
2624
+ {
2625
+ containerRef: M,
2626
+ hasPrev: t > 0,
2627
+ hasNext: t < P.length - 1,
2628
+ onPrev: () => o == null ? void 0 : o(t - 1),
2629
+ onNext: () => o == null ? void 0 : o(t + 1),
2630
+ resetKey: t,
2631
+ t: y
2632
+ }
2633
+ )
2634
+ ]
2635
+ }
2636
+ ) }) });
2637
+ }, _r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2638
+ __proto__: null,
2639
+ FilePreviewContent: le
2640
+ }, Symbol.toStringTag, { value: "Module" })), Fr = ({
2641
+ files: e,
2642
+ currentIndex: t,
2643
+ isOpen: o,
2644
+ onClose: r,
2645
+ onNavigate: n,
2646
+ customRenderers: a = [],
2647
+ locale: i,
2648
+ messages: l,
2649
+ headless: s,
2650
+ theme: f = "dark",
2651
+ onCustomEvent: c,
2652
+ requestInit: d,
2653
+ requestHandler: m,
2654
+ shouldFetchAsBlob: u,
2655
+ onDownload: _
2656
+ }) => {
2657
+ const [T, C] = z(
2658
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
2659
+ );
2660
+ S(() => {
2661
+ if (f !== "auto") return;
2662
+ const h = window.matchMedia("(prefers-color-scheme: dark)"), w = (N) => C(N.matches);
2663
+ return h.addEventListener("change", w), () => h.removeEventListener("change", w);
2664
+ }, [f]);
2665
+ const y = f === "auto" ? T ? "dark" : "light" : f;
2666
+ if (S(() => {
2667
+ if (o) {
2668
+ const h = document.body.style.overflow, w = document.body.style.paddingRight, N = window.innerWidth - document.documentElement.clientWidth;
2669
+ return document.body.style.overflow = "hidden", N > 0 && (document.body.style.paddingRight = `${N}px`), () => {
2670
+ document.body.style.overflow = h, document.body.style.paddingRight = w;
2671
+ };
2672
+ }
2673
+ }, [o]), !o) return null;
2674
+ const P = /* @__PURE__ */ p("div", { className: "rfp-root", "data-theme": y, children: /* @__PURE__ */ p(it, { children: o && /* @__PURE__ */ p(
2675
+ G.div,
2676
+ {
2677
+ initial: { opacity: 0 },
2678
+ animate: { opacity: 1 },
2679
+ exit: { opacity: 0 },
2680
+ className: "rfp-fixed rfp-inset-0 rfp-z-[9999] rfp-flex rfp-items-center rfp-justify-center rfp-backdrop-blur-md rfp-overflow-hidden rfp-bg-surface-overlay",
2681
+ onClick: r,
2682
+ onWheel: (h) => h.stopPropagation(),
2683
+ children: /* @__PURE__ */ p(
2684
+ "div",
2685
+ {
2686
+ className: "rfp-relative rfp-w-full rfp-h-full",
2687
+ onClick: (h) => h.stopPropagation(),
2688
+ children: /* @__PURE__ */ p(
2689
+ le,
2690
+ {
2691
+ mode: "modal",
2692
+ files: e,
2693
+ currentIndex: t,
2694
+ onClose: r,
2695
+ onNavigate: n,
2696
+ customRenderers: a,
2697
+ locale: i,
2698
+ messages: l,
2699
+ headless: s,
2700
+ theme: f,
2701
+ onCustomEvent: c,
2702
+ requestInit: d,
2703
+ requestHandler: m,
2704
+ shouldFetchAsBlob: u,
2705
+ onDownload: _
2706
+ }
2707
+ )
2708
+ }
2709
+ )
2710
+ }
2711
+ ) }) });
2712
+ return nt(P, document.body);
2713
+ }, Tr = ({
2714
+ files: e,
2715
+ currentIndex: t = 0,
2716
+ onNavigate: o,
2717
+ customRenderers: r = [],
2718
+ width: n = "100%",
2719
+ height: a = "100%",
2720
+ className: i,
2721
+ style: l,
2722
+ locale: s,
2723
+ messages: f,
2724
+ headless: c,
2725
+ theme: d = "dark",
2726
+ onCustomEvent: m,
2727
+ requestInit: u,
2728
+ requestHandler: _,
2729
+ shouldFetchAsBlob: T,
2730
+ onDownload: C,
2731
+ onClose: y
2732
+ }) => {
2733
+ const [P, h] = z(
2734
+ () => typeof window < "u" ? window.matchMedia("(prefers-color-scheme: dark)").matches : !0
2735
+ );
2736
+ S(() => {
2737
+ if (d !== "auto") return;
2738
+ const N = window.matchMedia("(prefers-color-scheme: dark)"), R = (x) => h(x.matches);
2739
+ return N.addEventListener("change", R), () => N.removeEventListener("change", R);
2740
+ }, [d]);
2741
+ const w = d === "auto" ? P ? "dark" : "light" : d;
2742
+ return /* @__PURE__ */ p(
2743
+ "div",
2744
+ {
2745
+ className: `rfp-root ${i ?? ""}`,
2746
+ style: { width: n, height: a, ...l },
2747
+ "data-theme": w,
2748
+ children: /* @__PURE__ */ p("div", { className: "rfp-relative rfp-w-full rfp-h-full rfp-overflow-hidden rfp-bg-surface-overlay", children: /* @__PURE__ */ p(
2749
+ le,
2750
+ {
2751
+ mode: "embed",
2752
+ files: e,
2753
+ currentIndex: t,
2754
+ onNavigate: o,
2755
+ customRenderers: r,
2756
+ locale: s,
2757
+ messages: f,
2758
+ headless: c,
2759
+ theme: d,
2760
+ onCustomEvent: m,
2761
+ requestInit: u,
2762
+ requestHandler: _,
2763
+ shouldFetchAsBlob: T,
2764
+ onDownload: C,
2765
+ onClose: y
2766
+ }
2767
+ ) })
2768
+ }
2769
+ );
2770
+ };
2771
+ function Pr(e) {
2772
+ Vt(mt, e);
2773
+ }
2774
+ const kr = gt.version;
2775
+ export {
2776
+ mr as A,
2777
+ wt as B,
2778
+ xt as C,
2779
+ ur as D,
2780
+ pr as E,
2781
+ yt as F,
2782
+ vr as G,
2783
+ gr as I,
2784
+ oo as L,
2785
+ lr as M,
2786
+ fr as P,
2787
+ hr as R,
2788
+ sr as S,
2789
+ cr as T,
2790
+ br as U,
2791
+ kr as V,
2792
+ lo as a,
2793
+ xr as b,
2794
+ X as c,
2795
+ le as d,
2796
+ Tr as e,
2797
+ Fr as f,
2798
+ Pr as g,
2799
+ yr as h,
2800
+ _r as i,
2801
+ dr as j,
2802
+ wr as q,
2803
+ Me as u,
2804
+ nr as v,
2805
+ vt as w,
2806
+ ir as y
2807
+ };
2808
+ //# sourceMappingURL=index-CEeKt7L3.mjs.map