@algorisys/tinyfly 0.79.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,37 +1,428 @@
1
- import { s as Ht, b as We, p as ae, c as Ut } from "./sketch-CA8ZXhxI.js";
2
- import { a as Fo } from "./sketch-CA8ZXhxI.js";
3
- import { createRandom as $e, hashSeed as Re } from "@algorisys/tinyfly";
4
- function yt(t, e, n) {
5
- const o = t.length;
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
6
  if (o < 2) return [];
7
- const s = [], r = [], h = (i) => e + (n - e) * i / (o - 1);
8
- return t.forEach((i, l) => {
9
- const a = t[Math.max(0, l - 1)], f = t[Math.min(o - 1, l + 1)], g = Math.hypot(f.x - a.x, f.y - a.y) || 1, m = h(l) / 2, c = -(f.y - a.y) / g * m, d = (f.x - a.x) / g * m;
10
- s.push({ x: i.x + c, y: i.y + d }), r.push({ x: i.x - c, y: i.y - d });
11
- }), [...s, ...r.reverse()];
12
- }
13
- function Xt(t, e, n, o) {
14
- const s = e.length;
15
- if (s < 2) return;
16
- const r = yt(e, n, o), h = (i) => n + (o - n) * i / (s - 1);
17
- t.beginPath(), t.moveTo(r[0].x, r[0].y);
18
- for (const i of r.slice(1)) t.lineTo(i.x, i.y);
19
- t.closePath(), t.fill(), e.forEach((i, l) => {
20
- l !== 0 && l !== s - 1 && s > 3 || (t.beginPath(), t.arc(i.x, i.y, h(l) / 2, 0, Math.PI * 2), t.fill());
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
+ e.beginPath(), e.moveTo(l[0].x, l[0].y);
18
+ for (const s of l.slice(1)) e.lineTo(s.x, s.y);
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 tt(t, e, n, o, s = 16) {
24
- const r = { x: 2 * e.x - (t.x + n.x) / 2, y: 2 * e.y - (t.y + n.y) / 2 }, h = [];
25
- for (let i = 0; i <= s; i++) {
26
- const l = i / s, a = l < 0.5 ? { x: t.x + (e.x - t.x) * 2 * l, y: t.y + (e.y - t.y) * 2 * l } : { x: e.x + (n.x - e.x) * (2 * l - 1), y: e.y + (n.y - e.y) * (2 * l - 1) }, f = 1 - l, g = {
27
- x: f * f * t.x + 2 * f * l * r.x + l * l * n.x,
28
- y: f * f * t.y + 2 * f * l * r.y + l * l * n.y
23
+ function fe(e, t, n, o, r = 16) {
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 <= 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
- h.push({ x: a.x + (g.x - a.x) * o, y: a.y + (g.y - a.y) * o });
30
+ i.push({ x: h.x + (g.x - h.x) * o, y: h.y + (g.y - h.y) * o });
31
+ }
32
+ return i;
33
+ }
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
+ });
40
+ }
41
+ function $t(e, t) {
42
+ return t.look === "pencil" ? bn(e, t) : un(e, t.ink, t.look);
43
+ }
44
+ function Ke(e, t, n = !1) {
45
+ e.beginPath(), e.moveTo(t[0].x, t[0].y);
46
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
47
+ n && e.closePath();
48
+ }
49
+ function un(e, t, n) {
50
+ const o = n === "silhouette", r = o ? 1.25 : 1;
51
+ return {
52
+ look: n,
53
+ ink: t,
54
+ limb(l, i, s) {
55
+ e.fillStyle = t, lt(e, l, i * r, s * r);
56
+ },
57
+ line(l, i) {
58
+ l.length < 2 || (e.strokeStyle = t, e.lineWidth = i * r, e.lineCap = "round", e.lineJoin = "round", Ke(e, l), e.stroke());
59
+ },
60
+ shape(l, i, s) {
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
+ },
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
+ },
66
+ dot(l, i, s) {
67
+ e.fillStyle = t, e.beginPath(), e.arc(l, i, s * r, 0, Math.PI * 2), e.fill();
68
+ },
69
+ guide() {
70
+ },
71
+ guideEllipse() {
72
+ }
73
+ };
74
+ }
75
+ function dn(e, t) {
76
+ const n = [e[0]];
77
+ let o = 0;
78
+ for (let i = 1; i < e.length; i++) {
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
+ }
85
+ o = h - (f - t);
86
+ }
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
+ }
90
+ function pn(e, t) {
91
+ const n = e.length;
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
+ });
96
+ }
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
+ phase: e.next() * Math.PI * 2,
101
+ amount: 0.5 + e.next() * 0.5
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
+ }
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
+ if (m.next() < s) {
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
+ }
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
+ for (let H = 0; H < l; H++) {
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
+ });
134
+ }
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
+ };
139
+ return {
140
+ look: "pencil",
141
+ ink: o,
142
+ limb(u, d, b) {
143
+ p(u, (m) => d + (b - d) * m);
144
+ },
145
+ line(u, d) {
146
+ p(u, () => d);
147
+ },
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
+ },
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
+ },
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
+ },
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
+ },
162
+ guideEllipse(u, d, b, m, w) {
163
+ if (n.construction === !1) return;
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
+ }
167
+ };
168
+ }
169
+ const mn = ["thumb", "index", "middle", "ring", "pinky"], R = {
170
+ "thumb.curl": 0.15,
171
+ "thumb.across": 0.15,
172
+ "index.curl": 0.12,
173
+ "middle.curl": 0.16,
174
+ "ring.curl": 0.2,
175
+ "pinky.curl": 0.25,
176
+ spread: 0.25,
177
+ turn: 0,
178
+ bend: 0,
179
+ tilt: 0,
180
+ roll: 0
181
+ };
182
+ function F(e = {}) {
183
+ return { ...R, ...e };
184
+ }
185
+ const q = (e, t, n, o, r) => ({
186
+ "thumb.curl": e,
187
+ "index.curl": t,
188
+ "middle.curl": n,
189
+ "ring.curl": o,
190
+ "pinky.curl": r
191
+ }), N = {
192
+ relaxed: R,
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
+ /** The fist on its side, knuckles toward the viewer, the thumb up */
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
+ /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
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
+ /** Holding a handle, a cup or a bar: every finger wrapped round it */
208
+ hold: F({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
+ };
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
+ }
216
+ return o;
217
+ }
218
+ const yn = {
219
+ index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
220
+ middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
221
+ ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
222
+ pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
223
+ }, wn = {
224
+ index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
225
+ middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
226
+ pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
227
+ }, V = {
228
+ base: [-0.11, 0.1, -0.05],
229
+ bones: [0.2, 0.15, 0.12],
230
+ widths: [0.2, 0.145, 0.135],
231
+ /** Where the thumb points with `across` 0 and 1 */
232
+ out: [-0.7, 0.68, -0.22],
233
+ across: [0.35, 0.5, -0.8]
234
+ }, kn = [82, 100, 62], Sn = [48, 72], En = 3, Hn = 13, Mn = 0.035, vn = -0.075, Tn = [
235
+ [-0.17, 0],
236
+ [-0.215, 0.12],
237
+ [-0.235, 0.26],
238
+ [-0.225, 0.4],
239
+ [-0.185, 0.49],
240
+ [-0.075, 0.525],
241
+ [0.05, 0.51],
242
+ [0.16, 0.465],
243
+ [0.215, 0.4],
244
+ [0.225, 0.26],
245
+ [0.2, 0.1],
246
+ [0.16, 0]
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
+ const t = Math.hypot(e[0], e[1], e[2]) || 1;
249
+ return [e[0] / t, e[1] / t, e[2] / t];
250
+ };
251
+ function ie(e, t, n) {
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
+ return [
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
+ ];
258
+ }
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
+ let s = 0;
263
+ e.bones.forEach((f, g) => {
264
+ s += le(kn[g] * t), i.push(Je(i[g], xe(ie(r, l, -s), f)));
265
+ });
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
+ }
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
+ V.bones.forEach((p, c) => {
273
+ c > 0 && (h += le(Sn[c - 1] * e)), a.push(Je(a[c], xe(ie(l, i, h), p)));
274
+ });
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
+ return { x: O * d - K * b, y: O * b + K * d };
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
+ }
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
+ nail: O[2],
304
+ back: H(O)
305
+ };
306
+ }
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
+ return {
309
+ size: o,
310
+ side: r,
311
+ wrist: { x: 0, y: 0 },
312
+ palm: I,
313
+ palmDepth: W,
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
+ };
319
+ }
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
+ }
326
+ function Pn(e) {
327
+ const t = [...e].sort((l, i) => l.x - i.x || l.y - i.y);
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), o = [];
330
+ for (const l of t) {
331
+ for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], l) <= 0; ) o.pop();
332
+ o.push(l);
333
+ }
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
+ }
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
+ ink: i,
346
+ lineWidth: s,
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
+ {
352
+ depth: l.palmDepth,
353
+ draw: () => In(a, l, h, s)
354
+ }
355
+ ];
356
+ for (const p of Object.values(l.fingers)) {
357
+ const c = p.depths.reduce((u, d) => u + d, 0) / p.depths.length;
358
+ g.push({
359
+ depth: c,
360
+ draw: () => $n(e, a, p, h, s, f)
361
+ });
362
+ }
363
+ if (o.prop) {
364
+ const p = o.prop;
365
+ g.push({ depth: p.depth, draw: () => p.draw(a) });
366
+ }
367
+ e.save(), e.lineCap = "round", e.lineJoin = "round";
368
+ for (const p of [...g].sort((c, u) => c.depth - u.depth)) p.draw();
369
+ return e.restore(), l;
370
+ }
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
+ for (const [l, i] of Object.entries(t.fingers)) {
375
+ const s = t.curls[l] ?? 0;
376
+ if (l === "thumb" || s < 0.5) continue;
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
+ });
381
+ e.line(p, o * 0.6);
382
+ }
383
+ }
384
+ if (t.palmFacing > 0.45 && e.look !== "silhouette") {
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);
31
390
  }
32
- return h;
33
391
  }
34
- const et = {
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
+ if (e.save(), t.look !== "silhouette") {
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
+ }
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
+ x: 0,
402
+ y: -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
+ };
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
+ }
409
+ function Bn(e, t) {
410
+ let n = e;
411
+ for (let o = 0; o < t; o++) {
412
+ if (n.length < 3) return n;
413
+ const r = [n[0]];
414
+ for (let l = 0; l < n.length - 1; l++) {
415
+ const i = n[l], s = n[l + 1];
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
+ }
418
+ r.push(n[n.length - 1]), n = r;
419
+ }
420
+ return n;
421
+ }
422
+ const _n = (e) => {
423
+ const t = Math.hypot(e.x, e.y);
424
+ return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
425
+ }, z = {
35
426
  lean: 0,
36
427
  headTilt: 0,
37
428
  leftShoulder: 18,
@@ -42,6 +433,12 @@ const et = {
42
433
  rightHip: 8,
43
434
  leftKnee: 0,
44
435
  rightKnee: 0,
436
+ leftWrist: 0,
437
+ rightWrist: 0,
438
+ leftAnkle: 0,
439
+ rightAnkle: 0,
440
+ leftFootOut: 0,
441
+ rightFootOut: 0,
45
442
  mouth: 0,
46
443
  smile: 0.6,
47
444
  mouthWidth: 1,
@@ -55,12 +452,14 @@ const et = {
55
452
  lookY: 0,
56
453
  stretch: 1,
57
454
  turn: 0,
58
- sit: 0
455
+ sit: 0,
456
+ spin: 0,
457
+ rise: 0
59
458
  };
60
- function L(t) {
61
- return { ...et, ...t };
459
+ function D(e) {
460
+ return { ...z, ...e };
62
461
  }
63
- const ce = {
462
+ const Bt = {
64
463
  mouth: 0,
65
464
  smile: 0,
66
465
  mouthWidth: 1,
@@ -71,1090 +470,1537 @@ const ce = {
71
470
  browTilt: 0,
72
471
  lookX: 0,
73
472
  lookY: 0
74
- }, $ = (t) => ({ ...ce, ...t }), X = {
75
- neutral: ce,
76
- happy: $({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
77
- joyful: $({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
78
- sad: $({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
79
- crying: $({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
80
- surprised: $({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
81
- shocked: $({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
82
- angry: $({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
83
- furious: $({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
84
- worried: $({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
85
- scared: $({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
86
- confused: $({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
87
- skeptical: $({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
88
- thinking: $({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
89
- sleepy: $({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
90
- disgusted: $({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
91
- smug: $({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
92
- wink: $({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
473
+ }, Y = (e) => ({ ...Bt, ...e }), J = {
474
+ neutral: Bt,
475
+ happy: Y({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
476
+ joyful: Y({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
477
+ sad: Y({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
478
+ crying: Y({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
479
+ surprised: Y({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
480
+ shocked: Y({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
481
+ angry: Y({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
482
+ furious: Y({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
483
+ worried: Y({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
484
+ scared: Y({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
485
+ confused: Y({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
486
+ skeptical: Y({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
487
+ thinking: Y({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
488
+ sleepy: Y({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
489
+ disgusted: Y({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
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
+ wink: Y({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
93
492
  };
94
- function Be(t, e) {
95
- return { ...t, ...typeof e == "string" ? X[e] : e };
96
- }
97
- const Ye = {
98
- rest: et,
99
- wave: L({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...X.happy }),
100
- cheer: L({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...X.joyful }),
101
- shrug: L({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...X.confused, lookX: 0, lookY: 0 }),
102
- point: L({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
493
+ function _t(e, t) {
494
+ return { ...e, ...typeof t == "string" ? J[t] : t };
495
+ }
496
+ const Fn = {
497
+ rest: z,
498
+ wave: D({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...J.happy }),
499
+ cheer: D({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...J.joyful }),
500
+ shrug: D({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...J.confused, lookX: 0, lookY: 0 }),
501
+ point: D({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
103
502
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
104
- think: L({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...X.thinking }),
105
- handsOnHips: L({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
106
- sad: L({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...X.sad }),
107
- surprised: L({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...X.surprised }),
503
+ think: D({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...J.thinking }),
504
+ handsOnHips: D({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
505
+ sad: D({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...J.sad }),
506
+ surprised: D({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...J.surprised }),
108
507
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
109
- crouch: L({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
508
+ crouch: D({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
110
509
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
111
510
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
112
- sit: L({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
113
- jump: L({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...X.joyful })
114
- }, fe = Object.keys(et);
115
- function Le(t, e, n) {
116
- const o = { ...t };
117
- for (const s of fe) o[s] = t[s] + (e[s] - t[s]) * n;
511
+ sit: D({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
512
+ jump: D({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...J.joyful }),
513
+ // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
514
+ // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
515
+ sideSplit: D({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...J.happy }),
516
+ // Front split, in profile: the left leg forward (+x), the right leg back.
517
+ frontSplit: D({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...J.happy })
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;
118
522
  return o;
119
523
  }
120
- const Wt = 24, Gt = 4, Jt = 28, Fe = 40;
121
- function Ne(t, e = et, n = 1) {
122
- const o = Math.sin(t * Math.PI * 2) * n, s = Math.cos(t * Math.PI * 2) * n, r = (a) => a <= Fe, h = (a) => r(a) ? 22 * o : a, i = r(e.leftShoulder) ? e.leftElbow - Jt * Math.max(0, -o) : e.leftElbow, l = r(e.rightShoulder) ? e.rightElbow + Jt * Math.max(0, o) : e.rightElbow;
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;
123
527
  return {
124
- ...e,
528
+ ...t,
125
529
  // Lean into the walk, and keep the head a little more level than the body.
126
- lean: e.lean + Gt * n,
127
- headTilt: e.headTilt - Gt * 0.5 * n,
128
- leftElbow: i,
129
- rightElbow: l,
530
+ lean: t.lean + yt * n,
531
+ headTilt: t.headTilt - yt * 0.5 * n,
532
+ leftElbow: s,
533
+ rightElbow: a,
130
534
  // Left foot forward while swing > 0, right foot back; then the other way.
131
- leftHip: -Wt * o,
132
- rightHip: -Wt * o,
535
+ leftHip: -Qe * o,
536
+ rightHip: -Qe * o,
133
537
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
134
538
  // knee folds toward the centre, which is backward only for the right leg.
135
- leftKnee: -30 * Math.max(0, s),
136
- rightKnee: 30 * Math.max(0, -s),
539
+ leftKnee: -30 * Math.max(0, r),
540
+ rightKnee: 30 * Math.max(0, -r),
137
541
  // Arms swing against the legs: left arm back while the left foot is forward.
138
- leftShoulder: h(e.leftShoulder),
139
- rightShoulder: h(e.rightShoulder)
542
+ leftShoulder: i(t.leftShoulder),
543
+ rightShoulder: i(t.rightShoulder)
140
544
  };
141
545
  }
142
- function go(t, e = 1) {
143
- return 4 * (($t + wt) * t) * Math.sin(Wt * e * Math.PI / 180);
546
+ function Kr(e, t = 1) {
547
+ return 4 * ((Ve + Pe) * e) * Math.sin(Qe * t * Math.PI / 180);
144
548
  }
145
- function Ce(t) {
146
- const e = Math.abs(Math.sin(t / 65)), n = 0.55 + 0.45 * Math.sin(t / 310);
147
- return e * n;
549
+ function Ln(e) {
550
+ const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
551
+ return t * n;
148
552
  }
149
- const de = 0.12, zt = 0.46, Ue = 1 - 2 * de, Xe = 0.1, De = 0.21, qe = 0.19, $t = 0.24, wt = 0.22, ue = 0.12, Ke = 0.14, ge = 0.33, jt = 0.7, Zt = 0.3, Ge = 0.35, Je = [1.7, 1.05], ze = [1.3, 0.75], Qt = [1.45, 0.85], je = [1.15, 0.75], Vt = 0.06, Ze = 0.7, Qe = 0.65, Ve = 0.3, tn = 0.02, en = 0.012, nn = 12, on = 0.25, ct = 90, sn = 0.25, rn = 0.01, V = (t) => Math.min(1, Math.max(0, t ?? 0));
150
- function yo(t, e = 1) {
151
- return wt * t * e;
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;
152
556
  }
153
- const Rt = -0.12, ye = 0.4, D = (t) => t * Math.PI / 180, ln = (t, e) => ({ x: e * Math.sin(D(t)), y: Math.cos(D(t)) }), me = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), pe = (t, e, n, o) => t - 0.3 * e - n * 0.14 * e - Math.max(0, o - 1) * 0.12 * e;
154
- function hn(t, e, n, o, s, r) {
155
- const h = Math.max(1, Math.min(r * 0.6, Ke * n)), i = V(e.turn), l = (ue + ge * i) * n, a = o + Rt * n, f = l + e.lookX * 0.08 * n, g = e.lookY * 0.07 * n, m = [
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 = [
156
560
  // The left eye is on the far side; turning closes it up more than the near one.
157
- { x: -0.34 * n * (1 - jt * i), squeeze: 1 - jt * i, open: e.leftEye, brow: e.leftBrow, side: -1 },
158
- { x: 0.34 * n * (1 - Zt * i), squeeze: 1 - Zt * i, open: e.rightEye, brow: e.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 }
159
563
  ];
160
- t.fillStyle = s, t.strokeStyle = s, t.lineWidth = h;
161
- for (const p of m) {
162
- const x = me(p.open, e.blink);
163
- if (x < 0.2) {
164
- const T = e.smile > 0.5 ? -0.12 * n : 0.06 * n;
165
- t.beginPath(), t.moveTo(p.x + l - 0.12 * n, a), t.quadraticCurveTo(p.x + l, a + T, p.x + l + 0.12 * n, a), t.stroke();
564
+ e.fillStyle = r, e.strokeStyle = r, e.lineWidth = i;
565
+ for (const m of p) {
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();
166
570
  } else {
167
- if (x > 1.2) {
168
- const P = 0.13 * n * x;
169
- t.beginPath(), t.ellipse(p.x + l, a, P * 0.85, P, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = s;
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;
170
574
  }
171
- const T = x > 1.2 ? 0.075 * n : 0.1 * n;
172
- t.beginPath(), t.ellipse(p.x + f, a + g, T, T * 1.1 * Math.min(x, 1), 0, 0, Math.PI * 2), t.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();
173
577
  }
174
- const E = pe(a, n, p.brow, x), b = p.x + l - p.side * 0.13 * n * p.squeeze, M = p.x + l + p.side * 0.13 * n * p.squeeze;
175
- t.beginPath(), t.moveTo(M, E), t.lineTo(b, E - e.browTilt * 0.1 * n), t.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();
176
580
  }
177
- const c = o + ye * n, d = 0.25 * n * Math.max(0.3, e.mouthWidth) * (1 - Ge * i), u = Math.min(1, Math.max(0, e.mouth));
178
- if (t.beginPath(), u <= 0.05) {
179
- t.moveTo(l - d, c), t.quadraticCurveTo(l, c + e.smile * 0.25 * n, l + d, c), t.stroke();
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
+ if (e.beginPath(), d <= 0.05) {
583
+ e.moveTo(a - u, c), e.quadraticCurveTo(a, c + t.smile * 0.25 * n, a + u, c), e.stroke();
180
584
  return;
181
585
  }
182
- const y = 0.3 * n * u;
183
- e.smile > 0.3 ? (t.moveTo(l - d, c - 0.05 * n), t.lineTo(l + d, c - 0.05 * n), t.quadraticCurveTo(l, c + y * 2, l - d, c - 0.05 * n)) : e.smile < -0.3 ? (t.moveTo(l - d, c + y * 0.6), t.lineTo(l + d, c + y * 0.6), t.quadraticCurveTo(l, c - y * 1.4, l - d, c + y * 0.6)) : t.ellipse(l, c, d * 0.8, y, 0, 0, Math.PI * 2), t.fill();
184
- }
185
- function we(t, e) {
186
- const n = e.height ?? 300, o = Math.min(3, Math.max(0.3, t.stretch ?? 1)), s = Math.sqrt(o), r = (e.headSize ?? 2 * de) / 2, h = e.headSize === void 0 ? Ue : 1 - 2 * r, i = r * n, l = V(t.sit), a = t.leftHip + (-ct - t.leftHip) * l, f = t.leftKnee + (-ct - t.leftKnee) * l, g = t.rightHip + (ct - t.rightHip) * l, m = t.rightKnee + (ct - t.rightKnee) * l, c = e.classic === !0, d = V(t.turn), u = (k, w, S) => {
187
- const v = D(w - S) / 2, A = d + (1 - d) * k * Ze;
188
- return c ? { x: 0, y: 0 } : { x: Math.cos(v) * Vt * A, y: Math.abs(Math.sin(v)) * Vt };
189
- };
190
- let y = 0;
191
- if (l > 0 || !c) {
192
- const k = (v, A, W) => $t * Math.cos(D(A)) + wt * Math.cos(D(A - W)) + u(v, A, W).y, w = Math.max(k(-1, a, f), k(1, g, m)), S = c ? Math.min(1, l / sn) : 1;
193
- y = (zt - w) * S * n * o;
586
+ const b = 0.3 * n * d;
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
+ }
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
+ }, b = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, m = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
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;
194
601
  }
195
- const p = -zt * n * o + y, x = -h * n * o + y, E = c ? 0 : (tn * V(t.turn) + en * l) * n * o, b = E === 0 ? [{ x: 0, y: p }, { x: 0, y: x }] : tt({ x: 0, y: p }, { x: -E, y: (p + x) / 2 }, { x: 0, y: x }, 1, 8), M = x + Xe * n * o, T = (e.shoulderWidth ?? 0) * n * Math.cos(d * Math.PI / 2), P = (k, w, S, v, A) => {
196
- const W = ln(S, v);
197
- return { x: k + W.x * A * n, y: w + W.y * A * n };
198
- }, I = (k, w, S) => {
199
- const v = P(0, p, w, k, $t * o);
200
- return { root: { x: 0, y: p }, joint: v, end: P(v.x, v.y, w - S, k, wt * o) };
201
- }, O = (k, w, S) => {
202
- const v = { x: k * T, y: M }, A = P(v.x, v.y, w, k, De * s);
203
- return { root: v, joint: A, end: P(A.x, A.y, w + S, k, qe * s) };
204
- }, H = { left: I(-1, a, f), right: I(1, g, m) }, _ = (k, w, S, v) => {
205
- const A = u(k, S, v);
206
- return { x: w.end.x + A.x * n * o, y: w.end.y + A.y * n * 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
+ left: W(-1, e.leftShoulder, e.leftElbow),
616
+ right: W(1, e.rightShoulder, e.rightElbow)
207
617
  };
208
618
  return {
209
619
  height: n,
210
- facing: (e.facing ?? 1) < 0 ? -1 : 1,
620
+ facing: (t.facing ?? 1) < 0 ? -1 : 1,
211
621
  stretch: o,
212
- lineWidth: e.lineWidth ?? n * 0.025,
213
- rubber: Math.min(1, Math.max(c ? 0 : Ve, e.rubber ?? 0)),
214
- r: i,
622
+ lineWidth: t.lineWidth ?? n * 0.025,
623
+ rubber: Math.min(1, Math.max(c ? 0 : Qn, t.rubber ?? 0)),
624
+ r: s,
215
625
  // The head keeps its area: taller and narrower when stretched.
216
- headRx: i / Math.sqrt(o),
217
- headRy: i * Math.sqrt(o),
218
- hipY: p,
219
- neckY: x,
220
- drop: y,
221
- lean: c ? t.lean : t.lean + nn * Math.sin(Math.PI * l),
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),
222
632
  classic: c,
223
- legs: H,
224
- toes: { left: _(-1, H.left, a, f), right: _(1, H.right, g, m) },
225
- spine: b,
226
- arms: {
227
- left: O(-1, t.leftShoulder, t.leftElbow),
228
- right: O(1, t.rightShoulder, t.rightElbow)
633
+ legs: v,
634
+ toes: {
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
+ },
638
+ spine: k,
639
+ arms: O,
640
+ handTips: {
641
+ left: x(-1, O.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
642
+ right: x(1, O.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
229
643
  }
230
644
  };
231
645
  }
232
- const rt = (t, e) => e === 0 ? [t.root, t.joint, t.end] : tt(t.root, t.joint, t.end, e);
233
- function Bt(t, e, n) {
234
- const o = Math.cos(n), s = Math.sin(n), r = t.x - e.x, h = t.y - e.y;
235
- return { x: e.x + r * o - h * s, y: e.y + r * s + h * o };
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
+ }
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
+ }
655
+ function Gt(e, t, n) {
656
+ return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Z(t), lift: n * e.height };
657
+ }
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
+ return { x: c.x, y: c.y - i };
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
+ return {
664
+ ...e,
665
+ hip: s(e.hip),
666
+ neck: s(e.neck),
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
+ feetY: f,
675
+ grounded: { left: h.left >= f - g, right: h.right >= f - g },
676
+ handAngle: { left: e.handAngle.left + l, right: e.handAngle.right + l },
677
+ limbs: {
678
+ leftArm: e.limbs.leftArm.map(s),
679
+ rightArm: e.limbs.rightArm.map(s),
680
+ leftLeg: e.limbs.leftLeg.map(s),
681
+ rightLeg: e.limbs.rightLeg.map(s),
682
+ spine: e.limbs.spine.map(s)
683
+ },
684
+ head: { ...e.head, center: s(e.head.center), angle: e.head.angle + l }
685
+ };
236
686
  }
237
- function be(t, e) {
238
- const n = D(t.lean), o = D(e.headTilt), s = { x: 0, y: t.hipY }, r = (p) => ({ x: t.facing * p.x, y: p.y }), h = (p) => r(Bt(p, s, n)), i = (p) => h(Bt({ x: p.x, y: p.y + t.neckY }, { x: 0, y: t.neckY }, o)), l = rt(t.arms.left, t.rubber).map(h), a = rt(t.arms.right, t.rubber).map(h), f = (p) => {
239
- const [x, E] = p.slice(-2);
240
- return Math.atan2(E.y - x.y, E.x - x.x);
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;
241
691
  };
242
- let g = 1 / 0;
243
- for (const [p, x] of [
244
- [e.leftBrow, e.leftEye],
245
- [e.rightBrow, e.rightEye]
692
+ let c = 1 / 0;
693
+ for (const [S, M] of [
694
+ [t.leftBrow, t.leftEye],
695
+ [t.rightBrow, t.rightEye]
246
696
  ]) {
247
- const E = pe(Rt, 1, p, me(x, e.blink));
248
- g = Math.min(g, E, E - e.browTilt * 0.1);
697
+ const H = qt(et, 1, S, Xt(M, t.blink));
698
+ c = Math.min(c, H, H - t.browTilt * 0.1);
249
699
  }
250
- const m = { left: r(t.legs.left.end), right: r(t.legs.right.end) }, c = { left: r(t.toes.left), right: r(t.toes.right) }, d = { left: Math.max(m.left.y, c.left.y), right: Math.max(m.right.y, c.right.y) }, u = Math.max(d.left, d.right), y = rn * t.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;
251
701
  return {
252
- facing: t.facing,
253
- height: t.height,
254
- stretch: t.stretch,
255
- lineWidth: t.lineWidth,
256
- hip: s,
257
- neck: h({ x: 0, y: t.neckY }),
258
- shoulders: { left: h(t.arms.left.root), right: h(t.arms.right.root) },
259
- elbows: { left: h(t.arms.left.joint), right: h(t.arms.right.joint) },
260
- hands: { left: h(t.arms.left.end), right: h(t.arms.right.end) },
261
- knees: { left: r(t.legs.left.joint), right: r(t.legs.right.joint) },
262
- feet: m,
263
- toes: c,
264
- feetY: u,
265
- grounded: { left: d.left >= u - y, right: d.right >= u - y },
266
- handAngle: { left: f(l), right: f(a) },
702
+ facing: e.facing,
703
+ height: e.height,
704
+ stretch: e.stretch,
705
+ lineWidth: e.lineWidth,
706
+ hip: r,
707
+ neck: i({ x: 0, y: e.neckY }),
708
+ shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
709
+ elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
710
+ hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
711
+ knees: { left: l(e.legs.left.joint), right: l(e.legs.right.joint) },
712
+ feet: u,
713
+ toes: d,
714
+ feetY: m,
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") },
267
718
  limbs: {
268
- leftArm: l,
269
- rightArm: a,
270
- leftLeg: rt(t.legs.left, t.rubber).map(r),
271
- rightLeg: rt(t.legs.right, t.rubber).map(r),
272
- spine: t.spine.map(h)
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
+ spine: e.spine.map(i)
273
724
  },
274
725
  head: {
275
- center: i({ x: 0, y: -t.headRy }),
276
- rx: t.headRx,
277
- ry: t.headRy,
726
+ center: s({ x: 0, y: -e.headRy }),
727
+ rx: e.headRx,
728
+ ry: e.headRy,
278
729
  // Mirroring a turn reverses it.
279
- angle: t.facing * (n + o),
280
- eyeY: Rt,
281
- browTopY: g,
282
- mouthY: ye,
283
- faceX: t.facing * (ue + ge * V(e.turn))
730
+ angle: e.facing * (n + o),
731
+ eyeY: et,
732
+ browTopY: c,
733
+ mouthY: Dt,
734
+ faceX: e.facing * (Yt + Lt * se(t.turn))
284
735
  }
285
736
  };
286
737
  }
287
- function an(t, e = {}) {
288
- return be(we(t, e), t);
738
+ function ho(e, t = {}) {
739
+ return zt(Ut(e, t), e);
289
740
  }
290
- function mo(t, e, n) {
291
- return Bt({ x: t.center.x + e * t.rx, y: t.center.y + n * t.ry }, t.center, t.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);
292
743
  }
293
- function cn(t, e, n) {
294
- const o = (r) => ({ x: r.x + e, y: r.y + n }), s = (r) => ({ left: o(r.left), right: o(r.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) });
295
746
  return {
296
- ...t,
297
- hip: o(t.hip),
298
- neck: o(t.neck),
299
- shoulders: s(t.shoulders),
300
- elbows: s(t.elbows),
301
- hands: s(t.hands),
302
- knees: s(t.knees),
303
- feet: s(t.feet),
304
- toes: s(t.toes),
305
- feetY: t.feetY + n,
306
- grounded: { ...t.grounded },
307
- handAngle: { ...t.handAngle },
747
+ ...e,
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
+ feetY: e.feetY + n,
757
+ grounded: { ...e.grounded },
758
+ handAngle: { ...e.handAngle },
308
759
  limbs: {
309
- leftArm: t.limbs.leftArm.map(o),
310
- rightArm: t.limbs.rightArm.map(o),
311
- leftLeg: t.limbs.leftLeg.map(o),
312
- rightLeg: t.limbs.rightLeg.map(o),
313
- spine: t.limbs.spine.map(o)
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)
314
765
  },
315
- head: { ...t.head, center: o(t.head.center) }
766
+ head: { ...e.head, center: o(e.head.center) }
316
767
  };
317
768
  }
318
- function fn(t, e, n = {}, o = 0) {
319
- const s = we(e, n), r = n.color ?? "#1e293b", h = n.layers ?? {}, i = n.layers ? be(s, e) : void 0, l = n.sketch ? Ht(t, n.sketch, o) : void 0, a = n.sketch && n.layers ? Ht(t, n.sketch, o) : void 0, f = (b) => {
320
- t.save(), b(), t.restore();
321
- }, g = (b) => {
322
- b && i && f(() => b(t, i, o, a));
323
- }, m = () => t.scale(s.facing, 1), c = () => {
324
- m(), t.translate(0, s.hipY), t.rotate(D(s.lean)), t.translate(0, -s.hipY);
325
- }, d = (b, M, T) => {
326
- if (l) return M ? l.curve(b) : l.line(b);
327
- if (s.classic) {
328
- t.beginPath(), t.moveTo(b[0].x, b[0].y);
329
- for (const P of b.slice(1)) t.lineTo(P.x, P.y);
330
- t.stroke();
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
+ e.stroke();
331
782
  return;
332
783
  }
333
- Xt(t, b, T[0] * s.lineWidth, T[1] * s.lineWidth);
334
- }, u = (b, M) => d(rt(b, s.rubber), s.rubber > 0, M), y = (b) => {
335
- s.classic || d([s.legs[b].end, s.toes[b]], !1, je);
336
- }, p = (b) => {
337
- if (s.classic || l) return;
338
- const M = s.arms[b].end;
339
- t.beginPath(), t.arc(M.x, M.y, Qe * s.lineWidth, 0, Math.PI * 2), t.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();
340
792
  };
341
- t.save(), t.strokeStyle = r, t.fillStyle = r, t.lineWidth = s.lineWidth, t.lineCap = "round", t.lineJoin = "round";
342
- const x = (b) => {
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
+ // Degrees clockwise from straight up, in the frame the hand is drawn in.
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
+ skin: E.skin ?? (I === "none" ? void 0 : I),
804
+ ink: l,
805
+ lineWidth: r.lineWidth * 0.45,
806
+ fingers: E.fingers,
807
+ plump: E.plump,
808
+ look: n.sketch ? "pencil" : "clean",
809
+ seed: n.sketch?.seed
810
+ }, o);
811
+ }
812
+ const M = (k) => {
343
813
  f(() => {
344
- c(), u(s.arms[b], ze), p(b);
814
+ c(), d(r.arms[k], Gn), m(k);
345
815
  });
346
- const M = h.sleeve;
347
- M && i && f(() => M(t, i, b, o, a));
348
- }, E = V(e.turn) > on;
349
- g(h.behind), f(() => {
350
- m(), u(s.legs.left, Qt), y("left"), u(s.legs.right, Qt), y("right");
351
- }), E && x("left"), f(() => {
352
- c(), d(s.spine, s.spine.length > 2, Je);
353
- const { left: b, right: M } = { left: s.arms.left.root, right: s.arms.right.root };
354
- if (b.x !== M.x)
355
- if (s.classic) d([b, M], !1, [1, 1]);
816
+ const E = i.sleeve;
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]);
356
826
  else {
357
- const T = { x: (b.x + M.x) / 2, y: b.y - 0.3 * Math.abs(M.x - b.x) };
358
- d(tt(b, T, M, 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]);
359
829
  }
360
- }), g(h.body), E || x("left"), x("right"), g(h.behindHead), f(() => {
361
- c(), t.translate(0, s.neckY), t.rotate(D(e.headTilt));
362
- const b = -s.headRy;
363
- t.beginPath(), t.ellipse(0, b, s.headRx, s.headRy, 0, 0, Math.PI * 2);
364
- const M = n.headFill ?? "#ffffff";
365
- if (M !== "none" && (t.fillStyle = M, t.fill()), l) {
366
- l.ellipse(0, b, s.headRx, s.headRy);
367
- const T = l.nudge();
368
- t.translate(T.x, T.y);
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
+ const E = n.headFill ?? "#ffffff";
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);
369
839
  } else
370
- t.stroke();
371
- t.translate(0, b), t.scale(s.headRx / s.r, s.headRy / s.r), hn(t, e, s.r, 0, r, s.lineWidth);
372
- }), g(h.overHead), g(h.front), t.restore(), n.label && (t.save(), t.fillStyle = r, t.font = n.labelFont ?? `700 ${Math.round(s.height * 0.11)}px sans-serif`, t.textAlign = "center", t.textBaseline = "bottom", t.fillText(n.label, 0, -s.height * s.stretch - 0.04 * s.height + s.drop), t.restore());
373
- }
374
- function Me(t, e) {
375
- const n = { ...t };
376
- let o = t.walking > 0 ? Le(n, Ne(t.walk, n), t.walking) : n;
377
- return t.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, t.talk * Ce(e)) }), o;
378
- }
379
- function po(t) {
380
- const e = t.style ?? {}, n = e.height ?? 300, o = n * 0.8, s = { ...L(t.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: e.rubber ?? 0 };
840
+ e.stroke();
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
+ }
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
+ const i = e.dancing ?? 0;
848
+ if (n && i > 0) {
849
+ const s = n(e.beat ?? 0);
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
+ }
854
+ }
855
+ return e.talk > 0 && (r = { ...r, mouth: Math.max(r.mouth, e.talk * Ln(t)) }), { pose: r, hands: l };
856
+ }
857
+ function go(e, t, n) {
858
+ return Jt(e, t, n).pose;
859
+ }
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
+ }
868
+ function po(e, t) {
869
+ return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
870
+ }
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
+ if (t.hands)
874
+ for (const i of ["left", "right"]) {
875
+ const s = t.hands[i] ?? R;
876
+ for (const a of Object.keys(R)) l[Oe(i, a)] = s[a] ?? R[a];
877
+ }
381
878
  return {
382
879
  type: "custom",
383
- x: t.x - o / 2,
384
- y: t.y - n,
880
+ x: e.x - o / 2,
881
+ y: e.y - n,
385
882
  width: o,
386
883
  height: n,
387
- props: { ...s },
388
- figureStyle: e,
389
- draw(r, h, i) {
390
- const l = h.props;
391
- r.translate(o / 2, n), fn(r, Me(l, i), { ...e, rubber: l.rubber }, i);
884
+ props: { ...r, ...l },
885
+ figureStyle: t,
886
+ figureDance: e.dance,
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);
392
890
  }
393
891
  };
394
892
  }
395
- function wo(t, e, n) {
396
- const o = t.figureStyle;
893
+ function Ir(e, t, n) {
894
+ const o = e.figureStyle;
397
895
  if (!o) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
398
- const s = { ...t.props };
399
- let r = 0, h = 0;
400
- for (const [a, f] of e.state?.values.get(n) ?? [])
401
- typeof f == "number" && (a === "x" || a === "motionPathX" ? r = f : a === "y" || a === "motionPathY" ? h = f : a in s && (s[a] = f));
402
- const i = Me(s, e.time), l = an(i, { ...o, rubber: s.rubber });
403
- return { pose: i, joints: cn(l, t.x + r + t.width / 2, t.y + h + t.height) };
404
- }
405
- function bo(t, e) {
896
+ const r = { ...e.props };
897
+ let l = 0, i = 0;
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
+ }
903
+ function $r(e, t) {
406
904
  const n = [];
407
- return e.forEach((o, s) => {
408
- const r = s === 0 ? et : n[s - 1], h = typeof o.pose == "string" ? Ye[o.pose] : { ...r, ...o.pose };
409
- n.push(o.expression ? Be(h, o.expression) : h);
410
- }), fe.filter((o) => n.some((s) => s[o] !== et[o])).map((o) => ({
411
- id: `${t}-${o}`,
412
- target: t,
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
+ target: e,
413
911
  property: o,
414
- keyframes: e.map((s, r) => ({
415
- time: s.time,
416
- value: n[r][o],
417
- ...s.easing ? { easing: s.easing } : {}
912
+ keyframes: t.map((r, l) => ({
913
+ time: r.time,
914
+ value: n[l][o],
915
+ ...r.easing ? { easing: r.easing } : {}
418
916
  }))
419
917
  }));
420
918
  }
421
- const dn = ["thumb", "index", "middle", "ring", "pinky"], kt = {
422
- "thumb.curl": 0.15,
423
- "thumb.across": 0.15,
424
- "index.curl": 0.12,
425
- "middle.curl": 0.16,
426
- "ring.curl": 0.2,
427
- "pinky.curl": 0.25,
428
- spread: 0.25,
429
- turn: 0,
430
- bend: 0,
431
- tilt: 0,
432
- roll: 0
919
+ const Ye = 0.5, vt = {
920
+ /** Flag: fingers together and straight, thumb bent in */
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
+ /** Pataka with the ring finger bent */
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
+ /** Lotus in bloom: fingers fanned, each a little more curled than the last */
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
+ /** Fist */
927
+ mushti: N.fist,
928
+ /** Fist, thumb up */
929
+ shikhara: N.thumbsUp,
930
+ /** Swan's beak: thumb and index touch, the others fanned */
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
+ /** Bracelet: thumb, index and middle meet, ring and little finger out */
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 })
433
934
  };
434
- function R(t = {}) {
435
- return { ...kt, ...t };
935
+ function Ie(e) {
936
+ return typeof e != "string" ? e : e in vt ? vt[e] : N[e];
436
937
  }
437
- const B = (t, e, n, o, s) => ({
438
- "thumb.curl": t,
439
- "index.curl": e,
440
- "middle.curl": n,
441
- "ring.curl": o,
442
- "pinky.curl": s
443
- }), un = {
444
- relaxed: kt,
445
- open: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
446
- spread: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
447
- flat: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
448
- fist: R({ ...B(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
449
- point: R({ ...B(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
450
- /** The fist on its side, knuckles toward the viewer, the thumb up */
451
- thumbsUp: R({ ...B(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
452
- peace: R({ ...B(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
453
- ok: R({ ...B(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
454
- pinch: R({ ...B(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
455
- cupped: R({ ...B(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
456
- wave: R({ ...B(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
457
- /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
458
- pencilGrip: R({ ...B(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
459
- /** Holding a handle, a cup or a bar: every finger wrapped round it */
460
- hold: R({ ...B(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
461
- };
462
- function Mo(t, e, n) {
463
- const o = { ...t };
464
- for (const [s, r] of Object.entries(e)) {
465
- const h = t[s] ?? r;
466
- o[s] = h + (r - h) * n;
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
+ });
467
949
  }
468
950
  return o;
469
951
  }
470
- const gn = {
471
- index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
472
- middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
473
- ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
474
- pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
475
- }, yn = {
476
- index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
477
- middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
478
- pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
479
- }, C = {
480
- base: [-0.11, 0.1, -0.05],
481
- bones: [0.2, 0.15, 0.12],
482
- widths: [0.2, 0.145, 0.135],
483
- /** Where the thumb points with `across` 0 and 1 */
484
- out: [-0.7, 0.68, -0.22],
485
- across: [0.35, 0.5, -0.8]
486
- }, mn = [82, 100, 62], pn = [48, 72], wn = 3, bn = 13, Mn = 0.035, kn = -0.075, xn = [
487
- [-0.17, 0],
488
- [-0.215, 0.12],
489
- [-0.235, 0.26],
490
- [-0.225, 0.4],
491
- [-0.185, 0.49],
492
- [-0.075, 0.525],
493
- [0.05, 0.51],
494
- [0.16, 0.465],
495
- [0.215, 0.4],
496
- [0.225, 0.26],
497
- [0.2, 0.1],
498
- [0.16, 0]
499
- ], J = (t) => t * Math.PI / 180, Yt = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], mt = (t, e) => [t[0] * e, t[1] * e, t[2] * e], Lt = (t, e) => [t[1] * e[2] - t[2] * e[1], t[2] * e[0] - t[0] * e[2], t[0] * e[1] - t[1] * e[0]], st = (t) => {
500
- const e = Math.hypot(t[0], t[1], t[2]) || 1;
501
- return [t[0] / e, t[1] / e, t[2] / e];
502
- };
503
- function j(t, e, n) {
504
- const o = Math.cos(n), s = Math.sin(n), r = Lt(e, t), h = e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
505
- return [
506
- t[0] * o + r[0] * s + e[0] * h * (1 - o),
507
- t[1] * o + r[1] * s + e[1] * h * (1 - o),
508
- t[2] * o + r[2] * s + e[2] * h * (1 - o)
509
- ];
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
+ return {
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
+ };
510
964
  }
511
- const te = [1, 0, 0], ee = [0, 1, 0], lt = [0, 0, 1];
512
- function En(t, e, n) {
513
- const o = J(t.fan * (wn + bn * n)), s = [Math.sin(o), Math.cos(o), 0], r = [Math.cos(o), -Math.sin(o), 0], h = [t.knuckle];
514
- let i = 0;
515
- t.bones.forEach((f, g) => {
516
- i += J(mn[g] * e), h.push(Yt(h[g], mt(j(s, r, -i), f)));
517
- });
518
- const l = j(lt, r, -i), a = h.map((f, g) => t.width * (1 - 0.14 * (g / (h.length - 1))));
519
- return { joints: h, back: l, widths: a };
520
- }
521
- function Sn(t, e, n = 1, o = 1) {
522
- const s = Math.min(1, Math.max(0, e)), r = st(Yt(mt(st(C.out), 1 - s), mt(st(C.across), s))), h = st(Lt(lt, r)), i = st(Lt(r, h)), l = [[C.base[0] * o, C.base[1], C.base[2]]];
523
- let a = 0;
524
- C.bones.forEach((m, c) => {
525
- c > 0 && (a += J(pn[c - 1] * t)), l.push(Yt(l[c], mt(j(r, h, a), m)));
526
- });
527
- const f = j(i, h, a), g = [...C.widths, C.widths[C.widths.length - 1] * 0.92].map((m) => m * n);
528
- return { joints: l, back: f, widths: g };
529
- }
530
- function Ft(t, e = {}) {
531
- const n = { ...kt, ...t }, o = e.size ?? 100, s = e.side ?? "right", r = s === "left" ? -1 : 1, h = J(e.angle ?? 0), i = e.fingers === 4, l = Math.max(0.5, e.plump ?? 1), a = 1 + (l - 1) * 0.7, f = (k) => ({
532
- ...k,
533
- knuckle: [k.knuckle[0] * a, k.knuckle[1], k.knuckle[2]],
534
- width: k.width * l
535
- }), g = J(n.bend ?? 0), m = J(n.tilt ?? 0), c = J(90 * (n.turn ?? 0)), d = (k) => j(j(j(k, te, -g), lt, -m), ee, c), u = Math.cos(h), y = Math.sin(h), p = J(n.roll ?? 0), x = Math.cos(p), E = Math.sin(p), b = (k) => {
536
- const w = k[0] * o, S = -k[1] * o, v = (w * x - S * E) * r, A = w * E + S * x;
537
- return { x: v * u - A * y, y: v * y + A * u };
538
- }, M = (k) => {
539
- const w = b(k), S = Math.hypot(w.x, w.y);
540
- return S > 1e-6 * o ? { x: w.x / S, y: w.y / S } : { x: 0, y: 0 };
541
- }, T = {
542
- thumb: Sn(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, l, a)
543
- }, P = i ? yn : gn;
544
- for (const k of dn) {
545
- const w = P[k];
546
- w && (T[k] = En(f(w), n[`${k}.curl`] ?? 0, n.spread ?? 0));
547
- }
548
- const I = {};
549
- for (const [k, w] of Object.entries(T)) {
550
- const S = w.joints.map(d), v = d(w.back);
551
- I[k] = {
552
- points: S.map(b),
553
- depths: S.map((A) => A[2] * o),
554
- widths: w.widths.map((A) => A * o),
555
- nail: v[2],
556
- back: M(v)
557
- };
965
+ const mo = [
966
+ ["leftShoulder", "rightShoulder"],
967
+ ["leftElbow", "rightElbow"],
968
+ ["leftWrist", "rightWrist"],
969
+ ["leftHip", "rightHip"],
970
+ ["leftKnee", "rightKnee"],
971
+ ["leftAnkle", "rightAnkle"],
972
+ ["leftFootOut", "rightFootOut"],
973
+ ["leftEye", "rightEye"],
974
+ ["leftBrow", "rightBrow"]
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
+ const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
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];
558
981
  }
559
- const O = xn.flatMap(([k, w]) => [d([k * a, w, Mn]), d([k * a, w, kn])]), H = Tn(O.map(b)), _ = O.reduce((k, w) => k + w[2], 0) / O.length * o;
982
+ if (!n) for (const o of yo) t[o] = -e[o];
983
+ return t;
984
+ }
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);
560
988
  return {
561
- size: o,
562
- side: s,
563
- wrist: { x: 0, y: 0 },
564
- palm: H,
565
- palmDepth: _,
566
- palmFacing: -d(lt)[2],
567
- fingers: I,
568
- axes: { up: M(d(ee)), across: M(d(te)), out: M(d(lt)) },
569
- curls: Object.fromEntries(Object.keys(I).map((k) => [k, n[`${k}.curl`] ?? 0]))
989
+ ...e,
990
+ leftHip: e.leftHip + s * l / 2,
991
+ rightHip: e.rightHip + l / 2,
992
+ leftKnee: e.leftKnee + s * l,
993
+ rightKnee: e.rightKnee + l,
994
+ lean: e.lean + (t.sway ?? 0) * (1 - i) * Math.sin(Math.PI * n)
570
995
  };
571
996
  }
572
- function Pn(t, e) {
573
- const n = (s) => ({ x: s.x + e.x - t.wrist.x, y: s.y + e.y - t.wrist.y }), o = {};
574
- for (const [s, r] of Object.entries(t.fingers))
575
- o[s] = { ...r, points: r.points.map(n) };
576
- return { ...t, wrist: n(t.wrist), palm: t.palm.map(n), fingers: o };
577
- }
578
- function Tn(t) {
579
- const e = [...t].sort((r, h) => r.x - h.x || r.y - h.y);
580
- if (e.length < 3) return e;
581
- const n = (r, h, i) => (h.x - r.x) * (i.y - r.y) - (h.y - r.y) * (i.x - r.x), o = [];
582
- for (const r of e) {
583
- for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], r) <= 0; ) o.pop();
584
- o.push(r);
585
- }
586
- const s = [];
587
- for (const r of [...e].reverse()) {
588
- for (; s.length >= 2 && n(s[s.length - 2], s[s.length - 1], r) <= 0; ) s.pop();
589
- s.push(r);
997
+ function tt(e) {
998
+ const t = { ...z, ...e.stance };
999
+ return e.expression ? _t(t, e.expression) : t;
1000
+ }
1001
+ function jt(e) {
1002
+ return {
1003
+ left: e.hands?.left ? Ie(e.hands.left) : R,
1004
+ right: e.hands?.right ? Ie(e.hands.right) : R
1005
+ };
1006
+ }
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
+ }
1013
+ function at(e, t, n = {}) {
1014
+ const o = typeof e == "string" ? ce[e] : e;
1015
+ let r;
1016
+ if (n.move)
1017
+ r = Le(o, { move: n.move, mirror: n.mirror }, t);
1018
+ else {
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
+ };
1029
+ }
590
1030
  }
591
- return [...o.slice(0, -1), ...s.slice(0, -1)];
1031
+ return { ...r, pose: Eo(r.pose, o.groove, t) };
592
1032
  }
593
- function ne(t, e, n, o, s, r = 0, h = 1, i = 40) {
594
- const l = Math.cos(s), a = Math.sin(s);
595
- return Array.from({ length: i + 1 }, (f, g) => {
596
- const m = r + Math.PI * 2 * h * g / i, c = Math.cos(m) * n, d = Math.sin(m) * o;
597
- return { x: t + c * l - d * a, y: e + c * a + d * l };
598
- });
1033
+ function Br(e, t, n = {}) {
1034
+ return at(e, t, n).pose;
599
1035
  }
600
- function ke(t, e) {
601
- return e.look === "pencil" ? On(t, e) : vn(t, e.ink, e.look);
1036
+ function ht(e) {
1037
+ return (typeof e == "string" ? ce[e] : e).routine.reduce((n, o) => n + o.beats, 0);
602
1038
  }
603
- function bt(t, e, n = !1) {
604
- t.beginPath(), t.moveTo(e[0].x, e[0].y);
605
- for (const o of e.slice(1)) t.lineTo(o.x, o.y);
606
- n && t.closePath();
1039
+ const Ho = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1040
+ function Tt(e, t, n, o, r, l, i) {
1041
+ for (let s = 0; s * e.beats < n; s++)
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
+ }
1047
+ }
1048
+ function _r(e, t, n, o = {}) {
1049
+ const r = typeof e == "string" ? ce[e] : e, l = [];
1050
+ if (n <= t) return l;
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
+ } else {
1055
+ const i = ht(r);
1056
+ for (let s = Math.floor(t / i) * i; s < n; s += i) {
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
+ }
1061
+ }
1062
+ return l.sort((i, s) => i.beat - s.beat);
1063
+ }
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;
607
1088
  }
608
- function vn(t, e, n) {
609
- const o = n === "silhouette", s = o ? 1.25 : 1;
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;
610
1105
  return {
611
- look: n,
612
- ink: e,
613
- limb(r, h, i) {
614
- t.fillStyle = e, Xt(t, r, h * s, i * s);
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) {
1113
+ return (e - n) * t / 6e4;
1114
+ }
1115
+ function Rr(e, t = {}) {
1116
+ return (n) => at(e, n, t);
1117
+ }
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);
1120
+ return [
1121
+ {
1122
+ id: `${e}-beat`,
1123
+ target: e,
1124
+ property: "beat",
1125
+ keyframes: [
1126
+ { time: n, value: 0 },
1127
+ { time: r, value: t.beats, easing: "linear" }
1128
+ ]
615
1129
  },
616
- line(r, h) {
617
- r.length < 2 || (t.strokeStyle = e, t.lineWidth = h * s, t.lineCap = "round", t.lineJoin = "round", bt(t, r), t.stroke());
1130
+ {
1131
+ id: `${e}-dancing`,
1132
+ target: e,
1133
+ property: "dancing",
1134
+ keyframes: [
1135
+ { time: n, value: 0 },
1136
+ { time: n + l, value: 1, easing: "ease-in-out" },
1137
+ { time: r - l, value: 1 },
1138
+ { time: r, value: 0, easing: "ease-in-out" }
1139
+ ]
1140
+ }
1141
+ ];
1142
+ }
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}`,
1149
+ target: e,
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));
1159
+ }
1160
+ return [...p, ...u];
1161
+ }
1162
+ const be = { type: "back", mode: "out", overshoot: 1.1 }, X = "ease-out-cubic", xo = {
1163
+ label: "Disco",
1164
+ bpm: 120,
1165
+ stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
1166
+ expression: { smile: 0.9, mouth: 0.15, leftBrow: 0.3, rightBrow: 0.3 },
1167
+ groove: { bounce: 10, accent: "down", sway: 2 },
1168
+ moves: {
1169
+ point: {
1170
+ label: "The point",
1171
+ beats: 2,
1172
+ easing: X,
1173
+ keys: [
1174
+ {
1175
+ beat: 0,
1176
+ pose: { rightShoulder: 150, rightElbow: 0, rightWrist: 0, leftShoulder: 40, leftElbow: -105, leftWrist: -20, lean: -5, headTilt: 8, rightHip: 18, leftHip: 6, lookX: 0.6, lookY: -0.7 },
1177
+ hands: { right: "point", left: "fist" }
1178
+ },
1179
+ { beat: 1, pose: { rightShoulder: -30, rightWrist: 10, lean: 5, headTilt: -6, rightHip: 6, leftHip: 18, lookX: -0.4, lookY: 0.6 } }
1180
+ ]
618
1181
  },
619
- shape(r, h, i) {
620
- bt(t, r, !0), (h !== null || o) && (t.fillStyle = o ? e : h, t.fill()), !(i <= 0) && (t.strokeStyle = e, t.lineWidth = i * s, t.lineJoin = "round", t.stroke());
1182
+ roll: {
1183
+ label: "Roll the arms",
1184
+ beats: 2,
1185
+ easing: "linear",
1186
+ keys: [
1187
+ { beat: 0, pose: { leftShoulder: 42, leftElbow: -128, rightShoulder: 26, rightElbow: -100, rightHip: 18, leftHip: 6, lean: -3 }, hands: { left: "fist", right: "fist" } },
1188
+ { beat: 0.5, pose: { leftShoulder: 26, leftElbow: -100, rightShoulder: 42, rightElbow: -128 } },
1189
+ { beat: 1, pose: { leftShoulder: 42, leftElbow: -128, rightShoulder: 26, rightElbow: -100, rightHip: 6, leftHip: 18, lean: 3 } },
1190
+ { beat: 1.5, pose: { leftShoulder: 26, leftElbow: -100, rightShoulder: 42, rightElbow: -128 } }
1191
+ ]
621
1192
  },
622
- ellipse(r, h, i, l, a, f, g) {
623
- t.beginPath(), t.ellipse(r, h, i, l, a, 0, Math.PI * 2), (f !== null || o) && (t.fillStyle = o ? e : f, t.fill()), !(g <= 0) && (t.strokeStyle = e, t.lineWidth = g * s, t.stroke());
1193
+ bump: {
1194
+ label: "Bump and clap",
1195
+ beats: 4,
1196
+ keys: [
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 },
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" } },
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 },
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" } }
1201
+ ]
1202
+ }
1203
+ },
1204
+ routine: [
1205
+ { move: "point", beats: 8 },
1206
+ { move: "roll", beats: 4 },
1207
+ { move: "point", beats: 8, mirror: !0 },
1208
+ { move: "bump", beats: 8 }
1209
+ ]
1210
+ }, Ao = {
1211
+ label: "Hip hop",
1212
+ bpm: 95,
1213
+ stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
1214
+ expression: "smug",
1215
+ hands: { left: "relaxed", right: "relaxed" },
1216
+ groove: { bounce: 18, accent: "down" },
1217
+ moves: {
1218
+ bounce: {
1219
+ label: "Bounce",
1220
+ beats: 2,
1221
+ keys: [
1222
+ { beat: 0, pose: { leftShoulder: 30, rightShoulder: 30, leftElbow: -50, rightElbow: -50, lean: -3, headTilt: -5, leftWrist: -20, rightWrist: -20 } },
1223
+ { beat: 1, pose: { leftShoulder: 14, rightShoulder: 14, leftElbow: -18, rightElbow: -18, lean: 3, headTilt: 5, leftWrist: 0, rightWrist: 0 } }
1224
+ ]
624
1225
  },
625
- dot(r, h, i) {
626
- t.fillStyle = e, t.beginPath(), t.arc(r, h, i * s, 0, Math.PI * 2), t.fill();
1226
+ runningMan: {
1227
+ label: "Running man",
1228
+ beats: 2,
1229
+ keys: [
1230
+ {
1231
+ beat: 0,
1232
+ reset: !0,
1233
+ pose: { turn: 0.85, leftHip: -84, leftKnee: -112, leftAnkle: 25, rightHip: -26, rightKnee: 8, leftShoulder: 35, leftElbow: -50, rightShoulder: 45, rightElbow: 75, lean: 6 },
1234
+ hands: { left: "fist", right: "fist" }
1235
+ },
1236
+ { beat: 0.5, pose: { leftHip: -4, leftKnee: -18, leftAnkle: 0, rightHip: 4, rightKnee: 18, leftShoulder: 5, leftElbow: -40, rightShoulder: 5, rightElbow: 40 } },
1237
+ { beat: 1, pose: { rightHip: 84, rightKnee: 112, rightAnkle: 25, leftHip: 26, leftKnee: -8, rightShoulder: -35, rightElbow: 50, leftShoulder: -45, leftElbow: -75 } },
1238
+ { beat: 1.5, pose: { rightHip: 4, rightKnee: 18, rightAnkle: 0, leftHip: -4, leftKnee: -18, rightShoulder: -5, rightElbow: 40, leftShoulder: -5, leftElbow: -40 } }
1239
+ ]
627
1240
  },
628
- guide() {
1241
+ armWave: {
1242
+ label: "Arm wave",
1243
+ beats: 4,
1244
+ keys: [
1245
+ { beat: 0, reset: !0, pose: { leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0 }, hands: { left: "flat", right: "flat" } },
1246
+ { beat: 0.5, pose: { leftWrist: 45, leftElbow: -15 } },
1247
+ { beat: 1, pose: { leftWrist: -35, leftElbow: 40, leftShoulder: 84 } },
1248
+ { beat: 1.5, pose: { leftWrist: 0, leftElbow: -10, leftShoulder: 102, headTilt: -8 } },
1249
+ { beat: 2, pose: { leftElbow: 0, leftShoulder: 90, rightShoulder: 102, headTilt: 8 } },
1250
+ { beat: 2.5, pose: { rightShoulder: 84, rightElbow: 40, headTilt: 0 } },
1251
+ { beat: 3, pose: { rightElbow: -15, rightWrist: 45 } },
1252
+ { beat: 3.5, pose: { rightElbow: 0, rightWrist: -35 } }
1253
+ ]
1254
+ }
1255
+ },
1256
+ routine: [
1257
+ { move: "bounce", beats: 8 },
1258
+ { move: "runningMan", beats: 8 },
1259
+ { move: "armWave", beats: 8 },
1260
+ { move: "bounce", beats: 4 }
1261
+ ]
1262
+ }, Ko = {
1263
+ label: "Breaking (toprock)",
1264
+ bpm: 110,
1265
+ stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
1266
+ expression: { smile: 0.3, leftBrow: -0.3, rightBrow: -0.3, browTilt: -0.3 },
1267
+ hands: { left: "fist", right: "fist" },
1268
+ groove: { bounce: 8, accent: "down" },
1269
+ moves: {
1270
+ toprock: {
1271
+ label: "Toprock (Indian step)",
1272
+ beats: 4,
1273
+ keys: [
1274
+ { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: X },
1275
+ { beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
1276
+ { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: X },
1277
+ { beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
1278
+ ]
629
1279
  },
630
- guideEllipse() {
1280
+ kick: {
1281
+ label: "Kick out",
1282
+ beats: 2,
1283
+ keys: [
1284
+ { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: X },
1285
+ { beat: 1, reset: !0 }
1286
+ ]
1287
+ },
1288
+ freeze: {
1289
+ label: "B-boy stance",
1290
+ beats: 4,
1291
+ keys: [
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 },
1293
+ { beat: 2, pose: { headTilt: 14, lean: -6 } }
1294
+ ]
631
1295
  }
632
- };
633
- }
634
- function In(t, e) {
635
- const n = [t[0]];
636
- let o = 0;
637
- for (let h = 1; h < t.length; h++) {
638
- const i = t[h - 1], l = t[h], a = Math.hypot(l.x - i.x, l.y - i.y);
639
- let f = e - o;
640
- for (; f < a; ) {
641
- const g = f / a;
642
- n.push({ x: i.x + (l.x - i.x) * g, y: i.y + (l.y - i.y) * g }), f += e;
1296
+ },
1297
+ routine: [
1298
+ { move: "toprock", beats: 8 },
1299
+ { move: "kick", beats: 4 },
1300
+ { move: "toprock", beats: 8 },
1301
+ { move: "kick", beats: 4, mirror: !0 },
1302
+ { move: "freeze", beats: 4 }
1303
+ ]
1304
+ }, Po = {
1305
+ label: "Jazz",
1306
+ bpm: 130,
1307
+ stance: { leftHip: 10, rightHip: 10 },
1308
+ expression: { mouth: 0.55, smile: 1, mouthWidth: 1.2, leftBrow: 0.6, rightBrow: 0.6 },
1309
+ hands: { left: "spread", right: "spread" },
1310
+ groove: { bounce: 6, accent: "up" },
1311
+ moves: {
1312
+ jazzHands: {
1313
+ label: "Jazz hands",
1314
+ beats: 2,
1315
+ easing: "linear",
1316
+ keys: [0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75].map((e, t) => ({
1317
+ beat: e,
1318
+ // The hands shimmer: the wrists flick a little each quarter beat.
1319
+ pose: { leftShoulder: 128, rightShoulder: 128, leftElbow: 8, rightElbow: 8, leftWrist: t % 2 ? 4 : 26, rightWrist: t % 2 ? 26 : 4, leftHip: 16, rightHip: 16, leftKnee: e < 1 ? 26 : 8, rightKnee: e < 1 ? 26 : 8 },
1320
+ hands: t === 0 ? { left: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } } : void 0
1321
+ }))
1322
+ },
1323
+ kickBallChange: {
1324
+ label: "Kick ball change",
1325
+ beats: 2,
1326
+ keys: [
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 },
1328
+ { beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
1329
+ { beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
1330
+ ]
1331
+ },
1332
+ splitDrop: {
1333
+ label: "Drop into the splits",
1334
+ beats: 8,
1335
+ keys: [
1336
+ { beat: 0, reset: !0 },
1337
+ // Slide down into a full side split, arms up…
1338
+ { beat: 2, reset: !0, pose: { leftHip: 90, rightHip: 90, leftKnee: 0, rightKnee: 0, leftAnkle: -45, rightAnkle: -45, leftShoulder: 125, rightShoulder: 125, leftElbow: 10, rightElbow: 10 }, easing: "ease-in-out-cubic" },
1339
+ // …hold and sell it…
1340
+ { beat: 4, pose: { leftShoulder: 95, rightShoulder: 95, leftElbow: 0, rightElbow: 0, leftWrist: 50, rightWrist: 50, headTilt: 8 } },
1341
+ // …then gather up through a crouch and stand.
1342
+ { beat: 6, reset: !0, pose: { leftHip: 30, rightHip: 30, leftKnee: 60, rightKnee: 60, leftShoulder: 40, rightShoulder: 40 }, easing: "ease-in-out-cubic" },
1343
+ { beat: 7.5, reset: !0 }
1344
+ ]
1345
+ },
1346
+ jazzSquare: {
1347
+ label: "Jazz square",
1348
+ beats: 4,
1349
+ keys: [
1350
+ { beat: 0, reset: !0, pose: { rightHip: -18, leftHip: 8, leftShoulder: 38, rightShoulder: 46, leftElbow: 100, rightElbow: 96, lean: 4 }, hands: { left: "pinch", right: "pinch" } },
1351
+ { beat: 1, pose: { leftHip: 18, rightHip: 6, leftShoulder: 46, rightShoulder: 38, lean: -4 } },
1352
+ { beat: 2, pose: { rightHip: 22, leftHip: 6, leftShoulder: 38, rightShoulder: 46, lean: 4 } },
1353
+ { beat: 3, pose: { leftHip: 10, rightHip: 10, leftShoulder: 46, rightShoulder: 38, lean: 0 } }
1354
+ ]
643
1355
  }
644
- o = a - (f - e);
645
- }
646
- const s = t[t.length - 1], r = n[n.length - 1];
647
- return Math.hypot(s.x - r.x, s.y - r.y) > e * 0.25 ? n.push(s) : n[n.length - 1] = s, n;
648
- }
649
- function An(t, e) {
650
- const n = t.length;
651
- return t.map((o, s) => {
652
- const r = t[Math.max(0, s - 1)], h = t[Math.min(n - 1, s + 1)], i = Math.hypot(h.x - r.x, h.y - r.y) || 1, l = e(n === 1 ? 0 : s / (n - 1));
653
- return { x: o.x - (h.y - r.y) / i * l, y: o.y + (h.x - r.x) / i * l };
654
- });
655
- }
656
- function oe(t) {
657
- const e = [0.6, 1.4, 2.9].map((o) => ({
658
- frequency: o * (0.8 + t.next() * 0.4),
659
- phase: t.next() * Math.PI * 2,
660
- amount: 0.5 + t.next() * 0.5
661
- })), n = e.reduce((o, s) => o + s.amount, 0);
662
- return (o) => e.reduce((s, r) => s + r.amount * Math.sin(Math.PI * 2 * r.frequency * o + r.phase), 0) / n;
663
- }
664
- function On(t, e) {
665
- const n = e.pencil ?? {}, o = e.ink, s = n.roughness ?? Math.max(1, e.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), h = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), l = We(e.time, n.boil ?? 8);
666
- let a = 0;
667
- const f = (d, u, y = !1) => $e(Re(`${e.seed}:${y ? "paper" : l}:${d}:${u}`)), g = (d, u, y, p, x, E = 0) => {
668
- if (d.length < 2) return;
669
- const b = d.slice(1).reduce((_, k, w) => _ + Math.hypot(k.x - d[w].x, k.y - d[w].y), 0);
670
- let M = In(d, Math.max(1.5, Math.min(e.lineWidth * 0.8, b / 24)));
671
- if (E > 0 && M.length >= 2) {
672
- const [_, k] = [M[M.length - 2], M[M.length - 1]], w = Math.hypot(k.x - _.x, k.y - _.y) || 1;
673
- M = [...M, { x: k.x + (k.x - _.x) / w * E, y: k.y + (k.y - _.y) / w * E }];
1356
+ },
1357
+ routine: [
1358
+ { move: "jazzHands", beats: 4 },
1359
+ { move: "kickBallChange", beats: 4 },
1360
+ { move: "kickBallChange", beats: 4, mirror: !0 },
1361
+ { move: "jazzSquare", beats: 8 },
1362
+ { move: "jazzHands", beats: 4 },
1363
+ { move: "splitDrop", beats: 8 }
1364
+ ]
1365
+ }, Wo = {
1366
+ label: "K-pop",
1367
+ bpm: 125,
1368
+ stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
1369
+ expression: "happy",
1370
+ groove: { bounce: 5, accent: "down" },
1371
+ moves: {
1372
+ pointCombo: {
1373
+ label: "Point combo",
1374
+ beats: 4,
1375
+ easing: be,
1376
+ keys: [
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" } },
1378
+ { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
1379
+ { beat: 2, reset: !0, pose: { leftShoulder: 36, leftElbow: -96, rightShoulder: 36, rightElbow: -96, leftWrist: 20, rightWrist: 20 }, hands: { left: "fist", right: "fist" } },
1380
+ { beat: 3, reset: !0, pose: { leftShoulder: 96, rightShoulder: 96, leftElbow: 0, rightElbow: 0, leftWrist: 50, rightWrist: 50, headTilt: 8, leftHip: 18, rightHip: 18 }, hands: { left: "flat", right: "flat" } }
1381
+ ]
1382
+ },
1383
+ heart: {
1384
+ label: "Big heart, finger heart",
1385
+ beats: 4,
1386
+ keys: [
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 },
1388
+ { beat: 1, pose: { headTilt: 8, lean: 4 } },
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 },
1390
+ { beat: 3, pose: { headTilt: 4 } }
1391
+ ]
1392
+ },
1393
+ isolations: {
1394
+ label: "Isolations",
1395
+ beats: 2,
1396
+ easing: X,
1397
+ keys: [
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" } },
1399
+ { beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
1400
+ { beat: 1, pose: { lean: 9, headTilt: -11, leftHip: 18 } },
1401
+ { beat: 1.5, pose: { lean: 0, headTilt: 0, leftHip: 9 } }
1402
+ ]
674
1403
  }
675
- const T = oe(y), P = oe(y), I = M.length, O = [], H = [];
676
- M.forEach((_, k) => {
677
- const w = I === 1 ? 0 : k / (I - 1), S = M[Math.max(0, k - 1)], v = M[Math.min(I - 1, k + 1)], A = Math.hypot(v.x - S.x, v.y - S.y) || 1, W = -(v.y - S.y) / A, nt = (v.x - S.x) / A, at = T(w) * x, xt = Math.min(1, w / 0.08, (1 - w) / 0.08), Et = (0.55 + 0.45 * Math.sqrt(Math.max(0, xt))) * (1 + h * P(w)), q = Math.max(0.3, u(w) * Et / 2), ot = _.x + W * at, Z = _.y + nt * at;
678
- O.push({ x: ot + W * q, y: Z + nt * q }), H.push({ x: ot - W * q, y: Z - nt * q });
679
- }), t.save(), t.globalAlpha *= p, t.fillStyle = o, bt(t, [...O, ...H.reverse()], !0), t.fill(), t.restore();
680
- }, m = (d, u) => {
681
- const y = a++, p = f(y, 99, !0);
682
- if (p.next() < i) {
683
- const M = (p.next() * 2 - 1) * e.lineWidth * 1.4, T = (p.next() * 2 - 1) * e.lineWidth * 1.4, P = d.map((I) => ({ x: I.x + M, y: I.y + T }));
684
- g(P, (I) => u(I) * 1.8, f(y, 98, !0), 0.035, s), g(P, (I) => u(I) * 0.45, f(y, 97, !0), 0.12, s * 1.5);
1404
+ },
1405
+ routine: [
1406
+ { move: "pointCombo", beats: 8 },
1407
+ { move: "isolations", beats: 4 },
1408
+ { move: "heart", beats: 8 },
1409
+ { move: "pointCombo", beats: 8, mirror: !0 },
1410
+ { move: "isolations", beats: 4 }
1411
+ ]
1412
+ }, Oo = {
1413
+ label: "Bollywood",
1414
+ bpm: 120,
1415
+ stance: { leftHip: 10, rightHip: 10 },
1416
+ expression: { smile: 1, mouth: 0.3, leftBrow: 0.4, rightBrow: 0.4 },
1417
+ groove: { bounce: 8, accent: "down", sway: 3 },
1418
+ moves: {
1419
+ lightBulb: {
1420
+ label: "Screw the bulb, pat the dog",
1421
+ beats: 2,
1422
+ keys: [
1423
+ { beat: 0, reset: !0, pose: { rightShoulder: 160, rightElbow: 12, rightWrist: -15, leftShoulder: 40, leftElbow: -12, leftWrist: -45, lean: -4, rightHip: 16, lookX: 0.5, lookY: -0.6 }, hands: { right: { ...N.cupped, roll: -30 }, left: { ...N.flat, turn: 0 } } },
1424
+ { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...N.cupped, roll: 30 } } },
1425
+ { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...N.cupped, roll: -30 } } },
1426
+ { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...N.cupped, roll: 30 } } }
1427
+ ]
1428
+ },
1429
+ thumka: {
1430
+ label: "Thumka",
1431
+ beats: 2,
1432
+ keys: [
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 },
1434
+ { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1435
+ { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: X },
1436
+ { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
1437
+ ]
1438
+ },
1439
+ flick: {
1440
+ label: "Cross and flick",
1441
+ beats: 4,
1442
+ keys: [
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" } },
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 },
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" } },
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 }
1447
+ ]
685
1448
  }
686
- const x = d.slice(1).reduce((M, T, P) => M + Math.hypot(T.x - d[P].x, T.y - d[P].y), 0), E = u(0.5) > 4 && x > u(0.5) * 6, b = E ? [-0.3, 0.3, 0] : [0];
687
- for (let M = 0; M < r; M++) {
688
- const T = M === 0;
689
- b.forEach((P, I) => {
690
- const O = f(y, M * 10 + I), H = P === 0 ? d : An(d, (k) => u(k) * P * Math.sqrt(Math.sin(Math.PI * k))), _ = !T && P === 0 ? e.lineWidth * (0.3 + O.next() * 0.8) : 0;
691
- g(H, (k) => u(k) * (E ? 0.5 : 1) * (T ? 1 : 0.6), O, T ? 0.85 : 0.45, s * (T ? 0.6 : 1), _);
692
- });
1449
+ },
1450
+ routine: [
1451
+ { move: "thumka", beats: 4 },
1452
+ { move: "lightBulb", beats: 8 },
1453
+ { move: "flick", beats: 8 },
1454
+ { move: "thumka", beats: 4, mirror: !0 },
1455
+ { move: "lightBulb", beats: 8, mirror: !0 }
1456
+ ]
1457
+ }, Io = {
1458
+ label: "Bhangra",
1459
+ bpm: 100,
1460
+ stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
1461
+ expression: { mouth: 0.6, smile: 1, mouthWidth: 1.2, leftBrow: 0.5, rightBrow: 0.5 },
1462
+ hands: { left: "open", right: "open" },
1463
+ groove: { bounce: 12, accent: "down" },
1464
+ moves: {
1465
+ basic: {
1466
+ label: "Bhangra step",
1467
+ beats: 2,
1468
+ keys: [
1469
+ { beat: 0, reset: !0, pose: { rightHip: 58, rightKnee: 104, rightAnkle: 30, leftShoulder: 162, rightShoulder: 140, headTilt: 7 } },
1470
+ { beat: 0.5, reset: !0, pose: { stretch: 0.98 } },
1471
+ { beat: 1, reset: !0, pose: { leftHip: 58, leftKnee: 104, leftAnkle: 30, rightShoulder: 162, leftShoulder: 140, headTilt: -7 } },
1472
+ { beat: 1.5, reset: !0, pose: { stretch: 0.98 } }
1473
+ ]
1474
+ },
1475
+ dhamaal: {
1476
+ label: "Dhamaal (jump, arms up)",
1477
+ beats: 2,
1478
+ keys: [
1479
+ { beat: 0, reset: !0, pose: { leftHip: 20, rightHip: 20, leftKnee: 40, rightKnee: 40, stretch: 0.94 } },
1480
+ { beat: 0.5, reset: !0, pose: { rise: 0.07, stretch: 1.06, leftHip: 6, rightHip: 6, leftAnkle: 45, rightAnkle: 45, leftShoulder: 172, rightShoulder: 172, leftElbow: 0, rightElbow: 0 }, hands: { left: "point", right: "point" }, easing: "ease-out-quad" },
1481
+ { beat: 1, reset: !0, pose: { leftHip: 20, rightHip: 20, leftKnee: 40, rightKnee: 40, stretch: 0.94 }, hands: { left: "open", right: "open" }, easing: "ease-in-quad" },
1482
+ { beat: 1.5, reset: !0, pose: { rise: 0.07, stretch: 1.06, leftHip: 6, rightHip: 6, leftAnkle: 45, rightAnkle: 45, leftShoulder: 172, rightShoulder: 172, leftElbow: 0, rightElbow: 0 }, hands: { left: "point", right: "point" }, easing: "ease-out-quad" }
1483
+ ]
693
1484
  }
694
- }, c = (d, u, y, p, x, E) => {
695
- const M = f(a, 50).next() * Math.PI * 2;
696
- m(ne(d, u, y, p, x, M, 1.08, 48), () => E);
697
- };
698
- return {
699
- look: "pencil",
700
- ink: o,
701
- limb(d, u, y) {
702
- m(d, (p) => u + (y - u) * p);
1485
+ },
1486
+ routine: [
1487
+ { move: "basic", beats: 8 },
1488
+ { move: "dhamaal", beats: 4 },
1489
+ { move: "basic", beats: 8 },
1490
+ { move: "dhamaal", beats: 4 }
1491
+ ]
1492
+ }, $o = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Bo = {
1493
+ label: "Bharatanatyam",
1494
+ bpm: 80,
1495
+ // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1496
+ stance: { ...$o, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1497
+ expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1498
+ hands: { left: "pataka", right: "pataka" },
1499
+ groove: { bounce: 0 },
1500
+ moves: {
1501
+ tatta: {
1502
+ label: "Tatta adavu (stamps)",
1503
+ beats: 2,
1504
+ keys: [
1505
+ { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 104, rightAnkle: -18 } },
1506
+ { beat: 0.3, reset: !0, easing: "ease-in-quad", taps: ["rightToe", "rightHeel"] },
1507
+ { beat: 1, reset: !0, pose: { leftHip: 48, leftKnee: 104, leftAnkle: -18 } },
1508
+ { beat: 1.3, reset: !0, easing: "ease-in-quad", taps: ["leftToe", "leftHeel"] }
1509
+ ]
703
1510
  },
704
- line(d, u) {
705
- m(d, () => u);
1511
+ natta: {
1512
+ label: "Natta adavu (stretch and look)",
1513
+ beats: 4,
1514
+ keys: [
1515
+ { beat: 0, reset: !0, pose: { rightHip: 52, rightKnee: 0, rightAnkle: -40, rightShoulder: 125, rightWrist: 60, leftShoulder: 25, leftElbow: -125, leftWrist: 0, headTilt: 8, lookX: 0.9, lookY: -0.4, lean: -6 } },
1516
+ { beat: 1, reset: !0 },
1517
+ { beat: 2, reset: !0, pose: { leftHip: 52, leftKnee: 0, leftAnkle: -40, leftShoulder: 125, leftWrist: 60, rightShoulder: 25, rightElbow: -125, rightWrist: 0, headTilt: -8, lookX: -0.9, lookY: -0.4, lean: 6 } },
1518
+ { beat: 3, reset: !0 }
1519
+ ]
706
1520
  },
707
- shape(d, u, y) {
708
- u !== null && (t.save(), t.globalAlpha *= 0.88, t.fillStyle = u, bt(t, d, !0), t.fill(), t.restore()), y > 0 && m([...d, d[0]], () => y);
1521
+ alapadma: {
1522
+ label: "Alapadma (lotus) to the sky",
1523
+ beats: 4,
1524
+ keys: [
1525
+ { beat: 0, reset: !0, pose: { rightShoulder: 145, rightElbow: 20, rightWrist: 30, leftShoulder: 28, leftElbow: -125, leftWrist: 0, lookX: 0.7, lookY: -0.9, headTilt: 6 }, hands: { right: "alapadma", left: "pataka" } },
1526
+ { beat: 1, pose: { rightWrist: 55, headTilt: 9 } },
1527
+ { beat: 2, reset: !0, pose: { leftShoulder: 145, leftElbow: 20, leftWrist: 30, rightShoulder: 28, rightElbow: -125, rightWrist: 0, lookX: -0.7, lookY: -0.9, headTilt: -6 }, hands: { left: "alapadma", right: "pataka" } },
1528
+ { beat: 3, pose: { leftWrist: 55, headTilt: -9 } }
1529
+ ]
1530
+ }
1531
+ },
1532
+ routine: [
1533
+ { move: "tatta", beats: 8 },
1534
+ { move: "natta", beats: 8 },
1535
+ { move: "alapadma", beats: 8 },
1536
+ { move: "tatta", beats: 4 }
1537
+ ]
1538
+ }, _o = {
1539
+ label: "Charleston",
1540
+ bpm: 150,
1541
+ stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
1542
+ expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
1543
+ hands: { left: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } },
1544
+ groove: { bounce: 8, accent: "down" },
1545
+ moves: {
1546
+ basic: {
1547
+ label: "Kick forward, kick back",
1548
+ beats: 4,
1549
+ keys: [
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 },
1551
+ { beat: 1, reset: !0 },
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 },
1553
+ { beat: 3, reset: !0 }
1554
+ ]
709
1555
  },
710
- ellipse(d, u, y, p, x, E, b) {
711
- E !== null && (t.save(), t.globalAlpha *= 0.9, t.fillStyle = E, t.beginPath(), t.ellipse(d, u, y, p, x, 0, Math.PI * 2), t.fill(), t.restore()), c(d, u, y, p, x, b);
1556
+ twist: {
1557
+ label: "Swivel (heels in, heels out)",
1558
+ beats: 2,
1559
+ keys: [
1560
+ // Toes in, knees in: the heels swivel out.
1561
+ { beat: 0, reset: !0, pose: { leftFootOut: -0.9, rightFootOut: -0.9, leftHip: 4, rightHip: 4, leftKnee: 4, rightKnee: 4, leftAnkle: -10, rightAnkle: -10, leftShoulder: 18, rightShoulder: 48, leftElbow: -10, rightElbow: 50 } },
1562
+ // Toes out, knees out: the heels swivel in.
1563
+ { beat: 0.5, pose: { leftFootOut: 0.6, rightFootOut: 0.6, leftHip: 16, rightHip: 16, leftKnee: 22, rightKnee: 22, leftAnkle: 10, rightAnkle: 10, leftShoulder: 48, rightShoulder: 18, leftElbow: 50, rightElbow: -10 } },
1564
+ { beat: 1, pose: { leftFootOut: -0.9, rightFootOut: -0.9, leftHip: 4, rightHip: 4, leftKnee: 4, rightKnee: 4, leftAnkle: -10, rightAnkle: -10, leftShoulder: 18, rightShoulder: 48, leftElbow: -10, rightElbow: 50 } },
1565
+ { beat: 1.5, pose: { leftFootOut: 0.6, rightFootOut: 0.6, leftHip: 16, rightHip: 16, leftKnee: 22, rightKnee: 22, leftAnkle: 10, rightAnkle: 10, leftShoulder: 48, rightShoulder: 18, leftElbow: 50, rightElbow: -10 } }
1566
+ ]
712
1567
  },
713
- dot(d, u, y) {
714
- t.save(), t.globalAlpha *= 0.9, t.fillStyle = o, t.beginPath(), t.arc(d, u, y, 0, Math.PI * 2), t.fill(), t.restore();
1568
+ kneeCross: {
1569
+ label: "Crossing knees",
1570
+ beats: 2,
1571
+ keys: [
1572
+ // Knees knock together while the hands cross over them…
1573
+ { beat: 0, reset: !0, pose: { leftHip: -6, rightHip: -6, leftKnee: -16, rightKnee: -16, leftFootOut: -0.4, rightFootOut: -0.4, leftShoulder: -12, rightShoulder: -12, leftElbow: 0, rightElbow: 0, lean: 0, lookY: 0.6 } },
1574
+ // …then swing apart, hands open.
1575
+ { beat: 0.5, pose: { leftHip: 18, rightHip: 18, leftKnee: 28, rightKnee: 28, leftFootOut: 0.3, rightFootOut: 0.3, leftShoulder: 16, rightShoulder: 16, lookY: 0 } },
1576
+ { beat: 1, pose: { leftHip: -6, rightHip: -6, leftKnee: -16, rightKnee: -16, leftFootOut: -0.4, rightFootOut: -0.4, leftShoulder: -12, rightShoulder: -12, lookY: 0.6 } },
1577
+ { beat: 1.5, pose: { leftHip: 18, rightHip: 18, leftKnee: 28, rightKnee: 28, leftFootOut: 0.3, rightFootOut: 0.3, leftShoulder: 16, rightShoulder: 16, lookY: 0 } }
1578
+ ]
1579
+ }
1580
+ },
1581
+ routine: [
1582
+ { move: "basic", beats: 8 },
1583
+ { move: "twist", beats: 8 },
1584
+ { move: "kneeCross", beats: 8 },
1585
+ { move: "basic", beats: 8, mirror: !0 },
1586
+ { move: "twist", beats: 4 }
1587
+ ]
1588
+ }, Fo = {
1589
+ label: "Tap",
1590
+ bpm: 120,
1591
+ // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
1592
+ // forward is a positive angle for the right limbs and a negative one for the left.
1593
+ stance: {
1594
+ turn: 0.8,
1595
+ leftHip: -3,
1596
+ rightHip: 3,
1597
+ leftKnee: -10,
1598
+ rightKnee: 10,
1599
+ leftShoulder: 12,
1600
+ rightShoulder: 12,
1601
+ leftElbow: -40,
1602
+ rightElbow: 40,
1603
+ leftWrist: -15,
1604
+ rightWrist: 15,
1605
+ lean: 4
1606
+ },
1607
+ expression: { smile: 0.9, mouth: 0.2, leftBrow: 0.3, rightBrow: 0.3, lookY: 0.3 },
1608
+ hands: { left: "relaxed", right: "relaxed" },
1609
+ groove: { bounce: 6, accent: "down" },
1610
+ moves: {
1611
+ shuffleBallChange: {
1612
+ label: "Shuffle ball change",
1613
+ beats: 2,
1614
+ easing: "ease-out-quad",
1615
+ keys: [
1616
+ // Knee up, the foot brushes forward (toe strikes)…
1617
+ { beat: 0, reset: !0, pose: { rightHip: 34, rightKnee: 8, rightAnkle: 30, leftShoulder: 30, rightShoulder: -10 }, taps: ["rightToe"] },
1618
+ // …and back from the knee (toe strikes again)…
1619
+ { beat: 0.25, pose: { rightHip: 24, rightKnee: 62, rightAnkle: 40 }, taps: ["rightToe"] },
1620
+ // …step on the ball behind, then change weight to the other foot.
1621
+ { beat: 0.5, pose: { rightHip: -8, rightKnee: 14, rightAnkle: 50, leftAnkle: 15, leftShoulder: 12, rightShoulder: 12 }, taps: ["rightToe"] },
1622
+ { beat: 0.75, pose: { rightHip: 3, rightKnee: 10, rightAnkle: 0, leftAnkle: 0 }, taps: ["leftHeel"] },
1623
+ { beat: 1, reset: !0, pose: { leftHip: -34, leftKnee: -8, leftAnkle: 30, rightShoulder: -30, leftShoulder: 10 }, taps: ["leftToe"] },
1624
+ { beat: 1.25, pose: { leftHip: -24, leftKnee: -62, leftAnkle: 40 }, taps: ["leftToe"] },
1625
+ { beat: 1.5, pose: { leftHip: 8, leftKnee: -14, leftAnkle: 50, rightAnkle: 15, leftShoulder: 12, rightShoulder: 12 }, taps: ["leftToe"] },
1626
+ { beat: 1.75, pose: { leftHip: -3, leftKnee: -10, leftAnkle: 0, rightAnkle: 0 }, taps: ["rightHeel"] }
1627
+ ]
715
1628
  },
716
- guide(d) {
717
- if (n.construction === !1 || d.length < 2) return;
718
- const u = a++;
719
- g(d, () => Math.max(0.6, e.lineWidth * 0.18), f(u, 0), 0.28, s * 1.2, e.lineWidth);
1629
+ timeStep: {
1630
+ label: "Single time step",
1631
+ beats: 4,
1632
+ easing: "ease-out-quad",
1633
+ keys: [
1634
+ // Stamp the right foot flat…
1635
+ { beat: 0, reset: !0, pose: { rightHip: 8, rightKnee: 4, rightAnkle: 0, leftShoulder: 25, rightShoulder: -20 }, taps: ["rightToe", "rightHeel"] },
1636
+ // …shuffle (brush forward, brush back)…
1637
+ { beat: 0.5, pose: { rightHip: 34, rightKnee: 8, rightAnkle: 30 }, taps: ["rightToe"] },
1638
+ { beat: 0.75, pose: { rightHip: 22, rightKnee: 62, rightAnkle: 40 }, taps: ["rightToe"] },
1639
+ // …hop on the left (up, then land)…
1640
+ { beat: 1, pose: { rise: 0.05, leftAnkle: 45, leftKnee: -4, leftHip: -2, rightHip: 26, rightKnee: 70, stretch: 1.03 } },
1641
+ { beat: 1.25, pose: { rise: 0, leftAnkle: 0, leftKnee: -14, stretch: 1 }, taps: ["leftToe"] },
1642
+ // …step right, flap left (brush forward and step), step right.
1643
+ { beat: 1.5, pose: { rightHip: 4, rightKnee: 12, rightAnkle: 0, rightShoulder: 25, leftShoulder: -20 }, taps: ["rightToe"] },
1644
+ { beat: 2, pose: { leftHip: -30, leftKnee: -6, leftAnkle: 35 }, taps: ["leftToe"] },
1645
+ { beat: 2.25, pose: { leftHip: -4, leftKnee: -12, leftAnkle: 0 }, taps: ["leftToe"] },
1646
+ { beat: 3, pose: { rightHip: 10, rightAnkle: 35, rightKnee: 18, leftShoulder: 12, rightShoulder: 12 }, taps: ["rightToe"] },
1647
+ { beat: 3.5, pose: { rightHip: 3, rightKnee: 10, rightAnkle: 0 } }
1648
+ ]
720
1649
  },
721
- guideEllipse(d, u, y, p, x) {
722
- if (n.construction === !1) return;
723
- const E = a++, b = f(E, 0), M = ne(d, u, y, p, x, b.next() * Math.PI * 2, 1.12, 48);
724
- g(M, () => Math.max(0.6, e.lineWidth * 0.18), b, 0.28, s * 1.5);
725
- }
726
- };
727
- }
728
- const _n = "#f1c9a5", Hn = "#2f2f33";
729
- function xe(t, e, n, o = {}, s = 0) {
730
- const r = Pn(Ft(n, o), e), h = o.ink ?? Hn, i = o.lineWidth ?? r.size * 0.035, l = o.pen ?? ke(t, {
731
- look: o.look ?? "clean",
732
- ink: h,
733
- lineWidth: i,
734
- seed: o.seed ?? 1,
735
- time: s,
736
- pencil: { construction: !1, ...o.pencil }
737
- }), a = o.skin ?? _n, f = o.nails ?? !0, g = [
738
- {
739
- depth: r.palmDepth,
740
- draw: () => Wn(l, r, a, i)
741
- }
742
- ];
743
- for (const m of Object.values(r.fingers)) {
744
- const c = m.depths.reduce((d, u) => d + u, 0) / m.depths.length;
745
- g.push({
746
- depth: c,
747
- draw: () => $n(t, l, m, a, i, f)
748
- });
749
- }
750
- if (o.prop) {
751
- const m = o.prop;
752
- g.push({ depth: m.depth, draw: () => m.draw(l) });
753
- }
754
- t.save(), t.lineCap = "round", t.lineJoin = "round";
755
- for (const m of [...g].sort((c, d) => c.depth - d.depth)) m.draw();
756
- return t.restore(), r;
757
- }
758
- function Wn(t, e, n, o) {
759
- if (t.shape(e.palm, n, o), e.palmFacing < -0.3 && t.look !== "silhouette") {
760
- const { up: s } = e.axes;
761
- for (const [r, h] of Object.entries(e.fingers)) {
762
- const i = e.curls[r] ?? 0;
763
- if (r === "thumb" || i < 0.5) continue;
764
- const l = h.points[0], a = h.widths[0] * 0.42, f = { x: l.x - s.x * a * 0.2, y: l.y - s.y * a * 0.2 }, g = Math.atan2(s.y, s.x), m = Array.from({ length: 7 }, (c, d) => {
765
- const u = g - Math.PI / 2 + Math.PI * d / 6;
766
- return { x: f.x + Math.cos(u) * a, y: f.y + Math.sin(u) * a };
767
- });
768
- t.line(m, o * 0.6);
1650
+ heelToe: {
1651
+ label: "Heel toe",
1652
+ beats: 2,
1653
+ easing: "ease-out-quad",
1654
+ keys: [
1655
+ // Dig the heel in front (toe up), then the toe behind (heel up); the arms swing against the feet.
1656
+ { beat: 0, reset: !0, pose: { rightHip: 26, rightKnee: 0, rightAnkle: -35, leftShoulder: 30, rightShoulder: -20 }, taps: ["rightHeel"] },
1657
+ { beat: 0.5, pose: { rightHip: -16, rightKnee: 24, rightAnkle: 55, leftShoulder: -15, rightShoulder: 25 }, taps: ["rightToe"] },
1658
+ { beat: 1, reset: !0, pose: { leftHip: -26, leftKnee: 0, leftAnkle: -35, rightShoulder: -30, leftShoulder: 20 }, taps: ["leftHeel"] },
1659
+ { beat: 1.5, pose: { leftHip: 16, leftKnee: -24, leftAnkle: 55, rightShoulder: 15, leftShoulder: -25 }, taps: ["leftToe"] }
1660
+ ]
1661
+ },
1662
+ crampRoll: {
1663
+ label: "Cramp roll",
1664
+ beats: 2,
1665
+ easing: "ease-out-quad",
1666
+ keys: [
1667
+ // Up on both balls, right then left, then the heels drop, right then left: four quick sounds.
1668
+ { beat: 0, reset: !0, pose: { rightHip: 12, rightKnee: 26, leftHip: -12, leftKnee: -26 } },
1669
+ { beat: 0.5, pose: { rightAnkle: 40, rise: 0.02 }, taps: ["rightToe"] },
1670
+ { beat: 0.625, pose: { leftAnkle: 40 }, taps: ["leftToe"] },
1671
+ { beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
1672
+ { beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
1673
+ // Arms flare on the finish: one up in front, one up behind.
1674
+ { beat: 1, pose: { rightShoulder: 135, leftShoulder: 125, leftElbow: 0, rightElbow: 0, leftWrist: 0, rightWrist: 30, rightKnee: 8, leftKnee: -8, rightHip: 4, leftHip: -4 }, hands: { left: { ...N.spread, turn: 2 }, right: { ...N.spread, turn: 2 } } },
1675
+ { beat: 1.75, reset: !0 }
1676
+ ]
769
1677
  }
770
- }
771
- if (e.palmFacing > 0.45 && t.look !== "silhouette") {
772
- const { up: s, across: r } = e.axes, h = e.size, i = e.wrist, l = (f, g) => ({
773
- x: i.x + (r.x * f + s.x * g) * h,
774
- y: i.y + (r.y * f + s.y * g) * h
775
- }), a = e.side === "left" ? -1 : 1;
776
- t.line([l(-0.15 * a, 0.36), l(-0.04 * a, 0.3), l(0.1 * a, 0.33)], o * 0.5);
777
- }
778
- }
779
- function $n(t, e, n, o, s, r) {
780
- const { widths: h } = n, i = Rn(n.points, 2), l = n.points[0], a = i[i.length - 1], f = h[0], g = h[h.length - 1];
781
- if (t.save(), e.look !== "silhouette") {
782
- t.beginPath(), t.rect(l.x - 1e5, l.y - 1e5, 2e5, 2e5);
783
- const u = f / 2 + s * 1.6;
784
- t.moveTo(l.x + u, l.y), t.arc(l.x, l.y, u, 0, Math.PI * 2), t.clip("evenodd");
785
- }
786
- if (e.limb(i, f + 2 * s, g + 2 * s), t.restore(), e.look !== "silhouette" && (t.fillStyle = o, Xt(t, i, f, g)), e.look === "silhouette" || !r || n.nail < 0.25) return;
787
- const m = i[i.length - 2], c = Bn({ x: a.x - m.x, y: a.y - m.y }) ?? {
788
- x: 0,
789
- y: -1
790
- }, d = {
791
- x: a.x - c.x * g * 0.22 + n.back.x * g * 0.1,
792
- y: a.y - c.y * g * 0.22 + n.back.y * g * 0.1
793
- };
794
- e.ellipse(d.x, d.y, g * 0.24 * Math.max(0.35, n.nail), g * 0.19, Math.atan2(c.y, c.x), "#f8e3d3", s * 0.45);
795
- }
796
- function Rn(t, e) {
797
- let n = t;
798
- for (let o = 0; o < e; o++) {
799
- if (n.length < 3) return n;
800
- const s = [n[0]];
801
- for (let r = 0; r < n.length - 1; r++) {
802
- const h = n[r], i = n[r + 1];
803
- r > 0 && s.push({ x: h.x * 0.75 + i.x * 0.25, y: h.y * 0.75 + i.y * 0.25 }), r < n.length - 2 && s.push({ x: h.x * 0.25 + i.x * 0.75, y: h.y * 0.25 + i.y * 0.75 });
1678
+ },
1679
+ routine: [
1680
+ { move: "shuffleBallChange", beats: 8 },
1681
+ { move: "timeStep", beats: 4 },
1682
+ { move: "timeStep", beats: 4, mirror: !0 },
1683
+ { move: "heelToe", beats: 8 },
1684
+ { move: "crampRoll", beats: 4 }
1685
+ ]
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
+ ]
804
1750
  }
805
- s.push(n[n.length - 1]), n = s;
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) {
1773
+ const t = { ...z, turn: e.view }, n = [];
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 });
806
1777
  }
807
1778
  return n;
808
1779
  }
809
- const Bn = (t) => {
810
- const e = Math.hypot(t.x, t.y);
811
- return e > 1e-6 ? { x: t.x / e, y: t.y / e } : null;
812
- };
813
- function Yn(t, e, n = {}, o) {
814
- const s = n.length ?? 240, r = 9, h = 28, i = s - 22;
815
- t.save(), t.translate(e.x, e.y), t.rotate((n.angle ?? -30) * Math.PI / 180), t.fillStyle = n.color ?? "#f4c542", t.fillRect(h, -r, i - h, 2 * r), t.fillStyle = "#e8b4a0", t.fillRect(i, -r, s - i, 2 * r), t.fillStyle = "#f1dcbf", t.beginPath(), t.moveTo(0, 0), t.lineTo(h, -r), t.lineTo(h, r), t.closePath(), t.fill(), t.fillStyle = n.outline ?? "#2f2f33", t.beginPath(), t.moveTo(0, 0), t.lineTo(h * 0.35, -r * 0.35), t.lineTo(h * 0.35, r * 0.35), t.closePath(), t.fill(), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round", t.lineCap = "round";
816
- const l = [
817
- [{ x: 0, y: 0 }, { x: h, y: -r }, { x: s, y: -r }, { x: s, y: r }, { x: h, y: r }, { x: 0, y: 0 }],
818
- [{ x: h, y: -r }, { x: h, y: r }],
819
- [{ x: i, y: -r }, { x: i, y: r }]
820
- ];
821
- for (const a of l) Te(t, a, o);
822
- t.restore();
823
- }
824
- function Ee(t, e, n = {}, o) {
825
- const s = n.length ?? 90, r = n.thickness ?? 34;
826
- t.save(), t.translate(e.x, e.y), t.rotate((n.angle ?? -35) * Math.PI / 180);
827
- const h = -r / 2;
828
- t.fillStyle = n.color ?? "#f4a7b9", t.fillRect(0, h, s, r), t.fillStyle = "#e9edf2", t.fillRect(s * 0.45, h, s * 0.55, r), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round";
829
- const i = [
830
- { x: 0, y: h },
831
- { x: s, y: h },
832
- { x: s, y: -h },
833
- { x: 0, y: -h },
834
- { x: 0, y: h }
835
- ], l = [{ x: s * 0.45, y: h }, { x: s * 0.45, y: -h }];
836
- if (o)
837
- o.line(i), o.line(l);
838
- else
839
- for (const a of [i, l]) {
840
- t.beginPath(), t.moveTo(a[0].x, a[0].y);
841
- for (const f of a.slice(1)) t.lineTo(f.x, f.y);
842
- t.stroke();
843
- }
844
- t.restore();
845
- }
846
- const Se = 150, Ln = { pencil: 44, eraser: 30 };
847
- function Pe(t, e, n = {}, o) {
848
- const s = n.tool ?? "pencil", r = n.skin ?? "#f1c9a5", h = n.outline ?? "#2f2f33", i = n.scale ?? 1, l = Math.min(1, Math.max(0, n.lift ?? 0)), a = (n.angle ?? -30) * Math.PI / 180, f = o ? o.nudge(0.6) : { x: 0, y: 0 }, g = Se * i * (1 + 0.05 * l);
849
- l > 0 && (t.save(), t.fillStyle = h, t.globalAlpha = 0.15 * l, t.beginPath(), t.ellipse(e.x, e.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), t.fill(), t.restore());
850
- const m = { x: e.x + f.x + 6 * l * i, y: e.y + f.y - 18 * l * i }, c = un.pencilGrip, d = (P) => {
851
- const I = P.fingers.thumb, O = P.fingers.index, H = P.fingers.middle, _ = se([I.points[3], O.points[3], H.points[3]]), k = se([I.points[1], O.points[0]]), w = (I.depths[3] + O.depths[3] + H.depths[3]) / 3;
852
- return { pinch: _, direction: Math.atan2(k.y - _.y, k.x - _.x), depth: w };
853
- }, u = Ft(c, { size: g }), y = a - d(u).direction, p = Ft(c, { size: g, angle: y * 180 / Math.PI }), x = d(p), E = Ln[s] * i, b = { x: x.pinch.x - Math.cos(a) * E, y: x.pinch.y - Math.sin(a) * E }, M = { x: m.x - b.x, y: m.y - b.y }, T = p.axes.up;
854
- Fn(t, M, { x: -T.x, y: -T.y }, g, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", h), xe(t, M, c, {
855
- size: g,
856
- angle: y * 180 / Math.PI,
857
- skin: r,
858
- ink: h,
859
- lineWidth: 3 * i,
860
- prop: {
861
- depth: x.depth,
862
- draw: () => {
863
- t.save(), t.translate(m.x, m.y), t.scale(i, i), s === "eraser" ? Ee(t, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, outline: h }, o) : Yn(t, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, length: 190, outline: h }, o), t.restore();
864
- }
865
- }
866
- });
867
- }
868
- const se = (t) => ({
869
- x: t.reduce((e, n) => e + n.x, 0) / t.length,
870
- y: t.reduce((e, n) => e + n.y, 0) / t.length
871
- });
872
- function Fn(t, e, n, o, s, r, h, i) {
873
- const l = { x: -n.y, y: n.x }, a = o * 0.15, f = (u, y, p) => ({
874
- x: e.x + n.x * u + l.x * y * p,
875
- y: e.y + n.y * u + l.y * y * p
876
- }), g = f(s, 0, 0), m = (u) => {
877
- const y = t.createLinearGradient(e.x, e.y, g.x, g.y);
878
- return y.addColorStop(0, u), y.addColorStop(0.6, u), y.addColorStop(1, Nn(u)), y;
879
- }, c = Math.min(o * 0.55, s * 0.35);
880
- t.save(), t.lineJoin = "round", t.lineCap = "round", t.lineWidth = 3 * (o / Se), t.beginPath(), t.moveTo(f(-o * 0.1, -1, a).x, f(-o * 0.1, -1, a).y), t.lineTo(f(c + 4, -1, a * 1.1).x, f(c + 4, -1, a * 1.1).y), t.lineTo(f(c + 4, 1, a * 1.1).x, f(c + 4, 1, a * 1.1).y), t.lineTo(f(-o * 0.1, 1, a).x, f(-o * 0.1, 1, a).y), t.closePath(), t.fillStyle = r, t.fill(), t.strokeStyle = i, t.beginPath(), t.moveTo(f(0, -1, a).x, f(0, -1, a).y), t.lineTo(f(c, -1, a * 1.1).x, f(c, -1, a * 1.1).y), t.moveTo(f(0, 1, a).x, f(0, 1, a).y), t.lineTo(f(c, 1, a * 1.1).x, f(c, 1, a * 1.1).y), t.stroke();
881
- const d = [f(c, -1, a * 1.3), f(s, -1, a * 1.5), f(s, 1, a * 1.5), f(c, 1, a * 1.3)];
882
- t.beginPath(), d.forEach((u, y) => y ? t.lineTo(u.x, u.y) : t.moveTo(u.x, u.y)), t.closePath(), t.fillStyle = m(h), t.fill(), t.strokeStyle = m(i), t.beginPath(), t.moveTo(d[1].x, d[1].y), t.lineTo(d[0].x, d[0].y), t.lineTo(d[3].x, d[3].y), t.lineTo(d[2].x, d[2].y), t.stroke(), t.restore();
883
- }
884
- function ko(t, e, n = {}) {
885
- const o = n.offstage ?? { x: 2e3, y: 1400 }, s = n.enter ?? 450, r = n.exit ?? 450, h = n.linger ?? 1500, i = [...t].filter((u) => u.path.length > 0).sort((u, y) => u.start - y.start), l = (u) => u.tool ?? "pencil", a = (u) => {
886
- const y = Math.min(1, Math.max(0, u));
887
- return y * y * (3 - 2 * y);
888
- }, f = (u, y, p) => ({ x: u.x + (y.x - u.x) * p, y: u.y + (y.y - u.y) * p }), g = i.find((u) => e >= u.start && e <= u.end);
889
- if (g) {
890
- const u = g.end - g.start, y = u > 0 ? (e - g.start) / u : 1;
891
- return { at: Ut(g.path, y), tool: l(g), lift: 0, drawing: !0 };
892
- }
893
- const m = [...i].reverse().find((u) => u.end < e), c = i.find((u) => u.start > e), d = (u) => u.path[u.path.length - 1];
894
- if (m && c && c.start - m.end <= h) {
895
- const u = (e - m.end) / (c.start - m.end), y = u < 0.5 ? l(m) : l(c);
896
- return { at: f(d(m), c.path[0], a(u)), tool: y, lift: Math.sin(Math.PI * u), drawing: !1 };
897
- }
898
- if (c && c.start - e <= s) {
899
- const u = 1 - (c.start - e) / s;
900
- return { at: f(o, c.path[0], a(u)), tool: l(c), lift: 1 - a(u), drawing: !1 };
901
- }
902
- if (m && e - m.end <= r) {
903
- const u = (e - m.end) / r;
904
- return { at: f(d(m), o, a(u)), tool: l(m), lift: a(u), drawing: !1 };
905
- }
906
- return null;
907
- }
908
- function xo(t, e, n, o = 0.08, s = 32) {
909
- const r = Math.PI * 2 * (1 + o), h = [];
910
- for (let i = 0; i <= s; i++) {
911
- const l = -Math.PI / 2 + r * i / s;
912
- h.push({ x: t + Math.cos(l) * n, y: e + Math.sin(l) * n });
913
- }
914
- return h;
915
- }
916
- function Eo(t) {
917
- const { path: e } = t, n = e.map((i) => i.x), o = e.map((i) => i.y), s = Math.min(...n), r = Math.min(...o), h = t.hand === !1 ? void 0 : t.hand === !0 || t.hand === void 0 ? {} : t.hand;
918
- return {
919
- type: "custom",
920
- x: s,
921
- y: r,
922
- width: Math.max(1, Math.max(...n) - s),
923
- height: Math.max(1, Math.max(...o) - r),
924
- props: { draw: 0 },
925
- draw(i, l, a) {
926
- const f = Math.min(1, Math.max(0, Number(l.props?.draw ?? 0)));
927
- i.translate(-s, -r), i.strokeStyle = t.color ?? "#2f2f33", i.lineWidth = t.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
928
- const g = t.sketch ? Ht(i, t.sketch, a) : void 0;
929
- f > 0 && (g ? t.smooth ? g.curve(e, f) : g.line(e, f) : Te(i, ae(e, f))), h && f > 0 && f < 1 && Pe(i, Ut(e, f), h, g);
930
- }
1780
+ function Lo(e) {
1781
+ return e - No * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1782
+ }
1783
+ const No = 0.5;
1784
+ function Co(e, t) {
1785
+ if (!(t <= e.takeoff || t >= e.landing))
1786
+ return (t - e.takeoff) / (e.landing - e.takeoff);
1787
+ }
1788
+ function Do(e, t) {
1789
+ const n = typeof e == "string" ? ft[e] : e, o = Yo(n), r = $e(t);
1790
+ let l = 0;
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),
1796
+ rise: 4 * n.height * f * (1 - f)
931
1797
  };
932
1798
  }
933
- function Nn(t) {
934
- const e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());
935
- if (!e) return "rgba(0, 0, 0, 0)";
936
- const n = e[1].length === 3 ? [...e[1]].map((h) => h + h).join("") : e[1], [o, s, r] = [0, 2, 4].map((h) => parseInt(n.slice(h, h + 2), 16));
937
- return `rgba(${o}, ${s}, ${r}, 0)`;
938
- }
939
- function Te(t, e, n) {
940
- if (!(e.length < 2)) {
941
- if (n) return n.line(e);
942
- t.beginPath(), t.moveTo(e[0].x, e[0].y);
943
- for (const o of e.slice(1)) t.lineTo(o.x, o.y);
944
- t.stroke();
945
- }
946
- }
947
- const ft = 1e5;
948
- function So(t, e, n, o, s = 6) {
949
- const r = [], h = Math.max(1, Math.round(s));
950
- for (let i = 0; i <= h; i++)
951
- r.push({ x: i % 2 === 0 ? t : t + n, y: e + o * i / h });
952
- return r;
953
- }
954
- function ve(t, e, n, o) {
955
- if (o <= 0 || e.length === 0) return;
956
- const s = ae(e, o), r = n / 2, h = (i) => {
957
- t.beginPath(), t.rect(-ft, -ft, 2 * ft, 2 * ft), i(), t.clip("evenodd");
958
- };
959
- for (const i of s)
960
- h(() => {
961
- t.moveTo(i.x + r, i.y), t.arc(i.x, i.y, r, 0, Math.PI * 2);
962
- });
963
- for (let i = 1; i < s.length; i++) {
964
- const l = s[i - 1], a = s[i], f = Math.hypot(a.x - l.x, a.y - l.y);
965
- if (f === 0) continue;
966
- const g = -(a.y - l.y) / f * r, m = (a.x - l.x) / f * r;
967
- h(() => {
968
- t.moveTo(l.x + g, l.y + m), t.lineTo(a.x + g, a.y + m), t.lineTo(a.x - g, a.y - m), t.lineTo(l.x - g, l.y - m), t.closePath();
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;
1802
+ }
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) => ({
1808
+ id: `${e}-${f}`,
1809
+ target: e,
1810
+ property: f,
1811
+ keyframes: s.map((g) => ({ time: g.time, value: g.pose[f] }))
1812
+ }));
1813
+ if (n.height !== void 0 && o.travel !== 0) {
1814
+ const f = (n.facing ?? 1) < 0 ? -1 : 1;
1815
+ h.push({
1816
+ id: `${e}-x`,
1817
+ target: e,
1818
+ property: "x",
1819
+ keyframes: s.map((g) => ({ time: g.time, value: (n.x ?? 0) + f * Xo(o, g.progress, n.height) }))
969
1820
  });
970
1821
  }
1822
+ return h;
971
1823
  }
972
- function Po(t, e, n, o, s) {
973
- t.save(), ve(t, e, n, o), s(), t.restore();
974
- }
975
- function To(t, e) {
976
- const n = e.width ?? 40, o = e.hand === !0 ? {} : e.hand || void 0, s = e.eraser === !1 ? void 0 : e.eraser === !0 || e.eraser === void 0 ? {} : e.eraser;
977
- return {
978
- ...t,
979
- props: { ...t.props, erase: 0 },
980
- draw(r, h, i) {
981
- const l = Number(h.props?.erase ?? 0);
982
- if (r.save(), ve(r, e.path, n, l), t.draw(r, h, i), r.restore(), !s || l <= 0 || l >= 1) return;
983
- const a = Ut(e.path, l);
984
- o ? Pe(r, a, { ...o, tool: "eraser" }) : Ee(r, a, s);
985
- }
986
- };
987
- }
988
- const K = (t) => t * Math.PI / 180;
989
- function Ie([t, e, n], o) {
990
- const s = Math.cos(o), r = Math.sin(o);
991
- return [t, e * s + n * r, -e * r + n * s];
992
- }
993
- function Ae([t, e, n], o) {
994
- const s = Math.cos(o), r = Math.sin(o);
995
- return [t * s - e * r, t * r + e * s, n];
996
- }
997
- function ht([t, e, n], o) {
998
- const s = Math.cos(o), r = Math.sin(o);
999
- return [t * s + n * r, e, -t * r + n * s];
1000
- }
1001
- const Tt = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], re = (t, e) => [t[0] * e, t[1] * e, t[2] * e], pt = (t, e) => Ae(Ie(t, e.swing), e.spread);
1002
- function vt(t, e) {
1003
- const n = ht(t, e);
1004
- return { point: { x: n[0], y: -n[1] }, depth: n[2] };
1005
- }
1006
- function Dt(t, e, n) {
1007
- const o = n.height, s = K(90 * (e.turn ?? 0)), h = [0, t.hipHeight * o * (t.boneScale?.(e, null) ?? 1), 0], i = {};
1008
- for (const w of t.chains) {
1009
- const S = w.parent ? i[w.parent] : void 0;
1010
- if (w.parent && !S) throw new Error(`body plan ${t.id}: chain ${w.id} comes before its parent ${w.parent}`);
1011
- const v = w.at ?? (S ? S.joints3.length - 1 : 0), A = S ? S.joints3[v] : h, W = S ? S.frames[Math.max(0, v - 1)] : { swing: 0, spread: 0 }, nt = w.offset ? Tt(A, pt(re(w.offset, o), W)) : A, at = w.side ?? 1, xt = t.boneScale?.(e, w) ?? 1, Et = t.angles(e, w), q = [nt], ot = [];
1012
- let Z = W.swing, St = W.spread;
1013
- w.bones.forEach((_e, Kt) => {
1014
- const Pt = Et[Kt] ?? { swing: 0, spread: 0 };
1015
- Z += K(Pt.swing), St += K(Pt.spread) * at, ot.push({ swing: Z, spread: St });
1016
- const He = ht(pt(w.rest, { swing: Z, spread: St }), K(Pt.yaw ?? 0));
1017
- q.push(Tt(q[Kt], re(He, _e.length * o * xt)));
1018
- }), i[w.id] = { joints3: q, frames: ot };
1019
- }
1020
- const l = i[t.head.on], a = t.headPose?.(e) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, f = l.frames[l.frames.length - 1], g = t.head.size / 2 * o, m = g * a.sx, c = g * a.sy, d = (w) => pt(ht(Ie(Ae(w, -K(a.tilt)), -K(a.nod)), K(a.yaw)), f), u = Tt(l.joints3[l.joints3.length - 1], d([0, c, 0])), y = {};
1021
- for (const w of t.chains) {
1022
- const { joints3: S, frames: v } = i[w.id], A = S.map((W) => vt(W, s));
1023
- y[w.id] = {
1024
- id: w.id,
1025
- joints3: S,
1026
- frames: v,
1027
- points: A.map((W) => W.point),
1028
- depths: A.map((W) => W.depth)
1029
- };
1030
- }
1031
- const p = vt(u, s), x = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((w) => ht(d(w), s)), E = vt(h, s).point, b = K(e.roll ?? 0), M = (w) => {
1032
- const S = w.x - E.x, v = w.y - E.y;
1033
- return { x: E.x + S * Math.cos(b) - v * Math.sin(b), y: E.y + S * Math.sin(b) + v * Math.cos(b) };
1034
- }, T = ([w, S, v]) => [w * Math.cos(b) + S * Math.sin(b), -w * Math.sin(b) + S * Math.cos(b), v];
1035
- for (const w of Object.values(y)) w.points = w.points.map(M);
1036
- const P = {
1037
- center: M(p.point),
1038
- depth: p.depth,
1039
- rx: m,
1040
- ry: c,
1041
- angle: 0,
1042
- axes: x.map(T)
1043
- }, I = P.axes[1];
1044
- P.angle = Math.atan2(I[0], I[1]);
1045
- const O = (w) => {
1046
- if ("head" in w) return { x: P.center.x + I[0] * c, y: P.center.y - I[1] * c };
1047
- const S = y[w.chain];
1048
- return S.points[Math.min(w.joint, S.points.length - 1)];
1049
- };
1050
- let H = 0;
1051
- (n.contact ?? "ground") === "ground" && (H = -Math.max(...t.contacts.map((w) => O(w).y))), H -= (e.lift ?? 0) * o;
1052
- const _ = (w) => ({ x: w.x, y: w.y + H });
1053
- for (const w of Object.values(y)) w.points = w.points.map(_);
1054
- P.center = _(P.center);
1055
- const k = t.contacts.map((w) => ({ spec: w, point: O(w) }));
1056
- return {
1057
- height: o,
1058
- view: s,
1059
- chains: y,
1060
- head: P,
1061
- hip: _(M(E)),
1062
- contacts: k,
1063
- groundY: Math.max(...k.map((w) => w.point.y))
1064
- };
1065
- }
1066
- function Oe(t, [e, n, o]) {
1067
- const [s, r, h] = t.axes, i = [
1068
- s[0] * e * t.rx + r[0] * n * t.ry + h[0] * o * t.rx,
1069
- s[1] * e * t.rx + r[1] * n * t.ry + h[1] * o * t.rx,
1070
- s[2] * e * t.rx + r[2] * n * t.ry + h[2] * o * t.rx
1071
- ], l = Math.hypot(e, n, o) || 1, a = (s[2] * e + r[2] * n + h[2] * o) / l;
1072
- return { point: { x: t.center.x + i[0], y: t.center.y - i[1] }, depth: t.depth + i[2], facing: a };
1073
- }
1074
- const dt = (t) => t * 180 / Math.PI, Q = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], It = (t, e) => t[0] * e[0] + t[1] * e[1] + t[2] * e[2], it = (t) => Math.hypot(t[0], t[1], t[2]), Nt = (t) => {
1075
- const e = it(t) || 1;
1076
- return [t[0] / e, t[1] / e, t[2] / e];
1077
- }, ut = (t) => Math.atan2(Math.sin(t), Math.cos(t));
1078
- function ie(t) {
1079
- const [e, n, o] = Nt(t);
1080
- return { swing: Math.asin(Math.max(-1, Math.min(1, o))), spread: Math.atan2(e, -n) };
1081
- }
1082
- function Cn(t, e, n, o, s) {
1083
- const r = t.chains.find((H) => H.id === n);
1084
- if (!r) throw new Error(`reach: no chain ${n} in ${t.id}`);
1085
- if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
1086
- if (!t.withAngles) throw new Error(`reach: the ${t.id} plan cannot set angles`);
1087
- const h = Dt(t, { ...e, turn: 0, roll: 0, lift: 0 }, { height: s.height, contact: "none" }), i = h.chains[n], l = i.joints3[0], a = it(Q(i.joints3[1], i.joints3[0])), f = it(Q(i.joints3[2], i.joints3[1])), g = r.parent ? h.chains[r.parent].frames[Math.max(0, (r.at ?? h.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, m = Q(o, l), c = Math.min(a + f - 1e-6, Math.max(Math.abs(a - f) + 1e-6, it(m))), d = Nt(m), u = r.parent !== null, y = pt(r.pole ?? (u ? [0, -0.35, -1] : [0, 0, 1]), g);
1088
- let p = Q(y, [d[0] * It(y, d), d[1] * It(y, d), d[2] * It(y, d)]);
1089
- it(p) < 1e-6 && (p = ht([1, 0, 0], 0)), p = Nt(p);
1090
- const x = (a * a + c * c - f * f) / (2 * a * c), E = Math.sqrt(Math.max(0, 1 - x * x)), b = [
1091
- l[0] + a * (x * d[0] + E * p[0]),
1092
- l[1] + a * (x * d[1] + E * p[1]),
1093
- l[2] + a * (x * d[2] + E * p[2])
1094
- ], M = [l[0] + d[0] * c, l[1] + d[1] * c, l[2] + d[2] * c], T = r.side ?? 1, P = ie(Q(b, l)), I = ie(Q(M, b)), O = [
1095
- { swing: dt(ut(P.swing - g.swing)), spread: dt(ut(P.spread - g.spread)) * T },
1096
- { swing: dt(ut(I.swing - P.swing)), spread: dt(ut(I.spread - P.spread)) * T }
1097
- ];
1098
- return t.withAngles(e, r, O);
1099
- }
1100
- const Un = 0.34, G = 0.12, N = -0.4, U = (t, e, n) => t[e] ?? n, Xn = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), Dn = 0.45, qn = 0.35, Kn = 0.7;
1101
- function Mt(t, e, n) {
1102
- const o = (c) => Math.sqrt(Math.max(0, 1 - c.x * c.x - c.y * c.y)), s = Oe(t, [n.x, n.y, o(n)]).facing, r = t.axes[2], h = Math.atan2(r[0], r[2]), i = Math.cos(h), l = i >= 0 ? 1 : -1, a = l * Math.max(qn, Math.abs(i)), f = l * Math.max(Kn, Math.abs(i)), g = Math.cos(t.angle), m = Math.sin(t.angle);
1824
+ const qo = {
1825
+ leftHip: -55,
1826
+ leftKnee: -95,
1827
+ rightHip: 55,
1828
+ rightKnee: 95,
1829
+ leftShoulder: 45,
1830
+ rightShoulder: -45,
1831
+ leftElbow: 10,
1832
+ rightElbow: -10,
1833
+ lean: 22,
1834
+ stretch: 0.94,
1835
+ headTilt: 6
1836
+ }, Uo = {
1837
+ leftHip: 0,
1838
+ leftKnee: 0,
1839
+ rightHip: 0,
1840
+ rightKnee: 0,
1841
+ leftAnkle: 55,
1842
+ rightAnkle: 55,
1843
+ leftShoulder: -172,
1844
+ rightShoulder: 172,
1845
+ leftElbow: 0,
1846
+ rightElbow: 0,
1847
+ lean: 0,
1848
+ stretch: 1.08,
1849
+ headTilt: 0
1850
+ }, Se = {
1851
+ leftHip: -128,
1852
+ leftKnee: -152,
1853
+ rightHip: 128,
1854
+ rightKnee: 152,
1855
+ leftAnkle: 30,
1856
+ rightAnkle: 30,
1857
+ leftShoulder: -78,
1858
+ rightShoulder: 78,
1859
+ leftElbow: -48,
1860
+ rightElbow: 48,
1861
+ lean: 26,
1862
+ stretch: 1,
1863
+ headTilt: 14
1864
+ }, zo = {
1865
+ leftHip: -22,
1866
+ leftKnee: -30,
1867
+ rightHip: 22,
1868
+ rightKnee: 30,
1869
+ leftAnkle: 10,
1870
+ rightAnkle: 10,
1871
+ leftShoulder: -125,
1872
+ rightShoulder: 125,
1873
+ leftElbow: 0,
1874
+ rightElbow: 0,
1875
+ lean: 8,
1876
+ headTilt: 0
1877
+ }, Go = {
1878
+ leftHip: -58,
1879
+ leftKnee: -100,
1880
+ rightHip: 58,
1881
+ rightKnee: 100,
1882
+ leftAnkle: 0,
1883
+ rightAnkle: 0,
1884
+ leftShoulder: -80,
1885
+ rightShoulder: 80,
1886
+ leftElbow: -10,
1887
+ rightElbow: 10,
1888
+ lean: 20,
1889
+ stretch: 0.93
1890
+ };
1891
+ function ae(e, t, n, o, r, l = 1300) {
1103
1892
  return {
1104
- facing: s,
1105
- points: e.map((c) => {
1106
- const d = Dn * Math.sin(h) + n.x * a + (c.x - n.x) * f, u = c.y + r[1] * o(c), y = d * t.rx, p = u * t.ry;
1107
- return { x: t.center.x + y * g + p * m, y: t.center.y + y * m - p * g };
1108
- })
1893
+ label: e,
1894
+ view: 1,
1895
+ spin: t,
1896
+ height: n,
1897
+ travel: o,
1898
+ takeoff: 0.27,
1899
+ landing: 0.8,
1900
+ duration: l,
1901
+ keys: [
1902
+ { at: 0, reset: !0 },
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" },
1908
+ { at: 1, reset: !0 }
1909
+ ]
1109
1910
  };
1110
1911
  }
1111
- const gt = (t, e, n, o = 12) => Array.from({ length: o + 1 }, (s, r) => {
1112
- const h = r / o, i = 1 - h;
1113
- return { x: i * i * t.x + 2 * i * h * e.x + h * h * n.x, y: i * i * t.y + 2 * i * h * e.y + h * h * n.y };
1114
- }), At = (t, e, n, o, s = 16) => Array.from({ length: s }, (r, h) => {
1115
- const i = Math.PI * 2 * h / s;
1116
- return { x: t + Math.cos(i) * n, y: e + Math.sin(i) * o };
1117
- }), le = 0.05;
1118
- function Gn(t, e, n, o) {
1119
- const s = Math.max(1, Math.min(o * 0.6, 0.14 * e.rx)), r = (p, x) => Mt(e, p, x).points, h = (p, x) => Mt(e, [], { x: p, y: x }).facing, i = U(n, "smile", 0), l = U(n, "blink", 0), a = U(n, "lookX", 0), f = U(n, "lookY", 0), g = U(n, "browTilt", 0);
1120
- for (const p of [1, -1]) {
1121
- const x = p === 1 ? "left" : "right", E = Un * p;
1122
- if (h(E, G) < le) continue;
1123
- const b = { x: E, y: G }, M = Xn(U(n, `eye.${x}`, 1), l);
1124
- if (M < 0.2) {
1125
- const O = i > 0.5 ? 0.12 : -0.06;
1126
- t.line(r(gt({ x: E - 0.12, y: G }, { x: E, y: G + O }, { x: E + 0.12, y: G }), b), s);
1127
- } else {
1128
- if (M > 1.2) {
1129
- const k = 0.13 * M;
1130
- t.shape(r(At(E, G, k * 0.85, k), b), "#ffffff", s);
1131
- }
1132
- const O = M > 1.2 ? 0.075 : 0.1, H = E + a * 0.08, _ = G - f * 0.07;
1133
- t.shape(r(At(H, _, O, O * 1.1 * Math.min(M, 1)), b), t.ink, 0);
1134
- }
1135
- const T = G + 0.3 + U(n, `brow.${x}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, P = { x: E + p * 0.13, y: T }, I = { x: E - p * 0.13, y: T + g * 0.1 };
1136
- t.line(r([P, { x: (P.x + I.x) / 2, y: (P.y + I.y) / 2 }, I], { x: E, y: T }), s);
1137
- }
1138
- const m = { x: 0, y: N };
1139
- if (h(0, N) < -le) return;
1140
- const c = 0.25 * Math.max(0.3, U(n, "mouthWidth", 1)), d = Math.min(1, Math.max(0, U(n, "mouth", 0)));
1141
- if (d <= 0.05) {
1142
- t.line(r(gt({ x: -c, y: N }, { x: 0, y: N - i * 0.25 }, { x: c, y: N }), m), s);
1143
- return;
1144
- }
1145
- const u = 0.3 * d;
1146
- let y;
1147
- if (i > 0.3) {
1148
- const p = N + 0.05;
1149
- y = [...gt({ x: c, y: p }, { x: 0, y: N - u * 2 }, { x: -c, y: p })];
1150
- } else if (i < -0.3) {
1151
- const p = N - u * 0.6;
1152
- y = [...gt({ x: c, y: p }, { x: 0, y: N + u * 1.4 }, { x: -c, y: p })];
1153
- } else
1154
- y = At(0, N, c * 0.8, u);
1155
- t.shape(r(y, m), t.ink, 0);
1156
- }
1157
- const Ot = 0.215, _t = 0.205, Jn = 0.065, he = 0.035, zn = 0.165, jn = 0.155, Zn = 12, z = {
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 }
1916
+ ]),
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 } }
1920
+ ]),
1921
+ layout: ae("Back layout (straight body)", -360, 0.66, -0.2, [
1922
+ // Arched, arms overhead, legs together and long.
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 } },
1924
+ { at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
1925
+ ], 1400),
1926
+ scissorFlip: ae("Scissor flip", 360, 0.6, 0.45, [
1927
+ // The legs scissor through the turn: left kicks high, then they switch.
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" },
1929
+ { at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
1930
+ { at: 0.66, pose: { leftHip: -30, leftKnee: -20, rightHip: 30, rightKnee: 20, leftShoulder: -110, rightShoulder: 110, lean: 6 } }
1931
+ ]),
1932
+ sideFlip: {
1933
+ label: "Side flip (tuck)",
1934
+ view: 0,
1935
+ spin: 360,
1936
+ height: 0.55,
1937
+ travel: 0.4,
1938
+ takeoff: 0.27,
1939
+ landing: 0.8,
1940
+ duration: 1300,
1941
+ keys: [
1942
+ { at: 0, reset: !0 },
1943
+ { at: 0.16, pose: { leftHip: 22, rightHip: 22, leftKnee: 44, rightKnee: 44, leftShoulder: 20, rightShoulder: 20, lean: -10, stretch: 0.94 } },
1944
+ { at: 0.27, pose: { leftHip: 4, rightHip: 4, leftKnee: 0, rightKnee: 0, leftAnkle: 55, rightAnkle: 55, leftShoulder: 165, rightShoulder: 165, lean: 6, stretch: 1.08 }, easing: "ease-out-quad" },
1945
+ { at: 0.38, pose: { leftHip: 105, rightHip: 105, leftKnee: 135, rightKnee: 135, leftShoulder: 40, rightShoulder: 40, leftElbow: -95, rightElbow: -95, lean: 0, stretch: 1, headTilt: 10 }, easing: "ease-out-cubic" },
1946
+ { at: 0.64, pose: {} },
1947
+ { at: 0.76, pose: { leftHip: 20, rightHip: 20, leftKnee: 20, rightKnee: 20, leftAnkle: 10, rightAnkle: 10, leftShoulder: 100, rightShoulder: 100, leftElbow: 0, rightElbow: 0, headTilt: 0 } },
1948
+ { at: 0.86, pose: { leftHip: 24, rightHip: 24, leftKnee: 48, rightKnee: 48, leftAnkle: 0, rightAnkle: 0, leftShoulder: 70, rightShoulder: 70, stretch: 0.93 }, easing: "ease-out-quad" },
1949
+ { at: 1, reset: !0 }
1950
+ ]
1951
+ },
1952
+ cartwheel: {
1953
+ label: "Cartwheel",
1954
+ view: 0,
1955
+ spin: 360,
1956
+ // Upside down half way round, the hands (arms overhead) just reach the ground.
1957
+ height: 0.155,
1958
+ travel: 0.9,
1959
+ takeoff: 0.2,
1960
+ landing: 0.86,
1961
+ duration: 1600,
1962
+ keys: [
1963
+ { at: 0, reset: !0 },
1964
+ { at: 0.12, pose: { leftShoulder: 165, rightShoulder: 165, rightHip: 30, rightKnee: 0, lean: -6 } },
1965
+ { at: 0.24, pose: { leftShoulder: 172, rightShoulder: 172, leftHip: 55, rightHip: 55, leftKnee: 0, rightKnee: 0, leftAnkle: 40, rightAnkle: 40, lean: 0 } },
1966
+ { at: 0.75, pose: {} },
1967
+ { at: 0.9, pose: { leftHip: 30, rightHip: 12, leftAnkle: 0, rightAnkle: 0, leftShoulder: 150, rightShoulder: 150 } },
1968
+ { at: 1, reset: !0 }
1969
+ ]
1970
+ },
1971
+ // Leaps: no turn, the shape is the trick.
1972
+ splitLeap: ae("Split leap (grand jeté)", 0, 0.36, 0.9, [
1973
+ // A front split in the air: front leg reaching, back leg long, arms open.
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" },
1975
+ { at: 0.64, pose: { lean: 2 } }
1976
+ ]),
1977
+ toeTouch: {
1978
+ label: "Toe touch (straddle jump)",
1979
+ view: 0,
1980
+ spin: 0,
1981
+ height: 0.36,
1982
+ travel: 0,
1983
+ takeoff: 0.27,
1984
+ landing: 0.8,
1985
+ duration: 1200,
1986
+ keys: [
1987
+ { at: 0, reset: !0 },
1988
+ { at: 0.16, pose: { leftHip: 22, rightHip: 22, leftKnee: 44, rightKnee: 44, leftShoulder: -20, rightShoulder: -20, stretch: 0.94 } },
1989
+ { at: 0.27, pose: { leftHip: 4, rightHip: 4, leftKnee: 0, rightKnee: 0, leftAnkle: 55, rightAnkle: 55, leftShoulder: 170, rightShoulder: 170, stretch: 1.06 }, easing: "ease-out-quad" },
1990
+ // Legs straddled up past level, hands reaching out toward the toes.
1991
+ { at: 0.42, pose: { leftHip: 104, rightHip: 104, leftShoulder: 96, rightShoulder: 96, leftElbow: 0, rightElbow: 0, stretch: 1, headTilt: 0 }, easing: "ease-out-cubic" },
1992
+ { at: 0.62, pose: {} },
1993
+ { at: 0.76, pose: { leftHip: 12, rightHip: 12, leftAnkle: 10, rightAnkle: 10, leftShoulder: 120, rightShoulder: 120 } },
1994
+ { at: 0.86, pose: { leftHip: 22, rightHip: 22, leftKnee: 44, rightKnee: 44, leftAnkle: 0, rightAnkle: 0, leftShoulder: 60, rightShoulder: 60, stretch: 0.94 }, easing: "ease-out-quad" },
1995
+ { at: 1, reset: !0 }
1996
+ ]
1997
+ },
1998
+ backHandspring: ae("Back handspring", -360, 0.16, -0.7, [
1999
+ // Arms reach back overhead to the ground, legs snap over.
2000
+ { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
2001
+ { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
2002
+ ], 1200)
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 = {
1158
2004
  turn: 0,
1159
2005
  lean: 0,
1160
2006
  side: 0,
@@ -1173,10 +2019,14 @@ const Ot = 0.215, _t = 0.205, Jn = 0.065, he = 0.035, zn = 0.165, jn = 0.155, Zn
1173
2019
  "leg.left.spread": 3,
1174
2020
  "leg.left.knee": 0,
1175
2021
  "leg.left.ankle": 0,
2022
+ "leg.left.toeOut": 0,
2023
+ "leg.left.rotate": 0,
1176
2024
  "leg.right.swing": 0,
1177
2025
  "leg.right.spread": 3,
1178
2026
  "leg.right.knee": 0,
1179
2027
  "leg.right.ankle": 0,
2028
+ "leg.right.toeOut": 0,
2029
+ "leg.right.rotate": 0,
1180
2030
  stretch: 1,
1181
2031
  lift: 0,
1182
2032
  roll: 0,
@@ -1192,24 +2042,33 @@ const Ot = 0.215, _t = 0.205, Jn = 0.065, he = 0.035, zn = 0.165, jn = 0.155, Zn
1192
2042
  lookX: 0,
1193
2043
  lookY: 0
1194
2044
  };
1195
- function F(t = {}) {
1196
- return { ...z, ...t };
2045
+ function G(e = {}) {
2046
+ return { ...te, ...e };
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;
1197
2056
  }
1198
- function Y(t, e) {
2057
+ function U(e, t) {
1199
2058
  const n = {};
1200
- for (const o of ["left", "right"]) for (const [s, r] of Object.entries(e)) n[`${t}.${o}.${s}`] = r;
2059
+ for (const o of ["left", "right"]) for (const [r, l] of Object.entries(t)) n[`${e}.${o}.${r}`] = l;
1201
2060
  return n;
1202
2061
  }
1203
- const Qn = {
1204
- rest: z,
1205
- wave: F({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
1206
- cheer: F({ ...Y("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
1207
- point: F({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
1208
- handsOnHips: F({ ...Y("arm", { spread: 50, bend: -105, elbow: 0 }), ...Y("leg", { spread: 9 }), smile: 0.8 }),
1209
- think: F({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
1210
- shrug: F({ ...Y("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
1211
- sit: F({ ...Y("leg", { swing: 90, knee: 90, spread: 4 }), ...Y("arm", { swing: 25, elbow: 45, spread: 8 }) }),
1212
- kneel: F({
2062
+ const tr = {
2063
+ rest: te,
2064
+ wave: G({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2065
+ cheer: G({ ...U("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2066
+ point: G({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
2067
+ handsOnHips: G({ ...U("arm", { spread: 50, bend: -105, elbow: 0 }), ...U("leg", { spread: 9 }), smile: 0.8 }),
2068
+ think: G({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
2069
+ shrug: G({ ...U("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
2070
+ sit: G({ ...U("leg", { swing: 90, knee: 90, spread: 4 }), ...U("arm", { swing: 25, elbow: 45, spread: 8 }) }),
2071
+ kneel: G({
1213
2072
  "leg.left.swing": 90,
1214
2073
  "leg.left.knee": 90,
1215
2074
  // The back thigh leans back a little so its knee meets the ground beside the
@@ -1217,114 +2076,117 @@ const Qn = {
1217
2076
  "leg.right.swing": -18,
1218
2077
  "leg.right.knee": 108,
1219
2078
  "leg.right.ankle": 16,
1220
- ...Y("arm", { swing: 20, elbow: 30 })
2079
+ ...U("arm", { swing: 20, elbow: 30 })
1221
2080
  }),
1222
- crouch: F({ ...Y("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...Y("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2081
+ crouch: G({ ...U("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...U("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
1223
2082
  // On hands and knees: the back nearly level, arms straight down, the toes
1224
2083
  // pointed back along the ground.
1225
- crawl: F({ lean: 82, "head.nod": -35, ...Y("arm", { swing: 80, elbow: 0, spread: 4 }), ...Y("leg", { knee: 92, ankle: -88 }) }),
1226
- lieDown: F({ roll: 90, ...Y("arm", { spread: 8 }), "head.nod": 0 })
2084
+ crawl: G({ lean: 82, "head.nod": -35, ...U("arm", { swing: 80, elbow: 0, spread: 4 }), ...U("leg", { knee: 92, ankle: -88 }) }),
2085
+ lieDown: G({ roll: 90, ...U("arm", { spread: 8 }), "head.nod": 0 })
1227
2086
  };
1228
- function Vn(t = {}) {
1229
- const e = t.headSize ?? 0.3, n = t.shoulderWidth ?? 0.06, o = t.hipWidth ?? 0.022, s = Math.max(0.12, 1 - e - he - (Ot + _t)), r = (l) => ({
1230
- id: `arm.${l}`,
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}`,
1231
2090
  parent: "spine",
1232
- offset: [(l === "left" ? 1 : -1) * n, -0.035, 0],
2091
+ offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
1233
2092
  rest: [0, -1, 0],
1234
- side: l === "left" ? 1 : -1,
2093
+ side: a === "left" ? 1 : -1,
1235
2094
  bones: [
1236
- { length: zn, width: [1.25, 0.9] },
1237
- { length: jn, width: [0.9, 0.75] }
2095
+ { length: Zo, width: [1.25, 0.9] },
2096
+ { length: jo, width: [0.9, 0.75] }
1238
2097
  ]
1239
- }), h = (l) => ({
1240
- id: `leg.${l}`,
2098
+ }), i = (a) => ({
2099
+ id: `leg.${a}`,
1241
2100
  parent: null,
1242
- offset: [(l === "left" ? 1 : -1) * o, 0, 0],
2101
+ offset: [(a === "left" ? 1 : -1) * o, 0, 0],
1243
2102
  rest: [0, -1, 0],
1244
- side: l === "left" ? 1 : -1,
2103
+ side: a === "left" ? 1 : -1,
1245
2104
  bones: [
1246
- { length: Ot, width: [1.45, 1.05] },
1247
- { length: _t, width: [1.05, 0.85] },
1248
- { length: Jn, 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] }
1249
2108
  ]
1250
- }), i = (l, a) => l[a] ?? z[a] ?? 0;
2109
+ }), s = (a, h) => a[h] ?? te[h] ?? 0;
1251
2110
  return {
1252
2111
  id: "human",
1253
- hipHeight: Ot + _t,
2112
+ hipHeight: Ce + De,
1254
2113
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
1255
2114
  chains: [
1256
- h("left"),
1257
- h("right"),
2115
+ i("left"),
2116
+ i("right"),
1258
2117
  {
1259
2118
  id: "spine",
1260
2119
  parent: null,
1261
2120
  rest: [0, 1, 0],
1262
2121
  bones: [
1263
- { length: s / 2, width: [1.7, 1.4] },
1264
- { length: s / 2, width: [1.4, 1.1] }
2122
+ { length: r / 2, width: [1.7, 1.4] },
2123
+ { length: r / 2, width: [1.4, 1.1] }
1265
2124
  ]
1266
2125
  },
1267
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: he, width: [1, 0.9] }] },
1268
- r("left"),
1269
- r("right")
2126
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: At, width: [1, 0.9] }] },
2127
+ l("left"),
2128
+ l("right")
1270
2129
  ],
1271
- head: { on: "neck", size: e },
2130
+ head: { on: "neck", size: t },
1272
2131
  contacts: [
1273
- ...["left", "right"].flatMap((l) => [
1274
- { chain: `leg.${l}`, joint: 1 },
1275
- { chain: `leg.${l}`, joint: 2 },
1276
- { chain: `leg.${l}`, joint: 3 },
1277
- { chain: `arm.${l}`, joint: 1 },
1278
- { chain: `arm.${l}`, 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 }
1279
2138
  ]),
1280
2139
  { chain: "spine", joint: 0 },
1281
2140
  { chain: "spine", joint: 1 },
1282
2141
  { chain: "spine", joint: 2 },
1283
2142
  { head: "top" }
1284
2143
  ],
1285
- angles(l, a) {
1286
- if (a.id === "spine") {
1287
- const c = -i(l, "lean") / 2, d = i(l, "side") / 2;
2144
+ angles(a, h) {
2145
+ if (h.id === "spine") {
2146
+ const d = -s(a, "lean") / 2, b = s(a, "side") / 2;
1288
2147
  return [
1289
- { swing: c, spread: d },
1290
- { swing: c, spread: d }
2148
+ { swing: d, spread: b },
2149
+ { swing: d, spread: b }
1291
2150
  ];
1292
2151
  }
1293
- if (a.id === "neck") return [{ swing: 0, spread: 0 }];
1294
- const [f, g] = a.id.split("."), m = (c) => i(l, `${f}.${g}.${c}`);
1295
- return f === "arm" ? [
1296
- { swing: m("swing"), spread: m("spread") },
1297
- { swing: m("elbow"), spread: m("bend") }
1298
- ] : [
1299
- { swing: m("swing"), spread: m("spread") },
1300
- { swing: -m("knee"), spread: 0 },
1301
- // The foot points forward, square to the shin, turned out a little.
1302
- { swing: 90 + m("ankle"), spread: 0, yaw: Zn * (a.side ?? 1) }
2152
+ if (h.id === "neck") return [{ swing: 0, spread: 0 }];
2153
+ const [f, g] = h.id.split("."), p = (d) => s(a, `${f}.${g}.${d}`);
2154
+ if (f === "arm")
2155
+ return [
2156
+ { swing: p("swing"), spread: p("spread") },
2157
+ { swing: p("elbow"), spread: p("bend") }
2158
+ ];
2159
+ const c = (h.side ?? 1) * p("rotate"), u = 1 - Math.cos(Vo(p("rotate")));
2160
+ return [
2161
+ { swing: p("swing"), spread: p("spread"), yaw: c },
2162
+ { swing: -p("knee"), spread: 0, yaw: c },
2163
+ // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2164
+ { swing: 90 + p("ankle") - u * (p("swing") - p("knee")), spread: 0, yaw: (Qo + p("toeOut")) * (h.side ?? 1) }
1303
2165
  ];
1304
2166
  },
1305
- withAngles(l, a, f) {
1306
- const [g, m] = a.id.split("."), c = (d) => `${g}.${m}.${d}`;
2167
+ withAngles(a, h, f) {
2168
+ const [g, p] = h.id.split("."), c = (u) => `${g}.${p}.${u}`;
1307
2169
  return g === "arm" ? {
1308
- ...l,
2170
+ ...a,
1309
2171
  [c("swing")]: f[0].swing,
1310
2172
  [c("spread")]: f[0].spread,
1311
2173
  [c("elbow")]: f[1].swing,
1312
2174
  [c("bend")]: f[1].spread
1313
- } : g === "leg" ? { ...l, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : l;
2175
+ } : g === "leg" ? { ...a, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : a;
1314
2176
  },
1315
- boneScale(l, a) {
1316
- const f = Math.min(3, Math.max(0.3, i(l, "stretch")));
1317
- 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;
1318
2180
  },
1319
- headPose(l) {
1320
- const a = Math.min(3, Math.max(0.3, i(l, "stretch")));
2181
+ headPose(a) {
2182
+ const h = Math.min(3, Math.max(0.3, s(a, "stretch")));
1321
2183
  return {
1322
- yaw: i(l, "head.turn"),
1323
- nod: i(l, "head.nod"),
1324
- tilt: i(l, "head.tilt"),
2184
+ yaw: s(a, "head.turn"),
2185
+ nod: s(a, "head.nod"),
2186
+ tilt: s(a, "head.tilt"),
1325
2187
  // The head keeps its area: taller and narrower when stretched.
1326
- sx: 1 / Math.sqrt(a),
1327
- sy: Math.sqrt(a)
2188
+ sx: 1 / Math.sqrt(h),
2189
+ sy: Math.sqrt(h)
1328
2190
  };
1329
2191
  },
1330
2192
  landmarks: {
@@ -1346,18 +2208,24 @@ function Vn(t = {}) {
1346
2208
  }
1347
2209
  };
1348
2210
  }
1349
- function vo(t) {
1350
- const e = t.split(".");
1351
- if (e.length === 3) {
1352
- const [o, s, r] = e;
1353
- return `${`${s === "left" ? "Left" : "Right"} ${o}`} · ${{
2211
+ function Dr(e) {
2212
+ const t = e.split(".");
2213
+ if (t[0] === "hand" && t.length >= 3) {
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")}`;
2216
+ }
2217
+ if (t.length === 3) {
2218
+ const [o, r, l] = t;
2219
+ return `${`${r === "left" ? "Left" : "Right"} ${o}`} · ${{
1354
2220
  swing: "forward / back",
1355
2221
  spread: "out / in",
1356
2222
  elbow: "elbow bend",
1357
2223
  bend: "forearm out / in",
1358
2224
  knee: "knee bend",
1359
- ankle: "foot tilt"
1360
- }[r] ?? r}`;
2225
+ ankle: "foot tilt",
2226
+ toeOut: "toes out / in",
2227
+ rotate: "turn out at the hip"
2228
+ }[l] ?? l}`;
1361
2229
  }
1362
2230
  return {
1363
2231
  turn: "View (front → side → back)",
@@ -1380,327 +2248,717 @@ function vo(t) {
1380
2248
  browTilt: "Brow slant",
1381
2249
  lookX: "Look left / right",
1382
2250
  lookY: "Look up / down"
1383
- }[t] ?? t;
2251
+ }[e] ?? e;
1384
2252
  }
1385
- const to = {
2253
+ const or = {
1386
2254
  leftEye: "eye.left",
1387
2255
  rightEye: "eye.right",
1388
2256
  leftBrow: "brow.left",
1389
2257
  rightBrow: "brow.right"
1390
- }, Io = Object.fromEntries(
1391
- Object.entries(X).map(([t, e]) => [
1392
- t,
1393
- Object.fromEntries(Object.entries(e).map(([n, o]) => [to[n] ?? n, o]))
2258
+ }, Xr = Object.fromEntries(
2259
+ Object.entries(J).map(([e, t]) => [
2260
+ e,
2261
+ Object.fromEntries(Object.entries(t).map(([n, o]) => [or[n] ?? n, o]))
1394
2262
  ])
1395
2263
  );
1396
- function Ao(t = {}) {
1397
- const e = (t.proportions ?? "bold") === "bold", n = t.figure ?? "fluid", o = t.look ?? "clean", s = t.height ?? 300, r = n === "stick";
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 = [
2266
+ { stick: "right", human: "left", s: 1 },
2267
+ { stick: "left", human: "right", s: -1 }
2268
+ ];
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));
2274
+ }
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;
2278
+ }
2279
+ const rr = 70;
2280
+ function lr(e, t, n, o) {
2281
+ const r = e === "right" ? 1 - o : 1 + o, l = {};
2282
+ for (const i of Object.keys(R)) l[`hand.${e}.${i}`] = t[i] ?? R[i];
2283
+ return l[`hand.${e}.turn`] = (t.turn ?? 0) - r, l[`hand.${e}.roll`] = (t.roll ?? 0) + n, l;
2284
+ }
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 }],
2290
+ [{ x: i, y: -l }, { x: i, y: l }],
2291
+ [{ x: s, y: -l }, { x: s, y: l }]
2292
+ ];
2293
+ for (const h of a) nn(e, h, o);
2294
+ e.restore();
2295
+ }
2296
+ function Vt(e, t, n = {}, o) {
2297
+ const r = n.length ?? 90, l = n.thickness ?? 34;
2298
+ e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
2299
+ const i = -l / 2;
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";
2301
+ const s = [
2302
+ { x: 0, y: i },
2303
+ { x: r, y: i },
2304
+ { x: r, y: -i },
2305
+ { x: 0, y: -i },
2306
+ { x: 0, y: i }
2307
+ ], a = [{ x: r * 0.45, y: i }, { x: r * 0.45, y: -i }];
2308
+ if (o)
2309
+ o.line(s), o.line(a);
2310
+ else
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);
2314
+ e.stroke();
2315
+ }
2316
+ e.restore();
2317
+ }
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,
2328
+ angle: b * 180 / Math.PI,
2329
+ skin: l,
2330
+ ink: i,
2331
+ lineWidth: 3 * s,
2332
+ prop: {
2333
+ depth: w.depth,
2334
+ draw: () => {
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();
2336
+ }
2337
+ }
2338
+ });
2339
+ }
2340
+ const Kt = (e) => ({
2341
+ x: e.reduce((t, n) => t + n.x, 0) / e.length,
2342
+ y: e.reduce((t, n) => t + n.y, 0) / e.length
2343
+ });
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) => {
2358
+ const b = Math.min(1, Math.max(0, d));
2359
+ return b * b * (3 - 2 * b);
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 };
2364
+ }
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];
2366
+ if (p && c && c.start - p.end <= i) {
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 };
2369
+ }
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 };
2373
+ }
2374
+ if (p && t - p.end <= l) {
2375
+ const d = (t - p.end) / l;
2376
+ return { at: f(u(p), o, h(d)), tool: a(p), lift: h(d), drawing: !1 };
2377
+ }
2378
+ return null;
2379
+ }
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 });
2385
+ }
2386
+ return i;
2387
+ }
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;
2390
+ return {
2391
+ type: "custom",
2392
+ x: r,
2393
+ y: l,
2394
+ width: Math.max(1, Math.max(...n) - r),
2395
+ height: Math.max(1, Math.max(...o) - l),
2396
+ props: { draw: 0 },
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);
2402
+ }
2403
+ };
2404
+ }
2405
+ function hr(e) {
2406
+ const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2407
+ if (!t) return "rgba(0, 0, 0, 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)`;
2410
+ }
2411
+ function nn(e, t, n) {
2412
+ if (!(t.length < 2)) {
2413
+ if (n) return n.line(t);
2414
+ e.beginPath(), e.moveTo(t[0].x, t[0].y);
2415
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
2416
+ e.stroke();
2417
+ }
2418
+ }
2419
+ const Ee = 1e5;
2420
+ function Jr(e, t, n, o, r = 6) {
2421
+ const l = [], i = Math.max(1, Math.round(r));
2422
+ for (let s = 0; s <= i; s++)
2423
+ l.push({ x: s % 2 === 0 ? e : e + n, y: t + o * s / i });
2424
+ return l;
2425
+ }
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");
2430
+ };
2431
+ for (const s of r)
2432
+ i(() => {
2433
+ e.moveTo(s.x + l, s.y), e.arc(s.x, s.y, l, 0, Math.PI * 2);
2434
+ });
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);
2437
+ if (f === 0) continue;
2438
+ const g = -(h.y - a.y) / f * l, p = (h.x - a.x) / f * l;
2439
+ i(() => {
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();
2441
+ });
2442
+ }
2443
+ }
2444
+ function Zr(e, t, n, o, r) {
2445
+ e.save(), on(e, t, n, o), r(), e.restore();
2446
+ }
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;
2449
+ return {
2450
+ ...e,
2451
+ props: { ...e.props, erase: 0 },
2452
+ draw(l, i, s) {
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);
2457
+ }
2458
+ };
2459
+ }
2460
+ const oe = (e) => e * Math.PI / 180;
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];
2464
+ }
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];
2468
+ }
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];
2472
+ }
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);
2476
+ return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2477
+ }
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 = {};
2480
+ for (const y of e.chains) {
2481
+ const x = y.parent ? s[y.parent] : void 0;
2482
+ if (y.parent && !x) throw new Error(`body plan ${e.id}: chain ${y.id} comes before its parent ${y.parent}`);
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 = [];
2484
+ let ne = P.swing, Fe = P.spread;
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 * _)));
2490
+ }), s[y.id] = { joints3: L, frames: Q };
2491
+ }
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 = {};
2493
+ for (const y of e.chains) {
2494
+ const { joints3: x, frames: O } = s[y.id], K = x.map((P) => qe(P, r));
2495
+ b[y.id] = {
2496
+ id: y.id,
2497
+ joints3: x,
2498
+ frames: O,
2499
+ points: K.map((P) => P.point),
2500
+ depths: K.map((P) => P.depth)
2501
+ };
2502
+ }
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];
2507
+ for (const y of Object.values(b)) y.points = y.points.map(H);
2508
+ const E = {
2509
+ center: H(m.point),
2510
+ depth: m.depth,
2511
+ rx: p,
2512
+ ry: c,
2513
+ angle: 0,
2514
+ axes: w.map(k)
2515
+ }, T = E.axes[1];
2516
+ E.angle = Math.atan2(T[0], T[1]);
2517
+ const A = (y) => {
2518
+ if ("head" in y) return { x: E.center.x + T[0] * c, y: E.center.y - T[1] * c };
2519
+ const x = b[y.chain];
2520
+ return x.points[Math.min(y.joint, x.points.length - 1)];
2521
+ };
2522
+ let I = 0;
2523
+ (n.contact ?? "ground") === "ground" && (I = -Math.max(...e.contacts.map((y) => A(y).y))), I -= (t.lift ?? 0) * o;
2524
+ const W = (y) => ({ x: y.x, y: y.y + I });
2525
+ for (const y of Object.values(b)) y.points = y.points.map(W);
2526
+ E.center = W(E.center);
2527
+ const v = e.contacts.map((y) => ({ spec: y, point: A(y) }));
1398
2528
  return {
1399
- plan: t.plan ?? Vn({
1400
- headSize: t.headSize ?? (e ? 0.3 : 0.24),
1401
- shoulderWidth: r ? 0 : t.shoulderWidth ?? 0.06,
1402
- hipWidth: r ? 0 : t.hipWidth ?? 0.022
2529
+ height: o,
2530
+ view: r,
2531
+ chains: b,
2532
+ head: E,
2533
+ hip: W(H(S)),
2534
+ contacts: v,
2535
+ groundY: Math.max(...v.map((y) => y.point.y))
2536
+ };
2537
+ }
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 };
2545
+ }
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;
2548
+ return [e[0] / t, e[1] / t, e[2] / t];
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) };
2553
+ }
2554
+ function fr(e, t, n, o, r) {
2555
+ const l = e.chains.find((I) => I.id === n);
2556
+ if (!l) throw new Error(`reach: no chain ${n} in ${e.id}`);
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`);
2558
+ if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
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 }
2569
+ ];
2570
+ return e.withAngles(t, l, A);
2571
+ }
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;
2573
+ function Be(e, t, n) {
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);
2575
+ return {
2576
+ facing: r,
2577
+ points: t.map((c) => {
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 };
2580
+ })
2581
+ };
2582
+ }
2583
+ const ve = (e, t, n, o = 12) => Array.from({ length: o + 1 }, (r, l) => {
2584
+ const i = l / o, s = 1 - i;
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 };
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);
2592
+ for (const m of [1, -1]) {
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);
2596
+ if (H < 0.2) {
2597
+ const A = s > 0.5 ? 0.12 : -0.06;
2598
+ e.line(l(ve({ x: S - 0.12, y: re }, { x: S, y: re + A }, { x: S + 0.12, y: re }), M), r);
2599
+ } else {
2600
+ if (H > 1.2) {
2601
+ const v = 0.13 * H;
2602
+ e.shape(l(ze(S, re, v * 0.85, v), M), "#ffffff", r);
2603
+ }
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);
2606
+ }
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);
2609
+ }
2610
+ const p = { x: 0, y: j };
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);
2615
+ return;
2616
+ }
2617
+ const d = 0.3 * u;
2618
+ let b;
2619
+ if (s > 0.3) {
2620
+ const m = j + 0.05;
2621
+ b = [...ve({ x: c, y: m }, { x: 0, y: j - d * 2 }, { x: -c, y: m })];
2622
+ } else if (s < -0.3) {
2623
+ const m = j - d * 0.6;
2624
+ b = [...ve({ x: c, y: m }, { x: 0, y: j + d * 1.4 }, { x: -c, y: m })];
2625
+ } else
2626
+ b = ze(0, j, c * 0.8, d);
2627
+ e.shape(l(b, p), e.ink, 0);
2628
+ }
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";
2631
+ return {
2632
+ plan: e.plan ?? nr({
2633
+ headSize: e.headSize ?? (t ? 0.3 : 0.24),
2634
+ shoulderWidth: l ? 0 : e.shoulderWidth ?? 0.06,
2635
+ hipWidth: l ? 0 : e.hipWidth ?? 0.022
1403
2636
  }),
1404
2637
  figure: n,
1405
2638
  look: o,
1406
- height: s,
1407
- lineWidth: t.lineWidth ?? s * (e ? 0.045 : 0.022),
1408
- ink: t.ink ?? (o === "pencil" ? "#2f2f33" : "#1e293b"),
1409
- skin: t.skin ?? (o === "pencil" ? "none" : "#ffffff"),
1410
- seed: t.seed ?? 1,
1411
- pencil: t.pencil ?? {},
1412
- layers: t.layers ?? {},
1413
- contact: t.contact ?? "ground",
1414
- hands: t.hands ?? "dot",
1415
- handSize: t.handSize ?? 0.17
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"),
2643
+ seed: e.seed ?? 1,
2644
+ pencil: e.pencil ?? {},
2645
+ layers: e.layers ?? {},
2646
+ contact: e.contact ?? "ground",
2647
+ hands: e.hands ?? "dot",
2648
+ handStyle: e.handStyle ?? "glove",
2649
+ handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
1416
2650
  };
1417
2651
  }
1418
- function Oo(t, e, n, o) {
1419
- const { point: s, facing: r } = Oe(t, [e, n, o]);
1420
- return { point: s, facing: r };
1421
- }
1422
- const Ct = (t) => t.rest[1] < -0.5, eo = 0.3;
1423
- function no(t, e, n) {
1424
- return t.figure === "stick" ? Ct(e) ? n.slice(0, 3) : n : Ct(e) && n.length >= 3 ? tt(n[0], n[1], n[2], eo) : n.length === 3 ? tt(n[0], n[1], n[2], 1) : n;
1425
- }
1426
- function qt(t, e) {
1427
- const n = t.plan.id === "human" ? { ...z, ...e } : e, o = Dt(t.plan, n, { height: t.height, contact: t.contact }), s = {}, r = {}, h = {}, i = 0.01 * t.height;
1428
- t.plan.chains.forEach((c) => {
1429
- const d = o.chains[c.id];
1430
- s[c.id] = d.points;
1431
- const u = d.depths.reduce((E, b) => E + b, 0) / d.depths.length, y = c.parent ? o.chains[c.parent] : void 0, p = y ? y.depths[c.at ?? y.depths.length - 1] : 0, x = u - p;
1432
- h[c.id] = Math.abs(x) < i ? 0 : x, r[c.id] = { points: no(t, c, d.points), depth: u };
1433
- }), r.head = { points: [o.head.center], depth: o.head.depth }, h.head = 0;
1434
- const l = [...t.plan.chains.map((c) => c.id), "head"], a = [...l].sort((c, d) => h[c] - h[d] || l.indexOf(c) - l.indexOf(d)), f = { hip: o.hip };
1435
- for (const [c, [d, u]] of Object.entries(t.plan.landmarks ?? {})) {
1436
- const y = o.chains[d]?.points;
1437
- y && (f[c] = y[Math.min(u, y.length - 1)]);
2652
+ function Vr(e, t, n, o) {
2653
+ const { point: r, facing: l } = sn(e, [t, n, o]);
2654
+ return { point: r, facing: l };
2655
+ }
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;
2659
+ }
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;
2662
+ e.plan.chains.forEach((c) => {
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;
2671
+ b && (f[c] = b[Math.min(d, b.length - 1)]);
1438
2672
  }
1439
2673
  const g = {};
1440
- for (const [c, d] of Object.entries(f)) g[c] = d.y >= o.groundY - 0.01 * t.height;
1441
- const m = {
1442
- height: t.height,
1443
- lineWidth: t.lineWidth,
2674
+ for (const [c, u] of Object.entries(f)) g[c] = u.y >= o.groundY - 0.01 * e.height;
2675
+ const p = {
2676
+ height: e.height,
2677
+ lineWidth: e.lineWidth,
1444
2678
  turn: n.turn ?? 0,
1445
2679
  points: f,
1446
- chains: s,
1447
- parts: r,
2680
+ chains: r,
2681
+ parts: l,
1448
2682
  head: o.head,
1449
2683
  groundY: o.groundY,
1450
2684
  grounded: g
1451
2685
  };
1452
- return { skeleton: o, joints: m, order: a };
2686
+ return { skeleton: o, joints: p, order: h };
1453
2687
  }
1454
- function oo(t, e) {
1455
- return qt(t, e).joints;
2688
+ function wr(e, t) {
2689
+ return gt(e, t).joints;
1456
2690
  }
1457
- function so(t, e, n) {
2691
+ function kr(e, t, n) {
1458
2692
  const { head: o } = n;
1459
- t.guideEllipse(o.center.x, o.center.y, o.rx * 1.03, o.ry * 1.03, o.angle);
1460
- const s = Array.from({ length: 13 }, (l, a) => ({ x: 0, y: -0.95 + 1.9 * a / 12 })), r = Array.from({ length: 13 }, (l, a) => ({ x: -0.95 + 1.9 * a / 12, y: 0.12 })), h = Mt(o, s, { x: 0, y: 0 });
1461
- h.facing > 0 && t.guide(h.points), t.guide(Mt(o, r, { x: 0, y: 0.12 }).points), t.guide(n.chains.spine ?? []);
1462
- const i = e.lineWidth * 0.9;
1463
- for (const l of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
1464
- const a = n.points[l];
1465
- a && t.guideEllipse(a.x, a.y, i, i, 0);
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 ?? []);
2696
+ const s = t.lineWidth * 0.9;
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);
1466
2700
  }
1467
2701
  }
1468
- function ro(t, e, n, o, s, r) {
1469
- const h = n.lineWidth;
1470
- if (s === "head") {
1471
- const { head: c } = o, d = n.skin === "none" ? null : n.skin;
1472
- e.ellipse(c.center.x, c.center.y, c.rx, c.ry, c.angle, d, h), e.look !== "silhouette" && Gn(e, c, r, h);
2702
+ function Sr(e, t, n, o, r, l) {
2703
+ const i = n.lineWidth;
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);
1473
2707
  return;
1474
2708
  }
1475
- const i = n.plan.chains.find((c) => c.id === s), l = o.chains[s], a = o.parts[s].points;
2709
+ const s = n.plan.chains.find((c) => c.id === r), a = o.chains[r], h = o.parts[r].points;
1476
2710
  if (n.figure === "stick") {
1477
- if (s === "neck") return;
1478
- const c = s === "spine" ? [...l, ...o.chains.neck?.slice(1) ?? []] : a;
1479
- e.line(c, h);
2711
+ if (r === "neck") return;
2712
+ const c = r === "spine" ? [...a, ...o.chains.neck?.slice(1) ?? []] : h;
2713
+ t.line(c, i);
1480
2714
  return;
1481
2715
  }
1482
- const f = (c, d) => [i.bones[c].width[0] * h, i.bones[d].width[1] * h];
1483
- if (Ct(i)) {
1484
- const [c, d] = f(0, 1);
1485
- if (e.limb(a, c, d), i.bones.length >= 3)
1486
- e.limb([l[2], l[3]], i.bones[2].width[0] * h, i.bones[2].width[1] * h);
1487
- else if (n.hands === "cartoon" && s.startsWith("arm."))
1488
- lo(t, e, n, l, s.endsWith(".left") ? "left" : "right", r);
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);
1489
2723
  else {
1490
- const u = l[l.length - 1];
1491
- e.dot(u.x, u.y, h * 0.62);
2724
+ const d = a[a.length - 1];
2725
+ t.dot(d.x, d.y, i * 0.62);
1492
2726
  }
1493
2727
  return;
1494
2728
  }
1495
- if (s === "spine") {
1496
- const c = o.points["hip.left"], d = o.points["hip.right"];
1497
- c && d && Math.hypot(c.x - d.x, c.y - d.y) > 0.5 && e.limb([c, d], h * 1.3, h * 1.3);
1498
- const [u, y] = f(0, i.bones.length - 1);
1499
- e.limb(a, u, y);
1500
- const p = o.points["shoulder.left"], x = o.points["shoulder.right"];
1501
- p && x && Math.hypot(p.x - x.x, p.y - x.y) > 0.5 && e.limb(tt(p, l[l.length - 1], x, 1, 10), h * 1.15, h * 1.15);
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);
2732
+ const [d, b] = f(0, s.bones.length - 1);
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);
1502
2736
  return;
1503
2737
  }
1504
- const [g, m] = f(0, i.bones.length - 1);
1505
- e.limb(a, g, m);
1506
- }
1507
- function io(t, e) {
1508
- const n = `hand.${e}.`, o = {};
1509
- for (const [h, i] of Object.entries(t)) h.startsWith(n) && (o[h.slice(n.length)] = i);
1510
- const s = t.turn ?? 0, r = e === "right" ? 1 - s : 1 + s;
1511
- return { ...kt, ...o, turn: r + (o.turn ?? 0) };
1512
- }
1513
- function lo(t, e, n, o, s, r) {
1514
- const h = o[o.length - 1], i = o[o.length - 2], l = Math.atan2(h.x - i.x, -(h.y - i.y)) * 180 / Math.PI;
1515
- xe(t, h, io(r, s), {
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), {
1516
2750
  size: n.handSize * n.height,
1517
- side: s,
1518
- angle: l,
1519
- pen: e,
2751
+ side: r,
2752
+ angle: a,
2753
+ pen: t,
1520
2754
  skin: n.skin === "none" ? "#ffffff" : n.skin,
1521
2755
  // A cartoon glove: three fingers and a thumb, plump enough to match the limbs.
1522
- fingers: 4,
1523
- plump: 1.6,
2756
+ // Natural: five fingers, a little fuller than a real hand so they hold up against the limbs.
2757
+ fingers: n.handStyle === "natural" ? 5 : 4,
2758
+ plump: n.handStyle === "natural" ? 1.15 : 1.6,
1524
2759
  lineWidth: n.lineWidth * 0.3
1525
2760
  });
1526
2761
  }
1527
- function ho(t, e, n, o = 0) {
1528
- const s = e.plan.id === "human" ? { ...z, ...n } : n, { joints: r, order: h } = qt(e, s), i = ke(t, {
1529
- look: e.look,
1530
- ink: e.ink,
1531
- lineWidth: e.lineWidth,
1532
- seed: e.seed,
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, {
2764
+ look: t.look,
2765
+ ink: t.ink,
2766
+ lineWidth: t.lineWidth,
2767
+ seed: t.seed,
1533
2768
  time: o,
1534
- pencil: e.pencil
1535
- }), l = (a) => {
1536
- a && (t.save(), a(t, r, i, o), t.restore());
2769
+ pencil: t.pencil
2770
+ }), a = (h) => {
2771
+ h && (e.save(), h(e, l, s, o), e.restore());
1537
2772
  };
1538
- t.save(), t.lineCap = "round", t.lineJoin = "round", e.look === "pencil" && e.pencil.construction !== !1 && so(i, e, r), l(e.layers.behind);
1539
- for (const a of h) {
1540
- const f = e.layers.parts?.[a];
1541
- l(f?.under), ro(t, i, e, r, a, s), l(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);
1542
2777
  }
1543
- l(e.layers.front), t.restore();
2778
+ a(t.layers.front), e.restore();
1544
2779
  }
1545
- function _o(t, e, n) {
1546
- const o = { ...t };
1547
- for (const [s, r] of Object.entries(e)) {
1548
- const h = t[s] ?? r;
1549
- o[s] = h + (r - h) * 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;
1550
2785
  }
1551
2786
  return o;
1552
2787
  }
1553
- function Ho(t, e, n, o) {
1554
- const s = t.plan.id === "human" ? { ...z, ...e } : e;
1555
- let r;
2788
+ function tl(e, t, n, o) {
2789
+ const r = e.plan.id === "human" ? { ...te, ...t } : t;
2790
+ let l;
1556
2791
  if (Array.isArray(o))
1557
- r = o;
2792
+ l = o;
1558
2793
  else {
1559
- const { skeleton: h } = qt(t, s), i = Dt(t.plan, { ...s, roll: 0 }, { height: t.height, contact: "none" }), l = (s.roll ?? 0) * Math.PI / 180, a = o.x - h.hip.x, f = o.y - h.hip.y, g = i.hip.x + a * Math.cos(-l) - f * Math.sin(-l), m = i.hip.y + a * Math.sin(-l) + f * Math.cos(-l), c = Math.PI / 2 * (s.turn ?? 0), d = o.depth ?? h.chains[n].depths[h.chains[n].depths.length - 1], u = Math.cos(c), y = Math.sin(c);
1560
- r = [g * u - d * y, -m, g * y + d * u];
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];
1561
2796
  }
1562
- return Cn(t.plan, s, n, r, { height: t.height });
2797
+ return fr(e.plan, r, n, l, { height: e.height });
1563
2798
  }
1564
- function Wo(t) {
1565
- const { character: e } = t, n = e.height * 0.8, o = e.height, s = e.plan.id === "human" ? z : {};
2799
+ function nl(e) {
2800
+ const { character: t } = e, n = t.height * 0.8, o = t.height, r = t.plan.id === "human" ? te : {};
1566
2801
  return {
1567
2802
  type: "custom",
1568
- x: t.x - n / 2,
1569
- y: t.y - o,
2803
+ x: e.x - n / 2,
2804
+ y: e.y - o,
1570
2805
  width: n,
1571
2806
  height: o,
1572
- props: { ...s, ...t.pose },
1573
- character: e,
1574
- draw(r, h, i) {
1575
- r.translate(n / 2, o), ho(r, e, h.props, i);
2807
+ props: { ...r, ...e.pose },
2808
+ character: t,
2809
+ draw(l, i, s) {
2810
+ l.translate(n / 2, o), Mr(l, t, i.props, s);
1576
2811
  }
1577
2812
  };
1578
2813
  }
1579
- function ao(t, e, n) {
1580
- const o = (r) => ({ x: r.x + e, y: r.y + n }), s = (r) => Object.fromEntries(Object.entries(r).map(([h, i]) => [h, i.map(o)]));
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)]));
1581
2816
  return {
1582
- ...t,
1583
- points: Object.fromEntries(Object.entries(t.points).map(([r, h]) => [r, o(h)])),
1584
- chains: s(t.chains),
1585
- parts: Object.fromEntries(Object.entries(t.parts).map(([r, h]) => [r, { ...h, points: h.points.map(o) }])),
1586
- head: { ...t.head, center: o(t.head.center) },
1587
- groundY: t.groundY + n
2817
+ ...e,
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) },
2822
+ groundY: e.groundY + n
1588
2823
  };
1589
2824
  }
1590
- function $o(t, e, n) {
1591
- const o = t.character;
2825
+ function ol(e, t, n) {
2826
+ const o = e.character;
1592
2827
  if (!o) throw new Error("characterAt: the target was not made by characterTarget");
1593
- const s = { ...t.props };
1594
- let r = 0, h = 0;
1595
- for (const [l, a] of e.state?.values.get(n) ?? [])
1596
- typeof a == "number" && (l === "x" || l === "motionPathX" ? r = a : l === "y" || l === "motionPathY" ? h = a : l in s && (s[l] = a));
1597
- const i = oo(o, s);
1598
- return { pose: s, joints: ao(i, t.x + r + t.width / 2, t.y + h + t.height) };
1599
- }
1600
- function Ro(t, e, n = z) {
2828
+ const r = { ...e.props };
2829
+ let l = 0, i = 0;
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) };
2834
+ }
2835
+ function rl(e, t, n = te) {
1601
2836
  const o = [];
1602
- return e.forEach((r, h) => {
1603
- const i = h === 0 ? n : o[h - 1], l = typeof r.pose == "string" ? Qn[r.pose] : void 0;
1604
- o.push(l ? { ...l, turn: i.turn ?? 0 } : { ...i, ...r.pose });
1605
- }), Object.keys(n).filter((r) => o.some((h) => (h[r] ?? n[r]) !== n[r])).map((r) => ({
1606
- id: `${t}-${r}`,
1607
- target: t,
1608
- property: r,
1609
- keyframes: e.map((h, i) => ({
1610
- time: h.time,
1611
- value: o[i][r] ?? n[r],
1612
- ...h.easing ? { easing: h.easing } : {}
2837
+ return t.forEach((l, i) => {
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) => ({
2841
+ id: `${e}-${l}`,
2842
+ target: e,
2843
+ property: l,
2844
+ keyframes: t.map((i, s) => ({
2845
+ time: i.time,
2846
+ value: o[s][l] ?? n[l],
2847
+ ...i.easing ? { easing: i.easing } : {}
1613
2848
  }))
1614
2849
  }));
1615
2850
  }
1616
- const co = (t, e, n) => t.slice(Math.floor((t.length - 1) * e), Math.ceil((t.length - 1) * n) + 1);
1617
- function Bo(t = {}) {
1618
- const e = t.shirt ?? "#e2493b", n = t.trousers ?? "#24476b", o = (i) => i.lineWidth * 0.45, s = (i, l, a) => {
1619
- const f = i.parts[`leg.${a}`].points;
1620
- l.shape(yt(f, i.height * 0.08, i.height * 0.05), n, o(i));
1621
- }, r = (i, l) => {
1622
- const a = i.chains.spine, f = a[0], g = a[a.length - 1], m = { x: f.x - (g.x - f.x) * 0.25, y: f.y - (g.y - f.y) * 0.25 };
1623
- l.shape(yt([m, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), e, o(i));
1624
- }, h = (i, l, a) => {
1625
- const f = i.parts[`arm.${a}`].points, g = f[0], m = i.chains.spine[i.chains.spine.length - 1], d = [{ x: g.x + (m.x - g.x) * 0.45, y: g.y + (m.y - g.y) * 0.45 }, ...co(f, 0, 0.45)], u = yt(d, i.height * 0.085, i.height * 0.06), y = d.length, p = u.slice(0, y), x = u.slice(y).reverse();
1626
- l.shape(u, e, 0);
1627
- const E = (T) => Math.hypot(T[1].x - m.x, T[1].y - m.y), [b, M] = E(p) > E(x) ? [p, x] : [x, p];
1628
- l.line(b.slice(1), o(i)), l.line(M.slice(Math.ceil(y * 0.45)), o(i)), l.line([p[y - 1], x[y - 1]], o(i));
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));
1629
2864
  };
1630
2865
  return {
1631
2866
  parts: {
1632
- "leg.left": { over: (i, l, a) => s(l, a, "left") },
1633
- "leg.right": { over: (i, l, a) => s(l, a, "right") },
1634
- spine: { over: (i, l, a) => r(l, a) },
1635
- "arm.left": { over: (i, l, a) => h(l, a, "left") },
1636
- "arm.right": { over: (i, l, a) => h(l, 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") }
1637
2872
  }
1638
2873
  };
1639
2874
  }
1640
2875
  export {
1641
- X as EXPRESSIONS,
1642
- dn as FINGERS,
1643
- kt as HAND_REST,
1644
- un as HAND_SHAPES,
1645
- Io as HUMAN_EXPRESSIONS,
1646
- Qn as HUMAN_POSES,
1647
- z as HUMAN_REST,
1648
- Ye as POSES,
1649
- et as REST_POSE,
1650
- Bo as basicOutfit,
1651
- Le as blendPose,
1652
- We as boilFrame,
1653
- Ao as character,
1654
- $o as characterAt,
1655
- io as characterHandPose,
1656
- oo as characterJoints,
1657
- Ro as characterPoseTracks,
1658
- Wo as characterTarget,
1659
- xo as circlePath,
1660
- ve as clipErased,
1661
- ke as createPen,
1662
- xe as drawCartoonHand,
1663
- ho as drawCharacter,
1664
- Ee as drawEraser,
1665
- Pe as drawHand,
1666
- Yn as drawPencil,
1667
- fn as drawStickFigure,
1668
- Eo as drawnPathTarget,
1669
- ne as ellipsePoints,
1670
- To as erasable,
1671
- ko as handAt,
1672
- Ft as handJoints,
1673
- Pn as handJointsAt,
1674
- R as handPose,
1675
- mo as headPoint,
1676
- vo as humanFieldLabel,
1677
- Vn as humanPlan,
1678
- F as humanPose,
1679
- ao as jointsInScene,
1680
- cn as jointsToScene,
1681
- Mo as mixHandPoses,
1682
- _o as mixPoses,
1683
- ae as partialPath,
1684
- Fo as pathLength,
1685
- Ut as pointAlong,
1686
- Oo as pointOnHead,
1687
- L as pose,
1688
- bo as poseTracks,
1689
- Ho as reachCharacter,
1690
- Me as resolveStickPose,
1691
- j as rotateAbout,
1692
- tt as rubberLimb,
1693
- So as scrubPath,
1694
- yo as seatHeight,
1695
- Ht as sketchPen,
1696
- wo as stickFigureAt,
1697
- an as stickFigureJoints,
1698
- po as stickFigureTarget,
1699
- go as strideLength,
1700
- Ce as talkingMouth,
1701
- Xt as taperedLine,
1702
- yt as taperedOutline,
1703
- Ne as walkPose,
1704
- Po as withErased,
1705
- Be as withExpression
2876
+ ce as DANCE_STYLES,
2877
+ J as EXPRESSIONS,
2878
+ mn as FINGERS,
2879
+ ft as FLIPS,
2880
+ R as HAND_REST,
2881
+ N as HAND_SHAPES,
2882
+ Xr as HUMAN_EXPRESSIONS,
2883
+ tr as HUMAN_POSES,
2884
+ te as HUMAN_REST,
2885
+ vt as MUDRAS,
2886
+ Fn as POSES,
2887
+ z as REST_POSE,
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,
2931
+ G as humanPose,
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,
2942
+ D as pose,
2943
+ $r as poseTracks,
2944
+ tl as reachCharacter,
2945
+ Jt as resolveStickFrame,
2946
+ go as resolveStickPose,
2947
+ ie as rotateAbout,
2948
+ ht as routineBeats,
2949
+ fe as rubberLimb,
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
1706
2964
  };