var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Config } from '../../../index';
import { Container } from 'aurelia-framework';
import { observable } from "aurelia-binding";
import { I18N } from "aurelia-i18n";
export var StringFilterHelper = (function () {
    function StringFilterHelper(searchMinLength, isMultiple, textChangedCallback) {
        this.searchMinLength = searchMinLength;
        this.isMultiple = isMultiple;
        this.textChangedCallback = textChangedCallback;
        this.displayEmptyFields = false;
        this.i18n = Container.instance.get(I18N);
        this.config = Container.instance.get(Config);
    }
    StringFilterHelper.prototype.isFilterActive = function () {
        return (this.text != null && this.text != this.config.agGridConfig.stringSeparatorAgGridFilter) || this.displayEmptyFields;
    };
    StringFilterHelper.prototype.resetFilter = function () {
        this.textDisplayed = null;
        this.displayEmptyFields = false;
    };
    StringFilterHelper.prototype.getValue = function () {
        return this.textDisplayed;
    };
    StringFilterHelper.prototype.getModelAsString = function () {
        var _a;
        return (_a = this.getValue()) !== null && _a !== void 0 ? _a : this.i18n.tr('grid.noFilter', { ns: "common" });
    };
    StringFilterHelper.prototype.setupContentGuiSideFilter = function () {
        return "<div class=\"col s12 m12 l12\">\n            <ui-field label.bind=\"params.colDef.headerName\">\n                <ui-input value.bind=\"filterHelper.textDisplayed & debounce:500\"></ui-input>\n            </ui-field>\n        </div>";
    };
    StringFilterHelper.prototype.textDisplayedChanged = function (newVal, oldVal) {
        if (newVal == '') {
            newVal = null;
        }
        if (oldVal == '') {
            oldVal = null;
        }
        if (newVal != oldVal) {
            this.text = newVal;
            if ((newVal == null || newVal.length >= this.searchMinLength) && this.textChangedCallback) {
                this.textChangedCallback(newVal, oldVal);
            }
        }
    };
    __decorate([
        observable,
        __metadata("design:type", String)
    ], StringFilterHelper.prototype, "textDisplayed", void 0);
    return StringFilterHelper;
}());

//# sourceMappingURL=string-filter-helper.js.map
