@algorisys/tinyfly 0.88.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,71 +1,71 @@
1
- import { c as mn, s as Je, p as Rt, b as lt } from "./sketch-CYPUbk3Q.js";
2
- import { a as xs } from "./sketch-CYPUbk3Q.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-CQvcFWGJ.js";
5
- function Ke(e, t, n) {
6
- const r = e.length;
7
- if (r < 2) return [];
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()];
13
- }
14
- function it(e, t, n, r) {
15
- const o = t.length;
16
- if (o < 2) return;
17
- const s = Ke(t, n, r), i = (l) => n + (r - n) * l / (o - 1);
1
+ import { c as Wn, s as tt, p as Gt, b as dt } from "./sketch-CYPUbk3Q.js";
2
+ import { a as ii } from "./sketch-CYPUbk3Q.js";
3
+ import { createRandom as On, hashSeed as De, getEasingFunction as qe, mat4 as C, vec3 as j, quat as Tt } from "@algorisys/tinyfly";
4
+ import { f as At, h as In, a as $n } from "./load-scene-CQvcFWGJ.js";
5
+ function Oe(e, t, n) {
6
+ const o = e.length;
7
+ if (o < 2) return [];
8
+ const r = [], s = [], l = (i) => t + (n - t) * i / (o - 1);
9
+ return e.forEach((i, a) => {
10
+ const h = e[Math.max(0, a - 1)], c = e[Math.min(o - 1, a + 1)], g = Math.hypot(c.x - h.x, c.y - h.y) || 1, u = l(a) / 2, f = -(c.y - h.y) / g * u, p = (c.x - h.x) / g * u;
11
+ r.push({ x: i.x + f, y: i.y + p }), s.push({ x: i.x - f, y: i.y - p });
12
+ }), [...r, ...s.reverse()];
13
+ }
14
+ function gt(e, t, n, o) {
15
+ const r = t.length;
16
+ if (r < 2) return;
17
+ const s = Oe(t, n, o), l = (i) => n + (o - n) * i / (r - 1);
18
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());
19
+ for (const i of s.slice(1)) e.lineTo(i.x, i.y);
20
+ e.closePath(), e.fill(), t.forEach((i, a) => {
21
+ a !== 0 && a !== r - 1 && r > 3 || (e.beginPath(), e.arc(i.x, i.y, l(a) / 2, 0, Math.PI * 2), e.fill());
22
22
  });
23
23
  }
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 = {
24
+ function pe(e, t, n, o, r = 16) {
25
+ const s = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, l = [];
26
+ for (let i = 0; i <= r; i++) {
27
+ const a = i / r, h = a < 0.5 ? { x: e.x + (t.x - e.x) * 2 * a, y: e.y + (t.y - e.y) * 2 * a } : { x: t.x + (n.x - t.x) * (2 * a - 1), y: t.y + (n.y - t.y) * (2 * a - 1) }, c = 1 - a, g = {
28
28
  x: c * c * e.x + 2 * c * a * s.x + a * a * n.x,
29
29
  y: c * c * e.y + 2 * c * a * s.y + a * a * n.y
30
30
  };
31
- i.push({ x: h.x + (p.x - h.x) * r, y: h.y + (p.y - h.y) * r });
31
+ l.push({ x: h.x + (g.x - h.x) * o, y: h.y + (g.y - h.y) * o });
32
32
  }
33
- return i;
33
+ return l;
34
34
  }
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 };
35
+ function xt(e, t, n, o, r, s = 0, l = 1, i = 40) {
36
+ const a = Math.cos(r), h = Math.sin(r);
37
+ return Array.from({ length: i + 1 }, (c, g) => {
38
+ const u = s + Math.PI * 2 * l * g / i, f = Math.cos(u) * n, p = Math.sin(u) * o;
39
+ return { x: e + f * a - p * h, y: t + f * h + p * a };
40
40
  });
41
41
  }
42
- function Yt(e, t) {
43
- return t.look === "pencil" ? vn(e, t) : En(e, t.ink, t.look);
42
+ function zt(e, t) {
43
+ return t.look === "pencil" ? Rn(e, t) : Bn(e, t.ink, t.look);
44
44
  }
45
- function Oe(e, t, n = !1) {
45
+ function Be(e, t, n = !1) {
46
46
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
47
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
47
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
48
48
  n && e.closePath();
49
49
  }
50
- function En(e, t, n) {
51
- const r = n === "silhouette", o = r ? 1.25 : 1;
50
+ function Bn(e, t, n) {
51
+ const o = n === "silhouette", r = o ? 1.25 : 1;
52
52
  return {
53
53
  look: n,
54
54
  ink: t,
55
- limb(s, i, l) {
56
- e.fillStyle = t, it(e, s, i * o, l * o);
55
+ limb(s, l, i) {
56
+ e.fillStyle = t, gt(e, s, l * r, i * r);
57
57
  },
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());
58
+ line(s, l) {
59
+ s.length < 2 || (e.strokeStyle = t, e.lineWidth = l * r, e.lineCap = "round", e.lineJoin = "round", Be(e, s), e.stroke());
60
60
  },
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());
61
+ shape(s, l, i) {
62
+ Be(e, s, !0), (l !== null || o) && (e.fillStyle = o ? t : l, e.fill()), !(i <= 0) && (e.strokeStyle = t, e.lineWidth = i * r, e.lineJoin = "round", e.stroke());
63
63
  },
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());
64
+ ellipse(s, l, i, a, h, c, g) {
65
+ e.beginPath(), e.ellipse(s, l, i, a, h, 0, Math.PI * 2), (c !== null || o) && (e.fillStyle = o ? t : c, e.fill()), !(g <= 0) && (e.strokeStyle = t, e.lineWidth = g * r, e.stroke());
66
66
  },
67
- dot(s, i, l) {
68
- e.fillStyle = t, e.beginPath(), e.arc(s, i, l * o, 0, Math.PI * 2), e.fill();
67
+ dot(s, l, i) {
68
+ e.fillStyle = t, e.beginPath(), e.arc(s, l, i * r, 0, Math.PI * 2), e.fill();
69
69
  },
70
70
  guide() {
71
71
  },
@@ -73,101 +73,101 @@ function En(e, t, n) {
73
73
  }
74
74
  };
75
75
  }
76
- function Hn(e, t) {
76
+ function _n(e, t) {
77
77
  const n = [e[0]];
78
- let r = 0;
79
- for (let i = 1; i < e.length; i++) {
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;
78
+ let o = 0;
79
+ for (let l = 1; l < e.length; l++) {
80
+ const i = e[l - 1], a = e[l], h = Math.hypot(a.x - i.x, a.y - i.y);
81
+ let c = t - o;
82
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;
83
+ const g = c / h;
84
+ n.push({ x: i.x + (a.x - i.x) * g, y: i.y + (a.y - i.y) * g }), c += t;
85
85
  }
86
- r = h - (c - t);
86
+ o = h - (c - t);
87
87
  }
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;
88
+ const r = e[e.length - 1], s = n[n.length - 1];
89
+ return Math.hypot(r.x - s.x, r.y - s.y) > t * 0.25 ? n.push(r) : n[n.length - 1] = r, n;
90
90
  }
91
- function Mn(e, t) {
91
+ function Fn(e, t) {
92
92
  const n = e.length;
93
- return e.map((r, o) => {
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 };
93
+ return e.map((o, r) => {
94
+ const s = e[Math.max(0, r - 1)], l = e[Math.min(n - 1, r + 1)], i = Math.hypot(l.x - s.x, l.y - s.y) || 1, a = t(n === 1 ? 0 : r / (n - 1));
95
+ return { x: o.x - (l.y - s.y) / i * a, y: o.y + (l.x - s.x) / i * a };
96
96
  });
97
97
  }
98
- function St(e) {
99
- const t = [0.6, 1.4, 2.9].map((r) => ({
100
- frequency: r * (0.8 + e.next() * 0.4),
98
+ function Kt(e) {
99
+ const t = [0.6, 1.4, 2.9].map((o) => ({
100
+ frequency: o * (0.8 + e.next() * 0.4),
101
101
  phase: e.next() * Math.PI * 2,
102
102
  amount: 0.5 + e.next() * 0.5
103
- })), n = t.reduce((r, o) => r + o.amount, 0);
104
- return (r) => t.reduce((o, s) => o + s.amount * Math.sin(Math.PI * 2 * s.frequency * r + s.phase), 0) / n;
103
+ })), n = t.reduce((o, r) => o + r.amount, 0);
104
+ return (o) => t.reduce((r, s) => r + s.amount * Math.sin(Math.PI * 2 * s.frequency * o + s.phase), 0) / n;
105
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);
106
+ function Rn(e, t) {
107
+ const n = t.pencil ?? {}, o = t.ink, r = n.roughness ?? Math.max(1, t.lineWidth * 0.12), s = Math.max(1, Math.round(n.passes ?? 2)), l = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), a = Wn(t.time, n.boil ?? 8);
108
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)));
109
+ const c = (p, d, b = !1) => On(De(`${t.seed}:${b ? "paper" : a}:${p}:${d}`)), g = (p, d, b, m, w, y = 0) => {
110
+ if (p.length < 2) return;
111
+ const H = p.slice(1).reduce((K, v, A) => K + Math.hypot(v.x - p[A].x, v.y - p[A].y), 0);
112
+ let E = _n(p, Math.max(1.5, Math.min(t.lineWidth * 0.8, H / 24)));
113
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 }];
114
+ const [K, v] = [E[E.length - 2], E[E.length - 1]], A = Math.hypot(v.x - K.x, v.y - K.y) || 1;
115
+ E = [...E, { x: v.x + (v.x - K.x) / A * y, y: v.y + (v.y - K.y) / A * y }];
116
116
  }
117
- const w = St(g), M = St(g), x = E.length, S = [], A = [];
117
+ const k = Kt(b), M = Kt(b), T = E.length, S = [], x = [];
118
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);
119
+ const A = T === 1 ? 0 : v / (T - 1), W = E[Math.max(0, v - 1)], $ = E[Math.min(T - 1, v + 1)], P = Math.hypot($.x - W.x, $.y - W.y) || 1, O = -($.y - W.y) / P, F = ($.x - W.x) / P, I = k(A) * w, L = Math.min(1, A / 0.08, (1 - A) / 0.08), G = (0.55 + 0.45 * Math.sqrt(Math.max(0, L))) * (1 + l * M(A)), J = Math.max(0.3, d(A) * G / 2), fe = K.x + O * I, He = K.y + F * I;
120
+ S.push({ x: fe + O * J, y: He + F * J }), x.push({ x: fe - O * J, y: He - F * J });
121
+ }), e.save(), e.globalAlpha *= m, e.fillStyle = o, Be(e, [...S, ...x.reverse()], !0), e.fill(), e.restore();
122
+ }, u = (p, d) => {
123
+ const b = h++, m = c(b, 99, !0);
124
+ if (m.next() < i) {
125
+ const E = (m.next() * 2 - 1) * t.lineWidth * 1.4, k = (m.next() * 2 - 1) * t.lineWidth * 1.4, M = p.map((T) => ({ x: T.x + E, y: T.y + k }));
126
+ g(M, (T) => d(T) * 1.8, c(b, 98, !0), 0.035, r), g(M, (T) => d(T) * 0.45, c(b, 97, !0), 0.12, r * 1.5);
127
127
  }
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];
128
+ const w = p.slice(1).reduce((E, k, M) => E + Math.hypot(k.x - p[M].x, k.y - p[M].y), 0), y = d(0.5) > 4 && w > d(0.5) * 6, H = y ? [-0.3, 0.3, 0] : [0];
129
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);
130
+ const k = E === 0;
131
+ H.forEach((M, T) => {
132
+ const S = c(b, E * 10 + T), x = M === 0 ? p : Fn(p, (v) => d(v) * M * Math.sqrt(Math.sin(Math.PI * v))), K = !k && M === 0 ? t.lineWidth * (0.3 + S.next() * 0.8) : 0;
133
+ g(x, (v) => d(v) * (y ? 0.5 : 1) * (k ? 1 : 0.6), S, k ? 0.85 : 0.45, r * (k ? 0.6 : 1), K);
134
134
  });
135
135
  }
136
- }, u = (b, f, g, m, k, y) => {
136
+ }, f = (p, d, b, m, w, y) => {
137
137
  const E = c(h, 50).next() * Math.PI * 2;
138
- d(kt(b, f, g, m, k, E, 1.08, 48), () => y);
138
+ u(xt(p, d, b, m, w, E, 1.08, 48), () => y);
139
139
  };
140
140
  return {
141
141
  look: "pencil",
142
- ink: r,
143
- limb(b, f, g) {
144
- d(b, (m) => f + (g - f) * m);
142
+ ink: o,
143
+ limb(p, d, b) {
144
+ u(p, (m) => d + (b - d) * m);
145
145
  },
146
- line(b, f) {
147
- d(b, () => f);
146
+ line(p, d) {
147
+ u(p, () => d);
148
148
  },
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);
149
+ shape(p, d, b) {
150
+ d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Be(e, p, !0), e.fill(), e.restore()), b > 0 && u([...p, p[0]], () => b);
151
151
  },
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);
152
+ ellipse(p, d, b, m, w, y, H) {
153
+ y !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = y, e.beginPath(), e.ellipse(p, d, b, m, w, 0, Math.PI * 2), e.fill(), e.restore()), f(p, d, b, m, w, H);
154
154
  },
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();
155
+ dot(p, d, b) {
156
+ e.save(), e.globalAlpha *= 0.9, e.fillStyle = o, e.beginPath(), e.arc(p, d, b, 0, Math.PI * 2), e.fill(), e.restore();
157
157
  },
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);
158
+ guide(p) {
159
+ if (n.construction === !1 || p.length < 2) return;
160
+ const d = h++;
161
+ g(p, () => Math.max(0.6, t.lineWidth * 0.18), c(d, 0), 0.28, r * 1.2, t.lineWidth);
162
162
  },
163
- guideEllipse(b, f, g, m, k) {
163
+ guideEllipse(p, d, b, m, w) {
164
164
  if (n.construction === !1) return;
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);
165
+ const y = h++, H = c(y, 0), E = xt(p, d, b, m, w, H.next() * Math.PI * 2, 1.12, 48);
166
+ g(E, () => Math.max(0.6, t.lineWidth * 0.18), H, 0.28, r * 1.5);
167
167
  }
168
168
  };
169
169
  }
170
- const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
170
+ const Ln = ["thumb", "index", "middle", "ring", "pinky"], _ = {
171
171
  "thumb.curl": 0.15,
172
172
  "thumb.across": 0.15,
173
173
  "index.curl": 0.12,
@@ -180,48 +180,48 @@ const xn = ["thumb", "index", "middle", "ring", "pinky"], _ = {
180
180
  tilt: 0,
181
181
  roll: 0
182
182
  };
183
- function $(e = {}) {
183
+ function B(e = {}) {
184
184
  return { ..._, ...e };
185
185
  }
186
- const q = (e, t, n, r, o) => ({
186
+ const z = (e, t, n, o, r) => ({
187
187
  "thumb.curl": e,
188
188
  "index.curl": t,
189
189
  "middle.curl": n,
190
- "ring.curl": r,
191
- "pinky.curl": o
192
- }), L = {
190
+ "ring.curl": o,
191
+ "pinky.curl": r
192
+ }), Y = {
193
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 }),
194
+ open: B({ ...z(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
195
+ spread: B({ ...z(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
196
+ flat: B({ ...z(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
197
+ fist: B({ ...z(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
198
+ point: B({ ...z(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
199
199
  /** The fist on its side, knuckles toward the viewer, the thumb up */
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 }),
200
+ thumbsUp: B({ ...z(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
201
+ peace: B({ ...z(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
202
+ ok: B({ ...z(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
203
+ pinch: B({ ...z(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
204
+ cupped: B({ ...z(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
205
+ wave: B({ ...z(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
206
206
  /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
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
+ pencilGrip: B({ ...z(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
208
208
  /** Holding a handle, a cup or a bar: every finger wrapped round it */
209
- hold: $({ ...q(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
209
+ hold: B({ ...z(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
210
210
  };
211
- function ke(e, t, n) {
212
- const r = { ...e };
213
- for (const [o, s] of Object.entries(t)) {
214
- const i = e[o] ?? s;
215
- r[o] = i + (s - i) * n;
211
+ function Ee(e, t, n) {
212
+ const o = { ...e };
213
+ for (const [r, s] of Object.entries(t)) {
214
+ const l = e[r] ?? s;
215
+ o[r] = l + (s - l) * n;
216
216
  }
217
- return r;
217
+ return o;
218
218
  }
219
- const Tn = {
219
+ const Yn = {
220
220
  index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
221
221
  middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
222
222
  ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
223
223
  pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
224
- }, An = {
224
+ }, Nn = {
225
225
  index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
226
226
  middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
227
227
  pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
@@ -232,7 +232,7 @@ const Tn = {
232
232
  /** Where the thumb points with `across` 0 and 1 */
233
233
  out: [-0.7, 0.68, -0.22],
234
234
  across: [0.35, 0.5, -0.8]
235
- }, Kn = [82, 100, 62], Pn = [48, 72], Wn = 3, On = 13, In = 0.035, Bn = -0.075, $n = [
235
+ }, Cn = [82, 100, 62], Dn = [48, 72], qn = 3, Xn = 13, Un = 0.035, Gn = -0.075, zn = [
236
236
  [-0.17, 0],
237
237
  [-0.215, 0.12],
238
238
  [-0.235, 0.26],
@@ -245,185 +245,185 @@ const Tn = {
245
245
  [0.225, 0.26],
246
246
  [0.2, 0.1],
247
247
  [0.16, 0]
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
+ ], se = (e) => e * Math.PI / 180, nt = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Ie = (e, t) => [e[0] * t, e[1] * t, e[2] * t], ot = (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]], me = (e) => {
249
249
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
250
250
  return [e[0] / t, e[1] / t, e[2] / t];
251
251
  };
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];
252
+ function he(e, t, n) {
253
+ const o = Math.cos(n), r = Math.sin(n), s = ot(t, e), l = t[0] * e[0] + t[1] * e[1] + t[2] * e[2];
254
254
  return [
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)
255
+ e[0] * o + s[0] * r + t[0] * l * (1 - o),
256
+ e[1] * o + s[1] * r + t[1] * l * (1 - o),
257
+ e[2] * o + s[2] * r + t[2] * l * (1 - o)
258
258
  ];
259
259
  }
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)));
260
+ const Pt = [1, 0, 0], Wt = [0, 1, 0], ke = [0, 0, 1];
261
+ function jn(e, t, n) {
262
+ const o = se(e.fan * (qn + Xn * n)), r = [Math.sin(o), Math.cos(o), 0], s = [Math.cos(o), -Math.sin(o), 0], l = [e.knuckle];
263
+ let i = 0;
264
+ e.bones.forEach((c, g) => {
265
+ i += se(Cn[g] * t), l.push(nt(l[g], Ie(he(r, s, -i), c)));
266
266
  });
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 };
267
+ const a = he(ke, s, -i), h = l.map((c, g) => e.width * (1 - 0.14 * (g / (l.length - 1))));
268
+ return { joints: l, back: a, widths: h };
269
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]]];
270
+ function Jn(e, t, n = 1, o = 1) {
271
+ const r = Math.min(1, Math.max(0, t)), s = me(nt(Ie(me(ne.out), 1 - r), Ie(me(ne.across), r))), l = me(ot(ke, s)), i = me(ot(s, l)), a = [[ne.base[0] * o, ne.base[1], ne.base[2]]];
272
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)));
273
+ ne.bones.forEach((u, f) => {
274
+ f > 0 && (h += se(Dn[f - 1] * e)), a.push(nt(a[f], Ie(he(s, l, h), u)));
275
275
  });
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 };
276
+ const c = he(i, l, h), g = [...ne.widths, ne.widths[ne.widths.length - 1] * 0.92].map((u) => u * n);
277
+ return { joints: a, back: c, widths: g };
278
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) => ({
279
+ function rt(e, t = {}) {
280
+ const n = { ..._, ...e }, o = t.size ?? 100, r = t.side ?? "right", s = r === "left" ? -1 : 1, l = se(t.angle ?? 0), i = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (v) => ({
281
281
  ...v,
282
282
  knuckle: [v.knuckle[0] * h, v.knuckle[1], v.knuckle[2]],
283
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 };
284
+ }), g = se(n.bend ?? 0), u = se(n.tilt ?? 0), f = se(90 * (n.turn ?? 0)), p = (v) => he(he(he(v, Pt, -g), ke, -u), Wt, f), d = Math.cos(l), b = Math.sin(l), m = se(n.roll ?? 0), w = Math.cos(m), y = Math.sin(m), H = (v) => {
285
+ const A = v[0] * o, W = -v[1] * o, $ = (A * w - W * y) * s, P = A * y + W * w;
286
+ return { x: $ * d - P * b, y: $ * b + P * d };
287
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 };
290
- }, w = {
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));
296
- }
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] = {
288
+ const A = H(v), W = Math.hypot(A.x, A.y);
289
+ return W > 1e-6 * o ? { x: A.x / W, y: A.y / W } : { x: 0, y: 0 };
290
+ }, k = {
291
+ thumb: Jn(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
292
+ }, M = i ? Nn : Yn;
293
+ for (const v of Ln) {
294
+ const A = M[v];
295
+ A && (k[v] = jn(c(A), n[`${v}.curl`] ?? 0, n.spread ?? 0));
296
+ }
297
+ const T = {};
298
+ for (const [v, A] of Object.entries(k)) {
299
+ const W = A.joints.map(p), $ = p(A.back);
300
+ T[v] = {
301
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)
302
+ depths: W.map((P) => P[2] * o),
303
+ widths: A.widths.map((P) => P * o),
304
+ nail: $[2],
305
+ back: E($)
306
306
  };
307
307
  }
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
+ const S = zn.flatMap(([v, A]) => [p([v * h, A, Un]), p([v * h, A, Gn])]), x = Zn(S.map(H)), K = S.reduce((v, A) => v + A[2], 0) / S.length * o;
309
309
  return {
310
- size: r,
311
- side: o,
310
+ size: o,
311
+ side: r,
312
312
  wrist: { x: 0, y: 0 },
313
- palm: A,
313
+ palm: x,
314
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]))
315
+ palmFacing: -p(ke)[2],
316
+ fingers: T,
317
+ axes: { up: E(p(Wt)), across: E(p(Pt)), out: E(p(ke)) },
318
+ curls: Object.fromEntries(Object.keys(T).map((v) => [v, n[`${v}.curl`] ?? 0]))
319
319
  };
320
320
  }
321
- function Rn(e, t) {
322
- const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), r = {};
323
- for (const [o, s] of Object.entries(e.fingers))
324
- r[o] = { ...s, points: s.points.map(n) };
325
- return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: r };
321
+ function Vn(e, t) {
322
+ const n = (r) => ({ x: r.x + t.x - e.wrist.x, y: r.y + t.y - e.wrist.y }), o = {};
323
+ for (const [r, s] of Object.entries(e.fingers))
324
+ o[r] = { ...s, points: s.points.map(n) };
325
+ return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: o };
326
326
  }
327
- function Yn(e) {
328
- const t = [...e].sort((s, i) => s.x - i.x || s.y - i.y);
327
+ function Zn(e) {
328
+ const t = [...e].sort((s, l) => s.x - l.x || s.y - l.y);
329
329
  if (t.length < 3) return t;
330
- const n = (s, i, l) => (i.x - s.x) * (l.y - s.y) - (i.y - s.y) * (l.x - s.x), r = [];
330
+ const n = (s, l, i) => (l.x - s.x) * (i.y - s.y) - (l.y - s.y) * (i.x - s.x), o = [];
331
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);
334
- }
335
- const o = [];
336
- for (const s of [...t].reverse()) {
337
332
  for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], s) <= 0; ) o.pop();
338
333
  o.push(s);
339
334
  }
340
- return [...r.slice(0, -1), ...o.slice(0, -1)];
341
- }
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, {
345
- look: r.look ?? "clean",
346
- ink: i,
347
- lineWidth: l,
348
- seed: r.seed ?? 1,
349
- time: o,
350
- pencil: { construction: !1, ...r.pencil }
351
- }), h = r.skin ?? Ln, c = r.nails ?? !0, p = [
335
+ const r = [];
336
+ for (const s of [...t].reverse()) {
337
+ for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], s) <= 0; ) r.pop();
338
+ r.push(s);
339
+ }
340
+ return [...o.slice(0, -1), ...r.slice(0, -1)];
341
+ }
342
+ const Qn = "#f1c9a5", eo = "#2f2f33";
343
+ function pt(e, t, n, o = {}, r = 0) {
344
+ const s = Vn(rt(n, o), t), l = o.ink ?? eo, i = o.lineWidth ?? s.size * 0.035, a = o.pen ?? zt(e, {
345
+ look: o.look ?? "clean",
346
+ ink: l,
347
+ lineWidth: i,
348
+ seed: o.seed ?? 1,
349
+ time: r,
350
+ pencil: { construction: !1, ...o.pencil }
351
+ }), h = o.skin ?? Qn, c = o.nails ?? !0, g = [
352
352
  {
353
353
  depth: s.palmDepth,
354
- draw: () => Cn(a, s, h, l)
354
+ draw: () => to(a, s, h, i)
355
355
  }
356
356
  ];
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)
357
+ for (const u of Object.values(s.fingers)) {
358
+ const f = u.depths.reduce((p, d) => p + d, 0) / u.depths.length;
359
+ g.push({
360
+ depth: f,
361
+ draw: () => no(e, a, u, h, i, c)
362
362
  });
363
363
  }
364
- if (r.prop) {
365
- const d = r.prop;
366
- p.push({ depth: d.depth, draw: () => d.draw(a) });
364
+ if (o.prop) {
365
+ const u = o.prop;
366
+ g.push({ depth: u.depth, draw: () => u.draw(a) });
367
367
  }
368
368
  e.save(), e.lineCap = "round", e.lineJoin = "round";
369
- for (const d of [...p].sort((u, b) => u.depth - b.depth)) d.draw();
369
+ for (const u of [...g].sort((f, p) => f.depth - p.depth)) u.draw();
370
370
  return e.restore(), s;
371
371
  }
372
- function Cn(e, t, n, r) {
373
- if (e.shape(t.palm, n, r), t.palmFacing < -0.3 && e.look !== "silhouette") {
374
- const { up: o } = t.axes;
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 };
372
+ function to(e, t, n, o) {
373
+ if (e.shape(t.palm, n, o), t.palmFacing < -0.3 && e.look !== "silhouette") {
374
+ const { up: r } = t.axes;
375
+ for (const [s, l] of Object.entries(t.fingers)) {
376
+ const i = t.curls[s] ?? 0;
377
+ if (s === "thumb" || i < 0.5) continue;
378
+ const a = l.points[0], h = l.widths[0] * 0.42, c = { x: a.x - r.x * h * 0.2, y: a.y - r.y * h * 0.2 }, g = Math.atan2(r.y, r.x), u = Array.from({ length: 7 }, (f, p) => {
379
+ const d = g - Math.PI / 2 + Math.PI * p / 6;
380
+ return { x: c.x + Math.cos(d) * h, y: c.y + Math.sin(d) * h };
381
381
  });
382
- e.line(d, r * 0.6);
382
+ e.line(u, o * 0.6);
383
383
  }
384
384
  }
385
385
  if (t.palmFacing > 0.45 && e.look !== "silhouette") {
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
386
+ const { up: r, across: s } = t.axes, l = t.size, i = t.wrist, a = (c, g) => ({
387
+ x: i.x + (s.x * c + r.x * g) * l,
388
+ y: i.y + (s.y * c + r.y * g) * l
389
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
+ e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], o * 0.5);
391
391
  }
392
392
  }
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];
393
+ function no(e, t, n, o, r, s) {
394
+ const { widths: l } = n, i = oo(n.points, 2), a = n.points[0], h = i[i.length - 1], c = l[0], g = l[l.length - 1];
395
395
  if (e.save(), t.look !== "silhouette") {
396
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");
397
+ const d = c / 2 + r * 1.6;
398
+ e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
399
399
  }
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 }) ?? {
400
+ if (t.limb(i, c + 2 * r, g + 2 * r), e.restore(), t.look !== "silhouette" && (e.fillStyle = o, gt(e, i, c, g)), t.look === "silhouette" || !s || n.nail < 0.25) return;
401
+ const u = i[i.length - 2], f = ro({ x: h.x - u.x, y: h.y - u.y }) ?? {
402
402
  x: 0,
403
403
  y: -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
404
+ }, p = {
405
+ x: h.x - f.x * g * 0.22 + n.back.x * g * 0.1,
406
+ y: h.y - f.y * g * 0.22 + n.back.y * g * 0.1
407
407
  };
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
+ t.ellipse(p.x, p.y, g * 0.24 * Math.max(0.35, n.nail), g * 0.19, Math.atan2(f.y, f.x), "#f8e3d3", r * 0.45);
409
409
  }
410
- function Xn(e, t) {
410
+ function oo(e, t) {
411
411
  let n = e;
412
- for (let r = 0; r < t; r++) {
412
+ for (let o = 0; o < t; o++) {
413
413
  if (n.length < 3) return n;
414
- const o = [n[0]];
414
+ const r = [n[0]];
415
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 });
416
+ const l = n[s], i = n[s + 1];
417
+ s > 0 && r.push({ x: l.x * 0.75 + i.x * 0.25, y: l.y * 0.75 + i.y * 0.25 }), s < n.length - 2 && r.push({ x: l.x * 0.25 + i.x * 0.75, y: l.y * 0.25 + i.y * 0.75 });
418
418
  }
419
- o.push(n[n.length - 1]), n = o;
419
+ r.push(n[n.length - 1]), n = r;
420
420
  }
421
421
  return n;
422
422
  }
423
- const qn = (e) => {
423
+ const ro = (e) => {
424
424
  const t = Math.hypot(e.x, e.y);
425
425
  return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
426
- }, J = {
426
+ }, N = {
427
427
  lean: 0,
428
428
  headTilt: 0,
429
429
  leftShoulder: 18,
@@ -457,10 +457,10 @@ const qn = (e) => {
457
457
  spin: 0,
458
458
  rise: 0
459
459
  };
460
- function C(e) {
461
- return { ...J, ...e };
460
+ function X(e) {
461
+ return { ...N, ...e };
462
462
  }
463
- const Lt = {
463
+ const jt = {
464
464
  mouth: 0,
465
465
  smile: 0,
466
466
  mouthWidth: 1,
@@ -471,8 +471,8 @@ const Lt = {
471
471
  browTilt: 0,
472
472
  lookX: 0,
473
473
  lookY: 0
474
- }, R = (e) => ({ ...Lt, ...e }), Z = {
475
- neutral: Lt,
474
+ }, R = (e) => ({ ...jt, ...e }), D = {
475
+ neutral: jt,
476
476
  happy: R({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
477
477
  joyful: R({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
478
478
  sad: R({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
@@ -491,180 +491,180 @@ const Lt = {
491
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
492
  wink: R({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
493
493
  };
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 }),
494
+ function Jt(e, t) {
495
+ return { ...e, ...typeof t == "string" ? D[t] : t };
496
+ }
497
+ const bt = {
498
+ rest: N,
499
+ wave: X({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...D.happy }),
500
+ cheer: X({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...D.joyful }),
501
+ shrug: X({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...D.confused, lookX: 0, lookY: 0 }),
502
+ point: X({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
503
503
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
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 }),
504
+ think: X({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...D.thinking }),
505
+ handsOnHips: X({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
506
+ sad: X({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...D.sad }),
507
+ surprised: X({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...D.surprised }),
508
508
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
509
- crouch: C({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
509
+ crouch: X({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
510
510
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
511
511
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
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 }),
512
+ sit: X({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
513
+ jump: X({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...D.joyful }),
514
514
  // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
515
515
  // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
516
- sideSplit: C({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Z.happy }),
516
+ sideSplit: X({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...D.happy }),
517
517
  // Front split, in profile: the left leg forward (+x), the right leg back.
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) {
521
- const r = { ...e };
522
- for (const o of Ct) r[o] = e[o] + (t[o] - e[o]) * n;
523
- return r;
518
+ frontSplit: X({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...D.happy })
519
+ }, Vt = Object.keys(N);
520
+ function Me(e, t, n) {
521
+ const o = { ...e };
522
+ for (const r of Vt) o[r] = e[r] + (t[r] - e[r]) * n;
523
+ return o;
524
524
  }
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;
525
+ const st = 24, Ot = 4, It = 28, so = 40;
526
+ function io(e, t = N, n = 1) {
527
+ const o = Math.sin(e * Math.PI * 2) * n, r = Math.cos(e * Math.PI * 2) * n, s = (h) => h <= so, l = (h) => s(h) ? 22 * o : h, i = s(t.leftShoulder) ? t.leftElbow - It * Math.max(0, -o) : t.leftElbow, a = s(t.rightShoulder) ? t.rightElbow + It * Math.max(0, o) : t.rightElbow;
528
528
  return {
529
529
  ...t,
530
530
  // Lean into the walk, and keep the head a little more level than the body.
531
- lean: t.lean + Mt * n,
532
- headTilt: t.headTilt - Mt * 0.5 * n,
533
- leftElbow: l,
531
+ lean: t.lean + Ot * n,
532
+ headTilt: t.headTilt - Ot * 0.5 * n,
533
+ leftElbow: i,
534
534
  rightElbow: a,
535
535
  // Left foot forward while swing > 0, right foot back; then the other way.
536
- leftHip: -Qe * r,
537
- rightHip: -Qe * r,
536
+ leftHip: -st * o,
537
+ rightHip: -st * o,
538
538
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
539
539
  // knee folds toward the centre, which is backward only for the right leg.
540
- leftKnee: -30 * Math.max(0, o),
541
- rightKnee: 30 * Math.max(0, -o),
540
+ leftKnee: -30 * Math.max(0, r),
541
+ rightKnee: 30 * Math.max(0, -r),
542
542
  // Arms swing against the legs: left arm back while the left foot is forward.
543
- leftShoulder: i(t.leftShoulder),
544
- rightShoulder: i(t.rightShoulder)
543
+ leftShoulder: l(t.leftShoulder),
544
+ rightShoulder: l(t.rightShoulder)
545
545
  };
546
546
  }
547
- function Ur(e, t = 1) {
548
- return 4 * ((et + Ie) * e) * Math.sin(Qe * t * Math.PI / 180);
547
+ function ks(e, t = 1) {
548
+ return 4 * ((it + _e) * e) * Math.sin(st * t * Math.PI / 180);
549
549
  }
550
- function Jn(e) {
550
+ function lo(e) {
551
551
  const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
552
552
  return t * n;
553
553
  }
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;
554
+ const Zt = 0.12, $t = 0.46, ao = 1 - 2 * Zt, ho = 0.1, co = 0.21, fo = 0.19, it = 0.24, _e = 0.22, Qt = 0.12, uo = 0.14, en = 0.33, Bt = 0.7, _t = 0.3, go = 0.35, po = [1.7, 1.05], bo = [1.3, 0.75], Ft = [1.45, 0.85], mo = [1.15, 0.75], Rt = 0.06, wo = 0.7, yo = 0.65, tn = 0.075, ko = 0.3, So = 0.02, Eo = 0.012, Mo = 12, Ho = 0.25, ve = 90, vo = 0.25, To = 0.04, nn = 0.01, le = (e) => Math.min(1, Math.max(0, e ?? 0));
555
+ function Ss(e, t = 1) {
556
+ return _e * e * t;
557
557
  }
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 = [
558
+ const lt = -0.12, on = 0.4, ee = (e) => e * Math.PI / 180, Ao = (e, t) => ({ x: t * Math.sin(ee(e)), y: Math.cos(ee(e)) }), rn = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), sn = (e, t, n, o) => e - 0.3 * t - n * 0.14 * t - Math.max(0, o - 1) * 0.12 * t;
559
+ function xo(e, t, n, o, r, s) {
560
+ const l = Math.max(1, Math.min(s * 0.6, uo * n)), i = le(t.turn), a = (Qt + en * i) * n, h = o + lt * n, c = a + t.lookX * 0.08 * n, g = t.lookY * 0.07 * n, u = [
561
561
  // The left eye is on the far side; turning closes it up more than the near one.
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 }
562
+ { x: -0.34 * n * (1 - Bt * i), squeeze: 1 - Bt * i, open: t.leftEye, brow: t.leftBrow, side: -1 },
563
+ { x: 0.34 * n * (1 - _t * i), squeeze: 1 - _t * i, open: t.rightEye, brow: t.rightBrow, side: 1 }
564
564
  ];
565
- e.fillStyle = o, e.strokeStyle = o, e.lineWidth = i;
566
- for (const m of d) {
567
- const k = Jt(m.open, t.blink);
568
- if (k < 0.2) {
569
- const w = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
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();
565
+ e.fillStyle = r, e.strokeStyle = r, e.lineWidth = l;
566
+ for (const m of u) {
567
+ const w = rn(m.open, t.blink);
568
+ if (w < 0.2) {
569
+ const k = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
570
+ e.beginPath(), e.moveTo(m.x + a - 0.12 * n, h), e.quadraticCurveTo(m.x + a, h + k, m.x + a + 0.12 * n, h), e.stroke();
571
571
  } else {
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;
572
+ if (w > 1.2) {
573
+ const M = 0.13 * n * w;
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 = r;
575
575
  }
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();
576
+ const k = w > 1.2 ? 0.075 * n : 0.1 * n;
577
+ e.beginPath(), e.ellipse(m.x + c, h + g, k, k * 1.1 * Math.min(w, 1), 0, 0, Math.PI * 2), e.fill();
578
578
  }
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;
579
+ const y = sn(h, n, m.brow, w), H = m.x + a - m.side * 0.13 * n * m.squeeze, E = m.x + a + m.side * 0.13 * n * m.squeeze;
580
580
  e.beginPath(), e.moveTo(E, y), e.lineTo(H, y - t.browTilt * 0.1 * n), e.stroke();
581
581
  }
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();
582
+ const f = o + on * n, p = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - go * i), d = Math.min(1, Math.max(0, t.mouth));
583
+ if (e.beginPath(), d <= 0.05) {
584
+ e.moveTo(a - p, f), e.quadraticCurveTo(a, f + t.smile * 0.25 * n, a + p, f), e.stroke();
585
585
  return;
586
586
  }
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;
602
- }
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) };
587
+ const b = 0.3 * n * d;
588
+ t.smile > 0.3 ? (e.moveTo(a - p, f - 0.05 * n), e.lineTo(a + p, f - 0.05 * n), e.quadraticCurveTo(a, f + b * 2, a - p, f - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - p, f + b * 0.6), e.lineTo(a + p, f + b * 0.6), e.quadraticCurveTo(a, f - b * 1.4, a - p, f + b * 0.6)) : e.ellipse(a, f, p * 0.8, b, 0, 0, Math.PI * 2), e.fill();
589
+ }
590
+ function ln(e, t) {
591
+ const n = t.height ?? 300, o = Math.min(3, Math.max(0.3, e.stretch ?? 1)), r = Math.sqrt(o), s = (t.headSize ?? 2 * Zt) / 2, l = t.headSize === void 0 ? ao : 1 - 2 * s, i = s * n, a = le(e.sit), h = e.leftHip + (-ve - e.leftHip) * a, c = e.leftKnee + (-ve - e.leftKnee) * a, g = e.rightHip + (ve - e.rightHip) * a, u = e.rightKnee + (ve - e.rightKnee) * a, f = t.classic === !0, p = le(e.turn), d = (P, O, F, I, L) => {
592
+ const G = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(ee(O - F) / 2) + ee(I))), J = Math.max(-1, Math.min(1, wo + L)), fe = p + (1 - p) * P * J;
593
+ return f ? { x: 0, y: 0 } : { x: Math.cos(G) * Rt * fe, y: Math.sin(G) * Rt };
594
+ }, b = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, m = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
595
+ let w = 0;
596
+ if (a > 0 || !f) {
597
+ const P = (L, G, J, fe, He) => it * Math.cos(ee(G)) + _e * Math.cos(ee(G - J)) + Math.max(0, d(L, G, J, fe, He).y), O = Math.max(
598
+ P(-1, h, c, b.left, m.left),
599
+ P(1, g, u, b.right, m.right)
600
+ ), F = 1 - le((e.rise ?? 0) / To), I = (f ? Math.min(1, a / vo) : 1) * F;
601
+ w = ($t - O) * I * n * o;
602
+ }
603
+ const y = -$t * n * o + w, H = -l * n * o + w, E = f ? 0 : (So * le(e.turn) + Eo * a) * n * o, k = E === 0 ? [{ x: 0, y }, { x: 0, y: H }] : pe({ x: 0, y }, { x: -E, y: (y + H) / 2 }, { x: 0, y: H }, 1, 8), M = H + ho * n * o, T = (t.shoulderWidth ?? 0) * n * Math.cos(p * Math.PI / 2), S = (P, O, F, I, L) => {
604
+ const G = Ao(F, I);
605
+ return { x: P + G.x * L * n, y: O + G.y * L * n };
606
+ }, x = (P, O, F) => {
607
+ const I = S(0, y, O, P, it * o);
608
+ return { root: { x: 0, y }, joint: I, end: S(I.x, I.y, O - F, P, _e * o) };
609
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 = {
610
+ const I = { x: P * T, y: M }, L = S(I.x, I.y, O, P, co * r);
611
+ return { root: I, joint: L, end: S(L.x, L.y, O + F, P, fo * r) };
612
+ }, v = { left: x(-1, h, c), right: x(1, g, u) }, A = (P, O, F, I, L, G) => {
613
+ const J = d(P, F, I, L, G);
614
+ return { x: O.end.x + J.x * n * o, y: O.end.y + J.y * n * o };
615
+ }, W = (P, O, F, I, L) => S(O.end.x, O.end.y, F + I + L, P, tn * r), $ = {
616
616
  left: K(-1, e.leftShoulder, e.leftElbow),
617
617
  right: K(1, e.rightShoulder, e.rightElbow)
618
618
  };
619
619
  return {
620
620
  height: n,
621
621
  facing: (t.facing ?? 1) < 0 ? -1 : 1,
622
- stretch: r,
622
+ stretch: o,
623
623
  lineWidth: t.lineWidth ?? n * 0.025,
624
- rubber: Math.min(1, Math.max(u ? 0 : io, t.rubber ?? 0)),
625
- r: l,
624
+ rubber: Math.min(1, Math.max(f ? 0 : ko, t.rubber ?? 0)),
625
+ r: i,
626
626
  // The head keeps its area: taller and narrower when stretched.
627
- headRx: l / Math.sqrt(r),
628
- headRy: l * Math.sqrt(r),
627
+ headRx: i / Math.sqrt(o),
628
+ headRy: i * Math.sqrt(o),
629
629
  hipY: y,
630
630
  neckY: H,
631
- drop: k,
632
- lean: u ? e.lean : e.lean + co * Math.sin(Math.PI * a),
633
- classic: u,
631
+ drop: w,
632
+ lean: f ? e.lean : e.lean + Mo * Math.sin(Math.PI * a),
633
+ classic: f,
634
634
  legs: v,
635
635
  toes: {
636
- left: T(-1, v.left, h, c, g.left, m.left),
637
- right: T(1, v.right, p, d, g.right, m.right)
636
+ left: A(-1, v.left, h, c, b.left, m.left),
637
+ right: A(1, v.right, g, u, b.right, m.right)
638
638
  },
639
- spine: w,
640
- arms: B,
639
+ spine: k,
640
+ arms: $,
641
641
  handTips: {
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)
642
+ left: W(-1, $.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
643
+ right: W(1, $.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
644
644
  }
645
645
  };
646
646
  }
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 };
647
+ const we = (e, t) => t === 0 ? [e.root, e.joint, e.end] : pe(e.root, e.joint, e.end, t);
648
+ function Fe(e, t, n) {
649
+ const o = Math.cos(n), r = Math.sin(n), s = e.x - t.x, l = e.y - t.y;
650
+ return { x: t.x + s * o - l * r, y: t.y + s * r + l * o };
651
651
  }
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;
652
+ function an(e, t, n = !0) {
653
+ const o = Po(e, t), r = t.spin ?? 0, s = t.rise ?? 0;
654
+ return n && (r !== 0 || s !== 0) ? Ko(o, e, r, s) : o;
655
655
  }
656
- function Qt(e, t, n) {
656
+ function hn(e, t, n) {
657
657
  return { pivot: { x: 0, y: e.hipY }, angle: e.facing * ee(t), lift: n * e.height };
658
658
  }
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;
659
+ function Ko(e, t, n, o) {
660
+ const { pivot: r, angle: s, lift: l } = hn(t, n, o), i = (u) => {
661
+ const f = Fe(u, r, s);
662
+ return { x: f.x, y: f.y - l };
663
+ }, a = (u) => ({ left: i(u.left), right: i(u.right) }), h = { left: Math.max(i(e.feet.left).y, i(e.toes.left).y), right: Math.max(i(e.feet.right).y, i(e.toes.right).y) }, c = Math.max(h.left, h.right), g = nn * t.height;
664
664
  return {
665
665
  ...e,
666
- hip: l(e.hip),
667
- neck: l(e.neck),
666
+ hip: i(e.hip),
667
+ neck: i(e.neck),
668
668
  shoulders: a(e.shoulders),
669
669
  elbows: a(e.elbows),
670
670
  hands: a(e.hands),
@@ -673,297 +673,301 @@ function mo(e, t, n, r) {
673
673
  feet: a(e.feet),
674
674
  toes: a(e.toes),
675
675
  feetY: c,
676
- grounded: { left: h.left >= c - p, right: h.right >= c - p },
676
+ grounded: { left: h.left >= c - g, right: h.right >= c - g },
677
677
  handAngle: { left: e.handAngle.left + s, right: e.handAngle.right + s },
678
678
  limbs: {
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)
679
+ leftArm: e.limbs.leftArm.map(i),
680
+ rightArm: e.limbs.rightArm.map(i),
681
+ leftLeg: e.limbs.leftLeg.map(i),
682
+ rightLeg: e.limbs.rightLeg.map(i),
683
+ spine: e.limbs.spine.map(i)
684
684
  },
685
- head: { ...e.head, center: l(e.head.center), angle: e.head.angle + s }
685
+ head: { ...e.head, center: i(e.head.center), angle: e.head.angle + s }
686
686
  };
687
687
  }
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;
688
+ function Po(e, t) {
689
+ const n = ee(e.lean), o = ee(t.headTilt), r = { x: 0, y: e.hipY }, s = (y) => ({ x: e.facing * y.x, y: y.y }), l = (y) => s(Fe(y, r, n)), i = (y) => l(Fe({ x: y.x, y: y.y + e.neckY }, { x: 0, y: e.neckY }, o)), a = we(e.arms.left, e.rubber).map(l), h = we(e.arms.right, e.rubber).map(l), c = (y, H) => Math.atan2(H.y - y.y, H.x - y.x), g = { left: l(e.handTips.left), right: l(e.handTips.right) }, u = (y, H) => {
690
+ const [E, k] = y.slice(-2), M = e.arms[H], T = c(l(M.end), g[H]) - c(l(M.joint), l(M.end));
691
+ return c(E, k) + T;
692
692
  };
693
- let u = 1 / 0;
693
+ let f = 1 / 0;
694
694
  for (const [y, H] of [
695
695
  [t.leftBrow, t.leftEye],
696
696
  [t.rightBrow, t.rightEye]
697
697
  ]) {
698
- const E = Vt(tt, 1, y, Jt(H, t.blink));
699
- u = Math.min(u, E, E - t.browTilt * 0.1);
698
+ const E = sn(lt, 1, y, rn(H, t.blink));
699
+ f = Math.min(f, E, E - t.browTilt * 0.1);
700
700
  }
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
+ const p = { left: s(e.legs.left.end), right: s(e.legs.right.end) }, d = { left: s(e.toes.left), right: s(e.toes.right) }, b = { left: Math.max(p.left.y, d.left.y), right: Math.max(p.right.y, d.right.y) }, m = Math.max(b.left, b.right), w = nn * e.height;
702
702
  return {
703
703
  facing: e.facing,
704
704
  height: e.height,
705
705
  stretch: e.stretch,
706
706
  lineWidth: e.lineWidth,
707
- hip: o,
708
- neck: i({ x: 0, y: e.neckY }),
709
- shoulders: { left: i(e.arms.left.root), right: i(e.arms.right.root) },
710
- elbows: { left: i(e.arms.left.joint), right: i(e.arms.right.joint) },
711
- hands: { left: i(e.arms.left.end), right: i(e.arms.right.end) },
707
+ hip: r,
708
+ neck: l({ x: 0, y: e.neckY }),
709
+ shoulders: { left: l(e.arms.left.root), right: l(e.arms.right.root) },
710
+ elbows: { left: l(e.arms.left.joint), right: l(e.arms.right.joint) },
711
+ hands: { left: l(e.arms.left.end), right: l(e.arms.right.end) },
712
712
  knees: { left: s(e.legs.left.joint), right: s(e.legs.right.joint) },
713
- feet: b,
714
- toes: f,
713
+ feet: p,
714
+ toes: d,
715
715
  feetY: m,
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") },
716
+ grounded: { left: b.left >= m - w, right: b.right >= m - w },
717
+ fingertips: g,
718
+ handAngle: { left: u(a, "left"), right: u(h, "right") },
719
719
  limbs: {
720
720
  leftArm: a,
721
721
  rightArm: h,
722
- leftLeg: be(e.legs.left, e.rubber).map(s),
723
- rightLeg: be(e.legs.right, e.rubber).map(s),
724
- spine: e.spine.map(i)
722
+ leftLeg: we(e.legs.left, e.rubber).map(s),
723
+ rightLeg: we(e.legs.right, e.rubber).map(s),
724
+ spine: e.spine.map(l)
725
725
  },
726
726
  head: {
727
- center: l({ x: 0, y: -e.headRy }),
727
+ center: i({ x: 0, y: -e.headRy }),
728
728
  rx: e.headRx,
729
729
  ry: e.headRy,
730
730
  // Mirroring a turn reverses it.
731
- angle: e.facing * (n + r),
732
- eyeY: tt,
733
- browTopY: u,
734
- mouthY: Gt,
735
- faceX: e.facing * (Xt + qt * ie(t.turn))
731
+ angle: e.facing * (n + o),
732
+ eyeY: lt,
733
+ browTopY: f,
734
+ mouthY: on,
735
+ faceX: e.facing * (Qt + en * le(t.turn))
736
736
  }
737
737
  };
738
738
  }
739
- function wo(e, t = {}) {
740
- return Zt(jt(e, t), e);
739
+ function Wo(e, t = {}) {
740
+ return an(ln(e, t), e);
741
741
  }
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);
742
+ function Es(e, t, n) {
743
+ return Fe({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
744
744
  }
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) });
745
+ function Oo(e, t, n) {
746
+ const o = (s) => ({ x: s.x + t, y: s.y + n }), r = (s) => ({ left: o(s.left), right: o(s.right) });
747
747
  return {
748
748
  ...e,
749
- hip: r(e.hip),
750
- neck: r(e.neck),
751
- shoulders: o(e.shoulders),
752
- elbows: o(e.elbows),
753
- hands: o(e.hands),
754
- knees: o(e.knees),
755
- feet: o(e.feet),
756
- toes: o(e.toes),
749
+ hip: o(e.hip),
750
+ neck: o(e.neck),
751
+ shoulders: r(e.shoulders),
752
+ elbows: r(e.elbows),
753
+ hands: r(e.hands),
754
+ knees: r(e.knees),
755
+ feet: r(e.feet),
756
+ toes: r(e.toes),
757
757
  feetY: e.feetY + n,
758
758
  grounded: { ...e.grounded },
759
759
  handAngle: { ...e.handAngle },
760
760
  limbs: {
761
- leftArm: e.limbs.leftArm.map(r),
762
- rightArm: e.limbs.rightArm.map(r),
763
- leftLeg: e.limbs.leftLeg.map(r),
764
- rightLeg: e.limbs.rightLeg.map(r),
765
- spine: e.limbs.spine.map(r)
761
+ leftArm: e.limbs.leftArm.map(o),
762
+ rightArm: e.limbs.rightArm.map(o),
763
+ leftLeg: e.limbs.leftLeg.map(o),
764
+ rightLeg: e.limbs.rightLeg.map(o),
765
+ spine: e.limbs.spine.map(o)
766
766
  },
767
- head: { ...e.head, center: r(e.head.center) }
767
+ head: { ...e.head, center: o(e.head.center) }
768
768
  };
769
769
  }
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) => {
772
- e.save(), w(), e.restore();
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);
779
- if (o.classic) {
780
- e.beginPath(), e.moveTo(w[0].x, w[0].y);
781
- for (const S of w.slice(1)) e.lineTo(S.x, S.y);
770
+ function Io(e, t, n = {}, o = 0) {
771
+ const r = ln(t, n), s = n.color ?? "#1e293b", l = n.layers ?? {}, i = n.layers ? an(r, t, !1) : void 0, a = n.sketch ? tt(e, n.sketch, o) : void 0, h = n.sketch && n.layers ? tt(e, n.sketch, o) : void 0, c = (k) => {
772
+ e.save(), k(), e.restore();
773
+ }, g = (k) => {
774
+ k && i && c(() => k(e, i, o, h));
775
+ }, u = () => e.scale(r.facing, 1), f = () => {
776
+ u(), e.translate(0, r.hipY), e.rotate(ee(r.lean)), e.translate(0, -r.hipY);
777
+ }, p = (k, M, T) => {
778
+ if (a) return M ? a.curve(k) : a.line(k);
779
+ if (r.classic) {
780
+ e.beginPath(), e.moveTo(k[0].x, k[0].y);
781
+ for (const S of k.slice(1)) e.lineTo(S.x, S.y);
782
782
  e.stroke();
783
783
  return;
784
784
  }
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);
788
- }, m = (w) => {
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();
785
+ gt(e, k, T[0] * r.lineWidth, T[1] * r.lineWidth);
786
+ }, d = (k, M) => p(we(k, r.rubber), r.rubber > 0, M), b = (k) => {
787
+ r.classic || p([r.legs[k].end, r.toes[k]], !1, mo);
788
+ }, m = (k) => {
789
+ if (n.hands && !r.classic) return y(k);
790
+ if (r.classic || a) return;
791
+ const M = r.arms[k].end;
792
+ e.beginPath(), e.arc(M.x, M.y, yo * r.lineWidth, 0, Math.PI * 2), e.fill();
793
793
  };
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] ?? _, {
800
- side: w,
794
+ e.save(), e.strokeStyle = s, e.fillStyle = s, e.lineWidth = r.lineWidth, e.lineCap = "round", e.lineJoin = "round";
795
+ const w = hn(r, t.spin ?? 0, t.rise ?? 0);
796
+ (w.angle !== 0 || w.lift !== 0) && (e.translate(0, -w.lift), e.translate(w.pivot.x, w.pivot.y), e.rotate(w.angle), e.translate(-w.pivot.x, -w.pivot.y));
797
+ function y(k) {
798
+ const M = n.hands ?? {}, T = r.arms[k].end, S = r.handTips[k], x = n.headFill ?? "#ffffff";
799
+ pt(e, T, M[k] ?? _, {
800
+ side: k,
801
801
  // Degrees clockwise from straight up, in the frame the hand is drawn in.
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),
802
+ angle: Math.atan2(S.x - T.x, T.y - S.y) * 180 / Math.PI,
803
+ size: (M.size ?? tn) * r.height * Math.sqrt(r.stretch),
804
+ skin: M.skin ?? (x === "none" ? void 0 : x),
805
805
  ink: s,
806
- lineWidth: o.lineWidth * 0.45,
806
+ lineWidth: r.lineWidth * 0.45,
807
807
  fingers: M.fingers,
808
808
  plump: M.plump,
809
809
  look: n.sketch ? "pencil" : "clean",
810
810
  seed: n.sketch?.seed
811
- }, r);
811
+ }, o);
812
812
  }
813
- const H = (w) => {
813
+ const H = (k) => {
814
814
  c(() => {
815
- u(), f(o.arms[w], oo), m(w);
815
+ f(), d(r.arms[k], bo), m(k);
816
816
  });
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");
817
+ const M = l.sleeve;
818
+ M && i && c(() => M(e, i, k, o, h));
819
+ }, E = le(t.turn) > Ho;
820
+ g(l.behind), c(() => {
821
+ u(), d(r.legs.left, Ft), b("left"), d(r.legs.right, Ft), b("right");
822
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]);
823
+ f(), p(r.spine, r.spine.length > 2, po);
824
+ const { left: k, right: M } = { left: r.arms.left.root, right: r.arms.right.root };
825
+ if (k.x !== M.x)
826
+ if (r.classic) p([k, M], !1, [1, 1]);
827
827
  else {
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]);
828
+ const T = { x: (k.x + M.x) / 2, y: k.y - 0.3 * Math.abs(M.x - k.x) };
829
+ p(pe(k, T, M, 1, 8), !0, [1.1, 1.1]);
830
830
  }
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));
833
- const w = -o.headRy;
834
- e.beginPath(), e.ellipse(0, w, o.headRx, o.headRy, 0, 0, Math.PI * 2);
831
+ }), g(l.body), E || H("left"), H("right"), g(l.behindHead), c(() => {
832
+ f(), e.translate(0, r.neckY), e.rotate(ee(t.headTilt));
833
+ const k = -r.headRy;
834
+ e.beginPath(), e.ellipse(0, k, r.headRx, r.headRy, 0, 0, Math.PI * 2);
835
835
  const M = n.headFill ?? "#ffffff";
836
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);
837
+ a.ellipse(0, k, r.headRx, r.headRy);
838
+ const T = a.nudge();
839
+ e.translate(T.x, T.y);
840
840
  } else
841
841
  e.stroke();
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());
844
- }
845
- function en(e, t, n) {
846
- const r = { ...e };
847
- let o = e.walking > 0 ? Se(r, Gn(e.walk, r), e.walking) : r, s = Ho(e);
848
- const i = e.dancing ?? 0;
849
- if (n && i > 0) {
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) };
842
+ e.translate(0, k), e.scale(r.headRx / r.r, r.headRy / r.r), xo(e, t, r.r, 0, s, r.lineWidth);
843
+ }), g(l.overHead), g(l.front), e.restore(), n.label && (e.save(), e.fillStyle = s, e.font = n.labelFont ?? `700 ${Math.round(r.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(n.label, 0, -r.height * r.stretch - 0.04 * r.height + r.drop), e.restore());
844
+ }
845
+ function cn(e, t, n) {
846
+ const o = { ...e };
847
+ let r = e.walking > 0 ? Me(o, io(e.walk, o), e.walking) : o, s = Bo(e);
848
+ const l = e.dancing ?? 0;
849
+ if (n && l > 0) {
850
+ const i = n(e.beat ?? 0);
851
+ if (r = Me(r, i.pose, l), i.hands) {
852
+ const a = (h, c) => c ? Ee(h ?? _, c, l) : h;
853
+ s = { left: a(s?.left, i.hands.left), right: a(s?.right, i.hands.right) };
854
854
  }
855
855
  }
856
- return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Jn(t)) }), { pose: o, hands: s };
856
+ return e.talk > 0 && (r = { ...r, mouth: Math.max(r.mouth, e.talk * lo(t)) }), { pose: r, hands: s };
857
857
  }
858
- function Eo(e, t, n) {
859
- return en(e, t, n).pose;
858
+ function $o(e, t, n) {
859
+ return cn(e, t, n).pose;
860
860
  }
861
- const $e = (e, t) => `hand.${e}.${t}`;
862
- function Ho(e) {
863
- const t = (o) => {
864
- if (typeof e[$e(o, "spread")] == "number")
865
- return Object.fromEntries(Object.keys(_).map((s) => [s, e[$e(o, s)]]));
866
- }, n = t("left"), r = t("right");
867
- return n || r ? { left: n, right: r } : void 0;
861
+ const Re = (e, t) => `hand.${e}.${t}`;
862
+ function Bo(e) {
863
+ const t = (r) => {
864
+ if (typeof e[Re(r, "spread")] == "number")
865
+ return Object.fromEntries(Object.keys(_).map((s) => [s, e[Re(r, s)]]));
866
+ }, n = t("left"), o = t("right");
867
+ return n || o ? { left: n, right: o } : void 0;
868
868
  }
869
- function Mo(e, t) {
869
+ function _o(e, t) {
870
870
  return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
871
871
  }
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 = {};
872
+ function Ms(e) {
873
+ const t = e.style ?? {}, n = t.height ?? 300, o = n * 0.8, r = { ...X(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, s = {};
874
874
  if (t.hands)
875
- for (const i of ["left", "right"]) {
876
- const l = t.hands[i] ?? _;
877
- for (const a of Object.keys(_)) s[$e(i, a)] = l[a] ?? _[a];
875
+ for (const l of ["left", "right"]) {
876
+ const i = t.hands[l] ?? _;
877
+ for (const a of Object.keys(_)) s[Re(l, a)] = i[a] ?? _[a];
878
878
  }
879
879
  return {
880
880
  type: "custom",
881
- x: e.x - r / 2,
881
+ x: e.x - o / 2,
882
882
  y: e.y - n,
883
- width: r,
883
+ width: o,
884
884
  height: n,
885
- props: { ...o, ...s },
885
+ props: { ...r, ...s },
886
886
  figureStyle: t,
887
887
  figureDance: e.dance,
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);
888
+ draw(l, i, a) {
889
+ const h = i.props, c = cn(h, a, e.dance);
890
+ l.translate(o / 2, n), Io(l, c.pose, _o({ ...t, rubber: h.rubber }, c.hands), a);
891
891
  }
892
892
  };
893
893
  }
894
- function Vr(e, t, n) {
895
- const r = e.figureStyle;
896
- if (!r) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
897
- const o = { ...e.props };
898
- let s = 0, i = 0;
894
+ function Fo(e, t, n) {
895
+ const o = e.figureStyle;
896
+ if (!o) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
897
+ const r = { ...e.props };
898
+ let s = 0, l = 0;
899
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) };
903
- }
904
- function jr(e, t) {
905
- const n = [];
906
- return t.forEach((r, o) => {
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) => ({
910
- id: `${e}-${r}`,
900
+ typeof c == "number" && (h === "x" || h === "motionPathX" ? s = c : h === "y" || h === "motionPathY" ? l = c : h in r && (r[h] = c));
901
+ const i = $o(r, t.time, e.figureDance), a = Wo(i, { ...o, rubber: r.rubber });
902
+ return { pose: i, joints: Oo(a, e.x + s + e.width / 2, e.y + l + e.height) };
903
+ }
904
+ function fn(e) {
905
+ const t = [];
906
+ return e.forEach((n, o) => {
907
+ const r = o === 0 ? N : t[o - 1], s = typeof n.pose == "string" ? bt[n.pose] : { ...r, ...n.pose };
908
+ t.push(n.expression ? Jt(s, n.expression) : s);
909
+ }), t;
910
+ }
911
+ function Hs(e, t) {
912
+ const n = fn(t);
913
+ return Vt.filter((o) => n.some((r) => r[o] !== N[o])).map((o) => ({
914
+ id: `${e}-${o}`,
911
915
  target: e,
912
- property: r,
913
- keyframes: t.map((o, s) => ({
914
- time: o.time,
915
- value: n[s][r],
916
- ...o.easing ? { easing: o.easing } : {}
916
+ property: o,
917
+ keyframes: t.map((r, s) => ({
918
+ time: r.time,
919
+ value: n[s][o],
920
+ ...r.easing ? { easing: r.easing } : {}
917
921
  }))
918
922
  }));
919
923
  }
920
- const Ne = 0.5, Wt = {
924
+ const Xe = 0.5, Lt = {
921
925
  /** Flag: fingers together and straight, thumb bent in */
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 }),
926
+ pataka: B({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
923
927
  /** Pataka with the ring finger bent */
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 }),
928
+ tripataka: B({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
925
929
  /** Lotus in bloom: fingers fanned, each a little more curled than the last */
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 }),
930
+ alapadma: B({ "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 }),
927
931
  /** Fist */
928
- mushti: L.fist,
932
+ mushti: Y.fist,
929
933
  /** Fist, thumb up */
930
- shikhara: L.thumbsUp,
934
+ shikhara: Y.thumbsUp,
931
935
  /** Swan's beak: thumb and index touch, the others fanned */
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 }),
936
+ hamsasya: B({ "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 }),
933
937
  /** Bracelet: thumb, index and middle meet, ring and little finger out */
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 })
938
+ katakamukha: B({ "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 })
935
939
  };
936
- function _e(e) {
937
- return typeof e != "string" ? e : e in Wt ? Wt[e] : L[e];
940
+ function Le(e) {
941
+ return typeof e != "string" ? e : e in Lt ? Lt[e] : Y[e];
938
942
  }
939
- function tn(e, t, n) {
940
- const r = [];
941
- for (const o of e.keys) {
942
- const s = r[r.length - 1], i = !s || o.reset ? { pose: t, ...n } : s;
943
- r.push({
944
- beat: o.beat,
945
- pose: { ...i.pose, ...o.pose },
946
- left: o.hands?.left ? _e(o.hands.left) : i.left,
947
- right: o.hands?.right ? _e(o.hands.right) : i.right,
948
- easing: o.easing ?? e.easing
943
+ function un(e, t, n) {
944
+ const o = [];
945
+ for (const r of e.keys) {
946
+ const s = o[o.length - 1], l = !s || r.reset ? { pose: t, ...n } : s;
947
+ o.push({
948
+ beat: r.beat,
949
+ pose: { ...l.pose, ...r.pose },
950
+ left: r.hands?.left ? Le(r.hands.left) : l.left,
951
+ right: r.hands?.right ? Le(r.hands.right) : l.right,
952
+ easing: r.easing ?? e.easing
949
953
  });
950
954
  }
951
- return r;
955
+ return o;
952
956
  }
953
- const ht = (e, t) => (e % t + t) % t;
954
- function vo(e, t, n, r) {
955
- const o = tn(e, n, r);
956
- if (o.length === 0) return { pose: n, hands: r };
957
- const s = ht(t, e.beats);
958
- let i = o.length - 1;
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)));
957
+ const mt = (e, t) => (e % t + t) % t;
958
+ function Ro(e, t, n, o) {
959
+ const r = un(e, n, o);
960
+ if (r.length === 0) return { pose: n, hands: o };
961
+ const s = mt(t, e.beats);
962
+ let l = r.length - 1;
963
+ for (let f = 0; f < r.length; f++) r[f].beat <= s && (l = f);
964
+ const i = r[l], a = r[(l + 1) % r.length], h = i.beat <= s ? i.beat : i.beat - e.beats, c = a.beat > h ? a.beat : a.beat + e.beats, g = c > h ? (s - h) / (c - h) : 0, u = qe(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, g)));
961
965
  return {
962
- pose: Se(l.pose, a.pose, d),
963
- hands: { left: ke(l.left, a.left, d), right: ke(l.right, a.right, d) }
966
+ pose: Me(i.pose, a.pose, u),
967
+ hands: { left: Ee(i.left, a.left, u), right: Ee(i.right, a.right, u) }
964
968
  };
965
969
  }
966
- const xo = [
970
+ const Lo = [
967
971
  ["leftShoulder", "rightShoulder"],
968
972
  ["leftElbow", "rightElbow"],
969
973
  ["leftWrist", "rightWrist"],
@@ -973,151 +977,151 @@ const xo = [
973
977
  ["leftFootOut", "rightFootOut"],
974
978
  ["leftEye", "rightEye"],
975
979
  ["leftBrow", "rightBrow"]
976
- ], To = ["lean", "headTilt", "lookX", "spin"], Ao = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
977
- function Ko(e) {
980
+ ], Yo = ["lean", "headTilt", "lookX", "spin"], No = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
981
+ function Co(e) {
978
982
  const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
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];
983
+ for (const [o, r] of Lo) {
984
+ const s = n && No.has(o) ? -1 : 1;
985
+ t[o] = s * e[r], t[r] = s * e[o];
982
986
  }
983
- if (!n) for (const r of To) t[r] = -e[r];
987
+ if (!n) for (const o of Yo) t[o] = -e[o];
984
988
  return t;
985
989
  }
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);
990
+ const Do = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
991
+ function qo(e, t, n) {
992
+ const o = mt(n, 1), r = (1 + Math.cos(2 * Math.PI * o)) / 2, s = t.bounce * (t.accent === "up" ? 1 - r : r), l = Math.min(1, Math.max(0, e.turn ?? 0)), i = Do(l);
989
993
  return {
990
994
  ...e,
991
- leftHip: e.leftHip + l * s / 2,
995
+ leftHip: e.leftHip + i * s / 2,
992
996
  rightHip: e.rightHip + s / 2,
993
- leftKnee: e.leftKnee + l * s,
997
+ leftKnee: e.leftKnee + i * s,
994
998
  rightKnee: e.rightKnee + s,
995
- lean: e.lean + (t.sway ?? 0) * (1 - i) * Math.sin(Math.PI * n)
999
+ lean: e.lean + (t.sway ?? 0) * (1 - l) * Math.sin(Math.PI * n)
996
1000
  };
997
1001
  }
998
- function nt(e) {
999
- const t = { ...J, ...e.stance };
1000
- return e.expression ? Nt(t, e.expression) : t;
1002
+ function at(e) {
1003
+ const t = { ...N, ...e.stance };
1004
+ return e.expression ? Jt(t, e.expression) : t;
1001
1005
  }
1002
- function nn(e) {
1006
+ function dn(e) {
1003
1007
  return {
1004
- left: e.hands?.left ? _e(e.hands.left) : _,
1005
- right: e.hands?.right ? _e(e.hands.right) : _
1008
+ left: e.hands?.left ? Le(e.hands.left) : _,
1009
+ right: e.hands?.right ? Le(e.hands.right) : _
1006
1010
  };
1007
1011
  }
1008
- function Ce(e, t, n) {
1009
- const r = e.moves[t.move];
1010
- if (!r) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
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;
1013
- }
1014
- function ct(e, t, n = {}) {
1015
- const r = typeof e == "string" ? ge[e] : e;
1016
- let o;
1012
+ function Ue(e, t, n) {
1013
+ const o = e.moves[t.move];
1014
+ if (!o) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1015
+ const r = Ro(o, n, at(e), dn(e));
1016
+ return t.mirror ? { pose: Co(r.pose), hands: { left: r.hands?.right, right: r.hands?.left } } : r;
1017
+ }
1018
+ function wt(e, t, n = {}) {
1019
+ const o = typeof e == "string" ? be[e] : e;
1020
+ let r;
1017
1021
  if (n.move)
1018
- o = Ce(r, { move: n.move, mirror: n.mirror }, t);
1022
+ r = Ue(o, { move: n.move, mirror: n.mirror }, t);
1019
1023
  else {
1020
- const s = r.routine, i = s.reduce((p, d) => p + d.beats, 0), l = ht(t, i);
1024
+ const s = o.routine, l = s.reduce((g, u) => g + u.beats, 0), i = mt(t, l);
1021
1025
  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);
1026
- o = {
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) }
1026
+ for (; h < s.length - 1 && i >= a + s[h].beats; ) a += s[h++].beats;
1027
+ const c = i - a;
1028
+ if (r = Ue(o, s[h], c), c < Xe && s.length > 1 && t >= Xe) {
1029
+ const g = s[(h - 1 + s.length) % s.length], u = Ue(o, g, g.beats + c), f = qe("ease-in-out")(c / Xe);
1030
+ r = {
1031
+ pose: Me(u.pose, r.pose, f),
1032
+ hands: { left: Ee(u.hands.left, r.hands.left, f), right: Ee(u.hands.right, r.hands.right, f) }
1029
1033
  };
1030
1034
  }
1031
1035
  }
1032
- return { ...o, pose: Wo(o.pose, r.groove, t) };
1036
+ return { ...r, pose: qo(r.pose, o.groove, t) };
1033
1037
  }
1034
- function Zr(e, t, n = {}) {
1035
- return ct(e, t, n).pose;
1038
+ function vs(e, t, n = {}) {
1039
+ return wt(e, t, n).pose;
1036
1040
  }
1037
- function ft(e) {
1038
- return (typeof e == "string" ? ge[e] : e).routine.reduce((n, r) => n + r.beats, 0);
1041
+ function yt(e) {
1042
+ return (typeof e == "string" ? be[e] : e).routine.reduce((n, o) => n + o.beats, 0);
1039
1043
  }
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++)
1044
+ const Xo = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1045
+ function Yt(e, t, n, o, r, s, l) {
1046
+ for (let i = 0; i * e.beats < n; i++)
1043
1047
  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 });
1048
+ const h = i * e.beats + a.beat, c = t + h;
1049
+ if (!(h >= n || c < s || c >= l))
1050
+ for (const g of a.taps ?? []) r.push({ beat: c, tap: o ? Xo[g] : g });
1047
1051
  }
1048
1052
  }
1049
- function Qr(e, t, n, r = {}) {
1050
- const o = typeof e == "string" ? ge[e] : e, s = [];
1053
+ function Ts(e, t, n, o = {}) {
1054
+ const r = typeof e == "string" ? be[e] : e, s = [];
1051
1055
  if (n <= t) return s;
1052
- if (r.move) {
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);
1056
+ if (o.move) {
1057
+ const l = r.moves[o.move], i = Math.floor(t / l.beats) * l.beats;
1058
+ Yt(l, i, Math.ceil((n - i) / l.beats) * l.beats, o.mirror, s, t, n);
1055
1059
  } else {
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
+ const l = yt(r);
1061
+ for (let i = Math.floor(t / l) * l; i < n; i += l) {
1062
+ let a = i;
1063
+ for (const h of r.routine)
1064
+ Yt(r.moves[h.move], a, h.beats, h.mirror, s, t, n), a += h.beats;
1061
1065
  }
1062
1066
  }
1063
- return s.sort((i, l) => i.beat - l.beat);
1067
+ return s.sort((l, i) => l.beat - i.beat);
1064
1068
  }
1065
- function It(e, t) {
1069
+ function Nt(e, t) {
1066
1070
  const n = e.moves[t.move];
1067
1071
  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;
1072
+ const o = n.travel / n.beats;
1073
+ return t.mirror ? (un(n, at(e), dn(e))[0]?.pose.turn ?? at(e).turn ?? 0) >= 0.5 ? o : -o : o;
1070
1074
  }
1071
- function on(e, t) {
1075
+ function gn(e, t) {
1072
1076
  return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
1073
1077
  }
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;
1078
+ function Ge(e, t, n = {}) {
1079
+ const o = typeof e == "string" ? be[e] : e, r = gn(o, n), s = r.reduce((c, g) => c + g.beats, 0), l = r.reduce((c, g) => c + Nt(o, g) * g.beats, 0), i = Math.floor(t / s);
1080
+ let a = i * l, h = t - i * s;
1081
+ for (const c of r) {
1082
+ const g = Math.min(c.beats, h);
1083
+ if (a += Nt(o, c) * g, h -= g, h <= 0) break;
1080
1084
  }
1081
1085
  return a;
1082
1086
  }
1083
- function Io(e, t, n) {
1084
- const r = on(e, n), o = [0];
1087
+ function Uo(e, t, n) {
1088
+ const o = gn(e, n), r = [0];
1085
1089
  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;
1090
+ for (let l = 0; s < t; l = (l + 1) % o.length)
1091
+ s += o[l].beats, r.push(Math.min(s, t));
1092
+ return r;
1089
1093
  }
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));
1094
+ const Go = 8;
1095
+ function zo(e, t, n) {
1096
+ const o = typeof t == "string" ? be[t] : t, r = n.bpm ?? o.bpm, s = n.beats ?? (n.move ? o.moves[n.move].beats : yt(o)), l = Uo(o, s, n);
1097
+ if (l.every((m) => Ge(o, m, n) === 0)) return;
1098
+ const i = Math.min(n.fade ?? 1, s / 2), a = qe("ease-in-out"), h = (m) => i <= 0 ? 1 : Math.min(a(Math.min(1, m / i)), a(Math.min(1, (s - m) / i))), c = Math.ceil(i * Go), g = i <= 0 ? [] : Array.from({ length: c + 1 }, (m, w) => [w / c * i, s - w / c * i]).flat(), u = [.../* @__PURE__ */ new Set([...l, ...g])].sort((m, w) => m - w);
1099
+ let f = 0;
1100
+ const p = u.map((m, w) => {
1101
+ if (w > 0) {
1102
+ const y = u[w - 1], H = Math.max(1, Math.ceil((m - y) * 16));
1099
1103
  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);
1104
+ const k = y + (m - y) * E / H, M = y + (m - y) * (E + 1) / H;
1105
+ f += (Ge(o, M, n) - Ge(o, k, n)) * h((k + M) / 2);
1102
1106
  }
1103
1107
  }
1104
- return { beat: m, travel: u };
1105
- }), f = n.start ?? 0, g = n.x ?? 0;
1108
+ return { beat: m, travel: f };
1109
+ }), d = n.start ?? 0, b = n.x ?? 0;
1106
1110
  return {
1107
1111
  id: `${e}-x`,
1108
1112
  target: e,
1109
1113
  property: "x",
1110
- keyframes: b.map((m) => ({ time: f + m.beat * 6e4 / o, value: g + n.height * m.travel, easing: "linear" }))
1114
+ keyframes: p.map((m) => ({ time: d + m.beat * 6e4 / r, value: b + n.height * m.travel, easing: "linear" }))
1111
1115
  };
1112
1116
  }
1113
- function es(e, t, n = 0) {
1117
+ function As(e, t, n = 0) {
1114
1118
  return (e - n) * t / 6e4;
1115
1119
  }
1116
- function ts(e, t = {}) {
1117
- return (n) => ct(e, n, t);
1120
+ function xs(e, t = {}) {
1121
+ return (n) => wt(e, n, t);
1118
1122
  }
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);
1123
+ function Ks(e, t) {
1124
+ const n = t.start ?? 0, o = 6e4 / t.bpm, r = n + t.beats * o, s = Math.min((t.fade ?? 1) * o, (r - n) / 2);
1121
1125
  return [
1122
1126
  {
1123
1127
  id: `${e}-beat`,
@@ -1125,7 +1129,7 @@ function ns(e, t) {
1125
1129
  property: "beat",
1126
1130
  keyframes: [
1127
1131
  { time: n, value: 0 },
1128
- { time: o, value: t.beats, easing: "linear" }
1132
+ { time: r, value: t.beats, easing: "linear" }
1129
1133
  ]
1130
1134
  },
1131
1135
  {
@@ -1135,32 +1139,32 @@ function ns(e, t) {
1135
1139
  keyframes: [
1136
1140
  { time: n, value: 0 },
1137
1141
  { time: n + s, value: 1, easing: "ease-in-out" },
1138
- { time: o - s, value: 1 },
1139
- { time: o, value: 0, easing: "ease-in-out" }
1142
+ { time: r - s, value: 1 },
1143
+ { time: r, value: 0, easing: "ease-in-out" }
1140
1144
  ]
1141
1145
  }
1142
1146
  ];
1143
1147
  }
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}`,
1148
+ function Ps(e, t, n = {}) {
1149
+ const o = typeof t == "string" ? be[t] : t, r = n.bpm ?? o.bpm, s = n.beats ?? (n.move ? o.moves[n.move].beats : yt(o)), l = n.samplesPerBeat ?? 4, i = n.start ?? 0, a = Math.round(s * l), h = Array.from({ length: a + 1 }, (d, b) => {
1150
+ const m = b / l;
1151
+ return { time: i + m * 6e4 / r, frame: wt(o, m, n) };
1152
+ }), c = (d, b) => ({
1153
+ id: `${e}-${d}`,
1150
1154
  target: e,
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));
1155
+ property: d,
1156
+ keyframes: h.map((m) => ({ time: m.time, value: b(m.frame) }))
1157
+ }), u = Object.keys(N).filter((d) => h.some((b) => b.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== N[d]).map((d) => c(d, (b) => b.pose[d])), f = n.height === void 0 ? void 0 : zo(e, o, { ...n, bpm: r, beats: s, start: i, height: n.height, fade: 0 });
1158
+ if (f && u.push(f), n.hands === !1) return u;
1159
+ const p = [];
1160
+ for (const d of ["left", "right"])
1161
+ for (const b of Object.keys(_)) {
1162
+ const m = (w) => w.hands?.[d]?.[b] ?? _[b];
1163
+ h.some((w) => m(w.frame) !== _[b]) && p.push(c(Re(d, b), m));
1160
1164
  }
1161
- return [...d, ...b];
1165
+ return [...u, ...p];
1162
1166
  }
1163
- const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic", _o = {
1167
+ const Se = { type: "back", mode: "out", overshoot: 1.1 }, U = "ease-out-cubic", jo = {
1164
1168
  label: "Disco",
1165
1169
  bpm: 120,
1166
1170
  stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
@@ -1170,7 +1174,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1170
1174
  point: {
1171
1175
  label: "The point",
1172
1176
  beats: 2,
1173
- easing: D,
1177
+ easing: U,
1174
1178
  keys: [
1175
1179
  {
1176
1180
  beat: 0,
@@ -1195,9 +1199,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1195
1199
  label: "Bump and clap",
1196
1200
  beats: 4,
1197
1201
  keys: [
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 },
1202
+ { 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: U },
1199
1203
  { 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" } },
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 },
1204
+ { 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: U },
1201
1205
  { 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" } }
1202
1206
  ]
1203
1207
  }
@@ -1208,7 +1212,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1208
1212
  { move: "point", beats: 8, mirror: !0 },
1209
1213
  { move: "bump", beats: 8 }
1210
1214
  ]
1211
- }, Fo = {
1215
+ }, Jo = {
1212
1216
  label: "Hip hop",
1213
1217
  bpm: 95,
1214
1218
  stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
@@ -1260,7 +1264,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1260
1264
  { move: "armWave", beats: 8 },
1261
1265
  { move: "bounce", beats: 4 }
1262
1266
  ]
1263
- }, Ro = {
1267
+ }, Vo = {
1264
1268
  label: "Breaking (toprock)",
1265
1269
  bpm: 110,
1266
1270
  stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
@@ -1272,9 +1276,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1272
1276
  label: "Toprock (Indian step)",
1273
1277
  beats: 4,
1274
1278
  keys: [
1275
- { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: D },
1279
+ { beat: 0, pose: { rightHip: -24, rightKnee: 10, leftHip: 10, leftShoulder: 80, leftElbow: 40, rightShoulder: 55, rightElbow: -50, lean: 6, headTilt: -6 }, easing: U },
1276
1280
  { beat: 1, reset: !0, pose: { leftHip: 18, rightHip: 18 } },
1277
- { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: D },
1281
+ { beat: 2, pose: { leftHip: -24, leftKnee: 10, rightHip: 10, rightShoulder: 80, rightElbow: 40, leftShoulder: 55, leftElbow: -50, lean: -6, headTilt: 6 }, easing: U },
1278
1282
  { beat: 3, reset: !0, pose: { leftHip: 18, rightHip: 18 } }
1279
1283
  ]
1280
1284
  },
@@ -1282,7 +1286,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1282
1286
  label: "Kick out",
1283
1287
  beats: 2,
1284
1288
  keys: [
1285
- { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: D },
1289
+ { beat: 0, pose: { rightHip: 72, rightKnee: 4, rightAnkle: -20, leftHip: 4, lean: -12, leftShoulder: 100, leftElbow: 20 }, easing: U },
1286
1290
  { beat: 1, reset: !0 }
1287
1291
  ]
1288
1292
  },
@@ -1290,7 +1294,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1290
1294
  label: "B-boy stance",
1291
1295
  beats: 4,
1292
1296
  keys: [
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 },
1297
+ { 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: Se },
1294
1298
  { beat: 2, pose: { headTilt: 14, lean: -6 } }
1295
1299
  ]
1296
1300
  }
@@ -1302,7 +1306,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1302
1306
  { move: "kick", beats: 4, mirror: !0 },
1303
1307
  { move: "freeze", beats: 4 }
1304
1308
  ]
1305
- }, Yo = {
1309
+ }, Zo = {
1306
1310
  label: "Jazz",
1307
1311
  bpm: 130,
1308
1312
  stance: { leftHip: 10, rightHip: 10 },
@@ -1318,14 +1322,14 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1318
1322
  beat: e,
1319
1323
  // The hands shimmer: the wrists flick a little each quarter beat.
1320
1324
  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 },
1321
- hands: t === 0 ? { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } } : void 0
1325
+ hands: t === 0 ? { left: { ...Y.spread, turn: 2 }, right: { ...Y.spread, turn: 2 } } : void 0
1322
1326
  }))
1323
1327
  },
1324
1328
  kickBallChange: {
1325
1329
  label: "Kick ball change",
1326
1330
  beats: 2,
1327
1331
  keys: [
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 },
1332
+ { 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: U },
1329
1333
  { beat: 1, reset: !0, pose: { rightHip: 10, rightKnee: 24, rightAnkle: 45, leftShoulder: 60, rightShoulder: 60, leftElbow: -20, rightElbow: -20 } },
1330
1334
  { beat: 1.5, pose: { rightAnkle: 0, rightKnee: 6, leftAnkle: 45, leftKnee: 20 } }
1331
1335
  ]
@@ -1363,7 +1367,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1363
1367
  { move: "jazzHands", beats: 4 },
1364
1368
  { move: "splitDrop", beats: 8 }
1365
1369
  ]
1366
- }, Lo = {
1370
+ }, Qo = {
1367
1371
  label: "K-pop",
1368
1372
  bpm: 125,
1369
1373
  stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
@@ -1373,7 +1377,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1373
1377
  pointCombo: {
1374
1378
  label: "Point combo",
1375
1379
  beats: 4,
1376
- easing: we,
1380
+ easing: Se,
1377
1381
  keys: [
1378
1382
  { 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" } },
1379
1383
  { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
@@ -1385,16 +1389,16 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1385
1389
  label: "Big heart, finger heart",
1386
1390
  beats: 4,
1387
1391
  keys: [
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 },
1392
+ { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: Se },
1389
1393
  { beat: 1, pose: { headTilt: 8, lean: 4 } },
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 },
1394
+ { 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: Se },
1391
1395
  { beat: 3, pose: { headTilt: 4 } }
1392
1396
  ]
1393
1397
  },
1394
1398
  isolations: {
1395
1399
  label: "Isolations",
1396
1400
  beats: 2,
1397
- easing: D,
1401
+ easing: U,
1398
1402
  keys: [
1399
1403
  { beat: 0, reset: !0, pose: { lean: -9, headTilt: 11, leftShoulder: 55, leftElbow: -112, rightShoulder: 55, rightElbow: -112, rightHip: 18 }, hands: { left: "fist", right: "fist" } },
1400
1404
  { beat: 0.5, pose: { lean: 0, headTilt: 0, rightHip: 9 } },
@@ -1410,7 +1414,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1410
1414
  { move: "pointCombo", beats: 8, mirror: !0 },
1411
1415
  { move: "isolations", beats: 4 }
1412
1416
  ]
1413
- }, No = {
1417
+ }, er = {
1414
1418
  label: "Bollywood",
1415
1419
  bpm: 120,
1416
1420
  stance: { leftHip: 10, rightHip: 10 },
@@ -1421,19 +1425,19 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1421
1425
  label: "Screw the bulb, pat the dog",
1422
1426
  beats: 2,
1423
1427
  keys: [
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 } } }
1428
+ { 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: { ...Y.cupped, roll: -30 }, left: { ...Y.flat, turn: 0 } } },
1429
+ { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...Y.cupped, roll: 30 } } },
1430
+ { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...Y.cupped, roll: -30 } } },
1431
+ { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...Y.cupped, roll: 30 } } }
1428
1432
  ]
1429
1433
  },
1430
1434
  thumka: {
1431
1435
  label: "Thumka",
1432
1436
  beats: 2,
1433
1437
  keys: [
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 },
1438
+ { 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: { ...Y.open, turn: 2 } }, easing: U },
1435
1439
  { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1436
- { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: D },
1440
+ { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: U },
1437
1441
  { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
1438
1442
  ]
1439
1443
  },
@@ -1442,9 +1446,9 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1442
1446
  beats: 4,
1443
1447
  keys: [
1444
1448
  { 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" } },
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 },
1449
+ { 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: U },
1446
1450
  { 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" } },
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 }
1451
+ { 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: U }
1448
1452
  ]
1449
1453
  }
1450
1454
  },
@@ -1455,7 +1459,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1455
1459
  { move: "thumka", beats: 4, mirror: !0 },
1456
1460
  { move: "lightBulb", beats: 8, mirror: !0 }
1457
1461
  ]
1458
- }, Co = {
1462
+ }, tr = {
1459
1463
  label: "Bhangra",
1460
1464
  bpm: 100,
1461
1465
  stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
@@ -1490,11 +1494,11 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1490
1494
  { move: "basic", beats: 8 },
1491
1495
  { move: "dhamaal", beats: 4 }
1492
1496
  ]
1493
- }, Do = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Xo = {
1497
+ }, nr = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, or = {
1494
1498
  label: "Bharatanatyam",
1495
1499
  bpm: 80,
1496
1500
  // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1497
- stance: { ...Do, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1501
+ stance: { ...nr, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1498
1502
  expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1499
1503
  hands: { left: "pataka", right: "pataka" },
1500
1504
  groove: { bounce: 0 },
@@ -1536,21 +1540,21 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1536
1540
  { move: "alapadma", beats: 8 },
1537
1541
  { move: "tatta", beats: 4 }
1538
1542
  ]
1539
- }, qo = {
1543
+ }, rr = {
1540
1544
  label: "Charleston",
1541
1545
  bpm: 150,
1542
1546
  stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
1543
1547
  expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
1544
- hands: { left: { ...L.spread, turn: 2 }, right: { ...L.spread, turn: 2 } },
1548
+ hands: { left: { ...Y.spread, turn: 2 }, right: { ...Y.spread, turn: 2 } },
1545
1549
  groove: { bounce: 8, accent: "down" },
1546
1550
  moves: {
1547
1551
  basic: {
1548
1552
  label: "Kick forward, kick back",
1549
1553
  beats: 4,
1550
1554
  keys: [
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 },
1555
+ { beat: 0, reset: !0, pose: { rightHip: 48, rightKnee: 8, rightAnkle: 45, leftShoulder: 75, rightShoulder: 15, leftElbow: 30, rightElbow: -10, lean: -7, headTilt: -5 }, easing: U },
1552
1556
  { beat: 1, reset: !0 },
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 },
1557
+ { beat: 2, reset: !0, pose: { leftHip: 18, leftKnee: 85, leftAnkle: 35, rightShoulder: 75, leftShoulder: 15, rightElbow: 30, leftElbow: -10, lean: 7, headTilt: 5 }, easing: U },
1554
1558
  { beat: 3, reset: !0 }
1555
1559
  ]
1556
1560
  },
@@ -1586,7 +1590,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1586
1590
  { move: "basic", beats: 8, mirror: !0 },
1587
1591
  { move: "twist", beats: 4 }
1588
1592
  ]
1589
- }, Uo = {
1593
+ }, sr = {
1590
1594
  label: "Tap",
1591
1595
  bpm: 120,
1592
1596
  // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
@@ -1672,7 +1676,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1672
1676
  { beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
1673
1677
  { beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
1674
1678
  // Arms flare on the finish: one up in front, one up behind.
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 } } },
1679
+ { 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: { ...Y.spread, turn: 2 }, right: { ...Y.spread, turn: 2 } } },
1676
1680
  { beat: 1.75, reset: !0 }
1677
1681
  ]
1678
1682
  }
@@ -1684,7 +1688,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1684
1688
  { move: "heelToe", beats: 8 },
1685
1689
  { move: "crampRoll", beats: 4 }
1686
1690
  ]
1687
- }, zo = {
1691
+ }, ir = {
1688
1692
  label: "Popping (glides, moonwalk)",
1689
1693
  bpm: 100,
1690
1694
  stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
@@ -1744,7 +1748,7 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1744
1748
  reset: !0,
1745
1749
  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
1750
  hands: { right: "fist", left: "fist" },
1747
- easing: we
1751
+ easing: Se
1748
1752
  },
1749
1753
  { beat: 2, pose: { headTilt: -14, lean: -2 } }
1750
1754
  ]
@@ -1757,72 +1761,72 @@ const we = { type: "back", mode: "out", overshoot: 1.1 }, D = "ease-out-cubic",
1757
1761
  { move: "forwardGlide", beats: 8 },
1758
1762
  { move: "toeStand", beats: 4 }
1759
1763
  ]
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 = [];
1775
- for (const r of e.keys) {
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 });
1764
+ }, be = {
1765
+ disco: jo,
1766
+ hipHop: Jo,
1767
+ breaking: Vo,
1768
+ jazz: Zo,
1769
+ kpop: Qo,
1770
+ bollywood: er,
1771
+ bhangra: tr,
1772
+ bharatanatyam: or,
1773
+ charleston: rr,
1774
+ tap: sr,
1775
+ popping: ir
1776
+ }, Ye = (e) => Math.min(1, Math.max(0, e));
1777
+ function lr(e) {
1778
+ const t = { ...N, turn: e.view }, n = [];
1779
+ for (const o of e.keys) {
1780
+ const r = n[n.length - 1], s = !r || o.reset ? t : r.pose;
1781
+ n.push({ at: o.at, pose: { ...s, ...o.pose }, easing: o.easing });
1778
1782
  }
1779
1783
  return n;
1780
1784
  }
1781
- function Jo(e) {
1782
- return e - Vo * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1785
+ function ar(e) {
1786
+ return e - hr * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1783
1787
  }
1784
- const Vo = 0.5;
1785
- function jo(e, t) {
1788
+ const hr = 0.5;
1789
+ function cr(e, t) {
1786
1790
  if (!(t <= e.takeoff || t >= e.landing))
1787
1791
  return (t - e.takeoff) / (e.landing - e.takeoff);
1788
1792
  }
1789
- function Zo(e, t) {
1790
- const n = typeof e == "string" ? ut[e] : e, r = Go(n), o = Fe(t);
1793
+ function fr(e, t) {
1794
+ const n = typeof e == "string" ? kt[e] : e, o = lr(n), r = Ye(t);
1791
1795
  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);
1796
+ for (let g = 0; g < o.length; g++) o[g].at <= r && (s = g);
1797
+ const l = o[s], i = o[Math.min(s + 1, o.length - 1)], a = i.at > l.at ? (r - l.at) / (i.at - l.at) : 0, h = Me(l.pose, i.pose, qe(i.easing ?? "ease-in-out")(Ye(a))), c = cr(n, r);
1794
1798
  return c === void 0 ? { ...h, spin: 0, rise: 0 } : {
1795
1799
  ...h,
1796
- spin: n.spin * Jo(c),
1800
+ spin: n.spin * ar(c),
1797
1801
  rise: 4 * n.height * c * (1 - c)
1798
1802
  };
1799
1803
  }
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;
1804
+ function ur(e, t, n) {
1805
+ const o = typeof e == "string" ? kt[e] : e, r = Ye(t), s = Ye((r - o.takeoff) / (o.landing - o.takeoff));
1806
+ return o.travel * n * s;
1803
1807
  }
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) => ({
1808
+ function Ws(e, t, n = {}) {
1809
+ const o = typeof t == "string" ? kt[t] : t, r = n.start ?? 0, s = n.duration ?? o.duration, l = n.samples ?? 48, i = Array.from({ length: l + 1 }, (c, g) => {
1810
+ const u = g / l;
1811
+ return { time: r + u * s, progress: u, pose: fr(o, u) };
1812
+ }), h = Object.keys(N).filter((c) => i.some((g) => g.pose[c] !== N[c])).map((c) => ({
1809
1813
  id: `${e}-${c}`,
1810
1814
  target: e,
1811
1815
  property: c,
1812
- keyframes: l.map((p) => ({ time: p.time, value: p.pose[c] }))
1816
+ keyframes: i.map((g) => ({ time: g.time, value: g.pose[c] }))
1813
1817
  }));
1814
- if (n.height !== void 0 && r.travel !== 0) {
1818
+ if (n.height !== void 0 && o.travel !== 0) {
1815
1819
  const c = (n.facing ?? 1) < 0 ? -1 : 1;
1816
1820
  h.push({
1817
1821
  id: `${e}-x`,
1818
1822
  target: e,
1819
1823
  property: "x",
1820
- keyframes: l.map((p) => ({ time: p.time, value: (n.x ?? 0) + c * Qo(r, p.progress, n.height) }))
1824
+ keyframes: i.map((g) => ({ time: g.time, value: (n.x ?? 0) + c * ur(o, g.progress, n.height) }))
1821
1825
  });
1822
1826
  }
1823
1827
  return h;
1824
1828
  }
1825
- const er = {
1829
+ const dr = {
1826
1830
  leftHip: -55,
1827
1831
  leftKnee: -95,
1828
1832
  rightHip: 55,
@@ -1834,7 +1838,7 @@ const er = {
1834
1838
  lean: 22,
1835
1839
  stretch: 0.94,
1836
1840
  headTilt: 6
1837
- }, tr = {
1841
+ }, gr = {
1838
1842
  leftHip: 0,
1839
1843
  leftKnee: 0,
1840
1844
  rightHip: 0,
@@ -1848,7 +1852,7 @@ const er = {
1848
1852
  lean: 0,
1849
1853
  stretch: 1.08,
1850
1854
  headTilt: 0
1851
- }, Me = {
1855
+ }, Te = {
1852
1856
  leftHip: -128,
1853
1857
  leftKnee: -152,
1854
1858
  rightHip: 128,
@@ -1862,7 +1866,7 @@ const er = {
1862
1866
  lean: 26,
1863
1867
  stretch: 1,
1864
1868
  headTilt: 14
1865
- }, nr = {
1869
+ }, pr = {
1866
1870
  leftHip: -22,
1867
1871
  leftKnee: -30,
1868
1872
  rightHip: 22,
@@ -1875,7 +1879,7 @@ const er = {
1875
1879
  rightElbow: 0,
1876
1880
  lean: 8,
1877
1881
  headTilt: 0
1878
- }, or = {
1882
+ }, br = {
1879
1883
  leftHip: -58,
1880
1884
  leftKnee: -100,
1881
1885
  rightHip: 58,
@@ -1889,42 +1893,42 @@ const er = {
1889
1893
  lean: 20,
1890
1894
  stretch: 0.93
1891
1895
  };
1892
- function fe(e, t, n, r, o, s = 1300) {
1896
+ function ue(e, t, n, o, r, s = 1300) {
1893
1897
  return {
1894
1898
  label: e,
1895
1899
  view: 1,
1896
1900
  spin: t,
1897
1901
  height: n,
1898
- travel: r,
1902
+ travel: o,
1899
1903
  takeoff: 0.27,
1900
1904
  landing: 0.8,
1901
1905
  duration: s,
1902
1906
  keys: [
1903
1907
  { at: 0, reset: !0 },
1904
- { at: 0.16, pose: er },
1905
- { at: 0.27, pose: tr, easing: "ease-out-quad" },
1906
- ...o,
1907
- { at: 0.76, pose: nr },
1908
- { at: 0.86, pose: or, easing: "ease-out-quad" },
1908
+ { at: 0.16, pose: dr },
1909
+ { at: 0.27, pose: gr, easing: "ease-out-quad" },
1910
+ ...r,
1911
+ { at: 0.76, pose: pr },
1912
+ { at: 0.86, pose: br, easing: "ease-out-quad" },
1909
1913
  { at: 1, reset: !0 }
1910
1914
  ]
1911
1915
  };
1912
1916
  }
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 }
1917
+ const kt = {
1918
+ frontFlip: ue("Front flip (tuck)", 360, 0.56, 0.35, [
1919
+ { at: 0.38, pose: Te, easing: "ease-out-cubic" },
1920
+ { at: 0.64, pose: Te }
1917
1921
  ]),
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 } }
1922
+ backFlip: ue("Back flip (tuck)", -360, 0.58, -0.15, [
1923
+ { at: 0.36, pose: { ...Te, lean: 18 }, easing: "ease-out-cubic" },
1924
+ { at: 0.64, pose: { ...Te, lean: 18 } }
1921
1925
  ]),
1922
- layout: fe("Back layout (straight body)", -360, 0.66, -0.2, [
1926
+ layout: ue("Back layout (straight body)", -360, 0.66, -0.2, [
1923
1927
  // Arched, arms overhead, legs together and long.
1924
1928
  { at: 0.4, pose: { leftHip: 8, rightHip: -8, leftKnee: 0, rightKnee: 0, leftAnkle: 60, rightAnkle: 60, leftShoulder: -178, rightShoulder: 178, lean: -18, headTilt: -14 } },
1925
1929
  { at: 0.64, pose: { leftHip: -4, rightHip: 4, lean: -6, headTilt: -4, leftShoulder: -150, rightShoulder: 150 } }
1926
1930
  ], 1400),
1927
- scissorFlip: fe("Scissor flip", 360, 0.6, 0.45, [
1931
+ scissorFlip: ue("Scissor flip", 360, 0.6, 0.45, [
1928
1932
  // The legs scissor through the turn: left kicks high, then they switch.
1929
1933
  { 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" },
1930
1934
  { at: 0.52, pose: { leftHip: 40, leftKnee: 20, rightHip: 105, rightKnee: 0, leftShoulder: -140, rightShoulder: 140 } },
@@ -1970,7 +1974,7 @@ const ut = {
1970
1974
  ]
1971
1975
  },
1972
1976
  // Leaps: no turn, the shape is the trick.
1973
- splitLeap: fe("Split leap (grand jeté)", 0, 0.36, 0.9, [
1977
+ splitLeap: ue("Split leap (grand jeté)", 0, 0.36, 0.9, [
1974
1978
  // A front split in the air: front leg reaching, back leg long, arms open.
1975
1979
  { 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" },
1976
1980
  { at: 0.64, pose: { lean: 2 } }
@@ -1996,12 +2000,12 @@ const ut = {
1996
2000
  { at: 1, reset: !0 }
1997
2001
  ]
1998
2002
  },
1999
- backHandspring: fe("Back handspring", -360, 0.16, -0.7, [
2003
+ backHandspring: ue("Back handspring", -360, 0.16, -0.7, [
2000
2004
  // Arms reach back overhead to the ground, legs snap over.
2001
2005
  { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
2002
2006
  { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
2003
2007
  ], 1200)
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 = {
2008
+ }, ze = 0.215, je = 0.205, mr = 0.065, Ct = 0.035, wr = 0.165, yr = 0.155, kr = 12, Sr = (e) => e * Math.PI / 180, q = {
2005
2009
  turn: 0,
2006
2010
  lean: 0,
2007
2011
  side: 0,
@@ -2043,33 +2047,33 @@ const ut = {
2043
2047
  lookX: 0,
2044
2048
  lookY: 0
2045
2049
  };
2046
- function j(e = {}) {
2047
- return { ...V, ...e };
2050
+ function Z(e = {}) {
2051
+ return { ...q, ...e };
2048
2052
  }
2049
- const hr = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2050
- function ss(e) {
2053
+ const Er = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2054
+ function Os(e) {
2051
2055
  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;
2056
+ for (const [n, o] of Object.entries(e)) {
2057
+ const r = n.replace(/(^|\.)(left|right)(\.|$)/, (s, l, i, a) => `${l}${i === "left" ? "right" : "left"}${a}`);
2058
+ t[r] = Er.has(n) ? -o : o;
2055
2059
  }
2056
2060
  return t;
2057
2061
  }
2058
- function G(e, t) {
2062
+ function V(e, t) {
2059
2063
  const n = {};
2060
- for (const r of ["left", "right"]) for (const [o, s] of Object.entries(t)) n[`${e}.${r}.${o}`] = s;
2064
+ for (const o of ["left", "right"]) for (const [r, s] of Object.entries(t)) n[`${e}.${o}.${r}`] = s;
2061
2065
  return n;
2062
2066
  }
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({
2067
+ const Mr = {
2068
+ rest: q,
2069
+ wave: Z({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2070
+ cheer: Z({ ...V("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2071
+ point: Z({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
2072
+ handsOnHips: Z({ ...V("arm", { spread: 50, bend: -105, elbow: 0 }), ...V("leg", { spread: 9 }), smile: 0.8 }),
2073
+ think: Z({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
2074
+ shrug: Z({ ...V("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
2075
+ sit: Z({ ...V("leg", { swing: 90, knee: 90, spread: 4 }), ...V("arm", { swing: 25, elbow: 45, spread: 8 }) }),
2076
+ kneel: Z({
2073
2077
  "leg.left.swing": 90,
2074
2078
  "leg.left.knee": 90,
2075
2079
  // The back thigh leans back a little so its knee meets the ground beside the
@@ -2077,54 +2081,54 @@ const cr = {
2077
2081
  "leg.right.swing": -18,
2078
2082
  "leg.right.knee": 108,
2079
2083
  "leg.right.ankle": 16,
2080
- ...G("arm", { swing: 20, elbow: 30 })
2084
+ ...V("arm", { swing: 20, elbow: 30 })
2081
2085
  }),
2082
- crouch: j({ ...G("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...G("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2086
+ crouch: Z({ ...V("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...V("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
2083
2087
  // On hands and knees: the back nearly level, arms straight down, the toes
2084
2088
  // pointed back along the ground.
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 })
2089
+ crawl: Z({ lean: 82, "head.nod": -35, ...V("arm", { swing: 80, elbow: 0, spread: 4 }), ...V("leg", { knee: 92, ankle: -88 }) }),
2090
+ lieDown: Z({ roll: 90, ...V("arm", { spread: 8 }), "head.nod": 0 })
2087
2091
  };
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) => ({
2092
+ function Hr(e = {}) {
2093
+ const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, o = e.hipWidth ?? 0.022, r = Math.max(0.12, 1 - t - Ct - (ze + je)), s = (a) => ({
2090
2094
  id: `arm.${a}`,
2091
2095
  parent: "spine",
2092
2096
  offset: [(a === "left" ? 1 : -1) * n, -0.035, 0],
2093
2097
  rest: [0, -1, 0],
2094
2098
  side: a === "left" ? 1 : -1,
2095
2099
  bones: [
2096
- { length: sr, width: [1.25, 0.9] },
2097
- { length: lr, width: [0.9, 0.75] }
2100
+ { length: wr, width: [1.25, 0.9] },
2101
+ { length: yr, width: [0.9, 0.75] }
2098
2102
  ]
2099
- }), i = (a) => ({
2103
+ }), l = (a) => ({
2100
2104
  id: `leg.${a}`,
2101
2105
  parent: null,
2102
- offset: [(a === "left" ? 1 : -1) * r, 0, 0],
2106
+ offset: [(a === "left" ? 1 : -1) * o, 0, 0],
2103
2107
  rest: [0, -1, 0],
2104
2108
  side: a === "left" ? 1 : -1,
2105
2109
  bones: [
2106
- { length: Xe, width: [1.45, 1.05] },
2107
- { length: qe, width: [1.05, 0.85] },
2108
- { length: rr, width: [0.95, 0.7] }
2110
+ { length: ze, width: [1.45, 1.05] },
2111
+ { length: je, width: [1.05, 0.85] },
2112
+ { length: mr, width: [0.95, 0.7] }
2109
2113
  ]
2110
- }), l = (a, h) => a[h] ?? V[h] ?? 0;
2114
+ }), i = (a, h) => a[h] ?? q[h] ?? 0;
2111
2115
  return {
2112
2116
  id: "human",
2113
- hipHeight: Xe + qe,
2117
+ hipHeight: ze + je,
2114
2118
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
2115
2119
  chains: [
2116
- i("left"),
2117
- i("right"),
2120
+ l("left"),
2121
+ l("right"),
2118
2122
  {
2119
2123
  id: "spine",
2120
2124
  parent: null,
2121
2125
  rest: [0, 1, 0],
2122
2126
  bones: [
2123
- { length: o / 2, width: [1.7, 1.4] },
2124
- { length: o / 2, width: [1.4, 1.1] }
2127
+ { length: r / 2, width: [1.7, 1.4] },
2128
+ { length: r / 2, width: [1.4, 1.1] }
2125
2129
  ]
2126
2130
  },
2127
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Bt, width: [1, 0.9] }] },
2131
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Ct, width: [1, 0.9] }] },
2128
2132
  s("left"),
2129
2133
  s("right")
2130
2134
  ],
@@ -2144,47 +2148,47 @@ function fr(e = {}) {
2144
2148
  ],
2145
2149
  angles(a, h) {
2146
2150
  if (h.id === "spine") {
2147
- const f = -l(a, "lean") / 2, g = l(a, "side") / 2;
2151
+ const d = -i(a, "lean") / 2, b = i(a, "side") / 2;
2148
2152
  return [
2149
- { swing: f, spread: g },
2150
- { swing: f, spread: g }
2153
+ { swing: d, spread: b },
2154
+ { swing: d, spread: b }
2151
2155
  ];
2152
2156
  }
2153
2157
  if (h.id === "neck") return [{ swing: 0, spread: 0 }];
2154
- const [c, p] = h.id.split("."), d = (f) => l(a, `${c}.${p}.${f}`);
2158
+ const [c, g] = h.id.split("."), u = (d) => i(a, `${c}.${g}.${d}`);
2155
2159
  if (c === "arm")
2156
2160
  return [
2157
- { swing: d("swing"), spread: d("spread") },
2158
- { swing: d("elbow"), spread: d("bend") }
2161
+ { swing: u("swing"), spread: u("spread") },
2162
+ { swing: u("elbow"), spread: u("bend") }
2159
2163
  ];
2160
- const u = (h.side ?? 1) * d("rotate"), b = 1 - Math.cos(ar(d("rotate")));
2164
+ const f = (h.side ?? 1) * u("rotate"), p = 1 - Math.cos(Sr(u("rotate")));
2161
2165
  return [
2162
- { swing: d("swing"), spread: d("spread"), yaw: u },
2163
- { swing: -d("knee"), spread: 0, yaw: u },
2166
+ { swing: u("swing"), spread: u("spread"), yaw: f },
2167
+ { swing: -u("knee"), spread: 0, yaw: f },
2164
2168
  // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2165
- { swing: 90 + d("ankle") - b * (d("swing") - d("knee")), spread: 0, yaw: (ir + d("toeOut")) * (h.side ?? 1) }
2169
+ { swing: 90 + u("ankle") - p * (u("swing") - u("knee")), spread: 0, yaw: (kr + u("toeOut")) * (h.side ?? 1) }
2166
2170
  ];
2167
2171
  },
2168
2172
  withAngles(a, h, c) {
2169
- const [p, d] = h.id.split("."), u = (b) => `${p}.${d}.${b}`;
2170
- return p === "arm" ? {
2173
+ const [g, u] = h.id.split("."), f = (p) => `${g}.${u}.${p}`;
2174
+ return g === "arm" ? {
2171
2175
  ...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;
2176
+ [f("swing")]: c[0].swing,
2177
+ [f("spread")]: c[0].spread,
2178
+ [f("elbow")]: c[1].swing,
2179
+ [f("bend")]: c[1].spread
2180
+ } : g === "leg" ? { ...a, [f("swing")]: c[0].swing, [f("spread")]: c[0].spread, [f("knee")]: -c[1].swing } : a;
2177
2181
  },
2178
2182
  boneScale(a, h) {
2179
- const c = Math.min(3, Math.max(0.3, l(a, "stretch")));
2183
+ const c = Math.min(3, Math.max(0.3, i(a, "stretch")));
2180
2184
  return h?.id.startsWith("arm.") ? Math.sqrt(c) : c;
2181
2185
  },
2182
2186
  headPose(a) {
2183
- const h = Math.min(3, Math.max(0.3, l(a, "stretch")));
2187
+ const h = Math.min(3, Math.max(0.3, i(a, "stretch")));
2184
2188
  return {
2185
- yaw: l(a, "head.turn"),
2186
- nod: l(a, "head.nod"),
2187
- tilt: l(a, "head.tilt"),
2189
+ yaw: i(a, "head.turn"),
2190
+ nod: i(a, "head.nod"),
2191
+ tilt: i(a, "head.tilt"),
2188
2192
  // The head keeps its area: taller and narrower when stretched.
2189
2193
  sx: 1 / Math.sqrt(h),
2190
2194
  sy: Math.sqrt(h)
@@ -2209,15 +2213,15 @@ function fr(e = {}) {
2209
2213
  }
2210
2214
  };
2211
2215
  }
2212
- function ls(e) {
2216
+ function Is(e) {
2213
2217
  const t = e.split(".");
2214
2218
  if (t[0] === "hand" && t.length >= 3) {
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")}`;
2219
+ const o = `${t[1] === "left" ? "Left" : "Right"} hand`, r = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, s = t.slice(2).join(".");
2220
+ return `${o} · ${r[s] ?? s.replace(".curl", " curl").replace(".across", " across")}`;
2217
2221
  }
2218
2222
  if (t.length === 3) {
2219
- const [r, o, s] = t;
2220
- return `${`${o === "left" ? "Left" : "Right"} ${r}`} · ${{
2223
+ const [o, r, s] = t;
2224
+ return `${`${r === "left" ? "Left" : "Right"} ${o}`} · ${{
2221
2225
  swing: "forward / back",
2222
2226
  spread: "out / in",
2223
2227
  elbow: "elbow bend",
@@ -2251,284 +2255,284 @@ function ls(e) {
2251
2255
  lookY: "Look up / down"
2252
2256
  }[e] ?? e;
2253
2257
  }
2254
- const ur = {
2258
+ const vr = {
2255
2259
  leftEye: "eye.left",
2256
2260
  rightEye: "eye.right",
2257
2261
  leftBrow: "brow.left",
2258
2262
  rightBrow: "brow.right"
2259
- }, is = Object.fromEntries(
2260
- Object.entries(Z).map(([e, t]) => [
2263
+ }, $s = Object.fromEntries(
2264
+ Object.entries(D).map(([e, t]) => [
2261
2265
  e,
2262
- Object.fromEntries(Object.entries(t).map(([n, r]) => [ur[n] ?? n, r]))
2266
+ Object.fromEntries(Object.entries(t).map(([n, o]) => [vr[n] ?? n, o]))
2263
2267
  ])
2264
2268
  );
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 = [
2269
+ function Bs(e, t) {
2270
+ const n = Math.min(1, Math.max(0, e.turn ?? 0)), o = 1 - n, r = { ...q, turn: n }, s = [
2267
2271
  { stick: "right", human: "left", s: 1 },
2268
2272
  { stick: "left", human: "right", s: -1 }
2269
2273
  ];
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));
2275
- }
2276
- o.lean = e.lean * n, o.side = e.lean * r, o["head.tilt"] = e.headTilt * r, o["head.nod"] = e.headTilt * n;
2277
- for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
2278
- return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
2279
- }
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;
2274
+ for (const { stick: l, human: i, s: a } of s) {
2275
+ const h = e[`${l}Shoulder`], c = e[`${l}Elbow`];
2276
+ r[`arm.${i}.spread`] = h * o, r[`arm.${i}.swing`] = a * h * n, r[`arm.${i}.bend`] = c * o, r[`arm.${i}.elbow`] = a * c * n;
2277
+ const g = e[`${l}Hip`], u = e[`${l}Knee`], f = o + a * n;
2278
+ r[`leg.${i}.rotate`] = 90 * o, r[`leg.${i}.spread`] = 0, r[`leg.${i}.swing`] = g * f, r[`leg.${i}.knee`] = u * f, r[`leg.${i}.ankle`] = -(e[`${l}Ankle`] ?? 0), r[`leg.${i}.toeOut`] = (e[`${l}FootOut`] ?? 0) * Tr, r[`eye.${i}`] = e[`${l}Eye`], r[`brow.${i}`] = e[`${l}Brow`], t && Object.assign(r, Ar(i, t[l] ?? _, e[`${l}Wrist`] ?? 0, n));
2279
+ }
2280
+ r.lean = e.lean * n, r.side = e.lean * o, r["head.tilt"] = e.headTilt * o, r["head.nod"] = e.headTilt * n;
2281
+ for (const l of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) r[l] = e[l];
2282
+ return r.lift = e.rise ?? 0, r.roll = e.spin ?? 0, r;
2283
+ }
2284
+ const Tr = 70;
2285
+ function Ar(e, t, n, o) {
2286
+ const r = e === "right" ? 1 - o : 1 + o, s = {};
2287
+ for (const l of Object.keys(_)) s[`hand.${e}.${l}`] = t[l] ?? _[l];
2288
+ return s[`hand.${e}.turn`] = (t.turn ?? 0) - r, s[`hand.${e}.roll`] = (t.roll ?? 0) + n, s;
2285
2289
  }
2286
2290
  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];
2291
+ function pn([e, t, n], o) {
2292
+ const r = Math.cos(o), s = Math.sin(o);
2293
+ return [e, t * r + n * s, -t * s + n * r];
2290
2294
  }
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];
2295
+ function St([e, t, n], o) {
2296
+ const r = Math.cos(o), s = Math.sin(o);
2297
+ return [e * r - t * s, e * s + t * r, n];
2294
2298
  }
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];
2299
+ function ce([e, t, n], o) {
2300
+ const r = Math.cos(o), s = Math.sin(o);
2301
+ return [e * r + n * s, t, -e * s + n * r];
2298
2302
  }
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);
2303
+ const ie = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Ne = (e, t) => [e[0] * t, e[1] * t, e[2] * t], $e = (e, t) => St(pn(e, t.swing), t.spread);
2304
+ function Je(e, t) {
2305
+ const n = ce(e, t);
2302
2306
  return { point: { x: n[0], y: -n[1] }, depth: n[2] };
2303
2307
  }
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 = {};
2308
+ function Et(e, t, n) {
2309
+ const o = n, s = [0, e.hipHeight * o * (e.boneScale?.(t, null) ?? 1), 0], l = {};
2310
+ for (const d of e.chains) {
2311
+ const b = d.parent ? l[d.parent] : void 0;
2312
+ if (d.parent && !b) throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);
2313
+ const m = d.at ?? (b ? b.joints3.length - 1 : 0), w = b ? b.joints3[m] : s, y = b ? b.frames[Math.max(0, m - 1)] : { swing: 0, spread: 0 }, H = d.offset ? ie(w, $e(Ne(d.offset, o), y)) : w, E = d.side ?? 1, k = e.boneScale?.(t, d) ?? 1, M = e.angles(t, d), T = [H], S = [];
2314
+ let x = y.swing, K = y.spread;
2315
+ d.bones.forEach((v, A) => {
2316
+ const W = M[A] ?? { swing: 0, spread: 0 };
2317
+ x += Q(W.swing), K += Q(W.spread) * E, S.push({ swing: x, spread: K });
2318
+ const $ = ce($e(d.rest, { swing: x, spread: K }), Q(W.yaw ?? 0));
2319
+ T.push(ie(T[A], Ne($, v.length * o * k)));
2320
+ }), l[d.id] = { joints3: T, frames: S };
2321
+ }
2322
+ const i = l[e.head.on], a = e.headPose?.(t) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, h = i.frames[i.frames.length - 1], c = e.head.size / 2 * o, g = c * a.sx, u = c * a.sy, f = (d) => $e(ce(pn(St(d, -Q(a.tilt)), -Q(a.nod)), Q(a.yaw)), h), p = ie(i.joints3[i.joints3.length - 1], f([0, u, 0]));
2323
+ return { height: o, root: s, chains: l, head: { center: p, rx: g, ry: u, toBody: f } };
2324
+ }
2325
+ function Mt(e, t, n) {
2326
+ const o = n.height, r = Q(90 * (t.turn ?? 0)), s = Et(e, t, o), { root: l } = s, i = s.chains, { rx: a, ry: h } = s.head, c = s.head.toBody, g = s.head.center, u = {};
2323
2327
  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] = {
2328
+ const { joints3: x, frames: K } = i[S.id], v = x.map((A) => Je(A, r));
2329
+ u[S.id] = {
2326
2330
  id: S.id,
2327
- joints3: A,
2331
+ joints3: x,
2328
2332
  frames: K,
2329
- points: v.map((T) => T.point),
2330
- depths: v.map((T) => T.depth)
2333
+ points: v.map((A) => A.point),
2334
+ depths: v.map((A) => A.depth)
2331
2335
  };
2332
2336
  }
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);
2337
+ const f = Je(g, r), p = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((S) => ce(c(S), r)), d = Je(l, r).point, b = Q(t.roll ?? 0), m = (S) => {
2338
+ const x = S.x - d.x, K = S.y - d.y;
2339
+ return { x: d.x + x * Math.cos(b) - K * Math.sin(b), y: d.y + x * Math.sin(b) + K * Math.cos(b) };
2340
+ }, w = ([S, x, K]) => [S * Math.cos(b) + x * Math.sin(b), -S * Math.sin(b) + x * Math.cos(b), K];
2341
+ for (const S of Object.values(u)) S.points = S.points.map(m);
2338
2342
  const y = {
2339
- center: m(u.point),
2340
- depth: u.depth,
2343
+ center: m(f.point),
2344
+ depth: f.depth,
2341
2345
  rx: a,
2342
2346
  ry: h,
2343
2347
  angle: 0,
2344
- axes: b.map(k)
2348
+ axes: p.map(w)
2345
2349
  }, H = y.axes[1];
2346
2350
  y.angle = Math.atan2(H[0], H[1]);
2347
2351
  const E = (S) => {
2348
2352
  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)];
2353
+ const x = u[S.chain];
2354
+ return x.points[Math.min(S.joint, x.points.length - 1)];
2351
2355
  };
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
+ let k = 0;
2357
+ (n.contact ?? "ground") === "ground" && (k = -Math.max(...e.contacts.map((S) => E(S).y))), k -= (t.lift ?? 0) * o;
2358
+ const M = (S) => ({ x: S.x, y: S.y + k });
2359
+ for (const S of Object.values(u)) S.points = S.points.map(M);
2356
2360
  y.center = M(y.center);
2357
- const x = e.contacts.map((S) => ({ spec: S, point: E(S) }));
2361
+ const T = e.contacts.map((S) => ({ spec: S, point: E(S) }));
2358
2362
  return {
2359
- height: r,
2360
- view: o,
2361
- chains: d,
2363
+ height: o,
2364
+ view: r,
2365
+ chains: u,
2362
2366
  head: y,
2363
- hip: M(m(f)),
2364
- contacts: x,
2365
- groundY: Math.max(...x.map((S) => S.point.y))
2367
+ hip: M(m(d)),
2368
+ contacts: T,
2369
+ groundY: Math.max(...T.map((S) => S.point.y))
2366
2370
  };
2367
2371
  }
2368
- const ot = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], sn = (e) => {
2372
+ const ht = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], bn = (e) => {
2369
2373
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
2370
2374
  return [e[0] / t, e[1] / t, e[2] / t];
2371
2375
  };
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)];
2376
+ function mn(e, t, n) {
2377
+ const o = n.height, r = Q(90 * (t.turn ?? 0)), s = Q(t.roll ?? 0), l = Et(e, t, o), i = ce(l.root, r), a = (b) => ie(St(ht(ce(b, r), i), -s), i), h = {};
2378
+ for (const b of e.chains) h[b.id] = l.chains[b.id].joints3.map(a);
2379
+ const c = a(l.head.center), g = (b) => bn(ht(a(ie(l.head.center, l.head.toBody(b))), c)), u = [g([1, 0, 0]), g([0, 1, 0]), g([0, 0, 1])], f = (b) => {
2380
+ if ("head" in b) return ie(c, Ne(u[1], l.head.ry));
2381
+ const m = h[b.chain];
2382
+ return m[Math.min(b.joint, m.length - 1)];
2379
2383
  };
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]];
2384
+ let p = 0;
2385
+ (n.contact ?? "ground") === "ground" && (p = -Math.min(...e.contacts.map((b) => f(b)[1]))), p += (t.lift ?? 0) * o;
2386
+ const d = (b) => [b[0], b[1] + p, b[2]];
2383
2387
  return {
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 }
2388
+ height: o,
2389
+ hip: d(i),
2390
+ chains: Object.fromEntries(Object.entries(h).map(([b, m]) => [b, m.map(d)])),
2391
+ head: { center: d(c), rx: l.head.rx, ry: l.head.ry, axes: u }
2388
2392
  };
2389
2393
  }
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 };
2394
+ function wn(e, t, n, o) {
2395
+ const r = n.height, s = Q(90 * (t.turn ?? 0)), l = Et(e, t, r), i = mn(e, t, n), a = i.hip, h = i.chains, c = i.head.center, g = (S) => {
2396
+ if ("head" in S) return ie(c, Ne(i.head.axes[1], i.head.ry));
2397
+ const x = h[S.chain];
2398
+ return x[Math.min(S.joint, x.length - 1)];
2399
+ }, u = o.toView(a), f = o.toScreen(u), p = o.toScreen([u[0] + 1, u[1], u[2]]), d = Math.hypot(p.x - f.x, p.y - f.y), b = (S) => {
2400
+ const x = o.toView(S);
2401
+ return { point: o.toScreen(x), depth: x[2] * d };
2398
2402
  }, m = {};
2399
2403
  for (const S of e.chains) {
2400
- const A = h[S.id].map(g);
2404
+ const x = h[S.id].map(b);
2401
2405
  m[S.id] = {
2402
2406
  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)
2407
+ joints3: l.chains[S.id].joints3,
2408
+ frames: l.chains[S.id].frames,
2409
+ points: x.map((K) => K.point),
2410
+ depths: x.map((K) => K.depth)
2407
2411
  };
2408
2412
  }
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 = {
2413
+ const w = o.toView(c), y = o.toScreen(w), H = o.toScreen([w[0] + 1, w[1], w[2]]), E = Math.hypot(H.x - y.x, H.y - y.y), k = i.head.axes.map((S) => bn(ht(o.toView(ie(c, S)), w))), M = {
2410
2414
  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 }));
2415
+ depth: w[2] * d,
2416
+ rx: l.head.rx * E,
2417
+ ry: l.head.ry * E,
2418
+ angle: Math.atan2(k[1][0], k[1][1]),
2419
+ axes: k
2420
+ }, T = e.contacts.map((S) => ({ spec: S, point: b(g(S)).point }));
2417
2421
  return {
2418
- height: o * f,
2422
+ height: r * d,
2419
2423
  view: s,
2420
2424
  chains: m,
2421
2425
  head: M,
2422
- hip: u,
2423
- contacts: x,
2424
- groundY: Math.max(...x.map((S) => S.point.y))
2426
+ hip: f,
2427
+ contacts: T,
2428
+ groundY: Math.max(...T.map((S) => S.point.y))
2425
2429
  };
2426
2430
  }
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 };
2431
+ function yn(e, [t, n, o]) {
2432
+ const [r, s, l] = e.axes, i = [
2433
+ r[0] * t * e.rx + s[0] * n * e.ry + l[0] * o * e.rx,
2434
+ r[1] * t * e.rx + s[1] * n * e.ry + l[1] * o * e.rx,
2435
+ r[2] * t * e.rx + s[2] * n * e.ry + l[2] * o * e.rx
2436
+ ], a = Math.hypot(t, n, o) || 1, h = (r[2] * t + s[2] * n + l[2] * o) / a;
2437
+ return { point: { x: e.center.x + i[0], y: e.center.y - i[1] }, depth: e.depth + i[2], facing: h };
2434
2438
  }
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;
2439
+ const Ae = (e) => e * 180 / Math.PI, de = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ve = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], ye = (e) => Math.hypot(e[0], e[1], e[2]), ct = (e) => {
2440
+ const t = ye(e) || 1;
2437
2441
  return [e[0] / t, e[1] / t, e[2] / t];
2438
2442
  }, xe = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2439
- function $t(e) {
2440
- const [t, n, r] = rt(e);
2441
- return { swing: Math.asin(Math.max(-1, Math.min(1, r))), spread: Math.atan2(t, -n) };
2443
+ function Dt(e) {
2444
+ const [t, n, o] = ct(e);
2445
+ return { swing: Math.asin(Math.max(-1, Math.min(1, o))), spread: Math.atan2(t, -n) };
2442
2446
  }
2443
- function pr(e, t, n, r, o) {
2444
- const s = e.chains.find((A) => A.id === n);
2447
+ function xr(e, t, n, o, r) {
2448
+ const s = e.chains.find((x) => x.id === n);
2445
2449
  if (!s) throw new Error(`reach: no chain ${n} in ${e.id}`);
2446
2450
  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`);
2447
2451
  if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
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 }
2452
+ const l = Mt(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: r.height, contact: "none" }), i = l.chains[n], a = i.joints3[0], h = ye(de(i.joints3[1], i.joints3[0])), c = ye(de(i.joints3[2], i.joints3[1])), g = s.parent ? l.chains[s.parent].frames[Math.max(0, (s.at ?? l.chains[s.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, u = de(o, a), f = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, ye(u))), p = ct(u), d = s.parent !== null, b = $e(s.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), g);
2453
+ let m = de(b, [p[0] * Ve(b, p), p[1] * Ve(b, p), p[2] * Ve(b, p)]);
2454
+ ye(m) < 1e-6 && (m = ce([1, 0, 0], 0)), m = ct(m);
2455
+ const w = (h * h + f * f - c * c) / (2 * h * f), y = Math.sqrt(Math.max(0, 1 - w * w)), H = [
2456
+ a[0] + h * (w * p[0] + y * m[0]),
2457
+ a[1] + h * (w * p[1] + y * m[1]),
2458
+ a[2] + h * (w * p[2] + y * m[2])
2459
+ ], E = [a[0] + p[0] * f, a[1] + p[1] * f, a[2] + p[2] * f], k = s.side ?? 1, M = Dt(de(H, a)), T = Dt(de(E, H)), S = [
2460
+ { swing: Ae(xe(M.swing - g.swing)), spread: Ae(xe(M.spread - g.spread)) * k },
2461
+ { swing: Ae(xe(T.swing - M.swing)), spread: Ae(xe(T.spread - M.spread)) * k }
2458
2462
  ];
2459
2463
  return e.withAngles(t, s, S);
2460
2464
  }
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);
2465
+ const Kr = 0.34, re = 0.12, te = -0.4, oe = (e, t, n) => e[t] ?? n, Pr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), Wr = 0.45, Or = 0.35, Ir = 0.7;
2466
+ function Ce(e, t, n) {
2467
+ const o = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), r = yn(e, [n.x, n.y, o(n)]).facing, s = e.axes[2], l = Math.atan2(s[0], s[2]), i = Math.cos(l), a = i >= 0 ? 1 : -1, h = a * Math.max(Or, Math.abs(i)), c = a * Math.max(Ir, Math.abs(i)), g = Math.cos(e.angle), u = Math.sin(e.angle);
2464
2468
  return {
2465
- facing: o,
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 };
2469
+ facing: r,
2470
+ points: t.map((f) => {
2471
+ const p = Wr * Math.sin(l) + n.x * h + (f.x - n.x) * c, d = f.y + s[1] * o(f), b = p * e.rx, m = d * e.ry;
2472
+ return { x: e.center.x + b * g + m * u, y: e.center.y + b * u - m * g };
2469
2473
  })
2470
2474
  };
2471
2475
  }
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);
2476
+ const Ke = (e, t, n, o = 12) => Array.from({ length: o + 1 }, (r, s) => {
2477
+ const l = s / o, i = 1 - l;
2478
+ return { x: i * i * e.x + 2 * i * l * t.x + l * l * n.x, y: i * i * e.y + 2 * i * l * t.y + l * l * n.y };
2479
+ }), Ze = (e, t, n, o, r = 16) => Array.from({ length: r }, (s, l) => {
2480
+ const i = Math.PI * 2 * l / r;
2481
+ return { x: e + Math.cos(i) * n, y: t + Math.sin(i) * o };
2482
+ }), qt = 0.05;
2483
+ function $r(e, t, n, o) {
2484
+ const r = Math.max(1, Math.min(o * 0.6, 0.14 * t.rx)), s = (m, w) => Ce(t, m, w).points, l = (m, w) => Ce(t, [], { x: m, y: w }).facing, i = oe(n, "smile", 0), a = oe(n, "blink", 0), h = oe(n, "lookX", 0), c = oe(n, "lookY", 0), g = oe(n, "browTilt", 0);
2481
2485
  for (const m of [1, -1]) {
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);
2486
+ const w = m === 1 ? "left" : "right", y = Kr * m;
2487
+ if (l(y, re) < qt) continue;
2488
+ const H = { x: y, y: re }, E = Pr(oe(n, `eye.${w}`, 1), a);
2485
2489
  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);
2490
+ const S = i > 0.5 ? 0.12 : -0.06;
2491
+ e.line(s(Ke({ x: y - 0.12, y: re }, { x: y, y: re + S }, { x: y + 0.12, y: re }), H), r);
2488
2492
  } else {
2489
2493
  if (E > 1.2) {
2490
2494
  const v = 0.13 * E;
2491
- e.shape(s(Ge(y, re, v * 0.85, v), H), "#ffffff", o);
2495
+ e.shape(s(Ze(y, re, v * 0.85, v), H), "#ffffff", r);
2492
2496
  }
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);
2497
+ const S = E > 1.2 ? 0.075 : 0.1, x = y + h * 0.08, K = re - c * 0.07;
2498
+ e.shape(s(Ze(x, K, S, S * 1.1 * Math.min(E, 1)), H), e.ink, 0);
2495
2499
  }
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);
2498
- }
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);
2500
+ const k = re + 0.3 + oe(n, `brow.${w}`, 0) * 0.14 + Math.max(0, E - 1) * 0.12, M = { x: y + m * 0.13, y: k }, T = { x: y - m * 0.13, y: k + g * 0.1 };
2501
+ e.line(s([M, { x: (M.x + T.x) / 2, y: (M.y + T.y) / 2 }, T], { x: y, y: k }), r);
2502
+ }
2503
+ const u = { x: 0, y: te };
2504
+ if (l(0, te) < -qt) return;
2505
+ const f = 0.25 * Math.max(0.3, oe(n, "mouthWidth", 1)), p = Math.min(1, Math.max(0, oe(n, "mouth", 0)));
2506
+ if (p <= 0.05) {
2507
+ e.line(s(Ke({ x: -f, y: te }, { x: 0, y: te - i * 0.25 }, { x: f, y: te }), u), r);
2504
2508
  return;
2505
2509
  }
2506
- const f = 0.3 * b;
2507
- let g;
2508
- if (l > 0.3) {
2510
+ const d = 0.3 * p;
2511
+ let b;
2512
+ if (i > 0.3) {
2509
2513
  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 })];
2514
+ b = [...Ke({ x: f, y: m }, { x: 0, y: te - d * 2 }, { x: -f, y: m })];
2515
+ } else if (i < -0.3) {
2516
+ const m = te - d * 0.6;
2517
+ b = [...Ke({ x: f, y: m }, { x: 0, y: te + d * 1.4 }, { x: -f, y: m })];
2514
2518
  } else
2515
- g = Ge(0, te, u * 0.8, f);
2516
- e.shape(s(g, d), e.ink, 0);
2519
+ b = Ze(0, te, f * 0.8, d);
2520
+ e.shape(s(b, u), e.ink, 0);
2517
2521
  }
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";
2522
+ function Br(e = {}) {
2523
+ const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", o = e.look ?? "clean", r = e.height ?? 300, s = n === "stick";
2520
2524
  return {
2521
- plan: e.plan ?? fr({
2525
+ plan: e.plan ?? Hr({
2522
2526
  headSize: e.headSize ?? (t ? 0.3 : 0.24),
2523
2527
  shoulderWidth: s ? 0 : e.shoulderWidth ?? 0.06,
2524
2528
  hipWidth: s ? 0 : e.hipWidth ?? 0.022
2525
2529
  }),
2526
2530
  figure: n,
2527
- look: r,
2528
- height: o,
2529
- lineWidth: e.lineWidth ?? o * (t ? 0.045 : 0.022),
2530
- ink: e.ink ?? (r === "pencil" ? "#2f2f33" : "#1e293b"),
2531
- skin: e.skin ?? (r === "pencil" ? "none" : "#ffffff"),
2531
+ look: o,
2532
+ height: r,
2533
+ lineWidth: e.lineWidth ?? r * (t ? 0.045 : 0.022),
2534
+ ink: e.ink ?? (o === "pencil" ? "#2f2f33" : "#1e293b"),
2535
+ skin: e.skin ?? (o === "pencil" ? "none" : "#ffffff"),
2532
2536
  seed: e.seed ?? 1,
2533
2537
  pencil: e.pencil ?? {},
2534
2538
  layers: e.layers ?? {},
@@ -2538,110 +2542,110 @@ function Er(e = {}) {
2538
2542
  handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
2539
2543
  };
2540
2544
  }
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)]);
2545
+ function _s(e, t, n, o) {
2546
+ const { point: r, facing: s } = yn(e, [t, n, o]);
2547
+ return { point: r, facing: s };
2548
+ }
2549
+ const ft = (e) => e.rest[1] < -0.5, _r = 0.3;
2550
+ function Fr(e, t, n) {
2551
+ return e.figure === "stick" ? ft(t) ? n.slice(0, 3) : n : ft(t) && n.length >= 3 ? pe(n[0], n[1], n[2], _r) : n.length === 3 ? pe(n[0], n[1], n[2], 1) : n;
2552
+ }
2553
+ function Ht(e, t) {
2554
+ const n = e.plan.id === "human" ? { ...q, ...t } : t;
2555
+ return vt(e, n, Mt(e.plan, n, { height: e.height, contact: e.contact }));
2556
+ }
2557
+ function vt(e, t, n) {
2558
+ const o = {}, r = {}, s = {}, l = 0.01 * e.height;
2559
+ e.plan.chains.forEach((u) => {
2560
+ const f = n.chains[u.id];
2561
+ o[u.id] = f.points;
2562
+ const p = f.depths.reduce((w, y) => w + y, 0) / f.depths.length, d = u.parent ? n.chains[u.parent] : void 0, b = d ? d.depths[u.at ?? d.depths.length - 1] : 0, m = p - b;
2563
+ s[u.id] = Math.abs(m) < l ? 0 : m, r[u.id] = { points: Fr(e, u, f.points), depth: p };
2564
+ }), r.head = { points: [n.head.center], depth: n.head.depth }, s.head = 0;
2565
+ const i = [...e.plan.chains.map((u) => u.id), "head"], a = [...i].sort((u, f) => s[u] - s[f] || i.indexOf(u) - i.indexOf(f)), h = { hip: n.hip };
2566
+ for (const [u, [f, p]] of Object.entries(e.plan.landmarks ?? {})) {
2567
+ const d = n.chains[f]?.points;
2568
+ d && (h[u] = d[Math.min(p, d.length - 1)]);
2565
2569
  }
2566
2570
  const c = {};
2567
- for (const [d, u] of Object.entries(h)) c[d] = u.y >= n.groundY - 0.01 * e.height;
2568
- const p = {
2571
+ for (const [u, f] of Object.entries(h)) c[u] = f.y >= n.groundY - 0.01 * e.height;
2572
+ const g = {
2569
2573
  height: e.height,
2570
2574
  lineWidth: e.lineWidth,
2571
2575
  turn: t.turn ?? 0,
2572
2576
  points: h,
2573
- chains: r,
2574
- parts: o,
2577
+ chains: o,
2578
+ parts: r,
2575
2579
  head: n.head,
2576
2580
  groundY: n.groundY,
2577
2581
  grounded: c
2578
2582
  };
2579
- return { skeleton: n, joints: p, order: a };
2583
+ return { skeleton: n, joints: g, order: a };
2580
2584
  }
2581
- function vr(e, t) {
2582
- return bt(e, t).joints;
2585
+ function Rr(e, t) {
2586
+ return Ht(e, t).joints;
2583
2587
  }
2584
- function xr(e, t, n) {
2585
- const { head: r } = n;
2586
- e.guideEllipse(r.center.x, r.center.y, r.rx * 1.03, r.ry * 1.03, r.angle);
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;
2588
+ function Lr(e, t, n) {
2589
+ const { head: o } = n;
2590
+ e.guideEllipse(o.center.x, o.center.y, o.rx * 1.03, o.ry * 1.03, o.angle);
2591
+ const r = 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 })), l = Ce(o, r, { x: 0, y: 0 });
2592
+ l.facing > 0 && e.guide(l.points), e.guide(Ce(o, s, { x: 0, y: 0.12 }).points), e.guide(n.chains.spine ?? []);
2593
+ const i = t.lineWidth * 0.9;
2590
2594
  for (const a of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
2591
2595
  const h = n.points[a];
2592
- h && e.guideEllipse(h.x, h.y, l, l, 0);
2596
+ h && e.guideEllipse(h.x, h.y, i, i, 0);
2593
2597
  }
2594
2598
  }
2595
- function Tr(e, t, n, r, o, s) {
2596
- const i = n.lineWidth;
2597
- if (o === "head") {
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);
2599
+ function Yr(e, t, n, o, r, s) {
2600
+ const l = n.lineWidth;
2601
+ if (r === "head") {
2602
+ const { head: f } = o, p = n.skin === "none" ? null : n.skin;
2603
+ t.ellipse(f.center.x, f.center.y, f.rx, f.ry, f.angle, p, l), t.look !== "silhouette" && $r(t, f, s, l);
2600
2604
  return;
2601
2605
  }
2602
- const l = n.plan.chains.find((u) => u.id === o), a = r.chains[o], h = r.parts[o].points;
2606
+ const i = n.plan.chains.find((f) => f.id === r), a = o.chains[r], h = o.parts[r].points;
2603
2607
  if (n.figure === "stick") {
2604
- if (o === "neck") return;
2605
- const u = o === "spine" ? [...a, ...r.chains.neck?.slice(1) ?? []] : h;
2606
- t.line(u, i);
2608
+ if (r === "neck") return;
2609
+ const f = r === "spine" ? [...a, ...o.chains.neck?.slice(1) ?? []] : h;
2610
+ t.line(f, l);
2607
2611
  return;
2608
2612
  }
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);
2614
- else if (n.hands === "cartoon" && o.startsWith("arm."))
2615
- Kr(e, t, n, a, o.endsWith(".left") ? "left" : "right", s);
2613
+ const c = (f, p) => [i.bones[f].width[0] * l, i.bones[p].width[1] * l];
2614
+ if (ft(i)) {
2615
+ const [f, p] = c(0, 1);
2616
+ if (t.limb(h, f, p), i.bones.length >= 3)
2617
+ t.limb([a[2], a[3]], i.bones[2].width[0] * l, i.bones[2].width[1] * l);
2618
+ else if (n.hands === "cartoon" && r.startsWith("arm."))
2619
+ Cr(e, t, n, a, r.endsWith(".left") ? "left" : "right", s);
2616
2620
  else {
2617
- const f = a[a.length - 1];
2618
- t.dot(f.x, f.y, i * 0.62);
2621
+ const d = a[a.length - 1];
2622
+ t.dot(d.x, d.y, l * 0.62);
2619
2623
  }
2620
2624
  return;
2621
2625
  }
2622
- if (o === "spine") {
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);
2626
+ if (r === "spine") {
2627
+ const f = o.points["hip.left"], p = o.points["hip.right"];
2628
+ f && p && Math.hypot(f.x - p.x, f.y - p.y) > 0.5 && t.limb([f, p], l * 1.3, l * 1.3);
2629
+ const [d, b] = c(0, i.bones.length - 1);
2630
+ t.limb(h, d, b);
2631
+ const m = o.points["shoulder.left"], w = o.points["shoulder.right"];
2632
+ m && w && Math.hypot(m.x - w.x, m.y - w.y) > 0.5 && t.limb(pe(m, a[a.length - 1], w, 1, 10), l * 1.15, l * 1.15);
2629
2633
  return;
2630
2634
  }
2631
- const [p, d] = c(0, l.bones.length - 1);
2632
- t.limb(h, p, d);
2633
- }
2634
- function Ar(e, t) {
2635
- const n = `hand.${t}.`, r = {};
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) };
2639
- }
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), {
2635
+ const [g, u] = c(0, i.bones.length - 1);
2636
+ t.limb(h, g, u);
2637
+ }
2638
+ function Nr(e, t) {
2639
+ const n = `hand.${t}.`, o = {};
2640
+ for (const [l, i] of Object.entries(e)) l.startsWith(n) && (o[l.slice(n.length)] = i);
2641
+ const r = e.turn ?? 0, s = t === "right" ? 1 - r : 1 + r;
2642
+ return { ..._, ...o, turn: s + (o.turn ?? 0) };
2643
+ }
2644
+ function Cr(e, t, n, o, r, s) {
2645
+ const l = o[o.length - 1], i = o[o.length - 2], a = Math.atan2(l.x - i.x, -(l.y - i.y)) * 180 / Math.PI;
2646
+ pt(e, l, Nr(s, r), {
2643
2647
  size: n.handSize * n.height,
2644
- side: o,
2648
+ side: r,
2645
2649
  angle: a,
2646
2650
  pen: t,
2647
2651
  skin: n.skin === "none" ? "#ffffff" : n.skin,
@@ -2652,112 +2656,116 @@ function Kr(e, t, n, r, o, s) {
2652
2656
  lineWidth: n.lineWidth * 0.3
2653
2657
  });
2654
2658
  }
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);
2659
+ function Dr(e, t, n, o = 0) {
2660
+ const r = t.plan.id === "human" ? { ...q, ...n } : n;
2661
+ Sn(e, t, r, Ht(t, r), o);
2658
2662
  }
2659
- function cn(e, t) {
2663
+ function kn(e, t) {
2660
2664
  const n = t / e.height;
2661
2665
  return { ...e, height: t, lineWidth: e.lineWidth * n };
2662
2666
  }
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;
2667
+ function Fs(e, t, n, o) {
2668
+ const r = e.plan.id === "human" ? { ...q, ...t } : t, s = wn(e.plan, r, { height: o.height, contact: e.contact }, n);
2669
+ return vt(kn(e, s.height), r, s).joints;
2666
2670
  }
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);
2671
+ function qr(e, t, n, o, r) {
2672
+ const s = t.plan.id === "human" ? { ...q, ...n } : n, l = wn(t.plan, s, { height: r.height, contact: t.contact }, o), i = kn(t, l.height);
2673
+ Sn(e, i, s, vt(i, s, l), r.time ?? 0);
2670
2674
  }
2671
- function fn(e, t, n, r, o) {
2672
- const { joints: s, order: i } = r, l = Yt(e, {
2675
+ function Sn(e, t, n, o, r) {
2676
+ const { joints: s, order: l } = o, i = zt(e, {
2673
2677
  look: t.look,
2674
2678
  ink: t.ink,
2675
2679
  lineWidth: t.lineWidth,
2676
2680
  seed: t.seed,
2677
- time: o,
2681
+ time: r,
2678
2682
  pencil: t.pencil
2679
2683
  }), a = (h) => {
2680
- h && (e.save(), h(e, s, l, o), e.restore());
2684
+ h && (e.save(), h(e, s, i, r), e.restore());
2681
2685
  };
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) {
2686
+ e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && Lr(i, t, s), a(t.layers.behind);
2687
+ for (const h of l) {
2684
2688
  const c = t.layers.parts?.[h];
2685
- a(c?.under), Tr(e, l, t, s, h, n), a(c?.over);
2689
+ a(c?.under), Yr(e, i, t, s, h, n), a(c?.over);
2686
2690
  }
2687
2691
  a(t.layers.front), e.restore();
2688
2692
  }
2689
- function fs(e, t, n) {
2690
- const r = { ...e };
2691
- for (const [o, s] of Object.entries(t)) {
2692
- const i = e[o] ?? s;
2693
- r[o] = i + (s - i) * n;
2693
+ function Rs(e, t, n) {
2694
+ const o = { ...e };
2695
+ for (const [r, s] of Object.entries(t)) {
2696
+ const l = e[r] ?? s;
2697
+ o[r] = l + (s - l) * n;
2694
2698
  }
2695
- return r;
2699
+ return o;
2696
2700
  }
2697
- function us(e, t, n, r) {
2698
- const o = e.plan.id === "human" ? { ...V, ...t } : t;
2701
+ function Ls(e, t, n, o) {
2702
+ const r = e.plan.id === "human" ? { ...q, ...t } : t;
2699
2703
  let s;
2700
- if (Array.isArray(r))
2701
- s = r;
2704
+ if (Array.isArray(o))
2705
+ s = o;
2702
2706
  else {
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];
2707
+ const { skeleton: l } = Ht(e, r), i = Mt(e.plan, { ...r, roll: 0 }, { height: e.height, contact: "none" }), a = (r.roll ?? 0) * Math.PI / 180, h = o.x - l.hip.x, c = o.y - l.hip.y, g = i.hip.x + h * Math.cos(-a) - c * Math.sin(-a), u = i.hip.y + h * Math.sin(-a) + c * Math.cos(-a), f = Math.PI / 2 * (r.turn ?? 0), p = o.depth ?? l.chains[n].depths[l.chains[n].depths.length - 1], d = Math.cos(f), b = Math.sin(f);
2708
+ s = [g * d - p * b, -u, g * b + p * d];
2705
2709
  }
2706
- return pr(e.plan, o, n, s, { height: e.height });
2710
+ return xr(e.plan, r, n, s, { height: e.height });
2707
2711
  }
2708
- function ds(e) {
2709
- const { character: t } = e, n = t.height * 0.8, r = t.height, o = t.plan.id === "human" ? V : {};
2712
+ function Ys(e) {
2713
+ const { character: t } = e, n = t.height * 0.8, o = t.height, r = t.plan.id === "human" ? q : {};
2710
2714
  return {
2711
2715
  type: "custom",
2712
2716
  x: e.x - n / 2,
2713
- y: e.y - r,
2717
+ y: e.y - o,
2714
2718
  width: n,
2715
- height: r,
2716
- props: { ...o, ...e.pose },
2719
+ height: o,
2720
+ props: { ...r, ...e.pose },
2717
2721
  character: t,
2718
- draw(s, i, l) {
2719
- s.translate(n / 2, r), Pr(s, t, i.props, l);
2722
+ draw(s, l, i) {
2723
+ s.translate(n / 2, o), Dr(s, t, l.props, i);
2720
2724
  }
2721
2725
  };
2722
2726
  }
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)]));
2727
+ function Xr(e, t, n) {
2728
+ const o = (s) => ({ x: s.x + t, y: s.y + n }), r = (s) => Object.fromEntries(Object.entries(s).map(([l, i]) => [l, i.map(o)]));
2725
2729
  return {
2726
2730
  ...e,
2727
- points: Object.fromEntries(Object.entries(e.points).map(([s, i]) => [s, r(i)])),
2728
- chains: o(e.chains),
2729
- parts: Object.fromEntries(Object.entries(e.parts).map(([s, i]) => [s, { ...i, points: i.points.map(r) }])),
2730
- head: { ...e.head, center: r(e.head.center) },
2731
+ points: Object.fromEntries(Object.entries(e.points).map(([s, l]) => [s, o(l)])),
2732
+ chains: r(e.chains),
2733
+ parts: Object.fromEntries(Object.entries(e.parts).map(([s, l]) => [s, { ...l, points: l.points.map(o) }])),
2734
+ head: { ...e.head, center: o(e.head.center) },
2731
2735
  groundY: e.groundY + n
2732
2736
  };
2733
2737
  }
2734
- function gs(e, t, n) {
2735
- const r = e.character;
2736
- if (!r) throw new Error("characterAt: the target was not made by characterTarget");
2737
- const o = { ...e.props };
2738
- let s = 0, i = 0;
2738
+ function Ns(e, t, n) {
2739
+ const o = e.character;
2740
+ if (!o) throw new Error("characterAt: the target was not made by characterTarget");
2741
+ const r = { ...e.props };
2742
+ let s = 0, l = 0;
2739
2743
  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) };
2744
+ typeof h == "number" && (a === "x" || a === "motionPathX" ? s = h : a === "y" || a === "motionPathY" ? l = h : a in r && (r[a] = h));
2745
+ const i = Rr(o, r);
2746
+ return { pose: r, joints: Xr(i, e.x + s + e.width / 2, e.y + l + e.height) };
2743
2747
  }
2744
- function ps(e, t, n = V) {
2745
- const r = [];
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) => ({
2748
+ function En(e, t = q) {
2749
+ const n = [];
2750
+ return e.forEach((o, r) => {
2751
+ const s = r === 0 ? t : n[r - 1], l = typeof o.pose == "string" ? Mr[o.pose] : void 0;
2752
+ n.push(l ? { ...l, turn: s.turn ?? 0 } : { ...s, ...o.pose });
2753
+ }), n;
2754
+ }
2755
+ function Cs(e, t, n = q) {
2756
+ const o = En(t, n);
2757
+ return Object.keys(n).filter((s) => o.some((l) => (l[s] ?? n[s]) !== n[s])).map((s) => ({
2750
2758
  id: `${e}-${s}`,
2751
2759
  target: e,
2752
2760
  property: s,
2753
- keyframes: t.map((i, l) => ({
2754
- time: i.time,
2755
- value: r[l][s] ?? n[s],
2756
- ...i.easing ? { easing: i.easing } : {}
2761
+ keyframes: t.map((l, i) => ({
2762
+ time: l.time,
2763
+ value: o[i][s] ?? n[s],
2764
+ ...l.easing ? { easing: l.easing } : {}
2757
2765
  }))
2758
2766
  }));
2759
2767
  }
2760
- const Ir = /* @__PURE__ */ new Set([
2768
+ const Ur = /* @__PURE__ */ new Set([
2761
2769
  "x",
2762
2770
  "y",
2763
2771
  "z",
@@ -2773,43 +2781,43 @@ const Ir = /* @__PURE__ */ new Set([
2773
2781
  "visible",
2774
2782
  "opacity",
2775
2783
  "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;
2784
+ ]), Gr = 1.7;
2785
+ function zr(e, t, n) {
2786
+ const o = Array.from({ length: 24 }, (r, s) => {
2787
+ const l = s / 24 * Math.PI * 2, i = t.toView([Math.cos(l) * n, 0, Math.sin(l) * n * 0.8]);
2788
+ return i[2] < -1e-3 ? t.toScreen(i) : null;
2781
2789
  });
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());
2790
+ o.some((r) => r === null) || (e.beginPath(), o.forEach((r, s) => s === 0 ? e.moveTo(r.x, r.y) : e.lineTo(r.x, r.y)), e.closePath(), e.fillStyle = "rgba(0, 0, 0, 0.22)", e.fill());
2783
2791
  }
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));
2792
+ function jr(e) {
2793
+ const t = j.dot([0, 1, 0], e);
2794
+ if (t > 0.999999) return C.identity();
2795
+ if (t < -0.999999) return C.fromQuat(Tt.fromAxisAngle([1, 0, 0], 180));
2796
+ const n = j.cross([0, 1, 0], e);
2797
+ return C.fromQuat(Tt.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
2790
2798
  }
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);
2799
+ function Jr(e, t, n, o, r) {
2800
+ const s = e.solid ?? {}, l = s.outline === !1 ? void 0 : s.outline ?? { width: 2, color: "#0f172a" }, i = { color: s.color ?? "#475569", shading: s.shading ?? "toon", outline: l }, a = { color: s.skin ?? "#f2c49b", shading: s.shading ?? "toon", outline: l }, h = { color: "#0f172a", shading: "unlit" }, c = o.height * 0.034, g = [], u = (y, H, E) => g.push({ mesh: y, world: C.multiply(r, H), material: E }), f = (y, H, E) => u(t.sphere, C.compose(y, [0, 0, 0, 1], [H, H, H]), E);
2793
2801
  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);
2802
+ const H = o.chains[y.id], E = y.id === "spine" ? 1.9 : 1;
2803
+ y.bones.forEach((k, M) => {
2804
+ const T = H[M], S = H[M + 1], x = j.distance(T, S), [K, v] = k.width ?? [1, 1], A = c * E * (K + v) / 2;
2805
+ if (x > 1e-6) {
2806
+ const W = j.lerp(T, S, 0.5), $ = jr(j.normalize(j.subtract(S, T)));
2807
+ u(t.cylinder, C.multiply(C.translation(W), C.multiply($, C.scaling([A, x, A]))), i);
2800
2808
  }
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);
2809
+ f(T, c * E * K, i), f(S, c * E * v, i);
2810
+ }), y.id.startsWith("arm.") && f(H[H.length - 1], c * 1.5, a);
2803
2811
  }
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);
2812
+ const { center: p, rx: d, ry: b, axes: m } = o.head, w = [...m[0], 0, ...m[1], 0, ...m[2], 0, ...p, 1];
2813
+ u(t.sphere, C.multiply(w, C.scaling([d, b, d])), a);
2806
2814
  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);
2815
+ const H = j.normalize([y * 0.36, 0.15, 0.92]), E = j.add(p, j.add(j.add(j.scale(m[0], H[0] * d * 1.04), j.scale(m[1], H[1] * b * 1.04)), j.scale(m[2], H[2] * d * 1.04))), k = [...m[0], 0, ...m[1], 0, ...m[2], 0, ...E, 1];
2816
+ u(t.sphere, C.multiply(k, C.scaling([d * 0.11, b * 0.14, d * 0.03])), h);
2809
2817
  }
2810
- return p;
2818
+ return g;
2811
2819
  }
2812
- const bs = {
2820
+ const Ds = {
2813
2821
  kind: "character",
2814
2822
  validate(e) {
2815
2823
  const t = e;
@@ -2817,330 +2825,751 @@ const bs = {
2817
2825
  },
2818
2826
  prepare(e) {
2819
2827
  return {
2820
- who: Er({ ...e.character, height: 1 }),
2821
- cylinder: wt(Sn(1, 1, 16)),
2822
- sphere: wt(kn(1, 20))
2828
+ who: Br({ ...e.character, height: 1 }),
2829
+ cylinder: At($n(1, 1, 16)),
2830
+ sphere: At(In(1, 20))
2823
2831
  };
2824
2832
  },
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 };
2833
+ resolve({ object: e, prepared: t, values: n, world: o, camera: r, toScreen: s }) {
2834
+ const l = e, i = t, a = i.who, h = { ...q, ...l.pose };
2835
+ for (const [b, m] of n)
2836
+ typeof m == "number" && !Ur.has(b) && (h[b] = m);
2837
+ const c = l.height ?? Gr, g = C.multiply(r.view, o), u = {
2838
+ toView: (b) => C.transformPoint(g, b),
2839
+ toScreen: (b) => s(b)
2840
+ }, p = -u.toView([0, c / 2, 0])[2];
2841
+ if (p <= r.near) return null;
2842
+ const d = l.shadow === !1 ? [] : [{ depth: p + c, draw: (b) => zr(b, u, c * 0.18) }];
2843
+ if (l.look === "solid") {
2844
+ const b = mn(a.plan, h, { height: c, contact: a.contact });
2845
+ return { meshes: Jr(l, i, a.plan, b, o), drawables: d };
2838
2846
  }
2839
2847
  return {
2840
2848
  drawables: [
2841
- ...f,
2849
+ ...d,
2842
2850
  {
2843
- depth: b,
2844
- draw(g, m) {
2845
- g.lineCap = "round", g.lineJoin = "round", Wr(g, a, h, d, { height: c, time: m.time });
2851
+ depth: p,
2852
+ draw(b, m) {
2853
+ b.lineCap = "round", b.lineJoin = "round", qr(b, a, h, u, { height: c, time: m.time });
2846
2854
  }
2847
2855
  }
2848
2856
  ]
2849
2857
  };
2850
2858
  }
2851
2859
  };
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";
2860
+ function Vr(e, t, n = {}, o) {
2861
+ const r = n.length ?? 240, s = 9, l = 28, i = r - 22;
2862
+ e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(l, -s, i - l, 2 * s), e.fillStyle = "#e8b4a0", e.fillRect(i, -s, r - i, 2 * s), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(l, -s), e.lineTo(l, s), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(l * 0.35, -s * 0.35), e.lineTo(l * 0.35, s * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2855
2863
  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 }]
2864
+ [{ x: 0, y: 0 }, { x: l, y: -s }, { x: r, y: -s }, { x: r, y: s }, { x: l, y: s }, { x: 0, y: 0 }],
2865
+ [{ x: l, y: -s }, { x: l, y: s }],
2866
+ [{ x: i, y: -s }, { x: i, y: s }]
2859
2867
  ];
2860
- for (const h of a) pn(e, h, r);
2868
+ for (const h of a) Tn(e, h, o);
2861
2869
  e.restore();
2862
2870
  }
2863
- function un(e, t, n = {}, r) {
2864
- const o = n.length ?? 90, s = n.thickness ?? 34;
2871
+ function Mn(e, t, n = {}, o) {
2872
+ const r = n.length ?? 90, s = n.thickness ?? 34;
2865
2873
  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);
2874
+ const l = -s / 2;
2875
+ e.fillStyle = n.color ?? "#f4a7b9", e.fillRect(0, l, r, s), e.fillStyle = "#e9edf2", e.fillRect(r * 0.45, l, r * 0.55, s), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
2876
+ const i = [
2877
+ { x: 0, y: l },
2878
+ { x: r, y: l },
2879
+ { x: r, y: -l },
2880
+ { x: 0, y: -l },
2881
+ { x: 0, y: l }
2882
+ ], a = [{ x: r * 0.45, y: l }, { x: r * 0.45, y: -l }];
2883
+ if (o)
2884
+ o.line(i), o.line(a);
2877
2885
  else
2878
- for (const h of [l, a]) {
2886
+ for (const h of [i, a]) {
2879
2887
  e.beginPath(), e.moveTo(h[0].x, h[0].y);
2880
2888
  for (const c of h.slice(1)) e.lineTo(c.x, c.y);
2881
2889
  e.stroke();
2882
2890
  }
2883
2891
  e.restore();
2884
2892
  }
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,
2893
+ const Hn = 150, Zr = { pencil: 44, eraser: 30 };
2894
+ function vn(e, t, n = {}, o) {
2895
+ const r = n.tool ?? "pencil", s = n.skin ?? "#f1c9a5", l = n.outline ?? "#2f2f33", i = n.scale ?? 1, a = Math.min(1, Math.max(0, n.lift ?? 0)), h = (n.angle ?? -30) * Math.PI / 180, c = o ? o.nudge(0.6) : { x: 0, y: 0 }, g = Hn * i * (1 + 0.05 * a);
2896
+ a > 0 && (e.save(), e.fillStyle = l, e.globalAlpha = 0.15 * a, e.beginPath(), e.ellipse(t.x, t.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), e.fill(), e.restore());
2897
+ const u = { x: t.x + c.x + 6 * a * i, y: t.y + c.y - 18 * a * i }, f = Y.pencilGrip, p = (M) => {
2898
+ const T = M.fingers.thumb, S = M.fingers.index, x = M.fingers.middle, K = Xt([T.points[3], S.points[3], x.points[3]]), v = Xt([T.points[1], S.points[0]]), A = (T.depths[3] + S.depths[3] + x.depths[3]) / 3;
2899
+ return { pinch: K, direction: Math.atan2(v.y - K.y, v.x - K.x), depth: A };
2900
+ }, d = rt(f, { size: g }), b = h - p(d).direction, m = rt(f, { size: g, angle: b * 180 / Math.PI }), w = p(m), y = Zr[r] * i, H = { x: w.pinch.x - Math.cos(h) * y, y: w.pinch.y - Math.sin(h) * y }, E = { x: u.x - H.x, y: u.y - H.y }, k = m.axes.up;
2901
+ Qr(e, E, { x: -k.x, y: -k.y }, g, n.arm ?? 300 * i, s, n.sleeve ?? "#5b7db1", l), pt(e, E, f, {
2902
+ size: g,
2903
+ angle: b * 180 / Math.PI,
2896
2904
  skin: s,
2897
- ink: i,
2898
- lineWidth: 3 * l,
2905
+ ink: l,
2906
+ lineWidth: 3 * i,
2899
2907
  prop: {
2900
- depth: k.depth,
2908
+ depth: w.depth,
2901
2909
  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();
2910
+ e.save(), e.translate(u.x, u.y), e.scale(i, i), r === "eraser" ? Mn(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: l }, o) : Vr(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: l }, o), e.restore();
2903
2911
  }
2904
2912
  }
2905
2913
  });
2906
2914
  }
2907
- const Ft = (e) => ({
2915
+ const Xt = (e) => ({
2908
2916
  x: e.reduce((t, n) => t + n.x, 0) / e.length,
2909
2917
  y: e.reduce((t, n) => t + n.y, 0) / e.length
2910
2918
  });
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 };
2919
+ function Qr(e, t, n, o, r, s, l, i) {
2920
+ const a = { x: -n.y, y: n.x }, h = o * 0.15, c = (d, b, m) => ({
2921
+ x: t.x + n.x * d + a.x * b * m,
2922
+ y: t.y + n.y * d + a.y * b * m
2923
+ }), g = c(r, 0, 0), u = (d) => {
2924
+ const b = e.createLinearGradient(t.x, t.y, g.x, g.y);
2925
+ return b.addColorStop(0, d), b.addColorStop(0.6, d), b.addColorStop(1, es(d)), b;
2926
+ }, f = Math.min(o * 0.55, r * 0.35);
2927
+ e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (o / Hn), e.beginPath(), e.moveTo(c(-o * 0.1, -1, h).x, c(-o * 0.1, -1, h).y), e.lineTo(c(f + 4, -1, h * 1.1).x, c(f + 4, -1, h * 1.1).y), e.lineTo(c(f + 4, 1, h * 1.1).x, c(f + 4, 1, h * 1.1).y), e.lineTo(c(-o * 0.1, 1, h).x, c(-o * 0.1, 1, h).y), e.closePath(), e.fillStyle = s, e.fill(), e.strokeStyle = i, e.beginPath(), e.moveTo(c(0, -1, h).x, c(0, -1, h).y), e.lineTo(c(f, -1, h * 1.1).x, c(f, -1, h * 1.1).y), e.moveTo(c(0, 1, h).x, c(0, 1, h).y), e.lineTo(c(f, 1, h * 1.1).x, c(f, 1, h * 1.1).y), e.stroke();
2928
+ const p = [c(f, -1, h * 1.3), c(r, -1, h * 1.5), c(r, 1, h * 1.5), c(f, 1, h * 1.3)];
2929
+ e.beginPath(), p.forEach((d, b) => b ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = u(l), e.fill(), e.strokeStyle = u(i), e.beginPath(), e.moveTo(p[1].x, p[1].y), e.lineTo(p[0].x, p[0].y), e.lineTo(p[3].x, p[3].y), e.lineTo(p[2].x, p[2].y), e.stroke(), e.restore();
2930
+ }
2931
+ function qs(e, t, n = {}) {
2932
+ const o = n.offstage ?? { x: 2e3, y: 1400 }, r = n.enter ?? 450, s = n.exit ?? 450, l = n.linger ?? 1500, i = [...e].filter((d) => d.path.length > 0).sort((d, b) => d.start - b.start), a = (d) => d.tool ?? "pencil", h = (d) => {
2933
+ const b = Math.min(1, Math.max(0, d));
2934
+ return b * b * (3 - 2 * b);
2935
+ }, c = (d, b, m) => ({ x: d.x + (b.x - d.x) * m, y: d.y + (b.y - d.y) * m }), g = i.find((d) => t >= d.start && t <= d.end);
2936
+ if (g) {
2937
+ const d = g.end - g.start, b = d > 0 ? (t - g.start) / d : 1;
2938
+ return { at: dt(g.path, b), tool: a(g), lift: 0, drawing: !0 };
2939
+ }
2940
+ const u = [...i].reverse().find((d) => d.end < t), f = i.find((d) => d.start > t), p = (d) => d.path[d.path.length - 1];
2941
+ if (u && f && f.start - u.end <= l) {
2942
+ const d = (t - u.end) / (f.start - u.end), b = d < 0.5 ? a(u) : a(f);
2943
+ return { at: c(p(u), f.path[0], h(d)), tool: b, lift: Math.sin(Math.PI * d), drawing: !1 };
2944
+ }
2945
+ if (f && f.start - t <= r) {
2946
+ const d = 1 - (f.start - t) / r;
2947
+ return { at: c(o, f.path[0], h(d)), tool: a(f), lift: 1 - h(d), drawing: !1 };
2948
+ }
2949
+ if (u && t - u.end <= s) {
2950
+ const d = (t - u.end) / s;
2951
+ return { at: c(p(u), o, h(d)), tool: a(u), lift: h(d), drawing: !1 };
2944
2952
  }
2945
2953
  return null;
2946
2954
  }
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 });
2955
+ function Xs(e, t, n, o = 0.08, r = 32) {
2956
+ const s = Math.PI * 2 * (1 + o), l = [];
2957
+ for (let i = 0; i <= r; i++) {
2958
+ const a = -Math.PI / 2 + s * i / r;
2959
+ l.push({ x: e + Math.cos(a) * n, y: t + Math.sin(a) * n });
2952
2960
  }
2953
- return i;
2961
+ return l;
2954
2962
  }
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;
2963
+ function Us(e) {
2964
+ const { path: t } = e, n = t.map((i) => i.x), o = t.map((i) => i.y), r = Math.min(...n), s = Math.min(...o), l = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
2957
2965
  return {
2958
2966
  type: "custom",
2959
- x: o,
2967
+ x: r,
2960
2968
  y: s,
2961
- width: Math.max(1, Math.max(...n) - o),
2962
- height: Math.max(1, Math.max(...r) - s),
2969
+ width: Math.max(1, Math.max(...n) - r),
2970
+ height: Math.max(1, Math.max(...o) - s),
2963
2971
  props: { draw: 0 },
2964
- draw(l, a, h) {
2972
+ draw(i, a, h) {
2965
2973
  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);
2974
+ i.translate(-r, -s), i.strokeStyle = e.color ?? "#2f2f33", i.lineWidth = e.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
2975
+ const g = e.sketch ? tt(i, e.sketch, h) : void 0;
2976
+ c > 0 && (g ? e.smooth ? g.curve(t, c) : g.line(t, c) : Tn(i, Gt(t, c))), l && c > 0 && c < 1 && vn(i, dt(t, c), l, g);
2969
2977
  }
2970
2978
  };
2971
2979
  }
2972
- function Nr(e) {
2980
+ function es(e) {
2973
2981
  const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
2974
2982
  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)`;
2983
+ const n = t[1].length === 3 ? [...t[1]].map((l) => l + l).join("") : t[1], [o, r, s] = [0, 2, 4].map((l) => parseInt(n.slice(l, l + 2), 16));
2984
+ return `rgba(${o}, ${r}, ${s}, 0)`;
2977
2985
  }
2978
- function pn(e, t, n) {
2986
+ function Tn(e, t, n) {
2979
2987
  if (!(t.length < 2)) {
2980
2988
  if (n) return n.line(t);
2981
2989
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
2982
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
2990
+ for (const o of t.slice(1)) e.lineTo(o.x, o.y);
2983
2991
  e.stroke();
2984
2992
  }
2985
2993
  }
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 });
2994
+ const Pe = 1e5;
2995
+ function Gs(e, t, n, o, r = 6) {
2996
+ const s = [], l = Math.max(1, Math.round(r));
2997
+ for (let i = 0; i <= l; i++)
2998
+ s.push({ x: i % 2 === 0 ? e : e + n, y: t + o * i / l });
2991
2999
  return s;
2992
3000
  }
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");
3001
+ function An(e, t, n, o) {
3002
+ if (o <= 0 || t.length === 0) return;
3003
+ const r = Gt(t, o), s = n / 2, l = (i) => {
3004
+ e.beginPath(), e.rect(-Pe, -Pe, 2 * Pe, 2 * Pe), i(), e.clip("evenodd");
2997
3005
  };
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);
3006
+ for (const i of r)
3007
+ l(() => {
3008
+ e.moveTo(i.x + s, i.y), e.arc(i.x, i.y, s, 0, Math.PI * 2);
3001
3009
  });
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);
3010
+ for (let i = 1; i < r.length; i++) {
3011
+ const a = r[i - 1], h = r[i], c = Math.hypot(h.x - a.x, h.y - a.y);
3004
3012
  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();
3013
+ const g = -(h.y - a.y) / c * s, u = (h.x - a.x) / c * s;
3014
+ l(() => {
3015
+ e.moveTo(a.x + g, a.y + u), e.lineTo(h.x + g, h.y + u), e.lineTo(h.x - g, h.y - u), e.lineTo(a.x - g, a.y - u), e.closePath();
3008
3016
  });
3009
3017
  }
3010
3018
  }
3011
- function Ss(e, t, n, r, o) {
3012
- e.save(), bn(e, t, n, r), o(), e.restore();
3019
+ function zs(e, t, n, o, r) {
3020
+ e.save(), An(e, t, n, o), r(), e.restore();
3013
3021
  }
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;
3022
+ function js(e, t) {
3023
+ const n = t.width ?? 40, o = t.hand === !0 ? {} : t.hand || void 0, r = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
3016
3024
  return {
3017
3025
  ...e,
3018
3026
  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);
3027
+ draw(s, l, i) {
3028
+ const a = Number(l.props?.erase ?? 0);
3029
+ if (s.save(), An(s, t.path, n, a), e.draw(s, l, i), s.restore(), !r || a <= 0 || a >= 1) return;
3030
+ const h = dt(t.path, a);
3031
+ o ? vn(s, h, { ...o, tool: "eraser" }) : Mn(s, h, r);
3024
3032
  }
3025
3033
  };
3026
3034
  }
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));
3035
+ const ts = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
3036
+ function Js(e = {}) {
3037
+ const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", o = (i) => i.lineWidth * 0.45, r = (i, a, h) => {
3038
+ const c = i.parts[`leg.${h}`].points;
3039
+ a.shape(Oe(c, i.height * 0.08, i.height * 0.05), n, o(i));
3040
+ }, s = (i, a) => {
3041
+ const h = i.chains.spine, c = h[0], g = h[h.length - 1], u = { x: c.x - (g.x - c.x) * 0.25, y: c.y - (g.y - c.y) * 0.25 };
3042
+ a.shape(Oe([u, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), t, o(i));
3043
+ }, l = (i, a, h) => {
3044
+ const c = i.parts[`arm.${h}`].points, g = c[0], u = i.chains.spine[i.chains.spine.length - 1], p = [{ x: g.x + (u.x - g.x) * 0.45, y: g.y + (u.y - g.y) * 0.45 }, ...ts(c, 0, 0.45)], d = Oe(p, i.height * 0.085, i.height * 0.06), b = p.length, m = d.slice(0, b), w = d.slice(b).reverse();
3045
+ a.shape(d, t, 0);
3046
+ const y = (k) => Math.hypot(k[1].x - u.x, k[1].y - u.y), [H, E] = y(m) > y(w) ? [m, w] : [w, m];
3047
+ a.line(H.slice(1), o(i)), a.line(E.slice(Math.ceil(b * 0.45)), o(i)), a.line([m[b - 1], w[b - 1]], o(i));
3040
3048
  };
3041
3049
  return {
3042
3050
  parts: {
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") }
3051
+ "leg.left": { over: (i, a, h) => r(a, h, "left") },
3052
+ "leg.right": { over: (i, a, h) => r(a, h, "right") },
3053
+ spine: { over: (i, a, h) => s(a, h) },
3054
+ "arm.left": { over: (i, a, h) => l(a, h, "left") },
3055
+ "arm.right": { over: (i, a, h) => l(a, h, "right") }
3056
+ }
3057
+ };
3058
+ }
3059
+ const Qe = {
3060
+ full: {
3061
+ anticipation: 0.12,
3062
+ anticipationTime: 0.3,
3063
+ hold: 0,
3064
+ overshoot: 0.08,
3065
+ settle: 220,
3066
+ settleEase: "ease-in-out",
3067
+ actionEase: "ease-in-out-cubic",
3068
+ overlap: 45,
3069
+ eyeLead: 120,
3070
+ eyeDart: 160,
3071
+ drift: 0.12,
3072
+ blinks: !0,
3073
+ jumpSquash: 1
3074
+ },
3075
+ snappy: {
3076
+ anticipation: 0.2,
3077
+ anticipationTime: 0.35,
3078
+ hold: 0.12,
3079
+ overshoot: 0.12,
3080
+ settle: 320,
3081
+ settleEase: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 },
3082
+ actionEase: "ease-out-cubic",
3083
+ overlap: 35,
3084
+ eyeLead: 100,
3085
+ eyeDart: 100,
3086
+ drift: 0.1,
3087
+ blinks: !0,
3088
+ jumpSquash: 1.3
3089
+ },
3090
+ limited: {
3091
+ anticipation: 0.06,
3092
+ anticipationTime: 0.25,
3093
+ hold: 0,
3094
+ overshoot: 0,
3095
+ settle: 0,
3096
+ settleEase: "ease-out",
3097
+ actionEase: "ease-in-out",
3098
+ overlap: 30,
3099
+ eyeLead: 80,
3100
+ eyeDart: 120,
3101
+ drift: 0,
3102
+ blinks: !0,
3103
+ jumpSquash: 0.6
3104
+ },
3105
+ none: {
3106
+ anticipation: 0,
3107
+ anticipationTime: 0,
3108
+ hold: 0,
3109
+ overshoot: 0,
3110
+ settle: 0,
3111
+ settleEase: "linear",
3112
+ actionEase: "linear",
3113
+ overlap: 0,
3114
+ eyeLead: 0,
3115
+ eyeDart: 0,
3116
+ drift: 0,
3117
+ blinks: !1,
3118
+ jumpSquash: 0
3119
+ }
3120
+ };
3121
+ function ns(e) {
3122
+ if (e === void 0) return Qe.full;
3123
+ if (typeof e == "string") return Qe[e];
3124
+ const { base: t, ...n } = e;
3125
+ return { ...Qe[t ?? "full"], ...n };
3126
+ }
3127
+ const ut = 160, os = 120, rs = 700, et = 60, ss = 90, We = 3200, ge = 1, ae = 1e-6;
3128
+ function xn(e, t, n = {}) {
3129
+ const o = ns(n.style), r = n.seed ?? 1, s = {};
3130
+ if (e.length === 0) return s;
3131
+ const l = Object.keys(e[0].pose).filter((u) => e.some((f) => Math.abs(f.pose[u] - e[0].pose[u]) > ae)), i = Math.min(1 / 0, ...e.slice(1).map((u, f) => u.time - e[f].time));
3132
+ for (const u of l) s[u] = is(u, e, t, o, r, i);
3133
+ const a = t.blink, h = a !== void 0 && l.includes(a);
3134
+ if (o.blinks && a !== void 0 && !h && a in e[0].pose) {
3135
+ const u = ls(e, t, o, r, e[0].pose[a]);
3136
+ u.length > 0 && (s[a] = u);
3137
+ }
3138
+ const { lift: c, stretch: g } = t;
3139
+ if (o.jumpSquash > 0 && c && g && l.includes(c) && !l.includes(g) && g in e[0].pose) {
3140
+ const u = as(e, c, e[0].pose[g], o.jumpSquash);
3141
+ u.length > 0 && (s[g] = u);
3142
+ }
3143
+ return s;
3144
+ }
3145
+ function is(e, t, n, o, r, s) {
3146
+ const l = n.eyes.includes(e), i = n.limits[e], a = i !== void 0, h = Number.isFinite(s) ? s / 4 : 0, c = l ? -o.eyeLead : (n.depth[e] ?? 1) * o.overlap, g = Math.max(-h, Math.min(h, c)), u = [{ time: t[0].time, value: t[0].pose[e] }], f = (d, b, m) => {
3147
+ const w = u[u.length - 1];
3148
+ if (d <= w.time + ge) {
3149
+ u[u.length - 1] = { ...w, value: b, ...m ? { easing: m } : {} };
3150
+ return;
3151
+ }
3152
+ u.push({ time: d, value: b, ...m ? { easing: m } : {} });
3153
+ };
3154
+ let p = t[0].pose[e];
3155
+ for (let d = 1; d < t.length; d++) {
3156
+ const b = t[d], m = t[d - 1].pose[e], w = b.pose[e], y = w - m, H = u[u.length - 1].time, E = b.act !== !1;
3157
+ if (Math.abs(y) <= ae) {
3158
+ const v = b.time + (E ? g : 0);
3159
+ if (d === t.length - 1)
3160
+ Math.abs(p - w) > ae && f(Math.max(v, H + ut), w, "ease-in-out"), p = w;
3161
+ else if (E && a && o.drift > 0 && n.drift.includes(e) && v - H >= rs) {
3162
+ const A = De(`${r}:${e}:${d}`) % 2 === 0 ? 1 : -1;
3163
+ p = w + A * o.drift * i, f(v, p, "ease-in-out");
3164
+ }
3165
+ continue;
3166
+ }
3167
+ if (!E) {
3168
+ f(t[d - 1].time, p), f(b.time, w, b.easing), p = w;
3169
+ continue;
3170
+ }
3171
+ const k = Math.max(t[d - 1].time + g, H);
3172
+ let M = b.time + g;
3173
+ l && o.eyeDart > 0 && (M = Math.min(M, k + o.eyeDart));
3174
+ const T = M - k;
3175
+ if (T <= ge) {
3176
+ f(b.time, w, b.easing), p = w;
3177
+ continue;
3048
3178
  }
3179
+ f(k, p);
3180
+ const S = Math.sign(y);
3181
+ if (a && o.anticipation > 0 && i > 0 && T >= ut) {
3182
+ const v = p - S * Math.min(Math.abs(y) * o.anticipation, i), A = k + T * o.anticipationTime;
3183
+ f(A, v, "ease-in-out"), o.hold > 0 && f(A + T * o.hold, v);
3184
+ }
3185
+ const x = d + 1 < t.length ? t[d + 1].time - b.time : 1 / 0, K = Math.min(o.settle, x / 2);
3186
+ if (a && o.overshoot > 0 && i > 0 && T >= os && K > ge) {
3187
+ const v = Math.min(Math.abs(y) * o.overshoot, i);
3188
+ f(M, w + S * v, b.easing ?? o.actionEase), f(M + K, w, o.settleEase);
3189
+ } else
3190
+ f(M, w, b.easing ?? o.actionEase);
3191
+ p = w;
3192
+ }
3193
+ return u;
3194
+ }
3195
+ function ls(e, t, n, o, r) {
3196
+ const s = [], l = et + ss;
3197
+ for (let f = 1; f < e.length; f++) {
3198
+ const p = e[f - 1].pose, d = e[f].pose;
3199
+ Object.entries(t.headTurns).some(([m, w]) => Math.abs((d[m] ?? 0) - (p[m] ?? 0)) > w) && e[f].act !== !1 && s.push(Math.max(e[0].time, e[f - 1].time - n.eyeLead));
3200
+ }
3201
+ const i = e[0].time, a = e[e.length - 1].time, h = [...s];
3202
+ let c = i + We * 0.6, g = 0;
3203
+ for (; c < a; ) {
3204
+ h.some((d) => Math.abs(d - c) < We / 2) || s.push(c);
3205
+ const p = (De(`${o}:blink:${g++}`) % 1e3 / 1e3 - 0.5) * (We * 0.66);
3206
+ c += We + p;
3207
+ }
3208
+ s.sort((f, p) => f - p);
3209
+ const u = [{ time: i, value: r }];
3210
+ for (const f of s) {
3211
+ const p = u[u.length - 1].time;
3212
+ f + et <= p + ge || (f > p + ge && u.push({ time: f, value: r }), u.push({ time: f + et, value: 1, easing: "ease-in" }), u.push({ time: f + l, value: r, easing: "ease-out" }));
3213
+ }
3214
+ return u.length > 1 ? u : [];
3215
+ }
3216
+ function as(e, t, n, o) {
3217
+ const r = n * (1 - 0.18 * o), s = n * (1 + 0.14 * o), l = [{ time: e[0].time, value: n }], i = (a, h, c) => {
3218
+ const g = l[l.length - 1];
3219
+ a <= g.time + ge || l.push({ time: a, value: h, ...c ? { easing: c } : {} });
3049
3220
  };
3221
+ for (let a = 1; a < e.length; a++) {
3222
+ const h = e[a - 1].pose[t], c = e[a].pose[t], g = e[a - 1].time, u = e[a].time, f = u - g;
3223
+ if (!(f < ut || e[a].act === !1)) {
3224
+ if (h <= ae && c > ae)
3225
+ i(g, n), i(g + f * 0.2, r, "ease-out"), i(g + f * 0.45, s, "ease-out"), i(u, n, "ease-in-out");
3226
+ else if (h > ae && c <= ae) {
3227
+ const p = a + 1 < e.length ? e[a + 1].time - u : 400;
3228
+ i(g + f * 0.5, n), i(u - Math.min(60, f * 0.15), s, "ease-in"), i(u, r, "ease-out"), i(u + Math.min(260, p / 2), n, { type: "back", mode: "out", overshoot: 1.4 });
3229
+ }
3230
+ }
3231
+ }
3232
+ return l.length > 1 ? l : [];
3233
+ }
3234
+ const hs = {
3235
+ depth: {
3236
+ lean: 0,
3237
+ rise: 0,
3238
+ sit: 0,
3239
+ spin: 0,
3240
+ stretch: 0,
3241
+ turn: 0,
3242
+ leftHip: 0,
3243
+ rightHip: 0,
3244
+ headTilt: 1,
3245
+ leftShoulder: 1,
3246
+ rightShoulder: 1,
3247
+ leftKnee: 1,
3248
+ rightKnee: 1,
3249
+ leftBrow: 1,
3250
+ rightBrow: 1,
3251
+ browTilt: 1,
3252
+ leftEye: 1,
3253
+ rightEye: 1,
3254
+ leftElbow: 2,
3255
+ rightElbow: 2,
3256
+ leftAnkle: 2,
3257
+ rightAnkle: 2,
3258
+ leftFootOut: 2,
3259
+ rightFootOut: 2,
3260
+ mouth: 2,
3261
+ smile: 2,
3262
+ mouthWidth: 2,
3263
+ leftWrist: 3,
3264
+ rightWrist: 3
3265
+ },
3266
+ limits: {
3267
+ lean: 10,
3268
+ headTilt: 12,
3269
+ spin: 25,
3270
+ turn: 0.06,
3271
+ sit: 0.06,
3272
+ stretch: 0.08,
3273
+ rise: 0,
3274
+ leftShoulder: 20,
3275
+ rightShoulder: 20,
3276
+ leftElbow: 18,
3277
+ rightElbow: 18,
3278
+ leftWrist: 15,
3279
+ rightWrist: 15,
3280
+ leftHip: 12,
3281
+ rightHip: 12,
3282
+ leftKnee: 15,
3283
+ rightKnee: 15,
3284
+ leftAnkle: 10,
3285
+ rightAnkle: 10,
3286
+ leftBrow: 0.25,
3287
+ rightBrow: 0.25,
3288
+ leftEye: 0.15,
3289
+ rightEye: 0.15
3290
+ },
3291
+ eyes: ["lookX", "lookY"],
3292
+ blink: "blink",
3293
+ headTurns: { turn: 0.15, headTilt: 8, lookX: 0.5, spin: 45 },
3294
+ drift: ["lean", "headTilt", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow"],
3295
+ lift: "rise",
3296
+ stretch: "stretch"
3297
+ };
3298
+ function cs(e) {
3299
+ return /^(turn|lean|side|lift|roll|stretch)$/.test(e) ? { depth: 0, limit: { turn: 0.06, lean: 10, side: 8, lift: 0, roll: 25, stretch: 0.08 }[e] } : /^leg\.\w+\.(swing|spread|rotate)$/.test(e) ? { depth: 0, limit: 12 } : /^head\./.test(e) ? { depth: 1, limit: 12 } : /^arm\.\w+\.(swing|spread)$/.test(e) ? { depth: 1, limit: 20 } : /^leg\.\w+\.knee$/.test(e) ? { depth: 1, limit: 15 } : /^(brow\.|browTilt$)/.test(e) ? { depth: 1, limit: e === "browTilt" ? void 0 : 0.25 } : /^eye\./.test(e) ? { depth: 1, limit: 0.15 } : /^arm\.\w+\.(elbow|bend)$/.test(e) ? { depth: 2, limit: 18 } : /^leg\.\w+\.(ankle|toeOut)$/.test(e) ? { depth: 2, limit: 10 } : /^(mouth|smile|mouthWidth)$/.test(e) ? { depth: 2 } : /^hand\./.test(e) ? { depth: 3 } : { depth: 1 };
3300
+ }
3301
+ function fs() {
3302
+ const e = {}, t = {};
3303
+ for (const n of Object.keys(q)) {
3304
+ const o = cs(n);
3305
+ e[n] = o.depth, o.limit !== void 0 && (t[n] = o.limit);
3306
+ }
3307
+ return {
3308
+ depth: e,
3309
+ limits: t,
3310
+ eyes: ["lookX", "lookY"],
3311
+ blink: "blink",
3312
+ headTurns: { turn: 0.15, "head.turn": 15, "head.nod": 12, lookX: 0.5, roll: 45 },
3313
+ drift: ["lean", "head.tilt", "head.nod", "arm.left.spread", "arm.right.spread", "arm.left.elbow", "arm.right.elbow"],
3314
+ lift: "lift",
3315
+ stretch: "stretch"
3316
+ };
3317
+ }
3318
+ const us = fs();
3319
+ function Kn(e, t) {
3320
+ return Object.entries(t).map(([n, o]) => ({ id: `${e}-${n}`, target: e, property: n, keyframes: o }));
3321
+ }
3322
+ function Vs(e, t, n = {}) {
3323
+ const o = fn(t), r = t.map((s, l) => ({ time: s.time, pose: { ...o[l] }, easing: s.easing, act: s.act }));
3324
+ return Kn(e, xn(r, n.rig ?? hs, n));
3325
+ }
3326
+ function Zs(e, t, n = {}) {
3327
+ const o = n.rest ?? q, r = En(t, o), s = t.map((l, i) => ({ time: l.time, pose: { ...o, ...r[i] }, easing: l.easing, act: l.act }));
3328
+ return Kn(e, xn(s, n.rig ?? us, n));
3329
+ }
3330
+ const Ut = D.shocked, ds = D.scared, Pn = {
3331
+ /** The classic take: squash down in a squint, then shoot up stretched with eyes popping, hang, and land squashed. */
3332
+ take: (e) => [
3333
+ { after: 140, pose: { stretch: 0.8, lean: e.lean - 4, leftShoulder: 8, rightShoulder: 8, leftEye: 0.35, rightEye: 0.35, leftBrow: -0.6, rightBrow: -0.6, mouth: 0 }, easing: "ease-in-out" },
3334
+ { after: 260, pose: { stretch: 0.78 } },
3335
+ { after: 360, pose: { rise: 0.22, stretch: 1.35, leftShoulder: 150, rightShoulder: 150, leftElbow: 35, rightElbow: 35, leftHip: 22, rightHip: 22, leftKnee: 45, rightKnee: 45, ...Ut, headTilt: 0 }, easing: "ease-out-cubic" },
3336
+ { after: 720, pose: { rise: 0.25, stretch: 1.25, leftShoulder: 140, rightShoulder: 140 }, easing: "ease-in-out" },
3337
+ { after: 900, pose: { rise: 0, stretch: 0.74, leftShoulder: 70, rightShoulder: 70, leftHip: 18, rightHip: 18, leftKnee: 30, rightKnee: 30 }, easing: "ease-in-quad" },
3338
+ { after: 1060, pose: { stretch: 1.06, leftShoulder: 60, rightShoulder: 60, leftHip: e.leftHip, rightHip: e.rightHip, leftKnee: e.leftKnee, rightKnee: e.rightKnee }, easing: "ease-out" },
3339
+ { after: 1260, pose: { stretch: e.stretch, ...D.surprised, leftShoulder: 70, rightShoulder: 70, leftElbow: 60, rightElbow: 60 }, easing: "ease-in-out" }
3340
+ ],
3341
+ /** Glance at something, look away unbothered, then snap back to it in shock. */
3342
+ doubleTake: (e) => [
3343
+ { after: 160, pose: { lookX: 1, lookY: 0 }, easing: "ease-out" },
3344
+ { after: 520, pose: { lookX: -0.6, headTilt: e.headTilt - 4, smile: 0.6, mouth: 0 }, easing: "ease-in-out" },
3345
+ { after: 1100, pose: { lookX: -0.6 } },
3346
+ { after: 1180, pose: { headTilt: e.headTilt + 10, rise: 0.05, stretch: 1.18, ...Ut, lookX: 1, lookY: 0 }, easing: "ease-out-cubic" },
3347
+ { after: 1360, pose: { rise: 0, stretch: 0.88, headTilt: e.headTilt + 4 }, easing: "ease-in-quad" },
3348
+ { after: 1560, pose: { stretch: e.stretch, headTilt: e.headTilt }, easing: { type: "elastic", mode: "out", amplitude: 1, period: 0.35 } }
3349
+ ],
3350
+ /** Rear back for a zip-off: lean back, one knee up, arms cocked, hold, then pitch forward ready to run. */
3351
+ windUp: () => [
3352
+ { after: 220, pose: { lean: -18, headTilt: -6, leftShoulder: 70, leftElbow: -100, rightShoulder: 40, rightElbow: 100, leftHip: -45, leftKnee: -80, stretch: 0.92, ...D.angry, lookX: 1 }, easing: "ease-out" },
3353
+ { after: 620, pose: { lean: -20, stretch: 0.9 } },
3354
+ { after: 700, pose: { lean: 28, headTilt: 6, leftShoulder: 30, rightShoulder: 60, leftHip: 30, leftKnee: -30, rightHip: -20, stretch: 1.12 }, easing: "ease-out-cubic" }
3355
+ ],
3356
+ /** Coming down to the ground: stretched in the fall, squashed on contact, a spring back up. */
3357
+ land: (e) => [
3358
+ { after: 120, pose: { rise: 0, stretch: 0.7, leftShoulder: 75, rightShoulder: 75, leftHip: 20, rightHip: 20, leftKnee: 35, rightKnee: 35 }, easing: "ease-in-quad" },
3359
+ { after: 300, pose: { stretch: 1.05, leftShoulder: e.leftShoulder, rightShoulder: e.rightShoulder }, easing: "ease-out" },
3360
+ { after: 460, pose: { rise: 0, stretch: e.stretch, leftHip: N.leftHip, rightHip: N.rightHip, leftKnee: 0, rightKnee: 0 }, easing: "ease-in-out" }
3361
+ ],
3362
+ /** A frightened shiver: small, fast shakes with wide eyes, then still. */
3363
+ tremble: (e) => {
3364
+ const t = [{ after: 80, pose: { ...ds, leftShoulder: 40, rightShoulder: 40, leftElbow: 110, rightElbow: 110, stretch: 0.94 }, easing: "ease-out" }];
3365
+ for (let n = 1; n <= 14; n++) t.push({ after: 80 + n * 45, pose: { lean: e.lean + (n % 2 === 0 ? 2.5 : -2.5), headTilt: e.headTilt + (n % 2 === 0 ? -2 : 2) } });
3366
+ return t.push({ after: 755, pose: { lean: e.lean, headTilt: e.headTilt } }), t;
3367
+ },
3368
+ /** A sigh: the body sags, shoulders drop, head and eyes go down. */
3369
+ deflate: (e) => [
3370
+ { after: 260, pose: { stretch: 1.04, headTilt: e.headTilt + 4, leftBrow: 0.3, rightBrow: 0.3 }, easing: "ease-in-out" },
3371
+ { after: 900, pose: { ...bt.sad, stretch: 0.92, lean: e.lean + 5, turn: e.turn, sit: e.sit }, easing: "ease-in-out" }
3372
+ ]
3373
+ };
3374
+ function Qs(e, t) {
3375
+ const n = typeof t.from == "string" ? bt[t.from] : t.from ?? N, o = t.speed ?? 1;
3376
+ let r = n;
3377
+ return [
3378
+ // The move onto the starting pose is acted like any other; the gag itself is not.
3379
+ { time: t.at, pose: n },
3380
+ ...Pn[e](n).map((s) => (r = { ...r, ...s.pose }, { time: t.at + s.after * o, pose: r, act: !1, ...s.easing ? { easing: s.easing } : {} }))
3381
+ ];
3382
+ }
3383
+ function ei(e, t = 1) {
3384
+ const n = Pn[e](N);
3385
+ return n[n.length - 1].after * t;
3386
+ }
3387
+ function gs(e, t, n = {}) {
3388
+ if (t.length < 2) return;
3389
+ const o = Math.max(1, Math.round(n.lines ?? 3)), r = n.spacing ?? 5, s = n.lineWidth ?? 2, l = n.opacity ?? 0.7;
3390
+ e.save(), e.strokeStyle = n.color ?? "#222", e.lineCap = "round";
3391
+ for (let i = 0; i < o; i++) {
3392
+ const a = (i - (o - 1) / 2) * r, h = Math.floor(Math.abs(a) / Math.max(r, 1) * (t.length / 6));
3393
+ for (let c = h + 1; c < t.length; c++) {
3394
+ const g = t[c - 1], u = t[c], f = u.x - g.x, p = u.y - g.y, d = Math.hypot(f, p) || 1, b = -p / d, m = f / d, w = 1 - c / (t.length - 1);
3395
+ e.globalAlpha = l * (1 - w), e.lineWidth = s * (1 - w * 0.7), e.beginPath(), e.moveTo(g.x + b * a, g.y + m * a), e.lineTo(u.x + b * a, u.y + m * a), e.stroke();
3396
+ }
3397
+ }
3398
+ e.restore();
3399
+ }
3400
+ const ps = {
3401
+ hands: [
3402
+ { name: "left hand", at: (e) => e.hands.left },
3403
+ { name: "right hand", at: (e) => e.hands.right }
3404
+ ],
3405
+ toes: [
3406
+ { name: "left toe", at: (e) => e.toes.left },
3407
+ { name: "right toe", at: (e) => e.toes.right }
3408
+ ],
3409
+ head: [{ name: "head", at: (e) => e.head.center }],
3410
+ body: [
3411
+ { name: "hip", at: (e) => e.hip },
3412
+ { name: "neck", at: (e) => e.neck }
3413
+ ]
3414
+ };
3415
+ function ti(e, t, n, o, r = {}) {
3416
+ const s = n.stateAt;
3417
+ if (!s) return;
3418
+ const l = r.length ?? 120, i = Math.max(2, Math.round(r.samples ?? 8)), a = Math.max(0, n.time - l);
3419
+ if (n.time - a < 1) return;
3420
+ const h = [];
3421
+ for (let f = 0; f < i; f++) {
3422
+ const p = a + (n.time - a) * f / (i - 1);
3423
+ h.push(Fo(t, { time: p, state: s(p) }, o).joints);
3424
+ }
3425
+ const c = h[h.length - 1].height, g = (r.threshold ?? 1.2) * c, u = (r.parts ?? ["hands", "toes", "head"]).flatMap((f) => ps[f]);
3426
+ for (const f of u) {
3427
+ const p = h.map(f.at);
3428
+ let d = 0;
3429
+ for (let w = 1; w < p.length; w++) d += Math.hypot(p[w].x - p[w - 1].x, p[w].y - p[w - 1].y);
3430
+ const b = d / ((n.time - a) / 1e3);
3431
+ if (b <= g) continue;
3432
+ const m = Math.min(1, (b - g) / (g * 0.5));
3433
+ gs(e, p, { ...r, opacity: (r.opacity ?? 0.7) * m, spacing: r.spacing ?? c * 0.02 });
3434
+ }
3435
+ }
3436
+ function ni(e, t, n, o = {}) {
3437
+ if (n <= 0 || n >= 1) return;
3438
+ const r = o.size ?? 40, s = o.seed ?? 1, l = 0.45 + 0.55 * (1 - (1 - n) ** 3);
3439
+ e.save(), e.strokeStyle = o.color ?? "#555", e.lineWidth = Math.max(1, r * 0.03), e.globalAlpha = Math.min(1, n / 0.08) * (1 - n);
3440
+ for (let i = 0; i < 5; i++) {
3441
+ const a = De(`${s}:puff:${i}`) % 1e3 / 1e3, h = i - 2, c = t.x + h * r * 0.3 * l, g = t.y - r * (0.06 + 0.12 * a) * l + Math.abs(h) * r * 0.03, u = r * (0.11 + 0.07 * a) * l;
3442
+ e.beginPath(), e.arc(c, g, u, Math.PI * 0.95, Math.PI * 2.05), e.stroke();
3443
+ }
3444
+ e.restore();
3445
+ }
3446
+ function oi(e, t, n, o = {}) {
3447
+ if (n <= 0 || n >= 1) return;
3448
+ const r = o.size ?? 40, s = 5, l = 1 - (1 - n) ** 2;
3449
+ e.save(), e.strokeStyle = o.color ?? "#222", e.lineWidth = Math.max(1, r * 0.035), e.lineJoin = "round", e.globalAlpha = n < 0.7 ? 1 : (1 - n) / 0.3;
3450
+ for (let i = 0; i < s; i++) {
3451
+ const a = -Math.PI / 2 + (i - (s - 1) / 2) * Math.PI / (s + 1), h = r * (0.3 + 0.7 * l), c = t.x + Math.cos(a) * h, g = t.y + Math.sin(a) * h;
3452
+ bs(e, c, g, r * 0.14, n * Math.PI + i), e.stroke();
3453
+ }
3454
+ e.restore();
3455
+ }
3456
+ function bs(e, t, n, o, r) {
3457
+ e.beginPath();
3458
+ for (let s = 0; s < 10; s++) {
3459
+ const l = s % 2 === 0 ? o : o * 0.45, i = r + s * Math.PI / 5 - Math.PI / 2, a = t + Math.cos(i) * l, h = n + Math.sin(i) * l;
3460
+ s === 0 ? e.moveTo(a, h) : e.lineTo(a, h);
3461
+ }
3462
+ e.closePath();
3050
3463
  }
3051
3464
  export {
3052
- ge as DANCE_STYLES,
3053
- Z as EXPRESSIONS,
3054
- xn as FINGERS,
3055
- ut as FLIPS,
3465
+ Qe as ACTING_STYLES,
3466
+ be as DANCE_STYLES,
3467
+ D as EXPRESSIONS,
3468
+ Ln as FINGERS,
3469
+ kt as FLIPS,
3470
+ Pn as GAGS,
3056
3471
  _ 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
3472
+ Y as HAND_SHAPES,
3473
+ us as HUMAN_ACTING_RIG,
3474
+ $s as HUMAN_EXPRESSIONS,
3475
+ Mr as HUMAN_POSES,
3476
+ q as HUMAN_REST,
3477
+ Lt as MUDRAS,
3478
+ bt as POSES,
3479
+ N as REST_POSE,
3480
+ hs as STICK_ACTING_RIG,
3481
+ Zs as actCharacterTracks,
3482
+ xn as actKeyframes,
3483
+ Vs as actTracks,
3484
+ qo as applyGroove,
3485
+ Ps as bakeDanceTracks,
3486
+ Js as basicOutfit,
3487
+ As as beatAt,
3488
+ Me as blendPose,
3489
+ Wn as boilFrame,
3490
+ Br as character,
3491
+ Ns as characterAt,
3492
+ Nr as characterHandPose,
3493
+ Rr as characterJoints,
3494
+ Fs as characterJointsInView,
3495
+ Ds as characterObjects,
3496
+ Cs as characterPoseTracks,
3497
+ Ys as characterTarget,
3498
+ Xs as circlePath,
3499
+ An as clipErased,
3500
+ zt as createPen,
3501
+ wt as danceFrame,
3502
+ vs as dancePose,
3503
+ at as danceStance,
3504
+ Ts as danceTaps,
3505
+ Ks as danceTracks,
3506
+ Ge as danceTravel,
3507
+ zo as danceTravelTrack,
3508
+ xs as dancer,
3509
+ pt as drawCartoonHand,
3510
+ Dr as drawCharacter,
3511
+ qr as drawCharacterInView,
3512
+ ni as drawDustPuff,
3513
+ Mn as drawEraser,
3514
+ vn as drawHand,
3515
+ oi as drawImpactStars,
3516
+ Vr as drawPencil,
3517
+ gs as drawSpeedLines,
3518
+ Io as drawStickFigure,
3519
+ ti as drawStickSmear,
3520
+ Us as drawnPathTarget,
3521
+ xt as ellipsePoints,
3522
+ js as erasable,
3523
+ fr as flipPose,
3524
+ Ws as flipTracks,
3525
+ ur as flipTravel,
3526
+ Qs as gag,
3527
+ ei as gagDuration,
3528
+ qs as handAt,
3529
+ rt as handJoints,
3530
+ Vn as handJointsAt,
3531
+ B as handPose,
3532
+ Re as handProp,
3533
+ Es as headPoint,
3534
+ Is as humanFieldLabel,
3535
+ Hr as humanPlan,
3536
+ Z as humanPose,
3537
+ Xr as jointsInScene,
3538
+ Oo as jointsToScene,
3539
+ Os as mirrorHumanPose,
3540
+ Co as mirrorPose,
3541
+ Ee as mixHandPoses,
3542
+ Rs as mixPoses,
3543
+ Gt as partialPath,
3544
+ ii as pathLength,
3545
+ dt as pointAlong,
3546
+ _s as pointOnHead,
3547
+ X as pose,
3548
+ Hs as poseTracks,
3549
+ Ls as reachCharacter,
3550
+ ns as resolveActingStyle,
3551
+ En as resolveCharacterPoseKeys,
3552
+ fn as resolvePoseKeys,
3553
+ cn as resolveStickFrame,
3554
+ $o as resolveStickPose,
3555
+ he as rotateAbout,
3556
+ yt as routineBeats,
3557
+ pe as rubberLimb,
3558
+ Gs as scrubPath,
3559
+ Ss as seatHeight,
3560
+ wn as skeletonInView,
3561
+ tt as sketchPen,
3562
+ Et as solvePlanSpace,
3563
+ mn as stagePlanSpace,
3564
+ Fo as stickFigureAt,
3565
+ Wo as stickFigureJoints,
3566
+ Ms as stickFigureTarget,
3567
+ Bs as stickToHuman,
3568
+ ks as strideLength,
3569
+ lo as talkingMouth,
3570
+ gt as taperedLine,
3571
+ Oe as taperedOutline,
3572
+ io as walkPose,
3573
+ zs as withErased,
3574
+ Jt as withExpression
3146
3575
  };