import { useCandidateMetadata } from "../../../../hooks/election/index.js";
import getColor from "../../../../utils/colors/getColor.js";
import getElectionPaletteColor from "../../../../utils/colors/getElectionPaletteColor.js";
const useDisplayProps = (bop = {}) => {
  const {
    winner = {},
    call = {}
  } = bop;
  const {
    party: winnerParty
  } = winner;
  const {
    subjectType = undefined,
    subjectId = undefined
  } = call;
  const candidateMeta = useCandidateMetadata(subjectId);
  if (!call) {
    return {
      splashBackground: undefined,
      candidateId: undefined
    };
  }
  if (subjectType === 'party') {
    return {
      splashBackground: getColor(getElectionPaletteColor(subjectId, 'bgDefault')),
      candidateId: undefined
    };
  }
  if (subjectType === 'candidate') {
    const {
      party = winnerParty
    } = candidateMeta || {};
    return {
      splashBackground: getColor(getElectionPaletteColor(party, 'bgDefault')),
      candidateId: subjectId
    };
  }
  return {
    splashBackground: undefined,
    candidateId: undefined
  };
};
export default useDisplayProps;