<!-- source-hash: d70b1713cdb85568acf904d7a2daa162 -->
Renders enhanced chat messages with support for multi-segment content, inline/block entity card markers, tool executions, approval flows, and rich markdown — delegating entity resolution and navigation to host-provided callbacks.

## Key Components

| Export | Type | Description |
|--------|------|-------------|
| `ChatMessageEnhanced` | `forwardRef` component | Main message renderer with role-aware layout (`user`, `error`, assistant variants) |
| `normalizeContent` | Function | Normalizes `MessageContent` (string or `MessageSegment[]`) to a uniform segment array |
| `CARD_MARKER_REGEX` | Regex | Shared pattern matching `[card://type:id]` markers — kept in lockstep with `remarkCardLinks` |
| `renderingPlan` | `useMemo` | Per-message plan splitting text segments at block card markers for accurate streaming position |
| `cardComponentOverrides` | `useMemo` | Overrides `<a>` tags for `card://` URLs, resolving inline/block entity cards via host callbacks |

### Supporting Displays (composed internally)
- `ToolExecutionDisplay` — renders tool call segments
- `ApprovalRequestMessage` / `ApprovalBatchMessage` — approval flow segments
- `ErrorMessageDisplay` — error role messages
- `ContextCompactionDisplay` — context compaction events
- `ThinkingDisplay` — streaming thinking segments

## Usage Example

```typescript
<ChatMessageEnhanced
  role="assistant"
  assistantType="mingo"
  content={[
    { type: 'text', text: 'Here is your ticket [card://ticket:123].' },
    { type: 'tool_execution', toolName: 'search', result: '...' },
  ]}
  chatRefs={{
    'ticket:123': { type: 'ticket', id: '123', title: 'Login bug', url: '/tickets/123' },
  }}
  renderEntityCard={(ref) => <TicketPill ref={ref} />}
  NavLinkAnchor={({ href, children }) => <Link href={href}>{children}</Link>}
  showAvatar
/>
```

## Notes

- **Data-agnostic**: the library never imports entity types or routing — the host provides `renderEntityCard` and `NavLinkAnchor`.
- Block card markers split their text segment so block payloads render at the marker position during streaming, not appended at the end.
- Three distinct fallbacks for unresolved `card://` hrefs prevent LLM hallucinations from appearing as real cards.