"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = _default;

var _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")), _amosJsplumb = require("amos-jsplumb"), _rayEventpool = require("ray-eventpool"), _classnames = _interopRequireDefault(require("classnames")), _ActionItem = _interopRequireDefault(require("./../../extra/ActionItem")), _stageConf = require("./../../modelConf/stageConf"), _plumbOptions = require("./../../modelConf/plumbOptions"), _ElementEditor = _interopRequireDefault(require("./../../ElementEditor"));

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

var DefaultNode = _amosJsplumb.PlumbEleNode.DefaultNode, Anchors = _amosJsplumb.placement.Anchors;

function _default(e) {
  var t, r = e.type, a = e.nodeIcon, n = (0, _stageConf.completeItemTypeIcon)(a);
  return (0, _amosJsplumb.plumbNodeConnect)({
    className: "data-node-ele-inner",
    sourceParams: {
      filter: ".ele-source-bar",
      allowLoopback: !1,
      anchor: Anchors.Right,
      dropOptions: {
        hoverClass: "drag-hover"
      }
    },
    endPointParams: [ {
      params: _plumbOptions.sourceEndPoint,
      referenceParams: {
        anchor: Anchors.RightMiddle
      }
    } ]
  })(t = function(e) {
    (0, _inherits2.default)(i, e);
    var t = _createSuper(i);
    function i(e) {
      var a;
      return (0, _classCallCheck2.default)(this, i), a = t.call(this, e), (0, _defineProperty2.default)((0, 
      _assertThisInitialized2.default)(a), "dbClickTrigger", (function(e) {
        var t = e.id, n = e.config, i = e.parentConfig;
        n.label = a.currentLabel, _rayEventpool.PubSub.publish(_stageConf.eleTypeTopic.stage, {
          id: t,
          config: n,
          parentConfig: i,
          type: r
        });
      })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "clickTrigger", (function() {})), 
      (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "remove", (function(e, t) {
        var r = t.id;
        _rayEventpool.PubSub.publish(_stageConf.ELE_DEL_TOPIC.trigger, {
          eleId: r
        });
      })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "refreshLabel", (function(e) {
        a.currentLabel = e;
      })), a.currentLabel = a.props.config.label, a.state = {
        active: !1
      }, a;
    }
    return (0, _createClass2.default)(i, [ {
      key: "render",
      value: function() {
        var e = this, t = this.state.active, r = this.props, i = r.id, l = r.config, o = r.parentConfig, u = (l.style, 
        l.label), s = (0, _classnames.default)({
          "node-content-wrapper": !0,
          "node-wrapper-active": t
        }), c = (0, _classnames.default)("data-node-ele", a);
        return React.createElement("div", {
          className: c,
          onDoubleClick: function() {
            return e.dbClickTrigger({
              id: i,
              config: l,
              parentConfig: o
            });
          }
        }, React.createElement("div", {
          className: s
        }, React.createElement("div", {
          className: "ele-node-icon"
        }, React.createElement("img", {
          src: n,
          alt: ""
        })), React.createElement("div", {
          className: "ele-node-content"
        }, React.createElement(_ElementEditor.default, {
          label: u,
          eleId: i,
          editCallBack: this.refreshLabel
        })), React.createElement("div", {
          className: "ele-node-action"
        }, React.createElement(_ActionItem.default, {
          icon: "delete",
          onClick: function(t) {
            return e.remove(t, {
              id: i
            });
          },
          tip: "点击删除元素节点"
        }))));
      }
    } ]), i;
  }(React.Component)) || t;
}