"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")), _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosFramework = require("amos-framework"), _FilterBtn = _interopRequireDefault(require("./FilterBtn"));

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, r = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? r : t;
  })(e);
}

function _interopRequireWildcard(e, t) {
  if (!t && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var r = _getRequireWildcardCache(t);
  if (r && r.has(e)) return r.get(e);
  var a = {}, i = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var n in e) if ("default" !== n && Object.prototype.hasOwnProperty.call(e, n)) {
    var l = i ? Object.getOwnPropertyDescriptor(e, n) : null;
    l && (l.get || l.set) ? Object.defineProperty(a, n, l) : a[n] = e[n];
  }
  return a.default = e, r && r.set(e, a), a;
}

function _createForOfIteratorHelper(e, t) {
  var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
  if (!r) {
    if (Array.isArray(e) || (r = _unsupportedIterableToArray(e)) || t && e && "number" == typeof e.length) {
      r && (e = r);
      var a = 0, i = function() {};
      return {
        s: i,
        n: function() {
          return a >= e.length ? {
            done: !0
          } : {
            done: !1,
            value: e[a++]
          };
        },
        e: function(e) {
          throw e;
        },
        f: i
      };
    }
    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }
  var n, l = !0, o = !1;
  return {
    s: function() {
      r = r.call(e);
    },
    n: function() {
      var e = r.next();
      return l = e.done, e;
    },
    e: function(e) {
      o = !0, n = e;
    },
    f: function() {
      try {
        l || null == r.return || r.return();
      } finally {
        if (o) throw n;
      }
    }
  };
}

function _unsupportedIterableToArray(e, t) {
  if (e) {
    if ("string" == typeof e) return _arrayLikeToArray(e, t);
    var r = Object.prototype.toString.call(e).slice(8, -1);
    return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray(e, t) : void 0;
  }
}

function _arrayLikeToArray(e, t) {
  (null == t || t > e.length) && (t = e.length);
  for (var r = 0, a = new Array(t); r < t; r++) a[r] = e[r];
  return a;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, a = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var i = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(a, arguments, i);
    } else r = a.apply(this, arguments);
    return (0, _possibleConstructorReturn2.default)(this, r);
  };
}

function _isNativeReflectConstruct() {
  if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  if (Reflect.construct.sham) return !1;
  if ("function" == typeof Proxy) return !0;
  try {
    return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
    !0;
  } catch (e) {
    return !1;
  }
}

var SearchBar = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var a;
    return (0, _classCallCheck2.default)(this, r), a = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "onSearch", (function(e) {
      var t = a.state, r = t.inputName, i = t.filterList, n = {};
      0 !== r.length && (n.name = r), void 0 !== i.types && 0 !== i.types.length && (n.types = i.types), 
      void 0 !== i.protocolIds && 0 !== i.protocolIds.length && (n.protocolIds = i.protocolIds), 
      void 0 !== i.commIds && 0 !== i.commIds.length && (n.commIds = i.commIds), void 0 !== i.industryIds && 0 !== i.industryIds.length && (n.industryIds = i.industryIds), 
      a.props.handleCriterias(n);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "onChange", (function(e) {
      a.setState({
        inputName: e.target.value.trim()
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "showFilter", (function() {
      a.setState({
        filterDisplay: "show-div"
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "hidFilter", (function() {
      a.setState({
        filterDisplay: "hide-div"
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "obilityValueChange", (function(e) {
      var t, r = a.state.filterList, i = [], n = _createForOfIteratorHelper(e);
      try {
        for (n.s(); !(t = n.n()).done; ) {
          var l = t.value;
          i.push(l.value);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      r.types = i, a.setState(r);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "protocolValueChange", (function(e) {
      var t, r = a.state.filterList, i = [], n = _createForOfIteratorHelper(e);
      try {
        for (n.s(); !(t = n.n()).done; ) {
          var l = t.value;
          i.push(l.value);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      r.protocolIds = i, a.setState(r);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "communityValueChange", (function(e) {
      var t, r = a.state.filterList, i = [], n = _createForOfIteratorHelper(e);
      try {
        for (n.s(); !(t = n.n()).done; ) {
          var l = t.value;
          i.push(l.value);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      r.commIds = i, a.setState(r);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "industryValueChange", (function(e) {
      var t, r = a.state.filterList, i = [], n = _createForOfIteratorHelper(e);
      try {
        for (n.s(); !(t = n.n()).done; ) {
          var l = t.value;
          i.push(l.value);
        }
      } catch (e) {
        n.e(e);
      } finally {
        n.f();
      }
      r.industryIds = i, a.setState(r);
    })), a.state = {
      filterDisplay: "hide-div",
      inputName: "",
      filterList: {}
    }, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = this.state.filterDisplay, t = "search-filter ".concat(e), r = "modal-box ".concat(e);
      return _react.default.createElement("div", {
        className: "search-bar"
      }, _react.default.createElement("div", {
        className: "search-input"
      }, _react.default.createElement(_amosFramework.Input, {
        placeholder: "请输入搜索内容",
        onFocus: this.showFilter,
        onChange: this.onChange
      }), _react.default.createElement(_amosFramework.Button, {
        onClick: this.onSearch
      }, "搜索"), _react.default.createElement("div", {
        className: r,
        onClick: this.hidFilter
      }), _react.default.createElement("div", {
        className: t
      }, _react.default.createElement(_FilterBtn.default, (0, _extends2.default)({
        obilityValueChange: this.obilityValueChange,
        protocolValueChange: this.protocolValueChange,
        communityValueChange: this.communityValueChange,
        industryValueChange: this.industryValueChange
      }, this.props)))));
    }
  } ]), r;
}(_react.Component);

SearchBar.displayName = "SearchBar", SearchBar.propTypes = {
  handleCriterias: _propTypes.default.func,
  communityOptions: _propTypes.default.array,
  equiptemplateIndustryOptions: _propTypes.default.array,
  flag: _propTypes.default.string
};

var _default = SearchBar;

exports.default = _default;