{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "trace-waterfall",
  "type": "registry:component",
  "title": "Trace waterfall",
  "description": "A distributed trace as a collapsible span tree beside a zoomable time axis, with the critical path, errors, and span detail one click away.",
  "categories": [
    "operations"
  ],
  "dependencies": [
    "@tabler/icons-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/trace-waterfall.tsx",
      "type": "registry:component",
      "target": "components/overtrue/trace-waterfall.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  IconAlertTriangleFilled as AlertTriangle,\n  IconChevronRight as ChevronRight,\n  IconFoldDown as FoldDown,\n  IconFoldUp as FoldUp,\n  IconRoute as Route,\n  IconX as X,\n  IconZoomReset as ZoomReset,\n} from \"@tabler/icons-react\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport type TraceSpanStatus = \"ok\" | \"error\";\n\nexport type TraceSpanAttributeValue = string | number | boolean;\n\nexport interface TraceSpan {\n  id: string;\n  /** The calling span. Spans without a known parent are drawn as roots. */\n  parentId?: string | null;\n  /** Operation name, e.g. \"POST /api/checkout\" or \"SELECT orders\". */\n  name: string;\n  /** Emitting service. Spans of one service share a color. */\n  service: string;\n  /** Milliseconds from the start of the trace. */\n  start: number;\n  /** Milliseconds. */\n  duration: number;\n  status?: TraceSpanStatus;\n  attributes?: Record<string, TraceSpanAttributeValue>;\n}\n\n/** Everything derived about one span, passed to `renderDetail`. */\nexport interface TraceSpanInfo {\n  span: TraceSpan;\n  parent: TraceSpan | null;\n  children: TraceSpan[];\n  depth: number;\n  /** All spans below this one, at any depth. */\n  descendantCount: number;\n  /** Time not covered by any child span, in milliseconds. */\n  selfTime: number;\n  /** Duration as a 0–1 share of the whole trace. */\n  share: number;\n  /** Whether the span is on the trace's critical path. */\n  critical: boolean;\n  /** The resolved service color. */\n  color: string;\n  /** Start and end of the whole trace, in milliseconds. */\n  trace: { start: number; end: number; duration: number };\n}\n\nexport type TraceTimeRange = [start: number, end: number];\n\nexport interface TraceWaterfallProps extends Omit<\n  React.ComponentProps<\"div\">,\n  \"title\" | \"children\"\n> {\n  spans: TraceSpan[];\n  title?: React.ReactNode;\n  description?: React.ReactNode;\n  /** Controls placed at the top right, before the built-in tools. */\n  actions?: React.ReactNode;\n  /** Selected span. Pass `null` for none; leave undefined to let the component manage it. */\n  selectedId?: string | null;\n  defaultSelectedId?: string | null;\n  onSelectedChange?: (id: string | null, span: TraceSpan | null) => void;\n  /** Emphasise the longest blocking chain. Pass with `onHighlightCriticalPathChange` to control it. */\n  highlightCriticalPath?: boolean;\n  defaultHighlightCriticalPath?: boolean;\n  onHighlightCriticalPathChange?: (highlight: boolean) => void;\n  /** Spans that start collapsed. */\n  defaultCollapsedIds?: string[];\n  /** Colors by service name. Unlisted services take the chart palette in order of appearance. */\n  serviceColors?: Record<string, string>;\n  /** Formats every duration and offset except axis ticks. */\n  durationFormatter?: (ms: number) => string;\n  /** Replaces the attribute table in the detail panel. Compose `TraceSpanAttributes` to keep it. */\n  renderDetail?: (span: TraceSpan, info: TraceSpanInfo) => React.ReactNode;\n  /** Row height in pixels. Defaults to 28. */\n  rowHeight?: number;\n  /** Maximum height of the scrolling span list in pixels. Defaults to 360. */\n  height?: number;\n  /** Width of the span tree as a 0.2–0.7 share of the card. Drag the divider to change it. */\n  treeWidth?: number;\n  /** Show the whole-trace minimap above the list. Defaults to true. */\n  showOverview?: boolean;\n  /** Show the service legend, which doubles as a filter. Defaults to true. */\n  showLegend?: boolean;\n  /** Called when the visible time range changes, with `null` when zoom resets. */\n  onZoomChange?: (range: TraceTimeRange | null) => void;\n}\n\n/* ------------------------------------------------------------------------ */\n/* Formatting                                                                */\n/* ------------------------------------------------------------------------ */\n\nfunction formatDuration(ms: number) {\n  if (!Number.isFinite(ms)) return \"—\";\n  const a = Math.abs(ms);\n  if (a === 0) return \"0ms\";\n  if (a < 1) return `${Math.round(ms * 1000)}µs`;\n  if (a < 10) return `${ms.toFixed(2)}ms`;\n  if (a < 100) return `${ms.toFixed(1)}ms`;\n  if (a < 1000) return `${Math.round(ms)}ms`;\n  if (a < 10_000) return `${(ms / 1000).toFixed(2)}s`;\n  if (a < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n  const minutes = Math.floor(ms / 60_000);\n  return `${minutes}m ${Math.round((ms - minutes * 60_000) / 1000)}s`;\n}\n\nfunction formatPercent(share: number) {\n  const pct = share * 100;\n  if (pct > 0 && pct < 0.1) return \"<0.1%\";\n  return `${pct >= 10 ? pct.toFixed(0) : pct.toFixed(1)}%`;\n}\n\nconst tidy = (value: number) => +value.toPrecision(12);\n\nfunction niceStep(span: number, count: number) {\n  const raw = span / Math.max(1, count);\n  const magnitude = 10 ** Math.floor(Math.log10(raw));\n  const r = raw / magnitude;\n  return (\n    (r <= 1 ? 1 : r <= 2 ? 2 : r <= 2.5 ? 2.5 : r <= 5 ? 5 : 10) * magnitude\n  );\n}\n\n/** Tick labels carry exactly the precision of the step, so neighbors never read alike. */\nfunction tickLabel(value: number, step: number) {\n  if (value === 0) return \"0\";\n  if (step >= 1000 || (Math.abs(value) >= 1000 && step >= 100)) {\n    const digits = Math.max(0, -Math.floor(Math.log10(step / 1000) + 1e-9));\n    return `${(value / 1000).toFixed(Math.min(3, digits))}s`;\n  }\n  if (step < 1 && step < 0.01) return `${tidy(value * 1000)}µs`;\n  const digits = Math.max(0, -Math.floor(Math.log10(step) + 1e-9));\n  return `${value.toFixed(Math.min(3, digits))}ms`;\n}\n\n/* ------------------------------------------------------------------------ */\n/* Model                                                                     */\n/* ------------------------------------------------------------------------ */\n\ninterface TraceNode {\n  span: TraceSpan;\n  order: number;\n  parent: TraceNode | null;\n  children: TraceNode[];\n  depth: number;\n  end: number;\n  self: number;\n  descendants: number;\n  critical: boolean;\n}\n\ninterface TraceModel {\n  nodes: Map<string, TraceNode>;\n  roots: TraceNode[];\n  /** Every node in tree order. */\n  ordered: TraceNode[];\n  start: number;\n  end: number;\n  duration: number;\n  services: { name: string; count: number; errors: number }[];\n  errors: number;\n}\n\nconst PALETTE = [\n  \"var(--color-chart-1)\",\n  \"var(--color-chart-2)\",\n  \"var(--color-chart-3)\",\n  \"var(--color-chart-4)\",\n  \"var(--color-chart-5)\",\n  // Blends of the theme's own chart colors keep extra services on-palette.\n  \"color-mix(in oklab, var(--color-chart-1) 50%, var(--color-chart-2))\",\n  \"color-mix(in oklab, var(--color-chart-2) 50%, var(--color-chart-3))\",\n  \"color-mix(in oklab, var(--color-chart-4) 55%, var(--color-chart-5))\",\n];\n\nconst DESTRUCTIVE = \"var(--color-destructive)\";\nconst errorFill = `repeating-linear-gradient(-45deg, ${DESTRUCTIVE} 0 3px, color-mix(in oklab, ${DESTRUCTIVE} 58%, var(--color-card)) 3px 6px)`;\n\nfunction buildModel(spans: TraceSpan[]): TraceModel {\n  const nodes = new Map<string, TraceNode>();\n  spans.forEach((span, order) => {\n    if (nodes.has(span.id)) return;\n    const start = Number.isFinite(span.start) ? span.start : 0;\n    const duration = Number.isFinite(span.duration)\n      ? Math.max(0, span.duration)\n      : 0;\n    nodes.set(span.id, {\n      span,\n      order,\n      parent: null,\n      children: [],\n      depth: 0,\n      end: start + duration,\n      self: duration,\n      descendants: 0,\n      critical: false,\n    });\n  });\n\n  const roots: TraceNode[] = [];\n  for (const node of nodes.values()) {\n    const parentId = node.span.parentId;\n    const parent =\n      parentId != null && parentId !== node.span.id\n        ? nodes.get(parentId)\n        : undefined;\n    if (parent) {\n      node.parent = parent;\n      parent.children.push(node);\n    } else roots.push(node);\n  }\n\n  const byStart = (a: TraceNode, b: TraceNode) =>\n    a.span.start - b.span.start || a.order - b.order;\n  const ordered: TraceNode[] = [];\n  const visited = new Set<TraceNode>();\n  const visit = (node: TraceNode, depth: number) => {\n    visited.add(node);\n    node.depth = depth;\n    ordered.push(node);\n    node.children = node.children\n      .filter((child) => !visited.has(child))\n      .sort(byStart);\n    let descendants = 0;\n    for (const child of node.children) {\n      visit(child, depth + 1);\n      descendants += 1 + child.descendants;\n    }\n    node.descendants = descendants;\n    // Self time: the span's duration minus the union of its children's time inside it.\n    const start = node.span.start;\n    const intervals = node.children\n      .map(\n        (child) =>\n          [\n            Math.max(child.span.start, start),\n            Math.min(child.end, node.end),\n          ] as const,\n      )\n      .filter(([a, b]) => b > a)\n      .sort((a, b) => a[0] - b[0]);\n    let covered = 0;\n    let cursor = -Infinity;\n    for (const [a, b] of intervals) {\n      if (b <= cursor) continue;\n      covered += b - Math.max(a, cursor);\n      cursor = b;\n    }\n    node.self = Math.max(0, node.end - start - covered);\n  };\n  roots.sort(byStart);\n  for (const root of roots) visit(root, 0);\n  // Spans caught in a parent cycle are never reached from a root; draw them as roots.\n  for (const node of nodes.values())\n    if (!visited.has(node)) {\n      node.parent = null;\n      roots.push(node);\n      visit(node, 0);\n    }\n\n  let start = 0;\n  let end = 0;\n  let errors = 0;\n  const services = new Map<\n    string,\n    { name: string; count: number; errors: number }\n  >();\n  for (const node of ordered) {\n    start = Math.min(start, node.span.start);\n    end = Math.max(end, node.end);\n    const isError = node.span.status === \"error\";\n    if (isError) errors += 1;\n    const entry = services.get(node.span.service) ?? {\n      name: node.span.service,\n      count: 0,\n      errors: 0,\n    };\n    entry.count += 1;\n    if (isError) entry.errors += 1;\n    services.set(node.span.service, entry);\n  }\n\n  // Critical path: from the longest root, walk back from each span's end through the\n  // child that finished last, then whatever finished before that child started.\n  const markCritical = (node: TraceNode) => {\n    node.critical = true;\n    let cursor = node.end + 1e-9;\n    const byEnd = [...node.children].sort((a, b) => b.end - a.end);\n    for (const child of byEnd) {\n      if (child.end <= cursor && child.end > node.span.start) {\n        markCritical(child);\n        cursor = child.span.start + 1e-9;\n      }\n    }\n  };\n  const main = roots.reduce<TraceNode | null>(\n    (best, root) =>\n      !best || root.end - root.span.start > best.end - best.span.start\n        ? root\n        : best,\n    null,\n  );\n  if (main) markCritical(main);\n\n  return {\n    nodes,\n    roots,\n    ordered,\n    start,\n    end,\n    duration: end - start || 1,\n    services: [...services.values()],\n    errors,\n  };\n}\n\ninterface TraceRowModel {\n  node: TraceNode;\n  depth: number;\n  /** For each ancestor column, whether a guide line continues through this row. */\n  lines: boolean[];\n  last: boolean;\n  childCount: number;\n  collapsed: boolean;\n  hiddenCount: number;\n  /** Descendants hidden by collapsing, drawn as a faint summary. */\n  summary: TraceNode[];\n  parentId: string | null;\n  position: number;\n  setSize: number;\n}\n\nfunction visibleChildren(\n  children: TraceNode[],\n  hidden: Set<string>,\n): TraceNode[] {\n  if (!hidden.size) return children;\n  let lifted = false;\n  const out: TraceNode[] = [];\n  for (const child of children) {\n    if (hidden.has(child.span.service)) {\n      lifted = true;\n      out.push(...visibleChildren(child.children, hidden));\n    } else out.push(child);\n  }\n  return lifted\n    ? out.sort((a, b) => a.span.start - b.span.start || a.order - b.order)\n    : out;\n}\n\nfunction buildRows(\n  model: TraceModel,\n  collapsed: Set<string>,\n  hidden: Set<string>,\n) {\n  const rows: TraceRowModel[] = [];\n  const flat: TraceNode[] = [];\n  const collect = (node: TraceNode, into: TraceNode[]) => {\n    for (const child of visibleChildren(node.children, hidden)) {\n      into.push(child);\n      collect(child, into);\n    }\n  };\n  const visit = (\n    node: TraceNode,\n    depth: number,\n    lines: boolean[],\n    last: boolean,\n    parentId: string | null,\n    position: number,\n    setSize: number,\n  ) => {\n    const kids = visibleChildren(node.children, hidden);\n    const isCollapsed = kids.length > 0 && collapsed.has(node.span.id);\n    const summary: TraceNode[] = [];\n    if (isCollapsed) collect(node, summary);\n    rows.push({\n      node,\n      depth,\n      lines,\n      last,\n      childCount: kids.length,\n      collapsed: isCollapsed,\n      hiddenCount: summary.length,\n      summary: summary.slice(0, 60),\n      parentId,\n      position,\n      setSize,\n    });\n    if (isCollapsed) return;\n    const childLines = depth === 0 ? [] : [...lines, !last];\n    kids.forEach((kid, i) =>\n      visit(\n        kid,\n        depth + 1,\n        childLines,\n        i === kids.length - 1,\n        node.span.id,\n        i + 1,\n        kids.length,\n      ),\n    );\n  };\n  const roots = visibleChildren(model.roots, hidden);\n  roots.forEach((root, i) =>\n    visit(root, 0, [], i === roots.length - 1, null, i + 1, roots.length),\n  );\n  // The overview ignores collapsing but follows the service filter.\n  for (const root of roots) {\n    flat.push(root);\n    collect(root, flat);\n  }\n  return { rows, flat };\n}\n\n/* ------------------------------------------------------------------------ */\n/* Hooks                                                                     */\n/* ------------------------------------------------------------------------ */\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (onChange) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", onChange);\n      return () => query.removeEventListener(\"change\", onChange);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction useControllable<T>(\n  value: T | undefined,\n  defaultValue: T,\n  onChange?: (value: T) => void,\n) {\n  const [inner, setInner] = React.useState(defaultValue);\n  const controlled = value !== undefined;\n  const current = controlled ? value : inner;\n  const set = React.useCallback(\n    (next: T) => {\n      if (!controlled) setInner(next);\n      onChange?.(next);\n    },\n    [controlled, onChange],\n  );\n  return [current, set] as const;\n}\n\nconst focusRing =\n  \"outline-none focus-visible:ring-2 focus-visible:ring-ring/50\";\nconst toolButton = cn(\n  \"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-40 aria-pressed:bg-muted aria-pressed:text-foreground motion-reduce:transition-none\",\n  focusRing,\n);\n\n/** Position inside the timeline column from the animated view variables. */\nconst at = (ms: number) =>\n  `calc((${tidy(ms)} - var(--trace-v0)) / var(--trace-vs) * 100%)`;\nconst span = (ms: number) => `calc(${tidy(ms)} / var(--trace-vs) * 100%)`;\n\nconst INDENT = 12;\nconst PAD = 10;\n\n/* ------------------------------------------------------------------------ */\n/* Row                                                                       */\n/* ------------------------------------------------------------------------ */\n\ninterface TraceRowProps {\n  row: TraceRowModel;\n  index: number;\n  rowHeight: number;\n  color: string;\n  colorOf: (service: string) => string;\n  selected: boolean;\n  tabStop: boolean;\n  emphasis: \"critical\" | \"dim\" | \"normal\";\n  labelSide: \"after\" | \"before\" | \"inside\";\n  /** The span lies outside the zoomed time range. */\n  outside: boolean;\n  format: (ms: number) => string;\n  onToggle: (id: string) => void;\n  onActivate: (id: string) => void;\n  onFocusRow: (id: string) => void;\n}\n\nconst TraceRow = React.memo(function TraceRow({\n  row,\n  index,\n  rowHeight,\n  color,\n  colorOf,\n  selected,\n  tabStop,\n  emphasis,\n  labelSide,\n  outside,\n  format,\n  onToggle,\n  onActivate,\n  onFocusRow,\n}: TraceRowProps) {\n  const { node, depth } = row;\n  const { span: s } = node;\n  const isError = s.status === \"error\";\n  const barHeight = Math.max(6, Math.round(rowHeight * 0.43));\n  const elbowX = (column: number) => PAD + column * INDENT + 7;\n  const duration = format(s.duration);\n\n  return (\n    <div\n      role=\"treeitem\"\n      data-slot=\"trace-row\"\n      data-span-id={s.id}\n      data-selected={selected || undefined}\n      data-outside={outside || undefined}\n      data-error={isError || undefined}\n      data-critical={node.critical || undefined}\n      aria-level={depth + 1}\n      aria-setsize={row.setSize}\n      aria-posinset={row.position}\n      aria-expanded={row.childCount > 0 ? !row.collapsed : undefined}\n      aria-selected={selected}\n      aria-label={`${s.name}, ${s.service}, ${duration}${isError ? \", error\" : \"\"}${row.collapsed ? `, ${row.hiddenCount} hidden` : \"\"}`}\n      tabIndex={tabStop ? 0 : -1}\n      onFocus={() => onFocusRow(s.id)}\n      onClick={() => onActivate(s.id)}\n      className={cn(\n        \"group/row absolute inset-x-0 grid cursor-default grid-cols-(--trace-cols) transition-colors duration-100 outline-none motion-reduce:transition-none\",\n        \"hover:bg-muted/55 focus-visible:z-[1] focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset\",\n        selected &&\n          \"bg-primary/[0.07] shadow-[inset_2px_0_0_var(--color-primary)] hover:bg-primary/10\",\n      )}\n      style={{ top: index * rowHeight, height: rowHeight }}\n    >\n      <div\n        data-slot=\"trace-row-label\"\n        className=\"relative flex min-w-0 items-center gap-1.5 border-r pr-2.5\"\n        style={{ paddingLeft: PAD + depth * INDENT }}\n      >\n        {depth > 0 && (\n          <span\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute inset-y-0 left-0\"\n          >\n            {row.lines.map((continues, column) =>\n              continues ? (\n                <span\n                  key={column}\n                  className=\"absolute inset-y-0 w-px bg-border\"\n                  style={{ left: elbowX(column) }}\n                />\n              ) : null,\n            )}\n            <span\n              className=\"absolute top-0 w-px bg-border\"\n              style={{\n                left: elbowX(depth - 1),\n                height: row.last ? \"50%\" : \"100%\",\n              }}\n            />\n            <span\n              className=\"absolute top-1/2 h-px bg-border\"\n              style={{\n                left: elbowX(depth - 1),\n                width: row.childCount > 0 ? 6 : 12,\n              }}\n            />\n          </span>\n        )}\n        {row.childCount > 0 ? (\n          // Not a tab stop: the row itself takes Left and Right to collapse and expand.\n          <span\n            aria-hidden=\"true\"\n            data-slot=\"trace-row-toggle\"\n            onClick={(event) => {\n              event.stopPropagation();\n              onToggle(s.id);\n            }}\n            className=\"relative -mx-px inline-flex size-3.5 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n          >\n            <ChevronRight\n              className={cn(\n                \"size-3 transition-transform duration-150 motion-reduce:transition-none\",\n                !row.collapsed && \"rotate-90\",\n              )}\n              strokeWidth={2.25}\n            />\n          </span>\n        ) : (\n          <span aria-hidden=\"true\" className=\"w-3.5 shrink-0\" />\n        )}\n        <span\n          aria-hidden=\"true\"\n          className=\"relative size-2 shrink-0 rounded-full\"\n          style={{\n            background: color,\n            boxShadow: `0 0 0 2px color-mix(in oklab, ${color} 18%, transparent)`,\n          }}\n        />\n        <span\n          className={cn(\n            \"min-w-0 truncate text-xs transition-opacity duration-200 motion-reduce:transition-none\",\n            depth === 0 ? \"font-semibold\" : \"font-medium text-foreground/90\",\n            outside && \"opacity-45\",\n          )}\n        >\n          {s.name}\n        </span>\n        {isError && (\n          <AlertTriangle\n            aria-hidden=\"true\"\n            className=\"size-3 shrink-0 text-destructive\"\n          />\n        )}\n        {row.collapsed && (\n          <span className=\"shrink-0 rounded-[4px] border px-1 font-mono text-[10px] leading-3.5 text-muted-foreground tabular-nums\">\n            +{row.hiddenCount}\n          </span>\n        )}\n        <span\n          className={cn(\n            \"ml-auto shrink-0 pl-1 font-mono text-[11px] tabular-nums @max-sm/trace:hidden\",\n            isError\n              ? \"text-destructive\"\n              : emphasis === \"critical\"\n                ? \"font-medium text-foreground\"\n                : \"text-muted-foreground\",\n          )}\n        >\n          {duration}\n        </span>\n      </div>\n\n      <div\n        data-slot=\"trace-row-timeline\"\n        className=\"relative min-w-0 overflow-hidden\"\n      >\n        {row.collapsed &&\n          row.summary.map((child) => (\n            <span\n              key={child.span.id}\n              aria-hidden=\"true\"\n              className=\"absolute h-[3px] rounded-full opacity-60\"\n              style={{\n                left: at(child.span.start),\n                width: `max(2px, ${span(child.end - child.span.start)})`,\n                bottom: Math.max(\n                  2,\n                  Math.round((rowHeight - barHeight) / 2) - 5,\n                ),\n                background:\n                  child.span.status === \"error\"\n                    ? DESTRUCTIVE\n                    : colorOf(child.span.service),\n              }}\n            />\n          ))}\n        <span\n          data-slot=\"trace-bar\"\n          aria-hidden=\"true\"\n          className={cn(\n            \"absolute top-1/2 -translate-y-1/2 rounded-[3px] transition-[opacity,box-shadow,filter] duration-200 motion-reduce:transition-none\",\n            emphasis === \"dim\" && \"opacity-40 group-hover/row:opacity-75\",\n            selected && \"ring-2 ring-primary/55 ring-offset-1 ring-offset-card\",\n            isError && \"ring-1 ring-destructive/70 ring-inset\",\n          )}\n          style={{\n            left: at(s.start),\n            width: `max(2px, ${span(node.end - s.start)})`,\n            height: barHeight,\n            background: isError ? errorFill : color,\n            boxShadow:\n              emphasis === \"critical\" && !selected\n                ? `0 0 0 1px color-mix(in oklab, ${color} 55%, transparent), 0 1px 6px -1px color-mix(in oklab, ${color} 55%, transparent)`\n                : undefined,\n          }}\n        >\n          <span\n            className={cn(\n              \"pointer-events-none absolute top-1/2 -translate-y-1/2 rounded-[3px] font-mono text-[10px] leading-4 whitespace-nowrap tabular-nums opacity-0 transition-opacity duration-150 group-hover/row:opacity-100 motion-reduce:transition-none @max-sm/trace:opacity-100\",\n              selected && \"opacity-100\",\n              labelSide === \"after\" && \"left-full ml-1.5 text-foreground\",\n              labelSide === \"before\" && \"right-full mr-1.5 text-foreground\",\n              labelSide === \"inside\" &&\n                \"right-1 bg-card/90 px-1 text-foreground shadow-xs\",\n            )}\n          >\n            {duration}\n          </span>\n        </span>\n      </div>\n    </div>\n  );\n});\n\n/* ------------------------------------------------------------------------ */\n/* Attributes                                                                */\n/* ------------------------------------------------------------------------ */\n\nexport interface TraceSpanAttributesProps extends React.ComponentProps<\"dl\"> {\n  attributes?: Record<string, TraceSpanAttributeValue>;\n}\n\n/** The default attribute table of the detail panel, exported for custom detail layouts. */\nexport function TraceSpanAttributes({\n  attributes,\n  className,\n  ...props\n}: TraceSpanAttributesProps) {\n  const entries = Object.entries(attributes ?? {});\n  if (!entries.length)\n    return (\n      <p className=\"py-1 text-xs text-muted-foreground\">\n        No attributes recorded.\n      </p>\n    );\n  return (\n    <dl\n      data-slot=\"trace-attributes\"\n      className={cn(\n        \"grid grid-cols-[minmax(6rem,auto)_minmax(0,1fr)] gap-x-5 text-xs\",\n        className,\n      )}\n      {...props}\n    >\n      {entries.map(([key, value]) => (\n        <React.Fragment key={key}>\n          <dt className=\"truncate border-t border-dashed py-1.5 font-mono text-[11px] text-muted-foreground first-of-type:border-t-0\">\n            {key}\n          </dt>\n          <dd\n            className={cn(\n              \"min-w-0 border-t border-dashed py-1.5 font-mono text-[11px] break-all tabular-nums first-of-type:border-t-0\",\n              typeof value === \"boolean\" &&\n                (value\n                  ? \"text-emerald-700 dark:text-emerald-400\"\n                  : \"text-muted-foreground\"),\n              typeof value === \"number\" && \"text-foreground\",\n            )}\n          >\n            {typeof value === \"number\"\n              ? value.toLocaleString(\"en-US\")\n              : String(value)}\n          </dd>\n        </React.Fragment>\n      ))}\n    </dl>\n  );\n}\n\n/* ------------------------------------------------------------------------ */\n/* TraceWaterfall                                                            */\n/* ------------------------------------------------------------------------ */\n\n/**\n * A distributed-trace waterfall: a collapsible span tree beside a time axis. Drag across\n * the axis to zoom, click a span for its detail, and follow the critical path at a glance.\n */\nexport function TraceWaterfall({\n  spans,\n  title,\n  description,\n  actions,\n  selectedId: selectedProp,\n  defaultSelectedId = null,\n  onSelectedChange,\n  highlightCriticalPath: highlightProp,\n  defaultHighlightCriticalPath = true,\n  onHighlightCriticalPathChange,\n  defaultCollapsedIds,\n  serviceColors,\n  durationFormatter = formatDuration,\n  renderDetail,\n  rowHeight = 28,\n  height = 360,\n  treeWidth,\n  showOverview = true,\n  showLegend = true,\n  onZoomChange,\n  className,\n  style,\n  ...props\n}: TraceWaterfallProps) {\n  const id = React.useId();\n  const reduced = useReducedMotion();\n  const model = React.useMemo(() => buildModel(spans), [spans]);\n  const format = durationFormatter;\n\n  const colors = React.useMemo(() => {\n    const map = new Map<string, string>();\n    model.services.forEach((service, i) =>\n      map.set(\n        service.name,\n        serviceColors?.[service.name] ?? PALETTE[i % PALETTE.length],\n      ),\n    );\n    return map;\n  }, [model, serviceColors]);\n  const colorOf = React.useCallback(\n    (service: string) => colors.get(service) ?? PALETTE[0],\n    [colors],\n  );\n\n  const [selectedId, setSelectedRaw] = useControllable<string | null>(\n    selectedProp,\n    defaultSelectedId,\n  );\n  const [highlight, setHighlight] = useControllable(\n    highlightProp,\n    defaultHighlightCriticalPath,\n    onHighlightCriticalPathChange,\n  );\n  const [collapsed, setCollapsed] = React.useState(\n    () => new Set(defaultCollapsedIds ?? []),\n  );\n  const [hidden, setHidden] = React.useState<Set<string>>(() => new Set());\n  const [view, setViewState] = React.useState<TraceTimeRange | null>(null);\n  const [focusId, setFocusId] = React.useState<string | null>(null);\n  const [frac, setFrac] = React.useState<number | null>(null);\n  const [width, setWidth] = React.useState(0);\n  const [axisWidth, setAxisWidth] = React.useState(0);\n  const [scroll, setScroll] = React.useState({ top: 0, height });\n\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const axisRef = React.useRef<HTMLDivElement>(null);\n  const treeRef = React.useRef<HTMLDivElement>(null);\n  const cursorRef = React.useRef<HTMLDivElement>(null);\n  const readoutRef = React.useRef<HTMLDivElement>(null);\n  const brushRef = React.useRef<HTMLDivElement>(null);\n  const overviewCursorRef = React.useRef<HTMLDivElement>(null);\n  const pendingFocus = React.useRef<string | null>(null);\n  const suppressClick = React.useRef(false);\n\n  const selectedNode = selectedId\n    ? (model.nodes.get(selectedId) ?? null)\n    : null;\n\n  const select = React.useCallback(\n    (next: string | null) => {\n      setSelectedRaw(next);\n      onSelectedChange?.(\n        next,\n        next ? (model.nodes.get(next)?.span ?? null) : null,\n      );\n    },\n    [model, onSelectedChange, setSelectedRaw],\n  );\n\n  // A selection inside a collapsed branch opens the branch so the row can be seen.\n  React.useEffect(() => {\n    if (!selectedNode) return;\n    setCollapsed((current) => {\n      let next: Set<string> | null = null;\n      for (let p = selectedNode.parent; p; p = p.parent)\n        if (current.has(p.span.id))\n          (next ??= new Set(current)).delete(p.span.id);\n      return next ?? current;\n    });\n  }, [selectedNode]);\n\n  const { rows, flat } = React.useMemo(\n    () => buildRows(model, collapsed, hidden),\n    [model, collapsed, hidden],\n  );\n  const indexOf = React.useMemo(() => {\n    const map = new Map<string, number>();\n    rows.forEach((row, i) => map.set(row.node.span.id, i));\n    return map;\n  }, [rows]);\n\n  /* ---------------------------------------------------------------- view */\n\n  const t0 = model.start;\n  const total = model.duration;\n  const target = view ?? ([t0, t0 + total] as TraceTimeRange);\n  const v0 = target[0];\n  const vs = Math.max(1e-6, target[1] - target[0]);\n  const zoomed = view != null;\n  const displayed = React.useRef({ v0, vs });\n\n  const setView = React.useCallback(\n    (next: TraceTimeRange | null) => {\n      setViewState(next);\n      onZoomChange?.(next);\n    },\n    [onZoomChange],\n  );\n\n  // Clear a zoom that no longer fits new data.\n  React.useEffect(() => {\n    setViewState((current) =>\n      current && (current[1] <= model.start || current[0] >= model.end)\n        ? null\n        : current,\n    );\n  }, [model]);\n\n  // Tween the view variables; React only renders the target, so zooming never re-renders per frame.\n  React.useLayoutEffect(() => {\n    const root = rootRef.current;\n    if (!root) return;\n    const apply = (a: number, s: number) => {\n      displayed.current = { v0: a, vs: s };\n      root.style.setProperty(\"--trace-v0\", String(tidy(a)));\n      root.style.setProperty(\"--trace-vs\", String(tidy(s)));\n    };\n    const from = displayed.current;\n    if (\n      reduced ||\n      (Math.abs(from.v0 - v0) < 1e-9 && Math.abs(from.vs - vs) < 1e-9)\n    ) {\n      apply(v0, vs);\n      return;\n    }\n    apply(from.v0, from.vs);\n    const started = performance.now();\n    let frame = 0;\n    const tick = (now: number) => {\n      const p = Math.min(1, (now - started) / 460);\n      const e = 1 - (1 - p) ** 4;\n      // Interpolate the span geometrically so zooming feels even at every scale.\n      const s = from.vs * (vs / from.vs) ** e;\n      const fromCenter = from.v0 + from.vs / 2;\n      const toCenter = v0 + vs / 2;\n      apply(fromCenter + (toCenter - fromCenter) * e - s / 2, s);\n      if (p < 1) frame = requestAnimationFrame(tick);\n      else apply(v0, vs);\n    };\n    frame = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(frame);\n  }, [v0, vs, reduced]);\n\n  const isEmpty = model.ordered.length === 0;\n  const ticks = React.useMemo(() => {\n    if (isEmpty) return { step: 1, list: [] };\n    const count = Math.max(2, Math.floor((axisWidth || 360) / 84));\n    const step = niceStep(vs, count);\n    const out: { value: number; label: string }[] = [];\n    for (\n      let t = Math.ceil(v0 / step - 1e-9) * step;\n      t <= v0 + vs + step * 1e-6;\n      t += step\n    )\n      out.push({ value: tidy(t), label: tickLabel(tidy(t), step) });\n    return { step, list: out };\n  }, [v0, vs, axisWidth, isEmpty]);\n\n  // After zooming, bring the first span inside the new range into view if none is showing.\n  React.useEffect(() => {\n    const el = scrollRef.current;\n    if (!view || !el) return;\n    const overlaps = (row: TraceRowModel) =>\n      row.depth > 0 &&\n      row.node.end >= view[0] &&\n      row.node.span.start <= view[1];\n    const top = Math.floor(el.scrollTop / rowHeight);\n    const bottom = Math.ceil((el.scrollTop + el.clientHeight - 28) / rowHeight);\n    if (rows.slice(top, bottom).some(overlaps)) return;\n    const index = rows.findIndex(overlaps);\n    if (index < 0) return;\n    el.scrollTo({\n      top: Math.max(0, (index - 1) * rowHeight),\n      behavior: reduced ? \"auto\" : \"smooth\",\n    });\n    // Rows are only read when the zoom changes, not when they do.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [view]);\n\n  /* -------------------------------------------------------------- layout */\n\n  React.useLayoutEffect(() => {\n    const root = rootRef.current;\n    const axis = axisRef.current;\n    if (!root || !axis) return;\n    const measure = () => {\n      setWidth(root.clientWidth);\n      setAxisWidth(axis.clientWidth);\n    };\n    measure();\n    const observer = new ResizeObserver(measure);\n    observer.observe(root);\n    observer.observe(axis);\n    return () => observer.disconnect();\n  }, []);\n\n  const treeShare = Math.min(\n    0.7,\n    Math.max(0.2, frac ?? treeWidth ?? (width && width < 560 ? 0.5 : 0.4)),\n  );\n  const contentHeight = rows.length * rowHeight;\n  // The axis row is 28px; an empty list keeps room for its message.\n  const viewportHeight = rows.length\n    ? Math.min(height, contentHeight + 28)\n    : 128;\n\n  const onScroll = () => {\n    const el = scrollRef.current;\n    if (!el) return;\n    const top = el.scrollTop;\n    const h = el.clientHeight;\n    setScroll((current) =>\n      Math.floor(current.top / rowHeight) === Math.floor(top / rowHeight) &&\n      current.height === h\n        ? current\n        : { top, height: h },\n    );\n  };\n\n  const overscan = 8;\n  const first = Math.max(0, Math.floor(scroll.top / rowHeight) - overscan);\n  const last = Math.min(\n    rows.length,\n    Math.ceil((scroll.top + scroll.height) / rowHeight) + overscan,\n  );\n  const stopId =\n    focusId && indexOf.has(focusId)\n      ? focusId\n      : selectedId && indexOf.has(selectedId)\n        ? selectedId\n        : (rows[0]?.node.span.id ?? null);\n  const stopIndex = stopId ? (indexOf.get(stopId) ?? -1) : -1;\n\n  const scrollToIndex = React.useCallback(\n    (index: number, center = false) => {\n      const el = scrollRef.current;\n      if (!el || index < 0) return;\n      const header = 28;\n      const top = index * rowHeight;\n      const view = el.clientHeight - header;\n      if (center) {\n        if (top < el.scrollTop || top + rowHeight > el.scrollTop + view)\n          el.scrollTop = Math.max(0, top - view / 2 + rowHeight / 2);\n      } else if (top < el.scrollTop) el.scrollTop = top;\n      else if (top + rowHeight > el.scrollTop + view)\n        el.scrollTop = top + rowHeight - view;\n    },\n    [rowHeight],\n  );\n\n  // Bring an outside selection into view.\n  const lastSelected = React.useRef<string | null>(null);\n  React.useLayoutEffect(() => {\n    if (selectedId === lastSelected.current) return;\n    lastSelected.current = selectedId;\n    if (selectedId && indexOf.has(selectedId))\n      scrollToIndex(indexOf.get(selectedId)!, true);\n  }, [selectedId, indexOf, scrollToIndex]);\n\n  React.useLayoutEffect(() => {\n    const target = pendingFocus.current;\n    if (!target) return;\n    pendingFocus.current = null;\n    const element = treeRef.current?.querySelector<HTMLElement>(\n      `[data-span-id=\"${CSS.escape(target)}\"]`,\n    );\n    element?.focus({ preventScroll: true });\n  });\n\n  /* --------------------------------------------------------- interaction */\n\n  const toggle = React.useCallback((spanId: string) => {\n    setCollapsed((current) => {\n      const next = new Set(current);\n      if (next.has(spanId)) next.delete(spanId);\n      else next.add(spanId);\n      return next;\n    });\n  }, []);\n\n  const selectedRef = React.useRef(selectedId);\n  selectedRef.current = selectedId;\n  const activate = React.useCallback(\n    (spanId: string) => {\n      if (suppressClick.current) return;\n      setFocusId(spanId);\n      select(selectedRef.current === spanId ? null : spanId);\n    },\n    [select],\n  );\n\n  const moveFocus = (index: number) => {\n    const row = rows[Math.max(0, Math.min(rows.length - 1, index))];\n    if (!row) return;\n    pendingFocus.current = row.node.span.id;\n    setFocusId(row.node.span.id);\n    scrollToIndex(indexOf.get(row.node.span.id)!);\n  };\n\n  const onTreeKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    const target = event.target as HTMLElement;\n    const spanId = target.dataset.spanId;\n    if (!spanId || target.dataset.slot !== \"trace-row\") return;\n    const index = indexOf.get(spanId) ?? 0;\n    const row = rows[index];\n    const page = Math.max(1, Math.floor((scroll.height - 28) / rowHeight) - 1);\n    switch (event.key) {\n      case \"ArrowDown\":\n        moveFocus(index + 1);\n        break;\n      case \"ArrowUp\":\n        moveFocus(index - 1);\n        break;\n      case \"Home\":\n        moveFocus(0);\n        break;\n      case \"End\":\n        moveFocus(rows.length - 1);\n        break;\n      case \"PageDown\":\n        moveFocus(index + page);\n        break;\n      case \"PageUp\":\n        moveFocus(index - page);\n        break;\n      case \"ArrowRight\":\n        if (row.childCount > 0 && row.collapsed) toggle(spanId);\n        else if (row.childCount > 0) moveFocus(index + 1);\n        break;\n      case \"ArrowLeft\":\n        if (row.childCount > 0 && !row.collapsed) toggle(spanId);\n        else if (row.parentId && indexOf.has(row.parentId))\n          moveFocus(indexOf.get(row.parentId)!);\n        break;\n      case \"Enter\":\n      case \" \":\n        select(selectedId === spanId ? null : spanId);\n        break;\n      case \"Escape\":\n        if (selectedId) select(null);\n        else if (zoomed) setView(null);\n        else return;\n        break;\n      default:\n        return;\n    }\n    event.preventDefault();\n  };\n\n  // Pointer: hover draws a cursor with a time readout; dragging across the axis zooms.\n  const drag = React.useRef<{ x: number; id: number; active: boolean } | null>(\n    null,\n  );\n  const axisRect = () => axisRef.current?.getBoundingClientRect() ?? null;\n  const timeAtX = (x: number, rect: DOMRect) => {\n    const f = Math.min(1, Math.max(0, (x - rect.left) / (rect.width || 1)));\n    return displayed.current.v0 + f * displayed.current.vs;\n  };\n\n  const showCursor = (clientX: number | null) => {\n    const rect = axisRect();\n    const cursor = cursorRef.current;\n    const readout = readoutRef.current;\n    const overview = overviewCursorRef.current;\n    const inside =\n      rect && clientX !== null && clientX >= rect.left && clientX <= rect.right;\n    for (const el of [cursor, readout, overview])\n      if (el) el.style.opacity = inside ? \"1\" : \"0\";\n    if (!inside || !rect) return;\n    const x = clientX - rect.left;\n    const time = timeAtX(clientX, rect);\n    if (cursor) cursor.style.transform = `translateX(${x}px)`;\n    if (readout) {\n      const brush = drag.current?.active ? drag.current : null;\n      if (brush) {\n        const a = timeAtX(brush.x, rect);\n        const [lo, hi] = a < time ? [a, time] : [time, a];\n        readout.textContent = `${tickLabel(lo, vs / 50)} – ${tickLabel(hi, vs / 50)} · ${format(hi - lo)}`;\n      } else readout.textContent = format(time - t0);\n      const w = readout.offsetWidth;\n      readout.style.transform = `translateX(${Math.min(Math.max(0, x - w / 2), rect.width - w)}px)`;\n    }\n    if (overview) overview.style.left = `${((time - t0) / total) * 100}%`;\n  };\n\n  const onPointerDown = (event: React.PointerEvent<HTMLDivElement>) => {\n    if (event.button !== 0 || event.pointerType === \"touch\") return;\n    const rect = axisRect();\n    if (!rect || event.clientX < rect.left || event.clientX > rect.right)\n      return;\n    if ((event.target as HTMLElement).closest('[role=\"separator\"]')) return;\n    drag.current = { x: event.clientX, id: event.pointerId, active: false };\n  };\n\n  const onPointerMove = (event: React.PointerEvent<HTMLDivElement>) => {\n    const d = drag.current;\n    const rect = axisRect();\n    if (d && rect && event.pointerId === d.id) {\n      if (!d.active && Math.abs(event.clientX - d.x) > 4) {\n        d.active = true;\n        event.currentTarget.setPointerCapture(event.pointerId);\n      }\n      if (d.active && brushRef.current) {\n        const a = Math.min(Math.max(d.x, rect.left), rect.right) - rect.left;\n        const b =\n          Math.min(Math.max(event.clientX, rect.left), rect.right) - rect.left;\n        brushRef.current.style.display = \"block\";\n        brushRef.current.style.left = `${Math.min(a, b)}px`;\n        brushRef.current.style.width = `${Math.abs(b - a)}px`;\n      }\n    }\n    showCursor(event.clientX);\n  };\n\n  const endDrag = (\n    event: React.PointerEvent<HTMLDivElement>,\n    commit: boolean,\n  ) => {\n    const d = drag.current;\n    drag.current = null;\n    if (brushRef.current) brushRef.current.style.display = \"none\";\n    if (!d?.active) return;\n    const rect = axisRect();\n    if (commit && rect) {\n      const a = timeAtX(d.x, rect);\n      const b = timeAtX(event.clientX, rect);\n      const lo = Math.max(t0, Math.min(a, b));\n      const hi = Math.min(t0 + total, Math.max(a, b));\n      if (hi - lo > Math.max(total / 5000, 1e-3)) setView([lo, hi]);\n    }\n    suppressClick.current = true;\n    window.setTimeout(() => (suppressClick.current = false), 0);\n    showCursor(event.clientX);\n  };\n\n  const onDoubleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n    const rect = axisRect();\n    if (\n      zoomed &&\n      rect &&\n      event.clientX >= rect.left &&\n      event.clientX <= rect.right\n    )\n      setView(null);\n  };\n\n  // Column divider: drag or use the arrow keys.\n  const onSeparatorPointerDown = (\n    event: React.PointerEvent<HTMLDivElement>,\n  ) => {\n    if (event.button !== 0) return;\n    event.preventDefault();\n    const root = rootRef.current;\n    if (!root) return;\n    const rect =\n      scrollRef.current?.getBoundingClientRect() ??\n      root.getBoundingClientRect();\n    const target = event.currentTarget;\n    target.setPointerCapture(event.pointerId);\n    const move = (e: PointerEvent) =>\n      setFrac(\n        Math.min(0.7, Math.max(0.2, (e.clientX - rect.left) / rect.width)),\n      );\n    const up = () => {\n      target.removeEventListener(\"pointermove\", move);\n      target.removeEventListener(\"pointerup\", up);\n      target.removeEventListener(\"pointercancel\", up);\n    };\n    target.addEventListener(\"pointermove\", move);\n    target.addEventListener(\"pointerup\", up);\n    target.addEventListener(\"pointercancel\", up);\n  };\n\n  const collapsibleIds = React.useMemo(\n    () =>\n      model.ordered\n        .filter((node) => node.depth > 0 && node.children.length > 0)\n        .map((node) => node.span.id),\n    [model],\n  );\n  const anyCollapsed = rows.some((row) => row.collapsed);\n\n  /* ------------------------------------------------------------ derived */\n\n  const emphasisOf = (node: TraceNode): TraceRowProps[\"emphasis\"] =>\n    highlight ? (node.critical ? \"critical\" : \"dim\") : \"normal\";\n  const labelSideOf = (node: TraceNode): TraceRowProps[\"labelSide\"] => {\n    const a = (node.span.start - v0) / vs;\n    const b = (node.end - v0) / vs;\n    if (b < 0.78) return \"after\";\n    if (a > 0.22) return \"before\";\n    return \"inside\";\n  };\n\n  const info = (node: TraceNode): TraceSpanInfo => ({\n    span: node.span,\n    parent: node.parent?.span ?? null,\n    children: node.children.map((child) => child.span),\n    depth: node.depth,\n    descendantCount: node.descendants,\n    selfTime: node.self,\n    share: (node.end - node.span.start) / total,\n    critical: node.critical,\n    color: colorOf(node.span.service),\n    trace: { start: t0, end: t0 + total, duration: total },\n  });\n\n  // Keep the last span while the panel animates closed.\n  const [shownNode, setShownNode] = React.useState<TraceNode | null>(\n    selectedNode,\n  );\n  if (selectedNode && selectedNode !== shownNode) setShownNode(selectedNode);\n\n  const label = typeof title === \"string\" ? title : \"Trace spans\";\n  const services = model.services;\n  const renderIndices: number[] = [];\n  for (let i = first; i < last; i++) renderIndices.push(i);\n  if (stopIndex >= 0 && (stopIndex < first || stopIndex >= last))\n    renderIndices.push(stopIndex);\n\n  return (\n    <div\n      ref={rootRef}\n      data-slot=\"trace-waterfall\"\n      data-zoomed={zoomed || undefined}\n      className={cn(\n        \"@container/trace flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card text-card-foreground shadow-xs\",\n        className,\n      )}\n      style={\n        {\n          \"--trace-v0\": tidy(v0),\n          \"--trace-vs\": tidy(vs),\n          \"--trace-t0\": tidy(t0),\n          \"--trace-total\": tidy(total),\n          \"--trace-tree\": `${(treeShare * 100).toFixed(2)}%`,\n          \"--trace-cols\": \"minmax(0, var(--trace-tree)) minmax(0, 1fr)\",\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div\n        data-slot=\"trace-header\"\n        className=\"flex items-start gap-3 px-4 pt-3.5 pb-3\"\n      >\n        <div className=\"min-w-0 flex-1 space-y-1\">\n          {title != null && (\n            <h3 className=\"truncate text-sm leading-5 font-semibold tracking-tight\">\n              {title}\n            </h3>\n          )}\n          <div\n            data-slot=\"trace-summary\"\n            className=\"flex flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[11px] leading-4 text-muted-foreground tabular-nums\"\n          >\n            <span>\n              <span className=\"font-medium text-foreground\">\n                {isEmpty ? \"—\" : format(total)}\n              </span>\n            </span>\n            <span aria-hidden=\"true\" className=\"text-border\">\n              /\n            </span>\n            <span>\n              {spans.length} {spans.length === 1 ? \"span\" : \"spans\"}\n            </span>\n            <span\n              aria-hidden=\"true\"\n              className=\"hidden text-border @sm/trace:inline\"\n            >\n              /\n            </span>\n            <span className=\"hidden @sm/trace:inline\">\n              {services.length} {services.length === 1 ? \"service\" : \"services\"}\n            </span>\n            {model.errors > 0 && (\n              <span className=\"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-1.5 font-sans text-[11px] font-medium text-destructive\">\n                <AlertTriangle aria-hidden=\"true\" className=\"size-3\" />\n                {model.errors} {model.errors === 1 ? \"error\" : \"errors\"}\n              </span>\n            )}\n          </div>\n          {description != null && (\n            <p\n              id={`${id}-description`}\n              className=\"text-xs text-muted-foreground\"\n            >\n              {description}\n            </p>\n          )}\n        </div>\n        <div className=\"flex shrink-0 items-center gap-1\">\n          {actions}\n          <div\n            role=\"toolbar\"\n            aria-label=\"Trace tools\"\n            className=\"flex items-center gap-0.5\"\n          >\n            <button\n              type=\"button\"\n              className={toolButton}\n              aria-pressed={highlight}\n              title=\"Highlight the critical path\"\n              onClick={() => setHighlight(!highlight)}\n            >\n              <Route className=\"size-4\" aria-hidden=\"true\" />\n              <span className=\"sr-only\">Highlight the critical path</span>\n            </button>\n            <button\n              type=\"button\"\n              className={toolButton}\n              title={anyCollapsed ? \"Expand all\" : \"Collapse all\"}\n              disabled={!collapsibleIds.length}\n              onClick={() =>\n                setCollapsed(anyCollapsed ? new Set() : new Set(collapsibleIds))\n              }\n            >\n              {anyCollapsed ? (\n                <FoldDown className=\"size-4\" aria-hidden=\"true\" />\n              ) : (\n                <FoldUp className=\"size-4\" aria-hidden=\"true\" />\n              )}\n              <span className=\"sr-only\">\n                {anyCollapsed ? \"Expand all\" : \"Collapse all\"}\n              </span>\n            </button>\n            <button\n              type=\"button\"\n              className={toolButton}\n              title=\"Reset zoom\"\n              disabled={!zoomed}\n              onClick={() => setView(null)}\n            >\n              <ZoomReset className=\"size-4\" aria-hidden=\"true\" />\n              <span className=\"sr-only\">Reset zoom</span>\n            </button>\n          </div>\n        </div>\n      </div>\n\n      {showOverview && !isEmpty && (\n        <TraceOverview\n          nodes={flat}\n          start={t0}\n          total={total}\n          zoomed={zoomed}\n          colorOf={colorOf}\n          highlight={highlight}\n          cursorRef={overviewCursorRef}\n          onRange={setView}\n          viewStart={target[0]}\n          viewEnd={target[1]}\n        />\n      )}\n\n      <div\n        ref={scrollRef}\n        data-slot=\"trace-scroll\"\n        className=\"relative mt-3 touch-pan-y overflow-y-auto overscroll-contain border-t select-none\"\n        style={{ height: viewportHeight }}\n        onScroll={onScroll}\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={(event) => endDrag(event, true)}\n        onPointerCancel={(event) => endDrag(event, false)}\n        onPointerLeave={() => {\n          if (!drag.current?.active) showCursor(null);\n        }}\n        onDoubleClick={onDoubleClick}\n      >\n        <div\n          data-slot=\"trace-axis\"\n          className=\"sticky top-0 z-20 grid h-7 grid-cols-(--trace-cols) border-b bg-card\"\n        >\n          <div className=\"flex min-w-0 items-center justify-between gap-2 border-r pr-2.5 pl-3 font-mono text-[10.5px] text-muted-foreground\">\n            <span className=\"truncate\">Span</span>\n            <span className=\"@max-sm/trace:hidden\">Duration</span>\n          </div>\n          <div\n            ref={axisRef}\n            className={cn(\n              \"relative min-w-0 overflow-hidden\",\n              zoomed ? \"cursor-zoom-out\" : \"cursor-crosshair\",\n            )}\n            title={\n              zoomed\n                ? \"Drag to zoom further, double-click to reset\"\n                : \"Drag across the axis to zoom\"\n            }\n          >\n            {ticks.list.map((tick) => (\n              <span\n                key={`${ticks.step}-${tick.value}`}\n                className=\"absolute inset-y-0 flex items-center border-l border-border pl-1 font-mono text-[10px] leading-none whitespace-nowrap text-muted-foreground tabular-nums motion-safe:animate-[trace-fade_.35s_ease-out_both]\"\n                style={{ left: at(tick.value) }}\n              >\n                {/* A label that would be clipped at the right edge keeps only its line. */}\n                {(tick.value - v0) / vs <= 0.93 ? tick.label : null}\n              </span>\n            ))}\n            <div\n              ref={readoutRef}\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute top-1/2 left-0 z-10 -mt-2 h-4 rounded-[4px] bg-foreground px-1.5 font-mono text-[10px] leading-4 whitespace-nowrap text-background tabular-nums opacity-0 shadow-sm\"\n            />\n          </div>\n          <div\n            role=\"separator\"\n            aria-orientation=\"vertical\"\n            aria-label=\"Resize span column\"\n            aria-valuemin={20}\n            aria-valuemax={70}\n            aria-valuenow={Math.round(treeShare * 100)}\n            tabIndex={0}\n            onPointerDown={onSeparatorPointerDown}\n            onKeyDown={(event) => {\n              const delta =\n                event.key === \"ArrowLeft\"\n                  ? -0.02\n                  : event.key === \"ArrowRight\"\n                    ? 0.02\n                    : 0;\n              if (!delta) return;\n              event.preventDefault();\n              setFrac(Math.min(0.7, Math.max(0.2, treeShare + delta)));\n            }}\n            className=\"group/sep absolute inset-y-0 z-10 w-2 -translate-x-1/2 cursor-col-resize outline-none\"\n            style={{ left: \"var(--trace-tree)\" }}\n          >\n            <span className=\"absolute inset-y-1 left-1/2 w-0.5 -translate-x-1/2 rounded-full bg-transparent transition-colors group-hover/sep:bg-primary/60 group-focus-visible/sep:bg-ring\" />\n          </div>\n        </div>\n\n        {rows.length === 0 ? (\n          <p className=\"py-10 text-center text-xs text-muted-foreground\">\n            {spans.length\n              ? \"Every service is filtered out.\"\n              : \"No spans in this trace.\"}\n          </p>\n        ) : (\n          <div\n            ref={treeRef}\n            role=\"tree\"\n            aria-label={label}\n            aria-describedby={\n              description != null ? `${id}-description` : undefined\n            }\n            onKeyDown={onTreeKeyDown}\n            onBlur={(event) => {\n              if (!event.currentTarget.contains(event.relatedTarget as Node))\n                setFocusId(null);\n            }}\n            className=\"relative\"\n            style={{ height: contentHeight }}\n          >\n            <div\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute inset-0 grid grid-cols-(--trace-cols)\"\n            >\n              <div />\n              <div className=\"relative overflow-hidden\">\n                {ticks.list.map((tick) => (\n                  <span\n                    key={`${ticks.step}-${tick.value}`}\n                    className=\"absolute inset-y-0 w-px bg-border/55 motion-safe:animate-[trace-fade_.35s_ease-out_both]\"\n                    style={{ left: at(tick.value) }}\n                  />\n                ))}\n              </div>\n            </div>\n\n            {renderIndices.map((i) => {\n              const row = rows[i];\n              const node = row.node;\n              return (\n                <TraceRow\n                  key={node.span.id}\n                  row={row}\n                  index={i}\n                  rowHeight={rowHeight}\n                  color={colorOf(node.span.service)}\n                  colorOf={colorOf}\n                  selected={node.span.id === selectedId}\n                  tabStop={node.span.id === stopId}\n                  emphasis={emphasisOf(node)}\n                  labelSide={labelSideOf(node)}\n                  outside={\n                    zoomed && (node.end < v0 || node.span.start > v0 + vs)\n                  }\n                  format={format}\n                  onToggle={toggle}\n                  onActivate={activate}\n                  onFocusRow={setFocusId}\n                />\n              );\n            })}\n\n            <div\n              aria-hidden=\"true\"\n              className=\"pointer-events-none absolute inset-0 z-10 grid grid-cols-(--trace-cols)\"\n            >\n              <div />\n              <div className=\"relative overflow-hidden\">\n                <div\n                  ref={cursorRef}\n                  className=\"absolute inset-y-0 left-0 w-px bg-foreground/45 opacity-0 transition-opacity duration-100\"\n                />\n                <div\n                  ref={brushRef}\n                  className=\"absolute inset-y-0 hidden border-x border-primary/70 bg-primary/10\"\n                />\n              </div>\n            </div>\n          </div>\n        )}\n      </div>\n\n      <TraceDetail\n        node={shownNode}\n        open={selectedNode != null}\n        info={shownNode ? info(shownNode) : null}\n        format={format}\n        renderDetail={renderDetail}\n        onClose={() => select(null)}\n        onSelect={select}\n      />\n\n      {showLegend && services.length > 0 && (\n        <div\n          data-slot=\"trace-legend\"\n          className=\"flex flex-wrap items-center gap-1 border-t px-3 py-2\"\n          role=\"group\"\n          aria-label=\"Show or hide services\"\n        >\n          {services.map((service) => {\n            const visible = !hidden.has(service.name);\n            const color = colorOf(service.name);\n            return (\n              <button\n                key={service.name}\n                type=\"button\"\n                aria-pressed={visible}\n                title={\n                  visible ? `Hide ${service.name}` : `Show ${service.name}`\n                }\n                onClick={() =>\n                  setHidden((current) => {\n                    const next = new Set(current);\n                    if (next.has(service.name)) next.delete(service.name);\n                    else next.add(service.name);\n                    return next;\n                  })\n                }\n                className={cn(\n                  \"inline-flex h-6 items-center gap-1.5 rounded-md border px-1.5 text-xs transition-colors motion-reduce:transition-none\",\n                  visible\n                    ? \"border-transparent text-foreground hover:bg-muted\"\n                    : \"border-dashed border-border text-muted-foreground line-through decoration-muted-foreground/50 hover:text-foreground\",\n                  focusRing,\n                )}\n              >\n                <span\n                  aria-hidden=\"true\"\n                  className=\"size-2 rounded-[2px]\"\n                  style={\n                    visible\n                      ? { background: color }\n                      : { boxShadow: `inset 0 0 0 1px ${color}` }\n                  }\n                />\n                <span className=\"font-medium\">{service.name}</span>\n                <span className=\"font-mono text-[10.5px] text-muted-foreground tabular-nums\">\n                  {service.count}\n                </span>\n                {service.errors > 0 && (\n                  <span\n                    className=\"inline-flex items-center gap-0.5 font-mono text-[10.5px] text-destructive tabular-nums\"\n                    title={`${service.errors} ${service.errors === 1 ? \"error\" : \"errors\"}`}\n                  >\n                    <AlertTriangle aria-hidden=\"true\" className=\"size-2.5\" />\n                    {service.errors}\n                    <span className=\"sr-only\">\n                      {\" \"}\n                      {service.errors === 1 ? \"error\" : \"errors\"}\n                    </span>\n                  </span>\n                )}\n              </button>\n            );\n          })}\n          {hidden.size > 0 && (\n            <button\n              type=\"button\"\n              onClick={() => setHidden(new Set())}\n              className={cn(\n                \"ml-auto h-6 rounded-md px-2 text-xs font-medium text-primary hover:bg-muted\",\n                focusRing,\n              )}\n            >\n              Show all\n            </button>\n          )}\n        </div>\n      )}\n\n      <style href=\"overtrue-trace-waterfall\" precedence=\"default\">\n        {`@keyframes trace-fade{from{opacity:0}to{opacity:1}}`}\n      </style>\n    </div>\n  );\n}\n\n/* ------------------------------------------------------------------------ */\n/* Overview                                                                  */\n/* ------------------------------------------------------------------------ */\n\ninterface TraceOverviewProps {\n  nodes: TraceNode[];\n  start: number;\n  total: number;\n  viewStart: number;\n  viewEnd: number;\n  zoomed: boolean;\n  colorOf: (service: string) => string;\n  highlight: boolean;\n  cursorRef: React.RefObject<HTMLDivElement | null>;\n  onRange: (range: TraceTimeRange | null) => void;\n}\n\nconst TraceOverview = React.memo(function TraceOverview({\n  nodes,\n  start,\n  total,\n  viewStart,\n  viewEnd,\n  zoomed,\n  colorOf,\n  highlight,\n  cursorRef,\n  onRange,\n}: TraceOverviewProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const brushRef = React.useRef<HTMLDivElement>(null);\n  const drag = React.useRef<{ x: number; active: boolean } | null>(null);\n  // A mini icicle: one band per depth, split into lanes only where siblings overlap.\n  const lanes = React.useMemo(() => {\n    const byDepth = new Map<number, TraceNode[]>();\n    for (const node of nodes) {\n      const list = byDepth.get(node.depth) ?? [];\n      list.push(node);\n      byDepth.set(node.depth, list);\n    }\n    const placed: { node: TraceNode; lane: number }[] = [];\n    let offset = 0;\n    for (const depth of [...byDepth.keys()].sort((a, b) => a - b)) {\n      const ends: number[] = [];\n      const list = byDepth\n        .get(depth)!\n        .sort((a, b) => a.span.start - b.span.start);\n      for (const node of list) {\n        let lane = ends.findIndex((end) => end <= node.span.start + 1e-9);\n        if (lane < 0) lane = ends.push(0) - 1;\n        ends[lane] = node.end;\n        placed.push({ node, lane: offset + lane });\n      }\n      offset += ends.length;\n    }\n    return { placed, count: offset };\n  }, [nodes]);\n  const laneHeight = Math.min(7, 30 / Math.max(1, lanes.count));\n  const lens = (a: number) =>\n    `calc((var(--trace-v0) - ${tidy(start)}) / ${tidy(total)} * 100% + ${a}px)`;\n\n  const timeAt = (clientX: number) => {\n    const rect = ref.current!.getBoundingClientRect();\n    return (\n      start +\n      Math.min(1, Math.max(0, (clientX - rect.left) / rect.width)) * total\n    );\n  };\n\n  return (\n    <div className=\"px-4\">\n      <div\n        ref={ref}\n        data-slot=\"trace-overview\"\n        aria-hidden=\"true\"\n        className=\"relative h-10 cursor-crosshair touch-pan-y overflow-hidden rounded-md border bg-muted/25 select-none\"\n        onPointerDown={(event) => {\n          if (event.button !== 0) return;\n          drag.current = { x: event.clientX, active: false };\n          event.currentTarget.setPointerCapture(event.pointerId);\n        }}\n        onPointerMove={(event) => {\n          const rect = event.currentTarget.getBoundingClientRect();\n          const cursor = cursorRef.current;\n          if (cursor) {\n            cursor.style.opacity = \"1\";\n            cursor.style.left = `${((event.clientX - rect.left) / rect.width) * 100}%`;\n          }\n          const d = drag.current;\n          if (!d) return;\n          if (!d.active && Math.abs(event.clientX - d.x) > 3) d.active = true;\n          if (d.active && brushRef.current) {\n            const a =\n              Math.min(Math.max(d.x, rect.left), rect.right) - rect.left;\n            const b =\n              Math.min(Math.max(event.clientX, rect.left), rect.right) -\n              rect.left;\n            brushRef.current.style.display = \"block\";\n            brushRef.current.style.left = `${Math.min(a, b)}px`;\n            brushRef.current.style.width = `${Math.abs(b - a)}px`;\n          }\n        }}\n        onPointerUp={(event) => {\n          const d = drag.current;\n          drag.current = null;\n          if (brushRef.current) brushRef.current.style.display = \"none\";\n          if (!d) return;\n          if (d.active) {\n            const a = timeAt(d.x);\n            const b = timeAt(event.clientX);\n            if (Math.abs(b - a) > total / 5000)\n              onRange([Math.min(a, b), Math.max(a, b)]);\n          } else if (zoomed) {\n            // A click recenters the zoom window on that moment.\n            const width = viewEnd - viewStart;\n            const center = timeAt(event.clientX);\n            const lo = Math.min(\n              Math.max(start, center - width / 2),\n              start + total - width,\n            );\n            onRange([lo, lo + width]);\n          }\n        }}\n        onPointerLeave={() => {\n          if (cursorRef.current) cursorRef.current.style.opacity = \"0\";\n        }}\n        onDoubleClick={() => onRange(null)}\n      >\n        <div className=\"absolute inset-x-1 inset-y-1\">\n          {lanes.placed.map(({ node, lane }) => {\n            const isError = node.span.status === \"error\";\n            return (\n              <span\n                key={node.span.id}\n                className={cn(\n                  \"absolute rounded-[1.5px]\",\n                  highlight && !node.critical && !isError && \"opacity-35\",\n                )}\n                style={{\n                  left: `${(((node.span.start - start) / total) * 100).toFixed(3)}%`,\n                  width: `max(2px, ${(((node.end - node.span.start) / total) * 100).toFixed(3)}%)`,\n                  top: lane * laneHeight,\n                  height: Math.max(\n                    1,\n                    laneHeight - (laneHeight > 3 ? 1.5 : 0.5),\n                  ),\n                  background: isError ? errorFill : colorOf(node.span.service),\n                }}\n              />\n            );\n          })}\n        </div>\n        {zoomed && (\n          <>\n            <div\n              className=\"absolute inset-y-0 left-0 bg-card/70\"\n              style={{ width: lens(0) }}\n            />\n            <div\n              className=\"absolute inset-y-0 right-0 bg-card/70\"\n              style={{\n                left: `calc((var(--trace-v0) + var(--trace-vs) - ${tidy(start)}) / ${tidy(total)} * 100%)`,\n              }}\n            />\n            <div\n              className=\"absolute inset-y-0 rounded-[3px] border-x-2 border-primary shadow-[0_0_0_1px_color-mix(in_oklab,var(--color-primary)_25%,transparent)]\"\n              style={{\n                left: lens(0),\n                width: `max(4px, calc(var(--trace-vs) / ${tidy(total)} * 100%))`,\n              }}\n            />\n          </>\n        )}\n        <div\n          ref={cursorRef}\n          className=\"pointer-events-none absolute inset-y-0 w-px bg-foreground/50 opacity-0 transition-opacity duration-100\"\n        />\n        <div\n          ref={brushRef}\n          className=\"pointer-events-none absolute inset-y-0 hidden border-x border-primary bg-primary/15\"\n        />\n      </div>\n    </div>\n  );\n});\n\n/* ------------------------------------------------------------------------ */\n/* Detail                                                                    */\n/* ------------------------------------------------------------------------ */\n\ninterface TraceDetailProps {\n  node: TraceNode | null;\n  info: TraceSpanInfo | null;\n  open: boolean;\n  format: (ms: number) => string;\n  renderDetail?: (span: TraceSpan, info: TraceSpanInfo) => React.ReactNode;\n  onClose: () => void;\n  onSelect: (id: string | null) => void;\n}\n\nfunction TraceDetail({\n  node,\n  info,\n  open,\n  format,\n  renderDetail,\n  onClose,\n  onSelect,\n}: TraceDetailProps) {\n  const s = node?.span;\n  const isError = s?.status === \"error\";\n  return (\n    <div\n      data-slot=\"trace-detail\"\n      data-open={open || undefined}\n      className=\"grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-out data-[open]:grid-rows-[1fr] motion-reduce:transition-none\"\n      inert={!open}\n    >\n      <div className=\"min-h-0 overflow-hidden\">\n        {s && info && (\n          <section\n            aria-label={`Span detail: ${s.name}`}\n            className=\"border-t bg-muted/20\"\n          >\n            <div className=\"flex items-start gap-2.5 px-4 pt-3\">\n              <span\n                aria-hidden=\"true\"\n                className=\"mt-1.5 size-2 shrink-0 rounded-full\"\n                style={{ background: info.color }}\n              />\n              <div className=\"min-w-0 flex-1\">\n                <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n                  <h4 className=\"min-w-0 truncate text-sm font-semibold tracking-tight\">\n                    {s.name}\n                  </h4>\n                  {isError ? (\n                    <span className=\"inline-flex items-center gap-1 rounded-full bg-destructive/10 px-1.5 py-px text-[11px] font-medium text-destructive\">\n                      <AlertTriangle aria-hidden=\"true\" className=\"size-3\" />\n                      Error\n                    </span>\n                  ) : (\n                    <span className=\"inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-1.5 py-px text-[11px] font-medium text-emerald-700 dark:text-emerald-400\">\n                      <span\n                        aria-hidden=\"true\"\n                        className=\"size-1.5 rounded-full bg-emerald-500\"\n                      />\n                      OK\n                    </span>\n                  )}\n                  {info.critical && (\n                    <span className=\"inline-flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-px text-[11px] font-medium text-primary\">\n                      <Route aria-hidden=\"true\" className=\"size-3\" />\n                      Critical path\n                    </span>\n                  )}\n                </div>\n                <p className=\"mt-0.5 flex min-w-0 flex-wrap gap-x-2 font-mono text-[11px] text-muted-foreground\">\n                  <span>{s.service}</span>\n                  <span aria-hidden=\"true\" className=\"text-border\">\n                    /\n                  </span>\n                  <span className=\"truncate\">{s.id}</span>\n                  {info.parent && (\n                    <>\n                      <span aria-hidden=\"true\" className=\"text-border\">\n                        /\n                      </span>\n                      <button\n                        type=\"button\"\n                        onClick={() => onSelect(info.parent!.id)}\n                        className={cn(\n                          \"truncate rounded-sm text-primary hover:underline\",\n                          focusRing,\n                        )}\n                      >\n                        ↑ {info.parent.name}\n                      </button>\n                    </>\n                  )}\n                </p>\n              </div>\n              <button\n                type=\"button\"\n                onClick={onClose}\n                className={cn(toolButton, \"-mt-0.5 -mr-1.5\")}\n                title=\"Close\"\n              >\n                <X className=\"size-4\" aria-hidden=\"true\" />\n                <span className=\"sr-only\">Close span detail</span>\n              </button>\n            </div>\n\n            <dl\n              data-slot=\"trace-detail-timing\"\n              className=\"mx-4 mt-3 grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border @lg/trace:grid-cols-4\"\n            >\n              {(\n                [\n                  [\"Start\", `+${format(s.start - info.trace.start)}`],\n                  [\"Duration\", format(s.duration)],\n                  [\"Self time\", format(info.selfTime)],\n                  [\"Share of trace\", formatPercent(info.share)],\n                ] as const\n              ).map(([term, value]) => (\n                <div key={term} className=\"bg-card px-3 py-2\">\n                  <dt className=\"text-[11px] text-muted-foreground\">{term}</dt>\n                  <dd className=\"font-mono text-sm font-medium tabular-nums\">\n                    {value}\n                  </dd>\n                </div>\n              ))}\n            </dl>\n            <div\n              aria-hidden=\"true\"\n              className=\"relative mx-4 mt-2.5 h-1.5 rounded-full bg-muted\"\n            >\n              <span\n                className=\"absolute inset-y-0 rounded-full\"\n                style={{\n                  left: `${((s.start - info.trace.start) / info.trace.duration) * 100}%`,\n                  width: `max(3px, ${(info.share * 100).toFixed(3)}%)`,\n                  background: isError ? DESTRUCTIVE : info.color,\n                }}\n              />\n            </div>\n\n            <div data-slot=\"trace-detail-body\" className=\"px-4 pt-3 pb-4\">\n              {renderDetail ? (\n                renderDetail(s, info)\n              ) : (\n                <>\n                  <p className=\"mb-1.5 flex items-baseline gap-1.5 text-xs font-medium\">\n                    Attributes\n                    <span className=\"font-mono text-[10.5px] font-normal text-muted-foreground tabular-nums\">\n                      {Object.keys(s.attributes ?? {}).length}\n                    </span>\n                  </p>\n                  <TraceSpanAttributes attributes={s.attributes} />\n                </>\n              )}\n            </div>\n          </section>\n        )}\n      </div>\n    </div>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/trace-waterfall. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
