{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elements-message-branches",
  "type": "registry:component",
  "title": "Message branches",
  "description": "Navigate between regenerated versions of the same answer without losing your place.",
  "registryDependencies": [
    "https://r.assistant-ui.com/base/elements-surfaces.json"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "type": "registry:component",
      "path": "components/assistant-ui/elements/message-branches.tsx",
      "sourcePath": "packages/ui/src/components/react/assistant-ui/elements/message-branches.tsx",
      "content": "\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { ghostButton, mono } from \"./surfaces\";\n\nexport interface MessageBranchesProps extends Omit<\n  ComponentProps<\"div\">,\n  \"children\"\n> {\n  variants: readonly string[];\n  index: number;\n  onIndexChange: (index: number) => void;\n}\n\nexport function MessageBranches({\n  variants,\n  index,\n  onIndexChange,\n  className,\n  ...props\n}: MessageBranchesProps) {\n  const current = variants[index] === undefined ? 0 : index;\n  const message = variants[current];\n  if (message === undefined) return null;\n\n  return (\n    <div\n      data-slot=\"message-branches\"\n      className={cn(\"flex max-w-sm flex-col gap-2\", className)}\n      {...props}\n    >\n      <p\n        key={current}\n        className=\"fade-in slide-in-from-bottom-1 animate-in text-foreground/90 min-h-[4.25rem] text-sm leading-relaxed duration-300 motion-reduce:animate-none\"\n      >\n        {message}\n      </p>\n      {variants.length > 1 && (\n        <div className=\"flex items-center gap-1\">\n          <button\n            type=\"button\"\n            aria-label=\"Show previous response\"\n            disabled={current === 0}\n            onClick={() => onIndexChange(current - 1)}\n            className={cn(\n              ghostButton,\n              \"size-6 disabled:pointer-events-none disabled:opacity-50\",\n            )}\n          >\n            <ChevronLeftIcon className=\"size-3.5\" />\n          </button>\n          <span className={cn(mono, \"text-muted-foreground tabular-nums\")}>\n            {current + 1} / {variants.length}\n          </span>\n          <button\n            type=\"button\"\n            aria-label=\"Show next response\"\n            disabled={current === variants.length - 1}\n            onClick={() => onIndexChange(current + 1)}\n            className={cn(\n              ghostButton,\n              \"size-6 disabled:pointer-events-none disabled:opacity-50\",\n            )}\n          >\n            <ChevronRightIcon className=\"size-3.5\" />\n          </button>\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}