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

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, n = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var a = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(n, arguments, a);
    } else r = n.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 TopoConfigPanel = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var n;
    return (0, _classCallCheck2.default)(this, r), n = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(n), "getTopoPanelByType", (function() {
      var e = n.props.isNodeSelected, t = n.state.selectedKey, r = [];
      return e ? r.push(_react.default.createElement(_TopoConfigBodyPanel.default, (0, 
      _extends2.default)({
        selectedKey: t,
        getImgPath: n.getImgPath
      }, n.props))) : r.push(_react.default.createElement(_TopoConfigDefaultPanel.default, (0, 
      _extends2.default)({
        getImgPath: n.getImgPath
      }, n.props))), r;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(n), "getImgPath", (function(e, t) {
      var r;
      return r = t.includes(e) ? "rotate-negative-ninety" : "rotate-ninety", _react.default.createElement("img", {
        src: require("./../../../../assets/iot/deviceManage/arrow.png"),
        alt: "",
        className: r
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(n), "clickPanel", (function() {
      var e = n.state.expandIconWidth, t = n.props.changePanelWidth;
      "0" === e ? (e = "300px", t(!0)) : (e = "0", t(!1)), n.setState({
        expandIconWidth: e
      });
    })), n.state = {
      selectedKey: 1,
      expandIconWidth: "300px"
    }, n;
  }
  return (0, _createClass2.default)(r, [ {
    key: "componentWillMount",
    value: function() {}
  }, {
    key: "componentDidMount",
    value: function() {
      var e = this;
      this.switchConfig = _rayEventpool.PubSub.subscribe(_stageConst.TOPO_SWITCH_CONFIG_TOPIC.switchConfig, (function(t, r) {
        var n = r.selectedKey;
        e.setState({
          selectedKey: n
        });
      }));
    }
  }, {
    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());
    }
  } ]), r;
}(_react.Component);

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 = _default;