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: 'ad4a6fbb56f329d2de7e3da505204e5907e2edff', class: "digi-header-avatar" }, !this.afHideImage && this.afIsLoggedIn && (h("digi-media-image", { key: '88698d3b3e264b0c75006b449e1ce053baaea595', 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: '0d2f3035ada5926f0b2e967f75129d800cc500d6', class: "digi-header-avatar__icon digi-header-avatar__icon-logged-in" }, h(this.currentAvatar, { key: '54b8cfd82f8cc663a9cbf428717de5acd1904147' }, h("title", { key: 'c3d9aa1dd81a22e6546696c1d64f3899c74ab32e' }, this.afPlacerholderTitle)))), this.afIsLoggedIn && (h("span", { key: '8d139eff27551f63846c2a75279438ca8fd913b6', class: "digi-header-avatar__name" }, this.setCurrentLoginName())), !this.afIsLoggedIn && (h("span", { key: '92429c3baff14e6fa269b465ea953843878438c7', class: "digi-header-avatar__icon digi-header-avatar__icon-logged-out" }, h(this.currentAvatar, { key: '02cc5522f465fdda8b3ec93f71a5c1b43528d278' }, h("title", { key: '3565ed9d119fb1cb8ea72de6806e9c7f785acc18' }, this.afPlacerholderTitle)))), !this.afIsLoggedIn && h("slot", { key: 'a24cc7907825dbee8389b6d26ccb18d4bea5e2fb' })));
    }
    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": {}
        };
    }
}
