{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dust-letters",
  "title": "Dust Letters",
  "type": "registry:component",
  "description": "A headline of dust that scatters and drifts home",
  "dependencies": [],
  "files": [
    {
      "path": "src/kavyn/dust-letters.jsx",
      "type": "registry:file",
      "target": "@components/kavyn/dust-letters.jsx",
      "content": "'use client'\n\nimport { useCanvasLoop } from './canvas-loop'\n\n// Turns text into target points by drawing it off screen and reading the pixels.\nexport function sampleText(text, w, h, step) {\n  const c = document.createElement('canvas')\n  c.width = Math.max(1, Math.floor(w)); c.height = Math.max(1, Math.floor(h))\n  const x = c.getContext('2d', { willReadFrequently: true })\n  if (!x) return []\n  let size = Math.min(h * 0.5, 200)\n  x.font = `700 ${size}px \"Geist Variable\", system-ui, sans-serif`\n  const tw = x.measureText(text).width || 1\n  size = Math.max(12, Math.min(size, (size * w * 0.86) / tw))\n  x.font = `700 ${size}px \"Geist Variable\", system-ui, sans-serif`\n  x.textAlign = 'center'; x.textBaseline = 'middle'; x.fillStyle = '#fff'\n  x.fillText(text, c.width / 2, c.height / 2)\n  let data\n  try { data = x.getImageData(0, 0, c.width, c.height).data } catch { return [] }\n  const out = []\n  for (let y = 0; y < c.height; y += step) for (let xx = 0; xx < c.width; xx += step) if (data[(y * c.width + xx) * 4 + 3] > 128) out.push({ x: xx, y })\n  return out\n}\n\n// A headline made of dust. Sweep through it and the grains scatter, then drift home.\nconst tk = (n, d) => (typeof document === 'undefined' ? d : getComputedStyle(document.documentElement).getPropertyValue(n).trim() || d)\n\nexport default function DustLetters({ text = 'kavyn', color = undefined, density = 4, className = '' }) {\n  const host = useCanvasLoop((ctx, s) => {\n    let parts = []\n    const step = Math.max(2, Math.round(Number(density) || 4))\n    const build = () => {\n      const targets = sampleText(String(text || ' '), s.w, s.h, step).slice(0, 6000)\n      parts = targets.map((t) => ({ hx: t.x, hy: t.y, x: Math.random() * s.w, y: Math.random() * s.h, vx: 0, vy: 0, hot: 0 }))\n    }\n    build()\n    document.fonts?.ready?.then(() => { try { build() } catch { /* ignore */ } }).catch(() => {})\n    return {\n      resize: build,\n      step(dt) {\n        const p = s.pointer, R = Math.max(50, s.w * 0.08)\n        ctx.clearRect(0, 0, s.w, s.h)\n        for (const q of parts) {\n          const dx = q.x - p.x, dy = q.y - p.y, d = Math.hypot(dx, dy)\n          if (d < R && d > 0.1) { const f = (1 - d / R) * 1800; q.vx += (dx / d) * f * dt; q.vy += (dy / d) * f * dt; q.hot = 1 }\n          q.vx += (q.hx - q.x) * 30 * dt; q.vy += (q.hy - q.y) * 30 * dt\n          q.vx *= 0.9; q.vy *= 0.9\n          q.x += q.vx * dt * (s.reduce ? 4 : 1); q.y += q.vy * dt * (s.reduce ? 4 : 1)\n          q.hot *= 0.96\n        }\n        ctx.fillStyle = tk('--tx', '#ededef')\n        for (const q of parts) if (q.hot < 0.2) ctx.fillRect(q.x, q.y, step * 0.55, step * 0.55)\n        ctx.fillStyle = color || tk('--mute', '#a1a1a6')\n        for (const q of parts) if (q.hot >= 0.2) ctx.fillRect(q.x, q.y, step * 0.6, step * 0.6)\n      },\n    }\n  }, [text, color, density])\n  return <div ref={host} className={`relative h-full min-h-60 w-full overflow-hidden bg-bg ${className}`} role=\"img\" aria-label={String(text)} />\n}\n"
    },
    {
      "path": "src/kavyn/canvas-loop.js",
      "type": "registry:file",
      "target": "@components/kavyn/canvas-loop.js",
      "content": "'use client'\n\nimport { useEffect, useRef } from 'react'\n\n// Shared 2D canvas runner for the physics and particle pieces.\n// Sizes the canvas to its box (capped DPR), pauses off screen and in hidden tabs,\n// tracks the pointer in CSS pixels, and hands your step() a ready context.\nexport function useCanvasLoop(setup, deps = []) {\n  const host = useRef(null)\n  useEffect(() => {\n    const el = host.current\n    if (!el || typeof window === 'undefined') return\n    const canvas = document.createElement('canvas')\n    canvas.setAttribute('aria-hidden', 'true')\n    canvas.style.cssText = 'position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none'\n    const ctx = canvas.getContext('2d')\n    if (!ctx) return\n    el.prepend(canvas)\n    const reduce = !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches\n    const state = { w: 0, h: 0, dpr: 1, pointer: { x: -9999, y: -9999, down: false, inside: false, vx: 0, vy: 0 }, reduce }\n    const resize = () => {\n      const dpr = Math.min(2, window.devicePixelRatio || 1)\n      const w = Math.max(1, el.clientWidth), h = Math.max(1, el.clientHeight)\n      if (w === state.w && h === state.h && dpr === state.dpr) return false\n      state.w = w; state.h = h; state.dpr = dpr\n      canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr)\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n      return true\n    }\n    resize()\n    let api = null\n    try { api = setup(ctx, state) || {} } catch { api = {} }\n    const pos = (e) => { const r = el.getBoundingClientRect(); return { x: e.clientX - r.left, y: e.clientY - r.top } }\n    const onMove = (e) => { const p = pos(e); const q = state.pointer; q.vx = p.x - q.x; q.vy = p.y - q.y; q.x = p.x; q.y = p.y; q.inside = true; api.move?.(q) }\n    const onDown = (e) => { const p = pos(e); Object.assign(state.pointer, p, { down: true, inside: true, vx: 0, vy: 0 }); try { canvas.setPointerCapture(e.pointerId) } catch { /* ignore */ } api.down?.(state.pointer) }\n    const onUp = () => { state.pointer.down = false; api.up?.(state.pointer) }\n    const onLeave = () => { if (!state.pointer.down) { state.pointer.inside = false; state.pointer.x = -9999; state.pointer.y = -9999 } }\n    canvas.addEventListener('pointermove', onMove)\n    canvas.addEventListener('pointerdown', onDown)\n    canvas.addEventListener('pointerup', onUp)\n    canvas.addEventListener('pointercancel', onUp)\n    canvas.addEventListener('pointerleave', onLeave)\n    let raf = 0, visible = true, prev = performance.now()\n    const loop = (now) => {\n      raf = 0\n      if (resize()) api.resize?.()\n      const dt = Math.min(1 / 30, Math.max(0, (now - prev) / 1000)); prev = now\n      try { api.step?.(dt, now / 1000) } catch { return }\n      if (visible && !document.hidden) raf = requestAnimationFrame(loop)\n    }\n    const start = () => { if (!raf) { prev = performance.now(); raf = requestAnimationFrame(loop) } }\n    const io = typeof IntersectionObserver !== 'undefined' ? new IntersectionObserver(([e]) => { visible = !!e?.isIntersecting; if (visible) start() }) : null\n    io?.observe(el)\n    const onVis = () => { if (!document.hidden) start() }\n    document.addEventListener('visibilitychange', onVis)\n    start()\n    return () => {\n      cancelAnimationFrame(raf); io?.disconnect()\n      document.removeEventListener('visibilitychange', onVis)\n      canvas.remove()\n    }\n  }, deps) // eslint-disable-line react-hooks/exhaustive-deps\n  return host\n}\n\nexport const clamp = (v, a, b) => Math.min(b, Math.max(a, v))\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"
    }
  }
}
