"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _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 _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 o, r, n = {},
    u = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (o in e) Object.prototype.hasOwnProperty.call(e, o) && ((r = u ? Object.getOwnPropertyDescriptor(e, o) : null) && (r.get || r.set) ? Object.defineProperty(n, o, r) : n[o] = e[o]);
  return n.default = e, t && t.set(e, n), n
}

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

function _createClass(e, t, o) {
  return t && _defineProperties(e.prototype, t), o && _defineProperties(e, o), 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(o) {
  var r = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(o);
    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, o) {
  return t in e ? Object.defineProperty(e, t, {
    value: o,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = o, e
}
var RuleScene = function() {
  _inherits(u, _react.Component);
  var n = _createSuper(u);

  function u() {
    var e;
    _classCallCheck(this, u);
    for (var t = arguments.length, o = new Array(t), r = 0; r < t; r++) o[r] = arguments[r];
    return _defineProperty(_assertThisInitialized(e = n.call.apply(n, [this].concat(o))), "handleDragOver", function(e) {
      (0, _amosJsplumb.stopEvent)(e)
    }), e
  }
  return _createClass(u, [{
    key: "render",
    value: function() {
      var e = _amosJsplumb.setting.defaultSettings,
        t = {
          connections: {
            dotted: _amosJsplumb.setting.dottedConnectionStyle,
            selected: _amosJsplumb.setting.selectedConnectionStyle
          },
          endpoints: {}
        },
        o = this.props,
        r = o.zoom,
        n = o.handleDrop,
        u = o.onPlumbChange,
        i = o.onSceneCreated,
        s = o.destroy,
        a = o.onPlumbClick,
        c = o.eventListeners,
        p = o.onAddConnection,
        l = o.onRemoveConnection,
        f = o.onRemoveNode,
        d = o.onZoom,
        _ = o.newRestProps,
        y = o.nodeProps,
        m = this.props.dataSource,
        o = m.nodes,
        m = m.connections;
      return _react.default.createElement("div", {
        className: "rule-scene",
        onDragOver: this.handleDragOver,
        onDrop: n
      }, _react.default.createElement(_amosFramework.Spin, {
        type: "grid",
        loading: s,
        color: "#26A65B",
        className: "grid-loading"
      }), _react.default.createElement(_amosJsplumb.AmosPlumb, _extends({
        className: "amos-plumb-container",
        key: "amos-plumb",
        onAddConnection: p,
        onRemoveConnection: l,
        onRemoveNode: f,
        jsPlumbSettings: e,
        registerTypes: t,
        onChange: u,
        onCreated: i,
        connections: m,
        nodes: o,
        onPlumbClick: a,
        eventListeners: c,
        zoom: r,
        nodeProps: y,
        onZoom: d,
        showControl: !0,
        getNodeContent: _elelist.default,
        destroy: s,
        draggableOptions: {
          constrain: !0
        }
      }, _)))
    }
  }]), u
}();
_defineProperty(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 = RuleScene, module.exports = exports.default;
