'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.sideMonitors = undefined;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reduxDevtools = require('redux-devtools');

var _reduxDevtoolsLogMonitor = require('redux-devtools-log-monitor');

var _reduxDevtoolsLogMonitor2 = _interopRequireDefault(_reduxDevtoolsLogMonitor);

var _reduxSliderMonitor = require('redux-slider-monitor');

var _reduxSliderMonitor2 = _interopRequireDefault(_reduxSliderMonitor);

var _reduxDevtoolsInspector = require('redux-devtools-inspector');

var _reduxDevtoolsInspector2 = _interopRequireDefault(_reduxDevtoolsInspector);

var _reduxDevtoolsChartMonitor = require('redux-devtools-chart-monitor');

var _reduxDevtoolsChartMonitor2 = _interopRequireDefault(_reduxDevtoolsChartMonitor);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

var sideMonitors = exports.sideMonitors = [{ key: 'LogMonitor', title: 'Log monitor' }, { key: 'InspectorMonitor', title: 'Inspector' }, { key: 'ChartMonitor', title: 'Chart' }];

function getMonitor(type, props) {
  switch (type) {
    case 'LogMonitor':
      return (0, _react.createElement)(_reduxDevtoolsLogMonitor2.default, { preserveScrollTop: false });
    case 'SliderMonitor':
      return (0, _react.createElement)(_reduxSliderMonitor2.default);
    case 'DispatchMonitor':
      return (0, _react.createElement)('div'); // deprecated
    case 'ChartMonitor':
      return (0, _react.createElement)(_reduxDevtoolsChartMonitor2.default, {
        defaultIsVisible: true, invertTheme: true,
        tooltipOptions: {
          style: {
            'background-color': '#ffffff',
            'color': '#000000',
            'opacity': '0.9',
            'border-radius': '5px',
            'padding': '5px'
          }
        }
      });
    default:
      return (0, _react.createElement)(_reduxDevtoolsInspector2.default, {
        shouldPersistState: false, isLightTheme: false, theme: 'nicinabox',
        tabs: function tabs(defaultTabs) {
          return [].concat(_toConsumableArray(defaultTabs), [{ name: 'Test', component: props.testComponent }]);
        }
      });
  }
}

var _default = (_temp = _class = function (_Component) {
  _inherits(_default, _Component);

  function _default() {
    _classCallCheck(this, _default);

    return _possibleConstructorReturn(this, Object.getPrototypeOf(_default).apply(this, arguments));
  }

  _createClass(_default, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate(nextProps) {
      return nextProps.monitor !== this.props.monitor;
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props;
      var monitor = _props.monitor;

      var rest = _objectWithoutProperties(_props, ['monitor']);

      var DevTools = (0, _reduxDevtools.createDevTools)(getMonitor(monitor, rest));
      return _react2.default.createElement(DevTools, rest);
    }
  }]);

  return _default;
}(_react.Component), _class.propTypes = {
  monitor: _react.PropTypes.string
}, _temp);

exports.default = _default;