"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 Button_1 = require("../../Button");
var Block_1 = require("../../Block");
var instanceCounter = 0;
var TimeAmPmEditor = /** @class */ (function (_super) {
    __extends(TimeAmPmEditor, _super);
    function TimeAmPmEditor(props, ctx) {
        var _this = _super.call(this, props, ctx) || this;
        _this.handleToggleAmPM = function () {
            var _a = _this.props, isAm = _a.isAm, onAmPmChange = _a.onAmPmChange;
            onAmPmChange(!isAm);
        };
        _this.getTitle = function () {
            var _a = _this.props, isAm = _a.isAm, enableAMTitle = _a.enableAMTitle, enablePMTitle = _a.enablePMTitle;
            return isAm ? enablePMTitle : enableAMTitle;
        };
        _this.instanceId = instanceCounter++;
        return _this;
    }
    TimeAmPmEditor.prototype.render = function () {
        var _a = this.props, isAm = _a.isAm, amPmSwitcherLabel = _a.amPmSwitcherLabel, amLabel = _a.amLabel, pmLabel = _a.pmLabel;
        var descriptionId = "amPmSwitcherDescription-" + this.instanceId;
        return (react_1.default.createElement(Block_1.Block, { className: "rc-datepicker-am-pm-button", testAutomationId: "amPmSwitcher" },
            react_1.default.createElement("p", { className: "sr-only", id: descriptionId }, this.getTitle()),
            react_1.default.createElement("div", { className: "text-center time-text" },
                react_1.default.createElement(Button_1.Button, { testAutomationId: "amPmSwitchButton", onClick: this.handleToggleAmPM, bsStyle: "primary", "aria-label": amPmSwitcherLabel, title: this.getTitle(), "aria-describedby": descriptionId }, isAm ? amLabel : pmLabel))));
    };
    TimeAmPmEditor.propTypes = {
        isAm: prop_types_1.default.bool.isRequired,
        onAmPmChange: prop_types_1.default.func.isRequired,
        amLabel: prop_types_1.default.string.isRequired,
        pmLabel: prop_types_1.default.string.isRequired,
        amPmSwitcherLabel: prop_types_1.default.string.isRequired,
        enablePMTitle: prop_types_1.default.string.isRequired,
        enableAMTitle: prop_types_1.default.string.isRequired
    };
    return TimeAmPmEditor;
}(react_1.default.PureComponent));
exports.TimeAmPmEditor = TimeAmPmEditor;
//# sourceMappingURL=TimeAmPmEditor.js.map