import _defineProperty from"babel-runtime/helpers/defineProperty";import _toConsumableArray from"babel-runtime/helpers/toConsumableArray";import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";var __rest=this&&this.__rest||function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&(r[s[o]]=e[s[o]])}return r};import*as React from"react";import*as PropTypes from"prop-types";import classNames from"classnames";import isFlexSupported from"../_util/isFlexSupported";function generator(e){return function(t){return function(r){function s(){return _classCallCheck(this,s),_possibleConstructorReturn(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return _inherits(s,r),_createClass(s,[{key:"render",value:function(){var r=e.prefixCls;return React.createElement(t,_extends({prefixCls:r},this.props))}}]),s}(React.Component)}}var Basic=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"render",value:function(){var e=this.props,t=e.prefixCls,r=e.className,s=e.children,o=__rest(e,["prefixCls","className","children"]),a=classNames(r,t);return React.createElement("div",_extends({className:a},o),s)}}]),t}(React.Component),BasicLayout=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.state={siders:[]},e}return _inherits(t,e),_createClass(t,[{key:"getChildContext",value:function(){var e=this;return{siderHook:{addSider:function(t){e.setState({siders:[].concat(_toConsumableArray(e.state.siders),[t])})},removeSider:function(t){e.setState({siders:e.state.siders.filter(function(e){return e!==t})})}}}}},{key:"render",value:function(){var e=this.props,t=e.prefixCls,r=e.className,s=e.children,o=e.hasSider,a=__rest(e,["prefixCls","className","children","hasSider"]),n=classNames(r,t,_defineProperty({},t+"-has-sider",o||this.state.siders.length>0),{"no-flex":!isFlexSupported()});return React.createElement("div",_extends({className:n},a),s)}}]),t}(React.Component);BasicLayout.childContextTypes={siderHook:PropTypes.object};var Layout=generator({prefixCls:"dt-layout"})(BasicLayout),Header=generator({prefixCls:"dt-layout-header"})(Basic),Footer=generator({prefixCls:"dt-layout-footer"})(Basic),Content=generator({prefixCls:"dt-layout-content"})(Basic);Layout.Header=Header,Layout.Footer=Footer,Layout.Content=Content;export default Layout;