@algorisys/tinyfly 0.81.0 → 0.82.0

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.
@@ -1,70 +1,70 @@
1
- import { b as on, s as Ue, p as Kt, c as tt } from "./sketch-CA8ZXhxI.js";
2
- import { a as Vr } from "./sketch-CA8ZXhxI.js";
3
- import { createRandom as rn, hashSeed as ln, getEasingFunction as nt } from "@algorisys/tinyfly";
4
- function Me(e, t, n) {
5
- const r = e.length;
6
- if (r < 2) return [];
7
- const o = [], l = [], i = (s) => t + (n - t) * s / (r - 1);
8
- return e.forEach((s, h) => {
9
- const a = e[Math.max(0, h - 1)], f = e[Math.min(r - 1, h + 1)], u = Math.hypot(f.x - a.x, f.y - a.y) || 1, p = i(h) / 2, c = -(f.y - a.y) / u * p, g = (f.x - a.x) / u * p;
10
- o.push({ x: s.x + c, y: s.y + g }), l.push({ x: s.x - c, y: s.y - g });
11
- }), [...o, ...l.reverse()];
12
- }
13
- function ot(e, t, n, r) {
14
- const o = t.length;
15
- if (o < 2) return;
16
- const l = Me(t, n, r), i = (s) => n + (r - n) * s / (o - 1);
1
+ import { b as fn, s as Ge, p as It, c as rt } from "./sketch-CA8ZXhxI.js";
2
+ import { a as al } from "./sketch-CA8ZXhxI.js";
3
+ import { createRandom as cn, hashSeed as gn, getEasingFunction as _e } from "@algorisys/tinyfly";
4
+ function Te(e, t, n) {
5
+ const o = e.length;
6
+ if (o < 2) return [];
7
+ const r = [], l = [], i = (s) => t + (n - t) * s / (o - 1);
8
+ return e.forEach((s, a) => {
9
+ const h = e[Math.max(0, a - 1)], f = e[Math.min(o - 1, a + 1)], g = Math.hypot(f.x - h.x, f.y - h.y) || 1, p = i(a) / 2, c = -(f.y - h.y) / g * p, u = (f.x - h.x) / g * p;
10
+ r.push({ x: s.x + c, y: s.y + u }), l.push({ x: s.x - c, y: s.y - u });
11
+ }), [...r, ...l.reverse()];
12
+ }
13
+ function lt(e, t, n, o) {
14
+ const r = t.length;
15
+ if (r < 2) return;
16
+ const l = Te(t, n, o), i = (s) => n + (o - n) * s / (r - 1);
17
17
  e.beginPath(), e.moveTo(l[0].x, l[0].y);
18
18
  for (const s of l.slice(1)) e.lineTo(s.x, s.y);
19
- e.closePath(), e.fill(), t.forEach((s, h) => {
20
- h !== 0 && h !== o - 1 && o > 3 || (e.beginPath(), e.arc(s.x, s.y, i(h) / 2, 0, Math.PI * 2), e.fill());
19
+ e.closePath(), e.fill(), t.forEach((s, a) => {
20
+ a !== 0 && a !== r - 1 && r > 3 || (e.beginPath(), e.arc(s.x, s.y, i(a) / 2, 0, Math.PI * 2), e.fill());
21
21
  });
22
22
  }
23
- function fe(e, t, n, r, o = 16) {
23
+ function fe(e, t, n, o, r = 16) {
24
24
  const l = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, i = [];
25
- for (let s = 0; s <= o; s++) {
26
- const h = s / o, a = h < 0.5 ? { x: e.x + (t.x - e.x) * 2 * h, y: e.y + (t.y - e.y) * 2 * h } : { x: t.x + (n.x - t.x) * (2 * h - 1), y: t.y + (n.y - t.y) * (2 * h - 1) }, f = 1 - h, u = {
27
- x: f * f * e.x + 2 * f * h * l.x + h * h * n.x,
28
- y: f * f * e.y + 2 * f * h * l.y + h * h * n.y
25
+ for (let s = 0; s <= r; s++) {
26
+ const a = s / r, h = a < 0.5 ? { x: e.x + (t.x - e.x) * 2 * a, y: e.y + (t.y - e.y) * 2 * a } : { x: t.x + (n.x - t.x) * (2 * a - 1), y: t.y + (n.y - t.y) * (2 * a - 1) }, f = 1 - a, g = {
27
+ x: f * f * e.x + 2 * f * a * l.x + a * a * n.x,
28
+ y: f * f * e.y + 2 * f * a * l.y + a * a * n.y
29
29
  };
30
- i.push({ x: a.x + (u.x - a.x) * r, y: a.y + (u.y - a.y) * r });
30
+ i.push({ x: h.x + (g.x - h.x) * o, y: h.y + (g.y - h.y) * o });
31
31
  }
32
32
  return i;
33
33
  }
34
- function ct(e, t, n, r, o, l = 0, i = 1, s = 40) {
35
- const h = Math.cos(o), a = Math.sin(o);
36
- return Array.from({ length: s + 1 }, (f, u) => {
37
- const p = l + Math.PI * 2 * i * u / s, c = Math.cos(p) * n, g = Math.sin(p) * r;
38
- return { x: e + c * h - g * a, y: t + c * a + g * h };
34
+ function dt(e, t, n, o, r, l = 0, i = 1, s = 40) {
35
+ const a = Math.cos(r), h = Math.sin(r);
36
+ return Array.from({ length: s + 1 }, (f, g) => {
37
+ const p = l + Math.PI * 2 * i * g / s, c = Math.cos(p) * n, u = Math.sin(p) * o;
38
+ return { x: e + c * a - u * h, y: t + c * h + u * a };
39
39
  });
40
40
  }
41
- function Pt(e, t) {
42
- return t.look === "pencil" ? fn(e, t) : sn(e, t.ink, t.look);
41
+ function $t(e, t) {
42
+ return t.look === "pencil" ? bn(e, t) : un(e, t.ink, t.look);
43
43
  }
44
- function Ae(e, t, n = !1) {
44
+ function Ke(e, t, n = !1) {
45
45
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
46
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
46
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
47
47
  n && e.closePath();
48
48
  }
49
- function sn(e, t, n) {
50
- const r = n === "silhouette", o = r ? 1.25 : 1;
49
+ function un(e, t, n) {
50
+ const o = n === "silhouette", r = o ? 1.25 : 1;
51
51
  return {
52
52
  look: n,
53
53
  ink: t,
54
54
  limb(l, i, s) {
55
- e.fillStyle = t, ot(e, l, i * o, s * o);
55
+ e.fillStyle = t, lt(e, l, i * r, s * r);
56
56
  },
57
57
  line(l, i) {
58
- l.length < 2 || (e.strokeStyle = t, e.lineWidth = i * o, e.lineCap = "round", e.lineJoin = "round", Ae(e, l), e.stroke());
58
+ l.length < 2 || (e.strokeStyle = t, e.lineWidth = i * r, e.lineCap = "round", e.lineJoin = "round", Ke(e, l), e.stroke());
59
59
  },
60
60
  shape(l, i, s) {
61
- Ae(e, l, !0), (i !== null || r) && (e.fillStyle = r ? t : i, e.fill()), !(s <= 0) && (e.strokeStyle = t, e.lineWidth = s * o, e.lineJoin = "round", e.stroke());
61
+ Ke(e, l, !0), (i !== null || o) && (e.fillStyle = o ? t : i, e.fill()), !(s <= 0) && (e.strokeStyle = t, e.lineWidth = s * r, e.lineJoin = "round", e.stroke());
62
62
  },
63
- ellipse(l, i, s, h, a, f, u) {
64
- e.beginPath(), e.ellipse(l, i, s, h, a, 0, Math.PI * 2), (f !== null || r) && (e.fillStyle = r ? t : f, e.fill()), !(u <= 0) && (e.strokeStyle = t, e.lineWidth = u * o, e.stroke());
63
+ ellipse(l, i, s, a, h, f, g) {
64
+ e.beginPath(), e.ellipse(l, i, s, a, h, 0, Math.PI * 2), (f !== null || o) && (e.fillStyle = o ? t : f, e.fill()), !(g <= 0) && (e.strokeStyle = t, e.lineWidth = g * r, e.stroke());
65
65
  },
66
66
  dot(l, i, s) {
67
- e.fillStyle = t, e.beginPath(), e.arc(l, i, s * o, 0, Math.PI * 2), e.fill();
67
+ e.fillStyle = t, e.beginPath(), e.arc(l, i, s * r, 0, Math.PI * 2), e.fill();
68
68
  },
69
69
  guide() {
70
70
  },
@@ -72,101 +72,101 @@ function sn(e, t, n) {
72
72
  }
73
73
  };
74
74
  }
75
- function hn(e, t) {
75
+ function dn(e, t) {
76
76
  const n = [e[0]];
77
- let r = 0;
77
+ let o = 0;
78
78
  for (let i = 1; i < e.length; i++) {
79
- const s = e[i - 1], h = e[i], a = Math.hypot(h.x - s.x, h.y - s.y);
80
- let f = t - r;
81
- for (; f < a; ) {
82
- const u = f / a;
83
- n.push({ x: s.x + (h.x - s.x) * u, y: s.y + (h.y - s.y) * u }), f += t;
79
+ const s = e[i - 1], a = e[i], h = Math.hypot(a.x - s.x, a.y - s.y);
80
+ let f = t - o;
81
+ for (; f < h; ) {
82
+ const g = f / h;
83
+ n.push({ x: s.x + (a.x - s.x) * g, y: s.y + (a.y - s.y) * g }), f += t;
84
84
  }
85
- r = a - (f - t);
85
+ o = h - (f - t);
86
86
  }
87
- const o = e[e.length - 1], l = n[n.length - 1];
88
- return Math.hypot(o.x - l.x, o.y - l.y) > t * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
87
+ const r = e[e.length - 1], l = n[n.length - 1];
88
+ return Math.hypot(r.x - l.x, r.y - l.y) > t * 0.25 ? n.push(r) : n[n.length - 1] = r, n;
89
89
  }
90
- function an(e, t) {
90
+ function pn(e, t) {
91
91
  const n = e.length;
92
- return e.map((r, o) => {
93
- const l = e[Math.max(0, o - 1)], i = e[Math.min(n - 1, o + 1)], s = Math.hypot(i.x - l.x, i.y - l.y) || 1, h = t(n === 1 ? 0 : o / (n - 1));
94
- return { x: r.x - (i.y - l.y) / s * h, y: r.y + (i.x - l.x) / s * h };
92
+ return e.map((o, r) => {
93
+ const l = e[Math.max(0, r - 1)], i = e[Math.min(n - 1, r + 1)], s = Math.hypot(i.x - l.x, i.y - l.y) || 1, a = t(n === 1 ? 0 : r / (n - 1));
94
+ return { x: o.x - (i.y - l.y) / s * a, y: o.y + (i.x - l.x) / s * a };
95
95
  });
96
96
  }
97
- function gt(e) {
98
- const t = [0.6, 1.4, 2.9].map((r) => ({
99
- frequency: r * (0.8 + e.next() * 0.4),
97
+ function pt(e) {
98
+ const t = [0.6, 1.4, 2.9].map((o) => ({
99
+ frequency: o * (0.8 + e.next() * 0.4),
100
100
  phase: e.next() * Math.PI * 2,
101
101
  amount: 0.5 + e.next() * 0.5
102
- })), n = t.reduce((r, o) => r + o.amount, 0);
103
- return (r) => t.reduce((o, l) => o + l.amount * Math.sin(Math.PI * 2 * l.frequency * r + l.phase), 0) / n;
104
- }
105
- function fn(e, t) {
106
- const n = t.pencil ?? {}, r = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), l = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), s = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), h = on(t.time, n.boil ?? 8);
107
- let a = 0;
108
- const f = (g, d, b = !1) => rn(ln(`${t.seed}:${b ? "paper" : h}:${g}:${d}`)), u = (g, d, b, m, S, k = 0) => {
109
- if (g.length < 2) return;
110
- const T = g.slice(1).reduce((W, M, y) => W + Math.hypot(M.x - g[y].x, M.y - g[y].y), 0);
111
- let H = hn(g, Math.max(1.5, Math.min(t.lineWidth * 0.8, T / 24)));
112
- if (k > 0 && H.length >= 2) {
113
- const [W, M] = [H[H.length - 2], H[H.length - 1]], y = Math.hypot(M.x - W.x, M.y - W.y) || 1;
114
- H = [...H, { x: M.x + (M.x - W.x) / y * k, y: M.y + (M.y - W.y) / y * k }];
102
+ })), n = t.reduce((o, r) => o + r.amount, 0);
103
+ return (o) => t.reduce((r, l) => r + l.amount * Math.sin(Math.PI * 2 * l.frequency * o + l.phase), 0) / n;
104
+ }
105
+ function bn(e, t) {
106
+ const n = t.pencil ?? {}, o = t.ink, r = n.roughness ?? Math.max(1, t.lineWidth * 0.12), l = Math.max(1, Math.round(n.passes ?? 2)), i = Math.min(1, Math.max(0, n.pressure ?? 0.25)), s = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = fn(t.time, n.boil ?? 8);
107
+ let h = 0;
108
+ const f = (u, d, b = !1) => cn(gn(`${t.seed}:${b ? "paper" : a}:${u}:${d}`)), g = (u, d, b, m, w, S = 0) => {
109
+ if (u.length < 2) return;
110
+ const M = u.slice(1).reduce((W, v, y) => W + Math.hypot(v.x - u[y].x, v.y - u[y].y), 0);
111
+ let H = dn(u, Math.max(1.5, Math.min(t.lineWidth * 0.8, M / 24)));
112
+ if (S > 0 && H.length >= 2) {
113
+ const [W, v] = [H[H.length - 2], H[H.length - 1]], y = Math.hypot(v.x - W.x, v.y - W.y) || 1;
114
+ H = [...H, { x: v.x + (v.x - W.x) / y * S, y: v.y + (v.y - W.y) / y * S }];
115
115
  }
116
- const w = gt(b), E = gt(b), v = H.length, A = [], I = [];
117
- H.forEach((W, M) => {
118
- const y = v === 1 ? 0 : M / (v - 1), x = H[Math.max(0, M - 1)], O = H[Math.min(v - 1, M + 1)], K = Math.hypot(O.x - x.x, O.y - x.y) || 1, P = -(O.y - x.y) / K, $ = (O.x - x.x) / K, B = w(y) * S, F = Math.min(1, y / 0.08, (1 - y) / 0.08), C = (0.55 + 0.45 * Math.sqrt(Math.max(0, F))) * (1 + i * E(y)), L = Math.max(0.3, d(y) * C / 2), Q = W.x + P * B, ne = W.y + $ * B;
119
- A.push({ x: Q + P * L, y: ne + $ * L }), I.push({ x: Q - P * L, y: ne - $ * L });
120
- }), e.save(), e.globalAlpha *= m, e.fillStyle = r, Ae(e, [...A, ...I.reverse()], !0), e.fill(), e.restore();
121
- }, p = (g, d) => {
122
- const b = a++, m = f(b, 99, !0);
116
+ const k = pt(b), E = pt(b), T = H.length, A = [], I = [];
117
+ H.forEach((W, v) => {
118
+ const y = T === 1 ? 0 : v / (T - 1), x = H[Math.max(0, v - 1)], O = H[Math.min(T - 1, v + 1)], K = Math.hypot(O.x - x.x, O.y - x.y) || 1, P = -(O.y - x.y) / K, B = (O.x - x.x) / K, $ = k(y) * w, _ = Math.min(1, y / 0.08, (1 - y) / 0.08), C = (0.55 + 0.45 * Math.sqrt(Math.max(0, _))) * (1 + i * E(y)), L = Math.max(0.3, d(y) * C / 2), Q = W.x + P * $, ne = W.y + B * $;
119
+ A.push({ x: Q + P * L, y: ne + B * L }), I.push({ x: Q - P * L, y: ne - B * L });
120
+ }), e.save(), e.globalAlpha *= m, e.fillStyle = o, Ke(e, [...A, ...I.reverse()], !0), e.fill(), e.restore();
121
+ }, p = (u, d) => {
122
+ const b = h++, m = f(b, 99, !0);
123
123
  if (m.next() < s) {
124
- const H = (m.next() * 2 - 1) * t.lineWidth * 1.4, w = (m.next() * 2 - 1) * t.lineWidth * 1.4, E = g.map((v) => ({ x: v.x + H, y: v.y + w }));
125
- u(E, (v) => d(v) * 1.8, f(b, 98, !0), 0.035, o), u(E, (v) => d(v) * 0.45, f(b, 97, !0), 0.12, o * 1.5);
124
+ const H = (m.next() * 2 - 1) * t.lineWidth * 1.4, k = (m.next() * 2 - 1) * t.lineWidth * 1.4, E = u.map((T) => ({ x: T.x + H, y: T.y + k }));
125
+ g(E, (T) => d(T) * 1.8, f(b, 98, !0), 0.035, r), g(E, (T) => d(T) * 0.45, f(b, 97, !0), 0.12, r * 1.5);
126
126
  }
127
- const S = g.slice(1).reduce((H, w, E) => H + Math.hypot(w.x - g[E].x, w.y - g[E].y), 0), k = d(0.5) > 4 && S > d(0.5) * 6, T = k ? [-0.3, 0.3, 0] : [0];
127
+ const w = u.slice(1).reduce((H, k, E) => H + Math.hypot(k.x - u[E].x, k.y - u[E].y), 0), S = d(0.5) > 4 && w > d(0.5) * 6, M = S ? [-0.3, 0.3, 0] : [0];
128
128
  for (let H = 0; H < l; H++) {
129
- const w = H === 0;
130
- T.forEach((E, v) => {
131
- const A = f(b, H * 10 + v), I = E === 0 ? g : an(g, (M) => d(M) * E * Math.sqrt(Math.sin(Math.PI * M))), W = !w && E === 0 ? t.lineWidth * (0.3 + A.next() * 0.8) : 0;
132
- u(I, (M) => d(M) * (k ? 0.5 : 1) * (w ? 1 : 0.6), A, w ? 0.85 : 0.45, o * (w ? 0.6 : 1), W);
129
+ const k = H === 0;
130
+ M.forEach((E, T) => {
131
+ const A = f(b, H * 10 + T), I = E === 0 ? u : pn(u, (v) => d(v) * E * Math.sqrt(Math.sin(Math.PI * v))), W = !k && E === 0 ? t.lineWidth * (0.3 + A.next() * 0.8) : 0;
132
+ g(I, (v) => d(v) * (S ? 0.5 : 1) * (k ? 1 : 0.6), A, k ? 0.85 : 0.45, r * (k ? 0.6 : 1), W);
133
133
  });
134
134
  }
135
- }, c = (g, d, b, m, S, k) => {
136
- const H = f(a, 50).next() * Math.PI * 2;
137
- p(ct(g, d, b, m, S, H, 1.08, 48), () => k);
135
+ }, c = (u, d, b, m, w, S) => {
136
+ const H = f(h, 50).next() * Math.PI * 2;
137
+ p(dt(u, d, b, m, w, H, 1.08, 48), () => S);
138
138
  };
139
139
  return {
140
140
  look: "pencil",
141
- ink: r,
142
- limb(g, d, b) {
143
- p(g, (m) => d + (b - d) * m);
141
+ ink: o,
142
+ limb(u, d, b) {
143
+ p(u, (m) => d + (b - d) * m);
144
144
  },
145
- line(g, d) {
146
- p(g, () => d);
145
+ line(u, d) {
146
+ p(u, () => d);
147
147
  },
148
- shape(g, d, b) {
149
- d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Ae(e, g, !0), e.fill(), e.restore()), b > 0 && p([...g, g[0]], () => b);
148
+ shape(u, d, b) {
149
+ d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Ke(e, u, !0), e.fill(), e.restore()), b > 0 && p([...u, u[0]], () => b);
150
150
  },
151
- ellipse(g, d, b, m, S, k, T) {
152
- k !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = k, e.beginPath(), e.ellipse(g, d, b, m, S, 0, Math.PI * 2), e.fill(), e.restore()), c(g, d, b, m, S, T);
151
+ ellipse(u, d, b, m, w, S, M) {
152
+ S !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = S, e.beginPath(), e.ellipse(u, d, b, m, w, 0, Math.PI * 2), e.fill(), e.restore()), c(u, d, b, m, w, M);
153
153
  },
154
- dot(g, d, b) {
155
- e.save(), e.globalAlpha *= 0.9, e.fillStyle = r, e.beginPath(), e.arc(g, d, b, 0, Math.PI * 2), e.fill(), e.restore();
154
+ dot(u, d, b) {
155
+ e.save(), e.globalAlpha *= 0.9, e.fillStyle = o, e.beginPath(), e.arc(u, d, b, 0, Math.PI * 2), e.fill(), e.restore();
156
156
  },
157
- guide(g) {
158
- if (n.construction === !1 || g.length < 2) return;
159
- const d = a++;
160
- u(g, () => Math.max(0.6, t.lineWidth * 0.18), f(d, 0), 0.28, o * 1.2, t.lineWidth);
157
+ guide(u) {
158
+ if (n.construction === !1 || u.length < 2) return;
159
+ const d = h++;
160
+ g(u, () => Math.max(0.6, t.lineWidth * 0.18), f(d, 0), 0.28, r * 1.2, t.lineWidth);
161
161
  },
162
- guideEllipse(g, d, b, m, S) {
162
+ guideEllipse(u, d, b, m, w) {
163
163
  if (n.construction === !1) return;
164
- const k = a++, T = f(k, 0), H = ct(g, d, b, m, S, T.next() * Math.PI * 2, 1.12, 48);
165
- u(H, () => Math.max(0.6, t.lineWidth * 0.18), T, 0.28, o * 1.5);
164
+ const S = h++, M = f(S, 0), H = dt(u, d, b, m, w, M.next() * Math.PI * 2, 1.12, 48);
165
+ g(H, () => Math.max(0.6, t.lineWidth * 0.18), M, 0.28, r * 1.5);
166
166
  }
167
167
  };
168
168
  }
169
- const cn = ["thumb", "index", "middle", "ring", "pinky"], R = {
169
+ const mn = ["thumb", "index", "middle", "ring", "pinky"], R = {
170
170
  "thumb.curl": 0.15,
171
171
  "thumb.across": 0.15,
172
172
  "index.curl": 0.12,
@@ -179,48 +179,48 @@ const cn = ["thumb", "index", "middle", "ring", "pinky"], R = {
179
179
  tilt: 0,
180
180
  roll: 0
181
181
  };
182
- function _(e = {}) {
182
+ function F(e = {}) {
183
183
  return { ...R, ...e };
184
184
  }
185
- const X = (e, t, n, r, o) => ({
185
+ const q = (e, t, n, o, r) => ({
186
186
  "thumb.curl": e,
187
187
  "index.curl": t,
188
188
  "middle.curl": n,
189
- "ring.curl": r,
190
- "pinky.curl": o
189
+ "ring.curl": o,
190
+ "pinky.curl": r
191
191
  }), N = {
192
192
  relaxed: R,
193
- open: _({ ...X(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
194
- spread: _({ ...X(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
195
- flat: _({ ...X(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
196
- fist: _({ ...X(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
197
- point: _({ ...X(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
193
+ open: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
194
+ spread: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
195
+ flat: F({ ...q(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
196
+ fist: F({ ...q(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
197
+ point: F({ ...q(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
198
198
  /** The fist on its side, knuckles toward the viewer, the thumb up */
199
- thumbsUp: _({ ...X(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
200
- peace: _({ ...X(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
201
- ok: _({ ...X(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
202
- pinch: _({ ...X(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
203
- cupped: _({ ...X(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
204
- wave: _({ ...X(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
199
+ thumbsUp: F({ ...q(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
200
+ peace: F({ ...q(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
201
+ ok: F({ ...q(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
202
+ pinch: F({ ...q(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
203
+ cupped: F({ ...q(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
204
+ wave: F({ ...q(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
205
205
  /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
206
- pencilGrip: _({ ...X(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
206
+ pencilGrip: F({ ...q(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
207
207
  /** Holding a handle, a cup or a bar: every finger wrapped round it */
208
- hold: _({ ...X(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
208
+ hold: F({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
209
  };
210
- function be(e, t, n) {
211
- const r = { ...e };
212
- for (const [o, l] of Object.entries(t)) {
213
- const i = e[o] ?? l;
214
- r[o] = i + (l - i) * n;
210
+ function ye(e, t, n) {
211
+ const o = { ...e };
212
+ for (const [r, l] of Object.entries(t)) {
213
+ const i = e[r] ?? l;
214
+ o[r] = i + (l - i) * n;
215
215
  }
216
- return r;
216
+ return o;
217
217
  }
218
- const gn = {
218
+ const yn = {
219
219
  index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
220
220
  middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
221
221
  ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
222
222
  pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
223
- }, un = {
223
+ }, wn = {
224
224
  index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
225
225
  middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
226
226
  pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
@@ -231,7 +231,7 @@ const gn = {
231
231
  /** Where the thumb points with `across` 0 and 1 */
232
232
  out: [-0.7, 0.68, -0.22],
233
233
  across: [0.35, 0.5, -0.8]
234
- }, dn = [82, 100, 62], pn = [48, 72], bn = 3, mn = 13, yn = 0.035, wn = -0.075, kn = [
234
+ }, kn = [82, 100, 62], Sn = [48, 72], En = 3, Hn = 13, Mn = 0.035, vn = -0.075, Tn = [
235
235
  [-0.17, 0],
236
236
  [-0.215, 0.12],
237
237
  [-0.235, 0.26],
@@ -244,182 +244,182 @@ const gn = {
244
244
  [0.225, 0.26],
245
245
  [0.2, 0.1],
246
246
  [0.16, 0]
247
- ], le = (e) => e * Math.PI / 180, ze = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Te = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Ge = (e, t) => [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]], ce = (e) => {
247
+ ], le = (e) => e * Math.PI / 180, Je = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], xe = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Ze = (e, t) => [e[1] * t[2] - e[2] * t[1], e[2] * t[0] - e[0] * t[2], e[0] * t[1] - e[1] * t[0]], ge = (e) => {
248
248
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
249
249
  return [e[0] / t, e[1] / t, e[2] / t];
250
250
  };
251
251
  function ie(e, t, n) {
252
- const r = Math.cos(n), o = Math.sin(n), l = Ge(t, e), i = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
252
+ const o = Math.cos(n), r = Math.sin(n), l = Ze(t, e), i = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
253
253
  return [
254
- e[0] * r + l[0] * o + t[0] * i * (1 - r),
255
- e[1] * r + l[1] * o + t[1] * i * (1 - r),
256
- e[2] * r + l[2] * o + t[2] * i * (1 - r)
254
+ e[0] * o + l[0] * r + t[0] * i * (1 - o),
255
+ e[1] * o + l[1] * r + t[1] * i * (1 - o),
256
+ e[2] * o + l[2] * r + t[2] * i * (1 - o)
257
257
  ];
258
258
  }
259
- const ut = [1, 0, 0], dt = [0, 1, 0], de = [0, 0, 1];
260
- function Sn(e, t, n) {
261
- const r = le(e.fan * (bn + mn * n)), o = [Math.sin(r), Math.cos(r), 0], l = [Math.cos(r), -Math.sin(r), 0], i = [e.knuckle];
259
+ const bt = [1, 0, 0], mt = [0, 1, 0], pe = [0, 0, 1];
260
+ function xn(e, t, n) {
261
+ const o = le(e.fan * (En + Hn * n)), r = [Math.sin(o), Math.cos(o), 0], l = [Math.cos(o), -Math.sin(o), 0], i = [e.knuckle];
262
262
  let s = 0;
263
- e.bones.forEach((f, u) => {
264
- s += le(dn[u] * t), i.push(ze(i[u], Te(ie(o, l, -s), f)));
263
+ e.bones.forEach((f, g) => {
264
+ s += le(kn[g] * t), i.push(Je(i[g], xe(ie(r, l, -s), f)));
265
265
  });
266
- const h = ie(de, l, -s), a = i.map((f, u) => e.width * (1 - 0.14 * (u / (i.length - 1))));
267
- return { joints: i, back: h, widths: a };
266
+ const a = ie(pe, l, -s), h = i.map((f, g) => e.width * (1 - 0.14 * (g / (i.length - 1))));
267
+ return { joints: i, back: a, widths: h };
268
268
  }
269
- function En(e, t, n = 1, r = 1) {
270
- const o = Math.min(1, Math.max(0, t)), l = ce(ze(Te(ce(V.out), 1 - o), Te(ce(V.across), o))), i = ce(Ge(de, l)), s = ce(Ge(l, i)), h = [[V.base[0] * r, V.base[1], V.base[2]]];
271
- let a = 0;
269
+ function An(e, t, n = 1, o = 1) {
270
+ const r = Math.min(1, Math.max(0, t)), l = ge(Je(xe(ge(V.out), 1 - r), xe(ge(V.across), r))), i = ge(Ze(pe, l)), s = ge(Ze(l, i)), a = [[V.base[0] * o, V.base[1], V.base[2]]];
271
+ let h = 0;
272
272
  V.bones.forEach((p, c) => {
273
- c > 0 && (a += le(pn[c - 1] * e)), h.push(ze(h[c], Te(ie(l, i, a), p)));
273
+ c > 0 && (h += le(Sn[c - 1] * e)), a.push(Je(a[c], xe(ie(l, i, h), p)));
274
274
  });
275
- const f = ie(s, i, a), u = [...V.widths, V.widths[V.widths.length - 1] * 0.92].map((p) => p * n);
276
- return { joints: h, back: f, widths: u };
277
- }
278
- function Je(e, t = {}) {
279
- const n = { ...R, ...e }, r = t.size ?? 100, o = t.side ?? "right", l = o === "left" ? -1 : 1, i = le(t.angle ?? 0), s = t.fingers === 4, h = Math.max(0.5, t.plump ?? 1), a = 1 + (h - 1) * 0.7, f = (M) => ({
280
- ...M,
281
- knuckle: [M.knuckle[0] * a, M.knuckle[1], M.knuckle[2]],
282
- width: M.width * h
283
- }), u = le(n.bend ?? 0), p = le(n.tilt ?? 0), c = le(90 * (n.turn ?? 0)), g = (M) => ie(ie(ie(M, ut, -u), de, -p), dt, c), d = Math.cos(i), b = Math.sin(i), m = le(n.roll ?? 0), S = Math.cos(m), k = Math.sin(m), T = (M) => {
284
- const y = M[0] * r, x = -M[1] * r, O = (y * S - x * k) * l, K = y * k + x * S;
275
+ const f = ie(s, i, h), g = [...V.widths, V.widths[V.widths.length - 1] * 0.92].map((p) => p * n);
276
+ return { joints: a, back: f, widths: g };
277
+ }
278
+ function je(e, t = {}) {
279
+ const n = { ...R, ...e }, o = t.size ?? 100, r = t.side ?? "right", l = r === "left" ? -1 : 1, i = le(t.angle ?? 0), s = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, f = (v) => ({
280
+ ...v,
281
+ knuckle: [v.knuckle[0] * h, v.knuckle[1], v.knuckle[2]],
282
+ width: v.width * a
283
+ }), g = le(n.bend ?? 0), p = le(n.tilt ?? 0), c = le(90 * (n.turn ?? 0)), u = (v) => ie(ie(ie(v, bt, -g), pe, -p), mt, c), d = Math.cos(i), b = Math.sin(i), m = le(n.roll ?? 0), w = Math.cos(m), S = Math.sin(m), M = (v) => {
284
+ const y = v[0] * o, x = -v[1] * o, O = (y * w - x * S) * l, K = y * S + x * w;
285
285
  return { x: O * d - K * b, y: O * b + K * d };
286
- }, H = (M) => {
287
- const y = T(M), x = Math.hypot(y.x, y.y);
288
- return x > 1e-6 * r ? { x: y.x / x, y: y.y / x } : { x: 0, y: 0 };
289
- }, w = {
290
- thumb: En(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, h, a)
291
- }, E = s ? un : gn;
292
- for (const M of cn) {
293
- const y = E[M];
294
- y && (w[M] = Sn(f(y), n[`${M}.curl`] ?? 0, n.spread ?? 0));
286
+ }, H = (v) => {
287
+ const y = M(v), x = Math.hypot(y.x, y.y);
288
+ return x > 1e-6 * o ? { x: y.x / x, y: y.y / x } : { x: 0, y: 0 };
289
+ }, k = {
290
+ thumb: An(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
291
+ }, E = s ? wn : yn;
292
+ for (const v of mn) {
293
+ const y = E[v];
294
+ y && (k[v] = xn(f(y), n[`${v}.curl`] ?? 0, n.spread ?? 0));
295
295
  }
296
- const v = {};
297
- for (const [M, y] of Object.entries(w)) {
298
- const x = y.joints.map(g), O = g(y.back);
299
- v[M] = {
300
- points: x.map(T),
301
- depths: x.map((K) => K[2] * r),
302
- widths: y.widths.map((K) => K * r),
296
+ const T = {};
297
+ for (const [v, y] of Object.entries(k)) {
298
+ const x = y.joints.map(u), O = u(y.back);
299
+ T[v] = {
300
+ points: x.map(M),
301
+ depths: x.map((K) => K[2] * o),
302
+ widths: y.widths.map((K) => K * o),
303
303
  nail: O[2],
304
304
  back: H(O)
305
305
  };
306
306
  }
307
- const A = kn.flatMap(([M, y]) => [g([M * a, y, yn]), g([M * a, y, wn])]), I = Mn(A.map(T)), W = A.reduce((M, y) => M + y[2], 0) / A.length * r;
307
+ const A = Tn.flatMap(([v, y]) => [u([v * h, y, Mn]), u([v * h, y, vn])]), I = Pn(A.map(M)), W = A.reduce((v, y) => v + y[2], 0) / A.length * o;
308
308
  return {
309
- size: r,
310
- side: o,
309
+ size: o,
310
+ side: r,
311
311
  wrist: { x: 0, y: 0 },
312
312
  palm: I,
313
313
  palmDepth: W,
314
- palmFacing: -g(de)[2],
315
- fingers: v,
316
- axes: { up: H(g(dt)), across: H(g(ut)), out: H(g(de)) },
317
- curls: Object.fromEntries(Object.keys(v).map((M) => [M, n[`${M}.curl`] ?? 0]))
314
+ palmFacing: -u(pe)[2],
315
+ fingers: T,
316
+ axes: { up: H(u(mt)), across: H(u(bt)), out: H(u(pe)) },
317
+ curls: Object.fromEntries(Object.keys(T).map((v) => [v, n[`${v}.curl`] ?? 0]))
318
318
  };
319
319
  }
320
- function Hn(e, t) {
321
- const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), r = {};
322
- for (const [o, l] of Object.entries(e.fingers))
323
- r[o] = { ...l, points: l.points.map(n) };
324
- return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: r };
320
+ function Kn(e, t) {
321
+ const n = (r) => ({ x: r.x + t.x - e.wrist.x, y: r.y + t.y - e.wrist.y }), o = {};
322
+ for (const [r, l] of Object.entries(e.fingers))
323
+ o[r] = { ...l, points: l.points.map(n) };
324
+ return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: o };
325
325
  }
326
- function Mn(e) {
326
+ function Pn(e) {
327
327
  const t = [...e].sort((l, i) => l.x - i.x || l.y - i.y);
328
328
  if (t.length < 3) return t;
329
- const n = (l, i, s) => (i.x - l.x) * (s.y - l.y) - (i.y - l.y) * (s.x - l.x), r = [];
329
+ const n = (l, i, s) => (i.x - l.x) * (s.y - l.y) - (i.y - l.y) * (s.x - l.x), o = [];
330
330
  for (const l of t) {
331
- for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], l) <= 0; ) r.pop();
332
- r.push(l);
333
- }
334
- const o = [];
335
- for (const l of [...t].reverse()) {
336
331
  for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], l) <= 0; ) o.pop();
337
332
  o.push(l);
338
333
  }
339
- return [...r.slice(0, -1), ...o.slice(0, -1)];
334
+ const r = [];
335
+ for (const l of [...t].reverse()) {
336
+ for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], l) <= 0; ) r.pop();
337
+ r.push(l);
338
+ }
339
+ return [...o.slice(0, -1), ...r.slice(0, -1)];
340
340
  }
341
- const Tn = "#f1c9a5", vn = "#2f2f33";
342
- function rt(e, t, n, r = {}, o = 0) {
343
- const l = Hn(Je(n, r), t), i = r.ink ?? vn, s = r.lineWidth ?? l.size * 0.035, h = r.pen ?? Pt(e, {
344
- look: r.look ?? "clean",
341
+ const Wn = "#f1c9a5", On = "#2f2f33";
342
+ function st(e, t, n, o = {}, r = 0) {
343
+ const l = Kn(je(n, o), t), i = o.ink ?? On, s = o.lineWidth ?? l.size * 0.035, a = o.pen ?? $t(e, {
344
+ look: o.look ?? "clean",
345
345
  ink: i,
346
346
  lineWidth: s,
347
- seed: r.seed ?? 1,
348
- time: o,
349
- pencil: { construction: !1, ...r.pencil }
350
- }), a = r.skin ?? Tn, f = r.nails ?? !0, u = [
347
+ seed: o.seed ?? 1,
348
+ time: r,
349
+ pencil: { construction: !1, ...o.pencil }
350
+ }), h = o.skin ?? Wn, f = o.nails ?? !0, g = [
351
351
  {
352
352
  depth: l.palmDepth,
353
- draw: () => xn(h, l, a, s)
353
+ draw: () => In(a, l, h, s)
354
354
  }
355
355
  ];
356
356
  for (const p of Object.values(l.fingers)) {
357
- const c = p.depths.reduce((g, d) => g + d, 0) / p.depths.length;
358
- u.push({
357
+ const c = p.depths.reduce((u, d) => u + d, 0) / p.depths.length;
358
+ g.push({
359
359
  depth: c,
360
- draw: () => An(e, h, p, a, s, f)
360
+ draw: () => $n(e, a, p, h, s, f)
361
361
  });
362
362
  }
363
- if (r.prop) {
364
- const p = r.prop;
365
- u.push({ depth: p.depth, draw: () => p.draw(h) });
363
+ if (o.prop) {
364
+ const p = o.prop;
365
+ g.push({ depth: p.depth, draw: () => p.draw(a) });
366
366
  }
367
367
  e.save(), e.lineCap = "round", e.lineJoin = "round";
368
- for (const p of [...u].sort((c, g) => c.depth - g.depth)) p.draw();
368
+ for (const p of [...g].sort((c, u) => c.depth - u.depth)) p.draw();
369
369
  return e.restore(), l;
370
370
  }
371
- function xn(e, t, n, r) {
372
- if (e.shape(t.palm, n, r), t.palmFacing < -0.3 && e.look !== "silhouette") {
373
- const { up: o } = t.axes;
371
+ function In(e, t, n, o) {
372
+ if (e.shape(t.palm, n, o), t.palmFacing < -0.3 && e.look !== "silhouette") {
373
+ const { up: r } = t.axes;
374
374
  for (const [l, i] of Object.entries(t.fingers)) {
375
375
  const s = t.curls[l] ?? 0;
376
376
  if (l === "thumb" || s < 0.5) continue;
377
- const h = i.points[0], a = i.widths[0] * 0.42, f = { x: h.x - o.x * a * 0.2, y: h.y - o.y * a * 0.2 }, u = Math.atan2(o.y, o.x), p = Array.from({ length: 7 }, (c, g) => {
378
- const d = u - Math.PI / 2 + Math.PI * g / 6;
379
- return { x: f.x + Math.cos(d) * a, y: f.y + Math.sin(d) * a };
377
+ const a = i.points[0], h = i.widths[0] * 0.42, f = { x: a.x - r.x * h * 0.2, y: a.y - r.y * h * 0.2 }, g = Math.atan2(r.y, r.x), p = Array.from({ length: 7 }, (c, u) => {
378
+ const d = g - Math.PI / 2 + Math.PI * u / 6;
379
+ return { x: f.x + Math.cos(d) * h, y: f.y + Math.sin(d) * h };
380
380
  });
381
- e.line(p, r * 0.6);
381
+ e.line(p, o * 0.6);
382
382
  }
383
383
  }
384
384
  if (t.palmFacing > 0.45 && e.look !== "silhouette") {
385
- const { up: o, across: l } = t.axes, i = t.size, s = t.wrist, h = (f, u) => ({
386
- x: s.x + (l.x * f + o.x * u) * i,
387
- y: s.y + (l.y * f + o.y * u) * i
388
- }), a = t.side === "left" ? -1 : 1;
389
- e.line([h(-0.15 * a, 0.36), h(-0.04 * a, 0.3), h(0.1 * a, 0.33)], r * 0.5);
385
+ const { up: r, across: l } = t.axes, i = t.size, s = t.wrist, a = (f, g) => ({
386
+ x: s.x + (l.x * f + r.x * g) * i,
387
+ y: s.y + (l.y * f + r.y * g) * i
388
+ }), h = t.side === "left" ? -1 : 1;
389
+ e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], o * 0.5);
390
390
  }
391
391
  }
392
- function An(e, t, n, r, o, l) {
393
- const { widths: i } = n, s = Kn(n.points, 2), h = n.points[0], a = s[s.length - 1], f = i[0], u = i[i.length - 1];
392
+ function $n(e, t, n, o, r, l) {
393
+ const { widths: i } = n, s = Bn(n.points, 2), a = n.points[0], h = s[s.length - 1], f = i[0], g = i[i.length - 1];
394
394
  if (e.save(), t.look !== "silhouette") {
395
- e.beginPath(), e.rect(h.x - 1e5, h.y - 1e5, 2e5, 2e5);
396
- const d = f / 2 + o * 1.6;
397
- e.moveTo(h.x + d, h.y), e.arc(h.x, h.y, d, 0, Math.PI * 2), e.clip("evenodd");
395
+ e.beginPath(), e.rect(a.x - 1e5, a.y - 1e5, 2e5, 2e5);
396
+ const d = f / 2 + r * 1.6;
397
+ e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
398
398
  }
399
- if (t.limb(s, f + 2 * o, u + 2 * o), e.restore(), t.look !== "silhouette" && (e.fillStyle = r, ot(e, s, f, u)), t.look === "silhouette" || !l || n.nail < 0.25) return;
400
- const p = s[s.length - 2], c = Pn({ x: a.x - p.x, y: a.y - p.y }) ?? {
399
+ if (t.limb(s, f + 2 * r, g + 2 * r), e.restore(), t.look !== "silhouette" && (e.fillStyle = o, lt(e, s, f, g)), t.look === "silhouette" || !l || n.nail < 0.25) return;
400
+ const p = s[s.length - 2], c = _n({ x: h.x - p.x, y: h.y - p.y }) ?? {
401
401
  x: 0,
402
402
  y: -1
403
- }, g = {
404
- x: a.x - c.x * u * 0.22 + n.back.x * u * 0.1,
405
- y: a.y - c.y * u * 0.22 + n.back.y * u * 0.1
403
+ }, u = {
404
+ x: h.x - c.x * g * 0.22 + n.back.x * g * 0.1,
405
+ y: h.y - c.y * g * 0.22 + n.back.y * g * 0.1
406
406
  };
407
- t.ellipse(g.x, g.y, u * 0.24 * Math.max(0.35, n.nail), u * 0.19, Math.atan2(c.y, c.x), "#f8e3d3", o * 0.45);
407
+ t.ellipse(u.x, u.y, g * 0.24 * Math.max(0.35, n.nail), g * 0.19, Math.atan2(c.y, c.x), "#f8e3d3", r * 0.45);
408
408
  }
409
- function Kn(e, t) {
409
+ function Bn(e, t) {
410
410
  let n = e;
411
- for (let r = 0; r < t; r++) {
411
+ for (let o = 0; o < t; o++) {
412
412
  if (n.length < 3) return n;
413
- const o = [n[0]];
413
+ const r = [n[0]];
414
414
  for (let l = 0; l < n.length - 1; l++) {
415
415
  const i = n[l], s = n[l + 1];
416
- l > 0 && o.push({ x: i.x * 0.75 + s.x * 0.25, y: i.y * 0.75 + s.y * 0.25 }), l < n.length - 2 && o.push({ x: i.x * 0.25 + s.x * 0.75, y: i.y * 0.25 + s.y * 0.75 });
416
+ l > 0 && r.push({ x: i.x * 0.75 + s.x * 0.25, y: i.y * 0.75 + s.y * 0.25 }), l < n.length - 2 && r.push({ x: i.x * 0.25 + s.x * 0.75, y: i.y * 0.25 + s.y * 0.75 });
417
417
  }
418
- o.push(n[n.length - 1]), n = o;
418
+ r.push(n[n.length - 1]), n = r;
419
419
  }
420
420
  return n;
421
421
  }
422
- const Pn = (e) => {
422
+ const _n = (e) => {
423
423
  const t = Math.hypot(e.x, e.y);
424
424
  return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
425
425
  }, z = {
@@ -459,7 +459,7 @@ const Pn = (e) => {
459
459
  function D(e) {
460
460
  return { ...z, ...e };
461
461
  }
462
- const Wt = {
462
+ const Bt = {
463
463
  mouth: 0,
464
464
  smile: 0,
465
465
  mouthWidth: 1,
@@ -470,8 +470,8 @@ const Wt = {
470
470
  browTilt: 0,
471
471
  lookX: 0,
472
472
  lookY: 0
473
- }, Y = (e) => ({ ...Wt, ...e }), J = {
474
- neutral: Wt,
473
+ }, Y = (e) => ({ ...Bt, ...e }), J = {
474
+ neutral: Bt,
475
475
  happy: Y({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
476
476
  joyful: Y({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
477
477
  sad: Y({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
@@ -490,10 +490,10 @@ const Wt = {
490
490
  smug: Y({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
491
491
  wink: Y({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
492
492
  };
493
- function Ot(e, t) {
493
+ function _t(e, t) {
494
494
  return { ...e, ...typeof t == "string" ? J[t] : t };
495
495
  }
496
- const Wn = {
496
+ const Fn = {
497
497
  rest: z,
498
498
  wave: D({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...J.happy }),
499
499
  cheer: D({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...J.joyful }),
@@ -515,127 +515,127 @@ const Wn = {
515
515
  sideSplit: D({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...J.happy }),
516
516
  // Front split, in profile: the left leg forward (+x), the right leg back.
517
517
  frontSplit: D({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...J.happy })
518
- }, It = Object.keys(z);
519
- function me(e, t, n) {
520
- const r = { ...e };
521
- for (const o of It) r[o] = e[o] + (t[o] - e[o]) * n;
522
- return r;
523
- }
524
- const Ze = 24, pt = 4, bt = 28, On = 40;
525
- function In(e, t = z, n = 1) {
526
- const r = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, l = (a) => a <= On, i = (a) => l(a) ? 22 * r : a, s = l(t.leftShoulder) ? t.leftElbow - bt * Math.max(0, -r) : t.leftElbow, h = l(t.rightShoulder) ? t.rightElbow + bt * Math.max(0, r) : t.rightElbow;
518
+ }, Ft = Object.keys(z);
519
+ function we(e, t, n) {
520
+ const o = { ...e };
521
+ for (const r of Ft) o[r] = e[r] + (t[r] - e[r]) * n;
522
+ return o;
523
+ }
524
+ const Qe = 24, yt = 4, wt = 28, Rn = 40;
525
+ function Yn(e, t = z, n = 1) {
526
+ const o = Math.sin(e * Math.PI * 2) * n, r = Math.cos(e * Math.PI * 2) * n, l = (h) => h <= Rn, i = (h) => l(h) ? 22 * o : h, s = l(t.leftShoulder) ? t.leftElbow - wt * Math.max(0, -o) : t.leftElbow, a = l(t.rightShoulder) ? t.rightElbow + wt * Math.max(0, o) : t.rightElbow;
527
527
  return {
528
528
  ...t,
529
529
  // Lean into the walk, and keep the head a little more level than the body.
530
- lean: t.lean + pt * n,
531
- headTilt: t.headTilt - pt * 0.5 * n,
530
+ lean: t.lean + yt * n,
531
+ headTilt: t.headTilt - yt * 0.5 * n,
532
532
  leftElbow: s,
533
- rightElbow: h,
533
+ rightElbow: a,
534
534
  // Left foot forward while swing > 0, right foot back; then the other way.
535
- leftHip: -Ze * r,
536
- rightHip: -Ze * r,
535
+ leftHip: -Qe * o,
536
+ rightHip: -Qe * o,
537
537
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
538
538
  // knee folds toward the centre, which is backward only for the right leg.
539
- leftKnee: -30 * Math.max(0, o),
540
- rightKnee: 30 * Math.max(0, -o),
539
+ leftKnee: -30 * Math.max(0, r),
540
+ rightKnee: 30 * Math.max(0, -r),
541
541
  // Arms swing against the legs: left arm back while the left foot is forward.
542
542
  leftShoulder: i(t.leftShoulder),
543
543
  rightShoulder: i(t.rightShoulder)
544
544
  };
545
545
  }
546
- function Sr(e, t = 1) {
547
- return 4 * ((je + Ke) * e) * Math.sin(Ze * t * Math.PI / 180);
546
+ function Kr(e, t = 1) {
547
+ return 4 * ((Ve + Pe) * e) * Math.sin(Qe * t * Math.PI / 180);
548
548
  }
549
- function Bn(e) {
549
+ function Ln(e) {
550
550
  const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
551
551
  return t * n;
552
552
  }
553
- const Bt = 0.12, mt = 0.46, $n = 1 - 2 * Bt, Fn = 0.1, _n = 0.21, Rn = 0.19, je = 0.24, Ke = 0.22, $t = 0.12, Yn = 0.14, Ft = 0.33, yt = 0.7, wt = 0.3, Ln = 0.35, Nn = [1.7, 1.05], Cn = [1.3, 0.75], kt = [1.45, 0.85], Dn = [1.15, 0.75], St = 0.06, qn = 0.7, Xn = 0.65, _t = 0.075, Un = 0.3, zn = 0.02, Gn = 0.012, Jn = 12, Zn = 0.25, ye = 90, jn = 0.25, Qn = 0.04, Rt = 0.01, se = (e) => Math.min(1, Math.max(0, e ?? 0));
554
- function Er(e, t = 1) {
555
- return Ke * e * t;
553
+ const Rt = 0.12, kt = 0.46, Nn = 1 - 2 * Rt, Cn = 0.1, Dn = 0.21, Xn = 0.19, Ve = 0.24, Pe = 0.22, Yt = 0.12, qn = 0.14, Lt = 0.33, St = 0.7, Et = 0.3, Un = 0.35, zn = [1.7, 1.05], Gn = [1.3, 0.75], Ht = [1.45, 0.85], Jn = [1.15, 0.75], Mt = 0.06, Zn = 0.7, jn = 0.65, Nt = 0.075, Qn = 0.3, Vn = 0.02, eo = 0.012, to = 12, no = 0.25, ke = 90, oo = 0.25, ro = 0.04, Ct = 0.01, se = (e) => Math.min(1, Math.max(0, e ?? 0));
554
+ function Pr(e, t = 1) {
555
+ return Pe * e * t;
556
556
  }
557
- const Qe = -0.12, Yt = 0.4, Z = (e) => e * Math.PI / 180, Vn = (e, t) => ({ x: t * Math.sin(Z(e)), y: Math.cos(Z(e)) }), Lt = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), Nt = (e, t, n, r) => e - 0.3 * t - n * 0.14 * t - Math.max(0, r - 1) * 0.12 * t;
558
- function eo(e, t, n, r, o, l) {
559
- const i = Math.max(1, Math.min(l * 0.6, Yn * n)), s = se(t.turn), h = ($t + Ft * s) * n, a = r + Qe * n, f = h + t.lookX * 0.08 * n, u = t.lookY * 0.07 * n, p = [
557
+ const et = -0.12, Dt = 0.4, Z = (e) => e * Math.PI / 180, lo = (e, t) => ({ x: t * Math.sin(Z(e)), y: Math.cos(Z(e)) }), Xt = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), qt = (e, t, n, o) => e - 0.3 * t - n * 0.14 * t - Math.max(0, o - 1) * 0.12 * t;
558
+ function so(e, t, n, o, r, l) {
559
+ const i = Math.max(1, Math.min(l * 0.6, qn * n)), s = se(t.turn), a = (Yt + Lt * s) * n, h = o + et * n, f = a + t.lookX * 0.08 * n, g = t.lookY * 0.07 * n, p = [
560
560
  // The left eye is on the far side; turning closes it up more than the near one.
561
- { x: -0.34 * n * (1 - yt * s), squeeze: 1 - yt * s, open: t.leftEye, brow: t.leftBrow, side: -1 },
562
- { x: 0.34 * n * (1 - wt * s), squeeze: 1 - wt * s, open: t.rightEye, brow: t.rightBrow, side: 1 }
561
+ { x: -0.34 * n * (1 - St * s), squeeze: 1 - St * s, open: t.leftEye, brow: t.leftBrow, side: -1 },
562
+ { x: 0.34 * n * (1 - Et * s), squeeze: 1 - Et * s, open: t.rightEye, brow: t.rightBrow, side: 1 }
563
563
  ];
564
- e.fillStyle = o, e.strokeStyle = o, e.lineWidth = i;
564
+ e.fillStyle = r, e.strokeStyle = r, e.lineWidth = i;
565
565
  for (const m of p) {
566
- const S = Lt(m.open, t.blink);
567
- if (S < 0.2) {
568
- const w = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
569
- e.beginPath(), e.moveTo(m.x + h - 0.12 * n, a), e.quadraticCurveTo(m.x + h, a + w, m.x + h + 0.12 * n, a), e.stroke();
566
+ const w = Xt(m.open, t.blink);
567
+ if (w < 0.2) {
568
+ const k = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
569
+ e.beginPath(), e.moveTo(m.x + a - 0.12 * n, h), e.quadraticCurveTo(m.x + a, h + k, m.x + a + 0.12 * n, h), e.stroke();
570
570
  } else {
571
- if (S > 1.2) {
572
- const E = 0.13 * n * S;
573
- e.beginPath(), e.ellipse(m.x + h, a, E * 0.85, E, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
571
+ if (w > 1.2) {
572
+ const E = 0.13 * n * w;
573
+ e.beginPath(), e.ellipse(m.x + a, h, E * 0.85, E, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = r;
574
574
  }
575
- const w = S > 1.2 ? 0.075 * n : 0.1 * n;
576
- e.beginPath(), e.ellipse(m.x + f, a + u, w, w * 1.1 * Math.min(S, 1), 0, 0, Math.PI * 2), e.fill();
575
+ const k = w > 1.2 ? 0.075 * n : 0.1 * n;
576
+ e.beginPath(), e.ellipse(m.x + f, h + g, k, k * 1.1 * Math.min(w, 1), 0, 0, Math.PI * 2), e.fill();
577
577
  }
578
- const k = Nt(a, n, m.brow, S), T = m.x + h - m.side * 0.13 * n * m.squeeze, H = m.x + h + m.side * 0.13 * n * m.squeeze;
579
- e.beginPath(), e.moveTo(H, k), e.lineTo(T, k - t.browTilt * 0.1 * n), e.stroke();
578
+ const S = qt(h, n, m.brow, w), M = m.x + a - m.side * 0.13 * n * m.squeeze, H = m.x + a + m.side * 0.13 * n * m.squeeze;
579
+ e.beginPath(), e.moveTo(H, S), e.lineTo(M, S - t.browTilt * 0.1 * n), e.stroke();
580
580
  }
581
- const c = r + Yt * n, g = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Ln * s), d = Math.min(1, Math.max(0, t.mouth));
581
+ const c = o + Dt * n, u = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Un * s), d = Math.min(1, Math.max(0, t.mouth));
582
582
  if (e.beginPath(), d <= 0.05) {
583
- e.moveTo(h - g, c), e.quadraticCurveTo(h, c + t.smile * 0.25 * n, h + g, c), e.stroke();
583
+ e.moveTo(a - u, c), e.quadraticCurveTo(a, c + t.smile * 0.25 * n, a + u, c), e.stroke();
584
584
  return;
585
585
  }
586
586
  const b = 0.3 * n * d;
587
- t.smile > 0.3 ? (e.moveTo(h - g, c - 0.05 * n), e.lineTo(h + g, c - 0.05 * n), e.quadraticCurveTo(h, c + b * 2, h - g, c - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(h - g, c + b * 0.6), e.lineTo(h + g, c + b * 0.6), e.quadraticCurveTo(h, c - b * 1.4, h - g, c + b * 0.6)) : e.ellipse(h, c, g * 0.8, b, 0, 0, Math.PI * 2), e.fill();
587
+ t.smile > 0.3 ? (e.moveTo(a - u, c - 0.05 * n), e.lineTo(a + u, c - 0.05 * n), e.quadraticCurveTo(a, c + b * 2, a - u, c - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - u, c + b * 0.6), e.lineTo(a + u, c + b * 0.6), e.quadraticCurveTo(a, c - b * 1.4, a - u, c + b * 0.6)) : e.ellipse(a, c, u * 0.8, b, 0, 0, Math.PI * 2), e.fill();
588
588
  }
589
- function Ct(e, t) {
590
- const n = t.height ?? 300, r = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(r), l = (t.headSize ?? 2 * Bt) / 2, i = t.headSize === void 0 ? $n : 1 - 2 * l, s = l * n, h = se(e.sit), a = e.leftHip + (-ye - e.leftHip) * h, f = e.leftKnee + (-ye - e.leftKnee) * h, u = e.rightHip + (ye - e.rightHip) * h, p = e.rightKnee + (ye - e.rightKnee) * h, c = t.classic === !0, g = se(e.turn), d = (K, P, $, B, F) => {
591
- const C = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Z(P - $) / 2) + Z(B))), L = Math.max(-1, Math.min(1, qn + F)), Q = g + (1 - g) * K * L;
592
- return c ? { x: 0, y: 0 } : { x: Math.cos(C) * St * Q, y: Math.sin(C) * St };
589
+ function Ut(e, t) {
590
+ const n = t.height ?? 300, o = Math.min(3, Math.max(0.3, e.stretch ?? 1)), r = Math.sqrt(o), l = (t.headSize ?? 2 * Rt) / 2, i = t.headSize === void 0 ? Nn : 1 - 2 * l, s = l * n, a = se(e.sit), h = e.leftHip + (-ke - e.leftHip) * a, f = e.leftKnee + (-ke - e.leftKnee) * a, g = e.rightHip + (ke - e.rightHip) * a, p = e.rightKnee + (ke - e.rightKnee) * a, c = t.classic === !0, u = se(e.turn), d = (K, P, B, $, _) => {
591
+ const C = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Z(P - B) / 2) + Z($))), L = Math.max(-1, Math.min(1, Zn + _)), Q = u + (1 - u) * K * L;
592
+ return c ? { x: 0, y: 0 } : { x: Math.cos(C) * Mt * Q, y: Math.sin(C) * Mt };
593
593
  }, b = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, m = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
594
- let S = 0;
595
- if (h > 0 || !c) {
596
- const K = (F, C, L, Q, ne) => je * Math.cos(Z(C)) + Ke * Math.cos(Z(C - L)) + Math.max(0, d(F, C, L, Q, ne).y), P = Math.max(
597
- K(-1, a, f, b.left, m.left),
598
- K(1, u, p, b.right, m.right)
599
- ), $ = 1 - se((e.rise ?? 0) / Qn), B = (c ? Math.min(1, h / jn) : 1) * $;
600
- S = (mt - P) * B * n * r;
594
+ let w = 0;
595
+ if (a > 0 || !c) {
596
+ const K = (_, C, L, Q, ne) => Ve * Math.cos(Z(C)) + Pe * Math.cos(Z(C - L)) + Math.max(0, d(_, C, L, Q, ne).y), P = Math.max(
597
+ K(-1, h, f, b.left, m.left),
598
+ K(1, g, p, b.right, m.right)
599
+ ), B = 1 - se((e.rise ?? 0) / ro), $ = (c ? Math.min(1, a / oo) : 1) * B;
600
+ w = (kt - P) * $ * n * o;
601
601
  }
602
- const k = -mt * n * r + S, T = -i * n * r + S, H = c ? 0 : (zn * se(e.turn) + Gn * h) * n * r, w = H === 0 ? [{ x: 0, y: k }, { x: 0, y: T }] : fe({ x: 0, y: k }, { x: -H, y: (k + T) / 2 }, { x: 0, y: T }, 1, 8), E = T + Fn * n * r, v = (t.shoulderWidth ?? 0) * n * Math.cos(g * Math.PI / 2), A = (K, P, $, B, F) => {
603
- const C = Vn($, B);
604
- return { x: K + C.x * F * n, y: P + C.y * F * n };
605
- }, I = (K, P, $) => {
606
- const B = A(0, k, P, K, je * r);
607
- return { root: { x: 0, y: k }, joint: B, end: A(B.x, B.y, P - $, K, Ke * r) };
608
- }, W = (K, P, $) => {
609
- const B = { x: K * v, y: E }, F = A(B.x, B.y, P, K, _n * o);
610
- return { root: B, joint: F, end: A(F.x, F.y, P + $, K, Rn * o) };
611
- }, M = { left: I(-1, a, f), right: I(1, u, p) }, y = (K, P, $, B, F, C) => {
612
- const L = d(K, $, B, F, C);
613
- return { x: P.end.x + L.x * n * r, y: P.end.y + L.y * n * r };
614
- }, x = (K, P, $, B, F) => A(P.end.x, P.end.y, $ + B + F, K, _t * o), O = {
602
+ const S = -kt * n * o + w, M = -i * n * o + w, H = c ? 0 : (Vn * se(e.turn) + eo * a) * n * o, k = H === 0 ? [{ x: 0, y: S }, { x: 0, y: M }] : fe({ x: 0, y: S }, { x: -H, y: (S + M) / 2 }, { x: 0, y: M }, 1, 8), E = M + Cn * n * o, T = (t.shoulderWidth ?? 0) * n * Math.cos(u * Math.PI / 2), A = (K, P, B, $, _) => {
603
+ const C = lo(B, $);
604
+ return { x: K + C.x * _ * n, y: P + C.y * _ * n };
605
+ }, I = (K, P, B) => {
606
+ const $ = A(0, S, P, K, Ve * o);
607
+ return { root: { x: 0, y: S }, joint: $, end: A($.x, $.y, P - B, K, Pe * o) };
608
+ }, W = (K, P, B) => {
609
+ const $ = { x: K * T, y: E }, _ = A($.x, $.y, P, K, Dn * r);
610
+ return { root: $, joint: _, end: A(_.x, _.y, P + B, K, Xn * r) };
611
+ }, v = { left: I(-1, h, f), right: I(1, g, p) }, y = (K, P, B, $, _, C) => {
612
+ const L = d(K, B, $, _, C);
613
+ return { x: P.end.x + L.x * n * o, y: P.end.y + L.y * n * o };
614
+ }, x = (K, P, B, $, _) => A(P.end.x, P.end.y, B + $ + _, K, Nt * r), O = {
615
615
  left: W(-1, e.leftShoulder, e.leftElbow),
616
616
  right: W(1, e.rightShoulder, e.rightElbow)
617
617
  };
618
618
  return {
619
619
  height: n,
620
620
  facing: (t.facing ?? 1) < 0 ? -1 : 1,
621
- stretch: r,
621
+ stretch: o,
622
622
  lineWidth: t.lineWidth ?? n * 0.025,
623
- rubber: Math.min(1, Math.max(c ? 0 : Un, t.rubber ?? 0)),
623
+ rubber: Math.min(1, Math.max(c ? 0 : Qn, t.rubber ?? 0)),
624
624
  r: s,
625
625
  // The head keeps its area: taller and narrower when stretched.
626
- headRx: s / Math.sqrt(r),
627
- headRy: s * Math.sqrt(r),
628
- hipY: k,
629
- neckY: T,
630
- drop: S,
631
- lean: c ? e.lean : e.lean + Jn * Math.sin(Math.PI * h),
626
+ headRx: s / Math.sqrt(o),
627
+ headRy: s * Math.sqrt(o),
628
+ hipY: S,
629
+ neckY: M,
630
+ drop: w,
631
+ lean: c ? e.lean : e.lean + to * Math.sin(Math.PI * a),
632
632
  classic: c,
633
- legs: M,
633
+ legs: v,
634
634
  toes: {
635
- left: y(-1, M.left, a, f, b.left, m.left),
636
- right: y(1, M.right, u, p, b.right, m.right)
635
+ left: y(-1, v.left, h, f, b.left, m.left),
636
+ right: y(1, v.right, g, p, b.right, m.right)
637
637
  },
638
- spine: w,
638
+ spine: k,
639
639
  arms: O,
640
640
  handTips: {
641
641
  left: x(-1, O.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
@@ -643,36 +643,36 @@ function Ct(e, t) {
643
643
  }
644
644
  };
645
645
  }
646
- const ge = (e, t) => t === 0 ? [e.root, e.joint, e.end] : fe(e.root, e.joint, e.end, t);
647
- function Pe(e, t, n) {
648
- const r = Math.cos(n), o = Math.sin(n), l = e.x - t.x, i = e.y - t.y;
649
- return { x: t.x + l * r - i * o, y: t.y + l * o + i * r };
646
+ const ue = (e, t) => t === 0 ? [e.root, e.joint, e.end] : fe(e.root, e.joint, e.end, t);
647
+ function We(e, t, n) {
648
+ const o = Math.cos(n), r = Math.sin(n), l = e.x - t.x, i = e.y - t.y;
649
+ return { x: t.x + l * o - i * r, y: t.y + l * r + i * o };
650
650
  }
651
- function Dt(e, t, n = !0) {
652
- const r = no(e, t), o = t.spin ?? 0, l = t.rise ?? 0;
653
- return n && (o !== 0 || l !== 0) ? to(r, e, o, l) : r;
651
+ function zt(e, t, n = !0) {
652
+ const o = ao(e, t), r = t.spin ?? 0, l = t.rise ?? 0;
653
+ return n && (r !== 0 || l !== 0) ? io(o, e, r, l) : o;
654
654
  }
655
- function qt(e, t, n) {
655
+ function Gt(e, t, n) {
656
656
  return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Z(t), lift: n * e.height };
657
657
  }
658
- function to(e, t, n, r) {
659
- const { pivot: o, angle: l, lift: i } = qt(t, n, r), s = (p) => {
660
- const c = Pe(p, o, l);
658
+ function io(e, t, n, o) {
659
+ const { pivot: r, angle: l, lift: i } = Gt(t, n, o), s = (p) => {
660
+ const c = We(p, r, l);
661
661
  return { x: c.x, y: c.y - i };
662
- }, h = (p) => ({ left: s(p.left), right: s(p.right) }), a = { left: Math.max(s(e.feet.left).y, s(e.toes.left).y), right: Math.max(s(e.feet.right).y, s(e.toes.right).y) }, f = Math.max(a.left, a.right), u = Rt * t.height;
662
+ }, a = (p) => ({ left: s(p.left), right: s(p.right) }), h = { left: Math.max(s(e.feet.left).y, s(e.toes.left).y), right: Math.max(s(e.feet.right).y, s(e.toes.right).y) }, f = Math.max(h.left, h.right), g = Ct * t.height;
663
663
  return {
664
664
  ...e,
665
665
  hip: s(e.hip),
666
666
  neck: s(e.neck),
667
- shoulders: h(e.shoulders),
668
- elbows: h(e.elbows),
669
- hands: h(e.hands),
670
- fingertips: h(e.fingertips),
671
- knees: h(e.knees),
672
- feet: h(e.feet),
673
- toes: h(e.toes),
667
+ shoulders: a(e.shoulders),
668
+ elbows: a(e.elbows),
669
+ hands: a(e.hands),
670
+ fingertips: a(e.fingertips),
671
+ knees: a(e.knees),
672
+ feet: a(e.feet),
673
+ toes: a(e.toes),
674
674
  feetY: f,
675
- grounded: { left: a.left >= f - u, right: a.right >= f - u },
675
+ grounded: { left: h.left >= f - g, right: h.right >= f - g },
676
676
  handAngle: { left: e.handAngle.left + l, right: e.handAngle.right + l },
677
677
  limbs: {
678
678
  leftArm: e.limbs.leftArm.map(s),
@@ -684,42 +684,42 @@ function to(e, t, n, r) {
684
684
  head: { ...e.head, center: s(e.head.center), angle: e.head.angle + l }
685
685
  };
686
686
  }
687
- function no(e, t) {
688
- const n = Z(e.lean), r = Z(t.headTilt), o = { x: 0, y: e.hipY }, l = (k) => ({ x: e.facing * k.x, y: k.y }), i = (k) => l(Pe(k, o, n)), s = (k) => i(Pe({ x: k.x, y: k.y + e.neckY }, { x: 0, y: e.neckY }, r)), h = ge(e.arms.left, e.rubber).map(i), a = ge(e.arms.right, e.rubber).map(i), f = (k, T) => Math.atan2(T.y - k.y, T.x - k.x), u = { left: i(e.handTips.left), right: i(e.handTips.right) }, p = (k, T) => {
689
- const [H, w] = k.slice(-2), E = e.arms[T], v = f(i(E.end), u[T]) - f(i(E.joint), i(E.end));
690
- return f(H, w) + v;
687
+ function ao(e, t) {
688
+ const n = Z(e.lean), o = Z(t.headTilt), r = { x: 0, y: e.hipY }, l = (S) => ({ x: e.facing * S.x, y: S.y }), i = (S) => l(We(S, r, n)), s = (S) => i(We({ x: S.x, y: S.y + e.neckY }, { x: 0, y: e.neckY }, o)), a = ue(e.arms.left, e.rubber).map(i), h = ue(e.arms.right, e.rubber).map(i), f = (S, M) => Math.atan2(M.y - S.y, M.x - S.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, p = (S, M) => {
689
+ const [H, k] = S.slice(-2), E = e.arms[M], T = f(i(E.end), g[M]) - f(i(E.joint), i(E.end));
690
+ return f(H, k) + T;
691
691
  };
692
692
  let c = 1 / 0;
693
- for (const [k, T] of [
693
+ for (const [S, M] of [
694
694
  [t.leftBrow, t.leftEye],
695
695
  [t.rightBrow, t.rightEye]
696
696
  ]) {
697
- const H = Nt(Qe, 1, k, Lt(T, t.blink));
697
+ const H = qt(et, 1, S, Xt(M, t.blink));
698
698
  c = Math.min(c, H, H - t.browTilt * 0.1);
699
699
  }
700
- const g = { left: l(e.legs.left.end), right: l(e.legs.right.end) }, d = { left: l(e.toes.left), right: l(e.toes.right) }, b = { left: Math.max(g.left.y, d.left.y), right: Math.max(g.right.y, d.right.y) }, m = Math.max(b.left, b.right), S = Rt * e.height;
700
+ const u = { left: l(e.legs.left.end), right: l(e.legs.right.end) }, d = { left: l(e.toes.left), right: l(e.toes.right) }, b = { left: Math.max(u.left.y, d.left.y), right: Math.max(u.right.y, d.right.y) }, m = Math.max(b.left, b.right), w = Ct * e.height;
701
701
  return {
702
702
  facing: e.facing,
703
703
  height: e.height,
704
704
  stretch: e.stretch,
705
705
  lineWidth: e.lineWidth,
706
- hip: o,
706
+ hip: r,
707
707
  neck: i({ x: 0, y: e.neckY }),
708
708
  shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
709
709
  elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
710
710
  hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
711
711
  knees: { left: l(e.legs.left.joint), right: l(e.legs.right.joint) },
712
- feet: g,
712
+ feet: u,
713
713
  toes: d,
714
714
  feetY: m,
715
- grounded: { left: b.left >= m - S, right: b.right >= m - S },
716
- fingertips: u,
717
- handAngle: { left: p(h, "left"), right: p(a, "right") },
715
+ grounded: { left: b.left >= m - w, right: b.right >= m - w },
716
+ fingertips: g,
717
+ handAngle: { left: p(a, "left"), right: p(h, "right") },
718
718
  limbs: {
719
- leftArm: h,
720
- rightArm: a,
721
- leftLeg: ge(e.legs.left, e.rubber).map(l),
722
- rightLeg: ge(e.legs.right, e.rubber).map(l),
719
+ leftArm: a,
720
+ rightArm: h,
721
+ leftLeg: ue(e.legs.left, e.rubber).map(l),
722
+ rightLeg: ue(e.legs.right, e.rubber).map(l),
723
723
  spine: e.spine.map(i)
724
724
  },
725
725
  head: {
@@ -727,242 +727,242 @@ function no(e, t) {
727
727
  rx: e.headRx,
728
728
  ry: e.headRy,
729
729
  // Mirroring a turn reverses it.
730
- angle: e.facing * (n + r),
731
- eyeY: Qe,
730
+ angle: e.facing * (n + o),
731
+ eyeY: et,
732
732
  browTopY: c,
733
- mouthY: Yt,
734
- faceX: e.facing * ($t + Ft * se(t.turn))
733
+ mouthY: Dt,
734
+ faceX: e.facing * (Yt + Lt * se(t.turn))
735
735
  }
736
736
  };
737
737
  }
738
- function oo(e, t = {}) {
739
- return Dt(Ct(e, t), e);
738
+ function ho(e, t = {}) {
739
+ return zt(Ut(e, t), e);
740
740
  }
741
- function Hr(e, t, n) {
742
- return Pe({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
741
+ function Wr(e, t, n) {
742
+ return We({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
743
743
  }
744
- function ro(e, t, n) {
745
- const r = (l) => ({ x: l.x + t, y: l.y + n }), o = (l) => ({ left: r(l.left), right: r(l.right) });
744
+ function fo(e, t, n) {
745
+ const o = (l) => ({ x: l.x + t, y: l.y + n }), r = (l) => ({ left: o(l.left), right: o(l.right) });
746
746
  return {
747
747
  ...e,
748
- hip: r(e.hip),
749
- neck: r(e.neck),
750
- shoulders: o(e.shoulders),
751
- elbows: o(e.elbows),
752
- hands: o(e.hands),
753
- knees: o(e.knees),
754
- feet: o(e.feet),
755
- toes: o(e.toes),
748
+ hip: o(e.hip),
749
+ neck: o(e.neck),
750
+ shoulders: r(e.shoulders),
751
+ elbows: r(e.elbows),
752
+ hands: r(e.hands),
753
+ knees: r(e.knees),
754
+ feet: r(e.feet),
755
+ toes: r(e.toes),
756
756
  feetY: e.feetY + n,
757
757
  grounded: { ...e.grounded },
758
758
  handAngle: { ...e.handAngle },
759
759
  limbs: {
760
- leftArm: e.limbs.leftArm.map(r),
761
- rightArm: e.limbs.rightArm.map(r),
762
- leftLeg: e.limbs.leftLeg.map(r),
763
- rightLeg: e.limbs.rightLeg.map(r),
764
- spine: e.limbs.spine.map(r)
760
+ leftArm: e.limbs.leftArm.map(o),
761
+ rightArm: e.limbs.rightArm.map(o),
762
+ leftLeg: e.limbs.leftLeg.map(o),
763
+ rightLeg: e.limbs.rightLeg.map(o),
764
+ spine: e.limbs.spine.map(o)
765
765
  },
766
- head: { ...e.head, center: r(e.head.center) }
766
+ head: { ...e.head, center: o(e.head.center) }
767
767
  };
768
768
  }
769
- function lo(e, t, n = {}, r = 0) {
770
- const o = Ct(t, n), l = n.color ?? "#1e293b", i = n.layers ?? {}, s = n.layers ? Dt(o, t, !1) : void 0, h = n.sketch ? Ue(e, n.sketch, r) : void 0, a = n.sketch && n.layers ? Ue(e, n.sketch, r) : void 0, f = (w) => {
771
- e.save(), w(), e.restore();
772
- }, u = (w) => {
773
- w && s && f(() => w(e, s, r, a));
774
- }, p = () => e.scale(o.facing, 1), c = () => {
775
- p(), e.translate(0, o.hipY), e.rotate(Z(o.lean)), e.translate(0, -o.hipY);
776
- }, g = (w, E, v) => {
777
- if (h) return E ? h.curve(w) : h.line(w);
778
- if (o.classic) {
779
- e.beginPath(), e.moveTo(w[0].x, w[0].y);
780
- for (const A of w.slice(1)) e.lineTo(A.x, A.y);
769
+ function co(e, t, n = {}, o = 0) {
770
+ const r = Ut(t, n), l = n.color ?? "#1e293b", i = n.layers ?? {}, s = n.layers ? zt(r, t, !1) : void 0, a = n.sketch ? Ge(e, n.sketch, o) : void 0, h = n.sketch && n.layers ? Ge(e, n.sketch, o) : void 0, f = (k) => {
771
+ e.save(), k(), e.restore();
772
+ }, g = (k) => {
773
+ k && s && f(() => k(e, s, o, h));
774
+ }, p = () => e.scale(r.facing, 1), c = () => {
775
+ p(), e.translate(0, r.hipY), e.rotate(Z(r.lean)), e.translate(0, -r.hipY);
776
+ }, u = (k, E, T) => {
777
+ if (a) return E ? a.curve(k) : a.line(k);
778
+ if (r.classic) {
779
+ e.beginPath(), e.moveTo(k[0].x, k[0].y);
780
+ for (const A of k.slice(1)) e.lineTo(A.x, A.y);
781
781
  e.stroke();
782
782
  return;
783
783
  }
784
- ot(e, w, v[0] * o.lineWidth, v[1] * o.lineWidth);
785
- }, d = (w, E) => g(ge(w, o.rubber), o.rubber > 0, E), b = (w) => {
786
- o.classic || g([o.legs[w].end, o.toes[w]], !1, Dn);
787
- }, m = (w) => {
788
- if (n.hands && !o.classic) return k(w);
789
- if (o.classic || h) return;
790
- const E = o.arms[w].end;
791
- e.beginPath(), e.arc(E.x, E.y, Xn * o.lineWidth, 0, Math.PI * 2), e.fill();
784
+ lt(e, k, T[0] * r.lineWidth, T[1] * r.lineWidth);
785
+ }, d = (k, E) => u(ue(k, r.rubber), r.rubber > 0, E), b = (k) => {
786
+ r.classic || u([r.legs[k].end, r.toes[k]], !1, Jn);
787
+ }, m = (k) => {
788
+ if (n.hands && !r.classic) return S(k);
789
+ if (r.classic || a) return;
790
+ const E = r.arms[k].end;
791
+ e.beginPath(), e.arc(E.x, E.y, jn * r.lineWidth, 0, Math.PI * 2), e.fill();
792
792
  };
793
- e.save(), e.strokeStyle = l, e.fillStyle = l, e.lineWidth = o.lineWidth, e.lineCap = "round", e.lineJoin = "round";
794
- const S = qt(o, t.spin ?? 0, t.rise ?? 0);
795
- (S.angle !== 0 || S.lift !== 0) && (e.translate(0, -S.lift), e.translate(S.pivot.x, S.pivot.y), e.rotate(S.angle), e.translate(-S.pivot.x, -S.pivot.y));
796
- function k(w) {
797
- const E = n.hands ?? {}, v = o.arms[w].end, A = o.handTips[w], I = n.headFill ?? "#ffffff";
798
- rt(e, v, E[w] ?? R, {
799
- side: w,
793
+ e.save(), e.strokeStyle = l, e.fillStyle = l, e.lineWidth = r.lineWidth, e.lineCap = "round", e.lineJoin = "round";
794
+ const w = Gt(r, t.spin ?? 0, t.rise ?? 0);
795
+ (w.angle !== 0 || w.lift !== 0) && (e.translate(0, -w.lift), e.translate(w.pivot.x, w.pivot.y), e.rotate(w.angle), e.translate(-w.pivot.x, -w.pivot.y));
796
+ function S(k) {
797
+ const E = n.hands ?? {}, T = r.arms[k].end, A = r.handTips[k], I = n.headFill ?? "#ffffff";
798
+ st(e, T, E[k] ?? R, {
799
+ side: k,
800
800
  // Degrees clockwise from straight up, in the frame the hand is drawn in.
801
- angle: Math.atan2(A.x - v.x, v.y - A.y) * 180 / Math.PI,
802
- size: (E.size ?? _t) * o.height * Math.sqrt(o.stretch),
801
+ angle: Math.atan2(A.x - T.x, T.y - A.y) * 180 / Math.PI,
802
+ size: (E.size ?? Nt) * r.height * Math.sqrt(r.stretch),
803
803
  skin: E.skin ?? (I === "none" ? void 0 : I),
804
804
  ink: l,
805
- lineWidth: o.lineWidth * 0.45,
805
+ lineWidth: r.lineWidth * 0.45,
806
806
  fingers: E.fingers,
807
807
  plump: E.plump,
808
808
  look: n.sketch ? "pencil" : "clean",
809
809
  seed: n.sketch?.seed
810
- }, r);
810
+ }, o);
811
811
  }
812
- const T = (w) => {
812
+ const M = (k) => {
813
813
  f(() => {
814
- c(), d(o.arms[w], Cn), m(w);
814
+ c(), d(r.arms[k], Gn), m(k);
815
815
  });
816
816
  const E = i.sleeve;
817
- E && s && f(() => E(e, s, w, r, a));
818
- }, H = se(t.turn) > Zn;
819
- u(i.behind), f(() => {
820
- p(), d(o.legs.left, kt), b("left"), d(o.legs.right, kt), b("right");
821
- }), H && T("left"), f(() => {
822
- c(), g(o.spine, o.spine.length > 2, Nn);
823
- const { left: w, right: E } = { left: o.arms.left.root, right: o.arms.right.root };
824
- if (w.x !== E.x)
825
- if (o.classic) g([w, E], !1, [1, 1]);
817
+ E && s && f(() => E(e, s, k, o, h));
818
+ }, H = se(t.turn) > no;
819
+ g(i.behind), f(() => {
820
+ p(), d(r.legs.left, Ht), b("left"), d(r.legs.right, Ht), b("right");
821
+ }), H && M("left"), f(() => {
822
+ c(), u(r.spine, r.spine.length > 2, zn);
823
+ const { left: k, right: E } = { left: r.arms.left.root, right: r.arms.right.root };
824
+ if (k.x !== E.x)
825
+ if (r.classic) u([k, E], !1, [1, 1]);
826
826
  else {
827
- const v = { x: (w.x + E.x) / 2, y: w.y - 0.3 * Math.abs(E.x - w.x) };
828
- g(fe(w, v, E, 1, 8), !0, [1.1, 1.1]);
827
+ const T = { x: (k.x + E.x) / 2, y: k.y - 0.3 * Math.abs(E.x - k.x) };
828
+ u(fe(k, T, E, 1, 8), !0, [1.1, 1.1]);
829
829
  }
830
- }), u(i.body), H || T("left"), T("right"), u(i.behindHead), f(() => {
831
- c(), e.translate(0, o.neckY), e.rotate(Z(t.headTilt));
832
- const w = -o.headRy;
833
- e.beginPath(), e.ellipse(0, w, o.headRx, o.headRy, 0, 0, Math.PI * 2);
830
+ }), g(i.body), H || M("left"), M("right"), g(i.behindHead), f(() => {
831
+ c(), e.translate(0, r.neckY), e.rotate(Z(t.headTilt));
832
+ const k = -r.headRy;
833
+ e.beginPath(), e.ellipse(0, k, r.headRx, r.headRy, 0, 0, Math.PI * 2);
834
834
  const E = n.headFill ?? "#ffffff";
835
- if (E !== "none" && (e.fillStyle = E, e.fill()), h) {
836
- h.ellipse(0, w, o.headRx, o.headRy);
837
- const v = h.nudge();
838
- e.translate(v.x, v.y);
835
+ if (E !== "none" && (e.fillStyle = E, e.fill()), a) {
836
+ a.ellipse(0, k, r.headRx, r.headRy);
837
+ const T = a.nudge();
838
+ e.translate(T.x, T.y);
839
839
  } else
840
840
  e.stroke();
841
- e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r), eo(e, t, o.r, 0, l, o.lineWidth);
842
- }), u(i.overHead), u(i.front), e.restore(), n.label && (e.save(), e.fillStyle = l, e.font = n.labelFont ?? `700 ${Math.round(o.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -o.height * o.stretch - 0.04 * o.height + o.drop), e.restore());
841
+ e.translate(0, k), e.scale(r.headRx / r.r, r.headRy / r.r), so(e, t, r.r, 0, l, r.lineWidth);
842
+ }), g(i.overHead), g(i.front), e.restore(), n.label && (e.save(), e.fillStyle = l, e.font = n.labelFont ?? `700 ${Math.round(r.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -r.height * r.stretch - 0.04 * r.height + r.drop), e.restore());
843
843
  }
844
- function Xt(e, t, n) {
845
- const r = { ...e };
846
- let o = e.walking > 0 ? me(r, In(e.walk, r), e.walking) : r, l = io(e);
844
+ function Jt(e, t, n) {
845
+ const o = { ...e };
846
+ let r = e.walking > 0 ? we(o, Yn(e.walk, o), e.walking) : o, l = uo(e);
847
847
  const i = e.dancing ?? 0;
848
848
  if (n && i > 0) {
849
849
  const s = n(e.beat ?? 0);
850
- if (o = me(o, s.pose, i), s.hands) {
851
- const h = (a, f) => f ? be(a ?? R, f, i) : a;
852
- l = { left: h(l?.left, s.hands.left), right: h(l?.right, s.hands.right) };
850
+ if (r = we(r, s.pose, i), s.hands) {
851
+ const a = (h, f) => f ? ye(h ?? R, f, i) : h;
852
+ l = { left: a(l?.left, s.hands.left), right: a(l?.right, s.hands.right) };
853
853
  }
854
854
  }
855
- return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Bn(t)) }), { pose: o, hands: l };
855
+ return e.talk > 0 && (r = { ...r, mouth: Math.max(r.mouth, e.talk * Ln(t)) }), { pose: r, hands: l };
856
856
  }
857
- function so(e, t, n) {
858
- return Xt(e, t, n).pose;
857
+ function go(e, t, n) {
858
+ return Jt(e, t, n).pose;
859
859
  }
860
- const We = (e, t) => `hand.${e}.${t}`;
861
- function io(e) {
862
- const t = (o) => {
863
- if (typeof e[We(o, "spread")] == "number")
864
- return Object.fromEntries(Object.keys(R).map((l) => [l, e[We(o, l)]]));
865
- }, n = t("left"), r = t("right");
866
- return n || r ? { left: n, right: r } : void 0;
860
+ const Oe = (e, t) => `hand.${e}.${t}`;
861
+ function uo(e) {
862
+ const t = (r) => {
863
+ if (typeof e[Oe(r, "spread")] == "number")
864
+ return Object.fromEntries(Object.keys(R).map((l) => [l, e[Oe(r, l)]]));
865
+ }, n = t("left"), o = t("right");
866
+ return n || o ? { left: n, right: o } : void 0;
867
867
  }
868
- function ho(e, t) {
868
+ function po(e, t) {
869
869
  return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
870
870
  }
871
- function Mr(e) {
872
- const t = e.style ?? {}, n = t.height ?? 300, r = n * 0.8, o = { ...D(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, l = {};
871
+ function Or(e) {
872
+ const t = e.style ?? {}, n = t.height ?? 300, o = n * 0.8, r = { ...D(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, l = {};
873
873
  if (t.hands)
874
874
  for (const i of ["left", "right"]) {
875
875
  const s = t.hands[i] ?? R;
876
- for (const h of Object.keys(R)) l[We(i, h)] = s[h] ?? R[h];
876
+ for (const a of Object.keys(R)) l[Oe(i, a)] = s[a] ?? R[a];
877
877
  }
878
878
  return {
879
879
  type: "custom",
880
- x: e.x - r / 2,
880
+ x: e.x - o / 2,
881
881
  y: e.y - n,
882
- width: r,
882
+ width: o,
883
883
  height: n,
884
- props: { ...o, ...l },
884
+ props: { ...r, ...l },
885
885
  figureStyle: t,
886
886
  figureDance: e.dance,
887
- draw(i, s, h) {
888
- const a = s.props, f = Xt(a, h, e.dance);
889
- i.translate(r / 2, n), lo(i, f.pose, ho({ ...t, rubber: a.rubber }, f.hands), h);
887
+ draw(i, s, a) {
888
+ const h = s.props, f = Jt(h, a, e.dance);
889
+ i.translate(o / 2, n), co(i, f.pose, po({ ...t, rubber: h.rubber }, f.hands), a);
890
890
  }
891
891
  };
892
892
  }
893
- function Tr(e, t, n) {
894
- const r = e.figureStyle;
895
- if (!r) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
896
- const o = { ...e.props };
893
+ function Ir(e, t, n) {
894
+ const o = e.figureStyle;
895
+ if (!o) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
896
+ const r = { ...e.props };
897
897
  let l = 0, i = 0;
898
- for (const [a, f] of t.state?.values.get(n) ?? [])
899
- typeof f == "number" && (a === "x" || a === "motionPathX" ? l = f : a === "y" || a === "motionPathY" ? i = f : a in o && (o[a] = f));
900
- const s = so(o, t.time, e.figureDance), h = oo(s, { ...r, rubber: o.rubber });
901
- return { pose: s, joints: ro(h, e.x + l + e.width / 2, e.y + i + e.height) };
898
+ for (const [h, f] of t.state?.values.get(n) ?? [])
899
+ typeof f == "number" && (h === "x" || h === "motionPathX" ? l = f : h === "y" || h === "motionPathY" ? i = f : h in r && (r[h] = f));
900
+ const s = go(r, t.time, e.figureDance), a = ho(s, { ...o, rubber: r.rubber });
901
+ return { pose: s, joints: fo(a, e.x + l + e.width / 2, e.y + i + e.height) };
902
902
  }
903
- function vr(e, t) {
903
+ function $r(e, t) {
904
904
  const n = [];
905
- return t.forEach((r, o) => {
906
- const l = o === 0 ? z : n[o - 1], i = typeof r.pose == "string" ? Wn[r.pose] : { ...l, ...r.pose };
907
- n.push(r.expression ? Ot(i, r.expression) : i);
908
- }), It.filter((r) => n.some((o) => o[r] !== z[r])).map((r) => ({
909
- id: `${e}-${r}`,
905
+ return t.forEach((o, r) => {
906
+ const l = r === 0 ? z : n[r - 1], i = typeof o.pose == "string" ? Fn[o.pose] : { ...l, ...o.pose };
907
+ n.push(o.expression ? _t(i, o.expression) : i);
908
+ }), Ft.filter((o) => n.some((r) => r[o] !== z[o])).map((o) => ({
909
+ id: `${e}-${o}`,
910
910
  target: e,
911
- property: r,
912
- keyframes: t.map((o, l) => ({
913
- time: o.time,
914
- value: n[l][r],
915
- ...o.easing ? { easing: o.easing } : {}
911
+ property: o,
912
+ keyframes: t.map((r, l) => ({
913
+ time: r.time,
914
+ value: n[l][o],
915
+ ...r.easing ? { easing: r.easing } : {}
916
916
  }))
917
917
  }));
918
918
  }
919
- const Re = 0.5, Et = {
919
+ const Ye = 0.5, vt = {
920
920
  /** Flag: fingers together and straight, thumb bent in */
921
- pataka: _({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
921
+ pataka: F({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
922
922
  /** Pataka with the ring finger bent */
923
- tripataka: _({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
923
+ tripataka: F({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
924
924
  /** Lotus in bloom: fingers fanned, each a little more curled than the last */
925
- alapadma: _({ "thumb.curl": 0.1, "thumb.across": 0, "index.curl": 0.05, "middle.curl": 0.15, "ring.curl": 0.25, "pinky.curl": 0.35, spread: 1, turn: 2 }),
925
+ alapadma: F({ "thumb.curl": 0.1, "thumb.across": 0, "index.curl": 0.05, "middle.curl": 0.15, "ring.curl": 0.25, "pinky.curl": 0.35, spread: 1, turn: 2 }),
926
926
  /** Fist */
927
927
  mushti: N.fist,
928
928
  /** Fist, thumb up */
929
929
  shikhara: N.thumbsUp,
930
930
  /** Swan's beak: thumb and index touch, the others fanned */
931
- hamsasya: _({ "thumb.curl": 0.15, "thumb.across": 0.6, "index.curl": 0.6, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0.7, turn: 2 }),
931
+ hamsasya: F({ "thumb.curl": 0.15, "thumb.across": 0.6, "index.curl": 0.6, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0.7, turn: 2 }),
932
932
  /** Bracelet: thumb, index and middle meet, ring and little finger out */
933
- katakamukha: _({ "thumb.curl": 0.2, "thumb.across": 0.6, "index.curl": 0.65, "middle.curl": 0.7, "ring.curl": 0, "pinky.curl": 0, spread: 0.4, turn: 2 })
933
+ katakamukha: F({ "thumb.curl": 0.2, "thumb.across": 0.6, "index.curl": 0.65, "middle.curl": 0.7, "ring.curl": 0, "pinky.curl": 0, spread: 0.4, turn: 2 })
934
934
  };
935
- function Oe(e) {
936
- return typeof e != "string" ? e : e in Et ? Et[e] : N[e];
935
+ function Ie(e) {
936
+ return typeof e != "string" ? e : e in vt ? vt[e] : N[e];
937
937
  }
938
- function ao(e, t, n) {
939
- const r = [];
940
- for (const o of e.keys) {
941
- const l = r[r.length - 1], i = !l || o.reset ? { pose: t, ...n } : l;
942
- r.push({
943
- beat: o.beat,
944
- pose: { ...i.pose, ...o.pose },
945
- left: o.hands?.left ? Oe(o.hands.left) : i.left,
946
- right: o.hands?.right ? Oe(o.hands.right) : i.right,
947
- easing: o.easing ?? e.easing
938
+ function Zt(e, t, n) {
939
+ const o = [];
940
+ for (const r of e.keys) {
941
+ const l = o[o.length - 1], i = !l || r.reset ? { pose: t, ...n } : l;
942
+ o.push({
943
+ beat: r.beat,
944
+ pose: { ...i.pose, ...r.pose },
945
+ left: r.hands?.left ? Ie(r.hands.left) : i.left,
946
+ right: r.hands?.right ? Ie(r.hands.right) : i.right,
947
+ easing: r.easing ?? e.easing
948
948
  });
949
949
  }
950
- return r;
951
- }
952
- const lt = (e, t) => (e % t + t) % t;
953
- function fo(e, t, n, r) {
954
- const o = ao(e, n, r);
955
- if (o.length === 0) return { pose: n, hands: r };
956
- const l = lt(t, e.beats);
957
- let i = o.length - 1;
958
- for (let c = 0; c < o.length; c++) o[c].beat <= l && (i = c);
959
- const s = o[i], h = o[(i + 1) % o.length], a = s.beat <= l ? s.beat : s.beat - e.beats, f = h.beat > a ? h.beat : h.beat + e.beats, u = f > a ? (l - a) / (f - a) : 0, p = nt(h.easing ?? "ease-in-out")(Math.min(1, Math.max(0, u)));
950
+ return o;
951
+ }
952
+ const it = (e, t) => (e % t + t) % t;
953
+ function bo(e, t, n, o) {
954
+ const r = Zt(e, n, o);
955
+ if (r.length === 0) return { pose: n, hands: o };
956
+ const l = it(t, e.beats);
957
+ let i = r.length - 1;
958
+ for (let c = 0; c < r.length; c++) r[c].beat <= l && (i = c);
959
+ const s = r[i], a = r[(i + 1) % r.length], h = s.beat <= l ? s.beat : s.beat - e.beats, f = a.beat > h ? a.beat : a.beat + e.beats, g = f > h ? (l - h) / (f - h) : 0, p = _e(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, g)));
960
960
  return {
961
- pose: me(s.pose, h.pose, p),
962
- hands: { left: be(s.left, h.left, p), right: be(s.right, h.right, p) }
961
+ pose: we(s.pose, a.pose, p),
962
+ hands: { left: ye(s.left, a.left, p), right: ye(s.right, a.right, p) }
963
963
  };
964
964
  }
965
- const co = [
965
+ const mo = [
966
966
  ["leftShoulder", "rightShoulder"],
967
967
  ["leftElbow", "rightElbow"],
968
968
  ["leftWrist", "rightWrist"],
@@ -972,19 +972,19 @@ const co = [
972
972
  ["leftFootOut", "rightFootOut"],
973
973
  ["leftEye", "rightEye"],
974
974
  ["leftBrow", "rightBrow"]
975
- ], go = ["lean", "headTilt", "lookX", "spin"], uo = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
976
- function po(e) {
975
+ ], yo = ["lean", "headTilt", "lookX", "spin"], wo = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
976
+ function ko(e) {
977
977
  const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
978
- for (const [r, o] of co) {
979
- const l = n && uo.has(r) ? -1 : 1;
980
- t[r] = l * e[o], t[o] = l * e[r];
978
+ for (const [o, r] of mo) {
979
+ const l = n && wo.has(o) ? -1 : 1;
980
+ t[o] = l * e[r], t[r] = l * e[o];
981
981
  }
982
- if (!n) for (const r of go) t[r] = -e[r];
982
+ if (!n) for (const o of yo) t[o] = -e[o];
983
983
  return t;
984
984
  }
985
- const bo = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
986
- function mo(e, t, n) {
987
- const r = lt(n, 1), o = (1 + Math.cos(2 * Math.PI * r)) / 2, l = t.bounce * (t.accent === "up" ? 1 - o : o), i = Math.min(1, Math.max(0, e.turn ?? 0)), s = bo(i);
985
+ const So = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
986
+ function Eo(e, t, n) {
987
+ const o = it(n, 1), r = (1 + Math.cos(2 * Math.PI * o)) / 2, l = t.bounce * (t.accent === "up" ? 1 - r : r), i = Math.min(1, Math.max(0, e.turn ?? 0)), s = So(i);
988
988
  return {
989
989
  ...e,
990
990
  leftHip: e.leftHip + s * l / 2,
@@ -994,81 +994,129 @@ function mo(e, t, n) {
994
994
  lean: e.lean + (t.sway ?? 0) * (1 - i) * Math.sin(Math.PI * n)
995
995
  };
996
996
  }
997
- function yo(e) {
997
+ function tt(e) {
998
998
  const t = { ...z, ...e.stance };
999
- return e.expression ? Ot(t, e.expression) : t;
999
+ return e.expression ? _t(t, e.expression) : t;
1000
1000
  }
1001
- function wo(e) {
1001
+ function jt(e) {
1002
1002
  return {
1003
- left: e.hands?.left ? Oe(e.hands.left) : R,
1004
- right: e.hands?.right ? Oe(e.hands.right) : R
1003
+ left: e.hands?.left ? Ie(e.hands.left) : R,
1004
+ right: e.hands?.right ? Ie(e.hands.right) : R
1005
1005
  };
1006
1006
  }
1007
- function Ye(e, t, n) {
1008
- const r = e.moves[t.move];
1009
- if (!r) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1010
- const o = fo(r, n, yo(e), wo(e));
1011
- return t.mirror ? { pose: po(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
1007
+ function Le(e, t, n) {
1008
+ const o = e.moves[t.move];
1009
+ if (!o) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1010
+ const r = bo(o, n, tt(e), jt(e));
1011
+ return t.mirror ? { pose: ko(r.pose), hands: { left: r.hands?.right, right: r.hands?.left } } : r;
1012
1012
  }
1013
- function st(e, t, n = {}) {
1014
- const r = typeof e == "string" ? $e[e] : e;
1015
- let o;
1013
+ function at(e, t, n = {}) {
1014
+ const o = typeof e == "string" ? ce[e] : e;
1015
+ let r;
1016
1016
  if (n.move)
1017
- o = Ye(r, { move: n.move, mirror: n.mirror }, t);
1017
+ r = Le(o, { move: n.move, mirror: n.mirror }, t);
1018
1018
  else {
1019
- const l = r.routine, i = l.reduce((u, p) => u + p.beats, 0), s = lt(t, i);
1020
- let h = 0, a = 0;
1021
- for (; a < l.length - 1 && s >= h + l[a].beats; ) h += l[a++].beats;
1022
- const f = s - h;
1023
- if (o = Ye(r, l[a], f), f < Re && l.length > 1 && t >= Re) {
1024
- const u = l[(a - 1 + l.length) % l.length], p = Ye(r, u, u.beats + f), c = nt("ease-in-out")(f / Re);
1025
- o = {
1026
- pose: me(p.pose, o.pose, c),
1027
- hands: { left: be(p.hands.left, o.hands.left, c), right: be(p.hands.right, o.hands.right, c) }
1019
+ const l = o.routine, i = l.reduce((g, p) => g + p.beats, 0), s = it(t, i);
1020
+ let a = 0, h = 0;
1021
+ for (; h < l.length - 1 && s >= a + l[h].beats; ) a += l[h++].beats;
1022
+ const f = s - a;
1023
+ if (r = Le(o, l[h], f), f < Ye && l.length > 1 && t >= Ye) {
1024
+ const g = l[(h - 1 + l.length) % l.length], p = Le(o, g, g.beats + f), c = _e("ease-in-out")(f / Ye);
1025
+ r = {
1026
+ pose: we(p.pose, r.pose, c),
1027
+ hands: { left: ye(p.hands.left, r.hands.left, c), right: ye(p.hands.right, r.hands.right, c) }
1028
1028
  };
1029
1029
  }
1030
1030
  }
1031
- return { ...o, pose: mo(o.pose, r.groove, t) };
1031
+ return { ...r, pose: Eo(r.pose, o.groove, t) };
1032
1032
  }
1033
- function xr(e, t, n = {}) {
1034
- return st(e, t, n).pose;
1033
+ function Br(e, t, n = {}) {
1034
+ return at(e, t, n).pose;
1035
1035
  }
1036
- function Ut(e) {
1037
- return (typeof e == "string" ? $e[e] : e).routine.reduce((n, r) => n + r.beats, 0);
1036
+ function ht(e) {
1037
+ return (typeof e == "string" ? ce[e] : e).routine.reduce((n, o) => n + o.beats, 0);
1038
1038
  }
1039
- const ko = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1040
- function Ht(e, t, n, r, o, l, i) {
1039
+ const Ho = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1040
+ function Tt(e, t, n, o, r, l, i) {
1041
1041
  for (let s = 0; s * e.beats < n; s++)
1042
- for (const h of e.keys) {
1043
- const a = s * e.beats + h.beat, f = t + a;
1044
- if (!(a >= n || f < l || f >= i))
1045
- for (const u of h.taps ?? []) o.push({ beat: f, tap: r ? ko[u] : u });
1042
+ for (const a of e.keys) {
1043
+ const h = s * e.beats + a.beat, f = t + h;
1044
+ if (!(h >= n || f < l || f >= i))
1045
+ for (const g of a.taps ?? []) r.push({ beat: f, tap: o ? Ho[g] : g });
1046
1046
  }
1047
1047
  }
1048
- function Ar(e, t, n, r = {}) {
1049
- const o = typeof e == "string" ? $e[e] : e, l = [];
1048
+ function _r(e, t, n, o = {}) {
1049
+ const r = typeof e == "string" ? ce[e] : e, l = [];
1050
1050
  if (n <= t) return l;
1051
- if (r.move) {
1052
- const i = o.moves[r.move], s = Math.floor(t / i.beats) * i.beats;
1053
- Ht(i, s, Math.ceil((n - s) / i.beats) * i.beats, r.mirror, l, t, n);
1051
+ if (o.move) {
1052
+ const i = r.moves[o.move], s = Math.floor(t / i.beats) * i.beats;
1053
+ Tt(i, s, Math.ceil((n - s) / i.beats) * i.beats, o.mirror, l, t, n);
1054
1054
  } else {
1055
- const i = Ut(o);
1055
+ const i = ht(r);
1056
1056
  for (let s = Math.floor(t / i) * i; s < n; s += i) {
1057
- let h = s;
1058
- for (const a of o.routine)
1059
- Ht(o.moves[a.move], h, a.beats, a.mirror, l, t, n), h += a.beats;
1057
+ let a = s;
1058
+ for (const h of r.routine)
1059
+ Tt(r.moves[h.move], a, h.beats, h.mirror, l, t, n), a += h.beats;
1060
1060
  }
1061
1061
  }
1062
1062
  return l.sort((i, s) => i.beat - s.beat);
1063
1063
  }
1064
- function Kr(e, t, n = 0) {
1064
+ function xt(e, t) {
1065
+ const n = e.moves[t.move];
1066
+ if (!n?.travel) return 0;
1067
+ const o = n.travel / n.beats;
1068
+ return t.mirror ? (Zt(n, tt(e), jt(e))[0]?.pose.turn ?? tt(e).turn ?? 0) >= 0.5 ? o : -o : o;
1069
+ }
1070
+ function Qt(e, t) {
1071
+ return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
1072
+ }
1073
+ function Ne(e, t, n = {}) {
1074
+ const o = typeof e == "string" ? ce[e] : e, r = Qt(o, n), l = r.reduce((f, g) => f + g.beats, 0), i = r.reduce((f, g) => f + xt(o, g) * g.beats, 0), s = Math.floor(t / l);
1075
+ let a = s * i, h = t - s * l;
1076
+ for (const f of r) {
1077
+ const g = Math.min(f.beats, h);
1078
+ if (a += xt(o, f) * g, h -= g, h <= 0) break;
1079
+ }
1080
+ return a;
1081
+ }
1082
+ function Mo(e, t, n) {
1083
+ const o = Qt(e, n), r = [0];
1084
+ let l = 0;
1085
+ for (let i = 0; l < t; i = (i + 1) % o.length)
1086
+ l += o[i].beats, r.push(Math.min(l, t));
1087
+ return r;
1088
+ }
1089
+ const vo = 8;
1090
+ function To(e, t, n) {
1091
+ const o = typeof t == "string" ? ce[t] : t, r = n.bpm ?? o.bpm, l = n.beats ?? (n.move ? o.moves[n.move].beats : ht(o)), i = Mo(o, l, n);
1092
+ if (i.every((m) => Ne(o, m, n) === 0)) return;
1093
+ const s = Math.min(n.fade ?? 1, l / 2), a = _e("ease-in-out"), h = (m) => s <= 0 ? 1 : Math.min(a(Math.min(1, m / s)), a(Math.min(1, (l - m) / s))), f = Math.ceil(s * vo), g = s <= 0 ? [] : Array.from({ length: f + 1 }, (m, w) => [w / f * s, l - w / f * s]).flat(), p = [.../* @__PURE__ */ new Set([...i, ...g])].sort((m, w) => m - w);
1094
+ let c = 0;
1095
+ const u = p.map((m, w) => {
1096
+ if (w > 0) {
1097
+ const S = p[w - 1], M = Math.max(1, Math.ceil((m - S) * 16));
1098
+ for (let H = 0; H < M; H++) {
1099
+ const k = S + (m - S) * H / M, E = S + (m - S) * (H + 1) / M;
1100
+ c += (Ne(o, E, n) - Ne(o, k, n)) * h((k + E) / 2);
1101
+ }
1102
+ }
1103
+ return { beat: m, travel: c };
1104
+ }), d = n.start ?? 0, b = n.x ?? 0;
1105
+ return {
1106
+ id: `${e}-x`,
1107
+ target: e,
1108
+ property: "x",
1109
+ keyframes: u.map((m) => ({ time: d + m.beat * 6e4 / r, value: b + n.height * m.travel, easing: "linear" }))
1110
+ };
1111
+ }
1112
+ function Fr(e, t, n = 0) {
1065
1113
  return (e - n) * t / 6e4;
1066
1114
  }
1067
- function Pr(e, t = {}) {
1068
- return (n) => st(e, n, t);
1115
+ function Rr(e, t = {}) {
1116
+ return (n) => at(e, n, t);
1069
1117
  }
1070
- function Wr(e, t) {
1071
- const n = t.start ?? 0, r = 6e4 / t.bpm, o = n + t.beats * r, l = Math.min((t.fade ?? 1) * r, (o - n) / 2);
1118
+ function Yr(e, t) {
1119
+ const n = t.start ?? 0, o = 6e4 / t.bpm, r = n + t.beats * o, l = Math.min((t.fade ?? 1) * o, (r - n) / 2);
1072
1120
  return [
1073
1121
  {
1074
1122
  id: `${e}-beat`,
@@ -1076,7 +1124,7 @@ function Wr(e, t) {
1076
1124
  property: "beat",
1077
1125
  keyframes: [
1078
1126
  { time: n, value: 0 },
1079
- { time: o, value: t.beats, easing: "linear" }
1127
+ { time: r, value: t.beats, easing: "linear" }
1080
1128
  ]
1081
1129
  },
1082
1130
  {
@@ -1086,32 +1134,32 @@ function Wr(e, t) {
1086
1134
  keyframes: [
1087
1135
  { time: n, value: 0 },
1088
1136
  { time: n + l, value: 1, easing: "ease-in-out" },
1089
- { time: o - l, value: 1 },
1090
- { time: o, value: 0, easing: "ease-in-out" }
1137
+ { time: r - l, value: 1 },
1138
+ { time: r, value: 0, easing: "ease-in-out" }
1091
1139
  ]
1092
1140
  }
1093
1141
  ];
1094
1142
  }
1095
- function Or(e, t, n = {}) {
1096
- const r = typeof t == "string" ? $e[t] : t, o = n.bpm ?? r.bpm, l = n.beats ?? (n.move ? r.moves[n.move].beats : Ut(r)), i = n.samplesPerBeat ?? 4, s = n.start ?? 0, h = Math.round(l * i), a = Array.from({ length: h + 1 }, (g, d) => {
1097
- const b = d / i;
1098
- return { time: s + b * 6e4 / o, frame: st(r, b, n) };
1099
- }), f = (g, d) => ({
1100
- id: `${e}-${g}`,
1143
+ function Lr(e, t, n = {}) {
1144
+ const o = typeof t == "string" ? ce[t] : t, r = n.bpm ?? o.bpm, l = n.beats ?? (n.move ? o.moves[n.move].beats : ht(o)), i = n.samplesPerBeat ?? 4, s = n.start ?? 0, a = Math.round(l * i), h = Array.from({ length: a + 1 }, (d, b) => {
1145
+ const m = b / i;
1146
+ return { time: s + m * 6e4 / r, frame: at(o, m, n) };
1147
+ }), f = (d, b) => ({
1148
+ id: `${e}-${d}`,
1101
1149
  target: e,
1102
- property: g,
1103
- keyframes: a.map((b) => ({ time: b.time, value: d(b.frame) }))
1104
- }), p = Object.keys(z).filter((g) => a.some((d) => d.frame.pose[g] !== a[0].frame.pose[g]) || a[0].frame.pose[g] !== z[g]).map((g) => f(g, (d) => d.pose[g]));
1105
- if (n.hands === !1) return p;
1106
- const c = [];
1107
- for (const g of ["left", "right"])
1108
- for (const d of Object.keys(R)) {
1109
- const b = (m) => m.hands?.[g]?.[d] ?? R[d];
1110
- a.some((m) => b(m.frame) !== R[d]) && c.push(f(We(g, d), b));
1150
+ property: d,
1151
+ keyframes: h.map((m) => ({ time: m.time, value: b(m.frame) }))
1152
+ }), p = Object.keys(z).filter((d) => h.some((b) => b.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== z[d]).map((d) => f(d, (b) => b.pose[d])), c = n.height === void 0 ? void 0 : To(e, o, { ...n, bpm: r, beats: l, start: s, height: n.height, fade: 0 });
1153
+ if (c && p.push(c), n.hands === !1) return p;
1154
+ const u = [];
1155
+ for (const d of ["left", "right"])
1156
+ for (const b of Object.keys(R)) {
1157
+ const m = (w) => w.hands?.[d]?.[b] ?? R[b];
1158
+ h.some((w) => m(w.frame) !== R[b]) && u.push(f(Oe(d, b), m));
1111
1159
  }
1112
- return [...p, ...c];
1160
+ return [...p, ...u];
1113
1161
  }
1114
- const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic", So = {
1162
+ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic", xo = {
1115
1163
  label: "Disco",
1116
1164
  bpm: 120,
1117
1165
  stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
@@ -1121,7 +1169,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1121
1169
  point: {
1122
1170
  label: "The point",
1123
1171
  beats: 2,
1124
- easing: q,
1172
+ easing: X,
1125
1173
  keys: [
1126
1174
  {
1127
1175
  beat: 0,
@@ -1146,9 +1194,9 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1146
1194
  label: "Bump and clap",
1147
1195
  beats: 4,
1148
1196
  keys: [
1149
- { beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: q },
1197
+ { beat: 0, pose: { lean: -10, rightHip: 22, leftHip: 4, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: X },
1150
1198
  { beat: 1, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } },
1151
- { beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: q },
1199
+ { beat: 2, pose: { lean: 10, rightHip: 4, leftHip: 22, leftShoulder: 140, rightShoulder: 140, leftElbow: 0, rightElbow: 0, leftWrist: 20, rightWrist: 20 }, hands: { left: "spread", right: "spread" }, easing: X },
1152
1200
  { beat: 3, pose: { lean: 0, rightHip: 10, leftHip: 10, leftShoulder: 168, rightShoulder: 168, leftElbow: 22, rightElbow: 22, leftWrist: 0, rightWrist: 0 }, hands: { left: "flat", right: "flat" } }
1153
1201
  ]
1154
1202
  }
@@ -1159,7 +1207,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1159
1207
  { move: "point", beats: 8, mirror: !0 },
1160
1208
  { move: "bump", beats: 8 }
1161
1209
  ]
1162
- }, Eo = {
1210
+ }, Ao = {
1163
1211
  label: "Hip hop",
1164
1212
  bpm: 95,
1165
1213
  stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
@@ -1211,7 +1259,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1211
1259
  { move: "armWave", beats: 8 },
1212
1260
  { move: "bounce", beats: 4 }
1213
1261
  ]
1214
- }, Ho = {
1262
+ }, Ko = {
1215
1263
  label: "Breaking (toprock)",
1216
1264
  bpm: 110,
1217
1265
  stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
@@ -1223,9 +1271,9 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1223
1271
  label: "Toprock (Indian step)",
1224
1272
  beats: 4,
1225
1273
  keys: [
1226
- { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: q },
1274
+ { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: X },
1227
1275
  { beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
1228
- { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: q },
1276
+ { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: X },
1229
1277
  { beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
1230
1278
  ]
1231
1279
  },
@@ -1233,7 +1281,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1233
1281
  label: "Kick out",
1234
1282
  beats: 2,
1235
1283
  keys: [
1236
- { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: q },
1284
+ { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: X },
1237
1285
  { beat: 1, reset: !0 }
1238
1286
  ]
1239
1287
  },
@@ -1241,7 +1289,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1241
1289
  label: "B-boy stance",
1242
1290
  beats: 4,
1243
1291
  keys: [
1244
- { beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing: ve },
1292
+ { beat: 0, reset: !0, pose: { leftShoulder: 26, leftElbow: -122, rightShoulder: 22, rightElbow: -118, leftHip: 18, rightHip: 18, leftKnee: 6, rightKnee: 6, lean: -4, headTilt: 10, smile: 0.6, leftEye: 0.6, rightEye: 0.6 }, easing: be },
1245
1293
  { beat: 2, pose: { headTilt: 14, lean: -6 } }
1246
1294
  ]
1247
1295
  }
@@ -1253,7 +1301,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1253
1301
  { move: "kick", beats: 4, mirror: !0 },
1254
1302
  { move: "freeze", beats: 4 }
1255
1303
  ]
1256
- }, Mo = {
1304
+ }, Po = {
1257
1305
  label: "Jazz",
1258
1306
  bpm: 130,
1259
1307
  stance: { leftHip: 10, rightHip: 10 },
@@ -1276,7 +1324,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1276
1324
  label: "Kick ball change",
1277
1325
  beats: 2,
1278
1326
  keys: [
1279
- { beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing: q },
1327
+ { beat: 0, reset: !0, pose: { rightHip: 88, rightKnee: 0, rightAnkle: 55, leftHip: 4, lean: -12, leftShoulder: 112, rightShoulder: 112, leftWrist: 15, rightWrist: 15 }, hands: { left: "flat", right: "flat" }, easing: X },
1280
1328
  { beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
1281
1329
  { beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
1282
1330
  ]
@@ -1314,7 +1362,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1314
1362
  { move: "jazzHands", beats: 4 },
1315
1363
  { move: "splitDrop", beats: 8 }
1316
1364
  ]
1317
- }, To = {
1365
+ }, Wo = {
1318
1366
  label: "K-pop",
1319
1367
  bpm: 125,
1320
1368
  stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
@@ -1324,7 +1372,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1324
1372
  pointCombo: {
1325
1373
  label: "Point combo",
1326
1374
  beats: 4,
1327
- easing: ve,
1375
+ easing: be,
1328
1376
  keys: [
1329
1377
  { beat: 0, reset: !0, pose: { rightShoulder: 142, rightElbow: 0, leftShoulder: 25, leftElbow: -125, headTilt: 6, lean: -3, lookX: 0.6, lookY: -0.6 }, hands: { right: "point", left: "flat" } },
1330
1378
  { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
@@ -1336,16 +1384,16 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1336
1384
  label: "Big heart, finger heart",
1337
1385
  beats: 4,
1338
1386
  keys: [
1339
- { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: ve },
1387
+ { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: be },
1340
1388
  { beat: 1, pose: { headTilt: 8, lean: 4 } },
1341
- { beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing: ve },
1389
+ { beat: 2, reset: !0, pose: { rightShoulder: 32, rightElbow: 112, rightWrist: 10, leftShoulder: 20, leftElbow: -30, headTilt: 10, leftEye: 0, smile: 1 }, hands: { right: "pinch", left: "relaxed" }, easing: be },
1342
1390
  { beat: 3, pose: { headTilt: 4 } }
1343
1391
  ]
1344
1392
  },
1345
1393
  isolations: {
1346
1394
  label: "Isolations",
1347
1395
  beats: 2,
1348
- easing: q,
1396
+ easing: X,
1349
1397
  keys: [
1350
1398
  { beat: 0, reset: !0, pose: { lean: -9, headTilt: 11, leftShoulder: 55, leftElbow: -112, rightShoulder: 55, rightElbow: -112, rightHip: 18 }, hands: { left: "fist", right: "fist" } },
1351
1399
  { beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
@@ -1361,7 +1409,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1361
1409
  { move: "pointCombo", beats: 8, mirror: !0 },
1362
1410
  { move: "isolations", beats: 4 }
1363
1411
  ]
1364
- }, vo = {
1412
+ }, Oo = {
1365
1413
  label: "Bollywood",
1366
1414
  bpm: 120,
1367
1415
  stance: { leftHip: 10, rightHip: 10 },
@@ -1382,9 +1430,9 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1382
1430
  label: "Thumka",
1383
1431
  beats: 2,
1384
1432
  keys: [
1385
- { beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...N.open, turn: 2 } }, easing: q },
1433
+ { beat: 0, reset: !0, pose: { lean: -11, rightHip: 22, leftHip: 2, leftKnee: 14, rightShoulder: 45, rightElbow: -105, leftShoulder: 128, leftElbow: 18, leftWrist: 35, headTilt: 10, lookX: -0.5 }, hands: { right: "fist", left: { ...N.open, turn: 2 } }, easing: X },
1386
1434
  { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1387
- { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: q },
1435
+ { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: X },
1388
1436
  { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
1389
1437
  ]
1390
1438
  },
@@ -1393,9 +1441,9 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1393
1441
  beats: 4,
1394
1442
  keys: [
1395
1443
  { beat: 0, reset: !0, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26 }, hands: { left: "fist", right: "fist" } },
1396
- { beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing: q },
1444
+ { beat: 1, pose: { leftShoulder: 132, rightShoulder: 132, leftElbow: 0, rightElbow: 0, leftWrist: 30, rightWrist: 30, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10, stretch: 1.03 }, hands: { left: "spread", right: "spread" }, easing: X },
1397
1445
  { beat: 2, pose: { leftShoulder: 22, rightShoulder: 22, leftElbow: -62, rightElbow: -62, leftWrist: 0, rightWrist: 0, leftHip: 16, rightHip: 16, leftKnee: 26, rightKnee: 26, stretch: 1 }, hands: { left: "fist", right: "fist" } },
1398
- { beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing: q }
1446
+ { beat: 3, pose: { leftShoulder: 62, rightShoulder: 62, leftElbow: 0, rightElbow: 0, leftWrist: 35, rightWrist: 35, leftKnee: 0, rightKnee: 0, leftHip: 10, rightHip: 10 }, hands: { left: "spread", right: "spread" }, easing: X }
1399
1447
  ]
1400
1448
  }
1401
1449
  },
@@ -1406,7 +1454,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1406
1454
  { move: "thumka", beats: 4, mirror: !0 },
1407
1455
  { move: "lightBulb", beats: 8, mirror: !0 }
1408
1456
  ]
1409
- }, xo = {
1457
+ }, Io = {
1410
1458
  label: "Bhangra",
1411
1459
  bpm: 100,
1412
1460
  stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
@@ -1441,11 +1489,11 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1441
1489
  { move: "basic", beats: 8 },
1442
1490
  { move: "dhamaal", beats: 4 }
1443
1491
  ]
1444
- }, Ao = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Ko = {
1492
+ }, $o = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Bo = {
1445
1493
  label: "Bharatanatyam",
1446
1494
  bpm: 80,
1447
1495
  // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1448
- stance: { ...Ao, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1496
+ stance: { ...$o, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1449
1497
  expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1450
1498
  hands: { left: "pataka", right: "pataka" },
1451
1499
  groove: { bounce: 0 },
@@ -1487,7 +1535,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1487
1535
  { move: "alapadma", beats: 8 },
1488
1536
  { move: "tatta", beats: 4 }
1489
1537
  ]
1490
- }, Po = {
1538
+ }, _o = {
1491
1539
  label: "Charleston",
1492
1540
  bpm: 150,
1493
1541
  stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
@@ -1499,9 +1547,9 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1499
1547
  label: "Kick forward, kick back",
1500
1548
  beats: 4,
1501
1549
  keys: [
1502
- { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: q },
1550
+ { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: X },
1503
1551
  { beat: 1, reset: !0 },
1504
- { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: q },
1552
+ { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: X },
1505
1553
  { beat: 3, reset: !0 }
1506
1554
  ]
1507
1555
  },
@@ -1537,7 +1585,7 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1537
1585
  { move: "basic", beats: 8, mirror: !0 },
1538
1586
  { move: "twist", beats: 4 }
1539
1587
  ]
1540
- }, Wo = {
1588
+ }, Fo = {
1541
1589
  label: "Tap",
1542
1590
  bpm: 120,
1543
1591
  // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
@@ -1635,71 +1683,145 @@ const ve = { type: "back", mode: "out", overshoot: 1.1 }, q = "ease-out-cubic",
1635
1683
  { move: "heelToe", beats: 8 },
1636
1684
  { move: "crampRoll", beats: 4 }
1637
1685
  ]
1638
- }, $e = {
1639
- disco: So,
1640
- hipHop: Eo,
1641
- breaking: Ho,
1642
- jazz: Mo,
1643
- kpop: To,
1644
- bollywood: vo,
1645
- bhangra: xo,
1646
- bharatanatyam: Ko,
1647
- charleston: Po,
1648
- tap: Wo
1649
- }, Ie = (e) => Math.min(1, Math.max(0, e));
1650
- function Oo(e) {
1686
+ }, Ro = {
1687
+ label: "Popping (glides, moonwalk)",
1688
+ bpm: 100,
1689
+ stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
1690
+ expression: { smile: 0.35, leftEye: 0.85, rightEye: 0.85, leftBrow: -0.2, rightBrow: -0.2 },
1691
+ hands: { left: "relaxed", right: "relaxed" },
1692
+ groove: { bounce: 0 },
1693
+ moves: {
1694
+ sideGlide: {
1695
+ label: "Side glide",
1696
+ beats: 2,
1697
+ easing: "linear",
1698
+ travel: 0.2,
1699
+ keys: [
1700
+ {
1701
+ beat: 0,
1702
+ reset: !0,
1703
+ pose: { leftHip: 11, leftKnee: 0, leftAnkle: 0, rightHip: 36, rightKnee: 45, rightAnkle: 45, rightShoulder: 80, rightElbow: -10, rightWrist: 10, leftShoulder: 28, leftElbow: 18, lean: -2, headTilt: 4, lookX: 0.7 },
1704
+ hands: { right: "flat", left: "relaxed" }
1705
+ },
1706
+ { beat: 1, pose: { leftHip: 27, leftKnee: 54, leftAnkle: 45, rightHip: -1, rightKnee: 0, rightAnkle: 0, rightShoulder: 74, rightWrist: -10, lean: 2 } }
1707
+ ]
1708
+ },
1709
+ moonwalk: {
1710
+ label: "Moonwalk",
1711
+ beats: 2,
1712
+ easing: "linear",
1713
+ travel: -0.29,
1714
+ keys: [
1715
+ {
1716
+ beat: 0,
1717
+ reset: !0,
1718
+ pose: { turn: 0.9, lean: 4, headTilt: -4, leftHip: -12, leftKnee: 0, leftAnkle: 0, rightHip: 23, rightKnee: 57, rightAnkle: 45, leftShoulder: -10, leftElbow: -45, rightShoulder: 14, rightElbow: 50 }
1719
+ },
1720
+ { beat: 1, pose: { leftHip: -23, leftKnee: -57, leftAnkle: 45, rightHip: 12, rightKnee: 0, rightAnkle: 0, leftShoulder: -14, leftElbow: -50, rightShoulder: 10, rightElbow: 45 } }
1721
+ ]
1722
+ },
1723
+ forwardGlide: {
1724
+ label: "Forward glide",
1725
+ beats: 2,
1726
+ easing: "linear",
1727
+ travel: 0.29,
1728
+ keys: [
1729
+ {
1730
+ beat: 0,
1731
+ reset: !0,
1732
+ pose: { turn: 0.9, lean: 2, leftHip: 16, leftKnee: 0, leftAnkle: 0, rightHip: 33, rightKnee: 59, rightAnkle: 45, leftShoulder: 12, leftElbow: -40, rightShoulder: -12, rightElbow: 40 }
1733
+ },
1734
+ { beat: 1, pose: { leftHip: -33, leftKnee: -59, leftAnkle: 45, rightHip: -16, rightKnee: 0, rightAnkle: 0, leftShoulder: -12, leftElbow: -40, rightShoulder: 12, rightElbow: 40 } }
1735
+ ]
1736
+ },
1737
+ toeStand: {
1738
+ label: "Toe stand",
1739
+ beats: 4,
1740
+ keys: [
1741
+ {
1742
+ beat: 0,
1743
+ reset: !0,
1744
+ pose: { leftHip: 6, rightHip: 6, leftKnee: 0, rightKnee: 0, leftAnkle: 65, rightAnkle: 65, rightShoulder: 150, rightElbow: 75, leftShoulder: 30, leftElbow: 20, headTilt: -10, lookY: 0.4 },
1745
+ hands: { right: "fist", left: "fist" },
1746
+ easing: be
1747
+ },
1748
+ { beat: 2, pose: { headTilt: -14, lean: -2 } }
1749
+ ]
1750
+ }
1751
+ },
1752
+ routine: [
1753
+ { move: "sideGlide", beats: 4 },
1754
+ { move: "sideGlide", beats: 4, mirror: !0 },
1755
+ { move: "moonwalk", beats: 8 },
1756
+ { move: "forwardGlide", beats: 8 },
1757
+ { move: "toeStand", beats: 4 }
1758
+ ]
1759
+ }, ce = {
1760
+ disco: xo,
1761
+ hipHop: Ao,
1762
+ breaking: Ko,
1763
+ jazz: Po,
1764
+ kpop: Wo,
1765
+ bollywood: Oo,
1766
+ bhangra: Io,
1767
+ bharatanatyam: Bo,
1768
+ charleston: _o,
1769
+ tap: Fo,
1770
+ popping: Ro
1771
+ }, $e = (e) => Math.min(1, Math.max(0, e));
1772
+ function Yo(e) {
1651
1773
  const t = { ...z, turn: e.view }, n = [];
1652
- for (const r of e.keys) {
1653
- const o = n[n.length - 1], l = !o || r.reset ? t : o.pose;
1654
- n.push({ at: r.at, pose: { ...l, ...r.pose }, easing: r.easing });
1774
+ for (const o of e.keys) {
1775
+ const r = n[n.length - 1], l = !r || o.reset ? t : r.pose;
1776
+ n.push({ at: o.at, pose: { ...l, ...o.pose }, easing: o.easing });
1655
1777
  }
1656
1778
  return n;
1657
1779
  }
1658
- function Io(e) {
1659
- return e - Bo * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1780
+ function Lo(e) {
1781
+ return e - No * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1660
1782
  }
1661
- const Bo = 0.5;
1662
- function $o(e, t) {
1783
+ const No = 0.5;
1784
+ function Co(e, t) {
1663
1785
  if (!(t <= e.takeoff || t >= e.landing))
1664
1786
  return (t - e.takeoff) / (e.landing - e.takeoff);
1665
1787
  }
1666
- function Fo(e, t) {
1667
- const n = typeof e == "string" ? it[e] : e, r = Oo(n), o = Ie(t);
1788
+ function Do(e, t) {
1789
+ const n = typeof e == "string" ? ft[e] : e, o = Yo(n), r = $e(t);
1668
1790
  let l = 0;
1669
- for (let u = 0; u < r.length; u++) r[u].at <= o && (l = u);
1670
- const i = r[l], s = r[Math.min(l + 1, r.length - 1)], h = s.at > i.at ? (o - i.at) / (s.at - i.at) : 0, a = me(i.pose, s.pose, nt(s.easing ?? "ease-in-out")(Ie(h))), f = $o(n, o);
1671
- return f === void 0 ? { ...a, spin: 0, rise: 0 } : {
1672
- ...a,
1673
- spin: n.spin * Io(f),
1791
+ for (let g = 0; g < o.length; g++) o[g].at <= r && (l = g);
1792
+ const i = o[l], s = o[Math.min(l + 1, o.length - 1)], a = s.at > i.at ? (r - i.at) / (s.at - i.at) : 0, h = we(i.pose, s.pose, _e(s.easing ?? "ease-in-out")($e(a))), f = Co(n, r);
1793
+ return f === void 0 ? { ...h, spin: 0, rise: 0 } : {
1794
+ ...h,
1795
+ spin: n.spin * Lo(f),
1674
1796
  rise: 4 * n.height * f * (1 - f)
1675
1797
  };
1676
1798
  }
1677
- function _o(e, t, n) {
1678
- const r = typeof e == "string" ? it[e] : e, o = Ie(t), l = Ie((o - r.takeoff) / (r.landing - r.takeoff));
1679
- return r.travel * n * l;
1799
+ function Xo(e, t, n) {
1800
+ const o = typeof e == "string" ? ft[e] : e, r = $e(t), l = $e((r - o.takeoff) / (o.landing - o.takeoff));
1801
+ return o.travel * n * l;
1680
1802
  }
1681
- function Ir(e, t, n = {}) {
1682
- const r = typeof t == "string" ? it[t] : t, o = n.start ?? 0, l = n.duration ?? r.duration, i = n.samples ?? 48, s = Array.from({ length: i + 1 }, (f, u) => {
1683
- const p = u / i;
1684
- return { time: o + p * l, progress: p, pose: Fo(r, p) };
1685
- }), a = Object.keys(z).filter((f) => s.some((u) => u.pose[f] !== z[f])).map((f) => ({
1803
+ function Nr(e, t, n = {}) {
1804
+ const o = typeof t == "string" ? ft[t] : t, r = n.start ?? 0, l = n.duration ?? o.duration, i = n.samples ?? 48, s = Array.from({ length: i + 1 }, (f, g) => {
1805
+ const p = g / i;
1806
+ return { time: r + p * l, progress: p, pose: Do(o, p) };
1807
+ }), h = Object.keys(z).filter((f) => s.some((g) => g.pose[f] !== z[f])).map((f) => ({
1686
1808
  id: `${e}-${f}`,
1687
1809
  target: e,
1688
1810
  property: f,
1689
- keyframes: s.map((u) => ({ time: u.time, value: u.pose[f] }))
1811
+ keyframes: s.map((g) => ({ time: g.time, value: g.pose[f] }))
1690
1812
  }));
1691
- if (n.height !== void 0 && r.travel !== 0) {
1813
+ if (n.height !== void 0 && o.travel !== 0) {
1692
1814
  const f = (n.facing ?? 1) < 0 ? -1 : 1;
1693
- a.push({
1815
+ h.push({
1694
1816
  id: `${e}-x`,
1695
1817
  target: e,
1696
1818
  property: "x",
1697
- keyframes: s.map((u) => ({ time: u.time, value: (n.x ?? 0) + f * _o(r, u.progress, n.height) }))
1819
+ keyframes: s.map((g) => ({ time: g.time, value: (n.x ?? 0) + f * Xo(o, g.progress, n.height) }))
1698
1820
  });
1699
1821
  }
1700
- return a;
1822
+ return h;
1701
1823
  }
1702
- const Ro = {
1824
+ const qo = {
1703
1825
  leftHip: -55,
1704
1826
  leftKnee: -95,
1705
1827
  rightHip: 55,
@@ -1711,7 +1833,7 @@ const Ro = {
1711
1833
  lean: 22,
1712
1834
  stretch: 0.94,
1713
1835
  headTilt: 6
1714
- }, Yo = {
1836
+ }, Uo = {
1715
1837
  leftHip: 0,
1716
1838
  leftKnee: 0,
1717
1839
  rightHip: 0,
@@ -1725,7 +1847,7 @@ const Ro = {
1725
1847
  lean: 0,
1726
1848
  stretch: 1.08,
1727
1849
  headTilt: 0
1728
- }, we = {
1850
+ }, Se = {
1729
1851
  leftHip: -128,
1730
1852
  leftKnee: -152,
1731
1853
  rightHip: 128,
@@ -1739,7 +1861,7 @@ const Ro = {
1739
1861
  lean: 26,
1740
1862
  stretch: 1,
1741
1863
  headTilt: 14
1742
- }, Lo = {
1864
+ }, zo = {
1743
1865
  leftHip: -22,
1744
1866
  leftKnee: -30,
1745
1867
  rightHip: 22,
@@ -1752,7 +1874,7 @@ const Ro = {
1752
1874
  rightElbow: 0,
1753
1875
  lean: 8,
1754
1876
  headTilt: 0
1755
- }, No = {
1877
+ }, Go = {
1756
1878
  leftHip: -58,
1757
1879
  leftKnee: -100,
1758
1880
  rightHip: 58,
@@ -1766,42 +1888,42 @@ const Ro = {
1766
1888
  lean: 20,
1767
1889
  stretch: 0.93
1768
1890
  };
1769
- function he(e, t, n, r, o, l = 1300) {
1891
+ function ae(e, t, n, o, r, l = 1300) {
1770
1892
  return {
1771
1893
  label: e,
1772
1894
  view: 1,
1773
1895
  spin: t,
1774
1896
  height: n,
1775
- travel: r,
1897
+ travel: o,
1776
1898
  takeoff: 0.27,
1777
1899
  landing: 0.8,
1778
1900
  duration: l,
1779
1901
  keys: [
1780
1902
  { at: 0, reset: !0 },
1781
- { at: 0.16, pose: Ro },
1782
- { at: 0.27, pose: Yo, easing: "ease-out-quad" },
1783
- ...o,
1784
- { at: 0.76, pose: Lo },
1785
- { at: 0.86, pose: No, easing: "ease-out-quad" },
1903
+ { at: 0.16, pose: qo },
1904
+ { at: 0.27, pose: Uo, easing: "ease-out-quad" },
1905
+ ...r,
1906
+ { at: 0.76, pose: zo },
1907
+ { at: 0.86, pose: Go, easing: "ease-out-quad" },
1786
1908
  { at: 1, reset: !0 }
1787
1909
  ]
1788
1910
  };
1789
1911
  }
1790
- const it = {
1791
- frontFlip: he("Front flip (tuck)", 360, 0.56, 0.35, [
1792
- { at: 0.38, pose: we, easing: "ease-out-cubic" },
1793
- { at: 0.64, pose: we }
1912
+ const ft = {
1913
+ frontFlip: ae("Front flip (tuck)", 360, 0.56, 0.35, [
1914
+ { at: 0.38, pose: Se, easing: "ease-out-cubic" },
1915
+ { at: 0.64, pose: Se }
1794
1916
  ]),
1795
- backFlip: he("Back flip (tuck)", -360, 0.58, -0.15, [
1796
- { at: 0.36, pose: { ...we, lean: 18 }, easing: "ease-out-cubic" },
1797
- { at: 0.64, pose: { ...we, lean: 18 } }
1917
+ backFlip: ae("Back flip (tuck)", -360, 0.58, -0.15, [
1918
+ { at: 0.36, pose: { ...Se, lean: 18 }, easing: "ease-out-cubic" },
1919
+ { at: 0.64, pose: { ...Se, lean: 18 } }
1798
1920
  ]),
1799
- layout: he("Back layout (straight body)", -360, 0.66, -0.2, [
1921
+ layout: ae("Back layout (straight body)", -360, 0.66, -0.2, [
1800
1922
  // Arched, arms overhead, legs together and long.
1801
1923
  { at: 0.4, pose: { leftHip: 8, rightHip: -8, leftKnee: 0, rightKnee: 0, leftAnkle: 60, rightAnkle: 60, leftShoulder: -178, rightShoulder: 178, lean: -18, headTilt: -14 } },
1802
1924
  { at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
1803
1925
  ], 1400),
1804
- scissorFlip: he("Scissor flip", 360, 0.6, 0.45, [
1926
+ scissorFlip: ae("Scissor flip", 360, 0.6, 0.45, [
1805
1927
  // The legs scissor through the turn: left kicks high, then they switch.
1806
1928
  { at: 0.36, pose: { leftHip: -105, leftKnee: 0, rightHip: -40, rightKnee: -20, leftAnkle: 50, rightAnkle: 50, leftShoulder: -150, rightShoulder: 150, leftElbow: 0, rightElbow: 0, lean: 12 }, easing: "ease-out-cubic" },
1807
1929
  { at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
@@ -1847,7 +1969,7 @@ const it = {
1847
1969
  ]
1848
1970
  },
1849
1971
  // Leaps: no turn, the shape is the trick.
1850
- splitLeap: he("Split leap (grand jeté)", 0, 0.36, 0.9, [
1972
+ splitLeap: ae("Split leap (grand jeté)", 0, 0.36, 0.9, [
1851
1973
  // A front split in the air: front leg reaching, back leg long, arms open.
1852
1974
  { at: 0.4, pose: { leftHip: -96, rightHip: -84, leftKnee: 0, rightKnee: 0, leftAnkle: 55, rightAnkle: 55, leftShoulder: -130, rightShoulder: -105, leftElbow: 0, rightElbow: 0, lean: 4, headTilt: -6 }, easing: "ease-out-cubic" },
1853
1975
  { at: 0.64, pose: { lean: 2 } }
@@ -1873,12 +1995,12 @@ const it = {
1873
1995
  { at: 1, reset: !0 }
1874
1996
  ]
1875
1997
  },
1876
- backHandspring: he("Back handspring", -360, 0.16, -0.7, [
1998
+ backHandspring: ae("Back handspring", -360, 0.16, -0.7, [
1877
1999
  // Arms reach back overhead to the ground, legs snap over.
1878
2000
  { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
1879
2001
  { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
1880
2002
  ], 1200)
1881
- }, Le = 0.215, Ne = 0.205, Co = 0.065, Mt = 0.035, Do = 0.165, qo = 0.155, Xo = 12, Uo = (e) => e * Math.PI / 180, te = {
2003
+ }, Ce = 0.215, De = 0.205, Jo = 0.065, At = 0.035, Zo = 0.165, jo = 0.155, Qo = 12, Vo = (e) => e * Math.PI / 180, te = {
1882
2004
  turn: 0,
1883
2005
  lean: 0,
1884
2006
  side: 0,
@@ -1923,12 +2045,21 @@ const it = {
1923
2045
  function G(e = {}) {
1924
2046
  return { ...te, ...e };
1925
2047
  }
2048
+ const er = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2049
+ function Cr(e) {
2050
+ const t = {};
2051
+ for (const [n, o] of Object.entries(e)) {
2052
+ const r = n.replace(/(^|\.)(left|right)(\.|$)/, (l, i, s, a) => `${i}${s === "left" ? "right" : "left"}${a}`);
2053
+ t[r] = er.has(n) ? -o : o;
2054
+ }
2055
+ return t;
2056
+ }
1926
2057
  function U(e, t) {
1927
2058
  const n = {};
1928
- for (const r of ["left", "right"]) for (const [o, l] of Object.entries(t)) n[`${e}.${r}.${o}`] = l;
2059
+ for (const o of ["left", "right"]) for (const [r, l] of Object.entries(t)) n[`${e}.${o}.${r}`] = l;
1929
2060
  return n;
1930
2061
  }
1931
- const zo = {
2062
+ const tr = {
1932
2063
  rest: te,
1933
2064
  wave: G({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
1934
2065
  cheer: G({ ...U("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
@@ -1953,32 +2084,32 @@ const zo = {
1953
2084
  crawl: G({ lean: 82, "head.nod": -35, ...U("arm", { swing: 80, elbow: 0, spread: 4 }), ...U("leg", { knee: 92, ankle: -88 }) }),
1954
2085
  lieDown: G({ roll: 90, ...U("arm", { spread: 8 }), "head.nod": 0 })
1955
2086
  };
1956
- function Go(e = {}) {
1957
- const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, r = e.hipWidth ?? 0.022, o = Math.max(0.12, 1 - t - Mt - (Le + Ne)), l = (h) => ({
1958
- id: `arm.${h}`,
2087
+ function nr(e = {}) {
2088
+ const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, o = e.hipWidth ?? 0.022, r = Math.max(0.12, 1 - t - At - (Ce + De)), l = (a) => ({
2089
+ id: `arm.${a}`,
1959
2090
  parent: "spine",
1960
- offset: [(h === "left" ? 1 : -1) * n, -0.035, 0],
2091
+ offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
1961
2092
  rest: [0, -1, 0],
1962
- side: h === "left" ? 1 : -1,
2093
+ side: a === "left" ? 1 : -1,
1963
2094
  bones: [
1964
- { length: Do, width: [1.25, 0.9] },
1965
- { length: qo, width: [0.9, 0.75] }
2095
+ { length: Zo, width: [1.25, 0.9] },
2096
+ { length: jo, width: [0.9, 0.75] }
1966
2097
  ]
1967
- }), i = (h) => ({
1968
- id: `leg.${h}`,
2098
+ }), i = (a) => ({
2099
+ id: `leg.${a}`,
1969
2100
  parent: null,
1970
- offset: [(h === "left" ? 1 : -1) * r, 0, 0],
2101
+ offset: [(a === "left" ? 1 : -1) * o, 0, 0],
1971
2102
  rest: [0, -1, 0],
1972
- side: h === "left" ? 1 : -1,
2103
+ side: a === "left" ? 1 : -1,
1973
2104
  bones: [
1974
- { length: Le, width: [1.45, 1.05] },
1975
- { length: Ne, width: [1.05, 0.85] },
1976
- { length: Co, width: [0.95, 0.7] }
2105
+ { length: Ce, width: [1.45, 1.05] },
2106
+ { length: De, width: [1.05, 0.85] },
2107
+ { length: Jo, width: [0.95, 0.7] }
1977
2108
  ]
1978
- }), s = (h, a) => h[a] ?? te[a] ?? 0;
2109
+ }), s = (a, h) => a[h] ?? te[h] ?? 0;
1979
2110
  return {
1980
2111
  id: "human",
1981
- hipHeight: Le + Ne,
2112
+ hipHeight: Ce + De,
1982
2113
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
1983
2114
  chains: [
1984
2115
  i("left"),
@@ -1988,74 +2119,74 @@ function Go(e = {}) {
1988
2119
  parent: null,
1989
2120
  rest: [0, 1, 0],
1990
2121
  bones: [
1991
- { length: o / 2, width: [1.7, 1.4] },
1992
- { length: o / 2, width: [1.4, 1.1] }
2122
+ { length: r / 2, width: [1.7, 1.4] },
2123
+ { length: r / 2, width: [1.4, 1.1] }
1993
2124
  ]
1994
2125
  },
1995
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Mt, width: [1, 0.9] }] },
2126
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: At, width: [1, 0.9] }] },
1996
2127
  l("left"),
1997
2128
  l("right")
1998
2129
  ],
1999
2130
  head: { on: "neck", size: t },
2000
2131
  contacts: [
2001
- ...["left", "right"].flatMap((h) => [
2002
- { chain: `leg.${h}`, joint: 1 },
2003
- { chain: `leg.${h}`, joint: 2 },
2004
- { chain: `leg.${h}`, joint: 3 },
2005
- { chain: `arm.${h}`, joint: 1 },
2006
- { chain: `arm.${h}`, joint: 2 }
2132
+ ...["left", "right"].flatMap((a) => [
2133
+ { chain: `leg.${a}`, joint: 1 },
2134
+ { chain: `leg.${a}`, joint: 2 },
2135
+ { chain: `leg.${a}`, joint: 3 },
2136
+ { chain: `arm.${a}`, joint: 1 },
2137
+ { chain: `arm.${a}`, joint: 2 }
2007
2138
  ]),
2008
2139
  { chain: "spine", joint: 0 },
2009
2140
  { chain: "spine", joint: 1 },
2010
2141
  { chain: "spine", joint: 2 },
2011
2142
  { head: "top" }
2012
2143
  ],
2013
- angles(h, a) {
2014
- if (a.id === "spine") {
2015
- const d = -s(h, "lean") / 2, b = s(h, "side") / 2;
2144
+ angles(a, h) {
2145
+ if (h.id === "spine") {
2146
+ const d = -s(a, "lean") / 2, b = s(a, "side") / 2;
2016
2147
  return [
2017
2148
  { swing: d, spread: b },
2018
2149
  { swing: d, spread: b }
2019
2150
  ];
2020
2151
  }
2021
- if (a.id === "neck") return [{ swing: 0, spread: 0 }];
2022
- const [f, u] = a.id.split("."), p = (d) => s(h, `${f}.${u}.${d}`);
2152
+ if (h.id === "neck") return [{ swing: 0, spread: 0 }];
2153
+ const [f, g] = h.id.split("."), p = (d) => s(a, `${f}.${g}.${d}`);
2023
2154
  if (f === "arm")
2024
2155
  return [
2025
2156
  { swing: p("swing"), spread: p("spread") },
2026
2157
  { swing: p("elbow"), spread: p("bend") }
2027
2158
  ];
2028
- const c = (a.side ?? 1) * p("rotate"), g = 1 - Math.cos(Uo(p("rotate")));
2159
+ const c = (h.side ?? 1) * p("rotate"), u = 1 - Math.cos(Vo(p("rotate")));
2029
2160
  return [
2030
2161
  { swing: p("swing"), spread: p("spread"), yaw: c },
2031
2162
  { swing: -p("knee"), spread: 0, yaw: c },
2032
2163
  // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2033
- { swing: 90 + p("ankle") - g * (p("swing") - p("knee")), spread: 0, yaw: (Xo + p("toeOut")) * (a.side ?? 1) }
2164
+ { swing: 90 + p("ankle") - u * (p("swing") - p("knee")), spread: 0, yaw: (Qo + p("toeOut")) * (h.side ?? 1) }
2034
2165
  ];
2035
2166
  },
2036
- withAngles(h, a, f) {
2037
- const [u, p] = a.id.split("."), c = (g) => `${u}.${p}.${g}`;
2038
- return u === "arm" ? {
2039
- ...h,
2167
+ withAngles(a, h, f) {
2168
+ const [g, p] = h.id.split("."), c = (u) => `${g}.${p}.${u}`;
2169
+ return g === "arm" ? {
2170
+ ...a,
2040
2171
  [c("swing")]: f[0].swing,
2041
2172
  [c("spread")]: f[0].spread,
2042
2173
  [c("elbow")]: f[1].swing,
2043
2174
  [c("bend")]: f[1].spread
2044
- } : u === "leg" ? { ...h, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : h;
2175
+ } : g === "leg" ? { ...a, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : a;
2045
2176
  },
2046
- boneScale(h, a) {
2047
- const f = Math.min(3, Math.max(0.3, s(h, "stretch")));
2048
- return a?.id.startsWith("arm.") ? Math.sqrt(f) : f;
2177
+ boneScale(a, h) {
2178
+ const f = Math.min(3, Math.max(0.3, s(a, "stretch")));
2179
+ return h?.id.startsWith("arm.") ? Math.sqrt(f) : f;
2049
2180
  },
2050
- headPose(h) {
2051
- const a = Math.min(3, Math.max(0.3, s(h, "stretch")));
2181
+ headPose(a) {
2182
+ const h = Math.min(3, Math.max(0.3, s(a, "stretch")));
2052
2183
  return {
2053
- yaw: s(h, "head.turn"),
2054
- nod: s(h, "head.nod"),
2055
- tilt: s(h, "head.tilt"),
2184
+ yaw: s(a, "head.turn"),
2185
+ nod: s(a, "head.nod"),
2186
+ tilt: s(a, "head.tilt"),
2056
2187
  // The head keeps its area: taller and narrower when stretched.
2057
- sx: 1 / Math.sqrt(a),
2058
- sy: Math.sqrt(a)
2188
+ sx: 1 / Math.sqrt(h),
2189
+ sy: Math.sqrt(h)
2059
2190
  };
2060
2191
  },
2061
2192
  landmarks: {
@@ -2077,15 +2208,15 @@ function Go(e = {}) {
2077
2208
  }
2078
2209
  };
2079
2210
  }
2080
- function Br(e) {
2211
+ function Dr(e) {
2081
2212
  const t = e.split(".");
2082
2213
  if (t[0] === "hand" && t.length >= 3) {
2083
- const r = `${t[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, l = t.slice(2).join(".");
2084
- return `${r} · ${o[l] ?? l.replace(".curl", " curl").replace(".across", " across")}`;
2214
+ const o = `${t[1] === "left" ? "Left" : "Right"} hand`, r = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, l = t.slice(2).join(".");
2215
+ return `${o} · ${r[l] ?? l.replace(".curl", " curl").replace(".across", " across")}`;
2085
2216
  }
2086
2217
  if (t.length === 3) {
2087
- const [r, o, l] = t;
2088
- return `${`${o === "left" ? "Left" : "Right"} ${r}`} · ${{
2218
+ const [o, r, l] = t;
2219
+ return `${`${r === "left" ? "Left" : "Right"} ${o}`} · ${{
2089
2220
  swing: "forward / back",
2090
2221
  spread: "out / in",
2091
2222
  elbow: "elbow bend",
@@ -2119,248 +2250,248 @@ function Br(e) {
2119
2250
  lookY: "Look up / down"
2120
2251
  }[e] ?? e;
2121
2252
  }
2122
- const Jo = {
2253
+ const or = {
2123
2254
  leftEye: "eye.left",
2124
2255
  rightEye: "eye.right",
2125
2256
  leftBrow: "brow.left",
2126
2257
  rightBrow: "brow.right"
2127
- }, $r = Object.fromEntries(
2258
+ }, Xr = Object.fromEntries(
2128
2259
  Object.entries(J).map(([e, t]) => [
2129
2260
  e,
2130
- Object.fromEntries(Object.entries(t).map(([n, r]) => [Jo[n] ?? n, r]))
2261
+ Object.fromEntries(Object.entries(t).map(([n, o]) => [or[n] ?? n, o]))
2131
2262
  ])
2132
2263
  );
2133
- function Fr(e, t) {
2134
- const n = Math.min(1, Math.max(0, e.turn ?? 0)), r = 1 - n, o = { ...te, turn: n }, l = [
2264
+ function qr(e, t) {
2265
+ const n = Math.min(1, Math.max(0, e.turn ?? 0)), o = 1 - n, r = { ...te, turn: n }, l = [
2135
2266
  { stick: "right", human: "left", s: 1 },
2136
2267
  { stick: "left", human: "right", s: -1 }
2137
2268
  ];
2138
- for (const { stick: i, human: s, s: h } of l) {
2139
- const a = e[`${i}Shoulder`], f = e[`${i}Elbow`];
2140
- o[`arm.${s}.spread`] = a * r, o[`arm.${s}.swing`] = h * a * n, o[`arm.${s}.bend`] = f * r, o[`arm.${s}.elbow`] = h * f * n;
2141
- const u = e[`${i}Hip`], p = e[`${i}Knee`], c = r + h * n;
2142
- o[`leg.${s}.rotate`] = 90 * r, o[`leg.${s}.spread`] = 0, o[`leg.${s}.swing`] = u * c, o[`leg.${s}.knee`] = p * c, o[`leg.${s}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${s}.toeOut`] = (e[`${i}FootOut`] ?? 0) * Zo, o[`eye.${s}`] = e[`${i}Eye`], o[`brow.${s}`] = e[`${i}Brow`], t && Object.assign(o, jo(s, t[i] ?? R, e[`${i}Wrist`] ?? 0, n));
2269
+ for (const { stick: i, human: s, s: a } of l) {
2270
+ const h = e[`${i}Shoulder`], f = e[`${i}Elbow`];
2271
+ r[`arm.${s}.spread`] = h * o, r[`arm.${s}.swing`] = a * h * n, r[`arm.${s}.bend`] = f * o, r[`arm.${s}.elbow`] = a * f * n;
2272
+ const g = e[`${i}Hip`], p = e[`${i}Knee`], c = o + a * n;
2273
+ r[`leg.${s}.rotate`] = 90 * o, r[`leg.${s}.spread`] = 0, r[`leg.${s}.swing`] = g * c, r[`leg.${s}.knee`] = p * c, r[`leg.${s}.ankle`] = -(e[`${i}Ankle`] ?? 0), r[`leg.${s}.toeOut`] = (e[`${i}FootOut`] ?? 0) * rr, r[`eye.${s}`] = e[`${i}Eye`], r[`brow.${s}`] = e[`${i}Brow`], t && Object.assign(r, lr(s, t[i] ?? R, e[`${i}Wrist`] ?? 0, n));
2143
2274
  }
2144
- o.lean = e.lean * n, o.side = e.lean * r, o["head.tilt"] = e.headTilt * r, o["head.nod"] = e.headTilt * n;
2145
- for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
2146
- return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
2275
+ r.lean = e.lean * n, r.side = e.lean * o, r["head.tilt"] = e.headTilt * o, r["head.nod"] = e.headTilt * n;
2276
+ for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) r[i] = e[i];
2277
+ return r.lift = e.rise ?? 0, r.roll = e.spin ?? 0, r;
2147
2278
  }
2148
- const Zo = 70;
2149
- function jo(e, t, n, r) {
2150
- const o = e === "right" ? 1 - r : 1 + r, l = {};
2279
+ const rr = 70;
2280
+ function lr(e, t, n, o) {
2281
+ const r = e === "right" ? 1 - o : 1 + o, l = {};
2151
2282
  for (const i of Object.keys(R)) l[`hand.${e}.${i}`] = t[i] ?? R[i];
2152
- return l[`hand.${e}.turn`] = (t.turn ?? 0) - o, l[`hand.${e}.roll`] = (t.roll ?? 0) + n, l;
2283
+ return l[`hand.${e}.turn`] = (t.turn ?? 0) - r, l[`hand.${e}.roll`] = (t.roll ?? 0) + n, l;
2153
2284
  }
2154
- function Qo(e, t, n = {}, r) {
2155
- const o = n.length ?? 240, l = 9, i = 28, s = o - 22;
2156
- e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(i, -l, s - i, 2 * l), e.fillStyle = "#e8b4a0", e.fillRect(s, -l, o - s, 2 * l), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(i, -l), e.lineTo(i, l), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(i * 0.35, -l * 0.35), e.lineTo(i * 0.35, l * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2157
- const h = [
2158
- [{ x: 0, y: 0 }, { x: i, y: -l }, { x: o, y: -l }, { x: o, y: l }, { x: i, y: l }, { x: 0, y: 0 }],
2285
+ function sr(e, t, n = {}, o) {
2286
+ const r = n.length ?? 240, l = 9, i = 28, s = r - 22;
2287
+ e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(i, -l, s - i, 2 * l), e.fillStyle = "#e8b4a0", e.fillRect(s, -l, r - s, 2 * l), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(i, -l), e.lineTo(i, l), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(i * 0.35, -l * 0.35), e.lineTo(i * 0.35, l * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2288
+ const a = [
2289
+ [{ x: 0, y: 0 }, { x: i, y: -l }, { x: r, y: -l }, { x: r, y: l }, { x: i, y: l }, { x: 0, y: 0 }],
2159
2290
  [{ x: i, y: -l }, { x: i, y: l }],
2160
2291
  [{ x: s, y: -l }, { x: s, y: l }]
2161
2292
  ];
2162
- for (const a of h) Zt(e, a, r);
2293
+ for (const h of a) nn(e, h, o);
2163
2294
  e.restore();
2164
2295
  }
2165
- function zt(e, t, n = {}, r) {
2166
- const o = n.length ?? 90, l = n.thickness ?? 34;
2296
+ function Vt(e, t, n = {}, o) {
2297
+ const r = n.length ?? 90, l = n.thickness ?? 34;
2167
2298
  e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
2168
2299
  const i = -l / 2;
2169
- e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, i, o, l), e.fillStyle = "#e9edf2", e.fillRect(o * 0.45, i, o * 0.55, l), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2300
+ e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, i, r, l), e.fillStyle = "#e9edf2", e.fillRect(r * 0.45, i, r * 0.55, l), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2170
2301
  const s = [
2171
2302
  { x: 0, y: i },
2172
- { x: o, y: i },
2173
- { x: o, y: -i },
2303
+ { x: r, y: i },
2304
+ { x: r, y: -i },
2174
2305
  { x: 0, y: -i },
2175
2306
  { x: 0, y: i }
2176
- ], h = [{ x: o * 0.45, y: i }, { x: o * 0.45, y: -i }];
2177
- if (r)
2178
- r.line(s), r.line(h);
2307
+ ], a = [{ x: r * 0.45, y: i }, { x: r * 0.45, y: -i }];
2308
+ if (o)
2309
+ o.line(s), o.line(a);
2179
2310
  else
2180
- for (const a of [s, h]) {
2181
- e.beginPath(), e.moveTo(a[0].x, a[0].y);
2182
- for (const f of a.slice(1)) e.lineTo(f.x, f.y);
2311
+ for (const h of [s, a]) {
2312
+ e.beginPath(), e.moveTo(h[0].x, h[0].y);
2313
+ for (const f of h.slice(1)) e.lineTo(f.x, f.y);
2183
2314
  e.stroke();
2184
2315
  }
2185
2316
  e.restore();
2186
2317
  }
2187
- const Gt = 150, Vo = { pencil: 44, eraser: 30 };
2188
- function Jt(e, t, n = {}, r) {
2189
- const o = n.tool ?? "pencil", l = n.skin ?? "#f1c9a5", i = n.outline ?? "#2f2f33", s = n.scale ?? 1, h = Math.min(1, Math.max(0, n.lift ?? 0)), a = (n.angle ?? -30) * Math.PI / 180, f = r ? r.nudge(0.6) : { x: 0, y: 0 }, u = Gt * s * (1 + 0.05 * h);
2190
- h > 0 && (e.save(), e.fillStyle = i, e.globalAlpha = 0.15 * h, e.beginPath(), e.ellipse(t.x, t.y, 9 * s, 4 * s, 0, 0, Math.PI * 2), e.fill(), e.restore());
2191
- const p = { x: t.x + f.x + 6 * h * s, y: t.y + f.y - 18 * h * s }, c = N.pencilGrip, g = (E) => {
2192
- const v = E.fingers.thumb, A = E.fingers.index, I = E.fingers.middle, W = Tt([v.points[3], A.points[3], I.points[3]]), M = Tt([v.points[1], A.points[0]]), y = (v.depths[3] + A.depths[3] + I.depths[3]) / 3;
2193
- return { pinch: W, direction: Math.atan2(M.y - W.y, M.x - W.x), depth: y };
2194
- }, d = Je(c, { size: u }), b = a - g(d).direction, m = Je(c, { size: u, angle: b * 180 / Math.PI }), S = g(m), k = Vo[o] * s, T = { x: S.pinch.x - Math.cos(a) * k, y: S.pinch.y - Math.sin(a) * k }, H = { x: p.x - T.x, y: p.y - T.y }, w = m.axes.up;
2195
- er(e, H, { x: -w.x, y: -w.y }, u, n.arm ?? 300 * s, l, n.sleeve ?? "#5b7db1", i), rt(e, H, c, {
2196
- size: u,
2318
+ const en = 150, ir = { pencil: 44, eraser: 30 };
2319
+ function tn(e, t, n = {}, o) {
2320
+ const r = n.tool ?? "pencil", l = n.skin ?? "#f1c9a5", i = n.outline ?? "#2f2f33", s = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, f = o ? o.nudge(0.6) : { x: 0, y: 0 }, g = en * s * (1 + 0.05 * a);
2321
+ a > 0 && (e.save(), e.fillStyle = i, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * s, 4 * s, 0, 0, Math.PI * 2), e.fill(), e.restore());
2322
+ const p = { x: t.x + f.x + 6 * a * s, y: t.y + f.y - 18 * a * s }, c = N.pencilGrip, u = (E) => {
2323
+ const T = E.fingers.thumb, A = E.fingers.index, I = E.fingers.middle, W = Kt([T.points[3], A.points[3], I.points[3]]), v = Kt([T.points[1], A.points[0]]), y = (T.depths[3] + A.depths[3] + I.depths[3]) / 3;
2324
+ return { pinch: W, direction: Math.atan2(v.y - W.y, v.x - W.x), depth: y };
2325
+ }, d = je(c, { size: g }), b = h - u(d).direction, m = je(c, { size: g, angle: b * 180 / Math.PI }), w = u(m), S = ir[r] * s, M = { x: w.pinch.x - Math.cos(h) * S, y: w.pinch.y - Math.sin(h) * S }, H = { x: p.x - M.x, y: p.y - M.y }, k = m.axes.up;
2326
+ ar(e, H, { x: -k.x, y: -k.y }, g, n.arm ?? 300 * s, l, n.sleeve ?? "#5b7db1", i), st(e, H, c, {
2327
+ size: g,
2197
2328
  angle: b * 180 / Math.PI,
2198
2329
  skin: l,
2199
2330
  ink: i,
2200
2331
  lineWidth: 3 * s,
2201
2332
  prop: {
2202
- depth: S.depth,
2333
+ depth: w.depth,
2203
2334
  draw: () => {
2204
- e.save(), e.translate(p.x, p.y), e.scale(s, s), o === "eraser" ? zt(e, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, outline: i }, r) : Qo(e, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, length: 190, outline: i }, r), e.restore();
2335
+ e.save(), e.translate(p.x, p.y), e.scale(s, s), r === "eraser" ? Vt(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: i }, o) : sr(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: i }, o), e.restore();
2205
2336
  }
2206
2337
  }
2207
2338
  });
2208
2339
  }
2209
- const Tt = (e) => ({
2340
+ const Kt = (e) => ({
2210
2341
  x: e.reduce((t, n) => t + n.x, 0) / e.length,
2211
2342
  y: e.reduce((t, n) => t + n.y, 0) / e.length
2212
2343
  });
2213
- function er(e, t, n, r, o, l, i, s) {
2214
- const h = { x: -n.y, y: n.x }, a = r * 0.15, f = (d, b, m) => ({
2215
- x: t.x + n.x * d + h.x * b * m,
2216
- y: t.y + n.y * d + h.y * b * m
2217
- }), u = f(o, 0, 0), p = (d) => {
2218
- const b = e.createLinearGradient(t.x, t.y, u.x, u.y);
2219
- return b.addColorStop(0, d), b.addColorStop(0.6, d), b.addColorStop(1, tr(d)), b;
2220
- }, c = Math.min(r * 0.55, o * 0.35);
2221
- e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (r / Gt), e.beginPath(), e.moveTo(f(-r * 0.1, -1, a).x, f(-r * 0.1, -1, a).y), e.lineTo(f(c + 4, -1, a * 1.1).x, f(c + 4, -1, a * 1.1).y), e.lineTo(f(c + 4, 1, a * 1.1).x, f(c + 4, 1, a * 1.1).y), e.lineTo(f(-r * 0.1, 1, a).x, f(-r * 0.1, 1, a).y), e.closePath(), e.fillStyle = l, e.fill(), e.strokeStyle = s, e.beginPath(), e.moveTo(f(0, -1, a).x, f(0, -1, a).y), e.lineTo(f(c, -1, a * 1.1).x, f(c, -1, a * 1.1).y), e.moveTo(f(0, 1, a).x, f(0, 1, a).y), e.lineTo(f(c, 1, a * 1.1).x, f(c, 1, a * 1.1).y), e.stroke();
2222
- const g = [f(c, -1, a * 1.3), f(o, -1, a * 1.5), f(o, 1, a * 1.5), f(c, 1, a * 1.3)];
2223
- e.beginPath(), g.forEach((d, b) => b ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = p(i), e.fill(), e.strokeStyle = p(s), e.beginPath(), e.moveTo(g[1].x, g[1].y), e.lineTo(g[0].x, g[0].y), e.lineTo(g[3].x, g[3].y), e.lineTo(g[2].x, g[2].y), e.stroke(), e.restore();
2224
- }
2225
- function _r(e, t, n = {}) {
2226
- const r = n.offstage ?? { x: 2e3, y: 1400 }, o = n.enter ?? 450, l = n.exit ?? 450, i = n.linger ?? 1500, s = [...e].filter((d) => d.path.length > 0).sort((d, b) => d.start - b.start), h = (d) => d.tool ?? "pencil", a = (d) => {
2344
+ function ar(e, t, n, o, r, l, i, s) {
2345
+ const a = { x: -n.y, y: n.x }, h = o * 0.15, f = (d, b, m) => ({
2346
+ x: t.x + n.x * d + a.x * b * m,
2347
+ y: t.y + n.y * d + a.y * b * m
2348
+ }), g = f(r, 0, 0), p = (d) => {
2349
+ const b = e.createLinearGradient(t.x, t.y, g.x, g.y);
2350
+ return b.addColorStop(0, d), b.addColorStop(0.6, d), b.addColorStop(1, hr(d)), b;
2351
+ }, c = Math.min(o * 0.55, r * 0.35);
2352
+ e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (o / en), e.beginPath(), e.moveTo(f(-o * 0.1, -1, h).x, f(-o * 0.1, -1, h).y), e.lineTo(f(c + 4, -1, h * 1.1).x, f(c + 4, -1, h * 1.1).y), e.lineTo(f(c + 4, 1, h * 1.1).x, f(c + 4, 1, h * 1.1).y), e.lineTo(f(-o * 0.1, 1, h).x, f(-o * 0.1, 1, h).y), e.closePath(), e.fillStyle = l, e.fill(), e.strokeStyle = s, e.beginPath(), e.moveTo(f(0, -1, h).x, f(0, -1, h).y), e.lineTo(f(c, -1, h * 1.1).x, f(c, -1, h * 1.1).y), e.moveTo(f(0, 1, h).x, f(0, 1, h).y), e.lineTo(f(c, 1, h * 1.1).x, f(c, 1, h * 1.1).y), e.stroke();
2353
+ const u = [f(c, -1, h * 1.3), f(r, -1, h * 1.5), f(r, 1, h * 1.5), f(c, 1, h * 1.3)];
2354
+ e.beginPath(), u.forEach((d, b) => b ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = p(i), e.fill(), e.strokeStyle = p(s), e.beginPath(), e.moveTo(u[1].x, u[1].y), e.lineTo(u[0].x, u[0].y), e.lineTo(u[3].x, u[3].y), e.lineTo(u[2].x, u[2].y), e.stroke(), e.restore();
2355
+ }
2356
+ function Ur(e, t, n = {}) {
2357
+ const o = n.offstage ?? { x: 2e3, y: 1400 }, r = n.enter ?? 450, l = n.exit ?? 450, i = n.linger ?? 1500, s = [...e].filter((d) => d.path.length > 0).sort((d, b) => d.start - b.start), a = (d) => d.tool ?? "pencil", h = (d) => {
2227
2358
  const b = Math.min(1, Math.max(0, d));
2228
2359
  return b * b * (3 - 2 * b);
2229
- }, f = (d, b, m) => ({ x: d.x + (b.x - d.x) * m, y: d.y + (b.y - d.y) * m }), u = s.find((d) => t >= d.start && t <= d.end);
2230
- if (u) {
2231
- const d = u.end - u.start, b = d > 0 ? (t - u.start) / d : 1;
2232
- return { at: tt(u.path, b), tool: h(u), lift: 0, drawing: !0 };
2360
+ }, f = (d, b, m) => ({ x: d.x + (b.x - d.x) * m, y: d.y + (b.y - d.y) * m }), g = s.find((d) => t >= d.start && t <= d.end);
2361
+ if (g) {
2362
+ const d = g.end - g.start, b = d > 0 ? (t - g.start) / d : 1;
2363
+ return { at: rt(g.path, b), tool: a(g), lift: 0, drawing: !0 };
2233
2364
  }
2234
- const p = [...s].reverse().find((d) => d.end < t), c = s.find((d) => d.start > t), g = (d) => d.path[d.path.length - 1];
2365
+ const p = [...s].reverse().find((d) => d.end < t), c = s.find((d) => d.start > t), u = (d) => d.path[d.path.length - 1];
2235
2366
  if (p && c && c.start - p.end <= i) {
2236
- const d = (t - p.end) / (c.start - p.end), b = d < 0.5 ? h(p) : h(c);
2237
- return { at: f(g(p), c.path[0], a(d)), tool: b, lift: Math.sin(Math.PI * d), drawing: !1 };
2367
+ const d = (t - p.end) / (c.start - p.end), b = d < 0.5 ? a(p) : a(c);
2368
+ return { at: f(u(p), c.path[0], h(d)), tool: b, lift: Math.sin(Math.PI * d), drawing: !1 };
2238
2369
  }
2239
- if (c && c.start - t <= o) {
2240
- const d = 1 - (c.start - t) / o;
2241
- return { at: f(r, c.path[0], a(d)), tool: h(c), lift: 1 - a(d), drawing: !1 };
2370
+ if (c && c.start - t <= r) {
2371
+ const d = 1 - (c.start - t) / r;
2372
+ return { at: f(o, c.path[0], h(d)), tool: a(c), lift: 1 - h(d), drawing: !1 };
2242
2373
  }
2243
2374
  if (p && t - p.end <= l) {
2244
2375
  const d = (t - p.end) / l;
2245
- return { at: f(g(p), r, a(d)), tool: h(p), lift: a(d), drawing: !1 };
2376
+ return { at: f(u(p), o, h(d)), tool: a(p), lift: h(d), drawing: !1 };
2246
2377
  }
2247
2378
  return null;
2248
2379
  }
2249
- function Rr(e, t, n, r = 0.08, o = 32) {
2250
- const l = Math.PI * 2 * (1 + r), i = [];
2251
- for (let s = 0; s <= o; s++) {
2252
- const h = -Math.PI / 2 + l * s / o;
2253
- i.push({ x: e + Math.cos(h) * n, y: t + Math.sin(h) * n });
2380
+ function zr(e, t, n, o = 0.08, r = 32) {
2381
+ const l = Math.PI * 2 * (1 + o), i = [];
2382
+ for (let s = 0; s <= r; s++) {
2383
+ const a = -Math.PI / 2 + l * s / r;
2384
+ i.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
2254
2385
  }
2255
2386
  return i;
2256
2387
  }
2257
- function Yr(e) {
2258
- const { path: t } = e, n = t.map((s) => s.x), r = t.map((s) => s.y), o = Math.min(...n), l = Math.min(...r), i = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
2388
+ function Gr(e) {
2389
+ const { path: t } = e, n = t.map((s) => s.x), o = t.map((s) => s.y), r = Math.min(...n), l = Math.min(...o), i = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
2259
2390
  return {
2260
2391
  type: "custom",
2261
- x: o,
2392
+ x: r,
2262
2393
  y: l,
2263
- width: Math.max(1, Math.max(...n) - o),
2264
- height: Math.max(1, Math.max(...r) - l),
2394
+ width: Math.max(1, Math.max(...n) - r),
2395
+ height: Math.max(1, Math.max(...o) - l),
2265
2396
  props: { draw: 0 },
2266
- draw(s, h, a) {
2267
- const f = Math.min(1, Math.max(0, Number(h.props?.draw ?? 0)));
2268
- s.translate(-o, -l), s.strokeStyle = e.color ?? "#2f2f33", s.lineWidth = e.lineWidth ?? 5, s.lineCap = "round", s.lineJoin = "round";
2269
- const u = e.sketch ? Ue(s, e.sketch, a) : void 0;
2270
- f > 0 && (u ? e.smooth ? u.curve(t, f) : u.line(t, f) : Zt(s, Kt(t, f))), i && f > 0 && f < 1 && Jt(s, tt(t, f), i, u);
2397
+ draw(s, a, h) {
2398
+ const f = Math.min(1, Math.max(0, Number(a.props?.draw ?? 0)));
2399
+ s.translate(-r, -l), s.strokeStyle = e.color ?? "#2f2f33", s.lineWidth = e.lineWidth ?? 5, s.lineCap = "round", s.lineJoin = "round";
2400
+ const g = e.sketch ? Ge(s, e.sketch, h) : void 0;
2401
+ f > 0 && (g ? e.smooth ? g.curve(t, f) : g.line(t, f) : nn(s, It(t, f))), i && f > 0 && f < 1 && tn(s, rt(t, f), i, g);
2271
2402
  }
2272
2403
  };
2273
2404
  }
2274
- function tr(e) {
2405
+ function hr(e) {
2275
2406
  const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2276
2407
  if (!t) return "rgba(0, 0, 0, 0)";
2277
- const n = t[1].length === 3 ? [...t[1]].map((i) => i + i).join("") : t[1], [r, o, l] = [0, 2, 4].map((i) => parseInt(n.slice(i, i + 2), 16));
2278
- return `rgba(${r}, ${o}, ${l}, 0)`;
2408
+ const n = t[1].length === 3 ? [...t[1]].map((i) => i + i).join("") : t[1], [o, r, l] = [0, 2, 4].map((i) => parseInt(n.slice(i, i + 2), 16));
2409
+ return `rgba(${o}, ${r}, ${l}, 0)`;
2279
2410
  }
2280
- function Zt(e, t, n) {
2411
+ function nn(e, t, n) {
2281
2412
  if (!(t.length < 2)) {
2282
2413
  if (n) return n.line(t);
2283
2414
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
2284
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
2415
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
2285
2416
  e.stroke();
2286
2417
  }
2287
2418
  }
2288
- const ke = 1e5;
2289
- function Lr(e, t, n, r, o = 6) {
2290
- const l = [], i = Math.max(1, Math.round(o));
2419
+ const Ee = 1e5;
2420
+ function Jr(e, t, n, o, r = 6) {
2421
+ const l = [], i = Math.max(1, Math.round(r));
2291
2422
  for (let s = 0; s <= i; s++)
2292
- l.push({ x: s % 2 === 0 ? e : e + n, y: t + r * s / i });
2423
+ l.push({ x: s % 2 === 0 ? e : e + n, y: t + o * s / i });
2293
2424
  return l;
2294
2425
  }
2295
- function jt(e, t, n, r) {
2296
- if (r <= 0 || t.length === 0) return;
2297
- const o = Kt(t, r), l = n / 2, i = (s) => {
2298
- e.beginPath(), e.rect(-ke, -ke, 2 * ke, 2 * ke), s(), e.clip("evenodd");
2426
+ function on(e, t, n, o) {
2427
+ if (o <= 0 || t.length === 0) return;
2428
+ const r = It(t, o), l = n / 2, i = (s) => {
2429
+ e.beginPath(), e.rect(-Ee, -Ee, 2 * Ee, 2 * Ee), s(), e.clip("evenodd");
2299
2430
  };
2300
- for (const s of o)
2431
+ for (const s of r)
2301
2432
  i(() => {
2302
2433
  e.moveTo(s.x + l, s.y), e.arc(s.x, s.y, l, 0, Math.PI * 2);
2303
2434
  });
2304
- for (let s = 1; s < o.length; s++) {
2305
- const h = o[s - 1], a = o[s], f = Math.hypot(a.x - h.x, a.y - h.y);
2435
+ for (let s = 1; s < r.length; s++) {
2436
+ const a = r[s - 1], h = r[s], f = Math.hypot(h.x - a.x, h.y - a.y);
2306
2437
  if (f === 0) continue;
2307
- const u = -(a.y - h.y) / f * l, p = (a.x - h.x) / f * l;
2438
+ const g = -(h.y - a.y) / f * l, p = (h.x - a.x) / f * l;
2308
2439
  i(() => {
2309
- e.moveTo(h.x + u, h.y + p), e.lineTo(a.x + u, a.y + p), e.lineTo(a.x - u, a.y - p), e.lineTo(h.x - u, h.y - p), e.closePath();
2440
+ e.moveTo(a.x + g, a.y + p), e.lineTo(h.x + g, h.y + p), e.lineTo(h.x - g, h.y - p), e.lineTo(a.x - g, a.y - p), e.closePath();
2310
2441
  });
2311
2442
  }
2312
2443
  }
2313
- function Nr(e, t, n, r, o) {
2314
- e.save(), jt(e, t, n, r), o(), e.restore();
2444
+ function Zr(e, t, n, o, r) {
2445
+ e.save(), on(e, t, n, o), r(), e.restore();
2315
2446
  }
2316
- function Cr(e, t) {
2317
- const n = t.width ?? 40, r = t.hand === !0 ? {} : t.hand || void 0, o = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
2447
+ function jr(e, t) {
2448
+ const n = t.width ?? 40, o = t.hand === !0 ? {} : t.hand || void 0, r = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
2318
2449
  return {
2319
2450
  ...e,
2320
2451
  props: { ...e.props, erase: 0 },
2321
2452
  draw(l, i, s) {
2322
- const h = Number(i.props?.erase ?? 0);
2323
- if (l.save(), jt(l, t.path, n, h), e.draw(l, i, s), l.restore(), !o || h <= 0 || h >= 1) return;
2324
- const a = tt(t.path, h);
2325
- r ? Jt(l, a, { ...r, tool: "eraser" }) : zt(l, a, o);
2453
+ const a = Number(i.props?.erase ?? 0);
2454
+ if (l.save(), on(l, t.path, n, a), e.draw(l, i, s), l.restore(), !r || a <= 0 || a >= 1) return;
2455
+ const h = rt(t.path, a);
2456
+ o ? tn(l, h, { ...o, tool: "eraser" }) : Vt(l, h, r);
2326
2457
  }
2327
2458
  };
2328
2459
  }
2329
2460
  const oe = (e) => e * Math.PI / 180;
2330
- function Qt([e, t, n], r) {
2331
- const o = Math.cos(r), l = Math.sin(r);
2332
- return [e, t * o + n * l, -t * l + n * o];
2461
+ function rn([e, t, n], o) {
2462
+ const r = Math.cos(o), l = Math.sin(o);
2463
+ return [e, t * r + n * l, -t * l + n * r];
2333
2464
  }
2334
- function Vt([e, t, n], r) {
2335
- const o = Math.cos(r), l = Math.sin(r);
2336
- return [e * o - t * l, e * l + t * o, n];
2465
+ function ln([e, t, n], o) {
2466
+ const r = Math.cos(o), l = Math.sin(o);
2467
+ return [e * r - t * l, e * l + t * r, n];
2337
2468
  }
2338
- function pe([e, t, n], r) {
2339
- const o = Math.cos(r), l = Math.sin(r);
2340
- return [e * o + n * l, t, -e * l + n * o];
2469
+ function me([e, t, n], o) {
2470
+ const r = Math.cos(o), l = Math.sin(o);
2471
+ return [e * r + n * l, t, -e * l + n * r];
2341
2472
  }
2342
- const Ce = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], vt = (e, t) => [e[0] * t, e[1] * t, e[2] * t], xe = (e, t) => Vt(Qt(e, t.swing), t.spread);
2343
- function De(e, t) {
2344
- const n = pe(e, t);
2473
+ const Xe = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Pt = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Ae = (e, t) => ln(rn(e, t.swing), t.spread);
2474
+ function qe(e, t) {
2475
+ const n = me(e, t);
2345
2476
  return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2346
2477
  }
2347
- function ht(e, t, n) {
2348
- const r = n.height, o = oe(90 * (t.turn ?? 0)), i = [0, e.hipHeight * r * (e.boneScale?.(t, null) ?? 1), 0], s = {};
2478
+ function ct(e, t, n) {
2479
+ const o = n.height, r = oe(90 * (t.turn ?? 0)), i = [0, e.hipHeight * o * (e.boneScale?.(t, null) ?? 1), 0], s = {};
2349
2480
  for (const y of e.chains) {
2350
2481
  const x = y.parent ? s[y.parent] : void 0;
2351
2482
  if (y.parent && !x) throw new Error(`body plan ${e.id}: chain ${y.id} comes before its parent ${y.parent}`);
2352
- const O = y.at ?? (x ? x.joints3.length - 1 : 0), K = x ? x.joints3[O] : i, P = x ? x.frames[Math.max(0, O - 1)] : { swing: 0, spread: 0 }, $ = y.offset ? Ce(K, xe(vt(y.offset, r), P)) : K, B = y.side ?? 1, F = e.boneScale?.(t, y) ?? 1, C = e.angles(t, y), L = [$], Q = [];
2483
+ const O = y.at ?? (x ? x.joints3.length - 1 : 0), K = x ? x.joints3[O] : i, P = x ? x.frames[Math.max(0, O - 1)] : { swing: 0, spread: 0 }, B = y.offset ? Xe(K, Ae(Pt(y.offset, o), P)) : K, $ = y.side ?? 1, _ = e.boneScale?.(t, y) ?? 1, C = e.angles(t, y), L = [B], Q = [];
2353
2484
  let ne = P.swing, Fe = P.spread;
2354
- y.bones.forEach((tn, ft) => {
2355
- const _e = C[ft] ?? { swing: 0, spread: 0 };
2356
- ne += oe(_e.swing), Fe += oe(_e.spread) * B, Q.push({ swing: ne, spread: Fe });
2357
- const nn = pe(xe(y.rest, { swing: ne, spread: Fe }), oe(_e.yaw ?? 0));
2358
- L.push(Ce(L[ft], vt(nn, tn.length * r * F)));
2485
+ y.bones.forEach((an, ut) => {
2486
+ const Re = C[ut] ?? { swing: 0, spread: 0 };
2487
+ ne += oe(Re.swing), Fe += oe(Re.spread) * $, Q.push({ swing: ne, spread: Fe });
2488
+ const hn = me(Ae(y.rest, { swing: ne, spread: Fe }), oe(Re.yaw ?? 0));
2489
+ L.push(Xe(L[ut], Pt(hn, an.length * o * _)));
2359
2490
  }), s[y.id] = { joints3: L, frames: Q };
2360
2491
  }
2361
- const h = s[e.head.on], a = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, f = h.frames[h.frames.length - 1], u = e.head.size / 2 * r, p = u * a.sx, c = u * a.sy, g = (y) => xe(pe(Qt(Vt(y, -oe(a.tilt)), -oe(a.nod)), oe(a.yaw)), f), d = Ce(h.joints3[h.joints3.length - 1], g([0, c, 0])), b = {};
2492
+ const a = s[e.head.on], h = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, f = a.frames[a.frames.length - 1], g = e.head.size / 2 * o, p = g * h.sx, c = g * h.sy, u = (y) => Ae(me(rn(ln(y, -oe(h.tilt)), -oe(h.nod)), oe(h.yaw)), f), d = Xe(a.joints3[a.joints3.length - 1], u([0, c, 0])), b = {};
2362
2493
  for (const y of e.chains) {
2363
- const { joints3: x, frames: O } = s[y.id], K = x.map((P) => De(P, o));
2494
+ const { joints3: x, frames: O } = s[y.id], K = x.map((P) => qe(P, r));
2364
2495
  b[y.id] = {
2365
2496
  id: y.id,
2366
2497
  joints3: x,
@@ -2369,10 +2500,10 @@ function ht(e, t, n) {
2369
2500
  depths: K.map((P) => P.depth)
2370
2501
  };
2371
2502
  }
2372
- const m = De(d, o), S = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((y) => pe(g(y), o)), k = De(i, o).point, T = oe(t.roll ?? 0), H = (y) => {
2373
- const x = y.x - k.x, O = y.y - k.y;
2374
- return { x: k.x + x * Math.cos(T) - O * Math.sin(T), y: k.y + x * Math.sin(T) + O * Math.cos(T) };
2375
- }, w = ([y, x, O]) => [y * Math.cos(T) + x * Math.sin(T), -y * Math.sin(T) + x * Math.cos(T), O];
2503
+ const m = qe(d, r), w = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((y) => me(u(y), r)), S = qe(i, r).point, M = oe(t.roll ?? 0), H = (y) => {
2504
+ const x = y.x - S.x, O = y.y - S.y;
2505
+ return { x: S.x + x * Math.cos(M) - O * Math.sin(M), y: S.y + x * Math.sin(M) + O * Math.cos(M) };
2506
+ }, k = ([y, x, O]) => [y * Math.cos(M) + x * Math.sin(M), -y * Math.sin(M) + x * Math.cos(M), O];
2376
2507
  for (const y of Object.values(b)) y.points = y.points.map(H);
2377
2508
  const E = {
2378
2509
  center: H(m.point),
@@ -2380,135 +2511,135 @@ function ht(e, t, n) {
2380
2511
  rx: p,
2381
2512
  ry: c,
2382
2513
  angle: 0,
2383
- axes: S.map(w)
2384
- }, v = E.axes[1];
2385
- E.angle = Math.atan2(v[0], v[1]);
2514
+ axes: w.map(k)
2515
+ }, T = E.axes[1];
2516
+ E.angle = Math.atan2(T[0], T[1]);
2386
2517
  const A = (y) => {
2387
- if ("head" in y) return { x: E.center.x + v[0] * c, y: E.center.y - v[1] * c };
2518
+ if ("head" in y) return { x: E.center.x + T[0] * c, y: E.center.y - T[1] * c };
2388
2519
  const x = b[y.chain];
2389
2520
  return x.points[Math.min(y.joint, x.points.length - 1)];
2390
2521
  };
2391
2522
  let I = 0;
2392
- (n.contact ?? "ground") === "ground" && (I = -Math.max(...e.contacts.map((y) => A(y).y))), I -= (t.lift ?? 0) * r;
2523
+ (n.contact ?? "ground") === "ground" && (I = -Math.max(...e.contacts.map((y) => A(y).y))), I -= (t.lift ?? 0) * o;
2393
2524
  const W = (y) => ({ x: y.x, y: y.y + I });
2394
2525
  for (const y of Object.values(b)) y.points = y.points.map(W);
2395
2526
  E.center = W(E.center);
2396
- const M = e.contacts.map((y) => ({ spec: y, point: A(y) }));
2527
+ const v = e.contacts.map((y) => ({ spec: y, point: A(y) }));
2397
2528
  return {
2398
- height: r,
2399
- view: o,
2529
+ height: o,
2530
+ view: r,
2400
2531
  chains: b,
2401
2532
  head: E,
2402
- hip: W(H(k)),
2403
- contacts: M,
2404
- groundY: Math.max(...M.map((y) => y.point.y))
2533
+ hip: W(H(S)),
2534
+ contacts: v,
2535
+ groundY: Math.max(...v.map((y) => y.point.y))
2405
2536
  };
2406
2537
  }
2407
- function en(e, [t, n, r]) {
2408
- const [o, l, i] = e.axes, s = [
2409
- o[0] * t * e.rx + l[0] * n * e.ry + i[0] * r * e.rx,
2410
- o[1] * t * e.rx + l[1] * n * e.ry + i[1] * r * e.rx,
2411
- o[2] * t * e.rx + l[2] * n * e.ry + i[2] * r * e.rx
2412
- ], h = Math.hypot(t, n, r) || 1, a = (o[2] * t + l[2] * n + i[2] * r) / h;
2413
- return { point: { x: e.center.x + s[0], y: e.center.y - s[1] }, depth: e.depth + s[2], facing: a };
2538
+ function sn(e, [t, n, o]) {
2539
+ const [r, l, i] = e.axes, s = [
2540
+ r[0] * t * e.rx + l[0] * n * e.ry + i[0] * o * e.rx,
2541
+ r[1] * t * e.rx + l[1] * n * e.ry + i[1] * o * e.rx,
2542
+ r[2] * t * e.rx + l[2] * n * e.ry + i[2] * o * e.rx
2543
+ ], a = Math.hypot(t, n, o) || 1, h = (r[2] * t + l[2] * n + i[2] * o) / a;
2544
+ return { point: { x: e.center.x + s[0], y: e.center.y - s[1] }, depth: e.depth + s[2], facing: h };
2414
2545
  }
2415
- const Se = (e) => e * 180 / Math.PI, ae = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], qe = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], ue = (e) => Math.hypot(e[0], e[1], e[2]), Ve = (e) => {
2416
- const t = ue(e) || 1;
2546
+ const He = (e) => e * 180 / Math.PI, he = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ue = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], de = (e) => Math.hypot(e[0], e[1], e[2]), nt = (e) => {
2547
+ const t = de(e) || 1;
2417
2548
  return [e[0] / t, e[1] / t, e[2] / t];
2418
- }, Ee = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2419
- function xt(e) {
2420
- const [t, n, r] = Ve(e);
2421
- return { swing: Math.asin(Math.max(-1, Math.min(1, r))), spread: Math.atan2(t, -n) };
2549
+ }, Me = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2550
+ function Wt(e) {
2551
+ const [t, n, o] = nt(e);
2552
+ return { swing: Math.asin(Math.max(-1, Math.min(1, o))), spread: Math.atan2(t, -n) };
2422
2553
  }
2423
- function nr(e, t, n, r, o) {
2554
+ function fr(e, t, n, o, r) {
2424
2555
  const l = e.chains.find((I) => I.id === n);
2425
2556
  if (!l) throw new Error(`reach: no chain ${n} in ${e.id}`);
2426
2557
  if (l.bones.length < 2 || l.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
2427
2558
  if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
2428
- const i = ht(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), s = i.chains[n], h = s.joints3[0], a = ue(ae(s.joints3[1], s.joints3[0])), f = ue(ae(s.joints3[2], s.joints3[1])), u = l.parent ? i.chains[l.parent].frames[Math.max(0, (l.at ?? i.chains[l.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, p = ae(r, h), c = Math.min(a + f - 1e-6, Math.max(Math.abs(a - f) + 1e-6, ue(p))), g = Ve(p), d = l.parent !== null, b = xe(l.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), u);
2429
- let m = ae(b, [g[0] * qe(b, g), g[1] * qe(b, g), g[2] * qe(b, g)]);
2430
- ue(m) < 1e-6 && (m = pe([1, 0, 0], 0)), m = Ve(m);
2431
- const S = (a * a + c * c - f * f) / (2 * a * c), k = Math.sqrt(Math.max(0, 1 - S * S)), T = [
2432
- h[0] + a * (S * g[0] + k * m[0]),
2433
- h[1] + a * (S * g[1] + k * m[1]),
2434
- h[2] + a * (S * g[2] + k * m[2])
2435
- ], H = [h[0] + g[0] * c, h[1] + g[1] * c, h[2] + g[2] * c], w = l.side ?? 1, E = xt(ae(T, h)), v = xt(ae(H, T)), A = [
2436
- { swing: Se(Ee(E.swing - u.swing)), spread: Se(Ee(E.spread - u.spread)) * w },
2437
- { swing: Se(Ee(v.swing - E.swing)), spread: Se(Ee(v.spread - E.spread)) * w }
2559
+ const i = ct(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: r.height, contact: "none" }), s = i.chains[n], a = s.joints3[0], h = de(he(s.joints3[1], s.joints3[0])), f = de(he(s.joints3[2], s.joints3[1])), g = l.parent ? i.chains[l.parent].frames[Math.max(0, (l.at ?? i.chains[l.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, p = he(o, a), c = Math.min(h + f - 1e-6, Math.max(Math.abs(h - f) + 1e-6, de(p))), u = nt(p), d = l.parent !== null, b = Ae(l.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), g);
2560
+ let m = he(b, [u[0] * Ue(b, u), u[1] * Ue(b, u), u[2] * Ue(b, u)]);
2561
+ de(m) < 1e-6 && (m = me([1, 0, 0], 0)), m = nt(m);
2562
+ const w = (h * h + c * c - f * f) / (2 * h * c), S = Math.sqrt(Math.max(0, 1 - w * w)), M = [
2563
+ a[0] + h * (w * u[0] + S * m[0]),
2564
+ a[1] + h * (w * u[1] + S * m[1]),
2565
+ a[2] + h * (w * u[2] + S * m[2])
2566
+ ], H = [a[0] + u[0] * c, a[1] + u[1] * c, a[2] + u[2] * c], k = l.side ?? 1, E = Wt(he(M, a)), T = Wt(he(H, M)), A = [
2567
+ { swing: He(Me(E.swing - g.swing)), spread: He(Me(E.spread - g.spread)) * k },
2568
+ { swing: He(Me(T.swing - E.swing)), spread: He(Me(T.spread - E.spread)) * k }
2438
2569
  ];
2439
2570
  return e.withAngles(t, l, A);
2440
2571
  }
2441
- const or = 0.34, re = 0.12, j = -0.4, ee = (e, t, n) => e[t] ?? n, rr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), lr = 0.45, sr = 0.35, ir = 0.7;
2572
+ const cr = 0.34, re = 0.12, j = -0.4, ee = (e, t, n) => e[t] ?? n, gr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), ur = 0.45, dr = 0.35, pr = 0.7;
2442
2573
  function Be(e, t, n) {
2443
- const r = (c) => Math.sqrt(Math.max(0, 1 - c.x * c.x - c.y * c.y)), o = en(e, [n.x, n.y, r(n)]).facing, l = e.axes[2], i = Math.atan2(l[0], l[2]), s = Math.cos(i), h = s >= 0 ? 1 : -1, a = h * Math.max(sr, Math.abs(s)), f = h * Math.max(ir, Math.abs(s)), u = Math.cos(e.angle), p = Math.sin(e.angle);
2574
+ const o = (c) => Math.sqrt(Math.max(0, 1 - c.x * c.x - c.y * c.y)), r = sn(e, [n.x, n.y, o(n)]).facing, l = e.axes[2], i = Math.atan2(l[0], l[2]), s = Math.cos(i), a = s >= 0 ? 1 : -1, h = a * Math.max(dr, Math.abs(s)), f = a * Math.max(pr, Math.abs(s)), g = Math.cos(e.angle), p = Math.sin(e.angle);
2444
2575
  return {
2445
- facing: o,
2576
+ facing: r,
2446
2577
  points: t.map((c) => {
2447
- const g = lr * Math.sin(i) + n.x * a + (c.x - n.x) * f, d = c.y + l[1] * r(c), b = g * e.rx, m = d * e.ry;
2448
- return { x: e.center.x + b * u + m * p, y: e.center.y + b * p - m * u };
2578
+ const u = ur * Math.sin(i) + n.x * h + (c.x - n.x) * f, d = c.y + l[1] * o(c), b = u * e.rx, m = d * e.ry;
2579
+ return { x: e.center.x + b * g + m * p, y: e.center.y + b * p - m * g };
2449
2580
  })
2450
2581
  };
2451
2582
  }
2452
- const He = (e, t, n, r = 12) => Array.from({ length: r + 1 }, (o, l) => {
2453
- const i = l / r, s = 1 - i;
2583
+ const ve = (e, t, n, o = 12) => Array.from({ length: o + 1 }, (r, l) => {
2584
+ const i = l / o, s = 1 - i;
2454
2585
  return { x: s * s * e.x + 2 * s * i * t.x + i * i * n.x, y: s * s * e.y + 2 * s * i * t.y + i * i * n.y };
2455
- }), Xe = (e, t, n, r, o = 16) => Array.from({ length: o }, (l, i) => {
2456
- const s = Math.PI * 2 * i / o;
2457
- return { x: e + Math.cos(s) * n, y: t + Math.sin(s) * r };
2458
- }), At = 0.05;
2459
- function hr(e, t, n, r) {
2460
- const o = Math.max(1, Math.min(r * 0.6, 0.14 * t.rx)), l = (m, S) => Be(t, m, S).points, i = (m, S) => Be(t, [], { x: m, y: S }).facing, s = ee(n, "smile", 0), h = ee(n, "blink", 0), a = ee(n, "lookX", 0), f = ee(n, "lookY", 0), u = ee(n, "browTilt", 0);
2586
+ }), ze = (e, t, n, o, r = 16) => Array.from({ length: r }, (l, i) => {
2587
+ const s = Math.PI * 2 * i / r;
2588
+ return { x: e + Math.cos(s) * n, y: t + Math.sin(s) * o };
2589
+ }), Ot = 0.05;
2590
+ function br(e, t, n, o) {
2591
+ const r = Math.max(1, Math.min(o * 0.6, 0.14 * t.rx)), l = (m, w) => Be(t, m, w).points, i = (m, w) => Be(t, [], { x: m, y: w }).facing, s = ee(n, "smile", 0), a = ee(n, "blink", 0), h = ee(n, "lookX", 0), f = ee(n, "lookY", 0), g = ee(n, "browTilt", 0);
2461
2592
  for (const m of [1, -1]) {
2462
- const S = m === 1 ? "left" : "right", k = or * m;
2463
- if (i(k, re) < At) continue;
2464
- const T = { x: k, y: re }, H = rr(ee(n, `eye.${S}`, 1), h);
2593
+ const w = m === 1 ? "left" : "right", S = cr * m;
2594
+ if (i(S, re) < Ot) continue;
2595
+ const M = { x: S, y: re }, H = gr(ee(n, `eye.${w}`, 1), a);
2465
2596
  if (H < 0.2) {
2466
2597
  const A = s > 0.5 ? 0.12 : -0.06;
2467
- e.line(l(He({ x: k - 0.12, y: re }, { x: k, y: re + A }, { x: k + 0.12, y: re }), T), o);
2598
+ e.line(l(ve({ x: S - 0.12, y: re }, { x: S, y: re + A }, { x: S + 0.12, y: re }), M), r);
2468
2599
  } else {
2469
2600
  if (H > 1.2) {
2470
- const M = 0.13 * H;
2471
- e.shape(l(Xe(k, re, M * 0.85, M), T), "#ffffff", o);
2601
+ const v = 0.13 * H;
2602
+ e.shape(l(ze(S, re, v * 0.85, v), M), "#ffffff", r);
2472
2603
  }
2473
- const A = H > 1.2 ? 0.075 : 0.1, I = k + a * 0.08, W = re - f * 0.07;
2474
- e.shape(l(Xe(I, W, A, A * 1.1 * Math.min(H, 1)), T), e.ink, 0);
2604
+ const A = H > 1.2 ? 0.075 : 0.1, I = S + h * 0.08, W = re - f * 0.07;
2605
+ e.shape(l(ze(I, W, A, A * 1.1 * Math.min(H, 1)), M), e.ink, 0);
2475
2606
  }
2476
- const w = re + 0.3 + ee(n, `brow.${S}`, 0) * 0.14 + Math.max(0, H - 1) * 0.12, E = { x: k + m * 0.13, y: w }, v = { x: k - m * 0.13, y: w + u * 0.1 };
2477
- e.line(l([E, { x: (E.x + v.x) / 2, y: (E.y + v.y) / 2 }, v], { x: k, y: w }), o);
2607
+ const k = re + 0.3 + ee(n, `brow.${w}`, 0) * 0.14 + Math.max(0, H - 1) * 0.12, E = { x: S + m * 0.13, y: k }, T = { x: S - m * 0.13, y: k + g * 0.1 };
2608
+ e.line(l([E, { x: (E.x + T.x) / 2, y: (E.y + T.y) / 2 }, T], { x: S, y: k }), r);
2478
2609
  }
2479
2610
  const p = { x: 0, y: j };
2480
- if (i(0, j) < -At) return;
2481
- const c = 0.25 * Math.max(0.3, ee(n, "mouthWidth", 1)), g = Math.min(1, Math.max(0, ee(n, "mouth", 0)));
2482
- if (g <= 0.05) {
2483
- e.line(l(He({ x: -c, y: j }, { x: 0, y: j - s * 0.25 }, { x: c, y: j }), p), o);
2611
+ if (i(0, j) < -Ot) return;
2612
+ const c = 0.25 * Math.max(0.3, ee(n, "mouthWidth", 1)), u = Math.min(1, Math.max(0, ee(n, "mouth", 0)));
2613
+ if (u <= 0.05) {
2614
+ e.line(l(ve({ x: -c, y: j }, { x: 0, y: j - s * 0.25 }, { x: c, y: j }), p), r);
2484
2615
  return;
2485
2616
  }
2486
- const d = 0.3 * g;
2617
+ const d = 0.3 * u;
2487
2618
  let b;
2488
2619
  if (s > 0.3) {
2489
2620
  const m = j + 0.05;
2490
- b = [...He({ x: c, y: m }, { x: 0, y: j - d * 2 }, { x: -c, y: m })];
2621
+ b = [...ve({ x: c, y: m }, { x: 0, y: j - d * 2 }, { x: -c, y: m })];
2491
2622
  } else if (s < -0.3) {
2492
2623
  const m = j - d * 0.6;
2493
- b = [...He({ x: c, y: m }, { x: 0, y: j + d * 1.4 }, { x: -c, y: m })];
2624
+ b = [...ve({ x: c, y: m }, { x: 0, y: j + d * 1.4 }, { x: -c, y: m })];
2494
2625
  } else
2495
- b = Xe(0, j, c * 0.8, d);
2626
+ b = ze(0, j, c * 0.8, d);
2496
2627
  e.shape(l(b, p), e.ink, 0);
2497
2628
  }
2498
- function Dr(e = {}) {
2499
- const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", r = e.look ?? "clean", o = e.height ?? 300, l = n === "stick";
2629
+ function Qr(e = {}) {
2630
+ const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", o = e.look ?? "clean", r = e.height ?? 300, l = n === "stick";
2500
2631
  return {
2501
- plan: e.plan ?? Go({
2632
+ plan: e.plan ?? nr({
2502
2633
  headSize: e.headSize ?? (t ? 0.3 : 0.24),
2503
2634
  shoulderWidth: l ? 0 : e.shoulderWidth ?? 0.06,
2504
2635
  hipWidth: l ? 0 : e.hipWidth ?? 0.022
2505
2636
  }),
2506
2637
  figure: n,
2507
- look: r,
2508
- height: o,
2509
- lineWidth: e.lineWidth ?? o * (t ? 0.045 : 0.022),
2510
- ink: e.ink ?? (r === "pencil" ? "#2f2f33" : "#1e293b"),
2511
- skin: e.skin ?? (r === "pencil" ? "none" : "#ffffff"),
2638
+ look: o,
2639
+ height: r,
2640
+ lineWidth: e.lineWidth ?? r * (t ? 0.045 : 0.022),
2641
+ ink: e.ink ?? (o === "pencil" ? "#2f2f33" : "#1e293b"),
2642
+ skin: e.skin ?? (o === "pencil" ? "none" : "#ffffff"),
2512
2643
  seed: e.seed ?? 1,
2513
2644
  pencil: e.pencil ?? {},
2514
2645
  layers: e.layers ?? {},
@@ -2518,107 +2649,107 @@ function Dr(e = {}) {
2518
2649
  handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
2519
2650
  };
2520
2651
  }
2521
- function qr(e, t, n, r) {
2522
- const { point: o, facing: l } = en(e, [t, n, r]);
2523
- return { point: o, facing: l };
2652
+ function Vr(e, t, n, o) {
2653
+ const { point: r, facing: l } = sn(e, [t, n, o]);
2654
+ return { point: r, facing: l };
2524
2655
  }
2525
- const et = (e) => e.rest[1] < -0.5, ar = 0.3;
2526
- function fr(e, t, n) {
2527
- return e.figure === "stick" ? et(t) ? n.slice(0, 3) : n : et(t) && n.length >= 3 ? fe(n[0], n[1], n[2], ar) : n.length === 3 ? fe(n[0], n[1], n[2], 1) : n;
2656
+ const ot = (e) => e.rest[1] < -0.5, mr = 0.3;
2657
+ function yr(e, t, n) {
2658
+ return e.figure === "stick" ? ot(t) ? n.slice(0, 3) : n : ot(t) && n.length >= 3 ? fe(n[0], n[1], n[2], mr) : n.length === 3 ? fe(n[0], n[1], n[2], 1) : n;
2528
2659
  }
2529
- function at(e, t) {
2530
- const n = e.plan.id === "human" ? { ...te, ...t } : t, r = ht(e.plan, n, { height: e.height, contact: e.contact }), o = {}, l = {}, i = {}, s = 0.01 * e.height;
2660
+ function gt(e, t) {
2661
+ const n = e.plan.id === "human" ? { ...te, ...t } : t, o = ct(e.plan, n, { height: e.height, contact: e.contact }), r = {}, l = {}, i = {}, s = 0.01 * e.height;
2531
2662
  e.plan.chains.forEach((c) => {
2532
- const g = r.chains[c.id];
2533
- o[c.id] = g.points;
2534
- const d = g.depths.reduce((k, T) => k + T, 0) / g.depths.length, b = c.parent ? r.chains[c.parent] : void 0, m = b ? b.depths[c.at ?? b.depths.length - 1] : 0, S = d - m;
2535
- i[c.id] = Math.abs(S) < s ? 0 : S, l[c.id] = { points: fr(e, c, g.points), depth: d };
2536
- }), l.head = { points: [r.head.center], depth: r.head.depth }, i.head = 0;
2537
- const h = [...e.plan.chains.map((c) => c.id), "head"], a = [...h].sort((c, g) => i[c] - i[g] || h.indexOf(c) - h.indexOf(g)), f = { hip: r.hip };
2538
- for (const [c, [g, d]] of Object.entries(e.plan.landmarks ?? {})) {
2539
- const b = r.chains[g]?.points;
2663
+ const u = o.chains[c.id];
2664
+ r[c.id] = u.points;
2665
+ const d = u.depths.reduce((S, M) => S + M, 0) / u.depths.length, b = c.parent ? o.chains[c.parent] : void 0, m = b ? b.depths[c.at ?? b.depths.length - 1] : 0, w = d - m;
2666
+ i[c.id] = Math.abs(w) < s ? 0 : w, l[c.id] = { points: yr(e, c, u.points), depth: d };
2667
+ }), l.head = { points: [o.head.center], depth: o.head.depth }, i.head = 0;
2668
+ const a = [...e.plan.chains.map((c) => c.id), "head"], h = [...a].sort((c, u) => i[c] - i[u] || a.indexOf(c) - a.indexOf(u)), f = { hip: o.hip };
2669
+ for (const [c, [u, d]] of Object.entries(e.plan.landmarks ?? {})) {
2670
+ const b = o.chains[u]?.points;
2540
2671
  b && (f[c] = b[Math.min(d, b.length - 1)]);
2541
2672
  }
2542
- const u = {};
2543
- for (const [c, g] of Object.entries(f)) u[c] = g.y >= r.groundY - 0.01 * e.height;
2673
+ const g = {};
2674
+ for (const [c, u] of Object.entries(f)) g[c] = u.y >= o.groundY - 0.01 * e.height;
2544
2675
  const p = {
2545
2676
  height: e.height,
2546
2677
  lineWidth: e.lineWidth,
2547
2678
  turn: n.turn ?? 0,
2548
2679
  points: f,
2549
- chains: o,
2680
+ chains: r,
2550
2681
  parts: l,
2551
- head: r.head,
2552
- groundY: r.groundY,
2553
- grounded: u
2682
+ head: o.head,
2683
+ groundY: o.groundY,
2684
+ grounded: g
2554
2685
  };
2555
- return { skeleton: r, joints: p, order: a };
2686
+ return { skeleton: o, joints: p, order: h };
2556
2687
  }
2557
- function cr(e, t) {
2558
- return at(e, t).joints;
2688
+ function wr(e, t) {
2689
+ return gt(e, t).joints;
2559
2690
  }
2560
- function gr(e, t, n) {
2561
- const { head: r } = n;
2562
- e.guideEllipse(r.center.x, r.center.y, r.rx * 1.03, r.ry * 1.03, r.angle);
2563
- const o = Array.from({ length: 13 }, (h, a) => ({ x: 0, y: -0.95 + 1.9 * a / 12 })), l = Array.from({ length: 13 }, (h, a) => ({ x: -0.95 + 1.9 * a / 12, y: 0.12 })), i = Be(r, o, { x: 0, y: 0 });
2564
- i.facing > 0 && e.guide(i.points), e.guide(Be(r, l, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2691
+ function kr(e, t, n) {
2692
+ const { head: o } = n;
2693
+ e.guideEllipse(o.center.x, o.center.y, o.rx * 1.03, o.ry * 1.03, o.angle);
2694
+ const r = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), l = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), i = Be(o, r, { x: 0, y: 0 });
2695
+ i.facing > 0 && e.guide(i.points), e.guide(Be(o, l, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2565
2696
  const s = t.lineWidth * 0.9;
2566
- for (const h of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
2567
- const a = n.points[h];
2568
- a && e.guideEllipse(a.x, a.y, s, s, 0);
2697
+ for (const a of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
2698
+ const h = n.points[a];
2699
+ h && e.guideEllipse(h.x, h.y, s, s, 0);
2569
2700
  }
2570
2701
  }
2571
- function ur(e, t, n, r, o, l) {
2702
+ function Sr(e, t, n, o, r, l) {
2572
2703
  const i = n.lineWidth;
2573
- if (o === "head") {
2574
- const { head: c } = r, g = n.skin === "none" ? null : n.skin;
2575
- t.ellipse(c.center.x, c.center.y, c.rx, c.ry, c.angle, g, i), t.look !== "silhouette" && hr(t, c, l, i);
2704
+ if (r === "head") {
2705
+ const { head: c } = o, u = n.skin === "none" ? null : n.skin;
2706
+ t.ellipse(c.center.x, c.center.y, c.rx, c.ry, c.angle, u, i), t.look !== "silhouette" && br(t, c, l, i);
2576
2707
  return;
2577
2708
  }
2578
- const s = n.plan.chains.find((c) => c.id === o), h = r.chains[o], a = r.parts[o].points;
2709
+ const s = n.plan.chains.find((c) => c.id === r), a = o.chains[r], h = o.parts[r].points;
2579
2710
  if (n.figure === "stick") {
2580
- if (o === "neck") return;
2581
- const c = o === "spine" ? [...h, ...r.chains.neck?.slice(1) ?? []] : a;
2711
+ if (r === "neck") return;
2712
+ const c = r === "spine" ? [...a, ...o.chains.neck?.slice(1) ?? []] : h;
2582
2713
  t.line(c, i);
2583
2714
  return;
2584
2715
  }
2585
- const f = (c, g) => [s.bones[c].width[0] * i, s.bones[g].width[1] * i];
2586
- if (et(s)) {
2587
- const [c, g] = f(0, 1);
2588
- if (t.limb(a, c, g), s.bones.length >= 3)
2589
- t.limb([h[2], h[3]], s.bones[2].width[0] * i, s.bones[2].width[1] * i);
2590
- else if (n.hands === "cartoon" && o.startsWith("arm."))
2591
- pr(e, t, n, h, o.endsWith(".left") ? "left" : "right", l);
2716
+ const f = (c, u) => [s.bones[c].width[0] * i, s.bones[u].width[1] * i];
2717
+ if (ot(s)) {
2718
+ const [c, u] = f(0, 1);
2719
+ if (t.limb(h, c, u), s.bones.length >= 3)
2720
+ t.limb([a[2], a[3]], s.bones[2].width[0] * i, s.bones[2].width[1] * i);
2721
+ else if (n.hands === "cartoon" && r.startsWith("arm."))
2722
+ Hr(e, t, n, a, r.endsWith(".left") ? "left" : "right", l);
2592
2723
  else {
2593
- const d = h[h.length - 1];
2724
+ const d = a[a.length - 1];
2594
2725
  t.dot(d.x, d.y, i * 0.62);
2595
2726
  }
2596
2727
  return;
2597
2728
  }
2598
- if (o === "spine") {
2599
- const c = r.points["hip.left"], g = r.points["hip.right"];
2600
- c && g && Math.hypot(c.x - g.x, c.y - g.y) > 0.5 && t.limb([c, g], i * 1.3, i * 1.3);
2729
+ if (r === "spine") {
2730
+ const c = o.points["hip.left"], u = o.points["hip.right"];
2731
+ c && u && Math.hypot(c.x - u.x, c.y - u.y) > 0.5 && t.limb([c, u], i * 1.3, i * 1.3);
2601
2732
  const [d, b] = f(0, s.bones.length - 1);
2602
- t.limb(a, d, b);
2603
- const m = r.points["shoulder.left"], S = r.points["shoulder.right"];
2604
- m && S && Math.hypot(m.x - S.x, m.y - S.y) > 0.5 && t.limb(fe(m, h[h.length - 1], S, 1, 10), i * 1.15, i * 1.15);
2733
+ t.limb(h, d, b);
2734
+ const m = o.points["shoulder.left"], w = o.points["shoulder.right"];
2735
+ m && w && Math.hypot(m.x - w.x, m.y - w.y) > 0.5 && t.limb(fe(m, a[a.length - 1], w, 1, 10), i * 1.15, i * 1.15);
2605
2736
  return;
2606
2737
  }
2607
- const [u, p] = f(0, s.bones.length - 1);
2608
- t.limb(a, u, p);
2609
- }
2610
- function dr(e, t) {
2611
- const n = `hand.${t}.`, r = {};
2612
- for (const [i, s] of Object.entries(e)) i.startsWith(n) && (r[i.slice(n.length)] = s);
2613
- const o = e.turn ?? 0, l = t === "right" ? 1 - o : 1 + o;
2614
- return { ...R, ...r, turn: l + (r.turn ?? 0) };
2615
- }
2616
- function pr(e, t, n, r, o, l) {
2617
- const i = r[r.length - 1], s = r[r.length - 2], h = Math.atan2(i.x - s.x, -(i.y - s.y)) * 180 / Math.PI;
2618
- rt(e, i, dr(l, o), {
2738
+ const [g, p] = f(0, s.bones.length - 1);
2739
+ t.limb(h, g, p);
2740
+ }
2741
+ function Er(e, t) {
2742
+ const n = `hand.${t}.`, o = {};
2743
+ for (const [i, s] of Object.entries(e)) i.startsWith(n) && (o[i.slice(n.length)] = s);
2744
+ const r = e.turn ?? 0, l = t === "right" ? 1 - r : 1 + r;
2745
+ return { ...R, ...o, turn: l + (o.turn ?? 0) };
2746
+ }
2747
+ function Hr(e, t, n, o, r, l) {
2748
+ const i = o[o.length - 1], s = o[o.length - 2], a = Math.atan2(i.x - s.x, -(i.y - s.y)) * 180 / Math.PI;
2749
+ st(e, i, Er(l, r), {
2619
2750
  size: n.handSize * n.height,
2620
- side: o,
2621
- angle: h,
2751
+ side: r,
2752
+ angle: a,
2622
2753
  pen: t,
2623
2754
  skin: n.skin === "none" ? "#ffffff" : n.skin,
2624
2755
  // A cartoon glove: three fingers and a thumb, plump enough to match the limbs.
@@ -2628,203 +2759,206 @@ function pr(e, t, n, r, o, l) {
2628
2759
  lineWidth: n.lineWidth * 0.3
2629
2760
  });
2630
2761
  }
2631
- function br(e, t, n, r = 0) {
2632
- const o = t.plan.id === "human" ? { ...te, ...n } : n, { joints: l, order: i } = at(t, o), s = Pt(e, {
2762
+ function Mr(e, t, n, o = 0) {
2763
+ const r = t.plan.id === "human" ? { ...te, ...n } : n, { joints: l, order: i } = gt(t, r), s = $t(e, {
2633
2764
  look: t.look,
2634
2765
  ink: t.ink,
2635
2766
  lineWidth: t.lineWidth,
2636
2767
  seed: t.seed,
2637
- time: r,
2768
+ time: o,
2638
2769
  pencil: t.pencil
2639
- }), h = (a) => {
2640
- a && (e.save(), a(e, l, s, r), e.restore());
2770
+ }), a = (h) => {
2771
+ h && (e.save(), h(e, l, s, o), e.restore());
2641
2772
  };
2642
- e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && gr(s, t, l), h(t.layers.behind);
2643
- for (const a of i) {
2644
- const f = t.layers.parts?.[a];
2645
- h(f?.under), ur(e, s, t, l, a, o), h(f?.over);
2773
+ e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && kr(s, t, l), a(t.layers.behind);
2774
+ for (const h of i) {
2775
+ const f = t.layers.parts?.[h];
2776
+ a(f?.under), Sr(e, s, t, l, h, r), a(f?.over);
2646
2777
  }
2647
- h(t.layers.front), e.restore();
2778
+ a(t.layers.front), e.restore();
2648
2779
  }
2649
- function Xr(e, t, n) {
2650
- const r = { ...e };
2651
- for (const [o, l] of Object.entries(t)) {
2652
- const i = e[o] ?? l;
2653
- r[o] = i + (l - i) * n;
2780
+ function el(e, t, n) {
2781
+ const o = { ...e };
2782
+ for (const [r, l] of Object.entries(t)) {
2783
+ const i = e[r] ?? l;
2784
+ o[r] = i + (l - i) * n;
2654
2785
  }
2655
- return r;
2786
+ return o;
2656
2787
  }
2657
- function Ur(e, t, n, r) {
2658
- const o = e.plan.id === "human" ? { ...te, ...t } : t;
2788
+ function tl(e, t, n, o) {
2789
+ const r = e.plan.id === "human" ? { ...te, ...t } : t;
2659
2790
  let l;
2660
- if (Array.isArray(r))
2661
- l = r;
2791
+ if (Array.isArray(o))
2792
+ l = o;
2662
2793
  else {
2663
- const { skeleton: i } = at(e, o), s = ht(e.plan, { ...o, roll: 0 }, { height: e.height, contact: "none" }), h = (o.roll ?? 0) * Math.PI / 180, a = r.x - i.hip.x, f = r.y - i.hip.y, u = s.hip.x + a * Math.cos(-h) - f * Math.sin(-h), p = s.hip.y + a * Math.sin(-h) + f * Math.cos(-h), c = Math.PI / 2 * (o.turn ?? 0), g = r.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], d = Math.cos(c), b = Math.sin(c);
2664
- l = [u * d - g * b, -p, u * b + g * d];
2794
+ const { skeleton: i } = gt(e, r), s = ct(e.plan, { ...r, roll: 0 }, { height: e.height, contact: "none" }), a = (r.roll ?? 0) * Math.PI / 180, h = o.x - i.hip.x, f = o.y - i.hip.y, g = s.hip.x + h * Math.cos(-a) - f * Math.sin(-a), p = s.hip.y + h * Math.sin(-a) + f * Math.cos(-a), c = Math.PI / 2 * (r.turn ?? 0), u = o.depth ?? i.chains[n].depths[i.chains[n].depths.length - 1], d = Math.cos(c), b = Math.sin(c);
2795
+ l = [g * d - u * b, -p, g * b + u * d];
2665
2796
  }
2666
- return nr(e.plan, o, n, l, { height: e.height });
2797
+ return fr(e.plan, r, n, l, { height: e.height });
2667
2798
  }
2668
- function zr(e) {
2669
- const { character: t } = e, n = t.height * 0.8, r = t.height, o = t.plan.id === "human" ? te : {};
2799
+ function nl(e) {
2800
+ const { character: t } = e, n = t.height * 0.8, o = t.height, r = t.plan.id === "human" ? te : {};
2670
2801
  return {
2671
2802
  type: "custom",
2672
2803
  x: e.x - n / 2,
2673
- y: e.y - r,
2804
+ y: e.y - o,
2674
2805
  width: n,
2675
- height: r,
2676
- props: { ...o, ...e.pose },
2806
+ height: o,
2807
+ props: { ...r, ...e.pose },
2677
2808
  character: t,
2678
2809
  draw(l, i, s) {
2679
- l.translate(n / 2, r), br(l, t, i.props, s);
2810
+ l.translate(n / 2, o), Mr(l, t, i.props, s);
2680
2811
  }
2681
2812
  };
2682
2813
  }
2683
- function mr(e, t, n) {
2684
- const r = (l) => ({ x: l.x + t, y: l.y + n }), o = (l) => Object.fromEntries(Object.entries(l).map(([i, s]) => [i, s.map(r)]));
2814
+ function vr(e, t, n) {
2815
+ const o = (l) => ({ x: l.x + t, y: l.y + n }), r = (l) => Object.fromEntries(Object.entries(l).map(([i, s]) => [i, s.map(o)]));
2685
2816
  return {
2686
2817
  ...e,
2687
- points: Object.fromEntries(Object.entries(e.points).map(([l, i]) => [l, r(i)])),
2688
- chains: o(e.chains),
2689
- parts: Object.fromEntries(Object.entries(e.parts).map(([l, i]) => [l, { ...i, points: i.points.map(r) }])),
2690
- head: { ...e.head, center: r(e.head.center) },
2818
+ points: Object.fromEntries(Object.entries(e.points).map(([l, i]) => [l, o(i)])),
2819
+ chains: r(e.chains),
2820
+ parts: Object.fromEntries(Object.entries(e.parts).map(([l, i]) => [l, { ...i, points: i.points.map(o) }])),
2821
+ head: { ...e.head, center: o(e.head.center) },
2691
2822
  groundY: e.groundY + n
2692
2823
  };
2693
2824
  }
2694
- function Gr(e, t, n) {
2695
- const r = e.character;
2696
- if (!r) throw new Error("characterAt: the target was not made by characterTarget");
2697
- const o = { ...e.props };
2825
+ function ol(e, t, n) {
2826
+ const o = e.character;
2827
+ if (!o) throw new Error("characterAt: the target was not made by characterTarget");
2828
+ const r = { ...e.props };
2698
2829
  let l = 0, i = 0;
2699
- for (const [h, a] of t.state?.values.get(n) ?? [])
2700
- typeof a == "number" && (h === "x" || h === "motionPathX" ? l = a : h === "y" || h === "motionPathY" ? i = a : h in o && (o[h] = a));
2701
- const s = cr(r, o);
2702
- return { pose: o, joints: mr(s, e.x + l + e.width / 2, e.y + i + e.height) };
2830
+ for (const [a, h] of t.state?.values.get(n) ?? [])
2831
+ typeof h == "number" && (a === "x" || a === "motionPathX" ? l = h : a === "y" || a === "motionPathY" ? i = h : a in r && (r[a] = h));
2832
+ const s = wr(o, r);
2833
+ return { pose: r, joints: vr(s, e.x + l + e.width / 2, e.y + i + e.height) };
2703
2834
  }
2704
- function Jr(e, t, n = te) {
2705
- const r = [];
2835
+ function rl(e, t, n = te) {
2836
+ const o = [];
2706
2837
  return t.forEach((l, i) => {
2707
- const s = i === 0 ? n : r[i - 1], h = typeof l.pose == "string" ? zo[l.pose] : void 0;
2708
- r.push(h ? { ...h, turn: s.turn ?? 0 } : { ...s, ...l.pose });
2709
- }), Object.keys(n).filter((l) => r.some((i) => (i[l] ?? n[l]) !== n[l])).map((l) => ({
2838
+ const s = i === 0 ? n : o[i - 1], a = typeof l.pose == "string" ? tr[l.pose] : void 0;
2839
+ o.push(a ? { ...a, turn: s.turn ?? 0 } : { ...s, ...l.pose });
2840
+ }), Object.keys(n).filter((l) => o.some((i) => (i[l] ?? n[l]) !== n[l])).map((l) => ({
2710
2841
  id: `${e}-${l}`,
2711
2842
  target: e,
2712
2843
  property: l,
2713
2844
  keyframes: t.map((i, s) => ({
2714
2845
  time: i.time,
2715
- value: r[s][l] ?? n[l],
2846
+ value: o[s][l] ?? n[l],
2716
2847
  ...i.easing ? { easing: i.easing } : {}
2717
2848
  }))
2718
2849
  }));
2719
2850
  }
2720
- const yr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
2721
- function Zr(e = {}) {
2722
- const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", r = (s) => s.lineWidth * 0.45, o = (s, h, a) => {
2723
- const f = s.parts[`leg.${a}`].points;
2724
- h.shape(Me(f, s.height * 0.08, s.height * 0.05), n, r(s));
2725
- }, l = (s, h) => {
2726
- const a = s.chains.spine, f = a[0], u = a[a.length - 1], p = { x: f.x - (u.x - f.x) * 0.25, y: f.y - (u.y - f.y) * 0.25 };
2727
- h.shape(Me([p, ...s.parts.spine.points], s.height * 0.15, s.height * 0.14), t, r(s));
2728
- }, i = (s, h, a) => {
2729
- const f = s.parts[`arm.${a}`].points, u = f[0], p = s.chains.spine[s.chains.spine.length - 1], g = [{ x: u.x + (p.x - u.x) * 0.45, y: u.y + (p.y - u.y) * 0.45 }, ...yr(f, 0, 0.45)], d = Me(g, s.height * 0.085, s.height * 0.06), b = g.length, m = d.slice(0, b), S = d.slice(b).reverse();
2730
- h.shape(d, t, 0);
2731
- const k = (w) => Math.hypot(w[1].x - p.x, w[1].y - p.y), [T, H] = k(m) > k(S) ? [m, S] : [S, m];
2732
- h.line(T.slice(1), r(s)), h.line(H.slice(Math.ceil(b * 0.45)), r(s)), h.line([m[b - 1], S[b - 1]], r(s));
2851
+ const Tr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
2852
+ function ll(e = {}) {
2853
+ const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", o = (s) => s.lineWidth * 0.45, r = (s, a, h) => {
2854
+ const f = s.parts[`leg.${h}`].points;
2855
+ a.shape(Te(f, s.height * 0.08, s.height * 0.05), n, o(s));
2856
+ }, l = (s, a) => {
2857
+ const h = s.chains.spine, f = h[0], g = h[h.length - 1], p = { x: f.x - (g.x - f.x) * 0.25, y: f.y - (g.y - f.y) * 0.25 };
2858
+ a.shape(Te([p, ...s.parts.spine.points], s.height * 0.15, s.height * 0.14), t, o(s));
2859
+ }, i = (s, a, h) => {
2860
+ const f = s.parts[`arm.${h}`].points, g = f[0], p = s.chains.spine[s.chains.spine.length - 1], u = [{ x: g.x + (p.x - g.x) * 0.45, y: g.y + (p.y - g.y) * 0.45 }, ...Tr(f, 0, 0.45)], d = Te(u, s.height * 0.085, s.height * 0.06), b = u.length, m = d.slice(0, b), w = d.slice(b).reverse();
2861
+ a.shape(d, t, 0);
2862
+ const S = (k) => Math.hypot(k[1].x - p.x, k[1].y - p.y), [M, H] = S(m) > S(w) ? [m, w] : [w, m];
2863
+ a.line(M.slice(1), o(s)), a.line(H.slice(Math.ceil(b * 0.45)), o(s)), a.line([m[b - 1], w[b - 1]], o(s));
2733
2864
  };
2734
2865
  return {
2735
2866
  parts: {
2736
- "leg.left": { over: (s, h, a) => o(h, a, "left") },
2737
- "leg.right": { over: (s, h, a) => o(h, a, "right") },
2738
- spine: { over: (s, h, a) => l(h, a) },
2739
- "arm.left": { over: (s, h, a) => i(h, a, "left") },
2740
- "arm.right": { over: (s, h, a) => i(h, a, "right") }
2867
+ "leg.left": { over: (s, a, h) => r(a, h, "left") },
2868
+ "leg.right": { over: (s, a, h) => r(a, h, "right") },
2869
+ spine: { over: (s, a, h) => l(a, h) },
2870
+ "arm.left": { over: (s, a, h) => i(a, h, "left") },
2871
+ "arm.right": { over: (s, a, h) => i(a, h, "right") }
2741
2872
  }
2742
2873
  };
2743
2874
  }
2744
2875
  export {
2745
- $e as DANCE_STYLES,
2876
+ ce as DANCE_STYLES,
2746
2877
  J as EXPRESSIONS,
2747
- cn as FINGERS,
2748
- it as FLIPS,
2878
+ mn as FINGERS,
2879
+ ft as FLIPS,
2749
2880
  R as HAND_REST,
2750
2881
  N as HAND_SHAPES,
2751
- $r as HUMAN_EXPRESSIONS,
2752
- zo as HUMAN_POSES,
2882
+ Xr as HUMAN_EXPRESSIONS,
2883
+ tr as HUMAN_POSES,
2753
2884
  te as HUMAN_REST,
2754
- Et as MUDRAS,
2755
- Wn as POSES,
2885
+ vt as MUDRAS,
2886
+ Fn as POSES,
2756
2887
  z as REST_POSE,
2757
- mo as applyGroove,
2758
- Or as bakeDanceTracks,
2759
- Zr as basicOutfit,
2760
- Kr as beatAt,
2761
- me as blendPose,
2762
- on as boilFrame,
2763
- Dr as character,
2764
- Gr as characterAt,
2765
- dr as characterHandPose,
2766
- cr as characterJoints,
2767
- Jr as characterPoseTracks,
2768
- zr as characterTarget,
2769
- Rr as circlePath,
2770
- jt as clipErased,
2771
- Pt as createPen,
2772
- st as danceFrame,
2773
- xr as dancePose,
2774
- yo as danceStance,
2775
- Ar as danceTaps,
2776
- Wr as danceTracks,
2777
- Pr as dancer,
2778
- rt as drawCartoonHand,
2779
- br as drawCharacter,
2780
- zt as drawEraser,
2781
- Jt as drawHand,
2782
- Qo as drawPencil,
2783
- lo as drawStickFigure,
2784
- Yr as drawnPathTarget,
2785
- ct as ellipsePoints,
2786
- Cr as erasable,
2787
- Fo as flipPose,
2788
- Ir as flipTracks,
2789
- _o as flipTravel,
2790
- _r as handAt,
2791
- Je as handJoints,
2792
- Hn as handJointsAt,
2793
- _ as handPose,
2794
- We as handProp,
2795
- Hr as headPoint,
2796
- Br as humanFieldLabel,
2797
- Go as humanPlan,
2888
+ Eo as applyGroove,
2889
+ Lr as bakeDanceTracks,
2890
+ ll as basicOutfit,
2891
+ Fr as beatAt,
2892
+ we as blendPose,
2893
+ fn as boilFrame,
2894
+ Qr as character,
2895
+ ol as characterAt,
2896
+ Er as characterHandPose,
2897
+ wr as characterJoints,
2898
+ rl as characterPoseTracks,
2899
+ nl as characterTarget,
2900
+ zr as circlePath,
2901
+ on as clipErased,
2902
+ $t as createPen,
2903
+ at as danceFrame,
2904
+ Br as dancePose,
2905
+ tt as danceStance,
2906
+ _r as danceTaps,
2907
+ Yr as danceTracks,
2908
+ Ne as danceTravel,
2909
+ To as danceTravelTrack,
2910
+ Rr as dancer,
2911
+ st as drawCartoonHand,
2912
+ Mr as drawCharacter,
2913
+ Vt as drawEraser,
2914
+ tn as drawHand,
2915
+ sr as drawPencil,
2916
+ co as drawStickFigure,
2917
+ Gr as drawnPathTarget,
2918
+ dt as ellipsePoints,
2919
+ jr as erasable,
2920
+ Do as flipPose,
2921
+ Nr as flipTracks,
2922
+ Xo as flipTravel,
2923
+ Ur as handAt,
2924
+ je as handJoints,
2925
+ Kn as handJointsAt,
2926
+ F as handPose,
2927
+ Oe as handProp,
2928
+ Wr as headPoint,
2929
+ Dr as humanFieldLabel,
2930
+ nr as humanPlan,
2798
2931
  G as humanPose,
2799
- mr as jointsInScene,
2800
- ro as jointsToScene,
2801
- po as mirrorPose,
2802
- be as mixHandPoses,
2803
- Xr as mixPoses,
2804
- Kt as partialPath,
2805
- Vr as pathLength,
2806
- tt as pointAlong,
2807
- qr as pointOnHead,
2932
+ vr as jointsInScene,
2933
+ fo as jointsToScene,
2934
+ Cr as mirrorHumanPose,
2935
+ ko as mirrorPose,
2936
+ ye as mixHandPoses,
2937
+ el as mixPoses,
2938
+ It as partialPath,
2939
+ al as pathLength,
2940
+ rt as pointAlong,
2941
+ Vr as pointOnHead,
2808
2942
  D as pose,
2809
- vr as poseTracks,
2810
- Ur as reachCharacter,
2811
- Xt as resolveStickFrame,
2812
- so as resolveStickPose,
2943
+ $r as poseTracks,
2944
+ tl as reachCharacter,
2945
+ Jt as resolveStickFrame,
2946
+ go as resolveStickPose,
2813
2947
  ie as rotateAbout,
2814
- Ut as routineBeats,
2948
+ ht as routineBeats,
2815
2949
  fe as rubberLimb,
2816
- Lr as scrubPath,
2817
- Er as seatHeight,
2818
- Ue as sketchPen,
2819
- Tr as stickFigureAt,
2820
- oo as stickFigureJoints,
2821
- Mr as stickFigureTarget,
2822
- Fr as stickToHuman,
2823
- Sr as strideLength,
2824
- Bn as talkingMouth,
2825
- ot as taperedLine,
2826
- Me as taperedOutline,
2827
- In as walkPose,
2828
- Nr as withErased,
2829
- Ot as withExpression
2950
+ Jr as scrubPath,
2951
+ Pr as seatHeight,
2952
+ Ge as sketchPen,
2953
+ Ir as stickFigureAt,
2954
+ ho as stickFigureJoints,
2955
+ Or as stickFigureTarget,
2956
+ qr as stickToHuman,
2957
+ Kr as strideLength,
2958
+ Ln as talkingMouth,
2959
+ lt as taperedLine,
2960
+ Te as taperedOutline,
2961
+ Yn as walkPose,
2962
+ Zr as withErased,
2963
+ _t as withExpression
2830
2964
  };