@almadar/ui 5.65.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.
@@ -10190,7 +10190,8 @@ function IsometricCanvas({
10190
10190
  const minX = Math.min(...allScreenPos.map((p2) => p2.x));
10191
10191
  const maxX = Math.max(...allScreenPos.map((p2) => p2.x + scaledTileWidth));
10192
10192
  const minY = Math.min(...allScreenPos.map((p2) => p2.y));
10193
- 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));
10194
10195
  const worldW = maxX - minX;
10195
10196
  const worldH = maxY - minY;
10196
10197
  const scaleM = Math.min(mW / worldW, mH / worldH) * 0.9;
@@ -10282,7 +10283,7 @@ function IsometricCanvas({
10282
10283
  const drawW = scaledTileWidth;
10283
10284
  const drawH = scaledTileWidth * (img.naturalHeight / img.naturalWidth);
10284
10285
  const drawX = pos.x;
10285
- const drawY = pos.y + scaledTileHeight - drawH;
10286
+ const drawY = tileLayout === "hex" ? pos.y : pos.y + scaledTileHeight - drawH;
10286
10287
  ctx.drawImage(img, drawX, drawY, drawW, drawH);
10287
10288
  }
10288
10289
  } else {
@@ -20583,6 +20584,8 @@ var init_ChartLegend = __esm({
20583
20584
  function ChoiceButton({
20584
20585
  text = "Charge forward into the fray",
20585
20586
  index,
20587
+ assetUrl,
20588
+ icon,
20586
20589
  disabled = false,
20587
20590
  selected = false,
20588
20591
  onClick,
@@ -20615,6 +20618,23 @@ function ChoiceButton({
20615
20618
  ]
20616
20619
  }
20617
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,
20618
20638
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-snug", children: text })
20619
20639
  ]
20620
20640
  }
@@ -20623,6 +20643,7 @@ function ChoiceButton({
20623
20643
  var init_ChoiceButton = __esm({
20624
20644
  "components/game/atoms/ChoiceButton.tsx"() {
20625
20645
  init_cn();
20646
+ init_Icon();
20626
20647
  ChoiceButton.displayName = "ChoiceButton";
20627
20648
  }
20628
20649
  });
@@ -28736,6 +28757,7 @@ function PowerupSlots({
28736
28757
  /* @__PURE__ */ jsxRuntime.jsx(
28737
28758
  ItemSlot,
28738
28759
  {
28760
+ assetUrl: powerup.assetUrl,
28739
28761
  icon: powerup.icon,
28740
28762
  label: powerup.label,
28741
28763
  rarity: "uncommon",
@@ -28985,13 +29007,26 @@ function HealthPanel({
28985
29007
  )
28986
29008
  }
28987
29009
  ),
28988
- 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(
28989
29011
  exports.Badge,
28990
29012
  {
28991
29013
  variant: effectVariantMap[effect.variant ?? "neutral"],
28992
29014
  size: "sm",
28993
- icon: effect.icon,
28994
- 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
+ ]
28995
29030
  },
28996
29031
  i
28997
29032
  )) })
@@ -29238,15 +29273,28 @@ function TurnPanel({
29238
29273
  activeTeam
29239
29274
  }
29240
29275
  ),
29241
- 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(
29242
29277
  exports.Button,
29243
29278
  {
29244
29279
  variant: "ghost",
29245
29280
  size: "sm",
29246
29281
  disabled: action.disabled,
29247
- leftIcon: action.icon,
29282
+ leftIcon: action.assetUrl ? void 0 : action.icon,
29248
29283
  onClick: () => handleAction(action.event),
29249
- 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
+ ]
29250
29298
  },
29251
29299
  i
29252
29300
  )) })
@@ -31006,13 +31054,13 @@ var init_MapView = __esm({
31006
31054
  shadowSize: [41, 41]
31007
31055
  });
31008
31056
  L.Marker.prototype.options.icon = defaultIcon;
31009
- 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;
31010
31058
  const { Typography: Typography2 } = await Promise.resolve().then(() => (init_Typography(), Typography_exports));
31011
31059
  const { useEventBus: useEventBus3 } = await Promise.resolve().then(() => (init_useEventBus(), useEventBus_exports));
31012
31060
  function MapUpdater({ centerLat, centerLng, zoom }) {
31013
31061
  const map = useMap();
31014
31062
  const prevRef = useRef83({ centerLat, centerLng, zoom });
31015
- useEffect83(() => {
31063
+ useEffect84(() => {
31016
31064
  const prev = prevRef.current;
31017
31065
  if (prev.centerLat !== centerLat || prev.centerLng !== centerLng || prev.zoom !== zoom) {
31018
31066
  map.setView([centerLat, centerLng], zoom);
@@ -31023,7 +31071,7 @@ var init_MapView = __esm({
31023
31071
  }
31024
31072
  function MapClickHandler({ onMapClick }) {
31025
31073
  const map = useMap();
31026
- useEffect83(() => {
31074
+ useEffect84(() => {
31027
31075
  if (!onMapClick) return;
31028
31076
  const handler = (e) => {
31029
31077
  onMapClick(e.latlng.lat, e.latlng.lng);
@@ -31051,8 +31099,8 @@ var init_MapView = __esm({
31051
31099
  showAttribution = true
31052
31100
  }) {
31053
31101
  const eventBus = useEventBus3();
31054
- const [clickedPosition, setClickedPosition] = useState112(null);
31055
- const handleMapClick = useCallback127((lat, lng) => {
31102
+ const [clickedPosition, setClickedPosition] = useState114(null);
31103
+ const handleMapClick = useCallback128((lat, lng) => {
31056
31104
  if (showClickedPin) {
31057
31105
  setClickedPosition({ lat, lng });
31058
31106
  }
@@ -31061,7 +31109,7 @@ var init_MapView = __esm({
31061
31109
  eventBus.emit(`UI:${mapClickEvent}`, { latitude: lat, longitude: lng });
31062
31110
  }
31063
31111
  }, [onMapClick, mapClickEvent, eventBus, showClickedPin]);
31064
- const handleMarkerClick = useCallback127((marker) => {
31112
+ const handleMarkerClick = useCallback128((marker) => {
31065
31113
  onMarkerClick?.(marker);
31066
31114
  if (markerClickEvent) {
31067
31115
  eventBus.emit(`UI:${markerClickEvent}`, { ...marker });
@@ -44512,9 +44560,9 @@ var init_GameCanvas3D2 = __esm({
44512
44560
  const color = unit.faction === "player" ? 4491519 : unit.faction === "enemy" ? 16729156 : 16777028;
44513
44561
  const hasAtlas = unitAtlasUrl(unit) !== null;
44514
44562
  const initialFrame = hasAtlas ? resolveUnitFrame(unit.id) : null;
44515
- const modelScale = UNIT_BASE_MODEL_SCALE * unitScale;
44516
- const billboardHeight = UNIT_BASE_BILLBOARD_HEIGHT * unitScale;
44517
- 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;
44518
44566
  return /* @__PURE__ */ jsxRuntime.jsxs(
44519
44567
  "group",
44520
44568
  {
@@ -44561,7 +44609,7 @@ var init_GameCanvas3D2 = __esm({
44561
44609
  /* @__PURE__ */ jsxRuntime.jsx("meshStandardMaterial", { color })
44562
44610
  ] })
44563
44611
  ] }),
44564
- 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: [
44565
44613
  /* @__PURE__ */ jsxRuntime.jsxs("mesh", { position: [-0.25, 0, 0], children: [
44566
44614
  /* @__PURE__ */ jsxRuntime.jsx("planeGeometry", { args: [0.5, 0.05] }),
44567
44615
  /* @__PURE__ */ jsxRuntime.jsx("meshBasicMaterial", { color: 3355443 })
@@ -44590,7 +44638,7 @@ var init_GameCanvas3D2 = __esm({
44590
44638
  }
44591
44639
  );
44592
44640
  },
44593
- [selectedUnitId, handleUnitClick, resolveUnitFrame, unitScale]
44641
+ [selectedUnitId, handleUnitClick, resolveUnitFrame, unitScale, gridConfig]
44594
44642
  );
44595
44643
  const DefaultFeatureRenderer = React79.useCallback(
44596
44644
  ({
@@ -44678,7 +44726,7 @@ var init_GameCanvas3D2 = __esm({
44678
44726
  {
44679
44727
  ref: containerRef,
44680
44728
  className: cn("game-canvas-3d relative w-full overflow-hidden", className),
44681
- style: { height: "85vh" },
44729
+ style: { flex: "1 1 0", minHeight: "400px" },
44682
44730
  "data-orientation": orientation,
44683
44731
  "data-camera-mode": cameraMode,
44684
44732
  "data-overlay": overlay,
@@ -44978,13 +45026,39 @@ var init_GameBoard3D = __esm({
44978
45026
  GameBoard3D.displayName = "GameBoard3D";
44979
45027
  }
44980
45028
  });
44981
- 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;
44982
45055
  var init_GameShell = __esm({
44983
45056
  "components/game/templates/GameShell.tsx"() {
44984
45057
  init_cn();
44985
45058
  init_Box();
44986
45059
  init_Stack();
44987
45060
  init_Typography();
45061
+ _scr = null;
44988
45062
  exports.GameShell = ({
44989
45063
  appName = "Game",
44990
45064
  hud,
@@ -45033,7 +45107,7 @@ var init_GameShell = __esm({
45033
45107
  children: appName
45034
45108
  }
45035
45109
  ),
45036
- 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") })
45037
45111
  ]
45038
45112
  }
45039
45113
  ),
@@ -45046,7 +45120,7 @@ var init_GameShell = __esm({
45046
45120
  overflow: "hidden",
45047
45121
  position: "relative"
45048
45122
  },
45049
- children
45123
+ children: resolveDescriptor(children, "gs-children")
45050
45124
  }
45051
45125
  )
45052
45126
  ]
@@ -45056,7 +45130,32 @@ var init_GameShell = __esm({
45056
45130
  exports.GameShell.displayName = "GameShell";
45057
45131
  }
45058
45132
  });
45059
- 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;
45060
45159
  var init_GameTemplate = __esm({
45061
45160
  "components/game/templates/GameTemplate.tsx"() {
45062
45161
  init_cn();
@@ -45064,6 +45163,7 @@ var init_GameTemplate = __esm({
45064
45163
  init_Stack();
45065
45164
  init_Typography();
45066
45165
  init_Button();
45166
+ _scr2 = null;
45067
45167
  exports.GameTemplate = ({
45068
45168
  entity,
45069
45169
  title = "Game",
@@ -45131,13 +45231,13 @@ var init_GameTemplate = __esm({
45131
45231
  fullWidth: true,
45132
45232
  className: "flex-1 bg-muted",
45133
45233
  children: [
45134
- children,
45234
+ resolveDescriptor2(children, "gt-children"),
45135
45235
  hud && /* @__PURE__ */ jsxRuntime.jsx(
45136
45236
  exports.Box,
45137
45237
  {
45138
45238
  position: "absolute",
45139
45239
  className: "top-0 left-0 right-0 pointer-events-none",
45140
- 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") })
45141
45241
  }
45142
45242
  )
45143
45243
  ]
@@ -45162,7 +45262,7 @@ var init_GameTemplate = __esm({
45162
45262
  children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "h6", children: "Debug Panel" })
45163
45263
  }
45164
45264
  ),
45165
- /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", children: debugPanel })
45265
+ /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { padding: "md", children: resolveDescriptor2(debugPanel, "gt-debug") })
45166
45266
  ]
45167
45267
  }
45168
45268
  )
@@ -54221,7 +54321,7 @@ function getSlotFallback(slot, config) {
54221
54321
  const variant = SLOT_SKELETON_MAP[slot] ?? "text";
54222
54322
  return /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { variant });
54223
54323
  }
54224
- function getComponentForPattern(patternType) {
54324
+ function getComponentForPattern3(patternType) {
54225
54325
  const mapping = patterns.getComponentForPattern(patternType);
54226
54326
  if (!mapping) {
54227
54327
  return null;
@@ -54852,7 +54952,8 @@ function SlotContentRenderer({
54852
54952
  entityDef = schemaCtx.entities.get(linkedEntity);
54853
54953
  }
54854
54954
  }
54855
- 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);
54856
54957
  if (PatternComponent) {
54857
54958
  const childrenConfig = content.props.children;
54858
54959
  const isSingleChild = typeof childrenConfig === "string" || typeof childrenConfig === "object" && childrenConfig !== null && !Array.isArray(childrenConfig) && "type" in childrenConfig;
@@ -54950,6 +55051,7 @@ function SlotContentRenderer({
54950
55051
  "data-orb-entity": content.entity,
54951
55052
  "data-orb-path": myPath,
54952
55053
  "data-orb-pattern": content.pattern,
55054
+ "data-orb-orbital": orbitalName,
54953
55055
  children: renderedChildren !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(PatternComponent, { ...finalProps, children: renderedChildren }) : /* @__PURE__ */ jsxRuntime.jsx(PatternComponent, { ...finalProps })
54954
55056
  }
54955
55057
  );
@@ -54969,6 +55071,7 @@ function SlotContentRenderer({
54969
55071
  "data-orb-entity": content.entity,
54970
55072
  "data-orb-path": patternPath ?? "root",
54971
55073
  "data-orb-pattern": content.pattern,
55074
+ "data-orb-orbital": orbitalName,
54972
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: [
54973
55076
  "Unknown pattern: ",
54974
55077
  content.pattern,
@@ -55138,7 +55241,7 @@ function TraitFrame({
55138
55241
  if (!content) {
55139
55242
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
55140
55243
  }
55141
- const SlotContentRenderer2 = getSlotContentRenderer();
55244
+ const SlotContentRenderer2 = getSlotContentRenderer3();
55142
55245
  const rendered = /* @__PURE__ */ jsxRuntime.jsx(
55143
55246
  SlotContentRenderer2,
55144
55247
  {
@@ -55152,7 +55255,7 @@ function TraitFrame({
55152
55255
  }
55153
55256
  return /* @__PURE__ */ jsxRuntime.jsx(providers.TraitScopeProvider, { orbital, trait: traitName, children: rendered });
55154
55257
  }
55155
- function getSlotContentRenderer() {
55258
+ function getSlotContentRenderer3() {
55156
55259
  if (_slotContentRenderer) return _slotContentRenderer;
55157
55260
  const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
55158
55261
  _slotContentRenderer = mod.SlotContentRenderer;
@@ -56228,6 +56331,1023 @@ init_CaseStudyOrganism();
56228
56331
  init_CodeRunnerPanel();
56229
56332
  init_SegmentRenderer();
56230
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
+
56231
57351
  // components/core/templates/index.ts
56232
57352
  init_DashboardLayout();
56233
57353
  init_AuthLayout();
@@ -56268,6 +57388,7 @@ exports.CardBattlerTemplate = CardBattlerTemplate;
56268
57388
  exports.CardHand = CardHand;
56269
57389
  exports.CastleBoard = CastleBoard;
56270
57390
  exports.CastleTemplate = CastleTemplate;
57391
+ exports.ChatBar = ChatBar;
56271
57392
  exports.ChoiceButton = ChoiceButton;
56272
57393
  exports.CityBuilderBoard = CityBuilderBoard;
56273
57394
  exports.CityBuilderTemplate = CityBuilderTemplate;
@@ -56289,6 +57410,7 @@ exports.DialogueBubble = DialogueBubble;
56289
57410
  exports.DocPagination = DocPagination;
56290
57411
  exports.DocSearch = DocSearch;
56291
57412
  exports.DomStateMachineVisualizer = exports.StateMachineView;
57413
+ exports.ELEMENT_SELECTED_EVENT = ELEMENT_SELECTED_EVENT;
56292
57414
  exports.EditorCheckbox = EditorCheckbox;
56293
57415
  exports.EditorSelect = EditorSelect;
56294
57416
  exports.EditorSlider = EditorSlider;
@@ -56349,6 +57471,7 @@ exports.StateJsonView = StateJsonView;
56349
57471
  exports.StateNode = StateNode2;
56350
57472
  exports.StatusBar = StatusBar;
56351
57473
  exports.StatusEffect = StatusEffect;
57474
+ exports.SubagentTracePanel = SubagentTracePanel;
56352
57475
  exports.TERRAIN_COLORS = TERRAIN_COLORS;
56353
57476
  exports.TableView = TableView;
56354
57477
  exports.TerrainPalette = TerrainPalette;
@@ -56392,6 +57515,7 @@ exports.getTileDimensions = getTileDimensions;
56392
57515
  exports.inferDirection = inferDirection;
56393
57516
  exports.isoToScreen = isoToScreen;
56394
57517
  exports.mapBookData = mapBookData;
57518
+ exports.parseEditFocus = parseEditFocus;
56395
57519
  exports.parseLessonSegments = parseLessonSegments;
56396
57520
  exports.parseMarkdownWithCodeBlocks = parseMarkdownWithCodeBlocks;
56397
57521
  exports.resolveFieldMap = resolveFieldMap;