@algorisys/yappydraw 0.8.296 → 0.8.298

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +2 -2
  2. package/chunks/anim-map-D7T1mIAM.js +111 -0
  3. package/chunks/{canva-ai-CkUlVY-Y.js → canva-ai-wYv31lWm.js} +1 -1
  4. package/chunks/{choice-dialog-state-BUFvjtpq.js → choice-dialog-state-DqR_5IIZ.js} +1 -1
  5. package/chunks/{custgeom-DThQ1Qnp.js → custgeom-DUHYX5Vs.js} +28 -26
  6. package/chunks/{design-generator-BlrBbMDM.js → design-generator-DGqLbsqR.js} +1 -1
  7. package/chunks/{drawing-engine-KJLwmUE-.js → drawing-engine-BCPX1hm_.js} +1 -1
  8. package/chunks/{drawings-store-CiDEeh5h.js → drawings-store-BJW1Dmw_.js} +1 -1
  9. package/chunks/{ds-operations-C27tW9qb.js → ds-operations-Bi7WKGwN.js} +1 -1
  10. package/chunks/{export-game-Bcz0A67O.js → export-game-BkUpm1R8.js} +1 -1
  11. package/chunks/{from-yappy-lL1q0m9y.js → from-yappy-fz7AULvS.js} +327 -295
  12. package/chunks/{game-runtime-RZ6Ygr7N.js → game-runtime-Bng0zlkA.js} +40 -40
  13. package/chunks/import-BvGSYTzL.js +1895 -0
  14. package/chunks/{index-NbpsufU1.js → index-Bqlr2FLr.js} +9405 -9245
  15. package/chunks/{lucide-solid-DL_MnmQm.js → lucide-solid-Db2bPSrx.js} +1 -1
  16. package/chunks/{markdown-to-slides-D9CoIzTi.js → markdown-to-slides-D1OVYcQV.js} +1 -1
  17. package/chunks/{morph-animator-C_rDbafN.js → morph-animator-DCs2sEkC.js} +1 -1
  18. package/chunks/{onboarding-tour-B1fDeTqe.js → onboarding-tour-DoZ9Sivk.js} +1 -1
  19. package/chunks/{pdf-vector-ByOSpRwK.js → pdf-vector-DTgEkBKW.js} +1 -1
  20. package/chunks/{search-MWY5OrgG.js → search-4gFkAhbD.js} +9 -9
  21. package/chunks/{slide-generator-8-amet_R.js → slide-generator-D1fy8u8B.js} +1 -1
  22. package/chunks/{turntable-ai-DgSAtAc8.js → turntable-ai-C1B4jzNc.js} +1 -1
  23. package/chunks/write-DDXhxpu-.js +408 -0
  24. package/chunks/yappy-Btkc8ueG.css +1 -0
  25. package/package.json +1 -1
  26. package/yappy.js +1 -1
  27. package/chunks/import-DFZ1uZOp.js +0 -1736
  28. package/chunks/write-B1-j7TNq.js +0 -265
  29. package/chunks/yappy-CvwwkLs8.css +0 -1
@@ -1,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 { a5 as rt, a6 as mt, a7 as xt, a1 as gt, a8 as yt, a9 as kt, aa as bt, ab as Mt, ac as wt, ad as vt, ae as G, af as St, ag as At, ah as $t, ai as It, aj as Ct, ak as Tt, al as zt, am as Ft, an as Pt, ao as Lt, ap as Et, aq as Ot } from "./index-Bqlr2FLr.js";
2
+ import { t as Rt } from "./anim-map-D7T1mIAM.js";
3
+ import { d as P, g as N, t as C, h as Xt } from "./custgeom-DUHYX5Vs.js";
4
+ function Dt(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
  };
@@ -11,23 +12,23 @@ function Et(t) {
11
12
  b: y(m)
12
13
  };
13
14
  }
14
- function R(t) {
15
+ function X(t) {
15
16
  const n = Math.abs(t), e = n > 31308e-7 ? 1.055 * Math.pow(n, 1 / 2.4) - 0.055 : 12.92 * n;
16
17
  return t < 0 ? -e : e;
17
18
  }
18
- function X(t) {
19
+ function D(t) {
19
20
  const n = Math.abs(t), e = n > 0.04045 ? Math.pow((n + 0.055) / 1.055, 2.4) : n / 12.92;
20
21
  return t < 0 ? -e : e;
21
22
  }
22
- function V(t, n, e) {
23
- const r = X(t), i = X(n), o = X(e);
23
+ function q(t, n, e) {
24
+ const r = D(t), i = D(n), o = D(e);
24
25
  return {
25
- r: R(1.2249401762805083 * r - 0.2249401762805082 * i),
26
- g: R(-0.04205697751522136 * r + 1.0420569775152215 * i),
27
- b: R(-0.019637554590334 * r - 0.07863604555063188 * i + 1.0982736001409656 * o)
26
+ r: X(1.2249401762805083 * r - 0.2249401762805082 * i),
27
+ g: X(-0.04205697751522136 * r + 1.0420569775152215 * i),
28
+ b: X(-0.019637554590334 * r - 0.07863604555063188 * i + 1.0982736001409656 * o)
28
29
  };
29
30
  }
30
- function Ot(t) {
31
+ function Bt(t) {
31
32
  return t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
32
33
  }
33
34
  function T(t) {
@@ -40,28 +41,28 @@ 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(Bt);
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 = q(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 = q(...(({ r: c, g: u, b: h }) => [c, u, h])(Dt({ l, c: f, h: a })));
58
+ return [e(s.r), e(s.g), e(s.b)];
58
59
  }
59
- return Rt(n);
60
+ return Yt(n);
60
61
  }
61
- const F = /* @__PURE__ */ new Map();
62
+ const z = /* @__PURE__ */ new Map();
62
63
  let $;
63
- function Rt(t) {
64
- if (F.has(t)) return F.get(t);
64
+ function Yt(t) {
65
+ if (z.has(t)) return z.get(t);
65
66
  let n = null;
66
67
  try {
67
68
  if ($ === void 0) {
@@ -76,10 +77,10 @@ function Rt(t) {
76
77
  } catch {
77
78
  n = null;
78
79
  }
79
- return F.size < 512 && F.set(t, n), n;
80
+ return z.size < 512 && z.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 Wt(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})$/);
@@ -87,23 +88,23 @@ function Xt(t) {
87
88
  const i = n.match(/^(?:rgba?|hsla?)\(([^)]*)\)$/);
88
89
  if (i) {
89
90
  const l = i[1].split(/[\s,/]+/).filter(Boolean);
90
- if (l.length >= 4) return q(l[3]);
91
+ if (l.length >= 4) return V(l[3]);
91
92
  }
92
93
  const o = n.match(/\/\s*([\d.]+%?)\s*\)$/);
93
- return o ? q(o[1]) : 1;
94
+ return o ? V(o[1]) : 1;
94
95
  }
95
- const q = (t) => {
96
+ const V = (t) => {
96
97
  const n = t.endsWith("%") ? parseFloat(t) / 100 : parseFloat(t);
97
98
  return Number.isFinite(n) ? Math.max(0, Math.min(1, n)) : 1;
98
99
  };
99
- function S(t, n = 1) {
100
+ function A(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 = Wt(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", W = {
107
108
  hachure: "ltUpDiag",
108
109
  zigzag: "ltUpDiag",
109
110
  "zigzag-line": "ltUpDiag",
@@ -111,16 +112,16 @@ 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 Ht(t, n) {
115
116
  const e = t.fillStyle || "solid";
116
117
  if ((e === "linear" || e === "radial" || e === "conic") && (t.gradientStops?.length ?? 0) > 0) {
117
- const i = t.gradientStops.map((o) => ({ pos: Math.max(0, Math.min(1, o.offset)), color: S(o.color, n) ?? { hex: "#000000", alpha: 0 } }));
118
+ const i = t.gradientStops.map((o) => ({ pos: Math.max(0, Math.min(1, o.offset)), color: A(o.color, n) ?? { hex: "#000000", alpha: 0 } }));
118
119
  return e === "linear" ? { kind: "linear", stops: i, angle: t.gradientDirection ?? 45, scaled: !0 } : { kind: "radial", stops: i };
119
120
  }
120
- const r = S(t.backgroundColor, n);
121
- return r ? Y[e] ? { kind: "pattern", preset: Y[e], color: r } : { kind: "solid", color: r } : { kind: "none" };
121
+ const r = A(t.backgroundColor, n);
122
+ return r ? W[e] ? { kind: "pattern", preset: W[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) {
@@ -128,14 +129,14 @@ function ot(t) {
128
129
  return n <= (t.strokeWidth || 2) * 1.5 ? "sysDot" : "dash";
129
130
  }
130
131
  }
131
- function N(t, n, e = !1) {
132
- const r = S(t.strokeColor, n);
132
+ function U(t, n, e = !1) {
133
+ const r = A(t.strokeColor, n);
133
134
  if (!r || !(t.strokeWidth > 0)) return null;
134
135
  const i = t.strokeLineCap === "butt" ? "flat" : t.strokeLineCap === "square" ? "sq" : "rnd";
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 _ = (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 jt(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 Nt(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 Ut(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 = jt(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 = A(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 = Ot(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 = Lt(Nt, 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) {
191
- const x = S(c.color, e);
192
- x && (h.color = x);
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 = _(c.paragraphAlign, n ?? "l")), c.listType && c.listType !== "none" && Object.assign(o, Ut(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) {
192
+ const x = A(c.color, e);
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
- const r = S(t.textColor || t.strokeColor || "#000000", n) ?? void 0;
199
+ function lt(t, n, e) {
200
+ const r = A(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: zt(t.fontWeight) >= 600 ? !0 : void 0,
206
+ italic: Tt(t.fontStyle) === "italic" ? !0 : void 0
206
207
  };
207
208
  }
208
- const lt = (t) => Ct(t) / Tt;
209
- function Ht(t, n) {
210
- const e = t.richText && t.richText.length > 0, r = U(t.textAlign, e ? "ctr" : "l");
209
+ const ft = (t) => Ft(t) / Pt;
210
+ function _t(t, n) {
211
+ const e = t.richText && t.richText.length > 0, r = _(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
- const r = U(t.textAlign, "ctr");
224
+ const r = _(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 Zt(t, n, e) {
235
+ const r = [], i = Math.abs(n) / 2, o = Math.abs(e) / 2, l = (a, s, c) => {
236
+ const u = C(P(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 Gt(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] = $t(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 qt = /* @__PURE__ */ new Set(["umlClass", "umlInterface", "qrCode", "video", "codeBlock"]), Vt = /* @__PURE__ */ new Set(["fineliner", "inkbrush", "marker", "ink"]), Jt = /* @__PURE__ */ new Set(["text", "richtext", "image", "line", "arrow"]);
285
+ function Kt(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 (qt.has(t.type) || t.clipMaskId || t.shadowEnabled || t.glowEnabled || (t.featherRadius ?? 0) > 0 || t.blendMode && t.blendMode !== "normal" || t.shearX || t.shearY || kt(t) || bt(t) || Mt(t) || wt(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") {
@@ -304,13 +305,13 @@ function K(t) {
304
305
  return null;
305
306
  }
306
307
  }
307
- function _(t) {
308
+ function Z(t) {
308
309
  if (!t) return null;
309
310
  const n = K(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");
@@ -321,76 +322,76 @@ function _(t) {
321
322
  return null;
322
323
  }
323
324
  }
324
- const A = (t) => t.name || t.type;
325
- function Z(t, n) {
325
+ const v = (t) => t.name || t.type;
326
+ function O(t, n) {
326
327
  const e = Math.abs(t.width), r = Math.abs(t.height), i = Math.min(t.x, t.x + t.width) - n.ox, o = Math.min(t.y, t.y + t.height) - n.oy;
327
328
  return { x: i, y: o, w: e, h: r, rot: t.angle ? t.angle * 180 / Math.PI : void 0, flipH: !!t.flipX || void 0, flipV: !!t.flipY || void 0 };
328
329
  }
329
- function W(t, n, e) {
330
- const r = n.hooks.rasterize(t), i = r ? _(r.dataURL) : null;
330
+ function H(t, n, e) {
331
+ const r = n.hooks.rasterize(t), i = r ? Z(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
- const e = _(t.dataURL);
335
- if (!e) return W([t], n, A(t));
334
+ function Qt(t, n) {
335
+ const e = Z(t.dataURL);
336
+ if (!e) return H([t], n, v(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
- 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
+ return n.report.native++, [{ kind: "picture", id: n.nextId++, name: v(t), ...O(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 tn(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
  }), [{
355
356
  kind: "shape",
356
357
  id: e.nextId++,
357
- name: `${A(t)} label`,
358
+ name: `${v(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 nn(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 en(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 rn(t, n) {
387
+ const e = (t.opacity ?? 100) / 100, r = U(t, e, !0), i = vt(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 || en(P(i.d), i.start, i.end)) {
391
+ const { start: c, end: u } = i, h = {
391
392
  kind: "connector",
392
393
  id: n.nextId++,
393
- name: A(t),
394
+ name: v(t),
394
395
  x: Math.min(c.x, u.x) - n.ox,
395
396
  y: Math.min(c.y, u.y) - n.oy,
396
397
  w: Math.abs(u.x - c.x),
@@ -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 = nn(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
- const c = z(i.d), u = j(c);
413
+ const c = P(i.d), u = N(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
- name: A(t),
419
+ name: v(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(...tn(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 on(t, n) {
435
+ const e = (t.opacity ?? 100) / 100, r = St(t.points), i = U(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
- name: A(t),
442
+ name: v(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,29 +450,29 @@ function tn(t, n) {
449
450
  line: i
450
451
  }];
451
452
  }
452
- function nn(t, n) {
453
+ function sn(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++;
456
- const i = S(t.backgroundColor, e);
457
+ const i = A(t.backgroundColor, e);
457
458
  return [{
458
459
  kind: "shape",
459
460
  id: n.nextId++,
460
- name: A(t),
461
- ...Z(t, n),
461
+ name: v(t),
462
+ ...O(t, n),
462
463
  textBox: !0,
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: _t(t, e)
467
468
  }];
468
469
  }
469
- const en = (t) => {
470
+ const an = (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 cn(t) {
475
+ const n = Et.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 ln(t) {
484
485
  const n = t.fillStyle, e = {
485
486
  ...t,
486
487
  renderStyle: "architectural",
@@ -492,31 +493,31 @@ function on(t) {
492
493
  containerText: void 0,
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
- fillStyle: Y[n] ? "solid" : t.fillStyle
496
- }, r = new St();
496
+ fillStyle: W[n] ? "solid" : t.fillStyle
497
+ }, r = new It();
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
+ Ct(cn(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: A(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,68 +525,68 @@ 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
- 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`;
538
+ const b = +c.getAttribute("x"), M = +c.getAttribute("y"), w = +c.getAttribute("width"), S = +c.getAttribute("height");
539
+ h = `M ${b} ${M} L ${b + w} ${M} L ${b + w} ${M + S} L ${b} ${M + S} 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 = an(c.getAttribute("transform")), d = Xt(P(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 fn(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 yn(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
  };
586
587
  return [{ pos: 0, color: n(0) }, ...t.filter((e) => e.pos > 0 && e.pos < 1), { pos: 1, color: n(1) }];
587
588
  }
588
- function H(t) {
589
+ function j(t) {
589
590
  if (t.fill === !1) return [t];
590
591
  const n = [];
591
592
  for (const i of t.cmds)
@@ -595,97 +596,97 @@ 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 un(t, n) {
600
+ const e = (t.opacity ?? 100) / 100, r = O(t, n), i = ut(t, e);
601
+ let o = Gt(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 = At(t), a = f ? Zt(f, t.width, t.height) : [], s = ln(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 = hn(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
- if (!v) return null;
616
- 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 }));
615
+ const S = ht(y, h);
616
+ if (!S) return null;
617
+ S.length === 1 && S[0] === y.cmds ? g.push(...j({ cmds: k(y.cmds), stroke: w ? void 0 : !1 })) : (g.push(...S.map((R) => ({ cmds: k(R), stroke: !1 }))), w && g.push({ cmds: k(y.cmds), fill: !1 }));
617
618
  } else
618
619
  g.push({ cmds: k(y.cmds), fill: !1, stroke: w ? void 0 : !1 });
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(j) };
624
625
  else return null;
625
626
  }
626
627
  const l = {
627
628
  kind: "shape",
628
629
  id: n.nextId++,
629
- name: A(t),
630
+ name: v(t),
630
631
  ...r,
631
632
  geom: o,
632
- fill: Bt(t, e),
633
- line: N(t, e),
633
+ fill: Ht(t, e),
634
+ line: U(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
+ const dn = (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
640
  let B = null;
640
- const P = 28;
641
- function D(t, n, e) {
641
+ const F = 28;
642
+ function Y(t, n, e) {
642
643
  B ??= document.createElement("canvas").getContext("2d");
643
644
  const r = [];
644
645
  if (!B) return r;
645
- const i = t.map((o) => new Path2D(cn(o)));
646
- 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)));
646
+ const i = t.map((o) => new Path2D(dn(o)));
647
+ for (let o = 0; o < F; o++) for (let l = 0; l < F; l++) {
648
+ const f = e.minX + (l + 0.5) / F * (e.maxX - e.minX), a = e.minY + (o + 0.5) / F * (e.maxY - e.minY);
649
+ r.push(i.some((s) => B.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
- const e = j(t.cmds);
656
+ const e = N(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 = Y([t.cmds], "nonzero", e);
659
+ return nt(r, Y([t.cmds], "evenodd", e)) === 0 ? [t.cmds] : n && nt(r, Y(n, "evenodd", e)) <= 0.03 ? n : null;
659
660
  }
660
- function ln(t, n, e, r, i, o, l) {
661
+ function hn(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 = N(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 = A(s.fill, o * s.fillAlpha), k = s.grad ? fn(s.grad, p, o) : g ? { kind: "solid", color: g } : { kind: "none" }, m = A(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 = (S) => C(S, -p.minX, -p.minY);
666
667
  let w;
667
668
  if (b) {
668
- const v = dt(a, l);
669
- 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 }];
669
+ const S = ht(s, l);
670
+ if (!S) return null;
671
+ w = S.length === 1 && S[0] === s.cmds ? j({ cmds: M(s.cmds), stroke: m ? void 0 : !1 }) : [...S.map((R) => ({ cmds: M(R), 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
- name: `${A(t)} part`,
676
- x: d.minX - i.ox,
677
- y: d.minY - i.oy,
678
- w: h,
676
+ name: `${v(t)} part`,
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",
687
688
  id: i.nextId++,
688
- name: `${A(t)} label`,
689
+ name: `${v(t)} label`,
689
690
  textBox: !0,
690
691
  x: e.x,
691
692
  y: e.y,
@@ -695,24 +696,26 @@ function ln(t, n, e, r, i, o, l) {
695
696
  fill: { kind: "none" },
696
697
  line: null,
697
698
  text: r
698
- }), i.report.native++, { kind: "group", id: i.nextId++, name: A(t), ...e, children: f };
699
+ }), i.report.native++, { kind: "group", id: i.nextId++, name: v(t), ...e, children: f };
699
700
  }
700
- function fn(t, n) {
701
- if (Gt(t)) return W([t], n, A(t));
701
+ function pn(t, n) {
702
+ if (Kt(t)) return H([t], n, v(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 === "chart")
705
+ return n.report.native++, [{ kind: "chart", id: n.nextId++, name: v(t), ...O(t, n), chart: gt(t.chart) }];
706
+ if (t.type === "text" || t.type === "richtext") return sn(t, n);
707
+ if (t.type === "image") return Qt(t, n);
708
+ if (t.type === "line" || t.type === "arrow") return rn(t, n);
709
+ if (Vt.has(t.type)) return on(t, n);
710
+ if (!Jt.has(t.type)) {
711
+ const e = un(t, n);
709
712
  if (e) return e;
710
713
  }
711
714
  } catch {
712
715
  }
713
- return W([t], n, A(t));
716
+ return H([t], n, v(t));
714
717
  }
715
- function ht(t, n, e) {
718
+ function pt(t, n, e) {
716
719
  const r = [];
717
720
  let i = 0;
718
721
  const o = (l) => {
@@ -722,29 +725,30 @@ function ht(t, n, e) {
722
725
  for (; i < t.length; ) {
723
726
  const l = o(t[i]);
724
727
  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++;
728
+ let s = pn(t[i], e);
729
+ const c = kn(t[i].link);
730
+ if (c) for (const u of s) u.link = c;
731
+ e.animTargets && t[i].animations?.length && s.length > 1 && (s = [{ kind: "group", id: e.nextId++, name: v(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
732
  continue;
729
733
  }
730
734
  let f = i;
731
735
  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);
736
+ const a = pt(t.slice(i, f), n + 1, e);
737
+ if (a.length > 1) {
738
+ const s = et(a), c = { kind: "group", id: e.nextId++, name: t[i].groupNames?.[l] || "Group", ...s, children: a };
739
+ if (r.push(c), e.animTargets) for (const u of t.slice(i, f)) e.animTargets.set(u.id, c.id);
740
+ } else r.push(...a);
737
741
  i = f;
738
742
  }
739
743
  return r;
740
744
  }
741
- function un(t) {
745
+ function et(t) {
742
746
  let n = 1 / 0, e = 1 / 0, r = -1 / 0, i = -1 / 0;
743
747
  for (const o of t)
744
748
  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
749
  return { x: n, y: e, w: Math.max(0, r - n), h: Math.max(0, i - e) };
746
750
  }
747
- function dn(t) {
751
+ function mn(t) {
748
752
  if (!t || t.type === "none") return;
749
753
  const n = t.duration ?? 500;
750
754
  switch (t.type) {
@@ -768,68 +772,96 @@ function dn(t) {
768
772
  return;
769
773
  }
770
774
  }
771
- function hn(t, n) {
775
+ function xn(t, n) {
772
776
  const e = t.slide;
773
777
  if (!e) {
774
- const f = S(t.background);
778
+ const f = A(t.background);
775
779
  return f ? { kind: "solid", color: f } : void 0;
776
780
  }
777
781
  const r = e.fillStyle || "solid", i = !e.backgroundImage && (!e.canvasTexture || e.canvasTexture === "none");
778
782
  if (i && r === "solid")
779
- return { kind: "solid", color: S(e.backgroundColor === "transparent" ? "#ffffff" : e.backgroundColor || "#ffffff") ?? { hex: "#ffffff" } };
783
+ return { kind: "solid", color: A(e.backgroundColor === "transparent" ? "#ffffff" : e.backgroundColor || "#ffffff") ?? { hex: "#ffffff" } };
780
784
  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 };
785
+ const f = e.gradientDirection || 0, a = e.gradientStops.map((s) => ({ pos: s.offset, color: A(s.color) ?? { hex: "#ffffff" } }));
786
+ return r === "radial" ? { kind: "radial", stops: a } : { kind: "linear", stops: gn(a, f, t.w, t.h), angle: f };
783
787
  }
784
- const o = n.rasterizeBackground?.(e), l = o ? _(o) : null;
785
- return l ? { kind: "image", media: l } : { kind: "solid", color: S(e.backgroundColor) ?? { hex: "#ffffff" } };
788
+ const o = n.rasterizeBackground?.(e), l = o ? Z(o) : null;
789
+ return l ? { kind: "image", media: l } : { kind: "solid", color: A(e.backgroundColor) ?? { hex: "#ffffff" } };
786
790
  }
787
- function pn(t, n, e, r) {
791
+ function gn(t, n, e, r) {
788
792
  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
793
  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);
794
+ const f = [...t].sort((a, s) => a.pos - s.pos).map((a) => ({ pos: (-o + 2 * o * a.pos + l) / (2 * l), color: a.color }));
795
+ return dt(f);
792
796
  }
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) };
797
+ function yn(t, n, e) {
798
+ 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;
799
+ return a < 0.999 ? { hex: L(o), alpha: a } : { hex: L(o) };
796
800
  }
797
- function xn(t) {
798
- const n = mt(t);
801
+ function kn(t) {
802
+ const n = yt(t);
799
803
  if (n.kind === "url") return { kind: "url", url: n.url };
800
804
  if (n.kind === "slide") return { kind: "slide", key: n.slideId };
801
805
  if (n.kind === "action") return { kind: "action", action: n.action };
802
806
  }
803
- function gn(t) {
807
+ function bn(t) {
804
808
  return {
805
809
  ...t?.hidden && { hidden: !0 },
806
810
  ...t?.advanceAfter && t.advanceAfter > 0 && { advanceAfterMs: t.advanceAfter },
807
811
  ...t?.section && { section: t.section }
808
812
  };
809
813
  }
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()), {
814
+ function An(t, n, e) {
815
+ 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);
816
+ r.glue.forEach((l) => l());
817
+ const o = t.layers && r.animTargets ? Mn(t.elements, t.layers, r.animTargets, e) : [];
818
+ return {
813
819
  name: t.name,
814
820
  items: i,
815
- background: hn(t, n),
816
- transition: dn(t.slide?.transition),
821
+ background: xn(t, n),
822
+ transition: mn(t.slide?.transition),
817
823
  notes: t.slide?.notes?.trim() ? t.slide.notes : void 0,
818
824
  key: t.slide?.id,
819
- ...gn(t.slide)
825
+ ...bn(t.slide),
826
+ ...o.length && { anims: o }
820
827
  };
821
828
  }
822
829
  function Mn(t, n, e, r) {
830
+ const i = xt(t.filter((a) => !a.id.includes("@page")), n), o = [];
831
+ let l = 0;
832
+ for (const a of i) {
833
+ const s = a.animation.trigger;
834
+ if (s === "with-prev" || s === "after-prev") {
835
+ const c = o[o.length - 1];
836
+ !c || c.skip ? l++ : c.steps.push(a);
837
+ } 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++);
838
+ }
839
+ const f = [];
840
+ for (const a of [...o.filter((s) => s.load && !s.skip), ...o.filter((s) => !s.load && !s.skip)]) {
841
+ const s = /* @__PURE__ */ new Set();
842
+ a.steps.forEach((c, u) => {
843
+ const h = e.get(c.elementId), p = u === 0 ? a.load ? "with" : "click" : c.animation.trigger === "after-prev" ? "after" : "with", d = h !== void 0 ? Rt(c.animation, h, p) : null;
844
+ if (!d) {
845
+ l++;
846
+ return;
847
+ }
848
+ const x = `${h}|${d.cls}|${d.effect}`;
849
+ s.has(x) || (s.add(x), f.push(d));
850
+ });
851
+ }
852
+ return l && (r.animsSkipped = (r.animsSkipped ?? 0) + l), f;
853
+ }
854
+ function $n(t, n, e, r) {
823
855
  const i = Math.min(e / Math.max(t, 1), r / Math.max(n, 1));
824
856
  return { scale: i, dx: (e - t * i) / 2, dy: (r - n * i) / 2 };
825
857
  }
826
858
  export {
827
- Mn as fitInto,
828
- _ as mediaOf,
829
- bn as pageToSlide,
830
- pn as remapPageStops,
831
- gn as showFields,
832
- S as toColor,
833
- dn as transitionOf,
834
- rt as typefaceOf
859
+ $n as fitInto,
860
+ Z as mediaOf,
861
+ An as pageToSlide,
862
+ gn as remapPageStops,
863
+ bn as showFields,
864
+ A as toColor,
865
+ mn as transitionOf,
866
+ ot as typefaceOf
835
867
  };