'use client';

import {useReducedMotion} from 'framer-motion';

/**
 * recharts drives its own animation, so <MotionConfig reducedMotion="user">
 * cannot reach it. This bridges the two: one hook, spread onto every animated
 * recharts primitive.
 */
export function useChartMotion(enabled = true) {
  const reduced = useReducedMotion();

  if (reduced || !enabled) {
    return {isAnimationActive: false as const};
  }
  return {
    isAnimationActive: true as const,
    animationDuration: 500,
    animationBegin: 0,
    animationEasing: 'ease-out' as const,
  };
}
