"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")), _amosFramework = require("amos-framework"), _amosJsplumb = require("amos-jsplumb"), _plumbOptions = require("./modelConf/plumbOptions"), _elelist = _interopRequireDefault(require("./elelist"));

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 = {}, o = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) {
    var a = o ? Object.getOwnPropertyDescriptor(e, u) : null;
    a && (a.get || a.set) ? Object.defineProperty(n, u, a) : n[u] = e[u];
  }
  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 o = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(n, arguments, o);
    } 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 RuleScene = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r() {
    var e;
    (0, _classCallCheck2.default)(this, r);
    for (var n = arguments.length, o = new Array(n), u = 0; u < n; u++) o[u] = arguments[u];
    return e = t.call.apply(t, [ this ].concat(o)), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(e), "handleDragOver", (function(e) {
      (0, _amosJsplumb.stopEvent)(e);
    })), e;
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = _amosJsplumb.setting.defaultSettings, t = {
        connections: {
          dotted: _amosJsplumb.setting.dottedConnectionStyle,
          selected: _amosJsplumb.setting.selectedConnectionStyle
        },
        endpoints: {}
      }, r = this.props, n = r.zoom, o = r.handleDrop, u = r.onPlumbChange, a = r.onSceneCreated, l = r.destroy, i = r.onPlumbClick, s = r.eventListeners, p = r.onAddConnection, c = r.onRemoveConnection, f = r.onRemoveNode, d = r.onZoom, _ = r.newRestProps, m = r.nodeProps, b = this.props.dataSource, y = b.nodes, h = b.connections;
      return _react.default.createElement("div", {
        className: "rule-scene",
        onDragOver: this.handleDragOver,
        onDrop: o
      }, _react.default.createElement(_amosFramework.Spin, {
        type: "grid",
        loading: l,
        color: "#26A65B",
        className: "grid-loading"
      }), _react.default.createElement(_amosJsplumb.AmosPlumb, (0, _extends2.default)({
        className: "amos-plumb-container",
        key: "amos-plumb",
        onAddConnection: p,
        onRemoveConnection: c,
        onRemoveNode: f,
        jsPlumbSettings: e,
        registerTypes: t,
        onChange: u,
        onCreated: a,
        connections: h,
        nodes: y,
        onPlumbClick: i,
        eventListeners: s,
        zoom: n,
        nodeProps: m,
        onZoom: d,
        showControl: !0,
        getNodeContent: _elelist.default,
        destroy: l,
        draggableOptions: {
          constrain: !0
        }
      }, _)));
    }
  } ]), r;
}(_react.Component);

(0, _defineProperty2.default)(RuleScene, "propTypes", {
  zoom: _propTypes.default.number,
  dataSource: _propTypes.default.object,
  handleDrop: _propTypes.default.func,
  onPlumbChange: _propTypes.default.func,
  onSceneCreated: _propTypes.default.func,
  onPlumbClick: _propTypes.default.func,
  destroy: _propTypes.default.bool,
  eventListeners: _propTypes.default.object,
  onAddConnection: _propTypes.default.func,
  onRemoveConnection: _propTypes.default.func,
  onRemoveNode: _propTypes.default.func,
  onZoom: _propTypes.default.func,
  newRestProps: _propTypes.default.object
}), RuleScene.displayName = "RuleScene";

var _default = RuleScene;

exports.default = _default;