import { isValidElement } from 'react';
import { Avatar } from './avatar.js';

const COLORS = [
    "indigo",
    "orange",
    "mint",
    "neutral",
    "sky",
    "lime",
    "grass",
    "cyan",
    "iris",
    "purple",
    "pink",
    "crimson",
    "gold",
];
function getAvatarColor(str) {
    const hash = str.split("").reduce((acc, char) => acc + char.charCodeAt(0), 0);
    const index = hash % COLORS.length;
    return COLORS[index];
}
/*
 * @desc Recursively get the avatar props even if it's
 * wrapped in another component like Tooltip, Flex, etc.
 */
const getAvatarProps = (element) => {
    const { props } = element;
    if (element.type === Avatar) {
        return props;
    }
    if (props.children) {
        if (isValidElement(props.children)) {
            return getAvatarProps(props.children);
        }
    }
    return {};
};

export { COLORS, getAvatarColor, getAvatarProps };
//# sourceMappingURL=utils.js.map
