@algorisys/yappydraw 0.8.293 → 0.8.295

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +2 -2
  2. package/chunks/{canva-ai-B5NJGMGr.js → canva-ai-kg789_jz.js} +1 -1
  3. package/chunks/{choice-dialog-state-Cw0WShhc.js → choice-dialog-state-ByeMPVwB.js} +1 -1
  4. package/chunks/{custgeom-BeeylhzV.js → custgeom-CEAI2znd.js} +13 -10
  5. package/chunks/{design-generator-BSZ2XUOE.js → design-generator-zF-F-iCB.js} +1 -1
  6. package/chunks/{drawing-engine-DfASJ_gK.js → drawing-engine-U5zBcwtj.js} +1 -1
  7. package/chunks/{drawings-store-cl-M93Eh.js → drawings-store-CZSZCNqP.js} +1 -1
  8. package/chunks/{ds-operations-CXoS_Obn.js → ds-operations-_c-HiYjk.js} +1 -1
  9. package/chunks/{export-game-BTjE-uv-.js → export-game-CgMvNkoa.js} +1 -1
  10. package/chunks/{from-yappy-hUcG5auS.js → from-yappy-Dd2p9P6N.js} +116 -97
  11. package/chunks/{game-runtime-33Ly0Axb.js → game-runtime-CH3yVPDc.js} +37 -37
  12. package/chunks/import-C3P7glRz.js +1726 -0
  13. package/chunks/{index-OCtbNe3Y.js → index-B_V19zDs.js} +20563 -19834
  14. package/chunks/{index.es-m_qpxIjM.js → index.es-yTIj1Pnc.js} +1 -1
  15. package/chunks/{jspdf.es.min-DGjtdWau.js → jspdf.es.min-DFBFqtMo.js} +2 -2
  16. package/chunks/{lucide-solid-Btzt68l9.js → lucide-solid-DfQVDBtM.js} +1 -1
  17. package/chunks/markdown-to-slides-B5OASdqg.js +122 -0
  18. package/chunks/{morph-animator-CWLzpuUc.js → morph-animator-b1aFWI5O.js} +1 -1
  19. package/chunks/{onboarding-tour-eLES7UJM.js → onboarding-tour-j-RhQYNM.js} +1 -1
  20. package/chunks/{pdf-vector-C1l03NEO.js → pdf-vector-CzrRoyPR.js} +2 -2
  21. package/chunks/purify.es-B0KlbA1O.js +1520 -0
  22. package/chunks/{search-tbh5OqVp.js → search-B7AUhYCm.js} +2 -2
  23. package/chunks/{slide-generator-CZfB2tSO.js → slide-generator-AO60zi1f.js} +1 -1
  24. package/chunks/{svg2pdf.es.min-B6z21zR3.js → svg2pdf.es.min-4O9RYeoT.js} +1 -1
  25. package/chunks/{turntable-ai-CeD-w_eE.js → turntable-ai-DddsPGTo.js} +1 -1
  26. package/chunks/write-uweO04Cm.js +265 -0
  27. package/package.json +1 -1
  28. package/yappy.js +1 -1
  29. package/chunks/import-Dk___UKU.js +0 -1635
  30. package/chunks/markdown-to-slides-CNpwNPE8.js +0 -96
  31. package/chunks/purify.es-C2Qa7b4C.js +0 -906
  32. package/chunks/write-BUtbdS9L.js +0 -212
@@ -1,1635 +0,0 @@
1
- import { u as ae, a as ie } from "./browser-DbZP-BrN.js";
2
- import { E as H, i as vt, g as le } from "./custgeom-BeeylhzV.js";
3
- import { ap as ce, aq as Rt, M as fe, q as ue, K as de } from "./index-OCtbNe3Y.js";
4
- const he = 1e4, pe = 1e5, Wt = 6e4, K = (t) => t / Wt * (Math.PI / 180);
5
- function _t(t, n, e, o = {}) {
6
- const s = /* @__PURE__ */ new Map(), r = Math.max(0, n), a = Math.max(0, e), i = Math.min(r, a), c = Math.max(r, a), y = {
7
- w: r,
8
- h: a,
9
- l: 0,
10
- t: 0,
11
- r,
12
- b: a,
13
- hc: r / 2,
14
- vc: a / 2,
15
- ss: i,
16
- ls: c,
17
- cd2: 108e5,
18
- cd4: 54e5,
19
- cd8: 27e5,
20
- "3cd4": 162e5,
21
- "3cd8": 81e5,
22
- "5cd8": 135e5,
23
- "7cd8": 189e5
24
- };
25
- for (const [g, h] of Object.entries(y)) s.set(g, h);
26
- for (const g of [2, 3, 4, 5, 6, 8, 10, 12, 16, 32])
27
- s.set(`wd${g}`, r / g), s.set(`hd${g}`, a / g), s.set(`ssd${g}`, i / g);
28
- const x = (g) => {
29
- const h = s.get(g);
30
- if (h !== void 0) return h;
31
- const u = /^(wd|hd|ssd)(\d+)$/.exec(g);
32
- if (u) {
33
- const b = u[1] === "wd" ? r : u[1] === "hd" ? a : i, d = Number(u[2]);
34
- return d ? b / d : 0;
35
- }
36
- const p = Number(g);
37
- return Number.isFinite(p) ? p : 0;
38
- }, f = (g, h) => {
39
- s.size > he || s.set(g, me(h, x));
40
- };
41
- for (const [g, h] of t.av ?? []) f(g, o[g] ?? h);
42
- for (const [g, h] of Object.entries(o)) s.has(g) || f(g, h);
43
- for (const [g, h] of t.gd ?? []) f(g, h);
44
- return s;
45
- }
46
- function me(t, n) {
47
- const e = String(t || "").trim().split(/\s+/), o = e[0], [s, r, a] = e.slice(1).map(n);
48
- let i;
49
- switch (o) {
50
- case "val":
51
- i = s;
52
- break;
53
- case "*/":
54
- i = a ? s * r / a : 0;
55
- break;
56
- case "+-":
57
- i = s + r - a;
58
- break;
59
- case "+/":
60
- i = a ? (s + r) / a : 0;
61
- break;
62
- case "?:":
63
- i = s > 0 ? r : a;
64
- break;
65
- case "abs":
66
- i = Math.abs(s);
67
- break;
68
- case "at2":
69
- i = Math.atan2(r, s) * 180 / Math.PI * Wt;
70
- break;
71
- case "cat2":
72
- i = s * Math.cos(Math.atan2(a, r));
73
- break;
74
- case "sat2":
75
- i = s * Math.sin(Math.atan2(a, r));
76
- break;
77
- case "cos":
78
- i = s * Math.cos(K(r));
79
- break;
80
- case "sin":
81
- i = s * Math.sin(K(r));
82
- break;
83
- case "tan":
84
- i = s * Math.tan(K(r));
85
- break;
86
- case "max":
87
- i = Math.max(s, r);
88
- break;
89
- case "min":
90
- i = Math.min(s, r);
91
- break;
92
- case "mod":
93
- i = Math.sqrt(s * s + r * r + a * a);
94
- break;
95
- case "pin":
96
- i = r < s ? s : r > a ? a : r;
97
- break;
98
- case "sqrt":
99
- i = Math.sqrt(Math.max(0, s));
100
- break;
101
- default:
102
- i = 0;
103
- }
104
- return Number.isFinite(i) ? i : 0;
105
- }
106
- const Nt = (t, n, e) => Math.atan2(n * Math.sin(t), e * Math.cos(t));
107
- function it(t, n, e, o = {}) {
108
- const s = Math.max(Math.abs(n), 0) * H, r = Math.max(Math.abs(e), 0) * H, a = _t(t, s, r, o), i = (x) => typeof x == "number" ? x : a.get(x) ?? (Number.isFinite(Number(x)) ? Number(x) : 0), c = [];
109
- let y = pe;
110
- for (const x of t.paths) {
111
- const f = x.w ? s / x.w : 1, g = x.h ? r / x.h : 1, h = (m) => i(m) * f / H, u = (m) => i(m) * g / H, p = [];
112
- let b = { x: 0, y: 0 }, d = { x: 0, y: 0 };
113
- for (const m of x.d) {
114
- if (--y < 0) break;
115
- switch (m[0]) {
116
- case "M":
117
- b = { x: h(m[1]), y: u(m[2]) }, d = b, p.push({ op: "M", ...b });
118
- break;
119
- case "L":
120
- b = { x: h(m[1]), y: u(m[2]) }, p.push({ op: "L", ...b });
121
- break;
122
- case "C": {
123
- const k = h(m[1]), M = u(m[2]), S = h(m[3]), v = u(m[4]);
124
- b = { x: h(m[5]), y: u(m[6]) }, p.push({ op: "C", x1: k, y1: M, x2: S, y2: v, ...b });
125
- break;
126
- }
127
- case "Q": {
128
- const k = h(m[1]), M = u(m[2]), S = h(m[3]), v = u(m[4]);
129
- p.push({ op: "C", x1: b.x + 2 / 3 * (k - b.x), y1: b.y + 2 / 3 * (M - b.y), x2: S + 2 / 3 * (k - S), y2: v + 2 / 3 * (M - v), x: S, y: v }), b = { x: S, y: v };
130
- break;
131
- }
132
- case "A": {
133
- const k = i(m[1]) * f / H, M = i(m[2]) * g / H;
134
- b = ge(p, b, k, M, i(m[3]), i(m[4]));
135
- break;
136
- }
137
- case "Z":
138
- p.push({ op: "Z" }), b = d;
139
- break;
140
- }
141
- }
142
- p.length && c.push({ cmds: p, fill: x.fill === "none" ? !1 : void 0, stroke: x.stroke === !1 ? !1 : void 0 });
143
- }
144
- return c;
145
- }
146
- function ge(t, n, e, o, s, r) {
147
- if (Math.abs(e) < 1e-9 || Math.abs(o) < 1e-9 || r === 0) return n;
148
- const a = K(s), i = Math.max(-4 * Math.PI, Math.min(4 * Math.PI, K(r))), c = Nt(a, e, o);
149
- let y = Nt(a + i, e, o);
150
- if (Math.abs(i) >= 2 * Math.PI - 1e-9) y = c + Math.sign(i) * 2 * Math.PI;
151
- else {
152
- for (; i > 0 && y < c; ) y += 2 * Math.PI;
153
- for (; i < 0 && y > c; ) y -= 2 * Math.PI;
154
- }
155
- const x = n.x - e * Math.cos(c), f = n.y - o * Math.sin(c), g = y - c, h = Math.max(1, Math.min(16, Math.ceil(Math.abs(g) / (Math.PI / 2)))), u = g / h, p = 4 / 3 * Math.tan(u / 4);
156
- let b = c, d = n;
157
- for (let m = 0; m < h; m++) {
158
- const k = b + u, M = Math.cos(b), S = Math.sin(b), v = Math.cos(k), I = Math.sin(k);
159
- d = { x: x + e * v, y: f + o * I }, t.push({ op: "C", x1: x + e * (M - p * S), y1: f + o * (S + p * M), x2: x + e * (v + p * I), y2: f + o * (I - p * v), ...d }), b = k;
160
- }
161
- return d;
162
- }
163
- function Ut(t, n, e, o = {}) {
164
- const s = Math.abs(n), r = Math.abs(e);
165
- if (!t.rect) return { l: 0, t: 0, r: s, b: r };
166
- const a = _t(t, s * H, r * H, o), i = (g) => (a.get(g) ?? (Number.isFinite(Number(g)) ? Number(g) : 0)) / H, [c, y, x, f] = t.rect.map(i);
167
- return { l: c, t: y, r: x, b: f };
168
- }
169
- let Ot = null;
170
- async function xe() {
171
- return Ot ??= (await import("./presets-DP49P8i2.js")).default, Ot;
172
- }
173
- const Et = 5e4, be = 256 * 1024 * 1024, At = 1024 * 1024 * 1024, ye = 1e4, ke = 32, we = 2e4, R = (t, n) => {
174
- if (!t) return [];
175
- const e = [];
176
- for (let o = t.firstChild; o; o = o.nextSibling)
177
- o.nodeType === 1 && (!n || o.localName === n) && e.push(o);
178
- return e;
179
- }, l = (t, n) => {
180
- if (!t) return null;
181
- for (let e = t.firstChild; e; e = e.nextSibling) if (e.nodeType === 1 && e.localName === n) return e;
182
- return null;
183
- }, E = (t, ...n) => {
184
- let e = t;
185
- for (const o of n) e = l(e, o);
186
- return e ?? null;
187
- }, w = (t, n) => {
188
- if (!t) return null;
189
- const e = t.getAttribute(n);
190
- if (e !== null && e !== "") return e;
191
- const o = n.includes(":") ? n.split(":")[1] : n;
192
- for (let s = 0; s < (t.attributes?.length ?? 0); s++) {
193
- const r = t.attributes[s];
194
- if (r.localName === o && (n.includes(":") || !r.name.includes(":"))) return r.value;
195
- }
196
- return null;
197
- }, C = (t, n, e = 0) => {
198
- const o = w(t, n), s = o === null ? NaN : Number(o);
199
- return Number.isFinite(s) ? s : e;
200
- }, B = (t, n) => {
201
- const e = w(t, n);
202
- return e === null ? void 0 : e === "1" || e === "true" || e === "on";
203
- }, L = (t) => t / H, Me = /* @__PURE__ */ new Set(["p14", "a14", "a16"]);
204
- function ve(t) {
205
- if (t.localName !== "AlternateContent") return [t];
206
- const n = l(t, "Fallback");
207
- for (const e of R(t, "Choice"))
208
- if ((w(e, "Requires") || "").split(/\s+/).filter(Boolean).every((s) => Me.has(s))) return R(e);
209
- return R(n);
210
- }
211
- const ut = (t) => R(t).flatMap(ve);
212
- class Se {
213
- files;
214
- text = /* @__PURE__ */ new Map();
215
- relCache = /* @__PURE__ */ new Map();
216
- parseXml;
217
- warn;
218
- constructor(n, e, o) {
219
- this.parseXml = e, this.warn = o, this.files = {};
220
- for (const [s, r] of Object.entries(n)) this.files[Z(s)] = r;
221
- }
222
- bytes(n) {
223
- return this.files[Z(n)];
224
- }
225
- xml(n) {
226
- const e = Z(n);
227
- if (!this.text.has(e)) {
228
- const o = this.files[e];
229
- let s = null;
230
- if (o) {
231
- try {
232
- const r = ie(o).replace(/^/, "");
233
- s = /<!DOCTYPE/i.test(r.slice(0, 2048)) ? null : this.parseXml(r), s && s.getElementsByTagName("parsererror").length && (s = null);
234
- } catch {
235
- s = null;
236
- }
237
- s || this.warn(`Couldn't read ${e}`);
238
- }
239
- this.text.set(e, s);
240
- }
241
- return this.text.get(e)?.documentElement ?? null;
242
- }
243
- rels(n) {
244
- const e = Z(n);
245
- let o = this.relCache.get(e);
246
- if (o) return o;
247
- o = /* @__PURE__ */ new Map();
248
- const s = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "", r = e.slice(e.lastIndexOf("/") + 1), a = this.xml(`${s ? s + "/" : ""}_rels/${r}.rels`);
249
- for (const i of R(a, "Relationship")) {
250
- const c = w(i, "Id"), y = w(i, "Type") || "", x = w(i, "Target") || "";
251
- if (!c) continue;
252
- const f = w(i, "TargetMode") === "External";
253
- o.set(c, { type: y.slice(y.lastIndexOf("/") + 1), target: f ? x : Ce(s, x), external: f });
254
- }
255
- return this.relCache.set(e, o), o;
256
- }
257
- relOfType(n, e) {
258
- for (const o of this.rels(n).values()) if (o.type === e && !o.external) return o.target;
259
- return null;
260
- }
261
- }
262
- const Z = (t) => t.replace(/\\/g, "/").replace(/^\/+/, "");
263
- function Ce(t, n) {
264
- let e = n.split("#")[0];
265
- try {
266
- e = decodeURIComponent(e);
267
- } catch {
268
- }
269
- if (e.startsWith("/")) return Z(e);
270
- const o = (t ? t.split("/") : []).concat(e.split("/")), s = [];
271
- for (const r of o)
272
- r === ".." ? s.pop() : r && r !== "." && s.push(r);
273
- return s.join("/");
274
- }
275
- const St = { bg1: "lt1", tx1: "dk1", bg2: "lt2", tx2: "dk2" };
276
- function pt(t) {
277
- const n = { colors: {}, major: "Calibri Light", minor: "Calibri", fills: [], lines: [], bgFills: [] }, e = l(t, "themeElements");
278
- for (const r of R(l(e, "clrScheme"))) {
279
- const a = R(r)[0];
280
- if (!a) continue;
281
- const i = a.localName === "sysClr" ? w(a, "lastClr") : w(a, "val");
282
- i && /^[0-9a-f]{6}$/i.test(i) && (n.colors[r.localName] = "#" + i.toLowerCase());
283
- }
284
- const o = l(e, "fontScheme");
285
- n.major = w(E(o, "majorFont", "latin"), "typeface") || n.major, n.minor = w(E(o, "minorFont", "latin"), "typeface") || n.minor;
286
- const s = l(e, "fmtScheme");
287
- return n.fills = R(l(s, "fillStyleLst")), n.lines = R(l(s, "lnStyleLst")), n.bgFills = R(l(s, "bgFillStyleLst")), n;
288
- }
289
- const Pe = {
290
- black: "#000000",
291
- white: "#ffffff",
292
- red: "#ff0000",
293
- green: "#008000",
294
- blue: "#0000ff",
295
- yellow: "#ffff00",
296
- gray: "#808080",
297
- grey: "#808080",
298
- silver: "#c0c0c0",
299
- orange: "#ffa500",
300
- purple: "#800080",
301
- navy: "#000080",
302
- teal: "#008080",
303
- maroon: "#800000",
304
- lime: "#00ff00",
305
- aqua: "#00ffff",
306
- cyan: "#00ffff",
307
- fuchsia: "#ff00ff",
308
- magenta: "#ff00ff",
309
- olive: "#808000",
310
- darkGray: "#a9a9a9",
311
- lightGray: "#d3d3d3",
312
- dkGray: "#a9a9a9",
313
- ltGray: "#d3d3d3"
314
- }, Gt = (t) => {
315
- const n = t.replace("#", "");
316
- return [parseInt(n.slice(0, 2), 16) || 0, parseInt(n.slice(2, 4), 16) || 0, parseInt(n.slice(4, 6), 16) || 0];
317
- }, rt = (t, n, e) => "#" + [t, n, e].map((o) => Math.max(0, Math.min(255, Math.round(o))).toString(16).padStart(2, "0")).join(""), Q = (t) => (t /= 255, t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4)), _ = (t) => 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * Math.pow(t, 1 / 2.4) - 0.055);
318
- function Lt(t, n, e) {
319
- t /= 255, n /= 255, e /= 255;
320
- const o = Math.max(t, n, e), s = Math.min(t, n, e), r = (o + s) / 2;
321
- if (o === s) return [0, 0, r];
322
- const a = o - s, i = r > 0.5 ? a / (2 - o - s) : a / (o + s);
323
- return [(o === t ? (n - e) / a + (n < e ? 6 : 0) : o === n ? (e - t) / a + 2 : (t - n) / a + 4) * 60, i, r];
324
- }
325
- function mt(t, n, e) {
326
- if (t = (t % 360 + 360) % 360 / 360, n === 0) return [e * 255, e * 255, e * 255];
327
- const o = e < 0.5 ? e * (1 + n) : e + n - e * n, s = 2 * e - o, r = (a) => (a = (a % 1 + 1) % 1, a < 1 / 6 ? s + (o - s) * 6 * a : a < 1 / 2 ? o : a < 2 / 3 ? s + (o - s) * (2 / 3 - a) * 6 : s);
328
- return [r(t + 1 / 3) * 255, r(t) * 255, r(t - 1 / 3) * 255];
329
- }
330
- function $(t, n) {
331
- const e = R(t).find((o) => /Clr$/.test(o.localName));
332
- return e ? Te(e, n) : null;
333
- }
334
- function Te(t, n) {
335
- let e = null, o = 1;
336
- switch (t.localName) {
337
- case "srgbClr": {
338
- const c = w(t, "val");
339
- e = c && /^[0-9a-f]{6}$/i.test(c) ? "#" + c.toLowerCase() : null;
340
- break;
341
- }
342
- case "sysClr": {
343
- const c = w(t, "lastClr");
344
- e = c ? "#" + c.toLowerCase() : w(t, "val") === "window" ? "#ffffff" : "#000000";
345
- break;
346
- }
347
- case "prstClr":
348
- e = Pe[w(t, "val") || ""] ?? "#000000";
349
- break;
350
- case "scrgbClr":
351
- e = rt(_(C(t, "r") / 1e5), _(C(t, "g") / 1e5), _(C(t, "b") / 1e5));
352
- break;
353
- case "hslClr": {
354
- const [c, y, x] = mt(C(t, "hue") / 6e4, C(t, "sat") / 1e5, C(t, "lum") / 1e5);
355
- e = rt(c, y, x);
356
- break;
357
- }
358
- case "schemeClr": {
359
- const c = w(t, "val") || "";
360
- if (c === "phClr") {
361
- n.phClr ? (e = n.phClr.hex, o = n.phClr.alpha ?? 1) : e = n.theme.colors.accent1 ?? "#4472c4";
362
- break;
363
- }
364
- const y = n.clrMap[c] ?? St[c] ?? c;
365
- e = n.theme.colors[y] ?? null;
366
- break;
367
- }
368
- }
369
- if (!e) return null;
370
- let [s, r, a] = Gt(e);
371
- for (const c of R(t)) {
372
- const y = C(c, "val") / 1e5;
373
- switch (c.localName) {
374
- case "alpha":
375
- o = y;
376
- break;
377
- case "alphaMod":
378
- o *= y;
379
- break;
380
- case "alphaOff":
381
- o += y;
382
- break;
383
- case "lumMod":
384
- case "lumOff":
385
- case "satMod":
386
- case "satOff":
387
- case "hueMod":
388
- case "hueOff": {
389
- let [x, f, g] = Lt(s, r, a);
390
- c.localName === "lumMod" ? g *= y : c.localName === "lumOff" ? g += y : c.localName === "satMod" ? f *= y : c.localName === "satOff" ? f += y : c.localName === "hueMod" ? x *= y : x += C(c, "val") / 6e4, [s, r, a] = mt(x, Math.max(0, Math.min(1, f)), Math.max(0, Math.min(1, g)));
391
- break;
392
- }
393
- case "tint":
394
- [s, r, a] = [s, r, a].map((x) => _(Q(x) * y + (1 - y)));
395
- break;
396
- case "shade":
397
- [s, r, a] = [s, r, a].map((x) => _(Q(x) * y));
398
- break;
399
- case "comp": {
400
- const [x, f, g] = Lt(s, r, a);
401
- [s, r, a] = mt(x + 180, f, g);
402
- break;
403
- }
404
- case "inv":
405
- [s, r, a] = [255 - s, 255 - r, 255 - a];
406
- break;
407
- case "gray": {
408
- s = r = a = 0.299 * s + 0.587 * r + 0.114 * a;
409
- break;
410
- }
411
- }
412
- }
413
- o = Math.max(0, Math.min(1, o));
414
- const i = { hex: rt(s, r, a) };
415
- return o < 0.999 && (i.alpha = o), i;
416
- }
417
- function V(t, n) {
418
- for (const e of R(t)) {
419
- const o = Ct(e, n);
420
- if (o) return o;
421
- }
422
- }
423
- function Ct(t, n) {
424
- switch (t.localName) {
425
- case "noFill":
426
- return { kind: "none" };
427
- case "solidFill": {
428
- const e = $(t, n.ctx);
429
- return e ? { kind: "solid", color: e } : { kind: "none" };
430
- }
431
- case "gradFill": {
432
- const e = R(l(t, "gsLst"), "gs").slice(0, 256).map((s) => ({ pos: C(s, "pos") / 1e5, color: $(s, n.ctx) ?? { hex: "#000000" } }));
433
- if (!e.length) return { kind: "none" };
434
- const o = l(t, "lin");
435
- return l(t, "path") ? { kind: "radial", stops: e } : { kind: "linear", stops: e, angle: o ? C(o, "ang") / 6e4 : 90, scaled: B(o, "scaled") ?? !1 };
436
- }
437
- case "blipFill": {
438
- const e = Vt(t, n);
439
- if (!e) return;
440
- const o = { kind: "image", media: e }, s = l(t, "tile");
441
- s && (o.tile = { sx: Math.max(0.01, C(s, "sx", 1e5) / 1e5), sy: Math.max(0.01, C(s, "sy", 1e5) / 1e5) });
442
- const r = l(l(t, "blip"), "alphaModFix");
443
- return r && (o.alpha = Math.max(0, Math.min(1, C(r, "amt", 1e5) / 1e5))), l(l(t, "blip"), "grayscl") && (o.grayscale = !0), o;
444
- }
445
- case "pattFill": {
446
- const e = $(l(t, "fgClr"), n.ctx), o = $(l(t, "bgClr"), n.ctx);
447
- return e ? { kind: "pattern", preset: w(t, "prst") || "pct50", color: e, ...o ? { bg: o } : {} } : void 0;
448
- }
449
- case "grpFill":
450
- return;
451
- }
452
- }
453
- const Ie = {
454
- png: "png",
455
- jpg: "jpeg",
456
- jpeg: "jpeg",
457
- jpe: "jpeg",
458
- gif: "gif",
459
- svg: "svg",
460
- bmp: "bmp",
461
- tif: "tiff",
462
- tiff: "tiff",
463
- webp: "webp",
464
- emf: "emf",
465
- wmf: "wmf"
466
- };
467
- function Vt(t, n) {
468
- const e = l(t, "blip"), o = w(e, "r:embed");
469
- if (!o) return null;
470
- const s = n.pkg.rels(n.part).get(o);
471
- if (!s || s.external) return null;
472
- const r = n.pkg.bytes(s.target), a = Ie[(s.target.split(".").pop() || "").toLowerCase()];
473
- return r && a ? { bytes: r, ext: a } : null;
474
- }
475
- const Re = { solid: "", dot: "sysDot", sysDot: "sysDot", sysDash: "dash", dash: "dash", lgDash: "dash", dashDot: "dash", lgDashDot: "dash", lgDashDotDot: "dash", sysDashDot: "dash", sysDashDotDot: "dash" };
476
- function U(t, n) {
477
- if (!t) return;
478
- let e;
479
- for (const i of R(t)) {
480
- if (i.localName === "noFill") return null;
481
- i.localName === "solidFill" && (e = $(i, n.ctx)), i.localName === "gradFill" && (e = $(l(l(i, "gsLst"), "gs"), n.ctx));
482
- }
483
- const o = w(t, "w");
484
- if (e === void 0 && o === null && !l(t, "prstDash") && !l(t, "headEnd") && !l(t, "tailEnd")) return;
485
- const s = (i) => {
486
- const c = w(i, "type");
487
- if (!c || c === "none") return;
488
- const y = c === "triangle" || c === "stealth" || c === "arrow" || c === "oval" || c === "diamond" ? c : "triangle", x = w(i, "len") || w(i, "w");
489
- return { type: y, size: x === "sm" || x === "lg" ? x : "med" };
490
- }, r = Re[w(l(t, "prstDash"), "val") || "solid"], a = w(t, "cap");
491
- return {
492
- // ECMA's default is 9525 EMU — 0.75 pt, one px.
493
- width: o !== null ? Math.max(0, L(Number(o) || 0)) : 1,
494
- color: e ?? { hex: "#000000" },
495
- dash: r || void 0,
496
- cap: a === "rnd" ? "rnd" : a === "sq" ? "sq" : a === "flat" ? "flat" : void 0,
497
- join: l(t, "round") ? "round" : l(t, "bevel") ? "bevel" : l(t, "miter") ? "miter" : void 0,
498
- head: s(l(t, "headEnd")),
499
- tail: s(l(t, "tailEnd"))
500
- };
501
- }
502
- function lt(t, n) {
503
- const e = l(t, "fillRef");
504
- if (!e) return;
505
- const o = C(e, "idx");
506
- if (o === 0) return { kind: "none" };
507
- const r = (o >= 1001 ? n.ctx.theme.bgFills : n.ctx.theme.fills)[o >= 1001 ? o - 1001 : o - 1];
508
- if (!r) return;
509
- const a = $(e, n.ctx) ?? void 0;
510
- return Ct(r, { ...n, ctx: { ...n.ctx, phClr: a } });
511
- }
512
- function Pt(t, n) {
513
- const e = l(t, "lnRef");
514
- if (!e) return;
515
- const o = C(e, "idx");
516
- if (o === 0) return null;
517
- const s = n.ctx.theme.lines[o - 1];
518
- if (!s) return;
519
- const r = $(e, n.ctx) ?? void 0;
520
- return U(s, { ...n, ctx: { ...n.ctx, phClr: r } }) ?? void 0;
521
- }
522
- function Y(t) {
523
- if (!t) return null;
524
- const n = l(t, "off"), e = l(t, "ext");
525
- return !n || !e ? null : {
526
- x: L(C(n, "x")),
527
- y: L(C(n, "y")),
528
- w: Math.max(0, L(C(e, "cx"))),
529
- h: Math.max(0, L(C(e, "cy"))),
530
- rot: C(t, "rot") / 6e4,
531
- flipH: !!B(t, "flipH"),
532
- flipV: !!B(t, "flipV")
533
- };
534
- }
535
- const gt = (t) => t;
536
- function Ne(t, n) {
537
- const e = Y(t);
538
- if (!e) return n;
539
- const o = l(t, "chOff"), s = l(t, "chExt"), r = o ? L(C(o, "x")) : e.x, a = o ? L(C(o, "y")) : e.y, i = s ? L(C(s, "cx")) : e.w, c = s ? L(C(s, "cy")) : e.h, y = i > 0 ? e.w / i : 1, x = c > 0 ? e.h / c : 1, f = e.x + e.w / 2, g = e.y + e.h / 2, h = e.rot * Math.PI / 180;
540
- return (u) => {
541
- let p = e.x + (u.x + u.w / 2 - r) * y, b = e.y + (u.y + u.h / 2 - a) * x, d = u.rot, m = u.flipH, k = u.flipV;
542
- if (e.flipH && (p = 2 * f - p, m = !m, d = -d), e.flipV && (b = 2 * g - b, k = !k, d = -d), h) {
543
- const v = p - f, I = b - g;
544
- p = f + v * Math.cos(h) - I * Math.sin(h), b = g + v * Math.sin(h) + I * Math.cos(h), d += e.rot;
545
- }
546
- const M = u.w * y, S = u.h * x;
547
- return n({ x: p - M / 2, y: b - S / 2, w: M, h: S, rot: (d % 360 + 360) % 360, flipH: m, flipV: k });
548
- };
549
- }
550
- function Ft(t) {
551
- const n = l(t, "spcPts"), e = l(t, "spcPct");
552
- if (n) return { px: Math.max(0, Math.min(1584, C(n, "val") / 100)) * (vt / H) };
553
- if (e) return { lines: Math.max(0, Math.min(13.2, C(e, "val") / 1e5)) };
554
- }
555
- function Dt(t, n, e) {
556
- const o = l(t, `lvl${n + 1}pPr`) ?? (t && t.localName.endsWith("pPr") ? t : null);
557
- return o ? qt(o, e) : {};
558
- }
559
- function qt(t, n) {
560
- const e = {};
561
- if (w(t, "algn") && (e.algn = w(t, "algn")), w(t, "marL") !== null && (e.marL = L(C(t, "marL"))), w(t, "indent") !== null && (e.indent = L(C(t, "indent"))), l(t, "buNone")) e.bullet = "none";
562
- else if (l(t, "buAutoNum")) {
563
- const a = l(t, "buAutoNum");
564
- e.bullet = "num", e.numType = w(a, "type") || "arabicPeriod", e.startAt = w(a, "startAt") !== null ? Math.max(1, Math.min(32767, Math.round(C(a, "startAt", 1)))) : void 0;
565
- } else l(t, "buChar") ? (e.bullet = "char", e.buChar = w(l(t, "buChar"), "char") || void 0) : l(t, "buBlip") && (e.bullet = "char", e.buChar = "•");
566
- if (l(t, "buFont") ? e.buFont = w(l(t, "buFont"), "typeface") || null : l(t, "buFontTx") && (e.buFont = null), l(t, "buClr") ? e.buClr = $(l(t, "buClr"), n.ctx) : l(t, "buClrTx") && (e.buClr = null), l(t, "buSzPct")) {
567
- const a = w(l(t, "buSzPct"), "val") || "", i = a.endsWith("%") ? parseFloat(a) / 100 : Number(a) / 1e5;
568
- e.buSz = Number.isFinite(i) && i > 0 ? Math.max(0.25, Math.min(4, i)) : null;
569
- } else (l(t, "buSzTx") || l(t, "buSzPts")) && (e.buSz = null);
570
- const o = E(t, "lnSpc", "spcPct");
571
- o && (e.lnSpcPct = C(o, "val") / 1e5);
572
- const s = Ft(l(t, "spcBef")), r = Ft(l(t, "spcAft"));
573
- return s && (e.spcBef = s), r && (e.spcAft = r), Object.assign(e, Zt(l(t, "defRPr"), n)), e;
574
- }
575
- function Zt(t, n) {
576
- if (!t) return {};
577
- const e = {};
578
- w(t, "sz") !== null && (e.sz = C(t, "sz") / 100 * (vt / H)), B(t, "b") !== void 0 && (e.b = B(t, "b")), B(t, "i") !== void 0 && (e.i = B(t, "i")), w(t, "u") && (e.u = w(t, "u") !== "none"), w(t, "strike") && (e.strike = w(t, "strike") !== "noStrike");
579
- const o = l(t, "solidFill");
580
- o ? e.color = $(o, n.ctx) : l(t, "noFill") && (e.color = null);
581
- const s = w(l(t, "latin"), "typeface");
582
- return s && (e.font = s), e;
583
- }
584
- const Oe = {
585
- 108: "●",
586
- 110: "■",
587
- 111: "□",
588
- 113: "❑",
589
- 117: "◆",
590
- 118: "❖",
591
- 159: "•",
592
- 167: "▪",
593
- 168: "◻",
594
- 216: "➢",
595
- 252: "✔",
596
- 251: "✗",
597
- 254: "☑"
598
- }, Ee = { 183: "•", 168: "♦", 174: "→", 222: "⇒", 45: "−", 42: "∗" };
599
- function Ae(t, n) {
600
- if (!t) return "•";
601
- let e = t.codePointAt(0);
602
- e >= 61440 && e <= 61695 && (e -= 61440);
603
- const o = (n || "").toLowerCase();
604
- return o.startsWith("wingdings") ? o === "wingdings" && Oe[e] || "•" : o === "symbol" ? Ee[e] ?? (e < 128 && e > 32 ? String.fromCharCode(e) : "•") : o.startsWith("webdings") || o.startsWith("marlett") ? "•" : o === "courier new" && t === "o" ? "◦" : /\s/.test(t) || e < 32 ? "•" : [...t][0];
605
- }
606
- const jt = (...t) => {
607
- const n = {};
608
- for (const e of t) for (const [o, s] of Object.entries(e)) s !== void 0 && (n[o] = s);
609
- return n;
610
- };
611
- function Le(t, n) {
612
- if (t)
613
- return t.startsWith("+mj") ? n.major : t.startsWith("+mn") ? n.minor : t;
614
- }
615
- function Tt(t, n, e) {
616
- if (!t) return;
617
- const o = R(t, "p");
618
- if (!o.some((h) => R(h).some((u) => (u.localName === "r" || u.localName === "fld") && (E(u, "t")?.textContent ?? "") !== ""))) return;
619
- const r = {};
620
- let a = 1, i = 1;
621
- for (const h of [...n.bodyPr, l(t, "bodyPr")]) {
622
- if (!h) continue;
623
- for (let p = 0; p < h.attributes.length; p++) r[h.attributes[p].localName ?? h.attributes[p].name] = h.attributes[p].value;
624
- const u = l(h, "normAutofit");
625
- u && (a = w(u, "fontScale") !== null ? C(u, "fontScale") / 1e5 : 1), u && (i = 1 - Math.max(0, Math.min(0.9, C(u, "lnSpcReduction") / 1e5))), (l(h, "noAutofit") || l(h, "spAutoFit")) && (a = 1, i = 1);
626
- }
627
- const c = (h, u) => r[h] !== void 0 ? L(Number(r[h]) || 0) : L(u), y = r.anchor === "ctr" ? "ctr" : r.anchor === "b" ? "b" : "t", x = l(t, "lstStyle"), f = [];
628
- let g;
629
- for (const h of o) {
630
- const u = l(h, "pPr"), p = Math.max(0, Math.min(8, C(u, "lvl"))), b = n.fontRef ? { color: n.fontRef.color ?? void 0, font: n.fontRef.font } : {}, d = jt(...n.levels.map((P) => Dt(P, p, e)), b, Dt(x, p, e), u ? qt(u, e) : {});
631
- d.lnSpcPct !== void 0 && g === void 0 && (g = d.lnSpcPct);
632
- const m = { runs: [], align: d.algn === "ctr" ? "ctr" : d.algn === "r" ? "r" : (d.algn === "just", "l"), level: p };
633
- if (d.bullet === "char" || d.bullet === "num") {
634
- if (m.bullet = d.bullet, m.marL = d.marL ?? 0, m.indent = d.indent ?? 0, d.bullet === "char") {
635
- const P = Ae(d.buChar, d.buFont ?? void 0);
636
- P !== "•" && (m.bulletChar = P);
637
- } else
638
- d.numType && d.numType !== "arabicPeriod" && (m.numType = d.numType), d.startAt && d.startAt !== 1 && (m.startAt = d.startAt);
639
- d.buClr && (m.bulletColor = d.buClr), d.buSz && Math.abs(d.buSz - 1) > 1e-3 && (m.bulletScale = d.buSz);
640
- }
641
- const k = (P) => {
642
- const T = jt(d, Zt(P, e)), O = (T.sz ?? 18 * vt / H) * a, A = T.color === null ? void 0 : T.color ?? Kt("tx1", e);
643
- return {
644
- text: "",
645
- size: O,
646
- bold: T.b || void 0,
647
- italic: T.i || void 0,
648
- underline: T.u || void 0,
649
- strike: T.strike || void 0,
650
- color: A ?? void 0,
651
- font: Le(T.font ?? "+mn-lt", e.ctx.theme)
652
- };
653
- };
654
- for (const P of R(h))
655
- if (P.localName === "r" || P.localName === "fld") {
656
- const T = E(P, "t")?.textContent ?? "";
657
- if (!T) continue;
658
- T.split(/[\v\n]/).forEach((O, A) => {
659
- A > 0 && m.runs.push({ ...k(l(P, "rPr")), br: !0 }), O && m.runs.push({ ...k(l(P, "rPr")), text: O });
660
- });
661
- } else P.localName === "br" && m.runs.push({ ...k(l(P, "rPr")), br: !0 });
662
- m.endSize = k(l(h, "endParaRPr")).size;
663
- const M = (m.runs.length ? Math.max(...m.runs.map((P) => P.size ?? 0)) : m.endSize ?? 0) * 1.2 * (d.lnSpcPct ?? 1), S = (P) => P ? ("px" in P ? P.px : P.lines * M) * i : 0, v = S(d.spcBef), I = S(d.spcAft);
664
- v > 0.05 && (m.spaceBefore = Math.round(v * 100) / 100), I > 0.05 && (m.spaceAfter = Math.round(I * 100) / 100), f.push(m);
665
- }
666
- return {
667
- paragraphs: f,
668
- anchor: y,
669
- insets: { l: c("lIns", 91440), t: c("tIns", 45720), r: c("rIns", 91440), b: c("bIns", 45720) },
670
- wrap: r.wrap !== "none",
671
- lineSpacing: g
672
- };
673
- }
674
- const Kt = (t, n) => {
675
- const e = n.ctx.clrMap[t] ?? St[t] ?? t, o = n.ctx.theme.colors[e];
676
- return o ? { hex: o } : null;
677
- }, J = (t) => {
678
- const n = l(t, "ph");
679
- return n ? { type: w(n, "type") || "obj", idx: C(n, "idx") } : null;
680
- }, at = (t) => l(R(t).find((n) => n.localName.startsWith("nv")) ?? null, "nvPr"), nt = /* @__PURE__ */ new Set(["title", "ctrTitle"]), $t = /* @__PURE__ */ new Set(["title", "ctrTitle", "dt", "ftr", "sldNum", "hdr"]), Bt = (t, n) => t === n || nt.has(t) && nt.has(n) || !$t.has(t) && !$t.has(n);
681
- function ct(t, n) {
682
- const e = Fe(t);
683
- if (n.idx) {
684
- const o = e.find((s) => s.ph.idx === n.idx && Bt(s.ph.type, n.type));
685
- if (o) return o.el;
686
- }
687
- return (e.find((o) => o.ph.type === n.type && (o.ph.idx === n.idx || !n.idx || nt.has(n.type))) ?? e.find((o) => o.ph.type === n.type) ?? e.find((o) => Bt(o.ph.type, n.type)))?.el ?? null;
688
- }
689
- function Fe(t) {
690
- const n = [];
691
- for (const e of ut(t)) {
692
- const o = J(at(e));
693
- o && n.push({ el: e, ph: o });
694
- }
695
- return n;
696
- }
697
- const Qt = (t) => nt.has(t) ? "title" : ["dt", "ftr", "sldNum", "hdr"].includes(t) ? t : "body", De = (t) => {
698
- const n = {};
699
- for (const e of R(l(t, "avLst"), "gd")) {
700
- const o = w(e, "name"), s = w(e, "fmla");
701
- o && s && (n[o] = s);
702
- }
703
- return n;
704
- };
705
- function je(t) {
706
- const n = (r) => R(r, "gd").slice(0, 1e4).map((a) => [w(a, "name") || "", w(a, "fmla") || "val 0"]), e = R(l(t, "cxnLst"), "cxn").map((r) => [w(r, "ang") || "0", w(l(r, "pos"), "x") || "0", w(l(r, "pos"), "y") || "0"]), o = l(t, "rect"), s = R(l(t, "pathLst"), "path").slice(0, 1e3).map((r) => {
707
- const a = [];
708
- for (const c of R(r)) {
709
- const y = R(c, "pt").map((x) => [w(x, "x") || "0", w(x, "y") || "0"]).flat();
710
- switch (c.localName) {
711
- case "moveTo":
712
- a.push(["M", ...y]);
713
- break;
714
- case "lnTo":
715
- a.push(["L", ...y]);
716
- break;
717
- case "quadBezTo":
718
- a.push(["Q", ...y]);
719
- break;
720
- case "cubicBezTo":
721
- a.push(["C", ...y]);
722
- break;
723
- case "arcTo":
724
- a.push(["A", w(c, "wR") || "0", w(c, "hR") || "0", w(c, "stAng") || "0", w(c, "swAng") || "0"]);
725
- break;
726
- case "close":
727
- a.push(["Z"]);
728
- break;
729
- }
730
- }
731
- const i = w(r, "fill");
732
- return { w: C(r, "w") || void 0, h: C(r, "h") || void 0, fill: i && i !== "norm" ? i : void 0, stroke: B(r, "stroke") === !1 ? !1 : void 0, d: a };
733
- });
734
- return {
735
- av: R(l(t, "avLst"), "gd").map((r) => [w(r, "name") || "", w(r, "fmla") || "val 0"]),
736
- gd: n(l(t, "gdLst")),
737
- cxn: e,
738
- rect: o ? [w(o, "l") || "l", w(o, "t") || "t", w(o, "r") || "r", w(o, "b") || "b"] : null,
739
- paths: s
740
- };
741
- }
742
- function tt(t, n) {
743
- const e = l(t, "prstGeom");
744
- if (e) {
745
- const s = {};
746
- for (const [r, a] of Object.entries(De(e))) {
747
- const i = /^val\s+(-?\d+(\.\d+)?)/.exec(a);
748
- i && (s[r] = Number(i[1]));
749
- }
750
- return { geom: { kind: "preset", prst: w(e, "prst") || "rect", adj: Object.keys(s).length ? s : void 0 } };
751
- }
752
- const o = l(t, "custGeom");
753
- if (o) {
754
- const s = je(o);
755
- return { geom: { kind: "custom", paths: it(s, n.w, n.h) }, textRect: s.rect ? Ut(s, n.w, n.h) : void 0 };
756
- }
757
- }
758
- function et(t, n, e, o, s, r) {
759
- const a = [];
760
- if (s > ke)
761
- return e.warnings.push("Groups nested too deeply; the innermost were skipped."), a;
762
- for (const i of ut(t)) {
763
- if (++e.count > we) {
764
- e.warnings.push("Too many shapes on one slide; the rest were skipped.");
765
- break;
766
- }
767
- try {
768
- const c = $e(i, n, e, o, s, r);
769
- c && a.push(...Array.isArray(c) ? c : [c]);
770
- } catch {
771
- e.warnings.push(`A ${i.localName} couldn't be read and was skipped.`);
772
- }
773
- }
774
- return a;
775
- }
776
- function $e(t, n, e, o, s, r) {
777
- const a = { pkg: e.pkg, part: n.part, ctx: e.ctx }, i = R(t).find((f) => f.localName.startsWith("nv")), c = l(i ?? null, "cNvPr"), y = C(c, "id"), x = w(c, "name") || t.localName;
778
- if (w(c, "hidden") === "1") return null;
779
- switch (t.localName) {
780
- case "sp":
781
- return Xe(t, n, e, o, y, x, r);
782
- case "cxnSp": {
783
- const f = l(t, "spPr"), g = Y(l(f, "xfrm"));
784
- if (!g) return null;
785
- const h = o(g), u = l(t, "style"), p = U(l(f, "ln"), a) ?? Pt(u, a) ?? { width: 1, color: { hex: "#000000" } };
786
- if (!p) return null;
787
- const b = tt(f, h) ?? { geom: { kind: "preset", prst: "line" } }, d = (k) => k ? { id: C(k, "id"), idx: C(k, "idx") } : void 0, m = l(i ?? null, "cNvCxnSpPr");
788
- return { kind: "connector", id: y, name: x, ...h, geom: b.geom, line: p, start: d(l(m, "stCxn")), end: d(l(m, "endCxn")) };
789
- }
790
- case "pic": {
791
- const f = l(t, "spPr");
792
- let g = Y(l(f, "xfrm"));
793
- const h = J(l(i ?? null, "nvPr"));
794
- if (!g && h && (g = Be(h, e)), !g) return null;
795
- const u = l(t, "blipFill"), p = u ? Vt(u, a) : null;
796
- if (!p)
797
- return e.warnings.push(`Picture "${x}" has no image the importer can read.`), null;
798
- const b = l(u, "srcRect"), d = b ? { l: C(b, "l") / 1e5, t: C(b, "t") / 1e5, r: C(b, "r") / 1e5, b: C(b, "b") / 1e5 } : void 0, m = w(E(u, "blip", "alphaModFix"), "amt"), k = o(g), M = tt(f, k)?.geom, S = M && !(M.kind === "preset" && M.prst === "rect") ? M : void 0;
799
- return { kind: "picture", id: y, name: x, ...k, media: p, crop: d, alpha: m !== null ? Number(m) / 1e5 : void 0, descr: w(c, "descr") || void 0, geom: S, ...E(u, "blip", "grayscl") ? { grayscale: !0 } : {} };
800
- }
801
- case "grpSp": {
802
- const f = l(t, "grpSpPr"), g = l(f, "xfrm"), h = Ne(g, o), u = et(t, n, e, h, s + 1, r);
803
- if (!u.length) return null;
804
- const p = ft(u);
805
- return { kind: "group", id: y, name: x, ...p, children: u };
806
- }
807
- case "graphicFrame":
808
- return We(t, n, e, o, y, x, s);
809
- default:
810
- return null;
811
- }
812
- }
813
- function ft(t) {
814
- let n = 1 / 0, e = 1 / 0, o = -1 / 0, s = -1 / 0;
815
- for (const r of t)
816
- n = Math.min(n, r.x), e = Math.min(e, r.y), o = Math.max(o, r.x + r.w), s = Math.max(s, r.y + r.h);
817
- return { x: n, y: e, w: Math.max(0, o - n), h: Math.max(0, s - e) };
818
- }
819
- function Be(t, n) {
820
- const e = ct(n.layout?.tree ?? null, t), o = Y(E(e, "spPr", "xfrm"));
821
- if (o) return o;
822
- const s = ct(n.master?.tree ?? null, { type: Qt(t.type), idx: 0 });
823
- return Y(E(s, "spPr", "xfrm"));
824
- }
825
- function ze(...t) {
826
- for (const n of t) {
827
- const e = n();
828
- if (e !== void 0) return e;
829
- }
830
- }
831
- function Xe(t, n, e, o, s, r, a) {
832
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, c = at(t), y = J(c);
833
- if (y && !a) return null;
834
- const x = l(t, "spPr"), f = l(t, "style"), g = w(E(t, "nvSpPr", "cNvSpPr"), "txBox") === "1", h = y && e.layout ? ct(e.layout.tree, y) : null, u = y && e.master ? ct(e.master.tree, { type: Qt(h ? J(at(h))?.type ?? y.type : y.type), idx: 0 }) : null, p = h && e.layout ? { pkg: e.pkg, part: e.layout.part, ctx: e.ctx } : null, b = u && e.master ? { pkg: e.pkg, part: e.master.part, ctx: e.ctx } : null;
835
- let d = Y(l(x, "xfrm")) ?? Y(E(h, "spPr", "xfrm")) ?? Y(E(u, "spPr", "xfrm"));
836
- if (!d) return null;
837
- d = o(d);
838
- const m = tt(x, d) ?? (h ? tt(l(h, "spPr"), d) : void 0) ?? (u ? tt(l(u, "spPr"), d) : void 0) ?? { geom: { kind: "preset", prst: "rect" } }, M = (B(t, "useBgFill") ? e.background?.kind === "image" ? { kind: "none" } : e.background ?? { kind: "solid", color: { hex: "#ffffff" } } : void 0) ?? V(x, i) ?? lt(f, i) ?? (p ? V(l(h, "spPr"), p) : void 0) ?? (b ? V(l(u, "spPr"), b) : void 0) ?? (p ? lt(l(h, "style"), p) : void 0) ?? { kind: "none" }, S = ze(
839
- () => U(l(x, "ln"), i),
840
- () => Pt(f, i),
841
- () => p ? U(E(h, "spPr", "ln"), p) : void 0,
842
- () => b ? U(E(u, "spPr", "ln"), b) : void 0
843
- ) ?? null, v = [];
844
- if (y) {
845
- const D = h ? J(at(h))?.type ?? y.type : y.type;
846
- v.push(nt.has(D) ? e.masterTx.title : ["body", "obj", "subTitle", "tbl", "chart", "dgm", "media", "pic", "clipArt"].includes(D) ? e.masterTx.body : e.masterTx.other), v.push(E(u, "txBody", "lstStyle"), E(h, "txBody", "lstStyle"));
847
- } else
848
- v.push(e.defaultText);
849
- const I = l(f, "fontRef"), P = {
850
- levels: v,
851
- bodyPr: [E(u, "txBody", "bodyPr"), E(h, "txBody", "bodyPr")],
852
- fontRef: I ? { font: w(I, "idx") === "major" ? "+mj-lt" : "+mn-lt", color: $(I, i.ctx) } : void 0
853
- }, T = Tt(l(t, "txBody"), P, i);
854
- if (!(M.kind !== "none" || !!S || !!T)) return null;
855
- let A = m.textRect;
856
- const N = Y(l(x, "xfrm")), z = T ? Y(l(t, "txXfrm")) : null;
857
- if (z && N && N.w > 0 && N.h > 0) {
858
- const D = d.w / N.w, W = d.h / N.h, X = { l: (z.x - N.x) * D, t: (z.y - N.y) * W, r: (z.x + z.w - N.x) * D, b: (z.y + z.h - N.y) * W };
859
- (Math.abs(X.l) > 0.5 || Math.abs(X.t) > 0.5 || Math.abs(X.r - d.w) > 0.5 || Math.abs(X.b - d.h) > 0.5) && (A = X);
860
- }
861
- return { kind: "shape", id: s, name: r, ...d, geom: m.geom, fill: M, line: S, text: T, textBox: g || void 0, textRect: A };
862
- }
863
- const zt = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
864
- function He(t, n) {
865
- const e = {};
866
- if (!t) return e;
867
- const o = l(t, "tcStyle"), s = l(t, "tcTxStyle"), r = l(o, "fill"), a = r ? V(r, n) : lt(o, n);
868
- a && (e.fill = a);
869
- const i = $(s, n.ctx) ?? $(l(s, "fontRef"), n.ctx);
870
- i && (e.text = i), w(s, "b") === "on" && (e.bold = !0);
871
- const c = l(o, "tcBdr");
872
- for (const y of ["insideH", "bottom", "top", "left"]) {
873
- const x = l(c, y);
874
- if (!x) continue;
875
- const f = U(l(x, "ln"), n) ?? Pt(x, n);
876
- if (f !== void 0) {
877
- e.border = f;
878
- break;
879
- }
880
- }
881
- return e;
882
- }
883
- function Ye(t, n, e) {
884
- const o = ((l(t, "tableStyleId")?.textContent || "").trim() || w(e, "def") || zt).toUpperCase(), s = (f) => B(t, f) ?? !1, r = { firstRow: s("firstRow"), lastRow: s("lastRow"), firstCol: s("firstCol"), lastCol: s("lastCol"), bandRow: s("bandRow"), bandCol: s("bandCol") }, a = R(e, "tblStyle").find((f) => (w(f, "styleId") || "").toUpperCase() === o);
885
- if (a) {
886
- const f = (b) => He(l(a, b), n), g = l(a, "tblBg"), h = g ? l(g, "fill") ? V(l(g, "fill"), n) : lt(g, n) : void 0, u = {
887
- whole: f("wholeTbl"),
888
- b1H: f("band1H"),
889
- b2H: f("band2H"),
890
- b1V: f("band1V"),
891
- b2V: f("band2V"),
892
- firstRow: f("firstRow"),
893
- lastRow: f("lastRow"),
894
- firstCol: f("firstCol"),
895
- lastCol: f("lastCol")
896
- }, p = (b, d, m, k) => {
897
- const M = [u.whole], S = b - (r.firstRow ? 1 : 0), v = d - (r.firstCol ? 1 : 0);
898
- r.bandCol && v >= 0 && M.push(v % 2 === 0 ? u.b1V : u.b2V), r.bandRow && S >= 0 && M.push(S % 2 === 0 ? u.b1H : u.b2H), r.firstCol && d === 0 && M.push(u.firstCol), r.lastCol && d === k - 1 && M.push(u.lastCol), r.firstRow && b === 0 && M.push(u.firstRow), r.lastRow && b === m - 1 && M.push(u.lastRow);
899
- const I = {};
900
- for (const P of M)
901
- P.fill && (I.fill = P.fill), P.text && (I.text = P.text), P.bold && (I.bold = !0), P.border !== void 0 && (I.border = P.border);
902
- return I;
903
- };
904
- return h && h.kind !== "none" && (p.background = h), p;
905
- }
906
- if (o !== zt) return null;
907
- const i = n.ctx.theme.colors.accent1 ?? "#4472c4", c = (f) => {
908
- const [g, h, u] = Gt(i);
909
- return { hex: rt(_(Q(g) * f + (1 - f)), _(Q(h) * f + (1 - f)), _(Q(u) * f + (1 - f))) };
910
- }, y = { hex: n.ctx.theme.colors.lt1 ?? "#ffffff" }, x = Kt("tx1", n) ?? void 0;
911
- return (f) => {
912
- const g = r.firstRow && f === 0, h = r.bandRow && !g && (f - (r.firstRow ? 1 : 0)) % 2 === 0;
913
- return {
914
- fill: { kind: "solid", color: g ? { hex: i } : c(h ? 0.4 : 0.2) },
915
- text: g ? y : x,
916
- bold: g || void 0,
917
- border: { width: 1.33, color: y }
918
- };
919
- };
920
- }
921
- function We(t, n, e, o, s, r, a = 0) {
922
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, c = Y(l(t, "xfrm"));
923
- if (!c) return null;
924
- const y = E(t, "graphic", "graphicData"), x = l(y, "tbl");
925
- if (x) {
926
- const h = R(l(x, "tblGrid"), "gridCol").map((k) => L(C(k, "w"))), u = Ye(l(x, "tblPr"), i, e.tableStyles), p = [];
927
- let b = c.y, d = 1e6 + s * 1e3;
928
- const m = R(x, "tr");
929
- if (m.forEach((k, M) => {
930
- const S = L(C(k, "h"));
931
- let v = c.x, I = 0;
932
- for (const P of R(k, "tc")) {
933
- const T = Math.max(1, C(P, "gridSpan", 1)), O = h.slice(I, I + T).reduce((G, F) => G + F, 0);
934
- if (I += T, B(P, "hMerge") || B(P, "vMerge")) {
935
- v += O;
936
- continue;
937
- }
938
- const A = Math.max(1, C(P, "rowSpan", 1)), N = l(P, "tcPr"), z = A > 1 ? S * A : S, D = u ? u(M, I - T, m.length, h.length) : null, W = D?.text ? { color: D.text } : void 0, X = Tt(l(P, "txBody"), { levels: [e.defaultText], bodyPr: [], fontRef: W }, i);
939
- X && D?.bold && X.paragraphs.forEach((G) => G.runs.forEach((F) => {
940
- F.bold === void 0 && (F.bold = !0);
941
- })), X && (X.insets = { l: L(C(N, "marL", 91440)), r: L(C(N, "marR", 91440)), t: L(C(N, "marT", 45720)), b: L(C(N, "marB", 45720)) }, X.anchor = w(N, "anchor") === "ctr" ? "ctr" : w(N, "anchor") === "b" ? "b" : "t");
942
- const dt = U(l(N, "lnB"), i) ?? U(l(N, "lnT"), i) ?? (D ? D.border ?? null : { width: 1, color: { hex: "#bfbfbf" } }), ot = D?.fill;
943
- p.push({
944
- kind: "shape",
945
- id: d++,
946
- name: `${r} cell`,
947
- ...o({ x: v, y: b, w: O, h: z, rot: 0, flipH: !1, flipV: !1 }),
948
- geom: { kind: "preset", prst: "rect" },
949
- fill: V(N, i) ?? ot ?? { kind: "none" },
950
- line: dt,
951
- text: X
952
- }), v += O;
953
- }
954
- b += S;
955
- }), !p.length) return null;
956
- if (u?.background) {
957
- const k = ft(p);
958
- p.unshift({
959
- kind: "shape",
960
- id: d++,
961
- name: `${r} background`,
962
- x: k.x,
963
- y: k.y,
964
- w: k.w,
965
- h: k.h,
966
- rot: 0,
967
- flipH: !1,
968
- flipV: !1,
969
- geom: { kind: "preset", prst: "rect" },
970
- fill: u.background,
971
- line: null
972
- });
973
- }
974
- return { kind: "group", id: s, name: r, ...ft(p), children: p };
975
- }
976
- const f = w(y, "uri") || "";
977
- if (/diagram/.test(f)) {
978
- const h = _e(y, n, e, o, c, s, r, a);
979
- if (h) return h;
980
- const u = Ue(y, n, e, o, c, s, r, i);
981
- if (u) return u;
982
- }
983
- const g = /chart/.test(f) ? "Chart" : /diagram/.test(f) ? "SmartArt diagram" : "Embedded object";
984
- return e.warnings.push(`${g} "${r}" was imported as a placeholder frame.`), {
985
- kind: "shape",
986
- id: s,
987
- name: r,
988
- ...o(c),
989
- geom: { kind: "preset", prst: "rect" },
990
- fill: { kind: "solid", color: { hex: "#f1f3f5" } },
991
- line: { width: 1, color: { hex: "#adb5bd" }, dash: "dash" },
992
- text: { paragraphs: [{ runs: [{ text: `${g}: ${r}`, size: 16, color: { hex: "#495057" } }], align: "ctr" }], anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
993
- };
994
- }
995
- function _e(t, n, e, o, s, r, a, i) {
996
- const c = e.pkg.rels(n.part), y = w(l(t, "relIds"), "r:dm"), x = y ? c.get(y) : void 0;
997
- let f;
998
- if (x && !x.external) {
999
- const d = Jt(e.pkg.xml(x.target), "dataModelExt", 6), m = d ? c.get(w(d, "relId") || "") : void 0;
1000
- m && !m.external && (f = m.target);
1001
- }
1002
- if (!f) {
1003
- const d = [...c.values()].filter((m) => m.type === "diagramDrawing" && !m.external);
1004
- d.length === 1 && (f = d[0].target);
1005
- }
1006
- if (!f) return null;
1007
- const g = l(e.pkg.xml(f), "spTree");
1008
- if (!g) return null;
1009
- const u = et(g, { part: f, tree: g }, e, (d) => o({ ...d, x: d.x + s.x, y: d.y + s.y }), i + 1, !0);
1010
- if (!u.length) return null;
1011
- let p = 2e6 + r * 1e3;
1012
- const b = (d) => d.forEach((m) => {
1013
- m.id = p++, m.kind === "group" && b(m.children);
1014
- });
1015
- return b(u), { kind: "group", id: r, name: a, ...ft(u), children: u };
1016
- }
1017
- function Ue(t, n, e, o, s, r, a, i) {
1018
- const c = w(l(t, "relIds"), "r:dm"), y = c ? e.pkg.rels(n.part).get(c) : void 0;
1019
- if (!y || y.external) return null;
1020
- const x = e.pkg.xml(y.target), f = /* @__PURE__ */ new Map();
1021
- for (const d of R(l(x, "ptLst"), "pt")) f.set(w(d, "modelId") || "", d);
1022
- const g = /* @__PURE__ */ new Map();
1023
- for (const d of R(l(x, "cxnLst"), "cxn")) {
1024
- if ((w(d, "type") || "parOf") !== "parOf") continue;
1025
- const m = w(d, "srcId") || "", k = w(d, "destId") || "";
1026
- g.has(m) || g.set(m, []), g.get(m).push({ id: k, ord: C(d, "srcOrd") });
1027
- }
1028
- const h = [...f.values()].find((d) => w(d, "type") === "doc");
1029
- if (!h) return null;
1030
- const u = [], p = /* @__PURE__ */ new Set(), b = (d, m) => {
1031
- if (!(p.has(d) || m > 16 || u.length > 500)) {
1032
- p.add(d);
1033
- for (const k of (g.get(d) ?? []).sort((M, S) => M.ord - S.ord)) {
1034
- const M = f.get(k.id), S = w(M, "type") || "node";
1035
- if (!M || S !== "node" && S !== "asst") continue;
1036
- const v = Tt(l(M, "t"), { levels: [e.defaultText], bodyPr: [] }, i);
1037
- for (const I of v?.paragraphs ?? [])
1038
- I.runs.some((P) => !P.br && P.text.trim()) && u.push({
1039
- ...I,
1040
- align: "l",
1041
- level: m,
1042
- ...m > 0 ? { bullet: "char" } : {},
1043
- runs: I.runs.map((P) => ({ ...P, size: P.size ?? (m > 0 ? 16 : 18), bold: P.bold ?? (m === 0 ? !0 : void 0) }))
1044
- });
1045
- b(k.id, m + 1);
1046
- }
1047
- }
1048
- };
1049
- return b(w(h, "modelId") || "", 0), u.length ? (e.warnings.push(`SmartArt diagram "${a}" had no saved drawing; its text was imported as a list.`), {
1050
- kind: "shape",
1051
- id: r,
1052
- name: a,
1053
- ...o(s),
1054
- geom: { kind: "preset", prst: "rect" },
1055
- fill: { kind: "none" },
1056
- line: null,
1057
- textBox: !0,
1058
- text: { paragraphs: u, anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
1059
- }) : null;
1060
- }
1061
- function Jt(t, n, e) {
1062
- if (!t || e < 0) return null;
1063
- for (const o of ut(t)) {
1064
- if (o.localName === n) return o;
1065
- const s = Jt(o, n, e - 1);
1066
- if (s) return s;
1067
- }
1068
- return null;
1069
- }
1070
- function xt(t, n) {
1071
- const e = l(t, "bg");
1072
- if (!e) return;
1073
- const o = l(e, "bgPr");
1074
- if (o)
1075
- return V(o, n);
1076
- const s = l(e, "bgRef");
1077
- if (s) {
1078
- const r = C(s, "idx"), i = (r >= 1001 ? n.ctx.theme.bgFills : n.ctx.theme.fills)[r >= 1001 ? r - 1001 : r - 1];
1079
- return (i ? Ct(i, { ...n, ctx: { ...n.ctx, phClr: $(s, n.ctx) ?? void 0 } }) : void 0) ?? ($(s, n.ctx) ? { kind: "solid", color: $(s, n.ctx) } : void 0);
1080
- }
1081
- }
1082
- function Ge(t) {
1083
- const n = ut(t).find((a) => a.localName === "transition");
1084
- if (!n) return;
1085
- const e = R(n).find((a) => a.localName !== "sndAc" && a.localName !== "extLst");
1086
- if (!e) return;
1087
- const o = w(n, "spd"), s = w(n, "p14:dur") !== null ? C(n, "p14:dur") : o === "fast" ? 500 : o === "slow" ? 1e3 : 750, r = w(e, "dir");
1088
- switch (e.localName) {
1089
- case "push":
1090
- case "cover":
1091
- case "pull":
1092
- case "wipe":
1093
- return { kind: "push", dir: r === "r" || r === "u" || r === "d" ? r : "l", durationMs: s };
1094
- case "zoom":
1095
- return { kind: "zoom", zoomIn: r !== "out", durationMs: s };
1096
- case "cut":
1097
- return;
1098
- default:
1099
- return { kind: "fade", durationMs: s };
1100
- }
1101
- }
1102
- function Ve(t, n = {}) {
1103
- const e = [], o = (T) => {
1104
- e.length < 200 && !e.includes(T) && e.push(T);
1105
- }, s = n.parseXml ?? ((T) => new DOMParser().parseFromString(T, "application/xml"));
1106
- let r, a = 0, i = 0;
1107
- try {
1108
- r = ae(t, {
1109
- filter: (T) => (a++, i += T.originalSize, a <= Et && T.originalSize <= be && i <= At)
1110
- });
1111
- } catch {
1112
- throw new Error("This file is not a PowerPoint presentation (it is not a valid .pptx package).");
1113
- }
1114
- (a > Et || i > At) && o("The file is very large; some parts were skipped.");
1115
- const c = new Se(r, s, o), y = c.relOfType("", "officeDocument") ?? "ppt/presentation.xml", x = c.xml(y);
1116
- if (!x || x.localName !== "presentation") throw new Error("This file is not a PowerPoint presentation (no presentation part).");
1117
- const f = l(x, "sldSz"), g = f ? Math.max(1, L(C(f, "cx", 9144e3))) : 960, h = f ? Math.max(1, L(C(f, "cy", 5143500))) : 540, u = l(x, "defaultTextStyle"), p = c.rels(y), b = c.relOfType(y, "tableStyles"), d = b ? c.xml(b) : null, m = [], k = /* @__PURE__ */ new Set();
1118
- for (const T of R(l(x, "sldIdLst"), "sldId")) {
1119
- const O = p.get(w(T, "r:id") || "");
1120
- O && !k.has(O.target) && m.length < ye && (k.add(O.target), m.push(O.target));
1121
- }
1122
- const M = /* @__PURE__ */ new Map(), S = (T) => {
1123
- const O = c.relOfType(T, "theme");
1124
- return O ? (M.has(O) || M.set(O, pt(c.xml(O))), M.get(O)) : pt(null);
1125
- }, v = (T) => {
1126
- if (!T) return null;
1127
- const O = {};
1128
- for (let A = 0; A < T.attributes.length; A++) O[T.attributes[A].localName ?? T.attributes[A].name] = T.attributes[A].value;
1129
- return O;
1130
- }, I = [];
1131
- m.forEach((T, O) => {
1132
- const A = c.xml(T);
1133
- if (!A) {
1134
- o(`Slide ${O + 1} couldn't be read and was skipped.`);
1135
- return;
1136
- }
1137
- const N = c.relOfType(T, "slideLayout"), z = N ? c.xml(N) : null, D = N ? c.relOfType(N, "slideMaster") : null, W = D ? c.xml(D) : null, X = D ? S(D) : pt(null), dt = v(E(A, "clrMapOvr", "overrideClrMapping")) ?? v(E(z, "clrMapOvr", "overrideClrMapping")) ?? v(l(W, "clrMap")) ?? St, ot = { theme: X, clrMap: dt }, G = l(W, "txStyles"), F = {
1138
- pkg: c,
1139
- ctx: ot,
1140
- slide: { part: T, tree: E(A, "cSld", "spTree") },
1141
- layout: N ? { part: N, tree: E(z, "cSld", "spTree") } : null,
1142
- master: D ? { part: D, tree: E(W, "cSld", "spTree") } : null,
1143
- masterTx: { title: l(G, "titleStyle"), body: l(G, "bodyStyle"), other: l(G, "otherStyle") },
1144
- defaultText: u,
1145
- warnings: e,
1146
- count: 0,
1147
- tableStyles: d
1148
- }, ht = (re) => ({ pkg: c, part: re?.part ?? T, ctx: ot }), It = xt(l(A, "cSld"), ht(F.slide)) ?? xt(l(z, "cSld"), ht(F.layout)) ?? xt(l(W, "cSld"), ht(F.master)) ?? { kind: "solid", color: { hex: "#ffffff" } };
1149
- F.background = It;
1150
- const st = [], se = B(A, "showMasterSp") !== !1 && B(z, "showMasterSp") !== !1;
1151
- F.master && se && st.push(...et(F.master.tree, F.master, F, gt, 0, !1)), F.layout && B(A, "showMasterSp") !== !1 && st.push(...et(F.layout.tree, F.layout, F, gt, 0, !1)), st.push(...et(F.slide.tree, F.slide, F, gt, 0, !0)), I.push({ items: st, background: It, transition: Ge(A), name: w(l(A, "cSld"), "name") || void 0 });
1152
- }), I.length || o("The presentation has no slides.");
1153
- const P = E(c.xml("docProps/core.xml"), "title")?.textContent || void 0;
1154
- return { deck: { width: g, height: h, slides: I, title: P }, warnings: e };
1155
- }
1156
- const qe = 80, Ze = "default-layer", j = (t) => {
1157
- if (!t) return "transparent";
1158
- if (t.alpha === void 0 || t.alpha >= 0.999) return t.hex;
1159
- const n = t.hex.replace("#", "");
1160
- return `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${+t.alpha.toFixed(3)})`;
1161
- }, Ke = /(times|georgia|garamond|cambria|book|serif|palatino|baskerville|merriweather)/i, Qe = /(courier|consolas|mono|menlo|code)/i;
1162
- function Xt(t) {
1163
- if (!t) return "sans-serif";
1164
- const n = fe(t);
1165
- return n || (Qe.test(t) ? "monospace" : Ke.test(t) ? "serif" : "sans-serif");
1166
- }
1167
- function Je(t) {
1168
- const n = [];
1169
- let e = [], o = !1;
1170
- const s = () => {
1171
- if (e.length >= 2) {
1172
- const r = e[0], a = e[e.length - 1];
1173
- o && Math.hypot(r.x - a.x, r.y - a.y) < 1e-6 && (r.inX = a.inX, r.inY = a.inY, e.pop()), n.push({ anchors: e, closed: o });
1174
- }
1175
- e = [], o = !1;
1176
- };
1177
- for (const r of t)
1178
- if (r.op === "M")
1179
- s(), e.push({ x: r.x, y: r.y, kind: "corner" });
1180
- else if (r.op === "L")
1181
- e.length ? e.push({ x: r.x, y: r.y, kind: "corner" }) : e.push({ x: r.x, y: r.y, kind: "corner" });
1182
- else if (r.op === "C") {
1183
- const a = e[e.length - 1];
1184
- if (!a) {
1185
- e.push({ x: r.x, y: r.y, kind: "corner" });
1186
- continue;
1187
- }
1188
- a.outX = r.x1 - a.x, a.outY = r.y1 - a.y, e.push({ x: r.x, y: r.y, inX: r.x2 - r.x, inY: r.y2 - r.y, kind: "smooth" });
1189
- } else r.op === "Z" && (o = !0, s());
1190
- return s(), n;
1191
- }
1192
- const tn = (t, n, e) => t.map((o) => o.op === "Z" ? o : o.op === "C" ? { ...o, x1: o.x1 + n, y1: o.y1 + e, x2: o.x2 + n, y2: o.y2 + e, x: o.x + n, y: o.y + e } : { ...o, x: o.x + n, y: o.y + e });
1193
- async function en(t) {
1194
- if (!(typeof document > "u"))
1195
- try {
1196
- const n = new Image();
1197
- n.src = t, await n.decode();
1198
- const e = document.createElement("canvas");
1199
- e.width = Math.max(1, Math.min(8192, n.naturalWidth)), e.height = Math.max(1, Math.min(8192, n.naturalHeight));
1200
- const o = e.getContext("2d");
1201
- return o ? (o.filter = "grayscale(1)", o.drawImage(n, 0, 0, e.width, e.height), e.toDataURL(/^data:image\/jpeg/.test(t) ? "image/jpeg" : "image/png", 0.92)) : void 0;
1202
- } catch {
1203
- return;
1204
- }
1205
- }
1206
- async function nn(t, n) {
1207
- const e = /* @__PURE__ */ new Set(), o = (r) => {
1208
- for (const a of r)
1209
- if (a.kind === "group") o(a.children);
1210
- else if (a.kind === "picture" && a.grayscale) {
1211
- const i = n.get(a.media)?.url;
1212
- i && e.add(i);
1213
- } else if (a.kind === "shape" && a.fill.kind === "image" && a.fill.grayscale) {
1214
- const i = n.get(a.fill.media)?.url;
1215
- i && e.add(i);
1216
- }
1217
- };
1218
- t.slides.forEach((r) => o(r.items));
1219
- const s = /* @__PURE__ */ new Map();
1220
- return await Promise.all([...e].map(async (r) => {
1221
- const a = await en(r);
1222
- a && s.set(r, a);
1223
- })), s;
1224
- }
1225
- async function on(t, n, e, o) {
1226
- if (!(typeof document > "u"))
1227
- try {
1228
- const s = new Image();
1229
- s.src = t, await s.decode();
1230
- const r = document.createElement("canvas");
1231
- r.width = Math.max(1, Math.min(4096, Math.round(n))), r.height = Math.max(1, Math.min(4096, Math.round(e)));
1232
- const a = r.getContext("2d");
1233
- if (!a) return;
1234
- if (o) {
1235
- const i = a.createPattern(s, "repeat");
1236
- if (!i) return;
1237
- i.setTransform(new DOMMatrix().scale(o.sx, o.sy)), a.fillStyle = i, a.fillRect(0, 0, r.width, r.height);
1238
- } else {
1239
- if (Math.abs(s.naturalWidth / s.naturalHeight - n / e) < 0.01) return;
1240
- a.drawImage(s, 0, 0, r.width, r.height);
1241
- }
1242
- return r.toDataURL(o ? "image/png" : "image/jpeg", 0.92);
1243
- } catch {
1244
- return;
1245
- }
1246
- }
1247
- function q(t, n, e, o) {
1248
- return {
1249
- id: t.nextId(n),
1250
- type: n,
1251
- x: e.x + t.ox,
1252
- y: e.y + t.oy,
1253
- width: Math.max(e.w, 1),
1254
- height: Math.max(e.h, 1),
1255
- angle: e.rot ? e.rot * Math.PI / 180 : 0,
1256
- flipX: e.flipH || void 0,
1257
- flipY: e.flipV || void 0,
1258
- strokeColor: "transparent",
1259
- backgroundColor: "transparent",
1260
- fillStyle: "solid",
1261
- strokeWidth: 0,
1262
- strokeStyle: "solid",
1263
- roughness: 0,
1264
- renderStyle: "architectural",
1265
- opacity: 100,
1266
- seed: 1,
1267
- locked: !1,
1268
- layerId: Ze,
1269
- groupIds: [...o].reverse(),
1270
- // innermost first, the store's convention
1271
- name: e.name
1272
- };
1273
- }
1274
- function Ht(t, n, e) {
1275
- switch (n.kind) {
1276
- case "none":
1277
- t.backgroundColor = "transparent";
1278
- break;
1279
- case "solid":
1280
- t.backgroundColor = j(n.color), t.fillStyle = "solid";
1281
- break;
1282
- case "linear":
1283
- case "radial":
1284
- t.fillStyle = n.kind, t.backgroundColor = j(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: j(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1285
- break;
1286
- case "pattern": {
1287
- t.backgroundColor = j(n.color), t.fillStyle = "pattern", t.patternFill = mn(n.preset, j(n.color), n.bg ? j(n.bg) : "transparent");
1288
- break;
1289
- }
1290
- case "image": {
1291
- const o = e.images.get(n.media);
1292
- o && (t.fillStyle = "image", t.backgroundImage = n.grayscale && e.gray.get(o.url) || o.url, t.backgroundColor = "#ffffff"), o && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
1293
- break;
1294
- }
1295
- }
1296
- }
1297
- function kt(t, n) {
1298
- if (!n || !(n.width > 0)) {
1299
- t.strokeColor = "transparent", t.strokeWidth = 0;
1300
- return;
1301
- }
1302
- t.strokeColor = j(n.color), t.strokeWidth = Math.max(0.5, n.width), t.strokeStyle = n.dash === "sysDot" ? "dotted" : n.dash ? "dashed" : "solid", (n.join === "miter" || n.join === "bevel") && (t.strokeLineJoin = n.join), n.cap === "flat" ? t.strokeLineCap = "butt" : n.cap === "sq" && (t.strokeLineCap = "square");
1303
- }
1304
- function sn(t) {
1305
- const n = /^(alphaLc|alphaUc|arabic|romanLc|romanUc)(ParenBoth|ParenR|Period|Plain)$/.exec(t ?? "");
1306
- if (!n) return {};
1307
- const e = { alphaLc: "lower-alpha", alphaUc: "upper-alpha", romanLc: "lower-roman", romanUc: "upper-roman", arabic: void 0 }[n[1]], o = { ParenBoth: "parens", ParenR: "paren", Plain: "none", Period: void 0 }[n[2]], s = {};
1308
- return e && (s.listNumberStyle = e), o && (s.listNumberSuffix = o), s;
1309
- }
1310
- function rn(t, n) {
1311
- const e = t.bullet === "num" ? sn(t.numType) : t.bulletChar ? { listMarker: t.bulletChar } : {}, o = t.runs.find((s) => !s.br)?.color ?? n.defaults?.color;
1312
- return t.bulletColor && j(t.bulletColor) !== j(o) && (e.listMarkerColor = j(t.bulletColor)), t.bulletScale && (e.listMarkerScale = Math.round(t.bulletScale * 100) / 100), t.marL !== void 0 && (e.listIndent = Math.max(0, Math.round(t.marL * 10) / 10), e.listMarkerIndent = Math.max(0, Math.round((t.marL + (t.indent ?? 0)) * 10) / 10)), e;
1313
- }
1314
- const bt = (t, n) => Math.round(((t.paragraphs[n - 1]?.spaceAfter ?? 0) + (t.paragraphs[n]?.spaceBefore ?? 0)) * 100) / 100;
1315
- function te(t, n) {
1316
- const e = t.paragraphs.flatMap((p) => p.runs.filter((b) => !b.br)), o = e[0], s = o?.size ?? 24, r = /* @__PURE__ */ new Map(), a = (p) => p.runs.reduce((b, d) => b + (d.br ? 0 : d.text.trim().length), 0);
1317
- for (const p of t.paragraphs) {
1318
- const b = a(p);
1319
- b && r.set(p.align ?? "l", (r.get(p.align ?? "l") ?? 0) + b);
1320
- }
1321
- const i = [...r].sort((p, b) => b[1] - p[1])[0]?.[0] ?? t.paragraphs.find((p) => p.runs.length)?.align ?? "l", c = (p) => a(p) > 0 && (p.align ?? "l") !== i ? p.align === "ctr" ? "center" : p.align === "r" ? "right" : "left" : void 0, y = e.every((p) => p.size === o?.size && p.bold === o?.bold && p.italic === o?.italic && p.underline === o?.underline && p.strike === o?.strike && p.font === o?.font && j(p.color) === j(o?.color)) && !t.paragraphs.some((p) => p.bullet) && !t.paragraphs.some((p, b) => b > 0 && bt(t, b) > 0) && !t.paragraphs.some(c), x = {
1322
- fontSize: Math.round(s * 10) / 10,
1323
- fontFamily: Xt(o?.font),
1324
- textAlign: i === "ctr" ? "center" : i === "r" ? "right" : "left",
1325
- verticalAlign: t.anchor === "ctr" ? "middle" : t.anchor === "b" ? "bottom" : "top",
1326
- textColor: j(o?.color ?? { hex: "#000000" })
1327
- };
1328
- t.lineSpacing && Math.abs(t.lineSpacing - 1) > 0.01 && (x.lineHeight = Math.max(0.5, Math.min(4, t.lineSpacing * 1.2)));
1329
- const f = t.paragraphs.map((p) => p.runs.map((b) => b.br ? `
1330
- ` : b.text).join("")).join(`
1331
- `);
1332
- if (y)
1333
- return o?.bold && (x.fontWeight = 700), o?.italic && (x.fontStyle = "italic"), n ? x.containerText = f : x.text = f, { fields: x, rich: !1 };
1334
- const g = [], h = [], u = [];
1335
- return t.paragraphs.forEach((p, b) => {
1336
- const d = p.level ?? 0;
1337
- if (p.bullet === "num") {
1338
- const M = p.numType ?? "arabicPeriod";
1339
- (h[d] === void 0 || u[d] !== M) && (h[d] = (p.startAt ?? 1) - 1), h[d]++, u[d] = M, h.length = d + 1, u.length = d + 1;
1340
- } else
1341
- h.length = Math.min(h.length, d), u.length = h.length;
1342
- const m = p.bullet ? { listType: p.bullet === "num" ? "ordered" : "bullet", listLevel: d, ...rn(p, t) } : {};
1343
- p.bullet === "num" && (m.listIndex = h[d]), (p.runs.length ? p.runs : [{ text: "" }]).forEach((M, S) => {
1344
- const v = { text: M.br ? `
1345
- ` : M.text, ...S === 0 ? m : {} };
1346
- S === 0 && b > 0 && bt(t, b) > 0 && (v.paragraphSpaceBefore = bt(t, b));
1347
- const I = c(p);
1348
- I && (v.paragraphAlign = I), M.bold && (v.bold = !0), M.italic && (v.italic = !0), M.underline && (v.underline = !0), M.strike && (v.strikethrough = !0), M.color && (v.color = j(M.color)), M.size && (v.fontSize = Math.round(M.size * 10) / 10), M.font && (v.fontFamily = Xt(M.font)), g.push(v);
1349
- }), b < t.paragraphs.length - 1 && g.push({ text: `
1350
- ` });
1351
- }), n ? (x.richContainerText = g, x.containerText = f) : (x.richText = g, x.text = f), { fields: x, rich: !0 };
1352
- }
1353
- function yt(t, n, e, o, s) {
1354
- const { fields: r, rich: a } = te(n, !1), i = 4, c = q(t, a ? "richtext" : "text", {
1355
- ...e,
1356
- x: e.x + n.insets.l - i,
1357
- y: e.y + n.insets.t - i,
1358
- w: Math.max(e.w - n.insets.l - n.insets.r + i * 2, 8),
1359
- h: Math.max(e.h - n.insets.t - n.insets.b + i * 2, 8)
1360
- }, o);
1361
- return Object.assign(c, r, { autoResize: !n.wrap, strokeColor: r.textColor }), c;
1362
- }
1363
- const ee = /* @__PURE__ */ new Set(["line", "straightConnector1"]);
1364
- function ne(t, n, e) {
1365
- const o = t.geom;
1366
- if (t.text && t.fill.kind === "none" && !t.line && (t.textBox || o.kind === "preset" && o.prst === "rect"))
1367
- return n.stats.elements++, [yt(n, t.text, t, e)];
1368
- if (o.kind === "preset" && ee.has(o.prst)) return wt({ ...t, kind: "connector", line: t.line ?? { width: 1, color: { hex: "#000000" } } }, n, e);
1369
- if (o.kind === "custom" && t.line && (t.line.head || t.line.tail) && !t.text && o.paths.every((f) => !f.cmds.some((g) => g.op === "Z")))
1370
- return wt({ ...t, kind: "connector", line: t.line }, n, e);
1371
- const s = ln(t);
1372
- if (s) {
1373
- const f = q(n, s.type, t, e);
1374
- Object.assign(f, s.extra), Ht(f, t.fill, n), kt(f, t.line), n.byPptId.set(t.id, { el: f, item: t }), n.stats.elements++;
1375
- const g = t.textRect ?? { l: 0, t: 0, r: t.w, b: t.h }, h = t.text?.insets, u = Math.abs(g.l) > 0.5 || Math.abs(g.t) > 0.5 || Math.abs(g.r - t.w) > 0.5 || Math.abs(g.b - t.h) > 0.5, p = !!h && Math.max(h.l, h.r, h.t, h.b) > 16;
1376
- if (t.text && (u || p)) {
1377
- const b = n.nextId("group");
1378
- return f.groupIds = [...e, b].reverse(), n.stats.elements++, [f, yt(n, t.text, { ...t, rot: 0, x: t.x + g.l, y: t.y + g.t, w: g.r - g.l, h: g.b - g.t }, [...e, b])];
1379
- }
1380
- if (t.text) {
1381
- const { fields: b } = te(t.text, !0);
1382
- Object.assign(f, b);
1383
- }
1384
- return [f];
1385
- }
1386
- const r = o.kind === "custom" ? o.paths : (() => {
1387
- const f = n.presets[o.prst];
1388
- if (!f)
1389
- return n.warnings.push(`Unknown shape "${o.prst}" was imported as a rectangle.`), it(n.presets.rect, t.w, t.h);
1390
- const g = Object.fromEntries(Object.entries(o.adj ?? {}).map(([h, u]) => [h, `val ${u}`]));
1391
- return it(f, t.w, t.h, g);
1392
- })(), a = [], i = (t.text || r.some((f) => f.fill === !1)) && r.some((f) => f.fill !== !1) ? n.nextId("group") : null, c = i ? [...e, i] : e, y = /* @__PURE__ */ new Map();
1393
- for (const f of r) {
1394
- const g = `${f.fill === !1 ? "nofill" : "fill"}|${f.stroke === !1 ? "nostroke" : "stroke"}`;
1395
- y.has(g) || y.set(g, []), y.get(g).push(f);
1396
- }
1397
- let x = null;
1398
- for (const [f, g] of y) {
1399
- const h = g.flatMap((m) => m.cmds), u = le(h);
1400
- if (!u) continue;
1401
- const p = Je(tn(h, -u.minX, -u.minY));
1402
- if (!p.length) continue;
1403
- const b = q(n, "path", { ...t, x: t.x + u.minX, y: t.y + u.minY, w: Math.max(u.maxX - u.minX, 1), h: Math.max(u.maxY - u.minY, 1) }, c);
1404
- !(Math.abs(u.minX + u.maxX - t.w) < 0.5 && Math.abs(u.minY + u.maxY - t.h) < 0.5) && (t.rot || t.flipH || t.flipV) && an(b, p, t, u), b.pathSubpaths = p, b.pathAnchors = p[0].anchors, b.pathClosed = p[0].closed, f.startsWith("fill") ? Ht(b, t.fill, n) : b.backgroundColor = "transparent", f.endsWith("|stroke") ? kt(b, t.line) : (b.strokeColor = "transparent", b.strokeWidth = 0), a.push(b), x ??= b, n.stats.paths++;
1405
- }
1406
- if (x && n.byPptId.set(t.id, { el: x, item: t }), t.text) {
1407
- const f = t.textRect ?? (o.kind === "preset" && n.presets[o.prst] ? Ut(n.presets[o.prst], t.w, t.h) : { l: 0, t: 0, r: t.w, b: t.h });
1408
- a.push(yt(n, t.text, { ...t, x: t.x + f.l, y: t.y + f.t, w: f.r - f.l, h: f.b - f.t }, c));
1409
- }
1410
- return n.stats.elements += a.length, a;
1411
- }
1412
- function an(t, n, e, o) {
1413
- const s = e.w / 2, r = e.h / 2, a = (e.rot || 0) * Math.PI / 180, i = Math.cos(a), c = Math.sin(a), y = e.flipH ? -1 : 1, x = e.flipV ? -1 : 1, f = (d, m) => {
1414
- const k = (d + o.minX - s) * y, M = (m + o.minY - r) * x;
1415
- return { x: s + k * i - M * c, y: r + k * c + M * i };
1416
- }, g = (d, m) => {
1417
- const k = d * y, M = m * x;
1418
- return { x: k * i - M * c, y: k * c + M * i };
1419
- };
1420
- let h = 1 / 0, u = 1 / 0, p = -1 / 0, b = -1 / 0;
1421
- for (const d of n) for (const m of d.anchors) {
1422
- const k = f(m.x, m.y);
1423
- if (m.x = k.x, m.y = k.y, m.inX !== void 0) {
1424
- const M = g(m.inX, m.inY ?? 0);
1425
- m.inX = M.x, m.inY = M.y;
1426
- }
1427
- if (m.outX !== void 0) {
1428
- const M = g(m.outX, m.outY ?? 0);
1429
- m.outX = M.x, m.outY = M.y;
1430
- }
1431
- h = Math.min(h, m.x), u = Math.min(u, m.y), p = Math.max(p, m.x), b = Math.max(b, m.y);
1432
- }
1433
- for (const d of n) for (const m of d.anchors)
1434
- m.x -= h, m.y -= u;
1435
- t.x = t.x - o.minX + h, t.y = t.y - o.minY + u, t.width = Math.max(p - h, 1), t.height = Math.max(b - u, 1), t.angle = 0, t.flipX = void 0, t.flipY = void 0;
1436
- }
1437
- function ln(t) {
1438
- const n = t.geom;
1439
- if (n.kind !== "preset") return null;
1440
- const e = n.adj ?? {};
1441
- switch (n.prst) {
1442
- case "rect":
1443
- return { type: "rectangle", extra: { borderRadius: 0 } };
1444
- case "roundRect":
1445
- return { type: "rectangle", extra: { borderRadius: Math.max(0, Math.min(50, (e.adj ?? 16667) / 1e3)) } };
1446
- case "ellipse":
1447
- return { type: "circle", extra: {} };
1448
- case "diamond":
1449
- return { type: "diamond", extra: { borderRadius: 0 } };
1450
- case "triangle":
1451
- return (e.adj ?? 5e4) === 5e4 ? { type: "triangle", extra: {} } : null;
1452
- default:
1453
- return null;
1454
- }
1455
- }
1456
- const Yt = { triangle: "triangle", stealth: "arrow", arrow: "arrow", oval: "dot", diamond: "diamondFilled" };
1457
- function wt(t, n, e) {
1458
- const o = t.geom;
1459
- let s;
1460
- if (o.kind === "preset" && ee.has(o.prst)) s = [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1461
- else if (o.kind === "custom") s = o.paths.flatMap((k) => k.cmds);
1462
- else {
1463
- const k = n.presets[o.prst], M = Object.fromEntries(Object.entries(o.adj ?? {}).map(([S, v]) => [S, `val ${v}`]));
1464
- s = k ? it(k, t.w, t.h, M).flatMap((S) => S.cmds) : [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1465
- }
1466
- const r = t.w / 2, a = t.h / 2, i = (t.rot || 0) * Math.PI / 180, c = (k, M) => {
1467
- let S = k - r, v = M - a;
1468
- return t.flipH && (S = -S), t.flipV && (v = -v), { x: t.x + r + S * Math.cos(i) - v * Math.sin(i), y: t.y + a + S * Math.sin(i) + v * Math.cos(i) };
1469
- }, y = [];
1470
- let x = { x: 0, y: 0 };
1471
- for (const k of s)
1472
- if (k.op === "M" || k.op === "L")
1473
- x = { x: k.x, y: k.y }, y.push(c(x.x, x.y));
1474
- else if (k.op === "C") {
1475
- for (let M = 1; M <= 12; M++) {
1476
- const S = M / 12, v = 1 - S, I = v * v * v * x.x + 3 * v * v * S * k.x1 + 3 * v * S * S * k.x2 + S * S * S * k.x, P = v * v * v * x.y + 3 * v * v * S * k.y1 + 3 * v * S * S * k.y2 + S * S * S * k.y;
1477
- y.push(c(I, P));
1478
- }
1479
- x = { x: k.x, y: k.y };
1480
- }
1481
- if (y.length < 2) return [];
1482
- const f = Math.min(...y.map((k) => k.x)), g = Math.min(...y.map((k) => k.y)), h = Math.max(...y.map((k) => k.x)), u = Math.max(...y.map((k) => k.y)), p = t.line.head && Yt[t.line.head.type], b = t.line.tail && Yt[t.line.tail.type], d = q(n, p || b ? "arrow" : "line", { ...t, x: f, y: g, w: Math.max(h - f, 1), h: Math.max(u - g, 1), rot: 0, flipH: !1, flipV: !1 }, e);
1483
- d.points = y.map((k) => ({ x: k.x - f, y: k.y - g })), d.curveType = "straight", d.startArrowhead = p ?? null, d.endArrowhead = b ?? null, kt(d, t.line);
1484
- const m = (k, M) => {
1485
- if (!k) return null;
1486
- const S = n.byPptId.get(k.id);
1487
- if (!S || !S.el.width || !S.el.height) return null;
1488
- const v = S.el;
1489
- return { elementId: v.id, focus: 0, gap: 0, anchorFractionX: (M.x + n.ox - v.x) / v.width, anchorFractionY: (M.y + n.oy - v.y) / v.height };
1490
- };
1491
- return n.glue.push(() => {
1492
- d.startBinding = m(t.start, y[0]), d.endBinding = m(t.end, y[y.length - 1]);
1493
- }), n.stats.elements++, [d];
1494
- }
1495
- function cn(t, n, e) {
1496
- const o = n.images.get(t.media);
1497
- if (!o) {
1498
- n.warnings.push(`Picture "${t.name}" is a ${t.media.ext.toUpperCase()} image, which browsers can't show; it was imported as a placeholder.`);
1499
- const c = q(n, "rectangle", t, e);
1500
- return Object.assign(c, { backgroundColor: "#f1f3f5", strokeColor: "#adb5bd", strokeWidth: 1, strokeStyle: "dashed", containerText: `${t.media.ext.toUpperCase()} picture`, fontSize: 14, textColor: "#495057" }), n.stats.elements++, [c];
1501
- }
1502
- const s = q(n, "image", t, e);
1503
- if (s.dataURL = t.grayscale && n.gray.get(o.url) || o.url, s.status = "loaded", s.mimeType = Mt[t.media.ext], t.crop && (t.crop.l || t.crop.t || t.crop.r || t.crop.b) && (s.crop = { x: t.crop.l * o.w, y: t.crop.t * o.h, width: Math.max(1, (1 - t.crop.l - t.crop.r) * o.w), height: Math.max(1, (1 - t.crop.t - t.crop.b) * o.h) }), t.alpha !== void 0 && t.alpha < 1 && (s.opacity = Math.round(t.alpha * 100)), t.descr && (s.altText = t.descr), n.stats.elements++, n.stats.pictures++, !t.geom) return [s];
1504
- const r = n.nextId("group"), a = ne({
1505
- kind: "shape",
1506
- id: t.id,
1507
- name: `${t.name} outline`,
1508
- x: t.x,
1509
- y: t.y,
1510
- w: t.w,
1511
- h: t.h,
1512
- rot: t.rot,
1513
- flipH: t.flipH,
1514
- flipV: t.flipV,
1515
- geom: t.geom,
1516
- fill: { kind: "solid", color: { hex: "#000000" } },
1517
- line: null
1518
- }, n, [...e, r]);
1519
- if (a.length !== 1)
1520
- return n.stats.elements -= a.length, [s];
1521
- const i = a[0];
1522
- return i.isClipMask = !0, s.groupIds = [r, ...s.groupIds], s.clipMaskId = i.id, s.maskType = "clip", [s, i];
1523
- }
1524
- function oe(t, n, e) {
1525
- const o = [];
1526
- for (const s of t)
1527
- try {
1528
- switch (s.kind) {
1529
- case "shape":
1530
- o.push(...ne(s, n, e));
1531
- break;
1532
- case "connector":
1533
- o.push(...wt(s, n, e));
1534
- break;
1535
- case "picture":
1536
- o.push(...cn(s, n, e));
1537
- break;
1538
- case "group":
1539
- o.push(...oe(s.children, n, [...e, n.nextId("group")]));
1540
- break;
1541
- }
1542
- } catch {
1543
- n.warnings.push(`"${s.name}" couldn't be converted and was skipped.`);
1544
- }
1545
- return o;
1546
- }
1547
- function fn(t) {
1548
- return t ? { type: t.kind === "fade" ? "fade" : t.kind === "zoom" ? t.zoomIn === !1 ? "zoom-out" : "zoom-in" : t.dir === "r" ? "slide-right" : t.dir === "u" ? "slide-up" : t.dir === "d" ? "slide-down" : "slide-left", duration: Math.max(100, Math.min(5e3, t.durationMs)), easing: "easeInOutQuad" } : void 0;
1549
- }
1550
- function un(t, n, e) {
1551
- if (n)
1552
- if (n.kind === "solid")
1553
- t.fillStyle = "solid", t.backgroundColor = j(n.color);
1554
- else if (n.kind === "linear" || n.kind === "radial")
1555
- t.fillStyle = n.kind, t.backgroundColor = j(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: j(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1556
- else if (n.kind === "image") {
1557
- const o = e.images.get(n.media), s = e.slideBg ?? o?.url;
1558
- s && (t.fillStyle = "image", t.backgroundImage = s, t.backgroundColor = "#ffffff"), s && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
1559
- } else n.kind === "pattern" && (t.fillStyle = "solid", t.backgroundColor = j(n.color));
1560
- }
1561
- const Mt = {
1562
- png: "image/png",
1563
- jpeg: "image/jpeg",
1564
- gif: "image/gif",
1565
- svg: "image/svg+xml",
1566
- bmp: "image/bmp",
1567
- tiff: "image/tiff",
1568
- webp: "image/webp",
1569
- emf: "image/x-emf",
1570
- wmf: "image/x-wmf"
1571
- }, dn = /* @__PURE__ */ new Set(["png", "jpeg", "gif", "svg", "bmp", "webp"]);
1572
- function hn(t) {
1573
- let n = "";
1574
- for (let o = 0; o < t.length; o += 32768) n += String.fromCharCode(...t.subarray(o, o + 32768));
1575
- return btoa(n);
1576
- }
1577
- async function pn(t) {
1578
- const n = /* @__PURE__ */ new Set(), e = (s) => {
1579
- for (const r of s)
1580
- r.kind === "picture" ? n.add(r.media) : r.kind === "group" ? e(r.children) : r.kind === "shape" && r.fill.kind === "image" && n.add(r.fill.media);
1581
- };
1582
- for (const s of t.slides)
1583
- e(s.items), s.background?.kind === "image" && n.add(s.background.media);
1584
- const o = /* @__PURE__ */ new Map();
1585
- return await Promise.all([...n].map(async (s) => {
1586
- if (!dn.has(s.ext)) {
1587
- o.set(s, null);
1588
- return;
1589
- }
1590
- const r = `data:${Mt[s.ext]};base64,${hn(s.bytes)}`;
1591
- let a = 0, i = 0;
1592
- try {
1593
- const c = await createImageBitmap(new Blob([s.bytes], { type: Mt[s.ext] }));
1594
- a = c.width, i = c.height, c.close();
1595
- } catch {
1596
- }
1597
- o.set(s, { url: r, w: a, h: i });
1598
- })), o;
1599
- }
1600
- function mn(t, n, e) {
1601
- const o = /^(nar|sm)/.test(t) ? 4 : /^(wd|lg)/.test(t) ? 12 : 8, s = /^dk/.test(t) ? 3 : /^lt/.test(t) ? 1 : /^(wd)/.test(t) ? 3 : 1.5, r = { color: n, background: e, spacing: o, strokeWidth: s }, a = /^pct(\d+)$/.exec(t);
1602
- if (a) {
1603
- const i = Math.max(1, Math.min(99, Number(a[1]))), c = i > 50, y = (c ? 100 - i : i) / 100;
1604
- return { type: "dots", color: c ? e : n, background: c ? n : e, spacing: 4, strokeWidth: Math.max(0.5, 4 * Math.sqrt(y / Math.PI)) };
1605
- }
1606
- return /Horz$|^horz|Brick$|^shingle$|^wave$|^zigZag$/.test(t) ? { type: "stripes", ...r, angle: 0 } : /Vert$|^vert$/.test(t) ? { type: "stripes", ...r, angle: 90 } : /DnDiag$|^dnDiag$/.test(t) ? { type: "stripes", ...r, angle: 45 } : /UpDiag$|^upDiag$/.test(t) ? { type: "stripes", ...r, angle: -45 } : /^(diagCross|trellis|openDmnd|weave)$/.test(t) ? { type: "crosshatch", ...r } : /Check$|^solidDmnd$/.test(t) ? { type: "checker", ...r, angle: t === "solidDmnd" ? 45 : 0 } : /^(cross|smGrid|lgGrid|dotGrid|plaid)$/.test(t) ? { type: "grid", ...r } : { type: "dots", ...r, strokeWidth: 1 };
1607
- }
1608
- async function gn(t, n, e) {
1609
- const o = await xe(), s = await pn(t), r = Math.round(t.width), a = Math.round(t.height), i = ce(e ?? t.title, "slides", { width: r, height: a }), c = [], y = { slides: 0, elements: 0, pictures: 0, paths: 0 };
1610
- i.slides = [];
1611
- const x = await nn(t, s), f = await Promise.all(t.slides.map((g) => {
1612
- const h = g.background, u = h?.kind === "image" ? s.get(h.media) : void 0;
1613
- return h?.kind === "image" && u ? on(u.url, r, a, h.tile) : void 0;
1614
- }));
1615
- return t.slides.forEach((g, h) => {
1616
- const u = h * (r + qe), p = Rt(void 0, g.name || `Slide ${h + 1}`, u, 0, { width: r, height: a });
1617
- p.order = h;
1618
- const b = { ox: u, oy: 0, presets: o, nextId: n, out: [], byPptId: /* @__PURE__ */ new Map(), glue: [], warnings: c, stats: y, images: s, slideBg: f[h], gray: x };
1619
- i.elements.push(...oe(g.items, b, [])), b.glue.forEach((m) => m()), un(p, g.background, b);
1620
- const d = fn(g.transition);
1621
- d && (p.transition = d), i.slides.push(p), y.slides++;
1622
- }), i.slides.length || i.slides.push(Rt(void 0, "Slide 1", 0, 0, { width: r, height: a })), { doc: i, warnings: [...new Set(c)], stats: y };
1623
- }
1624
- const xn = 512 * 1024 * 1024;
1625
- async function wn(t, n) {
1626
- const e = t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(await t.arrayBuffer());
1627
- if (e.length > xn) throw new Error("This presentation is too large to open (over 512 MB).");
1628
- const { deck: o, warnings: s } = Ve(e), r = /* @__PURE__ */ new Set(), a = await gn(o, (c) => de(c, r), n);
1629
- ue(a.doc);
1630
- const i = [...s, ...a.warnings];
1631
- return i.length && console.warn("[pptx import]", i), { stats: a.stats, warnings: i };
1632
- }
1633
- export {
1634
- wn as importPptx
1635
- };