"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Avatar = void 0;
const react_1 = __importDefault(require("react"));
const varsUtilities_1 = require("../../varsUtilities");
const Text_1 = require("../Text");
const Styled_1 = require("../Styled");
const Avatar = ({ color, squared = false, src, onClick, children, size: sizeProp = 'medium', style, light, autoColor, ...rest }) => {
    if (autoColor && !color) {
        color = (0, varsUtilities_1.colorHash)('nonSemanticBackground', children ?? src);
    }
    else if (!color) {
        color = 'grey';
    }
    const size = sizeProp === 'large'
        ? 48
        : sizeProp === 'medium'
            ? 40
            : sizeProp === 'small'
                ? 32
                : sizeProp === 'xsmall'
                    ? 24
                    : 20;
    const fontSize = sizeProp === 'large'
        ? 16
        : sizeProp === 'medium'
            ? 14
            : sizeProp === 'small'
                ? 12
                : 10;
    return (react_1.default.createElement(Styled_1.Center, { style: {
            flexShrink: '0',
            width: size,
            height: size,
            backgroundColor: (0, varsUtilities_1.color)('nonSemanticBackground', color, light ? 'muted' : 'strong'),
            borderRadius: squared ? '8px' : '50%',
            backgroundImage: src ? `url(${src})` : 'none',
            backgroundSize: 'cover',
            backgroundPosition: 'center center',
            ...style,
        }, onClick: onClick, ...rest }, children && !src ? (react_1.default.createElement(Text_1.Text, { selectable: "none", color: "inverted", size: fontSize, style: {
            lineHeight: '32px',
            color: (0, varsUtilities_1.color)('nonSemanticContent', light ? color : 'white', 'primary'),
        } },
        children[0]?.toLocaleUpperCase(),
        children[1]?.toLocaleUpperCase())) : null));
};
exports.Avatar = Avatar;
//# sourceMappingURL=index.js.map