@silurus/ooxml 0.82.1 → 0.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -5
- package/dist/assets/render-worker-4GSYWsM3.js +11 -0
- package/dist/assets/{render-worker-Cy-QsDge.js → render-worker-DwFpY197.js} +4 -4
- package/dist/{canvas-viewer-mechanics-CS_qbr6T.js → canvas-viewer-mechanics-h07vpVOQ.js} +42 -2
- package/dist/{comment-ui-runtime-C1RV_3iu.js → comment-ui-runtime-BelHJt73.js} +2 -2
- package/dist/{comment-ui-runtime-DgCZpPR0.js → comment-ui-runtime-DD5a3x3k.js} +2 -2
- package/dist/{comments-Cf9W7r3M.js → comments-AAaNnQTi.js} +7 -2
- package/dist/{document-pull-client-B1WOjA0z.js → document-pull-client-DSx36ZsB.js} +4519 -3952
- package/dist/docx-BF-WKW73.js +2784 -0
- package/dist/docx.mjs +6 -6
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/dom-interaction-boundary-CepOlXt6.js +217 -0
- package/dist/index.mjs +4 -4
- package/dist/line-distribute-D7A_wnJg.js +1003 -0
- package/dist/{line-metrics-B3syvDn2.js → line-metrics-Bpn7OeZD.js} +616 -616
- package/dist/node.mjs +308 -308
- package/dist/pptx-CA-Q09yW.js +3010 -0
- package/dist/pptx.mjs +5 -5
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/{render-BC8p7vZQ.js → render-DtbFbO5c.js} +1 -1
- package/dist/{render-worker-host-BNnXCtAu.js → render-worker-host-D1jcACJV.js} +1 -1
- package/dist/{render-worker-host-DhnkTyjj.js → render-worker-host-DCLyw6UR.js} +1 -1
- package/dist/{resource-measurement-CsW4_eYt.js → resource-measurement-DuiFWzam.js} +3 -3
- package/dist/{session-Da7LEQUB.js → session-CxT-t0BX.js} +107 -94
- package/dist/{slide-pull-client-Bg9DusLX.js → slide-pull-client-B9rcJdO4.js} +1190 -937
- package/dist/types/docx.d.ts +103 -8
- package/dist/types/index.d.ts +195 -13
- package/dist/types/node.d.ts +2 -2
- package/dist/types/pptx.d.ts +100 -5
- package/dist/types/xlsx.d.ts +2 -2
- package/dist/{worksheet-pull-client-CYtwXP5D.js → worksheet-pull-client-DyFsDF4A.js} +32 -32
- package/dist/{xlsx-DMWeXT-c.js → xlsx-BibrHQ52.js} +476 -476
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +3 -1
- package/dist/assets/render-worker-aHayzR7v.js +0 -11
- package/dist/docx-HoZXZUPA.js +0 -2162
- package/dist/dom-interaction-boundary-C8F6HO5x.js +0 -119
- package/dist/line-distribute-iXsUCIH-.js +0 -1003
- package/dist/pptx-DEUP4Yq5.js +0 -2432
- /package/dist/{comment-occurrence-C34fWs_F.js → comment-occurrence-X54si2ob.js} +0 -0
- /package/dist/{highlight-rect-MaCt0om0.js → highlight-rect-Hes0z_Mj.js} +0 -0
|
@@ -0,0 +1,3010 @@
|
|
|
1
|
+
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
+
import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, r as l, s as u, t as d, u as f } from "./slide-pull-client-B9rcJdO4.js";
|
|
3
|
+
import { B as p, G as m, Qt as h, R as g, Rt as _, Vt as v, W as y, Zt as b, a as x, et as S, ft as C, lt as w, tt as ee, z as te } from "./line-metrics-Bpn7OeZD.js";
|
|
4
|
+
import { C as ne, E as re, S as ie, T as ae, _ as oe, a as T, b as se, c as E, d as ce, f as le, g as ue, h as de, i as D, l as O, m as fe, n as pe, o as me, p as he, r as ge, s as _e, t as ve, v as ye, w as be, x as xe, y as Se } from "./canvas-viewer-mechanics-h07vpVOQ.js";
|
|
5
|
+
import { a as Ce, i as k, n as we, t as Te } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
6
|
+
import { a as A, c as Ee, i as De, l as j, n as Oe, r as ke, t as Ae } from "./dom-interaction-boundary-CepOlXt6.js";
|
|
7
|
+
import { cn as je, ln as Me } from "./plot-area-frame-DHV02PJU.js";
|
|
8
|
+
import { i as M } from "./units-BzZ0gAxs.js";
|
|
9
|
+
import { n as Ne } from "./resource-measurement-DuiFWzam.js";
|
|
10
|
+
import { n as Pe } from "./renderer-module-contract-DLbb7zY0.js";
|
|
11
|
+
import { t as Fe } from "./visible-index-BFE3PWiY.js";
|
|
12
|
+
import { n as Ie, t as N } from "./highlight-rect-Hes0z_Mj.js";
|
|
13
|
+
import { t as P } from "./comment-occurrence-X54si2ob.js";
|
|
14
|
+
//#region packages/core/src/nav/internal-target.ts
|
|
15
|
+
function Le(e, t) {
|
|
16
|
+
let n = t.startsWith("/") ? [] : e.split("/").filter((e) => e !== "");
|
|
17
|
+
for (let e of t.split("/")) if (e === "..") n.pop();
|
|
18
|
+
else if (e === "." || e === "") continue;
|
|
19
|
+
else n.push(e);
|
|
20
|
+
return n.join("/");
|
|
21
|
+
}
|
|
22
|
+
function Re(e) {
|
|
23
|
+
let t = /[?&]jump=([a-zA-Z]+)/.exec(e);
|
|
24
|
+
if (!t) return null;
|
|
25
|
+
let n = t[1].toLowerCase();
|
|
26
|
+
return n === "firstslide" || n === "lastslide" || n === "nextslide" || n === "previousslide" ? n : null;
|
|
27
|
+
}
|
|
28
|
+
function ze(e, t, n) {
|
|
29
|
+
if (!(n <= 0)) switch (e) {
|
|
30
|
+
case "firstslide": return 0;
|
|
31
|
+
case "lastslide": return n - 1;
|
|
32
|
+
case "nextslide": return Math.min(t + 1, n - 1);
|
|
33
|
+
case "previousslide": return Math.max(t - 1, 0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region packages/pptx/src/run-frame-transform.ts
|
|
38
|
+
function Be(e) {
|
|
39
|
+
let t = e.textBodyRotation ?? 0, n = e.shapeFlipH === !0, r = e.shapeFlipV === !0;
|
|
40
|
+
if (n || r) return `rotate(${e.rotation}deg) scale(${n ? -1 : 1}, ${r ? -1 : 1})` + (t === 0 ? "" : ` rotate(${t}deg)`);
|
|
41
|
+
let i = e.rotation + t;
|
|
42
|
+
return i === 0 ? "" : `rotate(${i}deg)`;
|
|
43
|
+
}
|
|
44
|
+
function Ve(e, t) {
|
|
45
|
+
return `${e.shapeX},${e.shapeY},${e.shapeW},${e.shapeH},` + t;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region packages/pptx/src/text-layer.ts
|
|
49
|
+
function F(e, t, n) {
|
|
50
|
+
e.dataset ? n === void 0 ? delete e.dataset[t] : e.dataset[t] = n : n !== void 0 && e.setAttribute?.(`data-${t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}`, n);
|
|
51
|
+
}
|
|
52
|
+
function I(e, t, n, r, i, a) {
|
|
53
|
+
e.innerHTML = "", F(e, "ooxmlSelectionSurface", "pptx"), F(e, "slideIndex", a === void 0 ? void 0 : String(a));
|
|
54
|
+
let o = /* @__PURE__ */ new Map(), s = e.ownerDocument ?? document;
|
|
55
|
+
for (let [a, c] of t.entries()) {
|
|
56
|
+
let t = Be(c), l = Ve(c, t), u = o.get(l);
|
|
57
|
+
if (!u) {
|
|
58
|
+
let i = s.createElement("div");
|
|
59
|
+
i.style.cssText = `position:absolute;left:${N(c.shapeX, n)};top:${N(c.shapeY, r)};width:${N(c.shapeW, n)};height:${N(c.shapeH, r)};pointer-events:all;overflow:visible;`, t && (i.style.transformOrigin = "center center", i.style.transform = t), u = {
|
|
60
|
+
div: i,
|
|
61
|
+
w: c.shapeW,
|
|
62
|
+
h: c.shapeH
|
|
63
|
+
}, o.set(l, u), e.appendChild(i);
|
|
64
|
+
}
|
|
65
|
+
let d = s.createElement("span");
|
|
66
|
+
F(d, "ooxmlSelectionRun", "pptx"), F(d, "runIndex", String(a)), c.shapeId !== void 0 && F(d, "shapeId", c.shapeId), c.elementIndex !== void 0 && F(d, "elementIndex", String(c.elementIndex)), c.origin !== void 0 && F(d, "elementOrigin", c.origin), d.textContent = c.text;
|
|
67
|
+
let f = i ? c.hyperlink : void 0;
|
|
68
|
+
d.style.cssText = `position:absolute;left:${N(c.inShapeX, u.w)};top:${N(c.inShapeY, u.h)};font:${c.font};line-height:${c.h}px;letter-spacing:0;white-space:pre;color:transparent;cursor:${f ? "pointer" : "text"};`, f && i && (d.title = f.kind === "external" ? f.url : f.ref, d.addEventListener("click", (e) => {
|
|
69
|
+
e.preventDefault(), i(f);
|
|
70
|
+
})), u.div.appendChild(d);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function L(e, t, n, r, i, a, o = {}) {
|
|
74
|
+
e.innerHTML = "";
|
|
75
|
+
let s = o.match ?? "rgba(255, 214, 0, 0.42)", c = o.active ?? "rgba(255, 140, 0, 0.55)", l = /* @__PURE__ */ new Map(), u = (t) => {
|
|
76
|
+
let n = Be(t), a = Ve(t, n), o = l.get(a);
|
|
77
|
+
if (!o) {
|
|
78
|
+
let s = document.createElement("div");
|
|
79
|
+
s.style.cssText = `position:absolute;left:${N(t.shapeX, r)};top:${N(t.shapeY, i)};width:${N(t.shapeW, r)};height:${N(t.shapeH, i)};pointer-events:none;overflow:hidden;`, n && (s.style.transformOrigin = "center center", s.style.transform = n), o = {
|
|
80
|
+
div: s,
|
|
81
|
+
w: t.shapeW,
|
|
82
|
+
h: t.shapeH
|
|
83
|
+
}, l.set(a, o), e.appendChild(s);
|
|
84
|
+
}
|
|
85
|
+
return o;
|
|
86
|
+
};
|
|
87
|
+
for (let e of n) {
|
|
88
|
+
let n = e.active ? c : s;
|
|
89
|
+
for (let r of e.slices) {
|
|
90
|
+
let e = t[r.runIndex];
|
|
91
|
+
if (!e) continue;
|
|
92
|
+
let i = a(e.font), { x: o, width: s } = Ie(e.text, r.start, r.end, i);
|
|
93
|
+
if (s <= 0) continue;
|
|
94
|
+
let c = u(e), l = document.createElement("div");
|
|
95
|
+
l.style.cssText = `position:absolute;left:${N(e.inShapeX + o, c.w)};top:${N(e.inShapeY, c.h)};width:${N(s, c.w)};height:${N(e.h, c.h)};background:${n};pointer-events:none;`, c.div.appendChild(l);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region packages/pptx/src/find.ts
|
|
101
|
+
function He(e, t) {
|
|
102
|
+
let n = e.tableCell, r = t.tableCell;
|
|
103
|
+
return !n && !r ? !0 : !n || !r ? !1 : e.elementIndex === t.elementIndex && e.origin === t.origin && e.shapeId === t.shapeId && n.row === r.row && n.column === r.column;
|
|
104
|
+
}
|
|
105
|
+
function Ue(e, t) {
|
|
106
|
+
for (let n = 1; n < t.length; n++) {
|
|
107
|
+
let r = e[t[n - 1].runIndex], i = e[t[n].runIndex];
|
|
108
|
+
if (!r || !i || !He(r, i)) return !1;
|
|
109
|
+
}
|
|
110
|
+
return !0;
|
|
111
|
+
}
|
|
112
|
+
var We = class {
|
|
113
|
+
_slideRuns = /* @__PURE__ */ new Map();
|
|
114
|
+
_matches = [];
|
|
115
|
+
_active = -1;
|
|
116
|
+
_generation = 0;
|
|
117
|
+
_runsRevision = 0;
|
|
118
|
+
constructor(e, t) {
|
|
119
|
+
this._slideCount = e, this._collectSlideRuns = t;
|
|
120
|
+
}
|
|
121
|
+
invalidate() {
|
|
122
|
+
this._generation++, this._runsRevision++, this._slideRuns.clear(), this._matches = [], this._active = -1;
|
|
123
|
+
}
|
|
124
|
+
slideRuns(e) {
|
|
125
|
+
return this._slideRuns.get(e);
|
|
126
|
+
}
|
|
127
|
+
setSlideRuns(e, t) {
|
|
128
|
+
this._runsRevision++, this._slideRuns.set(e, t);
|
|
129
|
+
}
|
|
130
|
+
slideHighlights(e) {
|
|
131
|
+
let t = [];
|
|
132
|
+
for (let n = 0; n < this._matches.length; n++) {
|
|
133
|
+
let r = this._matches[n];
|
|
134
|
+
r.slide === e && t.push({
|
|
135
|
+
slices: r.slices,
|
|
136
|
+
active: n === this._active
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return t;
|
|
140
|
+
}
|
|
141
|
+
activeSlide() {
|
|
142
|
+
let e = this._matches[this._active];
|
|
143
|
+
return e ? e.slide : null;
|
|
144
|
+
}
|
|
145
|
+
matches() {
|
|
146
|
+
return this._matches.map((e, t) => ({
|
|
147
|
+
matchIndex: t,
|
|
148
|
+
text: e.text,
|
|
149
|
+
location: { slide: e.slide }
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
async find(e, t = {}) {
|
|
153
|
+
let n = ++this._generation;
|
|
154
|
+
if (e.length === 0) return this._runsRevision++, this._slideRuns.clear(), this._matches = [], this._active = -1, [];
|
|
155
|
+
let r = this._runsRevision, i = new Map(this._slideRuns), a = this._slideCount();
|
|
156
|
+
for (let e = 0; e < a; e++) {
|
|
157
|
+
let t = i.get(e);
|
|
158
|
+
if (!t) {
|
|
159
|
+
try {
|
|
160
|
+
t = await this._collectSlideRuns(e);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if (n !== this._generation) return [];
|
|
163
|
+
throw e;
|
|
164
|
+
}
|
|
165
|
+
if (n !== this._generation) return [];
|
|
166
|
+
i.set(e, t);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (n !== this._generation) return [];
|
|
170
|
+
let o = r === this._runsRevision ? i : new Map([...i, ...this._slideRuns]), s = [];
|
|
171
|
+
for (let n = 0; n < a; n++) {
|
|
172
|
+
let r = o.get(n) ?? [], i = fe(r);
|
|
173
|
+
for (let a of de(i, e, t)) {
|
|
174
|
+
if (!Ue(r, a.slices)) continue;
|
|
175
|
+
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
176
|
+
s.push({
|
|
177
|
+
slide: n,
|
|
178
|
+
text: e,
|
|
179
|
+
slices: a.slices
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return this._runsRevision++, this._slideRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
184
|
+
}
|
|
185
|
+
next() {
|
|
186
|
+
return this._active = le(this._active, this._matches.length), this._activePublic();
|
|
187
|
+
}
|
|
188
|
+
prev() {
|
|
189
|
+
return this._active = he(this._active, this._matches.length), this._activePublic();
|
|
190
|
+
}
|
|
191
|
+
_activePublic() {
|
|
192
|
+
let e = this._matches[this._active];
|
|
193
|
+
return e ? {
|
|
194
|
+
matchIndex: this._active,
|
|
195
|
+
text: e.text,
|
|
196
|
+
location: { slide: e.slide }
|
|
197
|
+
} : null;
|
|
198
|
+
}
|
|
199
|
+
}, Ge = (e) => e >= "0" && e <= "9";
|
|
200
|
+
function Ke(e) {
|
|
201
|
+
let t = 0;
|
|
202
|
+
for (let n = 0; n < 10; n++) t = Math.max(t, e.measureText(String(n)).width);
|
|
203
|
+
return t;
|
|
204
|
+
}
|
|
205
|
+
function qe(e, t, n) {
|
|
206
|
+
let r = 0;
|
|
207
|
+
for (let i of t) r += Ge(i) ? n : e.measureText(i).width;
|
|
208
|
+
return r;
|
|
209
|
+
}
|
|
210
|
+
function Je(e, t, n, r, i) {
|
|
211
|
+
let a = e.textAlign;
|
|
212
|
+
e.textAlign = "left";
|
|
213
|
+
let o = n;
|
|
214
|
+
for (let n of t) if (Ge(n)) {
|
|
215
|
+
let t = e.measureText(n).width;
|
|
216
|
+
e.fillText(n, o + (i - t) / 2, r), o += i;
|
|
217
|
+
} else e.fillText(n, o, r), o += e.measureText(n).width;
|
|
218
|
+
e.textAlign = a;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region packages/pptx/src/presentation-handle.ts
|
|
222
|
+
var R = (e, t) => e / M * t;
|
|
223
|
+
async function Ye(e, t, n) {
|
|
224
|
+
let r = e.getContext("2d");
|
|
225
|
+
if (!r) throw Error("2D context not available");
|
|
226
|
+
let a = n.width / (n.slideWidthEmu / M);
|
|
227
|
+
await n.drawBase();
|
|
228
|
+
let o = document.createElement("canvas");
|
|
229
|
+
o.width = e.width, o.height = e.height;
|
|
230
|
+
let s = o.getContext("2d");
|
|
231
|
+
if (!s) throw Error("base 2D context not available");
|
|
232
|
+
s.drawImage(e, 0, 0);
|
|
233
|
+
let c = [], l = !1, u = () => {
|
|
234
|
+
for (let e of c) {
|
|
235
|
+
e.detachListeners(), e.media.pause(), e.media.removeAttribute("src");
|
|
236
|
+
try {
|
|
237
|
+
e.media.load();
|
|
238
|
+
} catch {}
|
|
239
|
+
URL.revokeObjectURL(e.objectUrl);
|
|
240
|
+
}
|
|
241
|
+
c.length = 0;
|
|
242
|
+
}, d = (e) => {
|
|
243
|
+
l || (n.onError ? n.onError(e) : console.error("[ooxml] PPTX embedded media failed:", e));
|
|
244
|
+
};
|
|
245
|
+
for (let e of t) {
|
|
246
|
+
let t;
|
|
247
|
+
try {
|
|
248
|
+
t = await n.fetchMedia(e.mediaPath);
|
|
249
|
+
} catch (t) {
|
|
250
|
+
throw u(), Qe(e, t);
|
|
251
|
+
}
|
|
252
|
+
let r = e.mimeType || t.type, i = t.type === r ? t : new Blob([t], { type: r }), o = URL.createObjectURL(i), s = e.mediaKind === "video" ? document.createElement("video") : document.createElement("audio");
|
|
253
|
+
s.src = o, s.preload = "metadata", e.mediaKind === "video" && (s.playsInline = !0);
|
|
254
|
+
let f = Xe(e, a), p = {
|
|
255
|
+
el: e,
|
|
256
|
+
rect: e.mediaKind === "audio" ? {
|
|
257
|
+
x: f.x + f.w / 2 - Math.max(f.w, 260) / 2,
|
|
258
|
+
y: f.y,
|
|
259
|
+
w: Math.max(f.w, 260),
|
|
260
|
+
h: f.h + 36
|
|
261
|
+
} : f,
|
|
262
|
+
posterRect: f,
|
|
263
|
+
media: s,
|
|
264
|
+
objectUrl: o,
|
|
265
|
+
loadState: "loading",
|
|
266
|
+
detachListeners: () => {}
|
|
267
|
+
}, m = () => {
|
|
268
|
+
l || (p.loadState = "metadata");
|
|
269
|
+
}, h = () => {
|
|
270
|
+
l || (p.loadState = "ready");
|
|
271
|
+
}, g = () => {
|
|
272
|
+
l || (p.loadState = "error", d(z(e, s, "decode")));
|
|
273
|
+
};
|
|
274
|
+
s.addEventListener("loadedmetadata", m), s.addEventListener("canplay", h), s.addEventListener("error", g), p.detachListeners = () => {
|
|
275
|
+
s.removeEventListener("loadedmetadata", m), s.removeEventListener("canplay", h), s.removeEventListener("error", g);
|
|
276
|
+
}, c.push(p);
|
|
277
|
+
try {
|
|
278
|
+
s.load();
|
|
279
|
+
} catch (t) {
|
|
280
|
+
let n = z(e, s, "load", t);
|
|
281
|
+
throw u(), n;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
let f = null, p = null, m = () => {
|
|
285
|
+
r.setTransform(n.dpr, 0, 0, n.dpr, 0, 0);
|
|
286
|
+
let t = e.width / n.dpr, a = e.height / n.dpr;
|
|
287
|
+
r.drawImage(o, 0, 0, e.width, e.height, 0, 0, t, a);
|
|
288
|
+
for (let e of c) {
|
|
289
|
+
let t = e.media;
|
|
290
|
+
if (e.loadState !== "loading") {
|
|
291
|
+
if (e.loadState === "error") {
|
|
292
|
+
Ze(r, e.posterRect, "Media unavailable");
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (e.el.mediaKind === "video" && t.readyState >= 2) {
|
|
296
|
+
let { x: n, y: i, w: a, h: o } = e.posterRect;
|
|
297
|
+
r.drawImage(t, n, i, a, o);
|
|
298
|
+
}
|
|
299
|
+
if (e === p || v?.state === e) rt(r, e, t);
|
|
300
|
+
else if (t.paused) {
|
|
301
|
+
let { x: t, y: n, w: a, h: o } = e.posterRect;
|
|
302
|
+
i(r, t + a / 2, n + o / 2, a, o, "paused");
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}, h = () => {
|
|
307
|
+
l || (m(), f = requestAnimationFrame(h));
|
|
308
|
+
}, g = (t, r) => {
|
|
309
|
+
let i = e.getBoundingClientRect(), a = e.width / n.dpr, o = e.height / n.dpr;
|
|
310
|
+
return {
|
|
311
|
+
x: (t - i.left) / i.width * a,
|
|
312
|
+
y: (r - i.top) / i.height * o
|
|
313
|
+
};
|
|
314
|
+
}, _ = (e, t) => {
|
|
315
|
+
for (let n of c) {
|
|
316
|
+
let { x: r, y: i, w: a, h: o } = n.rect;
|
|
317
|
+
if (e < r || e > r + a || t < i || t > i + o) continue;
|
|
318
|
+
let s = H(n), c = s.y - 12, l = s.y + s.h + 8;
|
|
319
|
+
return (Number.isFinite(n.media.duration) ? n.media.duration : 0) > 0 && e >= s.x && e <= s.x + s.w && t >= c && t <= l ? {
|
|
320
|
+
kind: "seek",
|
|
321
|
+
state: n,
|
|
322
|
+
fraction: Math.max(0, Math.min(1, (e - s.x) / s.w))
|
|
323
|
+
} : {
|
|
324
|
+
kind: "toggle",
|
|
325
|
+
state: n
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}, v = null, y = (e, t) => {
|
|
330
|
+
let n = Number.isFinite(e.media.duration) ? e.media.duration : 0;
|
|
331
|
+
n <= 0 || (e.media.currentTime = n * t);
|
|
332
|
+
}, b = (e) => {
|
|
333
|
+
try {
|
|
334
|
+
e.media.play().catch((t) => {
|
|
335
|
+
d(z(e.el, e.media, "play", t));
|
|
336
|
+
});
|
|
337
|
+
} catch (t) {
|
|
338
|
+
d(z(e.el, e.media, "play", t));
|
|
339
|
+
}
|
|
340
|
+
}, x = (t) => {
|
|
341
|
+
let { x: n, y: r } = g(t.clientX, t.clientY), i = _(n, r);
|
|
342
|
+
i && (i.kind === "seek" ? (v = {
|
|
343
|
+
state: i.state,
|
|
344
|
+
wasPlaying: !i.state.media.paused
|
|
345
|
+
}, i.state.media.pause(), y(i.state, i.fraction), e.setPointerCapture(t.pointerId), t.preventDefault()) : i.state.media.paused ? b(i.state) : i.state.media.pause());
|
|
346
|
+
}, S = (e) => {
|
|
347
|
+
let { x: t, y: n } = g(e.clientX, e.clientY);
|
|
348
|
+
p = null;
|
|
349
|
+
for (let e of c) {
|
|
350
|
+
let { x: r, y: i, w: a, h: o } = e.rect;
|
|
351
|
+
if (t >= r && t <= r + a && n >= i && n <= i + o) {
|
|
352
|
+
p = e;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (v) {
|
|
357
|
+
let e = H(v.state), n = Math.max(0, Math.min(1, (t - e.x) / e.w));
|
|
358
|
+
y(v.state, n);
|
|
359
|
+
}
|
|
360
|
+
}, C = () => {
|
|
361
|
+
p = null;
|
|
362
|
+
}, w = (t) => {
|
|
363
|
+
if (!v) return;
|
|
364
|
+
let { wasPlaying: n, state: r } = v;
|
|
365
|
+
v = null, e.releasePointerCapture(t.pointerId), n && b(r);
|
|
366
|
+
};
|
|
367
|
+
return c.length > 0 && (e.addEventListener("pointerdown", x), e.addEventListener("pointermove", S), e.addEventListener("pointerleave", C), e.addEventListener("pointerup", w), e.addEventListener("pointercancel", w), e.style.cursor = "pointer", h()), {
|
|
368
|
+
play(e) {
|
|
369
|
+
for (let t of c) (!e || t.el.mediaPath === e) && b(t);
|
|
370
|
+
},
|
|
371
|
+
pause(e) {
|
|
372
|
+
for (let t of c) (!e || t.el.mediaPath === e) && t.media.pause();
|
|
373
|
+
},
|
|
374
|
+
destroy() {
|
|
375
|
+
l || (l = !0, f !== null && cancelAnimationFrame(f), e.removeEventListener("pointerdown", x), e.removeEventListener("pointermove", S), e.removeEventListener("pointerleave", C), e.removeEventListener("pointerup", w), e.removeEventListener("pointercancel", w), e.style.cursor = "", u());
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
function Xe(e, t) {
|
|
380
|
+
return {
|
|
381
|
+
x: R(e.x, t),
|
|
382
|
+
y: R(e.y, t),
|
|
383
|
+
w: R(e.width, t),
|
|
384
|
+
h: R(e.height, t)
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function Ze(e, t, n) {
|
|
388
|
+
let r = Math.max(10, Math.min(14, t.h * .12));
|
|
389
|
+
e.save(), e.font = `500 ${r}px system-ui, -apple-system, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
|
|
390
|
+
let i = r + 12, a = Math.min(t.w, Math.max(100, e.measureText(n).width + 24));
|
|
391
|
+
U(e, t.x + (t.w - a) / 2, t.y + (t.h - i) / 2, a, i, i / 2), e.fillStyle = "rgba(20, 20, 20, 0.72)", e.fill(), e.fillStyle = "rgba(255, 255, 255, 0.95)", e.fillText(n, t.x + t.w / 2, t.y + t.h / 2), e.restore();
|
|
392
|
+
}
|
|
393
|
+
function Qe(e, t) {
|
|
394
|
+
return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} fetch failed for "${e.mediaPath}" (mime=${e.mimeType || "unknown"}): ${$e(t)}`);
|
|
395
|
+
}
|
|
396
|
+
function z(e, t, n, r) {
|
|
397
|
+
let i = "";
|
|
398
|
+
try {
|
|
399
|
+
i = e.mimeType ? t.canPlayType(e.mimeType) : "";
|
|
400
|
+
} catch {}
|
|
401
|
+
let a = t.error, o = [
|
|
402
|
+
`mime=${e.mimeType || "unknown"}`,
|
|
403
|
+
`canPlayType=${i || "no"}`,
|
|
404
|
+
`readyState=${t.readyState}`,
|
|
405
|
+
`networkState=${t.networkState}`
|
|
406
|
+
];
|
|
407
|
+
a && o.push(`mediaError=${a.code}${a.message ? ` ${a.message}` : ""}`);
|
|
408
|
+
let s = r === void 0 ? "" : `: ${$e(r)}`;
|
|
409
|
+
return /* @__PURE__ */ Error(`Embedded ${e.mediaKind} ${n} failed for "${e.mediaPath}" (${o.join("; ")})${s}`);
|
|
410
|
+
}
|
|
411
|
+
function $e(e) {
|
|
412
|
+
return e instanceof Error ? `${e.name || "Error"}${e.message ? `: ${e.message}` : ""}` : String(e);
|
|
413
|
+
}
|
|
414
|
+
var et = 28, B = 14, tt = 72, nt = 10, V = 3;
|
|
415
|
+
function rt(e, t, n) {
|
|
416
|
+
let r = Number.isFinite(n.duration) ? n.duration : 0, a = r > 0 ? Math.min(1, n.currentTime / r) : 0, o = t.posterRect;
|
|
417
|
+
i(e, o.x + o.w / 2, o.y + o.h / 2, o.w, o.h, n.paused ? "paused" : "playing"), t.el.mediaKind === "audio" ? at(e, t, n, r, a) : it(e, t, n, r, a);
|
|
418
|
+
}
|
|
419
|
+
function it(e, t, n, r, i) {
|
|
420
|
+
let { x: a, y: o, w: s, h: c } = t.rect, l = Math.max(28, Math.min(56, c * .22)), u = o + c - l;
|
|
421
|
+
e.save();
|
|
422
|
+
let d = e.createLinearGradient(0, u, 0, o + c);
|
|
423
|
+
d.addColorStop(0, "rgba(0, 0, 0, 0)"), d.addColorStop(1, "rgba(0, 0, 0, 0.55)"), e.fillStyle = d, e.fillRect(a, u, s, l), e.restore();
|
|
424
|
+
let f = H(t);
|
|
425
|
+
st(e, f, i, r > 0), e.save(), e.font = "500 11px system-ui, -apple-system, sans-serif", e.textBaseline = "middle", e.shadowColor = "rgba(0, 0, 0, 0.75)", e.shadowBlur = 3, e.fillStyle = "rgba(255, 255, 255, 0.95)", ot(e, n.currentTime, r, f.x, f.y - 10, "bottom"), e.restore();
|
|
426
|
+
}
|
|
427
|
+
function at(e, t, n, r, i) {
|
|
428
|
+
let a = ct(t.rect);
|
|
429
|
+
e.save(), U(e, a.x, a.y, a.w, a.h, a.h / 2), e.fillStyle = "rgba(20, 20, 20, 0.72)", e.fill(), e.font = "500 11px system-ui, -apple-system, sans-serif", e.textBaseline = "middle", e.fillStyle = "rgba(255, 255, 255, 0.95)", ot(e, n.currentTime, r, a.x + B, a.y + a.h / 2, "middle"), e.restore(), st(e, H(t), i, r > 0);
|
|
430
|
+
}
|
|
431
|
+
function ot(e, t, n, r, i, a) {
|
|
432
|
+
let o = lt(t), s = lt(n), c = Ke(e), l = qe(e, o, c), u = qe(e, s, c), d = e.measureText(" / ").width, f = Math.max(l, u);
|
|
433
|
+
Je(e, o, r + f - l, i, c);
|
|
434
|
+
let p = e.textAlign;
|
|
435
|
+
e.textAlign = "left", e.fillText(" / ", r + f, i), e.textAlign = p, Je(e, s, r + f + d, i, c);
|
|
436
|
+
}
|
|
437
|
+
function st(e, t, n, r) {
|
|
438
|
+
let i = t.h / 2;
|
|
439
|
+
if (e.save(), U(e, t.x, t.y, t.w, t.h, i), e.fillStyle = "rgba(255, 255, 255, 0.35)", e.fill(), n > 0 && (U(e, t.x, t.y, t.w * n, t.h, i), e.fillStyle = "#fff", e.fill()), r) {
|
|
440
|
+
let r = Math.max(t.x + 5, Math.min(t.x + t.w - 5, t.x + t.w * n));
|
|
441
|
+
e.shadowColor = "rgba(0, 0, 0, 0.3)", e.shadowBlur = 3, e.fillStyle = "#fff", e.beginPath(), e.arc(r, t.y + t.h / 2, 5, 0, Math.PI * 2), e.fill();
|
|
442
|
+
}
|
|
443
|
+
e.restore();
|
|
444
|
+
}
|
|
445
|
+
function ct(e) {
|
|
446
|
+
let t = Math.max(220, e.w - 24);
|
|
447
|
+
return {
|
|
448
|
+
x: e.x + e.w / 2 - t / 2,
|
|
449
|
+
y: e.y + e.h - et - 4,
|
|
450
|
+
w: t,
|
|
451
|
+
h: et
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function H(e) {
|
|
455
|
+
if (e.el.mediaKind === "audio") {
|
|
456
|
+
let t = ct(e.rect), n = t.x + B + tt + nt, r = Math.max(40, t.x + t.w - B - n);
|
|
457
|
+
return {
|
|
458
|
+
x: n,
|
|
459
|
+
y: t.y + (t.h - V) / 2,
|
|
460
|
+
w: r,
|
|
461
|
+
h: V
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
let t = e.rect, n = Math.max(12, t.w * .025), r = Math.max(12, Math.min(18, t.h * .05));
|
|
465
|
+
return {
|
|
466
|
+
x: t.x + n,
|
|
467
|
+
y: t.y + t.h - V - r,
|
|
468
|
+
w: t.w - n * 2,
|
|
469
|
+
h: V
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function U(e, t, n, r, i, a) {
|
|
473
|
+
let o = Math.min(a, i / 2, r / 2);
|
|
474
|
+
e.beginPath(), e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
|
|
475
|
+
}
|
|
476
|
+
function lt(e) {
|
|
477
|
+
if (!Number.isFinite(e) || e < 0) return "0:00";
|
|
478
|
+
let t = Math.floor(e);
|
|
479
|
+
return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region packages/pptx/src/slide-nav.ts
|
|
483
|
+
function ut(e) {
|
|
484
|
+
let t = /* @__PURE__ */ new Map();
|
|
485
|
+
for (let n = 0; n < e.length; n++) {
|
|
486
|
+
let r = e[n];
|
|
487
|
+
r !== void 0 && r !== "" && !t.has(r) && t.set(r, n);
|
|
488
|
+
}
|
|
489
|
+
return t;
|
|
490
|
+
}
|
|
491
|
+
function dt(e, t) {
|
|
492
|
+
if (e === "") return;
|
|
493
|
+
let n = Le("ppt/slides", e);
|
|
494
|
+
return t.get(n);
|
|
495
|
+
}
|
|
496
|
+
function ft(e, t, n) {
|
|
497
|
+
let r = Re(e);
|
|
498
|
+
return r === null ? dt(e, t) : ze(r, n, t.size);
|
|
499
|
+
}
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region packages/pptx/src/slide-repository.ts
|
|
502
|
+
var pt = class {
|
|
503
|
+
#e;
|
|
504
|
+
#t;
|
|
505
|
+
#n;
|
|
506
|
+
#r = 0;
|
|
507
|
+
#i = Promise.resolve();
|
|
508
|
+
#a;
|
|
509
|
+
#o;
|
|
510
|
+
constructor(e) {
|
|
511
|
+
if (!Number.isSafeInteger(e.slideCount) || e.slideCount < 0) throw TypeError("slideCount must be a non-negative safe integer");
|
|
512
|
+
this.#e = e.slideCount, this.#t = e.loadSlide, this.#n = new we({
|
|
513
|
+
maxEntries: e.maxCachedSlides,
|
|
514
|
+
maxWeight: e.maxCachedStructuralBytes,
|
|
515
|
+
measure: (e) => Ne(e).jsonBytes
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
get slideCount() {
|
|
519
|
+
return this.#e;
|
|
520
|
+
}
|
|
521
|
+
get usage() {
|
|
522
|
+
return this.#n.usage;
|
|
523
|
+
}
|
|
524
|
+
withSlide(e, t) {
|
|
525
|
+
this.#c(e);
|
|
526
|
+
let n = this.#r, r = this.#i.then(async () => {
|
|
527
|
+
if (n !== this.#r) throw this.#a ? this.#a : Error("PPTX slide repository generation is stale");
|
|
528
|
+
if (this.#a) throw this.#a;
|
|
529
|
+
let r = await this.#s(e, n);
|
|
530
|
+
try {
|
|
531
|
+
return await t(r);
|
|
532
|
+
} catch (e) {
|
|
533
|
+
let t = mt(e);
|
|
534
|
+
throw t ? (this.#l(t, n), this.#o === n ? this.#a ?? t : t) : e;
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
return this.#i = r.then(() => void 0, () => void 0), r;
|
|
538
|
+
}
|
|
539
|
+
async #s(e, t) {
|
|
540
|
+
return this.#n.getOrLoad(e, async () => {
|
|
541
|
+
let n;
|
|
542
|
+
try {
|
|
543
|
+
n = await this.#t(e);
|
|
544
|
+
} catch (e) {
|
|
545
|
+
let n = mt(e);
|
|
546
|
+
throw n ? (this.#l(n, t), this.#o === t ? this.#a ?? n : n) : e;
|
|
547
|
+
}
|
|
548
|
+
if (this.#o === t && this.#a) throw this.#a;
|
|
549
|
+
return n;
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
clear() {
|
|
553
|
+
this.#r += 1, this.#a = void 0, this.#o = void 0, this.#n.clear();
|
|
554
|
+
}
|
|
555
|
+
#c(e) {
|
|
556
|
+
if (!Number.isSafeInteger(e) || e < 0 || e >= this.#e) throw RangeError(`Slide index ${e} out of range (count: ${this.#e})`);
|
|
557
|
+
}
|
|
558
|
+
#l(e, t) {
|
|
559
|
+
t !== this.#r || this.#a || (this.#a = e, this.#o = t, this.#r += 1, this.#n.clear());
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
function mt(e) {
|
|
563
|
+
return e instanceof h ? e : m(e);
|
|
564
|
+
}
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region packages/pptx/src/embedded-fonts.ts
|
|
567
|
+
var ht = 1;
|
|
568
|
+
function W(e) {
|
|
569
|
+
return e.trim().toLowerCase();
|
|
570
|
+
}
|
|
571
|
+
async function gt(e, t) {
|
|
572
|
+
if (e.length === 0) return {
|
|
573
|
+
faces: [],
|
|
574
|
+
aliases: /* @__PURE__ */ new Map(),
|
|
575
|
+
authoredFamilies: /* @__PURE__ */ new Map()
|
|
576
|
+
};
|
|
577
|
+
let n = ht++, r = /* @__PURE__ */ new Map();
|
|
578
|
+
for (let t of e) {
|
|
579
|
+
let e = W(t.fontName);
|
|
580
|
+
r.has(e) || r.set(e, `__ooxml_pptx_${n}_${r.size + 1}`);
|
|
581
|
+
}
|
|
582
|
+
let i = [], a = /* @__PURE__ */ new Set();
|
|
583
|
+
for (let n = 0; n < e.length; n += 2) {
|
|
584
|
+
let o = (await Promise.all(e.slice(n, n + 2).map(async (e) => {
|
|
585
|
+
try {
|
|
586
|
+
return {
|
|
587
|
+
family: r.get(W(e.fontName)),
|
|
588
|
+
bytes: await t(e.partPath),
|
|
589
|
+
odttf: !1,
|
|
590
|
+
weight: e.style === "bold" || e.style === "boldItalic" ? "bold" : "normal",
|
|
591
|
+
style: e.style === "italic" || e.style === "boldItalic" ? "italic" : "normal"
|
|
592
|
+
};
|
|
593
|
+
} catch {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
}))).filter((e) => e !== null);
|
|
597
|
+
if (o.length !== 0) for (let e of await Ee(o)) a.has(e) ? j([e]) : (a.add(e), i.push(e));
|
|
598
|
+
}
|
|
599
|
+
let o = new Set(i.map((e) => W(e.family))), s = new Map([...r].filter(([, e]) => o.has(W(e))));
|
|
600
|
+
return {
|
|
601
|
+
faces: i,
|
|
602
|
+
aliases: s,
|
|
603
|
+
authoredFamilies: new Map([...s].map(([e, t]) => [t, e]))
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function _t(e, t) {
|
|
607
|
+
return e.filter((e) => e === null || !t.has(e.trim().toLowerCase()));
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region packages/pptx/src/worker.ts?worker&inline
|
|
611
|
+
var vt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},n=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};const r=67108864,i=`https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap`,a=`https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap`,o=`https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap`,s={calibri:{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},\"calibri light\":{url:`https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Carlito`},cambria:{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"cambria math\":{url:`https://fonts.googleapis.com/css2?family=Caladea:ital,wght@0,400;0,700;1,400;1,700&display=swap`,loadFamily:`Caladea`},\"franklin gothic book\":{url:o,loadFamily:`Libre Franklin`},\"franklin gothic medium\":{url:o,loadFamily:`Libre Franklin`},\"nunito sans\":{url:`https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},nunito:{url:`https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"open sans\":{url:`https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap`},roboto:{url:`https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap`},lato:{url:`https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap`},montserrat:{url:`https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;1,400;1,700&display=swap`},poppins:{url:`https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap`},raleway:{url:`https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"playfair display\":{url:`https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap`},ubuntu:{url:`https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,400;0,700;1,400;1,700&display=swap`},\"sakkal majalla\":{url:i,loadFamily:`Noto Naskh Arabic`},\"traditional arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"simplified arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"arabic typesetting\":{url:i,loadFamily:`Noto Naskh Arabic`},\"univers next arabic\":{url:a,loadFamily:`Noto Sans Arabic`},\"noto naskh arabic\":{url:i,loadFamily:`Noto Naskh Arabic`},\"noto sans arabic\":{url:a,loadFamily:`Noto Sans Arabic`}};function c(e){if(!e)return null;let t=e.toLowerCase();return/[ᄀ-ᇿ-가-]/.test(e)?`kr`:/[-ヿ]/.test(e)?`jp`:/jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\\s*liu/.test(t)||/新細明體|細明體|標楷體|微軟正黑體|華康/.test(e)?`tc`:/simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(t)||/宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(e)?`sc`:/malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(t)?`kr`:/\\bmeiryo\\b|\\byu\\s*(gothic|mincho)\\b|yugothic|yumincho|hiragino|\\bms\\s*(gothic|mincho|pgothic|pmincho|ui\\s*gothic)\\b|\\bms[pg]?(gothic|mincho)\\b|ipa(ex)?(gothic|mincho)|noto\\s+(sans|serif)\\s+jp|游ゴシック|游明朝|MS|メイリオ|ヒラギノ/.test(t)||/游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(e)?`jp`:null}const l=e=>`https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`,ee={\"noto sans kr\":{url:l(`Noto+Sans+KR`)},\"noto sans sc\":{url:l(`Noto+Sans+SC`)},\"noto sans tc\":{url:l(`Noto+Sans+TC`)},\"noto sans jp\":{url:l(`Noto+Sans+JP`)},\"noto serif kr\":{url:l(`Noto+Serif+KR`)},\"noto serif sc\":{url:l(`Noto+Serif+SC`)},\"noto serif tc\":{url:l(`Noto+Serif+TC`)},\"noto serif jp\":{url:l(`Noto+Serif+JP`)},\"noto sans\":{url:l(`Noto+Sans`)},\"noto serif\":{url:l(`Noto+Serif`)},\"noto sans devanagari\":{url:l(`Noto+Sans+Devanagari`)},\"noto sans thai\":{url:l(`Noto+Sans+Thai`)},\"noto sans hebrew\":{url:l(`Noto+Sans+Hebrew`)},\"noto serif hebrew\":{url:l(`Noto+Serif+Hebrew`)}};var u=class e{hasHan=!1;hasHangul=!1;hasKana=!1;hasArabic=!1;hasThai=!1;hasHebrew=!1;hasDevanagari=!1;hasCyrGreek=!1;constructor(e){this.cjkLang=e}clone(){let t=new e(this.cjkLang);return t.hasHan=this.hasHan,t.hasHangul=this.hasHangul,t.hasKana=this.hasKana,t.hasArabic=this.hasArabic,t.hasThai=this.hasThai,t.hasHebrew=this.hasHebrew,t.hasDevanagari=this.hasDevanagari,t.hasCyrGreek=this.hasCyrGreek,t}addText(e){let t=()=>this.hasHan&&this.hasHangul&&this.hasKana&&this.hasArabic&&this.hasThai&&this.hasHebrew&&this.hasDevanagari&&this.hasCyrGreek;outer:for(let n of e)if(n)for(let e of n){let n=e.codePointAt(0);if(n!==void 0&&!(n<=591)&&(n>=4352&&n<=4607||n>=12592&&n<=12687||n>=44032&&n<=55215?this.hasHangul=!0:n>=12352&&n<=12543?this.hasKana=!0:n>=13312&&n<=19903||n>=19968&&n<=40959||n>=63744&&n<=64255||n>=131072&&n<=195103?this.hasHan=!0:n>=1536&&n<=1791||n>=1872&&n<=1919||n>=2208&&n<=2303||n>=64336&&n<=65023||n>=65136&&n<=65279?this.hasArabic=!0:n>=3584&&n<=3711?this.hasThai=!0:n>=1424&&n<=1535||n>=64285&&n<=64335?this.hasHebrew=!0:n>=2304&&n<=2431?this.hasDevanagari=!0:(n>=1024&&n<=1279||n>=880&&n<=1023)&&(this.hasCyrGreek=!0),t()))break outer}}names(){let e=[],t=new Set;this.hasHangul&&t.add(`kr`),this.hasKana&&t.add(`jp`),this.hasHan&&t.size===0&&t.add(this.cjkLang??`jp`);for(let n of[`kr`,`sc`,`tc`,`jp`])if(t.has(n)){let t={kr:`KR`,sc:`SC`,tc:`TC`,jp:`JP`}[n];e.push(`Noto Sans ${t}`,`Noto Serif ${t}`)}return this.hasCyrGreek&&e.push(`Noto Sans`,`Noto Serif`),this.hasArabic&&e.push(`Noto Naskh Arabic`,`Noto Sans Arabic`),this.hasThai&&e.push(`Noto Sans Thai`),this.hasHebrew&&e.push(`Noto Sans Hebrew`,`Noto Serif Hebrew`),this.hasDevanagari&&e.push(`Noto Sans Devanagari`),e}},d,f,te=e((()=>{d=1<<25,d*4,f=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function ne(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var re=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},ie=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ae(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function oe(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function se(e,t){return e({module_or_path:t})}var ce=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new re(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),le),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new ie(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):se(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,oe(e)}};function le(e){return ae(e)?new ie(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function ue(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function de(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return ue(t.requiredBytes)&&ue(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var p=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function fe(e){if(e instanceof p)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!de(r)))return new p(r)}function pe(e,t,n){let r=fe(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}te();const me=`OOXML_RESOURCE_LIMIT:`;function m(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function he(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return m(t.archiveEntryCount)&&m(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||m(t.largestInflatedEntryBytes))&&m(t.distinctInflatedBytes)&&m(t.operationInflatedBytes)}function ge(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!he(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function _e(e){return e===`docx`||e===`xlsx`||e===`pptx`}function ve(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function h(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function g(e){return h(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function ye(e){return!h(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const _=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),be=new Set([..._.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),xe=new Set([..._.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function Se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!_e(t.format)||!h(t.operation,256)||!g(t.resource)||!g(t.metric)||!m(t.limit)||!m(t.observed)||typeof t.configurable!=`boolean`||!he(t.usage)?!1:!(`part`in t)||ye(t.part)}function v(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!ve(t.stage)||!Se(t.violation))return!1;let n=t.violation,r=_.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(be.has(n.resource)&&xe.has(n.metric))}function Ce(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function we(e){if(!v(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:Ce(t.usage)}};return v(n)?n:void 0}function Te(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function Ee(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(me))return;let r;try{r=JSON.parse(t.slice(21))}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(!(i.code!==`ooxml-resource-limit`||!v(i.details)))return new n(Te(i.details),i.details)}function De(e){if(e instanceof f)return{message:e.message,errorName:e.name,code:e.code,decodedImage:{metric:e.metric,limit:e.limit,observed:e.observed}};let r=fe(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof t||e instanceof n?e:Ee(e);if(i instanceof n){let e=we(i.details);return e?{message:typeof i.message==`string`?i.message:Te(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof t)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:h(i.name,128)?i.name:`OoxmlError`,...g(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(me))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:h(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function y(e){try{return De(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}const Oe=new Set([`encrypted`,`invalid-password`,`unsupported-encryption`,`legacy-binary-format`,`not-ooxml`]);function ke(e){if(e.code===`ooxml-decoded-image-limit`&&e.decodedImage&&(e.decodedImage.metric===`image-pixels`||e.decodedImage.metric===`active-decoded-bytes`)&&m(e.decodedImage.limit)&&m(e.decodedImage.observed)&&e.decodedImage.observed>e.decodedImage.limit)return new f(e.decodedImage.metric,e.decodedImage.limit,e.decodedImage.observed);if(e.code===`ooxml-insufficient-credit`&&de(e.insufficientCredit))return new p(e.insufficientCredit);if(e.code===`ooxml-resource-limit`&&v(e.resourceLimit))return new n(e.message,e.resourceLimit);if(e.code&&Oe.has(e.code))return new t(e.code,e.message);let r=e.errorName===`TypeError`?TypeError(e.message):e.errorName===`RangeError`?RangeError(e.message):Error(e.message);return e.errorName&&(r.name=e.errorName),e.code!==void 0&&Object.assign(r,{code:e.code}),r}function Ae(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function je(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const b=`ooxml-pull-v1`;function x(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Me(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var S=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,x(this.maxRetainedBytes,`max retained lease bytes`),x(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ne=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Me(e.sessionId),x(e.operationId,`operation id`),x(e.generation,`generation`),x(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&x(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=y(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(x(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:b,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){x(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(x(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:b,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:b,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};function C(e,t){if(!Number.isSafeInteger(e)||e<0)throw Error(`${t} must be a non-negative safe integer`)}function w(e,t,n){return C(e,`resource measurement`),C(t,`resource measurement`),C(n,`resource measurement limit`),e>n||t>n||t>n-e?n===2**53-1?n:n+1:e+t}function Pe(e,t=2**53-1){C(t,`resource measurement limit`);let n=0;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=3}else a=3;if(n=w(n,a,t),n>t)return n}return n}function T(e,t=2**53-1){C(t,`resource measurement limit`);let n=w(0,2,t);if(n>t)return n;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r),a;if(i===34||i===92||i===8||i===9||i===10||i===12||i===13)a=2;else if(i<=31)a=6;else if(i<=127)a=1;else if(i<=2047)a=2;else if(i>=55296&&i<=56319&&r+1<e.length){let t=e.charCodeAt(r+1);t>=56320&&t<=57343?(a=4,r+=1):a=6}else a=i>=55296&&i<=57343?6:3;if(n=w(n,a,t),n>t)return n}return n}function E(e,t){return w(0,e,t)}function D(e,t=2**53-1,n=!1){if(C(t,`resource measurement limit`),e===null)return{jsonBytes:E(4,t),stringValueUtf8Bytes:0};if(typeof e==`string`)return{jsonBytes:T(e,t),stringValueUtf8Bytes:Pe(e,t)};if(typeof e==`boolean`)return{jsonBytes:E(e?4:5,t),stringValueUtf8Bytes:0};if(typeof e==`number`)return{jsonBytes:E((Number.isFinite(e)?String(Object.is(e,-0)?0:e):`null`).length,t),stringValueUtf8Bytes:0};if(typeof e==`bigint`)throw TypeError(`BigInt values cannot be serialized to JSON`);if(Array.isArray(e)){let n=E(2,t),r=0;for(let i=0;i<e.length;i+=1){i!==0&&(n=w(n,1,t));let a=D(e[i],t,!0);n=w(n,a.jsonBytes,t),r=w(r,a.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}if(typeof e==`object`){let n=E(2,t),r=0,i=0;for(let[a,o]of Object.entries(e)){if(o===void 0||typeof o==`function`||typeof o==`symbol`)continue;i++!==0&&(n=w(n,1,t)),n=w(n,T(a,t),t),n=w(n,1,t);let e=D(o,t);n=w(n,e.jsonBytes,t),r=w(r,e.stringValueUtf8Bytes,t)}return{jsonBytes:n,stringValueUtf8Bytes:r}}return{jsonBytes:n?E(4,t):0,stringValueUtf8Bytes:0}}({...s,...ee});function*Fe(e){for(let t of e?.paragraphs??[])for(let e of t.runs)e.type===`text`&&(yield e.text)}function*Ie(e){for(let t of e?.paragraphs??[]){t.defFontFamily&&(yield t.defFontFamily);for(let e of t.runs)e.type===`text`&&(e.fontFamily&&(yield e.fontFamily),e.fontFamilyEa&&(yield e.fontFamilyEa),e.fontFamilySym&&(yield e.fontFamilySym))}}function*Le(e){for(let t of e.elements)if(t.type===`shape`)yield*Fe(t.textBody);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)yield*Fe(t.textBody);else if(t.type===`chart`){t.chart.title&&(yield t.chart.title);for(let e of t.chart.categories)yield e;for(let e of t.chart.series)e.name&&(yield e.name)}}var Re=class e{scripts;families;constructor(e,t,n,r){this.majorFont=e,this.minorFont=t;let i=c(e)??c(t)??null;this.scripts=n??new u(i),this.families=r??new Set,e&&this.families.add(e),t&&this.families.add(t)}addSlide(e){this.scripts.addText(Le(e));for(let t of e.elements)if(t.type===`shape`)for(let e of Ie(t.textBody))this.families.add(e);else if(t.type===`table`)for(let e of t.rows)for(let t of e.cells)for(let e of Ie(t.textBody))this.families.add(e)}names(){return[...this.families,...this.scripts.names()]}withSlide(t){let n=new e(this.majorFont,this.minorFont,this.scripts.clone(),new Set(this.families));return n.addSlide(t),n}};const O=Object.freeze({archiveEntryCount:0,declaredInflatedBytes:0,distinctInflatedBytes:0,operationInflatedBytes:0}),k=67108864;function A(e,t){if(e!==null&&typeof e!=`string`)throw Error(`invalid PPTX presentation bootstrap ${t}`)}function ze(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap slide at ${t}`);let n=e;if(n.index!==t)throw Error(`invalid PPTX presentation bootstrap slide index ${n.index}`);if(n.partName!==void 0&&typeof n.partName!=`string`)throw Error(`invalid PPTX presentation bootstrap slide partName at ${t}`);return Object.freeze({index:n.index,...n.partName===void 0?{}:{partName:n.partName}})}function Be(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap embedded font at ${t}`);let n=e;if(typeof n.fontName!=`string`||n.fontName.length===0||![`regular`,`bold`,`italic`,`boldItalic`].includes(n.style??``)||typeof n.partPath!=`string`||n.partPath.length===0||n.partPath.startsWith(`/`)||n.partPath.split(`/`).includes(`..`)||![`application/x-font-ttf`,`application/x-fontdata`].includes(n.contentType??``))throw Error(`invalid PPTX presentation bootstrap embedded font fields at ${t}`);return Object.freeze({fontName:n.fontName,style:n.style,partPath:n.partPath,contentType:n.contentType})}function Ve(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`invalid PPTX presentation bootstrap payload`);let t=e;if(!Number.isSafeInteger(t.slideCount)||(t.slideCount??-1)<0||!Number.isSafeInteger(t.slideWidth)||(t.slideWidth??0)<=0||!Number.isSafeInteger(t.slideHeight)||(t.slideHeight??0)<=0||!Array.isArray(t.embeddedFonts)||!Array.isArray(t.slides)||t.slides.length!==t.slideCount)throw Error(`invalid PPTX presentation bootstrap dimensions or slide count`);return A(t.defaultTextColor,`defaultTextColor`),A(t.majorFont,`majorFont`),A(t.minorFont,`minorFont`),A(t.hlinkColor,`hlinkColor`),A(t.folHlinkColor,`folHlinkColor`),Object.freeze({slideCount:t.slideCount,slideWidth:t.slideWidth,slideHeight:t.slideHeight,defaultTextColor:t.defaultTextColor,majorFont:t.majorFont,minorFont:t.minorFont,hlinkColor:t.hlinkColor,folHlinkColor:t.folHlinkColor,embeddedFonts:Object.freeze(t.embeddedFonts.map(Be)),slides:Object.freeze(t.slides.map(ze))})}function He(e){return Object.freeze({type:`media`,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation,flipH:e.flipH,flipV:e.flipV,mediaKind:e.mediaKind,posterPath:e.posterPath,posterMimeType:e.posterMimeType,mediaPath:e.mediaPath,mimeType:e.mimeType})}function Ue(e){return Object.freeze({...e.id===void 0?{}:{id:e.id},...e.authorId===void 0?{}:{authorId:e.authorId},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.status===void 0?{}:{status:e.status},text:e.text})}function We(e){return Object.freeze({...e})}function Ge(e){return Object.freeze({...e.authorId===void 0?{}:{authorId:e.authorId},...e.modernAuthorId===void 0?{}:{modernAuthorId:e.modernAuthorId},...e.id===void 0?{}:{id:e.id},...e.index===void 0?{}:{index:e.index},...e.author===void 0?{}:{author:e.author},...e.date===void 0?{}:{date:e.date},...e.x===void 0?{}:{x:e.x},...e.y===void 0?{}:{y:e.y},...e.anchors?.length?{anchors:Object.freeze(e.anchors.map(We))}:{},...e.status===void 0?{}:{status:e.status},text:e.text,...e.replies?.length?{replies:Object.freeze(e.replies.map(Ue))}:{}})}function Ke(e,t){if(e.index!==t.index||e.partName!==t.partName)throw Error(`PPTX pulled slide identity does not match bootstrap index ${t.index}`);return Object.freeze({index:t.index,...t.partName===void 0?{}:{partName:t.partName},notes:e.notes??null,hidden:e.hidden??!1,mediaElements:Object.freeze(e.elements.filter(e=>e.type===`media`).map(He)),...e.comments?.length?{comments:Object.freeze(e.comments.map(Ge))}:{}})}function j(e,t,r){if(!(e<=t))throw new n(`PPTX presentation preflight exceeded its hard limit of ${t} projected bytes`,{stage:`parsing`,violation:{format:`pptx`,operation:`presentation-preflight`,resource:`presentation-preflight`,metric:`projected-bytes`,limit:t,observed:Math.min(e,t+1),configurable:!1,usage:r}})}var qe=class{slideCountValue;slideWidthValue;slideHeightValue;defaultTextColorValue;majorFontValue;minorFontValue;hlinkColorValue;folHlinkColorValue;embeddedFontsValue;descriptors;slides=[];fonts;fontPreloadNames;fontProjectionBytes;projectionBytesValue;limit;pending=null;finished=null;constructor(e,t={}){let n=Ve(e),r=t.hardLimitForTesting??k;if(!Number.isSafeInteger(r)||r<=0||r>k)throw Error(`invalid PPTX presentation preflight test limit`);this.limit=r,this.slideCountValue=n.slideCount,this.slideWidthValue=n.slideWidth,this.slideHeightValue=n.slideHeight,this.defaultTextColorValue=n.defaultTextColor,this.majorFontValue=n.majorFont,this.minorFontValue=n.minorFont,this.hlinkColorValue=n.hlinkColor,this.folHlinkColorValue=n.folHlinkColor,this.embeddedFontsValue=n.embeddedFonts,this.descriptors=[...n.slides],this.fonts=new Re(this.majorFontValue,this.minorFontValue),this.fontPreloadNames=Object.freeze(this.fonts.names()),this.fontProjectionBytes=D(this.fontPreloadNames,this.limit).jsonBytes,this.projectionBytesValue=D({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,remainingSlides:this.descriptors,slides:[],fontPreloadNames:this.fontPreloadNames},this.limit).jsonBytes,j(this.projectionBytesValue,this.limit,O)}get acceptedSlideCount(){return this.finished?.slideCount??this.slides.length}get projectedBytes(){return this.projectionBytesValue}get remainingDescriptorCount(){return this.descriptors.reduce((e,t)=>e+Number(t!==void 0),0)}get latestSlide(){return this.slides[this.slides.length-1]}get currentFontPreloadNames(){return this.fontPreloadNames}snapshot(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);return Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames})}addSlide(e,t=O){this.prepareSlide(e,t).commit()}prepareSlide(e,t=O){if(this.finished)throw Error(`PPTX presentation preflight is already finished`);if(this.pending)throw Error(`PPTX presentation preflight already has a prepared slide`);let n=this.slides.length,r=this.descriptors[n];if(!r)throw Error(`PPTX presentation preflight received an extra slide`);let i=Ke(e,r),a=this.fonts.withSlide(e),o=Object.freeze(a.names()),s=D(o,this.limit).jsonBytes,c=D(i,this.limit).jsonBytes,l=this.projectionBytesValue-this.fontProjectionBytes-D(r,this.limit).jsonBytes+4;l=w(l,s,this.limit),l=w(l,c,this.limit),this.slides.length!==0&&(l=w(l,1,this.limit));let ee=D({slide:i,fontPreloadNames:o},this.limit).jsonBytes,u=w(this.projectionBytesValue,ee,this.limit);j(Math.max(u,l),this.limit,t);let d={state:`prepared`,fact:i,fonts:a,fontNames:o,fontBytes:s,committedBytes:l};return this.pending=d,{projectedBytes:u,commit:()=>{if(d.state!==`committed`){if(d.state===`rolled-back`)throw Error(`PPTX presentation preflight cannot commit a rolled-back slide`);if(this.pending!==d)throw Error(`PPTX presentation preflight prepared slide is stale`);this.descriptors[n]=void 0,this.slides.push(d.fact),this.fonts=d.fonts,this.fontPreloadNames=d.fontNames,this.fontProjectionBytes=d.fontBytes,this.projectionBytesValue=d.committedBytes,d.state=`committed`,this.pending=null}},rollback:()=>{if(d.state!==`rolled-back`){if(d.state===`committed`)throw Error(`PPTX presentation preflight cannot roll back a committed slide`);if(this.pending!==d)throw Error(`PPTX presentation preflight prepared slide is stale`);d.state=`rolled-back`,this.pending=null}}}}finish(){if(this.finished)return this.finished;if(this.pending)throw Error(`PPTX presentation preflight has an uncommitted slide`);if(this.slides.length!==this.slideCountValue)throw Error(`PPTX presentation preflight is incomplete: ${this.slides.length}/${this.slideCountValue} slides`);return this.finished=Object.freeze({slideCount:this.slideCountValue,slideWidth:this.slideWidthValue,slideHeight:this.slideHeightValue,defaultTextColor:this.defaultTextColorValue,majorFont:this.majorFontValue,minorFont:this.minorFontValue,hlinkColor:this.hlinkColorValue,folHlinkColor:this.folHlinkColorValue,embeddedFonts:this.embeddedFontsValue,slides:Object.freeze([...this.slides]),fontPreloadNames:this.fontPreloadNames}),this.descriptors=[],this.slides=[],this.projectionBytesValue=D(this.finished,this.limit).jsonBytes,this.finished}};function M(e){try{return ge(e(e=>e.slide_cursor_resource_usage()))}catch(e){if(String(e).includes(`slide cursor usage is unavailable`))return;throw e}}function Je(e,t,n,r,i){let a,o;try{if(i){if(!r)throw Error(`slide payload is missing before acknowledgement`);let t=i(n,r,M(e));typeof t==`function`?a=t:t&&({rollback:a,commit:o}=t)}e(e=>e.acknowledge_slide(t.operationId,t.generation)),o?.()}catch(e){try{a?.()}catch{}throw e}}var Ye=class{coordinatorGeneration=new S;sessions=new Map;pendingOpens=new Map;operationTail=Promise.resolve();resourceFailure;lifecycleState=`ready`;resetBarrier;resetIdentities=new Map;constructor(e,t,n=e=>e(this.requireArchive())){this.archive=e,this.acceptSlide=t,this.executeArchive=n}get coordinator(){return this.coordinatorGeneration}reserveOpen(e){if(this.assertReady(),Ze(e),this.pendingOpens.has(e.sessionId)||this.sessions.has(e.sessionId))throw Error(`slide pull session id is already reserved`);this.pendingOpens.set(e.sessionId,{identity:e,canceled:!1})}abandonOpen(e){this.pendingOpens.delete(e)}get pendingOpenCount(){return this.pendingOpens.size}async open(e,t){if(this.assertReady(),this.resourceFailure)throw this.resourceFailure;if(!Number.isSafeInteger(e)||e<0)throw RangeError(`slide index must be a non-negative safe integer`);let n=this.pendingOpens.get(t.sessionId);if(!n||!N(n.identity,t))throw Error(`slide pull session open reservation is stale or missing`);let i,a=new Promise(e=>{i=e}),o=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(n.canceled)throw Error(`slide pull session open was canceled`);let a,o=!1,s=new Ne({...t,maxByteCredit:r,coordinator:this.coordinator,driver:{pull:n=>{let i;try{i=this.executeArchive(r=>r.pull_slide(e,t.operationId,t.generation,n))}catch(e){throw pe(e,n,r)||(this.latchResourceFailure(e),e)}let s=Ae(i);return this.acceptSlide&&(a=JSON.parse(new TextDecoder().decode(new Uint8Array(s)))),o=!0,{payload:s,byteLength:s.byteLength,done:!0,transfer:[s]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:()=>{if(!o)throw Error(`slide unit is not awaiting acknowledgement`);try{Je(this.executeArchive,t,e,a,this.acceptSlide)}catch(e){throw this.latchResourceFailure(e),e}o=!1,a=void 0,this.sessions.delete(t.sessionId),i()},cancel:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},close:async()=>{try{this.archive()&&await this.executeArchive(e=>e.cancel_slide())}finally{a=void 0,o=!1,this.sessions.delete(t.sessionId),i()}},resourceUsage:()=>{try{return this.readResourceUsage()}catch(e){throw this.latchResourceFailure(e),e}}}});this.sessions.set(t.sessionId,{host:s,identity:t}),this.pendingOpens.delete(t.sessionId)}));this.operationTail=o.then(()=>a,()=>void 0);try{await o}catch(e){throw this.pendingOpens.delete(t.sessionId),i(),e}}async postOpenedSafely(e,t,n){if(this.lifecycleState!==`ready`){try{n(this.lifecycleError())}catch{}return}try{t()}catch(t){await this.closeIdentity(e);try{n(t)}catch{}}}dispatch(e,t){if(this.lifecycleState!==`ready`)return t(this.responseDuringReset(e)),Promise.resolve();let n=this.sessions.get(e.sessionId);if(n)return n.host.dispatch(e,t);let r=this.pendingOpens.get(e.sessionId);if(r&&(e.kind===`cancel`||e.kind===`close`)){let n=N(r.identity,e);return n&&(r.canceled=!0),t(n?{protocol:b,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}:this.staleLifecycleResponse(e)),Promise.resolve()}return e.kind===`cancel`||e.kind===`close`?(t({protocol:b,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}),Promise.resolve()):(t({protocol:b,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:y(Error(`slide pull session is not open`))}),Promise.resolve())}async dispatchSafely(e,t){try{await this.dispatch(e,t)}catch(n){try{t({protocol:b,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:y(n)})}catch{}}}run(e){if(this.lifecycleState!==`ready`)return Promise.reject(this.lifecycleError());let t=this.operationTail.then(()=>this.coordinator.enqueue(async()=>{if(this.resourceFailure)throw this.resourceFailure;return e()})).catch(e=>{throw this.latchResourceFailure(e),e});return this.operationTail=t.then(()=>void 0,()=>void 0),t}reset(){if(this.resetBarrier)return this.resetBarrier;this.lifecycleState=`resetting`,this.captureResetIdentities();let e=this.performReset().then(()=>{this.resetIdentities.clear(),this.lifecycleState=`ready`},e=>{throw this.lifecycleState=`reset-failed`,e}).finally(()=>{this.resetBarrier===e&&(this.resetBarrier=void 0)});return this.resetBarrier=e,e}async performReset(){for(let e of this.pendingOpens.values())e.canceled=!0;let e=1;for(let{host:t,identity:n}of[...this.sessions.values()]){let r;if(await t.dispatch({protocol:b,kind:`close`,...n,requestId:e++},e=>{e.kind===`error`&&(r=ke(e.error))}),r)throw r}this.sessions.clear(),await this.operationTail,this.pendingOpens.clear(),this.archive()&&await this.executeArchive(e=>e.close_presentation_session()),this.coordinatorGeneration=new S,this.resourceFailure=void 0}assertReady(){if(this.lifecycleState!==`ready`)throw this.lifecycleError()}lifecycleError(){let e=this.lifecycleState===`reset-failed`,t=Error(e?`slide pull worker reset failed; retry reset before new work`:`slide pull worker reset is in progress`);return t.name=`PullSessionLifecycleError`,Object.assign(t,{code:e?`ooxml-pull-reset-failed`:`ooxml-pull-resetting`})}captureResetIdentities(){for(let{identity:e}of this.sessions.values())this.resetIdentities.set(e.sessionId,e);for(let{identity:e}of this.pendingOpens.values())this.resetIdentities.set(e.sessionId,e)}responseDuringReset(e){if(e.kind===`cancel`||e.kind===`close`){let t=this.resetIdentities.get(e.sessionId);return t&&!N(t,e)?this.staleLifecycleResponse(e):{protocol:b,kind:`accepted`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,command:e.kind}}return{protocol:b,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:y(this.lifecycleError())}}requireArchive(){let e=this.archive();if(!e)throw Error(`Presentation not loaded`);return e}async closeIdentity(e){if(this.lifecycleState!==`ready`)return;let t=this.sessions.get(e.sessionId);if(t){await t.host.dispatch({protocol:b,kind:`close`,...e,requestId:1},()=>void 0);return}let n=this.pendingOpens.get(e.sessionId);n&&N(n.identity,e)&&(n.canceled=!0)}readResourceUsage(){return M(this.executeArchive)}latchResourceFailure(e){let t=e instanceof n?e:Ee(e);t&&(this.resourceFailure??=t)}staleLifecycleResponse(e){return{protocol:b,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:{message:`stale lifecycle targets another slide operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`}}}};function Xe(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}function Ze(e){if(!Number.isSafeInteger(e.sessionId)||e.sessionId<=0)throw RangeError(`session id must be a positive safe integer`);if(!Number.isSafeInteger(e.operationId)||e.operationId<=0)throw RangeError(`operation id must be a positive safe integer`);if(!Number.isSafeInteger(e.generation)||e.generation<=0)throw RangeError(`generation must be a positive safe integer`)}function N(e,t){return e.sessionId===t.sessionId&&e.operationId===t.operationId&&e.generation===t.generation}var P=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,F.unregister(this),e}free(){let e=this.__destroy_into_raw();J.__wbg_pptxarchive_free(e,0)}acknowledge_slide(e,t){let n=J.pptxarchive_acknowledge_slide(this.__wbg_ptr,e,t);if(n[1])throw U(n[0])}assert_healthy(){let e=J.pptxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw U(e[0])}cancel_slide(){J.pptxarchive_cancel_slide(this.__wbg_ptr)}close_presentation_session(){J.pptxarchive_close_presentation_session(this.__wbg_ptr)}extract_font(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_font(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_image(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}extract_media(e){let t=H(e,J.__wbindgen_malloc,J.__wbindgen_realloc),n=q,r=J.pptxarchive_extract_media(this.__wbg_ptr,t,n);if(r[3])throw U(r[2]);var i=I(r[0],r[1]).slice();return J.__wbindgen_free(r[0],r[1]*1,1),i}constructor(e,t,n,r){let i=et(e,J.__wbindgen_malloc),a=q,o=J.pptxarchive_new(i,a,!V(t),V(t)?BigInt(0):t,!V(n),V(n)?BigInt(0):n,!V(r),V(r)?BigInt(0):r);if(o[2])throw U(o[1]);return this.__wbg_ptr=o[0]>>>0,F.register(this,this.__wbg_ptr,this),this}parse(){let e=J.pptxarchive_parse(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}presentation_bootstrap(){let e=J.pptxarchive_presentation_bootstrap(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}pull_slide(e,t,n,r){let i=J.pptxarchive_pull_slide(this.__wbg_ptr,e,t,n,r);if(i[3])throw U(i[2]);var a=I(i[0],i[1]).slice();return J.__wbindgen_free(i[0],i[1]*1,1),a}resource_usage(){let e=J.pptxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}slide_cursor_resource_usage(){let e=J.pptxarchive_slide_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw U(e[2]);var t=I(e[0],e[1]).slice();return J.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=J.pptxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,U(i[2]);return e=n,t=r,R(n,r)}finally{J.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);function Qe(){return{__proto__:null,\"./pptx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(R(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(R(e,t))}finally{J.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=H(n,J.__wbindgen_malloc,J.__wbindgen_realloc),i=q;$e().setInt32(e+4,i,!0),$e().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return R(e,t)},__wbindgen_init_externref_table:function(){let e=J.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const F=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>J.__wbg_pptxarchive_free(e>>>0,1));function I(e,t){return e>>>=0,B().subarray(e/1,e/1+t)}let L=null;function $e(){return(L===null||L.buffer.detached===!0||L.buffer.detached===void 0&&L.buffer!==J.memory.buffer)&&(L=new DataView(J.memory.buffer)),L}function R(e,t){return e>>>=0,tt(e,t)}let z=null;function B(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(J.memory.buffer)),z}function V(e){return e==null}function et(e,t){let n=t(e.length*1,1)>>>0;return B().set(e,n/1),q=e.length,n}function H(e,t,n){if(n===void 0){let n=K.encode(e),r=t(n.length,1)>>>0;return B().subarray(r,r+n.length).set(n),q=n.length,r}let r=e.length,i=t(r,1)>>>0,a=B(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=B().subarray(i+o,i+r),a=K.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return q=o,i}function U(e){let t=J.__wbindgen_externrefs.get(e);return J.__externref_table_dealloc(e),t}let W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});W.decode();let G=0;function tt(e,t){return G+=t,G>=2146435072&&(W=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),W.decode(),G=t),W.decode(B().subarray(e,e+t))}const K=new TextEncoder;`encodeInto`in K||(K.encodeInto=function(e,t){let n=K.encode(e);return t.set(n),{read:e.length,written:n.length}});let q=0,J;function nt(e,t){return J=e.exports,L=null,z=null,J.__wbindgen_start(),J}async function rt(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function it(e){if(J!==void 0)return J;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=Qe();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await rt(await e,t);return nt(n,r)}async function at(e){return J=void 0,L=null,z=null,it(e)}const Y=new ce(it,{freeArchive:e=>e.free(),reinit:at});let X=null,Z=`empty`;function ot(){if(Z!==`empty`){let e=Error(`this PPTX worker already owns a presentation parse`);throw e.name=`PptxWorkerStateError`,Object.assign(e,{code:`ooxml-pptx-parse-already-started`})}Z=`opening`}const Q=new Ye(()=>Y.archive,(e,t,n)=>{if(X){if(e!==X.acceptedSlideCount)throw Error(`PPTX preflight expected slide ${X.acceptedSlideCount}, received ${e}`);return X.prepareSlide(t,n)}},e=>{let t=Y.archive;if(!t)throw Error(`Presentation not loaded`);return Y.run(()=>e(t))}),$=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let t=e.data;if(Xe(t)){await Q.dispatchSafely(t,$);return}if(t.kind===`init`){Y.setWasmInput(ne(t.wasmUrl)??t.wasmUrl);return}let n=t.id,r=!1;try{if(t.kind===`openSlideSession`&&Q.reserveOpen(t),t.kind===`parse`&&(ot(),r=!0),t.kind===`openSlideSession`){await Y.ensureReady(),await Q.open(t.slideIndex,t),await Q.postOpenedSafely(t,()=>$({kind:`slideSessionOpened`,id:n,sessionId:t.sessionId,operationId:t.operationId,generation:t.generation}),e=>$({kind:`error`,id:n,...y(e)}));return}t.kind===`parse`&&await Q.reset(),await Q.run(async()=>{if(await Y.ensureReady(),t.kind!==`parse`&&Y.archive){let e=Y.archive;Y.run(()=>e.assert_healthy())}if(t.kind===`parse`){X=null;let[e,r,i]=je(t.resourcePolicy),a=Y.run(()=>{let n=new P(new Uint8Array(t.buffer),e,r,i);return Y.setArchive(n),JSON.parse(new TextDecoder().decode(n.presentation_bootstrap()))});X=t.progressiveLayout?null:new qe(a),$({kind:`presentationOpened`,id:n,bootstrap:a}),Z=`ready`;return}let e=Y.archive;if(!e)throw Error(`No pptx loaded`);if(t.kind===`finishPresentationPreflight`){if(!X)throw Error(`PPTX presentation preflight is not active`);let e=X.finish();X=null,$({kind:`presentationPreflightReady`,id:n,preflight:e});return}if(t.kind===`extractMedia`){let r=Y.run(()=>e.extract_media(t.path).buffer);$({kind:`mediaExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractImage`){let r=Y.run(()=>e.extract_image(t.path).buffer);$({kind:`imageExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`extractFont`){let r=Y.run(()=>e.extract_font(t.path).buffer);$({kind:`fontExtracted`,id:n,bytes:r},[r]);return}if(t.kind===`resourceUsage`){$({kind:`resourceUsage`,id:n,usage:ge(Y.run(()=>e.resource_usage()))});return}t.kind===`toMarkdown`&&$({kind:`markdownRendered`,id:n,markdown:Y.run(()=>e.to_markdown())})})}catch(e){r&&(Z=`failed`),t.kind===`openSlideSession`&&Q.abandonOpen(t.sessionId);try{$({kind:`error`,id:n,...y(e)})}catch{}}};", yt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", vt], { type: "text/javascript;charset=utf-8" });
|
|
612
|
+
function bt(e) {
|
|
613
|
+
let t;
|
|
614
|
+
try {
|
|
615
|
+
if (t = yt && (self.URL || self.webkitURL).createObjectURL(yt), !t) throw "";
|
|
616
|
+
let n = new Worker(t, {
|
|
617
|
+
type: "module",
|
|
618
|
+
name: e?.name
|
|
619
|
+
});
|
|
620
|
+
return n.addEventListener("error", () => {
|
|
621
|
+
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
622
|
+
}), n;
|
|
623
|
+
} catch {
|
|
624
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(vt), {
|
|
625
|
+
type: "module",
|
|
626
|
+
name: e?.name
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region packages/pptx/src/wasm/pptx_parser_bg.wasm?url
|
|
632
|
+
var xt = new URL("pptx_parser_bg.wasm", import.meta.url).href, G = 65536, St = 16384, Ct = new Set(["line", "straightconnector1"]);
|
|
633
|
+
function wt(e, t) {
|
|
634
|
+
let n = e.x + e.width / 2, r = e.y + e.height / 2, i = -e.rotation * Math.PI / 180, a = Math.cos(i), o = Math.sin(i), s = t.x - n, c = t.y - r, l = n + a * s - o * c, u = r + o * s + a * c;
|
|
635
|
+
return e.flipH && (l = 2 * n - l), e.flipV && (u = 2 * r - u), {
|
|
636
|
+
x: l,
|
|
637
|
+
y: u
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function Tt(e, t, n) {
|
|
641
|
+
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
642
|
+
if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
|
|
643
|
+
let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a));
|
|
644
|
+
return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
645
|
+
}
|
|
646
|
+
function Et(e, t, n = 0) {
|
|
647
|
+
if (!Number.isFinite(t.x) || !Number.isFinite(t.y)) return !1;
|
|
648
|
+
let r = wt(e, t), i = Number.isFinite(n) && n > 0 ? n : 0;
|
|
649
|
+
if (e.type === "shape" && (Ct.has(e.geometry.toLowerCase()) || e.width === 0 || e.height === 0)) return Tt(r, {
|
|
650
|
+
x: e.x,
|
|
651
|
+
y: e.y
|
|
652
|
+
}, {
|
|
653
|
+
x: e.x + e.width,
|
|
654
|
+
y: e.y + e.height
|
|
655
|
+
}) <= i;
|
|
656
|
+
let a = Math.min(e.x, e.x + e.width), o = Math.max(e.x, e.x + e.width), s = Math.min(e.y, e.y + e.height), c = Math.max(e.y, e.y + e.height);
|
|
657
|
+
return r.x >= a && r.x <= o && r.y >= s && r.y <= c;
|
|
658
|
+
}
|
|
659
|
+
function* Dt(e) {
|
|
660
|
+
if (e) for (let t of e.paragraphs) {
|
|
661
|
+
let e = !0;
|
|
662
|
+
for (let n of t.runs) {
|
|
663
|
+
let t = n.type === "text" ? n.text : n.type === "break" ? "\n" : "[equation]";
|
|
664
|
+
t && (yield {
|
|
665
|
+
text: t,
|
|
666
|
+
beginsPart: e
|
|
667
|
+
}, e = !1);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function* Ot(e) {
|
|
672
|
+
if (e.type === "shape") {
|
|
673
|
+
yield* Dt(e.textBody);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (e.type === "table") {
|
|
677
|
+
for (let t of e.rows) for (let e of t.cells) yield* Dt(e.textBody);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function kt(e, t) {
|
|
682
|
+
let n = Math.min(e.length, t);
|
|
683
|
+
if (n > 0 && n < e.length) {
|
|
684
|
+
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
685
|
+
t >= 55296 && t <= 56319 && r >= 56320 && r <= 57343 && n--;
|
|
686
|
+
}
|
|
687
|
+
return e.slice(0, n);
|
|
688
|
+
}
|
|
689
|
+
function At(e, t = St) {
|
|
690
|
+
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
691
|
+
let n = Math.min(G, Math.floor(t)), r = e.text, i = r === void 0 ? void 0 : kt(r, n), a = r !== void 0 && i.length < r.length;
|
|
692
|
+
return {
|
|
693
|
+
...structuredClone(e),
|
|
694
|
+
...i === void 0 ? {} : { text: i },
|
|
695
|
+
truncated: e.truncated || a,
|
|
696
|
+
truncationReasons: e.truncated || a ? ["text"] : [],
|
|
697
|
+
textCharacters: i?.length ?? 0,
|
|
698
|
+
maxTextCharacters: n
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
function jt(e, t) {
|
|
702
|
+
let n = [], r = 0, i = !1, a = !1;
|
|
703
|
+
for (let o of e) {
|
|
704
|
+
if (a = !0, o.beginsPart && n.length > 0) {
|
|
705
|
+
if (r >= t) {
|
|
706
|
+
i = !0;
|
|
707
|
+
break;
|
|
708
|
+
}
|
|
709
|
+
n.push("\n"), r++;
|
|
710
|
+
}
|
|
711
|
+
let e = Math.max(0, t - r), s = kt(o.text, e);
|
|
712
|
+
if (n.push(s), r += s.length, s.length < o.text.length) {
|
|
713
|
+
i = !0;
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return a ? {
|
|
718
|
+
text: n.join(""),
|
|
719
|
+
truncated: i,
|
|
720
|
+
textCharacters: r
|
|
721
|
+
} : {
|
|
722
|
+
truncated: !1,
|
|
723
|
+
textCharacters: 0
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function Mt(e, t, n, r = {}) {
|
|
727
|
+
if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) throw RangeError("PPTX hit-test point must contain finite coordinates.");
|
|
728
|
+
let i = r.maxTextCharacters ?? St;
|
|
729
|
+
if (!Number.isFinite(i) || i < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
730
|
+
let a = Math.min(G, Math.floor(i)), o = r.tolerance ?? 0;
|
|
731
|
+
if (!Number.isFinite(o) || o < 0) throw RangeError("tolerance must be a finite non-negative number.");
|
|
732
|
+
for (let r = t.elements.length - 1; r >= 0; r--) {
|
|
733
|
+
let i = t.elements[r];
|
|
734
|
+
if (!Et(i, n, o)) continue;
|
|
735
|
+
let s = i.type === "chart" ? ce(i.chart, a) : jt(Ot(i), a);
|
|
736
|
+
return {
|
|
737
|
+
format: "pptx",
|
|
738
|
+
kind: "element",
|
|
739
|
+
slideIndex: e,
|
|
740
|
+
elementIndex: r,
|
|
741
|
+
origin: t.elementSources?.[r]?.origin ?? "unknown",
|
|
742
|
+
elementType: i.type,
|
|
743
|
+
point: { ...n },
|
|
744
|
+
bounds: {
|
|
745
|
+
x: i.x,
|
|
746
|
+
y: i.y,
|
|
747
|
+
width: i.width,
|
|
748
|
+
height: i.height,
|
|
749
|
+
rotation: i.rotation,
|
|
750
|
+
flipH: i.flipH,
|
|
751
|
+
flipV: i.flipV
|
|
752
|
+
},
|
|
753
|
+
...i.type === "shape" ? {
|
|
754
|
+
...i.id === void 0 ? {} : { shapeId: i.id },
|
|
755
|
+
...i.name === void 0 ? {} : { name: i.name },
|
|
756
|
+
geometry: i.geometry
|
|
757
|
+
} : {},
|
|
758
|
+
...s.text === void 0 ? {} : { text: s.text },
|
|
759
|
+
...i.type === "picture" ? { mimeType: i.mimeType } : {},
|
|
760
|
+
...i.type === "media" ? {
|
|
761
|
+
mimeType: i.mimeType,
|
|
762
|
+
mediaKind: i.mediaKind
|
|
763
|
+
} : {},
|
|
764
|
+
...i.type === "table" ? {
|
|
765
|
+
rowCount: i.rows.length,
|
|
766
|
+
columnCount: i.cols.length
|
|
767
|
+
} : {},
|
|
768
|
+
...i.type === "chart" ? { seriesCount: i.chart.series.length } : {},
|
|
769
|
+
truncated: s.truncated,
|
|
770
|
+
truncationReasons: s.truncated ? ["text"] : [],
|
|
771
|
+
textCharacters: s.textCharacters,
|
|
772
|
+
maxTextCharacters: a
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
function Nt(e, t) {
|
|
778
|
+
let n = new Set(t.filter((e) => e.length > 0));
|
|
779
|
+
if (n.size === 0) return Object.freeze([]);
|
|
780
|
+
let r = /* @__PURE__ */ new Map();
|
|
781
|
+
for (let [t, i] of e.elements.entries()) {
|
|
782
|
+
let a = i.id;
|
|
783
|
+
if (!a || !n.has(a)) continue;
|
|
784
|
+
let o = e.elementSources?.[t]?.origin ?? "unknown", s = o === "slide" ? 3 : o === "layout" ? 2 : +(o === "master"), c = r.get(a), l = c?.origin === "slide" ? 3 : c?.origin === "layout" ? 2 : +(c?.origin === "master");
|
|
785
|
+
c && l > s || r.set(a, Object.freeze({
|
|
786
|
+
elementId: a,
|
|
787
|
+
elementIndex: t,
|
|
788
|
+
origin: o,
|
|
789
|
+
elementType: i.type,
|
|
790
|
+
bounds: Object.freeze({
|
|
791
|
+
x: i.x,
|
|
792
|
+
y: i.y,
|
|
793
|
+
width: i.width,
|
|
794
|
+
height: i.height,
|
|
795
|
+
rotation: i.rotation,
|
|
796
|
+
flipH: i.flipH,
|
|
797
|
+
flipV: i.flipV
|
|
798
|
+
})
|
|
799
|
+
}));
|
|
800
|
+
}
|
|
801
|
+
return Object.freeze(t.flatMap((e) => {
|
|
802
|
+
let t = r.get(e);
|
|
803
|
+
return t ? [t] : [];
|
|
804
|
+
}));
|
|
805
|
+
}
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region packages/pptx/src/presentation-layout-events.ts
|
|
808
|
+
var K = /* @__PURE__ */ new WeakMap();
|
|
809
|
+
function q(e, t) {
|
|
810
|
+
let n = Object.freeze({ ...t });
|
|
811
|
+
for (let t of [...K.get(e) ?? []]) try {
|
|
812
|
+
t.notify(n);
|
|
813
|
+
} catch (e) {
|
|
814
|
+
try {
|
|
815
|
+
t.report(e);
|
|
816
|
+
} catch {}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function Pt(e, t, n, r) {
|
|
820
|
+
let i = K.get(e);
|
|
821
|
+
i || (i = /* @__PURE__ */ new Set(), K.set(e, i));
|
|
822
|
+
let a = Object.freeze({
|
|
823
|
+
notify: n,
|
|
824
|
+
report: r
|
|
825
|
+
});
|
|
826
|
+
i.add(a);
|
|
827
|
+
try {
|
|
828
|
+
n(Object.freeze({ ...t() }));
|
|
829
|
+
} catch (e) {
|
|
830
|
+
try {
|
|
831
|
+
r(e);
|
|
832
|
+
} catch {}
|
|
833
|
+
}
|
|
834
|
+
return () => {
|
|
835
|
+
i?.delete(a), i?.size === 0 && K.delete(e);
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region packages/pptx/src/worker-task-scheduler.ts
|
|
840
|
+
function Ft() {
|
|
841
|
+
return new Promise((e) => {
|
|
842
|
+
let t = new MessageChannel();
|
|
843
|
+
t.port1.onmessage = () => {
|
|
844
|
+
t.port1.close(), t.port2.close(), e();
|
|
845
|
+
}, t.port2.postMessage(void 0);
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
//#endregion
|
|
849
|
+
//#region packages/pptx/src/presentation.ts
|
|
850
|
+
function It() {
|
|
851
|
+
let e, t;
|
|
852
|
+
return {
|
|
853
|
+
promise: new Promise((n, r) => {
|
|
854
|
+
e = n, t = r;
|
|
855
|
+
}),
|
|
856
|
+
resolve: e,
|
|
857
|
+
reject: t
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
var J = class e {
|
|
861
|
+
_metrics = null;
|
|
862
|
+
_worker;
|
|
863
|
+
_bridge;
|
|
864
|
+
_mode = "main";
|
|
865
|
+
_bootstrap = null;
|
|
866
|
+
_preflight = null;
|
|
867
|
+
_availableSlideCount = 0;
|
|
868
|
+
_layoutLifecycle = new De();
|
|
869
|
+
_layoutObservers = new ke();
|
|
870
|
+
_layoutCompletion = null;
|
|
871
|
+
_parseRequestId = null;
|
|
872
|
+
_progressive = null;
|
|
873
|
+
_progressiveWatchdog;
|
|
874
|
+
_progressiveWatchdogMs;
|
|
875
|
+
_layoutWaiters = /* @__PURE__ */ new Set();
|
|
876
|
+
_slides = null;
|
|
877
|
+
_slidePullClient = null;
|
|
878
|
+
_resourceFailure = null;
|
|
879
|
+
_slidePartIndex = null;
|
|
880
|
+
_rawParts = new Te({
|
|
881
|
+
maxEntries: 64,
|
|
882
|
+
maxBytes: v
|
|
883
|
+
});
|
|
884
|
+
_googleFontFaces = [];
|
|
885
|
+
_embeddedFontFaces = [];
|
|
886
|
+
_embeddedFontAliases = /* @__PURE__ */ new Map();
|
|
887
|
+
_embeddedFontAuthoredFamilies = /* @__PURE__ */ new Map();
|
|
888
|
+
_destroyed = !1;
|
|
889
|
+
_fetchImage = (e, t) => this.getImage(e, t);
|
|
890
|
+
_fetchMedia = (e) => this.getMedia(e);
|
|
891
|
+
_math;
|
|
892
|
+
_threeD;
|
|
893
|
+
_regionMap;
|
|
894
|
+
_chartEx;
|
|
895
|
+
constructor(e, t, n) {
|
|
896
|
+
this._worker = e, this._mode = t, this._bridge = new ne(this._worker, {
|
|
897
|
+
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
898
|
+
toError: (e) => !("protocol" in e) && e.kind === "error" ? y(e) : void 0,
|
|
899
|
+
onUnsolicited: (e) => this._onWorkerLayoutPush(e)
|
|
900
|
+
});
|
|
901
|
+
let r = new URL(n ?? xt, location.href).href;
|
|
902
|
+
this._bridge.post({
|
|
903
|
+
kind: "init",
|
|
904
|
+
wasmUrl: r
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
_assertResourceHealthy() {
|
|
908
|
+
if (this._resourceFailure) throw this._resourceFailure;
|
|
909
|
+
}
|
|
910
|
+
_rethrowWithResourceFailure(e) {
|
|
911
|
+
let t = e instanceof h ? e : m(e);
|
|
912
|
+
throw t ? (this._resourceFailure ??= t, this._resourceFailure) : e;
|
|
913
|
+
}
|
|
914
|
+
static async load(t, r = {}) {
|
|
915
|
+
let i = p(r), a = r.mode ?? "main", o = new g({
|
|
916
|
+
enabled: !0,
|
|
917
|
+
format: "pptx",
|
|
918
|
+
mode: a,
|
|
919
|
+
policy: i.policy,
|
|
920
|
+
onMetrics: i.onResourceMetrics,
|
|
921
|
+
emitToConsole: i.debug
|
|
922
|
+
});
|
|
923
|
+
try {
|
|
924
|
+
if (a === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
925
|
+
let s;
|
|
926
|
+
if (typeof t == "string") {
|
|
927
|
+
let e = await fetch(t);
|
|
928
|
+
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
929
|
+
s = await e.arrayBuffer();
|
|
930
|
+
} else s = t;
|
|
931
|
+
s = re(await ae(s, r.password)), o.setSourceBytes(s.byteLength), o.checkpoint("container ready");
|
|
932
|
+
let c = a === "worker" ? (await import("./render-worker-host-D1jcACJV.js")).createRenderWorker() : new bt(), l = a === "worker" ? Pe(r) : void 0, u;
|
|
933
|
+
try {
|
|
934
|
+
u = new e(c, a, r.wasmUrl), u._metrics = o, r.math && a === "worker" && !l?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), r.threeD && a === "worker" && !l?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), u._math = a === "worker" ? void 0 : r.math, u._threeD = a === "worker" ? void 0 : r.threeD, r.regionMap && a === "worker" && !l?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), u._regionMap = a === "worker" ? void 0 : r.regionMap, r.chartEx && a === "worker" && !l?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), u._chartEx = a === "worker" ? void 0 : r.chartEx;
|
|
935
|
+
let t = r.progressiveLayout ? {
|
|
936
|
+
onProgress: r.onLayoutProgress,
|
|
937
|
+
onPartial: r.onLayoutPartial,
|
|
938
|
+
onComplete: r.onLayoutComplete,
|
|
939
|
+
firstPublication: It(),
|
|
940
|
+
published: !1,
|
|
941
|
+
deferred: !1,
|
|
942
|
+
settled: !1
|
|
943
|
+
} : void 0;
|
|
944
|
+
return await u._parse(s, i.policy, !!r.useGoogleFonts, r.workerTimeoutMs, (e) => o.observeUsage(e), l, t), o.checkpoint("presentation preflight ready"), a === "main" && r.useGoogleFonts && u._preflight && !t && (u._googleFontFaces = await k(_t(u._preflight.fontPreloadNames, u._embeddedFontAliases), n)), o.succeed({ slides: u.slideCount }), u;
|
|
945
|
+
} catch (e) {
|
|
946
|
+
let t = u;
|
|
947
|
+
throw ie(c, t ? () => t.destroy() : void 0), e;
|
|
948
|
+
}
|
|
949
|
+
} catch (e) {
|
|
950
|
+
throw o.fail(e), e;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
async _parse(e, n, r = !1, i, a, o, l) {
|
|
954
|
+
if (l) {
|
|
955
|
+
this._progressive = l, this._mode === "worker" ? await this._parseWorkerProgressively(e, n, r, i, a, o, l) : await this._parseMainProgressively(e, n, r, i, a, l);
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
let u = await this._bridge.request((t) => this._mode === "worker" ? {
|
|
959
|
+
kind: "parse",
|
|
960
|
+
id: t,
|
|
961
|
+
buffer: e,
|
|
962
|
+
resourcePolicy: n,
|
|
963
|
+
useGoogleFonts: r,
|
|
964
|
+
renderers: o
|
|
965
|
+
} : {
|
|
966
|
+
kind: "parse",
|
|
967
|
+
id: t,
|
|
968
|
+
buffer: e,
|
|
969
|
+
resourcePolicy: n
|
|
970
|
+
}, [e], { timeoutMs: i });
|
|
971
|
+
if (this._mode === "worker") {
|
|
972
|
+
let e = u;
|
|
973
|
+
e.usage && a?.(e.usage), this._preflight = c(u.preflight), this._bootstrap = this._preflight, this._availableSlideCount = this._preflight.slideCount;
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
let f = t(u.bootstrap);
|
|
977
|
+
this._bootstrap = f;
|
|
978
|
+
let p = gt(f.embeddedFonts, (e) => this.getFontBytes(e)).then((e) => {
|
|
979
|
+
this._destroyed ? j(e.faces) : (this._embeddedFontFaces = e.faces, this._embeddedFontAliases = e.aliases, this._embeddedFontAuthoredFamilies = e.authoredFamilies);
|
|
980
|
+
});
|
|
981
|
+
this._slidePullClient = new d({
|
|
982
|
+
slideCount: f.slideCount,
|
|
983
|
+
transport: this._bridge.transport(s),
|
|
984
|
+
open: async (e, t, n) => {
|
|
985
|
+
await this._bridge.request((n) => ({
|
|
986
|
+
kind: "openSlideSession",
|
|
987
|
+
id: n,
|
|
988
|
+
slideIndex: e,
|
|
989
|
+
...t
|
|
990
|
+
}), void 0, { timeoutMs: n });
|
|
991
|
+
},
|
|
992
|
+
onUsage: a
|
|
993
|
+
});
|
|
994
|
+
let m;
|
|
995
|
+
try {
|
|
996
|
+
for (let e = 0; e < f.slideCount; e += 1) await this._slidePullClient.load(e, !1, i);
|
|
997
|
+
m = await this._bridge.request((e) => ({
|
|
998
|
+
kind: "finishPresentationPreflight",
|
|
999
|
+
id: e
|
|
1000
|
+
}), void 0, { timeoutMs: i }), await p;
|
|
1001
|
+
} catch (e) {
|
|
1002
|
+
throw p.catch(() => void 0), e;
|
|
1003
|
+
}
|
|
1004
|
+
this._preflight = c(m.preflight), this._availableSlideCount = this._preflight.slideCount, this._slides = new pt({
|
|
1005
|
+
slideCount: this._preflight.slideCount,
|
|
1006
|
+
maxCachedSlides: 8,
|
|
1007
|
+
maxCachedStructuralBytes: _,
|
|
1008
|
+
loadSlide: async (e) => {
|
|
1009
|
+
let t = await this._slidePullClient?.load(e, !0, i);
|
|
1010
|
+
if (!t) throw Error("PPTX slide pull client is unavailable");
|
|
1011
|
+
return t;
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
async _parseMainProgressively(e, r, i, a, o, s) {
|
|
1016
|
+
let c = t((await this._bridge.request((t) => ({
|
|
1017
|
+
kind: "parse",
|
|
1018
|
+
id: t,
|
|
1019
|
+
buffer: e,
|
|
1020
|
+
resourcePolicy: r,
|
|
1021
|
+
progressiveLayout: !0
|
|
1022
|
+
}), [e], { timeoutMs: a })).bootstrap);
|
|
1023
|
+
this._bootstrap = c;
|
|
1024
|
+
let u = gt(c.embeddedFonts, (e) => this.getFontBytes(e)).then((e) => {
|
|
1025
|
+
this._destroyed ? j(e.faces) : (this._embeddedFontFaces = e.faces, this._embeddedFontAliases = e.aliases, this._embeddedFontAuthoredFamilies = e.authoredFamilies);
|
|
1026
|
+
});
|
|
1027
|
+
this._slidePullClient = this._createSlidePullClient(c.slideCount, a, o), this._slides = new pt({
|
|
1028
|
+
slideCount: c.slideCount,
|
|
1029
|
+
maxCachedSlides: 8,
|
|
1030
|
+
maxCachedStructuralBytes: _,
|
|
1031
|
+
loadSlide: async (e) => {
|
|
1032
|
+
let t = await this._slidePullClient?.load(e, !0, a);
|
|
1033
|
+
if (!t) throw Error("PPTX slide pull client is unavailable");
|
|
1034
|
+
return t;
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
let d = new l(c), f = /* @__PURE__ */ new Set(), p = async () => {
|
|
1038
|
+
if (await u, !i) return;
|
|
1039
|
+
let e = _t(d.currentFontPreloadNames, this._embeddedFontAliases).filter((e) => !!e && !f.has(e));
|
|
1040
|
+
if (e.length !== 0) {
|
|
1041
|
+
for (let t of e) f.add(t);
|
|
1042
|
+
this._googleFontFaces.push(...await k(e, n));
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
this._layoutCompletion = (async () => {
|
|
1046
|
+
for (let e = 0; e < c.slideCount; e += 1) await this._slides.withSlide(e, (e) => {
|
|
1047
|
+
d.addSlide(e);
|
|
1048
|
+
}), await p(), this._applyProgressivePrefix(d.snapshot(), s), e === 0 && s.deferred && await Ft();
|
|
1049
|
+
await u, this._finishProgressiveLayout(d.finish(), s);
|
|
1050
|
+
})().then(() => void 0, (e) => this._failProgressiveLayout(e, s)), await s.firstPublication.promise;
|
|
1051
|
+
}
|
|
1052
|
+
async _parseWorkerProgressively(e, t, n, r, i, a, o) {
|
|
1053
|
+
this._progressiveWatchdogMs = r;
|
|
1054
|
+
let s = this._bridge.request((r) => (this._parseRequestId = r, {
|
|
1055
|
+
kind: "parse",
|
|
1056
|
+
id: r,
|
|
1057
|
+
buffer: e,
|
|
1058
|
+
resourcePolicy: t,
|
|
1059
|
+
useGoogleFonts: n,
|
|
1060
|
+
renderers: a,
|
|
1061
|
+
progressiveLayout: !0
|
|
1062
|
+
}), [e], { timeoutMs: !1 });
|
|
1063
|
+
this._rearmProgressiveWatchdog(), this._layoutCompletion = s.then((e) => {
|
|
1064
|
+
this._parseRequestId = null;
|
|
1065
|
+
let t = e;
|
|
1066
|
+
t.usage && i?.(t.usage), this._finishProgressiveLayout(c(t.preflight), o);
|
|
1067
|
+
}, (e) => {
|
|
1068
|
+
this._parseRequestId = null, this._failProgressiveLayout(e, o);
|
|
1069
|
+
}), await o.firstPublication.promise;
|
|
1070
|
+
}
|
|
1071
|
+
_createSlidePullClient(e, t, n) {
|
|
1072
|
+
return new d({
|
|
1073
|
+
slideCount: e,
|
|
1074
|
+
transport: this._bridge.transport(s),
|
|
1075
|
+
open: async (e, n, r) => {
|
|
1076
|
+
await this._bridge.request((t) => ({
|
|
1077
|
+
kind: "openSlideSession",
|
|
1078
|
+
id: t,
|
|
1079
|
+
slideIndex: e,
|
|
1080
|
+
...n
|
|
1081
|
+
}), void 0, { timeoutMs: r ?? t });
|
|
1082
|
+
},
|
|
1083
|
+
onUsage: n
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
_onWorkerLayoutPush(e) {
|
|
1087
|
+
if (!(!("kind" in e) || e.kind !== "presentationLayoutPartial" || e.forId !== this._parseRequestId || !this._progressive)) try {
|
|
1088
|
+
this._rearmProgressiveWatchdog(), e.usage && this._metrics?.observeUsage(e.usage), e.bootstrap && (this._bootstrap = t(e.bootstrap));
|
|
1089
|
+
let n = this._bootstrap;
|
|
1090
|
+
if (!n) throw Error("PPTX progressive worker published before bootstrap");
|
|
1091
|
+
let r = this._preflight?.slides ?? [];
|
|
1092
|
+
if (e.availableSlides !== r.length + 1 || e.slide.index !== r.length) throw Error("PPTX progressive worker published a non-sequential slide");
|
|
1093
|
+
this._applyProgressivePrefix(u({
|
|
1094
|
+
...n,
|
|
1095
|
+
slides: [...r, e.slide],
|
|
1096
|
+
fontPreloadNames: e.fontPreloadNames
|
|
1097
|
+
}), this._progressive), Ft().then(() => {
|
|
1098
|
+
this._destroyed || this._parseRequestId !== e.forId || this._bridge.post({
|
|
1099
|
+
kind: "continuePresentationPreflight",
|
|
1100
|
+
forId: e.forId,
|
|
1101
|
+
availableSlides: e.availableSlides
|
|
1102
|
+
});
|
|
1103
|
+
}).catch((t) => {
|
|
1104
|
+
this._destroyed || this._parseRequestId !== e.forId || !this._progressive || (this._failProgressiveLayout(t, this._progressive), this._bridge.terminate());
|
|
1105
|
+
});
|
|
1106
|
+
} catch (e) {
|
|
1107
|
+
this._failProgressiveLayout(e, this._progressive), this._bridge.terminate();
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
_applyProgressivePrefix(e, t) {
|
|
1111
|
+
if (!(t.settled || this._destroyed)) {
|
|
1112
|
+
if (this._preflight = e, this._availableSlideCount = e.slides.length, !t.published && e.slides.length === e.slideCount) {
|
|
1113
|
+
t.published = !0, t.deferred = !1;
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (this._layoutLifecycle.begin(), this._wakeLayoutWaiters(), this._layoutObservers.notify("onLayoutProgress", t.onProgress, { committedUnits: this._availableSlideCount }), q(this, {
|
|
1117
|
+
availableSlides: this._availableSlideCount,
|
|
1118
|
+
slideCount: this.slideCount,
|
|
1119
|
+
exact: !1,
|
|
1120
|
+
complete: !1
|
|
1121
|
+
}), !t.published) {
|
|
1122
|
+
t.published = !0, t.deferred = e.slides.length < e.slideCount, t.firstPublication.resolve();
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
this._layoutObservers.notify("onLayoutPartial", t.onPartial, {
|
|
1126
|
+
availableUnits: this._availableSlideCount,
|
|
1127
|
+
totalUnits: this.slideCount,
|
|
1128
|
+
exact: !1
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
_finishProgressiveLayout(e, t) {
|
|
1133
|
+
t.settled || this._destroyed || (t.settled = !0, this._clearProgressiveWatchdog(), this._preflight = e, this._bootstrap ??= e, this._availableSlideCount = e.slideCount, this._layoutLifecycle.succeed(), this._wakeLayoutWaiters(), t.firstPublication.resolve(), q(this, {
|
|
1134
|
+
availableSlides: this._availableSlideCount,
|
|
1135
|
+
slideCount: this.slideCount,
|
|
1136
|
+
exact: !0,
|
|
1137
|
+
complete: !0
|
|
1138
|
+
}), t.deferred && this._layoutObservers.notify("onLayoutComplete", t.onComplete));
|
|
1139
|
+
}
|
|
1140
|
+
_failProgressiveLayout(e, t) {
|
|
1141
|
+
if (t.settled || (t.settled = !0, this._clearProgressiveWatchdog(), this._destroyed)) return;
|
|
1142
|
+
if (!t.published) {
|
|
1143
|
+
t.firstPublication.reject(e);
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
let n = this._layoutLifecycle.fail(e);
|
|
1147
|
+
this._wakeLayoutWaiters(), q(this, {
|
|
1148
|
+
availableSlides: this._availableSlideCount,
|
|
1149
|
+
slideCount: this.slideCount,
|
|
1150
|
+
exact: !1,
|
|
1151
|
+
complete: !1,
|
|
1152
|
+
error: n
|
|
1153
|
+
}), this._layoutObservers.notify("onLayoutComplete", t.onComplete, n);
|
|
1154
|
+
}
|
|
1155
|
+
_wakeLayoutWaiters() {
|
|
1156
|
+
for (let e of this._layoutWaiters) e();
|
|
1157
|
+
this._layoutWaiters.clear();
|
|
1158
|
+
}
|
|
1159
|
+
_rearmProgressiveWatchdog() {
|
|
1160
|
+
this._progressiveWatchdogMs !== void 0 && (clearTimeout(this._progressiveWatchdog), this._progressiveWatchdog = setTimeout(() => {
|
|
1161
|
+
let e = this._progressive, t = this._progressiveWatchdogMs;
|
|
1162
|
+
if (!e || e.settled || t === void 0 || this._destroyed) return;
|
|
1163
|
+
let n = /* @__PURE__ */ Error(`worker layout produced no progress for ${t}ms`);
|
|
1164
|
+
this._failProgressiveLayout(n, e), this._bridge.terminate();
|
|
1165
|
+
}, this._progressiveWatchdogMs));
|
|
1166
|
+
}
|
|
1167
|
+
_clearProgressiveWatchdog() {
|
|
1168
|
+
clearTimeout(this._progressiveWatchdog), this._progressiveWatchdog = void 0, this._progressiveWatchdogMs = void 0;
|
|
1169
|
+
}
|
|
1170
|
+
async _waitForSlide(e) {
|
|
1171
|
+
for (; !this._destroyed && e >= this._availableSlideCount && !this._layoutLifecycle.settled;) await new Promise((e) => this._layoutWaiters.add(e));
|
|
1172
|
+
e >= this._availableSlideCount && await this.waitUntilLayoutComplete();
|
|
1173
|
+
}
|
|
1174
|
+
_assertSlideIndex(e) {
|
|
1175
|
+
if (!Number.isInteger(e) || e < 0 || e >= this.slideCount) throw Error(`Slide index ${e} out of range (count: ${this.slideCount})`);
|
|
1176
|
+
}
|
|
1177
|
+
get slideCount() {
|
|
1178
|
+
return this._bootstrap?.slideCount ?? this._preflight?.slideCount ?? 0;
|
|
1179
|
+
}
|
|
1180
|
+
get availableSlideCount() {
|
|
1181
|
+
return this._availableSlideCount;
|
|
1182
|
+
}
|
|
1183
|
+
get layoutComplete() {
|
|
1184
|
+
return this._layoutLifecycle.complete;
|
|
1185
|
+
}
|
|
1186
|
+
async waitUntilLayoutComplete() {
|
|
1187
|
+
this._layoutCompletion && await this._layoutCompletion, this._layoutLifecycle.throwIfFailed();
|
|
1188
|
+
}
|
|
1189
|
+
get slideWidth() {
|
|
1190
|
+
return this._bootstrap?.slideWidth ?? this._preflight?.slideWidth ?? 0;
|
|
1191
|
+
}
|
|
1192
|
+
get slideHeight() {
|
|
1193
|
+
return this._bootstrap?.slideHeight ?? this._preflight?.slideHeight ?? 0;
|
|
1194
|
+
}
|
|
1195
|
+
get mode() {
|
|
1196
|
+
return this._mode;
|
|
1197
|
+
}
|
|
1198
|
+
getNotes(e) {
|
|
1199
|
+
return Number.isInteger(e) ? this._preflight?.slides[e]?.notes ?? null : null;
|
|
1200
|
+
}
|
|
1201
|
+
getComments(e) {
|
|
1202
|
+
return Number.isInteger(e) ? this._preflight?.slides[e]?.comments ?? [] : [];
|
|
1203
|
+
}
|
|
1204
|
+
isHidden(e) {
|
|
1205
|
+
return Number.isInteger(e) ? this._preflight?.slides[e]?.hidden ?? !1 : !1;
|
|
1206
|
+
}
|
|
1207
|
+
_partNames() {
|
|
1208
|
+
return (this._bootstrap?.slides ?? this._preflight?.slides ?? []).map((e) => e.partName);
|
|
1209
|
+
}
|
|
1210
|
+
_partIndex() {
|
|
1211
|
+
return this._slidePartIndex ||= ut(this._partNames()), this._slidePartIndex;
|
|
1212
|
+
}
|
|
1213
|
+
getSlideIndexByPartName(e) {
|
|
1214
|
+
return this._partIndex().get(e);
|
|
1215
|
+
}
|
|
1216
|
+
resolveInternalTarget(e, t = 0) {
|
|
1217
|
+
return ft(e, this._partIndex(), t);
|
|
1218
|
+
}
|
|
1219
|
+
async renderSlide(e, t, n = {}) {
|
|
1220
|
+
this._assertResourceHealthy();
|
|
1221
|
+
try {
|
|
1222
|
+
if (this._mode === "worker") throw Error("renderSlide(canvas) is unavailable in mode: 'worker'; use renderSlideToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1223
|
+
this._assertSlideIndex(t), await this._waitForSlide(t);
|
|
1224
|
+
let i = this._preflight, a = this._slides;
|
|
1225
|
+
if (!i || !a) throw Error("Presentation not loaded");
|
|
1226
|
+
let o = n.dpr ?? S(), s = n.width ?? ((ee(e) ? e.offsetWidth : 0) || 960);
|
|
1227
|
+
await a.withSlide(t, (t) => (this._assertResourceHealthy(), r(e, t, i.slideWidth, i.slideHeight, {
|
|
1228
|
+
width: s,
|
|
1229
|
+
dpr: o,
|
|
1230
|
+
defaultTextColor: i.defaultTextColor,
|
|
1231
|
+
majorFont: i.majorFont,
|
|
1232
|
+
minorFont: i.minorFont,
|
|
1233
|
+
hlinkColor: i.hlinkColor,
|
|
1234
|
+
embeddedFontAliases: this._embeddedFontAliases,
|
|
1235
|
+
embeddedFontAuthoredFamilies: this._embeddedFontAuthoredFamilies,
|
|
1236
|
+
fetchMedia: this._fetchMedia,
|
|
1237
|
+
fetchImage: this._fetchImage,
|
|
1238
|
+
skipMediaControls: n.skipMediaControls,
|
|
1239
|
+
dim: n.dim,
|
|
1240
|
+
math: this._math,
|
|
1241
|
+
threeD: this._threeD,
|
|
1242
|
+
regionMap: this._regionMap,
|
|
1243
|
+
chartEx: this._chartEx
|
|
1244
|
+
}, n.onTextRun)));
|
|
1245
|
+
} catch (e) {
|
|
1246
|
+
this._rethrowWithResourceFailure(e);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
async renderSlideToBitmap(e, t = {}) {
|
|
1250
|
+
this._assertResourceHealthy();
|
|
1251
|
+
try {
|
|
1252
|
+
this._assertSlideIndex(e), await this._waitForSlide(e);
|
|
1253
|
+
let n = t.width ?? 960, r = t.dpr ?? S();
|
|
1254
|
+
if (this._mode === "worker") {
|
|
1255
|
+
let i = await this._bridge.request((i) => ({
|
|
1256
|
+
kind: "renderSlide",
|
|
1257
|
+
id: i,
|
|
1258
|
+
slideIndex: e,
|
|
1259
|
+
width: n,
|
|
1260
|
+
dpr: r,
|
|
1261
|
+
skipMediaControls: t.skipMediaControls,
|
|
1262
|
+
dim: t.dim
|
|
1263
|
+
}));
|
|
1264
|
+
if (t.onTextRun) for (let e of i.runs) t.onTextRun(e);
|
|
1265
|
+
return i.bitmap;
|
|
1266
|
+
}
|
|
1267
|
+
let i = new OffscreenCanvas(1, 1);
|
|
1268
|
+
return await this.renderSlide(i, e, {
|
|
1269
|
+
width: n,
|
|
1270
|
+
dpr: r,
|
|
1271
|
+
skipMediaControls: t.skipMediaControls,
|
|
1272
|
+
dim: t.dim,
|
|
1273
|
+
onTextRun: t.onTextRun
|
|
1274
|
+
}), i.transferToImageBitmap();
|
|
1275
|
+
} catch (e) {
|
|
1276
|
+
this._rethrowWithResourceFailure(e);
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
async collectSlideRuns(e, t = 960) {
|
|
1280
|
+
this._assertResourceHealthy();
|
|
1281
|
+
try {
|
|
1282
|
+
if (this._assertSlideIndex(e), await this._waitForSlide(e), this._mode === "worker") return (await this._bridge.request((n) => ({
|
|
1283
|
+
kind: "collectRuns",
|
|
1284
|
+
id: n,
|
|
1285
|
+
slideIndex: e,
|
|
1286
|
+
width: t
|
|
1287
|
+
}))).runs;
|
|
1288
|
+
let n = [], r = new OffscreenCanvas(1, 1);
|
|
1289
|
+
return await this.renderSlide(r, e, {
|
|
1290
|
+
width: t,
|
|
1291
|
+
onTextRun: (e) => n.push(e)
|
|
1292
|
+
}), n;
|
|
1293
|
+
} catch (e) {
|
|
1294
|
+
this._rethrowWithResourceFailure(e);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
async getElementContextAt(e, t, n = {}) {
|
|
1298
|
+
this._assertResourceHealthy(), this._assertSlideIndex(e);
|
|
1299
|
+
try {
|
|
1300
|
+
if (await this._waitForSlide(e), this._mode === "worker") return (await this._bridge.request((r) => ({
|
|
1301
|
+
kind: "hitTestElement",
|
|
1302
|
+
id: r,
|
|
1303
|
+
slideIndex: e,
|
|
1304
|
+
point: t,
|
|
1305
|
+
options: n
|
|
1306
|
+
}))).context;
|
|
1307
|
+
if (!this._slides) throw Error("Presentation not loaded");
|
|
1308
|
+
return await this._slides.withSlide(e, (r) => Mt(e, r, t, n));
|
|
1309
|
+
} catch (e) {
|
|
1310
|
+
this._rethrowWithResourceFailure(e);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
async getElementBoundsByIds(e, t) {
|
|
1314
|
+
this._assertResourceHealthy(), this._assertSlideIndex(e);
|
|
1315
|
+
let n = Object.freeze(t.filter((e) => typeof e == "string" && e.length > 0));
|
|
1316
|
+
if (n.length === 0) return Object.freeze([]);
|
|
1317
|
+
try {
|
|
1318
|
+
if (await this._waitForSlide(e), this._mode === "worker") return (await this._bridge.request((t) => ({
|
|
1319
|
+
kind: "resolveElementBounds",
|
|
1320
|
+
id: t,
|
|
1321
|
+
slideIndex: e,
|
|
1322
|
+
elementIds: n
|
|
1323
|
+
}))).bounds;
|
|
1324
|
+
if (!this._slides) throw Error("Presentation not loaded");
|
|
1325
|
+
return await this._slides.withSlide(e, (e) => Nt(e, n));
|
|
1326
|
+
} catch (e) {
|
|
1327
|
+
this._rethrowWithResourceFailure(e);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
async getMedia(e) {
|
|
1331
|
+
this._assertResourceHealthy();
|
|
1332
|
+
try {
|
|
1333
|
+
let t = this._findMimeTypeForPath(e);
|
|
1334
|
+
return await this._rawParts.get(e, t, async () => {
|
|
1335
|
+
let n = (await this._bridge.request((t) => ({
|
|
1336
|
+
kind: "extractMedia",
|
|
1337
|
+
id: t,
|
|
1338
|
+
path: e
|
|
1339
|
+
}))).bytes;
|
|
1340
|
+
return new Blob([n], { type: t });
|
|
1341
|
+
});
|
|
1342
|
+
} catch (e) {
|
|
1343
|
+
this._rethrowWithResourceFailure(e);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
_findMimeTypeForPath(e) {
|
|
1347
|
+
return this._preflight ? a(this._preflight, e) : "";
|
|
1348
|
+
}
|
|
1349
|
+
async getImage(e, t) {
|
|
1350
|
+
this._assertResourceHealthy();
|
|
1351
|
+
try {
|
|
1352
|
+
return await this._rawParts.get(e, t, async () => {
|
|
1353
|
+
let n = (await this._bridge.request((t) => ({
|
|
1354
|
+
kind: "extractImage",
|
|
1355
|
+
id: t,
|
|
1356
|
+
path: e
|
|
1357
|
+
}))).bytes;
|
|
1358
|
+
return new Blob([n], { type: t });
|
|
1359
|
+
});
|
|
1360
|
+
} catch (e) {
|
|
1361
|
+
this._rethrowWithResourceFailure(e);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
async getFontBytes(e) {
|
|
1365
|
+
this._assertResourceHealthy();
|
|
1366
|
+
try {
|
|
1367
|
+
let t = await this._bridge.request((t) => ({
|
|
1368
|
+
kind: "extractFont",
|
|
1369
|
+
id: t,
|
|
1370
|
+
path: e
|
|
1371
|
+
}));
|
|
1372
|
+
return new Uint8Array(t.bytes);
|
|
1373
|
+
} catch (e) {
|
|
1374
|
+
this._rethrowWithResourceFailure(e);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
async getResourceMetrics() {
|
|
1378
|
+
let e = this._metrics;
|
|
1379
|
+
if (!e) throw Error("Presentation not loaded");
|
|
1380
|
+
return te(e, async (e) => (await this._bridge.request((e) => ({
|
|
1381
|
+
kind: "resourceUsage",
|
|
1382
|
+
id: e
|
|
1383
|
+
}), void 0, { timeoutMs: e })).usage);
|
|
1384
|
+
}
|
|
1385
|
+
async toMarkdown() {
|
|
1386
|
+
this._assertResourceHealthy();
|
|
1387
|
+
try {
|
|
1388
|
+
return (await this._bridge.request((e) => ({
|
|
1389
|
+
kind: "toMarkdown",
|
|
1390
|
+
id: e
|
|
1391
|
+
}))).markdown;
|
|
1392
|
+
} catch (e) {
|
|
1393
|
+
this._rethrowWithResourceFailure(e);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
async presentSlide(e, t, n = {}) {
|
|
1397
|
+
this._assertResourceHealthy();
|
|
1398
|
+
try {
|
|
1399
|
+
if (this._assertSlideIndex(t), await this._waitForSlide(t), !this._preflight) throw Error("Presentation not loaded");
|
|
1400
|
+
let r = n.dpr ?? S(), i = n.width ?? (e.offsetWidth || 960), a = this._mode === "worker" ? async () => {
|
|
1401
|
+
let a = await this.renderSlideToBitmap(t, {
|
|
1402
|
+
width: i,
|
|
1403
|
+
dpr: r,
|
|
1404
|
+
skipMediaControls: !0,
|
|
1405
|
+
dim: n.dim,
|
|
1406
|
+
onTextRun: n.onTextRun
|
|
1407
|
+
});
|
|
1408
|
+
e.width = a.width, e.height = a.height, e.style.width = `${Math.round(a.width / r)}px`, e.style.display || (e.style.display = "block");
|
|
1409
|
+
let o = e.getContext("2d");
|
|
1410
|
+
if (!o) throw Error("2D context not available");
|
|
1411
|
+
o.drawImage(a, 0, 0), a.close();
|
|
1412
|
+
} : () => this.renderSlide(e, t, {
|
|
1413
|
+
width: i,
|
|
1414
|
+
dpr: r,
|
|
1415
|
+
skipMediaControls: !0,
|
|
1416
|
+
dim: n.dim,
|
|
1417
|
+
onTextRun: n.onTextRun
|
|
1418
|
+
});
|
|
1419
|
+
return await Ye(e, this._preflight.slides[t]?.mediaElements ?? [], {
|
|
1420
|
+
width: i,
|
|
1421
|
+
dpr: r,
|
|
1422
|
+
slideWidthEmu: this.slideWidth,
|
|
1423
|
+
fetchMedia: this._fetchMedia,
|
|
1424
|
+
fetchImage: this._fetchImage,
|
|
1425
|
+
drawBase: a,
|
|
1426
|
+
onError: n.onError
|
|
1427
|
+
});
|
|
1428
|
+
} catch (e) {
|
|
1429
|
+
this._rethrowWithResourceFailure(e);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
destroy() {
|
|
1433
|
+
this._destroyed = !0, this._clearProgressiveWatchdog(), this._slidePullClient?.cancelAll(), this._bridge.terminate(), this._slides?.clear(), this._slides = null, this._slidePullClient = null, this._bootstrap = null, this._preflight = null, this._availableSlideCount = 0, this._layoutLifecycle.succeed(), this._layoutCompletion = null, this._progressive = null, this._parseRequestId = null, this._wakeLayoutWaiters(), this._resourceFailure = null, this._slidePartIndex = null, this._rawParts.clear(), this._googleFontFaces.length > 0 && (Ce(this._googleFontFaces), this._googleFontFaces = []), this._embeddedFontFaces.length > 0 && (j(this._embeddedFontFaces), this._embeddedFontFaces = []), this._embeddedFontAliases = /* @__PURE__ */ new Map(), this._embeddedFontAuthoredFamilies = /* @__PURE__ */ new Map(), C(this._fetchImage), w(this._fetchImage);
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region packages/pptx/src/selection-context.ts
|
|
1438
|
+
function Lt(e, t, n, r, i = {}) {
|
|
1439
|
+
let a = Oe({
|
|
1440
|
+
id: e.id,
|
|
1441
|
+
author: e.author,
|
|
1442
|
+
date: e.date,
|
|
1443
|
+
text: e.text,
|
|
1444
|
+
status: e.status ?? "active"
|
|
1445
|
+
}, (e.replies ?? []).map((e) => ({
|
|
1446
|
+
id: e.id,
|
|
1447
|
+
author: e.author,
|
|
1448
|
+
date: e.date,
|
|
1449
|
+
text: e.text,
|
|
1450
|
+
status: e.status ?? "active"
|
|
1451
|
+
})), i.maxTextCharacters);
|
|
1452
|
+
return Object.freeze({
|
|
1453
|
+
format: "pptx",
|
|
1454
|
+
kind: "comment",
|
|
1455
|
+
slideIndex: t,
|
|
1456
|
+
commentIndex: n,
|
|
1457
|
+
occurrenceId: r,
|
|
1458
|
+
...e.id ? { commentId: e.id } : {},
|
|
1459
|
+
...Number.isFinite(e.x) && Number.isFinite(e.y) ? { point: Object.freeze({
|
|
1460
|
+
x: e.x,
|
|
1461
|
+
y: e.y
|
|
1462
|
+
}) } : {},
|
|
1463
|
+
thread: a.thread,
|
|
1464
|
+
truncated: a.truncated,
|
|
1465
|
+
truncationReasons: a.truncated ? ["text"] : [],
|
|
1466
|
+
textCharacters: a.textCharacters,
|
|
1467
|
+
maxTextCharacters: a.maxTextCharacters
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
function Y(e) {
|
|
1471
|
+
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1472
|
+
let t = Number(e);
|
|
1473
|
+
return Number.isSafeInteger(t) ? t : null;
|
|
1474
|
+
}
|
|
1475
|
+
function Rt(e) {
|
|
1476
|
+
for (let t = e; t; t = t.parentElement) {
|
|
1477
|
+
let e = Y(t.dataset.slideIndex);
|
|
1478
|
+
if (e !== null) return e;
|
|
1479
|
+
}
|
|
1480
|
+
return null;
|
|
1481
|
+
}
|
|
1482
|
+
function X(e, t, n = {}) {
|
|
1483
|
+
let r = _e(e, t, (e) => {
|
|
1484
|
+
let t = Rt(e), n = Y(e.dataset.runIndex);
|
|
1485
|
+
if (t === null || n === null) return null;
|
|
1486
|
+
let r = Y(e.dataset.elementIndex), i = e.dataset.elementOrigin, a = r !== null && (i === "master" || i === "layout" || i === "slide");
|
|
1487
|
+
return {
|
|
1488
|
+
slideIndex: t,
|
|
1489
|
+
runIndex: n,
|
|
1490
|
+
...e.dataset.shapeId === void 0 ? {} : { shapeId: e.dataset.shapeId },
|
|
1491
|
+
...a ? {
|
|
1492
|
+
elementIndex: r,
|
|
1493
|
+
origin: i
|
|
1494
|
+
} : {}
|
|
1495
|
+
};
|
|
1496
|
+
}, {
|
|
1497
|
+
maxChars: n.maxTextCharacters,
|
|
1498
|
+
maxLocators: n.maxRunLocators
|
|
1499
|
+
});
|
|
1500
|
+
if (!r) return null;
|
|
1501
|
+
let i = [...r.locators].sort((e, t) => e.slideIndex - t.slideIndex || e.runIndex - t.runIndex);
|
|
1502
|
+
return {
|
|
1503
|
+
format: "pptx",
|
|
1504
|
+
kind: "text",
|
|
1505
|
+
text: r.text,
|
|
1506
|
+
slideIndexes: [...new Set(i.map((e) => e.slideIndex))],
|
|
1507
|
+
shapeIds: [...new Set(i.flatMap((e) => e.shapeId ? [e.shapeId] : []))],
|
|
1508
|
+
runs: i,
|
|
1509
|
+
truncated: r.truncated,
|
|
1510
|
+
truncationReasons: r.truncationReasons,
|
|
1511
|
+
textCharacters: r.textCharacters,
|
|
1512
|
+
maxTextCharacters: r.maxTextCharacters,
|
|
1513
|
+
maxRunLocators: r.maxLocators
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
//#endregion
|
|
1517
|
+
//#region packages/pptx/src/focused-view-runtime.ts
|
|
1518
|
+
function Z(e, t, n, r, i) {
|
|
1519
|
+
return r === "worker" ? e.renderSlideToBitmap(n, i) : e.renderSlide(t, n, i);
|
|
1520
|
+
}
|
|
1521
|
+
//#endregion
|
|
1522
|
+
//#region packages/pptx/src/viewer.ts
|
|
1523
|
+
var zt = Symbol("PptxViewer.borrowedPresentation"), Bt = {
|
|
1524
|
+
color: "#ffffff",
|
|
1525
|
+
opacity: .6
|
|
1526
|
+
}, Q = class e {
|
|
1527
|
+
canvas;
|
|
1528
|
+
wrapper;
|
|
1529
|
+
canvasMount;
|
|
1530
|
+
_scale = null;
|
|
1531
|
+
textLayer = null;
|
|
1532
|
+
highlightLayer = null;
|
|
1533
|
+
elementLayer = null;
|
|
1534
|
+
_find;
|
|
1535
|
+
_findGeneration = 0;
|
|
1536
|
+
_measureCtx = null;
|
|
1537
|
+
presentationOwner;
|
|
1538
|
+
get engine() {
|
|
1539
|
+
return this.presentationOwner.current;
|
|
1540
|
+
}
|
|
1541
|
+
borrowed;
|
|
1542
|
+
hostWindow;
|
|
1543
|
+
opts;
|
|
1544
|
+
currentSlide = 0;
|
|
1545
|
+
_renderedSlide = -1;
|
|
1546
|
+
_hiddenMode;
|
|
1547
|
+
handle = null;
|
|
1548
|
+
_mode;
|
|
1549
|
+
renderDispatcher;
|
|
1550
|
+
errorRouter;
|
|
1551
|
+
destroyed = !1;
|
|
1552
|
+
selectionChangeListener = null;
|
|
1553
|
+
selectionContextKey = "null";
|
|
1554
|
+
elementClickListener = null;
|
|
1555
|
+
contextMenuListener = null;
|
|
1556
|
+
elementContext = null;
|
|
1557
|
+
elementHitGeneration = 0;
|
|
1558
|
+
elementHitTolerance;
|
|
1559
|
+
_loadingLayer;
|
|
1560
|
+
_layoutUnsubscribe = null;
|
|
1561
|
+
_layoutWaiters = /* @__PURE__ */ new Set();
|
|
1562
|
+
_layoutFailed = !1;
|
|
1563
|
+
_navigationGeneration = 0;
|
|
1564
|
+
_renderProgressGeneration = 0;
|
|
1565
|
+
_lastReportedSlide = -1;
|
|
1566
|
+
_lastReportedTotal = -1;
|
|
1567
|
+
_lastReportedAvailable = -1;
|
|
1568
|
+
_lastReportedLayoutComplete = null;
|
|
1569
|
+
static fromPresentation(t, n, r = {}) {
|
|
1570
|
+
return new e(t, {
|
|
1571
|
+
...r,
|
|
1572
|
+
[zt]: n
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
constructor(e, t = {}) {
|
|
1576
|
+
this.opts = t, this.canvas = e;
|
|
1577
|
+
let n = t[zt];
|
|
1578
|
+
this.borrowed = n !== void 0, this._mode = O("PptxViewer", t.mode, n), this.presentationOwner = new T("PptxViewer", n ?? null, !1);
|
|
1579
|
+
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1580
|
+
if (!r) throw Error("PptxViewer requires a canvas with an active Window");
|
|
1581
|
+
this.hostWindow = r;
|
|
1582
|
+
let i = t.elementHitTolerance ?? 6;
|
|
1583
|
+
if (!Number.isFinite(i) || i < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
1584
|
+
this.elementHitTolerance = i, this._hiddenMode = t.hiddenSlideMode ?? "show", this.canvasMount = new ve(e, {
|
|
1585
|
+
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1586
|
+
forceDisplayBlock: !0
|
|
1587
|
+
}), this.wrapper = this.canvasMount.wrapper, this.renderDispatcher = new D(e, this._mode === "worker" && !t.enableMediaPlayback), this.errorRouter = new ge("PptxViewer", t.onError);
|
|
1588
|
+
let a = new pe(this.wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1589
|
+
this.textLayer = a.textLayer, this.highlightLayer = a.highlightLayer, this.elementLayer = a.elementLayer, this._loadingLayer = this.wrapper.ownerDocument.createElement("span"), this._loadingLayer.style.cssText = [
|
|
1590
|
+
"position:absolute",
|
|
1591
|
+
"inset:0",
|
|
1592
|
+
"display:none",
|
|
1593
|
+
"align-items:center",
|
|
1594
|
+
"justify-content:center",
|
|
1595
|
+
"background:rgba(255,255,255,0.72)",
|
|
1596
|
+
"pointer-events:none",
|
|
1597
|
+
"z-index:4"
|
|
1598
|
+
].join(";"), this._loadingLayer.setAttribute("role", "status"), this._loadingLayer.setAttribute("aria-live", "polite"), this._loadingLayer.setAttribute("aria-label", "Loading slide");
|
|
1599
|
+
let o = this.wrapper.ownerDocument.createElement("progress");
|
|
1600
|
+
o.setAttribute("aria-hidden", "true"), this._loadingLayer.appendChild(o), this.wrapper.insertBefore(this._loadingLayer, this.elementLayer), this.textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this.selectionChangeListener = () => this._emitSelectionContextChange(), this.wrapper.ownerDocument.addEventListener("selectionchange", this.selectionChangeListener)), t.enableElementSelection && (this.elementClickListener = (e) => {
|
|
1601
|
+
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1602
|
+
}, this.wrapper.addEventListener("click", this.elementClickListener)), t.onContextMenu && (this.contextMenuListener = (e) => this._onContextMenu(e), this.wrapper.addEventListener("contextmenu", this.contextMenuListener)), this._find = new We(() => this.slideCount, (e) => this._collectSlideRuns(e)), n && this._bindLayoutPresentation(n);
|
|
1603
|
+
}
|
|
1604
|
+
async load(e) {
|
|
1605
|
+
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
1606
|
+
if (this.borrowed) throw Error("PptxViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.");
|
|
1607
|
+
let t = !1;
|
|
1608
|
+
try {
|
|
1609
|
+
let n = await this.presentationOwner.replace(() => J.load(e, {
|
|
1610
|
+
password: this.opts.password,
|
|
1611
|
+
useGoogleFonts: this.opts.useGoogleFonts,
|
|
1612
|
+
maxZipEntryBytes: this.opts.maxZipEntryBytes,
|
|
1613
|
+
resourceLimits: this.opts.resourceLimits,
|
|
1614
|
+
debug: this.opts.debug,
|
|
1615
|
+
onResourceMetrics: this.opts.onResourceMetrics,
|
|
1616
|
+
workerTimeoutMs: this.opts.workerTimeoutMs,
|
|
1617
|
+
wasmUrl: this.opts.wasmUrl,
|
|
1618
|
+
math: this.opts.math,
|
|
1619
|
+
threeD: this.opts.threeD,
|
|
1620
|
+
regionMap: this.opts.regionMap,
|
|
1621
|
+
chartEx: this.opts.chartEx,
|
|
1622
|
+
mode: this._mode,
|
|
1623
|
+
progressiveLayout: this.opts.progressiveLayout,
|
|
1624
|
+
onLayoutProgress: this.opts.onLayoutProgress,
|
|
1625
|
+
onLayoutPartial: this.opts.onLayoutPartial,
|
|
1626
|
+
onLayoutComplete: this.opts.onLayoutComplete
|
|
1627
|
+
}), () => {
|
|
1628
|
+
this._invalidateElementSelection(!1), t = !0, this.renderDispatcher.begin(), this._invalidateFind(), this.handle?.destroy(), this.handle = null, this._unbindLayoutPresentation();
|
|
1629
|
+
});
|
|
1630
|
+
if (!n) return;
|
|
1631
|
+
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
1632
|
+
this._bindLayoutPresentation(n);
|
|
1633
|
+
let r = this._beginNavigation();
|
|
1634
|
+
if (this.currentSlide = await this._initialSlide(r), r !== this._navigationGeneration || n !== this.engine) return;
|
|
1635
|
+
this._renderedSlide = -1, this._invalidateFind(), await this.renderCurrentSlide();
|
|
1636
|
+
} catch (e) {
|
|
1637
|
+
throw this.destroyed ? Error("PptxViewer is destroyed") : e instanceof Error ? e : Error(String(e));
|
|
1638
|
+
}
|
|
1639
|
+
t && !this.destroyed && this._emitSelectionContextChange();
|
|
1640
|
+
}
|
|
1641
|
+
async goToSlide(e) {
|
|
1642
|
+
let t = this._beginNavigation();
|
|
1643
|
+
await this._goToSlide(e, t);
|
|
1644
|
+
}
|
|
1645
|
+
async _goToSlide(e, t) {
|
|
1646
|
+
if (t !== this._navigationGeneration || !this.engine || this.slideCount === 0) return;
|
|
1647
|
+
let n = Math.max(0, Math.min(e, this.slideCount - 1)), r = n !== this.currentSlide;
|
|
1648
|
+
r && this._invalidateElementSelection(!1), this.currentSlide = n, await this.renderCurrentSlide(), r && !this.destroyed && this._emitSelectionContextChange();
|
|
1649
|
+
}
|
|
1650
|
+
async nextSlide() {
|
|
1651
|
+
let e = this._beginNavigation(), t = await this._step(1, e);
|
|
1652
|
+
await this._goToSlide(t, e);
|
|
1653
|
+
}
|
|
1654
|
+
async prevSlide() {
|
|
1655
|
+
let e = this._beginNavigation(), t = await this._step(-1, e);
|
|
1656
|
+
await this._goToSlide(t, e);
|
|
1657
|
+
}
|
|
1658
|
+
async _step(e, t) {
|
|
1659
|
+
let n = this.engine, r = this.currentSlide;
|
|
1660
|
+
if (this._hiddenMode !== "skip" || !n) return r + e;
|
|
1661
|
+
for (let i = r + e; i >= 0 && i < this.slideCount; i += e) {
|
|
1662
|
+
if (i >= n.availableSlideCount && (n.layoutComplete || this._setLoading(!0), !await this._waitForSlide(n, i, () => t === this._navigationGeneration))) return r;
|
|
1663
|
+
if (!n.isHidden(i)) return i;
|
|
1664
|
+
}
|
|
1665
|
+
return r;
|
|
1666
|
+
}
|
|
1667
|
+
async _initialSlide(e) {
|
|
1668
|
+
let t = this.engine;
|
|
1669
|
+
if (this._hiddenMode !== "skip" || !t || this.slideCount === 0 || t.availableSlideCount === 0 && !await this._waitForSlide(t, 0, () => e === this._navigationGeneration) || !t.isHidden(0)) return 0;
|
|
1670
|
+
let n = await this._step(1, e);
|
|
1671
|
+
return n === 0 ? 0 : n;
|
|
1672
|
+
}
|
|
1673
|
+
_dim() {
|
|
1674
|
+
return {
|
|
1675
|
+
color: this.opts.hiddenSlideDim?.color ?? Bt.color,
|
|
1676
|
+
opacity: this.opts.hiddenSlideDim?.opacity ?? Bt.opacity
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
async setHiddenSlideMode(e) {
|
|
1680
|
+
let t = this._beginNavigation();
|
|
1681
|
+
this._hiddenMode = e;
|
|
1682
|
+
let n = this.currentSlide;
|
|
1683
|
+
if (e === "skip" && this.engine) {
|
|
1684
|
+
let e = this.engine;
|
|
1685
|
+
if (this.currentSlide >= e.availableSlideCount && !await this._waitForSlide(e, this.currentSlide, () => t === this._navigationGeneration)) return;
|
|
1686
|
+
e.isHidden(this.currentSlide) && (n = await this._step(1, t), n === this.currentSlide && (n = await this._step(-1, t)));
|
|
1687
|
+
}
|
|
1688
|
+
if (t !== this._navigationGeneration) return;
|
|
1689
|
+
let r = n !== this.currentSlide;
|
|
1690
|
+
r && this._invalidateElementSelection(!1), this.currentSlide = n, await this.renderCurrentSlide(), r && !this.destroyed && this._emitSelectionContextChange();
|
|
1691
|
+
}
|
|
1692
|
+
get hiddenSlideMode() {
|
|
1693
|
+
return this._hiddenMode;
|
|
1694
|
+
}
|
|
1695
|
+
get visibleSlideCount() {
|
|
1696
|
+
if (!this.engine) return 0;
|
|
1697
|
+
let e = this.engine;
|
|
1698
|
+
return Fe((t) => e.isHidden(t), this.slideCount);
|
|
1699
|
+
}
|
|
1700
|
+
get slideIndex() {
|
|
1701
|
+
return this.currentSlide;
|
|
1702
|
+
}
|
|
1703
|
+
get slideCount() {
|
|
1704
|
+
return this.engine?.slideCount ?? 0;
|
|
1705
|
+
}
|
|
1706
|
+
get availableSlideCount() {
|
|
1707
|
+
return this.engine?.availableSlideCount ?? this.slideCount;
|
|
1708
|
+
}
|
|
1709
|
+
get layoutComplete() {
|
|
1710
|
+
return this.engine?.layoutComplete ?? !0;
|
|
1711
|
+
}
|
|
1712
|
+
async waitUntilLayoutComplete() {
|
|
1713
|
+
await this.errorRouter.ownBackgroundLifecycle(async () => {
|
|
1714
|
+
await this.engine?.waitUntilLayoutComplete?.();
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
getNotes(e) {
|
|
1718
|
+
return this.engine?.getNotes(e) ?? null;
|
|
1719
|
+
}
|
|
1720
|
+
get canvasElement() {
|
|
1721
|
+
return this.canvas;
|
|
1722
|
+
}
|
|
1723
|
+
_naturalWidthPx() {
|
|
1724
|
+
let e = this.engine?.slideWidth ?? 0;
|
|
1725
|
+
return e > 0 ? e / M : 0;
|
|
1726
|
+
}
|
|
1727
|
+
_targetWidth() {
|
|
1728
|
+
if (this._scale === null) return this.opts.width ?? (this.canvas.offsetWidth || 960);
|
|
1729
|
+
let e = this._naturalWidthPx();
|
|
1730
|
+
return e <= 0 ? this.opts.width ?? (this.canvas.offsetWidth || 960) : Math.round(e * this._scale);
|
|
1731
|
+
}
|
|
1732
|
+
getScale() {
|
|
1733
|
+
if (this._scale !== null) return this._scale;
|
|
1734
|
+
let e = this._naturalWidthPx();
|
|
1735
|
+
return e <= 0 ? 1 : this._targetWidth() / e;
|
|
1736
|
+
}
|
|
1737
|
+
_zoomMin() {
|
|
1738
|
+
return this.opts.zoomMin ?? .1;
|
|
1739
|
+
}
|
|
1740
|
+
_zoomMax() {
|
|
1741
|
+
return this.opts.zoomMax ?? 4;
|
|
1742
|
+
}
|
|
1743
|
+
async setScale(e) {
|
|
1744
|
+
let t = ue(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1745
|
+
this._scale = t, await this.renderCurrentSlide(), n && this.opts.onScaleChange?.(t);
|
|
1746
|
+
}
|
|
1747
|
+
async zoomIn() {
|
|
1748
|
+
await this.setScale(ye(this.getScale()));
|
|
1749
|
+
}
|
|
1750
|
+
async zoomOut() {
|
|
1751
|
+
await this.setScale(Se(this.getScale()));
|
|
1752
|
+
}
|
|
1753
|
+
async fitWidth() {
|
|
1754
|
+
await this._fit("width");
|
|
1755
|
+
}
|
|
1756
|
+
async fitPage() {
|
|
1757
|
+
await this._fit("page");
|
|
1758
|
+
}
|
|
1759
|
+
async _fit(e) {
|
|
1760
|
+
if (!this.engine) return;
|
|
1761
|
+
let t = this.wrapper.parentElement;
|
|
1762
|
+
if (!t) return;
|
|
1763
|
+
let n = oe({
|
|
1764
|
+
contentWidth: this.engine.slideWidth / M,
|
|
1765
|
+
contentHeight: this.engine.slideHeight / M,
|
|
1766
|
+
containerWidth: t.clientWidth,
|
|
1767
|
+
containerHeight: t.clientHeight
|
|
1768
|
+
}, e);
|
|
1769
|
+
n <= 0 || await this.setScale(n);
|
|
1770
|
+
}
|
|
1771
|
+
async renderCurrentSlide() {
|
|
1772
|
+
let e = this.engine;
|
|
1773
|
+
if (!e) return;
|
|
1774
|
+
let t = this.currentSlide, n = ++this._renderProgressGeneration;
|
|
1775
|
+
this._setLoading(t >= this.availableSlideCount && !this.layoutComplete);
|
|
1776
|
+
let r = this.renderDispatcher.begin();
|
|
1777
|
+
try {
|
|
1778
|
+
if (t >= e.availableSlideCount && !await this._waitForSlide(e, t, () => n === this._renderProgressGeneration && this.renderDispatcher.isCurrent(r) && e === this.engine && t === this.currentSlide)) return;
|
|
1779
|
+
let i = this._hiddenMode === "dim" && e.isHidden(t) ? this._dim() : void 0, a = this._targetWidth(), o = this.opts.dpr ?? (window.devicePixelRatio || 1), s = a / e.slideWidth, c = Math.round(e.slideHeight * s);
|
|
1780
|
+
this.canvas.style.width = `${a}px`, this.canvas.style.height = `${c}px`, this.handle?.destroy(), this.handle = null;
|
|
1781
|
+
let l = this._mode === "worker", u = [], d = (e) => u.push(e);
|
|
1782
|
+
if (this.opts.enableMediaPlayback) {
|
|
1783
|
+
let n = await e.presentSlide(this.canvas, t, {
|
|
1784
|
+
width: a,
|
|
1785
|
+
dpr: o,
|
|
1786
|
+
dim: i,
|
|
1787
|
+
onTextRun: d,
|
|
1788
|
+
onError: (e) => {
|
|
1789
|
+
this.renderDispatcher.isCurrent(r) && this._reportRenderError(e);
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
if (!this.renderDispatcher.isCurrent(r)) {
|
|
1793
|
+
n.destroy();
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
this.handle = n;
|
|
1797
|
+
} else if (l) {
|
|
1798
|
+
let e = await Z(this.engine, this.canvas, t, "worker", {
|
|
1799
|
+
width: a,
|
|
1800
|
+
dpr: o,
|
|
1801
|
+
dim: i,
|
|
1802
|
+
onTextRun: d
|
|
1803
|
+
});
|
|
1804
|
+
if (!this.renderDispatcher.commitBitmap(r, e)) return;
|
|
1805
|
+
} else if (await Z(this.engine, this.canvas, t, "main", {
|
|
1806
|
+
width: a,
|
|
1807
|
+
dpr: o,
|
|
1808
|
+
onTextRun: d,
|
|
1809
|
+
dim: i
|
|
1810
|
+
}), !this.renderDispatcher.isCurrent(r)) return;
|
|
1811
|
+
this._renderedSlide = t, this._emitSlideChange(!0), this.textLayer && this._buildTextLayer(this.textLayer, u, a, c), this._find.setSlideRuns(t, u), this._buildHighlightLayer(u, a, c);
|
|
1812
|
+
} catch (t) {
|
|
1813
|
+
if (!this.renderDispatcher.isCurrent(r) && !(e === this.engine && this._layoutFailed)) return;
|
|
1814
|
+
throw t;
|
|
1815
|
+
} finally {
|
|
1816
|
+
n === this._renderProgressGeneration && this._setLoading(!1);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
_bindLayoutPresentation(e) {
|
|
1820
|
+
this._unbindLayoutPresentation(), this._layoutFailed = !1;
|
|
1821
|
+
let t = !0;
|
|
1822
|
+
this._layoutUnsubscribe = Pt(e, () => ({
|
|
1823
|
+
availableSlides: e.availableSlideCount,
|
|
1824
|
+
slideCount: e.slideCount,
|
|
1825
|
+
exact: e.layoutComplete,
|
|
1826
|
+
complete: e.layoutComplete
|
|
1827
|
+
}), (n) => {
|
|
1828
|
+
if (t) {
|
|
1829
|
+
t = !1;
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
this._onLayoutPublication(e, n);
|
|
1833
|
+
}, (e) => this._reportRenderError(e));
|
|
1834
|
+
}
|
|
1835
|
+
_unbindLayoutPresentation() {
|
|
1836
|
+
this._layoutUnsubscribe?.(), this._layoutUnsubscribe = null, this._layoutFailed = !1, this._navigationGeneration++, this._renderProgressGeneration++, this._wakeLayoutWaiters(), this._setLoading(!1);
|
|
1837
|
+
}
|
|
1838
|
+
_beginNavigation() {
|
|
1839
|
+
let e = ++this._navigationGeneration;
|
|
1840
|
+
return this._wakeLayoutWaiters(), e;
|
|
1841
|
+
}
|
|
1842
|
+
_onLayoutPublication(e, t) {
|
|
1843
|
+
if (!(this.destroyed || e !== this.engine)) {
|
|
1844
|
+
if (this._wakeLayoutWaiters(), t.error !== void 0) {
|
|
1845
|
+
this._layoutFailed = !0, this.errorRouter.reportBackground(t.error, this.opts.onLayoutComplete !== void 0);
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
this._renderedSlide === this.currentSlide && this._emitSlideChange();
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
async _waitForSlide(e, t, n) {
|
|
1852
|
+
return await this.errorRouter.ownBackgroundLifecycle(async () => {
|
|
1853
|
+
for (; !this.destroyed && n() && e === this.engine && t >= e.availableSlideCount && !e.layoutComplete && !this._layoutFailed;) await new Promise((e) => this._layoutWaiters.add(e));
|
|
1854
|
+
return this.destroyed || e !== this.engine || ((e.layoutComplete || this._layoutFailed) && await e.waitUntilLayoutComplete?.(), !n()) ? !1 : t < e.availableSlideCount;
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
_wakeLayoutWaiters() {
|
|
1858
|
+
for (let e of this._layoutWaiters) e();
|
|
1859
|
+
this._layoutWaiters.clear();
|
|
1860
|
+
}
|
|
1861
|
+
_emitSlideChange(e = !1) {
|
|
1862
|
+
let t = this.slideCount, n = this.availableSlideCount, r = this.layoutComplete;
|
|
1863
|
+
!e && this.currentSlide === this._lastReportedSlide && t === this._lastReportedTotal && n === this._lastReportedAvailable && r === this._lastReportedLayoutComplete || (this._lastReportedSlide = this.currentSlide, this._lastReportedTotal = t, this._lastReportedAvailable = n, this._lastReportedLayoutComplete = r, this.opts.onSlideChange?.(this.currentSlide, t, r));
|
|
1864
|
+
}
|
|
1865
|
+
_setLoading(e) {
|
|
1866
|
+
this._loadingLayer.style.display = e ? "flex" : "none";
|
|
1867
|
+
}
|
|
1868
|
+
_buildHighlightLayer(e, t, n) {
|
|
1869
|
+
let r = this.highlightLayer;
|
|
1870
|
+
r && L(r, e, this._find.slideHighlights(this.currentSlide), t, n, (e) => this._measureForFont(e), this.opts.findHighlightColors);
|
|
1871
|
+
}
|
|
1872
|
+
_measureForFont(e) {
|
|
1873
|
+
this._measureCtx ||= document.createElement("canvas").getContext("2d");
|
|
1874
|
+
let t = this._measureCtx;
|
|
1875
|
+
return t ? (t.font = e, (e) => t.measureText(e).width) : (e) => e.length;
|
|
1876
|
+
}
|
|
1877
|
+
async _collectSlideRuns(e) {
|
|
1878
|
+
return this.engine ? this.engine.collectSlideRuns(e, this._targetWidth()) : [];
|
|
1879
|
+
}
|
|
1880
|
+
async findText(e, t = {}) {
|
|
1881
|
+
let n = this.engine;
|
|
1882
|
+
if (!n) return [];
|
|
1883
|
+
let r = ++this._findGeneration;
|
|
1884
|
+
if (e.length === 0) return this._find.invalidate(), this._redrawHighlights(), [];
|
|
1885
|
+
if (n.layoutComplete || await this.errorRouter.ownBackgroundLifecycle(() => n.waitUntilLayoutComplete()), this.destroyed || r !== this._findGeneration || n !== this.engine) return [];
|
|
1886
|
+
let i = await this.errorRouter.ownAwaitable(() => this._find.find(e, t));
|
|
1887
|
+
return this.destroyed || r !== this._findGeneration || n !== this.engine ? [] : (this._redrawHighlights(), i);
|
|
1888
|
+
}
|
|
1889
|
+
async findNext() {
|
|
1890
|
+
return this._activateMatch(this._find.next());
|
|
1891
|
+
}
|
|
1892
|
+
async findPrev() {
|
|
1893
|
+
return this._activateMatch(this._find.prev());
|
|
1894
|
+
}
|
|
1895
|
+
clearFind() {
|
|
1896
|
+
this._invalidateFind(), this._redrawHighlights();
|
|
1897
|
+
}
|
|
1898
|
+
_invalidateFind() {
|
|
1899
|
+
this._findGeneration++, this._find.invalidate();
|
|
1900
|
+
}
|
|
1901
|
+
async _activateMatch(e) {
|
|
1902
|
+
return e ? (e.location.slide === this.currentSlide ? this._redrawHighlights() : await this.goToSlide(e.location.slide), e) : (this._redrawHighlights(), null);
|
|
1903
|
+
}
|
|
1904
|
+
_redrawHighlights() {
|
|
1905
|
+
let e = this._find.slideRuns(this.currentSlide) ?? [], t = this._targetWidth(), n = this.engine ? Math.round(this.engine.slideHeight * (t / this.engine.slideWidth)) : 0;
|
|
1906
|
+
this._buildHighlightLayer(e, t, n);
|
|
1907
|
+
}
|
|
1908
|
+
_buildTextLayer(e, t, n, r) {
|
|
1909
|
+
I(e, t, n, r, this._hyperlinkHandler(), this.currentSlide);
|
|
1910
|
+
}
|
|
1911
|
+
_hyperlinkHandler() {
|
|
1912
|
+
if (this.opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
|
|
1913
|
+
}
|
|
1914
|
+
_onHyperlinkClick(e) {
|
|
1915
|
+
let t = this._resolveInternalSlideIndex(e);
|
|
1916
|
+
if (this.opts.onHyperlinkClick) {
|
|
1917
|
+
this.opts.onHyperlinkClick(t);
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
if (t.kind === "external") {
|
|
1921
|
+
x(t.url, void 0, this.hostWindow);
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
t.slideIndex !== void 0 && this.goToSlide(t.slideIndex).catch((e) => this._reportRenderError(e));
|
|
1925
|
+
}
|
|
1926
|
+
_resolveInternalSlideIndex(e) {
|
|
1927
|
+
if (e.kind !== "internal" || e.slideIndex !== void 0) return e;
|
|
1928
|
+
let t = this.engine?.resolveInternalTarget(e.ref, this.currentSlide);
|
|
1929
|
+
return t === void 0 ? e : {
|
|
1930
|
+
...e,
|
|
1931
|
+
slideIndex: t
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
_reportRenderError(e) {
|
|
1935
|
+
this.errorRouter.report(e);
|
|
1936
|
+
}
|
|
1937
|
+
async getResourceMetrics() {
|
|
1938
|
+
if (!this.engine) throw Error("Presentation not loaded");
|
|
1939
|
+
return await this.engine.getResourceMetrics();
|
|
1940
|
+
}
|
|
1941
|
+
getSelectionContext(e = {}) {
|
|
1942
|
+
if (this.destroyed) throw Error("PptxViewer is destroyed");
|
|
1943
|
+
return (this.textLayer ? X(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this.elementContext ? At(this.elementContext, e.maxTextCharacters) : null);
|
|
1944
|
+
}
|
|
1945
|
+
_emitSelectionContextChange() {
|
|
1946
|
+
let e = this.getSelectionContext();
|
|
1947
|
+
e?.kind === "text" && (this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline());
|
|
1948
|
+
let t = JSON.stringify(e);
|
|
1949
|
+
t !== this.selectionContextKey && (this.selectionContextKey = t, this.opts.onSelectionContextChange?.(e ? structuredClone(e) : null));
|
|
1950
|
+
}
|
|
1951
|
+
_setElementContext(e) {
|
|
1952
|
+
this.elementContext = e ? structuredClone(e) : null, this._redrawElementOutline(), this._emitSelectionContextChange();
|
|
1953
|
+
}
|
|
1954
|
+
_invalidateElementSelection(e = !0) {
|
|
1955
|
+
this.elementHitGeneration++, this.elementContext = null, this._redrawElementOutline(), e && this._emitSelectionContextChange();
|
|
1956
|
+
}
|
|
1957
|
+
_redrawElementOutline() {
|
|
1958
|
+
let e = this.elementContext, t = this.engine;
|
|
1959
|
+
if (!e || !t || e.slideIndex !== this.currentSlide) {
|
|
1960
|
+
E(this.elementLayer, null);
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
E(this.elementLayer, {
|
|
1964
|
+
x: e.bounds.x / t.slideWidth,
|
|
1965
|
+
y: e.bounds.y / t.slideHeight,
|
|
1966
|
+
width: e.bounds.width / t.slideWidth,
|
|
1967
|
+
height: e.bounds.height / t.slideHeight,
|
|
1968
|
+
rotation: e.bounds.rotation
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
async _onElementClick(e) {
|
|
1972
|
+
this.destroyed || e.defaultPrevented || e.button !== 0 || await this._resolveContextAt(e);
|
|
1973
|
+
}
|
|
1974
|
+
_onContextMenu(e) {
|
|
1975
|
+
let t;
|
|
1976
|
+
this.opts.onContextMenu?.({
|
|
1977
|
+
originalEvent: e,
|
|
1978
|
+
getContext: () => t ??= this._resolveContextAt(e)
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
async _resolveContextAt(e) {
|
|
1982
|
+
let t = this.engine;
|
|
1983
|
+
if (this.destroyed || !t) return null;
|
|
1984
|
+
if (this.textLayer && X(this.wrapper, this.wrapper.ownerDocument?.getSelection?.() ?? null)) return this._emitSelectionContextChange(), this.destroyed ? null : this.getSelectionContext();
|
|
1985
|
+
if (!this.opts.enableElementSelection) return this.getSelectionContext();
|
|
1986
|
+
let n = this.canvas.getBoundingClientRect();
|
|
1987
|
+
if (n.width <= 0 || n.height <= 0) return this._invalidateElementSelection(), null;
|
|
1988
|
+
let r = e.clientX - n.left, i = e.clientY - n.top;
|
|
1989
|
+
if (r < 0 || i < 0 || r > n.width || i > n.height) return this._invalidateElementSelection(), null;
|
|
1990
|
+
let a = ++this.elementHitGeneration, o = this.currentSlide, s = {
|
|
1991
|
+
x: r / n.width * t.slideWidth,
|
|
1992
|
+
y: i / n.height * t.slideHeight
|
|
1993
|
+
}, c;
|
|
1994
|
+
try {
|
|
1995
|
+
c = await t.getElementContextAt(o, s, {
|
|
1996
|
+
tolerance: this.elementHitTolerance / n.width * t.slideWidth,
|
|
1997
|
+
maxTextCharacters: G
|
|
1998
|
+
});
|
|
1999
|
+
} catch (e) {
|
|
2000
|
+
if (this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine) return null;
|
|
2001
|
+
throw e;
|
|
2002
|
+
}
|
|
2003
|
+
return this.destroyed || a !== this.elementHitGeneration || o !== this.currentSlide || t !== this.engine ? null : (this._setElementContext(c), this.destroyed ? null : this.getSelectionContext());
|
|
2004
|
+
}
|
|
2005
|
+
destroy() {
|
|
2006
|
+
this.destroyed || (this.destroyed = !0, this.errorRouter.close(), this.renderDispatcher.destroy(), o(this.canvas), this.handle?.destroy(), this.handle = null, this._unbindLayoutPresentation(), this.presentationOwner.close(), this._invalidateFind(), this.selectionChangeListener &&= (this.wrapper.ownerDocument.removeEventListener("selectionchange", this.selectionChangeListener), null), this.elementHitGeneration++, this.elementClickListener &&= (this.wrapper.removeEventListener("click", this.elementClickListener), null), this.contextMenuListener &&= (this.wrapper.removeEventListener("contextmenu", this.contextMenuListener), null), this.elementContext = null, this.canvasMount.restore());
|
|
2007
|
+
}
|
|
2008
|
+
}, Vt = 150, Ht = "0 1px 3px rgba(0,0,0,0.2)", Ut = 12, Wt;
|
|
2009
|
+
function Gt() {
|
|
2010
|
+
return Wt ??= import("./comment-ui-runtime-BelHJt73.js");
|
|
2011
|
+
}
|
|
2012
|
+
var $ = 440, Kt = 20, qt = Symbol("PptxScrollViewer.borrowedPresentation"), Jt = class e {
|
|
2013
|
+
_presentationOwner;
|
|
2014
|
+
get _pres() {
|
|
2015
|
+
return this._presentationOwner.current;
|
|
2016
|
+
}
|
|
2017
|
+
_borrowed;
|
|
2018
|
+
_opts;
|
|
2019
|
+
_errorRouter;
|
|
2020
|
+
_container;
|
|
2021
|
+
_wrapper;
|
|
2022
|
+
_scrollHost;
|
|
2023
|
+
_spacer;
|
|
2024
|
+
_mode;
|
|
2025
|
+
_scale = 1;
|
|
2026
|
+
_scaleEstablished = !1;
|
|
2027
|
+
_pendingScale = null;
|
|
2028
|
+
_slots = /* @__PURE__ */ new Map();
|
|
2029
|
+
_free = [];
|
|
2030
|
+
_uniformSlideHeight = 0;
|
|
2031
|
+
_lastRange = null;
|
|
2032
|
+
_lastTopIndex = -1;
|
|
2033
|
+
_lastReportedTotal = -1;
|
|
2034
|
+
_lastReportedLayoutComplete = null;
|
|
2035
|
+
_layoutUnsubscribe = null;
|
|
2036
|
+
_scrollListener = null;
|
|
2037
|
+
_selectionChangeListener = null;
|
|
2038
|
+
_selectionContextKey = "null";
|
|
2039
|
+
_elementClickListener = null;
|
|
2040
|
+
_contextMenuListener = null;
|
|
2041
|
+
_commentOutsidePointerListener = null;
|
|
2042
|
+
_elementContext = null;
|
|
2043
|
+
_activeCommentId = null;
|
|
2044
|
+
_activeCommentSlide = null;
|
|
2045
|
+
_commentNavigationGeneration = 0;
|
|
2046
|
+
_commentUi = null;
|
|
2047
|
+
_commentGeometryScheduled = !1;
|
|
2048
|
+
_commentGeometryFrame = null;
|
|
2049
|
+
_pendingCommentGeometry = /* @__PURE__ */ new Map();
|
|
2050
|
+
_hasComments = !1;
|
|
2051
|
+
_reviewOriginPx = 0;
|
|
2052
|
+
_commentScanFrontier = 0;
|
|
2053
|
+
_layoutWaiters = /* @__PURE__ */ new Set();
|
|
2054
|
+
_layoutFailed = !1;
|
|
2055
|
+
_elementHitGeneration = 0;
|
|
2056
|
+
_elementHitTolerance;
|
|
2057
|
+
_destroyed = !1;
|
|
2058
|
+
_slideInFlight = /* @__PURE__ */ new Set();
|
|
2059
|
+
_renderEpoch = 0;
|
|
2060
|
+
_settleTimer = null;
|
|
2061
|
+
_wheelListener = null;
|
|
2062
|
+
_pendingZoomAnchor = null;
|
|
2063
|
+
_resizeObserver = null;
|
|
2064
|
+
_prevBase = 0;
|
|
2065
|
+
_lastFitWidth = 0;
|
|
2066
|
+
_pageShadow;
|
|
2067
|
+
_find = new We(() => this.slideCount, (e) => this._collectSlideRuns(e));
|
|
2068
|
+
_findGeneration = 0;
|
|
2069
|
+
_findActive = !1;
|
|
2070
|
+
_findMeasureCtx;
|
|
2071
|
+
static fromPresentation(t, n, r = {}) {
|
|
2072
|
+
return new e(t, {
|
|
2073
|
+
...r,
|
|
2074
|
+
[qt]: n
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
constructor(e, t = {}) {
|
|
2078
|
+
if (e.tagName === "CANVAS") throw Error("PptxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-slide canvas API use PptxViewer.");
|
|
2079
|
+
this._container = e, this._opts = t, this._errorRouter = new ge("PptxScrollViewer", t.onError);
|
|
2080
|
+
let n = t.elementHitTolerance ?? 6;
|
|
2081
|
+
if (!Number.isFinite(n) || n < 0) throw RangeError("elementHitTolerance must be a finite non-negative number.");
|
|
2082
|
+
this._elementHitTolerance = n, this._pageShadow = t.pageShadow ?? Ht;
|
|
2083
|
+
let r = t[qt];
|
|
2084
|
+
this._borrowed = r !== void 0, r ? (this._presentationOwner = new T("PptxScrollViewer", r, !1), this._mode = O("PptxScrollViewer", t.mode, r), this._scanAvailableComments(r, !1)) : (this._presentationOwner = new T("PptxScrollViewer"), this._mode = O("PptxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && Gt().then((e) => {
|
|
2085
|
+
if (!this._destroyed) {
|
|
2086
|
+
this._commentUi = e;
|
|
2087
|
+
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2088
|
+
}
|
|
2089
|
+
}).catch((e) => this._reportRenderError(e)), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
2090
|
+
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
2091
|
+
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), t.comments && (this._commentOutsidePointerListener = (e) => {
|
|
2092
|
+
if (!Ae(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
|
|
2093
|
+
this._activeCommentId = null, this._activeCommentSlide = null;
|
|
2094
|
+
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2095
|
+
this._emitSelectionContextChange();
|
|
2096
|
+
}
|
|
2097
|
+
}, this._wrapper.ownerDocument.addEventListener("pointerdown", this._commentOutsidePointerListener)), this._opts.enableZoom !== !1 && (this._wheelListener = (e) => {
|
|
2098
|
+
if (!(e.ctrlKey || e.metaKey) || (e.preventDefault(), e.deltaY === 0)) return;
|
|
2099
|
+
let t = this._scrollHost.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
|
|
2100
|
+
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
2101
|
+
x: n,
|
|
2102
|
+
y: r
|
|
2103
|
+
} : null, this.setScale(xe(this._scale, e.deltaY));
|
|
2104
|
+
}, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && (this._bindLayoutPresentation(r), this.relayout());
|
|
2105
|
+
}
|
|
2106
|
+
async load(e) {
|
|
2107
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2108
|
+
if (this._borrowed) throw Error("PptxScrollViewer.load() is unsupported on a Viewer created by fromPresentation(); the borrowed presentation is already loaded.");
|
|
2109
|
+
let t = !1;
|
|
2110
|
+
try {
|
|
2111
|
+
let n = await this._presentationOwner.replace(() => J.load(e, {
|
|
2112
|
+
password: this._opts.password,
|
|
2113
|
+
useGoogleFonts: this._opts.useGoogleFonts,
|
|
2114
|
+
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
2115
|
+
resourceLimits: this._opts.resourceLimits,
|
|
2116
|
+
debug: this._opts.debug,
|
|
2117
|
+
onResourceMetrics: this._opts.onResourceMetrics,
|
|
2118
|
+
workerTimeoutMs: this._opts.workerTimeoutMs,
|
|
2119
|
+
wasmUrl: this._opts.wasmUrl,
|
|
2120
|
+
math: this._opts.math,
|
|
2121
|
+
threeD: this._opts.threeD,
|
|
2122
|
+
regionMap: this._opts.regionMap,
|
|
2123
|
+
chartEx: this._opts.chartEx,
|
|
2124
|
+
mode: this._mode,
|
|
2125
|
+
progressiveLayout: this._opts.progressiveLayout,
|
|
2126
|
+
onLayoutProgress: this._opts.onLayoutProgress,
|
|
2127
|
+
onLayoutPartial: this._opts.onLayoutPartial,
|
|
2128
|
+
onLayoutComplete: this._opts.onLayoutComplete
|
|
2129
|
+
}), (e) => {
|
|
2130
|
+
if (this._invalidateElementSelection(!1), t = !0, this._invalidateFind(), this._findActive = !1, this._activeCommentId = null, this._activeCommentSlide = null, this._hasComments = !1, this._commentScanFrontier = 0, this._beginCommentNavigation(), this._unbindLayoutPresentation(), e) {
|
|
2131
|
+
for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
|
|
2132
|
+
this._lastTopIndex = -1;
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2135
|
+
if (!n) return;
|
|
2136
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2137
|
+
this._invalidateFind(), this._findActive = !1, this._activeCommentId = null, this._activeCommentSlide = null, this._hasComments = !1, this._commentScanFrontier = 0, this._scanAvailableComments(n, !1), this._bindLayoutPresentation(n);
|
|
2138
|
+
let r = [];
|
|
2139
|
+
this._relayout(r), await Promise.all(r);
|
|
2140
|
+
} catch (e) {
|
|
2141
|
+
throw this._destroyed ? Error("PptxScrollViewer is destroyed") : e instanceof Error ? e : Error(String(e));
|
|
2142
|
+
}
|
|
2143
|
+
t && !this._destroyed && this._emitSelectionContextChange();
|
|
2144
|
+
}
|
|
2145
|
+
get slideCount() {
|
|
2146
|
+
return this._pres?.slideCount ?? 0;
|
|
2147
|
+
}
|
|
2148
|
+
get availableSlideCount() {
|
|
2149
|
+
return this._pres?.availableSlideCount ?? this.slideCount;
|
|
2150
|
+
}
|
|
2151
|
+
get layoutComplete() {
|
|
2152
|
+
return this._pres?.layoutComplete ?? !0;
|
|
2153
|
+
}
|
|
2154
|
+
async waitUntilLayoutComplete() {
|
|
2155
|
+
await this._errorRouter.ownBackgroundLifecycle(async () => {
|
|
2156
|
+
await this._pres?.waitUntilLayoutComplete?.();
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
_slideWidthPx() {
|
|
2160
|
+
return this._pres.slideWidth / M * this._scale;
|
|
2161
|
+
}
|
|
2162
|
+
_slideHeightPx() {
|
|
2163
|
+
return this._pres.slideHeight / M * this._scale;
|
|
2164
|
+
}
|
|
2165
|
+
_fitWidthPx() {
|
|
2166
|
+
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
2167
|
+
let e = this._scrollHost.clientWidth || this._container.clientWidth;
|
|
2168
|
+
if (e <= 0) return 0;
|
|
2169
|
+
let { left: t, right: n } = this._padH(), r = e - t - n;
|
|
2170
|
+
return r <= 0 ? 0 : r;
|
|
2171
|
+
}
|
|
2172
|
+
_commentMarginExtent() {
|
|
2173
|
+
return this._hasCommentMargin() ? (Ut + $) * this._commentZoom() : 0;
|
|
2174
|
+
}
|
|
2175
|
+
_hasCommentMargin() {
|
|
2176
|
+
return this._commentsEnabled() && this._hasComments && this._commentsOptions()?.cards !== !1;
|
|
2177
|
+
}
|
|
2178
|
+
_commentZoom() {
|
|
2179
|
+
return this._scaleEstablished ? this._scale : 1;
|
|
2180
|
+
}
|
|
2181
|
+
_commentsEnabled() {
|
|
2182
|
+
return this._opts.comments === !0 || typeof this._opts.comments == "object";
|
|
2183
|
+
}
|
|
2184
|
+
_commentsOptions() {
|
|
2185
|
+
return typeof this._opts.comments == "object" ? this._opts.comments : void 0;
|
|
2186
|
+
}
|
|
2187
|
+
_commentSide() {
|
|
2188
|
+
let e = this._commentsOptions()?.side;
|
|
2189
|
+
return e === "left" || e === "right" ? e : (this._container.ownerDocument.defaultView?.getComputedStyle?.(this._container).direction || this._container.dir || this._container.style.direction) === "rtl" ? "left" : "right";
|
|
2190
|
+
}
|
|
2191
|
+
_syncCommentMarginGeometry(e) {
|
|
2192
|
+
if (!e) return;
|
|
2193
|
+
let t = this._commentZoom(), n = `calc(100% + ${Ut * t}px)`;
|
|
2194
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${$ * t}px`, e.style.fontSize = `${Kt}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
2195
|
+
}
|
|
2196
|
+
_scanAvailableComments(e, t) {
|
|
2197
|
+
if (!this._commentsEnabled() || this._hasComments) return;
|
|
2198
|
+
let n = this._commentsOptions()?.includeResolved === !0, r = Math.min(e.availableSlideCount, e.slideCount);
|
|
2199
|
+
for (let i = this._commentScanFrontier; i < r; i++) if (e.getComments(i).some((e) => n || e.status !== "resolved" && e.status !== "closed")) {
|
|
2200
|
+
this._commentScanFrontier = r, this._hasComments = !0, t && this._refreshDiscoveredComments();
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
this._commentScanFrontier = Math.max(this._commentScanFrontier, r);
|
|
2204
|
+
}
|
|
2205
|
+
_refreshDiscoveredComments() {
|
|
2206
|
+
this._syncSpacerWidth();
|
|
2207
|
+
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2208
|
+
}
|
|
2209
|
+
_baseScale() {
|
|
2210
|
+
if (!this._pres || this._pres.slideCount === 0) return 0;
|
|
2211
|
+
let e = this._fitWidthPx(), t = this._pres.slideWidth / M;
|
|
2212
|
+
return e <= 0 || t <= 0 ? 0 : e / t;
|
|
2213
|
+
}
|
|
2214
|
+
relayout() {
|
|
2215
|
+
this._relayout();
|
|
2216
|
+
}
|
|
2217
|
+
_relayout(e) {
|
|
2218
|
+
if (this._pres) {
|
|
2219
|
+
if (!this._scaleEstablished) {
|
|
2220
|
+
let e = this._baseScale();
|
|
2221
|
+
if (e > 0) {
|
|
2222
|
+
if (this._scale = e, this._prevBase = e, this._lastFitWidth = this._fitWidthPx(), this._scaleEstablished = !0, this._pendingScale !== null) {
|
|
2223
|
+
let e = this._pendingScale;
|
|
2224
|
+
this._pendingScale = null, e !== this._scale && (this._scale = e, this._opts.onScaleChange?.(e));
|
|
2225
|
+
}
|
|
2226
|
+
} else return;
|
|
2227
|
+
}
|
|
2228
|
+
this._recomputeHeights(), this._syncSpacer(), this._mountVisible(e);
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
_recomputeHeights() {
|
|
2232
|
+
this._uniformSlideHeight = this._slideHeightPx();
|
|
2233
|
+
}
|
|
2234
|
+
_gap() {
|
|
2235
|
+
return this._opts.gap ?? 16;
|
|
2236
|
+
}
|
|
2237
|
+
_overscan() {
|
|
2238
|
+
return this._opts.overscan ?? 1;
|
|
2239
|
+
}
|
|
2240
|
+
_mediaOverscan() {
|
|
2241
|
+
return this._opts.mediaOverscan ?? 1;
|
|
2242
|
+
}
|
|
2243
|
+
_pad() {
|
|
2244
|
+
let e = this._gap();
|
|
2245
|
+
return {
|
|
2246
|
+
leading: this._opts.paddingTop ?? e,
|
|
2247
|
+
trailing: this._opts.paddingBottom ?? e
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2250
|
+
_padH() {
|
|
2251
|
+
let e = this._gap();
|
|
2252
|
+
return {
|
|
2253
|
+
left: this._opts.paddingLeft ?? e,
|
|
2254
|
+
right: this._opts.paddingRight ?? e
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
_slideOffset(e) {
|
|
2258
|
+
return this._pad().leading + e * (this._uniformSlideHeight + this._gap());
|
|
2259
|
+
}
|
|
2260
|
+
_slideIndexAtOffset(e) {
|
|
2261
|
+
return A(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._gap(), e, 0, 0, this._pad()).topIndex;
|
|
2262
|
+
}
|
|
2263
|
+
_rangeAt(e, t) {
|
|
2264
|
+
return A(this._pres?.slideCount ?? 0, this._uniformSlideHeight, this._gap(), e, this._scrollHost.clientHeight, t, this._pad());
|
|
2265
|
+
}
|
|
2266
|
+
_range() {
|
|
2267
|
+
return this._rangeAt(this._scrollHost.scrollTop, this._overscan());
|
|
2268
|
+
}
|
|
2269
|
+
_mediaRange() {
|
|
2270
|
+
return this._rangeAt(this._scrollHost.scrollTop, this._mediaOverscan());
|
|
2271
|
+
}
|
|
2272
|
+
_rangeContains(e, t) {
|
|
2273
|
+
return t >= e.start && t <= e.end;
|
|
2274
|
+
}
|
|
2275
|
+
_syncSpacer() {
|
|
2276
|
+
let e = this._range();
|
|
2277
|
+
this._lastRange = e, this._spacer.style.height = `${e.totalHeight}px`, this._syncSpacerWidth();
|
|
2278
|
+
}
|
|
2279
|
+
_syncSpacerWidth() {
|
|
2280
|
+
let { left: e, right: t } = this._padH(), n = this._commentMarginExtent(), r = this._commentSide() === "left" ? n : 0, i = r - this._reviewOriginPx, a = Math.max(0, this._scrollHost.scrollLeft + i);
|
|
2281
|
+
this._spacer.style.width = `${this._slideWidthPx() + n + e + t}px`, i !== 0 && (this._reviewOriginPx = r, this._scrollHost.style["--ooxml-review-origin-x"] = `${r}px`, this._scrollHost.scrollLeft = a);
|
|
2282
|
+
}
|
|
2283
|
+
_onScroll() {
|
|
2284
|
+
!this._pres || !this._scaleEstablished || this._mountVisible(void 0, !1);
|
|
2285
|
+
}
|
|
2286
|
+
_mountVisible(e, t = !0) {
|
|
2287
|
+
if (!this._pres || this._pres.slideCount === 0) return;
|
|
2288
|
+
let n = this._range(), r = this._opts.enableMediaPlayback ? this._mediaRange() : null;
|
|
2289
|
+
this._lastRange = n;
|
|
2290
|
+
for (let [e, t] of [...this._slots]) (e < n.start || e > n.end) && this._recycleSlot(e, t);
|
|
2291
|
+
for (let i = n.start; i <= n.end; i++) if (this._slots.has(i)) t && this._positionSlot(this._slots.get(i), i, n);
|
|
2292
|
+
else {
|
|
2293
|
+
let t = this._acquireSlot();
|
|
2294
|
+
this._positionSlot(t, i, n), this._slots.set(i, t), this._redrawSlotComments(i, t);
|
|
2295
|
+
let a = this._renderSlot(i, t, !!r && this._rangeContains(r, i), e === void 0);
|
|
2296
|
+
e && a && i < this.availableSlideCount && e.push(a);
|
|
2297
|
+
}
|
|
2298
|
+
r && this._syncMediaPlayback(r), this._emitVisibleSlideChange(n);
|
|
2299
|
+
}
|
|
2300
|
+
_applyPageShadow(e) {
|
|
2301
|
+
this._pageShadow !== !1 && (e.style.boxShadow = this._pageShadow);
|
|
2302
|
+
}
|
|
2303
|
+
_acquireSlot() {
|
|
2304
|
+
let e = this._free.pop();
|
|
2305
|
+
if (e) return this._scrollHost.appendChild(e.wrapper), e;
|
|
2306
|
+
let t = document.createElement("div");
|
|
2307
|
+
t.style.cssText = "position:absolute;";
|
|
2308
|
+
let n = document.createElement("canvas");
|
|
2309
|
+
n.style.cssText = "display:block;background:#fff;", this._applyPageShadow(n), t.appendChild(n);
|
|
2310
|
+
let r = null;
|
|
2311
|
+
this._opts.enableTextSelection && (r = document.createElement("div"), r.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;user-select:text;-webkit-user-select:text;", t.appendChild(r));
|
|
2312
|
+
let i = document.createElement("div");
|
|
2313
|
+
i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
|
|
2314
|
+
let a = document.createElement("span");
|
|
2315
|
+
a.style.cssText = [
|
|
2316
|
+
"position:absolute",
|
|
2317
|
+
"top:0",
|
|
2318
|
+
"right:0",
|
|
2319
|
+
"bottom:0",
|
|
2320
|
+
"left:0",
|
|
2321
|
+
"display:none",
|
|
2322
|
+
"align-items:center",
|
|
2323
|
+
"justify-content:center",
|
|
2324
|
+
"background:rgba(255,255,255,0.72)",
|
|
2325
|
+
"pointer-events:none",
|
|
2326
|
+
"z-index:4"
|
|
2327
|
+
].join(";"), a.setAttribute("role", "status"), a.setAttribute("aria-live", "polite"), a.setAttribute("aria-label", "Loading slide");
|
|
2328
|
+
let o = document.createElement("progress");
|
|
2329
|
+
o.setAttribute("aria-hidden", "true"), a.appendChild(o), t.appendChild(a);
|
|
2330
|
+
let s = null, c = null, l = null;
|
|
2331
|
+
this._commentsEnabled() && (s = document.createElement("div"), s.style.cssText = "position:absolute;inset:0;overflow:hidden;pointer-events:none;", t.appendChild(s), this._commentsOptions()?.cards !== !1 && (c = document.createElement("div"), c.style.cssText = "position:absolute;top:0;height:100%;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;pointer-events:auto;", this._syncCommentMarginGeometry(c), this._commentsOptions()?.connectors !== void 0 && (l = document.createElement("div"), l.style.cssText = "position:absolute;top:0;left:0;overflow:visible;pointer-events:none;", t.appendChild(l)), t.appendChild(c)));
|
|
2332
|
+
let u = me(t, this._opts.enableElementSelection === !0);
|
|
2333
|
+
return this._scrollHost.appendChild(t), {
|
|
2334
|
+
wrapper: t,
|
|
2335
|
+
canvas: n,
|
|
2336
|
+
textLayer: r,
|
|
2337
|
+
highlightLayer: i,
|
|
2338
|
+
elementLayer: u,
|
|
2339
|
+
loadingLayer: a,
|
|
2340
|
+
commentMarkerLayer: s,
|
|
2341
|
+
commentMargin: c,
|
|
2342
|
+
commentDecorationLayer: l,
|
|
2343
|
+
commentElementBounds: Object.freeze([]),
|
|
2344
|
+
commentGeometry: null,
|
|
2345
|
+
commentAnchorSlide: -1,
|
|
2346
|
+
commentAnchorGeneration: 0,
|
|
2347
|
+
renderedSlide: -1,
|
|
2348
|
+
renderedScale: -1,
|
|
2349
|
+
dispatcher: new D(n, this._mode === "worker" && !this._opts.enableMediaPlayback),
|
|
2350
|
+
presentationHandle: null,
|
|
2351
|
+
mediaInteractive: !1,
|
|
2352
|
+
renderGeneration: 0,
|
|
2353
|
+
presentationGeneration: 0
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
_recycleSlot(e, t) {
|
|
2357
|
+
this._slots.delete(e), t.renderGeneration++, t.presentationGeneration++, t.presentationHandle?.destroy(), t.presentationHandle = null, t.mediaInteractive = !1, t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new D(t.canvas, this._mode === "worker" && !this._opts.enableMediaPlayback)), t.textLayer && (t.textLayer.innerHTML = "", t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = ""), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.loadingLayer.style.display = "none", t.commentMarkerLayer && (t.commentMarkerLayer.replaceChildren(), t.commentMarkerLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren(), t.commentDecorationLayer.style.visibility = ""), t.commentElementBounds = Object.freeze([]), t.commentGeometry = null, t.commentAnchorSlide = -1, t.commentAnchorGeneration++, E(t.elementLayer, null), t.canvas.style.height = "", t.renderedSlide = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
2358
|
+
}
|
|
2359
|
+
_positionSlot(e, t, n) {
|
|
2360
|
+
e.wrapper.dataset.slideIndex = String(t), e.wrapper.style.top = `${this._slideOffset(t)}px`;
|
|
2361
|
+
let r = this._slideWidthPx();
|
|
2362
|
+
if (e.wrapper.style.width = `${r}px`, e.wrapper.style.height = `${this._slideHeightPx()}px`, this._syncCommentMarginGeometry(e.commentMargin), e.commentDecorationLayer) {
|
|
2363
|
+
let t = this._commentMarginExtent();
|
|
2364
|
+
e.commentDecorationLayer.style.left = this._commentSide() === "left" ? `${-t}px` : "0px", e.commentDecorationLayer.style.width = `${r + t}px`, e.commentDecorationLayer.style.height = `${this._slideHeightPx()}px`;
|
|
2365
|
+
}
|
|
2366
|
+
this._redrawElementOutlineForSlot(t, e);
|
|
2367
|
+
let { left: i } = this._padH(), a = Math.max(i, (this._scrollHost.clientWidth - r) / 2);
|
|
2368
|
+
e.wrapper.style.left = this._commentSide() === "left" && this._commentsEnabled() ? `calc(${a}px + var(--ooxml-review-origin-x, 0px))` : `${a}px`;
|
|
2369
|
+
}
|
|
2370
|
+
_dpr() {
|
|
2371
|
+
return this._opts.dpr ?? (typeof window < "u" && window.devicePixelRatio || 1);
|
|
2372
|
+
}
|
|
2373
|
+
_renderSlot(e, t, n = !1, r = !0) {
|
|
2374
|
+
if (!this._pres || t.renderedSlide === e) return null;
|
|
2375
|
+
if (e >= this.availableSlideCount && !this.layoutComplete) return t.renderedSlide = -1, t.mediaInteractive = !1, t.loadingLayer.style.display = "flex", null;
|
|
2376
|
+
t.renderedSlide = e;
|
|
2377
|
+
let i = ++t.renderGeneration;
|
|
2378
|
+
t.loadingLayer.style.display = e >= this.availableSlideCount && !this.layoutComplete ? "flex" : "none";
|
|
2379
|
+
let a = this._dpr(), o = this._slideWidthPx(), s = this._renderEpoch, c = this._scale, l = t.dispatcher, u = l.begin();
|
|
2380
|
+
if (this._opts.enableMediaPlayback && n) return t.mediaInteractive = !0, this._trackSlotLoading(e, t, i, this._renderInteractiveSlot(e, t, o, a, c, s, r));
|
|
2381
|
+
if (t.mediaInteractive = !1, this._mode === "worker") return this._trackSlotLoading(e, t, i, this._renderSlotBitmap(e, t, o, a, c, i, l, u, r));
|
|
2382
|
+
let d = [], f = !!this._opts.enableTextSelection && !!t.textLayer, p = f || this._findActive, m = p ? (e) => d.push(e) : void 0, h = t.canvas;
|
|
2383
|
+
return this._trackSlotLoading(e, t, i, Z(this._pres, h, e, "main", {
|
|
2384
|
+
width: o,
|
|
2385
|
+
dpr: a,
|
|
2386
|
+
onTextRun: m
|
|
2387
|
+
}).then(() => {
|
|
2388
|
+
i !== t.renderGeneration || !l.isCurrent(u) || h !== t.canvas || s !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e || (t.renderedScale = c, f && t.textLayer && I(t.textLayer, d, Math.round(o), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e), p && this._refreshFindRuns(e, d), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t));
|
|
2389
|
+
}).catch((n) => {
|
|
2390
|
+
if (i === t.renderGeneration && l.isCurrent(u) && h === t.canvas && s === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e) if (r) this._reportRenderError(n);
|
|
2391
|
+
else throw n;
|
|
2392
|
+
}));
|
|
2393
|
+
}
|
|
2394
|
+
async _trackSlotLoading(e, t, n, r) {
|
|
2395
|
+
try {
|
|
2396
|
+
await r;
|
|
2397
|
+
} finally {
|
|
2398
|
+
n === t.renderGeneration && this._slots.get(e) === t && t.renderedSlide === e && (t.loadingLayer.style.display = "none");
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
_bindLayoutPresentation(e) {
|
|
2402
|
+
this._unbindLayoutPresentation();
|
|
2403
|
+
let t = !0;
|
|
2404
|
+
this._layoutUnsubscribe = Pt(e, () => ({
|
|
2405
|
+
availableSlides: e.availableSlideCount,
|
|
2406
|
+
slideCount: e.slideCount,
|
|
2407
|
+
exact: e.layoutComplete,
|
|
2408
|
+
complete: e.layoutComplete
|
|
2409
|
+
}), (n) => {
|
|
2410
|
+
if (t) {
|
|
2411
|
+
t = !1;
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
this._onLayoutPublication(e, n);
|
|
2415
|
+
}, (e) => this._reportRenderError(e));
|
|
2416
|
+
}
|
|
2417
|
+
_unbindLayoutPresentation() {
|
|
2418
|
+
this._layoutUnsubscribe?.(), this._layoutUnsubscribe = null, this._layoutFailed = !1, this._wakeLayoutWaiters();
|
|
2419
|
+
}
|
|
2420
|
+
_onLayoutPublication(e, t) {
|
|
2421
|
+
if (this._destroyed || e !== this._pres) return;
|
|
2422
|
+
if (this._wakeLayoutWaiters(), t.error !== void 0) {
|
|
2423
|
+
this._layoutFailed = !0, this._errorRouter.reportBackground(t.error, this._opts.onLayoutComplete !== void 0);
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
this._scanAvailableComments(e, !0);
|
|
2427
|
+
let n = this._opts.enableMediaPlayback ? this._mediaRange() : null;
|
|
2428
|
+
for (let [t, r] of this._slots) t >= e.availableSlideCount || r.renderedSlide === t || this._renderSlot(t, r, !!n && this._rangeContains(n, t));
|
|
2429
|
+
this._lastRange && this._emitVisibleSlideChange(this._lastRange);
|
|
2430
|
+
}
|
|
2431
|
+
_wakeLayoutWaiters() {
|
|
2432
|
+
for (let e of this._layoutWaiters) e();
|
|
2433
|
+
this._layoutWaiters.clear();
|
|
2434
|
+
}
|
|
2435
|
+
_beginCommentNavigation() {
|
|
2436
|
+
let e = ++this._commentNavigationGeneration;
|
|
2437
|
+
return this._wakeLayoutWaiters(), e;
|
|
2438
|
+
}
|
|
2439
|
+
async _waitForSlideMetadata(e, t, n) {
|
|
2440
|
+
return await this._errorRouter.ownBackgroundLifecycle(async () => {
|
|
2441
|
+
for (; !this._destroyed && n === this._commentNavigationGeneration && e === this._pres && t >= e.availableSlideCount && !e.layoutComplete && !this._layoutFailed;) await new Promise((e) => this._layoutWaiters.add(e));
|
|
2442
|
+
return this._destroyed || e !== this._pres || ((e.layoutComplete || this._layoutFailed) && await e.waitUntilLayoutComplete?.(), n !== this._commentNavigationGeneration) ? !1 : t < e.availableSlideCount;
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
_emitVisibleSlideChange(e) {
|
|
2446
|
+
if (!this._pres) return;
|
|
2447
|
+
let t = this._pres.slideCount, n = this.layoutComplete;
|
|
2448
|
+
e.topIndex === this._lastTopIndex && t === this._lastReportedTotal && n === this._lastReportedLayoutComplete || (this._lastTopIndex = e.topIndex, this._lastReportedTotal = t, this._lastReportedLayoutComplete = n, this._opts.onVisibleSlideChange?.(e.topIndex, t, n));
|
|
2449
|
+
}
|
|
2450
|
+
_renderInteractiveSlot(e, t, n, r, i, a, o = !0) {
|
|
2451
|
+
if (!this._pres) return Promise.resolve();
|
|
2452
|
+
let s = ++t.presentationGeneration;
|
|
2453
|
+
t.presentationHandle?.destroy(), t.presentationHandle = null;
|
|
2454
|
+
let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0;
|
|
2455
|
+
return this._pres.presentSlide(t.canvas, e, {
|
|
2456
|
+
width: n,
|
|
2457
|
+
dpr: r,
|
|
2458
|
+
onTextRun: d,
|
|
2459
|
+
onError: (e) => {
|
|
2460
|
+
s === t.presentationGeneration && this._reportRenderError(e);
|
|
2461
|
+
}
|
|
2462
|
+
}).then((r) => {
|
|
2463
|
+
if (s !== t.presentationGeneration || !t.mediaInteractive || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
2464
|
+
r.destroy();
|
|
2465
|
+
return;
|
|
2466
|
+
}
|
|
2467
|
+
t.presentationHandle = r, t.renderedScale = i, l && t.textLayer && I(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e), u && this._refreshFindRuns(e, c), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t);
|
|
2468
|
+
}).catch((e) => {
|
|
2469
|
+
if (s === t.presentationGeneration) if (o) this._reportRenderError(e);
|
|
2470
|
+
else throw e;
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
_syncMediaPlayback(e = this._mediaRange()) {
|
|
2474
|
+
if (this._opts.enableMediaPlayback) for (let [t, n] of this._slots) {
|
|
2475
|
+
let r = this._rangeContains(e, t);
|
|
2476
|
+
r !== n.mediaInteractive && (r ? (n.mediaInteractive = !0, this._settleInteractiveSlot(t, n, this._slideWidthPx(), this._dpr(), this._scale, this._renderEpoch)) : (n.mediaInteractive = !1, n.presentationGeneration++, n.presentationHandle?.destroy(), n.presentationHandle = null));
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
_reportRenderError(e) {
|
|
2480
|
+
this._errorRouter.report(e);
|
|
2481
|
+
}
|
|
2482
|
+
async _renderSlotBitmap(e, t, n, r, i, a = ++t.renderGeneration, o = t.dispatcher, s = o.begin(), c = !0) {
|
|
2483
|
+
if (this._slideInFlight.has(e) || this._slots.get(e) !== t) return;
|
|
2484
|
+
let l = this._renderEpoch;
|
|
2485
|
+
this._slideInFlight.add(e);
|
|
2486
|
+
let u = t.canvas, d = !1, f = !!this._opts.enableTextSelection && !!t.textLayer, p = f || this._findActive, m = [];
|
|
2487
|
+
try {
|
|
2488
|
+
let c = await Z(this._pres, u, e, "worker", {
|
|
2489
|
+
width: n,
|
|
2490
|
+
dpr: r,
|
|
2491
|
+
onTextRun: p ? (e) => m.push(e) : void 0
|
|
2492
|
+
});
|
|
2493
|
+
if (a !== t.renderGeneration || !o.isCurrent(s) || u !== t.canvas || l !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
2494
|
+
c.close();
|
|
2495
|
+
return;
|
|
2496
|
+
}
|
|
2497
|
+
let h = {
|
|
2498
|
+
cssWidth: Math.round(c.width / r),
|
|
2499
|
+
cssHeight: Math.round(c.height / r)
|
|
2500
|
+
};
|
|
2501
|
+
if (!(this._opts.enableMediaPlayback ? o.commitBitmapTo2d(s, c, h) : o.commitBitmap(s, c, h))) return;
|
|
2502
|
+
t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", f && I(t.textLayer, m, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), p && this._refreshFindRuns(e, m), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t), d = !0;
|
|
2503
|
+
} catch (n) {
|
|
2504
|
+
if (a === t.renderGeneration && o.isCurrent(s) && u === t.canvas && l === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e) if (c) this._reportRenderError(n);
|
|
2505
|
+
else throw n;
|
|
2506
|
+
} finally {
|
|
2507
|
+
this._slideInFlight.delete(e);
|
|
2508
|
+
let n = this._slots.get(e);
|
|
2509
|
+
!d && n && (n !== t || l !== this._renderEpoch || a !== n.renderGeneration || !o.isCurrent(s)) && !this._slideInFlight.has(e) && !this._destroyed && !(this._opts.enableMediaPlayback && n.mediaInteractive) && this._renderSlotBitmap(e, n, this._slideWidthPx(), this._dpr(), this._scale);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
setScale(e) {
|
|
2513
|
+
let t = this._opts.zoomMin ?? .1, n = this._opts.zoomMax ?? 4, r = Math.min(n, Math.max(t, e)), i = this._pendingZoomAnchor;
|
|
2514
|
+
if (this._pendingZoomAnchor = null, !this._pres || this._pres.slideCount === 0 || !this._scaleEstablished) {
|
|
2515
|
+
this._pendingScale = r;
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
if (r === this._scale) return;
|
|
2519
|
+
let a = this._scale, o = i ? i.y : 0, s = this._scrollHost.scrollTop, c = s + o, l = this._slideIndexAtOffset(c), u = this._uniformSlideHeight, d = u > 0 ? (c - this._slideOffset(l)) / u : 0;
|
|
2520
|
+
d = Math.min(1, Math.max(0, d));
|
|
2521
|
+
let f = this._padH().left, p = this._scrollHost.scrollLeft || 0;
|
|
2522
|
+
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2523
|
+
let m = this._rangeAt(0, this._overscan());
|
|
2524
|
+
this._spacer.style.height = `${m.totalHeight}px`, this._syncSpacerWidth();
|
|
2525
|
+
let h = Math.max(0, m.totalHeight - this._scrollHost.clientHeight), g = this._slideOffset(l) + d * this._uniformSlideHeight, _ = c < this._slideOffset(0) ? s : g - o;
|
|
2526
|
+
if (this._scrollHost.scrollTop = Math.min(h, Math.max(0, _)), i) {
|
|
2527
|
+
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2528
|
+
this._scrollHost.scrollLeft = se(p, i.x - f, a, r, { maxScroll: e });
|
|
2529
|
+
}
|
|
2530
|
+
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2531
|
+
}
|
|
2532
|
+
getScale() {
|
|
2533
|
+
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2534
|
+
}
|
|
2535
|
+
zoomIn() {
|
|
2536
|
+
this.setScale(ye(this.getScale()));
|
|
2537
|
+
}
|
|
2538
|
+
zoomOut() {
|
|
2539
|
+
this.setScale(Se(this.getScale()));
|
|
2540
|
+
}
|
|
2541
|
+
fitWidth() {
|
|
2542
|
+
this._fit("width");
|
|
2543
|
+
}
|
|
2544
|
+
fitPage() {
|
|
2545
|
+
this._fit("page");
|
|
2546
|
+
}
|
|
2547
|
+
_fit(e) {
|
|
2548
|
+
if (!this._pres || this._pres.slideCount === 0) return;
|
|
2549
|
+
let t = oe({
|
|
2550
|
+
contentWidth: this._pres.slideWidth / M,
|
|
2551
|
+
contentHeight: this._pres.slideHeight / M,
|
|
2552
|
+
containerWidth: this._fitWidthPx(),
|
|
2553
|
+
containerHeight: this._scrollHost.clientHeight
|
|
2554
|
+
}, e);
|
|
2555
|
+
t <= 0 || this.setScale(t);
|
|
2556
|
+
}
|
|
2557
|
+
_previewVisible() {
|
|
2558
|
+
if (!this._pres || this._pres.slideCount === 0) return;
|
|
2559
|
+
let e = this._range(), t = this._opts.enableMediaPlayback ? this._mediaRange() : null;
|
|
2560
|
+
this._lastRange = e;
|
|
2561
|
+
for (let [t, n] of [...this._slots]) (t < e.start || t > e.end) && this._recycleSlot(t, n);
|
|
2562
|
+
for (let n = e.start; n <= e.end; n++) {
|
|
2563
|
+
let r = this._slots.get(n);
|
|
2564
|
+
if (r) this._previewSlot(r, n, e);
|
|
2565
|
+
else {
|
|
2566
|
+
let r = this._acquireSlot();
|
|
2567
|
+
this._positionSlot(r, n, e), this._slots.set(n, r), this._redrawSlotComments(n, r), this._renderSlot(n, r, !!t && this._rangeContains(t, n));
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
t && this._syncMediaPlayback(t), this._emitVisibleSlideChange(e);
|
|
2571
|
+
}
|
|
2572
|
+
_previewSlot(e, t, n) {
|
|
2573
|
+
if (this._positionSlot(e, t, n), e.canvas.style.width = `${this._slideWidthPx()}px`, e.canvas.style.height = `${this._slideHeightPx()}px`, e.textLayer && e.renderedScale > 0) {
|
|
2574
|
+
let t = this._scale / e.renderedScale;
|
|
2575
|
+
e.textLayer.style.transformOrigin = "0 0", e.textLayer.style.transform = `scale(${t})`;
|
|
2576
|
+
}
|
|
2577
|
+
if (e.renderedScale > 0) {
|
|
2578
|
+
let t = this._scale / e.renderedScale, n = Math.round(t * 1e6) / 1e6;
|
|
2579
|
+
e.commentMargin && this._commentUi?.previewReadOnlyCommentMargin(e.commentMargin, t);
|
|
2580
|
+
for (let t of e.commentMarkerLayer?.children ?? []) t.dataset.ooxmlCommentMarker !== void 0 && (t.style.transform = `translate(-50%,-50%) scale(${n})`);
|
|
2581
|
+
e.commentMarkerLayer && (e.commentMarkerLayer.style.visibility = ""), e.commentMargin && (e.commentMargin.style.visibility = ""), e.commentDecorationLayer && (e.commentDecorationLayer.style.visibility = "");
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
e.commentMarkerLayer && (e.commentMarkerLayer.style.visibility = "hidden"), e.commentMargin && (e.commentMargin.style.visibility = "hidden"), e.commentDecorationLayer && (e.commentDecorationLayer.style.visibility = "hidden");
|
|
2585
|
+
}
|
|
2586
|
+
_scheduleSettle() {
|
|
2587
|
+
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2588
|
+
this._settleTimer = null, this._settleRender();
|
|
2589
|
+
}, Vt);
|
|
2590
|
+
}
|
|
2591
|
+
_settleRender() {
|
|
2592
|
+
if (this._destroyed || !this._pres || this._pres.slideCount === 0) return;
|
|
2593
|
+
let e = this._opts.enableMediaPlayback ? this._mediaRange() : null;
|
|
2594
|
+
for (let [t, n] of [...this._slots]) e && !this._rangeContains(e, t) || n.renderedScale !== this._scale && this._settleSlot(t, n);
|
|
2595
|
+
}
|
|
2596
|
+
_settleSlot(e, t) {
|
|
2597
|
+
if (!this._pres) return;
|
|
2598
|
+
let n = this._dpr(), r = this._slideWidthPx(), i = this._scale, a = this._renderEpoch;
|
|
2599
|
+
if (this._opts.enableMediaPlayback && t.mediaInteractive) {
|
|
2600
|
+
this._settleInteractiveSlot(e, t, r, n, i, a);
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
if (this._opts.enableMediaPlayback) return;
|
|
2604
|
+
if (this._mode === "worker") {
|
|
2605
|
+
this._renderSlotBitmap(e, t, r, n, i);
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
let o = document.createElement("canvas"), s = ++t.renderGeneration;
|
|
2609
|
+
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2610
|
+
let c = new D(o, !1), l = c.begin(), u = [], d = !!this._opts.enableTextSelection && !!t.textLayer, f = d || this._findActive, p = f ? (e) => u.push(e) : void 0;
|
|
2611
|
+
Z(this._pres, o, e, "main", {
|
|
2612
|
+
width: r,
|
|
2613
|
+
dpr: n,
|
|
2614
|
+
onTextRun: p
|
|
2615
|
+
}).then(() => {
|
|
2616
|
+
if (s !== t.renderGeneration || !c.isCurrent(l) || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
2617
|
+
c.destroy();
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
let n = t.canvas;
|
|
2621
|
+
t.dispatcher.destroy(), t.wrapper.insertBefore(o, n), n.remove(), t.canvas = o, t.dispatcher = c, t.renderedScale = i, t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", d && I(t.textLayer, u, Math.round(r), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), f && this._refreshFindRuns(e, u), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t);
|
|
2622
|
+
}).catch((n) => {
|
|
2623
|
+
s === t.renderGeneration && c.isCurrent(l) && a === this._renderEpoch && this._slots.get(e) === t && t.renderedSlide === e && this._reportRenderError(n), c.destroy();
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
_settleInteractiveSlot(e, t, n, r, i, a) {
|
|
2627
|
+
if (!this._pres) return;
|
|
2628
|
+
let o = ++t.presentationGeneration, s = document.createElement("canvas");
|
|
2629
|
+
s.style.cssText = "display:block;background:#fff;", this._applyPageShadow(s);
|
|
2630
|
+
let c = [], l = !!this._opts.enableTextSelection && !!t.textLayer, u = l || this._findActive, d = u ? (e) => c.push(e) : void 0;
|
|
2631
|
+
this._pres.presentSlide(s, e, {
|
|
2632
|
+
width: n,
|
|
2633
|
+
dpr: r,
|
|
2634
|
+
onTextRun: d,
|
|
2635
|
+
onError: (e) => {
|
|
2636
|
+
o === t.presentationGeneration && this._reportRenderError(e);
|
|
2637
|
+
}
|
|
2638
|
+
}).then((r) => {
|
|
2639
|
+
if (o !== t.presentationGeneration || !t.mediaInteractive || a !== this._renderEpoch || this._slots.get(e) !== t || t.renderedSlide !== e) {
|
|
2640
|
+
r.destroy();
|
|
2641
|
+
return;
|
|
2642
|
+
}
|
|
2643
|
+
let d = t.canvas, f = t.presentationHandle;
|
|
2644
|
+
t.dispatcher.destroy(), t.wrapper.insertBefore(s, d), d.remove(), t.canvas = s, t.dispatcher = new D(s, !1), t.presentationHandle = r, t.renderedScale = i, f?.destroy(), t.textLayer && (t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = "", l && I(t.textLayer, c, Math.round(n), Math.round(this._slideHeightPx()), this._hyperlinkHandler(), e)), u && this._refreshFindRuns(e, c), this._commitSlotComments(e, t), this._redrawSlotHighlights(e, t);
|
|
2645
|
+
}).catch((e) => {
|
|
2646
|
+
o === t.presentationGeneration && this._reportRenderError(e);
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
scrollToSlide(e, t) {
|
|
2650
|
+
if (!this._pres || this._pres.slideCount === 0 || !this._scaleEstablished) return;
|
|
2651
|
+
let n = Math.max(0, Math.min(e, this._pres.slideCount - 1)), r = this._rangeAt(0, this._overscan()), i = this._slideOffset(n), a = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), o = Math.min(a, Math.max(0, i)), s = this._scrollHost;
|
|
2652
|
+
typeof s.scrollTo == "function" ? s.scrollTo({
|
|
2653
|
+
top: o,
|
|
2654
|
+
behavior: t?.behavior ?? "auto"
|
|
2655
|
+
}) : this._scrollHost.scrollTop = o, this._mountVisible();
|
|
2656
|
+
}
|
|
2657
|
+
_scrollToSlideCommentTarget(e, t, n, r) {
|
|
2658
|
+
if (!this._pres) return !1;
|
|
2659
|
+
let i = this._slots.get(e), a = new Map((i?.commentElementBounds ?? []).map((e) => [e.elementId, e.bounds])), o = r ?? (t.anchors ?? []).flatMap((e) => {
|
|
2660
|
+
if (e.type !== "drawingElement" && e.type !== "textRange" || !e.elementId) return [];
|
|
2661
|
+
let t = a.get(e.elementId);
|
|
2662
|
+
return t ? [t] : [];
|
|
2663
|
+
})[0], s = t.anchors ?? [], c = Number.isFinite(t.x) && Number.isFinite(t.y) && (s.length === 0 || s.some((e) => e.type === "slide"));
|
|
2664
|
+
if (!o && !c) return !1;
|
|
2665
|
+
let l = o ? o.x + (c ? t.x : o.width) : t.x, u = o ? o.y + (c ? t.y : 0) : t.y, d = this._slideWidthPx(), { left: f } = this._padH(), p = Math.max(f, (this._scrollHost.clientWidth - d) / 2) + this._reviewOriginPx, m = this._rangeAt(0, this._overscan()), h = Math.max(0, m.totalHeight - this._scrollHost.clientHeight), g = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, _ = Math.max(0, g - this._scrollHost.clientWidth), v = l / M * this._scale, y = u / M * this._scale, b = Math.min(h, Math.max(0, this._slideOffset(e) + y - this._scrollHost.clientHeight / 2)), x = Math.min(_, Math.max(0, p + v - this._scrollHost.clientWidth / 2)), S = this._scrollHost;
|
|
2666
|
+
return typeof S.scrollTo == "function" ? S.scrollTo({
|
|
2667
|
+
top: b,
|
|
2668
|
+
left: x,
|
|
2669
|
+
behavior: n?.behavior ?? "auto"
|
|
2670
|
+
}) : (this._scrollHost.scrollTop = b, this._scrollHost.scrollLeft = x), this._mountVisible(), !0;
|
|
2671
|
+
}
|
|
2672
|
+
async _resolveSlideCommentElementBounds(e, t) {
|
|
2673
|
+
let n = this._pres;
|
|
2674
|
+
if (!n) return;
|
|
2675
|
+
let r = (t.anchors ?? []).flatMap((e) => (e.type === "drawingElement" || e.type === "textRange") && e.elementId ? [e.elementId] : []);
|
|
2676
|
+
if (r.length === 0) return;
|
|
2677
|
+
let i = new Map((this._slots.get(e)?.commentElementBounds ?? []).map((e) => [e.elementId, e.bounds])), a = r.flatMap((e) => {
|
|
2678
|
+
let t = i.get(e);
|
|
2679
|
+
return t ? [t] : [];
|
|
2680
|
+
})[0];
|
|
2681
|
+
if (a) return a;
|
|
2682
|
+
let o = await n.getElementBoundsByIds(e, r);
|
|
2683
|
+
return r.flatMap((e) => {
|
|
2684
|
+
let t = o.find((t) => t.elementId === e);
|
|
2685
|
+
return t ? [t.bounds] : [];
|
|
2686
|
+
})[0];
|
|
2687
|
+
}
|
|
2688
|
+
async goToComment(e, t, n) {
|
|
2689
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2690
|
+
let r = this._pres;
|
|
2691
|
+
if (!r || !Number.isInteger(e) || !Number.isInteger(t) || e < 0 || e >= r.slideCount || t < 0) return !1;
|
|
2692
|
+
let i = this._beginCommentNavigation();
|
|
2693
|
+
if (e >= r.availableSlideCount && !r.layoutComplete && !await this._waitForSlideMetadata(r, e, i)) return !1;
|
|
2694
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2695
|
+
if (i !== this._commentNavigationGeneration || r !== this._pres) return !1;
|
|
2696
|
+
let a = r.getComments(e)[t];
|
|
2697
|
+
if (!a) return !1;
|
|
2698
|
+
let o = await this._resolveSlideCommentElementBounds(e, a);
|
|
2699
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2700
|
+
if (i !== this._commentNavigationGeneration || r !== this._pres) return !1;
|
|
2701
|
+
let s = a.anchors ?? [], c = Number.isFinite(a.x) && Number.isFinite(a.y) && (s.length === 0 || s.some((e) => e.type === "slide"));
|
|
2702
|
+
if (!o && !c || (this.scrollToSlide(e, n), !this._scrollToSlideCommentTarget(e, a, n, o))) return !1;
|
|
2703
|
+
this._activeCommentId = P(a, t, e), this._activeCommentSlide = e, this._elementContext = null;
|
|
2704
|
+
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2705
|
+
return this._emitSelectionContextChange(), !0;
|
|
2706
|
+
}
|
|
2707
|
+
async findText(e, t = {}) {
|
|
2708
|
+
let n = this._pres;
|
|
2709
|
+
if (!n) return [];
|
|
2710
|
+
let r = ++this._findGeneration;
|
|
2711
|
+
if (this._findActive = e.length > 0, e.length === 0) return this._find.invalidate(), this._redrawHighlights(), [];
|
|
2712
|
+
if (n.layoutComplete || await this._errorRouter.ownBackgroundLifecycle(() => n.waitUntilLayoutComplete()), this._destroyed || r !== this._findGeneration || n !== this._pres) return [];
|
|
2713
|
+
let i = await this._errorRouter.ownAwaitable(() => this._find.find(e, t));
|
|
2714
|
+
return this._destroyed || r !== this._findGeneration || n !== this._pres ? [] : (this._redrawHighlights(), i);
|
|
2715
|
+
}
|
|
2716
|
+
async findNext() {
|
|
2717
|
+
return this._activateMatch(this._find.next());
|
|
2718
|
+
}
|
|
2719
|
+
async findPrev() {
|
|
2720
|
+
return this._activateMatch(this._find.prev());
|
|
2721
|
+
}
|
|
2722
|
+
clearFind() {
|
|
2723
|
+
this._findActive = !1, this._invalidateFind(), this._redrawHighlights();
|
|
2724
|
+
}
|
|
2725
|
+
_invalidateFind() {
|
|
2726
|
+
this._findGeneration++, this._find.invalidate();
|
|
2727
|
+
}
|
|
2728
|
+
async _activateMatch(e) {
|
|
2729
|
+
return e && this.scrollToSlide(e.location.slide), this._redrawHighlights(), e;
|
|
2730
|
+
}
|
|
2731
|
+
async _collectSlideRuns(e) {
|
|
2732
|
+
return this._pres ? this._pres.collectSlideRuns(e, this._slideWidthPx()) : [];
|
|
2733
|
+
}
|
|
2734
|
+
_redrawHighlights() {
|
|
2735
|
+
for (let [e, t] of this._slots) this._redrawSlotHighlights(e, t);
|
|
2736
|
+
}
|
|
2737
|
+
_refreshFindRuns(e, t) {
|
|
2738
|
+
this._findActive && this._find.setSlideRuns(e, t);
|
|
2739
|
+
}
|
|
2740
|
+
_redrawSlotComments(e, t) {
|
|
2741
|
+
if (!this._pres || !t.commentMarkerLayer) return;
|
|
2742
|
+
let n = this._commentUi;
|
|
2743
|
+
if (!n) {
|
|
2744
|
+
t.commentMarkerLayer.replaceChildren(), t.commentMargin?.replaceChildren(), t.commentDecorationLayer?.replaceChildren(), t.commentGeometry = null;
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2747
|
+
t.commentGeometry = n.buildPptxCommentMargin(t.commentMarkerLayer, t.commentMargin, this._pres.getComments(e), t.commentElementBounds, e, this._pres.slideWidth, this._pres.slideHeight, this._activeCommentId, (t, n) => {
|
|
2748
|
+
let r = n ? t : this._activeCommentId === t ? null : this._activeCommentId;
|
|
2749
|
+
if (r !== this._activeCommentId) {
|
|
2750
|
+
this._activeCommentId = r, this._activeCommentSlide = r ? e : null, this._elementContext = null;
|
|
2751
|
+
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2752
|
+
this._emitSelectionContextChange();
|
|
2753
|
+
}
|
|
2754
|
+
}, this._commentZoom(), $, this._commentsOptions()?.markers !== !1, this._commentsOptions()?.includeResolved === !0, t.commentDecorationLayer ? () => this._scheduleCommentGeometry(e, t, !1) : void 0, t.commentDecorationLayer ? () => this._scheduleCommentGeometry(e, t, !0) : void 0), this._redrawSlotCommentConnectors(e, t);
|
|
2755
|
+
}
|
|
2756
|
+
_redrawSlotCommentConnectors(e, t) {
|
|
2757
|
+
let n = t.commentDecorationLayer, r = t.commentMargin, i = t.commentGeometry, a = this._commentsOptions()?.connectors;
|
|
2758
|
+
if (!n || !r || !i || !a) return;
|
|
2759
|
+
let o = this._slideWidthPx(), s = this._slideHeightPx(), c = this._commentSide(), l = this._commentMarginExtent(), u = this._commentUi;
|
|
2760
|
+
u && u.buildReadOnlyCommentDecoration(n, Object.freeze({
|
|
2761
|
+
surfaceBounds: Object.freeze({
|
|
2762
|
+
x: c === "left" ? -l : 0,
|
|
2763
|
+
y: 0,
|
|
2764
|
+
width: o + l,
|
|
2765
|
+
height: s
|
|
2766
|
+
}),
|
|
2767
|
+
contentBounds: Object.freeze({
|
|
2768
|
+
x: 0,
|
|
2769
|
+
y: 0,
|
|
2770
|
+
width: o,
|
|
2771
|
+
height: s
|
|
2772
|
+
}),
|
|
2773
|
+
side: c,
|
|
2774
|
+
threads: u.projectReadOnlyCommentMarginScroll(i, r.scrollTop)
|
|
2775
|
+
}), {
|
|
2776
|
+
route: a.route ?? "bezier",
|
|
2777
|
+
stroke: a.stroke ?? "solid",
|
|
2778
|
+
color: a.color,
|
|
2779
|
+
activeColor: a.activeColor
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
_commitSlotComments(e, t) {
|
|
2783
|
+
this._ensureSlotCommentAnchors(e, t), this._redrawSlotComments(e, t), t.commentMarkerLayer && (t.commentMarkerLayer.style.visibility = ""), t.commentMargin && (t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (t.commentDecorationLayer.style.visibility = "");
|
|
2784
|
+
}
|
|
2785
|
+
_ensureSlotCommentAnchors(e, t) {
|
|
2786
|
+
let n = this._pres;
|
|
2787
|
+
if (!n || t.commentAnchorSlide === e) return;
|
|
2788
|
+
t.commentAnchorSlide = e, t.commentElementBounds = Object.freeze([]);
|
|
2789
|
+
let r = [...new Set(n.getComments(e).flatMap((e) => (e.anchors ?? []).flatMap((e) => (e.type === "drawingElement" || e.type === "textRange") && e.elementId ? [e.elementId] : [])))];
|
|
2790
|
+
if (r.length === 0) return;
|
|
2791
|
+
let i = ++t.commentAnchorGeneration;
|
|
2792
|
+
n.getElementBoundsByIds(e, r).then((r) => {
|
|
2793
|
+
if (this._destroyed || i !== t.commentAnchorGeneration || n !== this._pres || this._slots.get(e) !== t || t.commentAnchorSlide !== e) return;
|
|
2794
|
+
t.commentElementBounds = r, this._redrawSlotComments(e, t);
|
|
2795
|
+
let a = n.getComments(e).find((t, n) => P(t, n, e) === this._activeCommentId);
|
|
2796
|
+
a && this._scrollToSlideCommentTarget(e, a);
|
|
2797
|
+
}).catch((e) => {
|
|
2798
|
+
!this._destroyed && i === t.commentAnchorGeneration && this._reportRenderError(e);
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
_scheduleCommentGeometry(e, t, n = !1) {
|
|
2802
|
+
let r = this._pendingCommentGeometry.get(e);
|
|
2803
|
+
if (this._pendingCommentGeometry.set(e, {
|
|
2804
|
+
slot: t,
|
|
2805
|
+
connectorsOnly: r?.slot === t ? r.connectorsOnly && n : n
|
|
2806
|
+
}), this._commentGeometryScheduled) return;
|
|
2807
|
+
this._commentGeometryScheduled = !0;
|
|
2808
|
+
let i = () => {
|
|
2809
|
+
this._commentGeometryScheduled = !1, this._commentGeometryFrame = null;
|
|
2810
|
+
let e = [...this._pendingCommentGeometry];
|
|
2811
|
+
if (this._pendingCommentGeometry.clear(), !this._destroyed) for (let [t, n] of e) {
|
|
2812
|
+
let { slot: e, connectorsOnly: r } = n;
|
|
2813
|
+
this._slots.get(t) === e && e.renderedScale === this._scale && (r ? this._redrawSlotCommentConnectors(t, e) : this._redrawSlotComments(t, e));
|
|
2814
|
+
}
|
|
2815
|
+
}, a = this._wrapper.ownerDocument.defaultView;
|
|
2816
|
+
a?.requestAnimationFrame ? this._commentGeometryFrame = a.requestAnimationFrame(i) : queueMicrotask(i);
|
|
2817
|
+
}
|
|
2818
|
+
_redrawSlotHighlights(e, t) {
|
|
2819
|
+
if (!this._findActive) {
|
|
2820
|
+
t.highlightLayer.innerHTML = "";
|
|
2821
|
+
return;
|
|
2822
|
+
}
|
|
2823
|
+
let n = this._find.slideRuns(e);
|
|
2824
|
+
if (!n) {
|
|
2825
|
+
t.highlightLayer.innerHTML = "";
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2828
|
+
L(t.highlightLayer, n, this._find.slideHighlights(e), this._slideWidthPx(), this._slideHeightPx(), (e) => this._measureForFind(e), this._opts.findHighlightColors);
|
|
2829
|
+
}
|
|
2830
|
+
_measureForFind(e) {
|
|
2831
|
+
this._findMeasureCtx === void 0 && (this._findMeasureCtx = document.createElement("canvas").getContext("2d"));
|
|
2832
|
+
let t = this._findMeasureCtx;
|
|
2833
|
+
return !t || typeof t.measureText != "function" ? (e) => e.length : (t.font = e, (e) => t.measureText(e).width);
|
|
2834
|
+
}
|
|
2835
|
+
_hyperlinkHandler() {
|
|
2836
|
+
if (this._opts.enableHyperlinks !== !1) return (e) => this._onHyperlinkClick(e);
|
|
2837
|
+
}
|
|
2838
|
+
_onHyperlinkClick(e) {
|
|
2839
|
+
let t = this._resolveInternalSlideIndex(e);
|
|
2840
|
+
if (this._opts.onHyperlinkClick) {
|
|
2841
|
+
this._opts.onHyperlinkClick(t);
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
if (t.kind === "external") {
|
|
2845
|
+
x(t.url);
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
t.slideIndex !== void 0 && this.scrollToSlide(t.slideIndex);
|
|
2849
|
+
}
|
|
2850
|
+
_resolveInternalSlideIndex(e) {
|
|
2851
|
+
if (e.kind !== "internal" || e.slideIndex !== void 0) return e;
|
|
2852
|
+
let t = this._pres?.resolveInternalTarget(e.ref, this._range().topIndex);
|
|
2853
|
+
return t === void 0 ? e : {
|
|
2854
|
+
...e,
|
|
2855
|
+
slideIndex: t
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
_onResize() {
|
|
2859
|
+
if (!this._pres || this._pres.slideCount === 0) return;
|
|
2860
|
+
if (!this._scaleEstablished) {
|
|
2861
|
+
this.relayout();
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (this._opts.refitOnResize === !1) {
|
|
2865
|
+
this._lastFitWidth = this._fitWidthPx(), this._mountVisible();
|
|
2866
|
+
return;
|
|
2867
|
+
}
|
|
2868
|
+
let e = this._baseScale();
|
|
2869
|
+
if (e <= 0) return;
|
|
2870
|
+
let t = this._fitWidthPx();
|
|
2871
|
+
if (t === this._lastFitWidth) {
|
|
2872
|
+
this._mountVisible();
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
this._lastFitWidth = t;
|
|
2876
|
+
let n = this._prevBase > 0 ? this._scale / this._prevBase : 1;
|
|
2877
|
+
this._prevBase = e, this.setScale(e * n), this._mountVisible();
|
|
2878
|
+
}
|
|
2879
|
+
get topVisibleSlide() {
|
|
2880
|
+
return this._lastRange?.topIndex ?? 0;
|
|
2881
|
+
}
|
|
2882
|
+
mountedSlideIndicesForTest() {
|
|
2883
|
+
return [...this._slots.keys()];
|
|
2884
|
+
}
|
|
2885
|
+
interactiveSlideIndicesForTest() {
|
|
2886
|
+
return [...this._slots].filter(([, e]) => e.mediaInteractive).map(([e]) => e);
|
|
2887
|
+
}
|
|
2888
|
+
scaleForTest() {
|
|
2889
|
+
return this._scale;
|
|
2890
|
+
}
|
|
2891
|
+
baseScaleForTest() {
|
|
2892
|
+
return this._baseScale();
|
|
2893
|
+
}
|
|
2894
|
+
renderEpochForTest() {
|
|
2895
|
+
return this._renderEpoch;
|
|
2896
|
+
}
|
|
2897
|
+
resizeForTest() {
|
|
2898
|
+
this._onResize();
|
|
2899
|
+
}
|
|
2900
|
+
contentAtViewportYForTest(e) {
|
|
2901
|
+
let t = this._scrollHost.scrollTop + e, n = this._slideIndexAtOffset(t), r = this._uniformSlideHeight;
|
|
2902
|
+
return {
|
|
2903
|
+
slide: n,
|
|
2904
|
+
frac: r > 0 ? Math.min(1, Math.max(0, (t - this._slideOffset(n)) / r)) : 0
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
viewportYOfForTest(e, t) {
|
|
2908
|
+
return this._slideOffset(e) + t * this._uniformSlideHeight - this._scrollHost.scrollTop;
|
|
2909
|
+
}
|
|
2910
|
+
async getResourceMetrics() {
|
|
2911
|
+
if (!this._pres) throw Error("Presentation not loaded");
|
|
2912
|
+
return await this._pres.getResourceMetrics();
|
|
2913
|
+
}
|
|
2914
|
+
getSelectionContext(e = {}) {
|
|
2915
|
+
if (this._destroyed) throw Error("PptxScrollViewer is destroyed");
|
|
2916
|
+
if (this._pres && this._activeCommentId !== null && this._activeCommentSlide !== null) {
|
|
2917
|
+
let t = this._pres.getComments(this._activeCommentSlide), n = t.findIndex((e, t) => P(e, t, this._activeCommentSlide) === this._activeCommentId), r = t[n];
|
|
2918
|
+
if (r && n >= 0) return Lt(r, this._activeCommentSlide, n, this._activeCommentId, e);
|
|
2919
|
+
}
|
|
2920
|
+
return (this._opts.enableTextSelection ? X(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? At(this._elementContext, e.maxTextCharacters) : null);
|
|
2921
|
+
}
|
|
2922
|
+
_emitSelectionContextChange() {
|
|
2923
|
+
let e = this.getSelectionContext();
|
|
2924
|
+
e?.kind === "text" && (this._elementHitGeneration++, this._elementContext = null, this._redrawElementOutlines());
|
|
2925
|
+
let t = JSON.stringify(e);
|
|
2926
|
+
t !== this._selectionContextKey && (this._selectionContextKey = t, this._opts.onSelectionContextChange?.(e ? structuredClone(e) : null));
|
|
2927
|
+
}
|
|
2928
|
+
_setElementContext(e) {
|
|
2929
|
+
this._elementContext = e ? structuredClone(e) : null, this._redrawElementOutlines(), this._emitSelectionContextChange();
|
|
2930
|
+
}
|
|
2931
|
+
_invalidateElementSelection(e = !0) {
|
|
2932
|
+
this._elementHitGeneration++, this._elementContext = null, this._redrawElementOutlines(), e && this._emitSelectionContextChange();
|
|
2933
|
+
}
|
|
2934
|
+
_redrawElementOutlines() {
|
|
2935
|
+
for (let [e, t] of this._slots) this._redrawElementOutlineForSlot(e, t);
|
|
2936
|
+
}
|
|
2937
|
+
_redrawElementOutlineForSlot(e, t) {
|
|
2938
|
+
let n = this._elementContext, r = this._pres;
|
|
2939
|
+
if (!n || !r || n.slideIndex !== e) {
|
|
2940
|
+
E(t.elementLayer, null);
|
|
2941
|
+
return;
|
|
2942
|
+
}
|
|
2943
|
+
E(t.elementLayer, {
|
|
2944
|
+
x: n.bounds.x / r.slideWidth,
|
|
2945
|
+
y: n.bounds.y / r.slideHeight,
|
|
2946
|
+
width: n.bounds.width / r.slideWidth,
|
|
2947
|
+
height: n.bounds.height / r.slideHeight,
|
|
2948
|
+
rotation: n.bounds.rotation
|
|
2949
|
+
});
|
|
2950
|
+
}
|
|
2951
|
+
async _onElementClick(e) {
|
|
2952
|
+
this._destroyed || e.defaultPrevented || e.button !== 0 || await this._resolveContextAt(e);
|
|
2953
|
+
}
|
|
2954
|
+
_onContextMenu(e) {
|
|
2955
|
+
let t;
|
|
2956
|
+
this._opts.onContextMenu?.({
|
|
2957
|
+
originalEvent: e,
|
|
2958
|
+
getContext: () => t ??= this._resolveContextAt(e)
|
|
2959
|
+
});
|
|
2960
|
+
}
|
|
2961
|
+
async _resolveContextAt(e) {
|
|
2962
|
+
let t = this._pres;
|
|
2963
|
+
if (this._destroyed || !t) return null;
|
|
2964
|
+
if (this._opts.enableTextSelection && X(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null)) return this._emitSelectionContextChange(), this._destroyed ? null : this.getSelectionContext();
|
|
2965
|
+
if (!this._opts.enableElementSelection) return this.getSelectionContext();
|
|
2966
|
+
let n = e.target, r = [...this._slots].find(([, e]) => n !== null && e.wrapper.contains(n));
|
|
2967
|
+
if (!r) return this._invalidateElementSelection(), null;
|
|
2968
|
+
let [i, a] = r, o = a.canvas.getBoundingClientRect();
|
|
2969
|
+
if (o.width <= 0 || o.height <= 0) return this._invalidateElementSelection(), null;
|
|
2970
|
+
let s = e.clientX - o.left, c = e.clientY - o.top;
|
|
2971
|
+
if (s < 0 || c < 0 || s > o.width || c > o.height) return this._invalidateElementSelection(), null;
|
|
2972
|
+
let l = ++this._elementHitGeneration, u = {
|
|
2973
|
+
x: s / o.width * t.slideWidth,
|
|
2974
|
+
y: c / o.height * t.slideHeight
|
|
2975
|
+
}, d;
|
|
2976
|
+
try {
|
|
2977
|
+
d = await t.getElementContextAt(i, u, {
|
|
2978
|
+
tolerance: this._elementHitTolerance / o.width * t.slideWidth,
|
|
2979
|
+
maxTextCharacters: G
|
|
2980
|
+
});
|
|
2981
|
+
} catch (e) {
|
|
2982
|
+
if (this._destroyed || l !== this._elementHitGeneration || t !== this._pres) return null;
|
|
2983
|
+
throw e;
|
|
2984
|
+
}
|
|
2985
|
+
return this._destroyed || l !== this._elementHitGeneration || t !== this._pres ? null : (this._setElementContext(d), this._destroyed ? null : this.getSelectionContext());
|
|
2986
|
+
}
|
|
2987
|
+
destroy() {
|
|
2988
|
+
if (!this._destroyed) {
|
|
2989
|
+
this._destroyed = !0, this._beginCommentNavigation(), this._errorRouter.close(), this._invalidateFind(), this._findActive = !1, this._unbindLayoutPresentation(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._scrollHost.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._scrollHost.removeEventListener("contextmenu", this._contextMenuListener), null), this._commentOutsidePointerListener &&= (this._wrapper.ownerDocument.removeEventListener("pointerdown", this._commentOutsidePointerListener), null), this._commentGeometryFrame !== null && (this._wrapper.ownerDocument.defaultView?.cancelAnimationFrame?.(this._commentGeometryFrame), this._commentGeometryFrame = null), this._commentGeometryScheduled = !1, this._pendingCommentGeometry.clear(), this._elementContext = null, this._scrollListener &&= (this._scrollHost.removeEventListener("scroll", this._scrollListener), null), this._wheelListener &&= (this._scrollHost.removeEventListener("wheel", this._wheelListener), null), this._resizeObserver?.disconnect(), this._resizeObserver = null, this._settleTimer !== null && (clearTimeout(this._settleTimer), this._settleTimer = null);
|
|
2990
|
+
for (let [e, t] of [...this._slots]) this._recycleSlot(e, t);
|
|
2991
|
+
this._free.length = 0, this._presentationOwner.close(), this._wrapper.remove();
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
}, Yt = /* @__PURE__ */ e({
|
|
2995
|
+
OoxmlDecodedImageLimitError: () => je,
|
|
2996
|
+
OoxmlError: () => b,
|
|
2997
|
+
OoxmlResourceLimitError: () => h,
|
|
2998
|
+
PptxPresentation: () => J,
|
|
2999
|
+
PptxScrollViewer: () => Jt,
|
|
3000
|
+
PptxViewer: () => Q,
|
|
3001
|
+
autoResize: () => be,
|
|
3002
|
+
buildPptxHighlightLayer: () => L,
|
|
3003
|
+
buildPptxTextLayer: () => I,
|
|
3004
|
+
isOoxmlDecodedImageLimitError: () => Me,
|
|
3005
|
+
openExternalHyperlink: () => x,
|
|
3006
|
+
readPptxTextSelectionContext: () => X,
|
|
3007
|
+
renderSlide: () => f
|
|
3008
|
+
});
|
|
3009
|
+
//#endregion
|
|
3010
|
+
export { J as a, X as i, Jt as n, L as o, Q as r, I as s, Yt as t };
|