"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_checkbox=require("../checkbox"),_checkbox2=_interopRequireDefault(_checkbox),_radio=require("../radio"),_radio2=_interopRequireDefault(_radio);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var __rest=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&(r[n[i]]=e[n[i]])}return r},SelectionBox=function(e){function r(e){(0,_classCallCheck3.default)(this,r);var t=(0,_possibleConstructorReturn3.default)(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.state={checked:t.getCheckState(e)},t}return(0,_inherits3.default)(r,e),(0,_createClass3.default)(r,[{key:"componentDidMount",value:function(){this.subscribe()}},{key:"componentWillUnmount",value:function(){this.unsubscribe&&this.unsubscribe()}},{key:"subscribe",value:function(){var t=this,e=this.props.store;this.unsubscribe=e.subscribe(function(){var e=t.getCheckState(t.props);t.setState({checked:e})})}},{key:"getCheckState",value:function(e){var t=e.store,r=e.defaultSelection,n=e.rowIndex;return t.getState().selectionDirty?0<=t.getState().selectedRowKeys.indexOf(n):0<=t.getState().selectedRowKeys.indexOf(n)||0<=r.indexOf(n)}},{key:"render",value:function(){var e=this.props,t=e.type,r=e.rowIndex,n=__rest(e,["type","rowIndex"]),i=this.state.checked;return"radio"===t?React.createElement(_radio2.default,(0,_extends3.default)({checked:i,value:r},n)):React.createElement(_checkbox2.default,(0,_extends3.default)({checked:i},n))}}]),r}(React.Component);exports.default=SelectionBox,module.exports=exports.default;