import _extends from "@babel/runtime/helpers/extends";
/**
 * 规则节点，只有配置了PluginId的才能看见这个节点
 * 
 */
import { COLLAPSE_ICON, EXPAND_ICON } from "../icons";
import { FlowEvent } from "../type";
export var ruleNode = {
  options: {
    style: {
      fill: "#fa7a0a",
      stroke: "#ff4e18",
      radius: 8,
      lineWidth: 1,
      fillOpacity: "0.95"
    },
    stateStyles: {
      hover: {},
      selected: {}
    },
    labelCfg: {
      style: {
        fill: "#000000",
        fontSize: 14,
        fontWeight: 400,
        fillOpacity: "0.7"
      }
    },
    size: [120, 40]
  },
  drawShape: function drawShape(cfg, group) {
    var styles = this.getShapeStyle(cfg);
    var h = styles.height;
    var w = styles.width;
    var keyShape = group.addShape("rect", {
      attrs: _extends({
        x: 0,
        y: 0
      }, styles)
    });
    group.addShape("marker", {
      attrs: {
        x: w / 2 - 20,
        y: 0,
        r: 6,
        stroke: "#ff4d4f",
        cursor: "pointer",
        symbol: COLLAPSE_ICON
      },
      name: FlowEvent.removeItem
    });
    group.addShape("marker", {
      attrs: {
        x: 0,
        y: h / 2 + 7,
        r: 6,
        stroke: "#73d13d",
        cursor: "pointer",
        symbol: EXPAND_ICON
      },
      // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
      name: FlowEvent.addItem
    });
    return keyShape;
  },
  update: function update(cfg, node) {
    var _cfg$menus;
    var styles = this.getShapeStyle(cfg);
    var h = styles.height;
    var group = node.getContainer();
    var child = group.find(function (item) {
      return item.get("name") === FlowEvent.addItem;
    });
    var text = group.find(function (item) {
      return item.get("name") === "text-shape";
    });
    if (text) {
      text.attr({
        text: cfg.label
      });
    }
    if (!child && (_cfg$menus = cfg.menus) !== null && _cfg$menus !== void 0 && _cfg$menus.length) {
      group.addShape("marker", {
        attrs: {
          x: 0,
          y: h / 2 + 7,
          r: 6,
          stroke: "#73d13d",
          cursor: "pointer",
          symbol: EXPAND_ICON
        },
        name: FlowEvent.addItem
      });
    }
  }
};