@algorisys/tinyfly 0.90.0 → 0.91.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,8 +1,9 @@
1
- import { c as to, s as ut, p as mn, b as Ht } from "./sketch-CYPUbk3Q.js";
2
- import { a as Zi } from "./sketch-CYPUbk3Q.js";
3
- import { createRandom as no, hashSeed as Ze, getEasingFunction as Qe, mat4 as D, vec3 as J, quat as Ft, Timeline as oo } from "@algorisys/tinyfly";
4
- import { f as Rt, h as so, a as ro } from "./load-scene-CQvcFWGJ.js";
5
- function Ye(e, t, n) {
1
+ import { c as ro, s as ut, p as kn, b as Ht } from "./sketch-CYPUbk3Q.js";
2
+ import { a as nl } from "./sketch-CYPUbk3Q.js";
3
+ import { createRandom as io, hashSeed as Ze, getEasingFunction as Qe, mat4 as q, vec3 as J, quat as Ft, Timeline as lo } from "@algorisys/tinyfly";
4
+ import { f as Rt, h as ao, a as ho } from "./load-scene-CQvcFWGJ.js";
5
+ import { I as sl, a as rl, c as il, b as ll } from "./camera-C7bZOWMB.js";
6
+ function Ce(e, t, n) {
6
7
  const s = e.length;
7
8
  if (s < 2) return [];
8
9
  const o = [], r = [], l = (i) => t + (n - t) * i / (s - 1);
@@ -14,14 +15,14 @@ function Ye(e, t, n) {
14
15
  function vt(e, t, n, s) {
15
16
  const o = t.length;
16
17
  if (o < 2) return;
17
- const r = Ye(t, n, s), l = (i) => n + (s - n) * i / (o - 1);
18
+ const r = Ce(t, n, s), l = (i) => n + (s - n) * i / (o - 1);
18
19
  e.beginPath(), e.moveTo(r[0].x, r[0].y);
19
20
  for (const i of r.slice(1)) e.lineTo(i.x, i.y);
20
21
  e.closePath(), e.fill(), t.forEach((i, a) => {
21
22
  a !== 0 && a !== o - 1 && o > 3 || (e.beginPath(), e.arc(i.x, i.y, l(a) / 2, 0, Math.PI * 2), e.fill());
22
23
  });
23
24
  }
24
- function ke(e, t, n, s, o = 16) {
25
+ function Se(e, t, n, s, o = 16) {
25
26
  const r = { x: 2 * t.x - (e.x + n.x) / 2, y: 2 * t.y - (e.y + n.y) / 2 }, l = [];
26
27
  for (let i = 0; i <= o; i++) {
27
28
  const a = i / 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, u = {
@@ -39,15 +40,15 @@ function Lt(e, t, n, s, o, r = 0, l = 1, i = 40) {
39
40
  return { x: e + f * a - p * h, y: t + f * h + p * a };
40
41
  });
41
42
  }
42
- function bn(e, t) {
43
- return t.look === "pencil" ? ho(e, t) : io(e, t.ink, t.look);
43
+ function Sn(e, t) {
44
+ return t.look === "pencil" ? go(e, t) : co(e, t.ink, t.look);
44
45
  }
45
- function Xe(e, t, n = !1) {
46
+ function qe(e, t, n = !1) {
46
47
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
47
48
  for (const s of t.slice(1)) e.lineTo(s.x, s.y);
48
49
  n && e.closePath();
49
50
  }
50
- function io(e, t, n) {
51
+ function co(e, t, n) {
51
52
  const s = n === "silhouette", o = s ? 1.25 : 1;
52
53
  return {
53
54
  look: n,
@@ -56,10 +57,10 @@ function io(e, t, n) {
56
57
  e.fillStyle = t, vt(e, r, l * o, i * o);
57
58
  },
58
59
  line(r, l) {
59
- r.length < 2 || (e.strokeStyle = t, e.lineWidth = l * o, e.lineCap = "round", e.lineJoin = "round", Xe(e, r), e.stroke());
60
+ r.length < 2 || (e.strokeStyle = t, e.lineWidth = l * o, e.lineCap = "round", e.lineJoin = "round", qe(e, r), e.stroke());
60
61
  },
61
62
  shape(r, l, i) {
62
- Xe(e, r, !0), (l !== null || s) && (e.fillStyle = s ? t : l, e.fill()), !(i <= 0) && (e.strokeStyle = t, e.lineWidth = i * o, e.lineJoin = "round", e.stroke());
63
+ qe(e, r, !0), (l !== null || s) && (e.fillStyle = s ? t : l, e.fill()), !(i <= 0) && (e.strokeStyle = t, e.lineWidth = i * o, e.lineJoin = "round", e.stroke());
63
64
  },
64
65
  ellipse(r, l, i, a, h, c, u) {
65
66
  e.beginPath(), e.ellipse(r, l, i, a, h, 0, Math.PI * 2), (c !== null || s) && (e.fillStyle = s ? t : c, e.fill()), !(u <= 0) && (e.strokeStyle = t, e.lineWidth = u * o, e.stroke());
@@ -73,7 +74,7 @@ function io(e, t, n) {
73
74
  }
74
75
  };
75
76
  }
76
- function lo(e, t) {
77
+ function fo(e, t) {
77
78
  const n = [e[0]];
78
79
  let s = 0;
79
80
  for (let l = 1; l < e.length; l++) {
@@ -88,7 +89,7 @@ function lo(e, t) {
88
89
  const o = e[e.length - 1], r = n[n.length - 1];
89
90
  return Math.hypot(o.x - r.x, o.y - r.y) > t * 0.25 ? n.push(o) : n[n.length - 1] = o, n;
90
91
  }
91
- function ao(e, t) {
92
+ function uo(e, t) {
92
93
  const n = e.length;
93
94
  return e.map((s, o) => {
94
95
  const r = e[Math.max(0, o - 1)], l = e[Math.min(n - 1, o + 1)], i = Math.hypot(l.x - r.x, l.y - r.y) || 1, a = t(n === 1 ? 0 : o / (n - 1));
@@ -103,39 +104,39 @@ function Nt(e) {
103
104
  })), n = t.reduce((s, o) => s + o.amount, 0);
104
105
  return (s) => t.reduce((o, r) => o + r.amount * Math.sin(Math.PI * 2 * r.frequency * s + r.phase), 0) / n;
105
106
  }
106
- function ho(e, t) {
107
- const n = t.pencil ?? {}, s = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), r = 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 = to(t.time, n.boil ?? 8);
107
+ function go(e, t) {
108
+ const n = t.pencil ?? {}, s = t.ink, o = n.roughness ?? Math.max(1, t.lineWidth * 0.12), r = 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 = ro(t.time, n.boil ?? 8);
108
109
  let h = 0;
109
- const c = (p, d, m = !1) => no(Ze(`${t.seed}:${m ? "paper" : a}:${p}:${d}`)), u = (p, d, m, b, y, E = 0) => {
110
+ const c = (p, d, m = !1) => io(Ze(`${t.seed}:${m ? "paper" : a}:${p}:${d}`)), u = (p, d, m, b, S, k = 0) => {
110
111
  if (p.length < 2) return;
111
- const H = p.slice(1).reduce((v, T, K) => v + Math.hypot(T.x - p[K].x, T.y - p[K].y), 0);
112
- let M = lo(p, Math.max(1.5, Math.min(t.lineWidth * 0.8, H / 24)));
113
- if (E > 0 && M.length >= 2) {
114
- const [v, T] = [M[M.length - 2], M[M.length - 1]], K = Math.hypot(T.x - v.x, T.y - v.y) || 1;
115
- M = [...M, { x: T.x + (T.x - v.x) / K * E, y: T.y + (T.y - v.y) / K * E }];
112
+ const v = p.slice(1).reduce((x, E, P) => x + Math.hypot(E.x - p[P].x, E.y - p[P].y), 0);
113
+ let H = fo(p, Math.max(1.5, Math.min(t.lineWidth * 0.8, v / 24)));
114
+ if (k > 0 && H.length >= 2) {
115
+ const [x, E] = [H[H.length - 2], H[H.length - 1]], P = Math.hypot(E.x - x.x, E.y - x.y) || 1;
116
+ H = [...H, { x: E.x + (E.x - x.x) / P * k, y: E.y + (E.y - x.y) / P * k }];
116
117
  }
117
- const A = Nt(m), w = Nt(m), S = M.length, k = [], x = [];
118
- M.forEach((v, T) => {
119
- const K = S === 1 ? 0 : T / (S - 1), P = M[Math.max(0, T - 1)], I = M[Math.min(S - 1, T + 1)], q = Math.hypot(I.x - P.x, I.y - P.y) || 1, G = -(I.y - P.y) / q, W = (I.x - P.x) / q, O = A(K) * y, F = Math.min(1, K / 0.08, (1 - K) / 0.08), $ = (0.55 + 0.45 * Math.sqrt(Math.max(0, F))) * (1 + l * w(K)), B = Math.max(0.3, d(K) * $ / 2), U = v.x + G * O, ne = v.y + W * O;
120
- k.push({ x: U + G * B, y: ne + W * B }), x.push({ x: U - G * B, y: ne - W * B });
121
- }), e.save(), e.globalAlpha *= b, e.fillStyle = s, Xe(e, [...k, ...x.reverse()], !0), e.fill(), e.restore();
118
+ const T = Nt(m), M = Nt(m), w = H.length, y = [], A = [];
119
+ H.forEach((x, E) => {
120
+ const P = w === 1 ? 0 : E / (w - 1), K = H[Math.max(0, E - 1)], I = H[Math.min(w - 1, E + 1)], _ = Math.hypot(I.x - K.x, I.y - K.y) || 1, X = -(I.y - K.y) / _, W = (I.x - K.x) / _, O = T(P) * S, R = Math.min(1, P / 0.08, (1 - P) / 0.08), B = (0.55 + 0.45 * Math.sqrt(Math.max(0, R))) * (1 + l * M(P)), F = Math.max(0.3, d(P) * B / 2), U = x.x + X * O, ne = x.y + W * O;
121
+ y.push({ x: U + X * F, y: ne + W * F }), A.push({ x: U - X * F, y: ne - W * F });
122
+ }), e.save(), e.globalAlpha *= b, e.fillStyle = s, qe(e, [...y, ...A.reverse()], !0), e.fill(), e.restore();
122
123
  }, g = (p, d) => {
123
124
  const m = h++, b = c(m, 99, !0);
124
125
  if (b.next() < i) {
125
- const M = (b.next() * 2 - 1) * t.lineWidth * 1.4, A = (b.next() * 2 - 1) * t.lineWidth * 1.4, w = p.map((S) => ({ x: S.x + M, y: S.y + A }));
126
- u(w, (S) => d(S) * 1.8, c(m, 98, !0), 0.035, o), u(w, (S) => d(S) * 0.45, c(m, 97, !0), 0.12, o * 1.5);
126
+ const H = (b.next() * 2 - 1) * t.lineWidth * 1.4, T = (b.next() * 2 - 1) * t.lineWidth * 1.4, M = p.map((w) => ({ x: w.x + H, y: w.y + T }));
127
+ u(M, (w) => d(w) * 1.8, c(m, 98, !0), 0.035, o), u(M, (w) => d(w) * 0.45, c(m, 97, !0), 0.12, o * 1.5);
127
128
  }
128
- const y = p.slice(1).reduce((M, A, w) => M + Math.hypot(A.x - p[w].x, A.y - p[w].y), 0), E = d(0.5) > 4 && y > d(0.5) * 6, H = E ? [-0.3, 0.3, 0] : [0];
129
- for (let M = 0; M < r; M++) {
130
- const A = M === 0;
131
- H.forEach((w, S) => {
132
- const k = c(m, M * 10 + S), x = w === 0 ? p : ao(p, (T) => d(T) * w * Math.sqrt(Math.sin(Math.PI * T))), v = !A && w === 0 ? t.lineWidth * (0.3 + k.next() * 0.8) : 0;
133
- u(x, (T) => d(T) * (E ? 0.5 : 1) * (A ? 1 : 0.6), k, A ? 0.85 : 0.45, o * (A ? 0.6 : 1), v);
129
+ const S = p.slice(1).reduce((H, T, M) => H + Math.hypot(T.x - p[M].x, T.y - p[M].y), 0), k = d(0.5) > 4 && S > d(0.5) * 6, v = k ? [-0.3, 0.3, 0] : [0];
130
+ for (let H = 0; H < r; H++) {
131
+ const T = H === 0;
132
+ v.forEach((M, w) => {
133
+ const y = c(m, H * 10 + w), A = M === 0 ? p : uo(p, (E) => d(E) * M * Math.sqrt(Math.sin(Math.PI * E))), x = !T && M === 0 ? t.lineWidth * (0.3 + y.next() * 0.8) : 0;
134
+ u(A, (E) => d(E) * (k ? 0.5 : 1) * (T ? 1 : 0.6), y, T ? 0.85 : 0.45, o * (T ? 0.6 : 1), x);
134
135
  });
135
136
  }
136
- }, f = (p, d, m, b, y, E) => {
137
- const M = c(h, 50).next() * Math.PI * 2;
138
- g(Lt(p, d, m, b, y, M, 1.08, 48), () => E);
137
+ }, f = (p, d, m, b, S, k) => {
138
+ const H = c(h, 50).next() * Math.PI * 2;
139
+ g(Lt(p, d, m, b, S, H, 1.08, 48), () => k);
139
140
  };
140
141
  return {
141
142
  look: "pencil",
@@ -147,10 +148,10 @@ function ho(e, t) {
147
148
  g(p, () => d);
148
149
  },
149
150
  shape(p, d, m) {
150
- d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, Xe(e, p, !0), e.fill(), e.restore()), m > 0 && g([...p, p[0]], () => m);
151
+ d !== null && (e.save(), e.globalAlpha *= 0.88, e.fillStyle = d, qe(e, p, !0), e.fill(), e.restore()), m > 0 && g([...p, p[0]], () => m);
151
152
  },
152
- ellipse(p, d, m, b, y, E, H) {
153
- E !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = E, e.beginPath(), e.ellipse(p, d, m, b, y, 0, Math.PI * 2), e.fill(), e.restore()), f(p, d, m, b, y, H);
153
+ ellipse(p, d, m, b, S, k, v) {
154
+ k !== null && (e.save(), e.globalAlpha *= 0.9, e.fillStyle = k, e.beginPath(), e.ellipse(p, d, m, b, S, 0, Math.PI * 2), e.fill(), e.restore()), f(p, d, m, b, S, v);
154
155
  },
155
156
  dot(p, d, m) {
156
157
  e.save(), e.globalAlpha *= 0.9, e.fillStyle = s, e.beginPath(), e.arc(p, d, m, 0, Math.PI * 2), e.fill(), e.restore();
@@ -160,14 +161,14 @@ function ho(e, t) {
160
161
  const d = h++;
161
162
  u(p, () => Math.max(0.6, t.lineWidth * 0.18), c(d, 0), 0.28, o * 1.2, t.lineWidth);
162
163
  },
163
- guideEllipse(p, d, m, b, y) {
164
+ guideEllipse(p, d, m, b, S) {
164
165
  if (n.construction === !1) return;
165
- const E = h++, H = c(E, 0), M = Lt(p, d, m, b, y, H.next() * Math.PI * 2, 1.12, 48);
166
- u(M, () => Math.max(0.6, t.lineWidth * 0.18), H, 0.28, o * 1.5);
166
+ const k = h++, v = c(k, 0), H = Lt(p, d, m, b, S, v.next() * Math.PI * 2, 1.12, 48);
167
+ u(H, () => Math.max(0.6, t.lineWidth * 0.18), v, 0.28, o * 1.5);
167
168
  }
168
169
  };
169
170
  }
170
- const co = ["thumb", "index", "middle", "ring", "pinky"], L = {
171
+ const po = ["thumb", "index", "middle", "ring", "pinky"], N = {
171
172
  "thumb.curl": 0.15,
172
173
  "thumb.across": 0.15,
173
174
  "index.curl": 0.12,
@@ -180,8 +181,8 @@ const co = ["thumb", "index", "middle", "ring", "pinky"], L = {
180
181
  tilt: 0,
181
182
  roll: 0
182
183
  };
183
- function R(e = {}) {
184
- return { ...L, ...e };
184
+ function L(e = {}) {
185
+ return { ...N, ...e };
185
186
  }
186
187
  const j = (e, t, n, s, o) => ({
187
188
  "thumb.curl": e,
@@ -189,24 +190,24 @@ const j = (e, t, n, s, o) => ({
189
190
  "middle.curl": n,
190
191
  "ring.curl": s,
191
192
  "pinky.curl": o
192
- }), C = {
193
- relaxed: L,
194
- open: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
195
- spread: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
196
- flat: R({ ...j(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
197
- fist: R({ ...j(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
198
- point: R({ ...j(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
193
+ }), D = {
194
+ relaxed: N,
195
+ open: L({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
196
+ spread: L({ ...j(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
197
+ flat: L({ ...j(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
198
+ fist: L({ ...j(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
199
+ point: L({ ...j(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
199
200
  /** The fist on its side, knuckles toward the viewer, the thumb up */
200
- thumbsUp: R({ ...j(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
201
- peace: R({ ...j(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
202
- ok: R({ ...j(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
203
- pinch: R({ ...j(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
204
- cupped: R({ ...j(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
205
- wave: R({ ...j(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
201
+ thumbsUp: L({ ...j(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
202
+ peace: L({ ...j(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
203
+ ok: L({ ...j(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
204
+ pinch: L({ ...j(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
205
+ cupped: L({ ...j(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
206
+ wave: L({ ...j(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
206
207
  /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
207
- pencilGrip: R({ ...j(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
208
+ pencilGrip: L({ ...j(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
208
209
  /** Holding a handle, a cup or a bar: every finger wrapped round it */
209
- hold: R({ ...j(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
210
+ hold: L({ ...j(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
210
211
  };
211
212
  function Ke(e, t, n) {
212
213
  const s = { ...e };
@@ -216,12 +217,12 @@ function Ke(e, t, n) {
216
217
  }
217
218
  return s;
218
219
  }
219
- const fo = {
220
+ const mo = {
220
221
  index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
221
222
  middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
222
223
  ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
223
224
  pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
224
- }, uo = {
225
+ }, bo = {
225
226
  index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
226
227
  middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
227
228
  pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
@@ -232,7 +233,7 @@ const fo = {
232
233
  /** Where the thumb points with `across` 0 and 1 */
233
234
  out: [-0.7, 0.68, -0.22],
234
235
  across: [0.35, 0.5, -0.8]
235
- }, go = [82, 100, 62], po = [48, 72], mo = 3, bo = 13, wo = 0.035, yo = -0.075, ko = [
236
+ }, wo = [82, 100, 62], yo = [48, 72], ko = 3, So = 13, Eo = 0.035, Mo = -0.075, Ho = [
236
237
  [-0.17, 0],
237
238
  [-0.215, 0.12],
238
239
  [-0.235, 0.26],
@@ -245,7 +246,7 @@ const fo = {
245
246
  [0.225, 0.26],
246
247
  [0.2, 0.1],
247
248
  [0.16, 0]
248
- ], ae = (e) => e * Math.PI / 180, dt = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], Ce = (e, t) => [e[0] * t, e[1] * t, e[2] * t], gt = (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]], Ee = (e) => {
249
+ ], ae = (e) => e * Math.PI / 180, dt = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], De = (e, t) => [e[0] * t, e[1] * t, e[2] * t], gt = (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
250
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
250
251
  return [e[0] / t, e[1] / t, e[2] / t];
251
252
  };
@@ -258,73 +259,73 @@ function de(e, t, n) {
258
259
  ];
259
260
  }
260
261
  const Yt = [1, 0, 0], Ct = [0, 1, 0], Ae = [0, 0, 1];
261
- function So(e, t, n) {
262
- const s = ae(e.fan * (mo + bo * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], l = [e.knuckle];
262
+ function vo(e, t, n) {
263
+ const s = ae(e.fan * (ko + So * n)), o = [Math.sin(s), Math.cos(s), 0], r = [Math.cos(s), -Math.sin(s), 0], l = [e.knuckle];
263
264
  let i = 0;
264
265
  e.bones.forEach((c, u) => {
265
- i += ae(go[u] * t), l.push(dt(l[u], Ce(de(o, r, -i), c)));
266
+ i += ae(wo[u] * t), l.push(dt(l[u], De(de(o, r, -i), c)));
266
267
  });
267
268
  const a = de(Ae, r, -i), h = l.map((c, u) => e.width * (1 - 0.14 * (u / (l.length - 1))));
268
269
  return { joints: l, back: a, widths: h };
269
270
  }
270
- function Eo(e, t, n = 1, s = 1) {
271
- const o = Math.min(1, Math.max(0, t)), r = Ee(dt(Ce(Ee(se.out), 1 - o), Ce(Ee(se.across), o))), l = Ee(gt(Ae, r)), i = Ee(gt(r, l)), a = [[se.base[0] * s, se.base[1], se.base[2]]];
271
+ function To(e, t, n = 1, s = 1) {
272
+ const o = Math.min(1, Math.max(0, t)), r = Me(dt(De(Me(se.out), 1 - o), De(Me(se.across), o))), l = Me(gt(Ae, r)), i = Me(gt(r, l)), a = [[se.base[0] * s, se.base[1], se.base[2]]];
272
273
  let h = 0;
273
274
  se.bones.forEach((g, f) => {
274
- f > 0 && (h += ae(po[f - 1] * e)), a.push(dt(a[f], Ce(de(r, l, h), g)));
275
+ f > 0 && (h += ae(yo[f - 1] * e)), a.push(dt(a[f], De(de(r, l, h), g)));
275
276
  });
276
277
  const c = de(i, l, h), u = [...se.widths, se.widths[se.widths.length - 1] * 0.92].map((g) => g * n);
277
278
  return { joints: a, back: c, widths: u };
278
279
  }
279
280
  function pt(e, t = {}) {
280
- const n = { ...L, ...e }, s = t.size ?? 100, o = t.side ?? "right", r = o === "left" ? -1 : 1, l = ae(t.angle ?? 0), i = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (T) => ({
281
- ...T,
282
- knuckle: [T.knuckle[0] * h, T.knuckle[1], T.knuckle[2]],
283
- width: T.width * a
284
- }), u = ae(n.bend ?? 0), g = ae(n.tilt ?? 0), f = ae(90 * (n.turn ?? 0)), p = (T) => de(de(de(T, Yt, -u), Ae, -g), Ct, f), d = Math.cos(l), m = Math.sin(l), b = ae(n.roll ?? 0), y = Math.cos(b), E = Math.sin(b), H = (T) => {
285
- const K = T[0] * s, P = -T[1] * s, I = (K * y - P * E) * r, q = K * E + P * y;
286
- return { x: I * d - q * m, y: I * m + q * d };
287
- }, M = (T) => {
288
- const K = H(T), P = Math.hypot(K.x, K.y);
289
- return P > 1e-6 * s ? { x: K.x / P, y: K.y / P } : { x: 0, y: 0 };
290
- }, A = {
291
- thumb: Eo(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
292
- }, w = i ? uo : fo;
293
- for (const T of co) {
294
- const K = w[T];
295
- K && (A[T] = So(c(K), n[`${T}.curl`] ?? 0, n.spread ?? 0));
296
- }
297
- const S = {};
298
- for (const [T, K] of Object.entries(A)) {
299
- const P = K.joints.map(p), I = p(K.back);
300
- S[T] = {
301
- points: P.map(H),
302
- depths: P.map((q) => q[2] * s),
303
- widths: K.widths.map((q) => q * s),
281
+ const n = { ...N, ...e }, s = t.size ?? 100, o = t.side ?? "right", r = o === "left" ? -1 : 1, l = ae(t.angle ?? 0), i = t.fingers === 4, a = Math.max(0.5, t.plump ?? 1), h = 1 + (a - 1) * 0.7, c = (E) => ({
282
+ ...E,
283
+ knuckle: [E.knuckle[0] * h, E.knuckle[1], E.knuckle[2]],
284
+ width: E.width * a
285
+ }), u = ae(n.bend ?? 0), g = ae(n.tilt ?? 0), f = ae(90 * (n.turn ?? 0)), p = (E) => de(de(de(E, Yt, -u), Ae, -g), Ct, f), d = Math.cos(l), m = Math.sin(l), b = ae(n.roll ?? 0), S = Math.cos(b), k = Math.sin(b), v = (E) => {
286
+ const P = E[0] * s, K = -E[1] * s, I = (P * S - K * k) * r, _ = P * k + K * S;
287
+ return { x: I * d - _ * m, y: I * m + _ * d };
288
+ }, H = (E) => {
289
+ const P = v(E), K = Math.hypot(P.x, P.y);
290
+ return K > 1e-6 * s ? { x: P.x / K, y: P.y / K } : { x: 0, y: 0 };
291
+ }, T = {
292
+ thumb: To(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, a, h)
293
+ }, M = i ? bo : mo;
294
+ for (const E of po) {
295
+ const P = M[E];
296
+ P && (T[E] = vo(c(P), n[`${E}.curl`] ?? 0, n.spread ?? 0));
297
+ }
298
+ const w = {};
299
+ for (const [E, P] of Object.entries(T)) {
300
+ const K = P.joints.map(p), I = p(P.back);
301
+ w[E] = {
302
+ points: K.map(v),
303
+ depths: K.map((_) => _[2] * s),
304
+ widths: P.widths.map((_) => _ * s),
304
305
  nail: I[2],
305
- back: M(I)
306
+ back: H(I)
306
307
  };
307
308
  }
308
- const k = ko.flatMap(([T, K]) => [p([T * h, K, wo]), p([T * h, K, yo])]), x = Ho(k.map(H)), v = k.reduce((T, K) => T + K[2], 0) / k.length * s;
309
+ const y = Ho.flatMap(([E, P]) => [p([E * h, P, Eo]), p([E * h, P, Mo])]), A = xo(y.map(v)), x = y.reduce((E, P) => E + P[2], 0) / y.length * s;
309
310
  return {
310
311
  size: s,
311
312
  side: o,
312
313
  wrist: { x: 0, y: 0 },
313
- palm: x,
314
- palmDepth: v,
314
+ palm: A,
315
+ palmDepth: x,
315
316
  palmFacing: -p(Ae)[2],
316
- fingers: S,
317
- axes: { up: M(p(Ct)), across: M(p(Yt)), out: M(p(Ae)) },
318
- curls: Object.fromEntries(Object.keys(S).map((T) => [T, n[`${T}.curl`] ?? 0]))
317
+ fingers: w,
318
+ axes: { up: H(p(Ct)), across: H(p(Yt)), out: H(p(Ae)) },
319
+ curls: Object.fromEntries(Object.keys(w).map((E) => [E, n[`${E}.curl`] ?? 0]))
319
320
  };
320
321
  }
321
- function Mo(e, t) {
322
+ function Ao(e, t) {
322
323
  const n = (o) => ({ x: o.x + t.x - e.wrist.x, y: o.y + t.y - e.wrist.y }), s = {};
323
324
  for (const [o, r] of Object.entries(e.fingers))
324
325
  s[o] = { ...r, points: r.points.map(n) };
325
326
  return { ...e, wrist: n(e.wrist), palm: e.palm.map(n), fingers: s };
326
327
  }
327
- function Ho(e) {
328
+ function xo(e) {
328
329
  const t = [...e].sort((r, l) => r.x - l.x || r.y - l.y);
329
330
  if (t.length < 3) return t;
330
331
  const n = (r, l, i) => (l.x - r.x) * (i.y - r.y) - (l.y - r.y) * (i.x - r.x), s = [];
@@ -339,26 +340,26 @@ function Ho(e) {
339
340
  }
340
341
  return [...s.slice(0, -1), ...o.slice(0, -1)];
341
342
  }
342
- const vo = "#f1c9a5", To = "#2f2f33";
343
+ const Po = "#f1c9a5", Ko = "#2f2f33";
343
344
  function Tt(e, t, n, s = {}, o = 0) {
344
- const r = Mo(pt(n, s), t), l = s.ink ?? To, i = s.lineWidth ?? r.size * 0.035, a = s.pen ?? bn(e, {
345
+ const r = Ao(pt(n, s), t), l = s.ink ?? Ko, i = s.lineWidth ?? r.size * 0.035, a = s.pen ?? Sn(e, {
345
346
  look: s.look ?? "clean",
346
347
  ink: l,
347
348
  lineWidth: i,
348
349
  seed: s.seed ?? 1,
349
350
  time: o,
350
351
  pencil: { construction: !1, ...s.pencil }
351
- }), h = s.skin ?? vo, c = s.nails ?? !0, u = [
352
+ }), h = s.skin ?? Po, c = s.nails ?? !0, u = [
352
353
  {
353
354
  depth: r.palmDepth,
354
- draw: () => Ao(a, r, h, i)
355
+ draw: () => Wo(a, r, h, i)
355
356
  }
356
357
  ];
357
358
  for (const g of Object.values(r.fingers)) {
358
359
  const f = g.depths.reduce((p, d) => p + d, 0) / g.depths.length;
359
360
  u.push({
360
361
  depth: f,
361
- draw: () => xo(e, a, g, h, i, c)
362
+ draw: () => Oo(e, a, g, h, i, c)
362
363
  });
363
364
  }
364
365
  if (s.prop) {
@@ -369,7 +370,7 @@ function Tt(e, t, n, s = {}, o = 0) {
369
370
  for (const g of [...u].sort((f, p) => f.depth - p.depth)) g.draw();
370
371
  return e.restore(), r;
371
372
  }
372
- function Ao(e, t, n, s) {
373
+ function Wo(e, t, n, s) {
373
374
  if (e.shape(t.palm, n, s), t.palmFacing < -0.3 && e.look !== "silhouette") {
374
375
  const { up: o } = t.axes;
375
376
  for (const [r, l] of Object.entries(t.fingers)) {
@@ -390,15 +391,15 @@ function Ao(e, t, n, s) {
390
391
  e.line([a(-0.15 * h, 0.36), a(-0.04 * h, 0.3), a(0.1 * h, 0.33)], s * 0.5);
391
392
  }
392
393
  }
393
- function xo(e, t, n, s, o, r) {
394
- const { widths: l } = n, i = Ko(n.points, 2), a = n.points[0], h = i[i.length - 1], c = l[0], u = l[l.length - 1];
394
+ function Oo(e, t, n, s, o, r) {
395
+ const { widths: l } = n, i = Io(n.points, 2), a = n.points[0], h = i[i.length - 1], c = l[0], u = l[l.length - 1];
395
396
  if (e.save(), t.look !== "silhouette") {
396
397
  e.beginPath(), e.rect(a.x - 1e5, a.y - 1e5, 2e5, 2e5);
397
398
  const d = c / 2 + o * 1.6;
398
399
  e.moveTo(a.x + d, a.y), e.arc(a.x, a.y, d, 0, Math.PI * 2), e.clip("evenodd");
399
400
  }
400
401
  if (t.limb(i, c + 2 * o, u + 2 * o), e.restore(), t.look !== "silhouette" && (e.fillStyle = s, vt(e, i, c, u)), t.look === "silhouette" || !r || n.nail < 0.25) return;
401
- const g = i[i.length - 2], f = Po({ x: h.x - g.x, y: h.y - g.y }) ?? {
402
+ const g = i[i.length - 2], f = _o({ x: h.x - g.x, y: h.y - g.y }) ?? {
402
403
  x: 0,
403
404
  y: -1
404
405
  }, p = {
@@ -407,7 +408,7 @@ function xo(e, t, n, s, o, r) {
407
408
  };
408
409
  t.ellipse(p.x, p.y, u * 0.24 * Math.max(0.35, n.nail), u * 0.19, Math.atan2(f.y, f.x), "#f8e3d3", o * 0.45);
409
410
  }
410
- function Ko(e, t) {
411
+ function Io(e, t) {
411
412
  let n = e;
412
413
  for (let s = 0; s < t; s++) {
413
414
  if (n.length < 3) return n;
@@ -420,10 +421,10 @@ function Ko(e, t) {
420
421
  }
421
422
  return n;
422
423
  }
423
- const Po = (e) => {
424
+ const _o = (e) => {
424
425
  const t = Math.hypot(e.x, e.y);
425
426
  return t > 1e-6 ? { x: e.x / t, y: e.y / t } : null;
426
- }, we = {
427
+ }, ye = {
427
428
  walk: { swing: 24, knee: 30, arm: 22, elbow: 28, lean: 4 },
428
429
  bouncy: { swing: 26, knee: 45, arm: 34, elbow: 30, lean: 2, bend: -4, bounce: 0.035, squash: 0.06 },
429
430
  doubleBounce: { swing: 22, knee: 40, arm: 26, elbow: 24, lean: 3, bounce: 0.02, bounces: 2, squash: 0.04 },
@@ -431,14 +432,14 @@ const Po = (e) => {
431
432
  strut: { swing: 26, knee: 30, arm: 30, elbow: 20, lean: -4, bend: -10, headTilt: -6, sway: 4, bounce: 0.01 },
432
433
  tired: { swing: 14, knee: 14, arm: 6, elbow: 6, lean: 10, bend: 16, headTilt: 12 },
433
434
  run: { swing: 40, knee: 95, arm: 45, elbow: 0, forearm: 90, lean: 16, bend: 6, bounce: 0.05, squash: 0.06 }
434
- }, Wo = 40;
435
- function wn(e) {
436
- return e === void 0 ? we.walk : typeof e == "string" ? we[e] ?? we.walk : e;
437
- }
438
- function Oo(e, t, n = _, s = 1) {
439
- const o = wn(e);
440
- if (o === we.walk) return $o(t, n, s);
441
- const r = t * Math.PI * 2, l = Math.sin(r) * s, i = Math.cos(r) * s, a = (b) => b <= Wo, h = o.shoulder ?? 0, c = (b, y) => a(b) ? y * h + o.arm * l : b, u = o.forearm ?? 0, g = a(n.leftShoulder) ? n.leftElbow - u - o.elbow * Math.max(0, -l) : n.leftElbow, f = a(n.rightShoulder) ? n.rightElbow + u + o.elbow * Math.max(0, l) : n.rightElbow, p = o.bounces ?? 1, d = (1 + Math.cos(r * 2 * p)) / 2, m = o.crouch ?? 0;
435
+ }, $o = 40;
436
+ function En(e) {
437
+ return e === void 0 ? ye.walk : typeof e == "string" ? ye[e] ?? ye.walk : e;
438
+ }
439
+ function Bo(e, t, n = $, s = 1) {
440
+ const o = En(e);
441
+ if (o === ye.walk) return Lo(t, n, s);
442
+ const r = t * Math.PI * 2, l = Math.sin(r) * s, i = Math.cos(r) * s, a = (b) => b <= $o, h = o.shoulder ?? 0, c = (b, S) => a(b) ? S * h + o.arm * l : b, u = o.forearm ?? 0, g = a(n.leftShoulder) ? n.leftElbow - u - o.elbow * Math.max(0, -l) : n.leftElbow, f = a(n.rightShoulder) ? n.rightElbow + u + o.elbow * Math.max(0, l) : n.rightElbow, p = o.bounces ?? 1, d = (1 + Math.cos(r * 2 * p)) / 2, m = o.crouch ?? 0;
442
443
  return {
443
444
  ...n,
444
445
  lean: n.lean + o.lean * s + (o.sway ?? 0) * Math.sin(r) * (1 - (n.turn ?? 0)),
@@ -461,11 +462,11 @@ function Oo(e, t, n = _, s = 1) {
461
462
  stretch: n.stretch * (1 + (o.squash ?? 0) * (d - 0.5))
462
463
  };
463
464
  }
464
- function Io(e, t, n = 1) {
465
- const s = wn(e), o = we.walk.swing, r = (l) => Math.sin(l * Math.PI / 180);
466
- return Bo(t, n) * r(s.swing * n) / r(o * n);
465
+ function Fo(e, t, n = 1) {
466
+ const s = En(e), o = ye.walk.swing, r = (l) => Math.sin(l * Math.PI / 180);
467
+ return No(t, n) * r(s.swing * n) / r(o * n);
467
468
  }
468
- const _ = {
469
+ const $ = {
469
470
  lean: 0,
470
471
  bend: 0,
471
472
  headTilt: 0,
@@ -501,9 +502,9 @@ const _ = {
501
502
  rise: 0
502
503
  };
503
504
  function z(e) {
504
- return { ..._, ...e };
505
+ return { ...$, ...e };
505
506
  }
506
- const yn = {
507
+ const Mn = {
507
508
  mouth: 0,
508
509
  smile: 0,
509
510
  mouthWidth: 1,
@@ -514,60 +515,60 @@ const yn = {
514
515
  browTilt: 0,
515
516
  lookX: 0,
516
517
  lookY: 0
517
- }, N = (e) => ({ ...yn, ...e }), Y = {
518
- neutral: yn,
519
- happy: N({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
520
- joyful: N({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
521
- sad: N({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
522
- crying: N({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
523
- surprised: N({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
524
- shocked: N({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
525
- angry: N({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
526
- furious: N({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
527
- worried: N({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
528
- scared: N({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
529
- confused: N({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
530
- skeptical: N({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
531
- thinking: N({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
532
- sleepy: N({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
533
- disgusted: N({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
534
- smug: N({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
535
- wink: N({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
518
+ }, Y = (e) => ({ ...Mn, ...e }), C = {
519
+ neutral: Mn,
520
+ happy: Y({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
521
+ joyful: Y({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
522
+ sad: Y({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
523
+ crying: Y({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
524
+ surprised: Y({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
525
+ shocked: Y({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
526
+ angry: Y({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
527
+ furious: Y({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
528
+ worried: Y({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
529
+ scared: Y({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
530
+ confused: Y({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
531
+ skeptical: Y({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
532
+ thinking: Y({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
533
+ sleepy: Y({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
534
+ disgusted: Y({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
535
+ smug: Y({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
536
+ wink: Y({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
536
537
  };
537
- function qe(e, t) {
538
- return { ...e, ...typeof t == "string" ? Y[t] : t };
539
- }
540
- const Oe = {
541
- rest: _,
542
- wave: z({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...Y.happy }),
543
- cheer: z({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...Y.joyful }),
544
- shrug: z({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...Y.confused, lookX: 0, lookY: 0 }),
538
+ function xe(e, t) {
539
+ return { ...e, ...typeof t == "string" ? C[t] : t };
540
+ }
541
+ const Ie = {
542
+ rest: $,
543
+ wave: z({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...C.happy }),
544
+ cheer: z({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...C.joyful }),
545
+ shrug: z({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...C.confused, lookX: 0, lookY: 0 }),
545
546
  point: z({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
546
547
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
547
- think: z({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...Y.thinking }),
548
+ think: z({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...C.thinking }),
548
549
  handsOnHips: z({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
549
- sad: z({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...Y.sad }),
550
- surprised: z({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...Y.surprised }),
550
+ sad: z({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...C.sad }),
551
+ surprised: z({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...C.surprised }),
551
552
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
552
553
  crouch: z({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
553
554
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
554
555
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
555
556
  sit: z({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
556
- jump: z({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...Y.joyful }),
557
+ jump: z({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...C.joyful }),
557
558
  // Full splits: legs flat along the floor, so the planted feet bring the hips right down to it.
558
559
  // Side (straddle) split, seen front-on: each leg straight out to its side, toes pointed.
559
- sideSplit: z({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...Y.happy }),
560
+ sideSplit: z({ leftHip: 90, rightHip: 90, leftAnkle: -45, rightAnkle: -45, leftShoulder: 120, rightShoulder: 120, leftElbow: 10, rightElbow: 10, ...C.happy }),
560
561
  // Front split, in profile: the left leg forward (+x), the right leg back.
561
- frontSplit: z({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...Y.happy })
562
- }, kn = Object.keys(_);
563
- function Pe(e, t, n) {
562
+ frontSplit: z({ turn: 1, leftHip: -90, rightHip: -90, leftAnkle: -45, rightAnkle: -45, leftShoulder: -150, rightShoulder: 150, leftElbow: 10, rightElbow: -10, ...C.happy })
563
+ }, Hn = Object.keys($);
564
+ function We(e, t, n) {
564
565
  const s = { ...e };
565
- for (const o of kn) s[o] = e[o] + (t[o] - e[o]) * n;
566
+ for (const o of Hn) s[o] = e[o] + (t[o] - e[o]) * n;
566
567
  return s;
567
568
  }
568
- const mt = 24, Dt = 4, Xt = 28, _o = 40;
569
- function $o(e, t = _, n = 1) {
570
- const s = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, r = (h) => h <= _o, l = (h) => r(h) ? 22 * s : h, i = r(t.leftShoulder) ? t.leftElbow - Xt * Math.max(0, -s) : t.leftElbow, a = r(t.rightShoulder) ? t.rightElbow + Xt * Math.max(0, s) : t.rightElbow;
569
+ const mt = 24, Dt = 4, Xt = 28, Ro = 40;
570
+ function Lo(e, t = $, n = 1) {
571
+ const s = Math.sin(e * Math.PI * 2) * n, o = Math.cos(e * Math.PI * 2) * n, r = (h) => h <= Ro, l = (h) => r(h) ? 22 * s : h, i = r(t.leftShoulder) ? t.leftElbow - Xt * Math.max(0, -s) : t.leftElbow, a = r(t.rightShoulder) ? t.rightElbow + Xt * Math.max(0, s) : t.rightElbow;
571
572
  return {
572
573
  ...t,
573
574
  // Lean into the walk, and keep the head a little more level than the body.
@@ -587,42 +588,42 @@ function $o(e, t = _, n = 1) {
587
588
  rightShoulder: l(t.rightShoulder)
588
589
  };
589
590
  }
590
- function Bo(e, t = 1) {
591
+ function No(e, t = 1) {
591
592
  return 4 * ((bt + Ge) * e) * Math.sin(mt * t * Math.PI / 180);
592
593
  }
593
- function Fo(e) {
594
+ function Yo(e) {
594
595
  const t = Math.abs(Math.sin(e / 65)), n = 0.55 + 0.45 * Math.sin(e / 310);
595
596
  return t * n;
596
597
  }
597
- const Sn = 0.12, qt = 0.46, Ro = 1 - 2 * Sn, Lo = 0.1, No = 0.21, Yo = 0.19, bt = 0.24, Ge = 0.22, En = 0.12, Co = 0.14, Mn = 0.33, Gt = 0.7, Ut = 0.3, Do = 0.35, Xo = [1.7, 1.05], qo = [1.3, 0.75], zt = [1.45, 0.85], Go = [1.15, 0.75], Vt = 0.06, Uo = 0.7, zo = 0.65, Hn = 0.075, Vo = 0.3, jo = 0.02, Jo = 0.012, Zo = 12, Qo = 0.25, Ie = 90, es = 0.25, ts = 0.04, vn = 0.01, fe = (e) => Math.min(1, Math.max(0, e ?? 0));
598
- function gi(e, t = 1) {
598
+ const vn = 0.12, qt = 0.46, Co = 1 - 2 * vn, Do = 0.1, Xo = 0.21, qo = 0.19, bt = 0.24, Ge = 0.22, Tn = 0.12, Go = 0.14, An = 0.33, Gt = 0.7, Ut = 0.3, Uo = 0.35, zo = [1.7, 1.05], Vo = [1.3, 0.75], zt = [1.45, 0.85], jo = [1.15, 0.75], Vt = 0.06, Jo = 0.7, Zo = 0.65, xn = 0.075, Qo = 0.3, es = 0.02, ts = 0.012, ns = 12, os = 0.25, _e = 90, ss = 0.25, rs = 0.04, Pn = 0.01, fe = (e) => Math.min(1, Math.max(0, e ?? 0));
599
+ function wi(e, t = 1) {
599
600
  return Ge * e * t;
600
601
  }
601
- const wt = -0.12, Tn = 0.4, Q = (e) => e * Math.PI / 180, ns = (e, t) => ({ x: t * Math.sin(Q(e)), y: Math.cos(Q(e)) }), An = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), xn = (e, t, n, s) => e - 0.3 * t - n * 0.14 * t - Math.max(0, s - 1) * 0.12 * t;
602
- function os(e, t, n, s, o, r) {
603
- const l = Math.max(1, Math.min(r * 0.6, Co * n)), i = fe(t.turn), a = (En + Mn * i) * n, h = s + wt * n, c = a + t.lookX * 0.08 * n, u = t.lookY * 0.07 * n, g = [
602
+ const wt = -0.12, Kn = 0.4, Q = (e) => e * Math.PI / 180, is = (e, t) => ({ x: t * Math.sin(Q(e)), y: Math.cos(Q(e)) }), Wn = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), On = (e, t, n, s) => e - 0.3 * t - n * 0.14 * t - Math.max(0, s - 1) * 0.12 * t;
603
+ function ls(e, t, n, s, o, r) {
604
+ const l = Math.max(1, Math.min(r * 0.6, Go * n)), i = fe(t.turn), a = (Tn + An * i) * n, h = s + wt * n, c = a + t.lookX * 0.08 * n, u = t.lookY * 0.07 * n, g = [
604
605
  // The left eye is on the far side; turning closes it up more than the near one.
605
606
  { x: -0.34 * n * (1 - Gt * i), squeeze: 1 - Gt * i, open: t.leftEye, brow: t.leftBrow, side: -1 },
606
607
  { x: 0.34 * n * (1 - Ut * i), squeeze: 1 - Ut * i, open: t.rightEye, brow: t.rightBrow, side: 1 }
607
608
  ];
608
609
  e.fillStyle = o, e.strokeStyle = o, e.lineWidth = l;
609
610
  for (const b of g) {
610
- const y = An(b.open, t.blink);
611
- if (y < 0.2) {
612
- const A = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
613
- e.beginPath(), e.moveTo(b.x + a - 0.12 * n, h), e.quadraticCurveTo(b.x + a, h + A, b.x + a + 0.12 * n, h), e.stroke();
611
+ const S = Wn(b.open, t.blink);
612
+ if (S < 0.2) {
613
+ const T = t.smile > 0.5 ? -0.12 * n : 0.06 * n;
614
+ e.beginPath(), e.moveTo(b.x + a - 0.12 * n, h), e.quadraticCurveTo(b.x + a, h + T, b.x + a + 0.12 * n, h), e.stroke();
614
615
  } else {
615
- if (y > 1.2) {
616
- const w = 0.13 * n * y;
617
- e.beginPath(), e.ellipse(b.x + a, h, w * 0.85, w, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
616
+ if (S > 1.2) {
617
+ const M = 0.13 * n * S;
618
+ e.beginPath(), e.ellipse(b.x + a, h, M * 0.85, M, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = o;
618
619
  }
619
- const A = y > 1.2 ? 0.075 * n : 0.1 * n;
620
- e.beginPath(), e.ellipse(b.x + c, h + u, A, A * 1.1 * Math.min(y, 1), 0, 0, Math.PI * 2), e.fill();
620
+ const T = S > 1.2 ? 0.075 * n : 0.1 * n;
621
+ e.beginPath(), e.ellipse(b.x + c, h + u, T, T * 1.1 * Math.min(S, 1), 0, 0, Math.PI * 2), e.fill();
621
622
  }
622
- const E = xn(h, n, b.brow, y), H = b.x + a - b.side * 0.13 * n * b.squeeze, M = b.x + a + b.side * 0.13 * n * b.squeeze;
623
- e.beginPath(), e.moveTo(M, E), e.lineTo(H, E - t.browTilt * 0.1 * n), e.stroke();
623
+ const k = On(h, n, b.brow, S), v = b.x + a - b.side * 0.13 * n * b.squeeze, H = b.x + a + b.side * 0.13 * n * b.squeeze;
624
+ e.beginPath(), e.moveTo(H, k), e.lineTo(v, k - t.browTilt * 0.1 * n), e.stroke();
624
625
  }
625
- const f = s + Tn * n, p = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Do * i), d = Math.min(1, Math.max(0, t.mouth));
626
+ const f = s + Kn * n, p = 0.25 * n * Math.max(0.3, t.mouthWidth) * (1 - Uo * i), d = Math.min(1, Math.max(0, t.mouth));
626
627
  if (e.beginPath(), d <= 0.05) {
627
628
  e.moveTo(a - p, f), e.quadraticCurveTo(a, f + t.smile * 0.25 * n, a + p, f), e.stroke();
628
629
  return;
@@ -630,71 +631,71 @@ function os(e, t, n, s, o, r) {
630
631
  const m = 0.3 * n * d;
631
632
  t.smile > 0.3 ? (e.moveTo(a - p, f - 0.05 * n), e.lineTo(a + p, f - 0.05 * n), e.quadraticCurveTo(a, f + m * 2, a - p, f - 0.05 * n)) : t.smile < -0.3 ? (e.moveTo(a - p, f + m * 0.6), e.lineTo(a + p, f + m * 0.6), e.quadraticCurveTo(a, f - m * 1.4, a - p, f + m * 0.6)) : e.ellipse(a, f, p * 0.8, m, 0, 0, Math.PI * 2), e.fill();
632
633
  }
633
- function Kn(e, t) {
634
- const n = t.height ?? 300, s = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(s), r = (t.headSize ?? 2 * Sn) / 2, l = t.headSize === void 0 ? Ro : 1 - 2 * r, i = r * n, a = fe(e.sit), h = e.leftHip + (-Ie - e.leftHip) * a, c = e.leftKnee + (-Ie - e.leftKnee) * a, u = e.rightHip + (Ie - e.rightHip) * a, g = e.rightKnee + (Ie - e.rightKnee) * a, f = t.classic === !0, p = fe(e.turn), d = (W, O, F, $, B) => {
635
- const U = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Q(O - F) / 2) + Q($))), ne = Math.max(-1, Math.min(1, Uo + B)), et = p + (1 - p) * W * ne;
634
+ function In(e, t) {
635
+ const n = t.height ?? 300, s = Math.min(3, Math.max(0.3, e.stretch ?? 1)), o = Math.sqrt(s), r = (t.headSize ?? 2 * vn) / 2, l = t.headSize === void 0 ? Co : 1 - 2 * r, i = r * n, a = fe(e.sit), h = e.leftHip + (-_e - e.leftHip) * a, c = e.leftKnee + (-_e - e.leftKnee) * a, u = e.rightHip + (_e - e.rightHip) * a, g = e.rightKnee + (_e - e.rightKnee) * a, f = t.classic === !0, p = fe(e.turn), d = (W, O, R, B, F) => {
636
+ const U = Math.max(-Math.PI / 2, Math.min(Math.PI / 2, Math.abs(Q(O - R) / 2) + Q(B))), ne = Math.max(-1, Math.min(1, Jo + F)), et = p + (1 - p) * W * ne;
636
637
  return f ? { x: 0, y: 0 } : { x: Math.cos(U) * Vt * et, y: Math.sin(U) * Vt };
637
638
  }, m = { left: e.leftAnkle ?? 0, right: e.rightAnkle ?? 0 }, b = { left: e.leftFootOut ?? 0, right: e.rightFootOut ?? 0 };
638
- let y = 0;
639
+ let S = 0;
639
640
  if (a > 0 || !f) {
640
- const W = (B, U, ne, et, eo) => bt * Math.cos(Q(U)) + Ge * Math.cos(Q(U - ne)) + Math.max(0, d(B, U, ne, et, eo).y), O = Math.max(
641
+ const W = (F, U, ne, et, so) => bt * Math.cos(Q(U)) + Ge * Math.cos(Q(U - ne)) + Math.max(0, d(F, U, ne, et, so).y), O = Math.max(
641
642
  W(-1, h, c, m.left, b.left),
642
643
  W(1, u, g, m.right, b.right)
643
- ), F = 1 - fe((e.rise ?? 0) / ts), $ = (f ? Math.min(1, a / es) : 1) * F;
644
- y = (qt - O) * $ * n * s;
644
+ ), R = 1 - fe((e.rise ?? 0) / rs), B = (f ? Math.min(1, a / ss) : 1) * R;
645
+ S = (qt - O) * B * n * s;
645
646
  }
646
- const E = -qt * n * s + y, H = -l * n * s + y, M = f ? 0 : (jo * fe(e.turn) + Jo * a) * n * s, A = Q(e.bend ?? 0), w = { end: Jt(E, H, A, 1), bend: A };
647
- let S;
648
- if (A !== 0) {
649
- S = [];
647
+ const k = -qt * n * s + S, v = -l * n * s + S, H = f ? 0 : (es * fe(e.turn) + ts * a) * n * s, T = Q(e.bend ?? 0), M = { end: Jt(k, v, T, 1), bend: T };
648
+ let w;
649
+ if (T !== 0) {
650
+ w = [];
650
651
  for (let W = 0; W <= jt; W++) {
651
- const O = W / jt, F = Jt(E, H, A, O);
652
- S.push({ x: F.x - M * Math.sin(Math.PI * O), y: F.y });
652
+ const O = W / jt, R = Jt(k, v, T, O);
653
+ w.push({ x: R.x - H * Math.sin(Math.PI * O), y: R.y });
653
654
  }
654
655
  } else
655
- S = M === 0 ? [{ x: 0, y: E }, { x: 0, y: H }] : ke({ x: 0, y: E }, { x: -M, y: (E + H) / 2 }, { x: 0, y: H }, 1, 8);
656
- const k = H + Lo * n * s, x = (t.shoulderWidth ?? 0) * n * Math.cos(p * Math.PI / 2), v = (W, O, F, $, B) => {
657
- const U = ns(F, $);
658
- return { x: W + U.x * B * n, y: O + U.y * B * n };
659
- }, T = (W, O, F) => {
660
- const $ = v(0, E, O, W, bt * s);
661
- return { root: { x: 0, y: E }, joint: $, end: v($.x, $.y, O - F, W, Ge * s) };
662
- }, K = (W, O, F) => {
663
- const $ = { x: W * x, y: k }, B = v($.x, $.y, O, W, No * o);
664
- return { root: $, joint: B, end: v(B.x, B.y, O + F, W, Yo * o) };
665
- }, P = { left: T(-1, h, c), right: T(1, u, g) }, I = (W, O, F, $, B, U) => {
666
- const ne = d(W, F, $, B, U);
656
+ w = H === 0 ? [{ x: 0, y: k }, { x: 0, y: v }] : Se({ x: 0, y: k }, { x: -H, y: (k + v) / 2 }, { x: 0, y: v }, 1, 8);
657
+ const y = v + Do * n * s, A = (t.shoulderWidth ?? 0) * n * Math.cos(p * Math.PI / 2), x = (W, O, R, B, F) => {
658
+ const U = is(R, B);
659
+ return { x: W + U.x * F * n, y: O + U.y * F * n };
660
+ }, E = (W, O, R) => {
661
+ const B = x(0, k, O, W, bt * s);
662
+ return { root: { x: 0, y: k }, joint: B, end: x(B.x, B.y, O - R, W, Ge * s) };
663
+ }, P = (W, O, R) => {
664
+ const B = { x: W * A, y }, F = x(B.x, B.y, O, W, Xo * o);
665
+ return { root: B, joint: F, end: x(F.x, F.y, O + R, W, qo * o) };
666
+ }, K = { left: E(-1, h, c), right: E(1, u, g) }, I = (W, O, R, B, F, U) => {
667
+ const ne = d(W, R, B, F, U);
667
668
  return { x: O.end.x + ne.x * n * s, y: O.end.y + ne.y * n * s };
668
- }, q = (W, O, F, $, B) => v(O.end.x, O.end.y, F + $ + B, W, Hn * o), G = {
669
- left: K(-1, e.leftShoulder, e.leftElbow),
670
- right: K(1, e.rightShoulder, e.rightElbow)
669
+ }, _ = (W, O, R, B, F) => x(O.end.x, O.end.y, R + B + F, W, xn * o), X = {
670
+ left: P(-1, e.leftShoulder, e.leftElbow),
671
+ right: P(1, e.rightShoulder, e.rightElbow)
671
672
  };
672
673
  return {
673
674
  height: n,
674
675
  facing: (t.facing ?? 1) < 0 ? -1 : 1,
675
676
  stretch: s,
676
677
  lineWidth: t.lineWidth ?? n * 0.025,
677
- rubber: Math.min(1, Math.max(f ? 0 : Vo, t.rubber ?? 0)),
678
+ rubber: Math.min(1, Math.max(f ? 0 : Qo, t.rubber ?? 0)),
678
679
  r: i,
679
680
  // The head keeps its area: taller and narrower when stretched.
680
681
  headRx: i / Math.sqrt(s),
681
682
  headRy: i * Math.sqrt(s),
682
- hipY: E,
683
- neckY: H,
684
- drop: y,
685
- lean: f ? e.lean : e.lean + Zo * Math.sin(Math.PI * a),
683
+ hipY: k,
684
+ neckY: v,
685
+ drop: S,
686
+ lean: f ? e.lean : e.lean + ns * Math.sin(Math.PI * a),
686
687
  classic: f,
687
- legs: P,
688
+ legs: K,
688
689
  toes: {
689
- left: I(-1, P.left, h, c, m.left, b.left),
690
- right: I(1, P.right, u, g, m.right, b.right)
690
+ left: I(-1, K.left, h, c, m.left, b.left),
691
+ right: I(1, K.right, u, g, m.right, b.right)
691
692
  },
692
- spine: S,
693
- chest: w,
694
- arms: G,
693
+ spine: w,
694
+ chest: M,
695
+ arms: X,
695
696
  handTips: {
696
- left: q(-1, G.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
697
- right: q(1, G.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
697
+ left: _(-1, X.left, e.leftShoulder, e.leftElbow, e.leftWrist ?? 0),
698
+ right: _(1, X.right, e.rightShoulder, e.rightElbow, e.rightWrist ?? 0)
698
699
  }
699
700
  };
700
701
  }
@@ -705,28 +706,28 @@ function Jt(e, t, n, s) {
705
706
  const l = o / n;
706
707
  return { x: l * (1 - Math.cos(r)), y: e - l * Math.sin(r) };
707
708
  }
708
- function ss(e, t) {
709
+ function as(e, t) {
709
710
  if (e.chest.bend === 0) return t;
710
- const n = We(t, { x: 0, y: e.neckY }, e.chest.bend);
711
+ const n = Oe(t, { x: 0, y: e.neckY }, e.chest.bend);
711
712
  return { x: n.x + e.chest.end.x, y: n.y + e.chest.end.y - e.neckY };
712
713
  }
713
- const ve = (e, t) => t === 0 ? [e.root, e.joint, e.end] : ke(e.root, e.joint, e.end, t);
714
- function We(e, t, n) {
714
+ const ve = (e, t) => t === 0 ? [e.root, e.joint, e.end] : Se(e.root, e.joint, e.end, t);
715
+ function Oe(e, t, n) {
715
716
  const s = Math.cos(n), o = Math.sin(n), r = e.x - t.x, l = e.y - t.y;
716
717
  return { x: t.x + r * s - l * o, y: t.y + r * o + l * s };
717
718
  }
718
- function Pn(e, t, n = !0) {
719
- const s = is(e, t), o = t.spin ?? 0, r = t.rise ?? 0;
720
- return n && (o !== 0 || r !== 0) ? rs(s, e, o, r) : s;
719
+ function _n(e, t, n = !0) {
720
+ const s = cs(e, t), o = t.spin ?? 0, r = t.rise ?? 0;
721
+ return n && (o !== 0 || r !== 0) ? hs(s, e, o, r) : s;
721
722
  }
722
- function Wn(e, t, n) {
723
+ function $n(e, t, n) {
723
724
  return { pivot: { x: 0, y: e.hipY }, angle: e.facing * Q(t), lift: n * e.height };
724
725
  }
725
- function rs(e, t, n, s) {
726
- const { pivot: o, angle: r, lift: l } = Wn(t, n, s), i = (g) => {
727
- const f = We(g, o, r);
726
+ function hs(e, t, n, s) {
727
+ const { pivot: o, angle: r, lift: l } = $n(t, n, s), i = (g) => {
728
+ const f = Oe(g, o, r);
728
729
  return { x: f.x, y: f.y - l };
729
- }, a = (g) => ({ left: i(g.left), right: i(g.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), u = vn * t.height;
730
+ }, a = (g) => ({ left: i(g.left), right: i(g.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), u = Pn * t.height;
730
731
  return {
731
732
  ...e,
732
733
  hip: i(e.hip),
@@ -751,20 +752,20 @@ function rs(e, t, n, s) {
751
752
  head: { ...e.head, center: i(e.head.center), angle: e.head.angle + r }
752
753
  };
753
754
  }
754
- function is(e, t) {
755
- const n = Q(e.lean), s = Q(t.headTilt), o = { x: 0, y: e.hipY }, r = (H) => ({ x: e.facing * H.x, y: H.y }), l = (H) => r(We(H, o, n)), i = (H) => l(ss(e, H)), a = (H) => i(We({ x: H.x, y: H.y + e.neckY }, { x: 0, y: e.neckY }, s)), h = ve(e.arms.left, e.rubber).map(i), c = ve(e.arms.right, e.rubber).map(i), u = (H, M) => Math.atan2(M.y - H.y, M.x - H.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, f = (H, M) => {
756
- const [A, w] = H.slice(-2), S = e.arms[M], k = u(i(S.end), g[M]) - u(i(S.joint), i(S.end));
757
- return u(A, w) + k;
755
+ function cs(e, t) {
756
+ const n = Q(e.lean), s = Q(t.headTilt), o = { x: 0, y: e.hipY }, r = (v) => ({ x: e.facing * v.x, y: v.y }), l = (v) => r(Oe(v, o, n)), i = (v) => l(as(e, v)), a = (v) => i(Oe({ x: v.x, y: v.y + e.neckY }, { x: 0, y: e.neckY }, s)), h = ve(e.arms.left, e.rubber).map(i), c = ve(e.arms.right, e.rubber).map(i), u = (v, H) => Math.atan2(H.y - v.y, H.x - v.x), g = { left: i(e.handTips.left), right: i(e.handTips.right) }, f = (v, H) => {
757
+ const [T, M] = v.slice(-2), w = e.arms[H], y = u(i(w.end), g[H]) - u(i(w.joint), i(w.end));
758
+ return u(T, M) + y;
758
759
  };
759
760
  let p = 1 / 0;
760
- for (const [H, M] of [
761
+ for (const [v, H] of [
761
762
  [t.leftBrow, t.leftEye],
762
763
  [t.rightBrow, t.rightEye]
763
764
  ]) {
764
- const A = xn(wt, 1, H, An(M, t.blink));
765
- p = Math.min(p, A, A - t.browTilt * 0.1);
765
+ const T = On(wt, 1, v, Wn(H, t.blink));
766
+ p = Math.min(p, T, T - t.browTilt * 0.1);
766
767
  }
767
- const d = { left: r(e.legs.left.end), right: r(e.legs.right.end) }, m = { left: r(e.toes.left), right: r(e.toes.right) }, b = { left: Math.max(d.left.y, m.left.y), right: Math.max(d.right.y, m.right.y) }, y = Math.max(b.left, b.right), E = vn * e.height;
768
+ const d = { left: r(e.legs.left.end), right: r(e.legs.right.end) }, m = { left: r(e.toes.left), right: r(e.toes.right) }, b = { left: Math.max(d.left.y, m.left.y), right: Math.max(d.right.y, m.right.y) }, S = Math.max(b.left, b.right), k = Pn * e.height;
768
769
  return {
769
770
  facing: e.facing,
770
771
  height: e.height,
@@ -778,8 +779,8 @@ function is(e, t) {
778
779
  knees: { left: r(e.legs.left.joint), right: r(e.legs.right.joint) },
779
780
  feet: d,
780
781
  toes: m,
781
- feetY: y,
782
- grounded: { left: b.left >= y - E, right: b.right >= y - E },
782
+ feetY: S,
783
+ grounded: { left: b.left >= S - k, right: b.right >= S - k },
783
784
  fingertips: g,
784
785
  handAngle: { left: f(h, "left"), right: f(c, "right") },
785
786
  limbs: {
@@ -797,18 +798,18 @@ function is(e, t) {
797
798
  angle: e.facing * (n + e.chest.bend + s),
798
799
  eyeY: wt,
799
800
  browTopY: p,
800
- mouthY: Tn,
801
- faceX: e.facing * (En + Mn * fe(t.turn))
801
+ mouthY: Kn,
802
+ faceX: e.facing * (Tn + An * fe(t.turn))
802
803
  }
803
804
  };
804
805
  }
805
- function ls(e, t = {}) {
806
- return Pn(Kn(e, t), e);
806
+ function fs(e, t = {}) {
807
+ return _n(In(e, t), e);
807
808
  }
808
- function pi(e, t, n) {
809
- return We({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
809
+ function yi(e, t, n) {
810
+ return Oe({ x: e.center.x + t * e.rx, y: e.center.y + n * e.ry }, e.center, e.angle);
810
811
  }
811
- function as(e, t, n) {
812
+ function us(e, t, n) {
812
813
  const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => ({ left: s(r.left), right: s(r.right) });
813
814
  return {
814
815
  ...e,
@@ -833,118 +834,118 @@ function as(e, t, n) {
833
834
  head: { ...e.head, center: s(e.head.center) }
834
835
  };
835
836
  }
836
- function hs(e, t, n = {}, s = 0) {
837
- const o = Kn(t, n), r = n.color ?? "#1e293b", l = n.layers ?? {}, i = n.layers ? Pn(o, t, !1) : void 0, a = n.sketch ? ut(e, n.sketch, s) : void 0, h = n.sketch && n.layers ? ut(e, n.sketch, s) : void 0, c = (w) => {
838
- e.save(), w(), e.restore();
839
- }, u = (w) => {
840
- w && i && c(() => w(e, i, s, h));
837
+ function ds(e, t, n = {}, s = 0) {
838
+ const o = In(t, n), r = n.color ?? "#1e293b", l = n.layers ?? {}, i = n.layers ? _n(o, t, !1) : void 0, a = n.sketch ? ut(e, n.sketch, s) : void 0, h = n.sketch && n.layers ? ut(e, n.sketch, s) : void 0, c = (M) => {
839
+ e.save(), M(), e.restore();
840
+ }, u = (M) => {
841
+ M && i && c(() => M(e, i, s, h));
841
842
  }, g = () => e.scale(o.facing, 1), f = () => {
842
843
  g(), e.translate(0, o.hipY), e.rotate(Q(o.lean)), e.translate(0, -o.hipY);
843
844
  }, p = () => {
844
845
  f(), o.chest.bend !== 0 && (e.translate(o.chest.end.x, o.chest.end.y), e.rotate(o.chest.bend), e.translate(0, -o.neckY));
845
- }, d = (w, S, k) => {
846
- if (a) return S ? a.curve(w) : a.line(w);
846
+ }, d = (M, w, y) => {
847
+ if (a) return w ? a.curve(M) : a.line(M);
847
848
  if (o.classic) {
848
- e.beginPath(), e.moveTo(w[0].x, w[0].y);
849
- for (const x of w.slice(1)) e.lineTo(x.x, x.y);
849
+ e.beginPath(), e.moveTo(M[0].x, M[0].y);
850
+ for (const A of M.slice(1)) e.lineTo(A.x, A.y);
850
851
  e.stroke();
851
852
  return;
852
853
  }
853
- vt(e, w, k[0] * o.lineWidth, k[1] * o.lineWidth);
854
- }, m = (w, S) => d(ve(w, o.rubber), o.rubber > 0, S), b = (w) => {
855
- o.classic || d([o.legs[w].end, o.toes[w]], !1, Go);
856
- }, y = (w) => {
857
- if (n.hands && !o.classic) return H(w);
854
+ vt(e, M, y[0] * o.lineWidth, y[1] * o.lineWidth);
855
+ }, m = (M, w) => d(ve(M, o.rubber), o.rubber > 0, w), b = (M) => {
856
+ o.classic || d([o.legs[M].end, o.toes[M]], !1, jo);
857
+ }, S = (M) => {
858
+ if (n.hands && !o.classic) return v(M);
858
859
  if (o.classic || a) return;
859
- const S = o.arms[w].end;
860
- e.beginPath(), e.arc(S.x, S.y, zo * o.lineWidth, 0, Math.PI * 2), e.fill();
860
+ const w = o.arms[M].end;
861
+ e.beginPath(), e.arc(w.x, w.y, Zo * o.lineWidth, 0, Math.PI * 2), e.fill();
861
862
  };
862
863
  e.save(), e.strokeStyle = r, e.fillStyle = r, e.lineWidth = o.lineWidth, e.lineCap = "round", e.lineJoin = "round";
863
- const E = Wn(o, t.spin ?? 0, t.rise ?? 0);
864
- (E.angle !== 0 || E.lift !== 0) && (e.translate(0, -E.lift), e.translate(E.pivot.x, E.pivot.y), e.rotate(E.angle), e.translate(-E.pivot.x, -E.pivot.y));
865
- function H(w) {
866
- const S = n.hands ?? {}, k = o.arms[w].end, x = o.handTips[w], v = n.headFill ?? "#ffffff";
867
- Tt(e, k, S[w] ?? L, {
868
- side: w,
864
+ const k = $n(o, t.spin ?? 0, t.rise ?? 0);
865
+ (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));
866
+ function v(M) {
867
+ const w = n.hands ?? {}, y = o.arms[M].end, A = o.handTips[M], x = n.headFill ?? "#ffffff";
868
+ Tt(e, y, w[M] ?? N, {
869
+ side: M,
869
870
  // Degrees clockwise from straight up, in the frame the hand is drawn in.
870
- angle: Math.atan2(x.x - k.x, k.y - x.y) * 180 / Math.PI,
871
- size: (S.size ?? Hn) * o.height * Math.sqrt(o.stretch),
872
- skin: S.skin ?? (v === "none" ? void 0 : v),
871
+ angle: Math.atan2(A.x - y.x, y.y - A.y) * 180 / Math.PI,
872
+ size: (w.size ?? xn) * o.height * Math.sqrt(o.stretch),
873
+ skin: w.skin ?? (x === "none" ? void 0 : x),
873
874
  ink: r,
874
875
  lineWidth: o.lineWidth * 0.45,
875
- fingers: S.fingers,
876
- plump: S.plump,
876
+ fingers: w.fingers,
877
+ plump: w.plump,
877
878
  look: n.sketch ? "pencil" : "clean",
878
879
  seed: n.sketch?.seed
879
880
  }, s);
880
881
  }
881
- const M = (w) => {
882
+ const H = (M) => {
882
883
  c(() => {
883
- p(), m(o.arms[w], qo), y(w);
884
+ p(), m(o.arms[M], Vo), S(M);
884
885
  });
885
- const S = l.sleeve;
886
- S && i && c(() => S(e, i, w, s, h));
887
- }, A = fe(t.turn) > Qo;
886
+ const w = l.sleeve;
887
+ w && i && c(() => w(e, i, M, s, h));
888
+ }, T = fe(t.turn) > os;
888
889
  u(l.behind), c(() => {
889
890
  g(), m(o.legs.left, zt), b("left"), m(o.legs.right, zt), b("right");
890
- }), A && M("left"), c(() => {
891
- f(), d(o.spine, o.spine.length > 2, Xo);
891
+ }), T && H("left"), c(() => {
892
+ f(), d(o.spine, o.spine.length > 2, zo);
892
893
  }), c(() => {
893
894
  p();
894
- const { left: w, right: S } = { left: o.arms.left.root, right: o.arms.right.root };
895
- if (w.x !== S.x)
896
- if (o.classic) d([w, S], !1, [1, 1]);
895
+ const { left: M, right: w } = { left: o.arms.left.root, right: o.arms.right.root };
896
+ if (M.x !== w.x)
897
+ if (o.classic) d([M, w], !1, [1, 1]);
897
898
  else {
898
- const k = { x: (w.x + S.x) / 2, y: w.y - 0.3 * Math.abs(S.x - w.x) };
899
- d(ke(w, k, S, 1, 8), !0, [1.1, 1.1]);
899
+ const y = { x: (M.x + w.x) / 2, y: M.y - 0.3 * Math.abs(w.x - M.x) };
900
+ d(Se(M, y, w, 1, 8), !0, [1.1, 1.1]);
900
901
  }
901
- }), u(l.body), A || M("left"), M("right"), u(l.behindHead), c(() => {
902
+ }), u(l.body), T || H("left"), H("right"), u(l.behindHead), c(() => {
902
903
  p(), e.translate(0, o.neckY), e.rotate(Q(t.headTilt));
903
- const w = -o.headRy;
904
- e.beginPath(), e.ellipse(0, w, o.headRx, o.headRy, 0, 0, Math.PI * 2);
905
- const S = n.headFill ?? "#ffffff";
906
- if (S !== "none" && (e.fillStyle = S, e.fill()), a) {
907
- a.ellipse(0, w, o.headRx, o.headRy);
908
- const k = a.nudge();
909
- e.translate(k.x, k.y);
904
+ const M = -o.headRy;
905
+ e.beginPath(), e.ellipse(0, M, o.headRx, o.headRy, 0, 0, Math.PI * 2);
906
+ const w = n.headFill ?? "#ffffff";
907
+ if (w !== "none" && (e.fillStyle = w, e.fill()), a) {
908
+ a.ellipse(0, M, o.headRx, o.headRy);
909
+ const y = a.nudge();
910
+ e.translate(y.x, y.y);
910
911
  } else
911
912
  e.stroke();
912
- e.translate(0, w), e.scale(o.headRx / o.r, o.headRy / o.r), os(e, t, o.r, 0, r, o.lineWidth);
913
+ e.translate(0, M), e.scale(o.headRx / o.r, o.headRy / o.r), ls(e, t, o.r, 0, r, o.lineWidth);
913
914
  }), u(l.overHead), u(l.front), e.restore(), n.label && (e.save(), e.fillStyle = r, 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());
914
915
  }
915
- function On(e, t, n) {
916
+ function Bn(e, t, n) {
916
917
  const s = { ...e };
917
- let o = e.walking > 0 ? Pe(s, Oo(e.gait, e.walk, s), e.walking) : s, r = fs(e);
918
+ let o = e.walking > 0 ? We(s, Bo(e.gait, e.walk, s), e.walking) : s, r = ps(e);
918
919
  const l = e.dancing ?? 0;
919
920
  if (n && l > 0) {
920
921
  const i = n(e.beat ?? 0);
921
- if (o = Pe(o, i.pose, l), i.hands) {
922
- const a = (h, c) => c ? Ke(h ?? L, c, l) : h;
922
+ if (o = We(o, i.pose, l), i.hands) {
923
+ const a = (h, c) => c ? Ke(h ?? N, c, l) : h;
923
924
  r = { left: a(r?.left, i.hands.left), right: a(r?.right, i.hands.right) };
924
925
  }
925
926
  }
926
- return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Fo(t)) }), { pose: o, hands: r };
927
+ return e.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, e.talk * Yo(t)) }), { pose: o, hands: r };
927
928
  }
928
- function cs(e, t, n) {
929
- return On(e, t, n).pose;
929
+ function gs(e, t, n) {
930
+ return Bn(e, t, n).pose;
930
931
  }
931
- const In = (e, t) => (e.facing ?? t.facing ?? 1) < 0 ? -1 : 1, Ue = (e, t) => `hand.${e}.${t}`;
932
- function fs(e) {
932
+ const Fn = (e, t) => (e.facing ?? t.facing ?? 1) < 0 ? -1 : 1, Ue = (e, t) => `hand.${e}.${t}`;
933
+ function ps(e) {
933
934
  const t = (o) => {
934
935
  if (typeof e[Ue(o, "spread")] == "number")
935
- return Object.fromEntries(Object.keys(L).map((r) => [r, e[Ue(o, r)]]));
936
+ return Object.fromEntries(Object.keys(N).map((r) => [r, e[Ue(o, r)]]));
936
937
  }, n = t("left"), s = t("right");
937
938
  return n || s ? { left: n, right: s } : void 0;
938
939
  }
939
- function us(e, t) {
940
+ function ms(e, t) {
940
941
  return !t || !e.hands ? e : { ...e, hands: { ...e.hands, left: t.left ?? e.hands.left, right: t.right ?? e.hands.right } };
941
942
  }
942
- function mi(e) {
943
+ function ki(e) {
943
944
  const t = e.style ?? {}, n = t.height ?? 300, s = n * 0.8, o = { ...z(e.pose ?? {}), walk: 0, walking: 0, gait: "walk", facing: (t.facing ?? 1) < 0 ? -1 : 1, talk: 0, rubber: t.rubber ?? 0, beat: 0, dancing: 0 }, r = {};
944
945
  if (t.hands)
945
946
  for (const l of ["left", "right"]) {
946
- const i = t.hands[l] ?? L;
947
- for (const a of Object.keys(L)) r[Ue(l, a)] = i[a] ?? L[a];
947
+ const i = t.hands[l] ?? N;
948
+ for (const a of Object.keys(N)) r[Ue(l, a)] = i[a] ?? N[a];
948
949
  }
949
950
  return {
950
951
  type: "custom",
@@ -956,31 +957,31 @@ function mi(e) {
956
957
  figureStyle: t,
957
958
  figureDance: e.dance,
958
959
  draw(l, i, a) {
959
- const h = i.props, c = On(h, a, e.dance);
960
- l.translate(s / 2, n), hs(l, c.pose, us({ ...t, rubber: h.rubber, facing: In(h, t) }, c.hands), a);
960
+ const h = i.props, c = Bn(h, a, e.dance);
961
+ l.translate(s / 2, n), ds(l, c.pose, ms({ ...t, rubber: h.rubber, facing: Fn(h, t) }, c.hands), a);
961
962
  }
962
963
  };
963
964
  }
964
- function ds(e, t, n) {
965
+ function bs(e, t, n) {
965
966
  const s = e.figureStyle;
966
967
  if (!s) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
967
968
  const o = { ...e.props };
968
969
  let r = 0, l = 0;
969
970
  for (const [h, c] of t.state?.values.get(n) ?? [])
970
971
  h === "gait" && typeof c == "string" && (o.gait = c), typeof c == "number" && (h === "x" || h === "motionPathX" ? r = c : h === "y" || h === "motionPathY" ? l = c : h in o && (o[h] = c));
971
- const i = cs(o, t.time, e.figureDance), a = ls(i, { ...s, rubber: o.rubber, facing: In(o, s) });
972
- return { pose: i, joints: as(a, e.x + r + e.width / 2, e.y + l + e.height) };
972
+ const i = gs(o, t.time, e.figureDance), a = fs(i, { ...s, rubber: o.rubber, facing: Fn(o, s) });
973
+ return { pose: i, joints: us(a, e.x + r + e.width / 2, e.y + l + e.height) };
973
974
  }
974
- function _n(e) {
975
+ function Rn(e) {
975
976
  const t = [];
976
977
  return e.forEach((n, s) => {
977
- const o = s === 0 ? _ : t[s - 1], r = typeof n.pose == "string" ? Oe[n.pose] : { ...o, ...n.pose };
978
- t.push(n.expression ? qe(r, n.expression) : r);
978
+ const o = s === 0 ? $ : t[s - 1], r = typeof n.pose == "string" ? Ie[n.pose] : { ...o, ...n.pose };
979
+ t.push(n.expression ? xe(r, n.expression) : r);
979
980
  }), t;
980
981
  }
981
- function bi(e, t) {
982
- const n = _n(t);
983
- return kn.filter((s) => n.some((o) => o[s] !== _[s])).map((s) => ({
982
+ function Si(e, t) {
983
+ const n = Rn(t);
984
+ return Hn.filter((s) => n.some((o) => o[s] !== $[s])).map((s) => ({
984
985
  id: `${e}-${s}`,
985
986
  target: e,
986
987
  property: s,
@@ -993,24 +994,24 @@ function bi(e, t) {
993
994
  }
994
995
  const tt = 0.5, Zt = {
995
996
  /** Flag: fingers together and straight, thumb bent in */
996
- pataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
997
+ pataka: L({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 0, "pinky.curl": 0, spread: 0, turn: 2 }),
997
998
  /** Pataka with the ring finger bent */
998
- tripataka: R({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
999
+ tripataka: L({ "thumb.curl": 0.3, "thumb.across": 0.6, "index.curl": 0, "middle.curl": 0, "ring.curl": 1, "pinky.curl": 0, spread: 0, turn: 2 }),
999
1000
  /** Lotus in bloom: fingers fanned, each a little more curled than the last */
1000
- alapadma: R({ "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 }),
1001
+ alapadma: L({ "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 }),
1001
1002
  /** Fist */
1002
- mushti: C.fist,
1003
+ mushti: D.fist,
1003
1004
  /** Fist, thumb up */
1004
- shikhara: C.thumbsUp,
1005
+ shikhara: D.thumbsUp,
1005
1006
  /** Swan's beak: thumb and index touch, the others fanned */
1006
- hamsasya: R({ "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 }),
1007
+ hamsasya: L({ "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 }),
1007
1008
  /** Bracelet: thumb, index and middle meet, ring and little finger out */
1008
- katakamukha: R({ "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 })
1009
+ katakamukha: L({ "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 })
1009
1010
  };
1010
1011
  function ze(e) {
1011
- return typeof e != "string" ? e : e in Zt ? Zt[e] : C[e];
1012
+ return typeof e != "string" ? e : e in Zt ? Zt[e] : D[e];
1012
1013
  }
1013
- function $n(e, t, n) {
1014
+ function Ln(e, t, n) {
1014
1015
  const s = [];
1015
1016
  for (const o of e.keys) {
1016
1017
  const r = s[s.length - 1], l = !r || o.reset ? { pose: t, ...n } : r;
@@ -1025,19 +1026,19 @@ function $n(e, t, n) {
1025
1026
  return s;
1026
1027
  }
1027
1028
  const At = (e, t) => (e % t + t) % t;
1028
- function gs(e, t, n, s) {
1029
- const o = $n(e, n, s);
1029
+ function ws(e, t, n, s) {
1030
+ const o = Ln(e, n, s);
1030
1031
  if (o.length === 0) return { pose: n, hands: s };
1031
1032
  const r = At(t, e.beats);
1032
1033
  let l = o.length - 1;
1033
1034
  for (let f = 0; f < o.length; f++) o[f].beat <= r && (l = f);
1034
1035
  const i = o[l], a = o[(l + 1) % o.length], h = i.beat <= r ? i.beat : i.beat - e.beats, c = a.beat > h ? a.beat : a.beat + e.beats, u = c > h ? (r - h) / (c - h) : 0, g = Qe(a.easing ?? "ease-in-out")(Math.min(1, Math.max(0, u)));
1035
1036
  return {
1036
- pose: Pe(i.pose, a.pose, g),
1037
+ pose: We(i.pose, a.pose, g),
1037
1038
  hands: { left: Ke(i.left, a.left, g), right: Ke(i.right, a.right, g) }
1038
1039
  };
1039
1040
  }
1040
- const ps = [
1041
+ const ys = [
1041
1042
  ["leftShoulder", "rightShoulder"],
1042
1043
  ["leftElbow", "rightElbow"],
1043
1044
  ["leftWrist", "rightWrist"],
@@ -1047,19 +1048,19 @@ const ps = [
1047
1048
  ["leftFootOut", "rightFootOut"],
1048
1049
  ["leftEye", "rightEye"],
1049
1050
  ["leftBrow", "rightBrow"]
1050
- ], ms = ["lean", "headTilt", "lookX", "spin"], bs = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
1051
- function ws(e) {
1051
+ ], ks = ["lean", "headTilt", "lookX", "spin"], Ss = /* @__PURE__ */ new Set(["leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee"]);
1052
+ function Es(e) {
1052
1053
  const t = { ...e }, n = (e.turn ?? 0) >= 0.5;
1053
- for (const [s, o] of ps) {
1054
- const r = n && bs.has(s) ? -1 : 1;
1054
+ for (const [s, o] of ys) {
1055
+ const r = n && Ss.has(s) ? -1 : 1;
1055
1056
  t[s] = r * e[o], t[o] = r * e[s];
1056
1057
  }
1057
- if (!n) for (const s of ms) t[s] = -e[s];
1058
+ if (!n) for (const s of ks) t[s] = -e[s];
1058
1059
  return t;
1059
1060
  }
1060
- const ys = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
1061
- function ks(e, t, n) {
1062
- const s = At(n, 1), o = (1 + Math.cos(2 * Math.PI * s)) / 2, r = t.bounce * (t.accent === "up" ? 1 - o : o), l = Math.min(1, Math.max(0, e.turn ?? 0)), i = ys(l);
1061
+ const Ms = (e) => Math.min(1, Math.max(-1, (0.5 - e) * 4));
1062
+ function Hs(e, t, n) {
1063
+ const s = At(n, 1), o = (1 + Math.cos(2 * Math.PI * s)) / 2, r = t.bounce * (t.accent === "up" ? 1 - o : o), l = Math.min(1, Math.max(0, e.turn ?? 0)), i = Ms(l);
1063
1064
  return {
1064
1065
  ...e,
1065
1066
  leftHip: e.leftHip + i * r / 2,
@@ -1070,23 +1071,23 @@ function ks(e, t, n) {
1070
1071
  };
1071
1072
  }
1072
1073
  function yt(e) {
1073
- const t = { ..._, ...e.stance };
1074
- return e.expression ? qe(t, e.expression) : t;
1074
+ const t = { ...$, ...e.stance };
1075
+ return e.expression ? xe(t, e.expression) : t;
1075
1076
  }
1076
- function Bn(e) {
1077
+ function Nn(e) {
1077
1078
  return {
1078
- left: e.hands?.left ? ze(e.hands.left) : L,
1079
- right: e.hands?.right ? ze(e.hands.right) : L
1079
+ left: e.hands?.left ? ze(e.hands.left) : N,
1080
+ right: e.hands?.right ? ze(e.hands.right) : N
1080
1081
  };
1081
1082
  }
1082
1083
  function nt(e, t, n) {
1083
1084
  const s = e.moves[t.move];
1084
1085
  if (!s) throw new Error(`dance: "${e.label}" has no move "${t.move}"`);
1085
- const o = gs(s, n, yt(e), Bn(e));
1086
- return t.mirror ? { pose: ws(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
1086
+ const o = ws(s, n, yt(e), Nn(e));
1087
+ return t.mirror ? { pose: Es(o.pose), hands: { left: o.hands?.right, right: o.hands?.left } } : o;
1087
1088
  }
1088
1089
  function xt(e, t, n = {}) {
1089
- const s = typeof e == "string" ? Se[e] : e;
1090
+ const s = typeof e == "string" ? Ee[e] : e;
1090
1091
  let o;
1091
1092
  if (n.move)
1092
1093
  o = nt(s, { move: n.move, mirror: n.mirror }, t);
@@ -1098,36 +1099,36 @@ function xt(e, t, n = {}) {
1098
1099
  if (o = nt(s, r[h], c), c < tt && r.length > 1 && t >= tt) {
1099
1100
  const u = r[(h - 1 + r.length) % r.length], g = nt(s, u, u.beats + c), f = Qe("ease-in-out")(c / tt);
1100
1101
  o = {
1101
- pose: Pe(g.pose, o.pose, f),
1102
+ pose: We(g.pose, o.pose, f),
1102
1103
  hands: { left: Ke(g.hands.left, o.hands.left, f), right: Ke(g.hands.right, o.hands.right, f) }
1103
1104
  };
1104
1105
  }
1105
1106
  }
1106
- return { ...o, pose: ks(o.pose, s.groove, t) };
1107
+ return { ...o, pose: Hs(o.pose, s.groove, t) };
1107
1108
  }
1108
- function wi(e, t, n = {}) {
1109
+ function Ei(e, t, n = {}) {
1109
1110
  return xt(e, t, n).pose;
1110
1111
  }
1111
- function Kt(e) {
1112
- return (typeof e == "string" ? Se[e] : e).routine.reduce((n, s) => n + s.beats, 0);
1112
+ function Pt(e) {
1113
+ return (typeof e == "string" ? Ee[e] : e).routine.reduce((n, s) => n + s.beats, 0);
1113
1114
  }
1114
- const Ss = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1115
+ const vs = { leftToe: "rightToe", rightToe: "leftToe", leftHeel: "rightHeel", rightHeel: "leftHeel" };
1115
1116
  function Qt(e, t, n, s, o, r, l) {
1116
1117
  for (let i = 0; i * e.beats < n; i++)
1117
1118
  for (const a of e.keys) {
1118
1119
  const h = i * e.beats + a.beat, c = t + h;
1119
1120
  if (!(h >= n || c < r || c >= l))
1120
- for (const u of a.taps ?? []) o.push({ beat: c, tap: s ? Ss[u] : u });
1121
+ for (const u of a.taps ?? []) o.push({ beat: c, tap: s ? vs[u] : u });
1121
1122
  }
1122
1123
  }
1123
- function yi(e, t, n, s = {}) {
1124
- const o = typeof e == "string" ? Se[e] : e, r = [];
1124
+ function Mi(e, t, n, s = {}) {
1125
+ const o = typeof e == "string" ? Ee[e] : e, r = [];
1125
1126
  if (n <= t) return r;
1126
1127
  if (s.move) {
1127
1128
  const l = o.moves[s.move], i = Math.floor(t / l.beats) * l.beats;
1128
1129
  Qt(l, i, Math.ceil((n - i) / l.beats) * l.beats, s.mirror, r, t, n);
1129
1130
  } else {
1130
- const l = Kt(o);
1131
+ const l = Pt(o);
1131
1132
  for (let i = Math.floor(t / l) * l; i < n; i += l) {
1132
1133
  let a = i;
1133
1134
  for (const h of o.routine)
@@ -1140,13 +1141,13 @@ function en(e, t) {
1140
1141
  const n = e.moves[t.move];
1141
1142
  if (!n?.travel) return 0;
1142
1143
  const s = n.travel / n.beats;
1143
- return t.mirror ? ($n(n, yt(e), Bn(e))[0]?.pose.turn ?? yt(e).turn ?? 0) >= 0.5 ? s : -s : s;
1144
+ return t.mirror ? (Ln(n, yt(e), Nn(e))[0]?.pose.turn ?? yt(e).turn ?? 0) >= 0.5 ? s : -s : s;
1144
1145
  }
1145
- function Fn(e, t) {
1146
+ function Yn(e, t) {
1146
1147
  return t.move ? [{ move: t.move, beats: e.moves[t.move].beats, mirror: t.mirror }] : e.routine;
1147
1148
  }
1148
1149
  function ot(e, t, n = {}) {
1149
- const s = typeof e == "string" ? Se[e] : e, o = Fn(s, n), r = o.reduce((c, u) => c + u.beats, 0), l = o.reduce((c, u) => c + en(s, u) * u.beats, 0), i = Math.floor(t / r);
1150
+ const s = typeof e == "string" ? Ee[e] : e, o = Yn(s, n), r = o.reduce((c, u) => c + u.beats, 0), l = o.reduce((c, u) => c + en(s, u) * u.beats, 0), i = Math.floor(t / r);
1150
1151
  let a = i * l, h = t - i * r;
1151
1152
  for (const c of o) {
1152
1153
  const u = Math.min(c.beats, h);
@@ -1154,25 +1155,25 @@ function ot(e, t, n = {}) {
1154
1155
  }
1155
1156
  return a;
1156
1157
  }
1157
- function Es(e, t, n) {
1158
- const s = Fn(e, n), o = [0];
1158
+ function Ts(e, t, n) {
1159
+ const s = Yn(e, n), o = [0];
1159
1160
  let r = 0;
1160
1161
  for (let l = 0; r < t; l = (l + 1) % s.length)
1161
1162
  r += s[l].beats, o.push(Math.min(r, t));
1162
1163
  return o;
1163
1164
  }
1164
- const Ms = 8;
1165
- function Hs(e, t, n) {
1166
- const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = Es(s, r, n);
1165
+ const As = 8;
1166
+ function xs(e, t, n) {
1167
+ const s = typeof t == "string" ? Ee[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Pt(s)), l = Ts(s, r, n);
1167
1168
  if (l.every((b) => ot(s, b, n) === 0)) return;
1168
- const i = Math.min(n.fade ?? 1, r / 2), a = Qe("ease-in-out"), h = (b) => i <= 0 ? 1 : Math.min(a(Math.min(1, b / i)), a(Math.min(1, (r - b) / i))), c = Math.ceil(i * Ms), u = i <= 0 ? [] : Array.from({ length: c + 1 }, (b, y) => [y / c * i, r - y / c * i]).flat(), g = [.../* @__PURE__ */ new Set([...l, ...u])].sort((b, y) => b - y);
1169
+ const i = Math.min(n.fade ?? 1, r / 2), a = Qe("ease-in-out"), h = (b) => i <= 0 ? 1 : Math.min(a(Math.min(1, b / i)), a(Math.min(1, (r - b) / i))), c = Math.ceil(i * As), u = i <= 0 ? [] : Array.from({ length: c + 1 }, (b, S) => [S / c * i, r - S / c * i]).flat(), g = [.../* @__PURE__ */ new Set([...l, ...u])].sort((b, S) => b - S);
1169
1170
  let f = 0;
1170
- const p = g.map((b, y) => {
1171
- if (y > 0) {
1172
- const E = g[y - 1], H = Math.max(1, Math.ceil((b - E) * 16));
1173
- for (let M = 0; M < H; M++) {
1174
- const A = E + (b - E) * M / H, w = E + (b - E) * (M + 1) / H;
1175
- f += (ot(s, w, n) - ot(s, A, n)) * h((A + w) / 2);
1171
+ const p = g.map((b, S) => {
1172
+ if (S > 0) {
1173
+ const k = g[S - 1], v = Math.max(1, Math.ceil((b - k) * 16));
1174
+ for (let H = 0; H < v; H++) {
1175
+ const T = k + (b - k) * H / v, M = k + (b - k) * (H + 1) / v;
1176
+ f += (ot(s, M, n) - ot(s, T, n)) * h((T + M) / 2);
1176
1177
  }
1177
1178
  }
1178
1179
  return { beat: b, travel: f };
@@ -1184,13 +1185,13 @@ function Hs(e, t, n) {
1184
1185
  keyframes: p.map((b) => ({ time: d + b.beat * 6e4 / o, value: m + n.height * b.travel, easing: "linear" }))
1185
1186
  };
1186
1187
  }
1187
- function ki(e, t, n = 0) {
1188
+ function Hi(e, t, n = 0) {
1188
1189
  return (e - n) * t / 6e4;
1189
1190
  }
1190
- function Si(e, t = {}) {
1191
+ function vi(e, t = {}) {
1191
1192
  return (n) => xt(e, n, t);
1192
1193
  }
1193
- function Ei(e, t) {
1194
+ function Ti(e, t) {
1194
1195
  const n = t.start ?? 0, s = 6e4 / t.bpm, o = n + t.beats * s, r = Math.min((t.fade ?? 1) * s, (o - n) / 2);
1195
1196
  return [
1196
1197
  {
@@ -1215,8 +1216,8 @@ function Ei(e, t) {
1215
1216
  }
1216
1217
  ];
1217
1218
  }
1218
- function Mi(e, t, n = {}) {
1219
- const s = typeof t == "string" ? Se[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Kt(s)), l = n.samplesPerBeat ?? 4, i = n.start ?? 0, a = Math.round(r * l), h = Array.from({ length: a + 1 }, (d, m) => {
1219
+ function Ai(e, t, n = {}) {
1220
+ const s = typeof t == "string" ? Ee[t] : t, o = n.bpm ?? s.bpm, r = n.beats ?? (n.move ? s.moves[n.move].beats : Pt(s)), l = n.samplesPerBeat ?? 4, i = n.start ?? 0, a = Math.round(r * l), h = Array.from({ length: a + 1 }, (d, m) => {
1220
1221
  const b = m / l;
1221
1222
  return { time: i + b * 6e4 / o, frame: xt(s, b, n) };
1222
1223
  }), c = (d, m) => ({
@@ -1224,17 +1225,17 @@ function Mi(e, t, n = {}) {
1224
1225
  target: e,
1225
1226
  property: d,
1226
1227
  keyframes: h.map((b) => ({ time: b.time, value: m(b.frame) }))
1227
- }), g = Object.keys(_).filter((d) => h.some((m) => m.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== _[d]).map((d) => c(d, (m) => m.pose[d])), f = n.height === void 0 ? void 0 : Hs(e, s, { ...n, bpm: o, beats: r, start: i, height: n.height, fade: 0 });
1228
+ }), g = Object.keys($).filter((d) => h.some((m) => m.frame.pose[d] !== h[0].frame.pose[d]) || h[0].frame.pose[d] !== $[d]).map((d) => c(d, (m) => m.pose[d])), f = n.height === void 0 ? void 0 : xs(e, s, { ...n, bpm: o, beats: r, start: i, height: n.height, fade: 0 });
1228
1229
  if (f && g.push(f), n.hands === !1) return g;
1229
1230
  const p = [];
1230
1231
  for (const d of ["left", "right"])
1231
- for (const m of Object.keys(L)) {
1232
- const b = (y) => y.hands?.[d]?.[m] ?? L[m];
1233
- h.some((y) => b(y.frame) !== L[m]) && p.push(c(Ue(d, m), b));
1232
+ for (const m of Object.keys(N)) {
1233
+ const b = (S) => S.hands?.[d]?.[m] ?? N[m];
1234
+ h.some((S) => b(S.frame) !== N[m]) && p.push(c(Ue(d, m), b));
1234
1235
  }
1235
1236
  return [...g, ...p];
1236
1237
  }
1237
- const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic", vs = {
1238
+ const Pe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic", Ps = {
1238
1239
  label: "Disco",
1239
1240
  bpm: 120,
1240
1241
  stance: { leftHip: 10, rightHip: 10, leftKnee: 6, rightKnee: 6 },
@@ -1282,7 +1283,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1282
1283
  { move: "point", beats: 8, mirror: !0 },
1283
1284
  { move: "bump", beats: 8 }
1284
1285
  ]
1285
- }, Ts = {
1286
+ }, Ks = {
1286
1287
  label: "Hip hop",
1287
1288
  bpm: 95,
1288
1289
  stance: { leftHip: 14, rightHip: 14, leftKnee: 20, rightKnee: 20, leftShoulder: 22, rightShoulder: 22, leftElbow: -30, rightElbow: -30, leftFootOut: 0.15, rightFootOut: 0.15 },
@@ -1334,7 +1335,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1334
1335
  { move: "armWave", beats: 8 },
1335
1336
  { move: "bounce", beats: 4 }
1336
1337
  ]
1337
- }, As = {
1338
+ }, Ws = {
1338
1339
  label: "Breaking (toprock)",
1339
1340
  bpm: 110,
1340
1341
  stance: { leftHip: 14, rightHip: 14, leftKnee: 14, rightKnee: 14, leftShoulder: 35, rightShoulder: 35, leftElbow: -90, rightElbow: -90 },
@@ -1364,7 +1365,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1364
1365
  label: "B-boy stance",
1365
1366
  beats: 4,
1366
1367
  keys: [
1367
- { 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: xe },
1368
+ { 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: Pe },
1368
1369
  { beat: 2, pose: { headTilt: 14, lean: -6 } }
1369
1370
  ]
1370
1371
  }
@@ -1376,7 +1377,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1376
1377
  { move: "kick", beats: 4, mirror: !0 },
1377
1378
  { move: "freeze", beats: 4 }
1378
1379
  ]
1379
- }, xs = {
1380
+ }, Os = {
1380
1381
  label: "Jazz",
1381
1382
  bpm: 130,
1382
1383
  stance: { leftHip: 10, rightHip: 10 },
@@ -1392,7 +1393,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1392
1393
  beat: e,
1393
1394
  // The hands shimmer: the wrists flick a little each quarter beat.
1394
1395
  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 },
1395
- hands: t === 0 ? { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } : void 0
1396
+ hands: t === 0 ? { left: { ...D.spread, turn: 2 }, right: { ...D.spread, turn: 2 } } : void 0
1396
1397
  }))
1397
1398
  },
1398
1399
  kickBallChange: {
@@ -1437,7 +1438,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1437
1438
  { move: "jazzHands", beats: 4 },
1438
1439
  { move: "splitDrop", beats: 8 }
1439
1440
  ]
1440
- }, Ks = {
1441
+ }, Is = {
1441
1442
  label: "K-pop",
1442
1443
  bpm: 125,
1443
1444
  stance: { leftHip: 9, rightHip: 9, leftKnee: 4, rightKnee: 4 },
@@ -1447,7 +1448,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1447
1448
  pointCombo: {
1448
1449
  label: "Point combo",
1449
1450
  beats: 4,
1450
- easing: xe,
1451
+ easing: Pe,
1451
1452
  keys: [
1452
1453
  { 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" } },
1453
1454
  { beat: 1, pose: { rightShoulder: -38, headTilt: -6, lean: 3, lookX: -0.3, lookY: 0.5, rightHip: 18 } },
@@ -1459,9 +1460,9 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1459
1460
  label: "Big heart, finger heart",
1460
1461
  beats: 4,
1461
1462
  keys: [
1462
- { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: xe },
1463
+ { beat: 0, reset: !0, pose: { leftShoulder: 165, rightShoulder: 165, leftElbow: 46, rightElbow: 46, headTilt: -8, lean: -4 }, hands: { left: "cupped", right: "cupped" }, easing: Pe },
1463
1464
  { beat: 1, pose: { headTilt: 8, lean: 4 } },
1464
- { 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: xe },
1465
+ { 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: Pe },
1465
1466
  { beat: 3, pose: { headTilt: 4 } }
1466
1467
  ]
1467
1468
  },
@@ -1484,7 +1485,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1484
1485
  { move: "pointCombo", beats: 8, mirror: !0 },
1485
1486
  { move: "isolations", beats: 4 }
1486
1487
  ]
1487
- }, Ps = {
1488
+ }, _s = {
1488
1489
  label: "Bollywood",
1489
1490
  bpm: 120,
1490
1491
  stance: { leftHip: 10, rightHip: 10 },
@@ -1495,17 +1496,17 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1495
1496
  label: "Screw the bulb, pat the dog",
1496
1497
  beats: 2,
1497
1498
  keys: [
1498
- { 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: { ...C.cupped, roll: -30 }, left: { ...C.flat, turn: 0 } } },
1499
- { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } },
1500
- { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...C.cupped, roll: -30 } } },
1501
- { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...C.cupped, roll: 30 } } }
1499
+ { 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: { ...D.cupped, roll: -30 }, left: { ...D.flat, turn: 0 } } },
1500
+ { beat: 0.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...D.cupped, roll: 30 } } },
1501
+ { beat: 1, pose: { rightWrist: -15, rightElbow: 12, leftWrist: -45, lean: -4, rightHip: 16, leftHip: 6 }, hands: { right: { ...D.cupped, roll: -30 } } },
1502
+ { beat: 1.5, pose: { rightWrist: 25, rightElbow: 22, leftWrist: 10, lean: 4, rightHip: 6, leftHip: 16 }, hands: { right: { ...D.cupped, roll: 30 } } }
1502
1503
  ]
1503
1504
  },
1504
1505
  thumka: {
1505
1506
  label: "Thumka",
1506
1507
  beats: 2,
1507
1508
  keys: [
1508
- { 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: { ...C.open, turn: 2 } }, easing: V },
1509
+ { 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: { ...D.open, turn: 2 } }, easing: V },
1509
1510
  { beat: 0.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } },
1510
1511
  { beat: 1, pose: { lean: -11, rightHip: 22, headTilt: 10 }, easing: V },
1511
1512
  { beat: 1.5, pose: { lean: -4, rightHip: 12, headTilt: 6 } }
@@ -1529,7 +1530,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1529
1530
  { move: "thumka", beats: 4, mirror: !0 },
1530
1531
  { move: "lightBulb", beats: 8, mirror: !0 }
1531
1532
  ]
1532
- }, Ws = {
1533
+ }, $s = {
1533
1534
  label: "Bhangra",
1534
1535
  bpm: 100,
1535
1536
  stance: { leftShoulder: 150, rightShoulder: 150, leftElbow: 18, rightElbow: 18, leftHip: 10, rightHip: 10 },
@@ -1564,11 +1565,11 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1564
1565
  { move: "basic", beats: 8 },
1565
1566
  { move: "dhamaal", beats: 4 }
1566
1567
  ]
1567
- }, Os = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Is = {
1568
+ }, Bs = { leftHip: 42, rightHip: 42, leftKnee: 82, rightKnee: 82, leftFootOut: 0.3, rightFootOut: 0.3 }, Fs = {
1568
1569
  label: "Bharatanatyam",
1569
1570
  bpm: 80,
1570
1571
  // Natyarambhe: arms out at shoulder height, hands raised in pataka.
1571
- stance: { ...Os, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1572
+ stance: { ...Bs, leftShoulder: 90, rightShoulder: 90, leftElbow: 0, rightElbow: 0, leftWrist: 75, rightWrist: 75 },
1572
1573
  expression: { smile: 0.5, leftEye: 1.2, rightEye: 1.2, leftBrow: 0.3, rightBrow: 0.3 },
1573
1574
  hands: { left: "pataka", right: "pataka" },
1574
1575
  groove: { bounce: 0 },
@@ -1610,12 +1611,12 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1610
1611
  { move: "alapadma", beats: 8 },
1611
1612
  { move: "tatta", beats: 4 }
1612
1613
  ]
1613
- }, _s = {
1614
+ }, Rs = {
1614
1615
  label: "Charleston",
1615
1616
  bpm: 150,
1616
1617
  stance: { leftHip: 10, rightHip: 10, leftKnee: 10, rightKnee: 10, leftShoulder: 30, rightShoulder: 30, leftElbow: 20, rightElbow: 20 },
1617
1618
  expression: { mouth: 0.4, smile: 1, leftBrow: 0.5, rightBrow: 0.5 },
1618
- hands: { left: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } },
1619
+ hands: { left: { ...D.spread, turn: 2 }, right: { ...D.spread, turn: 2 } },
1619
1620
  groove: { bounce: 8, accent: "down" },
1620
1621
  moves: {
1621
1622
  basic: {
@@ -1660,7 +1661,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1660
1661
  { move: "basic", beats: 8, mirror: !0 },
1661
1662
  { move: "twist", beats: 4 }
1662
1663
  ]
1663
- }, $s = {
1664
+ }, Ls = {
1664
1665
  label: "Tap",
1665
1666
  bpm: 120,
1666
1667
  // Three-quarters to side-on, so shuffles read as brushes forward and back. Side-on,
@@ -1746,7 +1747,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1746
1747
  { beat: 0.75, pose: { rightAnkle: 0, rise: 0 }, taps: ["rightHeel"] },
1747
1748
  { beat: 0.875, pose: { leftAnkle: 0 }, taps: ["leftHeel"] },
1748
1749
  // Arms flare on the finish: one up in front, one up behind.
1749
- { 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: { ...C.spread, turn: 2 }, right: { ...C.spread, turn: 2 } } },
1750
+ { 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: { ...D.spread, turn: 2 }, right: { ...D.spread, turn: 2 } } },
1750
1751
  { beat: 1.75, reset: !0 }
1751
1752
  ]
1752
1753
  }
@@ -1758,7 +1759,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1758
1759
  { move: "heelToe", beats: 8 },
1759
1760
  { move: "crampRoll", beats: 4 }
1760
1761
  ]
1761
- }, Bs = {
1762
+ }, Ns = {
1762
1763
  label: "Popping (glides, moonwalk)",
1763
1764
  bpm: 100,
1764
1765
  stance: { leftHip: 9, rightHip: 9, leftShoulder: 16, rightShoulder: 16, leftElbow: -24, rightElbow: -24 },
@@ -1818,7 +1819,7 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1818
1819
  reset: !0,
1819
1820
  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 },
1820
1821
  hands: { right: "fist", left: "fist" },
1821
- easing: xe
1822
+ easing: Pe
1822
1823
  },
1823
1824
  { beat: 2, pose: { headTilt: -14, lean: -2 } }
1824
1825
  ]
@@ -1831,55 +1832,55 @@ const xe = { type: "back", mode: "out", overshoot: 1.1 }, V = "ease-out-cubic",
1831
1832
  { move: "forwardGlide", beats: 8 },
1832
1833
  { move: "toeStand", beats: 4 }
1833
1834
  ]
1834
- }, Se = {
1835
- disco: vs,
1836
- hipHop: Ts,
1837
- breaking: As,
1838
- jazz: xs,
1839
- kpop: Ks,
1840
- bollywood: Ps,
1841
- bhangra: Ws,
1842
- bharatanatyam: Is,
1843
- charleston: _s,
1844
- tap: $s,
1845
- popping: Bs
1835
+ }, Ee = {
1836
+ disco: Ps,
1837
+ hipHop: Ks,
1838
+ breaking: Ws,
1839
+ jazz: Os,
1840
+ kpop: Is,
1841
+ bollywood: _s,
1842
+ bhangra: $s,
1843
+ bharatanatyam: Fs,
1844
+ charleston: Rs,
1845
+ tap: Ls,
1846
+ popping: Ns
1846
1847
  }, Ve = (e) => Math.min(1, Math.max(0, e));
1847
- function Fs(e) {
1848
- const t = { ..._, turn: e.view }, n = [];
1848
+ function Ys(e) {
1849
+ const t = { ...$, turn: e.view }, n = [];
1849
1850
  for (const s of e.keys) {
1850
1851
  const o = n[n.length - 1], r = !o || s.reset ? t : o.pose;
1851
1852
  n.push({ at: s.at, pose: { ...r, ...s.pose }, easing: s.easing });
1852
1853
  }
1853
1854
  return n;
1854
1855
  }
1855
- function Rs(e) {
1856
- return e - Ls * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1856
+ function Cs(e) {
1857
+ return e - Ds * Math.sin(2 * Math.PI * e) / (2 * Math.PI);
1857
1858
  }
1858
- const Ls = 0.5;
1859
- function Ns(e, t) {
1859
+ const Ds = 0.5;
1860
+ function Xs(e, t) {
1860
1861
  if (!(t <= e.takeoff || t >= e.landing))
1861
1862
  return (t - e.takeoff) / (e.landing - e.takeoff);
1862
1863
  }
1863
- function Ys(e, t) {
1864
- const n = typeof e == "string" ? Pt[e] : e, s = Fs(n), o = Ve(t);
1864
+ function qs(e, t) {
1865
+ const n = typeof e == "string" ? Kt[e] : e, s = Ys(n), o = Ve(t);
1865
1866
  let r = 0;
1866
1867
  for (let u = 0; u < s.length; u++) s[u].at <= o && (r = u);
1867
- const l = s[r], i = s[Math.min(r + 1, s.length - 1)], a = i.at > l.at ? (o - l.at) / (i.at - l.at) : 0, h = Pe(l.pose, i.pose, Qe(i.easing ?? "ease-in-out")(Ve(a))), c = Ns(n, o);
1868
+ const l = s[r], i = s[Math.min(r + 1, s.length - 1)], a = i.at > l.at ? (o - l.at) / (i.at - l.at) : 0, h = We(l.pose, i.pose, Qe(i.easing ?? "ease-in-out")(Ve(a))), c = Xs(n, o);
1868
1869
  return c === void 0 ? { ...h, spin: 0, rise: 0 } : {
1869
1870
  ...h,
1870
- spin: n.spin * Rs(c),
1871
+ spin: n.spin * Cs(c),
1871
1872
  rise: 4 * n.height * c * (1 - c)
1872
1873
  };
1873
1874
  }
1874
- function Cs(e, t, n) {
1875
- const s = typeof e == "string" ? Pt[e] : e, o = Ve(t), r = Ve((o - s.takeoff) / (s.landing - s.takeoff));
1875
+ function Gs(e, t, n) {
1876
+ const s = typeof e == "string" ? Kt[e] : e, o = Ve(t), r = Ve((o - s.takeoff) / (s.landing - s.takeoff));
1876
1877
  return s.travel * n * r;
1877
1878
  }
1878
- function Hi(e, t, n = {}) {
1879
- const s = typeof t == "string" ? Pt[t] : t, o = n.start ?? 0, r = n.duration ?? s.duration, l = n.samples ?? 48, i = Array.from({ length: l + 1 }, (c, u) => {
1879
+ function xi(e, t, n = {}) {
1880
+ const s = typeof t == "string" ? Kt[t] : t, o = n.start ?? 0, r = n.duration ?? s.duration, l = n.samples ?? 48, i = Array.from({ length: l + 1 }, (c, u) => {
1880
1881
  const g = u / l;
1881
- return { time: o + g * r, progress: g, pose: Ys(s, g) };
1882
- }), h = Object.keys(_).filter((c) => i.some((u) => u.pose[c] !== _[c])).map((c) => ({
1882
+ return { time: o + g * r, progress: g, pose: qs(s, g) };
1883
+ }), h = Object.keys($).filter((c) => i.some((u) => u.pose[c] !== $[c])).map((c) => ({
1883
1884
  id: `${e}-${c}`,
1884
1885
  target: e,
1885
1886
  property: c,
@@ -1891,12 +1892,12 @@ function Hi(e, t, n = {}) {
1891
1892
  id: `${e}-x`,
1892
1893
  target: e,
1893
1894
  property: "x",
1894
- keyframes: i.map((u) => ({ time: u.time, value: (n.x ?? 0) + c * Cs(s, u.progress, n.height) }))
1895
+ keyframes: i.map((u) => ({ time: u.time, value: (n.x ?? 0) + c * Gs(s, u.progress, n.height) }))
1895
1896
  });
1896
1897
  }
1897
1898
  return h;
1898
1899
  }
1899
- const Ds = {
1900
+ const Us = {
1900
1901
  leftHip: -55,
1901
1902
  leftKnee: -95,
1902
1903
  rightHip: 55,
@@ -1908,7 +1909,7 @@ const Ds = {
1908
1909
  lean: 22,
1909
1910
  stretch: 0.94,
1910
1911
  headTilt: 6
1911
- }, Xs = {
1912
+ }, zs = {
1912
1913
  leftHip: 0,
1913
1914
  leftKnee: 0,
1914
1915
  rightHip: 0,
@@ -1922,7 +1923,7 @@ const Ds = {
1922
1923
  lean: 0,
1923
1924
  stretch: 1.08,
1924
1925
  headTilt: 0
1925
- }, _e = {
1926
+ }, $e = {
1926
1927
  leftHip: -128,
1927
1928
  leftKnee: -152,
1928
1929
  rightHip: 128,
@@ -1936,7 +1937,7 @@ const Ds = {
1936
1937
  lean: 26,
1937
1938
  stretch: 1,
1938
1939
  headTilt: 14
1939
- }, qs = {
1940
+ }, Vs = {
1940
1941
  leftHip: -22,
1941
1942
  leftKnee: -30,
1942
1943
  rightHip: 22,
@@ -1949,7 +1950,7 @@ const Ds = {
1949
1950
  rightElbow: 0,
1950
1951
  lean: 8,
1951
1952
  headTilt: 0
1952
- }, Gs = {
1953
+ }, js = {
1953
1954
  leftHip: -58,
1954
1955
  leftKnee: -100,
1955
1956
  rightHip: 58,
@@ -1975,23 +1976,23 @@ function pe(e, t, n, s, o, r = 1300) {
1975
1976
  duration: r,
1976
1977
  keys: [
1977
1978
  { at: 0, reset: !0 },
1978
- { at: 0.16, pose: Ds },
1979
- { at: 0.27, pose: Xs, easing: "ease-out-quad" },
1979
+ { at: 0.16, pose: Us },
1980
+ { at: 0.27, pose: zs, easing: "ease-out-quad" },
1980
1981
  ...o,
1981
- { at: 0.76, pose: qs },
1982
- { at: 0.86, pose: Gs, easing: "ease-out-quad" },
1982
+ { at: 0.76, pose: Vs },
1983
+ { at: 0.86, pose: js, easing: "ease-out-quad" },
1983
1984
  { at: 1, reset: !0 }
1984
1985
  ]
1985
1986
  };
1986
1987
  }
1987
- const Pt = {
1988
+ const Kt = {
1988
1989
  frontFlip: pe("Front flip (tuck)", 360, 0.56, 0.35, [
1989
- { at: 0.38, pose: _e, easing: "ease-out-cubic" },
1990
- { at: 0.64, pose: _e }
1990
+ { at: 0.38, pose: $e, easing: "ease-out-cubic" },
1991
+ { at: 0.64, pose: $e }
1991
1992
  ]),
1992
1993
  backFlip: pe("Back flip (tuck)", -360, 0.58, -0.15, [
1993
- { at: 0.36, pose: { ..._e, lean: 18 }, easing: "ease-out-cubic" },
1994
- { at: 0.64, pose: { ..._e, lean: 18 } }
1994
+ { at: 0.36, pose: { ...$e, lean: 18 }, easing: "ease-out-cubic" },
1995
+ { at: 0.64, pose: { ...$e, lean: 18 } }
1995
1996
  ]),
1996
1997
  layout: pe("Back layout (straight body)", -360, 0.66, -0.2, [
1997
1998
  // Arched, arms overhead, legs together and long.
@@ -2075,7 +2076,7 @@ const Pt = {
2075
2076
  { at: 0.38, pose: { leftHip: 10, rightHip: -10, leftKnee: 0, rightKnee: 0, leftShoulder: -178, rightShoulder: 178, lean: -26, headTilt: -20 } },
2076
2077
  { at: 0.6, pose: { leftHip: -40, rightHip: 40, leftKnee: -20, rightKnee: 20, lean: 6, headTilt: 0 } }
2077
2078
  ], 1200)
2078
- }, st = 0.215, rt = 0.205, Us = 0.065, tn = 0.035, zs = 0.165, Vs = 0.155, js = 12, Js = (e) => e * Math.PI / 180, X = {
2079
+ }, st = 0.215, rt = 0.205, Js = 0.065, tn = 0.035, Zs = 0.165, Qs = 0.155, er = 12, tr = (e) => e * Math.PI / 180, G = {
2079
2080
  turn: 0,
2080
2081
  lean: 0,
2081
2082
  side: 0,
@@ -2118,14 +2119,14 @@ const Pt = {
2118
2119
  lookY: 0
2119
2120
  };
2120
2121
  function ee(e = {}) {
2121
- return { ...X, ...e };
2122
+ return { ...G, ...e };
2122
2123
  }
2123
- const Zs = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2124
- function vi(e) {
2124
+ const nr = /* @__PURE__ */ new Set(["turn", "side", "head.turn", "head.tilt", "roll", "lookX"]);
2125
+ function Pi(e) {
2125
2126
  const t = {};
2126
2127
  for (const [n, s] of Object.entries(e)) {
2127
2128
  const o = n.replace(/(^|\.)(left|right)(\.|$)/, (r, l, i, a) => `${l}${i === "left" ? "right" : "left"}${a}`);
2128
- t[o] = Zs.has(n) ? -s : s;
2129
+ t[o] = nr.has(n) ? -s : s;
2129
2130
  }
2130
2131
  return t;
2131
2132
  }
@@ -2134,8 +2135,8 @@ function Z(e, t) {
2134
2135
  for (const s of ["left", "right"]) for (const [o, r] of Object.entries(t)) n[`${e}.${s}.${o}`] = r;
2135
2136
  return n;
2136
2137
  }
2137
- const Qs = {
2138
- rest: X,
2138
+ const or = {
2139
+ rest: G,
2139
2140
  wave: ee({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
2140
2141
  cheer: ee({ ...Z("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
2141
2142
  point: ee({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
@@ -2159,7 +2160,7 @@ const Qs = {
2159
2160
  crawl: ee({ lean: 82, "head.nod": -35, ...Z("arm", { swing: 80, elbow: 0, spread: 4 }), ...Z("leg", { knee: 92, ankle: -88 }) }),
2160
2161
  lieDown: ee({ roll: 90, ...Z("arm", { spread: 8 }), "head.nod": 0 })
2161
2162
  };
2162
- function er(e = {}) {
2163
+ function sr(e = {}) {
2163
2164
  const t = e.headSize ?? 0.3, n = e.shoulderWidth ?? 0.06, s = e.hipWidth ?? 0.022, o = Math.max(0.12, 1 - t - tn - (st + rt)), r = (a) => ({
2164
2165
  id: `arm.${a}`,
2165
2166
  parent: "spine",
@@ -2167,8 +2168,8 @@ function er(e = {}) {
2167
2168
  rest: [0, -1, 0],
2168
2169
  side: a === "left" ? 1 : -1,
2169
2170
  bones: [
2170
- { length: zs, width: [1.25, 0.9] },
2171
- { length: Vs, width: [0.9, 0.75] }
2171
+ { length: Zs, width: [1.25, 0.9] },
2172
+ { length: Qs, width: [0.9, 0.75] }
2172
2173
  ]
2173
2174
  }), l = (a) => ({
2174
2175
  id: `leg.${a}`,
@@ -2179,9 +2180,9 @@ function er(e = {}) {
2179
2180
  bones: [
2180
2181
  { length: st, width: [1.45, 1.05] },
2181
2182
  { length: rt, width: [1.05, 0.85] },
2182
- { length: Us, width: [0.95, 0.7] }
2183
+ { length: Js, width: [0.95, 0.7] }
2183
2184
  ]
2184
- }), i = (a, h) => a[h] ?? X[h] ?? 0;
2185
+ }), i = (a, h) => a[h] ?? G[h] ?? 0;
2185
2186
  return {
2186
2187
  id: "human",
2187
2188
  hipHeight: st + rt,
@@ -2231,12 +2232,12 @@ function er(e = {}) {
2231
2232
  { swing: g("swing"), spread: g("spread") },
2232
2233
  { swing: g("elbow"), spread: g("bend") }
2233
2234
  ];
2234
- const f = (h.side ?? 1) * g("rotate"), p = 1 - Math.cos(Js(g("rotate")));
2235
+ const f = (h.side ?? 1) * g("rotate"), p = 1 - Math.cos(tr(g("rotate")));
2235
2236
  return [
2236
2237
  { swing: g("swing"), spread: g("spread"), yaw: f },
2237
2238
  { swing: -g("knee"), spread: 0, yaw: f },
2238
2239
  // The foot points forward, square to the shin, turned out a little (more with `toeOut`).
2239
- { swing: 90 + g("ankle") - p * (g("swing") - g("knee")), spread: 0, yaw: (js + g("toeOut")) * (h.side ?? 1) }
2240
+ { swing: 90 + g("ankle") - p * (g("swing") - g("knee")), spread: 0, yaw: (er + g("toeOut")) * (h.side ?? 1) }
2240
2241
  ];
2241
2242
  },
2242
2243
  withAngles(a, h, c) {
@@ -2283,7 +2284,7 @@ function er(e = {}) {
2283
2284
  }
2284
2285
  };
2285
2286
  }
2286
- function Ti(e) {
2287
+ function Ki(e) {
2287
2288
  const t = e.split(".");
2288
2289
  if (t[0] === "hand" && t.length >= 3) {
2289
2290
  const s = `${t[1] === "left" ? "Left" : "Right"} hand`, o = { spread: "finger spread", turn: "wrist turn", bend: "wrist bend", tilt: "wrist tilt", roll: "roll" }, r = t.slice(2).join(".");
@@ -2325,19 +2326,19 @@ function Ti(e) {
2325
2326
  lookY: "Look up / down"
2326
2327
  }[e] ?? e;
2327
2328
  }
2328
- const tr = {
2329
+ const rr = {
2329
2330
  leftEye: "eye.left",
2330
2331
  rightEye: "eye.right",
2331
2332
  leftBrow: "brow.left",
2332
2333
  rightBrow: "brow.right"
2333
- }, Ai = Object.fromEntries(
2334
- Object.entries(Y).map(([e, t]) => [
2334
+ }, Wi = Object.fromEntries(
2335
+ Object.entries(C).map(([e, t]) => [
2335
2336
  e,
2336
- Object.fromEntries(Object.entries(t).map(([n, s]) => [tr[n] ?? n, s]))
2337
+ Object.fromEntries(Object.entries(t).map(([n, s]) => [rr[n] ?? n, s]))
2337
2338
  ])
2338
2339
  );
2339
- function xi(e, t) {
2340
- const n = Math.min(1, Math.max(0, e.turn ?? 0)), s = 1 - n, o = { ...X, turn: n }, r = [
2340
+ function Oi(e, t) {
2341
+ const n = Math.min(1, Math.max(0, e.turn ?? 0)), s = 1 - n, o = { ...G, turn: n }, r = [
2341
2342
  { stick: "right", human: "left", s: 1 },
2342
2343
  { stick: "left", human: "right", s: -1 }
2343
2344
  ];
@@ -2345,21 +2346,21 @@ function xi(e, t) {
2345
2346
  const c = e[`${i}Shoulder`], u = e[`${i}Elbow`];
2346
2347
  o[`arm.${a}.spread`] = c * s, o[`arm.${a}.swing`] = h * c * n, o[`arm.${a}.bend`] = u * s, o[`arm.${a}.elbow`] = h * u * n;
2347
2348
  const g = e[`${i}Hip`], f = e[`${i}Knee`], p = s + h * n;
2348
- o[`leg.${a}.rotate`] = 90 * s, o[`leg.${a}.spread`] = 0, o[`leg.${a}.swing`] = g * p, o[`leg.${a}.knee`] = f * p, o[`leg.${a}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${a}.toeOut`] = (e[`${i}FootOut`] ?? 0) * nr, o[`eye.${a}`] = e[`${i}Eye`], o[`brow.${a}`] = e[`${i}Brow`], t && Object.assign(o, or(a, t[i] ?? L, e[`${i}Wrist`] ?? 0, n));
2349
+ o[`leg.${a}.rotate`] = 90 * s, o[`leg.${a}.spread`] = 0, o[`leg.${a}.swing`] = g * p, o[`leg.${a}.knee`] = f * p, o[`leg.${a}.ankle`] = -(e[`${i}Ankle`] ?? 0), o[`leg.${a}.toeOut`] = (e[`${i}FootOut`] ?? 0) * ir, o[`eye.${a}`] = e[`${i}Eye`], o[`brow.${a}`] = e[`${i}Brow`], t && Object.assign(o, lr(a, t[i] ?? N, e[`${i}Wrist`] ?? 0, n));
2349
2350
  }
2350
2351
  const l = e.bend ?? 0;
2351
2352
  o.lean = (e.lean + l * 0.5) * n, o.side = (e.lean + l * 0.5) * s, o["head.tilt"] = (e.headTilt + l * 0.5) * s, o["head.nod"] = (e.headTilt + l * 0.5) * n;
2352
2353
  for (const i of ["mouth", "smile", "mouthWidth", "blink", "browTilt", "lookX", "lookY", "stretch"]) o[i] = e[i];
2353
2354
  return o.lift = e.rise ?? 0, o.roll = e.spin ?? 0, o;
2354
2355
  }
2355
- const nr = 70;
2356
- function or(e, t, n, s) {
2356
+ const ir = 70;
2357
+ function lr(e, t, n, s) {
2357
2358
  const o = e === "right" ? 1 - s : 1 + s, r = {};
2358
- for (const l of Object.keys(L)) r[`hand.${e}.${l}`] = t[l] ?? L[l];
2359
+ for (const l of Object.keys(N)) r[`hand.${e}.${l}`] = t[l] ?? N[l];
2359
2360
  return r[`hand.${e}.turn`] = (t.turn ?? 0) - o, r[`hand.${e}.roll`] = (t.roll ?? 0) + n, r;
2360
2361
  }
2361
2362
  const te = (e) => e * Math.PI / 180;
2362
- function Rn([e, t, n], s) {
2363
+ function Cn([e, t, n], s) {
2363
2364
  const o = Math.cos(s), r = Math.sin(s);
2364
2365
  return [e, t * o + n * r, -t * r + n * o];
2365
2366
  }
@@ -2371,7 +2372,7 @@ function ge([e, t, n], s) {
2371
2372
  const o = Math.cos(s), r = Math.sin(s);
2372
2373
  return [e * o + n * r, t, -e * r + n * o];
2373
2374
  }
2374
- const he = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], je = (e, t) => [e[0] * t, e[1] * t, e[2] * t], De = (e, t) => Wt(Rn(e, t.swing), t.spread);
2375
+ const he = (e, t) => [e[0] + t[0], e[1] + t[1], e[2] + t[2]], je = (e, t) => [e[0] * t, e[1] * t, e[2] * t], Xe = (e, t) => Wt(Cn(e, t.swing), t.spread);
2375
2376
  function it(e, t) {
2376
2377
  const n = ge(e, t);
2377
2378
  return { point: { x: n[0], y: -n[1] }, depth: n[2] };
@@ -2381,73 +2382,73 @@ function Ot(e, t, n) {
2381
2382
  for (const d of e.chains) {
2382
2383
  const m = d.parent ? l[d.parent] : void 0;
2383
2384
  if (d.parent && !m) throw new Error(`body plan ${e.id}: chain ${d.id} comes before its parent ${d.parent}`);
2384
- const b = d.at ?? (m ? m.joints3.length - 1 : 0), y = m ? m.joints3[b] : r, E = m ? m.frames[Math.max(0, b - 1)] : { swing: 0, spread: 0 }, H = d.offset ? he(y, De(je(d.offset, s), E)) : y, M = d.side ?? 1, A = e.boneScale?.(t, d) ?? 1, w = e.angles(t, d), S = [H], k = [];
2385
- let x = E.swing, v = E.spread;
2386
- d.bones.forEach((T, K) => {
2387
- const P = w[K] ?? { swing: 0, spread: 0 };
2388
- x += te(P.swing), v += te(P.spread) * M, k.push({ swing: x, spread: v });
2389
- const I = ge(De(d.rest, { swing: x, spread: v }), te(P.yaw ?? 0));
2390
- S.push(he(S[K], je(I, T.length * s * A)));
2391
- }), l[d.id] = { joints3: S, frames: k };
2392
- }
2393
- 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 * s, u = c * a.sx, g = c * a.sy, f = (d) => De(ge(Rn(Wt(d, -te(a.tilt)), -te(a.nod)), te(a.yaw)), h), p = he(i.joints3[i.joints3.length - 1], f([0, g, 0]));
2385
+ const b = d.at ?? (m ? m.joints3.length - 1 : 0), S = m ? m.joints3[b] : r, k = m ? m.frames[Math.max(0, b - 1)] : { swing: 0, spread: 0 }, v = d.offset ? he(S, Xe(je(d.offset, s), k)) : S, H = d.side ?? 1, T = e.boneScale?.(t, d) ?? 1, M = e.angles(t, d), w = [v], y = [];
2386
+ let A = k.swing, x = k.spread;
2387
+ d.bones.forEach((E, P) => {
2388
+ const K = M[P] ?? { swing: 0, spread: 0 };
2389
+ A += te(K.swing), x += te(K.spread) * H, y.push({ swing: A, spread: x });
2390
+ const I = ge(Xe(d.rest, { swing: A, spread: x }), te(K.yaw ?? 0));
2391
+ w.push(he(w[P], je(I, E.length * s * T)));
2392
+ }), l[d.id] = { joints3: w, frames: y };
2393
+ }
2394
+ 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 * s, u = c * a.sx, g = c * a.sy, f = (d) => Xe(ge(Cn(Wt(d, -te(a.tilt)), -te(a.nod)), te(a.yaw)), h), p = he(i.joints3[i.joints3.length - 1], f([0, g, 0]));
2394
2395
  return { height: s, root: r, chains: l, head: { center: p, rx: u, ry: g, toBody: f } };
2395
2396
  }
2396
2397
  function It(e, t, n) {
2397
2398
  const s = n.height, o = te(90 * (t.turn ?? 0)), r = Ot(e, t, s), { root: l } = r, i = r.chains, { rx: a, ry: h } = r.head, c = r.head.toBody, u = r.head.center, g = {};
2398
- for (const k of e.chains) {
2399
- const { joints3: x, frames: v } = i[k.id], T = x.map((K) => it(K, o));
2400
- g[k.id] = {
2401
- id: k.id,
2402
- joints3: x,
2403
- frames: v,
2404
- points: T.map((K) => K.point),
2405
- depths: T.map((K) => K.depth)
2399
+ for (const y of e.chains) {
2400
+ const { joints3: A, frames: x } = i[y.id], E = A.map((P) => it(P, o));
2401
+ g[y.id] = {
2402
+ id: y.id,
2403
+ joints3: A,
2404
+ frames: x,
2405
+ points: E.map((P) => P.point),
2406
+ depths: E.map((P) => P.depth)
2406
2407
  };
2407
2408
  }
2408
- const f = it(u, o), p = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((k) => ge(c(k), o)), d = it(l, o).point, m = te(t.roll ?? 0), b = (k) => {
2409
- const x = k.x - d.x, v = k.y - d.y;
2410
- return { x: d.x + x * Math.cos(m) - v * Math.sin(m), y: d.y + x * Math.sin(m) + v * Math.cos(m) };
2411
- }, y = ([k, x, v]) => [k * Math.cos(m) + x * Math.sin(m), -k * Math.sin(m) + x * Math.cos(m), v];
2412
- for (const k of Object.values(g)) k.points = k.points.map(b);
2413
- const E = {
2409
+ const f = it(u, o), p = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((y) => ge(c(y), o)), d = it(l, o).point, m = te(t.roll ?? 0), b = (y) => {
2410
+ const A = y.x - d.x, x = y.y - d.y;
2411
+ return { x: d.x + A * Math.cos(m) - x * Math.sin(m), y: d.y + A * Math.sin(m) + x * Math.cos(m) };
2412
+ }, S = ([y, A, x]) => [y * Math.cos(m) + A * Math.sin(m), -y * Math.sin(m) + A * Math.cos(m), x];
2413
+ for (const y of Object.values(g)) y.points = y.points.map(b);
2414
+ const k = {
2414
2415
  center: b(f.point),
2415
2416
  depth: f.depth,
2416
2417
  rx: a,
2417
2418
  ry: h,
2418
2419
  angle: 0,
2419
- axes: p.map(y)
2420
- }, H = E.axes[1];
2421
- E.angle = Math.atan2(H[0], H[1]);
2422
- const M = (k) => {
2423
- if ("head" in k) return { x: E.center.x + H[0] * h, y: E.center.y - H[1] * h };
2424
- const x = g[k.chain];
2425
- return x.points[Math.min(k.joint, x.points.length - 1)];
2420
+ axes: p.map(S)
2421
+ }, v = k.axes[1];
2422
+ k.angle = Math.atan2(v[0], v[1]);
2423
+ const H = (y) => {
2424
+ if ("head" in y) return { x: k.center.x + v[0] * h, y: k.center.y - v[1] * h };
2425
+ const A = g[y.chain];
2426
+ return A.points[Math.min(y.joint, A.points.length - 1)];
2426
2427
  };
2427
- let A = 0;
2428
- (n.contact ?? "ground") === "ground" && (A = -Math.max(...e.contacts.map((k) => M(k).y))), A -= (t.lift ?? 0) * s;
2429
- const w = (k) => ({ x: k.x, y: k.y + A });
2430
- for (const k of Object.values(g)) k.points = k.points.map(w);
2431
- E.center = w(E.center);
2432
- const S = e.contacts.map((k) => ({ spec: k, point: M(k) }));
2428
+ let T = 0;
2429
+ (n.contact ?? "ground") === "ground" && (T = -Math.max(...e.contacts.map((y) => H(y).y))), T -= (t.lift ?? 0) * s;
2430
+ const M = (y) => ({ x: y.x, y: y.y + T });
2431
+ for (const y of Object.values(g)) y.points = y.points.map(M);
2432
+ k.center = M(k.center);
2433
+ const w = e.contacts.map((y) => ({ spec: y, point: H(y) }));
2433
2434
  return {
2434
2435
  height: s,
2435
2436
  view: o,
2436
2437
  chains: g,
2437
- head: E,
2438
- hip: w(b(d)),
2439
- contacts: S,
2440
- groundY: Math.max(...S.map((k) => k.point.y))
2438
+ head: k,
2439
+ hip: M(b(d)),
2440
+ contacts: w,
2441
+ groundY: Math.max(...w.map((y) => y.point.y))
2441
2442
  };
2442
2443
  }
2443
- const kt = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Ln = (e) => {
2444
+ const kt = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], Dn = (e) => {
2444
2445
  const t = Math.hypot(e[0], e[1], e[2]) || 1;
2445
2446
  return [e[0] / t, e[1] / t, e[2] / t];
2446
2447
  };
2447
- function Nn(e, t, n) {
2448
+ function Xn(e, t, n) {
2448
2449
  const s = n.height, o = te(90 * (t.turn ?? 0)), r = te(t.roll ?? 0), l = Ot(e, t, s), i = ge(l.root, o), a = (m) => he(Wt(kt(ge(m, o), i), -r), i), h = {};
2449
2450
  for (const m of e.chains) h[m.id] = l.chains[m.id].joints3.map(a);
2450
- const c = a(l.head.center), u = (m) => Ln(kt(a(he(l.head.center, l.head.toBody(m))), c)), g = [u([1, 0, 0]), u([0, 1, 0]), u([0, 0, 1])], f = (m) => {
2451
+ const c = a(l.head.center), u = (m) => Dn(kt(a(he(l.head.center, l.head.toBody(m))), c)), g = [u([1, 0, 0]), u([0, 1, 0]), u([0, 0, 1])], f = (m) => {
2451
2452
  if ("head" in m) return he(c, je(g[1], l.head.ry));
2452
2453
  const b = h[m.chain];
2453
2454
  return b[Math.min(m.joint, b.length - 1)];
@@ -2462,44 +2463,44 @@ function Nn(e, t, n) {
2462
2463
  head: { center: d(c), rx: l.head.rx, ry: l.head.ry, axes: g }
2463
2464
  };
2464
2465
  }
2465
- function Yn(e, t, n, s) {
2466
- const o = n.height, r = te(90 * (t.turn ?? 0)), l = Ot(e, t, o), i = Nn(e, t, n), a = i.hip, h = i.chains, c = i.head.center, u = (k) => {
2467
- if ("head" in k) return he(c, je(i.head.axes[1], i.head.ry));
2468
- const x = h[k.chain];
2469
- return x[Math.min(k.joint, x.length - 1)];
2470
- }, g = s.toView(a), f = s.toScreen(g), p = s.toScreen([g[0] + 1, g[1], g[2]]), d = Math.hypot(p.x - f.x, p.y - f.y), m = (k) => {
2471
- const x = s.toView(k);
2472
- return { point: s.toScreen(x), depth: x[2] * d };
2466
+ function qn(e, t, n, s) {
2467
+ const o = n.height, r = te(90 * (t.turn ?? 0)), l = Ot(e, t, o), i = Xn(e, t, n), a = i.hip, h = i.chains, c = i.head.center, u = (y) => {
2468
+ if ("head" in y) return he(c, je(i.head.axes[1], i.head.ry));
2469
+ const A = h[y.chain];
2470
+ return A[Math.min(y.joint, A.length - 1)];
2471
+ }, g = s.toView(a), f = s.toScreen(g), p = s.toScreen([g[0] + 1, g[1], g[2]]), d = Math.hypot(p.x - f.x, p.y - f.y), m = (y) => {
2472
+ const A = s.toView(y);
2473
+ return { point: s.toScreen(A), depth: A[2] * d };
2473
2474
  }, b = {};
2474
- for (const k of e.chains) {
2475
- const x = h[k.id].map(m);
2476
- b[k.id] = {
2477
- id: k.id,
2478
- joints3: l.chains[k.id].joints3,
2479
- frames: l.chains[k.id].frames,
2480
- points: x.map((v) => v.point),
2481
- depths: x.map((v) => v.depth)
2475
+ for (const y of e.chains) {
2476
+ const A = h[y.id].map(m);
2477
+ b[y.id] = {
2478
+ id: y.id,
2479
+ joints3: l.chains[y.id].joints3,
2480
+ frames: l.chains[y.id].frames,
2481
+ points: A.map((x) => x.point),
2482
+ depths: A.map((x) => x.depth)
2482
2483
  };
2483
2484
  }
2484
- const y = s.toView(c), E = s.toScreen(y), H = s.toScreen([y[0] + 1, y[1], y[2]]), M = Math.hypot(H.x - E.x, H.y - E.y), A = i.head.axes.map((k) => Ln(kt(s.toView(he(c, k)), y))), w = {
2485
- center: E,
2486
- depth: y[2] * d,
2487
- rx: l.head.rx * M,
2488
- ry: l.head.ry * M,
2489
- angle: Math.atan2(A[1][0], A[1][1]),
2490
- axes: A
2491
- }, S = e.contacts.map((k) => ({ spec: k, point: m(u(k)).point }));
2485
+ const S = s.toView(c), k = s.toScreen(S), v = s.toScreen([S[0] + 1, S[1], S[2]]), H = Math.hypot(v.x - k.x, v.y - k.y), T = i.head.axes.map((y) => Dn(kt(s.toView(he(c, y)), S))), M = {
2486
+ center: k,
2487
+ depth: S[2] * d,
2488
+ rx: l.head.rx * H,
2489
+ ry: l.head.ry * H,
2490
+ angle: Math.atan2(T[1][0], T[1][1]),
2491
+ axes: T
2492
+ }, w = e.contacts.map((y) => ({ spec: y, point: m(u(y)).point }));
2492
2493
  return {
2493
2494
  height: o * d,
2494
2495
  view: r,
2495
2496
  chains: b,
2496
- head: w,
2497
+ head: M,
2497
2498
  hip: f,
2498
- contacts: S,
2499
- groundY: Math.max(...S.map((k) => k.point.y))
2499
+ contacts: w,
2500
+ groundY: Math.max(...w.map((y) => y.point.y))
2500
2501
  };
2501
2502
  }
2502
- function Cn(e, [t, n, s]) {
2503
+ function Gn(e, [t, n, s]) {
2503
2504
  const [o, r, l] = e.axes, i = [
2504
2505
  o[0] * t * e.rx + r[0] * n * e.ry + l[0] * s * e.rx,
2505
2506
  o[1] * t * e.rx + r[1] * n * e.ry + l[1] * s * e.rx,
@@ -2507,93 +2508,93 @@ function Cn(e, [t, n, s]) {
2507
2508
  ], a = Math.hypot(t, n, s) || 1, h = (o[2] * t + r[2] * n + l[2] * s) / a;
2508
2509
  return { point: { x: e.center.x + i[0], y: e.center.y - i[1] }, depth: e.depth + i[2], facing: h };
2509
2510
  }
2510
- const $e = (e) => e * 180 / Math.PI, me = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], lt = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], Te = (e) => Math.hypot(e[0], e[1], e[2]), St = (e) => {
2511
+ const Be = (e) => e * 180 / Math.PI, me = (e, t) => [e[0] - t[0], e[1] - t[1], e[2] - t[2]], lt = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], Te = (e) => Math.hypot(e[0], e[1], e[2]), St = (e) => {
2511
2512
  const t = Te(e) || 1;
2512
2513
  return [e[0] / t, e[1] / t, e[2] / t];
2513
- }, Be = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2514
+ }, Fe = (e) => Math.atan2(Math.sin(e), Math.cos(e));
2514
2515
  function nn(e) {
2515
2516
  const [t, n, s] = St(e);
2516
2517
  return { swing: Math.asin(Math.max(-1, Math.min(1, s))), spread: Math.atan2(t, -n) };
2517
2518
  }
2518
- function sr(e, t, n, s, o) {
2519
- const r = e.chains.find((x) => x.id === n);
2519
+ function ar(e, t, n, s, o) {
2520
+ const r = e.chains.find((A) => A.id === n);
2520
2521
  if (!r) throw new Error(`reach: no chain ${n} in ${e.id}`);
2521
2522
  if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
2522
2523
  if (!e.withAngles) throw new Error(`reach: the ${e.id} plan cannot set angles`);
2523
- const l = It(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), i = l.chains[n], a = i.joints3[0], h = Te(me(i.joints3[1], i.joints3[0])), c = Te(me(i.joints3[2], i.joints3[1])), u = r.parent ? l.chains[r.parent].frames[Math.max(0, (r.at ?? l.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, g = me(s, a), f = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, Te(g))), p = St(g), d = r.parent !== null, m = De(r.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), u);
2524
+ const l = It(e, { ...t, turn: 0, roll: 0, lift: 0 }, { height: o.height, contact: "none" }), i = l.chains[n], a = i.joints3[0], h = Te(me(i.joints3[1], i.joints3[0])), c = Te(me(i.joints3[2], i.joints3[1])), u = r.parent ? l.chains[r.parent].frames[Math.max(0, (r.at ?? l.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, g = me(s, a), f = Math.min(h + c - 1e-6, Math.max(Math.abs(h - c) + 1e-6, Te(g))), p = St(g), d = r.parent !== null, m = Xe(r.pole ?? (d ? [0, -0.35, -1] : [0, 0, 1]), u);
2524
2525
  let b = me(m, [p[0] * lt(m, p), p[1] * lt(m, p), p[2] * lt(m, p)]);
2525
2526
  Te(b) < 1e-6 && (b = ge([1, 0, 0], 0)), b = St(b);
2526
- const y = (h * h + f * f - c * c) / (2 * h * f), E = Math.sqrt(Math.max(0, 1 - y * y)), H = [
2527
- a[0] + h * (y * p[0] + E * b[0]),
2528
- a[1] + h * (y * p[1] + E * b[1]),
2529
- a[2] + h * (y * p[2] + E * b[2])
2530
- ], M = [a[0] + p[0] * f, a[1] + p[1] * f, a[2] + p[2] * f], A = r.side ?? 1, w = nn(me(H, a)), S = nn(me(M, H)), k = [
2531
- { swing: $e(Be(w.swing - u.swing)), spread: $e(Be(w.spread - u.spread)) * A },
2532
- { swing: $e(Be(S.swing - w.swing)), spread: $e(Be(S.spread - w.spread)) * A }
2527
+ const S = (h * h + f * f - c * c) / (2 * h * f), k = Math.sqrt(Math.max(0, 1 - S * S)), v = [
2528
+ a[0] + h * (S * p[0] + k * b[0]),
2529
+ a[1] + h * (S * p[1] + k * b[1]),
2530
+ a[2] + h * (S * p[2] + k * b[2])
2531
+ ], H = [a[0] + p[0] * f, a[1] + p[1] * f, a[2] + p[2] * f], T = r.side ?? 1, M = nn(me(v, a)), w = nn(me(H, v)), y = [
2532
+ { swing: Be(Fe(M.swing - u.swing)), spread: Be(Fe(M.spread - u.spread)) * T },
2533
+ { swing: Be(Fe(w.swing - M.swing)), spread: Be(Fe(w.spread - M.spread)) * T }
2533
2534
  ];
2534
- return e.withAngles(t, r, k);
2535
+ return e.withAngles(t, r, y);
2535
2536
  }
2536
- const rr = 0.34, ie = 0.12, oe = -0.4, re = (e, t, n) => e[t] ?? n, ir = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), lr = 0.45, ar = 0.35, hr = 0.7;
2537
+ const hr = 0.34, ie = 0.12, oe = -0.4, re = (e, t, n) => e[t] ?? n, cr = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), fr = 0.45, ur = 0.35, dr = 0.7;
2537
2538
  function Je(e, t, n) {
2538
- const s = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), o = Cn(e, [n.x, n.y, s(n)]).facing, r = e.axes[2], l = Math.atan2(r[0], r[2]), i = Math.cos(l), a = i >= 0 ? 1 : -1, h = a * Math.max(ar, Math.abs(i)), c = a * Math.max(hr, Math.abs(i)), u = Math.cos(e.angle), g = Math.sin(e.angle);
2539
+ const s = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), o = Gn(e, [n.x, n.y, s(n)]).facing, r = e.axes[2], l = Math.atan2(r[0], r[2]), i = Math.cos(l), a = i >= 0 ? 1 : -1, h = a * Math.max(ur, Math.abs(i)), c = a * Math.max(dr, Math.abs(i)), u = Math.cos(e.angle), g = Math.sin(e.angle);
2539
2540
  return {
2540
2541
  facing: o,
2541
2542
  points: t.map((f) => {
2542
- const p = lr * Math.sin(l) + n.x * h + (f.x - n.x) * c, d = f.y + r[1] * s(f), m = p * e.rx, b = d * e.ry;
2543
+ const p = fr * Math.sin(l) + n.x * h + (f.x - n.x) * c, d = f.y + r[1] * s(f), m = p * e.rx, b = d * e.ry;
2543
2544
  return { x: e.center.x + m * u + b * g, y: e.center.y + m * g - b * u };
2544
2545
  })
2545
2546
  };
2546
2547
  }
2547
- const Fe = (e, t, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
2548
+ const Re = (e, t, n, s = 12) => Array.from({ length: s + 1 }, (o, r) => {
2548
2549
  const l = r / s, i = 1 - l;
2549
2550
  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 };
2550
2551
  }), at = (e, t, n, s, o = 16) => Array.from({ length: o }, (r, l) => {
2551
2552
  const i = Math.PI * 2 * l / o;
2552
2553
  return { x: e + Math.cos(i) * n, y: t + Math.sin(i) * s };
2553
2554
  }), on = 0.05;
2554
- function cr(e, t, n, s) {
2555
- const o = Math.max(1, Math.min(s * 0.6, 0.14 * t.rx)), r = (b, y) => Je(t, b, y).points, l = (b, y) => Je(t, [], { x: b, y }).facing, i = re(n, "smile", 0), a = re(n, "blink", 0), h = re(n, "lookX", 0), c = re(n, "lookY", 0), u = re(n, "browTilt", 0);
2555
+ function gr(e, t, n, s) {
2556
+ const o = Math.max(1, Math.min(s * 0.6, 0.14 * t.rx)), r = (b, S) => Je(t, b, S).points, l = (b, S) => Je(t, [], { x: b, y: S }).facing, i = re(n, "smile", 0), a = re(n, "blink", 0), h = re(n, "lookX", 0), c = re(n, "lookY", 0), u = re(n, "browTilt", 0);
2556
2557
  for (const b of [1, -1]) {
2557
- const y = b === 1 ? "left" : "right", E = rr * b;
2558
- if (l(E, ie) < on) continue;
2559
- const H = { x: E, y: ie }, M = ir(re(n, `eye.${y}`, 1), a);
2560
- if (M < 0.2) {
2561
- const k = i > 0.5 ? 0.12 : -0.06;
2562
- e.line(r(Fe({ x: E - 0.12, y: ie }, { x: E, y: ie + k }, { x: E + 0.12, y: ie }), H), o);
2558
+ const S = b === 1 ? "left" : "right", k = hr * b;
2559
+ if (l(k, ie) < on) continue;
2560
+ const v = { x: k, y: ie }, H = cr(re(n, `eye.${S}`, 1), a);
2561
+ if (H < 0.2) {
2562
+ const y = i > 0.5 ? 0.12 : -0.06;
2563
+ e.line(r(Re({ x: k - 0.12, y: ie }, { x: k, y: ie + y }, { x: k + 0.12, y: ie }), v), o);
2563
2564
  } else {
2564
- if (M > 1.2) {
2565
- const T = 0.13 * M;
2566
- e.shape(r(at(E, ie, T * 0.85, T), H), "#ffffff", o);
2565
+ if (H > 1.2) {
2566
+ const E = 0.13 * H;
2567
+ e.shape(r(at(k, ie, E * 0.85, E), v), "#ffffff", o);
2567
2568
  }
2568
- const k = M > 1.2 ? 0.075 : 0.1, x = E + h * 0.08, v = ie - c * 0.07;
2569
- e.shape(r(at(x, v, k, k * 1.1 * Math.min(M, 1)), H), e.ink, 0);
2569
+ const y = H > 1.2 ? 0.075 : 0.1, A = k + h * 0.08, x = ie - c * 0.07;
2570
+ e.shape(r(at(A, x, y, y * 1.1 * Math.min(H, 1)), v), e.ink, 0);
2570
2571
  }
2571
- const A = ie + 0.3 + re(n, `brow.${y}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, w = { x: E + b * 0.13, y: A }, S = { x: E - b * 0.13, y: A + u * 0.1 };
2572
- e.line(r([w, { x: (w.x + S.x) / 2, y: (w.y + S.y) / 2 }, S], { x: E, y: A }), o);
2572
+ const T = ie + 0.3 + re(n, `brow.${S}`, 0) * 0.14 + Math.max(0, H - 1) * 0.12, M = { x: k + b * 0.13, y: T }, w = { x: k - b * 0.13, y: T + u * 0.1 };
2573
+ e.line(r([M, { x: (M.x + w.x) / 2, y: (M.y + w.y) / 2 }, w], { x: k, y: T }), o);
2573
2574
  }
2574
2575
  const g = { x: 0, y: oe };
2575
2576
  if (l(0, oe) < -on) return;
2576
2577
  const f = 0.25 * Math.max(0.3, re(n, "mouthWidth", 1)), p = Math.min(1, Math.max(0, re(n, "mouth", 0)));
2577
2578
  if (p <= 0.05) {
2578
- e.line(r(Fe({ x: -f, y: oe }, { x: 0, y: oe - i * 0.25 }, { x: f, y: oe }), g), o);
2579
+ e.line(r(Re({ x: -f, y: oe }, { x: 0, y: oe - i * 0.25 }, { x: f, y: oe }), g), o);
2579
2580
  return;
2580
2581
  }
2581
2582
  const d = 0.3 * p;
2582
2583
  let m;
2583
2584
  if (i > 0.3) {
2584
2585
  const b = oe + 0.05;
2585
- m = [...Fe({ x: f, y: b }, { x: 0, y: oe - d * 2 }, { x: -f, y: b })];
2586
+ m = [...Re({ x: f, y: b }, { x: 0, y: oe - d * 2 }, { x: -f, y: b })];
2586
2587
  } else if (i < -0.3) {
2587
2588
  const b = oe - d * 0.6;
2588
- m = [...Fe({ x: f, y: b }, { x: 0, y: oe + d * 1.4 }, { x: -f, y: b })];
2589
+ m = [...Re({ x: f, y: b }, { x: 0, y: oe + d * 1.4 }, { x: -f, y: b })];
2589
2590
  } else
2590
2591
  m = at(0, oe, f * 0.8, d);
2591
2592
  e.shape(r(m, g), e.ink, 0);
2592
2593
  }
2593
- function fr(e = {}) {
2594
+ function pr(e = {}) {
2594
2595
  const t = (e.proportions ?? "bold") === "bold", n = e.figure ?? "fluid", s = e.look ?? "clean", o = e.height ?? 300, r = n === "stick";
2595
2596
  return {
2596
- plan: e.plan ?? er({
2597
+ plan: e.plan ?? sr({
2597
2598
  headSize: e.headSize ?? (t ? 0.3 : 0.24),
2598
2599
  shoulderWidth: r ? 0 : e.shoulderWidth ?? 0.06,
2599
2600
  hipWidth: r ? 0 : e.hipWidth ?? 0.022
@@ -2613,16 +2614,16 @@ function fr(e = {}) {
2613
2614
  handSize: e.handSize ?? (e.handStyle === "natural" ? 0.14 : 0.17)
2614
2615
  };
2615
2616
  }
2616
- function Ki(e, t, n, s) {
2617
- const { point: o, facing: r } = Cn(e, [t, n, s]);
2617
+ function Ii(e, t, n, s) {
2618
+ const { point: o, facing: r } = Gn(e, [t, n, s]);
2618
2619
  return { point: o, facing: r };
2619
2620
  }
2620
- const Et = (e) => e.rest[1] < -0.5, ur = 0.3;
2621
- function dr(e, t, n) {
2622
- return e.figure === "stick" ? Et(t) ? n.slice(0, 3) : n : Et(t) && n.length >= 3 ? ke(n[0], n[1], n[2], ur) : n.length === 3 ? ke(n[0], n[1], n[2], 1) : n;
2621
+ const Et = (e) => e.rest[1] < -0.5, mr = 0.3;
2622
+ function br(e, t, n) {
2623
+ return e.figure === "stick" ? Et(t) ? n.slice(0, 3) : n : Et(t) && n.length >= 3 ? Se(n[0], n[1], n[2], mr) : n.length === 3 ? Se(n[0], n[1], n[2], 1) : n;
2623
2624
  }
2624
2625
  function _t(e, t) {
2625
- const n = e.plan.id === "human" ? { ...X, ...t } : t;
2626
+ const n = e.plan.id === "human" ? { ...G, ...t } : t;
2626
2627
  return $t(e, n, It(e.plan, n, { height: e.height, contact: e.contact }));
2627
2628
  }
2628
2629
  function $t(e, t, n) {
@@ -2630,8 +2631,8 @@ function $t(e, t, n) {
2630
2631
  e.plan.chains.forEach((g) => {
2631
2632
  const f = n.chains[g.id];
2632
2633
  s[g.id] = f.points;
2633
- const p = f.depths.reduce((y, E) => y + E, 0) / f.depths.length, d = g.parent ? n.chains[g.parent] : void 0, m = d ? d.depths[g.at ?? d.depths.length - 1] : 0, b = p - m;
2634
- r[g.id] = Math.abs(b) < l ? 0 : b, o[g.id] = { points: dr(e, g, f.points), depth: p };
2634
+ const p = f.depths.reduce((S, k) => S + k, 0) / f.depths.length, d = g.parent ? n.chains[g.parent] : void 0, m = d ? d.depths[g.at ?? d.depths.length - 1] : 0, b = p - m;
2635
+ r[g.id] = Math.abs(b) < l ? 0 : b, o[g.id] = { points: br(e, g, f.points), depth: p };
2635
2636
  }), o.head = { points: [n.head.center], depth: n.head.depth }, r.head = 0;
2636
2637
  const i = [...e.plan.chains.map((g) => g.id), "head"], a = [...i].sort((g, f) => r[g] - r[f] || i.indexOf(g) - i.indexOf(f)), h = { hip: n.hip };
2637
2638
  for (const [g, [f, p]] of Object.entries(e.plan.landmarks ?? {})) {
@@ -2653,10 +2654,10 @@ function $t(e, t, n) {
2653
2654
  };
2654
2655
  return { skeleton: n, joints: u, order: a };
2655
2656
  }
2656
- function gr(e, t) {
2657
+ function wr(e, t) {
2657
2658
  return _t(e, t).joints;
2658
2659
  }
2659
- function pr(e, t, n) {
2660
+ function yr(e, t, n) {
2660
2661
  const { head: s } = n;
2661
2662
  e.guideEllipse(s.center.x, s.center.y, s.rx * 1.03, s.ry * 1.03, s.angle);
2662
2663
  const o = Array.from({ length: 13 }, (a, h) => ({ x: 0, y: -0.95 + 1.9 * h / 12 })), r = Array.from({ length: 13 }, (a, h) => ({ x: -0.95 + 1.9 * h / 12, y: 0.12 })), l = Je(s, o, { x: 0, y: 0 });
@@ -2667,11 +2668,11 @@ function pr(e, t, n) {
2667
2668
  h && e.guideEllipse(h.x, h.y, i, i, 0);
2668
2669
  }
2669
2670
  }
2670
- function mr(e, t, n, s, o, r) {
2671
+ function kr(e, t, n, s, o, r) {
2671
2672
  const l = n.lineWidth;
2672
2673
  if (o === "head") {
2673
2674
  const { head: f } = s, p = n.skin === "none" ? null : n.skin;
2674
- t.ellipse(f.center.x, f.center.y, f.rx, f.ry, f.angle, p, l), t.look !== "silhouette" && cr(t, f, r, l);
2675
+ t.ellipse(f.center.x, f.center.y, f.rx, f.ry, f.angle, p, l), t.look !== "silhouette" && gr(t, f, r, l);
2675
2676
  return;
2676
2677
  }
2677
2678
  const i = n.plan.chains.find((f) => f.id === o), a = s.chains[o], h = s.parts[o].points;
@@ -2687,7 +2688,7 @@ function mr(e, t, n, s, o, r) {
2687
2688
  if (t.limb(h, f, p), i.bones.length >= 3)
2688
2689
  t.limb([a[2], a[3]], i.bones[2].width[0] * l, i.bones[2].width[1] * l);
2689
2690
  else if (n.hands === "cartoon" && o.startsWith("arm."))
2690
- wr(e, t, n, a, o.endsWith(".left") ? "left" : "right", r);
2691
+ Er(e, t, n, a, o.endsWith(".left") ? "left" : "right", r);
2691
2692
  else {
2692
2693
  const d = a[a.length - 1];
2693
2694
  t.dot(d.x, d.y, l * 0.62);
@@ -2699,22 +2700,22 @@ function mr(e, t, n, s, o, r) {
2699
2700
  f && p && Math.hypot(f.x - p.x, f.y - p.y) > 0.5 && t.limb([f, p], l * 1.3, l * 1.3);
2700
2701
  const [d, m] = c(0, i.bones.length - 1);
2701
2702
  t.limb(h, d, m);
2702
- const b = s.points["shoulder.left"], y = s.points["shoulder.right"];
2703
- b && y && Math.hypot(b.x - y.x, b.y - y.y) > 0.5 && t.limb(ke(b, a[a.length - 1], y, 1, 10), l * 1.15, l * 1.15);
2703
+ const b = s.points["shoulder.left"], S = s.points["shoulder.right"];
2704
+ b && S && Math.hypot(b.x - S.x, b.y - S.y) > 0.5 && t.limb(Se(b, a[a.length - 1], S, 1, 10), l * 1.15, l * 1.15);
2704
2705
  return;
2705
2706
  }
2706
2707
  const [u, g] = c(0, i.bones.length - 1);
2707
2708
  t.limb(h, u, g);
2708
2709
  }
2709
- function br(e, t) {
2710
+ function Sr(e, t) {
2710
2711
  const n = `hand.${t}.`, s = {};
2711
2712
  for (const [l, i] of Object.entries(e)) l.startsWith(n) && (s[l.slice(n.length)] = i);
2712
2713
  const o = e.turn ?? 0, r = t === "right" ? 1 - o : 1 + o;
2713
- return { ...L, ...s, turn: r + (s.turn ?? 0) };
2714
+ return { ...N, ...s, turn: r + (s.turn ?? 0) };
2714
2715
  }
2715
- function wr(e, t, n, s, o, r) {
2716
+ function Er(e, t, n, s, o, r) {
2716
2717
  const l = s[s.length - 1], i = s[s.length - 2], a = Math.atan2(l.x - i.x, -(l.y - i.y)) * 180 / Math.PI;
2717
- Tt(e, l, br(r, o), {
2718
+ Tt(e, l, Sr(r, o), {
2718
2719
  size: n.handSize * n.height,
2719
2720
  side: o,
2720
2721
  angle: a,
@@ -2727,24 +2728,24 @@ function wr(e, t, n, s, o, r) {
2727
2728
  lineWidth: n.lineWidth * 0.3
2728
2729
  });
2729
2730
  }
2730
- function yr(e, t, n, s = 0) {
2731
- const o = t.plan.id === "human" ? { ...X, ...n } : n;
2732
- Xn(e, t, o, _t(t, o), s);
2731
+ function Mr(e, t, n, s = 0) {
2732
+ const o = t.plan.id === "human" ? { ...G, ...n } : n;
2733
+ zn(e, t, o, _t(t, o), s);
2733
2734
  }
2734
- function Dn(e, t) {
2735
+ function Un(e, t) {
2735
2736
  const n = t / e.height;
2736
2737
  return { ...e, height: t, lineWidth: e.lineWidth * n };
2737
2738
  }
2738
- function Pi(e, t, n, s) {
2739
- const o = e.plan.id === "human" ? { ...X, ...t } : t, r = Yn(e.plan, o, { height: s.height, contact: e.contact }, n);
2740
- return $t(Dn(e, r.height), o, r).joints;
2739
+ function _i(e, t, n, s) {
2740
+ const o = e.plan.id === "human" ? { ...G, ...t } : t, r = qn(e.plan, o, { height: s.height, contact: e.contact }, n);
2741
+ return $t(Un(e, r.height), o, r).joints;
2741
2742
  }
2742
- function kr(e, t, n, s, o) {
2743
- const r = t.plan.id === "human" ? { ...X, ...n } : n, l = Yn(t.plan, r, { height: o.height, contact: t.contact }, s), i = Dn(t, l.height);
2744
- Xn(e, i, r, $t(i, r, l), o.time ?? 0);
2743
+ function Hr(e, t, n, s, o) {
2744
+ const r = t.plan.id === "human" ? { ...G, ...n } : n, l = qn(t.plan, r, { height: o.height, contact: t.contact }, s), i = Un(t, l.height);
2745
+ zn(e, i, r, $t(i, r, l), o.time ?? 0);
2745
2746
  }
2746
- function Xn(e, t, n, s, o) {
2747
- const { joints: r, order: l } = s, i = bn(e, {
2747
+ function zn(e, t, n, s, o) {
2748
+ const { joints: r, order: l } = s, i = Sn(e, {
2748
2749
  look: t.look,
2749
2750
  ink: t.ink,
2750
2751
  lineWidth: t.lineWidth,
@@ -2754,14 +2755,14 @@ function Xn(e, t, n, s, o) {
2754
2755
  }), a = (h) => {
2755
2756
  h && (e.save(), h(e, r, i, o), e.restore());
2756
2757
  };
2757
- e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && pr(i, t, r), a(t.layers.behind);
2758
+ e.save(), e.lineCap = "round", e.lineJoin = "round", t.look === "pencil" && t.pencil.construction !== !1 && yr(i, t, r), a(t.layers.behind);
2758
2759
  for (const h of l) {
2759
2760
  const c = t.layers.parts?.[h];
2760
- a(c?.under), mr(e, i, t, r, h, n), a(c?.over);
2761
+ a(c?.under), kr(e, i, t, r, h, n), a(c?.over);
2761
2762
  }
2762
2763
  a(t.layers.front), e.restore();
2763
2764
  }
2764
- function Wi(e, t, n) {
2765
+ function $i(e, t, n) {
2765
2766
  const s = { ...e };
2766
2767
  for (const [o, r] of Object.entries(t)) {
2767
2768
  const l = e[o] ?? r;
@@ -2769,8 +2770,8 @@ function Wi(e, t, n) {
2769
2770
  }
2770
2771
  return s;
2771
2772
  }
2772
- function Oi(e, t, n, s) {
2773
- const o = e.plan.id === "human" ? { ...X, ...t } : t;
2773
+ function Bi(e, t, n, s) {
2774
+ const o = e.plan.id === "human" ? { ...G, ...t } : t;
2774
2775
  let r;
2775
2776
  if (Array.isArray(s))
2776
2777
  r = s;
@@ -2778,10 +2779,10 @@ function Oi(e, t, n, s) {
2778
2779
  const { skeleton: l } = _t(e, o), i = It(e.plan, { ...o, roll: 0 }, { height: e.height, contact: "none" }), a = (o.roll ?? 0) * Math.PI / 180, h = s.x - l.hip.x, c = s.y - l.hip.y, u = i.hip.x + h * Math.cos(-a) - c * Math.sin(-a), g = i.hip.y + h * Math.sin(-a) + c * Math.cos(-a), f = Math.PI / 2 * (o.turn ?? 0), p = s.depth ?? l.chains[n].depths[l.chains[n].depths.length - 1], d = Math.cos(f), m = Math.sin(f);
2779
2780
  r = [u * d - p * m, -g, u * m + p * d];
2780
2781
  }
2781
- return sr(e.plan, o, n, r, { height: e.height });
2782
+ return ar(e.plan, o, n, r, { height: e.height });
2782
2783
  }
2783
- function Ii(e) {
2784
- const { character: t } = e, n = t.height * 0.8, s = t.height, o = t.plan.id === "human" ? X : {};
2784
+ function Fi(e) {
2785
+ const { character: t } = e, n = t.height * 0.8, s = t.height, o = t.plan.id === "human" ? G : {};
2785
2786
  return {
2786
2787
  type: "custom",
2787
2788
  x: e.x - n / 2,
@@ -2791,11 +2792,11 @@ function Ii(e) {
2791
2792
  props: { ...o, ...e.pose },
2792
2793
  character: t,
2793
2794
  draw(r, l, i) {
2794
- r.translate(n / 2, s), yr(r, t, l.props, i);
2795
+ r.translate(n / 2, s), Mr(r, t, l.props, i);
2795
2796
  }
2796
2797
  };
2797
2798
  }
2798
- function Sr(e, t, n) {
2799
+ function vr(e, t, n) {
2799
2800
  const s = (r) => ({ x: r.x + t, y: r.y + n }), o = (r) => Object.fromEntries(Object.entries(r).map(([l, i]) => [l, i.map(s)]));
2800
2801
  return {
2801
2802
  ...e,
@@ -2806,25 +2807,25 @@ function Sr(e, t, n) {
2806
2807
  groundY: e.groundY + n
2807
2808
  };
2808
2809
  }
2809
- function _i(e, t, n) {
2810
+ function Ri(e, t, n) {
2810
2811
  const s = e.character;
2811
2812
  if (!s) throw new Error("characterAt: the target was not made by characterTarget");
2812
2813
  const o = { ...e.props };
2813
2814
  let r = 0, l = 0;
2814
2815
  for (const [a, h] of t.state?.values.get(n) ?? [])
2815
2816
  typeof h == "number" && (a === "x" || a === "motionPathX" ? r = h : a === "y" || a === "motionPathY" ? l = h : a in o && (o[a] = h));
2816
- const i = gr(s, o);
2817
- return { pose: o, joints: Sr(i, e.x + r + e.width / 2, e.y + l + e.height) };
2817
+ const i = wr(s, o);
2818
+ return { pose: o, joints: vr(i, e.x + r + e.width / 2, e.y + l + e.height) };
2818
2819
  }
2819
- function qn(e, t = X) {
2820
+ function Vn(e, t = G) {
2820
2821
  const n = [];
2821
2822
  return e.forEach((s, o) => {
2822
- const r = o === 0 ? t : n[o - 1], l = typeof s.pose == "string" ? Qs[s.pose] : void 0;
2823
+ const r = o === 0 ? t : n[o - 1], l = typeof s.pose == "string" ? or[s.pose] : void 0;
2823
2824
  n.push(l ? { ...l, turn: r.turn ?? 0 } : { ...r, ...s.pose });
2824
2825
  }), n;
2825
2826
  }
2826
- function $i(e, t, n = X) {
2827
- const s = qn(t, n);
2827
+ function Li(e, t, n = G) {
2828
+ const s = Vn(t, n);
2828
2829
  return Object.keys(n).filter((r) => s.some((l) => (l[r] ?? n[r]) !== n[r])).map((r) => ({
2829
2830
  id: `${e}-${r}`,
2830
2831
  target: e,
@@ -2836,7 +2837,7 @@ function $i(e, t, n = X) {
2836
2837
  }))
2837
2838
  }));
2838
2839
  }
2839
- const Er = /* @__PURE__ */ new Set([
2840
+ const Tr = /* @__PURE__ */ new Set([
2840
2841
  "x",
2841
2842
  "y",
2842
2843
  "z",
@@ -2852,43 +2853,43 @@ const Er = /* @__PURE__ */ new Set([
2852
2853
  "visible",
2853
2854
  "opacity",
2854
2855
  "color"
2855
- ]), Mr = 1.7;
2856
- function Hr(e, t, n) {
2856
+ ]), Ar = 1.7;
2857
+ function xr(e, t, n) {
2857
2858
  const s = Array.from({ length: 24 }, (o, r) => {
2858
2859
  const l = r / 24 * Math.PI * 2, i = t.toView([Math.cos(l) * n, 0, Math.sin(l) * n * 0.8]);
2859
2860
  return i[2] < -1e-3 ? t.toScreen(i) : null;
2860
2861
  });
2861
2862
  s.some((o) => o === null) || (e.beginPath(), s.forEach((o, r) => r === 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());
2862
2863
  }
2863
- function vr(e) {
2864
+ function Pr(e) {
2864
2865
  const t = J.dot([0, 1, 0], e);
2865
- if (t > 0.999999) return D.identity();
2866
- if (t < -0.999999) return D.fromQuat(Ft.fromAxisAngle([1, 0, 0], 180));
2866
+ if (t > 0.999999) return q.identity();
2867
+ if (t < -0.999999) return q.fromQuat(Ft.fromAxisAngle([1, 0, 0], 180));
2867
2868
  const n = J.cross([0, 1, 0], e);
2868
- return D.fromQuat(Ft.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
2869
- }
2870
- function Tr(e, t, n, s, o) {
2871
- const r = e.solid ?? {}, l = r.outline === !1 ? void 0 : r.outline ?? { width: 2, color: "#0f172a" }, i = { color: r.color ?? "#475569", shading: r.shading ?? "toon", outline: l }, a = { color: r.skin ?? "#f2c49b", shading: r.shading ?? "toon", outline: l }, h = { color: "#0f172a", shading: "unlit" }, c = s.height * 0.034, u = [], g = (E, H, M) => u.push({ mesh: E, world: D.multiply(o, H), material: M }), f = (E, H, M) => g(t.sphere, D.compose(E, [0, 0, 0, 1], [H, H, H]), M);
2872
- for (const E of n.chains) {
2873
- const H = s.chains[E.id], M = E.id === "spine" ? 1.9 : 1;
2874
- E.bones.forEach((A, w) => {
2875
- const S = H[w], k = H[w + 1], x = J.distance(S, k), [v, T] = A.width ?? [1, 1], K = c * M * (v + T) / 2;
2876
- if (x > 1e-6) {
2877
- const P = J.lerp(S, k, 0.5), I = vr(J.normalize(J.subtract(k, S)));
2878
- g(t.cylinder, D.multiply(D.translation(P), D.multiply(I, D.scaling([K, x, K]))), i);
2869
+ return q.fromQuat(Ft.fromAxisAngle(n, Math.acos(t) * 180 / Math.PI));
2870
+ }
2871
+ function Kr(e, t, n, s, o) {
2872
+ const r = e.solid ?? {}, l = r.outline === !1 ? void 0 : r.outline ?? { width: 2, color: "#0f172a" }, i = { color: r.color ?? "#475569", shading: r.shading ?? "toon", outline: l }, a = { color: r.skin ?? "#f2c49b", shading: r.shading ?? "toon", outline: l }, h = { color: "#0f172a", shading: "unlit" }, c = s.height * 0.034, u = [], g = (k, v, H) => u.push({ mesh: k, world: q.multiply(o, v), material: H }), f = (k, v, H) => g(t.sphere, q.compose(k, [0, 0, 0, 1], [v, v, v]), H);
2873
+ for (const k of n.chains) {
2874
+ const v = s.chains[k.id], H = k.id === "spine" ? 1.9 : 1;
2875
+ k.bones.forEach((T, M) => {
2876
+ const w = v[M], y = v[M + 1], A = J.distance(w, y), [x, E] = T.width ?? [1, 1], P = c * H * (x + E) / 2;
2877
+ if (A > 1e-6) {
2878
+ const K = J.lerp(w, y, 0.5), I = Pr(J.normalize(J.subtract(y, w)));
2879
+ g(t.cylinder, q.multiply(q.translation(K), q.multiply(I, q.scaling([P, A, P]))), i);
2879
2880
  }
2880
- f(S, c * M * v, i), f(k, c * M * T, i);
2881
- }), E.id.startsWith("arm.") && f(H[H.length - 1], c * 1.5, a);
2881
+ f(w, c * H * x, i), f(y, c * H * E, i);
2882
+ }), k.id.startsWith("arm.") && f(v[v.length - 1], c * 1.5, a);
2882
2883
  }
2883
- const { center: p, rx: d, ry: m, axes: b } = s.head, y = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...p, 1];
2884
- g(t.sphere, D.multiply(y, D.scaling([d, m, d])), a);
2885
- for (const E of [-1, 1]) {
2886
- const H = J.normalize([E * 0.36, 0.15, 0.92]), M = J.add(p, J.add(J.add(J.scale(b[0], H[0] * d * 1.04), J.scale(b[1], H[1] * m * 1.04)), J.scale(b[2], H[2] * d * 1.04))), A = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...M, 1];
2887
- g(t.sphere, D.multiply(A, D.scaling([d * 0.11, m * 0.14, d * 0.03])), h);
2884
+ const { center: p, rx: d, ry: m, axes: b } = s.head, S = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...p, 1];
2885
+ g(t.sphere, q.multiply(S, q.scaling([d, m, d])), a);
2886
+ for (const k of [-1, 1]) {
2887
+ const v = J.normalize([k * 0.36, 0.15, 0.92]), H = J.add(p, J.add(J.add(J.scale(b[0], v[0] * d * 1.04), J.scale(b[1], v[1] * m * 1.04)), J.scale(b[2], v[2] * d * 1.04))), T = [...b[0], 0, ...b[1], 0, ...b[2], 0, ...H, 1];
2888
+ g(t.sphere, q.multiply(T, q.scaling([d * 0.11, m * 0.14, d * 0.03])), h);
2888
2889
  }
2889
2890
  return u;
2890
2891
  }
2891
- const Bi = {
2892
+ const Ni = {
2892
2893
  kind: "character",
2893
2894
  validate(e) {
2894
2895
  const t = e;
@@ -2896,24 +2897,24 @@ const Bi = {
2896
2897
  },
2897
2898
  prepare(e) {
2898
2899
  return {
2899
- who: fr({ ...e.character, height: 1 }),
2900
- cylinder: Rt(ro(1, 1, 16)),
2901
- sphere: Rt(so(1, 20))
2900
+ who: pr({ ...e.character, height: 1 }),
2901
+ cylinder: Rt(ho(1, 1, 16)),
2902
+ sphere: Rt(ao(1, 20))
2902
2903
  };
2903
2904
  },
2904
2905
  resolve({ object: e, prepared: t, values: n, world: s, camera: o, toScreen: r }) {
2905
- const l = e, i = t, a = i.who, h = { ...X, ...l.pose };
2906
+ const l = e, i = t, a = i.who, h = { ...G, ...l.pose };
2906
2907
  for (const [m, b] of n)
2907
- typeof b == "number" && !Er.has(m) && (h[m] = b);
2908
- const c = l.height ?? Mr, u = D.multiply(o.view, s), g = {
2909
- toView: (m) => D.transformPoint(u, m),
2908
+ typeof b == "number" && !Tr.has(m) && (h[m] = b);
2909
+ const c = l.height ?? Ar, u = q.multiply(o.view, s), g = {
2910
+ toView: (m) => q.transformPoint(u, m),
2910
2911
  toScreen: (m) => r(m)
2911
2912
  }, p = -g.toView([0, c / 2, 0])[2];
2912
2913
  if (p <= o.near) return null;
2913
- const d = l.shadow === !1 ? [] : [{ depth: p + c, draw: (m) => Hr(m, g, c * 0.18) }];
2914
+ const d = l.shadow === !1 ? [] : [{ depth: p + c, draw: (m) => xr(m, g, c * 0.18) }];
2914
2915
  if (l.look === "solid") {
2915
- const m = Nn(a.plan, h, { height: c, contact: a.contact });
2916
- return { meshes: Tr(l, i, a.plan, m, s), drawables: d };
2916
+ const m = Xn(a.plan, h, { height: c, contact: a.contact });
2917
+ return { meshes: Kr(l, i, a.plan, m, s), drawables: d };
2917
2918
  }
2918
2919
  return {
2919
2920
  drawables: [
@@ -2921,14 +2922,14 @@ const Bi = {
2921
2922
  {
2922
2923
  depth: p,
2923
2924
  draw(m, b) {
2924
- m.lineCap = "round", m.lineJoin = "round", kr(m, a, h, g, { height: c, time: b.time });
2925
+ m.lineCap = "round", m.lineJoin = "round", Hr(m, a, h, g, { height: c, time: b.time });
2925
2926
  }
2926
2927
  }
2927
2928
  ]
2928
2929
  };
2929
2930
  }
2930
2931
  };
2931
- function Ar(e, t, n = {}, s) {
2932
+ function Wr(e, t, n = {}, s) {
2932
2933
  const o = n.length ?? 240, r = 9, l = 28, i = o - 22;
2933
2934
  e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -30) * Math.PI / 180), e.fillStyle = n.color ?? "#f4c542", e.fillRect(l, -r, i - l, 2 * r), e.fillStyle = "#e8b4a0", e.fillRect(i, -r, o - i, 2 * r), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(l, -r), e.lineTo(l, r), e.closePath(), e.fill(), e.fillStyle = n.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(l * 0.35, -r * 0.35), e.lineTo(l * 0.35, r * 0.35), e.closePath(), e.fill(), e.strokeStyle = n.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
2934
2935
  const a = [
@@ -2936,10 +2937,10 @@ function Ar(e, t, n = {}, s) {
2936
2937
  [{ x: l, y: -r }, { x: l, y: r }],
2937
2938
  [{ x: i, y: -r }, { x: i, y: r }]
2938
2939
  ];
2939
- for (const h of a) Vn(e, h, s);
2940
+ for (const h of a) Qn(e, h, s);
2940
2941
  e.restore();
2941
2942
  }
2942
- function Gn(e, t, n = {}, s) {
2943
+ function jn(e, t, n = {}, s) {
2943
2944
  const o = n.length ?? 90, r = n.thickness ?? 34;
2944
2945
  e.save(), e.translate(t.x, t.y), e.rotate((n.angle ?? -35) * Math.PI / 180);
2945
2946
  const l = -r / 2;
@@ -2961,24 +2962,24 @@ function Gn(e, t, n = {}, s) {
2961
2962
  }
2962
2963
  e.restore();
2963
2964
  }
2964
- const Un = 150, xr = { pencil: 44, eraser: 30 };
2965
- function zn(e, t, n = {}, s) {
2966
- const o = n.tool ?? "pencil", r = 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 = s ? s.nudge(0.6) : { x: 0, y: 0 }, u = Un * i * (1 + 0.05 * a);
2965
+ const Jn = 150, Or = { pencil: 44, eraser: 30 };
2966
+ function Zn(e, t, n = {}, s) {
2967
+ const o = n.tool ?? "pencil", r = 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 = s ? s.nudge(0.6) : { x: 0, y: 0 }, u = Jn * i * (1 + 0.05 * a);
2967
2968
  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());
2968
- const g = { x: t.x + c.x + 6 * a * i, y: t.y + c.y - 18 * a * i }, f = C.pencilGrip, p = (w) => {
2969
- const S = w.fingers.thumb, k = w.fingers.index, x = w.fingers.middle, v = sn([S.points[3], k.points[3], x.points[3]]), T = sn([S.points[1], k.points[0]]), K = (S.depths[3] + k.depths[3] + x.depths[3]) / 3;
2970
- return { pinch: v, direction: Math.atan2(T.y - v.y, T.x - v.x), depth: K };
2971
- }, d = pt(f, { size: u }), m = h - p(d).direction, b = pt(f, { size: u, angle: m * 180 / Math.PI }), y = p(b), E = xr[o] * i, H = { x: y.pinch.x - Math.cos(h) * E, y: y.pinch.y - Math.sin(h) * E }, M = { x: g.x - H.x, y: g.y - H.y }, A = b.axes.up;
2972
- Kr(e, M, { x: -A.x, y: -A.y }, u, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", l), Tt(e, M, f, {
2969
+ const g = { x: t.x + c.x + 6 * a * i, y: t.y + c.y - 18 * a * i }, f = D.pencilGrip, p = (M) => {
2970
+ const w = M.fingers.thumb, y = M.fingers.index, A = M.fingers.middle, x = sn([w.points[3], y.points[3], A.points[3]]), E = sn([w.points[1], y.points[0]]), P = (w.depths[3] + y.depths[3] + A.depths[3]) / 3;
2971
+ return { pinch: x, direction: Math.atan2(E.y - x.y, E.x - x.x), depth: P };
2972
+ }, d = pt(f, { size: u }), m = h - p(d).direction, b = pt(f, { size: u, angle: m * 180 / Math.PI }), S = p(b), k = Or[o] * i, v = { x: S.pinch.x - Math.cos(h) * k, y: S.pinch.y - Math.sin(h) * k }, H = { x: g.x - v.x, y: g.y - v.y }, T = b.axes.up;
2973
+ Ir(e, H, { x: -T.x, y: -T.y }, u, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", l), Tt(e, H, f, {
2973
2974
  size: u,
2974
2975
  angle: m * 180 / Math.PI,
2975
2976
  skin: r,
2976
2977
  ink: l,
2977
2978
  lineWidth: 3 * i,
2978
2979
  prop: {
2979
- depth: y.depth,
2980
+ depth: S.depth,
2980
2981
  draw: () => {
2981
- e.save(), e.translate(g.x, g.y), e.scale(i, i), o === "eraser" ? Gn(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: l }, s) : Ar(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: l }, s), e.restore();
2982
+ e.save(), e.translate(g.x, g.y), e.scale(i, i), o === "eraser" ? jn(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, outline: l }, s) : Wr(e, { x: 0, y: 0 }, { angle: h * 180 / Math.PI, length: 190, outline: l }, s), e.restore();
2982
2983
  }
2983
2984
  }
2984
2985
  });
@@ -2987,19 +2988,19 @@ const sn = (e) => ({
2987
2988
  x: e.reduce((t, n) => t + n.x, 0) / e.length,
2988
2989
  y: e.reduce((t, n) => t + n.y, 0) / e.length
2989
2990
  });
2990
- function Kr(e, t, n, s, o, r, l, i) {
2991
+ function Ir(e, t, n, s, o, r, l, i) {
2991
2992
  const a = { x: -n.y, y: n.x }, h = s * 0.15, c = (d, m, b) => ({
2992
2993
  x: t.x + n.x * d + a.x * m * b,
2993
2994
  y: t.y + n.y * d + a.y * m * b
2994
2995
  }), u = c(o, 0, 0), g = (d) => {
2995
2996
  const m = e.createLinearGradient(t.x, t.y, u.x, u.y);
2996
- return m.addColorStop(0, d), m.addColorStop(0.6, d), m.addColorStop(1, Pr(d)), m;
2997
+ return m.addColorStop(0, d), m.addColorStop(0.6, d), m.addColorStop(1, _r(d)), m;
2997
2998
  }, f = Math.min(s * 0.55, o * 0.35);
2998
- e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (s / Un), e.beginPath(), e.moveTo(c(-s * 0.1, -1, h).x, c(-s * 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(-s * 0.1, 1, h).x, c(-s * 0.1, 1, h).y), e.closePath(), e.fillStyle = r, 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();
2999
+ e.save(), e.lineJoin = "round", e.lineCap = "round", e.lineWidth = 3 * (s / Jn), e.beginPath(), e.moveTo(c(-s * 0.1, -1, h).x, c(-s * 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(-s * 0.1, 1, h).x, c(-s * 0.1, 1, h).y), e.closePath(), e.fillStyle = r, 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();
2999
3000
  const p = [c(f, -1, h * 1.3), c(o, -1, h * 1.5), c(o, 1, h * 1.5), c(f, 1, h * 1.3)];
3000
3001
  e.beginPath(), p.forEach((d, m) => m ? e.lineTo(d.x, d.y) : e.moveTo(d.x, d.y)), e.closePath(), e.fillStyle = g(l), e.fill(), e.strokeStyle = g(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();
3001
3002
  }
3002
- function Fi(e, t, n = {}) {
3003
+ function Yi(e, t, n = {}) {
3003
3004
  const s = n.offstage ?? { x: 2e3, y: 1400 }, o = n.enter ?? 450, r = n.exit ?? 450, l = n.linger ?? 1500, i = [...e].filter((d) => d.path.length > 0).sort((d, m) => d.start - m.start), a = (d) => d.tool ?? "pencil", h = (d) => {
3004
3005
  const m = Math.min(1, Math.max(0, d));
3005
3006
  return m * m * (3 - 2 * m);
@@ -3023,7 +3024,7 @@ function Fi(e, t, n = {}) {
3023
3024
  }
3024
3025
  return null;
3025
3026
  }
3026
- function Ri(e, t, n, s = 0.08, o = 32) {
3027
+ function Ci(e, t, n, s = 0.08, o = 32) {
3027
3028
  const r = Math.PI * 2 * (1 + s), l = [];
3028
3029
  for (let i = 0; i <= o; i++) {
3029
3030
  const a = -Math.PI / 2 + r * i / o;
@@ -3031,7 +3032,7 @@ function Ri(e, t, n, s = 0.08, o = 32) {
3031
3032
  }
3032
3033
  return l;
3033
3034
  }
3034
- function Li(e) {
3035
+ function Di(e) {
3035
3036
  const { path: t } = e, n = t.map((i) => i.x), s = t.map((i) => i.y), o = Math.min(...n), r = Math.min(...s), l = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
3036
3037
  return {
3037
3038
  type: "custom",
@@ -3044,17 +3045,17 @@ function Li(e) {
3044
3045
  const c = Math.min(1, Math.max(0, Number(a.props?.draw ?? 0)));
3045
3046
  i.translate(-o, -r), i.strokeStyle = e.color ?? "#2f2f33", i.lineWidth = e.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
3046
3047
  const u = e.sketch ? ut(i, e.sketch, h) : void 0;
3047
- c > 0 && (u ? e.smooth ? u.curve(t, c) : u.line(t, c) : Vn(i, mn(t, c))), l && c > 0 && c < 1 && zn(i, Ht(t, c), l, u);
3048
+ c > 0 && (u ? e.smooth ? u.curve(t, c) : u.line(t, c) : Qn(i, kn(t, c))), l && c > 0 && c < 1 && Zn(i, Ht(t, c), l, u);
3048
3049
  }
3049
3050
  };
3050
3051
  }
3051
- function Pr(e) {
3052
+ function _r(e) {
3052
3053
  const t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
3053
3054
  if (!t) return "rgba(0, 0, 0, 0)";
3054
3055
  const n = t[1].length === 3 ? [...t[1]].map((l) => l + l).join("") : t[1], [s, o, r] = [0, 2, 4].map((l) => parseInt(n.slice(l, l + 2), 16));
3055
3056
  return `rgba(${s}, ${o}, ${r}, 0)`;
3056
3057
  }
3057
- function Vn(e, t, n) {
3058
+ function Qn(e, t, n) {
3058
3059
  if (!(t.length < 2)) {
3059
3060
  if (n) return n.line(t);
3060
3061
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
@@ -3062,17 +3063,17 @@ function Vn(e, t, n) {
3062
3063
  e.stroke();
3063
3064
  }
3064
3065
  }
3065
- const Re = 1e5;
3066
- function Ni(e, t, n, s, o = 6) {
3066
+ const Le = 1e5;
3067
+ function Xi(e, t, n, s, o = 6) {
3067
3068
  const r = [], l = Math.max(1, Math.round(o));
3068
3069
  for (let i = 0; i <= l; i++)
3069
3070
  r.push({ x: i % 2 === 0 ? e : e + n, y: t + s * i / l });
3070
3071
  return r;
3071
3072
  }
3072
- function jn(e, t, n, s) {
3073
+ function eo(e, t, n, s) {
3073
3074
  if (s <= 0 || t.length === 0) return;
3074
- const o = mn(t, s), r = n / 2, l = (i) => {
3075
- e.beginPath(), e.rect(-Re, -Re, 2 * Re, 2 * Re), i(), e.clip("evenodd");
3075
+ const o = kn(t, s), r = n / 2, l = (i) => {
3076
+ e.beginPath(), e.rect(-Le, -Le, 2 * Le, 2 * Le), i(), e.clip("evenodd");
3076
3077
  };
3077
3078
  for (const i of o)
3078
3079
  l(() => {
@@ -3087,35 +3088,35 @@ function jn(e, t, n, s) {
3087
3088
  });
3088
3089
  }
3089
3090
  }
3090
- function Yi(e, t, n, s, o) {
3091
- e.save(), jn(e, t, n, s), o(), e.restore();
3091
+ function qi(e, t, n, s, o) {
3092
+ e.save(), eo(e, t, n, s), o(), e.restore();
3092
3093
  }
3093
- function Ci(e, t) {
3094
+ function Gi(e, t) {
3094
3095
  const n = t.width ?? 40, s = t.hand === !0 ? {} : t.hand || void 0, o = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
3095
3096
  return {
3096
3097
  ...e,
3097
3098
  props: { ...e.props, erase: 0 },
3098
3099
  draw(r, l, i) {
3099
3100
  const a = Number(l.props?.erase ?? 0);
3100
- if (r.save(), jn(r, t.path, n, a), e.draw(r, l, i), r.restore(), !o || a <= 0 || a >= 1) return;
3101
+ if (r.save(), eo(r, t.path, n, a), e.draw(r, l, i), r.restore(), !o || a <= 0 || a >= 1) return;
3101
3102
  const h = Ht(t.path, a);
3102
- s ? zn(r, h, { ...s, tool: "eraser" }) : Gn(r, h, o);
3103
+ s ? Zn(r, h, { ...s, tool: "eraser" }) : jn(r, h, o);
3103
3104
  }
3104
3105
  };
3105
3106
  }
3106
- const Wr = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
3107
- function Di(e = {}) {
3107
+ const $r = (e, t, n) => e.slice(Math.floor((e.length - 1) * t), Math.ceil((e.length - 1) * n) + 1);
3108
+ function Ui(e = {}) {
3108
3109
  const t = e.shirt ?? "#e2493b", n = e.trousers ?? "#24476b", s = (i) => i.lineWidth * 0.45, o = (i, a, h) => {
3109
3110
  const c = i.parts[`leg.${h}`].points;
3110
- a.shape(Ye(c, i.height * 0.08, i.height * 0.05), n, s(i));
3111
+ a.shape(Ce(c, i.height * 0.08, i.height * 0.05), n, s(i));
3111
3112
  }, r = (i, a) => {
3112
3113
  const h = i.chains.spine, c = h[0], u = h[h.length - 1], g = { x: c.x - (u.x - c.x) * 0.25, y: c.y - (u.y - c.y) * 0.25 };
3113
- a.shape(Ye([g, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), t, s(i));
3114
+ a.shape(Ce([g, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), t, s(i));
3114
3115
  }, l = (i, a, h) => {
3115
- const c = i.parts[`arm.${h}`].points, u = c[0], g = i.chains.spine[i.chains.spine.length - 1], p = [{ x: u.x + (g.x - u.x) * 0.45, y: u.y + (g.y - u.y) * 0.45 }, ...Wr(c, 0, 0.45)], d = Ye(p, i.height * 0.085, i.height * 0.06), m = p.length, b = d.slice(0, m), y = d.slice(m).reverse();
3116
+ const c = i.parts[`arm.${h}`].points, u = c[0], g = i.chains.spine[i.chains.spine.length - 1], p = [{ x: u.x + (g.x - u.x) * 0.45, y: u.y + (g.y - u.y) * 0.45 }, ...$r(c, 0, 0.45)], d = Ce(p, i.height * 0.085, i.height * 0.06), m = p.length, b = d.slice(0, m), S = d.slice(m).reverse();
3116
3117
  a.shape(d, t, 0);
3117
- const E = (A) => Math.hypot(A[1].x - g.x, A[1].y - g.y), [H, M] = E(b) > E(y) ? [b, y] : [y, b];
3118
- a.line(H.slice(1), s(i)), a.line(M.slice(Math.ceil(m * 0.45)), s(i)), a.line([b[m - 1], y[m - 1]], s(i));
3118
+ const k = (T) => Math.hypot(T[1].x - g.x, T[1].y - g.y), [v, H] = k(b) > k(S) ? [b, S] : [S, b];
3119
+ a.line(v.slice(1), s(i)), a.line(H.slice(Math.ceil(m * 0.45)), s(i)), a.line([b[m - 1], S[m - 1]], s(i));
3119
3120
  };
3120
3121
  return {
3121
3122
  parts: {
@@ -3189,37 +3190,37 @@ const ht = {
3189
3190
  jumpSquash: 0
3190
3191
  }
3191
3192
  };
3192
- function Or(e) {
3193
+ function Br(e) {
3193
3194
  if (e === void 0) return ht.full;
3194
3195
  if (typeof e == "string") return ht[e];
3195
3196
  const { base: t, ...n } = e;
3196
3197
  return { ...ht[t ?? "full"], ...n };
3197
3198
  }
3198
- const Mt = 160, Ir = 120, _r = 700, ct = 60, $r = 90, Le = 3200, ye = 1, ue = 1e-6;
3199
- function Jn(e, t, n = {}) {
3200
- const s = Or(n.style), o = n.seed ?? 1, r = {};
3199
+ const Mt = 160, Fr = 120, Rr = 700, ct = 60, Lr = 90, Ne = 3200, ke = 1, ue = 1e-6;
3200
+ function to(e, t, n = {}) {
3201
+ const s = Br(n.style), o = n.seed ?? 1, r = {};
3201
3202
  if (e.length === 0) return r;
3202
3203
  const l = Object.keys(e[0].pose).filter((u) => e.some((g) => Math.abs(g.pose[u] - e[0].pose[u]) > ue));
3203
- for (const u of l) r[u] = Br(u, e, t, s, o);
3204
+ for (const u of l) r[u] = Nr(u, e, t, s, o);
3204
3205
  const i = t.blink, a = i !== void 0 && l.includes(i);
3205
3206
  if (s.blinks && i !== void 0 && !a && i in e[0].pose) {
3206
- const u = Fr(e, t, s, o, e[0].pose[i]);
3207
+ const u = Yr(e, t, s, o, e[0].pose[i]);
3207
3208
  u.length > 0 && (r[i] = u);
3208
3209
  }
3209
3210
  const { lift: h, stretch: c } = t;
3210
3211
  if (s.jumpSquash > 0 && h && c && l.includes(h) && !l.includes(c) && c in e[0].pose) {
3211
- const u = Rr(e, h, e[0].pose[c], s.jumpSquash);
3212
+ const u = Cr(e, h, e[0].pose[c], s.jumpSquash);
3212
3213
  u.length > 0 && (r[c] = u);
3213
3214
  }
3214
3215
  return r;
3215
3216
  }
3216
- function Br(e, t, n, s, o) {
3217
+ function Nr(e, t, n, s, o) {
3217
3218
  const r = n.eyes.includes(e), l = n.limits[e], i = l !== void 0, a = r ? -s.eyeLead : (n.depth[e] ?? 1) * s.overlap, h = (f) => {
3218
3219
  const p = (t[f].time - t[f - 1].time) / 2;
3219
3220
  return Math.max(-p, Math.min(p, a));
3220
3221
  }, c = [{ time: t[0].time, value: t[0].pose[e] }], u = (f, p, d) => {
3221
3222
  const m = c[c.length - 1];
3222
- if (f <= m.time + ye) {
3223
+ if (f <= m.time + ke) {
3223
3224
  c[c.length - 1] = { ...m, value: p, ...d ? { easing: d } : {} };
3224
3225
  return;
3225
3226
  }
@@ -3227,70 +3228,70 @@ function Br(e, t, n, s, o) {
3227
3228
  };
3228
3229
  let g = t[0].pose[e];
3229
3230
  for (let f = 1; f < t.length; f++) {
3230
- const p = t[f], d = t[f - 1].pose[e], m = p.pose[e], b = m - d, y = c[c.length - 1].time, E = p.act !== !1;
3231
+ const p = t[f], d = t[f - 1].pose[e], m = p.pose[e], b = m - d, S = c[c.length - 1].time, k = p.act !== !1;
3231
3232
  if (Math.abs(b) <= ue) {
3232
- const v = p.time + (E ? h(f) : 0);
3233
+ const x = p.time + (k ? h(f) : 0);
3233
3234
  if (f === t.length - 1)
3234
- Math.abs(g - m) > ue && u(Math.max(v, y + Mt), m, "ease-in-out"), g = m;
3235
- else if (E && i && s.drift > 0 && n.drift.includes(e) && v - y >= _r) {
3236
- const T = Ze(`${o}:${e}:${f}`) % 2 === 0 ? 1 : -1;
3237
- g = m + T * s.drift * l, u(v, g, "ease-in-out");
3235
+ Math.abs(g - m) > ue && u(Math.max(x, S + Mt), m, "ease-in-out"), g = m;
3236
+ else if (k && i && s.drift > 0 && n.drift.includes(e) && x - S >= Rr) {
3237
+ const E = Ze(`${o}:${e}:${f}`) % 2 === 0 ? 1 : -1;
3238
+ g = m + E * s.drift * l, u(x, g, "ease-in-out");
3238
3239
  }
3239
3240
  continue;
3240
3241
  }
3241
- if (!E) {
3242
+ if (!k) {
3242
3243
  u(t[f - 1].time, g), u(p.time, m, p.easing), g = m;
3243
3244
  continue;
3244
3245
  }
3245
- const H = h(f), M = Math.max(t[f - 1].time + H, y);
3246
- let A = p.time + H;
3247
- r && s.eyeDart > 0 && (A = Math.min(A, M + s.eyeDart));
3248
- const w = A - M;
3249
- if (w <= ye) {
3246
+ const v = h(f), H = Math.max(t[f - 1].time + v, S);
3247
+ let T = p.time + v;
3248
+ r && s.eyeDart > 0 && (T = Math.min(T, H + s.eyeDart));
3249
+ const M = T - H;
3250
+ if (M <= ke) {
3250
3251
  u(p.time, m, p.easing), g = m;
3251
3252
  continue;
3252
3253
  }
3253
- u(M, g);
3254
- const S = Math.sign(b);
3255
- if (i && s.anticipation > 0 && l > 0 && w >= Mt) {
3256
- const v = g - S * Math.min(Math.abs(b) * s.anticipation, l), T = M + w * s.anticipationTime;
3257
- u(T, v, "ease-in-out"), s.hold > 0 && u(T + w * s.hold, v);
3254
+ u(H, g);
3255
+ const w = Math.sign(b);
3256
+ if (i && s.anticipation > 0 && l > 0 && M >= Mt) {
3257
+ const x = g - w * Math.min(Math.abs(b) * s.anticipation, l), E = H + M * s.anticipationTime;
3258
+ u(E, x, "ease-in-out"), s.hold > 0 && u(E + M * s.hold, x);
3258
3259
  }
3259
- const k = f + 1 < t.length ? t[f + 1].time - p.time : 1 / 0, x = Math.min(s.settle, k / 2);
3260
- if (i && s.overshoot > 0 && l > 0 && w >= Ir && x > ye) {
3261
- const v = Math.min(Math.abs(b) * s.overshoot, l);
3262
- u(A, m + S * v, p.easing ?? s.actionEase), u(A + x, m, s.settleEase);
3260
+ const y = f + 1 < t.length ? t[f + 1].time - p.time : 1 / 0, A = Math.min(s.settle, y / 2);
3261
+ if (i && s.overshoot > 0 && l > 0 && M >= Fr && A > ke) {
3262
+ const x = Math.min(Math.abs(b) * s.overshoot, l);
3263
+ u(T, m + w * x, p.easing ?? s.actionEase), u(T + A, m, s.settleEase);
3263
3264
  } else
3264
- u(A, m, p.easing ?? s.actionEase);
3265
+ u(T, m, p.easing ?? s.actionEase);
3265
3266
  g = m;
3266
3267
  }
3267
3268
  return c;
3268
3269
  }
3269
- function Fr(e, t, n, s, o) {
3270
- const r = [], l = ct + $r;
3270
+ function Yr(e, t, n, s, o) {
3271
+ const r = [], l = ct + Lr;
3271
3272
  for (let f = 1; f < e.length; f++) {
3272
3273
  const p = e[f - 1].pose, d = e[f].pose;
3273
- Object.entries(t.headTurns).some(([b, y]) => Math.abs((d[b] ?? 0) - (p[b] ?? 0)) > y) && e[f].act !== !1 && r.push(Math.max(e[0].time, e[f - 1].time - n.eyeLead));
3274
+ Object.entries(t.headTurns).some(([b, S]) => Math.abs((d[b] ?? 0) - (p[b] ?? 0)) > S) && e[f].act !== !1 && r.push(Math.max(e[0].time, e[f - 1].time - n.eyeLead));
3274
3275
  }
3275
3276
  const i = e[0].time, a = e[e.length - 1].time, h = [...r];
3276
- let c = i + Le * 0.6, u = 0;
3277
+ let c = i + Ne * 0.6, u = 0;
3277
3278
  for (; c < a; ) {
3278
- h.some((d) => Math.abs(d - c) < Le / 2) || r.push(c);
3279
- const p = (Ze(`${s}:blink:${u++}`) % 1e3 / 1e3 - 0.5) * (Le * 0.66);
3280
- c += Le + p;
3279
+ h.some((d) => Math.abs(d - c) < Ne / 2) || r.push(c);
3280
+ const p = (Ze(`${s}:blink:${u++}`) % 1e3 / 1e3 - 0.5) * (Ne * 0.66);
3281
+ c += Ne + p;
3281
3282
  }
3282
3283
  r.sort((f, p) => f - p);
3283
3284
  const g = [{ time: i, value: o }];
3284
3285
  for (const f of r) {
3285
3286
  const p = g[g.length - 1].time;
3286
- f + ct <= p + ye || (f > p + ye && g.push({ time: f, value: o }), g.push({ time: f + ct, value: 1, easing: "ease-in" }), g.push({ time: f + l, value: o, easing: "ease-out" }));
3287
+ f + ct <= p + ke || (f > p + ke && g.push({ time: f, value: o }), g.push({ time: f + ct, value: 1, easing: "ease-in" }), g.push({ time: f + l, value: o, easing: "ease-out" }));
3287
3288
  }
3288
3289
  return g.length > 1 ? g : [];
3289
3290
  }
3290
- function Rr(e, t, n, s) {
3291
+ function Cr(e, t, n, s) {
3291
3292
  const o = n * (1 - 0.18 * s), r = n * (1 + 0.14 * s), l = [{ time: e[0].time, value: n }], i = (a, h, c) => {
3292
3293
  const u = l[l.length - 1];
3293
- a <= u.time + ye || l.push({ time: a, value: h, ...c ? { easing: c } : {} });
3294
+ a <= u.time + ke || l.push({ time: a, value: h, ...c ? { easing: c } : {} });
3294
3295
  };
3295
3296
  for (let a = 1; a < e.length; a++) {
3296
3297
  const h = e[a - 1].pose[t], c = e[a].pose[t], u = e[a - 1].time, g = e[a].time, f = g - u;
@@ -3305,7 +3306,7 @@ function Rr(e, t, n, s) {
3305
3306
  }
3306
3307
  return l.length > 1 ? l : [];
3307
3308
  }
3308
- const Lr = {
3309
+ const Dr = {
3309
3310
  depth: {
3310
3311
  lean: 0,
3311
3312
  bend: 0,
@@ -3371,13 +3372,13 @@ const Lr = {
3371
3372
  lift: "rise",
3372
3373
  stretch: "stretch"
3373
3374
  };
3374
- function Nr(e) {
3375
+ function Xr(e) {
3375
3376
  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 };
3376
3377
  }
3377
- function Yr() {
3378
+ function qr() {
3378
3379
  const e = {}, t = {};
3379
- for (const n of Object.keys(X)) {
3380
- const s = Nr(n);
3380
+ for (const n of Object.keys(G)) {
3381
+ const s = Xr(n);
3381
3382
  e[n] = s.depth, s.limit !== void 0 && (t[n] = s.limit);
3382
3383
  }
3383
3384
  return {
@@ -3391,19 +3392,19 @@ function Yr() {
3391
3392
  stretch: "stretch"
3392
3393
  };
3393
3394
  }
3394
- const Cr = Yr();
3395
- function Zn(e, t) {
3395
+ const Gr = qr();
3396
+ function no(e, t) {
3396
3397
  return Object.entries(t).map(([n, s]) => ({ id: `${e}-${n}`, target: e, property: n, keyframes: s }));
3397
3398
  }
3398
- function Dr(e, t, n = {}) {
3399
- const s = _n(t), o = t.map((r, l) => ({ time: r.time, pose: { ...s[l] }, easing: r.easing, act: r.act }));
3400
- return Zn(e, Jn(o, n.rig ?? Lr, n));
3399
+ function Ur(e, t, n = {}) {
3400
+ const s = Rn(t), o = t.map((r, l) => ({ time: r.time, pose: { ...s[l] }, easing: r.easing, act: r.act }));
3401
+ return no(e, to(o, n.rig ?? Dr, n));
3401
3402
  }
3402
- function Xi(e, t, n = {}) {
3403
- const s = n.rest ?? X, o = qn(t, s), r = t.map((l, i) => ({ time: l.time, pose: { ...s, ...o[i] }, easing: l.easing, act: l.act }));
3404
- return Zn(e, Jn(r, n.rig ?? Cr, n));
3403
+ function zi(e, t, n = {}) {
3404
+ const s = n.rest ?? G, o = Vn(t, s), r = t.map((l, i) => ({ time: l.time, pose: { ...s, ...o[i] }, easing: l.easing, act: l.act }));
3405
+ return no(e, to(r, n.rig ?? Gr, n));
3405
3406
  }
3406
- const rn = Y.shocked, Xr = Y.scared, Bt = {
3407
+ const rn = C.shocked, zr = C.scared, Bt = {
3407
3408
  /** The classic take: squash down in a squint, then shoot up stretched with eyes popping, hang, and land squashed. */
3408
3409
  take: (e) => [
3409
3410
  { after: 140, pose: { stretch: 0.8, bend: 10, 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" },
@@ -3412,7 +3413,7 @@ const rn = Y.shocked, Xr = Y.scared, Bt = {
3412
3413
  { after: 720, pose: { rise: 0.25, stretch: 1.25, bend: -10, leftShoulder: 140, rightShoulder: 140 }, easing: "ease-in-out" },
3413
3414
  { after: 900, pose: { rise: 0, stretch: 0.74, bend: 12, leftShoulder: 70, rightShoulder: 70, leftHip: 18, rightHip: 18, leftKnee: 30, rightKnee: 30 }, easing: "ease-in-quad" },
3414
3415
  { after: 1060, pose: { stretch: 1.06, bend: -3, leftShoulder: 60, rightShoulder: 60, leftHip: e.leftHip, rightHip: e.rightHip, leftKnee: e.leftKnee, rightKnee: e.rightKnee }, easing: "ease-out" },
3415
- { after: 1260, pose: { stretch: e.stretch, bend: e.bend, ...Y.surprised, leftShoulder: 70, rightShoulder: 70, leftElbow: 60, rightElbow: 60 }, easing: "ease-in-out" }
3416
+ { after: 1260, pose: { stretch: e.stretch, bend: e.bend, ...C.surprised, leftShoulder: 70, rightShoulder: 70, leftElbow: 60, rightElbow: 60 }, easing: "ease-in-out" }
3416
3417
  ],
3417
3418
  /** Glance at something, look away unbothered, then snap back to it in shock. */
3418
3419
  doubleTake: (e) => [
@@ -3425,7 +3426,7 @@ const rn = Y.shocked, Xr = Y.scared, Bt = {
3425
3426
  ],
3426
3427
  /** Rear back for a zip-off: lean back, one knee up, arms cocked, hold, then pitch forward ready to run. */
3427
3428
  windUp: () => [
3428
- { after: 220, pose: { lean: -18, bend: -16, headTilt: -6, leftShoulder: 70, leftElbow: -100, rightShoulder: 40, rightElbow: 100, leftHip: -45, leftKnee: -80, stretch: 0.92, ...Y.angry, lookX: 1 }, easing: "ease-out" },
3429
+ { after: 220, pose: { lean: -18, bend: -16, headTilt: -6, leftShoulder: 70, leftElbow: -100, rightShoulder: 40, rightElbow: 100, leftHip: -45, leftKnee: -80, stretch: 0.92, ...C.angry, lookX: 1 }, easing: "ease-out" },
3429
3430
  { after: 620, pose: { lean: -20, bend: -18, stretch: 0.9 } },
3430
3431
  { after: 700, pose: { lean: 28, bend: 14, headTilt: 6, leftShoulder: 30, rightShoulder: 60, leftHip: 30, leftKnee: -30, rightHip: -20, stretch: 1.12 }, easing: "ease-out-cubic" }
3431
3432
  ],
@@ -3433,22 +3434,22 @@ const rn = Y.shocked, Xr = Y.scared, Bt = {
3433
3434
  land: (e) => [
3434
3435
  { after: 120, pose: { rise: 0, stretch: 0.7, bend: 14, leftShoulder: 75, rightShoulder: 75, leftHip: 20, rightHip: 20, leftKnee: 35, rightKnee: 35 }, easing: "ease-in-quad" },
3435
3436
  { after: 300, pose: { stretch: 1.05, bend: -4, leftShoulder: e.leftShoulder, rightShoulder: e.rightShoulder }, easing: "ease-out" },
3436
- { after: 460, pose: { rise: 0, stretch: e.stretch, bend: e.bend, leftHip: _.leftHip, rightHip: _.rightHip, leftKnee: 0, rightKnee: 0 }, easing: "ease-in-out" }
3437
+ { after: 460, pose: { rise: 0, stretch: e.stretch, bend: e.bend, leftHip: $.leftHip, rightHip: $.rightHip, leftKnee: 0, rightKnee: 0 }, easing: "ease-in-out" }
3437
3438
  ],
3438
3439
  /** A frightened shiver: small, fast shakes with wide eyes, then still. */
3439
3440
  tremble: (e) => {
3440
- const t = [{ after: 80, pose: { ...Xr, bend: e.bend + 8, leftShoulder: 40, rightShoulder: 40, leftElbow: 110, rightElbow: 110, stretch: 0.94 }, easing: "ease-out" }];
3441
+ const t = [{ after: 80, pose: { ...zr, bend: e.bend + 8, leftShoulder: 40, rightShoulder: 40, leftElbow: 110, rightElbow: 110, stretch: 0.94 }, easing: "ease-out" }];
3441
3442
  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) } });
3442
3443
  return t.push({ after: 755, pose: { lean: e.lean, headTilt: e.headTilt, bend: e.bend } }), t;
3443
3444
  },
3444
3445
  /** A sigh: the body sags, shoulders drop, head and eyes go down. */
3445
3446
  deflate: (e) => [
3446
3447
  { after: 260, pose: { stretch: 1.04, headTilt: e.headTilt + 4, leftBrow: 0.3, rightBrow: 0.3 }, easing: "ease-in-out" },
3447
- { after: 900, pose: { ...Oe.sad, bend: 18, stretch: 0.92, lean: e.lean + 5, turn: e.turn, sit: e.sit }, easing: "ease-in-out" }
3448
+ { after: 900, pose: { ...Ie.sad, bend: 18, stretch: 0.92, lean: e.lean + 5, turn: e.turn, sit: e.sit }, easing: "ease-in-out" }
3448
3449
  ]
3449
3450
  };
3450
- function qr(e, t) {
3451
- const n = typeof t.from == "string" ? Oe[t.from] : t.from ?? _, s = t.speed ?? 1;
3451
+ function ln(e, t) {
3452
+ const n = typeof t.from == "string" ? Ie[t.from] : t.from ?? $, s = t.speed ?? 1;
3452
3453
  let o = n;
3453
3454
  return [
3454
3455
  // The move onto the starting pose is acted like any other; the gag itself is not.
@@ -3456,24 +3457,24 @@ function qr(e, t) {
3456
3457
  ...Bt[e](n).map((r) => (o = { ...o, ...r.pose }, { time: t.at + r.after * s, pose: o, act: !1, ...r.easing ? { easing: r.easing } : {} }))
3457
3458
  ];
3458
3459
  }
3459
- function Gr(e, t = 1) {
3460
- const n = Bt[e](_);
3460
+ function an(e, t = 1) {
3461
+ const n = Bt[e]($);
3461
3462
  return n[n.length - 1].after * t;
3462
3463
  }
3463
- function Ur(e, t, n = {}) {
3464
+ function Vr(e, t, n = {}) {
3464
3465
  if (t.length < 2) return;
3465
3466
  const s = Math.max(1, Math.round(n.lines ?? 3)), o = n.spacing ?? 5, r = n.lineWidth ?? 2, l = n.opacity ?? 0.7;
3466
3467
  e.save(), e.strokeStyle = n.color ?? "#222", e.lineCap = "round";
3467
3468
  for (let i = 0; i < s; i++) {
3468
3469
  const a = (i - (s - 1) / 2) * o, h = Math.floor(Math.abs(a) / Math.max(o, 1) * (t.length / 6));
3469
3470
  for (let c = h + 1; c < t.length; c++) {
3470
- const u = t[c - 1], g = t[c], f = g.x - u.x, p = g.y - u.y, d = Math.hypot(f, p) || 1, m = -p / d, b = f / d, y = 1 - c / (t.length - 1);
3471
- e.globalAlpha = l * (1 - y), e.lineWidth = r * (1 - y * 0.7), e.beginPath(), e.moveTo(u.x + m * a, u.y + b * a), e.lineTo(g.x + m * a, g.y + b * a), e.stroke();
3471
+ const u = t[c - 1], g = t[c], f = g.x - u.x, p = g.y - u.y, d = Math.hypot(f, p) || 1, m = -p / d, b = f / d, S = 1 - c / (t.length - 1);
3472
+ e.globalAlpha = l * (1 - S), e.lineWidth = r * (1 - S * 0.7), e.beginPath(), e.moveTo(u.x + m * a, u.y + b * a), e.lineTo(g.x + m * a, g.y + b * a), e.stroke();
3472
3473
  }
3473
3474
  }
3474
3475
  e.restore();
3475
3476
  }
3476
- const zr = {
3477
+ const jr = {
3477
3478
  hands: [
3478
3479
  { name: "left hand", at: (e) => e.hands.left },
3479
3480
  { name: "right hand", at: (e) => e.hands.right }
@@ -3488,7 +3489,7 @@ const zr = {
3488
3489
  { name: "neck", at: (e) => e.neck }
3489
3490
  ]
3490
3491
  };
3491
- function qi(e, t, n, s, o = {}) {
3492
+ function Vi(e, t, n, s, o = {}) {
3492
3493
  const r = n.stateAt;
3493
3494
  if (!r) return;
3494
3495
  const l = o.length ?? 120, i = Math.max(2, Math.round(o.samples ?? 8)), a = Math.max(0, n.time - l);
@@ -3496,20 +3497,20 @@ function qi(e, t, n, s, o = {}) {
3496
3497
  const h = [];
3497
3498
  for (let f = 0; f < i; f++) {
3498
3499
  const p = a + (n.time - a) * f / (i - 1);
3499
- h.push(ds(t, { time: p, state: r(p) }, s).joints);
3500
+ h.push(bs(t, { time: p, state: r(p) }, s).joints);
3500
3501
  }
3501
- const c = h[h.length - 1].height, u = (o.threshold ?? 1.2) * c, g = (o.parts ?? ["hands", "toes", "head"]).flatMap((f) => zr[f]);
3502
+ const c = h[h.length - 1].height, u = (o.threshold ?? 1.2) * c, g = (o.parts ?? ["hands", "toes", "head"]).flatMap((f) => jr[f]);
3502
3503
  for (const f of g) {
3503
3504
  const p = h.map(f.at);
3504
3505
  let d = 0;
3505
- for (let y = 1; y < p.length; y++) d += Math.hypot(p[y].x - p[y - 1].x, p[y].y - p[y - 1].y);
3506
+ for (let S = 1; S < p.length; S++) d += Math.hypot(p[S].x - p[S - 1].x, p[S].y - p[S - 1].y);
3506
3507
  const m = d / ((n.time - a) / 1e3);
3507
3508
  if (m <= u) continue;
3508
3509
  const b = Math.min(1, (m - u) / (u * 0.5));
3509
- Ur(e, p, { ...o, opacity: (o.opacity ?? 0.7) * b, spacing: o.spacing ?? c * 0.02 });
3510
+ Vr(e, p, { ...o, opacity: (o.opacity ?? 0.7) * b, spacing: o.spacing ?? c * 0.02 });
3510
3511
  }
3511
3512
  }
3512
- function Gi(e, t, n, s = {}) {
3513
+ function ji(e, t, n, s = {}) {
3513
3514
  if (n <= 0 || n >= 1) return;
3514
3515
  const o = s.size ?? 40, r = s.seed ?? 1, l = 0.45 + 0.55 * (1 - (1 - n) ** 3);
3515
3516
  e.save(), e.strokeStyle = s.color ?? "#555", e.lineWidth = Math.max(1, o * 0.03), e.globalAlpha = Math.min(1, n / 0.08) * (1 - n);
@@ -3519,17 +3520,17 @@ function Gi(e, t, n, s = {}) {
3519
3520
  }
3520
3521
  e.restore();
3521
3522
  }
3522
- function Ui(e, t, n, s = {}) {
3523
+ function Ji(e, t, n, s = {}) {
3523
3524
  if (n <= 0 || n >= 1) return;
3524
3525
  const o = s.size ?? 40, r = 5, l = 1 - (1 - n) ** 2;
3525
3526
  e.save(), e.strokeStyle = s.color ?? "#222", e.lineWidth = Math.max(1, o * 0.035), e.lineJoin = "round", e.globalAlpha = n < 0.7 ? 1 : (1 - n) / 0.3;
3526
3527
  for (let i = 0; i < r; i++) {
3527
3528
  const a = -Math.PI / 2 + (i - (r - 1) / 2) * Math.PI / (r + 1), h = o * (0.3 + 0.7 * l), c = t.x + Math.cos(a) * h, u = t.y + Math.sin(a) * h;
3528
- Vr(e, c, u, o * 0.14, n * Math.PI + i), e.stroke();
3529
+ Jr(e, c, u, o * 0.14, n * Math.PI + i), e.stroke();
3529
3530
  }
3530
3531
  e.restore();
3531
3532
  }
3532
- function Vr(e, t, n, s, o) {
3533
+ function Jr(e, t, n, s, o) {
3533
3534
  e.beginPath();
3534
3535
  for (let r = 0; r < 10; r++) {
3535
3536
  const l = r % 2 === 0 ? s : s * 0.45, i = o + r * Math.PI / 5 - Math.PI / 2, a = t + Math.cos(i) * l, h = n + Math.sin(i) * l;
@@ -3558,7 +3559,7 @@ const ce = {
3558
3559
  l: { mouth: 0.3, mouthWidth: 1 },
3559
3560
  /** Other consonants: slightly open */
3560
3561
  c: { mouth: 0.2, mouthWidth: 1 }
3561
- }, Me = 1, Ne = 0.55, ln = 0.35, jr = 1.6, an = { a: "a", e: "e", i: "i", y: "i", o: "o", u: "u" }, hn = { m: "m", b: "m", p: "m", f: "f", v: "f", w: "u", q: "u", l: "l", n: "l", d: "l", t: "l" }, cn = {
3562
+ }, He = 1, Ye = 0.55, hn = 0.35, Zr = 1.6, cn = { a: "a", e: "e", i: "i", y: "i", o: "o", u: "u" }, fn = { m: "m", b: "m", p: "m", f: "f", v: "f", w: "u", q: "u", l: "l", n: "l", d: "l", t: "l" }, un = {
3562
3563
  अ: "a",
3563
3564
  आ: "a",
3564
3565
  इ: "i",
@@ -3572,7 +3573,7 @@ const ce = {
3572
3573
  औ: "o",
3573
3574
  ऍ: "e",
3574
3575
  ऑ: "o"
3575
- }, fn = {
3576
+ }, dn = {
3576
3577
  "ा": "a",
3577
3578
  "ि": "i",
3578
3579
  "ी": "i",
@@ -3585,41 +3586,41 @@ const ce = {
3585
3586
  "ौ": "o",
3586
3587
  "ॅ": "e",
3587
3588
  "ॉ": "o"
3588
- }, Jr = { प: "m", फ: "m", ब: "m", भ: "m", म: "m", व: "u" }, Zr = "्", un = "़", Qr = (e) => e >= "क" && e <= "ह", dn = /* @__PURE__ */ new Set([".", ",", "!", "?", ";", ":", "…", "।", "॥", "—", "-"]);
3589
- function ei(e) {
3589
+ }, Qr = { प: "m", फ: "m", ब: "m", भ: "m", म: "m", व: "u" }, ei = "्", gn = "़", ti = (e) => e >= "क" && e <= "ह", pn = /* @__PURE__ */ new Set([".", ",", "!", "?", ";", ":", "…", "।", "॥", "—", "-"]);
3590
+ function ni(e) {
3590
3591
  const t = [], n = Array.from(e.toLowerCase()), s = (o, r) => {
3591
3592
  const l = t[t.length - 1];
3592
3593
  l && l.viseme === o ? l.weight += r * 0.5 : t.push({ viseme: o, weight: r });
3593
3594
  };
3594
3595
  for (let o = 0; o < n.length; o++) {
3595
3596
  const r = n[o], l = n[o + 1];
3596
- if (dn.has(r)) s("rest", jr);
3597
+ if (pn.has(r)) s("rest", Zr);
3597
3598
  else if (/\s/.test(r)) {
3598
3599
  const i = t[t.length - 1];
3599
- i && i.viseme !== "rest" && t.push({ viseme: "c", weight: ln });
3600
+ i && i.viseme !== "rest" && t.push({ viseme: "c", weight: hn });
3600
3601
  } else if ((r === "o" || r === "e") && l === r)
3601
- s(r === "o" ? "u" : "i", Me), o++;
3602
- else if (r in an) s(an[r], Me);
3603
- else if (r in hn) s(hn[r], Ne);
3602
+ s(r === "o" ? "u" : "i", He), o++;
3603
+ else if (r in cn) s(cn[r], He);
3604
+ else if (r in fn) s(fn[r], Ye);
3604
3605
  else {
3605
3606
  if (r === "h") continue;
3606
- if (/[a-z]/.test(r)) s("c", Ne);
3607
- else if (r in cn) s(cn[r], Me);
3608
- else if (Qr(r)) {
3609
- const i = l === un ? r === "फ" ? "f" : void 0 : Jr[r];
3610
- s(i ?? "c", Ne);
3607
+ if (/[a-z]/.test(r)) s("c", Ye);
3608
+ else if (r in un) s(un[r], He);
3609
+ else if (ti(r)) {
3610
+ const i = l === gn ? r === "फ" ? "f" : void 0 : Qr[r];
3611
+ s(i ?? "c", Ye);
3611
3612
  let a = o + 1;
3612
- n[a] === un && a++;
3613
+ n[a] === gn && a++;
3613
3614
  const h = n[a];
3614
- h === Zr ? o = a : h && h in fn ? (s(fn[h], Me), o = a) : (!h || /\s/.test(h) || dn.has(h) || s("a", Me * 0.6), o = a - 1);
3615
- } else (r === "ं" || r === "ँ") && s("l", Ne * 0.6);
3615
+ h === ei ? o = a : h && h in dn ? (s(dn[h], He), o = a) : (!h || /\s/.test(h) || pn.has(h) || s("a", He * 0.6), o = a - 1);
3616
+ } else (r === "ं" || r === "ँ") && s("l", Ye * 0.6);
3616
3617
  }
3617
3618
  }
3618
- for (; t.length > 0 && (t[t.length - 1].viseme === "rest" || t[t.length - 1].weight === ln); ) t.pop();
3619
+ for (; t.length > 0 && (t[t.length - 1].viseme === "rest" || t[t.length - 1].weight === hn); ) t.pop();
3619
3620
  return t;
3620
3621
  }
3621
- function Qn(e, t = {}) {
3622
- const n = t.fields?.mouth ?? "mouth", s = t.fields?.mouthWidth ?? "mouthWidth", o = t.energy ?? 1, r = ei(e.text), l = [{ time: e.start, value: ce.rest.mouth }], i = [{ time: e.start, value: ce.rest.mouthWidth }], a = r.reduce((c, u) => c + u.weight, 0), h = e.end - e.start;
3622
+ function oo(e, t = {}) {
3623
+ const n = t.fields?.mouth ?? "mouth", s = t.fields?.mouthWidth ?? "mouthWidth", o = t.energy ?? 1, r = ni(e.text), l = [{ time: e.start, value: ce.rest.mouth }], i = [{ time: e.start, value: ce.rest.mouthWidth }], a = r.reduce((c, u) => c + u.weight, 0), h = e.end - e.start;
3623
3624
  if (a > 0 && h > 0) {
3624
3625
  let c = e.start;
3625
3626
  for (const u of r) {
@@ -3633,30 +3634,30 @@ function Qn(e, t = {}) {
3633
3634
  }
3634
3635
  return e.end > l[l.length - 1].time && (l.push({ time: e.end, value: ce.rest.mouth, easing: "ease-in-out" }), i.push({ time: e.end, value: ce.rest.mouthWidth, easing: "ease-in-out" })), { [n]: l, [s]: i };
3635
3636
  }
3636
- function zi(e, t, n = {}) {
3637
+ function Zi(e, t, n = {}) {
3637
3638
  const s = {};
3638
3639
  for (const o of [...t].sort((r, l) => r.start - l.start))
3639
- for (const [r, l] of Object.entries(Qn(o, n))) {
3640
+ for (const [r, l] of Object.entries(oo(o, n))) {
3640
3641
  const i = s[r] ??= [], a = i.length > 0 ? i[i.length - 1].time : -1 / 0;
3641
3642
  i.push(...l.filter((h) => h.time > a));
3642
3643
  }
3643
3644
  return Object.entries(s).map(([o, r]) => ({ id: `${e}-${o}`, target: e, property: o, keyframes: r }));
3644
3645
  }
3645
- function ti(e, t, n, s = {}) {
3646
+ function oi(e, t, n, s = {}) {
3646
3647
  if (n.length === 0) return t;
3647
- const o = s.fields?.mouth ?? "mouth", r = s.fields?.mouthWidth ?? "mouthWidth", l = { [o]: ce.rest.mouth, [r]: ce.rest.mouthWidth, ...s.rest }, i = new oo({ id: "before-speech", tracks: t }), a = (u, g) => i.getStateAtTime(g).values.get(e)?.get(u) ?? l[u], h = [o, r], c = t.filter((u) => u.target !== e || !h.includes(u.property));
3648
+ const o = s.fields?.mouth ?? "mouth", r = s.fields?.mouthWidth ?? "mouthWidth", l = { [o]: ce.rest.mouth, [r]: ce.rest.mouthWidth, ...s.rest }, i = new lo({ id: "before-speech", tracks: t }), a = (u, g) => i.getStateAtTime(g).values.get(e)?.get(u) ?? l[u], h = [o, r], c = t.filter((u) => u.target !== e || !h.includes(u.property));
3648
3649
  for (const u of h) {
3649
3650
  const g = t.find((p) => p.target === e && p.property === u);
3650
3651
  let f = g ? [...g.keyframes] : [{ time: 0, value: a(u, 0) }];
3651
3652
  for (const p of n) {
3652
- const d = Qn(p, s)[u];
3653
+ const d = oo(p, s)[u];
3653
3654
  d[0] = { ...d[0], value: a(u, p.start) }, d[d.length - 1] = { ...d[d.length - 1], value: a(u, p.end) }, f = [...f.filter((m) => m.time < p.start || m.time > p.end), ...d], f.sort((m, b) => m.time - b.time);
3654
3655
  }
3655
3656
  c.push({ id: g?.id ?? `${e}-${u}`, target: e, property: u, keyframes: f });
3656
3657
  }
3657
3658
  return c;
3658
3659
  }
3659
- const ni = {
3660
+ const mn = {
3660
3661
  walk: 1e3,
3661
3662
  bouncy: 900,
3662
3663
  doubleBounce: 1100,
@@ -3664,53 +3665,61 @@ const ni = {
3664
3665
  strut: 1100,
3665
3666
  tired: 1500,
3666
3667
  run: 560
3667
- }, le = 450, gn = 1200, oi = 700, be = 320, He = 220, si = 65, ri = 700, ft = (e) => e in we, pn = (e) => e in Bt, ii = (e) => e in Oe;
3668
- function li(e) {
3669
- return Math.max(ri, Array.from(e).length * si);
3668
+ }, si = 450, ri = 2.4, ii = 160, bn = 2.5, le = 450, wn = 1200, li = 700, be = 320, we = 220, ai = 65, hi = 700, ft = (e) => e in ye, yn = (e) => e in Bt, ci = (e) => e in Ie;
3669
+ function fi(e) {
3670
+ return Math.max(hi, Array.from(e).length * ai);
3670
3671
  }
3671
- function Vi(e, t, n = {}) {
3672
+ function Qi(e, t, n = {}) {
3672
3673
  const s = n.from ?? 0, o = n.height ?? 300;
3673
- let r = s, l = n.facing ?? 1, i = n.start ?? _, a = 0, h = 0;
3674
- const c = [{ time: 0, pose: i }], u = [{ time: 0, value: 0 }], g = [{ time: 0, value: 0 }], f = [{ time: 0, value: 0 }], p = [{ time: 0, value: "walk" }], d = [{ time: 0, value: l }], m = [], b = [], y = (w, S, k, x) => {
3675
- i = { ...i, ...S }, k && (i = qe(i, k)), c.push({ time: w, pose: i });
3676
- }, E = (w, S, k) => (y(w + be / 2, { turn: 0 }, k), d.push({ time: w + be / 2, value: l }, { time: w + be / 2 + 1, value: S }), l = S, y(w + be, { turn: 1 }), w + be), H = (w) => w < r ? -1 : 1;
3674
+ let r = s, l = n.facing ?? 1, i = n.start ?? $, a = 0, h = 0;
3675
+ const c = [{ time: 0, pose: i }], u = [{ time: 0, value: 0 }], g = [{ time: 0, value: 0 }], f = [{ time: 0, value: 0 }], p = [{ time: 0, value: "walk" }], d = [{ time: 0, value: l }], m = [], b = [], S = [], k = (w, y, A, x) => {
3676
+ i = { ...i, ...y }, A && (i = xe(i, A)), c.push({ time: w, pose: i });
3677
+ }, v = (w, y, A) => (k(w + be / 2, { turn: 0 }, A), d.push({ time: w + be / 2, value: l }, { time: w + be / 2 + 1, value: y }), l = y, k(w + be, { turn: 1 }), w + be), H = (w) => w < r ? -1 : 1;
3677
3678
  for (const w of t) {
3678
- const S = Math.max(w.at ?? h, h === 0 ? 0 : c[c.length - 1].time);
3679
- let k = S;
3679
+ const y = Math.max(w.at ?? h, h === 0 ? 0 : c[c.length - 1].time);
3680
+ let A = y;
3680
3681
  const x = w.pose ?? {};
3681
3682
  if (ft(w.do)) {
3682
- const v = w.to ?? r, T = v === r ? l : H(v);
3683
- let K = S;
3684
- T !== l ? K = E(S, T, w.mood) : i.turn < 1 ? (K = S + He, y(K, { turn: 1, ...x }, w.mood)) : (w.mood || w.pose) && y(S + He, x, w.mood);
3685
- const I = Math.abs(v - r) / Io(w.do, o), q = w.for ?? Math.max(He * 2, I * ni[w.do]), G = K + q;
3686
- p.push({ time: K, value: w.do }), f.push({ time: K, value: 0 }, { time: K + He, value: 1, easing: "ease-out" }), f.push({ time: G - He, value: 1 }, { time: G, value: 0, easing: "ease-in" }), g.push({ time: K, value: a }, { time: G, value: a + I }), u.push({ time: K, value: r - s }, { time: G, value: v - s }), a += I, r = v, y(G, {}), k = G;
3687
- } else if (pn(w.do)) {
3688
- const v = qr(w.do, { at: S, from: w.mood ? qe(i, w.mood) : i });
3689
- c.push(...v), i = v[v.length - 1].pose, k = S + Gr(w.do);
3683
+ const E = w.to ?? r, P = E === r ? l : H(E);
3684
+ let K = y;
3685
+ P !== l ? K = v(y, P, w.mood) : i.turn < 1 ? (K = y + we, k(K, { turn: 1, ...x }, w.mood)) : (w.mood || w.pose) && k(y + we, x, w.mood);
3686
+ const _ = Math.abs(E - r) / Fo(w.do, o), X = w.for ?? Math.max(we * 2, _ * mn[w.do]), W = K + X;
3687
+ p.push({ time: K, value: w.do }), f.push({ time: K, value: 0 }, { time: K + we, value: 1, easing: "ease-out" }), f.push({ time: W - we, value: 1 }, { time: W, value: 0, easing: "ease-in" }), g.push({ time: K, value: a }, { time: W, value: a + _ }), u.push({ time: K, value: r - s }, { time: W, value: E - s }), a += _, r = E, k(W, {}), A = W;
3688
+ } else if (w.do === "zip") {
3689
+ const E = w.to ?? r, P = E === r ? l : H(E);
3690
+ let K = y;
3691
+ P !== l ? K = v(y, P, w.mood) : i.turn < 1 && (K = y + we, k(K, { turn: 1 }, w.mood));
3692
+ const I = ln("windUp", { at: K, from: w.mood ? xe(i, w.mood) : i });
3693
+ c.push(...I), i = I[I.length - 1].pose;
3694
+ const _ = K + an("windUp"), X = _ + si, W = X + Math.max(ii, Math.abs(E - r) / ri);
3695
+ p.push({ time: _, value: "run" }), f.push({ time: _, value: 0 }, { time: _ + 80, value: 1, easing: "ease-out" }, { time: W, value: 1 }, { time: W + 120, value: 0 }), g.push({ time: _, value: a }, { time: X, value: a + bn, easing: "ease-in" }), a += bn + (W - X) / mn.run * 1.5, g.push({ time: W, value: a }), u.push({ time: X, value: r - s }, { time: W, value: E - s, easing: "ease-in" }), S.push({ kind: "dust", time: X, x: r, length: 900 }), r = E, k(W, {}), A = W;
3696
+ } else if (yn(w.do)) {
3697
+ const E = ln(w.do, { at: y, from: w.mood ? xe(i, w.mood) : i });
3698
+ c.push(...E), i = E[E.length - 1].pose, A = y + an(w.do), w.do === "take" && S.push({ kind: "dust", time: y + 900, x: r, length: 500 }), w.do === "land" && S.push({ kind: "dust", time: y + 120, x: r, length: 500 });
3690
3699
  } else if (w.do === "look" || w.do === "face") {
3691
- const v = w.toward ?? "viewer", T = w.for ?? oi;
3692
- if (v === "viewer") y(S + le, { turn: 0, lookX: 0, lookY: 0, ...x }, w.mood);
3693
- else if (v === "ahead") y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3694
- else if (v === "back") y(S + le, { turn: 0.2, lookX: -1, ...x }, w.mood);
3700
+ const E = w.toward ?? "viewer", P = w.for ?? li;
3701
+ if (E === "viewer") k(y + le, { turn: 0, lookX: 0, lookY: 0, ...x }, w.mood);
3702
+ else if (E === "ahead") k(y + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3703
+ else if (E === "back") k(y + le, { turn: 0.2, lookX: -1, ...x }, w.mood);
3695
3704
  else {
3696
- const K = H(v);
3697
- K !== l && w.do === "face" ? (E(S, K, w.mood), y(S + be + 1, { lookX: 1, ...x })) : K !== l ? y(S + le, { turn: 0.25, lookX: -1, ...x }, w.mood) : y(S + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3705
+ const K = H(E);
3706
+ K !== l && w.do === "face" ? (v(y, K, w.mood), k(y + be + 1, { lookX: 1, ...x })) : K !== l ? k(y + le, { turn: 0.25, lookX: -1, ...x }, w.mood) : k(y + le, { turn: w.do === "face" ? 1 : 0.6, lookX: 1, ...x }, w.mood);
3698
3707
  }
3699
- k = S + Math.max(T, le);
3700
- } else if (ii(w.do) || w.do === "stand") {
3701
- const v = w.do === "stand" ? _ : Oe[w.do], T = v.turn !== _.turn ? v.turn : i.turn, K = w.mood ? Y[w.mood] : { lookX: i.lookX, lookY: i.lookY };
3702
- y(S + le, { ...v, turn: T, ...K, ...x }), k = S + (w.for ?? gn);
3708
+ A = y + Math.max(P, le);
3709
+ } else if (ci(w.do) || w.do === "stand") {
3710
+ const E = w.do === "stand" ? $ : Ie[w.do], P = E.turn !== $.turn ? E.turn : i.turn, K = w.mood ? C[w.mood] : { lookX: i.lookX, lookY: i.lookY };
3711
+ k(y + le, { ...E, turn: P, ...K, ...x }), A = y + (w.for ?? wn);
3703
3712
  } else {
3704
- const v = w.for ?? (w.say ? li(w.say) : gn);
3705
- (w.mood || w.pose) && y(S + Math.min(le, v / 2), x, w.mood), k = S + v;
3713
+ const E = w.for ?? (w.say ? fi(w.say) : wn);
3714
+ (w.mood || w.pose) && k(y + Math.min(le, E / 2), x, w.mood), A = y + E;
3706
3715
  }
3707
3716
  if (w.say) {
3708
- const v = ft(w.do) || pn(w.do) ? S : S + Math.min(150, (k - S) / 4), T = ft(w.do) ? k : Math.max(v + 200, k - 100);
3709
- m.push({ text: w.say, start: v, end: T }), w.do === "say" && ci(c, i, v, T);
3717
+ const E = ft(w.do) || yn(w.do) ? y : y + Math.min(150, (A - y) / 4), P = ft(w.do) ? A : Math.max(E + 200, A - 100);
3718
+ m.push({ text: w.say, start: E, end: P }), w.do === "say" && gi(c, i, E, P);
3710
3719
  }
3711
- k > c[c.length - 1].time && c.push({ time: k, pose: i }), b.push({ start: S, end: k }), h = k;
3720
+ A > c[c.length - 1].time && c.push({ time: A, pose: i }), b.push({ start: y, end: A }), h = A;
3712
3721
  }
3713
- const M = Dr(e, hi(c), n), A = [
3722
+ const T = Ur(e, di(c), n), M = [
3714
3723
  { id: `${e}-x`, target: e, property: "x", keyframes: u },
3715
3724
  { id: `${e}-walk`, target: e, property: "walk", keyframes: g },
3716
3725
  { id: `${e}-walking`, target: e, property: "walking", keyframes: f },
@@ -3718,23 +3727,24 @@ function Vi(e, t, n = {}) {
3718
3727
  { id: `${e}-facing`, target: e, property: "facing", keyframes: d }
3719
3728
  ].filter((w) => w.keyframes.length > 1 || w.property === "x");
3720
3729
  return {
3721
- tracks: [...ti(e, M, m, { energy: n.energy }), ...A],
3730
+ tracks: [...oi(e, T, m, { energy: n.energy }), ...M],
3722
3731
  duration: h,
3723
3732
  lines: m,
3724
3733
  keys: c,
3725
- beats: b
3734
+ beats: b,
3735
+ effects: S
3726
3736
  };
3727
3737
  }
3728
- const ai = 30;
3729
- function hi(e) {
3738
+ const ui = 30;
3739
+ function di(e) {
3730
3740
  const t = [];
3731
3741
  for (const n of e) {
3732
3742
  const s = t[t.length - 1];
3733
- s && n.time - s.time < ai ? t[t.length - 1] = { ...n, time: s.time } : t.push(n);
3743
+ s && n.time - s.time < ui ? t[t.length - 1] = { ...n, time: s.time } : t.push(n);
3734
3744
  }
3735
3745
  return t;
3736
3746
  }
3737
- function ci(e, t, n, s) {
3747
+ function gi(e, t, n, s) {
3738
3748
  const r = e.filter((a) => a.time > n), l = e.filter((a) => a.time <= n), i = [];
3739
3749
  for (let a = n + 520, h = 0; a < s - 520 / 2; a += 520, h++) {
3740
3750
  const c = h % 2 === 0 ? 3 : -2;
@@ -3744,125 +3754,129 @@ function ci(e, t, n, s) {
3744
3754
  }
3745
3755
  export {
3746
3756
  ht as ACTING_STYLES,
3747
- Se as DANCE_STYLES,
3748
- Y as EXPRESSIONS,
3749
- co as FINGERS,
3750
- Pt as FLIPS,
3757
+ Ee as DANCE_STYLES,
3758
+ C as EXPRESSIONS,
3759
+ po as FINGERS,
3760
+ Kt as FLIPS,
3751
3761
  Bt as GAGS,
3752
- we as GAITS,
3753
- ni as GAIT_CYCLE_MS,
3754
- L as HAND_REST,
3755
- C as HAND_SHAPES,
3756
- Cr as HUMAN_ACTING_RIG,
3757
- Ai as HUMAN_EXPRESSIONS,
3758
- Qs as HUMAN_POSES,
3759
- X as HUMAN_REST,
3762
+ ye as GAITS,
3763
+ mn as GAIT_CYCLE_MS,
3764
+ N as HAND_REST,
3765
+ D as HAND_SHAPES,
3766
+ Gr as HUMAN_ACTING_RIG,
3767
+ Wi as HUMAN_EXPRESSIONS,
3768
+ or as HUMAN_POSES,
3769
+ G as HUMAN_REST,
3770
+ sl as IDENTITY_CAMERA,
3760
3771
  Zt as MUDRAS,
3761
- Oe as POSES,
3762
- _ as REST_POSE,
3763
- Lr as STICK_ACTING_RIG,
3772
+ Ie as POSES,
3773
+ $ as REST_POSE,
3774
+ Dr as STICK_ACTING_RIG,
3764
3775
  ce as VISEMES,
3765
- Xi as actCharacterTracks,
3766
- Jn as actKeyframes,
3767
- Dr as actTracks,
3768
- ks as applyGroove,
3769
- Mi as bakeDanceTracks,
3770
- Di as basicOutfit,
3771
- ki as beatAt,
3772
- Pe as blendPose,
3773
- to as boilFrame,
3774
- fr as character,
3775
- _i as characterAt,
3776
- br as characterHandPose,
3777
- gr as characterJoints,
3778
- Pi as characterJointsInView,
3779
- Bi as characterObjects,
3780
- $i as characterPoseTracks,
3781
- Ii as characterTarget,
3782
- Ri as circlePath,
3783
- jn as clipErased,
3784
- bn as createPen,
3776
+ zi as actCharacterTracks,
3777
+ to as actKeyframes,
3778
+ Ur as actTracks,
3779
+ rl as applyCamera,
3780
+ Hs as applyGroove,
3781
+ Ai as bakeDanceTracks,
3782
+ Ui as basicOutfit,
3783
+ Hi as beatAt,
3784
+ We as blendPose,
3785
+ ro as boilFrame,
3786
+ il as cameraFromValues,
3787
+ ll as cameraPoint,
3788
+ pr as character,
3789
+ Ri as characterAt,
3790
+ Sr as characterHandPose,
3791
+ wr as characterJoints,
3792
+ _i as characterJointsInView,
3793
+ Ni as characterObjects,
3794
+ Li as characterPoseTracks,
3795
+ Fi as characterTarget,
3796
+ Ci as circlePath,
3797
+ eo as clipErased,
3798
+ Sn as createPen,
3785
3799
  xt as danceFrame,
3786
- wi as dancePose,
3800
+ Ei as dancePose,
3787
3801
  yt as danceStance,
3788
- yi as danceTaps,
3789
- Ei as danceTracks,
3802
+ Mi as danceTaps,
3803
+ Ti as danceTracks,
3790
3804
  ot as danceTravel,
3791
- Hs as danceTravelTrack,
3792
- Si as dancer,
3805
+ xs as danceTravelTrack,
3806
+ vi as dancer,
3793
3807
  Tt as drawCartoonHand,
3794
- yr as drawCharacter,
3795
- kr as drawCharacterInView,
3796
- Gi as drawDustPuff,
3797
- Gn as drawEraser,
3798
- zn as drawHand,
3799
- Ui as drawImpactStars,
3800
- Ar as drawPencil,
3801
- Ur as drawSpeedLines,
3802
- hs as drawStickFigure,
3803
- qi as drawStickSmear,
3804
- Li as drawnPathTarget,
3808
+ Mr as drawCharacter,
3809
+ Hr as drawCharacterInView,
3810
+ ji as drawDustPuff,
3811
+ jn as drawEraser,
3812
+ Zn as drawHand,
3813
+ Ji as drawImpactStars,
3814
+ Wr as drawPencil,
3815
+ Vr as drawSpeedLines,
3816
+ ds as drawStickFigure,
3817
+ Vi as drawStickSmear,
3818
+ Di as drawnPathTarget,
3805
3819
  Lt as ellipsePoints,
3806
- Ci as erasable,
3807
- Ys as flipPose,
3808
- Hi as flipTracks,
3809
- Cs as flipTravel,
3810
- qr as gag,
3811
- Gr as gagDuration,
3812
- Oo as gaitPose,
3813
- Io as gaitStrideLength,
3814
- Fi as handAt,
3820
+ Gi as erasable,
3821
+ qs as flipPose,
3822
+ xi as flipTracks,
3823
+ Gs as flipTravel,
3824
+ ln as gag,
3825
+ an as gagDuration,
3826
+ Bo as gaitPose,
3827
+ Fo as gaitStrideLength,
3828
+ Yi as handAt,
3815
3829
  pt as handJoints,
3816
- Mo as handJointsAt,
3817
- R as handPose,
3830
+ Ao as handJointsAt,
3831
+ L as handPose,
3818
3832
  Ue as handProp,
3819
- pi as headPoint,
3820
- Ti as humanFieldLabel,
3821
- er as humanPlan,
3833
+ yi as headPoint,
3834
+ Ki as humanFieldLabel,
3835
+ sr as humanPlan,
3822
3836
  ee as humanPose,
3823
- Sr as jointsInScene,
3824
- as as jointsToScene,
3825
- Qn as lipSyncKeyframes,
3826
- ti as lipSyncOver,
3827
- zi as lipSyncTracks,
3828
- vi as mirrorHumanPose,
3829
- ws as mirrorPose,
3837
+ vr as jointsInScene,
3838
+ us as jointsToScene,
3839
+ oo as lipSyncKeyframes,
3840
+ oi as lipSyncOver,
3841
+ Zi as lipSyncTracks,
3842
+ Pi as mirrorHumanPose,
3843
+ Es as mirrorPose,
3830
3844
  Ke as mixHandPoses,
3831
- Wi as mixPoses,
3832
- mn as partialPath,
3833
- Zi as pathLength,
3845
+ $i as mixPoses,
3846
+ kn as partialPath,
3847
+ nl as pathLength,
3834
3848
  Ht as pointAlong,
3835
- Ki as pointOnHead,
3849
+ Ii as pointOnHead,
3836
3850
  z as pose,
3837
- bi as poseTracks,
3838
- Oi as reachCharacter,
3839
- Or as resolveActingStyle,
3840
- qn as resolveCharacterPoseKeys,
3841
- wn as resolveGait,
3842
- _n as resolvePoseKeys,
3843
- On as resolveStickFrame,
3844
- cs as resolveStickPose,
3851
+ Si as poseTracks,
3852
+ Bi as reachCharacter,
3853
+ Br as resolveActingStyle,
3854
+ Vn as resolveCharacterPoseKeys,
3855
+ En as resolveGait,
3856
+ Rn as resolvePoseKeys,
3857
+ Bn as resolveStickFrame,
3858
+ gs as resolveStickPose,
3845
3859
  de as rotateAbout,
3846
- Kt as routineBeats,
3847
- ke as rubberLimb,
3848
- Vi as scriptTracks,
3849
- Ni as scrubPath,
3850
- gi as seatHeight,
3851
- Yn as skeletonInView,
3860
+ Pt as routineBeats,
3861
+ Se as rubberLimb,
3862
+ Qi as scriptTracks,
3863
+ Xi as scrubPath,
3864
+ wi as seatHeight,
3865
+ qn as skeletonInView,
3852
3866
  ut as sketchPen,
3853
3867
  Ot as solvePlanSpace,
3854
- ei as soundsOf,
3855
- li as speechDuration,
3856
- Nn as stagePlanSpace,
3857
- ds as stickFigureAt,
3858
- ls as stickFigureJoints,
3859
- mi as stickFigureTarget,
3860
- xi as stickToHuman,
3861
- Bo as strideLength,
3862
- Fo as talkingMouth,
3868
+ ni as soundsOf,
3869
+ fi as speechDuration,
3870
+ Xn as stagePlanSpace,
3871
+ bs as stickFigureAt,
3872
+ fs as stickFigureJoints,
3873
+ ki as stickFigureTarget,
3874
+ Oi as stickToHuman,
3875
+ No as strideLength,
3876
+ Yo as talkingMouth,
3863
3877
  vt as taperedLine,
3864
- Ye as taperedOutline,
3865
- $o as walkPose,
3866
- Yi as withErased,
3867
- qe as withExpression
3878
+ Ce as taperedOutline,
3879
+ Lo as walkPose,
3880
+ qi as withErased,
3881
+ xe as withExpression
3868
3882
  };