{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-chain-of-thought",
  "title": "AI: Chain Of Thought",
  "description": "A collapsible step-by-step chain-of-thought trace with search results and images.",
  "dependencies": [
    "@untitledui/icons@^0.0.22"
  ],
  "registryDependencies": [
    "@nx-ui/utils",
    "@nx-ui/badge",
    "@nx-ui/collapsible",
    "@nx-ui/ai-use-controllable-state"
  ],
  "files": [
    {
      "path": "components/ai/chain-of-thought.tsx",
      "content": "\"use client\"\n\nimport {\n  type ComponentProps,\n  type ReactNode,\n  createContext,\n  memo,\n  useContext,\n  useMemo,\n} from \"react\"\nimport { ChevronDown, Dotpoints01, Stars01 } from \"@untitledui/icons\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport {\n  Collapsible,\n  CollapsibleContent,\n  CollapsibleTrigger,\n} from \"@/components/ui/collapsible\"\nimport { cn } from \"@/lib/utils\"\n\nimport { useControllableState } from \"./use-controllable-state\"\n\n/** A line-icon component, e.g. any export from @untitledui/icons. */\ntype IconComponent = React.ComponentType<{ className?: string }>\n\ntype ChainOfThoughtContextValue = {\n  isOpen: boolean\n  setIsOpen: (open: boolean) => void\n}\n\nconst ChainOfThoughtContext = createContext<ChainOfThoughtContextValue | null>(\n  null\n)\n\nconst useChainOfThought = () => {\n  const context = useContext(ChainOfThoughtContext)\n  if (!context) {\n    throw new Error(\n      \"ChainOfThought components must be used within ChainOfThought\"\n    )\n  }\n  return context\n}\n\nexport type ChainOfThoughtProps = ComponentProps<\"div\"> & {\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n}\n\nexport const ChainOfThought = memo(\n  ({\n    className,\n    open,\n    defaultOpen = false,\n    onOpenChange,\n    children,\n    ...props\n  }: ChainOfThoughtProps) => {\n    const [isOpen, setIsOpen] = useControllableState({\n      prop: open,\n      defaultProp: defaultOpen,\n      onChange: onOpenChange,\n    })\n\n    const chainOfThoughtContext = useMemo(\n      () => ({ isOpen: isOpen ?? false, setIsOpen }),\n      [isOpen, setIsOpen]\n    )\n\n    return (\n      <ChainOfThoughtContext.Provider value={chainOfThoughtContext}>\n        <div\n          className={cn(\"not-prose max-w-prose space-y-4\", className)}\n          {...props}\n        >\n          {children}\n        </div>\n      </ChainOfThoughtContext.Provider>\n    )\n  }\n)\n\nexport type ChainOfThoughtHeaderProps = ComponentProps<\n  typeof CollapsibleTrigger\n>\n\nexport const ChainOfThoughtHeader = memo(\n  ({ className, children, ...props }: ChainOfThoughtHeaderProps) => {\n    const { isOpen, setIsOpen } = useChainOfThought()\n\n    return (\n      <Collapsible onOpenChange={setIsOpen} open={isOpen}>\n        <CollapsibleTrigger\n          className={cn(\n            \"flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground\",\n            className\n          )}\n          {...props}\n        >\n          <Stars01 className=\"size-4\" />\n          <span className=\"flex-1 text-left\">\n            {children ?? \"Chain of Thought\"}\n          </span>\n          <ChevronDown\n            className={cn(\n              \"size-4 transition-transform\",\n              isOpen ? \"rotate-180\" : \"rotate-0\"\n            )}\n          />\n        </CollapsibleTrigger>\n      </Collapsible>\n    )\n  }\n)\n\nexport type ChainOfThoughtStepProps = ComponentProps<\"div\"> & {\n  icon?: IconComponent\n  label: ReactNode\n  description?: ReactNode\n  status?: \"complete\" | \"active\" | \"pending\"\n}\n\nexport const ChainOfThoughtStep = memo(\n  ({\n    className,\n    icon: Icon = Dotpoints01,\n    label,\n    description,\n    status = \"complete\",\n    children,\n    ...props\n  }: ChainOfThoughtStepProps) => {\n    const statusStyles = {\n      complete: \"text-muted-foreground\",\n      active: \"text-foreground\",\n      pending: \"text-muted-foreground/50\",\n    }\n\n    return (\n      <div\n        className={cn(\n          \"flex gap-2 text-sm\",\n          statusStyles[status],\n          \"fade-in-0 slide-in-from-top-2 animate-in\",\n          className\n        )}\n        {...props}\n      >\n        <div className=\"relative mt-0.5\">\n          <Icon className=\"size-4\" />\n          <div className=\"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border\" />\n        </div>\n        <div className=\"flex-1 space-y-2 overflow-hidden\">\n          <div>{label}</div>\n          {description && (\n            <div className=\"text-muted-foreground text-xs\">{description}</div>\n          )}\n          {children}\n        </div>\n      </div>\n    )\n  }\n)\n\nexport type ChainOfThoughtSearchResultsProps = ComponentProps<\"div\">\n\nexport const ChainOfThoughtSearchResults = memo(\n  ({ className, ...props }: ChainOfThoughtSearchResultsProps) => (\n    <div\n      className={cn(\"flex flex-wrap items-center gap-2\", className)}\n      {...props}\n    />\n  )\n)\n\nexport type ChainOfThoughtSearchResultProps = ComponentProps<typeof Badge>\n\nexport const ChainOfThoughtSearchResult = memo(\n  ({ className, children, ...props }: ChainOfThoughtSearchResultProps) => (\n    <Badge\n      className={cn(\"gap-1 px-2 py-0.5 font-normal text-xs\", className)}\n      variant=\"secondary\"\n      {...props}\n    >\n      {children}\n    </Badge>\n  )\n)\n\nexport type ChainOfThoughtContentProps = ComponentProps<\n  typeof CollapsibleContent\n>\n\nexport const ChainOfThoughtContent = memo(\n  ({ className, children, ...props }: ChainOfThoughtContentProps) => {\n    const { isOpen } = useChainOfThought()\n\n    return (\n      <Collapsible open={isOpen}>\n        <CollapsibleContent\n          className={cn(\n            \"mt-2 space-y-3\",\n            \"data-closed:fade-out-0 data-closed:slide-out-to-top-2 data-open:slide-in-from-top-2 text-popover-foreground outline-none data-closed:animate-out data-open:animate-in\",\n            className\n          )}\n          {...props}\n        >\n          {children}\n        </CollapsibleContent>\n      </Collapsible>\n    )\n  }\n)\n\nexport type ChainOfThoughtImageProps = ComponentProps<\"div\"> & {\n  caption?: string\n}\n\nexport const ChainOfThoughtImage = memo(\n  ({ className, children, caption, ...props }: ChainOfThoughtImageProps) => (\n    <div className={cn(\"mt-2 space-y-2\", className)} {...props}>\n      <div className=\"relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg bg-muted p-3\">\n        {children}\n      </div>\n      {caption && <p className=\"text-muted-foreground text-xs\">{caption}</p>}\n    </div>\n  )\n)\n\nChainOfThought.displayName = \"ChainOfThought\"\nChainOfThoughtHeader.displayName = \"ChainOfThoughtHeader\"\nChainOfThoughtStep.displayName = \"ChainOfThoughtStep\"\nChainOfThoughtSearchResults.displayName = \"ChainOfThoughtSearchResults\"\nChainOfThoughtSearchResult.displayName = \"ChainOfThoughtSearchResult\"\nChainOfThoughtContent.displayName = \"ChainOfThoughtContent\"\nChainOfThoughtImage.displayName = \"ChainOfThoughtImage\"\n",
      "type": "registry:ui",
      "target": "components/ai/chain-of-thought.tsx"
    }
  ],
  "type": "registry:ui"
}