jbxl-workflow
Version:
流程图
1,260 lines (1,259 loc) • 1.06 MB
JavaScript
var Jv = Object.defineProperty;
var Zc = (e) => {
throw TypeError(e);
};
var Qv = (e, t, n) => t in e ? Jv(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var kr = (e, t, n) => Qv(e, typeof t != "symbol" ? t + "" : t, n), Jc = (e, t, n) => t.has(e) || Zc("Cannot " + n);
var Qc = (e, t, n) => (Jc(e, t, "read from private field"), n ? n.call(e) : t.get(e)), ed = (e, t, n) => t.has(e) ? Zc("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), td = (e, t, n, a) => (Jc(e, t, "write to private field"), a ? a.call(e, n) : t.set(e, n), n);
import { Graph as Fe, Basecoat as oo, ObjectExt as Ua, FunctionExt as Kn, Model as em, View as Wl, Dom as _e, Collection as tm, Rectangle as ja, Cell as nm, CssLoader as El, ModifierKey as tu, Disposable as Kl, Node as Gu, Markup as am, NodeView as $p, GraphView as om, Platform as $s, NumberExt as _r, Point as Bo, Util as nd, BackgroundManager as rm, Config as sm } from "@antv/x6";
import { ref as N, defineComponent as de, computed as D, createElementBlock as B, openBlock as T, mergeProps as Ut, unref as c, renderSlot as ge, useAttrs as ia, useSlots as Un, shallowRef as Vn, watch as ye, nextTick as je, onMounted as pt, toRef as xt, normalizeStyle as ut, normalizeClass as H, createCommentVNode as le, Fragment as Re, createElementVNode as A, createBlock as ce, withCtx as Y, resolveDynamicComponent as Mt, withModifiers as We, createVNode as G, toDisplayString as fe, provide as Et, reactive as fn, onActivated as lm, onUpdated as Yl, inject as Me, onBeforeUnmount as pn, withDirectives as st, cloneVNode as im, Text as Ip, Comment as Lp, Transition as $a, vShow as At, readonly as qu, onDeactivated as um, isRef as Kt, vModelCheckbox as Tl, createTextVNode as tt, toRefs as us, toHandlers as cm, renderList as nt, h as He, createSlots as po, getCurrentInstance as lt, watchEffect as Na, withKeys as Wn, onUnmounted as Oo, onBeforeMount as Xu, toRaw as nu, warn as dm, getCurrentScope as fm, onScopeDispose as Fp, resolveComponent as St, resolveDirective as Zu, Teleport as pm, toHandlerKey as hm, vModelText as gm, isVNode as au, render as Pl, normalizeProps as vm, guardReactiveProps as mm, createApp as bm } from "vue";
import { ElTooltip as En, ElPopover as Gr, ElMessage as It, ElForm as er, ElFormItem as Qt, ElTreeSelect as ym, ElCheckbox as tr, ElUpload as wm, ElIcon as bi, ElLoading as Bp, ElImage as Cm, ElRadioGroup as Sm, ElRadio as km, ElRow as _m, ElCol as ad, ElSwitch as xm, ClickOutside as Em, ElSlider as od, ElCheckboxGroup as Tm, ElMessageBox as Pm } from "element-plus";
import Ae from "dayjs";
Fe.prototype.isHistoryEnabled = function() {
const e = this.getPlugin("history");
return e ? e.isEnabled() : !1;
};
Fe.prototype.enableHistory = function() {
const e = this.getPlugin("history");
return e && e.enable(), this;
};
Fe.prototype.disableHistory = function() {
const e = this.getPlugin("history");
return e && e.disable(), this;
};
Fe.prototype.toggleHistory = function(e) {
const t = this.getPlugin("history");
return t && t.toggleEnabled(e), this;
};
Fe.prototype.undo = function(e) {
const t = this.getPlugin("history");
return t && t.undo(e), this;
};
Fe.prototype.redo = function(e) {
const t = this.getPlugin("history");
return t && t.redo(e), this;
};
Fe.prototype.undoAndCancel = function(e) {
const t = this.getPlugin("history");
return t && t.cancel(e), this;
};
Fe.prototype.canUndo = function() {
const e = this.getPlugin("history");
return e ? e.canUndo() : !1;
};
Fe.prototype.canRedo = function() {
const e = this.getPlugin("history");
return e ? e.canRedo() : !1;
};
Fe.prototype.cleanHistory = function(e) {
const t = this.getPlugin("history");
return t && t.clean(e), this;
};
Fe.prototype.getHistoryStackSize = function() {
return this.getPlugin("history").getSize();
};
Fe.prototype.getUndoStackSize = function() {
return this.getPlugin("history").getUndoSize();
};
Fe.prototype.getRedoStackSize = function() {
return this.getPlugin("history").getRedoSize();
};
Fe.prototype.getUndoRemainSize = function() {
return this.getPlugin("history").getUndoRemainSize();
};
var Vp = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class nr extends oo {
constructor(t = {}) {
super(), this.name = "history", this.batchCommands = null, this.batchLevel = 0, this.lastBatchIndex = -1, this.freezed = !1, this.stackSize = 0, this.handlers = [];
const { stackSize: n = 0 } = t;
this.stackSize = n, this.options = Rt.getOptions(t), this.validator = new nr.Validator({
history: this,
cancelInvalid: this.options.cancelInvalid
});
}
init(t) {
this.graph = t, this.model = this.graph.model, this.clean(), this.startListening();
}
// #region api
isEnabled() {
return !this.disabled;
}
enable() {
this.disabled && (this.options.enabled = !0);
}
disable() {
this.disabled || (this.options.enabled = !1);
}
toggleEnabled(t) {
return t != null ? t !== this.isEnabled() && (t ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this;
}
undo(t = {}) {
if (!this.disabled) {
const n = this.undoStack.pop();
n && (this.revertCommand(n, t), this.redoStack.push(n), this.notify("undo", n, t));
}
return this;
}
redo(t = {}) {
if (!this.disabled) {
const n = this.redoStack.pop();
n && (this.applyCommand(n, t), this.undoStackPush(n), this.notify("redo", n, t));
}
return this;
}
/**
* Same as `undo()` but does not store the undo-ed command to the
* `redoStack`. Canceled command therefore cannot be redo-ed.
*/
cancel(t = {}) {
if (!this.disabled) {
const n = this.undoStack.pop();
n && (this.revertCommand(n, t), this.redoStack = [], this.notify("cancel", n, t));
}
return this;
}
getSize() {
return this.stackSize;
}
getUndoRemainSize() {
const t = this.undoStack.length;
return this.stackSize - t;
}
getUndoSize() {
return this.undoStack.length;
}
getRedoSize() {
return this.redoStack.length;
}
canUndo() {
return !this.disabled && this.undoStack.length > 0;
}
canRedo() {
return !this.disabled && this.redoStack.length > 0;
}
clean(t = {}) {
return this.undoStack = [], this.redoStack = [], this.notify("clean", null, t), this;
}
// #endregion
get disabled() {
return this.options.enabled !== !0;
}
validate(t, ...n) {
return this.validator.validate(t, ...n), this;
}
startListening() {
this.model.on("batch:start", this.initBatchCommand, this), this.model.on("batch:stop", this.storeBatchCommand, this), this.options.eventNames && this.options.eventNames.forEach((t, n) => {
this.handlers[n] = this.addCommand.bind(this, t), this.model.on(t, this.handlers[n]);
}), this.validator.on("invalid", (t) => this.trigger("invalid", t));
}
stopListening() {
this.model.off("batch:start", this.initBatchCommand, this), this.model.off("batch:stop", this.storeBatchCommand, this), this.options.eventNames && (this.options.eventNames.forEach((t, n) => {
this.model.off(t, this.handlers[n]);
}), this.handlers.length = 0), this.validator.off("invalid");
}
createCommand(t) {
return {
batch: t ? t.batch : !1,
data: {}
};
}
revertCommand(t, n) {
this.freezed = !0;
const a = Array.isArray(t) ? Rt.sortBatchCommands(t) : [t];
for (let o = a.length - 1; o >= 0; o -= 1) {
const r = a[o], s = Object.assign(Object.assign({}, n), Ua.pick(r.options, this.options.revertOptionsList || []));
this.executeCommand(r, !0, s);
}
this.freezed = !1;
}
applyCommand(t, n) {
this.freezed = !0;
const a = Array.isArray(t) ? Rt.sortBatchCommands(t) : [t];
for (let o = 0; o < a.length; o += 1) {
const r = a[o], s = Object.assign(Object.assign({}, n), Ua.pick(r.options, this.options.applyOptionsList || []));
this.executeCommand(r, !1, s);
}
this.freezed = !1;
}
executeCommand(t, n, a) {
const o = this.model, r = o.getCell(t.data.id), s = t.event;
if (Rt.isAddEvent(s) && n || Rt.isRemoveEvent(s) && !n)
r && r.remove(a);
else if (Rt.isAddEvent(s) && !n || Rt.isRemoveEvent(s) && n) {
const l = t.data;
l.node ? o.addNode(l.props, a) : l.edge && o.addEdge(l.props, a);
} else if (Rt.isChangeEvent(s)) {
const l = t.data, i = l.key;
if (i && r) {
const u = n ? l.prev[i] : l.next[i];
l.key === "attrs" && this.ensureUndefinedAttrs(u, n ? l.next[i] : l.prev[i]) && (a.dirty = !0), r.prop(i, u, a);
}
} else {
const l = this.options.executeCommand;
l && Kn.call(l, this, t, n, a);
}
}
addCommand(t, n) {
if (this.freezed || this.disabled)
return;
const a = n, o = a.options || {};
if (o.dryrun || Rt.isAddEvent(t) && this.options.ignoreAdd || Rt.isRemoveEvent(t) && this.options.ignoreRemove || Rt.isChangeEvent(t) && this.options.ignoreChange)
return;
const r = this.options.beforeAddCommand;
if (r != null && Kn.call(r, this, t, n) === !1)
return;
t === "cell:change:*" && (t = `cell:change:${a.key}`);
const s = a.cell, l = em.isModel(s);
let i;
if (this.batchCommands) {
i = this.batchCommands[Math.max(this.lastBatchIndex, 0)];
const d = l && !i.modelChange || i.data.id !== s.id, f = i.event !== t;
if (this.lastBatchIndex >= 0 && (d || f)) {
const p = this.batchCommands.findIndex((g) => (l && g.modelChange || g.data.id === s.id) && g.event === t);
p < 0 || Rt.isAddEvent(t) || Rt.isRemoveEvent(t) ? i = this.createCommand({ batch: !0 }) : (i = this.batchCommands[p], this.batchCommands.splice(p, 1)), this.batchCommands.push(i), this.lastBatchIndex = this.batchCommands.length - 1;
}
} else
i = this.createCommand({ batch: !1 });
if (Rt.isAddEvent(t) || Rt.isRemoveEvent(t)) {
const d = i.data;
return i.event = t, i.options = o, d.id = s.id, d.props = Ua.cloneDeep(s.toJSON()), s.isEdge() ? d.edge = !0 : s.isNode() && (d.node = !0), this.push(i, o);
}
if (Rt.isChangeEvent(t)) {
const d = n.key, f = i.data;
return (!i.batch || !i.event) && (i.event = t, i.options = o, f.key = d, f.prev == null && (f.prev = {}), f.prev[d] = Ua.cloneDeep(s.previous(d)), l ? i.modelChange = !0 : f.id = s.id), f.next == null && (f.next = {}), f.next[d] = Ua.cloneDeep(s.prop(d)), this.push(i, o);
}
const u = this.options.afterAddCommand;
u && Kn.call(u, this, t, n, i), this.push(i, o);
}
/**
* Gather multiple changes into a single command. These commands could
* be reverted with single `undo()` call. From the moment the function
* is called every change made on model is not stored into the undoStack.
* Changes are temporarily kept until `storeBatchCommand()` is called.
*/
// eslint-disable-next-line
initBatchCommand(t) {
this.freezed || (this.batchCommands ? this.batchLevel += 1 : (this.batchCommands = [this.createCommand({ batch: !0 })], this.batchLevel = 0, this.lastBatchIndex = -1));
}
/**
* Store changes temporarily kept in the undoStack. You have to call this
* function as many times as `initBatchCommand()` been called.
*/
storeBatchCommand(t) {
if (!this.freezed)
if (this.batchCommands && this.batchLevel <= 0) {
const n = this.filterBatchCommand(this.batchCommands);
n.length > 0 && (this.redoStack = [], this.undoStackPush(n), this.consolidateCommands(), this.notify("add", n, t)), this.batchCommands = null, this.lastBatchIndex = -1, this.batchLevel = 0;
} else this.batchCommands && this.batchLevel > 0 && (this.batchLevel -= 1);
}
filterBatchCommand(t) {
let n = t.slice();
const a = [];
for (; n.length > 0; ) {
const o = n.shift(), r = o.event, s = o.data.id;
if (r != null && (s != null || o.modelChange)) {
if (Rt.isAddEvent(r)) {
const l = n.findIndex((i) => Rt.isRemoveEvent(i.event) && i.data.id === s);
if (l >= 0) {
n = n.filter((i, u) => l < u || i.data.id !== s);
continue;
}
} else if (Rt.isRemoveEvent(r)) {
const l = n.findIndex((i) => Rt.isAddEvent(i.event) && i.data.id === s);
if (l >= 0) {
n.splice(l, 1);
continue;
}
} else if (Rt.isChangeEvent(r)) {
const l = o.data;
if (Ua.isEqual(l.prev, l.next))
continue;
}
a.push(o);
}
}
return a;
}
notify(t, n, a) {
const o = n == null ? null : Array.isArray(n) ? n : [n];
this.emit(t, { cmds: o, options: a }), this.graph.trigger(`history:${t}`, { cmds: o, options: a }), this.emit("change", { cmds: o, options: a }), this.graph.trigger("history:change", { cmds: o, options: a });
}
push(t, n) {
this.redoStack = [], t.batch ? (this.lastBatchIndex = Math.max(this.lastBatchIndex, 0), this.emit("batch", { cmd: t, options: n })) : (this.undoStackPush(t), this.consolidateCommands(), this.notify("add", t, n));
}
/**
* Conditionally combine multiple undo items into one.
*
* Currently this is only used combine a `cell:changed:position` event
* followed by multiple `cell:change:parent` and `cell:change:children`
* events, such that a "move + embed" action can be undone in one step.
*
* See https://github.com/antvis/X6/issues/2421
*
* This is an ugly WORKAROUND. It does not solve deficiencies in the batch
* system itself.
*/
consolidateCommands() {
var t;
const n = this.undoStack[this.undoStack.length - 1], a = this.undoStack[this.undoStack.length - 2];
if (!Array.isArray(n))
return;
const o = new Set(n.map((s) => s.event));
if (o.size !== 2 || !o.has("cell:change:parent") || !o.has("cell:change:children") || !n.every((s) => {
var l;
return s.batch && ((l = s.options) === null || l === void 0 ? void 0 : l.ui);
}) || !Array.isArray(a) || a.length !== 1)
return;
const r = a[0];
r.event !== "cell:change:position" || !(!((t = r.options) === null || t === void 0) && t.ui) || (a.push(...n), this.undoStack.pop());
}
undoStackPush(t) {
if (this.stackSize === 0) {
this.undoStack.push(t);
return;
}
this.undoStack.length >= this.stackSize && this.undoStack.shift(), this.undoStack.push(t);
}
ensureUndefinedAttrs(t, n) {
let a = !1;
return t !== null && n !== null && typeof t == "object" && typeof n == "object" && Object.keys(n).forEach((o) => {
t[o] === void 0 && n[o] !== void 0 ? (t[o] = void 0, a = !0) : typeof t[o] == "object" && typeof n[o] == "object" && (a = this.ensureUndefinedAttrs(t[o], n[o]));
}), a;
}
dispose() {
this.validator.dispose(), this.clean(), this.stopListening(), this.off();
}
}
Vp([
oo.dispose()
], nr.prototype, "dispose", null);
(function(e) {
class t extends oo {
constructor(a) {
super(), this.map = {}, this.command = a.history, this.cancelInvalid = a.cancelInvalid !== !1, this.command.on("add", this.onCommandAdded, this);
}
onCommandAdded({ cmds: a }) {
return Array.isArray(a) ? a.every((o) => this.isValidCommand(o)) : this.isValidCommand(a);
}
isValidCommand(a) {
if (a.options && a.options.validation === !1)
return !0;
const o = a.event && this.map[a.event] || [];
let r = null;
return o.forEach((s) => {
let l = 0;
const i = (u) => {
const d = s[l];
l += 1;
try {
if (d)
d(u, a, i);
else {
r = u;
return;
}
} catch (f) {
i(f);
}
};
i(r);
}), r ? (this.cancelInvalid && this.command.cancel(), this.emit("invalid", { err: r }), !1) : !0;
}
validate(a, ...o) {
const r = Array.isArray(a) ? a : a.split(/\s+/);
return o.forEach((s) => {
if (typeof s != "function")
throw new Error(`${r.join(" ")} requires callback functions.`);
}), r.forEach((s) => {
this.map[s] == null && (this.map[s] = []), this.map[s].push(o);
}), this;
}
dispose() {
this.command.off("add", this.onCommandAdded, this);
}
}
Vp([
oo.dispose()
], t.prototype, "dispose", null), e.Validator = t;
})(nr || (nr = {}));
var Rt;
(function(e) {
function t(s) {
return s === "cell:added";
}
e.isAddEvent = t;
function n(s) {
return s === "cell:removed";
}
e.isRemoveEvent = n;
function a(s) {
return s != null && s.startsWith("cell:change:");
}
e.isChangeEvent = a;
function o(s) {
const l = [
"cell:added",
"cell:removed",
"cell:change:*"
], i = ["batch:start", "batch:stop"], u = s.eventNames ? s.eventNames.filter((d) => !(e.isChangeEvent(d) || l.includes(d) || i.includes(d))) : l;
return Object.assign(Object.assign({ enabled: !0 }, s), { eventNames: u, applyOptionsList: s.applyOptionsList || ["propertyPath"], revertOptionsList: s.revertOptionsList || ["propertyPath"] });
}
e.getOptions = o;
function r(s) {
const l = [];
for (let i = 0, u = s.length; i < u; i += 1) {
const d = s[i];
let f = null;
if (e.isAddEvent(d.event)) {
const p = d.data.id;
for (let g = 0; g < i; g += 1)
if (s[g].data.id === p) {
f = g;
break;
}
}
f !== null ? l.splice(f, 0, d) : l.push(d);
}
return l;
}
e.sortBatchCommands = r;
})(Rt || (Rt = {}));
var Dm = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class zp extends Wl {
get graph() {
return this.options.graph;
}
get boxClassName() {
return this.prefixClassName(_n.classNames.box);
}
get $boxes() {
return _e.children(this.container, this.boxClassName);
}
get handleOptions() {
return this.options;
}
constructor(t) {
super(), this.options = t, this.options.model && (this.options.collection = this.options.model.collection), this.options.collection ? this.collection = this.options.collection : (this.collection = new tm([], {
comparator: _n.depthComparator
}), this.options.collection = this.collection), this.boxCount = 0, this.createContainer(), this.startListening();
}
startListening() {
const t = this.graph, n = this.collection;
this.delegateEvents({
[`mousedown .${this.boxClassName}`]: "onSelectionBoxMouseDown",
[`touchstart .${this.boxClassName}`]: "onSelectionBoxMouseDown"
}, !0), t.on("scale", this.onGraphTransformed, this), t.on("translate", this.onGraphTransformed, this), t.model.on("updated", this.onModelUpdated, this), n.on("added", this.onCellAdded, this), n.on("removed", this.onCellRemoved, this), n.on("reseted", this.onReseted, this), n.on("updated", this.onCollectionUpdated, this), n.on("node:change:position", this.onNodePositionChanged, this), n.on("cell:changed", this.onCellChanged, this);
}
stopListening() {
const t = this.graph, n = this.collection;
this.undelegateEvents(), t.off("scale", this.onGraphTransformed, this), t.off("translate", this.onGraphTransformed, this), t.model.off("updated", this.onModelUpdated, this), n.off("added", this.onCellAdded, this), n.off("removed", this.onCellRemoved, this), n.off("reseted", this.onReseted, this), n.off("updated", this.onCollectionUpdated, this), n.off("node:change:position", this.onNodePositionChanged, this), n.off("cell:changed", this.onCellChanged, this);
}
onRemove() {
this.stopListening();
}
onGraphTransformed() {
this.updateSelectionBoxes();
}
onCellChanged() {
this.updateSelectionBoxes();
}
onNodePositionChanged({ node: t, options: n }) {
const { showNodeSelectionBox: a, pointerEvents: o } = this.options, { ui: r, selection: s, translateBy: l, snapped: i } = n, u = (a !== !0 || o && this.getPointerEventsValue(o) === "none") && !this.translating && !s, d = r && l && t.id === l;
if (u && (d || i)) {
this.translating = !0;
const f = t.position(), p = t.previous("position"), g = f.x - p.x, h = f.y - p.y;
(g !== 0 || h !== 0) && this.translateSelectedNodes(g, h, t, n), this.translating = !1;
}
}
onModelUpdated({ removed: t }) {
t && t.length && this.unselect(t);
}
isEmpty() {
return this.length <= 0;
}
isSelected(t) {
return this.collection.has(t);
}
get length() {
return this.collection.length;
}
get cells() {
return this.collection.toArray();
}
select(t, n = {}) {
n.dryrun = !0;
const a = this.filter(Array.isArray(t) ? t : [t]);
return this.collection.add(a, n), this;
}
unselect(t, n = {}) {
return n.dryrun = !0, this.collection.remove(Array.isArray(t) ? t : [t], n), this;
}
reset(t, n = {}) {
if (t) {
if (n.batch) {
const u = this.filter(Array.isArray(t) ? t : [t]);
return this.collection.reset(u, Object.assign(Object.assign({}, n), { ui: !0 })), this;
}
const a = this.cells, o = this.filter(Array.isArray(t) ? t : [t]), r = {}, s = {};
a.forEach((u) => r[u.id] = u), o.forEach((u) => s[u.id] = u);
const l = [], i = [];
return o.forEach((u) => {
r[u.id] || l.push(u);
}), a.forEach((u) => {
s[u.id] || i.push(u);
}), i.length && this.unselect(i, Object.assign(Object.assign({}, n), { ui: !0 })), l.length && this.select(l, Object.assign(Object.assign({}, n), { ui: !0 })), i.length === 0 && l.length === 0 && this.updateContainer(), this;
}
return this.clean(n);
}
clean(t = {}) {
return this.length && (t.batch === !1 ? this.unselect(this.cells, t) : this.collection.reset([], Object.assign(Object.assign({}, t), { ui: !0 }))), this;
}
setFilter(t) {
this.options.filter = t;
}
setContent(t) {
this.options.content = t;
}
startSelecting(t) {
t = this.normalizeEvent(t), this.clean();
let n, a;
const o = this.graph.container;
if (t.offsetX != null && t.offsetY != null && o.contains(t.target))
n = t.offsetX, a = t.offsetY;
else {
const r = _e.offset(o), s = o.scrollLeft, l = o.scrollTop;
n = t.clientX - r.left + window.pageXOffset + s, a = t.clientY - r.top + window.pageYOffset + l;
}
_e.css(this.container, {
top: a,
left: n,
width: 1,
height: 1
}), this.setEventData(t, {
action: "selecting",
clientX: t.clientX,
clientY: t.clientY,
offsetX: n,
offsetY: a,
scrollerX: 0,
scrollerY: 0,
moving: !1
}), this.delegateDocumentEvents(_n.documentEvents, t.data);
}
filter(t) {
const n = this.options.filter;
return t.filter((a) => Array.isArray(n) ? n.some((o) => typeof o == "string" ? a.shape === o : a.id === o.id) : typeof n == "function" ? Kn.call(n, this.graph, a) : !0);
}
stopSelecting(t) {
const n = this.graph, a = this.getEventData(t);
switch (a.action) {
case "selecting": {
let r = _e.width(this.container), s = _e.height(this.container);
const l = _e.offset(this.container), i = n.pageToLocal(l.left, l.top), u = n.transform.getScale();
r /= u.sx, s /= u.sy;
const d = new ja(i.x, i.y, r, s), f = this.getCellViewsInArea(d).map((p) => p.cell);
this.reset(f, { batch: !0 }), this.hideRubberband();
break;
}
case "translating": {
const r = n.snapToGrid(t.clientX, t.clientY);
if (!this.options.following) {
const s = a;
this.updateSelectedNodesPosition({
dx: s.clientX - s.originX,
dy: s.clientY - s.originY
});
}
this.graph.model.stopBatch("move-selection"), this.notifyBoxEvent("box:mouseup", t, r.x, r.y);
break;
}
default: {
this.clean();
break;
}
}
}
onMouseUp(t) {
this.getEventData(t).action && (this.stopSelecting(t), this.undelegateDocumentEvents());
}
onSelectionBoxMouseDown(t) {
this.options.following || t.stopPropagation();
const n = this.normalizeEvent(t);
this.options.movable && this.startTranslating(n);
const a = this.getCellViewFromElem(n.target);
this.setEventData(n, { activeView: a });
const o = this.graph.snapToGrid(n.clientX, n.clientY);
this.notifyBoxEvent("box:mousedown", n, o.x, o.y), this.delegateDocumentEvents(_n.documentEvents, n.data);
}
startTranslating(t) {
this.graph.model.startBatch("move-selection");
const n = this.graph.snapToGrid(t.clientX, t.clientY);
this.setEventData(t, {
action: "translating",
clientX: n.x,
clientY: n.y,
originX: n.x,
originY: n.y
});
}
getRestrictArea() {
const t = this.graph.options.translating.restrict, n = typeof t == "function" ? Kn.call(t, this.graph, null) : t;
return typeof n == "number" ? this.graph.transform.getGraphArea().inflate(n) : n === !0 ? this.graph.transform.getGraphArea() : n || null;
}
getSelectionOffset(t, n) {
let a = t.x - n.clientX, o = t.y - n.clientY;
const r = this.getRestrictArea();
if (r) {
const s = this.collection.toArray(), l = nm.getCellsBBox(s, { deep: !0 }) || ja.create(), i = r.x - l.x, u = r.y - l.y, d = r.x + r.width - (l.x + l.width), f = r.y + r.height - (l.y + l.height);
if (a < i && (a = i), o < u && (o = u), d < a && (a = d), f < o && (o = f), !this.options.following) {
const p = t.x - n.originX, g = t.y - n.originY;
a = p <= i || p >= d ? 0 : a, o = g <= u || g >= f ? 0 : o;
}
}
return {
dx: a,
dy: o
};
}
updateElementPosition(t, n, a) {
const o = _e.css(t, "left"), r = _e.css(t, "top"), s = o ? parseFloat(o) : 0, l = r ? parseFloat(r) : 0;
_e.css(t, "left", s + n), _e.css(t, "top", l + a);
}
updateSelectedNodesPosition(t) {
const { dx: n, dy: a } = t;
if (n || a)
if (this.translateSelectedNodes(n, a), this.boxesUpdated)
this.collection.length > 1 && this.updateSelectionBoxes();
else {
const o = this.graph.transform.getScale();
for (let r = 0, s = this.$boxes, l = s.length; r < l; r += 1)
this.updateElementPosition(s[r], n * o.sx, a * o.sy);
this.updateElementPosition(this.selectionContainer, n * o.sx, a * o.sy);
}
}
autoScrollGraph(t, n) {
const a = this.graph.getPlugin("scroller");
return a ? a.autoScroll(t, n) : { scrollerX: 0, scrollerY: 0 };
}
adjustSelection(t) {
const n = this.normalizeEvent(t), a = this.getEventData(n);
switch (a.action) {
case "selecting": {
const r = a;
r.moving !== !0 && (_e.appendTo(this.container, this.graph.container), this.showRubberband(), r.moving = !0);
const { scrollerX: s, scrollerY: l } = this.autoScrollGraph(n.clientX, n.clientY);
r.scrollerX += s, r.scrollerY += l;
const i = n.clientX - r.clientX + r.scrollerX, u = n.clientY - r.clientY + r.scrollerY, d = parseInt(_e.css(this.container, "left") || "0", 10), f = parseInt(_e.css(this.container, "top") || "0", 10);
_e.css(this.container, {
left: i < 0 ? r.offsetX + i : d,
top: u < 0 ? r.offsetY + u : f,
width: Math.abs(i),
height: Math.abs(u)
});
break;
}
case "translating": {
const r = this.graph.snapToGrid(n.clientX, n.clientY), s = a, l = this.getSelectionOffset(r, s);
this.options.following ? this.updateSelectedNodesPosition(l) : this.updateContainerPosition(l), l.dx && (s.clientX = r.x), l.dy && (s.clientY = r.y), this.notifyBoxEvent("box:mousemove", t, r.x, r.y);
break;
}
}
this.boxesUpdated = !1;
}
translateSelectedNodes(t, n, a, o) {
const r = {}, s = [];
if (a && (r[a.id] = !0), this.collection.toArray().forEach((l) => {
l.getDescendants({ deep: !0 }).forEach((i) => {
r[i.id] = !0;
});
}), o && o.translateBy) {
const l = this.graph.getCellById(o.translateBy);
l && (r[l.id] = !0, l.getDescendants({ deep: !0 }).forEach((i) => {
r[i.id] = !0;
}), s.push(l));
}
this.collection.toArray().forEach((l) => {
if (!r[l.id]) {
const i = Object.assign(Object.assign({}, o), { selection: this.cid, exclude: s });
l.translate(t, n, i), this.graph.model.getConnectedEdges(l).forEach((u) => {
r[u.id] || (u.translate(t, n, i), r[u.id] = !0);
});
}
});
}
getCellViewsInArea(t) {
const n = this.graph, a = {
strict: this.options.strict
};
let o = [];
return this.options.rubberNode && (o = o.concat(n.model.getNodesInArea(t, a).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), this.options.rubberEdge && (o = o.concat(n.model.getEdgesInArea(t, a).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), o;
}
notifyBoxEvent(t, n, a, o) {
const s = this.getEventData(n).activeView;
this.trigger(t, { e: n, view: s, x: a, y: o, cell: s.cell });
}
getSelectedClassName(t) {
return this.prefixClassName(`${t.isNode() ? "node" : "edge"}-selected`);
}
addCellSelectedClassName(t) {
const n = this.graph.renderer.findViewByCell(t);
n && n.addClass(this.getSelectedClassName(t));
}
removeCellUnSelectedClassName(t) {
const n = this.graph.renderer.findViewByCell(t);
n && n.removeClass(this.getSelectedClassName(t));
}
destroySelectionBox(t) {
this.removeCellUnSelectedClassName(t), this.canShowSelectionBox(t) && (_e.remove(this.container.querySelector(`[data-cell-id="${t.id}"]`)), this.$boxes.length === 0 && this.hide(), this.boxCount = Math.max(0, this.boxCount - 1));
}
destroyAllSelectionBoxes(t) {
t.forEach((n) => this.removeCellUnSelectedClassName(n)), this.hide(), _e.remove(this.$boxes), this.boxCount = 0;
}
hide() {
_e.removeClass(this.container, this.prefixClassName(_n.classNames.rubberband)), _e.removeClass(this.container, this.prefixClassName(_n.classNames.selected));
}
showRubberband() {
_e.addClass(this.container, this.prefixClassName(_n.classNames.rubberband));
}
hideRubberband() {
_e.removeClass(this.container, this.prefixClassName(_n.classNames.rubberband));
}
showSelected() {
_e.removeAttribute(this.container, "style"), _e.addClass(this.container, this.prefixClassName(_n.classNames.selected));
}
createContainer() {
this.container = document.createElement("div"), _e.addClass(this.container, this.prefixClassName(_n.classNames.root)), this.options.className && _e.addClass(this.container, this.options.className), this.selectionContainer = document.createElement("div"), _e.addClass(this.selectionContainer, this.prefixClassName(_n.classNames.inner)), this.selectionContent = document.createElement("div"), _e.addClass(this.selectionContent, this.prefixClassName(_n.classNames.content)), _e.append(this.selectionContainer, this.selectionContent), _e.attr(this.selectionContainer, "data-selection-length", this.collection.length), _e.prepend(this.container, this.selectionContainer);
}
updateContainerPosition(t) {
(t.dx || t.dy) && this.updateElementPosition(this.selectionContainer, t.dx, t.dy);
}
updateContainer() {
const t = { x: 1 / 0, y: 1 / 0 }, n = { x: 0, y: 0 };
this.collection.toArray().filter((r) => this.canShowSelectionBox(r)).forEach((r) => {
const s = this.graph.renderer.findViewByCell(r);
if (s) {
const l = s.getBBox({
useCellGeometry: !0
});
t.x = Math.min(t.x, l.x), t.y = Math.min(t.y, l.y), n.x = Math.max(n.x, l.x + l.width), n.y = Math.max(n.y, l.y + l.height);
}
}), _e.css(this.selectionContainer, {
position: "absolute",
pointerEvents: "none",
left: t.x,
top: t.y,
width: n.x - t.x,
height: n.y - t.y
}), _e.attr(this.selectionContainer, "data-selection-length", this.collection.length);
const o = this.options.content;
if (o)
if (typeof o == "function") {
const r = Kn.call(o, this.graph, this, this.selectionContent);
r && (this.selectionContent.innerHTML = r);
} else
this.selectionContent.innerHTML = o;
this.collection.length > 0 && !this.container.parentNode ? _e.appendTo(this.container, this.graph.container) : this.collection.length <= 0 && this.container.parentNode && this.container.parentNode.removeChild(this.container);
}
canShowSelectionBox(t) {
return t.isNode() && this.options.showNodeSelectionBox === !0 || t.isEdge() && this.options.showEdgeSelectionBox === !0;
}
getPointerEventsValue(t) {
return typeof t == "string" ? t : t(this.cells);
}
createSelectionBox(t) {
if (this.addCellSelectedClassName(t), this.canShowSelectionBox(t)) {
const n = this.graph.renderer.findViewByCell(t);
if (n) {
const a = n.getBBox({
useCellGeometry: !0
}), o = this.boxClassName, r = document.createElement("div"), s = this.options.pointerEvents;
_e.addClass(r, o), _e.addClass(r, `${o}-${t.isNode() ? "node" : "edge"}`), _e.attr(r, "data-cell-id", t.id), _e.css(r, {
position: "absolute",
left: a.x,
top: a.y,
width: a.width,
height: a.height,
pointerEvents: s ? this.getPointerEventsValue(s) : "auto"
}), _e.appendTo(r, this.container), this.showSelected(), this.boxCount += 1;
}
}
}
updateSelectionBoxes() {
this.collection.length > 0 && (this.boxesUpdated = !0, this.confirmUpdate());
}
confirmUpdate() {
if (this.boxCount) {
this.hide();
for (let t = 0, n = this.$boxes, a = n.length; t < a; t += 1) {
const o = n[t], r = _e.attr(o, "data-cell-id");
_e.remove(o), this.boxCount -= 1;
const s = this.collection.get(r);
s && this.createSelectionBox(s);
}
this.updateContainer();
}
return 0;
}
getCellViewFromElem(t) {
const n = t.getAttribute("data-cell-id");
if (n) {
const a = this.collection.get(n);
if (a)
return this.graph.renderer.findViewByCell(a);
}
return null;
}
onCellRemoved({ cell: t }) {
this.destroySelectionBox(t), this.updateContainer();
}
onReseted({ previous: t, current: n }) {
this.destroyAllSelectionBoxes(t), n.forEach((a) => {
this.listenCellRemoveEvent(a), this.createSelectionBox(a);
}), this.updateContainer();
}
onCellAdded({ cell: t }) {
this.listenCellRemoveEvent(t), this.createSelectionBox(t), this.updateContainer();
}
listenCellRemoveEvent(t) {
t.off("removed", this.onCellRemoved, this), t.on("removed", this.onCellRemoved, this);
}
onCollectionUpdated({ added: t, removed: n, options: a }) {
t.forEach((r) => {
this.trigger("cell:selected", { cell: r, options: a }), r.isNode() ? this.trigger("node:selected", { cell: r, options: a, node: r }) : r.isEdge() && this.trigger("edge:selected", { cell: r, options: a, edge: r });
}), n.forEach((r) => {
this.trigger("cell:unselected", { cell: r, options: a }), r.isNode() ? this.trigger("node:unselected", { cell: r, options: a, node: r }) : r.isEdge() && this.trigger("edge:unselected", { cell: r, options: a, edge: r });
});
const o = {
added: t,
removed: n,
options: a,
selected: this.cells.filter((r) => !!this.graph.getCellById(r.id))
};
this.trigger("selection:changed", o);
}
// #endregion
dispose() {
this.clean(), this.remove(), this.off();
}
}
Dm([
Wl.dispose()
], zp.prototype, "dispose", null);
var _n;
(function(e) {
const t = "widget-selection";
e.classNames = {
root: t,
inner: `${t}-inner`,
box: `${t}-box`,
content: `${t}-content`,
rubberband: `${t}-rubberband`,
selected: `${t}-selected`
}, e.documentEvents = {
mousemove: "adjustSelection",
touchmove: "adjustSelection",
mouseup: "onMouseUp",
touchend: "onMouseUp",
touchcancel: "onMouseUp"
};
function n(a) {
return a.getAncestors().length;
}
e.depthComparator = n;
})(_n || (_n = {}));
const Nm = `.x6-widget-selection {
position: absolute;
top: 0;
left: 0;
display: none;
width: 0;
height: 0;
touch-action: none;
}
.x6-widget-selection-rubberband {
display: block;
overflow: visible;
opacity: 0.3;
}
.x6-widget-selection-selected {
display: block;
}
.x6-widget-selection-box {
cursor: move;
}
.x6-widget-selection-inner[data-selection-length='0'],
.x6-widget-selection-inner[data-selection-length='1'] {
display: none;
}
.x6-widget-selection-content {
position: absolute;
top: 100%;
right: -20px;
left: -20px;
margin-top: 30px;
padding: 6px;
line-height: 14px;
text-align: center;
border-radius: 6px;
}
.x6-widget-selection-content:empty {
display: none;
}
.x6-widget-selection-rubberband {
background-color: #3498db;
border: 2px solid #2980b9;
}
.x6-widget-selection-box {
box-sizing: content-box !important;
margin-top: -4px;
margin-left: -4px;
padding-right: 4px;
padding-bottom: 4px;
border: 2px dashed #feb663;
box-shadow: 2px 2px 5px #d3d3d3;
}
.x6-widget-selection-inner {
box-sizing: content-box !important;
margin-top: -8px;
margin-left: -8px;
padding-right: 12px;
padding-bottom: 12px;
border: 2px solid #feb663;
box-shadow: 2px 2px 5px #d3d3d3;
}
.x6-widget-selection-content {
color: #fff;
font-size: 10px;
background-color: #6a6b8a;
}
`;
Fe.prototype.isSelectionEnabled = function() {
const e = this.getPlugin("selection");
return e ? e.isEnabled() : !1;
};
Fe.prototype.enableSelection = function() {
const e = this.getPlugin("selection");
return e && e.enable(), this;
};
Fe.prototype.disableSelection = function() {
const e = this.getPlugin("selection");
return e && e.disable(), this;
};
Fe.prototype.toggleSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleEnabled(e), this;
};
Fe.prototype.isMultipleSelection = function() {
const e = this.getPlugin("selection");
return e ? e.isMultipleSelection() : !1;
};
Fe.prototype.enableMultipleSelection = function() {
const e = this.getPlugin("selection");
return e && e.enableMultipleSelection(), this;
};
Fe.prototype.disableMultipleSelection = function() {
const e = this.getPlugin("selection");
return e && e.disableMultipleSelection(), this;
};
Fe.prototype.toggleMultipleSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleMultipleSelection(e), this;
};
Fe.prototype.isSelectionMovable = function() {
const e = this.getPlugin("selection");
return e ? e.isSelectionMovable() : !1;
};
Fe.prototype.enableSelectionMovable = function() {
const e = this.getPlugin("selection");
return e && e.enableSelectionMovable(), this;
};
Fe.prototype.disableSelectionMovable = function() {
const e = this.getPlugin("selection");
return e && e.disableSelectionMovable(), this;
};
Fe.prototype.toggleSelectionMovable = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleSelectionMovable(e), this;
};
Fe.prototype.isRubberbandEnabled = function() {
const e = this.getPlugin("selection");
return e ? e.isRubberbandEnabled() : !1;
};
Fe.prototype.enableRubberband = function() {
const e = this.getPlugin("selection");
return e && e.enableRubberband(), this;
};
Fe.prototype.disableRubberband = function() {
const e = this.getPlugin("selection");
return e && e.disableRubberband(), this;
};
Fe.prototype.toggleRubberband = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleRubberband(e), this;
};
Fe.prototype.isStrictRubberband = function() {
const e = this.getPlugin("selection");
return e ? e.isStrictRubberband() : !1;
};
Fe.prototype.enableStrictRubberband = function() {
const e = this.getPlugin("selection");
return e && e.enableStrictRubberband(), this;
};
Fe.prototype.disableStrictRubberband = function() {
const e = this.getPlugin("selection");
return e && e.disableStrictRubberband(), this;
};
Fe.prototype.toggleStrictRubberband = function(e) {
const t = this.getPlugin("selection");
return t && t.toggleStrictRubberband(e), this;
};
Fe.prototype.setRubberbandModifiers = function(e) {
const t = this.getPlugin("selection");
return t && t.setRubberbandModifiers(e), this;
};
Fe.prototype.setSelectionFilter = function(e) {
const t = this.getPlugin("selection");
return t && t.setSelectionFilter(e), this;
};
Fe.prototype.setSelectionDisplayContent = function(e) {
const t = this.getPlugin("selection");
return t && t.setSelectionDisplayContent(e), this;
};
Fe.prototype.isSelectionEmpty = function() {
const e = this.getPlugin("selection");
return e ? e.isEmpty() : !0;
};
Fe.prototype.cleanSelection = function(e) {
const t = this.getPlugin("selection");
return t && t.clean(e), this;
};
Fe.prototype.resetSelection = function(e, t) {
const n = this.getPlugin("selection");
return n && n.reset(e, t), this;
};
Fe.prototype.getSelectedCells = function() {
const e = this.getPlugin("selection");
return e ? e.getSelectedCells() : [];
};
Fe.prototype.getSelectedCellCount = function() {
const e = this.getPlugin("selection");
return e ? e.getSelectedCellCount() : 0;
};
Fe.prototype.isSelected = function(e) {
const t = this.getPlugin("selection");
return t ? t.isSelected(e) : !1;
};
Fe.prototype.select = function(e, t) {
const n = this.getPlugin("selection");
return n && n.select(e, t), this;
};
Fe.prototype.unselect = function(e, t) {
const n = this.getPlugin("selection");
return n && n.unselect(e, t), this;
};
var Om = function(e, t, n, a) {
var o = arguments.length, r = o < 3 ? t : a === null ? a = Object.getOwnPropertyDescriptor(t, n) : a, s;
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(e, t, n, a);
else for (var l = e.length - 1; l >= 0; l--) (s = e[l]) && (r = (o < 3 ? s(r) : o > 3 ? s(t, n, r) : s(t, n)) || r);
return o > 3 && r && Object.defineProperty(t, n, r), r;
};
class ar extends oo {
get rubberbandDisabled() {
return this.options.enabled !== !0 || this.options.rubberband !== !0;
}
get disabled() {
return this.options.enabled !== !0;
}
get length() {
return this.selectionImpl.length;
}
get cells() {
return this.selectionImpl.cells;
}
constructor(t = {}) {
super(), this.name = "selection", this.movedMap = /* @__PURE__ */ new WeakMap(), this.unselectMap = /* @__PURE__ */ new WeakMap(), this.options = Object.assign(Object.assign({ enabled: !0 }, ar.defaultOptions), t), El.ensure(this.name, Nm);
}
init(t) {
this.graph = t, this.selectionImpl = new zp(Object.assign(Object.assign({}, this.options), { graph: t })), this.setup(), this.startListening();
}
// #region api
isEnabled() {
return !this.disabled;
}
enable() {
this.disabled && (this.options.enabled = !0);
}
disable() {
this.disabled || (this.options.enabled = !1);
}
toggleEnabled(t) {
return t != null ? t !== this.isEnabled() && (t ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this;
}
isMultipleSelection() {
return this.isMultiple();
}
enableMultipleSelection() {
return this.enableMultiple(), this;
}
disableMultipleSelection() {
return this.disableMultiple(), this;
}
toggleMultipleSelection(t) {
return t != null ? t !== this.isMultipleSelection() && (t ? this.enableMultipleSelection() : this.disableMultipleSelection()) : this.isMultipleSelection() ? this.disableMultipleSelection() : this.enableMultipleSelection(), this;
}
isSelectionMovable() {
return this.options.movable !== !1;
}
enableSelectionMovable() {
return this.selectionImpl.options.movable = !0, this;
}
disableSelectionMovable() {
return this.selectionImpl.options.movable = !1, this;
}
toggleSelectionMovable(t) {
return t != null ? t !== this.isSelectionMovable() && (t ? this.enableSelectionMovable() : this.disableSelectionMovable()) : this.isSelectionMovable() ? this.disableSelectionMovable() : this.enableSelectionMovable(), this;
}
isRubberbandEnabled() {
return !this.rubberbandDisabled;
}
enableRubberband() {
return this.rubberbandDisabled && (this.options.rubberband = !0), this;
}
disableRubberband() {
return this.rubberbandDisabled || (this.options.rubberband = !1), this;
}
toggleRubberband(t) {
return t != null ? t !== this.isRubberbandEnabled() && (t ? this.enableRubberband() : this.disableRubberband()) : this.isRubberbandEnabled() ? this.disableRubberband() : this.enableRubberband(), this;
}
isStrictRubberband() {
return this.selectionImpl.options.strict === !0;
}
enableStrictRubberband() {
return this.selectionImpl.options.strict = !0, this;
}
disableStrictRubberband() {
return this.selectionImpl.options.strict = !1, this;
}
toggleStrictRubberband(t) {
return t != null ? t !== this.isStrictRubberband() && (t ? this.enableStrictRubberband() : this.disableStrictRubberband()) : this.isStrictRubberband() ? this.disableStrictRubberband() : this.enableStrictRubberband(), this;
}
setRubberbandModifiers(t) {
this.setModifiers(t);
}
setSelectionFilter(t) {
return this.setFilter(t), this;
}
setSelectionDisplayContent(t) {
return this.setContent(t), this;
}
isEmpty() {
return this.length <= 0;
}
clean(t = {}) {
return this.selectionImpl.clean(t), this;
}
reset(t, n = {}) {
return this.selectionImpl.reset(t ? this.getCells(t) : [], n), this;
}
getSelectedCells() {
return this.cells;
}
getSelectedCellCount() {
return this.length;
}
isSelected(t) {
return this.selectionImpl.isSelected(t);
}
select(t, n = {}) {
const a = this.getCells(t);
return a.length && (this.isMultiple() ? this.selectionImpl.select(a, n) : this.reset(a.slice(0, 1), n)), this;
}
unselect(t, n = {}) {
return this.selectionImpl.unselect(this.getCells(t), n), this;
}
// #endregion
setup() {
this.selectionImpl.on("*", (t, n) => {
this.trigger(t, n), this.graph.trigger(t, n);
});
}
startListening() {
this.graph.on("blank:mousedown", this.onBlankMouseDown, this), this.graph.on("blank:click", this.onBlankClick, this), this.graph.on("cell:mousemove", this.onCellMouseMove, this), this.graph.on("cell:mouseup", this.onCellMouseUp, this), this.selectionImpl.on("box:mousedown", this.onBoxMouseDown, this);
}
stopListening() {
this.graph.off("blank:mousedown", this.onBlankMouseDown, this), this.graph.off("blank:click", this.onBlankClick, this), this.graph.off("cell:mousemove", this.onCellMouseMove, this), this.graph.off("cell:mouseup", this.onCellMouseUp, this), this.selectionImpl.off("box:mousedown", this.onBoxMouseDown, this);
}
onBlankMouseDown({ e: t }) {
if (!this.allowBlankMouseDown(t))
return;
const n = this.graph.panning.allowPanning(t, !0), a = this.graph.getPlugin("scroller"), o = a && a.allowPanning(t, !0);
(this.allowRubberband(t, !0) || this.allowRubberband(t) && !o && !n) && this.startRubberband(t);
}
allowBlankMouseDown(t) {
const n = this.options.eventTypes;
return (n == null ? void 0 : n.includes("leftMouseDown")) && t.button === 0 || (n == null ? void 0 : n.includes("mouseWheelDown")) && t.button === 1;
}
onBlankClick() {
this.clean();
}
allowRubberband(t, n) {
return !this.rubberbandDisabled && tu.isMatch(t, this.options.modifiers, n);
}
allowMultipleSelection(t) {
return this.isMultiple() && tu.isMatch(t, this.options.multipleSelectionModifiers);
}
onCellMouseMove({ cell: t }) {
this.movedMap.set(t, !0);
}
onCellMouseUp({ e: t, cell: n }) {
const a = this.options;
let o = this.disabled;
!o && this.movedMap.has(n) && (o = a.selectCellOnMoved === !1, o || (o = a.selectNodeOnMoved === !1 && n.isNode()), o || (o = a.selectEdgeOnMoved === !1 && n.isEdge())), o || (this.allowMultipleSelection(t) ? this.unselectMap.has(n) ? this.unselectMap.delete(n) : this.isSelected(n) ? this.unselect(n) : this.select(n) : this.reset(n)), this.movedMap.delete(n);
}
onBoxMouseDown({ e: t, cell: n }) {
this.disabled || this.allowMultipleSelection(t) && (this.unselect(n), this.unselectMap.set(n, !0));
}
getCells(t) {
return (Array.isArray(t) ? t : [t]).map((n) => typeof n == "string" ? this.graph.getCellById(n) : n).filter((n) => n != null);
}
startRubberband(t) {
return this.rubberbandDisabled || this.selectionImpl.startSelecting(t), this;
}
isMultiple() {
return this.options.multiple !== !1;
}
enableMultiple() {
return this.options.multiple = !0, this;
}
disableMultiple() {
return this.options.multiple = !1, this;
}
setModifiers(t) {
return this.options.modifiers = t, this;
}
setContent(t) {
return this.selectionImpl.setContent(t), this;
}
setFilter(t) {
return this.selectionImpl.setFilter(t), this;
}
dispose() {
this.stopListening(), this.off(), this.selectionImpl.dispose(), El.clean(this.name);
}
}
Om([
oo.dispose()
], ar.prototype, "dispose", null);
(function(e) {
e.defaultOptions = {
rubberband: !1,