import IfActive from "../../../application/IfActive/index.js";
import { useContestStatus } from "../../../../hooks/election/index.js";
import Flip from '../Flip';
import Held from '../Held';
import Recount from '../Recount';
import Runoff from '../Runoff';
import Rating from '../Rating';
const TagInner = function TagInner(props) {
  const {
    contestId,
    showRating,
    size
  } = props;
  const contestStatus = useContestStatus(contestId);
  const {
    recount,
    outcome,
    outcomeBalanceType
  } = contestStatus;
  if (recount === 'recount') {
    return <Recount contestId={contestId} size={size} />;
  }
  if (outcome === 'runoff') {
    return <Runoff size={size} />;
  }
  if (outcome === 'winner' && outcomeBalanceType === 'flip') {
    return <Flip contestId={contestId} size={size} />;
  }
  if (outcome === 'winner' && outcomeBalanceType === 'hold') {
    return <Held contestId={contestId} size={size} />;
  }
  if (outcome === 'winner') {
    // Do not return the rating if we have a winner
    return null;
  }
  return <IfActive active={showRating}>
      <Rating contestId={contestId} size={size} />
    </IfActive>;
};
export default TagInner;