@eternalheart/vue-file-preview 1.6.13 → 1.7.1

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 (128) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/lib/FilePreviewContent.vue.d.ts +25 -6
  4. package/lib/FilePreviewEmbed.vue.d.ts +19 -6
  5. package/lib/FilePreviewModal.vue.d.ts +19 -6
  6. package/lib/chunks/{EmptyState.vue_vue_type_script_setup_true_lang-C7qk6wj0.mjs → EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs} +1 -1
  7. package/lib/chunks/{avifLoader-CAUzjn-d-C0KRpetN.mjs → avifLoader-CAUzjn-d-Cf00sjt2.mjs} +1 -1
  8. package/lib/chunks/{heicLoader-D_9PukkA-Czof_5FJ.mjs → heicLoader-D_9PukkA-cn1P7b2x.mjs} +1 -1
  9. package/lib/chunks/{index-BASg1cr4.mjs → index-0VXtKKev.mjs} +1018 -1018
  10. package/lib/chunks/index-0fXL30y0.mjs +333 -0
  11. package/lib/chunks/{index-C9mAajbD.mjs → index-B1AwVHWI.mjs} +191 -191
  12. package/lib/chunks/{index-BvBqDq3O.mjs → index-B77rFiau.mjs} +2023 -2023
  13. package/lib/chunks/index-BB10as16.mjs +108 -0
  14. package/lib/chunks/index-BBIn-k4u.mjs +359 -0
  15. package/lib/chunks/index-BSzaI9ea.mjs +122 -0
  16. package/lib/chunks/index-BZvy39tn.mjs +117 -0
  17. package/lib/chunks/index-BlJEM2Lb.mjs +383 -0
  18. package/lib/chunks/{index-CxKZKUJj.mjs → index-CZlnxQFA.mjs} +1385 -1385
  19. package/lib/chunks/index-ClhTPqDI.mjs +137 -0
  20. package/lib/chunks/{index-8Vpbg2kS.mjs → index-D690gnNu.mjs} +118 -117
  21. package/lib/chunks/index-D7WykPYL.mjs +51 -0
  22. package/lib/chunks/{index-DZZN3kYi.mjs → index-DBzyeU0G.mjs} +1609 -1375
  23. package/lib/chunks/{index-Dkro_8Fy.mjs → index-DKFX5ToE.mjs} +33 -33
  24. package/lib/chunks/index-DRmKaFXK.mjs +157 -0
  25. package/lib/chunks/index-DXf3wXT5.mjs +155 -0
  26. package/lib/chunks/{index-BuqPb5mP.mjs → index-Dp7QQjNH.mjs} +114 -114
  27. package/lib/chunks/index-FzI__DHC.mjs +104 -0
  28. package/lib/chunks/index-PWjCziZG.mjs +90 -0
  29. package/lib/chunks/index-bT6XWKO_.mjs +52 -0
  30. package/lib/chunks/{index-DN4Ui0Gh.mjs → index-tX9VR6Vo.mjs} +122 -122
  31. package/lib/chunks/{jp2Loader-Dig19xyo-CKUaGhPl.mjs → jp2Loader-Dig19xyo-D-OEDL3n.mjs} +1 -1
  32. package/lib/chunks/{psdLoader-C0tKUXXl-CYWoQis5.mjs → psdLoader-C0tKUXXl-CVN06LUc.mjs} +1 -1
  33. package/lib/chunks/{rawLoader-C-tPeFAB-C35zC8nZ.mjs → rawLoader-C-tPeFAB-DBqcJPFK.mjs} +5 -5
  34. package/lib/chunks/{tiffLoader-BlhByX8w-BOxg_Du5.mjs → tiffLoader-BlhByX8w-8-0icdyL.mjs} +1 -1
  35. package/lib/chunks/{useShikiHighlight-BPmcxA-h.mjs → useShikiHighlight-a_GUszuU.mjs} +1 -1
  36. package/lib/composables/useAudioPlayer.d.ts +1 -1
  37. package/lib/composables/usePreviewEvents.d.ts +27 -0
  38. package/lib/composables/useRequest.d.ts +16 -4
  39. package/lib/composables/useThemeMode.d.ts +1 -1
  40. package/lib/composables/useTranslator.d.ts +2 -2
  41. package/lib/core/events.d.ts +69 -0
  42. package/lib/core/i18n/index.d.ts +29 -0
  43. package/lib/core/i18n/messages/en-US.d.ts +5 -0
  44. package/lib/core/i18n/messages/index.d.ts +9 -0
  45. package/lib/core/i18n/messages/zh-CN.d.ts +5 -0
  46. package/lib/core/i18n/types.d.ts +23 -0
  47. package/lib/core/index.d.ts +34 -0
  48. package/lib/core/loaders/avifLoader.d.ts +22 -0
  49. package/lib/core/loaders/heicLoader.d.ts +21 -0
  50. package/lib/core/loaders/jp2Loader.d.ts +16 -0
  51. package/lib/core/loaders/jp2Worker.d.ts +1 -0
  52. package/lib/core/loaders/psdLoader.d.ts +14 -0
  53. package/lib/core/loaders/rawLoader.d.ts +14 -0
  54. package/lib/core/loaders/registry.d.ts +32 -0
  55. package/lib/core/loaders/tiffLoader.d.ts +28 -0
  56. package/lib/core/loaders/types.d.ts +56 -0
  57. package/lib/core/types.d.ts +89 -0
  58. package/lib/core/utils/csvParser.d.ts +31 -0
  59. package/lib/core/utils/emptyState.d.ts +28 -0
  60. package/lib/core/utils/excelDataConverter.d.ts +61 -0
  61. package/lib/core/utils/fileNormalizer.d.ts +21 -0
  62. package/lib/core/utils/fileType.d.ts +21 -0
  63. package/lib/core/utils/legacy-office/doc.d.ts +25 -0
  64. package/lib/core/utils/legacy-office/index.d.ts +8 -0
  65. package/lib/core/utils/legacy-office/ole.d.ts +8 -0
  66. package/lib/core/utils/legacy-office/ppt.d.ts +79 -0
  67. package/lib/core/utils/legacy-office/xls.d.ts +28 -0
  68. package/lib/core/utils/mimeTypes.d.ts +29 -0
  69. package/lib/core/utils/ooxml/docx.d.ts +17 -0
  70. package/lib/core/utils/ooxml/index.d.ts +4 -0
  71. package/lib/core/utils/ooxml/pptx.d.ts +7 -0
  72. package/lib/core/utils/ooxml/xml.d.ts +15 -0
  73. package/lib/core/utils/ooxml/zip.d.ts +3 -0
  74. package/lib/core/utils/pdfWorker.d.ts +61 -0
  75. package/lib/core/utils/previewMode.d.ts +7 -0
  76. package/lib/core/utils/request.d.ts +49 -0
  77. package/lib/core/utils/subtitleParser.d.ts +44 -0
  78. package/lib/core/utils/textDecoder.d.ts +30 -0
  79. package/lib/core/utils/uint8ArrayPolyfill.d.ts +18 -0
  80. package/lib/core/utils/zipReader.d.ts +51 -0
  81. package/lib/core/workers/imageDecoder.worker.d.ts +31 -0
  82. package/lib/core/workers/workerClient.d.ts +14 -0
  83. package/lib/i18n/localeKey.d.ts +1 -1
  84. package/lib/index.cjs +60 -60
  85. package/lib/index.css +1 -1
  86. package/lib/index.d.ts +11 -9
  87. package/lib/index.mjs +15 -12
  88. package/lib/renderers/Audio/index.vue.d.ts +1 -1
  89. package/lib/renderers/Cad/index.vue.d.ts +1 -1
  90. package/lib/renderers/Cad/toolbar.d.ts +2 -2
  91. package/lib/renderers/Csv/index.vue.d.ts +1 -1
  92. package/lib/renderers/Doc/index.vue.d.ts +1 -1
  93. package/lib/renderers/Docx/index.vue.d.ts +1 -1
  94. package/lib/renderers/Epub/index.vue.d.ts +1 -1
  95. package/lib/renderers/Font/index.vue.d.ts +1 -1
  96. package/lib/renderers/Image/index.vue.d.ts +2 -2
  97. package/lib/renderers/Json/index.vue.d.ts +2 -2
  98. package/lib/renderers/Markdown/index.vue.d.ts +1 -1
  99. package/lib/renderers/Mobi/index.vue.d.ts +1 -1
  100. package/lib/renderers/Msg/index.vue.d.ts +1 -1
  101. package/lib/renderers/Pdf/index.vue.d.ts +1 -1
  102. package/lib/renderers/Ppt/index.vue.d.ts +1 -1
  103. package/lib/renderers/Pptx/index.vue.d.ts +2 -2
  104. package/lib/renderers/Subtitle/index.vue.d.ts +1 -1
  105. package/lib/renderers/Text/index.vue.d.ts +2 -2
  106. package/lib/renderers/Unsupported/index.vue.d.ts +1 -1
  107. package/lib/renderers/Video/index.vue.d.ts +1 -1
  108. package/lib/renderers/Xlsx/index.vue.d.ts +2 -2
  109. package/lib/renderers/Xml/index.vue.d.ts +1 -1
  110. package/lib/renderers/Zip/TreeItem.vue.d.ts +1 -1
  111. package/lib/renderers/Zip/index.vue.d.ts +1 -1
  112. package/lib/renderers/base.types.d.ts +1 -1
  113. package/lib/renderers/registry.d.ts +1 -1
  114. package/lib/types.d.ts +3 -3
  115. package/package.json +2 -2
  116. package/lib/chunks/index--612Smof.mjs +0 -383
  117. package/lib/chunks/index-B21EAyWz.mjs +0 -137
  118. package/lib/chunks/index-BB0i4QqI.mjs +0 -117
  119. package/lib/chunks/index-BVdrGK3Q.mjs +0 -356
  120. package/lib/chunks/index-BlrFFeqc.mjs +0 -330
  121. package/lib/chunks/index-Bp9CuvMZ.mjs +0 -157
  122. package/lib/chunks/index-Bxpf9v5j.mjs +0 -104
  123. package/lib/chunks/index-CDg6vIbT.mjs +0 -51
  124. package/lib/chunks/index-CWE-hKSs.mjs +0 -90
  125. package/lib/chunks/index-CY3xzGgt.mjs +0 -108
  126. package/lib/chunks/index-D30L8tm9.mjs +0 -155
  127. package/lib/chunks/index-VdzIFJJW.mjs +0 -118
  128. package/lib/chunks/index-aoXgVLBb.mjs +0 -52
@@ -0,0 +1,117 @@
1
+ import { defineComponent as $, ref as f, computed as d, watch as T, unref as m, openBlock as t, createElementBlock as i, createElementVNode as l, toDisplayString as _, createBlock as E, normalizeClass as H, normalizeStyle as z, Fragment as S, renderList as G } from "vue";
2
+ import { WrapText as M, Code as P, Eye as W } from "lucide-vue-next";
3
+ import { u as X, a as D, b as R, X as V, S as j, T as q, f as A } from "./index-DBzyeU0G.mjs";
4
+ import { u as I } from "./useShikiHighlight-a_GUszuU.mjs";
5
+ import { _ as J } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
6
+ import { _ as K } from "./EmptyState.vue_vue_type_script_setup_true_lang-DSQp7H-K.mjs";
7
+ import { T as O } from "./base.types-DaftHyg7.mjs";
8
+ const Q = {
9
+ key: 0,
10
+ class: "vfp-renderer-loading"
11
+ }, U = { class: "vfp-renderer-loading-content" }, Y = { class: "vfp-renderer-loading-text" }, Z = {
12
+ key: 3,
13
+ class: "vfp-w-full vfp-h-full vfp-bg-surface-toolbar"
14
+ }, ee = ["srcdoc", "title"], le = {
15
+ key: 4,
16
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
17
+ style: { background: "var(--fp-code-bg)" }
18
+ }, te = {
19
+ key: 5,
20
+ class: "vfp-w-full vfp-h-full vfp-overflow-auto",
21
+ style: { background: "var(--fp-code-bg)" }
22
+ }, oe = { class: "vfp-code-gutter" }, ae = ["innerHTML"], me = /* @__PURE__ */ $({
23
+ __name: "index",
24
+ props: {
25
+ url: {},
26
+ fileName: {},
27
+ emptyHint: {}
28
+ },
29
+ setup(b, { expose: C }) {
30
+ const v = b, w = new O(), { t: s } = X(), L = D(), g = R(), o = f(!0), a = f(!1), r = f(""), p = f(!0), c = f(null), n = d(() => V(v.fileName)), N = d(() => n.value !== "text" ? r.value : ""), { lineHtmls: y, loading: B } = I(N, n), x = d(() => n.value === "html"), F = d(
31
+ () => !p.value && !c.value && j(r.value) && q(v.emptyHint, "textual")
32
+ );
33
+ T([o, a, p, x], () => {
34
+ w.notify();
35
+ }), T(() => v.url, async () => {
36
+ g.begin(v.url), p.value = !0, c.value = null;
37
+ try {
38
+ const e = await A(v.url, { fetcher: L.value });
39
+ r.value = e, g.ready();
40
+ } catch (e) {
41
+ console.error(e), c.value = s.value("text.load_failed"), g.error(e);
42
+ } finally {
43
+ p.value = !1;
44
+ }
45
+ }, { immediate: !0 });
46
+ const k = d(() => r.value.split(`
47
+ `));
48
+ return C({
49
+ getToolbarGroups: () => {
50
+ const e = [];
51
+ return e.push({
52
+ items: [
53
+ {
54
+ type: "button",
55
+ icon: M,
56
+ tooltip: o.value ? s.value("toolbar.wrap_off") : s.value("toolbar.wrap_on"),
57
+ action: () => {
58
+ o.value = !o.value;
59
+ },
60
+ active: o.value
61
+ }
62
+ ]
63
+ }), x.value && e.push({
64
+ items: [
65
+ {
66
+ type: "button",
67
+ icon: a.value ? P : W,
68
+ tooltip: a.value ? s.value("toolbar.source") : s.value("toolbar.preview"),
69
+ action: () => {
70
+ a.value = !a.value;
71
+ },
72
+ active: a.value
73
+ }
74
+ ]
75
+ }), e;
76
+ },
77
+ onToolbarChange: (e) => w.subscribe(e)
78
+ }), (e, u) => p.value || n.value !== "text" && m(B) ? (t(), i("div", Q, [
79
+ l("div", U, [
80
+ u[0] || (u[0] = l("div", { class: "vfp-renderer-spinner" }, null, -1)),
81
+ l("span", Y, _(m(s)("common.loading")), 1)
82
+ ])
83
+ ])) : c.value ? (t(), E(J, {
84
+ key: 1,
85
+ message: c.value
86
+ }, null, 8, ["message"])) : F.value ? (t(), E(K, { key: 2 })) : a.value && n.value === "html" ? (t(), i("div", Z, [
87
+ l("iframe", {
88
+ srcdoc: r.value,
89
+ sandbox: "allow-same-origin",
90
+ class: "vfp-w-full vfp-h-full vfp-border-0",
91
+ title: b.fileName
92
+ }, null, 8, ee)
93
+ ])) : n.value === "text" || m(y).length === 0 ? (t(), i("div", le, [
94
+ l("pre", {
95
+ class: H(["vfp-py-6 vfp-px-4 vfp-text-fg-primary vfp-font-mono vfp-text-sm", o.value ? "vfp-whitespace-pre-wrap vfp-break-words" : "vfp-whitespace-pre"])
96
+ }, _(r.value), 3)
97
+ ])) : (t(), i("div", te, [
98
+ l("div", {
99
+ class: H(["vfp-code-block with-line-numbers vfp-w-full", { "no-wrap": !o.value }]),
100
+ style: z({ gridTemplateRows: `repeat(${k.value.length}, auto) minmax(1.5rem, 1fr)` })
101
+ }, [
102
+ (t(!0), i(S, null, G(k.value, (ne, h) => (t(), i(S, { key: h }, [
103
+ l("span", oe, _(h + 1), 1),
104
+ l("span", {
105
+ class: "vfp-code-line",
106
+ innerHTML: m(y)[h] ?? ""
107
+ }, null, 8, ae)
108
+ ], 64))), 128)),
109
+ u[1] || (u[1] = l("span", { class: "vfp-code-gutter-filler" }, null, -1)),
110
+ u[2] || (u[2] = l("span", { class: "vfp-code-line-filler" }, null, -1))
111
+ ], 6)
112
+ ]));
113
+ }
114
+ });
115
+ export {
116
+ me as default
117
+ };
@@ -0,0 +1,383 @@
1
+ import { defineComponent as ke, ref as s, watch as I, onBeforeUnmount as ae, onMounted as Ee, computed as le, openBlock as w, createElementBlock as U, normalizeStyle as oe, createElementVNode as _, createTextVNode as Ce, toDisplayString as b, unref as D, createCommentVNode as E, createBlock as ne, normalizeClass as Te } from "vue";
2
+ import { u as Ue, a as Ye, b as ze, $ as Se, _ as Xe, J as ie, M as Be, I as De, p as se, A as Oe } from "./index-DBzyeU0G.mjs";
3
+ import { ZoomOut as We, ZoomIn as $e, Scan as Pe, Maximize2 as je, RotateCcw as He, RotateCw as Ze, RefreshCw as Ie } from "lucide-vue-next";
4
+ import { _ as re } from "./RendererError.vue_vue_type_script_setup_true_lang-FmkMQHB8.mjs";
5
+ import { T as Ne } from "./base.types-DaftHyg7.mjs";
6
+ const Ae = {
7
+ key: 0,
8
+ class: "vfp-absolute vfp-inset-0 vfp-renderer-loading vfp-bg-surface-1/80 vfp-z-10"
9
+ }, Ve = { class: "vfp-renderer-loading-content" }, Fe = { class: "vfp-renderer-loading-text" }, Ge = { key: 0 }, Qe = {
10
+ key: 2,
11
+ class: "vfp-renderer-loading"
12
+ }, qe = { class: "vfp-renderer-loading-content" }, Je = { class: "vfp-renderer-loading-text" }, Ke = ["src"], et = {
13
+ key: 5,
14
+ class: "vfp-absolute vfp-bottom-2 vfp-right-3 vfp-text-[10px] vfp-text-fg-disabled hover:vfp-text-fg-secondary vfp-transition-colors vfp-pointer-events-auto vfp-select-none vfp-cursor-default"
15
+ }, tt = {
16
+ key: 6,
17
+ class: "vfp-absolute vfp-bottom-2 vfp-left-1/2 -vfp-translate-x-1/2 vfp-flex vfp-items-center vfp-gap-2 vfp-px-3 vfp-py-1.5 vfp-bg-surface-toolbar vfp-border vfp-border-line vfp-rounded-lg vfp-text-sm vfp-text-fg-primary vfp-shadow-md"
18
+ }, at = ["disabled"], lt = { class: "vfp-text-fg-secondary vfp-tabular-nums" }, ot = ["disabled"], vt = /* @__PURE__ */ ke({
19
+ __name: "index",
20
+ props: {
21
+ url: {},
22
+ fileSize: {},
23
+ file: {}
24
+ },
25
+ setup(ue, { expose: ce }) {
26
+ const f = ue, V = new Ne(), { t: i } = Ue(), ve = Ye(), B = ze(), r = s(1), C = s(0), T = s(!1), M = s(null), p = s(!1), O = s(0), R = s(null), L = s(""), k = s(1), Y = s(1), F = s(!1), l = s({ x: 0, y: 0 }), y = s(!1);
27
+ let z = { x: 0, y: 0 };
28
+ const m = s(1), v = s({ width: 0, height: 0 });
29
+ I([r, C], () => {
30
+ V.notify();
31
+ }), ce({
32
+ getToolbarGroups: () => [
33
+ {
34
+ items: [
35
+ {
36
+ type: "button",
37
+ icon: We,
38
+ tooltip: i.value("toolbar.zoom_out"),
39
+ action: fe,
40
+ disabled: r.value <= 0.01
41
+ },
42
+ {
43
+ type: "text",
44
+ content: `${Math.round(r.value * 100)}%`,
45
+ minWidth: "3rem"
46
+ },
47
+ {
48
+ type: "button",
49
+ icon: $e,
50
+ tooltip: i.value("toolbar.zoom_in"),
51
+ action: de,
52
+ disabled: r.value >= 10
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ items: [
58
+ {
59
+ type: "button",
60
+ icon: Pe,
61
+ tooltip: i.value("toolbar.fit_to_window"),
62
+ action: G
63
+ },
64
+ {
65
+ type: "button",
66
+ icon: je,
67
+ tooltip: i.value("toolbar.original_size"),
68
+ action: me
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ items: [
74
+ {
75
+ type: "button",
76
+ icon: He,
77
+ tooltip: i.value("toolbar.rotate_left"),
78
+ action: pe
79
+ },
80
+ {
81
+ type: "button",
82
+ icon: Ze,
83
+ tooltip: i.value("toolbar.rotate_right"),
84
+ action: he
85
+ }
86
+ ]
87
+ },
88
+ {
89
+ items: [
90
+ {
91
+ type: "button",
92
+ icon: Ie,
93
+ tooltip: i.value("toolbar.reset"),
94
+ action: ge
95
+ }
96
+ ]
97
+ }
98
+ ],
99
+ onToolbarChange: (e) => V.subscribe(e)
100
+ });
101
+ const de = () => {
102
+ r.value = Math.min(r.value + 0.1, 10);
103
+ }, fe = () => {
104
+ r.value = Math.max(r.value - 0.1, 0.01);
105
+ }, he = () => {
106
+ C.value = (C.value + 90) % 360;
107
+ }, pe = () => {
108
+ C.value = (C.value - 90 + 360) % 360;
109
+ }, me = () => {
110
+ r.value = 1, C.value = 0, l.value = { x: 0, y: 0 };
111
+ }, ge = () => {
112
+ G();
113
+ }, G = () => {
114
+ if (h.value && v.value.width > 0 && v.value.height > 0) {
115
+ const e = h.value.clientWidth, t = h.value.clientHeight, a = e / v.value.width, u = t / v.value.height;
116
+ r.value = Math.max(0.01, Math.min(10, Math.min(a, u))), l.value = { x: 0, y: 0 };
117
+ }
118
+ }, be = s(null), h = s(null);
119
+ let S = null, W = null, $ = null;
120
+ const g = /* @__PURE__ */ new Map();
121
+ let P = !1, j = 0, Q = 1, N = { x: 0, y: 0 }, q = 0;
122
+ I(
123
+ () => [f.url, f.file],
124
+ async () => {
125
+ if (B.begin(f.url), L.value = "", T.value = !1, M.value = null, p.value = !1, R.value = null, O.value = 0, l.value = { x: 0, y: 0 }, m.value = 1, r.value = 1, k.value = 1, Y.value = 1, F.value = !1, S && (URL.revokeObjectURL(S), S = null), g.forEach((e) => URL.revokeObjectURL(e)), g.clear(), W = null, $ = null, !f.file) {
126
+ L.value = f.url;
127
+ return;
128
+ }
129
+ try {
130
+ const e = await Se(f.file), t = await Xe(e);
131
+ if (!t || !await t.needsDecode(e)) {
132
+ L.value = f.url;
133
+ return;
134
+ }
135
+ p.value = !0;
136
+ let a;
137
+ if (f.file instanceof Blob)
138
+ a = f.file;
139
+ else if (f.file.file instanceof Blob)
140
+ a = f.file.file;
141
+ else {
142
+ const n = await ve.value(f.url);
143
+ if (!n.ok) throw new ie("file.load_failed");
144
+ a = await n.blob();
145
+ }
146
+ if (W = a, $ = t, e.startsWith("image/x-") && (F.value = !0), t.getMetadata)
147
+ try {
148
+ const n = await t.getMetadata(a);
149
+ n.pageCount && n.pageCount > 1 && (Y.value = n.pageCount);
150
+ } catch {
151
+ }
152
+ const c = {
153
+ page: 1,
154
+ fullQuality: !1,
155
+ onProgress: (n) => {
156
+ O.value = n;
157
+ }
158
+ };
159
+ let o;
160
+ if (Be(e))
161
+ try {
162
+ o = await De(
163
+ e,
164
+ await a.arrayBuffer(),
165
+ { page: 1, fullQuality: !1 }
166
+ );
167
+ } catch {
168
+ o = await t.decode(a, c);
169
+ }
170
+ else
171
+ o = await t.decode(a, c);
172
+ const d = typeof o == "string" ? o : URL.createObjectURL(o);
173
+ S = d, g.set(1, d), L.value = d, p.value = !1;
174
+ } catch (e) {
175
+ R.value = se(i.value, e) || i.value("image.decode_failed"), p.value = !1, B.error(e);
176
+ }
177
+ },
178
+ { immediate: !0 }
179
+ );
180
+ const J = async (e) => {
181
+ if (!W || !$ || e < 1 || e > Y.value) return;
182
+ const t = g.get(e);
183
+ if (t) {
184
+ k.value = e, L.value = t;
185
+ return;
186
+ }
187
+ p.value = !0;
188
+ try {
189
+ const a = await $.decode(W, { page: e }), u = typeof a == "string" ? a : URL.createObjectURL(a);
190
+ if (g.size >= 10) {
191
+ const c = g.keys().next().value;
192
+ if (c !== void 0) {
193
+ const o = g.get(c);
194
+ o && URL.revokeObjectURL(o), g.delete(c);
195
+ }
196
+ }
197
+ g.set(e, u), k.value = e, L.value = u, p.value = !1;
198
+ } catch (a) {
199
+ R.value = se(i.value, a) || i.value("image.page_decode_failed"), p.value = !1, B.error(a, "render");
200
+ }
201
+ };
202
+ ae(() => {
203
+ S && URL.revokeObjectURL(S), g.forEach((t) => URL.revokeObjectURL(t)), g.clear();
204
+ const e = h.value;
205
+ e && e.removeEventListener("wheel", A);
206
+ }), I(r, (e) => {
207
+ m.value = e;
208
+ }), I(m, (e) => {
209
+ r.value = e;
210
+ });
211
+ const H = (e, t) => {
212
+ const a = h.value;
213
+ if (!a || v.value.width === 0) return e;
214
+ const u = a.clientWidth, c = a.clientHeight, o = v.value.width * t, d = v.value.height * t, n = Math.min(80, u * 0.15, c * 0.15), x = (u + o) / 2 - n, X = (c + d) / 2 - n;
215
+ return {
216
+ x: x > 0 ? Math.max(-x, Math.min(x, e.x)) : 0,
217
+ y: X > 0 ? Math.max(-X, Math.min(X, e.y)) : 0
218
+ };
219
+ }, ye = (e) => {
220
+ T.value = !0;
221
+ const t = e.currentTarget;
222
+ if (v.value = { width: t.naturalWidth, height: t.naturalHeight }, B.ready(), h.value && v.value.width > 0 && v.value.height > 0) {
223
+ const a = h.value.clientWidth, u = h.value.clientHeight, c = a / v.value.width, o = u / v.value.height, d = Math.min(c, o);
224
+ r.value = Math.max(0.01, Math.min(10, d)), l.value = { x: 0, y: 0 };
225
+ }
226
+ }, xe = () => {
227
+ M.value = i.value("image.load_failed"), T.value = !0, B.error(new ie("image.load_failed"), "request");
228
+ }, we = () => {
229
+ l.value = { x: 0, y: 0 }, r.value = 1;
230
+ }, A = (e) => {
231
+ e.preventDefault(), e.stopPropagation();
232
+ const t = h.value;
233
+ if (!t) return;
234
+ const a = t.getBoundingClientRect(), u = e.clientX - a.left - a.width / 2, c = e.clientY - a.top - a.height / 2, o = e.deltaY > 0 ? -0.05 : 0.05, d = m.value, n = Math.max(0.01, Math.min(10, d + o)), x = n / d;
235
+ l.value = H(
236
+ {
237
+ x: u - x * (u - l.value.x),
238
+ y: c - x * (c - l.value.y)
239
+ },
240
+ n
241
+ ), m.value = n;
242
+ };
243
+ Ee(() => {
244
+ const e = h.value;
245
+ e && (e.addEventListener("wheel", A, { passive: !1 }), e.addEventListener("touchstart", ee, { passive: !1 }), e.addEventListener("touchmove", te, { passive: !1 }), e.addEventListener("touchend", Z), e.addEventListener("touchcancel", Z));
246
+ }), ae(() => {
247
+ const e = h.value;
248
+ e && (e.removeEventListener("wheel", A), e.removeEventListener("touchstart", ee), e.removeEventListener("touchmove", te), e.removeEventListener("touchend", Z), e.removeEventListener("touchcancel", Z));
249
+ });
250
+ const _e = (e) => {
251
+ P || e.button === 0 && (y.value = !0, z = {
252
+ x: e.clientX - l.value.x,
253
+ y: e.clientY - l.value.y
254
+ });
255
+ }, Me = (e) => {
256
+ P || y.value && (l.value = H(
257
+ {
258
+ x: e.clientX - z.x,
259
+ y: e.clientY - z.y
260
+ },
261
+ m.value
262
+ ));
263
+ }, K = () => {
264
+ P || (y.value = !1);
265
+ }, ee = (e) => {
266
+ P = !0, e.preventDefault();
267
+ const t = e.touches;
268
+ if (t.length === 1) {
269
+ y.value = !0, z = {
270
+ x: t[0].clientX - l.value.x,
271
+ y: t[0].clientY - l.value.y
272
+ };
273
+ const a = Date.now();
274
+ a - q < 300 && (l.value = { x: 0, y: 0 }, r.value = 1), q = a;
275
+ } else t.length === 2 && (y.value = !1, j = Math.hypot(
276
+ t[1].clientX - t[0].clientX,
277
+ t[1].clientY - t[0].clientY
278
+ ), Q = m.value, N = { ...l.value });
279
+ }, te = (e) => {
280
+ e.preventDefault();
281
+ const t = e.touches;
282
+ if (t.length === 1 && y.value)
283
+ l.value = H(
284
+ {
285
+ x: t[0].clientX - z.x,
286
+ y: t[0].clientY - z.y
287
+ },
288
+ m.value
289
+ );
290
+ else if (t.length === 2) {
291
+ const a = h.value;
292
+ if (!a) return;
293
+ const u = Math.hypot(
294
+ t[1].clientX - t[0].clientX,
295
+ t[1].clientY - t[0].clientY
296
+ );
297
+ if (Math.abs(u - j) < 5) return;
298
+ const c = u / j, o = Math.max(0.01, Math.min(10, Q * c)), d = a.getBoundingClientRect(), n = (t[0].clientX + t[1].clientX) / 2 - d.left - d.width / 2, x = (t[0].clientY + t[1].clientY) / 2 - d.top - d.height / 2, X = o / m.value;
299
+ l.value = H(
300
+ {
301
+ x: n - X * (n - N.x),
302
+ y: x - X * (x - N.y)
303
+ },
304
+ o
305
+ ), m.value = o;
306
+ }
307
+ }, Z = () => {
308
+ y.value = !1, j = 0;
309
+ }, Re = le(() => ({
310
+ transform: `translate(${l.value.x}px, ${l.value.y}px) scale(${m.value}) rotate(${C.value}deg)`,
311
+ transformOrigin: "center",
312
+ transition: y.value ? "none" : "transform 0.3s ease-out",
313
+ opacity: T.value && !M.value && !R.value ? 1 : 0
314
+ })), Le = le(() => f.fileSize == null ? "" : ` · ${Oe(f.fileSize)}`);
315
+ return (e, t) => (w(), U("div", {
316
+ ref_key: "containerRef",
317
+ ref: h,
318
+ class: "vfp-relative vfp-flex vfp-items-center vfp-justify-center vfp-w-full vfp-h-full vfp-overflow-hidden",
319
+ style: oe({ cursor: y.value ? "grabbing" : "grab", touchAction: "none" }),
320
+ onMousedown: _e,
321
+ onMousemove: Me,
322
+ onMouseup: K,
323
+ onMouseleave: K
324
+ }, [
325
+ p.value ? (w(), U("div", Ae, [
326
+ _("div", Ve, [
327
+ t[2] || (t[2] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
328
+ _("p", Fe, [
329
+ Ce(b(D(i)("image.decoding")) + " ", 1),
330
+ O.value > 0 ? (w(), U("span", Ge, b(Math.round(O.value)) + "%", 1)) : E("", !0)
331
+ ])
332
+ ])
333
+ ])) : E("", !0),
334
+ R.value ? (w(), ne(re, {
335
+ key: 1,
336
+ message: D(i)("image.decode_failed"),
337
+ detail: R.value
338
+ }, null, 8, ["message", "detail"])) : E("", !0),
339
+ !T.value && !M.value && !p.value && !R.value ? (w(), U("div", Qe, [
340
+ _("div", qe, [
341
+ t[3] || (t[3] = _("div", { class: "vfp-renderer-spinner" }, null, -1)),
342
+ _("span", Je, b(D(i)("common.loading")), 1)
343
+ ])
344
+ ])) : E("", !0),
345
+ M.value ? (w(), ne(re, {
346
+ key: 3,
347
+ message: M.value
348
+ }, null, 8, ["message"])) : E("", !0),
349
+ L.value ? (w(), U("img", {
350
+ key: 4,
351
+ ref_key: "imgRef",
352
+ ref: be,
353
+ src: L.value,
354
+ alt: "Preview",
355
+ class: Te(["vfp-max-w-none vfp-select-none", (!T.value || M.value || R.value) && "vfp-hidden"]),
356
+ style: oe(Re.value),
357
+ draggable: !1,
358
+ onLoad: ye,
359
+ onError: xe,
360
+ onDblclick: we
361
+ }, null, 46, Ke)) : E("", !0),
362
+ T.value && !M.value && v.value.width > 0 ? (w(), U("div", et, b(v.value.width) + " × " + b(v.value.height) + b(Le.value), 1)) : E("", !0),
363
+ Y.value > 1 ? (w(), U("div", tt, [
364
+ _("button", {
365
+ type: "button",
366
+ disabled: k.value <= 1 || p.value,
367
+ class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
368
+ onClick: t[0] || (t[0] = (a) => J(k.value - 1))
369
+ }, b(D(i)("toolbar.prev_page")), 9, at),
370
+ _("span", lt, b(k.value) + " / " + b(Y.value), 1),
371
+ _("button", {
372
+ type: "button",
373
+ disabled: k.value >= Y.value || p.value,
374
+ class: "vfp-px-2 vfp-py-0.5 vfp-rounded hover:vfp-bg-surface-nav-hover disabled:vfp-opacity-40 disabled:vfp-cursor-not-allowed",
375
+ onClick: t[1] || (t[1] = (a) => J(k.value + 1))
376
+ }, b(D(i)("toolbar.next_page")), 9, ot)
377
+ ])) : E("", !0)
378
+ ], 36));
379
+ }
380
+ });
381
+ export {
382
+ vt as default
383
+ };