filens-preview 0.3.0 → 0.3.2
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/README.md +13 -7
- package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +870 -0
- package/dist/all-in-one/filens.js +5069 -114897
- package/dist/index.d.ts +2 -0
- package/dist/split/THIRD-PARTY-NOTICES.txt +870 -0
- package/dist/split/chunks/archive-haip2eOP.js +1 -0
- package/dist/split/chunks/browser-video-session-C_14e_mG.js +1 -0
- package/dist/split/chunks/cad-5oTkbaDV.js +7 -0
- package/dist/split/chunks/core-EjELrtsP.js +17 -0
- package/dist/split/chunks/diagram-BRcdlitF.js +1 -0
- package/dist/split/chunks/docx-I39iDYpR.js +1 -0
- package/dist/split/chunks/ebook-BRfadCGl.js +5 -0
- package/dist/split/chunks/index-C4jdVbDq.js +1 -0
- package/dist/split/chunks/index-DkF8PBGR.js +1 -0
- package/dist/split/chunks/iwork-DXq9Adf7.js +4 -0
- package/dist/split/chunks/media-runtime-B6322raw.js +1 -0
- package/dist/split/chunks/mindmap-CyR3TRfx.js +1 -0
- package/dist/split/chunks/model3d-BEt6INTt.js +55 -0
- package/dist/split/chunks/mp4box.all-Bw_Tlr0T-D0URDfA1.js +1 -0
- package/dist/split/chunks/panorama-ChsqnvWC.js +973 -0
- package/dist/split/chunks/pdf-Dzzffz3p.js +12 -0
- package/dist/split/chunks/vendor-C1aIdQ-w.js +4115 -0
- package/dist/split/chunks/xlsx-CITQo0Od.js +3 -0
- package/dist/split/converter-image.wasm +0 -0
- package/dist/split/filens.js +2 -5012
- package/package.json +1 -1
- package/dist/split/chunks/archive-B4jVwD9o.js +0 -921
- package/dist/split/chunks/cad-DMg-lGJX.js +0 -2405
- package/dist/split/chunks/core--zVW212C.js +0 -14627
- package/dist/split/chunks/diagram-CDwCA6LZ.js +0 -654
- package/dist/split/chunks/docx-CuQfFJqr.js +0 -299
- package/dist/split/chunks/ebook-CLlJ8KX3.js +0 -623
- package/dist/split/chunks/iwork-dNVC0X8j.js +0 -772
- package/dist/split/chunks/media-runtime-gcsBQMuo.js +0 -48
- package/dist/split/chunks/mindmap-g0-VoK-K.js +0 -560
- package/dist/split/chunks/model3d-1G1CC52V.js +0 -5093
- package/dist/split/chunks/panorama-D7GVivtM.js +0 -5972
- package/dist/split/chunks/pdf-CecYOWld.js +0 -17898
- package/dist/split/chunks/vendor-DPFNKNkh.js +0 -59575
- package/dist/split/chunks/xlsx-Co26yo-R.js +0 -818
|
@@ -1,818 +0,0 @@
|
|
|
1
|
-
var K = Object.defineProperty;
|
|
2
|
-
var Q = (t, e, r) => e in t ? K(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
-
var v = (t, e, r) => Q(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { o as ee, h as W, i as te, c as re, b as se, a as ne, j as ie, f as oe, k as ae } from "./core--zVW212C.js";
|
|
5
|
-
import { f as le } from "./vendor-DPFNKNkh.js";
|
|
6
|
-
function he(t, e) {
|
|
7
|
-
var b, p;
|
|
8
|
-
if (t.includes("<!") || (b = e.fontStyles) != null && b.length && /<cols\b/.test(t)) return;
|
|
9
|
-
const r = /<sheetData\s*>/.exec(t);
|
|
10
|
-
if (!r) return;
|
|
11
|
-
const s = r.index + r[0].length, n = t.indexOf("</sheetData>", s);
|
|
12
|
-
if (n < 0) return;
|
|
13
|
-
const i = t.slice(s, n);
|
|
14
|
-
if (/<(?:f|is)\b/.test(i)) return;
|
|
15
|
-
const o = [], a = /\s*<row\b([^<>]*?)(?:\/>|>([\s\S]*?)<\/row\s*>)/gy, d = /\s*<c\b([^<>]*?)(?:\/>|>([\s\S]*?)<\/c\s*>)/gy;
|
|
16
|
-
let u = 0, f = 0, m = 0;
|
|
17
|
-
for (; u < i.length; ) {
|
|
18
|
-
a.lastIndex = u;
|
|
19
|
-
const l = a.exec(i);
|
|
20
|
-
if (!l) {
|
|
21
|
-
if (i.slice(u).trim()) return;
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
const g = Z(l[1]);
|
|
25
|
-
if (!g) return;
|
|
26
|
-
const c = Number(g.r ?? o.length + 1);
|
|
27
|
-
if (!Number.isInteger(c) || c < 1) return;
|
|
28
|
-
const w = [], S = l[2] ?? "";
|
|
29
|
-
let y = 0;
|
|
30
|
-
for (; y < S.length; ) {
|
|
31
|
-
d.lastIndex = y;
|
|
32
|
-
const A = d.exec(S);
|
|
33
|
-
if (!A) {
|
|
34
|
-
if (S.slice(y).trim()) return;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
const C = Z(A[1]);
|
|
38
|
-
if (!C) return;
|
|
39
|
-
const I = A[2] ?? "", N = /^\s*(?:<v\s*>([\s\S]*?)<\/v\s*>|<v\s*\/>)?\s*$/.exec(I);
|
|
40
|
-
if (!N) return;
|
|
41
|
-
const E = N[1] ?? "";
|
|
42
|
-
if (E.trim() && !/^[\s]*[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?\s*$/.test(E) && !/^\s*(?:true|false)\s*$/.test(E) || C.t && !["n", "s", "b"].includes(C.t)) return;
|
|
43
|
-
if (C.r) {
|
|
44
|
-
const $ = /^([A-Z]+)([1-9]\d*)$/i.exec(C.r);
|
|
45
|
-
if (!$) return;
|
|
46
|
-
let T = 0;
|
|
47
|
-
for (const Y of $[1].toUpperCase()) T = T * 26 + Y.charCodeAt(0) - 64;
|
|
48
|
-
const L = C.t === "s" ? e.sharedStrings[Number(E)] ?? "" : C.t === "b" ? E.trim() === "1" || E.trim() === "true" ? "TRUE" : "FALSE" : E, R = { ref: C.r, row: Number($[2]), column: T, value: L }, J = ["1", "true"].includes(g.customFormat) ? g.s : void 0, D = (p = e.fontStyles) == null ? void 0 : p[Number(C.s ?? J ?? 0)];
|
|
49
|
-
D && (R.font = D), w.push(R), m = Math.max(m, T);
|
|
50
|
-
}
|
|
51
|
-
y = d.lastIndex;
|
|
52
|
-
}
|
|
53
|
-
o.push({ index: c, cells: w }), f = Math.max(f, c), u = a.lastIndex;
|
|
54
|
-
}
|
|
55
|
-
return { id: e.id, name: e.name, rows: o, columnCount: m, rowCount: f };
|
|
56
|
-
}
|
|
57
|
-
function Z(t) {
|
|
58
|
-
const e = /* @__PURE__ */ Object.create(null), r = /\s+([A-Za-z_:][\w:.-]*)\s*=\s*(?:"([^"<>&]*)"|'([^'<>&]*)')/gy;
|
|
59
|
-
let s = 0;
|
|
60
|
-
for (; s < t.length; ) {
|
|
61
|
-
r.lastIndex = s;
|
|
62
|
-
const n = r.exec(t);
|
|
63
|
-
if (!n) return t.slice(s).trim() ? void 0 : e;
|
|
64
|
-
e[n[1]] = n[2] ?? n[3], s = r.lastIndex;
|
|
65
|
-
}
|
|
66
|
-
return e;
|
|
67
|
-
}
|
|
68
|
-
const ce = 1e5, M = new le.XMLParser({
|
|
69
|
-
ignoreAttributes: !1,
|
|
70
|
-
attributeNamePrefix: "",
|
|
71
|
-
textNodeName: "#text",
|
|
72
|
-
parseTagValue: !1,
|
|
73
|
-
parseAttributeValue: !1,
|
|
74
|
-
trimValues: !1,
|
|
75
|
-
processEntities: {
|
|
76
|
-
enabled: !0,
|
|
77
|
-
maxEntitySize: 1e4,
|
|
78
|
-
maxExpansionDepth: 10,
|
|
79
|
-
maxTotalExpansions: ce,
|
|
80
|
-
maxExpandedLength: 1e5,
|
|
81
|
-
maxEntityCount: 100
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
async function fe(t, e) {
|
|
85
|
-
var l, g;
|
|
86
|
-
if (k(e == null ? void 0 : e.signal), Ne(((l = e == null ? void 0 : e.route) == null ? void 0 : l.sourceFormat) ?? (e == null ? void 0 : e.descriptor.extension)) === "csv")
|
|
87
|
-
return de(t, e);
|
|
88
|
-
const s = await ue(t, e);
|
|
89
|
-
k(e == null ? void 0 : e.signal);
|
|
90
|
-
const n = await ee(s);
|
|
91
|
-
k(e == null ? void 0 : e.signal);
|
|
92
|
-
const i = [], o = await _(n, "xl/workbook.xml", e == null ? void 0 : e.signal), a = await _(n, "xl/_rels/workbook.xml.rels", e == null ? void 0 : e.signal), d = await pe(n, e == null ? void 0 : e.signal);
|
|
93
|
-
k(e == null ? void 0 : e.signal);
|
|
94
|
-
const u = M.parse(o), f = be(a), m = await ve(n, f, e == null ? void 0 : e.signal), b = ye(u), p = [];
|
|
95
|
-
for (const c of b) {
|
|
96
|
-
k(e == null ? void 0 : e.signal);
|
|
97
|
-
const w = f.find((A) => A.id === c.relationshipId);
|
|
98
|
-
if (!w) {
|
|
99
|
-
i.push(`Missing relationship for sheet ${c.name}.`);
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
const S = O(w.target), y = await ((g = n.get(S)) == null ? void 0 : g.text());
|
|
103
|
-
if (k(e == null ? void 0 : e.signal), !y) {
|
|
104
|
-
i.push(`Missing worksheet file for sheet ${c.name}.`);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
p.push(ke(y, {
|
|
108
|
-
id: c.sheetId,
|
|
109
|
-
name: c.name,
|
|
110
|
-
sharedStrings: d,
|
|
111
|
-
fontStyles: m.styles
|
|
112
|
-
}));
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
sheets: p,
|
|
116
|
-
warnings: i,
|
|
117
|
-
fonts: m.fonts
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
async function de(t, e) {
|
|
121
|
-
k(e == null ? void 0 : e.signal);
|
|
122
|
-
const r = await me(t, e);
|
|
123
|
-
k(e == null ? void 0 : e.signal);
|
|
124
|
-
const { rows: s, columnCount: n } = we(r);
|
|
125
|
-
return {
|
|
126
|
-
sheets: [
|
|
127
|
-
{
|
|
128
|
-
id: "csv",
|
|
129
|
-
name: Te(e == null ? void 0 : e.descriptor.name),
|
|
130
|
-
rows: s,
|
|
131
|
-
columnCount: n,
|
|
132
|
-
rowCount: s.length
|
|
133
|
-
}
|
|
134
|
-
],
|
|
135
|
-
warnings: []
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
async function ue(t, e) {
|
|
139
|
-
if (typeof t == "string") {
|
|
140
|
-
const r = await fetch(t, {
|
|
141
|
-
signal: e == null ? void 0 : e.signal
|
|
142
|
-
});
|
|
143
|
-
if (!r.ok)
|
|
144
|
-
throw new Error(`Failed to load XLSX source: ${r.status} ${r.statusText}`.trim());
|
|
145
|
-
return new Uint8Array(await r.arrayBuffer());
|
|
146
|
-
}
|
|
147
|
-
return t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : t instanceof ArrayBuffer ? new Uint8Array(t) : t instanceof Blob ? new Uint8Array(await t.arrayBuffer()) : new Uint8Array();
|
|
148
|
-
}
|
|
149
|
-
async function me(t, e) {
|
|
150
|
-
if (typeof t == "string") {
|
|
151
|
-
if (t.trimStart().toLowerCase().startsWith("data:"))
|
|
152
|
-
return ge(t);
|
|
153
|
-
const r = await fetch(t, {
|
|
154
|
-
signal: e == null ? void 0 : e.signal
|
|
155
|
-
});
|
|
156
|
-
if (!r.ok)
|
|
157
|
-
throw new Error(`Failed to load CSV source: ${r.status} ${r.statusText}`.trim());
|
|
158
|
-
return r.text();
|
|
159
|
-
}
|
|
160
|
-
return t instanceof Blob ? t.text() : ArrayBuffer.isView(t) ? new TextDecoder().decode(new Uint8Array(t.buffer, t.byteOffset, t.byteLength)) : t instanceof ArrayBuffer ? new TextDecoder().decode(t) : String(t);
|
|
161
|
-
}
|
|
162
|
-
function ge(t) {
|
|
163
|
-
const e = t.indexOf(",");
|
|
164
|
-
if (e < 0)
|
|
165
|
-
return t;
|
|
166
|
-
const r = t.slice(0, e).toLowerCase(), s = t.slice(e + 1);
|
|
167
|
-
return r.endsWith(";base64") ? new TextDecoder().decode(Uint8Array.from(atob(s), (n) => n.charCodeAt(0))) : decodeURIComponent(s);
|
|
168
|
-
}
|
|
169
|
-
function we(t) {
|
|
170
|
-
t = t.replace(/^\uFEFF/, "");
|
|
171
|
-
const e = [], r = [], s = (f) => {
|
|
172
|
-
for (; r.length < f.length; ) r.push(q(r.length + 1));
|
|
173
|
-
const m = e.length + 1, b = String(m), p = new Array(f.length);
|
|
174
|
-
for (let l = 0; l < f.length; l++)
|
|
175
|
-
p[l] = { ref: r[l] + b, row: m, column: l + 1, value: f[l] };
|
|
176
|
-
e.push({ index: m, cells: p });
|
|
177
|
-
};
|
|
178
|
-
if (!t.includes('"')) {
|
|
179
|
-
const f = t.split(/\r\n|\r|\n/);
|
|
180
|
-
t.length && /[\r\n]$/.test(t) && f.pop();
|
|
181
|
-
for (const m of f) s(m.split(","));
|
|
182
|
-
return { rows: e, columnCount: r.length };
|
|
183
|
-
}
|
|
184
|
-
let n = [], i = "", o = 0, a = 0, d = 0, u = !1;
|
|
185
|
-
for (; o < t.length; ) {
|
|
186
|
-
if (u) {
|
|
187
|
-
const m = t.indexOf('"', o);
|
|
188
|
-
if (m < 0) {
|
|
189
|
-
i += t.slice(o), a = o = t.length;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
i += t.slice(o, m), o = m + 1, t[o] === '"' ? (i += '"', o++) : u = !1, a = o;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
const f = t[o];
|
|
196
|
-
if (f === '"' && i.length === 0 && o === a) {
|
|
197
|
-
u = !0, a = ++o;
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (f === ",") {
|
|
201
|
-
n.push(i + t.slice(a, o)), i = "", a = ++o;
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
if (f === "\r" || f === `
|
|
205
|
-
`) {
|
|
206
|
-
n.push(i + t.slice(a, o)), s(n), n = [], i = "", f === "\r" && t[o + 1] === `
|
|
207
|
-
` ? o += 2 : o += 1, d = a = o;
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
o += 1;
|
|
211
|
-
}
|
|
212
|
-
return (d < t.length || t.length === 0) && (n.push(i + t.slice(a, o)), s(n)), { rows: e, columnCount: r.length };
|
|
213
|
-
}
|
|
214
|
-
function k(t) {
|
|
215
|
-
if (t != null && t.aborted) throw new DOMException("Workbook preview aborted.", "AbortError");
|
|
216
|
-
}
|
|
217
|
-
async function _(t, e, r) {
|
|
218
|
-
k(r);
|
|
219
|
-
const s = t.get(e);
|
|
220
|
-
if (!s)
|
|
221
|
-
throw new Error(`Invalid XLSX file: missing ${e}.`);
|
|
222
|
-
const n = await s.text();
|
|
223
|
-
return k(r), n;
|
|
224
|
-
}
|
|
225
|
-
async function pe(t, e) {
|
|
226
|
-
k(e);
|
|
227
|
-
const r = t.get("xl/sharedStrings.xml");
|
|
228
|
-
if (!r)
|
|
229
|
-
return [];
|
|
230
|
-
const s = await r.text();
|
|
231
|
-
k(e);
|
|
232
|
-
const n = M.parse(s);
|
|
233
|
-
return F(h(n, ["sst", "si"])).map(V);
|
|
234
|
-
}
|
|
235
|
-
function V(t) {
|
|
236
|
-
const e = h(t, ["t"]);
|
|
237
|
-
if (e != null)
|
|
238
|
-
return B(e);
|
|
239
|
-
const r = F(h(t, ["r"]));
|
|
240
|
-
return r.length ? r.map((s) => B(h(s, ["t"]))).join("") : "";
|
|
241
|
-
}
|
|
242
|
-
function B(t) {
|
|
243
|
-
if (typeof t == "string") return t;
|
|
244
|
-
const e = h(t, ["#text"]);
|
|
245
|
-
return typeof e == "string" ? e : "";
|
|
246
|
-
}
|
|
247
|
-
function be(t) {
|
|
248
|
-
const e = M.parse(t);
|
|
249
|
-
return F(h(e, ["Relationships", "Relationship"])).map((r) => ({
|
|
250
|
-
id: String(h(r, ["Id"]) ?? ""),
|
|
251
|
-
target: String(h(r, ["Target"]) ?? ""),
|
|
252
|
-
type: String(h(r, ["Type"]) ?? "")
|
|
253
|
-
})).filter((r) => r.id && r.target);
|
|
254
|
-
}
|
|
255
|
-
function ye(t) {
|
|
256
|
-
return F(h(t, ["workbook", "sheets", "sheet"])).map((e) => ({
|
|
257
|
-
name: String(h(e, ["name"]) ?? "Sheet"),
|
|
258
|
-
sheetId: String(h(e, ["sheetId"]) ?? h(e, ["name"]) ?? "sheet"),
|
|
259
|
-
relationshipId: String(h(e, ["r:id"]) ?? "")
|
|
260
|
-
})).filter((e) => e.relationshipId);
|
|
261
|
-
}
|
|
262
|
-
async function ve(t, e, r) {
|
|
263
|
-
var b, p, l, g;
|
|
264
|
-
const s = O(((b = e.find((c) => {
|
|
265
|
-
var w;
|
|
266
|
-
return (w = c.type) == null ? void 0 : w.endsWith("/styles");
|
|
267
|
-
})) == null ? void 0 : b.target) ?? "styles.xml"), n = await ((p = t.get(s)) == null ? void 0 : p.text());
|
|
268
|
-
if (k(r), !n) return { fonts: [], styles: [] };
|
|
269
|
-
const i = M.parse(n), o = O(((l = e.find((c) => {
|
|
270
|
-
var w;
|
|
271
|
-
return (w = c.type) == null ? void 0 : w.endsWith("/theme");
|
|
272
|
-
})) == null ? void 0 : l.target) ?? "theme/theme1.xml"), a = await ((g = t.get(o)) == null ? void 0 : g.text());
|
|
273
|
-
k(r);
|
|
274
|
-
const d = a ? M.parse(a) : void 0, u = F(h(i, ["styleSheet", "fonts", "font"])).map((c) => {
|
|
275
|
-
const w = h(c, ["scheme", "val"]), S = w === "major" || w === "minor" ? U(d, ["theme", "themeElements", "fontScheme", `${w}Font`, "latin"]) : void 0, y = U(S, ["typeface"]), A = typeof y == "string" && y.trim() ? y : void 0, C = String(A ?? h(c, ["name", "val"]) ?? "").trim(), I = Number(U(S, ["pitchFamily"])), N = Number.isInteger(I) && I >= 0 && I <= 255, E = N && (I & 3) === 1 ? "fixed" : N && (I & 3) === 2 ? "variable" : void 0, $ = N ? W(I >> 4) : {}, T = U(S, ["panose"]), L = h(c, ["b"]), R = L !== void 0 && !["0", "false"].includes(String(h(L, ["val"]) ?? L)) ? 700 : 400;
|
|
276
|
-
return {
|
|
277
|
-
fontFamily: C || void 0,
|
|
278
|
-
// Saved family metadata describes the saved face, not a changed theme face.
|
|
279
|
-
traits: {
|
|
280
|
-
...A ? {
|
|
281
|
-
...$,
|
|
282
|
-
...te(typeof T == "string" ? T : void 0),
|
|
283
|
-
...W(void 0, E)
|
|
284
|
-
} : W(h(c, ["family", "val"])),
|
|
285
|
-
weight: R
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
}), f = F(h(i, ["styleSheet", "cellStyleXfs", "xf"])), m = F(h(i, ["styleSheet", "cellXfs", "xf"]));
|
|
289
|
-
return {
|
|
290
|
-
fonts: u,
|
|
291
|
-
styles: m.map((c) => {
|
|
292
|
-
const w = f[Number(h(c, ["xfId"]) ?? 0)], y = ["0", "false"].includes(String(h(c, ["applyFont"]))) ? h(w, ["fontId"]) : h(c, ["fontId"]) ?? h(w, ["fontId"]);
|
|
293
|
-
return u[Number(y ?? 0)];
|
|
294
|
-
})
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
function U(t, e) {
|
|
298
|
-
for (const r of e) {
|
|
299
|
-
if (!t || typeof t != "object") return;
|
|
300
|
-
const s = t, n = Object.keys(s).find((i) => i.split(":").pop() === r);
|
|
301
|
-
t = n ? s[n] : void 0;
|
|
302
|
-
}
|
|
303
|
-
return t;
|
|
304
|
-
}
|
|
305
|
-
function ke(t, e) {
|
|
306
|
-
const r = he(t, e);
|
|
307
|
-
if (r) return r;
|
|
308
|
-
const s = M.parse(t), n = F(h(s, ["worksheet", "sheetData", "row"])), i = [], o = F(h(s, ["worksheet", "cols", "col"]));
|
|
309
|
-
let a = 0, d = 0;
|
|
310
|
-
for (const u of n) {
|
|
311
|
-
const f = Number(h(u, ["r"]) ?? i.length + 1);
|
|
312
|
-
d = Math.max(d, f);
|
|
313
|
-
const m = ["1", "true"].includes(String(h(u, ["customFormat"]))) ? h(u, ["s"]) : void 0, b = F(h(u, ["c"])).map((p) => {
|
|
314
|
-
var S;
|
|
315
|
-
const l = Se(p, e.sharedStrings);
|
|
316
|
-
if (!l) return null;
|
|
317
|
-
const g = o.find((y) => l.column >= Number(h(y, ["min"])) && l.column <= Number(h(y, ["max"]))), c = h(p, ["s"]) ?? m ?? h(g, ["style"]) ?? 0, w = (S = e.fontStyles) == null ? void 0 : S[Number(c)];
|
|
318
|
-
return w && (l.font = w), l;
|
|
319
|
-
}).filter((p) => p != null);
|
|
320
|
-
for (const p of b)
|
|
321
|
-
a = Math.max(a, p.column);
|
|
322
|
-
i.push({
|
|
323
|
-
index: f,
|
|
324
|
-
cells: b
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
id: e.id,
|
|
329
|
-
name: e.name,
|
|
330
|
-
rows: i,
|
|
331
|
-
columnCount: a,
|
|
332
|
-
rowCount: d
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
function Se(t, e) {
|
|
336
|
-
const r = String(h(t, ["r"]) ?? "");
|
|
337
|
-
if (!r)
|
|
338
|
-
return null;
|
|
339
|
-
const s = P(r), n = String(h(t, ["t"]) ?? ""), i = Ce(t), o = xe(t);
|
|
340
|
-
let a = i ?? "";
|
|
341
|
-
if (n === "s")
|
|
342
|
-
a = e[Number(i ?? "")] ?? "";
|
|
343
|
-
else if (n === "b") {
|
|
344
|
-
const d = i == null ? void 0 : i.trim();
|
|
345
|
-
a = d === "1" || d === "true" ? "TRUE" : "FALSE";
|
|
346
|
-
} else n === "inlineStr" && (a = V(h(t, ["is"])));
|
|
347
|
-
return {
|
|
348
|
-
ref: r,
|
|
349
|
-
row: s.row,
|
|
350
|
-
column: s.column,
|
|
351
|
-
value: a,
|
|
352
|
-
...o ? { formula: o, needsCalculation: i == null } : {}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
function Ce(t) {
|
|
356
|
-
const e = h(t, ["v"]);
|
|
357
|
-
return e == null ? null : String(e);
|
|
358
|
-
}
|
|
359
|
-
function xe(t) {
|
|
360
|
-
const e = h(t, ["f"]);
|
|
361
|
-
if (typeof e == "string")
|
|
362
|
-
return e;
|
|
363
|
-
const r = h(e, ["#text"]);
|
|
364
|
-
return typeof r == "string" ? r : "";
|
|
365
|
-
}
|
|
366
|
-
function j(t, e, r = /* @__PURE__ */ new Set()) {
|
|
367
|
-
if (!e.formula || !e.needsCalculation)
|
|
368
|
-
return e.value;
|
|
369
|
-
if (r.has(e.ref))
|
|
370
|
-
return `=${e.formula}`;
|
|
371
|
-
r.add(e.ref);
|
|
372
|
-
try {
|
|
373
|
-
const s = new Ee(e.formula, (n) => Fe(t, n, r)).read();
|
|
374
|
-
e.value = String(s);
|
|
375
|
-
} catch {
|
|
376
|
-
e.value = `=${e.formula}`;
|
|
377
|
-
} finally {
|
|
378
|
-
r.delete(e.ref), e.needsCalculation = !1;
|
|
379
|
-
}
|
|
380
|
-
return e.value;
|
|
381
|
-
}
|
|
382
|
-
const z = /* @__PURE__ */ new WeakMap();
|
|
383
|
-
function Fe(t, e, r) {
|
|
384
|
-
const s = P(e.replace(/\$/g, ""));
|
|
385
|
-
let n = z.get(t);
|
|
386
|
-
if (!n) {
|
|
387
|
-
n = /* @__PURE__ */ new Map();
|
|
388
|
-
for (const d of t.rows) for (const u of d.cells) n.set(`${d.index}:${u.column}`, u);
|
|
389
|
-
z.set(t, n);
|
|
390
|
-
}
|
|
391
|
-
const i = n.get(`${s.row}:${s.column}`);
|
|
392
|
-
if (!i)
|
|
393
|
-
return 0;
|
|
394
|
-
const o = j(t, i, r).trim();
|
|
395
|
-
if (o === "")
|
|
396
|
-
return 0;
|
|
397
|
-
if (o.toUpperCase() === "TRUE")
|
|
398
|
-
return 1;
|
|
399
|
-
if (o.toUpperCase() === "FALSE")
|
|
400
|
-
return 0;
|
|
401
|
-
const a = Number(o);
|
|
402
|
-
if (!Number.isFinite(a))
|
|
403
|
-
throw new Error(`Formula reference ${e} is not numeric.`);
|
|
404
|
-
return a;
|
|
405
|
-
}
|
|
406
|
-
class Ee {
|
|
407
|
-
constructor(e, r) {
|
|
408
|
-
v(this, "tokens");
|
|
409
|
-
v(this, "index", 0);
|
|
410
|
-
this.readCell = r, this.tokens = Ae(e.replace(/^=/, "").trim());
|
|
411
|
-
}
|
|
412
|
-
read() {
|
|
413
|
-
const e = this.readExpression();
|
|
414
|
-
if (this.index !== this.tokens.length || Array.isArray(e) || !Number.isFinite(e))
|
|
415
|
-
throw new Error("Unsupported formula.");
|
|
416
|
-
return e;
|
|
417
|
-
}
|
|
418
|
-
readExpression() {
|
|
419
|
-
let e = this.readTerm();
|
|
420
|
-
for (; this.peek() === "+" || this.peek() === "-"; ) {
|
|
421
|
-
const r = this.take(), s = this.readTerm();
|
|
422
|
-
e = r === "+" ? x(e) + x(s) : x(e) - x(s);
|
|
423
|
-
}
|
|
424
|
-
return e;
|
|
425
|
-
}
|
|
426
|
-
readTerm() {
|
|
427
|
-
let e = this.readPower();
|
|
428
|
-
for (; this.peek() === "*" || this.peek() === "/"; ) {
|
|
429
|
-
const r = this.take(), s = this.readPower();
|
|
430
|
-
e = r === "*" ? x(e) * x(s) : x(e) / x(s);
|
|
431
|
-
}
|
|
432
|
-
return e;
|
|
433
|
-
}
|
|
434
|
-
readPower() {
|
|
435
|
-
let e = this.readUnary();
|
|
436
|
-
return this.peek() === "^" && (this.take(), e = x(e) ** x(this.readPower())), e;
|
|
437
|
-
}
|
|
438
|
-
readUnary() {
|
|
439
|
-
return this.peek() === "+" || this.peek() === "-" ? (this.take() === "-" ? -1 : 1) * x(this.readUnary()) : this.readPrimary();
|
|
440
|
-
}
|
|
441
|
-
readPrimary() {
|
|
442
|
-
const e = this.take();
|
|
443
|
-
if (e === "(") {
|
|
444
|
-
const r = this.readExpression();
|
|
445
|
-
return this.expect(")"), r;
|
|
446
|
-
}
|
|
447
|
-
if (/^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/i.test(e))
|
|
448
|
-
return Number(e);
|
|
449
|
-
if (/^\$?[A-Z]+\$?\d+$/i.test(e))
|
|
450
|
-
return this.peek() !== ":" ? this.readCell(e) : (this.take(), this.readRange(e, this.take()));
|
|
451
|
-
if (/^[A-Z][A-Z0-9_.]*$/i.test(e)) {
|
|
452
|
-
if (e.toUpperCase() === "TRUE")
|
|
453
|
-
return 1;
|
|
454
|
-
if (e.toUpperCase() === "FALSE")
|
|
455
|
-
return 0;
|
|
456
|
-
if (e.toUpperCase() !== "SUM")
|
|
457
|
-
throw new Error("Unsupported function.");
|
|
458
|
-
this.expect("(");
|
|
459
|
-
const r = [];
|
|
460
|
-
if (this.peek() !== ")")
|
|
461
|
-
do {
|
|
462
|
-
const s = this.readExpression();
|
|
463
|
-
r.push(...Array.isArray(s) ? s : [s]);
|
|
464
|
-
} while (this.peek() === "," && this.take());
|
|
465
|
-
return this.expect(")"), r.reduce((s, n) => s + n, 0);
|
|
466
|
-
}
|
|
467
|
-
throw new Error("Unsupported formula token.");
|
|
468
|
-
}
|
|
469
|
-
readRange(e, r) {
|
|
470
|
-
if (!/^\$?[A-Z]+\$?\d+$/i.test(r))
|
|
471
|
-
throw new Error("Invalid range.");
|
|
472
|
-
const s = P(e.replace(/\$/g, "")), n = P(r.replace(/\$/g, "")), i = [];
|
|
473
|
-
for (let o = Math.min(s.row, n.row); o <= Math.max(s.row, n.row); o += 1)
|
|
474
|
-
for (let a = Math.min(s.column, n.column); a <= Math.max(s.column, n.column); a += 1)
|
|
475
|
-
i.push(this.readCell(`${q(a)}${o}`));
|
|
476
|
-
return i;
|
|
477
|
-
}
|
|
478
|
-
peek() {
|
|
479
|
-
return this.tokens[this.index] ?? "";
|
|
480
|
-
}
|
|
481
|
-
take() {
|
|
482
|
-
const e = this.tokens[this.index];
|
|
483
|
-
if (!e)
|
|
484
|
-
throw new Error("Unexpected end of formula.");
|
|
485
|
-
return this.index += 1, e;
|
|
486
|
-
}
|
|
487
|
-
expect(e) {
|
|
488
|
-
if (this.take() !== e)
|
|
489
|
-
throw new Error(`Expected ${e}.`);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
function x(t) {
|
|
493
|
-
if (Array.isArray(t))
|
|
494
|
-
throw new Error("Range cannot be used as a scalar.");
|
|
495
|
-
return t;
|
|
496
|
-
}
|
|
497
|
-
function Ae(t) {
|
|
498
|
-
const e = [], r = /\s*((?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|\$?[A-Z]+\$?\d+|[A-Z][A-Z0-9_.]*|[()+\-*/^,:])/iy;
|
|
499
|
-
let s = 0;
|
|
500
|
-
for (; s < t.length; ) {
|
|
501
|
-
r.lastIndex = s;
|
|
502
|
-
const n = r.exec(t);
|
|
503
|
-
if (!n)
|
|
504
|
-
throw new Error("Unsupported formula token.");
|
|
505
|
-
e.push(n[1] ?? ""), s = r.lastIndex;
|
|
506
|
-
}
|
|
507
|
-
return e;
|
|
508
|
-
}
|
|
509
|
-
function P(t) {
|
|
510
|
-
const e = /^([A-Z]+)(\d+)$/i.exec(t);
|
|
511
|
-
return e ? {
|
|
512
|
-
column: Ie(e[1] ?? "A"),
|
|
513
|
-
row: Number(e[2] ?? 1)
|
|
514
|
-
} : {
|
|
515
|
-
row: 1,
|
|
516
|
-
column: 1
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function Ie(t) {
|
|
520
|
-
let e = 0;
|
|
521
|
-
for (const r of t.toUpperCase())
|
|
522
|
-
e = e * 26 + r.charCodeAt(0) - 64;
|
|
523
|
-
return e;
|
|
524
|
-
}
|
|
525
|
-
function q(t) {
|
|
526
|
-
let e = t, r = "";
|
|
527
|
-
for (; e > 0; ) {
|
|
528
|
-
const s = (e - 1) % 26;
|
|
529
|
-
r = String.fromCharCode(65 + s) + r, e = Math.floor((e - 1) / 26);
|
|
530
|
-
}
|
|
531
|
-
return r || "A";
|
|
532
|
-
}
|
|
533
|
-
function Te(t) {
|
|
534
|
-
var r;
|
|
535
|
-
return (((r = String(t ?? "").split(/[?#]/, 1)[0]) == null ? void 0 : r.split(/[\\/]/).pop()) ?? "").replace(/\.[^.]+$/, "") || "CSV";
|
|
536
|
-
}
|
|
537
|
-
function Ne(t) {
|
|
538
|
-
return String(t ?? "").trim().replace(/^\./, "").toLowerCase();
|
|
539
|
-
}
|
|
540
|
-
function O(t) {
|
|
541
|
-
const e = t.replace(/\\/g, "/").replace(/^\//, "");
|
|
542
|
-
return e.startsWith("xl/") ? e : `xl/${e}`;
|
|
543
|
-
}
|
|
544
|
-
function h(t, e) {
|
|
545
|
-
let r = t;
|
|
546
|
-
for (const s of e) {
|
|
547
|
-
if (!r || typeof r != "object")
|
|
548
|
-
return;
|
|
549
|
-
r = r[s];
|
|
550
|
-
}
|
|
551
|
-
return r;
|
|
552
|
-
}
|
|
553
|
-
function F(t) {
|
|
554
|
-
return t == null ? [] : Array.isArray(t) ? t : [t];
|
|
555
|
-
}
|
|
556
|
-
const X = 100, Me = [
|
|
557
|
-
{
|
|
558
|
-
extensions: ["xlsx"],
|
|
559
|
-
family: "workbook",
|
|
560
|
-
driverId: "xlsx",
|
|
561
|
-
targetFormat: "xlsx"
|
|
562
|
-
},
|
|
563
|
-
{
|
|
564
|
-
extensions: ["csv"],
|
|
565
|
-
family: "workbook",
|
|
566
|
-
driverId: "xlsx",
|
|
567
|
-
targetFormat: "csv",
|
|
568
|
-
contentTypes: ["text/csv", "application/csv"]
|
|
569
|
-
}
|
|
570
|
-
];
|
|
571
|
-
class $e {
|
|
572
|
-
constructor(e, r = {}) {
|
|
573
|
-
v(this, "listeners", {
|
|
574
|
-
loading: /* @__PURE__ */ new Set(),
|
|
575
|
-
rendered: /* @__PURE__ */ new Set(),
|
|
576
|
-
error: /* @__PURE__ */ new Set(),
|
|
577
|
-
statechange: /* @__PURE__ */ new Set(),
|
|
578
|
-
warnings: /* @__PURE__ */ new Set()
|
|
579
|
-
});
|
|
580
|
-
v(this, "root");
|
|
581
|
-
v(this, "tabs");
|
|
582
|
-
v(this, "grid");
|
|
583
|
-
v(this, "workbook", null);
|
|
584
|
-
v(this, "loadGeneration", 0);
|
|
585
|
-
v(this, "loadController");
|
|
586
|
-
v(this, "removeAbortListener");
|
|
587
|
-
v(this, "state");
|
|
588
|
-
v(this, "fontLoading");
|
|
589
|
-
v(this, "fontReferences", []);
|
|
590
|
-
v(this, "allFontReferences", []);
|
|
591
|
-
v(this, "handleGridScroll", () => {
|
|
592
|
-
var i;
|
|
593
|
-
const e = (i = this.workbook) == null ? void 0 : i.sheets[this.state.activeSheetIndex], r = this.grid.querySelector("tbody");
|
|
594
|
-
if (!e || !r || this.grid.scrollHeight - this.grid.scrollTop - this.grid.clientHeight > this.grid.clientHeight * 2)
|
|
595
|
-
return;
|
|
596
|
-
const s = r.rows.length, n = Math.max(e.rowCount, 1);
|
|
597
|
-
s >= n || H(r, e, s + 1, Math.min(s + X, n));
|
|
598
|
-
});
|
|
599
|
-
this.host = e, this.root = document.createElement("div"), this.root.className = "xlsxv-preview", this.tabs = document.createElement("div"), this.tabs.className = "xlsxv-sheet-tabs", this.grid = document.createElement("div"), this.grid.className = "xlsxv-grid", this.root.replaceChildren(this.tabs, this.grid), this.host.replaceChildren(this.root), this.grid.addEventListener("scroll", this.handleGridScroll, { passive: !0 }), this.state = {
|
|
600
|
-
loading: !1,
|
|
601
|
-
error: null,
|
|
602
|
-
family: "workbook",
|
|
603
|
-
warnings: [],
|
|
604
|
-
capabilities: {
|
|
605
|
-
workbook: !0,
|
|
606
|
-
sheets: !0,
|
|
607
|
-
search: !0,
|
|
608
|
-
download: !0
|
|
609
|
-
},
|
|
610
|
-
activeSheetIndex: 0,
|
|
611
|
-
sheets: [],
|
|
612
|
-
scale: r.initialScale ?? 1
|
|
613
|
-
}, this.fontLoading = se(this, e.ownerDocument, r);
|
|
614
|
-
}
|
|
615
|
-
async load(e, r) {
|
|
616
|
-
var a, d, u;
|
|
617
|
-
this.fontLoading.reset(r.signal, ((a = r.route) == null ? void 0 : a.targetFormat) ?? r.descriptor.extension ?? "xlsx");
|
|
618
|
-
const s = ++this.loadGeneration;
|
|
619
|
-
(d = this.loadController) == null || d.abort(), (u = this.removeAbortListener) == null || u.call(this), this.releaseWorkbook();
|
|
620
|
-
const n = new AbortController();
|
|
621
|
-
this.loadController = n;
|
|
622
|
-
const i = r.signal, o = () => {
|
|
623
|
-
n.abort(), s === this.loadGeneration && (this.releaseWorkbook(), this.state.loading = !1, this.emit("statechange", this.state));
|
|
624
|
-
};
|
|
625
|
-
i == null || i.addEventListener("abort", o, { once: !0 }), this.removeAbortListener = () => i == null ? void 0 : i.removeEventListener("abort", o), this.state = {
|
|
626
|
-
...this.state,
|
|
627
|
-
loading: !0,
|
|
628
|
-
error: null,
|
|
629
|
-
title: r.descriptor.name,
|
|
630
|
-
warnings: []
|
|
631
|
-
}, this.emit("loading", this.state), this.emit("statechange", this.state);
|
|
632
|
-
try {
|
|
633
|
-
i != null && i.aborted && o();
|
|
634
|
-
const f = await fe(e, { ...r, signal: n.signal });
|
|
635
|
-
if (s !== this.loadGeneration) return;
|
|
636
|
-
if (n.signal.aborted) throw new DOMException("Workbook preview aborted.", "AbortError");
|
|
637
|
-
this.workbook = f;
|
|
638
|
-
const m = /* @__PURE__ */ new Set();
|
|
639
|
-
for (const l of f.sheets) for (const g of l.rows) for (const c of g.cells)
|
|
640
|
-
c.font && m.add(c.font);
|
|
641
|
-
this.allFontReferences = (f.fonts ?? []).map((l) => ({ ...l })), this.fontReferences = this.allFontReferences.filter((l, g) => m.has(f.fonts[g]));
|
|
642
|
-
const b = ne(f.fonts ?? [], this.host.ownerDocument, { substitute: !0 }), p = new Map(b.fonts.map((l) => [JSON.stringify([l.fontFamily, l.classification]), l.resolvedFontFamily]));
|
|
643
|
-
for (const l of f.fonts ?? []) {
|
|
644
|
-
const g = p.get(JSON.stringify([l.fontFamily, ie(l.fontFamily ?? "", l.traits)]));
|
|
645
|
-
g && (l.resolvedFontFamily = g);
|
|
646
|
-
}
|
|
647
|
-
this.state = {
|
|
648
|
-
...this.state,
|
|
649
|
-
loading: !1,
|
|
650
|
-
error: null,
|
|
651
|
-
warnings: [.../* @__PURE__ */ new Set([...this.workbook.warnings, ...b.warnings])],
|
|
652
|
-
fonts: b.fonts,
|
|
653
|
-
activeSheetIndex: 0,
|
|
654
|
-
sheets: this.workbook.sheets.map((l, g) => ({
|
|
655
|
-
id: l.id || String(g + 1),
|
|
656
|
-
name: l.name
|
|
657
|
-
}))
|
|
658
|
-
}, this.render(), this.state.warnings.length && this.emit("warnings", this.state.warnings), this.emit("rendered", this.state), this.emit("statechange", this.state);
|
|
659
|
-
} catch (f) {
|
|
660
|
-
if (s !== this.loadGeneration) return;
|
|
661
|
-
if (this.releaseWorkbook(), this.state.loading = !1, n.signal.aborted) throw new DOMException("Workbook preview aborted.", "AbortError");
|
|
662
|
-
const m = f instanceof Error ? f : new Error(String(f));
|
|
663
|
-
throw this.state.error = m.message, this.emit("error", m), this.emit("statechange", this.state), m;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
destroy() {
|
|
667
|
-
var e, r;
|
|
668
|
-
this.fontLoading.destroy(), this.loadGeneration++, (e = this.loadController) == null || e.abort(), (r = this.removeAbortListener) == null || r.call(this), this.releaseWorkbook(), this.state.loading = !1, this.grid.removeEventListener("scroll", this.handleGridScroll), this.root.replaceChildren(), this.root.parentElement === this.host && this.host.replaceChildren();
|
|
669
|
-
for (const s of Object.values(this.listeners)) s.clear();
|
|
670
|
-
}
|
|
671
|
-
getState() {
|
|
672
|
-
var e;
|
|
673
|
-
return {
|
|
674
|
-
...this.state,
|
|
675
|
-
warnings: this.state.warnings.slice(),
|
|
676
|
-
fonts: (e = this.state.fonts) == null ? void 0 : e.map((r) => ({ ...r, classification: r.classification ? { ...r.classification } : void 0 })),
|
|
677
|
-
sheets: this.state.sheets.slice()
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
getFontReferences() {
|
|
681
|
-
return this.fontReferences;
|
|
682
|
-
}
|
|
683
|
-
refreshFonts(e) {
|
|
684
|
-
var s, n;
|
|
685
|
-
if (!this.workbook || (s = this.loadController) != null && s.signal.aborted) return;
|
|
686
|
-
this.fontReferences = e.references, this.allFontReferences = this.allFontReferences.map((i) => e.references.find((o) => {
|
|
687
|
-
var a, d;
|
|
688
|
-
return o.fontFamily === i.fontFamily && ((a = o.traits) == null ? void 0 : a.weight) === ((d = i.traits) == null ? void 0 : d.weight);
|
|
689
|
-
}) ?? i);
|
|
690
|
-
const r = oe({ ...e, references: this.allFontReferences }, this.host.ownerDocument);
|
|
691
|
-
for (const i of this.workbook.fonts ?? []) {
|
|
692
|
-
const o = e.references.find((a) => {
|
|
693
|
-
var d, u;
|
|
694
|
-
return a.fontFamily === i.fontFamily && ((d = a.traits) == null ? void 0 : d.weight) === ((u = i.traits) == null ? void 0 : u.weight);
|
|
695
|
-
});
|
|
696
|
-
o != null && o.resolvedFontFamily && (i.resolvedFontFamily = o.resolvedFontFamily);
|
|
697
|
-
}
|
|
698
|
-
if (this.state.fonts = r.fonts, this.state.warnings = [.../* @__PURE__ */ new Set([...this.workbook.warnings, ...r.warnings])], e.loaded.length || e.relayout) {
|
|
699
|
-
const i = this.workbook.sheets[this.state.activeSheetIndex], o = this.grid.scrollTop, a = this.grid.scrollLeft, d = ((n = this.grid.querySelector("tbody")) == null ? void 0 : n.rows.length) ?? X;
|
|
700
|
-
i && this.grid.replaceChildren(G(i, d)), this.grid.scrollTop = o, this.grid.scrollLeft = a;
|
|
701
|
-
}
|
|
702
|
-
this.emit("warnings", this.state.warnings), this.emit("rendered", this.getState()), this.emit("statechange", this.getState());
|
|
703
|
-
}
|
|
704
|
-
on(e, r) {
|
|
705
|
-
return this.listeners[e].add(r), () => {
|
|
706
|
-
this.listeners[e].delete(r);
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
goToPage(e) {
|
|
710
|
-
this.goToSheet(e);
|
|
711
|
-
}
|
|
712
|
-
next() {
|
|
713
|
-
this.goToSheet(Math.min(this.state.activeSheetIndex + 1, Math.max(this.state.sheets.length - 1, 0)));
|
|
714
|
-
}
|
|
715
|
-
prev() {
|
|
716
|
-
this.goToSheet(Math.max(this.state.activeSheetIndex - 1, 0));
|
|
717
|
-
}
|
|
718
|
-
goToSheet(e) {
|
|
719
|
-
if (!Number.isInteger(e) || !this.workbook) return;
|
|
720
|
-
const r = Math.max(0, Math.min(e, Math.max(this.state.sheets.length - 1, 0)));
|
|
721
|
-
r !== this.state.activeSheetIndex && (this.state.activeSheetIndex = r, this.render(), this.emit("statechange", this.state));
|
|
722
|
-
}
|
|
723
|
-
render() {
|
|
724
|
-
this.renderTabs(), this.renderActiveSheet();
|
|
725
|
-
}
|
|
726
|
-
renderTabs() {
|
|
727
|
-
this.tabs.replaceChildren();
|
|
728
|
-
for (const [e, r] of this.state.sheets.entries()) {
|
|
729
|
-
const s = document.createElement("button");
|
|
730
|
-
s.type = "button", s.className = "xlsxv-sheet-tab", s.classList.toggle("is-active", e === this.state.activeSheetIndex), s.textContent = r.name, s.addEventListener("click", () => this.goToSheet(e)), this.tabs.appendChild(s);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
renderActiveSheet() {
|
|
734
|
-
var r;
|
|
735
|
-
const e = (r = this.workbook) == null ? void 0 : r.sheets[this.state.activeSheetIndex];
|
|
736
|
-
this.grid.replaceChildren(), this.grid.scrollTop = this.grid.scrollLeft = 0, e && this.grid.appendChild(G(e, Math.min(Math.max(e.rowCount, 1), X)));
|
|
737
|
-
}
|
|
738
|
-
releaseWorkbook() {
|
|
739
|
-
this.fontReferences = [], this.allFontReferences = [], this.workbook = null, this.tabs.replaceChildren(), this.grid.replaceChildren(), this.grid.scrollTop = this.grid.scrollLeft = 0, this.state.activeSheetIndex = 0, this.state.sheets = [], this.state.fonts = [];
|
|
740
|
-
}
|
|
741
|
-
emit(e, r) {
|
|
742
|
-
for (const s of this.listeners[e])
|
|
743
|
-
s(r);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
function Xe() {
|
|
747
|
-
return {
|
|
748
|
-
id: "xlsx",
|
|
749
|
-
family: "workbook",
|
|
750
|
-
supports: (t) => ["xlsx", "csv"].includes(Le(t)),
|
|
751
|
-
createSession: (t, e) => new $e(t, e)
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
function Oe(t = re()) {
|
|
755
|
-
return [
|
|
756
|
-
...Me,
|
|
757
|
-
...t.filter((e) => !e.extensions.some((r) => {
|
|
758
|
-
var s;
|
|
759
|
-
return r === "xlsx" || r === "csv" && !((s = e.conversion) != null && s.required);
|
|
760
|
-
}))
|
|
761
|
-
];
|
|
762
|
-
}
|
|
763
|
-
function G(t, e = Math.max(t.rowCount, 1)) {
|
|
764
|
-
const r = document.createElement("table");
|
|
765
|
-
r.className = "xlsxv-table";
|
|
766
|
-
const s = document.createElement("thead"), n = document.createElement("tr"), i = document.createElement("th");
|
|
767
|
-
i.className = "xlsxv-corner", n.appendChild(i);
|
|
768
|
-
for (let a = 1; a <= Math.max(t.columnCount, 1); a += 1) {
|
|
769
|
-
const d = document.createElement("th");
|
|
770
|
-
d.className = "xlsxv-col-header", d.textContent = Re(a), n.appendChild(d);
|
|
771
|
-
}
|
|
772
|
-
s.appendChild(n), r.appendChild(s);
|
|
773
|
-
const o = document.createElement("tbody");
|
|
774
|
-
return H(o, t, 1, e), r.appendChild(o), r;
|
|
775
|
-
}
|
|
776
|
-
function H(t, e, r, s) {
|
|
777
|
-
var a, d;
|
|
778
|
-
if (r > s) return;
|
|
779
|
-
const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
780
|
-
for (const u of e.rows)
|
|
781
|
-
u.index >= r && u.index <= s && i.set(u.index, u);
|
|
782
|
-
const o = document.createDocumentFragment();
|
|
783
|
-
for (let u = r; u <= s; u += 1) {
|
|
784
|
-
const f = i.get(u), m = document.createElement("tr"), b = document.createElement("th");
|
|
785
|
-
b.className = "xlsxv-row-header", b.textContent = String(u), m.appendChild(b);
|
|
786
|
-
const p = new Map((f == null ? void 0 : f.cells.map((l) => [l.column, l])) ?? []);
|
|
787
|
-
for (let l = 1; l <= Math.max(e.columnCount, 1); l += 1) {
|
|
788
|
-
const g = document.createElement("td");
|
|
789
|
-
g.className = "xlsxv-cell";
|
|
790
|
-
const c = p.get(l);
|
|
791
|
-
if (g.textContent = c ? j(e, c) : "", (a = c == null ? void 0 : c.font) != null && a.fontFamily) {
|
|
792
|
-
let w = n.get(c.font);
|
|
793
|
-
w || (w = ae(c.font.fontFamily, c.font.traits, c.font.resolvedFontFamily ? [c.font.resolvedFontFamily] : []), n.set(c.font, w)), g.style.fontFamily = w, (d = c.font.traits) != null && d.weight && (g.style.fontWeight = String(c.font.traits.weight));
|
|
794
|
-
}
|
|
795
|
-
m.appendChild(g);
|
|
796
|
-
}
|
|
797
|
-
o.appendChild(m);
|
|
798
|
-
}
|
|
799
|
-
t.appendChild(o);
|
|
800
|
-
}
|
|
801
|
-
function Le(t) {
|
|
802
|
-
return t.trim().replace(/^\./, "").toLowerCase();
|
|
803
|
-
}
|
|
804
|
-
function Re(t) {
|
|
805
|
-
let e = t, r = "";
|
|
806
|
-
for (; e > 0; ) {
|
|
807
|
-
const s = (e - 1) % 26;
|
|
808
|
-
r = String.fromCharCode(65 + s) + r, e = Math.floor((e - 1) / 26);
|
|
809
|
-
}
|
|
810
|
-
return r || "A";
|
|
811
|
-
}
|
|
812
|
-
export {
|
|
813
|
-
X as R,
|
|
814
|
-
H as a,
|
|
815
|
-
Xe as b,
|
|
816
|
-
G as c,
|
|
817
|
-
Oe as d
|
|
818
|
-
};
|