// @ts-nocheck
import { __assign, __rest } from "tslib";
import './User.css';
import React from 'react';
import { cn } from '../../utils/bem';
import { getSizeByMap } from '../../utils/getSizeByMap';
import { forwardRefWithAs } from '../../utils/types/PropsWithAsAttributes';
import { Avatar } from '../Avatar/Avatar';
import { Typography } from '../Typography';
export var userPropSize = ['xs', 'm', 's', 'l'];
export var userPropSizeDefault = userPropSize[0];
export var userPropView = ['clear', 'ghost'];
export var userPropViewDefault = userPropView[0];
export var userPropWidth = ['default', 'full'];
export var userPropWidthDefault = userPropWidth[0];
export var userPropStatus = ['available', 'remote', 'out'];
export var cnUser = cn('User');
var titleSizeMap = {
    xs: 'm',
    s: 'm',
    m: 'm'
};
var infoSizeMap = {
    xs: 's',
    s: 'm',
    m: '2xs',
    l: 'xs'
};
var avatarSizeMap = {
    s: 's',
    m: 'm',
    l: 'l'
};
export var User = forwardRefWithAs(function (props, ref) {
    var _a = props.as, as = _a === void 0 ? 'div' : _a, className = props.className, _b = props.size, size = _b === void 0 ? userPropSizeDefault : _b, avatarUrl = props.avatarUrl, name = props.name, _c = props.view, view = _c === void 0 ? userPropViewDefault : _c, _d = props.width, width = _d === void 0 ? userPropWidthDefault : _d, propOnlyAvatar = props.onlyAvatar, info = props.info, contacts = props.contacts, socials = props.socials, status = props.status, description = props.description, otherProps = __rest(props, ["as", "className", "size", "avatarUrl", "name", "view", "width", "onlyAvatar", "info", "contacts", "socials", "status", "description"]);
    var Tag = as;
    var onlyAvatar = propOnlyAvatar || (!name && !info);
    return (React.createElement(Tag, __assign({}, otherProps, { className: cnUser({
            size: size,
            view: view,
            width: width,
            minified: onlyAvatar,
            alignTop: !!contacts || !!socials || !!description
        }, [className]), ref: ref }),
        avatarUrl && (React.createElement("div", { className: cnUser('AvatarWrapper', { status: status }) },
            React.createElement(Avatar, { size: getSizeByMap(avatarSizeMap, size), url: avatarUrl, name: name }))),
        !onlyAvatar && (name || info) && (React.createElement("div", { className: cnUser('Block') },
            name && (React.createElement(Typography.Text, { className: cnUser('Name'), size: getSizeByMap(titleSizeMap, size), weight: "bold" }, name)),
            info && size !== 's' && (React.createElement(Typography.Text, { className: cnUser('Info'), size: getSizeByMap(infoSizeMap, size) }, info)),
            description && React.createElement("div", { className: cnUser('Description') }, description()),
            contacts && React.createElement("div", { className: cnUser('Contacts') }, contacts()),
            socials && React.createElement("div", { className: cnUser('Socials') }, socials())))));
});
