"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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var lodash_1 = __importDefault(require("lodash"));
var Button_1 = require("../../Button");
var Block_1 = require("../../Block");
var datePickerHelpers_1 = require("./datePickerHelpers");
var PreDefinedRangesBlock = /** @class */ (function (_super) {
    __extends(PreDefinedRangesBlock, _super);
    function PreDefinedRangesBlock() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PreDefinedRangesBlock.prototype.render = function () {
        var _a = this.props, ranges = _a.ranges, startDate = _a.startDate, endDate = _a.endDate, onPredefinedRangeButtonClick = _a.onPredefinedRangeButtonClick;
        if (lodash_1.default.isEmpty(ranges)) {
            return null;
        }
        var rangeButtons = lodash_1.default.map(ranges, function (rangeConfig, buttonText) {
            var range = datePickerHelpers_1.parsePreDefinedRangeConfig(rangeConfig);
            return (react_1.default.createElement(Button_1.Button, { key: buttonText, className: "range-predefined-btn", block: true, active: datePickerHelpers_1.isActiveRange({ range: range, startDate: startDate, endDate: endDate }), onClick: function () {
                    return onPredefinedRangeButtonClick({
                        startDate: range.startDate,
                        endDate: range.endDate
                    });
                } }, buttonText));
        });
        return react_1.default.createElement(Block_1.Block, { className: "rc-datepicker-predefined-ranges" }, rangeButtons);
    };
    PreDefinedRangesBlock.propTypes = {
        ranges: prop_types_1.default.object,
        startDate: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.object, prop_types_1.default.string]),
        endDate: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.object, prop_types_1.default.string]),
        onPredefinedRangeButtonClick: prop_types_1.default.func.isRequired
    };
    PreDefinedRangesBlock.defaultProps = {
        ranges: [],
        startDate: null,
        endDate: null
    };
    return PreDefinedRangesBlock;
}(react_1.default.PureComponent));
exports.PreDefinedRangesBlock = PreDefinedRangesBlock;
//# sourceMappingURL=PreDefinedRangesBlock.js.map