{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mega-menu",
  "type": "registry:ui",
  "title": "Mega Menu",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Kinetic multi-column navigation mega menu featuring spring category tabs, directional sliding content panels, interactive feature cards, and quick link references.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/mega-menu.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useRef, useEffect, useId } from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"framer-motion\";\nimport {\n  ChevronDown,\n  ArrowRight,\n  Sparkles,\n  Zap,\n  Shield,\n  Layers,\n  Box,\n  Cpu,\n  Compass,\n  FileCode,\n  Globe,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MegaMenuItem {\n  title: string;\n  description: string;\n  href: string;\n  icon?: React.ComponentType<{ className?: string }>;\n  badge?: string;\n}\n\nexport interface MegaMenuCategory {\n  id: string;\n  label: string;\n  title: string;\n  description: string;\n  items: MegaMenuItem[];\n  featured?: {\n    title: string;\n    description: string;\n    href: string;\n    ctaText?: string;\n    badge?: string;\n  };\n  quickLinks?: { label: string; href: string }[];\n}\n\nexport interface MegaMenuProps extends React.HTMLAttributes<HTMLElement> {\n  /** Array of mega menu categories with cards and links */\n  categories?: MegaMenuCategory[];\n  /** Controlled active category ID */\n  activeCategory?: string;\n  /** Callback fired when a category or link is chosen */\n  onCategoryChange?: (id: string) => void;\n  /** Custom trigger label or children */\n  triggerLabel?: string;\n  /** Custom container class */\n  className?: string;\n}\n\nconst DEFAULT_CATEGORIES: MegaMenuCategory[] = [\n  {\n    id: \"products\",\n    label: \"Products\",\n    title: \"Kinetic Architecture\",\n    description: \"Explore our physics-based primitives and application blocks.\",\n    items: [\n      {\n        title: \"Kinetic Primitives\",\n        description: \"106+ spring-driven buttons, cards, docks, and forms.\",\n        href: \"#primitives\",\n        icon: Sparkles,\n        badge: \"v2.0\",\n      },\n      {\n        title: \"Application Blocks\",\n        description: \"Composite hero sections, pricing tables, and dashboards.\",\n        href: \"#blocks\",\n        icon: Box,\n      },\n      {\n        title: \"Simulation Canvases\",\n        description: \"Interactive particle mesh, black holes, and liquid caustics.\",\n        href: \"#simulations\",\n        icon: Cpu,\n        badge: \"WebGL\",\n      },\n      {\n        title: \"Design Tokens\",\n        description: \"Calibrated typographic scales, palettes, and spring curves.\",\n        href: \"#tokens\",\n        icon: Layers,\n      },\n    ],\n    featured: {\n      title: \"BoseUI Pro Engine\",\n      description: \"Upgrade your team's workflow with pre-assembled kinetic screens.\",\n      href: \"#upgrade\",\n      ctaText: \"Explore Pro\",\n      badge: \"Release\",\n    },\n    quickLinks: [\n      { label: \"Component Catalog\", href: \"#catalog\" },\n      { label: \"Interactive Playground\", href: \"#playground\" },\n      { label: \"Figma UI Kit\", href: \"#figma\" },\n    ],\n  },\n  {\n    id: \"developers\",\n    label: \"Developers\",\n    title: \"Developer Toolkit\",\n    description: \"Documentation, CLI guides, and full source code access.\",\n    items: [\n      {\n        title: \"CLI Registry\",\n        description: \"Install directly into your codebase with npx shadcn add.\",\n        href: \"#cli\",\n        icon: Zap,\n      },\n      {\n        title: \"Architecture & Rules\",\n        description: \"Two-file contract, Hooke's Law physics, and zero-lock-in design.\",\n        href: \"#architecture\",\n        icon: Shield,\n      },\n      {\n        title: \"Framework Recipes\",\n        description: \"Next.js 14 App Router, Vite, Astro, and Remix integration.\",\n        href: \"#recipes\",\n        icon: FileCode,\n      },\n      {\n        title: \"API Reference\",\n        description: \"TypeScript interfaces, prop contracts, and accessibility guides.\",\n        href: \"#api\",\n        icon: Compass,\n      },\n    ],\n    featured: {\n      title: \"CLI Auto-Sync\",\n      description: \"Run npm run sync to regenerate registry manifests and SEO in milliseconds.\",\n      href: \"#sync\",\n      ctaText: \"Read Docs\",\n    },\n    quickLinks: [\n      { label: \"GitHub Repository\", href: \"https://github.com/Theb0se/bose-ui\" },\n      { label: \"Contributing Guide\", href: \"#contributing\" },\n      { label: \"Changelog\", href: \"#changelog\" },\n    ],\n  },\n  {\n    id: \"ecosystem\",\n    label: \"Ecosystem\",\n    title: \"Community & Workspaces\",\n    description: \"Global open-source network of creators and design engineers.\",\n    items: [\n      {\n        title: \"Showcase Gallery\",\n        description: \"Real-world production SaaS and landing pages built with BoseUI.\",\n        href: \"#showcase\",\n        icon: Globe,\n      },\n      {\n        title: \"Community Discord\",\n        description: \"Get assistance, share kinetic experiments, and collaborate.\",\n        href: \"#discord\",\n        icon: Sparkles,\n      },\n    ],\n    quickLinks: [\n      { label: \"Author Portfolio\", href: \"https://theb0se.vercel.app/\" },\n      { label: \"Report an Issue\", href: \"#issues\" },\n      { label: \"Roadmap 2026\", href: \"#roadmap\" },\n    ],\n  },\n];\n\nexport function MegaMenu({\n  categories = DEFAULT_CATEGORIES,\n  activeCategory: controlledActive,\n  onCategoryChange,\n  triggerLabel = \"Explore Platform\",\n  className,\n  ...props\n}: MegaMenuProps) {\n  const [isOpen, setIsOpen] = useState(false);\n  const [internalActiveId, setInternalActiveId] = useState(\n    categories[0]?.id || \"\"\n  );\n  const [direction, setDirection] = useState<1 | -1>(1);\n  const menuRef = useRef<HTMLDivElement>(null);\n  const instanceId = useId();\n  const shouldReduceMotion = useReducedMotion();\n\n  const currentCategory =\n    controlledActive !== undefined ? controlledActive : internalActiveId;\n\n  const currentCategoryData =\n    categories.find((c) => c.id === currentCategory) || categories[0];\n\n  const handleSelectCategory = (id: string) => {\n    const currentIndex = categories.findIndex((c) => c.id === currentCategory);\n    const nextIndex = categories.findIndex((c) => c.id === id);\n    setDirection(nextIndex > currentIndex ? 1 : -1);\n\n    if (controlledActive === undefined) {\n      setInternalActiveId(id);\n    }\n    onCategoryChange?.(id);\n  };\n\n  // Close when clicking outside or pressing Escape\n  useEffect(() => {\n    const handleClickOutside = (e: MouseEvent) => {\n      if (menuRef.current && !menuRef.current.contains(e.target as Node)) {\n        setIsOpen(false);\n      }\n    };\n\n    const handleKeyDown = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setIsOpen(false);\n      }\n    };\n\n    if (isOpen) {\n      document.addEventListener(\"mousedown\", handleClickOutside);\n      document.addEventListener(\"keydown\", handleKeyDown);\n    }\n    return () => {\n      document.removeEventListener(\"mousedown\", handleClickOutside);\n      document.removeEventListener(\"keydown\", handleKeyDown);\n    };\n  }, [isOpen]);\n\n  return (\n    <div\n      ref={menuRef}\n      className={cn(\"relative inline-block text-left\", className)}\n      {...props}\n    >\n      {/* MegaMenu Trigger Button */}\n      <button\n        type=\"button\"\n        onClick={() => setIsOpen((prev) => !prev)}\n        aria-expanded={isOpen}\n        aria-haspopup=\"true\"\n        className=\"inline-flex items-center gap-2 rounded-xl border border-neutral-200/80 bg-white px-4 py-2 text-xs font-semibold text-neutral-900 shadow-sm transition-all hover:bg-neutral-50 active:scale-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 dark:border-neutral-800 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800\"\n      >\n        <span>{triggerLabel}</span>\n        <ChevronDown\n          className={cn(\n            \"h-3.5 w-3.5 transition-transform duration-200\",\n            isOpen ? \"rotate-180\" : \"\"\n          )}\n        />\n      </button>\n\n      {/* Floating Mega Dropdown Container */}\n      <AnimatePresence>\n        {isOpen && (\n          <motion.div\n            initial={\n              shouldReduceMotion\n                ? { opacity: 0 }\n                : { opacity: 0, y: 10, scale: 0.98 }\n            }\n            animate={\n              shouldReduceMotion\n                ? { opacity: 1 }\n                : { opacity: 1, y: 0, scale: 1 }\n            }\n            exit={\n              shouldReduceMotion\n                ? { opacity: 0 }\n                : { opacity: 0, y: 8, scale: 0.98 }\n            }\n            transition={{ type: \"spring\", stiffness: 420, damping: 30 }}\n            className=\"absolute left-1/2 top-full z-50 mt-3 -translate-x-1/2 w-[92vw] max-w-4xl\"\n          >\n            <div className=\"overflow-hidden rounded-2xl border border-neutral-200/90 bg-white/95 p-6 shadow-2xl shadow-neutral-900/10 backdrop-blur-2xl dark:border-neutral-800/90 dark:bg-neutral-950/95 dark:shadow-black/40\">\n              {/* Category Tab Selector */}\n              <div className=\"flex items-center gap-2 border-b border-neutral-200/70 pb-4 dark:border-neutral-800/70\">\n                {categories.map((cat) => {\n                  const isActive = cat.id === currentCategory;\n                  return (\n                    <button\n                      key={cat.id}\n                      type=\"button\"\n                      onClick={() => handleSelectCategory(cat.id)}\n                      className={cn(\n                        \"relative rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none\",\n                        isActive\n                          ? \"text-neutral-950 font-bold dark:text-white\"\n                          : \"text-neutral-500 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white\"\n                      )}\n                    >\n                      {isActive && (\n                        <motion.div\n                          layoutId={`mega-category-pill-${instanceId}`}\n                          className=\"absolute inset-0 rounded-lg bg-neutral-100 dark:bg-neutral-800 -z-10 shadow-sm\"\n                          transition={{\n                            type: \"spring\",\n                            stiffness: 400,\n                            damping: 30,\n                          }}\n                        />\n                      )}\n                      <span>{cat.label}</span>\n                    </button>\n                  );\n                })}\n              </div>\n\n              {/* Dynamic Content Panel with Directional Animation */}\n              <AnimatePresence mode=\"wait\" custom={direction}>\n                <motion.div\n                  key={currentCategoryData.id}\n                  custom={direction}\n                  initial={\n                    shouldReduceMotion\n                      ? { opacity: 0 }\n                      : { opacity: 0, x: direction * 15 }\n                  }\n                  animate={\n                    shouldReduceMotion ? { opacity: 1 } : { opacity: 1, x: 0 }\n                  }\n                  exit={\n                    shouldReduceMotion\n                      ? { opacity: 0 }\n                      : { opacity: 0, x: direction * -15 }\n                  }\n                  transition={{ duration: 0.18, ease: \"easeOut\" }}\n                  className=\"mt-6 grid grid-cols-1 gap-8 md:grid-cols-12\"\n                >\n                  {/* Left Section: Cards Grid */}\n                  <div className=\"md:col-span-8\">\n                    <div className=\"mb-4\">\n                      <h3 className=\"text-sm font-bold text-neutral-950 dark:text-white\">\n                        {currentCategoryData.title}\n                      </h3>\n                      <p className=\"text-xs text-neutral-500 dark:text-neutral-400\">\n                        {currentCategoryData.description}\n                      </p>\n                    </div>\n\n                    <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n                      {currentCategoryData.items.map((item) => {\n                        const Icon = item.icon;\n                        return (\n                          <a\n                            key={item.title}\n                            href={item.href}\n                            onClick={() => setIsOpen(false)}\n                            className=\"group flex items-start gap-3 rounded-xl border border-transparent p-3 transition-all hover:border-neutral-200/80 hover:bg-neutral-50 dark:hover:border-neutral-800 dark:hover:bg-neutral-900/60\"\n                          >\n                            {Icon && (\n                              <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-neutral-200/70 bg-white text-neutral-700 shadow-sm transition-transform group-hover:scale-105 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-200\">\n                                <Icon className=\"h-4 w-4\" />\n                              </div>\n                            )}\n                            <div className=\"flex-1\">\n                              <div className=\"flex items-center gap-1.5\">\n                                <span className=\"text-xs font-semibold text-neutral-900 group-hover:text-black dark:text-white dark:group-hover:text-white\">\n                                  {item.title}\n                                </span>\n                                {item.badge && (\n                                  <span className=\"rounded bg-neutral-100 px-1.5 py-0.2 text-[9px] font-semibold text-neutral-600 dark:bg-neutral-800 dark:text-neutral-300\">\n                                    {item.badge}\n                                  </span>\n                                )}\n                              </div>\n                              <p className=\"mt-0.5 text-[11px] leading-relaxed text-neutral-500 dark:text-neutral-400\">\n                                {item.description}\n                              </p>\n                            </div>\n                          </a>\n                        );\n                      })}\n                    </div>\n                  </div>\n\n                  {/* Right Section: Featured Card & Quick Links */}\n                  <div className=\"flex flex-col gap-5 border-t border-neutral-200/70 pt-6 md:border-l md:border-t-0 md:pl-6 md:pt-0 dark:border-neutral-800/70 md:col-span-4\">\n                    {currentCategoryData.featured && (\n                      <div className=\"relative overflow-hidden rounded-xl border border-neutral-200/80 bg-neutral-50/70 p-4 dark:border-neutral-800 dark:bg-neutral-900/60\">\n                        {currentCategoryData.featured.badge && (\n                          <span className=\"rounded-full bg-neutral-950 px-2 py-0.5 text-[9px] font-bold text-white dark:bg-white dark:text-neutral-950\">\n                            {currentCategoryData.featured.badge}\n                          </span>\n                        )}\n                        <h4 className=\"mt-2 text-xs font-bold text-neutral-950 dark:text-white\">\n                          {currentCategoryData.featured.title}\n                        </h4>\n                        <p className=\"mt-1 text-[11px] leading-relaxed text-neutral-500 dark:text-neutral-400\">\n                          {currentCategoryData.featured.description}\n                        </p>\n                        <a\n                          href={currentCategoryData.featured.href}\n                          onClick={() => setIsOpen(false)}\n                          className=\"mt-3 inline-flex items-center gap-1 text-xs font-bold text-neutral-900 hover:underline dark:text-white\"\n                        >\n                          <span>\n                            {currentCategoryData.featured.ctaText || \"Learn more\"}\n                          </span>\n                          <ArrowRight className=\"h-3 w-3\" />\n                        </a>\n                      </div>\n                    )}\n\n                    {currentCategoryData.quickLinks && (\n                      <div className=\"flex flex-col gap-2\">\n                        <span className=\"text-[10px] font-bold uppercase tracking-wider text-neutral-400 dark:text-neutral-500\">\n                          Quick Links\n                        </span>\n                        <ul className=\"flex flex-col gap-1.5\">\n                          {currentCategoryData.quickLinks.map((link) => (\n                            <li key={link.label}>\n                              <a\n                                href={link.href}\n                                onClick={() => setIsOpen(false)}\n                                className=\"inline-flex items-center gap-1 text-xs text-neutral-600 transition-colors hover:text-neutral-950 dark:text-neutral-400 dark:hover:text-white\"\n                              >\n                                <span>{link.label}</span>\n                                <ArrowRight className=\"h-2.5 w-2.5 opacity-60\" />\n                              </a>\n                            </li>\n                          ))}\n                        </ul>\n                      </div>\n                    )}\n                  </div>\n                </motion.div>\n              </AnimatePresence>\n            </div>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nexport default MegaMenu;\n",
      "type": "registry:ui",
      "target": "components/ui/mega-menu.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"
    }
  ]
}
