@almadar/ui 5.64.0 → 5.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 (31) hide show
  1. package/dist/avl/index.cjs +241 -71
  2. package/dist/avl/index.d.cts +10 -2
  3. package/dist/avl/index.d.ts +1 -0
  4. package/dist/avl/index.js +244 -75
  5. package/dist/components/avl/derive-edit-focus.d.ts +8 -0
  6. package/dist/components/core/organisms/ChatBar.d.ts +31 -0
  7. package/dist/components/core/organisms/SubagentTracePanel.d.ts +50 -0
  8. package/dist/components/core/organisms/index.d.ts +3 -0
  9. package/dist/components/core/organisms/trace-edit-focus.d.ts +14 -0
  10. package/dist/components/game/atoms/ChoiceButton.d.ts +7 -1
  11. package/dist/components/game/molecules/HealthPanel.d.ts +3 -0
  12. package/dist/components/game/molecules/IsometricCanvas.d.ts +4 -1
  13. package/dist/components/game/molecules/PowerupSlots.d.ts +3 -0
  14. package/dist/components/game/molecules/TurnPanel.d.ts +3 -0
  15. package/dist/components/game/molecules/index.d.ts +1 -0
  16. package/dist/components/game/molecules/three/index.cjs +6 -6
  17. package/dist/components/game/molecules/three/index.js +6 -6
  18. package/dist/components/game/organisms/HexStrategyBoard.d.ts +37 -0
  19. package/dist/components/game/organisms/index.d.ts +2 -0
  20. package/dist/components/game/organisms/utils/isometric.d.ts +20 -7
  21. package/dist/components/index.cjs +1241 -53
  22. package/dist/components/index.js +1243 -60
  23. package/dist/hooks/index.cjs +94 -0
  24. package/dist/hooks/index.d.ts +1 -0
  25. package/dist/hooks/index.js +95 -2
  26. package/dist/hooks/useAgentTrace.d.ts +85 -0
  27. package/dist/providers/index.cjs +210 -45
  28. package/dist/providers/index.js +213 -48
  29. package/dist/runtime/index.cjs +212 -47
  30. package/dist/runtime/index.js +215 -50
  31. package/package.json +2 -2
@@ -9923,16 +9923,26 @@ var init_useUnitSpriteAtlas = __esm({
9923
9923
  });
9924
9924
 
9925
9925
  // components/game/organisms/utils/isometric.ts
9926
- function isoToScreen(tileX, tileY, scale, baseOffsetX) {
9926
+ function isoToScreen(tileX, tileY, scale, baseOffsetX, layout = "isometric") {
9927
9927
  const scaledTileWidth = exports.TILE_WIDTH * scale;
9928
9928
  const scaledFloorHeight = exports.FLOOR_HEIGHT * scale;
9929
+ if (layout === "hex") {
9930
+ const screenX2 = tileX * scaledTileWidth + (tileY & 1) * (scaledTileWidth / 2) + baseOffsetX;
9931
+ const screenY2 = tileY * (scaledFloorHeight * 0.75);
9932
+ return { x: screenX2, y: screenY2 };
9933
+ }
9929
9934
  const screenX = (tileX - tileY) * (scaledTileWidth / 2) + baseOffsetX;
9930
9935
  const screenY = (tileX + tileY) * (scaledFloorHeight / 2);
9931
9936
  return { x: screenX, y: screenY };
9932
9937
  }
9933
- function screenToIso(screenX, screenY, scale, baseOffsetX) {
9938
+ function screenToIso(screenX, screenY, scale, baseOffsetX, layout = "isometric") {
9934
9939
  const scaledTileWidth = exports.TILE_WIDTH * scale;
9935
9940
  const scaledFloorHeight = exports.FLOOR_HEIGHT * scale;
9941
+ if (layout === "hex") {
9942
+ const row = Math.round(screenY / (scaledFloorHeight * 0.75));
9943
+ const col = Math.round((screenX - (row & 1) * (scaledTileWidth / 2) - baseOffsetX) / scaledTileWidth);
9944
+ return { x: col, y: row };
9945
+ }
9936
9946
  const adjustedX = screenX - baseOffsetX;
9937
9947
  const tileX = (adjustedX / (scaledTileWidth / 2) + screenY / (scaledFloorHeight / 2)) / 2;
9938
9948
  const tileY = (screenY / (scaledFloorHeight / 2) - adjustedX / (scaledTileWidth / 2)) / 2;
@@ -9982,6 +9992,7 @@ function IsometricCanvas({
9982
9992
  tileHoverEvent,
9983
9993
  tileLeaveEvent,
9984
9994
  // Rendering options
9995
+ tileLayout = "isometric",
9985
9996
  scale = 0.4,
9986
9997
  debug: debug2 = false,
9987
9998
  backgroundImage = "",
@@ -10051,13 +10062,17 @@ function IsometricCanvas({
10051
10062
  );
10052
10063
  const sortedTiles = React79.useMemo(() => {
10053
10064
  const tiles = [...tilesProp];
10054
- tiles.sort((a, b) => {
10055
- const depthA = a.x + a.y;
10056
- const depthB = b.x + b.y;
10057
- return depthA !== depthB ? depthA - depthB : a.y - b.y;
10058
- });
10065
+ if (tileLayout === "hex") {
10066
+ tiles.sort((a, b) => a.y !== b.y ? a.y - b.y : a.x - b.x);
10067
+ } else {
10068
+ tiles.sort((a, b) => {
10069
+ const depthA = a.x + a.y;
10070
+ const depthB = b.x + b.y;
10071
+ return depthA !== depthB ? depthA - depthB : a.y - b.y;
10072
+ });
10073
+ }
10059
10074
  return tiles;
10060
- }, [tilesProp]);
10075
+ }, [tilesProp, tileLayout]);
10061
10076
  const gridWidth = React79.useMemo(() => {
10062
10077
  if (sortedTiles.length === 0) return 0;
10063
10078
  return Math.max(...sortedTiles.map((t2) => t2.x)) + 1;
@@ -10171,18 +10186,19 @@ function IsometricCanvas({
10171
10186
  miniCanvas.width = mW;
10172
10187
  miniCanvas.height = mH;
10173
10188
  mCtx.clearRect(0, 0, mW, mH);
10174
- const allScreenPos = sortedTiles.map((t2) => isoToScreen(t2.x, t2.y, scale, baseOffsetX));
10189
+ const allScreenPos = sortedTiles.map((t2) => isoToScreen(t2.x, t2.y, scale, baseOffsetX, tileLayout));
10175
10190
  const minX = Math.min(...allScreenPos.map((p2) => p2.x));
10176
10191
  const maxX = Math.max(...allScreenPos.map((p2) => p2.x + scaledTileWidth));
10177
10192
  const minY = Math.min(...allScreenPos.map((p2) => p2.y));
10178
- const maxY = Math.max(...allScreenPos.map((p2) => p2.y + scaledTileHeight));
10193
+ const tileBottomExtent = tileLayout === "hex" ? scaledTileWidth : scaledTileHeight;
10194
+ const maxY = Math.max(...allScreenPos.map((p2) => p2.y + tileBottomExtent));
10179
10195
  const worldW = maxX - minX;
10180
10196
  const worldH = maxY - minY;
10181
10197
  const scaleM = Math.min(mW / worldW, mH / worldH) * 0.9;
10182
10198
  const offsetMx = (mW - worldW * scaleM) / 2;
10183
10199
  const offsetMy = (mH - worldH * scaleM) / 2;
10184
10200
  for (const tile of sortedTiles) {
10185
- const pos = isoToScreen(tile.x, tile.y, scale, baseOffsetX);
10201
+ const pos = isoToScreen(tile.x, tile.y, scale, baseOffsetX, tileLayout);
10186
10202
  const mx = (pos.x - minX) * scaleM + offsetMx;
10187
10203
  const my = (pos.y - minY) * scaleM + offsetMy;
10188
10204
  const mTileW = scaledTileWidth * scaleM;
@@ -10198,7 +10214,7 @@ function IsometricCanvas({
10198
10214
  }
10199
10215
  for (const unit of units) {
10200
10216
  if (!unit.position) continue;
10201
- const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX);
10217
+ const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX, tileLayout);
10202
10218
  const mx = (pos.x + scaledTileWidth / 2 - minX) * scaleM + offsetMx;
10203
10219
  const my = (pos.y + scaledTileHeight / 2 - minY) * scaleM + offsetMy;
10204
10220
  mCtx.fillStyle = unit.team === "player" ? "#60a5fa" : unit.team === "enemy" ? "#f87171" : "#9ca3af";
@@ -10214,7 +10230,7 @@ function IsometricCanvas({
10214
10230
  mCtx.strokeStyle = "rgba(255, 255, 255, 0.8)";
10215
10231
  mCtx.lineWidth = 1;
10216
10232
  mCtx.strokeRect(vLeft, vTop, vW, vH);
10217
- }, [showMinimap, sortedTiles, units, scale, baseOffsetX, scaledTileWidth, scaledTileHeight, scaledFloorHeight, viewportSize, cameraRef]);
10233
+ }, [showMinimap, sortedTiles, units, tileLayout, scale, baseOffsetX, scaledTileWidth, scaledTileHeight, scaledFloorHeight, viewportSize, cameraRef]);
10218
10234
  const draw = React79.useCallback((animTime) => {
10219
10235
  const canvas = canvasRef.current;
10220
10236
  if (!canvas) return;
@@ -10254,7 +10270,7 @@ function IsometricCanvas({
10254
10270
  const visTop = cam.y - viewportSize.height / cam.zoom;
10255
10271
  const visBottom = cam.y + viewportSize.height * 2 / cam.zoom;
10256
10272
  for (const tile of sortedTiles) {
10257
- const pos = isoToScreen(tile.x, tile.y, scale, baseOffsetX);
10273
+ const pos = isoToScreen(tile.x, tile.y, scale, baseOffsetX, tileLayout);
10258
10274
  if (pos.x + scaledTileWidth < visLeft || pos.x > visRight || pos.y + scaledTileHeight < visTop || pos.y > visBottom) {
10259
10275
  continue;
10260
10276
  }
@@ -10267,7 +10283,7 @@ function IsometricCanvas({
10267
10283
  const drawW = scaledTileWidth;
10268
10284
  const drawH = scaledTileWidth * (img.naturalHeight / img.naturalWidth);
10269
10285
  const drawX = pos.x;
10270
- const drawY = pos.y + scaledTileHeight - drawH;
10286
+ const drawY = tileLayout === "hex" ? pos.y : pos.y + scaledTileHeight - drawH;
10271
10287
  ctx.drawImage(img, drawX, drawY, drawW, drawH);
10272
10288
  }
10273
10289
  } else {
@@ -10334,12 +10350,13 @@ function IsometricCanvas({
10334
10350
  }
10335
10351
  }
10336
10352
  const sortedFeatures = [...features].sort((a, b) => {
10353
+ if (tileLayout === "hex") return a.y !== b.y ? a.y - b.y : a.x - b.x;
10337
10354
  const depthA = a.x + a.y;
10338
10355
  const depthB = b.x + b.y;
10339
10356
  return depthA !== depthB ? depthA - depthB : a.y - b.y;
10340
10357
  });
10341
10358
  for (const feature of sortedFeatures) {
10342
- const pos = isoToScreen(feature.x, feature.y, scale, baseOffsetX);
10359
+ const pos = isoToScreen(feature.x, feature.y, scale, baseOffsetX, tileLayout);
10343
10360
  if (pos.x + scaledTileWidth < visLeft || pos.x > visRight || pos.y + scaledTileHeight < visTop || pos.y > visBottom) {
10344
10361
  continue;
10345
10362
  }
@@ -10374,12 +10391,13 @@ function IsometricCanvas({
10374
10391
  }
10375
10392
  const unitsWithPosition = units.filter((u) => !!u.position);
10376
10393
  const sortedUnits = [...unitsWithPosition].sort((a, b) => {
10394
+ if (tileLayout === "hex") return a.position.y !== b.position.y ? a.position.y - b.position.y : a.position.x - b.position.x;
10377
10395
  const depthA = a.position.x + a.position.y;
10378
10396
  const depthB = b.position.x + b.position.y;
10379
10397
  return depthA !== depthB ? depthA - depthB : a.position.y - b.position.y;
10380
10398
  });
10381
10399
  for (const unit of sortedUnits) {
10382
- const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX);
10400
+ const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX, tileLayout);
10383
10401
  if (pos.x + scaledTileWidth < visLeft || pos.x > visRight || pos.y + scaledTileHeight < visTop || pos.y > visBottom) {
10384
10402
  continue;
10385
10403
  }
@@ -10399,7 +10417,7 @@ function IsometricCanvas({
10399
10417
  drawH = maxUnitW / ar;
10400
10418
  }
10401
10419
  if (unit.previousPosition && (unit.previousPosition.x !== unit.position.x || unit.previousPosition.y !== unit.position.y)) {
10402
- const ghostPos = isoToScreen(unit.previousPosition.x, unit.previousPosition.y, scale, baseOffsetX);
10420
+ const ghostPos = isoToScreen(unit.previousPosition.x, unit.previousPosition.y, scale, baseOffsetX, tileLayout);
10403
10421
  const ghostCenterX = ghostPos.x + scaledTileWidth / 2;
10404
10422
  const ghostGroundY = ghostPos.y + scaledDiamondTopY + scaledFloorHeight * 0.5;
10405
10423
  ctx.save();
@@ -10528,6 +10546,7 @@ function IsometricCanvas({
10528
10546
  units,
10529
10547
  features,
10530
10548
  selectedUnitId,
10549
+ tileLayout,
10531
10550
  scale,
10532
10551
  debug2,
10533
10552
  resolveTerrainSpriteUrl,
@@ -10556,14 +10575,14 @@ function IsometricCanvas({
10556
10575
  if (!selectedUnitId) return;
10557
10576
  const unit = units.find((u) => u.id === selectedUnitId);
10558
10577
  if (!unit?.position) return;
10559
- const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX);
10578
+ const pos = isoToScreen(unit.position.x, unit.position.y, scale, baseOffsetX, tileLayout);
10560
10579
  const centerX = pos.x + scaledTileWidth / 2;
10561
10580
  const centerY = pos.y + scaledDiamondTopY + scaledFloorHeight / 2;
10562
10581
  targetCameraRef.current = {
10563
10582
  x: centerX - viewportSize.width / 2,
10564
10583
  y: centerY - viewportSize.height / 2
10565
10584
  };
10566
- }, [selectedUnitId, units, scale, baseOffsetX, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, viewportSize, targetCameraRef]);
10585
+ }, [selectedUnitId, units, tileLayout, scale, baseOffsetX, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, viewportSize, targetCameraRef]);
10567
10586
  React79.useEffect(() => {
10568
10587
  const hasAnimations = units.length > 0 || validMoves.length > 0 || attackTargets.length > 0 || selectedUnitId != null || targetCameraRef.current != null || hasActiveEffects2 || pendingCount > 0 || atlasPending > 0;
10569
10588
  draw(animTimeRef.current);
@@ -10596,13 +10615,13 @@ function IsometricCanvas({
10596
10615
  const world = screenToWorld(e.clientX, e.clientY, canvasRef.current, viewportSize);
10597
10616
  const adjustedX = world.x - scaledTileWidth / 2;
10598
10617
  const adjustedY = world.y - scaledDiamondTopY - scaledFloorHeight / 2;
10599
- const isoPos = screenToIso(adjustedX, adjustedY, scale, baseOffsetX);
10618
+ const isoPos = screenToIso(adjustedX, adjustedY, scale, baseOffsetX, tileLayout);
10600
10619
  const tileExists = tilesProp.some((t2) => t2.x === isoPos.x && t2.y === isoPos.y);
10601
10620
  if (tileExists) {
10602
10621
  if (tileHoverEvent) eventBus.emit(`UI:${tileHoverEvent}`, { x: isoPos.x, y: isoPos.y });
10603
10622
  onTileHover?.(isoPos.x, isoPos.y);
10604
10623
  }
10605
- }, [onTileHover, screenToWorld, viewportSize, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, scale, baseOffsetX, tilesProp, tileHoverEvent, eventBus]);
10624
+ }, [onTileHover, screenToWorld, viewportSize, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, tileLayout, scale, baseOffsetX, tilesProp, tileHoverEvent, eventBus]);
10606
10625
  const handleCanvasPointerUp = React79.useCallback((e) => {
10607
10626
  singlePointerActiveRef.current = false;
10608
10627
  if (enableCamera) handlePointerUp();
@@ -10611,7 +10630,7 @@ function IsometricCanvas({
10611
10630
  const world = screenToWorld(e.clientX, e.clientY, canvasRef.current, viewportSize);
10612
10631
  const adjustedX = world.x - scaledTileWidth / 2;
10613
10632
  const adjustedY = world.y - scaledDiamondTopY - scaledFloorHeight / 2;
10614
- const isoPos = screenToIso(adjustedX, adjustedY, scale, baseOffsetX);
10633
+ const isoPos = screenToIso(adjustedX, adjustedY, scale, baseOffsetX, tileLayout);
10615
10634
  const clickedUnit = units.find((u) => u.position?.x === isoPos.x && u.position?.y === isoPos.y);
10616
10635
  if (clickedUnit && (onUnitClick || unitClickEvent)) {
10617
10636
  if (unitClickEvent) eventBus.emit(`UI:${unitClickEvent}`, { unitId: clickedUnit.id });
@@ -10623,7 +10642,7 @@ function IsometricCanvas({
10623
10642
  onTileClick?.(isoPos.x, isoPos.y);
10624
10643
  }
10625
10644
  }
10626
- }, [enableCamera, handlePointerUp, dragDistance, screenToWorld, viewportSize, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, scale, baseOffsetX, units, tilesProp, onUnitClick, onTileClick, unitClickEvent, tileClickEvent, eventBus]);
10645
+ }, [enableCamera, handlePointerUp, dragDistance, screenToWorld, viewportSize, scaledTileWidth, scaledDiamondTopY, scaledFloorHeight, tileLayout, scale, baseOffsetX, units, tilesProp, onUnitClick, onTileClick, unitClickEvent, tileClickEvent, eventBus]);
10627
10646
  const handleCanvasPointerLeave = React79.useCallback(() => {
10628
10647
  handleMouseLeave();
10629
10648
  if (tileLeaveEvent) eventBus.emit(`UI:${tileLeaveEvent}`, {});
@@ -20565,6 +20584,8 @@ var init_ChartLegend = __esm({
20565
20584
  function ChoiceButton({
20566
20585
  text = "Charge forward into the fray",
20567
20586
  index,
20587
+ assetUrl,
20588
+ icon,
20568
20589
  disabled = false,
20569
20590
  selected = false,
20570
20591
  onClick,
@@ -20597,6 +20618,23 @@ function ChoiceButton({
20597
20618
  ]
20598
20619
  }
20599
20620
  ),
20621
+ assetUrl ? /* @__PURE__ */ jsxRuntime.jsx(
20622
+ "img",
20623
+ {
20624
+ src: assetUrl,
20625
+ alt: "",
20626
+ width: 16,
20627
+ height: 16,
20628
+ style: { imageRendering: "pixelated", objectFit: "contain" },
20629
+ className: "flex-shrink-0"
20630
+ }
20631
+ ) : icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 text-sm", children: typeof icon === "string" ? (() => {
20632
+ const I = resolveIcon(icon);
20633
+ return I ? /* @__PURE__ */ jsxRuntime.jsx(I, { className: "w-4 h-4" }) : null;
20634
+ })() : /* @__PURE__ */ (() => {
20635
+ const I = icon;
20636
+ return /* @__PURE__ */ jsxRuntime.jsx(I, { className: "w-4 h-4" });
20637
+ })() }) : null,
20600
20638
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-snug", children: text })
20601
20639
  ]
20602
20640
  }
@@ -20605,6 +20643,7 @@ function ChoiceButton({
20605
20643
  var init_ChoiceButton = __esm({
20606
20644
  "components/game/atoms/ChoiceButton.tsx"() {
20607
20645
  init_cn();
20646
+ init_Icon();
20608
20647
  ChoiceButton.displayName = "ChoiceButton";
20609
20648
  }
20610
20649
  });
@@ -28718,6 +28757,7 @@ function PowerupSlots({
28718
28757
  /* @__PURE__ */ jsxRuntime.jsx(
28719
28758
  ItemSlot,
28720
28759
  {
28760
+ assetUrl: powerup.assetUrl,
28721
28761
  icon: powerup.icon,
28722
28762
  label: powerup.label,
28723
28763
  rarity: "uncommon",
@@ -28967,13 +29007,26 @@ function HealthPanel({
28967
29007
  )
28968
29008
  }
28969
29009
  ),
28970
- effects && effects.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex items-center gap-1 flex-wrap", children: effects.map((effect, i) => /* @__PURE__ */ jsxRuntime.jsx(
29010
+ effects && effects.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex items-center gap-1 flex-wrap", children: effects.map((effect, i) => /* @__PURE__ */ jsxRuntime.jsxs(
28971
29011
  exports.Badge,
28972
29012
  {
28973
29013
  variant: effectVariantMap[effect.variant ?? "neutral"],
28974
29014
  size: "sm",
28975
- icon: effect.icon,
28976
- children: effect.label
29015
+ icon: effect.assetUrl ? void 0 : effect.icon,
29016
+ children: [
29017
+ effect.assetUrl && /* @__PURE__ */ jsxRuntime.jsx(
29018
+ "img",
29019
+ {
29020
+ src: effect.assetUrl,
29021
+ alt: "",
29022
+ width: 12,
29023
+ height: 12,
29024
+ style: { imageRendering: "pixelated", objectFit: "contain" },
29025
+ className: "flex-shrink-0 inline-block"
29026
+ }
29027
+ ),
29028
+ effect.label
29029
+ ]
28977
29030
  },
28978
29031
  i
28979
29032
  )) })
@@ -29220,15 +29273,28 @@ function TurnPanel({
29220
29273
  activeTeam
29221
29274
  }
29222
29275
  ),
29223
- actions && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex items-center gap-1.5 ml-auto", children: actions.map((action, i) => /* @__PURE__ */ jsxRuntime.jsx(
29276
+ actions && actions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex items-center gap-1.5 ml-auto", children: actions.map((action, i) => /* @__PURE__ */ jsxRuntime.jsxs(
29224
29277
  exports.Button,
29225
29278
  {
29226
29279
  variant: "ghost",
29227
29280
  size: "sm",
29228
29281
  disabled: action.disabled,
29229
- leftIcon: action.icon,
29282
+ leftIcon: action.assetUrl ? void 0 : action.icon,
29230
29283
  onClick: () => handleAction(action.event),
29231
- children: action.label
29284
+ children: [
29285
+ action.assetUrl && /* @__PURE__ */ jsxRuntime.jsx(
29286
+ "img",
29287
+ {
29288
+ src: action.assetUrl,
29289
+ alt: "",
29290
+ width: 14,
29291
+ height: 14,
29292
+ style: { imageRendering: "pixelated", objectFit: "contain" },
29293
+ className: "flex-shrink-0"
29294
+ }
29295
+ ),
29296
+ action.label
29297
+ ]
29232
29298
  },
29233
29299
  i
29234
29300
  )) })
@@ -30988,13 +31054,13 @@ var init_MapView = __esm({
30988
31054
  shadowSize: [41, 41]
30989
31055
  });
30990
31056
  L.Marker.prototype.options.icon = defaultIcon;
30991
- const { useEffect: useEffect83, useRef: useRef83, useCallback: useCallback127, useState: useState112 } = React79__namespace.default;
31057
+ const { useEffect: useEffect84, useRef: useRef83, useCallback: useCallback128, useState: useState114 } = React79__namespace.default;
30992
31058
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
30993
31059
  const { useEventBus: useEventBus3 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
30994
31060
  function MapUpdater({ centerLat, centerLng, zoom }) {
30995
31061
  const map = useMap();
30996
31062
  const prevRef = useRef83({ centerLat, centerLng, zoom });
30997
- useEffect83(() => {
31063
+ useEffect84(() => {
30998
31064
  const prev = prevRef.current;
30999
31065
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
31000
31066
  map.setView([centerLat, centerLng], zoom);
@@ -31005,7 +31071,7 @@ var init_MapView = __esm({
31005
31071
  }
31006
31072
  function MapClickHandler({ onMapClick }) {
31007
31073
  const map = useMap();
31008
- useEffect83(() => {
31074
+ useEffect84(() => {
31009
31075
  if (!onMapClick) return;
31010
31076
  const handler = (e) => {
31011
31077
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -31033,8 +31099,8 @@ var init_MapView = __esm({
31033
31099
  showAttribution = true
31034
31100
  }) {
31035
31101
  const eventBus = useEventBus3();
31036
- const [clickedPosition, setClickedPosition] = useState112(null);
31037
- const handleMapClick = useCallback127((lat, lng) => {
31102
+ const [clickedPosition, setClickedPosition] = useState114(null);
31103
+ const handleMapClick = useCallback128((lat, lng) => {
31038
31104
  if (showClickedPin) {
31039
31105
  setClickedPosition({ lat, lng });
31040
31106
  }
@@ -31043,7 +31109,7 @@ var init_MapView = __esm({
31043
31109
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
31044
31110
  }
31045
31111
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
31046
- const handleMarkerClick = useCallback127((marker) => {
31112
+ const handleMarkerClick = useCallback128((marker) => {
31047
31113
  onMarkerClick?.(marker);
31048
31114
  if (markerClickEvent) {
31049
31115
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -44494,9 +44560,9 @@ var init_GameCanvas3D2 = __esm({
44494
44560
  const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
44495
44561
  const hasAtlas = unitAtlasUrl(unit) !== null;
44496
44562
  const initialFrame = hasAtlas ? resolveUnitFrame(unit.id) : null;
44497
- const modelScale = UNIT_BASE_MODEL_SCALE * unitScale;
44498
- const billboardHeight = UNIT_BASE_BILLBOARD_HEIGHT * unitScale;
44499
- const primitiveRadius = UNIT_BASE_PRIMITIVE_RADIUS * unitScale;
44563
+ const modelScale = UNIT_BASE_MODEL_SCALE * unitScale * gridConfig.cellSize;
44564
+ const billboardHeight = UNIT_BASE_BILLBOARD_HEIGHT * unitScale * gridConfig.cellSize;
44565
+ const primitiveRadius = UNIT_BASE_PRIMITIVE_RADIUS * unitScale * gridConfig.cellSize;
44500
44566
  return /* @__PURE__ */ jsxRuntime.jsxs(
44501
44567
  "group",
44502
44568
  {
@@ -44543,7 +44609,7 @@ var init_GameCanvas3D2 = __esm({
44543
44609
  /* @__PURE__ */ jsxRuntime.jsx("meshStandardMaterial", { color })
44544
44610
  ] })
44545
44611
  ] }),
44546
- unit.health !== void 0 && unit.maxHealth !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("group", { position: [0, 1.2, 0], children: [
44612
+ unit.health !== void 0 && unit.maxHealth !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("group", { position: [0, billboardHeight, 0], children: [
44547
44613
  /* @__PURE__ */ jsxRuntime.jsxs("mesh", { position: [-0.25, 0, 0], children: [
44548
44614
  /* @__PURE__ */ jsxRuntime.jsx("planeGeometry", { args: [0.5, 0.05] }),
44549
44615
  /* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: 3355443 })
@@ -44572,7 +44638,7 @@ var init_GameCanvas3D2 = __esm({
44572
44638
  }
44573
44639
  );
44574
44640
  },
44575
- [selectedUnitId, handleUnitClick, resolveUnitFrame, unitScale]
44641
+ [selectedUnitId, handleUnitClick, resolveUnitFrame, unitScale, gridConfig]
44576
44642
  );
44577
44643
  const DefaultFeatureRenderer = React79.useCallback(
44578
44644
  ({
@@ -44660,7 +44726,7 @@ var init_GameCanvas3D2 = __esm({
44660
44726
  {
44661
44727
  ref: containerRef,
44662
44728
  className: cn("game-canvas-3d relative w-full overflow-hidden", className),
44663
- style: { height: "85vh" },
44729
+ style: { flex: "1 1 0", minHeight: "400px" },
44664
44730
  "data-orientation": orientation,
44665
44731
  "data-camera-mode": cameraMode,
44666
44732
  "data-overlay": overlay,
@@ -44960,13 +45026,39 @@ var init_GameBoard3D = __esm({
44960
45026
  GameBoard3D.displayName = "GameBoard3D";
44961
45027
  }
44962
45028
  });
44963
- exports.GameShell = void 0;
45029
+ function getSlotContentRenderer() {
45030
+ if (_scr) return _scr;
45031
+ const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
45032
+ _scr = mod.SlotContentRenderer;
45033
+ return _scr;
45034
+ }
45035
+ function resolveDescriptor(value, idPrefix) {
45036
+ if (value === null || value === void 0) return value;
45037
+ if (React79__namespace.default.isValidElement(value)) return value;
45038
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
45039
+ if (Array.isArray(value)) {
45040
+ return value.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx(React79__namespace.default.Fragment, { children: resolveDescriptor(item, `${idPrefix}-${i}`) }, i));
45041
+ }
45042
+ if (typeof value === "object") {
45043
+ const rec = value;
45044
+ if (typeof rec.type === "string" && patterns.getComponentForPattern(rec.type) !== null) {
45045
+ const { type, props: nestedProps, _id, ...flatProps } = rec;
45046
+ const resolvedProps = nestedProps !== void 0 ? nestedProps : flatProps;
45047
+ const content = { id: _id ?? idPrefix, pattern: type, props: resolvedProps, priority: 0 };
45048
+ const SCR = getSlotContentRenderer();
45049
+ return /* @__PURE__ */ jsxRuntime.jsx(SCR, { content, onDismiss: () => void 0 });
45050
+ }
45051
+ }
45052
+ return null;
45053
+ }
45054
+ var _scr; exports.GameShell = void 0;
44964
45055
  var init_GameShell = __esm({
44965
45056
  "components/game/templates/GameShell.tsx"() {
44966
45057
  init_cn();
44967
45058
  init_Box();
44968
45059
  init_Stack();
44969
45060
  init_Typography();
45061
+ _scr = null;
44970
45062
  exports.GameShell = ({
44971
45063
  appName = "Game",
44972
45064
  hud,
@@ -45015,7 +45107,7 @@ var init_GameShell = __esm({
45015
45107
  children: appName
45016
45108
  }
45017
45109
  ),
45018
- hud && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "game-shell__hud", children: hud })
45110
+ hud && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "game-shell__hud", children: resolveDescriptor(hud, "gs-hud") })
45019
45111
  ]
45020
45112
  }
45021
45113
  ),
@@ -45028,7 +45120,7 @@ var init_GameShell = __esm({
45028
45120
  overflow: "hidden",
45029
45121
  position: "relative"
45030
45122
  },
45031
- children
45123
+ children: resolveDescriptor(children, "gs-children")
45032
45124
  }
45033
45125
  )
45034
45126
  ]
@@ -45038,7 +45130,32 @@ var init_GameShell = __esm({
45038
45130
  exports.GameShell.displayName = "GameShell";
45039
45131
  }
45040
45132
  });
45041
- exports.GameTemplate = void 0;
45133
+ function getSlotContentRenderer2() {
45134
+ if (_scr2) return _scr2;
45135
+ const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
45136
+ _scr2 = mod.SlotContentRenderer;
45137
+ return _scr2;
45138
+ }
45139
+ function resolveDescriptor2(value, idPrefix) {
45140
+ if (value === null || value === void 0) return value;
45141
+ if (React79__namespace.default.isValidElement(value)) return value;
45142
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
45143
+ if (Array.isArray(value)) {
45144
+ return value.map((item, i) => /* @__PURE__ */ jsxRuntime.jsx(React79__namespace.default.Fragment, { children: resolveDescriptor2(item, `${idPrefix}-${i}`) }, i));
45145
+ }
45146
+ if (typeof value === "object") {
45147
+ const rec = value;
45148
+ if (typeof rec.type === "string" && patterns.getComponentForPattern(rec.type) !== null) {
45149
+ const { type, props: nestedProps, _id, ...flatProps } = rec;
45150
+ const resolvedProps = nestedProps !== void 0 ? nestedProps : flatProps;
45151
+ const content = { id: _id ?? idPrefix, pattern: type, props: resolvedProps, priority: 0 };
45152
+ const SCR = getSlotContentRenderer2();
45153
+ return /* @__PURE__ */ jsxRuntime.jsx(SCR, { content, onDismiss: () => void 0 });
45154
+ }
45155
+ }
45156
+ return null;
45157
+ }
45158
+ var _scr2; exports.GameTemplate = void 0;
45042
45159
  var init_GameTemplate = __esm({
45043
45160
  "components/game/templates/GameTemplate.tsx"() {
45044
45161
  init_cn();
@@ -45046,6 +45163,7 @@ var init_GameTemplate = __esm({
45046
45163
  init_Stack();
45047
45164
  init_Typography();
45048
45165
  init_Button();
45166
+ _scr2 = null;
45049
45167
  exports.GameTemplate = ({
45050
45168
  entity,
45051
45169
  title = "Game",
@@ -45113,13 +45231,13 @@ var init_GameTemplate = __esm({
45113
45231
  fullWidth: true,
45114
45232
  className: "flex-1 bg-muted",
45115
45233
  children: [
45116
- children,
45234
+ resolveDescriptor2(children, "gt-children"),
45117
45235
  hud && /* @__PURE__ */ jsxRuntime.jsx(
45118
45236
  exports.Box,
45119
45237
  {
45120
45238
  position: "absolute",
45121
45239
  className: "top-0 left-0 right-0 pointer-events-none",
45122
- children: /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", className: "pointer-events-auto w-fit", children: hud })
45240
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", className: "pointer-events-auto w-fit", children: resolveDescriptor2(hud, "gt-hud") })
45123
45241
  }
45124
45242
  )
45125
45243
  ]
@@ -45144,7 +45262,7 @@ var init_GameTemplate = __esm({
45144
45262
  children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "h6", children: "Debug Panel" })
45145
45263
  }
45146
45264
  ),
45147
- /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", children: debugPanel })
45265
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", children: resolveDescriptor2(debugPanel, "gt-debug") })
45148
45266
  ]
45149
45267
  }
45150
45268
  )
@@ -45314,6 +45432,48 @@ var init_HeroOrganism = __esm({
45314
45432
  _HeroClickInterceptor.displayName = "_HeroClickInterceptor";
45315
45433
  }
45316
45434
  });
45435
+ function HexStrategyBoard({
45436
+ tiles,
45437
+ units,
45438
+ features,
45439
+ assetManifest,
45440
+ assetBaseUrl,
45441
+ scale = 0.45,
45442
+ showMinimap = true,
45443
+ enableCamera = true,
45444
+ tileClickEvent,
45445
+ unitClickEvent,
45446
+ isLoading,
45447
+ error,
45448
+ className
45449
+ }) {
45450
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("hex-strategy-board relative w-full h-full", className), children: /* @__PURE__ */ jsxRuntime.jsx(
45451
+ IsometricCanvas_default,
45452
+ {
45453
+ tileLayout: "hex",
45454
+ tiles,
45455
+ units,
45456
+ features,
45457
+ assetManifest,
45458
+ assetBaseUrl,
45459
+ scale,
45460
+ showMinimap,
45461
+ enableCamera,
45462
+ tileClickEvent,
45463
+ unitClickEvent,
45464
+ isLoading,
45465
+ error
45466
+ }
45467
+ ) });
45468
+ }
45469
+ var init_HexStrategyBoard = __esm({
45470
+ "components/game/organisms/HexStrategyBoard.tsx"() {
45471
+ "use client";
45472
+ init_cn();
45473
+ init_IsometricCanvas();
45474
+ HexStrategyBoard.displayName = "HexStrategyBoard";
45475
+ }
45476
+ });
45317
45477
  exports.LandingPageTemplate = void 0;
45318
45478
  var init_LandingPageTemplate = __esm({
45319
45479
  "components/marketing/templates/LandingPageTemplate.tsx"() {
@@ -53622,6 +53782,7 @@ var init_component_registry_generated = __esm({
53622
53782
  init_HealthPanel();
53623
53783
  init_HeroOrganism();
53624
53784
  init_HeroSection();
53785
+ init_HexStrategyBoard();
53625
53786
  init_Icon();
53626
53787
  init_InfiniteScrollSentinel();
53627
53788
  init_Input();
@@ -53958,6 +54119,7 @@ var init_component_registry_generated = __esm({
53958
54119
  "HealthPanel": HealthPanel,
53959
54120
  "HeroOrganism": exports.HeroOrganism,
53960
54121
  "HeroSection": exports.HeroSection,
54122
+ "HexStrategyBoard": HexStrategyBoard,
53961
54123
  "Icon": exports.Icon,
53962
54124
  "InfiniteScrollSentinel": exports.InfiniteScrollSentinel,
53963
54125
  "Input": exports.Input,
@@ -54159,7 +54321,7 @@ function getSlotFallback(slot, config) {
54159
54321
  const variant = SLOT_SKELETON_MAP[slot] ?? "text";
54160
54322
  return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { variant });
54161
54323
  }
54162
- function getComponentForPattern(patternType) {
54324
+ function getComponentForPattern3(patternType) {
54163
54325
  const mapping = patterns.getComponentForPattern(patternType);
54164
54326
  if (!mapping) {
54165
54327
  return null;
@@ -54790,7 +54952,8 @@ function SlotContentRenderer({
54790
54952
  entityDef = schemaCtx.entities.get(linkedEntity);
54791
54953
  }
54792
54954
  }
54793
- const PatternComponent = getComponentForPattern(content.pattern);
54955
+ const orbitalName = schemaCtx && content.sourceTrait !== void 0 ? schemaCtx.orbitalsByTrait.get(content.sourceTrait) : void 0;
54956
+ const PatternComponent = getComponentForPattern3(content.pattern);
54794
54957
  if (PatternComponent) {
54795
54958
  const childrenConfig = content.props.children;
54796
54959
  const isSingleChild = typeof childrenConfig === "string" || typeof childrenConfig === "object" && childrenConfig !== null && !Array.isArray(childrenConfig) && "type" in childrenConfig;
@@ -54888,6 +55051,7 @@ function SlotContentRenderer({
54888
55051
  "data-orb-entity": content.entity,
54889
55052
  "data-orb-path": myPath,
54890
55053
  "data-orb-pattern": content.pattern,
55054
+ "data-orb-orbital": orbitalName,
54891
55055
  children: renderedChildren !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(PatternComponent, { ...finalProps, children: renderedChildren }) : /* @__PURE__ */ jsxRuntime.jsx(PatternComponent, { ...finalProps })
54892
55056
  }
54893
55057
  );
@@ -54907,6 +55071,7 @@ function SlotContentRenderer({
54907
55071
  "data-orb-entity": content.entity,
54908
55072
  "data-orb-path": patternPath ?? "root",
54909
55073
  "data-orb-pattern": content.pattern,
55074
+ "data-orb-orbital": orbitalName,
54910
55075
  children: content.props.children ?? /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "p-4 text-sm text-muted-foreground border border-dashed border-border rounded", children: [
54911
55076
  "Unknown pattern: ",
54912
55077
  content.pattern,
@@ -55076,7 +55241,7 @@ function TraitFrame({
55076
55241
  if (!content) {
55077
55242
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
55078
55243
  }
55079
- const SlotContentRenderer2 = getSlotContentRenderer();
55244
+ const SlotContentRenderer2 = getSlotContentRenderer3();
55080
55245
  const rendered = /* @__PURE__ */ jsxRuntime.jsx(
55081
55246
  SlotContentRenderer2,
55082
55247
  {
@@ -55090,7 +55255,7 @@ function TraitFrame({
55090
55255
  }
55091
55256
  return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: traitName, children: rendered });
55092
55257
  }
55093
- function getSlotContentRenderer() {
55258
+ function getSlotContentRenderer3() {
55094
55259
  if (_slotContentRenderer) return _slotContentRenderer;
55095
55260
  const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
55096
55261
  _slotContentRenderer = mod.SlotContentRenderer;
@@ -55603,6 +55768,7 @@ init_CityBuilderBoard();
55603
55768
  init_GameBoard3D();
55604
55769
  init_VisualNovelBoard();
55605
55770
  init_CardBattlerBoard();
55771
+ init_HexStrategyBoard();
55606
55772
  init_TraitStateViewer();
55607
55773
  init_TraitSlot();
55608
55774
 
@@ -56165,6 +56331,1023 @@ init_CaseStudyOrganism();
56165
56331
  init_CodeRunnerPanel();
56166
56332
  init_SegmentRenderer();
56167
56333
 
56334
+ // components/core/organisms/ChatBar.tsx
56335
+ init_Box();
56336
+ init_Stack();
56337
+ init_Typography();
56338
+ init_Button();
56339
+ init_Badge();
56340
+ init_Icon();
56341
+ init_Textarea();
56342
+ init_useEventBus();
56343
+
56344
+ // components/core/organisms/trace-edit-focus.ts
56345
+ var ELEMENT_SELECTED_EVENT = "UI:ELEMENT_SELECTED";
56346
+ var EDIT_FOCUS_LEVELS = /* @__PURE__ */ new Set([
56347
+ "node",
56348
+ "slot",
56349
+ "field",
56350
+ "effect",
56351
+ "trait",
56352
+ "page",
56353
+ "orbital"
56354
+ ]);
56355
+ function asString(v) {
56356
+ return typeof v === "string" ? v : void 0;
56357
+ }
56358
+ function asLevel(v) {
56359
+ if (typeof v === "string" && EDIT_FOCUS_LEVELS.has(v)) {
56360
+ return v;
56361
+ }
56362
+ return "node";
56363
+ }
56364
+ function isEventPayload(v) {
56365
+ return v !== null && v !== void 0 && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date);
56366
+ }
56367
+ function parseEditFocus(value) {
56368
+ if (!isEventPayload(value)) return null;
56369
+ const payload = value;
56370
+ const orbital = asString(payload.orbital);
56371
+ if (orbital === void 0 || orbital.length === 0) return null;
56372
+ const focus = {
56373
+ level: asLevel(payload.level),
56374
+ orbital,
56375
+ label: asString(payload.label) ?? orbital
56376
+ };
56377
+ const trait = asString(payload.trait);
56378
+ if (trait !== void 0) focus.trait = trait;
56379
+ const transition = asString(payload.transition);
56380
+ if (transition !== void 0) focus.transition = transition;
56381
+ const state = asString(payload.state);
56382
+ if (state !== void 0) focus.state = state;
56383
+ const slot = asString(payload.slot);
56384
+ if (slot !== void 0) focus.slot = slot;
56385
+ const path = asString(payload.path);
56386
+ if (path !== void 0) focus.path = path;
56387
+ const patternType = asString(payload.patternType);
56388
+ if (patternType !== void 0) focus.patternType = patternType;
56389
+ const entity = asString(payload.entity);
56390
+ if (entity !== void 0) focus.entity = entity;
56391
+ const source = asString(payload.source);
56392
+ if (source !== void 0) focus.source = source;
56393
+ return focus;
56394
+ }
56395
+ function getJepaBadgeVariant(probability) {
56396
+ if (probability >= 0.9) return "success";
56397
+ if (probability >= 0.5) return "warning";
56398
+ return "danger";
56399
+ }
56400
+ function ChatBar({
56401
+ status = "idle",
56402
+ activeGate,
56403
+ jepaValidity,
56404
+ placeholder,
56405
+ context,
56406
+ className
56407
+ }) {
56408
+ const { t } = hooks.useTranslate();
56409
+ const eventBus = useEventBus();
56410
+ const [inputValue, setInputValue] = React79.useState("");
56411
+ const [focus, setFocus] = React79.useState(null);
56412
+ const clearFocus = React79.useCallback(() => {
56413
+ setFocus(null);
56414
+ eventBus.emit(ELEMENT_SELECTED_EVENT, { focus: null });
56415
+ }, [eventBus]);
56416
+ const handleKeyDown = React79.useCallback((e) => {
56417
+ if (e.key !== "Enter" || e.shiftKey) return;
56418
+ const trimmed = inputValue.trim();
56419
+ if (!trimmed) return;
56420
+ e.preventDefault();
56421
+ eventBus.emit("UI:CHAT_SEND", { message: trimmed });
56422
+ }, [inputValue, eventBus]);
56423
+ React79.useEffect(() => {
56424
+ const unsubSend = eventBus.on("UI:CHAT_SEND", () => {
56425
+ setInputValue("");
56426
+ setFocus(null);
56427
+ });
56428
+ const unsubSelect = eventBus.on(ELEMENT_SELECTED_EVENT, (e) => {
56429
+ setFocus(parseEditFocus(e.payload?.focus));
56430
+ });
56431
+ return () => {
56432
+ unsubSend();
56433
+ unsubSelect();
56434
+ };
56435
+ }, [eventBus]);
56436
+ const trailingAction = status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs(exports.Button, { variant: "secondary", size: "sm", action: "RETRY_GENERATION", className: "rounded-none flex-shrink-0 h-auto", children: [
56437
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "refresh-cw", size: "xs" }),
56438
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", children: t("openFile.retry") })
56439
+ ] }) : status === "running" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
56440
+ /* @__PURE__ */ jsxRuntime.jsx(
56441
+ exports.Button,
56442
+ {
56443
+ variant: "ghost",
56444
+ size: "sm",
56445
+ action: "PAUSE",
56446
+ title: t("chatBar.pauseTheAgentYouCanEdit"),
56447
+ className: "rounded-none flex-shrink-0 h-auto",
56448
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "pause", size: "xs" })
56449
+ }
56450
+ ),
56451
+ /* @__PURE__ */ jsxRuntime.jsx(
56452
+ exports.Button,
56453
+ {
56454
+ variant: "ghost",
56455
+ size: "sm",
56456
+ action: "STOP",
56457
+ title: t("chatBar.cancelGeneration"),
56458
+ className: "rounded-none flex-shrink-0 h-auto border-l border-[var(--color-border)]",
56459
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "square", size: "xs" })
56460
+ }
56461
+ )
56462
+ ] }) : status === "paused" ? /* @__PURE__ */ jsxRuntime.jsxs(
56463
+ exports.Button,
56464
+ {
56465
+ variant: "primary",
56466
+ size: "sm",
56467
+ action: "RESUME",
56468
+ title: t("chatBar.resumeTheAgentYourCanvasEdits"),
56469
+ className: "rounded-none flex-shrink-0 h-auto",
56470
+ children: [
56471
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "play", size: "xs" }),
56472
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", children: t("chatBar.resume") })
56473
+ ]
56474
+ }
56475
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
56476
+ exports.Button,
56477
+ {
56478
+ variant: "primary",
56479
+ size: "sm",
56480
+ action: "CHAT_SEND",
56481
+ actionPayload: { message: inputValue.trim() },
56482
+ disabled: !inputValue.trim(),
56483
+ "aria-label": t("chatBar.sendMessage"),
56484
+ className: "rounded-none flex-shrink-0 h-auto",
56485
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "send", size: "xs" })
56486
+ }
56487
+ );
56488
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: `border-t border-[var(--color-border)] bg-[var(--color-card)] ${className ?? ""}`, children: [
56489
+ focus && /* @__PURE__ */ jsxRuntime.jsx(exports.HStack, { gap: "xs", className: "items-center px-4 pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Badge, { variant: "secondary", size: "sm", className: "flex items-center gap-1 max-w-full", children: [
56490
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "mouse-pointer-2", size: "xs" }),
56491
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "text-inherit truncate", children: [
56492
+ t("chatBar.editing"),
56493
+ ": ",
56494
+ focus.label
56495
+ ] }),
56496
+ /* @__PURE__ */ jsxRuntime.jsx(
56497
+ exports.Box,
56498
+ {
56499
+ onClick: clearFocus,
56500
+ title: t("chatBar.clearSelection"),
56501
+ className: "cursor-pointer flex items-center ml-1 hover:opacity-70",
56502
+ children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "x", size: "xs" })
56503
+ }
56504
+ )
56505
+ ] }) }),
56506
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: "items-center px-4 py-2", children: [
56507
+ context && /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "primary", size: "sm", className: "whitespace-nowrap flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "text-inherit", children: context }) }),
56508
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "flex-1 min-w-0 flex items-stretch rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-background)] focus-within:border-[var(--color-primary)] overflow-hidden", children: [
56509
+ /* @__PURE__ */ jsxRuntime.jsx(
56510
+ exports.Textarea,
56511
+ {
56512
+ value: inputValue,
56513
+ placeholder: placeholder ?? t("chatBar.askTheAgentAnything"),
56514
+ onChange: (e) => setInputValue(e.target.value),
56515
+ onKeyDown: handleKeyDown,
56516
+ rows: 1,
56517
+ className: "flex-1 min-w-0 min-h-0 text-sm border-0 rounded-none shadow-none bg-transparent resize-none focus:ring-0"
56518
+ }
56519
+ ),
56520
+ trailingAction
56521
+ ] }),
56522
+ (activeGate || jepaValidity !== void 0) && /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center flex-shrink-0", children: [
56523
+ activeGate && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "whitespace-nowrap", children: activeGate }),
56524
+ jepaValidity !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: getJepaBadgeVariant(jepaValidity), size: "sm", children: /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "text-inherit", children: [
56525
+ (jepaValidity * 100).toFixed(1),
56526
+ "%"
56527
+ ] }) })
56528
+ ] })
56529
+ ] })
56530
+ ] });
56531
+ }
56532
+ ChatBar.displayName = "ChatBar";
56533
+
56534
+ // components/core/organisms/SubagentTracePanel.tsx
56535
+ init_Box();
56536
+ init_Stack();
56537
+ init_Typography();
56538
+ init_Badge();
56539
+ init_Icon();
56540
+ init_Button();
56541
+ init_Modal();
56542
+ init_Accordion();
56543
+
56544
+ // components/core/molecules/markdown/index.ts
56545
+ init_MarkdownContent();
56546
+ init_CodeBlock();
56547
+ function groupByOrbital(subagents) {
56548
+ const map = /* @__PURE__ */ new Map();
56549
+ for (const sub of subagents) {
56550
+ const key = sub.orbitalName ?? "(unattached)";
56551
+ const arr = map.get(key) ?? [];
56552
+ arr.push(sub);
56553
+ map.set(key, arr);
56554
+ }
56555
+ return map;
56556
+ }
56557
+ function statusIconName(status) {
56558
+ switch (status) {
56559
+ case "running":
56560
+ return "loader";
56561
+ case "complete":
56562
+ return "check";
56563
+ case "error":
56564
+ return "x";
56565
+ default:
56566
+ return "circle";
56567
+ }
56568
+ }
56569
+ function lastMessage(sub) {
56570
+ if (sub.messages.length === 0) return void 0;
56571
+ return sub.messages[sub.messages.length - 1].message;
56572
+ }
56573
+ function formatHHMMSS(ts) {
56574
+ const d = new Date(ts);
56575
+ const hh = String(d.getHours()).padStart(2, "0");
56576
+ const mm = String(d.getMinutes()).padStart(2, "0");
56577
+ const ss = String(d.getSeconds()).padStart(2, "0");
56578
+ return `${hh}:${mm}:${ss}`;
56579
+ }
56580
+ function compactJson(value) {
56581
+ if (value === void 0 || value === null) return "";
56582
+ if (typeof value === "string") return value;
56583
+ try {
56584
+ const json = JSON.stringify(value);
56585
+ if (json.length <= 240) return json;
56586
+ return json.slice(0, 239) + "\u2026";
56587
+ } catch {
56588
+ return String(value);
56589
+ }
56590
+ }
56591
+ function tryPrettyJson(s) {
56592
+ try {
56593
+ return JSON.stringify(JSON.parse(s), null, 2);
56594
+ } catch {
56595
+ return null;
56596
+ }
56597
+ }
56598
+ function summarizeArgs(args) {
56599
+ const keys = Object.keys(args);
56600
+ if (keys.length === 0) return "";
56601
+ return keys.slice(0, 3).join(", ") + (keys.length > 3 ? ", \u2026" : "");
56602
+ }
56603
+ function previewText(text, max = 120) {
56604
+ if (!text) return "";
56605
+ return text.length > max ? text.slice(0, max - 1) + "\u2026" : text;
56606
+ }
56607
+ function coordinatorToActivityItems(activities) {
56608
+ return activities.flatMap((a) => {
56609
+ switch (a.type) {
56610
+ case "tool_call":
56611
+ return [{
56612
+ type: "tool_call",
56613
+ tool: a.tool,
56614
+ args: a.args,
56615
+ timestamp: a.timestamp
56616
+ }];
56617
+ case "tool_result":
56618
+ return [{
56619
+ type: "tool_result",
56620
+ tool: a.tool,
56621
+ result: a.result,
56622
+ success: a.success,
56623
+ timestamp: a.timestamp
56624
+ }];
56625
+ case "message":
56626
+ return [{
56627
+ type: "message",
56628
+ role: a.role,
56629
+ content: a.content,
56630
+ timestamp: a.timestamp
56631
+ }];
56632
+ case "error":
56633
+ return [{
56634
+ type: "message",
56635
+ role: "system",
56636
+ content: `Error: ${a.message}`,
56637
+ timestamp: a.timestamp
56638
+ }];
56639
+ case "coordinator_decision":
56640
+ case "plan_committed":
56641
+ case "pending_question":
56642
+ case "clarification_question":
56643
+ return [];
56644
+ case "file_operation":
56645
+ return [{
56646
+ type: "file_operation",
56647
+ operation: a.operation,
56648
+ path: a.path,
56649
+ success: a.success,
56650
+ timestamp: a.timestamp
56651
+ }];
56652
+ case "schema_diff":
56653
+ return [{
56654
+ type: "schema_diff",
56655
+ filePath: a.filePath,
56656
+ hunks: a.hunks,
56657
+ timestamp: a.timestamp
56658
+ }];
56659
+ }
56660
+ });
56661
+ }
56662
+ function pluckCoordinatorState(activities) {
56663
+ let decision = null;
56664
+ let plan = null;
56665
+ const pendingQuestions = [];
56666
+ for (const a of activities) {
56667
+ if (a.type === "coordinator_decision") decision = a;
56668
+ else if (a.type === "plan_committed") plan = a;
56669
+ else if (a.type === "pending_question") pendingQuestions.push(a);
56670
+ }
56671
+ return { decision, plan, pendingQuestions };
56672
+ }
56673
+ var InlineActivityRow = ({ activity }) => {
56674
+ const time = formatHHMMSS(activity.timestamp);
56675
+ const baseRow = "items-start px-3 py-1 hover:bg-[var(--color-surface)]";
56676
+ if (activity.type === "tool_call") {
56677
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: baseRow, children: [
56678
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "terminal", size: "xs", className: "mt-0.5 flex-shrink-0 text-[var(--color-primary)]" }),
56679
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "flex-1 min-w-0 text-[11px] font-mono break-all whitespace-pre-wrap", children: [
56680
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { as: "span", variant: "caption", weight: "semibold", className: "text-[11px] font-mono", children: activity.tool }),
56681
+ activity.args !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { as: "span", variant: "caption", color: "muted", className: "text-[11px] font-mono", children: [
56682
+ " ",
56683
+ compactJson(activity.args)
56684
+ ] })
56685
+ ] }),
56686
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] flex-shrink-0 tabular-nums mt-0.5", children: time })
56687
+ ] });
56688
+ }
56689
+ if (activity.type === "tool_result") {
56690
+ const success = activity.success !== false;
56691
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: baseRow, children: [
56692
+ /* @__PURE__ */ jsxRuntime.jsx(
56693
+ exports.Icon,
56694
+ {
56695
+ name: success ? "check" : "x",
56696
+ size: "xs",
56697
+ className: `mt-0.5 flex-shrink-0 ${success ? "text-[var(--color-success)]" : "text-[var(--color-danger)]"}`
56698
+ }
56699
+ ),
56700
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "flex-1 min-w-0 text-[11px] font-mono break-all whitespace-pre-wrap", children: [
56701
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { as: "span", variant: "caption", color: "muted", className: "text-[11px] font-mono", children: [
56702
+ activity.tool,
56703
+ ":",
56704
+ " "
56705
+ ] }),
56706
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { as: "span", variant: "caption", className: "text-[11px] font-mono", children: compactJson(activity.result) })
56707
+ ] }),
56708
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] flex-shrink-0 tabular-nums mt-0.5", children: time })
56709
+ ] });
56710
+ }
56711
+ if (activity.type === "message") {
56712
+ const role = activity.role;
56713
+ const iconName = role === "user" ? "user" : role === "system" ? "info" : "sparkles";
56714
+ const roleColor = role === "user" ? "text-[var(--color-primary)]" : role === "system" ? "text-[var(--color-muted-foreground)]" : "text-[var(--color-foreground)]";
56715
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: baseRow, children: [
56716
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: iconName, size: "xs", className: `mt-0.5 flex-shrink-0 ${roleColor}` }),
56717
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "flex-1 min-w-0 text-[11px] whitespace-pre-wrap break-words", children: activity.content }),
56718
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] flex-shrink-0 tabular-nums mt-0.5", children: time })
56719
+ ] });
56720
+ }
56721
+ if (activity.type === "error") {
56722
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: baseRow, children: [
56723
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "alert-triangle", size: "xs", className: "mt-0.5 flex-shrink-0 text-[var(--color-danger)]" }),
56724
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "flex-1 min-w-0 text-[11px] text-[var(--color-danger)] whitespace-pre-wrap break-words", children: activity.message }),
56725
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] flex-shrink-0 tabular-nums mt-0.5", children: time })
56726
+ ] });
56727
+ }
56728
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: baseRow, children: [
56729
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "file", size: "xs", className: "mt-0.5 flex-shrink-0 text-[var(--color-muted-foreground)]" }),
56730
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", color: "muted", className: "flex-1 min-w-0 text-[11px] font-mono break-all", children: [
56731
+ "[",
56732
+ activity.type,
56733
+ "] ",
56734
+ compactJson(activity)
56735
+ ] }),
56736
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] flex-shrink-0 tabular-nums mt-0.5", children: time })
56737
+ ] });
56738
+ };
56739
+ var InlineActivityStream = ({ activities, autoScroll = true, className }) => {
56740
+ const endRef = React79__namespace.default.useRef(null);
56741
+ React79__namespace.default.useEffect(() => {
56742
+ if (!autoScroll) return;
56743
+ endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
56744
+ }, [activities.length, autoScroll]);
56745
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className, children: [
56746
+ activities.map((a, i) => /* @__PURE__ */ jsxRuntime.jsx(InlineActivityRow, { activity: a }, `${a.timestamp}-${i}`)),
56747
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { ref: endRef })
56748
+ ] });
56749
+ };
56750
+ var CoordinatorCard = ({ snapshot, className }) => {
56751
+ const { t } = hooks.useTranslate();
56752
+ const { decision, plan, pendingQuestions } = snapshot;
56753
+ if (!decision && !plan && pendingQuestions.length === 0) return null;
56754
+ return /* @__PURE__ */ jsxRuntime.jsxs(
56755
+ exports.Box,
56756
+ {
56757
+ className: `px-3 py-2 border-b border-[var(--color-border)] bg-[var(--color-muted)]/30 ${className ?? ""}`,
56758
+ children: [
56759
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center mb-2", children: [
56760
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "compass", size: "xs" }),
56761
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold text-[11px]", children: t("subagentTrace.coordinator") })
56762
+ ] }),
56763
+ decision && /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "mb-2", children: [
56764
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
56765
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] uppercase tracking-wide", children: t("subagentTrace.organism") }),
56766
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "default", className: "text-[10px]", children: decision.organism }),
56767
+ decision.priorOrganism && decision.priorOrganism !== decision.organism && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px]", children: t("subagentTrace.wasOrganism", { organism: decision.priorOrganism }) })
56768
+ ] }),
56769
+ decision.reason && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[11px] mt-0.5", children: decision.reason })
56770
+ ] }),
56771
+ plan && plan.orbitals.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "mb-2", children: [
56772
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] uppercase tracking-wide mb-0.5", children: plan.orbitals.length === 1 ? t("subagentTrace.planOrbital", { count: plan.orbitals.length }) : t("subagentTrace.planOrbitals", { count: plan.orbitals.length }) }),
56773
+ /* @__PURE__ */ jsxRuntime.jsx(exports.HStack, { gap: "xs", className: "flex-wrap", children: plan.orbitals.map((o) => /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "neutral", className: "text-[10px]", children: o }, o)) })
56774
+ ] }),
56775
+ pendingQuestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", children: [
56776
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] uppercase tracking-wide mb-0.5", children: pendingQuestions.length === 1 ? t("subagentTrace.pendingQuestion", { count: pendingQuestions.length }) : t("subagentTrace.pendingQuestions", { count: pendingQuestions.length }) }),
56777
+ pendingQuestions.map((q) => /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-start", children: [
56778
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "help-circle", size: "xs", className: "mt-0.5 flex-shrink-0 text-[var(--color-warning)]" }),
56779
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "text-[11px] flex-1 min-w-0", children: [
56780
+ q.question,
56781
+ q.orbitalName && /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px] ml-1", children: [
56782
+ "(",
56783
+ q.orbitalName,
56784
+ ")"
56785
+ ] })
56786
+ ] })
56787
+ ] }, q.questionId))
56788
+ ] })
56789
+ ]
56790
+ }
56791
+ );
56792
+ };
56793
+ function subagentMessagesToActivities(messages) {
56794
+ return messages.map((m) => {
56795
+ if (m.tool) {
56796
+ return {
56797
+ type: "tool_call",
56798
+ tool: m.tool,
56799
+ args: { preview: m.message },
56800
+ timestamp: m.timestamp
56801
+ };
56802
+ }
56803
+ return {
56804
+ type: "message",
56805
+ role: "system",
56806
+ content: m.message,
56807
+ timestamp: m.timestamp
56808
+ };
56809
+ });
56810
+ }
56811
+ var SubagentRow = ({ subagent }) => {
56812
+ const recent = lastMessage(subagent);
56813
+ return /* @__PURE__ */ jsxRuntime.jsxs(
56814
+ exports.HStack,
56815
+ {
56816
+ gap: "sm",
56817
+ className: "items-start px-3 py-2 border-b border-[var(--color-border)]",
56818
+ children: [
56819
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "pt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: statusIconName(subagent.status), size: "xs" }) }),
56820
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "flex-1 min-w-0", children: [
56821
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: "items-center", children: [
56822
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-medium truncate", children: subagent.name }),
56823
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "default", children: subagent.role })
56824
+ ] }),
56825
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "truncate", children: recent ?? subagent.task })
56826
+ ] })
56827
+ ]
56828
+ }
56829
+ );
56830
+ };
56831
+ var OrbitalGroup = ({ orbitalName, subagents }) => {
56832
+ const { t } = hooks.useTranslate();
56833
+ const runningCount = subagents.filter((s) => s.status === "running").length;
56834
+ const completeCount = subagents.filter((s) => s.status === "complete").length;
56835
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "border-b border-[var(--color-border)]", children: [
56836
+ /* @__PURE__ */ jsxRuntime.jsxs(
56837
+ exports.HStack,
56838
+ {
56839
+ gap: "sm",
56840
+ className: "items-center px-3 py-2 bg-[var(--color-surface)] border-b border-[var(--color-border)]",
56841
+ children: [
56842
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "circle", size: "xs" }),
56843
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold flex-1 truncate", children: orbitalName }),
56844
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "default", children: runningCount > 0 ? t("subagentTrace.countRunning", { count: runningCount }) : t("subagentTrace.countDone", { count: completeCount }) })
56845
+ ]
56846
+ }
56847
+ ),
56848
+ subagents.map((sub) => /* @__PURE__ */ jsxRuntime.jsx(SubagentRow, { subagent: sub }, sub.id))
56849
+ ] });
56850
+ };
56851
+ var SubagentRichCard = ({ subagent }) => {
56852
+ const { t } = hooks.useTranslate();
56853
+ const activities = React79__namespace.default.useMemo(
56854
+ () => subagentMessagesToActivities(subagent.messages),
56855
+ [subagent.messages]
56856
+ );
56857
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "border-b border-[var(--color-border)] p-3", children: [
56858
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: "items-center mb-2", children: [
56859
+ /* @__PURE__ */ jsxRuntime.jsx(
56860
+ exports.Box,
56861
+ {
56862
+ style: {
56863
+ width: 8,
56864
+ height: 8,
56865
+ borderRadius: "50%",
56866
+ flexShrink: 0,
56867
+ backgroundColor: subagent.status === "complete" ? "var(--color-success)" : subagent.status === "error" ? "var(--color-error)" : "var(--color-primary)",
56868
+ ...subagent.status === "running" ? { animation: "pulse 1.5s infinite" } : {}
56869
+ }
56870
+ }
56871
+ ),
56872
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold flex-1 truncate", children: subagent.name }),
56873
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: subagent.role === "deterministic" ? "default" : subagent.role === "llm" ? "info" : "warning", children: subagent.role }),
56874
+ subagent.durationMs !== void 0 && subagent.durationMs > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: subagent.durationMs < 1e3 ? `${subagent.durationMs}ms` : `${(subagent.durationMs / 1e3).toFixed(1)}s` })
56875
+ ] }),
56876
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "mb-2", children: subagent.task }),
56877
+ activities.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "max-h-64 overflow-y-auto border-t border-[var(--color-border)]", children: /* @__PURE__ */ jsxRuntime.jsx(InlineActivityStream, { activities, autoScroll: true }) }) : /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "italic text-[10px]", children: subagent.status === "complete" ? t("subagentTrace.noConversationLog") : t("subagentTrace.waitingForProcessData") })
56878
+ ] });
56879
+ };
56880
+ var roleBadgeVariant = {
56881
+ system: "neutral",
56882
+ user: "info",
56883
+ assistant: "default",
56884
+ tool: "warning"
56885
+ };
56886
+ var ChatMessageRow = ({ message, index }) => {
56887
+ const { t } = hooks.useTranslate();
56888
+ const { role, content, toolCalls, reasoningContent, toolCallId, toolName } = message;
56889
+ if (role === "tool") {
56890
+ const pretty = tryPrettyJson(content);
56891
+ const title = `${toolName ?? "tool"} \u2192${toolCallId ? ` ${toolCallId.slice(0, 8)}` : ""}`;
56892
+ const body = pretty !== null ? /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: pretty, language: "json", maxHeight: "24rem" }) : /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body", className: "whitespace-pre-wrap font-mono text-[11px]", children: content });
56893
+ const items = [{ id: `tool-${index}`, title, content: body }];
56894
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "px-3 py-2 border-b border-[var(--color-border)]", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Accordion, { items }) });
56895
+ }
56896
+ const hasReasoning = typeof reasoningContent === "string" && reasoningContent.length > 0;
56897
+ const hasToolCalls = Array.isArray(toolCalls) && toolCalls.length > 0;
56898
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "xs", className: "px-3 py-2 border-b border-[var(--color-border)]", children: [
56899
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
56900
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: roleBadgeVariant[role], className: "text-[10px] uppercase", children: role }),
56901
+ hasReasoning && /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px]", children: [
56902
+ "\xB7 ",
56903
+ t("subagentTrace.thinking")
56904
+ ] }),
56905
+ hasToolCalls && /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px]", children: [
56906
+ "\xB7 ",
56907
+ toolCalls.length === 1 ? t("subagentTrace.toolCallCount", { count: toolCalls.length }) : t("subagentTrace.toolCallCountPlural", { count: toolCalls.length })
56908
+ ] })
56909
+ ] }),
56910
+ hasReasoning && /* @__PURE__ */ jsxRuntime.jsx(exports.Accordion, { items: [{
56911
+ id: `reasoning-${index}`,
56912
+ title: t("subagentTrace.reasoning"),
56913
+ content: /* @__PURE__ */ jsxRuntime.jsx(exports.MarkdownContent, { content: reasoningContent })
56914
+ }] }),
56915
+ content.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.MarkdownContent, { content }),
56916
+ hasToolCalls && /* @__PURE__ */ jsxRuntime.jsx(
56917
+ exports.Accordion,
56918
+ {
56919
+ multiple: true,
56920
+ items: toolCalls.map((tc, i) => ({
56921
+ id: `tc-${index}-${i}`,
56922
+ title: `${tc.name}(${summarizeArgs(tc.args)})`,
56923
+ content: /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: JSON.stringify(tc.args, null, 2), language: "json", maxHeight: "24rem" })
56924
+ }))
56925
+ }
56926
+ )
56927
+ ] });
56928
+ };
56929
+ var CoordinatorConversation = ({ messages, autoScroll = true, className }) => {
56930
+ const endRef = React79__namespace.default.useRef(null);
56931
+ React79__namespace.default.useEffect(() => {
56932
+ if (!autoScroll) return;
56933
+ endRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
56934
+ }, [messages.length, autoScroll]);
56935
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className, children: [
56936
+ messages.map((m, i) => /* @__PURE__ */ jsxRuntime.jsx(ChatMessageRow, { message: m, index: i }, `msg-${i}`)),
56937
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { ref: endRef })
56938
+ ] });
56939
+ };
56940
+ function buildTimelineItems(messages, activities, subagents) {
56941
+ const items = [];
56942
+ if (messages) {
56943
+ messages.forEach((m, i) => items.push({ source: "message", data: m, index: i }));
56944
+ }
56945
+ if (activities) {
56946
+ activities.forEach((a) => items.push({ source: "activity", data: a }));
56947
+ }
56948
+ subagents.forEach((s) => items.push({ source: "subagent", data: s }));
56949
+ return items;
56950
+ }
56951
+ function timelineItemIcon(item) {
56952
+ switch (item.source) {
56953
+ case "message": {
56954
+ const m = item.data;
56955
+ if (m.role === "tool") return { name: "terminal", color: "text-[var(--color-primary)]" };
56956
+ if (m.reasoningContent) return { name: "sparkles", color: "text-[var(--color-primary)]" };
56957
+ if (m.role === "user") return { name: "user", color: "text-[var(--color-primary)]" };
56958
+ return { name: "message-square", color: "text-[var(--color-muted-foreground)]" };
56959
+ }
56960
+ case "activity": {
56961
+ const a = item.data;
56962
+ switch (a.type) {
56963
+ case "tool_call":
56964
+ return { name: "terminal", color: "text-[var(--color-primary)]" };
56965
+ case "tool_result":
56966
+ return { name: a.success !== false ? "check" : "x", color: a.success !== false ? "text-[var(--color-success)]" : "text-[var(--color-danger)]" };
56967
+ case "error":
56968
+ return { name: "alert-triangle", color: "text-[var(--color-danger)]" };
56969
+ case "file_operation":
56970
+ return { name: "file", color: "text-[var(--color-muted-foreground)]" };
56971
+ case "schema_diff":
56972
+ return { name: "git-commit", color: "text-[var(--color-muted-foreground)]" };
56973
+ default:
56974
+ return { name: "info", color: "text-[var(--color-muted-foreground)]" };
56975
+ }
56976
+ }
56977
+ case "subagent":
56978
+ return { name: "bot", color: "text-[var(--color-primary)]" };
56979
+ }
56980
+ }
56981
+ function timelineItemLabel(item) {
56982
+ switch (item.source) {
56983
+ case "message": {
56984
+ const m = item.data;
56985
+ if (m.role === "tool") return "tool";
56986
+ if (m.reasoningContent) return "thinking";
56987
+ return m.role;
56988
+ }
56989
+ case "activity":
56990
+ return item.data.type;
56991
+ case "subagent":
56992
+ return "subagent";
56993
+ }
56994
+ }
56995
+ function timelineItemPreview(item) {
56996
+ switch (item.source) {
56997
+ case "message": {
56998
+ const m = item.data;
56999
+ if (m.role === "tool") return `${m.toolName ?? "tool"} \u2192 ${m.toolCallId?.slice(0, 8) ?? ""}`;
57000
+ if (m.reasoningContent) return previewText(m.reasoningContent, 120);
57001
+ return previewText(m.content, 120);
57002
+ }
57003
+ case "activity": {
57004
+ const a = item.data;
57005
+ switch (a.type) {
57006
+ case "tool_call":
57007
+ return `${a.tool}(${summarizeArgs(a.args)})`;
57008
+ case "tool_result":
57009
+ return `${a.tool}: ${compactJson(a.result)}`;
57010
+ case "message":
57011
+ return previewText(a.content, 120);
57012
+ case "error":
57013
+ return previewText(a.message, 120);
57014
+ case "file_operation":
57015
+ return `${a.operation} ${a.path}`;
57016
+ case "schema_diff":
57017
+ return `diff ${a.filePath}`;
57018
+ default:
57019
+ return String(a.type);
57020
+ }
57021
+ }
57022
+ case "subagent":
57023
+ return `${item.data.name} \xB7 ${item.data.task}`;
57024
+ }
57025
+ }
57026
+ function timelineItemTimeLabel(item) {
57027
+ if (item.source === "activity") return formatHHMMSS(item.data.timestamp);
57028
+ if (item.source === "subagent") {
57029
+ const ts = item.data.messages[0]?.timestamp;
57030
+ return ts !== void 0 ? formatHHMMSS(ts) : void 0;
57031
+ }
57032
+ return void 0;
57033
+ }
57034
+ function TraceDetailContent({ item }) {
57035
+ const { t } = hooks.useTranslate();
57036
+ switch (item.source) {
57037
+ case "message": {
57038
+ const m = item.data;
57039
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57040
+ /* @__PURE__ */ jsxRuntime.jsx(exports.HStack, { gap: "xs", className: "items-center", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: roleBadgeVariant[m.role], className: "text-[10px] uppercase", children: m.role }) }),
57041
+ typeof m.reasoningContent === "string" && m.reasoningContent.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { children: [
57042
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "mb-1", children: t("subagentTrace.reasoning") }),
57043
+ /* @__PURE__ */ jsxRuntime.jsx(exports.MarkdownContent, { content: m.reasoningContent })
57044
+ ] }),
57045
+ m.content.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { children: [
57046
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "mb-1", children: t("subagentTrace.content") }),
57047
+ m.role === "tool" ? (() => {
57048
+ const pretty = tryPrettyJson(m.content);
57049
+ return pretty !== null ? /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: pretty, language: "json", maxHeight: "24rem" }) : /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body", className: "whitespace-pre-wrap font-mono text-[11px]", children: m.content });
57050
+ })() : /* @__PURE__ */ jsxRuntime.jsx(exports.MarkdownContent, { content: m.content })
57051
+ ] }),
57052
+ Array.isArray(m.toolCalls) && m.toolCalls.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { children: [
57053
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "mb-1", children: t("subagentTrace.toolCalls") }),
57054
+ /* @__PURE__ */ jsxRuntime.jsx(
57055
+ exports.Accordion,
57056
+ {
57057
+ multiple: true,
57058
+ items: m.toolCalls.map((tc, i) => ({
57059
+ id: `tc-detail-${i}`,
57060
+ title: `${tc.name}(${summarizeArgs(tc.args)})`,
57061
+ content: /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: JSON.stringify(tc.args, null, 2), language: "json", maxHeight: "24rem" })
57062
+ }))
57063
+ }
57064
+ )
57065
+ ] })
57066
+ ] });
57067
+ }
57068
+ case "activity": {
57069
+ const a = item.data;
57070
+ switch (a.type) {
57071
+ case "tool_call":
57072
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57073
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57074
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "default", className: "text-[10px]", children: "tool_call" }),
57075
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57076
+ ] }),
57077
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", children: a.tool }),
57078
+ /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: JSON.stringify(a.args, null, 2), language: "json", maxHeight: "60vh" })
57079
+ ] });
57080
+ case "tool_result":
57081
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57082
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57083
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: a.success !== false ? "default" : "warning", className: "text-[10px]", children: a.success !== false ? "success" : "fail" }),
57084
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57085
+ ] }),
57086
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", children: a.tool }),
57087
+ /* @__PURE__ */ jsxRuntime.jsx(exports.CodeBlock, { code: JSON.stringify(a.result, null, 2), language: "json", maxHeight: "60vh" })
57088
+ ] });
57089
+ case "message":
57090
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57091
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57092
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "neutral", className: "text-[10px]", children: a.role }),
57093
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57094
+ ] }),
57095
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", className: "whitespace-pre-wrap", children: a.content })
57096
+ ] });
57097
+ case "error":
57098
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57099
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57100
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "warning", className: "text-[10px]", children: "error" }),
57101
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57102
+ ] }),
57103
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", className: "whitespace-pre-wrap text-[var(--color-danger)]", children: a.message })
57104
+ ] });
57105
+ case "file_operation":
57106
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57107
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57108
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "neutral", className: "text-[10px]", children: "file" }),
57109
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57110
+ ] }),
57111
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "body2", children: [
57112
+ a.operation,
57113
+ " ",
57114
+ a.path
57115
+ ] })
57116
+ ] });
57117
+ case "schema_diff":
57118
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57119
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57120
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "neutral", className: "text-[10px]", children: "diff" }),
57121
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) })
57122
+ ] }),
57123
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", children: a.filePath })
57124
+ ] });
57125
+ default:
57126
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57127
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(a.timestamp) }),
57128
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", children: String(a.type) })
57129
+ ] });
57130
+ }
57131
+ }
57132
+ case "subagent": {
57133
+ const s = item.data;
57134
+ const activities = subagentMessagesToActivities(s.messages);
57135
+ const ts = s.messages[0]?.timestamp;
57136
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "md", children: [
57137
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57138
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "default", className: "text-[10px]", children: s.role }),
57139
+ ts !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: formatHHMMSS(ts) })
57140
+ ] }),
57141
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", weight: "semibold", children: s.name }),
57142
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", color: "muted", children: s.task }),
57143
+ activities.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "border-t border-[var(--color-border)] pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(InlineActivityStream, { activities, autoScroll: false }) })
57144
+ ] });
57145
+ }
57146
+ }
57147
+ }
57148
+ var SubagentTracePanel = ({
57149
+ subagents,
57150
+ focusedOrbital,
57151
+ disclosureLevel,
57152
+ open,
57153
+ onClose,
57154
+ className,
57155
+ mode = "overlay",
57156
+ coordinatorActivities,
57157
+ coordinatorMessages
57158
+ }) => {
57159
+ const { t } = hooks.useTranslate();
57160
+ const [selectedItem, setSelectedItem] = React79.useState(null);
57161
+ const densityLabel = (rich) => rich ? t("subagentTrace.densityRich") : t("subagentTrace.densityCompact");
57162
+ if (mode === "overlay" && !open) return null;
57163
+ const isTabMode = mode === "tab";
57164
+ const isRichMode = isTabMode || disclosureLevel >= 3;
57165
+ if (isTabMode) {
57166
+ const timelineItems = buildTimelineItems(coordinatorMessages, coordinatorActivities, subagents);
57167
+ const hasData = timelineItems.length > 0;
57168
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: `h-full w-full bg-[var(--color-card)] overflow-hidden flex flex-col ${className ?? ""}`, children: [
57169
+ /* @__PURE__ */ jsxRuntime.jsxs(
57170
+ exports.HStack,
57171
+ {
57172
+ gap: "sm",
57173
+ className: "items-center px-3 py-2 border-b border-[var(--color-border)]",
57174
+ children: [
57175
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "activity", size: "sm" }),
57176
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold flex-1", children: t("subagentTrace.trace") }),
57177
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(exports.Button, { variant: "ghost", size: "sm", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "x", size: "xs" }) })
57178
+ ]
57179
+ }
57180
+ ),
57181
+ !hasData && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 flex items-center justify-center px-4", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", color: "muted", className: "text-center", children: t("subagentTrace.noAgentActivity") }) }),
57182
+ hasData && /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(exports.VStack, { gap: "none", children: timelineItems.map((item, i) => {
57183
+ const { name: iconName, color: iconColor } = timelineItemIcon(item);
57184
+ const isLast = i === timelineItems.length - 1;
57185
+ return /* @__PURE__ */ jsxRuntime.jsxs(
57186
+ exports.Box,
57187
+ {
57188
+ className: "flex items-start px-3 py-2 border-b border-[var(--color-border)] hover:bg-[var(--color-muted)]/30 transition-colors duration-fast cursor-pointer",
57189
+ onClick: () => setSelectedItem(item),
57190
+ children: [
57191
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "flex flex-col items-center mr-3 mt-0.5", style: { width: 20 }, children: [
57192
+ /* @__PURE__ */ jsxRuntime.jsx(
57193
+ exports.Box,
57194
+ {
57195
+ className: "rounded-full flex-shrink-0",
57196
+ style: {
57197
+ width: 8,
57198
+ height: 8,
57199
+ backgroundColor: "var(--color-primary)"
57200
+ }
57201
+ }
57202
+ ),
57203
+ !isLast && /* @__PURE__ */ jsxRuntime.jsx(
57204
+ exports.Box,
57205
+ {
57206
+ className: "flex-1",
57207
+ style: {
57208
+ width: 2,
57209
+ backgroundColor: "var(--color-border)",
57210
+ marginTop: 4,
57211
+ minHeight: 24
57212
+ }
57213
+ }
57214
+ )
57215
+ ] }),
57216
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "xs", className: "flex-1 min-w-0", children: [
57217
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center", children: [
57218
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: iconName, size: "xs", className: `flex-shrink-0 ${iconColor}` }),
57219
+ timelineItemTimeLabel(item) && /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", children: timelineItemTimeLabel(item) }),
57220
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Badge, { variant: "neutral", className: "text-[10px]", children: timelineItemLabel(item) })
57221
+ ] }),
57222
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "sm", className: "items-start", children: [
57223
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body2", color: "muted", className: "flex-1 min-w-0 line-clamp-2", children: timelineItemPreview(item) }),
57224
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Button, { variant: "ghost", size: "sm", className: "flex-shrink-0 mt-0", onClick: (e) => {
57225
+ e.stopPropagation();
57226
+ setSelectedItem(item);
57227
+ }, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "maximize-2", size: "xs" }) })
57228
+ ] })
57229
+ ] })
57230
+ ]
57231
+ },
57232
+ `${item.source}-${i}`
57233
+ );
57234
+ }) }) }),
57235
+ /* @__PURE__ */ jsxRuntime.jsx(
57236
+ exports.Modal,
57237
+ {
57238
+ isOpen: selectedItem !== null,
57239
+ onClose: () => setSelectedItem(null),
57240
+ title: selectedItem ? `${timelineItemLabel(selectedItem)}${timelineItemTimeLabel(selectedItem) ? ` \xB7 ${timelineItemTimeLabel(selectedItem)}` : ""}` : "",
57241
+ size: "lg",
57242
+ children: selectedItem && /* @__PURE__ */ jsxRuntime.jsx(TraceDetailContent, { item: selectedItem })
57243
+ }
57244
+ )
57245
+ ] });
57246
+ }
57247
+ const filtered = focusedOrbital ? subagents.filter((s) => s.orbitalName === focusedOrbital) : subagents;
57248
+ const wrapperClass = isRichMode ? `absolute inset-x-3 bottom-3 sm:inset-x-auto sm:top-3 sm:right-3 sm:bottom-3 w-full sm:w-[28rem] max-w-[calc(100vw-1.5rem)] max-h-[60vh] sm:max-h-none bg-[var(--color-card)] border border-[var(--color-border)] rounded-md shadow-lg overflow-hidden flex flex-col ${className ?? ""}` : `absolute inset-x-3 bottom-3 sm:inset-x-auto sm:top-3 sm:right-3 sm:bottom-3 w-full sm:w-80 max-w-[calc(100vw-1.5rem)] max-h-[60vh] sm:max-h-none bg-[var(--color-card)] border border-[var(--color-border)] rounded-md shadow-lg overflow-hidden flex flex-col ${className ?? ""}`;
57249
+ const wrapperStyle = { zIndex: 20 };
57250
+ const hasCoordinatorData = coordinatorMessages && coordinatorMessages.length > 0 || coordinatorActivities && coordinatorActivities.length > 0;
57251
+ if (filtered.length === 0 && !hasCoordinatorData) {
57252
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: wrapperClass, style: wrapperStyle, children: [
57253
+ /* @__PURE__ */ jsxRuntime.jsxs(
57254
+ exports.HStack,
57255
+ {
57256
+ gap: "sm",
57257
+ className: "items-center px-3 py-2 border-b border-[var(--color-border)]",
57258
+ children: [
57259
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "activity", size: "sm" }),
57260
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold flex-1", children: t("subagentTrace.subagents") }),
57261
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(exports.Button, { variant: "ghost", size: "sm", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "x", size: "xs" }) })
57262
+ ]
57263
+ }
57264
+ ),
57265
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 flex items-center justify-center px-4", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-center", children: focusedOrbital ? t("subagentTrace.noSubagentsForOrbital", { orbital: focusedOrbital }) : t("subagentTrace.noSubagentsActive") }) })
57266
+ ] });
57267
+ }
57268
+ if (focusedOrbital) {
57269
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: wrapperClass, style: wrapperStyle, children: [
57270
+ /* @__PURE__ */ jsxRuntime.jsxs(
57271
+ exports.HStack,
57272
+ {
57273
+ gap: "sm",
57274
+ className: "items-center px-3 py-2 border-b border-[var(--color-border)]",
57275
+ children: [
57276
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "activity", size: "sm" }),
57277
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.VStack, { gap: "none", className: "flex-1 min-w-0", children: [
57278
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold truncate", children: focusedOrbital }),
57279
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", color: "muted", children: [
57280
+ filtered.length === 1 ? t("subagentTrace.subagentCount", { count: filtered.length }) : t("subagentTrace.subagentCountPlural", { count: filtered.length }),
57281
+ " \xB7 ",
57282
+ densityLabel(isRichMode)
57283
+ ] })
57284
+ ] }),
57285
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(exports.Button, { variant: "ghost", size: "sm", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "x", size: "xs" }) })
57286
+ ]
57287
+ }
57288
+ ),
57289
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "flex-1 overflow-y-auto", children: filtered.map((sub) => isRichMode ? /* @__PURE__ */ jsxRuntime.jsx(SubagentRichCard, { subagent: sub }, sub.id) : /* @__PURE__ */ jsxRuntime.jsx(SubagentRow, { subagent: sub }, sub.id)) })
57290
+ ] });
57291
+ }
57292
+ const grouped = groupByOrbital(filtered);
57293
+ const coordinatorSnapshot = pluckCoordinatorState(coordinatorActivities ?? []);
57294
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: wrapperClass, style: wrapperStyle, children: [
57295
+ /* @__PURE__ */ jsxRuntime.jsxs(
57296
+ exports.HStack,
57297
+ {
57298
+ gap: "sm",
57299
+ className: "items-center px-3 py-2 border-b border-[var(--color-border)]",
57300
+ children: [
57301
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "activity", size: "sm" }),
57302
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Typography, { variant: "caption", className: "font-semibold flex-1", children: [
57303
+ t("subagentTrace.subagentsWithCount", { count: filtered.length }),
57304
+ " \xB7 ",
57305
+ densityLabel(isRichMode)
57306
+ ] }),
57307
+ onClose && /* @__PURE__ */ jsxRuntime.jsx(exports.Button, { variant: "ghost", size: "sm", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { name: "x", size: "xs" }) })
57308
+ ]
57309
+ }
57310
+ ),
57311
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "flex-1 overflow-y-auto", children: [
57312
+ !focusedOrbital && isRichMode && /* @__PURE__ */ jsxRuntime.jsx(CoordinatorCard, { snapshot: coordinatorSnapshot }),
57313
+ coordinatorMessages && coordinatorMessages.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "border-b border-[var(--color-border)]", children: [
57314
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center px-3 py-1.5 bg-[var(--color-card)] border-b border-[var(--color-border)]", children: [
57315
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { style: { width: 6, height: 6, borderRadius: "50%", backgroundColor: "var(--color-primary)", flexShrink: 0 } }),
57316
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold text-[11px]", children: t("subagentTrace.coordinator") }),
57317
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px]", children: t("subagentTrace.messagesCount", { count: coordinatorMessages.length }) })
57318
+ ] }),
57319
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "max-h-[36rem] overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(CoordinatorConversation, { messages: coordinatorMessages, autoScroll: true }) })
57320
+ ] }) : coordinatorActivities && coordinatorActivities.length > 0 && (() => {
57321
+ const filteredCoordinator = coordinatorActivities;
57322
+ if (filteredCoordinator.length === 0) return null;
57323
+ return /* @__PURE__ */ jsxRuntime.jsxs(exports.Box, { className: "border-b border-[var(--color-border)]", children: [
57324
+ /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", className: "items-center px-3 py-1.5 bg-[var(--color-card)] border-b border-[var(--color-border)]", children: [
57325
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { style: { width: 6, height: 6, borderRadius: "50%", backgroundColor: "var(--color-primary)", flexShrink: 0 } }),
57326
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", className: "font-semibold text-[11px]", children: t("subagentTrace.coordinator") }),
57327
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "caption", color: "muted", className: "text-[10px]", children: t("subagentTrace.eventsCount", { count: filteredCoordinator.length }) })
57328
+ ] }),
57329
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "max-h-60 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
57330
+ InlineActivityStream,
57331
+ {
57332
+ activities: coordinatorToActivityItems(filteredCoordinator),
57333
+ autoScroll: true
57334
+ }
57335
+ ) })
57336
+ ] });
57337
+ })(),
57338
+ isRichMode ? filtered.map((sub) => /* @__PURE__ */ jsxRuntime.jsx(SubagentRichCard, { subagent: sub }, sub.id)) : Array.from(grouped.entries()).map(([orbitalName, subs]) => /* @__PURE__ */ jsxRuntime.jsx(
57339
+ OrbitalGroup,
57340
+ {
57341
+ orbitalName,
57342
+ subagents: subs
57343
+ },
57344
+ orbitalName
57345
+ ))
57346
+ ] })
57347
+ ] });
57348
+ };
57349
+ SubagentTracePanel.displayName = "SubagentTracePanel";
57350
+
56168
57351
  // components/core/templates/index.ts
56169
57352
  init_DashboardLayout();
56170
57353
  init_AuthLayout();
@@ -56205,6 +57388,7 @@ exports.CardBattlerTemplate = CardBattlerTemplate;
56205
57388
  exports.CardHand = CardHand;
56206
57389
  exports.CastleBoard = CastleBoard;
56207
57390
  exports.CastleTemplate = CastleTemplate;
57391
+ exports.ChatBar = ChatBar;
56208
57392
  exports.ChoiceButton = ChoiceButton;
56209
57393
  exports.CityBuilderBoard = CityBuilderBoard;
56210
57394
  exports.CityBuilderTemplate = CityBuilderTemplate;
@@ -56226,6 +57410,7 @@ exports.DialogueBubble = DialogueBubble;
56226
57410
  exports.DocPagination = DocPagination;
56227
57411
  exports.DocSearch = DocSearch;
56228
57412
  exports.DomStateMachineVisualizer = exports.StateMachineView;
57413
+ exports.ELEMENT_SELECTED_EVENT = ELEMENT_SELECTED_EVENT;
56229
57414
  exports.EditorCheckbox = EditorCheckbox;
56230
57415
  exports.EditorSelect = EditorSelect;
56231
57416
  exports.EditorSlider = EditorSlider;
@@ -56244,6 +57429,7 @@ exports.GameMenu = GameMenu;
56244
57429
  exports.GameOverScreen = GameOverScreen;
56245
57430
  exports.HealthBar = HealthBar;
56246
57431
  exports.HealthPanel = HealthPanel;
57432
+ exports.HexStrategyBoard = HexStrategyBoard;
56247
57433
  exports.InventoryGrid = InventoryGrid;
56248
57434
  exports.InventoryPanel = InventoryPanel;
56249
57435
  exports.IsometricCanvas = IsometricCanvas;
@@ -56285,6 +57471,7 @@ exports.StateJsonView = StateJsonView;
56285
57471
  exports.StateNode = StateNode2;
56286
57472
  exports.StatusBar = StatusBar;
56287
57473
  exports.StatusEffect = StatusEffect;
57474
+ exports.SubagentTracePanel = SubagentTracePanel;
56288
57475
  exports.TERRAIN_COLORS = TERRAIN_COLORS;
56289
57476
  exports.TableView = TableView;
56290
57477
  exports.TerrainPalette = TerrainPalette;
@@ -56328,6 +57515,7 @@ exports.getTileDimensions = getTileDimensions;
56328
57515
  exports.inferDirection = inferDirection;
56329
57516
  exports.isoToScreen = isoToScreen;
56330
57517
  exports.mapBookData = mapBookData;
57518
+ exports.parseEditFocus = parseEditFocus;
56331
57519
  exports.parseLessonSegments = parseLessonSegments;
56332
57520
  exports.parseMarkdownWithCodeBlocks = parseMarkdownWithCodeBlocks;
56333
57521
  exports.resolveFieldMap = resolveFieldMap;