@eternalheart/vue-file-preview 1.6.11 → 1.6.13

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 (54) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/lib/FilePreviewContent.vue.d.ts +9 -1
  4. package/lib/FilePreviewEmbed.vue.d.ts +4 -1
  5. package/lib/FilePreviewModal.vue.d.ts +4 -1
  6. package/lib/chunks/EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs +20 -0
  7. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs +32 -0
  8. package/lib/chunks/{avifLoader-CAUzjn-d-Bv80osgL.mjs → avifLoader-CAUzjn-d-C0KRpetN.mjs} +1 -1
  9. package/lib/chunks/{heicLoader-D_9PukkA-c40agcEu.mjs → heicLoader-D_9PukkA-Czof_5FJ.mjs} +1 -1
  10. package/lib/chunks/{index-CO713RPO.mjs → index--612Smof.mjs} +118 -118
  11. package/lib/chunks/{index-Dw6YZA28.mjs → index-8Vpbg2kS.mjs} +2 -2
  12. package/lib/chunks/index-B21EAyWz.mjs +137 -0
  13. package/lib/chunks/{index-CrLeFRdr.mjs → index-BASg1cr4.mjs} +2 -2
  14. package/lib/chunks/index-BB0i4QqI.mjs +117 -0
  15. package/lib/chunks/{index-C92b547K.mjs → index-BVdrGK3Q.mjs} +80 -80
  16. package/lib/chunks/index-BlrFFeqc.mjs +330 -0
  17. package/lib/chunks/index-Bp9CuvMZ.mjs +157 -0
  18. package/lib/chunks/index-BuqPb5mP.mjs +306 -0
  19. package/lib/chunks/{index-Df-1MbYj.mjs → index-BvBqDq3O.mjs} +2 -2
  20. package/lib/chunks/{index-BkqPtbFz.mjs → index-Bxpf9v5j.mjs} +29 -29
  21. package/lib/chunks/{index-DpY9eMSI.mjs → index-C9mAajbD.mjs} +231 -226
  22. package/lib/chunks/{index-DTZVumT8.mjs → index-CDg6vIbT.mjs} +14 -14
  23. package/lib/chunks/{index-By8q8XPn.mjs → index-CWE-hKSs.mjs} +10 -10
  24. package/lib/chunks/{index-DbOpSm8f.mjs → index-CY3xzGgt.mjs} +19 -19
  25. package/lib/chunks/{index-C8pOqpTq.mjs → index-CxKZKUJj.mjs} +521 -523
  26. package/lib/chunks/{index-Cyg4lWK-.mjs → index-D30L8tm9.mjs} +12 -12
  27. package/lib/chunks/{index-DfC_cA90.mjs → index-DN4Ui0Gh.mjs} +24 -24
  28. package/lib/chunks/{index-B3uQ1OoT.mjs → index-DZZN3kYi.mjs} +832 -812
  29. package/lib/chunks/{index-BpKvjFVp.mjs → index-Dkro_8Fy.mjs} +20 -20
  30. package/lib/chunks/{index-B35jLxPz.mjs → index-VdzIFJJW.mjs} +26 -26
  31. package/lib/chunks/{index--D2MwF_x.mjs → index-aoXgVLBb.mjs} +10 -10
  32. package/lib/chunks/{jp2Loader-Dig19xyo-82PXw2fC.mjs → jp2Loader-Dig19xyo-CKUaGhPl.mjs} +1 -1
  33. package/lib/chunks/{psdLoader-C0tKUXXl-DRn7RYLA.mjs → psdLoader-C0tKUXXl-CYWoQis5.mjs} +1 -1
  34. package/lib/chunks/{rawLoader-C-tPeFAB-DP397Cnq.mjs → rawLoader-C-tPeFAB-C35zC8nZ.mjs} +1 -1
  35. package/lib/chunks/{tiffLoader-BlhByX8w-BC52z4Tf.mjs → tiffLoader-BlhByX8w-BOxg_Du5.mjs} +1 -1
  36. package/lib/chunks/{useShikiHighlight-DSyCygls.mjs → useShikiHighlight-BPmcxA-h.mjs} +1 -1
  37. package/lib/index.cjs +63 -63
  38. package/lib/index.css +1 -1
  39. package/lib/index.d.ts +1 -1
  40. package/lib/index.mjs +6 -6
  41. package/lib/renderers/Cad/toolbar.d.ts +1 -0
  42. package/lib/renderers/EmptyState.vue.d.ts +2 -0
  43. package/lib/renderers/Json/index.vue.d.ts +5 -0
  44. package/lib/renderers/Pptx/index.vue.d.ts +3 -0
  45. package/lib/renderers/Text/index.vue.d.ts +3 -0
  46. package/lib/renderers/Xlsx/index.vue.d.ts +3 -0
  47. package/lib/renderers/registry.d.ts +3 -1
  48. package/package.json +1 -1
  49. package/lib/chunks/RendererError.vue_vue_type_script_setup_true_lang-BNoENOWX.mjs +0 -30
  50. package/lib/chunks/index-2xdBoG-I.mjs +0 -141
  51. package/lib/chunks/index-B2xLxhp0.mjs +0 -133
  52. package/lib/chunks/index-DKJ_iQ70.mjs +0 -295
  53. package/lib/chunks/index-DMwZXKa4.mjs +0 -322
  54. package/lib/chunks/index-DyP3rhuf.mjs +0 -113
@@ -0,0 +1,330 @@
1
+ import { defineComponent as ue, ref as d, watch as Q, onMounted as ce, onBeforeUnmount as fe, openBlock as h, createElementBlock as m, createBlock as pe, createCommentVNode as S, createElementVNode as p, toDisplayString as L, unref as N, normalizeStyle as z, createVNode as ve, Fragment as O, renderList as Y } from "vue";
2
+ import de from "@likecoin/epub-ts";
3
+ import { List as he, ChevronLeft as me, ChevronRight as ge, Minimize2 as be, Maximize2 as xe, X as we } from "lucide-vue-next";
4
+ import { u as ye, c as ke } from "./index-DZZN3kYi.mjs";
5
+ import { _ as _e } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ import { T as Te } from "./base.types-DaftHyg7.mjs";
7
+ const ze = { class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-bg-surface-1 vfp-overflow-hidden" }, Ce = {
8
+ key: 1,
9
+ class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-z-10"
10
+ }, Se = { class: "vfp-renderer-loading-content" }, We = { class: "vfp-renderer-loading-text" }, Me = {
11
+ class: "vfp-flex vfp-items-center vfp-justify-between vfp-flex-shrink-0",
12
+ style: { padding: "12px 16px", "border-bottom": "1px solid rgba(255,255,255,0.1)" }
13
+ }, Ee = { style: { color: "white", "font-weight": "500", "font-size": "14px" } }, $e = {
14
+ class: "vfp-flex-1 vfp-overflow-y-auto",
15
+ style: { padding: "8px 4px" }
16
+ }, He = ["title", "onClick", "onMouseenter", "onMouseleave"], Re = ["title", "onClick", "onMouseenter", "onMouseleave"], Le = 794, qe = /* @__PURE__ */ ue({
17
+ __name: "index",
18
+ props: {
19
+ url: {}
20
+ },
21
+ setup(Z, { expose: ee }) {
22
+ const W = Z, q = new Te(), { t: v } = ye(), te = ke(), g = d(1), w = d(1), r = d(null), M = d(!0), y = d(null), b = d(!1), x = d([]), s = d(!1), A = d("");
23
+ Q([g, w, b, s, () => x.value.length], () => {
24
+ q.notify();
25
+ });
26
+ let c = null, e = null, k = 0, _ = null;
27
+ const G = () => {
28
+ var t;
29
+ try {
30
+ (t = e == null ? void 0 : e.destroy) == null || t.call(e);
31
+ } catch {
32
+ }
33
+ try {
34
+ c == null || c.destroy();
35
+ } catch {
36
+ }
37
+ e = null, c = null, k = 0, _ = null;
38
+ }, oe = () => {
39
+ e == null || e.prev();
40
+ }, ae = () => {
41
+ e == null || e.next();
42
+ }, re = () => {
43
+ b.value = !b.value, setTimeout(() => {
44
+ r.value && e && (e.resize(r.value.offsetWidth, r.value.offsetHeight), _ && e.display(_), P());
45
+ }, 350);
46
+ }, le = () => {
47
+ s.value = !s.value;
48
+ }, I = (t) => {
49
+ A.value = t, e == null || e.display(t), s.value = !1;
50
+ }, f = (t) => t === A.value;
51
+ ee({
52
+ getToolbarGroups: () => [
53
+ {
54
+ items: [
55
+ {
56
+ type: "button",
57
+ icon: he,
58
+ tooltip: v.value("toolbar.toc"),
59
+ action: le,
60
+ disabled: x.value.length === 0,
61
+ active: s.value
62
+ }
63
+ ]
64
+ },
65
+ {
66
+ items: [
67
+ {
68
+ type: "button",
69
+ icon: me,
70
+ tooltip: v.value("toolbar.prev_page"),
71
+ action: oe,
72
+ disabled: g.value <= 1
73
+ },
74
+ {
75
+ type: "text",
76
+ content: `${g.value} / ${w.value}`,
77
+ minWidth: "4rem"
78
+ },
79
+ {
80
+ type: "button",
81
+ icon: ge,
82
+ tooltip: v.value("toolbar.next_page"),
83
+ action: ae,
84
+ disabled: g.value >= w.value
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ items: [
90
+ {
91
+ type: "button",
92
+ icon: b.value ? be : xe,
93
+ tooltip: b.value ? v.value("toolbar.normal_width") : v.value("toolbar.full_width"),
94
+ action: re,
95
+ active: b.value
96
+ }
97
+ ]
98
+ }
99
+ ],
100
+ onToolbarChange: (t) => q.subscribe(t)
101
+ });
102
+ const V = async () => {
103
+ if (r.value) {
104
+ M.value = !0, y.value = null, x.value = [], s.value = !1, r.value.innerHTML = "", G();
105
+ try {
106
+ let t = W.url;
107
+ W.url.startsWith("blob:") && (t = await (await te.value(W.url)).arrayBuffer());
108
+ const l = de(t);
109
+ c = l;
110
+ const o = new Promise((a, n) => {
111
+ l.on("openFailed", (i) => {
112
+ n(i instanceof Error ? i : new Error("EPUB open failed"));
113
+ });
114
+ });
115
+ e = l.renderTo(r.value, {
116
+ manager: "continuous",
117
+ flow: "scrolled",
118
+ width: "100%",
119
+ height: "100%"
120
+ }), e.themes.register("default", {
121
+ body: {
122
+ background: "#ffffff !important",
123
+ color: "#1a1a1a !important",
124
+ "font-family": '"Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important',
125
+ "font-size": "16px !important",
126
+ "line-height": "2 !important",
127
+ padding: "40px 60px !important",
128
+ "max-width": "100% !important",
129
+ "box-sizing": "border-box !important",
130
+ "word-break": "break-word !important",
131
+ "overflow-wrap": "break-word !important"
132
+ },
133
+ p: { "text-indent": "2em !important", margin: "0.8em 0 !important" },
134
+ h1: { "text-align": "center !important", margin: "1.5em 0 1em !important" },
135
+ h2: { margin: "1.2em 0 0.8em !important" },
136
+ h3: { margin: "1em 0 0.6em !important" },
137
+ img: { "max-width": "100% !important", height: "auto !important" },
138
+ a: { color: "#2563eb !important", "text-decoration": "none !important" }
139
+ }), e.themes.select("default"), await Promise.race([c.ready, o]), c.locations.generate(1024).then(() => {
140
+ var i;
141
+ if (!c) return;
142
+ k = c.locations.length();
143
+ const a = e == null ? void 0 : e.currentLocation(), n = ((i = a == null ? void 0 : a.start) == null ? void 0 : i.location) ?? 0;
144
+ g.value = n + 1, w.value = k;
145
+ }).catch(() => {
146
+ });
147
+ const T = await Promise.race([c.loaded.navigation, o]);
148
+ Array.isArray(T == null ? void 0 : T.toc) && (x.value = T.toc), await Promise.race([e.display(), o]), M.value = !1, g.value = 1, w.value = k || 1, e.on("relocated", (a) => {
149
+ var j, U, J;
150
+ const n = a;
151
+ if ((j = n == null ? void 0 : n.start) != null && j.cfi && (_ = n.start.cfi), (U = n == null ? void 0 : n.start) != null && U.href) {
152
+ const B = n.start.href, D = [], K = (se) => {
153
+ for (const H of se) {
154
+ const R = H.href.split("#")[0];
155
+ R && (B === R || B.endsWith("/" + R) || B.endsWith(R)) && D.push(H.href), H.subitems && K(H.subitems);
156
+ }
157
+ };
158
+ K(x.value), D.length === 1 && (A.value = D[0]);
159
+ }
160
+ const i = (J = n == null ? void 0 : n.start) == null ? void 0 : J.location;
161
+ typeof i == "number" && k > 0 && (g.value = i + 1, w.value = k);
162
+ });
163
+ } catch (t) {
164
+ console.error(v.value("epub.load_failed") + ":", t), y.value = v.value("epub.load_failed"), M.value = !1;
165
+ }
166
+ }
167
+ };
168
+ let E = null, C = null, $ = { width: 0, height: 0 }, X = !0;
169
+ const ne = () => {
170
+ if (!(!r.value || !e)) {
171
+ if (e.resize(r.value.offsetWidth, r.value.offsetHeight), _)
172
+ try {
173
+ e.display(_);
174
+ } catch {
175
+ }
176
+ P();
177
+ }
178
+ }, ie = () => {
179
+ r.value && (E = new ResizeObserver(() => {
180
+ if (!r.value) return;
181
+ if (X) {
182
+ X = !1, $ = { width: r.value.offsetWidth, height: r.value.offsetHeight };
183
+ return;
184
+ }
185
+ const t = { width: r.value.offsetWidth, height: r.value.offsetHeight }, l = Math.abs($.width - t.width), o = Math.abs($.height - t.height);
186
+ l < 10 && o < 10 || ($ = t, C !== null && clearTimeout(C), C = window.setTimeout(ne, 350));
187
+ }), E.observe(r.value));
188
+ };
189
+ let u = null;
190
+ const F = () => {
191
+ var l;
192
+ if (!u) return;
193
+ const t = u;
194
+ if (t.scrollTop + t.clientHeight >= t.scrollHeight - 200)
195
+ try {
196
+ const o = e == null ? void 0 : e.manager;
197
+ (l = o == null ? void 0 : o.check) == null || l.call(o, 500, 500);
198
+ } catch {
199
+ }
200
+ }, P = () => {
201
+ u && (u.removeEventListener("scroll", F), u = null);
202
+ const t = () => {
203
+ var l;
204
+ u = ((l = r.value) == null ? void 0 : l.querySelector(".epub-container")) ?? null, u ? u.addEventListener("scroll", F, { passive: !0 }) : requestAnimationFrame(t);
205
+ };
206
+ requestAnimationFrame(t);
207
+ };
208
+ return ce(() => {
209
+ V(), ie(), P();
210
+ }), Q(() => W.url, (t) => {
211
+ t && V();
212
+ }), fe(() => {
213
+ E && E.disconnect(), C !== null && clearTimeout(C), u == null || u.removeEventListener("scroll", F), G();
214
+ }), (t, l) => (h(), m("div", ze, [
215
+ y.value ? (h(), pe(_e, {
216
+ key: 0,
217
+ message: y.value,
218
+ class: "vfp-absolute vfp-inset-0"
219
+ }, null, 8, ["message"])) : S("", !0),
220
+ M.value && !y.value ? (h(), m("div", Ce, [
221
+ p("div", Se, [
222
+ l[2] || (l[2] = p("div", { class: "vfp-renderer-spinner" }, null, -1)),
223
+ p("span", We, L(N(v)("common.loading")), 1)
224
+ ])
225
+ ])) : S("", !0),
226
+ x.value.length > 0 ? (h(), m("div", {
227
+ key: 2,
228
+ class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex",
229
+ style: z({ opacity: s.value ? 1 : 0, pointerEvents: s.value ? "auto" : "none", transition: "opacity 0.3s" })
230
+ }, [
231
+ p("div", {
232
+ class: "vfp-w-72 vfp-h-full vfp-flex vfp-flex-col",
233
+ style: z({
234
+ maxWidth: "80%",
235
+ background: "rgba(0,0,0,0.9)",
236
+ backdropFilter: "blur(12px)",
237
+ borderRight: "1px solid rgba(255,255,255,0.1)",
238
+ boxShadow: "0 25px 50px -12px rgba(0,0,0,0.25)",
239
+ transform: s.value ? "translateX(0)" : "translateX(-100%)",
240
+ transition: "transform 0.3s ease"
241
+ })
242
+ }, [
243
+ p("div", Me, [
244
+ p("span", Ee, L(N(v)("toolbar.toc")), 1),
245
+ p("button", {
246
+ style: { color: "rgba(255,255,255,0.6)", background: "none", border: "none", cursor: "pointer", padding: "4px" },
247
+ onClick: l[0] || (l[0] = (o) => s.value = !1)
248
+ }, [
249
+ ve(N(we), { style: { width: "16px", height: "16px" } })
250
+ ])
251
+ ]),
252
+ p("div", $e, [
253
+ (h(!0), m(O, null, Y(x.value, (o, T) => (h(), m(O, {
254
+ key: `${o.href}-${T}`
255
+ }, [
256
+ p("button", {
257
+ style: z({
258
+ width: "100%",
259
+ textAlign: "left",
260
+ padding: "8px 12px",
261
+ fontSize: "14px",
262
+ color: f(o.href) ? "white" : "rgba(255,255,255,0.7)",
263
+ fontWeight: f(o.href) ? "500" : "400",
264
+ background: f(o.href) ? "rgba(255,255,255,0.15)" : "none",
265
+ border: "none",
266
+ cursor: "pointer",
267
+ borderRadius: "4px",
268
+ overflow: "hidden",
269
+ textOverflow: "ellipsis",
270
+ whiteSpace: "nowrap",
271
+ display: "block",
272
+ transition: "all 0.15s"
273
+ }),
274
+ title: o.label,
275
+ onClick: (a) => I(o.href),
276
+ onMouseenter: (a) => !f(o.href) && (a.target.style.background = "rgba(255,255,255,0.1)"),
277
+ onMouseleave: (a) => !f(o.href) && (a.target.style.background = "none")
278
+ }, L(o.label.trim()), 45, He),
279
+ o.subitems && o.subitems.length > 0 ? (h(!0), m(O, { key: 0 }, Y(o.subitems, (a, n) => (h(), m("button", {
280
+ key: `${a.href}-${n}`,
281
+ style: z({
282
+ width: "100%",
283
+ textAlign: "left",
284
+ padding: "8px 12px 8px 28px",
285
+ fontSize: "13px",
286
+ color: f(a.href) ? "white" : "rgba(255,255,255,0.6)",
287
+ fontWeight: f(a.href) ? "500" : "400",
288
+ background: f(a.href) ? "rgba(255,255,255,0.15)" : "none",
289
+ border: "none",
290
+ cursor: "pointer",
291
+ borderRadius: "4px",
292
+ overflow: "hidden",
293
+ textOverflow: "ellipsis",
294
+ whiteSpace: "nowrap",
295
+ display: "block",
296
+ transition: "all 0.15s"
297
+ }),
298
+ title: a.label,
299
+ onClick: (i) => I(a.href),
300
+ onMouseenter: (i) => !f(a.href) && (i.target.style.background = "rgba(255,255,255,0.1)"),
301
+ onMouseleave: (i) => !f(a.href) && (i.target.style.background = "none")
302
+ }, L(a.label.trim()), 45, Re))), 128)) : S("", !0)
303
+ ], 64))), 128))
304
+ ])
305
+ ], 4),
306
+ p("div", {
307
+ class: "vfp-flex-1",
308
+ style: z({ background: s.value ? "rgba(0,0,0,0.3)" : "transparent", transition: "background 0.3s" }),
309
+ onClick: l[1] || (l[1] = (o) => s.value = !1)
310
+ }, null, 4)
311
+ ], 4)) : S("", !0),
312
+ y.value ? S("", !0) : (h(), m("div", {
313
+ key: 3,
314
+ ref_key: "viewerRef",
315
+ ref: r,
316
+ class: "vfp-h-full vfp-bg-surface-toolbar",
317
+ style: z({
318
+ width: b.value ? "100%" : `${Le}px`,
319
+ maxWidth: "100%",
320
+ transition: "width 0.3s ease",
321
+ boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
322
+ overflow: "hidden"
323
+ })
324
+ }, null, 4))
325
+ ]));
326
+ }
327
+ });
328
+ export {
329
+ qe as default
330
+ };
@@ -0,0 +1,157 @@
1
+ import { defineComponent as P, ref as v, onMounted as V, watch as q, onBeforeUnmount as A, computed as I, openBlock as p, createElementBlock as h, createElementVNode as k, toDisplayString as O, unref as C, createCommentVNode as T, createVNode as W, normalizeStyle as S } from "vue";
2
+ import { u as $, c as G, l as U, k as E, t as j, W as J } from "./index-DZZN3kYi.mjs";
3
+ import { init as D } from "pptx-preview";
4
+ import { _ as K } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ import { _ as Q } from "./EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs";
6
+ const X = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, Y = {
7
+ key: 0,
8
+ class: "vfp-renderer-overlay vfp-renderer-loading"
9
+ }, Z = { class: "vfp-renderer-loading-content" }, ee = { class: "vfp-renderer-loading-text" }, te = {
10
+ key: 1,
11
+ class: "vfp-renderer-overlay"
12
+ }, ie = {
13
+ key: 2,
14
+ class: "vfp-renderer-overlay"
15
+ }, se = /* @__PURE__ */ P({
16
+ __name: "index",
17
+ props: {
18
+ url: {},
19
+ tiled: { type: Boolean, default: !0 },
20
+ emptyHint: {}
21
+ },
22
+ setup(R, { expose: z }) {
23
+ const s = R, { t: o } = $(), H = G(), n = v(!0), u = v(null), m = v(!1), w = v(0), l = v(null);
24
+ let r = null, y = null, c = null, f = null, _ = { width: 0, height: 0 }, M = 9 / 16;
25
+ const g = () => {
26
+ var d;
27
+ if (!l.value) return { width: 960, height: 540 };
28
+ const t = l.value.clientWidth, e = ((d = l.value.parentElement) == null ? void 0 : d.clientWidth) || 0, i = t > 100 ? t : e > 100 ? e : 300, a = Math.floor(i * M);
29
+ return { width: i, height: a };
30
+ }, F = async () => {
31
+ if (!(!l.value || !c || w.value === 0))
32
+ try {
33
+ if (r)
34
+ try {
35
+ r.destroy();
36
+ } catch {
37
+ }
38
+ l.value.innerHTML = "";
39
+ const t = g();
40
+ r = D(l.value, {
41
+ width: t.width,
42
+ height: s.tiled ? t.height * w.value : t.height,
43
+ mode: s.tiled ? "list" : "slide"
44
+ }), await r.preview(c);
45
+ } catch {
46
+ }
47
+ }, B = async () => {
48
+ if (!l.value) return;
49
+ n.value = !0, u.value = null, m.value = !1;
50
+ let t = window.setTimeout(() => {
51
+ u.value = o.value("pptx.timeout"), n.value = !1;
52
+ }, 3e4);
53
+ try {
54
+ const e = await H.value(s.url, {
55
+ mode: "cors",
56
+ credentials: "omit",
57
+ redirect: "follow"
58
+ });
59
+ if (!e.ok)
60
+ throw e.status === 404 ? new Error(o.value("pptx.not_found")) : e.status === 403 ? new E("file.forbidden") : e.status >= 500 ? new E("file.server_error") : new E("file.load_failed_status", { status: e.status });
61
+ const i = await e.arrayBuffer();
62
+ if (i.byteLength === 0) {
63
+ t !== null && clearTimeout(t), m.value = !0, n.value = !1;
64
+ return;
65
+ }
66
+ c = i, M = (await j(i)).ratio;
67
+ const a = document.createElement("div");
68
+ a.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden", document.body.appendChild(a);
69
+ try {
70
+ const d = D(a, {
71
+ width: 100,
72
+ height: 100,
73
+ mode: "slide"
74
+ });
75
+ try {
76
+ await d.preview(i);
77
+ } catch {
78
+ throw new Error(o.value("pptx.invalid_format"));
79
+ }
80
+ const x = d.slideCount;
81
+ if (!x || x === 0) throw new Error(o.value("pptx.no_pages"));
82
+ d.destroy(), w.value = x, l.value && (l.value.innerHTML = "");
83
+ const b = g();
84
+ r = D(l.value, {
85
+ width: b.width,
86
+ height: s.tiled ? b.height * x : b.height,
87
+ mode: s.tiled ? "list" : "slide"
88
+ }), await r.preview(i), t !== null && (clearTimeout(t), t = null), n.value = !1;
89
+ } finally {
90
+ document.body.contains(a) && document.body.removeChild(a);
91
+ }
92
+ } catch (e) {
93
+ t !== null && clearTimeout(t);
94
+ let i = o.value("pptx.parse_failed");
95
+ e instanceof Error ? i = J(o.value, e) : typeof e == "string" && (i = e), u.value = i, n.value = !1;
96
+ }
97
+ };
98
+ V(() => {
99
+ if (!l.value) return;
100
+ let t = !0;
101
+ y = new ResizeObserver(() => {
102
+ if (t) {
103
+ t = !1, _ = g();
104
+ return;
105
+ }
106
+ const e = g(), i = Math.abs(_.width - e.width), a = Math.abs(_.height - e.height);
107
+ i < 10 && a < 10 || (_ = e, f !== null && clearTimeout(f), f = window.setTimeout(() => {
108
+ r && c && F();
109
+ }, 800));
110
+ }), y.observe(l.value), setTimeout(() => {
111
+ requestAnimationFrame(() => requestAnimationFrame(() => B()));
112
+ }, 150);
113
+ }), q(
114
+ () => s.url,
115
+ (t) => {
116
+ t && B();
117
+ }
118
+ ), A(() => {
119
+ if (y && y.disconnect(), f !== null && clearTimeout(f), c = null, w.value = 0, r)
120
+ try {
121
+ r.destroy();
122
+ } catch {
123
+ }
124
+ r = null;
125
+ });
126
+ const L = () => [], N = I(() => U(s.emptyHint, "structured"));
127
+ return z({
128
+ getToolbarGroups: L
129
+ }), (t, e) => (p(), h("div", X, [
130
+ n.value ? (p(), h("div", Y, [
131
+ k("div", Z, [
132
+ e[0] || (e[0] = k("div", { class: "vfp-renderer-spinner" }, null, -1)),
133
+ k("p", ee, O(C(o)("pptx.loading")), 1)
134
+ ])
135
+ ])) : T("", !0),
136
+ m.value && !n.value && N.value ? (p(), h("div", te, [
137
+ W(Q)
138
+ ])) : T("", !0),
139
+ u.value && !n.value ? (p(), h("div", ie, [
140
+ W(K, {
141
+ message: C(o)("pptx.load_failed"),
142
+ detail: u.value
143
+ }, null, 8, ["message", "detail"])
144
+ ])) : T("", !0),
145
+ u.value ? T("", !0) : (p(), h("div", {
146
+ key: 3,
147
+ ref_key: "containerRef",
148
+ ref: l,
149
+ class: "pptx-wrapper vfp-w-full vfp-max-w-full md:vfp-max-w-6xl",
150
+ style: S({ opacity: n.value || m.value ? 0 : 1 })
151
+ }, null, 4))
152
+ ]));
153
+ }
154
+ });
155
+ export {
156
+ se as default
157
+ };