"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _react = _interopRequireWildcard(require("react")),
  _propTypes = _interopRequireDefault(require("prop-types")),
  _rayEventpool = require("ray-eventpool"),
  _amosIcon = _interopRequireDefault(require("amos-icon")),
  _stageConst = require("./../modelConf/stageConst"),
  _TopoConfigHeadPanel = _interopRequireDefault(require("./TopoConfigHeadPanel")),
  _TopoConfigBodyPanel = _interopRequireDefault(require("./TopoConfigBodyPanel")),
  _TopoConfigDefaultPanel = _interopRequireDefault(require("./TopoConfigDefaultPanel"));

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, o, r = {},
    i = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (n in e) Object.prototype.hasOwnProperty.call(e, n) && ((o = i ? Object.getOwnPropertyDescriptor(e, n) : null) && (o.get || o.set) ? Object.defineProperty(r, n, o) : r[n] = e[n]);
  return r.default = e, t && t.set(e, r), r
}

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, o = arguments[t];
      for (n in o) Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[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 o = t[n];
    o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, o.key, o)
  }
}

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 o = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(n);
    return _possibleConstructorReturn(this, o ? (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 TopoConfigPanel = function() {
  _inherits(n, _react.Component);
  var t = _createSuper(n);

  function n(e) {
    var o;
    return _classCallCheck(this, n), _defineProperty(_assertThisInitialized(o = t.call(this, e)), "getTopoPanelByType", function() {
      var e = o.props.isNodeSelected,
        t = o.state.selectedKey,
        n = [];
      return e ? n.push(_react.default.createElement(_TopoConfigBodyPanel.default, _extends({
        selectedKey: t,
        getImgPath: o.getImgPath
      }, o.props))) : n.push(_react.default.createElement(_TopoConfigDefaultPanel.default, _extends({
        getImgPath: o.getImgPath
      }, o.props))), n
    }), _defineProperty(_assertThisInitialized(o), "getImgPath", function(e, t) {
      e = t.includes(e) ? "rotate-negative-ninety" : "rotate-ninety";
      return _react.default.createElement("img", {
        src: require("./../../../../assets/iot/deviceManage/arrow.png"),
        alt: "",
        className: e
      })
    }), _defineProperty(_assertThisInitialized(o), "clickPanel", function() {
      var e = o.state.expandIconWidth,
        t = o.props.changePanelWidth;
      "0" === e ? (e = "300px", t(!0)) : t(!(e = "0")), o.setState({
        expandIconWidth: e
      })
    }), o.state = {
      selectedKey: 1,
      expandIconWidth: "300px"
    }, o
  }
  return _createClass(n, [{
    key: "componentWillMount",
    value: function() {}
  }, {
    key: "componentDidMount",
    value: function() {
      var n = this;
      this.switchConfig = _rayEventpool.PubSub.subscribe(_stageConst.TOPO_SWITCH_CONFIG_TOPIC.switchConfig, function(e, t) {
        t = t.selectedKey;
        n.setState({
          selectedKey: t
        })
      })
    }
  }, {
    key: "componentWillReceiveProps",
    value: function(e) {
      this.props.expandIconRight !== e.expandIconRight && this.setState({
        expandIconWidth: e.expandIconRight
      })
    }
  }, {
    key: "componentWillUnmount",
    value: function() {
      _rayEventpool.PubSub.unsubscribe(this.switchConfig)
    }
  }, {
    key: "render",
    value: function() {
      var e = this.state.expandIconWidth;
      return _react.default.createElement("div", {
        className: "topo-config-panel-root"
      }, _react.default.createElement("div", {
        className: "device-config-choose-btn",
        style: {
          right: e
        },
        onClick: this.clickPanel
      }, _react.default.createElement(_amosIcon.default, {
        icon: "0" === e ? "right" : "left"
      })), _react.default.createElement(_TopoConfigHeadPanel.default, this.props), this.getTopoPanelByType())
    }
  }]), n
}();
TopoConfigPanel.displayName = "TopoConfigPanel", TopoConfigPanel.propTypes = {
  isNodeSelected: _propTypes.default.bool,
  changePanelWidth: _propTypes.default.func,
  expandIconRight: _propTypes.default.string
}, TopoConfigPanel.defaultProps = {
  isNodeSelected: !1
};
var _default = TopoConfigPanel;
exports.default = TopoConfigPanel, module.exports = exports.default;
