{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kitchen-timer",
  "title": "Kitchen Timer",
  "author": "VenusUI",
  "description": "A wind-up kitchen timer: twist the dial to set it and it ticks back to zero, then rings.",
  "files": [
    {
      "path": "registry/default/ui/kitchen-timer.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface KitchenTimerProps extends React.ComponentProps<\"div\"> {\n  /** Minutes on the dial. */\n  max?: number\n  defaultMinutes?: number\n  onDone?: () => void\n}\n\nconst mod = (value: number, by: number) => ((value % by) + by) % by\n\n/**\n * A wind-up kitchen timer. Twist the dial (drag, scroll or arrow keys) to set\n * the minutes; let go and it ticks back down to zero, then rings.\n */\nfunction KitchenTimer({ max = 60, defaultMinutes = 0, onDone, className, ...props }: KitchenTimerProps) {\n  const [seconds, setSeconds] = React.useState(defaultMinutes * 60)\n  const [running, setRunning] = React.useState(defaultMinutes > 0)\n  const [ringing, setRinging] = React.useState(false)\n  const drag = React.useRef<{ angle: number } | null>(null)\n  const done = React.useRef(onDone)\n  const left = React.useRef(seconds)\n  React.useEffect(() => {\n    done.current = onDone\n    left.current = seconds\n  })\n\n  React.useEffect(() => {\n    if (!running) return\n    const tick = setInterval(() => {\n      const next = Math.max(0, left.current - 1)\n      left.current = next\n      setSeconds(next)\n      if (next === 0) {\n        setRunning(false)\n        setRinging(true)\n        done.current?.()\n      }\n    }, 1000)\n    return () => clearInterval(tick)\n  }, [running])\n\n  const set = (next: number) => {\n    setRinging(false)\n    setSeconds(Math.round(Math.min(max * 60, Math.max(0, next)) / 30) * 30)\n  }\n\n  const angleAt = (event: React.PointerEvent, element: HTMLElement) => {\n    const box = element.getBoundingClientRect()\n    return mod((Math.atan2(event.clientX - (box.left + box.width / 2), box.top + box.height / 2 - event.clientY) * 180) / Math.PI, 360)\n  }\n\n  const minutes = Math.floor(seconds / 60)\n  const rest = seconds % 60\n\n  return (\n    <div data-slot=\"kitchen-timer\" className={cn(\"flex w-60 flex-col items-center gap-4\", className)} {...props}>\n      <div className={cn(\"relative aspect-square w-full\", ringing && \"animate-kitchen-timer-ring motion-reduce:animate-none\")}>\n        <div aria-hidden=\"true\" className=\"absolute inset-[6%] rounded-full bg-linear-to-b from-neutral-50 to-neutral-200 shadow-[0_14px_24px_-12px_rgb(0_0_0/0.55),inset_0_-6px_12px_rgb(0_0_0/0.08)] dark:from-neutral-200 dark:to-neutral-400\" />\n        <span aria-hidden=\"true\" className=\"absolute top-[3%] left-1/2 size-0 -translate-x-1/2 border-x-[8px] border-t-[12px] border-x-transparent border-t-red-500\" />\n        <div\n          role=\"slider\"\n          tabIndex={0}\n          aria-label=\"Minutes\"\n          aria-valuemin={0}\n          aria-valuemax={max}\n          aria-valuenow={minutes}\n          aria-valuetext={`${minutes} minutes ${rest} seconds`}\n          onPointerDown={(event) => {\n            event.currentTarget.setPointerCapture(event.pointerId)\n            drag.current = { angle: angleAt(event, event.currentTarget) }\n            setRunning(false)\n          }}\n          onPointerMove={(event) => {\n            if (!drag.current) return\n            const now = angleAt(event, event.currentTarget)\n            const delta = mod(now - drag.current.angle + 180, 360) - 180\n            drag.current.angle = now\n            set(seconds - (delta / 360) * max * 60)\n          }}\n          onPointerUp={() => {\n            drag.current = null\n            setRunning(seconds > 0)\n          }}\n          onKeyDown={(event) => {\n            const moves: Record<string, number> = { ArrowUp: 60, ArrowRight: 60, ArrowDown: -60, ArrowLeft: -60, PageUp: 300, PageDown: -300 }\n            const move = moves[event.key]\n            if (move === undefined) return\n            event.preventDefault()\n            const next = Math.min(max * 60, Math.max(0, seconds + move))\n            set(next)\n            setRunning(next > 0)\n          }}\n          style={{ rotate: `${(-seconds / (max * 60)) * 360}deg` }}\n          className=\"absolute inset-[12%] cursor-grab touch-none rounded-full bg-linear-to-b from-red-500 to-red-700 shadow-[0_6px_10px_rgb(0_0_0/0.35),inset_0_2px_0_rgb(255_255_255/0.35)] outline-none select-none focus-visible:ring-4 focus-visible:ring-ring/60 active:cursor-grabbing\"\n        >\n          {Array.from({ length: max }, (_, i) => (\n            <span key={i} aria-hidden=\"true\" className=\"absolute inset-0\" style={{ rotate: `${(i / max) * 360}deg` }}>\n              <span className={cn(\"absolute top-1.5 left-1/2 w-px -translate-x-1/2 bg-white/90\", i % 5 === 0 ? \"h-3\" : \"h-1.5\")} />\n              {i % 5 === 0 ? <span className=\"absolute top-5 left-1/2 -translate-x-1/2 font-mono text-[10px] font-bold text-white\">{i}</span> : null}\n            </span>\n          ))}\n          <span aria-hidden=\"true\" className=\"absolute inset-[32%] rounded-full bg-linear-to-b from-red-400 to-red-600 shadow-inner\" />\n        </div>\n      </div>\n      <p role=\"timer\" className=\"font-mono text-2xl tabular-nums\">\n        {String(minutes).padStart(2, \"0\")}:{String(rest).padStart(2, \"0\")}\n      </p>\n      <p aria-live=\"polite\" className=\"-mt-3 min-h-4 text-xs text-muted-foreground\">\n        {ringing ? \"Ring ring! Time’s up.\" : running ? \"Ticking…\" : \"Twist the dial to set it\"}\n      </p>\n    </div>\n  )\n}\n\nexport { KitchenTimer }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-kitchen-timer-ring": "kitchen-timer-ring 0.12s ease-in-out 8"
    }
  },
  "css": {
    "@keyframes kitchen-timer-ring": {
      "0%, 100%": {
        "transform": "rotate(0)"
      },
      "50%": {
        "transform": "rotate(6deg)"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "data-display",
    "interactive"
  ],
  "type": "registry:ui"
}