{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elastic-dock",
  "type": "registry:ui",
  "title": "Elastic Dock",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Physics-coupled magnification dock with continuous Euclidean pointer falloff, spring-tethered icon scaling, and roving keyboard navigation.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/elastic-dock.tsx",
      "content": "\"use client\";\n\nimport React, { useRef, useState } from \"react\";\nimport {\n  motion,\n  useMotionValue,\n  useSpring,\n  useTransform,\n  useReducedMotion,\n  type MotionValue,\n} from \"framer-motion\";\nimport {\n  Home,\n  Terminal,\n  Sparkles,\n  Layers,\n  Settings,\n  Compass,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ElasticDockItem {\n  id: string;\n  label: string;\n  icon: React.ReactNode;\n  badge?: string | number;\n  onClick?: () => void;\n}\n\nexport interface ElasticDockProps {\n  /** Array of dock items to render. Defaults to a 6-item studio toolbar. */\n  items?: ElasticDockItem[];\n  /** Resting icon button size in pixels. Default: 46 */\n  baseSize?: number;\n  /** Peak magnified icon button size in pixels on hover. Default: 72 */\n  magnifiedSize?: number;\n  /** Pointer proximity radius in pixels affecting neighboring items. Default: 140 */\n  distance?: number;\n  /** Hooke's Law spring stiffness coefficient. Default: 320 */\n  stiffness?: number;\n  /** Spring damping coefficient. Default: 22 */\n  damping?: number;\n  /** Controlled or initial active item id */\n  defaultActiveId?: string;\n  /** Callback fired when an item is selected */\n  onSelect?: (id: string) => void;\n  className?: string;\n}\n\nconst DEFAULT_ITEMS: ElasticDockItem[] = [\n  { id: \"overview\", label: \"Overview\", icon: <Home className=\"h-5 w-5\" /> },\n  { id: \"explore\", label: \"Explore\", icon: <Compass className=\"h-5 w-5\" /> },\n  {\n    id: \"primitives\",\n    label: \"Primitives\",\n    icon: <Layers className=\"h-5 w-5\" />,\n    badge: \"12\",\n  },\n  { id: \"kinetic\", label: \"Kinetic Lab\", icon: <Sparkles className=\"h-5 w-5\" /> },\n  { id: \"cli\", label: \"CLI Registry\", icon: <Terminal className=\"h-5 w-5\" /> },\n  { id: \"settings\", label: \"Settings\", icon: <Settings className=\"h-5 w-5\" /> },\n];\n\ninterface DockIconButtonProps {\n  item: ElasticDockItem;\n  isActive: boolean;\n  mouseX: MotionValue<number>;\n  baseSize: number;\n  magnifiedSize: number;\n  distance: number;\n  stiffness: number;\n  damping: number;\n  shouldReduceMotion: boolean;\n  onSelect: () => void;\n  onKeyNav: (e: React.KeyboardEvent<HTMLButtonElement>) => void;\n  buttonRef: (el: HTMLButtonElement | null) => void;\n}\n\nfunction DockIconButton({\n  item,\n  isActive,\n  mouseX,\n  baseSize,\n  magnifiedSize,\n  distance,\n  stiffness,\n  damping,\n  shouldReduceMotion,\n  onSelect,\n  onKeyNav,\n  buttonRef,\n}: DockIconButtonProps) {\n  const localRef = useRef<HTMLButtonElement | null>(null);\n  const [isHovered, setIsHovered] = useState(false);\n  const [isFocused, setIsFocused] = useState(false);\n\n  const distanceFromPointer = useTransform(mouseX, (val) => {\n    const bounds = localRef.current?.getBoundingClientRect();\n    if (!bounds || val === -Infinity) return Infinity;\n    return val - (bounds.x + bounds.width / 2);\n  });\n\n  const targetSize = useTransform(\n    distanceFromPointer,\n    [-distance, 0, distance],\n    [baseSize, magnifiedSize, baseSize]\n  );\n\n  const targetLift = useTransform(\n    distanceFromPointer,\n    [-distance, 0, distance],\n    [0, -8, 0]\n  );\n\n  const springSize = useSpring(targetSize, {\n    stiffness,\n    damping,\n    mass: 0.5,\n  });\n\n  const springLift = useSpring(targetLift, {\n    stiffness,\n    damping,\n    mass: 0.5,\n  });\n\n  const showTooltip = isHovered || isFocused;\n\n  return (\n    <div className=\"relative flex flex-col items-center\">\n      {/* Floating HUD Tooltip */}\n      <motion.div\n        initial={false}\n        animate={{\n          opacity: showTooltip ? 1 : 0,\n          y: showTooltip ? -8 : 2,\n          scale: showTooltip ? 1 : 0.92,\n        }}\n        transition={{ duration: 0.14, ease: \"easeOut\" }}\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute -top-9 z-20 whitespace-nowrap rounded-md border border-neutral-200 bg-white/95 px-2.5 py-1 text-[11px] font-medium tracking-tight text-black shadow-sm backdrop-blur-md dark:border-[#262626] dark:bg-[#111111]/95 dark:text-white\"\n      >\n        {item.label}\n      </motion.div>\n\n      <motion.button\n        ref={(el) => {\n          localRef.current = el;\n          buttonRef(el);\n        }}\n        type=\"button\"\n        aria-label={item.label}\n        aria-current={isActive ? \"page\" : undefined}\n        onClick={() => {\n          onSelect();\n          item.onClick?.();\n        }}\n        onKeyDown={onKeyNav}\n        onMouseEnter={() => setIsHovered(true)}\n        onMouseLeave={() => setIsHovered(false)}\n        onFocus={() => setIsFocused(true)}\n        onBlur={() => setIsFocused(false)}\n        whileTap={shouldReduceMotion ? undefined : { scale: 0.9 }}\n        style={{\n          width: shouldReduceMotion ? baseSize : springSize,\n          height: shouldReduceMotion ? baseSize : springSize,\n          y: shouldReduceMotion ? 0 : springLift,\n        }}\n        className={cn(\n          \"group relative flex items-center justify-center rounded-2xl border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:focus-visible:ring-white\",\n          isActive\n            ? \"border-black bg-black text-white dark:border-white dark:bg-white dark:text-black\"\n            : \"border-neutral-200/90 bg-neutral-50/90 text-neutral-700 hover:border-neutral-400 hover:bg-white hover:text-black dark:border-[#222222] dark:bg-[#121212] dark:text-neutral-300 dark:hover:border-[#383838] dark:hover:bg-[#1A1A1A] dark:hover:text-white\"\n        )}\n      >\n        <span className=\"pointer-events-none flex items-center justify-center\">\n          {item.icon}\n        </span>\n\n        {item.badge !== undefined && (\n          <span className=\"pointer-events-none absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-full border border-white bg-black px-1 text-[9px] font-bold text-white dark:border-[#0A0A0A] dark:bg-white dark:text-black\">\n            {item.badge}\n          </span>\n        )}\n      </motion.button>\n\n      {/* Active spring indicator dot */}\n      <div className=\"mt-1.5 flex h-1.5 items-center justify-center\">\n        {isActive && (\n          <motion.span\n            layoutId=\"elastic-dock-active-dot\"\n            transition={\n              shouldReduceMotion\n                ? { duration: 0 }\n                : { type: \"spring\", stiffness: 380, damping: 26 }\n            }\n            className=\"h-1.5 w-1.5 rounded-full bg-black dark:bg-white\"\n          />\n        )}\n      </div>\n    </div>\n  );\n}\n\nexport function ElasticDock({\n  items = DEFAULT_ITEMS,\n  baseSize = 46,\n  magnifiedSize = 68,\n  distance = 140,\n  stiffness = 320,\n  damping = 22,\n  defaultActiveId = \"kinetic\",\n  onSelect,\n  className,\n}: ElasticDockProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const mouseX = useMotionValue(-Infinity);\n  const [activeId, setActiveId] = useState<string>(\n    defaultActiveId || items[0]?.id || \"\"\n  );\n  const buttonRefs = useRef<Array<HTMLButtonElement | null>>([]);\n\n  const handleKeyDown = (\n    index: number,\n    e: React.KeyboardEvent<HTMLButtonElement>\n  ) => {\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      const next = (index + 1) % items.length;\n      buttonRefs.current[next]?.focus();\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      const prev = (index - 1 + items.length) % items.length;\n      buttonRefs.current[prev]?.focus();\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      buttonRefs.current[0]?.focus();\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      buttonRefs.current[items.length - 1]?.focus();\n    }\n  };\n\n  return (\n    <motion.div\n      role=\"toolbar\"\n      aria-label=\"Application dock navigation\"\n      onMouseMove={(e) => {\n        if (!shouldReduceMotion) {\n          mouseX.set(e.clientX);\n        }\n      }}\n      onMouseLeave={() => mouseX.set(-Infinity)}\n      className={cn(\n        \"inline-flex items-end gap-2.5 rounded-3xl border border-neutral-200/90 bg-white/85 px-4 pb-2 pt-3 shadow-sm backdrop-blur-xl dark:border-[#222222] dark:bg-[#0A0A0A]/85\",\n        className\n      )}\n    >\n      {items.map((item, idx) => (\n        <DockIconButton\n          key={item.id}\n          item={item}\n          isActive={activeId === item.id}\n          mouseX={mouseX}\n          baseSize={baseSize}\n          magnifiedSize={magnifiedSize}\n          distance={distance}\n          stiffness={stiffness}\n          damping={damping}\n          shouldReduceMotion={shouldReduceMotion}\n          onSelect={() => {\n            setActiveId(item.id);\n            onSelect?.(item.id);\n          }}\n          onKeyNav={(e) => handleKeyDown(idx, e)}\n          buttonRef={(el) => {\n            buttonRefs.current[idx] = el;\n          }}\n        />\n      ))}\n    </motion.div>\n  );\n}\n\nexport default ElasticDock;\n",
      "type": "registry:ui",
      "target": "components/ui/elastic-dock.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
