{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-tracing-beam",
  "title": "Tracing Beam",
  "description": "Feixe vertical que acompanha o scroll com thumb e gradiente — inspirado em Aceternity Tracing Beam.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "components/ds/ds-tracing-beam.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\n// ── Types ──\n\nexport interface TracingBeamProps\n  extends\n    React.HTMLAttributes<HTMLDivElement>,\n    VariantProps<typeof tracingBeamVariants> {\n  beamColor?: string\n}\n\n// ── Variants ──\n\nexport const tracingBeamVariants = cva(\"relative mx-auto w-full max-w-3xl\", {\n  variants: {\n    inset: {\n      true: \"px-6\",\n      false: \"\",\n    },\n  },\n  defaultVariants: {\n    inset: true,\n  },\n})\n\n// ── Component ──\n\nexport function TracingBeam({\n  className,\n  inset = true,\n  beamColor,\n  children,\n  ...props\n}: TracingBeamProps) {\n  const containerRef = React.useRef<HTMLDivElement>(null)\n  const [progress, setProgress] = React.useState(0)\n  const [height, setHeight] = React.useState(0)\n\n  React.useEffect(() => {\n    const el = containerRef.current\n    if (!el) return\n\n    const update = () => {\n      const rect = el.getBoundingClientRect()\n      const scrollY = window.scrollY\n      const top = rect.top + scrollY\n      const viewBottom = scrollY + window.innerHeight\n      // progress 0..1 as container enters/exits viewport\n      const total = rect.height + window.innerHeight\n      const current = viewBottom - top\n      const p = Math.min(1, Math.max(0, current / total))\n      setProgress(p)\n      setHeight(rect.height)\n      // also adjust beam height via CSS var\n      el.style.setProperty(\"--beam-progress\", String(p))\n    }\n\n    update()\n    window.addEventListener(\"scroll\", update, { passive: true })\n    window.addEventListener(\"resize\", update)\n    const ro = new ResizeObserver(update)\n    ro.observe(el)\n    return () => {\n      window.removeEventListener(\"scroll\", update)\n      window.removeEventListener(\"resize\", update)\n      ro.disconnect()\n    }\n  }, [])\n\n  return (\n    <div\n      ref={containerRef}\n      data-slot=\"tracing-beam\"\n      className={cn(tracingBeamVariants({ inset }), className)}\n      {...props}\n    >\n      <div\n        aria-hidden=\"true\"\n        className=\"absolute top-0 left-0 flex h-full w-px justify-center\"\n        style={{ left: \"16px\" }}\n      >\n        {/* track */}\n        <div className=\"h-full w-px bg-border/60\" />\n        {/* active beam */}\n        <div\n          className=\"absolute top-0 w-px origin-top bg-gradient-to-b from-primary via-primary/60 to-transparent transition-[height] duration-150\"\n          style={{\n            height: `${progress * 100}%`,\n            maxHeight: height ? `${height}px` : \"100%\",\n            backgroundColor: beamColor,\n          }}\n        />\n        {/* thumb dot */}\n        <div\n          className=\"absolute size-2.5 -translate-x-1 rounded-full bg-primary shadow-sm ring-4 ring-background\"\n          style={{ top: `calc(${progress * 100}% - 5px)` }}\n        />\n      </div>\n      <div className=\"flex flex-col gap-10 pl-10\">{children}</div>\n    </div>\n  )\n}\n\n// ── Sub-component: item ──\n\nexport function TracingBeamItem({\n  className,\n  ...props\n}: React.HTMLAttributes<HTMLDivElement>) {\n  return (\n    <div\n      data-slot=\"tracing-beam-item\"\n      className={cn(\n        \"flex flex-col gap-3 rounded-xl border bg-card p-6 shadow-sm\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
