{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fireworks",
  "type": "registry:ui",
  "title": "Fireworks",
  "description": "Autonomous firework bursts with configurable timing.",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "components/prequelui/motion.tsx",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  MotionConfig,\n  useInView as useMotionInView,\n  type Transition,\n} from \"motion/react\";\nimport { useHydratedReducedMotion } from \"@/lib/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nconst TempoContext = React.createContext(1);\n\nexport function PrequelMotionProvider({\n  tempo = 1,\n  children,\n}: {\n  tempo?: number;\n  children: React.ReactNode;\n}) {\n  const value = React.useMemo(() => Math.max(0.4, tempo), [tempo]);\n  return (\n    <TempoContext.Provider value={value}>\n      <MotionConfig reducedMotion=\"user\">{children}</MotionConfig>\n    </TempoContext.Provider>\n  );\n}\n\nexport function useTempo() {\n  return React.useContext(TempoContext);\n}\n\nconst TIME_KEYS = [\n  \"duration\",\n  \"visualDuration\",\n  \"delay\",\n  \"repeatDelay\",\n  \"delayChildren\",\n] as const;\n\nfunction scaleValue(transition: Transition, tempo: number): Transition {\n  if (tempo === 1 || !transition || typeof transition !== \"object\") {\n    return transition;\n  }\n  const next: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(transition)) {\n    if (typeof value === \"number\" && (TIME_KEYS as readonly string[]).includes(key)) {\n      next[key] = value * tempo;\n    } else if (typeof value === \"number\" && key === \"stiffness\") {\n      next[key] = value / (tempo * tempo);\n    } else if (typeof value === \"number\" && key === \"damping\") {\n      next[key] = value / tempo;\n    } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n      next[key] = scaleValue(value as Transition, tempo);\n    } else {\n      next[key] = value;\n    }\n  }\n  return next as Transition;\n}\n\nexport function useTempoTransition(transition: Transition) {\n  const tempo = useTempo();\n  return React.useMemo(\n    () => scaleValue(transition, tempo),\n    [tempo, JSON.stringify(transition)],\n  );\n}\n\nexport function useReduceMotion() {\n  return useHydratedReducedMotion();\n}\n\nexport function usePageVisible() {\n  const [visible, setVisible] = React.useState(true);\n  React.useEffect(() => {\n    const update = () => setVisible(!document.hidden);\n    update();\n    document.addEventListener(\"visibilitychange\", update);\n    return () => document.removeEventListener(\"visibilitychange\", update);\n  }, []);\n  return visible;\n}\n\nexport function useMounted() {\n  return React.useSyncExternalStore(\n    () => () => {},\n    () => true,\n    () => false,\n  );\n}\n\nexport function useSeen(\n  ref: React.RefObject<Element | null>,\n  enabled = true,\n  once = true,\n) {\n  const inView = useMotionInView(ref, { once, amount: 0.35 });\n  return enabled ? inView : true;\n}\n\ntype SlotProps = React.HTMLAttributes<HTMLElement> & {\n  children?: React.ReactNode;\n  ref?: React.Ref<HTMLElement>;\n};\n\nexport function Slot({ children, ...props }: SlotProps) {\n  if (!React.isValidElement<Record<string, unknown>>(children)) {\n    return null;\n  }\n  const child = children as React.ReactElement<Record<string, unknown>>;\n  const childProps = child.props;\n  return React.cloneElement(child, {\n    ...props,\n    ...childProps,\n    className: cn(\n      String(props.className ?? \"\"),\n      String(childProps.className ?? \"\"),\n    ),\n    style: {\n      ...((props.style as React.CSSProperties) ?? {}),\n      ...((childProps.style as React.CSSProperties) ?? {}),\n    },\n  } as Record<string, unknown>);\n}\n\nexport function srOnlyStyle(): React.CSSProperties {\n  return {\n    position: \"absolute\",\n    width: 1,\n    height: 1,\n    padding: 0,\n    margin: -1,\n    overflow: \"hidden\",\n    clip: \"rect(0, 0, 0, 0)\",\n    whiteSpace: \"nowrap\",\n    borderWidth: 0,\n  };\n}\n\nlet segmenter: Intl.Segmenter | null | undefined;\n\nexport function splitGraphemes(text: string): string[] {\n  if (segmenter === undefined) {\n    segmenter =\n      typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\"\n        ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" })\n        : null;\n  }\n  if (!segmenter) return Array.from(text);\n  return Array.from(segmenter.segment(text), (entry) => entry.segment);\n}\n\nexport const easeOut = [0.23, 1, 0.32, 1] as const;\nexport const easeSoft = [0.215, 0.61, 0.355, 1] as const;\nexport const easeInOut = [0.77, 0, 0.175, 1] as const;\nexport const easeEnter = [0.25, 0.1, 0.35, 1] as const;\nexport const easeLeave = [0, 0, 0.58, 1] as const;\nexport const easeResize = [0.4, 0, 0.1, 1] as const;\nexport const easeAway = [0.33, 0.17, 0.67, 0.5] as const;\n\nexport const pressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const selectionSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n};\n\nexport const highlightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 40,\n};\n\nexport const popSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 29,\n};\n\nexport const tooltipSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 31,\n};\n\nexport const dialogSpring: Transition = {\n  type: \"spring\",\n  stiffness: 150,\n  damping: 25,\n};\n\nexport const toastSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 24,\n};\n\nexport const heightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n  bounce: 0,\n  restDelta: 0.01,\n};\n\nexport const progressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 35,\n  restDelta: 0.01,\n  restSpeed: 0.1,\n};\n\nexport const scrollSpring: Transition = {\n  type: \"spring\",\n  stiffness: 250,\n  damping: 40,\n  bounce: 0,\n};\n\nexport const avatarSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 17,\n};\n\nexport const pinnedSpring: Transition = {\n  type: \"spring\",\n  stiffness: 320,\n  damping: 25,\n  mass: 0.8,\n};\n\nexport const thumbSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 25,\n};\n\nexport const checkSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 24,\n};\n\nexport const cursorEntry: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const cursorExit: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 46.9,\n  restSpeed: 10,\n};\n\nexport const cursorLabel: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 50,\n  bounce: 0,\n};\n\nexport const swapTween: Transition = {\n  duration: 0.15,\n  ease: easeOut,\n};\n\nexport const overlayTween: Transition = {\n  duration: 0.4,\n  ease: easeSoft,\n};\n\nexport const disclosureTween: Transition = {\n  duration: 0.35,\n  ease: easeSoft,\n};\n\nexport const menuTween: Transition = {\n  duration: 0.22,\n  ease: easeSoft,\n};\n\nexport const panelOutTween: Transition = {\n  duration: 0.15,\n  ease: easeLeave,\n};\n\nexport const panelInTween: Transition = {\n  duration: 0.3,\n  ease: easeEnter,\n};\n\nexport const panelHeightTween: Transition = {\n  duration: 0.45,\n  ease: easeResize,\n};\n\nexport const exitTween: Transition = {\n  duration: 0.2,\n  ease: easeAway,\n};\n\nexport const faceSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 20,\n};\n\nexport const blurIcon = \"blur(2px)\";\n\nexport function flipTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate =\n    side === \"top\"\n      ? \"rotateX(-20deg)\"\n      : side === \"bottom\"\n        ? \"rotateX(20deg)\"\n        : side === \"left\"\n          ? \"rotateY(20deg)\"\n          : \"rotateY(-20deg)\";\n  return `perspective(500px) ${rotate} scale(0.8)`;\n}\n\nexport function uprightTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate = side === \"left\" || side === \"right\" ? \"rotateY(0deg)\" : \"rotateX(0deg)\";\n  return `perspective(500px) ${rotate} scale(1)`;\n}\n",
      "target": "components/prequelui/motion.tsx"
    },
    {
      "path": "components/prequelui/backgrounds/shared.tsx",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { useInView } from \"motion/react\";\nimport { usePageVisible, useReduceMotion } from \"../motion\";\n\nexport function useBackgroundPlayback(ref: React.RefObject<Element | null>) {\n  const inView = useInView(ref);\n  const pageVisible = usePageVisible();\n  const reduce = useReduceMotion();\n  return {\n    inView,\n    pageVisible,\n    reduce,\n    playing: inView && pageVisible && !reduce,\n  };\n}\n\nexport function seeded(index: number, salt = 1) {\n  const value = Math.sin(index * 127.1 * salt + 311.7) * 43758.5453;\n  return value - Math.floor(value);\n}\n\nexport function useIsDark(ref: React.RefObject<Element | null>) {\n  const [dark, setDark] = React.useState(false);\n\n  React.useEffect(() => {\n    const element = ref.current;\n    if (!element) return;\n    const read = () =>\n      setDark(\n        element.classList.contains(\"dark\") ||\n          document.documentElement.classList.contains(\"dark\"),\n      );\n    read();\n    const observer = new MutationObserver(read);\n    observer.observe(document.documentElement, {\n      attributes: true,\n      attributeFilter: [\"class\", \"data-theme\", \"style\"],\n    });\n    return () => observer.disconnect();\n  }, [ref]);\n\n  return dark;\n}\n\nexport function useCanvasSize(\n  containerRef: React.RefObject<HTMLDivElement | null>,\n  canvasRef: React.RefObject<HTMLCanvasElement | null>,\n  onChange: () => void,\n) {\n  const changeRef = React.useRef(onChange);\n  changeRef.current = onChange;\n\n  React.useEffect(() => {\n    const container = containerRef.current;\n    const canvas = canvasRef.current;\n    if (!container || !canvas) return;\n\n    const resize = () => {\n      const rect = container.getBoundingClientRect();\n      const dpr = Math.max(1, Math.min(window.devicePixelRatio || 1, 2));\n      const width = Math.max(1, Math.round(rect.width * dpr));\n      const height = Math.max(1, Math.round(rect.height * dpr));\n      if (canvas.width !== width || canvas.height !== height) {\n        canvas.width = width;\n        canvas.height = height;\n      }\n      canvas.style.width = `${rect.width}px`;\n      canvas.style.height = `${rect.height}px`;\n      changeRef.current();\n    };\n\n    resize();\n    const observer = new ResizeObserver(resize);\n    observer.observe(container);\n    window.addEventListener(\"resize\", resize);\n    return () => {\n      observer.disconnect();\n      window.removeEventListener(\"resize\", resize);\n    };\n  }, [canvasRef, containerRef]);\n}\n",
      "target": "components/prequelui/backgrounds/shared.tsx"
    },
    {
      "path": "components/prequelui/backgrounds/fireworks.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { useBackgroundPlayback, useCanvasSize } from \"./shared\";\n\ntype Spark = {\n  x: number;\n  y: number;\n  vx: number;\n  vy: number;\n  alpha: number;\n  decay: number;\n  size: number;\n  color: string;\n};\n\ntype Rocket = {\n  x: number;\n  y: number;\n  vx: number;\n  vy: number;\n  target: number;\n  color: string;\n  size: number;\n  trail: { x: number; y: number }[];\n};\n\nconst PALETTE = [\"#f97316\", \"#f43f5e\", \"#a855f7\", \"#22d3ee\", \"#facc15\", \"#34d399\"];\n\nexport type FireworksBackgroundProps = React.ComponentProps<\"div\"> & {\n  speed?: number;\n  paused?: boolean;\n  interactive?: boolean;\n  population?: number;\n  colors?: string[];\n  particleCount?: number;\n};\n\nexport function FireworksBackground({\n  speed = 1,\n  paused = false,\n  interactive = true,\n  population = 1,\n  colors = PALETTE,\n  particleCount = 64,\n  className,\n  children,\n  ...props\n}: FireworksBackgroundProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const canvasRef = React.useRef<HTMLCanvasElement>(null);\n  const { playing: live, reduce } = useBackgroundPlayback(ref);\n  const playing = live && !paused;\n  const rocketsRef = React.useRef<Rocket[]>([]);\n  const sparksRef = React.useRef<Spark[]>([]);\n  const nextLaunchRef = React.useRef(0);\n  const drawRef = React.useRef<(clearOnly?: boolean) => void>(() => {});\n  const rate = Math.max(0.1, speed);\n\n  const explode = React.useCallback(\n    (x: number, y: number, color: string) => {\n      const count = Math.round(particleCount * Math.min(1.6, Math.max(0.4, rate)));\n      for (let index = 0; index < count; index++) {\n        const angle = Math.random() * Math.PI * 2;\n        const velocity = 0.9 + Math.random() * 4.4;\n        sparksRef.current.push({\n          x,\n          y,\n          vx: Math.cos(angle) * velocity,\n          vy: Math.sin(angle) * velocity,\n          alpha: 1,\n          decay: 0.005 + Math.random() * 0.01,\n          size: 1.2 + Math.random() * 2.8,\n          color,\n        });\n      }\n    },\n    [particleCount, rate],\n  );\n\n  const launch = React.useCallback(\n    (x: number, target: number, color?: string) => {\n      const canvas = canvasRef.current;\n      if (!canvas) return;\n      const rect = canvas.getBoundingClientRect();\n      rocketsRef.current.push({\n        x,\n        y: rect.height * 1.02,\n        vx: (Math.random() - 0.5) * 0.7,\n        vy: -(3.4 + Math.random() * 2.2) * rate,\n        target,\n        color: color ?? colors[Math.floor(Math.random() * colors.length)] ?? PALETTE[0],\n        size: 1.8 + Math.random() * 1.8,\n        trail: [],\n      });\n    },\n    [colors, rate],\n  );\n\n  const draw = React.useCallback(() => {\n    const canvas = canvasRef.current;\n    if (!canvas) return;\n    const ctx = canvas.getContext(\"2d\");\n    if (!ctx) return;\n    const rect = canvas.getBoundingClientRect();\n    const width = rect.width;\n    const height = rect.height;\n    if (width < 2 || height < 2) return;\n    const dpr = canvas.width / Math.max(1, width);\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.clearRect(0, 0, width, height);\n\n    const background = ctx.createRadialGradient(\n      width / 2,\n      height * 0.8,\n      0,\n      width / 2,\n      height * 0.8,\n      Math.max(width, height) * 0.8,\n    );\n    background.addColorStop(0, \"#10101c\");\n    background.addColorStop(1, \"#040408\");\n    ctx.fillStyle = background;\n    ctx.fillRect(0, 0, width, height);\n\n    ctx.globalCompositeOperation = \"lighter\";\n    for (const rocket of rocketsRef.current) {\n      if (rocket.trail.length > 1) {\n        ctx.beginPath();\n        ctx.moveTo(rocket.trail[0]!.x, rocket.trail[0]!.y);\n        for (const point of rocket.trail) ctx.lineTo(point.x, point.y);\n        ctx.strokeStyle = rocket.color;\n        ctx.lineWidth = rocket.size;\n        ctx.lineCap = \"round\";\n        ctx.globalAlpha = 0.9;\n        ctx.stroke();\n      }\n    }\n    for (const spark of sparksRef.current) {\n      ctx.globalAlpha = Math.max(0, spark.alpha);\n      ctx.fillStyle = spark.color;\n      ctx.beginPath();\n      ctx.arc(spark.x, spark.y, spark.size, 0, Math.PI * 2);\n      ctx.fill();\n    }\n    ctx.globalAlpha = 1;\n    ctx.globalCompositeOperation = \"source-over\";\n  }, []);\n\n  drawRef.current = draw;\n\n  useCanvasSize(ref, canvasRef, () => {\n    if (reduce) {\n      sparksRef.current = [];\n      rocketsRef.current = [];\n      const rect = canvasRef.current?.getBoundingClientRect();\n      if (rect) {\n        const spots = [0.3, 0.5, 0.72];\n        for (const spot of spots) {\n          explode(rect.width * spot, rect.height * (0.3 + Math.random() * 0.25), colors[0] ?? PALETTE[0]);\n        }\n        for (let step = 0; step < 22; step++) {\n          for (const spark of sparksRef.current) {\n            spark.x += spark.vx;\n            spark.y += spark.vy;\n            spark.vy += 0.05;\n            spark.vx *= 0.985;\n            spark.vy *= 0.985;\n            spark.alpha *= 0.94;\n          }\n        }\n      }\n      drawRef.current();\n    }\n  });\n\n  React.useEffect(() => {\n    if (!playing) {\n      if (reduce) drawRef.current();\n      return;\n    }\n    let frame = 0;\n    let last = performance.now();\n    const first = canvasRef.current?.getBoundingClientRect();\n    if (first) {\n      explode(\n        first.width * 0.5,\n        first.height * 0.3,\n        colors[1] ?? colors[0] ?? PALETTE[0],\n      );\n      nextLaunchRef.current = performance.now() + 260;\n    }\n    const tick = (now: number) => {\n      const delta = Math.min(64, now - last);\n      last = now;\n      const canvas = canvasRef.current;\n      if (!canvas) return;\n      const rect = canvas.getBoundingClientRect();\n      if (now > nextLaunchRef.current) {\n        if (population > 0 && Math.random() < population) {\n          launch(\n            rect.width * (0.12 + Math.random() * 0.76),\n            rect.height * (0.12 + Math.random() * 0.3),\n          );\n        }\n        nextLaunchRef.current = now + (260 + Math.random() * 520) / Math.max(0.2, population);\n      }\n      for (let index = rocketsRef.current.length - 1; index >= 0; index--) {\n        const rocket = rocketsRef.current[index]!;\n        rocket.trail.push({ x: rocket.x, y: rocket.y });\n        if (rocket.trail.length > 18) rocket.trail.shift();\n        rocket.x += rocket.vx * rate;\n        rocket.y += rocket.vy * rate;\n        rocket.vy += 0.028 * delta * 0.06;\n        if (rocket.vy >= 0 || rocket.y <= rocket.target) {\n          explode(rocket.x, rocket.y, rocket.color);\n          rocketsRef.current.splice(index, 1);\n        }\n      }\n      for (let index = sparksRef.current.length - 1; index >= 0; index--) {\n        const spark = sparksRef.current[index]!;\n        spark.vx *= 0.985;\n        spark.vy *= 0.985;\n        spark.vy += 0.045;\n        spark.x += spark.vx * rate;\n        spark.y += spark.vy * rate;\n        spark.alpha -= spark.decay;\n        if (spark.alpha <= 0) sparksRef.current.splice(index, 1);\n      }\n      drawRef.current();\n      frame = requestAnimationFrame(tick);\n    };\n    frame = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(frame);\n  }, [explode, launch, playing, population, rate, reduce]);\n\n  return (\n    <div\n      ref={ref}\n      data-slot=\"fireworks-background\"\n      className={cn(\"relative size-full overflow-hidden bg-[#040408]\", className)}\n      {...props}\n      onClick={(event) => {\n        if (!interactive || !playing) return;\n        const rect = event.currentTarget.getBoundingClientRect();\n        launch(event.clientX - rect.left, event.clientY - rect.top);\n      }}\n    >\n      <canvas ref={canvasRef} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" />\n      {children}\n    </div>\n  );\n}\n",
      "target": "components/prequelui/backgrounds/fireworks.tsx"
    },
    {
      "path": "lib/use-reduced-motion.ts",
      "target": "lib/use-reduced-motion.ts",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport { useReducedMotion } from \"motion/react\";\nimport { useSyncExternalStore } from \"react\";\n\nconst subscribe = () => () => {};\n\nexport function useHydratedReducedMotion() {\n  const reduce = useReducedMotion() ?? false;\n  const mounted = useSyncExternalStore(\n    subscribe,\n    () => true,\n    () => false,\n  );\n  return mounted ? reduce : false;\n}\n"
    }
  ]
}
