{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reactions",
  "title": "Reactions",
  "author": "Tori Bryan",
  "description": "Emoji responses to content, in one tap.",
  "dependencies": [
    "@base-ui/react",
    "class-variance-authority",
    "motion"
  ],
  "registryDependencies": [
    "https://fibo.toribryan.com/r/button.json",
    "https://fibo.toribryan.com/r/count.json",
    "utils"
  ],
  "files": [
    {
      "path": "registry/ui/reactions.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Popover as PopoverPrimitive } from \"@base-ui/react/popover\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { motion, useReducedMotion, type Variants } from \"motion/react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Count } from \"@/components/ui/count\"\nimport { mergeRefs } from \"@/lib/merge-refs\"\nimport { cn } from \"@/lib/utils\"\n\ntype Reaction = {\n  /** The emoji itself. Also the reaction's identity, so keep it unique. */\n  emoji: string\n  /** Its accessible name, such as \"Heart\". Screen readers hear this, not the emoji. */\n  label: string\n  /** How many people reacted with it. */\n  count?: number\n  /** Whether the current person is one of them. */\n  active?: boolean\n}\n\n// Used when neither `choices` nor any existing reaction gives the picker\n// something to offer. Escaped so the source stays plain ASCII.\nconst DEFAULT_CHOICES: Reaction[] = [\n  { emoji: \"\\u{1F44D}\", label: \"Thumbs up\" },\n  { emoji: \"\\u2764\\uFE0F\", label: \"Heart\" },\n  { emoji: \"\\u{1F602}\", label: \"Laughing\" },\n  { emoji: \"\\u{1F389}\", label: \"Celebrate\" },\n  { emoji: \"\\u{1F62E}\", label: \"Surprised\" },\n  { emoji: \"\\u{1F525}\", label: \"Fire\" },\n]\n\nfunction describeCount(count: number) {\n  return `${count} ${count === 1 ? \"reaction\" : \"reactions\"}`\n}\n\nconst ANCHOR =\n  \"pointer-events-none fixed z-50 flex [--edge:1rem] [--gap:0.5rem] sm:[--edge:1.5rem] sm:[--gap:1rem] lg:[--edge:2rem] lg:[--gap:2rem]\"\n\nconst reactionsVariants = cva(\"group/reactions\", {\n  variants: {\n    type: {\n      inline: \"relative flex flex-wrap items-center gap-1.5\",\n      floating: ANCHOR,\n    },\n    position: {\n      \"bottom-right\": \"\",\n      \"bottom-left\": \"\",\n      \"top-right\": \"\",\n      \"top-left\": \"\",\n    },\n  },\n  compoundVariants: [\n    {\n      type: \"floating\",\n      position: \"bottom-right\",\n      class:\n        \"right-[var(--edge)] bottom-[calc(var(--gap)+env(safe-area-inset-bottom,0px))]\",\n    },\n    {\n      type: \"floating\",\n      position: \"bottom-left\",\n      class:\n        \"bottom-[calc(var(--gap)+env(safe-area-inset-bottom,0px))] left-[var(--edge)]\",\n    },\n    {\n      type: \"floating\",\n      position: \"top-right\",\n      class:\n        \"top-[calc(var(--gap)+env(safe-area-inset-top,0px))] right-[var(--edge)]\",\n    },\n    {\n      type: \"floating\",\n      position: \"top-left\",\n      class:\n        \"top-[calc(var(--gap)+env(safe-area-inset-top,0px))] left-[var(--edge)]\",\n    },\n  ],\n  defaultVariants: {\n    type: \"inline\",\n    position: \"bottom-right\",\n  },\n})\n\n/*\n * One translucent surface for every floating piece: the bar that holds the\n * trigger and the panel that opens off it. `inset-ring` rather than `border`\n * so the ring sits inside the blur instead of drawing a hard edge around it.\n */\nconst SURFACE = \"shadow-lg backdrop-blur-md inset-ring-1 inset-ring-border\"\n\nconst RISE_EASING = \"cubic-bezier(0.22, 0.61, 0.36, 1)\"\nconst SPRING_EASING = \"cubic-bezier(0.34, 1.56, 0.64, 1)\"\n\nfunction prefersReducedMotion() {\n  return (\n    typeof window !== \"undefined\" &&\n    typeof window.matchMedia === \"function\" &&\n    window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n  )\n}\n\n/*\n * Particles are thrown into a body-level layer rather than the component tree:\n * they outlive the click that spawned them, never affect layout, and escape\n * any ancestor that clips overflow or creates a containing block. The layer\n * leaves the body with its last particle, and comes back with the next.\n */\nfunction getParticleLayer() {\n  const existing = document.querySelector<HTMLElement>(\n    '[data-slot=\"reactions-particles\"]'\n  )\n  if (existing) return existing\n\n  const layer = document.createElement(\"div\")\n  layer.setAttribute(\"data-slot\", \"reactions-particles\")\n  layer.setAttribute(\"aria-hidden\", \"true\")\n  layer.style.cssText =\n    \"position:fixed;inset:0;z-index:9999;overflow:hidden;pointer-events:none\"\n  document.body.append(layer)\n  return layer\n}\n\nfunction launchParticle(emoji: string, x: number, y: number) {\n  const layer = getParticleLayer()\n  const node = document.createElement(\"span\")\n  node.textContent = emoji\n\n  const size = 1.4 + Math.random() * 0.8\n  const rise = window.innerHeight * (0.55 + Math.random() * 0.35)\n  const sway = 24 + Math.random() * 28\n  const spin = (Math.random() - 0.5) * 40\n\n  // A trigger pinned to a corner would otherwise throw half its particles\n  // straight into the clip boundary, so drift leans back toward the center in\n  // proportion to how close the origin sits to an edge.\n  const inward = (window.innerWidth / 2 - x) / (window.innerWidth / 2)\n  const drift = (Math.random() - 0.5) * 90 + inward * 70\n  const lean =\n    Math.abs(inward) > 0.5 ? Math.sign(inward) : Math.random() < 0.5 ? -1 : 1\n\n  // The shadow is a class, not inline, so it reads a token like every other\n  // color and Tailwind sees it to generate.\n  node.className = \"[filter:drop-shadow(0_2px_6px_var(--particle-shadow))]\"\n  node.style.cssText = `position:absolute;left:${x}px;top:${y}px;font-size:${size}rem;line-height:1;will-change:transform,opacity`\n  layer.append(node)\n\n  // Sway alternates sides on the way up so the path reads as an S-curve\n  // rather than a straight line with jitter.\n  const animation = node.animate(\n    [\n      {\n        offset: 0,\n        transform: \"translate3d(0, 0, 0) scale(0.35) rotate(0deg)\",\n        opacity: 0,\n      },\n      {\n        offset: 0.12,\n        transform: `translate3d(${lean * sway * 0.35}px, ${-rise * 0.12}px, 0) scale(1.08) rotate(${spin * 0.4}deg)`,\n        opacity: 1,\n      },\n      {\n        offset: 0.38,\n        transform: `translate3d(${-lean * sway}px, ${-rise * 0.38}px, 0) scale(1) rotate(${-spin * 0.6}deg)`,\n        opacity: 1,\n      },\n      {\n        offset: 0.66,\n        transform: `translate3d(${lean * sway * 0.8 + drift * 0.5}px, ${-rise * 0.66}px, 0) scale(0.95) rotate(${spin * 0.8}deg)`,\n        opacity: 0.85,\n      },\n      {\n        offset: 1,\n        transform: `translate3d(${drift}px, ${-rise}px, 0) scale(0.6) rotate(${-spin * 0.3}deg)`,\n        opacity: 0,\n      },\n    ],\n    {\n      duration: 2200 + Math.random() * 1600,\n      easing: RISE_EASING,\n      fill: \"forwards\",\n    }\n  )\n\n  const cleanup = () => {\n    node.remove()\n    if (!layer.hasChildNodes()) layer.remove()\n  }\n  animation.finished.then(cleanup, cleanup)\n}\n\n/*\n * Staggers the launches. Each pending one is kept in `pending` so an\n * unmounted Reactions can cancel what it has not thrown yet.\n */\nfunction burst(\n  emoji: string,\n  origin: HTMLElement | null,\n  count: number,\n  pending: Set<number>\n) {\n  if (!origin || count < 1 || prefersReducedMotion()) return\n\n  const rect = origin.getBoundingClientRect()\n  const x = rect.left + rect.width / 2\n  const y = rect.top + rect.height / 2\n\n  for (let index = 0; index < count; index += 1) {\n    const jitterX = x + (Math.random() - 0.5) * 36\n    const jitterY = y + (Math.random() - 0.5) * 12\n    const id = window.setTimeout(() => {\n      pending.delete(id)\n      launchParticle(emoji, jitterX, jitterY)\n    }, index * 55)\n    pending.add(id)\n  }\n}\n\nconst FACE: Variants = {\n  closed: { scale: 1 },\n  open: {\n    scale: 1.1,\n    transition: { type: \"spring\", stiffness: 200, damping: 20 },\n  },\n}\n\n// The plus turns a quarter and grows a beat after the face swells.\nconst PLUS: Variants = {\n  closed: { rotate: 0, scale: 1 },\n  open: {\n    rotate: 90,\n    scale: 1.2,\n    transition: { type: \"spring\", stiffness: 200, damping: 20, delay: 0.1 },\n  },\n}\n\n// lucide's smile-plus, drawn here so the face and the plus move separately.\nfunction SmilePlus({ open }: { open: boolean }) {\n  const reduceMotion = useReducedMotion()\n  const state = open && !reduceMotion ? \"open\" : \"closed\"\n  return (\n    <motion.svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth={2}\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      initial={false}\n      animate={state}\n      variants={FACE}\n    >\n      <path d=\"M22 11v1a10 10 0 1 1-9-10\" />\n      <path d=\"M8 14s1.5 2 4 2 4-2 4-2\" />\n      <line x1=\"9\" x2=\"9.01\" y1=\"9\" y2=\"9\" />\n      <line x1=\"15\" x2=\"15.01\" y1=\"9\" y2=\"9\" />\n      <motion.path d=\"M16 5h6\" variants={PLUS} />\n      <motion.path d=\"M19 2v6\" variants={PLUS} />\n    </motion.svg>\n  )\n}\n\nfunction animatePill(pill: HTMLElement) {\n  if (prefersReducedMotion()) return\n\n  pill\n    .querySelector<HTMLElement>('[data-slot=\"reactions-pill-emoji\"]')\n    ?.animate(\n      [\n        { transform: \"scale(1) rotate(0deg)\" },\n        { transform: \"scale(1.45) rotate(-9deg)\", offset: 0.35 },\n        { transform: \"scale(0.93) rotate(5deg)\", offset: 0.62 },\n        { transform: \"scale(1) rotate(0deg)\" },\n      ],\n      { duration: 420, easing: SPRING_EASING }\n    )\n\n  pill\n    .querySelector<HTMLElement>('[data-slot=\"reactions-pill-count\"]')\n    ?.animate(\n      [\n        { transform: \"translateY(65%)\", opacity: 0 },\n        { transform: \"translateY(0)\", opacity: 1 },\n      ],\n      { duration: 260, easing: RISE_EASING }\n    )\n}\n\nfunction pop(element: HTMLElement) {\n  if (prefersReducedMotion()) return\n\n  element.animate(\n    [\n      { transform: \"scale(1)\" },\n      { transform: \"scale(1.4)\", offset: 0.5 },\n      { transform: \"scale(1)\" },\n    ],\n    { duration: 380, easing: SPRING_EASING }\n  )\n}\n\ntype ReactionsProps = Omit<React.ComponentProps<\"div\">, \"onChange\"> &\n  VariantProps<typeof reactionsVariants> & {\n    /** The reactions on the item. Pass it to control the state yourself. */\n    reactions?: Reaction[]\n    /** The starting reactions when uncontrolled. */\n    defaultReactions?: Reaction[]\n    /**\n     * What the picker offers. Defaults to six common reactions plus any\n     * already on the item.\n     */\n    choices?: Reaction[]\n    /** Fires with the whole new list after every change. */\n    onReactionsChange?: (reactions: Reaction[]) => void\n    /** Fires with the reaction that changed and whether it is now on. */\n    onReact?: (reaction: Reaction, active: boolean) => void\n    /** Show the count on each pill, or the total on the floating bar. */\n    showCounts?: boolean\n    /** Emoji thrown up on each new reaction. `0` turns the burst off. */\n    particles?: number\n    /** Accessible name of the button that opens the picker. */\n    triggerLabel?: string\n    /** Accessible name of the group of choices. */\n    panelLabel?: string\n    /** Locale for counts of a thousand and up. */\n    locale?: string\n  }\n\nfunction Reactions({\n  className,\n  type = \"inline\",\n  position = \"bottom-right\",\n  reactions: reactionsProp,\n  defaultReactions = [],\n  choices,\n  onReactionsChange,\n  onReact,\n  showCounts = true,\n  particles = 7,\n  triggerLabel = \"Add reaction\",\n  panelLabel = \"Pick a reaction\",\n  locale = \"en\",\n  \"aria-label\": ariaLabel = \"Reactions\",\n  ref,\n  ...props\n}: ReactionsProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null)\n  // A caller's ref would otherwise replace the one the pills are found by.\n  const mergedRootRef = React.useMemo(() => mergeRefs(rootRef, ref), [ref])\n  const panelRef = React.useRef<HTMLDivElement>(null)\n  const triggerRef = React.useRef<HTMLButtonElement>(null)\n  const badgeRef = React.useRef<HTMLSpanElement>(null)\n  const pulseNonce = React.useRef(0)\n  const launches = React.useRef(new Set<number>())\n\n  const [uncontrolled, setUncontrolled] = React.useState(defaultReactions)\n  const [pulse, setPulse] = React.useState<{ emoji: string; nonce: number }>()\n  const [open, setOpen] = React.useState(false)\n  const [announcement, setAnnouncement] = React.useState(\"\")\n\n  const isControlled = reactionsProp !== undefined\n  const items = isControlled ? reactionsProp : uncontrolled\n  // Without `choices`, the picker offers the defaults plus anything already\n  // reacted with that isn't among them.\n  const palette =\n    choices ??\n    DEFAULT_CHOICES.concat(\n      items.filter(\n        (item) => !DEFAULT_CHOICES.some((choice) => choice.emoji === item.emoji)\n      )\n    )\n  const total = items.reduce((sum, item) => sum + (item.count ?? 0), 0)\n\n  React.useEffect(() => {\n    const pending = launches.current\n    return () => {\n      pending.forEach((id) => window.clearTimeout(id))\n      pending.clear()\n    }\n  }, [])\n\n  React.useEffect(() => {\n    if (!pulse) return\n    const pill = rootRef.current?.querySelector<HTMLElement>(\n      `[data-slot=\"reactions-pill\"][data-emoji=\"${CSS.escape(pulse.emoji)}\"]`\n    )\n    if (pill) animatePill(pill)\n    if (badgeRef.current) pop(badgeRef.current)\n  }, [pulse])\n\n  function commit(next: Reaction[]) {\n    if (!isControlled) setUncontrolled(next)\n    onReactionsChange?.(next)\n  }\n\n  function toggle(reaction: Reaction, origin: HTMLElement | null) {\n    const existing = items.find((item) => item.emoji === reaction.emoji)\n    const nowActive = !existing?.active\n\n    // A reaction nobody holds any more leaves the list instead of lingering\n    // as a zero.\n    commit(\n      existing\n        ? items\n            .map((item) =>\n              item.emoji === reaction.emoji\n                ? {\n                    ...item,\n                    active: nowActive,\n                    count: Math.max(\n                      0,\n                      (item.count ?? 0) + (nowActive ? 1 : -1)\n                    ),\n                  }\n                : item\n            )\n            .filter((item) => item.active || (item.count ?? 0) > 0)\n        : [\n            ...items,\n            { ...reaction, active: true, count: (reaction.count ?? 0) + 1 },\n          ]\n    )\n\n    onReact?.(reaction, nowActive)\n    const change = `${nowActive ? \"Added\" : \"Removed\"} ${reaction.label}`\n    // The floating bar has no pills, so its total is the only count to hear.\n    setAnnouncement(\n      type === \"floating\" && showCounts\n        ? `${change}, ${describeCount(total + (nowActive ? 1 : -1))} in total`\n        : change\n    )\n    pulseNonce.current += 1\n    setPulse({ emoji: reaction.emoji, nonce: pulseNonce.current })\n    if (nowActive) burst(reaction.emoji, origin, particles, launches.current)\n  }\n\n  function rove(event: React.KeyboardEvent<HTMLDivElement>) {\n    const targets = Array.from(\n      panelRef.current?.querySelectorAll<HTMLElement>(\n        '[data-slot=\"reactions-choice\"]'\n      ) ?? []\n    )\n    if (targets.length === 0) return\n\n    const current = targets.indexOf(document.activeElement as HTMLElement)\n    const step =\n      event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowLeft\" ? -1 : 0\n\n    if (step !== 0) {\n      event.preventDefault()\n      targets[(current + step + targets.length) % targets.length]?.focus()\n      return\n    }\n\n    if (event.key === \"Home\" || event.key === \"End\") {\n      event.preventDefault()\n      const target =\n        event.key === \"Home\" ? targets[0] : targets[targets.length - 1]\n      target?.focus()\n    }\n  }\n\n  // The panel opens away from the bar's corner when floating, and above the\n  // trigger inline. Base UI flips it to whichever side has room.\n  const isBar = type === \"floating\"\n  const opensDown =\n    isBar && (position === \"top-right\" || position === \"top-left\")\n  const alignsEnd =\n    isBar && (position === \"bottom-right\" || position === \"top-right\")\n\n  const totalChip = showCounts && total > 0 && (\n    <span\n      ref={badgeRef}\n      data-slot=\"reactions-badge\"\n      className=\"inline-flex h-8 min-w-6 shrink-0 items-center justify-center px-1.5 text-xs font-medium text-muted-foreground\"\n    >\n      <Count\n        value={total}\n        notation=\"compact\"\n        locale={locale}\n        label={describeCount}\n      />\n    </span>\n  )\n\n  const trigger = (\n    <PopoverPrimitive.Trigger\n      ref={triggerRef}\n      data-slot=\"reactions-trigger\"\n      data-state={open ? \"open\" : \"closed\"}\n      aria-label={triggerLabel}\n      render={<Button variant=\"ghost\" size=\"icon-sm\" />}\n      className={cn(\n        \"group/trigger relative\",\n        type === \"inline\"\n          ? \"text-muted-foreground\"\n          : \"touch-manipulation motion-safe:active:scale-95\"\n      )}\n    >\n      <SmilePlus open={open} />\n    </PopoverPrimitive.Trigger>\n  )\n\n  return (\n    <div\n      ref={mergedRootRef}\n      data-slot=\"reactions\"\n      data-type={type}\n      role=\"group\"\n      aria-label={ariaLabel}\n      className={cn(reactionsVariants({ type, position, className }))}\n      {...props}\n    >\n      <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n        {announcement}\n      </span>\n      {type === \"inline\" &&\n        items.map((item) => (\n          <button\n            key={item.emoji}\n            type=\"button\"\n            data-slot=\"reactions-pill\"\n            data-emoji={item.emoji}\n            data-active={item.active ? \"\" : undefined}\n            aria-pressed={Boolean(item.active)}\n            aria-label={\n              showCounts\n                ? `${item.label}, ${describeCount(item.count ?? 0)}`\n                : item.label\n            }\n            onClick={(event) => toggle(item, event.currentTarget)}\n            className=\"group/pill relative inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs transition-[background-color,border-color,transform] duration-150 outline-none hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring-subtle active:translate-y-0 motion-safe:hover:-translate-y-px data-active:border-primary data-active:bg-primary-subtle\"\n          >\n            <span\n              data-slot=\"reactions-pill-emoji\"\n              aria-hidden=\"true\"\n              className=\"text-sm leading-none\"\n            >\n              {item.emoji}\n            </span>\n            {showCounts && (\n              // The pill's own name already says the count.\n              <Count\n                data-slot=\"reactions-pill-count\"\n                value={item.count ?? 0}\n                notation=\"compact\"\n                locale={locale}\n                label={null}\n                className=\"font-medium text-muted-foreground group-data-active/pill:text-primary\"\n              />\n            )}\n          </button>\n        ))}\n\n      <span\n        data-slot=\"reactions-picker\"\n        className={cn(\n          \"relative inline-flex items-center\",\n          isBar &&\n            cn(\n              \"pointer-events-auto gap-1 rounded-full bg-popover-overlay p-1.5\",\n              SURFACE\n            )\n        )}\n      >\n        {/* Base UI's popover handles outside clicks, Escape, tabbing away\n            and returning focus, and portals the panel so a card that clips\n            its overflow can't cut it off. */}\n        <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n          <PopoverPrimitive.Portal>\n            <PopoverPrimitive.Positioner\n              side={opensDown ? \"bottom\" : \"top\"}\n              align={alignsEnd ? \"end\" : \"start\"}\n              sideOffset={8}\n              collisionPadding={8}\n              className=\"isolate z-50\"\n            >\n              <PopoverPrimitive.Popup\n                ref={panelRef}\n                data-slot=\"reactions-panel\"\n                data-state={open ? \"open\" : \"closed\"}\n                aria-label={panelLabel}\n                initialFocus={() =>\n                  panelRef.current?.querySelector<HTMLElement>(\n                    '[data-slot=\"reactions-choice\"]'\n                  ) ?? true\n                }\n                onKeyDown={rove}\n                className={cn(\n                  \"flex origin-(--transform-origin) items-center gap-0.5 rounded-full bg-popover-overlay p-1 outline-hidden transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none\",\n                  SURFACE,\n                  \"data-ending-style:scale-90 data-ending-style:opacity-0 data-starting-style:scale-90 data-starting-style:opacity-0\",\n                  \"data-[side=bottom]:data-ending-style:-translate-y-2 data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=top]:data-ending-style:translate-y-2 data-[side=top]:data-starting-style:translate-y-2\"\n                )}\n              >\n                {palette.map((choice, index) => {\n                  const picked = items.find(\n                    (entry) => entry.emoji === choice.emoji\n                  )?.active\n                  return (\n                    <button\n                      key={choice.emoji}\n                      type=\"button\"\n                      data-slot=\"reactions-choice\"\n                      data-state={open ? \"open\" : \"closed\"}\n                      data-active={picked ? \"\" : undefined}\n                      aria-pressed={Boolean(picked)}\n                      aria-label={choice.label}\n                      // Staggering the entrance and reversing it on exit makes\n                      // the panel unfurl and furl rather than pop as one block.\n                      style={{\n                        transitionDelay: `${open ? index * 28 : (palette.length - 1 - index) * 16}ms`,\n                      }}\n                      onClick={(event) => {\n                        toggle(\n                          choice,\n                          isBar ? triggerRef.current : event.currentTarget\n                        )\n                        setOpen(false)\n                      }}\n                      className=\"inline-flex size-9 touch-manipulation items-center justify-center rounded-full text-lg leading-none transition-[background-color,transform,opacity] duration-200 ease-out outline-none hover:bg-muted focus-visible:ring-[3px] focus-visible:ring-ring-subtle data-[state=closed]:scale-50 data-[state=closed]:opacity-0 motion-safe:hover:scale-115 motion-safe:active:scale-95 motion-reduce:transition-none starting:scale-50 starting:opacity-0 data-active:bg-primary-subtle\"\n                    >\n                      <span aria-hidden=\"true\">{choice.emoji}</span>\n                    </button>\n                  )\n                })}\n              </PopoverPrimitive.Popup>\n            </PopoverPrimitive.Positioner>\n          </PopoverPrimitive.Portal>\n\n          {type === \"floating\" && totalChip}\n\n          {trigger}\n        </PopoverPrimitive.Root>\n      </span>\n    </div>\n  )\n}\n\nexport { Reactions, reactionsVariants, type Reaction }\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/lib/merge-refs.ts",
      "content": "import * as React from \"react\"\n\n/**\n * One callback ref that sets every ref given, so a part can keep its own\n * ref on an element and still hand the element to a caller's `ref`. Undo\n * runs through React 19's ref cleanup, which calls a function ref with\n * null and empties an object ref.\n */\nexport function mergeRefs<T>(\n  ...refs: (React.Ref<T> | undefined)[]\n): React.RefCallback<T> {\n  return (node) => {\n    const cleanups = refs.map((ref) => {\n      if (typeof ref === \"function\") {\n        const cleanup = ref(node)\n        return typeof cleanup === \"function\" ? cleanup : () => ref(null)\n      }\n      if (ref) {\n        ref.current = node\n        return () => {\n          ref.current = null\n        }\n      }\n      return undefined\n    })\n    return () => {\n      for (const cleanup of cleanups) cleanup?.()\n    }\n  }\n}\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-popover-overlay": "var(--popover-overlay)",
      "color-primary-subtle": "var(--primary-subtle)",
      "color-ring-subtle": "var(--ring-subtle)",
      "color-particle-shadow": "var(--particle-shadow)"
    },
    "light": {
      "popover-overlay": "color-mix(in oklch, var(--color-white) 85%, transparent)",
      "primary-subtle": "color-mix(in oklch, var(--color-neutral-900) 10%, transparent)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-400) 50%, transparent)",
      "particle-shadow": "color-mix(in oklch, var(--color-black) 18%, transparent)"
    },
    "dark": {
      "popover-overlay": "color-mix(in oklch, var(--color-neutral-900) 85%, transparent)",
      "primary-subtle": "color-mix(in oklch, var(--color-neutral-50) 20%, transparent)",
      "ring-subtle": "color-mix(in oklch, var(--color-neutral-500) 50%, transparent)",
      "particle-shadow": "color-mix(in oklch, var(--color-black) 18%, transparent)"
    }
  },
  "meta": {
    "tier": "special-components",
    "group": "Feedback",
    "docs": "https://fibo.toribryan.com/?path=/docs/special-components-reactions--docs"
  },
  "docs": "Docs and live examples: https://fibo.toribryan.com/?path=/docs/special-components-reactions--docs",
  "categories": [
    "special-components",
    "feedback"
  ],
  "type": "registry:ui"
}