import { apnumber, intcomma } from 'journalize';
import { getPartyName } from "../../../../utils/election/index.js";
const defaultHeadline = '{delegates} {party} delegates are up for grabs in {states} states';
export default function getHeadline({
  headline,
  party,
  delegates,
  states
}) {
  const {
    threshold
  } = delegates;
  const numDels = intcomma(threshold);
  const numStates = apnumber(states.length);
  const partyName = getPartyName(party);
  const headlineTemplate = headline || defaultHeadline;
  return headlineTemplate.replace('{delegates}', numDels).replace('{party}', partyName).replace('{states}', numStates);
}