{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "provenance-tooltip",
  "type": "registry:ui",
  "title": "Provenance tooltip",
  "description": "One hover away from every cue: a wrapped Tooltip that says where the cue came from (Rule · date parser, Recognizer · 0.82, You), the detail in Tooltip.Dim, with the number whenever the app guessed.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "https://metalui.dev/r/tokens.json"
  ],
  "files": [
    {
      "path": "packages/metalui/src/blocks/provenance-tooltip/provenance-tooltip.tsx",
      "type": "registry:ui",
      "target": "components/metalui/blocks/provenance-tooltip/provenance-tooltip.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { Tooltip, TooltipProvider } from '../../components/tooltip/tooltip';\n\n/* ─────────────────────────────────────────────────────────\n * PROVENANCE TOOLTIP (the reference design's #tip): a composition\n *   Tooltip(wrap, 380 ms, 8 or 34 above) › the source + Tooltip.Dim \"· detail · detail\"\n *\n *   rest     the cue, nothing else\n *   380 ms   hovered or focused: the tooltip fades in on settle, 8 above the cue\n *            (34 above a cue that shows its own value chip, so the two never overlap)\n *   edge     near the top of the view it flips below (Base UI collision avoidance)\n *   leave    fades out on settle; moving to the next cue shows it at once\n * The source comes first, then the dimmed detail: \"Rule · date parser\", \"Recognizer · 0.82\", \"You\".\n * ───────────────────────────────────────────────────────── */\n\nconst token = (name: string, fallback: number) => {\n  if (typeof window === 'undefined') return fallback;\n  return parseFloat(getComputedStyle(document.documentElement).getPropertyValue(name)) || fallback;\n};\n\nexport interface ProvenanceTooltipProps {\n  /** Where the cue came from: \"Rule\", \"Recognizer\", \"Region\", \"Cluster\", \"Formula\", \"You\". */\n  source: string;\n  /** The rest, dimmed: [\"date parser\"], [\"0.82\"], [\"Done\"]. Show the number whenever the app guessed. */\n  detail?: string[];\n  /** The cue shows its own resolved-value chip on hover: sit above it. */\n  clearsChip?: boolean;\n  /** The cue element. It must accept a ref and props (a Mark, a span, a button). */\n  children: React.ReactElement<Record<string, unknown>>;\n  /** Controlled open state (a docs still, a test). */\n  open?: boolean;\n}\n\n/** Says where a cue came from, one hover away. */\nexport function ProvenanceTooltip({ source, detail = [], clearsChip, children, open }: ProvenanceTooltipProps) {\n  // Tooltips are visual; the provenance is also the cue's accessible description.\n  const trigger = React.cloneElement(children, { 'aria-description': [source, ...detail].join(', ') });\n  return (\n    <Tooltip\n      wrap\n      open={open}\n      className=\"mu-provenance\"\n      delay={token('--mu-provenance-delay-ms', 380)}\n      offset={token(clearsChip ? '--mu-provenance-chip-offset' : '--mu-provenance-offset', clearsChip ? 34 : 8)}\n      label={\n        <>\n          {source}\n          {detail.length > 0 && <Tooltip.Dim> · {detail.join(' · ')}</Tooltip.Dim>}\n        </>\n      }\n    >\n      {trigger}\n    </Tooltip>\n  );\n}\n\n/** Groups provenance tooltips at their 380 ms delay: after one shows, the next cue shows its own at once. */\nexport function ProvenanceProvider({ children }: { children: React.ReactNode }) {\n  return <TooltipProvider delay={token('--mu-provenance-delay-ms', 380)}>{children}</TooltipProvider>;\n}\n"
    }
  ],
  "docs": "Agent guide: https://metalui.dev/r/provenance-tooltip.md. SwiftUI: MetalProvenanceTooltip, .metalProvenance(_:detail:) in the MetalUI Swift package."
}
