@eternalheart/vue-file-preview 1.3.6 → 1.3.8

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 (61) hide show
  1. package/lib/FilePreviewContent.vue.d.ts.map +1 -1
  2. package/lib/FilePreviewEmbed.vue.d.ts.map +1 -1
  3. package/lib/FilePreviewModal.vue.d.ts.map +1 -1
  4. package/lib/chunks/index-5Smm2vx0.mjs +77 -0
  5. package/lib/chunks/index-5Smm2vx0.mjs.map +1 -0
  6. package/lib/chunks/index-BCkcZs4y.mjs +84 -0
  7. package/lib/chunks/index-BCkcZs4y.mjs.map +1 -0
  8. package/lib/chunks/index-BM9FaQUl.mjs +134 -0
  9. package/lib/chunks/index-BM9FaQUl.mjs.map +1 -0
  10. package/lib/chunks/index-BYzQg-jL.mjs +152 -0
  11. package/lib/chunks/index-BYzQg-jL.mjs.map +1 -0
  12. package/lib/chunks/index-BoL1b2w-.mjs +129 -0
  13. package/lib/chunks/index-BoL1b2w-.mjs.map +1 -0
  14. package/lib/chunks/index-Bri7VeRx.mjs +203 -0
  15. package/lib/chunks/index-Bri7VeRx.mjs.map +1 -0
  16. package/lib/chunks/index-C324a7kV.mjs +2017 -0
  17. package/lib/chunks/index-C324a7kV.mjs.map +1 -0
  18. package/lib/chunks/index-C7uOM7XL.mjs +139 -0
  19. package/lib/chunks/index-C7uOM7XL.mjs.map +1 -0
  20. package/lib/chunks/index-CTsscgqY.mjs +136 -0
  21. package/lib/chunks/index-CTsscgqY.mjs.map +1 -0
  22. package/lib/chunks/index-Ch7AEfnk.mjs +116 -0
  23. package/lib/chunks/index-Ch7AEfnk.mjs.map +1 -0
  24. package/lib/chunks/index-D9wf6m37.mjs +249 -0
  25. package/lib/chunks/index-D9wf6m37.mjs.map +1 -0
  26. package/lib/chunks/index-DAEQe-RI.mjs +111 -0
  27. package/lib/chunks/index-DAEQe-RI.mjs.map +1 -0
  28. package/lib/chunks/index-DAo-7spn.mjs +103 -0
  29. package/lib/chunks/index-DAo-7spn.mjs.map +1 -0
  30. package/lib/chunks/index-DXlcF1Dk.mjs +113 -0
  31. package/lib/chunks/index-DXlcF1Dk.mjs.map +1 -0
  32. package/lib/chunks/index-ELyTQZeF.mjs +281 -0
  33. package/lib/chunks/index-ELyTQZeF.mjs.map +1 -0
  34. package/lib/chunks/index-cZn4ih-x.mjs +111 -0
  35. package/lib/chunks/index-cZn4ih-x.mjs.map +1 -0
  36. package/lib/chunks/index-dzB4jd9b.mjs +353 -0
  37. package/lib/chunks/index-dzB4jd9b.mjs.map +1 -0
  38. package/lib/chunks/index-lHlugUBI.mjs +391 -0
  39. package/lib/chunks/index-lHlugUBI.mjs.map +1 -0
  40. package/lib/composables/useResolvedTheme.d.ts +15 -0
  41. package/lib/composables/useResolvedTheme.d.ts.map +1 -0
  42. package/lib/index.cjs +24 -499
  43. package/lib/index.cjs.map +1 -1
  44. package/lib/index.css +1 -1
  45. package/lib/index.mjs +12 -44597
  46. package/lib/index.mjs.map +1 -1
  47. package/lib/renderers/Audio/index.vue.d.ts.map +1 -1
  48. package/lib/renderers/Csv/index.vue.d.ts.map +1 -1
  49. package/lib/renderers/Json/index.vue.d.ts.map +1 -1
  50. package/lib/renderers/Markdown/index.vue.d.ts.map +1 -1
  51. package/lib/renderers/Pptx/index.vue.d.ts.map +1 -1
  52. package/lib/renderers/RendererLoading.vue.d.ts +3 -0
  53. package/lib/renderers/RendererLoading.vue.d.ts.map +1 -0
  54. package/lib/renderers/Text/index.vue.d.ts.map +1 -1
  55. package/lib/renderers/Video/index.vue.d.ts.map +1 -1
  56. package/lib/renderers/Xlsx/index.vue.d.ts.map +1 -1
  57. package/lib/renderers/Xml/index.vue.d.ts.map +1 -1
  58. package/lib/renderers/Zip/index.vue.d.ts.map +1 -1
  59. package/lib/renderers/lazy.d.ts +19 -0
  60. package/lib/renderers/lazy.d.ts.map +1 -0
  61. package/package.json +2 -2
@@ -0,0 +1,129 @@
1
+ import { defineComponent as E, ref as h, onMounted as T, watch as D, onBeforeUnmount as M, openBlock as u, createElementBlock as c, createElementVNode as s, toDisplayString as x, unref as w, createCommentVNode as g, createVNode as S, normalizeStyle as z } from "vue";
2
+ import { FileSpreadsheet as W } from "lucide-vue-next";
3
+ import B from "exceljs";
4
+ import C from "x-data-spreadsheet";
5
+ /* empty css */
6
+ import { u as H, C as R } from "./index-C324a7kV.mjs";
7
+ const j = { class: "vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full" }, L = {
8
+ key: 0,
9
+ class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
10
+ }, N = { class: "vfp-text-center" }, V = { class: "vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium" }, F = {
11
+ key: 1,
12
+ class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10"
13
+ }, O = { class: "vfp-text-center vfp-max-w-sm md:vfp-max-w-md vfp-px-4" }, q = { class: "vfp-w-24 vfp-h-24 md:vfp-w-32 md:vfp-h-32 vfp-mx-auto vfp-mb-4 md:vfp-mb-6 vfp-rounded-2xl md:vfp-rounded-3xl vfp-bg-gradient-to-br vfp-from-green-500 vfp-via-emerald-500 vfp-to-teal-500 vfp-flex vfp-items-center vfp-justify-center vfp-shadow-2xl" }, A = { class: "vfp-text-lg md:vfp-text-xl vfp-text-fg-primary vfp-mb-2 md:vfp-mb-3 vfp-font-medium" }, G = { class: "vfp-text-xs md:vfp-text-sm vfp-text-fg-tertiary vfp-mb-4 md:vfp-mb-6" }, I = ["href"], X = /* @__PURE__ */ E({
14
+ __name: "index",
15
+ props: {
16
+ url: {}
17
+ },
18
+ setup(b) {
19
+ const _ = b, { t: p } = H(), o = h(!0), l = h(null), r = h(null);
20
+ let n = null, v = null, a = null, d = { width: 0, height: 0 };
21
+ const m = () => {
22
+ if (!r.value) return { width: 800, height: 600 };
23
+ const e = r.value.clientWidth, t = r.value.clientHeight, f = e > 100 ? e : 800, i = t > 100 ? t : 600;
24
+ return { width: f, height: i };
25
+ }, y = () => {
26
+ if (!r.value || !n) return;
27
+ r.value.innerHTML = "";
28
+ const { width: e, height: t } = m(), f = e < 640;
29
+ new C(r.value, {
30
+ mode: "read",
31
+ showToolbar: !1,
32
+ showContextmenu: !1,
33
+ showGrid: !0,
34
+ row: {
35
+ len: 100,
36
+ height: 25
37
+ },
38
+ col: {
39
+ len: 26,
40
+ width: f ? 80 : 100,
41
+ indexWidth: f ? 40 : 60,
42
+ minWidth: f ? 40 : 60
43
+ },
44
+ view: {
45
+ height: () => t,
46
+ width: () => e
47
+ }
48
+ }).loadData(n);
49
+ }, k = async () => {
50
+ if (r.value) {
51
+ o.value = !0, l.value = null;
52
+ try {
53
+ const e = await fetch(_.url, {
54
+ mode: "cors",
55
+ credentials: "omit",
56
+ redirect: "follow"
57
+ });
58
+ if (!e.ok)
59
+ throw e.status === 404 ? new Error(p.value("xlsx.not_found")) : e.status === 403 ? new Error("无权限访问此文件") : new Error(`文件加载失败 (${e.status})`);
60
+ const t = await e.arrayBuffer();
61
+ if (t.byteLength === 0)
62
+ throw new Error("文件为空");
63
+ const f = new B.Workbook();
64
+ await f.xlsx.load(t), n = R(f), y(), o.value = !1;
65
+ } catch (e) {
66
+ console.error("Excel 解析错误:", e);
67
+ let t = p.value("xlsx.parse_failed");
68
+ e instanceof Error && (t = e.message), l.value = t, o.value = !1;
69
+ }
70
+ }
71
+ };
72
+ return T(() => {
73
+ if (!r.value) return;
74
+ let e = !0;
75
+ v = new ResizeObserver(() => {
76
+ if (e) {
77
+ e = !1, d = m();
78
+ return;
79
+ }
80
+ const t = m(), f = Math.abs(d.width - t.width), i = Math.abs(d.height - t.height);
81
+ f < 10 && i < 10 || (d = t, a !== null && clearTimeout(a), a = window.setTimeout(() => {
82
+ n && y();
83
+ }, 500));
84
+ }), v.observe(r.value), setTimeout(() => {
85
+ requestAnimationFrame(() => k());
86
+ }, 100);
87
+ }), D(
88
+ () => _.url,
89
+ () => {
90
+ k();
91
+ }
92
+ ), M(() => {
93
+ v && v.disconnect(), a !== null && clearTimeout(a), n = null, r.value && (r.value.innerHTML = "");
94
+ }), (e, t) => (u(), c("div", j, [
95
+ o.value ? (u(), c("div", L, [
96
+ s("div", N, [
97
+ t[0] || (t[0] = s("div", { class: "vfp-w-10 vfp-h-10 md:vfp-w-12 md:vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)),
98
+ s("p", V, x(w(p)("xlsx.loading")), 1)
99
+ ])
100
+ ])) : g("", !0),
101
+ l.value && !o.value ? (u(), c("div", F, [
102
+ s("div", O, [
103
+ s("div", q, [
104
+ S(w(W), { class: "vfp-w-12 vfp-h-12 md:vfp-w-16 md:vfp-h-16 vfp-text-fg-primary" })
105
+ ]),
106
+ s("p", A, x(w(p)("xlsx.load_failed")), 1),
107
+ s("p", G, x(l.value), 1),
108
+ s("a", {
109
+ href: b.url,
110
+ download: "",
111
+ class: "vfp-inline-flex vfp-items-center vfp-gap-2 vfp-px-4 vfp-py-2 md:vfp-px-6 md:vfp-py-3 vfp-bg-gradient-to-r vfp-from-purple-500 vfp-to-pink-500 vfp-text-fg-primary vfp-text-sm md:vfp-text-base vfp-rounded-lg md:vfp-rounded-xl hover:vfp-scale-105 vfp-transition-all vfp-shadow-lg"
112
+ }, " 下载文件 ", 8, I),
113
+ t[1] || (t[1] = s("p", { class: "vfp-text-xs vfp-text-fg-muted vfp-mt-3 md:vfp-mt-4" }, "提示:可以使用 Microsoft Excel 或 WPS 打开", -1))
114
+ ])
115
+ ])) : g("", !0),
116
+ l.value ? g("", !0) : (u(), c("div", {
117
+ key: 2,
118
+ ref_key: "containerRef",
119
+ ref: r,
120
+ class: "xlsx-spreadsheet-container vfp-w-full vfp-h-full",
121
+ style: z({ opacity: o.value ? 0 : 1 })
122
+ }, null, 4))
123
+ ]));
124
+ }
125
+ });
126
+ export {
127
+ X as default
128
+ };
129
+ //# sourceMappingURL=index-BoL1b2w-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BoL1b2w-.mjs","sources":["../../src/renderers/Xlsx/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount } from 'vue';\nimport { FileSpreadsheet } from 'lucide-vue-next';\nimport ExcelJS from 'exceljs';\nimport Spreadsheet from 'x-data-spreadsheet';\nimport 'x-data-spreadsheet/dist/xspreadsheet.css';\nimport { convertWorkbookToSpreadsheetData } from '@eternalheart/file-preview-core';\nimport { useTranslator } from '../../composables/useTranslator';\n\nconst props = defineProps<{\n url: string;\n}>();\n\nconst { t } = useTranslator();\n\nconst loading = ref(true);\nconst error = ref<string | null>(null);\nconst containerRef = ref<HTMLDivElement | null>(null);\nlet sheetData: Record<string, unknown>[] | null = null;\nlet resizeObserver: ResizeObserver | null = null;\nlet resizeTimeout: number | null = null;\nlet lastDimensions = { width: 0, height: 0 };\n\nconst calculateDimensions = () => {\n if (!containerRef.value) return { width: 800, height: 600 };\n const rawWidth = containerRef.value.clientWidth;\n const rawHeight = containerRef.value.clientHeight;\n const width = rawWidth > 100 ? rawWidth : 800;\n const height = rawHeight > 100 ? rawHeight : 600;\n return { width, height };\n};\n\nconst mountSpreadsheet = () => {\n if (!containerRef.value || !sheetData) return;\n\n containerRef.value.innerHTML = '';\n\n const { width, height } = calculateDimensions();\n const isMobile = width < 640;\n\n const s = new Spreadsheet(containerRef.value, {\n mode: 'read',\n showToolbar: false,\n showContextmenu: false,\n showGrid: true,\n row: {\n len: 100,\n height: 25,\n },\n col: {\n len: 26,\n width: isMobile ? 80 : 100,\n indexWidth: isMobile ? 40 : 60,\n minWidth: isMobile ? 40 : 60,\n },\n view: {\n height: () => height,\n width: () => width,\n },\n });\n\n s.loadData(sheetData as unknown as Record<string, unknown>);\n};\n\nconst loadExcel = async () => {\n if (!containerRef.value) return;\n\n loading.value = true;\n error.value = null;\n\n try {\n const response = await fetch(props.url, {\n mode: 'cors',\n credentials: 'omit',\n redirect: 'follow',\n });\n\n if (!response.ok) {\n if (response.status === 404) throw new Error(t.value('xlsx.not_found'));\n if (response.status === 403) throw new Error('无权限访问此文件');\n throw new Error(`文件加载失败 (${response.status})`);\n }\n\n const arrayBuffer = await response.arrayBuffer();\n\n if (arrayBuffer.byteLength === 0) {\n throw new Error('文件为空');\n }\n\n const workbook = new ExcelJS.Workbook();\n await workbook.xlsx.load(arrayBuffer);\n const data = convertWorkbookToSpreadsheetData(workbook);\n\n sheetData = data as unknown as Record<string, unknown>[];\n mountSpreadsheet();\n loading.value = false;\n } catch (err) {\n console.error('Excel 解析错误:', err);\n let errorMsg = t.value('xlsx.parse_failed');\n if (err instanceof Error) errorMsg = err.message;\n error.value = errorMsg;\n loading.value = false;\n }\n};\n\nonMounted(() => {\n if (!containerRef.value) return;\n\n let isInitialRender = true;\n\n resizeObserver = new ResizeObserver(() => {\n if (isInitialRender) {\n isInitialRender = false;\n lastDimensions = calculateDimensions();\n return;\n }\n\n const newDimensions = calculateDimensions();\n const widthDiff = Math.abs(lastDimensions.width - newDimensions.width);\n const heightDiff = Math.abs(lastDimensions.height - newDimensions.height);\n\n if (widthDiff < 10 && heightDiff < 10) return;\n\n lastDimensions = newDimensions;\n\n if (resizeTimeout !== null) clearTimeout(resizeTimeout);\n\n resizeTimeout = window.setTimeout(() => {\n if (sheetData) mountSpreadsheet();\n }, 500);\n });\n\n resizeObserver.observe(containerRef.value);\n\n setTimeout(() => {\n requestAnimationFrame(() => loadExcel());\n }, 100);\n});\n\nwatch(\n () => props.url,\n () => {\n loadExcel();\n }\n);\n\nonBeforeUnmount(() => {\n if (resizeObserver) resizeObserver.disconnect();\n if (resizeTimeout !== null) clearTimeout(resizeTimeout);\n sheetData = null;\n if (containerRef.value) containerRef.value.innerHTML = '';\n});\n</script>\n\n<template>\n <div class=\"vfp-relative vfp-flex vfp-flex-col vfp-items-center vfp-w-full vfp-h-full\">\n <div\n v-if=\"loading\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10\"\n >\n <div class=\"vfp-text-center\">\n <div\n class=\"vfp-w-10 vfp-h-10 md:vfp-w-12 md:vfp-h-12 vfp-mx-auto vfp-mb-3 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\"\n />\n <p class=\"vfp-text-xs md:vfp-text-sm vfp-text-fg-secondary vfp-font-medium\">{{ t('xlsx.loading') }}</p>\n </div>\n </div>\n\n <div\n v-if=\"error && !loading\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-bg-surface-toolbar vfp-backdrop-blur-sm vfp-z-10\"\n >\n <div class=\"vfp-text-center vfp-max-w-sm md:vfp-max-w-md vfp-px-4\">\n <div\n class=\"vfp-w-24 vfp-h-24 md:vfp-w-32 md:vfp-h-32 vfp-mx-auto vfp-mb-4 md:vfp-mb-6 vfp-rounded-2xl md:vfp-rounded-3xl vfp-bg-gradient-to-br vfp-from-green-500 vfp-via-emerald-500 vfp-to-teal-500 vfp-flex vfp-items-center vfp-justify-center vfp-shadow-2xl\"\n >\n <FileSpreadsheet class=\"vfp-w-12 vfp-h-12 md:vfp-w-16 md:vfp-h-16 vfp-text-fg-primary\" />\n </div>\n <p class=\"vfp-text-lg md:vfp-text-xl vfp-text-fg-primary vfp-mb-2 md:vfp-mb-3 vfp-font-medium\">\n {{ t('xlsx.load_failed') }}\n </p>\n <p class=\"vfp-text-xs md:vfp-text-sm vfp-text-fg-tertiary vfp-mb-4 md:vfp-mb-6\">{{ error }}</p>\n <a\n :href=\"url\"\n download\n class=\"vfp-inline-flex vfp-items-center vfp-gap-2 vfp-px-4 vfp-py-2 md:vfp-px-6 md:vfp-py-3 vfp-bg-gradient-to-r vfp-from-purple-500 vfp-to-pink-500 vfp-text-fg-primary vfp-text-sm md:vfp-text-base vfp-rounded-lg md:vfp-rounded-xl hover:vfp-scale-105 vfp-transition-all vfp-shadow-lg\"\n >\n 下载文件\n </a>\n <p class=\"vfp-text-xs vfp-text-fg-muted vfp-mt-3 md:vfp-mt-4\">提示:可以使用 Microsoft Excel 或 WPS 打开</p>\n </div>\n </div>\n\n <div\n v-if=\"!error\"\n ref=\"containerRef\"\n class=\"xlsx-spreadsheet-container vfp-w-full vfp-h-full\"\n :style=\"{ opacity: loading ? 0 : 1 }\"\n />\n </div>\n</template>\n"],"names":["props","__props","t","useTranslator","loading","ref","error","containerRef","sheetData","resizeObserver","resizeTimeout","lastDimensions","calculateDimensions","rawWidth","rawHeight","width","height","mountSpreadsheet","isMobile","Spreadsheet","loadExcel","response","arrayBuffer","workbook","ExcelJS","convertWorkbookToSpreadsheetData","err","errorMsg","onMounted","isInitialRender","newDimensions","widthDiff","heightDiff","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_hoisted_2","_createElementVNode","_hoisted_3","_hoisted_4","_toDisplayString","_unref","_hoisted_5","_hoisted_6","_hoisted_7","_createVNode","FileSpreadsheet","_hoisted_8","_hoisted_9","_hoisted_10","_cache"],"mappings":";;;;;;;;;;;;;;;;;;AASA,UAAMA,IAAQC,GAIR,EAAE,GAAAC,EAAA,IAAMC,EAAA,GAERC,IAAUC,EAAI,EAAI,GAClBC,IAAQD,EAAmB,IAAI,GAC/BE,IAAeF,EAA2B,IAAI;AACpD,QAAIG,IAA8C,MAC9CC,IAAwC,MACxCC,IAA+B,MAC/BC,IAAiB,EAAE,OAAO,GAAG,QAAQ,EAAA;AAEzC,UAAMC,IAAsB,MAAM;AAChC,UAAI,CAACL,EAAa,MAAO,QAAO,EAAE,OAAO,KAAK,QAAQ,IAAA;AACtD,YAAMM,IAAWN,EAAa,MAAM,aAC9BO,IAAYP,EAAa,MAAM,cAC/BQ,IAAQF,IAAW,MAAMA,IAAW,KACp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AA,IACzD,CAAC,cAIC4B,EAAA,GAAAC,EA4CM,OA5CNC,GA4CM;AAAA,MA1CIjC,EAAA,SADR+B,EAAA,GAAAC,EAUM,OAVNE,GAUM;AAAA,QANJC,EAKM,OALNC,GAKM;AAAA,0BAJJD,EAEE,OAAA,EADA,OAAM,iKAAA,GAAgK,MAAA,EAAA;AAAA,UAExKA,EAAuG,KAAvGE,GAAuGC,EAAxBC,EAAAzC,CAAA,EAAC,cAAA,CAAA,GAAA,CAAA;AAAA,QAAA;;MAK5EI,EAAA,UAAUF,EAAA,SADlB+B,KAAAC,EAuBM,OAvBNQ,GAuBM;AAAA,QAnBJL,EAkBM,OAlBNM,GAkBM;AAAA,UAjBJN,EAIM,OAJNO,GAIM;AAAA,YADJC,EAAyFJ,EAAAK,CAAA,GAAA,EAAxE,OAAM,iEAA+D;AAAA,UAAA;UAExFT,EAEI,KAFJU,GAEIP,EADCC,EAAAzC,CAAA,EAAC,kBAAA,CAAA,GAAA,CAAA;AAAA,UAENqC,EAA+F,KAA/FW,GAA+FR,EAAZpC,EAAA,KAAK,GAAA,CAAA;AAAA,UACxFiC,EAMI,KAAA;AAAA,YALD,MAAMtC,EAAA;AAAA,YACP,UAAA;AAAA,YACA,OAAM;AAAA,UAAA,GACP,UAED,GAAAkD,CAAA;AAAA,UACAC,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAAb,EAAkG,KAAA,EAA/F,OAAM,wDAAqD,oCAAgC,EAAA;AAAA,QAAA;;MAKzFjC,EAAA,0BADT8B,EAKE,OAAA;AAAA;iBAHI;AAAA,QAAJ,KAAI7B;AAAA,QACJ,OAAM;AAAA,QACL,oBAAkBH,EAAA,QAAO,IAAA,GAAA;AAAA,MAAA;;;;"}
@@ -0,0 +1,203 @@
1
+ import { defineComponent as V, ref as p, watch as te, onBeforeUnmount as oe, openBlock as m, createElementBlock as h, createElementVNode as f, toDisplayString as P, createCommentVNode as C, normalizeStyle as S, unref as z, createVNode as U, h as b } from "vue";
2
+ import { X as re } from "lucide-vue-next";
3
+ import "foliate-js/view.js";
4
+ import { u as ae, _ as le } from "./index-C324a7kV.mjs";
5
+ const ne = {
6
+ class: "vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-overflow-hidden",
7
+ style: { background: "#f5f5f0" }
8
+ }, se = {
9
+ key: 0,
10
+ class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-secondary vfp-text-center vfp-p-6"
11
+ }, fe = { class: "vfp-text-lg" }, ie = {
12
+ key: 1,
13
+ class: "vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-z-10"
14
+ }, pe = { class: "vfp-flex vfp-items-center vfp-justify-between vfp-px-4 vfp-py-3 vfp-border-b vfp-border-line-weak vfp-flex-shrink-0" }, ve = { class: "vfp-text-fg-primary vfp-font-medium vfp-text-sm" }, ce = { class: "vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1" }, X = V({
15
+ name: "MobiTocList",
16
+ props: {
17
+ items: { type: Array, required: !0 },
18
+ activeHref: { type: String, default: "" },
19
+ depth: { type: Number, default: 0 }
20
+ },
21
+ emits: ["select"],
22
+ render() {
23
+ return b(
24
+ "ul",
25
+ { style: { listStyle: "none", padding: 0, margin: this.depth > 0 ? "0 0 0 16px" : 0 } },
26
+ this.items.map(
27
+ (r, T) => {
28
+ var g, x, A;
29
+ return b("li", { key: `${r.href ?? r.label}-${T}` }, [
30
+ r.href ? b(
31
+ "button",
32
+ {
33
+ onClick: () => this.$emit("select", r.href),
34
+ class: [
35
+ "vfp-w-full vfp-text-left vfp-py-2 vfp-px-3 vfp-text-sm vfp-rounded vfp-transition-all vfp-truncate",
36
+ this.activeHref === r.href ? "vfp-text-fg-primary vfp-bg-surface-3 vfp-font-medium" : "vfp-text-fg-secondary hover:vfp-text-fg-primary hover:vfp-bg-surface-2"
37
+ ],
38
+ title: r.label,
39
+ style: "background: none; border: none; cursor: pointer"
40
+ },
41
+ (g = r.label) == null ? void 0 : g.trim()
42
+ ) : b(
43
+ "div",
44
+ { class: "vfp-w-full vfp-py-2 vfp-px-3 vfp-text-sm vfp-text-fg-tertiary vfp-truncate" },
45
+ (x = r.label) == null ? void 0 : x.trim()
46
+ ),
47
+ (A = r.subitems) != null && A.length ? b(X, {
48
+ items: r.subitems,
49
+ activeHref: this.activeHref,
50
+ depth: this.depth + 1,
51
+ onSelect: (c) => this.$emit("select", c)
52
+ }) : null
53
+ ]);
54
+ }
55
+ )
56
+ );
57
+ }
58
+ }), ue = { name: "MobiRenderer" }, de = /* @__PURE__ */ V({
59
+ ...ue,
60
+ props: {
61
+ url: {}
62
+ },
63
+ emits: ["chapterChange", "fullWidthChange"],
64
+ setup(r, { expose: T, emit: g }) {
65
+ const x = `
66
+ @namespace epub "http://www.idpf.org/2007/ops";
67
+ html { color-scheme: light; }
68
+ body {
69
+ background: #ffffff !important;
70
+ color: #1a1a1a !important;
71
+ font-family: "Noto Serif SC", "Source Han Serif SC", Georgia, "Times New Roman", serif !important;
72
+ font-size: 16px !important;
73
+ line-height: 2 !important;
74
+ max-width: 100% !important;
75
+ box-sizing: border-box !important;
76
+ word-break: break-word !important;
77
+ overflow-wrap: break-word !important;
78
+ }
79
+ p, li, blockquote, dd { line-height: 2; text-align: justify; }
80
+ p { text-indent: 2em; margin: 0.8em 0; }
81
+ h1 { text-align: center; margin: 1.5em 0 1em; }
82
+ h2 { margin: 1.2em 0 0.8em; }
83
+ h3 { margin: 1em 0 0.6em; }
84
+ img { max-width: 100% !important; height: auto !important; }
85
+ a { color: #2563eb; text-decoration: none; }
86
+ pre { white-space: pre-wrap !important; }
87
+ `, c = r, M = g, { t: $ } = ae(), E = p(null);
88
+ let e = null, N = 1;
89
+ const y = p(!0), v = p(null), w = p([]), l = p(!1), k = p(""), u = p(!1), H = (o, t) => {
90
+ t > 0 && (N = t), M("chapterChange", Math.max(1, o + 1), N);
91
+ }, q = () => {
92
+ e == null || e.prev().catch(() => {
93
+ });
94
+ }, G = () => {
95
+ e == null || e.next().catch(() => {
96
+ });
97
+ }, O = () => {
98
+ l.value = !l.value;
99
+ }, Z = () => {
100
+ u.value = !u.value, M("fullWidthChange", u.value), e != null && e.renderer && e.renderer.setAttribute("max-inline-size", u.value ? "9999" : "720");
101
+ }, J = (o) => {
102
+ k.value = o, l.value = !1, e == null || e.goTo(o).catch(() => {
103
+ });
104
+ };
105
+ T({ prevPage: q, nextPage: G, toggleFullWidth: Z, toggleToc: O });
106
+ const K = async () => {
107
+ var t, i, j, L;
108
+ const o = E.value;
109
+ if (o) {
110
+ y.value = !0, v.value = null, w.value = [], l.value = !1, k.value = "", o.replaceChildren(), e = null;
111
+ try {
112
+ const n = document.createElement("foliate-view");
113
+ o.appendChild(n), e = n, n.addEventListener("relocate", (D) => {
114
+ var F;
115
+ const s = D.detail;
116
+ if (!s) return;
117
+ const d = s.location;
118
+ if (d && typeof d.current == "number" && typeof d.total == "number")
119
+ H(d.current, d.total);
120
+ else {
121
+ const Y = ((F = e == null ? void 0 : e.book) == null ? void 0 : F.sections) ?? [], I = s.index ?? 0, ee = s.fraction ?? 0, W = Math.max(Y.length, 1);
122
+ H(Math.round((I + ee) / W * W), W);
123
+ }
124
+ const _ = s.tocItem;
125
+ _ != null && _.href && (k.value = _.href);
126
+ });
127
+ const R = await fetch(c.url);
128
+ if (!R.ok) throw new Error(`请求失败: ${R.status}`);
129
+ const Q = await R.blob();
130
+ let B = "book.mobi";
131
+ try {
132
+ const s = new URL(c.url, window.location.href).pathname.split("/").pop();
133
+ s && (B = decodeURIComponent(s));
134
+ } catch {
135
+ }
136
+ await n.open(new File([Q], B));
137
+ const a = n.renderer;
138
+ a && (a.setAttribute("animated", ""), a.setAttribute("max-inline-size", "720"), a.setAttribute("margin", "48"), a.setAttribute("gap", "5%"), (t = a.setStyles) == null || t.call(a, x), await ((i = a.next) == null ? void 0 : i.call(a))), w.value = ((j = n.book) == null ? void 0 : j.toc) ?? [], y.value = !1, H(0, ((L = n.book) == null ? void 0 : L.sections.length) ?? 1);
139
+ } catch (n) {
140
+ console.error("MOBI/AZW3 加载错误:", n), v.value = $.value("mobi.load_failed"), y.value = !1;
141
+ }
142
+ }
143
+ };
144
+ return te(() => c.url, () => K(), { immediate: !0 }), oe(() => {
145
+ var o, t, i;
146
+ try {
147
+ (t = (o = e == null ? void 0 : e.book) == null ? void 0 : o.destroy) == null || t.call(o);
148
+ } catch {
149
+ }
150
+ e = null, (i = E.value) == null || i.replaceChildren();
151
+ }), (o, t) => (m(), h("div", ne, [
152
+ v.value ? (m(), h("div", se, [
153
+ f("p", fe, P(v.value), 1)
154
+ ])) : C("", !0),
155
+ y.value && !v.value ? (m(), h("div", ie, [...t[2] || (t[2] = [
156
+ f("div", { class: "vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin" }, null, -1)
157
+ ])])) : C("", !0),
158
+ w.value.length > 0 ? (m(), h("div", {
159
+ key: 2,
160
+ class: "vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex vfp-transition-opacity vfp-duration-300",
161
+ style: S({ opacity: l.value ? 1 : 0, pointerEvents: l.value ? "auto" : "none" })
162
+ }, [
163
+ f("div", {
164
+ class: "vfp-w-72 vfp-max-w-[80%] vfp-h-full vfp-bg-surface-overlay vfp-backdrop-blur-xl vfp-border-r vfp-border-line-weak vfp-flex vfp-flex-col vfp-shadow-2xl vfp-transition-transform vfp-duration-300",
165
+ style: S({ transform: l.value ? "translateX(0)" : "translateX(-100%)" })
166
+ }, [
167
+ f("div", pe, [
168
+ f("span", ve, P(z($)("toolbar.toc")), 1),
169
+ f("button", {
170
+ class: "toc-close-btn",
171
+ onClick: t[0] || (t[0] = (i) => l.value = !1)
172
+ }, [
173
+ U(z(re), { class: "vfp-w-4 vfp-h-4" })
174
+ ])
175
+ ]),
176
+ f("div", ce, [
177
+ U(z(X), {
178
+ items: w.value,
179
+ "active-href": k.value,
180
+ onSelect: J
181
+ }, null, 8, ["items", "active-href"])
182
+ ])
183
+ ], 4),
184
+ f("div", {
185
+ class: "vfp-flex-1 vfp-transition-opacity vfp-duration-300",
186
+ style: S({ background: l.value ? "rgba(0,0,0,0.3)" : "transparent" }),
187
+ onClick: t[1] || (t[1] = (i) => l.value = !1)
188
+ }, null, 4)
189
+ ], 4)) : C("", !0),
190
+ v.value ? C("", !0) : (m(), h("div", {
191
+ key: 3,
192
+ ref_key: "hostRef",
193
+ ref: E,
194
+ class: "vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg",
195
+ style: S({ width: u.value ? "100%" : "794px", maxWidth: "100%", transition: "width 0.3s ease" })
196
+ }, null, 4))
197
+ ]));
198
+ }
199
+ }), xe = /* @__PURE__ */ le(de, [["__scopeId", "data-v-c0eebdf8"]]);
200
+ export {
201
+ xe as default
202
+ };
203
+ //# sourceMappingURL=index-Bri7VeRx.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Bri7VeRx.mjs","sources":["../../src/renderers/Mobi/index.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch, onBeforeUnmount, defineComponent, h, type PropType } from 'vue';\nimport { X } from 'lucide-vue-next';\nimport 'foliate-js/view.js';\nimport { useTranslator } from '../../composables/useTranslator';\n\ninterface TocItem {\n label: string;\n href?: string;\n subitems?: TocItem[];\n}\n\ninterface FoliateView extends HTMLElement {\n book: {\n sections: unknown[];\n toc?: TocItem[];\n destroy?: () => void;\n } | null;\n renderer: HTMLElement & {\n setStyles?: (css: string) => void;\n next?: () => Promise<void>;\n page?: number;\n pages?: number;\n };\n open(target: string | Blob | File | ArrayBuffer): Promise<void>;\n goTo(target: number | string): Promise<void>;\n prev(distance?: number): Promise<void>;\n next(distance?: number): Promise<void>;\n}\n\nconst READER_CSS = `\n @namespace epub \"http://www.idpf.org/2007/ops\";\n html { color-scheme: light; }\n body {\n background: #ffffff !important;\n color: #1a1a1a !important;\n font-family: \"Noto Serif SC\", \"Source Han Serif SC\", Georgia, \"Times New Roman\", serif !important;\n font-size: 16px !important;\n line-height: 2 !important;\n max-width: 100% !important;\n box-sizing: border-box !important;\n word-break: break-word !important;\n overflow-wrap: break-word !important;\n }\n p, li, blockquote, dd { line-height: 2; text-align: justify; }\n p { text-indent: 2em; margin: 0.8em 0; }\n h1 { text-align: center; margin: 1.5em 0 1em; }\n h2 { margin: 1.2em 0 0.8em; }\n h3 { margin: 1em 0 0.6em; }\n img { max-width: 100% !important; height: auto !important; }\n a { color: #2563eb; text-decoration: none; }\n pre { white-space: pre-wrap !important; }\n`;\n\nconst A4_WIDTH = 794;\n\nconst props = defineProps<{ url: string }>();\nconst emit = defineEmits<{\n (e: 'chapterChange', current: number, total: number): void;\n (e: 'fullWidthChange', isFullWidth: boolean): void;\n}>();\n\nconst { t } = useTranslator();\n\nconst hostRef = ref<HTMLDivElement | null>(null);\nlet viewInstance: FoliateView | null = null;\nlet totalLocations = 1;\n\nconst loading = ref(true);\nconst error = ref<string | null>(null);\nconst toc = ref<TocItem[]>([]);\nconst showToc = ref(false);\nconst activeTocHref = ref('');\nconst isFullWidth = ref(false);\n\nconst reportProgress = (current: number, total: number) => {\n if (total > 0) totalLocations = total;\n emit('chapterChange', Math.max(1, current + 1), totalLocations);\n};\n\nconst prevPage = () => { viewInstance?.prev().catch(() => {}); };\nconst nextPage = () => { viewInstance?.next().catch(() => {}); };\nconst toggleToc = () => { showToc.value = !showToc.value; };\nconst toggleFullWidth = () => {\n isFullWidth.value = !isFullWidth.value;\n emit('fullWidthChange', isFullWidth.value);\n if (viewInstance?.renderer) {\n viewInstance.renderer.setAttribute('max-inline-size', isFullWidth.value ? '9999' : '720');\n }\n};\n\nconst handleTocClick = (href: string) => {\n activeTocHref.value = href;\n showToc.value = false;\n viewInstance?.goTo(href).catch(() => {});\n};\n\ndefineExpose({ prevPage, nextPage, toggleFullWidth, toggleToc });\n\nconst load = async () => {\n const host = hostRef.value;\n if (!host) return;\n loading.value = true;\n error.value = null;\n toc.value = [];\n showToc.value = false;\n activeTocHref.value = '';\n host.replaceChildren();\n viewInstance = null;\n\n try {\n const view = document.createElement('foliate-view') as FoliateView;\n host.appendChild(view);\n viewInstance = view;\n\n // 先注册事件\n view.addEventListener('relocate', (e: Event) => {\n const detail = (e as CustomEvent).detail;\n if (!detail) return;\n const loc = detail.location as { current?: number; total?: number } | undefined;\n if (loc && typeof loc.current === 'number' && typeof loc.total === 'number') {\n reportProgress(loc.current, loc.total);\n } else {\n const sections = viewInstance?.book?.sections ?? [];\n const idx = detail.index ?? 0;\n const frac = detail.fraction ?? 0;\n const total = Math.max(sections.length, 1);\n reportProgress(Math.round((idx + frac) / total * total), total);\n }\n const tocItem = detail.tocItem as { href?: string } | undefined;\n if (tocItem?.href) activeTocHref.value = tocItem.href;\n });\n\n const res = await fetch(props.url);\n if (!res.ok) throw new Error(`请求失败: ${res.status}`);\n const blob = await res.blob();\n let name = 'book.mobi';\n try {\n const u = new URL(props.url, window.location.href);\n const base = u.pathname.split('/').pop();\n if (base) name = decodeURIComponent(base);\n } catch { /* blob: URL */ }\n\n await view.open(new File([blob], name));\n\n // 配置 paginator:paginated 模式 + 动画\n const renderer = view.renderer;\n if (renderer) {\n renderer.setAttribute('animated', '');\n renderer.setAttribute('max-inline-size', '720');\n renderer.setAttribute('margin', '48');\n renderer.setAttribute('gap', '5%');\n renderer.setStyles?.(READER_CSS);\n await renderer.next?.();\n }\n\n toc.value = (view.book?.toc ?? []) as TocItem[];\n loading.value = false;\n reportProgress(0, view.book?.sections.length ?? 1);\n } catch (err) {\n console.error('MOBI/AZW3 加载错误:', err);\n error.value = t.value('mobi.load_failed');\n loading.value = false;\n }\n};\n\nwatch(() => props.url, () => load(), { immediate: true });\nonBeforeUnmount(() => {\n try { viewInstance?.book?.destroy?.(); } catch { /* ignore */ }\n viewInstance = null;\n hostRef.value?.replaceChildren();\n});\n</script>\n\n<template>\n <div\n class=\"vfp-relative vfp-w-full vfp-h-full vfp-flex vfp-justify-center vfp-overflow-hidden\"\n style=\"background: #f5f5f0\"\n >\n <div\n v-if=\"error\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-text-fg-secondary vfp-text-center vfp-p-6\"\n >\n <p class=\"vfp-text-lg\">{{ error }}</p>\n </div>\n\n <div\n v-if=\"loading && !error\"\n class=\"vfp-absolute vfp-inset-0 vfp-flex vfp-items-center vfp-justify-center vfp-z-10\"\n >\n <div class=\"vfp-w-12 vfp-h-12 vfp-border-4 vfp-border-line-strong vfp-border-t-spinner-head vfp-rounded-full vfp-animate-spin\" />\n </div>\n\n <!-- 目录侧栏 -->\n <div\n v-if=\"toc.length > 0\"\n class=\"vfp-absolute vfp-inset-0 vfp-z-20 vfp-flex vfp-transition-opacity vfp-duration-300\"\n :style=\"{ opacity: showToc ? 1 : 0, pointerEvents: showToc ? 'auto' : 'none' }\"\n >\n <div\n class=\"vfp-w-72 vfp-max-w-[80%] vfp-h-full vfp-bg-surface-overlay vfp-backdrop-blur-xl vfp-border-r vfp-border-line-weak vfp-flex vfp-flex-col vfp-shadow-2xl vfp-transition-transform vfp-duration-300\"\n :style=\"{ transform: showToc ? 'translateX(0)' : 'translateX(-100%)' }\"\n >\n <div class=\"vfp-flex vfp-items-center vfp-justify-between vfp-px-4 vfp-py-3 vfp-border-b vfp-border-line-weak vfp-flex-shrink-0\">\n <span class=\"vfp-text-fg-primary vfp-font-medium vfp-text-sm\">{{ t('toolbar.toc') }}</span>\n <button class=\"toc-close-btn\" @click=\"showToc = false\">\n <X class=\"vfp-w-4 vfp-h-4\" />\n </button>\n </div>\n <div class=\"vfp-flex-1 vfp-overflow-y-auto vfp-py-4 vfp-px-1\">\n <MobiTocList :items=\"toc\" :active-href=\"activeTocHref\" @select=\"handleTocClick\" />\n </div>\n </div>\n <div\n class=\"vfp-flex-1 vfp-transition-opacity vfp-duration-300\"\n :style=\"{ background: showToc ? 'rgba(0,0,0,0.3)' : 'transparent' }\"\n @click=\"showToc = false\"\n />\n </div>\n\n <div\n v-if=\"!error\"\n ref=\"hostRef\"\n class=\"vfp-h-full vfp-bg-surface-toolbar vfp-shadow-lg\"\n :style=\"{ width: isFullWidth ? '100%' : A4_WIDTH + 'px', maxWidth: '100%', transition: 'width 0.3s ease' }\"\n />\n </div>\n</template>\n\n<script lang=\"ts\">\ninterface TocItemLocal {\n label: string;\n href?: string;\n subitems?: TocItemLocal[];\n}\n\nconst MobiTocList = defineComponent({\n name: 'MobiTocList',\n props: {\n items: { type: Array as PropType<TocItemLocal[]>, required: true },\n activeHref: { type: String, default: '' },\n depth: { type: Number, default: 0 },\n },\n emits: ['select'],\n render(): ReturnType<typeof h> {\n return h(\n 'ul',\n { style: { listStyle: 'none', padding: 0, margin: this.depth > 0 ? '0 0 0 16px' : 0 } },\n this.items.map((item: TocItemLocal, i: number) =>\n h('li', { key: `${item.href ?? item.label}-${i}` }, [\n item.href\n ? h(\n 'button',\n {\n onClick: () => this.$emit('select', item.href),\n class: [\n 'vfp-w-full vfp-text-left vfp-py-2 vfp-px-3 vfp-text-sm vfp-rounded vfp-transition-all vfp-truncate',\n this.activeHref === item.href\n ? 'vfp-text-fg-primary vfp-bg-surface-3 vfp-font-medium'\n : 'vfp-text-fg-secondary hover:vfp-text-fg-primary hover:vfp-bg-surface-2',\n ],\n title: item.label,\n style: 'background: none; border: none; cursor: pointer',\n },\n item.label?.trim()\n )\n : h(\n 'div',\n { class: 'vfp-w-full vfp-py-2 vfp-px-3 vfp-text-sm vfp-text-fg-tertiary vfp-truncate' },\n item.label?.trim()\n ),\n item.subitems?.length\n ? h(MobiTocList, {\n items: item.subitems,\n activeHref: this.activeHref,\n depth: (this.depth as number) + 1,\n onSelect: (href: string) => this.$emit('select', href),\n })\n : null,\n ])\n )\n );\n },\n});\n\nexport default { name: 'MobiRenderer' };\n</script>\n\n<style scoped>\n.toc-close-btn {\n color: var(--fp-fg-tertiary);\n background: none;\n border: none;\n cursor: pointer;\n transition: color 0.15s;\n}\n.toc-close-btn:hover { color: #fff; }\n</style>\n"],"names":["MobiTocList","defineComponent","h","item","i","_a","_b","_c","href","__default__","READER_CSS","props","__props","emit","__emit","t","useTranslator","hostRef","ref","viewInstance","totalLocations","loading","error","toc","showToc","activeTocHref","isFullWidth","reportProgress","current","total","prevPage","nextPage","toggleToc","toggleFullWidth","handleTocClick","__expose","load","host","view","e","detail","loc","sections","idx","frac","tocItem","res","blob","name","base","renderer","_d","err","watch","onBeforeUnmount","_openBlock","_createElementBlock","_hoisted_1","_hoisted_2","_createElementVNode","_hoisted_3","_toDisplayString","_hoisted_4","_cache","_normalizeStyle","_hoisted_5","_hoisted_6","_unref","_createVNode","X","_hoisted_7"],"mappings":";;;;;;;;;;;;;iRA4OMA,IAAcC,EAAgB;AAAA,EAClC,MAAM;AAAA,EACN,OAAO;AAAA,IACL,OAAO,EAAE,MAAM,OAAmC,UAAU,GAAA;AAAA,IAC5D,YAAY,EAAE,MAAM,QAAQ,SAAS,GAAA;AAAA,IACrC,OAAO,EAAE,MAAM,QAAQ,SAAS,EAAA;AAAA,EAAE;AAAA,EAEpC,OAAO,CAAC,QAAQ;AAAA,EAChB,SAA+B;AAC7B,WAAOC;AAAA,MACL;AAAA,MACA,EAAE,OAAO,EAAE,WAAW,QAAQ,SAAS,GAAG,QAAQ,KAAK,QAAQ,IAAI,eAAe,IAAE;AAAA,MACpF,KAAK,MAAM;AAAA,QAAI,CAACC,GAAoBC,MAAA;;AAClC,iBAAAF,EAAE,MAAM,EAAE,KAAK,GAAGC,EAAK,QAAQA,EAAK,KAAK,IAAIC,CAAC,MAAM;AAAA,YAClDD,EAAK,OACDD;AAAA,cACE;AAAA,cACA;AAAA,gBACE,SAAS,MAAM,KAAK,MAAM,UAAUC,EAAK,IAAI;AAAA,gBAC7C,OAAO;AAAA,kBACL;AAAA,kBACA,KAAK,eAAeA,EAAK,OACrB,yDACA;AAAA,gBAAA;AAAA,gBAEN,OAAOA,EAAK;AAAA,gBACZ,OAAO;AAAA,cAAA;AAAA,eAETE,IAAAF,EAAK,UAAL,gBAAAE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