"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BooleanFloatingFilter = void 0;
var boolean_filter_helper_1 = require("./boolean-filter-helper");
var aurelia_framework_1 = require("aurelia-framework");
var aurelia_i18n_1 = require("aurelia-i18n");
var base_floating_filter_1 = __importDefault(require("../base-floating-filter"));
var BooleanFloatingFilter = exports.BooleanFloatingFilter = (function (_super) {
    __extends(BooleanFloatingFilter, _super);
    function BooleanFloatingFilter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    BooleanFloatingFilter.prototype.init = function (params) {
        this.filterHelper = new boolean_filter_helper_1.BooleanFilterHelper();
        _super.prototype.init.call(this, params);
        this.groupName = Math.random().toString();
        this.i18n = aurelia_framework_1.Container.instance.get(aurelia_i18n_1.I18N);
        if (this.i18n != null) {
            this.filterHelper.setFilterNames([this.i18n.tr(params.noFilterName || 'grid.noFilter', { ns: "common" }), this.i18n.tr(params.trueFilterName || 'grid.yes', { ns: "common" }), this.i18n.tr(params.falseFilterName || 'grid.no', { ns: "common" })]);
            this.filterHelper.setFilterIcons([(params.noFilterIcon || 'digi-filter'), (params.trueFilterIcon || 'digi-valid'), (params.falseFilterIcon || 'digi-cross')]);
        }
        this.selectedIndex = 0;
        this.setDropDown();
        _super.prototype.setupGui.call(this);
    };
    BooleanFloatingFilter.prototype.resetFilter = function () {
        this.selectedIndex = this.filterHelper.getFilterValueIndex(this.filterHelper.getFilterNone());
    };
    BooleanFloatingFilter.prototype.setupContentGui = function () {
        return this.filterHelper.setupContentGui(this.groupName);
    };
    BooleanFloatingFilter.prototype.setupContentGuiSideFilter = function () {
        return this.filterHelper.setupContentGuiSideFilter();
    };
    BooleanFloatingFilter.prototype.getModelAsString = function () {
        return this.filterHelper.getModelAsString(this.selectedIndex);
    };
    BooleanFloatingFilter.prototype.selectedIndexChanged = function (newVal, oldVal) {
        var _this = this;
        if (newVal != oldVal && !this.firstTime) {
            this.setDropDown();
            this.params.parentFilterInstance(function (instance) {
                instance.setModel({ "filterType": "boolean", "filter": _this.filterHelper.getFilterValue(_this.selectedIndex) });
            });
        }
    };
    BooleanFloatingFilter.prototype.onParentModelChanged = function (parentModel, filterChangedEvent) {
        this.selectedIndex = ((parentModel && parentModel.filter) ? (this.filterHelper.getFilterValueIndex(parentModel.filter)) : 0);
        this.setDropDown();
    };
    BooleanFloatingFilter.prototype.setDropDown = function () {
        this.DROPDOWN_NAME = this.getModelAsString();
        this.DROPDOWN_ICON = this.filterHelper.getFilterIcon(this.selectedIndex);
    };
    __decorate([
        aurelia_framework_1.observable,
        __metadata("design:type", Number)
    ], BooleanFloatingFilter.prototype, "selectedIndex", void 0);
    return BooleanFloatingFilter;
}(base_floating_filter_1.default));

//# sourceMappingURL=boolean-floating-filter.js.map
