{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-globe-3d",
  "description": "3D Globe component.",
  "dependencies": [
    "cobe"
  ],
  "registryDependencies": [
    "@lema-ds/client-only"
  ],
  "files": [
    {
      "path": "components/ds/ds-globe-3d.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { ClientOnly } from \"@/lib/client-only\"\n\n// cobe is dynamically imported inside the effect to avoid bundling ~45kB in the initial chunk\n// Use DynamicGlobe3D to also skip server rendering (canvas) in any React framework\n\nexport interface Globe3DProps extends React.HTMLAttributes<HTMLDivElement> {\n  markers?: Array<{ location: [number, number]; size: number }>\n  baseColor?: [number, number, number]\n  glowColor?: [number, number, number]\n  markerColor?: [number, number, number]\n}\n\nexport const Globe3D = React.forwardRef<HTMLDivElement, Globe3DProps>(\n  (\n    {\n      className,\n      markers = [],\n      baseColor = [0.3, 0.3, 0.3],\n      glowColor = [1, 1, 1],\n      markerColor = [0.1, 0.7, 1],\n      ...props\n    },\n    ref\n  ) => {\n    const canvasRef = React.useRef<HTMLCanvasElement>(null)\n    const pointerInteracting = React.useRef<number | null>(null)\n    const pointerInteractionMovement = React.useRef(0)\n    const [{ r }, setR] = React.useState({ r: 0 })\n\n    React.useEffect(() => {\n      let phi = 0\n      let width = 0\n      let animationFrame: number\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n      let globeInstance: any = null\n      let cancelled = false\n\n      const onResize = () => {\n        if (canvasRef.current) {\n          width = canvasRef.current.offsetWidth\n        }\n      }\n\n      window.addEventListener(\"resize\", onResize)\n      onResize()\n\n      if (!canvasRef.current) return\n\n      void (async () => {\n        const { default: createGlobe } = await import(\"cobe\")\n        if (cancelled || !canvasRef.current) return\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any\n        globeInstance = createGlobe(canvasRef.current as any, {\n          devicePixelRatio: 2,\n          width: width * 2,\n          height: width * 2,\n          phi: 0,\n          theta: 0.3,\n          dark: 1,\n          diffuse: 1.2,\n          mapSamples: 16000,\n          mapBrightness: 6,\n          baseColor,\n          markerColor,\n          glowColor,\n          markers,\n        })\n\n        const animate = () => {\n          if (!pointerInteracting.current) {\n            phi += 0.005\n          }\n          globeInstance?.update({\n            phi: phi + r,\n            width: width * 2,\n            height: width * 2,\n          })\n          animationFrame = requestAnimationFrame(animate)\n        }\n        animate()\n      })()\n\n      return () => {\n        cancelled = true\n        cancelAnimationFrame(animationFrame)\n        globeInstance?.destroy()\n        window.removeEventListener(\"resize\", onResize)\n      }\n    }, [markers, baseColor, glowColor, markerColor, r])\n\n    return (\n      <div\n        ref={ref}\n        className={cn(\n          \"relative mx-auto aspect-square w-full max-w-[600px]\",\n          className\n        )}\n        {...props}\n      >\n        <canvas\n          ref={canvasRef}\n          onPointerDown={(e) => {\n            pointerInteracting.current =\n              e.clientX - pointerInteractionMovement.current\n            canvasRef.current!.style.cursor = \"grabbing\"\n          }}\n          onPointerUp={() => {\n            pointerInteracting.current = null\n            canvasRef.current!.style.cursor = \"grab\"\n          }}\n          onPointerOut={() => {\n            pointerInteracting.current = null\n            canvasRef.current!.style.cursor = \"grab\"\n          }}\n          onMouseMove={(e) => {\n            if (pointerInteracting.current !== null) {\n              const delta = e.clientX - pointerInteracting.current\n              pointerInteractionMovement.current = delta\n              setR({ r: delta / 200 })\n            }\n          }}\n          onTouchMove={(e) => {\n            if (pointerInteracting.current !== null && e.touches[0]) {\n              const delta = e.touches[0].clientX - pointerInteracting.current\n              pointerInteractionMovement.current = delta\n              setR({ r: delta / 100 })\n            }\n          }}\n          style={{\n            width: \"100%\",\n            height: \"100%\",\n            cursor: \"grab\",\n            contain: \"layout paint size\",\n            opacity: 1,\n            transition: \"opacity 1s ease\",\n          }}\n        />\n      </div>\n    )\n  }\n)\nGlobe3D.displayName = \"Globe3D\"\n\n// Client-only wrapper — skips server rendering (canvas SSR mismatch).\n// Framework-agnostic replacement for next/dynamic with ssr:false.\nexport function DynamicGlobe3D(props: Globe3DProps) {\n  return (\n    <ClientOnly>\n      <Globe3D {...props} />\n    </ClientOnly>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
