{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stamp-approval",
  "title": "Stamp Approval",
  "description": "Human sign-off for an agent's tool call. The decision lands as a rubber stamp.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://spotcheckui.com/r/spotcheck-base.json",
    "https://spotcheckui.com/r/button.json",
    "https://spotcheckui.com/r/tag.json"
  ],
  "files": [
    {
      "path": "registry/spotcheck/components/spotcheck/stamp-approval.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useAnimate, useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/registry/spotcheck/components/spotcheck/button\"\nimport { Tag } from \"@/registry/spotcheck/components/spotcheck/tag\"\n\nconst STAMP_SPRING = { type: \"spring\", stiffness: 520, damping: 19 } as const\nconst STAMP_START_SCALE = 2.6\nconst IMPACT_DELAY_MS = 140\nconst STAMP_TILT = { approved: [-26, -8], denied: [18, 6] }\n\ntype Decision = \"approved\" | \"denied\"\ntype Args = Record<string, string>\n\nexport type ToolCall = {\n  name: string\n  args: Args\n  /** What the call will actually do, in plain words. People should approve this, not the raw call. */\n  resolved: string\n  risk?: \"low\" | \"high\"\n}\n\ntype StampApprovalProps = {\n  call: ToolCall\n  /** Argument names a person may change before approving. */\n  editable?: string[]\n  /** Runs with the final arguments, including any edits. */\n  onApprove?: (args: Args) => void\n  onDeny?: () => void\n  className?: string\n}\n\nexport function StampApproval({ call, editable = [], onApprove, onDeny, className }: StampApprovalProps) {\n  const [args, setArgs] = React.useState(call.args)\n  const [decision, setDecision] = React.useState<Decision | null>(null)\n  const [card, animateCard] = useAnimate<HTMLDivElement>()\n  const status = React.useRef<HTMLParagraphElement>(null)\n  const reduced = useReducedMotion()\n  const risky = call.risk === \"high\"\n\n  const decide = (next: Decision) => {\n    setDecision(next)\n    if (next === \"approved\") onApprove?.(args)\n    else onDeny?.()\n    if (!reduced) {\n      setTimeout(() => animateCard(card.current, { y: [0, 5, 0], scale: [1, 0.985, 1] }, { duration: 0.22 }), IMPACT_DELAY_MS)\n    }\n  }\n\n  // The buttons are gone after a decision, so focus moves to the result.\n  React.useEffect(() => {\n    if (decision) status.current?.focus()\n  }, [decision])\n\n  return (\n    <div className={cn(\"flex flex-col gap-3.5 font-(family-name:--f-body)\", className)}>\n      <div\n        ref={card}\n        className=\"border-ink bg-raise relative max-w-160 overflow-hidden border-(length:--rule) px-4 pt-3.5 pb-4 font-(family-name:--f-mono) text-[13px]\"\n      >\n        <div className=\"mb-2.5 flex flex-wrap justify-between gap-2 border-b border-dashed border-[color-mix(in_srgb,var(--ink)_40%,transparent)] pb-2\">\n          <span className=\"spotcheck-label\">Agent request · needs approval</span>\n          <Tag variant={risky ? \"accent\" : \"outline\"}>{risky ? \"High risk\" : \"Low risk\"}</Tag>\n        </div>\n        <p className=\"mb-3 font-(family-name:--f-body) text-base text-pretty\">{call.resolved}</p>\n        <div className=\"spotcheck-heading text-[26px] leading-none\">\n          {call.name}\n          <span className=\"text-mute\">(</span>\n        </div>\n        <table className=\"my-2 ml-4.5 border-collapse\">\n          <tbody>\n            {Object.entries(args).map(([name, value]) => (\n              <tr key={name}>\n                <th scope=\"row\" className=\"text-mute py-[3px] pr-3.5 text-left align-bottom font-normal\">\n                  {name}\n                </th>\n                <td className=\"py-[3px] align-bottom\">\n                  {editable.includes(name) && !decision ? (\n                    <input\n                      aria-label={`Edit ${name}`}\n                      value={value}\n                      onChange={(event) => setArgs((current) => ({ ...current, [name]: event.target.value }))}\n                      className=\"spotcheck-focus border-ink w-full min-w-40 border-b border-dashed bg-transparent\"\n                    />\n                  ) : (\n                    value\n                  )}\n                </td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n        <div className=\"spotcheck-heading text-mute text-[26px] leading-none\">)</div>\n        {decision && (\n          <motion.div\n            aria-hidden\n            data-testid=\"stamp\"\n            data-stamp={decision}\n            initial={reduced ? false : { opacity: 0, scale: STAMP_START_SCALE, rotate: STAMP_TILT[decision][0] }}\n            animate={{ opacity: 1, scale: 1, rotate: STAMP_TILT[decision][1] }}\n            transition={STAMP_SPRING}\n            className={cn(\n              \"spotcheck-display pointer-events-none absolute top-[38%] right-4.5 border-4 border-double border-current px-3.5 py-1.5 text-[32px] leading-none tracking-[.06em] md:text-[44px]\",\n              decision === \"approved\" ? \"text-accent-ink\" : \"text-bad\",\n            )}\n          >\n            {decision}\n          </motion.div>\n        )}\n      </div>\n      {decision ? (\n        <p ref={status} tabIndex={-1} role=\"status\" className=\"spotcheck-label outline-none\">\n          {decision === \"approved\" ? \"Approved. The tool call was released to the agent.\" : \"Denied. The agent was told to stop.\"}\n        </p>\n      ) : (\n        <div className=\"flex flex-wrap gap-4\">\n          <Button variant=\"accent\" onClick={() => decide(\"approved\")}>\n            Approve\n          </Button>\n          <Button onClick={() => decide(\"denied\")}>Deny</Button>\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "springs"
  ],
  "type": "registry:component"
}