"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends4=require("babel-runtime/helpers/extends"),_extends5=_interopRequireDefault(_extends4),_typeof2=require("babel-runtime/helpers/typeof"),_typeof3=_interopRequireDefault(_typeof2),_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),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes);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 s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&(r[n[s]]=e[n[s]])}return r},enquire=void 0;if("undefined"!=typeof window){var matchMediaPolyfill=function(e){return{media:e,matches:!1,addListener:function(){},removeListener:function(){}}};window.matchMedia=window.matchMedia||matchMediaPolyfill,enquire=require("enquire.js")}var responsiveArray=["xxl","xl","lg","md","sm","xs"],responsiveMap={xs:"(max-width: 575px)",sm:"(min-width: 576px)",md:"(min-width: 768px)",lg:"(min-width: 992px)",xl:"(min-width: 1200px)",xxl:"(min-width: 1600px)"},Row=function(e){function t(){(0,_classCallCheck3.default)(this,t);var e=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.state={screens:{}},e}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"componentDidMount",value:function(){var e=this;Object.keys(responsiveMap).map(function(t){return enquire.register(responsiveMap[t],{match:function(){"object"===(0,_typeof3.default)(e.props.gutter)&&e.setState(function(e){return{screens:(0,_extends5.default)({},e.screens,(0,_defineProperty3.default)({},t,!0))}})},unmatch:function(){"object"===(0,_typeof3.default)(e.props.gutter)&&e.setState(function(e){return{screens:(0,_extends5.default)({},e.screens,(0,_defineProperty3.default)({},t,!1))}})},destroy:function(){}})})}},{key:"componentWillUnmount",value:function(){Object.keys(responsiveMap).map(function(e){return enquire.unregister(responsiveMap[e])})}},{key:"getGutter",value:function(){var e=this.props.gutter;if("object"===(void 0===e?"undefined":(0,_typeof3.default)(e)))for(var t=0;t<=responsiveArray.length;t++){var r=responsiveArray[t];if(this.state.screens[r]&&void 0!==e[r])return e[r]}return e}},{key:"render",value:function(){var e,t=this.props,r=t.type,n=t.justify,s=t.align,i=t.className,o=t.style,a=t.children,u=t.prefixCls,l=void 0===u?"dt-row":u,p=__rest(t,["type","justify","align","className","style","children","prefixCls"]),f=this.getGutter(),d=(0,_classnames2.default)((e={},(0,_defineProperty3.default)(e,l,!r),(0,_defineProperty3.default)(e,l+"-"+r,r),(0,_defineProperty3.default)(e,l+"-"+r+"-"+n,r&&n),(0,_defineProperty3.default)(e,l+"-"+r+"-"+s,r&&s),e),i),c=0<f?(0,_extends5.default)({marginLeft:f/-2,marginRight:f/-2},o):o,_=_react.Children.map(a,function(e){return e?e.props&&0<f?(0,_react.cloneElement)(e,{style:(0,_extends5.default)({paddingLeft:f/2,paddingRight:f/2},e.props.style)}):e:null}),y=(0,_extends5.default)({},p);return delete y.gutter,React.createElement("div",(0,_extends5.default)({},y,{className:d,style:c}),_)}}]),t}(React.Component);(exports.default=Row).defaultProps={gutter:0},Row.propTypes={type:PropTypes.string,align:PropTypes.string,justify:PropTypes.string,className:PropTypes.string,children:PropTypes.node,gutter:PropTypes.oneOfType([PropTypes.object,PropTypes.number]),prefixCls:PropTypes.string},module.exports=exports.default;