@algorisys/yappydraw 0.8.296 → 0.8.297

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 (26) 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-cwK_LwEk.js} +1 -1
  4. package/chunks/{choice-dialog-state-BUFvjtpq.js → choice-dialog-state-CF9ddIAk.js} +1 -1
  5. package/chunks/{custgeom-DThQ1Qnp.js → custgeom-N1NlyQKZ.js} +1 -1
  6. package/chunks/{design-generator-BlrBbMDM.js → design-generator-DSEgwQ7i.js} +1 -1
  7. package/chunks/{drawing-engine-KJLwmUE-.js → drawing-engine-CPFaJPyz.js} +1 -1
  8. package/chunks/{drawings-store-CiDEeh5h.js → drawings-store-CxGNbTN7.js} +1 -1
  9. package/chunks/{ds-operations-C27tW9qb.js → ds-operations-BTcGLr6X.js} +1 -1
  10. package/chunks/{export-game-Bcz0A67O.js → export-game-BVjxTYD1.js} +1 -1
  11. package/chunks/{from-yappy-lL1q0m9y.js → from-yappy-kTebD-0Y.js} +269 -239
  12. package/chunks/{game-runtime-RZ6Ygr7N.js → game-runtime-Ch0y0mLm.js} +27 -27
  13. package/chunks/{import-DFZ1uZOp.js → import-eCGTFoVi.js} +697 -619
  14. package/chunks/{index-NbpsufU1.js → index-zg1eC33A.js} +1941 -1936
  15. package/chunks/{lucide-solid-DL_MnmQm.js → lucide-solid-DAmszm-d.js} +1 -1
  16. package/chunks/{markdown-to-slides-D9CoIzTi.js → markdown-to-slides-CGvmGrK2.js} +1 -1
  17. package/chunks/{morph-animator-C_rDbafN.js → morph-animator-BQPPQ08b.js} +1 -1
  18. package/chunks/{onboarding-tour-B1fDeTqe.js → onboarding-tour-CpRCV3Ub.js} +1 -1
  19. package/chunks/{pdf-vector-ByOSpRwK.js → pdf-vector-D65OC03c.js} +1 -1
  20. package/chunks/{search-MWY5OrgG.js → search-rp-eRNJ6.js} +2 -2
  21. package/chunks/{slide-generator-8-amet_R.js → slide-generator-Ctxdc9Yn.js} +5 -5
  22. package/chunks/{turntable-ai-DgSAtAc8.js → turntable-ai-ZhAGEjzz.js} +1 -1
  23. package/chunks/write-ZW6FSyj1.js +327 -0
  24. package/package.json +1 -1
  25. package/yappy.js +1 -1
  26. package/chunks/write-B1-j7TNq.js +0 -265
@@ -1,7 +1,8 @@
1
- import { a1 as et, a2 as pt, a3 as mt, a4 as xt, a5 as gt, a6 as yt, a7 as kt, a8 as bt, a9 as G, aa as Mt, ab as wt, ac as vt, ad as St, ae as At, af as $t, ag as It, ah as Ct, ai as Tt, aj as Ft, ak as Pt, al as zt } from "./index-NbpsufU1.js";
2
- import { d as z, g as j, t as C, h as Lt } from "./custgeom-DThQ1Qnp.js";
3
- function Et(t) {
4
- const { l: n, c: e, h: r } = t, i = r * Math.PI / 180, o = e * Math.cos(i), l = e * Math.sin(i), f = n + 0.3963377774 * o + 0.2158037573 * l, s = n - 0.1055613458 * o - 0.0638541728 * l, a = n - 0.0894841775 * o - 1.291485548 * l, c = f * f * f, u = s * s * s, p = a * a * a, d = 1.2270138511 * c - 0.5577999807 * u + 0.2812561489 * p, h = -0.0405801784 * c + 1.1122568696 * u - 0.0716766787 * p, x = -0.0763812845 * c - 0.4214819787 * u + 1.5861632204 * p, g = 2.4039459 * d - 0.9898517 * h - 0.4141151 * x, k = -0.7797967 * d + 1.5445214 * h + 0.0352745 * x, m = 0.0384795 * d - 0.1141381 * h + 1.0756786 * x, y = (b) => {
1
+ import { a1 as rt, a2 as mt, a3 as xt, a4 as gt, a5 as yt, a6 as kt, a7 as bt, a8 as Mt, a9 as wt, aa as G, ab as vt, ac as St, ad as At, ae as $t, af as It, ag as Ct, ah as Tt, ai as Ft, aj as Pt, ak as zt, al as Lt, am as Et } from "./index-zg1eC33A.js";
2
+ import { t as Ot } from "./anim-map-D7T1mIAM.js";
3
+ import { d as z, g as j, t as C, h as Rt } from "./custgeom-N1NlyQKZ.js";
4
+ function Xt(t) {
5
+ const { l: n, c: e, h: r } = t, i = r * Math.PI / 180, o = e * Math.cos(i), l = e * Math.sin(i), f = n + 0.3963377774 * o + 0.2158037573 * l, a = n - 0.1055613458 * o - 0.0638541728 * l, s = n - 0.0894841775 * o - 1.291485548 * l, c = f * f * f, u = a * a * a, h = s * s * s, p = 1.2270138511 * c - 0.5577999807 * u + 0.2812561489 * h, d = -0.0405801784 * c + 1.1122568696 * u - 0.0716766787 * h, x = -0.0763812845 * c - 0.4214819787 * u + 1.5861632204 * h, g = 2.4039459 * p - 0.9898517 * d - 0.4141151 * x, k = -0.7797967 * p + 1.5445214 * d + 0.0352745 * x, m = 0.0384795 * p - 0.1141381 * d + 1.0756786 * x, y = (b) => {
5
6
  const M = Math.abs(b), w = M > 31308e-7 ? 1.055 * Math.pow(M, 1 / 2.4) - 0.055 : 12.92 * M;
6
7
  return b < 0 ? -w : w;
7
8
  };
@@ -27,7 +28,7 @@ function V(t, n, e) {
27
28
  b: R(-0.019637554590334 * r - 0.07863604555063188 * i + 1.0982736001409656 * o)
28
29
  };
29
30
  }
30
- function Ot(t) {
31
+ function Dt(t) {
31
32
  return t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
32
33
  }
33
34
  function T(t) {
@@ -40,27 +41,27 @@ function T(t) {
40
41
  }
41
42
  const e = (o) => Math.round(Math.max(0, Math.min(1, o)) * 255), r = n.match(/^color\(\s*(display-p3|srgb)\s+([^/)]+?)\s*(?:\/[^)]*)?\)$/);
42
43
  if (r) {
43
- const o = r[2].split(/[\s,]+/).filter(Boolean).map(Ot);
44
+ const o = r[2].split(/[\s,]+/).filter(Boolean).map(Dt);
44
45
  if (o.length < 3 || o.some((c) => !isFinite(c))) return null;
45
- const [l, f, s] = o;
46
- if (r[1] === "srgb") return [e(l), e(f), e(s)];
47
- const a = V(l, f, s);
48
- return [e(a.r), e(a.g), e(a.b)];
46
+ const [l, f, a] = o;
47
+ if (r[1] === "srgb") return [e(l), e(f), e(a)];
48
+ const s = V(l, f, a);
49
+ return [e(s.r), e(s.g), e(s.b)];
49
50
  }
50
51
  const i = n.match(/^oklch\(\s*([^/)]+?)\s*(?:\/[^)]*)?\)$/);
51
52
  if (i) {
52
53
  const o = i[1].split(/[\s,]+/).filter(Boolean);
53
54
  if (o.length < 3) return null;
54
- const l = o[0].endsWith("%") ? parseFloat(o[0]) / 100 : parseFloat(o[0]), f = parseFloat(o[1]), s = parseFloat(o[2]);
55
- if (![l, f, s].every(isFinite)) return null;
56
- const a = V(...(({ r: c, g: u, b: p }) => [c, u, p])(Et({ l, c: f, h: s })));
57
- return [e(a.r), e(a.g), e(a.b)];
55
+ const l = o[0].endsWith("%") ? parseFloat(o[0]) / 100 : parseFloat(o[0]), f = parseFloat(o[1]), a = parseFloat(o[2]);
56
+ if (![l, f, a].every(isFinite)) return null;
57
+ const s = V(...(({ r: c, g: u, b: h }) => [c, u, h])(Xt({ l, c: f, h: a })));
58
+ return [e(s.r), e(s.g), e(s.b)];
58
59
  }
59
- return Rt(n);
60
+ return Bt(n);
60
61
  }
61
62
  const F = /* @__PURE__ */ new Map();
62
63
  let $;
63
- function Rt(t) {
64
+ function Bt(t) {
64
65
  if (F.has(t)) return F.get(t);
65
66
  let n = null;
66
67
  try {
@@ -79,7 +80,7 @@ function Rt(t) {
79
80
  return F.size < 512 && F.set(t, n), n;
80
81
  }
81
82
  const L = (t) => "#" + t.map((n) => n.toString(16).padStart(2, "0")).join("");
82
- function Xt(t) {
83
+ function Yt(t) {
83
84
  const n = t.trim().toLowerCase(), e = n.match(/^#([0-9a-f]{8})$/);
84
85
  if (e) return parseInt(e[1].slice(6), 16) / 255;
85
86
  const r = n.match(/^#([0-9a-f]{4})$/);
@@ -100,10 +101,10 @@ function S(t, n = 1) {
100
101
  if (!t) return null;
101
102
  const e = T(t);
102
103
  if (!e) return null;
103
- const r = Xt(t) * n;
104
+ const r = Yt(t) * n;
104
105
  return r <= 0 ? null : r < 0.999 ? { hex: L(e), alpha: r } : { hex: L(e) };
105
106
  }
106
- const rt = (t) => pt(t).split(",")[0].trim().replace(/^['"]|['"]$/g, "") || "Calibri", Y = {
107
+ const ot = (t) => mt(t).split(",")[0].trim().replace(/^['"]|['"]$/g, "") || "Calibri", Y = {
107
108
  hachure: "ltUpDiag",
108
109
  zigzag: "ltUpDiag",
109
110
  "zigzag-line": "ltUpDiag",
@@ -111,7 +112,7 @@ const rt = (t) => pt(t).split(",")[0].trim().replace(/^['"]|['"]$/g, "") || "Cal
111
112
  "cross-hatch": "diagCross",
112
113
  dots: "pct20"
113
114
  };
114
- function Bt(t, n) {
115
+ function Wt(t, n) {
115
116
  const e = t.fillStyle || "solid";
116
117
  if ((e === "linear" || e === "radial" || e === "conic") && (t.gradientStops?.length ?? 0) > 0) {
117
118
  const i = t.gradientStops.map((o) => ({ pos: Math.max(0, Math.min(1, o.offset)), color: S(o.color, n) ?? { hex: "#000000", alpha: 0 } }));
@@ -120,7 +121,7 @@ function Bt(t, n) {
120
121
  const r = S(t.backgroundColor, n);
121
122
  return r ? Y[e] ? { kind: "pattern", preset: Y[e], color: r } : { kind: "solid", color: r } : { kind: "none" };
122
123
  }
123
- function ot(t) {
124
+ function it(t) {
124
125
  if (t.strokeStyle === "dotted") return "sysDot";
125
126
  if (t.strokeStyle === "dashed") return "dash";
126
127
  if (Array.isArray(t.strokeDashArray) && t.strokeDashArray.length >= 2) {
@@ -135,7 +136,7 @@ function N(t, n, e = !1) {
135
136
  return {
136
137
  width: t.strokeWidth,
137
138
  color: r,
138
- dash: ot(t),
139
+ dash: it(t),
139
140
  cap: e ? i : void 0,
140
141
  join: t.strokeLineJoin === "miter" ? "miter" : t.strokeLineJoin === "bevel" ? "bevel" : "round"
141
142
  };
@@ -145,133 +146,133 @@ function J(t, n, e) {
145
146
  const r = n / Math.max(e, 0.5), i = r <= 2.5 ? "sm" : r <= 4 ? "med" : "lg";
146
147
  return { type: t === "triangle" ? "triangle" : t === "dot" || t === "circle" ? "oval" : t === "diamond" || t === "diamondFilled" ? "diamond" : "arrow", size: i };
147
148
  }
148
- const U = (t, n) => t === "center" ? "ctr" : t === "right" ? "r" : t === "left" ? "l" : n, it = (t) => t === "top" ? "t" : t === "bottom" ? "b" : "ctr";
149
- function st(t, n) {
149
+ const U = (t, n) => t === "center" ? "ctr" : t === "right" ? "r" : t === "left" ? "l" : n, st = (t) => t === "top" ? "t" : t === "bottom" ? "b" : "ctr";
150
+ function at(t, n) {
150
151
  return t.split(`
151
152
  `).map((e) => ({ runs: e ? [{ text: e }] : [], align: n }));
152
153
  }
153
- function Dt(t) {
154
+ function Ht(t) {
154
155
  const n = { "lower-alpha": "alphaLc", "upper-alpha": "alphaUc", "lower-roman": "romanLc", "upper-roman": "romanUc" }[t.listNumberStyle ?? ""] ?? "arabic", e = { paren: "ParenR", parens: "ParenBoth", none: "Plain" }[t.listNumberSuffix ?? ""] ?? "Period";
155
156
  return n + e;
156
157
  }
157
158
  let I;
158
- function Yt(t, n) {
159
+ function jt(t, n) {
159
160
  if (I === void 0 && (I = typeof document < "u" ? document.createElement("canvas").getContext("2d") : null), I)
160
161
  return I.font = n, I.measureText(t).width;
161
162
  const e = Number(/(\d+(?:\.\d+)?)px/.exec(n)?.[1] ?? 16);
162
163
  return t.length * e * 0.6;
163
164
  }
164
- function Wt(t, n, e, r) {
165
+ function Nt(t, n, e, r) {
165
166
  const i = t.listLevel || 0, o = { bullet: t.listType === "ordered" ? "num" : "char", level: i };
166
167
  if (o.bullet === "num") {
167
- const s = Dt(t);
168
- s !== "arabicPeriod" && (o.numType = s), !(e && e.level === i && e.scheme === s && (t.listIndex || 1) === e.index + 1) && (t.listIndex || 1) > 1 && (o.startAt = t.listIndex);
168
+ const a = Ht(t);
169
+ a !== "arabicPeriod" && (o.numType = a), !(e && e.level === i && e.scheme === a && (t.listIndex || 1) === e.index + 1) && (t.listIndex || 1) > 1 && (o.startAt = t.listIndex);
169
170
  } else t.listMarker && t.listMarker !== "•" && (o.bulletChar = t.listMarker);
170
171
  if (t.listMarkerColor) {
171
- const s = S(t.listMarkerColor, n);
172
- s && (o.bulletColor = s);
172
+ const a = S(t.listMarkerColor, n);
173
+ a && (o.bulletColor = a);
173
174
  }
174
175
  t.listMarkerScale && t.listMarkerScale !== 1 && (o.bulletScale = t.listMarkerScale);
175
- const l = zt(t), f = r(t);
176
+ const l = Et(t), f = r(t);
176
177
  return o.marL = f, o.indent = l - f, o;
177
178
  }
178
- function at(t, n, e, r) {
179
+ function ct(t, n, e, r) {
179
180
  const i = [];
180
181
  let o = { runs: [], align: n }, l = !1, f = null;
181
- const s = Ft(Yt, t, r), a = () => {
182
+ const a = zt(jt, t, r), s = () => {
182
183
  i.push(o), o = { runs: [], align: n }, l = !1;
183
184
  };
184
185
  for (const c of t)
185
186
  String(c.text ?? "").split(`
186
- `).forEach((p, d) => {
187
- if (d > 0 && a(), c.fontSize && !l && (o.endSize = c.fontSize), !p) return;
188
- l || (l = !0, c.paragraphSpaceBefore && (o.spaceBefore = c.paragraphSpaceBefore), c.paragraphAlign && (o.align = U(c.paragraphAlign, n ?? "l")), c.listType && c.listType !== "none" && Object.assign(o, Wt(c, e, f, s)), f = o.bullet === "num" ? { level: o.level ?? 0, scheme: o.numType ?? "arabicPeriod", index: c.listIndex || 1 } : null);
189
- const h = { text: p };
190
- if (c.bold && (h.bold = !0), c.italic && (h.italic = !0), c.underline && (h.underline = !0), c.strikethrough && (h.strike = !0), c.color) {
187
+ `).forEach((h, p) => {
188
+ if (p > 0 && s(), c.fontSize && !l && (o.endSize = c.fontSize), !h) return;
189
+ l || (l = !0, c.paragraphSpaceBefore && (o.spaceBefore = c.paragraphSpaceBefore), c.paragraphAlign && (o.align = U(c.paragraphAlign, n ?? "l")), c.listType && c.listType !== "none" && Object.assign(o, Nt(c, e, f, a)), f = o.bullet === "num" ? { level: o.level ?? 0, scheme: o.numType ?? "arabicPeriod", index: c.listIndex || 1 } : null);
190
+ const d = { text: h };
191
+ if (c.bold && (d.bold = !0), c.italic && (d.italic = !0), c.underline && (d.underline = !0), c.strikethrough && (d.strike = !0), c.color) {
191
192
  const x = S(c.color, e);
192
- x && (h.color = x);
193
+ x && (d.color = x);
193
194
  }
194
- c.fontSize && (h.size = c.fontSize), c.fontFamily && (h.font = rt(c.fontFamily)), o.runs.push(h);
195
+ c.fontSize && (d.size = c.fontSize), c.fontFamily && (d.font = ot(c.fontFamily)), o.runs.push(d);
195
196
  });
196
- return a(), i;
197
+ return s(), i;
197
198
  }
198
- function ct(t, n, e) {
199
+ function lt(t, n, e) {
199
200
  const r = S(t.textColor || t.strokeColor || "#000000", n) ?? void 0;
200
201
  return {
201
202
  size: e,
202
203
  color: r,
203
- font: rt(t.fontFamily),
204
- bold: It(t.fontWeight) >= 600 ? !0 : void 0,
205
- italic: $t(t.fontStyle) === "italic" ? !0 : void 0
204
+ font: ot(t.fontFamily),
205
+ bold: Tt(t.fontWeight) >= 600 ? !0 : void 0,
206
+ italic: Ct(t.fontStyle) === "italic" ? !0 : void 0
206
207
  };
207
208
  }
208
- const lt = (t) => Ct(t) / Tt;
209
- function Ht(t, n) {
209
+ const ft = (t) => Ft(t) / Pt;
210
+ function Ut(t, n) {
210
211
  const e = t.richText && t.richText.length > 0, r = U(t.textAlign, e ? "ctr" : "l");
211
212
  return {
212
- paragraphs: e ? at(t.richText, r, n, { fontSize: t.fontSize || 20, fontFamily: t.fontFamily || "sans-serif" }) : st(t.text || "", r),
213
- anchor: it(t.verticalAlign),
213
+ paragraphs: e ? ct(t.richText, r, n, { fontSize: t.fontSize || 20, fontFamily: t.fontFamily || "sans-serif" }) : at(t.text || "", r),
214
+ anchor: st(t.verticalAlign),
214
215
  insets: { l: 4, t: 4, r: 4, b: 4 },
215
216
  wrap: !t.autoResize,
216
- lineSpacing: lt(t),
217
- defaults: ct(t, n, t.fontSize || 20)
217
+ lineSpacing: ft(t),
218
+ defaults: lt(t, n, t.fontSize || 20)
218
219
  };
219
220
  }
220
- function ft(t, n) {
221
+ function ut(t, n) {
221
222
  const e = t.richContainerText && t.richContainerText.length > 0;
222
223
  if (!e && !t.containerText) return;
223
224
  const r = U(t.textAlign, "ctr");
224
225
  return {
225
- paragraphs: e ? at(t.richContainerText, r, n, { fontSize: t.fontSize || 28, fontFamily: t.fontFamily || "hand-drawn" }) : st(t.containerText, r),
226
- anchor: it(t.verticalAlign),
226
+ paragraphs: e ? ct(t.richContainerText, r, n, { fontSize: t.fontSize || 28, fontFamily: t.fontFamily || "hand-drawn" }) : at(t.containerText, r),
227
+ anchor: st(t.verticalAlign),
227
228
  insets: { l: 10, t: 4, r: 10, b: 4 },
228
229
  wrap: !0,
229
- lineSpacing: lt(t),
230
- defaults: ct(t, n, t.fontSize || 16)
230
+ lineSpacing: ft(t),
231
+ defaults: lt(t, n, t.fontSize || 16)
231
232
  };
232
233
  }
233
- function jt(t, n, e) {
234
- const r = [], i = Math.abs(n) / 2, o = Math.abs(e) / 2, l = (s, a, c) => {
235
- const u = C(z(s), i, o);
234
+ function _t(t, n, e) {
235
+ const r = [], i = Math.abs(n) / 2, o = Math.abs(e) / 2, l = (a, s, c) => {
236
+ const u = C(z(a), i, o);
236
237
  if (u.length === 0) return;
237
- const p = a, d = { fill: p.noFill ? !1 : void 0, stroke: p.noStroke ? !1 : void 0 };
238
+ const h = s, p = { fill: h.noFill ? !1 : void 0, stroke: h.noStroke ? !1 : void 0 };
238
239
  if (c) {
239
- r.push({ cmds: u, ...d });
240
+ r.push({ cmds: u, ...p });
240
241
  return;
241
242
  }
242
- let h = [];
243
+ let d = [];
243
244
  for (const x of u)
244
- x.op === "M" && h.length && (r.push({ cmds: h, ...d }), h = []), h.push(x);
245
- h.length && r.push({ cmds: h, ...d });
246
- }, f = (s) => {
247
- const a = (c) => Math.round(c * 1e3) / 1e3;
248
- switch (s.type) {
245
+ x.op === "M" && d.length && (r.push({ cmds: d, ...p }), d = []), d.push(x);
246
+ d.length && r.push({ cmds: d, ...p });
247
+ }, f = (a) => {
248
+ const s = (c) => Math.round(c * 1e3) / 1e3;
249
+ switch (a.type) {
249
250
  case "rect": {
250
- const c = Math.min(Math.abs(s.w), Math.abs(s.h)) / 2, [u, p, d, h] = (Array.isArray(s.r) ? s.r : [s.r || 0, s.r || 0, s.r || 0, s.r || 0]).map((b) => Math.max(0, Math.min(b || 0, c))), x = (b, M, w) => b ? ` A ${a(b)} ${a(b)} 0 0 1 ${a(M)} ${a(w)}` : "", { x: g, y: k } = s, m = s.w, y = s.h;
251
- l(`M ${g + u} ${k} H ${g + m - p}${x(p, g + m, k + p)} V ${k + y - d}${x(d, g + m - d, k + y)} H ${g + h}${x(h, g, k + y - h)} V ${k + u}${x(u, g + u, k)} Z`, s, !1);
251
+ const c = Math.min(Math.abs(a.w), Math.abs(a.h)) / 2, [u, h, p, d] = (Array.isArray(a.r) ? a.r : [a.r || 0, a.r || 0, a.r || 0, a.r || 0]).map((b) => Math.max(0, Math.min(b || 0, c))), x = (b, M, w) => b ? ` A ${s(b)} ${s(b)} 0 0 1 ${s(M)} ${s(w)}` : "", { x: g, y: k } = a, m = a.w, y = a.h;
252
+ l(`M ${g + u} ${k} H ${g + m - h}${x(h, g + m, k + h)} V ${k + y - p}${x(p, g + m - p, k + y)} H ${g + d}${x(d, g, k + y - d)} V ${k + u}${x(u, g + u, k)} Z`, a, !1);
252
253
  break;
253
254
  }
254
255
  case "ellipse":
255
- l(`M ${s.cx - s.rx} ${s.cy} A ${s.rx} ${s.ry} 0 1 0 ${s.cx + s.rx} ${s.cy} A ${s.rx} ${s.ry} 0 1 0 ${s.cx - s.rx} ${s.cy} Z`, s, !1);
256
+ l(`M ${a.cx - a.rx} ${a.cy} A ${a.rx} ${a.ry} 0 1 0 ${a.cx + a.rx} ${a.cy} A ${a.rx} ${a.ry} 0 1 0 ${a.cx - a.rx} ${a.cy} Z`, a, !1);
256
257
  break;
257
258
  case "points":
258
- s.points.length >= 2 && l(`M ${s.points.map((c) => `${c.x} ${c.y}`).join(" L ")}${s.isClosed !== !1 ? " Z" : ""}`, s, !1);
259
+ a.points.length >= 2 && l(`M ${a.points.map((c) => `${c.x} ${c.y}`).join(" L ")}${a.isClosed !== !1 ? " Z" : ""}`, a, !1);
259
260
  break;
260
261
  case "path":
261
- l(s.path, s, !!s.evenOdd);
262
+ l(a.path, a, !!a.evenOdd);
262
263
  break;
263
264
  case "multi":
264
- s.shapes.forEach(f);
265
+ a.shapes.forEach(f);
265
266
  break;
266
267
  }
267
268
  };
268
269
  return f(t), r;
269
270
  }
270
- function Nt(t) {
271
+ function Zt(t) {
271
272
  if (t.warp || t.points && t.points.length) return null;
272
273
  if (t.type === "circle") return { kind: "preset", prst: "ellipse" };
273
274
  if (t.type === "rectangle") {
274
- const [n, e, r, i] = vt(t);
275
+ const [n, e, r, i] = At(t);
275
276
  if (!n && !e && !r && !i) return { kind: "preset", prst: "rect" };
276
277
  if (n === e && e === r && r === i) {
277
278
  const o = Math.min(Math.abs(t.width), Math.abs(t.height));
@@ -280,10 +281,10 @@ function Nt(t) {
280
281
  }
281
282
  return null;
282
283
  }
283
- const Ut = /* @__PURE__ */ new Set(["umlClass", "umlInterface", "qrCode", "video", "codeBlock"]), _t = /* @__PURE__ */ new Set(["fineliner", "inkbrush", "marker", "ink"]), Zt = /* @__PURE__ */ new Set(["text", "richtext", "image", "line", "arrow"]);
284
- function Gt(t) {
284
+ const Gt = /* @__PURE__ */ new Set(["umlClass", "umlInterface", "qrCode", "video", "codeBlock"]), Vt = /* @__PURE__ */ new Set(["fineliner", "inkbrush", "marker", "ink"]), qt = /* @__PURE__ */ new Set(["text", "richtext", "image", "line", "arrow"]);
285
+ function Jt(t) {
285
286
  const n = t;
286
- if (Ut.has(t.type) || t.clipMaskId || t.shadowEnabled || t.glowEnabled || (t.featherRadius ?? 0) > 0 || t.blendMode && t.blendMode !== "normal" || t.shearX || t.shearY || xt(t) || gt(t) || yt(t) || kt(t) || t.appearance && (t.appearance.fills?.length ?? 0) + (t.appearance.strokes?.length ?? 0) > 0) return !0;
287
+ if (Gt.has(t.type) || t.clipMaskId || t.shadowEnabled || t.glowEnabled || (t.featherRadius ?? 0) > 0 || t.blendMode && t.blendMode !== "normal" || t.shearX || t.shearY || yt(t) || kt(t) || bt(t) || Mt(t) || t.appearance && (t.appearance.fills?.length ?? 0) + (t.appearance.strokes?.length ?? 0) > 0) return !0;
287
288
  const e = t.fillStyle;
288
289
  if (e === "image" || e === "mesh" || e === "pattern" || t.backgroundImage || t.curvedText || (t.type === "text" || t.type === "richtext") && (t.verticalText || (n.charTransforms?.length ?? 0) > 0)) return !0;
289
290
  if (t.type === "image") {
@@ -310,7 +311,7 @@ function _(t) {
310
311
  if (n && n.mime === "image/png") return { bytes: n.bytes, ext: "png" };
311
312
  if (n && (n.mime === "image/jpeg" || n.mime === "image/jpg")) return { bytes: n.bytes, ext: "jpeg" };
312
313
  if (n && n.mime === "image/gif") return { bytes: n.bytes, ext: "gif" };
313
- const e = et(t);
314
+ const e = rt(t);
314
315
  if (!e || !e.naturalWidth) return null;
315
316
  try {
316
317
  const r = document.createElement("canvas");
@@ -330,25 +331,25 @@ function W(t, n, e) {
330
331
  const r = n.hooks.rasterize(t), i = r ? _(r.dataURL) : null;
331
332
  return !r || !i ? [] : (n.report.pictures++, [{ kind: "picture", id: n.nextId++, name: e, x: r.x - n.ox, y: r.y - n.oy, w: r.width, h: r.height, media: i }]);
332
333
  }
333
- function Vt(t, n) {
334
+ function Kt(t, n) {
334
335
  const e = _(t.dataURL);
335
336
  if (!e) return W([t], n, A(t));
336
337
  let r;
337
338
  if (t.crop) {
338
- const o = t.dataURL ? et(t.dataURL) : null, l = o?.naturalWidth, f = o?.naturalHeight;
339
+ const o = t.dataURL ? rt(t.dataURL) : null, l = o?.naturalWidth, f = o?.naturalHeight;
339
340
  if (l && f) {
340
- const s = t.crop;
341
- r = { l: s.x / l, t: s.y / f, r: 1 - (s.x + s.width) / l, b: 1 - (s.y + s.height) / f };
341
+ const a = t.crop;
342
+ r = { l: a.x / l, t: a.y / f, r: 1 - (a.x + a.width) / l, b: 1 - (a.y + a.height) / f };
342
343
  }
343
344
  }
344
345
  const i = (t.opacity ?? 100) / 100;
345
346
  return n.report.native++, [{ kind: "picture", id: n.nextId++, name: A(t), ...Z(t, n), media: e, crop: r, alpha: i < 1 ? i : void 0, descr: t.altText }];
346
347
  }
347
- function qt(t, n, e, r) {
348
- const i = ft(t, r);
348
+ function Qt(t, n, e, r) {
349
+ const i = ut(t, r);
349
350
  if (!i) return [];
350
351
  const o = t.fontSize || 16, l = (t.containerText || "").split(`
351
- `), f = Math.max(1, ...l.map((c) => c.length)), s = Math.max(40, f * o * 0.6 + 24), a = Math.max(o * 1.6, l.length * o * 1.25 + 8);
352
+ `), f = Math.max(1, ...l.map((c) => c.length)), a = Math.max(40, f * o * 0.6 + 24), s = Math.max(o * 1.6, l.length * o * 1.25 + 8);
352
353
  return i.wrap = !1, i.anchor = "ctr", i.paragraphs.forEach((c) => {
353
354
  c.align = "ctr";
354
355
  }), [{
@@ -356,38 +357,38 @@ function qt(t, n, e, r) {
356
357
  id: e.nextId++,
357
358
  name: `${A(t)} label`,
358
359
  textBox: !0,
359
- x: n.x - e.ox - s / 2,
360
- y: n.y - e.oy - a / 2,
361
- w: s,
362
- h: a,
360
+ x: n.x - e.ox - a / 2,
361
+ y: n.y - e.oy - s / 2,
362
+ w: a,
363
+ h: s,
363
364
  geom: { kind: "preset", prst: "rect" },
364
365
  fill: { kind: "none" },
365
366
  line: null,
366
367
  text: i
367
368
  }];
368
369
  }
369
- function Jt(t, n, e) {
370
- const r = t.x + t.w / 2, i = t.y + t.h / 2, o = (t.rot || 0) * Math.PI / 180, l = [[0, -t.h / 2], [-t.w / 2, 0], [0, t.h / 2], [t.w / 2, 0]], f = n.x - e.ox, s = n.y - e.oy;
371
- for (let a = 0; a < 4; a++) {
372
- let [c, u] = l[a];
370
+ function tn(t, n, e) {
371
+ const r = t.x + t.w / 2, i = t.y + t.h / 2, o = (t.rot || 0) * Math.PI / 180, l = [[0, -t.h / 2], [-t.w / 2, 0], [0, t.h / 2], [t.w / 2, 0]], f = n.x - e.ox, a = n.y - e.oy;
372
+ for (let s = 0; s < 4; s++) {
373
+ let [c, u] = l[s];
373
374
  t.flipH && (c = -c), t.flipV && (u = -u);
374
- const p = r + c * Math.cos(o) - u * Math.sin(o), d = i + c * Math.sin(o) + u * Math.cos(o);
375
- if (Math.hypot(p - f, d - s) <= 2) return a;
375
+ const h = r + c * Math.cos(o) - u * Math.sin(o), p = i + c * Math.sin(o) + u * Math.cos(o);
376
+ if (Math.hypot(h - f, p - a) <= 2) return s;
376
377
  }
377
378
  return -1;
378
379
  }
379
- function Kt(t, n, e) {
380
+ function nn(t, n, e) {
380
381
  const r = e.x - n.x, i = e.y - n.y, o = Math.hypot(r, i);
381
382
  if (!(o > 0)) return !1;
382
- const l = (a, c) => Math.abs((a - n.x) * i - (c - n.y) * r) / o, f = (a, c) => ((a - n.x) * r + (c - n.y) * i) / (o * o), s = (a, c) => l(a, c) <= 0.5 && f(a, c) >= -0.01 && f(a, c) <= 1.01;
383
- return t.every((a) => a.op === "Z" ? !1 : a.op === "C" ? s(a.x1, a.y1) && s(a.x2, a.y2) && s(a.x, a.y) : s(a.x, a.y));
383
+ const l = (s, c) => Math.abs((s - n.x) * i - (c - n.y) * r) / o, f = (s, c) => ((s - n.x) * r + (c - n.y) * i) / (o * o), a = (s, c) => l(s, c) <= 0.5 && f(s, c) >= -0.01 && f(s, c) <= 1.01;
384
+ return t.every((s) => s.op === "Z" ? !1 : s.op === "C" ? a(s.x1, s.y1) && a(s.x2, s.y2) && a(s.x, s.y) : a(s.x, s.y));
384
385
  }
385
- function Qt(t, n) {
386
- const e = (t.opacity ?? 100) / 100, r = N(t, e, !0), i = bt(t), o = [];
386
+ function en(t, n) {
387
+ const e = (t.opacity ?? 100) / 100, r = N(t, e, !0), i = wt(t), o = [];
387
388
  if (r) {
388
- const l = t.type === "arrow", f = l ? t.startArrowhead : null, s = l ? t.endArrowhead || (t.startArrowhead ? null : "arrow") : null, a = { ...r, head: J(f, G(t, "start"), t.strokeWidth), tail: J(s, G(t, "end"), t.strokeWidth) };
389
- if (!i.d || Kt(z(i.d), i.start, i.end)) {
390
- const { start: c, end: u } = i, p = {
389
+ const l = t.type === "arrow", f = l ? t.startArrowhead : null, a = l ? t.endArrowhead || (t.startArrowhead ? null : "arrow") : null, s = { ...r, head: J(f, G(t, "start"), t.strokeWidth), tail: J(a, G(t, "end"), t.strokeWidth) };
390
+ if (!i.d || nn(z(i.d), i.start, i.end)) {
391
+ const { start: c, end: u } = i, h = {
391
392
  kind: "connector",
392
393
  id: n.nextId++,
393
394
  name: A(t),
@@ -398,50 +399,50 @@ function Qt(t, n) {
398
399
  flipH: u.x < c.x || void 0,
399
400
  flipV: u.y < c.y || void 0,
400
401
  geom: { kind: "preset", prst: "straightConnector1" },
401
- line: a
402
- }, d = (h, x) => {
403
- const g = h?.elementId ? n.ids.get(h.elementId) : void 0;
402
+ line: s
403
+ }, p = (d, x) => {
404
+ const g = d?.elementId ? n.ids.get(d.elementId) : void 0;
404
405
  if (!g) return;
405
- const k = Jt(g.item, x, n);
406
+ const k = tn(g.item, x, n);
406
407
  return k >= 0 ? { id: g.id, idx: k } : void 0;
407
408
  };
408
409
  n.glue.push(() => {
409
- p.start = d(t.startBinding, c), p.end = d(t.endBinding, u);
410
- }), o.push(p);
410
+ h.start = p(t.startBinding, c), h.end = p(t.endBinding, u);
411
+ }), o.push(h);
411
412
  } else {
412
413
  const c = z(i.d), u = j(c);
413
414
  if (u) {
414
- const p = Math.max(u.maxX - u.minX, 0.01), d = Math.max(u.maxY - u.minY, 0.01);
415
+ const h = Math.max(u.maxX - u.minX, 0.01), p = Math.max(u.maxY - u.minY, 0.01);
415
416
  o.push({
416
417
  kind: "shape",
417
418
  id: n.nextId++,
418
419
  name: A(t),
419
420
  x: u.minX - n.ox,
420
421
  y: u.minY - n.oy,
421
- w: p,
422
- h: d,
422
+ w: h,
423
+ h: p,
423
424
  geom: { kind: "custom", paths: [{ cmds: C(c, -u.minX, -u.minY), fill: !1 }] },
424
425
  fill: { kind: "none" },
425
- line: a
426
+ line: s
426
427
  });
427
428
  }
428
429
  }
429
430
  n.report.native++;
430
431
  }
431
- return o.push(...qt(t, i.mid, n, e)), o;
432
+ return o.push(...Qt(t, i.mid, n, e)), o;
432
433
  }
433
- function tn(t, n) {
434
- const e = (t.opacity ?? 100) / 100, r = Mt(t.points), i = N(t, e, !0);
434
+ function rn(t, n) {
435
+ const e = (t.opacity ?? 100) / 100, r = vt(t.points), i = N(t, e, !0);
435
436
  if (r.length < 2 || !i) return [];
436
437
  i.cap = "rnd", i.join = "round";
437
- const o = r.map((p) => p.x), l = r.map((p) => p.y), f = Math.min(...o), s = Math.min(...l), a = Math.max(Math.max(...o) - f, 0.01), c = Math.max(Math.max(...l) - s, 0.01), u = r.map((p, d) => ({ op: d ? "L" : "M", x: p.x - f, y: p.y - s }));
438
+ const o = r.map((h) => h.x), l = r.map((h) => h.y), f = Math.min(...o), a = Math.min(...l), s = Math.max(Math.max(...o) - f, 0.01), c = Math.max(Math.max(...l) - a, 0.01), u = r.map((h, p) => ({ op: p ? "L" : "M", x: h.x - f, y: h.y - a }));
438
439
  return n.report.native++, [{
439
440
  kind: "shape",
440
441
  id: n.nextId++,
441
442
  name: A(t),
442
443
  x: t.x + f - n.ox,
443
- y: t.y + s - n.oy,
444
- w: a,
444
+ y: t.y + a - n.oy,
445
+ w: s,
445
446
  h: c,
446
447
  rot: t.angle ? t.angle * 180 / Math.PI : void 0,
447
448
  geom: { kind: "custom", paths: [{ cmds: u, fill: !1 }] },
@@ -449,7 +450,7 @@ function tn(t, n) {
449
450
  line: i
450
451
  }];
451
452
  }
452
- function nn(t, n) {
453
+ function on(t, n) {
453
454
  const e = (t.opacity ?? 100) / 100;
454
455
  if (!(t.text || t.richText && t.richText.length > 0)) return [];
455
456
  n.report.native++;
@@ -463,15 +464,15 @@ function nn(t, n) {
463
464
  geom: { kind: "preset", prst: "rect" },
464
465
  fill: i ? { kind: "solid", color: i } : { kind: "none" },
465
466
  line: null,
466
- text: Ht(t, e)
467
+ text: Ut(t, e)
467
468
  }];
468
469
  }
469
- const en = (t) => {
470
+ const sn = (t) => {
470
471
  const n = t && /matrix\(([^)]+)\)/.exec(t), e = n ? n[1].split(/[\s,]+/).map(Number) : [];
471
472
  return e.length === 6 && e.every(Number.isFinite) ? e : [1, 0, 0, 1, 0, 0];
472
473
  }, Q = (t, n, e) => ({ x: t[0] * n + t[2] * e + t[4], y: t[1] * n + t[3] * e + t[5] });
473
- function rn(t) {
474
- const n = Pt.generator(), e = (i) => {
474
+ function an(t) {
475
+ const n = Lt.generator(), e = (i) => {
475
476
  for (const o of n.toPaths(i))
476
477
  t.save(), o.fill && o.fill !== "none" && (!o.stroke || o.stroke === "none") ? (t.fillStyle = o.fill, t.fillPath(o.d)) : o.stroke && o.stroke !== "none" && o.strokeWidth > 0 && (t.strokeStyle = o.stroke, t.lineWidth = o.strokeWidth, t.strokePath(o.d)), t.restore();
477
478
  return i;
@@ -480,7 +481,7 @@ function rn(t) {
480
481
  r[i] = (...o) => e(n[i](...o));
481
482
  return r;
482
483
  }
483
- function on(t) {
484
+ function cn(t) {
484
485
  const n = t.fillStyle, e = {
485
486
  ...t,
486
487
  renderStyle: "architectural",
@@ -493,30 +494,30 @@ function on(t) {
493
494
  richContainerText: void 0,
494
495
  // Hatching is re-created as a pattern fill on the body; recording it would be hundreds of lines.
495
496
  fillStyle: Y[n] ? "solid" : t.fillStyle
496
- }, r = new St();
497
+ }, r = new $t();
497
498
  try {
498
- const a = document.createElement("canvas");
499
- At(rn(r), a.getContext("2d"), e, !1, 1, r);
499
+ const s = document.createElement("canvas");
500
+ It(an(r), s.getContext("2d"), e, !1, 1, r);
500
501
  } catch {
501
502
  return null;
502
503
  }
503
504
  if (r.failed) return null;
504
505
  const i = /* @__PURE__ */ new Map();
505
- for (const a of Array.from(r.defs.children)) a.id && i.set(a.id, a);
506
- const o = (a, c) => {
507
- const u = i.get(a.replace(/^url\(#|\)$/g, ""));
506
+ for (const s of Array.from(r.defs.children)) s.id && i.set(s.id, s);
507
+ const o = (s, c) => {
508
+ const u = i.get(s.replace(/^url\(#|\)$/g, ""));
508
509
  if (!u) return null;
509
- const p = Array.from(u.children).map((d) => ({ pos: +(d.getAttribute("offset") || 0), color: S(d.getAttribute("stop-color")) ?? { hex: "#000000", alpha: 0 } }));
510
- if (!p.length) return null;
510
+ const h = Array.from(u.children).map((p) => ({ pos: +(p.getAttribute("offset") || 0), color: S(p.getAttribute("stop-color")) ?? { hex: "#000000", alpha: 0 } }));
511
+ if (!h.length) return null;
511
512
  if (u.tagName.toLowerCase() === "lineargradient") {
512
- const d = Q(c, +u.getAttribute("x1"), +u.getAttribute("y1")), h = Q(c, +u.getAttribute("x2"), +u.getAttribute("y2"));
513
- return { kind: "linear", x1: d.x, y1: d.y, x2: h.x, y2: h.y, stops: p };
513
+ const p = Q(c, +u.getAttribute("x1"), +u.getAttribute("y1")), d = Q(c, +u.getAttribute("x2"), +u.getAttribute("y2"));
514
+ return { kind: "linear", x1: p.x, y1: p.y, x2: d.x, y2: d.y, stops: h };
514
515
  }
515
- return { kind: "radial", x1: 0, y1: 0, x2: 0, y2: 0, stops: p };
516
+ return { kind: "radial", x1: 0, y1: 0, x2: 0, y2: 0, stops: h };
516
517
  }, l = [];
517
518
  let f = "ok";
518
- const s = (a) => {
519
- for (const c of Array.from(a.children)) {
519
+ const a = (s) => {
520
+ for (const c of Array.from(s.children)) {
520
521
  if (f !== "ok") return;
521
522
  const u = c.tagName.toLowerCase();
522
523
  if (u === "g") {
@@ -524,62 +525,62 @@ function on(t) {
524
525
  f = "picture";
525
526
  return;
526
527
  }
527
- s(c);
528
+ a(c);
528
529
  continue;
529
530
  }
530
531
  if (u === "text" || u === "image") {
531
532
  f = "picture";
532
533
  return;
533
534
  }
534
- let p = null;
535
- if (u === "path") p = c.getAttribute("d");
535
+ let h = null;
536
+ if (u === "path") h = c.getAttribute("d");
536
537
  else if (u === "rect") {
537
538
  const b = +c.getAttribute("x"), M = +c.getAttribute("y"), w = +c.getAttribute("width"), v = +c.getAttribute("height");
538
- p = `M ${b} ${M} L ${b + w} ${M} L ${b + w} ${M + v} L ${b} ${M + v} Z`;
539
+ h = `M ${b} ${M} L ${b + w} ${M} L ${b + w} ${M + v} L ${b} ${M + v} Z`;
539
540
  } else {
540
541
  f = "fail";
541
542
  return;
542
543
  }
543
- const d = en(c.getAttribute("transform")), h = Lt(z(p || ""), d);
544
- if (!h.length) continue;
544
+ const p = sn(c.getAttribute("transform")), d = Rt(z(h || ""), p);
545
+ if (!d.length) continue;
545
546
  const x = c.getAttribute("fill"), g = c.getAttribute("stroke"), k = !!x && x.startsWith("url("), m = +(c.getAttribute("fill-opacity") ?? 1), y = +(c.getAttribute("stroke-opacity") ?? 1);
546
547
  l.push({
547
- cmds: h,
548
+ cmds: d,
548
549
  fill: x && x !== "none" && !k ? x : null,
549
- grad: k ? o(x, d) : null,
550
+ grad: k ? o(x, p) : null,
550
551
  stroke: g && g !== "none" ? g : null,
551
552
  fillAlpha: Number.isFinite(m) ? m : 1,
552
553
  strokeAlpha: Number.isFinite(y) ? y : 1,
553
- width: +(c.getAttribute("stroke-width") || 1) * Math.sqrt(Math.abs(d[0] * d[3] - d[1] * d[2])),
554
+ width: +(c.getAttribute("stroke-width") || 1) * Math.sqrt(Math.abs(p[0] * p[3] - p[1] * p[2])),
554
555
  dash: !!c.getAttribute("stroke-dasharray"),
555
556
  evenOdd: c.getAttribute("fill-rule") === "evenodd"
556
557
  });
557
558
  }
558
559
  };
559
- return s(r.root), f === "ok" ? l : f === "picture" ? "picture" : null;
560
+ return a(r.root), f === "ok" ? l : f === "picture" ? "picture" : null;
560
561
  }
561
562
  const tt = (t, n) => {
562
563
  if (!t || !n) return !1;
563
564
  const e = T(t), r = T(n);
564
565
  return !!e && !!r && e[0] === r[0] && e[1] === r[1] && e[2] === r[2];
565
566
  };
566
- function sn(t, n, e) {
567
- const r = t.stops.map((h) => ({ pos: h.pos, color: e < 1 ? { ...h.color, alpha: (h.color.alpha ?? 1) * e } : h.color }));
567
+ function ln(t, n, e) {
568
+ const r = t.stops.map((d) => ({ pos: d.pos, color: e < 1 ? { ...d.color, alpha: (d.color.alpha ?? 1) * e } : d.color }));
568
569
  if (t.kind === "radial") return { kind: "radial", stops: r };
569
570
  const i = t.x2 - t.x1, o = t.y2 - t.y1, l = Math.hypot(i, o);
570
571
  if (!(l > 0)) return { kind: "solid", color: r[r.length - 1].color };
571
- const f = i / l, s = o / l, a = (n.minX + n.maxX) / 2, c = (n.minY + n.maxY) / 2, u = (Math.abs((n.maxX - n.minX) * f) + Math.abs((n.maxY - n.minY) * s)) / 2;
572
+ const f = i / l, a = o / l, s = (n.minX + n.maxX) / 2, c = (n.minY + n.maxY) / 2, u = (Math.abs((n.maxX - n.minX) * f) + Math.abs((n.maxY - n.minY) * a)) / 2;
572
573
  if (!(u > 0)) return { kind: "solid", color: r[0].color };
573
- const p = (h) => ((t.x1 + i * h - a) * f + (t.y1 + o * h - c) * s + u) / (2 * u), d = [...r].sort((h, x) => h.pos - x.pos).map((h) => ({ pos: p(h.pos), color: h.color }));
574
- return { kind: "linear", angle: Math.atan2(o, i) * 180 / Math.PI, stops: ut(d) };
574
+ const h = (d) => ((t.x1 + i * d - s) * f + (t.y1 + o * d - c) * a + u) / (2 * u), p = [...r].sort((d, x) => d.pos - x.pos).map((d) => ({ pos: h(d.pos), color: d.color }));
575
+ return { kind: "linear", angle: Math.atan2(o, i) * 180 / Math.PI, stops: dt(p) };
575
576
  }
576
- function ut(t) {
577
+ function dt(t) {
577
578
  if (t.length < 2) return t.map((e) => ({ ...e, pos: Math.max(0, Math.min(1, e.pos)) }));
578
579
  const n = (e) => {
579
580
  if (e <= t[0].pos) return t[0].color;
580
581
  for (let r = 1; r < t.length; r++) {
581
582
  const i = t[r - 1], o = t[r];
582
- if (e <= o.pos) return mn(i.color, o.color, o.pos > i.pos ? (e - i.pos) / (o.pos - i.pos) : 0);
583
+ if (e <= o.pos) return gn(i.color, o.color, o.pos > i.pos ? (e - i.pos) / (o.pos - i.pos) : 0);
583
584
  }
584
585
  return t[t.length - 1].color;
585
586
  };
@@ -595,23 +596,23 @@ function H(t) {
595
596
  return t.stroke !== !1 && r.push({ cmds: t.cmds, fill: !1, stroke: t.stroke }), r;
596
597
  }
597
598
  const E = (t) => JSON.stringify(t.cmds);
598
- function an(t, n) {
599
- const e = (t.opacity ?? 100) / 100, r = Z(t, n), i = ft(t, e);
600
- let o = Nt(t);
599
+ function fn(t, n) {
600
+ const e = (t.opacity ?? 100) / 100, r = Z(t, n), i = ut(t, e);
601
+ let o = Zt(t);
601
602
  if (!o) {
602
- const f = wt(t), s = f ? jt(f, t.width, t.height) : [], a = on(t);
603
- if (a === "picture") return null;
604
- if (a && a.length) {
605
- const c = Math.min(t.x, t.x + t.width), u = Math.min(t.y, t.y + t.height), p = s.length ? s.filter((m) => m.fill !== !1).map((m) => C(m.cmds, c, u)) : null, d = !!ot(t), h = ["linear", "radial", "conic"].includes(t.fillStyle);
606
- if (!a.every((m) => (!m.grad || h) && m.fillAlpha >= 1 && m.strokeAlpha >= 1 && (!m.fill || tt(m.fill, t.backgroundColor)) && (!m.stroke || tt(m.stroke, t.strokeColor) && Math.abs(m.width - t.strokeWidth) < 0.75 && m.dash === d))) {
607
- const m = ln(t, a, r, i, n, e, p);
603
+ const f = St(t), a = f ? _t(f, t.width, t.height) : [], s = cn(t);
604
+ if (s === "picture") return null;
605
+ if (s && s.length) {
606
+ const c = Math.min(t.x, t.x + t.width), u = Math.min(t.y, t.y + t.height), h = a.length ? a.filter((m) => m.fill !== !1).map((m) => C(m.cmds, c, u)) : null, p = !!it(t), d = ["linear", "radial", "conic"].includes(t.fillStyle);
607
+ if (!s.every((m) => (!m.grad || d) && m.fillAlpha >= 1 && m.strokeAlpha >= 1 && (!m.fill || tt(m.fill, t.backgroundColor)) && (!m.stroke || tt(m.stroke, t.strokeColor) && Math.abs(m.width - t.strokeWidth) < 0.75 && m.dash === p))) {
608
+ const m = dn(t, s, r, i, n, e, h);
608
609
  return m ? [m] : null;
609
610
  }
610
611
  const g = [], k = (m) => C(m, -c, -u);
611
- for (let m = 0; m < a.length; m++) {
612
- const y = a[m], b = a[m + 1], M = !!((y.fill || y.grad) && !y.stroke && b && b.stroke && !b.fill && !b.grad && E(b) === E(y)), w = !!y.stroke || M;
612
+ for (let m = 0; m < s.length; m++) {
613
+ const y = s[m], b = s[m + 1], M = !!((y.fill || y.grad) && !y.stroke && b && b.stroke && !b.fill && !b.grad && E(b) === E(y)), w = !!y.stroke || M;
613
614
  if (y.fill || y.grad) {
614
- const v = dt(y, p);
615
+ const v = ht(y, h);
615
616
  if (!v) return null;
616
617
  v.length === 1 && v[0] === y.cmds ? g.push(...H({ cmds: k(y.cmds), stroke: w ? void 0 : !1 })) : (g.push(...v.map((O) => ({ cmds: k(O), stroke: !1 }))), w && g.push({ cmds: k(y.cmds), fill: !1 }));
617
618
  } else
@@ -619,8 +620,8 @@ function an(t, n) {
619
620
  M && m++;
620
621
  }
621
622
  o = { kind: "custom", paths: g };
622
- } else if (s.length)
623
- o = { kind: "custom", paths: s.flatMap(H) };
623
+ } else if (a.length)
624
+ o = { kind: "custom", paths: a.flatMap(H) };
624
625
  else return null;
625
626
  }
626
627
  const l = {
@@ -629,58 +630,58 @@ function an(t, n) {
629
630
  name: A(t),
630
631
  ...r,
631
632
  geom: o,
632
- fill: Bt(t, e),
633
+ fill: Wt(t, e),
633
634
  line: N(t, e),
634
635
  text: i
635
636
  };
636
637
  return n.ids.set(t.id, { id: l.id, item: l }), n.report.native++, [l];
637
638
  }
638
- const cn = (t) => t.map((n) => n.op === "Z" ? "Z" : n.op === "C" ? `C ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}` : `${n.op} ${n.x} ${n.y}`).join(" ");
639
- let B = null;
639
+ const un = (t) => t.map((n) => n.op === "Z" ? "Z" : n.op === "C" ? `C ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}` : `${n.op} ${n.x} ${n.y}`).join(" ");
640
+ let D = null;
640
641
  const P = 28;
641
- function D(t, n, e) {
642
- B ??= document.createElement("canvas").getContext("2d");
642
+ function B(t, n, e) {
643
+ D ??= document.createElement("canvas").getContext("2d");
643
644
  const r = [];
644
- if (!B) return r;
645
- const i = t.map((o) => new Path2D(cn(o)));
645
+ if (!D) return r;
646
+ const i = t.map((o) => new Path2D(un(o)));
646
647
  for (let o = 0; o < P; o++) for (let l = 0; l < P; l++) {
647
- const f = e.minX + (l + 0.5) / P * (e.maxX - e.minX), s = e.minY + (o + 0.5) / P * (e.maxY - e.minY);
648
- r.push(i.some((a) => B.isPointInPath(a, f, s, n)));
648
+ const f = e.minX + (l + 0.5) / P * (e.maxX - e.minX), a = e.minY + (o + 0.5) / P * (e.maxY - e.minY);
649
+ r.push(i.some((s) => D.isPointInPath(s, f, a, n)));
649
650
  }
650
651
  return r;
651
652
  }
652
653
  const nt = (t, n) => t.reduce((e, r, i) => e + (r !== n[i] ? 1 : 0), 0) / Math.max(1, t.length);
653
- function dt(t, n) {
654
+ function ht(t, n) {
654
655
  if (t.evenOdd) return [t.cmds];
655
656
  const e = j(t.cmds);
656
657
  if (!e) return [t.cmds];
657
- const r = D([t.cmds], "nonzero", e);
658
- return nt(r, D([t.cmds], "evenodd", e)) === 0 ? [t.cmds] : n && nt(r, D(n, "evenodd", e)) <= 0.03 ? n : null;
658
+ const r = B([t.cmds], "nonzero", e);
659
+ return nt(r, B([t.cmds], "evenodd", e)) === 0 ? [t.cmds] : n && nt(r, B(n, "evenodd", e)) <= 0.03 ? n : null;
659
660
  }
660
- function ln(t, n, e, r, i, o, l) {
661
+ function dn(t, n, e, r, i, o, l) {
661
662
  const f = [];
662
- for (let s = 0; s < n.length; s++) {
663
- const a = n[s], c = n[s + 1], u = !!((a.fill || a.grad) && !a.stroke && c && c.stroke && !c.fill && !c.grad && E(c) === E(a)), p = u ? c : a, d = j(a.cmds);
664
- if (!d) continue;
665
- const h = Math.max(d.maxX - d.minX, 0.01), x = Math.max(d.maxY - d.minY, 0.01), g = S(a.fill, o * a.fillAlpha), k = a.grad ? sn(a.grad, d, o) : g ? { kind: "solid", color: g } : { kind: "none" }, m = S(p.stroke, o * p.strokeAlpha), y = m ? { width: p.width, color: m, dash: p.dash ? "dash" : void 0, join: "round", cap: "rnd" } : null, b = !!(a.fill || a.grad), M = (v) => C(v, -d.minX, -d.minY);
663
+ for (let a = 0; a < n.length; a++) {
664
+ const s = n[a], c = n[a + 1], u = !!((s.fill || s.grad) && !s.stroke && c && c.stroke && !c.fill && !c.grad && E(c) === E(s)), h = u ? c : s, p = j(s.cmds);
665
+ if (!p) continue;
666
+ const d = Math.max(p.maxX - p.minX, 0.01), x = Math.max(p.maxY - p.minY, 0.01), g = S(s.fill, o * s.fillAlpha), k = s.grad ? ln(s.grad, p, o) : g ? { kind: "solid", color: g } : { kind: "none" }, m = S(h.stroke, o * h.strokeAlpha), y = m ? { width: h.width, color: m, dash: h.dash ? "dash" : void 0, join: "round", cap: "rnd" } : null, b = !!(s.fill || s.grad), M = (v) => C(v, -p.minX, -p.minY);
666
667
  let w;
667
668
  if (b) {
668
- const v = dt(a, l);
669
+ const v = ht(s, l);
669
670
  if (!v) return null;
670
- w = v.length === 1 && v[0] === a.cmds ? H({ cmds: M(a.cmds), stroke: m ? void 0 : !1 }) : [...v.map((O) => ({ cmds: M(O), stroke: !1 })), ...m ? [{ cmds: M(a.cmds), fill: !1 }] : []];
671
- } else w = [{ cmds: M(a.cmds), fill: !1, stroke: m ? void 0 : !1 }];
671
+ w = v.length === 1 && v[0] === s.cmds ? H({ cmds: M(s.cmds), stroke: m ? void 0 : !1 }) : [...v.map((O) => ({ cmds: M(O), stroke: !1 })), ...m ? [{ cmds: M(s.cmds), fill: !1 }] : []];
672
+ } else w = [{ cmds: M(s.cmds), fill: !1, stroke: m ? void 0 : !1 }];
672
673
  f.push({
673
674
  kind: "shape",
674
675
  id: i.nextId++,
675
676
  name: `${A(t)} part`,
676
- x: d.minX - i.ox,
677
- y: d.minY - i.oy,
678
- w: h,
677
+ x: p.minX - i.ox,
678
+ y: p.minY - i.oy,
679
+ w: d,
679
680
  h: x,
680
681
  geom: { kind: "custom", paths: w },
681
682
  fill: k,
682
683
  line: y
683
- }), u && s++;
684
+ }), u && a++;
684
685
  }
685
686
  return r && f.push({
686
687
  kind: "shape",
@@ -697,22 +698,22 @@ function ln(t, n, e, r, i, o, l) {
697
698
  text: r
698
699
  }), i.report.native++, { kind: "group", id: i.nextId++, name: A(t), ...e, children: f };
699
700
  }
700
- function fn(t, n) {
701
- if (Gt(t)) return W([t], n, A(t));
701
+ function hn(t, n) {
702
+ if (Jt(t)) return W([t], n, A(t));
702
703
  try {
703
- if (t.type === "text" || t.type === "richtext") return nn(t, n);
704
- if (t.type === "image") return Vt(t, n);
705
- if (t.type === "line" || t.type === "arrow") return Qt(t, n);
706
- if (_t.has(t.type)) return tn(t, n);
707
- if (!Zt.has(t.type)) {
708
- const e = an(t, n);
704
+ if (t.type === "text" || t.type === "richtext") return on(t, n);
705
+ if (t.type === "image") return Kt(t, n);
706
+ if (t.type === "line" || t.type === "arrow") return en(t, n);
707
+ if (Vt.has(t.type)) return rn(t, n);
708
+ if (!qt.has(t.type)) {
709
+ const e = fn(t, n);
709
710
  if (e) return e;
710
711
  }
711
712
  } catch {
712
713
  }
713
714
  return W([t], n, A(t));
714
715
  }
715
- function ht(t, n, e) {
716
+ function pt(t, n, e) {
716
717
  const r = [];
717
718
  let i = 0;
718
719
  const o = (l) => {
@@ -722,29 +723,30 @@ function ht(t, n, e) {
722
723
  for (; i < t.length; ) {
723
724
  const l = o(t[i]);
724
725
  if (!l) {
725
- const a = fn(t[i], e), c = xn(t[i].link);
726
- if (c) for (const u of a) u.link = c;
727
- r.push(...a), i++;
726
+ let s = hn(t[i], e);
727
+ const c = yn(t[i].link);
728
+ if (c) for (const u of s) u.link = c;
729
+ e.animTargets && t[i].animations?.length && s.length > 1 && (s = [{ kind: "group", id: e.nextId++, name: A(t[i]), ...et(s), children: s }]), e.animTargets && s.length === 1 && e.animTargets.set(t[i].id, s[0].id), r.push(...s), i++;
728
730
  continue;
729
731
  }
730
732
  let f = i;
731
733
  for (; f < t.length && o(t[f]) === l; ) f++;
732
- const s = ht(t.slice(i, f), n + 1, e);
733
- if (s.length > 1) {
734
- const a = un(s), c = { kind: "group", id: e.nextId++, name: t[i].groupNames?.[l] || "Group", ...a, children: s };
735
- r.push(c);
736
- } else r.push(...s);
734
+ const a = pt(t.slice(i, f), n + 1, e);
735
+ if (a.length > 1) {
736
+ const s = et(a), c = { kind: "group", id: e.nextId++, name: t[i].groupNames?.[l] || "Group", ...s, children: a };
737
+ if (r.push(c), e.animTargets) for (const u of t.slice(i, f)) e.animTargets.set(u.id, c.id);
738
+ } else r.push(...a);
737
739
  i = f;
738
740
  }
739
741
  return r;
740
742
  }
741
- function un(t) {
743
+ function et(t) {
742
744
  let n = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
743
745
  for (const o of t)
744
746
  n = Math.min(n, o.x), e = Math.min(e, o.y), r = Math.max(r, o.x + o.w), i = Math.max(i, o.y + o.h);
745
747
  return { x: n, y: e, w: Math.max(0, r - n), h: Math.max(0, i - e) };
746
748
  }
747
- function dn(t) {
749
+ function pn(t) {
748
750
  if (!t || t.type === "none") return;
749
751
  const n = t.duration ?? 500;
750
752
  switch (t.type) {
@@ -768,7 +770,7 @@ function dn(t) {
768
770
  return;
769
771
  }
770
772
  }
771
- function hn(t, n) {
773
+ function mn(t, n) {
772
774
  const e = t.slide;
773
775
  if (!e) {
774
776
  const f = S(t.background);
@@ -778,58 +780,86 @@ function hn(t, n) {
778
780
  if (i && r === "solid")
779
781
  return { kind: "solid", color: S(e.backgroundColor === "transparent" ? "#ffffff" : e.backgroundColor || "#ffffff") ?? { hex: "#ffffff" } };
780
782
  if (i && (r === "linear" || r === "radial") && (e.gradientStops?.length ?? 0) > 0) {
781
- const f = e.gradientDirection || 0, s = e.gradientStops.map((a) => ({ pos: a.offset, color: S(a.color) ?? { hex: "#ffffff" } }));
782
- return r === "radial" ? { kind: "radial", stops: s } : { kind: "linear", stops: pn(s, f, t.w, t.h), angle: f };
783
+ const f = e.gradientDirection || 0, a = e.gradientStops.map((s) => ({ pos: s.offset, color: S(s.color) ?? { hex: "#ffffff" } }));
784
+ return r === "radial" ? { kind: "radial", stops: a } : { kind: "linear", stops: xn(a, f, t.w, t.h), angle: f };
783
785
  }
784
786
  const o = n.rasterizeBackground?.(e), l = o ? _(o) : null;
785
787
  return l ? { kind: "image", media: l } : { kind: "solid", color: S(e.backgroundColor) ?? { hex: "#ffffff" } };
786
788
  }
787
- function pn(t, n, e, r) {
789
+ function xn(t, n, e, r) {
788
790
  const i = n * Math.PI / 180, o = Math.hypot(e, r) / 2, l = (Math.abs(e * Math.cos(i)) + Math.abs(r * Math.sin(i))) / 2;
789
791
  if (!(l > 0) || t.length < 2) return t;
790
- const f = [...t].sort((s, a) => s.pos - a.pos).map((s) => ({ pos: (-o + 2 * o * s.pos + l) / (2 * l), color: s.color }));
791
- return ut(f);
792
+ const f = [...t].sort((a, s) => a.pos - s.pos).map((a) => ({ pos: (-o + 2 * o * a.pos + l) / (2 * l), color: a.color }));
793
+ return dt(f);
792
794
  }
793
- function mn(t, n, e) {
794
- const r = T(t.hex), i = T(n.hex), o = [0, 1, 2].map((a) => Math.round(r[a] + (i[a] - r[a]) * e)), l = t.alpha ?? 1, f = n.alpha ?? 1, s = l + (f - l) * e;
795
- return s < 0.999 ? { hex: L(o), alpha: s } : { hex: L(o) };
795
+ function gn(t, n, e) {
796
+ const r = T(t.hex), i = T(n.hex), o = [0, 1, 2].map((s) => Math.round(r[s] + (i[s] - r[s]) * e)), l = t.alpha ?? 1, f = n.alpha ?? 1, a = l + (f - l) * e;
797
+ return a < 0.999 ? { hex: L(o), alpha: a } : { hex: L(o) };
796
798
  }
797
- function xn(t) {
798
- const n = mt(t);
799
+ function yn(t) {
800
+ const n = gt(t);
799
801
  if (n.kind === "url") return { kind: "url", url: n.url };
800
802
  if (n.kind === "slide") return { kind: "slide", key: n.slideId };
801
803
  if (n.kind === "action") return { kind: "action", action: n.action };
802
804
  }
803
- function gn(t) {
805
+ function kn(t) {
804
806
  return {
805
807
  ...t?.hidden && { hidden: !0 },
806
808
  ...t?.advanceAfter && t.advanceAfter > 0 && { advanceAfterMs: t.advanceAfter },
807
809
  ...t?.section && { section: t.section }
808
810
  };
809
811
  }
810
- function bn(t, n, e) {
811
- const r = { ox: t.x, oy: t.y, nextId: 2, ids: /* @__PURE__ */ new Map(), glue: [], hooks: n, report: e }, i = ht(t.elements, 0, r);
812
- return r.glue.forEach((o) => o()), {
812
+ function Sn(t, n, e) {
813
+ const r = { ox: t.x, oy: t.y, nextId: 2, ids: /* @__PURE__ */ new Map(), glue: [], hooks: n, report: e, ...t.layers && { animTargets: /* @__PURE__ */ new Map() } }, i = pt(t.elements, 0, r);
814
+ r.glue.forEach((l) => l());
815
+ const o = t.layers && r.animTargets ? bn(t.elements, t.layers, r.animTargets, e) : [];
816
+ return {
813
817
  name: t.name,
814
818
  items: i,
815
- background: hn(t, n),
816
- transition: dn(t.slide?.transition),
819
+ background: mn(t, n),
820
+ transition: pn(t.slide?.transition),
817
821
  notes: t.slide?.notes?.trim() ? t.slide.notes : void 0,
818
822
  key: t.slide?.id,
819
- ...gn(t.slide)
823
+ ...kn(t.slide),
824
+ ...o.length && { anims: o }
820
825
  };
821
826
  }
822
- function Mn(t, n, e, r) {
827
+ function bn(t, n, e, r) {
828
+ const i = xt(t.filter((a) => !a.id.includes("@page")), n), o = [];
829
+ let l = 0;
830
+ for (const a of i) {
831
+ const s = a.animation.trigger;
832
+ if (s === "with-prev" || s === "after-prev") {
833
+ const c = o[o.length - 1];
834
+ !c || c.skip ? l++ : c.steps.push(a);
835
+ } else s === "on-load" || s === "on-click" ? o.push({ load: s === "on-load", skip: !1, steps: [a] }) : (o.push({ load: !1, skip: !0, steps: [] }), l++);
836
+ }
837
+ const f = [];
838
+ for (const a of [...o.filter((s) => s.load && !s.skip), ...o.filter((s) => !s.load && !s.skip)]) {
839
+ const s = /* @__PURE__ */ new Set();
840
+ a.steps.forEach((c, u) => {
841
+ const h = e.get(c.elementId), p = u === 0 ? a.load ? "with" : "click" : c.animation.trigger === "after-prev" ? "after" : "with", d = h !== void 0 ? Ot(c.animation, h, p) : null;
842
+ if (!d) {
843
+ l++;
844
+ return;
845
+ }
846
+ const x = `${h}|${d.cls}|${d.effect}`;
847
+ s.has(x) || (s.add(x), f.push(d));
848
+ });
849
+ }
850
+ return l && (r.animsSkipped = (r.animsSkipped ?? 0) + l), f;
851
+ }
852
+ function An(t, n, e, r) {
823
853
  const i = Math.min(e / Math.max(t, 1), r / Math.max(n, 1));
824
854
  return { scale: i, dx: (e - t * i) / 2, dy: (r - n * i) / 2 };
825
855
  }
826
856
  export {
827
- Mn as fitInto,
857
+ An as fitInto,
828
858
  _ as mediaOf,
829
- bn as pageToSlide,
830
- pn as remapPageStops,
831
- gn as showFields,
859
+ Sn as pageToSlide,
860
+ xn as remapPageStops,
861
+ kn as showFields,
832
862
  S as toColor,
833
- dn as transitionOf,
834
- rt as typefaceOf
863
+ pn as transitionOf,
864
+ ot as typefaceOf
835
865
  };