/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { coerceBoolean, FoundationProperty } from '@tylertech/forge-core';
import { tylIconArrowDropDown } from '@tylertech/tyler-icons/standard';
import { IconRegistry } from '../../icon/icon-registry';
import { BaseComponent } from '../../core/base/base-component';
import { internals, setDefaultAria } from '../../constants';
import { BASE_BUTTON_CONSTANTS } from './base-button-constants';
import { WithLabelAwareness } from '../../core/mixins/label/with-label-aware';
import { WithElementInternals } from '../../core/mixins/internals/with-element-internals';
import { WithDefaultAria } from '../../core/mixins/internals/with-default-aria';
export class BaseButton extends WithDefaultAria(WithElementInternals(WithLabelAwareness(BaseComponent))) {
    static get observedAttributes() {
        return Object.values(BASE_BUTTON_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        // PopoverInvokerElement
        /** @ignore */
        this.popoverTargetElement = null;
        /** @ignore */
        this.popoverTargetAction = 'click';
        IconRegistry.define(tylIconArrowDropDown);
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case BASE_BUTTON_CONSTANTS.observedAttributes.TYPE:
                this.type = newValue;
                return;
            case BASE_BUTTON_CONSTANTS.observedAttributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                return;
            case BASE_BUTTON_CONSTANTS.observedAttributes.POPOVER_ICON:
                this.popoverIcon = coerceBoolean(newValue);
                return;
            case BASE_BUTTON_CONSTANTS.observedAttributes.DENSE:
                this.dense = coerceBoolean(newValue);
                return;
        }
    }
    labelClickedCallback() {
        this._foundation.click({ animateStateLayer: true });
    }
    labelChangedCallback(value) {
        this[setDefaultAria]({ ariaLabel: value }, { setAttribute: !this.hasAttribute('aria-label') });
    }
    get form() {
        return this[internals].form;
    }
    get name() {
        var _a;
        return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
    }
    set name(name) {
        this.setAttribute('name', name);
    }
    get value() {
        var _a;
        return (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
    }
    set value(value) {
        this.setAttribute('value', value);
    }
    click() {
        this._foundation.click({ animateStateLayer: true });
    }
    focus(options) {
        this._foundation.focus(options);
    }
}
BaseButton.formAssociated = true;
__decorate([
    FoundationProperty()
], BaseButton.prototype, "type", void 0);
__decorate([
    FoundationProperty()
], BaseButton.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], BaseButton.prototype, "popoverIcon", void 0);
__decorate([
    FoundationProperty()
], BaseButton.prototype, "dense", void 0);
