{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "paper-shredder",
  "title": "Paper Shredder",
  "author": "VenusUI",
  "description": "A desk shredder that feeds a page in and drops it out underneath in curling strips.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/paper-shredder.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { FilePlus2, Scissors } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface PaperShredderProps extends React.ComponentProps<\"div\"> {\n  /** What's printed on the sheet. */\n  children: React.ReactNode\n  /** Strips the sheet is cut into. */\n  strips?: number\n  onShred?: (count: number) => void\n}\n\n/**\n * A desk shredder. Press \"Shred\" (or the sheet) and the page feeds into the\n * slot and comes out underneath in curling strips. A playful confirmation for\n * destructive actions such as deleting data.\n */\nfunction PaperShredder({ children, strips = 12, onShred, className, ...props }: PaperShredderProps) {\n  const [state, setState] = React.useState<\"ready\" | \"shredding\" | \"gone\">(\"ready\")\n  const [count, setCount] = React.useState(0)\n  const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)\n\n  React.useEffect(() => () => clearTimeout(timer.current), [])\n\n  const shred = () => {\n    if (state !== \"ready\") return\n    setState(\"shredding\")\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n    timer.current = setTimeout(() => {\n      setState(\"gone\")\n      setCount((value) => value + 1)\n      onShred?.(count + 1)\n    }, reduced ? 0 : 1700)\n  }\n\n  const sheet = <div className=\"h-full w-full bg-[#fdfcf7] p-4 text-[11px] leading-4 text-neutral-700\">{children}</div>\n\n  return (\n    <div data-slot=\"paper-shredder\" className={cn(\"flex w-72 max-w-full flex-col items-center\", className)} {...props}>\n      {/* The sheet waiting on top. */}\n      <div className=\"relative h-56 w-56 overflow-hidden\">\n        {state !== \"gone\" ? (\n          <button\n            type=\"button\"\n            onClick={shred}\n            aria-label=\"Shred this page\"\n            className={cn(\n              \"absolute inset-x-0 top-4 h-64 overflow-hidden rounded-t-sm text-left shadow-[0_6px_14px_-6px_rgb(0_0_0/0.4)] ring-1 ring-black/10 outline-none focus-visible:ring-3 focus-visible:ring-ring/60\",\n              state === \"shredding\" && \"animate-paper-shredder-feed motion-reduce:animate-none\"\n            )}\n          >\n            {sheet}\n          </button>\n        ) : (\n          <p className=\"absolute inset-x-0 bottom-6 text-center text-sm text-muted-foreground\">Nothing left to read.</p>\n        )}\n      </div>\n\n      {/* The machine. */}\n      <div className=\"relative z-10 h-16 w-72 max-w-full rounded-t-xl rounded-b-md bg-linear-to-b from-neutral-700 to-neutral-900 shadow-[0_10px_20px_-10px_rgb(0_0_0/0.6),inset_0_1px_0_rgb(255_255_255/0.15)]\">\n        <span aria-hidden=\"true\" className=\"absolute top-3 left-1/2 h-1.5 w-60 -translate-x-1/2 rounded-full bg-black shadow-[inset_0_1px_2px_rgb(0_0_0/0.8)]\" />\n        <span aria-hidden=\"true\" className={cn(\"absolute right-4 bottom-3 size-2 rounded-full\", state === \"shredding\" ? \"animate-pulse bg-emerald-400\" : \"bg-neutral-600\")} />\n        <span aria-hidden=\"true\" className=\"absolute bottom-2.5 left-4 font-mono text-[10px] tracking-[0.2em] text-neutral-400\">CROSS-CUT</span>\n      </div>\n\n      {/* Strips falling out underneath. */}\n      <div aria-hidden=\"true\" className=\"relative h-36 w-56 overflow-hidden rounded-b-lg bg-neutral-200/60 dark:bg-neutral-800/60\">\n        {state !== \"ready\"\n          ? Array.from({ length: strips }, (_, i) => (\n              <div\n                key={`${count}-${i}`}\n                className=\"animate-paper-shredder-strip absolute top-0 h-64 motion-reduce:animate-none\"\n                style={{\n                  left: `${(i / strips) * 100}%`,\n                  width: `${100 / strips}%`,\n                  animationDelay: `${(i % 3) * 60}ms`,\n                  rotate: `${(i % 2 ? 1 : -1) * (1 + (i % 4))}deg`,\n                }}\n              >\n                <div className=\"h-full overflow-hidden\" style={{ width: `${strips * 100}%`, marginLeft: `${-i * 100}%` }}>\n                  {sheet}\n                </div>\n              </div>\n            ))\n          : null}\n      </div>\n\n      <div className=\"mt-4 flex items-center gap-2\">\n        <button type=\"button\" onClick={shred} disabled={state !== \"ready\"} className=\"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground outline-none hover:bg-primary/90 focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50\">\n          <Scissors aria-hidden=\"true\" className=\"size-4\" />\n          Shred\n        </button>\n        <button type=\"button\" onClick={() => setState(\"ready\")} disabled={state !== \"gone\"} className=\"inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm text-muted-foreground outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50\">\n          <FilePlus2 aria-hidden=\"true\" className=\"size-4\" />\n          New page\n        </button>\n      </div>\n      <p role=\"status\" className=\"mt-2 min-h-5 text-xs text-muted-foreground\">\n        {state === \"shredding\" ? \"Shredding…\" : count ? `${count} ${count === 1 ? \"page\" : \"pages\"} shredded` : \"\"}\n      </p>\n    </div>\n  )\n}\n\nexport { PaperShredder }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-paper-shredder-feed": "paper-shredder-feed 1.6s ease-in forwards",
      "animate-paper-shredder-strip": "paper-shredder-strip 1.5s ease-out 0.5s both"
    }
  },
  "css": {
    "@keyframes paper-shredder-feed": {
      "from": {
        "transform": "translateY(0)"
      },
      "to": {
        "transform": "translateY(115%)"
      }
    },
    "@keyframes paper-shredder-strip": {
      "from": {
        "transform": "translateY(-100%)"
      },
      "to": {
        "transform": "translateY(-48%)"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "animations"
  ],
  "type": "registry:ui"
}