var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { MelodicComponent } from '@melodicdev/core';
import { avatarTemplate } from './avatar.template.js';
import { avatarStyles } from './avatar.styles.js';
/**
 * ml-avatar - User avatar with image, initials, or icon fallback
 *
 * @example
 * ```html
 * <ml-avatar src="/images/user.jpg" alt="John Doe"></ml-avatar>
 * <ml-avatar initials="JD"></ml-avatar>
 * <ml-avatar initials="JD" size="lg"></ml-avatar>
 * ```
 *
 * @slot default - Custom fallback content (icon)
 */
let AvatarComponent = class AvatarComponent {
    constructor() {
        /** Image source URL */
        this.src = '';
        /** Alt text for image */
        this.alt = '';
        /** Initials to display (fallback if no image) */
        this.initials = '';
        /** Avatar size */
        this.size = 'md';
        /** Use rounded square instead of circle */
        this.rounded = false;
        /** Internal: track image load errors */
        this._imageError = false;
        this.handleImageError = () => {
            this._imageError = true;
        };
    }
    getInitials() {
        // Return at most 2 characters
        return this.initials.slice(0, 2).toUpperCase();
    }
};
AvatarComponent = __decorate([
    MelodicComponent({
        selector: 'ml-avatar',
        template: avatarTemplate,
        styles: avatarStyles,
        attributes: ['src', 'alt', 'initials', 'size', 'rounded']
    })
], AvatarComponent);
export { AvatarComponent };
