"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _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 _interopRequireDefault(e) {
  return e && e.__esModule ? e : {
    default: e
  }
}

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

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

function _typeof(e) {
  return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e
  } : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  })(e)
}

function _extends() {
  return (_extends = Object.assign || function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var n, r = arguments[t];
      for (n in r) Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n])
    }
    return e
  }).apply(this, arguments)
}

function _classCallCheck(e, t) {
  if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}

function _defineProperties(e, t) {
  for (var n = 0; n < t.length; n++) {
    var r = t[n];
    r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
  }
}

function _createClass(e, t, n) {
  return t && _defineProperties(e.prototype, t), n && _defineProperties(e, n), e
}

function _inherits(e, t) {
  if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
  e.prototype = Object.create(t && t.prototype, {
    constructor: {
      value: e,
      writable: !0,
      configurable: !0
    }
  }), t && _setPrototypeOf(e, t)
}

function _setPrototypeOf(e, t) {
  return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) {
    return e.__proto__ = t, e
  })(e, t)
}

function _createSuper(n) {
  var r = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(n);
    return _possibleConstructorReturn(this, r ? (e = _getPrototypeOf(this).constructor, Reflect.construct(t, arguments, e)) : t.apply(this, arguments))
  }
}

function _possibleConstructorReturn(e, t) {
  return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t
}

function _assertThisInitialized(e) {
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return e
}

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

function _getPrototypeOf(e) {
  return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
    return e.__proto__ || Object.getPrototypeOf(e)
  })(e)
}

function _defineProperty(e, t, n) {
  return t in e ? Object.defineProperty(e, t, {
    value: n,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = n, e
}
var FilterBtn = function() {
  _inherits(n, _react.Component);
  var t = _createSuper(n);

  function n(e) {
    var u;
    return _classCallCheck(this, n), _defineProperty(_assertThisInitialized(u = t.call(this, e)), "obilitySelectFunc", function(e) {
      u.setState({
        obilitySelectedOption: e
      }), u.props.obilityValueChange(e)
    }), _defineProperty(_assertThisInitialized(u), "protocolSelectFunc", function(e) {
      u.setState({
        protocolSelectedOption: e
      }), u.props.protocolValueChange(e)
    }), _defineProperty(_assertThisInitialized(u), "communitySelectFunc", function(e) {
      u.setState({
        communitySelectedOption: e
      }), u.props.communityValueChange(e)
    }), _defineProperty(_assertThisInitialized(u), "industrySelectFunc", function(e) {
      u.setState({
        industrySelectedOption: e
      }), u.props.industryValueChange(e)
    }), _defineProperty(_assertThisInitialized(u), "delBtn", function(t) {
      var e = u.state,
        n = e.obilitySelectedOption,
        r = e.protocolSelectedOption,
        l = e.communitySelectedOption,
        e = e.industrySelectedOption,
        o = [];
      n.map(function(e) {
        e.label === t && (e.selected = !1, e.style = "all-filter-btn"), e.selected && o.push(e)
      }), 0 === o.length && u.refs.protocolChild.disableAllSelected(), u.setState({
        obilitySelectedOption: n
      }), u.props.obilityValueChange(o);
      var i = [];
      r.map(function(e) {
        e.label === t && (e.selected = !1, e.style = "all-filter-btn"), e.selected && i.push(e)
      }), 0 === i.length && u.refs.obilityChild.disableAllSelected(), u.setState({
        protocolSelectedOption: r
      }), u.props.protocolValueChange(i);
      var a = [];
      l.map(function(e) {
        e.label === t && (e.selected = !1, e.style = "all-filter-btn"), e.selected && a.push(e)
      }), 0 === a.length && u.refs.communityChild.disableAllSelected(), u.setState({
        communitySelectedOption: l
      }), u.props.communityValueChange(a);
      var c = [];
      e.map(function(e) {
        e.label === t && (e.selected = !1, e.style = "all-filter-btn"), e.selected && c.push(e)
      }), 0 === c.length && u.refs.industryChild.disableAllSelected(), u.setState({
        industrySelectedOption: e
      }), u.props.industryValueChange(c)
    }), _defineProperty(_assertThisInitialized(u), "selectOptions", function() {
      var t = [],
        e = u.state,
        n = e.obilitySelectedOption,
        r = e.protocolSelectedOption,
        l = e.communitySelectedOption,
        e = e.industrySelectedOption;
      return n.map(function(e) {
        e.selected && t.push(_react.default.createElement("div", {
          key: "obility".concat(e.value),
          id: "obility" + e.value,
          onClick: function() {
            return u.delBtn(e.label)
          },
          className: "select-filter-btn"
        }, e.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })))
      }), r.map(function(e) {
        e.selected && t.push(_react.default.createElement("div", {
          key: "protocol".concat(e.value),
          id: "protocol" + e.value,
          onClick: function() {
            return u.delBtn(e.label)
          },
          className: "select-filter-btn"
        }, e.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })))
      }), l.map(function(e) {
        e.selected && t.push(_react.default.createElement("div", {
          key: "community".concat(e.value),
          id: "community" + e.value,
          onClick: function() {
            return u.delBtn(e.label)
          },
          className: "select-filter-btn"
        }, e.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })))
      }), e.map(function(e) {
        e.selected && t.push(_react.default.createElement("div", {
          key: "industry".concat(e.value),
          id: "industry" + e.value,
          onClick: function() {
            return u.delBtn(e.label)
          },
          className: "select-filter-btn"
        }, e.label, _react.default.createElement(_amosAntd.Icon, {
          type: "close"
        })))
      }), t
    }), u.state = {
      obilitySelectedOption: [],
      protocolSelectedOption: [],
      communitySelectedOption: [],
      industrySelectedOption: []
    }, u
  }
  return _createClass(n, [{
    key: "render",
    value: function() {
      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, _extends({
        obilitySelectFunc: this.obilitySelectFunc,
        ref: "obilityChild"
      }, 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, _extends({
        protocolSelectFunc: this.protocolSelectFunc,
        ref: "protocolChild"
      }, 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, _extends({
        communitySelectFunc: this.communitySelectFunc,
        ref: "communityChild"
      }, 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, _extends({
        industrySelectFunc: this.industrySelectFunc,
        ref: "industryChild"
      }, this.props)))))
    }
  }]), n
}();
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 = FilterBtn, module.exports = exports.default;
