{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"availability-scheduler","type":"registry:block","title":"Availability Scheduler","description":"Weekly availability editor where each day springs between available and unavailable, time ranges add and remove with blur-slide motion, times pick from a scrollable dropdown, and a copy menu clones hours to other days.","author":"Saurabh <saurabh10102@gmail.com>","dependencies":["clsx","lucide-react","motion","tailwind-merge"],"registryDependencies":[],"files":[{"path":"components/motion/availability-scheduler/index.tsx","type":"registry:component","target":"@components/motion/availability-scheduler/index.tsx","content":"\"use client\";\n// beui.dev/components/blocks/availability-scheduler\n\nimport { LayoutGroup, useReducedMotion } from \"motion/react\";\nimport { useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { DayRow } from \"./day-row\";\nimport {\n  type DayAvailability,\n  type DayKey,\n  WEEKDAYS,\n  type WeekAvailability,\n  buildOptions,\n  defaultWeek,\n} from \"./types\";\n\nexport type {\n  DayAvailability,\n  DayKey,\n  TimeRange,\n  WeekAvailability,\n} from \"./types\";\nexport { defaultWeek } from \"./types\";\n\nexport interface AvailabilitySchedulerProps {\n  value?: WeekAvailability;\n  defaultValue?: WeekAvailability;\n  onChange?: (value: WeekAvailability) => void;\n  /** Minutes between selectable times. Default 30. */\n  step?: number;\n  className?: string;\n}\n\nexport function AvailabilityScheduler({\n  value,\n  defaultValue,\n  onChange,\n  step = 30,\n  className,\n}: AvailabilitySchedulerProps) {\n  const reduce = useReducedMotion() ?? false;\n  const groupId = useId();\n  const options = useMemo(() => buildOptions(step), [step]);\n  const idRef = useRef(0);\n\n  const [internal, setInternal] = useState<WeekAvailability>(\n    () => defaultValue ?? defaultWeek(),\n  );\n  const controlled = value !== undefined;\n  const week = controlled ? value : internal;\n\n  const commit = useCallback(\n    (next: WeekAvailability) => {\n      if (!controlled) setInternal(next);\n      onChange?.(next);\n    },\n    [controlled, onChange],\n  );\n\n  const setDay = useCallback(\n    (day: DayKey, next: DayAvailability) => {\n      commit({ ...week, [day]: next });\n    },\n    [commit, week],\n  );\n\n  const copyDay = useCallback(\n    (from: DayKey, targets: DayKey[]) => {\n      const source = week[from];\n      const next = { ...week };\n      for (const t of targets) {\n        next[t] = {\n          enabled: source.enabled,\n          ranges: source.ranges.map((r) => ({\n            ...r,\n            id: `${t}-c${idRef.current++}`,\n          })),\n        };\n      }\n      commit(next);\n    },\n    [commit, week],\n  );\n\n  return (\n    <LayoutGroup id={groupId}>\n      <div className={cn(\"w-full max-w-xl divide-y divide-border\", className)}>\n        {WEEKDAYS.map(({ key, label }, i) => (\n          <DayRow\n            key={key}\n            day={key}\n            label={label}\n            state={week[key]}\n            options={options}\n            reduce={reduce}\n            depth={WEEKDAYS.length - i}\n            onChange={(next) => setDay(key, next)}\n            onCopy={(targets) => copyDay(key, targets)}\n          />\n        ))}\n      </div>\n    </LayoutGroup>\n  );\n}\n"},{"path":"components/motion/availability-scheduler/day-row.tsx","type":"registry:component","target":"@components/motion/availability-scheduler/day-row.tsx","content":"\"use client\";\n\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { Plus, X } from \"lucide-react\";\nimport { useRef } from \"react\";\nimport { Switch } from \"@/components/motion/switch\";\nimport { Tooltip } from \"@/components/motion/tooltip\";\nimport { SPRING_LAYOUT } from \"@/lib/ease\";\nimport { CopyMenu } from \"./copy-menu\";\nimport { IconButton } from \"./icon-button\";\nimport { TimeSelect } from \"./time-select\";\nimport {\n  type DayAvailability,\n  type DayKey,\n  type TimeOption,\n  type TimeRange,\n  toMinutes,\n  toValue,\n} from \"./types\";\n\nexport function DayRow({\n  day,\n  label,\n  state,\n  options,\n  reduce,\n  depth,\n  onChange,\n  onCopy,\n}: {\n  day: DayKey;\n  label: string;\n  state: DayAvailability;\n  options: TimeOption[];\n  reduce: boolean;\n  // Higher = painted above later rows, so a downward-opening panel always sits\n  // over the rows below it — during both open and close animations.\n  depth: number;\n  onChange: (next: DayAvailability) => void;\n  onCopy: (targets: DayKey[]) => void;\n}) {\n  const idRef = useRef(0);\n  const nextId = () => `${day}-n${idRef.current++}`;\n\n  const setEnabled = (enabled: boolean) => {\n    if (enabled && state.ranges.length === 0) {\n      onChange({\n        enabled,\n        ranges: [{ id: nextId(), start: \"09:00\", end: \"17:00\" }],\n      });\n    } else {\n      onChange({ ...state, enabled });\n    }\n  };\n\n  const updateRange = (id: string, patch: Partial<TimeRange>) => {\n    onChange({\n      ...state,\n      ranges: state.ranges.map((r) => (r.id === id ? { ...r, ...patch } : r)),\n    });\n  };\n\n  const addRange = () => {\n    const last = state.ranges[state.ranges.length - 1];\n    const start = last ? Math.min(toMinutes(last.end) + 60, 24 * 60 - 60) : 540;\n    onChange({\n      enabled: true,\n      ranges: [\n        ...state.ranges,\n        { id: nextId(), start: toValue(start), end: toValue(start + 60) },\n      ],\n    });\n  };\n\n  const removeRange = (id: string) => {\n    const ranges = state.ranges.filter((r) => r.id !== id);\n    // Removing the last slot marks the day unavailable.\n    onChange({ enabled: ranges.length > 0, ranges });\n  };\n\n  const actions = (\n    <>\n      <Tooltip content=\"Add time\">\n        <IconButton\n          label={`Add time range to ${label}`}\n          reduce={reduce}\n          onClick={addRange}\n        >\n          <Plus className=\"h-4 w-4\" />\n        </IconButton>\n      </Tooltip>\n      <CopyMenu fromLabel={label} reduce={reduce} onApply={onCopy} />\n    </>\n  );\n\n  return (\n    <motion.div\n      layout={reduce ? false : \"position\"}\n      transition={SPRING_LAYOUT}\n      style={{ zIndex: depth }}\n      className=\"relative flex flex-col gap-3 py-4 sm:flex-row sm:items-start sm:gap-4\"\n    >\n      {/* toggle + label; actions ride along on mobile */}\n      <div className=\"flex items-center justify-between sm:w-36 sm:shrink-0 sm:justify-start sm:pt-1\">\n        <div className=\"flex items-center gap-2.5\">\n          <Switch\n            checked={state.enabled}\n            onCheckedChange={setEnabled}\n            className=\"scale-90\"\n          />\n          <span className=\"text-sm font-medium text-foreground\">{label}</span>\n        </div>\n        <div className=\"flex items-center gap-1 sm:hidden\">{actions}</div>\n      </div>\n\n      {/* ranges or unavailable */}\n      <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n        <AnimatePresence initial={false} mode=\"popLayout\">\n          {state.enabled ? (\n            state.ranges.map((r, i) => (\n              <motion.div\n                key={r.id}\n                layout={reduce ? false : \"position\"}\n                style={{ zIndex: state.ranges.length - i }}\n                initial={\n                  reduce\n                    ? { opacity: 0 }\n                    : { opacity: 0, y: -6, filter: \"blur(4px)\" }\n                }\n                animate={\n                  reduce\n                    ? { opacity: 1 }\n                    : { opacity: 1, y: 0, filter: \"blur(0px)\" }\n                }\n                exit={\n                  reduce\n                    ? { opacity: 0 }\n                    : { opacity: 0, y: -4, filter: \"blur(4px)\" }\n                }\n                transition={SPRING_LAYOUT}\n                className=\"relative flex items-center gap-2\"\n              >\n                <div className=\"min-w-0 flex-1 sm:max-w-[132px]\">\n                  <TimeSelect\n                    value={r.start}\n                    options={options}\n                    onChange={(v) => updateRange(r.id, { start: v })}\n                  />\n                </div>\n                <span className=\"text-muted-foreground\">–</span>\n                <div className=\"min-w-0 flex-1 sm:max-w-[132px]\">\n                  <TimeSelect\n                    value={r.end}\n                    options={options}\n                    onChange={(v) => updateRange(r.id, { end: v })}\n                  />\n                </div>\n                <Tooltip content=\"Remove\">\n                  <IconButton\n                    label=\"Remove time range\"\n                    reduce={reduce}\n                    onClick={() => removeRange(r.id)}\n                  >\n                    <X className=\"h-4 w-4\" />\n                  </IconButton>\n                </Tooltip>\n              </motion.div>\n            ))\n          ) : (\n            <motion.span\n              key=\"unavailable\"\n              layout={reduce ? false : \"position\"}\n              initial={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n              animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0 }}\n              exit={reduce ? { opacity: 0 } : { opacity: 0, y: -4 }}\n              transition={SPRING_LAYOUT}\n              className=\"py-1 text-sm text-muted-foreground sm:py-2\"\n            >\n              Unavailable\n            </motion.span>\n          )}\n        </AnimatePresence>\n      </div>\n\n      {/* actions (desktop) */}\n      <div className=\"hidden shrink-0 items-center gap-1 pt-0.5 sm:flex\">\n        {actions}\n      </div>\n    </motion.div>\n  );\n}\n"},{"path":"components/motion/availability-scheduler/types.ts","type":"registry:component","target":"@components/motion/availability-scheduler/types.ts","content":"export type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n  { key: \"mon\", label: \"Monday\" },\n  { key: \"tue\", label: \"Tuesday\" },\n  { key: \"wed\", label: \"Wednesday\" },\n  { key: \"thu\", label: \"Thursday\" },\n  { key: \"fri\", label: \"Friday\" },\n  { key: \"sat\", label: \"Saturday\" },\n  { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n  const [h, m] = v.split(\":\").map(Number);\n  return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n  const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n  const h = Math.floor(clamped / 60);\n  const m = clamped % 60;\n  return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\nexport const label12 = (v: string) => {\n  const [h, m] = v.split(\":\").map(Number);\n  const ap = h < 12 ? \"AM\" : \"PM\";\n  const h12 = h % 12 === 0 ? 12 : h % 12;\n  return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\nexport function buildOptions(step: number): TimeOption[] {\n  const out: TimeOption[] = [];\n  for (let m = 0; m < 24 * 60; m += step) {\n    const value = toValue(m);\n    out.push({ value, label: label12(value) });\n  }\n  return out;\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n  const workday = (day: DayKey): DayAvailability => ({\n    enabled: true,\n    ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n  });\n  const off = (day: DayKey): DayAvailability => ({\n    enabled: false,\n    ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n  });\n  return {\n    mon: workday(\"mon\"),\n    tue: workday(\"tue\"),\n    wed: workday(\"wed\"),\n    thu: workday(\"thu\"),\n    fri: workday(\"fri\"),\n    sat: off(\"sat\"),\n    sun: off(\"sun\"),\n  };\n}\n"},{"path":"lib/utils.ts","type":"registry:lib","target":"@lib/utils.ts","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"components/motion/availability-scheduler/copy-menu.tsx","type":"registry:component","target":"@components/motion/availability-scheduler/copy-menu.tsx","content":"\"use client\";\n\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { Checkbox } from \"@/components/motion/checkbox\";\nimport {\n  MorphPopover,\n  MorphPopoverContent,\n} from \"@/components/motion/popover-morph\";\nimport { Tooltip } from \"@/components/motion/tooltip\";\nimport { SPRING_PRESS } from \"@/lib/ease\";\nimport { IconButton } from \"./icon-button\";\nimport { type DayKey, WEEKDAYS } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n  fromLabel,\n  reduce,\n  onApply,\n}: {\n  fromLabel: string;\n  reduce: boolean;\n  onApply: (targets: DayKey[]) => void;\n}) {\n  const [open, setOpen] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n  const others = WEEKDAYS.filter((d) => d.label !== fromLabel);\n\n  const toggle = (k: DayKey) =>\n    setPicked((prev) => {\n      const next = new Set(prev);\n      if (next.has(k)) next.delete(k);\n      else next.add(k);\n      return next;\n    });\n\n  const apply = (targets: DayKey[]) => {\n    if (!targets.length) return;\n    onApply(targets);\n    setOpen(false);\n    setPicked(new Set());\n    setCopied(true);\n    window.setTimeout(() => setCopied(false), 1200);\n  };\n\n  return (\n    <MorphPopover open={open} onOpenChange={setOpen}>\n      <Tooltip content=\"Copy times\">\n        <IconButton\n          label={`Copy ${fromLabel} hours to other days`}\n          reduce={reduce}\n          expanded={open}\n          onClick={() => setOpen(!open)}\n        >\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            {copied ? (\n              <motion.span\n                key=\"done\"\n                initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n                animate={{ opacity: 1, scale: 1 }}\n                exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n                transition={SPRING_PRESS}\n                className=\"text-foreground\"\n              >\n                <Check className=\"h-4 w-4\" />\n              </motion.span>\n            ) : (\n              <motion.span\n                key=\"copy\"\n                initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n                animate={{ opacity: 1, scale: 1 }}\n                exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n                transition={SPRING_PRESS}\n              >\n                <Copy className=\"h-4 w-4\" />\n              </motion.span>\n            )}\n          </AnimatePresence>\n        </IconButton>\n      </Tooltip>\n\n      <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n        <p className=\"px-2 py-1.5 text-xs font-medium text-muted-foreground\">\n          Copy times to\n        </p>\n        <div className=\"flex flex-col\">\n          {others.map((d) => (\n            <Checkbox\n              key={d.key}\n              checked={picked.has(d.key)}\n              onCheckedChange={() => toggle(d.key)}\n              label={d.label}\n              className=\"w-full flex-row-reverse justify-between rounded-lg px-2 py-1.5 transition-colors hover:bg-muted [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border [&_button[data-state=unchecked]]:border-border-strong\"\n            />\n          ))}\n        </div>\n        <div className=\"mt-1 flex items-center gap-2 border-t border-border px-1 pt-2\">\n          <button\n            type=\"button\"\n            onClick={() => apply(others.map((d) => d.key))}\n            className=\"flex-1 rounded-lg px-2 py-1.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted\"\n          >\n            Every day\n          </button>\n          <button\n            type=\"button\"\n            onClick={() => apply([...picked])}\n            disabled={picked.size === 0}\n            className=\"flex-1 rounded-lg bg-primary px-2 py-1.5 text-xs font-semibold text-primary-foreground outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\"\n          >\n            Apply\n          </button>\n        </div>\n      </MorphPopoverContent>\n    </MorphPopover>\n  );\n}\n"},{"path":"components/motion/availability-scheduler/icon-button.tsx","type":"registry:component","target":"@components/motion/availability-scheduler/icon-button.tsx","content":"\"use client\";\n\nimport { motion } from \"motion/react\";\nimport type { ReactNode } from \"react\";\nimport { SPRING_PRESS } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport function IconButton({\n  onClick,\n  label,\n  disabled,\n  expanded,\n  reduce,\n  children,\n  className,\n  // Rest props let a wrapping Tooltip inject its hover/focus handlers.\n  ...rest\n}: {\n  onClick: () => void;\n  label: string;\n  disabled?: boolean;\n  expanded?: boolean;\n  reduce: boolean;\n  children: ReactNode;\n  className?: string;\n  [key: string]: unknown;\n}) {\n  return (\n    <motion.button\n      {...rest}\n      type=\"button\"\n      aria-label={label}\n      aria-expanded={expanded}\n      onClick={onClick}\n      disabled={disabled}\n      whileTap={reduce || disabled ? undefined : { scale: 0.86 }}\n      transition={SPRING_PRESS}\n      className={cn(\n        \"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40\",\n        className,\n      )}\n    >\n      {children}\n    </motion.button>\n  );\n}\n"},{"path":"components/motion/availability-scheduler/time-select.tsx","type":"registry:component","target":"@components/motion/availability-scheduler/time-select.tsx","content":"\"use client\";\n\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from \"@/components/motion/select\";\nimport type { TimeOption } from \"./types\";\n\n// Time field: the library Select, with the option list capped so the panel\n// measures a small height and scrolls instead of unfolding all 48 options.\nexport function TimeSelect({\n  value,\n  onChange,\n  options,\n}: {\n  value: string;\n  onChange: (v: string) => void;\n  options: TimeOption[];\n}) {\n  return (\n    <Select value={value} onValueChange={onChange} className=\"w-full\">\n      <SelectTrigger className=\"tabular-nums\">\n        <SelectValue className=\"whitespace-nowrap\" />\n      </SelectTrigger>\n      <SelectContent>\n        <div className=\"max-h-56 overflow-y-auto overscroll-contain\">\n          {options.map((o) => (\n            <SelectItem key={o.value} value={o.value} className=\"tabular-nums\">\n              {o.label}\n            </SelectItem>\n          ))}\n        </div>\n      </SelectContent>\n    </Select>\n  );\n}\n"},{"path":"components/motion/switch.tsx","type":"registry:component","target":"@components/motion/switch.tsx","content":"\"use client\";\n\nimport { animate, motion, MotionConfig, useReducedMotion } from \"motion/react\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\n// Heavy, deliberate thumb — high mass keeps the travel weighty without wobble.\nconst THUMB_SPRING = { type: \"spring\", stiffness: 800, damping: 80, mass: 4 } as const;\n\nexport interface SwitchProps {\n  checked: boolean;\n  onCheckedChange: (checked: boolean) => void;\n  disabled?: boolean;\n  label?: string;\n  className?: string;\n}\n\nexport function Switch({ checked, onCheckedChange, disabled, label, className }: SwitchProps) {\n  const id = useId();\n  const thumbRef = useRef<HTMLDivElement>(null);\n  const reduce = useReducedMotion();\n  const [isPressed, setIsPressed] = useState(false);\n  const [isPointer, setIsPointer] = useState(false);\n\n  // Disabled shake feedback when pressed.\n  useEffect(() => {\n    if (!thumbRef.current || reduce) return;\n    if (disabled && isPressed) {\n      animate(\n        thumbRef.current,\n        { x: [0, -2, 2, -1, 0] },\n        { delay: 0.2, duration: 0.6 },\n      );\n    }\n  }, [disabled, isPressed, reduce]);\n\n  const squish = !disabled && isPointer && isPressed && !reduce;\n\n  return (\n    <MotionConfig transition={reduce ? { duration: 0 } : THUMB_SPRING}>\n      <span className={cn(\"inline-flex items-center gap-3\", className)}>\n        <motion.button\n          id={id}\n          type=\"button\"\n          role=\"switch\"\n          aria-checked={checked}\n          disabled={disabled}\n          onClick={() => !disabled && onCheckedChange(!checked)}\n          onPointerDown={(e) => {\n            setIsPressed(true);\n            setIsPointer(e.type.startsWith(\"pointer\"));\n          }}\n          onPointerUp={() => setIsPressed(false)}\n          onPointerLeave={() => setIsPressed(false)}\n          initial={false}\n          data-state={checked ? \"checked\" : \"unchecked\"}\n          className={cn(\n            \"group peer inline-flex h-7 w-12 shrink-0 cursor-pointer items-center px-1 rounded-full outline-none transition-colors duration-200\",\n            \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n            \"disabled:cursor-not-allowed disabled:opacity-60\",\n            checked ? \"justify-end bg-primary\" : \"justify-start bg-muted-foreground/60\",\n          )}\n        >\n          <motion.div\n            ref={thumbRef}\n            layout\n            animate={{ scale: squish ? 0.9 : 1 }}\n            className=\"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-md\"\n          >\n            {/* Stretch toward the destination while active. */}\n            <div\n              className={cn(\n                \"size-5\",\n                squish && (checked ? \"ml-1\" : \"mr-1\"),\n              )}\n            />\n          </motion.div>\n        </motion.button>\n        {label ? (\n          <label htmlFor={id} className=\"cursor-pointer text-sm text-foreground\">\n            {label}\n          </label>\n        ) : null}\n      </span>\n    </MotionConfig>\n  );\n}\n"},{"path":"components/motion/tooltip.tsx","type":"registry:component","target":"@components/motion/tooltip.tsx","content":"\"use client\";\n\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  cloneElement,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n  useCallback,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { useHoverCapable } from \"@/lib/hooks/use-hover-capable\";\nimport { cn } from \"@/lib/utils\";\n\ntype Side = \"top\" | \"right\" | \"bottom\" | \"left\";\n\nexport interface TooltipProps {\n  content: ReactNode;\n  children: ReactElement;\n  side?: Side;\n  /** Delay before showing (ms). Default 120. */\n  delay?: number;\n  className?: string;\n  /** Classes for the outer wrapper span. Use to fix baseline / fill parent. */\n  wrapperClassName?: string;\n}\n\n// Gap between trigger and tooltip, in px.\nconst GAP = 8;\n\n// Centering transform for the fixed-positioned anchor point, per side.\nconst anchorTransform: Record<Side, string> = {\n  top: \"translate(-50%, -100%)\",\n  bottom: \"translate(-50%, 0)\",\n  left: \"translate(-100%, -50%)\",\n  right: \"translate(0, -50%)\",\n};\n\nconst transformOrigin: Record<Side, string> = {\n  top: \"center bottom\",\n  bottom: \"center top\",\n  left: \"right center\",\n  right: \"left center\",\n};\n\n// Offset is in the direction *away* from the trigger — content originates near\n// the trigger and rises into resting position.\nconst offsetFrom: Record<Side, { x?: number; y?: number }> = {\n  top: { y: 8 },\n  bottom: { y: -8 },\n  left: { x: 8 },\n  right: { x: -8 },\n};\n\nfunction buildVariants(side: Side): Variants {\n  const o = offsetFrom[side];\n  return {\n    initial: {\n      opacity: 0,\n      scale: 0.9,\n      filter: \"blur(5px)\",\n      x: o.x ?? 0,\n      y: o.y ?? 0,\n    },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      filter: \"blur(0px)\",\n      x: 0,\n      y: 0,\n      transition: {\n        type: \"spring\",\n        stiffness: 380,\n        damping: 30,\n        mass: 0.7,\n        opacity: { duration: 0.14, ease: EASE_OUT },\n        filter: { duration: 0.18, ease: EASE_OUT },\n      },\n    },\n    exit: {\n      opacity: 0,\n      scale: 0.94,\n      filter: \"blur(3px)\",\n      x: (o.x ?? 0) * 0.6,\n      y: (o.y ?? 0) * 0.6,\n      transition: { duration: 0.12, ease: EASE_OUT },\n    },\n  };\n}\n\nconst REDUCED_VARIANTS: Variants = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1, transition: { duration: 0.14, ease: EASE_OUT } },\n  exit: { opacity: 0, transition: { duration: 0.1, ease: EASE_OUT } },\n};\n\n// Once any tooltip has just closed, neighbouring tooltips open without the\n// initial delay — moving along a toolbar feels instant after the first one.\nconst WARM_WINDOW_MS = 300;\nlet lastHiddenAt = 0;\n\nexport function Tooltip({\n  content,\n  children,\n  side = \"top\",\n  delay = 120,\n  className,\n  wrapperClassName,\n}: TooltipProps) {\n  const [open, setOpen] = useState(false);\n  const [coords, setCoords] = useState<{ top: number; left: number } | null>(\n    null,\n  );\n  const id = useId();\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const anchorRef = useRef<HTMLSpanElement>(null);\n  const reduce = useReducedMotion();\n  const canHover = useHoverCapable();\n\n  // Anchor point in viewport coords, on the edge of the trigger facing `side`.\n  // Position:fixed means these viewport coords place the tooltip directly, so\n  // it escapes every ancestor's stacking context and overflow.\n  const place = useCallback(() => {\n    const el = anchorRef.current;\n    if (!el) return;\n    const r = el.getBoundingClientRect();\n    const cx = r.left + r.width / 2;\n    const cy = r.top + r.height / 2;\n    const point: Record<Side, { top: number; left: number }> = {\n      top: { top: r.top - GAP, left: cx },\n      bottom: { top: r.bottom + GAP, left: cx },\n      left: { top: cy, left: r.left - GAP },\n      right: { top: cy, left: r.right + GAP },\n    };\n    setCoords(point[side]);\n  }, [side]);\n\n  const show = useCallback(() => {\n    if (!canHover) return;\n    if (timer.current) clearTimeout(timer.current);\n    const warm = Date.now() - lastHiddenAt < WARM_WINDOW_MS;\n    timer.current = setTimeout(\n      () => {\n        place();\n        setOpen(true);\n      },\n      warm ? 0 : delay,\n    );\n  }, [canHover, delay, place]);\n\n  const hide = useCallback(() => {\n    if (timer.current) {\n      clearTimeout(timer.current);\n      timer.current = null;\n    }\n    setOpen((wasOpen) => {\n      if (wasOpen) lastHiddenAt = Date.now();\n      return false;\n    });\n  }, []);\n\n  // Keep the tooltip pinned to the trigger while it's open and the page scrolls\n  // or resizes (fixed coords are viewport-relative).\n  useEffect(() => {\n    if (!open) return;\n    const onMove = () => place();\n    window.addEventListener(\"scroll\", onMove, true);\n    window.addEventListener(\"resize\", onMove);\n    return () => {\n      window.removeEventListener(\"scroll\", onMove, true);\n      window.removeEventListener(\"resize\", onMove);\n    };\n  }, [open, place]);\n\n  const variants = useMemo(\n    () => (reduce ? REDUCED_VARIANTS : buildVariants(side)),\n    [reduce, side],\n  );\n\n  if (!isValidElement(children)) return children;\n\n  const trigger = cloneElement(\n    children as ReactElement<Record<string, unknown>>,\n    {\n      onMouseEnter: show,\n      onMouseLeave: hide,\n      onFocus: show,\n      onBlur: hide,\n      \"aria-describedby\": id,\n    },\n  );\n\n  return (\n    <>\n      <span\n        ref={anchorRef}\n        className={cn(\"relative inline-flex align-middle\", wrapperClassName)}\n      >\n        {trigger}\n      </span>\n      {typeof document !== \"undefined\"\n        ? createPortal(\n            <AnimatePresence>\n              {open && coords ? (\n                <span\n                  aria-hidden\n                  className=\"pointer-events-none fixed z-[9999]\"\n                  style={{\n                    top: coords.top,\n                    left: coords.left,\n                    transform: anchorTransform[side],\n                  }}\n                >\n                  <motion.span\n                    id={id}\n                    role=\"tooltip\"\n                    variants={variants}\n                    initial=\"initial\"\n                    animate=\"animate\"\n                    exit=\"exit\"\n                    style={{\n                      transformOrigin: transformOrigin[side],\n                      willChange: \"transform, opacity\",\n                    }}\n                    className={cn(\n                      \"block whitespace-nowrap rounded-lg border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground shadow-lg\",\n                      className,\n                    )}\n                  >\n                    {content}\n                  </motion.span>\n                </span>\n              ) : null}\n            </AnimatePresence>,\n            document.body,\n          )\n        : null}\n    </>\n  );\n}\n"},{"path":"lib/ease.ts","type":"registry:lib","target":"@lib/ease.ts","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants — defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n"},{"path":"components/motion/checkbox.tsx","type":"registry:component","target":"@components/motion/checkbox.tsx","content":"\"use client\";\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { useId } from \"react\";\nimport { EASE_OUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nconst CHECK_PATH = \"M5 13l4 4L19 7\";\nconst INDETERMINATE_PATH = \"M6 12h12\";\n\nexport interface CheckboxProps {\n  checked: boolean;\n  onCheckedChange: (checked: boolean) => void;\n  disabled?: boolean;\n  indeterminate?: boolean;\n  label?: string;\n  className?: string;\n  id?: string;\n  \"aria-label\"?: string;\n}\n\nexport function Checkbox({\n  checked,\n  onCheckedChange,\n  disabled,\n  indeterminate,\n  label,\n  className,\n  id: idProp,\n  \"aria-label\": ariaLabel,\n}: CheckboxProps) {\n  const autoId = useId();\n  const id = idProp ?? autoId;\n  const reduce = useReducedMotion();\n  const showMark = checked || indeterminate;\n  const path = indeterminate ? INDETERMINATE_PATH : CHECK_PATH;\n\n  return (\n    <label\n      htmlFor={id}\n      className={cn(\n        \"inline-flex items-center gap-3\",\n        disabled ? \"cursor-not-allowed\" : \"cursor-pointer\",\n        className,\n      )}\n    >\n      <motion.button\n        id={id}\n        type=\"button\"\n        role=\"checkbox\"\n        aria-checked={indeterminate ? \"mixed\" : checked}\n        aria-label={ariaLabel}\n        disabled={disabled}\n        onClick={() => !disabled && onCheckedChange(!checked)}\n        whileTap={reduce || disabled ? undefined : { scale: 0.92 }}\n        transition={SPRING_PRESS}\n        data-state={\n          checked ? \"checked\" : indeterminate ? \"indeterminate\" : \"unchecked\"\n        }\n        className={cn(\n          \"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md border-2 outline-none transition-colors duration-200\",\n          \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n          \"disabled:cursor-not-allowed disabled:opacity-60\",\n          showMark\n            ? \"border-primary bg-primary text-primary-foreground\"\n            : \"border-muted-foreground/50 bg-background hover:border-muted-foreground\",\n        )}\n      >\n        <AnimatePresence initial={false}>\n          {showMark ? (\n            <motion.svg\n              key={indeterminate ? \"indeterminate\" : \"checked\"}\n              width=\"12\"\n              height=\"12\"\n              viewBox=\"0 0 24 24\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              strokeWidth={3}\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              initial={reduce ? { opacity: 1 } : { opacity: 0, scale: 0.5 }}\n              animate={reduce ? { opacity: 1 } : { opacity: 1, scale: 1 }}\n              exit={\n                reduce\n                  ? { opacity: 0 }\n                  : { opacity: 0, scale: 0.5, filter: \"blur(4px)\" }\n              }\n              transition={\n                reduce ? { duration: 0 } : { duration: 0.16, ease: EASE_OUT }\n              }\n              aria-hidden\n            >\n              <title>{indeterminate ? \"Partially selected\" : \"Selected\"}</title>\n              <motion.path\n                d={path}\n                initial={reduce ? { pathLength: 1 } : { pathLength: 0 }}\n                animate={{ pathLength: 1 }}\n                transition={\n                  reduce\n                    ? { duration: 0 }\n                    : {\n                        duration: indeterminate ? 0.2 : 0.3,\n                        ease: EASE_OUT,\n                        delay: 0.04,\n                      }\n                }\n              />\n            </motion.svg>\n          ) : null}\n        </AnimatePresence>\n      </motion.button>\n      {label ? (\n        <span className={cn(\"select-none text-sm text-foreground\", disabled && \"opacity-60\")}>\n          {label}\n        </span>\n      ) : null}\n    </label>\n  );\n}\n"},{"path":"components/motion/popover-morph.tsx","type":"registry:component","target":"@components/motion/popover-morph.tsx","content":"\"use client\";\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport {\n  cloneElement,\n  createContext,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { SPRING_PANEL } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"end\";\n\ntype MorphContextValue = {\n  open: boolean;\n  setOpen: (open: boolean) => void;\n  toggle: () => void;\n  triggerId: string;\n  contentId: string;\n};\n\nconst MorphContext = createContext<MorphContextValue | null>(null);\n\nfunction useMorphContext(component: string) {\n  const ctx = useContext(MorphContext);\n  if (!ctx) throw new Error(`${component} must be used within <MorphPopover>`);\n  return ctx;\n}\n\nexport interface MorphPopoverProps {\n  children: ReactNode;\n  /** Controlled open state. */\n  open?: boolean;\n  /** Uncontrolled initial open state. */\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  className?: string;\n}\n\n/**\n * A popover whose panel morphs open from the trigger corner: it's laid out at\n * full size but clipped to the corner nearest the trigger, then unclips as one\n * piece. Closes on outside pointer / Escape. Controlled or uncontrolled.\n */\nexport function MorphPopover({\n  children,\n  open: controlledOpen,\n  defaultOpen = false,\n  onOpenChange,\n  className,\n}: MorphPopoverProps) {\n  const baseId = useId();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const [internalOpen, setInternalOpen] = useState(defaultOpen);\n  const controlled = controlledOpen !== undefined;\n  const open = controlled ? controlledOpen : internalOpen;\n\n  const setOpen = useCallback(\n    (next: boolean) => {\n      if (!controlled) setInternalOpen(next);\n      onOpenChange?.(next);\n    },\n    [controlled, onOpenChange],\n  );\n  const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n  useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n    const onPointer = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node))\n        setOpen(false);\n    };\n    window.addEventListener(\"keydown\", onKey);\n    window.addEventListener(\"pointerdown\", onPointer);\n    return () => {\n      window.removeEventListener(\"keydown\", onKey);\n      window.removeEventListener(\"pointerdown\", onPointer);\n    };\n  }, [open, setOpen]);\n\n  const ctx = useMemo<MorphContextValue>(\n    () => ({\n      open,\n      setOpen,\n      toggle,\n      triggerId: `${baseId}-trigger`,\n      contentId: `${baseId}-content`,\n    }),\n    [open, setOpen, toggle, baseId],\n  );\n\n  return (\n    <MorphContext.Provider value={ctx}>\n      <div ref={rootRef} className={cn(\"relative inline-flex\", className)}>\n        {children}\n      </div>\n    </MorphContext.Provider>\n  );\n}\n\nexport interface MorphPopoverTriggerProps {\n  children: ReactElement;\n}\n\n/** Wraps a single element, toggling the popover on click. */\nexport function MorphPopoverTrigger({ children }: MorphPopoverTriggerProps) {\n  const ctx = useMorphContext(\"MorphPopoverTrigger\");\n  if (!isValidElement(children)) return children;\n\n  const child = children as ReactElement<Record<string, unknown>>;\n  const childOnClick = child.props.onClick as\n    | ((e: unknown) => void)\n    | undefined;\n\n  return cloneElement(child, {\n    id: ctx.triggerId,\n    onClick: (e: unknown) => {\n      childOnClick?.(e);\n      ctx.toggle();\n    },\n    \"aria-haspopup\": \"menu\",\n    \"aria-expanded\": ctx.open,\n    \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n  });\n}\n\nconst originFor = (side: Side, align: Align) =>\n  `${side === \"bottom\" ? \"top\" : \"bottom\"} ${align === \"end\" ? \"right\" : \"left\"}`;\n\n// A clip that hides everything but the corner nearest the trigger, so the\n// panel appears to grow out of it. inset(top right bottom left).\nfunction clipHidden(side: Side, align: Align, radius: number) {\n  const top = side === \"bottom\" ? \"0%\" : \"92%\";\n  const bottom = side === \"bottom\" ? \"92%\" : \"0%\";\n  const right = align === \"end\" ? \"0%\" : \"92%\";\n  const left = align === \"end\" ? \"92%\" : \"0%\";\n  return `inset(${top} ${right} ${bottom} ${left} round ${radius}px)`;\n}\nconst clipShown = (radius: number) => `inset(0% 0% 0% 0% round ${radius}px)`;\n\nexport interface MorphPopoverContentProps {\n  children: ReactNode;\n  side?: Side;\n  align?: Align;\n  /** Gap between trigger and panel, in px. Default 8. */\n  sideOffset?: number;\n  /** Panel corner radius, in px. Default 16. */\n  radius?: number;\n  className?: string;\n}\n\nexport function MorphPopoverContent({\n  children,\n  side = \"bottom\",\n  align = \"end\",\n  sideOffset = 8,\n  radius = 16,\n  className,\n}: MorphPopoverContentProps) {\n  const ctx = useMorphContext(\"MorphPopoverContent\");\n  const reduce = useReducedMotion() ?? false;\n\n  const posClass = cn(\n    side === \"bottom\" ? \"top-full\" : \"bottom-full\",\n    align === \"end\" ? \"right-0\" : \"left-0\",\n  );\n  const marginStyle =\n    side === \"bottom\" ? { marginTop: sideOffset } : { marginBottom: sideOffset };\n\n  // Close animates with the same spring as open, so it morphs back to the\n  // corner instead of snapping shut.\n  const wrap = reduce\n    ? undefined\n    : {\n        hidden: { opacity: 0, scale: 0.96 },\n        show: { opacity: 1, scale: 1, transition: SPRING_PANEL },\n        exit: { opacity: 0, scale: 0.96, transition: SPRING_PANEL },\n      };\n  const clip = reduce\n    ? undefined\n    : {\n        hidden: { clipPath: clipHidden(side, align, radius) },\n        show: { clipPath: clipShown(radius), transition: SPRING_PANEL },\n        exit: { clipPath: clipHidden(side, align, radius), transition: SPRING_PANEL },\n      };\n\n  return (\n    <AnimatePresence>\n      {ctx.open ? (\n        <motion.div\n          // Wrapper carries the shadow as a drop-shadow filter, which hugs the\n          // clipped shape below (box-shadow would just get clipped away).\n          variants={wrap}\n          initial={reduce ? { opacity: 0 } : \"hidden\"}\n          animate={reduce ? { opacity: 1 } : \"show\"}\n          exit={reduce ? { opacity: 0 } : \"exit\"}\n          transition={reduce ? { duration: 0.12 } : undefined}\n          style={{ transformOrigin: originFor(side, align), ...marginStyle }}\n          className={cn(\n            \"absolute z-30 [filter:drop-shadow(0_10px_18px_rgba(0,0,0,0.14))]\",\n            posClass,\n          )}\n        >\n          <motion.div\n            id={ctx.contentId}\n            variants={clip}\n            style={{ borderRadius: radius }}\n            className={cn(\n              \"overflow-hidden border border-border bg-background\",\n              className,\n            )}\n          >\n            {children}\n          </motion.div>\n        </motion.div>\n      ) : null}\n    </AnimatePresence>\n  );\n}\n"},{"path":"components/motion/select.tsx","type":"registry:component","target":"@components/motion/select.tsx","content":"\"use client\";\n\nimport { Check, ChevronDown } from \"lucide-react\";\nimport {\n  motion,\n  type Transition,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useEffect,\n  useId,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\n// Spring with bounce powers the unfold/separation; per-property timings in the\n// content choreograph it (see SelectContent). Mirrors bouncy-accordion's feel.\nconst CHEVRON_TRANSITION: Transition = { type: \"spring\", duration: 0.4, bounce: 0.3 };\n\nconst LIST_VARIANTS: Variants = {\n  hidden: {},\n  show: { transition: { staggerChildren: 0.035, delayChildren: 0.05 } },\n};\nconst ITEM_VARIANTS: Variants = {\n  hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n  show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\ntype Placement = \"bottom\" | \"top\";\n\ninterface SelectContextValue {\n  value: string | undefined;\n  open: boolean;\n  setOpen: (open: boolean) => void;\n  select: (value: string) => void;\n  register: (value: string, label: string) => void;\n  unregister: (value: string) => void;\n  labelFor: (value: string | undefined) => string | undefined;\n  reduce: boolean;\n  triggerId: string;\n  listId: string;\n  disabled: boolean;\n  placement: Placement;\n  setPlacement: (p: Placement) => void;\n}\n\nconst SelectContext = createContext<SelectContextValue | null>(null);\n\nfunction useSelectContext(component: string) {\n  const ctx = useContext(SelectContext);\n  if (!ctx) throw new Error(`${component} must be used within <Select>`);\n  return ctx;\n}\n\nexport interface SelectProps {\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string) => void;\n  disabled?: boolean;\n  className?: string;\n  children: ReactNode;\n}\n\nexport function Select({\n  value,\n  defaultValue,\n  onValueChange,\n  disabled = false,\n  className,\n  children,\n}: SelectProps) {\n  const reduce = useReducedMotion() ?? false;\n  const baseId = useId();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const [open, setOpen] = useState(false);\n  const [internal, setInternal] = useState(defaultValue);\n  const [labels, setLabels] = useState<Map<string, string>>(new Map());\n  const [placement, setPlacement] = useState<Placement>(\"bottom\");\n\n  const controlled = value !== undefined;\n  const current = controlled ? value : internal;\n\n  const select = useCallback(\n    (next: string) => {\n      if (!controlled) setInternal(next);\n      onValueChange?.(next);\n      setOpen(false);\n    },\n    [controlled, onValueChange],\n  );\n\n  const register = useCallback((v: string, label: string) => {\n    setLabels((m) => (m.get(v) === label ? m : new Map(m).set(v, label)));\n  }, []);\n  const unregister = useCallback((v: string) => {\n    setLabels((m) => {\n      if (!m.has(v)) return m;\n      const next = new Map(m);\n      next.delete(v);\n      return next;\n    });\n  }, []);\n\n  // close on outside pointer / escape\n  useEffect(() => {\n    if (!open) return;\n    const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n    const onPointer = (e: PointerEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node))\n        setOpen(false);\n    };\n    window.addEventListener(\"keydown\", onKey);\n    window.addEventListener(\"pointerdown\", onPointer);\n    return () => {\n      window.removeEventListener(\"keydown\", onKey);\n      window.removeEventListener(\"pointerdown\", onPointer);\n    };\n  }, [open]);\n\n  const ctx = useMemo<SelectContextValue>(\n    () => ({\n      value: current,\n      open,\n      setOpen,\n      select,\n      register,\n      unregister,\n      labelFor: (v) => (v === undefined ? undefined : labels.get(v)),\n      reduce,\n      triggerId: `${baseId}-trigger`,\n      listId: `${baseId}-list`,\n      disabled,\n      placement,\n      setPlacement,\n    }),\n    [\n      current,\n      open,\n      select,\n      register,\n      unregister,\n      labels,\n      reduce,\n      baseId,\n      disabled,\n      placement,\n    ],\n  );\n\n  return (\n    <SelectContext.Provider value={ctx}>\n      <div ref={rootRef} className={cn(\"relative\", className)}>\n        {children}\n      </div>\n    </SelectContext.Provider>\n  );\n}\n\nexport interface SelectTriggerProps {\n  className?: string;\n  children: ReactNode;\n}\n\nexport function SelectTrigger({ className, children }: SelectTriggerProps) {\n  const ctx = useSelectContext(\"SelectTrigger\");\n  const isTop = ctx.placement === \"top\";\n  // edge facing the panel flattens then rounds; the far edge stays rounded.\n  // All four corners are specified so none gets stranded when placement flips.\n  const kf = ctx.open ? [0, 0, 12] : [12, 0, 12];\n  const kfT: Transition = ctx.reduce\n    ? { duration: 0 }\n    : ctx.open\n      ? { duration: 0.6, times: [0, 0.4, 1], ease: EASE_OUT }\n      : { duration: 0.42, times: [0, 0.5, 1], ease: EASE_OUT };\n  const flatT: Transition = { duration: 0 };\n  return (\n    <motion.button\n      type=\"button\"\n      id={ctx.triggerId}\n      disabled={ctx.disabled}\n      aria-haspopup=\"listbox\"\n      aria-expanded={ctx.open}\n      aria-controls={ctx.listId}\n      onClick={() => ctx.setOpen(!ctx.open)}\n      // Gooey: the edge facing the panel snaps flat (panel attached) then rounds\n      // back once the panel pulls away — the two pinch apart.\n      initial={false}\n      animate={{\n        borderTopLeftRadius: isTop ? kf : 12,\n        borderTopRightRadius: isTop ? kf : 12,\n        borderBottomLeftRadius: isTop ? 12 : kf,\n        borderBottomRightRadius: isTop ? 12 : kf,\n      }}\n      transition={{\n        borderTopLeftRadius: isTop ? kfT : flatT,\n        borderTopRightRadius: isTop ? kfT : flatT,\n        borderBottomLeftRadius: isTop ? flatT : kfT,\n        borderBottomRightRadius: isTop ? flatT : kfT,\n      }}\n      className={cn(\n        \"relative z-10 flex w-full items-center justify-between gap-2 rounded-xl border border-border bg-background px-3 py-2 text-sm text-foreground outline-none transition-colors\",\n        \"hover:border-(--color-border-strong) focus-visible:ring-2 focus-visible:ring-foreground/20\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        className,\n      )}\n    >\n      {children}\n      <motion.span\n        aria-hidden\n        animate={{ rotate: ctx.open ? 180 : 0 }}\n        transition={ctx.reduce ? { duration: 0 } : CHEVRON_TRANSITION}\n        className=\"text-muted-foreground\"\n      >\n        <ChevronDown className=\"h-4 w-4\" />\n      </motion.span>\n    </motion.button>\n  );\n}\n\nexport interface SelectValueProps {\n  placeholder?: string;\n  className?: string;\n}\n\nexport function SelectValue({ placeholder, className }: SelectValueProps) {\n  const ctx = useSelectContext(\"SelectValue\");\n  const label = ctx.labelFor(ctx.value);\n  return (\n    <span\n      className={cn(label ? \"text-foreground\" : \"text-muted-foreground\", className)}\n    >\n      {label ?? placeholder ?? \"Select\"}\n    </span>\n  );\n}\n\nexport interface SelectContentProps {\n  className?: string;\n  children: ReactNode;\n}\n\nexport function SelectContent({ className, children }: SelectContentProps) {\n  const ctx = useSelectContext(\"SelectContent\");\n  const innerRef = useRef<HTMLDivElement>(null);\n  const [height, setHeight] = useState(0);\n  const open = ctx.open;\n  const { setPlacement } = ctx;\n\n  useLayoutEffect(() => {\n    const node = innerRef.current;\n    if (!node) return;\n    const measure = () => setHeight(node.offsetHeight);\n    measure();\n    const observer = new ResizeObserver(measure);\n    observer.observe(node);\n    return () => observer.disconnect();\n  });\n\n  // On open, flip upward when there isn't room below and there's more above.\n  useLayoutEffect(() => {\n    if (!open) return;\n    const trigger = document.getElementById(ctx.triggerId);\n    const node = innerRef.current;\n    if (!trigger || !node) return;\n    const rect = trigger.getBoundingClientRect();\n    const h = node.offsetHeight;\n    const below = window.innerHeight - rect.bottom;\n    const above = rect.top;\n    setPlacement(below < h + 16 && above > below ? \"top\" : \"bottom\");\n  }, [open, ctx.triggerId, setPlacement]);\n\n  // Specify EVERY corner + both margins each render. The near edge (facing the\n  // trigger) animates flat->round and the gap opens on that side; the far edge\n  // stays rounded and its margin pinned to 0. Setting all of them avoids a\n  // stranded square corner when the placement flips between opens.\n  const isTop = ctx.placement === \"top\";\n  const nearGap = open ? 8 : 0;\n  const nearRadius = open ? 12 : 0;\n\n  const gapT: Transition = open\n    ? { type: \"spring\", duration: 0.6, bounce: 0.5, delay: 0.12 }\n    : { type: \"spring\", duration: 0.3, bounce: 0.1 };\n  const radiusT: Transition = open\n    ? { duration: 0.3, ease: EASE_OUT, delay: 0.14 }\n    : { duration: 0.16, ease: EASE_OUT };\n  const instant: Transition = { duration: 0 };\n\n  // Items stay mounted (open just animates the panel) so each item's label\n  // registration persists — otherwise the trigger would fall back to the\n  // placeholder the moment the panel closes.\n  return (\n    <motion.div\n      id={ctx.listId}\n      role=\"listbox\"\n      aria-labelledby={ctx.triggerId}\n      aria-hidden={!open}\n      initial={false}\n      animate={\n        ctx.reduce\n          ? { opacity: open ? 1 : 0, height: open ? height : 0 }\n          : {\n              opacity: open ? 1 : 0,\n              height: open ? height : 0,\n              // gap opens on the side facing the trigger\n              marginTop: isTop ? 0 : nearGap,\n              marginBottom: isTop ? nearGap : 0,\n              // near corners go flat->round; far corners stay rounded\n              borderTopLeftRadius: isTop ? 12 : nearRadius,\n              borderTopRightRadius: isTop ? 12 : nearRadius,\n              borderBottomLeftRadius: isTop ? nearRadius : 12,\n              borderBottomRightRadius: isTop ? nearRadius : 12,\n            }\n      }\n      transition={\n        ctx.reduce\n          ? { duration: 0.12 }\n          : {\n              opacity: open\n                ? { duration: 0.18 }\n                : { duration: 0.16, delay: 0.12 },\n              height: open\n                ? { type: \"spring\", duration: 0.42, bounce: 0.14 }\n                : { duration: 0.26, ease: EASE_OUT, delay: 0.14 },\n              marginTop: isTop ? instant : gapT,\n              marginBottom: isTop ? gapT : instant,\n              borderTopLeftRadius: isTop ? instant : radiusT,\n              borderTopRightRadius: isTop ? instant : radiusT,\n              borderBottomLeftRadius: isTop ? radiusT : instant,\n              borderBottomRightRadius: isTop ? radiusT : instant,\n            }\n      }\n      style={{\n        transformOrigin: isTop ? \"bottom\" : \"top\",\n        overflow: \"hidden\",\n        pointerEvents: open ? \"auto\" : \"none\",\n      }}\n      // flush against the trigger, then separates into its own rounded pill;\n      // sits above or below depending on available space\n      className={cn(\n        \"absolute left-0 right-0 z-20 rounded-xl border border-border bg-background shadow-lg\",\n        isTop ? \"bottom-full\" : \"top-full\",\n        className,\n      )}\n    >\n      <motion.div\n        ref={innerRef}\n        variants={ctx.reduce ? undefined : LIST_VARIANTS}\n        initial={false}\n        animate={open ? \"show\" : \"hidden\"}\n        className=\"p-1\"\n      >\n        {children}\n      </motion.div>\n    </motion.div>\n  );\n}\n\nexport interface SelectItemProps {\n  value: string;\n  disabled?: boolean;\n  className?: string;\n  children: ReactNode;\n}\n\nexport function SelectItem({\n  value,\n  disabled = false,\n  className,\n  children,\n}: SelectItemProps) {\n  const ctx = useSelectContext(\"SelectItem\");\n  const selected = ctx.value === value;\n  const label = typeof children === \"string\" ? children : value;\n\n  useLayoutEffect(() => {\n    ctx.register(value, label);\n    return () => ctx.unregister(value);\n  }, [ctx.register, ctx.unregister, value, label]);\n\n  return (\n    <motion.li variants={ctx.reduce ? undefined : ITEM_VARIANTS}>\n      <button\n        type=\"button\"\n        role=\"option\"\n        aria-selected={selected}\n        disabled={disabled}\n        onClick={() => ctx.select(value)}\n        className={cn(\n          \"flex w-full items-center justify-between gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors\",\n          selected\n            ? \"bg-muted text-foreground\"\n            : \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:bg-muted\",\n          \"disabled:pointer-events-none disabled:opacity-50\",\n          className,\n        )}\n      >\n        {children}\n        {selected ? <Check className=\"h-3.5 w-3.5 shrink-0\" /> : null}\n      </button>\n    </motion.li>\n  );\n}\n"},{"path":"lib/hooks/use-hover-capable.ts","type":"registry:hook","target":"@lib/hooks/use-hover-capable.ts","content":"\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Returns true only on devices that have a true hover (mouse / trackpad).\n * Touch devices fire phantom `:hover` on tap that sticks until tap-elsewhere\n * — gate hover-only effects (scale lifts, magnetic pulls) behind this.\n */\nexport function useHoverCapable() {\n  const [canHover, setCanHover] = useState(false);\n\n  useEffect(() => {\n    if (typeof window === \"undefined\" || !window.matchMedia) return;\n    const mq = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const update = () => setCanHover(mq.matches);\n    update();\n    mq.addEventListener?.(\"change\", update);\n    return () => mq.removeEventListener?.(\"change\", update);\n  }, []);\n\n  return canHover;\n}\n"}]}