import { Host, h } from "@stencil/core";
import { checkCircleFilled, userFilled } from "@pine-ds/icons/icons";
/**
 * @part image - The main image element that represents the avatar component.
*/
export class PdsAvatar {
    constructor() {
        this.renderAssetWrapper = () => {
            const style = {
                height: this.avatarSize(),
                width: this.avatarSize()
            };
            return (h("div", { style: style, part: "asset-wrapper" }, this.renderIconOrImage(), this.renderBadge()));
        };
        this.renderAvatar = () => {
            return (this.dropdown
                ?
                    h("button", { class: "pds-avatar__button", type: "button", "aria-label": "Avatar dropdown trigger" }, this.renderAssetWrapper())
                :
                    this.renderAssetWrapper());
        };
        this.renderBadge = () => (this.badge
            // Percentage is average size of icon in relation to total avatar size
            // of all preset sizes found in Figma.
            // Used to allow icons to scale to container size
            && h("pds-icon", { color: "var(--pine-color-purple-600)", class: "pds-avatar__badge", icon: checkCircleFilled, size: "33.53%" }));
        this.renderIconOrImage = () => (this.image
            ? h("img", { alt: this.alt, src: this.image })
            // Percentage is average size of icon in relation to total avatar size
            // of all preset sizes found in Figma.
            // Used to allow icons to scale to container size
            : h("pds-icon", { color: "var(--pine-color-mercury-500)", icon: userFilled, size: "33.53%" }));
        this.classNames = () => ({
            'pds-avatar': true,
            [`pds-avatar--has-image`]: this.image !== '' && this.image !== null, // Remove when FF supports :has selector
            [`pds-avatar--${this.variant}`]: this.variant === 'admin'
        });
        this.alt = null;
        this.badge = false;
        this.componentId = undefined;
        this.dropdown = false;
        this.image = null;
        this.size = 'lg';
        this.variant = 'customer';
    }
    avatarSize() {
        const sizes = {
            xs: '24px',
            sm: '32px',
            md: '40px',
            lg: '56px',
            xl: '64px',
        };
        if (sizes[this.size]) {
            return sizes[this.size];
        }
        else {
            return this.size;
        }
    }
    render() {
        return (h(Host, { key: '0b753aa7cb61c88a3808684a67eb1ee84898822c', id: this.componentId, class: Object.assign({}, this.classNames()) }, this.renderAvatar()));
    }
    static get is() { return "pds-avatar"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["../../global/styles/base.scss", "pds-avatar.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["../../global/styles/base.css", "pds-avatar.css"]
        };
    }
    static get properties() {
        return {
            "alt": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "null"
                        }],
                    "text": "The alt for a custom user image."
                },
                "attribute": "alt",
                "reflect": false,
                "defaultValue": "null"
            },
            "badge": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "false"
                        }],
                    "text": "Determines whether the badge is visible or not."
                },
                "attribute": "badge",
                "reflect": false,
                "defaultValue": "false"
            },
            "componentId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "A unique identifier used for the underlying component `id` attribute."
                },
                "attribute": "component-id",
                "reflect": false
            },
            "dropdown": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "false"
                        }],
                    "text": "Determines whether the avatar functions as a dropdown trigger."
                },
                "attribute": "dropdown",
                "reflect": false,
                "defaultValue": "false"
            },
            "image": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "null"
                        }],
                    "text": "The src for a custom user image."
                },
                "attribute": "image",
                "reflect": false,
                "defaultValue": "null"
            },
            "size": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "| 'xl' // 64px\n  | 'lg' // 56px\n  | 'md' // 40px\n  | 'sm' // 32px\n  | 'xs' // 24px\n  | string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "lg"
                        }],
                    "text": "Size of the avatar. Value can be preset or custom."
                },
                "attribute": "size",
                "reflect": true,
                "defaultValue": "'lg'"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'customer' | 'admin'",
                    "resolved": "\"admin\" | \"customer\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [{
                            "name": "defaultValue",
                            "text": "customer"
                        }],
                    "text": "Determines the variant of avatar. Changes appearance accordingly."
                },
                "attribute": "variant",
                "reflect": true,
                "defaultValue": "'customer'"
            }
        };
    }
}
//# sourceMappingURL=pds-avatar.js.map
