import * as tslib_1 from "tslib";
import { Component, HostBinding, Input } from '@angular/core';
var NbFormControlComponent = /** @class */ (function () {
    function NbFormControlComponent() {
        this._hasFeedback = false;
        this._nbFormItemControlWrapper = true;
    }
    Object.defineProperty(NbFormControlComponent.prototype, "nbHasFeedback", {
        get: function () {
            return this._hasFeedback;
        },
        set: function (value) {
            this._hasFeedback = value === '';
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NbFormControlComponent.prototype, "isError", {
        get: function () {
            return this._isDirtyAndError('error')
                || this._isDirtyAndError('required')
                || this._isDirtyAndError('pattern')
                || this._isDirtyAndError('email')
                || this._isDirtyAndError('maxlength')
                || this._isDirtyAndError('minlength')
                || this._isDirtyAndError('min')
                || this._isDirtyAndError('max');
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NbFormControlComponent.prototype, "isSuccess", {
        get: function () {
            return this.nbValidateStatus === 'success' || this.nbValidateStatus &&
                this.nbValidateStatus.dirty && this.nbValidateStatus.valid;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NbFormControlComponent.prototype, "hasFeedBack", {
        get: function () {
            return this.nbHasFeedback;
        },
        enumerable: true,
        configurable: true
    });
    NbFormControlComponent.prototype._isDirtyAndError = function (name) {
        return this.nbValidateStatus === name || this.nbValidateStatus &&
            this.nbValidateStatus.dirty && this.nbValidateStatus.hasError && this.nbValidateStatus.hasError(name);
    };
    tslib_1.__decorate([
        HostBinding("class.nb-form-item-control-wrapper"),
        tslib_1.__metadata("design:type", Object)
    ], NbFormControlComponent.prototype, "_nbFormItemControlWrapper", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object),
        tslib_1.__metadata("design:paramtypes", [Object])
    ], NbFormControlComponent.prototype, "nbHasFeedback", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbFormControlComponent.prototype, "nbValidateStatus", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], NbFormControlComponent.prototype, "nbRequired", void 0);
    NbFormControlComponent = tslib_1.__decorate([
        Component({
            selector: '[nb-form-control]',
            template: "\n        <div class=\"nb-form-item-control\"\n             [class.nb-form-item-required]=\"nbRequired\"\n             [class.has-error]=\"isError\"\n             [class.has-success]=\"isSuccess\"\n             [class.has-feedback]=\"hasFeedBack\">\n            <ng-content></ng-content>\n        </div>\n    "
        }),
        tslib_1.__metadata("design:paramtypes", [])
    ], NbFormControlComponent);
    return NbFormControlComponent;
}());
export { NbFormControlComponent };
//# sourceMappingURL=nb-form-control.component.js.map