{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "confirmation",
  "title": "Confirmation",
  "description": "Approve or deny an agent's request, with an optional reason, then the recorded outcome.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-textarea"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/confirmation.tsx",
      "content": "\"use client\";\n\nimport { codeSpans, confirmationPrimitive, WORDS } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport { type ComponentProps, Fragment } from \"react\";\nimport { KindTextarea } from \"./internal/textarea\";\n\nconst parts = createParts(confirmationPrimitive, {\n  root: \"div\",\n  title: \"div\",\n  meta: \"span\",\n  risk: \"div\",\n  \"risk-icon\": \"span\",\n  reason: \"div\",\n  choices: \"div\",\n  approve: \"button\",\n  always: \"button\",\n  deny: \"button\",\n  cancel: \"button\",\n  error: \"span\",\n  detail: \"div\",\n  outcome: \"div\",\n  \"outcome-icon\": \"span\",\n});\n\nexport type ConfirmationProps = ComponentProps<typeof parts.Root>;\n\n/**\n * Asks a person to approve or deny a request, then shows what was decided. Only the choices the host supplies\n * (`onDeny`, `onAlwaysAllow`, `onApprove`) render, in that order. Any `children` replace the default parts.\n */\nexport function Confirmation({ children, ...props }: ConfirmationProps) {\n  return <parts.Root {...props}>{children !== undefined ? children : DEFAULT_PARTS}</parts.Root>;\n}\n\nexport const ConfirmationChoices = parts.Choices;\nexport const ConfirmationOutcomeIcon = parts.OutcomeIcon;\nexport const ConfirmationRiskIcon = parts.RiskIcon;\n\n/** Text with its backticks as `code`. */\nexport const withCode = (text: string) =>\n  codeSpans(text).map((piece, index) =>\n    // biome-ignore lint/suspicious/noArrayIndexKey: the pieces never move.\n    index % 2 ? <code key={index}>{piece}</code> : <Fragment key={index}>{piece}</Fragment>,\n  );\n\nexport type ConfirmationTitleProps = ComponentProps<typeof parts.Title>;\n\n/** The `label`, unless you pass children. Rendered only while `label` is set, and hidden inside a Tool. */\nexport function ConfirmationTitle({\n  children = ({ label }) => withCode(label),\n  ...props\n}: ConfirmationTitleProps) {\n  return <parts.Title {...props}>{children}</parts.Title>;\n}\n\nexport type ConfirmationMetaProps = ComponentProps<typeof parts.Meta>;\n\n/** \"Sending decision\", else the deadline (\"Decide in 4 min\", then \"Expired\"), unless you pass children. */\nexport function ConfirmationMeta({ children = ({ text }) => text, ...props }: ConfirmationMetaProps) {\n  return <parts.Meta {...props}>{children}</parts.Meta>;\n}\n\nexport type ConfirmationRiskProps = ComponentProps<typeof parts.Risk>;\n\n/** The `riskText` after a warning mark, unless you pass children. Rendered only while `riskText` is set. */\nexport function ConfirmationRisk({\n  children = ({ text }) => (\n    <>\n      <ConfirmationRiskIcon />\n      <span>{withCode(text)}</span>\n    </>\n  ),\n  ...props\n}: ConfirmationRiskProps) {\n  return <parts.Risk {...props}>{children}</parts.Risk>;\n}\n\nexport type ConfirmationReasonProps = ComponentProps<typeof parts.Reason>;\n\n/**\n * A box for the reason Deny sends, unless you pass children. Rendered with the `reason` option, once a person's Deny\n * opens it.\n */\nexport function ConfirmationReason({\n  children = ({ controller, readOnly }) => (\n    <KindTextarea\n      controller={controller}\n      readOnly={readOnly}\n      aria-label=\"Reason for denying\"\n      placeholder=\"Add a reason (optional)\"\n      rows={2}\n    />\n  ),\n  ...props\n}: ConfirmationReasonProps) {\n  return <parts.Reason {...props}>{children}</parts.Reason>;\n}\n\nexport type ConfirmationApproveProps = ComponentProps<typeof parts.Approve>;\n\n/** Calls `onApprove`. Reads the `approveLabel` unless you pass children. Rendered only while `onApprove` is set. */\nexport function ConfirmationApprove({ children = withPendingMark, ...props }: ConfirmationApproveProps) {\n  return <parts.Approve {...props}>{children}</parts.Approve>;\n}\n\nexport type ConfirmationAlwaysProps = ComponentProps<typeof parts.Always>;\n\n/**\n * Calls `onAlwaysAllow`, which approves and asks the host to remember. Reads the `alwaysLabel` and `alwaysTarget`\n * unless you pass children. Rendered only while `onAlwaysAllow` is set and `risk` isn't `\"danger\"`.\n */\nexport function ConfirmationAlways({ children = withPendingMark, ...props }: ConfirmationAlwaysProps) {\n  return <parts.Always {...props}>{children}</parts.Always>;\n}\n\nexport type ConfirmationDenyProps = ComponentProps<typeof parts.Deny>;\n\n/**\n * Calls `onDeny`. With `reason`, a person's first press opens the reason box instead. Reads the `denyLabel` unless\n * you pass children. Rendered only while `onDeny` is set.\n */\nexport function ConfirmationDeny({ children = withPendingMark, ...props }: ConfirmationDenyProps) {\n  return <parts.Deny {...props}>{children}</parts.Deny>;\n}\n\nexport type ConfirmationCancelProps = ComponentProps<typeof parts.Cancel>;\n\n/** Closes the reason box without deciding. Reads \"Cancel\" unless you pass children. Rendered while the box is open. */\nexport function ConfirmationCancel({ children = \"Cancel\", ...props }: ConfirmationCancelProps) {\n  return <parts.Cancel {...props}>{children}</parts.Cancel>;\n}\n\nexport type ConfirmationErrorProps = ComponentProps<typeof parts.Error>;\n\n/** \"Decision not sent. Try again.\" while the host reports `submit-failed`, unless you pass children. */\nexport function ConfirmationError({ children = WORDS.notSentRetry, ...props }: ConfirmationErrorProps) {\n  return <parts.Error {...props}>{children}</parts.Error>;\n}\n\nexport type ConfirmationDetailProps = ComponentProps<typeof parts.Detail>;\n\n/** The `alwaysDetail`, unless you pass children. Rendered under the choices while Always allow shows. */\nexport function ConfirmationDetail({\n  children = ({ text }) => withCode(text),\n  ...props\n}: ConfirmationDetailProps) {\n  return <parts.Detail {...props}>{children}</parts.Detail>;\n}\n\nexport type ConfirmationOutcomeProps = ComponentProps<typeof parts.Outcome>;\n\n/** Where the request stands, like \"Approved\", with the denial's reason, unless you pass children. */\nexport function ConfirmationOutcome({\n  children = ({ label, reason }) => (\n    <>\n      <ConfirmationOutcomeIcon />\n      <span data-confirmation-label=\"\">{withCode(label)}</span>{\" \"}\n      {reason ? <span data-confirmation-reason=\"\">{reason}</span> : null}\n    </>\n  ),\n  ...props\n}: ConfirmationOutcomeProps) {\n  return <parts.Outcome {...props}>{children}</parts.Outcome>;\n}\n\n// The mark shows only while the button's call is pending (controls.css).\nconst withPendingMark = ({ label }: { label: string }) => (\n  <>\n    <span data-kind-pending-mark=\"\" data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />\n    {withCode(label)}\n  </>\n);\n\n// Shared, so an update to the request doesn't render the default parts' wrappers again.\nconst DEFAULT_PARTS = (\n  <>\n    <ConfirmationTitle />\n    <ConfirmationMeta />\n    <ConfirmationRisk />\n    <ConfirmationReason />\n    <ConfirmationChoices>\n      <ConfirmationCancel />\n      <ConfirmationDeny />\n      <ConfirmationAlways />\n      <ConfirmationApprove />\n      <ConfirmationError />\n    </ConfirmationChoices>\n    <ConfirmationDetail />\n    <ConfirmationOutcome />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/confirmation.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
