text: 'use strict';
  
  exports.__esModule = true;
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /*
                                                                                                                                                                                                                                                                     * This file is part of the nivo project.
                                                                                                                                                                                                                                                                     *
                                                                                                                                                                                                                                                                     * Copyright 2016-present, Raphaël Benitte.
                                                                                                                                                                                                                                                                     *
                                                                                                                                                                                                                                                                     * For the full copyright and license information, please view the LICENSE
                                                                                                                                                                                                                                                                     * file that was distributed with this source code.
                                                                                                                                                                                                                                                                     */
  
  
  var _d3Hierarchy = require('d3-hierarchy');
  
  var _cloneDeep = require('lodash/cloneDeep');
  
  var _cloneDeep2 = _interopRequireDefault(_cloneDeep);
  
  var _compose = require('recompose/compose');
  
  var _compose2 = _interopRequireDefault(_compose);
  
  var _defaultProps = require('recompose/defaultProps');
  
  var _defaultProps2 = _interopRequireDefault(_defaultProps);
  
  var _withPropsOnChange = require('recompose/withPropsOnChange');
  
  var _withPropsOnChange2 = _interopRequireDefault(_withPropsOnChange);
  
  var _pure = require('recompose/pure');
  
  var _pure2 = _interopRequireDefault(_pure);
  
  var _hocs = require('../../../hocs');
  
  var _propertiesConverters = require('../../../lib/propertiesConverters');
  
  var _props = require('../../../props');
  
  var _colors = require('../../../lib/colors');
  
  var _hierarchy = require('../../../lib/hierarchy');
  
  var _defs = require('../../../lib/defs');
  
  var _props2 = require('./props');
  
  var props = _interopRequireWildcard(_props2);
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  var commonEnhancers = [(0, _hocs.withHierarchy)(), (0, _hocs.withDimensions)(), (0, _hocs.withColors)({ defaultColorBy: 'depth' }), (0, _hocs.withTheme)(), (0, _hocs.withMotion)(), (0, _withPropsOnChange2.default)(['identity'], function (_ref) {
      var identity = _ref.identity;
      return {
          getIdentity: (0, _propertiesConverters.getAccessorFor)(identity)
      };
  }), (0, _withPropsOnChange2.default)(['borderColor'], function (_ref2) {
      var borderColor = _ref2.borderColor;
      return {
          getBorderColor: (0, _colors.getInheritedColorGenerator)(borderColor)
      };
  }), (0, _withPropsOnChange2.default)(['label', 'labelFormat'], function (_ref3) {
      var label = _ref3.label,
          labelFormat = _ref3.labelFormat;
      return {
          getLabel: (0, _propertiesConverters.getLabelGenerator)(label, labelFormat)
      };
  }), (0, _withPropsOnChange2.default)(['labelTextColor'], function (_ref4) {
      var labelTextColor = _ref4.labelTextColor;
      return {
          getLabelTextColor: (0, _colors.getInheritedColorGenerator)(labelTextColor)
      };
  }), (0, _withPropsOnChange2.default)(['width', 'height', 'tile', 'innerPadding', 'outerPadding'], function (_ref5) {
      var width = _ref5.width,
          height = _ref5.height,
          tile = _ref5.tile,
          innerPadding = _ref5.innerPadding,
          outerPadding = _ref5.outerPadding;
      return {
          treemap: (0, _d3Hierarchy.treemap)().size([width, height]).tile((0, _props.treeMapTileFromProp)(tile)).round(true).paddingInner(innerPadding).paddingOuter(outerPadding)
      };
  }), (0, _withPropsOnChange2.default)(['root', 'treemap', 'leavesOnly', 'getIdentity', 'getColor'], function (_ref6) {
      var _root = _ref6.root,
          treemap = _ref6.treemap,
          leavesOnly = _ref6.leavesOnly,
          getIdentity = _ref6.getIdentity,
          getColor = _ref6.getColor;
  
      var root = (0, _cloneDeep2.default)(_root);
  
      treemap(root);
  
      var nodes = leavesOnly ? root.leaves() : root.descendants();
      nodes = nodes.map(function (d) {
          d.path = (0, _hierarchy.computeNodePath)(d, getIdentity);
  
          d.nodeHeight = d.height;
  
          d.x = d.x0;
          d.y = d.y0;
          d.width = d.x1 - d.x0;
          d.height = d.y1 - d.y0;
          d.data.color = d.color = getColor(_extends({}, d.data, { depth: d.depth }));
  
          d.data.id = d.id = getIdentity(d.data);
          d.data.value = d.value;
  
          return d;
      });
  
      return { nodes: nodes };
  }), (0, _withPropsOnChange2.default)(['enableLabel', 'nodes', 'getLabel', 'labelSkipSize'], function (_ref7) {
      var enableLabel = _ref7.enableLabel,
          nodes = _ref7.nodes,
          getLabel = _ref7.getLabel,
          labelSkipSize = _ref7.labelSkipSize;
  
      if (!enableLabel) return;
  
      var nodesWithLabel = nodes.map(function (node) {
          if (node.nodeHeight > 0 || labelSkipSize !== 0 && Math.min(node.width, node.height) <= labelSkipSize) return node;
          return _extends({}, node, { label: getLabel(node.data) });
      });
  
      return { nodes: nodesWithLabel };
  })];
  
  var svgEnhancers = [(0, _withPropsOnChange2.default)(['nodes', 'defs', 'fill'], function (_ref8) {
      var nodes = _ref8.nodes,
          defs = _ref8.defs,
          fill = _ref8.fill;
  
      return {
          defs: (0, _defs.bindDefs)(defs, nodes, fill, { targetKey: 'fill' })
      };
  })];
  
  exports.default = function (Component) {
      var implPropTypes = props[Component.displayName + 'PropTypes'];
      var implDefaultProps = props[Component.displayName + 'DefaultProps'];
  
      Component.propTypes = implPropTypes;
  
      switch (Component.displayName) {
          case 'TreeMap':
          case 'TreeMapPlaceholders':
              return _compose2.default.apply(undefined, [(0, _defaultProps2.default)(implDefaultProps)].concat(commonEnhancers, svgEnhancers, [(0, _hocs.withMotion)(), _pure2.default]))(Component);
  
          case 'TreeMapHtml':
              return _compose2.default.apply(undefined, [(0, _defaultProps2.default)(implDefaultProps)].concat(commonEnhancers, [(0, _hocs.withMotion)(), _pure2.default]))(Component);
  
          case 'TreeMapCanvas':
              return _compose2.default.apply(undefined, [(0, _defaultProps2.default)(implDefaultProps)].concat(commonEnhancers, [_pure2.default]))(Component);
      }
  
      return Component;
  };