/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { FIELD_CONSTANTS } from './field-constants';
import { BaseComponent } from '../core/base/base-component';
import { coerceBoolean, ensureChild, FoundationProperty } from '@tylertech/forge-core';
export class FieldComponent extends BaseComponent {
    constructor() {
        super();
    }
    static get observedAttributes() {
        return [
            FIELD_CONSTANTS.attributes.DENSITY,
            FIELD_CONSTANTS.attributes.FLOAT_LABEL_TYPE,
            FIELD_CONSTANTS.attributes.SHAPE,
            FIELD_CONSTANTS.attributes.INVALID,
            FIELD_CONSTANTS.attributes.REQUIRED
        ];
    }
    connectedCallback() {
        if (this.querySelector(FIELD_CONSTANTS.selectors.INPUT)) {
            this._initialize();
        }
        else {
            ensureChild(this, FIELD_CONSTANTS.selectors.INPUT).then(() => this._initialize());
        }
    }
    _initialize() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case FIELD_CONSTANTS.attributes.DENSITY:
                this.density = newValue;
                break;
            case FIELD_CONSTANTS.attributes.FLOAT_LABEL_TYPE:
                this.floatLabelType = newValue;
                break;
            case FIELD_CONSTANTS.attributes.SHAPE:
                this.shape = newValue;
                break;
            case FIELD_CONSTANTS.attributes.INVALID:
                this.invalid = coerceBoolean(newValue);
                break;
            case FIELD_CONSTANTS.attributes.REQUIRED:
                this.required = coerceBoolean(newValue);
                break;
        }
    }
    /**
     * Controls whether the label should be floating or not.
     * @param {boolean} value
     */
    floatLabel(value) {
        this._foundation.floatLabel(value);
    }
}
__decorate([
    FoundationProperty()
], FieldComponent.prototype, "density", void 0);
__decorate([
    FoundationProperty()
], FieldComponent.prototype, "floatLabelType", void 0);
__decorate([
    FoundationProperty()
], FieldComponent.prototype, "shape", void 0);
__decorate([
    FoundationProperty()
], FieldComponent.prototype, "invalid", void 0);
__decorate([
    FoundationProperty()
], FieldComponent.prototype, "required", void 0);
