{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"xp-bar","type":"registry:ui","title":"XP Bar","description":"A level badge and a spring-filled progress bar that bursts when the player levels up.","dependencies":["motion"],"registryDependencies":["https://ui.mekaigames.com/r/theme.json"],"files":[{"path":"components/ui/xp-bar.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { useState } from \"react\";\n\ntype XpBarProps = {\n  xp: number;\n  perLevel?: number;\n  color?: string;\n  className?: string;\n};\n\nconst BURST = Array.from({ length: 10 }, (_, i) => (i / 10) * Math.PI * 2);\n\nexport function XpBar({ xp, perLevel = 100, color = \"#ffc24a\", className = \"\" }: XpBarProps) {\n  const level = Math.floor(xp / perLevel) + 1;\n  const into = xp % perLevel;\n  // Only celebrate levels gained after mount, not the starting level.\n  const [startLevel] = useState(level);\n  const leveledUp = level > startLevel;\n\n  return (\n    <div className={`flex items-center gap-3 ${className}`}>\n      <div className=\"relative grid size-11 shrink-0 place-items-center\">\n        <motion.div\n          key={level}\n          initial={leveledUp ? { scale: 1.7, rotate: -12 } : false}\n          animate={{ scale: 1, rotate: 0 }}\n          transition={{ type: \"spring\", stiffness: 380, damping: 14 }}\n          className=\"grid size-11 place-items-center rounded-md border-2 font-display text-lg font-extrabold tabular-nums\"\n          style={{ borderColor: color, color, backgroundColor: `${color}1a` }}\n          aria-label={`Level ${level}`}\n        >\n          {level}\n        </motion.div>\n        <AnimatePresence>\n          {leveledUp ? (\n            <motion.div key={level} className=\"pointer-events-none absolute inset-0\" aria-hidden=\"true\">\n              {BURST.map((angle, i) => (\n                <motion.span\n                  key={i}\n                  className=\"absolute left-1/2 top-1/2 size-1.5\"\n                  style={{ backgroundColor: color }}\n                  initial={{ x: -3, y: -3, opacity: 1 }}\n                  animate={{ x: Math.cos(angle) * 34 - 3, y: Math.sin(angle) * 34 - 3, opacity: 0 }}\n                  transition={{ duration: 0.6, ease: \"easeOut\" }}\n                />\n              ))}\n            </motion.div>\n          ) : null}\n        </AnimatePresence>\n      </div>\n\n      <div className=\"min-w-0 flex-1\">\n        <div\n          className=\"h-3 overflow-hidden rounded-[3px] bg-white/8 ring-1 ring-inset ring-white/10\"\n          role=\"progressbar\"\n          aria-label={`Progress to level ${level + 1}`}\n          aria-valuemin={0}\n          aria-valuemax={perLevel}\n          aria-valuenow={into}\n        >\n          <motion.div\n            key={level}\n            className=\"relative h-full\"\n            style={{ backgroundColor: color }}\n            initial={{ width: 0 }}\n            animate={{ width: `${(into / perLevel) * 100}%` }}\n            transition={{ type: \"spring\", stiffness: 90, damping: 18, delay: 0.1 }}\n          >\n            <span className=\"absolute inset-y-0 right-0 w-1.5 bg-white/70\" />\n          </motion.div>\n        </div>\n        <p className=\"mt-1.5 flex justify-between text-xs tabular-nums text-bone-dim\">\n          <span>\n            {into} / {perLevel} XP\n          </span>\n          <span>\n            {perLevel - into} to level {level + 1}\n          </span>\n        </p>\n      </div>\n    </div>\n  );\n}\n"}]}