'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-f6e770c8.js');
const helpers = require('./helpers-987f948e.js');

const colorList = [
    'default',
    'primary',
    'accent',
    'danger',
    'warning',
    'success',
    'info',
    'blue',
    'indigo',
    'purple',
    'pink',
    'red',
    'orange',
    'yellow',
    'green',
    'teal',
    'cyan'
];

const styleCss = "x-avatar{display:inline-block;position:relative;margin:0px;padding:0px}x-avatar>div{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;position:relative;width:1em;height:1em;margin:0px;padding:0px;border-radius:0.45rem;overflow:hidden;background-color:rgba(0, 0, 0, 0.1);background-position:center;background-repeat:no-repeat;background-size:cover;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35)}x-avatar>div:not(.avatar-only-letters){-webkit-transition:background-color 0.2s;transition:background-color 0.2s}x-avatar>div.avatar-image-loaded{background-color:white !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35) !important;box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35) !important}x-avatar>div.avatar-image-loaded span{opacity:0}x-avatar>div.avatar-image-loaded img{opacity:1}x-avatar>div.avatar-rounded,x-avatar>div.avatar-rounded img,x-avatar>div.avatar-rounded span{border-radius:50%}.is-dark-mode x-avatar>div{background-color:rgba(255, 255, 255, 0.1)}x-avatar>div img{width:100%;height:auto;-webkit-transition:0.3s;transition:0.3s;opacity:0;position:absolute}x-avatar>div span{font-size:0.45em;font-weight:normal;-webkit-transition:0.3s;transition:0.3s}x-avatar>div.avatar-primary{background-color:var(--color-primary-tinted, #7b9ef6);color:var(--color-primary-shaded, #2e52a9) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-primary-rgb, 66, 117, 242), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-primary-rgb, 66, 117, 242), 0.35)}.is-dark-mode x-avatar>div.avatar-primary{color:var(--color-primary-shadest, #1e356d) !important}x-avatar>div.avatar-accent{background-color:var(--color-accent-tinted, #f66858);color:var(--color-accent-shaded, #a91b0b) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-accent-rgb, 242, 39, 16), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-accent-rgb, 242, 39, 16), 0.35)}.is-dark-mode x-avatar>div.avatar-accent{color:var(--color-accent-shadest, #6d1207) !important}x-avatar>div.avatar-danger{background-color:var(--color-danger-tinted, #e7727d);color:var(--color-danger-shaded, #9a2530) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-danger-rgb, 220, 53, 69), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-danger-rgb, 220, 53, 69), 0.35)}.is-dark-mode x-avatar>div.avatar-danger{color:var(--color-danger-shadest, #63181f) !important}x-avatar>div.avatar-warning{background-color:var(--color-warning-tinted, #ffce51);color:var(--color-warning-shaded, #b38205) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-warning-rgb, 255, 185, 7), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-warning-rgb, 255, 185, 7), 0.35)}.is-dark-mode x-avatar>div.avatar-warning{color:var(--color-warning-shadest, #735303) !important}x-avatar>div.avatar-success{background-color:var(--color-success-tinted, #4dc696);color:var(--color-success-shaded, #007a4a) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-success-rgb, 0, 174, 105), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-success-rgb, 0, 174, 105), 0.35)}.is-dark-mode x-avatar>div.avatar-success{color:var(--color-success-shadest, #004e2f) !important}x-avatar>div.avatar-info{background-color:var(--color-info-tinted, #56daf5);color:var(--color-info-shaded, #098da8) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-info-rgb, 13, 202, 240), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-info-rgb, 13, 202, 240), 0.35)}.is-dark-mode x-avatar>div.avatar-info{color:var(--color-info-shadest, #065b6c) !important}x-avatar>div.avatar-link{background-color:var(--color-link-tinted, #7b9ef6);color:var(--color-link-shaded, #2e52a9) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-link-rgb, 66, 117, 242), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-link-rgb, 66, 117, 242), 0.35)}.is-dark-mode x-avatar>div.avatar-link{color:var(--color-link-shadest, #1e356d) !important}x-avatar>div.avatar-blue{background-color:var(--color-blue-tinted, #5d9ce4);color:var(--color-blue-shaded, #104f97) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-blue-rgb, 23, 113, 216), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-blue-rgb, 23, 113, 216), 0.35)}.is-dark-mode x-avatar>div.avatar-blue{color:var(--color-blue-shadest, #0a3361) !important}x-avatar>div.avatar-indigo{background-color:var(--color-indigo-tinted, #939edc);color:var(--color-indigo-shaded, #475190) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-indigo-rgb, 101, 116, 205), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-indigo-rgb, 101, 116, 205), 0.35)}.is-dark-mode x-avatar>div.avatar-indigo{color:var(--color-indigo-shadest, #2d345c) !important}x-avatar>div.avatar-purple{background-color:var(--color-purple-tinted, #b590eb);color:var(--color-purple-shaded, #68449e) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-purple-rgb, 149, 97, 226), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-purple-rgb, 149, 97, 226), 0.35)}.is-dark-mode x-avatar>div.avatar-purple{color:var(--color-purple-shadest, #432c66) !important}x-avatar>div.avatar-pink{background-color:var(--color-pink-tinted, #f999b9);color:var(--color-pink-shaded, #ac4c6d) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-pink-rgb, 246, 109, 155), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-pink-rgb, 246, 109, 155), 0.35)}.is-dark-mode x-avatar>div.avatar-pink{color:var(--color-pink-shadest, #6f3146) !important}x-avatar>div.avatar-red{background-color:var(--color-red-tinted, #eb716d);color:var(--color-red-shaded, #9f2421) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-red-rgb, 227, 52, 47), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-red-rgb, 227, 52, 47), 0.35)}.is-dark-mode x-avatar>div.avatar-red{color:var(--color-red-shadest, #661715) !important}x-avatar>div.avatar-orange{background-color:var(--color-orange-tinted, #f9b879);color:var(--color-orange-shaded, #ac6b2c) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-orange-rgb, 246, 153, 63), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-orange-rgb, 246, 153, 63), 0.35)}.is-dark-mode x-avatar>div.avatar-orange{color:var(--color-orange-shadest, #6f451c) !important}x-avatar>div.avatar-yellow{background-color:var(--color-yellow-tinted, #f0d67b);color:var(--color-yellow-shaded, #a4892e) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-yellow-rgb, 234, 196, 66), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-yellow-rgb, 234, 196, 66), 0.35)}.is-dark-mode x-avatar>div.avatar-yellow{color:var(--color-yellow-shadest, #69581e) !important}x-avatar>div.avatar-green{background-color:var(--color-green-tinted, #74d49c);color:var(--color-green-shaded, #278750) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-green-rgb, 56, 193, 114), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-green-rgb, 56, 193, 114), 0.35)}.is-dark-mode x-avatar>div.avatar-green{color:var(--color-green-shadest, #195733) !important}x-avatar>div.avatar-teal{background-color:var(--color-teal-tinted, #82d3cb);color:var(--color-teal-shaded, #36867f) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-teal-rgb, 77, 192, 181), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-teal-rgb, 77, 192, 181), 0.35)}.is-dark-mode x-avatar>div.avatar-teal{color:var(--color-teal-shadest, #235651) !important}x-avatar>div.avatar-cyan{background-color:var(--color-cyan-tinted, #98c9f1);color:var(--color-cyan-shaded, #4c7da5) !important;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-cyan-rgb, 108, 178, 235), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-cyan-rgb, 108, 178, 235), 0.35)}.is-dark-mode x-avatar>div.avatar-cyan{color:var(--color-cyan-shadest, #31506a) !important}x-chip x-avatar>div{width:1.5rem !important;height:1.5rem !important;max-width:1.5rem !important;max-height:1.5rem !important}x-chip x-avatar>div span{font-size:1.1rem}x-avatar x-badge{position:absolute;bottom:-0.25em;left:-0.25em;-webkit-box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35);box-shadow:0px 3px 1rem rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(var(--color-border-rgb, 200, 199, 204), 0.35);margin:0;font-size:0.25em;height:1.5em;padding-left:0.5em;padding-right:0.5em}";
const XAvatarStyle0 = styleCss;

const XAvatar = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.image = undefined;
        this.letters = '?';
        this.size = '3rem';
        this.rounded = false;
        this.imageLoaded = false;
        this.imageError = false;
    }
    /**
     * Get a number index by letter
     *
     * @returns
     */
    getLetterNumber() {
        const text = (this.letters || 'A').toUpperCase();
        const size = (this.letters || 'A').length;
        let number = 0;
        for (let position = 0; position < size; position++) {
            number += (text.charCodeAt(position) - 64) * Math.pow(26, size - position - 1);
        }
        return number;
    }
    /**
     * Get the color relative to the letters
     *
     * @returns
     */
    getColorByLetters() {
        const list = colorList.filter(color => color != 'default');
        return list[this.getLetterNumber() % list.length];
    }
    /**
     * Callback on finished loaded image
     *
     * @param event
     */
    onLoadImage() {
        this.imageLoaded = true;
    }
    /**
     * Callback error on loaded image
     *
     * @param event
     */
    onErrorImage() {
        this.imageError = true;
    }
    /**
     * Render component
     */
    render() {
        var _a;
        return index.h(index.Host, { key: '8afae1b521dd9063ac4897827b6f5b87763a4b50', style: { fontSize: this.size } }, index.h("div", { key: 'd57d131fdaf8a3dc4ce773ad437d3502753e0059', class: helpers.cls(`avatar-${this.getColorByLetters()}`, {
                'avatar-only-letters': !this.image,
                'avatar-image-loaded': this.imageLoaded && !this.imageError,
                'avatar-rounded': this.rounded,
            }) }, ((_a = this.image) === null || _a === void 0 ? void 0 : _a.length) && index.h("img", { key: 'c13a4dd363bc355345b4411201588b18285ebdca', src: this.image, alt: this.letters, onLoad: () => this.onLoadImage(), onError: () => this.onErrorImage() }), index.h("span", { key: '53efed99361231f4e68c6f36f0e2e5701bbaffbe' }, this.letters.substring(0, 2))), index.h("slot", { key: '0153f9d432c1e49535fa04be65bc8377fcf11be8' }));
    }
};
XAvatar.style = XAvatarStyle0;

exports.x_avatar = XAvatar;
