{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "site-hotspot-tour",
  "type": "registry:component",
  "title": "Hotspot Tour",
  "description": "A product tour made of pulsing hotspots laid over a mock interface, with a step popover that offers Next, Back and Skip and works with the arrow keys.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "site",
    "tour",
    "onboarding",
    "hotspot",
    "product tour",
    "popover",
    "walkthrough"
  ],
  "docs": "https://hyperblur.dev/effects/site-hotspot-tour",
  "files": [
    {
      "path": "registry/hyperblur/site-hotspot-tour.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/site-hotspot-tour.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TourStep {\n  id: string;\n  x: number;\n  y: number;\n  title: string;\n  body: string;\n}\n\nexport interface SiteHotspotTourProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  steps?: TourStep[];\n  step?: number;\n  defaultStep?: number;\n  onStepChange?: (step: number) => void;\n  running?: boolean;\n  defaultRunning?: boolean;\n  onRunningChange?: (running: boolean) => void;\n  onFinish?: () => void;\n  onSkip?: () => void;\n  popoverWidth?: number;\n  replayLabel?: string;\n  accent?: string;\n}\n\nconst defaultSteps: TourStep[] = [\n  { id: \"search\", x: 40, y: 12, title: \"Search anything\", body: \"Jump to any report or teammate.\" },\n  { id: \"chart\", x: 72, y: 28, title: \"Live metrics\", body: \"Numbers refresh every minute.\" },\n  { id: \"nav\", x: 14, y: 70, title: \"Your workspaces\", body: \"Switch projects from here.\" },\n  { id: \"share\", x: 88, y: 86, title: \"Share a view\", body: \"Send a read-only link.\" },\n];\n\nconst css = `\n.hb-yf9 {\n  --hb-yf9-pw: 176px;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  height: 100%;\n  overflow: hidden;\n  font-family: inherit;\n  font-size: 12px;\n  line-height: 1.35;\n  color: #ededed;\n  text-align: left;\n  outline: none;\n}\n.hb-yf9 *, .hb-yf9 *::before, .hb-yf9 *::after { box-sizing: border-box; font-family: inherit; }\n.hb-yf9-stage { position: absolute; inset: 0; transition: filter 0.3s ease; }\n.hb-yf9[data-run=\"true\"] .hb-yf9-stage { filter: saturate(0.7) brightness(0.72); }\n.hb-yf9-mock { display: grid; grid-template-columns: 22% 1fr; grid-template-rows: 18% 1fr; width: 100%; height: 100%; background: #0d0d0d; }\n.hb-yf9-mock > div { border: 0 solid #1f1f1f; }\n.hb-yf9-mh { grid-column: 1 / 3; border-bottom-width: 1px !important; background: #111111; }\n.hb-yf9-ms { border-right-width: 1px !important; background: #101010; padding: 10px; display: grid; align-content: start; gap: 8px; }\n.hb-yf9-mm { padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }\n.hb-yf9-bar { display: block; height: 8px; border-radius: 4px; background: #222222; }\n.hb-yf9-blk { min-height: 44px; border-radius: 8px; background: #161616; border: 1px solid #222222; }\n.hb-yf9-spot {\n  position: absolute;\n  z-index: 3;\n  left: calc(var(--hb-yf9-x) * 1%);\n  top: calc(var(--hb-yf9-y) * 1%);\n  display: grid;\n  place-items: center;\n  width: 26px;\n  height: 26px;\n  margin: -13px 0 0 -13px;\n  padding: 0;\n  color: inherit;\n  background: transparent;\n  border: 0;\n  border-radius: 50%;\n  cursor: pointer;\n}\n.hb-yf9-dot { position: relative; z-index: 1; width: 12px; height: 12px; background: var(--hb-yf9-a, #2f7bff); border: 2px solid #fff; border-radius: 50%; transition: transform 0.2s ease, background-color 0.2s ease; }\n.hb-yf9-spot::before, .hb-yf9-spot::after { content: \"\"; position: absolute; inset: 3px; border: 2px solid var(--hb-yf9-a, #2f7bff); border-radius: 50%; opacity: 0; animation: hb-yf9-pulse 2.2s ease-out infinite; }\n.hb-yf9-spot::after { animation-delay: 1.1s; }\n.hb-yf9-spot[data-on=\"false\"] { opacity: 0.75; }\n.hb-yf9-spot[data-on=\"false\"]::before, .hb-yf9-spot[data-on=\"false\"]::after { animation-duration: 3.4s; }\n.hb-yf9-spot[data-on=\"true\"] .hb-yf9-dot { transform: scale(1.25); background: #fff; border-color: var(--hb-yf9-a, #2f7bff); }\n.hb-yf9-spot:hover .hb-yf9-dot { transform: scale(1.25); }\n.hb-yf9-spot:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }\n.hb-yf9-pop {\n  position: absolute;\n  z-index: 4;\n  width: var(--hb-yf9-pw);\n  left: clamp(8px, calc(var(--hb-yf9-x) * 1% - var(--hb-yf9-pw) / 2), calc(100% - var(--hb-yf9-pw) - 8px));\n  padding: 10px 10px 8px 12px;\n  background: #151515;\n  border: 1px solid #333333;\n  border-radius: 12px;\n  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);\n  outline: none;\n  animation: hb-yf9-pop 0.3s cubic-bezier(0.22, 1.2, 0.36, 1) both;\n}\n.hb-yf9-pop[data-side=\"below\"] { top: calc(var(--hb-yf9-y) * 1% + 18px); }\n.hb-yf9-pop[data-side=\"above\"] { bottom: calc((100 - var(--hb-yf9-y)) * 1% + 18px); }\n.hb-yf9-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n.hb-yf9-title { margin: 0; font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; }\n.hb-yf9-count { flex: none; font-size: 10.5px; font-variant-numeric: tabular-nums; color: #8f8f8f; }\n.hb-yf9-body { margin: 3px 0 8px; font-size: 11px; line-height: 1.4; color: #a1a1a1; }\n.hb-yf9-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }\n.hb-yf9-grp { display: flex; align-items: center; gap: 4px; }\n.hb-yf9-btn { height: 24px; margin: 0; padding: 0 10px; font: inherit; font-size: 11px; font-weight: 600; color: #ededed; white-space: nowrap; background: transparent; border: 1px solid #333333; border-radius: 999px; cursor: pointer; transition: background-color 0.15s ease, transform 0.15s ease; }\n.hb-yf9-btn:hover { background: rgba(255, 255, 255, 0.07); }\n.hb-yf9-btn:active { transform: scale(0.96); }\n.hb-yf9-btn:focus-visible { outline: 2px solid var(--hb-yf9-a, #2f7bff); outline-offset: 2px; }\n.hb-yf9-btn[data-kind=\"ghost\"] { border-color: transparent; color: #8f8f8f; padding: 0 6px; }\n.hb-yf9-btn[data-kind=\"primary\"] { color: #fff; background: var(--hb-yf9-a, #2f7bff); border-color: var(--hb-yf9-a, #2f7bff); }\n.hb-yf9-btn[data-kind=\"primary\"]:hover { background: color-mix(in srgb, var(--hb-yf9-a, #2f7bff) 86%, #fff); }\n.hb-yf9-btn:disabled { opacity: 0.4; cursor: default; }\n.hb-yf9-replay { position: absolute; z-index: 4; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; font: inherit; font-size: 11.5px; font-weight: 600; color: #ededed; background: #151515; border: 1px solid #333333; border-radius: 999px; cursor: pointer; animation: hb-yf9-pop 0.3s ease both; }\n.hb-yf9-replay:hover { background: #1c1c1c; }\n.hb-yf9-replay:focus-visible { outline: 2px solid var(--hb-yf9-a, #2f7bff); outline-offset: 2px; }\n.hb-yf9-replay svg { width: 11px; height: 11px; }\n@keyframes hb-yf9-pulse { 0% { transform: scale(0.55); opacity: 0.85; } 100% { transform: scale(1.6); opacity: 0; } }\n@keyframes hb-yf9-pop { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-yf9-spot::before, .hb-yf9-spot::after { animation: none; opacity: 0.4; transform: scale(1.2); }\n  .hb-yf9-pop, .hb-yf9-replay { animation: none; }\n  .hb-yf9-dot, .hb-yf9-btn, .hb-yf9-stage { transition: none; }\n}\n`;\n\nfunction DefaultMock() {\n  return (\n    <div className=\"hb-yf9-mock\">\n      <div className=\"hb-yf9-mh\" />\n      <div className=\"hb-yf9-ms\">\n        <span className=\"hb-yf9-bar\" />\n        <span className=\"hb-yf9-bar\" style={{ width: \"70%\" }} />\n        <span className=\"hb-yf9-bar\" style={{ width: \"85%\" }} />\n      </div>\n      <div className=\"hb-yf9-mm\">\n        <span className=\"hb-yf9-blk\" />\n        <span className=\"hb-yf9-blk\" />\n        <span className=\"hb-yf9-blk\" style={{ gridColumn: \"1 / 3\" }} />\n      </div>\n    </div>\n  );\n}\n\nexport function SiteHotspotTour({\n  steps = defaultSteps,\n  step,\n  defaultStep = 0,\n  onStepChange,\n  running,\n  defaultRunning = true,\n  onRunningChange,\n  onFinish,\n  onSkip,\n  popoverWidth = 176,\n  replayLabel = \"Replay tour\",\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  children,\n  onKeyDown,\n  ...rest\n}: SiteHotspotTourProps) {\n  const [innerStep, setInnerStep] = React.useState(defaultStep);\n  const [innerRun, setInnerRun] = React.useState(defaultRunning);\n  const popRef = React.useRef<HTMLDivElement>(null);\n  const interacted = React.useRef(false);\n  const stepControlled = step !== undefined;\n  const runControlled = running !== undefined;\n  const count = steps.length;\n  const index = Math.min(Math.max(0, stepControlled ? step : innerStep), Math.max(0, count - 1));\n  const isRunning = (runControlled ? running : innerRun) && count > 0;\n  const current = steps[index];\n\n  React.useEffect(() => {\n    if (interacted.current && isRunning) popRef.current?.focus({ preventScroll: true });\n  }, [index, isRunning]);\n\n  function setStep(next: number) {\n    interacted.current = true;\n    if (!stepControlled) setInnerStep(next);\n    onStepChange?.(next);\n  }\n\n  function setRun(next: boolean) {\n    if (!runControlled) setInnerRun(next);\n    onRunningChange?.(next);\n  }\n\n  function next() {\n    if (index >= count - 1) {\n      setRun(false);\n      onFinish?.();\n      return;\n    }\n    setStep(index + 1);\n  }\n\n  function back() {\n    if (index > 0) setStep(index - 1);\n  }\n\n  function skip() {\n    setRun(false);\n    onSkip?.();\n  }\n\n  function replay() {\n    interacted.current = true;\n    if (!stepControlled) setInnerStep(0);\n    onStepChange?.(0);\n    setRun(true);\n  }\n\n  function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {\n    onKeyDown?.(e);\n    if (!isRunning) return;\n    const tag = (e.target as HTMLElement).tagName;\n    if (tag === \"INPUT\" || tag === \"TEXTAREA\") return;\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      next();\n    } else if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      back();\n    } else if (e.key === \"Escape\") {\n      e.stopPropagation();\n      skip();\n    }\n  }\n\n  return (\n    <>\n      <style href=\"hb-site-hotspot-tour\" precedence=\"default\">{css}</style>\n      <div\n        role=\"group\"\n        aria-label=\"Product tour\"\n        tabIndex={-1}\n        data-run={isRunning}\n        className={`hb-yf9 ${className}`}\n        style={{ \"--hb-yf9-a\": accent, \"--hb-yf9-pw\": `${popoverWidth}px`, ...style } as React.CSSProperties}\n        onKeyDown={handleKeyDown}\n        {...rest}\n      >\n        <div className=\"hb-yf9-stage\">{children ?? <DefaultMock />}</div>\n        {isRunning\n          ? steps.map((s, i) => (\n              <button\n                key={s.id}\n                type=\"button\"\n                className=\"hb-yf9-spot\"\n                data-on={i === index}\n                aria-label={`Step ${i + 1} of ${count}: ${s.title}`}\n                aria-current={i === index ? \"step\" : undefined}\n                style={{ \"--hb-yf9-x\": s.x, \"--hb-yf9-y\": s.y } as React.CSSProperties}\n                onClick={() => setStep(i)}\n              >\n                <span className=\"hb-yf9-dot\" />\n              </button>\n            ))\n          : null}\n        {isRunning && current ? (\n          <div\n            key={current.id}\n            ref={popRef}\n            role=\"dialog\"\n            aria-label={current.title}\n            tabIndex={-1}\n            className=\"hb-yf9-pop\"\n            data-side={current.y > 52 ? \"above\" : \"below\"}\n            style={{ \"--hb-yf9-x\": current.x, \"--hb-yf9-y\": current.y } as React.CSSProperties}\n          >\n            <div className=\"hb-yf9-top\">\n              <h3 className=\"hb-yf9-title\">{current.title}</h3>\n              <span className=\"hb-yf9-count\" aria-live=\"polite\">{index + 1} / {count}</span>\n            </div>\n            <p className=\"hb-yf9-body\">{current.body}</p>\n            <div className=\"hb-yf9-foot\">\n              <button type=\"button\" className=\"hb-yf9-btn\" data-kind=\"ghost\" onClick={skip}>\n                Skip\n              </button>\n              <span className=\"hb-yf9-grp\">\n                <button type=\"button\" className=\"hb-yf9-btn\" onClick={back} disabled={index === 0}>\n                  Back\n                </button>\n                <button type=\"button\" className=\"hb-yf9-btn\" data-kind=\"primary\" onClick={next}>\n                  {index === count - 1 ? \"Done\" : \"Next\"}\n                </button>\n              </span>\n            </div>\n          </div>\n        ) : null}\n        {!isRunning && count > 0 ? (\n          <button type=\"button\" className=\"hb-yf9-replay\" onClick={replay}>\n            <svg viewBox=\"0 0 12 12\" fill=\"none\" aria-hidden=\"true\">\n              <path d=\"M10 6a4 4 0 1 1-1.2-2.8M10 1.8v2.4H7.6\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n            {replayLabel}\n          </button>\n        ) : null}\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}