presenter 0.9.4 → 0.10.0
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/dist/3d/index.d.ts +17 -0
- package/dist/3d/objects/ThreeBox.d.ts +9 -0
- package/dist/3d/objects/ThreeCameraType.d.ts +5 -0
- package/dist/3d/objects/ThreeMesh.d.ts +30 -0
- package/dist/3d/objects/ThreeModel.d.ts +18 -0
- package/dist/3d/objects/ThreeModelMaterial.d.ts +11 -0
- package/dist/3d/objects/ThreeModelNode.d.ts +24 -0
- package/dist/3d/objects/ThreeModelTarget.d.ts +9 -0
- package/dist/3d/objects/ThreeObjectType.d.ts +10 -0
- package/dist/3d/objects/ThreePresenterGroup.d.ts +13 -0
- package/dist/3d/objects/ThreeScene.d.ts +39 -0
- package/dist/3d/objects/ThreeSphere.d.ts +9 -0
- package/dist/3d/renderers/getThreeObjectRenderers.d.ts +6 -0
- package/dist/3d/renderers/renderThreeSceneFallback.d.ts +3 -0
- package/dist/3d/renderers/renderThreeScenePowerPointFallback.d.ts +3 -0
- package/dist/3d/renderers/threeFallbackRenderers.d.ts +5 -0
- package/dist/3d/types/ThreeModules.d.ts +10 -0
- package/dist/3d/utils/colorToThreeHex.d.ts +2 -0
- package/dist/3d/utils/inspectThreeModel.d.ts +4 -0
- package/dist/3d/utils/installThreeSceneCaptureApi.d.ts +21 -0
- package/dist/3d/utils/loadThreeModules.d.ts +2 -0
- package/dist/3d/utils/modelCache.d.ts +6 -0
- package/dist/3d/utils/modelInspection.d.ts +23 -0
- package/dist/3d/utils/modelInspection.test.d.ts +1 -0
- package/dist/3d/utils/modelPaths.d.ts +14 -0
- package/dist/3d/utils/modelPaths.test.d.ts +1 -0
- package/dist/3d.js +2 -0
- package/dist/3d.js.map +1 -0
- package/dist/3d.mjs +1055 -0
- package/dist/3d.mjs.map +1 -0
- package/dist/export/browser-image-renderer/BrowserImageRenderer.d.ts +7 -0
- package/dist/export/browser-image-renderer/types/BrowserImageRendererProps.d.ts +36 -0
- package/dist/export/browser.d.ts +2 -0
- package/dist/export/image-renderer/ImageRenderer.d.ts +1 -1
- package/dist/export/index.d.ts +2 -0
- package/dist/export/utils/getImageExportFrames.d.ts +14 -0
- package/dist/export/utils/getImageExportFrames.test.d.ts +1 -0
- package/dist/export-browser.js +6 -0
- package/dist/export-browser.js.map +1 -0
- package/dist/export-browser.mjs +2231 -0
- package/dist/export-browser.mjs.map +1 -0
- package/dist/export.js +74 -72
- package/dist/export.js.map +1 -1
- package/dist/export.mjs +5441 -4325
- package/dist/export.mjs.map +1 -1
- package/dist/objects/Image.d.ts +2 -1
- package/dist/presenter.js +5 -5
- package/dist/presenter.js.map +1 -1
- package/dist/presenter.mjs +1236 -1203
- package/dist/presenter.mjs.map +1 -1
- package/dist/renderer/browser-canvas/types/BrowserCanvasObjectRenderer.d.ts +8 -1
- package/dist/utils/presentation/getImagePathUrlById.d.ts +2 -0
- package/dist/utils/presentation/getObjectChildren.d.ts +1 -1
- package/package.json +22 -2
|
@@ -0,0 +1,2231 @@
|
|
|
1
|
+
const tt = "presenter.navigator.state", D = {
|
|
2
|
+
open: !1,
|
|
3
|
+
visibility: {
|
|
4
|
+
slides: !0,
|
|
5
|
+
current: !0,
|
|
6
|
+
next: !0,
|
|
7
|
+
notes: !1
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function et() {
|
|
11
|
+
return typeof document > "u" ? !1 : Array.from(document.scripts).some((t) => t.src.includes("/@vite/client"));
|
|
12
|
+
}
|
|
13
|
+
function $t() {
|
|
14
|
+
return et() ? nt().open : !1;
|
|
15
|
+
}
|
|
16
|
+
function Wt() {
|
|
17
|
+
Ct({
|
|
18
|
+
...nt(),
|
|
19
|
+
open: !0
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function St() {
|
|
23
|
+
var t;
|
|
24
|
+
(t = it()) == null || t.removeItem(tt);
|
|
25
|
+
}
|
|
26
|
+
function nt() {
|
|
27
|
+
var t, e, n, r, i;
|
|
28
|
+
if (!et())
|
|
29
|
+
return D;
|
|
30
|
+
try {
|
|
31
|
+
const o = (t = it()) == null ? void 0 : t.getItem(tt);
|
|
32
|
+
if (o == null)
|
|
33
|
+
return D;
|
|
34
|
+
const s = JSON.parse(o);
|
|
35
|
+
return {
|
|
36
|
+
open: typeof s.open == "boolean" ? s.open : D.open,
|
|
37
|
+
visibility: {
|
|
38
|
+
slides: typeof ((e = s.visibility) == null ? void 0 : e.slides) == "boolean" ? s.visibility.slides : D.visibility.slides,
|
|
39
|
+
current: typeof ((n = s.visibility) == null ? void 0 : n.current) == "boolean" ? s.visibility.current : D.visibility.current,
|
|
40
|
+
next: typeof ((r = s.visibility) == null ? void 0 : r.next) == "boolean" ? s.visibility.next : D.visibility.next,
|
|
41
|
+
notes: typeof ((i = s.visibility) == null ? void 0 : i.notes) == "boolean" ? s.visibility.notes : D.visibility.notes
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
} catch {
|
|
45
|
+
return D;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function Ct(t) {
|
|
49
|
+
var e;
|
|
50
|
+
et() && ((e = it()) == null || e.setItem(tt, JSON.stringify(t)));
|
|
51
|
+
}
|
|
52
|
+
function it() {
|
|
53
|
+
try {
|
|
54
|
+
return window.sessionStorage;
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function Ut(t = null) {
|
|
60
|
+
return {
|
|
61
|
+
objects: [],
|
|
62
|
+
animations: [],
|
|
63
|
+
extras: [],
|
|
64
|
+
description: null,
|
|
65
|
+
isAllKey: !1,
|
|
66
|
+
isEndKey: !0,
|
|
67
|
+
isStartKey: !1,
|
|
68
|
+
notes: null,
|
|
69
|
+
shortcut: null,
|
|
70
|
+
title: "",
|
|
71
|
+
...t
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function Tt(t) {
|
|
75
|
+
return t.altKey || t.ctrlKey || t.metaKey || t.shiftKey;
|
|
76
|
+
}
|
|
77
|
+
function lt(t) {
|
|
78
|
+
var r, i;
|
|
79
|
+
if (t === null)
|
|
80
|
+
return !1;
|
|
81
|
+
const e = t, n = (r = e.tagName) == null ? void 0 : r.toLowerCase();
|
|
82
|
+
return n === "input" || n === "textarea" || n === "select" || n === "button" || e.isContentEditable ? !0 : (((i = e.closest) == null ? void 0 : i.call(e, "[contenteditable=''], [contenteditable='true']")) ?? null) !== null;
|
|
83
|
+
}
|
|
84
|
+
function Gt(t) {
|
|
85
|
+
var r;
|
|
86
|
+
const { slides: e } = t, n = {
|
|
87
|
+
// First build of first slide
|
|
88
|
+
s: { slideIndex: 0, buildIndex: 0 },
|
|
89
|
+
// First build of current slide
|
|
90
|
+
c: { slideIndex: null, buildIndex: 0 },
|
|
91
|
+
// Last build of last slide
|
|
92
|
+
e: {
|
|
93
|
+
slideIndex: e.length - 1,
|
|
94
|
+
buildIndex: ((r = e[e.length - 1]) == null ? void 0 : r.animations.length) ?? 0
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
for (let i = 0; i < e.length; i++) {
|
|
98
|
+
const o = e[i];
|
|
99
|
+
if (o === void 0)
|
|
100
|
+
continue;
|
|
101
|
+
const s = o.shortcut;
|
|
102
|
+
J(n, s, i, 0);
|
|
103
|
+
for (let a = 0; a < o.animations.length; a++) {
|
|
104
|
+
const c = o.animations[a];
|
|
105
|
+
if (c !== void 0)
|
|
106
|
+
if (Array.isArray(c))
|
|
107
|
+
for (const l of c)
|
|
108
|
+
J(n, l.shortcut, i, a + 1);
|
|
109
|
+
else
|
|
110
|
+
J(n, c.shortcut, i, a + 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return n;
|
|
114
|
+
}
|
|
115
|
+
function J(t, e, n, r) {
|
|
116
|
+
if (e !== null)
|
|
117
|
+
if (Array.isArray(e))
|
|
118
|
+
for (const i of e)
|
|
119
|
+
t[i] = { slideIndex: n, buildIndex: r };
|
|
120
|
+
else
|
|
121
|
+
t[e] = { slideIndex: n, buildIndex: r };
|
|
122
|
+
}
|
|
123
|
+
function ct(t, e) {
|
|
124
|
+
const n = t[e];
|
|
125
|
+
return n !== void 0 ? n : isNaN(Number(e)) ? null : { slideIndex: Number(e) - 1, buildIndex: 0 };
|
|
126
|
+
}
|
|
127
|
+
function It(t, e, n, { onNext: r, onPrevious: i, onRenderSlide: o, onShowNavigator: s }, { focusOnPointerDown: a = !1, keyEventTarget: c = e, signal: l } = {}) {
|
|
128
|
+
n.shortcuts = Gt(t);
|
|
129
|
+
const d = l === void 0 ? void 0 : { signal: l };
|
|
130
|
+
a && (e.hasAttribute("tabindex") || (e.tabIndex = -1), e.addEventListener(
|
|
131
|
+
"pointerdown",
|
|
132
|
+
(h) => {
|
|
133
|
+
lt(h.target) || e.focus({ preventScroll: !0 });
|
|
134
|
+
},
|
|
135
|
+
d
|
|
136
|
+
)), e.addEventListener(
|
|
137
|
+
"mousemove",
|
|
138
|
+
() => {
|
|
139
|
+
e.style.cursor = "auto";
|
|
140
|
+
},
|
|
141
|
+
d
|
|
142
|
+
), c.addEventListener(
|
|
143
|
+
"keyup",
|
|
144
|
+
(h) => {
|
|
145
|
+
const u = h;
|
|
146
|
+
if (lt(u.target))
|
|
147
|
+
return;
|
|
148
|
+
if (u.code === "Escape") {
|
|
149
|
+
n.textCommand = null;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (u.code === "ArrowRight" || u.code === "Space") {
|
|
153
|
+
r(u.shiftKey);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (u.code === "ArrowLeft") {
|
|
157
|
+
i(u.shiftKey);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const p = Kt(u);
|
|
161
|
+
if (p !== null) {
|
|
162
|
+
const g = ct(
|
|
163
|
+
n.shortcuts,
|
|
164
|
+
p
|
|
165
|
+
);
|
|
166
|
+
n.textCommand = null, g !== null && (u.preventDefault(), o(g.slideIndex, g.buildIndex));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (n.textCommand !== null) {
|
|
170
|
+
if (u.code === "Enter") {
|
|
171
|
+
const g = n.textCommand;
|
|
172
|
+
n.textCommand = null;
|
|
173
|
+
const m = ct(
|
|
174
|
+
n.shortcuts,
|
|
175
|
+
g
|
|
176
|
+
);
|
|
177
|
+
m !== null && o(m.slideIndex, m.buildIndex);
|
|
178
|
+
return;
|
|
179
|
+
} else u.code === "Backspace" ? n.textCommand = n.textCommand.slice(0, -1) : n.textCommand += u.key;
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (u.key === "g") {
|
|
183
|
+
n.textCommand = "";
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (u.key === "`" && !Tt(u)) {
|
|
187
|
+
s();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
d
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
function Kt(t) {
|
|
195
|
+
return !t.altKey || t.ctrlKey || t.metaKey || t.shiftKey ? null : t.code.startsWith("Key") && t.code.length === 4 ? t.code.slice(3).toLowerCase() : t.code.startsWith("Digit") && t.code.length === 6 ? t.code.slice(5) : t.code.startsWith("Numpad") && t.code.length === 7 ? t.code.slice(6) : null;
|
|
196
|
+
}
|
|
197
|
+
function Yt(t, e) {
|
|
198
|
+
for (let n = Math.min(e, t.animations.length); n >= 0; n--) {
|
|
199
|
+
const r = Xt(t, n);
|
|
200
|
+
if (r !== null)
|
|
201
|
+
return r;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
function Xt(t, e) {
|
|
206
|
+
if (e === 0)
|
|
207
|
+
return t.notes;
|
|
208
|
+
const n = t.animations[e - 1];
|
|
209
|
+
return n === void 0 ? null : Jt(n);
|
|
210
|
+
}
|
|
211
|
+
function Jt(t) {
|
|
212
|
+
if (!Array.isArray(t))
|
|
213
|
+
return t.notes;
|
|
214
|
+
const e = t.map(({ notes: n }) => n).filter((n) => n !== null);
|
|
215
|
+
return e.length > 0 ? e.join(`
|
|
216
|
+
|
|
217
|
+
`) : null;
|
|
218
|
+
}
|
|
219
|
+
let f = null, G = null, V = null;
|
|
220
|
+
const dt = "__presenterNavigatorInstanceId";
|
|
221
|
+
let Et = {
|
|
222
|
+
width: 700,
|
|
223
|
+
height: 680,
|
|
224
|
+
left: 20,
|
|
225
|
+
top: 50
|
|
226
|
+
};
|
|
227
|
+
function qt({
|
|
228
|
+
presentation: t,
|
|
229
|
+
shortcutState: e,
|
|
230
|
+
onNavigateToSlide: n,
|
|
231
|
+
onRenderSlide: r,
|
|
232
|
+
onNext: i,
|
|
233
|
+
onPrevious: o,
|
|
234
|
+
forceRefresh: s = !1
|
|
235
|
+
}) {
|
|
236
|
+
if (f !== null && !f.closed && (K(f), !s))
|
|
237
|
+
return f.focus(), G;
|
|
238
|
+
if ((f === null || f.closed) && (f = window.open("", "Navigator", ne())), f === null)
|
|
239
|
+
return console.error("Failed to open navigator window."), null;
|
|
240
|
+
V == null || V();
|
|
241
|
+
const a = ie(f), c = new AbortController();
|
|
242
|
+
V = () => c.abort();
|
|
243
|
+
const l = Qt(
|
|
244
|
+
t,
|
|
245
|
+
n,
|
|
246
|
+
i,
|
|
247
|
+
a.isActive
|
|
248
|
+
);
|
|
249
|
+
return G = l, Wt(), f.document.title = t.title, f.document.body.replaceChildren(l.element), It(
|
|
250
|
+
t,
|
|
251
|
+
l.element,
|
|
252
|
+
e,
|
|
253
|
+
{
|
|
254
|
+
onNext: (d) => {
|
|
255
|
+
a.isActive() && i(d);
|
|
256
|
+
},
|
|
257
|
+
onPrevious: (d) => {
|
|
258
|
+
a.isActive() && o(d);
|
|
259
|
+
},
|
|
260
|
+
onRenderSlide: (d, h) => {
|
|
261
|
+
a.isActive() && r(d, h);
|
|
262
|
+
},
|
|
263
|
+
onShowNavigator: () => {
|
|
264
|
+
a.isActive() && Z();
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
keyEventTarget: f,
|
|
269
|
+
signal: c.signal
|
|
270
|
+
}
|
|
271
|
+
), f.addEventListener("resize", () => K(f), {
|
|
272
|
+
signal: c.signal
|
|
273
|
+
}), f.addEventListener(
|
|
274
|
+
"beforeunload",
|
|
275
|
+
() => {
|
|
276
|
+
K(f), St();
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
signal: c.signal
|
|
280
|
+
}
|
|
281
|
+
), f.addEventListener(
|
|
282
|
+
"keyup",
|
|
283
|
+
(d) => {
|
|
284
|
+
a.isActive() && (d.key === "Escape" || d.key === "`" && !Tt(d)) && Z();
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
signal: c.signal
|
|
288
|
+
}
|
|
289
|
+
), G;
|
|
290
|
+
}
|
|
291
|
+
function Qt(t, e, n, r = () => !0) {
|
|
292
|
+
const i = (f == null ? void 0 : f.document) ?? document, o = i.createElement("div");
|
|
293
|
+
o.style.boxSizing = "border-box", o.style.display = "grid", o.style.gridTemplateColumns = "260px 1fr", o.style.gap = "18px", o.style.height = "100vh", o.style.overflow = "hidden", o.style.padding = "18px", o.style.fontFamily = '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', o.style.backgroundColor = "#f5f6f8", o.style.color = "#1f2937", i.body.style.margin = "0", i.body.style.overflow = "hidden";
|
|
294
|
+
const s = i.createElement("div");
|
|
295
|
+
s.style.display = "flex", s.style.flexDirection = "column", s.style.gap = "8px", s.style.minHeight = "0", s.style.overflowY = "auto", s.style.paddingRight = "4px";
|
|
296
|
+
const a = i.createElement("div");
|
|
297
|
+
a.style.display = "flex", a.style.flexDirection = "column", a.style.gap = "14px", a.style.minHeight = "0", a.style.minWidth = "0", a.style.overflow = "hidden";
|
|
298
|
+
const c = i.createElement("div");
|
|
299
|
+
c.style.display = "flex", c.style.gap = "14px", c.style.alignItems = "center", c.style.flexWrap = "wrap", c.style.fontSize = "13px", c.style.color = "#4b5563";
|
|
300
|
+
const l = i.createElement("div");
|
|
301
|
+
l.style.display = "flex", l.style.gap = "14px", l.style.flex = "1 1 auto", l.style.minHeight = "0", l.style.minWidth = "0", l.style.overflow = "hidden";
|
|
302
|
+
const d = ht("Current", t), h = ht("Next", t), u = Zt(), p = nt();
|
|
303
|
+
h.container.style.cursor = "pointer", h.container.addEventListener("click", () => {
|
|
304
|
+
r() && n();
|
|
305
|
+
});
|
|
306
|
+
const g = t.slides.map((y, N) => {
|
|
307
|
+
const E = te(y, N);
|
|
308
|
+
return E.style.cursor = "pointer", E.addEventListener("click", (B) => {
|
|
309
|
+
r() && (B.shiftKey && Z(), e(N));
|
|
310
|
+
}), s.appendChild(E), E;
|
|
311
|
+
}), m = U("Slides", s, p.visibility.slides), w = U(
|
|
312
|
+
"Current",
|
|
313
|
+
d.container,
|
|
314
|
+
p.visibility.current
|
|
315
|
+
), O = U(
|
|
316
|
+
"Next",
|
|
317
|
+
h.container,
|
|
318
|
+
p.visibility.next
|
|
319
|
+
), v = U(
|
|
320
|
+
"Notes",
|
|
321
|
+
u.container,
|
|
322
|
+
p.visibility.notes
|
|
323
|
+
), b = () => {
|
|
324
|
+
const y = w.input.checked && O.input.checked && C();
|
|
325
|
+
o.style.gridTemplateColumns = m.input.checked ? "260px 1fr" : "1fr", l.style.flexDirection = y ? "column" : "row", d.container.style.flex = "1 1 0", h.container.style.flex = "1 1 0", requestAnimationFrame(() => {
|
|
326
|
+
d.resize(), h.resize();
|
|
327
|
+
}), Ct({
|
|
328
|
+
...p,
|
|
329
|
+
open: !0,
|
|
330
|
+
visibility: {
|
|
331
|
+
slides: m.input.checked,
|
|
332
|
+
current: w.input.checked,
|
|
333
|
+
next: O.input.checked,
|
|
334
|
+
notes: v.input.checked
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
m.input.addEventListener("change", b), w.input.addEventListener("change", b), O.input.addEventListener("change", b), v.input.addEventListener("change", b), f == null || f.addEventListener("resize", b), c.appendChild(m.element), c.appendChild(w.element), c.appendChild(O.element), c.appendChild(v.element), l.appendChild(d.container), l.appendChild(h.container), a.appendChild(c), a.appendChild(l), a.appendChild(u.container), o.appendChild(s), o.appendChild(a);
|
|
339
|
+
function S(y, N, E, B) {
|
|
340
|
+
r() && (g.forEach((_, _t) => {
|
|
341
|
+
const X = _t === y;
|
|
342
|
+
_.style.backgroundColor = X ? "#dbeafe" : "#ffffff", _.style.borderColor = X ? "#60a5fa" : "#e5e7eb", _.style.color = X ? "#1e3a8a" : "#1f2937";
|
|
343
|
+
}), d.label.textContent = ut(t, y, N), h.label.textContent = ut(t, E, B), u.content.textContent = Yt(t.slides[y] ?? Ut(), N) ?? "", ee(g[y], s), b());
|
|
344
|
+
}
|
|
345
|
+
function C() {
|
|
346
|
+
const y = f;
|
|
347
|
+
if (y === null)
|
|
348
|
+
return !1;
|
|
349
|
+
const N = m.input.checked ? 278 : 0, E = y.innerWidth - 36 - N, B = y.innerHeight - 36 - c.offsetHeight - 14;
|
|
350
|
+
return E <= 0 || B <= 0 ? !1 : E / B < 1.1;
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
element: o,
|
|
354
|
+
currentCanvas: d.canvas,
|
|
355
|
+
nextCanvas: h.canvas,
|
|
356
|
+
currentLabel: d.label,
|
|
357
|
+
nextLabel: h.label,
|
|
358
|
+
isOpen: () => f !== null && !f.closed,
|
|
359
|
+
update: S
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function Zt() {
|
|
363
|
+
const t = (f == null ? void 0 : f.document) ?? document, e = t.createElement("div");
|
|
364
|
+
e.style.display = "flex", e.style.flex = "0 1 180px", e.style.flexDirection = "column", e.style.minHeight = "100px", e.style.maxHeight = "30vh", e.style.overflow = "hidden", e.style.backgroundColor = "#ffffff", e.style.border = "1px solid #e5e7eb", e.style.borderRadius = "6px", e.style.boxShadow = "0 1px 2px rgba(15, 23, 42, 0.06)";
|
|
365
|
+
const n = t.createElement("div");
|
|
366
|
+
n.textContent = "Notes", n.style.padding = "10px 12px 6px", n.style.fontSize = "12px", n.style.fontWeight = "700", n.style.textTransform = "uppercase", n.style.color = "#6b7280";
|
|
367
|
+
const r = t.createElement("div");
|
|
368
|
+
return r.style.flex = "1 1 auto", r.style.minHeight = "0", r.style.overflowY = "auto", r.style.padding = "4px 12px 12px", r.style.fontSize = "16px", r.style.lineHeight = "1.5", r.style.whiteSpace = "pre-wrap", e.appendChild(n), e.appendChild(r), { container: e, content: r };
|
|
369
|
+
}
|
|
370
|
+
function te(t, e) {
|
|
371
|
+
const n = (f == null ? void 0 : f.document) ?? document, r = n.createElement("div");
|
|
372
|
+
r.style.display = "flex", r.style.alignItems = "center", r.style.gap = "10px", r.style.padding = "8px 10px", r.style.backgroundColor = "#ffffff", r.style.border = "1px solid #e5e7eb", r.style.borderRadius = "6px", r.style.boxShadow = "0 1px 2px rgba(15, 23, 42, 0.06)", r.style.fontSize = "14px", r.style.lineHeight = "1", r.style.userSelect = "none";
|
|
373
|
+
const i = n.createElement("div");
|
|
374
|
+
i.textContent = `${e + 1}`, i.style.minWidth = "24px", i.style.fontWeight = "700", i.style.color = "#6b7280";
|
|
375
|
+
const o = n.createElement("div");
|
|
376
|
+
return o.textContent = t.title.length > 0 ? t.title : `Slide ${e + 1}`, o.style.overflow = "hidden", o.style.textOverflow = "ellipsis", o.style.whiteSpace = "nowrap", r.appendChild(i), r.appendChild(o), r;
|
|
377
|
+
}
|
|
378
|
+
function ht(t, e) {
|
|
379
|
+
var d;
|
|
380
|
+
const n = (f == null ? void 0 : f.document) ?? document, r = n.createElement("div");
|
|
381
|
+
r.style.display = "flex", r.style.alignItems = "center", r.style.flexDirection = "column", r.style.minHeight = "0", r.style.minWidth = "0";
|
|
382
|
+
const i = n.createElement("div");
|
|
383
|
+
i.textContent = t, i.style.marginBottom = "4px", i.style.fontSize = "12px", i.style.fontWeight = "700", i.style.textAlign = "center", i.style.textTransform = "uppercase", i.style.color = "#6b7280";
|
|
384
|
+
const o = n.createElement("div");
|
|
385
|
+
o.style.marginBottom = "6px", o.style.fontSize = "14px", o.style.fontWeight = "600", o.style.textAlign = "center";
|
|
386
|
+
const s = n.createElement("div");
|
|
387
|
+
s.style.flex = "1 1 auto", s.style.display = "flex", s.style.alignItems = "flex-start", s.style.justifyContent = "center", s.style.minHeight = "0", s.style.width = "100%", s.style.overflow = "hidden";
|
|
388
|
+
const a = n.createElement("canvas");
|
|
389
|
+
a.style.display = "block", a.style.width = "0", a.style.height = "0";
|
|
390
|
+
function c() {
|
|
391
|
+
const h = s.clientWidth, u = s.clientHeight;
|
|
392
|
+
if (h <= 0 || u <= 0)
|
|
393
|
+
return;
|
|
394
|
+
const p = e.size.width / e.size.height, g = Math.min(h, u * p), m = g / p;
|
|
395
|
+
a.style.width = `${g}px`, a.style.height = `${m}px`;
|
|
396
|
+
}
|
|
397
|
+
const l = (d = n.defaultView) == null ? void 0 : d.ResizeObserver;
|
|
398
|
+
return l !== void 0 && new l(c).observe(s), f == null || f.addEventListener("resize", c), s.appendChild(a), r.appendChild(i), r.appendChild(o), r.appendChild(s), { container: r, label: o, canvas: a, resize: c };
|
|
399
|
+
}
|
|
400
|
+
function U(t, e, n) {
|
|
401
|
+
const r = (f == null ? void 0 : f.document) ?? document, i = e.style.display || "block", o = r.createElement("label");
|
|
402
|
+
o.style.display = "inline-flex", o.style.alignItems = "center", o.style.gap = "6px", o.style.userSelect = "none";
|
|
403
|
+
const s = r.createElement("input");
|
|
404
|
+
return s.type = "checkbox", s.checked = n, e.style.display = n ? i : "none", s.addEventListener("change", () => {
|
|
405
|
+
e.style.display = s.checked ? i : "none";
|
|
406
|
+
}), o.appendChild(s), o.appendChild(r.createTextNode(t)), { element: o, input: s };
|
|
407
|
+
}
|
|
408
|
+
function ut(t, e, n) {
|
|
409
|
+
if (e === null)
|
|
410
|
+
return "End of presentation";
|
|
411
|
+
const r = t.slides[e];
|
|
412
|
+
return r === void 0 ? "No slide" : `Slide ${e + 1} of ${t.slides.length}, Build ${n + 1} of ${r.animations.length + 1}`;
|
|
413
|
+
}
|
|
414
|
+
function ee(t, e) {
|
|
415
|
+
if (t === void 0)
|
|
416
|
+
return;
|
|
417
|
+
const n = t.offsetTop, r = n + t.offsetHeight, i = e.scrollTop, o = i + e.clientHeight;
|
|
418
|
+
(n < i || r > o) && t.scrollIntoView({ block: "nearest" });
|
|
419
|
+
}
|
|
420
|
+
function Z() {
|
|
421
|
+
K(f), St(), V == null || V(), f == null || f.close(), f = null, G = null, V = null;
|
|
422
|
+
}
|
|
423
|
+
function ne() {
|
|
424
|
+
const { width: t, height: e, left: n, top: r } = Et;
|
|
425
|
+
return `width=${t},height=${e},left=${n},top=${r}`;
|
|
426
|
+
}
|
|
427
|
+
function K(t) {
|
|
428
|
+
t === null || t.closed || (Et = {
|
|
429
|
+
width: t.outerWidth,
|
|
430
|
+
height: t.outerHeight,
|
|
431
|
+
left: t.screenX,
|
|
432
|
+
top: t.screenY
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function ie(t) {
|
|
436
|
+
var r;
|
|
437
|
+
const e = typeof ((r = globalThis.crypto) == null ? void 0 : r.randomUUID) == "function" ? globalThis.crypto.randomUUID() : `${Date.now()}-${Math.random()}`, n = t;
|
|
438
|
+
return n[dt] = e, {
|
|
439
|
+
isActive: () => !t.closed && n[dt] === e
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function P(t, e = 0, n = 0, r = 1) {
|
|
443
|
+
if (typeof t == "string") {
|
|
444
|
+
const i = t.replace("#", ""), o = parseInt(i, 16);
|
|
445
|
+
return isNaN(o) ? (console.warn("Invalid hex color format:", t), ft) : i.length === 6 ? {
|
|
446
|
+
red: o >> 16 & 255,
|
|
447
|
+
green: o >> 8 & 255,
|
|
448
|
+
blue: o & 255,
|
|
449
|
+
alpha: 1
|
|
450
|
+
} : i.length === 8 ? {
|
|
451
|
+
red: o >> 24 & 255,
|
|
452
|
+
green: o >> 16 & 255,
|
|
453
|
+
blue: o >> 8 & 255,
|
|
454
|
+
alpha: (o & 255) / 255
|
|
455
|
+
} : (console.warn("Invalid hex color format:", t), ft);
|
|
456
|
+
} else if (typeof t == "number")
|
|
457
|
+
return {
|
|
458
|
+
red: t,
|
|
459
|
+
green: e ?? 0,
|
|
460
|
+
blue: n ?? 0,
|
|
461
|
+
alpha: r ?? 1
|
|
462
|
+
};
|
|
463
|
+
return {
|
|
464
|
+
red: 0,
|
|
465
|
+
green: 0,
|
|
466
|
+
blue: 0,
|
|
467
|
+
alpha: 1,
|
|
468
|
+
...t
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
P.BLACK = P(0, 0, 0);
|
|
472
|
+
P.BLUE = P(0, 0, 255);
|
|
473
|
+
P.GREEN = P(0, 255, 0);
|
|
474
|
+
P.RED = P(255, 0, 0);
|
|
475
|
+
P.TRANSPARENT = P(0, 0, 0, 0);
|
|
476
|
+
P.WHITE = P(255, 255, 255);
|
|
477
|
+
const ft = { red: 0, green: 0, blue: 0, alpha: 1 };
|
|
478
|
+
function I(t = null) {
|
|
479
|
+
return {
|
|
480
|
+
height: 0,
|
|
481
|
+
width: 0,
|
|
482
|
+
...t
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
const oe = I({ width: 0, height: 0 });
|
|
486
|
+
function At(t = null) {
|
|
487
|
+
return {
|
|
488
|
+
backgroundColor: P.WHITE,
|
|
489
|
+
slides: [],
|
|
490
|
+
title: "Presentation",
|
|
491
|
+
size: I({ width: 3840, height: 2160 }),
|
|
492
|
+
resources: {
|
|
493
|
+
images: {}
|
|
494
|
+
},
|
|
495
|
+
...t
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
const $ = {
|
|
499
|
+
/** Represents an animated change in an object's properties. */
|
|
500
|
+
ANIMATE: "Animate",
|
|
501
|
+
/** Represents a pause in the animation timeline. */
|
|
502
|
+
PAUSE: "Pause",
|
|
503
|
+
/** Represents an immediate update to an object's properties without animation. */
|
|
504
|
+
UPDATE: "Update"
|
|
505
|
+
};
|
|
506
|
+
function L(t, e) {
|
|
507
|
+
throw new Error("Unexpected value: " + t);
|
|
508
|
+
}
|
|
509
|
+
function Pt(t) {
|
|
510
|
+
const e = Array.isArray(t) ? t : [t];
|
|
511
|
+
let n = 0, r = 0;
|
|
512
|
+
for (const i of e)
|
|
513
|
+
switch (i.type) {
|
|
514
|
+
case $.PAUSE:
|
|
515
|
+
n += i.duration;
|
|
516
|
+
break;
|
|
517
|
+
case $.ANIMATE:
|
|
518
|
+
r = Math.max(r, n + i.delay + i.duration), i.block && (n += i.delay + i.duration);
|
|
519
|
+
break;
|
|
520
|
+
case $.UPDATE:
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
L(i);
|
|
524
|
+
}
|
|
525
|
+
return r;
|
|
526
|
+
}
|
|
527
|
+
function Ot(t, e = null) {
|
|
528
|
+
return t.alpha * (e ?? 1);
|
|
529
|
+
}
|
|
530
|
+
function ot(t, e = null) {
|
|
531
|
+
const { red: n, green: r, blue: i } = t, o = Ot(t, e);
|
|
532
|
+
return `rgba(${n}, ${r}, ${i}, ${o})`;
|
|
533
|
+
}
|
|
534
|
+
function Nt(t) {
|
|
535
|
+
return t === document.body;
|
|
536
|
+
}
|
|
537
|
+
function re(t, e) {
|
|
538
|
+
const n = document.createElement("div");
|
|
539
|
+
if (n.style.width = "100%", n.style.aspectRatio = `${t.size.width} / ${t.size.height}`, n.style.position = "relative", Nt(e)) {
|
|
540
|
+
n.style.top = "50%", n.style.transform = "translateY(-50%)", n.style.marginLeft = "auto", n.style.marginRight = "auto", n.style.overflowY = "clip", document.title = t.title, document.documentElement.style.height = "100%", document.body.style.margin = "0", document.body.style.height = "100%", document.body.style.width = "100%", document.body.style.backgroundColor = "#000000";
|
|
541
|
+
const r = t.size.height / t.size.width;
|
|
542
|
+
pt(n, r), window.matchMedia(`(min-aspect-ratio: ${t.size.width} / ${t.size.height})`).addEventListener("change", () => pt(n, r));
|
|
543
|
+
}
|
|
544
|
+
return n;
|
|
545
|
+
}
|
|
546
|
+
function pt(t, e) {
|
|
547
|
+
window.innerHeight / window.innerWidth > e ? (t.style.width = "100%", t.style.height = "auto") : (t.style.width = "auto", t.style.height = "100%");
|
|
548
|
+
}
|
|
549
|
+
function Y(t) {
|
|
550
|
+
const e = [], n = t;
|
|
551
|
+
for (const r of ["objects", "meshes", "nodes", "materials"]) {
|
|
552
|
+
const i = n[r];
|
|
553
|
+
Array.isArray(i) && e.push(...se(i));
|
|
554
|
+
}
|
|
555
|
+
return e;
|
|
556
|
+
}
|
|
557
|
+
function se(t) {
|
|
558
|
+
return t.filter(
|
|
559
|
+
(e) => typeof e == "object" && e !== null && "objectType" in e
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
function Bt(t) {
|
|
563
|
+
const e = {};
|
|
564
|
+
function n(i) {
|
|
565
|
+
i != null && i.length > 0 && (e[i] = i);
|
|
566
|
+
}
|
|
567
|
+
function r(i) {
|
|
568
|
+
const o = i;
|
|
569
|
+
n(o.imagePath), n(o.fallbackImagePath);
|
|
570
|
+
for (const s of Y(i))
|
|
571
|
+
r(s);
|
|
572
|
+
}
|
|
573
|
+
for (const i of t.slides)
|
|
574
|
+
for (const o of i.objects)
|
|
575
|
+
r(o);
|
|
576
|
+
return e;
|
|
577
|
+
}
|
|
578
|
+
const ae = {
|
|
579
|
+
check: (t) => typeof t == "object" && t !== null && typeof t.red == "number" && typeof t.green == "number" && typeof t.blue == "number" && typeof t.alpha == "number",
|
|
580
|
+
interpolate: (t, e, n) => ({
|
|
581
|
+
red: Math.round(t.red + (e.red - t.red) * n),
|
|
582
|
+
green: Math.round(t.green + (e.green - t.green) * n),
|
|
583
|
+
blue: Math.round(t.blue + (e.blue - t.blue) * n),
|
|
584
|
+
alpha: t.alpha + (e.alpha - t.alpha) * n
|
|
585
|
+
})
|
|
586
|
+
}, le = {
|
|
587
|
+
check: (t) => !0,
|
|
588
|
+
interpolate: (t, e) => e
|
|
589
|
+
}, ce = {
|
|
590
|
+
check: (t) => typeof t == "number",
|
|
591
|
+
interpolate: (t, e, n) => t + (e - t) * n
|
|
592
|
+
}, gt = [
|
|
593
|
+
ce,
|
|
594
|
+
ae,
|
|
595
|
+
le
|
|
596
|
+
];
|
|
597
|
+
function de(t, e, n, r = null) {
|
|
598
|
+
if (n === 0)
|
|
599
|
+
return t;
|
|
600
|
+
if (n === 1)
|
|
601
|
+
return { ...t, ...e };
|
|
602
|
+
const i = r != null ? [...r, ...gt] : gt, o = {};
|
|
603
|
+
for (const s in e) {
|
|
604
|
+
const a = t[s], c = e[s];
|
|
605
|
+
for (const l of i)
|
|
606
|
+
if (l.check(a, s) && l.check(c, s)) {
|
|
607
|
+
o[s] = l.interpolate(
|
|
608
|
+
a,
|
|
609
|
+
c,
|
|
610
|
+
n
|
|
611
|
+
);
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return { ...t, ...o };
|
|
616
|
+
}
|
|
617
|
+
function yt(t, e, n = null) {
|
|
618
|
+
if (e === null)
|
|
619
|
+
return;
|
|
620
|
+
const r = Array.isArray(e) ? e : [e];
|
|
621
|
+
let i = 0;
|
|
622
|
+
for (const o of r) {
|
|
623
|
+
if (n !== null && i > n)
|
|
624
|
+
break;
|
|
625
|
+
switch (o.type) {
|
|
626
|
+
case $.ANIMATE: {
|
|
627
|
+
const s = t.get(o.object);
|
|
628
|
+
if (s === void 0)
|
|
629
|
+
break;
|
|
630
|
+
const a = n !== null ? n - i : null, c = Math.max(
|
|
631
|
+
Math.min(
|
|
632
|
+
a !== null ? (a - o.delay) / o.duration : 1,
|
|
633
|
+
1
|
|
634
|
+
),
|
|
635
|
+
0
|
|
636
|
+
);
|
|
637
|
+
t.set(o.object, {
|
|
638
|
+
...s,
|
|
639
|
+
...de(
|
|
640
|
+
s,
|
|
641
|
+
o.props,
|
|
642
|
+
o.easing(c),
|
|
643
|
+
o.interpolators
|
|
644
|
+
)
|
|
645
|
+
}), o.block && (i += o.delay + o.duration);
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
case $.UPDATE: {
|
|
649
|
+
const s = t.get(o.object);
|
|
650
|
+
if (s === void 0)
|
|
651
|
+
break;
|
|
652
|
+
t.set(o.object, {
|
|
653
|
+
...s,
|
|
654
|
+
...o.props
|
|
655
|
+
});
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
case $.PAUSE:
|
|
659
|
+
i += o.duration;
|
|
660
|
+
break;
|
|
661
|
+
default:
|
|
662
|
+
L(o);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function mt({
|
|
667
|
+
slide: t,
|
|
668
|
+
buildIndex: e,
|
|
669
|
+
buildTime: n
|
|
670
|
+
}) {
|
|
671
|
+
const r = /* @__PURE__ */ new Map();
|
|
672
|
+
function i(s) {
|
|
673
|
+
r.set(s, s);
|
|
674
|
+
for (const a of Y(s))
|
|
675
|
+
i(a);
|
|
676
|
+
}
|
|
677
|
+
for (const s of t.objects)
|
|
678
|
+
i(s);
|
|
679
|
+
const o = n === null ? e : e - 1;
|
|
680
|
+
for (let s = 0; s < o; s++) {
|
|
681
|
+
const a = t.animations[s] ?? null;
|
|
682
|
+
yt(r, a);
|
|
683
|
+
}
|
|
684
|
+
if (n !== null && e > 0) {
|
|
685
|
+
const s = t.animations[e - 1] ?? null;
|
|
686
|
+
yt(r, s, n);
|
|
687
|
+
}
|
|
688
|
+
return r;
|
|
689
|
+
}
|
|
690
|
+
const T = {
|
|
691
|
+
ARROW: "Arrow",
|
|
692
|
+
CIRCLE: "Circle",
|
|
693
|
+
GROUP: "Group",
|
|
694
|
+
IMAGE: "Image",
|
|
695
|
+
LINE: "Line",
|
|
696
|
+
MASK: "Mask",
|
|
697
|
+
PATH: "Path",
|
|
698
|
+
POLYGON: "Polygon",
|
|
699
|
+
RECTANGLE: "Rectangle",
|
|
700
|
+
SLIDE_OBJECT: "SlideObject",
|
|
701
|
+
SPOTLIGHT: "Spotlight",
|
|
702
|
+
SVG: "SVG",
|
|
703
|
+
TEXT: "Text"
|
|
704
|
+
};
|
|
705
|
+
function Rt(t) {
|
|
706
|
+
const e = {};
|
|
707
|
+
function n(r) {
|
|
708
|
+
if (r.objectType === T.SVG) {
|
|
709
|
+
const o = r.svg;
|
|
710
|
+
o !== void 0 && o.length > 0 && (e[o] = o);
|
|
711
|
+
}
|
|
712
|
+
const i = Y(r);
|
|
713
|
+
for (const o of i)
|
|
714
|
+
n(o);
|
|
715
|
+
}
|
|
716
|
+
for (const r of t.slides)
|
|
717
|
+
for (const i of r.objects)
|
|
718
|
+
n(i);
|
|
719
|
+
return e;
|
|
720
|
+
}
|
|
721
|
+
const z = "presenterState";
|
|
722
|
+
function he(t, e) {
|
|
723
|
+
const n = localStorage.getItem(z);
|
|
724
|
+
if (n === null)
|
|
725
|
+
return null;
|
|
726
|
+
if (e === null)
|
|
727
|
+
return localStorage.removeItem(z), null;
|
|
728
|
+
let r;
|
|
729
|
+
try {
|
|
730
|
+
r = JSON.parse(n);
|
|
731
|
+
} catch (l) {
|
|
732
|
+
return console.error("Failed to parse presentation state from localStorage:", l), localStorage.removeItem(z), null;
|
|
733
|
+
}
|
|
734
|
+
const { title: i, timestamp: o } = r;
|
|
735
|
+
let { slideIndex: s, buildIndex: a } = r;
|
|
736
|
+
if (typeof i != "string" || typeof s != "number" || typeof a != "number" || typeof o != "number" || i !== t.title || Date.now() - o > 1e3 * 60 * e)
|
|
737
|
+
return localStorage.removeItem(z), null;
|
|
738
|
+
s > t.slides.length - 1 && (s = t.slides.length - 1, a = 0);
|
|
739
|
+
const c = t.slides[s];
|
|
740
|
+
return c === void 0 ? (localStorage.removeItem(z), null) : (a > c.animations.length && (a = c.animations.length), {
|
|
741
|
+
title: i,
|
|
742
|
+
slideIndex: s,
|
|
743
|
+
buildIndex: a
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
function xt({ title: t, slideIndex: e, buildIndex: n }) {
|
|
747
|
+
localStorage.setItem(
|
|
748
|
+
z,
|
|
749
|
+
JSON.stringify({ title: t, slideIndex: e, buildIndex: n, timestamp: Date.now() })
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
const bt = Object.freeze({
|
|
753
|
+
accessibleDescriptionElement: null,
|
|
754
|
+
canvas: null,
|
|
755
|
+
extrasContainer: null,
|
|
756
|
+
mountedExtrasCleanups: [],
|
|
757
|
+
slideIndex: 0,
|
|
758
|
+
buildIndex: 0,
|
|
759
|
+
currentAnimationId: null,
|
|
760
|
+
imageById: {},
|
|
761
|
+
shortcutState: {
|
|
762
|
+
textCommand: null,
|
|
763
|
+
shortcuts: {}
|
|
764
|
+
}
|
|
765
|
+
}), A = {
|
|
766
|
+
Browser: "browser",
|
|
767
|
+
Node: "node"
|
|
768
|
+
};
|
|
769
|
+
function Lt(t) {
|
|
770
|
+
return typeof t == "string" ? [[{ text: t }]] : t.map((e) => e.map((n) => typeof n == "string" ? { text: n } : n));
|
|
771
|
+
}
|
|
772
|
+
function ue(t) {
|
|
773
|
+
const e = document.createElement("div");
|
|
774
|
+
return e.setAttribute("role", "status"), e.setAttribute("aria-label", t), e.setAttribute("aria-atomic", "true"), Object.assign(e.style, {
|
|
775
|
+
position: "absolute",
|
|
776
|
+
width: "1px",
|
|
777
|
+
height: "1px",
|
|
778
|
+
overflow: "hidden",
|
|
779
|
+
clipPath: "inset(50%)",
|
|
780
|
+
whiteSpace: "nowrap"
|
|
781
|
+
}), e;
|
|
782
|
+
}
|
|
783
|
+
function fe(t, e) {
|
|
784
|
+
const n = t.description ? [t.description] : [];
|
|
785
|
+
function r(i, o) {
|
|
786
|
+
const s = e.get(i);
|
|
787
|
+
if (s === void 0)
|
|
788
|
+
return;
|
|
789
|
+
const a = o * s.opacity;
|
|
790
|
+
if (!pe(s, a))
|
|
791
|
+
return;
|
|
792
|
+
const c = ge(s);
|
|
793
|
+
c && n.push(c);
|
|
794
|
+
for (const l of Y(i))
|
|
795
|
+
r(l, a);
|
|
796
|
+
}
|
|
797
|
+
for (const i of t.objects)
|
|
798
|
+
r(i, 1);
|
|
799
|
+
return n.join(`
|
|
800
|
+
`);
|
|
801
|
+
}
|
|
802
|
+
function pe(t, e) {
|
|
803
|
+
return e !== 0 && (!("drawn" in t) || t.drawn !== 0);
|
|
804
|
+
}
|
|
805
|
+
function ge(t) {
|
|
806
|
+
return t.description !== null ? t.description : ye(t) ? me(t) : null;
|
|
807
|
+
}
|
|
808
|
+
function ye(t) {
|
|
809
|
+
return t.objectType === T.TEXT;
|
|
810
|
+
}
|
|
811
|
+
function me(t) {
|
|
812
|
+
let e = t.length;
|
|
813
|
+
return Lt(t.text).map(
|
|
814
|
+
(n) => n.map((r) => {
|
|
815
|
+
if (e === null)
|
|
816
|
+
return r.text;
|
|
817
|
+
if (e <= 0)
|
|
818
|
+
return "";
|
|
819
|
+
const i = r.text.slice(0, e);
|
|
820
|
+
return e -= i.length, i;
|
|
821
|
+
}).join("")
|
|
822
|
+
).join(`
|
|
823
|
+
`);
|
|
824
|
+
}
|
|
825
|
+
function xe(t, e) {
|
|
826
|
+
t.textContent !== e && (t.textContent = e);
|
|
827
|
+
}
|
|
828
|
+
function be(t, e) {
|
|
829
|
+
e.context.clearRect(0, 0, t.width, t.height);
|
|
830
|
+
}
|
|
831
|
+
function kt(t) {
|
|
832
|
+
const e = document.createElement("canvas");
|
|
833
|
+
return e.setAttribute("width", t.width.toString()), e.setAttribute("height", t.height.toString()), e.setAttribute("aria-hidden", "true"), e.style.position = "absolute", e.style.width = "100%", e;
|
|
834
|
+
}
|
|
835
|
+
const F = {
|
|
836
|
+
Browser: "browser",
|
|
837
|
+
Node: "node"
|
|
838
|
+
};
|
|
839
|
+
function we(t) {
|
|
840
|
+
const e = new Path2D(t);
|
|
841
|
+
return {
|
|
842
|
+
type: F.Browser,
|
|
843
|
+
path: e
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function ve(t) {
|
|
847
|
+
const { drawn: e, startX: n, startY: r, endX: i, endY: o, arrowheadSize: s, isArrowheadFilled: a, isDrawnFromCenter: c } = t, l = { x: n, y: r }, d = { x: i, y: o }, h = Math.atan2(d.y - l.y, d.x - l.x), u = { x: l.x + (d.x - l.x) / 2, y: l.y + (d.y - l.y) / 2 }, p = d.x - l.x, g = d.y - l.y, w = Math.hypot(p, g) * e, O = Math.cos(h), v = Math.sin(h), b = c ? { x: u.x - O * w / 2, y: u.y - v * w / 2 } : l, S = c ? { x: u.x + O * w / 2, y: u.y + v * w / 2 } : { x: l.x + O * w, y: l.y + v * w }, C = a ? Math.PI / 6 : Math.PI / 4.5, y = w < s * 2 ? w / 2 : s, N = {
|
|
848
|
+
x: S.x - y * Math.cos(h - C),
|
|
849
|
+
y: S.y - y * Math.sin(h - C)
|
|
850
|
+
}, E = {
|
|
851
|
+
x: S.x - y * Math.cos(h + C),
|
|
852
|
+
y: S.y - y * Math.sin(h + C)
|
|
853
|
+
}, B = {
|
|
854
|
+
x: b.x + y * Math.cos(h - C),
|
|
855
|
+
y: b.y + y * Math.sin(h - C)
|
|
856
|
+
}, _ = {
|
|
857
|
+
x: b.x + y * Math.cos(h + C),
|
|
858
|
+
y: b.y + y * Math.sin(h + C)
|
|
859
|
+
};
|
|
860
|
+
return {
|
|
861
|
+
arrowPoints: [b, S],
|
|
862
|
+
arrowheadPoints: [N, S, E],
|
|
863
|
+
doubledArrowheadPoints: [B, b, _]
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function rt(t, e = null) {
|
|
867
|
+
const { red: n, green: r, blue: i } = t, o = n << 16 | r << 8 | i, s = Math.round(Ot(t, e) * 255);
|
|
868
|
+
return `#${o.toString(16).padStart(6, "0")}${s !== 255 ? s.toString(16).padStart(2, "0") : ""}`;
|
|
869
|
+
}
|
|
870
|
+
function H({
|
|
871
|
+
ctx: t,
|
|
872
|
+
color: e,
|
|
873
|
+
drawn: n = null,
|
|
874
|
+
isDrawnFromCenter: r = !1,
|
|
875
|
+
isRounded: i = !1,
|
|
876
|
+
opacity: o = null,
|
|
877
|
+
path: s,
|
|
878
|
+
pathLength: a = null,
|
|
879
|
+
width: c
|
|
880
|
+
}) {
|
|
881
|
+
if (!(c === 0 || n === 0)) {
|
|
882
|
+
if (n !== null && a !== null && n !== 1) {
|
|
883
|
+
const l = a + (i ? c : 0), d = a * n;
|
|
884
|
+
if (!r)
|
|
885
|
+
t.context.setLineDash([d, l - d]), t.context.lineDashOffset = 0;
|
|
886
|
+
else {
|
|
887
|
+
const h = l - d;
|
|
888
|
+
t.context.setLineDash([d, h]), t.context.lineDashOffset = -h / 2;
|
|
889
|
+
}
|
|
890
|
+
} else
|
|
891
|
+
t.context.setLineDash([]), t.context.lineDashOffset = 0;
|
|
892
|
+
if (t.context.lineWidth = c, t.context.strokeStyle = rt(e, o), t.context.lineCap = i ? "round" : "butt", s === void 0) {
|
|
893
|
+
t.context.stroke();
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
switch (t.type) {
|
|
897
|
+
case A.Browser:
|
|
898
|
+
s.type === F.Browser ? t.context.stroke(s.path) : console.warn("Attempted to use Node Path2D in Browser Canvas context");
|
|
899
|
+
break;
|
|
900
|
+
case A.Node:
|
|
901
|
+
s.type === F.Node ? t.context.stroke(s.path) : console.warn("Attempted to use Browser Path2D in Node Canvas context");
|
|
902
|
+
break;
|
|
903
|
+
default:
|
|
904
|
+
L(t);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function j({ ctx: t, path: e, color: n, opacity: r = null }) {
|
|
909
|
+
if (t.context.fillStyle = ot(n, r), e === void 0) {
|
|
910
|
+
t.context.fill();
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
switch (t.type) {
|
|
914
|
+
case A.Browser:
|
|
915
|
+
e.type === F.Browser ? t.context.fill(e.path) : console.warn("Attempted to use Node Path2D in Browser Canvas context");
|
|
916
|
+
break;
|
|
917
|
+
case A.Node:
|
|
918
|
+
e.type === F.Node ? t.context.fill(e.path) : console.warn("Attempted to use Browser Path2D in Node Canvas context");
|
|
919
|
+
break;
|
|
920
|
+
default:
|
|
921
|
+
L(t);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
function q(t, e) {
|
|
925
|
+
const n = e(), r = t[0];
|
|
926
|
+
if (r === void 0)
|
|
927
|
+
return { path: n, length: 0 };
|
|
928
|
+
n.path.moveTo(r.x, r.y);
|
|
929
|
+
let i = 0;
|
|
930
|
+
for (let o = 1; o < t.length; o++) {
|
|
931
|
+
const s = t[o], a = t[o - 1];
|
|
932
|
+
if (s === void 0 || a === void 0)
|
|
933
|
+
continue;
|
|
934
|
+
const c = s.x - a.x, l = s.y - a.y;
|
|
935
|
+
i += Math.hypot(c, l), n.path.lineTo(s.x, s.y);
|
|
936
|
+
}
|
|
937
|
+
return { path: n, length: i };
|
|
938
|
+
}
|
|
939
|
+
const Se = ({
|
|
940
|
+
ctx: t,
|
|
941
|
+
object: e,
|
|
942
|
+
opacity: n,
|
|
943
|
+
createPath2D: r
|
|
944
|
+
}) => {
|
|
945
|
+
const i = e.opacity * n;
|
|
946
|
+
if (i === 0 || e.drawn === 0)
|
|
947
|
+
return;
|
|
948
|
+
const { arrowPoints: o, arrowheadPoints: s, doubledArrowheadPoints: a } = ve(e), { path: c } = q(o, r), { path: l } = q(s, r);
|
|
949
|
+
if (H({
|
|
950
|
+
color: e.color,
|
|
951
|
+
ctx: t,
|
|
952
|
+
path: c,
|
|
953
|
+
opacity: i,
|
|
954
|
+
width: e.width
|
|
955
|
+
}), e.isArrowheadFilled && (l.path.closePath(), j({
|
|
956
|
+
ctx: t,
|
|
957
|
+
path: l,
|
|
958
|
+
color: e.color,
|
|
959
|
+
opacity: i
|
|
960
|
+
})), H({
|
|
961
|
+
color: e.color,
|
|
962
|
+
ctx: t,
|
|
963
|
+
path: l,
|
|
964
|
+
opacity: i,
|
|
965
|
+
width: e.width
|
|
966
|
+
}), e.isArrowheadDoubled) {
|
|
967
|
+
const { path: d } = q(
|
|
968
|
+
a,
|
|
969
|
+
r
|
|
970
|
+
);
|
|
971
|
+
e.isArrowheadFilled && (d.path.closePath(), j({
|
|
972
|
+
ctx: t,
|
|
973
|
+
path: d,
|
|
974
|
+
color: e.color,
|
|
975
|
+
opacity: i
|
|
976
|
+
})), H({
|
|
977
|
+
color: e.color,
|
|
978
|
+
ctx: t,
|
|
979
|
+
path: d,
|
|
980
|
+
opacity: i,
|
|
981
|
+
width: e.width
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
function Ce(t, e) {
|
|
986
|
+
const n = t.radius - t.strokeWidth / 2;
|
|
987
|
+
if (n <= 0)
|
|
988
|
+
return;
|
|
989
|
+
const r = e(), i = -Math.PI / 2;
|
|
990
|
+
return r.path.arc(t.x, t.y, n, i, i + 2 * Math.PI), r;
|
|
991
|
+
}
|
|
992
|
+
function Te(t, e) {
|
|
993
|
+
const n = e(), r = -Math.PI / 2;
|
|
994
|
+
n.path.arc(t.x, t.y, t.radius, r, r + 2 * Math.PI);
|
|
995
|
+
const i = 2 * Math.PI * t.radius;
|
|
996
|
+
return { path: n, length: i };
|
|
997
|
+
}
|
|
998
|
+
function Mt(t, e) {
|
|
999
|
+
switch (t.type) {
|
|
1000
|
+
case A.Browser:
|
|
1001
|
+
e.type === F.Browser ? t.context.clip(e.path) : console.warn("Attempted to use Node Path2D in Browser Canvas context");
|
|
1002
|
+
break;
|
|
1003
|
+
case A.Node:
|
|
1004
|
+
e.type === F.Node ? t.context.clip(e.path) : console.warn("Attempted to use Browser Path2D in Node Canvas context");
|
|
1005
|
+
break;
|
|
1006
|
+
default:
|
|
1007
|
+
L(t);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
const Ie = ({
|
|
1011
|
+
ctx: t,
|
|
1012
|
+
object: e,
|
|
1013
|
+
opacity: n,
|
|
1014
|
+
createPath2D: r
|
|
1015
|
+
}) => {
|
|
1016
|
+
const i = e.opacity * n;
|
|
1017
|
+
if (i === 0 || e.drawn === 0 && e.fillColor.alpha === 0)
|
|
1018
|
+
return;
|
|
1019
|
+
const { path: o, length: s } = Te(e, r);
|
|
1020
|
+
if (i < 1 && e.strokeWidth > 0) {
|
|
1021
|
+
const a = Ce(e, r);
|
|
1022
|
+
a !== void 0 && (t.context.save(), Mt(t, a), j({ ctx: t, path: o, color: e.fillColor, opacity: i }), t.context.restore());
|
|
1023
|
+
} else
|
|
1024
|
+
j({ ctx: t, path: o, color: e.fillColor, opacity: i });
|
|
1025
|
+
H({
|
|
1026
|
+
color: e.strokeColor,
|
|
1027
|
+
ctx: t,
|
|
1028
|
+
drawn: e.drawn,
|
|
1029
|
+
path: o,
|
|
1030
|
+
pathLength: s,
|
|
1031
|
+
opacity: i,
|
|
1032
|
+
width: e.strokeWidth
|
|
1033
|
+
});
|
|
1034
|
+
};
|
|
1035
|
+
function x(t = null) {
|
|
1036
|
+
return {
|
|
1037
|
+
x: 0,
|
|
1038
|
+
y: 0,
|
|
1039
|
+
...t
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
const Ee = x(), M = {
|
|
1043
|
+
TOP_LEFT: "TopLeft",
|
|
1044
|
+
TOP: "Top",
|
|
1045
|
+
TOP_RIGHT: "TopRight",
|
|
1046
|
+
LEFT: "Left",
|
|
1047
|
+
CENTER: "Center",
|
|
1048
|
+
RIGHT: "Right",
|
|
1049
|
+
BOTTOM_LEFT: "BottomLeft",
|
|
1050
|
+
BOTTOM: "Bottom",
|
|
1051
|
+
BOTTOM_RIGHT: "BottomRight"
|
|
1052
|
+
};
|
|
1053
|
+
function R(t = null) {
|
|
1054
|
+
return {
|
|
1055
|
+
origin: Ee,
|
|
1056
|
+
size: oe,
|
|
1057
|
+
...t
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
R();
|
|
1061
|
+
function k(t, e, n) {
|
|
1062
|
+
const { x: r, y: i } = t, { width: o, height: s } = n;
|
|
1063
|
+
switch (e) {
|
|
1064
|
+
case M.TOP_LEFT:
|
|
1065
|
+
return R({
|
|
1066
|
+
origin: x({ x: r, y: i }),
|
|
1067
|
+
size: n
|
|
1068
|
+
});
|
|
1069
|
+
case M.TOP:
|
|
1070
|
+
return R({
|
|
1071
|
+
origin: x({ x: r - o / 2, y: i }),
|
|
1072
|
+
size: n
|
|
1073
|
+
});
|
|
1074
|
+
case M.TOP_RIGHT:
|
|
1075
|
+
return R({
|
|
1076
|
+
origin: x({ x: r - o, y: i }),
|
|
1077
|
+
size: n
|
|
1078
|
+
});
|
|
1079
|
+
case M.LEFT:
|
|
1080
|
+
return R({
|
|
1081
|
+
origin: x({ x: r, y: i - s / 2 }),
|
|
1082
|
+
size: n
|
|
1083
|
+
});
|
|
1084
|
+
case M.CENTER:
|
|
1085
|
+
return R({
|
|
1086
|
+
origin: x({ x: r - o / 2, y: i - s / 2 }),
|
|
1087
|
+
size: n
|
|
1088
|
+
});
|
|
1089
|
+
case M.RIGHT:
|
|
1090
|
+
return R({
|
|
1091
|
+
origin: x({ x: r - o, y: i - s / 2 }),
|
|
1092
|
+
size: n
|
|
1093
|
+
});
|
|
1094
|
+
case M.BOTTOM_LEFT:
|
|
1095
|
+
return R({
|
|
1096
|
+
origin: x({ x: r, y: i - s }),
|
|
1097
|
+
size: n
|
|
1098
|
+
});
|
|
1099
|
+
case M.BOTTOM:
|
|
1100
|
+
return R({
|
|
1101
|
+
origin: x({ x: r - o / 2, y: i - s }),
|
|
1102
|
+
size: n
|
|
1103
|
+
});
|
|
1104
|
+
case M.BOTTOM_RIGHT:
|
|
1105
|
+
return R({
|
|
1106
|
+
origin: x({ x: r - o, y: i - s }),
|
|
1107
|
+
size: n
|
|
1108
|
+
});
|
|
1109
|
+
default:
|
|
1110
|
+
L(e);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
const Ae = ({
|
|
1114
|
+
ctx: t,
|
|
1115
|
+
object: e,
|
|
1116
|
+
renderObject: n,
|
|
1117
|
+
opacity: r
|
|
1118
|
+
}) => {
|
|
1119
|
+
const i = e.scale * e.scaleX, o = e.scale * e.scaleY, s = k(
|
|
1120
|
+
x({ x: e.x, y: e.y }),
|
|
1121
|
+
e.anchor,
|
|
1122
|
+
I({
|
|
1123
|
+
width: e.width * Math.abs(i),
|
|
1124
|
+
height: e.height * Math.abs(o)
|
|
1125
|
+
})
|
|
1126
|
+
), { rotation: a, rotateOriginX: c, rotateOriginY: l, skewOriginX: d, skewOriginY: h, skewX: u, skewY: p } = e;
|
|
1127
|
+
if (!(i === 0 || o === 0)) {
|
|
1128
|
+
t.context.save(), t.context.translate(s.origin.x, s.origin.y), t.context.scale(i, o), t.context.translate(c, l), t.context.rotate(a * Math.PI / 180), t.context.translate(-c, -l), t.context.translate(d, h), t.context.transform(
|
|
1129
|
+
1,
|
|
1130
|
+
Math.tan(p * Math.PI / 180),
|
|
1131
|
+
Math.tan(u * Math.PI / 180),
|
|
1132
|
+
1,
|
|
1133
|
+
0,
|
|
1134
|
+
0
|
|
1135
|
+
), t.context.translate(-d, -h);
|
|
1136
|
+
for (const g of e.objects)
|
|
1137
|
+
n(g, r * e.opacity);
|
|
1138
|
+
e.previewColor !== null && (t.context.fillStyle = rt(e.previewColor), t.context.fillRect(0, 0, e.width, e.height)), e.rotateOriginPreviewSize > 0 && (t.context.fillStyle = "red", t.context.beginPath(), t.context.arc(c, l, e.rotateOriginPreviewSize, 0, 2 * Math.PI), t.context.fill()), e.skewOriginPreviewSize > 0 && (t.context.fillStyle = "blue", t.context.beginPath(), t.context.arc(d, h, e.skewOriginPreviewSize, 0, 2 * Math.PI), t.context.fill()), t.context.restore();
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
function st(t, e, n, r, i = 0) {
|
|
1142
|
+
const o = r();
|
|
1143
|
+
o.path.moveTo(t.x + n, t.y), o.path.lineTo(t.x + e.width - n, t.y), o.path.arcTo(
|
|
1144
|
+
t.x + e.width,
|
|
1145
|
+
t.y,
|
|
1146
|
+
t.x + e.width,
|
|
1147
|
+
t.y + n,
|
|
1148
|
+
n
|
|
1149
|
+
), o.path.lineTo(t.x + e.width, t.y + e.height - n), o.path.arcTo(
|
|
1150
|
+
t.x + e.width,
|
|
1151
|
+
t.y + e.height,
|
|
1152
|
+
t.x + e.width - n,
|
|
1153
|
+
t.y + e.height,
|
|
1154
|
+
n
|
|
1155
|
+
), o.path.lineTo(t.x + n, t.y + e.height), o.path.arcTo(
|
|
1156
|
+
t.x,
|
|
1157
|
+
t.y + e.height,
|
|
1158
|
+
t.x,
|
|
1159
|
+
t.y + e.height - n,
|
|
1160
|
+
n
|
|
1161
|
+
), o.path.lineTo(t.x, t.y + n), o.path.arcTo(t.x, t.y, t.x + n, t.y, n), i > 0 && o.path.lineTo(t.x + n + i, t.y);
|
|
1162
|
+
const s = 2 * (e.width + e.height - 4 * n) + 2 * Math.PI * n + i;
|
|
1163
|
+
return { path: o, length: s };
|
|
1164
|
+
}
|
|
1165
|
+
const W = {
|
|
1166
|
+
Browser: "browser",
|
|
1167
|
+
Node: "node"
|
|
1168
|
+
}, Pe = ({
|
|
1169
|
+
ctx: t,
|
|
1170
|
+
imageById: e,
|
|
1171
|
+
object: n,
|
|
1172
|
+
opacity: r,
|
|
1173
|
+
createPath2D: i
|
|
1174
|
+
}) => {
|
|
1175
|
+
const o = k(
|
|
1176
|
+
x({ x: n.x, y: n.y }),
|
|
1177
|
+
n.anchor,
|
|
1178
|
+
I({ width: n.width, height: n.height })
|
|
1179
|
+
), s = n.imageId != null && n.imageId.length > 0 ? n.imageId : n.imagePath;
|
|
1180
|
+
if (s == null)
|
|
1181
|
+
return;
|
|
1182
|
+
const a = e[s];
|
|
1183
|
+
if (a !== void 0) {
|
|
1184
|
+
if (t.context.save(), n.cornerRadius > 0) {
|
|
1185
|
+
const c = st(
|
|
1186
|
+
o.origin,
|
|
1187
|
+
o.size,
|
|
1188
|
+
n.cornerRadius,
|
|
1189
|
+
i
|
|
1190
|
+
);
|
|
1191
|
+
switch (t.type) {
|
|
1192
|
+
case A.Browser:
|
|
1193
|
+
c.path.type === F.Browser ? t.context.clip(c.path.path) : console.warn("Attempted to use Node Path2D in Browser Canvas context");
|
|
1194
|
+
break;
|
|
1195
|
+
case A.Node:
|
|
1196
|
+
c.path.type === F.Node ? t.context.clip(c.path.path) : console.warn("Attempted to use Browser Path2D in Node Canvas context");
|
|
1197
|
+
break;
|
|
1198
|
+
default:
|
|
1199
|
+
L(t);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
switch (t.context.globalAlpha = r * n.opacity, t.context.imageSmoothingEnabled = n.smooth, t.type) {
|
|
1203
|
+
case A.Browser:
|
|
1204
|
+
a.type === W.Browser ? t.context.drawImage(
|
|
1205
|
+
a.image,
|
|
1206
|
+
o.origin.x,
|
|
1207
|
+
o.origin.y,
|
|
1208
|
+
o.size.width,
|
|
1209
|
+
o.size.height
|
|
1210
|
+
) : console.warn("Attempted to use Node Image in Browser Canvas context");
|
|
1211
|
+
break;
|
|
1212
|
+
case A.Node:
|
|
1213
|
+
a.type === W.Node ? t.context.drawImage(
|
|
1214
|
+
a.image,
|
|
1215
|
+
o.origin.x,
|
|
1216
|
+
o.origin.y,
|
|
1217
|
+
o.size.width,
|
|
1218
|
+
o.size.height
|
|
1219
|
+
) : console.warn("Attempted to use Browser Image in Node Canvas context");
|
|
1220
|
+
break;
|
|
1221
|
+
default:
|
|
1222
|
+
L(t);
|
|
1223
|
+
}
|
|
1224
|
+
t.context.restore();
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
function Oe(t, e) {
|
|
1228
|
+
const n = e();
|
|
1229
|
+
n.path.moveTo(t.startX, t.startY), n.path.lineTo(t.endX, t.endY);
|
|
1230
|
+
const r = Math.hypot(t.endX - t.startX, t.endY - t.startY);
|
|
1231
|
+
return { path: n, length: r };
|
|
1232
|
+
}
|
|
1233
|
+
const Ne = ({
|
|
1234
|
+
ctx: t,
|
|
1235
|
+
object: e,
|
|
1236
|
+
opacity: n,
|
|
1237
|
+
createPath2D: r
|
|
1238
|
+
}) => {
|
|
1239
|
+
const i = e.opacity * n;
|
|
1240
|
+
if (i === 0 || e.drawn === 0)
|
|
1241
|
+
return;
|
|
1242
|
+
const { path: o, length: s } = Oe(e, r);
|
|
1243
|
+
H({
|
|
1244
|
+
color: e.color,
|
|
1245
|
+
ctx: t,
|
|
1246
|
+
drawn: e.drawn,
|
|
1247
|
+
isDrawnFromCenter: e.isDrawnFromCenter,
|
|
1248
|
+
isRounded: e.isRounded,
|
|
1249
|
+
path: o,
|
|
1250
|
+
pathLength: s,
|
|
1251
|
+
opacity: i,
|
|
1252
|
+
width: e.width
|
|
1253
|
+
});
|
|
1254
|
+
}, Be = ({
|
|
1255
|
+
ctx: t,
|
|
1256
|
+
object: e,
|
|
1257
|
+
opacity: n,
|
|
1258
|
+
renderObject: r
|
|
1259
|
+
}) => {
|
|
1260
|
+
t.context.save();
|
|
1261
|
+
const i = k(
|
|
1262
|
+
x({ x: e.x, y: e.y }),
|
|
1263
|
+
e.anchor,
|
|
1264
|
+
I({ width: e.width, height: e.height })
|
|
1265
|
+
);
|
|
1266
|
+
e.preview && (t.context.lineWidth = 4, t.context.strokeStyle = rt(P.RED), t.context.rect(i.origin.x, i.origin.y, i.size.width, i.size.height), t.context.stroke()), t.context.beginPath(), t.context.rect(i.origin.x, i.origin.y, i.size.width, i.size.height), t.context.closePath(), t.context.clip();
|
|
1267
|
+
for (const o of e.objects)
|
|
1268
|
+
r(o, n * e.opacity);
|
|
1269
|
+
t.context.restore();
|
|
1270
|
+
}, Re = ({
|
|
1271
|
+
ctx: t,
|
|
1272
|
+
object: e,
|
|
1273
|
+
opacity: n,
|
|
1274
|
+
createPath2D: r
|
|
1275
|
+
}) => {
|
|
1276
|
+
const i = e.opacity * n;
|
|
1277
|
+
if (i === 0 || e.drawn === 0 && e.fillColor.alpha === 0)
|
|
1278
|
+
return;
|
|
1279
|
+
const { origin: o } = k(
|
|
1280
|
+
x({ x: e.x, y: e.y }),
|
|
1281
|
+
e.anchor,
|
|
1282
|
+
I({ width: e.width, height: e.height })
|
|
1283
|
+
), s = r(e.path);
|
|
1284
|
+
t.context.save(), t.context.translate(o.x, o.y), t.context.scale(e.width / e.viewboxWidth, e.height / e.viewboxHeight), j({
|
|
1285
|
+
ctx: t,
|
|
1286
|
+
path: s,
|
|
1287
|
+
color: e.fillColor,
|
|
1288
|
+
opacity: i
|
|
1289
|
+
}), H({
|
|
1290
|
+
color: e.strokeColor,
|
|
1291
|
+
ctx: t,
|
|
1292
|
+
drawn: e.drawn,
|
|
1293
|
+
isRounded: e.isRounded,
|
|
1294
|
+
path: s,
|
|
1295
|
+
pathLength: e.pathLength,
|
|
1296
|
+
opacity: i,
|
|
1297
|
+
width: e.strokeWidth
|
|
1298
|
+
}), t.context.restore();
|
|
1299
|
+
};
|
|
1300
|
+
function Le(t, e) {
|
|
1301
|
+
const n = e(), r = t.points, i = r[0];
|
|
1302
|
+
if (i === void 0)
|
|
1303
|
+
return { path: n, length: 0 };
|
|
1304
|
+
n.path.moveTo(i.x, i.y);
|
|
1305
|
+
let o = 0, s = i;
|
|
1306
|
+
for (let c = 1; c < r.length; c++) {
|
|
1307
|
+
const l = r[c];
|
|
1308
|
+
if (l === void 0)
|
|
1309
|
+
continue;
|
|
1310
|
+
n.path.lineTo(l.x, l.y);
|
|
1311
|
+
const d = Math.hypot(l.x - s.x, l.y - s.y);
|
|
1312
|
+
o += d, s = l;
|
|
1313
|
+
}
|
|
1314
|
+
n.path.closePath();
|
|
1315
|
+
const a = Math.hypot(
|
|
1316
|
+
i.x - s.x,
|
|
1317
|
+
i.y - s.y
|
|
1318
|
+
);
|
|
1319
|
+
return o += a, { path: n, length: o };
|
|
1320
|
+
}
|
|
1321
|
+
const ke = ({
|
|
1322
|
+
ctx: t,
|
|
1323
|
+
object: e,
|
|
1324
|
+
opacity: n,
|
|
1325
|
+
createPath2D: r
|
|
1326
|
+
}) => {
|
|
1327
|
+
const i = e.opacity * n;
|
|
1328
|
+
if (i === 0 || e.drawn === 0 && e.fillColor.alpha === 0)
|
|
1329
|
+
return;
|
|
1330
|
+
const { path: o, length: s } = Le(e, r);
|
|
1331
|
+
j({
|
|
1332
|
+
ctx: t,
|
|
1333
|
+
path: o,
|
|
1334
|
+
color: e.fillColor,
|
|
1335
|
+
opacity: i
|
|
1336
|
+
}), H({
|
|
1337
|
+
color: e.strokeColor,
|
|
1338
|
+
ctx: t,
|
|
1339
|
+
drawn: e.drawn,
|
|
1340
|
+
path: o,
|
|
1341
|
+
pathLength: s,
|
|
1342
|
+
opacity: i,
|
|
1343
|
+
width: e.strokeWidth
|
|
1344
|
+
});
|
|
1345
|
+
};
|
|
1346
|
+
function Me(t, e) {
|
|
1347
|
+
const n = t.strokeWidth / 2, { origin: r, size: i } = k(
|
|
1348
|
+
x({ x: t.x, y: t.y }),
|
|
1349
|
+
t.anchor,
|
|
1350
|
+
I({ width: t.width, height: t.height })
|
|
1351
|
+
), o = i.width - t.strokeWidth, s = i.height - t.strokeWidth;
|
|
1352
|
+
if (o <= 0 || s <= 0)
|
|
1353
|
+
return;
|
|
1354
|
+
const a = x({ x: r.x + n, y: r.y + n }), c = I({ width: o, height: s }), l = Math.max(
|
|
1355
|
+
0,
|
|
1356
|
+
Math.min(t.cornerRadius - n, Math.min(o, s) / 2)
|
|
1357
|
+
);
|
|
1358
|
+
if (l > 0)
|
|
1359
|
+
return st(a, c, l, e).path;
|
|
1360
|
+
const d = e();
|
|
1361
|
+
return d.path.moveTo(a.x, a.y), d.path.lineTo(a.x + o, a.y), d.path.lineTo(a.x + o, a.y + s), d.path.lineTo(a.x, a.y + s), d.path.closePath(), d;
|
|
1362
|
+
}
|
|
1363
|
+
function Fe(t, e) {
|
|
1364
|
+
const { origin: n, size: r } = k(
|
|
1365
|
+
x({ x: t.x, y: t.y }),
|
|
1366
|
+
t.anchor,
|
|
1367
|
+
I({ width: t.width, height: t.height })
|
|
1368
|
+
), i = Math.max(
|
|
1369
|
+
0,
|
|
1370
|
+
Math.min(t.cornerRadius, Math.min(r.width, r.height) / 2)
|
|
1371
|
+
), o = Math.min(t.strokeWidth * 2, r.width - i);
|
|
1372
|
+
if (i > 0)
|
|
1373
|
+
return st(n, r, i, e, o);
|
|
1374
|
+
{
|
|
1375
|
+
const s = e();
|
|
1376
|
+
s.path.moveTo(n.x, n.y), s.path.lineTo(n.x + r.width, n.y), s.path.lineTo(n.x + r.width, n.y + r.height), s.path.lineTo(n.x, n.y + r.height), s.path.lineTo(n.x, n.y), s.path.lineTo(n.x + o, n.y);
|
|
1377
|
+
const a = 2 * (r.width + r.height) + o;
|
|
1378
|
+
return { path: s, length: a };
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const je = ({
|
|
1382
|
+
ctx: t,
|
|
1383
|
+
object: e,
|
|
1384
|
+
opacity: n,
|
|
1385
|
+
createPath2D: r
|
|
1386
|
+
}) => {
|
|
1387
|
+
const i = e.opacity * n;
|
|
1388
|
+
if (i === 0 || e.drawn === 0 && e.fillColor.alpha === 0)
|
|
1389
|
+
return;
|
|
1390
|
+
const { path: o, length: s } = Fe(e, r);
|
|
1391
|
+
if (i < 1 && e.strokeWidth > 0) {
|
|
1392
|
+
const a = Me(e, r);
|
|
1393
|
+
a !== void 0 && (t.context.save(), Mt(t, a), j({ ctx: t, path: o, color: e.fillColor, opacity: i }), t.context.restore());
|
|
1394
|
+
} else
|
|
1395
|
+
j({ ctx: t, path: o, color: e.fillColor, opacity: i });
|
|
1396
|
+
H({
|
|
1397
|
+
color: e.strokeColor,
|
|
1398
|
+
ctx: t,
|
|
1399
|
+
drawn: e.drawn,
|
|
1400
|
+
path: o,
|
|
1401
|
+
pathLength: s,
|
|
1402
|
+
opacity: i,
|
|
1403
|
+
width: e.strokeWidth
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1406
|
+
function De(t) {
|
|
1407
|
+
const { origin: e, size: n } = k(
|
|
1408
|
+
x({ x: t.x, y: t.y }),
|
|
1409
|
+
t.anchor,
|
|
1410
|
+
I({ width: t.width, height: t.height })
|
|
1411
|
+
);
|
|
1412
|
+
return {
|
|
1413
|
+
origin: e,
|
|
1414
|
+
size: n,
|
|
1415
|
+
cornerRadius: Math.max(
|
|
1416
|
+
0,
|
|
1417
|
+
Math.min(t.cornerRadius, Math.min(n.width, n.height) / 2)
|
|
1418
|
+
)
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
function ze(t, e, n, r = {
|
|
1422
|
+
origin: x({ x: 0, y: 0 }),
|
|
1423
|
+
size: e
|
|
1424
|
+
}) {
|
|
1425
|
+
const i = n(), { origin: o, size: s, cornerRadius: a } = De(t), { origin: c, size: l } = r;
|
|
1426
|
+
return i.path.moveTo(c.x, c.y), i.path.lineTo(c.x + l.width, c.y), i.path.lineTo(c.x + l.width, c.y + l.height), i.path.lineTo(c.x, c.y + l.height), i.path.lineTo(c.x, c.y), a === 0 ? (i.path.moveTo(o.x, o.y), i.path.lineTo(o.x, o.y + s.height), i.path.lineTo(o.x + s.width, o.y + s.height), i.path.lineTo(o.x + s.width, o.y), i.path.lineTo(o.x, o.y), i) : (i.path.moveTo(o.x + a, o.y), i.path.arcTo(o.x, o.y, o.x, o.y + a, a), i.path.lineTo(o.x, o.y + s.height - a), i.path.arcTo(
|
|
1427
|
+
o.x,
|
|
1428
|
+
o.y + s.height,
|
|
1429
|
+
o.x + a,
|
|
1430
|
+
o.y + s.height,
|
|
1431
|
+
a
|
|
1432
|
+
), i.path.lineTo(o.x + s.width - a, o.y + s.height), i.path.arcTo(
|
|
1433
|
+
o.x + s.width,
|
|
1434
|
+
o.y + s.height,
|
|
1435
|
+
o.x + s.width,
|
|
1436
|
+
o.y + s.height - a,
|
|
1437
|
+
a
|
|
1438
|
+
), i.path.lineTo(o.x + s.width, o.y + a), i.path.arcTo(
|
|
1439
|
+
o.x + s.width,
|
|
1440
|
+
o.y,
|
|
1441
|
+
o.x + s.width - a,
|
|
1442
|
+
o.y,
|
|
1443
|
+
a
|
|
1444
|
+
), i.path.lineTo(o.x + a, o.y), i);
|
|
1445
|
+
}
|
|
1446
|
+
const Ve = ({
|
|
1447
|
+
createPath2D: t,
|
|
1448
|
+
ctx: e,
|
|
1449
|
+
object: n,
|
|
1450
|
+
opacity: r,
|
|
1451
|
+
renderScale: i,
|
|
1452
|
+
slideSize: o
|
|
1453
|
+
}) => {
|
|
1454
|
+
const s = n.opacity * r;
|
|
1455
|
+
if (s === 0 || n.color.alpha === 0)
|
|
1456
|
+
return;
|
|
1457
|
+
const a = I({
|
|
1458
|
+
width: o.width / i,
|
|
1459
|
+
height: o.height / i
|
|
1460
|
+
}), c = x({
|
|
1461
|
+
x: (o.width - a.width) / 2,
|
|
1462
|
+
y: (o.height - a.height) / 2
|
|
1463
|
+
}), l = ze(n, o, t, {
|
|
1464
|
+
origin: c,
|
|
1465
|
+
size: a
|
|
1466
|
+
});
|
|
1467
|
+
j({ ctx: e, path: l, color: n.color, opacity: s });
|
|
1468
|
+
}, He = ({
|
|
1469
|
+
ctx: t,
|
|
1470
|
+
imageById: e,
|
|
1471
|
+
object: n,
|
|
1472
|
+
opacity: r
|
|
1473
|
+
}) => {
|
|
1474
|
+
const i = n.opacity * r;
|
|
1475
|
+
if (i === 0 || !n.svg)
|
|
1476
|
+
return;
|
|
1477
|
+
const o = e[n.svg];
|
|
1478
|
+
if (o === void 0)
|
|
1479
|
+
return;
|
|
1480
|
+
const s = k(
|
|
1481
|
+
x({ x: n.x, y: n.y }),
|
|
1482
|
+
n.anchor,
|
|
1483
|
+
I({ width: n.width, height: n.height })
|
|
1484
|
+
);
|
|
1485
|
+
switch (t.context.save(), t.context.globalAlpha = i, t.type) {
|
|
1486
|
+
case A.Browser:
|
|
1487
|
+
o.type === W.Browser && t.context.drawImage(
|
|
1488
|
+
o.image,
|
|
1489
|
+
s.origin.x,
|
|
1490
|
+
s.origin.y,
|
|
1491
|
+
s.size.width,
|
|
1492
|
+
s.size.height
|
|
1493
|
+
);
|
|
1494
|
+
break;
|
|
1495
|
+
case A.Node:
|
|
1496
|
+
o.type === W.Node && t.context.drawImage(
|
|
1497
|
+
o.image,
|
|
1498
|
+
s.origin.x,
|
|
1499
|
+
s.origin.y,
|
|
1500
|
+
s.size.width,
|
|
1501
|
+
s.size.height
|
|
1502
|
+
);
|
|
1503
|
+
break;
|
|
1504
|
+
default:
|
|
1505
|
+
L(t);
|
|
1506
|
+
}
|
|
1507
|
+
t.context.restore();
|
|
1508
|
+
}, Q = {
|
|
1509
|
+
LEFT: "left",
|
|
1510
|
+
CENTER: "center",
|
|
1511
|
+
RIGHT: "right"
|
|
1512
|
+
};
|
|
1513
|
+
function _e(t) {
|
|
1514
|
+
return {
|
|
1515
|
+
color: t.color,
|
|
1516
|
+
fontFamily: t.fontFamily,
|
|
1517
|
+
fontSize: t.fontSize,
|
|
1518
|
+
fontStyle: t.fontStyle,
|
|
1519
|
+
fontWeight: t.fontWeight,
|
|
1520
|
+
ligatures: t.ligatures,
|
|
1521
|
+
subscript: t.subscript,
|
|
1522
|
+
superscript: t.superscript
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
function $e(t) {
|
|
1526
|
+
const e = Math.max(...t.map((r) => r.bottom), 0), n = Math.max(...t.map((r) => r.top), 0);
|
|
1527
|
+
return {
|
|
1528
|
+
bottom: e,
|
|
1529
|
+
height: n + e,
|
|
1530
|
+
lineAdvance: Math.max(...t.map((r) => r.lineAdvance), 0),
|
|
1531
|
+
top: n,
|
|
1532
|
+
width: t.reduce((r, i) => r + i.width, 0)
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
function We(t, e = 1) {
|
|
1536
|
+
const n = t.map($e);
|
|
1537
|
+
if (n.length === 0)
|
|
1538
|
+
return {
|
|
1539
|
+
baselines: [],
|
|
1540
|
+
size: I()
|
|
1541
|
+
};
|
|
1542
|
+
let r = 0, i, o = 0, s = 0;
|
|
1543
|
+
const a = [];
|
|
1544
|
+
for (const l of n) {
|
|
1545
|
+
const h = (l.lineAdvance * e - l.height) / 2, u = l.top + h;
|
|
1546
|
+
i === void 0 ? r = u : r += i + u, a.push(r), o = Math.min(o, r - l.top), s = Math.max(s, r + l.bottom), i = l.bottom + h;
|
|
1547
|
+
}
|
|
1548
|
+
const c = -o;
|
|
1549
|
+
return {
|
|
1550
|
+
baselines: a.map((l) => l + c),
|
|
1551
|
+
size: I({
|
|
1552
|
+
height: s - o,
|
|
1553
|
+
width: Math.max(...n.map((l) => l.width), 0)
|
|
1554
|
+
})
|
|
1555
|
+
};
|
|
1556
|
+
}
|
|
1557
|
+
const Ue = 0.7, Ge = 0.3;
|
|
1558
|
+
function Ft(t) {
|
|
1559
|
+
const e = t.superscript, n = t.subscript && !e;
|
|
1560
|
+
return !e && !n ? {
|
|
1561
|
+
baselineShift: 0,
|
|
1562
|
+
fontSize: t.fontSize,
|
|
1563
|
+
isSubscript: !1,
|
|
1564
|
+
isSuperscript: !1
|
|
1565
|
+
} : {
|
|
1566
|
+
baselineShift: t.fontSize * Ge * (e ? -1 : 1),
|
|
1567
|
+
fontSize: t.fontSize * Ue,
|
|
1568
|
+
isSubscript: n,
|
|
1569
|
+
isSuperscript: e
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
function wt(t, e = 0) {
|
|
1573
|
+
return t ?? e;
|
|
1574
|
+
}
|
|
1575
|
+
function Ke(t) {
|
|
1576
|
+
const e = wt(
|
|
1577
|
+
t.fontBoundingBoxAscent,
|
|
1578
|
+
t.actualBoundingBoxAscent
|
|
1579
|
+
), n = wt(
|
|
1580
|
+
t.fontBoundingBoxDescent,
|
|
1581
|
+
t.actualBoundingBoxDescent
|
|
1582
|
+
);
|
|
1583
|
+
return {
|
|
1584
|
+
bottom: n,
|
|
1585
|
+
height: e + n,
|
|
1586
|
+
top: e,
|
|
1587
|
+
width: t.width
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function jt(t, e, n = 1) {
|
|
1591
|
+
const r = Ft(e);
|
|
1592
|
+
t.context.fillStyle = ot(e.color, n), t.context.font = `${e.fontStyle} ${e.fontWeight} ${r.fontSize}px ${e.fontFamily}`, t.type === A.Browser ? t.context.textRendering = e.ligatures ? "optimizeLegibility" : "optimizeSpeed" : t.context.fontVariant = e.ligatures ? "common-ligatures" : "no-common-ligatures";
|
|
1593
|
+
}
|
|
1594
|
+
function Ye(t, e, n) {
|
|
1595
|
+
const r = [];
|
|
1596
|
+
for (const i of t) {
|
|
1597
|
+
const o = [], s = i.length === 0 ? [{ text: "" }] : i;
|
|
1598
|
+
for (const a of s) {
|
|
1599
|
+
const { text: c, ...l } = a, d = { ...e, ...l };
|
|
1600
|
+
jt(n, d);
|
|
1601
|
+
const h = n.context.measureText(c), u = Ke(h), { baselineShift: p } = Ft(d), g = Math.max(0, u.top - p), m = Math.max(0, u.bottom + p);
|
|
1602
|
+
o.push({
|
|
1603
|
+
...u,
|
|
1604
|
+
baselineShift: p,
|
|
1605
|
+
bottom: m,
|
|
1606
|
+
height: g + m,
|
|
1607
|
+
lineAdvance: d.fontSize,
|
|
1608
|
+
top: g
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
r.push(o);
|
|
1612
|
+
}
|
|
1613
|
+
return r;
|
|
1614
|
+
}
|
|
1615
|
+
const Xe = ({ ctx: t, object: e, opacity: n }) => {
|
|
1616
|
+
const r = e.opacity * n;
|
|
1617
|
+
if (r === 0)
|
|
1618
|
+
return;
|
|
1619
|
+
const { length: i } = e, o = Lt(e.text), s = _e(e), a = Ye(o, s, t), c = We(a, e.lineSpacing), l = k(x({ x: e.x, y: e.y }), e.anchor, c.size);
|
|
1620
|
+
let d = l.origin.x, h = 0;
|
|
1621
|
+
for (let u = 0; u < o.length; u++) {
|
|
1622
|
+
const p = o[u], g = a[u], m = c.baselines[u];
|
|
1623
|
+
if (p == null || g == null || m == null) {
|
|
1624
|
+
console.error("Could not determine text units or sizes for line");
|
|
1625
|
+
continue;
|
|
1626
|
+
}
|
|
1627
|
+
const w = g.reduce((v, b) => v + b.width, 0);
|
|
1628
|
+
switch (e.alignment) {
|
|
1629
|
+
case Q.LEFT:
|
|
1630
|
+
d = l.origin.x;
|
|
1631
|
+
break;
|
|
1632
|
+
case Q.CENTER:
|
|
1633
|
+
d = l.origin.x + (l.size.width - w) / 2;
|
|
1634
|
+
break;
|
|
1635
|
+
case Q.RIGHT:
|
|
1636
|
+
d = l.origin.x + (l.size.width - w);
|
|
1637
|
+
break;
|
|
1638
|
+
default:
|
|
1639
|
+
L(e.alignment);
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
const O = l.origin.y + m;
|
|
1643
|
+
for (let v = 0; v < p.length && !(i !== null && h >= i); v++) {
|
|
1644
|
+
const b = p[v], S = g[v];
|
|
1645
|
+
if (b == null || S == null) {
|
|
1646
|
+
console.error("Could not determine text unit or size for unit");
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
const { text: C, ...y } = b;
|
|
1650
|
+
let N;
|
|
1651
|
+
if (i !== null && h + C.length > i) {
|
|
1652
|
+
const _ = i - h;
|
|
1653
|
+
N = C.slice(0, _);
|
|
1654
|
+
}
|
|
1655
|
+
const E = N ?? C;
|
|
1656
|
+
h += E.length;
|
|
1657
|
+
const B = { ...s, ...y };
|
|
1658
|
+
jt(t, B, r), t.context.fillText(E, d, O + S.baselineShift), d += S.width;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}, Je = {
|
|
1662
|
+
[T.ARROW]: Se,
|
|
1663
|
+
[T.CIRCLE]: Ie,
|
|
1664
|
+
[T.GROUP]: Ae,
|
|
1665
|
+
[T.IMAGE]: Pe,
|
|
1666
|
+
[T.LINE]: Ne,
|
|
1667
|
+
[T.MASK]: Be,
|
|
1668
|
+
[T.PATH]: Re,
|
|
1669
|
+
[T.POLYGON]: ke,
|
|
1670
|
+
[T.RECTANGLE]: je,
|
|
1671
|
+
[T.SLIDE_OBJECT]: () => {
|
|
1672
|
+
},
|
|
1673
|
+
[T.SPOTLIGHT]: Ve,
|
|
1674
|
+
[T.SVG]: He,
|
|
1675
|
+
[T.TEXT]: Xe
|
|
1676
|
+
};
|
|
1677
|
+
function qe(t) {
|
|
1678
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1679
|
+
return e.setAttribute("viewBox", `0 0 ${t.width} ${t.height}`), e.style.backgroundColor = "transparent", e.style.position = "absolute", e.style.width = "100%", e;
|
|
1680
|
+
}
|
|
1681
|
+
function Qe(t, e) {
|
|
1682
|
+
if (t === null)
|
|
1683
|
+
return null;
|
|
1684
|
+
const n = k(
|
|
1685
|
+
x({ x: e.x, y: e.y }),
|
|
1686
|
+
e.anchor,
|
|
1687
|
+
I({ width: e.width, height: e.height })
|
|
1688
|
+
), r = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
|
|
1689
|
+
r.setAttribute("x", n.origin.x.toString()), r.setAttribute("y", n.origin.y.toString()), r.setAttribute("width", e.width.toString()), r.setAttribute("height", e.height.toString());
|
|
1690
|
+
const i = e.content;
|
|
1691
|
+
i !== null && r.appendChild(i), t.appendChild(r);
|
|
1692
|
+
let o = null;
|
|
1693
|
+
if (e.setup !== null) {
|
|
1694
|
+
const s = e.setup(r);
|
|
1695
|
+
s !== void 0 && (o = s);
|
|
1696
|
+
}
|
|
1697
|
+
return () => {
|
|
1698
|
+
o !== null && o(), t.removeChild(r);
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
async function Dt(t) {
|
|
1702
|
+
if (Object.keys(t).length === 0)
|
|
1703
|
+
return {};
|
|
1704
|
+
const e = {}, n = (i) => new Promise((o, s) => {
|
|
1705
|
+
const a = new Image();
|
|
1706
|
+
if (a.onload = () => o(a), a.onerror = (l) => s(l), i.includes("</svg>")) {
|
|
1707
|
+
const l = i.replace(/<\?xml[^?]*\?>\s*/g, ""), d = new Blob([l], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(d);
|
|
1708
|
+
a.src = h;
|
|
1709
|
+
} else
|
|
1710
|
+
a.src = i;
|
|
1711
|
+
}), r = Object.entries(t).map(async ([i, o]) => {
|
|
1712
|
+
const s = await n(o);
|
|
1713
|
+
e[i] = {
|
|
1714
|
+
type: W.Browser,
|
|
1715
|
+
image: s
|
|
1716
|
+
};
|
|
1717
|
+
});
|
|
1718
|
+
try {
|
|
1719
|
+
await Promise.all(r);
|
|
1720
|
+
} catch (i) {
|
|
1721
|
+
console.error("Error loading images:", i);
|
|
1722
|
+
}
|
|
1723
|
+
return e;
|
|
1724
|
+
}
|
|
1725
|
+
const vt = "presenterPendingVariables:";
|
|
1726
|
+
function Ze(t) {
|
|
1727
|
+
const e = en();
|
|
1728
|
+
e !== null && e.setItem(tn(), JSON.stringify({ values: t }));
|
|
1729
|
+
}
|
|
1730
|
+
function tn() {
|
|
1731
|
+
return typeof window > "u" ? vt : `${vt}${window.location.origin}${window.location.pathname}`;
|
|
1732
|
+
}
|
|
1733
|
+
function en() {
|
|
1734
|
+
try {
|
|
1735
|
+
return typeof sessionStorage > "u" ? null : sessionStorage;
|
|
1736
|
+
} catch {
|
|
1737
|
+
return null;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
const nn = 0, at = /* @__PURE__ */ new Map();
|
|
1741
|
+
let zt = /* @__PURE__ */ new Map();
|
|
1742
|
+
function Vt() {
|
|
1743
|
+
return Array.from(at.values());
|
|
1744
|
+
}
|
|
1745
|
+
function Ht(t) {
|
|
1746
|
+
const e = at.get(t);
|
|
1747
|
+
return e === void 0 ? nn : zt.get(e.id) ?? e.default;
|
|
1748
|
+
}
|
|
1749
|
+
function on(t, e) {
|
|
1750
|
+
const n = at.get(t);
|
|
1751
|
+
if (n === void 0)
|
|
1752
|
+
return e;
|
|
1753
|
+
const r = rn(e, n);
|
|
1754
|
+
return zt.set(n.id, r), r;
|
|
1755
|
+
}
|
|
1756
|
+
function rn(t, e) {
|
|
1757
|
+
return sn(t, e.min, e.max);
|
|
1758
|
+
}
|
|
1759
|
+
function sn(t, e, n) {
|
|
1760
|
+
return Math.max(e, Math.min(n, t));
|
|
1761
|
+
}
|
|
1762
|
+
function an({
|
|
1763
|
+
onCommit: t,
|
|
1764
|
+
onPreview: e
|
|
1765
|
+
}) {
|
|
1766
|
+
const n = Vt();
|
|
1767
|
+
if (n.length === 0)
|
|
1768
|
+
return null;
|
|
1769
|
+
const r = document.createElement("div");
|
|
1770
|
+
Object.assign(r.style, {
|
|
1771
|
+
position: "absolute",
|
|
1772
|
+
right: "16px",
|
|
1773
|
+
bottom: "16px",
|
|
1774
|
+
zIndex: "20",
|
|
1775
|
+
display: "flex",
|
|
1776
|
+
flexDirection: "column",
|
|
1777
|
+
gap: "8px",
|
|
1778
|
+
width: "min(360px, calc(100% - 32px))",
|
|
1779
|
+
padding: "10px",
|
|
1780
|
+
boxSizing: "border-box",
|
|
1781
|
+
border: "1px solid rgba(255, 255, 255, 0.18)",
|
|
1782
|
+
borderRadius: "8px",
|
|
1783
|
+
background: "rgba(16, 18, 22, 0.82)",
|
|
1784
|
+
color: "#ffffff",
|
|
1785
|
+
fontFamily: 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
1786
|
+
fontSize: "12px",
|
|
1787
|
+
lineHeight: "1.25",
|
|
1788
|
+
pointerEvents: "auto",
|
|
1789
|
+
boxShadow: "0 12px 36px rgba(0, 0, 0, 0.28)",
|
|
1790
|
+
backdropFilter: "blur(10px)"
|
|
1791
|
+
});
|
|
1792
|
+
for (const i of n)
|
|
1793
|
+
r.appendChild(ln(i, e, t));
|
|
1794
|
+
return r;
|
|
1795
|
+
}
|
|
1796
|
+
function ln(t, e, n) {
|
|
1797
|
+
const r = document.createElement("div");
|
|
1798
|
+
r.dataset.presenterVariableId = t.id, r.dataset.presenterVariableName = t.name, Object.assign(r.style, {
|
|
1799
|
+
display: "grid",
|
|
1800
|
+
gridTemplateColumns: "72px minmax(0, 1fr) 74px",
|
|
1801
|
+
alignItems: "center",
|
|
1802
|
+
gap: "8px"
|
|
1803
|
+
});
|
|
1804
|
+
const i = document.createElement("div");
|
|
1805
|
+
i.textContent = t.name, i.title = t.name, Object.assign(i.style, {
|
|
1806
|
+
overflow: "hidden",
|
|
1807
|
+
textOverflow: "ellipsis",
|
|
1808
|
+
whiteSpace: "nowrap",
|
|
1809
|
+
color: "rgba(255, 255, 255, 0.86)",
|
|
1810
|
+
fontWeight: "600"
|
|
1811
|
+
});
|
|
1812
|
+
const o = document.createElement("input");
|
|
1813
|
+
o.type = "range", o.min = t.min.toString(), o.max = t.max.toString(), o.step = t.increment.toString(), Object.assign(o.style, {
|
|
1814
|
+
width: "100%",
|
|
1815
|
+
minWidth: "0",
|
|
1816
|
+
accentColor: "#8bc7ff"
|
|
1817
|
+
});
|
|
1818
|
+
const s = document.createElement("input");
|
|
1819
|
+
s.type = "number", s.min = t.min.toString(), s.max = t.max.toString(), s.step = t.increment.toString(), Object.assign(s.style, {
|
|
1820
|
+
width: "100%",
|
|
1821
|
+
boxSizing: "border-box",
|
|
1822
|
+
border: "1px solid rgba(255, 255, 255, 0.24)",
|
|
1823
|
+
borderRadius: "6px",
|
|
1824
|
+
padding: "4px 6px",
|
|
1825
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
1826
|
+
color: "#ffffff",
|
|
1827
|
+
font: "inherit"
|
|
1828
|
+
});
|
|
1829
|
+
let a = Ht(t.id);
|
|
1830
|
+
const c = (h) => {
|
|
1831
|
+
const u = cn(h);
|
|
1832
|
+
o.value = u, s.value = u;
|
|
1833
|
+
}, l = (h) => {
|
|
1834
|
+
Number.isFinite(h) && (a = e(t.id, h), c(a));
|
|
1835
|
+
}, d = (h) => {
|
|
1836
|
+
Number.isFinite(h) && (h !== a && l(h), n());
|
|
1837
|
+
};
|
|
1838
|
+
return o.addEventListener("input", () => l(o.valueAsNumber)), o.addEventListener("change", () => d(o.valueAsNumber)), s.addEventListener("change", () => d(s.valueAsNumber)), c(a), r.appendChild(i), r.appendChild(o), r.appendChild(s), r;
|
|
1839
|
+
}
|
|
1840
|
+
function cn(t) {
|
|
1841
|
+
return Number.isInteger(t) ? t.toString() : parseFloat(t.toFixed(6)).toString();
|
|
1842
|
+
}
|
|
1843
|
+
function dn({ container: t, onCommit: e }) {
|
|
1844
|
+
const n = an({
|
|
1845
|
+
onPreview: (r, i) => {
|
|
1846
|
+
const o = on(r, i);
|
|
1847
|
+
return Ze(hn()), o;
|
|
1848
|
+
},
|
|
1849
|
+
onCommit: e
|
|
1850
|
+
});
|
|
1851
|
+
n !== null && t.appendChild(n);
|
|
1852
|
+
}
|
|
1853
|
+
function hn() {
|
|
1854
|
+
const t = {};
|
|
1855
|
+
for (const e of Vt())
|
|
1856
|
+
t[e.id] = Ht(e.id);
|
|
1857
|
+
return t;
|
|
1858
|
+
}
|
|
1859
|
+
class un {
|
|
1860
|
+
constructor(e) {
|
|
1861
|
+
this.navigator = null;
|
|
1862
|
+
const { objectRenderers: n, scale: r = 1, ...i } = e;
|
|
1863
|
+
this.props = {
|
|
1864
|
+
presentation: At(),
|
|
1865
|
+
element: document.body,
|
|
1866
|
+
objectRenderers: {
|
|
1867
|
+
...Je,
|
|
1868
|
+
...n
|
|
1869
|
+
},
|
|
1870
|
+
cacheDurationMinutes: 15,
|
|
1871
|
+
scale: fn(r),
|
|
1872
|
+
...i
|
|
1873
|
+
}, this.state = { ...bt };
|
|
1874
|
+
}
|
|
1875
|
+
/** Starts the presentation. */
|
|
1876
|
+
async present() {
|
|
1877
|
+
const { presentation: e, element: n, scale: r } = this.props;
|
|
1878
|
+
this.hideCursor();
|
|
1879
|
+
const i = ue(e.title), o = kt(e.size), s = qe(e.size);
|
|
1880
|
+
s.style.transformOrigin = "center center", s.style.transform = `scale(${r})`, this.state = {
|
|
1881
|
+
...bt,
|
|
1882
|
+
accessibleDescriptionElement: i,
|
|
1883
|
+
imageById: await Dt({
|
|
1884
|
+
...Bt(e),
|
|
1885
|
+
...e.resources.images,
|
|
1886
|
+
...Rt(e)
|
|
1887
|
+
}),
|
|
1888
|
+
canvas: o,
|
|
1889
|
+
extrasContainer: s
|
|
1890
|
+
};
|
|
1891
|
+
const a = re(e, n), c = Nt(n), l = (u, p) => {
|
|
1892
|
+
this.state.shortcutState.shortcuts.b = {
|
|
1893
|
+
slideIndex: this.state.slideIndex,
|
|
1894
|
+
buildIndex: this.state.buildIndex
|
|
1895
|
+
}, this.renderSlide(u ?? this.state.slideIndex, p);
|
|
1896
|
+
}, d = (u = !1) => {
|
|
1897
|
+
c && (this.navigator = qt({
|
|
1898
|
+
presentation: e,
|
|
1899
|
+
shortcutState: this.state.shortcutState,
|
|
1900
|
+
onNavigateToSlide: (p) => this.renderSlide(p),
|
|
1901
|
+
onRenderSlide: l,
|
|
1902
|
+
onNext: (p) => this.next(p),
|
|
1903
|
+
onPrevious: (p) => this.previous(p),
|
|
1904
|
+
forceRefresh: u
|
|
1905
|
+
}), this.updateNavigator());
|
|
1906
|
+
};
|
|
1907
|
+
It(
|
|
1908
|
+
e,
|
|
1909
|
+
a,
|
|
1910
|
+
this.state.shortcutState,
|
|
1911
|
+
{
|
|
1912
|
+
onNext: (u) => this.next(u),
|
|
1913
|
+
onPrevious: (u) => this.previous(u),
|
|
1914
|
+
onRenderSlide: l,
|
|
1915
|
+
onShowNavigator: () => d()
|
|
1916
|
+
},
|
|
1917
|
+
{
|
|
1918
|
+
focusOnPointerDown: !c,
|
|
1919
|
+
keyEventTarget: c ? window : a
|
|
1920
|
+
}
|
|
1921
|
+
), n.replaceChildren(), a.appendChild(i), a.appendChild(o), a.appendChild(s), dn({
|
|
1922
|
+
container: a,
|
|
1923
|
+
onCommit: () => this.reloadAfterVariableChange()
|
|
1924
|
+
}), n.appendChild(a);
|
|
1925
|
+
const h = he(e, this.props.cacheDurationMinutes);
|
|
1926
|
+
h !== null ? this.renderSlide(h.slideIndex, h.buildIndex) : this.renderSlide(0), $t() && d(!0);
|
|
1927
|
+
}
|
|
1928
|
+
reloadAfterVariableChange() {
|
|
1929
|
+
const { presentation: e } = this.props;
|
|
1930
|
+
this.state.currentAnimationId !== null && (cancelAnimationFrame(this.state.currentAnimationId), this.state.currentAnimationId = null), xt({
|
|
1931
|
+
title: e.title,
|
|
1932
|
+
slideIndex: this.state.slideIndex,
|
|
1933
|
+
buildIndex: this.state.buildIndex
|
|
1934
|
+
}), window.location.reload();
|
|
1935
|
+
}
|
|
1936
|
+
renderSlide(e, n = 0, r = null) {
|
|
1937
|
+
const { presentation: i } = this.props, { canvas: o } = this.state, s = this.state.slideIndex !== e;
|
|
1938
|
+
this.state.slideIndex = e, this.state.buildIndex = n, r === null && xt({ title: i.title, slideIndex: e, buildIndex: n });
|
|
1939
|
+
const a = i.slides[e];
|
|
1940
|
+
if (!(a === void 0 || o === null)) {
|
|
1941
|
+
if (s || this.state.mountedExtrasCleanups.length === 0 && a.extras.length > 0) {
|
|
1942
|
+
for (const c of this.state.mountedExtrasCleanups)
|
|
1943
|
+
c();
|
|
1944
|
+
this.state.mountedExtrasCleanups = [];
|
|
1945
|
+
for (const c of a.extras) {
|
|
1946
|
+
const l = Qe(this.state.extrasContainer, c);
|
|
1947
|
+
l !== null && this.state.mountedExtrasCleanups.push(l);
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
if (this.renderCanvas(o, e, n, r, this.props.scale), r === null) {
|
|
1951
|
+
if (this.state.accessibleDescriptionElement !== null) {
|
|
1952
|
+
const c = mt({ slide: a, buildIndex: n, buildTime: r });
|
|
1953
|
+
xe(
|
|
1954
|
+
this.state.accessibleDescriptionElement,
|
|
1955
|
+
fe(a, c)
|
|
1956
|
+
);
|
|
1957
|
+
}
|
|
1958
|
+
this.updateNavigator();
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
renderCanvas(e, n, r = 0, i = null, o = 1) {
|
|
1963
|
+
const { objectRenderers: s, presentation: a } = this.props, { imageById: c } = this.state;
|
|
1964
|
+
e.width = a.size.width, e.height = a.size.height;
|
|
1965
|
+
const l = e.getContext("2d");
|
|
1966
|
+
if (l === null)
|
|
1967
|
+
return;
|
|
1968
|
+
const d = {
|
|
1969
|
+
type: A.Browser,
|
|
1970
|
+
context: l
|
|
1971
|
+
};
|
|
1972
|
+
be(e, d);
|
|
1973
|
+
const h = a.slides[n];
|
|
1974
|
+
if (h === void 0)
|
|
1975
|
+
return;
|
|
1976
|
+
const u = mt({
|
|
1977
|
+
slide: h,
|
|
1978
|
+
buildIndex: r,
|
|
1979
|
+
buildTime: i
|
|
1980
|
+
});
|
|
1981
|
+
d.context.fillStyle = ot(a.backgroundColor), d.context.fillRect(0, 0, e.width, e.height);
|
|
1982
|
+
function p(m, w, O = d) {
|
|
1983
|
+
const v = s[m.objectType], b = u.get(m);
|
|
1984
|
+
v === void 0 || b === void 0 || v({
|
|
1985
|
+
ctx: O,
|
|
1986
|
+
originalObject: m,
|
|
1987
|
+
imageById: c,
|
|
1988
|
+
object: b,
|
|
1989
|
+
opacity: w,
|
|
1990
|
+
renderScale: o,
|
|
1991
|
+
renderObject: (S, C, y = O) => p(S, C, y),
|
|
1992
|
+
getCurrentObject: (S) => u.get(S),
|
|
1993
|
+
createPath2D: we,
|
|
1994
|
+
slideSize: a.size
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
const g = o !== 1;
|
|
1998
|
+
g && (d.context.save(), d.context.translate(
|
|
1999
|
+
e.width * (1 - o) / 2,
|
|
2000
|
+
e.height * (1 - o) / 2
|
|
2001
|
+
), d.context.scale(o, o));
|
|
2002
|
+
for (const m of h.objects)
|
|
2003
|
+
p(m, 1);
|
|
2004
|
+
g && d.context.restore();
|
|
2005
|
+
}
|
|
2006
|
+
updateNavigator() {
|
|
2007
|
+
const { navigator: e } = this;
|
|
2008
|
+
if (e === null)
|
|
2009
|
+
return;
|
|
2010
|
+
if (!e.isOpen()) {
|
|
2011
|
+
this.navigator = null;
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
const { slideIndex: n, buildIndex: r } = this.state, i = this.getNextSlideBuild(n, r);
|
|
2015
|
+
e.update(n, r, i.slideIndex, i.buildIndex), this.renderCanvas(e.currentCanvas, n, r), i.slideIndex === null ? this.renderEndCanvas(e.nextCanvas) : this.renderCanvas(e.nextCanvas, i.slideIndex, i.buildIndex);
|
|
2016
|
+
}
|
|
2017
|
+
getNextSlideBuild(e, n) {
|
|
2018
|
+
const { presentation: r } = this.props, i = r.slides[e];
|
|
2019
|
+
return i === void 0 ? { slideIndex: e, buildIndex: n } : n < i.animations.length ? { slideIndex: e, buildIndex: n + 1 } : e + 1 < r.slides.length ? { slideIndex: e + 1, buildIndex: 0 } : { slideIndex: null, buildIndex: 0 };
|
|
2020
|
+
}
|
|
2021
|
+
renderEndCanvas(e) {
|
|
2022
|
+
const { presentation: n } = this.props;
|
|
2023
|
+
e.width = n.size.width, e.height = n.size.height;
|
|
2024
|
+
const r = e.getContext("2d");
|
|
2025
|
+
r !== null && (r.fillStyle = "#000000", r.fillRect(0, 0, e.width, e.height));
|
|
2026
|
+
}
|
|
2027
|
+
next(e = !1) {
|
|
2028
|
+
const { presentation: n } = this.props, { currentAnimationId: r, slideIndex: i, buildIndex: o } = this.state;
|
|
2029
|
+
this.hideCursor(), r !== null && cancelAnimationFrame(r);
|
|
2030
|
+
const s = n.slides[i];
|
|
2031
|
+
if (s === void 0)
|
|
2032
|
+
return;
|
|
2033
|
+
const a = s.animations[o];
|
|
2034
|
+
if (a !== void 0 && !e) {
|
|
2035
|
+
const c = performance.now(), l = Pt(a), d = (h) => {
|
|
2036
|
+
const u = h - c;
|
|
2037
|
+
u < l ? (this.renderSlide(i, o + 1, u), this.state.currentAnimationId = requestAnimationFrame(d)) : this.renderSlide(i, o + 1, null);
|
|
2038
|
+
};
|
|
2039
|
+
this.state.currentAnimationId = requestAnimationFrame(d);
|
|
2040
|
+
} else i + 1 < n.slides.length && this.renderSlide(i + 1);
|
|
2041
|
+
}
|
|
2042
|
+
previous(e = !1) {
|
|
2043
|
+
const { currentAnimationId: n, slideIndex: r, buildIndex: i } = this.state;
|
|
2044
|
+
if (this.hideCursor(), n !== null && cancelAnimationFrame(n), i > 0)
|
|
2045
|
+
e ? this.renderSlide(r, 0) : this.renderSlide(r, i - 1);
|
|
2046
|
+
else if (r > 0) {
|
|
2047
|
+
const o = this.props.presentation.slides[r - 1], s = e ? 0 : (o == null ? void 0 : o.animations.length) ?? 0;
|
|
2048
|
+
this.renderSlide(r - 1, s);
|
|
2049
|
+
} else
|
|
2050
|
+
this.renderSlide(0, 0);
|
|
2051
|
+
}
|
|
2052
|
+
hasNext() {
|
|
2053
|
+
const { presentation: e } = this.props, { slideIndex: n, buildIndex: r } = this.state, i = e.slides[n];
|
|
2054
|
+
return i === void 0 ? !1 : i.animations[r] !== void 0 ? !0 : n + 1 < e.slides.length;
|
|
2055
|
+
}
|
|
2056
|
+
hasPrevious() {
|
|
2057
|
+
const { slideIndex: e, buildIndex: n } = this.state;
|
|
2058
|
+
return n > 0 || e > 0;
|
|
2059
|
+
}
|
|
2060
|
+
hideCursor() {
|
|
2061
|
+
var e, n;
|
|
2062
|
+
this.props.element.style.cursor = "none", (n = (e = this.state.canvas) == null ? void 0 : e.parentElement) == null || n.style.setProperty("cursor", "none");
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
function fn(t) {
|
|
2066
|
+
return t <= 0 || t > 1 ? (console.warn(
|
|
2067
|
+
`BrowserCanvasRenderer scale must be positive and no greater than 1. Received ${t}; using 1 instead.`
|
|
2068
|
+
), 1) : t;
|
|
2069
|
+
}
|
|
2070
|
+
function pn(t) {
|
|
2071
|
+
const e = [];
|
|
2072
|
+
if (t.isAllKey) {
|
|
2073
|
+
for (let n = 0; n <= t.animations.length; n++)
|
|
2074
|
+
e.push(n);
|
|
2075
|
+
return e;
|
|
2076
|
+
}
|
|
2077
|
+
return t.isStartKey && e.push(0), t.animations.forEach((n, r) => {
|
|
2078
|
+
Array.isArray(n) ? n.some((i) => i.isKey) && e.push(r + 1) : n.isKey && e.push(r + 1);
|
|
2079
|
+
}), t.isEndKey && e[e.length - 1] !== t.animations.length && e.push(t.animations.length), e;
|
|
2080
|
+
}
|
|
2081
|
+
function* gn({
|
|
2082
|
+
presentation: t,
|
|
2083
|
+
isAnimatedExport: e,
|
|
2084
|
+
animationHoldFrames: n,
|
|
2085
|
+
framesPerSecond: r
|
|
2086
|
+
}) {
|
|
2087
|
+
let i = 0;
|
|
2088
|
+
for (let o = 0; o < t.slides.length; o++) {
|
|
2089
|
+
const s = t.slides[o];
|
|
2090
|
+
if (s !== void 0)
|
|
2091
|
+
if (e) {
|
|
2092
|
+
for (let a = 0; a < n; a++)
|
|
2093
|
+
yield { imageIndex: i++, slideIndex: o, buildIndex: 0, buildTime: null };
|
|
2094
|
+
for (let a = 0; a < s.animations.length; a++) {
|
|
2095
|
+
const c = s.animations[a];
|
|
2096
|
+
if (c === void 0)
|
|
2097
|
+
continue;
|
|
2098
|
+
const l = Pt(c), d = Math.ceil(l / 1e3 * r);
|
|
2099
|
+
for (let h = 0; h < d; h++)
|
|
2100
|
+
yield {
|
|
2101
|
+
imageIndex: i++,
|
|
2102
|
+
slideIndex: o,
|
|
2103
|
+
buildIndex: a + 1,
|
|
2104
|
+
buildTime: h * (l / d)
|
|
2105
|
+
};
|
|
2106
|
+
for (let h = 0; h < n; h++)
|
|
2107
|
+
yield {
|
|
2108
|
+
imageIndex: i++,
|
|
2109
|
+
slideIndex: o,
|
|
2110
|
+
buildIndex: a + 1,
|
|
2111
|
+
buildTime: null
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
} else {
|
|
2115
|
+
const a = pn(s);
|
|
2116
|
+
for (const c of a)
|
|
2117
|
+
yield { imageIndex: i++, slideIndex: o, buildIndex: c, buildTime: null };
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
class Sn {
|
|
2122
|
+
constructor(e) {
|
|
2123
|
+
const { imageFormat: n = "png", ...r } = e;
|
|
2124
|
+
this.props = {
|
|
2125
|
+
presentation: At(),
|
|
2126
|
+
imageFormat: n,
|
|
2127
|
+
imageQuality: void 0,
|
|
2128
|
+
animationHoldFrames: 1,
|
|
2129
|
+
framesPerSecond: 30,
|
|
2130
|
+
isAnimatedExport: !1,
|
|
2131
|
+
getFilenameForImage: (i) => `${i.toString().padStart(4, "0")}.${n}`,
|
|
2132
|
+
logFrequency: 0,
|
|
2133
|
+
objectRenderers: {},
|
|
2134
|
+
onRenderImage: () => {
|
|
2135
|
+
},
|
|
2136
|
+
renderScale: 1,
|
|
2137
|
+
resourcePathPrefix: "",
|
|
2138
|
+
waitForFonts: !0,
|
|
2139
|
+
...r
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
async render(e = 0) {
|
|
2143
|
+
vn();
|
|
2144
|
+
const { presentation: n } = this.props, r = await Dt(
|
|
2145
|
+
xn(
|
|
2146
|
+
{
|
|
2147
|
+
...Bt(n),
|
|
2148
|
+
...n.resources.images,
|
|
2149
|
+
...Rt(n)
|
|
2150
|
+
},
|
|
2151
|
+
this.props.resourcePathPrefix
|
|
2152
|
+
)
|
|
2153
|
+
);
|
|
2154
|
+
this.props.waitForFonts && await document.fonts.ready;
|
|
2155
|
+
const i = kt(n.size), o = new un({
|
|
2156
|
+
presentation: n,
|
|
2157
|
+
objectRenderers: this.props.objectRenderers,
|
|
2158
|
+
scale: this.props.renderScale,
|
|
2159
|
+
element: document.createElement("div")
|
|
2160
|
+
});
|
|
2161
|
+
o.state = {
|
|
2162
|
+
...o.state,
|
|
2163
|
+
imageById: r
|
|
2164
|
+
};
|
|
2165
|
+
for (const s of gn(this.props))
|
|
2166
|
+
s.imageIndex < e || await this.renderFrame(o, i, s);
|
|
2167
|
+
}
|
|
2168
|
+
async renderFrame(e, n, r) {
|
|
2169
|
+
const { getFilenameForImage: i, imageFormat: o, imageQuality: s, logFrequency: a, onRenderImage: c } = this.props;
|
|
2170
|
+
e.renderCanvas(
|
|
2171
|
+
n,
|
|
2172
|
+
r.slideIndex,
|
|
2173
|
+
r.buildIndex,
|
|
2174
|
+
r.buildTime,
|
|
2175
|
+
this.props.renderScale
|
|
2176
|
+
);
|
|
2177
|
+
const l = await yn(n, mn(o), s), d = i(r.imageIndex), h = {
|
|
2178
|
+
...r,
|
|
2179
|
+
blob: l,
|
|
2180
|
+
filename: d
|
|
2181
|
+
};
|
|
2182
|
+
await c(h), a > 0 && r.imageIndex % a === 0 && console.log(`Rendered image ${r.imageIndex}: ${d}`);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
function yn(t, e, n) {
|
|
2186
|
+
return new Promise((r, i) => {
|
|
2187
|
+
t.toBlob(
|
|
2188
|
+
(o) => {
|
|
2189
|
+
if (o === null) {
|
|
2190
|
+
i(new Error("Unable to encode browser image export frame."));
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
r(o);
|
|
2194
|
+
},
|
|
2195
|
+
e,
|
|
2196
|
+
n
|
|
2197
|
+
);
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
function mn(t) {
|
|
2201
|
+
switch (t) {
|
|
2202
|
+
case "jpeg":
|
|
2203
|
+
return "image/jpeg";
|
|
2204
|
+
case "webp":
|
|
2205
|
+
return "image/webp";
|
|
2206
|
+
case "png":
|
|
2207
|
+
return "image/png";
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function xn(t, e) {
|
|
2211
|
+
if (e === "")
|
|
2212
|
+
return t;
|
|
2213
|
+
const n = {};
|
|
2214
|
+
for (const [r, i] of Object.entries(t))
|
|
2215
|
+
n[r] = bn(i) ? wn(e, i) : i;
|
|
2216
|
+
return n;
|
|
2217
|
+
}
|
|
2218
|
+
function bn(t) {
|
|
2219
|
+
return !t.includes("</svg>") && !t.startsWith("/") && !t.startsWith("data:") && !t.startsWith("blob:") && !/^[a-z][a-z0-9+.-]*:\/\//i.test(t);
|
|
2220
|
+
}
|
|
2221
|
+
function wn(t, e) {
|
|
2222
|
+
return `${t.replace(/\/$/, "")}/${e.replace(/^\//, "")}`;
|
|
2223
|
+
}
|
|
2224
|
+
function vn() {
|
|
2225
|
+
if (typeof document > "u")
|
|
2226
|
+
throw new Error("BrowserImageRenderer must run in a browser environment.");
|
|
2227
|
+
}
|
|
2228
|
+
export {
|
|
2229
|
+
Sn as BrowserImageRenderer
|
|
2230
|
+
};
|
|
2231
|
+
//# sourceMappingURL=export-browser.mjs.map
|