import { ARROW_DOWN } from "../../../util/keycodes";
import { cloneDeep } from "lodash-es";
export const getItemIndex = (direction, currentItemIndex, numberOfItems) => {
    const increment = direction === ARROW_DOWN ? 1 : -1;
    return (currentItemIndex + increment + numberOfItems) % numberOfItems;
};
/**
 *
 * @param items
 * @param highlightedItemIndex
 */
export function getUpdatedItems(items, highlightedItemIndex) {
    return items.map((item, index) => {
        const newItem = cloneDeep(item);
        return Object.assign(Object.assign({}, newItem), { selected: index === highlightedItemIndex });
    });
}
