import getElectionPalette from "../colors/getElectionPalette.js";
import getColor from "../colors/getColor.js";

/**
 * Get a set of CSS variable definitions for a particular election palette.
 *
 * @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`).
 * @returns {Object}
 */
const getElectionPaletteCssVariables = function getElectionPaletteCssVariables(palette) {
  const colors = getElectionPalette(palette);
  if (!colors) return {};
  return Object.fromEntries(Object.entries(colors).map(([name, color]) => [`--election-palette-${name}`, getColor(color)]));
};
export default getElectionPaletteCssVariables;