{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"time-picker","type":"registry:component","title":"Time picker","description":"Type “9:30 pm” or fling the hour, minute and AM/PM drums; both paths settle into one plain HH:mm value.","author":"Hairline UI","dependencies":[],"registryDependencies":["https://hairlineui.com/r/number-roll.json?as=dependency","https://hairlineui.com/r/text-morph.json?as=dependency","https://hairlineui.com/r/wheel-picker.json?as=dependency"],"files":[{"path":"registry/time-picker.tsx","type":"registry:component","content":"// Hairline UI · time-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Field, fieldSurface, useFieldIds, useShake } from \"./field\";\nimport { enterStyle, themeVars, useDismiss, useFloating, usePresence } from \"./floating\";\nimport { NumberRoll } from \"./number-roll\";\nimport { TextMorph } from \"./text-morph\";\nimport { Wheel, WheelPicker } from \"./wheel-picker\";\nimport { EASE_OUT, INTERACTION_FOCUS, INTERACTION_PRESS, useInteractionReducedMotion } from \"./ui-interaction-motion\";\n\nexport interface TimePickerProps {\n  value?: string | null;\n  defaultValue?: string | null;\n  onValueChange?: (value: string | null) => void;\n  hour12?: boolean;\n  minuteStep?: number;\n  min?: string;\n  max?: string;\n  label?: React.ReactNode;\n  hint?: React.ReactNode;\n  error?: React.ReactNode;\n  placeholder?: string;\n  disabled?: boolean;\n  name?: string;\n  id?: string;\n  className?: string;\n}\n\nconst MINUTES = 24 * 60;\nconst pad = (n: number) => String(n).padStart(2, \"0\");\nconst minutesOf = (time: string) => {\n  const [h, m] = time.split(\":\").map(Number);\n  return h * 60 + m;\n};\nconst timeOf = (minutes: number) => {\n  const wrapped = ((minutes % MINUTES) + MINUTES) % MINUTES;\n  return `${pad(Math.floor(wrapped / 60))}:${pad(wrapped % 60)}`;\n};\n\nexport function parseTime(input: string): string | null {\n  const text = input.trim().toLowerCase().replace(/\\s+/g, \"\").replace(\".\", \":\");\n  const match = text.match(/^(\\d{1,2})(?::?(\\d{2}))?(am|pm|a|p)?$/);\n  if (!match) return null;\n  let h = Number(match[1]);\n  const m = Number(match[2] ?? 0);\n  const period = match[3];\n  if (m > 59) return null;\n  if (period) {\n    if (h < 1 || h > 12) return null;\n    h = (h % 12) + (period.startsWith(\"p\") ? 12 : 0);\n  } else if (h > 23) return null;\n  return `${pad(h)}:${pad(m)}`;\n}\n\nfunction snapTime(time: string, step: number) {\n  return timeOf(Math.round(minutesOf(time) / step) * step);\n}\n\nfunction clampTime(time: string, min?: string, max?: string) {\n  const value = minutesOf(time);\n  if (min && value < minutesOf(min)) return min;\n  if (max && value > minutesOf(max)) return max;\n  return time;\n}\n\nfunction formatTime(time: string, hour12: boolean) {\n  const [h, m] = time.split(\":\").map(Number);\n  if (!hour12) return `${pad(h)}:${pad(m)}`;\n  return `${h % 12 || 12}:${pad(m)} ${h < 12 ? \"AM\" : \"PM\"}`;\n}\n\nfunction ClockIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" className=\"size-3.5\">\n      <circle cx=\"8\" cy=\"8\" r=\"5.75\" stroke=\"currentColor\" strokeWidth=\"1.35\" />\n      <path d=\"M8 4.75V8l2.25 1.5\" stroke=\"currentColor\" strokeWidth=\"1.35\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nexport function TimePicker({\n  value,\n  defaultValue = null,\n  onValueChange,\n  hour12 = false,\n  minuteStep = 5,\n  min,\n  max,\n  label,\n  hint,\n  error,\n  placeholder = \"Choose a time\",\n  disabled,\n  name,\n  id,\n  className = \"\",\n}: TimePickerProps) {\n  const reduced = useInteractionReducedMotion();\n  const ids = useFieldIds(id);\n  const [own, setOwn] = React.useState<string | null>(defaultValue);\n  const current = value !== undefined ? value : own;\n  const [open, setOpen] = React.useState(false);\n  const [draft, setDraft] = React.useState(\"\");\n  const [badInput, setBadInput] = React.useState(false);\n  const anchor = React.useRef<HTMLDivElement>(null);\n  const surface = React.useRef<HTMLDivElement>(null);\n  const trigger = React.useRef<HTMLButtonElement>(null);\n  const input = React.useRef<HTMLInputElement>(null);\n  const shakeRef = useShake<HTMLDivElement>(badInput);\n  const { mounted, shown } = usePresence(open, 180);\n  const place = useFloating({ open: mounted, anchor, floating: surface, side: \"bottom\", align: \"start\", offset: 6 });\n  const [vars, setVars] = React.useState<React.CSSProperties>({});\n  const step = Math.max(1, Math.min(60, Math.round(minuteStep)));\n  const selected = snapTime(parseTime(current ?? \"\") ?? \"09:00\", step);\n  const selectedHour = Number(selected.slice(0, 2));\n  const selectedMinute = Number(selected.slice(3));\n  const hourOptions = React.useMemo(() => Array.from({ length: hour12 ? 12 : 24 }, (_, i) => (hour12 ? i + 1 : i)), [hour12]);\n  const minuteOptions = React.useMemo(() => Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step).filter((n) => n < 60), [step]);\n  const periodOptions = React.useMemo(() => [\"AM\", \"PM\"] as const, []);\n  const shownText = current ? formatTime(current, hour12) : placeholder;\n\n  React.useLayoutEffect(() => {\n    if (mounted) setVars(themeVars(anchor.current));\n  }, [mounted]);\n\n  React.useEffect(() => {\n    if (!open) return;\n    input.current?.focus({ preventScroll: true });\n    input.current?.select();\n  }, [open]);\n\n  const commit = (next: string | null) => {\n    if (value === undefined) setOwn(next);\n    onValueChange?.(next);\n  };\n\n  const close = (refocus: boolean) => {\n    setOpen(false);\n    setBadInput(false);\n    if (refocus) trigger.current?.focus({ preventScroll: true });\n  };\n  useDismiss(open, (reason) => close(reason === \"escape\"), [anchor, surface]);\n\n  const openPanel = () => {\n    setDraft(current ?? \"\");\n    setBadInput(false);\n    setOpen(true);\n  };\n\n  const change = (next: string) => {\n    const snapped = clampTime(snapTime(next, step), min, max);\n    commit(snapped);\n    setDraft(snapped);\n    setBadInput(false);\n  };\n\n  const settle = (closeAfter: boolean) => {\n    if (!draft.trim()) {\n      commit(null);\n      if (closeAfter) close(true);\n      return true;\n    }\n    const parsed = parseTime(draft);\n    const next = parsed ? snapTime(parsed, step) : null;\n    if (!next || (min && minutesOf(next) < minutesOf(min)) || (max && minutesOf(next) > minutesOf(max))) {\n      setBadInput(true);\n      return false;\n    }\n    commit(next);\n    setDraft(next);\n    setBadInput(false);\n    if (closeAfter) close(true);\n    return true;\n  };\n\n  const changeHour = (hour: number) => {\n    const nextHour = hour12 ? (hour % 12) + (selectedHour >= 12 ? 12 : 0) : hour;\n    change(`${pad(nextHour)}:${pad(selectedMinute)}`);\n  };\n  const changePeriod = (period: \"AM\" | \"PM\") => {\n    const nextHour = (selectedHour % 12) + (period === \"PM\" ? 12 : 0);\n    change(`${pad(nextHour)}:${pad(selectedMinute)}`);\n  };\n\n  const describedBy = [hint && !error ? ids.hint : null, error ? ids.error : null].filter(Boolean).join(\" \") || undefined;\n\n  return (\n    <Field id={ids.id} label={label} hint={hint} error={error} className={className}>\n      <div ref={anchor}>\n        <button\n          ref={trigger}\n          id={ids.id}\n          type=\"button\"\n          disabled={disabled}\n          aria-haspopup=\"dialog\"\n          aria-expanded={open}\n          aria-describedby={describedBy}\n          onClick={() => (open ? close(false) : openPanel())}\n          className={`${fieldSurface({ invalid: !!error, disabled })} h-9 cursor-pointer gap-2.5 px-3 text-left text-[16px] sm:text-[13.5px] ${INTERACTION_FOCUS}`}\n        >\n          <span className=\"flex shrink-0 text-muted-foreground\"><ClockIcon /></span>\n          {/* The hours and minutes roll the way the time moved, like a clock; AM and PM morph. */}\n          <span className={`flex min-w-0 flex-1 items-baseline truncate tabular-nums ${current ? \"text-foreground\" : \"text-muted-foreground/70\"}`}>\n            {current ? (\n              <>\n                <span className=\"sr-only\">{shownText}</span>\n                <span aria-hidden=\"true\" className=\"inline-flex items-baseline\">\n                  <NumberRoll value={hour12 ? Number(current.slice(0, 2)) % 12 || 12 : Number(current.slice(0, 2))} format={{ minimumIntegerDigits: hour12 ? 1 : 2 }} />\n                  <span className=\"px-px\">:</span>\n                  <NumberRoll value={Number(current.slice(3, 5))} format={{ minimumIntegerDigits: 2 }} />\n                  {hour12 && (\n                    <span className=\"pl-1\">\n                      <TextMorph>{Number(current.slice(0, 2)) < 12 ? \"AM\" : \"PM\"}</TextMorph>\n                    </span>\n                  )}\n                </span>\n              </>\n            ) : (\n              <TextMorph animateWidth={false}>{shownText}</TextMorph>\n            )}\n          </span>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" className=\"size-3.5 shrink-0 text-muted-foreground transition-transform duration-300\" style={{ transform: open ? \"rotate(180deg)\" : \"none\" }}>\n            <path d=\"m4.5 6 3.5 3 3.5-3\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n          </svg>\n        </button>\n      </div>\n      {name && <input type=\"hidden\" name={name} value={current ?? \"\"} />}\n      {mounted &&\n        createPortal(\n          <div\n            ref={surface}\n            role=\"dialog\"\n            aria-label=\"Choose a time\"\n            className=\"fixed left-0 top-0 z-[55] w-[284px] max-w-[calc(100vw-16px)] rounded-[18px] bg-popover p-3 text-popover-foreground shadow-[0_0_0_1px_var(--border)]\"\n            style={{ ...vars, left: place.x, top: place.y, transformOrigin: place.origin, ...enterStyle(shown, place.side, reduced) }}\n          >\n            <div ref={shakeRef} className=\"flex h-8 items-center rounded-full bg-background shadow-[inset_0_0_0_1px_var(--border)] focus-within:shadow-[inset_0_0_0_1px_var(--ring),0_0_0_3px_color-mix(in_oklab,var(--ring)_16%,transparent)]\">\n              <input\n                ref={input}\n                value={draft}\n                placeholder={hour12 ? \"9:30 am\" : \"09:30\"}\n                inputMode=\"numeric\"\n                aria-label=\"Type a time\"\n                aria-invalid={badInput || undefined}\n                onChange={(e) => {\n                  setDraft(e.target.value);\n                  setBadInput(false);\n                }}\n                onBlur={(e) => {\n                  if (e.relatedTarget && !surface.current?.contains(e.relatedTarget as Node)) settle(false);\n                }}\n                onKeyDown={(e) => {\n                  if (e.key === \"Enter\") {\n                    e.preventDefault();\n                    settle(true);\n                  }\n                }}\n                className=\"h-full min-w-0 flex-1 bg-transparent px-3 text-[13px] tabular-nums outline-none placeholder:text-muted-foreground/60\"\n              />\n              <span className=\"pr-3 font-mono text-[10.5px] uppercase text-muted-foreground\">{hour12 ? \"12 hr\" : \"24 hr\"}</span>\n            </div>\n            <div className=\"grid\" style={{ gridTemplateRows: badInput ? \"1fr\" : \"0fr\", transition: reduced ? \"none\" : `grid-template-rows 280ms ${EASE_OUT}` }}>\n              <p className=\"min-h-0 overflow-hidden pt-1.5 text-[11.5px] text-red-600 dark:text-red-400\">\n                Enter a valid time{min || max ? ` ${min ? `from ${formatTime(min, hour12)}` : \"\"}${min && max ? \" \" : \"\"}${max ? `to ${formatTime(max, hour12)}` : \"\"}` : \"\"}.\n              </p>\n            </div>\n\n            <div className=\"mt-2 border-y border-border py-1\">\n              <WheelPicker itemHeight={32} aria-label=\"Time wheels\" className=\"px-0\">\n                <Wheel options={hourOptions} value={hour12 ? selectedHour % 12 || 12 : selectedHour} onValueChange={changeHour} label=\"Hours\" />\n                <span aria-hidden=\"true\" className=\"flex items-center pb-1 text-[18px] text-muted-foreground\">:</span>\n                <Wheel options={minuteOptions} value={selectedMinute} onValueChange={(minute) => change(`${pad(selectedHour)}:${pad(minute)}`)} label=\"Minutes\" loop />\n                {hour12 && <Wheel options={periodOptions} value={selectedHour < 12 ? \"AM\" : \"PM\"} onValueChange={changePeriod} label=\"AM or PM\" />}\n              </WheelPicker>\n            </div>\n\n            <div className=\"mt-2 flex items-center justify-between gap-1\">\n              <div className=\"flex\">\n                <button\n                  type=\"button\"\n                  onClick={() => {\n                    const now = new Date();\n                    change(`${pad(now.getHours())}:${pad(now.getMinutes())}`);\n                  }}\n                  className={`h-7 rounded-full px-2.5 text-[12px] font-medium text-foreground cursor-pointer hover:bg-accent ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n                >\n                  Now\n                </button>\n                {current && (\n                  <button\n                    type=\"button\"\n                    onClick={() => {\n                      commit(null);\n                      setDraft(\"\");\n                      close(true);\n                    }}\n                    className={`h-7 rounded-full px-2.5 text-[12px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n                  >\n                    Clear\n                  </button>\n                )}\n              </div>\n              <button type=\"button\" onClick={() => settle(true)} className={`h-7 rounded-full bg-primary px-3 text-[12px] font-medium text-primary-foreground cursor-pointer ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}>\n                Done\n              </button>\n            </div>\n          </div>,\n          document.body,\n        )}\n    </Field>\n  );\n}\n\nexport default TimePicker;\n"},{"path":"registry/field.tsx","type":"registry:component","content":"// Hairline UI · time-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\nimport { EASE_OUT, useInteractionReducedMotion } from \"./ui-interaction-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * FIELD: the column every text control sits in\n *\n *   label    above, with an optional aside on the right (a count)\n *   hint     under the control while all is well\n *   error    takes the hint's place: the hint folds away, the\n *            error rises in out of a blur, the control shakes once\n *\n * Shared by input, textarea, password, search and select so the\n * whole family has one surface, one focus ring and one error.\n * ───────────────────────────────────────────────────────── */\n\nexport interface FieldProps {\n  id: string;\n  label?: React.ReactNode;\n  /** Right side of the label row, e.g. a character count. */\n  aside?: React.ReactNode;\n  hint?: React.ReactNode;\n  error?: React.ReactNode;\n  required?: boolean;\n  className?: string;\n  children: React.ReactNode;\n}\n\nexport type FieldSize = \"sm\" | \"md\";\n\n/** The surface of a text control: a hairline that darkens on hover and turns to the ring on focus. */\nexport function fieldSurface({ invalid, disabled, round = true }: { invalid?: boolean; disabled?: boolean; round?: boolean }) {\n  const ring = invalid\n    ? \"shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-red-500)_55%,transparent)] focus-within:shadow-[inset_0_0_0_1px_var(--color-red-500),0_0_0_3px_color-mix(in_oklab,var(--color-red-500)_14%,transparent)]\"\n    : \"shadow-[inset_0_0_0_1px_var(--border)] [&:not(:focus-within)]:hover:shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--foreground)_24%,var(--border))] focus-within:shadow-[inset_0_0_0_1px_var(--ring),0_0_0_3px_color-mix(in_oklab,var(--ring)_16%,transparent)]\";\n  return `relative flex w-full items-center bg-background text-foreground transition-[box-shadow,background-color,opacity] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] ${round ? \"rounded-full\" : \"rounded-[14px]\"} ${ring} ${\n    disabled ? \"pointer-events-none opacity-50\" : \"\"\n  }`;\n}\n\n/** ids for the control's label, hint and error. */\nexport function useFieldIds(id?: string) {\n  const auto = React.useId();\n  const base = id ?? auto;\n  return { id: base, hint: `${base}-hint`, error: `${base}-error` };\n}\n\n/** One short shake whenever `on` turns true (an error arrives). */\nexport function useShake<T extends HTMLElement>(on: boolean) {\n  const ref = React.useRef<T>(null);\n  const reduced = useInteractionReducedMotion();\n  React.useEffect(() => {\n    if (!on || reduced) return;\n    ref.current?.animate(\n      [{ transform: \"none\" }, { transform: \"translateX(-4px)\" }, { transform: \"translateX(4px)\" }, { transform: \"translateX(-2px)\" }, { transform: \"none\" }],\n      { duration: 380, easing: \"ease-out\" },\n    );\n  }, [on, reduced]);\n  return ref;\n}\n\n/** Sets a native input's value so React's onChange still fires (clear buttons, pickers). */\nexport function setNativeValue(el: HTMLInputElement | HTMLTextAreaElement, value: string) {\n  const proto = el instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;\n  Object.getOwnPropertyDescriptor(proto, \"value\")?.set?.call(el, value);\n  el.dispatchEvent(new Event(\"input\", { bubbles: true }));\n}\n\n/** A line under the control that folds open and closed; keeps its last words while closing. */\nfunction Line({ show, children, id, tone, reduced }: { show: boolean; children: React.ReactNode; id: string; tone: string; reduced: boolean }) {\n  const [kept, setKept] = React.useState(children);\n  if (show && children !== kept) setKept(children);\n  return (\n    <div\n      className=\"grid\"\n      style={{ gridTemplateRows: show ? \"1fr\" : \"0fr\", transition: reduced ? \"none\" : `grid-template-rows 320ms ${EASE_OUT}` }}\n    >\n      <div className=\"min-h-0 overflow-hidden\">\n        <p\n          id={id}\n          className={`pt-1.5 pl-3 text-[12.5px] leading-snug ${tone}`}\n          style={{\n            opacity: show ? 1 : 0,\n            filter: show ? \"blur(0px)\" : \"blur(4px)\",\n            transform: show ? \"none\" : \"translateY(-4px)\",\n            transition: reduced ? \"none\" : show ? `opacity 280ms ${EASE_OUT} 60ms, filter 280ms ${EASE_OUT} 60ms, transform 380ms ${EASE_OUT}` : `opacity 140ms ${EASE_OUT}, filter 140ms ${EASE_OUT}, transform 200ms ${EASE_OUT}`,\n          }}\n        >\n          {show ? children : kept}\n        </p>\n      </div>\n    </div>\n  );\n}\n\nexport function Field({ id, label, aside, hint, error, required, className = \"\", children }: FieldProps) {\n  const reduced = useInteractionReducedMotion();\n  const ids = { hint: `${id}-hint`, error: `${id}-error` };\n  return (\n    <div className={`flex w-full flex-col ${className}`}>\n      {(label || aside) && (\n        <div className=\"flex items-baseline justify-between gap-3 px-3 pb-1.5\">\n          {label && (\n            <label htmlFor={id} className=\"text-[13px] font-medium text-foreground\">\n              {label}\n              {required && (\n                <span aria-hidden=\"true\" className=\"ml-0.5 text-muted-foreground\">\n                  *\n                </span>\n              )}\n            </label>\n          )}\n          {aside && <span className=\"text-[12px] tabular-nums text-muted-foreground\">{aside}</span>}\n        </div>\n      )}\n      {children}\n      <Line show={!error && !!hint} id={ids.hint} tone=\"text-muted-foreground\" reduced={reduced}>\n        {hint}\n      </Line>\n      <Line show={!!error} id={ids.error} tone=\"text-red-600 dark:text-red-400\" reduced={reduced}>\n        {error}\n      </Line>\n    </div>\n  );\n}\n\nexport default Field;\n"},{"path":"registry/floating.ts","type":"registry:component","content":"// Hairline UI · time-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * FLOATING: what every popover, menu and tooltip shares\n *\n *   place     beside an anchor on a side, lined up start, centre\n *             or end; flips to the other side when it doesn't fit\n *             and shifts to stay `padding` inside the viewport;\n *             follows scroll and resize\n *   presence  mounts on open, shows a frame later (so the entry\n *             transitions run), hides, then unmounts after `exit`\n *   dismiss   Escape and a press outside both close it\n *   theme     the portal carries the anchor's theme tokens, so a\n *             light specimen on a dark page stays light\n * ───────────────────────────────────────────────────────── */\n\nexport type Side = \"top\" | \"bottom\" | \"left\" | \"right\";\nexport type Align = \"start\" | \"center\" | \"end\";\n\nconst TOKENS = [\"--background\", \"--foreground\", \"--popover\", \"--popover-foreground\", \"--border\", \"--accent\", \"--accent-foreground\", \"--primary\", \"--primary-foreground\", \"--muted\", \"--muted-foreground\", \"--ring\", \"--card\"];\n\n/** The anchor's theme tokens as inline styles for something portalled out of its tree. */\nexport function themeVars(anchor: Element | null): React.CSSProperties {\n  if (!anchor) return {};\n  const style = getComputedStyle(anchor);\n  const vars: Record<string, string> = {};\n  for (const t of TOKENS) {\n    const v = style.getPropertyValue(t);\n    if (v) vars[t] = v;\n  }\n  return vars as React.CSSProperties;\n}\n\nconst OPPOSITE: Record<Side, Side> = { top: \"bottom\", bottom: \"top\", left: \"right\", right: \"left\" };\n\nexport interface Placement {\n  x: number;\n  y: number;\n  side: Side;\n  /** Where the surface grows from, for transform-origin. */\n  origin: string;\n  ready: boolean;\n}\n\n/** Positions `floating` (position: fixed) next to `anchor` while `open`. Pass a point instead of an anchor for context menus. */\nexport function useFloating({\n  open,\n  anchor,\n  point,\n  floating,\n  side = \"bottom\",\n  align = \"center\",\n  offset = 8,\n  padding = 8,\n}: {\n  open: boolean;\n  anchor?: React.RefObject<Element | null>;\n  point?: { x: number; y: number } | null;\n  floating: React.RefObject<HTMLElement | null>;\n  side?: Side;\n  align?: Align;\n  offset?: number;\n  padding?: number;\n}): Placement {\n  const [place, setPlace] = React.useState<Placement>({ x: -9999, y: -9999, side, origin: \"center\", ready: false });\n\n  React.useLayoutEffect(() => {\n    if (!open) return;\n    let frame = 0;\n    const measure = () => {\n      const el = floating.current;\n      if (!el) return;\n      const a = point\n        ? { left: point.x, right: point.x, top: point.y, bottom: point.y, width: 0, height: 0 }\n        : anchor?.current?.getBoundingClientRect();\n      if (!a) return;\n      const w = el.offsetWidth;\n      const h = el.offsetHeight;\n      const vw = window.innerWidth;\n      const vh = window.innerHeight;\n      const room: Record<Side, number> = { top: a.top - padding, bottom: vh - a.bottom - padding, left: a.left - padding, right: vw - a.right - padding };\n      const need = side === \"top\" || side === \"bottom\" ? h + offset : w + offset;\n      const s = room[side] < need && room[OPPOSITE[side]] > room[side] ? OPPOSITE[side] : side;\n      let x: number;\n      let y: number;\n      if (s === \"top\" || s === \"bottom\") {\n        y = s === \"bottom\" ? a.bottom + offset : a.top - offset - h;\n        x = align === \"start\" ? a.left : align === \"end\" ? a.right - w : a.left + a.width / 2 - w / 2;\n        if (point) x = a.left;\n      } else {\n        x = s === \"right\" ? a.right + offset : a.left - offset - w;\n        y = align === \"start\" ? a.top : align === \"end\" ? a.bottom - h : a.top + a.height / 2 - h / 2;\n      }\n      x = Math.max(padding, Math.min(vw - padding - w, x));\n      y = Math.max(padding, Math.min(vh - padding - h, y));\n      // Grow from the point on the anchor's edge nearest the surface.\n      const ox = s === \"left\" ? \"100%\" : s === \"right\" ? \"0%\" : `${Math.max(0, Math.min(w, a.left + a.width / 2 - x))}px`;\n      const oy = s === \"top\" ? \"100%\" : s === \"bottom\" ? \"0%\" : `${Math.max(0, Math.min(h, a.top + a.height / 2 - y))}px`;\n      const next = { x: Math.round(x), y: Math.round(y), side: s, origin: `${ox} ${oy}`, ready: true };\n      setPlace((p) => (p.x === next.x && p.y === next.y && p.side === next.side && p.origin === next.origin && p.ready ? p : next));\n    };\n    const schedule = () => {\n      cancelAnimationFrame(frame);\n      frame = requestAnimationFrame(measure);\n    };\n    measure();\n    const ro = new ResizeObserver(schedule);\n    if (floating.current) ro.observe(floating.current);\n    window.addEventListener(\"scroll\", schedule, { capture: true, passive: true });\n    window.addEventListener(\"resize\", schedule);\n    return () => {\n      cancelAnimationFrame(frame);\n      ro.disconnect();\n      window.removeEventListener(\"scroll\", schedule, { capture: true });\n      window.removeEventListener(\"resize\", schedule);\n    };\n  }, [open, anchor, point, floating, side, align, offset, padding]);\n\n  return open ? place : { ...place, ready: false };\n}\n\n/** Mount → show next frame → hide → unmount after `exit` ms. */\nexport function usePresence(open: boolean, exit = 160) {\n  const [mounted, setMounted] = React.useState(open);\n  const [shown, setShown] = React.useState(false);\n  if (open && !mounted) setMounted(true);\n  React.useEffect(() => {\n    if (open) {\n      let inner = 0;\n      const outer = requestAnimationFrame(() => {\n        inner = requestAnimationFrame(() => setShown(true));\n      });\n      return () => {\n        cancelAnimationFrame(outer);\n        cancelAnimationFrame(inner);\n      };\n    }\n    const timer = window.setTimeout(() => {\n      setMounted(false);\n      setShown(false);\n    }, exit);\n    return () => window.clearTimeout(timer);\n  }, [open, exit]);\n  return { mounted: mounted || open, shown: open && shown };\n}\n\n/** Escape and presses outside `refs` call onDismiss while `open`. */\nexport function useDismiss(open: boolean, onDismiss: (reason: \"escape\" | \"outside\") => void, refs: React.RefObject<Element | null>[]) {\n  const latest = React.useRef({ onDismiss, refs });\n  React.useEffect(() => {\n    latest.current = { onDismiss, refs };\n  });\n  React.useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return;\n      e.stopPropagation();\n      latest.current.onDismiss(\"escape\");\n    };\n    const onDown = (e: PointerEvent) => {\n      const target = e.target as Node;\n      if (latest.current.refs.some((r) => r.current?.contains(target))) return;\n      latest.current.onDismiss(\"outside\");\n    };\n    document.addEventListener(\"keydown\", onKey);\n    document.addEventListener(\"pointerdown\", onDown, true);\n    return () => {\n      document.removeEventListener(\"keydown\", onKey);\n      document.removeEventListener(\"pointerdown\", onDown, true);\n    };\n  }, [open]);\n}\n\n/** The entry pose for a surface on `side`: it comes 6px from the anchor, 0.96 and blurred. */\nexport function enterStyle(shown: boolean, side: Side, reduced: boolean, ease = \"cubic-bezier(0.16,1,0.3,1)\"): React.CSSProperties {\n  const d = 6;\n  const shift = side === \"top\" ? `0 ${d}px` : side === \"bottom\" ? `0 -${d}px` : side === \"left\" ? `${d}px 0` : `-${d}px 0`;\n  return {\n    opacity: shown ? 1 : 0,\n    translate: shown || reduced ? \"0 0\" : shift,\n    scale: shown || reduced ? \"1\" : \"0.96\",\n    filter: shown || reduced ? \"blur(0px)\" : \"blur(4px)\",\n    transition: reduced\n      ? \"opacity 120ms ease-out\"\n      : shown\n        ? `opacity 220ms ${ease}, translate 320ms ${ease}, scale 320ms ${ease}, filter 220ms ${ease}`\n        : `opacity 140ms ${ease}, translate 180ms ${ease}, scale 180ms ${ease}, filter 140ms ${ease}`,\n  };\n}\n"},{"path":"registry/ui-interaction-motion.ts","type":"registry:component","content":"// Hairline UI · time-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n'use client';\n\nimport * as React from 'react';\n\nexport const EASE_OUT = 'cubic-bezier(0.16, 1, 0.3, 1)';\nexport const EASE_SETTLE = 'cubic-bezier(0.22, 1.18, 0.36, 1)';\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = 'cubic-bezier(0.34, 1.36, 0.64, 1)';\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  'transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100';\nexport const INTERACTION_FOCUS ='focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\nconst query = '(prefers-reduced-motion: reduce)';\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener('change', notify);\n  return () => media.removeEventListener('change', notify);\n};\nexport const useInteractionReducedMotion = () => React.useSyncExternalStore(subscribe, () => window.matchMedia(query).matches, () => false);\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility(); document.addEventListener('visibilitychange', visibility);\n    return () => { observer.disconnect(); document.removeEventListener('visibilitychange', visibility); };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(on: boolean, reduced: boolean): React.CSSProperties {\n  return { opacity: on ? 1 : 0, transform: on ? 'none' : 'scale(0.6)', filter: on ? 'blur(0px)' : 'blur(3px)', transition: reduced ? 'none' : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}` };\n}\n\n/** A raised object: one tight contact shadow, one short ambient, a hairline of light on its top edge. */\nexport const MATERIAL_LIFT =\n  'shadow-[0_1px_1.5px_rgb(0_0_0/0.07),0_3px_8px_-2px_rgb(0_0_0/0.1),inset_0_0.5px_0_rgb(255_255_255/0.8)] dark:shadow-[0_1px_2px_rgb(0_0_0/0.5),0_4px_10px_-2px_rgb(0_0_0/0.35),inset_0_0.5px_0_rgb(255_255_255/0.1)]';\n/** A trough something sits in, shaded from above, lit along its bottom edge. */\nexport const MATERIAL_RECESS =\n  'shadow-[inset_0_1px_2.5px_rgb(0_0_0/0.09),inset_0_-0.5px_0_rgb(255_255_255/0.7)] dark:shadow-[inset_0_1px_3px_rgb(0_0_0/0.45),inset_0_-0.5px_0_rgb(255_255_255/0.07)]';\n\nexport type SpringConfig = { stiffness: number; damping: number; mass?: number };\nexport interface Spring {\n  get(): number;\n  getVelocity(): number;\n  getTarget(): number;\n  /** Aim somewhere new from wherever it is now, keeping its speed. */\n  set(target: number): void;\n  /** Add speed (units per second), on top of what it already has. */\n  push(velocity: number): void;\n  /** Be there now, at rest. */\n  jump(value: number): void;\n  configure(config: SpringConfig): void;\n  stop(): void;\n}\n\n// Every moving spring on the page shares one frame loop, which sleeps when the last one rests. Each spring's onFrame runs\n// once per frame after all of them have stepped, so several springs that draw one shape paint it once.\nconst SPRING_STEP = 1 / 240;\ntype Running = { step: () => void };\nconst runningSprings = new Set<Running>();\nconst springPainters = new Set<() => void>();\nlet springFrame = 0;\nlet springLast = 0;\nlet springSpare = 0;\n\nfunction springTick(now: number) {\n  // A hidden tab stops the frames, so the first one back must not count the whole gap as time passed.\n  springSpare += Math.min((now - springLast) / 1000, 0.05);\n  springLast = now;\n  while (springSpare >= SPRING_STEP) {\n    runningSprings.forEach((spring) => spring.step());\n    springSpare -= SPRING_STEP;\n  }\n  const painters = [...springPainters];\n  springPainters.clear();\n  painters.forEach((paint) => paint());\n  springFrame = runningSprings.size ? requestAnimationFrame(springTick) : 0;\n}\n\nfunction wakeSprings(spring: Running) {\n  runningSprings.add(spring);\n  if (springFrame) return;\n  springSpare = 0;\n  springFrame = requestAnimationFrame((now) => {\n    springLast = now - 1000 / 60;\n    springTick(now);\n  });\n}\n\n/**\n * A spring that carries its speed: re-aim it mid-flight and it curves on from where it is, push it while it swings and the\n * push adds to the swing. Use it for anything that can be interrupted; a curve restarts from a standstill every time.\n * `onFrame` should write straight to the DOM. `precision` is how close counts as there, in the value's own units.\n */\nexport function createSpring(initial: number, config: SpringConfig, onFrame: () => void, precision = 0.01): Spring {\n  let value = initial;\n  let velocity = 0;\n  let target = initial;\n  let { stiffness, damping, mass = 1 } = config;\n  const running: Running = {\n    step() {\n      velocity += ((-stiffness * (value - target) - damping * velocity) / mass) * SPRING_STEP;\n      value += velocity * SPRING_STEP;\n      if (Math.abs(value - target) < precision && Math.abs(velocity) < precision * 10) {\n        value = target;\n        velocity = 0;\n        runningSprings.delete(running);\n      }\n      springPainters.add(onFrame);\n    },\n  };\n  return {\n    get: () => value,\n    getVelocity: () => velocity,\n    getTarget: () => target,\n    set(next) {\n      if (next === target && !runningSprings.has(running)) return;\n      target = next;\n      wakeSprings(running);\n    },\n    push(speed) {\n      velocity += speed;\n      wakeSprings(running);\n    },\n    jump(next) {\n      value = next;\n      target = next;\n      velocity = 0;\n      runningSprings.delete(running);\n      onFrame();\n    },\n    configure(next) {\n      ({ stiffness, damping, mass = 1 } = next);\n    },\n    stop() {\n      runningSprings.delete(running);\n    },\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(samples: PointerSample[], x: number, time: number) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100) return 0;\n  const first = samples[0], last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(overshoot: number, dimension = 320, constant = 0.55): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(distance: number, velocity: number, time = 0.12): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(velocity: number, distanceToTarget: number, factor = 10): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient = (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value = to + Math.exp(-damping * omega * t) * (displacement * Math.cos(damped * t) + coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n\n"},{"path":"registry/use-wheel-drum.ts","type":"registry:component","content":"// Hairline UI · time-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n'use client';\n\nimport * as React from 'react';\n\n/*\n * One wheel's motion engine. The options sit on a ring of SLOTS faces round a cylinder; turning\n * the wheel is one rotateX on the drum (and the same on its copy in the lens), so a fling costs two\n * transforms a frame. Only faces turning round the back are relabelled, so a wheel of 60 minutes or\n * 200 years still has 18 faces. Nothing renders through React while it turns: the value is committed\n * once the wheel comes to rest.\n *\n *   drag     follows the finger one row per row height; past the ends of a wheel that doesn't\n *            loop it stretches with resistance\n *   fling    release velocity is projected forward and rounded to a row, then the wheel decays\n *            onto it exponentially, so it lands without a separate snap\n *   wheel    a mouse notch moves one row; trackpad scrolling turns it freely and settles when quiet\n *   tap      a row above or below the lens turns to the middle\n */\n\nexport const SLOTS = 18;\nexport const STEP = 360 / SLOTS;\n\nexport type DrumOptions = {\n  count: number;\n  loop: boolean;\n  itemHeight: number;\n  reduced: boolean;\n  haptics: boolean;\n  label: (index: number) => string;\n  disabled: (index: number) => boolean;\n  /** The wheel came to rest on this option. */\n  onRest: (index: number) => void;\n};\n\nconst mod = (n: number, m: number) => ((n % m) + m) % m;\nconst rubber = (x: number) => (1 - 1 / (x * 0.6 + 1)) / 0.6;\n\nexport function useWheelDrum(initial: number, options: DrumOptions) {\n  const opts = React.useRef(options);\n  React.useLayoutEffect(() => {\n    opts.current = options;\n  });\n  const column = React.useRef<HTMLDivElement>(null);\n  const drum = React.useRef<HTMLDivElement>(null);\n  const lens = React.useRef<HTMLDivElement>(null);\n  const faces = React.useRef<(HTMLElement | null)[]>([]);\n  const lensFaces = React.useRef<(HTMLElement | null)[]>([]);\n  const shown = React.useRef<number[]>([]);\n  const sim = React.useRef({ p: initial, from: initial, target: initial, tau: 0.3, t0: 0, settling: false, spring: false, rested: initial, tick: Math.round(initial), buzz: 0, touch: false });\n  const frame = React.useRef(0);\n\n  const radius = options.itemHeight / (2 * Math.tan((STEP / 2) * (Math.PI / 180)));\n\n  /** Write the drum's rotation and relabel the faces that crossed the back. */\n  const paint = React.useCallback((force = false) => {\n    const { count, loop, label, disabled, haptics } = opts.current;\n    const s = sim.current;\n    const r = opts.current.itemHeight / (2 * Math.tan((STEP / 2) * (Math.PI / 180)));\n    const transform = `translateZ(${-r}px) rotateX(${s.p * STEP}deg)`;\n    if (drum.current) drum.current.style.transform = transform;\n    if (lens.current) lens.current.style.transform = transform;\n    for (let k = 0; k < SLOTS; k++) {\n      const i = k + SLOTS * Math.round((s.p - k) / SLOTS);\n      if (!force && shown.current[k] === i) continue;\n      shown.current[k] = i;\n      const real = loop ? mod(i, count) : i;\n      const empty = !loop && (i < 0 || i >= count);\n      const text = empty || !count ? '' : label(real);\n      const off = !empty && count > 0 && disabled(real);\n      for (const el of [faces.current[k], lensFaces.current[k]]) {\n        if (!el) continue;\n        if (el.textContent !== text) el.textContent = text;\n        el.toggleAttribute('data-off', off);\n      }\n    }\n    // A tick under the finger for every row that passes the lens (phones that support it).\n    const row = Math.round(s.p);\n    if (row !== s.tick) {\n      s.tick = row;\n      const now = performance.now();\n      if (haptics && s.touch && now - s.buzz > 45 && typeof navigator !== 'undefined' && 'vibrate' in navigator) {\n        s.buzz = now;\n        try { navigator.vibrate(3); } catch { /* not allowed yet */ }\n      }\n    }\n  }, []);\n\n  const rest = React.useCallback(() => {\n    const { count, loop, disabled, onRest } = opts.current;\n    const s = sim.current;\n    s.settling = false;\n    if (!count) return;\n    const index = loop ? mod(Math.round(s.p), count) : Math.max(0, Math.min(count - 1, Math.round(s.p)));\n    // Landed on an option that can't be chosen: turn on to the nearest one that can.\n    if (disabled(index)) {\n      for (let d = 1; d < count; d++) {\n        const down = index - d, up = index + d;\n        const ok = (i: number) => (loop || (i >= 0 && i < count)) && !disabled(mod(i, count));\n        const next = ok(down) ? down : ok(up) ? up : null;\n        if (next !== null) {\n          settleTo(Math.round(s.p) + (next - index), 0.16);\n          return;\n        }\n      }\n      return;\n    }\n    s.rested = index;\n    onRest(index);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  const step = React.useCallback(function runStep(now: number) {\n    frame.current = 0;\n    const s = sim.current;\n    if (!s.settling) return;\n    const t = (now - s.t0) / 1000;\n    let k: number;\n    if (s.spring) {\n      // Harmonic spring for overdrag boundaries (omega = 16, zeta = 0.74)\n      const omega = 16, zeta = 0.74, damped = 10.76;\n      k = Math.exp(-zeta * omega * t) * (Math.cos(damped * t) + (zeta / 0.6726) * Math.sin(damped * t));\n      if (t > 0.44 || Math.abs(s.p - s.target) < 0.002) {\n        s.p = s.target;\n        paint();\n        rest();\n        return;\n      }\n    } else {\n      k = Math.exp(-t / s.tau);\n      if (Math.abs(s.p - s.target) < 0.002) {\n        s.p = s.target;\n        paint();\n        rest();\n        return;\n      }\n    }\n    s.p = s.target + (s.from - s.target) * k;\n    paint();\n    frame.current = requestAnimationFrame(runStep);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [paint]);\n\n  function settleTo(target: number, tau: number, spring = false) {\n    const s = sim.current;\n    s.from = s.p;\n    s.target = target;\n    s.tau = tau;\n    s.spring = spring;\n    s.t0 = performance.now();\n    s.settling = true;\n    if (opts.current.reduced) {\n      s.p = target;\n      paint();\n      rest();\n      return;\n    }\n    cancelAnimationFrame(frame.current);\n    frame.current = requestAnimationFrame(step);\n  }\n\n  const clampTarget = (target: number) => {\n    const { count, loop } = opts.current;\n    return loop ? target : Math.max(0, Math.min(count - 1, target));\n  };\n\n  /** Turn to an option. Loops take the shorter way round. */\n  const turnTo = React.useCallback((index: number, animate = true) => {\n    const { count, loop } = opts.current;\n    const s = sim.current;\n    if (!count) return;\n    let target = index;\n    if (loop) {\n      const base = Math.round(s.settling ? s.target : s.p);\n      const delta = mod(index - mod(base, count) + count / 2, count) - count / 2;\n      target = base + Math.round(delta);\n    }\n    s.rested = mod(index, count);\n    if (!animate) {\n      cancelAnimationFrame(frame.current);\n      frame.current = 0;\n      s.settling = false;\n      s.p = s.target = target;\n      paint();\n      return;\n    }\n    settleTo(target, 0.16);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [paint]);\n\n  /** Move by whole rows from wherever the wheel is heading (keys, mouse notches). */\n  const nudge = React.useCallback((rows: number) => {\n    const s = sim.current;\n    s.touch = false;\n    const base = s.settling ? s.target : Math.round(s.p);\n    settleTo(clampTarget(base + rows), 0.11);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  // Pointer, wheel and the initial paint.\n  React.useEffect(() => {\n    const el = column.current;\n    if (!el) return;\n    paint(true);\n    let drag: { id: number; y: number; p: number; moved: boolean; samples: { y: number; t: number }[] } | null = null;\n    let quiet: ReturnType<typeof setTimeout> | null = null;\n    const s = sim.current;\n    const H = () => opts.current.itemHeight;\n\n    const down = (e: PointerEvent) => {\n      if (e.button !== 0 || drag) return;\n      el.setPointerCapture(e.pointerId);\n      cancelAnimationFrame(frame.current);\n      frame.current = 0;\n      s.settling = false;\n      s.touch = e.pointerType === 'touch';\n      drag = { id: e.pointerId, y: e.clientY, p: s.p, moved: false, samples: [{ y: e.clientY, t: e.timeStamp }] };\n    };\n    const move = (e: PointerEvent) => {\n      if (!drag || e.pointerId !== drag.id) return;\n      const dy = e.clientY - drag.y;\n      if (!drag.moved) {\n        if (Math.abs(dy) < 3) return;\n        drag.moved = true;\n        drag.y = e.clientY;\n      }\n      drag.samples.push({ y: e.clientY, t: e.timeStamp });\n      while (drag.samples.length > 2 && e.timeStamp - drag.samples[0].t > 90) drag.samples.shift();\n      const { count, loop } = opts.current;\n      let p = drag.p - (e.clientY - drag.y) / H();\n      if (!loop) {\n        if (p < 0) p = -rubber(-p);\n        else if (p > count - 1) p = count - 1 + rubber(p - (count - 1));\n      }\n      s.p = p;\n      paint();\n    };\n    const up = (e: PointerEvent) => {\n      if (!drag || e.pointerId !== drag.id) return;\n      const d = drag;\n      drag = null;\n      if (!d.moved) {\n        // A tap above or below the lens turns that row to the middle.\n        const r = el.getBoundingClientRect();\n        const r0 = opts.current.itemHeight / (2 * Math.tan((STEP / 2) * (Math.PI / 180)));\n        const off = (Math.asin(Math.max(-1, Math.min(1, (e.clientY - (r.top + r.height / 2)) / r0))) * 180) / Math.PI / STEP;\n        const rows = Math.round(off);\n        if (rows) settleTo(clampTarget(Math.round(s.p) + rows), 0.16);\n        else settleTo(clampTarget(Math.round(s.p)), 0.12);\n        return;\n      }\n      const first = d.samples[0], last = d.samples[d.samples.length - 1];\n      const fresh = e.timeStamp - last.t < 80 && last.t > first.t;\n      const velocity = fresh ? -((last.y - first.y) / (last.t - first.t)) * (1000 / H()) : 0; // rows per second\n      const { count, loop } = opts.current;\n      const outside = !loop && (s.p < 0 || s.p > count - 1);\n      const projected = outside ? s.p : s.p + velocity * 0.3;\n      const target = clampTarget(Math.round(projected));\n      settleTo(target, outside ? 0.38 : Math.abs(target - s.p) < 0.75 ? 0.12 : 0.3, outside);\n    };\n    const wheel = (e: WheelEvent) => {\n      e.preventDefault();\n      s.touch = false;\n      const px = e.deltaMode === 1 ? e.deltaY * H() : e.deltaMode === 2 ? e.deltaY * H() * 5 : e.deltaY;\n      // A mouse wheel notch is one row; a trackpad turns the wheel freely and settles once it goes quiet.\n      if (Math.abs(px) >= 50 && Number.isInteger(e.deltaY)) {\n        nudge(Math.sign(px));\n        return;\n      }\n      cancelAnimationFrame(frame.current);\n      frame.current = 0;\n      s.settling = false;\n      const { count, loop } = opts.current;\n      let p = s.p + px / H();\n      if (!loop) p = Math.max(-0.35, Math.min(count - 1 + 0.35, p));\n      s.p = p;\n      paint();\n      if (quiet) clearTimeout(quiet);\n      quiet = setTimeout(() => settleTo(clampTarget(Math.round(s.p)), 0.14), 120);\n    };\n    el.addEventListener('pointerdown', down);\n    el.addEventListener('pointermove', move);\n    el.addEventListener('pointerup', up);\n    el.addEventListener('pointercancel', up);\n    el.addEventListener('wheel', wheel, { passive: false });\n    return () => {\n      if (quiet) clearTimeout(quiet);\n      cancelAnimationFrame(frame.current);\n      frame.current = 0;\n      el.removeEventListener('pointerdown', down);\n      el.removeEventListener('pointermove', move);\n      el.removeEventListener('pointerup', up);\n      el.removeEventListener('pointercancel', up);\n      el.removeEventListener('wheel', wheel);\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  // Options changed (a month with fewer days): relabel every face.\n  const signature = `${options.count}|${options.loop}`;\n  React.useEffect(() => {\n    paint(true);\n  }, [signature, paint]);\n\n  const attachColumn = React.useCallback((el: HTMLDivElement | null) => { column.current = el; }, []);\n  const attachDrum = React.useCallback((el: HTMLDivElement | null) => { drum.current = el; }, []);\n  const attachLens = React.useCallback((el: HTMLDivElement | null) => { lens.current = el; }, []);\n  const attachFace = React.useCallback((k: number, el: HTMLElement | null) => { faces.current[k] = el; }, []);\n  const attachLensFace = React.useCallback((k: number, el: HTMLElement | null) => { lensFaces.current[k] = el; }, []);\n\n  return { column, drum, lens, faces, lensFaces, attachColumn, attachDrum, attachLens, attachFace, attachLensFace, radius, turnTo, nudge, repaint: () => paint(true), resting: () => sim.current.rested, moving: () => sim.current.settling };\n}\n"}],"css":{},"docs":"Docs and live preview: https://hairlineui.com/ui/time-picker. MIT licensed: https://hairlineui.com/license#components","meta":{"license":"MIT"}}