agentglow 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,786 @@
1
+ var mt = Object.defineProperty;
2
+ var gt = (e, t, r) => t in e ? mt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var pe = (e, t, r) => gt(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsxs as P, jsx as n, Fragment as Ie } from "react/jsx-runtime";
5
+ import { OrbitControls as Mt } from "@react-three/drei";
6
+ import { useFrame as ae, Canvas as yt } from "@react-three/fiber";
7
+ import { EffectComposer as xt, Bloom as vt, Vignette as bt, Noise as wt } from "@react-three/postprocessing";
8
+ import { useRef as I, useMemo as N, useLayoutEffect as ot, useEffect as St, useState as Be } from "react";
9
+ import { j as At, w as O, h as Ct, l as De, o as zt, K as Ke, L as ve, G as Bt, n as Gt, T as ue, p as Oe, e as Pt, b as Ve, a as Et, S as de, R as Rt, d as st, c as It, C as _t, f as Tt, H as Lt, t as Dt, g as Ot, i as kt } from "./ClusterBall-CPsd6JvJ.js";
10
+ import * as p from "three";
11
+ import { a as ke, i as Wt, r as Nt, j as we } from "./spread-CWdeDFd9.js";
12
+ import { RoundedBoxGeometry as Ut } from "three/examples/jsm/geometries/RoundedBoxGeometry.js";
13
+ var nt;
14
+ const q = typeof window < "u" && !!((nt = window.matchMedia) != null && nt.call(window, "(prefers-reduced-motion: reduce)").matches), Me = -13, ee = { plan: -9.5, research: -1, write: 9 }, $t = 8.5, rt = (e) => 3 - e * $t, jt = (e) => De.grouped ? zt(e) : e, ye = (e, t) => rt(jt(t)) + ke(At(e)) * 2.4, Ft = 2.2, Xt = 200, Fe = 14.6, te = 14, We = 1, Ne = 1.75, Ue = -23, fe = Fe - 1.3, at = (e, t) => (t.x = Fe + e % te * We, t.z = Ue + Math.floor(e / te) * Ne, t), he = -17.8, xe = he + 2.1, Ee = (e) => 6 - e * 6.6, Re = (e) => Wt(e.type);
15
+ function Kt(e, t) {
16
+ var g;
17
+ const r = ye(e.run, ((g = O.runs.get(e.run)) == null ? void 0 : g.slot) ?? 0) + Ft, s = Nt(e), m = e.id;
18
+ if (!Re(e)) {
19
+ const E = e.type === "planner" ? ee.plan : e.type === "writer" ? ee.write : ee.research;
20
+ return t.set(E + we(m, 51) * 0.7 + ke(s) * 2.6, 0, r + we(m, 52) * 0.5);
21
+ }
22
+ const f = 0.3 + we(e.run, 53) * 0.5 + ke(s) * 0.6, w = 4.6 + Ct(e.run, 54) * 0.6 + we(m, 55) * 0.4;
23
+ return t.set(ee.research + 0.4 + Math.cos(f) * w, 0, r + 0.4 + Math.sin(f) * w * 0.62);
24
+ }
25
+ const Y = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map();
26
+ function H(e) {
27
+ let t = He.get(e);
28
+ return t || He.set(e, t = new p.Color(e)), t;
29
+ }
30
+ class Vt {
31
+ constructor() {
32
+ pe(this, "x", new Float32Array(8));
33
+ pe(this, "z", new Float32Array(8));
34
+ pe(this, "l", new Float32Array(8));
35
+ pe(this, "n", 0);
36
+ }
37
+ begin() {
38
+ return this.n = 0, this;
39
+ }
40
+ pt(t, r) {
41
+ const s = this.n;
42
+ return this.x[s] = t, this.z[s] = r, this.l[s] = s ? this.l[s - 1] + Math.hypot(t - this.x[s - 1], r - this.z[s - 1]) : 0, this.n++, this;
43
+ }
44
+ get len() {
45
+ return this.n ? this.l[this.n - 1] : 0;
46
+ }
47
+ /** point at fraction s (0..1); writes out.x/out.z and returns segment direction angle */
48
+ at(t, r) {
49
+ const s = Math.max(0, Math.min(1, t)) * this.len;
50
+ for (let m = 0; m < this.n - 1; m++)
51
+ if (s <= this.l[m + 1] || m === this.n - 2) {
52
+ const f = this.l[m + 1] - this.l[m] || 1, w = Math.min(1, (s - this.l[m]) / f);
53
+ return r.x = this.x[m] + (this.x[m + 1] - this.x[m]) * w, r.z = this.z[m] + (this.z[m + 1] - this.z[m]) * w, Math.atan2(this.z[m + 1] - this.z[m], this.x[m + 1] - this.x[m]);
54
+ }
55
+ return r.x = this.x[0], r.z = this.z[0], 0;
56
+ }
57
+ }
58
+ const re = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, it = (e) => 1 - Math.pow(1 - e, 3), X = (e) => e < 0 ? 0 : e > 1 ? 1 : e;
59
+ let Se = null;
60
+ function $e() {
61
+ if (Se) return Se;
62
+ const e = document.createElement("canvas");
63
+ e.width = e.height = 128;
64
+ const t = e.getContext("2d"), r = t.createRadialGradient(64, 64, 0, 64, 64, 64);
65
+ return r.addColorStop(0, "rgba(255,255,255,1)"), r.addColorStop(0.25, "rgba(255,255,255,0.45)"), r.addColorStop(0.6, "rgba(255,255,255,0.08)"), r.addColorStop(1, "rgba(255,255,255,0)"), t.fillStyle = r, t.fillRect(0, 0, 128, 128), Se = new p.CanvasTexture(e), Se;
66
+ }
67
+ let Ae = null;
68
+ function Ht() {
69
+ if (Ae) return Ae;
70
+ const e = document.createElement("canvas");
71
+ e.width = e.height = 128;
72
+ const t = e.getContext("2d");
73
+ t.strokeStyle = "#fff", t.lineWidth = 5, t.strokeRect(8, 8, 112, 112), t.lineWidth = 3, t.strokeRect(40, 40, 48, 48), t.fillStyle = "rgba(255,255,255,0.55)", t.fillRect(52, 52, 24, 24), t.lineWidth = 2, t.globalAlpha = 0.7;
74
+ for (let r = 0; r < 4; r++) {
75
+ const s = 48 + r * 10;
76
+ t.beginPath(), t.moveTo(s, 40), t.lineTo(s, 18), t.moveTo(s, 88), t.lineTo(s, 110), t.moveTo(40, s), t.lineTo(18, s), t.moveTo(88, s), t.lineTo(110, s), t.stroke();
77
+ }
78
+ return Ae = new p.CanvasTexture(e), Ae;
79
+ }
80
+ const me = 650, ct = (e) => Math.min(Xt, e.nodes.length), qe = /* @__PURE__ */ new Map();
81
+ function je(e, t) {
82
+ let r = qe.get(t);
83
+ return r === void 0 && qe.set(t, r = Gt(e, t) % ct(e)), r;
84
+ }
85
+ const Ze = 24, qt = 120, oe = 10, Ce = 2;
86
+ function Zt({ galaxy: e }) {
87
+ const t = I(null), r = I(null), s = I(null), m = I([]), f = I([]), w = I(Array(Ce).fill(-1)), g = ct(e), E = Math.ceil(g / te), x = N(() => e.nodes.slice(0, g).map((c) => new p.Color(Ke[c.kind] ?? "#94a3b8")), [e, g]), S = N(() => Array.from({ length: g }, (c, i) => at(i, { x: 0, z: 0 })), [g]), h = N(() => new Float32Array(g), [g]), y = N(() => new Float32Array(g), [g]), v = N(() => new p.Object3D(), []), u = N(() => new p.Color(), []), b = N(() => new p.Color(1, 1, 1), []), C = N(() => {
88
+ const c = new Map(e.nodes.map((B, R) => [B.id, R % g])), i = /* @__PURE__ */ new Set(), M = [];
89
+ for (const B of e.links) {
90
+ const R = c.get(B.source), G = c.get(B.target);
91
+ if (R === void 0 || G === void 0 || R === G || Math.hypot(R % te - G % te, Math.floor(R / te) - Math.floor(G / te)) > 5) continue;
92
+ const _ = R < G ? `${R}-${G}` : `${G}-${R}`;
93
+ if (!i.has(_) && (i.add(_), M.push([R, G]), M.length >= qt))
94
+ break;
95
+ }
96
+ return M;
97
+ }, [e, g]), U = N(() => {
98
+ const c = new p.BufferGeometry(), i = new Float32Array(C.length * oe * 6);
99
+ let M = 0;
100
+ for (const [B, R] of C) {
101
+ const G = S[B], _ = S[R], z = 0.3 + Math.hypot(_.x - G.x, _.z - G.z) * 0.1;
102
+ for (let T = 0; T < oe; T++)
103
+ for (const A of [T / oe, (T + 1) / oe])
104
+ i[M++] = G.x + (_.x - G.x) * A, i[M++] = 0.25 + 4 * z * A * (1 - A), i[M++] = G.z + (_.z - G.z) * A;
105
+ }
106
+ return c.setAttribute("position", new p.BufferAttribute(i, 3)), c.setAttribute("color", new p.BufferAttribute(new Float32Array(i.length), 3)), c;
107
+ }, [C, S]);
108
+ ae(() => {
109
+ const c = t.current, i = r.current, M = s.current;
110
+ if (!c || !i || !M) return;
111
+ const B = performance.now();
112
+ h.fill(0), y.fill(0);
113
+ let R = 0;
114
+ for (const z of O.flares) {
115
+ const T = B - z.start - me;
116
+ if (T < 0) continue;
117
+ const A = je(e, z.node), $ = T / 1e3, L = Math.exp(-$ * 1.5);
118
+ if (z.op === "read") h[A] = Math.max(h[A], L);
119
+ else if (y[A] = Math.max(y[A], L * 1.4), h[A] = Math.max(h[A], L), $ < 1.3) {
120
+ const K = $ * 10, k = 1 - $ / 1.3, F = S[A];
121
+ for (let Z = 0; Z < g; Z++) {
122
+ const ie = Math.hypot(S[Z].x - F.x, (S[Z].z - F.z) * 0.8), ne = Math.exp(-(ie - K) * (ie - K) * 1.2) * k * 0.38;
123
+ ne > y[Z] && (y[Z] = ne);
124
+ }
125
+ R < Ze && (v.position.set(F.x, 0.06, F.z), v.rotation.set(-Math.PI / 2, 0, 0), v.scale.setScalar(0.4 + K), v.updateMatrix(), M.setMatrixAt(R, v.matrix), u.set(1, 1, 1).multiplyScalar(0.9 * k * k), M.setColorAt(R++, u));
126
+ }
127
+ }
128
+ for (let z = 0; z < g; z++) {
129
+ const T = h[z], A = y[z];
130
+ v.position.set(S[z].x, 0.1 + T * 0.35 + A * 0.2, S[z].z), v.rotation.set(0, 0, 0), v.scale.set(0.74, 0.2 + T * 0.7 + A * 0.3, 1.25), v.updateMatrix(), c.setMatrixAt(z, v.matrix), u.copy(x[z]).multiplyScalar(0.06 + T * 4.5), A > 0.01 && u.lerp(b, Math.min(1, A * 0.7)).multiplyScalar(1 + A * 2.5), c.setColorAt(z, u), v.position.set(S[z].x - 0.22, 0.22 + T * 0.7 + A * 0.35, S[z].z + 0.45), v.scale.setScalar(1), v.updateMatrix(), i.setMatrixAt(z, v.matrix), u.copy(x[z]).multiplyScalar(0.45 + T * 5), i.setColorAt(z, u);
131
+ }
132
+ const G = U.getAttribute("color"), _ = G.array;
133
+ for (let z = 0; z < C.length; z++) {
134
+ const [T, A] = C[z], $ = Math.max(h[T], h[A]), L = Math.max(y[T], y[A]);
135
+ u.setRGB(0.05, 0.2, 0.28), $ > 0.02 && u.lerp(x[h[T] > h[A] ? T : A], Math.min(1, $)).multiplyScalar(1 + $ * 4), L > 0.05 && u.lerp(b, Math.min(1, L)).multiplyScalar(1 + L * 2);
136
+ const K = z * oe * 6;
137
+ for (let k = 0; k < oe * 2; k++)
138
+ _[K + k * 3] = u.r, _[K + k * 3 + 1] = u.g, _[K + k * 3 + 2] = u.b;
139
+ }
140
+ G.needsUpdate = !0;
141
+ let j = 0;
142
+ for (let z = O.flares.length - 1; z >= 0 && j < Ce; z--) {
143
+ const T = O.flares[z], A = B - T.start - me;
144
+ if (A < 0 || A > 1700) continue;
145
+ const $ = je(e, T.node);
146
+ let L = !1;
147
+ for (let F = 0; F < j; F++) w.current[F] === $ && (L = !0);
148
+ if (L) continue;
149
+ const K = m.current[j], k = f.current[j];
150
+ K && k && (K.visible = !0, K.position.set(S[$].x, 1.4, S[$].z), w.current[j] !== $ && (k.setText(`${T.op === "write" ? "WRITE" : "read"} · ${T.node}`), k.setColor(T.op === "write" ? "#ffffff" : Ke[e.nodes[$].kind] ?? "#22d3ee")), k.setOpacity(Math.min(1, (1700 - A) / 400))), w.current[j++] = $;
151
+ }
152
+ for (; j < Ce; j++) {
153
+ w.current[j] = -1;
154
+ const z = m.current[j];
155
+ z && (z.visible = !1);
156
+ const T = f.current[j];
157
+ T == null || T.setOpacity(0);
158
+ }
159
+ c.instanceMatrix.needsUpdate = !0, i.instanceMatrix.needsUpdate = !0, c.instanceColor && (c.instanceColor.needsUpdate = !0), i.instanceColor && (i.instanceColor.needsUpdate = !0), M.count = R, M.instanceMatrix.needsUpdate = !0, M.instanceColor && (M.instanceColor.needsUpdate = !0);
160
+ });
161
+ const D = te * We, o = E * Ne, a = Fe + D / 2 - We / 2, l = Ue + o / 2 - Ne / 2, d = N(() => new p.EdgesGeometry(new p.BoxGeometry(D + 1.2, 0.12, o + 1.2)), [D, o]);
162
+ return /* @__PURE__ */ P("group", { children: [
163
+ /* @__PURE__ */ P("mesh", { position: [a, 0.03, l], children: [
164
+ /* @__PURE__ */ n("boxGeometry", { args: [D + 1.2, 0.06, o + 1.2] }),
165
+ /* @__PURE__ */ n("meshStandardMaterial", { color: "#060a16", metalness: 0.6, roughness: 0.5 })
166
+ ] }),
167
+ /* @__PURE__ */ n("lineSegments", { geometry: d, position: [a, 0.06, l], children: /* @__PURE__ */ n("lineBasicMaterial", { color: H("#a5f3fc").clone().multiplyScalar(1.3), toneMapped: !1, transparent: !0, opacity: 0.8 }) }),
168
+ /* @__PURE__ */ P("mesh", { position: [fe, 0.02, l], children: [
169
+ /* @__PURE__ */ n("boxGeometry", { args: [0.12, 0.03, o + 1.2] }),
170
+ /* @__PURE__ */ n("meshBasicMaterial", { color: H("#22d3ee").clone().multiplyScalar(1.1), toneMapped: !1 })
171
+ ] }),
172
+ /* @__PURE__ */ n("lineSegments", { geometry: U, frustumCulled: !1, children: /* @__PURE__ */ n("lineBasicMaterial", { vertexColors: !0, toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 }) }),
173
+ /* @__PURE__ */ P("instancedMesh", { ref: t, args: [void 0, void 0, g], frustumCulled: !1, children: [
174
+ /* @__PURE__ */ n("boxGeometry", {}),
175
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1 })
176
+ ] }),
177
+ /* @__PURE__ */ P("instancedMesh", { ref: r, args: [void 0, void 0, g], frustumCulled: !1, children: [
178
+ /* @__PURE__ */ n("boxGeometry", { args: [0.1, 0.05, 0.1] }),
179
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1 })
180
+ ] }),
181
+ /* @__PURE__ */ P("instancedMesh", { ref: s, args: [void 0, void 0, Ze], frustumCulled: !1, children: [
182
+ /* @__PURE__ */ n("ringGeometry", { args: [0.92, 1, 64] }),
183
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, side: p.DoubleSide })
184
+ ] }),
185
+ Array.from({ length: Ce }, (c, i) => /* @__PURE__ */ n("group", { ref: (M) => void (m.current[i] = M), visible: !1, children: /* @__PURE__ */ n(ve, { ref: (M) => void (f.current[i] = M), text: "", size: 0.24, opacity: 0, fadeMs: 120, pxRange: [8, 12] }) }, i)),
186
+ /* @__PURE__ */ n(Bt, { position: [a, 0.4, Ue + o + 0.7], suffix: " · memory bank", color: "#22d3ee", letterSpacing: 0.06, size: 0.4, pxRange: [10, 15] })
187
+ ] });
188
+ }
189
+ const Qt = (
190
+ /* glsl */
191
+ `
192
+ varying vec2 vP;
193
+ void main() {
194
+ vec4 w = modelMatrix * vec4(position, 1.0);
195
+ vP = w.xz;
196
+ gl_Position = projectionMatrix * viewMatrix * w;
197
+ }`
198
+ ), Yt = (
199
+ /* glsl */
200
+ `
201
+ varying vec2 vP;
202
+ uniform vec2 uCenter;
203
+ float gridLine(vec2 p, float s, float w) {
204
+ vec2 q = p / s;
205
+ vec2 g = abs(fract(q - 0.5) - 0.5) / (fwidth(q) * w);
206
+ return 1.0 - min(min(g.x, g.y), 1.0);
207
+ }
208
+ void main() {
209
+ float minor = gridLine(vP, 1.0, 1.0);
210
+ float major = gridLine(vP, 5.0, 1.4);
211
+ float d = length(vP - uCenter);
212
+ float fade = exp(-d * 0.028);
213
+ vec3 base = vec3(0.004, 0.008, 0.02);
214
+ vec3 cy = vec3(0.05, 0.55, 0.75);
215
+ vec3 mg = vec3(0.55, 0.12, 0.65);
216
+ float side = smoothstep(-30.0, 40.0, vP.x);
217
+ vec3 lineC = mix(cy, mg, side * 0.6);
218
+ vec3 col = base + lineC * (minor * 0.07 + major * 0.32) * fade;
219
+ gl_FragColor = vec4(col, 1.0);
220
+ }`
221
+ );
222
+ function Jt(e) {
223
+ return () => {
224
+ e |= 0, e = e + 1831565813 | 0;
225
+ let t = Math.imul(e ^ e >>> 15, 1 | e);
226
+ return t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t, ((t ^ t >>> 14) >>> 0) / 4294967296;
227
+ };
228
+ }
229
+ const Qe = [
230
+ [1, 0],
231
+ [0, 1],
232
+ [-1, 0],
233
+ [0, -1],
234
+ [Math.SQRT1_2, Math.SQRT1_2],
235
+ [-Math.SQRT1_2, Math.SQRT1_2]
236
+ ], ge = (() => {
237
+ const e = Jt(42), t = [];
238
+ for (let r = 0; r < 170; r++) {
239
+ let s = Math.round((-46 + e() * 96) * 2) / 2, m = Math.round((-50 + e() * 70) * 2) / 2;
240
+ const f = [s, m];
241
+ let w = Math.floor(e() * 4);
242
+ const g = 2 + Math.floor(e() * 3);
243
+ for (let E = 0; E < g; E++) {
244
+ const x = 1.5 + e() * 6;
245
+ s += Qe[w][0] * x, m += Qe[w][1] * x, f.push(s, m), w = e() < 0.5 ? (w + 1) % 4 : e() < 0.5 ? 4 + Math.floor(e() * 2) : w;
246
+ }
247
+ t.push({ pts: f, magenta: e() < 0.35 });
248
+ }
249
+ return t;
250
+ })();
251
+ function en() {
252
+ const e = I(null), t = I(null), r = N(() => ge.reduce((s, m) => s + m.pts.length / 2 - 1, 0), []);
253
+ return ot(() => {
254
+ const s = e.current, m = t.current, f = new p.Object3D(), w = new p.Color();
255
+ let g = 0, E = 0;
256
+ for (const x of ge) {
257
+ w.set(x.magenta ? "#d946ef" : "#22d3ee").multiplyScalar(x.magenta ? 0.16 : 0.2);
258
+ for (let S = 0; S + 3 < x.pts.length; S += 2) {
259
+ const [h, y, v, u] = [x.pts[S], x.pts[S + 1], x.pts[S + 2], x.pts[S + 3]];
260
+ f.position.set((h + v) / 2, 5e-3, (y + u) / 2), f.rotation.set(0, -Math.atan2(u - y, v - h), 0), f.scale.set(Math.hypot(v - h, u - y) + 0.06, 0.01, 0.07), f.updateMatrix(), s.setMatrixAt(g, f.matrix), s.setColorAt(g++, w);
261
+ }
262
+ for (const S of [0, x.pts.length - 2])
263
+ f.position.set(x.pts[S], 0.01, x.pts[S + 1]), f.rotation.set(-Math.PI / 2, 0, 0), f.scale.set(1, 1, 1), f.updateMatrix(), m.setMatrixAt(E, f.matrix), m.setColorAt(E++, w.clone().multiplyScalar(2.2));
264
+ }
265
+ s.instanceMatrix.needsUpdate = !0, m.instanceMatrix.needsUpdate = !0, s.instanceColor && (s.instanceColor.needsUpdate = !0), m.instanceColor && (m.instanceColor.needsUpdate = !0);
266
+ }, []), /* @__PURE__ */ P(Ie, { children: [
267
+ /* @__PURE__ */ P("instancedMesh", { ref: e, args: [void 0, void 0, r], frustumCulled: !1, children: [
268
+ /* @__PURE__ */ n("boxGeometry", {}),
269
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 })
270
+ ] }),
271
+ /* @__PURE__ */ P("instancedMesh", { ref: t, args: [void 0, void 0, ge.length * 2], frustumCulled: !1, children: [
272
+ /* @__PURE__ */ n("ringGeometry", { args: [0.08, 0.17, 12] }),
273
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, side: p.DoubleSide })
274
+ ] })
275
+ ] });
276
+ }
277
+ function tn() {
278
+ const e = N(() => ({ uCenter: { value: new p.Vector2(2, -8) } }), []);
279
+ return /* @__PURE__ */ P("group", { children: [
280
+ /* @__PURE__ */ P("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [2, 0, -10], children: [
281
+ /* @__PURE__ */ n("planeGeometry", { args: [220, 220] }),
282
+ /* @__PURE__ */ n("shaderMaterial", { vertexShader: Qt, fragmentShader: Yt, uniforms: e, toneMapped: !1 })
283
+ ] }),
284
+ /* @__PURE__ */ n(en, {})
285
+ ] });
286
+ }
287
+ const nn = new Ut(1.5, 0.34, 1.5, 3, 0.07), on = new p.BoxGeometry(0.24, 0.05, 0.09), sn = new p.BoxGeometry(1, 1, 1), Ye = 16, Je = 36, rn = new p.Color("#fbbf24"), et = new p.Color(1, 1, 1), _e = new p.Color("#ef4444"), lt = [];
288
+ for (let e = 0; e < 4; e++)
289
+ for (let t = 0; t < 4; t++) {
290
+ const r = -0.48 + t * 0.32, s = 0.86, m = e === 0 ? [r, 0, s] : e === 1 ? [s, 0, -r] : e === 2 ? [-r, 0, -s] : [-s, 0, r];
291
+ lt.push(m);
292
+ }
293
+ const Ge = [], Pe = [];
294
+ for (let e = 0; e < 3; e++)
295
+ for (let t = 0; t < 2; t++)
296
+ for (let r = 0; r < 3; r++)
297
+ for (let s = 0; s < 2; s++) {
298
+ const m = -0.5 + e * 0.5 + (s ? 0.18 : -0.05), f = -0.5 + r * 0.5 + (s ? -0.12 : 0.08);
299
+ Ge.push(m, 0.08 + t * 0.18 + s * 0.1, f), Pe.push(m * (1.2 + (e * 7 + r * 3 + s) % 5 * 0.35), 1.8 + (e + t * 3 + r * 5 + s * 2) % 6 * 0.55, f * (1.2 + (r * 5 + e + s) % 4 * 0.4));
300
+ }
301
+ function an(e) {
302
+ for (const t of O.mcpPending.values()) if (t.instance === e) return !0;
303
+ return !1;
304
+ }
305
+ function cn({ inst: e, selected: t, onSelect: r }) {
306
+ const s = I(null), m = I(null), f = I(null), w = I(null), g = I(null), E = I(null), x = I(null), S = I(null), h = I(null), y = I(null), v = N(() => H(ue[e.type]), [e.type]), u = N(
307
+ () => ({
308
+ body: new p.MeshStandardMaterial({ color: "#0a0f1d", metalness: 0.75, roughness: 0.3, emissive: v, emissiveIntensity: 0.05 }),
309
+ die: new p.MeshBasicMaterial({ map: Ht(), transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
310
+ coreOuter: new p.MeshBasicMaterial({ wireframe: !0, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
311
+ coreInner: new p.MeshBasicMaterial({ toneMapped: !1 }),
312
+ column: new p.MeshBasicMaterial({ transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
313
+ glow: new p.MeshBasicMaterial({ map: $e(), transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
314
+ flash: new p.MeshBasicMaterial({ map: $e(), transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
315
+ ring: new p.MeshBasicMaterial({ transparent: !0, blending: p.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: p.DoubleSide }),
316
+ vox: new p.MeshBasicMaterial({ toneMapped: !1 }),
317
+ pins: new p.MeshBasicMaterial({ toneMapped: !1 })
318
+ }),
319
+ [v]
320
+ ), b = N(() => ({ pos: new p.Vector3(), start: new p.Vector3(), home: new p.Vector3(), init: !1, emerge: !1, spin: 0, spin2: 0 }), []), C = N(() => new p.Object3D(), []), U = N(() => new p.Color(), []), D = Re(e) ? 1 : 1.45;
321
+ return ot(() => {
322
+ const o = w.current;
323
+ o && (lt.forEach((a, l) => {
324
+ C.position.set(a[0], a[1], a[2]), C.rotation.set(0, l < 4 || l >= 8 && l < 12 ? Math.PI / 2 : 0, 0), C.scale.setScalar(1), C.updateMatrix(), o.setMatrixAt(l, C.matrix), o.setColorAt(l, U.setScalar(0));
325
+ }), o.instanceMatrix.needsUpdate = !0);
326
+ }, [C, U]), St(() => (Y.set(e.id, b.pos), () => {
327
+ Y.get(e.id) === b.pos && Y.delete(e.id);
328
+ }), [e.id, b.pos]), ae(({ clock: o }, a) => {
329
+ var Xe;
330
+ const l = performance.now(), d = e, c = o.elapsedTime;
331
+ if (Kt(d, b.home), !b.init) {
332
+ b.init = !0;
333
+ const W = d.parent ? Y.get(d.parent) : void 0;
334
+ b.emerge = !!W, b.start.copy(W ?? b.home), b.pos.copy(b.start);
335
+ }
336
+ const i = l - d.bornAt, M = b.emerge ? 620 : 480;
337
+ let B = 0, R = 1;
338
+ if (i < M && !q) {
339
+ const W = X(i / M);
340
+ if (b.emerge) {
341
+ const V = re(W);
342
+ b.pos.lerpVectors(b.start, b.home, V), B = 2.4 * Math.sin(Math.PI * W), R = 0.2 + 0.8 * V;
343
+ } else
344
+ b.pos.copy(b.home), B = 9 * (1 - W * W);
345
+ } else
346
+ b.pos.lerp(b.home, 1 - Math.exp(-a * 5));
347
+ const G = i - M, _ = d.exitAt > 0, j = _ ? l - d.exitAt : -1, z = d.status === "failed", T = 2500 / Et(d), A = j * T, $ = A > 600 ? Math.pow(X((A - 600) / 1900), 2) * 3.8 : 0, L = A > 950 ? X((A - 950) / 1300) : 0, K = Oe(d, l), k = Math.min(1.3, Pt(d, l)), F = d.status === "thinking" || d.status === "spawning", Z = !_ && an(d.id), ie = X(_ ? 1 - A / 700 : G / 300);
348
+ s.current && (s.current.position.set(b.pos.x, B + $, b.pos.z), s.current.scale.setScalar(D * R * Ve()), !q && _ && (s.current.rotation.y += a * L * 4)), m.current && m.current.scale.setScalar(L > 0 ? Math.max(1e-3, 1 - L * 4) : 1);
349
+ const ne = 0.5 + 0.5 * Math.sin(c * (Z ? 2.4 : 1.3));
350
+ let J = F ? 1.1 + k * 1.6 + 0.25 * Math.sin(c * 9) : 0.28 + ne * 0.22 + k;
351
+ Z && (J = 0.5 + ne * 0.9), J *= ie, u.body.emissiveIntensity = 0.04 + J * 0.12;
352
+ const ce = Z ? U.copy(v).lerp(rn, 0.55 * ne) : U.copy(v);
353
+ if (u.die.color.copy(ce).multiplyScalar(0.25 + J * 1.4), w.current) {
354
+ for (let W = 0; W < Ye; W++) {
355
+ const V = (q || G > W * 40) && !(_ && A > W * 38), le = F && !q ? Math.max(0, Math.sin(c * 9 - W * 0.7)) * (0.6 + k) : 0, ht = V ? 0.55 + J * 0.9 + le * 1.4 + k * 1.2 : 0.03;
356
+ w.current.setColorAt(W, U.copy(v).multiplyScalar(ht));
357
+ }
358
+ w.current.instanceColor && (w.current.instanceColor.needsUpdate = !0);
359
+ }
360
+ const ft = q ? 0.4 : F ? 3.6 + k * 5 : Z ? 0.9 : 0.45;
361
+ if (b.spin += a * ft * (_ ? ie : 1), f.current) {
362
+ const W = X(G / 280) * (L > 0 ? 1 - L : 1);
363
+ f.current.visible = W > 0.01, f.current.position.y = 1.15 + (q ? 0 : Math.sin(c * 2 + d.index) * 0.08), f.current.rotation.set(b.spin * 0.6, b.spin, 0), f.current.children[1].rotation.set(-b.spin * 1.3, 0, b.spin * 0.9), f.current.scale.setScalar(W * (F ? 1 + k * 0.35 : 0.82 + ne * 0.08)), u.coreOuter.color.copy(ce).multiplyScalar(0.5 + J * 1.1), u.coreInner.color.copy(ce).multiplyScalar(0.8 + J * 1.1 + k * 1.2);
364
+ }
365
+ if (h.current && (h.current.visible = !!((Xe = f.current) != null && Xe.visible), u.column.color.copy(ce).multiplyScalar(0.08 + J * 0.22)), E.current) {
366
+ E.current.position.y = (-B - $) / (D * R * Ve()) + 0.03;
367
+ const W = F && !q ? 1 + 0.08 * Math.sin(c * 17) + 0.05 * Math.sin(c * 29) : 1;
368
+ E.current.scale.setScalar((2.3 + k * 0.5) * W), u.glow.color.copy(ce).multiplyScalar((0.05 + Math.min(J, 2.4) * 0.12) * K);
369
+ }
370
+ let Q = 0, be = et;
371
+ if (G >= 0 && G < 520 && (Q = 1 - G / 520), _ && A < 400 && (Q = Math.max(Q, (1 - A / 400) * 0.6), be = z ? _e : et), L > 0 && L < 0.4 && (Q = Math.max(Q, 1 - L / 0.4), be = z ? _e : v), x.current && S.current && (x.current.visible = S.current.visible = Q > 0.01, Q > 0.01)) {
372
+ const W = 1 - Q;
373
+ u.flash.color.copy(be).multiplyScalar(1.1 * Q * Q), x.current.scale.setScalar(1.2 + W * 2.2), S.current.scale.setScalar(0.9 + W * 2), u.ring.color.copy(be).multiplyScalar(1.5 * Q);
374
+ }
375
+ if (g.current && (g.current.visible = L > 0, L > 0)) {
376
+ const W = 0.16 * (1 - L * 0.85);
377
+ for (let V = 0; V < Je; V++) {
378
+ const le = q ? 0.2 : 1;
379
+ C.position.set(
380
+ Ge[V * 3] + Pe[V * 3] * L * 1.6 * le,
381
+ Ge[V * 3 + 1] + Pe[V * 3 + 1] * L * 1.4 * le,
382
+ Ge[V * 3 + 2] + Pe[V * 3 + 2] * L * 1.6 * le
383
+ ), C.rotation.set(L * V, L * 3, 0), C.scale.setScalar(W * (V % 3 === 0 ? 1.3 : 1)), C.updateMatrix(), g.current.setMatrixAt(V, C.matrix);
384
+ }
385
+ g.current.instanceMatrix.needsUpdate = !0, u.vox.color.copy(z ? _e : v).multiplyScalar(3.2 * (1 - L));
386
+ }
387
+ y.current && (y.current.visible = t, t && (y.current.rotation.z = c * 0.8, y.current.material.color.setScalar(1.6 + 0.6 * Math.sin(c * 5))));
388
+ }), /* @__PURE__ */ P("group", { ref: s, children: [
389
+ /* @__PURE__ */ n("mesh", { ref: E, rotation: [-Math.PI / 2, 0, 0], material: u.glow, children: /* @__PURE__ */ n("planeGeometry", { args: [1, 1] }) }),
390
+ /* @__PURE__ */ P("group", { ref: m, children: [
391
+ /* @__PURE__ */ n(
392
+ "mesh",
393
+ {
394
+ geometry: nn,
395
+ material: u.body,
396
+ position: [0, 0.2, 0],
397
+ onClick: (o) => (o.stopPropagation(), r(e.id)),
398
+ onPointerOver: () => document.body.style.cursor = "pointer",
399
+ onPointerOut: () => document.body.style.cursor = ""
400
+ }
401
+ ),
402
+ /* @__PURE__ */ n("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.375, 0], material: u.die, children: /* @__PURE__ */ n("planeGeometry", { args: [1.25, 1.25] }) }),
403
+ /* @__PURE__ */ n("instancedMesh", { ref: w, args: [on, u.pins, Ye], position: [0, 0.06, 0] })
404
+ ] }),
405
+ /* @__PURE__ */ n("mesh", { ref: h, position: [0, 0.78, 0], material: u.column, children: /* @__PURE__ */ n("cylinderGeometry", { args: [0.05, 0.22, 0.75, 12, 1, !0] }) }),
406
+ /* @__PURE__ */ P("group", { ref: f, position: [0, 1.15, 0], children: [
407
+ /* @__PURE__ */ n("mesh", { material: u.coreOuter, children: /* @__PURE__ */ n("octahedronGeometry", { args: [0.42, 0] }) }),
408
+ /* @__PURE__ */ n("mesh", { material: u.coreInner, children: /* @__PURE__ */ n("icosahedronGeometry", { args: [0.15, 0] }) })
409
+ ] }),
410
+ /* @__PURE__ */ n("mesh", { ref: x, rotation: [-Math.PI / 2, 0, 0], position: [0, 0.06, 0], material: u.flash, visible: !1, children: /* @__PURE__ */ n("planeGeometry", { args: [1, 1] }) }),
411
+ /* @__PURE__ */ n("mesh", { ref: S, rotation: [-Math.PI / 2, 0, 0], position: [0, 0.07, 0], material: u.ring, visible: !1, children: /* @__PURE__ */ n("ringGeometry", { args: [0.9, 1, 48] }) }),
412
+ /* @__PURE__ */ n("instancedMesh", { ref: g, args: [sn, u.vox, Je], visible: !1, frustumCulled: !1 }),
413
+ /* @__PURE__ */ P("mesh", { ref: y, rotation: [-Math.PI / 2, 0, 0], position: [0, 0.05, 0], visible: !1, children: [
414
+ /* @__PURE__ */ n("ringGeometry", { args: [1.25, 1.35, 4, 1, Math.PI / 4] }),
415
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, side: p.DoubleSide })
416
+ ] }),
417
+ t && /* @__PURE__ */ n(ve, { position: [0, 2, 0], text: e.name, color: ue[e.type], size: 0.32, pxRange: [9.5, 13.5] })
418
+ ] });
419
+ }
420
+ const ze = fe - Me, ln = { queued: "#64748b", running: "#fde68a", done: "#5eead4", failed: "#f87171" }, pn = new p.Color("#334155"), dn = new p.Color("#5eead4"), un = new p.Color("#ef4444"), pt = new p.BoxGeometry(1.5, 0.55, 1.25), fn = new p.EdgesGeometry(pt);
421
+ function dt(e, t) {
422
+ return e.endedAt ? X(1 - (t - e.endedAt - 1200) / (Rt - 1200)) : 1;
423
+ }
424
+ function hn({ run: e }) {
425
+ const t = I(null), r = I(null), s = N(() => new p.MeshBasicMaterial({ toneMapped: !1 }), []), m = I([]), f = I([]), w = I([]), g = I([]), E = I(null), x = I(""), S = N(() => H(e.color), [e.color]), h = I(null);
426
+ return ae(({ clock: y }) => {
427
+ const v = performance.now(), u = O.runs.get(e.id) ?? e;
428
+ h.current && (h.current.position.z += (ye(u.id, u.slot) - h.current.position.z) * 0.12);
429
+ const b = dt(u, v), C = y.elapsedTime;
430
+ if (t.current && (t.current.scale.x = Math.max(1e-3, it(X((v - u.startedAt) / 900)))), r.current && r.current.color.copy(S).multiplyScalar(0.32 * b), s.color.copy(S).multiplyScalar(2.4 * b), de.forEach((U, D) => {
431
+ const o = u.steps[U], a = m.current[D], l = f.current[D], d = w.current[D], c = g.current[D];
432
+ if (!a || !l || !d || !c) return;
433
+ const i = o === "running", M = i ? q ? 1 : 0.75 + 0.35 * Math.sin(C * 6) : 1, B = o === "queued" ? pn : o === "done" ? dn : o === "failed" ? un : S, R = o === "queued" ? 0.9 : o === "done" ? 1.1 : o === "failed" ? 2 : 3.2 * M;
434
+ d.color.copy(B).multiplyScalar(R * b), l.emissive.copy(B), l.emissiveIntensity = (i ? 0.9 * M : o === "done" ? 0.12 : 0.04) * b;
435
+ const G = i ? 2.2 : o === "done" ? 1 : 0.7;
436
+ a.scale.y += (G - a.scale.y) * 0.12, a.position.y = 0.55 * a.scale.y / 2, c.visible = i && b > 0.05, c.visible && (c.material.color.copy(S).multiplyScalar(0.55 * M * b), c.scale.y = 1 + 0.1 * Math.sin(C * 3));
437
+ }), E.current) {
438
+ const U = de.map((D) => `${D}:${u.steps[D]}`).join(" ");
439
+ U !== x.current && (x.current = U, E.current.setText(
440
+ `${u.hasSteps ? "hatchet · " : ""}${u.topic}`,
441
+ de.map((D, o) => ({ text: `${o ? " " : ""}${D}${u.steps[D] === "done" ? " ·" : u.steps[D] === "failed" ? " ×" : ""}`, color: ln[u.steps[D]] }))
442
+ ));
443
+ }
444
+ }), /* @__PURE__ */ P("group", { ref: h, position: [0, 0, ye(e.id, e.slot)], children: [
445
+ /* @__PURE__ */ P("group", { ref: t, position: [Me, 0, 0], children: [
446
+ /* @__PURE__ */ P("mesh", { position: [ze / 2, 0.015, 0], children: [
447
+ /* @__PURE__ */ n("boxGeometry", { args: [ze, 0.02, 0.95] }),
448
+ /* @__PURE__ */ n("meshBasicMaterial", { ref: r, toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 })
449
+ ] }),
450
+ [-0.5, 0.5].map((y) => /* @__PURE__ */ n("mesh", { position: [ze / 2, 0.03, y], material: s, children: /* @__PURE__ */ n("boxGeometry", { args: [ze, 0.04, 0.07] }) }, y)),
451
+ /* @__PURE__ */ P("mesh", { position: [0, 0.04, 0], children: [
452
+ /* @__PURE__ */ n("boxGeometry", { args: [0.5, 0.08, 1.4] }),
453
+ /* @__PURE__ */ n("meshBasicMaterial", { color: S.clone().multiplyScalar(1.6), toneMapped: !1 })
454
+ ] })
455
+ ] }),
456
+ de.map((y, v) => /* @__PURE__ */ P("group", { position: [ee[y], 0, 0], children: [
457
+ /* @__PURE__ */ P("group", { ref: (u) => void (m.current[v] = u), children: [
458
+ /* @__PURE__ */ n("mesh", { geometry: pt, children: /* @__PURE__ */ n("meshStandardMaterial", { ref: (u) => void (f.current[v] = u), color: "#070b16", metalness: 0.75, roughness: 0.3, toneMapped: !1 }) }),
459
+ /* @__PURE__ */ n("lineSegments", { geometry: fn, children: /* @__PURE__ */ n("lineBasicMaterial", { ref: (u) => void (w.current[v] = u), toneMapped: !1 }) })
460
+ ] }),
461
+ /* @__PURE__ */ P("mesh", { ref: (u) => void (g.current[v] = u), position: [0, 3.2, 0], visible: !1, children: [
462
+ /* @__PURE__ */ n("boxGeometry", { args: [0.12, 5, 0.12] }),
463
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 })
464
+ ] })
465
+ ] }, y)),
466
+ /* @__PURE__ */ n(
467
+ ve,
468
+ {
469
+ ref: E,
470
+ position: [Me + 0.2, 0.3, 0],
471
+ anchorY: "bottom",
472
+ offset: [0, 0.15],
473
+ plate: "box",
474
+ text: `${e.hasSteps ? "hatchet · " : ""}${e.topic}`,
475
+ secondary: "",
476
+ color: e.color,
477
+ size: 0.36,
478
+ maxWidth: 11,
479
+ pxRange: [10, 14]
480
+ }
481
+ )
482
+ ] });
483
+ }
484
+ function mn({ runs: e }) {
485
+ return /* @__PURE__ */ n("group", { children: e.map((t) => /* @__PURE__ */ n(hn, { run: t }, t.id)) });
486
+ }
487
+ function gn() {
488
+ return /* @__PURE__ */ n("group", { children: de.map((e) => /* @__PURE__ */ n(ve, { position: [ee[e], 1.2, rt(3) - 2.6], text: `gate · ${e}`, color: "#5eead4", uppercase: !0, letterSpacing: 0.12, size: 0.3, pxRange: [8.5, 12.5] }, e)) });
489
+ }
490
+ const Te = 1800, Le = 360, tt = new p.Color("#fbbf24"), Mn = new p.Color("#ef4444"), se = new p.Color(1, 1, 1);
491
+ function yn({ galaxy: e }) {
492
+ const t = I(null), r = I(null), s = N(
493
+ () => ({
494
+ o: new p.Object3D(),
495
+ c: new p.Color(),
496
+ c2: new p.Color(),
497
+ path: new Vt(),
498
+ pt: { x: 0, z: 0 },
499
+ pt2: { x: 0, z: 0 },
500
+ nw: 0,
501
+ nh: 0
502
+ }),
503
+ []
504
+ );
505
+ ae(() => {
506
+ const f = t.current, w = r.current;
507
+ if (!f || !w) return;
508
+ const g = performance.now(), { o: E, c: x, c2: S, path: h, pt: y, pt2: v } = s;
509
+ s.nw = 0, s.nh = 0;
510
+ const u = (o, a, l, d, c, i, M, B, R) => {
511
+ if (s.nw >= Te || R < 3e-3) return;
512
+ const G = Math.hypot(l - o, d - a);
513
+ G < 0.01 || (E.position.set((o + l) / 2, c + M / 2, (a + d) / 2), E.rotation.set(0, -Math.atan2(d - a, l - o), 0), E.scale.set(G + i * 0.5, M, i), E.updateMatrix(), f.setMatrixAt(s.nw, E.matrix), f.setColorAt(s.nw++, S.copy(B).multiplyScalar(R)));
514
+ }, b = (o, a, l, d, c, i, M, B) => {
515
+ s.nh >= Le || B < 3e-3 || (E.position.set(o, a, l), E.rotation.set(0, -d, 0), E.scale.set(c, i, i), E.updateMatrix(), w.setMatrixAt(s.nh, E.matrix), w.setColorAt(s.nh++, S.copy(M).multiplyScalar(B)));
516
+ }, C = (o, a, l, d, c, i, M) => {
517
+ const B = h.len, R = X(Math.min(o, a)) * B, G = X(Math.max(o, a)) * B;
518
+ if (!(G - R < 0.01))
519
+ for (let _ = 0; _ < h.n - 1; _++) {
520
+ const j = h.l[_], z = h.l[_ + 1], T = Math.max(R, j), A = Math.min(G, z);
521
+ if (A <= T) continue;
522
+ const $ = z - j || 1, L = (T - j) / $, K = (A - j) / $, k = h.x[_ + 1] - h.x[_], F = h.z[_ + 1] - h.z[_];
523
+ u(h.x[_] + k * L, h.z[_] + F * L, h.x[_] + k * K, h.z[_] + F * K, l, d, c, i, M);
524
+ }
525
+ }, U = (o, a, l, d, c = 0.4, i = !1) => {
526
+ const M = h.at(o, y) + (i ? Math.PI : 0);
527
+ i ? (C(1, o + c, a, 0.05, 0.05, l, d * 0.35), C(o + c, o, a, 0.07, 0.2, l, d * 1.2)) : (C(0, o - c, a, 0.05, 0.05, l, d * 0.35), C(o - c, o, a, 0.07, 0.2, l, d * 1.2)), b(y.x, a + 0.12, y.z, M, 0.42, 0.17, se, d * 2.2), b(y.x, a + 0.12, y.z, M, 0.7, 0.3, l, d * 1.2);
528
+ };
529
+ for (const o of O.runs.values()) {
530
+ if (!st(o.id)) continue;
531
+ const a = ye(o.id, o.slot), l = dt(o, g), d = H(o.color), c = g - o.startedAt;
532
+ if (c < 1300) {
533
+ const M = re(X(c / 1300));
534
+ h.begin().pt(Me, a).pt(ee.plan, a), U(M, 0.06, d, 2.2 * (c > 1100 ? (1300 - c) / 200 : 1), 0.6);
535
+ }
536
+ const i = g - o.handoffAt;
537
+ if (o.handoffAt && i < 1300) {
538
+ const M = re(X(i / 1e3)), B = i > 1e3 ? 1 - (i - 1e3) / 300 : 1;
539
+ h.begin().pt(ee[o.handoffFrom], a).pt(ee[o.handoffTo], a), U(M, 0.06, se, 1.4 * B, 0.5), U(M, 0.06, d, 2.4 * B, 0.5);
540
+ }
541
+ if (o.status === "started" && !q) {
542
+ h.begin().pt(Me, a).pt(fe, a);
543
+ for (let M = 0; M < 3; M++) {
544
+ const B = ((g / 5200 + M / 3) % 1 + 1) % 1;
545
+ h.at(B, y), b(y.x, 0.08, y.z + (M - 1) * 0.28, 0, 0.5, 0.06, d, 1.3 * l);
546
+ }
547
+ }
548
+ }
549
+ for (const o of O.instances.values()) {
550
+ const a = Y.get(o.id);
551
+ if (!a) continue;
552
+ const l = Oe(o, g), d = H(ue[o.type]), c = O.runs.get(o.run);
553
+ if (!Re(o) && c) {
554
+ const G = ye(c.id, c.slot);
555
+ u(a.x, a.z - 0.75, a.x, G + 0.55, 0.02, 0.09, 0.03, H(c.color), 1.4 * l);
556
+ }
557
+ if (!o.parent) continue;
558
+ const i = Y.get(o.parent);
559
+ if (!i) continue;
560
+ const M = O.instances.get(o.parent), B = l * (M ? Math.max(0.35, Oe(M, g)) : 1), R = X((g - o.bornAt) / 520);
561
+ if (Re(o)) {
562
+ const G = i.x + 0.95;
563
+ if (h.begin().pt(i.x + 0.6, i.z).pt(G, i.z).pt(a.x - 0.55, a.z), C(0, R, 0.03, 0.12, 0.05, d, 2.4 * B), C(0, R, 0.03, 0.4, 0.01, d, 0.35 * B), R < 1) {
564
+ const _ = h.at(R, y);
565
+ b(y.x, 0.15, y.z, _, 0.4, 0.16, se, 3);
566
+ }
567
+ } else
568
+ h.begin().pt(i.x, i.z + 0.85).pt(i.x, i.z + 1.2).pt(a.x, a.z + 1.2).pt(a.x, a.z + 0.85), C(0, R, 0.02, 0.06, 0.03, d, 0.9 * B);
569
+ }
570
+ for (const o of O.comets) {
571
+ const a = Y.get(o.from), l = Y.get(o.to);
572
+ if (!a || !l) continue;
573
+ const d = (g - o.start) / o.dur, c = O.instances.get(o.from), i = H(c ? ue[c.type] : "#ffffff");
574
+ h.begin().pt(a.x, a.z).pt(l.x, a.z).pt(l.x, l.z), d < 1 ? U(re(X(d)), 0.3, i, 2, 0.45) : C(0, 1, 0.3, 0.05, 0.05, i, 0.8 * (1 - (d - 1) * 4));
575
+ }
576
+ for (const o of O.flares) {
577
+ const a = g - o.start, l = Y.get(o.instance), d = je(e, o.node);
578
+ at(d, v);
579
+ const c = o.op === "write", i = O.instances.get(o.instance), M = c ? se : H(i ? ue[i.type] : "#22d3ee");
580
+ if (l)
581
+ if (h.begin().pt(l.x + 0.6, l.z).pt(fe, l.z).pt(fe, v.z).pt(v.x - 0.4, v.z), a < me) U(re(a / me), 0.04, M, c ? 2.4 : 1.6, 0.35);
582
+ else {
583
+ const B = Math.exp(-((a - me) / 1e3) * 2.4);
584
+ C(0, 1, 0.04, 0.05, 0.04, M, (c ? 1 : 0.7) * B);
585
+ }
586
+ }
587
+ const D = (o, a) => {
588
+ const l = Y.get(o), d = O.mcpServers.get(a);
589
+ if (!l || !d) return null;
590
+ const c = Ee(d.slot);
591
+ return h.begin().pt(l.x - 0.6, l.z).pt(xe, l.z).pt(xe, c).pt(he + 0.8, c), d;
592
+ };
593
+ for (const o of O.mcpPending.values()) {
594
+ const a = D(o.instance, o.server);
595
+ if (!a) continue;
596
+ const l = It(o, g);
597
+ x.copy(H(a.color)), l < 1.2 ? x.lerp(tt, l / 1.2) : x.copy(tt).lerp(Mn, X((l - 1.2) / 1));
598
+ const d = 0.55 + Math.min(l, 3) * 0.45, c = l > 2.2 && !q ? 0.75 + 0.25 * Math.sin(g / 45) : 1;
599
+ C(0, 1, 0.16, 0.11, 0.11, x, 0.75 * d * c), C(0, 1, 0.12, 0.5, 0.02, x, 0.22 * d);
600
+ for (let i = 0; i < 6; i++) {
601
+ const M = q ? i / 6 : (g / 900 * (1 + l * 0.4) + i / 6) % 1, B = h.at(M, y);
602
+ b(y.x, 0.28, y.z, B, 0.42, 0.16, x, 2 * d);
603
+ }
604
+ }
605
+ for (const o of O.mcpResolved) {
606
+ const a = D(o.instance, o.server);
607
+ if (!a) continue;
608
+ const l = X((g - o.resolvedAt) / 700), d = 1 - it(l), c = H(a.color);
609
+ C(0, 1, 0.16, 0.06, 0.06, c, 0.6 * (1 - l) * (1 - l)), C(d, d + 0.22, 0.16, 0.1, 0.22, se, 2.2 * (1 - l * 0.5));
610
+ const i = h.at(d, y) + Math.PI;
611
+ b(y.x, 0.3, y.z, i, 0.6, 0.26, se, 3.2);
612
+ }
613
+ for (const o of O.mcpCalls) {
614
+ const a = D(o.instance, o.server);
615
+ if (!a) continue;
616
+ const l = (g - o.start) / o.dur;
617
+ if (l >= 1) continue;
618
+ const d = H(a.color), c = re(X(l));
619
+ o.phase === "call" ? U(c, 0.36, d, 1.8, 0.35) : U(1 - c, 0.36, d, 1.8, 0.35, !0);
620
+ }
621
+ if (!q)
622
+ for (let o = 0; o < ge.length; o += 7) {
623
+ const a = ge[o];
624
+ h.begin();
625
+ for (let i = 0; i < a.pts.length; i += 2) h.pt(a.pts[i], a.pts[i + 1]);
626
+ const l = (g / 1e3 * (0.12 + o % 5 * 0.03) + o * 0.137) % 1, d = h.at(l, y), c = H(a.magenta ? "#e879f9" : "#22d3ee");
627
+ C(l - 0.12, l, 0.01, 0.06, 0.02, c, 0.6), b(y.x, 0.05, y.z, d, 0.3, 0.07, c, 1.6);
628
+ }
629
+ f.count = s.nw, w.count = s.nh, f.instanceMatrix.needsUpdate = !0, w.instanceMatrix.needsUpdate = !0, f.instanceColor && (f.instanceColor.needsUpdate = !0), w.instanceColor && (w.instanceColor.needsUpdate = !0);
630
+ });
631
+ const m = (f, w) => {
632
+ f && !f.instanceColor && (f.instanceColor = new p.InstancedBufferAttribute(new Float32Array(w * 3), 3), f.count = 0);
633
+ };
634
+ return /* @__PURE__ */ P(Ie, { children: [
635
+ /* @__PURE__ */ P(
636
+ "instancedMesh",
637
+ {
638
+ ref: (f) => {
639
+ t.current = f, m(f, Te);
640
+ },
641
+ args: [void 0, void 0, Te],
642
+ frustumCulled: !1,
643
+ children: [
644
+ /* @__PURE__ */ n("boxGeometry", {}),
645
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 })
646
+ ]
647
+ }
648
+ ),
649
+ /* @__PURE__ */ P(
650
+ "instancedMesh",
651
+ {
652
+ ref: (f) => {
653
+ r.current = f, m(f, Le);
654
+ },
655
+ args: [void 0, void 0, Le],
656
+ frustumCulled: !1,
657
+ children: [
658
+ /* @__PURE__ */ n("boxGeometry", {}),
659
+ /* @__PURE__ */ n("meshBasicMaterial", { toneMapped: !1 })
660
+ ]
661
+ }
662
+ )
663
+ ] });
664
+ }
665
+ const ut = new p.BoxGeometry(1.5, 0.7, 3.2), xn = new p.EdgesGeometry(ut);
666
+ function vn({ srv: e }) {
667
+ const t = I(null), r = I(null), s = I(null), m = N(() => new p.MeshBasicMaterial({ toneMapped: !1, wireframe: !0, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 }), []), f = N(() => new p.MeshBasicMaterial({ toneMapped: !1 }), []), w = I(null), g = N(() => H(e.color), [e.color]), E = I(0);
668
+ ae(({ clock: S }, h) => {
669
+ const y = performance.now(), v = O.mcpServers.get(e.name) ?? e, u = v.inflight > 0, b = Math.exp(-((y - v.activeAt) / 1e3) * 2.5), C = S.elapsedTime, D = (u ? 0.75 + 0.25 * Math.sin(C * 7) : 0.5 + 0.1 * Math.sin(C * 1.3)) + b * 2.5 + (u ? 1 : 0);
670
+ E.current += h * (q ? 0.3 : u ? 4.5 : 0.6), t.current && (t.current.rotation.y = E.current, t.current.children[0].rotation.x = E.current * 0.7, t.current.scale.setScalar(1 + b * 0.35), t.current.position.y = 1.7 + (q ? 0 : Math.sin(C * 1.6 + v.slot) * 0.08)), m.color.copy(g).multiplyScalar(0.9 + D * 0.9), f.color.copy(g).multiplyScalar(1.2 + D * 1.4), r.current && r.current.color.copy(g).multiplyScalar(0.5 + D * 1.3), s.current && s.current.color.copy(g).multiplyScalar(0.6 + D * 0.8), w.current && w.current.color.copy(g).multiplyScalar(0.15 + D * 0.35);
671
+ });
672
+ const x = Ee(e.slot);
673
+ return /* @__PURE__ */ P("group", { position: [he, 0, x], children: [
674
+ /* @__PURE__ */ n("mesh", { geometry: ut, position: [0, 0.35, 0], children: /* @__PURE__ */ n("meshStandardMaterial", { color: "#070b16", metalness: 0.8, roughness: 0.28 }) }),
675
+ /* @__PURE__ */ n("lineSegments", { geometry: xn, position: [0, 0.35, 0], children: /* @__PURE__ */ n("lineBasicMaterial", { ref: s, toneMapped: !1 }) }),
676
+ /* @__PURE__ */ P("mesh", { position: [0, 0.71, 0], children: [
677
+ /* @__PURE__ */ n("boxGeometry", { args: [0.3, 0.02, 2.8] }),
678
+ /* @__PURE__ */ n("meshBasicMaterial", { ref: r, toneMapped: !1 })
679
+ ] }),
680
+ Array.from({ length: 7 }, (S, h) => /* @__PURE__ */ P("mesh", { position: [0.95 + (xe - he - 1) / 2, 0.02, -1.2 + h * 0.4], children: [
681
+ /* @__PURE__ */ n("boxGeometry", { args: [xe - he - 1, 0.02, 0.06] }),
682
+ /* @__PURE__ */ n("meshBasicMaterial", { color: g.clone().multiplyScalar(0.55), toneMapped: !1 })
683
+ ] }, h)),
684
+ /* @__PURE__ */ P("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.02, 0], children: [
685
+ /* @__PURE__ */ n("planeGeometry", { args: [5, 6] }),
686
+ /* @__PURE__ */ n("meshBasicMaterial", { ref: w, map: $e(), toneMapped: !1, transparent: !0, blending: p.AdditiveBlending, depthWrite: !1 })
687
+ ] }),
688
+ /* @__PURE__ */ P("group", { ref: t, position: [0, 1.7, 0], children: [
689
+ /* @__PURE__ */ n("mesh", { material: m, children: /* @__PURE__ */ n("torusGeometry", { args: [0.55, 0.05, 6, 24] }) }),
690
+ /* @__PURE__ */ n("mesh", { material: m, rotation: [Math.PI / 2, 0, 0], children: /* @__PURE__ */ n("torusGeometry", { args: [0.42, 0.03, 6, 20] }) }),
691
+ /* @__PURE__ */ n("mesh", { material: f, children: /* @__PURE__ */ n("octahedronGeometry", { args: [0.2, 0] }) })
692
+ ] }),
693
+ /* @__PURE__ */ n(ve, { position: [-1.1, 0.6, 0], anchorX: "right", text: `mcp · ${e.name}`, color: e.color, size: 0.3, pxRange: [9, 13] })
694
+ ] });
695
+ }
696
+ function bn({ servers: e }) {
697
+ const t = Ee(4) - 2, r = Ee(0) + 2;
698
+ return /* @__PURE__ */ P("group", { children: [
699
+ /* @__PURE__ */ P("mesh", { position: [xe, 0.02, (t + r) / 2], children: [
700
+ /* @__PURE__ */ n("boxGeometry", { args: [0.12, 0.03, r - t] }),
701
+ /* @__PURE__ */ n("meshBasicMaterial", { color: H("#e879f9").clone().multiplyScalar(0.9), toneMapped: !1 })
702
+ ] }),
703
+ e.map((s) => /* @__PURE__ */ n(vn, { srv: s }, s.name))
704
+ ] });
705
+ }
706
+ const wn = -9.5, Sn = 4.1, An = 7.5;
707
+ function Cn(e, t, r) {
708
+ return t.set(wn + e * Sn, 2.2 + Math.sin(r * 0.6 + e) * 0.15, An + (e % 2 ? -3.2 : 1.2));
709
+ }
710
+ function zn() {
711
+ return /* @__PURE__ */ n(_t, { place: Cn, radius: 1.1, variant: "orb", glowGain: 0.85 });
712
+ }
713
+ function Bn({ selected: e, onSelect: t }) {
714
+ const [r, s] = Be([]), [m, f] = Be([]), [w, g] = Be([]), E = I({ i: /* @__PURE__ */ new Set(), r: /* @__PURE__ */ new Set(), s: 0, v: -1 });
715
+ return ae(() => {
716
+ Dt(), Ot();
717
+ const x = E.current, S = x.v !== De.version;
718
+ x.v = De.version;
719
+ let h = S || O.instances.size !== x.i.size;
720
+ if (!h)
721
+ for (const v of O.instances.keys()) x.i.has(v) || (h = !0);
722
+ h && (x.i = new Set(O.instances.keys()), s([...O.instances.values()].filter(kt)));
723
+ let y = S || O.runs.size !== x.r.size;
724
+ if (!y)
725
+ for (const v of O.runs.keys()) x.r.has(v) || (y = !0);
726
+ y && (x.r = new Set(O.runs.keys()), f([...O.runs.values()].filter((v) => st(v.id)))), O.mcpServers.size !== x.s && (x.s = O.mcpServers.size, g([...O.mcpServers.values()]));
727
+ }), /* @__PURE__ */ P(Ie, { children: [
728
+ /* @__PURE__ */ n(mn, { runs: m }),
729
+ /* @__PURE__ */ n(bn, { servers: w }),
730
+ r.map((x) => /* @__PURE__ */ n(cn, { inst: x, selected: e === x.id, onSelect: t }, x.id)),
731
+ /* @__PURE__ */ n(zn, {})
732
+ ] });
733
+ }
734
+ function Gn({ galaxy: e, selected: t, onSelect: r }) {
735
+ return /* @__PURE__ */ P(Ie, { children: [
736
+ /* @__PURE__ */ n("color", { attach: "background", args: ["#010309"] }),
737
+ /* @__PURE__ */ n("fog", { attach: "fog", args: ["#010309", 34, 92] }),
738
+ /* @__PURE__ */ n("ambientLight", { intensity: 0.35 }),
739
+ /* @__PURE__ */ n("hemisphereLight", { args: ["#67e8f9", "#1e0b2e", 0.6] }),
740
+ /* @__PURE__ */ n("directionalLight", { position: [-8, 14, 10], intensity: 1.4, color: "#c4b5fd" }),
741
+ /* @__PURE__ */ n("pointLight", { position: [18, 6, -8], intensity: 60, distance: 40, color: "#22d3ee" }),
742
+ /* @__PURE__ */ n("pointLight", { position: [-14, 5, 2], intensity: 50, distance: 36, color: "#e879f9" }),
743
+ /* @__PURE__ */ n(tn, {}),
744
+ /* @__PURE__ */ n(Zt, { galaxy: e }),
745
+ /* @__PURE__ */ n(gn, {}),
746
+ /* @__PURE__ */ n(Bn, { selected: t, onSelect: r }),
747
+ /* @__PURE__ */ n(yn, { galaxy: e }),
748
+ /* @__PURE__ */ n(
749
+ Mt,
750
+ {
751
+ makeDefault: !0,
752
+ target: [2.6, 0, -5.5],
753
+ enableDamping: !0,
754
+ dampingFactor: 0.06,
755
+ minDistance: 10,
756
+ maxDistance: 70,
757
+ minPolarAngle: 0.6,
758
+ maxPolarAngle: 1.42
759
+ }
760
+ ),
761
+ /* @__PURE__ */ P(xt, { multisampling: 0, children: [
762
+ /* @__PURE__ */ n(vt, { mipmapBlur: !0, intensity: 1.25, luminanceThreshold: 0.22, luminanceSmoothing: 0.25, radius: 0.72 }),
763
+ /* @__PURE__ */ n(bt, { eskil: !1, offset: 0.22, darkness: 0.9 }),
764
+ /* @__PURE__ */ n(wt, { opacity: 0.03 })
765
+ ] })
766
+ ] });
767
+ }
768
+ function kn() {
769
+ const e = Tt(), [t, r] = Be(null);
770
+ return /* @__PURE__ */ P("div", { className: "scene-root", children: [
771
+ /* @__PURE__ */ n(
772
+ yt,
773
+ {
774
+ camera: { position: [1.6, 19, 35], fov: 50, near: 0.1, far: 300 },
775
+ dpr: [1, 2],
776
+ gl: { antialias: !1, powerPreference: "high-performance" },
777
+ onPointerMissed: () => r(null),
778
+ children: /* @__PURE__ */ n(Gn, { galaxy: e, selected: t, onSelect: r })
779
+ }
780
+ ),
781
+ /* @__PURE__ */ n(Lt, { title: "circuit", subtitle: "Hatchet buses · agent chips · graph memory bank · MCP I/O ports", selected: t, onClose: () => r(null) })
782
+ ] });
783
+ }
784
+ export {
785
+ kn as default
786
+ };