{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tooltip",
  "title": "Tooltip",
  "description": "Dark, light, tone, glass and neo tooltips with sizes, shapes, shadows and an optional arrow; twelve placements that flip and shift at the screen edge, scale, fade, slide or spring entrances, rich title + keyboard-shortcut content, delay groups that open instantly after the first, follow-cursor for charts and touch long-press.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/kbd.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/core/tooltip.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { AnimatePresence, motion, useReducedMotion, type TargetAndTransition, type Transition } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { Kbd } from \"@/components/goodui/kbd\"\nimport { spring, ease as easing } from \"@/lib/goodui-motion\"\n\n/*\n * One tooltip, independent layers: every axis combines with every other.\n *   variant    dark, light, tone, glass, neo            tone       color for tone and neo\n *   size       sm, md, lg                               shape      square, rounded, pill\n *   shadow     none → lg                                animation  none, fade, scale, slide, spring\n *   placement  side (top, bottom, left, right, start, end) × align (start, center, end), flips and shifts to stay on screen\n *   content    text, or title + body + keyboard shortcut; arrow on or off; follows the cursor if asked\n * Opens on hover (after delay), keyboard focus (at once) and touch long-press. Esc closes it. Wrap neighbours in\n * <TooltipGroup> so the first tooltip waits and the next ones open instantly.\n */\n\nexport type TooltipVariant = \"dark\" | \"light\" | \"tone\" | \"glass\" | \"neo\"\nexport type TooltipTone = \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type TooltipSize = \"sm\" | \"md\" | \"lg\"\nexport type TooltipShape = \"square\" | \"rounded\" | \"pill\"\nexport type TooltipShadow = \"none\" | \"sm\" | \"md\" | \"lg\"\nexport type TooltipAnimation = \"none\" | \"fade\" | \"scale\" | \"slide\" | \"spring\"\n/** start and end follow the reading direction (left/right in LTR, right/left in RTL). */\nexport type TooltipSide = \"top\" | \"bottom\" | \"left\" | \"right\" | \"start\" | \"end\"\nexport type TooltipAlign = \"start\" | \"center\" | \"end\"\n\nexport type TooltipLabels = {\n  /** Read before the keyboard shortcut: \"Shortcut: Ctrl K\". */\n  shortcut: string\n}\nconst DEFAULT_LABELS: TooltipLabels = { shortcut: \"Shortcut\" }\n\ntype TriggerProps = React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> }\ntype MotionSafe = \"onAnimationStart\" | \"onAnimationEnd\" | \"onAnimationIteration\" | \"onDrag\" | \"onDragStart\" | \"onDragEnd\" | \"onDragEnter\" | \"onDragLeave\" | \"onDragOver\" | \"onDrop\" | \"onDragExit\"\n\nexport type TooltipProps = Omit<React.ComponentProps<\"div\">, \"title\" | \"content\" | \"children\" | MotionSafe> & {\n  /** The trigger: one element (a button, an icon, a link). Text is wrapped in a focusable span. */\n  children: React.ReactNode\n  /** Tooltip body (with a title, the muted second line). */\n  content?: React.ReactNode\n  /** Bold first line for rich tooltips; content becomes the muted second line. */\n  title?: React.ReactNode\n  /** Keyboard shortcut shown as keycaps: \"Mod+K\" or [\"Shift\", \"D\"]. Mod is ⌘ on Mac and Ctrl elsewhere. */\n  shortcut?: string | string[]\n  /** Paint: dark (default, dark in both themes), light (light in both themes), tone (filled with the tone), glass, neo. */\n  variant?: TooltipVariant\n  /** Color for the tone and neo variants. */\n  tone?: TooltipTone\n  size?: TooltipSize\n  shape?: TooltipShape\n  /** Drop shadow. Ignored by neo, which has its own offset shadow. */\n  shadow?: TooltipShadow\n  /** How it appears: scale (default), fade, slide, spring or none. Reduced motion uses a short fade. */\n  animation?: TooltipAnimation\n  /** Preferred side; flips to the opposite side when there is no room. */\n  side?: TooltipSide\n  /** Alignment along the side. start/end follow the reading direction. */\n  align?: TooltipAlign\n  /** Gap between trigger and tooltip, in px. */\n  offset?: number\n  arrow?: boolean\n  /** Hover delay before opening, in ms. Inside a TooltipGroup the group's delay is used. Focus opens at once. */\n  delay?: number\n  /** Grace period before closing after the pointer leaves, so the pointer can move onto the tooltip, in ms. */\n  closeDelay?: number\n  /** Touch: how long to press before the tooltip shows, in ms. It hides 1.5 s after release or on the next tap. */\n  longPressDelay?: number\n  /** Position at the pointer and follow it while it moves over the trigger (charts, heatmaps). */\n  followCursor?: boolean\n  /** Open state (controlled). */\n  open?: boolean\n  /** Initial open state when uncontrolled. */\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n  /** Never open. */\n  disabled?: boolean\n  /** Render into document.body so overflow and z-index of parents can't clip it. */\n  portal?: boolean\n  /** Text for screen readers; pass translations here. */\n  labels?: Partial<TooltipLabels>\n}\n\n/* ---------- group: instant after the first ---------- */\n\ntype GroupValue = { delay: number; isWarm: () => boolean; opened: (close: () => void) => void; closed: (close: () => void) => void }\nconst GroupContext = React.createContext<GroupValue | null>(null)\n\nexport type TooltipGroupProps = {\n  /** Delay before the first tooltip in the group opens, in ms. */\n  delay?: number\n  /** After a tooltip closes, how long the next one still opens instantly, in ms. */\n  skipDelay?: number\n  children: React.ReactNode\n}\n\n/** Shares one open delay across tooltips (a toolbar): once one is open, moving to a neighbour shows its tooltip at once. Only one is open at a time. */\nexport function TooltipGroup({ delay = 500, skipDelay = 400, children }: TooltipGroupProps) {\n  const current = React.useRef<(() => void) | null>(null)\n  const warmUntil = React.useRef(0)\n  const value = React.useMemo<GroupValue>(\n    () => ({\n      delay,\n      isWarm: () => current.current !== null || performance.now() < warmUntil.current,\n      opened: (close) => {\n        if (current.current && current.current !== close) current.current()\n        current.current = close\n      },\n      closed: (close) => {\n        if (current.current === close) current.current = null\n        warmUntil.current = performance.now() + skipDelay\n      },\n    }),\n    [delay, skipDelay],\n  )\n  return <GroupContext.Provider value={value}>{children}</GroupContext.Provider>\n}\n\n/* ---------- positioning: flip + shift, written for this component ---------- */\n\ntype Side = \"top\" | \"bottom\" | \"left\" | \"right\"\ntype Box = { x: number; y: number; width: number; height: number }\ntype Placed = { x: number; y: number; side: Side; arrow: number; rtl: boolean }\nconst OPPOSITE: Record<Side, Side> = { top: \"bottom\", bottom: \"top\", left: \"right\", right: \"left\" }\nconst clamp = (v: number, lo: number, hi: number) => Math.min(Math.max(v, lo), Math.max(lo, hi))\n\nfunction place(a: Box, w: number, h: number, want: Side, align: TooltipAlign, offset: number, rtl: boolean, arrowPad: number): Placed {\n  const pad = 8\n  const vw = document.documentElement.clientWidth\n  const vh = window.innerHeight\n  const at = (s: Side) => {\n    if (s === \"top\" || s === \"bottom\") {\n      const y = s === \"top\" ? a.y - h - offset : a.y + a.height + offset\n      const start = rtl ? a.x + a.width - w : a.x\n      const end = rtl ? a.x : a.x + a.width - w\n      return { x: align === \"center\" ? a.x + a.width / 2 - w / 2 : align === \"start\" ? start : end, y }\n    }\n    const x = s === \"left\" ? a.x - w - offset : a.x + a.width + offset\n    return { x, y: align === \"center\" ? a.y + a.height / 2 - h / 2 : align === \"start\" ? a.y : a.y + a.height - h }\n  }\n  const over = (s: Side, p: { x: number; y: number }) =>\n    s === \"top\" ? pad - p.y : s === \"bottom\" ? p.y + h - (vh - pad) : s === \"left\" ? pad - p.x : p.x + w - (vw - pad)\n  let side = want\n  let p = at(want)\n  if (over(want, p) > 0) {\n    const q = at(OPPOSITE[want])\n    if (over(OPPOSITE[want], q) < over(want, p)) {\n      side = OPPOSITE[want]\n      p = q\n    }\n  }\n  const vertical = side === \"top\" || side === \"bottom\"\n  if (vertical) p.x = clamp(p.x, pad, vw - pad - w)\n  else p.y = clamp(p.y, pad, vh - pad - h)\n  const arrow = vertical ? clamp(a.x + a.width / 2 - p.x, arrowPad, w - arrowPad) : clamp(a.y + a.height / 2 - p.y, arrowPad, h - arrowPad)\n  return { x: p.x, y: p.y, side, arrow, rtl }\n}\n\n/* ---------- look ---------- */\n\nconst CSS = `\n.pc-tooltip{--pc-c:var(--primary);--pc-fg:var(--primary-foreground)}\n.pc-tooltip[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.pc-tooltip[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.pc-tooltip[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.pc-tooltip[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.pc-tooltip[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .pc-tooltip[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .pc-tooltip[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .pc-tooltip[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.pc-tooltip{--pc-tint:color-mix(in oklab,var(--pc-c) 14%,transparent);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.pc-tooltip[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n\n.pc-tooltip{--pc-bg:oklch(0.22 0.006 286);--pc-tx:oklch(0.985 0 0);--pc-bd:oklch(0.22 0.006 286);--pc-bw:1px;--pc-as:9px;position:relative;background:var(--pc-bg);color:var(--pc-tx);border:var(--pc-bw) solid var(--pc-bd);overflow-wrap:break-word}\n.dark .pc-tooltip[data-variant=dark]{--pc-bg:oklch(0.3 0.008 286);--pc-bd:oklch(0.38 0.008 286)}\n.pc-tooltip[data-variant=light]{--pc-bg:#fff;--pc-tx:oklch(0.21 0.006 286);--pc-bd:oklch(0.9 0.004 286)}\n.pc-tooltip[data-variant=tone]{--pc-bg:var(--pc-c);--pc-tx:var(--pc-fg);--pc-bd:var(--pc-c)}\n.pc-tooltip[data-variant=glass]{--pc-bg:color-mix(in oklab,var(--background) 62%,transparent);--pc-tx:var(--foreground);--pc-bd:color-mix(in oklab,var(--foreground) 14%,transparent);-webkit-backdrop-filter:blur(14px) saturate(1.7);backdrop-filter:blur(14px) saturate(1.7)}\n.pc-tooltip[data-variant=neo]{--pc-bg:color-mix(in oklab,var(--pc-c) 16%,var(--background));--pc-tx:var(--foreground);--pc-bd:var(--foreground);--pc-bw:2px;--pc-as:10px}\n.pc-tooltip[data-variant=neo][data-tone=neutral]{--pc-bg:var(--background)}\n.pc-tooltip-motion[data-variant=neo]{filter:drop-shadow(3px 3px 0 var(--foreground))}\n.pc-tooltip[data-shadow=sm]{box-shadow:0 1px 3px rgb(0 0 0/.14)}\n.pc-tooltip[data-shadow=md]{box-shadow:0 6px 18px -6px rgb(0 0 0/.3),0 2px 4px -2px rgb(0 0 0/.12)}\n.pc-tooltip[data-shadow=lg]{box-shadow:0 14px 34px -10px rgb(0 0 0/.38),0 4px 8px -4px rgb(0 0 0/.14)}\n.pc-tooltip[data-variant=neo]{box-shadow:none}\n.pc-tooltip-sub{opacity:.78}\n.pc-tooltip[data-variant=light] .pc-tooltip-sub,.pc-tooltip[data-variant=glass] .pc-tooltip-sub,.pc-tooltip[data-variant=neo] .pc-tooltip-sub{opacity:.72}\n\n/* The arrow is a rotated square clipped to its outer half, centered on the edge so it covers the border there. */\n.pc-tooltip-arrow{position:absolute;width:var(--pc-as);height:var(--pc-as);background:var(--pc-bg);border:var(--pc-bw) solid var(--pc-bd);transform:rotate(45deg);pointer-events:none}\n.pc-tooltip[data-variant=glass] .pc-tooltip-arrow{background:color-mix(in oklab,var(--background) 86%,transparent)}\n.pc-tooltip-arrow[data-side=top]{top:calc(100% - var(--pc-as) / 2);clip-path:polygon(100% 0,100% 100%,0 100%)}\n.pc-tooltip-arrow[data-side=bottom]{top:calc(var(--pc-as) / -2);clip-path:polygon(0 0,100% 0,0 100%)}\n.pc-tooltip-arrow[data-side=left]{left:calc(100% - var(--pc-as) / 2);clip-path:polygon(0 0,100% 0,100% 100%)}\n.pc-tooltip-arrow[data-side=right]{left:calc(var(--pc-as) / -2);clip-path:polygon(0 0,100% 100%,0 100%)}\n\n/* Keycaps take the tooltip's colors instead of the page's. */\n.pc-tooltip .pc-tooltip-kbd .pc-kbd[data-variant][data-tone] .pc-kbd-key{color:inherit;background:color-mix(in oklab,currentColor 13%,transparent);border:1px solid color-mix(in oklab,currentColor 22%,transparent);box-shadow:none;transform:none}\n.pc-tooltip .pc-tooltip-kbd .pc-kbd .pc-kbd-sep{color:inherit;opacity:.6}\n`\n\nconst SIZES: Record<TooltipSize, string> = {\n  sm: \"px-2 py-1 text-xs max-w-56\",\n  md: \"px-2.5 py-1.5 text-[13px] leading-snug max-w-64\",\n  lg: \"px-3 py-2 text-sm max-w-80\",\n}\nconst RICH: Record<TooltipSize, string> = { sm: \"px-2.5 py-2\", md: \"px-3 py-2.5\", lg: \"px-3.5 py-3\" }\nconst SHAPES: Record<TooltipShape, string> = { square: \"rounded-none\", rounded: \"rounded-md\", pill: \"rounded-full\" }\n\nfunction mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {\n  return (el: T | null) => {\n    for (const r of refs) {\n      if (typeof r === \"function\") r(el)\n      else if (r) (r as React.RefObject<T | null>).current = el\n    }\n  }\n}\n\nconst focusVisible = (el: Element) => {\n  try {\n    return el.matches(\":focus-visible\")\n  } catch {\n    return true\n  }\n}\n\nexport function Tooltip({\n  children,\n  content,\n  title,\n  shortcut,\n  variant = \"dark\",\n  tone = \"primary\",\n  size = \"md\",\n  shape = \"rounded\",\n  shadow = \"md\",\n  animation = \"scale\",\n  side = \"top\",\n  align = \"center\",\n  offset = 8,\n  arrow = true,\n  delay = 500,\n  closeDelay = 100,\n  longPressDelay = 500,\n  followCursor = false,\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  disabled = false,\n  portal = true,\n  labels,\n  className,\n  ...props\n}: TooltipProps) {\n  const l = useLabels(\"tooltip\", DEFAULT_LABELS, labels)\n  const group = React.useContext(GroupContext)\n  const prefersReduced = useReducedMotion()\n  const [mounted, setMounted] = React.useState(false)\n  React.useEffect(() => setMounted(true), [])\n  const reduce = mounted && !!prefersReduced\n\n  const id = React.useId()\n  const tipId = id + \"-tip\"\n  const descId = id + \"-desc\"\n\n  const [inner, setInner] = React.useState(defaultOpen)\n  const open = !disabled && (openProp ?? inner)\n  const [instant, setInstant] = React.useState(false)\n\n  const trigger = React.useRef<HTMLElement | null>(null)\n  const floating = React.useRef<HTMLDivElement>(null)\n  const cursor = React.useRef<{ x: number; y: number } | null>(null)\n  const timers = React.useRef({ open: 0, close: 0, press: 0, touchHide: 0 })\n  const press = React.useRef({ x: 0, y: 0, fired: false })\n\n  // Latest values for timers and listeners.\n  const live = React.useRef({ open, openProp, onOpenChange, delay, group })\n  React.useLayoutEffect(() => {\n    live.current = { open, openProp, onOpenChange, delay, group }\n  })\n\n  const setOpen = React.useCallback((o: boolean) => {\n    const c = live.current\n    if (c.open === o) return\n    if (c.openProp === undefined) setInner(o)\n    c.onOpenChange?.(o)\n  }, [])\n  const show = React.useCallback(\n    (immediate = false) => {\n      const t = timers.current\n      window.clearTimeout(t.close)\n      window.clearTimeout(t.touchHide)\n      if (live.current.open) return\n      const g = live.current.group\n      const warm = g?.isWarm() ?? false\n      const wait = immediate || warm ? 0 : (g?.delay ?? live.current.delay)\n      const go = () => {\n        setInstant(warm)\n        setOpen(true)\n      }\n      window.clearTimeout(t.open)\n      if (wait <= 0) go()\n      else t.open = window.setTimeout(go, wait)\n    },\n    [setOpen],\n  )\n  const hide = React.useCallback(\n    (wait = 0) => {\n      const t = timers.current\n      window.clearTimeout(t.open)\n      window.clearTimeout(t.close)\n      if (wait > 0) t.close = window.setTimeout(() => setOpen(false), wait)\n      else setOpen(false)\n    },\n    [setOpen],\n  )\n\n  React.useEffect(() => {\n    const t = timers.current\n    return () => {\n      window.clearTimeout(t.open)\n      window.clearTimeout(t.close)\n      window.clearTimeout(t.press)\n      window.clearTimeout(t.touchHide)\n    }\n  }, [])\n\n  // One open tooltip per group; Esc closes (capture phase, so a dialog behind it stays open); a tap elsewhere closes.\n  React.useEffect(() => {\n    if (!open) return\n    const close = () => hide()\n    group?.opened(close)\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\") return\n      e.stopPropagation()\n      hide()\n    }\n    const onDown = (e: PointerEvent) => {\n      if (!trigger.current?.contains(e.target as Node) && !floating.current?.contains(e.target as Node)) hide()\n    }\n    window.addEventListener(\"keydown\", onKey, true)\n    document.addEventListener(\"pointerdown\", onDown)\n    return () => {\n      group?.closed(close)\n      window.removeEventListener(\"keydown\", onKey, true)\n      document.removeEventListener(\"pointerdown\", onDown)\n    }\n  }, [open, group, hide])\n\n  /* positioning */\n  const [pos, setPos] = React.useState<Placed | null>(null)\n  const arrowPad = shape === \"pill\" ? 16 : 10\n  const update = React.useCallback(() => {\n    const el = floating.current\n    const t = trigger.current\n    if (!el || !t) return\n    const c = cursor.current\n    const r = t.getBoundingClientRect()\n    const a: Box = followCursor && c ? { x: c.x, y: c.y, width: 0, height: 0 } : { x: r.left, y: r.top, width: r.width, height: r.height }\n    const rtl = getComputedStyle(t).direction === \"rtl\"\n    const s: Side = side === \"start\" ? (rtl ? \"right\" : \"left\") : side === \"end\" ? (rtl ? \"left\" : \"right\") : side\n    const next = place(a, el.offsetWidth, el.offsetHeight, s, align, followCursor ? offset + 6 : offset, rtl, arrowPad)\n    setPos((p) =>\n      p && Math.abs(p.x - next.x) < 0.5 && Math.abs(p.y - next.y) < 0.5 && p.side === next.side && Math.abs(p.arrow - next.arrow) < 0.5 && p.rtl === next.rtl ? p : next,\n    )\n  }, [followCursor, side, align, offset, arrowPad])\n\n  React.useLayoutEffect(() => {\n    if (!open || !mounted) return\n    update()\n    const on = () => update()\n    window.addEventListener(\"scroll\", on, { capture: true, passive: true })\n    window.addEventListener(\"resize\", on)\n    const ro = new ResizeObserver(on)\n    if (floating.current) ro.observe(floating.current)\n    if (trigger.current) ro.observe(trigger.current)\n    return () => {\n      window.removeEventListener(\"scroll\", on, { capture: true })\n      window.removeEventListener(\"resize\", on)\n      ro.disconnect()\n    }\n  }, [open, mounted, update])\n\n  /* trigger wiring */\n  const child: React.ReactElement<TriggerProps> = React.isValidElement<TriggerProps>(children) ? children : <span tabIndex={0}>{children}</span>\n  const cp = child.props\n  const describedBy = mounted ? [cp[\"aria-describedby\"], open ? tipId : descId].filter(Boolean).join(\" \") : cp[\"aria-describedby\"]\n\n  const triggerEl = React.cloneElement(child, {\n    ref: mergeRefs(cp.ref, (el: HTMLElement | null) => {\n      trigger.current = el\n    }),\n    \"aria-describedby\": describedBy || undefined,\n    onPointerEnter: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerEnter?.(e)\n      if (e.pointerType === \"touch\") return\n      cursor.current = { x: e.clientX, y: e.clientY }\n      show()\n    },\n    onPointerMove: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerMove?.(e)\n      if (e.pointerType === \"touch\") {\n        if (Math.hypot(e.clientX - press.current.x, e.clientY - press.current.y) > 10) window.clearTimeout(timers.current.press)\n        return\n      }\n      if (followCursor) {\n        cursor.current = { x: e.clientX, y: e.clientY }\n        if (live.current.open) update()\n      }\n    },\n    onPointerLeave: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerLeave?.(e)\n      if (e.pointerType === \"touch\") return\n      hide(followCursor ? 0 : closeDelay)\n    },\n    onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerDown?.(e)\n      if (e.pointerType !== \"touch\") {\n        hide()\n        return\n      }\n      press.current = { x: e.clientX, y: e.clientY, fired: false }\n      cursor.current = { x: e.clientX, y: e.clientY }\n      window.clearTimeout(timers.current.press)\n      timers.current.press = window.setTimeout(() => {\n        press.current.fired = true\n        show(true)\n      }, longPressDelay)\n    },\n    onPointerUp: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerUp?.(e)\n      if (e.pointerType !== \"touch\") return\n      window.clearTimeout(timers.current.press)\n      if (press.current.fired) timers.current.touchHide = window.setTimeout(() => hide(), 1500)\n    },\n    onPointerCancel: (e: React.PointerEvent<HTMLElement>) => {\n      cp.onPointerCancel?.(e)\n      window.clearTimeout(timers.current.press)\n    },\n    onContextMenu: (e: React.MouseEvent<HTMLElement>) => {\n      // A long-press shows the tooltip instead of the system menu.\n      if (press.current.fired) e.preventDefault()\n      cp.onContextMenu?.(e)\n    },\n    onClick: (e: React.MouseEvent<HTMLElement>) => {\n      // The release after a long-press is not a tap on the button.\n      if (press.current.fired) {\n        press.current.fired = false\n        e.preventDefault()\n        return\n      }\n      cp.onClick?.(e)\n    },\n    onFocus: (e: React.FocusEvent<HTMLElement>) => {\n      cp.onFocus?.(e)\n      if (focusVisible(e.currentTarget)) show(true)\n    },\n    onBlur: (e: React.FocusEvent<HTMLElement>) => {\n      cp.onBlur?.(e)\n      hide()\n    },\n  })\n\n  /* motion */\n  const s: Side = pos?.side ?? (side === \"start\" ? \"left\" : side === \"end\" ? \"right\" : side)\n  const away = { top: { y: 5 }, bottom: { y: -5 }, left: { x: 5 }, right: { x: -5 } }[s]\n  const still = reduce || animation === \"none\" || instant\n  let enter: TargetAndTransition = {}\n  let leave: TargetAndTransition = {}\n  let from: TargetAndTransition = {}\n  let move: Transition = { duration: 0 }\n  if (!still) {\n    if (animation === \"scale\") {\n      from = { scale: 0.9 }\n      enter = { scale: 1 }\n      leave = { scale: 0.95 }\n      move = { duration: 0.16, ease: easing.out }\n    } else if (animation === \"slide\") {\n      from = { ...away }\n      enter = { x: 0, y: 0 }\n      leave = { x: (away.x ?? 0) / 2, y: (away.y ?? 0) / 2 }\n      move = { duration: 0.2, ease: easing.out }\n    } else if (animation === \"spring\") {\n      from = { scale: 0.55, x: (away.x ?? 0) * 1.6, y: (away.y ?? 0) * 1.6 }\n      enter = { scale: 1, x: 0, y: 0 }\n      leave = { scale: 0.9 }\n      move = spring.play\n    }\n  }\n  const fade: Transition = animation === \"none\" && !reduce ? { duration: 0 } : { duration: instant ? 0.06 : reduce ? 0.1 : 0.14 }\n  const origin = pos\n    ? s === \"top\"\n      ? `${pos.arrow}px 100%`\n      : s === \"bottom\"\n        ? `${pos.arrow}px 0`\n        : s === \"left\"\n          ? `100% ${pos.arrow}px`\n          : `0 ${pos.arrow}px`\n    : \"50% 50%\"\n\n  const rich = title !== undefined && title !== null\n  const keys = shortcut ? (\n    <span className=\"pc-tooltip-kbd inline-flex shrink-0 items-center\">\n      <span className=\"sr-only\">{l.shortcut}: </span>\n      <Kbd keys={shortcut} variant=\"flat\" size={size === \"lg\" ? \"sm\" : \"xs\"} animation=\"none\" />\n    </span>\n  ) : null\n  const body = rich ? (\n    <span className=\"flex min-w-0 flex-col gap-0.5 text-start\">\n      <span className=\"flex items-center justify-between gap-3 font-semibold\">\n        <span className=\"min-w-0\">{title}</span>\n        {keys}\n      </span>\n      {content !== undefined && content !== null && <span className=\"pc-tooltip-sub\">{content}</span>}\n    </span>\n  ) : (\n    <span className=\"flex items-center gap-2 text-start\">\n      <span className=\"min-w-0\">{content}</span>\n      {keys}\n    </span>\n  )\n\n  const layer = (\n    <>\n      {mounted && !open && (\n        <span id={descId} hidden>\n          {body}\n        </span>\n      )}\n      <AnimatePresence>\n        {open && mounted && (\n          <div\n            key=\"tip\"\n            ref={floating}\n            data-slot=\"tooltip-positioner\"\n            dir={pos ? (pos.rtl ? \"rtl\" : \"ltr\") : undefined}\n            className={cn(\"fixed top-0 left-0 z-50 w-max\", followCursor && \"pointer-events-none\")}\n            style={{ transform: pos ? `translate3d(${Math.round(pos.x)}px,${Math.round(pos.y)}px,0)` : undefined, visibility: pos ? undefined : \"hidden\" }}\n            onPointerEnter={() => window.clearTimeout(timers.current.close)}\n            onPointerLeave={(e) => e.pointerType !== \"touch\" && hide(closeDelay)}\n          >\n            <motion.div\n              className=\"pc-tooltip-motion\"\n              data-variant={variant}\n              initial={from}\n              animate={enter}\n              exit={{ ...leave, transition: still ? { duration: 0 } : { duration: 0.1 } }}\n              transition={move}\n              style={{ transformOrigin: origin }}\n            >\n              <motion.div\n                {...props}\n                id={tipId}\n                role=\"tooltip\"\n                data-slot=\"tooltip\"\n                data-variant={variant}\n                data-tone={tone}\n                data-shadow={shadow}\n                data-side={s}\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0, transition: animation === \"none\" && !reduce ? { duration: 0 } : { duration: 0.1 } }}\n                transition={fade}\n                className={cn(\"pc-tooltip w-max font-medium\", SIZES[size], rich && RICH[size], shape === \"pill\" && rich ? \"rounded-2xl\" : SHAPES[shape], size === \"lg\" && shape === \"rounded\" && \"rounded-lg\", className)}\n              >\n                {body}\n                {arrow && pos && (\n                  <span\n                    aria-hidden=\"true\"\n                    data-slot=\"tooltip-arrow\"\n                    data-side={s}\n                    className=\"pc-tooltip-arrow\"\n                    style={\n                      s === \"top\" || s === \"bottom\"\n                        ? { left: `calc(${pos.arrow}px - var(--pc-bw) - var(--pc-as) / 2)` }\n                        : { top: `calc(${pos.arrow}px - var(--pc-bw) - var(--pc-as) / 2)` }\n                    }\n                  />\n                )}\n              </motion.div>\n            </motion.div>\n          </div>\n        )}\n      </AnimatePresence>\n    </>\n  )\n\n  return (\n    <>\n      <style href=\"pc-tooltip\" precedence=\"default\">\n        {CSS}\n      </style>\n      {triggerEl}\n      {mounted && portal ? createPortal(layer, document.body) : layer}\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/tooltip.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}
