{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-confirmation",
  "title": "AI: Confirmation",
  "description": "A human-in-the-loop approve or reject card for a pending tool call.",
  "registryDependencies": [
    "@nx-ui/utils",
    "@nx-ui/alert",
    "@nx-ui/button",
    "@nx-ui/ai-types"
  ],
  "files": [
    {
      "path": "components/ai/confirmation.tsx",
      "content": "\"use client\"\n\nimport {\n  type ComponentProps,\n  type ReactNode,\n  createContext,\n  useContext,\n} from \"react\"\n\nimport { Alert, AlertDescription } from \"@/components/ui/alert\"\nimport { Button } from \"@/components/ui/button\"\nimport { cn } from \"@/lib/utils\"\n\nimport type { ToolUIPart } from \"./types\"\n\ntype ToolUIPartApproval =\n  | {\n      id: string\n      approved?: never\n      reason?: never\n    }\n  | {\n      id: string\n      approved: boolean\n      reason?: string\n    }\n  | {\n      id: string\n      approved: true\n      reason?: string\n    }\n  | {\n      id: string\n      approved: false\n      reason?: string\n    }\n  | undefined\n\ntype ConfirmationContextValue = {\n  approval: ToolUIPartApproval\n  state: ToolUIPart[\"state\"]\n}\n\nconst ConfirmationContext = createContext<ConfirmationContextValue | null>(null)\n\nconst useConfirmation = () => {\n  const context = useContext(ConfirmationContext)\n\n  if (!context) {\n    throw new Error(\"Confirmation components must be used within Confirmation\")\n  }\n\n  return context\n}\n\nexport type ConfirmationProps = ComponentProps<typeof Alert> & {\n  approval?: ToolUIPartApproval\n  state: ToolUIPart[\"state\"]\n}\n\nexport const Confirmation = ({\n  className,\n  approval,\n  state,\n  ...props\n}: ConfirmationProps) => {\n  if (!approval || state === \"input-streaming\" || state === \"input-available\") {\n    return null\n  }\n\n  return (\n    <ConfirmationContext.Provider value={{ approval, state }}>\n      <Alert className={cn(\"flex flex-col gap-2\", className)} {...props} />\n    </ConfirmationContext.Provider>\n  )\n}\n\nexport type ConfirmationTitleProps = ComponentProps<typeof AlertDescription>\n\nexport const ConfirmationTitle = ({\n  className,\n  ...props\n}: ConfirmationTitleProps) => (\n  <AlertDescription className={cn(\"inline\", className)} {...props} />\n)\n\nexport type ConfirmationRequestProps = {\n  children?: ReactNode\n}\n\nexport const ConfirmationRequest = ({ children }: ConfirmationRequestProps) => {\n  const { state } = useConfirmation()\n\n  // Only show when approval is requested\n  if (state !== \"approval-requested\") {\n    return null\n  }\n\n  return children\n}\n\nexport type ConfirmationAcceptedProps = {\n  children?: ReactNode\n}\n\nexport const ConfirmationAccepted = ({\n  children,\n}: ConfirmationAcceptedProps) => {\n  const { approval, state } = useConfirmation()\n\n  // Only show when approved and in response states\n  if (\n    !approval?.approved ||\n    (state !== \"approval-responded\" &&\n      state !== \"output-denied\" &&\n      state !== \"output-available\")\n  ) {\n    return null\n  }\n\n  return children\n}\n\nexport type ConfirmationRejectedProps = {\n  children?: ReactNode\n}\n\nexport const ConfirmationRejected = ({\n  children,\n}: ConfirmationRejectedProps) => {\n  const { approval, state } = useConfirmation()\n\n  // Only show when rejected and in response states\n  if (\n    approval?.approved !== false ||\n    (state !== \"approval-responded\" &&\n      state !== \"output-denied\" &&\n      state !== \"output-available\")\n  ) {\n    return null\n  }\n\n  return children\n}\n\nexport type ConfirmationActionsProps = ComponentProps<\"div\">\n\nexport const ConfirmationActions = ({\n  className,\n  ...props\n}: ConfirmationActionsProps) => {\n  const { state } = useConfirmation()\n\n  // Only show when approval is requested\n  if (state !== \"approval-requested\") {\n    return null\n  }\n\n  return (\n    <div\n      className={cn(\"flex items-center justify-end gap-2 self-end\", className)}\n      {...props}\n    />\n  )\n}\n\nexport type ConfirmationActionProps = ComponentProps<typeof Button>\n\nexport const ConfirmationAction = (props: ConfirmationActionProps) => (\n  <Button size=\"sm\" type=\"button\" {...props} />\n)\n",
      "type": "registry:ui",
      "target": "components/ai/confirmation.tsx"
    }
  ],
  "type": "registry:ui"
}