import { useCallback } from 'react';
import getColor from "../../../utils/colors/getColor.js";
import getElectionPaletteColor from "../../../utils/colors/getElectionPaletteColor.js";
const useGetLabelProps = function useGetLabelProps(colors, format) {
  return useCallback(({
    code
  }) => {
    const color = colors.fipsToPalette.get(code);
    if (!color && format === 'geo') {
      return {
        fill: 'white'
      };
    }
    if (!color) {
      return {
        fill: getColor('warmgray-60'),
        fontWeight: 'normal'
      };
    }
    if (color.statusIsUnclear) {
      return {
        stroke: getColor('warmgray-100'),
        fontWeight: 'bold'
      };
    }
    if (color.status.outcome === 'winner') {
      return {
        fill: 'white',
        stroke: getColor(getElectionPaletteColor(color.palette, 'fgColored')),
        fontWeight: 'bold'
      };
    }
    if (color.status.outcome === 'runoff') {
      return {
        fill: getColor('runoff-contrast'),
        stroke: getColor('runoff'),
        fontWeight: 'bold'
      };
    }
    return {
      fill: getColor('warmgray-100'),
      stroke: getColor(getElectionPaletteColor(color.palette, 'leadingBg')),
      fontWeight: 'bold'
    };
  }, [colors]);
};
export default useGetLabelProps;