@algorisys/yappydraw 0.8.296 → 0.8.298

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 (29) hide show
  1. package/README.md +2 -2
  2. package/chunks/anim-map-D7T1mIAM.js +111 -0
  3. package/chunks/{canva-ai-CkUlVY-Y.js → canva-ai-wYv31lWm.js} +1 -1
  4. package/chunks/{choice-dialog-state-BUFvjtpq.js → choice-dialog-state-DqR_5IIZ.js} +1 -1
  5. package/chunks/{custgeom-DThQ1Qnp.js → custgeom-DUHYX5Vs.js} +28 -26
  6. package/chunks/{design-generator-BlrBbMDM.js → design-generator-DGqLbsqR.js} +1 -1
  7. package/chunks/{drawing-engine-KJLwmUE-.js → drawing-engine-BCPX1hm_.js} +1 -1
  8. package/chunks/{drawings-store-CiDEeh5h.js → drawings-store-BJW1Dmw_.js} +1 -1
  9. package/chunks/{ds-operations-C27tW9qb.js → ds-operations-Bi7WKGwN.js} +1 -1
  10. package/chunks/{export-game-Bcz0A67O.js → export-game-BkUpm1R8.js} +1 -1
  11. package/chunks/{from-yappy-lL1q0m9y.js → from-yappy-fz7AULvS.js} +327 -295
  12. package/chunks/{game-runtime-RZ6Ygr7N.js → game-runtime-Bng0zlkA.js} +40 -40
  13. package/chunks/import-BvGSYTzL.js +1895 -0
  14. package/chunks/{index-NbpsufU1.js → index-Bqlr2FLr.js} +9405 -9245
  15. package/chunks/{lucide-solid-DL_MnmQm.js → lucide-solid-Db2bPSrx.js} +1 -1
  16. package/chunks/{markdown-to-slides-D9CoIzTi.js → markdown-to-slides-D1OVYcQV.js} +1 -1
  17. package/chunks/{morph-animator-C_rDbafN.js → morph-animator-DCs2sEkC.js} +1 -1
  18. package/chunks/{onboarding-tour-B1fDeTqe.js → onboarding-tour-DoZ9Sivk.js} +1 -1
  19. package/chunks/{pdf-vector-ByOSpRwK.js → pdf-vector-DTgEkBKW.js} +1 -1
  20. package/chunks/{search-MWY5OrgG.js → search-4gFkAhbD.js} +9 -9
  21. package/chunks/{slide-generator-8-amet_R.js → slide-generator-D1fy8u8B.js} +1 -1
  22. package/chunks/{turntable-ai-DgSAtAc8.js → turntable-ai-C1B4jzNc.js} +1 -1
  23. package/chunks/write-DDXhxpu-.js +408 -0
  24. package/chunks/yappy-Btkc8ueG.css +1 -0
  25. package/package.json +1 -1
  26. package/yappy.js +1 -1
  27. package/chunks/import-DFZ1uZOp.js +0 -1736
  28. package/chunks/write-B1-j7TNq.js +0 -265
  29. package/chunks/yappy-CvwwkLs8.css +0 -1
@@ -1,1736 +0,0 @@
1
- import { u as fe, a as de } from "./browser-DbZP-BrN.js";
2
- import { E as z, i as Ct, g as ue } from "./custgeom-DThQ1Qnp.js";
3
- import { aq as he, ar as Lt, as as pe, at as me, M as ge, q as xe, K as be } from "./index-NbpsufU1.js";
4
- const ye = 1e4, ke = 1e5, qt = 6e4, nt = (t) => t / qt * (Math.PI / 180);
5
- function Zt(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), l = Math.max(r, a), g = {
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: l,
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 [m, x] of Object.entries(g)) s.set(m, x);
26
- for (const m of [2, 3, 4, 5, 6, 8, 10, 12, 16, 32])
27
- s.set(`wd${m}`, r / m), s.set(`hd${m}`, a / m), s.set(`ssd${m}`, i / m);
28
- const b = (m) => {
29
- const x = s.get(m);
30
- if (x !== void 0) return x;
31
- const f = /^(wd|hd|ssd)(\d+)$/.exec(m);
32
- if (f) {
33
- const y = f[1] === "wd" ? r : f[1] === "hd" ? a : i, u = Number(f[2]);
34
- return u ? y / u : 0;
35
- }
36
- const h = Number(m);
37
- return Number.isFinite(h) ? h : 0;
38
- }, d = (m, x) => {
39
- s.size > ye || s.set(m, we(x, b));
40
- };
41
- for (const [m, x] of t.av ?? []) d(m, o[m] ?? x);
42
- for (const [m, x] of Object.entries(o)) s.has(m) || d(m, x);
43
- for (const [m, x] of t.gd ?? []) d(m, x);
44
- return s;
45
- }
46
- function we(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 * qt;
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(nt(r));
79
- break;
80
- case "sin":
81
- i = s * Math.sin(nt(r));
82
- break;
83
- case "tan":
84
- i = s * Math.tan(nt(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 Et = (t, n, e) => Math.atan2(n * Math.sin(t), e * Math.cos(t));
107
- function ft(t, n, e, o = {}) {
108
- const s = Math.max(Math.abs(n), 0) * z, r = Math.max(Math.abs(e), 0) * z, a = Zt(t, s, r, o), i = (b) => typeof b == "number" ? b : a.get(b) ?? (Number.isFinite(Number(b)) ? Number(b) : 0), l = [];
109
- let g = ke;
110
- for (const b of t.paths) {
111
- const d = b.w ? s / b.w : 1, m = b.h ? r / b.h : 1, x = (p) => i(p) * d / z, f = (p) => i(p) * m / z, h = [];
112
- let y = { x: 0, y: 0 }, u = { x: 0, y: 0 };
113
- for (const p of b.d) {
114
- if (--g < 0) break;
115
- switch (p[0]) {
116
- case "M":
117
- y = { x: x(p[1]), y: f(p[2]) }, u = y, h.push({ op: "M", ...y });
118
- break;
119
- case "L":
120
- y = { x: x(p[1]), y: f(p[2]) }, h.push({ op: "L", ...y });
121
- break;
122
- case "C": {
123
- const w = x(p[1]), M = f(p[2]), S = x(p[3]), v = f(p[4]);
124
- y = { x: x(p[5]), y: f(p[6]) }, h.push({ op: "C", x1: w, y1: M, x2: S, y2: v, ...y });
125
- break;
126
- }
127
- case "Q": {
128
- const w = x(p[1]), M = f(p[2]), S = x(p[3]), v = f(p[4]);
129
- h.push({ op: "C", x1: y.x + 2 / 3 * (w - y.x), y1: y.y + 2 / 3 * (M - y.y), x2: S + 2 / 3 * (w - S), y2: v + 2 / 3 * (M - v), x: S, y: v }), y = { x: S, y: v };
130
- break;
131
- }
132
- case "A": {
133
- const w = i(p[1]) * d / z, M = i(p[2]) * m / z;
134
- y = Me(h, y, w, M, i(p[3]), i(p[4]));
135
- break;
136
- }
137
- case "Z":
138
- h.push({ op: "Z" }), y = u;
139
- break;
140
- }
141
- }
142
- h.length && l.push({ cmds: h, fill: b.fill === "none" ? !1 : void 0, stroke: b.stroke === !1 ? !1 : void 0 });
143
- }
144
- return l;
145
- }
146
- function Me(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 = nt(s), i = Math.max(-4 * Math.PI, Math.min(4 * Math.PI, nt(r))), l = Et(a, e, o);
149
- let g = Et(a + i, e, o);
150
- if (Math.abs(i) >= 2 * Math.PI - 1e-9) g = l + Math.sign(i) * 2 * Math.PI;
151
- else {
152
- for (; i > 0 && g < l; ) g += 2 * Math.PI;
153
- for (; i < 0 && g > l; ) g -= 2 * Math.PI;
154
- }
155
- const b = n.x - e * Math.cos(l), d = n.y - o * Math.sin(l), m = g - l, x = Math.max(1, Math.min(16, Math.ceil(Math.abs(m) / (Math.PI / 2)))), f = m / x, h = 4 / 3 * Math.tan(f / 4);
156
- let y = l, u = n;
157
- for (let p = 0; p < x; p++) {
158
- const w = y + f, M = Math.cos(y), S = Math.sin(y), v = Math.cos(w), N = Math.sin(w);
159
- u = { x: b + e * v, y: d + o * N }, t.push({ op: "C", x1: b + e * (M - h * S), y1: d + o * (S + h * M), x2: b + e * (v + h * N), y2: d + o * (N - h * v), ...u }), y = w;
160
- }
161
- return u;
162
- }
163
- function Kt(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 = Zt(t, s * z, r * z, o), i = (m) => (a.get(m) ?? (Number.isFinite(Number(m)) ? Number(m) : 0)) / z, [l, g, b, d] = t.rect.map(i);
167
- return { l, t: g, r: b, b: d };
168
- }
169
- let Ft = null;
170
- async function ve() {
171
- return Ft ??= (await import("./presets-DP49P8i2.js")).default, Ft;
172
- }
173
- const jt = 5e4, Se = 256 * 1024 * 1024, Dt = 1024 * 1024 * 1024, Ce = 1e4, Pe = 32, Te = 2e4, I = (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
- }, c = (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
- }, A = (t, ...n) => {
184
- let e = t;
185
- for (const o of n) e = c(e, o);
186
- return e ?? null;
187
- }, k = (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 = k(t, n), s = o === null ? NaN : Number(o);
199
- return Number.isFinite(s) ? s : e;
200
- }, B = (t, n) => {
201
- const e = k(t, n);
202
- return e === null ? void 0 : e === "1" || e === "true" || e === "on";
203
- }, E = (t) => t / z, Ie = /* @__PURE__ */ new Set(["p14", "a14", "a16"]);
204
- function Ne(t) {
205
- if (t.localName !== "AlternateContent") return [t];
206
- const n = c(t, "Fallback");
207
- for (const e of I(t, "Choice"))
208
- if ((k(e, "Requires") || "").split(/\s+/).filter(Boolean).every((s) => Ie.has(s))) return I(e);
209
- return I(n);
210
- }
211
- const J = (t) => I(t).flatMap(Ne);
212
- class Oe {
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[et(s)] = r;
221
- }
222
- bytes(n) {
223
- return this.files[et(n)];
224
- }
225
- xml(n) {
226
- const e = et(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 = de(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 = et(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 I(a, "Relationship")) {
250
- const l = k(i, "Id"), g = k(i, "Type") || "", b = k(i, "Target") || "";
251
- if (!l) continue;
252
- const d = k(i, "TargetMode") === "External";
253
- o.set(l, { type: g.slice(g.lastIndexOf("/") + 1), target: d ? b : Ae(s, b), external: d });
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 et = (t) => t.replace(/\\/g, "/").replace(/^\/+/, "");
263
- function Ae(t, n) {
264
- let e = n.split("#")[0];
265
- try {
266
- e = decodeURIComponent(e);
267
- } catch {
268
- }
269
- if (e.startsWith("/")) return et(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 Pt = { bg1: "lt1", tx1: "dk1", bg2: "lt2", tx2: "dk2" };
276
- function gt(t) {
277
- const n = { colors: {}, major: "Calibri Light", minor: "Calibri", fills: [], lines: [], bgFills: [] }, e = c(t, "themeElements");
278
- for (const r of I(c(e, "clrScheme"))) {
279
- const a = I(r)[0];
280
- if (!a) continue;
281
- const i = a.localName === "sysClr" ? k(a, "lastClr") : k(a, "val");
282
- i && /^[0-9a-f]{6}$/i.test(i) && (n.colors[r.localName] = "#" + i.toLowerCase());
283
- }
284
- const o = c(e, "fontScheme");
285
- n.major = k(A(o, "majorFont", "latin"), "typeface") || n.major, n.minor = k(A(o, "minorFont", "latin"), "typeface") || n.minor;
286
- const s = c(e, "fmtScheme");
287
- return n.fills = I(c(s, "fillStyleLst")), n.lines = I(c(s, "lnStyleLst")), n.bgFills = I(c(s, "bgFillStyleLst")), n;
288
- }
289
- const Re = {
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
- }, Qt = (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
- }, ct = (t, n, e) => "#" + [t, n, e].map((o) => Math.max(0, Math.min(255, Math.round(o))).toString(16).padStart(2, "0")).join(""), ot = (t) => (t /= 255, t <= 0.04045 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4)), U = (t) => 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * Math.pow(t, 1 / 2.4) - 0.055);
318
- function $t(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 xt(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 D(t, n) {
331
- const e = I(t).find((o) => /Clr$/.test(o.localName));
332
- return e ? Le(e, n) : null;
333
- }
334
- function Le(t, n) {
335
- let e = null, o = 1;
336
- switch (t.localName) {
337
- case "srgbClr": {
338
- const l = k(t, "val");
339
- e = l && /^[0-9a-f]{6}$/i.test(l) ? "#" + l.toLowerCase() : null;
340
- break;
341
- }
342
- case "sysClr": {
343
- const l = k(t, "lastClr");
344
- e = l ? "#" + l.toLowerCase() : k(t, "val") === "window" ? "#ffffff" : "#000000";
345
- break;
346
- }
347
- case "prstClr":
348
- e = Re[k(t, "val") || ""] ?? "#000000";
349
- break;
350
- case "scrgbClr":
351
- e = ct(U(C(t, "r") / 1e5), U(C(t, "g") / 1e5), U(C(t, "b") / 1e5));
352
- break;
353
- case "hslClr": {
354
- const [l, g, b] = xt(C(t, "hue") / 6e4, C(t, "sat") / 1e5, C(t, "lum") / 1e5);
355
- e = ct(l, g, b);
356
- break;
357
- }
358
- case "schemeClr": {
359
- const l = k(t, "val") || "";
360
- if (l === "phClr") {
361
- n.phClr ? (e = n.phClr.hex, o = n.phClr.alpha ?? 1) : e = n.theme.colors.accent1 ?? "#4472c4";
362
- break;
363
- }
364
- const g = n.clrMap[l] ?? Pt[l] ?? l;
365
- e = n.theme.colors[g] ?? null;
366
- break;
367
- }
368
- }
369
- if (!e) return null;
370
- let [s, r, a] = Qt(e);
371
- for (const l of I(t)) {
372
- const g = C(l, "val") / 1e5;
373
- switch (l.localName) {
374
- case "alpha":
375
- o = g;
376
- break;
377
- case "alphaMod":
378
- o *= g;
379
- break;
380
- case "alphaOff":
381
- o += g;
382
- break;
383
- case "lumMod":
384
- case "lumOff":
385
- case "satMod":
386
- case "satOff":
387
- case "hueMod":
388
- case "hueOff": {
389
- let [b, d, m] = $t(s, r, a);
390
- l.localName === "lumMod" ? m *= g : l.localName === "lumOff" ? m += g : l.localName === "satMod" ? d *= g : l.localName === "satOff" ? d += g : l.localName === "hueMod" ? b *= g : b += C(l, "val") / 6e4, [s, r, a] = xt(b, Math.max(0, Math.min(1, d)), Math.max(0, Math.min(1, m)));
391
- break;
392
- }
393
- case "tint":
394
- [s, r, a] = [s, r, a].map((b) => U(ot(b) * g + (1 - g)));
395
- break;
396
- case "shade":
397
- [s, r, a] = [s, r, a].map((b) => U(ot(b) * g));
398
- break;
399
- case "comp": {
400
- const [b, d, m] = $t(s, r, a);
401
- [s, r, a] = xt(b + 180, d, m);
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: ct(s, r, a) };
415
- return o < 0.999 && (i.alpha = o), i;
416
- }
417
- function V(t, n) {
418
- for (const e of I(t)) {
419
- const o = Tt(e, n);
420
- if (o) return o;
421
- }
422
- }
423
- function Tt(t, n) {
424
- switch (t.localName) {
425
- case "noFill":
426
- return { kind: "none" };
427
- case "solidFill": {
428
- const e = D(t, n.ctx);
429
- return e ? { kind: "solid", color: e } : { kind: "none" };
430
- }
431
- case "gradFill": {
432
- const e = I(c(t, "gsLst"), "gs").slice(0, 256).map((s) => ({ pos: C(s, "pos") / 1e5, color: D(s, n.ctx) ?? { hex: "#000000" } }));
433
- if (!e.length) return { kind: "none" };
434
- const o = c(t, "lin");
435
- return c(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 = Jt(t, n);
439
- if (!e) return;
440
- const o = { kind: "image", media: e }, s = c(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 = c(c(t, "blip"), "alphaModFix");
443
- return r && (o.alpha = Math.max(0, Math.min(1, C(r, "amt", 1e5) / 1e5))), c(c(t, "blip"), "grayscl") && (o.grayscale = !0), o;
444
- }
445
- case "pattFill": {
446
- const e = D(c(t, "fgClr"), n.ctx), o = D(c(t, "bgClr"), n.ctx);
447
- return e ? { kind: "pattern", preset: k(t, "prst") || "pct50", color: e, ...o ? { bg: o } : {} } : void 0;
448
- }
449
- case "grpFill":
450
- return;
451
- }
452
- }
453
- const Ee = {
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 Jt(t, n) {
468
- const e = c(t, "blip"), o = k(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 = Ee[(s.target.split(".").pop() || "").toLowerCase()];
473
- return r && a ? { bytes: r, ext: a } : null;
474
- }
475
- const Fe = { solid: "", dot: "sysDot", sysDot: "sysDot", sysDash: "dash", dash: "dash", lgDash: "dash", dashDot: "dash", lgDashDot: "dash", lgDashDotDot: "dash", sysDashDot: "dash", sysDashDotDot: "dash" };
476
- function G(t, n) {
477
- if (!t) return;
478
- let e;
479
- for (const i of I(t)) {
480
- if (i.localName === "noFill") return null;
481
- i.localName === "solidFill" && (e = D(i, n.ctx)), i.localName === "gradFill" && (e = D(c(c(i, "gsLst"), "gs"), n.ctx));
482
- }
483
- const o = k(t, "w");
484
- if (e === void 0 && o === null && !c(t, "prstDash") && !c(t, "headEnd") && !c(t, "tailEnd")) return;
485
- const s = (i) => {
486
- const l = k(i, "type");
487
- if (!l || l === "none") return;
488
- const g = l === "triangle" || l === "stealth" || l === "arrow" || l === "oval" || l === "diamond" ? l : "triangle", b = k(i, "len") || k(i, "w");
489
- return { type: g, size: b === "sm" || b === "lg" ? b : "med" };
490
- }, r = Fe[k(c(t, "prstDash"), "val") || "solid"], a = k(t, "cap");
491
- return {
492
- // ECMA's default is 9525 EMU — 0.75 pt, one px.
493
- width: o !== null ? Math.max(0, E(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: c(t, "round") ? "round" : c(t, "bevel") ? "bevel" : c(t, "miter") ? "miter" : void 0,
498
- head: s(c(t, "headEnd")),
499
- tail: s(c(t, "tailEnd"))
500
- };
501
- }
502
- function dt(t, n) {
503
- const e = c(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 = D(e, n.ctx) ?? void 0;
510
- return Tt(r, { ...n, ctx: { ...n.ctx, phClr: a } });
511
- }
512
- function It(t, n) {
513
- const e = c(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 = D(e, n.ctx) ?? void 0;
520
- return G(s, { ...n, ctx: { ...n.ctx, phClr: r } }) ?? void 0;
521
- }
522
- function W(t) {
523
- if (!t) return null;
524
- const n = c(t, "off"), e = c(t, "ext");
525
- return !n || !e ? null : {
526
- x: E(C(n, "x")),
527
- y: E(C(n, "y")),
528
- w: Math.max(0, E(C(e, "cx"))),
529
- h: Math.max(0, E(C(e, "cy"))),
530
- rot: C(t, "rot") / 6e4,
531
- flipH: !!B(t, "flipH"),
532
- flipV: !!B(t, "flipV")
533
- };
534
- }
535
- const bt = (t) => t;
536
- function je(t, n) {
537
- const e = W(t);
538
- if (!e) return n;
539
- const o = c(t, "chOff"), s = c(t, "chExt"), r = o ? E(C(o, "x")) : e.x, a = o ? E(C(o, "y")) : e.y, i = s ? E(C(s, "cx")) : e.w, l = s ? E(C(s, "cy")) : e.h, g = i > 0 ? e.w / i : 1, b = l > 0 ? e.h / l : 1, d = e.x + e.w / 2, m = e.y + e.h / 2, x = e.rot * Math.PI / 180;
540
- return (f) => {
541
- let h = e.x + (f.x + f.w / 2 - r) * g, y = e.y + (f.y + f.h / 2 - a) * b, u = f.rot, p = f.flipH, w = f.flipV;
542
- if (e.flipH && (h = 2 * d - h, p = !p, u = -u), e.flipV && (y = 2 * m - y, w = !w, u = -u), x) {
543
- const v = h - d, N = y - m;
544
- h = d + v * Math.cos(x) - N * Math.sin(x), y = m + v * Math.sin(x) + N * Math.cos(x), u += e.rot;
545
- }
546
- const M = f.w * g, S = f.h * b;
547
- return n({ x: h - M / 2, y: y - S / 2, w: M, h: S, rot: (u % 360 + 360) % 360, flipH: p, flipV: w });
548
- };
549
- }
550
- function Bt(t) {
551
- const n = c(t, "spcPts"), e = c(t, "spcPct");
552
- if (n) return { px: Math.max(0, Math.min(1584, C(n, "val") / 100)) * (Ct / z) };
553
- if (e) return { lines: Math.max(0, Math.min(13.2, C(e, "val") / 1e5)) };
554
- }
555
- function zt(t, n, e) {
556
- const o = c(t, `lvl${n + 1}pPr`) ?? (t && t.localName.endsWith("pPr") ? t : null);
557
- return o ? te(o, e) : {};
558
- }
559
- function te(t, n) {
560
- const e = {};
561
- if (k(t, "algn") && (e.algn = k(t, "algn")), k(t, "marL") !== null && (e.marL = E(C(t, "marL"))), k(t, "indent") !== null && (e.indent = E(C(t, "indent"))), c(t, "buNone")) e.bullet = "none";
562
- else if (c(t, "buAutoNum")) {
563
- const a = c(t, "buAutoNum");
564
- e.bullet = "num", e.numType = k(a, "type") || "arabicPeriod", e.startAt = k(a, "startAt") !== null ? Math.max(1, Math.min(32767, Math.round(C(a, "startAt", 1)))) : void 0;
565
- } else c(t, "buChar") ? (e.bullet = "char", e.buChar = k(c(t, "buChar"), "char") || void 0) : c(t, "buBlip") && (e.bullet = "char", e.buChar = "•");
566
- if (c(t, "buFont") ? e.buFont = k(c(t, "buFont"), "typeface") || null : c(t, "buFontTx") && (e.buFont = null), c(t, "buClr") ? e.buClr = D(c(t, "buClr"), n.ctx) : c(t, "buClrTx") && (e.buClr = null), c(t, "buSzPct")) {
567
- const a = k(c(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 (c(t, "buSzTx") || c(t, "buSzPts")) && (e.buSz = null);
570
- const o = A(t, "lnSpc", "spcPct");
571
- o && (e.lnSpcPct = C(o, "val") / 1e5);
572
- const s = Bt(c(t, "spcBef")), r = Bt(c(t, "spcAft"));
573
- return s && (e.spcBef = s), r && (e.spcAft = r), Object.assign(e, ee(c(t, "defRPr"), n)), e;
574
- }
575
- function ee(t, n) {
576
- if (!t) return {};
577
- const e = {};
578
- k(t, "sz") !== null && (e.sz = C(t, "sz") / 100 * (Ct / z)), B(t, "b") !== void 0 && (e.b = B(t, "b")), B(t, "i") !== void 0 && (e.i = B(t, "i")), k(t, "u") && (e.u = k(t, "u") !== "none"), k(t, "strike") && (e.strike = k(t, "strike") !== "noStrike");
579
- const o = c(t, "solidFill");
580
- o ? e.color = D(o, n.ctx) : c(t, "noFill") && (e.color = null);
581
- const s = k(c(t, "latin"), "typeface");
582
- return s && (e.font = s), e;
583
- }
584
- const De = {
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
- }, $e = { 183: "•", 168: "♦", 174: "→", 222: "⇒", 45: "−", 42: "∗" };
599
- function Be(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" && De[e] || "•" : o === "symbol" ? $e[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 Xt = (...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 ze(t, n) {
612
- if (t)
613
- return t.startsWith("+mj") ? n.major : t.startsWith("+mn") ? n.minor : t;
614
- }
615
- function Nt(t, n, e) {
616
- if (!t) return;
617
- const o = I(t, "p");
618
- if (!o.some((x) => I(x).some((f) => (f.localName === "r" || f.localName === "fld") && (A(f, "t")?.textContent ?? "") !== ""))) return;
619
- const r = {};
620
- let a = 1, i = 1;
621
- for (const x of [...n.bodyPr, c(t, "bodyPr")]) {
622
- if (!x) continue;
623
- for (let h = 0; h < x.attributes.length; h++) r[x.attributes[h].localName ?? x.attributes[h].name] = x.attributes[h].value;
624
- const f = c(x, "normAutofit");
625
- f && (a = k(f, "fontScale") !== null ? C(f, "fontScale") / 1e5 : 1), f && (i = 1 - Math.max(0, Math.min(0.9, C(f, "lnSpcReduction") / 1e5))), (c(x, "noAutofit") || c(x, "spAutoFit")) && (a = 1, i = 1);
626
- }
627
- const l = (x, f) => r[x] !== void 0 ? E(Number(r[x]) || 0) : E(f), g = r.anchor === "ctr" ? "ctr" : r.anchor === "b" ? "b" : "t", b = c(t, "lstStyle"), d = [];
628
- let m;
629
- for (const x of o) {
630
- const f = c(x, "pPr"), h = Math.max(0, Math.min(8, C(f, "lvl"))), y = n.fontRef ? { color: n.fontRef.color ?? void 0, font: n.fontRef.font } : {}, u = Xt(...n.levels.map((P) => zt(P, h, e)), y, zt(b, h, e), f ? te(f, e) : {});
631
- u.lnSpcPct !== void 0 && m === void 0 && (m = u.lnSpcPct);
632
- const p = { runs: [], align: u.algn === "ctr" ? "ctr" : u.algn === "r" ? "r" : (u.algn === "just", "l"), level: h };
633
- if (u.bullet === "char" || u.bullet === "num") {
634
- if (p.bullet = u.bullet, p.marL = u.marL ?? 0, p.indent = u.indent ?? 0, u.bullet === "char") {
635
- const P = Be(u.buChar, u.buFont ?? void 0);
636
- P !== "•" && (p.bulletChar = P);
637
- } else
638
- u.numType && u.numType !== "arabicPeriod" && (p.numType = u.numType), u.startAt && u.startAt !== 1 && (p.startAt = u.startAt);
639
- u.buClr && (p.bulletColor = u.buClr), u.buSz && Math.abs(u.buSz - 1) > 1e-3 && (p.bulletScale = u.buSz);
640
- }
641
- const w = (P) => {
642
- const L = Xt(u, ee(P, e)), X = (L.sz ?? 18 * Ct / z) * a, H = L.color === null ? void 0 : L.color ?? ne("tx1", e);
643
- return {
644
- text: "",
645
- size: X,
646
- bold: L.b || void 0,
647
- italic: L.i || void 0,
648
- underline: L.u || void 0,
649
- strike: L.strike || void 0,
650
- color: H ?? void 0,
651
- font: ze(L.font ?? "+mn-lt", e.ctx.theme)
652
- };
653
- };
654
- for (const P of I(x))
655
- if (P.localName === "r" || P.localName === "fld") {
656
- const L = A(P, "t")?.textContent ?? "";
657
- if (!L) continue;
658
- L.split(/[\v\n]/).forEach((X, H) => {
659
- H > 0 && p.runs.push({ ...w(c(P, "rPr")), br: !0 }), X && p.runs.push({ ...w(c(P, "rPr")), text: X });
660
- });
661
- } else P.localName === "br" && p.runs.push({ ...w(c(P, "rPr")), br: !0 });
662
- p.endSize = w(c(x, "endParaRPr")).size;
663
- const M = (p.runs.length ? Math.max(...p.runs.map((P) => P.size ?? 0)) : p.endSize ?? 0) * 1.2 * (u.lnSpcPct ?? 1), S = (P) => P ? ("px" in P ? P.px : P.lines * M) * i : 0, v = S(u.spcBef), N = S(u.spcAft);
664
- v > 0.05 && (p.spaceBefore = Math.round(v * 100) / 100), N > 0.05 && (p.spaceAfter = Math.round(N * 100) / 100), d.push(p);
665
- }
666
- return {
667
- paragraphs: d,
668
- anchor: g,
669
- insets: { l: l("lIns", 91440), t: l("tIns", 45720), r: l("rIns", 91440), b: l("bIns", 45720) },
670
- wrap: r.wrap !== "none",
671
- lineSpacing: m
672
- };
673
- }
674
- const ne = (t, n) => {
675
- const e = n.ctx.clrMap[t] ?? Pt[t] ?? t, o = n.ctx.theme.colors[e];
676
- return o ? { hex: o } : null;
677
- }, K = (t) => {
678
- const n = c(t, "ph");
679
- return n ? { type: k(n, "type") || "obj", idx: C(n, "idx") } : null;
680
- }, st = (t) => c(I(t).find((n) => n.localName.startsWith("nv")) ?? null, "nvPr"), it = /* @__PURE__ */ new Set(["title", "ctrTitle"]), Ht = /* @__PURE__ */ new Set(["title", "ctrTitle", "dt", "ftr", "sldNum", "hdr"]), Yt = (t, n) => t === n || it.has(t) && it.has(n) || !Ht.has(t) && !Ht.has(n);
681
- function ut(t, n) {
682
- const e = Xe(t);
683
- if (n.idx) {
684
- const o = e.find((s) => s.ph.idx === n.idx && Yt(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 || it.has(n.type))) ?? e.find((o) => o.ph.type === n.type) ?? e.find((o) => Yt(o.ph.type, n.type)))?.el ?? null;
688
- }
689
- function Xe(t) {
690
- const n = [];
691
- for (const e of J(t)) {
692
- const o = K(st(e));
693
- o && n.push({ el: e, ph: o });
694
- }
695
- return n;
696
- }
697
- const oe = (t) => it.has(t) ? "title" : ["dt", "ftr", "sldNum", "hdr"].includes(t) ? t : "body", He = (t) => {
698
- const n = {};
699
- for (const e of I(c(t, "avLst"), "gd")) {
700
- const o = k(e, "name"), s = k(e, "fmla");
701
- o && s && (n[o] = s);
702
- }
703
- return n;
704
- };
705
- function Ye(t) {
706
- const n = (r) => I(r, "gd").slice(0, 1e4).map((a) => [k(a, "name") || "", k(a, "fmla") || "val 0"]), e = I(c(t, "cxnLst"), "cxn").map((r) => [k(r, "ang") || "0", k(c(r, "pos"), "x") || "0", k(c(r, "pos"), "y") || "0"]), o = c(t, "rect"), s = I(c(t, "pathLst"), "path").slice(0, 1e3).map((r) => {
707
- const a = [];
708
- for (const l of I(r)) {
709
- const g = I(l, "pt").map((b) => [k(b, "x") || "0", k(b, "y") || "0"]).flat();
710
- switch (l.localName) {
711
- case "moveTo":
712
- a.push(["M", ...g]);
713
- break;
714
- case "lnTo":
715
- a.push(["L", ...g]);
716
- break;
717
- case "quadBezTo":
718
- a.push(["Q", ...g]);
719
- break;
720
- case "cubicBezTo":
721
- a.push(["C", ...g]);
722
- break;
723
- case "arcTo":
724
- a.push(["A", k(l, "wR") || "0", k(l, "hR") || "0", k(l, "stAng") || "0", k(l, "swAng") || "0"]);
725
- break;
726
- case "close":
727
- a.push(["Z"]);
728
- break;
729
- }
730
- }
731
- const i = k(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: I(c(t, "avLst"), "gd").map((r) => [k(r, "name") || "", k(r, "fmla") || "val 0"]),
736
- gd: n(c(t, "gdLst")),
737
- cxn: e,
738
- rect: o ? [k(o, "l") || "l", k(o, "t") || "t", k(o, "r") || "r", k(o, "b") || "b"] : null,
739
- paths: s
740
- };
741
- }
742
- function rt(t, n) {
743
- const e = c(t, "prstGeom");
744
- if (e) {
745
- const s = {};
746
- for (const [r, a] of Object.entries(He(e))) {
747
- const i = /^val\s+(-?\d+(\.\d+)?)/.exec(a);
748
- i && (s[r] = Number(i[1]));
749
- }
750
- return { geom: { kind: "preset", prst: k(e, "prst") || "rect", adj: Object.keys(s).length ? s : void 0 } };
751
- }
752
- const o = c(t, "custGeom");
753
- if (o) {
754
- const s = Ye(o);
755
- return { geom: { kind: "custom", paths: ft(s, n.w, n.h) }, textRect: s.rect ? Kt(s, n.w, n.h) : void 0 };
756
- }
757
- }
758
- function at(t, n, e, o, s, r) {
759
- const a = [];
760
- if (s > Pe)
761
- return e.warnings.push("Groups nested too deeply; the innermost were skipped."), a;
762
- for (const i of J(t)) {
763
- if (++e.count > Te) {
764
- e.warnings.push("Too many shapes on one slide; the rest were skipped.");
765
- break;
766
- }
767
- try {
768
- const l = Ue(i, n, e, o, s, r);
769
- l && a.push(...Array.isArray(l) ? l : [l]);
770
- } catch {
771
- e.warnings.push(`A ${i.localName} couldn't be read and was skipped.`);
772
- }
773
- }
774
- return a;
775
- }
776
- const We = {
777
- nextslide: "next",
778
- previousslide: "previous",
779
- firstslide: "first",
780
- lastslide: "last",
781
- endshow: "end"
782
- };
783
- function _e(t, n, e) {
784
- const o = c(t, "hlinkClick");
785
- if (!o) return;
786
- const s = k(o, "action") || "", r = e.rels(n).get(k(o, "r:id") || "");
787
- if (s.startsWith("ppaction://hlinkshowjump")) {
788
- const a = We[(/jump=([a-z]+)/i.exec(s)?.[1] ?? "").toLowerCase()];
789
- return a ? { kind: "action", action: a } : void 0;
790
- }
791
- if (s.startsWith("ppaction://hlinksldjump")) return r && !r.external ? { kind: "slide", key: r.target } : void 0;
792
- if (!s)
793
- return r?.external && /^(https?:|mailto:|tel:)/i.test(r.target) ? { kind: "url", url: r.target } : void 0;
794
- }
795
- function Ue(t, n, e, o, s, r) {
796
- const a = I(t).find((g) => g.localName.startsWith("nv")), i = Ge(t, n, e, o, s, r), l = i ? _e(c(a ?? null, "cNvPr"), n.part, e.pkg) : void 0;
797
- if (l) for (const g of Array.isArray(i) ? i : [i]) g.link = l;
798
- return i;
799
- }
800
- function Ge(t, n, e, o, s, r) {
801
- const a = { pkg: e.pkg, part: n.part, ctx: e.ctx }, i = I(t).find((d) => d.localName.startsWith("nv")), l = c(i ?? null, "cNvPr"), g = C(l, "id"), b = k(l, "name") || t.localName;
802
- if (k(l, "hidden") === "1") return null;
803
- switch (t.localName) {
804
- case "sp":
805
- return Ze(t, n, e, o, g, b, r);
806
- case "cxnSp": {
807
- const d = c(t, "spPr"), m = W(c(d, "xfrm"));
808
- if (!m) return null;
809
- const x = o(m), f = c(t, "style"), h = G(c(d, "ln"), a) ?? It(f, a) ?? { width: 1, color: { hex: "#000000" } };
810
- if (!h) return null;
811
- const y = rt(d, x) ?? { geom: { kind: "preset", prst: "line" } }, u = (w) => w ? { id: C(w, "id"), idx: C(w, "idx") } : void 0, p = c(i ?? null, "cNvCxnSpPr");
812
- return { kind: "connector", id: g, name: b, ...x, geom: y.geom, line: h, start: u(c(p, "stCxn")), end: u(c(p, "endCxn")) };
813
- }
814
- case "pic": {
815
- const d = c(t, "spPr");
816
- let m = W(c(d, "xfrm"));
817
- const x = K(c(i ?? null, "nvPr"));
818
- if (!m && x && (m = Ve(x, e)), !m) return null;
819
- const f = c(t, "blipFill"), h = f ? Jt(f, a) : null;
820
- if (!h)
821
- return e.warnings.push(`Picture "${b}" has no image the importer can read.`), null;
822
- const y = c(f, "srcRect"), u = y ? { l: C(y, "l") / 1e5, t: C(y, "t") / 1e5, r: C(y, "r") / 1e5, b: C(y, "b") / 1e5 } : void 0, p = k(A(f, "blip", "alphaModFix"), "amt"), w = o(m), M = rt(d, w)?.geom, S = M && !(M.kind === "preset" && M.prst === "rect") ? M : void 0;
823
- return { kind: "picture", id: g, name: b, ...w, media: h, crop: u, alpha: p !== null ? Number(p) / 1e5 : void 0, descr: k(l, "descr") || void 0, geom: S, ...A(f, "blip", "grayscl") ? { grayscale: !0 } : {} };
824
- }
825
- case "grpSp": {
826
- const d = c(t, "grpSpPr"), m = c(d, "xfrm"), x = je(m, o), f = at(t, n, e, x, s + 1, r);
827
- if (!f.length) return null;
828
- const h = ht(f);
829
- return { kind: "group", id: g, name: b, ...h, children: f };
830
- }
831
- case "graphicFrame":
832
- return Je(t, n, e, o, g, b, s);
833
- default:
834
- return null;
835
- }
836
- }
837
- function ht(t) {
838
- let n = 1 / 0, e = 1 / 0, o = -1 / 0, s = -1 / 0;
839
- for (const r of t)
840
- 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);
841
- return { x: n, y: e, w: Math.max(0, o - n), h: Math.max(0, s - e) };
842
- }
843
- function Ve(t, n) {
844
- const e = ut(n.layout?.tree ?? null, t), o = W(A(e, "spPr", "xfrm"));
845
- if (o) return o;
846
- const s = ut(n.master?.tree ?? null, { type: oe(t.type), idx: 0 });
847
- return W(A(s, "spPr", "xfrm"));
848
- }
849
- function qe(...t) {
850
- for (const n of t) {
851
- const e = n();
852
- if (e !== void 0) return e;
853
- }
854
- }
855
- function Ze(t, n, e, o, s, r, a) {
856
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, l = st(t), g = K(l);
857
- if (g && !a) return null;
858
- const b = c(t, "spPr"), d = c(t, "style"), m = k(A(t, "nvSpPr", "cNvSpPr"), "txBox") === "1", x = g && e.layout ? ut(e.layout.tree, g) : null, f = g && e.master ? ut(e.master.tree, { type: oe(x ? K(st(x))?.type ?? g.type : g.type), idx: 0 }) : null, h = x && e.layout ? { pkg: e.pkg, part: e.layout.part, ctx: e.ctx } : null, y = f && e.master ? { pkg: e.pkg, part: e.master.part, ctx: e.ctx } : null;
859
- let u = W(c(b, "xfrm")) ?? W(A(x, "spPr", "xfrm")) ?? W(A(f, "spPr", "xfrm"));
860
- if (!u) return null;
861
- u = o(u);
862
- const p = rt(b, u) ?? (x ? rt(c(x, "spPr"), u) : void 0) ?? (f ? rt(c(f, "spPr"), u) : 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(b, i) ?? dt(d, i) ?? (h ? V(c(x, "spPr"), h) : void 0) ?? (y ? V(c(f, "spPr"), y) : void 0) ?? (h ? dt(c(x, "style"), h) : void 0) ?? { kind: "none" }, S = qe(
863
- () => G(c(b, "ln"), i),
864
- () => It(d, i),
865
- () => h ? G(A(x, "spPr", "ln"), h) : void 0,
866
- () => y ? G(A(f, "spPr", "ln"), y) : void 0
867
- ) ?? null, v = [];
868
- if (g) {
869
- const O = x ? K(st(x))?.type ?? g.type : g.type;
870
- v.push(it.has(O) ? e.masterTx.title : ["body", "obj", "subTitle", "tbl", "chart", "dgm", "media", "pic", "clipArt"].includes(O) ? e.masterTx.body : e.masterTx.other), v.push(A(f, "txBody", "lstStyle"), A(x, "txBody", "lstStyle"));
871
- } else
872
- v.push(e.defaultText);
873
- const N = c(d, "fontRef"), P = {
874
- levels: v,
875
- bodyPr: [A(f, "txBody", "bodyPr"), A(x, "txBody", "bodyPr")],
876
- fontRef: N ? { font: k(N, "idx") === "major" ? "+mj-lt" : "+mn-lt", color: D(N, i.ctx) } : void 0
877
- }, L = Nt(c(t, "txBody"), P, i);
878
- if (!(M.kind !== "none" || !!S || !!L)) return null;
879
- let H = p.textRect;
880
- const T = W(c(b, "xfrm")), R = L ? W(c(t, "txXfrm")) : null;
881
- if (R && T && T.w > 0 && T.h > 0) {
882
- const O = u.w / T.w, Y = u.h / T.h, j = { l: (R.x - T.x) * O, t: (R.y - T.y) * Y, r: (R.x + R.w - T.x) * O, b: (R.y + R.h - T.y) * Y };
883
- (Math.abs(j.l) > 0.5 || Math.abs(j.t) > 0.5 || Math.abs(j.r - u.w) > 0.5 || Math.abs(j.b - u.h) > 0.5) && (H = j);
884
- }
885
- return { kind: "shape", id: s, name: r, ...u, geom: p.geom, fill: M, line: S, text: L, textBox: m || void 0, textRect: H };
886
- }
887
- const Wt = "{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}";
888
- function Ke(t, n) {
889
- const e = {};
890
- if (!t) return e;
891
- const o = c(t, "tcStyle"), s = c(t, "tcTxStyle"), r = c(o, "fill"), a = r ? V(r, n) : dt(o, n);
892
- a && (e.fill = a);
893
- const i = D(s, n.ctx) ?? D(c(s, "fontRef"), n.ctx);
894
- i && (e.text = i), k(s, "b") === "on" && (e.bold = !0);
895
- const l = c(o, "tcBdr");
896
- for (const g of ["insideH", "bottom", "top", "left"]) {
897
- const b = c(l, g);
898
- if (!b) continue;
899
- const d = G(c(b, "ln"), n) ?? It(b, n);
900
- if (d !== void 0) {
901
- e.border = d;
902
- break;
903
- }
904
- }
905
- return e;
906
- }
907
- function Qe(t, n, e) {
908
- const o = ((c(t, "tableStyleId")?.textContent || "").trim() || k(e, "def") || Wt).toUpperCase(), s = (d) => B(t, d) ?? !1, r = { firstRow: s("firstRow"), lastRow: s("lastRow"), firstCol: s("firstCol"), lastCol: s("lastCol"), bandRow: s("bandRow"), bandCol: s("bandCol") }, a = I(e, "tblStyle").find((d) => (k(d, "styleId") || "").toUpperCase() === o);
909
- if (a) {
910
- const d = (y) => Ke(c(a, y), n), m = c(a, "tblBg"), x = m ? c(m, "fill") ? V(c(m, "fill"), n) : dt(m, n) : void 0, f = {
911
- whole: d("wholeTbl"),
912
- b1H: d("band1H"),
913
- b2H: d("band2H"),
914
- b1V: d("band1V"),
915
- b2V: d("band2V"),
916
- firstRow: d("firstRow"),
917
- lastRow: d("lastRow"),
918
- firstCol: d("firstCol"),
919
- lastCol: d("lastCol")
920
- }, h = (y, u, p, w) => {
921
- const M = [f.whole], S = y - (r.firstRow ? 1 : 0), v = u - (r.firstCol ? 1 : 0);
922
- r.bandCol && v >= 0 && M.push(v % 2 === 0 ? f.b1V : f.b2V), r.bandRow && S >= 0 && M.push(S % 2 === 0 ? f.b1H : f.b2H), r.firstCol && u === 0 && M.push(f.firstCol), r.lastCol && u === w - 1 && M.push(f.lastCol), r.firstRow && y === 0 && M.push(f.firstRow), r.lastRow && y === p - 1 && M.push(f.lastRow);
923
- const N = {};
924
- for (const P of M)
925
- P.fill && (N.fill = P.fill), P.text && (N.text = P.text), P.bold && (N.bold = !0), P.border !== void 0 && (N.border = P.border);
926
- return N;
927
- };
928
- return x && x.kind !== "none" && (h.background = x), h;
929
- }
930
- if (o !== Wt) return null;
931
- const i = n.ctx.theme.colors.accent1 ?? "#4472c4", l = (d) => {
932
- const [m, x, f] = Qt(i);
933
- return { hex: ct(U(ot(m) * d + (1 - d)), U(ot(x) * d + (1 - d)), U(ot(f) * d + (1 - d))) };
934
- }, g = { hex: n.ctx.theme.colors.lt1 ?? "#ffffff" }, b = ne("tx1", n) ?? void 0;
935
- return (d) => {
936
- const m = r.firstRow && d === 0, x = r.bandRow && !m && (d - (r.firstRow ? 1 : 0)) % 2 === 0;
937
- return {
938
- fill: { kind: "solid", color: m ? { hex: i } : l(x ? 0.4 : 0.2) },
939
- text: m ? g : b,
940
- bold: m || void 0,
941
- border: { width: 1.33, color: g }
942
- };
943
- };
944
- }
945
- function Je(t, n, e, o, s, r, a = 0) {
946
- const i = { pkg: e.pkg, part: n.part, ctx: e.ctx }, l = W(c(t, "xfrm"));
947
- if (!l) return null;
948
- const g = A(t, "graphic", "graphicData"), b = c(g, "tbl");
949
- if (b) {
950
- const x = I(c(b, "tblGrid"), "gridCol").map((w) => E(C(w, "w"))), f = Qe(c(b, "tblPr"), i, e.tableStyles), h = [];
951
- let y = l.y, u = 1e6 + s * 1e3;
952
- const p = I(b, "tr");
953
- if (p.forEach((w, M) => {
954
- const S = E(C(w, "h"));
955
- let v = l.x, N = 0;
956
- for (const P of I(w, "tc")) {
957
- const L = Math.max(1, C(P, "gridSpan", 1)), X = x.slice(N, N + L).reduce((tt, Z) => tt + Z, 0);
958
- if (N += L, B(P, "hMerge") || B(P, "vMerge")) {
959
- v += X;
960
- continue;
961
- }
962
- const H = Math.max(1, C(P, "rowSpan", 1)), T = c(P, "tcPr"), R = H > 1 ? S * H : S, O = f ? f(M, N - L, p.length, x.length) : null, Y = O?.text ? { color: O.text } : void 0, j = Nt(c(P, "txBody"), { levels: [e.defaultText], bodyPr: [], fontRef: Y }, i);
963
- j && O?.bold && j.paragraphs.forEach((tt) => tt.runs.forEach((Z) => {
964
- Z.bold === void 0 && (Z.bold = !0);
965
- })), j && (j.insets = { l: E(C(T, "marL", 91440)), r: E(C(T, "marR", 91440)), t: E(C(T, "marT", 45720)), b: E(C(T, "marB", 45720)) }, j.anchor = k(T, "anchor") === "ctr" ? "ctr" : k(T, "anchor") === "b" ? "b" : "t");
966
- const _ = G(c(T, "lnB"), i) ?? G(c(T, "lnT"), i) ?? (O ? O.border ?? null : { width: 1, color: { hex: "#bfbfbf" } }), q = O?.fill;
967
- h.push({
968
- kind: "shape",
969
- id: u++,
970
- name: `${r} cell`,
971
- ...o({ x: v, y, w: X, h: R, rot: 0, flipH: !1, flipV: !1 }),
972
- geom: { kind: "preset", prst: "rect" },
973
- fill: V(T, i) ?? q ?? { kind: "none" },
974
- line: _,
975
- text: j
976
- }), v += X;
977
- }
978
- y += S;
979
- }), !h.length) return null;
980
- if (f?.background) {
981
- const w = ht(h);
982
- h.unshift({
983
- kind: "shape",
984
- id: u++,
985
- name: `${r} background`,
986
- x: w.x,
987
- y: w.y,
988
- w: w.w,
989
- h: w.h,
990
- rot: 0,
991
- flipH: !1,
992
- flipV: !1,
993
- geom: { kind: "preset", prst: "rect" },
994
- fill: f.background,
995
- line: null
996
- });
997
- }
998
- return { kind: "group", id: s, name: r, ...ht(h), children: h };
999
- }
1000
- const d = k(g, "uri") || "";
1001
- if (/diagram/.test(d)) {
1002
- const x = tn(g, n, e, o, l, s, r, a);
1003
- if (x) return x;
1004
- const f = en(g, n, e, o, l, s, r, i);
1005
- if (f) return f;
1006
- }
1007
- const m = /chart/.test(d) ? "Chart" : /diagram/.test(d) ? "SmartArt diagram" : "Embedded object";
1008
- return e.warnings.push(`${m} "${r}" was imported as a placeholder frame.`), {
1009
- kind: "shape",
1010
- id: s,
1011
- name: r,
1012
- ...o(l),
1013
- geom: { kind: "preset", prst: "rect" },
1014
- fill: { kind: "solid", color: { hex: "#f1f3f5" } },
1015
- line: { width: 1, color: { hex: "#adb5bd" }, dash: "dash" },
1016
- text: { paragraphs: [{ runs: [{ text: `${m}: ${r}`, size: 16, color: { hex: "#495057" } }], align: "ctr" }], anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
1017
- };
1018
- }
1019
- function tn(t, n, e, o, s, r, a, i) {
1020
- const l = e.pkg.rels(n.part), g = k(c(t, "relIds"), "r:dm"), b = g ? l.get(g) : void 0;
1021
- let d;
1022
- if (b && !b.external) {
1023
- const u = Ot(e.pkg.xml(b.target), "dataModelExt", 6), p = u ? l.get(k(u, "relId") || "") : void 0;
1024
- p && !p.external && (d = p.target);
1025
- }
1026
- if (!d) {
1027
- const u = [...l.values()].filter((p) => p.type === "diagramDrawing" && !p.external);
1028
- u.length === 1 && (d = u[0].target);
1029
- }
1030
- if (!d) return null;
1031
- const m = c(e.pkg.xml(d), "spTree");
1032
- if (!m) return null;
1033
- const f = at(m, { part: d, tree: m }, e, (u) => o({ ...u, x: u.x + s.x, y: u.y + s.y }), i + 1, !0);
1034
- if (!f.length) return null;
1035
- let h = 2e6 + r * 1e3;
1036
- const y = (u) => u.forEach((p) => {
1037
- p.id = h++, p.kind === "group" && y(p.children);
1038
- });
1039
- return y(f), { kind: "group", id: r, name: a, ...ht(f), children: f };
1040
- }
1041
- function en(t, n, e, o, s, r, a, i) {
1042
- const l = k(c(t, "relIds"), "r:dm"), g = l ? e.pkg.rels(n.part).get(l) : void 0;
1043
- if (!g || g.external) return null;
1044
- const b = e.pkg.xml(g.target), d = /* @__PURE__ */ new Map();
1045
- for (const u of I(c(b, "ptLst"), "pt")) d.set(k(u, "modelId") || "", u);
1046
- const m = /* @__PURE__ */ new Map();
1047
- for (const u of I(c(b, "cxnLst"), "cxn")) {
1048
- if ((k(u, "type") || "parOf") !== "parOf") continue;
1049
- const p = k(u, "srcId") || "", w = k(u, "destId") || "";
1050
- m.has(p) || m.set(p, []), m.get(p).push({ id: w, ord: C(u, "srcOrd") });
1051
- }
1052
- const x = [...d.values()].find((u) => k(u, "type") === "doc");
1053
- if (!x) return null;
1054
- const f = [], h = /* @__PURE__ */ new Set(), y = (u, p) => {
1055
- if (!(h.has(u) || p > 16 || f.length > 500)) {
1056
- h.add(u);
1057
- for (const w of (m.get(u) ?? []).sort((M, S) => M.ord - S.ord)) {
1058
- const M = d.get(w.id), S = k(M, "type") || "node";
1059
- if (!M || S !== "node" && S !== "asst") continue;
1060
- const v = Nt(c(M, "t"), { levels: [e.defaultText], bodyPr: [] }, i);
1061
- for (const N of v?.paragraphs ?? [])
1062
- N.runs.some((P) => !P.br && P.text.trim()) && f.push({
1063
- ...N,
1064
- align: "l",
1065
- level: p,
1066
- ...p > 0 ? { bullet: "char" } : {},
1067
- runs: N.runs.map((P) => ({ ...P, size: P.size ?? (p > 0 ? 16 : 18), bold: P.bold ?? (p === 0 ? !0 : void 0) }))
1068
- });
1069
- y(w.id, p + 1);
1070
- }
1071
- }
1072
- };
1073
- return y(k(x, "modelId") || "", 0), f.length ? (e.warnings.push(`SmartArt diagram "${a}" had no saved drawing; its text was imported as a list.`), {
1074
- kind: "shape",
1075
- id: r,
1076
- name: a,
1077
- ...o(s),
1078
- geom: { kind: "preset", prst: "rect" },
1079
- fill: { kind: "none" },
1080
- line: null,
1081
- textBox: !0,
1082
- text: { paragraphs: f, anchor: "ctr", insets: { l: 8, t: 8, r: 8, b: 8 }, wrap: !0 }
1083
- }) : null;
1084
- }
1085
- function Ot(t, n, e) {
1086
- if (!t || e < 0) return null;
1087
- for (const o of J(t)) {
1088
- if (o.localName === n) return o;
1089
- const s = Ot(o, n, e - 1);
1090
- if (s) return s;
1091
- }
1092
- return null;
1093
- }
1094
- function yt(t, n) {
1095
- const e = c(t, "bg");
1096
- if (!e) return;
1097
- const o = c(e, "bgPr");
1098
- if (o)
1099
- return V(o, n);
1100
- const s = c(e, "bgRef");
1101
- if (s) {
1102
- const r = C(s, "idx"), i = (r >= 1001 ? n.ctx.theme.bgFills : n.ctx.theme.fills)[r >= 1001 ? r - 1001 : r - 1];
1103
- return (i ? Tt(i, { ...n, ctx: { ...n.ctx, phClr: D(s, n.ctx) ?? void 0 } }) : void 0) ?? (D(s, n.ctx) ? { kind: "solid", color: D(s, n.ctx) } : void 0);
1104
- }
1105
- }
1106
- function nn(t, n) {
1107
- const e = t.relOfType(n, "notesSlide"), o = e ? A(t.xml(e), "cSld", "spTree") : null;
1108
- if (!o) return;
1109
- const s = [], r = (i) => {
1110
- for (const l of J(i)) {
1111
- if (l.localName === "grpSp") {
1112
- r(l);
1113
- continue;
1114
- }
1115
- if (l.localName !== "sp") continue;
1116
- const g = K(st(l));
1117
- if (!(!g || g.type !== "body" && g.type !== "obj"))
1118
- for (const b of I(c(l, "txBody"), "p")) {
1119
- let d = "";
1120
- for (const m of I(b))
1121
- m.localName === "r" || m.localName === "fld" ? d += c(m, "t")?.textContent ?? "" : m.localName === "br" && (d += `
1122
- `);
1123
- s.push(d);
1124
- }
1125
- }
1126
- };
1127
- r(o);
1128
- const a = s.join(`
1129
- `).replace(/\s+$/, "");
1130
- return a.trim() ? a : void 0;
1131
- }
1132
- function on(t) {
1133
- for (const a of I(t, "AlternateContent"))
1134
- for (const i of I(a, "Choice")) {
1135
- const l = c(i, "transition");
1136
- if (l && c(l, "morph")) {
1137
- const g = k(l, "spd");
1138
- return { kind: "morph", durationMs: k(l, "p14:dur") !== null ? C(l, "p14:dur") : g === "fast" ? 500 : g === "slow" ? 1e3 : 750 };
1139
- }
1140
- }
1141
- const n = J(t).find((a) => a.localName === "transition");
1142
- if (!n) return;
1143
- const e = I(n).find((a) => a.localName !== "sndAc" && a.localName !== "extLst");
1144
- if (!e) return;
1145
- const o = k(n, "spd"), s = k(n, "p14:dur") !== null ? C(n, "p14:dur") : o === "fast" ? 500 : o === "slow" ? 1e3 : 750, r = k(e, "dir");
1146
- switch (e.localName) {
1147
- case "push":
1148
- case "cover":
1149
- case "pull":
1150
- case "wipe":
1151
- return { kind: "push", dir: r === "r" || r === "u" || r === "d" ? r : "l", durationMs: s };
1152
- case "zoom":
1153
- return { kind: "zoom", zoomIn: r !== "out", durationMs: s };
1154
- case "morph":
1155
- return { kind: "morph", durationMs: s };
1156
- case "cut":
1157
- return;
1158
- default:
1159
- return { kind: "fade", durationMs: s };
1160
- }
1161
- }
1162
- function _t(t) {
1163
- const n = J(t).find((s) => s.localName === "transition"), e = n ? k(n, "advTm") : null, o = e !== null ? Number(e) : NaN;
1164
- return Number.isFinite(o) && o > 0 ? o : void 0;
1165
- }
1166
- function sn(t, n) {
1167
- const e = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
1168
- for (const r of I(c(t, "sldIdLst"), "sldId")) {
1169
- const a = n.get(k(r, "r:id") || ""), i = k(r, "id");
1170
- a && i && o.set(i, a.target);
1171
- }
1172
- const s = Ot(c(t, "extLst"), "sectionLst", 4);
1173
- for (const r of I(s, "section")) {
1174
- const a = (k(r, "name") || "").trim(), i = I(c(r, "sldIdLst"), "sldId")[0], l = i ? o.get(k(i, "id") || "") : void 0;
1175
- a && l && !e.has(l) && e.set(l, a);
1176
- }
1177
- return e;
1178
- }
1179
- function rn(t, n = {}) {
1180
- const e = [], o = (T) => {
1181
- e.length < 200 && !e.includes(T) && e.push(T);
1182
- }, s = n.parseXml ?? ((T) => new DOMParser().parseFromString(T, "application/xml"));
1183
- let r, a = 0, i = 0;
1184
- try {
1185
- r = fe(t, {
1186
- filter: (T) => (a++, i += T.originalSize, a <= jt && T.originalSize <= Se && i <= Dt)
1187
- });
1188
- } catch {
1189
- throw new Error("This file is not a PowerPoint presentation (it is not a valid .pptx package).");
1190
- }
1191
- (a > jt || i > Dt) && o("The file is very large; some parts were skipped.");
1192
- const l = new Oe(r, s, o), g = l.relOfType("", "officeDocument") ?? "ppt/presentation.xml", b = l.xml(g);
1193
- if (!b || b.localName !== "presentation") throw new Error("This file is not a PowerPoint presentation (no presentation part).");
1194
- const d = c(b, "sldSz"), m = d ? Math.max(1, E(C(d, "cx", 9144e3))) : 960, x = d ? Math.max(1, E(C(d, "cy", 5143500))) : 540, f = c(b, "defaultTextStyle"), h = l.rels(g), y = l.relOfType(g, "tableStyles"), u = y ? l.xml(y) : null, p = [], w = /* @__PURE__ */ new Set();
1195
- for (const T of I(c(b, "sldIdLst"), "sldId")) {
1196
- const R = h.get(k(T, "r:id") || "");
1197
- R && !w.has(R.target) && p.length < Ce && (w.add(R.target), p.push(R.target));
1198
- }
1199
- const M = /* @__PURE__ */ new Map(), S = (T) => {
1200
- const R = l.relOfType(T, "theme");
1201
- return R ? (M.has(R) || M.set(R, gt(l.xml(R))), M.get(R)) : gt(null);
1202
- }, v = (T) => {
1203
- if (!T) return null;
1204
- const R = {};
1205
- for (let O = 0; O < T.attributes.length; O++) R[T.attributes[O].localName ?? T.attributes[O].name] = T.attributes[O].value;
1206
- return R;
1207
- }, N = sn(b, h), P = [];
1208
- p.forEach((T, R) => {
1209
- const O = l.xml(T);
1210
- if (!O) {
1211
- o(`Slide ${R + 1} couldn't be read and was skipped.`);
1212
- return;
1213
- }
1214
- const Y = l.relOfType(T, "slideLayout"), j = Y ? l.xml(Y) : null, _ = Y ? l.relOfType(Y, "slideMaster") : null, q = _ ? l.xml(_) : null, tt = _ ? S(_) : gt(null), Z = v(A(O, "clrMapOvr", "overrideClrMapping")) ?? v(A(j, "clrMapOvr", "overrideClrMapping")) ?? v(c(q, "clrMap")) ?? Pt, At = { theme: tt, clrMap: Z }, pt = c(q, "txStyles"), $ = {
1215
- pkg: l,
1216
- ctx: At,
1217
- slide: { part: T, tree: A(O, "cSld", "spTree") },
1218
- layout: Y ? { part: Y, tree: A(j, "cSld", "spTree") } : null,
1219
- master: _ ? { part: _, tree: A(q, "cSld", "spTree") } : null,
1220
- masterTx: { title: c(pt, "titleStyle"), body: c(pt, "bodyStyle"), other: c(pt, "otherStyle") },
1221
- defaultText: f,
1222
- warnings: e,
1223
- count: 0,
1224
- tableStyles: u
1225
- }, mt = (ce) => ({ pkg: l, part: ce?.part ?? T, ctx: At }), Rt = yt(c(O, "cSld"), mt($.slide)) ?? yt(c(j, "cSld"), mt($.layout)) ?? yt(c(q, "cSld"), mt($.master)) ?? { kind: "solid", color: { hex: "#ffffff" } };
1226
- $.background = Rt;
1227
- const lt = [], le = B(O, "showMasterSp") !== !1 && B(j, "showMasterSp") !== !1;
1228
- $.master && le && lt.push(...at($.master.tree, $.master, $, bt, 0, !1)), $.layout && B(O, "showMasterSp") !== !1 && lt.push(...at($.layout.tree, $.layout, $, bt, 0, !1)), lt.push(...at($.slide.tree, $.slide, $, bt, 0, !0)), P.push({
1229
- items: lt,
1230
- background: Rt,
1231
- transition: on(O),
1232
- name: k(c(O, "cSld"), "name") || void 0,
1233
- notes: nn(l, T),
1234
- key: T,
1235
- ...k(O, "show") === "0" && { hidden: !0 },
1236
- ..._t(O) && { advanceAfterMs: _t(O) },
1237
- ...N.has(T) && { section: N.get(T) }
1238
- });
1239
- }), P.length || o("The presentation has no slides.");
1240
- const L = A(l.xml("docProps/core.xml"), "title")?.textContent || void 0, X = l.relOfType(g, "presProps"), H = k(c(X ? l.xml(X) : null, "showPr"), "loop");
1241
- return { deck: { width: m, height: x, slides: P, title: L, ...(H === "1" || H === "true") && { loop: !0 } }, warnings: e };
1242
- }
1243
- const an = 80, ln = "default-layer", F = (t) => {
1244
- if (!t) return "transparent";
1245
- if (t.alpha === void 0 || t.alpha >= 0.999) return t.hex;
1246
- const n = t.hex.replace("#", "");
1247
- return `rgba(${parseInt(n.slice(0, 2), 16)}, ${parseInt(n.slice(2, 4), 16)}, ${parseInt(n.slice(4, 6), 16)}, ${+t.alpha.toFixed(3)})`;
1248
- }, cn = /(times|georgia|garamond|cambria|book|serif|palatino|baskerville|merriweather)/i, fn = /(courier|consolas|mono|menlo|code)/i;
1249
- function Ut(t) {
1250
- if (!t) return "sans-serif";
1251
- const n = ge(t);
1252
- return n || (fn.test(t) ? "monospace" : cn.test(t) ? "serif" : "sans-serif");
1253
- }
1254
- function dn(t) {
1255
- const n = [];
1256
- let e = [], o = !1;
1257
- const s = () => {
1258
- if (e.length >= 2) {
1259
- const r = e[0], a = e[e.length - 1];
1260
- 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 });
1261
- }
1262
- e = [], o = !1;
1263
- };
1264
- for (const r of t)
1265
- if (r.op === "M")
1266
- s(), e.push({ x: r.x, y: r.y, kind: "corner" });
1267
- else if (r.op === "L")
1268
- e.length ? e.push({ x: r.x, y: r.y, kind: "corner" }) : e.push({ x: r.x, y: r.y, kind: "corner" });
1269
- else if (r.op === "C") {
1270
- const a = e[e.length - 1];
1271
- if (!a) {
1272
- e.push({ x: r.x, y: r.y, kind: "corner" });
1273
- continue;
1274
- }
1275
- 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" });
1276
- } else r.op === "Z" && (o = !0, s());
1277
- return s(), n;
1278
- }
1279
- const un = (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 });
1280
- function hn(t, n) {
1281
- if (!t) return null;
1282
- if (t.kind === "url") return t.url;
1283
- if (t.kind === "action") return pe(t.action);
1284
- const e = n.slideIds?.get(t.key);
1285
- return e ? me(e) : null;
1286
- }
1287
- async function pn(t) {
1288
- if (!(typeof document > "u"))
1289
- try {
1290
- const n = new Image();
1291
- n.src = t, await n.decode();
1292
- const e = document.createElement("canvas");
1293
- e.width = Math.max(1, Math.min(8192, n.naturalWidth)), e.height = Math.max(1, Math.min(8192, n.naturalHeight));
1294
- const o = e.getContext("2d");
1295
- 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;
1296
- } catch {
1297
- return;
1298
- }
1299
- }
1300
- async function mn(t, n) {
1301
- const e = /* @__PURE__ */ new Set(), o = (r) => {
1302
- for (const a of r)
1303
- if (a.kind === "group") o(a.children);
1304
- else if (a.kind === "picture" && a.grayscale) {
1305
- const i = n.get(a.media)?.url;
1306
- i && e.add(i);
1307
- } else if (a.kind === "shape" && a.fill.kind === "image" && a.fill.grayscale) {
1308
- const i = n.get(a.fill.media)?.url;
1309
- i && e.add(i);
1310
- }
1311
- };
1312
- t.slides.forEach((r) => o(r.items));
1313
- const s = /* @__PURE__ */ new Map();
1314
- return await Promise.all([...e].map(async (r) => {
1315
- const a = await pn(r);
1316
- a && s.set(r, a);
1317
- })), s;
1318
- }
1319
- async function gn(t, n, e, o) {
1320
- if (!(typeof document > "u"))
1321
- try {
1322
- const s = new Image();
1323
- s.src = t, await s.decode();
1324
- const r = document.createElement("canvas");
1325
- r.width = Math.max(1, Math.min(4096, Math.round(n))), r.height = Math.max(1, Math.min(4096, Math.round(e)));
1326
- const a = r.getContext("2d");
1327
- if (!a) return;
1328
- if (o) {
1329
- const i = a.createPattern(s, "repeat");
1330
- if (!i) return;
1331
- i.setTransform(new DOMMatrix().scale(o.sx, o.sy)), a.fillStyle = i, a.fillRect(0, 0, r.width, r.height);
1332
- } else {
1333
- if (Math.abs(s.naturalWidth / s.naturalHeight - n / e) < 0.01) return;
1334
- a.drawImage(s, 0, 0, r.width, r.height);
1335
- }
1336
- return r.toDataURL(o ? "image/png" : "image/jpeg", 0.92);
1337
- } catch {
1338
- return;
1339
- }
1340
- }
1341
- function Q(t, n, e, o) {
1342
- return {
1343
- id: t.nextId(n),
1344
- type: n,
1345
- x: e.x + t.ox,
1346
- y: e.y + t.oy,
1347
- width: Math.max(e.w, 1),
1348
- height: Math.max(e.h, 1),
1349
- angle: e.rot ? e.rot * Math.PI / 180 : 0,
1350
- flipX: e.flipH || void 0,
1351
- flipY: e.flipV || void 0,
1352
- strokeColor: "transparent",
1353
- backgroundColor: "transparent",
1354
- fillStyle: "solid",
1355
- strokeWidth: 0,
1356
- strokeStyle: "solid",
1357
- roughness: 0,
1358
- renderStyle: "architectural",
1359
- opacity: 100,
1360
- seed: 1,
1361
- locked: !1,
1362
- layerId: ln,
1363
- groupIds: [...o].reverse(),
1364
- // innermost first, the store's convention
1365
- name: e.name
1366
- };
1367
- }
1368
- function Gt(t, n, e) {
1369
- switch (n.kind) {
1370
- case "none":
1371
- t.backgroundColor = "transparent";
1372
- break;
1373
- case "solid":
1374
- t.backgroundColor = F(n.color), t.fillStyle = "solid";
1375
- break;
1376
- case "linear":
1377
- case "radial":
1378
- t.fillStyle = n.kind, t.backgroundColor = F(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: F(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1379
- break;
1380
- case "pattern": {
1381
- t.backgroundColor = F(n.color), t.fillStyle = "pattern", t.patternFill = Tn(n.preset, F(n.color), n.bg ? F(n.bg) : "transparent");
1382
- break;
1383
- }
1384
- case "image": {
1385
- const o = e.images.get(n.media);
1386
- 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);
1387
- break;
1388
- }
1389
- }
1390
- }
1391
- function Mt(t, n) {
1392
- if (!n || !(n.width > 0)) {
1393
- t.strokeColor = "transparent", t.strokeWidth = 0;
1394
- return;
1395
- }
1396
- t.strokeColor = F(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");
1397
- }
1398
- function xn(t) {
1399
- const n = /^(alphaLc|alphaUc|arabic|romanLc|romanUc)(ParenBoth|ParenR|Period|Plain)$/.exec(t ?? "");
1400
- if (!n) return {};
1401
- 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 = {};
1402
- return e && (s.listNumberStyle = e), o && (s.listNumberSuffix = o), s;
1403
- }
1404
- function bn(t, n) {
1405
- const e = t.bullet === "num" ? xn(t.numType) : t.bulletChar ? { listMarker: t.bulletChar } : {}, o = t.runs.find((s) => !s.br)?.color ?? n.defaults?.color;
1406
- return t.bulletColor && F(t.bulletColor) !== F(o) && (e.listMarkerColor = F(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;
1407
- }
1408
- const kt = (t, n) => Math.round(((t.paragraphs[n - 1]?.spaceAfter ?? 0) + (t.paragraphs[n]?.spaceBefore ?? 0)) * 100) / 100;
1409
- function se(t, n) {
1410
- const e = t.paragraphs.flatMap((h) => h.runs.filter((y) => !y.br)), o = e[0], s = o?.size ?? 24, r = /* @__PURE__ */ new Map(), a = (h) => h.runs.reduce((y, u) => y + (u.br ? 0 : u.text.trim().length), 0);
1411
- for (const h of t.paragraphs) {
1412
- const y = a(h);
1413
- y && r.set(h.align ?? "l", (r.get(h.align ?? "l") ?? 0) + y);
1414
- }
1415
- const i = [...r].sort((h, y) => y[1] - h[1])[0]?.[0] ?? t.paragraphs.find((h) => h.runs.length)?.align ?? "l", l = (h) => a(h) > 0 && (h.align ?? "l") !== i ? h.align === "ctr" ? "center" : h.align === "r" ? "right" : "left" : void 0, g = e.every((h) => h.size === o?.size && h.bold === o?.bold && h.italic === o?.italic && h.underline === o?.underline && h.strike === o?.strike && h.font === o?.font && F(h.color) === F(o?.color)) && !t.paragraphs.some((h) => h.bullet) && !t.paragraphs.some((h, y) => y > 0 && kt(t, y) > 0) && !t.paragraphs.some(l), b = {
1416
- fontSize: Math.round(s * 10) / 10,
1417
- fontFamily: Ut(o?.font),
1418
- textAlign: i === "ctr" ? "center" : i === "r" ? "right" : "left",
1419
- verticalAlign: t.anchor === "ctr" ? "middle" : t.anchor === "b" ? "bottom" : "top",
1420
- textColor: F(o?.color ?? { hex: "#000000" })
1421
- };
1422
- t.lineSpacing && Math.abs(t.lineSpacing - 1) > 0.01 && (b.lineHeight = Math.max(0.5, Math.min(4, t.lineSpacing * 1.2)));
1423
- const d = t.paragraphs.map((h) => h.runs.map((y) => y.br ? `
1424
- ` : y.text).join("")).join(`
1425
- `);
1426
- if (g)
1427
- return o?.bold && (b.fontWeight = 700), o?.italic && (b.fontStyle = "italic"), n ? b.containerText = d : b.text = d, { fields: b, rich: !1 };
1428
- const m = [], x = [], f = [];
1429
- return t.paragraphs.forEach((h, y) => {
1430
- const u = h.level ?? 0;
1431
- if (h.bullet === "num") {
1432
- const M = h.numType ?? "arabicPeriod";
1433
- (x[u] === void 0 || f[u] !== M) && (x[u] = (h.startAt ?? 1) - 1), x[u]++, f[u] = M, x.length = u + 1, f.length = u + 1;
1434
- } else
1435
- x.length = Math.min(x.length, u), f.length = x.length;
1436
- const p = h.bullet ? { listType: h.bullet === "num" ? "ordered" : "bullet", listLevel: u, ...bn(h, t) } : {};
1437
- h.bullet === "num" && (p.listIndex = x[u]), (h.runs.length ? h.runs : [{ text: "" }]).forEach((M, S) => {
1438
- const v = { text: M.br ? `
1439
- ` : M.text, ...S === 0 ? p : {} };
1440
- S === 0 && y > 0 && kt(t, y) > 0 && (v.paragraphSpaceBefore = kt(t, y));
1441
- const N = l(h);
1442
- N && (v.paragraphAlign = N), M.bold && (v.bold = !0), M.italic && (v.italic = !0), M.underline && (v.underline = !0), M.strike && (v.strikethrough = !0), M.color && (v.color = F(M.color)), M.size && (v.fontSize = Math.round(M.size * 10) / 10), M.font && (v.fontFamily = Ut(M.font)), m.push(v);
1443
- }), y < t.paragraphs.length - 1 && m.push({ text: `
1444
- ` });
1445
- }), n ? (b.richContainerText = m, b.containerText = d) : (b.richText = m, b.text = d), { fields: b, rich: !0 };
1446
- }
1447
- function wt(t, n, e, o, s) {
1448
- const { fields: r, rich: a } = se(n, !1), i = 4, l = Q(t, a ? "richtext" : "text", {
1449
- ...e,
1450
- x: e.x + n.insets.l - i,
1451
- y: e.y + n.insets.t - i,
1452
- w: Math.max(e.w - n.insets.l - n.insets.r + i * 2, 8),
1453
- h: Math.max(e.h - n.insets.t - n.insets.b + i * 2, 8)
1454
- }, o);
1455
- return Object.assign(l, r, { autoResize: !n.wrap, strokeColor: r.textColor }), l;
1456
- }
1457
- const re = /* @__PURE__ */ new Set(["line", "straightConnector1"]);
1458
- function ae(t, n, e) {
1459
- const o = t.geom;
1460
- if (t.text && t.fill.kind === "none" && !t.line && (t.textBox || o.kind === "preset" && o.prst === "rect"))
1461
- return n.stats.elements++, [wt(n, t.text, t, e)];
1462
- if (o.kind === "preset" && re.has(o.prst)) return vt({ ...t, kind: "connector", line: t.line ?? { width: 1, color: { hex: "#000000" } } }, n, e);
1463
- if (o.kind === "custom" && t.line && (t.line.head || t.line.tail) && !t.text && o.paths.every((d) => !d.cmds.some((m) => m.op === "Z")))
1464
- return vt({ ...t, kind: "connector", line: t.line }, n, e);
1465
- const s = kn(t);
1466
- if (s) {
1467
- const d = Q(n, s.type, t, e);
1468
- Object.assign(d, s.extra), Gt(d, t.fill, n), Mt(d, t.line), n.byPptId.set(t.id, { el: d, item: t }), n.stats.elements++;
1469
- const m = t.textRect ?? { l: 0, t: 0, r: t.w, b: t.h }, x = t.text?.insets, f = Math.abs(m.l) > 0.5 || Math.abs(m.t) > 0.5 || Math.abs(m.r - t.w) > 0.5 || Math.abs(m.b - t.h) > 0.5, h = !!x && Math.max(x.l, x.r, x.t, x.b) > 16;
1470
- if (t.text && (f || h)) {
1471
- const y = n.nextId("group");
1472
- return d.groupIds = [...e, y].reverse(), n.stats.elements++, [d, wt(n, t.text, { ...t, rot: 0, x: t.x + m.l, y: t.y + m.t, w: m.r - m.l, h: m.b - m.t }, [...e, y])];
1473
- }
1474
- if (t.text) {
1475
- const { fields: y } = se(t.text, !0);
1476
- Object.assign(d, y);
1477
- }
1478
- return [d];
1479
- }
1480
- const r = o.kind === "custom" ? o.paths : (() => {
1481
- const d = n.presets[o.prst];
1482
- if (!d)
1483
- return n.warnings.push(`Unknown shape "${o.prst}" was imported as a rectangle.`), ft(n.presets.rect, t.w, t.h);
1484
- const m = Object.fromEntries(Object.entries(o.adj ?? {}).map(([x, f]) => [x, `val ${f}`]));
1485
- return ft(d, t.w, t.h, m);
1486
- })(), a = [], i = (t.text || r.some((d) => d.fill === !1)) && r.some((d) => d.fill !== !1) ? n.nextId("group") : null, l = i ? [...e, i] : e, g = /* @__PURE__ */ new Map();
1487
- for (const d of r) {
1488
- const m = `${d.fill === !1 ? "nofill" : "fill"}|${d.stroke === !1 ? "nostroke" : "stroke"}`;
1489
- g.has(m) || g.set(m, []), g.get(m).push(d);
1490
- }
1491
- let b = null;
1492
- for (const [d, m] of g) {
1493
- const x = m.flatMap((p) => p.cmds), f = ue(x);
1494
- if (!f) continue;
1495
- const h = dn(un(x, -f.minX, -f.minY));
1496
- if (!h.length) continue;
1497
- const y = Q(n, "path", { ...t, x: t.x + f.minX, y: t.y + f.minY, w: Math.max(f.maxX - f.minX, 1), h: Math.max(f.maxY - f.minY, 1) }, l);
1498
- !(Math.abs(f.minX + f.maxX - t.w) < 0.5 && Math.abs(f.minY + f.maxY - t.h) < 0.5) && (t.rot || t.flipH || t.flipV) && yn(y, h, t, f), y.pathSubpaths = h, y.pathAnchors = h[0].anchors, y.pathClosed = h[0].closed, d.startsWith("fill") ? Gt(y, t.fill, n) : y.backgroundColor = "transparent", d.endsWith("|stroke") ? Mt(y, t.line) : (y.strokeColor = "transparent", y.strokeWidth = 0), a.push(y), b ??= y, n.stats.paths++;
1499
- }
1500
- if (b && n.byPptId.set(t.id, { el: b, item: t }), t.text) {
1501
- const d = t.textRect ?? (o.kind === "preset" && n.presets[o.prst] ? Kt(n.presets[o.prst], t.w, t.h) : { l: 0, t: 0, r: t.w, b: t.h });
1502
- a.push(wt(n, t.text, { ...t, x: t.x + d.l, y: t.y + d.t, w: d.r - d.l, h: d.b - d.t }, l));
1503
- }
1504
- return n.stats.elements += a.length, a;
1505
- }
1506
- function yn(t, n, e, o) {
1507
- const s = e.w / 2, r = e.h / 2, a = (e.rot || 0) * Math.PI / 180, i = Math.cos(a), l = Math.sin(a), g = e.flipH ? -1 : 1, b = e.flipV ? -1 : 1, d = (u, p) => {
1508
- const w = (u + o.minX - s) * g, M = (p + o.minY - r) * b;
1509
- return { x: s + w * i - M * l, y: r + w * l + M * i };
1510
- }, m = (u, p) => {
1511
- const w = u * g, M = p * b;
1512
- return { x: w * i - M * l, y: w * l + M * i };
1513
- };
1514
- let x = 1 / 0, f = 1 / 0, h = -1 / 0, y = -1 / 0;
1515
- for (const u of n) for (const p of u.anchors) {
1516
- const w = d(p.x, p.y);
1517
- if (p.x = w.x, p.y = w.y, p.inX !== void 0) {
1518
- const M = m(p.inX, p.inY ?? 0);
1519
- p.inX = M.x, p.inY = M.y;
1520
- }
1521
- if (p.outX !== void 0) {
1522
- const M = m(p.outX, p.outY ?? 0);
1523
- p.outX = M.x, p.outY = M.y;
1524
- }
1525
- x = Math.min(x, p.x), f = Math.min(f, p.y), h = Math.max(h, p.x), y = Math.max(y, p.y);
1526
- }
1527
- for (const u of n) for (const p of u.anchors)
1528
- p.x -= x, p.y -= f;
1529
- t.x = t.x - o.minX + x, t.y = t.y - o.minY + f, t.width = Math.max(h - x, 1), t.height = Math.max(y - f, 1), t.angle = 0, t.flipX = void 0, t.flipY = void 0;
1530
- }
1531
- function kn(t) {
1532
- const n = t.geom;
1533
- if (n.kind !== "preset") return null;
1534
- const e = n.adj ?? {};
1535
- switch (n.prst) {
1536
- case "rect":
1537
- return { type: "rectangle", extra: { borderRadius: 0 } };
1538
- case "roundRect":
1539
- return { type: "rectangle", extra: { borderRadius: Math.max(0, Math.min(50, (e.adj ?? 16667) / 1e3)) } };
1540
- case "ellipse":
1541
- return { type: "circle", extra: {} };
1542
- case "diamond":
1543
- return { type: "diamond", extra: { borderRadius: 0 } };
1544
- case "triangle":
1545
- return (e.adj ?? 5e4) === 5e4 ? { type: "triangle", extra: {} } : null;
1546
- default:
1547
- return null;
1548
- }
1549
- }
1550
- const Vt = { triangle: "triangle", stealth: "arrow", arrow: "arrow", oval: "dot", diamond: "diamondFilled" };
1551
- function vt(t, n, e) {
1552
- const o = t.geom;
1553
- let s;
1554
- if (o.kind === "preset" && re.has(o.prst)) s = [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1555
- else if (o.kind === "custom") s = o.paths.flatMap((w) => w.cmds);
1556
- else {
1557
- const w = n.presets[o.prst], M = Object.fromEntries(Object.entries(o.adj ?? {}).map(([S, v]) => [S, `val ${v}`]));
1558
- s = w ? ft(w, t.w, t.h, M).flatMap((S) => S.cmds) : [{ op: "M", x: 0, y: 0 }, { op: "L", x: t.w, y: t.h }];
1559
- }
1560
- const r = t.w / 2, a = t.h / 2, i = (t.rot || 0) * Math.PI / 180, l = (w, M) => {
1561
- let S = w - r, v = M - a;
1562
- 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) };
1563
- }, g = [];
1564
- let b = { x: 0, y: 0 };
1565
- for (const w of s)
1566
- if (w.op === "M" || w.op === "L")
1567
- b = { x: w.x, y: w.y }, g.push(l(b.x, b.y));
1568
- else if (w.op === "C") {
1569
- for (let M = 1; M <= 12; M++) {
1570
- const S = M / 12, v = 1 - S, N = v * v * v * b.x + 3 * v * v * S * w.x1 + 3 * v * S * S * w.x2 + S * S * S * w.x, P = v * v * v * b.y + 3 * v * v * S * w.y1 + 3 * v * S * S * w.y2 + S * S * S * w.y;
1571
- g.push(l(N, P));
1572
- }
1573
- b = { x: w.x, y: w.y };
1574
- }
1575
- if (g.length < 2) return [];
1576
- const d = Math.min(...g.map((w) => w.x)), m = Math.min(...g.map((w) => w.y)), x = Math.max(...g.map((w) => w.x)), f = Math.max(...g.map((w) => w.y)), h = t.line.head && Vt[t.line.head.type], y = t.line.tail && Vt[t.line.tail.type], u = Q(n, h || y ? "arrow" : "line", { ...t, x: d, y: m, w: Math.max(x - d, 1), h: Math.max(f - m, 1), rot: 0, flipH: !1, flipV: !1 }, e);
1577
- u.points = g.map((w) => ({ x: w.x - d, y: w.y - m })), u.curveType = "straight", u.startArrowhead = h ?? null, u.endArrowhead = y ?? null, Mt(u, t.line);
1578
- const p = (w, M) => {
1579
- if (!w) return null;
1580
- const S = n.byPptId.get(w.id);
1581
- if (!S || !S.el.width || !S.el.height) return null;
1582
- const v = S.el;
1583
- 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 };
1584
- };
1585
- return n.glue.push(() => {
1586
- u.startBinding = p(t.start, g[0]), u.endBinding = p(t.end, g[g.length - 1]);
1587
- }), n.stats.elements++, [u];
1588
- }
1589
- function wn(t, n, e) {
1590
- const o = n.images.get(t.media);
1591
- if (!o) {
1592
- n.warnings.push(`Picture "${t.name}" is a ${t.media.ext.toUpperCase()} image, which browsers can't show; it was imported as a placeholder.`);
1593
- const l = Q(n, "rectangle", t, e);
1594
- return Object.assign(l, { backgroundColor: "#f1f3f5", strokeColor: "#adb5bd", strokeWidth: 1, strokeStyle: "dashed", containerText: `${t.media.ext.toUpperCase()} picture`, fontSize: 14, textColor: "#495057" }), n.stats.elements++, [l];
1595
- }
1596
- const s = Q(n, "image", t, e);
1597
- if (s.dataURL = t.grayscale && n.gray.get(o.url) || o.url, s.status = "loaded", s.mimeType = St[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];
1598
- const r = n.nextId("group"), a = ae({
1599
- kind: "shape",
1600
- id: t.id,
1601
- name: `${t.name} outline`,
1602
- x: t.x,
1603
- y: t.y,
1604
- w: t.w,
1605
- h: t.h,
1606
- rot: t.rot,
1607
- flipH: t.flipH,
1608
- flipV: t.flipV,
1609
- geom: t.geom,
1610
- fill: { kind: "solid", color: { hex: "#000000" } },
1611
- line: null
1612
- }, n, [...e, r]);
1613
- if (a.length !== 1)
1614
- return n.stats.elements -= a.length, [s];
1615
- const i = a[0];
1616
- return i.isClipMask = !0, s.groupIds = [r, ...s.groupIds], s.clipMaskId = i.id, s.maskType = "clip", [s, i];
1617
- }
1618
- function ie(t, n, e) {
1619
- const o = [];
1620
- for (const s of t)
1621
- try {
1622
- const r = [];
1623
- switch (s.kind) {
1624
- case "shape":
1625
- r.push(...ae(s, n, e));
1626
- break;
1627
- case "connector":
1628
- r.push(...vt(s, n, e));
1629
- break;
1630
- case "picture":
1631
- r.push(...wn(s, n, e));
1632
- break;
1633
- case "group":
1634
- r.push(...ie(s.children, n, [...e, n.nextId("group")]));
1635
- break;
1636
- }
1637
- const a = hn(s.link, n);
1638
- if (a)
1639
- for (const i of r) i.link || (i.link = a);
1640
- o.push(...r);
1641
- } catch {
1642
- n.warnings.push(`"${s.name}" couldn't be converted and was skipped.`);
1643
- }
1644
- return o;
1645
- }
1646
- function Mn(t) {
1647
- return t ? { type: t.kind === "morph" ? "morph" : 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;
1648
- }
1649
- function vn(t, n, e) {
1650
- if (n)
1651
- if (n.kind === "solid")
1652
- t.fillStyle = "solid", t.backgroundColor = F(n.color);
1653
- else if (n.kind === "linear" || n.kind === "radial")
1654
- t.fillStyle = n.kind, t.backgroundColor = F(n.stops[0]?.color), t.gradientStops = n.stops.map((o) => ({ offset: o.pos, color: F(o.color) })), n.kind === "linear" && (t.gradientDirection = n.angle);
1655
- else if (n.kind === "image") {
1656
- const o = e.images.get(n.media), s = e.slideBg ?? o?.url;
1657
- s && (t.fillStyle = "image", t.backgroundImage = s, t.backgroundColor = "#ffffff"), s && n.alpha !== void 0 && n.alpha < 1 && (t.backgroundOpacity = n.alpha);
1658
- } else n.kind === "pattern" && (t.fillStyle = "solid", t.backgroundColor = F(n.color));
1659
- }
1660
- const St = {
1661
- png: "image/png",
1662
- jpeg: "image/jpeg",
1663
- gif: "image/gif",
1664
- svg: "image/svg+xml",
1665
- bmp: "image/bmp",
1666
- tiff: "image/tiff",
1667
- webp: "image/webp",
1668
- emf: "image/x-emf",
1669
- wmf: "image/x-wmf"
1670
- }, Sn = /* @__PURE__ */ new Set(["png", "jpeg", "gif", "svg", "bmp", "webp"]);
1671
- function Cn(t) {
1672
- let n = "";
1673
- for (let o = 0; o < t.length; o += 32768) n += String.fromCharCode(...t.subarray(o, o + 32768));
1674
- return btoa(n);
1675
- }
1676
- async function Pn(t) {
1677
- const n = /* @__PURE__ */ new Set(), e = (s) => {
1678
- for (const r of s)
1679
- 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);
1680
- };
1681
- for (const s of t.slides)
1682
- e(s.items), s.background?.kind === "image" && n.add(s.background.media);
1683
- const o = /* @__PURE__ */ new Map();
1684
- return await Promise.all([...n].map(async (s) => {
1685
- if (!Sn.has(s.ext)) {
1686
- o.set(s, null);
1687
- return;
1688
- }
1689
- const r = `data:${St[s.ext]};base64,${Cn(s.bytes)}`;
1690
- let a = 0, i = 0;
1691
- try {
1692
- const l = await createImageBitmap(new Blob([s.bytes], { type: St[s.ext] }));
1693
- a = l.width, i = l.height, l.close();
1694
- } catch {
1695
- }
1696
- o.set(s, { url: r, w: a, h: i });
1697
- })), o;
1698
- }
1699
- function Tn(t, n, e) {
1700
- 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);
1701
- if (a) {
1702
- const i = Math.max(1, Math.min(99, Number(a[1]))), l = i > 50, g = (l ? 100 - i : i) / 100;
1703
- return { type: "dots", color: l ? e : n, background: l ? n : e, spacing: 4, strokeWidth: Math.max(0.5, 4 * Math.sqrt(g / Math.PI)) };
1704
- }
1705
- 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 };
1706
- }
1707
- async function In(t, n, e) {
1708
- const o = await ve(), s = await Pn(t), r = Math.round(t.width), a = Math.round(t.height), i = he(e ?? t.title, "slides", { width: r, height: a }), l = [], g = { slides: 0, elements: 0, pictures: 0, paths: 0 };
1709
- i.slides = [];
1710
- const b = await mn(t, s), d = await Promise.all(t.slides.map((f) => {
1711
- const h = f.background, y = h?.kind === "image" ? s.get(h.media) : void 0;
1712
- return h?.kind === "image" && y ? gn(y.url, r, a, h.tile) : void 0;
1713
- })), m = t.slides.map(() => n("slide")), x = /* @__PURE__ */ new Map();
1714
- return t.slides.forEach((f, h) => {
1715
- f.key && x.set(f.key, m[h]);
1716
- }), t.slides.forEach((f, h) => {
1717
- const y = h * (r + an), u = Lt(m[h], f.name || `Slide ${h + 1}`, y, 0, { width: r, height: a });
1718
- u.order = h;
1719
- const p = { ox: y, oy: 0, presets: o, nextId: n, out: [], byPptId: /* @__PURE__ */ new Map(), glue: [], warnings: l, stats: g, images: s, slideBg: d[h], gray: b, slideIds: x };
1720
- i.elements.push(...ie(f.items, p, [])), p.glue.forEach((M) => M()), vn(u, f.background, p);
1721
- const w = Mn(f.transition);
1722
- w && (u.transition = w), f.notes && (u.notes = f.notes), f.hidden && (u.hidden = !0), f.advanceAfterMs && (u.advanceAfter = f.advanceAfterMs), f.section && (u.section = f.section), i.slides.push(u), g.slides++;
1723
- }), i.slides.length || i.slides.push(Lt(void 0, "Slide 1", 0, 0, { width: r, height: a })), t.loop && (i.globalSettings = { ...i.globalSettings || {}, slideShowLoop: !0 }), { doc: i, warnings: [...new Set(l)], stats: g };
1724
- }
1725
- const Nn = 512 * 1024 * 1024;
1726
- async function Ln(t, n) {
1727
- const e = t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(await t.arrayBuffer());
1728
- if (e.length > Nn) throw new Error("This presentation is too large to open (over 512 MB).");
1729
- const { deck: o, warnings: s } = rn(e), r = /* @__PURE__ */ new Set(), a = await In(o, (l) => be(l, r), n);
1730
- xe(a.doc);
1731
- const i = [...s, ...a.warnings];
1732
- return i.length && console.warn("[pptx import]", i), { stats: a.stats, warnings: i };
1733
- }
1734
- export {
1735
- Ln as importPptx
1736
- };