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