import { useCallback } from 'react';
const useSortBoundariesCompare = function useSortBoundariesCompare(colors) {
  return useCallback((a, b) => {
    const aColor = colors.fipsToPalette.get(a.code);
    const bColor = colors.fipsToPalette.get(b.code);
    if (!aColor) return -1;
    if (!bColor) return 1;
    const aIsUnclear = aColor.status === 'unclear' || aColor.statusIsUnclear;
    const aIsRunoff = aColor.status.outcome === 'runoff';
    const bIsUnclear = bColor.status === 'unclear' || bColor.statusIsUnclear;
    const bIsRunoff = bColor.status.outcome === 'runoff';
    if (!aIsUnclear && bIsRunoff) return -1;
    if (aIsUnclear && bIsUnclear) return 0;
    if (aIsRunoff && bIsRunoff) return 0;
    if (aIsUnclear && bIsRunoff) return 0;
    if (!aIsUnclear && !bIsUnclear) return 0;
    if (aIsRunoff) return 1;
    if (aIsUnclear) return 1;
    return -1;
  }, [colors]);
};
export default useSortBoundariesCompare;