'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactRouterDom = require('react-router-dom');

var _mobxReact = require('mobx-react');

var _SearchInput = require('./SearchInput');

var _SearchInput2 = _interopRequireDefault(_SearchInput);

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

var SearchInputWrapper = (_dec = (0, _mobxReact.inject)('MenuStore'), (0, _reactRouterDom.withRouter)(_class = _dec(_class = function (_PureComponent) {
  (0, _inherits3['default'])(SearchInputWrapper, _PureComponent);

  function SearchInputWrapper() {
    var _ref;

    var _temp, _this, _ret;

    (0, _classCallCheck3['default'])(this, SearchInputWrapper);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = (0, _possibleConstructorReturn3['default'])(this, (_ref = SearchInputWrapper.__proto__ || Object.getPrototypeOf(SearchInputWrapper)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function (code) {
      var _this$props = _this.props,
          MenuStore = _this$props.MenuStore,
          history = _this$props.history;
      var treeNodeMenus = MenuStore.treeNodeMenus,
          activeMenu = MenuStore.activeMenu;

      var target = treeNodeMenus.find(function (node) {
        return node.functionCode === code;
      });
      if (target && target.functionCode !== activeMenu.functionCode) {
        var LINK_MAP = {
          REACT: '/' + target.url,
          HTML: '/iframe/' + target.functionCode
        };
        var desUrl = LINK_MAP[target.symbol] || '/';
        history.push(desUrl);
      }
    }, _temp), (0, _possibleConstructorReturn3['default'])(_this, _ret);
  }

  (0, _createClass3['default'])(SearchInputWrapper, [{
    key: 'render',
    value: function render() {
      return _react2['default'].createElement(_SearchInput2['default'], { onChange: this.handleChange });
    }
  }]);
  return SearchInputWrapper;
}(_react.PureComponent)) || _class) || _class);
exports['default'] = SearchInputWrapper;