import getElectionPalette from './getElectionPalette';

/**
 * Get a particular color from an election color palette based on the role you
 * want the color to play. This utility returns a color name, which you can
 * then pass to `getColor` to retrieve an actual color value if necessary.
 *
 * @param {ElectionColorPaletteId} palette
 *   The name of the palette to use. This should be the name of a valid
 *   election color palette (e.g., `dem`, `gop`).
 * @param {ElectionColorPaletteRole} role
 *   The color role you want to select from the palette.
 * @returns {string}
 */
const getElectionPaletteColor = function getElectionPaletteColor(palette, role = 'main') {
  const colors = getElectionPalette(palette);
  if (!colors) return undefined;
  return colors[role];
};
export default getElectionPaletteColor;