{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "upstash-leaderboard",
  "title": "Upstash Leaderboard",
  "description": "Ranked leaderboard display for Redis sorted sets (ZSET) with positions, scores, and avatars.",
  "dependencies": [
    "@upstash/redis"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/blocks/upstash/upstash-leaderboard/components/elements/upstash-leaderboard.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\n\ninterface LeaderboardEntry {\n  id: string;\n  name: string;\n  score: number;\n  avatar?: string;\n  highlight?: boolean;\n}\n\ninterface UpstashLeaderboardProps {\n  entries: LeaderboardEntry[];\n  title?: string;\n  showRank?: boolean;\n  maxEntries?: number;\n  scoreLabel?: string;\n  scoreFormat?: (score: number) => string;\n  className?: string;\n}\n\nfunction TrophyIcon({ className }: { className?: string }) {\n  return (\n    <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n      <path d=\"M6 9H4.5a2.5 2.5 0 0 1 0-5H6\" />\n      <path d=\"M18 9h1.5a2.5 2.5 0 0 0 0-5H18\" />\n      <path d=\"M4 22h16\" />\n      <path d=\"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22\" />\n      <path d=\"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22\" />\n      <path d=\"M18 2H6v7a6 6 0 0 0 12 0V2Z\" />\n    </svg>\n  );\n}\n\nfunction CrownIcon({ className }: { className?: string }) {\n  return (\n    <svg className={className} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n      <path d=\"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z\" />\n      <path d=\"M5 21h14\" />\n    </svg>\n  );\n}\n\nconst RANK_COLORS: Record<number, string> = {\n  1: \"text-yellow-500\",\n  2: \"text-gray-400\",\n  3: \"text-amber-600\",\n};\n\nconst RANK_BG: Record<number, string> = {\n  1: \"bg-yellow-500/10\",\n  2: \"bg-gray-400/10\",\n  3: \"bg-amber-600/10\",\n};\n\nfunction defaultScoreFormat(score: number): string {\n  return score.toLocaleString();\n}\n\nexport function UpstashLeaderboard({\n  entries,\n  title = \"Leaderboard\",\n  showRank = true,\n  maxEntries = 10,\n  scoreLabel = \"Score\",\n  scoreFormat = defaultScoreFormat,\n  className,\n}: UpstashLeaderboardProps) {\n  const displayEntries = entries.slice(0, maxEntries);\n\n  return (\n    <div\n      data-slot=\"upstash-leaderboard\"\n      className={cn(\n        \"rounded-lg border border-border bg-card overflow-hidden\",\n        className\n      )}\n    >\n      <div className=\"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30\">\n        <div className=\"flex items-center gap-2\">\n          <TrophyIcon className=\"w-5 h-5 text-yellow-500\" />\n          <h3 className=\"font-semibold\">{title}</h3>\n        </div>\n        <span className=\"text-xs text-muted-foreground\">{scoreLabel}</span>\n      </div>\n\n      <div className=\"divide-y divide-border\">\n        {displayEntries.map((entry, index) => {\n          const rank = index + 1;\n          const isTopThree = rank <= 3;\n\n          return (\n            <div\n              key={entry.id}\n              className={cn(\n                \"flex items-center gap-3 px-4 py-3 transition-colors\",\n                entry.highlight && \"bg-primary/5\",\n                !entry.highlight && \"hover:bg-muted/30\"\n              )}\n            >\n              {showRank && (\n                <div\n                  className={cn(\n                    \"w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold\",\n                    isTopThree ? RANK_BG[rank] : \"bg-muted\",\n                    isTopThree ? RANK_COLORS[rank] : \"text-muted-foreground\"\n                  )}\n                >\n                  {rank === 1 ? (\n                    <CrownIcon className=\"w-4 h-4\" />\n                  ) : (\n                    rank\n                  )}\n                </div>\n              )}\n\n              {entry.avatar ? (\n                <img\n                  src={entry.avatar}\n                  alt={entry.name}\n                  className=\"w-8 h-8 rounded-full object-cover\"\n                />\n              ) : (\n                <div className=\"w-8 h-8 rounded-full bg-muted flex items-center justify-center text-sm font-medium text-muted-foreground\">\n                  {entry.name.charAt(0).toUpperCase()}\n                </div>\n              )}\n\n              <span className={cn(\n                \"flex-1 font-medium truncate\",\n                entry.highlight && \"text-primary\"\n              )}>\n                {entry.name}\n              </span>\n\n              <span className={cn(\n                \"font-mono text-sm tabular-nums\",\n                isTopThree ? RANK_COLORS[rank] : \"text-muted-foreground\"\n              )}>\n                {scoreFormat(entry.score)}\n              </span>\n            </div>\n          );\n        })}\n      </div>\n\n      {entries.length > maxEntries && (\n        <div className=\"px-4 py-2 text-center text-xs text-muted-foreground border-t border-border\">\n          +{entries.length - maxEntries} more entries\n        </div>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Display Redis ZSET data as a ranked leaderboard. Features gold/silver/bronze styling for top 3, avatar support, and score formatting.",
  "categories": [
    "upstash"
  ],
  "type": "registry:block"
}