{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "edge-globe",
  "title": "Edge Globe",
  "type": "registry:component",
  "description": "Rotating globe of real land dots with arcs. Drag to spin",
  "dependencies": [],
  "files": [
    {
      "path": "src/kavyn/edge-globe.jsx",
      "type": "registry:file",
      "target": "@components/kavyn/edge-globe.jsx",
      "content": "'use client'\n\nimport { useEffect, useRef } from 'react'\nimport { worldDots } from './world-dots'\n\n// Light or dark, read from the --bg token itself: works with a .dark class, a .light class, or neither.\nconst isLightTheme = () => {\n  const h = getComputedStyle(document.documentElement).getPropertyValue('--bg').trim().replace(/^#(.)(.)(.)$/, '#$1$1$2$2$3$3')\n  return /^#[0-9a-f]{6}/i.test(h) ? [1, 3, 5].reduce((s, i, k) => s + parseInt(h.slice(i, i + 2), 16) * [0.299, 0.587, 0.114][k], 0) > 128 : !document.documentElement.classList.contains('dark')\n}\n\nconst HUBS = [[19.07, 72.87], [50.11, 8.68], [38.95, -77.45], [1.35, 103.99], [-23.43, -46.47], [35.77, 140.39], [-33.94, 151.18], [25.25, 55.36]]\nconst rad = Math.PI / 180\nconst vec = (lat, lon) => [Math.cos(lat * rad) * Math.sin(lon * rad), Math.sin(lat * rad), Math.cos(lat * rad) * Math.cos(lon * rad)]\nconst slerp = (a, b, t) => {\n  const d = Math.acos(Math.max(-1, Math.min(1, a[0] * b[0] + a[1] * b[1] + a[2] * b[2])))\n  if (d < 1e-4) return a\n  const s = Math.sin(d), k0 = Math.sin((1 - t) * d) / s, k1 = Math.sin(t * d) / s\n  return [a[0] * k0 + b[0] * k1, a[1] * k0 + b[1] * k1, a[2] * k0 + b[2] * k1]\n}\n\n// Rotating dotted globe of real land masses with arcs between edge locations. Drag to spin.\nexport default function EdgeGlobe({ size = 320, hubs = HUBS, speed = 0.18, color = undefined }) {\n  const ref = useRef(null)\n  useEffect(() => {\n    const c = ref.current\n    const ctx = c?.getContext('2d')\n    if (!ctx) return\n    const d = Math.min(window.devicePixelRatio || 1, 2)\n    c.width = size * d; c.height = size * d; ctx.setTransform(d, 0, 0, d, 0, 0)\n    const pts = worldDots().map((p) => vec(p.lat, p.lon))\n    const H = hubs.map(([la, lo]) => vec(la, lo))\n    const arcs = Array.from({ length: Math.min(5, H.length) }, (_, i) => ({ a: i % H.length, b: (i * 3 + 2) % H.length, t: -i * 0.3 }))\n    let rot = -1.3, raf, last = performance.now(), drag = null\n    const R = size * 0.44, cx = size / 2, cy = size / 2, tilt = -0.3\n    const proj = ([x, y, z], lift = 1) => {\n      const X = x * Math.cos(rot) + z * Math.sin(rot), Z = -x * Math.sin(rot) + z * Math.cos(rot)\n      const Y = y * Math.cos(tilt) - Z * Math.sin(tilt), Z2 = y * Math.sin(tilt) + Z * Math.cos(tilt)\n      return [cx + X * R * lift, cy - Y * R * lift, Z2]\n    }\n    const draw = (now) => {\n      const dt = Math.min(0.05, (now - last) / 1000); last = now\n      if (!drag) rot += speed * dt\n      ctx.clearRect(0, 0, size, size)\n      const lite = isLightTheme()\n      const ink = color || (lite ? '29,29,31' : '245,245,247')\n      const g = ctx.createRadialGradient(cx - R * 0.3, cy - R * 0.3, R * 0.1, cx, cy, R)\n      if (lite) { g.addColorStop(0, '#ffffff'); g.addColorStop(1, '#e8e8ec') } else { g.addColorStop(0, '#1c1c1e'); g.addColorStop(1, '#050505') }\n      ctx.fillStyle = g; ctx.beginPath(); ctx.arc(cx, cy, R, 0, 6.283); ctx.fill()\n      ctx.strokeStyle = lite ? 'rgba(20,20,23,0.16)' : 'rgba(237,237,239,0.08)'; ctx.stroke()\n      for (const p of pts) {\n        const [x, y, z] = proj(p)\n        if (z < 0) continue\n        ctx.fillStyle = lite ? `rgba(20,20,23,${0.14 + z * 0.5})` : `rgba(237,237,239,${0.1 + z * 0.45})`\n        ctx.fillRect(x - 0.8, y - 0.8, 1.6, 1.6)\n      }\n      for (const arc of arcs) {\n        arc.t += dt * 0.4\n        if (arc.t > 1.4) { arc.t = 0; arc.a = arc.b; arc.b = (arc.b + 1 + ((Math.random() * (H.length - 1)) | 0)) % H.length }\n        if (arc.t <= 0) continue\n        const head = Math.min(1, arc.t), tail = Math.max(0, arc.t - 0.4)\n        for (let i = 0; i < 20; i++) {\n          const t0 = tail + ((head - tail) * i) / 20, t1 = tail + ((head - tail) * (i + 1)) / 20\n          const l0 = 1 + Math.sin(t0 * Math.PI) * 0.18, l1 = 1 + Math.sin(t1 * Math.PI) * 0.18\n          const p0 = proj(slerp(H[arc.a], H[arc.b], t0), l0), p1 = proj(slerp(H[arc.a], H[arc.b], t1), l1)\n          if (p0[2] < -0.1 || p1[2] < -0.1) continue\n          ctx.strokeStyle = `rgba(${ink},${(i / 20) * 0.95})`; ctx.lineWidth = 1.3\n          ctx.beginPath(); ctx.moveTo(p0[0], p0[1]); ctx.lineTo(p1[0], p1[1]); ctx.stroke()\n        }\n      }\n      const pulse = (now / 1600) % 1\n      for (const h of H) {\n        const [x, y, z] = proj(h)\n        if (z < 0) continue\n        ctx.strokeStyle = `rgba(${ink},${(1 - pulse) * 0.7 * z})`\n        ctx.beginPath(); ctx.arc(x, y, 2 + pulse * 9, 0, 6.283); ctx.stroke()\n        ctx.fillStyle = `rgb(${ink})`; ctx.beginPath(); ctx.arc(x, y, 2, 0, 6.283); ctx.fill()\n      }\n      raf = requestAnimationFrame(draw)\n    }\n    raf = requestAnimationFrame(draw)\n    const down = (e) => { drag = e.clientX; c.setPointerCapture?.(e.pointerId) }\n    const move = (e) => { if (drag !== null) { rot += (e.clientX - drag) * 0.008; drag = e.clientX } }\n    const up = () => { drag = null }\n    c.addEventListener('pointerdown', down); c.addEventListener('pointermove', move)\n    c.addEventListener('pointerup', up); c.addEventListener('pointercancel', up)\n    return () => {\n      cancelAnimationFrame(raf)\n      c.removeEventListener('pointerdown', down); c.removeEventListener('pointermove', move)\n      c.removeEventListener('pointerup', up); c.removeEventListener('pointercancel', up)\n    }\n  }, [size, hubs, speed, color])\n  return <canvas ref={ref} style={{ width: size, height: size }} className=\"cursor-grab touch-none active:cursor-grabbing\" role=\"img\" aria-label=\"Rotating globe\" />\n}\n"
    },
    {
      "path": "src/kavyn/world-dots.js",
      "type": "registry:file",
      "target": "@components/kavyn/world-dots.js",
      "content": "// Land mask for the dotted world map, 2.5° grid (lat 80 to -58).\n// Each row lists runs of land as \"startCol.length\" in base 36.\n// Generated from Natural Earth 1:110m land (public domain) via the world-atlas package.\nexport const STEP = 2.5\nexport const LAT_TOP = 80\nexport const COLS = 144\nconst RLE = 'x.b,19.k,26.5,31.3|o.2,11.4,19.j,26.1,35.1|r.2,w.8,1d.f,2m.2,2z.a,3j.3,3n.1|m.2,p.3,t.1,v.2,y.1,10.4,1e.d,2l.1,2s.1,2w.k,3k.2|7.8,p.7,y.1,12.2,15.4,1e.d,28.4,2r.2,2u.y,3w.1|0.2,6.m,t.a,15.1,17.3,1f.8,26.a,2j.a,2u.16|2.1,5.w,12.1,15.4,1f.5,1r.3,24.4,2a.4,2g.1k|6.t,12.1,18.1,1g.3,22.5,28.1l,3u.6|5.8,f.j,15.3,22.5,29.1,2c.1e,3t.2|9.2,j.g,15.6,1y.1,25.2,2a.1a,3r.2|6.1,k.j,15.8,1y.1,23.1,28.1a,3q.3|l.i,15.9,1w.1,1y.3,22.1j,3q.1|l.o,1d.1,20.1k,3l.1|m.o,1e.1,1z.1l|m.n,1a.1,1z.6,26.6,2d.1,2f.4,2l.y|m.m,1w.5,23.3,27.4,2h.2,2l.v,3k.1|m.k,1w.4,23.1,26.1,28.2,2b.9,2l.r,3d.2,3k.1|n.i,1w.4,25.1,2b.9,2m.r,3f.1,3j.1|o.i,1x.7,2d.z,3h.3|p.f,1w.a,28.1,2e.y,3g.1|r.9,12.1,1w.n,2k.t|q.1,s.5,13.1,1v.i,2e.6,2l.r|r.1,t.4,1u.k,2f.6,2m.1,2r.m|u.3,12.2,1t.m,2g.8,2s.8,31.9|u.3,10.1,15.1,1t.m,2g.7,2t.5,31.5|v.6,1u.l,2h.5,2t.4,32.5,3c.1|z.4,1t.n,2h.3,2u.2,33.5,3c.1|11.2,1t.o,2u.2,33.1,35.3,3c.1|12.1,16.1,18.3,1u.q,2u.2,33.1,36.1,3b.1|15.8,1v.p,2w.1,3e.1|15.a,1w.2,1z.1,22.h,32.1,34.1,3a.2|15.b,24.e,33.1,35.1,39.2|14.c,24.d,34.2,38.3|14.f,24.c,34.2,38.3,3c.1,3h.3|13.i,25.b,3j.3|14.i,25.b,37.2,3j.4|15.h,25.b,3d.1,3n.1|15.g,25.b,3g.3|16.e,25.b,2j.1,3e.4,3l.1|17.d,25.a,2i.2,3d.9|18.c,25.9,2i.1,3c.b|18.b,26.8,2h.2,39.f|18.9,26.8,2i.1,39.g|18.9,26.7,3a.f|17.9,27.5,3a.f|17.8,27.4,3a.4,3i.7|17.6,3j.5|17.6,3k.4|17.4,3y.1|16.5,3m.1,3w.1|16.4,3v.1|16.4|16.3|16.2|18.2|'\n\nlet cache = null\n// Returns [{ lat, lon, col, row }] for every land dot.\nexport function worldDots() {\n  if (cache) return cache\n  cache = []\n  RLE.split('|').forEach((line, row) => {\n    if (!line) return\n    line.split(',').forEach((run) => {\n      const [a, b] = run.split('.').map((v) => parseInt(v, 36))\n      for (let col = a; col < a + b; col++) cache.push({ row, col, lat: LAT_TOP - row * STEP, lon: -180 + col * STEP + STEP / 2 })\n    })\n  })\n  return cache\n}\n\nexport const ROWS = RLE.split('|').length\n\n// Equirectangular position inside a width x height box.\nexport const project = (lat, lon, w, h) => [((lon + 180) / 360) * w, ((LAT_TOP - lat) / (ROWS * STEP)) * h]\n"
    }
  ],
  "cssVars": {
    "theme": {
      "color-bg": "var(--bg)",
      "color-panel": "var(--panel)",
      "color-panel2": "var(--panel2)",
      "color-line": "var(--line)",
      "color-line2": "var(--line2)",
      "color-tx": "var(--tx)",
      "color-mute": "var(--mute)",
      "color-faint": "var(--faint)",
      "color-acc": "var(--acc)",
      "color-acc-fg": "var(--acc-fg)"
    },
    "light": {
      "bg": "#ffffff",
      "panel": "#f5f5f7",
      "panel2": "#e8e8ed",
      "line": "#e5e5ea",
      "line2": "#d2d2d7",
      "tx": "#1d1d1f",
      "mute": "#6e6e73",
      "faint": "#a1a1a6",
      "acc": "#1d1d1f",
      "acc-fg": "#ffffff"
    },
    "dark": {
      "bg": "#000000",
      "panel": "#141416",
      "panel2": "#1f1f22",
      "line": "#262628",
      "line2": "#3a3a3d",
      "tx": "#f5f5f7",
      "mute": "#a1a1a6",
      "faint": "#6e6e73",
      "acc": "#f5f5f7",
      "acc-fg": "#000000"
    }
  },
  "css": {
    ".light": {
      "--bg": "#ffffff",
      "--panel": "#f5f5f7",
      "--panel2": "#e8e8ed",
      "--line": "#e5e5ea",
      "--line2": "#d2d2d7",
      "--tx": "#1d1d1f",
      "--mute": "#6e6e73",
      "--faint": "#a1a1a6",
      "--acc": "#1d1d1f",
      "--acc-fg": "#ffffff"
    }
  }
}
