{
  "name": "map",
  "type": "registry:ui",
  "description": "map component for the Canadian AI design system",
  "files": [
    {
      "path": "components/ui/map.tsx",
      "content": "\"use client\"\n\nimport { createContext, useContext, useMemo } from \"react\"\nimport { cn } from \"@/lib/utils\"\n\ntype LngLat = [number, number]\n\ninterface MapContextValue {\n  project: (longitude: number, latitude: number) => { x: number; y: number }\n}\n\nconst MapContext = createContext<MapContextValue | null>(null)\n\nfunction useMapContext() {\n  const ctx = useContext(MapContext)\n  if (!ctx) {\n    throw new Error(\"Map primitives must be used inside <Map>\")\n  }\n  return ctx\n}\n\ninterface MapProps {\n  children: React.ReactNode\n  className?: string\n  loading?: boolean\n  center?: LngLat\n  zoom?: number\n  minZoom?: number\n  maxZoom?: number\n  styles?: {\n    light?: string\n    dark?: string\n  }\n}\n\nexport function Map({ children, className, loading, center = [-122.435, 37.696] }: MapProps) {\n  const project = useMemo(() => {\n    const [centerLng, centerLat] = center\n    const scaleX = 700\n    const scaleY = 900\n\n    return (longitude: number, latitude: number) => {\n      const x = 50 + (longitude - centerLng) * scaleX\n      const y = 50 - (latitude - centerLat) * scaleY\n      return {\n        x: Math.max(2, Math.min(98, x)),\n        y: Math.max(2, Math.min(98, y)),\n      }\n    }\n  }, [center])\n\n  return (\n    <MapContext.Provider value={{ project }}>\n      <div className={cn(\"relative h-full w-full overflow-hidden border border-foreground/10 bg-muted/20\", className)}>\n        <div className=\"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(56,189,248,0.15),transparent_40%),radial-gradient(circle_at_70%_80%,rgba(16,185,129,0.15),transparent_45%)]\" />\n        <div className=\"absolute inset-0 bg-[linear-gradient(rgba(120,120,120,0.12)_1px,transparent_1px),linear-gradient(90deg,rgba(120,120,120,0.12)_1px,transparent_1px)] [background-size:24px_24px]\" />\n        {loading && (\n          <div className=\"absolute inset-0 z-30 grid place-items-center bg-background/60 text-xs text-muted-foreground\">\n            Loading route...\n          </div>\n        )}\n        {children}\n      </div>\n    </MapContext.Provider>\n  )\n}\n\ninterface MapRouteProps {\n  id?: string\n  coordinates: LngLat[]\n  color?: string\n  width?: number\n  opacity?: number\n  interactive?: boolean\n  onClick?: () => void\n}\n\nexport function MapRoute({ coordinates, color = \"#3b82f6\", width = 3, opacity = 1, interactive = false, onClick }: MapRouteProps) {\n  const { project } = useMapContext()\n\n  const points = coordinates\n    .map(([lng, lat]) => {\n      const p = project(lng, lat)\n      return `${p.x},${p.y}`\n    })\n    .join(\" \")\n\n  if (!points) return null\n\n  return (\n    <svg\n      className={cn(\"absolute inset-0 z-10 h-full w-full\", interactive ? \"cursor-pointer\" : \"\")}\n      viewBox=\"0 0 100 100\"\n      preserveAspectRatio=\"none\"\n      onClick={onClick}\n    >\n      <polyline fill=\"none\" stroke={color} strokeWidth={width / 10} strokeOpacity={opacity} points={points} />\n    </svg>\n  )\n}\n\ninterface MapMarkerProps {\n  longitude: number\n  latitude: number\n  children: React.ReactNode\n  offset?: [number, number]\n}\n\nexport function MapMarker({ longitude, latitude, children, offset = [0, 0] }: MapMarkerProps) {\n  const { project } = useMapContext()\n  const p = project(longitude, latitude)\n\n  return (\n    <div\n      className=\"group absolute z-20\"\n      style={{\n        left: `calc(${p.x}% + ${offset[0]}px)`,\n        top: `calc(${p.y}% + ${offset[1]}px)`,\n        transform: \"translate(-50%, -50%)\",\n      }}\n    >\n      {children}\n    </div>\n  )\n}\n\nexport function MarkerContent({ children }: { children: React.ReactNode }) {\n  return <div>{children}</div>\n}\n\nexport function MarkerTooltip({ children }: { children: React.ReactNode }) {\n  return (\n    <div className=\"pointer-events-none absolute left-1/2 top-full mt-2 hidden -translate-x-1/2 whitespace-nowrap border border-foreground/15 bg-background px-2 py-1 text-[10px] text-foreground shadow-sm group-hover:block\">\n      {children}\n    </div>\n  )\n}\n\nexport function MarkerLabel({ children, position = \"top\" }: { children: React.ReactNode; position?: \"top\" | \"bottom\" }) {\n  const topClasses = position === \"top\"\n    ? \"bottom-full mb-1.5\"\n    : \"top-full mt-1.5\"\n\n  return (\n    <div className={cn(\"absolute left-1/2 -translate-x-1/2 whitespace-nowrap border border-foreground/15 bg-background px-2 py-0.5 text-[10px] text-foreground shadow-sm\", topClasses)}>\n      {children}\n    </div>\n  )\n}\n",
      "type": "registry:ui"
    }
  ]
}