"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 _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")), _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")), _amosIcon = _interopRequireDefault(require("amos-icon")), _rayEventpool = require("ray-eventpool"), _amosJsplumb = require("amos-jsplumb"), _TopoHeader = _interopRequireDefault(require("./../header/TopoHeader")), _TopoStagePlumb = _interopRequireDefault(require("./TopoStagePlumb")), _addNode = require("./addNode"), _TriggerEditor = _interopRequireDefault(require("./../../../common/editor/TriggerEditor")), _ConfigPanel = _interopRequireDefault(require("./../toporight/demofile/ConfigPanel")), _stageConst = require("./../modelConf/stageConst");

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

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, a = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var o = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(a, arguments, o);
    } 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;
  }
}

require("./topocontent.scss");

var testFunc = function(e) {
  console.log(e);
}, eventListeners = {
  click: testFunc,
  connection: testFunc,
  endpointClick: testFunc
}, extraSize = {
  top: 90,
  left: 350
}, TopoContent = 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), "onChange", (function(e) {
      var t = e.nodes, r = e.connections;
      a.setState({
        nodes: t,
        connections: r
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "onIstCreated", (function(e) {
      a.jsPlumbInstance = e;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "handleDrop", (function(e) {
      (0, _amosJsplumb.stopEvent)(e);
      var t = e.clientX - extraSize.left, r = e.clientY - extraSize.top, o = e.dataTransfer.getData("FlowChartNode"), n = (0, 
      _addNode.transferDropData)(o), i = n.nodeType, l = n.label;
      a.doDropAddNode({
        nodeType: i,
        label: l,
        x: t,
        y: r
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "doDropAddNode", (function(e) {
      var t = e.nodeType, r = e.label, o = e.x, n = e.y, i = a.state.nodes, l = {
        left: o,
        top: n
      }, u = (0, _addNode.commonAddNode)({
        eleType: t,
        labelValue: r,
        position: l
      });
      a.setState({
        catalogVisible: !1,
        nodes: [].concat((0, _toConsumableArray2.default)(i), [ u ])
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "handleDragOver", (function(e) {
      (0, _amosJsplumb.stopEvent)(e);
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "renderTopoHeaderExtra", (function() {
      return [ _react.default.createElement("div", {
        key: "zoom-in",
        className: "topo-header-extra-item",
        onClick: a.zoomIn,
        title: "放大"
      }, _react.default.createElement(_amosIcon.default, {
        icon: "zoom-in"
      })), _react.default.createElement("div", {
        key: "zoom-out",
        className: "topo-header-extra-item",
        onClick: a.zoomOut,
        title: "缩小"
      }, _react.default.createElement(_amosIcon.default, {
        icon: "zoom-out"
      })), _react.default.createElement("div", {
        key: "save",
        className: "topo-header-extra-item",
        onClick: a.save,
        title: "保存"
      }, _react.default.createElement(_amosIcon.default, {
        icon: "save"
      })) ];
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "test", (function() {})), 
    (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "showProperty", (function(e) {
      a.deviceLabel = e, a.setState({
        hiddenProperty: !1
      }), void 0 !== a.configPanelRef && a.configPanelRef.closeDeviceCapacityPanel();
    })), a.state = {
      hiddenProperty: !0,
      showEditor: !1,
      connections: [],
      nodes: [],
      zoom: 1,
      resetCanvas: !1
    }, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "componentDidMount",
    value: function() {
      var e = this;
      this.pubsub = _rayEventpool.PubSub.subscribe(_stageConst.DB_CLICK_ELE, (function(t, r) {
        r.id, r.preStatus, r.nextStatus;
        var a = r.config;
        r.parentConfig;
        e.showProperty(a.label);
      }));
    }
  }, {
    key: "render",
    value: function() {
      var e = this, t = this.state, r = t.zoom, a = t.nodes, o = t.connections, n = t.resetCanvas, i = (t.showEditor, 
      t.hiddenProperty), l = this.deviceLabel, u = i ? _react.default.createElement("div", null) : _react.default.createElement(_ConfigPanel.default, {
        updateNodeConfig: this.test,
        updateNodeName: this.test,
        config: {
          label: "IG541气体灭火设备",
          type: "custom",
          data: {
            id: 1000019,
            isDelete: !1,
            createTime: null,
            updateTime: null,
            name: "IG541气体灭火设备",
            model: "IG-541",
            type: 1,
            img: "default.png",
            descr: null,
            visibility: 0,
            userId: null,
            attributes: null,
            capabilities: null
          },
          style: {
            left: "570px",
            top: "152px"
          }
        },
        equipmentId: 23,
        nodeId: "df0f9d2f-8e5a-44f5-a6f9-8ded3e1185aa",
        getSubgraphData: this.getSubgraphData,
        subviewId: 24,
        cfgParamJson: {
          equip_10000022: "",
          cpbl_10000019_10000022: "15.0",
          cpbl_intfc_10000019_10000019: "1026"
        },
        deviceLabel: l,
        ref: function(t) {
          return e.configPanelRef = t;
        }
      });
      return _react.default.createElement("div", {
        className: "topo-content-wrapper"
      }, _react.default.createElement(_TopoHeader.default, {
        title: "子图",
        extra: this.renderTopoHeaderExtra()
      }), _react.default.createElement("div", {
        onDragOver: this.handleDragOver,
        onDrop: this.handleDrop,
        ref: function(t) {
          return e.topoView = t;
        },
        onClick: this.hiddenDevicePanel,
        className: "kunshan-topo-content"
      }, n ? null : _react.default.createElement(_TopoStagePlumb.default, {
        eventListeners: eventListeners,
        onPlumbClick: this.onPlumbClick,
        onSceneCreated: this.onSceneCreated,
        onPlumbChange: this.onPlumbChange,
        zoom: r,
        nodes: a,
        connections: o
      })), u);
    }
  } ]), r;
}(_react.Component);

TopoContent.displayName = "TopoContent", TopoContent.propTypes = {
  subviewId: _propTypes.default.string,
  subviewName: _propTypes.default.string,
  currentNode: _propTypes.default.object,
  selectedKeys: _propTypes.default.array,
  editTreeData: _propTypes.default.func
};

var _default = TopoContent;

exports.default = _default;