voice-ring 0.1.2 → 0.2.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.
package/dist/index.es.js CHANGED
@@ -1,35 +1,35 @@
1
- import { jsx as Xn } from "react/jsx-runtime";
2
- import { useState as Bt, useEffect as It, useRef as St, useCallback as Gn } from "react";
3
- let Ut = null;
4
- function Vn() {
1
+ import { jsx as jn } from "react/jsx-runtime";
2
+ import { useState as Wt, useEffect as Dt, useRef as It, useCallback as On } from "react";
3
+ let Zt = null;
4
+ function Zn() {
5
5
  if (typeof window > "u") return null;
6
- const t = window;
7
- return t.AudioContext ?? t.webkitAudioContext ?? null;
6
+ const n = window;
7
+ return n.AudioContext ?? n.webkitAudioContext ?? null;
8
8
  }
9
- function Re() {
10
- return Vn() != null;
9
+ function Le() {
10
+ return Zn() != null;
11
11
  }
12
- function Hn() {
13
- const t = Vn();
14
- return t ? (Ut || (Ut = new t()), Ut.state === "suspended" && Ut.resume().catch(() => {
15
- }), Ut) : null;
12
+ function Jn() {
13
+ const n = Zn();
14
+ return n ? (Zt || (Zt = new n()), Zt.state === "suspended" && Zt.resume().catch(() => {
15
+ }), Zt) : null;
16
16
  }
17
- const fn = /* @__PURE__ */ new WeakMap();
18
- function ps(t) {
19
- const n = Hn();
20
- if (!n || t.getAudioTracks().length === 0) return null;
21
- let e = fn.get(t);
22
- e || (e = { node: n.createMediaStreamSource(t), refs: 0 }, fn.set(t, e)), e.refs += 1;
23
- const s = n.createAnalyser();
24
- s.fftSize = 1024, s.smoothingTimeConstant = 0.5, e.node.connect(s);
17
+ const gn = /* @__PURE__ */ new WeakMap();
18
+ function ys(n) {
19
+ const s = Jn();
20
+ if (!s || n.getAudioTracks().length === 0) return null;
21
+ let e = gn.get(n);
22
+ e || (e = { node: s.createMediaStreamSource(n), refs: 0 }, gn.set(n, e)), e.refs += 1;
23
+ const t = s.createAnalyser();
24
+ t.fftSize = 1024, t.smoothingTimeConstant = 0.5, e.node.connect(t);
25
25
  let o = !1;
26
26
  return {
27
- analyser: s,
27
+ analyser: t,
28
28
  release: () => {
29
29
  if (!o) {
30
30
  o = !0;
31
31
  try {
32
- e.node.disconnect(s);
32
+ e.node.disconnect(t);
33
33
  } catch {
34
34
  }
35
35
  if (e.refs -= 1, e.refs <= 0) {
@@ -37,58 +37,58 @@ function ps(t) {
37
37
  e.node.disconnect();
38
38
  } catch {
39
39
  }
40
- fn.delete(t);
40
+ gn.delete(n);
41
41
  }
42
42
  }
43
43
  }
44
44
  };
45
45
  }
46
- const tn = {
46
+ const Ot = {
47
47
  positive: { r: 92, g: 224, b: 150 },
48
48
  negative: { r: 255, g: 104, b: 104 },
49
49
  calm: { r: 104, g: 162, b: 255 }
50
- }, ms = {
51
- green: tn.positive,
52
- red: tn.negative,
53
- blue: tn.calm
54
- }, Ms = 0.7, gs = 1.1, bs = 0.6;
55
- class vs {
50
+ }, xs = {
51
+ green: Ot.positive,
52
+ red: Ot.negative,
53
+ blue: Ot.calm
54
+ }, ws = 0.7, Ss = 1.1, Es = 0.6;
55
+ class Ts {
56
56
  constructor() {
57
57
  this.glow = { r: 0, g: 0, b: 0, amount: 0, t: 0, size: 0 };
58
58
  }
59
59
  /** Advance toward `target` (null: fade out). `still` jumps straight there. */
60
- step(n, e, s, o, c) {
61
- const r = this.glow, l = (a) => c ? 1 : 1 - Math.exp(-n / a), i = e ? 1 : 0;
62
- if (r.amount += (i - r.amount) * l(i > r.amount ? Ms : gs), e) {
63
- const a = r.amount < 0.03 ? 1 : l(bs);
64
- r.r += (e.r - r.r) * a, r.g += (e.g - r.g) * a, r.b += (e.b - r.b) * a;
60
+ step(s, e, t, o, r) {
61
+ const c = this.glow, h = (a) => r ? 1 : 1 - Math.exp(-s / a), i = e ? 1 : 0;
62
+ if (c.amount += (i - c.amount) * h(i > c.amount ? ws : Ss), e) {
63
+ const a = c.amount < 0.03 ? 1 : h(Es);
64
+ c.r += (e.r - c.r) * a, c.g += (e.g - c.g) * a, c.b += (e.b - c.b) * a;
65
65
  }
66
- return r.t = s, r.size = o, r;
66
+ return c.t = t, c.size = o, c;
67
67
  }
68
68
  }
69
- const Kn = (t, n) => {
69
+ const Qn = (n, s) => {
70
70
  var e;
71
- return ((e = t.light) == null ? void 0 : e.r) ?? n * 0.28;
71
+ return ((e = n.light) == null ? void 0 : e.r) ?? s * 0.28;
72
72
  };
73
- function xs(t, n, e) {
74
- const o = (Kn(t, n) * 0.7) ** 2, c = 0.9 * Math.min(1, Math.max(0, e.amount)), r = (l, i) => {
75
- const a = e.x - l, d = e.y - i, h = c * Math.exp(-(a * a + d * d) / o);
76
- return [l + a * h, i + d * h];
73
+ function Rs(n, s, e) {
74
+ const o = (Qn(n, s) * 0.7) ** 2, r = 0.9 * Math.min(1, Math.max(0, e.amount)), c = (h, i) => {
75
+ const a = e.x - h, f = e.y - i, l = r * Math.exp(-(a * a + f * f) / o);
76
+ return [h + a * l, i + f * l];
77
77
  };
78
78
  return {
79
- ...t,
80
- strokes: t.strokes.map((l) => {
81
- const i = l.pts.slice();
82
- for (let a = 0; a < i.length; a += 2) [i[a], i[a + 1]] = r(i[a], i[a + 1]);
83
- return { ...l, pts: i };
79
+ ...n,
80
+ strokes: n.strokes.map((h) => {
81
+ const i = h.pts.slice();
82
+ for (let a = 0; a < i.length; a += 2) [i[a], i[a + 1]] = c(i[a], i[a + 1]);
83
+ return { ...h, pts: i };
84
84
  }),
85
- dots: t.dots.map((l) => {
86
- const [i, a] = r(l.x, l.y);
87
- return { ...l, x: i, y: a };
85
+ dots: n.dots.map((h) => {
86
+ const [i, a] = c(h.x, h.y);
87
+ return { ...h, x: i, y: a };
88
88
  })
89
89
  };
90
90
  }
91
- const ys = (t, n) => Math.min(1, Math.max(0, (0.8 * n - t) / (0.6 * n))), bt = {
91
+ const As = (n, s) => Math.min(1, Math.max(0, (0.8 * s - n) / (0.6 * s))), Rt = {
92
92
  move: 2,
93
93
  pull: 0.7,
94
94
  deform: 0.1,
@@ -99,11 +99,11 @@ const ys = (t, n) => Math.min(1, Math.max(0, (0.8 * n - t) / (0.6 * n))), bt = {
99
99
  blur: 1,
100
100
  bounce: 1
101
101
  };
102
- function ws(t, n) {
103
- const e = Math.abs(t.move) + Math.abs(t.pull) + 2 * Math.abs(t.deform);
104
- return e === 0 ? 0 : Math.ceil(n * 0.36 * e) + 2;
102
+ function Ps(n, s) {
103
+ const e = Math.abs(n.move) + Math.abs(n.pull) + 2 * Math.abs(n.deform);
104
+ return e === 0 ? 0 : Math.ceil(s * 0.36 * e) + 2;
105
105
  }
106
- class Es {
106
+ class _s {
107
107
  constructor() {
108
108
  this.x = 0, this.v = 0, this.landed = !1;
109
109
  }
@@ -112,312 +112,423 @@ class Es {
112
112
  * lags as the orb arrives, but only a rebound counts as behind: the orb
113
113
  * never backs off the edge before it has pressed into it.
114
114
  */
115
- step(n, e) {
116
- const c = Math.max(1, Math.ceil(e * 240)), r = e / c;
117
- for (let i = 0; i < c; i++)
118
- this.v += (15 * 15 * (n - this.x) - 2 * 0.3 * 15 * this.v) * r, this.x += this.v * r;
119
- const l = this.x - n;
120
- return n <= 0 ? this.landed = !1 : l >= 0 && (this.landed = !0), l < 0 && !this.landed ? 0 : l;
115
+ step(s, e) {
116
+ const r = Math.max(1, Math.ceil(e * 240)), c = e / r;
117
+ for (let i = 0; i < r; i++)
118
+ this.v += (15 * 15 * (s - this.x) - 2 * 0.3 * 15 * this.v) * c, this.x += this.v * c;
119
+ const h = this.x - s;
120
+ return s <= 0 ? this.landed = !1 : h >= 0 && (this.landed = !0), h < 0 && !this.landed ? 0 : h;
121
121
  }
122
122
  }
123
- function Ss(t, n, e, s, o = [1 / 0, 1 / 0], c = 0) {
124
- if (Math.abs(n) < 2e-3 || s.move === 0 && s.pull === 0 && s.deform === 0) return t;
125
- const r = e / 2, l = e * 0.36, i = n < 0 ? -1 : 1, a = Math.abs(n), d = (b, E) => {
126
- const y = (b - r) / l, I = (E - r) / l, R = Math.max(0, Math.min(1, (y * i + 1) / 2)), G = Math.max(0, y * i);
127
- return n * l * (s.move + s.pull * R * R + s.deform * G * G * Math.exp(-I * I * 1.5));
128
- }, h = Math.max(0, Math.min(2, s.lens ?? 1)), f = l * 0.9, m = i > 0 ? o[1] : o[0], p = Number.isFinite(m) ? Math.min(f * 0.45, l * 0.3 * h * Math.max(0, s.stretch ?? 1)) : 0;
129
- let M = 1, v = 1 / 0, A = 1;
130
- if (Number.isFinite(m)) {
131
- v = i > 0 ? e + m : -m;
132
- const b = (E, y, I) => {
133
- A = Math.max(A, I);
134
- const R = d(E, y) * i;
135
- R > 1e-9 && (M = Math.min(M, Math.max(0, ((v - E) * i - I - p) / R)));
123
+ function Cs(n, s, e, t, o = [1 / 0, 1 / 0], r = 0) {
124
+ if (Math.abs(s) < 2e-3 || t.move === 0 && t.pull === 0 && t.deform === 0) return n;
125
+ const c = e / 2, h = e * 0.36, i = s < 0 ? -1 : 1, a = Math.abs(s), f = (w, T) => {
126
+ const F = (w - c) / h, P = (T - c) / h, S = Math.max(0, Math.min(1, (F * i + 1) / 2)), I = Math.max(0, F * i);
127
+ return s * h * (t.move + t.pull * S * S + t.deform * I * I * Math.exp(-P * P * 1.5));
128
+ }, l = Math.max(0, Math.min(2, t.lens ?? 1)), u = h * 0.9, p = i > 0 ? o[1] : o[0], d = Number.isFinite(p) ? Math.min(u * 0.45, h * 0.3 * l * Math.max(0, t.stretch ?? 1)) : 0;
129
+ let g = 1, M = 1 / 0, y = 1;
130
+ if (Number.isFinite(p)) {
131
+ M = i > 0 ? e + p : -p;
132
+ const w = (T, F, P) => {
133
+ y = Math.max(y, P);
134
+ const S = f(T, F) * i;
135
+ S > 1e-9 && (g = Math.min(g, Math.max(0, ((M - T) * i - P - d) / S)));
136
136
  };
137
- for (const E of t.dots) b(E.x, E.y, E.r);
138
- for (const E of t.strokes) for (let y = 0; y < E.pts.length; y += 2) b(E.pts[y], E.pts[y + 1], 1);
137
+ for (const T of n.dots) w(T.x, T.y, T.r);
138
+ for (const T of n.strokes) for (let F = 0; F < T.pts.length; F += 2) w(T.pts[F], T.pts[F + 1], 1);
139
139
  }
140
- const u = M < 1 ? Math.min(1, (1 - M) / 0.35) : 0, g = u > 0 ? c * (s.bounce ?? 1) : 0, x = Math.min(1.4, u + Math.max(0, g)), B = l * 0.12 * Math.max(0, -g), S = v - i * A, L = S - i * p, w = l * 0.55 * x * (s.squash ?? 0);
141
- let k = 1 / 0, _ = -1 / 0, q = !0;
142
- const U = (b, E) => {
143
- const y = Math.max(0, Math.min(1, ((b - r) / l * i + 1) / 2)), I = 1 - 0.15 * s.deform * a * M * y;
144
- let R = b + d(b, E) * M + i * (w * 0.5 - B), G = r + (E - r) * I;
145
- if (w > 0) {
146
- const C = (R - (L - i * w)) * i;
147
- if (C > 0) {
148
- const F = C / w, T = w * (F / Math.sqrt(1 + F * F));
149
- R = L - i * w + i * T, G = r + (G - r) * (1 + 0.18 * x * (s.squash ?? 0) * (T / w));
140
+ const m = g < 1 ? Math.min(1, (1 - g) / 0.35) : 0, R = m > 0 ? r * (t.bounce ?? 1) : 0, b = Math.min(1.4, m + Math.max(0, R)), A = h * 0.12 * Math.max(0, -R), v = M - i * y, E = v - i * d, x = h * 0.55 * b * (t.squash ?? 0);
141
+ let k = 1 / 0, C = -1 / 0, z = !0;
142
+ const B = (w, T) => {
143
+ const F = Math.max(0, Math.min(1, ((w - c) / h * i + 1) / 2)), P = 1 - 0.15 * t.deform * a * g * F;
144
+ let S = w + f(w, T) * g + i * (x * 0.5 - A), I = c + (T - c) * P;
145
+ if (x > 0) {
146
+ const G = (S - (E - i * x)) * i;
147
+ if (G > 0) {
148
+ const L = G / x, _ = x * (L / Math.sqrt(1 + L * L));
149
+ S = E - i * x + i * _, I = c + (I - c) * (1 + 0.18 * b * (t.squash ?? 0) * (_ / x));
150
150
  }
151
151
  }
152
- return q && (L - R) * i < Math.max(w, f * 0.3) && (k = Math.min(k, G), _ = Math.max(_, G)), [R, G];
152
+ return z && (E - S) * i < Math.max(x, u * 0.3) && (k = Math.min(k, I), C = Math.max(C, I)), [S, I];
153
153
  };
154
- for (const b of t.dots)
155
- [b.x, b.y] = U(b.x, b.y);
156
- for (const b of t.strokes)
157
- for (let E = 0; E < b.pts.length; E += 2) {
158
- const [y, I] = U(b.pts[E], b.pts[E + 1]);
159
- b.pts[E] = y, b.pts[E + 1] = I;
154
+ for (const w of n.dots)
155
+ [w.x, w.y] = B(w.x, w.y);
156
+ for (const w of n.strokes)
157
+ for (let T = 0; T < w.pts.length; T += 2) {
158
+ const [F, P] = B(w.pts[T], w.pts[T + 1]);
159
+ w.pts[T] = F, w.pts[T + 1] = P;
160
160
  }
161
- if (u > 0 && _ > k) {
162
- const b = h * x;
163
- t.contact = {
161
+ if (m > 0 && C > k) {
162
+ const w = l * b;
163
+ n.contact = {
164
164
  side: i,
165
- x: S,
165
+ x: v,
166
166
  y0: k,
167
- y1: _,
168
- depth: w,
169
- press: u,
170
- lens: b > 0.02 ? {
171
- zone: f,
167
+ y1: C,
168
+ depth: x,
169
+ press: m,
170
+ lens: w > 0.02 ? {
171
+ zone: u,
172
172
  // drawn across the gap as it presses, all the way at full press
173
- gap: p * Math.min(1, x),
174
- flare: 0.22 * b * Math.max(0, s.stretch ?? 1),
175
- split: f * 0.1 * b * Math.max(0, s.split ?? 1),
176
- blur: f * 0.075 * b * Math.max(0, s.blur ?? 1),
177
- cy: r
173
+ gap: d * Math.min(1, b),
174
+ flare: 0.22 * w * Math.max(0, t.stretch ?? 1),
175
+ split: u * 0.1 * w * Math.max(0, t.split ?? 1),
176
+ blur: u * 0.075 * w * Math.max(0, t.blur ?? 1),
177
+ cy: c
178
178
  } : void 0
179
179
  };
180
180
  }
181
- if (q = !1, t.light) {
182
- const b = t.light;
183
- [b.cx, b.cy] = U(b.cx, b.cy);
184
- for (const E of b.spec) [E.x, E.y] = U(E.x, E.y);
181
+ if (z = !1, n.light) {
182
+ const w = n.light;
183
+ [w.cx, w.cy] = B(w.cx, w.cy);
184
+ for (const T of w.spec) [T.x, T.y] = B(T.x, T.y);
185
185
  }
186
- return t;
186
+ return n;
187
187
  }
188
188
  const Mt = Math.PI * 2;
189
- function Ct(t, n, e) {
190
- return t + (n - t) * e;
189
+ function Gt(n, s, e) {
190
+ return n + (s - n) * e;
191
191
  }
192
- function j(t) {
193
- return t < 0 ? 0 : t > 1 ? 1 : t;
192
+ function $(n) {
193
+ return n < 0 ? 0 : n > 1 ? 1 : n;
194
194
  }
195
- function wn(t, n, e) {
196
- const s = j((e - t) / (n - t));
197
- return s * s * (3 - 2 * s);
195
+ function Qt(n, s, e) {
196
+ const t = $((e - n) / (s - n));
197
+ return t * t * (3 - 2 * t);
198
198
  }
199
- const jt = (t) => t < 1e-6 ? 1 : Math.sin(t) / t, Ts = Math.hypot(2.1, 1.3), Rs = Math.hypot(1.9, 1.7), As = Math.hypot(4.3 - 2.9, -3.7, -3.1), _s = Math.hypot(4.3 + 2.9, 3.7, -3.1);
200
- function En(t, n, e, s = 1) {
201
- const o = 1 / Math.max(0.05, s), c = 0.9 * e, r = -0.7 * e + 1.3, l = 2.1 * e, i = -1.6 * e, a = t * (0.55 * Math.sin(c) * jt(Ts * o) + 0.45 * Math.sin(r) * jt(Rs * o)) + n * 0.5 * (Math.cos(l - i) * jt(As * o) - Math.cos(l + i) * jt(_s * o));
202
- return (d, h, f) => (d *= o, h *= o, f *= o, t * (0.55 * Math.sin(2.1 * d + 1.3 * h + c) + 0.45 * Math.sin(1.7 * f - 1.9 * h + r)) + n * Math.sin(4.3 * d - 3.1 * f + l) * Math.sin(3.7 * h + 2.9 * d + i) - a);
199
+ const en = (n) => n < 1e-6 ? 1 : Math.sin(n) / n, Bs = Math.hypot(2.1, 1.3), Is = Math.hypot(1.9, 1.7), Fs = Math.hypot(4.3 - 2.9, -3.7, -3.1), ks = Math.hypot(4.3 + 2.9, 3.7, -3.1);
200
+ function Pn(n, s, e, t = 1) {
201
+ const o = 1 / Math.max(0.05, t), r = 0.9 * e, c = -0.7 * e + 1.3, h = 2.1 * e, i = -1.6 * e, a = n * (0.55 * Math.sin(r) * en(Bs * o) + 0.45 * Math.sin(c) * en(Is * o)) + s * 0.5 * (Math.cos(h - i) * en(Fs * o) - Math.cos(h + i) * en(ks * o));
202
+ return (f, l, u) => (f *= o, l *= o, u *= o, n * (0.55 * Math.sin(2.1 * f + 1.3 * l + r) + 0.45 * Math.sin(1.7 * u - 1.9 * l + c)) + s * Math.sin(4.3 * f - 3.1 * u + h) * Math.sin(3.7 * l + 2.9 * f + i) - a);
203
203
  }
204
- function Tt(t, n) {
205
- const e = Math.sin(t * 12.9898 + n * 78.233) * 43758.5453;
204
+ function Ft(n, s) {
205
+ const e = Math.sin(n * 12.9898 + s * 78.233) * 43758.5453;
206
206
  return e - Math.floor(e);
207
207
  }
208
- function Et(t, n, e) {
209
- const s = Math.sin(t * 127.1 + n * 311.7 + e * 74.7) * 43758.5453;
210
- return s - Math.floor(s);
208
+ function Bt(n, s, e) {
209
+ const t = Math.sin(n * 127.1 + s * 311.7 + e * 74.7) * 43758.5453;
210
+ return t - Math.floor(t);
211
211
  }
212
- function zt(t, n, e) {
213
- const s = Math.floor(t), o = Math.floor(n), c = Math.floor(e);
214
- let r = t - s, l = n - o, i = e - c;
215
- r = r * r * (3 - 2 * r), l = l * l * (3 - 2 * l), i = i * i * (3 - 2 * i);
216
- const a = Ct(Et(s, o, c), Et(s + 1, o, c), r), d = Ct(Et(s, o + 1, c), Et(s + 1, o + 1, c), r), h = Ct(Et(s, o, c + 1), Et(s + 1, o, c + 1), r), f = Ct(Et(s, o + 1, c + 1), Et(s + 1, o + 1, c + 1), r);
217
- return Ct(Ct(a, d, l), Ct(h, f, l), i);
212
+ function Jt(n, s, e) {
213
+ const t = Math.floor(n), o = Math.floor(s), r = Math.floor(e);
214
+ let c = n - t, h = s - o, i = e - r;
215
+ c = c * c * (3 - 2 * c), h = h * h * (3 - 2 * h), i = i * i * (3 - 2 * i);
216
+ const a = Gt(Bt(t, o, r), Bt(t + 1, o, r), c), f = Gt(Bt(t, o + 1, r), Bt(t + 1, o + 1, r), c), l = Gt(Bt(t, o, r + 1), Bt(t + 1, o, r + 1), c), u = Gt(Bt(t, o + 1, r + 1), Bt(t + 1, o + 1, r + 1), c);
217
+ return Gt(Gt(a, f, h), Gt(l, u, h), i);
218
218
  }
219
- function Sn(t, n) {
220
- const e = Math.PI * (3 - Math.sqrt(5)), s = 1 - 2 * (t + 0.5) / n, o = Math.sqrt(1 - s * s), c = t * e;
221
- return [o * Math.cos(c), s, o * Math.sin(c)];
219
+ function _n(n, s) {
220
+ const e = Math.PI * (3 - Math.sqrt(5)), t = 1 - 2 * (n + 0.5) / s, o = Math.sqrt(1 - t * t), r = n * e;
221
+ return [o * Math.cos(r), t, o * Math.sin(r)];
222
222
  }
223
- function nn(t, n, e, s, o) {
224
- const c = Math.sin(n), r = Math.cos(n), l = Math.sin(t), i = Math.cos(t);
225
- return (a, d, h) => {
226
- const f = a * i + h * l, m = -a * l + h * i, p = d * r - m * c, M = d * c + m * r;
227
- return [e + f * o, s - p * o, M];
223
+ function hn(n, s, e, t, o) {
224
+ const r = Math.sin(s), c = Math.cos(s), h = Math.sin(n), i = Math.cos(n);
225
+ return (a, f, l) => {
226
+ const u = a * i + l * h, p = -a * h + l * i, d = f * c - p * r, g = f * r + p * c;
227
+ return [e + u * o, t - d * o, g];
228
228
  };
229
229
  }
230
- function $t(t, n = 0.6) {
231
- return (t / 200) ** n;
230
+ function Xt(n, s = 0.6) {
231
+ return (n / 200) ** s;
232
232
  }
233
- function Gt(t, n, e = 0.3) {
234
- const s = [];
235
- for (const o of t)
236
- (o.a ?? 1) < 0.02 || (o.r = Math.max(e, o.r), s.push(o));
237
- return s.sort((o, c) => o.z - c.z), { dots: s, strokes: n };
233
+ function Vt(n, s, e = 0.3) {
234
+ const t = [];
235
+ for (const o of n)
236
+ (o.a ?? 1) < 0.02 || (o.r = Math.max(e, o.r), t.push(o));
237
+ return t.sort((o, r) => o.z - r.z), { dots: t, strokes: s };
238
238
  }
239
- const Zt = 32;
240
- function Ps(t, n = 0, e = 0, s = 1) {
241
- const o = t.r / 255, c = t.g / 255, r = t.b / 255, l = Math.max(o, c, r), i = Math.min(o, c, r);
242
- let a = (l + i) / 2, d = l === i ? 0 : (l - i) / (1 - Math.abs(2 * a - 1)), h = 0;
243
- if (l !== i) {
244
- const M = l - i;
245
- h = l === o ? (c - r) / M % 6 : l === c ? (r - o) / M + 2 : (o - c) / M + 4, h *= 60;
239
+ const on = 32;
240
+ function Ns(n, s = 0, e = 0, t = 1) {
241
+ const o = n.r / 255, r = n.g / 255, c = n.b / 255, h = Math.max(o, r, c), i = Math.min(o, r, c);
242
+ let a = (h + i) / 2, f = h === i ? 0 : (h - i) / (1 - Math.abs(2 * a - 1)), l = 0;
243
+ if (h !== i) {
244
+ const g = h - i;
245
+ l = h === o ? (r - c) / g % 6 : h === r ? (c - o) / g + 2 : (o - r) / g + 4, l *= 60;
246
246
  }
247
- h = ((h + n) % 360 + 360) % 360, d = Math.min(1, d * (1 + e)), a = 0.5 + (a - 0.5) * (1 - 0.6 * e), a = Math.max(0, Math.min(1, a * s));
248
- const f = (M) => (M + h / 30) % 12, m = d * Math.min(a, 1 - a), p = (M) => a - m * Math.max(-1, Math.min(f(M) - 3, 9 - f(M), 1));
249
- return [Math.round(p(0) * 255), Math.round(p(8) * 255), Math.round(p(4) * 255)];
247
+ l = ((l + s) % 360 + 360) % 360, f = Math.min(1, f * (1 + e)), a = 0.5 + (a - 0.5) * (1 - 0.6 * e), a = Math.max(0, Math.min(1, a * t));
248
+ const u = (g) => (g + l / 30) % 12, p = f * Math.min(a, 1 - a), d = (g) => a - p * Math.max(-1, Math.min(u(g) - 3, 9 - u(g), 1));
249
+ return [Math.round(d(0) * 255), Math.round(d(8) * 255), Math.round(d(4) * 255)];
250
250
  }
251
- function ks(t) {
252
- const n = Math.max(0, Math.min(1, t.saturation)), e = Math.max(0, Math.min(1, t.neutral)), s = t.start ?? 0.1, o = Math.max(0.05, t.width ?? 0.6), c = [];
253
- for (let h = 0; h < Zt; h++) {
254
- const f = h / (Zt - 1), m = Math.max(0, Math.min(1, (f - s) / o)), p = m * m * (3 - 2 * m);
255
- c.push(n * (1 - e * (1 - p)));
251
+ function zs(n) {
252
+ const s = Math.max(0, Math.min(1, n.saturation)), e = Math.max(0, Math.min(1, n.neutral)), t = n.start ?? 0.1, o = Math.max(0.05, n.width ?? 0.6), r = [];
253
+ for (let l = 0; l < on; l++) {
254
+ const u = l / (on - 1), p = Math.max(0, Math.min(1, (u - t) / o)), d = p * p * (3 - 2 * p);
255
+ r.push(s * (1 - e * (1 - d)));
256
256
  }
257
- const r = t.angle * Math.PI / 180, l = Math.cos(r), i = Math.sin(r), a = t.size / 2, d = t.size * 0.8;
257
+ const c = n.angle * Math.PI / 180, h = Math.cos(c), i = Math.sin(c), a = n.size / 2, f = n.size * 0.8;
258
258
  return {
259
- rgb: Ps(t.accent, t.hue, Math.max(0, Math.min(1, t.vivid ?? 0)), t.brightness),
260
- mix: c,
261
- saturation: n,
262
- at: (h, f) => {
263
- const m = ((h - a) * l + (f - a) * i) / d + 0.5;
264
- return Math.max(0, Math.min(Zt - 1, Math.round(m * (Zt - 1))));
259
+ rgb: Ns(n.accent, n.hue, Math.max(0, Math.min(1, n.vivid ?? 0)), n.brightness),
260
+ mix: r,
261
+ saturation: s,
262
+ at: (l, u) => {
263
+ const p = ((l - a) * h + (u - a) * i) / f + 0.5;
264
+ return Math.max(0, Math.min(on - 1, Math.round(p * (on - 1))));
265
265
  }
266
266
  };
267
267
  }
268
- const Cs = [120, 232, 214], Fs = [64, 72, 255];
269
- function Dn(t, n, e) {
270
- t /= 255, n /= 255, e /= 255;
271
- const s = Math.max(t, n, e), o = Math.min(t, n, e), c = (s + o) / 2;
272
- if (s === o) return [0, 0, c];
273
- const r = s - o, l = c > 0.5 ? r / (2 - s - o) : r / (s + o);
274
- return [(s === t ? (n - e) / r + (n < e ? 6 : 0) : s === n ? (e - t) / r + 2 : (t - n) / r + 4) / 6, l, c];
268
+ const Gs = [120, 232, 214], Ls = [64, 72, 255];
269
+ function qn(n, s, e) {
270
+ n /= 255, s /= 255, e /= 255;
271
+ const t = Math.max(n, s, e), o = Math.min(n, s, e), r = (t + o) / 2;
272
+ if (t === o) return [0, 0, r];
273
+ const c = t - o, h = r > 0.5 ? c / (2 - t - o) : c / (t + o);
274
+ return [(t === n ? (s - e) / c + (s < e ? 6 : 0) : t === s ? (e - n) / c + 2 : (n - s) / c + 4) / 6, h, r];
275
275
  }
276
- function Is(t, n, e) {
277
- const s = (r) => (r + t * 12) % 12, o = n * Math.min(e, 1 - e), c = (r) => e - o * Math.max(-1, Math.min(s(r) - 3, 9 - s(r), 1));
278
- return [c(0) * 255, c(8) * 255, c(4) * 255];
276
+ function Ds(n, s, e) {
277
+ const t = (c) => (c + n * 12) % 12, o = s * Math.min(e, 1 - e), r = (c) => e - o * Math.max(-1, Math.min(t(c) - 3, 9 - t(c), 1));
278
+ return [r(0) * 255, r(8) * 255, r(4) * 255];
279
279
  }
280
- const dn = (t) => (t /= 255) <= 0.04045 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4, Ns = (t) => 255 * (t <= 31308e-7 ? 12.92 * t : 1.055 * Math.max(0, t) ** (1 / 2.4) - 0.055);
281
- function yn(t, n, e) {
282
- const [s, o, c] = [dn(t), dn(n), dn(e)], r = Math.cbrt(0.4122214708 * s + 0.5363325363 * o + 0.0514459929 * c), l = Math.cbrt(0.2119034982 * s + 0.6806995451 * o + 0.1073969566 * c), i = Math.cbrt(0.0883024619 * s + 0.2817188376 * o + 0.6299787005 * c);
280
+ const bn = (n) => (n /= 255) <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4, Os = (n) => 255 * (n <= 31308e-7 ? 12.92 * n : 1.055 * Math.max(0, n) ** (1 / 2.4) - 0.055);
281
+ function rn(n, s, e) {
282
+ const [t, o, r] = [bn(n), bn(s), bn(e)], c = Math.cbrt(0.4122214708 * t + 0.5363325363 * o + 0.0514459929 * r), h = Math.cbrt(0.2119034982 * t + 0.6806995451 * o + 0.1073969566 * r), i = Math.cbrt(0.0883024619 * t + 0.2817188376 * o + 0.6299787005 * r);
283
283
  return [
284
- 0.2104542553 * r + 0.793617785 * l - 0.0040720468 * i,
285
- 1.9779984951 * r - 2.428592205 * l + 0.4505937099 * i,
286
- 0.0259040371 * r + 0.7827717662 * l - 0.808675766 * i
284
+ 0.2104542553 * c + 0.793617785 * h - 0.0040720468 * i,
285
+ 1.9779984951 * c - 2.428592205 * h + 0.4505937099 * i,
286
+ 0.0259040371 * c + 0.7827717662 * h - 0.808675766 * i
287
287
  ];
288
288
  }
289
- function Yn(t, n, e) {
290
- const s = (t + 0.3963377774 * n + 0.2158037573 * e) ** 3, o = (t - 0.1055613458 * n - 0.0638541728 * e) ** 3, c = (t - 0.0894841775 * n - 1.291485548 * e) ** 3, r = (l) => Math.max(0, Math.min(255, Ns(l)));
289
+ function Cn(n, s, e) {
290
+ const t = (n + 0.3963377774 * s + 0.2158037573 * e) ** 3, o = (n - 0.1055613458 * s - 0.0638541728 * e) ** 3, r = (n - 0.0894841775 * s - 1.291485548 * e) ** 3, c = (h) => Math.max(0, Math.min(255, Os(h)));
291
291
  return [
292
- r(4.0767416621 * s - 3.3077115913 * o + 0.2309699292 * c),
293
- r(-1.2684380046 * s + 2.6097574011 * o - 0.3413193965 * c),
294
- r(-0.0041960863 * s - 0.7034186147 * o + 1.707614701 * c)
292
+ c(4.0767416621 * t - 3.3077115913 * o + 0.2309699292 * r),
293
+ c(-1.2684380046 * t + 2.6097574011 * o - 0.3413193965 * r),
294
+ c(-0.0041960863 * t - 0.7034186147 * o + 1.707614701 * r)
295
295
  ];
296
296
  }
297
- const Bs = 146 / 360, Gs = [81, 136], Ln = 0.1;
298
- function Ds(t, n = Gs) {
299
- const e = (n[0] + n[1]) / 720, s = (n[1] - n[0]) / 720, o = Math.abs((t - Bs + 1.5) % 1 - 0.5), c = Math.max(0, 1 - o / (40 / 360));
300
- return [t + (e - t) * c, Ln + (s - Ln) * c];
297
+ const qs = 146 / 360, Us = [81, 136], Un = 0.1;
298
+ function $s(n, s = Us) {
299
+ const e = (s[0] + s[1]) / 720, t = (s[1] - s[0]) / 720, o = Math.abs((n - qs + 1.5) % 1 - 0.5), r = Math.max(0, 1 - o / (40 / 360));
300
+ return [n + (e - n) * r, Un + (t - Un) * r];
301
301
  }
302
- function Ls(t, n, e, s, o) {
303
- const c = s && s.amount > 5e-3 ? s : void 0;
304
- return t.map(([r, l, i, a]) => {
305
- if (e && (l += (e.r - l) * 0.85, i += (e.g - i) * 0.85, a += (e.b - a) * 0.85), c) {
306
- const [, h, f] = Dn(l, i, a), [m, p] = Ds(Dn(c.r, c.g, c.b)[0], o), M = Is((m + p * Math.sin(2 * Math.PI * r) + 1) % 1, h, f), v = yn(l, i, a), A = yn(M[0], M[1], M[2]), u = c.amount;
307
- [l, i, a] = Yn(v[0] + (A[0] - v[0]) * u, v[1] + (A[1] - v[1]) * u, v[2] + (A[2] - v[2]) * u);
302
+ function Ws(n, s, e, t, o) {
303
+ const r = t && t.amount > 5e-3 ? t : void 0;
304
+ return n.map(([c, h, i, a]) => {
305
+ if (e && (h += (e.r - h) * 0.85, i += (e.g - i) * 0.85, a += (e.b - a) * 0.85), r) {
306
+ const [, l, u] = qn(h, i, a), [p, d] = $s(qn(r.r, r.g, r.b)[0], o), g = Ds((p + d * Math.sin(2 * Math.PI * c) + 1) % 1, l, u), M = rn(h, i, a), y = rn(g[0], g[1], g[2]), m = r.amount;
307
+ [h, i, a] = Cn(M[0] + (y[0] - M[0]) * m, M[1] + (y[1] - M[1]) * m, M[2] + (y[2] - M[2]) * m);
308
308
  }
309
- const d = n ? 1 : 0.82;
310
- return [r, l * d, i * d, a * d];
309
+ const f = s ? 1 : 0.82;
310
+ return [c, h * f, i * f, a * f];
311
+ });
312
+ }
313
+ function Xs(n, s) {
314
+ if (!s.hue && s.chroma === 1 && !s.warmth && s.contrast === 1) return n;
315
+ const e = n.map(([, c, h, i]) => rn(c, h, i)), t = e.reduce((c, [h]) => c + h, 0) / e.length, o = Math.cos(s.hue * Math.PI / 180), r = Math.sin(s.hue * Math.PI / 180);
316
+ return n.map(([c], h) => {
317
+ const [i, a, f] = e[h], l = Math.max(0, Math.min(1, t + (i - t) * s.contrast)), u = (a * o - f * r) * s.chroma + 0.02 * s.warmth, p = (a * r + f * o) * s.chroma + 0.07 * s.warmth;
318
+ return [c, ...Cn(l, u, p)];
311
319
  });
312
320
  }
313
- const jn = (t, n, e) => `rgb(${Math.round(t)},${Math.round(n)},${Math.round(e)})`;
314
- function qs(t, n = 36) {
315
- const e = t.filter(([a]) => a < 1), s = e.length;
316
- if (s < 3) return t;
317
- const o = e.map(([, a, d, h]) => yn(a, d, h)), c = (a) => (a % s + s) % s, r = (a) => e[c(a)][0] + Math.floor(a / s), l = (a) => {
318
- const d = r(a + 1) - r(a - 1);
319
- return o[c(a + 1)].map((h, f) => (h - o[c(a - 1)][f]) / d);
321
+ function Vs(n, s) {
322
+ if (s <= 1) return n;
323
+ const e = [];
324
+ for (let t = 0; t < s; t++) for (const [o, r, c, h] of n) e.push([(o + t) / s, r, c, h]);
325
+ return e;
326
+ }
327
+ const vn = {
328
+ hue: 0,
329
+ chroma: 1,
330
+ warmth: 0,
331
+ contrast: 1,
332
+ cycles: 1,
333
+ glowSize: 1,
334
+ bloom: 1,
335
+ bloomSize: 1,
336
+ soft: 1.5,
337
+ core: 1
338
+ }, ts = (n, s, e) => `rgb(${Math.round(n)},${Math.round(s)},${Math.round(e)})`;
339
+ function Ks(n, s = 36) {
340
+ const e = n.filter(([a]) => a < 1), t = e.length;
341
+ if (t < 3) return n;
342
+ const o = e.map(([, a, f, l]) => rn(a, f, l)), r = (a) => (a % t + t) % t, c = (a) => e[r(a)][0] + Math.floor(a / t), h = (a) => {
343
+ const f = c(a + 1) - c(a - 1);
344
+ return o[r(a + 1)].map((l, u) => (l - o[r(a - 1)][u]) / f);
320
345
  }, i = [];
321
- for (let a = 0; a <= n; a++) {
322
- const d = a / n;
323
- let h = -1;
324
- for (; h < s - 1 && r(h + 1) <= d; ) h++;
325
- const f = r(h + 1) - r(h), m = (d - r(h)) / f, p = m * m, M = p * m, v = o[c(h)], A = o[c(h + 1)], u = l(h), g = l(h + 1), x = [0, 1, 2].map(
326
- (w) => (2 * M - 3 * p + 1) * v[w] + (M - 2 * p + m) * f * u[w] + (-2 * M + 3 * p) * A[w] + (M - p) * f * g[w]
327
- ), [B, S, L] = Yn(x[0], x[1], x[2]);
328
- i.push([d, B, S, L]);
346
+ for (let a = 0; a <= s; a++) {
347
+ const f = a / s;
348
+ let l = -1;
349
+ for (; l < t - 1 && c(l + 1) <= f; ) l++;
350
+ const u = c(l + 1) - c(l), p = (f - c(l)) / u, d = p * p, g = d * p, M = o[r(l)], y = o[r(l + 1)], m = h(l), R = h(l + 1), b = [0, 1, 2].map(
351
+ (x) => (2 * g - 3 * d + 1) * M[x] + (g - 2 * d + p) * u * m[x] + (-2 * g + 3 * d) * y[x] + (g - d) * u * R[x]
352
+ ), [A, v, E] = Cn(b[0], b[1], b[2]);
353
+ i.push([f, A, v, E]);
329
354
  }
330
355
  return i;
331
356
  }
332
- const Os = 1.5, Zn = typeof CanvasRenderingContext2D == "function" && "filter" in CanvasRenderingContext2D.prototype, qn = /* @__PURE__ */ new WeakMap();
333
- function pn(t, n) {
334
- return (typeof OffscreenCanvas == "function" ? new OffscreenCanvas(t, n) : Object.assign(document.createElement("canvas"), { width: t, height: n })).getContext("2d");
357
+ const ns = typeof CanvasRenderingContext2D == "function" && "filter" in CanvasRenderingContext2D.prototype, $n = /* @__PURE__ */ new WeakMap();
358
+ function yn(n, s) {
359
+ return (typeof OffscreenCanvas == "function" ? new OffscreenCanvas(n, s) : Object.assign(document.createElement("canvas"), { width: n, height: s })).getContext("2d");
335
360
  }
336
- function Us(t) {
337
- const { width: n, height: e } = t.canvas;
338
- let s = qn.get(t);
339
- return (!s || s.full.canvas.width !== n || s.full.canvas.height !== e) && (s = { full: pn(n, e) }, Zn || (s.half = pn(Math.ceil(n / 2), Math.ceil(e / 2)), s.quarter = pn(Math.ceil(n / 4), Math.ceil(e / 4))), qn.set(t, s)), s.full.setTransform(1, 0, 0, 1, 0, 0), s.full.clearRect(0, 0, n, e), s.full.setTransform(t.getTransform()), s;
361
+ function Ys(n) {
362
+ const { width: s, height: e } = n.canvas;
363
+ let t = $n.get(n);
364
+ return (!t || t.full.canvas.width !== s || t.full.canvas.height !== e) && (t = { full: yn(s, e) }, ns || (t.half = yn(Math.ceil(s / 2), Math.ceil(e / 2)), t.quarter = yn(Math.ceil(s / 4), Math.ceil(e / 4))), $n.set(n, t)), t.full.setTransform(1, 0, 0, 1, 0, 0), t.full.clearRect(0, 0, s, e), t.full.setTransform(n.getTransform()), t;
340
365
  }
341
- function mn(t, n) {
342
- t.globalCompositeOperation = "copy", t.imageSmoothingEnabled = !0, t.imageSmoothingQuality = "high", t.drawImage(n.canvas, 0, 0, t.canvas.width, t.canvas.height);
366
+ function xn(n, s) {
367
+ n.globalCompositeOperation = "copy", n.imageSmoothingEnabled = !0, n.imageSmoothingQuality = "high", n.drawImage(s.canvas, 0, 0, n.canvas.width, n.canvas.height);
343
368
  }
344
- function zs(t, n, e) {
345
- const s = t.getTransform();
346
- t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.globalCompositeOperation = e, t.globalAlpha = 1, t.imageSmoothingEnabled = !0, t.imageSmoothingQuality = "high", Zn ? (t.filter = `blur(${Os * Math.hypot(s.a, s.b)}px)`, t.drawImage(n.full.canvas, 0, 0)) : n.half && n.quarter && (mn(n.half, n.full), mn(n.quarter, n.half), mn(n.half, n.quarter), t.drawImage(n.half.canvas, 0, 0, n.half.canvas.width * 2, n.half.canvas.height * 2)), t.restore();
369
+ function Hs(n, s, e, t) {
370
+ const o = n.getTransform();
371
+ n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalCompositeOperation = e, n.globalAlpha = 1, n.imageSmoothingEnabled = !0, n.imageSmoothingQuality = "high", ns || t <= 0 ? (t > 0 && (n.filter = `blur(${t * Math.hypot(o.a, o.b)}px)`), n.drawImage(s.full.canvas, 0, 0)) : s.half && s.quarter && (xn(s.half, s.full), xn(s.quarter, s.half), xn(s.half, s.quarter), n.drawImage(s.half.canvas, 0, 0, s.half.canvas.width * 2, s.half.canvas.height * 2)), n.restore();
347
372
  }
348
- function On(t, n, e) {
349
- const s = typeof t.createConicGradient == "function" ? t.createConicGradient(n.angle, n.cx, n.cy) : t.createLinearGradient(n.cx - n.r, n.cy - n.r, n.cx + n.r, n.cy + n.r);
350
- for (const [o, c, r, l] of e) s.addColorStop(j(o), jn(c, r, l));
351
- return s;
373
+ function Wn(n, s, e) {
374
+ const t = typeof n.createConicGradient == "function" ? n.createConicGradient(s.angle, s.cx, s.cy) : n.createLinearGradient(s.cx - s.r, s.cy - s.r, s.cx + s.r, s.cy + s.r);
375
+ for (const [o, r, c, h] of e) t.addColorStop($(o), ts(r, c, h));
376
+ return t;
352
377
  }
353
- function $s(t, n, e, s, o, c) {
354
- const r = qs(Ls(e.stops, s, o, c, e.green)), l = On(t, e, r), i = n.strokes.map((u) => {
355
- const g = new Path2D(), x = u.pts.length >> 1;
356
- let B = 0;
357
- for (let S = 0; S < x; S++)
358
- S === 0 ? g.moveTo(u.pts[0], u.pts[1]) : g.lineTo(u.pts[2 * S], u.pts[2 * S + 1]), B += u.a[S];
359
- return u.closed && g.closePath(), { p: g, a: x ? B / x : 1, w: u.w };
360
- }), a = Math.max(1, i.length), d = e.intensity, h = s ? "lighter" : "source-over", f = (u, g, x = t) => {
361
- for (const B of i)
362
- x.lineWidth = u(B.w), x.globalAlpha = j(g(B.a)), x.stroke(B.p);
363
- }, m = (u, g) => {
364
- u.lineCap = "round", u.lineJoin = "round", u.globalCompositeOperation = h, u.strokeStyle = g;
365
- }, p = Us(t), M = p.full;
366
- m(M, On(M, e, r));
367
- const v = e.halo * d * (s ? 1 : 0.2) / a;
368
- for (const [u, g] of [
378
+ function js(n, s, e, t, o, r) {
379
+ var R;
380
+ const c = { ...vn };
381
+ for (const b of Object.keys(vn)) c[b] = ((R = e.look) == null ? void 0 : R[b]) ?? vn[b];
382
+ const h = Vs(Ks(Ws(Xs(e.stops, c), t, o, r, e.green)), Math.round(c.cycles)), i = Wn(n, e, h), a = s.strokes.map((b) => {
383
+ const A = new Path2D(), v = b.pts.length >> 1;
384
+ let E = 0;
385
+ for (let x = 0; x < v; x++)
386
+ x === 0 ? A.moveTo(b.pts[0], b.pts[1]) : A.lineTo(b.pts[2 * x], b.pts[2 * x + 1]), E += b.a[x];
387
+ return b.closed && A.closePath(), { p: A, a: v ? E / v : 1, w: b.w };
388
+ }), f = Math.max(1, a.length), l = e.intensity, u = t ? "lighter" : "source-over", p = (b, A, v = n) => {
389
+ for (const E of a)
390
+ v.lineWidth = b(E.w), v.globalAlpha = $(A(E.a)), v.stroke(E.p);
391
+ }, d = (b, A) => {
392
+ b.lineCap = "round", b.lineJoin = "round", b.globalCompositeOperation = u, b.strokeStyle = A;
393
+ }, g = Ys(n), M = g.full;
394
+ d(M, Wn(M, e, h));
395
+ const y = e.halo * l * (t ? 1 : 0.2) / f;
396
+ for (const [b, A] of [
369
397
  [0.7, 0.045],
370
398
  [0.42, 0.075],
371
399
  [0.24, 0.11],
372
400
  [0.12, 0.16]
373
401
  ])
374
- f(
375
- () => e.r * u,
376
- () => g * v,
402
+ p(
403
+ () => e.r * b * c.glowSize,
404
+ () => A * y,
377
405
  M
378
406
  );
379
- const A = d * (s ? 1 : 0.6);
380
- for (const [u, g] of [
407
+ const m = l * (t ? 1 : 0.6) * c.bloom;
408
+ for (const [b, A] of [
381
409
  [16, 0.05],
382
410
  [8, 0.11],
383
411
  [4, 0.2]
384
412
  ])
385
- f(
386
- (x) => x * u,
387
- (x) => g * A * x,
413
+ p(
414
+ (v) => v * b * c.bloomSize,
415
+ (v) => A * m * v,
388
416
  M
389
417
  );
390
- if (zs(t, p, h), t.save(), m(t, l), s && e.fringe > 0) {
391
- for (const [u, g, x] of [
392
- [1 + e.fringe, Cs, 0.16],
393
- [1 - e.fringe, Fs, 0.22]
418
+ if (Hs(n, g, u, c.soft), n.save(), d(n, i), t && e.fringe > 0) {
419
+ for (const [b, A, v] of [
420
+ [1 + e.fringe, Gs, 0.16],
421
+ [1 - e.fringe, Ls, 0.22]
394
422
  ])
395
- t.save(), t.translate(e.cx, e.cy), t.scale(u, u), t.translate(-e.cx, -e.cy), t.strokeStyle = jn(g[0], g[1], g[2]), f(
396
- (B) => B * 1.4 / u,
397
- (B) => x * d * B
398
- ), t.restore();
399
- t.strokeStyle = l;
423
+ n.save(), n.translate(e.cx, e.cy), n.scale(b, b), n.translate(-e.cx, -e.cy), n.strokeStyle = ts(A[0], A[1], A[2]), p(
424
+ (E) => E * 1.4 / b,
425
+ (E) => v * l * E
426
+ ), n.restore();
427
+ n.strokeStyle = i;
400
428
  }
401
- if (f(
402
- (u) => u,
403
- (u) => 0.7 * u * (0.75 + 0.25 * d)
404
- ), s)
405
- for (const u of e.spec) {
406
- const g = t.createRadialGradient(u.x, u.y, 0, u.x, u.y, u.r);
407
- g.addColorStop(0, "rgba(255,255,255,1)"), g.addColorStop(0.35, "rgba(255,255,255,0.45)"), g.addColorStop(1, "rgba(255,255,255,0)"), t.strokeStyle = g, f(
408
- (x) => x * 2.2,
409
- (x) => u.a * x
429
+ if (p(
430
+ (b) => b,
431
+ (b) => 0.7 * b * (0.75 + 0.25 * l) * c.core
432
+ ), t)
433
+ for (const b of e.spec) {
434
+ const A = n.createRadialGradient(b.x, b.y, 0, b.x, b.y, b.r);
435
+ A.addColorStop(0, "rgba(255,255,255,1)"), A.addColorStop(0.35, "rgba(255,255,255,0.45)"), A.addColorStop(1, "rgba(255,255,255,0)"), n.strokeStyle = A, p(
436
+ (v) => v * 2.2,
437
+ (v) => b.a * v
410
438
  );
411
439
  }
412
- t.restore();
440
+ n.restore();
441
+ }
442
+ const Xn = 6;
443
+ function Zs(n, s) {
444
+ const e = [
445
+ [Ot.positive, n.positiveBrightness ?? 1],
446
+ [Ot.negative, n.negativeBrightness ?? 1],
447
+ [Ot.calm, n.calmBrightness ?? 1]
448
+ ];
449
+ let t = 0, o = 0;
450
+ for (const [r, c] of e) {
451
+ const h = Math.exp(-((s.r - r.r) ** 2 + (s.g - r.g) ** 2 + (s.b - r.b) ** 2) / 6e3);
452
+ t += h * c, o += h;
453
+ }
454
+ return o > 1e-6 ? t / o : 1;
455
+ }
456
+ function wn(n, s, e, t, o, r = 1) {
457
+ const c = s ? 255 * (0.16 + 0.84 * n) : 255 * (0.1 + 0.6 * (1 - n));
458
+ let h = c, i = c, a = c;
459
+ if (t) {
460
+ const l = (u) => s ? u * c / 255 : u + (255 - u) * (c / 255) * 0.7;
461
+ h += (l(t.r) - h) * 0.85, i += (l(t.g) - i) * 0.85, a += (l(t.b) - a) * 0.85;
462
+ }
463
+ if (o) {
464
+ const l = (e.colorBrightness ?? 1) * Zs(e, o), u = (g) => s ? Math.min(255, g * (0.3 + 0.9 * n) * l + 90 * n ** 4) : Math.min(255, g * (0.45 + 0.55 * (1 - n)) * l), p = o.amount * r;
465
+ h += (u(o.r) - h) * p, i += (u(o.g) - i) * p, a += (u(o.b) - a) * p;
466
+ const d = e.saturation ?? 1;
467
+ if (d !== 1) {
468
+ const g = (h + i + a) / 3;
469
+ h = g + (h - g) * d, i = g + (i - g) * d, a = g + (a - g) * d;
470
+ }
471
+ }
472
+ const f = (l) => Math.round(Math.max(0, Math.min(255, l)));
473
+ return `rgb(${f(h)},${f(i)},${f(a)})`;
413
474
  }
414
- const Ws = `
475
+ function Js(n, s, e, t, o, r) {
476
+ var g;
477
+ const c = (M, y) => $(0.5 + (M.a[y] - 0.5) * e.contrast), h = [];
478
+ for (const M of s) {
479
+ const y = M.pts.length >> 1, m = M.closed ? y : y - 1;
480
+ for (let R = 0; R < m; R += Xn) {
481
+ const b = Math.min(m, R + Xn);
482
+ let A = 0;
483
+ for (let E = R; E <= b; E++) A += ((g = M.z) == null ? void 0 : g[E % y]) ?? 0;
484
+ const v = M.closed ? R - 1 : Math.max(0, R - 1);
485
+ h.push({ s: M, from: v, to: b, z: A / (b - R + 1) });
486
+ }
487
+ }
488
+ h.sort((M, y) => M.z - y.z);
489
+ const i = r && r.amount > 5e-3 ? r : void 0;
490
+ let a = 0, f = 0, l = 0;
491
+ if (i) {
492
+ for (const M of s)
493
+ for (let y = 0; y < M.pts.length; y += 2)
494
+ a += M.pts[y], f += M.pts[y + 1], l++;
495
+ a /= l || 1, f /= l || 1;
496
+ }
497
+ const u = ((e.gradientAngle ?? 0) + (e.gradientSpin ?? 20) * ((r == null ? void 0 : r.t) ?? 0)) * Math.PI / 180, p = $(e.gradient ?? 1), d = (M, y) => {
498
+ if (!i) return 1;
499
+ const m = (Math.sin(Math.atan2(M.pts[2 * y + 1] - f, M.pts[2 * y] - a) + u) + 1) / 2;
500
+ return 1 - p * (1 - Qt(0, 1, m));
501
+ };
502
+ n.save(), n.lineCap = "butt", n.lineJoin = "round";
503
+ for (const { s: M, from: y, to: m, z: R } of h) {
504
+ const b = M.pts.length >> 1, A = (S) => (S % b + b) % b, v = new Path2D();
505
+ for (let S = y; S <= m; S++) {
506
+ const I = A(S);
507
+ S === y ? v.moveTo(M.pts[2 * I], M.pts[2 * I + 1]) : v.lineTo(M.pts[2 * I], M.pts[2 * I + 1]);
508
+ }
509
+ const E = A(y), x = A(m), k = e.depth ?? 0.15, C = M.w * (1 - k + k * R);
510
+ n.globalCompositeOperation = "destination-out", n.strokeStyle = "#000", n.lineWidth = C * 1.35, n.stroke(v), n.globalCompositeOperation = "source-over";
511
+ const z = M.pts[2 * E], B = M.pts[2 * E + 1], w = M.pts[2 * x], T = M.pts[2 * x + 1];
512
+ if (Math.hypot(w - z, T - B) > 0.5) {
513
+ const S = n.createLinearGradient(z, B, w, T);
514
+ S.addColorStop(0, wn(c(M, E), t, e, o, i, d(M, E))), S.addColorStop(1, wn(c(M, x), t, e, o, i, d(M, x))), n.strokeStyle = S;
515
+ } else n.strokeStyle = wn(c(M, E), t, e, o, i, d(M, E));
516
+ n.lineWidth = C, n.stroke(v);
517
+ let F = 0;
518
+ for (let S = y; S <= m; S++) F += c(M, A(S));
519
+ F /= m - y + 1;
520
+ const P = $(e.shine * (t ? 0.6 : 0.45) * F * F);
521
+ P > 0.01 && (n.save(), n.translate(-0.17 * C, -0.19 * C), n.strokeStyle = `rgba(255,255,255,${P.toFixed(3)})`, n.lineWidth = C * 0.32, n.stroke(v), n.restore());
522
+ }
523
+ n.restore();
524
+ }
525
+ const Qs = `
415
526
  attribute vec2 aPos;
416
527
  varying vec2 vUv;
417
528
  void main() {
418
529
  vUv = vec2(aPos.x + 1.0, 1.0 - aPos.y) * 0.5;
419
530
  gl_Position = vec4(aPos, 0.0, 1.0);
420
- }`, Xs = `
531
+ }`, te = `
421
532
  precision highp float;
422
533
  uniform sampler2D uTex;
423
534
  uniform vec2 uSize;
@@ -452,88 +563,88 @@ void main() {
452
563
  }
453
564
  gl_FragColor = vec4(rgb, a) / float(TAPS);
454
565
  }`;
455
- let Jt;
456
- function Vs() {
566
+ let an;
567
+ function ne() {
457
568
  if (typeof document > "u") return null;
458
- const t = document.createElement("canvas"), n = t.getContext("webgl", { premultipliedAlpha: !0, antialias: !1, depth: !1 });
459
- if (!n) return null;
569
+ const n = document.createElement("canvas"), s = n.getContext("webgl", { premultipliedAlpha: !0, antialias: !1, depth: !1 });
570
+ if (!s) return null;
460
571
  const e = (i, a) => {
461
- const d = n.createShader(i);
462
- return n.shaderSource(d, a), n.compileShader(d), d;
463
- }, s = n.createProgram();
464
- if (n.attachShader(s, e(n.VERTEX_SHADER, Ws)), n.attachShader(s, e(n.FRAGMENT_SHADER, Xs)), n.linkProgram(s), !n.getProgramParameter(s, n.LINK_STATUS)) return null;
465
- n.useProgram(s);
466
- const o = n.createBuffer();
467
- n.bindBuffer(n.ARRAY_BUFFER, o), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), n.STATIC_DRAW);
468
- const c = n.getAttribLocation(s, "aPos");
469
- n.enableVertexAttribArray(c), n.vertexAttribPointer(c, 2, n.FLOAT, !1, 0, 0);
470
- const r = n.createTexture();
471
- n.bindTexture(n.TEXTURE_2D, r), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_S, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_WRAP_T, n.CLAMP_TO_EDGE), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.LINEAR), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.LINEAR), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0);
472
- const l = {};
572
+ const f = s.createShader(i);
573
+ return s.shaderSource(f, a), s.compileShader(f), f;
574
+ }, t = s.createProgram();
575
+ if (s.attachShader(t, e(s.VERTEX_SHADER, Qs)), s.attachShader(t, e(s.FRAGMENT_SHADER, te)), s.linkProgram(t), !s.getProgramParameter(t, s.LINK_STATUS)) return null;
576
+ s.useProgram(t);
577
+ const o = s.createBuffer();
578
+ s.bindBuffer(s.ARRAY_BUFFER, o), s.bufferData(s.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), s.STATIC_DRAW);
579
+ const r = s.getAttribLocation(t, "aPos");
580
+ s.enableVertexAttribArray(r), s.vertexAttribPointer(r, 2, s.FLOAT, !1, 0, 0);
581
+ const c = s.createTexture();
582
+ s.bindTexture(s.TEXTURE_2D, c), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.LINEAR), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.LINEAR), s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0);
583
+ const h = {};
473
584
  for (const i of ["uSize", "uWall", "uSide", "uZone", "uGap", "uFlare", "uSplit", "uBlur", "uCy"])
474
- l[i] = n.getUniformLocation(s, i);
475
- return { gl: n, canvas: t, source: document.createElement("canvas"), tex: r, u: l };
585
+ h[i] = s.getUniformLocation(t, i);
586
+ return { gl: s, canvas: n, source: document.createElement("canvas"), tex: c, u: h };
476
587
  }
477
- function Hs(t, n, e, s) {
478
- if (Jt === void 0 && (Jt = Vs()), !Jt) return !1;
479
- const { gl: o, canvas: c, source: r, tex: l, u: i } = Jt, a = t.getTransform(), d = Math.hypot(a.a, a.b) || 1, h = t.canvas.width, f = t.canvas.height, m = a.a * e + a.e, p = s.zone * d, M = s.blur * d, v = Math.max(0, Math.floor(n > 0 ? m - p - 2 * M - 4 : 0)), u = Math.min(h, Math.ceil(n > 0 ? h : m + p + 2 * M + 4)) - v;
480
- if (u < 2 || f < 2) return !1;
481
- (r.width !== u || r.height !== f) && (r.width = u, r.height = f);
482
- const g = r.getContext("2d");
483
- return g.clearRect(0, 0, u, f), g.drawImage(t.canvas, v, 0, u, f, 0, 0, u, f), (c.width !== u || c.height !== f) && (c.width = u, c.height = f), o.viewport(0, 0, u, f), o.bindTexture(o.TEXTURE_2D, l), o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, r), o.uniform2f(i.uSize, u, f), o.uniform1f(i.uWall, m - v), o.uniform1f(i.uSide, n), o.uniform1f(i.uZone, p), o.uniform1f(i.uGap, s.gap * d), o.uniform1f(i.uFlare, s.flare), o.uniform1f(i.uSplit, s.split * d), o.uniform1f(i.uBlur, M), o.uniform1f(i.uCy, a.d * s.cy + a.f), o.clearColor(0, 0, 0, 0), o.clear(o.COLOR_BUFFER_BIT), o.drawArrays(o.TRIANGLE_STRIP, 0, 4), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.globalCompositeOperation = "copy", t.beginPath(), t.rect(v, 0, u, f), t.clip(), t.drawImage(c, v, 0), t.restore(), !0;
588
+ function se(n, s, e, t) {
589
+ if (an === void 0 && (an = ne()), !an) return !1;
590
+ const { gl: o, canvas: r, source: c, tex: h, u: i } = an, a = n.getTransform(), f = Math.hypot(a.a, a.b) || 1, l = n.canvas.width, u = n.canvas.height, p = a.a * e + a.e, d = t.zone * f, g = t.blur * f, M = Math.max(0, Math.floor(s > 0 ? p - d - 2 * g - 4 : 0)), m = Math.min(l, Math.ceil(s > 0 ? l : p + d + 2 * g + 4)) - M;
591
+ if (m < 2 || u < 2) return !1;
592
+ (c.width !== m || c.height !== u) && (c.width = m, c.height = u);
593
+ const R = c.getContext("2d");
594
+ return R.clearRect(0, 0, m, u), R.drawImage(n.canvas, M, 0, m, u, 0, 0, m, u), (r.width !== m || r.height !== u) && (r.width = m, r.height = u), o.viewport(0, 0, m, u), o.bindTexture(o.TEXTURE_2D, h), o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, c), o.uniform2f(i.uSize, m, u), o.uniform1f(i.uWall, p - M), o.uniform1f(i.uSide, s), o.uniform1f(i.uZone, d), o.uniform1f(i.uGap, t.gap * f), o.uniform1f(i.uFlare, t.flare), o.uniform1f(i.uSplit, t.split * f), o.uniform1f(i.uBlur, g), o.uniform1f(i.uCy, a.d * t.cy + a.f), o.clearColor(0, 0, 0, 0), o.clear(o.COLOR_BUFFER_BIT), o.drawArrays(o.TRIANGLE_STRIP, 0, 4), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalCompositeOperation = "copy", n.beginPath(), n.rect(M, 0, m, u), n.clip(), n.drawImage(r, M, 0), n.restore(), !0;
484
595
  }
485
- function Jn(t, n, e, s) {
486
- const o = 2.2 / s.size, c = zt(t * o + s.t * 0.11, n * o - s.t * 0.08, s.t * 0.07), r = wn(0.3, 0.75, c);
487
- return s.amount * (0.2 + 0.75 * r) * j(1.3 - e);
596
+ function ss(n, s, e, t) {
597
+ const o = 2.2 / t.size, r = Jt(n * o + t.t * 0.11, s * o - t.t * 0.08, t.t * 0.07), c = Qt(0.3, 0.75, r);
598
+ return t.amount * (0.2 + 0.75 * c) * $(1.3 - e);
488
599
  }
489
- function Qn(t, n, e, s, o, c = 0, r, l = 0) {
490
- const i = Math.round(n * 1e3) / 1e3, a = (p) => e ? p * (1 - t) : p + (255 - p) * t, d = (e ? 1 - t : t) * 255;
491
- let h = s ? a(s.r) : d, f = s ? a(s.g) : d, m = s ? a(s.b) : d;
492
- return r && l > 0 && (h += (a(r[0]) - h) * l, f += (a(r[1]) - f) * l, m += (a(r[2]) - m) * l), o && c > 0 && (h += (a(o.r) - h) * c, f += (a(o.g) - f) * c, m += (a(o.b) - m) * c), `rgba(${Math.round(h)},${Math.round(f)},${Math.round(m)},${i})`;
600
+ function es(n, s, e, t, o, r = 0, c, h = 0) {
601
+ const i = Math.round(s * 1e3) / 1e3, a = (d) => e ? d * (1 - n) : d + (255 - d) * n, f = (e ? 1 - n : n) * 255;
602
+ let l = t ? a(t.r) : f, u = t ? a(t.g) : f, p = t ? a(t.b) : f;
603
+ return c && h > 0 && (l += (a(c[0]) - l) * h, u += (a(c[1]) - u) * h, p += (a(c[2]) - p) * h), o && r > 0 && (l += (a(o.r) - l) * r, u += (a(o.g) - u) * r, p += (a(o.b) - p) * r), `rgba(${Math.round(l)},${Math.round(u)},${Math.round(p)},${i})`;
493
604
  }
494
- const Un = 24, zn = 8;
495
- function Ks(t, n, e, s, o, c) {
496
- const r = o && o.amount > 5e-3 ? o : void 0, l = c && c.saturation > 0 ? c : void 0, i = /* @__PURE__ */ new Map();
497
- for (const a of n) {
498
- const d = a.pts.length >> 1, h = a.closed ? d : d - 1;
499
- let f = "", m;
500
- for (let p = 0; p < h; p++) {
501
- const M = p + 1 === d ? 0 : p + 1, v = Math.round(j((a.a[p] + a.a[M]) / 2) * Un);
502
- if (v === 0) {
503
- f = "";
605
+ const Vn = 24, Kn = 8;
606
+ function ee(n, s, e, t, o, r) {
607
+ const c = o && o.amount > 5e-3 ? o : void 0, h = r && r.saturation > 0 ? r : void 0, i = /* @__PURE__ */ new Map();
608
+ for (const a of s) {
609
+ const f = a.pts.length >> 1, l = a.closed ? f : f - 1;
610
+ let u = "", p;
611
+ for (let d = 0; d < l; d++) {
612
+ const g = d + 1 === f ? 0 : d + 1, M = Math.round($((a.a[d] + a.a[g]) / 2) * Vn);
613
+ if (M === 0) {
614
+ u = "";
504
615
  continue;
505
616
  }
506
- const A = r ? Math.round(
507
- Jn((a.pts[2 * p] + a.pts[2 * M]) / 2, (a.pts[2 * p + 1] + a.pts[2 * M + 1]) / 2, a.white, r) * zn
508
- ) : 0, u = l ? l.at((a.pts[2 * p] + a.pts[2 * M]) / 2, (a.pts[2 * p + 1] + a.pts[2 * M + 1]) / 2) : 0, g = `${v}|${a.white}|${Math.round(a.w * 20)}|${A}|${u}`;
509
- if (g !== f) {
510
- let x = i.get(g);
511
- x || (x = { path: new Path2D(), white: a.white, w: a.w, a: v / Un, gw: A / zn, ci: u }, i.set(g, x)), m = x, f = g, x.path.moveTo(a.pts[2 * p], a.pts[2 * p + 1]);
617
+ const y = c ? Math.round(
618
+ ss((a.pts[2 * d] + a.pts[2 * g]) / 2, (a.pts[2 * d + 1] + a.pts[2 * g + 1]) / 2, a.white, c) * Kn
619
+ ) : 0, m = h ? h.at((a.pts[2 * d] + a.pts[2 * g]) / 2, (a.pts[2 * d + 1] + a.pts[2 * g + 1]) / 2) : 0, R = `${M}|${a.white}|${Math.round(a.w * 20)}|${y}|${m}`;
620
+ if (R !== u) {
621
+ let b = i.get(R);
622
+ b || (b = { path: new Path2D(), white: a.white, w: a.w, a: M / Vn, gw: y / Kn, ci: m }, i.set(R, b)), p = b, u = R, b.path.moveTo(a.pts[2 * d], a.pts[2 * d + 1]);
512
623
  }
513
- m.path.lineTo(a.pts[2 * M], a.pts[2 * M + 1]);
624
+ p.path.lineTo(a.pts[2 * g], a.pts[2 * g + 1]);
514
625
  }
515
626
  }
516
- t.lineCap = "round", t.lineJoin = "round";
627
+ n.lineCap = "round", n.lineJoin = "round";
517
628
  for (const a of i.values())
518
- t.strokeStyle = Qn(j(a.white), a.a, e, s, r, a.gw, l == null ? void 0 : l.rgb, l == null ? void 0 : l.mix[a.ci]), t.lineWidth = a.w, t.stroke(a.path);
629
+ n.strokeStyle = es($(a.white), a.a, e, t, c, a.gw, h == null ? void 0 : h.rgb, h == null ? void 0 : h.mix[a.ci]), n.lineWidth = a.w, n.stroke(a.path);
519
630
  }
520
- function Ys(t, n, e, s, o, c, r = !1) {
521
- const l = o && o.amount > 5e-3 ? o : void 0, i = c && c.saturation > 0 ? c : void 0;
522
- for (const a of n) {
523
- const d = j(a.white), h = l ? Jn(a.x, a.y, d, l) : 0, f = i ? i.at(a.x, a.y) : 0;
524
- if (t.fillStyle = Qn(d, j(a.a ?? 1), e, s, l, h, i == null ? void 0 : i.rgb, i == null ? void 0 : i.mix[f]), r) {
525
- t.fillRect(a.x - a.r, a.y - a.r, 2 * a.r, 2 * a.r);
631
+ function oe(n, s, e, t, o, r, c = !1) {
632
+ const h = o && o.amount > 5e-3 ? o : void 0, i = r && r.saturation > 0 ? r : void 0;
633
+ for (const a of s) {
634
+ const f = $(a.white), l = h ? ss(a.x, a.y, f, h) : 0, u = i ? i.at(a.x, a.y) : 0;
635
+ if (n.fillStyle = es(f, $(a.a ?? 1), e, t, h, l, i == null ? void 0 : i.rgb, i == null ? void 0 : i.mix[u]), c) {
636
+ n.fillRect(a.x - a.r, a.y - a.r, 2 * a.r, 2 * a.r);
526
637
  continue;
527
638
  }
528
- t.beginPath(), t.arc(a.x, a.y, a.r, 0, Mt), t.fill();
639
+ n.beginPath(), n.arc(a.x, a.y, a.r, 0, Mt), n.fill();
529
640
  }
530
641
  }
531
- function js(t, n, e, s, o, c) {
532
- var l;
533
- const r = c && c.saturation > 0 && !n.light ? ks(c) : void 0;
534
- n.light ? $s(t, n, n.light, e, s, o) : n.strokes.length && Ks(t, n.strokes, e, s, o, r), Ys(t, n.dots, e, s, o, r, n.square), (l = n.contact) != null && l.lens && Hs(t, n.contact.side, n.contact.x, n.contact.lens);
642
+ function ae(n, s, e, t, o, r) {
643
+ var h;
644
+ const c = r && r.saturation > 0 && !s.light ? zs(r) : void 0;
645
+ s.light ? js(n, s, s.light, e, t, o) : s.tube ? Js(n, s.strokes, s.tube, e, t, o) : s.strokes.length && ee(n, s.strokes, e, t, o, c), oe(n, s.dots, e, t, o, c, s.square), (h = s.contact) != null && h.lens && se(n, s.contact.side, s.contact.x, s.contact.lens);
535
646
  }
536
- const Zs = [
647
+ const ce = [
537
648
  [0, 255, 150, 90],
538
649
  [0.12, 255, 110, 120],
539
650
  [0.24, 255, 80, 170],
@@ -545,173 +656,225 @@ const Zs = [
545
656
  [0.84, 170, 90, 255],
546
657
  [0.93, 240, 104, 165],
547
658
  [1, 255, 150, 90]
548
- ], Js = (t, n, e, s) => {
549
- const o = t / 2, c = e.level, [r, l] = e.softBands, i = e.bands[2], a = e.drive, d = e.processing, h = 0.5 * c + 0.5 * e.soft, f = o * (s.radius ?? 0.56) * (1 + (s.zoom ?? 0.17) * e.soft) * (1 - 0.06 * d), m = s.deform ?? 1.45, p = 0.02 + (0.14 * r + 0.06 * c) * m, M = 0.01 + (0.07 * l + 0.03 * i) * m, v = En(p, M, a, s.deformRadius ?? 1.75), A = Math.max(0.6, (s.lineW ?? 1.85) * $t(t, 0.5)), u = Math.max(1, Math.round(s.rings ?? 6)), g = Math.max(24, Math.round(s.segs ?? 140)), x = s.lean ?? 0.91, B = s.ringGap ?? 0.02, S = [];
550
- let L = 0, w = 0;
551
- for (let y = 0; y < u; y++) {
552
- const I = 0.16 * (0.5 + Tt(y, 2.1)) * (y % 2 ? 1 : -1), R = Math.max(
659
+ ], re = (n, s, e, t) => {
660
+ const o = n / 2, r = e.level, [c, h] = e.softBands, i = e.bands[2], a = e.drive, f = e.processing, l = 0.5 * r + 0.5 * e.soft, u = o * (t.radius ?? 0.56) * (1 + (t.zoom ?? 0.17) * e.soft) * (1 - 0.06 * f), p = t.deform ?? 1.45, d = 0.02 + (0.14 * c + 0.06 * r) * p, g = 0.01 + (0.07 * h + 0.03 * i) * p, M = Pn(d, g, a, t.deformRadius ?? 1.75), y = Math.max(0.6, (t.lineW ?? 1.85) * Xt(n, 0.5)), m = Math.max(1, Math.round(t.rings ?? 6)), R = Math.max(24, Math.round(t.segs ?? 140)), b = t.lean ?? 0.91, A = t.ringGap ?? 0.02, v = [];
661
+ let E = 0, x = 0;
662
+ for (let P = 0; P < m; P++) {
663
+ const S = 0.16 * (0.5 + Ft(P, 2.1)) * (P % 2 ? 1 : -1), I = Math.max(
553
664
  0.02,
554
- x * (0.2 + 0.8 * Tt(y, 3.1)) + 0.03 * Math.sin(n * 0.27 + y * 1.3) + 0.08 * Math.sin(a * 0.35 + y * 1.7)
555
- ), G = Tt(y, 7.7) * Mt + n * 0.05 * (y % 2 ? 1 : -1) + a * I, C = Math.sin(R) * Math.cos(G), F = Math.sin(R) * Math.sin(G), T = Math.cos(R), P = Math.hypot(C, T), N = T / P, O = -C / P, z = F * O, W = T * N - C * O, X = -F * N, Q = f * (1 + B * (y - (u - 1) / 2)), Z = Math.sin(R), V = [], at = [], nt = [];
556
- for (let H = 0; H < g; H++) {
557
- const st = H / g * Mt, $ = Math.cos(st), ht = Math.sin(st), ut = N * $ + z * ht, tt = W * ht, ft = O * $ + X * ht, dt = v(ut, tt, ft);
558
- V.push(ut, tt), at.push(dt), L += dt, w++, nt.push(0.62 + 0.38 * j((ft / Z + 1) / 2));
665
+ b * (0.2 + 0.8 * Ft(P, 3.1)) + 0.03 * Math.sin(s * 0.27 + P * 1.3) + 0.08 * Math.sin(a * 0.35 + P * 1.7)
666
+ ), G = Ft(P, 7.7) * Mt + s * 0.05 * (P % 2 ? 1 : -1) + a * S, L = Math.sin(I) * Math.cos(G), _ = Math.sin(I) * Math.sin(G), N = Math.cos(I), D = Math.hypot(L, N), q = N / D, U = -L / D, V = _ * U, K = N * q - L * U, J = -_ * q, Y = u * (1 + A * (P - (m - 1) / 2)), H = Math.sin(I), ht = [], rt = [], j = [];
667
+ for (let et = 0; et < R; et++) {
668
+ const X = et / R * Mt, gt = Math.cos(X), lt = Math.sin(X), Q = q * gt + V * lt, ot = K * lt, at = U * gt + J * lt, tt = M(Q, ot, at);
669
+ ht.push(Q, ot), rt.push(tt), E += tt, x++, j.push(0.62 + 0.38 * $((at / H + 1) / 2));
559
670
  }
560
- S.push({ dirs: V, f: at, a: nt, rk: Q });
671
+ v.push({ dirs: ht, f: rt, a: j, rk: Y });
561
672
  }
562
- const k = w ? L / w : 0;
563
- let _ = 0, q = 0;
564
- for (const { dirs: y, f: I } of S)
565
- for (let R = 0; R < I.length; R++) {
566
- const G = y[2 * R], C = y[2 * R + 1], F = Math.hypot(G, C) || 1;
567
- _ += (I[R] - k) * (G / F), q += (I[R] - k) * (C / F);
673
+ const k = x ? E / x : 0;
674
+ let C = 0, z = 0;
675
+ for (const { dirs: P, f: S } of v)
676
+ for (let I = 0; I < S.length; I++) {
677
+ const G = P[2 * I], L = P[2 * I + 1], _ = Math.hypot(G, L) || 1;
678
+ C += (S[I] - k) * (G / _), z += (S[I] - k) * (L / _);
568
679
  }
569
- _ = w ? 2 * _ / w : 0, q = w ? 2 * q / w : 0;
570
- const U = S.map(({ dirs: y, f: I, a: R, rk: G }) => {
571
- const C = [];
572
- for (let F = 0; F < I.length; F++) {
573
- const T = y[2 * F], P = y[2 * F + 1], N = Math.hypot(T, P) || 1, O = G * (1 + I[F] - k - _ * (T / N) - q * (P / N));
574
- C.push(o + T * O, o - P * O);
680
+ C = x ? 2 * C / x : 0, z = x ? 2 * z / x : 0;
681
+ const B = v.map(({ dirs: P, f: S, a: I, rk: G }) => {
682
+ const L = [];
683
+ for (let _ = 0; _ < S.length; _++) {
684
+ const N = P[2 * _], D = P[2 * _ + 1], q = Math.hypot(N, D) || 1, U = G * (1 + S[_] - k - C * (N / q) - z * (D / q));
685
+ L.push(o + N * U, o - D * U);
575
686
  }
576
- return { pts: C, a: R, white: 0, w: A, closed: !0 };
577
- }), b = 2.3 + 0.25 * Math.sin(n * 0.21) + 2 * e.spin, E = {
687
+ return { pts: L, a: I, white: 0, w: y, closed: !0 };
688
+ }), w = 2.3 + 0.25 * Math.sin(s * 0.21) + 2 * e.spin, T = t.colorDrift ?? 1, F = {
578
689
  cx: o,
579
690
  cy: o,
580
- r: f,
581
- stops: Zs,
691
+ r: u,
692
+ stops: ce,
582
693
  // warm at the top, cool below, swaying rather than turning — the
583
694
  // spectrum flows with the voice but keeps its sense of up; processing
584
695
  // spins it all the way round
585
- angle: -Math.PI / 2 - 0.35 + 0.5 * Math.sin(n * 0.07) + 0.4 * Math.sin(a * 0.2) + e.spin,
696
+ angle: -Math.PI / 2 - 0.35 + (t.colorTurn ?? 0) * Math.PI / 180 + T * (0.5 * Math.sin(s * 0.07) + 0.4 * Math.sin(a * 0.2)) + e.spin,
586
697
  // processing lights the ring up: brighter bloom and a bigger halo
587
- intensity: 0.62 + 0.55 * h + 0.5 * d,
588
- halo: (s.halo ?? 0.5) * (1 + 0.6 * d),
698
+ intensity: (0.62 + 0.55 * l + 0.5 * f) * (t.brightness ?? 0.78),
699
+ halo: (t.halo ?? 0.5) * (1 + 0.6 * f),
589
700
  spec: [
590
701
  {
591
- x: o + Math.cos(b) * f,
592
- y: o + Math.sin(b) * f,
593
- r: f * (0.5 + 0.25 * d),
594
- a: 0.5 + 0.35 * h + 0.4 * d
702
+ x: o + Math.cos(w) * u,
703
+ y: o + Math.sin(w) * u,
704
+ r: u * (0.5 + 0.25 * f) * (t.highlightSize ?? 1),
705
+ a: (0.5 + 0.35 * l + 0.4 * f) * (t.highlight ?? 1.4)
595
706
  }
596
707
  ],
597
- fringe: 0.016 + 0.012 * h,
598
- green: [s.greenFrom ?? 81, s.greenTo ?? 136]
708
+ fringe: (0.016 + 0.012 * l) * (t.fringe ?? 1),
709
+ green: [t.greenFrom ?? 81, t.greenTo ?? 136],
710
+ look: {
711
+ hue: t.hue,
712
+ chroma: t.chroma,
713
+ warmth: t.warmth,
714
+ contrast: t.contrast,
715
+ cycles: t.colorCycles,
716
+ glowSize: t.glowSize,
717
+ // a fainter, wider, softer bloom than the painter's own
718
+ bloom: t.bloom ?? 0.55,
719
+ bloomSize: t.bloomSize ?? 1.4,
720
+ soft: t.softness ?? 3.7,
721
+ core: t.core
722
+ }
599
723
  };
600
- return { ...Gt([], U), light: E };
601
- }, ts = -0.45, ns = 0.55, ss = 0.7, Qs = Math.hypot(ts, ns, ss), te = (t, n, e, s) => {
602
- const o = t / 2, c = e.level, [r, l, i] = e.bands, a = e.drive, d = e.processing, h = o * (s.radius ?? 0.72), f = h * (1 + (s.zoom ?? 0.3) * c) * (1 - 0.06 * d), m = s.rMul ?? 1, p = Math.max(4, Math.round(s.cells ?? 17)), M = 2 * h / p, v = M / 2 - Math.max(0.5, M * (s.gap ?? 0.24) / 2), A = Math.ceil(f * 1.25 / M), u = (s.turn ?? 0.12) * n + 0.1 * a + 0.5 * e.spin, g = Math.sin(u), x = Math.cos(u), B = Math.sin(0.35), S = Math.cos(0.35), L = s.shade ?? 0.7, w = s.texture ?? 0.35, k = s.fade ?? 1.3, _ = s.strength ?? 1.38, q = s.deform ?? 1.7, U = 0.012 + (0.09 * r + 0.03 * c) * q, b = (0.035 * l + 0.025 * i) * q, E = (C) => U * (0.55 * Math.sin(2 * C + 0.9 * a) + 0.45 * Math.sin(3 * C - 0.7 * a + 1.3)) + b * Math.sin(7 * C + 2.3 * a) * Math.sin(5 * C - 1.7 * a), y = 0.95 * Math.sin(n * 1.3), I = e.spectrum, R = I.length, G = [];
603
- for (let C = -A; C <= A; C++)
604
- for (let F = -A; F <= A; F++) {
605
- const T = o + F * M, P = o + C * M, N = (T - o) / f, O = -(P - o) / f, z = E(Math.atan2(O, N)), W = Math.hypot(N, O) / (1 + z);
606
- if (W >= 1) continue;
607
- const X = 1 / (1 + z), Q = N * X, Z = O * X, V = Math.sqrt(Math.max(0, 1 - Q * Q - Z * Z)), at = j((Q * ts + Z * ns + V * ss) / Qs), nt = 1 - L + L * at, H = Z * S + V * B, st = -Z * B + V * S, $ = Q * x - st * g, ht = Q * g + st * x, ut = 0.65 * zt($ * 2.2 + a * 0.15, H * 2.2, ht * 2.2 - a * 0.1) + 0.35 * zt($ * 4.6 - a * 0.2, H * 4.6 + 7.3, ht * 4.6), tt = 1 - w + w * wn(0.32, 0.68, ut), ft = R ? I[Math.min(R - 1, Math.floor(W * R))] : c, dt = 0.35 * c + 0.85 * ft, Rt = Math.exp(-((Z - y) ** 2) / 0.01) * d, Wt = 1 - 0.4 * k * (1 - V), ct = (0.35 + 0.75 * nt * tt + 0.3 * dt + 0.2 * Rt) * Wt * m, At = 0.22 + 0.62 * nt * tt + 0.22 * dt + 0.3 * Rt;
608
- G.push({
609
- x: T,
610
- y: P,
611
- z: V * f,
612
- r: v * Math.min(1, ct),
613
- white: j(1 - At * _),
614
- a: j((1 - 0.75 * k * (1 - Math.sqrt(V))) * _)
724
+ return { ...Vt([], B), light: F };
725
+ }, os = -0.45, as = 0.55, cs = 0.7, ie = Math.hypot(os, as, cs), he = (n, s, e, t) => {
726
+ const o = n / 2, r = e.processing, c = e.soft, h = e.softBands[1], i = o * (t.radius ?? 0.44) * (1 + (t.zoom ?? 0.08) * c) * (1 - 0.06 * r), a = t.deform ?? 1.85, f = Math.max(1, Math.round(t.rings ?? 2)), l = Math.max(48, Math.round(t.segs ?? 180)), u = Math.max(0.5, (t.lineW ?? 1.7) * Xt(n, 0.6)), p = (t.tilt ?? 0.22) + (t.open ?? 0.75) * c, d = $(t.restBend ?? 0.12), g = d + (1 - d) * $(c * a), M = (t.twist ?? 1.69) * g, y = (t.wobble ?? 0.31) * g, m = e.drive * (t.pace ?? 2.1), R = 1 / Math.max(0.02, t.persp ?? 0), b = 1 - Qt(0.1, 0.5, c), A = (t.idleSway ?? 0.18) * b, v = (t.idleDeform ?? 0.05) * b, E = (t.idleDrift ?? 0.03) * b, x = o + i * E * Math.sin(0.9 * s + 0.6), k = o + i * E * Math.sin(0.7 * s + 2.1), C = [];
727
+ for (let z = 0; z < f; z++) {
728
+ const B = z * 2.399, w = p * (1 + 0.25 * Math.sin(0.17 * m + B)) + A * Math.sin(1.3 * s + 1.3 * B), T = z * Mt / f + 0.23 * m * (z % 2 ? -1 : 1) + 0.4 * Math.sin(0.11 * m + B) + e.spin, F = Math.sin(w) * Math.cos(T), P = Math.sin(w) * Math.sin(T), S = Math.cos(w), I = Math.hypot(F, S) || 1, G = S / I, L = -F / I, _ = P * L, N = S * G - F * L, D = -P * G, q = 0.2 * M * Math.sin(0.29 * m + 1.3 + B), U = 0.37 * m + B, V = 0.07 * M * Math.sin(0.23 * m + 0.4 + B), K = -0.31 * m + 2.1 + B, J = 0.07 * y * Math.sin(0.33 * m + 0.4 + B), Y = 0.41 * m + B, H = 0.04 * y * Math.sin(0.27 * m + 1 + B), ht = -0.35 * m + 0.8 + B, rt = 0.04 * a * h, j = 0.5 * m + B, et = v * Math.sin(1.1 * s + 0.7 + B), X = 0.7 * s + B, gt = 0.6 * v * Math.sin(1.5 * s + 1.9 + B), lt = -0.5 * s + B, Q = 1 - (t.ringGap ?? 0.035) * z, ot = [], at = [], tt = [];
729
+ for (let Z = 0; Z < l; Z++) {
730
+ const W = Z / l * Mt, ut = Math.cos(W), yt = Math.sin(W), Pt = Q * (1 + J * Math.cos(2 * W + Y) + H * Math.cos(3 * W + ht) + rt * Math.cos(4 * W + j) + et * Math.cos(2 * W + X) + gt * Math.cos(3 * W + lt)), xt = Q * (q * Math.sin(2 * W + U) + V * Math.sin(3 * W + K));
731
+ ot.push((G * ut + _ * yt) * Pt + F * xt), at.push(N * yt * Pt + P * xt), tt.push((L * ut + D * yt) * Pt + S * xt);
732
+ }
733
+ const kt = [], it = [], vt = [];
734
+ for (let Z = 0; Z < l; Z++) {
735
+ const W = R / (R - tt[Z]);
736
+ kt.push(x + ot[Z] * i * W, k - at[Z] * i * W);
737
+ const ut = (Z + 1) % l, yt = (Z + l - 1) % l, Pt = ot[ut] - ot[yt], xt = at[ut] - at[yt], qt = tt[ut] - tt[yt], ft = Math.hypot(Pt, xt, qt) || 1, wt = (Pt * os + xt * as + qt * cs) / (ft * ie), Ut = Math.sqrt(Math.max(0, 1 - wt * wt)), $t = $((tt[Z] + 1) / 2);
738
+ it.push($(0.12 + 0.6 * Ut * (0.55 + 0.45 * $t) + 0.28 * $t + 0.08 * c)), vt.push($t * 2 - 1);
739
+ }
740
+ C.push({ pts: kt, a: it, z: vt, white: 0, w: u, closed: !0 });
741
+ }
742
+ return {
743
+ dots: [],
744
+ strokes: C,
745
+ tube: {
746
+ shine: t.shine ?? 1,
747
+ // one even grey all round: the highlight alone gives it its roundness
748
+ contrast: t.contrast ?? 0,
749
+ depth: t.depthWidth ?? 0,
750
+ // an emotion's colour as deep as it goes, a touch dark, fading most
751
+ // of the way into the grey on one side of the orb, the fade holding
752
+ // still; green a shade darker than the others
753
+ saturation: t.colorSaturation ?? 2,
754
+ gradient: t.colorGradient ?? 0.69,
755
+ gradientAngle: t.gradientAngle ?? 0,
756
+ gradientSpin: t.gradientSpin ?? 0,
757
+ colorBrightness: t.colorBrightness ?? 0.9,
758
+ positiveBrightness: t.positiveBrightness ?? 0.93,
759
+ negativeBrightness: t.negativeBrightness ?? 1,
760
+ calmBrightness: t.calmBrightness ?? 1
761
+ }
762
+ };
763
+ }, rs = -0.45, is = 0.55, hs = 0.7, le = Math.hypot(rs, is, hs), ue = (n, s, e, t) => {
764
+ const o = n / 2, r = e.level, [c, h, i] = e.bands, a = e.drive, f = e.processing, l = o * (t.radius ?? 0.72), u = l * (1 + (t.zoom ?? 0.3) * r) * (1 - 0.06 * f), p = t.rMul ?? 1, d = Math.max(4, Math.round(t.cells ?? 17)), g = 2 * l / d, M = g / 2 - Math.max(0.5, g * (t.gap ?? 0.24) / 2), y = Math.ceil(u * 1.25 / g), m = (t.turn ?? 0.12) * s + 0.1 * a + 0.5 * e.spin, R = Math.sin(m), b = Math.cos(m), A = Math.sin(0.35), v = Math.cos(0.35), E = t.shade ?? 0.7, x = t.texture ?? 0.35, k = t.fade ?? 1.3, C = t.strength ?? 1.38, z = t.deform ?? 1.7, B = 0.012 + (0.09 * c + 0.03 * r) * z, w = (0.035 * h + 0.025 * i) * z, T = (G) => B * (0.55 * Math.sin(2 * G + 0.9 * a) + 0.45 * Math.sin(3 * G - 0.7 * a + 1.3)) + w * Math.sin(7 * G + 2.3 * a) * Math.sin(5 * G - 1.7 * a), F = 0.95 * Math.sin(s * 1.3), P = e.spectrum, S = P.length, I = [];
765
+ for (let G = -y; G <= y; G++)
766
+ for (let L = -y; L <= y; L++) {
767
+ const _ = o + L * g, N = o + G * g, D = (_ - o) / u, q = -(N - o) / u, U = T(Math.atan2(q, D)), V = Math.hypot(D, q) / (1 + U);
768
+ if (V >= 1) continue;
769
+ const K = 1 / (1 + U), J = D * K, Y = q * K, H = Math.sqrt(Math.max(0, 1 - J * J - Y * Y)), ht = $((J * rs + Y * is + H * hs) / le), rt = 1 - E + E * ht, j = Y * v + H * A, et = -Y * A + H * v, X = J * b - et * R, gt = J * R + et * b, lt = 0.65 * Jt(X * 2.2 + a * 0.15, j * 2.2, gt * 2.2 - a * 0.1) + 0.35 * Jt(X * 4.6 - a * 0.2, j * 4.6 + 7.3, gt * 4.6), Q = 1 - x + x * Qt(0.32, 0.68, lt), ot = S ? P[Math.min(S - 1, Math.floor(V * S))] : r, at = 0.35 * r + 0.85 * ot, tt = Math.exp(-((Y - F) ** 2) / 0.01) * f, kt = 1 - 0.4 * k * (1 - H), it = (0.35 + 0.75 * rt * Q + 0.3 * at + 0.2 * tt) * kt * p, vt = 0.22 + 0.62 * rt * Q + 0.22 * at + 0.3 * tt;
770
+ I.push({
771
+ x: _,
772
+ y: N,
773
+ z: H * u,
774
+ r: M * Math.min(1, it),
775
+ white: $(1 - vt * C),
776
+ a: $((1 - 0.75 * k * (1 - Math.sqrt(H))) * C)
615
777
  });
616
778
  }
617
- return { ...Gt(G, [], s.rMin ?? 0.4), square: !0 };
618
- }, ne = (t, n, e, s) => {
619
- const o = t / 2, c = t / 2, r = 0.5 * e.level + 0.5 * e.soft, l = (1 + (s.swell ?? 0.49) * r) * (1 - 0.14 * e.processing), i = t / 2 * (s.radius ?? 0.56), a = s.persp ?? 0.25, d = nn(n * 0.12 + e.drive * 0.03, 0.3, 0, 0, 1), h = $t(t, s.rsPow ?? 0.9) * (s.rMul ?? 1), f = [], m = s.orbitN ?? 12, p = s.particles ?? 6;
620
- for (let M = 0; M < m; M++) {
621
- const v = Tt(M, 1.7), A = Tt(M, 5.2), u = Tt(M, 8.9), g = i * (0.45 + 0.52 * v), x = v * Mt, B = Math.acos(2 * A - 1), S = Math.sin(B) * Math.cos(x), L = Math.cos(B), w = Math.sin(B) * Math.sin(x);
622
- let k = -L, _ = S;
623
- const q = Math.max(1e-6, Math.sqrt(k * k + _ * _));
624
- k /= q, _ /= q;
625
- const U = -w * _, b = w * k, E = S * _ - L * k, y = (0.25 + 0.55 * u) * (u > 0.5 ? 1 : -1);
626
- for (let I = 0; I < p; I++) {
627
- const R = e.drive * y + I / p * Mt + A * 6, G = Math.cos(R), C = Math.sin(R), [F, T, P] = d((k * G + U * C) * g, (_ * G + b * C) * g, E * C * g), N = j((P / i + 1) / 2), O = l / (1 - a * P / i);
628
- f.push({
629
- x: o + F * O,
630
- y: c + T * O,
631
- z: P,
632
- r: ((s.partR ?? 0.47) + (s.partRDepth ?? 0.65) * N) * h * O,
633
- white: 0.32 - 0.24 * N
779
+ return { ...Vt(I, [], t.rMin ?? 0.4), square: !0 };
780
+ }, fe = (n, s, e, t) => {
781
+ const o = n / 2, r = n / 2, c = 0.5 * e.level + 0.5 * e.soft, h = (1 + (t.swell ?? 0.49) * c) * (1 - 0.14 * e.processing), i = n / 2 * (t.radius ?? 0.56), a = t.persp ?? 0.25, f = hn(s * 0.12 + e.drive * 0.03, 0.3, 0, 0, 1), l = Xt(n, t.rsPow ?? 0.9) * (t.rMul ?? 1), u = [], p = t.orbitN ?? 12, d = t.particles ?? 6;
782
+ for (let g = 0; g < p; g++) {
783
+ const M = Ft(g, 1.7), y = Ft(g, 5.2), m = Ft(g, 8.9), R = i * (0.45 + 0.52 * M), b = M * Mt, A = Math.acos(2 * y - 1), v = Math.sin(A) * Math.cos(b), E = Math.cos(A), x = Math.sin(A) * Math.sin(b);
784
+ let k = -E, C = v;
785
+ const z = Math.max(1e-6, Math.sqrt(k * k + C * C));
786
+ k /= z, C /= z;
787
+ const B = -x * C, w = x * k, T = v * C - E * k, F = (0.25 + 0.55 * m) * (m > 0.5 ? 1 : -1);
788
+ for (let P = 0; P < d; P++) {
789
+ const S = e.drive * F + P / d * Mt + y * 6, I = Math.cos(S), G = Math.sin(S), [L, _, N] = f((k * I + B * G) * R, (C * I + w * G) * R, T * G * R), D = $((N / i + 1) / 2), q = h / (1 - a * N / i);
790
+ u.push({
791
+ x: o + L * q,
792
+ y: r + _ * q,
793
+ z: N,
794
+ r: ((t.partR ?? 0.47) + (t.partRDepth ?? 0.65) * D) * l * q,
795
+ white: 0.32 - 0.24 * D
634
796
  });
635
797
  }
636
798
  }
637
- return Gt(f, [], s.rMin);
638
- }, se = (t, n, e, s) => {
639
- const o = t / 2, c = t / 2, r = e.soft, [l, i] = e.softBands, a = t / 2 * (s.radius ?? 0.66) * (1 + (s.zoom ?? 0.21) * e.level), d = e.drive, h = s.deform ?? 1, f = s.wave ?? 1, m = 0.015 + (0.1 * l + 0.05 * e.level) * h, p = 0.04 * i * h, M = En(m, p, d), v = 0.55 + 0.05 * Math.sin(n * 0.37), A = Math.cos(v), u = Math.sin(v);
640
- let g = 0;
641
- for (let T = 0; T < 48; T++) {
642
- const P = T / 48 * Mt;
643
- g += M(Math.cos(P), Math.sin(P) * A, Math.sin(P) * u);
799
+ return Vt(u, [], t.rMin);
800
+ }, de = (n, s, e, t) => {
801
+ const o = n / 2, r = n / 2, c = e.soft, [h, i] = e.softBands, a = n / 2 * (t.radius ?? 0.66) * (1 + (t.zoom ?? 0.21) * e.level), f = e.drive, l = t.deform ?? 1, u = t.wave ?? 1, p = 0.015 + (0.1 * h + 0.05 * e.level) * l, d = 0.04 * i * l, g = Pn(p, d, f), M = 0.55 + 0.05 * Math.sin(s * 0.37), y = Math.cos(M), m = Math.sin(M);
802
+ let R = 0;
803
+ for (let _ = 0; _ < 48; _++) {
804
+ const N = _ / 48 * Mt;
805
+ R += g(Math.cos(N), Math.sin(N) * y, Math.sin(N) * m);
644
806
  }
645
- g /= 48;
646
- const x = (T, P, N) => 1 + M(T, P, N) - g, S = nn(0, 0.3, o, c, 1), L = $t(t, s.rsPow ?? 0.6) * (s.rMul ?? 1), w = e.drive, k = [], _ = s.ghostN ?? 60;
647
- for (let T = 0; T < _; T++) {
648
- const P = Sn(T, _), N = a * x(P[0], P[1], P[2]), [O, z, W] = S(P[0] * N, P[1] * N, P[2] * N), X = (W / a + 1) / 2;
649
- k.push({ x: O, y: z, z: W, r: 0.65 * L, white: 0.78, a: 0.1 + 0.22 * X });
807
+ R /= 48;
808
+ const b = (_, N, D) => 1 + g(_, N, D) - R, v = hn(0, 0.3, o, r, 1), E = Xt(n, t.rsPow ?? 0.6) * (t.rMul ?? 1), x = e.drive, k = [], C = t.ghostN ?? 60;
809
+ for (let _ = 0; _ < C; _++) {
810
+ const N = _n(_, C), D = a * b(N[0], N[1], N[2]), [q, U, V] = v(N[0] * D, N[1] * D, N[2] * D), K = (V / a + 1) / 2;
811
+ k.push({ x: q, y: U, z: V, r: 0.65 * E, white: 0.78, a: 0.1 + 0.22 * K });
650
812
  }
651
- const q = -u, U = A, b = Math.max(1, Math.round(s.lanes ?? 10)), E = Math.max(8, Math.round(s.segs ?? 56)), y = e.processing, I = (s.laneGap ?? 0.062) * (1 + 0.25 * r) * (1 - 0.4 * y), R = w * 1.6, G = 0.15 * (0.55 + 0.9 * l * f) * (1 - 0.6 * y), C = 0.06 * (0.5 + 1.2 * i * f), F = 0.05 + 0.05 * r;
652
- for (let T = 0; T < b; T++) {
653
- const P = (T - (b - 1) / 2) * I, N = Math.abs(T - (b - 1) / 2) / Math.max(1, (b - 1) / 2);
654
- for (let O = 0; O < E; O++) {
655
- const z = O / E * Mt, W = G * Math.sin(z * 3 - w * 0.95 + T * 0.18) + C * Math.sin(z * 5 + w * 0.6) + F * Math.sin(z * 2 + n * 0.31 + Math.sin(n * 0.17) * 1.5), X = P + W, Q = Math.cos(z), Z = Math.sin(z), V = Q, at = Z * A + q * X, nt = Z * u + U * X, H = Math.sqrt(V * V + at * at + nt * nt), st = a * x(V / H, at / H, nt / H) / H, [$, ht, ut] = S(V * st, at * st, nt * st), tt = (ut / a + 1) / 2, ft = Math.max(0, W) * r, dt = Math.atan2(Math.sin(z - R), Math.cos(z - R)), Rt = Math.exp(-(dt * dt) / 0.18) * y;
813
+ const z = -m, B = y, w = Math.max(1, Math.round(t.lanes ?? 10)), T = Math.max(8, Math.round(t.segs ?? 56)), F = e.processing, P = (t.laneGap ?? 0.062) * (1 + 0.25 * c) * (1 - 0.4 * F), S = x * 1.6, I = 0.15 * (0.55 + 0.9 * h * u) * (1 - 0.6 * F), G = 0.06 * (0.5 + 1.2 * i * u), L = 0.05 + 0.05 * c;
814
+ for (let _ = 0; _ < w; _++) {
815
+ const N = (_ - (w - 1) / 2) * P, D = Math.abs(_ - (w - 1) / 2) / Math.max(1, (w - 1) / 2);
816
+ for (let q = 0; q < T; q++) {
817
+ const U = q / T * Mt, V = I * Math.sin(U * 3 - x * 0.95 + _ * 0.18) + G * Math.sin(U * 5 + x * 0.6) + L * Math.sin(U * 2 + s * 0.31 + Math.sin(s * 0.17) * 1.5), K = N + V, J = Math.cos(U), Y = Math.sin(U), H = J, ht = Y * y + z * K, rt = Y * m + B * K, j = Math.sqrt(H * H + ht * ht + rt * rt), et = a * b(H / j, ht / j, rt / j) / j, [X, gt, lt] = v(H * et, ht * et, rt * et), Q = (lt / a + 1) / 2, ot = Math.max(0, V) * c, at = Math.atan2(Math.sin(U - S), Math.cos(U - S)), tt = Math.exp(-(at * at) / 0.18) * F;
656
818
  k.push({
657
- x: $,
658
- y: ht,
659
- z: ut,
660
- r: ((s.rBase ?? 0.49) + (s.rDepth ?? 0.78) * tt) * (1 - 0.25 * N) * (1 + 1.2 * ft + 0.5 * Rt) * L,
661
- white: 0.52 - 0.44 * tt + 0.18 * N - 0.3 * Rt,
662
- a: 0.4 + 0.6 * tt
819
+ x: X,
820
+ y: gt,
821
+ z: lt,
822
+ r: ((t.rBase ?? 0.49) + (t.rDepth ?? 0.78) * Q) * (1 - 0.25 * D) * (1 + 1.2 * ot + 0.5 * tt) * E,
823
+ white: 0.52 - 0.44 * Q + 0.18 * D - 0.3 * tt,
824
+ a: 0.4 + 0.6 * Q
663
825
  });
664
826
  }
665
827
  }
666
- return Gt(k, [], s.rMin);
667
- }, ee = (t, n, e, s) => {
668
- const o = t / 2, c = e.level, [r, l] = e.softBands, i = e.bands[2], a = e.drive, d = o * (s.radius ?? 0.6) * (1 + (s.zoom ?? 0.06) * e.soft) * (1 - 0.08 * e.processing), h = nn((s.yaw ?? 0.42) + 0.08 * Math.sin(n * 0.23), s.tilt ?? 0.32, o, o, 1), f = Math.max(0.4, (s.lineW ?? 0.6) * $t(t, 0.5)), m = (S) => 0.06 + 0.94 * j((S / d + 1) / 2) ** 2, p = s.deform ?? 1, M = 0.02 + (0.14 * r + 0.06 * c) * p, v = 0.01 + (0.07 * l + 0.03 * i) * p, A = En(M, v, a), u = [], g = Math.max(24, Math.round(s.segs ?? 96)), x = Math.max(0, Math.round(s.limbs ?? 2));
669
- for (let S = 0; S < x; S++) {
670
- const L = 0.1 + 0.05 * Math.sin(n * 0.31 + S * 2.1), w = n * 0.17 * (S % 2 ? 1 : -1) + S * 2.4, k = Math.sin(L) * Math.cos(w), _ = Math.sin(L) * Math.sin(w), q = Math.cos(L), U = Math.hypot(k, q), b = q / U, E = -k / U, y = _ * E, I = q * b - k * E, R = -_ * b, G = [], C = [];
671
- for (let F = 0; F < g; F++) {
672
- const T = F / g * Mt, P = b * Math.cos(T) + y * Math.sin(T), N = I * Math.sin(T), O = E * Math.cos(T) + R * Math.sin(T), z = d * (1 + 6e-3 * S + A(P, N, O));
673
- G.push(o + P * z, o - N * z), C.push(0.55 + 0.35 * j((O / Math.sin(L) + 1) / 2));
828
+ return Vt(k, [], t.rMin);
829
+ }, pe = (n, s, e, t) => {
830
+ const o = n / 2, r = e.level, [c, h] = e.softBands, i = e.bands[2], a = e.drive, f = o * (t.radius ?? 0.6) * (1 + (t.zoom ?? 0.06) * e.soft) * (1 - 0.08 * e.processing), l = hn((t.yaw ?? 0.42) + 0.08 * Math.sin(s * 0.23), t.tilt ?? 0.32, o, o, 1), u = Math.max(0.4, (t.lineW ?? 0.6) * Xt(n, 0.5)), p = (v) => 0.06 + 0.94 * $((v / f + 1) / 2) ** 2, d = t.deform ?? 1, g = 0.02 + (0.14 * c + 0.06 * r) * d, M = 0.01 + (0.07 * h + 0.03 * i) * d, y = Pn(g, M, a), m = [], R = Math.max(24, Math.round(t.segs ?? 96)), b = Math.max(0, Math.round(t.limbs ?? 2));
831
+ for (let v = 0; v < b; v++) {
832
+ const E = 0.1 + 0.05 * Math.sin(s * 0.31 + v * 2.1), x = s * 0.17 * (v % 2 ? 1 : -1) + v * 2.4, k = Math.sin(E) * Math.cos(x), C = Math.sin(E) * Math.sin(x), z = Math.cos(E), B = Math.hypot(k, z), w = z / B, T = -k / B, F = C * T, P = z * w - k * T, S = -C * w, I = [], G = [];
833
+ for (let L = 0; L < R; L++) {
834
+ const _ = L / R * Mt, N = w * Math.cos(_) + F * Math.sin(_), D = P * Math.sin(_), q = T * Math.cos(_) + S * Math.sin(_), U = f * (1 + 6e-3 * v + y(N, D, q));
835
+ I.push(o + N * U, o - D * U), G.push(0.55 + 0.35 * $((q / Math.sin(E) + 1) / 2));
674
836
  }
675
- u.push({ pts: G, a: C, white: 0, w: f, closed: !0 });
837
+ m.push({ pts: I, a: G, white: 0, w: u, closed: !0 });
676
838
  }
677
- const B = Math.max(2, Math.round(s.circles ?? 8));
678
- for (let S = 0; S < B; S++) {
679
- const [L, w, k] = Sn(S, B), _ = a * 0.16 * (0.5 + Tt(S, 2.1)) * (S % 2 ? 1 : -1) + Tt(S, 6.6) * Mt, q = w * Math.cos(_) - k * Math.sin(_), U = w * Math.sin(_) + k * Math.cos(_), b = Math.max(1e-6, Math.hypot(U, L)), E = U / b, y = -L / b, I = q * y, R = U * E - L * y, G = -q * E, C = [], F = [];
680
- for (let T = 0; T < g; T++) {
681
- const P = T / g * Mt, N = E * Math.cos(P) + I * Math.sin(P), O = R * Math.sin(P), z = y * Math.cos(P) + G * Math.sin(P), W = d * (1 + A(N, O, z)), [X, Q, Z] = h(N * W, O * W, z * W);
682
- C.push(X, Q), F.push(m(Z));
839
+ const A = Math.max(2, Math.round(t.circles ?? 8));
840
+ for (let v = 0; v < A; v++) {
841
+ const [E, x, k] = _n(v, A), C = a * 0.16 * (0.5 + Ft(v, 2.1)) * (v % 2 ? 1 : -1) + Ft(v, 6.6) * Mt, z = x * Math.cos(C) - k * Math.sin(C), B = x * Math.sin(C) + k * Math.cos(C), w = Math.max(1e-6, Math.hypot(B, E)), T = B / w, F = -E / w, P = z * F, S = B * T - E * F, I = -z * T, G = [], L = [];
842
+ for (let _ = 0; _ < R; _++) {
843
+ const N = _ / R * Mt, D = T * Math.cos(N) + P * Math.sin(N), q = S * Math.sin(N), U = F * Math.cos(N) + I * Math.sin(N), V = f * (1 + y(D, q, U)), [K, J, Y] = l(D * V, q * V, U * V);
844
+ G.push(K, J), L.push(p(Y));
683
845
  }
684
- u.push({ pts: C, a: F, white: 0, w: f, closed: !0 });
846
+ m.push({ pts: G, a: L, white: 0, w: u, closed: !0 });
685
847
  }
686
- return Gt([], u, s.rMin);
687
- }, oe = (t, n, e, s) => {
688
- const o = t / 2, c = e.level, [r, l, i] = e.bands, a = e.drive, d = e.processing, h = o * (s.radius ?? 0.6) * (1 + (s.zoom ?? 0.1) * c) * (1 - 0.08 * d), f = 0.95 * Math.sin(n * 1.3), m = nn(n * 0.14, 0.32, o, o, 1), p = $t(t, s.rsPow ?? 0.6) * (s.rMul ?? 1), M = Math.max(40, Math.round(s.dotN ?? 900)), v = s.cloudFreq ?? 2.3, A = s.deform ?? 1, u = 0.018 + (0.12 * r + 0.04 * c) * A, g = (0.045 * l + 0.03 * i) * A, x = [], B = [];
689
- let S = 0;
690
- for (let w = 0; w < M; w++) {
691
- const k = Sn(w, M), [_, q, U] = k, b = 0.55 * Math.sin(2.1 * _ + 1.3 * q + 0.9 * a) + 0.45 * Math.sin(1.7 * U - 1.9 * q - 0.7 * a + 1.3), E = Math.sin(5.3 * _ - 4.1 * U + 2.3 * a) * Math.sin(4.7 * q + 3.1 * _ - 1.7 * a), y = u * b + g * E;
692
- x.push(k), B.push(y), S += y / M;
848
+ return Vt([], m, t.rMin);
849
+ }, me = (n, s, e, t) => {
850
+ const o = n / 2, r = e.level, [c, h, i] = e.bands, a = e.drive, f = e.processing, l = o * (t.radius ?? 0.6) * (1 + (t.zoom ?? 0.1) * r) * (1 - 0.08 * f), u = 0.95 * Math.sin(s * 1.3), p = hn(s * 0.14, 0.32, o, o, 1), d = Xt(n, t.rsPow ?? 0.6) * (t.rMul ?? 1), g = Math.max(40, Math.round(t.dotN ?? 900)), M = t.cloudFreq ?? 2.3, y = t.deform ?? 1, m = 0.018 + (0.12 * c + 0.04 * r) * y, R = (0.045 * h + 0.03 * i) * y, b = [], A = [];
851
+ let v = 0;
852
+ for (let x = 0; x < g; x++) {
853
+ const k = _n(x, g), [C, z, B] = k, w = 0.55 * Math.sin(2.1 * C + 1.3 * z + 0.9 * a) + 0.45 * Math.sin(1.7 * B - 1.9 * z - 0.7 * a + 1.3), T = Math.sin(5.3 * C - 4.1 * B + 2.3 * a) * Math.sin(4.7 * z + 3.1 * C - 1.7 * a), F = m * w + R * T;
854
+ b.push(k), A.push(F), v += F / g;
693
855
  }
694
- const L = [];
695
- for (let w = 0; w < M; w++) {
696
- const [k, _, q] = x[w], U = B[w] - S, b = h * (1 + U), [E, y, I] = m(k * b, _ * b, q * b), R = j((I / h + 1) / 2), G = 0.65 * zt(k * v + a * 0.21, _ * v - a * 0.15, q * v + a * 0.1) + 0.35 * zt(k * v * 2.1 - a * 0.29, _ * v * 2.1 + 7.3, q * v * 2.1 + a * 0.24), C = wn(0.34, 0.68, G), F = Math.exp(-((_ - f) ** 2) / 0.012) * d, T = Math.max(0, U) / 0.16;
697
- L.push({
698
- x: E,
699
- y,
700
- z: I,
701
- r: ((s.rBase ?? 0.27) + (s.rDepth ?? 0.84) * R) * (0.22 + 0.95 * C + 0.6 * F) * (1 + 0.5 * T) * p,
702
- white: 0.62 - 0.52 * R - 0.16 * C - 0.3 * F,
703
- a: 0.3 + 0.7 * R
856
+ const E = [];
857
+ for (let x = 0; x < g; x++) {
858
+ const [k, C, z] = b[x], B = A[x] - v, w = l * (1 + B), [T, F, P] = p(k * w, C * w, z * w), S = $((P / l + 1) / 2), I = 0.65 * Jt(k * M + a * 0.21, C * M - a * 0.15, z * M + a * 0.1) + 0.35 * Jt(k * M * 2.1 - a * 0.29, C * M * 2.1 + 7.3, z * M * 2.1 + a * 0.24), G = Qt(0.34, 0.68, I), L = Math.exp(-((C - u) ** 2) / 0.012) * f, _ = Math.max(0, B) / 0.16;
859
+ E.push({
860
+ x: T,
861
+ y: F,
862
+ z: P,
863
+ r: ((t.rBase ?? 0.27) + (t.rDepth ?? 0.84) * S) * (0.22 + 0.95 * G + 0.6 * L) * (1 + 0.5 * _) * d,
864
+ white: 0.62 - 0.52 * S - 0.16 * G - 0.3 * L,
865
+ a: 0.3 + 0.7 * S
704
866
  });
705
867
  }
706
- return Gt(L, [], s.rMin ?? 0.25);
707
- }, Ae = ["orbit", "sash", "signal", "swell", "pixel", "aura"], ae = {
708
- orbit: ne,
709
- sash: se,
710
- signal: ee,
711
- swell: oe,
712
- pixel: te,
713
- aura: Js
714
- }, ot = {
868
+ return Vt(E, [], t.rMin ?? 0.25);
869
+ }, De = ["orbit", "sash", "signal", "swell", "pixel", "aura-mono", "aura"], Me = {
870
+ orbit: fe,
871
+ sash: de,
872
+ signal: pe,
873
+ swell: me,
874
+ pixel: ue,
875
+ "aura-mono": he,
876
+ aura: re
877
+ }, mt = {
715
878
  orbit: {
716
879
  speed: 1.05,
717
880
  driveGain: 0.12,
@@ -745,6 +908,17 @@ const Zs = [
745
908
  opts: { cells: 17 },
746
909
  counts: { cells: 0.5 }
747
910
  },
911
+ "aura-mono": {
912
+ speed: 1.2,
913
+ // a voice spins it up a long way: waiting it drifts, speaking it turns
914
+ // and morphs quickly
915
+ driveGain: 4,
916
+ // leans like the aura, the near side drawn out, but drifts further and
917
+ // meets the edge with no lens
918
+ lean: { move: 0.55, pull: 0.36, deform: 0.28, squash: 0, bounce: 0.92, lens: 0, stretch: 0, split: 0, blur: 1.24 },
919
+ opts: { segs: 180 },
920
+ counts: { segs: 0.5 }
921
+ },
748
922
  aura: {
749
923
  speed: 1.6,
750
924
  driveGain: 2,
@@ -757,87 +931,87 @@ const Zs = [
757
931
  counts: { segs: 0.5 }
758
932
  }
759
933
  };
760
- function ce(t, n, e = 1, s = 1) {
761
- const o = t in ot ? t : "orbit", c = ot[o], r = Math.min(1.4, Math.max(0.2, n / 200)) * Math.max(0.1, e), l = { ...c.opts };
762
- for (const [i, a] of Object.entries(c.counts)) {
763
- const d = l[i];
764
- d != null && (l[i] = Math.max(1, Math.round(d * r ** a)));
934
+ function ge(n, s, e = 1, t = 1) {
935
+ const o = n in mt ? n : "orbit", r = mt[o], c = Math.min(1.4, Math.max(0.2, s / 200)) * Math.max(0.1, e), h = { ...r.opts };
936
+ for (const [i, a] of Object.entries(r.counts)) {
937
+ const f = h[i];
938
+ f != null && (h[i] = Math.max(1, Math.round(f * c ** a)));
765
939
  }
766
- return s !== 1 && (l.rMul = Math.max(0.1, s)), { frame: ae[o], speed: c.speed, driveGain: c.driveGain, gain: c.gain ?? 1, opts: l };
940
+ return t !== 1 && (h.rMul = Math.max(0.1, t)), { frame: Me[o], speed: r.speed, driveGain: r.driveGain, gain: r.gain ?? 1, opts: h };
767
941
  }
768
- function re(t) {
769
- let n = t;
770
- for (; n; ) {
771
- const e = n.getAttribute("data-theme");
942
+ function be(n) {
943
+ let s = n;
944
+ for (; s; ) {
945
+ const e = s.getAttribute("data-theme");
772
946
  if (e === "dark") return !0;
773
947
  if (e === "light") return !1;
774
- if (n.classList.contains("dark")) return !0;
775
- if (n.classList.contains("light")) return !1;
776
- n = n.parentElement;
948
+ if (s.classList.contains("dark")) return !0;
949
+ if (s.classList.contains("light")) return !1;
950
+ s = s.parentElement;
777
951
  }
778
952
  return null;
779
953
  }
780
- function ie() {
954
+ function ve() {
781
955
  return typeof matchMedia > "u" || matchMedia("(prefers-color-scheme: dark)").matches;
782
956
  }
783
- function le(t, n) {
784
- const [e, s] = Bt(!0);
785
- return It(() => {
786
- if (t === "dark") {
787
- s(!0);
957
+ function ye(n, s) {
958
+ const [e, t] = Wt(!0);
959
+ return Dt(() => {
960
+ if (n === "dark") {
961
+ t(!0);
788
962
  return;
789
963
  }
790
- if (t === "light") {
791
- s(!1);
964
+ if (n === "light") {
965
+ t(!1);
792
966
  return;
793
967
  }
794
968
  const o = () => {
795
- const i = re(n.current);
796
- s(i ?? ie());
969
+ const i = be(s.current);
970
+ t(i ?? ve());
797
971
  };
798
972
  o();
799
- const c = typeof matchMedia < "u" ? matchMedia("(prefers-color-scheme: dark)") : null, r = () => o();
800
- c == null || c.addEventListener("change", r);
801
- let l = null;
802
- return typeof MutationObserver < "u" && n.current && (l = new MutationObserver(o), l.observe(document.documentElement, {
973
+ const r = typeof matchMedia < "u" ? matchMedia("(prefers-color-scheme: dark)") : null, c = () => o();
974
+ r == null || r.addEventListener("change", c);
975
+ let h = null;
976
+ return typeof MutationObserver < "u" && s.current && (h = new MutationObserver(o), h.observe(document.documentElement, {
803
977
  attributes: !0,
804
978
  attributeFilter: ["class", "data-theme"],
805
979
  subtree: !0
806
980
  })), () => {
807
- c == null || c.removeEventListener("change", r), l == null || l.disconnect();
981
+ r == null || r.removeEventListener("change", c), h == null || h.disconnect();
808
982
  };
809
- }, [t, n]), e;
983
+ }, [n, s]), e;
810
984
  }
811
- function he() {
812
- const [t, n] = Bt(!1);
813
- return It(() => {
985
+ function xe() {
986
+ const [n, s] = Wt(!1);
987
+ return Dt(() => {
814
988
  if (typeof matchMedia > "u") return;
815
989
  const e = matchMedia("(prefers-reduced-motion: reduce)");
816
- n(e.matches);
817
- const s = (o) => n(o.matches);
818
- return e.addEventListener("change", s), () => e.removeEventListener("change", s);
819
- }, []), t;
990
+ s(e.matches);
991
+ const t = (o) => s(o.matches);
992
+ return e.addEventListener("change", t), () => e.removeEventListener("change", t);
993
+ }, []), n;
820
994
  }
821
- const vt = 16, ue = 2.1, fe = 0.3, de = 2.5, pe = 1.6, me = 5, $n = 2.2, Wn = [
995
+ const At = 16, we = 2.1, Se = 0.3, Ee = 2.5, Te = 1.6, Re = 5, Yn = 2.2, Hn = [
822
996
  [80, 300],
823
997
  [300, 2e3],
824
998
  [2e3, 6e3]
825
- ], Mn = 90, Me = 7e3, gn = Math.PI * 2, bn = 0.35, vn = 0.9;
826
- function es(t) {
827
- return t < 0 ? 0 : t > 1 ? 1 : t;
999
+ ], Sn = 90, Ae = 7e3, En = Math.PI * 2, Tn = 0.35, Rn = 0.9;
1000
+ function ls(n) {
1001
+ return n < 0 ? 0 : n > 1 ? 1 : n;
828
1002
  }
829
- function xn(t, n) {
830
- if (t <= n) return 0;
831
- const e = (t - n) / Math.max(1e-3, 1 - n);
832
- return es((1 - Math.exp(-3 * e)) / (1 - Math.exp(-3)));
1003
+ function An(n, s) {
1004
+ if (n <= s) return 0;
1005
+ const e = (n - s) / Math.max(1e-3, 1 - s);
1006
+ return ls((1 - Math.exp(-3 * e)) / (1 - Math.exp(-3)));
833
1007
  }
834
- function Ft(t, n, e, s, o) {
835
- const c = n > t ? s : o;
836
- return t + (n - t) * (1 - Math.exp(-e / Math.max(1e-3, c)));
1008
+ function Lt(n, s, e, t, o) {
1009
+ const r = s > n ? t : o;
1010
+ return n + (s - n) * (1 - Math.exp(-e / Math.max(1e-3, r)));
837
1011
  }
838
- class ge {
1012
+ class Pe {
839
1013
  constructor() {
840
- this.clock = 0, this.t = 0, this.drive = 0, this.level = 0, this.bands = [0, 0, 0], this.spectrum = new Float32Array(vt), this.floor = new Float32Array(vt + 3).fill(1), this.heard = 0, this.proc = 0, this.spin = 0, this.pan = 0, this.panVel = 0, this.raw = { level: 0, bands: [0, 0, 0], spectrum: new Float32Array(vt) }, this.timeBuf = null, this.freqBuf = null, this.out = {
1014
+ this.clock = 0, this.t = 0, this.drive = 0, this.level = 0, this.bands = [0, 0, 0], this.spectrum = new Float32Array(At), this.floor = new Float32Array(At + 3).fill(1), this.heard = 0, this.proc = 0, this.spin = 0, this.pan = 0, this.panVel = 0, this.raw = { level: 0, bands: [0, 0, 0], spectrum: new Float32Array(At) }, this.timeBuf = null, this.freqBuf = null, this.out = {
841
1015
  level: 0,
842
1016
  bands: [0, 0, 0],
843
1017
  soft: 0,
@@ -850,28 +1024,28 @@ class ge {
850
1024
  };
851
1025
  }
852
1026
  /** Read an analyser: RMS loudness, three voice bands and the spectrum. */
853
- readAnalyser(n, e, s) {
854
- (!this.timeBuf || this.timeBuf.length !== n.fftSize) && (this.timeBuf = new Float32Array(n.fftSize)), (!this.freqBuf || this.freqBuf.length !== n.frequencyBinCount) && (this.freqBuf = new Uint8Array(n.frequencyBinCount));
855
- const o = this.timeBuf, c = this.freqBuf;
856
- n.getFloatTimeDomainData(o);
857
- let r = 0;
858
- for (let h = 0; h < o.length; h++) r += o[h] * o[h];
859
- this.raw.level = Math.sqrt(r / o.length) * me * e, n.getByteFrequencyData(c);
860
- const l = n.context.sampleRate / n.fftSize, i = (h, f) => {
861
- const m = Math.max(0, Math.floor(h / l)), p = Math.max(m, Math.min(c.length - 1, Math.ceil(f / l)));
862
- let M = 0;
863
- for (let v = m; v <= p; v++) M += c[v];
864
- return M / (p - m + 1) / 255;
865
- }, a = (h, f) => {
866
- const m = this.floor[h];
867
- return this.floor[h] = f < m ? f : m + (f - m) * (1 - Math.exp(-s / 8)), Math.max(0, f - this.floor[h]) / Math.max(0.05, 1 - this.floor[h]);
1027
+ readAnalyser(s, e, t) {
1028
+ (!this.timeBuf || this.timeBuf.length !== s.fftSize) && (this.timeBuf = new Float32Array(s.fftSize)), (!this.freqBuf || this.freqBuf.length !== s.frequencyBinCount) && (this.freqBuf = new Uint8Array(s.frequencyBinCount));
1029
+ const o = this.timeBuf, r = this.freqBuf;
1030
+ s.getFloatTimeDomainData(o);
1031
+ let c = 0;
1032
+ for (let l = 0; l < o.length; l++) c += o[l] * o[l];
1033
+ this.raw.level = Math.sqrt(c / o.length) * Re * e, s.getByteFrequencyData(r);
1034
+ const h = s.context.sampleRate / s.fftSize, i = (l, u) => {
1035
+ const p = Math.max(0, Math.floor(l / h)), d = Math.max(p, Math.min(r.length - 1, Math.ceil(u / h)));
1036
+ let g = 0;
1037
+ for (let M = p; M <= d; M++) g += r[M];
1038
+ return g / (d - p + 1) / 255;
1039
+ }, a = (l, u) => {
1040
+ const p = this.floor[l];
1041
+ return this.floor[l] = u < p ? u : p + (u - p) * (1 - Math.exp(-t / 8)), Math.max(0, u - this.floor[l]) / Math.max(0.05, 1 - this.floor[l]);
868
1042
  };
869
- for (let h = 0; h < 3; h++)
870
- this.raw.bands[h] = a(h, i(Wn[h][0], Wn[h][1])) * $n * e;
871
- const d = Me / Mn;
872
- for (let h = 0; h < vt; h++) {
873
- const f = Mn * d ** (h / vt), m = Mn * d ** ((h + 1) / vt);
874
- this.raw.spectrum[h] = a(3 + h, i(f, m)) * $n * e;
1043
+ for (let l = 0; l < 3; l++)
1044
+ this.raw.bands[l] = a(l, i(Hn[l][0], Hn[l][1])) * Yn * e;
1045
+ const f = Ae / Sn;
1046
+ for (let l = 0; l < At; l++) {
1047
+ const u = Sn * f ** (l / At), p = Sn * f ** ((l + 1) / At);
1048
+ this.raw.spectrum[l] = a(3 + l, i(u, p)) * Yn * e;
875
1049
  }
876
1050
  }
877
1051
  /**
@@ -880,13 +1054,13 @@ class ge {
880
1054
  * scaled by the level, with two formant-like humps wandering the
881
1055
  * spectrum — so a level-driven orb still moves like a voice.
882
1056
  */
883
- readLevel(n, e) {
884
- const s = es(n) * e, o = this.clock;
885
- this.raw.level = s, this.raw.bands[0] = s, this.raw.bands[1] = s * (0.72 + 0.28 * Math.sin(o * 2.3)), this.raw.bands[2] = s * (0.6 + 0.4 * Math.sin(o * 3.7 + 2));
886
- const c = 0.28 + 0.1 * Math.sin(o * 2.3) + 0.05 * Math.sin(o * 5.1), r = 0.64 + 0.1 * Math.sin(o * 1.7 + 1);
887
- for (let l = 0; l < vt; l++) {
888
- const i = l / (vt - 1), a = Math.exp(-((i - c) ** 2) / 0.012) + 0.6 * Math.exp(-((i - r) ** 2) / 8e-3);
889
- this.raw.spectrum[l] = s * (0.25 + 0.75 * a) * (1 - 0.4 * i);
1057
+ readLevel(s, e) {
1058
+ const t = ls(s) * e, o = this.clock;
1059
+ this.raw.level = t, this.raw.bands[0] = t, this.raw.bands[1] = t * (0.72 + 0.28 * Math.sin(o * 2.3)), this.raw.bands[2] = t * (0.6 + 0.4 * Math.sin(o * 3.7 + 2));
1060
+ const r = 0.28 + 0.1 * Math.sin(o * 2.3) + 0.05 * Math.sin(o * 5.1), c = 0.64 + 0.1 * Math.sin(o * 1.7 + 1);
1061
+ for (let h = 0; h < At; h++) {
1062
+ const i = h / (At - 1), a = Math.exp(-((i - r) ** 2) / 0.012) + 0.6 * Math.exp(-((i - c) ** 2) / 8e-3);
1063
+ this.raw.spectrum[h] = t * (0.25 + 0.75 * a) * (1 - 0.4 * i);
890
1064
  }
891
1065
  }
892
1066
  /** Nothing to read: let every envelope settle. */
@@ -894,346 +1068,347 @@ class ge {
894
1068
  this.raw.level = 0, this.raw.bands.fill(0), this.raw.spectrum.fill(0);
895
1069
  }
896
1070
  /** Advance by `dt` real seconds. `still` (reduced motion) holds the clocks. */
897
- step(n, e, s) {
898
- const { threshold: o, attack: c, release: r, rate: l } = e, i = this.proc = Ft(this.proc, e.processing ? 1 : 0, n, 0.35, 0.5), a = e.calm + (1 - e.calm) * Math.min(1, Math.max(this.heard * 2.5, i));
899
- s || (this.clock += n, this.t += n * l * a * (1 + 0.5 * i));
900
- const d = xn(this.raw.level, o);
901
- this.level = Ft(this.level, d, n, c, r), this.heard = Ft(this.heard, this.level, n, bn, vn);
902
- for (let u = 0; u < 3; u++)
903
- this.bands[u] = Ft(this.bands[u], xn(this.raw.bands[u], o * 0.6), n, c, r * 1.15);
904
- for (let u = 0; u < vt; u++)
905
- this.spectrum[u] = Ft(this.spectrum[u], xn(this.raw.spectrum[u], o * 0.6), n, c, r);
906
- const h = this.clock, f = s ? 0.5 : 0.5 + 0.5 * Math.sin(gn * h / 6), m = e.idle * f * (1 - i), p = this.out;
907
- p.level = this.level + (1 - this.level) * m;
908
- for (let u = 0; u < 3; u++) p.bands[u] = this.bands[u] + (1 - this.bands[u]) * m * 0.6;
909
- p.soft = Ft(p.soft, p.level, n, bn, vn);
910
- for (let u = 0; u < 3; u++) p.softBands[u] = Ft(p.softBands[u], p.bands[u], n, bn, vn);
911
- if (s || (this.drive += n * l * (a + e.driveGain * this.level + 1.3 * i)), p.drive = this.drive, p.processing = i, !s) {
912
- const u = Math.ceil(this.spin / gn - 1e-6) * gn, g = Math.min(fe, (u - this.spin) * 0.6);
913
- this.spin += n * (ue * l * i + g * (1 - i));
1071
+ step(s, e, t) {
1072
+ const { threshold: o, attack: r, release: c, rate: h } = e, i = this.proc = Lt(this.proc, e.processing ? 1 : 0, s, 0.35, 0.5), a = e.calm + (1 - e.calm) * Math.min(1, Math.max(this.heard * 2.5, i));
1073
+ t || (this.clock += s, this.t += s * h * a * (1 + 0.5 * i));
1074
+ const f = An(this.raw.level, o);
1075
+ this.level = Lt(this.level, f, s, r, c), this.heard = Lt(this.heard, this.level, s, Tn, Rn);
1076
+ for (let m = 0; m < 3; m++)
1077
+ this.bands[m] = Lt(this.bands[m], An(this.raw.bands[m], o * 0.6), s, r, c * 1.15);
1078
+ for (let m = 0; m < At; m++)
1079
+ this.spectrum[m] = Lt(this.spectrum[m], An(this.raw.spectrum[m], o * 0.6), s, r, c);
1080
+ const l = this.clock, u = t ? 0.5 : 0.5 + 0.5 * Math.sin(En * l / 6), p = e.idle * u * (1 - i), d = this.out;
1081
+ d.level = this.level + (1 - this.level) * p;
1082
+ for (let m = 0; m < 3; m++) d.bands[m] = this.bands[m] + (1 - this.bands[m]) * p * 0.6;
1083
+ d.soft = Lt(d.soft, d.level, s, Tn, Rn);
1084
+ for (let m = 0; m < 3; m++) d.softBands[m] = Lt(d.softBands[m], d.bands[m], s, Tn, Rn);
1085
+ if (t || (this.drive += s * h * (a + e.driveGain * this.level + 1.3 * i)), d.drive = this.drive, d.processing = i, !t) {
1086
+ const m = Math.ceil(this.spin / En - 1e-6) * En, R = Math.min(Se, (m - this.spin) * 0.6);
1087
+ this.spin += s * (we * h * i + R * (1 - i));
914
1088
  }
915
- p.spin = this.spin;
916
- const M = Math.max(-1, Math.min(1, e.direction || 0)), v = this.heard > 0.06 && !e.processing ? M : 0, A = Math.abs(v) > Math.abs(this.pan) ? de : pe;
917
- return this.panVel += (A * A * (v - this.pan) - 2 * A * this.panVel) * n, this.pan += this.panVel * n, p.pan = this.pan, p;
1089
+ d.spin = this.spin;
1090
+ const g = Math.max(-1, Math.min(1, e.direction || 0)), M = this.heard > 0.06 && !e.processing ? g : 0, y = Math.abs(M) > Math.abs(this.pan) ? Ee : Te;
1091
+ return this.panVel += (y * y * (M - this.pan) - 2 * y * this.panVel) * s, this.pan += this.panVel * s, d.pan = this.pan, d;
918
1092
  }
919
1093
  }
920
- function be(t) {
921
- if (!t) return;
922
- const n = t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
923
- if (n) {
924
- let s = n[1];
925
- s.length === 3 && (s = s.replace(/./g, (c) => c + c));
926
- const o = parseInt(s, 16);
1094
+ function _e(n) {
1095
+ if (!n) return;
1096
+ const s = n.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
1097
+ if (s) {
1098
+ let t = s[1];
1099
+ t.length === 3 && (t = t.replace(/./g, (r) => r + r));
1100
+ const o = parseInt(t, 16);
927
1101
  return { r: o >> 16 & 255, g: o >> 8 & 255, b: o & 255 };
928
1102
  }
929
- const e = t.trim().match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
1103
+ const e = n.trim().match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
930
1104
  if (e) return { r: Number(e[1]), g: Number(e[2]), b: Number(e[3]) };
931
1105
  }
932
- const ve = {
1106
+ const Ce = {
933
1107
  idle: "Waiting",
934
1108
  listening: "Listening",
935
1109
  speaking: "Speaking",
936
1110
  processing: "Thinking"
937
- }, xe = 0.55, ye = 1e3 / 62;
938
- function we({
939
- type: t = "orbit",
940
- state: n = "listening",
1111
+ }, Be = 0.55, Ie = 1e3 / 62;
1112
+ function Fe({
1113
+ type: n = "orbit",
1114
+ state: s = "listening",
941
1115
  size: e = 160,
942
- stream: s,
1116
+ stream: t,
943
1117
  analyser: o,
944
- level: c,
945
- sensitivity: r = 0.85,
946
- threshold: l = 0.04,
1118
+ level: r,
1119
+ sensitivity: c = 0.85,
1120
+ threshold: h = 0.04,
947
1121
  attack: i,
948
1122
  release: a = 0.32,
949
- idle: d = 0.1,
950
- calm: h = 0.4,
951
- voiceSpeed: f,
952
- emotion: m = null,
953
- emotionColors: p,
954
- saturation: M = 2,
955
- accent: v = null,
956
- gradientAngle: A = 99,
957
- gradientSpin: u = 12,
958
- neutral: g = 1,
959
- colorBrightness: x = 1.02,
960
- colorHue: B = 0,
961
- gradientStart: S = 0.1,
962
- gradientWidth: L = 0.6,
963
- direction: w,
1123
+ idle: f = 0.1,
1124
+ calm: l = 0.4,
1125
+ voiceSpeed: u,
1126
+ emotion: p = null,
1127
+ emotionColors: d,
1128
+ saturation: g = 2,
1129
+ accent: M = null,
1130
+ gradientAngle: y = 99,
1131
+ gradientSpin: m = 12,
1132
+ neutral: R = 1,
1133
+ colorBrightness: b = 1.02,
1134
+ colorHue: A = 0,
1135
+ gradientStart: v = 0.1,
1136
+ gradientWidth: E = 0.6,
1137
+ direction: x,
964
1138
  directionMove: k,
965
- directionPull: _,
966
- directionDeform: q,
967
- directionSquash: U,
968
- directionLens: b,
969
- directionStretch: E,
970
- directionSplit: y,
971
- directionBlur: I,
972
- directionBounce: R,
973
- directionMargin: G,
974
- directionBounds: C,
975
- hoverBend: F = !1,
976
- theme: T = "auto",
977
- speed: P = 1,
978
- paused: N = !1,
979
- color: O,
980
- dots: z = 1,
981
- dotSize: W,
982
- opts: X,
983
- frame: Q,
984
- onLevel: Z,
985
- style: V,
986
- "aria-label": at,
987
- ...nt
1139
+ directionPull: C,
1140
+ directionDeform: z,
1141
+ directionSquash: B,
1142
+ directionLens: w,
1143
+ directionStretch: T,
1144
+ directionSplit: F,
1145
+ directionBlur: P,
1146
+ directionBounce: S,
1147
+ directionMargin: I,
1148
+ directionBounds: G,
1149
+ hoverBend: L = !1,
1150
+ theme: _ = "auto",
1151
+ speed: N = 1,
1152
+ paused: D = !1,
1153
+ color: q,
1154
+ dots: U = 1,
1155
+ dotSize: V,
1156
+ opts: K,
1157
+ frame: J,
1158
+ onLevel: Y,
1159
+ style: H,
1160
+ "aria-label": ht,
1161
+ ...rt
988
1162
  }) {
989
- const H = St(null), st = le(T, H), $ = he(), ht = X ? JSON.stringify(X) : "", ut = !!(s || o || c != null || n === "processing"), tt = St(null);
990
- tt.current || (tt.current = new ge());
991
- const ft = St(null);
992
- ft.current || (ft.current = new vs());
993
- const dt = m ? (p == null ? void 0 : p[m]) ?? tn[m] : null, Rt = {
994
- saturation: Math.min(1, M),
995
- vivid: Math.max(0, Math.min(1, M - 1)),
996
- brightness: x,
997
- hue: B,
998
- start: S,
999
- width: L,
1000
- accent: v ? ms[v] : null,
1001
- angle: A,
1002
- spin: u,
1003
- neutral: g,
1163
+ const j = It(null), et = ye(_, j), X = xe(), gt = K ? JSON.stringify(K) : "", lt = !!(t || o || r != null || s === "processing"), Q = It(null);
1164
+ Q.current || (Q.current = new Pe());
1165
+ const ot = It(null);
1166
+ ot.current || (ot.current = new Ts());
1167
+ const at = p ? (d == null ? void 0 : d[p]) ?? Ot[p] : null, tt = {
1168
+ saturation: Math.min(1, g),
1169
+ vivid: Math.max(0, Math.min(1, g - 1)),
1170
+ brightness: b,
1171
+ hue: A,
1172
+ start: v,
1173
+ width: E,
1174
+ accent: M ? xs[M] : null,
1175
+ angle: y,
1176
+ spin: m,
1177
+ neutral: R,
1004
1178
  size: e
1005
- }, Wt = W ?? ot[t in ot ? t : "orbit"].dotSize ?? 1, ct = ot[t in ot ? t : "orbit"].lean ?? {}, At = G ?? ot[t in ot ? t : "orbit"].margin ?? 32, Xt = {
1006
- state: n,
1007
- level: c,
1179
+ }, kt = V ?? mt[n in mt ? n : "orbit"].dotSize ?? 1, it = mt[n in mt ? n : "orbit"].lean ?? {}, vt = I ?? mt[n in mt ? n : "orbit"].margin ?? 32, Z = {
1180
+ state: s,
1181
+ level: r,
1008
1182
  analyser: o,
1009
- sensitivity: r,
1010
- threshold: l,
1011
- attack: i ?? ot[t in ot ? t : "orbit"].attack ?? 0.06,
1183
+ sensitivity: c,
1184
+ threshold: h,
1185
+ attack: i ?? mt[n in mt ? n : "orbit"].attack ?? 0.06,
1012
1186
  release: a,
1013
- idle: d,
1014
- calm: h,
1015
- voiceSpeed: f ?? ot[t in ot ? t : "orbit"].voiceSpeed ?? 1,
1016
- onLevel: Z,
1017
- emotionTint: dt,
1018
- colors: Rt,
1019
- direction: w,
1020
- bounds: C,
1021
- bend: F === !0 ? xe : typeof F == "number" ? Math.max(0, Math.min(1, F)) : 0,
1187
+ idle: f,
1188
+ calm: l,
1189
+ voiceSpeed: u ?? mt[n in mt ? n : "orbit"].voiceSpeed ?? 1,
1190
+ onLevel: Y,
1191
+ emotionTint: at,
1192
+ colors: tt,
1193
+ direction: x,
1194
+ bounds: G,
1195
+ bend: L === !0 ? Be : typeof L == "number" ? Math.max(0, Math.min(1, L)) : 0,
1022
1196
  // each amount: the prop, else the type's own, else the shared default
1023
1197
  lean: {
1024
- move: k ?? ct.move ?? bt.move,
1025
- pull: _ ?? ct.pull ?? bt.pull,
1026
- deform: q ?? ct.deform ?? bt.deform,
1027
- squash: U ?? ct.squash ?? bt.squash,
1028
- lens: b ?? ct.lens ?? bt.lens,
1029
- stretch: E ?? ct.stretch ?? bt.stretch,
1030
- split: y ?? ct.split ?? bt.split,
1031
- blur: I ?? ct.blur ?? bt.blur,
1032
- bounce: R ?? ct.bounce ?? bt.bounce
1198
+ move: k ?? it.move ?? Rt.move,
1199
+ pull: C ?? it.pull ?? Rt.pull,
1200
+ deform: z ?? it.deform ?? Rt.deform,
1201
+ squash: B ?? it.squash ?? Rt.squash,
1202
+ lens: w ?? it.lens ?? Rt.lens,
1203
+ stretch: T ?? it.stretch ?? Rt.stretch,
1204
+ split: F ?? it.split ?? Rt.split,
1205
+ blur: P ?? it.blur ?? Rt.blur,
1206
+ bounce: S ?? it.bounce ?? Rt.bounce
1033
1207
  }
1034
- }, xt = St(Xt);
1035
- xt.current = Xt;
1036
- const Nt = w == null ? 0 : ws(Xt.lean, e), [Tn, os] = Bt([1 / 0, 1 / 0]), sn = Math.min(Nt, Tn[0]), en = Math.min(Nt, Tn[1]), rt = Nt ? sn + At : 0, _t = Nt ? en + At : 0, Vt = St({ x: 0, y: 0, over: !1 }), Rn = Xt.bend > 0 && !$;
1037
- It(() => {
1038
- const K = H.current;
1039
- if (!Rn || !K || typeof matchMedia != "function" || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
1040
- const yt = (it) => {
1041
- if (it.pointerType === "touch") return;
1042
- const Dt = K.getBoundingClientRect(), Ht = (e + rt + _t) / (Dt.width || 1);
1043
- Vt.current = { x: (it.clientX - Dt.left) * Ht - rt, y: (it.clientY - Dt.top) * Ht, over: !0 };
1044
- }, Pt = () => {
1045
- Vt.current.over = !1;
1208
+ }, W = It(Z);
1209
+ W.current = Z;
1210
+ const ut = x == null ? 0 : Ps(Z.lean, e), [yt, Pt] = Wt([1 / 0, 1 / 0]), xt = Math.min(ut, yt[0]), qt = Math.min(ut, yt[1]), ft = ut ? xt + vt : 0, wt = ut ? qt + vt : 0, Ut = It({ x: 0, y: 0, over: !1 }), $t = Z.bend > 0 && !X;
1211
+ Dt(() => {
1212
+ const nt = j.current;
1213
+ if (!$t || !nt || typeof matchMedia != "function" || !matchMedia("(hover: hover) and (pointer: fine)").matches) return;
1214
+ const _t = (bt) => {
1215
+ if (bt.pointerType === "touch") return;
1216
+ const Kt = nt.getBoundingClientRect(), tn = (e + ft + wt) / (Kt.width || 1);
1217
+ Ut.current = { x: (bt.clientX - Kt.left) * tn - ft, y: (bt.clientY - Kt.top) * tn, over: !0 };
1218
+ }, Nt = () => {
1219
+ Ut.current.over = !1;
1046
1220
  };
1047
- return window.addEventListener("pointermove", yt, { passive: !0 }), document.documentElement.addEventListener("pointerleave", Pt), () => {
1048
- window.removeEventListener("pointermove", yt), document.documentElement.removeEventListener("pointerleave", Pt), Vt.current.over = !1;
1221
+ return window.addEventListener("pointermove", _t, { passive: !0 }), document.documentElement.addEventListener("pointerleave", Nt), () => {
1222
+ window.removeEventListener("pointermove", _t), document.documentElement.removeEventListener("pointerleave", Nt), Ut.current.over = !1;
1049
1223
  };
1050
- }, [Rn, e, rt, _t]);
1051
- const on = St(null);
1052
- return It(() => {
1053
- if (!s) return;
1054
- const K = ps(s);
1055
- return on.current = (K == null ? void 0 : K.analyser) ?? null, () => {
1056
- on.current = null, K == null || K.release();
1224
+ }, [$t, e, ft, wt]);
1225
+ const ln = It(null);
1226
+ return Dt(() => {
1227
+ if (!t) return;
1228
+ const nt = ys(t);
1229
+ return ln.current = (nt == null ? void 0 : nt.analyser) ?? null, () => {
1230
+ ln.current = null, nt == null || nt.release();
1057
1231
  };
1058
- }, [s]), It(() => {
1059
- const K = H.current;
1060
- if (!K) return;
1061
- const yt = Math.min(2, typeof devicePixelRatio < "u" && devicePixelRatio || 1);
1062
- K.width = Math.round((e + rt + _t) * yt), K.height = Math.round(e * yt);
1063
- const Pt = K.getContext("2d");
1064
- if (!Pt) return;
1065
- const it = ce(t, e, z, Wt), Dt = X ? { ...it.opts, ...X } : it.opts, Ht = Q ?? it.frame, as = be(O), wt = tt.current, cs = ft.current, rs = new Es();
1066
- let An = 0, Lt = 0, an = e / 2, cn = e / 2;
1067
- const is = (J, Y, D) => {
1068
- var In;
1069
- Pt.setTransform(yt, 0, 0, yt, rt * yt, 0), Pt.clearRect(-rt, 0, e + rt + _t, e);
1070
- const qt = N || $ ? 0 : rs.step(An, D);
1071
- let lt = Ss(Ht(e, wt.t, J, Dt), J.pan, e, xt.current.lean, [sn, en], qt);
1072
- An = ((In = lt.contact) == null ? void 0 : In.press) ?? 0;
1073
- const gt = xt.current.bend;
1074
- if (gt > 0) {
1075
- const Ot = Vt.current, Nn = Kn(lt, e), fs = xt.current.state === "idle" || xt.current.state === "processing", ds = Ot.over && fs && !N && !$ ? ys(Math.hypot(Ot.x - e / 2, Ot.y - e / 2) - Nn, Nn) : 0;
1076
- Lt += (ds - Lt) * (1 - Math.exp(-D / 0.14));
1077
- const Bn = Lt < 0.01 ? 1 : 1 - Math.exp(-D / 0.05);
1078
- an += (Ot.x - an) * Bn, cn += (Ot.y - cn) * Bn, Lt > 2e-3 && (lt = xs(lt, e, { x: an, y: cn, amount: Lt * gt }));
1232
+ }, [t]), Dt(() => {
1233
+ const nt = j.current;
1234
+ if (!nt) return;
1235
+ const _t = Math.min(2, typeof devicePixelRatio < "u" && devicePixelRatio || 1);
1236
+ nt.width = Math.round((e + ft + wt) * _t), nt.height = Math.round(e * _t);
1237
+ const Nt = nt.getContext("2d");
1238
+ if (!Nt) return;
1239
+ const bt = ge(n, e, U, kt), Kt = K ? { ...bt.opts, ...K } : bt.opts, tn = J ?? bt.frame, us = _e(q), Ct = Q.current, fs = ot.current, ds = new _s();
1240
+ let Bn = 0, Yt = 0, un = e / 2, fn = e / 2;
1241
+ const ps = (ct, st, O) => {
1242
+ var Gn;
1243
+ Nt.setTransform(_t, 0, 0, _t, ft * _t, 0), Nt.clearRect(-ft, 0, e + ft + wt, e);
1244
+ const Ht = D || X ? 0 : ds.step(Bn, O);
1245
+ let dt = Cs(tn(e, Ct.t, ct, Kt), ct.pan, e, W.current.lean, [xt, qt], Ht);
1246
+ Bn = ((Gn = dt.contact) == null ? void 0 : Gn.press) ?? 0;
1247
+ const Tt = W.current.bend;
1248
+ if (Tt > 0) {
1249
+ const jt = Ut.current, Ln = Qn(dt, e), bs = W.current.state === "idle" || W.current.state === "processing", vs = jt.over && bs && !D && !X ? As(Math.hypot(jt.x - e / 2, jt.y - e / 2) - Ln, Ln) : 0;
1250
+ Yt += (vs - Yt) * (1 - Math.exp(-O / 0.14));
1251
+ const Dn = Yt < 0.01 ? 1 : 1 - Math.exp(-O / 0.05);
1252
+ un += (jt.x - un) * Dn, fn += (jt.y - fn) * Dn, Yt > 2e-3 && (dt = Rs(dt, e, { x: un, y: fn, amount: Yt * Tt }));
1079
1253
  }
1080
- const pt = xt.current.colors, mt = Y.amount, et = pt.accent, hs = et ? { r: et.r + (Y.r - et.r) * mt, g: et.g + (Y.g - et.g) * mt, b: et.b + (Y.b - et.b) * mt } : { r: Y.r, g: Y.g, b: Y.b }, us = {
1081
- ...pt,
1082
- accent: hs,
1083
- saturation: pt.saturation * (et ? 1 : mt),
1084
- angle: pt.angle + pt.spin * wt.clock
1254
+ const St = W.current.colors, Et = st.amount, pt = St.accent, Ms = pt ? { r: pt.r + (st.r - pt.r) * Et, g: pt.g + (st.g - pt.g) * Et, b: pt.b + (st.b - pt.b) * Et } : { r: st.r, g: st.g, b: st.b }, gs = {
1255
+ ...St,
1256
+ accent: Ms,
1257
+ saturation: St.saturation * (pt ? 1 : Et),
1258
+ angle: St.angle + St.spin * Ct.clock
1085
1259
  };
1086
- js(Pt, lt, st, as, lt.light ? Y : void 0, us);
1260
+ ae(Nt, dt, et, us, dt.light || dt.tube ? st : void 0, gs);
1087
1261
  };
1088
- let _n = -1 / 0;
1089
- const ls = (J) => {
1090
- var pt, mt;
1091
- if (!Nt || J - _n < 500) return;
1092
- _n = J;
1093
- const Y = K.getBoundingClientRect().left + rt, D = (mt = (pt = xt.current.bounds) == null ? void 0 : pt.current) == null ? void 0 : mt.getBoundingClientRect(), qt = D ? D.left : 0, lt = D ? D.right : document.documentElement.clientWidth, gt = [
1094
- Math.max(0, Math.floor(Y - qt - At)),
1095
- Math.max(0, Math.floor(lt - Y - e - At))
1262
+ let In = -1 / 0;
1263
+ const ms = (ct) => {
1264
+ var St, Et;
1265
+ if (!ut || ct - In < 500) return;
1266
+ In = ct;
1267
+ const st = nt.getBoundingClientRect().left + ft, O = (Et = (St = W.current.bounds) == null ? void 0 : St.current) == null ? void 0 : Et.getBoundingClientRect(), Ht = O ? O.left : 0, dt = O ? O.right : document.documentElement.clientWidth, Tt = [
1268
+ Math.max(0, Math.floor(st - Ht - vt)),
1269
+ Math.max(0, Math.floor(dt - st - e - vt))
1096
1270
  ];
1097
- os((et) => Math.abs(et[0] - gt[0]) > 1 || Math.abs(et[1] - gt[1]) > 1 ? gt : et);
1271
+ Pt((pt) => Math.abs(pt[0] - Tt[0]) > 1 || Math.abs(pt[1] - Tt[1]) > 1 ? Tt : pt);
1098
1272
  };
1099
- let Kt = 0;
1100
- const Pn = (J) => {
1101
- var mt;
1102
- ls(J);
1103
- const Y = Kt ? Math.min(0.05, (J - Kt) / 1e3) : 1 / 60;
1104
- Kt = J;
1105
- const D = xt.current, qt = D.state === "listening" || D.state === "speaking", lt = on.current ?? D.analyser ?? null;
1106
- qt ? lt ? wt.readAnalyser(lt, D.sensitivity * it.gain, Y) : D.level != null ? wt.readLevel(typeof D.level == "function" ? D.level() : D.level, D.sensitivity * it.gain) : wt.readSilence() : wt.readSilence();
1107
- const gt = wt.step(
1108
- Y,
1273
+ let nn = 0;
1274
+ const Fn = (ct) => {
1275
+ var Et;
1276
+ ms(ct);
1277
+ const st = nn ? Math.min(0.05, (ct - nn) / 1e3) : 1 / 60;
1278
+ nn = ct;
1279
+ const O = W.current, Ht = O.state === "listening" || O.state === "speaking", dt = ln.current ?? O.analyser ?? null;
1280
+ Ht ? dt ? Ct.readAnalyser(dt, O.sensitivity * bt.gain, st) : O.level != null ? Ct.readLevel(typeof O.level == "function" ? O.level() : O.level, O.sensitivity * bt.gain) : Ct.readSilence() : Ct.readSilence();
1281
+ const Tt = Ct.step(
1282
+ st,
1109
1283
  {
1110
- sensitivity: D.sensitivity,
1111
- threshold: D.threshold,
1112
- attack: D.attack,
1113
- release: D.release,
1114
- idle: D.idle,
1115
- driveGain: it.driveGain * D.voiceSpeed,
1116
- calm: D.calm,
1117
- rate: it.speed * P,
1118
- processing: D.state === "processing",
1119
- direction: typeof D.direction == "function" ? D.direction() : D.direction ?? 0
1284
+ sensitivity: O.sensitivity,
1285
+ threshold: O.threshold,
1286
+ attack: O.attack,
1287
+ release: O.release,
1288
+ idle: O.idle,
1289
+ driveGain: bt.driveGain * O.voiceSpeed,
1290
+ calm: O.calm,
1291
+ rate: bt.speed * N,
1292
+ processing: O.state === "processing",
1293
+ direction: typeof O.direction == "function" ? O.direction() : O.direction ?? 0
1120
1294
  },
1121
- $
1295
+ X
1122
1296
  );
1123
- (mt = D.onLevel) == null || mt.call(D, gt.level);
1124
- const pt = cs.step(Y, D.emotionTint, wt.clock, e, N || $);
1125
- is(gt, pt, Y);
1297
+ (Et = O.onLevel) == null || Et.call(O, Tt.level);
1298
+ const St = fs.step(st, O.emotionTint, Ct.clock, e, D || X);
1299
+ ps(Tt, St, st);
1126
1300
  };
1127
- if (Pn(performance.now()), N || $ && !ut) return;
1128
- let rn = 0, Yt = !1, kn = 0;
1129
- const Cn = (J) => {
1130
- Yt && (rn = requestAnimationFrame(Cn), !(J - kn < ye) && (kn = J, Pn(J)));
1131
- }, ln = () => {
1132
- Yt || (Yt = !0, Kt = 0, rn = requestAnimationFrame(Cn));
1133
- }, hn = () => {
1134
- Yt = !1, cancelAnimationFrame(rn);
1301
+ if (Fn(performance.now()), D || X && !lt) return;
1302
+ let dn = 0, sn = !1, kn = 0;
1303
+ const Nn = (ct) => {
1304
+ sn && (dn = requestAnimationFrame(Nn), !(ct - kn < Ie) && (kn = ct, Fn(ct)));
1305
+ }, pn = () => {
1306
+ sn || (sn = !0, nn = 0, dn = requestAnimationFrame(Nn));
1307
+ }, mn = () => {
1308
+ sn = !1, cancelAnimationFrame(dn);
1135
1309
  };
1136
- let un = !0;
1137
- const kt = typeof IntersectionObserver < "u" ? new IntersectionObserver(([J]) => {
1138
- un = J.isIntersecting, un && document.visibilityState !== "hidden" ? ln() : hn();
1310
+ let Mn = !0;
1311
+ const zt = typeof IntersectionObserver < "u" ? new IntersectionObserver(([ct]) => {
1312
+ Mn = ct.isIntersecting, Mn && document.visibilityState !== "hidden" ? pn() : mn();
1139
1313
  }) : null;
1140
- kt == null || kt.observe(K);
1141
- const Fn = () => {
1142
- document.visibilityState === "hidden" ? hn() : un && ln();
1314
+ zt == null || zt.observe(nt);
1315
+ const zn = () => {
1316
+ document.visibilityState === "hidden" ? mn() : Mn && pn();
1143
1317
  };
1144
- return document.addEventListener("visibilitychange", Fn), kt || ln(), () => {
1145
- hn(), kt == null || kt.disconnect(), document.removeEventListener("visibilitychange", Fn);
1318
+ return document.addEventListener("visibilitychange", zn), zt || pn(), () => {
1319
+ mn(), zt == null || zt.disconnect(), document.removeEventListener("visibilitychange", zn);
1146
1320
  };
1147
1321
  }, [
1148
- t,
1322
+ n,
1149
1323
  e,
1150
- Nt,
1151
- sn,
1152
- en,
1153
- rt,
1154
- _t,
1155
- At,
1156
- st,
1157
- P,
1158
- N,
1159
- $,
1160
1324
  ut,
1161
- O,
1162
- z,
1163
- Wt,
1164
- ht,
1165
- Q,
1166
- N || $ ? m : null,
1167
- N || $ ? `${M}|${v}|${A}|${u}|${g}|${x}|${B}|${S}|${L}` : null
1168
- ]), /* @__PURE__ */ Xn(
1325
+ xt,
1326
+ qt,
1327
+ ft,
1328
+ wt,
1329
+ vt,
1330
+ et,
1331
+ N,
1332
+ D,
1333
+ X,
1334
+ lt,
1335
+ q,
1336
+ U,
1337
+ kt,
1338
+ gt,
1339
+ J,
1340
+ D || X ? p : null,
1341
+ D || X ? `${g}|${M}|${y}|${m}|${R}|${b}|${A}|${v}|${E}` : null
1342
+ ]), /* @__PURE__ */ jn(
1169
1343
  "canvas",
1170
1344
  {
1171
- ref: H,
1345
+ ref: j,
1172
1346
  role: "img",
1173
- "aria-label": at ?? ve[n],
1174
- style: { width: e + rt + _t, height: e, display: "block", marginLeft: -rt, marginRight: -_t, ...V },
1175
- ...nt
1347
+ "aria-label": ht ?? Ce[s],
1348
+ style: { width: e + ft + wt, height: e, display: "block", marginLeft: -ft, marginRight: -wt, ...H },
1349
+ ...rt
1176
1350
  }
1177
1351
  );
1178
1352
  }
1179
- const Ee = {
1353
+ const ke = {
1180
1354
  echoCancellation: !1,
1181
1355
  noiseSuppression: !1,
1182
1356
  autoGainControl: !1
1183
1357
  };
1184
- function Qt() {
1358
+ function cn() {
1185
1359
  return typeof navigator < "u" && typeof navigator.mediaDevices < "u" && typeof navigator.mediaDevices.getUserMedia == "function";
1186
1360
  }
1187
- function _e(t = {}) {
1188
- const { constraints: n, autoStart: e = !1 } = t, [s, o] = Bt(null), [c, r] = Bt(() => Qt() ? "idle" : "unsupported"), [l, i] = Bt(null), a = St(null), d = St(n);
1189
- d.current = n;
1190
- const h = Gn(() => {
1191
- const m = a.current;
1192
- a.current = null, m && m.getTracks().forEach((p) => p.stop()), o(null), r(Qt() ? "idle" : "unsupported");
1193
- }, []), f = Gn(async () => {
1194
- if (!Qt())
1195
- return r("unsupported"), null;
1361
+ function Oe(n = {}) {
1362
+ const { constraints: s, autoStart: e = !1 } = n, [t, o] = Wt(null), [r, c] = Wt(() => cn() ? "idle" : "unsupported"), [h, i] = Wt(null), a = It(null), f = It(s);
1363
+ f.current = s;
1364
+ const l = On(() => {
1365
+ const p = a.current;
1366
+ a.current = null, p && p.getTracks().forEach((d) => d.stop()), o(null), c(cn() ? "idle" : "unsupported");
1367
+ }, []), u = On(async () => {
1368
+ if (!cn())
1369
+ return c("unsupported"), null;
1196
1370
  if (a.current) return a.current;
1197
- Hn(), r("requesting"), i(null);
1371
+ Jn(), c("requesting"), i(null);
1198
1372
  try {
1199
- const m = await navigator.mediaDevices.getUserMedia({
1200
- audio: { ...Ee, ...d.current ?? {} }
1373
+ const p = await navigator.mediaDevices.getUserMedia({
1374
+ audio: { ...ke, ...f.current ?? {} }
1201
1375
  });
1202
- a.current = m, o(m), r("live");
1203
- const p = () => {
1204
- a.current === m && (a.current = null, o(null), r("idle"));
1376
+ a.current = p, o(p), c("live");
1377
+ const d = () => {
1378
+ a.current === p && (a.current = null, o(null), c("idle"));
1205
1379
  };
1206
- return m.getAudioTracks().forEach((M) => M.addEventListener("ended", p)), m;
1207
- } catch (m) {
1208
- const p = m instanceof Error ? m : new Error(String(m));
1209
- return i(p), r(p.name === "NotAllowedError" || p.name === "SecurityError" ? "denied" : "error"), null;
1380
+ return p.getAudioTracks().forEach((g) => g.addEventListener("ended", d)), p;
1381
+ } catch (p) {
1382
+ const d = p instanceof Error ? p : new Error(String(p));
1383
+ return i(d), c(d.name === "NotAllowedError" || d.name === "SecurityError" ? "denied" : "error"), null;
1210
1384
  }
1211
1385
  }, []);
1212
- return It(() => {
1213
- e && f();
1214
- }, [e]), It(
1386
+ return Dt(() => {
1387
+ e && u();
1388
+ }, [e]), Dt(
1215
1389
  () => () => {
1216
- const m = a.current;
1217
- a.current = null, m && m.getTracks().forEach((p) => p.stop());
1390
+ const p = a.current;
1391
+ a.current = null, p && p.getTracks().forEach((d) => d.stop());
1218
1392
  },
1219
1393
  []
1220
- ), { stream: s, state: c, error: l, supported: Qt(), start: f, stop: h };
1394
+ ), { stream: t, state: r, error: h, supported: cn(), start: u, stop: l };
1221
1395
  }
1222
- function Pe(t) {
1223
- return /* @__PURE__ */ Xn(we, { ...t, type: "aura" });
1396
+ const Ne = { ring: "aura", mono: "aura-mono" };
1397
+ function qe({ type: n = "ring", ...s }) {
1398
+ return /* @__PURE__ */ jn(Fe, { ...s, type: Ne[n] });
1224
1399
  }
1225
1400
  export {
1226
- ms as ACCENT_COLORS,
1227
- tn as EMOTION_COLORS,
1228
- ot as PRESETS,
1229
- vt as SPECTRUM_N,
1230
- Ae as VOICE_ORB_TYPES,
1231
- ge as VoiceFollower,
1232
- we as VoiceOrb,
1233
- Pe as VoiceRing,
1234
- ps as acquireAnalyser,
1235
- Hn as getAudioContext,
1236
- Re as isAudioSupported,
1237
- ce as resolvePreset,
1238
- _e as useMicrophone
1401
+ xs as ACCENT_COLORS,
1402
+ Ot as EMOTION_COLORS,
1403
+ mt as PRESETS,
1404
+ At as SPECTRUM_N,
1405
+ De as VOICE_ORB_TYPES,
1406
+ Pe as VoiceFollower,
1407
+ Fe as VoiceOrb,
1408
+ qe as VoiceRing,
1409
+ ys as acquireAnalyser,
1410
+ Jn as getAudioContext,
1411
+ Le as isAudioSupported,
1412
+ ge as resolvePreset,
1413
+ Oe as useMicrophone
1239
1414
  };