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