/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { coerceBoolean, CustomElement, FoundationProperty } from '@tylertech/forge-core';
import { BaseComponent } from '../../core/base/base-component';
import { OptionAdapter } from './option-adapter';
import { OPTION_CONSTANTS } from './option-constants';
import { OptionFoundation } from './option-foundation';
/**
 * The custom element class behind the `<forge-option>` element.
 *
 * @tag forge-option
 */
let OptionComponent = class OptionComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            OPTION_CONSTANTS.attributes.VALUE,
            OPTION_CONSTANTS.attributes.LABEL,
            OPTION_CONSTANTS.attributes.SECONDARY_LABEL,
            OPTION_CONSTANTS.attributes.DISABLED,
            OPTION_CONSTANTS.attributes.DIVIDER,
            OPTION_CONSTANTS.attributes.OPTION_CLASS,
            OPTION_CONSTANTS.attributes.LEADING_ICON,
            OPTION_CONSTANTS.attributes.LEADING_ICON_CLASS,
            OPTION_CONSTANTS.attributes.LEADING_ICON_TYPE,
            OPTION_CONSTANTS.attributes.TRAILING_ICON,
            OPTION_CONSTANTS.attributes.TRAILING_ICON_CLASS,
            OPTION_CONSTANTS.attributes.TRAILING_ICON_TYPE
        ];
    }
    constructor() {
        super();
        this._foundation = new OptionFoundation(new OptionAdapter(this));
    }
    initializedCallback() {
        if (!this.hasAttribute('role')) {
            this.setAttribute('role', 'option');
        }
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case OPTION_CONSTANTS.attributes.VALUE:
                this.value = newValue;
                break;
            case OPTION_CONSTANTS.attributes.LABEL:
                this.label = newValue;
                break;
            case OPTION_CONSTANTS.attributes.SECONDARY_LABEL:
                this.secondaryLabel = newValue;
                break;
            case OPTION_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
            case OPTION_CONSTANTS.attributes.DIVIDER:
                this.divider = this.hasAttribute(OPTION_CONSTANTS.attributes.DIVIDER);
                break;
            case OPTION_CONSTANTS.attributes.OPTION_CLASS:
                this.optionClass = newValue;
                break;
            case OPTION_CONSTANTS.attributes.LEADING_ICON:
                this.leadingIcon = newValue;
                break;
            case OPTION_CONSTANTS.attributes.LEADING_ICON_CLASS:
                this.leadingIconClass = newValue;
                break;
            case OPTION_CONSTANTS.attributes.LEADING_ICON_TYPE:
                this.leadingIconType = newValue;
                break;
            case OPTION_CONSTANTS.attributes.TRAILING_ICON:
                this.trailingIcon = newValue;
                break;
            case OPTION_CONSTANTS.attributes.TRAILING_ICON_CLASS:
                this.trailingIconClass = newValue;
                break;
            case OPTION_CONSTANTS.attributes.TRAILING_ICON_TYPE:
                this.trailingIconType = newValue;
                break;
        }
    }
};
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "value", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "label", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "secondaryLabel", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "divider", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "optionClass", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "leadingIcon", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "leadingIconClass", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "leadingIconType", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "leadingIconComponentProps", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "trailingIcon", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "trailingIconClass", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "trailingIconType", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "trailingIconComponentProps", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "leadingBuilder", void 0);
__decorate([
    FoundationProperty()
], OptionComponent.prototype, "trailingBuilder", void 0);
OptionComponent = __decorate([
    CustomElement({
        name: OPTION_CONSTANTS.elementName
    })
], OptionComponent);
export { OptionComponent };
