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,654 +0,0 @@
|
|
|
1
|
-
var _ = Object.defineProperty;
|
|
2
|
-
var R = (e, t, r) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var f = (e, t, r) => R(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { c as G } from "./core--zVW212C.js";
|
|
5
|
-
import { J as Y, i as W, a as H, s as j } from "./vendor-DPFNKNkh.js";
|
|
6
|
-
const q = [
|
|
7
|
-
{
|
|
8
|
-
extensions: ["drawio", "dio", "vdx", "vsdx"],
|
|
9
|
-
family: "diagram",
|
|
10
|
-
driverId: "diagram",
|
|
11
|
-
targetFormat: "diagram",
|
|
12
|
-
contentTypes: ["application/vnd.jgraph.mxfile", "application/vnd.visio"]
|
|
13
|
-
}
|
|
14
|
-
], F = /* @__PURE__ */ new Set(["drawio", "dio", "vdx", "vsdx"]), w = 96, p = "http://www.w3.org/2000/svg", S = 36, J = 120, Z = 60, K = "#ffffff", Q = "#9db3d1", V = "#1f2937", tt = "#6b7f99", et = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
15
|
-
class rt {
|
|
16
|
-
constructor(t, r = {}) {
|
|
17
|
-
f(this, "listeners", {
|
|
18
|
-
loading: /* @__PURE__ */ new Set(),
|
|
19
|
-
rendered: /* @__PURE__ */ new Set(),
|
|
20
|
-
error: /* @__PURE__ */ new Set(),
|
|
21
|
-
statechange: /* @__PURE__ */ new Set(),
|
|
22
|
-
warnings: /* @__PURE__ */ new Set()
|
|
23
|
-
});
|
|
24
|
-
f(this, "root");
|
|
25
|
-
f(this, "scale");
|
|
26
|
-
f(this, "fitMode");
|
|
27
|
-
f(this, "canvasSize");
|
|
28
|
-
f(this, "resizeObserver");
|
|
29
|
-
f(this, "document", null);
|
|
30
|
-
f(this, "loadGeneration", 0);
|
|
31
|
-
f(this, "loadController");
|
|
32
|
-
f(this, "removeAbortListener");
|
|
33
|
-
f(this, "pageIndex", 0);
|
|
34
|
-
f(this, "selectedElementId");
|
|
35
|
-
f(this, "state");
|
|
36
|
-
this.host = t, this.scale = r.initialScale ?? 1, this.fitMode = r.fit ?? "contain", this.root = document.createElement("div"), this.root.className = "diagramv-preview", this.host.replaceChildren(this.root), this.state = {
|
|
37
|
-
loading: !1,
|
|
38
|
-
error: null,
|
|
39
|
-
family: "diagram",
|
|
40
|
-
warnings: [],
|
|
41
|
-
capabilities: {
|
|
42
|
-
zoom: !0,
|
|
43
|
-
fit: !0,
|
|
44
|
-
pan: !0,
|
|
45
|
-
paged: !0,
|
|
46
|
-
search: !0,
|
|
47
|
-
fullscreen: !0,
|
|
48
|
-
metadata: !0,
|
|
49
|
-
download: !0
|
|
50
|
-
},
|
|
51
|
-
scale: this.scale,
|
|
52
|
-
pageIndex: 0,
|
|
53
|
-
pageCount: 0
|
|
54
|
-
}, typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
|
|
55
|
-
if (this.fitMode === "none") return;
|
|
56
|
-
const i = this.scale;
|
|
57
|
-
this.applyScale(), this.scale !== i && this.emit("statechange", this.state);
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
async load(t, r) {
|
|
61
|
-
var a, c, d;
|
|
62
|
-
const i = ++this.loadGeneration;
|
|
63
|
-
(a = this.loadController) == null || a.abort(), (c = this.removeAbortListener) == null || c.call(this), this.releaseDocument();
|
|
64
|
-
const n = new AbortController();
|
|
65
|
-
this.loadController = n;
|
|
66
|
-
const s = r.signal, o = () => {
|
|
67
|
-
n.abort(), i === this.loadGeneration && (this.releaseDocument(), this.state.loading = !1, this.emit("statechange", this.state));
|
|
68
|
-
};
|
|
69
|
-
s == null || s.addEventListener("abort", o, { once: !0 }), this.removeAbortListener = () => s == null ? void 0 : s.removeEventListener("abort", o), this.state = {
|
|
70
|
-
...this.state,
|
|
71
|
-
loading: !0,
|
|
72
|
-
error: null,
|
|
73
|
-
title: r.descriptor.name,
|
|
74
|
-
warnings: [],
|
|
75
|
-
selectedElementId: void 0
|
|
76
|
-
}, this.emit("loading", this.state), this.emit("statechange", this.state);
|
|
77
|
-
try {
|
|
78
|
-
s != null && s.aborted && n.abort(), m(n.signal);
|
|
79
|
-
const l = O(((d = r.route) == null ? void 0 : d.sourceFormat) ?? r.descriptor.extension);
|
|
80
|
-
if (!F.has(l))
|
|
81
|
-
throw new Error(`Diagram preview currently supports diagrams.net drawio/dio and Visio VDX/VSDX files, got ${l || "unknown"}.`);
|
|
82
|
-
const h = { ...r, signal: n.signal };
|
|
83
|
-
let u;
|
|
84
|
-
if (l === "vsdx") {
|
|
85
|
-
const y = await It(t, h);
|
|
86
|
-
m(n.signal), u = await nt(y, h);
|
|
87
|
-
} else {
|
|
88
|
-
const y = await Nt(t, h);
|
|
89
|
-
m(n.signal), u = l === "vdx" ? lt(y) : it(y);
|
|
90
|
-
}
|
|
91
|
-
if (i !== this.loadGeneration) return;
|
|
92
|
-
m(n.signal), this.document = u, this.pageIndex = 0, this.selectedElementId = void 0, this.state = {
|
|
93
|
-
...this.state,
|
|
94
|
-
loading: !1,
|
|
95
|
-
error: null,
|
|
96
|
-
title: this.document.title ?? r.descriptor.name,
|
|
97
|
-
pageIndex: 0,
|
|
98
|
-
pageCount: this.document.pages.length,
|
|
99
|
-
selectedElementId: void 0,
|
|
100
|
-
scale: this.scale
|
|
101
|
-
}, this.render(), this.emit("rendered", this.state), this.emit("statechange", this.state);
|
|
102
|
-
} catch (l) {
|
|
103
|
-
if (i !== this.loadGeneration) return;
|
|
104
|
-
this.releaseDocument(), this.state.loading = !1, m(n.signal);
|
|
105
|
-
const h = l instanceof Error ? l : new Error(String(l));
|
|
106
|
-
throw this.state.error = h.message, this.emit("error", h), this.emit("statechange", this.state), h;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
destroy() {
|
|
110
|
-
var t, r;
|
|
111
|
-
this.loadGeneration++, (t = this.loadController) == null || t.abort(), (r = this.removeAbortListener) == null || r.call(this), this.releaseDocument(), this.state.loading = !1, this.root.parentElement === this.host && this.host.replaceChildren();
|
|
112
|
-
for (const i of Object.values(this.listeners)) i.clear();
|
|
113
|
-
}
|
|
114
|
-
getState() {
|
|
115
|
-
var t;
|
|
116
|
-
return {
|
|
117
|
-
...this.state,
|
|
118
|
-
warnings: [...this.state.warnings],
|
|
119
|
-
pageIndex: this.pageIndex,
|
|
120
|
-
pageCount: ((t = this.document) == null ? void 0 : t.pages.length) ?? 0,
|
|
121
|
-
selectedElementId: this.selectedElementId
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
on(t, r) {
|
|
125
|
-
return this.listeners[t].add(r), () => {
|
|
126
|
-
this.listeners[t].delete(r);
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
setScale(t) {
|
|
130
|
-
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));
|
|
131
|
-
}
|
|
132
|
-
fit(t = "contain") {
|
|
133
|
-
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);
|
|
134
|
-
}
|
|
135
|
-
pan(t, r) {
|
|
136
|
-
this.root.scrollLeft += t, this.root.scrollTop += r;
|
|
137
|
-
}
|
|
138
|
-
async fullscreen() {
|
|
139
|
-
var t, r;
|
|
140
|
-
await ((r = (t = this.root).requestFullscreen) == null ? void 0 : r.call(t));
|
|
141
|
-
}
|
|
142
|
-
goToPage(t) {
|
|
143
|
-
if (!this.document || !Number.isInteger(t))
|
|
144
|
-
return;
|
|
145
|
-
const r = Math.max(0, Math.min(t, this.document.pages.length - 1));
|
|
146
|
-
r !== this.pageIndex && (this.pageIndex = r, this.selectedElementId = void 0, this.state.pageIndex = this.pageIndex, this.state.selectedElementId = void 0, this.root.scrollTop = 0, this.root.scrollLeft = 0, this.render(), this.emit("statechange", this.state));
|
|
147
|
-
}
|
|
148
|
-
next() {
|
|
149
|
-
this.goToPage(this.pageIndex + 1);
|
|
150
|
-
}
|
|
151
|
-
prev() {
|
|
152
|
-
this.goToPage(this.pageIndex - 1);
|
|
153
|
-
}
|
|
154
|
-
render() {
|
|
155
|
-
var o, a, c, d;
|
|
156
|
-
const t = (o = this.document) == null ? void 0 : o.pages[this.pageIndex];
|
|
157
|
-
if (!t) {
|
|
158
|
-
this.root.replaceChildren();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const r = vt(t);
|
|
162
|
-
this.canvasSize = r;
|
|
163
|
-
const i = document.createElement("div");
|
|
164
|
-
i.className = "diagramv-summary", i.textContent = `${t.name} - ${t.nodes.length} node${t.nodes.length === 1 ? "" : "s"} - ${t.edges.length} edge${t.edges.length === 1 ? "" : "s"}`;
|
|
165
|
-
const n = document.createElement("div");
|
|
166
|
-
n.className = "diagramv-canvas-wrap", n.style.width = `${r.width}px`, n.style.height = `${r.height}px`;
|
|
167
|
-
const s = document.createElementNS(p, "svg");
|
|
168
|
-
s.classList.add("diagramv-canvas"), s.setAttribute("viewBox", `${r.minX} ${r.minY} ${r.width} ${r.height}`), s.setAttribute("role", "img"), s.setAttribute("aria-label", t.name), s.appendChild(yt()), s.append(wt(t, (l) => this.selectElement(l)), bt(t, (l) => this.selectElement(l))), n.appendChild(s), (a = this.resizeObserver) == null || a.disconnect(), this.root.replaceChildren(i, n), this.applyScale(), (c = this.resizeObserver) == null || c.observe(this.root), (d = this.resizeObserver) == null || d.observe(i), this.selectedElementId && this.selectElement(this.selectedElementId, !1);
|
|
169
|
-
}
|
|
170
|
-
selectElement(t, r = !0) {
|
|
171
|
-
this.selectedElementId = t, this.state.selectedElementId = t, this.root.querySelectorAll(".diagramv-node, .diagramv-edge").forEach((i) => {
|
|
172
|
-
i.classList.toggle("is-selected", i.getAttribute("data-element-id") === t);
|
|
173
|
-
}), r && this.emit("statechange", this.state);
|
|
174
|
-
}
|
|
175
|
-
applyScale() {
|
|
176
|
-
const t = this.root.querySelector(".diagramv-canvas-wrap");
|
|
177
|
-
if (!(!t || !this.canvasSize)) {
|
|
178
|
-
if (this.fitMode !== "none") {
|
|
179
|
-
const r = this.root.clientWidth, i = this.root.clientHeight - this.root.firstElementChild.offsetHeight;
|
|
180
|
-
if (r > 0 && i > 0) {
|
|
181
|
-
const n = r / this.canvasSize.width, s = i / this.canvasSize.height;
|
|
182
|
-
this.scale = this.fitMode === "width" ? n : this.fitMode === "height" ? s : Math.min(n, s);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
this.state.scale = this.scale, t.style.width = `${this.canvasSize.width * this.scale}px`, t.style.height = `${this.canvasSize.height * this.scale}px`;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
releaseDocument() {
|
|
189
|
-
var t;
|
|
190
|
-
(t = this.resizeObserver) == null || t.disconnect(), this.canvasSize = void 0, this.document = null, this.pageIndex = 0, this.selectedElementId = void 0, this.state.pageIndex = 0, this.state.pageCount = 0, this.state.selectedElementId = void 0, this.root.replaceChildren();
|
|
191
|
-
}
|
|
192
|
-
emit(t, r) {
|
|
193
|
-
for (const i of this.listeners[t])
|
|
194
|
-
i(r);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function kt() {
|
|
198
|
-
return {
|
|
199
|
-
id: "diagram",
|
|
200
|
-
family: "diagram",
|
|
201
|
-
supports: (e) => F.has(O(e)),
|
|
202
|
-
createSession: (e, t) => new rt(e, t)
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function Bt(e = G()) {
|
|
206
|
-
return [
|
|
207
|
-
...q,
|
|
208
|
-
...e.filter((t) => !t.extensions.some((r) => F.has(r)))
|
|
209
|
-
];
|
|
210
|
-
}
|
|
211
|
-
function it(e) {
|
|
212
|
-
var s;
|
|
213
|
-
const t = new DOMParser().parseFromString(e, "application/xml");
|
|
214
|
-
if (t.getElementsByTagName("parsererror")[0])
|
|
215
|
-
throw new Error("draw.io XML is invalid.");
|
|
216
|
-
const r = {}, i = Array.from(t.getElementsByTagName("*")).filter((o) => g(o) === "diagram"), n = i.length ? i.map((o, a) => P(o, a, r)) : [P(t.documentElement, 0, r)];
|
|
217
|
-
if (!n.some((o) => o.nodes.length || o.edges.length))
|
|
218
|
-
throw new Error("draw.io file does not contain supported mxCell geometry.");
|
|
219
|
-
return {
|
|
220
|
-
title: t.documentElement.getAttribute("name") ?? ((s = n[0]) == null ? void 0 : s.name),
|
|
221
|
-
pages: n
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
async function nt(e, t = {}) {
|
|
225
|
-
var o;
|
|
226
|
-
m(t.signal);
|
|
227
|
-
const r = await Y.loadAsync(e);
|
|
228
|
-
m(t.signal);
|
|
229
|
-
const i = await st(r, t.signal);
|
|
230
|
-
if (m(t.signal), !i.length)
|
|
231
|
-
throw new Error("VSDX package is missing visio/pages/page*.xml files.");
|
|
232
|
-
const n = [], s = {};
|
|
233
|
-
for (let a = 0; a < i.length; a += 1) {
|
|
234
|
-
const c = i[a], d = await c.file.async("text");
|
|
235
|
-
m(t.signal);
|
|
236
|
-
const l = ct(d, a, s, c.metadata);
|
|
237
|
-
(l.nodes.length || l.edges.length) && n.push(l);
|
|
238
|
-
}
|
|
239
|
-
if (!n.length)
|
|
240
|
-
throw new Error("VSDX file does not contain supported shape geometry.");
|
|
241
|
-
return {
|
|
242
|
-
title: (o = n[0]) == null ? void 0 : o.name,
|
|
243
|
-
pages: n
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
async function st(e, t) {
|
|
247
|
-
const r = e.file(/^visio\/pages\/page\d+\.xml$/i).sort((d, l) => d.name.localeCompare(l.name, void 0, { numeric: !0 })), i = e.file("visio/pages/pages.xml");
|
|
248
|
-
if (!i)
|
|
249
|
-
return r.map((d) => ({ file: d }));
|
|
250
|
-
const n = await i.async("text");
|
|
251
|
-
m(t);
|
|
252
|
-
const s = new DOMParser().parseFromString(n, "application/xml");
|
|
253
|
-
if (s.getElementsByTagName("parsererror")[0])
|
|
254
|
-
return r.map((d) => ({ file: d }));
|
|
255
|
-
const o = await ot(e, t);
|
|
256
|
-
m(t);
|
|
257
|
-
const c = Array.from(s.getElementsByTagName("*")).filter((d) => g(d) === "page").map((d, l) => {
|
|
258
|
-
var E;
|
|
259
|
-
const h = (E = Array.from(d.children).find((I) => g(I) === "rel")) == null ? void 0 : E.getAttribute("r:id"), u = h ? o.get(h) : void 0, y = u ? e.file(at(u)) : r[l];
|
|
260
|
-
if (y)
|
|
261
|
-
return {
|
|
262
|
-
file: y,
|
|
263
|
-
metadata: {
|
|
264
|
-
id: d.getAttribute("ID") ?? void 0,
|
|
265
|
-
name: d.getAttribute("NameU") || d.getAttribute("Name") || void 0
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
}).filter(Dt);
|
|
269
|
-
return c.length ? c : r.map((d) => ({ file: d }));
|
|
270
|
-
}
|
|
271
|
-
async function ot(e, t) {
|
|
272
|
-
const r = /* @__PURE__ */ new Map(), i = e.file("visio/pages/_rels/pages.xml.rels");
|
|
273
|
-
if (!i)
|
|
274
|
-
return r;
|
|
275
|
-
const n = await i.async("text");
|
|
276
|
-
m(t);
|
|
277
|
-
const s = new DOMParser().parseFromString(n, "application/xml");
|
|
278
|
-
if (s.getElementsByTagName("parsererror")[0])
|
|
279
|
-
return r;
|
|
280
|
-
for (const o of Array.from(s.getElementsByTagName("*")).filter((a) => g(a) === "relationship")) {
|
|
281
|
-
const a = o.getAttribute("Id"), c = o.getAttribute("Target");
|
|
282
|
-
a && c && r.set(a, c);
|
|
283
|
-
}
|
|
284
|
-
return r;
|
|
285
|
-
}
|
|
286
|
-
function at(e) {
|
|
287
|
-
const t = e.replace(/\\/g, "/").replace(/^\//, "");
|
|
288
|
-
return t.toLowerCase().startsWith("visio/pages/") ? t : `visio/pages/${t.replace(/^pages\//i, "")}`;
|
|
289
|
-
}
|
|
290
|
-
function lt(e) {
|
|
291
|
-
var s;
|
|
292
|
-
const t = new DOMParser().parseFromString(e, "application/xml");
|
|
293
|
-
if (t.getElementsByTagName("parsererror")[0])
|
|
294
|
-
throw new Error("VDX XML is invalid.");
|
|
295
|
-
const r = { legacy: !0 }, i = Array.from(t.getElementsByTagName("*")).filter((o) => g(o) === "page"), n = i.length ? i.map((o, a) => M(o, a, r)) : [M(t.documentElement, 0, r)];
|
|
296
|
-
if (!n.some((o) => o.nodes.length || o.edges.length))
|
|
297
|
-
throw new Error("VDX file does not contain supported shape geometry.");
|
|
298
|
-
return {
|
|
299
|
-
title: t.documentElement.getAttribute("Name") ?? ((s = n[0]) == null ? void 0 : s.name),
|
|
300
|
-
pages: n
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
function ct(e, t, r, i) {
|
|
304
|
-
const n = new DOMParser().parseFromString(e, "application/xml");
|
|
305
|
-
if (n.getElementsByTagName("parsererror")[0])
|
|
306
|
-
throw new Error("Visio page XML is invalid.");
|
|
307
|
-
return M(n.documentElement, t, r, i);
|
|
308
|
-
}
|
|
309
|
-
function M(e, t, r, i) {
|
|
310
|
-
let n;
|
|
311
|
-
const s = [], o = [];
|
|
312
|
-
for (const h of Array.from(e.getElementsByTagName("*"))) {
|
|
313
|
-
const u = g(h);
|
|
314
|
-
u === "pagesheet" && !n ? n = h : u === "shape" ? s.push(h) : u === "connect" && o.push(h);
|
|
315
|
-
}
|
|
316
|
-
const a = (b(B(n, !!r.legacy), "PageHeight") ?? 8.5) * w, c = mt(o), d = [], l = [];
|
|
317
|
-
for (const h of s) {
|
|
318
|
-
const u = h.getAttribute("ID") ?? `shape-${d.length + l.length + 1}`, y = h.getAttribute("Type") ?? "", E = B(h, !!r.legacy), I = b(E, "BeginX"), U = b(E, "EndX"), x = c.get(u), k = L(gt(h), r);
|
|
319
|
-
if (y === "Shape" && I == null && U == null && !(x != null && x.source) && !(x != null && x.target)) {
|
|
320
|
-
const T = dt(E, u, k, a);
|
|
321
|
-
T.width > 0 && T.height > 0 && d.push(T);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
if (y === "Foreign" || y === "Group")
|
|
325
|
-
continue;
|
|
326
|
-
const v = ht(E, u, k, a, x);
|
|
327
|
-
(v.points.length || v.source || v.target) && l.push(v);
|
|
328
|
-
}
|
|
329
|
-
return {
|
|
330
|
-
id: (i == null ? void 0 : i.id) ?? `visio-page-${t + 1}`,
|
|
331
|
-
name: (i == null ? void 0 : i.name) || e.getAttribute("NameU") || e.getAttribute("Name") || `Page ${t + 1}`,
|
|
332
|
-
nodes: d,
|
|
333
|
-
edges: l
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function dt(e, t, r, i) {
|
|
337
|
-
const n = (b(e, "PinX") ?? 0) * w, s = (b(e, "PinY") ?? 0) * w, o = Math.max(1, (b(e, "Width") ?? 1) * w), a = Math.max(1, (b(e, "Height") ?? 0.5) * w);
|
|
338
|
-
return {
|
|
339
|
-
id: t,
|
|
340
|
-
label: r,
|
|
341
|
-
x: n - o / 2,
|
|
342
|
-
y: i - s - a / 2,
|
|
343
|
-
width: o,
|
|
344
|
-
height: a,
|
|
345
|
-
style: ut(e)
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
function ht(e, t, r, i, n = {}) {
|
|
349
|
-
const s = b(e, "PinX") ?? 0, o = b(e, "PinY") ?? 0, a = (b(e, "BeginX") ?? s) * w, c = i - (b(e, "BeginY") ?? o) * w, d = (b(e, "EndX") ?? s) * w, l = i - (b(e, "EndY") ?? o) * w;
|
|
350
|
-
return {
|
|
351
|
-
id: t,
|
|
352
|
-
label: r,
|
|
353
|
-
source: n.source,
|
|
354
|
-
target: n.target,
|
|
355
|
-
points: n.source || n.target ? [] : [[a, c], [d, l]],
|
|
356
|
-
style: "endArrow=block;strokeColor=#6b7f99"
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
function mt(e) {
|
|
360
|
-
const t = /* @__PURE__ */ new Map();
|
|
361
|
-
for (const r of e) {
|
|
362
|
-
const i = r.getAttribute("FromSheet"), n = r.getAttribute("ToSheet");
|
|
363
|
-
if (!i || !n)
|
|
364
|
-
continue;
|
|
365
|
-
const s = r.getAttribute("FromCell") ?? "", o = t.get(i) ?? {};
|
|
366
|
-
/begin/i.test(s) ? o.source = n : /end/i.test(s) && (o.target = n), t.set(i, o);
|
|
367
|
-
}
|
|
368
|
-
return t;
|
|
369
|
-
}
|
|
370
|
-
function B(e, t) {
|
|
371
|
-
const r = /* @__PURE__ */ new Map();
|
|
372
|
-
if (!e) return r;
|
|
373
|
-
for (const i of Array.from(e.getElementsByTagName("*"))) {
|
|
374
|
-
if (g(i) !== "cell") continue;
|
|
375
|
-
const n = i.getAttribute("N");
|
|
376
|
-
n != null && !r.has(n) && r.set(n, i.getAttribute("V"));
|
|
377
|
-
}
|
|
378
|
-
if (t) {
|
|
379
|
-
for (const i of Array.from(e.children))
|
|
380
|
-
if (["xform", "xform1d", "pageprops", "fill", "line"].includes(g(i)))
|
|
381
|
-
for (const n of Array.from(i.children))
|
|
382
|
-
r.has(n.localName) || r.set(n.localName, n.textContent);
|
|
383
|
-
}
|
|
384
|
-
return r;
|
|
385
|
-
}
|
|
386
|
-
function b(e, t) {
|
|
387
|
-
const r = Number(e.get(t));
|
|
388
|
-
return Number.isFinite(r) ? r : void 0;
|
|
389
|
-
}
|
|
390
|
-
function gt(e) {
|
|
391
|
-
const t = Array.from(e.children).find((r) => g(r) === "text");
|
|
392
|
-
return (t == null ? void 0 : t.textContent) ?? "";
|
|
393
|
-
}
|
|
394
|
-
function ut(e) {
|
|
395
|
-
const t = $(e.get("FillForegnd") ?? void 0), r = $(e.get("LineColor") ?? void 0);
|
|
396
|
-
return [
|
|
397
|
-
t ? `fillColor=${t}` : "",
|
|
398
|
-
r ? `strokeColor=${r}` : "",
|
|
399
|
-
"rounded=1"
|
|
400
|
-
].filter(Boolean).join(";");
|
|
401
|
-
}
|
|
402
|
-
function $(e) {
|
|
403
|
-
var i;
|
|
404
|
-
if (!e || e === "THEMEGUARD(RGB(255,255,255))")
|
|
405
|
-
return;
|
|
406
|
-
const t = (i = /^#?[0-9a-f]{6}$/i.exec(e.trim())) == null ? void 0 : i[0];
|
|
407
|
-
if (t)
|
|
408
|
-
return t.startsWith("#") ? t : `#${t}`;
|
|
409
|
-
const r = /RGB\((\d+),\s*(\d+),\s*(\d+)\)/i.exec(e);
|
|
410
|
-
if (r)
|
|
411
|
-
return `#${[r[1], r[2], r[3]].map((n) => Number(n).toString(16).padStart(2, "0")).join("")}`;
|
|
412
|
-
}
|
|
413
|
-
function P(e, t, r) {
|
|
414
|
-
const i = ft(e), n = g(i) === "mxgraphmodel" ? i : Array.from(i.getElementsByTagName("*")).find((c) => g(c) === "mxgraphmodel"), s = n ? Array.from(n.getElementsByTagName("*")).filter((c) => g(c) === "mxcell") : [], o = [], a = [];
|
|
415
|
-
for (const c of s) {
|
|
416
|
-
const d = c.getAttribute("id") ?? `cell-${o.length + a.length + 1}`, l = N(c, "mxgeometry")[0];
|
|
417
|
-
if (c.getAttribute("vertex") === "1" && l) {
|
|
418
|
-
o.push({
|
|
419
|
-
id: d,
|
|
420
|
-
label: L(c.getAttribute("value") ?? "", r),
|
|
421
|
-
x: A(l, "x"),
|
|
422
|
-
y: A(l, "y"),
|
|
423
|
-
width: A(l, "width", J),
|
|
424
|
-
height: A(l, "height", Z),
|
|
425
|
-
style: c.getAttribute("style") ?? void 0
|
|
426
|
-
});
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
c.getAttribute("edge") === "1" && a.push({
|
|
430
|
-
id: d,
|
|
431
|
-
label: L(c.getAttribute("value") ?? "", r),
|
|
432
|
-
source: c.getAttribute("source") ?? void 0,
|
|
433
|
-
target: c.getAttribute("target") ?? void 0,
|
|
434
|
-
points: l ? xt(l) : [],
|
|
435
|
-
style: c.getAttribute("style") ?? void 0
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
return {
|
|
439
|
-
id: e.getAttribute("id") ?? `page-${t + 1}`,
|
|
440
|
-
name: e.getAttribute("name") || `Page ${t + 1}`,
|
|
441
|
-
nodes: o,
|
|
442
|
-
edges: a
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function ft(e) {
|
|
446
|
-
var r;
|
|
447
|
-
if (g(e) !== "diagram" || Array.from(e.getElementsByTagName("*")).some((i) => g(i) === "mxgraphmodel"))
|
|
448
|
-
return e;
|
|
449
|
-
const t = (r = e.textContent) == null ? void 0 : r.trim();
|
|
450
|
-
if (!t)
|
|
451
|
-
return e;
|
|
452
|
-
try {
|
|
453
|
-
const i = pt(t), n = new DOMParser().parseFromString(i, "application/xml");
|
|
454
|
-
return n.getElementsByTagName("parsererror")[0] ? e : n.documentElement;
|
|
455
|
-
} catch {
|
|
456
|
-
return e;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
function pt(e) {
|
|
460
|
-
const t = e.replace(/\s+/g, ""), r = typeof atob == "function" ? atob(t) : Buffer.from(t, "base64").toString("binary"), i = Uint8Array.from(r, (o) => o.charCodeAt(0));
|
|
461
|
-
let n;
|
|
462
|
-
try {
|
|
463
|
-
n = W(i);
|
|
464
|
-
} catch {
|
|
465
|
-
n = H(i);
|
|
466
|
-
}
|
|
467
|
-
const s = j(n).replace(/\+/g, "%20");
|
|
468
|
-
return decodeURIComponent(s);
|
|
469
|
-
}
|
|
470
|
-
function bt(e, t) {
|
|
471
|
-
const r = document.createElementNS(p, "g");
|
|
472
|
-
r.classList.add("diagramv-nodes");
|
|
473
|
-
for (const i of e.nodes) {
|
|
474
|
-
const n = document.createElementNS(p, "g");
|
|
475
|
-
n.classList.add("diagramv-node"), n.setAttribute("data-element-id", i.id), n.setAttribute("tabindex", "0"), n.setAttribute("role", "button"), n.setAttribute("aria-label", i.label || i.id), n.addEventListener("click", () => t(i.id)), n.addEventListener("keydown", (a) => {
|
|
476
|
-
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), t(i.id));
|
|
477
|
-
});
|
|
478
|
-
const s = X(i.style), o = At(i, s);
|
|
479
|
-
if (n.appendChild(o), i.label) {
|
|
480
|
-
const a = document.createElementNS(p, "text");
|
|
481
|
-
a.setAttribute("x", String(i.x + i.width / 2)), a.setAttribute("y", String(i.y + i.height / 2 + 5)), a.setAttribute("fill", s.fontColor ?? V), a.setAttribute("font-size", s.fontSize ?? "13"), a.textContent = z(i.label), n.appendChild(a);
|
|
482
|
-
}
|
|
483
|
-
r.appendChild(n);
|
|
484
|
-
}
|
|
485
|
-
return r;
|
|
486
|
-
}
|
|
487
|
-
function yt() {
|
|
488
|
-
const e = document.createElementNS(p, "defs"), t = document.createElementNS(p, "marker");
|
|
489
|
-
t.setAttribute("id", "diagramv-arrow-end"), t.setAttribute("viewBox", "0 0 10 10"), t.setAttribute("refX", "9"), t.setAttribute("refY", "5"), t.setAttribute("markerWidth", "7"), t.setAttribute("markerHeight", "7"), t.setAttribute("orient", "auto-start-reverse");
|
|
490
|
-
const r = document.createElementNS(p, "path");
|
|
491
|
-
return r.setAttribute("d", "M 0 0 L 10 5 L 0 10 z"), r.setAttribute("fill", "context-stroke"), t.appendChild(r), e.appendChild(t), e;
|
|
492
|
-
}
|
|
493
|
-
function wt(e, t) {
|
|
494
|
-
const r = document.createElementNS(p, "g");
|
|
495
|
-
r.classList.add("diagramv-edges");
|
|
496
|
-
const i = new Map(e.nodes.map((n) => [n.id, n]));
|
|
497
|
-
for (const n of e.edges) {
|
|
498
|
-
const s = document.createElementNS(p, "g");
|
|
499
|
-
s.classList.add("diagramv-edge"), s.setAttribute("data-element-id", n.id), s.setAttribute("tabindex", "0"), s.setAttribute("role", "button"), s.setAttribute("aria-label", n.label || n.id), s.addEventListener("click", () => t(n.id)), s.addEventListener("keydown", (d) => {
|
|
500
|
-
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), t(n.id));
|
|
501
|
-
});
|
|
502
|
-
const o = Et(n, i), a = X(n.style), c = document.createElementNS(p, "polyline");
|
|
503
|
-
if (c.setAttribute("points", o.map(([d, l]) => `${d},${l}`).join(" ")), c.setAttribute("stroke", a.strokeColor ?? tt), c.setAttribute("stroke-width", a.strokeWidth ?? "2"), a.dashed === "1" && c.setAttribute("stroke-dasharray", "8 5"), a.endArrow && a.endArrow !== "none" && c.setAttribute("marker-end", "url(#diagramv-arrow-end)"), s.appendChild(c), n.label && o.length) {
|
|
504
|
-
const d = o[Math.floor(o.length / 2)], l = document.createElementNS(p, "text");
|
|
505
|
-
l.setAttribute("x", String(d[0] + 8)), l.setAttribute("y", String(d[1] - 8)), l.setAttribute("fill", a.fontColor ?? V), l.setAttribute("font-size", a.fontSize ?? "13"), l.textContent = z(n.label), s.appendChild(l);
|
|
506
|
-
}
|
|
507
|
-
r.appendChild(s);
|
|
508
|
-
}
|
|
509
|
-
return r;
|
|
510
|
-
}
|
|
511
|
-
function At(e, t) {
|
|
512
|
-
const r = t.shape ?? "";
|
|
513
|
-
if (r === "ellipse" || t.ellipse === "1") {
|
|
514
|
-
const n = document.createElementNS(p, "ellipse");
|
|
515
|
-
return n.setAttribute("cx", String(e.x + e.width / 2)), n.setAttribute("cy", String(e.y + e.height / 2)), n.setAttribute("rx", String(e.width / 2)), n.setAttribute("ry", String(e.height / 2)), C(n, t), n;
|
|
516
|
-
}
|
|
517
|
-
if (r === "rhombus" || t.rhombus === "1") {
|
|
518
|
-
const n = document.createElementNS(p, "polygon");
|
|
519
|
-
return n.setAttribute("points", [
|
|
520
|
-
[e.x + e.width / 2, e.y],
|
|
521
|
-
[e.x + e.width, e.y + e.height / 2],
|
|
522
|
-
[e.x + e.width / 2, e.y + e.height],
|
|
523
|
-
[e.x, e.y + e.height / 2]
|
|
524
|
-
].map(([s, o]) => `${s},${o}`).join(" ")), C(n, t), n;
|
|
525
|
-
}
|
|
526
|
-
const i = document.createElementNS(p, "rect");
|
|
527
|
-
return i.setAttribute("x", String(e.x)), i.setAttribute("y", String(e.y)), i.setAttribute("width", String(e.width)), i.setAttribute("height", String(e.height)), i.setAttribute("rx", t.rounded === "1" ? "8" : "3"), C(i, t), i;
|
|
528
|
-
}
|
|
529
|
-
function C(e, t) {
|
|
530
|
-
e.setAttribute("fill", t.fillColor === "none" ? "transparent" : t.fillColor ?? K), e.setAttribute("stroke", t.strokeColor === "none" ? "transparent" : t.strokeColor ?? Q), e.setAttribute("stroke-width", t.strokeWidth ?? "1.4"), t.dashed === "1" && e.setAttribute("stroke-dasharray", "8 5");
|
|
531
|
-
}
|
|
532
|
-
function Et(e, t) {
|
|
533
|
-
const r = [], i = e.source ? t.get(e.source) : void 0, n = e.target ? t.get(e.target) : void 0;
|
|
534
|
-
return i && r.push([i.x + i.width, i.y + i.height / 2]), r.push(...e.points), n && r.push([n.x, n.y + n.height / 2]), r.length >= 2 ? r : i && n ? [
|
|
535
|
-
[i.x + i.width, i.y + i.height / 2],
|
|
536
|
-
[n.x, n.y + n.height / 2]
|
|
537
|
-
] : r;
|
|
538
|
-
}
|
|
539
|
-
function xt(e) {
|
|
540
|
-
const t = [];
|
|
541
|
-
for (const i of N(e, "mxpoint"))
|
|
542
|
-
t.push([A(i, "x"), A(i, "y")]);
|
|
543
|
-
const r = N(e, "array")[0];
|
|
544
|
-
if (r)
|
|
545
|
-
for (const i of N(r, "mxpoint"))
|
|
546
|
-
t.push([A(i, "x"), A(i, "y")]);
|
|
547
|
-
return t;
|
|
548
|
-
}
|
|
549
|
-
function vt(e) {
|
|
550
|
-
let t = Number.POSITIVE_INFINITY, r = Number.POSITIVE_INFINITY, i = Number.NEGATIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
|
|
551
|
-
for (const s of e.nodes)
|
|
552
|
-
t = Math.min(t, s.x), r = Math.min(r, s.y), i = Math.max(i, s.x + s.width), n = Math.max(n, s.y + s.height);
|
|
553
|
-
for (const s of e.edges)
|
|
554
|
-
for (const [o, a] of s.points)
|
|
555
|
-
t = Math.min(t, o), r = Math.min(r, a), i = Math.max(i, o), n = Math.max(n, a);
|
|
556
|
-
return !Number.isFinite(t) || !Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(n) ? { minX: 0, minY: 0, width: 360, height: 260 } : (t -= S, r -= S, i += S, n += S, {
|
|
557
|
-
minX: t,
|
|
558
|
-
minY: r,
|
|
559
|
-
width: Math.max(360, i - t),
|
|
560
|
-
height: Math.max(260, n - r)
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
function N(e, t) {
|
|
564
|
-
return Array.from(e.children).filter((r) => g(r) === t);
|
|
565
|
-
}
|
|
566
|
-
function g(e) {
|
|
567
|
-
return e.localName.toLowerCase();
|
|
568
|
-
}
|
|
569
|
-
function A(e, t, r = 0) {
|
|
570
|
-
const i = e.getAttribute(t), n = i === null ? NaN : Number(i);
|
|
571
|
-
return Number.isFinite(n) ? n : r;
|
|
572
|
-
}
|
|
573
|
-
function L(e, t) {
|
|
574
|
-
return St(e.replace(/<[^>]+>/g, " "), t).replace(/\s+/g, " ").trim();
|
|
575
|
-
}
|
|
576
|
-
function X(e) {
|
|
577
|
-
const t = {};
|
|
578
|
-
for (const r of String(e ?? "").split(";")) {
|
|
579
|
-
if (!r)
|
|
580
|
-
continue;
|
|
581
|
-
const [i, ...n] = r.split("="), s = i == null ? void 0 : i.trim();
|
|
582
|
-
s && (t[s] = n.length ? n.join("=").trim() : "1");
|
|
583
|
-
}
|
|
584
|
-
return t;
|
|
585
|
-
}
|
|
586
|
-
function St(e, t) {
|
|
587
|
-
if (!e.includes("&") && !e.includes("\0")) return e;
|
|
588
|
-
if (!e.includes("\0") && !/&(?!amp;|lt;|gt;|quot;|apos;)/.test(e))
|
|
589
|
-
return e.replace(/&(amp|lt|gt|quot|apos);/g, (i, n) => et[n]);
|
|
590
|
-
const r = t.labelDecoder ?? (t.labelDecoder = document.createElement("textarea"));
|
|
591
|
-
return r.innerHTML = e, r.value;
|
|
592
|
-
}
|
|
593
|
-
function z(e) {
|
|
594
|
-
return e.length > 34 ? `${e.slice(0, 31)}...` : e;
|
|
595
|
-
}
|
|
596
|
-
async function Nt(e, t) {
|
|
597
|
-
if (m(t.signal), typeof e == "string") {
|
|
598
|
-
if (e.trimStart().toLowerCase().startsWith("data:"))
|
|
599
|
-
return Tt(e);
|
|
600
|
-
const r = await fetch(e, { signal: t.signal });
|
|
601
|
-
if (m(t.signal), !r.ok)
|
|
602
|
-
throw new Error(`Failed to load diagram source: ${r.status} ${r.statusText}`.trim());
|
|
603
|
-
return r.text();
|
|
604
|
-
}
|
|
605
|
-
return e instanceof Blob ? e.text() : ArrayBuffer.isView(e) ? new TextDecoder().decode(e) : e instanceof ArrayBuffer ? new TextDecoder().decode(e) : String(e);
|
|
606
|
-
}
|
|
607
|
-
async function It(e, t) {
|
|
608
|
-
if (m(t.signal), typeof e == "string") {
|
|
609
|
-
if (e.trimStart().toLowerCase().startsWith("data:"))
|
|
610
|
-
return D(Ct(e));
|
|
611
|
-
const r = await fetch(e, { signal: t.signal });
|
|
612
|
-
if (m(t.signal), !r.ok)
|
|
613
|
-
throw new Error(`Failed to load diagram source: ${r.status} ${r.statusText}`.trim());
|
|
614
|
-
return r.arrayBuffer();
|
|
615
|
-
}
|
|
616
|
-
if (e instanceof Blob)
|
|
617
|
-
return e.arrayBuffer();
|
|
618
|
-
if (ArrayBuffer.isView(e)) {
|
|
619
|
-
const r = new Uint8Array(e.byteLength);
|
|
620
|
-
return r.set(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)), D(r);
|
|
621
|
-
}
|
|
622
|
-
return e instanceof ArrayBuffer ? e : D(new TextEncoder().encode(String(e)));
|
|
623
|
-
}
|
|
624
|
-
function m(e) {
|
|
625
|
-
if (e != null && e.aborted) throw new DOMException("The operation was aborted.", "AbortError");
|
|
626
|
-
}
|
|
627
|
-
function Tt(e) {
|
|
628
|
-
const t = e.indexOf(",");
|
|
629
|
-
if (t < 0)
|
|
630
|
-
return e;
|
|
631
|
-
const r = e.slice(0, t).toLowerCase(), i = e.slice(t + 1);
|
|
632
|
-
return r.endsWith(";base64") ? new TextDecoder().decode(Uint8Array.from(atob(i), (n) => n.charCodeAt(0))) : decodeURIComponent(i);
|
|
633
|
-
}
|
|
634
|
-
function Ct(e) {
|
|
635
|
-
const t = e.indexOf(",");
|
|
636
|
-
if (t < 0)
|
|
637
|
-
return new TextEncoder().encode(e);
|
|
638
|
-
const r = e.slice(0, t).toLowerCase(), i = e.slice(t + 1);
|
|
639
|
-
return r.endsWith(";base64") ? Uint8Array.from(atob(i), (n) => n.charCodeAt(0)) : new TextEncoder().encode(decodeURIComponent(i));
|
|
640
|
-
}
|
|
641
|
-
function D(e) {
|
|
642
|
-
const t = new Uint8Array(e.byteLength);
|
|
643
|
-
return t.set(e), t.buffer;
|
|
644
|
-
}
|
|
645
|
-
function Dt(e) {
|
|
646
|
-
return e !== void 0;
|
|
647
|
-
}
|
|
648
|
-
function O(e) {
|
|
649
|
-
return String(e ?? "").trim().replace(/^\./, "").toLowerCase();
|
|
650
|
-
}
|
|
651
|
-
export {
|
|
652
|
-
Bt as a,
|
|
653
|
-
kt as c
|
|
654
|
-
};
|