"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Mouse = require("../../util/Mouse.js");
const index_esm = require("../../../../min-dash/dist/index.esm.js");
function S(r, n, l, f) {
  r.on("create.end", 500, function(t) {
    var e = t.context, i = e.canExecute, o = e.elements, c = e.hints || {}, a = c.autoSelect;
    if (i) {
      if (a === false)
        return;
      index_esm.isArray(a) ? n.select(a) : n.select(o.filter(p));
    }
  }), r.on("connect.end", 500, function(t) {
    var e = t.context, i = e.connection;
    i && n.select(i);
  }), r.on("shape.move.end", 500, function(t) {
    var e = t.previousSelection || [], i = f.get(t.context.shape.id), o = index_esm.find(e, function(c) {
      return i.id === c.id;
    });
    o || n.select(i);
  }), r.on("element.click", function(t) {
    if (Mouse.isPrimaryButton(t)) {
      var e = t.element;
      e === l.getRootElement() && (e = null);
      var i = n.isSelected(e), o = n.get().length > 1, c = Mouse.hasPrimaryModifier(t) || Mouse.hasSecondaryModifier(t);
      if (i && o)
        return c ? n.deselect(e) : n.select(e);
      i ? n.deselect(e) : n.select(e, c);
    }
  });
}
S.$inject = [
  "eventBus",
  "selection",
  "canvas",
  "elementRegistry"
];
function p(r) {
  return !r.hidden;
}
exports.default = S;
