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