agentglow 0.4.0 → 0.4.2

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,770 @@
1
+ var gt = Object.defineProperty;
2
+ var wt = (e, s, a) => s in e ? gt(e, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[s] = a;
3
+ var Z = (e, s, a) => wt(e, typeof s != "symbol" ? s + "" : s, a);
4
+ import { jsxs as se, Fragment as Ce, jsx as v } from "react/jsx-runtime";
5
+ import { EffectComposer as bt, Bloom as yt, Vignette as Mt } from "@react-three/postprocessing";
6
+ import { useMemo as V, useRef as U, useEffect as St, useState as xt } from "react";
7
+ import * as t from "three";
8
+ import { useFrame as Ae } from "@react-three/fiber";
9
+ import { T as mt, w as H, k as Ct, a as ge, d as st, h as Me, l as At, U as Vt, p as Pt, e as zt, f as Se, s as Et, L as nt, j as Gt, n as Bt, o as Ft, S as Ye, H as Rt, R as It, q as Lt, A as he, u as _t, V as Ot, E as Tt, t as Nt, v as Ut, g as Xt, b as jt, K as Kt, B as Yt, G as Ht, C as qt, x as Wt } from "./KitScene-D8qiflCw.js";
10
+ var dt;
11
+ const ee = typeof window < "u" && !!((dt = window.matchMedia) != null && dt.call(window, "(prefers-reduced-motion: reduce)").matches), at = new t.Color("#3db8ff"), ve = new t.Color("#9fdcff"), _e = new t.Color("#ff4fa8"), it = new t.Color("#ff9ccf"), ie = new t.Color(1, 1, 1), Ge = new t.Color("#ffc24a"), Zt = new t.Color("#ff2d55"), Dt = new t.Color("#3a4560"), rt = Object.fromEntries(Object.entries(mt).map(([e, s]) => [e, new t.Color(s)])), D = (e) => e < 0 ? 0 : e > 1 ? 1 : e, Te = (e) => 1 - Math.pow(1 - D(e), 3), Ne = (e) => (e = D(e), e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2);
12
+ let Ie = null;
13
+ function $t() {
14
+ if (Ie) return Ie;
15
+ const e = document.createElement("canvas");
16
+ e.width = e.height = 128;
17
+ const s = e.getContext("2d"), a = s.createRadialGradient(64, 64, 0, 64, 64, 64);
18
+ return a.addColorStop(0, "rgba(255,255,255,1)"), a.addColorStop(0.12, "rgba(255,255,255,0.7)"), a.addColorStop(0.4, "rgba(255,255,255,0.15)"), a.addColorStop(1, "rgba(255,255,255,0)"), s.fillStyle = a, s.fillRect(0, 0, 128, 128), Ie = new t.CanvasTexture(e), Ie;
19
+ }
20
+ function ce(e = "#fff") {
21
+ return new t.SpriteMaterial({ map: $t(), color: e, blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
22
+ }
23
+ function ye(e = "#fff") {
24
+ return new t.MeshBasicMaterial({ color: e, blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
25
+ }
26
+ function we(e = "#fff", s = !1) {
27
+ return new t.LineBasicMaterial({ color: e, vertexColors: s, transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 });
28
+ }
29
+ const He = new t.SphereGeometry(1, 24, 18), ht = new t.ConeGeometry(1, 1, 12).translate(0, 0.5, 0), ct = new t.TorusGeometry(1, 0.03, 6, 72);
30
+ function kt(e = 48, s = 6) {
31
+ const a = [], o = [];
32
+ for (let n = 0; n <= e; n++)
33
+ for (let c = 0; c < s; c++) {
34
+ const l = c / s * Math.PI * 2;
35
+ a.push(n / e, Math.cos(l), Math.sin(l));
36
+ }
37
+ for (let n = 0; n < e; n++)
38
+ for (let c = 0; c < s; c++) {
39
+ const l = n * s + c, f = n * s + (c + 1) % s;
40
+ o.push(l, l + s, f, f, l + s, f + s);
41
+ }
42
+ const u = new t.BufferGeometry();
43
+ return u.setAttribute("position", new t.Float32BufferAttribute(a, 3)), u.setIndex(o), u.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), u;
44
+ }
45
+ const Jt = kt();
46
+ function Qt(e, s = 0.04) {
47
+ return new t.ShaderMaterial({
48
+ uniforms: {
49
+ uP0: { value: new t.Vector3() },
50
+ uP1: { value: new t.Vector3() },
51
+ uP2: { value: new t.Vector3() },
52
+ uRadius: { value: s },
53
+ uOpacity: { value: 1 },
54
+ uGrow: { value: 1 },
55
+ uTime: { value: 0 },
56
+ uFlow: { value: 0 },
57
+ uHead: { value: -1 },
58
+ uColor: { value: new t.Color(e) },
59
+ uHeadColor: { value: new t.Color(3, 3, 3) }
60
+ },
61
+ vertexShader: (
62
+ /* glsl */
63
+ `
64
+ uniform vec3 uP0; uniform vec3 uP1; uniform vec3 uP2; uniform float uRadius;
65
+ varying float vT; varying float vRim;
66
+ void main(){
67
+ float t = position.x; float a = 1.0 - t;
68
+ vec3 p = a*a*uP0 + 2.0*a*t*uP1 + t*t*uP2;
69
+ vec3 tg = 2.0*a*(uP1-uP0) + 2.0*t*(uP2-uP1);
70
+ tg = length(tg) > 1e-5 ? normalize(tg) : vec3(1.0,0.0,0.0);
71
+ vec3 up = abs(tg.y) > 0.92 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,0.0);
72
+ vec3 n = normalize(cross(tg, up)); vec3 b = cross(tg, n);
73
+ vec3 off = n*position.y + b*position.z;
74
+ vec4 mv = modelViewMatrix * vec4(p + off * uRadius * mix(1.0, 0.45, t), 1.0);
75
+ vRim = abs(dot(normalize(normalMatrix * off), normalize(-mv.xyz)));
76
+ vT = t;
77
+ gl_Position = projectionMatrix * mv;
78
+ }`
79
+ ),
80
+ fragmentShader: (
81
+ /* glsl */
82
+ `
83
+ uniform vec3 uColor; uniform vec3 uHeadColor; uniform float uOpacity; uniform float uGrow; uniform float uTime; uniform float uFlow; uniform float uHead;
84
+ varying float vT; varying float vRim;
85
+ void main(){
86
+ if (vT > uGrow) discard;
87
+ float core = 0.2 + 0.8 * vRim * vRim;
88
+ // field quanta travelling parent (t=0) -> child (t=1)
89
+ float flow = uFlow * pow(max(0.0, sin((vT * 6.0 - uTime * 0.8) * 3.14159)), 10.0);
90
+ float head = uHead >= 0.0 ? exp(-pow((vT - uHead) / 0.05, 2.0)) : 0.0;
91
+ gl_FragColor = vec4(uColor * uOpacity * (core + flow * 2.6) + uHeadColor * head, 1.0);
92
+ }`
93
+ ),
94
+ transparent: !0,
95
+ depthWrite: !1,
96
+ blending: t.AdditiveBlending
97
+ });
98
+ }
99
+ function pe(e, s, a, o, u) {
100
+ const n = 1 - o;
101
+ return u.set(n * n * e.x + 2 * n * o * s.x + o * o * a.x, n * n * e.y + 2 * n * o * s.y + o * o * a.y, n * n * e.z + 2 * n * o * s.z + o * o * a.z);
102
+ }
103
+ function Ue(e, s, a, o) {
104
+ o.copy(e).add(s).multiplyScalar(0.5);
105
+ const u = o.length() || 1;
106
+ return o.multiplyScalar(1 + a / u), o.z += a * 0.4, o;
107
+ }
108
+ const je = class je {
109
+ constructor(s) {
110
+ Z(this, "mesh");
111
+ Z(this, "colors");
112
+ Z(this, "n", 0);
113
+ Z(this, "o", new t.Object3D());
114
+ Z(this, "a", new t.Vector3());
115
+ Z(this, "b", new t.Vector3());
116
+ this.max = s, this.colors = new Float32Array(s * 3), this.mesh = new t.InstancedMesh(ht, new t.MeshBasicMaterial({ blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 }), s), this.mesh.instanceColor = new t.InstancedBufferAttribute(this.colors, 3), this.mesh.frustumCulled = !1, this.mesh.count = 0;
117
+ }
118
+ begin() {
119
+ this.n = 0;
120
+ }
121
+ add(s, a, o, u, n, c, l, f = 1) {
122
+ this.n >= this.max || f <= 0.01 || (pe(s, a, o, u, this.a), pe(s, a, o, D(u + 0.02 * n), this.b), this.b.sub(this.a), !(this.b.lengthSq() < 1e-8) && (this.o.position.copy(this.a), this.o.quaternion.setFromUnitVectors(je.UP, this.b.normalize()), this.o.scale.set(c * 0.38, c, c * 0.38), this.o.updateMatrix(), this.mesh.setMatrixAt(this.n, this.o.matrix), this.colors[this.n * 3] = l.r * f, this.colors[this.n * 3 + 1] = l.g * f, this.colors[this.n * 3 + 2] = l.b * f, this.n++));
123
+ }
124
+ end() {
125
+ this.mesh.count = this.n, this.mesh.instanceMatrix.needsUpdate = !0, this.mesh.instanceColor.needsUpdate = !0;
126
+ }
127
+ };
128
+ Z(je, "UP", new t.Vector3(0, 1, 0));
129
+ let Xe = je;
130
+ class vt {
131
+ constructor(s, a) {
132
+ Z(this, "geo", new t.BufferGeometry());
133
+ Z(this, "P");
134
+ Z(this, "C");
135
+ Z(this, "n", 0);
136
+ this.max = s, this.seg = a, this.P = new t.BufferAttribute(new Float32Array(s * a * 6), 3), this.C = new t.BufferAttribute(new Float32Array(s * a * 6), 3), this.geo.setAttribute("position", this.P), this.geo.setAttribute("color", this.C), this.geo.boundingSphere = new t.Sphere(new t.Vector3(), 1e4);
137
+ }
138
+ begin() {
139
+ this.n = 0;
140
+ }
141
+ /** Returns the base vertex index for curve slot, or -1 if full. Caller writes seg*2 vertices. */
142
+ next() {
143
+ return this.n < this.max ? this.n++ * this.seg * 2 : -1;
144
+ }
145
+ end() {
146
+ this.geo.setDrawRange(0, this.n * this.seg * 2), this.P.needsUpdate = !0, this.C.needsUpdate = !0;
147
+ }
148
+ }
149
+ const ae = 2.4, xe = /* @__PURE__ */ new Map(), Oe = /* @__PURE__ */ new Map();
150
+ function eo(e, s, a) {
151
+ return e.r += s.r * a, e.g += s.g * a, e.b += s.b * a, e;
152
+ }
153
+ new t.Vector3();
154
+ new t.Vector3(0, 1, 0);
155
+ function to() {
156
+ const e = [], s = (n, c) => e.push(...n, ...c), o = (n, c, l = 48) => {
157
+ for (let f = 0; f < l; f++) {
158
+ const y = f / l * Math.PI * 2, m = (f + 1) / l * Math.PI * 2;
159
+ s([Math.cos(y) * n, Math.sin(y) * n, c], [Math.cos(m) * n, Math.sin(m) * n, c]);
160
+ }
161
+ };
162
+ for (const n of [-0.7, 0.7])
163
+ o(1, n), o(0.62, n), o(0.3, n * 1.15);
164
+ o(1, 0);
165
+ for (let n = 0; n < 16; n++) {
166
+ const c = n / 16 * Math.PI * 2, l = Math.cos(c), f = Math.sin(c);
167
+ s([l * 1, f * 1, -0.7], [l * 1, f * 1, 0.7]);
168
+ for (const y of [-0.7, 0.7]) s([l * 0.62, f * 0.62, y], [l * 1, f * 1, y]);
169
+ n % 2 === 0 && s([l * 0.3, f * 0.3, -0.8], [l * 0.3, f * 0.3, 0.8]);
170
+ }
171
+ const u = new t.BufferGeometry();
172
+ return u.setAttribute("position", new t.Float32BufferAttribute(e, 3)), u;
173
+ }
174
+ to();
175
+ new t.CylinderGeometry(1, 1, 1.4, 32, 1, !0).rotateX(Math.PI / 2);
176
+ new t.Vector3();
177
+ new t.Vector3();
178
+ const lt = 28, qe = 40, We = 24;
179
+ function oo() {
180
+ const e = V(() => new vt(lt * 2, qe), []), s = V(() => we("#fff", !0), []), a = V(() => new Xe(lt), []), o = V(() => Array.from({ length: We }, () => ce("#fff")), []), u = U([]), n = V(() => ({ a: new t.Vector3(), b: new t.Vector3(), c: new t.Vector3(), p: new t.Vector3(), col: new t.Color(), k: new t.Color() }), []);
181
+ return Ae(({ clock: c }) => {
182
+ const l = performance.now(), f = ee ? 0 : c.elapsedTime;
183
+ e.begin(), a.begin();
184
+ const { a: y, b: m, c: E, p: G, col: M, k: P } = n, z = (d, b, C, r) => {
185
+ const F = ge(d), I = H.mcpServers.get(b), B = st(b);
186
+ if (!F || !I || !B) return;
187
+ y.copy(F), m.copy(B), Ue(y, m, 1.2, E), M.set(I.color);
188
+ let R;
189
+ C === 0 ? (M.lerp(Ge, D(r / 1.2)), r > 1.2 && M.lerp(Zt, D((r - 1.2) / 1)), R = (0.25 + Math.min(0.6, r * 0.25)) * Te(r / 0.3)) : (M.lerp(ie, 0.35), R = 1.2 * (r < 0.75 ? 1 : 1 - (r - 0.75) / 0.25));
190
+ const j = 1 - Ne(r / 0.75);
191
+ for (let g = 0; g < 2; g++) {
192
+ const S = e.next();
193
+ if (S < 0) return;
194
+ const L = g ? 0.045 : 0;
195
+ for (let _ = 0; _ < qe; _++)
196
+ for (let K = 0; K < 2; K++) {
197
+ const Y = (_ + K) / qe;
198
+ pe(y, E, m, Y, G), e.P.setXYZ(S + _ * 2 + K, G.x + L, G.y + L, G.z);
199
+ let O;
200
+ C === 0 ? O = R * (0.22 + Math.pow(Math.max(0, Math.sin(Y * 26 - f * 3)), 10) * 1.8) * (g ? 0.3 : 1) : O = R * (0.18 + Math.exp(-(((Y - j) / 0.05) ** 2)) * 3.4 * (r < 0.8 ? 1 : 0)) * (g ? 0.5 : 1), e.C.setXYZ(S + _ * 2 + K, M.r * O, M.g * O, M.b * O);
201
+ }
202
+ }
203
+ P.copy(M), C === 0 ? a.add(y, E, m, 0.93, 1, 0.45, P, 0.5 + R * 1.3) : a.add(y, E, m, 0.07, -1, 0.6, P, R * 1.5);
204
+ };
205
+ for (const d of H.mcpPending.values()) z(d.instance, d.server, 0, Ct(d, l));
206
+ for (const d of H.mcpCalls) d.phase === "result" && z(d.instance, d.server, 1, D((l - d.start) / d.dur));
207
+ e.end(), a.end();
208
+ let i = 0;
209
+ for (const d of H.mcpCalls) {
210
+ if (d.phase !== "call" || i >= We) continue;
211
+ const b = ge(d.instance), C = H.mcpServers.get(d.server), r = st(d.server), F = u.current[i], I = D((l - d.start) / d.dur);
212
+ !b || !C || !r || !F || I >= 1 || (y.copy(b), m.copy(r), Ue(y, m, 1.2, E), pe(y, E, m, Ne(I), G), F.visible = !0, F.position.copy(G), F.scale.setScalar(0.85), o[i].color.set(C.color).lerp(ie, 0.4).multiplyScalar(1.5), i++);
213
+ }
214
+ for (let d = i; d < We; d++) u.current[d] && (u.current[d].visible = !1);
215
+ }), /* @__PURE__ */ se(Ce, { children: [
216
+ /* @__PURE__ */ v("lineSegments", { geometry: e.geo, material: s, frustumCulled: !1 }),
217
+ /* @__PURE__ */ v("primitive", { object: a.mesh }),
218
+ o.map((c, l) => /* @__PURE__ */ v("sprite", { ref: (f) => void (u.current[l] = f), material: c, visible: !1 }, l))
219
+ ] });
220
+ }
221
+ const ze = 40, Ze = 160, no = new t.MeshBasicMaterial({ transparent: !0, opacity: 0, depthWrite: !1, colorWrite: !1 }), ro = new t.Vector3(0, 1, 0), so = new t.Vector3(0, 0, 1), De = new t.Vector3(), ut = new t.Vector3(), Ee = new t.Vector3(), ao = (() => {
222
+ const e = new Float32Array((Ze + 1) * 3);
223
+ for (let a = 0; a <= Ze; a++) {
224
+ const o = a / Ze * Math.PI * 2;
225
+ e.set([Math.cos(o), Math.sin(o), 0], a * 3);
226
+ }
227
+ const s = new t.BufferGeometry();
228
+ return s.setAttribute("position", new t.BufferAttribute(e, 3)), s.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), s;
229
+ })(), Be = 40, ot = Array.from({ length: Be }, () => ({ on: !1, start: 0, size: 1, o: new t.Vector3(), dir: new t.Vector3(), perp: new t.Vector3(), c: new t.Color() }));
230
+ let $e = 0;
231
+ function io(e, s, a, o, u) {
232
+ const n = ot[$e];
233
+ $e = ($e + 1) % Be, n.on = !0, n.start = performance.now(), n.size = a, n.o.copy(e), n.dir.copy(e).sub(s), n.dir.lengthSq() < 1e-4 && n.dir.set(0, 1, 0), n.dir.normalize(), n.dir.x += Math.sin(u * 12.9) * 0.6, n.dir.y += Math.cos(u * 7.3) * 0.6, n.dir.z += 0.35, n.dir.normalize(), n.perp.set(0, 0, 1).cross(n.dir).normalize(), n.perp.lengthSq() < 0.5 && n.perp.set(1, 0, 0), n.c.copy(o).lerp(ie, 0.35);
234
+ }
235
+ function co({ agent: e, selected: s, onSelect: a }) {
236
+ const o = e.inst, u = U(null), n = U(null), c = U(null), l = U(null), f = U(null), y = U(null), m = U(null), E = U(null), G = U(null), M = U(null), P = rt[o.type], z = !!o.subagent, i = V(
237
+ () => ({
238
+ core: ye("#fff"),
239
+ shell: ye(P),
240
+ halo: ce(P),
241
+ ring: ye(Ge),
242
+ sel: ye(ve),
243
+ flash: ce("#fff"),
244
+ arrow: ye(P),
245
+ field: Qt(P, z ? 0.028 : 0.04),
246
+ trail: we("#fff", !0),
247
+ orbit: we(P)
248
+ }),
249
+ [P, z]
250
+ ), d = V(() => {
251
+ const B = new t.BufferGeometry();
252
+ return B.setAttribute("position", new t.BufferAttribute(new Float32Array(ze * 3), 3)), B.setAttribute("color", new t.BufferAttribute(new Float32Array(ze * 3), 3)), B.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), B;
253
+ }, []), b = V(() => Object.assign(new t.Line(d, i.trail), { frustumCulled: !1 }), [d, i.trail]), C = V(() => Object.assign(new t.Line(ao, i.orbit), { frustumCulled: !1, matrixAutoUpdate: !1, visible: !1 }), [i.orbit]), r = V(
254
+ () => ({
255
+ p: new t.Vector3(),
256
+ ctrl: new t.Vector3(),
257
+ par: new t.Vector3(),
258
+ n: new t.Vector3(),
259
+ a: new t.Vector3(),
260
+ b: new t.Vector3(),
261
+ from: new t.Vector3(),
262
+ fromSet: !1,
263
+ c: new t.Color(),
264
+ llm: o.llmCalls,
265
+ ringK: 0,
266
+ linkK: 0,
267
+ labelK: 1,
268
+ seed: Me(o.id, 3),
269
+ dir: Me(o.id, 4) < 0.5 ? 1 : -1,
270
+ // shell plane: tilt toward the viewer (seeded per agent) -> classic atom-logo ellipses
271
+ tilt: 0.35 + Me(o.id, 5) * 0.25,
272
+ lean: 0.45 + Me(o.id, 6) * 0.25
273
+ }),
274
+ [o]
275
+ ), F = (B, R) => R.copy(r.n).addScaledVector(r.a, Math.cos(B)).addScaledVector(r.b, Math.sin(B));
276
+ Ae(({ clock: B, camera: R }) => {
277
+ var ue, Q, re, Re, fe;
278
+ const j = performance.now(), g = B.elapsedTime, S = o.exitAt ? (j - o.exitAt) / 1e3 / (At(o) / Vt) : -1, L = S >= 0 ? D(S / 0.8) : 0, _ = S > 0 ? S : 0;
279
+ if (z) {
280
+ const x = 0.32 * Se.spread;
281
+ r.n.copy(e.pos), r.a.set(x, 0, 0), r.b.set(0, x * 0.45, x * 0.6);
282
+ } else {
283
+ const x = xe.get(e.run.id) ?? e.run.origin;
284
+ r.n.copy(x), r.a.copy(e.pos).sub(x);
285
+ let q = r.a.length();
286
+ q < 0.5 && (r.a.set(0, 0.5, 0), q = 0.5), r.b.set(-r.a.y, r.a.x, 0).normalize().multiplyScalar(q * r.tilt * r.dir).addScaledVector(so, q * r.lean);
287
+ }
288
+ let Y = z ? g * (z ? ee ? 0 : 0.9 : 0) * r.dir + r.seed * 6.28 : ee ? 0 : Math.sin(g * 0.6 + r.seed * 9) * 0.06;
289
+ Y += r.dir * _ * 0.9;
290
+ const O = 1 + _ * _ * 0.07;
291
+ F(Y, e.live), O !== 1 && e.live.sub(r.n).multiplyScalar(O).add(r.n);
292
+ const p = Te((j - o.bornAt) / 1100);
293
+ if (p < 1) {
294
+ const x = o.parent ? ge(o.parent) : void 0;
295
+ x ? (r.from.copy(x), r.fromSet = !0) : r.fromSet || (r.from.copy(r.n), r.fromSet = !0), e.live.lerpVectors(r.from, e.live, z ? p : 0.3 + 0.7 * p);
296
+ }
297
+ const w = e.live;
298
+ (ue = u.current) == null || ue.position.copy(w);
299
+ const T = Pt(o, j), N = S < 0 && (o.status === "thinking" || o.status === "spawning"), te = zt(o, j);
300
+ let Ve = !1;
301
+ for (const x of H.mcpPending.values()) x.instance === o.id && (Ve = !0);
302
+ const Fe = ee ? 0.5 : 0.5 + 0.5 * Math.sin(g * (N ? 6 : 1.6) + r.seed * 30);
303
+ o.llmCalls !== r.llm && (r.llm = o.llmCalls, S < 0 && io(w, xe.get(e.run.id) ?? e.run.origin, o.pulse, P, r.seed + o.llmCalls * 0.37));
304
+ const oe = e.scale, le = Te((j - o.bornAt) / 700), Ke = 0.3 * oe * le * (1 - L * 0.9) * (1 + te * 0.12);
305
+ if ((Q = n.current) == null || Q.scale.setScalar(Math.max(1e-4, Ke)), r.c.copy(P).multiplyScalar((N ? 1 + Fe * 0.4 : 0.55 + Fe * 0.15) + te * 0.5), S >= 0 && r.c.lerp(Dt, L), i.shell.color.copy(r.c), i.core.color.setScalar((N ? 0.9 : 0.45) * (1 - L) + te * 0.4), c.current && (c.current.scale.setScalar(Math.max(1e-4, (N ? 2.4 : 1.7) * oe * le * (1 - L * 0.7) + te * 0.9 * Se.scale)), i.halo.color.copy(P).multiplyScalar(((N ? 0.32 : 0.16) + te * 0.25) * T)), y.current) {
306
+ const x = S >= 0 && S < 0.9 ? 1 - S / 0.9 : 0;
307
+ y.current.visible = x > 0, y.current.scale.setScalar(Math.max(1e-4, oe * (1.2 + (1 - x) * 3.5))), i.flash.color.copy(o.status === "failed" ? Ge : ie).multiplyScalar(x * x * 0.9);
308
+ }
309
+ if (r.ringK += ((Ve && S < 0 ? 1 : 0) - r.ringK) * 0.1, l.current && (l.current.visible = r.ringK > 0.02, l.current.rotation.set(1.2 + Math.sin(g * 0.8) * 0.3, g * 1.4, 0), l.current.scale.setScalar(Math.max(1e-4, 0.62 * oe * r.ringK)), i.ring.color.copy(Ge).multiplyScalar(1.1 * r.ringK * (0.7 + Fe * 0.3))), f.current && (f.current.visible = s, f.current.quaternion.copy(R.quaternion), f.current.scale.setScalar(0.8 * oe + (ee ? 0 : Math.sin(g * 3) * 0.04))), (re = E.current) == null || re.scale.setScalar(Math.max(0.55, 0.62 * oe)), z ? (Re = M.current) == null || Re.position.set(0.3 * oe + 0.15, 0, 0) : (fe = M.current) == null || fe.position.set(0, (r.a.y > 0.2 ? 1 : -1) * (0.42 * oe + 0.28), 0), G.current && (r.labelK += ((Et(o.id) ? 1 : 0) - r.labelK) * 0.12, G.current.setOpacity(D((j - o.bornAt) / 600) * (1 - D(S / 1.2)) * 0.95 * r.labelK)), !z) {
310
+ const x = r.a.length();
311
+ C.visible = x > 0.6 && T > 0.02, C.visible && (Ee.crossVectors(r.a, r.b).normalize(), C.matrix.makeBasis(r.a, r.b, Ee).setPosition(r.n), C.matrixWorldNeedsUpdate = !0, i.orbit.color.copy(P).multiplyScalar((N ? 0.32 : 0.2) * le * (1 - L) * T));
312
+ }
313
+ const W = d.getAttribute("position"), h = d.getAttribute("color"), A = z ? 2.4 : 1.5, X = (N ? 0.75 : 0.45) * le * (S >= 0 ? (1 - D((S - 0.4) / 2)) * 1.6 : 1);
314
+ for (let x = 0; x < ze; x++) {
315
+ const q = Y - r.dir * (x / (ze - 1)) * A;
316
+ F(q, r.p), O !== 1 && r.p.sub(r.n).multiplyScalar(O).add(r.n), p < 1 && r.p.lerpVectors(r.from, r.p, z ? p : 0.3 + 0.7 * p), W.setXYZ(x, r.p.x, r.p.y, r.p.z);
317
+ const Pe = Math.pow(1 - x / (ze - 1), 1.8) * X;
318
+ h.setXYZ(x, (S >= 0 ? ve.r : P.r) * Pe, (S >= 0 ? ve.g : P.g) * Pe, (S >= 0 ? ve.b : P.b) * Pe);
319
+ }
320
+ W.needsUpdate = !0, h.needsUpdate = !0;
321
+ const $ = o.parent ? ge(o.parent) : void 0, k = o.parent ? H.instances.get(o.parent) : void 0, ne = !!$ && !!k && !k.exitAt && !o.exitAt;
322
+ r.linkK += ((ne ? 1 : 0) - r.linkK) * (ne ? 0.06 : 0.05), $ && r.par.copy($);
323
+ const J = i.field.uniforms;
324
+ J.uP0.value.copy(r.par), J.uP2.value.copy(w), Ue(r.par, w, z ? 0.3 : 1.4, r.ctrl), J.uP1.value.copy(r.ctrl);
325
+ const de = Ne((j - o.bornAt) / 900);
326
+ if (J.uGrow.value = o.parent && r.linkK > 0.01 ? de : 0, J.uOpacity.value = (N ? 0.7 : 0.45) * r.linkK, J.uFlow.value = r.linkK, J.uTime.value = ee ? 0 : g, J.uHead.value = de < 1 ? de : -1, m.current) {
327
+ const x = o.parent && r.linkK > 0.05 && de >= 1;
328
+ if (m.current.visible = !!x, x) {
329
+ pe(r.par, r.ctrl, w, 0.74, De), pe(r.par, r.ctrl, w, 0.8, ut), m.current.position.copy(De), Ee.subVectors(ut, De), Ee.lengthSq() > 1e-8 && m.current.quaternion.setFromUnitVectors(ro, Ee.normalize());
330
+ const q = (z ? 0.11 : 0.15) * Math.min(1.3, Se.scale);
331
+ m.current.scale.set(q, q * 2.6, q), i.arrow.color.copy(P).multiplyScalar(1.5 * r.linkK);
332
+ }
333
+ }
334
+ });
335
+ const I = o.id.split(":")[2];
336
+ return /* @__PURE__ */ se(Ce, { children: [
337
+ /* @__PURE__ */ v("primitive", { object: C }),
338
+ /* @__PURE__ */ v("mesh", { geometry: Jt, material: i.field, frustumCulled: !1 }),
339
+ /* @__PURE__ */ v("mesh", { ref: m, geometry: ht, material: i.arrow, visible: !1 }),
340
+ /* @__PURE__ */ v("primitive", { object: b }),
341
+ /* @__PURE__ */ se("group", { ref: u, position: e.pos, children: [
342
+ /* @__PURE__ */ se("group", { ref: n, scale: 1e-4, children: [
343
+ /* @__PURE__ */ v("mesh", { geometry: He, material: i.shell }),
344
+ /* @__PURE__ */ v("mesh", { geometry: He, material: i.core, scale: 0.55 })
345
+ ] }),
346
+ /* @__PURE__ */ v(
347
+ "mesh",
348
+ {
349
+ ref: E,
350
+ geometry: He,
351
+ material: no,
352
+ onClick: (B) => {
353
+ B.stopPropagation(), a(o.id);
354
+ },
355
+ onPointerOver: () => document.body.style.cursor = "pointer",
356
+ onPointerOut: () => document.body.style.cursor = ""
357
+ }
358
+ ),
359
+ /* @__PURE__ */ v("sprite", { ref: c, material: i.halo }),
360
+ /* @__PURE__ */ v("sprite", { ref: y, material: i.flash, visible: !1 }),
361
+ /* @__PURE__ */ v("mesh", { ref: l, geometry: ct, material: i.ring, visible: !1 }),
362
+ /* @__PURE__ */ v("mesh", { ref: f, geometry: ct, material: i.sel, visible: !1 }),
363
+ /* @__PURE__ */ v("group", { ref: M, children: /* @__PURE__ */ v(
364
+ nt,
365
+ {
366
+ ref: G,
367
+ anchorX: z ? "left" : "center",
368
+ text: `${o.name}${I !== void 0 ? ` ${Number(I) + 1}` : ""}`,
369
+ live: o.job ? () => Gt(o) : null,
370
+ color: mt[o.type],
371
+ size: z ? 0.22 : 0.28,
372
+ opacity: 0,
373
+ fit: !0,
374
+ pxRange: z ? [8, 11.5] : [9, 13]
375
+ }
376
+ ) })
377
+ ] })
378
+ ] });
379
+ }
380
+ const be = 36, ft = 1.5;
381
+ function lo() {
382
+ const e = V(() => {
383
+ const n = new t.BufferGeometry();
384
+ return n.setAttribute("position", new t.BufferAttribute(new Float32Array(Be * be * 6), 3)), n.setAttribute("color", new t.BufferAttribute(new Float32Array(Be * be * 6), 3)), n.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), n;
385
+ }, []), s = V(() => we("#fff", !0), []), a = V(() => ot.map(() => ce("#fff")), []), o = U([]), u = V(() => new t.Vector3(), []);
386
+ return Ae(() => {
387
+ const n = performance.now(), c = e.getAttribute("position"), l = e.getAttribute("color");
388
+ let f = 0;
389
+ for (let y = 0; y < Be; y++) {
390
+ const m = ot[y], E = o.current[y], G = (n - m.start) / 1e3;
391
+ if (!m.on || G > ft) {
392
+ m.on = !1, E && (E.visible = !1);
393
+ continue;
394
+ }
395
+ if (E) {
396
+ const b = Math.max(0, 1 - G / 0.55);
397
+ E.visible = b > 0, E.position.copy(m.o), E.scale.setScalar(Math.max(1e-4, (0.8 + m.size * 1.5) * (0.6 + (1 - b) * 0.8))), a[y].color.copy(m.c).multiplyScalar(b * b * 1.1);
398
+ }
399
+ const M = 1 - G / ft, P = 0.4 + G * 7.5, z = 1.2 + m.size * 1.1, i = 0.1 + m.size * 0.07, d = f * be * 2;
400
+ for (let b = 0; b < be; b++)
401
+ for (let C = 0; C < 2; C++) {
402
+ const r = (b + C) / be, F = Math.max(0, P - z * (1 - r)), I = Math.sin(Math.PI * r), B = Math.sin(r * Math.PI * 2 * (3 + m.size)) * i * I;
403
+ u.copy(m.o).addScaledVector(m.dir, F).addScaledVector(m.perp, B), c.setXYZ(d + b * 2 + C, u.x, u.y, u.z);
404
+ const R = I * M * 1.4;
405
+ l.setXYZ(d + b * 2 + C, m.c.r * R, m.c.g * R, m.c.b * R);
406
+ }
407
+ f++;
408
+ }
409
+ e.setDrawRange(0, f * be * 2), c.needsUpdate = !0, l.needsUpdate = !0;
410
+ }), /* @__PURE__ */ se(Ce, { children: [
411
+ /* @__PURE__ */ v("lineSegments", { geometry: e, material: s, frustumCulled: !1 }),
412
+ a.map((n, c) => /* @__PURE__ */ v("sprite", { ref: (l) => void (o.current[c] = l), material: n, visible: !1 }, c))
413
+ ] });
414
+ }
415
+ const ke = 24;
416
+ function uo() {
417
+ const e = V(() => Array.from({ length: ke }, () => ce("#fff")), []), s = U([]), a = V(() => ({ c: new t.Vector3(), h: new t.Vector3() }), []);
418
+ return Ae(() => {
419
+ const o = performance.now();
420
+ let u = 0;
421
+ for (const n of H.comets) {
422
+ if (u >= ke) break;
423
+ const c = ge(n.from), l = ge(n.to), f = s.current[u];
424
+ if (!c || !l || !f) continue;
425
+ const y = Bt(n, o);
426
+ if (!Ft(n, o)) continue;
427
+ Ue(c, l, 1, a.c), pe(c, a.c, l, Ne(y), a.h), f.visible = !0, f.position.copy(a.h), f.scale.setScalar(0.9);
428
+ const m = H.instances.get(n.from);
429
+ e[u].color.copy(m ? rt[m.type] : ve).lerp(ie, 0.4).multiplyScalar(1.4 * Math.sin(Math.PI * y) + 0.2), u++;
430
+ }
431
+ for (let n = u; n < ke; n++) s.current[n] && (s.current[n].visible = !1);
432
+ }), /* @__PURE__ */ v(Ce, { children: e.map((o, u) => /* @__PURE__ */ v("sprite", { ref: (n) => void (s.current[u] = n), material: o, visible: !1 }, u)) });
433
+ }
434
+ const me = 14, fo = 0.2, po = new t.OctahedronGeometry(0.13, 0), mo = (
435
+ /* glsl */
436
+ `
437
+ attribute vec3 aCol;
438
+ varying vec3 vN; varying vec3 vV; varying vec3 vC;
439
+ void main(){
440
+ vec4 mv = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
441
+ vN = normalize(normalMatrix * mat3(instanceMatrix) * normal);
442
+ vV = normalize(-mv.xyz); vC = aCol;
443
+ gl_Position = projectionMatrix * mv;
444
+ }`
445
+ ), ho = (
446
+ /* glsl */
447
+ `
448
+ uniform float uGain;
449
+ varying vec3 vN; varying vec3 vV; varying vec3 vC;
450
+ void main(){
451
+ vec3 n = normalize(vN);
452
+ vec3 L = normalize(vec3(-0.45, 0.65, 0.6));
453
+ float d = max(dot(n, L), 0.0);
454
+ float rim = pow(1.0 - abs(dot(n, normalize(vV))), 2.4);
455
+ float spec = pow(max(dot(reflect(-L, n), normalize(vV)), 0.0), 28.0);
456
+ vec3 col = vC * (0.10 + 0.55 * d) + vC * rim * 0.75 + vec3(spec) * 0.35;
457
+ gl_FragColor = vec4(col * uGain, 1.0);
458
+ }`
459
+ ), Je = new t.Vector3();
460
+ function vo(e, s) {
461
+ let a = 0, o = 0, u = 0, n = 1 / 0;
462
+ for (const f of he.agents.values())
463
+ f.run === e && (f.depth === 0 ? (a++, o += f.eu, u += f.ev) : n = Math.min(n, f.ev));
464
+ const c = 2.1 * Se.spread;
465
+ if (!a) {
466
+ s.u = e.cu, s.v = n < 1 / 0 ? n - c : e.cv;
467
+ return;
468
+ }
469
+ s.u = o / a;
470
+ const l = u / a;
471
+ s.v = n < 1 / 0 ? (l + n) / 2 : l - c;
472
+ }
473
+ const Qe = { u: 0, v: 0 };
474
+ function go({ run: e }) {
475
+ const s = V(() => new t.Vector3(), []), a = V(() => new t.Vector3(), []), o = V(() => ({ init: !1, c: new t.Color(), topY: 0, topSet: !1 }), []);
476
+ St(() => (xe.set(e.id, s), Oe.set(e.id, a), () => {
477
+ xe.get(e.id) === s && xe.delete(e.id), Oe.get(e.id) === a && Oe.delete(e.id);
478
+ }), [e.id, s, a]);
479
+ const u = V(() => {
480
+ const m = new t.SphereGeometry(1, 16, 12), E = new t.InstancedBufferAttribute(new Float32Array(me * 3), 3);
481
+ m.setAttribute("aCol", E);
482
+ const G = new t.ShaderMaterial({ uniforms: { uGain: { value: 1 } }, vertexShader: mo, fragmentShader: ho }), M = new t.InstancedMesh(m, G, me);
483
+ M.frustumCulled = !1;
484
+ const P = new Float32Array(me * 3), z = Math.PI * (3 - Math.sqrt(5));
485
+ for (let i = 0; i < me; i++) {
486
+ const d = 0.36 * Math.cbrt(1 - i / me), b = 1 - 2 * (i + 0.5) / me, C = Math.sqrt(1 - b * b);
487
+ P.set([Math.cos(i * z) * C * d, b * d, Math.sin(i * z) * C * d], i * 3);
488
+ const r = (Me(e.id, 40 + i) < 0.5 ? _e : at).clone().lerp(ie, 0.08 + Me(e.id, 80 + i) * 0.12).multiplyScalar(0.9);
489
+ E.setXYZ(i, r.r, r.g, r.b);
490
+ }
491
+ return { mesh: M, mat: G, pos: P, o: new t.Object3D() };
492
+ }, [e.id]), n = V(() => new t.Color(e.color).lerp(e.index % 2 ? _e : at, 0.45), [e.color, e.index]), c = V(
493
+ () => ({
494
+ core: ce(new t.Color("#7a5cff").multiplyScalar(0.35)),
495
+ cloud: ce("#000"),
496
+ beads: Ye.map(() => ye("#fff"))
497
+ }),
498
+ []
499
+ ), l = U(null), f = U([]), y = U(null);
500
+ return Ae(({ clock: m }) => {
501
+ var j;
502
+ const E = performance.now(), G = m.elapsedTime, M = e.run ?? H.runs.get(e.id);
503
+ vo(e, Qe), Rt(e, Qe.u, Qe.v, Je), o.init ? s.lerp(Je, 0.12) : (s.copy(Je), o.init = !0);
504
+ const P = Math.max(0.6, Se.scale), z = M ? Te((E - M.startedAt) / 1200) : 1, i = M != null && M.endedAt ? D(1 - (E - M.endedAt - (It - 2600)) / 2600) : 1, d = (M == null ? void 0 : M.status) === "started" ? 1 : 0.6;
505
+ l.current && (l.current.position.copy(s), l.current.scale.setScalar(Math.max(1e-4, P * (0.4 + 0.6 * z) * (0.6 + 0.4 * i))));
506
+ const { mesh: b, mat: C, pos: r, o: F } = u, I = ee ? 0 : 0.02;
507
+ for (let g = 0; g < me; g++)
508
+ F.position.set(r[g * 3] + Math.sin(G * 2.1 + g * 1.7) * I, r[g * 3 + 1] + Math.cos(G * 1.8 + g * 2.3) * I, r[g * 3 + 2] + Math.sin(G * 1.6 + g) * I), F.scale.setScalar(fo), F.updateMatrix(), b.setMatrixAt(g, F.matrix);
509
+ b.instanceMatrix.needsUpdate = !0;
510
+ const B = ee ? 1 : 0.88 + 0.12 * Math.sin(G * 0.7 + e.index);
511
+ C.uniforms.uGain.value = (0.55 + 0.45 * d) * i * (0.7 + 0.3 * z), c.cloud.color.copy(n).multiplyScalar(0.22 * i * d * B * z);
512
+ for (let g = 0; g < Ye.length; g++) {
513
+ const S = f.current[g];
514
+ if (!S || (S.visible = !!(M != null && M.hasSteps), !(M != null && M.hasSteps))) continue;
515
+ const L = Lt(M, g), _ = g / 3 * Math.PI * 2 + (ee ? 0 : G * 0.35);
516
+ S.position.set(Math.cos(_) * 0.72, Math.sin(_) * 0.72 * 0.42, Math.sin(_) * 0.3);
517
+ const K = 0.5 + 0.5 * Math.sin(G * 4);
518
+ S.scale.setScalar(L === "running" ? 1.25 + K * 0.3 : 1), S.rotation.y = ee ? 0 : G * 0.8, c.beads[g].color.copy(L === "running" ? Ge : L === "done" ? ve : L === "failed" ? _e : n).multiplyScalar((L === "queued" ? 0.35 : L === "running" ? 1.2 + K * 0.6 : 0.9) * i);
519
+ }
520
+ let R = s.y + 0.95 * P;
521
+ for (const g of he.agents.values()) g.run === e && g.live.y + 0.95 * g.scale + 0.45 > R && (R = g.live.y + 0.95 * g.scale + 0.45);
522
+ o.topY = o.topSet ? o.topY + (R - o.topY) * 0.12 : R, o.topSet = !0, a.set(s.x, o.topY, 0.5), (j = y.current) == null || j.position.copy(a);
523
+ }), /* @__PURE__ */ se(Ce, { children: [
524
+ /* @__PURE__ */ se("group", { ref: l, scale: 1e-4, children: [
525
+ /* @__PURE__ */ v("sprite", { material: c.cloud, scale: 4.2, position: [0, 0, -0.6] }),
526
+ /* @__PURE__ */ v("sprite", { material: c.core, scale: 1.8 }),
527
+ /* @__PURE__ */ v("primitive", { object: u.mesh }),
528
+ Ye.map((m) => /* @__PURE__ */ v("mesh", { ref: (E) => void (f.current[m] = E), geometry: po, material: c.beads[m], visible: !1 }, m))
529
+ ] }),
530
+ /* @__PURE__ */ v("group", { ref: y, children: e.run && /* @__PURE__ */ v(wo, { run: e.run, color: `#${n.getHexString()}` }) })
531
+ ] });
532
+ }
533
+ function wo({ run: e, color: s }) {
534
+ _t();
535
+ const a = e.status !== "started";
536
+ let o = 0;
537
+ for (const n of H.instances.values()) n.run === e.id && Ot(n) && o++;
538
+ const u = e.hasSteps ? [...Tt(e, { base: "#9fb3d1", current: "#ffc24a", done: "#cfe9ff" })] : [{ text: "nucleus", color: "#9fb3d1" }];
539
+ return u.push({ text: a ? " · complete" : ` · ${o} e-`, color: "#9fb3d1" }), !e.hasSteps && Nt(e) && u.push({ text: ` · ${Ut(e)}`, color: "#9fb3d1" }), /* @__PURE__ */ v(nt, { text: e.topic, secondary: u, color: s, size: 0.32, secondarySize: 0.25, maxWidth: 10, opacity: a ? 0.5 : 0.95, fadeMs: 400, anchorY: "bottom", pxRange: [10, 14] });
540
+ }
541
+ const bo = 140, yo = 0.17, pt = 40, et = 18, tt = 5, Le = 4, Mo = (e) => yo * t.MathUtils.clamp(Math.sqrt(48 / Math.max(1, e)), 1, 3), So = (
542
+ /* glsl */
543
+ `
544
+ attribute vec3 aCol; attribute float aFire;
545
+ varying vec3 vN; varying vec3 vV; varying vec3 vC; varying float vF;
546
+ void main(){
547
+ vec4 mv = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
548
+ vN = normalize(normalMatrix * mat3(instanceMatrix) * normal);
549
+ vV = normalize(-mv.xyz); vC = aCol; vF = aFire;
550
+ gl_Position = projectionMatrix * mv;
551
+ }`
552
+ ), xo = (
553
+ /* glsl */
554
+ `
555
+ varying vec3 vN; varying vec3 vV; varying vec3 vC; varying float vF;
556
+ void main(){
557
+ vec3 n = normalize(vN);
558
+ vec3 L = normalize(vec3(-0.45, 0.65, 0.6));
559
+ float d = max(dot(n, L), 0.0);
560
+ float rim = pow(1.0 - abs(dot(n, normalize(vV))), 2.4);
561
+ float spec = pow(max(dot(reflect(-L, n), normalize(vV)), 0.0), 28.0);
562
+ vec3 col = vC * (0.10 + 0.55 * d) + vC * rim * 0.75 + vec3(spec) * 0.35;
563
+ col += vC * vF * 1.8 + vec3(1.0) * vF * vF * 0.9;
564
+ gl_FragColor = vec4(col, 1.0);
565
+ }`
566
+ ), Co = () => new t.ShaderMaterial({
567
+ uniforms: { uColor: { value: new t.Color() } },
568
+ vertexShader: (
569
+ /* glsl */
570
+ `varying vec3 vN; varying vec3 vV;
571
+ void main(){ vec4 mv = modelViewMatrix * vec4(position,1.0); vN = normalize(normalMatrix*normal); vV = normalize(-mv.xyz); gl_Position = projectionMatrix*mv; }`
572
+ ),
573
+ fragmentShader: (
574
+ /* glsl */
575
+ `uniform vec3 uColor; varying vec3 vN; varying vec3 vV;
576
+ void main(){ float f = pow(1.0 - abs(dot(normalize(vN), normalize(vV))), 3.0); gl_FragColor = vec4(uColor * f, 1.0); }`
577
+ ),
578
+ transparent: !0,
579
+ depthWrite: !1,
580
+ blending: t.AdditiveBlending
581
+ }), Ao = new t.SphereGeometry(1, 48, 32);
582
+ function Vo({ galaxy: e }) {
583
+ const s = V(() => Xt(e, bo), [e]), a = s.nodes.length, o = V(() => {
584
+ const i = new Float32Array(a * 3), d = Math.PI * (3 - Math.sqrt(5)), b = s.ns, C = Mo(b || a);
585
+ for (let p = 0; p < b; p++) {
586
+ const w = (ae - C) * (0.3 + 0.7 * Math.cbrt(1 - p / b)), T = 1 - 2 * (p + 0.5) / b, N = Math.sqrt(1 - T * T);
587
+ i.set([Math.cos(p * d) * N * w, T * w, Math.sin(p * d) * N * w], p * 3);
588
+ }
589
+ jt(s, i, C * 3.2);
590
+ const r = s.nodes.map((p, w) => new t.Color(Kt[p.kind] ?? "#94a3b8").lerp(ie, 0.08 + w * 37 % 10 / 70).multiplyScalar(0.8)), F = new Map(s.nodes.map((p, w) => [p.id, w])), I = [], B = /* @__PURE__ */ new Set(), R = (p, w) => (i[p * 3] - i[w * 3]) ** 2 + (i[p * 3 + 1] - i[w * 3 + 1]) ** 2 + (i[p * 3 + 2] - i[w * 3 + 2]) ** 2, j = (p, w) => {
591
+ const T = p < w ? p * 4096 + w : w * 4096 + p;
592
+ p === w || B.has(T) || (B.add(T), I.push(p, w));
593
+ };
594
+ for (const p of s.links) {
595
+ const w = F.get(p.source), T = F.get(p.target);
596
+ w !== void 0 && T !== void 0 && R(w, T) < (ae * 0.9) ** 2 && j(w, T);
597
+ }
598
+ for (let p = 0; p < a; p++) {
599
+ let w = -1, T = 1 / 0;
600
+ for (let N = 0; N < a; N++) N !== p && R(p, N) < T && (T = R(p, N), w = N);
601
+ w >= 0 && j(p, w);
602
+ }
603
+ const g = new Float32Array(I.length * 3);
604
+ I.forEach((p, w) => g.set([i[p * 3], i[p * 3 + 1], i[p * 3 + 2]], w * 3));
605
+ const S = new t.BufferGeometry();
606
+ S.setAttribute("position", new t.BufferAttribute(g, 3)), S.setAttribute("color", new t.BufferAttribute(new Float32Array(I.length * 3), 3)), S.boundingSphere = new t.Sphere(new t.Vector3(), ae * 2);
607
+ const L = new t.SphereGeometry(1, 20, 14), _ = new t.InstancedBufferAttribute(new Float32Array(a * 3), 3), K = new t.InstancedBufferAttribute(new Float32Array(a), 1);
608
+ L.setAttribute("aCol", _), L.setAttribute("aFire", K);
609
+ const Y = new t.InstancedMesh(L, new t.ShaderMaterial({ vertexShader: So, fragmentShader: xo }), a);
610
+ Y.frustumCulled = !1;
611
+ const O = new t.Object3D();
612
+ for (let p = 0; p < a; p++)
613
+ O.position.set(i[p * 3], i[p * 3 + 1], i[p * 3 + 2]), O.scale.setScalar(C), O.updateMatrix(), Y.setMatrixAt(p, O.matrix), _.setXYZ(p, r[p].r, r[p].g, r[p].b);
614
+ return { pos: i, base: r, atomR: C, mesh: Y, aCol: _, aFire: K, o: O, bgeo: S, owner: Int32Array.from(I), fire: new Float32Array(a), fireC: Array.from({ length: a }, () => new t.Color()) };
615
+ }, [s, a]), u = V(
616
+ () => ({
617
+ beam: we("#fff", !0),
618
+ bond: we("#fff", !0),
619
+ core: ce(new t.Color("#7a5cff").multiplyScalar(0.35)),
620
+ cloud: ce(new t.Color("#1d4ed8").multiplyScalar(0.22)),
621
+ waves: Array.from({ length: tt }, Co)
622
+ }),
623
+ []
624
+ ), n = V(() => new vt(pt, et), []), c = V(() => new Xe(pt), []), l = U([]), f = U([]), y = U([]), m = U(Array(Le).fill("")), [E, G] = xt("left"), M = V(() => /* @__PURE__ */ new Map(), [s]), P = V(() => ({ v: new t.Vector3(), mid: new t.Vector3(), p: new t.Vector3(), c: new t.Color(), c2: new t.Color(), sp: new t.Vector3() }), []), z = (i) => {
625
+ let d = M.get(i);
626
+ return d === void 0 && M.set(i, d = qt(s, i) % a), d;
627
+ };
628
+ return Ae(({ clock: i, camera: d, size: b }) => {
629
+ if (!a) return;
630
+ const C = performance.now(), r = i.elapsedTime, { pos: F, base: I, fire: B, fireC: R, mesh: j, aCol: g, aFire: S, o: L } = o;
631
+ B.fill(0);
632
+ const { v: _, mid: K, p: Y, c: O, c2: p } = P;
633
+ n.begin(), c.begin();
634
+ let w = 0;
635
+ for (const h of H.flares) {
636
+ const A = z(h.node), X = (C - h.start) / 1e3, $ = H.instances.get(h.instance), k = h.op === "write", ne = k ? it : $ ? rt[$.type] : ve, J = X < 0.3 ? X / 0.3 : Math.exp(-(X - 0.3) * 1.3);
637
+ if (J > B[A] && (B[A] = J, R[A].copy(k ? ie : ne)), k && X < 1.6 && w < tt) {
638
+ const Q = l.current[w];
639
+ if (Q) {
640
+ const re = X / 1.6;
641
+ Q.visible = !0, Q.scale.setScalar(ae * (1.05 + re * 1.9)), Q.material.uniforms.uColor.value.copy(_e).lerp(ie, 0.3).multiplyScalar(0.9 * (1 - re) * (1 - re));
642
+ }
643
+ w++;
644
+ }
645
+ const de = ge(h.instance), ue = de ? Yt(de, P.sp) : void 0;
646
+ if (ue && X < 2) {
647
+ const Q = n.next();
648
+ if (Q < 0) continue;
649
+ _.set(F[A * 3], F[A * 3 + 1], F[A * 3 + 2]), K.copy(ue).add(_).multiplyScalar(0.5), K.z += 0.8;
650
+ const re = Math.min(1, X / 0.2) * Math.pow(1 - X / 2, 1.6), Re = k ? Math.min(1, X * 1.1) : 1 - Math.min(1, X * 1.1);
651
+ for (let fe = 0; fe < et; fe++)
652
+ for (let x = 0; x < 2; x++) {
653
+ const q = (fe + x) / et;
654
+ pe(ue, K, _, q, Y), n.P.setXYZ(Q + fe * 2 + x, Y.x, Y.y, Y.z);
655
+ const Pe = Math.exp(-(((q - Re) / 0.07) ** 2)) * 2.2;
656
+ p.copy(ne).multiplyScalar(re * (0.18 + Pe) * 0.8), n.C.setXYZ(Q + fe * 2 + x, p.r, p.g, p.b);
657
+ }
658
+ k ? c.add(ue, K, _, 0.86, 1, 0.38, it, re * 1.4) : c.add(ue, K, _, 0.12, -1, 0.38, ne, re * 1.4);
659
+ }
660
+ }
661
+ for (let h = w; h < tt; h++) l.current[h] && (l.current[h].visible = !1);
662
+ n.end(), c.end();
663
+ const T = ee ? 0 : 0.025;
664
+ for (let h = 0; h < a; h++) {
665
+ const A = B[h];
666
+ O.copy(I[h]), A > 0.01 && eo(O.multiplyScalar(1 - A * 0.5), R[h], A * 0.9), g.setXYZ(h, O.r, O.g, O.b), S.setX(h, A), L.position.set(F[h * 3] + Math.sin(r * 2.1 + h * 1.7) * T, F[h * 3 + 1] + Math.cos(r * 1.8 + h * 2.3) * T, F[h * 3 + 2] + Math.sin(r * 1.6 + h) * T), L.scale.setScalar(o.atomR * (1 + A * 0.35)), L.updateMatrix(), j.setMatrixAt(h, L.matrix);
667
+ }
668
+ j.instanceMatrix.needsUpdate = !0, g.needsUpdate = !0, S.needsUpdate = !0;
669
+ const N = o.bgeo.getAttribute("color"), te = o.owner;
670
+ for (let h = 0; h < te.length; h++) {
671
+ const A = Math.max(B[te[h]], B[te[h ^ 1]]), X = I[te[h]];
672
+ N.setXYZ(h, X.r * 0.22 + A * 0.5, X.g * 0.22 + A * 0.5, X.b * 0.22 + A * 0.55);
673
+ }
674
+ N.needsUpdate = !0;
675
+ const Ve = d, oe = 30 * Math.max(1, Ve.position.distanceTo(he.graph.pos)) * Math.tan(Ve.fov * Math.PI / 360) / Math.max(1, b.height) / Math.max(0.05, he.graph.scale), le = he.graph.out.x < -0.5 ? "right" : he.graph.out.x > 0.5 ? "left" : E;
676
+ le !== E && G(le);
677
+ const Ke = (le === "right" ? -1 : 1) * (ae + 0.3);
678
+ let W = 0;
679
+ for (let h = H.flares.length - 1; h >= 0 && W < Le; h--) {
680
+ const A = H.flares[h];
681
+ if (C - A.start > 2200) break;
682
+ if (A.area) continue;
683
+ let X = !1;
684
+ for (let ne = 0; ne < W; ne++) m.current[ne] === A.node && (X = !0);
685
+ if (X) continue;
686
+ const $ = f.current[W], k = y.current[W];
687
+ $ && k && (k.position.set(Ke, (1.5 - W) * oe, 0.5), m.current[W] !== A.node && ($.setText(`${A.op === "write" ? "wrote" : "read"} · ${A.node}`), $.setColor(A.op === "write" ? "#ff9ccf" : "#7dd3fc")), $.setOpacity(1)), m.current[W] = A.node, W++;
688
+ }
689
+ for (let h = W; h < Le; h++) {
690
+ const A = f.current[h];
691
+ A == null || A.setOpacity(0), m.current[h] = "";
692
+ }
693
+ }), /* @__PURE__ */ se(Ce, { children: [
694
+ /* @__PURE__ */ v("sprite", { material: u.cloud, scale: ae * 4.2, position: [0, 0, -1] }),
695
+ /* @__PURE__ */ v("sprite", { material: u.core, scale: ae * 1.6 }),
696
+ /* @__PURE__ */ v("lineSegments", { geometry: o.bgeo, material: u.bond, frustumCulled: !1 }),
697
+ /* @__PURE__ */ v("primitive", { object: o.mesh }),
698
+ u.waves.map((i, d) => /* @__PURE__ */ v("mesh", { ref: (b) => void (l.current[d] = b), geometry: Ao, material: i, visible: !1 }, d)),
699
+ /* @__PURE__ */ v("lineSegments", { geometry: n.geo, material: u.beam, frustumCulled: !1 }),
700
+ /* @__PURE__ */ v("primitive", { object: c.mesh }),
701
+ Array.from({ length: Le }, (i, d) => /* @__PURE__ */ v("group", { ref: (b) => void (y.current[d] = b), children: /* @__PURE__ */ v(nt, { ref: (b) => void (f.current[d] = b), text: "", font: "mono", anchorX: E, size: 0.24, opacity: 0, fadeMs: 250, pxRange: [8, 11.5] }) }, d)),
702
+ /* @__PURE__ */ v(Ht, { position: [0, -ae - 0.85, 0], prefix: "molecule · ", font: "mono", color: "#ff4fa8", letterSpacing: 0.04, size: 0.26, opacity: 0.75, pxRange: [8.5, 12] })
703
+ ] });
704
+ }
705
+ const Po = { tint: "#3db8ff", tintAmt: 0.25, gain: 0.9, halo: 0.8, size: 0.85 };
706
+ function zo() {
707
+ const e = V(() => {
708
+ const a = [], o = (n, c) => a.push(...n, ...c);
709
+ for (const n of [4, 8, 12, 16, 20, 24])
710
+ for (let l = 0; l < 160; l++) {
711
+ if (n > 4 && l % 4 === 3) continue;
712
+ const f = l / 160 * Math.PI * 2, y = (l + 1) / 160 * Math.PI * 2;
713
+ o([Math.cos(f) * n, Math.sin(f) * n, 0], [Math.cos(y) * n, Math.sin(y) * n, 0]);
714
+ }
715
+ for (let n = 0; n < 72; n++) {
716
+ const c = n / 72 * Math.PI * 2, l = 24, f = n % 6 === 0 ? 25.2 : 24.5;
717
+ o([Math.cos(c) * l, Math.sin(c) * l, 0], [Math.cos(c) * f, Math.sin(c) * f, 0]), n % 6 === 0 && o([Math.cos(c) * 3, Math.sin(c) * 3, 0], [Math.cos(c) * 24, Math.sin(c) * 24, 0]);
718
+ }
719
+ const u = new t.BufferGeometry();
720
+ return u.setAttribute("position", new t.Float32BufferAttribute(a, 3)), u;
721
+ }, []), s = V(() => we(new t.Color("#3db8ff").multiplyScalar(0.075)), []);
722
+ return /* @__PURE__ */ v("lineSegments", { geometry: e, material: s, position: [0, 0, -9] });
723
+ }
724
+ const Eo = new t.Vector3();
725
+ function Go(e) {
726
+ for (const s of he.runs.values()) {
727
+ const a = xe.get(s.id);
728
+ a && e(a, 0.8 * Math.max(0.6, Se.scale));
729
+ const o = Oe.get(s.id);
730
+ o && e(Eo.set(o.x, o.y + 0.5, o.z), 1.2);
731
+ }
732
+ }
733
+ function Oo() {
734
+ return /* @__PURE__ */ se(
735
+ Wt,
736
+ {
737
+ title: "atom · agent orbitals",
738
+ subtitle: "Each run is an atom: the nucleus is the run hub, agents are electrons on its shells, subagents orbit their parent · LLM calls emit photons sized by tokens · ◎ MCP detectors with backend sensors · graph = molecule on the side · exit = decay",
739
+ className: "atom-root",
740
+ preset: "radial",
741
+ plane: "xy",
742
+ camera: { position: [0, 3.5, 36], fov: 46 },
743
+ bg: "#02040c",
744
+ gl: { antialias: !0 },
745
+ fit: { nRef: 4, min: 0.62, max: 1.6, minRadius: 5.5 },
746
+ agentRadius: 0.75,
747
+ graph: { natural: ae * 1.15, radius: 2.3 },
748
+ peripheryGap: 3.8,
749
+ Background: /* @__PURE__ */ v(zo, {}),
750
+ Agent: co,
751
+ RunMarker: go,
752
+ mcpStyle: Po,
753
+ GraphResource: Vo,
754
+ cluster: { radius: 1.3, variant: "orb" },
755
+ extents: Go,
756
+ PostFX: /* @__PURE__ */ se(bt, { multisampling: 0, children: [
757
+ /* @__PURE__ */ v(yt, { mipmapBlur: !0, intensity: 1.05, luminanceThreshold: 0.22, luminanceSmoothing: 0.25, radius: 0.7 }),
758
+ /* @__PURE__ */ v(Mt, { eskil: !1, offset: 0.25, darkness: 0.85 })
759
+ ] }),
760
+ children: [
761
+ /* @__PURE__ */ v(lo, {}),
762
+ /* @__PURE__ */ v(uo, {}),
763
+ /* @__PURE__ */ v(oo, {})
764
+ ]
765
+ }
766
+ );
767
+ }
768
+ export {
769
+ Oo as default
770
+ };