@newtone-dev/ui-react-web 0.65.0 → 0.67.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.
Files changed (59) hide show
  1. package/dist/icon/icon.css +8 -0
  2. package/dist/icon/icon.d.ts +7 -1
  3. package/dist/icon/icon.d.ts.map +1 -1
  4. package/dist/icon/icon.js +3 -2
  5. package/dist/icon/icon.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/nav-list/nav-list.css +18 -1
  11. package/dist/nav-list/nav-list.d.ts +23 -2
  12. package/dist/nav-list/nav-list.d.ts.map +1 -1
  13. package/dist/nav-list/nav-list.js +44 -6
  14. package/dist/nav-list/nav-list.js.map +1 -1
  15. package/dist/node-map/beads-gl.d.ts +39 -1
  16. package/dist/node-map/beads-gl.d.ts.map +1 -1
  17. package/dist/node-map/beads-gl.js +266 -34
  18. package/dist/node-map/beads-gl.js.map +1 -1
  19. package/dist/node-map/index.d.ts +1 -1
  20. package/dist/node-map/index.d.ts.map +1 -1
  21. package/dist/node-map/index.js +1 -1
  22. package/dist/node-map/index.js.map +1 -1
  23. package/dist/node-map/node-map-3d.d.ts +7 -1
  24. package/dist/node-map/node-map-3d.d.ts.map +1 -1
  25. package/dist/node-map/node-map-3d.js +524 -98
  26. package/dist/node-map/node-map-3d.js.map +1 -1
  27. package/dist/node-map/node-map.css +93 -3
  28. package/dist/node-map/node-map.d.ts +51 -2
  29. package/dist/node-map/node-map.d.ts.map +1 -1
  30. package/dist/node-map/node-map.js +9 -3
  31. package/dist/node-map/node-map.js.map +1 -1
  32. package/dist/node-map/space.d.ts +121 -0
  33. package/dist/node-map/space.d.ts.map +1 -1
  34. package/dist/node-map/space.js +551 -1
  35. package/dist/node-map/space.js.map +1 -1
  36. package/dist/pick/index.d.ts +29 -0
  37. package/dist/pick/index.d.ts.map +1 -0
  38. package/dist/pick/index.js +45 -0
  39. package/dist/pick/index.js.map +1 -0
  40. package/dist/pick/palettes.d.ts +2 -0
  41. package/dist/pick/palettes.d.ts.map +1 -0
  42. package/dist/pick/palettes.js +3 -0
  43. package/dist/pick/palettes.js.map +1 -0
  44. package/dist/pick/pick.css +634 -0
  45. package/dist/shade-picker/index.d.ts +5 -0
  46. package/dist/shade-picker/index.d.ts.map +1 -0
  47. package/dist/shade-picker/index.js +3 -0
  48. package/dist/shade-picker/index.js.map +1 -0
  49. package/dist/shade-picker/shade-picker.css +52 -0
  50. package/dist/shade-picker/shade-picker.d.ts +31 -0
  51. package/dist/shade-picker/shade-picker.d.ts.map +1 -0
  52. package/dist/shade-picker/shade-picker.js +61 -0
  53. package/dist/shade-picker/shade-picker.js.map +1 -0
  54. package/dist/split/split.css +1 -0
  55. package/dist/split/split.d.ts +9 -1
  56. package/dist/split/split.d.ts.map +1 -1
  57. package/dist/split/split.js +2 -2
  58. package/dist/split/split.js.map +1 -1
  59. package/package.json +13 -1
@@ -3,7 +3,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
3
3
  import { useCallback, useEffect, useId, useMemo, useRef, useState, } from 'react';
4
4
  import { MapOver, MapTools } from './over.js';
5
5
  import { beadsOn, rgbOf } from './beads-gl.js';
6
- import { boundsOf, FIT, fitted, focalOf, seen, spaceOf, turned, unturned, } from './space.js';
6
+ import { boundsOf, branchOf, layoutOf, placePills, FIT, fitted, focalOf, seen, turned, unturned, } from './space.js';
7
7
  // A mark's radius, in pixels, at the target's depth.
8
8
  const MARK = 4;
9
9
  // How many names show at once when nothing is chosen, nearest first; and how many of the chosen one's ties.
@@ -54,14 +54,67 @@ const PAINTS = {
54
54
  fresh: 'var(--newtone-role-text-accent)',
55
55
  solid: 'var(--newtone-role-text-primary)',
56
56
  warning: 'var(--newtone-role-text-warning)',
57
+ error: 'var(--newtone-role-text-error)',
57
58
  support: 'var(--newtone-color-system-support-12, var(--newtone-role-text-secondary))',
58
59
  ring: 'color-mix(in oklab, var(--newtone-role-surface-primary), var(--newtone-role-text-accent) 40%)',
59
60
  dashed: 'color-mix(in oklab, var(--newtone-role-surface-primary), var(--newtone-role-text-primary) 28%)',
60
61
  ground: 'var(--newtone-role-surface-primary)',
61
- // A tie is a plain line in the divider's colour (2026-12-04, Joshua: lines, not tubes).
62
- tie: 'var(--newtone-role-divider-secondary)',
62
+ // A tie is a plain line (2026-12-04, Joshua: lines, not tubes), in a colour that stands 3 to 1 off the ground
63
+ // (2026-12-05), as a control's outline must; TIE_CONTRAST keeps the depth fade from undoing it.
64
+ tie: 'var(--newtone-role-divider-primary)',
63
65
  };
66
+ // The least contrast a tie keeps against the map's ground, however far back it sits; and how wide it is drawn, in CSS
67
+ // pixels: a hairline, and a little wider while fresh, never 1.5 or more (2026-12-05).
68
+ const TIE_CONTRAST = 3;
69
+ const TIE_WIDTH = 1;
70
+ const FRESH_TIE_WIDTH = 1.4;
71
+ // What a colour weighs to the eye (WCAG relative luminance, from sRGB 0..1), and two colours' contrast.
72
+ const luminance = ([r, g, b]) => {
73
+ const lin = (v) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
74
+ return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
75
+ };
76
+ export const contrastOf = (a, b) => {
77
+ const [x, y] = [luminance(a), luminance(b)].sort((p, q) => q - p);
78
+ return (x + 0.05) / (y + 0.05);
79
+ };
80
+ /**
81
+ * The least opacity a line of `color` drawn over `ground` may have and still stand `want` to 1 off it: what the depth
82
+ * fade may go down to. 1 when even the full colour does not reach it.
83
+ */
84
+ export function floorOf(color, ground, want = TIE_CONTRAST) {
85
+ const at = (a) => contrastOf(color.map((c, i) => c * a + ground[i] * (1 - a)), ground);
86
+ if (at(1) < want)
87
+ return 1;
88
+ let [lo, hi] = [0, 1];
89
+ for (let i = 0; i < 20; i++) {
90
+ const mid = (lo + hi) / 2;
91
+ if (at(mid) >= want)
92
+ hi = mid;
93
+ else
94
+ lo = mid;
95
+ }
96
+ return hi;
97
+ }
64
98
  const ALPHA = { dashed: 0.45 };
99
+ // A pill (s_map_pills): its name's size and weight at the target's depth, its height, the room either side of its name,
100
+ // how much depth may grow or shrink it, and the deepest fog it takes, so a far topic still reads.
101
+ const PILL_FONT = 12;
102
+ const PILL_H = 24;
103
+ const PILL_PAD = 10;
104
+ const PILL_SMALLEST = 0.75;
105
+ const PILL_BIGGEST = 1.3;
106
+ const PILL_FOG = 0.6;
107
+ const PILL_CHARS = 40;
108
+ // How see-through a pill is when it finds no room on the screen this frame (it then takes no presses).
109
+ const PILL_FADED = 0.25;
110
+ // A pill's tint of its look's colour at rest and pointed at; pressed or chosen it is filled with it.
111
+ const PILL_REST = 0.1;
112
+ const PILL_HOVER = 0.24;
113
+ // How far a press may wander, in CSS pixels, and still be a press rather than a turn: a mouse or pen, and a finger.
114
+ const PRESS_SLOP = 6;
115
+ const TOUCH_SLOP = 10;
116
+ // How long a branch takes to fade in or out, in ms (s_map_branch).
117
+ const BRANCH_FADE = 250;
65
118
  const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
66
119
  const lerp = (a, b, t) => a + (b - a) * t;
67
120
  /**
@@ -71,7 +124,9 @@ const lerp = (a, b, t) => a + (b - a) * t;
71
124
  * pointed node, its ties, and the nearest `named` nodes, never more than a few at once. Drawn in SVG with the same
72
125
  * looks as the flat map; a hidden list of the nodes, in a steady order, is what Tab and assistive tech reach.
73
126
  */
74
- export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labels, fresh, light = 'world', }) {
127
+ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labels, fresh, light = 'world', home, layout = 'force', branch, hoverNames = 'many', blur = true, links = 'contrast', }) {
128
+ const one = hoverNames === 'one';
129
+ const plain = links === 'plain';
75
130
  const svg = useRef(null);
76
131
  const root = useRef(null);
77
132
  const canvas = useRef(null);
@@ -94,6 +149,7 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
94
149
  }, []);
95
150
  // Each look's colour, read from the tokens, and read again when the mode or the style changes.
96
151
  const [paints, setPaints] = useState(null);
152
+ const [font, setFont] = useState({ family: 'sans-serif', weight: '600' });
97
153
  useEffect(() => {
98
154
  const read = () => {
99
155
  const el = probe.current;
@@ -103,6 +159,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
103
159
  for (const [k, css] of Object.entries(PAINTS))
104
160
  out[k] = rgbOf(css, el);
105
161
  setPaints(out);
162
+ const cs = getComputedStyle(el);
163
+ const family = (svg.current ? getComputedStyle(svg.current).fontFamily : '') ||
164
+ cs.fontFamily ||
165
+ 'sans-serif';
166
+ setFont((f) => f.family === family && f.weight === cs.fontWeight
167
+ ? f
168
+ : { family, weight: cs.fontWeight || '600' });
106
169
  };
107
170
  read();
108
171
  const watch = new MutationObserver(read);
@@ -118,10 +181,60 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
118
181
  // The beads' shared paints (a satin body per look, the light inside, the shadow), named for this map alone.
119
182
  const paint = `newtone-node-map-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
120
183
  const isFresh = useMemo(() => new Set(fresh ?? []), [fresh]);
121
- const space = useMemo(() => spaceOf(nodes, edges), [nodes, edges]);
184
+ const space = useMemo(() => layoutOf(nodes, edges, layout, home), [nodes, edges, layout, home]);
185
+ // The branch drawn alone, if any (s_map_branch); null draws everything.
186
+ const visible = useMemo(() => (branch ? branchOf(nodes, edges, home, branch) : null), [nodes, edges, home, branch]);
187
+ const drawn = (id) => !visible || visible.has(id);
188
+ // Each pill's name as drawn and its width at scale 1, measured in the pills' own font.
189
+ const pillText = useMemo(() => {
190
+ const m = new Map();
191
+ const pills = nodes.filter((n) => n.shape === 'pill');
192
+ if (!pills.length)
193
+ return m;
194
+ const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;
195
+ let x = null;
196
+ try {
197
+ x = c?.getContext('2d') ?? null;
198
+ }
199
+ catch {
200
+ x = null;
201
+ }
202
+ if (x)
203
+ x.font = `${font.weight} ${PILL_FONT}px ${font.family}`;
204
+ for (const n of pills) {
205
+ const text = clip(n.label, PILL_CHARS);
206
+ const w = x?.measureText(text).width || text.length * PILL_FONT * 0.55;
207
+ m.set(n.id, { text, w });
208
+ }
209
+ return m;
210
+ }, [nodes, font]);
122
211
  const bounds = useMemo(() => boundsOf(space.values()), [space]);
123
212
  const [box, setBox] = useState({ w: 0, h: 0 });
124
- const [cam, setCam] = useState(() => fitted(space.values()));
213
+ // The node the map turns round while nothing is chosen (2026-12-05), if the consumer names one: every view that
214
+ // fits the map keeps it in the middle, standing back as far again as it is from the map's own middle.
215
+ const homeAt = home ? space.get(home) : undefined;
216
+ const homeNow = useRef(homeAt);
217
+ homeNow.current = homeAt;
218
+ // A burst is a ball round its home (2026-12-05): its views fit that ball, as `firstView` says, so a lopsided map
219
+ // does not stand farther off than it needs to.
220
+ const homeReach = useMemo(() => {
221
+ if (layout !== 'burst' || !homeAt)
222
+ return 0;
223
+ let r = 0;
224
+ for (const p of space.values())
225
+ r = Math.max(r, Math.hypot(p.x - homeAt.x, p.y - homeAt.y, p.z - homeAt.z));
226
+ return r;
227
+ }, [layout, homeAt, space]);
228
+ const around = (c) => {
229
+ const h = homeNow.current;
230
+ if (!h)
231
+ return c;
232
+ if (homeReach > 0)
233
+ return { ...c, target: h, dist: homeReach * FIT };
234
+ const off = Math.hypot(h.x - c.target.x, h.y - c.target.y, h.z - c.target.z);
235
+ return { ...c, target: h, dist: c.dist + off };
236
+ };
237
+ const [cam, setCam] = useState(() => around(fitted(space.values())));
125
238
  const camNow = useRef(cam);
126
239
  camNow.current = cam;
127
240
  // Where the camera is flying to, if anywhere: the frames ease it there.
@@ -135,9 +248,10 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
135
248
  }, []);
136
249
  // Fitted again only when what is drawn changes, keeping how it is turned.
137
250
  useEffect(() => {
138
- setCam((c) => fitted(space.values(), c));
251
+ setCam((c) => around(fitted(space.values(), c)));
139
252
  goal.current = null;
140
- }, [space]);
253
+ // eslint-disable-next-line react-hooks/exhaustive-deps
254
+ }, [space, home]);
141
255
  useEffect(() => {
142
256
  const el = svg.current;
143
257
  if (!el)
@@ -174,7 +288,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
174
288
  Math.abs(yaw - (g.yaw ?? yaw)) < 0.002 &&
175
289
  Math.abs(pitch - (g.pitch ?? pitch)) < 0.002;
176
290
  return done
177
- ? { ...c, target: g.target, dist: g.dist, yaw: g.yaw ?? c.yaw, pitch: g.pitch ?? c.pitch }
291
+ ? {
292
+ ...c,
293
+ target: g.target,
294
+ dist: g.dist,
295
+ yaw: g.yaw ?? c.yaw,
296
+ pitch: g.pitch ?? c.pitch,
297
+ }
178
298
  : { ...c, target: t, dist, yaw, pitch };
179
299
  });
180
300
  if (done)
@@ -185,26 +305,36 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
185
305
  frame = requestAnimationFrame(step);
186
306
  return () => cancelAnimationFrame(frame);
187
307
  }, [flying, bounds.reach]);
188
- // Choosing a node flies to it, a little nearer than it was; clearing leaves the camera where it is.
308
+ // Choosing a node flies to it, a little nearer than it was. Clearing flies back to the home node, standing at least
309
+ // as far off as the first view (2026-12-05); with no home node it leaves the camera where it is.
189
310
  const placeOf = useCallback((id) => space.get(id), [space]);
311
+ const chosenOnce = useRef(false);
190
312
  useEffect(() => {
191
- if (!selected)
313
+ if (!selected) {
314
+ const h = homeNow.current;
315
+ if (!h || !chosenOnce.current)
316
+ return;
317
+ const first = around(fitted(space.values()));
318
+ fly({ target: h, dist: Math.max(camNow.current.dist, first.dist) });
192
319
  return;
320
+ }
193
321
  const p = placeOf(selected);
194
322
  if (!p)
195
323
  return;
324
+ chosenOnce.current = true;
196
325
  fly({ target: p, dist: Math.min(camNow.current.dist, bounds.reach * 1.4) });
326
+ // eslint-disable-next-line react-hooks/exhaustive-deps
197
327
  }, [selected, placeOf, bounds.reach, fly]);
198
328
  const clampDist = (d) => Math.min(bounds.reach * FARTHEST, Math.max(bounds.reach * CLOSEST, d));
199
329
  const flyBy = (by) => {
200
330
  goal.current = null;
201
331
  setCam((c) => ({ ...c, dist: clampDist(c.dist / by) }));
202
332
  };
203
- const fit = () => fly(fitted(space.values(), cam));
333
+ const fit = () => fly(around(fitted(space.values(), cam)));
204
334
  // The double click on the ground (2026-12-04, Joshua): back to the first view, fitted and turned as the map opens;
205
335
  // from there, turned half way round, so a second double click shows the back.
206
- const home = () => {
207
- const first = fitted(space.values());
336
+ const backHome = () => {
337
+ const first = around(fitted(space.values()));
208
338
  const atHome = Math.abs(cam.dist - first.dist) < bounds.reach * 0.02 &&
209
339
  Math.hypot(cam.target.x - first.target.x, cam.target.y - first.target.y, cam.target.z - first.target.z) <
210
340
  bounds.reach * 0.02 &&
@@ -229,8 +359,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
229
359
  // A drag orbits; two fingers pinch. As on the flat map, the pointer is taken only once it moves.
230
360
  const down = useRef(new Map());
231
361
  const moved = useRef(false);
362
+ // Where each pointer went down, to tell a press that wobbled from a drag.
363
+ const start = useRef(new Map());
232
364
  const press = (e) => {
233
365
  down.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
366
+ start.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
234
367
  moved.current = false;
235
368
  interacting.current = true;
236
369
  };
@@ -242,7 +375,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
242
375
  const others = [...down.current.entries()]
243
376
  .filter(([id]) => id !== e.pointerId)
244
377
  .map(([, p]) => p);
245
- if (!moved.current && Math.abs(now.x - was.x) + Math.abs(now.y - was.y) > 2) {
378
+ // A hand's press wobbles a few pixels (2026-12-05: a real click on a pill moved 2 to 3px and was taken for a
379
+ // turn, so nothing was chosen): only past PRESS_SLOP (TOUCH_SLOP for a finger) is it a drag.
380
+ const slop = e.pointerType === 'touch' ? TOUCH_SLOP : PRESS_SLOP;
381
+ const from = start.current.get(e.pointerId) ?? was;
382
+ if (!moved.current && Math.hypot(now.x - from.x, now.y - from.y) > slop) {
246
383
  moved.current = true;
247
384
  if (!e.currentTarget.hasPointerCapture(e.pointerId))
248
385
  e.currentTarget.setPointerCapture(e.pointerId);
@@ -265,6 +402,7 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
265
402
  };
266
403
  const release = (e) => {
267
404
  down.current.delete(e.pointerId);
405
+ start.current.delete(e.pointerId);
268
406
  if (!down.current.size)
269
407
  interacting.current = false;
270
408
  };
@@ -281,16 +419,27 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
281
419
  }, [nodes, space, cam, f, box.w, box.h]);
282
420
  const near = bounds.reach * 0.05;
283
421
  const inView = (id) => (at.get(id)?.depth ?? -1) > near;
284
- const order = useMemo(() => nodes
422
+ // Every node in view, farthest first (what the spheres' painter may still be fading), and those of them drawn.
423
+ const allOrder = useMemo(() => nodes
285
424
  .filter((n) => inView(n.id))
286
425
  .sort((a, b) => at.get(b.id).depth - at.get(a.id).depth),
287
426
  // eslint-disable-next-line react-hooks/exhaustive-deps
288
427
  [nodes, at]);
428
+ const order = useMemo(() => (visible ? allOrder.filter((n) => visible.has(n.id)) : allOrder), [allOrder, visible]);
289
429
  // How faint a node is by its depth: the nearest full, the farthest FAINTEST.
290
430
  const [nearest, farthest] = order.length
291
431
  ? [at.get(order[order.length - 1].id).depth, at.get(order[0].id).depth]
292
432
  : [0, 1];
293
433
  const fade = (depth) => farthest - nearest < 1e-6 ? 1 : lerp(1, FAINTEST, (depth - nearest) / (farthest - nearest));
434
+ // A tie fades with depth only as far as it still stands TIE_CONTRAST off the ground (2026-12-05).
435
+ const tieFloor = useMemo(() => (paints ? floorOf(paints.tie, paints.ground) : FAINTEST), [paints]);
436
+ const tieFade = (depth) => Math.max(fade(depth), tieFloor);
437
+ // A plain tie (s_map_link_plain) fades at each end as a sphere there sinks into the fog; in the nearer half of the
438
+ // depth it keeps the 3 to 1 floor, which lets go evenly over the farther half.
439
+ const plainFade = (depth) => {
440
+ const t = depthT(depth);
441
+ return Math.max(1 - SPHERE_FOG * t, tieFloor * Math.min(1, 2 * (1 - t)));
442
+ };
294
443
  const ties = useMemo(() => {
295
444
  const m = new Map();
296
445
  for (const e of edges) {
@@ -304,12 +453,142 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
304
453
  return m;
305
454
  }, [edges]);
306
455
  const byId = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]);
307
- const lit = (id) => !selected || id === selected || !!ties.get(selected)?.has(id);
456
+ // What choosing keeps lit (2026-12-05): a chosen pill (or the branch shown) keeps all it holds and its way home, so a
457
+ // branch is never dimmed by its own pill; a chosen bead keeps its ties, among what is drawn.
458
+ const pillChosen = !!selected && (byId.get(selected)?.shape === 'pill' || selected === branch);
459
+ const litSet = useMemo(() => {
460
+ if (!selected)
461
+ return null;
462
+ if (pillChosen)
463
+ return branchOf(nodes, edges, home, selected);
464
+ return new Set([selected, ...(ties.get(selected) ?? [])]);
465
+ }, [selected, pillChosen, nodes, edges, home, ties]);
466
+ const lit = (id) => !litSet || litSet.has(id);
467
+ // Whether a tie stays bright while something is chosen: both ends lit, and touching the chosen bead (any tie of a
468
+ // chosen pill's branch).
469
+ const tieOn = (from, to) => lit(from) && lit(to) && (!selected || pillChosen || from === selected || to === selected);
308
470
  const [pointed, setPointed] = useState(null);
471
+ const pointedNow = useRef(pointed);
472
+ pointedNow.current = pointed;
473
+ // The pill a pointer is held down on, drawn pressed until let go.
474
+ const [held, setHeld] = useState(null);
309
475
  const focus = pointed ?? selected;
476
+ const isPill = (id) => byId.get(id)?.shape === 'pill';
310
477
  // A big graph draws its marks smaller, so a crowd of them still reads as separate nodes.
311
478
  const crowd = Math.min(1, Math.max(CROWDED, Math.sqrt(ROOMY / Math.max(1, nodes.length))));
312
479
  const sizeOf = (s) => Math.min(BIGGEST, Math.max(SMALLEST, s)) * crowd;
480
+ // A pill's size where it falls: its scale, half width and half height in CSS pixels.
481
+ const pillOf = (id, s) => {
482
+ const scale = Math.min(PILL_BIGGEST, Math.max(PILL_SMALLEST, s));
483
+ const hh = (PILL_H / 2) * scale;
484
+ const hw = Math.max(hh, ((pillText.get(id)?.w ?? 0) / 2 + PILL_PAD) * scale);
485
+ return { scale, hw, hh };
486
+ };
487
+ // Where each pill stands on the screen this frame (s_map_pills, 2026-12-05): pills are drawn over everything, so two
488
+ // must never stand on each other. Topics take their places first, then the nearer pills; a pill that would stand on
489
+ // one already placed moves up or down by its own height until it is free, and one that finds no room is faded and
490
+ // takes no presses.
491
+ const pillPlaces = useMemo(() => {
492
+ const out = new Map();
493
+ const list = order.filter((n) => n.shape === 'pill');
494
+ if (!list.length)
495
+ return out;
496
+ const sizes = new Map(list.map((n) => [n.id, pillOf(n.id, at.get(n.id).s)]));
497
+ const placed = placePills(list.map((n) => {
498
+ const p = at.get(n.id);
499
+ const { hw, hh } = sizes.get(n.id);
500
+ return {
501
+ id: n.id,
502
+ x: p.x,
503
+ y: p.y,
504
+ hw,
505
+ hh,
506
+ depth: p.depth,
507
+ topic: !!home && !!ties.get(home)?.has(n.id),
508
+ };
509
+ }));
510
+ for (const [id, q] of placed) {
511
+ const z = sizes.get(id);
512
+ out.set(id, {
513
+ x: q.x,
514
+ y: q.y,
515
+ faded: q.faded,
516
+ hw: z.hw * q.shrink,
517
+ hh: z.hh * q.shrink,
518
+ scale: z.scale * q.shrink,
519
+ });
520
+ }
521
+ return out;
522
+ // eslint-disable-next-line react-hooks/exhaustive-deps
523
+ }, [order, at, pillText, home, ties]);
524
+ // Where a node is drawn: a pill where it stands this frame, anything else where it falls.
525
+ const drawnAt = (id) => {
526
+ const q = pillPlaces.get(id);
527
+ return q ? { x: q.x, y: q.y } : at.get(id);
528
+ };
529
+ // The node under a point: a pill first (it is drawn over everything; the nearest one when two are under it); else,
530
+ // with `hoverNames="one"` (s_map_hover_one), the bead whose middle is nearest the point.
531
+ const pillAt = (x, y) => {
532
+ let best = null;
533
+ let bestDepth = Infinity;
534
+ for (const [id, q] of pillPlaces) {
535
+ if (q.faded || Math.abs(x - q.x) > q.hw + 3 || Math.abs(y - q.y) > q.hh + 3)
536
+ continue;
537
+ const d = at.get(id).depth;
538
+ if (d < bestDepth) {
539
+ bestDepth = d;
540
+ best = id;
541
+ }
542
+ }
543
+ return best;
544
+ };
545
+ const nearestAt = (x, y) => {
546
+ const pill = pillAt(x, y);
547
+ if (pill)
548
+ return pill;
549
+ let best = null;
550
+ let bestD = Infinity;
551
+ for (const n of order) {
552
+ if (n.shape === 'pill')
553
+ continue;
554
+ const p = at.get(n.id);
555
+ const d = Math.hypot(x - p.x, y - p.y);
556
+ if (d <= n.r * sizeOf(p.s) + 8 && d < bestD) {
557
+ bestD = d;
558
+ best = n.id;
559
+ }
560
+ }
561
+ return best;
562
+ };
563
+ const pointAt = (e) => {
564
+ const el = svg.current;
565
+ if (!el)
566
+ return null;
567
+ const b = el.getBoundingClientRect();
568
+ return nearestAt(e.clientX - b.left, e.clientY - b.top);
569
+ };
570
+ // What a press lands on, decided where it went down (2026-12-05: a press on a pill's name must never fall to the
571
+ // ground, whatever is redrawn before it is let go): a pill under the point; else the bead nearest it (one name),
572
+ // or the node drawn under it; else the ground (null).
573
+ const pressAt = (e) => {
574
+ const el = svg.current;
575
+ if (!el)
576
+ return null;
577
+ const b = el.getBoundingClientRect();
578
+ const [x, y] = [e.clientX - b.left, e.clientY - b.top];
579
+ const pill = pillAt(x, y);
580
+ if (pill)
581
+ return pill;
582
+ if (one) {
583
+ const n = nearestAt(x, y);
584
+ if (n)
585
+ return n;
586
+ }
587
+ const hit = e.target?.closest?.('[data-node]');
588
+ const id = hit?.getAttribute('data-node');
589
+ return id && drawn(id) ? id : null;
590
+ };
591
+ const pressed = useRef(null);
313
592
  // The names shown: the chosen and pointed nodes, then the focus's nearest ties, then the nearest named nodes still
314
593
  // lit, never more than a few; in that order each takes its place, and a name that would cross one already placed
315
594
  // is left out, so names never pile up.
@@ -322,21 +601,27 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
322
601
  wanted.push(n);
323
602
  }
324
603
  };
325
- const byId = new Map(order.map((n) => [n.id, n]));
326
- if (selected)
327
- want(byId.get(selected));
328
- if (focus)
329
- want(byId.get(focus));
330
- const byNear = [...order].reverse();
331
- if (focus)
604
+ // A pill carries its own name.
605
+ const byId = new Map(order.filter((n) => n.shape !== 'pill').map((n) => [n.id, n]));
606
+ if (one) {
607
+ want(byId.get(pointed ?? selected ?? ''));
608
+ }
609
+ else {
610
+ if (selected)
611
+ want(byId.get(selected));
612
+ if (focus)
613
+ want(byId.get(focus));
614
+ const byNear = [...byId.values()].reverse();
615
+ if (focus)
616
+ byNear
617
+ .filter((n) => ties.get(focus)?.has(n.id))
618
+ .slice(0, BESIDE)
619
+ .forEach(want);
332
620
  byNear
333
- .filter((n) => ties.get(focus)?.has(n.id))
334
- .slice(0, BESIDE)
621
+ .filter((n) => (n.named || isFresh.has(n.id)) && lit(n.id))
622
+ .slice(0, NAMES)
335
623
  .forEach(want);
336
- byNear
337
- .filter((n) => (n.named || isFresh.has(n.id)) && lit(n.id))
338
- .slice(0, NAMES)
339
- .forEach(want);
624
+ }
340
625
  const placed = [];
341
626
  const kept = new Set();
342
627
  for (const n of wanted) {
@@ -354,11 +639,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
354
639
  }
355
640
  return order.filter((n) => kept.has(n.id));
356
641
  // eslint-disable-next-line react-hooks/exhaustive-deps
357
- }, [order, focus, selected, ties, at, isFresh]);
642
+ }, [order, focus, selected, ties, at, isFresh, one, pointed]);
358
643
  // How deep a bead sits in the fog: none nearest, FOG farthest; deeper still when the chosen node does not touch it.
644
+ const depthT = (d) => farthest - nearest < 1e-6
645
+ ? 0
646
+ : Math.min(1, Math.max(0, (d - nearest) / (farthest - nearest)));
359
647
  const fogOf = (id) => {
360
- const d = at.get(id).depth;
361
- const t = farthest - nearest < 1e-6 ? 0 : (d - nearest) / (farthest - nearest);
648
+ const t = depthT(at.get(id).depth);
362
649
  return lit(id) ? FOG * t : Math.max(FOG * t, DIMMED_FOG);
363
650
  };
364
651
  const opacityOf = (id) => {
@@ -380,7 +667,12 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
380
667
  if (!f)
381
668
  return out;
382
669
  const list = nodes
383
- .map((n) => ({ id: n.id, p: space.get(n.id), R: (n.r * crowd * bounds.reach * FIT) / f }))
670
+ .filter((n) => n.shape !== 'pill')
671
+ .map((n) => ({
672
+ id: n.id,
673
+ p: space.get(n.id),
674
+ R: (n.r * crowd * bounds.reach * FIT) / f,
675
+ }))
384
676
  .filter((x) => !!x.p);
385
677
  const L = worldLight;
386
678
  for (const a of list) {
@@ -410,7 +702,13 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
410
702
  }, [nodes, space, worldLight, f, crowd, bounds.reach]);
411
703
  // What fades: each sphere's share of the fresh colour, and how far the rest has stepped back. Kept between frames
412
704
  // and eased toward what is wanted now, so a fresh sphere shows in accent at once and fades back over FADE.
413
- const ease = useRef({ fresh: new Map(), quiet: 0, last: 0, painted: 0 });
705
+ const ease = useRef({
706
+ fresh: new Map(),
707
+ shown: new Map(),
708
+ quiet: 0,
709
+ last: 0,
710
+ painted: 0,
711
+ });
414
712
  const paintNow = useRef(() => false);
415
713
  paintNow.current = () => {
416
714
  const b = beads.current;
@@ -420,7 +718,8 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
420
718
  const now = performance.now();
421
719
  const dt = e.last ? Math.min(100, now - e.last) : 16;
422
720
  e.last = now;
423
- const still = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
721
+ const still = typeof matchMedia === 'function' &&
722
+ matchMedia('(prefers-reduced-motion: reduce)').matches;
424
723
  const by = still ? 1 : dt / FADE;
425
724
  let moving = false;
426
725
  const toward = (v, to) => {
@@ -440,6 +739,19 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
440
739
  e.fresh.set(edge.id, was === undefined ? want : toward(was, want));
441
740
  }
442
741
  e.quiet = toward(e.quiet, isFresh.size && !selected ? QUIET : 0);
742
+ // A branch fades in and out quicker than the fresh do.
743
+ const byBranch = still ? 1 : dt / BRANCH_FADE;
744
+ for (const n of nodes) {
745
+ const want = drawn(n.id) ? 1 : 0;
746
+ const was = e.shown.get(n.id);
747
+ if (was === undefined || Math.abs(was - want) <= byBranch)
748
+ e.shown.set(n.id, want);
749
+ else {
750
+ moving = true;
751
+ e.shown.set(n.id, was + Math.sign(want - was) * byBranch);
752
+ }
753
+ }
754
+ const shownOf = (id) => e.shown.get(id) ?? 1;
443
755
  const mixed = (a, c, t) => [lerp(a[0], c[0], t), lerp(a[1], c[1], t), lerp(a[2], c[2], t)];
444
756
  const view = (id) => {
445
757
  const p = at.get(id);
@@ -448,15 +760,59 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
448
760
  return { p, r, R: (r * p.depth) / Math.max(f, 1) };
449
761
  };
450
762
  const beadsNow = [];
763
+ const pillsNow = [];
451
764
  let maxR = 0;
452
- for (const n of order) {
453
- const { p, r, R } = view(n.id);
454
- maxR = Math.max(maxR, R);
765
+ for (const n of allOrder) {
766
+ const w = shownOf(n.id);
767
+ if (w <= 0)
768
+ continue;
455
769
  const fr = e.fresh.get(n.id) ?? 0;
456
770
  const lifted = n.id === selected || n.id === pointed;
771
+ if (n.shape === 'pill') {
772
+ const p = at.get(n.id);
773
+ // Where it stands this frame; a pill fading out of a branch, where it falls.
774
+ const q = pillPlaces.get(n.id) ?? {
775
+ ...pillOf(n.id, p.s),
776
+ x: p.x,
777
+ y: p.y,
778
+ faded: false,
779
+ };
780
+ const { scale, hw, hh } = q;
781
+ const R = (hh * p.depth) / Math.max(f, 1);
782
+ maxR = Math.max(maxR, R);
783
+ const ink = mixed(n.look === 'plain' || n.look === 'dashed' ? paints.solid : paints[n.look], paints.fresh, fr);
784
+ const pressed = n.id === selected || n.id === held;
785
+ const fill = pressed
786
+ ? ink
787
+ : mixed(paints.ground, ink, n.id === pointed ? PILL_HOVER : PILL_REST);
788
+ // Its name in the ink or the ground, whichever stands farther off its fill.
789
+ const text = contrastOf(paints.solid, fill) >= contrastOf(paints.ground, fill)
790
+ ? paints.solid
791
+ : paints.ground;
792
+ const fog = lifted
793
+ ? 0
794
+ : Math.min(PILL_FOG, Math.max(fogOf(n.id) * (SPHERE_FOG / FOG), e.quiet * (1 - fr)));
795
+ pillsNow.push({
796
+ x: q.x,
797
+ y: q.y,
798
+ depth: p.depth,
799
+ R,
800
+ hw,
801
+ hh,
802
+ scale,
803
+ text: pillText.get(n.id)?.text ?? '',
804
+ fill: mixed(fill, paints.ground, fog),
805
+ edge: mixed(ink, paints.ground, fog),
806
+ ink: mixed(text, paints.ground, fog),
807
+ alpha: w * (q.faded ? PILL_FADED : 1),
808
+ });
809
+ continue;
810
+ }
811
+ const { p, r, R } = view(n.id);
812
+ maxR = Math.max(maxR, R);
457
813
  const fog = lifted ? 0 : Math.max(fogOf(n.id) * (SPHERE_FOG / FOG), e.quiet * (1 - fr));
458
814
  const occId = occluders.get(n.id);
459
- const occ = occId && at.has(occId) ? view(occId) : null;
815
+ const occ = occId && at.has(occId) && drawn(occId) ? view(occId) : null;
460
816
  beadsNow.push({
461
817
  x: p.x,
462
818
  y: p.y,
@@ -467,9 +823,11 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
467
823
  vz: p.v.z,
468
824
  R,
469
825
  color: mixed(paints[n.look], paints.fresh, fr),
470
- alpha: lerp(ALPHA[n.look] ?? 1, 1, fr),
826
+ alpha: lerp(ALPHA[n.look] ?? 1, 1, fr) * w,
471
827
  fog,
472
- occluder: occ ? { vx: occ.p.v.x, vy: occ.p.v.y, vz: occ.p.v.z, R: occ.R } : undefined,
828
+ occluder: occ
829
+ ? { vx: occ.p.v.x, vy: occ.p.v.y, vz: occ.p.v.z, R: occ.R }
830
+ : undefined,
473
831
  });
474
832
  }
475
833
  const tiesNow = [];
@@ -478,22 +836,42 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
478
836
  const c = at.get(edge.to);
479
837
  if (!a || !c || a.depth <= near || c.depth <= near)
480
838
  continue;
839
+ const w = Math.min(shownOf(edge.from), shownOf(edge.to));
840
+ if (w <= 0)
841
+ continue;
481
842
  const fr = e.fresh.get(edge.id) ?? 0;
482
- const on = lit(edge.from) &&
483
- lit(edge.to) &&
484
- (!selected || edge.from === selected || edge.to === selected);
485
- const o = fade((a.depth + c.depth) / 2);
486
- const alpha = on ? o : Math.min(selected ? DIMMED_TIE : 0.18, o);
843
+ const on = tieOn(edge.from, edge.to);
844
+ // A tie ends where its pill stands this frame.
845
+ const [ea, ec] = [drawnAt(edge.from), drawnAt(edge.to)];
846
+ const quietBy = (1 - e.quiet * (1 - fr)) * w;
847
+ const dimmed = (o) => (on ? o : Math.min(selected ? DIMMED_TIE : 0.18, o));
848
+ if (plain) {
849
+ tiesNow.push({
850
+ ax: ea.x,
851
+ ay: ea.y,
852
+ ad: a.depth,
853
+ bx: ec.x,
854
+ by: ec.y,
855
+ bd: c.depth,
856
+ width: lerp(TIE_WIDTH, FRESH_TIE_WIDTH, fr),
857
+ color: mixed(paints.tie, paints.fresh, fr),
858
+ alpha: dimmed(plainFade(a.depth)) * quietBy,
859
+ alphaB: dimmed(plainFade(c.depth)) * quietBy,
860
+ });
861
+ continue;
862
+ }
863
+ const o = tieFade((a.depth + c.depth) / 2);
864
+ const alpha = dimmed(o);
487
865
  tiesNow.push({
488
- ax: a.x,
489
- ay: a.y,
866
+ ax: ea.x,
867
+ ay: ea.y,
490
868
  ad: a.depth,
491
- bx: c.x,
492
- by: c.y,
869
+ bx: ec.x,
870
+ by: ec.y,
493
871
  bd: c.depth,
494
- width: lerp(1, 2, fr),
872
+ width: lerp(TIE_WIDTH, FRESH_TIE_WIDTH, fr),
495
873
  color: mixed(paints.tie, paints.fresh, fr),
496
- alpha: alpha * (1 - e.quiet * (1 - fr)),
874
+ alpha: alpha * quietBy,
497
875
  });
498
876
  }
499
877
  const lightNow = light === 'screen' ? LIGHT : turned(worldLight.x, worldLight.y, worldLight.z, cam);
@@ -504,10 +882,15 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
504
882
  ties: tiesNow,
505
883
  light: [lightNow.x, lightNow.y, lightNow.z],
506
884
  ground: paints.ground,
507
- focus: cam.dist,
885
+ // In focus: the nearest beads (2026-12-05); only what is behind them blurs, more the farther back.
886
+ focus: nearest + maxR * 2,
508
887
  span: bounds.reach * 1.2,
509
888
  near: nearest - maxR * 2,
510
889
  far: farthest + maxR * 2,
890
+ blur,
891
+ plainTies: plain,
892
+ pills: pillsNow,
893
+ pillFont: { family: font.family, weight: font.weight, size: PILL_FONT },
511
894
  });
512
895
  // How long since the last frame while the person turns or flies it: a card that cannot keep up steps down.
513
896
  if (interacting.current || goal.current) {
@@ -536,57 +919,100 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
536
919
  '--newtone-node-map-sheen-accent': `url(#${paint}-accent)`,
537
920
  '--newtone-node-map-sheen-solid': `url(#${paint}-solid)`,
538
921
  '--newtone-node-map-sheen-warning': `url(#${paint}-warning)`,
922
+ '--newtone-node-map-sheen-error': `url(#${paint}-error)`,
539
923
  '--newtone-node-map-sheen-support': `url(#${paint}-support)`,
540
- }, onWheel: wheel, onPointerDown: press, onPointerMove: drag, onPointerUp: release, onPointerCancel: release, onClick: () => {
541
- if (!moved.current)
542
- onSelect(null);
924
+ }, onWheel: wheel, onPointerDown: (e) => {
925
+ press(e);
926
+ // Decided now, where it went down: see pressAt.
927
+ const id = pressAt(e);
928
+ pressed.current = { pointer: e.pointerId, id };
929
+ if (id && isPill(id))
930
+ setHeld(id);
931
+ }, onPointerMove: (e) => {
932
+ drag(e);
933
+ // A press that turned into a turn of the map leaves the pill it began on.
934
+ if (moved.current && held)
935
+ setHeld(null);
936
+ // One name (s_map_hover_one): the node nearest the pointer, found by the map, not by what is on top.
937
+ if (one && !(down.current.size && moved.current)) {
938
+ const id = pointAt(e);
939
+ if (id !== pointedNow.current)
940
+ setPointed(id);
941
+ }
942
+ }, onPointerUp: (e) => {
943
+ release(e);
944
+ setHeld(null);
945
+ const p = pressed.current;
946
+ pressed.current = null;
947
+ // A press that did not move chooses what it went down on, or clears on the ground.
948
+ if (p && p.pointer === e.pointerId && !moved.current)
949
+ onSelect(p.id);
950
+ }, onPointerCancel: (e) => {
951
+ release(e);
952
+ setHeld(null);
953
+ pressed.current = null;
954
+ }, onPointerLeave: () => {
955
+ setHeld(null);
956
+ if (one)
957
+ setPointed(null);
543
958
  }, onDoubleClick: (e) => {
544
959
  // A double click on the ground fits the whole map (2026-12-04), as on Slides' plane.
545
960
  if (!e.target.closest('.newtone-node-map-node, .newtone-node-map-label'))
546
- home();
547
- }, children: [_jsxs("defs", { children: [['plain', 'accent', 'solid', 'warning', 'support'].map((look) => (_jsxs("radialGradient", { id: `${paint}-${look}`, className: "newtone-node-map-sheen", "data-look": look, fx: "0.34", fy: "0.3", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.3" }), _jsx("stop", { offset: "0.72" }), _jsx("stop", { offset: "0.93" }), _jsx("stop", { offset: "1" })] }, look))), ['soft', 'bright'].map((glow) => (_jsxs("radialGradient", { id: `${paint}-bulb-${glow}`, className: "newtone-node-map-glow", "data-glow": glow, cy: "0.56", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.3" }), _jsx("stop", { offset: "1" })] }, glow))), _jsxs("radialGradient", { id: `${paint}-shadow`, className: "newtone-node-map-umbra", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.55" }), _jsx("stop", { offset: "1" })] })] }), box.w && !gl
961
+ backHome();
962
+ }, children: [_jsxs("defs", { children: [['plain', 'accent', 'solid', 'warning', 'error', 'support'].map((look) => (_jsxs("radialGradient", { id: `${paint}-${look}`, className: "newtone-node-map-sheen", "data-look": look, fx: "0.34", fy: "0.3", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.3" }), _jsx("stop", { offset: "0.72" }), _jsx("stop", { offset: "0.93" }), _jsx("stop", { offset: "1" })] }, look))), ['soft', 'bright'].map((glow) => (_jsxs("radialGradient", { id: `${paint}-bulb-${glow}`, className: "newtone-node-map-glow", "data-glow": glow, cy: "0.56", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.3" }), _jsx("stop", { offset: "1" })] }, glow))), _jsxs("radialGradient", { id: `${paint}-shadow`, className: "newtone-node-map-umbra", children: [_jsx("stop", { offset: "0" }), _jsx("stop", { offset: "0.55" }), _jsx("stop", { offset: "1" })] })] }), box.w && !gl
548
963
  ? edges.map((edge) => {
549
964
  const s = at.get(edge.from);
550
965
  const t = at.get(edge.to);
551
966
  if (!s || !t || s.depth <= near || t.depth <= near)
552
967
  return null;
553
- const on = lit(edge.from) &&
554
- lit(edge.to) &&
555
- (!selected || edge.from === selected || edge.to === selected);
968
+ if (!drawn(edge.from) || !drawn(edge.to))
969
+ return null;
970
+ const o = plain
971
+ ? (plainFade(s.depth) + plainFade(t.depth)) / 2
972
+ : tieFade((s.depth + t.depth) / 2);
973
+ const on = tieOn(edge.from, edge.to);
556
974
  return (_jsx("line", { className: "newtone-node-map-edge", "data-fresh": isFresh.has(edge.id) ? '' : undefined, style: {
557
- opacity: on
558
- ? fade((s.depth + t.depth) / 2)
559
- : Math.min(selected ? DIMMED_TIE : 0.18, fade((s.depth + t.depth) / 2)),
560
- }, x1: s.x, y1: s.y, x2: t.x, y2: t.y }, edge.id));
975
+ opacity: on ? o : Math.min(selected ? DIMMED_TIE : 0.18, o),
976
+ }, x1: drawnAt(edge.from).x, y1: drawnAt(edge.from).y, x2: drawnAt(edge.to).x, y2: drawnAt(edge.to).y }, edge.id));
561
977
  })
562
978
  : null, box.w
563
- ? order.map((n) => {
564
- const p = at.get(n.id);
565
- const r = n.r * sizeOf(p.s);
566
- const fog = fogOf(n.id);
567
- const detailed = r >= DETAIL;
568
- const bright = n.look === 'accent' || isFresh.has(n.id);
569
- return (_jsxs("g", { className: "newtone-node-map-node", "data-look": n.look, "data-fresh": isFresh.has(n.id) ? '' : undefined, "data-selected": n.id === selected ? '' : undefined, "data-pointed": n.id === pointed ? '' : undefined, transform: `translate(${p.x},${p.y})`, onClick: (e) => {
570
- e.stopPropagation();
571
- if (!moved.current)
572
- onSelect(n.id);
573
- }, onPointerEnter: () => setPointed(n.id), onPointerLeave: () => setPointed((x) => (x === n.id ? null : x)), children: [_jsx("circle", { r: r + 8, className: "newtone-node-map-hit" }), gl ? (
574
- // The sphere is drawn below, on the canvas; here only what is pressed, and the
575
- // ring of the one chosen or pointed at.
576
- n.id === selected || n.id === pointed ? (_jsx("circle", { r: r + 3, className: "newtone-node-map-focus", style: { fill: 'none' } })) : null) : (_jsxs(_Fragment, { children: [detailed ? (_jsx("circle", { className: "newtone-node-map-shadow", cx: r * 0.3, cy: r * 0.45, r: r * 1.25, style: {
577
- fill: `url(#${paint}-shadow)`,
578
- stroke: 'none',
579
- opacity: 1 - fog,
580
- } })) : null, _jsx("circle", { r: r, className: "newtone-node-map-body" }), detailed ? (_jsx("circle", { className: "newtone-node-map-bulb", r: r * 0.62, style: {
581
- fill: `url(#${paint}-bulb-${bright ? 'bright' : 'soft'})`,
582
- stroke: 'none',
583
- } })) : null, _jsx("circle", { className: "newtone-node-map-veil", r: r + 2.5, style: {
584
- '--newtone-node-map-fog': fog,
585
- fill: 'var(--newtone-role-surface-primary)',
586
- stroke: 'none',
587
- } })] })), n.mark ? (_jsx("circle", { className: "newtone-node-map-mark", r: MARK, cx: r * Math.SQRT1_2, cy: -r * Math.SQRT1_2 })) : null] }, n.id));
588
- })
589
- : null, _jsxs("g", { className: "newtone-node-map-labels", children: [focus && box.w
979
+ ? // Pills last: they are drawn over everything, and take presses over the beads under them.
980
+ [
981
+ ...order.filter((n) => n.shape !== 'pill'),
982
+ ...order.filter((n) => n.shape === 'pill' && pillPlaces.has(n.id)),
983
+ ].map((n) => {
984
+ const p = at.get(n.id);
985
+ const r = n.r * sizeOf(p.s);
986
+ const fog = fogOf(n.id);
987
+ const detailed = r >= DETAIL;
988
+ const bright = n.look === 'accent' || isFresh.has(n.id);
989
+ const pill = n.shape === 'pill' ? pillPlaces.get(n.id) : null;
990
+ const where = pill ?? p;
991
+ return (_jsx("g", { "data-node": n.id, style: pill?.faded
992
+ ? { pointerEvents: 'none', opacity: PILL_FADED }
993
+ : undefined, className: "newtone-node-map-node", "data-look": n.look, "data-shape": pill ? 'pill' : undefined, "data-fresh": isFresh.has(n.id) ? '' : undefined, "data-selected": n.id === selected ? '' : undefined, "data-pointed": n.id === pointed ? '' : undefined, "data-held": n.id === held ? '' : undefined, transform: `translate(${where.x},${where.y})`, onPointerEnter: one ? undefined : () => setPointed(n.id), onPointerLeave: one
994
+ ? undefined
995
+ : () => setPointed((x) => (x === n.id ? null : x)), children: pill ? (_jsxs(_Fragment, { children: [_jsx("rect", { className: "newtone-node-map-hit", x: -pill.hw - 4, y: -pill.hh - 4, width: pill.hw * 2 + 8, height: pill.hh * 2 + 8, rx: pill.hh + 4 }), gl ? (n.id === selected ? (_jsx("rect", { className: "newtone-node-map-focus", x: -pill.hw - 3, y: -pill.hh - 3, width: pill.hw * 2 + 6, height: pill.hh * 2 + 6, rx: pill.hh + 3, style: { fill: 'none' } })) : null) : (_jsxs(_Fragment, { children: [_jsx("rect", { className: "newtone-node-map-pill", x: -pill.hw, y: -pill.hh, width: pill.hw * 2, height: pill.hh * 2, rx: pill.hh }), _jsx("text", { className: "newtone-node-map-pill-name", textAnchor: "middle", dominantBaseline: "central", style: { fontSize: PILL_FONT * pill.scale }, children: pillText.get(n.id)?.text }), _jsx("rect", { className: "newtone-node-map-veil", x: -pill.hw - 1, y: -pill.hh - 1, width: pill.hw * 2 + 2, height: pill.hh * 2 + 2, rx: pill.hh + 1, style: {
996
+ '--newtone-node-map-fog': Math.min(PILL_FOG, fog),
997
+ fill: 'var(--newtone-role-surface-primary)',
998
+ stroke: 'none',
999
+ } })] })), n.mark ? (_jsx("circle", { className: "newtone-node-map-mark", r: MARK, cx: pill.hw - pill.hh * 0.3, cy: -pill.hh * 0.75 })) : null] })) : (_jsxs(_Fragment, { children: [_jsx("circle", { r: r + 8, className: "newtone-node-map-hit" }), gl ? (
1000
+ // The sphere is drawn below, on the canvas; here only what is pressed, and the
1001
+ // ring of the one chosen or pointed at.
1002
+ n.id === selected || n.id === pointed ? (_jsx("circle", { r: r + 3, className: "newtone-node-map-focus", style: { fill: 'none' } })) : null) : (_jsxs(_Fragment, { children: [detailed ? (_jsx("circle", { className: "newtone-node-map-shadow", cx: r * 0.3, cy: r * 0.45, r: r * 1.25, style: {
1003
+ fill: `url(#${paint}-shadow)`,
1004
+ stroke: 'none',
1005
+ opacity: 1 - fog,
1006
+ } })) : null, _jsx("circle", { r: r, className: "newtone-node-map-body" }), detailed ? (_jsx("circle", { className: "newtone-node-map-bulb", r: r * 0.62, style: {
1007
+ fill: `url(#${paint}-bulb-${bright ? 'bright' : 'soft'})`,
1008
+ stroke: 'none',
1009
+ } })) : null, _jsx("circle", { className: "newtone-node-map-veil", r: r + 2.5, style: {
1010
+ '--newtone-node-map-fog': fog,
1011
+ fill: 'var(--newtone-role-surface-primary)',
1012
+ stroke: 'none',
1013
+ } })] })), n.mark ? (_jsx("circle", { className: "newtone-node-map-mark", r: MARK, cx: r * Math.SQRT1_2, cy: -r * Math.SQRT1_2 })) : null] })) }, n.id));
1014
+ })
1015
+ : null, _jsxs("g", { className: "newtone-node-map-labels", children: [focus && box.w && !one
590
1016
  ? edges
591
1017
  .filter((e) => e.label && (e.from === focus || e.to === focus))
592
1018
  .map((e) => {
@@ -594,16 +1020,16 @@ export function NodeMap3D({ nodes, edges, selected, onSelect, head, legend, labe
594
1020
  const t = at.get(e.to);
595
1021
  if (!s || !t || s.depth <= near || t.depth <= near)
596
1022
  return null;
1023
+ if (!drawn(e.from) || !drawn(e.to))
1024
+ return null;
597
1025
  return (_jsx("text", { className: "newtone-node-map-edge-label", x: (s.x + t.x) / 2, y: (s.y + t.y) / 2 - 4, textAnchor: "middle", children: clip(e.label, 28) }, e.id));
598
1026
  })
599
1027
  : null, box.w
600
1028
  ? shown.map((n) => {
601
1029
  const p = at.get(n.id);
602
- return (_jsx("text", { className: "newtone-node-map-label", "data-style": n.labelStyle, "data-fresh": isFresh.has(n.id) ? '' : undefined, style: { opacity: opacityOf(n.id) }, x: p.x, y: p.y + n.r * sizeOf(p.s) + 15, textAnchor: "middle", onClick: (e) => {
603
- e.stopPropagation();
604
- if (!moved.current)
605
- onSelect(n.id);
606
- }, onPointerEnter: () => setPointed(n.id), onPointerLeave: () => setPointed((x) => (x === n.id ? null : x)), children: clip(n.label, n.id === focus ? 60 : 32) }, n.id));
1030
+ return (_jsx("text", { className: "newtone-node-map-label", "data-style": n.labelStyle, "data-fresh": isFresh.has(n.id) ? '' : undefined, style: { opacity: opacityOf(n.id) }, x: p.x, y: p.y + n.r * sizeOf(p.s) + 15, textAnchor: "middle", "data-node": n.id, onPointerEnter: one ? undefined : () => setPointed(n.id), onPointerLeave: one
1031
+ ? undefined
1032
+ : () => setPointed((x) => (x === n.id ? null : x)), children: clip(n.label, n.id === focus ? 60 : 32) }, n.id));
607
1033
  })
608
1034
  : null] })] }), _jsx("ul", { className: "newtone-node-map-list", role: "group", "aria-label": labels.map, children: nodes.map((n) => (_jsx("li", { children: _jsx("button", { type: "button", "aria-pressed": n.id === selected, onClick: () => onSelect(n.id), onFocus: () => setPointed(n.id), onBlur: () => setPointed((x) => (x === n.id ? null : x)), children: n.name }) }, n.id))) }), _jsx(MapOver, { head: head, legend: legend, sphere: gl }), _jsx(MapTools, { labels: labels, zoomIn: () => flyBy(1.4), zoomOut: () => flyBy(1 / 1.4), fit: fit }), _jsx("span", { ref: probe, className: "newtone-node-map-probe", "aria-hidden": "true" })] }));
609
1035
  }