{
	"$schema": "https://ui.shadcn.com/schema/registry-item.json",
	"name": "Counter-JS-TW",
	"title": "Counter",
	"description": "Flexible animated counter supporting increments + easing.",
	"type": "registry:component",
	"files": [
		{
			"type": "registry:component",
			"path": "Counter/Counter.jsx",
			"content": "import { motion, useSpring, useTransform } from 'motion/react';\nimport { useEffect } from 'react';\n\nfunction Number({ mv, number, height }) {\n  const y = useTransform(mv, latest => {\n    const placeValue = latest % 10;\n    const offset = (10 + number - placeValue) % 10;\n    let memo = offset * height;\n    if (offset > 5) {\n      memo -= 10 * height;\n    }\n    return memo;\n  });\n\n  const baseStyle = {\n    position: 'absolute',\n    inset: 0,\n    display: 'flex',\n    alignItems: 'center',\n    justifyContent: 'center'\n  };\n\n  return <motion.span style={{ ...baseStyle, y }}>{number}</motion.span>;\n}\n\nfunction normalizeNearInteger(num) {\n  const nearest = Math.round(num);\n  const tolerance = 1e-9 * Math.max(1, Math.abs(num));\n  return Math.abs(num - nearest) < tolerance ? nearest : num;\n}\n\nfunction getValueRoundedToPlace(value, place) {\n  const scaled = value / place;\n  return Math.floor(normalizeNearInteger(scaled));\n}\n\nfunction Digit({ place, value, height, digitStyle }) {\n  const isDecimal = place === '.';\n  const valueRoundedToPlace = isDecimal ? 0 : getValueRoundedToPlace(value, place);\n  const animatedValue = useSpring(valueRoundedToPlace);\n\n  useEffect(() => {\n    if (!isDecimal) {\n      animatedValue.set(valueRoundedToPlace);\n    }\n  }, [animatedValue, valueRoundedToPlace, isDecimal]);\n\n  if (isDecimal) {\n    return (\n      <span\n        className=\"relative inline-flex items-center justify-center\"\n        style={{ height, width: 'fit-content', ...digitStyle }}\n      >\n        .\n      </span>\n    );\n  }\n\n  const defaultStyle = {\n    height,\n    position: 'relative',\n    width: '1ch',\n    fontVariantNumeric: 'tabular-nums'\n  };\n\n  return (\n    <span className=\"relative inline-flex overflow-hidden\" style={{ ...defaultStyle, ...digitStyle }}>\n      {Array.from({ length: 10 }, (_, i) => (\n        <Number key={i} mv={animatedValue} number={i} height={height} />\n      ))}\n    </span>\n  );\n}\n\nexport default function Counter({\n  value,\n  fontSize = 100,\n  padding = 0,\n  // same refactored default as your CSS version\n  places = [...value.toString()].map((ch, i, a) => {\n    if (ch === '.') return '.';\n    return (\n      10 **\n      (a.indexOf('.') === -1 ? a.length - i - 1 : i < a.indexOf('.') ? a.indexOf('.') - i - 1 : -(i - a.indexOf('.')))\n    );\n  }),\n  gap = 8,\n  borderRadius = 4,\n  horizontalPadding = 8,\n  textColor = 'white',\n  fontWeight = 'bold',\n  containerStyle,\n  counterStyle,\n  digitStyle,\n  gradientHeight = 16,\n  gradientFrom = 'black',\n  gradientTo = 'transparent',\n  topGradientStyle,\n  bottomGradientStyle\n}) {\n  const height = fontSize + padding;\n\n  const defaultContainerStyle = {\n    position: 'relative',\n    display: 'inline-block'\n  };\n\n  const defaultCounterStyle = {\n    fontSize,\n    display: 'flex',\n    gap,\n    overflow: 'hidden',\n    borderRadius,\n    paddingLeft: horizontalPadding,\n    paddingRight: horizontalPadding,\n    lineHeight: 1,\n    color: textColor,\n    fontWeight,\n    direction: \"ltr\"\n  };\n\n  const gradientContainerStyle = {\n    pointerEvents: 'none',\n    position: 'absolute',\n    inset: 0,\n    display: 'flex',\n    flexDirection: 'column',\n    justifyContent: 'space-between'\n  };\n\n  const defaultTopGradientStyle = {\n    height: gradientHeight,\n    background: `linear-gradient(to bottom, ${gradientFrom}, ${gradientTo})`\n  };\n\n  const defaultBottomGradientStyle = {\n    height: gradientHeight,\n    background: `linear-gradient(to top, ${gradientFrom}, ${gradientTo})`\n  };\n\n  return (\n    <span style={{ ...defaultContainerStyle, ...containerStyle }}>\n      <span style={{ ...defaultCounterStyle, ...counterStyle }}>\n        {places.map(place => (\n          <Digit key={place} place={place} value={value} height={height} digitStyle={digitStyle} />\n        ))}\n      </span>\n      <span style={gradientContainerStyle}>\n        <span style={topGradientStyle ?? defaultTopGradientStyle} />\n        <span style={bottomGradientStyle ?? defaultBottomGradientStyle} />\n      </span>\n    </span>\n  );\n}\n"
		}
	],
	"registryDependencies": [],
	"dependencies": [
		"motion@^12.23.12"
	]
}