import { h } from "@stencil/core";
import { avatarPlaceholder } from "./avatars/avatars";
/**
 *
 *
 * @swedishName Sidhuvud-avatar
 */
export class NavigationAvatar {
    constructor() {
        this.currentAvatar = undefined;
        this.afIsLoggedIn = true;
        this.afSrc = undefined;
        this.afAlt = undefined;
        this.afShowPlaceholderImage = undefined;
        this.afHideImage = false;
        this.afName = undefined;
        this.afHideName = false;
        this.afSignature = undefined;
        this.afHideSignature = false;
        this.afUserPlacerholder = 'Inloggad';
        this.afPlacerholderTitle = '';
        this.afHideUser = false;
    }
    setCurrentLoginName() {
        if (!this.afHideName && !this.afHideSignature) {
            return this.afName + ' (' + this.afSignature + ')';
        }
        if (!this.afHideSignature) {
            return this.afSignature;
        }
        if (!this.afHideName) {
            return this.afName;
        }
        if (this.afHideUser) {
            return this.afUserPlacerholder;
        }
    }
    setAvatarPlaceholder(name) {
        const { AvatarPlaceholderComponent } = avatarPlaceholder[name];
        this.currentAvatar = AvatarPlaceholderComponent;
    }
    componentWillLoad() {
        this.getAvatar();
    }
    getAvatar() {
        if (this.afIsLoggedIn) {
            return this.setAvatarPlaceholder('avatar-logged-in');
        }
        else {
            return this.setAvatarPlaceholder('avatar-logged-out');
        }
    }
    render() {
        if (this.afShowPlaceholderImage) {
            this.afHideImage = true;
        }
        return (h("div", { key: 'd92a2c1a9352fd2a56df7cbad6a6c3f2c68caecd', class: "digi-header-avatar" }, !this.afHideImage && this.afIsLoggedIn && (h("digi-media-image", { key: 'b9aecc4059a8e69b946c54c74371c1804f699a25', class: 'digi-header-avatar__image', "af-height": "32", "af-width": "32", afUnlazy: true, "af-src": this.afSrc, afAlt: this.afAlt })), this.afShowPlaceholderImage && this.afIsLoggedIn && (h("span", { key: 'dc6b66cab7b8bdb46060123130627289a6d8b12b', class: "digi-header-avatar__icon digi-header-avatar__icon-logged-in" }, h(this.currentAvatar, { key: 'b893994829ece85bebe5fbc168724b36c54da5e3' }, h("title", { key: '2d00431f10f5d1c4bcad4b8cec60cee95763c78f' }, this.afPlacerholderTitle)))), this.afIsLoggedIn && (h("span", { key: '3e7abd2b59568800b56b31aa055e34ac7e8407ea', class: "digi-header-avatar__name" }, this.setCurrentLoginName())), !this.afIsLoggedIn && (h("span", { key: '1fc58de76baf36c2591fec08e10ef90daa1701e8', class: "digi-header-avatar__icon digi-header-avatar__icon-logged-out" }, h(this.currentAvatar, { key: '69221a6797b1c8c96a11ee8d8654a6aeee5a8d53' }, h("title", { key: 'abea1ff5fae414ae81323a3d47348ffcc58aeb36' }, this.afPlacerholderTitle)))), !this.afIsLoggedIn && h("slot", { key: 'f129fa9f48732c2dc0fae65c76f90315d53ee8ee' })));
    }
    static get is() { return "digi-header-avatar"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["header-avatar.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["header-avatar.css"]
        };
    }
    static get properties() {
        return {
            "afIsLoggedIn": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Shows the avatar if logged in."
                        }],
                    "text": "F\u00F6r att visa avataren om man \u00E4r inloggad"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-is-logged-in",
                "reflect": false,
                "defaultValue": "true"
            },
            "afSrc": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Sets `src` attribute."
                        }],
                    "text": "S\u00E4tter attributet 'src'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-src",
                "reflect": false
            },
            "afAlt": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Sets `alt` attribute."
                        }],
                    "text": "S\u00E4tter attributet 'alt'."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-alt",
                "reflect": false
            },
            "afShowPlaceholderImage": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Shows placerholder image if profile image isn't available."
                        }],
                    "text": "Visar placeholderbild om profilbild inte finns"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-show-placeholder-image",
                "reflect": false
            },
            "afHideImage": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Hides profile image."
                        }],
                    "text": "D\u00F6ljer profilbilden."
                },
                "getter": false,
                "setter": false,
                "attribute": "af-hide-image",
                "reflect": false,
                "defaultValue": "false"
            },
            "afName": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Sets user name"
                        }],
                    "text": "S\u00E4tter namnet p\u00E5 anv\u00E4ndaren"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-name",
                "reflect": false
            },
            "afHideName": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Hides user name"
                        }],
                    "text": "D\u00F6ljer anv\u00E4ndarens namn"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-hide-name",
                "reflect": false,
                "defaultValue": "false"
            },
            "afSignature": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Set user signature"
                        }],
                    "text": "S\u00E4tter anv\u00E4ndarens signatur"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-signature",
                "reflect": false
            },
            "afHideSignature": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Hide user signature"
                        }],
                    "text": "D\u00F6ljer anv\u00E4ndarens signatur"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-hide-signature",
                "reflect": false,
                "defaultValue": "false"
            },
            "afUserPlacerholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Shows a placeholder text if user is hidden"
                        }],
                    "text": "Visar en placeholdertext om anv\u00E4ndaren \u00E4r dold"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-user-placerholder",
                "reflect": false,
                "defaultValue": "'Inloggad'"
            },
            "afPlacerholderTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Shows title for placeholder avatar"
                        }],
                    "text": "Title f\u00F6r placeholderikonen"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-placerholder-title",
                "reflect": false,
                "defaultValue": "''"
            },
            "afHideUser": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "Hide user"
                        }],
                    "text": "D\u00F6ljer anv\u00E4ndaren helt"
                },
                "getter": false,
                "setter": false,
                "attribute": "af-hide-user",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "currentAvatar": {}
        };
    }
}
