import { useCallback } from 'react';

interface UniformNavigationParams {
  config: {
    cloneCount: number;
  };
  state: {
    itemWidth: number;
    activeIndex: number;
  };
}

/**
 * Hook to calculate the translate X position for uniform carousel.
 * Keeps translate in sync with the active index and clone offset.
 */
export const useUniformTranslateX = ({
  config: { cloneCount },
  state: { itemWidth, activeIndex },
}: UniformNavigationParams) => {
  const getTranslateX = useCallback(
    (index = activeIndex + cloneCount) => {
      if (cloneCount === 0) {
        return 0;
      }

      return -(index * itemWidth);
    },
    [cloneCount, itemWidth, activeIndex],
  );

  return {
    getTranslateX,
  };
};

