import { getStateName } from "../index.js";
/**
 * Utility to format names of Presidential contests
 *
 * @param {Object} metadata
 * @param {Object} opts
 * @param {string} opts.format
 * @returns {string}
 */
const presContestName = function presContestName(metadata, opts = {}) {
  const {
    stateFips
  } = metadata;
  const {
    format = 'long'
  } = opts;

  // e.g., "NM"
  if (format === 'tiny') {
    return getStateName(stateFips, {
      format: 'abbr'
    });
  }

  // e.g., "NM, Pres."
  if (format === 'short') {
    const stateName = getStateName(stateFips, {
      format: 'abbr'
    });
    return `${stateName}, Pres.`;
  }

  // e.g., "New Mexico, Pres.", "New Mexico, Pres."
  if (format === 'medium') {
    const stateName = getStateName(stateFips, {
      format: 'name'
    });
    return `${stateName}, Pres.`;
  }

  // e.g., "President"
  if (format === 'no-state') {
    return 'President';
  }
  const stateName = getStateName(stateFips, {
    format: 'name'
  });
  return `${stateName}, President`;
};
export default presContestName;