"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")), _amosAntd = require("amos-antd"), _obilityOptionsFilter = _interopRequireDefault(require("./../../common/filterOptions/obilityOptionsFilter")), _protocolOptionsFilter = _interopRequireDefault(require("./../../common/filterOptions/protocolOptionsFilter")), _communityOptionsFilter = _interopRequireDefault(require("./../../common/filterOptions/communityOptionsFilter")), _industryOptionsFilter = _interopRequireDefault(require("./../../common/filterOptions/industryOptionsFilter"));

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, l = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? l : 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 l = _getRequireWildcardCache(t);
  if (l && l.has(e)) return l.get(e);
  var r = {}, n = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var a in e) if ("default" !== a && Object.prototype.hasOwnProperty.call(e, a)) {
    var i = n ? Object.getOwnPropertyDescriptor(e, a) : null;
    i && (i.get || i.set) ? Object.defineProperty(r, a, i) : r[a] = e[a];
  }
  return r.default = e, l && l.set(e, r), r;
}

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

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 FilterBtn = function(e) {
  (0, _inherits2.default)(l, e);
  var t = _createSuper(l);
  function l(e) {
    var r;
    return (0, _classCallCheck2.default)(this, l), r = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(r), "obilitySelectFunc", (function(e) {
      r.setState({
        obilitySelectedOption: e
      }), r.props.obilityValueChange(e);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "protocolSelectFunc", (function(e) {
      r.setState({
        protocolSelectedOption: e
      }), r.props.protocolValueChange(e);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "communitySelectFunc", (function(e) {
      r.setState({
        communitySelectedOption: e
      }), r.props.communityValueChange(e);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "industrySelectFunc", (function(e) {
      r.setState({
        industrySelectedOption: e
      }), r.props.industryValueChange(e);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "delBtn", (function(e) {
      var t = r.state, l = t.obilitySelectedOption, n = t.protocolSelectedOption, a = t.communitySelectedOption, i = t.industrySelectedOption, o = [];
      l.map((function(t) {
        t.label === e && (t.selected = !1, t.style = "all-filter-btn"), t.selected && o.push(t);
      })), 0 === o.length && r.protocolChild.disableAllSelected(), r.setState({
        obilitySelectedOption: l
      }), r.props.obilityValueChange(o);
      var u = [];
      n.map((function(t) {
        t.label === e && (t.selected = !1, t.style = "all-filter-btn"), t.selected && u.push(t);
      })), 0 === u.length && r.obilityChild.disableAllSelected(), r.setState({
        protocolSelectedOption: n
      }), r.props.protocolValueChange(u);
      var c = [];
      a.map((function(t) {
        t.label === e && (t.selected = !1, t.style = "all-filter-btn"), t.selected && c.push(t);
      })), 0 === c.length && r.communityChild.disableAllSelected(), r.setState({
        communitySelectedOption: a
      }), r.props.communityValueChange(c);
      var s = [];
      i.map((function(t) {
        t.label === e && (t.selected = !1, t.style = "all-filter-btn"), t.selected && s.push(t);
      })), 0 === s.length && r.industryChild.disableAllSelected(), r.setState({
        industrySelectedOption: i
      }), r.props.industryValueChange(s);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(r), "selectOptions", (function() {
      var e = [], t = r.state, l = t.obilitySelectedOption, n = t.protocolSelectedOption, a = t.communitySelectedOption, i = t.industrySelectedOption;
      return l.map((function(t) {
        t.selected && e.push(_react.default.createElement("div", {
          id: "obility".concat(t.value),
          onClick: function() {
            return r.delBtn(t.label);
          },
          className: "select-filter-btn"
        }, t.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })));
      })), n.map((function(t) {
        t.selected && e.push(_react.default.createElement("div", {
          id: "protocol".concat(t.value),
          onClick: function() {
            return r.delBtn(t.label);
          },
          className: "select-filter-btn"
        }, t.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })));
      })), a.map((function(t) {
        t.selected && e.push(_react.default.createElement("div", {
          id: "community".concat(t.value),
          onClick: function() {
            return r.delBtn(t.label);
          },
          className: "select-filter-btn"
        }, t.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })));
      })), i.map((function(t) {
        t.selected && e.push(_react.default.createElement("div", {
          key: "industry".concat(t.value),
          id: "industry".concat(t.value),
          onClick: function() {
            return r.delBtn(t.label);
          },
          className: "select-filter-btn"
        }, t.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })));
      })), e;
    })), r.state = {
      obilitySelectedOption: [],
      protocolSelectedOption: [],
      communitySelectedOption: [],
      industrySelectedOption: []
    }, r;
  }
  return (0, _createClass2.default)(l, [ {
    key: "render",
    value: function() {
      var e = this;
      return _react.default.createElement("div", null, _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 8
      }, _react.default.createElement("span", null, "筛选条件：")), _react.default.createElement(_amosAntd.Col, {
        span: 16
      }, this.selectOptions())), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 8
      }, _react.default.createElement("span", null, "分类：")), _react.default.createElement(_amosAntd.Col, {
        span: 16
      }, _react.default.createElement(_obilityOptionsFilter.default, (0, _extends2.default)({
        obilitySelectFunc: this.obilitySelectFunc,
        ref: function(t) {
          return e.obilityChild = t;
        }
      }, this.props)))), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 8
      }, _react.default.createElement("span", null, "协议：")), _react.default.createElement(_amosAntd.Col, {
        span: 16
      }, _react.default.createElement(_protocolOptionsFilter.default, (0, _extends2.default)({
        protocolSelectFunc: this.protocolSelectFunc,
        ref: function(t) {
          return e.protocolChild = t;
        }
      }, this.props)))), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 8
      }, _react.default.createElement("span", null, "设备接口：")), _react.default.createElement(_amosAntd.Col, {
        span: 16
      }, _react.default.createElement(_communityOptionsFilter.default, (0, _extends2.default)({
        communitySelectFunc: this.communitySelectFunc,
        ref: function(t) {
          return e.communityChild = t;
        }
      }, this.props)))), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 8
      }, _react.default.createElement("span", null, "所属行业：")), _react.default.createElement(_amosAntd.Col, {
        span: 16
      }, _react.default.createElement(_industryOptionsFilter.default, (0, _extends2.default)({
        industrySelectFunc: this.industrySelectFunc,
        ref: function(t) {
          return e.industryChild = t;
        }
      }, this.props)))));
    }
  } ]), l;
}(_react.Component);

FilterBtn.displayName = "FilterBtn", FilterBtn.propTypes = {
  obilityValueChange: _propTypes.default.func,
  protocolValueChange: _propTypes.default.func,
  communityValueChange: _propTypes.default.func,
  communityOptions: _propTypes.default.array,
  equiptemplateIndustryOptions: _propTypes.default.array,
  flag: _propTypes.default.string
};

var _default = FilterBtn;

exports.default = _default;