import PropTypes from 'prop-types';
import { StatesGeo, StatesCarto } from "../../maps/index.js";
import { useGetMapLabelProps, useGetMapFills } from "../../../hooks/election/index.js";

/**
 * A map of the country displaying electoral results in states.
 */
const NationalStatesMap = function NationalStatesMap(props) {
  const {
    colors,
    format,
    tooltip,
    ...restProps
  } = props;
  const getFillProps = useGetMapFills(colors, format);
  const getLabelProps = useGetMapLabelProps(colors, format);
  const Map = format === 'geo' ? StatesGeo : StatesCarto;
  return <Map getBoundaryProps={getFillProps} getLabelProps={getLabelProps} tooltip={tooltip} labelStyle="abbr" {...restProps} />;
};
NationalStatesMap.defaultProps = {
  format: 'carto',
  tooltip: undefined
};
NationalStatesMap.propTypes = {
  /**
   * An object of palettes and legend configurations to show, as returned by `Hooks/getMapFills`
   */
  colors: PropTypes.string.isRequired,
  /**
   * The format the map should display
   */
  format: PropTypes.oneOf(['geo', 'carto']),
  /**
   * The map's tooltip
   */
  tooltip: PropTypes.shape({})
};
export default NationalStatesMap;