@algorisys/tinyfly 0.81.0 → 0.86.2

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