Thinking
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"
import {
  ShimmerLabel,
  thinkSwapEnter,
  threadMeta,
} from "@/registry/tonic/lib/surfaces"

export type ThinkingIndicatorProps = Omit<
  React.ComponentProps<"div">,
  "children" | "label" | "elapsed"
> & {
  label: string
  elapsed?: string
}

/** Quiet shimmer status line with optional elapsed time and label swaps. */
export function ThinkingIndicator({
  label,
  elapsed,
  className,
  ...props
}: ThinkingIndicatorProps) {
  return (
    <div
      data-slot="thinking-indicator"
      role="status"
      aria-live="polite"
      aria-label={elapsed ? `${label}, ${elapsed}` : label}
      className={cn("flex items-center gap-1.5 py-0.5", threadMeta, className)}
      {...props}
    >
      <ShimmerLabel
        key={label}
        className={cn("relative inline-block", thinkSwapEnter)}
      >
        {label}
      </ShimmerLabel>
      {elapsed !== undefined ? (
        <span className="tabular-nums opacity-80">{elapsed}</span>
      ) : null}
    </div>
  )
}