{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "approval-request",
  "title": "Approval Request",
  "description": "Asks the user to approve or deny one action, such as an agent running a command.",
  "dependencies": [
    "@vllnt/ui@^0.3.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/approval-request/approval-request.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cva } from \"class-variance-authority\";\n\nimport { cn } from \"@vllnt/ui\";\nimport { Badge } from \"@vllnt/ui\";\nimport { Button } from \"@vllnt/ui\";\nimport { Checkbox } from \"@vllnt/ui\";\nimport { Label } from \"@vllnt/ui\";\n\n/** How much damage the requested action can do if it goes wrong. */\nexport type ApprovalRequestRisk = \"high\" | \"low\" | \"medium\";\n\n/** Where the request stands. A `pending` request takes a decision; the others are final. */\nexport type ApprovalRequestStatus =\n  | \"approved\"\n  | \"denied\"\n  | \"expired\"\n  | \"pending\";\n\n/**\n * Surface treatment. It changes the look and nothing else: the host supplies\n * any Dialog, overlay or positioning.\n */\nexport type ApprovalRequestPlacement = \"dialog\" | \"hud\" | \"inline\";\n\n/** Optional \"remember my choice\" checkbox shown while the request is pending. */\nexport type ApprovalRequestRemember = {\n  /** Controlled value. Leave it out to let the checkbox keep its own state. */\n  checked?: boolean;\n  /** Visible text next to the checkbox. A blank value shows `Remember my choice`. */\n  label: string;\n  /** Called with the new value when the user toggles the checkbox. */\n  onCheckedChange?: (checked: boolean) => void;\n};\n\n/**\n * Visible words. Every key is optional: a missing or blank entry falls back to\n * the English default, so a risk or status is never shown without a word.\n */\nexport type ApprovalRequestLabels = {\n  /** Text of the approve button. Default `Approve`. */\n  approve?: string;\n  /** Text of the deny button. Default `Deny`. */\n  deny?: string;\n  /** Risk words. Defaults `Low risk`, `Medium risk`, `High risk`. */\n  risk?: Partial<Record<ApprovalRequestRisk, string>>;\n  /** Status words. Defaults `Pending`, `Approved`, `Denied`, `Expired`. */\n  status?: Partial<Record<ApprovalRequestStatus, string>>;\n};\n\nexport type ApprovalRequestProps = Omit<\n  React.ComponentPropsWithoutRef<\"fieldset\">,\n  \"children\" | \"title\"\n> & {\n  /** What the request asks for, shown in a monospace block (a command, a path, a URL). */\n  action: string;\n  /** Extra context under the title. */\n  detail?: string;\n  /** Visible words for the badges and buttons. English defaults. */\n  labels?: ApprovalRequestLabels;\n  /** Called when the user clicks Approve. The button exists while `status` is `pending`. */\n  onApprove: () => void;\n  /** Called when the user clicks Deny. The button exists while `status` is `pending`. */\n  onDeny: () => void;\n  /** Surface treatment. Default `inline`. */\n  placement?: ApprovalRequestPlacement;\n  /** Adds a \"remember my choice\" checkbox while the request is pending. */\n  remember?: ApprovalRequestRemember;\n  /** Risk of the requested action. Default `low`. */\n  risk?: ApprovalRequestRisk;\n  /** Request status. Default `pending`. */\n  status?: ApprovalRequestStatus;\n  /** Short name of the request. Labels the group. */\n  title: string;\n};\n\ntype ApprovalRequestFooterProps = {\n  approveLabel: string;\n  denyLabel: string;\n  onApprove: () => void;\n  onDeny: () => void;\n};\n\nconst DEFAULT_APPROVE_LABEL = \"Approve\";\nconst DEFAULT_DENY_LABEL = \"Deny\";\nconst DEFAULT_REMEMBER_LABEL = \"Remember my choice\";\n\nconst DEFAULT_RISK_LABELS: Record<ApprovalRequestRisk, string> = {\n  high: \"High risk\",\n  low: \"Low risk\",\n  medium: \"Medium risk\",\n};\n\nconst DEFAULT_STATUS_LABELS: Record<ApprovalRequestStatus, string> = {\n  approved: \"Approved\",\n  denied: \"Denied\",\n  expired: \"Expired\",\n  pending: \"Pending\",\n};\n\nconst surfaceVariants = cva(\n  \"flex w-full min-w-0 flex-col gap-3 border text-sm\",\n  {\n    defaultVariants: {\n      placement: \"inline\",\n    },\n    variants: {\n      placement: {\n        dialog:\n          \"max-w-lg gap-4 rounded-lg bg-background p-6 text-foreground shadow-lg\",\n        hud: \"max-w-sm rounded-md bg-popover p-3 text-popover-foreground shadow-md\",\n        inline: \"rounded-lg bg-card p-4 text-card-foreground\",\n      },\n    },\n  },\n);\n\nconst riskVariants = cva(\"\", {\n  defaultVariants: {\n    risk: \"low\",\n  },\n  variants: {\n    risk: {\n      high: \"border-destructive/40 bg-destructive/10 text-destructive\",\n      low: \"border-border bg-muted text-muted-foreground\",\n      medium: \"border-warning/40 bg-warning/10 text-warning\",\n    },\n  },\n});\n\nconst statusVariants = cva(\"\", {\n  defaultVariants: {\n    status: \"pending\",\n  },\n  variants: {\n    status: {\n      approved: \"border-success/40 bg-success/10 text-success\",\n      denied: \"border-destructive/40 bg-destructive/10 text-destructive\",\n      expired: \"border-border bg-muted text-muted-foreground\",\n      pending: \"border-info/40 bg-info/10 text-info\",\n    },\n  },\n});\n\nfunction resolveLabel(custom: string | undefined, fallback: string): string {\n  return custom !== undefined && custom.trim() !== \"\" ? custom : fallback;\n}\n\nfunction RememberRow({\n  checked,\n  label,\n  onCheckedChange,\n}: ApprovalRequestRemember): React.JSX.Element {\n  const rememberId = React.useId();\n\n  return (\n    <div className=\"flex items-center gap-2\">\n      <Checkbox\n        checked={checked}\n        id={rememberId}\n        onCheckedChange={(state) => {\n          onCheckedChange?.(state === true);\n        }}\n      />\n      <Label\n        className=\"font-normal leading-snug text-muted-foreground\"\n        htmlFor={rememberId}\n      >\n        {resolveLabel(label, DEFAULT_REMEMBER_LABEL)}\n      </Label>\n    </div>\n  );\n}\n\nfunction ApprovalRequestFooter({\n  approveLabel,\n  denyLabel,\n  onApprove,\n  onDeny,\n}: ApprovalRequestFooterProps): React.JSX.Element {\n  return (\n    <div className=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n      <Button onClick={onDeny} type=\"button\" variant=\"outline\">\n        {denyLabel}\n      </Button>\n      <Button onClick={onApprove} type=\"button\">\n        {approveLabel}\n      </Button>\n    </div>\n  );\n}\n\n/**\n * Asks the user to approve or deny one action, such as an agent running a\n * command. It shows the risk and the status as words, the action in\n * monospace, and, while the request is pending, Approve and Deny buttons with\n * an optional \"remember my choice\" checkbox. Once the request reaches\n * approved, denied or expired, the buttons go away and the status word stays.\n *\n * The root is a `<fieldset>`, which exposes `role=\"group\"` named by the title.\n * Passing `disabled` disables the buttons and the checkbox, for example while\n * the host sends the decision.\n *\n * @example\n * ```tsx\n * <ApprovalRequest\n *   action=\"rm -rf ./dist\"\n *   onApprove={approve}\n *   onDeny={deny}\n *   risk=\"high\"\n *   title=\"Delete build output\"\n * />\n * ```\n */\nexport const ApprovalRequest = ({\n  action,\n  className,\n  detail,\n  labels,\n  onApprove,\n  onDeny,\n  placement = \"inline\",\n  ref: reference,\n  remember,\n  risk = \"low\",\n  status = \"pending\",\n  title,\n  ...props\n}: ApprovalRequestProps & { ref?: React.Ref<HTMLFieldSetElement> }) => {\n  const titleId = React.useId();\n  const isPending = status === \"pending\";\n\n  return (\n    <fieldset\n      aria-labelledby={titleId}\n      className={cn(surfaceVariants({ placement }), className)}\n      ref={reference}\n      {...props}\n    >\n      <div className=\"flex flex-wrap items-center gap-2\">\n        <Badge className={riskVariants({ risk })} variant=\"outline\">\n          {resolveLabel(labels?.risk?.[risk], DEFAULT_RISK_LABELS[risk])}\n        </Badge>\n        <Badge\n          className={statusVariants({ status })}\n          role=\"status\"\n          variant=\"outline\"\n        >\n          {resolveLabel(\n            labels?.status?.[status],\n            DEFAULT_STATUS_LABELS[status],\n          )}\n        </Badge>\n      </div>\n      <p className=\"text-base font-semibold leading-snug\" id={titleId}>\n        {title}\n      </p>\n      {detail ? <p className=\"text-muted-foreground\">{detail}</p> : null}\n      <code className=\"block whitespace-pre-wrap break-words rounded-md border bg-muted px-3 py-2 font-mono text-sm text-foreground\">\n        {action}\n      </code>\n      {isPending ? (\n        <>\n          <hr className=\"border-border\" />\n          {remember ? <RememberRow {...remember} /> : null}\n          <ApprovalRequestFooter\n            approveLabel={resolveLabel(labels?.approve, DEFAULT_APPROVE_LABEL)}\n            denyLabel={resolveLabel(labels?.deny, DEFAULT_DENY_LABEL)}\n            onApprove={onApprove}\n            onDeny={onDeny}\n          />\n        </>\n      ) : null}\n    </fieldset>\n  );\n};\n\nApprovalRequest.displayName = \"ApprovalRequest\";\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component",
  "version": "0.3.0",
  "stability": "stable",
  "platforms": [
    "web"
  ]
}
