text: 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; };
  
  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; }; }();
  
  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; }
  
  import React, { Component } from 'react';
  import assign from 'object-assign';
  
  import ModeSwitchHelper from './ModeSwitchHelper';
  
  export default (function () {
      for (var _len = arguments.length, conf = Array(_len), _key = 0; _key < _len; _key++) {
          conf[_key] = arguments[_key];
      }
  
      return function (WrappedComponent) {
          var _class, _temp;
  
          return _temp = _class = function (_Component) {
              _inherits(PureComponent, _Component);
  
              function PureComponent() {
                  var _ref;
  
                  _classCallCheck(this, PureComponent);
  
                  for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
                      params[_key2] = arguments[_key2];
                  }
  
                  var _this = _possibleConstructorReturn(this, (_ref = PureComponent.__proto__ || Object.getPrototypeOf(PureComponent)).call.apply(_ref, [this].concat(params)));
  
                  _this.update = function (mode) {
                      _this.setState({
                          mode: mode
                      });
                  };
  
                  _this.state = {
                      mode: ModeSwitchHelper.getCurrentMode().id
                  };
  
                  ModeSwitchHelper.onChange(_this.update);
                  return _this;
              }
  
              _createClass(PureComponent, [{
                  key: 'componentWillMount',
                  value: function componentWillMount() {
                      this.setState({
                          mode: ModeSwitchHelper.getCurrentMode().id
                      });
                  }
              }, {
                  key: 'componentWillUnmount',
                  value: function componentWillUnmount() {
                      ModeSwitchHelper.unregisterOnChange(this.updatedMode);
                  }
              }, {
                  key: '_shouldRender',
                  value: function _shouldRender() {
                      var mode = this.state.mode;
  
  
                      if (window.chayns.utils.isArray(conf) && conf.indexOf(mode.id) !== -1) return true;
  
                      if (!conf || conf.length === 0) return true;
  
                      return false;
                  }
              }, {
                  key: 'render',
                  value: function render() {
                      var mode = this.state.mode;
  
  
                      if (window.chayns.utils.isArray(conf) && !ModeSwitchHelper.isInitialized()) return null;
  
                      if (this._shouldRender()) {
                          var props = assign({}, this.props, {
                              mode: mode
                          });
  
                          return React.createElement(WrappedComponent, _extends({}, props, this.state));
                      }
  
                      return null;
                  }
              }]);
  
              return PureComponent;
          }(Component), _class.getStores = WrappedComponent.getStores, _class.getPropsFromStores = WrappedComponent.getPropsFromStores, _temp;
      };
  });