"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var moment = require("moment");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var DateFilterOld = (function (_super) {
    __extends(DateFilterOld, _super);
    function DateFilterOld(settings, dateUtility, transformService) {
        var _this = _super.call(this) || this;
        _this.date = dateUtility;
        _this.transformService = transformService;
        _this.valueSelector = settings.valueSelector;
        _this.type = settings.type;
        _this.showClear = settings.showClear;
        _this.useDateRange = settings.useDateRange;
        _this.useTime = settings.useTime != null ? settings.useTime : false;
        _this.label = settings.label;
        _this.template = "<rl-date-filter filter=\"filter\" source=\"dataSource\" label=\"{{filter.label}}\" include-time=\"filter.useTime\"\n\t\t\t\t\t\t\t\t\t     include-date-range=\"filter.useDateRange\" clear-button=\"filter.showClear\"></rl-date-filter>";
        return _this;
    }
    Object.defineProperty(DateFilterOld.prototype, "dateFrom", {
        get: function () {
            return this._dateFrom;
        },
        set: function (value) {
            if (this._dateFrom != value) {
                this._dateFrom = value;
                this.onChange();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(DateFilterOld.prototype, "dateTo", {
        get: function () {
            return this._dateTo;
        },
        set: function (value) {
            if (this._dateTo != value) {
                this._dateTo = value;
                this.onChange();
            }
        },
        enumerable: true,
        configurable: true
    });
    DateFilterOld.prototype.filter = function (item) {
        if (!this.date.isDate(this.dateFrom)) {
            return true;
        }
        if (this.dateRange) {
            var itemDate = this.getValue(item);
            var dateFrom = void 0;
            //have to set the dateFrom to a valid Date object for comparisons.
            if (this.useTime) {
                dateFrom = moment(this.dateFrom);
            }
            else {
                //increase it by 1 days. to inlcude the selected date in the range.
                dateFrom = moment(this.dateFrom).add(1, 'days');
            }
            return this.date.dateInRange(itemDate, this.dateTo, this.dateFrom);
        }
        else {
            if (this.useTime) {
                return this.date.sameDateTime(this.getValue(item), this.dateFrom);
            }
            else {
                return this.date.sameDate(this.getValue(item), this.dateFrom);
            }
        }
    };
    DateFilterOld.prototype.serialize = function () {
        return {
            dateFrom: this.dateFrom,
            dateTo: this.dateTo,
        };
    };
    DateFilterOld.prototype.getValue = function (item) {
        return this.transformService.getValue(item, this.valueSelector);
    };
    return DateFilterOld;
}(typescript_angular_utilities_1.filters.SerializableFilter));
exports.DateFilterOld = DateFilterOld;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZUZpbHRlck9sZC5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZGF0ZUZpbHRlck9sZC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLCtCQUFpQztBQUVqQyw2RUFBMEU7QUE4QjFFO0lBQW1DLGlDQUErQztJQXdDakYsdUJBQVksUUFBZ0MsRUFDeEMsV0FBZ0MsRUFDaEMsZ0JBQStDO1FBRm5ELFlBR0MsaUJBQU8sU0FhUDtRQVhBLEtBQUksQ0FBQyxJQUFJLEdBQUcsV0FBVyxDQUFDO1FBQ3hCLEtBQUksQ0FBQyxnQkFBZ0IsR0FBRyxnQkFBZ0IsQ0FBQztRQUV6QyxLQUFJLENBQUMsYUFBYSxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUM7UUFDNUMsS0FBSSxDQUFDLElBQUksR0FBRyxRQUFRLENBQUMsSUFBSSxDQUFDO1FBQzFCLEtBQUksQ0FBQyxTQUFTLEdBQUcsUUFBUSxDQUFDLFNBQVMsQ0FBQztRQUNwQyxLQUFJLENBQUMsWUFBWSxHQUFHLFFBQVEsQ0FBQyxZQUFZLENBQUM7UUFDMUMsS0FBSSxDQUFDLE9BQU8sR0FBRyxRQUFRLENBQUMsT0FBTyxJQUFJLElBQUksR0FBRyxRQUFRLENBQUMsT0FBTyxHQUFHLEtBQUssQ0FBQztRQUNuRSxLQUFJL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