define(["require", "exports", "tslib", "react", "../../Utilities", "./Checkbox.scss"], function (require, exports, tslib_1, React, Utilities_1, stylesImport) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var styles = stylesImport;
    var Checkbox = (function (_super) {
        tslib_1.__extends(Checkbox, _super);
        function Checkbox(props) {
            var _this = _super.call(this, props) || this;
            _this._warnMutuallyExclusive({
                'checked': 'defaultChecked'
            });
            _this._id = Utilities_1.getId('checkbox-');
            _this.state = {
                isFocused: false,
                isChecked: !!(props.checked !== undefined ? props.checked : props.defaultChecked)
            };
            return _this;
        }
        Checkbox.prototype.render = function () {
            var _a = this.props, checked = _a.checked, className = _a.className, defaultChecked = _a.defaultChecked, disabled = _a.disabled, inputProps = _a.inputProps, label = _a.label, name = _a.name;
            var isFocused = this.state.isFocused;
            var isChecked = checked === undefined ? this.state.isChecked : checked;
            return (React.createElement("div", { className: Utilities_1.css('ms-Checkbox', styles.root, className, (_b = {
                        'is-inFocus': isFocused
                    },
                    _b[styles.rootIsInFocus] = isFocused,
                    _b)) },
                React.createElement("input", tslib_1.__assign({}, inputProps, (checked !== undefined && { checked: checked }), (defaultChecked !== undefined && { defaultChecked: defaultChecked }), { disabled: disabled, ref: this._resolveRef('_checkBox'), id: this._id, name: name || this._id, className: Utilities_1.css('ms-Checkbox-input', styles.input), type: 'checkbox', onChange: this._onChange, onFocus: this._onFocus, onBlur: this._onBlur, "aria-checked": isChecked })),
                this.props.children,
                React.createElement("label", { htmlFor: this._id, className: Utilities_1.css('ms-Checkbox-label', styles.label, (_c = {},
                        _c['is-checked ' + styles.labelIsChecked] = isChecked,
                        _c['is-disabled ' + styles.labelIsDisabled] = disabled,
                        _c[styles.labelIsInFocus] = isFocused,
                        _c)) }, label && React.createElement("span", { className: styles.textLabel }, label))));
            var _b, _c;
        };
        Object.defineProperty(Checkbox.prototype, "checked", {
            get: function () {
                return this._checkBox ? this._checkBox.checked : false;
            },
            enumerable: true,
            configurable: true
        });
        Checkbox.prototype.focus = function () {
            if (this._checkBox) {
                this._checkBox.focus();
            }
        };
        Checkbox.prototype._onFocus = function (ev) {
            var inputProps = this.props.inputProps;
            if (inputProps && inputProps.onFocus) {
                inputProps.onFocus(ev);
            }
            this.setState({ isFocused: true });
        };
        Checkbox.prototype._onBlur = function (ev) {
            var inputProps = this.props.inputProps;
            if (inputProps && inputProps.onBlur) {
                inputProps.onBlur(ev);
            }
            this.setState({ isFocused: false });
        };
        Checkbox.prototype._onChange = function (ev) {
            var onChange = this.props.onChange;
            var isChecked = ev.target.checked;
            if (onChange) {
                onChange(ev, isChecked);
            }
            if (this.props.checked === undefined) {
                this.setState({ isChecked: isChecked });
            }
        };
        return Checkbox;
    }(Utilities_1.BaseComponent));
    Checkbox.defaultProps = {};
    tslib_1.__decorate([
        Utilities_1.autobind
    ], Checkbox.prototype, "_onFocus", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], Checkbox.prototype, "_onBlur", null);
    tslib_1.__decorate([
        Utilities_1.autobind
    ], Checkbox.prototype, "_onChange", null);
    exports.Checkbox = Checkbox;
});

//# sourceMappingURL=Checkbox.js.map
