"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const styles_1 = require("@mui/material/styles");
const system_1 = require("@mui/system");
const material_1 = require("@mui/material");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const react_core_1 = require("@selfcommunity/react-core");
const PREFERENCES = [react_core_1.SCPreferences.STAFF_STAFF_BADGE_LABEL, react_core_1.SCPreferences.STAFF_STAFF_BADGE_ICON];
const PREFIX = 'SCUserAvatar';
const classes = {
    root: `${PREFIX}-root`,
    badgeContent: `${PREFIX}-badge-content`,
    badgeContentSmaller: `${PREFIX}-badge-content-xs`
};
const Root = (0, styles_1.styled)(material_1.Badge, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
function UserAvatar(inProps) {
    // PROPS
    const props = (0, system_1.useThemeProps)({
        props: inProps,
        name: PREFIX
    });
    const { className, children = null, hide = false, smaller = false } = props, rest = tslib_1.__rest(props, ["className", "children", "hide", "smaller"]);
    // PREFERENCES
    const scPreferences = (0, react_core_1.useSCPreferences)();
    const preferences = (0, react_1.useMemo)(() => {
        const _preferences = {};
        PREFERENCES.map((p) => (_preferences[p] = p in scPreferences.preferences ? scPreferences.preferences[p].value : null));
        return _preferences;
    }, [scPreferences.preferences]);
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ classes: { root: (0, classnames_1.default)(className, classes.root) }, invisible: hide, overlap: "circular", anchorOrigin: { vertical: 'top', horizontal: 'right' }, showZero: !preferences, badgeContent: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: (0, classnames_1.default)(classes.badgeContent, { [classes.badgeContentSmaller]: smaller }), alt: preferences[react_core_1.SCPreferences.STAFF_STAFF_BADGE_LABEL], src: preferences[react_core_1.SCPreferences.STAFF_STAFF_BADGE_ICON] }) }, rest, { children: children })));
}
exports.default = UserAvatar;
