/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachLightTemplate, coerceNumber, coerceBoolean, FoundationProperty } from '@tylertech/forge-core';
import { AppBarProfileButtonAdapter } from './app-bar-profile-button-adapter';
import { AppBarProfileButtonFoundation } from './app-bar-profile-button-foundation';
import { APP_BAR_PROFILE_BUTTON_CONSTANTS } from './app-bar-profile-button-constants';
import { ProfileCardComponent } from '../../profile-card';
import { IconButtonComponent } from '../../icon-button';
import { AvatarComponent } from '../../avatar';
import { TooltipComponent } from '../../tooltip';
import { BaseComponent } from '../../core/base/base-component';
import { PopoverComponent } from '../../popover/popover';
const template = '<template><forge-icon-button><forge-avatar aria-hidden=\"true\"></forge-avatar></forge-icon-button><forge-tooltip type=\"label\" placement=\"bottom\">View profile</forge-tooltip></template>';
/**
 * @tag forge-app-bar-profile-button
 *
 * @property {string} avatarImageUrl - The url of the avatar image to display.
 * @property {number} avatarLetterCount - The number of letters to display in the avatar.
 * @property {string} avatarText - The text to display in the avatar.
 * @property {string} avatarIcon - The name of an alternative icon to display in the avatar.
 * @property {string} fullName - The full name.
 * @property {string} email - The email address.
 * @property {boolean} signOutButton - Whether to display the sign out button or not. Defaults to `true`.
 * @property {boolean} profileButton - Whether to display the profile button or not.
 * @property {string} signOutButtonText - The text to display in the sign out button.
 * @property {string} profileButtonText - The text to display in the profile button.
 * @property {boolean} open - Whether the profile card is open or not.
 * @property {IPopoverComponent | undefined} popupElement - The popup element when open.
 * @property {AppBarProfileButtonProfileCardBuilder} profileCardBuilder - Sets the profile card builder callback that will be used to add extra content to the profile card.
 *
 * @attribute {string} [avatar-image-url] - The url of the avatar image to display.
 * @attribute {number} [avatar-letter-count] - The number of letters to display in the avatar.
 * @attribute {string} [avatar-text] - The text to display in the avatar.
 * @attribute {string} [avatar-icon] - The name of an alternative icon to display in the avatar.
 * @attribute {string} [full-name] - The full name.
 * @attribute {string} [email] - The email address.
 * @attribute {boolean} [sign-out-button] - Whether to display the sign out button or not. Defaults to `true`.
 * @attribute {boolean} [profile-button] - Whether to display the profile button or not.
 * @attribute {string} [sign-out-button-text] - The text to display in the sign out button.
 * @attribute {string} [profile-button-text] - The text to display in the profile button.
 * @attribute {boolean} [open] - Whether the profile card is open or not.
 * @attribute {string} [aria-label] - The aria-label to apply to the button.
 * @attribute {string} [aria-labelledby] - The id of an element to use as the aria-labelledby attribute.
 */
let AppBarProfileButtonComponent = class AppBarProfileButtonComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.FULL_NAME,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.EMAIL,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_IMAGE_URL,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_LETTER_COUNT,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_TEXT,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_ICON,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.SIGN_OUT_BUTTON,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.PROFILE_BUTTON,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.SIGN_OUT_BUTTON_TEXT,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.PROFILE_BUTTON_TEXT,
            APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.OPEN
        ];
    }
    constructor() {
        super();
        this._foundation = new AppBarProfileButtonFoundation(new AppBarProfileButtonAdapter(this));
    }
    initializedCallback() {
        attachLightTemplate(this, template);
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.FULL_NAME:
                this.fullName = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.EMAIL:
                this.email = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_IMAGE_URL:
                this.avatarImageUrl = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_LETTER_COUNT:
                this.avatarLetterCount = coerceNumber(newValue);
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_TEXT:
                this.avatarText = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.AVATAR_ICON:
                this.avatarIcon = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.SIGN_OUT_BUTTON:
                this.signOutButton = coerceBoolean(newValue);
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.PROFILE_BUTTON:
                this.profileButton = coerceBoolean(newValue);
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.SIGN_OUT_BUTTON_TEXT:
                this.signOutButtonText = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.PROFILE_BUTTON_TEXT:
                this.profileButtonText = newValue;
                break;
            case APP_BAR_PROFILE_BUTTON_CONSTANTS.attributes.OPEN:
                this.open = coerceBoolean(newValue);
                break;
        }
    }
    get popupElement() {
        return this._foundation.popupElement;
    }
};
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "fullName", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "email", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "avatarImageUrl", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "avatarLetterCount", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "avatarText", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "avatarIcon", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "signOutButton", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "profileButton", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "signOutButtonText", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "profileButtonText", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "open", void 0);
__decorate([
    FoundationProperty()
], AppBarProfileButtonComponent.prototype, "profileCardBuilder", void 0);
AppBarProfileButtonComponent = __decorate([
    CustomElement({
        name: APP_BAR_PROFILE_BUTTON_CONSTANTS.elementName,
        dependencies: [
            PopoverComponent,
            ProfileCardComponent,
            IconButtonComponent,
            AvatarComponent,
            TooltipComponent
        ]
    })
], AppBarProfileButtonComponent);
export { AppBarProfileButtonComponent };
