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