robot-heads-solid 0.1.0 → 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/solid2.js ADDED
@@ -0,0 +1,1423 @@
1
+ import { getNextElement as e, ref as t, runHydrationEvents as n, spread as r, template as i } from "@solidjs/web";
2
+ import { createSignal as a, createTrackedEffect as o, createUniqueId as s, omit as c, onSettled as l } from "solid-js";
3
+ var u = [
4
+ "idle",
5
+ "thinking",
6
+ "searching",
7
+ "listening",
8
+ "speaking",
9
+ "working",
10
+ "happy",
11
+ "error",
12
+ "sleeping"
13
+ ], d = [
14
+ "rectangle",
15
+ "square",
16
+ "circle",
17
+ "hexagon"
18
+ ], f = {
19
+ bevel: .075,
20
+ margin: .045,
21
+ gasket: .022,
22
+ recess: .03,
23
+ earY: .03,
24
+ stem: .2,
25
+ ball: .052
26
+ }, p = {
27
+ plate: f.bevel,
28
+ hole: f.bevel + f.margin,
29
+ glass: f.bevel + f.margin + f.gasket
30
+ };
31
+ function m(e, t, n) {
32
+ let r = Math.cos(e), i = Math.sin(e), a = Math.cos(t), o = Math.sin(t), s = Math.cos(n), c = Math.sin(n), l = [
33
+ r,
34
+ i * o,
35
+ i * a,
36
+ 0,
37
+ a,
38
+ -o,
39
+ -i,
40
+ r * o,
41
+ r * a
42
+ ];
43
+ return [
44
+ s * l[0] - c * l[3],
45
+ s * l[1] - c * l[4],
46
+ s * l[2] - c * l[5],
47
+ c * l[0] + s * l[3],
48
+ c * l[1] + s * l[4],
49
+ c * l[2] + s * l[5],
50
+ l[6],
51
+ l[7],
52
+ l[8]
53
+ ];
54
+ }
55
+ function h(e, t, n, r) {
56
+ return [
57
+ e[0] * t + e[1] * n + e[2] * r,
58
+ e[3] * t + e[4] * n + e[5] * r,
59
+ e[6] * t + e[7] * n + e[8] * r
60
+ ];
61
+ }
62
+ var g = (e, t, n) => {
63
+ let r = Math.hypot(e, t, n) || 1;
64
+ return [
65
+ e / r,
66
+ t / r,
67
+ n / r
68
+ ];
69
+ }, _ = Math.PI * 2;
70
+ function v(e, t, n, r, i, a) {
71
+ let o = t.map(([e, t]) => ({
72
+ x: e,
73
+ y: t,
74
+ t: Math.atan2(t, e)
75
+ })).sort((e, t) => e.t - t.t), s = o.length, c = [];
76
+ for (let e = 0; e < s; e++) {
77
+ let t = o[e], n = o[(e + 1) % s];
78
+ c.push(Math.atan2(-(n.x - t.x), n.y - t.y));
79
+ }
80
+ let l = o.map((e, t) => {
81
+ if (s === 1) return {
82
+ x: e.x,
83
+ y: e.y,
84
+ a0: -Math.PI,
85
+ a1: Math.PI
86
+ };
87
+ let n = c[(t - 1 + s) % s], r = c[t];
88
+ for (; r < n;) r += _;
89
+ return {
90
+ x: e.x,
91
+ y: e.y,
92
+ a0: n,
93
+ a1: r
94
+ };
95
+ }), u = (e, t) => {
96
+ if (s === 1) return Math.hypot(e - o[0].x, t - o[0].y);
97
+ let n = Infinity, r = !0;
98
+ for (let i = 0; i < s; i++) {
99
+ let a = o[i], c = o[(i + 1) % s], l = c.x - a.x, u = c.y - a.y, d = e - a.x, f = t - a.y, p = Math.max(0, Math.min(1, (d * l + f * u) / (l * l + u * u)));
100
+ n = Math.min(n, Math.hypot(d - l * p, f - u * p)), l * f - u * d < 0 && (r = !1);
101
+ }
102
+ return r ? -n : n;
103
+ }, d = (e, t, r) => u(e, t) - (n - r), m = (e, t) => {
104
+ let r = Math.max(5e-4, n - t);
105
+ l.forEach((t, n) => {
106
+ n === 0 && e.moveTo(t.x + r * Math.cos(t.a0), t.y + r * Math.sin(t.a0)), e.arc(t.x, t.y, r, t.a0, t.a1);
107
+ }), e.closePath();
108
+ }, h = 0, g = 0;
109
+ for (let e of o) h = Math.max(h, Math.abs(e.x) + n), g = Math.max(g, Math.abs(e.y) + n);
110
+ let v = 0, y = h + .1;
111
+ for (let e = 0; e < 40; e++) {
112
+ let e = (v + y) / 2;
113
+ d(e, f.earY, 0) < 0 ? v = e : y = e;
114
+ }
115
+ let x = (e, t) => e.map((e, r) => {
116
+ let i = e * Math.PI / 180, a = l.find((e) => [
117
+ i,
118
+ i + _,
119
+ i - _
120
+ ].some((t) => t >= e.a0 - 1e-6 && t <= e.a1 + 1e-6)) ?? l[0];
121
+ return [
122
+ a.x + Math.cos(i) * (n - t),
123
+ a.y + Math.sin(i) * (n - t),
124
+ .5 + r * .9
125
+ ];
126
+ }), S = 2 * (h - p.glass), C = 2 * (g - p.glass), w = Math.min(b * S / 14, .65 * C / 10);
127
+ return {
128
+ name: e,
129
+ r: n,
130
+ depth: r,
131
+ corners: l,
132
+ hx: h,
133
+ hy: g,
134
+ pitch: w,
135
+ earX: v - .008,
136
+ screws: x(i, (p.hole - .018 + p.plate) / 2),
137
+ backScrews: x(a, p.plate + .07),
138
+ sd: d,
139
+ path: m
140
+ };
141
+ }
142
+ var y = (e) => [
143
+ 0,
144
+ 60,
145
+ 120,
146
+ 180,
147
+ 240,
148
+ 300
149
+ ].map((t) => [e * Math.cos(t * Math.PI / 180), e * Math.sin(t * Math.PI / 180)]), b = .6, x = [45, 135], S = [
150
+ -135,
151
+ -45,
152
+ 45,
153
+ 135
154
+ ], C = {
155
+ rectangle: () => v("rectangle", [
156
+ [-.29, -.17],
157
+ [.29, -.17],
158
+ [.29, .17],
159
+ [-.29, .17]
160
+ ], .21, .6, x, S),
161
+ square: () => v("square", [
162
+ [-.22, -.22],
163
+ [.22, -.22],
164
+ [.22, .22],
165
+ [-.22, .22]
166
+ ], .2, .6, x, S),
167
+ circle: () => v("circle", [[0, 0]], .46, .56, x, S),
168
+ hexagon: () => v("hexagon", y(.35), .16, .58, [60, 120], [
169
+ -120,
170
+ -60,
171
+ 60,
172
+ 120
173
+ ])
174
+ }, w = /* @__PURE__ */ new Map();
175
+ function T(e) {
176
+ let t = w.get(e);
177
+ return t || (t = (C[e] ?? C.rectangle)(), w.set(e, t)), t;
178
+ }
179
+ function E(e, t, n) {
180
+ let r = new Float32Array(t.length / 4 * 3);
181
+ for (let e = 0; e < t.length / 4; e++) {
182
+ let i = 0, a = 0, o = 0;
183
+ for (let r = 0; r < 4; r++) {
184
+ let s = t[e * 4 + r] * 3;
185
+ i += n[s], a += n[s + 1], o += n[s + 2];
186
+ }
187
+ r.set(g(i, a, o), e * 3);
188
+ }
189
+ return {
190
+ pos: new Float32Array(e),
191
+ quads: new Uint16Array(t),
192
+ normals: r
193
+ };
194
+ }
195
+ function D(e, t, n = !0) {
196
+ let r = [], i = n ? t : t - 1;
197
+ for (let n = 0; n < e - 1; n++) for (let e = 0; e < i; e++) {
198
+ let i = (e + 1) % t;
199
+ r.push(n * t + e, n * t + i, (n + 1) * t + i, (n + 1) * t + e);
200
+ }
201
+ return r;
202
+ }
203
+ function O(e, t = 10) {
204
+ let n = e.r, r = f.bevel, i = e.depth / 2, a = [];
205
+ for (let t of e.corners) {
206
+ let e = t.a1 - t.a0, n = Math.max(2, Math.ceil(e / (Math.PI / 2) * 14)), r = e >= _ - 1e-6 ? n - 1 : n;
207
+ for (let i = 0; i <= r; i++) {
208
+ let r = t.a0 + i / n * e;
209
+ a.push([
210
+ t.x,
211
+ t.y,
212
+ Math.cos(r),
213
+ Math.sin(r)
214
+ ]);
215
+ }
216
+ }
217
+ let o = [];
218
+ for (let e = t; e >= 0; e--) {
219
+ let n = e / t * (Math.PI / 2);
220
+ o.push([
221
+ -i + r - r * Math.sin(n),
222
+ r * (1 - Math.cos(n)),
223
+ -n
224
+ ]);
225
+ }
226
+ for (let e = 0; e <= t; e++) {
227
+ let n = e / t * (Math.PI / 2);
228
+ o.push([
229
+ i - r + r * Math.sin(n),
230
+ r * (1 - Math.cos(n)),
231
+ n
232
+ ]);
233
+ }
234
+ let s = [], c = [];
235
+ for (let [e, t, r] of o) for (let [i, o, l, u] of a) s.push(i + (n - t) * l, o + (n - t) * u, e), c.push(l * Math.cos(r), u * Math.cos(r), Math.sin(r));
236
+ return E(s, D(o.length, a.length), c);
237
+ }
238
+ function k(e, t, n, r = 36) {
239
+ let i = Math.abs(n[1]) > .9 ? [
240
+ 1,
241
+ 0,
242
+ 0
243
+ ] : [
244
+ 0,
245
+ 1,
246
+ 0
247
+ ], a = g(n[1] * i[2] - n[2] * i[1], n[2] * i[0] - n[0] * i[2], n[0] * i[1] - n[1] * i[0]), o = [], s = [];
248
+ for (let c = 0; c < e.length; c++) {
249
+ let [l, u] = e[c], d = e[Math.max(0, c - 1)], f = e[Math.min(e.length - 1, c + 1)], p = f[0] - d[0], m = f[1] - d[1], h = Math.hypot(p, m) || 1, g = m / h, v = -p / h;
250
+ for (let e = 0; e < r; e++) {
251
+ let c = e / r * _, d = Math.cos(c) * i[0] + Math.sin(c) * a[0], f = Math.cos(c) * i[1] + Math.sin(c) * a[1], p = Math.cos(c) * i[2] + Math.sin(c) * a[2];
252
+ o.push(t[0] + n[0] * u + l * d, t[1] + n[1] * u + l * f, t[2] + n[2] * u + l * p), s.push(d * g + n[0] * v, f * g + n[1] * v, p * g + n[2] * v);
253
+ }
254
+ }
255
+ return E(o, D(e.length, r), s);
256
+ }
257
+ var A = [
258
+ [.06, -.012],
259
+ [.068, 0],
260
+ [.074, .006],
261
+ [.08, .018],
262
+ [.084, .032],
263
+ [.084, .048],
264
+ [.079, .06],
265
+ [.068, .07],
266
+ [.052, .077],
267
+ [.032, .081],
268
+ [.014, .083],
269
+ [0, .0835]
270
+ ], j = [
271
+ [.05, -.012],
272
+ [.052, .006],
273
+ [.05, .016],
274
+ [.042, .024],
275
+ [.026, .029],
276
+ [.014, .031],
277
+ [0, .032]
278
+ ], ee = /* @__PURE__ */ new Map();
279
+ function te(e) {
280
+ let t = ee.get(e.name);
281
+ return t || (t = {
282
+ body: O(e),
283
+ earL: k(A, [
284
+ -e.earX,
285
+ f.earY,
286
+ 0
287
+ ], [
288
+ -1,
289
+ 0,
290
+ 0
291
+ ]),
292
+ earR: k(A, [
293
+ e.earX,
294
+ f.earY,
295
+ 0
296
+ ], [
297
+ 1,
298
+ 0,
299
+ 0
300
+ ]),
301
+ collar: k(j, [
302
+ 0,
303
+ -e.hy,
304
+ 0
305
+ ], [
306
+ 0,
307
+ -1,
308
+ 0
309
+ ], 16)
310
+ }, ee.set(e.name, t)), t;
311
+ }
312
+ //#endregion
313
+ //#region ../src/tv/sim.ts
314
+ var M = class {
315
+ x = 0;
316
+ v = 0;
317
+ constructor(e = 0) {
318
+ this.x = e;
319
+ }
320
+ step(e, t, n, r) {
321
+ let i = n * Math.PI * 2;
322
+ this.v += (i * i * (e - this.x) - 2 * r * i * this.v) * t, this.x += this.v * t;
323
+ }
324
+ };
325
+ function N(e) {
326
+ let t = Math.floor(e * 4294967295) >>> 0 || 1;
327
+ return () => {
328
+ t = t + 1831565813 >>> 0;
329
+ let e = t;
330
+ return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
331
+ };
332
+ }
333
+ var P = (e, t, n) => Math.min(n, Math.max(t, e)), ne = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2, F = .11, I = class {
334
+ state;
335
+ shown;
336
+ previous;
337
+ switched = 10;
338
+ age = 0;
339
+ time = 0;
340
+ since = 0;
341
+ pose = {
342
+ yaw: 0,
343
+ pitch: 0,
344
+ roll: 0,
345
+ x: 0,
346
+ lift: 0,
347
+ sx: 1,
348
+ sy: 1,
349
+ antennaX: 0,
350
+ antennaZ: 0
351
+ };
352
+ face;
353
+ pointer = null;
354
+ yaw = new M();
355
+ pitch = new M();
356
+ roll = new M();
357
+ sway = new M();
358
+ squash = new M();
359
+ antX = new M();
360
+ antZ = new M();
361
+ lastV = {
362
+ roll: 0,
363
+ pitch: 0,
364
+ sway: 0
365
+ };
366
+ jump = null;
367
+ random;
368
+ lookAt = {
369
+ yaw: 0,
370
+ pitch: 0,
371
+ x: 0,
372
+ y: 0
373
+ };
374
+ nextLook = .6;
375
+ nextBlink = 1.5;
376
+ blinkAge = -1;
377
+ nextHop = 8;
378
+ nextSide = 4;
379
+ reactUntil = -1;
380
+ nextNod = 2.5;
381
+ constructor(e, t) {
382
+ this.random = N(e), this.state = this.shown = this.previous = t, this.face = {
383
+ lookX: 0,
384
+ lookY: 0,
385
+ blink: 0,
386
+ time: 0,
387
+ side: 1,
388
+ seed: e
389
+ }, this.nextBlink = 1 + this.random() * 3, this.nextHop = 6 + this.random() * 6;
390
+ }
391
+ setState(e) {
392
+ e !== this.state && (this.state = e, this.since = 0, this.nextLook = 0, this.nextHop = this.time + (e === "happy" ? .2 : 3 + this.random() * 4), e === "happy" && this.hop(.22, 1));
393
+ }
394
+ poke() {
395
+ this.hop(.24, this.random() < .5 ? 1 : -1), this.reactUntil = this.time + 1.6;
396
+ }
397
+ hop(e, t) {
398
+ this.jump ||= {
399
+ age: 0,
400
+ height: e,
401
+ spin: t,
402
+ lean: (this.random() - .5) * .3,
403
+ air: .42 + e * .45,
404
+ landed: !1
405
+ };
406
+ }
407
+ update(e) {
408
+ if (!Number.isFinite(e) || !(e > 0)) return;
409
+ let t = Math.min(e, .8), n = Math.max(1, Math.ceil(t / (1 / 120)));
410
+ for (let e = 0; e < n; e++) this.step(t / n);
411
+ }
412
+ stepJump(e) {
413
+ let t = 0, n = 0, r = 0, i = 0, a = this.jump, o = this.random;
414
+ if (a) {
415
+ if (a.age += e, a.age < F) i = .14;
416
+ else {
417
+ let e = (a.age - F) / a.air;
418
+ e < 1 ? (e < .06 && this.squash.x > .05 && (this.squash.v = -2.6, this.antZ.v -= 3), t = 4 * a.height * e * (1 - e), n = a.spin * Math.PI * 2 * ne(P(e * 1.08, 0, 1)), r = a.lean * Math.sin(e * Math.PI), i = e < .5 ? -.05 : 0) : a.landed ? a.age - F - a.air > .35 && (this.jump = null) : (a.landed = !0, this.squash.v += 3.2, this.antX.v += (o() < .5 ? -1 : 1) * (2.5 + o() * 2), this.antZ.v += 3.5);
419
+ }
420
+ }
421
+ return this.squash.step(i, e, 3.2, .32), {
422
+ lift: t,
423
+ spin: n,
424
+ lean: r
425
+ };
426
+ }
427
+ hopWithChance(e, t) {
428
+ this.hop(e, this.random() < t ? this.random() < .5 ? 1 : -1 : 0);
429
+ }
430
+ updateLookAt(e) {
431
+ if (e > this.nextLook) {
432
+ let t = this.random;
433
+ this.lookAt = {
434
+ yaw: (t() - .5) * .75,
435
+ pitch: (t() - .5) * .24,
436
+ x: 0,
437
+ y: 0
438
+ }, this.lookAt.x = P(Math.round(this.lookAt.yaw * 5), -2, 2), this.lookAt.y = t() < .3 ? -1 : +(t() < .2), this.nextLook = e + 1.4 + t() * 2.6;
439
+ }
440
+ }
441
+ stateTargets(e) {
442
+ let t = this.random, n = 0, r = 0, i = 0, a = Math.sin(e * 1.9) * .008, o = 0, s = 0, c = 1.3, l = .62, u = 0;
443
+ switch (this.state) {
444
+ case "idle":
445
+ n = this.lookAt.yaw, r = this.lookAt.pitch, i = -this.lookAt.yaw * .16, o = this.lookAt.x, s = this.lookAt.y, e > this.nextHop && (this.hopWithChance(.15 + t() * .07, .35), this.nextHop = e + 7 + t() * 7);
446
+ break;
447
+ case "thinking": {
448
+ e > this.nextSide && (this.face.side = -this.face.side, this.nextSide = e + 3 + t() * 2);
449
+ let a = this.face.side;
450
+ n = .24 * a + Math.sin(e * .9) * .05, r = .17 + Math.sin(e * 1.3) * .03, i = -.13 * a, c = .9;
451
+ break;
452
+ }
453
+ case "searching": {
454
+ let t = e * 1.6;
455
+ n = Math.sin(t) * .55, r = -.04 + Math.sin(t * 2) * .04, i = Math.sin(t) * -.06, o = P(Math.sin(t + .4) * 3, -3, 3), c = 2.2, l = .8;
456
+ break;
457
+ }
458
+ case "listening":
459
+ n = -.14, r = .02, i = .17, e > this.nextNod && (this.pitch.v -= .9, this.nextNod = e + 2 + t() * 2.5);
460
+ break;
461
+ case "speaking":
462
+ n = Math.sin(e * .7) * .12, r = .03 + Math.sin(e * 6.3) * .025 * (.5 + .5 * Math.sin(e * 2.1)), i = Math.sin(e * .9) * .05, a += Math.abs(Math.sin(e * 6.3)) * .01, c = 1.8;
463
+ break;
464
+ case "working":
465
+ n = Math.sin(e * .8) * .08, r = -.16, i = Math.sin(e * .5) * .04, a += Math.abs(Math.sin(e * 7)) * .012, e > this.nextHop && (this.hop(.2, t() < .5 ? 1 : -1), this.nextHop = e + 5 + t() * 3);
466
+ break;
467
+ case "happy":
468
+ n = Math.sin(e * 2.2) * .18, i = Math.sin(e * 4.4) * .12, r = .08, e > this.nextHop && (this.hopWithChance(.17, .34), this.nextHop = e + 1.05 + t() * .4);
469
+ break;
470
+ case "error": {
471
+ let t = e % 2.4 / .7;
472
+ u = t < 1 ? Math.sin(t * Math.PI * 7) * .22 * (1 - t) : 0, r = -.06, i = -.05, c = 1.6;
473
+ break;
474
+ }
475
+ case "sleeping":
476
+ r = -.34, i = .13, n = .06, a = Math.sin(e * 1.15) * .016, c = .55, l = .9, e > this.nextNod && (this.pitch.v -= .5, this.nextNod = e + 5 + t() * 4);
477
+ break;
478
+ default: this.state;
479
+ }
480
+ return {
481
+ yaw: n,
482
+ pitch: r,
483
+ roll: i,
484
+ bob: a,
485
+ lookX: o,
486
+ lookY: s,
487
+ freq: c,
488
+ damping: l,
489
+ shake: u
490
+ };
491
+ }
492
+ step(e) {
493
+ this.time += e, this.since += e, this.age += e, this.switched += e;
494
+ let t = this.time, n = this.random, r = t < this.reactUntil ? "happy" : this.state;
495
+ r !== this.shown && (this.previous = this.shown, this.shown = r, this.switched = 0), this.updateLookAt(t);
496
+ let { yaw: i, pitch: a, roll: o, bob: s, lookX: c, lookY: l, freq: u, damping: d, shake: f } = this.stateTargets(t), p = this.pointer;
497
+ p && (this.state === "idle" || this.state === "listening" || this.state === "happy" || this.state === "speaking") && p && (i = P(p.x / 260, -1, 1) * .55, a = -P(p.y / 260, -1, 1) * .32, o = -i * .12 + (this.state === "listening" ? .12 : 0), c = P(p.x / 120, -2.4, 2.4), l = P(p.y / 160, -1.4, 1.4)), this.yaw.step(i, e, u, d), this.pitch.step(a, e, u, d), this.roll.step(o, e, u, d), this.sway.step(0, e, 1.2, .7);
498
+ let { lift: m, spin: h, lean: g } = this.stepJump(e);
499
+ t > this.nextBlink && (this.blinkAge = 0, this.nextBlink = t + 2.2 + n() * 3.5, n() < .2 && (this.nextBlink = t + .35));
500
+ let _ = 0;
501
+ this.blinkAge >= 0 && (this.blinkAge += e, _ = Math.sin(P(this.blinkAge / .17, 0, 1) * Math.PI), this.blinkAge > .17 && (this.blinkAge = -1));
502
+ let v = (this.roll.v - this.lastV.roll) / e, y = (this.pitch.v - this.lastV.pitch) / e, b = (this.sway.v - this.lastV.sway) / e;
503
+ this.lastV = {
504
+ roll: this.roll.v,
505
+ pitch: this.pitch.v,
506
+ sway: this.sway.v
507
+ };
508
+ let x = 2.3;
509
+ this.antX.v -= (v * .05 + b * .3) * e * 6, this.antZ.v -= y * .05 * e * 6, this.antX.step(0, e, x, .09), this.antZ.step(0, e, x, .09), this.antX.x = P(this.antX.x, -.7, .7), this.antZ.x = P(this.antZ.x, -.7, .7);
510
+ let S = this.squash.x;
511
+ this.pose = {
512
+ yaw: this.yaw.x + h + f,
513
+ pitch: this.pitch.x,
514
+ roll: this.roll.x + g,
515
+ x: this.sway.x,
516
+ lift: m + s,
517
+ sx: 1 + S * .55,
518
+ sy: 1 - S,
519
+ antennaX: this.antX.x,
520
+ antennaZ: this.antZ.x
521
+ }, this.face.lookX = c, this.face.lookY = l, this.face.blink = this.state === "sleeping" ? 0 : _, this.face.time = this.since;
522
+ }
523
+ };
524
+ function L(e) {
525
+ let t = {
526
+ yaw: 0,
527
+ pitch: 0,
528
+ roll: 0,
529
+ x: 0,
530
+ lift: 0,
531
+ sx: 1,
532
+ sy: 1,
533
+ antennaX: 0,
534
+ antennaZ: 0
535
+ };
536
+ switch (e) {
537
+ case "thinking": return {
538
+ ...t,
539
+ yaw: .24,
540
+ pitch: .17,
541
+ roll: -.13
542
+ };
543
+ case "searching": return {
544
+ ...t,
545
+ yaw: .3,
546
+ roll: -.04
547
+ };
548
+ case "listening": return {
549
+ ...t,
550
+ yaw: -.14,
551
+ pitch: .02,
552
+ roll: .17
553
+ };
554
+ case "working": return {
555
+ ...t,
556
+ pitch: -.16
557
+ };
558
+ case "happy": return {
559
+ ...t,
560
+ pitch: .08,
561
+ roll: .06
562
+ };
563
+ case "error": return {
564
+ ...t,
565
+ pitch: -.06,
566
+ roll: -.05
567
+ };
568
+ case "sleeping": return {
569
+ ...t,
570
+ pitch: -.34,
571
+ roll: .13,
572
+ yaw: .06
573
+ };
574
+ case "idle": return {
575
+ ...t,
576
+ yaw: -.18,
577
+ pitch: .04,
578
+ roll: .03
579
+ };
580
+ case "speaking": return {
581
+ ...t,
582
+ yaw: -.18,
583
+ pitch: .04,
584
+ roll: .03
585
+ };
586
+ default: return t;
587
+ }
588
+ }
589
+ function re(e, t) {
590
+ let n = 22 + 2 * Math.max(0, Math.ceil((e - 22) / 2)), r = 14 + 2 * Math.max(0, Math.ceil((t - 14) / 2));
591
+ return {
592
+ v: new Float32Array(n * r),
593
+ cols: n,
594
+ rows: r,
595
+ ox: (n - 22) / 2,
596
+ oy: (r - 14) / 2
597
+ };
598
+ }
599
+ var R = (e, t, n, r) => {
600
+ let i = t + e.ox, a = n + e.oy;
601
+ if (i < 0 || a < 0 || i >= e.cols || a >= e.rows) return;
602
+ let o = a * e.cols + i;
603
+ r > e.v[o] && (e.v[o] = r);
604
+ }, z = (e, t, n, r, i, a) => {
605
+ for (let o = n; o < n + i; o++) for (let n = t; n < t + r; n++) R(e, n, o, a);
606
+ }, B = (e, t, n, r, i) => {
607
+ r.forEach((r, a) => {
608
+ for (let o = 0; o < r.length; o++) r[o] === "#" ? R(e, t + o, n + a, i) : r[o] === "+" && R(e, t + o, n + a, i * .5);
609
+ });
610
+ }, ie = 6, ae = 13, oe = 5;
611
+ function V(e, t, n = 4, r = 1, i = 0, a = 0) {
612
+ let o = Math.round(t.lookX), s = Math.round(t.lookY) + i, c = Math.max(1, Math.round(n - (n - 1) * t.blink)), l = oe + Math.floor((4 - n) / 2) + s + Math.floor((n - c) / 2);
613
+ for (let t of [ie, ae]) a > 0 && c > 1 ? (z(e, t + o, l, 3, 1, r * (1 - a)), z(e, t + o, l + 1, 3, c - 1, r)) : z(e, t + o, l, 3, c, r);
614
+ }
615
+ var se = (e) => .5 + .25 * Math.sin(e * 1.7) + .15 * Math.sin(e * 3.1 + 1.3) + .1 * Math.sin(e * 5.3 + 4.1), ce = [
616
+ "..#..",
617
+ ".#.#.",
618
+ "#...#"
619
+ ], le = [
620
+ "#...#",
621
+ ".#.#.",
622
+ "..#..",
623
+ ".#.#.",
624
+ "#...#"
625
+ ], ue = [
626
+ "####",
627
+ "..#.",
628
+ ".#..",
629
+ "####"
630
+ ], de = [
631
+ "###",
632
+ ".#.",
633
+ "###"
634
+ ], fe = {
635
+ idle(e, t) {
636
+ V(e, t);
637
+ },
638
+ thinking(e, t) {
639
+ V(e, {
640
+ ...t,
641
+ lookX: t.lookX + t.side * 1.4,
642
+ lookY: t.lookY - 1.2
643
+ }, 3, 1, 0, .45);
644
+ for (let n = 0; n < 3; n++) {
645
+ let r = (t.time * 1.6 - n * .22) % 1, i = r < .35 ? Math.sin(r / .35 * Math.PI) : 0;
646
+ z(e, 6 + n * 4, 11 - (i > .5), 2, 2, .28 + .72 * i);
647
+ }
648
+ },
649
+ searching(e, t) {
650
+ V(e, t);
651
+ let n = -e.ox, r = 21 + e.ox, i = n + (Math.sin(t.time * 1.6 + .4) * .5 + .5) * (r - n), a = Math.cos(t.time * 1.6 + .4) > 0 ? -1 : 1;
652
+ for (let t = 0; t < 5; t++) {
653
+ let n = Math.round(i + a * t), r = .32 * (1 - t / 5);
654
+ for (let t = -e.oy; t < 14 + e.oy; t++) R(e, n, t, r);
655
+ }
656
+ },
657
+ listening(e, t) {
658
+ V(e, t, 4, 1, -1);
659
+ for (let n = 0; n < 12; n++) {
660
+ let r = 1 - Math.abs(n - 5.5) / 7, i = se(t.time * 7 + n * 1.9 + t.seed * 10) * r, a = Math.max(1, Math.round(i * 4));
661
+ for (let t = 0; t < a; t++) R(e, 5 + n, 12 - t, .75 - t * .12);
662
+ }
663
+ },
664
+ speaking(e, t) {
665
+ V(e, t, 4, 1, -1);
666
+ let n = Math.max(0, Math.sin(t.time * 2.1) * .5 + Math.sin(t.time * 3.7 + 1) * .5);
667
+ for (let r = 0; r < 8; r++) {
668
+ let i = 1 - Math.abs(r - 3.5) / 5, a = se(t.time * 11 + r * .9) * i * (.35 + n), o = a > .55 ? 3 : a > .28 ? 2 : 1, s = o === 3 ? 10 : 11, c = o === 3 ? 3 : o === 2 ? 2 : 1;
669
+ z(e, 7 + r, s, 1, c, 1);
670
+ }
671
+ },
672
+ working(e, t) {
673
+ V(e, {
674
+ ...t,
675
+ lookY: t.lookY + 1
676
+ }, 2, 1, 0);
677
+ let n = t.time / 2.6 % 1, r = Math.round(n * 12);
678
+ for (let t = 0; t < 12; t++) R(e, 5 + t, 11, t < r ? .95 : .16);
679
+ R(e, 4, 11, .4), R(e, 17, 11, .4);
680
+ },
681
+ happy(e, t) {
682
+ let n = Math.round(Math.max(0, Math.sin(t.time * 5.6)) * -1);
683
+ B(e, 5, oe + n, ce, 1), B(e, 12, oe + n, ce, 1), B(e, 7, 10 + n, ["#......#", ".######."], .9);
684
+ },
685
+ error(e, t) {
686
+ let n = Math.sin(t.time * 7) > -.6 ? 1 : .55;
687
+ B(e, 5, 4, le, n), B(e, 12, 4, le, n);
688
+ for (let t = 0; t < 8; t++) R(e, 7 + t, t % 2 ? 11 : 12, .8);
689
+ },
690
+ sleeping(e, t) {
691
+ for (let t of [ie, ae]) R(e, t - 1, 7, .32), z(e, t, 8, 3, 1, .42), R(e, t + 3, 7, .32);
692
+ for (let [n, r] of [[0, !0], [1.1, !1]]) {
693
+ let i = (t.time + n) / 2.2 % 1, a = Math.sin(i * Math.PI) * .6, o = Math.round(5 - i * 5);
694
+ B(e, 16 + Math.round(i * 2), o, r ? ue : de, a);
695
+ }
696
+ }
697
+ }, pe = (e) => () => e, me = {
698
+ idle: {
699
+ screen: null,
700
+ ball: [
701
+ 255,
702
+ 250,
703
+ 240
704
+ ],
705
+ pulse: (e) => .75 + .1 * Math.sin(e * 1.4)
706
+ },
707
+ thinking: {
708
+ screen: null,
709
+ ball: [
710
+ 255,
711
+ 184,
712
+ 64
713
+ ],
714
+ pulse: (e) => .45 + .55 * (.5 + .5 * Math.sin(e * 4.2))
715
+ },
716
+ searching: {
717
+ screen: null,
718
+ ball: [
719
+ 90,
720
+ 220,
721
+ 255
722
+ ],
723
+ pulse: (e) => e * 2.4 % 1 < .18 ? 1 : .25
724
+ },
725
+ listening: {
726
+ screen: null,
727
+ ball: [
728
+ 96,
729
+ 255,
730
+ 150
731
+ ],
732
+ pulse: pe(.95)
733
+ },
734
+ speaking: {
735
+ screen: null,
736
+ ball: [
737
+ 255,
738
+ 250,
739
+ 240
740
+ ],
741
+ pulse: (e) => .55 + .45 * se(e * 11)
742
+ },
743
+ working: {
744
+ screen: null,
745
+ ball: [
746
+ 110,
747
+ 160,
748
+ 255
749
+ ],
750
+ pulse: (e) => e * 1.7 % 1 < .5 ? 1 : .35
751
+ },
752
+ happy: {
753
+ screen: null,
754
+ ball: [
755
+ 255,
756
+ 130,
757
+ 200
758
+ ],
759
+ pulse: (e) => .8 + .2 * Math.sin(e * 8)
760
+ },
761
+ error: {
762
+ screen: [
763
+ 255,
764
+ 70,
765
+ 64
766
+ ],
767
+ ball: [
768
+ 255,
769
+ 60,
770
+ 50
771
+ ],
772
+ pulse: (e) => e * 3 % 1 < .5 ? 1 : .15
773
+ },
774
+ sleeping: {
775
+ screen: null,
776
+ ball: [
777
+ 255,
778
+ 250,
779
+ 240
780
+ ],
781
+ pulse: pe(0)
782
+ }
783
+ }, he = (e, t, n) => {
784
+ let r = Math.hypot(e, t, n);
785
+ return [
786
+ e / r,
787
+ t / r,
788
+ n / r
789
+ ];
790
+ }, H = he(-.5, -.78, .62), ge = he(.85, .15, .5), _e = he(.55, -.55, -.62), ve = he(H[0], H[1], H[2] + 1), U = (e, t, n) => {
791
+ let r = Math.min(1, Math.max(0, (n - e) / (t - e)));
792
+ return r * r * (3 - 2 * r);
793
+ };
794
+ function ye(e, t, n) {
795
+ let r = -t, i = .05 + .12 * U(-.25, .3, r), a = 1.1 * U(.42, .78, r) * U(-.9, -.2, n - .6 * Math.abs(e)), o = 2.6 * U(.86, .97, e * H[0] + t * H[1] + n * H[2]), s = .5 * U(.6, .85, -e) * U(-.35, .05, r) * (1 - U(.2, .5, r));
796
+ return i + a + o + s;
797
+ }
798
+ var be = (e) => (e / 255) ** 2.2;
799
+ function xe(e) {
800
+ return [
801
+ be(e[0]),
802
+ be(e[1]),
803
+ be(e[2])
804
+ ];
805
+ }
806
+ function W(e) {
807
+ let t = e * (2.51 * e + .03) / (e * (2.43 * e + .59) + .14);
808
+ return Math.round(255 * Math.min(1, Math.max(0, t)) ** (1 / 2.2));
809
+ }
810
+ function Se(e, t, n, r, i = [
811
+ 0,
812
+ 0,
813
+ 0
814
+ ]) {
815
+ let a = t * H[0] + n * H[1] + r * H[2], o = Math.max(0, (a + .12) / 1.12), s = Math.max(0, t * ge[0] + n * ge[1] + r * ge[2]), c = .5 - .5 * n, l = Math.max(0, r), u = e.f0 + (1 - e.f0) * (1 - l) ** 5, d = ye(2 * l * t, 2 * l * n, 2 * l * r - 1) * u, f = e.spec * Math.max(0, t * ve[0] + n * ve[1] + r * ve[2]) ** +e.shininess, p = Math.max(0, t * _e[0] + n * _e[1] + r * _e[2]), m = e.rim * p * p * (1 - l) ** 1.6, h = .05 + .1 * c + 1.25 * o + .16 * s;
816
+ for (let t = 0; t < 3; t++) {
817
+ let n = e.albedo[t], r = 1 - e.metal + e.metal * n * 2.2, a = t === 0 ? .62 : t === 1 ? .78 : 1;
818
+ i[t] = n * h * (1 - u * .6) + (d + f) * r + m * a * (.35 + n);
819
+ }
820
+ return i;
821
+ }
822
+ function Ce(e, t = 1) {
823
+ return t >= 1 ? `rgb(${W(e[0])},${W(e[1])},${W(e[2])})` : `rgba(${W(e[0])},${W(e[1])},${W(e[2])},${t})`;
824
+ }
825
+ function we(e, t, n, r) {
826
+ return Ce(Se(e, t, n, r));
827
+ }
828
+ //#endregion
829
+ //#region ../src/tv/render.ts
830
+ var G = (e, t) => {
831
+ let n = document.createElement("canvas");
832
+ return n.width = Math.max(1, Math.ceil(e)), n.height = Math.max(1, Math.ceil(t)), n;
833
+ }, Te = (e, t, n) => {
834
+ let r = Math.min(1, Math.max(0, (n - e) / (t - e)));
835
+ return r * r * (3 - 2 * r);
836
+ }, Ee = (e, t) => {
837
+ let n = Math.imul(e, 374761393) + Math.imul(t, 668265263);
838
+ return n = Math.imul(n ^ n >>> 13, 1274126177), ((n ^ n >>> 16) >>> 0) / 4294967296;
839
+ }, De = (() => {
840
+ let e = Math.hypot(H[0], H[1], H[2] + 1);
841
+ return [
842
+ H[0] / e,
843
+ H[1] / e,
844
+ (H[2] + 1) / e
845
+ ];
846
+ })(), K = {
847
+ antenna: .028 + f.stem + f.ball * 1.8,
848
+ glow: .18,
849
+ hop: .3,
850
+ shadow: .22,
851
+ margin: .02
852
+ }, Oe = .035, ke = (e) => ({
853
+ hx: e.hx - p.glass,
854
+ hy: e.hy - p.glass
855
+ });
856
+ function Ae(e) {
857
+ let t = ke(e);
858
+ return {
859
+ hx: Math.max(t.hx, 11 * e.pitch) + Oe,
860
+ hy: Math.max(t.hy, 7 * e.pitch) + Oe
861
+ };
862
+ }
863
+ var je = (e) => ({
864
+ hx: e.hx - p.plate,
865
+ hy: e.hy - p.plate
866
+ });
867
+ function Me(e, t, n) {
868
+ let r = je(e), i = G(Math.ceil(r.hx * 2 * t), Math.ceil(r.hy * 2 * t)), a = i.getContext("2d"), o = a.createImageData(i.width, i.height), s = o.data, c = r.hx * 2 / i.width;
869
+ for (let t = 0; t < i.height; t++) {
870
+ let a = -r.hy + (t + .5) * c;
871
+ for (let o = 0; o < i.width; o++) {
872
+ let l = -r.hx + (o + .5) * c, u = e.sd(l, a, p.plate), d = Math.min(1, Math.max(0, .5 - u / c));
873
+ if (d <= 0) continue;
874
+ let f = n(l, a, c, o, t), m = (t * i.width + o) * 4, h = Math.min(1, Math.abs(f)) * d, g = f > 0 ? 255 : 0;
875
+ s[m] = s[m + 1] = s[m + 2] = g, s[m + 3] = Math.round(h * 255);
876
+ }
877
+ }
878
+ return a.putImageData(o, 0, 0), i;
879
+ }
880
+ function q(e, t, n, r = .55, i = 36) {
881
+ let a = Math.hypot(e, t, n);
882
+ return e /= a, t /= a, n /= a, (e * H[0] + t * H[1] + n * H[2] - H[2]) * .95 + r * Math.max(0, e * De[0] + t * De[1] + n * De[2]) ** +i - r * De[2] ** +i;
883
+ }
884
+ function Ne(e, t, n) {
885
+ let r = .0015, i = e(t + r, n) - e(t - r, n), a = e(t, n + r) - e(t, n - r), o = Math.hypot(i, a) || 1;
886
+ return [i / o, a / o];
887
+ }
888
+ function Pe(e, t, n, r, i) {
889
+ let a = .013, o = e - n, s = t - r, c = Math.hypot(o, s);
890
+ if (c > .019) return null;
891
+ if (c > a) return -.5 * (1 - (c - a) / .006);
892
+ let l = Math.sqrt(Math.max(0, 1 - (c / a) ** 2)) + .6, u = q(o / a, s / a, l, .9, 30) * 1.3 + .08, d = Math.cos(i);
893
+ return Math.abs(o * -Math.sin(i) + s * d) < .0026 && c < a * .8 && (u = -.65), u;
894
+ }
895
+ function Fe(e, t) {
896
+ let n = .018, r = (t, n) => e.sd(t, n, p.hole), i = (t, n) => e.sd(t, n, p.glass), a = e.screws;
897
+ return Me(e, t, (e, t, o, s, c) => {
898
+ let l = (Ee(s, c) - .5) * .07;
899
+ for (let [n, r, i] of a) {
900
+ let a = Pe(e, t, n, r, i);
901
+ if (a !== null) return a;
902
+ }
903
+ let u = r(e, t);
904
+ if (u >= 0) {
905
+ if (u < n) {
906
+ let [i, a] = Ne(r, e, t), o = 1 - u / n, s = o * o * 1.25;
907
+ return q(-i * Math.sin(s), -a * Math.sin(s), Math.cos(s)) + l;
908
+ }
909
+ return l;
910
+ }
911
+ let d = i(e, t);
912
+ if (d >= 0) {
913
+ let n = d / f.gasket, [r, a] = Ne(i, e, t), o = (n - .45) * 2.2;
914
+ return q(r * Math.sin(o), a * Math.sin(o), Math.cos(o), .22, 14) * .7 + l * .4;
915
+ }
916
+ let p = .05;
917
+ return -(.5 * Te(-.012, .012, i(e - H[0] * p, t - H[1] * p)) + .32 * Math.exp(d / .014));
918
+ });
919
+ }
920
+ function Ie(e, t) {
921
+ let n = [
922
+ -.12,
923
+ -.065,
924
+ -.01,
925
+ .045,
926
+ .1
927
+ ], r = (t, n) => e.sd(t, n, p.plate + .04), i = e.backScrews;
928
+ return Me(e, t, (e, t, a, o, s) => {
929
+ let c = (Ee(o, s) - .5) * .07;
930
+ for (let [n, r, a] of i) {
931
+ let i = Pe(e, t, n, r, a);
932
+ if (i !== null) return i;
933
+ }
934
+ let l = r(e, t);
935
+ if (Math.abs(l) < .006) {
936
+ let [n, i] = Ne(r, e, t), a = l / .006 * 1.1;
937
+ return q(-n * Math.sin(a), -i * Math.sin(a), Math.cos(a)) * .9 - .18;
938
+ }
939
+ for (let r of n) {
940
+ let n = (e, t) => Math.hypot(Math.max(0, Math.abs(e) - .196), t - r) - .014, i = n(e, t);
941
+ if (i < 0) return -.72 - .15 * Te(-.014, 0, -(t - r));
942
+ if (i < .01) {
943
+ let [r, a] = Ne(n, e, t), o = (1 - i / .01) ** 2 * 1.2;
944
+ return q(-r * Math.sin(o), -a * Math.sin(o), Math.cos(o)) + c;
945
+ }
946
+ }
947
+ return c;
948
+ });
949
+ }
950
+ function Le(e, t, n, r, i, a) {
951
+ let o = G(e, t), s = o.getContext("2d"), c = s.createRadialGradient(e * .5, t * .45, 0, e * .5, t * .5, Math.max(e, t) * .65);
952
+ c.addColorStop(0, "#111417"), c.addColorStop(1, "#050607"), s.fillStyle = c, s.fillRect(0, 0, e, t);
953
+ let l = n * .8, u = (n - l) / 2, d = `rgba(${Math.round(60 + a[0] * .12)},${Math.round(64 + a[1] * .12)},${Math.round(70 + a[2] * .12)},0.34)`, f = -Math.ceil(r / n), p = Math.ceil((e - r) / n), m = -Math.ceil(i / n), h = Math.ceil((t - i) / n);
954
+ s.fillStyle = d;
955
+ for (let e = m; e < h; e++) for (let t = f; t < p; t++) s.fillRect(r + t * n + u, i + e * n + u, l, l);
956
+ s.fillStyle = "rgba(255,255,255,0.05)";
957
+ for (let e = m; e < h; e++) for (let t = f; t < p; t++) s.fillRect(r + t * n + u, i + e * n + u, l, Math.max(1, l * .16));
958
+ return o;
959
+ }
960
+ function Re(e, t) {
961
+ let n = G(e, t), r = n.getContext("2d"), i = r.createRadialGradient(e / 2, t / 2, Math.min(e, t) * .3, e / 2, t / 2, Math.hypot(e, t) * .55);
962
+ i.addColorStop(0, "rgba(0,0,0,0)"), i.addColorStop(1, "rgba(0,0,0,0.5)"), r.fillStyle = i, r.fillRect(0, 0, e, t);
963
+ let a = r.createLinearGradient(0, 0, 0, t);
964
+ a.addColorStop(0, "rgba(190,210,255,0.09)"), a.addColorStop(.42, "rgba(190,210,255,0.015)"), a.addColorStop(.43, "rgba(190,210,255,0)"), r.fillStyle = a, r.fillRect(0, 0, e, t), r.save(), r.translate(e * .3, t * .2), r.scale(1, .45);
965
+ let o = r.createRadialGradient(0, 0, 0, 0, 0, e * .35);
966
+ return o.addColorStop(0, "rgba(255,255,255,0.07)"), o.addColorStop(1, "rgba(255,255,255,0)"), r.fillStyle = o, r.fillRect(-e, -t * 3, e * 2, t * 6), r.restore(), n;
967
+ }
968
+ function ze(e) {
969
+ let t = G(128, 128), n = t.getContext("2d"), r = n.createImageData(128, 128);
970
+ for (let e = 0; e < 16384; e++) {
971
+ let t = Ee(e, 7) > .5 ? 255 : 0;
972
+ r.data[e * 4] = r.data[e * 4 + 1] = r.data[e * 4 + 2] = t, r.data[e * 4 + 3] = Math.round(Ee(e, 13) * 9);
973
+ }
974
+ return n.putImageData(r, 0, 0), e.createPattern(t, "repeat");
975
+ }
976
+ var J = /* @__PURE__ */ new Map(), Be = 25165824, Ve = 12, He = 0;
977
+ function Ue(e) {
978
+ return 4 * (e.front.width * e.front.height + e.back.width * e.back.height + e.glass.width * e.glass.height);
979
+ }
980
+ function We(e, t) {
981
+ let n = `${e.name}:${Math.round(t)}`, r = J.get(n);
982
+ if (r) return J.delete(n), J.set(n, r), r;
983
+ let i = Ae(e);
984
+ r = {
985
+ front: Fe(e, t),
986
+ back: Ie(e, t),
987
+ glass: Re(i.hx * 2 * t, i.hy * 2 * t)
988
+ };
989
+ let a = Ue(r);
990
+ for (; J.size && (J.size >= Ve || He + a > Be);) {
991
+ let e = J.keys().next().value;
992
+ He -= Ue(J.get(e)), J.delete(e);
993
+ }
994
+ return a <= Be && (J.set(n, r), He += a), r;
995
+ }
996
+ var Y = (e, t, n) => [
997
+ e[0] + (t[0] - e[0]) * n,
998
+ e[1] + (t[1] - e[1]) * n,
999
+ e[2] + (t[2] - e[2]) * n
1000
+ ], Ge = class {
1001
+ shape = null;
1002
+ meshes = null;
1003
+ unit = 0;
1004
+ ledKey = "";
1005
+ front = null;
1006
+ back = null;
1007
+ screen = null;
1008
+ screenBase = null;
1009
+ glass = null;
1010
+ layer = null;
1011
+ tiny = G(22, 14);
1012
+ tinyHalf = G(11, 7);
1013
+ tinyImg = null;
1014
+ grain = null;
1015
+ grid = re(22, 14);
1016
+ gridPrev = re(22, 14);
1017
+ proj = /* @__PURE__ */ new Float32Array(6144);
1018
+ screenGeo = {
1019
+ pitch: 0,
1020
+ x0: 0,
1021
+ y0: 0
1022
+ };
1023
+ prepare(e, t, n) {
1024
+ if (Math.abs(t - this.unit) > .5 || e !== this.shape) {
1025
+ this.unit = t, this.shape = e, this.meshes = te(e);
1026
+ let n = We(e, t);
1027
+ this.front = n.front, this.back = n.back, this.glass = n.glass;
1028
+ let r = Ae(e);
1029
+ this.screen = G(r.hx * 2 * t, r.hy * 2 * t), this.ledKey = "";
1030
+ let i = ke(e);
1031
+ this.grid = re(Math.ceil(i.hx * 2 / e.pitch), Math.ceil(i.hy * 2 / e.pitch)), this.gridPrev = re(this.grid.cols, this.grid.rows), this.tiny = G(this.grid.cols, this.grid.rows), this.tinyHalf = G(Math.ceil(this.grid.cols / 2), Math.ceil(this.grid.rows / 2)), this.tinyImg = null;
1032
+ let a = e.pitch * t;
1033
+ this.screenGeo = {
1034
+ pitch: a,
1035
+ x0: (this.screen.width - a * this.grid.cols) / 2,
1036
+ y0: (this.screen.height - a * this.grid.rows) / 2
1037
+ };
1038
+ }
1039
+ let r = n.join(",");
1040
+ if (r !== this.ledKey && this.screen) {
1041
+ this.ledKey = r;
1042
+ let { pitch: e, x0: t, y0: i } = this.screenGeo;
1043
+ this.screenBase = Le(this.screen.width, this.screen.height, e, t, i, n);
1044
+ }
1045
+ }
1046
+ compose(e, t) {
1047
+ let n = this.grid, r = n.v, { cols: i, rows: a } = n;
1048
+ if (r.fill(0), !e) return fe[t](n, {
1049
+ lookX: 0,
1050
+ lookY: 0,
1051
+ blink: 0,
1052
+ time: .4,
1053
+ side: 1,
1054
+ seed: 0
1055
+ }), n;
1056
+ if (fe[e.shown](n, e.face), e.switched < .3) {
1057
+ let t = this.gridPrev;
1058
+ t.v.fill(0), fe[e.previous](t, {
1059
+ ...e.face,
1060
+ time: e.face.time + 10
1061
+ });
1062
+ let n = e.switched / .3;
1063
+ for (let e = 0; e < r.length; e++) r[e] = r[e] * n + t.v[e] * (1 - n);
1064
+ if (e.switched < .13) {
1065
+ let t = Math.floor(e.time * 30);
1066
+ for (let e = 0; e < a; e++) {
1067
+ let n = Math.floor((Math.sin(t * 12.9 + e * 78.2) * .5 + .5) * 3) - 1;
1068
+ if (!n) continue;
1069
+ let a = r.slice(e * i, (e + 1) * i);
1070
+ for (let t = 0; t < i; t++) r[e * i + t] = a[(t - n + i) % i];
1071
+ }
1072
+ for (let e = 0; e < r.length; e++) Math.sin(e * 91.7 + t * 3.1) > .93 && (r[e] = Math.max(r[e], .3));
1073
+ }
1074
+ }
1075
+ if (e.age < .55) {
1076
+ let t = Te(.08, .5, e.age) * (a / 2 + .5);
1077
+ for (let n = 0; n < a; n++) {
1078
+ let o = Math.abs(n - (a - 1) / 2);
1079
+ for (let a = 0; a < i; a++) {
1080
+ let s = n * i + a;
1081
+ o > t ? r[s] = 0 : o > t - 1.2 && (r[s] = Math.max(r[s], .85 * (1 - e.age / .55)));
1082
+ }
1083
+ }
1084
+ }
1085
+ return n;
1086
+ }
1087
+ drawScreen(e, t) {
1088
+ let n = this.screen.getContext("2d"), { cols: r, rows: i, v: a } = e;
1089
+ n.globalCompositeOperation = "source-over", n.globalAlpha = 1, n.drawImage(this.screenBase, 0, 0);
1090
+ let { pitch: o, x0: s, y0: c } = this.screenGeo, l = `rgb(${Y(t, [
1091
+ 255,
1092
+ 255,
1093
+ 255
1094
+ ], .6).map(Math.round).join(",")})`, u = `rgb(${t.map(Math.round).join(",")})`, d = o * .8, f = (o - d) / 2;
1095
+ for (let e = 0; e < i; e++) for (let t = 0; t < r; t++) {
1096
+ let i = a[e * r + t];
1097
+ i < .01 || (n.globalAlpha = Math.min(1, i * .4), n.fillStyle = u, n.fillRect(s + t * o + f * .4, c + e * o + f * .4, o - f * .8, o - f * .8), n.globalAlpha = Math.min(1, i), n.fillStyle = l, n.fillRect(s + t * o + f, c + e * o + f, d, d));
1098
+ }
1099
+ let p = this.tiny.getContext("2d");
1100
+ this.tinyImg ||= p.createImageData(r, i);
1101
+ let m = this.tinyImg.data;
1102
+ for (let e = 0; e < r * i; e++) m[e * 4] = t[0], m[e * 4 + 1] = t[1], m[e * 4 + 2] = t[2], m[e * 4 + 3] = Math.round(Math.min(1, a[e]) * 255);
1103
+ p.putImageData(this.tinyImg, 0, 0);
1104
+ let h = this.tinyHalf.getContext("2d");
1105
+ h.clearRect(0, 0, this.tinyHalf.width, this.tinyHalf.height), h.imageSmoothingEnabled = !0, h.drawImage(this.tiny, 0, 0, this.tinyHalf.width, this.tinyHalf.height), n.imageSmoothingEnabled = !0, n.globalCompositeOperation = "lighter", n.globalAlpha = .7, n.drawImage(this.tiny, s, c, r * o, i * o), n.globalAlpha = .65, n.drawImage(this.tinyHalf, s - o, c - o, (r + 2) * o, (i + 2) * o), n.globalCompositeOperation = "source-over", n.globalAlpha = 1, n.drawImage(this.glass, 0, 0);
1106
+ }
1107
+ drawFloorShadow(e, t, n, r, i, a, o) {
1108
+ if (o) {
1109
+ let o = Math.max(0, n.lift), s = r + (i.hy + .11) * a, c = a * i.hx * (1 - o * .9) * n.sx;
1110
+ e.save(), e.translate(t / 2 + n.x * a, s), e.scale(1, .16);
1111
+ let l = e.createRadialGradient(0, 0, 0, 0, 0, c), u = .55 * Math.max(0, 1 - o * 1.6);
1112
+ l.addColorStop(0, `rgba(0,0,0,${u})`), l.addColorStop(.55, `rgba(0,0,0,${u * .45})`), l.addColorStop(1, "rgba(0,0,0,0)"), e.fillStyle = l, e.beginPath(), e.arc(0, 0, c, 0, Math.PI * 2), e.fill(), e.restore();
1113
+ }
1114
+ }
1115
+ drawGrain(e, t, n) {
1116
+ if (this.grain) {
1117
+ e.setTransform(1, 0, 0, 1, 0, 0), e.globalCompositeOperation = "source-atop";
1118
+ let r = typeof DOMMatrix > "u" ? null : new DOMMatrix().translate(t, n);
1119
+ r && "setTransform" in this.grain && this.grain.setTransform(r), e.fillStyle = this.grain, e.fillRect(0, 0, e.canvas.width, e.canvas.height), e.globalCompositeOperation = "source-over";
1120
+ }
1121
+ }
1122
+ draw(e, t, n, r, i, a, o, s) {
1123
+ let c = K.antenna + K.glow + K.hop, l = K.shadow, u = Math.min(t * .6, t * (1 - 2 * K.margin) / (2 * a.hy + c + l)), d = je(a), g = ke(a), _ = Ae(a), v = r ? r.shown : i, y = me[v], b = y.screen ?? o.led;
1124
+ r && r.switched < .3 && (b = Y(me[r.previous].screen ?? o.led, b, r.switched / .3).map(Math.round)), this.prepare(a, u, b), (!this.layer || this.layer.width !== e.canvas.width || this.layer.height !== e.canvas.height) && (this.layer = G(e.canvas.width, e.canvas.height), this.grain = ze(e));
1125
+ let x = this.layer.getContext("2d"), S = m(n.yaw, n.pitch, n.roll), C = t / 2 + n.x * u, w = t * K.margin + (a.hy + c) * u, T = w - n.lift * u, E = T + a.hy * u, D = (e, t, r) => {
1126
+ let i = h(S, e, t, r);
1127
+ return [
1128
+ C + i[0] * u * n.sx,
1129
+ E + (T + i[1] * u - E) * n.sy,
1130
+ i[2]
1131
+ ];
1132
+ }, O = (e, t, n) => {
1133
+ let r = D(0, 0, t), i = D(n ? -1 : 1, 0, t), a = D(0, 1, t);
1134
+ e.setTransform(i[0] - r[0], i[1] - r[1], a[0] - r[0], a[1] - r[1], r[0], r[1]);
1135
+ };
1136
+ e.setTransform(1, 0, 0, 1, 0, 0), e.clearRect(0, 0, e.canvas.width, e.canvas.height), this.drawFloorShadow(e, t, n, w, a, u, s.floorShadow);
1137
+ let { body: k, earL: A, earR: j, collar: ee } = this.meshes, te = h(S, -a.earX - .05, f.earY, 0)[2], M = h(S, a.earX + .05, f.earY, 0)[2], N = h(S, 0, -a.hy, 0)[2] < -.012, P = (e, t, n) => {
1138
+ let r = t.pos.length / 3, i = this.proj;
1139
+ for (let e = 0; e < r; e++) {
1140
+ let n = D(t.pos[e * 3], t.pos[e * 3 + 1], t.pos[e * 3 + 2]);
1141
+ i[e * 3] = n[0], i[e * 3 + 1] = n[1], i[e * 3 + 2] = n[2];
1142
+ }
1143
+ let a = [], o = t.quads, s = t.normals;
1144
+ for (let e = 0; e < o.length / 4; e++) {
1145
+ if (S[6] * s[e * 3] + S[7] * s[e * 3 + 1] + S[8] * s[e * 3 + 2] < -.03) continue;
1146
+ let t = i[o[e * 4] * 3 + 2] + i[o[e * 4 + 1] * 3 + 2] + i[o[e * 4 + 2] * 3 + 2] + i[o[e * 4 + 3] * 3 + 2];
1147
+ a.push([t, e]);
1148
+ }
1149
+ a.sort((e, t) => e[0] - t[0]), e.lineWidth = Math.max(.6, u / 260), e.lineJoin = "round";
1150
+ for (let [, t] of a) {
1151
+ let r = s[t * 3], a = s[t * 3 + 1], c = s[t * 3 + 2], l = h(S, r, a, c), u = we(n, l[0], l[1], l[2]);
1152
+ e.beginPath();
1153
+ for (let n = 0; n < 4; n++) {
1154
+ let r = o[t * 4 + n] * 3;
1155
+ n ? e.lineTo(i[r], i[r + 1]) : e.moveTo(i[r], i[r + 1]);
1156
+ }
1157
+ e.closePath(), e.fillStyle = u, e.strokeStyle = u, e.fill(), e.stroke();
1158
+ }
1159
+ }, ne = () => this.drawAntenna(e, D, u, n, o, r, v, y, ee);
1160
+ N && ne(), te < 0 && P(e, A, o.trim), M < 0 && P(e, j, o.trim), x.setTransform(1, 0, 0, 1, 0, 0), x.globalCompositeOperation = "source-over", x.clearRect(0, 0, this.layer.width, this.layer.height), P(x, k, o.shell);
1161
+ let F = S[8], I = a.depth / 2, L = Math.abs(F) > .005 ? F > 0 ? 1 : -1 : 0;
1162
+ if (L) {
1163
+ let e = .17;
1164
+ O(x, L * I, L < 0);
1165
+ let t = (e, t) => {
1166
+ let n = h(S, e * (L < 0 ? -1 : 1), t, L), r = Math.hypot(n[0], n[1], n[2]);
1167
+ return Ce(Se(o.shell, n[0] / r, n[1] / r, n[2] / r));
1168
+ };
1169
+ x.beginPath(), a.path(x, p.plate - .002);
1170
+ let n = x.createLinearGradient(0, -d.hy, 0, d.hy);
1171
+ n.addColorStop(0, t(0, -.17)), n.addColorStop(.5, t(0, 0)), n.addColorStop(1, t(0, e)), x.fillStyle = n, x.fill();
1172
+ let r = x.createLinearGradient(-d.hx, 0, d.hx, 0);
1173
+ r.addColorStop(0, t(-.17, 0)), r.addColorStop(.5, t(0, 0)), r.addColorStop(1, t(e, 0)), x.globalAlpha = .5, x.fillStyle = r, x.fill(), x.globalAlpha = 1;
1174
+ }
1175
+ if (this.drawGrain(x, C, T), e.drawImage(this.layer, 0, 0), L > 0) {
1176
+ e.save(), O(e, I, !1), e.beginPath(), a.path(e, p.hole), e.fillStyle = "#060709", e.fill(), e.save(), e.beginPath(), a.path(e, p.glass), e.clip(), this.drawScreen(this.compose(r, i), b), O(e, I - f.recess, !1), e.drawImage(this.screen, -_.hx, -_.hy, _.hx * 2, _.hy * 2), O(e, I, !1);
1177
+ let t = -.05 - n.yaw * .9 + n.pitch * .5, o = e.createLinearGradient(-.55 + t, -.35, .15 + t, .35);
1178
+ o.addColorStop(0, "rgba(255,255,255,0)"), o.addColorStop(.36, "rgba(255,255,255,0)"), o.addColorStop(.43, "rgba(220,232,255,0.075)"), o.addColorStop(.5, "rgba(255,255,255,0)"), o.addColorStop(.58, "rgba(255,255,255,0)"), o.addColorStop(.61, "rgba(220,232,255,0.04)"), o.addColorStop(.65, "rgba(255,255,255,0)"), e.fillStyle = o, e.fillRect(-g.hx, -g.hy, g.hx * 2, g.hy * 2), e.restore(), e.drawImage(this.front, -d.hx, -d.hy, d.hx * 2, d.hy * 2), e.restore();
1179
+ } else L < 0 && (e.save(), O(e, -I, !0), e.drawImage(this.back, -d.hx, -d.hy, d.hx * 2, d.hy * 2), e.restore());
1180
+ te >= 0 && P(e, A, o.trim), M >= 0 && P(e, j, o.trim), N || ne(), e.setTransform(1, 0, 0, 1, 0, 0);
1181
+ }
1182
+ drawAntenna(e, t, n, r, i, a, o, s, c) {
1183
+ let l = m(r.yaw, r.pitch, r.roll), u = this.proj, d = c.pos.length / 3;
1184
+ for (let e = 0; e < d; e++) {
1185
+ let n = t(c.pos[e * 3], c.pos[e * 3 + 1], c.pos[e * 3 + 2]);
1186
+ u[e * 3] = n[0], u[e * 3 + 1] = n[1], u[e * 3 + 2] = n[2];
1187
+ }
1188
+ let p = c.quads, g = c.normals;
1189
+ e.lineWidth = Math.max(.6, n / 260);
1190
+ for (let t = 0; t < p.length / 4; t++) {
1191
+ let n = h(l, g[t * 3], g[t * 3 + 1], g[t * 3 + 2]);
1192
+ if (n[2] < -.03) continue;
1193
+ let r = we(i.trim, n[0], n[1], n[2]);
1194
+ e.beginPath();
1195
+ for (let n = 0; n < 4; n++) {
1196
+ let r = p[t * 4 + n] * 3;
1197
+ n ? e.lineTo(u[r], u[r + 1]) : e.moveTo(u[r], u[r + 1]);
1198
+ }
1199
+ e.closePath(), e.fillStyle = r, e.strokeStyle = r, e.fill(), e.stroke();
1200
+ }
1201
+ let _ = -this.shape.hy - .028, v = f.stem, y = r.antennaX, b = r.antennaZ, x = [
1202
+ Math.sin(y),
1203
+ -Math.cos(y) * Math.cos(b),
1204
+ Math.sin(b)
1205
+ ], S = t(0, _, 0), C = t(0, _ - v * .55, 0), w = t(x[0] * v, _ + x[1] * v, x[2] * v), T = t(x[0] * (v + f.ball * .8), _ + x[1] * (v + f.ball * .8), x[2] * (v + f.ball * .8));
1206
+ e.lineCap = "round", e.beginPath(), e.moveTo(S[0], S[1]), e.quadraticCurveTo(C[0], C[1], w[0], w[1]), e.lineWidth = n * .02, e.strokeStyle = "#4a5260", e.stroke(), e.lineWidth = n * .009, e.strokeStyle = "#9aa3b1", e.stroke(), e.save(), e.translate(-n * .004, 0), e.lineWidth = n * .004, e.strokeStyle = "rgba(255,255,255,0.75)", e.stroke(), e.restore();
1207
+ let E = s.ball, D = s.pulse(a ? a.face.time : .3);
1208
+ if (a && a.switched < .3) {
1209
+ let e = me[a.previous], t = a.switched / .3;
1210
+ E = Y(e.ball, E, t), D = e.pulse(a.face.time + 10) * (1 - t) + D * t;
1211
+ }
1212
+ a && a.age < .55 && (D *= Te(.1, .5, a.age));
1213
+ let O = f.ball * n * r.sx, [k, A] = T, j = Y([
1214
+ 168,
1215
+ 174,
1216
+ 186
1217
+ ], Y(E, [
1218
+ 255,
1219
+ 255,
1220
+ 255
1221
+ ], .35), D), ee = Y(j, Y([
1222
+ 150,
1223
+ 158,
1224
+ 172
1225
+ ], E, .5), .48), te = Y([
1226
+ 70,
1227
+ 76,
1228
+ 88
1229
+ ], Y(E, [
1230
+ 90,
1231
+ 96,
1232
+ 108
1233
+ ], .5), D * .55), M = e.createRadialGradient(k - O * .18, A - O * .22, O * .05, k, A, O);
1234
+ if (M.addColorStop(0, `rgb(${Y(j, [
1235
+ 255,
1236
+ 255,
1237
+ 255
1238
+ ], .6 + D * .3).map(Math.round).join(",")})`), M.addColorStop(.38, `rgb(${j.map(Math.round).join(",")})`), M.addColorStop(.78, `rgb(${ee.map(Math.round).join(",")})`), M.addColorStop(1, `rgb(${te.map(Math.round).join(",")})`), D > .01) {
1239
+ e.globalCompositeOperation = "lighter";
1240
+ let t = e.createRadialGradient(k, A, O * .6, k, A, O * 4.2), n = E.map(Math.round).join(",");
1241
+ t.addColorStop(0, `rgba(${n},${.5 * D})`), t.addColorStop(.35, `rgba(${n},${.14 * D})`), t.addColorStop(1, `rgba(${n},0)`), e.fillStyle = t, e.beginPath(), e.arc(k, A, O * 4.2, 0, Math.PI * 2), e.fill(), e.globalCompositeOperation = "source-over";
1242
+ }
1243
+ let N = e.createRadialGradient(k, A + O * .9, 0, k, A + O * .9, O * .7);
1244
+ N.addColorStop(0, "rgba(20,24,32,0.28)"), N.addColorStop(1, "rgba(20,24,32,0)"), e.fillStyle = N, e.beginPath(), e.arc(k, A + O * .9, O * .7, 0, Math.PI * 2), e.fill(), e.beginPath(), e.arc(k, A, O, 0, Math.PI * 2), e.fillStyle = M, e.fill(), e.lineWidth = Math.max(.75, O * .07), e.strokeStyle = "rgba(28,32,42,0.28)", e.stroke();
1245
+ let P = e.createRadialGradient(k - O * .38, A - O * .42, 0, k - O * .38, A - O * .42, O * .38);
1246
+ P.addColorStop(0, "rgba(255,255,255,0.95)"), P.addColorStop(1, "rgba(255,255,255,0)"), e.fillStyle = P, e.fill();
1247
+ }
1248
+ };
1249
+ //#endregion
1250
+ //#region ../src/color.ts
1251
+ function Ke(e) {
1252
+ let t = e.trim(), n = t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
1253
+ if (n) {
1254
+ let e = n[1].length === 3 ? n[1].replace(/./g, (e) => e + e) : n[1], t = parseInt(e, 16);
1255
+ return [
1256
+ t >> 16 & 255,
1257
+ t >> 8 & 255,
1258
+ t & 255
1259
+ ];
1260
+ }
1261
+ let r = t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
1262
+ return r ? [
1263
+ Number(r[1]),
1264
+ Number(r[2]),
1265
+ Number(r[3])
1266
+ ] : null;
1267
+ }
1268
+ //#endregion
1269
+ //#region ../src/ticker.ts
1270
+ var X = {
1271
+ x: NaN,
1272
+ y: NaN
1273
+ }, Z = /* @__PURE__ */ new Set(), Q = 0, qe = 0, Je = !1;
1274
+ function $() {
1275
+ X.x = NaN, X.y = NaN;
1276
+ }
1277
+ function Ye(e) {
1278
+ X.x = e.clientX, X.y = e.clientY;
1279
+ }
1280
+ function Xe() {
1281
+ document.hidden ? $e() : Z.size && Qe();
1282
+ }
1283
+ function Ze(e) {
1284
+ Q = 0;
1285
+ let t = qe ? Math.min(.1, (e - qe) / 1e3) : 0;
1286
+ qe = e, Z.forEach((e) => e(t)), Z.size && (Q = requestAnimationFrame(Ze));
1287
+ }
1288
+ function Qe() {
1289
+ Q || typeof document > "u" || document.hidden || (qe = 0, Q = requestAnimationFrame(Ze));
1290
+ }
1291
+ function $e() {
1292
+ Q && cancelAnimationFrame(Q), Q = 0;
1293
+ }
1294
+ function et() {
1295
+ Je || typeof document > "u" || (Je = !0, document.addEventListener("pointermove", Ye, { passive: !0 }), document.addEventListener("pointerleave", $), window.addEventListener("blur", $), document.addEventListener("visibilitychange", Xe));
1296
+ }
1297
+ function tt() {
1298
+ Je && (Je = !1, $(), document.removeEventListener("pointermove", Ye), document.removeEventListener("pointerleave", $), window.removeEventListener("blur", $), document.removeEventListener("visibilitychange", Xe));
1299
+ }
1300
+ function nt(e) {
1301
+ return et(), Z.add(e), Qe(), () => {
1302
+ Z.delete(e), Z.size || ($e(), tt());
1303
+ };
1304
+ }
1305
+ //#endregion
1306
+ //#region ../src/solid2/RobotHead.tsx
1307
+ var rt = /* @__PURE__ */ i("<canvas>");
1308
+ function it(e) {
1309
+ let t = 2166136261;
1310
+ for (let n = 0; n < e.length; n++) t = Math.imul(t ^ e.charCodeAt(n), 16777619);
1311
+ return (t >>> 0) % 1e3 / 1e3;
1312
+ }
1313
+ function at(e, t, n) {
1314
+ let r = Ke(e) ?? [
1315
+ 48,
1316
+ 80,
1317
+ 172
1318
+ ], i = Ke(t) ?? [
1319
+ 150,
1320
+ 168,
1321
+ 200
1322
+ ], a = Ke(n) ?? [
1323
+ 232,
1324
+ 242,
1325
+ 255
1326
+ ];
1327
+ return {
1328
+ shell: {
1329
+ albedo: xe(r),
1330
+ f0: .05,
1331
+ metal: .15,
1332
+ spec: .55,
1333
+ shininess: 70,
1334
+ rim: .9
1335
+ },
1336
+ trim: {
1337
+ albedo: xe(i),
1338
+ f0: .2,
1339
+ metal: .65,
1340
+ spec: .8,
1341
+ shininess: 45,
1342
+ rim: .7
1343
+ },
1344
+ led: a
1345
+ };
1346
+ }
1347
+ var ot = (e) => e && u.includes(e) ? e : "idle", st = (e) => e && d.includes(e) ? e : "rectangle";
1348
+ function ct(e) {
1349
+ return typeof e == "function";
1350
+ }
1351
+ function lt(e) {
1352
+ return typeof e == "function";
1353
+ }
1354
+ function ut(e, t) {
1355
+ if (Array.isArray(e)) for (let n of e) ut(n, t);
1356
+ else lt(e) && e(t);
1357
+ }
1358
+ function dt(e) {
1359
+ return typeof e == "string";
1360
+ }
1361
+ function ft(i) {
1362
+ let u = s(), d = i, f = c(i, "model", "shape", "state", "size", "color", "trimColor", "screenColor", "speed", "paused", "interactive", "floorShadow", "seed", "class", "className", "style", "onClick", "aria-label", "ref"), p, m, h = () => Number.isFinite(d.size) && (d.size ?? 0) > 0 ? Math.max(32, Math.min(d.size, 1024)) : 160, g = () => Number.isFinite(d.speed) && (d.speed ?? -1) >= 0 ? Math.min(d.speed, 8) : 1, _ = new I(Number.isFinite(d.seed) ? Math.min(1, Math.max(0, d.seed)) : it(u), ot(d.state)), [v, y] = a(!1), [b, x] = a(!0);
1363
+ l(() => {
1364
+ let e = new IntersectionObserver(([e]) => x(e.isIntersecting));
1365
+ e.observe(p);
1366
+ let t = window.matchMedia("(prefers-reduced-motion: reduce)");
1367
+ y(t.matches);
1368
+ let n = () => y(t.matches);
1369
+ return t.addEventListener("change", n), () => {
1370
+ e.disconnect(), t.removeEventListener("change", n);
1371
+ };
1372
+ }), o(() => {
1373
+ let e = ot(d.state), t = T(st(d.shape)), n = h(), r = at(d.color ?? "#2b49a3", d.trimColor ?? "#93a6c8", d.screenColor ?? "#e8f2ff"), i = g(), a = d.interactive ?? !0, o = d.floorShadow ?? !0, s = (d.paused ?? !1) || !(i > 0) || v();
1374
+ _.setState(e);
1375
+ let c = (i) => {
1376
+ if (!p) return;
1377
+ let a = Math.min(2, window.devicePixelRatio || 1), s = Math.round(n * a);
1378
+ (p.width !== s || p.height !== s) && (p.width = s, p.height = s);
1379
+ let c = p.getContext("2d");
1380
+ c && (m ??= new Ge(), m.draw(c, s, i ? _.pose : L(e), i ? _ : null, e, t, r, { floorShadow: o }));
1381
+ };
1382
+ if (s || !b()) b() && c(!1);
1383
+ else return nt((e) => {
1384
+ if (a && Number.isFinite(X.x)) {
1385
+ let e = p.getBoundingClientRect(), t = X.x - (e.left + e.width / 2), n = X.y - (e.top + e.height * .56);
1386
+ _.pointer = Math.hypot(t, n) < 700 ? {
1387
+ x: t,
1388
+ y: n
1389
+ } : null;
1390
+ } else _.pointer = null;
1391
+ _.update(e * i), c(!0);
1392
+ });
1393
+ });
1394
+ let S = (e) => {
1395
+ (d.interactive ?? !0) && !(d.paused ?? !1) && g() > 0 && !v() && _.poke();
1396
+ let t = d.onClick;
1397
+ ct(t) ? t(e) : Array.isArray(t) && t[0](t[1], e);
1398
+ }, C = (e) => {
1399
+ p = e, ut(d.ref, e);
1400
+ };
1401
+ var w = e(rt);
1402
+ return r(w, [{
1403
+ role: "img",
1404
+ get "aria-label"() {
1405
+ return d["aria-label"] ?? `Robot, ${ot(d.state)}`;
1406
+ },
1407
+ get class() {
1408
+ return d.class ?? d.className;
1409
+ },
1410
+ get style() {
1411
+ return dt(d.style) ? `width:${h()}px;height:${h()}px;display:block;cursor:${d.interactive === !1 ? "auto" : "pointer"};${d.style}` : {
1412
+ width: `${h()}px`,
1413
+ height: `${h()}px`,
1414
+ display: "block",
1415
+ cursor: d.interactive === !1 ? void 0 : "pointer",
1416
+ ...d.style
1417
+ };
1418
+ },
1419
+ onClick: S
1420
+ }, f], !1), t(() => C, w), n(), w;
1421
+ }
1422
+ //#endregion
1423
+ export { ft as RobotHead, d as robotHeadShapes, u as robotHeadStates };