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.
Files changed (40) hide show
  1. package/README.md +13 -7
  2. package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +870 -0
  3. package/dist/all-in-one/filens.js +5069 -114897
  4. package/dist/index.d.ts +2 -0
  5. package/dist/split/THIRD-PARTY-NOTICES.txt +870 -0
  6. package/dist/split/chunks/archive-haip2eOP.js +1 -0
  7. package/dist/split/chunks/browser-video-session-C_14e_mG.js +1 -0
  8. package/dist/split/chunks/cad-5oTkbaDV.js +7 -0
  9. package/dist/split/chunks/core-EjELrtsP.js +17 -0
  10. package/dist/split/chunks/diagram-BRcdlitF.js +1 -0
  11. package/dist/split/chunks/docx-I39iDYpR.js +1 -0
  12. package/dist/split/chunks/ebook-BRfadCGl.js +5 -0
  13. package/dist/split/chunks/index-C4jdVbDq.js +1 -0
  14. package/dist/split/chunks/index-DkF8PBGR.js +1 -0
  15. package/dist/split/chunks/iwork-DXq9Adf7.js +4 -0
  16. package/dist/split/chunks/media-runtime-B6322raw.js +1 -0
  17. package/dist/split/chunks/mindmap-CyR3TRfx.js +1 -0
  18. package/dist/split/chunks/model3d-BEt6INTt.js +55 -0
  19. package/dist/split/chunks/mp4box.all-Bw_Tlr0T-D0URDfA1.js +1 -0
  20. package/dist/split/chunks/panorama-ChsqnvWC.js +973 -0
  21. package/dist/split/chunks/pdf-Dzzffz3p.js +12 -0
  22. package/dist/split/chunks/vendor-C1aIdQ-w.js +4115 -0
  23. package/dist/split/chunks/xlsx-CITQo0Od.js +3 -0
  24. package/dist/split/converter-image.wasm +0 -0
  25. package/dist/split/filens.js +2 -5012
  26. package/package.json +1 -1
  27. package/dist/split/chunks/archive-B4jVwD9o.js +0 -921
  28. package/dist/split/chunks/cad-DMg-lGJX.js +0 -2405
  29. package/dist/split/chunks/core--zVW212C.js +0 -14627
  30. package/dist/split/chunks/diagram-CDwCA6LZ.js +0 -654
  31. package/dist/split/chunks/docx-CuQfFJqr.js +0 -299
  32. package/dist/split/chunks/ebook-CLlJ8KX3.js +0 -623
  33. package/dist/split/chunks/iwork-dNVC0X8j.js +0 -772
  34. package/dist/split/chunks/media-runtime-gcsBQMuo.js +0 -48
  35. package/dist/split/chunks/mindmap-g0-VoK-K.js +0 -560
  36. package/dist/split/chunks/model3d-1G1CC52V.js +0 -5093
  37. package/dist/split/chunks/panorama-D7GVivtM.js +0 -5972
  38. package/dist/split/chunks/pdf-CecYOWld.js +0 -17898
  39. package/dist/split/chunks/vendor-DPFNKNkh.js +0 -59575
  40. package/dist/split/chunks/xlsx-Co26yo-R.js +0 -818
@@ -1,560 +0,0 @@
1
- var U = Object.defineProperty;
2
- var j = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var d = (e, t, n) => j(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { c as G } from "./core--zVW212C.js";
5
- import { J as O } from "./vendor-DPFNKNkh.js";
6
- const R = [
7
- {
8
- extensions: ["mm", "opml", "xmind", "mmap"],
9
- family: "mindmap",
10
- driverId: "mindmap",
11
- targetFormat: "mindmap",
12
- contentTypes: [
13
- "text/x-opml",
14
- "application/x-freemind",
15
- "application/x-xmind",
16
- "application/vnd.xmind.workbook",
17
- "application/x-mindmanager",
18
- "application/vnd.mindjet.mindmanager"
19
- ]
20
- }
21
- ], D = /* @__PURE__ */ new Set(["mm", "opml", "xmind", "mmap"]), y = "http://www.w3.org/2000/svg", x = 34, _ = 110, I = 260, J = 90, W = 20, E = 36;
22
- class H {
23
- constructor(t, n = {}) {
24
- d(this, "listeners", {
25
- loading: /* @__PURE__ */ new Set(),
26
- rendered: /* @__PURE__ */ new Set(),
27
- error: /* @__PURE__ */ new Set(),
28
- statechange: /* @__PURE__ */ new Set(),
29
- warnings: /* @__PURE__ */ new Set()
30
- });
31
- d(this, "root");
32
- d(this, "scale");
33
- d(this, "fitMode");
34
- d(this, "canvasSize");
35
- d(this, "resizeObserver");
36
- d(this, "document", null);
37
- d(this, "loadGeneration", 0);
38
- d(this, "loadController");
39
- d(this, "removeAbortListener");
40
- d(this, "selectedNodeId");
41
- d(this, "state");
42
- this.host = t, this.scale = n.initialScale ?? 1, this.fitMode = n.fit ?? "contain", this.root = document.createElement("div"), this.root.className = "mindmapv-preview", this.host.replaceChildren(this.root), this.state = {
43
- loading: !1,
44
- error: null,
45
- family: "mindmap",
46
- warnings: [],
47
- capabilities: {
48
- zoom: !0,
49
- fit: !0,
50
- pan: !0,
51
- outline: !0,
52
- search: !0,
53
- fullscreen: !0,
54
- metadata: !0,
55
- download: !0
56
- },
57
- scale: this.scale
58
- }, typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
59
- if (this.fitMode === "none") return;
60
- const r = this.scale;
61
- this.applyScale(), this.scale !== r && this.emit("statechange", this.state);
62
- }));
63
- }
64
- async load(t, n) {
65
- var a, c, f;
66
- const r = ++this.loadGeneration;
67
- (a = this.loadController) == null || a.abort(), (c = this.removeAbortListener) == null || c.call(this), this.releaseDocument();
68
- const i = new AbortController();
69
- this.loadController = i;
70
- const o = n.signal, s = () => {
71
- i.abort(), r === this.loadGeneration && (this.releaseDocument(), this.state.loading = !1, this.emit("statechange", this.state));
72
- };
73
- o == null || o.addEventListener("abort", s, { once: !0 }), this.removeAbortListener = () => o == null ? void 0 : o.removeEventListener("abort", s), this.state = {
74
- ...this.state,
75
- loading: !0,
76
- error: null,
77
- title: n.descriptor.name,
78
- warnings: [],
79
- selectedNodeId: void 0
80
- }, this.emit("loading", this.state), this.emit("statechange", this.state);
81
- try {
82
- o != null && o.aborted && i.abort(), l(i.signal);
83
- const p = $(((f = n.route) == null ? void 0 : f.sourceFormat) ?? n.descriptor.extension);
84
- if (!D.has(p))
85
- throw new Error(
86
- `Mind-map preview currently supports FreeMind MM, OPML, XMind, and MindManager MMAP files, got ${p || "unknown"}.`
87
- );
88
- const w = { ...n, signal: i.signal };
89
- let N;
90
- if (p === "xmind" || p === "mmap") {
91
- const v = await ut(t, w);
92
- l(i.signal), N = await (p === "xmind" ? q(v, w) : Y(v, w));
93
- } else {
94
- const v = await mt(t, w);
95
- l(i.signal), N = V(v, p);
96
- }
97
- if (r !== this.loadGeneration) return;
98
- l(i.signal), this.document = N, this.selectedNodeId = this.document.root.id, this.state = {
99
- ...this.state,
100
- loading: !1,
101
- error: null,
102
- title: this.document.title ?? n.descriptor.name,
103
- selectedNodeId: this.selectedNodeId,
104
- scale: this.scale
105
- }, this.render(), this.emit("rendered", this.state), this.emit("statechange", this.state);
106
- } catch (p) {
107
- if (r !== this.loadGeneration) return;
108
- this.releaseDocument(), this.state.loading = !1, l(i.signal);
109
- const w = p instanceof Error ? p : new Error(String(p));
110
- throw this.state.error = w.message, this.emit("error", w), this.emit("statechange", this.state), w;
111
- }
112
- }
113
- destroy() {
114
- var t, n;
115
- this.loadGeneration++, (t = this.loadController) == null || t.abort(), (n = this.removeAbortListener) == null || n.call(this), this.releaseDocument(), this.state.loading = !1, this.root.parentElement === this.host && this.host.replaceChildren();
116
- for (const r of Object.values(this.listeners)) r.clear();
117
- }
118
- getState() {
119
- return {
120
- ...this.state,
121
- warnings: [...this.state.warnings],
122
- selectedNodeId: this.selectedNodeId
123
- };
124
- }
125
- on(t, n) {
126
- return this.listeners[t].add(n), () => {
127
- this.listeners[t].delete(n);
128
- };
129
- }
130
- setScale(t) {
131
- Number.isFinite(t) && (this.scale = Math.max(0.25, Math.min(t, 3)), this.fitMode = "none", this.state.scale = this.scale, this.applyScale(), this.emit("statechange", this.state));
132
- }
133
- fit(t = "contain") {
134
- this.fitMode = t, t === "none" && (this.scale = 1), this.applyScale(), this.state.scale = this.scale, this.root.scrollLeft = 0, this.root.scrollTop = 0, this.emit("statechange", this.state);
135
- }
136
- pan(t, n) {
137
- this.root.scrollLeft += t, this.root.scrollTop += n;
138
- }
139
- async fullscreen() {
140
- var t, n;
141
- await ((n = (t = this.root).requestFullscreen) == null ? void 0 : n.call(t));
142
- }
143
- render() {
144
- var s, a, c;
145
- if (!this.document) {
146
- this.root.replaceChildren();
147
- return;
148
- }
149
- const t = st(this.document.root), n = at(t);
150
- this.canvasSize = n;
151
- const r = document.createElement("div");
152
- r.className = "mindmapv-canvas-wrap", r.style.width = `${n.width}px`, r.style.height = `${n.height}px`;
153
- const i = document.createElementNS(y, "svg");
154
- i.classList.add("mindmapv-canvas"), i.setAttribute("viewBox", `0 0 ${n.width} ${n.height}`), i.setAttribute("role", "img"), i.setAttribute("aria-label", this.document.title ?? "Mind map preview"), i.appendChild(ct(t)), i.appendChild(lt(t, this.selectedNodeId, (f) => this.selectNode(f))), r.appendChild(i);
155
- const o = document.createElement("div");
156
- o.className = "mindmapv-summary", o.textContent = `${this.document.nodeCount} node${this.document.nodeCount === 1 ? "" : "s"}`, (s = this.resizeObserver) == null || s.disconnect(), this.root.replaceChildren(o, r), this.applyScale(), (a = this.resizeObserver) == null || a.observe(this.root), (c = this.resizeObserver) == null || c.observe(o);
157
- }
158
- selectNode(t) {
159
- if (!t) {
160
- this.selectedNodeId = void 0, this.state.selectedNodeId = void 0, this.root.querySelectorAll(".mindmapv-node").forEach((n) => {
161
- n.classList.remove("is-selected");
162
- }), this.emit("statechange", this.state);
163
- return;
164
- }
165
- this.selectedNodeId = t, this.state.selectedNodeId = t, this.root.querySelectorAll(".mindmapv-node").forEach((n) => {
166
- n.classList.toggle("is-selected", n.getAttribute("data-node-id") === t);
167
- }), this.emit("statechange", this.state);
168
- }
169
- applyScale() {
170
- const t = this.root.querySelector(".mindmapv-canvas-wrap");
171
- if (!(!t || !this.canvasSize)) {
172
- if (this.fitMode !== "none") {
173
- const n = this.root.clientWidth, r = this.root.clientHeight - this.root.firstElementChild.offsetHeight;
174
- if (n > 0 && r > 0) {
175
- const i = n / this.canvasSize.width, o = r / this.canvasSize.height;
176
- this.scale = this.fitMode === "width" ? i : this.fitMode === "height" ? o : Math.min(i, o);
177
- }
178
- }
179
- this.state.scale = this.scale, t.style.width = `${this.canvasSize.width * this.scale}px`, t.style.height = `${this.canvasSize.height * this.scale}px`;
180
- }
181
- }
182
- releaseDocument() {
183
- var t;
184
- (t = this.resizeObserver) == null || t.disconnect(), this.canvasSize = void 0, this.document = null, this.selectedNodeId = void 0, this.state.selectedNodeId = void 0, this.root.replaceChildren();
185
- }
186
- emit(t, n) {
187
- for (const r of this.listeners[t])
188
- r(n);
189
- }
190
- }
191
- function bt() {
192
- return {
193
- id: "mindmap",
194
- family: "mindmap",
195
- supports: (e) => D.has($(e)),
196
- createSession: (e, t) => new H(e, t)
197
- };
198
- }
199
- function At(e = G()) {
200
- return [
201
- ...R,
202
- ...e.filter((t) => !t.extensions.some((n) => D.has(n)))
203
- ];
204
- }
205
- function V(e, t) {
206
- const n = new DOMParser().parseFromString(e, "application/xml");
207
- if (n.getElementsByTagName("parsererror")[0])
208
- throw new Error("Mind-map XML is invalid.");
209
- const i = $(t) === "opml" || m(n.documentElement) === "opml" ? nt(n) : et(n);
210
- return {
211
- title: i.text,
212
- root: i,
213
- nodeCount: b(i)
214
- };
215
- }
216
- async function q(e, t = {}) {
217
- l(t.signal);
218
- const n = await O.loadAsync(e);
219
- l(t.signal);
220
- const r = n.file("content.json");
221
- if (r) {
222
- const o = await r.async("text");
223
- return l(t.signal), it(o);
224
- }
225
- const i = n.file("content.xml");
226
- if (i) {
227
- const o = await i.async("text");
228
- return l(t.signal), ot(o);
229
- }
230
- throw new Error("XMind package is missing content.json or content.xml.");
231
- }
232
- async function Y(e, t = {}) {
233
- l(t.signal);
234
- const n = await O.loadAsync(e);
235
- l(t.signal);
236
- const r = n.file("Document.xml") ?? n.file("document.xml") ?? n.file(/(^|\/)document\.xml$/i)[0];
237
- if (!r)
238
- throw new Error("MindManager package is missing Document.xml.");
239
- const i = await r.async("text");
240
- return l(t.signal), Z(i);
241
- }
242
- function Z(e) {
243
- const t = new DOMParser().parseFromString(e, "application/xml");
244
- if (t.getElementsByTagName("parsererror")[0])
245
- throw new Error("MindManager Document.xml is invalid.");
246
- const n = Array.from(t.getElementsByTagName("*")).filter((o) => m(o) === "topic");
247
- if (!n.length)
248
- throw new Error("MindManager Document.xml does not contain topic nodes.");
249
- const r = n.find((o) => !K(o)) ?? n[0], i = B(r, "mmap-root");
250
- return {
251
- title: i.text,
252
- root: i,
253
- nodeCount: b(i)
254
- };
255
- }
256
- function K(e) {
257
- let t = e.parentElement;
258
- for (; t; ) {
259
- if (m(t) === "topic")
260
- return !0;
261
- t = t.parentElement;
262
- }
263
- return !1;
264
- }
265
- function B(e, t) {
266
- var o;
267
- const n = L(e, "id") || t, r = A(
268
- L(e, "text") || ((o = u(e, "text")[0]) == null ? void 0 : o.textContent) || e.textContent || "Untitled"
269
- ), i = Q(e).map((s, a) => B(s, `${n}-${a + 1}`));
270
- return {
271
- id: n,
272
- text: r,
273
- children: i
274
- };
275
- }
276
- function Q(e) {
277
- const t = [], n = (r) => {
278
- for (const i of Array.from(r.children)) {
279
- if (m(i) === "topic") {
280
- t.push(i);
281
- continue;
282
- }
283
- tt(i) && n(i);
284
- }
285
- };
286
- return n(e), t;
287
- }
288
- function tt(e) {
289
- return Array.from(e.getElementsByTagName("*")).some((t) => m(t) === "topic");
290
- }
291
- function L(e, t) {
292
- const n = t.toLowerCase();
293
- for (const r of Array.from(e.attributes))
294
- if (r.name.toLowerCase() === n)
295
- return r.value;
296
- }
297
- function et(e) {
298
- const t = Array.from(e.getElementsByTagName("*")).find((n) => m(n) === "node");
299
- if (!t)
300
- throw new Error("FreeMind MM file does not contain a root node.");
301
- return z(t, "mm", t.parentElement ? ht(t) : "");
302
- }
303
- function z(e, t, n) {
304
- const r = e.getAttribute("ID") || `${t}-${n || "1"}`, i = A(e.getAttribute("TEXT") || e.getAttribute("text") || "Untitled"), o = u(e, "node").map((s, a) => z(s, `${r}-${a + 1}`, n ? `${n}-${a + 1}` : String(a + 1)));
305
- return {
306
- id: r,
307
- text: i,
308
- children: o
309
- };
310
- }
311
- function nt(e) {
312
- var i, o;
313
- const t = Array.from(e.getElementsByTagName("*")).find((s) => m(s) === "body"), n = (o = (i = Array.from(e.getElementsByTagName("*")).find((s) => m(s) === "title")) == null ? void 0 : i.textContent) == null ? void 0 : o.trim(), r = t ? u(t, "outline") : [];
314
- if (!r.length)
315
- throw new Error("OPML file does not contain outline nodes.");
316
- if (r.length === 1) {
317
- const s = C(r[0], "opml-1");
318
- return n && s.text === "Untitled" ? { ...s, text: n } : s;
319
- }
320
- return {
321
- id: "opml-root",
322
- text: n || "OPML",
323
- children: r.map((s, a) => C(s, `opml-${a + 1}`))
324
- };
325
- }
326
- function C(e, t) {
327
- const n = A(e.getAttribute("text") || e.getAttribute("title") || "Untitled");
328
- return {
329
- id: t,
330
- text: n,
331
- children: u(e, "outline").map((r, i) => C(r, `${t}-${i + 1}`))
332
- };
333
- }
334
- function it(e) {
335
- let t;
336
- try {
337
- t = JSON.parse(e);
338
- } catch {
339
- throw new Error("XMind content.json is invalid.");
340
- }
341
- const r = (Array.isArray(t) ? t : [t]).find((s) => s && typeof s == "object");
342
- if (!r)
343
- throw new Error("XMind content.json does not contain a sheet.");
344
- const i = h(r.rootTopic) ?? h(r.centralTopic) ?? h(r.topic);
345
- if (!i)
346
- throw new Error("XMind content.json does not contain a root topic.");
347
- const o = F(i, "xmind-json-1");
348
- return {
349
- title: g(r.title) || o.text,
350
- root: o,
351
- nodeCount: b(o)
352
- };
353
- }
354
- function F(e, t) {
355
- const n = g(e.id) || g(e.uuid) || t, r = A(g(e.title) || g(e.text) || gt(e) || "Untitled"), i = rt(e).map((o, s) => F(o, `${n}-${s + 1}`));
356
- return {
357
- id: n,
358
- text: r,
359
- children: i
360
- };
361
- }
362
- function rt(e) {
363
- var s;
364
- const t = [], n = e.children;
365
- Array.isArray(n) && t.push(...n.map(h).filter(M));
366
- const r = h(n);
367
- if (r)
368
- for (const a of ["attached", "detached", "floating", "summary"]) {
369
- const c = r[a], f = Array.isArray(c) ? c : (s = h(c)) == null ? void 0 : s.topics;
370
- Array.isArray(f) && t.push(...f.map(h).filter(M));
371
- }
372
- const i = e.subTopics ?? e.subtopics;
373
- Array.isArray(i) && t.push(...i.map(h).filter(M));
374
- const o = h(i);
375
- if (o)
376
- for (const a of Object.values(o))
377
- Array.isArray(a) && t.push(...a.map(h).filter(M));
378
- return t;
379
- }
380
- function ot(e) {
381
- var s, a;
382
- const t = new DOMParser().parseFromString(e, "application/xml");
383
- if (t.getElementsByTagName("parsererror")[0])
384
- throw new Error("XMind content.xml is invalid.");
385
- const n = Array.from(t.getElementsByTagName("*")).find((c) => m(c) === "sheet") ?? t.documentElement, r = u(n, "topic")[0] ?? Array.from(t.getElementsByTagName("*")).find((c) => m(c) === "topic");
386
- if (!r)
387
- throw new Error("XMind content.xml does not contain a root topic.");
388
- const i = X(r, "xmind-xml-1");
389
- return {
390
- title: ((a = (s = u(n, "title")[0]) == null ? void 0 : s.textContent) == null ? void 0 : a.trim()) || i.text,
391
- root: i,
392
- nodeCount: b(i)
393
- };
394
- }
395
- function X(e, t) {
396
- var o;
397
- const n = e.getAttribute("id") || t, r = ((o = u(e, "title")[0]) == null ? void 0 : o.textContent) ?? e.getAttribute("title") ?? e.getAttribute("text") ?? "Untitled", i = u(e, "children").flatMap((s) => u(s, "topics")).flatMap((s) => u(s, "topic")).map((s, a) => X(s, `${n}-${a + 1}`));
398
- return {
399
- id: n,
400
- text: A(r),
401
- children: i
402
- };
403
- }
404
- function st(e) {
405
- const t = k(e, 0);
406
- let n = E;
407
- const r = (i) => {
408
- if (i.x = E + i.depth * (I + J), i.width = P(i.text), i.height = x, !i.children.length) {
409
- i.y = n, n += x + W;
410
- return;
411
- }
412
- for (const o of i.children)
413
- r(o);
414
- i.y = (i.children[0].y + i.children[i.children.length - 1].y) / 2;
415
- };
416
- return r(t), t;
417
- }
418
- function k(e, t) {
419
- return {
420
- ...e,
421
- x: 0,
422
- y: 0,
423
- width: P(e.text),
424
- height: x,
425
- depth: t,
426
- children: e.children.map((n) => k(n, t + 1))
427
- };
428
- }
429
- function at(e) {
430
- let t = 0, n = 0;
431
- return S(e, (r) => {
432
- t = Math.max(t, r.x + r.width + E), n = Math.max(n, r.y + r.height + E);
433
- }), {
434
- width: Math.max(360, t),
435
- height: Math.max(260, n)
436
- };
437
- }
438
- function ct(e) {
439
- const t = document.createElementNS(y, "g");
440
- return t.classList.add("mindmapv-links"), S(e, (n) => {
441
- for (const r of n.children) {
442
- const i = document.createElementNS(y, "path"), o = n.x + n.width, s = n.y + x / 2, a = r.x, c = r.y + x / 2, f = o + (a - o) * 0.5;
443
- i.setAttribute("d", `M ${o} ${s} C ${f} ${s}, ${f} ${c}, ${a} ${c}`), t.appendChild(i);
444
- }
445
- }), t;
446
- }
447
- function lt(e, t, n) {
448
- const r = document.createElementNS(y, "g");
449
- return r.classList.add("mindmapv-nodes"), S(e, (i) => {
450
- const o = document.createElementNS(y, "g");
451
- o.classList.add("mindmapv-node"), i.id === t && o.classList.add("is-selected"), o.setAttribute("data-node-id", i.id), o.setAttribute("tabindex", "0"), o.setAttribute("role", "button"), o.setAttribute("aria-label", i.text), o.addEventListener("click", () => n(i.id)), o.addEventListener("keydown", (c) => {
452
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), n(i.id));
453
- });
454
- const s = document.createElementNS(y, "rect");
455
- s.setAttribute("x", String(i.x)), s.setAttribute("y", String(i.y)), s.setAttribute("width", String(i.width)), s.setAttribute("height", String(x)), s.setAttribute("rx", "6");
456
- const a = document.createElementNS(y, "text");
457
- a.setAttribute("x", String(i.x + 14)), a.setAttribute("y", String(i.y + 22)), a.textContent = dt(i.text), o.append(s, a), r.appendChild(o);
458
- }), r;
459
- }
460
- function S(e, t) {
461
- t(e);
462
- for (const n of e.children)
463
- S(n, t);
464
- }
465
- function P(e) {
466
- return Math.max(_, Math.min(I, e.length * 8 + 34));
467
- }
468
- function dt(e) {
469
- return e.length > 34 ? `${e.slice(0, 31)}...` : e;
470
- }
471
- function b(e) {
472
- return 1 + e.children.reduce((t, n) => t + b(n), 0);
473
- }
474
- function u(e, t) {
475
- return Array.from(e.children).filter((n) => m(n) === t);
476
- }
477
- function m(e) {
478
- return e.localName.toLowerCase();
479
- }
480
- function A(e) {
481
- return e.replace(/\s+/g, " ").trim() || "Untitled";
482
- }
483
- function ht(e) {
484
- const t = [];
485
- let n = e;
486
- for (; n != null && n.parentElement; ) {
487
- const r = u(n.parentElement, m(n));
488
- t.unshift(r.indexOf(n) + 1), n = n.parentElement;
489
- }
490
- return t.join("-") || "1";
491
- }
492
- async function mt(e, t) {
493
- if (l(t.signal), typeof e == "string") {
494
- if (e.trimStart().toLowerCase().startsWith("data:"))
495
- return ft(e);
496
- const n = await fetch(e, { signal: t.signal });
497
- if (l(t.signal), !n.ok)
498
- throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());
499
- return n.text();
500
- }
501
- return e instanceof Blob ? e.text() : ArrayBuffer.isView(e) ? new TextDecoder().decode(e) : e instanceof ArrayBuffer ? new TextDecoder().decode(e) : String(e);
502
- }
503
- async function ut(e, t) {
504
- if (l(t.signal), typeof e == "string") {
505
- if (e.trimStart().toLowerCase().startsWith("data:"))
506
- return T(pt(e));
507
- const n = await fetch(e, { signal: t.signal });
508
- if (l(t.signal), !n.ok)
509
- throw new Error(`Failed to load mind-map source: ${n.status} ${n.statusText}`.trim());
510
- return n.arrayBuffer();
511
- }
512
- if (e instanceof Blob)
513
- return e.arrayBuffer();
514
- if (ArrayBuffer.isView(e)) {
515
- const n = new Uint8Array(e.byteLength);
516
- return n.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)), T(n);
517
- }
518
- return e instanceof ArrayBuffer ? e : T(new TextEncoder().encode(String(e)));
519
- }
520
- function l(e) {
521
- if (e != null && e.aborted) throw new DOMException("Mind-map preview aborted.", "AbortError");
522
- }
523
- function ft(e) {
524
- const t = e.indexOf(",");
525
- if (t < 0)
526
- return e;
527
- const n = e.slice(0, t).toLowerCase(), r = e.slice(t + 1);
528
- return n.endsWith(";base64") ? new TextDecoder().decode(Uint8Array.from(atob(r), (i) => i.charCodeAt(0))) : decodeURIComponent(r);
529
- }
530
- function pt(e) {
531
- const t = e.indexOf(",");
532
- if (t < 0)
533
- return new TextEncoder().encode(e);
534
- const n = e.slice(0, t).toLowerCase(), r = e.slice(t + 1);
535
- return n.endsWith(";base64") ? Uint8Array.from(atob(r), (i) => i.charCodeAt(0)) : new TextEncoder().encode(decodeURIComponent(r));
536
- }
537
- function T(e) {
538
- const t = new Uint8Array(e.byteLength);
539
- return t.set(e), t.buffer;
540
- }
541
- function $(e) {
542
- return String(e ?? "").trim().replace(/^\./, "").toLowerCase();
543
- }
544
- function h(e) {
545
- return e && typeof e == "object" && !Array.isArray(e) ? e : void 0;
546
- }
547
- function M(e) {
548
- return e !== void 0;
549
- }
550
- function g(e) {
551
- return typeof e == "string" ? e.trim() : "";
552
- }
553
- function gt(e) {
554
- const t = h(e.title), n = h(e.text);
555
- return g(t == null ? void 0 : t.plain) || g(t == null ? void 0 : t.content) || g(n == null ? void 0 : n.plain) || g(n == null ? void 0 : n.content);
556
- }
557
- export {
558
- At as a,
559
- bt as c
560
- };