import getElectionPaletteColor from "../../../../utils/colors/getElectionPaletteColor.js";
import getColor from "../../../../utils/colors/getColor.js";
import { useMapColorContext } from '../context';
const useBadgeProps = function useBadgeProps(code) {
  const colors = useMapColorContext();
  if (!colors) return undefined;
  const color = colors.fipsToPalette.get(code);
  if (!color) return undefined;
  const {
    status,
    palette
  } = color;
  const {
    outcome,
    outcomeBalanceType,
    winningParty
  } = status;
  const main = getColor(getElectionPaletteColor(palette, 'main'));
  if (outcomeBalanceType === 'flip' && winningParty === 'gop') {
    return {
      bg: main,
      fg: 'white',
      stroke: 'white',
      iconType: 'OutcomeFlipToGop'
    };
  }
  if (outcomeBalanceType === 'flip' && winningParty === 'dem') {
    return {
      bg: main,
      fg: 'white',
      stroke: 'white',
      iconType: 'OutcomeFlipToDem'
    };
  }
  if (outcome === 'runoff') {
    return {
      bg: getColor('runoff'),
      fg: getColor('runoff-contrast'),
      stroke: getColor('yellow-90'),
      iconType: 'OutcomeRunoff'
    };
  }
  return undefined;
};
export default useBadgeProps;