'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var box = require('../box/box.cjs');
var avatar_module = require('./avatar.module.css.cjs');
var index = require('../../node_modules/.pnpm/@radix-ui_react-avatar@1.1.10_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@19.1._5qc66ks5idtunqcw6cbfdp4iwy/node_modules/@radix-ui/react-avatar/dist/index.cjs');

const avatar = index$1.cva(avatar_module.default.avatar, {
    variants: {
        radius: {
            small: avatar_module.default['avatar-small'],
            full: avatar_module.default['avatar-full']
        },
        size: {
            1: avatar_module.default['avatar-size-1'],
            2: avatar_module.default['avatar-size-2'],
            3: avatar_module.default['avatar-size-3'],
            4: avatar_module.default['avatar-size-4'],
            5: avatar_module.default['avatar-size-5'],
            6: avatar_module.default['avatar-size-6'],
            7: avatar_module.default['avatar-size-7'],
            8: avatar_module.default['avatar-size-8'],
            9: avatar_module.default['avatar-size-9'],
            10: avatar_module.default['avatar-size-10'],
            11: avatar_module.default['avatar-size-11'],
            12: avatar_module.default['avatar-size-12'],
            13: avatar_module.default['avatar-size-13']
        },
        variant: {
            solid: avatar_module.default['avatar-solid'],
            soft: avatar_module.default['avatar-soft']
        },
        disabled: {
            true: avatar_module.default['avatar-disabled']
        },
        color: {
            indigo: avatar_module.default['avatar-color-indigo'],
            orange: avatar_module.default['avatar-color-orange'],
            mint: avatar_module.default['avatar-color-mint'],
            neutral: avatar_module.default['avatar-color-neutral'],
            sky: avatar_module.default['avatar-color-sky'],
            lime: avatar_module.default['avatar-color-lime'],
            grass: avatar_module.default['avatar-color-grass'],
            cyan: avatar_module.default['avatar-color-cyan'],
            iris: avatar_module.default['avatar-color-iris'],
            purple: avatar_module.default['avatar-color-purple'],
            pink: avatar_module.default['avatar-color-pink'],
            crimson: avatar_module.default['avatar-color-crimson'],
            gold: avatar_module.default['avatar-color-gold']
        }
    },
    compoundVariants: [
        {
            variant: 'solid',
            color: 'indigo',
            className: avatar_module.default['avatar-solid-indigo']
        },
        {
            variant: 'solid',
            color: 'orange',
            className: avatar_module.default['avatar-solid-orange']
        },
        { variant: 'solid', color: 'mint', className: avatar_module.default['avatar-solid-mint'] },
        { variant: 'solid', color: 'sky', className: avatar_module.default['avatar-solid-sky'] },
        { variant: 'solid', color: 'lime', className: avatar_module.default['avatar-solid-lime'] },
        {
            variant: 'solid',
            color: 'grass',
            className: avatar_module.default['avatar-solid-grass']
        },
        { variant: 'solid', color: 'cyan', className: avatar_module.default['avatar-solid-cyan'] },
        { variant: 'solid', color: 'iris', className: avatar_module.default['avatar-solid-iris'] },
        {
            variant: 'solid',
            color: 'purple',
            className: avatar_module.default['avatar-solid-purple']
        },
        { variant: 'solid', color: 'pink', className: avatar_module.default['avatar-solid-pink'] },
        {
            variant: 'solid',
            color: 'crimson',
            className: avatar_module.default['avatar-solid-crimson']
        },
        { variant: 'solid', color: 'gold', className: avatar_module.default['avatar-solid-gold'] },
        {
            variant: 'soft',
            color: 'indigo',
            className: avatar_module.default['avatar-soft-indigo']
        },
        {
            variant: 'soft',
            color: 'orange',
            className: avatar_module.default['avatar-soft-orange']
        },
        { variant: 'soft', color: 'mint', className: avatar_module.default['avatar-soft-mint'] },
        { variant: 'soft', color: 'sky', className: avatar_module.default['avatar-soft-sky'] },
        { variant: 'soft', color: 'lime', className: avatar_module.default['avatar-soft-lime'] },
        { variant: 'soft', color: 'grass', className: avatar_module.default['avatar-soft-grass'] },
        { variant: 'soft', color: 'cyan', className: avatar_module.default['avatar-soft-cyan'] },
        { variant: 'soft', color: 'iris', className: avatar_module.default['avatar-soft-iris'] },
        {
            variant: 'soft',
            color: 'purple',
            className: avatar_module.default['avatar-soft-purple']
        },
        { variant: 'soft', color: 'pink', className: avatar_module.default['avatar-soft-pink'] },
        {
            variant: 'soft',
            color: 'crimson',
            className: avatar_module.default['avatar-soft-crimson']
        },
        { variant: 'soft', color: 'gold', className: avatar_module.default['avatar-soft-gold'] }
    ],
    defaultVariants: {
        size: 3,
        radius: 'small',
        variant: 'soft',
        color: 'indigo'
    }
});
const image = index$1.cva(avatar_module.default.image);
/*
 * @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 (React.isValidElement(props.children)) {
            return getAvatarProps(props.children);
        }
    }
    return {};
};
const AvatarRoot = React.forwardRef(({ className, alt, src, fallback, size, radius, variant, color, ...props }, ref) => (jsxRuntime.jsx(box.Box, { className: avatar_module.default.imageWrapper, children: jsxRuntime.jsxs(index.Root, { ref: ref, className: index$1.cx(avatar({ size, radius, variant, color }), className), ...props, children: [jsxRuntime.jsx(index.Image, { className: image(), src: src, alt: alt }), jsxRuntime.jsx(index.Fallback, { className: avatar_module.default.fallback, children: fallback })] }) })));
AvatarRoot.displayName = index.Root.displayName;
const Avatar = AvatarRoot;
const AvatarGroup = React.forwardRef(({ children, max, className, ...props }, ref) => {
    const avatars = max ? children.slice(0, max) : children;
    const count = max && children.length > max ? children.length - max : 0;
    // Overflow avatar matches the first avatar styling
    const firstAvatarProps = getAvatarProps(avatars[0]);
    return (jsxRuntime.jsxs("div", { ref: ref, className: index$1.cx(avatar_module.default.avatarGroup, className), ...props, children: [avatars.map((avatar, index) => (jsxRuntime.jsx("div", { className: avatar_module.default.avatarWrapper, children: avatar }, index))), count > 0 && (jsxRuntime.jsx("div", { className: avatar_module.default.avatarWrapper, children: jsxRuntime.jsx(Avatar, { size: firstAvatarProps.size, radius: firstAvatarProps.radius, variant: firstAvatarProps.variant, color: 'neutral', fallback: `+${count}` }) }))] }));
});

exports.Avatar = Avatar;
exports.AvatarGroup = AvatarGroup;
exports.getAvatarProps = getAvatarProps;
//# sourceMappingURL=avatar.cjs.map
