e]; return { path: e, startValue: n.startValue, targetValue: n.targetValue, cell: this.cell }; } } (function(t) { t.defaultOptions = { delay: 10, duration: 100, timing: "linear" }; })(ka || (ka = {})); var gle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }, Yw = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class Pt extends kn { static config(e) { const { markup: n, propHooks: o, attrHooks: s } = e, r = Yw(e, ["markup", "propHooks", "attrHooks"]); n != null && (this.markup = n), o && (this.propHooks = this.propHooks.slice(), Array.isArray(o) ? this.propHooks.push(...o) : typeof o == "function" ? this.propHooks.push(o) : Object.values(o).forEach((i) => { typeof i == "function" && this.propHooks.push(i); })), s && (this.attrHooks = Object.assign(Object.assign({}, this.attrHooks), s)), this.defaults = rn({}, this.defaults, r); } static getMarkup() { return this.markup; } static getDefaults(e) { return e ? this.defaults : Kt(this.defaults); } static getAttrHooks() { return this.attrHooks; } static applyPropHooks(e, n) { return this.propHooks.reduce((o, s) => s ? dt(s, e, o) : o, n); } // #endregion get [Symbol.toStringTag]() { return Pt.toStringTag; } constructor(e = {}) { super(); const o = this.constructor.getDefaults(!0), s = rn({}, this.preprocess(o), this.preprocess(e)); this.id = s.id || zh(), this.store = new Gw(s), this.animation = new ka(this), this.setup(), this.init(), this.postprocess(e); } init() { } // #region model get model() { return this._model; } set model(e) { this._model !== e && (this._model = e); } // #endregion preprocess(e, n) { const o = e.id, r = this.constructor.applyPropHooks(this, e); return o == null && n !== !0 && (r.id = zh()), r; } postprocess(e) { } // eslint-disable-line setup() { this.store.on("change:*", (e) => { const { key: n, current: o, previous: s, options: r } = e; this.notify("change:*", { key: n, options: r, current: o, previous: s, cell: this }), this.notify(`change:${n}`, { options: r, current: o, previous: s, cell: this }); const i = n; (i === "source" || i === "target") && this.notify("change:terminal", { type: i, current: o, previous: s, options: r, cell: this }); }), this.store.on("changed", ({ options: e }) => this.notify("changed", { options: e, cell: this })); } notify(e, n) { this.trigger(e, n); const o = this.model; return o && (o.notify(`cell:${e}`, n), this.isNode() ? o.notify(`node:${e}`, Object.assign(Object.assign({}, n), { node: this })) : this.isEdge() && o.notify(`edge:${e}`, Object.assign(Object.assign({}, n), { edge: this }))), this; } isNode() { return !1; } isEdge() { return !1; } isSameStore(e) { return this.store === e.store; } get view() { return this.store.get("view"); } get shape() { return this.store.get("shape", ""); } getProp(e, n) { return e == null ? this.store.get() : this.store.get(e, n); } setProp(e, n, o) { if (typeof e == "string") this.store.set(e, n, o); else { const s = this.preprocess(e, !0); this.store.set(rn({}, this.getProp(), s), n), this.postprocess(e); } return this; } removeProp(e, n) { return typeof e == "string" || Array.isArray(e) ? this.store.removeByPath(e, n) : this.store.remove(n), this; } hasChanged(e) { return e == null ? this.store.hasChanged() : this.store.hasChanged(e); } getPropByPath(e) { return this.store.getByPath(e); } setPropByPath(e, n, o = {}) { return this.model && (e === "children" ? this._children = n ? n.map((s) => this.model.getCell(s)).filter((s) => s != null) : null : e === "parent" && (this._parent = n ? this.model.getCell(n) : null)), this.store.setByPath(e, n, o), this; } removePropByPath(e, n = {}) { const o = Array.isArray(e) ? e : e.split("/"); return o[0] === "attrs" && (n.dirty = !0), this.store.removeByPath(o, n), this; } prop(e, n, o) { return e == null ? this.getProp() : typeof e == "string" || Array.isArray(e) ? arguments.length === 1 ? this.getPropByPath(e) : n == null ? this.removePropByPath(e, o || {}) : this.setPropByPath(e, n, o || {}) : this.setProp(e, n || {}); } previous(e) { return this.store.getPrevious(e); } // #endregion // #region zIndex get zIndex() { return this.getZIndex(); } set zIndex(e) { e == null ? this.removeZIndex() : this.setZIndex(e); } getZIndex() { return this.store.get("zIndex"); } setZIndex(e, n = {}) { return this.store.set("zIndex", e, n), this; } removeZIndex(e = {}) { return this.store.remove("zIndex", e), this; } toFront(e = {}) { const n = this.model; if (n) { let o = n.getMaxZIndex(), s; e.deep ? (s = this.getDescendants({ deep: !0, breadthFirst: !0 }), s.unshift(this)) : s = [this], o = o - s.length + 1; const r = n.total(); let i = n.indexOf(this) !== r - s.length; i || (i = s.some((l, a) => l.getZIndex() !== o + a)), i && this.batchUpdate("to-front", () => { o += s.length, s.forEach((l, a) => { l.setZIndex(o + a, e); }); }); } return this; } toBack(e = {}) { const n = this.model; if (n) { let o = n.getMinZIndex(), s; e.deep ? (s = this.getDescendants({ deep: !0, breadthFirst: !0 }), s.unshift(this)) : s = [this]; let r = n.indexOf(this) !== 0; r || (r = s.some((i, l) => i.getZIndex() !== o + l)), r && this.batchUpdate("to-back", () => { o -= s.length, s.forEach((i, l) => { i.setZIndex(o + l, e); }); }); } return this; } // #endregion // #region markup get markup() { return this.getMarkup(); } set markup(e) { e == null ? this.removeMarkup() : this.setMarkup(e); } getMarkup() { let e = this.store.get("markup"); return e == null && (e = this.constructor.getMarkup()), e; } setMarkup(e, n = {}) { return this.store.set("markup", e, n), this; } removeMarkup(e = {}) { return this.store.remove("markup", e), this; } // #endregion // #region attrs get attrs() { return this.getAttrs(); } set attrs(e) { e == null ? this.removeAttrs() : this.setAttrs(e); } getAttrs() { const e = this.store.get("attrs"); return e ? Object.assign({}, e) : {}; } setAttrs(e, n = {}) { if (e == null) this.removeAttrs(n); else { const o = (s) => this.store.set("attrs", s, n); if (n.overwrite === !0) o(e); else { const s = this.getAttrs(); n.deep === !1 ? o(Object.assign(Object.assign({}, s), e)) : o(rn({}, s, e)); } } return this; } replaceAttrs(e, n = {}) { return this.setAttrs(e, Object.assign(Object.assign({}, n), { overwrite: !0 })); } updateAttrs(e, n = {}) { return this.setAttrs(e, Object.assign(Object.assign({}, n), { deep: !1 })); } removeAttrs(e = {}) { return this.store.remove("attrs", e), this; } getAttrDefinition(e) { if (!e) return null; const o = this.constructor.getAttrHooks() || {}; let s = o[e] || cs.registry.get(e); if (!s) { const r = ju(e); s = o[r] || cs.registry.get(r); } return s || null; } getAttrByPath(e) { return e == null || e === "" ? this.getAttrs() : this.getPropByPath(this.prefixAttrPath(e)); } setAttrByPath(e, n, o = {}) { return this.setPropByPath(this.prefixAttrPath(e), n, o), this; } removeAttrByPath(e, n = {}) { return this.removePropByPath(this.prefixAttrPath(e), n), this; } prefixAttrPath(e) { return Array.isArray(e) ? ["attrs"].concat(e) : `attrs/${e}`; } attr(e, n, o) { return e == null ? this.getAttrByPath() : typeof e == "string" || Array.isArray(e) ? arguments.length === 1 ? this.getAttrByPath(e) : n == null ? this.removeAttrByPath(e, o || {}) : this.setAttrByPath(e, n, o || {}) : this.setAttrs(e, n || {}); } // #endregion // #region visible get visible() { return this.isVisible(); } set visible(e) { this.setVisible(e); } setVisible(e, n = {}) { return this.store.set("visible", e, n), this; } isVisible() { return this.store.get("visible") !== !1; } show(e = {}) { return this.isVisible() || this.setVisible(!0, e), this; } hide(e = {}) { return this.isVisible() && this.setVisible(!1, e), this; } toggleVisible(e, n = {}) { const o = typeof e == "boolean" ? e : !this.isVisible(), s = typeof e == "boolean" ? n : e; return o ? this.show(s) : this.hide(s), this; } // #endregion // #region data get data() { return this.getData(); } set data(e) { this.setData(e); } getData() { return this.store.get("data"); } setData(e, n = {}) { if (e == null) this.removeData(n); else { const o = (s) => this.store.set("data", s, n); if (n.overwrite === !0) o(e); else { const s = this.getData(); n.deep === !1 ? o(typeof e == "object" ? Object.assign(Object.assign({}, s), e) : e) : o(rn({}, s, e)); } } return this; } replaceData(e, n = {}) { return this.setData(e, Object.assign(Object.assign({}, n), { overwrite: !0 })); } updateData(e, n = {}) { return this.setData(e, Object.assign(Object.assign({}, n), { deep: !1 })); } removeData(e = {}) { return this.store.remove("data", e), this; } // #endregion // #region parent children get parent() { return this.getParent(); } get children() { return this.getChildren(); } getParentId() { return this.store.get("parent"); } getParent() { const e = this.getParentId(); if (e && this.model) { const n = this.model.getCell(e); return this._parent = n, n; } return null; } getChildren() { const e = this.store.get("children"); if (e && e.length && this.model) { const n = e.map((o) => { var s; return (s = this.model) === null || s === void 0 ? void 0 : s.getCell(o); }).filter((o) => o != null); return this._children = n, [...n]; } return null; } hasParent() { return this.parent != null; } isParentOf(e) { return e != null && e.getParent() === this; } isChildOf(e) { return e != null && this.getParent() === e; } eachChild(e, n) { return this.children && this.children.forEach(e, n), this; } filterChild(e, n) { return this.children ? this.children.filter(e, n) : []; } getChildCount() { return this.children == null ? 0 : this.children.length; } getChildIndex(e) { return this.children == null ? -1 : this.children.indexOf(e); } getChildAt(e) { return this.children != null && e >= 0 ? this.children[e] : null; } getAncestors(e = {}) { const n = []; let o = this.getParent(); for (; o; ) n.push(o), o = e.deep !== !1 ? o.getParent() : null; return n; } getDescendants(e = {}) { if (e.deep !== !1) { if (e.breadthFirst) { const n = [], o = this.getChildren() || []; for (; o.length > 0; ) { const s = o.shift(), r = s.getChildren(); n.push(s), r && o.push(...r); } return n; } { const n = this.getChildren() || []; return n.forEach((o) => { n.push(...o.getDescendants(e)); }), n; } } return this.getChildren() || []; } isDescendantOf(e, n = {}) { if (e == null) return !1; if (n.deep !== !1) { let o = this.getParent(); for (; o; ) { if (o === e) return !0; o = o.getParent(); } return !1; } return this.isChildOf(e); } isAncestorOf(e, n = {}) { return e == null ? !1 : e.isDescendantOf(this, n); } contains(e) { return this.isAncestorOf(e); } getCommonAncestor(...e) { return Pt.getCommonAncestor(this, ...e); } setParent(e, n = {}) { return this._parent = e, e ? this.store.set("parent", e.id, n) : this.store.remove("parent", n), this; } setChildren(e, n = {}) { return this._children = e, e != null ? this.store.set("children", e.map((o) => o.id), n) : this.store.remove("children", n), this; } unembed(e, n = {}) { const o = this.children; if (o != null && e != null) { const s = this.getChildIndex(e); s !== -1 && (o.splice(s, 1), e.setParent(null, n), this.setChildren(o, n)); } return this; } embed(e, n = {}) { return e.addTo(this, n), this; } addTo(e, n = {}) { return Pt.isCell(e) ? e.addChild(this, n) : e.addCell(this, n), this; } insertTo(e, n, o = {}) { return e.insertChild(this, n, o), this; } addChild(e, n = {}) { return this.insertChild(e, void 0, n); } insertChild(e, n, o = {}) { if (e != null && e !== this) { const s = e.getParent(), r = this !== s; let i = n; if (i == null && (i = this.getChildCount(), r || (i -= 1)), s) { const a = s.getChildren(); if (a) { const c = a.indexOf(e); c >= 0 && (e.setParent(null, o), a.splice(c, 1), s.setChildren(a, o)); } } let l = this.children; if (l == null ? (l = [], l.push(e)) : l.splice(i, 0, e), e.setParent(this, o), this.setChildren(l, o), r && this.model) { const a = this.model.getIncomingEdges(this), c = this.model.getOutgoingEdges(this); a && a.forEach((u) => u.updateParent(o)), c && c.forEach((u) => u.updateParent(o)); } this.model && this.model.addCell(e, o); } return this; } removeFromParent(e = {}) { const n = this.getParent(); if (n != null) { const o = n.getChildIndex(this); n.removeChildAt(o, e); } return this; } removeChild(e, n = {}) { const o = this.getChildIndex(e); return this.removeChildAt(o, n); } removeChildAt(e, n = {}) { const o = this.getChildAt(e); return this.children != null && o != null && (this.unembed(o, n), o.remove(n)), o; } remove(e = {}) { return this.batchUpdate("remove", () => { const n = this.getParent(); n && n.removeChild(this, e), e.deep !== !1 && this.eachChild((o) => o.remove(e)), this.model && this.model.removeCell(this, e); }), this; } transition(e, n, o = {}, s = "/") { return this.animation.start(e, n, o, s); } stopTransition(e, n, o = "/") { return this.animation.stop(e, n, o), this; } getTransitions() { return this.animation.get(); } // #endregion // #region transform // eslint-disable-next-line translate(e, n, o) { return this; } scale(e, n, o, s) { return this; } addTools(e, n, o) { const s = Array.isArray(e) ? e : [e], r = typeof n == "string" ? n : null, i = typeof n == "object" ? n : typeof o == "object" ? o : {}; if (i.reset) return this.setTools({ name: r, items: s, local: i.local }, i); let l = Kt(this.getTools()); if (l == null || r == null || l.name === r) return l == null && (l = {}), l.items || (l.items = []), l.name = r, l.items = [...l.items, ...s], this.setTools(Object.assign({}, l), i); } setTools(e, n = {}) { return e == null ? this.removeTools() : this.store.set("tools", Pt.normalizeTools(e), n), this; } getTools() { return this.store.get("tools"); } removeTools(e = {}) { return this.store.remove("tools", e), this; } hasTools(e) { const n = this.getTools(); return n == null ? !1 : e == null ? !0 : n.name === e; } hasTool(e) { const n = this.getTools(); return n == null ? !1 : n.items.some((o) => typeof o == "string" ? o === e : o.name === e); } removeTool(e, n = {}) { const o = Kt(this.getTools()); if (o) { let s = !1; const r = o.items.slice(), i = (l) => { r.splice(l, 1), s = !0; }; if (typeof e == "number") i(e); else for (let l = r.length - 1; l >= 0; l -= 1) { const a = r[l]; (typeof a == "string" ? a === e : a.name === e) && i(l); } s && (o.items = r, this.setTools(o, n)); } return this; } // #endregion // #region common // eslint-disable-next-line getBBox(e) { return new Fe(); } // eslint-disable-next-line getConnectionPoint(e, n) { return new te(); } toJSON(e = {}) { const n = Object.assign({}, this.store.get()), o = Object.prototype.toString, s = this.isNode() ? "node" : this.isEdge() ? "edge" : "cell"; if (!n.shape) { const m = this.constructor; throw new Error(`Unable to serialize ${s} missing "shape" prop, check the ${s} "${m.name || o.call(m)}"`); } const r = this.constructor, i = e.diff === !0, l = n.attrs || {}, a = r.getDefaults(!0), c = i ? this.preprocess(a, !0) : a, u = c.attrs || {}, d = {}; Object.entries(n).forEach(([m, g]) => { if (g != null && !Array.isArray(g) && typeof g == "object" && !ds(g)) throw new Error(`Can only serialize ${s} with plain-object props, but got a "${o.call(g)}" type of key "${m}" on ${s} "${this.id}"`); if (m !== "attrs" && m !== "shape" && i) { const v = c[m]; dn(g, v) && delete n[m]; } }), Object.keys(l).forEach((m) => { const g = l[m], v = u[m]; Object.keys(g).forEach((y) => { const w = g[y], b = v ? v[y] : null; w != null && typeof w == "object" && !Array.isArray(w) ? Object.keys(w).forEach((C) => { const S = w[C]; if (v == null || b == null || !hn(b) || !dn(b[C], S)) { d[m] == null && (d[m] = {}), d[m][y] == null && (d[m][y] = {}); const k = d[m][y]; k[C] = S; } }) : (v == null || !dn(b, w)) && (d[m] == null && (d[m] = {}), d[m][y] = w); }); }); const h = Object.assign(Object.assign({}, n), { attrs: Gy(d) ? void 0 : d }); h.attrs == null && delete h.attrs; const p = h; return p.angle === 0 && delete p.angle, Kt(p); } clone(e = {}) { if (!e.deep) { const o = Object.assign({}, this.store.get()); e.keepId || delete o.id, delete o.parent, delete o.children; const s = this.constructor; return new s(o); } return Pt.deepClone(this)[this.id]; } findView(e) { return e.findViewByCell(this); } // #endregion // #region batch startBatch(e, n = {}, o = this.model) { return this.notify("batch:start", { name: e, data: n, cell: this }), o && o.startBatch(e, Object.assign(Object.assign({}, n), { cell: this })), this; } stopBatch(e, n = {}, o = this.model) { return o && o.stopBatch(e, Object.assign(Object.assign({}, n), { cell: this })), this.notify("batch:stop", { name: e, data: n, cell: this }), this; } batchUpdate(e, n, o) { const s = this.model; this.startBatch(e, o, s); const r = n(); return this.stopBatch(e, o, s), r; } // #endregion // #region IDisposable dispose() { this.removeFromParent(), this.store.dispose(); } } Pt.defaults = {}; Pt.attrHooks = {}; Pt.propHooks = []; gle([ kn.dispose() ], Pt.prototype, "dispose", null); (function(t) { function e(n) { return typeof n == "string" ? { items: [n] } : Array.isArray(n) ? { items: n } : n.items ? n : { items: [n] }; } t.normalizeTools = e; })(Pt || (Pt = {})); (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.isNode == "function" && typeof s.isEdge == "function" && typeof s.prop == "function" && typeof s.attr == "function"; } t.isCell = e; })(Pt || (Pt = {})); (function(t) { function e(...r) { const i = r.filter((a) => a != null).map((a) => a.getAncestors()).sort((a, c) => a.length - c.length); return i.shift().find((a) => i.every((c) => c.includes(a))) || null; } t.getCommonAncestor = e; function n(r, i = {}) { let l = null; for (let a = 0, c = r.length; a < c; a += 1) { const u = r[a]; let d = u.getBBox(i); if (d) { if (u.isNode()) { const h = u.getAngle(); h != null && h !== 0 && (d = d.bbox(h)); } l = l == null ? d : l.union(d); } } return l; } t.getCellsBBox = n; function o(r) { const i = [r, ...r.getDescendants({ deep: !0 })]; return t.cloneCells(i); } t.deepClone = o; function s(r) { const i = Jy(r), l = i.reduce((a, c) => (a[c.id] = c.clone(), a), {}); return i.forEach((a) => { const c = l[a.id]; if (c.isEdge()) { const h = c.getSourceCellId(), p = c.getTargetCellId(); h && l[h] && c.setSource(Object.assign(Object.assign({}, c.getSource()), { cell: l[h].id })), p && l[p] && c.setTarget(Object.assign(Object.assign({}, c.getTarget()), { cell: l[p].id })); } const u = a.getParent(); u && l[u.id] && c.setParent(l[u.id]); const d = a.getChildren(); if (d && d.length) { const h = d.reduce((p, m) => (l[m.id] && p.push(l[m.id]), p), []); h.length > 0 && c.setChildren(h); } }), l; } t.cloneCells = s; })(Pt || (Pt = {})); (function(t) { t.config({ propHooks(e) { var { tools: n } = e, o = Yw(e, ["tools"]); return n && (o.tools = t.normalizeTools(n)), o; } }); })(Pt || (Pt = {})); var Xi; (function(t) { let e, n; function o(i, l) { return l ? e != null && e.exist(i) : n != null && n.exist(i); } t.exist = o; function s(i) { e = i; } t.setEdgeRegistry = s; function r(i) { n = i; } t.setNodeRegistry = r; })(Xi || (Xi = {})); class mle { constructor(e) { this.ports = [], this.groups = {}, this.init(Kt(e)); } getPorts() { return this.ports; } getGroup(e) { return e != null ? this.groups[e] : null; } getPortsByGroup(e) { return this.ports.filter((n) => n.group === e || n.group == null && e == null); } getPortsLayoutByGroup(e, n) { const o = this.getPortsByGroup(e), s = e ? this.getGroup(e) : null, r = s ? s.position : null, i = r ? r.name : null; let l; if (i != null) { const d = Tr.registry.get(i); if (d == null) return Tr.registry.onNotFound(i); l = d; } else l = Tr.presets.left; const a = o.map((d) => d && d.position && d.position.args || {}), c = r && r.args || {}; return l(a, n, c).map((d, h) => { const p = o[h]; return { portLayout: d, portId: p.id, portSize: p.size, portAttrs: p.attrs, labelSize: p.label.size, labelLayout: this.getPortLabelLayout(p, te.create(d.position), n) }; }); } init(e) { const { groups: n, items: o } = e; n != null && Object.keys(n).forEach((s) => { this.groups[s] = this.parseGroup(n[s]); }), Array.isArray(o) && o.forEach((s) => { this.ports.push(this.parsePort(s)); }); } parseGroup(e) { return Object.assign(Object.assign({}, e), { label: this.getLabel(e, !0), position: this.getPortPosition(e.position, !0) }); } parsePort(e) { const n = Object.assign({}, e), o = this.getGroup(e.group) || {}; return n.markup = n.markup || o.markup, n.attrs = rn({}, o.attrs, n.attrs), n.position = this.createPosition(o, n), n.label = rn({}, o.label, this.getLabel(n)), n.zIndex = this.getZIndex(o, n), n.size = Object.assign(Object.assign({}, o.size), n.size), n; } getZIndex(e, n) { return typeof n.zIndex == "number" ? n.zIndex : typeof e.zIndex == "number" || e.zIndex === "auto" ? e.zIndex : "auto"; } createPosition(e, n) { return rn({ name: "left", args: {} }, e.position, { args: n.args }); } getPortPosition(e, n = !1) { if (e == null) { if (n) return { name: "left", args: {} }; } else { if (typeof e == "string") return { name: e, args: {} }; if (Array.isArray(e)) return { name: "absolute", args: { x: e[0], y: e[1] } }; if (typeof e == "object") return e; } return { args: {} }; } getPortLabelPosition(e, n = !1) { if (e == null) { if (n) return { name: "left", args: {} }; } else { if (typeof e == "string") return { name: e, args: {} }; if (typeof e == "object") return e; } return { args: {} }; } getLabel(e, n = !1) { const o = e.label || {}; return o.position = this.getPortLabelPosition(o.position, n), o; } getPortLabelLayout(e, n, o) { const s = e.label.position.name || "left", r = e.label.position.args || {}, i = ji.registry.get(s) || ji.presets.left; return i ? i(n, o, r) : null; } } var Td = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; let Cn = class Xw extends Pt { get [Symbol.toStringTag]() { return Xw.toStringTag; } constructor(e = {}) { super(e), this.initPorts(); } preprocess(e, n) { const { x: o, y: s, width: r, height: i } = e, l = Td(e, ["x", "y", "width", "height"]); if (o != null || s != null) { const a = l.position; l.position = Object.assign(Object.assign({}, a), { x: o ?? (a ? a.x : 0), y: s ?? (a ? a.y : 0) }); } if (r != null || i != null) { const a = l.size; l.size = Object.assign(Object.assign({}, a), { width: r ?? (a ? a.width : 0), height: i ?? (a ? a.height : 0) }); } return super.preprocess(l, n); } isNode() { return !0; } size(e, n, o) { return e === void 0 ? this.getSize() : typeof e == "number" ? this.setSize(e, n, o) : this.setSize(e, n); } getSize() { const e = this.store.get("size"); return e ? Object.assign({}, e) : { width: 1, height: 1 }; } setSize(e, n, o) { return typeof e == "object" ? this.resize(e.width, e.height, n) : this.resize(e, n, o), this; } resize(e, n, o = {}) { this.startBatch("resize", o); const s = o.direction; if (s) { const r = this.getSize(); switch (s) { case "left": case "right": n = r.height; break; case "top": case "bottom": e = r.width; break; } let l = { right: 0, "top-right": 0, top: 1, "top-left": 1, left: 2, "bottom-left": 2, bottom: 3, "bottom-right": 3 }[s]; const a = Ut.normalize(this.getAngle() || 0); o.absolute && (l += Math.floor((a + 45) / 90), l %= 4); const c = this.getBBox(); let u; l === 0 ? u = c.getBottomLeft() : l === 1 ? u = c.getCorner() : l === 2 ? u = c.getTopRight() : u = c.getOrigin(); const d = u.clone().rotate(-a, c.getCenter()), h = Math.sqrt(e * e + n * n) / 2; let p = l * Math.PI / 2; p += Math.atan(l % 2 === 0 ? n / e : e / n), p -= Ut.toRad(a); const g = te.fromPolar(h, p, d).clone().translate(e / -2, n / -2); this.store.set("size", { width: e, height: n }, o), this.setPosition(g.x, g.y, o); } else this.store.set("size", { width: e, height: n }, o); return this.stopBatch("resize", o), this; } scale(e, n, o, s = {}) { const r = this.getBBox().scale(e, n, o ?? void 0); return this.startBatch("scale", s), this.setPosition(r.x, r.y, s), this.resize(r.width, r.height, s), this.stopBatch("scale"), this; } position(e, n, o) { return typeof e == "number" ? this.setPosition(e, n, o) : this.getPosition(e); } getPosition(e = {}) { if (e.relative) { const o = this.getParent(); if (o != null && o.isNode()) { const s = this.getPosition(), r = o.getPosition(); return { x: s.x - r.x, y: s.y - r.y }; } } const n = this.store.get("position"); return n ? Object.assign({}, n) : { x: 0, y: 0 }; } setPosition(e, n, o = {}) { let s, r, i; if (typeof e == "object" ? (s = e.x, r = e.y, i = n || {}) : (s = e, r = n, i = o || {}), i.relative) { const l = this.getParent(); if (l != null && l.isNode()) { const a = l.getPosition(); s += a.x, r += a.y; } } if (i.deep) { const l = this.getPosition(); this.translate(s - l.x, r - l.y, i); } else this.store.set("position", { x: s, y: r }, i); return this; } translate(e = 0, n = 0, o = {}) { if (e === 0 && n === 0) return this; o.translateBy = o.translateBy || this.id; const s = this.getPosition(); if (o.restrict != null && o.translateBy === this.id) { const i = this.getBBox({ deep: !0 }), l = o.restrict, a = s.x - i.x, c = s.y - i.y, u = Math.max(l.x + a, Math.min(l.x + l.width + a - i.width, s.x + e)), d = Math.max(l.y + c, Math.min(l.y + l.height + c - i.height, s.y + n)); e = u - s.x, n = d - s.y; } const r = { x: s.x + e, y: s.y + n }; return o.tx = e, o.ty = n, o.transition ? (typeof o.transition != "object" && (o.transition = {}), this.transition("position", r, Object.assign(Object.assign({}, o.transition), { interp: Mr.object })), this.eachChild((i) => { var l; ((l = o.exclude) === null || l === void 0 ? void 0 : l.includes(i)) || i.translate(e, n, o); })) : (this.startBatch("translate", o), this.store.set("position", r, o), this.eachChild((i) => { var l; ((l = o.exclude) === null || l === void 0 ? void 0 : l.includes(i)) || i.translate(e, n, o); }), this.stopBatch("translate", o)), this; } angle(e, n) { return e == null ? this.getAngle() : this.rotate(e, n); } getAngle() { return this.store.get("angle", 0); } rotate(e, n = {}) { const o = this.getAngle(); if (n.center) { const s = this.getSize(), r = this.getPosition(), i = this.getBBox().getCenter(); i.rotate(o - e, n.center); const l = i.x - s.width / 2 - r.x, a = i.y - s.height / 2 - r.y; this.startBatch("rotate", { angle: e, options: n }), this.setPosition(r.x + l, r.y + a, n), this.rotate(e, Object.assign(Object.assign({}, n), { center: null })), this.stopBatch("rotate"); } else this.store.set("angle", n.absolute ? e : (o + e) % 360, n); return this; } // #endregion // #region common getBBox(e = {}) { if (e.deep) { const n = this.getDescendants({ deep: !0, breadthFirst: !0 }); return n.push(this), Pt.getCellsBBox(n); } return Fe.fromPositionAndSize(this.getPosition(), this.getSize()); } getConnectionPoint(e, n) { const o = this.getBBox(), s = o.getCenter(), r = e.getTerminal(n); if (r == null) return s; const i = r.port; if (!i || !this.hasPort(i)) return s; const l = this.getPort(i); if (!l || !l.group) return s; const c = this.getPortsPosition(l.group)[i].position, u = te.create(c).translate(o.getOrigin()), d = this.getAngle(); return d && u.rotate(-d, s), u; } /** * Sets cell's size and position based on the children bbox and given padding. */ fit(e = {}) { const o = (this.getChildren() || []).filter((c) => c.isNode()); if (o.length === 0) return this; this.startBatch("fit-embeds", e), e.deep && o.forEach((c) => c.fit(e)); let { x: s, y: r, width: i, height: l } = Pt.getCellsBBox(o); const a = Lr(e.padding); return s -= a.left, r -= a.top, i += a.left + a.right, l += a.bottom + a.top, this.store.set({ position: { x: s, y: r }, size: { width: i, height: l } }, e), this.stopBatch("fit-embeds"), this; } // #endregion // #region ports get portContainerMarkup() { return this.getPortContainerMarkup(); } set portContainerMarkup(e) { this.setPortContainerMarkup(e); } getDefaultPortContainerMarkup() { return this.store.get("defaultPortContainerMarkup") || en.getPortContainerMarkup(); } getPortContainerMarkup() { return this.store.get("portContainerMarkup") || this.getDefaultPortContainerMarkup(); } setPortContainerMarkup(e, n = {}) { return this.store.set("portContainerMarkup", en.clone(e), n), this; } get portMarkup() { return this.getPortMarkup(); } set portMarkup(e) { this.setPortMarkup(e); } getDefaultPortMarkup() { return this.store.get("defaultPortMarkup") || en.getPortMarkup(); } getPortMarkup() { return this.store.get("portMarkup") || this.getDefaultPortMarkup(); } setPortMarkup(e, n = {}) { return this.store.set("portMarkup", en.clone(e), n), this; } get portLabelMarkup() { return this.getPortLabelMarkup(); } set portLabelMarkup(e) { this.setPortLabelMarkup(e); } getDefaultPortLabelMarkup() { return this.store.get("defaultPortLabelMarkup") || en.getPortLabelMarkup(); } getPortLabelMarkup() { return this.store.get("portLabelMarkup") || this.getDefaultPortLabelMarkup(); } setPortLabelMarkup(e, n = {}) { return this.store.set("portLabelMarkup", en.clone(e), n), this; } get ports() { const e = this.store.get("ports", { items: [] }); return e.items == null && (e.items = []), e; } getPorts() { return Kt(this.ports.items); } getPortsByGroup(e) { return this.getPorts().filter((n) => n.group === e); } getPort(e) { return Kt(this.ports.items.find((n) => n.id && n.id === e)); } getPortAt(e) { return this.ports.items[e] || null; } hasPorts() { return this.ports.items.length > 0; } hasPort(e) { return this.getPortIndex(e) !== -1; } getPortIndex(e) { const n = typeof e == "string" ? e : e.id; return n != null ? this.ports.items.findIndex((o) => o.id === n) : -1; } getPortsPosition(e) { const n = this.getSize(); return this.port.getPortsLayoutByGroup(e, new Fe(0, 0, n.width, n.height)).reduce((s, r) => { const i = r.portLayout; return s[r.portId] = { position: Object.assign({}, i.position), angle: i.angle || 0 }, s; }, {}); } getPortProp(e, n) { return this.getPropByPath(this.prefixPortPath(e, n)); } setPortProp(e, n, o, s) { if (typeof n == "string" || Array.isArray(n)) { const l = this.prefixPortPath(e, n), a = o; return this.setPropByPath(l, a, s); } const r = this.prefixPortPath(e), i = n; return this.setPropByPath(r, i, o); } removePortProp(e, n, o) { return typeof n == "string" || Array.isArray(n) ? this.removePropByPath(this.prefixPortPath(e, n), o) : this.removePropByPath(this.prefixPortPath(e), n); } portProp(e, n, o, s) { return n == null ? this.getPortProp(e) : typeof n == "string" || Array.isArray(n) ? arguments.length === 2 ? this.getPortProp(e, n) : o == null ? this.removePortProp(e, n, s) : this.setPortProp(e, n, o, s) : this.setPortProp(e, n, o); } prefixPortPath(e, n) { const o = this.getPortIndex(e); if (o === -1) throw new Error(`Unable to find port with id: "${e}"`); return n == null || n === "" ? ["ports", "items", `${o}`] : Array.isArray(n) ? ["ports", "items", `${o}`, ...n] : `ports/items/${o}/${n}`; } addPort(e, n) { const o = [...this.ports.items]; return o.push(e), this.setPropByPath("ports/items", o, n), this; } addPorts(e, n) { return this.setPropByPath("ports/items", [...this.ports.items, ...e], n), this; } insertPort(e, n, o) { const s = [...this.ports.items]; return s.splice(e, 0, n), this.setPropByPath("ports/items", s, o), this; } removePort(e, n = {}) { return this.removePortAt(this.getPortIndex(e), n); } removePortAt(e, n = {}) { if (e >= 0) { const o = [...this.ports.items]; o.splice(e, 1), n.rewrite = !0, this.setPropByPath("ports/items", o, n); } return this; } removePorts(e, n) { let o; if (Array.isArray(e)) { if (o = n || {}, e.length) { o.rewrite = !0; const r = [...this.ports.items].filter((i) => !e.some((l) => { const a = typeof l == "string" ? l : l.id; return i.id === a; })); this.setPropByPath("ports/items", r, o); } } else o = e || {}, o.rewrite = !0, this.setPropByPath("ports/items", [], o); return this; } getParsedPorts() { return this.port.getPorts(); } getParsedGroups() { return this.port.groups; } getPortsLayoutByGroup(e, n) { return this.port.getPortsLayoutByGroup(e, n); } initPorts() { this.updatePortData(), this.on("change:ports", () => { this.processRemovedPort(), this.updatePortData(); }); } processRemovedPort() { const e = this.ports, n = {}; e.items.forEach((i) => { i.id && (n[i.id] = !0); }); const o = {}; (this.store.getPrevious("ports") || { items: [] }).items.forEach((i) => { i.id && !n[i.id] && (o[i.id] = !0); }); const r = this.model; r && !Gy(o) && (r.getConnectedEdges(this, { incoming: !0 }).forEach((a) => { const c = a.getTargetPortId(); c && o[c] && a.remove(); }), r.getConnectedEdges(this, { outgoing: !0 }).forEach((a) => { const c = a.getSourcePortId(); c && o[c] && a.remove(); })); } validatePorts() { const e = {}, n = []; return this.ports.items.forEach((o) => { typeof o != "object" && n.push(`Invalid port ${o}.`), o.id == null && (o.id = this.generatePortId()), e[o.id] && n.push("Duplicitied port id."), e[o.id] = !0; }), n; } generatePortId() { return zh(); } updatePortData() { const e = this.validatePorts(); if (e.length > 0) throw this.store.set("ports", this.store.getPrevious("ports")), new Error(e.join(" ")); const n = this.port ? this.port.getPorts() : null; this.port = new mle(this.ports); const o = this.port.getPorts(), s = n ? o.filter((i) => n.find((l) => l.id === i.id) ? null : i) : [...o], r = n ? n.filter((i) => o.find((l) => l.id === i.id) ? null : i) : []; s.length > 0 && this.notify("ports:added", { added: s, cell: this, node: this }), r.length > 0 && this.notify("ports:removed", { removed: r, cell: this, node: this }); } }; Cn.defaults = { angle: 0, position: { x: 0, y: 0 }, size: { width: 1, height: 1 } }; (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.isNode == "function" && typeof s.isEdge == "function" && typeof s.prop == "function" && typeof s.attr == "function" && typeof s.size == "function" && typeof s.position == "function"; } t.isNode = e; })(Cn || (Cn = {})); (function(t) { t.config({ propHooks(e) { var { ports: n } = e, o = Td(e, ["ports"]); return n && (o.ports = Array.isArray(n) ? { items: n } : n), o; } }); })(Cn || (Cn = {})); (function(t) { t.registry = wn.create({ type: "node", process(e, n) { if (Xi.exist(e, !0)) throw new Error(`Node with name '${e}' was registered by anthor Edge`); if (typeof n == "function") return n.config({ shape: e }), n; let o = t; const { inherit: s } = n, r = Td(n, ["inherit"]); if (s) if (typeof s == "string") { const l = this.get(s); l == null ? this.onNotFound(s, "inherited") : o = l; } else o = s; r.constructorName == null && (r.constructorName = e); const i = o.define.call(o, r); return i.config({ shape: e }), i; } }), Xi.setNodeRegistry(t.registry); })(Cn || (Cn = {})); (function(t) { let e = 0; function n(r) { return r ? Ig(r) : (e += 1, `CustomNode${e}`); } function o(r) { const { constructorName: i, overwrite: l } = r, a = Td(r, ["constructorName", "overwrite"]), c = Pg(n(i || a.shape), this); return c.config(a), a.shape && t.registry.register(a.shape, c, l), c; } t.define = o; function s(r) { const i = r.shape || "rect", l = t.registry.get(i); return l ? new l(r) : t.registry.onNotFound(i); } t.create = s; })(Cn || (Cn = {})); var Od = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; let pn = class Zw extends Pt { get [Symbol.toStringTag]() { return Zw.toStringTag; } constructor(e = {}) { super(e); } preprocess(e, n) { const { source: o, sourceCell: s, sourcePort: r, sourcePoint: i, target: l, targetCell: a, targetPort: c, targetPoint: u } = e, h = Od(e, ["source", "sourceCell", "sourcePort", "sourcePoint", "target", "targetCell", "targetPort", "targetPoint"]), p = (m) => typeof m == "string" || typeof m == "number"; if (o != null) if (Pt.isCell(o)) h.source = { cell: o.id }; else if (p(o)) h.source = { cell: o }; else if (te.isPoint(o)) h.source = o.toJSON(); else if (Array.isArray(o)) h.source = { x: o[0], y: o[1] }; else { const m = o.cell; Pt.isCell(m) ? h.source = Object.assign(Object.assign({}, o), { cell: m.id }) : h.source = o; } if (s != null || r != null) { let m = h.source; if (s != null) { const g = p(s) ? s : s.id; m ? m.cell = g : m = h.source = { cell: g }; } r != null && m && (m.port = r); } else i != null && (h.source = te.create(i).toJSON()); if (l != null) if (Pt.isCell(l)) h.target = { cell: l.id }; else if (p(l)) h.target = { cell: l }; else if (te.isPoint(l)) h.target = l.toJSON(); else if (Array.isArray(l)) h.target = { x: l[0], y: l[1] }; else { const m = l.cell; Pt.isCell(m) ? h.target = Object.assign(Object.assign({}, l), { cell: m.id }) : h.target = l; } if (a != null || c != null) { let m = h.target; if (a != null) { const g = p(a) ? a : a.id; m ? m.cell = g : m = h.target = { cell: g }; } c != null && m && (m.port = c); } else u != null && (h.target = te.create(u).toJSON()); return super.preprocess(h, n); } setup() { super.setup(), this.on("change:labels", (e) => this.onLabelsChanged(e)), this.on("change:vertices", (e) => this.onVertexsChanged(e)); } isEdge() { return !0; } // #region terminal disconnect(e = {}) { return this.store.set({ source: { x: 0, y: 0 }, target: { x: 0, y: 0 } }, e), this; } get source() { return this.getSource(); } set source(e) { this.setSource(e); } getSource() { return this.getTerminal("source"); } getSourceCellId() { return this.source.cell; } getSourcePortId() { return this.source.port; } setSource(e, n, o = {}) { return this.setTerminal("source", e, n, o); } get target() { return this.getTarget(); } set target(e) { this.setTarget(e); } getTarget() { return this.getTerminal("target"); } getTargetCellId() { return this.target.cell; } getTargetPortId() { return this.target.port; } setTarget(e, n, o = {}) { return this.setTerminal("target", e, n, o); } getTerminal(e) { return Object.assign({}, this.store.get(e)); } setTerminal(e, n, o, s = {}) { if (Pt.isCell(n)) return this.store.set(e, rn({}, o, { cell: n.id }), s), this; const r = n; return te.isPoint(n) || r.x != null && r.y != null ? (this.store.set(e, rn({}, o, { x: r.x, y: r.y }), s), this) : (this.store.set(e, Kt(n), s), this); } getSourcePoint() { return this.getTerminalPoint("source"); } getTargetPoint() { return this.getTerminalPoint("target"); } getTerminalPoint(e) { const n = this[e]; if (te.isPointLike(n)) return te.create(n); const o = this.getTerminalCell(e); return o ? o.getConnectionPoint(this, e) : new te(); } getSourceCell() { return this.getTerminalCell("source"); } getTargetCell() { return this.getTerminalCell("target"); } getTerminalCell(e) { if (this.model) { const n = e === "source" ? this.getSourceCellId() : this.getTargetCellId(); if (n) return this.model.getCell(n); } return null; } getSourceNode() { return this.getTerminalNode("source"); } getTargetNode() { return this.getTerminalNode("target"); } getTerminalNode(e) { let n = this; const o = {}; for (; n && n.isEdge(); ) { if (o[n.id]) return null; o[n.id] = !0, n = n.getTerminalCell(e); } return n && n.isNode() ? n : null; } // #endregion // #region router get router() { return this.getRouter(); } set router(e) { e == null ? this.removeRouter() : this.setRouter(e); } getRouter() { return this.store.get("router"); } setRouter(e, n, o) { return typeof e == "object" ? this.store.set("router", e, n) : this.store.set("router", { name: e, args: n }, o), this; } removeRouter(e = {}) { return this.store.remove("router", e), this; } // #endregion // #region connector get connector() { return this.getConnector(); } set connector(e) { e == null ? this.removeConnector() : this.setConnector(e); } getConnector() { return this.store.get("connector"); } setConnector(e, n, o) { return typeof e == "object" ? this.store.set("connector", e, n) : this.store.set("connector", { name: e, args: n }, o), this; } removeConnector(e = {}) { return this.store.remove("connector", e); } // #endregion // #region labels getDefaultLabel() { const e = this.constructor, n = this.store.get("defaultLabel") || e.defaultLabel || {}; return Kt(n); } get labels() { return this.getLabels(); } set labels(e) { this.setLabels(e); } getLabels() { return [...this.store.get("labels", [])].map((e) => this.parseLabel(e)); } setLabels(e, n = {}) { return this.store.set("labels", Array.isArray(e) ? e : [e], n), this; } insertLabel(e, n, o = {}) { const s = this.getLabels(), r = s.length; let i = n != null && Number.isFinite(n) ? n : r; return i < 0 && (i = r + i + 1), s.splice(i, 0, this.parseLabel(e)), this.setLabels(s, o); } appendLabel(e, n = {}) { return this.insertLabel(e, -1, n); } getLabelAt(e) { const n = this.getLabels(); return e != null && Number.isFinite(e) ? this.parseLabel(n[e]) : null; } setLabelAt(e, n, o = {}) { if (e != null && Number.isFinite(e)) { const s = this.getLabels(); s[e] = this.parseLabel(n), this.setLabels(s, o); } return this; } removeLabelAt(e, n = {}) { const o = this.getLabels(), s = e != null && Number.isFinite(e) ? e : -1, r = o.splice(s, 1); return this.setLabels(o, n), r.length ? r[0] : null; } parseLabel(e) { return typeof e == "string" ? this.constructor.parseStringLabel(e) : e; } onLabelsChanged({ previous: e, current: n }) { const o = e && n ? n.filter((r) => e.find((i) => r === i || dn(r, i)) ? null : r) : n ? [...n] : [], s = e && n ? e.filter((r) => n.find((i) => r === i || dn(r, i)) ? null : r) : e ? [...e] : []; o.length > 0 && this.notify("labels:added", { added: o, cell: this, edge: this }), s.length > 0 && this.notify("labels:removed", { removed: s, cell: this, edge: this }); } // #endregion // #region vertices get vertices() { return this.getVertices(); } set vertices(e) { this.setVertices(e); } getVertices() { return [...this.store.get("vertices", [])]; } setVertices(e, n = {}) { const o = Array.isArray(e) ? e : [e]; return this.store.set("vertices", o.map((s) => te.toJSON(s)), n), this; } insertVertex(e, n, o = {}) { const s = this.getVertices(), r = s.length; let i = n != null && Number.isFinite(n) ? n : r; return i < 0 && (i = r + i + 1), s.splice(i, 0, te.toJSON(e)), this.setVertices(s, o); } appendVertex(e, n = {}) { return this.insertVertex(e, -1, n); } getVertexAt(e) { return e != null && Number.isFinite(e) ? this.getVertices()[e] : null; } setVertexAt(e, n, o = {}) { if (e != null && Number.isFinite(e)) { const s = this.getVertices(); s[e] = n, this.setVertices(s, o); } return this; } removeVertexAt(e, n = {}) { const o = this.getVertices(), s = e != null && Number.isFinite(e) ? e : -1; return o.splice(s, 1), this.setVertices(o, n); } onVertexsChanged({ previous: e, current: n }) { const o = e && n ? n.filter((r) => e.find((i) => te.equals(r, i)) ? null : r) : n ? [...n] : [], s = e && n ? e.filter((r) => n.find((i) => te.equals(r, i)) ? null : r) : e ? [...e] : []; o.length > 0 && this.notify("vertexs:added", { added: o, cell: this, edge: this }), s.length > 0 && this.notify("vertexs:removed", { removed: s, cell: this, edge: this }); } // #endregion // #region markup getDefaultMarkup() { return this.store.get("defaultMarkup") || en.getEdgeMarkup(); } getMarkup() { return super.getMarkup() || this.getDefaultMarkup(); } // #endregion // #region transform /** * Translate the edge vertices (and source and target if they are points) * by `tx` pixels in the x-axis and `ty` pixels in the y-axis. */ translate(e, n, o = {}) { return o.translateBy = o.translateBy || this.id, o.tx = e, o.ty = n, this.applyToPoints((s) => ({ x: (s.x || 0) + e, y: (s.y || 0) + n }), o); } /** * Scales the edge's points (vertices) relative to the given origin. */ scale(e, n, o, s = {}) { return this.applyToPoints((r) => te.create(r).scale(e, n, o).toJSON(), s); } applyToPoints(e, n = {}) { const o = {}, s = this.getSource(), r = this.getTarget(); te.isPointLike(s) && (o.source = e(s)), te.isPointLike(r) && (o.target = e(r)); const i = this.getVertices(); return i.length > 0 && (o.vertices = i.map(e)), this.store.set(o, n), this; } // #endregion // #region common getBBox() { return this.getPolyline().bbox(); } getConnectionPoint() { return this.getPolyline().pointAt(0.5); } getPolyline() { const e = [ this.getSourcePoint(), ...this.getVertices().map((n) => te.create(n)), this.getTargetPoint() ]; return new mn(e); } updateParent(e) { let n = null; const o = this.getSourceCell(), s = this.getTargetCell(), r = this.getParent(); return o && s && (o === s || o.isDescendantOf(s) ? n = s : s.isDescendantOf(o) ? n = o : n = Pt.getCommonAncestor(o, s)), r && (!n || n.id !== r.id) && r.unembed(this, e), n && n.embed(this, e), n; } hasLoop(e = {}) { const n = this.getSource(), o = this.getTarget(), s = n.cell, r = o.cell; if (!s || !r) return !1; let i = s === r; if (!i && e.deep && this._model) { const l = this.getSourceCell(), a = this.getTargetCell(); l && a && (i = l.isAncestorOf(a, e) || a.isAncestorOf(l, e)); } return i; } getFragmentAncestor() { const e = [this, this.getSourceNode(), this.getTargetNode()].filter((n) => n != null); return this.getCommonAncestor(...e); } isFragmentDescendantOf(e) { const n = this.getFragmentAncestor(); return !!n && (n.id === e.id || n.isDescendantOf(e)); } }; pn.defaults = {}; (function(t) { function e(n, o) { const s = n, r = o; return s.cell === r.cell ? s.port === r.port || s.port == null && r.port == null : !1; } t.equalTerminals = e; })(pn || (pn = {})); (function(t) { t.defaultLabel = { markup: [ { tagName: "rect", selector: "body" }, { tagName: "text", selector: "label" } ], attrs: { text: { fill: "#000", fontSize: 14, textAnchor: "middle", textVerticalAnchor: "middle", pointerEvents: "none" }, rect: { ref: "label", fill: "#fff", rx: 3, ry: 3, refWidth: 1, refHeight: 1, refX: 0, refY: 0 } }, position: { distance: 0.5 } }; function e(n) { return { attrs: { label: { text: n } } }; } t.parseStringLabel = e; })(pn || (pn = {})); (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.isNode == "function" && typeof s.isEdge == "function" && typeof s.prop == "function" && typeof s.attr == "function" && typeof s.disconnect == "function" && typeof s.getSource == "function" && typeof s.getTarget == "function"; } t.isEdge = e; })(pn || (pn = {})); (function(t) { t.registry = wn.create({ type: "edge", process(e, n) { if (Xi.exist(e, !1)) throw new Error(`Edge with name '${e}' was registered by anthor Node`); if (typeof n == "function") return n.config({ shape: e }), n; let o = t; const { inherit: s = "edge" } = n, r = Od(n, ["inherit"]); if (typeof s == "string") { const l = this.get(s || "edge"); l == null && s ? this.onNotFound(s, "inherited") : o = l; } else o = s; r.constructorName == null && (r.constructorName = e); const i = o.define.call(o, r); return i.config({ shape: e }), i; } }), Xi.setEdgeRegistry(t.registry); })(pn || (pn = {})); (function(t) { let e = 0; function n(r) { return r ? Ig(r) : (e += 1, `CustomEdge${e}`); } function o(r) { const { constructorName: i, overwrite: l } = r, a = Od(r, ["constructorName", "overwrite"]), c = Pg(n(i || a.shape), this); return c.config(a), a.shape && t.registry.register(a.shape, c, l), c; } t.define = o; function s(r) { const i = r.shape || "edge", l = t.registry.get(i); return l ? new l(r) : t.registry.onNotFound(i); } t.create = s; })(pn || (pn = {})); (function(t) { const e = "basic.edge"; t.config({ shape: e, propHooks(n) { const { label: o, vertices: s } = n, r = Od(n, ["label", "vertices"]); if (o) { r.labels == null && (r.labels = []); const i = typeof o == "string" ? t.parseStringLabel(o) : o; r.labels.push(i); } return s && Array.isArray(s) && (r.vertices = s.map((i) => te.create(i).toJSON())), r; } }), t.registry.register(e, t); })(pn || (pn = {})); class Jw extends kn { constructor(e, n = {}) { super(), this.length = 0, this.comparator = n.comparator || "zIndex", this.clean(), e && this.reset(e, { silent: !0 }); } toJSON() { return this.cells.map((e) => e.toJSON()); } add(e, n, o) { let s, r; typeof n == "number" ? (s = n, r = Object.assign({ merge: !1 }, o)) : (s = this.length, r = Object.assign({ merge: !1 }, n)), s > this.length && (s = this.length), s < 0 && (s += this.length + 1); const i = Array.isArray(e) ? e : [e], l = this.comparator && typeof n != "number" && r.sort !== !1, a = this.comparator || null; let c = !1; const u = [], d = []; return i.forEach((h) => { const p = this.get(h); p ? r.merge && !h.isSameStore(p) && (p.setProp(h.getProp(), o), d.push(p), l && !c && (a == null || typeof a == "function" ? c = p.hasChanged() : typeof a == "string" ? c = p.hasChanged(a) : c = a.some((m) => p.hasChanged(m)))) : (u.push(h), this.reference(h)); }), u.length && (l && (c = !0), this.cells.splice(s, 0, ...u), this.length = this.cells.length), c && this.sort({ silent: !0 }), r.silent || (u.forEach((h, p) => { const m = { cell: h, index: s + p, options: r }; this.trigger("added", m), r.dryrun || h.notify("added", Object.assign({}, m)); }), c && this.trigger("sorted"), (u.length || d.length) && this.trigger("updated", { added: u, merged: d, removed: [], options: r })), this; } remove(e, n = {}) { const o = Array.isArray(e) ? e : [e], s = this.removeCells(o, n); return !n.silent && s.length > 0 && this.trigger("updated", { options: n, removed: s, added: [], merged: [] }), Array.isArray(e) ? s : s[0]; } removeCells(e, n) { const o = []; for (let s = 0; s < e.length; s += 1) { const r = this.get(e[s]); if (r == null) continue; const i = this.cells.indexOf(r); this.cells.splice(i, 1), this.length -= 1, delete this.map[r.id], o.push(r), this.unreference(r), n.dryrun || r.remove(), n.silent || (this.trigger("removed", { cell: r, index: i, options: n }), n.dryrun || r.notify("removed", { cell: r, index: i, options: n })); } return o; } reset(e, n = {}) { const o = this.cells.slice(); if (o.forEach((s) => this.unreference(s)), this.clean(), this.add(e, Object.assign({ silent: !0 }, n)), !n.silent) { const s = this.cells.slice(); this.trigger("reseted", { options: n, previous: o, current: s }); const r = [], i = []; s.forEach((l) => { o.some((c) => c.id === l.id) || r.push(l); }), o.forEach((l) => { s.some((c) => c.id === l.id) || i.push(l); }), this.trigger("updated", { options: n, added: r, removed: i, merged: [] }); } return this; } push(e, n) { return this.add(e, this.length, n); } pop(e) { const n = this.at(this.length - 1); return this.remove(n, e); } unshift(e, n) { return this.add(e, 0, n); } shift(e) { const n = this.at(0); return this.remove(n, e); } get(e) { if (e == null) return null; const n = typeof e == "string" || typeof e == "number" ? e : e.id; return this.map[n] || null; } has(e) { return this.get(e) != null; } at(e) { return e < 0 && (e += this.length), this.cells[e] || null; } first() { return this.at(0); } last() { return this.at(-1); } indexOf(e) { return this.cells.indexOf(e); } toArray() { return this.cells.slice(); } sort(e = {}) { return this.comparator != null && (this.cells = vp(this.cells, this.comparator), e.silent || this.trigger("sorted")), this; } clone() { const e = this.constructor; return new e(this.cells.slice(), { comparator: this.comparator }); } reference(e) { this.map[e.id] = e, e.on("*", this.notifyCellEvent, this); } unreference(e) { e.off("*", this.notifyCellEvent, this), delete this.map[e.id]; } notifyCellEvent(e, n) { const o = n.cell; this.trigger(`cell:${e}`, n), o && (o.isNode() ? this.trigger(`node:${e}`, Object.assign(Object.assign({}, n), { node: o })) : o.isEdge() && this.trigger(`edge:${e}`, Object.assign(Object.assign({}, n), { edge: o }))); } clean() { this.length = 0, this.cells = [], this.map = {}; } } class To extends kn { get [Symbol.toStringTag]() { return To.toStringTag; } constructor(e = []) { super(), this.batches = {}, this.addings = /* @__PURE__ */ new WeakMap(), this.nodes = {}, this.edges = {}, this.outgoings = {}, this.incomings = {}, this.collection = new Jw(e), this.setup(); } notify(e, n) { this.trigger(e, n); const o = this.graph; return o && (e === "sorted" || e === "reseted" || e === "updated" ? o.trigger(`model:${e}`, n) : o.trigger(e, n)), this; } setup() { const e = this.collection; e.on("sorted", () => this.notify("sorted", null)), e.on("updated", (n) => this.notify("updated", n)), e.on("cell:change:zIndex", () => this.sortOnChangeZ()), e.on("added", ({ cell: n }) => { this.onCellAdded(n); }), e.on("removed", (n) => { const o = n.cell; this.onCellRemoved(o, n.options), this.notify("cell:removed", n), o.isNode() ? this.notify("node:removed", Object.assign(Object.assign({}, n), { node: o })) : o.isEdge() && this.notify("edge:removed", Object.assign(Object.assign({}, n), { edge: o })); }), e.on("reseted", (n) => { this.onReset(n.current), this.notify("reseted", n); }), e.on("edge:change:source", ({ edge: n }) => this.onEdgeTerminalChanged(n, "source")), e.on("edge:change:target", ({ edge: n }) => { this.onEdgeTerminalChanged(n, "target"); }); } sortOnChangeZ() { this.collection.sort(); } onCellAdded(e) { const n = e.id; e.isEdge() ? (e.updateParent(), this.edges[n] = !0, this.onEdgeTerminalChanged(e, "source"), this.onEdgeTerminalChanged(e, "target")) : this.nodes[n] = !0; } onCellRemoved(e, n) { const o = e.id; if (e.isEdge()) { delete this.edges[o]; const s = e.getSource(), r = e.getTarget(); if (s && s.cell) { const i = this.outgoings[s.cell], l = i ? i.indexOf(o) : -1; l >= 0 && (i.splice(l, 1), i.length === 0 && delete this.outgoings[s.cell]); } if (r && r.cell) { const i = this.incomings[r.cell], l = i ? i.indexOf(o) : -1; l >= 0 && (i.splice(l, 1), i.length === 0 && delete this.incomings[r.cell]); } } else delete this.nodes[o]; n.clear || (n.disconnectEdges ? this.disconnectConnectedEdges(e, n) : this.removeConnectedEdges(e, n)), e.model === this && (e.model = null); } onReset(e) { this.nodes = {}, this.edges = {}, this.outgoings = {}, this.incomings = {}, e.forEach((n) => this.onCellAdded(n)); } onEdgeTerminalChanged(e, n) { const o = n === "source" ? this.outgoings : this.incomings, s = e.previous(n); if (s && s.cell) { const i = Pt.isCell(s.cell) ? s.cell.id : s.cell, l = o[i], a = l ? l.indexOf(e.id) : -1; a >= 0 && (l.splice(a, 1), l.length === 0 && delete o[i]); } const r = e.getTerminal(n); if (r && r.cell) { const i = Pt.isCell(r.cell) ? r.cell.id : r.cell, l = o[i] || []; l.indexOf(e.id) === -1 && l.push(e.id), o[i] = l; } } prepareCell(e, n) { return !e.model && (!n || !n.dryrun) && (e.model = this), e.zIndex == null && e.setZIndex(this.getMaxZIndex() + 1, { silent: !0 }), e; } resetCells(e, n = {}) { return e.map((o) => this.prepareCell(o, Object.assign(Object.assign({}, n), { dryrun: !0 }))), this.collection.reset(e, n), e.map((o) => this.prepareCell(o, { options: n })), this; } clear(e = {}) { const n = this.getCells(); if (n.length === 0) return this; const o = Object.assign(Object.assign({}, e), { clear: !0 }); return this.batchUpdate("clear", () => { const s = n.sort((r, i) => { const l = r.isEdge() ? 1 : 2, a = i.isEdge() ? 1 : 2; return l - a; }); for (; s.length > 0; ) { const r = s.shift(); r && r.remove(o); } }, o), this; } addNode(e, n = {}) { const o = Cn.isNode(e) ? e : this.createNode(e); return this.addCell(o, n), o; } updateNode(e, n = {}) { const o = this.createNode(e), s = o.getProp(); return o.dispose(), this.updateCell(s, n); } createNode(e) { return Cn.create(e); } addEdge(e, n = {}) { const o = pn.isEdge(e) ? e : this.createEdge(e); return this.addCell(o, n), o; } createEdge(e) { return pn.create(e); } updateEdge(e, n = {}) { const o = this.createEdge(e), s = o.getProp(); return o.dispose(), this.updateCell(s, n); } addCell(e, n = {}) { return Array.isArray(e) ? this.addCells(e, n) : (!this.collection.has(e) && !this.addings.has(e) && (this.addings.set(e, !0), this.collection.add(this.prepareCell(e, n), n), e.eachChild((o) => this.addCell(o, n)), this.addings.delete(e)), this); } addCells(e, n = {}) { const o = e.length; if (o === 0) return this; const s = Object.assign(Object.assign({}, n), { position: o - 1, maxPosition: o - 1 }); return this.startBatch("add", Object.assign(Object.assign({}, s), { cells: e })), e.forEach((r) => { this.addCell(r, s), s.position -= 1; }), this.stopBatch("add", Object.assign(Object.assign({}, s), { cells: e })), this; } updateCell(e, n = {}) { const o = e.id && this.getCell(e.id); return o ? this.batchUpdate("update", () => (Object.entries(e).forEach(([s, r]) => o.setProp(s, r, n)), !0), e) : !1; } removeCell(e, n = {}) { const o = typeof e == "string" ? this.getCell(e) : e; return o && this.has(o) ? this.collection.remove(o, n) : null; } updateCellId(e, n) { this.startBatch("update", { id: n }), e.prop("id", n); const o = e.clone({ keepId: !0 }); return this.addCell(o), this.getConnectedEdges(e).forEach((r) => { const i = r.getSourceCell(), l = r.getTargetCell(); i === e && r.setSource(Object.assign(Object.assign({}, r.getSource()), { cell: n })), l === e && r.setTarget(Object.assign(Object.assign({}, r.getTarget()), { cell: n })); }), this.removeCell(e), this.stopBatch("update", { id: n }), o; } removeCells(e, n = {}) { return e.length ? this.batchUpdate("remove", () => e.map((o) => this.removeCell(o, n))) : []; } removeConnectedEdges(e, n = {}) { const o = this.getConnectedEdges(e); return o.forEach((s) => { s.remove(n); }), o; } disconnectConnectedEdges(e, n = {}) { const o = typeof e == "string" ? e : e.id; this.getConnectedEdges(e).forEach((s) => { const r = s.getSourceCellId(), i = s.getTargetCellId(); r === o && s.setSource({ x: 0, y: 0 }, n), i === o && s.setTarget({ x: 0, y: 0 }, n); }); } has(e) { return this.collection.has(e); } total() { return this.collection.length; } indexOf(e) { return this.collection.indexOf(e); } /** * Returns a cell from the graph by its id. */ getCell(e) { return this.collection.get(e); } /** * Returns all the nodes and edges in the graph. */ getCells() { return this.collection.toArray(); } /** * Returns the first cell (node or edge) in the graph. The first cell is * defined as the cell with the lowest `zIndex`. */ getFirstCell() { return this.collection.first(); } /** * Returns the last cell (node or edge) in the graph. The last cell is * defined as the cell with the highest `zIndex`. */ getLastCell() { return this.collection.last(); } /** * Returns the lowest `zIndex` value in the graph. */ getMinZIndex() { const e = this.collection.first(); return e && e.getZIndex() || 0; } /** * Returns the highest `zIndex` value in the graph. */ getMaxZIndex() { const e = this.collection.last(); return e && e.getZIndex() || 0; } getCellsFromCache(e) { return e ? Object.keys(e).map((n) => this.getCell(n)).filter((n) => n != null) : []; } /** * Returns all the nodes in the graph. */ getNodes() { return this.getCellsFromCache(this.nodes); } /** * Returns all the edges in the graph. */ getEdges() { return this.getCellsFromCache(this.edges); } /** * Returns all outgoing edges for the node. */ getOutgoingEdges(e) { const n = typeof e == "string" ? e : e.id, o = this.outgoings[n]; return o ? o.map((s) => this.getCell(s)).filter((s) => s && s.isEdge()) : null; } /** * Returns all incoming edges for the node. */ getIncomingEdges(e) { const n = typeof e == "string" ? e : e.id, o = this.incomings[n]; return o ? o.map((s) => this.getCell(s)).filter((s) => s && s.isEdge()) : null; } /** * Returns edges connected with cell. */ getConnectedEdges(e, n = {}) { const o = [], s = typeof e == "string" ? this.getCell(e) : e; if (s == null) return o; const r = {}, i = n.indirect; let l = n.incoming, a = n.outgoing; l == null && a == null && (l = a = !0); const c = (u, d) => { const h = d ? this.getOutgoingEdges(u) : this.getIncomingEdges(u); if (h != null && h.forEach((p) => { r[p.id] || (o.push(p), r[p.id] = !0, i && (l && c(p, !1), a && c(p, !0))); }), i && u.isEdge()) { const p = d ? u.getTargetCell() : u.getSourceCell(); p && p.isEdge() && (r[p.id] || (o.push(p), c(p, d))); } }; if (a && c(s, !0), l && c(s, !1), n.deep) { const u = s.getDescendants({ deep: !0 }), d = {}; u.forEach((p) => { p.isNode() && (d[p.id] = !0); }); const h = (p, m) => { const g = m ? this.getOutgoingEdges(p.id) : this.getIncomingEdges(p.id); g != null && g.forEach((v) => { if (!r[v.id]) { const y = v.getSourceCell(), w = v.getTargetCell(); if (!n.enclosed && y && d[y.id] && w && d[w.id]) return; o.push(v), r[v.id] = !0; } }); }; u.forEach((p) => { p.isEdge() || (a && h(p, !0), l && h(p, !1)); }); } return o; } isBoundary(e, n) { const o = typeof e == "string" ? this.getCell(e) : e, s = n ? this.getIncomingEdges(o) : this.getOutgoingEdges(o); return s == null || s.length === 0; } getBoundaryNodes(e) { const n = []; return Object.keys(this.nodes).forEach((o) => { if (this.isBoundary(o, e)) { const s = this.getCell(o); s && n.push(s); } }), n; } /** * Returns an array of all the roots of the graph. */ getRoots() { return this.getBoundaryNodes(!0); } /** * Returns an array of all the leafs of the graph. */ getLeafs() { return this.getBoundaryNodes(!1); } /** * Returns `true` if the node is a root node, i.e. there is no edges * coming to the node. */ isRoot(e) { return this.isBoundary(e, !0); } /** * Returns `true` if the node is a leaf node, i.e. there is no edges * going out from the node. */ isLeaf(e) { return this.isBoundary(e, !1); } /** * Returns all the neighbors of node in the graph. Neighbors are all * the nodes connected to node via either incoming or outgoing edge. */ getNeighbors(e, n = {}) { let o = n.incoming, s = n.outgoing; o == null && s == null && (o = s = !0); const i = this.getConnectedEdges(e, n).reduce((l, a) => { const c = a.hasLoop(n), u = a.getSourceCell(), d = a.getTargetCell(); return o && u && u.isNode() && !l[u.id] && (c || u !== e && (!n.deep || !u.isDescendantOf(e))) && (l[u.id] = u), s && d && d.isNode() && !l[d.id] && (c || d !== e && (!n.deep || !d.isDescendantOf(e))) && (l[d.id] = d), l; }, {}); if (e.isEdge()) { if (o) { const l = e.getSourceCell(); l && l.isNode() && !i[l.id] && (i[l.id] = l); } if (s) { const l = e.getTargetCell(); l && l.isNode() && !i[l.id] && (i[l.id] = l); } } return Object.keys(i).map((l) => i[l]); } /** * Returns `true` if `cell2` is a neighbor of `cell1`. */ isNeighbor(e, n, o = {}) { let s = o.incoming, r = o.outgoing; return s == null && r == null && (s = r = !0), this.getConnectedEdges(e, o).some((i) => { const l = i.getSourceCell(), a = i.getTargetCell(); return !!(s && l && l.id === n.id || r && a && a.id === n.id); }); } getSuccessors(e, n = {}) { const o = []; return this.search(e, (s, r) => { s !== e && this.matchDistance(r, n.distance) && o.push(s); }, Object.assign(Object.assign({}, n), { outgoing: !0 })), o; } /** * Returns `true` if `cell2` is a successor of `cell1`. */ isSuccessor(e, n, o = {}) { let s = !1; return this.search(e, (r, i) => { if (r === n && r !== e && this.matchDistance(i, o.distance)) return s = !0, !1; }, Object.assign(Object.assign({}, o), { outgoing: !0 })), s; } getPredecessors(e, n = {}) { const o = []; return this.search(e, (s, r) => { s !== e && this.matchDistance(r, n.distance) && o.push(s); }, Object.assign(Object.assign({}, n), { incoming: !0 })), o; } /** * Returns `true` if `cell2` is a predecessor of `cell1`. */ isPredecessor(e, n, o = {}) { let s = !1; return this.search(e, (r, i) => { if (r === n && r !== e && this.matchDistance(i, o.distance)) return s = !0, !1; }, Object.assign(Object.assign({}, o), { incoming: !0 })), s; } matchDistance(e, n) { return n == null ? !0 : typeof n == "function" ? n(e) : Array.isArray(n) && n.includes(e) ? !0 : e === n; } /** * Returns the common ancestor of the passed cells. */ getCommonAncestor(...e) { const n = []; return e.forEach((o) => { o && (Array.isArray(o) ? n.push(...o) : n.push(o)); }), Pt.getCommonAncestor(...n); } /** * Returns an array of cells that result from finding nodes/edges that * are connected to any of the cells in the cells array. This function * loops over cells and if the current cell is a edge, it collects its * source/target nodes; if it is an node, it collects its incoming and * outgoing edges if both the edge terminal (source/target) are in the * cells array. */ getSubGraph(e, n = {}) { const o = [], s = {}, r = [], i = [], l = (a) => { s[a.id] || (o.push(a), s[a.id] = a, a.isEdge() && i.push(a), a.isNode() && r.push(a)); }; return e.forEach((a) => { l(a), n.deep && a.getDescendants({ deep: !0 }).forEach((u) => l(u)); }), i.forEach((a) => { const c = a.getSourceCell(), u = a.getTargetCell(); c && !s[c.id] && (o.push(c), s[c.id] = c, c.isNode() && r.push(c)), u && !s[u.id] && (o.push(u), s[u.id] = u, u.isNode() && r.push(u)); }), r.forEach((a) => { this.getConnectedEdges(a, n).forEach((u) => { const d = u.getSourceCell(), h = u.getTargetCell(); !s[u.id] && d && s[d.id] && h && s[h.id] && (o.push(u), s[u.id] = u); }); }), o; } /** * Clones the whole subgraph (including all the connected links whose * source/target is in the subgraph). If `options.deep` is `true`, also * take into account all the embedded cells of all the subgraph cells. * * Returns a map of the form: { [original cell ID]: [clone] }. */ cloneSubGraph(e, n = {}) { const o = this.getSubGraph(e, n); return this.cloneCells(o); } cloneCells(e) { return Pt.cloneCells(e); } getNodesFromPoint(e, n) { const o = typeof e == "number" ? { x: e, y: n || 0 } : e; return this.getNodes().filter((s) => s.getBBox().containsPoint(o)); } getNodesInArea(e, n, o, s, r) { const i = typeof e == "number" ? new Fe(e, n, o, s) : Fe.create(e), l = typeof e == "number" ? r : n, a = l && l.strict; return this.getNodes().filter((c) => { const u = c.getBBox(); return a ? i.containsRect(u) : i.isIntersectWithRect(u); }); } getEdgesInArea(e, n, o, s, r) { const i = typeof e == "number" ? new Fe(e, n, o, s) : Fe.create(e), l = typeof e == "number" ? r : n, a = l && l.strict; return this.getEdges().filter((c) => { const u = c.getBBox(); return u.width === 0 ? u.inflate(1, 0) : u.height === 0 && u.inflate(0, 1), a ? i.containsRect(u) : i.isIntersectWithRect(u); }); } getNodesUnderNode(e, n = {}) { const o = e.getBBox(); return (n.by == null || n.by === "bbox" ? this.getNodesInArea(o) : this.getNodesFromPoint(o[n.by])).filter((r) => e.id !== r.id && !r.isDescendantOf(e)); } /** * Returns the bounding box that surrounds all cells in the graph. */ getAllCellsBBox() { return this.getCellsBBox(this.getCells()); } /** * Returns the bounding box that surrounds all the given cells. */ getCellsBBox(e, n = {}) { return Pt.getCellsBBox(e, n); } // #region search search(e, n, o = {}) { o.breadthFirst ? this.breadthFirstSearch(e, n, o) : this.depthFirstSearch(e, n, o); } breadthFirstSearch(e, n, o = {}) { const s = [], r = {}, i = {}; for (s.push(e), i[e.id] = 0; s.length > 0; ) { const l = s.shift(); if (l == null || r[l.id] || (r[l.id] = !0, dt(n, this, l, i[l.id]) === !1)) continue; this.getNeighbors(l, o).forEach((c) => { i[c.id] = i[l.id] + 1, s.push(c); }); } } depthFirstSearch(e, n, o = {}) { const s = [], r = {}, i = {}; for (s.push(e), i[e.id] = 0; s.length > 0; ) { const l = s.pop(); if (l == null || r[l.id] || (r[l.id] = !0, dt(n, this, l, i[l.id]) === !1)) continue; const a = this.getNeighbors(l, o), c = s.length; a.forEach((u) => { i[u.id] = i[l.id] + 1, s.splice(c, 0, u); }); } } // #endregion // #region shortest path /** * * Returns an array of IDs of nodes on the shortest * path between source and target. */ getShortestPath(e, n, o = {}) { const s = {}; this.getEdges().forEach((c) => { const u = c.getSourceCellId(), d = c.getTargetCellId(); u && d && (s[u] || (s[u] = []), s[d] || (s[d] = []), s[u].push(d), o.directed || s[d].push(u)); }); const r = typeof e == "string" ? e : e.id, i = qh.run(s, r, o.weight), l = []; let a = typeof n == "string" ? n : n.id; for (i[a] && l.push(a); a = i[a]; ) l.unshift(a); return l; } // #endregion // #region transform /** * Translate all cells in the graph by `tx` and `ty` pixels. */ translate(e, n, o) { return this.getCells().filter((s) => !s.hasParent()).forEach((s) => s.translate(e, n, o)), this; } resize(e, n, o) { return this.resizeCells(e, n, this.getCells(), o); } resizeCells(e, n, o, s = {}) { const r = this.getCellsBBox(o); if (r) { const i = Math.max(e / r.width, 0), l = Math.max(n / r.height, 0), a = r.getOrigin(); o.forEach((c) => c.scale(i, l, a, s)); } return this; } // #endregion // #region serialize/deserialize toJSON(e = {}) { return To.toJSON(this.getCells(), e); } parseJSON(e) { return To.fromJSON(e); } fromJSON(e, n = {}) { const o = this.parseJSON(e); return this.resetCells(o, n), this; } // #endregion // #region batch startBatch(e, n = {}) { return this.batches[e] = (this.batches[e] || 0) + 1, this.notify("batch:start", { name: e, data: n }), this; } stopBatch(e, n = {}) { return this.batches[e] = (this.batches[e] || 0) - 1, this.notify("batch:stop", { name: e, data: n }), this; } batchUpdate(e, n, o = {}) { this.startBatch(e, o); const s = n(); return this.stopBatch(e, o), s; } hasActiveBatch(e = Object.keys(this.batches)) { return (Array.isArray(e) ? e : [e]).some((o) => this.batches[o] > 0); } } (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.addNode == "function" && typeof s.addEdge == "function" && s.collection != null; } t.isModel = e; })(To || (To = {})); (function(t) { function e(o, s = {}) { return { cells: o.map((r) => r.toJSON(s)) }; } t.toJSON = e; function n(o) { const s = []; return Array.isArray(o) ? s.push(...o) : (o.cells && s.push(...o.cells), o.nodes && o.nodes.forEach((r) => { r.shape == null && (r.shape = "rect"), s.push(r); }), o.edges && o.edges.forEach((r) => { r.shape == null && (r.shape = "edge"), s.push(r); })), s.map((r) => { const i = r.shape; if (i) { if (Cn.registry.exist(i)) return Cn.create(r); if (pn.registry.exist(i)) return pn.create(r); } throw new Error("The `shape` should be specified when creating a node/edge instance"); }); } t.fromJSON = n; })(To || (To = {})); var vle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; let sr = class extends Cn { get label() { return this.getLabel(); } set label(e) { this.setLabel(e); } getLabel() { return this.getAttrByPath("text/text"); } setLabel(e, n) { return e == null ? this.removeLabel() : this.setAttrByPath("text/text", e, n), this; } removeLabel() { return this.removeAttrByPath("text/text"), this; } }; (function(t) { t.bodyAttr = { fill: "#ffffff", stroke: "#333333", strokeWidth: 2 }, t.labelAttr = { fontSize: 14, fill: "#000000", refX: 0.5, refY: 0.5, textAnchor: "middle", textVerticalAnchor: "middle", fontFamily: "Arial, helvetica, sans-serif" }, t.config({ attrs: { text: Object.assign({}, t.labelAttr) }, propHooks(e) { const { label: n } = e, o = vle(e, ["label"]); return n && ja(o, "attrs/text/text", n), o; }, visible: !0 }); })(sr || (sr = {})); var yle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; function ble(t, e = "body") { return [ { tagName: t, selector: e }, { tagName: "text", selector: "label" } ]; } function wle(t = "xlink:href") { return (n) => { const { imageUrl: o, imageWidth: s, imageHeight: r } = n, i = yle(n, ["imageUrl", "imageWidth", "imageHeight"]); if (o != null || s != null || r != null) { const l = () => { if (i.attrs) { const a = i.attrs.image; o != null && (a[t] = o), s != null && (a.width = s), r != null && (a.height = r), i.attrs.image = a; } }; i.attrs ? (i.attrs.image == null && (i.attrs.image = {}), l()) : (i.attrs = { image: {} }, l()); } return i; }; } function ml(t, e, n = {}) { const o = { constructorName: t, markup: ble(t, n.selector), attrs: { [t]: Object.assign({}, sr.bodyAttr) } }; return (n.parent || sr).define(rn(o, e, { shape: t })); } ml("rect", { attrs: { body: { refWidth: "100%", refHeight: "100%" } } }); const Qw = pn.define({ shape: "edge", markup: [ { tagName: "path", selector: "wrap", groupSelector: "lines", attrs: { fill: "none", cursor: "pointer", stroke: "transparent", strokeLinecap: "round" } }, { tagName: "path", selector: "line", groupSelector: "lines", attrs: { fill: "none", pointerEvents: "none" } } ], attrs: { lines: { connection: !0, strokeLinejoin: "round" }, wrap: { strokeWidth: 10 }, line: { stroke: "#333", strokeWidth: 2, targetMarker: "classic" } } }); ml("ellipse", { attrs: { body: { refCx: "50%", refCy: "50%", refRx: "50%", refRy: "50%" } } }); var Cle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class Zi extends sr { get points() { return this.getPoints(); } set points(e) { this.setPoints(e); } getPoints() { return this.getAttrByPath("body/refPoints"); } setPoints(e, n) { return e == null ? this.removePoints() : this.setAttrByPath("body/refPoints", Zi.pointsToString(e), n), this; } removePoints() { return this.removeAttrByPath("body/refPoints"), this; } } (function(t) { function e(n) { return typeof n == "string" ? n : n.map((o) => Array.isArray(o) ? o.join(",") : te.isPointLike(o) ? `${o.x}, ${o.y}` : "").join(" "); } t.pointsToString = e, t.config({ propHooks(n) { const { points: o } = n, s = Cle(n, ["points"]); if (o) { const r = e(o); r && ja(s, "attrs/body/refPoints", r); } return s; } }); })(Zi || (Zi = {})); ml("polygon", {}, { parent: Zi }); ml("polyline", {}, { parent: Zi }); var Sle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; sr.define({ shape: "path", markup: [ { tagName: "rect", selector: "bg" }, { tagName: "path", selector: "body" }, { tagName: "text", selector: "label" } ], attrs: { bg: { refWidth: "100%", refHeight: "100%", fill: "none", stroke: "none", pointerEvents: "all" }, body: { fill: "none", stroke: "#000", strokeWidth: 2 } }, propHooks(t) { const { path: e } = t, n = Sle(t, ["path"]); return e && ja(n, "attrs/body/refD", e), n; } }); var xle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; sr.define({ shape: "text-block", markup: [ { tagName: "rect", selector: "body" }, Qs.SUPPORT_FOREIGNOBJECT ? { tagName: "foreignObject", selector: "foreignObject", children: [ { tagName: "div", ns: Nn.xhtml, selector: "label", style: { width: "100%", height: "100%", position: "static", backgroundColor: "transparent", textAlign: "center", margin: 0, padding: "0px 5px", boxSizing: "border-box", display: "flex", alignItems: "center", justifyContent: "center" } } ] } : { tagName: "text", selector: "label", attrs: { textAnchor: "middle" } } ], attrs: { body: Object.assign(Object.assign({}, sr.bodyAttr), { refWidth: "100%", refHeight: "100%" }), foreignObject: { refWidth: "100%", refHeight: "100%" }, label: { style: { fontSize: 14 } } }, propHooks(t) { const { text: e } = t, n = xle(t, ["text"]); return e && ja(n, "attrs/label/text", e), n; }, attrHooks: { text: { set(t, { cell: e, view: n, refBBox: o, elem: s, attrs: r }) { if (s instanceof HTMLElement) s.textContent = t; else { const i = r.style || {}, l = { text: t, width: -5, height: "100%" }, a = Object.assign({ textVerticalAnchor: "middle" }, i), c = cs.presets.textWrap; return dt(c.set, this, l, { cell: e, view: n, elem: s, refBBox: o, attrs: a }), { fill: i.color || null }; } }, position(t, { refBBox: e, elem: n }) { if (n instanceof SVGElement) return e.getCenter(); } } } }); ml("image", { attrs: { image: { refWidth: "100%", refHeight: "100%" } }, propHooks: wle() }, { selector: "image" }); ml("circle", { attrs: { body: { refCx: "50%", refCy: "50%", refR: "50%" } } }); class bo extends _n { constructor() { super(...arguments), this.portsCache = {}; } get [Symbol.toStringTag]() { return bo.toStringTag; } getContainerClassName() { const e = [ super.getContainerClassName(), this.prefixClassName("node") ]; return this.can("nodeMovable") || e.push(this.prefixClassName("node-immovable")), e.join(" "); } updateClassName(e) { const n = e.target; if (n.hasAttribute("magnet")) { const o = this.prefixClassName("port-unconnectable"); this.can("magnetConnectable") ? Hn(n, o) : _t(n, o); } else { const o = this.prefixClassName("node-immovable"); this.can("nodeMovable") ? this.removeClass(o) : this.addClass(o); } } isNodeView() { return !0; } confirmUpdate(e, n = {}) { let o = e; return this.hasAction(o, "ports") && (this.removePorts(), this.cleanPortsCache()), this.hasAction(o, "render") ? (this.render(), o = this.removeAction(o, [ "render", "update", "resize", "translate", "rotate", "ports", "tools" ])) : (o = this.handleAction(o, "resize", () => this.resize(), "update"), o = this.handleAction( o, "update", () => this.update(), // `update()` will render ports when useCSSSelectors are enabled "ports" ), o = this.handleAction(o, "translate", () => this.translate()), o = this.handleAction(o, "rotate", () => this.rotate()), o = this.handleAction(o, "ports", () => this.renderPorts()), o = this.handleAction(o, "tools", () => { this.getFlag("tools") === e ? this.renderTools() : this.updateTools(n); })), o; } update(e) { this.cleanCache(), this.removePorts(); const n = this.cell, o = n.getSize(), s = n.getAttrs(); this.updateAttrs(this.container, s, { attrs: e === s ? null : e, rootBBox: new Fe(0, 0, o.width, o.height), selectors: this.selectors }), this.renderPorts(); } renderMarkup() { const e = this.cell.markup; if (e) { if (typeof e == "string") throw new TypeError("Not support string markup."); return this.renderJSONMarkup(e); } throw new TypeError("Invalid node markup."); } renderJSONMarkup(e) { const n = this.parseJSONMarkup(e, this.container); this.selectors = n.selectors, this.container.appendChild(n.fragment); } render() { return this.empty(), this.renderMarkup(), this.resize(), this.updateTransform(), this.renderTools(), this; } resize() { this.cell.getAngle() && this.rotate(), this.update(); } translate() { this.updateTransform(); } rotate() { this.updateTransform(); } getTranslationString() { const e = this.cell.getPosition(); return `translate(${e.x},${e.y})`; } getRotationString() { const e = this.cell.getAngle(); if (e) { const n = this.cell.getSize(); return `rotate(${e},${n.width / 2},${n.height / 2})`; } } updateTransform() { let e = this.getTranslationString(); const n = this.getRotationString(); n && (e += ` ${n}`), this.container.setAttribute("transform", e); } // #region ports findPortElem(e, n) { const o = e ? this.portsCache[e] : null; if (!o) return null; const s = o.portContentElement, r = o.portContentSelectors || {}; return this.findOne(n, s, r); } cleanPortsCache() { this.portsCache = {}; } removePorts() { Object.values(this.portsCache).forEach((e) => { os(e.portElement); }); } renderPorts() { const e = this.container, n = []; e.childNodes.forEach((i) => { n.push(i); }); const o = this.cell.getParsedPorts(), s = Um(o, "zIndex"), r = "auto"; s[r] && s[r].forEach((i) => { const l = this.getPortElement(i); e.append(l), n.push(l); }), Object.keys(s).forEach((i) => { if (i !== r) { const l = parseInt(i, 10); this.appendPorts(s[i], l, n); } }), this.updatePorts(); } appendPorts(e, n, o) { const s = e.map((r) => this.getPortElement(r)); o[n] || n < 0 ? Hg(o[Math.max(n, 0)], s) : Gr(this.container, s); } getPortElement(e) { const n = this.portsCache[e.id]; return n ? n.portElement : this.createPortElement(e); } createPortElement(e) { let n = en.renderMarkup(this.cell.getPortContainerMarkup()); const o = n.elem; if (o == null) throw new Error("Invalid port container markup."); n = en.renderMarkup(this.getPortMarkup(e)); const s = n.elem, r = n.selectors; if (s == null) throw new Error("Invalid port markup."); this.setAttrs({ port: e.id, "port-group": e.group }, s); let i = "x6-port"; e.group && (i += ` x6-port-${e.group}`), _t(o, i), _t(o, "x6-port"), _t(s, "x6-port-body"), o.appendChild(s); let l = r, a, c; if (this.existPortLabel(e)) { if (n = en.renderMarkup(this.getPortLabelMarkup(e.label)), a = n.elem, c = n.selectors, a == null) throw new Error("Invalid port label markup."); if (r && c) { for (const d in c) if (r[d] && d !== this.rootSelector) throw new Error("Selectors within port must be unique."); l = Object.assign(Object.assign({}, r), c); } _t(a, "x6-port-label"), o.appendChild(a); } return this.portsCache[e.id] = { portElement: o, portSelectors: l, portLabelElement: a, portLabelSelectors: c, portContentElement: s, portContentSelectors: r }, this.graph.options.onPortRendered && this.graph.options.onPortRendered({ port: e, node: this.cell, container: o, selectors: l, labelContainer: a, labelSelectors: c, contentContainer: s, contentSelectors: r }), o; } updatePorts() { const e = this.cell.getParsedGroups(), n = Object.keys(e); n.length === 0 ? this.updatePortGroup() : n.forEach((o) => this.updatePortGroup(o)); } updatePortGroup(e) { const n = Fe.fromSize(this.cell.getSize()), o = this.cell.getPortsLayoutByGroup(e, n); for (let s = 0, r = o.length; s < r; s += 1) { const i = o[s], l = i.portId, a = this.portsCache[l] || {}, c = i.portLayout; if (this.applyPortTransform(a.portElement, c), i.portAttrs != null) { const d = { selectors: a.portSelectors || {} }; i.portSize && (d.rootBBox = Fe.fromSize(i.portSize)), this.updateAttrs(a.portElement, i.portAttrs, d); } const u = i.labelLayout; if (u && a.portLabelElement && (this.applyPortTransform(a.portLabelElement, u, -(c.angle || 0)), u.attrs)) { const d = { selectors: a.portLabelSelectors || {} }; i.labelSize && (d.rootBBox = Fe.fromSize(i.labelSize)), this.updateAttrs(a.portLabelElement, u.attrs, d); } } } applyPortTransform(e, n, o = 0) { const s = n.angle, r = n.position, i = Vn().rotate(o).translate(r.x || 0, r.y || 0).rotate(s || 0); zi(e, i, { absolute: !0 }); } getPortMarkup(e) { return e.markup || this.cell.portMarkup; } getPortLabelMarkup(e) { return e.markup || this.cell.portLabelMarkup; } existPortLabel(e) { return e.attrs && e.attrs.text; } getEventArgs(e, n, o) { const s = this, r = s.cell, i = r; return n == null || o == null ? { e, view: s, node: r, cell: i } : { e, x: n, y: o, view: s, node: r, cell: i }; } getPortEventArgs(e, n, o) { const s = this, r = s.cell, i = r; return o ? { e, x: o.x, y: o.y, view: s, node: r, cell: i, port: n } : { e, view: s, node: r, cell: i, port: n }; } notifyMouseDown(e, n, o) { super.onMouseDown(e, n, o), this.notify("node:mousedown", this.getEventArgs(e, n, o)); } notifyMouseMove(e, n, o) { super.onMouseMove(e, n, o), this.notify("node:mousemove", this.getEventArgs(e, n, o)); } notifyMouseUp(e, n, o) { super.onMouseUp(e, n, o), this.notify("node:mouseup", this.getEventArgs(e, n, o)); } notifyPortEvent(e, n, o) { const s = this.findAttr("port", n.target); s && this.notify(e, this.getPortEventArgs(n, s, o)); } onClick(e, n, o) { super.onClick(e, n, o), this.notify("node:click", this.getEventArgs(e, n, o)), this.notifyPortEvent("node:port:click", e, { x: n, y: o }); } onDblClick(e, n, o) { super.onDblClick(e, n, o), this.notify("node:dblclick", this.getEventArgs(e, n, o)), this.notifyPortEvent("node:port:dblclick", e, { x: n, y: o }); } onContextMenu(e, n, o) { super.onContextMenu(e, n, o), this.notify("node:contextmenu", this.getEventArgs(e, n, o)), this.notifyPortEvent("node:port:contextmenu", e, { x: n, y: o }); } onMouseDown(e, n, o) { this.isPropagationStopped(e) || (this.notifyMouseDown(e, n, o), this.notifyPortEvent("node:port:mousedown", e, { x: n, y: o }), this.startNodeDragging(e, n, o)); } onMouseMove(e, n, o) { const s = this.getEventData(e), r = s.action; if (r === "magnet") this.dragMagnet(e, n, o); else { if (r === "move") { const l = s.targetView || this; l.dragNode(e, n, o), l.notify("node:moving", { e, x: n, y: o, view: l, cell: l.cell, node: l.cell }); } this.notifyMouseMove(e, n, o), this.notifyPortEvent("node:port:mousemove", e, { x: n, y: o }); } this.setEventData(e, s); } onMouseUp(e, n, o) { const s = this.getEventData(e), r = s.action; r === "magnet" ? this.stopMagnetDragging(e, n, o) : (this.notifyMouseUp(e, n, o), this.notifyPortEvent("node:port:mouseup", e, { x: n, y: o }), r === "move" && (s.targetView || this).stopNodeDragging(e, n, o)); const i = s.targetMagnet; i && this.onMagnetClick(e, i, n, o), this.checkMouseleave(e); } onMouseOver(e) { super.onMouseOver(e), this.notify("node:mouseover", this.getEventArgs(e)), this.notifyPortEvent("node:port:mouseover", e); } onMouseOut(e) { super.onMouseOut(e), this.notify("node:mouseout", this.getEventArgs(e)), this.notifyPortEvent("node:port:mouseout", e); } onMouseEnter(e) { this.updateClassName(e), super.onMouseEnter(e), this.notify("node:mouseenter", this.getEventArgs(e)), this.notifyPortEvent("node:port:mouseenter", e); } onMouseLeave(e) { super.onMouseLeave(e), this.notify("node:mouseleave", this.getEventArgs(e)), this.notifyPortEvent("node:port:mouseleave", e); } onMouseWheel(e, n, o, s) { super.onMouseWheel(e, n, o, s), this.notify("node:mousewheel", Object.assign({ delta: s }, this.getEventArgs(e, n, o))); } onMagnetClick(e, n, o, s) { const r = this.graph; r.view.getMouseMovedCount(e) > r.options.clickThreshold || this.notify("node:magnet:click", Object.assign({ magnet: n }, this.getEventArgs(e, o, s))); } onMagnetDblClick(e, n, o, s) { this.notify("node:magnet:dblclick", Object.assign({ magnet: n }, this.getEventArgs(e, o, s))); } onMagnetContextMenu(e, n, o, s) { this.notify("node:magnet:contextmenu", Object.assign({ magnet: n }, this.getEventArgs(e, o, s))); } onMagnetMouseDown(e, n, o, s) { this.startMagnetDragging(e, o, s); } onCustomEvent(e, n, o, s) { this.notify("node:customevent", Object.assign({ name: n }, this.getEventArgs(e, o, s))), super.onCustomEvent(e, n, o, s); } prepareEmbedding(e) { const n = this.graph, s = this.getEventData(e).cell || this.cell, r = n.findViewByCell(s), i = n.snapToGrid(e.clientX, e.clientY); this.notify("node:embed", { e, node: s, view: r, cell: s, x: i.x, y: i.y, currentParent: s.getParent() }); } processEmbedding(e, n) { const o = n.cell || this.cell, s = n.graph || this.graph, r = s.options.embedding, i = r.findParent; let l = typeof i == "function" ? dt(i, s, { view: this, node: this.cell }).filter((h) => Pt.isCell(h) && this.cell.id !== h.id && !h.isDescendantOf(this.cell)) : s.model.getNodesUnderNode(o, { by: i }); if (r.frontOnly && l.length > 0) { const h = Um(l, "zIndex"), p = RE(Object.keys(h).map((m) => parseInt(m, 10))); p && (l = h[p]); } l = l.filter((h) => h.visible); let a = null; const c = n.candidateEmbedView, u = r.validate; for (let h = l.length - 1; h >= 0; h -= 1) { const p = l[h]; if (c && c.cell.id === p.id) { a = c; break; } else { const m = p.findView(s); if (dt(u, s, { child: this.cell, parent: m.cell, childView: this, parentView: m })) { a = m; break; } } } this.clearEmbedding(n), a && a.highlight(null, { type: "embedding" }), n.candidateEmbedView = a; const d = s.snapToGrid(e.clientX, e.clientY); this.notify("node:embedding", { e, cell: o, node: o, view: s.findViewByCell(o), x: d.x, y: d.y, currentParent: o.getParent(), candidateParent: a ? a.cell : null }); } clearEmbedding(e) { const n = e.candidateEmbedView; n && (n.unhighlight(null, { type: "embedding" }), e.candidateEmbedView = null); } finalizeEmbedding(e, n) { this.graph.startBatch("embedding"); const o = n.cell || this.cell, s = n.graph || this.graph, r = s.findViewByCell(o), i = o.getParent(), l = n.candidateEmbedView; if (l ? (l.unhighlight(null, { type: "embedding" }), n.candidateEmbedView = null, (i == null || i.id !== l.cell.id) && l.cell.insertChild(o, void 0, { ui: !0 })) : i && i.unembed(o, { ui: !0 }), s.model.getConnectedEdges(o, { deep: !0 }).forEach((a) => { a.updateParent({ ui: !0 }); }), r && l) { const a = s.snapToGrid(e.clientX, e.clientY); r.notify("node:embedded", { e, cell: o, x: a.x, y: a.y, node: o, view: s.findViewByCell(o), previousParent: i, currentParent: o.getParent() }); } this.graph.stopBatch("embedding"); } getDelegatedView() { let e = this.cell, n = this; for (; n && !e.isEdge(); ) { if (!e.hasParent() || n.can("stopDelegateOnDragging")) return n; e = e.getParent(), n = this.graph.findViewByCell(e); } return null; } validateMagnet(e, n, o) { if (n.getAttribute("magnet") !== "passive") { const s = this.graph.options.connecting.validateMagnet; return s ? dt(s, this.graph, { e: o, magnet: n, view: e, cell: e.cell }) : !0; } return !1; } startMagnetDragging(e, n, o) { if (!this.can("magnetConnectable")) return; e.stopPropagation(); const s = e.currentTarget, r = this.graph; this.setEventData(e, { targetMagnet: s }), this.validateMagnet(this, s, e) ? (r.options.magnetThreshold <= 0 && this.startConnectting(e, s, n, o), this.setEventData(e, { action: "magnet" }), this.stopPropagation(e)) : this.onMouseDown(e, n, o), r.view.delegateDragEvents(e, this); } startConnectting(e, n, o, s) { this.graph.model.startBatch("add-edge"); const r = this.createEdgeFromMagnet(n, o, s); r.setEventData(e, r.prepareArrowheadDragging("target", { x: o, y: s, isNewEdge: !0, fallbackAction: "remove" })), this.setEventData(e, { edgeView: r }), r.notifyMouseDown(e, o, s); } getDefaultEdge(e, n) { let o; const s = this.graph.options.connecting.createEdge; return s && (o = dt(s, this.graph, { sourceMagnet: n, sourceView: e, sourceCell: e.cell })), o; } createEdgeFromMagnet(e, n, o) { const s = this.graph, r = s.model, i = this.getDefaultEdge(this, e); return i.setSource(Object.assign(Object.assign({}, i.getSource()), this.getEdgeTerminal(e, n, o, i, "source"))), i.setTarget(Object.assign(Object.assign({}, i.getTarget()), { x: n, y: o })), i.addTo(r, { async: !1, ui: !0 }), i.findView(s); } dragMagnet(e, n, o) { const s = this.getEventData(e), r = s.edgeView; if (r) r.onMouseMove(e, n, o), this.autoScrollGraph(e.clientX, e.clientY); else { const i = this.graph, l = i.options.magnetThreshold, a = this.getEventTarget(e), c = s.targetMagnet; if (l === "onleave") { if (c === a || c.contains(a)) return; } else if (i.view.getMouseMovedCount(e) <= l) return; this.startConnectting(e, c, n, o); } } stopMagnetDragging(e, n, o) { const r = this.eventData(e).edgeView; r && (r.onMouseUp(e, n, o), this.graph.model.stopBatch("add-edge")); } notifyUnhandledMouseDown(e, n, o) { this.notify("node:unhandled:mousedown", { e, x: n, y: o, view: this, cell: this.cell, node: this.cell }); } notifyNodeMove(e, n, o, s, r) { let i = [r]; const l = this.graph.getPlugin("selection"); if (l && l.isSelectionMovable()) { const a = l.getSelectedCells(); a.includes(r) && (i = a.filter((c) => c.isNode())); } i.forEach((a) => { this.notify(e, { e: n, x: o, y: s, cell: a, node: a, view: a.findView(this.graph) }); }); } getRestrictArea(e) { const n = this.graph.options.translating.restrict, o = typeof n == "function" ? dt(n, this.graph, e) : n; return typeof o == "number" ? this.graph.transform.getGraphArea().inflate(o) : o === !0 ? this.graph.transform.getGraphArea() : o || null; } startNodeDragging(e, n, o) { const s = this.getDelegatedView(); if (s == null || !s.can("nodeMovable")) return this.notifyUnhandledMouseDown(e, n, o); this.setEventData(e, { targetView: s, action: "move" }); const r = te.create(s.cell.getPosition()); s.setEventData(e, { moving: !1, offset: r.diff(n, o), restrict: this.getRestrictArea(s) }); } dragNode(e, n, o) { const s = this.cell, r = this.graph, i = r.getGridSize(), l = this.getEventData(e), a = l.offset, c = l.restrict; l.moving || (l.moving = !0, this.addClass("node-moving"), this.notifyNodeMove("node:move", e, n, o, this.cell)), this.autoScrollGraph(e.clientX, e.clientY); const u = Ht.snapToGrid(n + a.x, i), d = Ht.snapToGrid(o + a.y, i); s.setPosition(u, d, { restrict: c, deep: !0, ui: !0 }), r.options.embedding.enabled && (l.embedding || (this.prepareEmbedding(e), l.embedding = !0), this.processEmbedding(e, l)); } stopNodeDragging(e, n, o) { const s = this.getEventData(e); s.embedding && this.finalizeEmbedding(e, s), s.moving && (this.removeClass("node-moving"), this.notifyNodeMove("node:moved", e, n, o, this.cell)), s.moving = !1, s.embedding = !1; } // eslint-disable-next-line autoScrollGraph(e, n) { const o = this.graph.getPlugin("scroller"); o && o.autoScroll(e, n); } } (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.isNodeView == "function" && typeof s.isEdgeView == "function" && typeof s.confirmUpdate == "function" && typeof s.update == "function" && typeof s.findPortElem == "function" && typeof s.resize == "function" && typeof s.rotate == "function" && typeof s.translate == "function"; } t.isNodeView = e; })(bo || (bo = {})); bo.config({ isSvgElement: !0, priority: 0, bootstrap: ["render"], actions: { view: ["render"], markup: ["render"], attrs: ["update"], size: ["resize", "ports", "tools"], angle: ["rotate", "tools"], position: ["translate", "tools"], ports: ["ports"], tools: ["tools"] } }); bo.registry.register("node", bo, !0); class Ms extends _n { constructor() { super(...arguments), this.POINT_ROUNDING = 2; } get [Symbol.toStringTag]() { return Ms.toStringTag; } getContainerClassName() { return [super.getContainerClassName(), this.prefixClassName("edge")].join(" "); } get sourceBBox() { const e = this.sourceView; if (!e) { const o = this.cell.getSource(); return new Fe(o.x, o.y); } const n = this.sourceMagnet; return e.isEdgeElement(n) ? new Fe(this.sourceAnchor.x, this.sourceAnchor.y) : e.getBBoxOfElement(n || e.container); } get targetBBox() { const e = this.targetView; if (!e) { const o = this.cell.getTarget(); return new Fe(o.x, o.y); } const n = this.targetMagnet; return e.isEdgeElement(n) ? new Fe(this.targetAnchor.x, this.targetAnchor.y) : e.getBBoxOfElement(n || e.container); } isEdgeView() { return !0; } confirmUpdate(e, n = {}) { let o = e; if (this.hasAction(o, "source")) { if (!this.updateTerminalProperties("source")) return o; o = this.removeAction(o, "source"); } if (this.hasAction(o, "target")) { if (!this.updateTerminalProperties("target")) return o; o = this.removeAction(o, "target"); } const s = this.graph, r = this.sourceView, i = this.targetView; return s && (r && !s.renderer.isViewMounted(r) || i && !s.renderer.isViewMounted(i)) ? o : this.hasAction(o, "render") ? (this.render(), o = this.removeAction(o, ["render", "update", "labels", "tools"]), o) : (o = this.handleAction(o, "update", () => this.update(n)), o = this.handleAction(o, "labels", () => this.onLabelsChange(n)), o = this.handleAction(o, "tools", () => this.renderTools()), o); } // #region render render() { return this.empty(), this.renderMarkup(), this.labelContainer = null, this.renderLabels(), this.update(), this.renderTools(), this; } renderMarkup() { const e = this.cell.markup; if (e) { if (typeof e == "string") throw new TypeError("Not support string markup."); return this.renderJSONMarkup(e); } throw new TypeError("Invalid edge markup."); } renderJSONMarkup(e) { const n = this.parseJSONMarkup(e, this.container); this.selectors = n.selectors, this.container.append(n.fragment); } customizeLabels() { if (this.labelContainer) { const e = this.cell, n = e.labels; for (let o = 0, s = n.length; o < s; o += 1) { const r = n[o], i = this.labelCache[o], l = this.labelSelectors[o], a = this.graph.options.onEdgeLabelRendered; a && a({ edge: e, label: r, container: i, selectors: l }); } } } renderLabels() { const e = this.cell, n = e.getLabels(), o = n.length; let s = this.labelContainer; if (this.labelCache = {}, this.labelSelectors = {}, o <= 0) return s && s.parentNode && s.parentNode.removeChild(s), this; s ? this.empty(s) : (s = Os("g"), this.addClass(this.prefixClassName("edge-labels"), s), this.labelContainer = s); for (let r = 0, i = n.length; r < i; r += 1) { const l = n[r], a = this.normalizeLabelMarkup(this.parseLabelMarkup(l.markup)); let c, u; if (a) c = a.node, u = a.selectors; else { const h = e.getDefaultLabel(), p = this.normalizeLabelMarkup(this.parseLabelMarkup(h.markup)); c = p.node, u = p.selectors; } c.setAttribute("data-index", `${r}`), s.appendChild(c); const d = this.rootSelector; if (u[d]) throw new Error("Ambiguous label root selector."); u[d] = c, this.labelCache[r] = c, this.labelSelectors[r] = u; } return s.parentNode == null && this.container.appendChild(s), this.updateLabels(), this.customizeLabels(), this; } onLabelsChange(e = {}) { this.shouldRerenderLabels(e) ? this.renderLabels() : this.updateLabels(), this.updateLabelPositions(); } shouldRerenderLabels(e = {}) { const n = this.cell.previous("labels"); if (n == null) return !0; if ("propertyPathArray" in e && "propertyValue" in e) { const o = e.propertyPathArray || [], s = o.length; if (s > 1) { const r = o[1]; if (n[r]) { if (s === 2) return typeof e.propertyValue == "object" && Ya(e.propertyValue, "markup"); if (o[2] !== "markup") return !1; } } } return !0; } parseLabelMarkup(e) { return e ? typeof e == "string" ? this.parseLabelStringMarkup(e) : this.parseJSONMarkup(e) : null; } parseLabelStringMarkup(e) { const n = vt.createVectors(e), o = document.createDocumentFragment(); for (let s = 0, r = n.length; s < r; s += 1) { const i = n[s].node; o.appendChild(i); } return { fragment: o, selectors: {} }; } normalizeLabelMarkup(e) { if (e == null) return; const n = e.fragment; if (!(n instanceof DocumentFragment) || !n.hasChildNodes()) throw new Error("Invalid label markup."); let o; const s = n.childNodes; return s.length > 1 || s[0].nodeName.toUpperCase() !== "G" ? o = vt.create("g").append(n) : o = vt.create(s[0]), o.addClass(this.prefixClassName("edge-label")), { node: o.node, selectors: e.selectors }; } updateLabels() { if (this.labelContainer) { const e = this.cell, n = e.labels, o = this.can("edgeLabelMovable"), s = e.getDefaultLabel(); for (let r = 0, i = n.length; r < i; r += 1) { const l = this.labelCache[r], a = this.labelSelectors[r]; l.setAttribute("cursor", o ? "move" : "default"); const c = n[r], u = rn({}, s.attrs, c.attrs); this.updateAttrs(l, u, { selectors: a, rootBBox: c.size ? Fe.fromSize(c.size) : void 0 }); } } } renderTools() { const e = this.cell.getTools(); return this.addTools(e), this; } // #endregion // #region updating update(e = {}) { this.cleanCache(), this.updateConnection(e); const n = this.cell.getAttrs(); return n != null && this.updateAttrs(this.container, n, { selectors: this.selectors }), this.updateLabelPositions(), this.updateTools(e), this; } removeRedundantLinearVertices(e = {}) { const n = this.cell, o = n.getVertices(), s = [this.sourceAnchor, ...o, this.targetAnchor], r = s.length, i = new mn(s); i.simplify({ threshold: 0.01 }); const l = i.points.map((c) => c.toJSON()), a = l.length; return r === a ? 0 : (n.setVertices(l.slice(1, a - 1), e), r - a); } getTerminalView(e) { switch (e) { case "source": return this.sourceView || null; case "target": return this.targetView || null; default: throw new Error(`Unknown terminal type '${e}'`); } } getTerminalAnchor(e) { switch (e) { case "source": return te.create(this.sourceAnchor); case "target": return te.create(this.targetAnchor); default: throw new Error(`Unknown terminal type '${e}'`); } } getTerminalConnectionPoint(e) { switch (e) { case "source": return te.create(this.sourcePoint); case "target": return te.create(this.targetPoint); default: throw new Error(`Unknown terminal type '${e}'`); } } getTerminalMagnet(e, n = {}) { switch (e) { case "source": { if (n.raw) return this.sourceMagnet; const o = this.sourceView; return o ? this.sourceMagnet || o.container : null; } case "target": { if (n.raw) return this.targetMagnet; const o = this.targetView; return o ? this.targetMagnet || o.container : null; } default: throw new Error(`Unknown terminal type '${e}'`); } } updateConnection(e = {}) { const n = this.cell; if (e.translateBy && n.isFragmentDescendantOf(e.translateBy)) { const o = e.tx || 0, s = e.ty || 0; this.routePoints = new mn(this.routePoints).translate(o, s).points, this.translateConnectionPoints(o, s), this.path.translate(o, s); } else { const o = n.getVertices(), s = this.findAnchors(o); this.sourceAnchor = s.source, this.targetAnchor = s.target, this.routePoints = this.findRoutePoints(o); const r = this.findConnectionPoints(this.routePoints, this.sourceAnchor, this.targetAnchor); this.sourcePoint = r.source, this.targetPoint = r.target; const i = this.findMarkerPoints(this.routePoints, this.sourcePoint, this.targetPoint); this.path = this.findPath(this.routePoints, i.source || this.sourcePoint, i.target || this.targetPoint); } this.cleanCache(); } findAnchors(e) { const n = this.cell, o = n.source, s = n.target, r = e[0], i = e[e.length - 1]; return s.priority && !o.priority ? this.findAnchorsOrdered("target", i, "source", r) : this.findAnchorsOrdered("source", r, "target", i); } findAnchorsOrdered(e, n, o, s) { let r, i; const l = this.cell, a = l[e], c = l[o], u = this.getTerminalView(e), d = this.getTerminalView(o), h = this.getTerminalMagnet(e), p = this.getTerminalMagnet(o); if (u) { let m; n ? m = te.create(n) : d ? m = p : m = te.create(c), r = this.getAnchor(a.anchor, u, h, m, e); } else r = te.create(a); if (d) { const m = te.create(s || r); i = this.getAnchor(c.anchor, d, p, m, o); } else i = te.isPointLike(c) ? te.create(c) : new te(); return { [e]: r, [o]: i }; } getAnchor(e, n, o, s, r) { const i = n.isEdgeElement(o), l = this.graph.options.connecting; let a = typeof e == "string" ? { name: e } : e; if (!a) { const d = i ? (r === "source" ? l.sourceEdgeAnchor : l.targetEdgeAnchor) || l.edgeAnchor : (r === "source" ? l.sourceAnchor : l.targetAnchor) || l.anchor; a = typeof d == "string" ? { name: d } : d; } if (!a) throw new Error("Anchor should be specified."); let c; const u = a.name; if (i) { const d = Gi.registry.get(u); if (typeof d != "function") return Gi.registry.onNotFound(u); c = dt(d, this, n, o, s, a.args || {}, r); } else { const d = Ui.registry.get(u); if (typeof d != "function") return Ui.registry.onNotFound(u); c = dt(d, this, n, o, s, a.args || {}, r); } return c ? c.round(this.POINT_ROUNDING) : new te(); } findRoutePoints(e = []) { const n = this.graph.options.connecting.router || Fs.presets.normal, o = this.cell.getRouter() || n; let s; if (typeof o == "function") s = dt(o, this, e, {}, this); else { const r = typeof o == "string" ? o : o.name, i = typeof o == "string" ? {} : o.args || {}, l = r ? Fs.registry.get(r) : Fs.presets.normal; if (typeof l != "function") return Fs.registry.onNotFound(r); s = dt(l, this, e, i, this); } return s == null ? e.map((r) => te.create(r)) : s.map((r) => te.create(r)); } findConnectionPoints(e, n, o) { const s = this.cell, r = this.graph.options.connecting, i = s.getSource(), l = s.getTarget(), a = this.sourceView, c = this.targetView, u = e[0], d = e[e.length - 1]; let h; if (a && !a.isEdgeElement(this.sourceMagnet)) { const m = this.sourceMagnet || a.container, g = u || o, v = new Ye(g, n), y = i.connectionPoint || r.sourceConnectionPoint || r.connectionPoint; h = this.getConnectionPoint(y, a, m, v, "source"); } else h = n; let p; if (c && !c.isEdgeElement(this.targetMagnet)) { const m = this.targetMagnet || c.container, g = l.connectionPoint || r.targetConnectionPoint || r.connectionPoint, v = d || n, y = new Ye(v, o); p = this.getConnectionPoint(g, c, m, y, "target"); } else p = o; return { source: h, target: p }; } getConnectionPoint(e, n, o, s, r) { const i = s.end; if (e == null) return i; const l = typeof e == "string" ? e : e.name, a = typeof e == "string" ? {} : e.args, c = Yi.registry.get(l); if (typeof c != "function") return Yi.registry.onNotFound(l); const u = dt(c, this, s, n, o, a || {}, r); return u ? u.round(this.POINT_ROUNDING) : i; } findMarkerPoints(e, n, o) { const s = (d) => { const h = this.cell.getAttrs(), p = Object.keys(h); for (let m = 0, g = p.length; m < g; m += 1) { const v = h[p[m]]; if (v[`${d}Marker`] || v[`${d}-marker`]) { const y = v.strokeWidth || v["stroke-width"]; if (y) return parseFloat(y); break; } } return null; }, r = e[0], i = e[e.length - 1]; let l, a; const c = s("source"); c && (l = n.clone().move(r || o, -c)); const u = s("target"); return u && (a = o.clone().move(i || n, -u)), this.sourceMarkerPoint = l || n.clone(), this.targetMarkerPoint = a || o.clone(), { source: l, target: a }; } findPath(e, n, o) { const s = this.cell.getConnector() || this.graph.options.connecting.connector; let r, i, l; if (typeof s == "string" ? r = s : (r = s.name, i = s.args), r) { const c = Or.registry.get(r); if (typeof c != "function") return Or.registry.onNotFound(r); l = c; } else l = Or.presets.normal; const a = dt(l, this, n, o, e, Object.assign(Object.assign({}, i), { raw: !0 }), this); return typeof a == "string" ? ut.parse(a) : a; } translateConnectionPoints(e, n) { this.sourcePoint.translate(e, n), this.targetPoint.translate(e, n), this.sourceAnchor.translate(e, n), this.targetAnchor.translate(e, n), this.sourceMarkerPoint.translate(e, n), this.targetMarkerPoint.translate(e, n); } updateLabelPositions() { if (this.labelContainer == null) return this; if (!this.path) return this; const n = this.cell, o = n.getLabels(); if (o.length === 0) return this; const s = n.getDefaultLabel(), r = this.normalizeLabelPosition(s.position); for (let i = 0, l = o.length; i < l; i += 1) { const a = o[i], c = this.normalizeLabelPosition(a.position), u = rn({}, r, c), d = this.getLabelTransformationMatrix(u); this.labelCache[i].setAttribute("transform", pl(d)); } return this; } updateTerminalProperties(e) { const n = this.cell, o = this.graph, s = n[e], r = s && s.cell, i = `${e}View`; if (!r) return this[i] = null, this.updateTerminalMagnet(e), !0; const l = o.getCellById(r); if (!l) throw new Error(`Edge's ${e} node with id "${r}" not exists`); const a = l.findView(o); return a ? (this[i] = a, this.updateTerminalMagnet(e), !0) : !1; } updateTerminalMagnet(e) { const n = `${e}Magnet`, o = this.getTerminalView(e); if (o) { let s = o.getMagnetFromEdgeTerminal(this.cell[e]); s === o.container && (s = null), this[n] = s; } else this[n] = null; } getLabelPositionAngle(e) { const n = this.cell.getLabelAt(e); return n && n.position && typeof n.position == "object" && n.position.angle || 0; } getLabelPositionArgs(e) { const n = this.cell.getLabelAt(e); if (n && n.position && typeof n.position == "object") return n.position.options; } getDefaultLabelPositionArgs() { const e = this.cell.getDefaultLabel(); if (e && e.position && typeof e.position == "object") return e.position.options; } mergeLabelPositionArgs(e, n) { return e === null ? null : e === void 0 ? n === null ? null : n : rn({}, n, e); } // #endregion getConnection() { return this.path != null ? this.path.clone() : null; } getConnectionPathData() { if (this.path == null) return ""; const e = this.cache.pathCache; return Ya(e, "data") || (e.data = this.path.serialize()), e.data || ""; } getConnectionSubdivisions() { if (this.path == null) return null; const e = this.cache.pathCache; return Ya(e, "segmentSubdivisions") || (e.segmentSubdivisions = this.path.getSegmentSubdivisions()), e.segmentSubdivisions; } getConnectionLength() { if (this.path == null) return 0; const e = this.cache.pathCache; return Ya(e, "length") || (e.length = this.path.length({ segmentSubdivisions: this.getConnectionSubdivisions() })), e.length; } getPointAtLength(e) { return this.path == null ? null : this.path.pointAtLength(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getPointAtRatio(e) { return this.path == null ? null : (Es(e) && (e = parseFloat(e) / 100), this.path.pointAt(e, { segmentSubdivisions: this.getConnectionSubdivisions() })); } getTangentAtLength(e) { return this.path == null ? null : this.path.tangentAtLength(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getTangentAtRatio(e) { return this.path == null ? null : this.path.tangentAt(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getClosestPoint(e) { return this.path == null ? null : this.path.closestPoint(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getClosestPointLength(e) { return this.path == null ? null : this.path.closestPointLength(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getClosestPointRatio(e) { return this.path == null ? null : this.path.closestPointNormalizedLength(e, { segmentSubdivisions: this.getConnectionSubdivisions() }); } getLabelPosition(e, n, o, s) { const r = { distance: 0 }; let i = 0, l; typeof o == "number" ? (i = o, l = s) : l = o, l != null && (r.options = l); const a = l && l.absoluteOffset, c = !(l && l.absoluteDistance), u = l && l.absoluteDistance && l.reverseDistance, d = this.path, h = { segmentSubdivisions: this.getConnectionSubdivisions() }, p = new te(e, n), m = d.closestPointT(p, h), g = this.getConnectionLength() || 0; let v = d.lengthAtT(m, h); c && (v = g > 0 ? v / g : 0), u && (v = -1 * (g - v) || 1), r.distance = v; let y; a || (y = d.tangentAtT(m)); let w; if (y) w = y.pointOffset(p); else { const b = d.pointAtT(m), C = p.diff(b); w = { x: C.x, y: C.y }; } return r.offset = w, r.angle = i, r; } normalizeLabelPosition(e) { return typeof e == "number" ? { distance: e } : e; } getLabelTransformationMatrix(e) { const n = this.normalizeLabelPosition(e), o = n.options || {}, s = n.angle || 0, r = n.distance, i = r > 0 && r <= 1; let l = 0; const a = { x: 0, y: 0 }, c = n.offset; c && (typeof c == "number" ? l = c : (c.x != null && (a.x = c.x), c.y != null && (a.y = c.y))); const u = a.x !== 0 || a.y !== 0 || l === 0, d = o.keepGradient, h = o.ensureLegibility, p = this.path, m = { segmentSubdivisions: this.getConnectionSubdivisions() }, g = i ? r * this.getConnectionLength() : r, v = p.tangentAtLength(g, m); let y, w = s; if (v) { if (u) y = v.start, y.translate(a); else { const b = v.clone(); b.rotate(-90, v.start), b.setLength(l), y = b.end; } d && (w = v.angle() + s, h && (w = Ut.normalize((w + 90) % 180 - 90))); } else y = p.start, u && y.translate(a); return Vn().translate(y.x, y.y).rotate(w); } getVertexIndex(e, n) { const s = this.cell.getVertices(), r = this.getClosestPointLength(new te(e, n)); let i = 0; if (r != null) for (const l = s.length; i < l; i += 1) { const a = s[i], c = this.getClosestPointLength(a); if (c != null && r < c) break; } return i; } getEventArgs(e, n, o) { const s = this, r = s.cell, i = r; return n == null || o == null ? { e, view: s, edge: r, cell: i } : { e, x: n, y: o, view: s, edge: r, cell: i }; } notifyUnhandledMouseDown(e, n, o) { this.notify("edge:unhandled:mousedown", { e, x: n, y: o, view: this, cell: this.cell, edge: this.cell }); } notifyMouseDown(e, n, o) { super.onMouseDown(e, n, o), this.notify("edge:mousedown", this.getEventArgs(e, n, o)); } notifyMouseMove(e, n, o) { super.onMouseMove(e, n, o), this.notify("edge:mousemove", this.getEventArgs(e, n, o)); } notifyMouseUp(e, n, o) { super.onMouseUp(e, n, o), this.notify("edge:mouseup", this.getEventArgs(e, n, o)); } onClick(e, n, o) { super.onClick(e, n, o), this.notify("edge:click", this.getEventArgs(e, n, o)); } onDblClick(e, n, o) { super.onDblClick(e, n, o), this.notify("edge:dblclick", this.getEventArgs(e, n, o)); } onContextMenu(e, n, o) { super.onContextMenu(e, n, o), this.notify("edge:contextmenu", this.getEventArgs(e, n, o)); } onMouseDown(e, n, o) { this.notifyMouseDown(e, n, o), this.startEdgeDragging(e, n, o); } onMouseMove(e, n, o) { const s = this.getEventData(e); switch (s.action) { case "drag-label": { this.dragLabel(e, n, o); break; } case "drag-arrowhead": { this.dragArrowhead(e, n, o); break; } case "drag-edge": { this.dragEdge(e, n, o); break; } } return this.notifyMouseMove(e, n, o), s; } onMouseUp(e, n, o) { const s = this.getEventData(e); switch (s.action) { case "drag-label": { this.stopLabelDragging(e, n, o); break; } case "drag-arrowhead": { this.stopArrowheadDragging(e, n, o); break; } case "drag-edge": { this.stopEdgeDragging(e, n, o); break; } } return this.notifyMouseUp(e, n, o), this.checkMouseleave(e), s; } onMouseOver(e) { super.onMouseOver(e), this.notify("edge:mouseover", this.getEventArgs(e)); } onMouseOut(e) { super.onMouseOut(e), this.notify("edge:mouseout", this.getEventArgs(e)); } onMouseEnter(e) { super.onMouseEnter(e), this.notify("edge:mouseenter", this.getEventArgs(e)); } onMouseLeave(e) { super.onMouseLeave(e), this.notify("edge:mouseleave", this.getEventArgs(e)); } onMouseWheel(e, n, o, s) { super.onMouseWheel(e, n, o, s), this.notify("edge:mousewheel", Object.assign({ delta: s }, this.getEventArgs(e, n, o))); } onCustomEvent(e, n, o, s) { if (W4(e.target, "edge-tool", this.container)) { if (e.stopPropagation(), this.can("useEdgeTools")) { if (n === "edge:remove") { this.cell.remove({ ui: !0 }); return; } this.notify("edge:customevent", Object.assign({ name: n }, this.getEventArgs(e, o, s))); } this.notifyMouseDown(e, o, s); } else this.notify("edge:customevent", Object.assign({ name: n }, this.getEventArgs(e, o, s))), super.onCustomEvent(e, n, o, s); } onLabelMouseDown(e, n, o) { this.notifyMouseDown(e, n, o), this.startLabelDragging(e, n, o), this.getEventData(e).stopPropagation && e.stopPropagation(); } // #region drag edge startEdgeDragging(e, n, o) { if (!this.can("edgeMovable")) { this.notifyUnhandledMouseDown(e, n, o); return; } this.setEventData(e, { x: n, y: o, moving: !1, action: "drag-edge" }); } dragEdge(e, n, o) { const s = this.getEventData(e); s.moving || (s.moving = !0, this.addClass("edge-moving"), this.notify("edge:move", { e, x: n, y: o, view: this, cell: this.cell, edge: this.cell })), this.cell.translate(n - s.x, o - s.y, { ui: !0 }), this.setEventData(e, { x: n, y: o }), this.notify("edge:moving", { e, x: n, y: o, view: this, cell: this.cell, edge: this.cell }); } stopEdgeDragging(e, n, o) { const s = this.getEventData(e); s.moving && (this.removeClass("edge-moving"), this.notify("edge:moved", { e, x: n, y: o, view: this, cell: this.cell, edge: this.cell })), s.moving = !1; } // #endregion // #region drag arrowhead prepareArrowheadDragging(e, n) { const o = this.getTerminalMagnet(e), s = { action: "drag-arrowhead", x: n.x, y: n.y, isNewEdge: n.isNewEdge === !0, terminalType: e, initialMagnet: o, initialTerminal: Zl(this.cell[e]), fallbackAction: n.fallbackAction || "revert", getValidateConnectionArgs: this.createValidateConnectionArgs(e), options: n.options }; return this.beforeArrowheadDragging(s), s; } createValidateConnectionArgs(e) { const n = []; n[4] = e, n[5] = this; let o, s = 0, r = 0; e === "source" ? (s = 2, o = "target") : (r = 2, o = "source"); const i = this.cell[o], l = i.cell; if (l) { let a; const c = n[s] = this.graph.findViewByCell(l); c && (a = c.getMagnetFromEdgeTerminal(i), a === c.container && (a = void 0)), n[s + 1] = a; } return (a, c) => (n[r] = a, n[r + 1] = a.container === c ? void 0 : c, n); } beforeArrowheadDragging(e) { e.zIndex = this.cell.zIndex, this.cell.toFront(); const n = this.container.style; e.pointerEvents = n.pointerEvents, n.pointerEvents = "none", this.graph.options.connecting.highlight && this.highlightAvailableMagnets(e); } afterArrowheadDragging(e) { e.zIndex != null && (this.cell.setZIndex(e.zIndex, { ui: !0 }), e.zIndex = null); const n = this.container; n.style.pointerEvents = e.pointerEvents || "", this.graph.options.connecting.highlight && this.unhighlightAvailableMagnets(e); } validateConnection(e, n, o, s, r, i, l) { const a = this.graph.options.connecting, c = a.allowLoop, u = a.allowNode, d = a.allowEdge, h = a.allowPort, p = a.allowMulti, m = a.validateConnection, g = i ? i.cell : null, v = r === "target" ? o : e, y = r === "target" ? s : n; let w = !0; const b = (C) => { const S = r === "source" ? l ? l.port : null : g ? g.getSourcePortId() : null, k = r === "target" ? l ? l.port : null : g ? g.getTargetPortId() : null; return dt(C, this.graph, { edge: g, edgeView: i, sourceView: e, targetView: o, sourcePort: S, targetPort: k, sourceMagnet: n, targetMagnet: s, sourceCell: e ? e.cell : null, targetCell: o ? o.cell : null, type: r }); }; if (c != null && (typeof c == "boolean" ? !c && e === o && (w = !1) : w = b(c)), w && h != null && (typeof h == "boolean" ? !h && y && (w = !1) : w = b(h)), w && d != null && (typeof d == "boolean" ? !d && Ms.isEdgeView(v) && (w = !1) : w = b(d)), w && u != null && y == null && (typeof u == "boolean" ? !u && bo.isNodeView(v) && (w = !1) : w = b(u)), w && p != null && i) { const C = i.cell, S = r === "source" ? l : C.getSource(), k = r === "target" ? l : C.getTarget(), E = l ? this.graph.getCellById(l.cell) : null; if (S && k && S.cell && k.cell && E) if (typeof p == "function") w = b(p); else { const $ = this.graph.model.getConnectedEdges(E, { outgoing: r === "source", incoming: r === "target" }); $.length && (p === "withPort" ? $.some((P) => { const A = P.getSource(), I = P.getTarget(); return A && I && A.cell === S.cell && I.cell === k.cell && A.port != null && A.port === S.port && I.port != null && I.port === k.port; }) && (w = !1) : p || $.some((P) => { const A = P.getSource(), I = P.getTarget(); return A && I && A.cell === S.cell && I.cell === k.cell; }) && (w = !1)); } } return w && m != null && (w = b(m)), w; } allowConnectToBlank(e) { const n = this.graph, s = n.options.connecting.allowBlank; if (typeof s != "function") return !!s; const r = n.findViewByCell(e), i = e.getSourceCell(), l = e.getTargetCell(), a = n.findViewByCell(i), c = n.findViewByCell(l); return dt(s, n, { edge: e, edgeView: r, sourceCell: i, targetCell: l, sourceView: a, targetView: c, sourcePort: e.getSourcePortId(), targetPort: e.getTargetPortId(), sourceMagnet: r.sourceMagnet, targetMagnet: r.targetMagnet }); } validateEdge(e, n, o) { const s = this.graph; if (!this.allowConnectToBlank(e)) { const i = e.getSourceCellId(), l = e.getTargetCellId(); if (!(i && l)) return !1; } const r = s.options.connecting.validateEdge; return r ? dt(r, s, { edge: e, type: n, previous: o }) : !0; } arrowheadDragging(e, n, o, s) { s.x = n, s.y = o, s.currentTarget !== e && (s.currentMagnet && s.currentView && s.currentView.unhighlight(s.currentMagnet, { type: "magnetAdsorbed" }), s.currentView = this.graph.findViewByElem(e), s.currentView ? (s.currentMagnet = s.currentView.findMagnet(e), s.currentMagnet && this.validateConnection(...s.getValidateConnectionArgs(s.currentView, s.currentMagnet), s.currentView.getEdgeTerminal(s.currentMagnet, n, o, this.cell, s.terminalType)) ? s.currentView.highlight(s.currentMagnet, { type: "magnetAdsorbed" }) : s.currentMagnet = null) : s.currentMagnet = null), s.currentTarget = e, this.cell.prop(s.terminalType, { x: n, y: o }, Object.assign(Object.assign({}, s.options), { ui: !0 })); } arrowheadDragged(e, n, o) { const s = e.currentView, r = e.currentMagnet; if (!r || !s) return; s.unhighlight(r, { type: "magnetAdsorbed" }); const i = e.terminalType, l = s.getEdgeTerminal(r, n, o, this.cell, i); this.cell.setTerminal(i, l, { ui: !0 }); } snapArrowhead(e, n, o) { const s = this.graph, { snap: r, allowEdge: i } = s.options.connecting, l = typeof r == "object" && r.radius || 50, a = s.renderer.findViewsInArea({ x: e - l, y: n - l, width: 2 * l, height: 2 * l }, { nodeOnly: !0 }); if (i) { const b = s.renderer.findEdgeViewsFromPoint({ x: e, y: n }, l).filter((C) => C !== this); a.push(...b); } const c = o.closestView || null, u = o.closestMagnet || null; o.closestView = null, o.closestMagnet = null; let d, h = Number.MAX_SAFE_INTEGER; const p = new te(e, n); a.forEach((b) => { if (b.container.getAttribute("magnet") !== "false") { if (b.isNodeView()) d = b.cell.getBBox().getCenter().distance(p); else if (b.isEdgeView()) { const C = b.getClosestPoint(p); C ? d = C.distance(p) : d = Number.MAX_SAFE_INTEGER; } d < l && d < h && (u === b.container || this.validateConnection(...o.getValidateConnectionArgs(b, null), b.getEdgeTerminal(b.container, e, n, this.cell, o.terminalType))) && (h = d, o.closestView = b, o.closestMagnet = b.container); } b.container.querySelectorAll("[magnet]").forEach((C) => { if (C.getAttribute("magnet") !== "false") { const S = b.getBBoxOfElement(C); d = p.distance(S.getCenter()), d < l && d < h && (u === C || this.validateConnection(...o.getValidateConnectionArgs(b, C), b.getEdgeTerminal(C, e, n, this.cell, o.terminalType))) && (h = d, o.closestView = b, o.closestMagnet = C); } }); }); let m; const g = o.terminalType, v = o.closestView, y = o.closestMagnet, w = u !== y; if (c && w && c.unhighlight(u, { type: "magnetAdsorbed" }), v) { if (!w) return; v.highlight(y, { type: "magnetAdsorbed" }), m = v.getEdgeTerminal(y, e, n, this.cell, g); } else m = { x: e, y: n }; this.cell.setTerminal(g, m, {}, Object.assign(Object.assign({}, o.options), { ui: !0 })); } snapArrowheadEnd(e) { const n = e.closestView, o = e.closestMagnet; n && o && (n.unhighlight(o, { type: "magnetAdsorbed" }), e.currentMagnet = n.findMagnet(o)), e.closestView = null, e.closestMagnet = null; } finishEmbedding(e) { this.graph.options.embedding.enabled && this.cell.updateParent() && (e.zIndex = null); } fallbackConnection(e) { switch (e.fallbackAction) { case "remove": this.cell.remove({ ui: !0 }); break; case "revert": default: this.cell.prop(e.terminalType, e.initialTerminal, { ui: !0 }); break; } } notifyConnectionEvent(e, n) { const o = e.terminalType, s = e.initialTerminal, r = this.cell[o]; if (r && !pn.equalTerminals(s, r)) { const l = this.graph, a = s, c = a.cell ? l.getCellById(a.cell) : null, u = a.port, d = c ? l.findViewByCell(c) : null, h = c || e.isNewEdge ? null : te.create(s).toJSON(), p = r, m = p.cell ? l.getCellById(p.cell) : null, g = p.port, v = m ? l.findViewByCell(m) : null, y = m ? null : te.create(r).toJSON(); this.notify("edge:connected", { e: n, previousCell: c, previousPort: u, previousView: d, previousPoint: h, currentCell: m, currentView: v, currentPort: g, currentPoint: y, previousMagnet: e.initialMagnet, currentMagnet: e.currentMagnet, edge: this.cell, view: this, type: o, isNew: e.isNewEdge }); } } highlightAvailableMagnets(e) { const n = this.graph, o = n.model.getCells(); e.marked = {}; for (let s = 0, r = o.length; s < r; s += 1) { const i = n.findViewByCell(o[s]); if (!i || i.cell.id === this.cell.id) continue; const l = Array.prototype.slice.call(i.container.querySelectorAll("[magnet]")); i.container.getAttribute("magnet") !== "false" && l.push(i.container); const a = l.filter((c) => this.validateConnection(...e.getValidateConnectionArgs(i, c), i.getEdgeTerminal(c, e.x, e.y, this.cell, e.terminalType))); if (a.length > 0) { for (let c = 0, u = a.length; c < u; c += 1) i.highlight(a[c], { type: "magnetAvailable" }); i.highlight(null, { type: "nodeAvailable" }), e.marked[i.cell.id] = a; } } } unhighlightAvailableMagnets(e) { const n = e.marked || {}; Object.keys(n).forEach((o) => { const s = this.graph.findViewByCell(o); s && (n[o].forEach((i) => { s.unhighlight(i, { type: "magnetAvailable" }); }), s.unhighlight(null, { type: "nodeAvailable" })); }), e.marked = null; } startArrowheadDragging(e, n, o) { if (!this.can("arrowheadMovable")) { this.notifyUnhandledMouseDown(e, n, o); return; } const r = e.target.getAttribute("data-terminal"), i = this.prepareArrowheadDragging(r, { x: n, y: o }); this.setEventData(e, i); } dragArrowhead(e, n, o) { const s = this.getEventData(e); this.graph.options.connecting.snap ? this.snapArrowhead(n, o, s) : this.arrowheadDragging(this.getEventTarget(e), n, o, s); } stopArrowheadDragging(e, n, o) { const s = this.graph, r = this.getEventData(e); s.options.connecting.snap ? this.snapArrowheadEnd(r) : this.arrowheadDragged(r, n, o), this.validateEdge(this.cell, r.terminalType, r.initialTerminal) ? (this.finishEmbedding(r), this.notifyConnectionEvent(r, e)) : this.fallbackConnection(r), this.afterArrowheadDragging(r); } // #endregion // #region drag lable // eslint-disable-next-line @typescript-eslint/no-unused-vars startLabelDragging(e, n, o) { if (this.can("edgeLabelMovable")) { const s = e.currentTarget, r = parseInt(s.getAttribute("data-index"), 10), i = this.getLabelPositionAngle(r), l = this.getLabelPositionArgs(r), a = this.getDefaultLabelPositionArgs(), c = this.mergeLabelPositionArgs(l, a); this.setEventData(e, { index: r, positionAngle: i, positionArgs: c, stopPropagation: !0, action: "drag-label" }); } else this.setEventData(e, { stopPropagation: !0 }); this.graph.view.delegateDragEvents(e, this); } dragLabel(e, n, o) { const s = this.getEventData(e), r = this.cell.getLabelAt(s.index), i = rn({}, r, { position: this.getLabelPosition(n, o, s.positionAngle, s.positionArgs) }); this.cell.setLabelAt(s.index, i); } // eslint-disable-next-line @typescript-eslint/no-unused-vars stopLabelDragging(e, n, o) { } } (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag], s = n; return (o == null || o === t.toStringTag) && typeof s.isNodeView == "function" && typeof s.isEdgeView == "function" && typeof s.confirmUpdate == "function" && typeof s.update == "function" && typeof s.getConnection == "function"; } t.isEdgeView = e; })(Ms || (Ms = {})); Ms.config({ isSvgElement: !0, priority: 1, bootstrap: ["render", "source", "target"], actions: { view: ["render"], markup: ["render"], attrs: ["update"], source: ["source", "update"], target: ["target", "update"], router: ["update"], connector: ["update"], labels: ["labels"], defaultLabel: ["labels"], tools: ["tools"], vertices: ["vertices", "update"] } }); Ms.registry.register("edge", Ms, !0); var kle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class us extends jt { get options() { return this.graph.options; } constructor(e) { super(), this.graph = e; const { selectors: n, fragment: o } = en.parseJSONMarkup(us.markup); this.background = n.background, this.grid = n.grid, this.svg = n.svg, this.defs = n.defs, this.viewport = n.viewport, this.primer = n.primer, this.stage = n.stage, this.decorator = n.decorator, this.overlay = n.overlay, this.container = this.options.container, this.restore = us.snapshoot(this.container), _t(this.container, this.prefixClassName("graph")), Gr(this.container, o), this.delegateEvents(); } delegateEvents() { const e = this.constructor; return super.delegateEvents(e.events), this; } /** * Guard the specified event. If the event is not interesting, it * returns `true`, otherwise returns `false`. */ guard(e, n) { return e.type === "mousedown" && e.button === 2 || this.options.guard && this.options.guard(e, n) ? !0 : e.data && e.data.guarded !== void 0 ? e.data.guarded : !(n && n.cell && Pt.isCell(n.cell) || this.svg === e.target || this.container === e.target || this.svg.contains(e.target)); } findView(e) { return this.graph.findViewByElem(e); } onDblClick(e) { this.options.preventDefaultDblClick && e.preventDefault(); const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; const s = this.graph.snapToGrid(n.clientX, n.clientY); o ? o.onDblClick(n, s.x, s.y) : this.graph.trigger("blank:dblclick", { e: n, x: s.x, y: s.y }); } onClick(e) { if (this.getMouseMovedCount(e) <= this.options.clickThreshold) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; const s = this.graph.snapToGrid(n.clientX, n.clientY); o ? o.onClick(n, s.x, s.y) : this.graph.trigger("blank:click", { e: n, x: s.x, y: s.y }); } } isPreventDefaultContextMenu(e) { let n = this.options.preventDefaultContextMenu; return typeof n == "function" && (n = dt(n, this.graph, { view: e })), n; } onContextMenu(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.isPreventDefaultContextMenu(o) && e.preventDefault(), this.guard(n, o)) return; const s = this.graph.snapToGrid(n.clientX, n.clientY); o ? o.onContextMenu(n, s.x, s.y) : this.graph.trigger("blank:contextmenu", { e: n, x: s.x, y: s.y }); } delegateDragEvents(e, n) { e.data == null && (e.data = {}), this.setEventData(e, { currentView: n || null, mouseMovedCount: 0, startPosition: { x: e.clientX, y: e.clientY } }); const o = this.constructor; this.delegateDocumentEvents(o.documentEvents, e.data), this.undelegateEvents(); } getMouseMovedCount(e) { return this.getEventData(e).mouseMovedCount || 0; } onMouseDown(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; this.options.preventDefaultMouseDown && e.preventDefault(); const s = this.graph.snapToGrid(n.clientX, n.clientY); o ? o.onMouseDown(n, s.x, s.y) : (this.options.preventDefaultBlankAction && ["touchstart"].includes(n.type) && e.preventDefault(), this.graph.trigger("blank:mousedown", { e: n, x: s.x, y: s.y })), this.delegateDragEvents(n, o); } onMouseMove(e) { const n = this.getEventData(e), o = n.startPosition; if (o && o.x === e.clientX && o.y === e.clientY || (n.mouseMovedCount == null && (n.mouseMovedCount = 0), n.mouseMovedCount += 1, n.mouseMovedCount <= this.options.moveThreshold)) return; const r = this.normalizeEvent(e), i = this.graph.snapToGrid(r.clientX, r.clientY), l = n.currentView; l ? l.onMouseMove(r, i.x, i.y) : this.graph.trigger("blank:mousemove", { e: r, x: i.x, y: i.y }), this.setEventData(r, n); } onMouseUp(e) { this.undelegateDocumentEvents(); const n = this.normalizeEvent(e), o = this.graph.snapToGrid(n.clientX, n.clientY), r = this.getEventData(e).currentView; if (r ? r.onMouseUp(n, o.x, o.y) : this.graph.trigger("blank:mouseup", { e: n, x: o.x, y: o.y }), !e.isPropagationStopped()) { const i = new ss(e, { type: "click", data: e.data }); this.onClick(i); } e.stopImmediatePropagation(), this.delegateEvents(); } onMouseOver(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (!this.guard(n, o)) if (o) o.onMouseOver(n); else { if (this.container === n.target) return; this.graph.trigger("blank:mouseover", { e: n }); } } onMouseOut(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (!this.guard(n, o)) if (o) o.onMouseOut(n); else { if (this.container === n.target) return; this.graph.trigger("blank:mouseout", { e: n }); } } onMouseEnter(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; const s = this.graph.findViewByElem(n.relatedTarget); if (o) { if (s === o) return; o.onMouseEnter(n); } else { if (s) return; this.graph.trigger("graph:mouseenter", { e: n }); } } onMouseLeave(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; const s = this.graph.findViewByElem(n.relatedTarget); if (o) { if (s === o) return; o.onMouseLeave(n); } else { if (s) return; this.graph.trigger("graph:mouseleave", { e: n }); } } onMouseWheel(e) { const n = this.normalizeEvent(e), o = this.findView(n.target); if (this.guard(n, o)) return; const s = n.originalEvent, r = this.graph.snapToGrid(s.clientX, s.clientY), i = Math.max(-1, Math.min(1, s.wheelDelta || -s.detail)); o ? o.onMouseWheel(n, r.x, r.y, i) : this.graph.trigger("blank:mousewheel", { e: n, delta: i, x: r.x, y: r.y }); } onCustomEvent(e) { const n = e.currentTarget, o = n.getAttribute("event") || n.getAttribute("data-event"); if (o) { const s = this.findView(n); if (s) { const r = this.normalizeEvent(e); if (this.guard(r, s)) return; const i = this.graph.snapToGrid(r.clientX, r.clientY); s.onCustomEvent(r, o, i.x, i.y); } } } handleMagnetEvent(e, n) { const o = e.currentTarget, s = o.getAttribute("magnet"); if (s && s.toLowerCase() !== "false") { const r = this.findView(o); if (r) { const i = this.normalizeEvent(e); if (this.guard(i, r)) return; const l = this.graph.snapToGrid(i.clientX, i.clientY); dt(n, this.graph, r, i, o, l.x, l.y); } } } onMagnetMouseDown(e) { this.handleMagnetEvent(e, (n, o, s, r, i) => { n.onMagnetMouseDown(o, s, r, i); }); } onMagnetDblClick(e) { this.handleMagnetEvent(e, (n, o, s, r, i) => { n.onMagnetDblClick(o, s, r, i); }); } onMagnetContextMenu(e) { const n = this.findView(e.target); this.isPreventDefaultContextMenu(n) && e.preventDefault(), this.handleMagnetEvent(e, (o, s, r, i, l) => { o.onMagnetContextMenu(s, r, i, l); }); } onLabelMouseDown(e) { const n = e.currentTarget, o = this.findView(n); if (o) { const s = this.normalizeEvent(e); if (this.guard(s, o)) return; const r = this.graph.snapToGrid(s.clientX, s.clientY); o.onLabelMouseDown(s, r.x, r.y); } } onImageDragStart() { return !1; } dispose() { this.undelegateEvents(), this.undelegateDocumentEvents(), this.restore(), this.restore = () => { }; } } kle([ jt.dispose() ], us.prototype, "dispose", null); (function(t) { const e = `${Io.prefixCls}-graph`; t.markup = [ { ns: Nn.xhtml, tagName: "div", selector: "background", className: `${e}-background` }, { ns: Nn.xhtml, tagName: "div", selector: "grid", className: `${e}-grid` }, { ns: Nn.svg, tagName: "svg", selector: "svg", className: `${e}-svg`, attrs: { width: "100%", height: "100%", "xmlns:xlink": Nn.xlink }, children: [ { tagName: "defs", selector: "defs" }, { tagName: "g", selector: "viewport", className: `${e}-svg-viewport`, children: [ { tagName: "g", selector: "primer", className: `${e}-svg-primer` }, { tagName: "g", selector: "stage", className: `${e}-svg-stage` }, { tagName: "g", selector: "decorator", className: `${e}-svg-decorator` }, { tagName: "g", selector: "overlay", className: `${e}-svg-overlay` } ] } ] } ]; function n(o) { const s = o.cloneNode(); return o.childNodes.forEach((r) => s.appendChild(r)), () => { for (Wa(o); o.attributes.length > 0; ) o.removeAttribute(o.attributes[0].name); for (let r = 0, i = s.attributes.length; r < i; r += 1) { const l = s.attributes[r]; o.setAttribute(l.name, l.value); } s.childNodes.forEach((r) => o.appendChild(r)); }; } t.snapshoot = n; })(us || (us = {})); (function(t) { const e = Io.prefixCls; t.events = { dblclick: "onDblClick", contextmenu: "onContextMenu", touchstart: "onMouseDown", mousedown: "onMouseDown", mouseover: "onMouseOver", mouseout: "onMouseOut", mouseenter: "onMouseEnter", mouseleave: "onMouseLeave", mousewheel: "onMouseWheel", DOMMouseScroll: "onMouseWheel", [`mouseenter .${e}-cell`]: "onMouseEnter", [`mouseleave .${e}-cell`]: "onMouseLeave", [`mouseenter .${e}-cell-tools`]: "onMouseEnter", [`mouseleave .${e}-cell-tools`]: "onMouseLeave", [`mousedown .${e}-cell [event]`]: "onCustomEvent", [`touchstart .${e}-cell [event]`]: "onCustomEvent", [`mousedown .${e}-cell [data-event]`]: "onCustomEvent", [`touchstart .${e}-cell [data-event]`]: "onCustomEvent", [`dblclick .${e}-cell [magnet]`]: "onMagnetDblClick", [`contextmenu .${e}-cell [magnet]`]: "onMagnetContextMenu", [`mousedown .${e}-cell [magnet]`]: "onMagnetMouseDown", [`touchstart .${e}-cell [magnet]`]: "onMagnetMouseDown", [`dblclick .${e}-cell [data-magnet]`]: "onMagnetDblClick", [`contextmenu .${e}-cell [data-magnet]`]: "onMagnetContextMenu", [`mousedown .${e}-cell [data-magnet]`]: "onMagnetMouseDown", [`touchstart .${e}-cell [data-magnet]`]: "onMagnetMouseDown", [`dragstart .${e}-cell image`]: "onImageDragStart", [`mousedown .${e}-edge .${e}-edge-label`]: "onLabelMouseDown", [`touchstart .${e}-edge .${e}-edge-label`]: "onLabelMouseDown" }, t.documentEvents = { mousemove: "onMouseMove", touchmove: "onMouseMove", mouseup: "onMouseUp", touchend: "onMouseUp", touchcancel: "onMouseUp" }; })(us || (us = {})); const Ele = `.x6-graph { position: relative; outline: none; touch-action: none; } .x6-graph-background, .x6-graph-grid, .x6-graph-svg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } .x6-graph-background-stage, .x6-graph-grid-stage, .x6-graph-svg-stage { user-select: none; } .x6-graph.x6-graph-pannable { cursor: grab; cursor: -moz-grab; cursor: -webkit-grab; } .x6-graph.x6-graph-panning { cursor: grabbing; cursor: -moz-grabbing; cursor: -webkit-grabbing; user-select: none; } .x6-node { cursor: move; /* stylelint-disable-next-line */ } .x6-node.x6-node-immovable { cursor: default; } .x6-node * { -webkit-user-drag: none; } .x6-node .scalable * { vector-effect: non-scaling-stroke; } .x6-node [magnet='true'] { cursor: crosshair; transition: opacity 0.3s; } .x6-node [magnet='true']:hover { opacity: 0.7; } .x6-node foreignObject { display: block; overflow: visible; background-color: transparent; } .x6-node foreignObject > body { position: static; width: 100%; height: 100%; margin: 0; padding: 0; overflow: visible; background-color: transparent; } .x6-edge .source-marker, .x6-edge .target-marker { vector-effect: non-scaling-stroke; } .x6-edge .connection { stroke-linejoin: round; fill: none; } .x6-edge .connection-wrap { cursor: move; opacity: 0; fill: none; stroke: #000; stroke-width: 15; stroke-linecap: round; stroke-linejoin: round; } .x6-edge .connection-wrap:hover { opacity: 0.4; stroke-opacity: 0.4; } .x6-edge .vertices { cursor: move; opacity: 0; } .x6-edge .vertices .vertex { fill: #1abc9c; } .x6-edge .vertices .vertex :hover { fill: #34495e; stroke: none; } .x6-edge .vertices .vertex-remove { cursor: pointer; fill: #fff; } .x6-edge .vertices .vertex-remove-area { cursor: pointer; opacity: 0.1; } .x6-edge .vertices .vertex-group:hover .vertex-remove-area { opacity: 1; } .x6-edge .arrowheads { cursor: move; opacity: 0; } .x6-edge .arrowheads .arrowhead { fill: #1abc9c; } .x6-edge .arrowheads .arrowhead :hover { fill: #f39c12; stroke: none; } .x6-edge .tools { cursor: pointer; opacity: 0; } .x6-edge .tools .tool-options { display: none; } .x6-edge .tools .tool-remove circle { fill: #f00; } .x6-edge .tools .tool-remove path { fill: #fff; } .x6-edge:hover .vertices, .x6-edge:hover .arrowheads, .x6-edge:hover .tools { opacity: 1; } .x6-highlight-opacity { opacity: 0.3; } .x6-cell-tool-editor { position: relative; display: inline-block; min-height: 1em; margin: 0; padding: 0; line-height: 1; white-space: normal; text-align: center; vertical-align: top; overflow-wrap: normal; outline: none; transform-origin: 0 0; -webkit-user-drag: none; } .x6-edge-tool-editor { border: 1px solid #275fc5; border-radius: 2px; } `; class zn extends uo { get options() { return this.graph.options; } get model() { return this.graph.model; } get view() { return this.graph.view; } constructor(e) { super(), this.graph = e, this.init(); } init() { } } var Mle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Zh extends zn { init() { Sd("core", Ele); } dispose() { xd("core"); } } Mle([ Zh.dispose() ], Zh.prototype, "dispose", null); var $le = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }, Ea; (function(t) { function e(n) { const { grid: o, panning: s, mousewheel: r, embedding: i } = n, l = $le( n, ["grid", "panning", "mousewheel", "embedding"] ), a = n.container; if (a != null) l.width == null && (l.width = a.clientWidth), l.height == null && (l.height = a.clientHeight); else throw new Error("Ensure the container of the graph is specified and valid"); const c = rn({}, t.defaults, l), u = { size: 10, visible: !1 }; return typeof o == "number" ? c.grid = { size: o, visible: !1 } : typeof o == "boolean" ? c.grid = Object.assign(Object.assign({}, u), { visible: o }) : c.grid = Object.assign(Object.assign({}, u), o), [ "panning", "mousewheel", "embedding" ].forEach((h) => { const p = n[h]; typeof p == "boolean" ? c[h].enabled = p : c[h] = Object.assign(Object.assign({}, c[h]), p); }), c; } t.get = e; })(Ea || (Ea = {})); (function(t) { t.defaults = { x: 0, y: 0, scaling: { min: 0.01, max: 16 }, grid: { size: 10, visible: !1 }, background: !1, panning: { enabled: !1, eventTypes: ["leftMouseDown"] }, mousewheel: { enabled: !1, factor: 1.2, zoomAtMousePosition: !0 }, highlighting: { default: { name: "stroke", args: { padding: 3 } }, nodeAvailable: { name: "className", args: { className: Io.prefix("available-node") } }, magnetAvailable: { name: "className", args: { className: Io.prefix("available-magnet") } } }, connecting: { snap: !1, allowLoop: !0, allowNode: !0, allowEdge: !1, allowPort: !0, allowBlank: !0, allowMulti: !0, highlight: !1, anchor: "center", edgeAnchor: "ratio", connectionPoint: "boundary", router: "normal", connector: "normal", validateConnection({ type: e, sourceView: n, targetView: o }) { return (e === "target" ? o : n) != null; }, createEdge() { return new Qw(); } }, translating: { restrict: !1 }, embedding: { enabled: !1, findParent: "bbox", frontOnly: !0, validate: () => !0 }, moveThreshold: 0, clickThreshold: 0, magnetThreshold: 0, preventDefaultDblClick: !0, preventDefaultMouseDown: !1, preventDefaultContextMenu: !0, preventDefaultBlankAction: !0, interacting: { edgeLabelMovable: !1 }, async: !0, virtual: !1, guard: () => !1 }; })(Ea || (Ea = {})); var _le = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }, Tle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class Yg extends zn { get elem() { return this.view.grid; } get grid() { return this.options.grid; } init() { this.startListening(), this.draw(this.grid); } startListening() { this.graph.on("scale", this.update, this), this.graph.on("translate", this.update, this); } stopListening() { this.graph.off("scale", this.update, this), this.graph.off("translate", this.update, this); } setVisible(e) { this.grid.visible !== e && (this.grid.visible = e, this.update()); } getGridSize() { return this.grid.size; } setGridSize(e) { this.grid.size = Math.max(e, 1), this.update(); } show() { this.setVisible(!0), this.update(); } hide() { this.setVisible(!1), this.update(); } clear() { this.elem.style.backgroundImage = ""; } draw(e) { this.clear(), this.instance = null, Object.assign(this.grid, e), this.patterns = this.resolveGrid(e), this.update(); } update(e = {}) { const n = this.grid.size; if (n <= 1 || !this.grid.visible) return this.clear(); const o = this.graph.matrix(), s = this.getInstance(), r = Array.isArray(e) ? e : [e]; this.patterns.forEach((a, c) => { const u = `pattern_${c}`, d = o.a || 1, h = o.d || 1, { update: p, markup: m } = a, g = Tle(a, ["update", "markup"]), v = Object.assign(Object.assign(Object.assign({}, g), r[c]), { sx: d, sy: h, ox: o.e || 0, oy: o.f || 0, width: n * d, height: n * h }); s.has(u) || s.add(u, vt.create("pattern", { id: u, patternUnits: "userSpaceOnUse" }, vt.createVectors(m)).node); const y = s.get(u); typeof p == "function" && p(y.childNodes[0], v); let w = v.ox % v.width; w < 0 && (w += v.width); let b = v.oy % v.height; b < 0 && (b += v.height), Vt(y, { x: w, y: b, width: v.width, height: v.height }); }); const i = new XMLSerializer().serializeToString(s.root), l = `url(data:image/svg+xml;base64,${btoa(i)})`; this.elem.style.backgroundImage = l; } getInstance() { return this.instance || (this.instance = new Ds()), this.instance; } resolveGrid(e) { if (!e) return []; const n = e.type; if (n == null) return [ Object.assign(Object.assign({}, Ds.presets.dot), e.args) ]; const o = Ds.registry.get(n); if (o) { let s = e.args || []; return Array.isArray(s) || (s = [s]), Array.isArray(o) ? o.map((r, i) => Object.assign(Object.assign({}, r), s[i])) : [Object.assign(Object.assign({}, o), s[0])]; } return Ds.registry.onNotFound(n); } dispose() { this.stopListening(), this.clear(); } } _le([ zn.dispose() ], Yg.prototype, "dispose", null); class e8 extends zn { get container() { return this.graph.view.container; } get viewport() { return this.graph.view.viewport; } get stage() { return this.graph.view.stage; } init() { this.resize(); } /** * Returns the current transformation matrix of the graph. */ getMatrix() { const e = this.viewport.getAttribute("transform"); return e !== this.viewportTransformString && (this.viewportMatrix = this.viewport.getCTM(), this.viewportTransformString = e), Vn(this.viewportMatrix); } /** * Sets new transformation with the given `matrix` */ setMatrix(e) { const n = Vn(e), o = pl(n); this.viewport.setAttribute("transform", o), this.viewportMatrix = n, this.viewportTransformString = o; } resize(e, n) { let o = e === void 0 ? this.options.width : e, s = n === void 0 ? this.options.height : n; this.options.width = o, this.options.height = s, typeof o == "number" && (o = Math.round(o)), typeof s == "number" && (s = Math.round(s)), this.container.style.width = o == null ? "" : `${o}px`, this.container.style.height = s == null ? "" : `${s}px`; const r = this.getComputedSize(); return this.graph.trigger("resize", Object.assign({}, r)), this; } getComputedSize() { let e = this.options.width, n = this.options.height; return Gm(e) || (e = this.container.clientWidth), Gm(n) || (n = this.container.clientHeight), { width: e, height: n }; } getScale() { return Aoe(this.getMatrix()); } scale(e, n = e, o = 0, s = 0) { if (e = this.clampScale(e), n = this.clampScale(n), o || s) { const i = this.getTranslation(), l = i.tx - o * (e - 1), a = i.ty - s * (n - 1); (l !== i.tx || a !== i.ty) && this.translate(l, a); } const r = this.getMatrix(); return r.a = e, r.d = n, this.setMatrix(r), this.graph.trigger("scale", { sx: e, sy: n, ox: o, oy: s }), this; } clampScale(e) { const n = this.graph.options.scaling; return Mo(e, n.min || 0.01, n.max || 16); } getZoom() { return this.getScale().sx; } zoom(e, n) { n = n || {}; let o = e, s = e; const r = this.getScale(), i = this.getComputedSize(); let l = i.width / 2, a = i.height / 2; if (n.absolute || (o += r.sx, s += r.sy), n.scaleGrid && (o = Math.round(o / n.scaleGrid) * n.scaleGrid, s = Math.round(s / n.scaleGrid) * n.scaleGrid), n.maxScale && (o = Math.min(n.maxScale, o), s = Math.min(n.maxScale, s)), n.minScale && (o = Math.max(n.minScale, o), s = Math.max(n.minScale, s)), n.center && (l = n.center.x, a = n.center.y), o = this.clampScale(o), s = this.clampScale(s), l || a) { const c = this.getTranslation(), u = l - (l - c.tx) * (o / r.sx), d = a - (a - c.ty) * (s / r.sy); (u !== c.tx || d !== c.ty) && this.translate(u, d); } return this.scale(o, s), this; } getRotation() { return Poe(this.getMatrix()); } rotate(e, n, o) { if (n == null || o == null) { const r = Ft.getBBox(this.stage); n = r.width / 2, o = r.height / 2; } const s = this.getMatrix().translate(n, o).rotate(e).translate(-n, -o); return this.setMatrix(s), this; } getTranslation() { return Noe(this.getMatrix()); } translate(e, n) { const o = this.getMatrix(); o.e = e || 0, o.f = n || 0, this.setMatrix(o); const s = this.getTranslation(); return this.options.x = s.tx, this.options.y = s.ty, this.graph.trigger("translate", Object.assign({}, s)), this; } setOrigin(e, n) { return this.translate(e || 0, n || 0); } fitToContent(e, n, o, s) { if (typeof e == "object") { const b = e; e = b.gridWidth || 1, n = b.gridHeight || 1, o = b.padding || 0, s = b; } else e = e || 1, n = n || 1, o = o || 0, s == null && (s = {}); const r = Lr(o), i = s.border || 0, l = s.contentArea ? Fe.create(s.contentArea) : this.getContentArea(s); i > 0 && l.inflate(i); const a = this.getScale(), c = this.getTranslation(), u = a.sx, d = a.sy; l.x *= u, l.y *= d, l.width *= u, l.height *= d; let h = Math.max(Math.ceil((l.width + l.x) / e), 1) * e, p = Math.max(Math.ceil((l.height + l.y) / n), 1) * n, m = 0, g = 0; (s.allowNewOrigin === "negative" && l.x < 0 || s.allowNewOrigin === "positive" && l.x >= 0 || s.allowNewOrigin === "any") && (m = Math.ceil(-l.x / e) * e, m += r.left, h += m), (s.allowNewOrigin === "negative" && l.y < 0 || s.allowNewOrigin === "positive" && l.y >= 0 || s.allowNewOrigin === "any") && (g = Math.ceil(-l.y / n) * n, g += r.top, p += g), h += r.right, p += r.bottom, h = Math.max(h, s.minWidth || 0), p = Math.max(p, s.minHeight || 0), h = Math.min(h, s.maxWidth || Number.MAX_SAFE_INTEGER), p = Math.min(p, s.maxHeight || Number.MAX_SAFE_INTEGER); const v = this.getComputedSize(), y = h !== v.width || p !== v.height; return (m !== c.tx || g !== c.ty) && this.translate(m, g), y && this.resize(h, p), new Fe(-m / u, -g / d, h / u, p / d); } scaleContentToFit(e = {}) { this.scaleContentToFitImpl(e); } scaleContentToFitImpl(e = {}, n = !0) { let o, s; if (e.contentArea) { const y = e.contentArea; o = this.graph.localToGraph(y), s = te.create(y); } else o = this.getContentBBox(e), s = this.graph.graphToLocal(o); if (!o.width || !o.height) return; const r = Lr(e.padding), i = e.minScale || 0, l = e.maxScale || Number.MAX_SAFE_INTEGER, a = e.minScaleX || i, c = e.maxScaleX || l, u = e.minScaleY || i, d = e.maxScaleY || l; let h; if (e.viewportArea) h = e.viewportArea; else { const y = this.getComputedSize(), w = this.getTranslation(); h = { x: w.tx, y: w.ty, width: y.width, height: y.height }; } h = Fe.create(h).moveAndExpand({ x: r.left, y: r.top, width: -r.left - r.right, height: -r.top - r.bottom }); const p = this.getScale(); let m = h.width / o.width * p.sx, g = h.height / o.height * p.sy; e.preserveAspectRatio !== !1 && (m = g = Math.min(m, g)); const v = e.scaleGrid; if (v && (m = v * Math.floor(m / v), g = v * Math.floor(g / v)), m = Mo(m, a, c), g = Mo(g, u, d), this.scale(m, g), n) { const y = this.options, w = h.x - s.x * m - y.x, b = h.y - s.y * g - y.y; this.translate(w, b); } } getContentArea(e = {}) { return e.useCellGeometry !== !1 ? this.model.getAllCellsBBox() || new Fe() : Ft.getBBox(this.stage); } getContentBBox(e = {}) { return this.graph.localToGraph(this.getContentArea(e)); } getGraphArea() { const e = Fe.fromSize(this.getComputedSize()); return this.graph.graphToLocal(e); } zoomToRect(e, n = {}) { const o = Fe.create(e), s = this.graph; n.contentArea = o, n.viewportArea == null && (n.viewportArea = { x: s.options.x, y: s.options.y, width: this.options.width, height: this.options.height }), this.scaleContentToFitImpl(n, !1); const r = o.getCenter(); return this.centerPoint(r.x, r.y), this; } zoomToFit(e = {}) { return this.zoomToRect(this.getContentArea(e), e); } centerPoint(e, n) { const o = this.getComputedSize(), s = this.getScale(), r = this.getTranslation(), i = o.width / 2, l = o.height / 2; e = typeof e == "number" ? e : i, n = typeof n == "number" ? n : l, e = i - e * s.sx, n = l - n * s.sy, (r.tx !== e || r.ty !== n) && this.translate(e, n); } centerContent(e) { const o = this.graph.getContentArea(e).getCenter(); this.centerPoint(o.x, o.y); } centerCell(e) { return this.positionCell(e, "center"); } positionPoint(e, n, o) { const s = this.getComputedSize(); n = Ho(n, Math.max(0, s.width)), n < 0 && (n = s.width + n), o = Ho(o, Math.max(0, s.height)), o < 0 && (o = s.height + o); const r = this.getTranslation(), i = this.getScale(), l = n - e.x * i.sx, a = o - e.y * i.sy; (r.tx !== l || r.ty !== a) && this.translate(l, a); } positionRect(e, n) { const o = Fe.create(e); switch (n) { case "center": return this.positionPoint(o.getCenter(), "50%", "50%"); case "top": return this.positionPoint(o.getTopCenter(), "50%", 0); case "top-right": return this.positionPoint(o.getTopRight(), "100%", 0); case "right": return this.positionPoint(o.getRightMiddle(), "100%", "50%"); case "bottom-right": return this.positionPoint(o.getBottomRight(), "100%", "100%"); case "bottom": return this.positionPoint(o.getBottomCenter(), "50%", "100%"); case "bottom-left": return this.positionPoint(o.getBottomLeft(), 0, "100%"); case "left": return this.positionPoint(o.getLeftMiddle(), 0, "50%"); case "top-left": return this.positionPoint(o.getTopLeft(), 0, 0); default: return this; } } positionCell(e, n) { const o = e.getBBox(); return this.positionRect(o, n); } positionContent(e, n) { const o = this.graph.getContentArea(n); return this.positionRect(o, e); } } var Ole = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Xg extends zn { get elem() { return this.view.background; } init() { this.startListening(), this.options.background && this.draw(this.options.background); } startListening() { this.graph.on("scale", this.update, this), this.graph.on("translate", this.update, this); } stopListening() { this.graph.off("scale", this.update, this), this.graph.off("translate", this.update, this); } updateBackgroundImage(e = {}) { let n = e.size || "auto auto", o = e.position || "center"; const s = this.graph.transform.getScale(), r = this.graph.translate(); if (typeof o == "object") { const i = r.tx + s.sx * (o.x || 0), l = r.ty + s.sy * (o.y || 0); o = `${i}px ${l}px`; } typeof n == "object" && (n = Fe.fromSize(n).scale(s.sx, s.sy), n = `${n.width}px ${n.height}px`), this.elem.style.backgroundSize = n, this.elem.style.backgroundPosition = o; } drawBackgroundImage(e, n = {}) { if (!(e instanceof HTMLImageElement)) { this.elem.style.backgroundImage = ""; return; } const o = this.optionsCache; if (o && o.image !== n.image) return; let s; const r = n.opacity, i = n.size; let l = n.repeat || "no-repeat"; const a = wa.registry.get(l); if (typeof a == "function") { const u = n.quality || 1; e.width *= u, e.height *= u; const d = a(e, n); if (!(d instanceof HTMLCanvasElement)) throw new Error("Background pattern must return an HTML Canvas instance"); s = d.toDataURL("image/png"), n.repeat && l !== n.repeat ? l = n.repeat : l = "repeat", typeof i == "object" ? (i.width *= d.width / e.width, i.height *= d.height / e.height) : i === void 0 && (n.size = { width: d.width / u, height: d.height / u }); } else s = e.src, i === void 0 && (n.size = { width: e.width, height: e.height }); o != null && typeof n.size == "object" && n.image === o.image && n.repeat === o.repeat && n.quality === o.quality && (o.size = Zl(n.size)); const c = this.elem.style; c.backgroundImage = `url(${s})`, c.backgroundRepeat = l, c.opacity = r == null || r >= 1 ? "" : `${r}`, this.updateBackgroundImage(n); } updateBackgroundColor(e) { this.elem.style.backgroundColor = e || ""; } updateBackgroundOptions(e) { this.graph.options.background = e; } update() { this.optionsCache && this.updateBackgroundImage(this.optionsCache); } draw(e) { const n = e || {}; if (this.updateBackgroundOptions(e), this.updateBackgroundColor(n.color), n.image) { this.optionsCache = Zl(n); const o = document.createElement("img"); o.onload = () => this.drawBackgroundImage(o, e), o.setAttribute("crossorigin", "anonymous"), o.src = n.image; } else this.drawBackgroundImage(null), this.optionsCache = null; } clear() { this.draw(); } dispose() { this.clear(), this.stopListening(); } } Ole([ zn.dispose() ], Xg.prototype, "dispose", null); var Ale = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class t8 extends zn { get widgetOptions() { return this.options.panning; } get pannable() { return this.widgetOptions && this.widgetOptions.enabled === !0; } init() { this.startListening(), this.updateClassName(); } startListening() { const e = this.widgetOptions.eventTypes; e && (e.includes("leftMouseDown") && (this.graph.on("blank:mousedown", this.preparePanning, this), this.graph.on("node:unhandled:mousedown", this.preparePanning, this), this.graph.on("edge:unhandled:mousedown", this.preparePanning, this)), e.includes("rightMouseDown") && (this.onRightMouseDown = this.onRightMouseDown.bind(this), Zn.on(this.graph.container, "mousedown", this.onRightMouseDown)), e.includes("mouseWheel") && (this.mousewheelHandle = new nw(this.graph.container, this.onMouseWheel.bind(this), this.allowMouseWheel.bind(this)), this.mousewheelHandle.enable())); } stopListening() { const e = this.widgetOptions.eventTypes; e && (e.includes("leftMouseDown") && (this.graph.off("blank:mousedown", this.preparePanning, this), this.graph.off("node:unhandled:mousedown", this.preparePanning, this), this.graph.off("edge:unhandled:mousedown", this.preparePanning, this)), e.includes("rightMouseDown") && Zn.off(this.graph.container, "mousedown", this.onRightMouseDown), e.includes("mouseWheel") && this.mousewheelHandle && this.mousewheelHandle.disable()); } preparePanning({ e }) { const n = this.graph.getPlugin("selection"), o = n && n.allowRubberband(e, !0); (this.allowPanning(e, !0) || this.allowPanning(e) && !o) && this.startPanning(e); } allowPanning(e, n) { return this.pannable && Vr.isMatch(e, this.widgetOptions.modifiers, n); } startPanning(e) { const n = this.view.normalizeEvent(e); this.clientX = n.clientX, this.clientY = n.clientY, this.panning = !0, this.updateClassName(), Zn.on(document.body, { "mousemove.panning touchmove.panning": this.pan.bind(this), "mouseup.panning touchend.panning": this.stopPanning.bind(this), "mouseleave.panning": this.stopPanning.bind(this) }), Zn.on(window, "mouseup.panning", this.stopPanning.bind(this)); } pan(e) { const n = this.view.normalizeEvent(e), o = n.clientX - this.clientX, s = n.clientY - this.clientY; this.clientX = n.clientX, this.clientY = n.clientY, this.graph.translateBy(o, s); } // eslint-disable-next-line stopPanning(e) { this.panning = !1, this.updateClassName(), Zn.off(document.body, ".panning"), Zn.off(window, ".panning"); } updateClassName() { const e = this.view.container, n = this.view.prefixClassName("graph-panning"), o = this.view.prefixClassName("graph-pannable"); this.pannable ? this.panning ? (_t(e, n), Hn(e, o)) : (Hn(e, n), _t(e, o)) : (Hn(e, n), Hn(e, o)); } onRightMouseDown(e) { e.button === 2 && this.allowPanning(e, !0) && this.startPanning(e); } allowMouseWheel(e) { return this.pannable && !e.ctrlKey; } onMouseWheel(e, n, o) { e.ctrlKey || this.graph.translateBy(-n, -o); } autoPanning(e, n) { const s = this.graph.getGraphArea(); let r = 0, i = 0; e <= s.left + 10 && (r = -10), n <= s.top + 10 && (i = -10), e >= s.right - 10 && (r = 10), n >= s.bottom - 10 && (i = 10), (r !== 0 || i !== 0) && this.graph.translateBy(-r, -i); } enablePanning() { this.pannable || (this.widgetOptions.enabled = !0, this.updateClassName()); } disablePanning() { this.pannable && (this.widgetOptions.enabled = !1, this.updateClassName()); } dispose() { this.stopListening(); } } Ale([ zn.dispose() ], t8.prototype, "dispose", null); var Ple = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Zg extends zn { constructor() { super(...arguments), this.cumulatedFactor = 1; } get widgetOptions() { return this.options.mousewheel; } init() { this.container = this.graph.container, this.target = this.widgetOptions.global ? document : this.container, this.mousewheelHandle = new nw(this.target, this.onMouseWheel.bind(this), this.allowMouseWheel.bind(this)), this.widgetOptions.enabled && this.enable(!0); } get disabled() { return this.widgetOptions.enabled !== !0; } enable(e) { (this.disabled || e) && (this.widgetOptions.enabled = !0, this.mousewheelHandle.enable()); } disable() { this.disabled || (this.widgetOptions.enabled = !1, this.mousewheelHandle.disable()); } allowMouseWheel(e) { const n = this.widgetOptions.guard; return (n == null || n.call(e)) && Vr.isMatch(e, this.widgetOptions.modifiers); } onMouseWheel(e) { const n = this.widgetOptions.guard; if ((n == null || n.call(e)) && Vr.isMatch(e, this.widgetOptions.modifiers)) { const o = this.widgetOptions.factor || 1.2; this.currentScale == null && (this.startPos = { x: e.clientX, y: e.clientY }, this.currentScale = this.graph.transform.getScale().sx), e.deltaY < 0 ? this.currentScale < 0.15 ? this.cumulatedFactor = (this.currentScale + 0.01) / this.currentScale : this.cumulatedFactor = Math.round(this.currentScale * o * 20) / 20 / this.currentScale : this.currentScale <= 0.15 ? this.cumulatedFactor = (this.currentScale - 0.01) / this.currentScale : this.cumulatedFactor = Math.round(this.currentScale * (1 / o) * 20) / 20 / this.currentScale, this.cumulatedFactor = Math.max(0.01, Math.min(this.currentScale * this.cumulatedFactor, 160) / this.currentScale); const r = this.currentScale; let i = this.graph.transform.clampScale(r * this.cumulatedFactor); const l = this.widgetOptions.minScale || Number.MIN_SAFE_INTEGER, a = this.widgetOptions.maxScale || Number.MAX_SAFE_INTEGER; if (i = Mo(i, l, a), i !== r) if (this.widgetOptions.zoomAtMousePosition) { const u = !!this.graph.getPlugin("scroller") ? this.graph.clientToLocal(this.startPos) : this.graph.clientToGraph(this.startPos); this.graph.zoom(i, { absolute: !0, center: u.clone() }); } else this.graph.zoom(i, { absolute: !0 }); this.currentScale = null, this.cumulatedFactor = 1; } } dispose() { this.disable(); } } Ple([ uo.dispose() ], Zg.prototype, "dispose", null); var Nle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class n8 extends zn { init() { this.resetRenderArea = Hs(this.resetRenderArea, 200, { leading: !0 }), this.resetRenderArea(), this.startListening(); } startListening() { this.graph.on("translate", this.resetRenderArea, this), this.graph.on("scale", this.resetRenderArea, this), this.graph.on("resize", this.resetRenderArea, this); } stopListening() { this.graph.off("translate", this.resetRenderArea, this), this.graph.off("scale", this.resetRenderArea, this), this.graph.off("resize", this.resetRenderArea, this); } enableVirtualRender() { this.options.virtual = !0, this.resetRenderArea(); } disableVirtualRender() { this.options.virtual = !1, this.graph.renderer.setRenderArea(void 0); } resetRenderArea() { if (this.options.virtual) { const e = this.graph.getGraphArea(); this.graph.renderer.setRenderArea(e); } } dispose() { this.stopListening(); } } Nle([ zn.dispose() ], n8.prototype, "dispose", null); class Ile { constructor() { this.isFlushing = !1, this.isFlushPending = !1, this.scheduleId = 0, this.queue = [], this.frameInterval = 33, this.initialTime = Date.now(); } queueJob(e) { if (e.priority & ys.PRIOR) e.cb(); else { const n = this.findInsertionIndex(e); n >= 0 && this.queue.splice(n, 0, e); } } queueFlush() { !this.isFlushing && !this.isFlushPending && (this.isFlushPending = !0, this.scheduleJob()); } queueFlushSync() { !this.isFlushing && !this.isFlushPending && (this.isFlushPending = !0, this.flushJobsSync()); } clearJobs() { this.queue.length = 0, this.isFlushing = !1, this.isFlushPending = !1, this.cancelScheduleJob(); } flushJobs() { this.isFlushPending = !1, this.isFlushing = !0; const e = this.getCurrentTime(); let n; for (; (n = this.queue.shift()) && (n.cb(), !(this.getCurrentTime() - e >= this.frameInterval)); ) ; this.isFlushing = !1, this.queue.length && this.queueFlush(); } flushJobsSync() { this.isFlushPending = !1, this.isFlushing = !0; let e; for (; e = this.queue.shift(); ) try { e.cb(); } catch (n) { console.log(n); } this.isFlushing = !1; } findInsertionIndex(e) { let n = 0, o = this.queue.length, s = o - 1; const r = e.priority; for (; n <= s; ) { const i = (s - n >> 1) + n; r <= this.queue[i].priority ? n = i + 1 : (o = i, s = i - 1); } return o; } scheduleJob() { "requestIdleCallback" in window ? (this.scheduleId && this.cancelScheduleJob(), this.scheduleId = window.requestIdleCallback(this.flushJobs.bind(this), { timeout: 100 })) : (this.scheduleId && this.cancelScheduleJob(), this.scheduleId = window.setTimeout(this.flushJobs.bind(this))); } cancelScheduleJob() { "cancelIdleCallback" in window ? (this.scheduleId && window.cancelIdleCallback(this.scheduleId), this.scheduleId = 0) : (this.scheduleId && clearTimeout(this.scheduleId), this.scheduleId = 0); } getCurrentTime() { return typeof performance == "object" && typeof performance.now == "function" ? performance.now() : Date.now() - this.initialTime; } } var ys; (function(t) { t[t.RenderEdge = 2] = "RenderEdge", t[t.RenderNode = 4] = "RenderNode", t[t.Update = 8] = "Update", t[t.PRIOR = 1048576] = "PRIOR"; })(ys || (ys = {})); var Lle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Mn extends uo { get model() { return this.graph.model; } get container() { return this.graph.view.stage; } constructor(e) { super(), this.views = {}, this.willRemoveViews = {}, this.queue = new Ile(), this.graph = e, this.init(); } init() { this.startListening(), this.renderViews(this.model.getCells()); } startListening() { this.model.on("reseted", this.onModelReseted, this), this.model.on("cell:added", this.onCellAdded, this), this.model.on("cell:removed", this.onCellRemoved, this), this.model.on("cell:change:zIndex", this.onCellZIndexChanged, this), this.model.on("cell:change:visible", this.onCellVisibleChanged, this); } stopListening() { this.model.off("reseted", this.onModelReseted, this), this.model.off("cell:added", this.onCellAdded, this), this.model.off("cell:removed", this.onCellRemoved, this), this.model.off("cell:change:zIndex", this.onCellZIndexChanged, this), this.model.off("cell:change:visible", this.onCellVisibleChanged, this); } onModelReseted({ options: e }) { this.queue.clearJobs(), this.removeZPivots(), this.resetViews(), this.renderViews(this.model.getCells(), e); } onCellAdded({ cell: e, options: n }) { this.renderViews([e], n); } onCellRemoved({ cell: e }) { this.removeViews([e]); } onCellZIndexChanged({ cell: e, options: n }) { const o = this.views[e.id]; o && this.requestViewUpdate(o.view, Mn.FLAG_INSERT, n, ys.Update, !0); } onCellVisibleChanged({ cell: e, current: n }) { this.toggleVisible(e, !!n); } requestViewUpdate(e, n, o = {}, s = ys.Update, r = !0) { const i = e.cell.id, l = this.views[i]; if (!l) return; l.flag = n, l.options = o; const a = e.hasAction(n, ["translate", "resize", "rotate"]); e.isNodeView() && a && (s = ys.PRIOR, r = !1), this.queue.queueJob({ id: i, priority: s, cb: () => { this.renderViewInArea(e, n, o); } }), this.getEffectedEdges(e).forEach((u) => { this.requestViewUpdate(u.view, u.flag, o, s, !1); }), r && this.flush(); } setRenderArea(e) { this.renderArea = e, this.flushWaittingViews(); } isViewMounted(e) { if (e == null) return !1; const n = this.views[e.cell.id]; return n ? n.state === Mn.ViewState.MOUNTED : !1; } renderViews(e, n = {}) { e.sort((o, s) => o.isNode() && s.isEdge() ? -1 : 0), e.forEach((o) => { const s = o.id, r = this.views; let i = 0, l = r[s]; if (l) i = Mn.FLAG_INSERT; else { const a = this.createCellView(o); a && (a.graph = this.graph, i = Mn.FLAG_INSERT | a.getBootstrapFlag(), l = { view: a, flag: i, options: n, state: Mn.ViewState.CREATED }, this.views[s] = l); } l && this.requestViewUpdate(l.view, i, n, this.getRenderPriority(l.view), !1); }), this.flush(); } renderViewInArea(e, n, o = {}) { const s = e.cell, r = s.id, i = this.views[r]; if (!i) return; let l = 0; this.isUpdateable(e) ? (l = this.updateView(e, n, o), i.flag = l) : i.state === Mn.ViewState.MOUNTED ? (l = this.updateView(e, n, o), i.flag = l) : i.state = Mn.ViewState.WAITTING, l && s.isEdge() && !(l & e.getFlag(["source", "target"])) && this.queue.queueJob({ id: r, priority: ys.RenderEdge, cb: () => { this.updateView(e, n, o); } }); } removeViews(e) { e.forEach((n) => { const o = n.id, s = this.views[o]; s && (this.willRemoveViews[o] = s, delete this.views[o], this.queue.queueJob({ id: o, priority: this.getRenderPriority(s.view), cb: () => { this.removeView(s.view); } })); }), this.flush(); } flush() { this.graph.options.async ? this.queue.queueFlush() : this.queue.queueFlushSync(); } flushWaittingViews() { Object.values(this.views).forEach((e) => { if (e && e.state === Mn.ViewState.WAITTING) { const { view: n, flag: o, options: s } = e; this.requestViewUpdate(n, o, s, this.getRenderPriority(n), !1); } }), this.flush(); } updateView(e, n, o = {}) { if (e == null) return 0; if (_n.isCellView(e)) { if (n & Mn.FLAG_REMOVE) return this.removeView(e.cell), 0; n & Mn.FLAG_INSERT && (this.insertView(e), n ^= Mn.FLAG_INSERT); } return n ? e.confirmUpdate(n, o) : 0; } insertView(e) { const n = this.views[e.cell.id]; if (n) { const o = e.cell.getZIndex(), s = this.addZPivot(o); this.container.insertBefore(e.container, s), e.cell.isVisible() || this.toggleVisible(e.cell, !1), n.state = Mn.ViewState.MOUNTED, this.graph.trigger("view:mounted", { view: e }); } } resetViews() { this.willRemoveViews = Object.assign(Object.assign({}, this.views), this.willRemoveViews), Object.values(this.willRemoveViews).forEach((e) => { e && this.removeView(e.view); }), this.views = {}, this.willRemoveViews = {}; } removeView(e) { const n = e.cell, o = this.willRemoveViews[n.id]; o && e && (o.view.remove(), delete this.willRemoveViews[n.id], this.graph.trigger("view:unmounted", { view: e })); } toggleVisible(e, n) { const o = this.model.getConnectedEdges(e); for (let r = 0, i = o.length; r < i; r += 1) { const l = o[r]; if (n) { const a = l.getSourceCell(), c = l.getTargetCell(); if (a && !a.isVisible() || c && !c.isVisible()) continue; this.toggleVisible(l, !0); } else this.toggleVisible(l, !1); } const s = this.views[e.id]; s && An(s.view.container, { display: n ? "unset" : "none" }); } addZPivot(e = 0) { this.zPivots == null && (this.zPivots = {}); const n = this.zPivots; let o = n[e]; if (o) return o; o = n[e] = document.createComment(`z-index:${e + 1}`); let s = -1 / 0; for (const i in n) { const l = +i; l < e && l > s && (s = l, e - 1); } const r = this.container; if (s !== -1 / 0) { const i = n[s]; r.insertBefore(o, i.nextSibling); } else r.insertBefore(o, r.firstChild); return o; } removeZPivots() { this.zPivots && Object.values(this.zPivots).forEach((e) => { e && e.parentNode && e.parentNode.removeChild(e); }), this.zPivots = {}; } createCellView(e) { const n = { graph: this.graph }, o = this.graph.options.createCellView; if (o) { const r = dt(o, this.graph, e); if (r) return new r(e, n); if (r === null) return null; } const s = e.view; if (s != null && typeof s == "string") { const r = _n.registry.get(s); return r ? new r(e, n) : _n.registry.onNotFound(s); } return e.isNode() ? new bo(e, n) : e.isEdge() ? new Ms(e, n) : null; } getEffectedEdges(e) { const n = [], o = e.cell, s = this.model.getConnectedEdges(o); for (let r = 0, i = s.length; r < i; r += 1) { const l = s[r], a = this.views[l.id]; if (!a) continue; const c = a.view; if (!this.isViewMounted(c)) continue; const u = ["update"]; l.getTargetCell() === o && u.push("target"), l.getSourceCell() === o && u.push("source"), n.push({ id: l.id, view: c, flag: c.getFlag(u) }); } return n; } isUpdateable(e) { if (e.isNodeView()) { if (!this.renderArea) return !0; const n = e.cell; return this.renderArea.isIntersectWithRect(n.getBBox()); } if (e.isEdgeView()) { const n = e.cell, o = n.getSourceCell(), s = n.getTargetCell(); if (o) { const r = this.views[o.id]; if (r && !this.isViewMounted(r.view)) return !1; } if (s) { const r = this.views[s.id]; if (r && !this.isViewMounted(r.view)) return !1; } } return !0; } getRenderPriority(e) { return e.cell.isNode() ? ys.RenderNode : ys.RenderEdge; } dispose() { this.stopListening(); } } Lle([ uo.dispose() ], Mn.prototype, "dispose", null); (function(t) { t.FLAG_INSERT = 1 << 30, t.FLAG_REMOVE = 1 << 29, t.FLAG_RENDER = (1 << 26) - 1; })(Mn || (Mn = {})); (function(t) { (function(e) { e[e.CREATED = 0] = "CREATED", e[e.MOUNTED = 1] = "MOUNTED", e[e.WAITTING = 2] = "WAITTING"; })(t.ViewState || (t.ViewState = {})); })(Mn || (Mn = {})); var Rle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Jg extends zn { constructor() { super(...arguments), this.schedule = new Mn(this.graph); } requestViewUpdate(e, n, o = {}) { this.schedule.requestViewUpdate(e, n, o); } isViewMounted(e) { return this.schedule.isViewMounted(e); } setRenderArea(e) { this.schedule.setRenderArea(e); } findViewByElem(e) { if (e == null) return null; const n = this.options.container, o = typeof e == "string" ? n.querySelector(e) : e instanceof Element ? e : e[0]; if (o) { const s = this.graph.view.findAttr("data-cell-id", o); if (s) { const r = this.schedule.views; if (r[s]) return r[s].view; } } return null; } findViewByCell(e) { if (e == null) return null; const n = Pt.isCell(e) ? e.id : e, o = this.schedule.views; return o[n] ? o[n].view : null; } findViewsFromPoint(e) { const n = { x: e.x, y: e.y }; return this.model.getCells().map((o) => this.findViewByCell(o)).filter((o) => o != null ? Ft.getBBox(o.container, { target: this.view.stage }).containsPoint(n) : !1); } findEdgeViewsFromPoint(e, n = 5) { return this.model.getEdges().map((o) => this.findViewByCell(o)).filter((o) => { if (o != null) { const s = o.getClosestPoint(e); if (s) return s.distance(e) <= n; } return !1; }); } findViewsInArea(e, n = {}) { const o = Fe.create(e); return this.model.getCells().map((s) => this.findViewByCell(s)).filter((s) => { if (s) { if (n.nodeOnly && !s.isNodeView()) return !1; const r = Ft.getBBox(s.container, { target: this.view.stage }); return r.width === 0 ? r.inflate(1, 0) : r.height === 0 && r.inflate(0, 1), n.strict ? o.containsRect(r) : o.isIntersectWithRect(r); } return !1; }); } dispose() { this.schedule.dispose(); } } Rle([ zn.dispose() ], Jg.prototype, "dispose", null); var k1 = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class o8 extends zn { get cid() { return this.graph.view.cid; } get svg() { return this.view.svg; } get defs() { return this.view.defs; } isDefined(e) { return this.svg.getElementById(e) != null; } filter(e) { let n = e.id; const o = e.name; if (n || (n = `filter-${o}-${this.cid}-${af(JSON.stringify(e))}`), !this.isDefined(n)) { const s = Hi.registry.get(o); if (s == null) return Hi.registry.onNotFound(o); const r = s(e.args || {}), i = Object.assign(Object.assign({ x: -1, y: -1, width: 3, height: 3, filterUnits: "objectBoundingBox" }, e.attrs), { id: n }); vt.create(en.sanitize(r), i).appendTo(this.defs); } return n; } gradient(e) { let n = e.id; const o = e.type; if (n || (n = `gradient-${o}-${this.cid}-${af(JSON.stringify(e))}`), !this.isDefined(n)) { const r = e.stops.map((a) => { const c = a.opacity != null && Number.isFinite(a.opacity) ? a.opacity : 1; return `<stop offset="${a.offset}" stop-color="${a.color}" stop-opacity="${c}"/>`; }), i = `<${o}>${r.join("")}</${o}>`, l = Object.assign({ id: n }, e.attrs); vt.create(i, l).appendTo(this.defs); } return n; } marker(e) { const { id: n, refX: o, refY: s, markerUnits: r, markerOrient: i, tagName: l, children: a } = e, c = k1(e, ["id", "refX", "refY", "markerUnits", "markerOrient", "tagName", "children"]); let u = n; if (u || (u = `marker-${this.cid}-${af(JSON.stringify(e))}`), !this.isDefined(u)) { l !== "path" && delete c.d; const d = vt.create("marker", { refX: o, refY: s, id: u, overflow: "visible", orient: i ?? "auto", markerUnits: r || "userSpaceOnUse" }, a ? a.map((h) => { var { tagName: p } = h, m = k1(h, ["tagName"]); return vt.create(`${p}` || "path", ma(Object.assign(Object.assign({}, c), m))); }) : [vt.create(l || "path", ma(c))]); this.defs.appendChild(d.node); } return u; } remove(e) { const n = this.svg.getElementById(e); n && n.parentNode && n.parentNode.removeChild(n); } } class s8 extends zn { getClientMatrix() { return Vn(this.view.stage.getScreenCTM()); } /** * Returns coordinates of the graph viewport, relative to the window. */ getClientOffset() { const e = this.view.svg.getBoundingClientRect(); return new te(e.left, e.top); } /** * Returns coordinates of the graph viewport, relative to the document. */ getPageOffset() { return this.getClientOffset().translate(window.scrollX, window.scrollY); } snapToGrid(e, n) { return (typeof e == "number" ? this.clientToLocalPoint(e, n) : this.clientToLocalPoint(e.x, e.y)).snapToGrid(this.graph.getGridSize()); } localToGraphPoint(e, n) { const o = te.create(e, n); return Ft.transformPoint(o, this.graph.matrix()); } localToClientPoint(e, n) { const o = te.create(e, n); return Ft.transformPoint(o, this.getClientMatrix()); } localToPagePoint(e, n) { return (typeof e == "number" ? this.localToGraphPoint(e, n) : this.localToGraphPoint(e)).translate(this.getPageOffset()); } localToGraphRect(e, n, o, s) { const r = Fe.create(e, n, o, s); return Ft.transformRectangle(r, this.graph.matrix()); } localToClientRect(e, n, o, s) { const r = Fe.create(e, n, o, s); return Ft.transformRectangle(r, this.getClientMatrix()); } localToPageRect(e, n, o, s) { return (typeof e == "number" ? this.localToGraphRect(e, n, o, s) : this.localToGraphRect(e)).translate(this.getPageOffset()); } graphToLocalPoint(e, n) { const o = te.create(e, n); return Ft.transformPoint(o, this.graph.matrix().inverse()); } clientToLocalPoint(e, n) { const o = te.create(e, n); return Ft.transformPoint(o, this.getClientMatrix().inverse()); } clientToGraphPoint(e, n) { const o = te.create(e, n); return Ft.transformPoint(o, this.graph.matrix().multiply(this.getClientMatrix().inverse())); } pageToLocalPoint(e, n) { const s = te.create(e, n).diff(this.getPageOffset()); return this.graphToLocalPoint(s); } graphToLocalRect(e, n, o, s) { const r = Fe.create(e, n, o, s); return Ft.transformRectangle(r, this.graph.matrix().inverse()); } clientToLocalRect(e, n, o, s) { const r = Fe.create(e, n, o, s); return Ft.transformRectangle(r, this.getClientMatrix().inverse()); } clientToGraphRect(e, n, o, s) { const r = Fe.create(e, n, o, s); return Ft.transformRectangle(r, this.graph.matrix().multiply(this.getClientMatrix().inverse())); } pageToLocalRect(e, n, o, s) { const r = Fe.create(e, n, o, s), i = this.getPageOffset(); return r.x -= i.x, r.y -= i.y, this.graphToLocalRect(r); } } var Vle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Tu extends zn { constructor() { super(...arguments), this.highlights = {}; } init() { this.startListening(); } startListening() { this.graph.on("cell:highlight", this.onCellHighlight, this), this.graph.on("cell:unhighlight", this.onCellUnhighlight, this); } stopListening() { this.graph.off("cell:highlight", this.onCellHighlight, this), this.graph.off("cell:unhighlight", this.onCellUnhighlight, this); } onCellHighlight({ view: e, magnet: n, options: o = {} }) { const s = this.resolveHighlighter(o); if (!s) return; const r = this.getHighlighterId(n, s); if (!this.highlights[r]) { const i = s.highlighter; i.highlight(e, n, Object.assign({}, s.args)), this.highlights[r] = { cellView: e, magnet: n, highlighter: i, args: s.args }; } } onCellUnhighlight({ magnet: e, options: n = {} }) { const o = this.resolveHighlighter(n); if (!o) return; const s = this.getHighlighterId(e, o); this.unhighlight(s); } resolveHighlighter(e) { const n = this.options; let o = e.highlighter; if (o == null) { const l = e.type; o = l && n.highlighting[l] || n.highlighting.default; } if (o == null) return null; const s = typeof o == "string" ? { name: o } : o, r = s.name, i = xs.registry.get(r); return i == null ? xs.registry.onNotFound(r) : (xs.check(r, i), { name: r, highlighter: i, args: s.args || {} }); } getHighlighterId(e, n) { return Bg(e), n.name + e.id + JSON.stringify(n.args); } unhighlight(e) { const n = this.highlights[e]; n && (n.highlighter.unhighlight(n.cellView, n.magnet, n.args), delete this.highlights[e]); } dispose() { Object.keys(this.highlights).forEach((e) => this.unhighlight(e)), this.stopListening(); } } Vle([ Tu.dispose() ], Tu.prototype, "dispose", null); var Ble = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class r8 extends zn { getScroller() { const e = this.graph.getPlugin("scroller"); return e && e.options.enabled ? e : null; } getContainer() { const e = this.getScroller(); return e ? e.container.parentElement : this.graph.container.parentElement; } getSensorTarget() { const e = this.options.autoResize; if (e) return typeof e == "boolean" ? this.getContainer() : e; } init() { if (this.options.autoResize) { const n = this.getSensorTarget(); n && Cu.bind(n, () => { const o = n.offsetWidth, s = n.offsetHeight; this.resize(o, s); }); } } resize(e, n) { const o = this.getScroller(); o ? o.resize(e, n) : this.graph.transform.resize(e, n); } dispose() { Cu.clear(this.graph.container); } } Ble([ zn.dispose() ], r8.prototype, "dispose", null); var zle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Le extends kn { get container() { return this.options.container; } get [Symbol.toStringTag]() { return Le.toStringTag; } constructor(e) { super(), this.installedPlugins = /* @__PURE__ */ new Set(), this.options = Ea.get(e), this.css = new Zh(this), this.view = new us(this), this.defs = new o8(this), this.coord = new s8(this), this.transform = new e8(this), this.highlight = new Tu(this), this.grid = new Yg(this), this.background = new Xg(this), this.options.model ? this.model = this.options.model : (this.model = new To(), this.model.graph = this), this.renderer = new Jg(this), this.panning = new t8(this), this.mousewheel = new Zg(this), this.virtualRender = new n8(this), this.size = new r8(this); } // #region model isNode(e) { return e.isNode(); } isEdge(e) { return e.isEdge(); } resetCells(e, n = {}) { return this.model.resetCells(e, n), this; } clearCells(e = {}) { return this.model.clear(e), this; } toJSON(e = {}) { return this.model.toJSON(e); } parseJSON(e) { return this.model.parseJSON(e); } fromJSON(e, n = {}) { return this.model.fromJSON(e, n), this; } getCellById(e) { return this.model.getCell(e); } addNode(e, n = {}) { return this.model.addNode(e, n); } addNodes(e, n = {}) { return this.addCell(e.map((o) => Cn.isNode(o) ? o : this.createNode(o)), n); } createNode(e) { return this.model.createNode(e); } removeNode(e, n = {}) { return this.model.removeCell(e, n); } addEdge(e, n = {}) { return this.model.addEdge(e, n); } addEdges(e, n = {}) { return this.addCell(e.map((o) => pn.isEdge(o) ? o : this.createEdge(o)), n); } removeEdge(e, n = {}) { return this.model.removeCell(e, n); } createEdge(e) { return this.model.createEdge(e); } addCell(e, n = {}) { return this.model.addCell(e, n), this; } removeCell(e, n = {}) { return this.model.removeCell(e, n); } removeCells(e, n = {}) { return this.model.removeCells(e, n); } removeConnectedEdges(e, n = {}) { return this.model.removeConnectedEdges(e, n); } disconnectConnectedEdges(e, n = {}) { return this.model.disconnectConnectedEdges(e, n), this; } hasCell(e) { return this.model.has(e); } getCells() { return this.model.getCells(); } getCellCount() { return this.model.total(); } /** * Returns all the nodes in the graph. */ getNodes() { return this.model.getNodes(); } /** * Returns all the edges in the graph. */ getEdges() { return this.model.getEdges(); } /** * Returns all outgoing edges for the node. */ getOutgoingEdges(e) { return this.model.getOutgoingEdges(e); } /** * Returns all incoming edges for the node. */ getIncomingEdges(e) { return this.model.getIncomingEdges(e); } /** * Returns edges connected with cell. */ getConnectedEdges(e, n = {}) { return this.model.getConnectedEdges(e, n); } /** * Returns an array of all the roots of the graph. */ getRootNodes() { return this.model.getRoots(); } /** * Returns an array of all the leafs of the graph. */ getLeafNodes() { return this.model.getLeafs(); } /** * Returns `true` if the node is a root node, i.e. * there is no edges coming to the node. */ isRootNode(e) { return this.model.isRoot(e); } /** * Returns `true` if the node is a leaf node, i.e. * there is no edges going out from the node. */ isLeafNode(e) { return this.model.isLeaf(e); } /** * Returns all the neighbors of node in the graph. Neighbors are all * the nodes connected to node via either incoming or outgoing edge. */ getNeighbors(e, n = {}) { return this.model.getNeighbors(e, n); } /** * Returns `true` if `cell2` is a neighbor of `cell1`. */ isNeighbor(e, n, o = {}) { return this.model.isNeighbor(e, n, o); } getSuccessors(e, n = {}) { return this.model.getSuccessors(e, n); } /** * Returns `true` if `cell2` is a successor of `cell1`. */ isSuccessor(e, n, o = {}) { return this.model.isSuccessor(e, n, o); } getPredecessors(e, n = {}) { return this.model.getPredecessors(e, n); } /** * Returns `true` if `cell2` is a predecessor of `cell1`. */ isPredecessor(e, n, o = {}) { return this.model.isPredecessor(e, n, o); } getCommonAncestor(...e) { return this.model.getCommonAncestor(...e); } /** * Returns an array of cells that result from finding nodes/edges that * are connected to any of the cells in the cells array. This function * loops over cells and if the current cell is a edge, it collects its * source/target nodes; if it is an node, it collects its incoming and * outgoing edges if both the edge terminal (source/target) are in the * cells array. */ getSubGraph(e, n = {}) { return this.model.getSubGraph(e, n); } /** * Clones the whole subgraph (including all the connected links whose * source/target is in the subgraph). If `options.deep` is `true`, also * take into account all the embedded cells of all the subgraph cells. * * Returns a map of the form: { [original cell ID]: [clone] }. */ cloneSubGraph(e, n = {}) { return this.model.cloneSubGraph(e, n); } cloneCells(e) { return this.model.cloneCells(e); } getNodesFromPoint(e, n) { return this.model.getNodesFromPoint(e, n); } getNodesInArea(e, n, o, s, r) { return this.model.getNodesInArea(e, n, o, s, r); } getNodesUnderNode(e, n = {}) { return this.model.getNodesUnderNode(e, n); } searchCell(e, n, o = {}) { return this.model.search(e, n, o), this; } /** * * Returns an array of IDs of nodes on the shortest * path between source and target. */ getShortestPath(e, n, o = {}) { return this.model.getShortestPath(e, n, o); } /** * Returns the bounding box that surrounds all cells in the graph. */ getAllCellsBBox() { return this.model.getAllCellsBBox(); } /** * Returns the bounding box that surrounds all the given cells. */ getCellsBBox(e, n = {}) { return this.model.getCellsBBox(e, n); } startBatch(e, n = {}) { this.model.startBatch(e, n); } stopBatch(e, n = {}) { this.model.stopBatch(e, n); } batchUpdate(e, n, o) { const s = typeof e == "string" ? e : "update", r = typeof e == "string" ? n : e, i = typeof n == "function" ? o : n; this.startBatch(s, i); const l = r(); return this.stopBatch(s, i), l; } updateCellId(e, n) { return this.model.updateCellId(e, n); } // #endregion // #region view findView(e) { return Pt.isCell(e) ? this.findViewByCell(e) : this.findViewByElem(e); } findViews(e) { return Fe.isRectangleLike(e) ? this.findViewsInArea(e) : te.isPointLike(e) ? this.findViewsFromPoint(e) : []; } findViewByCell(e) { return this.renderer.findViewByCell(e); } findViewByElem(e) { return this.renderer.findViewByElem(e); } findViewsFromPoint(e, n) { const o = typeof e == "number" ? { x: e, y: n } : e; return this.renderer.findViewsFromPoint(o); } findViewsInArea(e, n, o, s, r) { const i = typeof e == "number" ? { x: e, y: n, width: o, height: s } : e, l = typeof e == "number" ? r : n; return this.renderer.findViewsInArea(i, l); } matrix(e) { return typeof e > "u" ? this.transform.getMatrix() : (this.transform.setMatrix(e), this); } resize(e, n) { const o = this.getPlugin("scroller"); return o ? o.resize(e, n) : this.transform.resize(e, n), this; } scale(e, n = e, o = 0, s = 0) { return typeof e > "u" ? this.transform.getScale() : (this.transform.scale(e, n, o, s), this); } zoom(e, n) { const o = this.getPlugin("scroller"); if (o) { if (typeof e > "u") return o.zoom(); o.zoom(e, n); } else { if (typeof e > "u") return this.transform.getZoom(); this.transform.zoom(e, n); } return this; } zoomTo(e, n = {}) { const o = this.getPlugin("scroller"); return o ? o.zoom(e, Object.assign(Object.assign({}, n), { absolute: !0 })) : this.transform.zoom(e, Object.assign(Object.assign({}, n), { absolute: !0 })), this; } zoomToRect(e, n = {}) { const o = this.getPlugin("scroller"); return o ? o.zoomToRect(e, n) : this.transform.zoomToRect(e, n), this; } zoomToFit(e = {}) { const n = this.getPlugin("scroller"); return n ? n.zoomToFit(e) : this.transform.zoomToFit(e), this; } rotate(e, n, o) { return typeof e > "u" ? this.transform.getRotation() : (this.transform.rotate(e, n, o), this); } translate(e, n) { return typeof e > "u" ? this.transform.getTranslation() : (this.transform.translate(e, n), this); } translateBy(e, n) { const o = this.translate(), s = o.tx + e, r = o.ty + n; return this.translate(s, r); } getGraphArea() { return this.transform.getGraphArea(); } getContentArea(e = {}) { return this.transform.getContentArea(e); } getContentBBox(e = {}) { return this.transform.getContentBBox(e); } fitToContent(e, n, o, s) { return this.transform.fitToContent(e, n, o, s); } scaleContentToFit(e = {}) { return this.transform.scaleContentToFit(e), this; } /** * Position the center of graph to the center of the viewport. */ center(e) { return this.centerPoint(e); } centerPoint(e, n, o) { const s = this.getPlugin("scroller"); return s ? s.centerPoint(e, n, o) : this.transform.centerPoint(e, n), this; } centerContent(e) { const n = this.getPlugin("scroller"); return n ? n.centerContent(e) : this.transform.centerContent(e), this; } centerCell(e, n) { const o = this.getPlugin("scroller"); return o ? o.centerCell(e, n) : this.transform.centerCell(e), this; } positionPoint(e, n, o, s = {}) { const r = this.getPlugin("scroller"); return r ? r.positionPoint(e, n, o, s) : this.transform.positionPoint(e, n, o), this; } positionRect(e, n, o) { const s = this.getPlugin("scroller"); return s ? s.positionRect(e, n, o) : this.transform.positionRect(e, n), this; } positionCell(e, n, o) { const s = this.getPlugin("scroller"); return s ? s.positionCell(e, n, o) : this.transform.positionCell(e, n), this; } positionContent(e, n) { const o = this.getPlugin("scroller"); return o ? o.positionContent(e, n) : this.transform.positionContent(e, n), this; } snapToGrid(e, n) { return this.coord.snapToGrid(e, n); } pageToLocal(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.pageToLocalRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.pageToLocalRect(e, n, o, s) : this.coord.pageToLocalPoint(e, n); } localToPage(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.localToPageRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.localToPageRect(e, n, o, s) : this.coord.localToPagePoint(e, n); } clientToLocal(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.clientToLocalRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.clientToLocalRect(e, n, o, s) : this.coord.clientToLocalPoint(e, n); } localToClient(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.localToClientRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.localToClientRect(e, n, o, s) : this.coord.localToClientPoint(e, n); } localToGraph(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.localToGraphRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.localToGraphRect(e, n, o, s) : this.coord.localToGraphPoint(e, n); } graphToLocal(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.graphToLocalRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.graphToLocalRect(e, n, o, s) : this.coord.graphToLocalPoint(e, n); } clientToGraph(e, n, o, s) { return Fe.isRectangleLike(e) ? this.coord.clientToGraphRect(e) : typeof e == "number" && typeof n == "number" && typeof o == "number" && typeof s == "number" ? this.coord.clientToGraphRect(e, n, o, s) : this.coord.clientToGraphPoint(e, n); } // #endregion // #region defs defineFilter(e) { return this.defs.filter(e); } defineGradient(e) { return this.defs.gradient(e); } defineMarker(e) { return this.defs.marker(e); } // #endregion // #region grid getGridSize() { return this.grid.getGridSize(); } setGridSize(e) { return this.grid.setGridSize(e), this; } showGrid() { return this.grid.show(), this; } hideGrid() { return this.grid.hide(), this; } clearGrid() { return this.grid.clear(), this; } drawGrid(e) { return this.grid.draw(e), this; } // #endregion // #region background updateBackground() { return this.background.update(), this; } drawBackground(e, n) { const o = this.getPlugin("scroller"); return o != null && (this.options.background == null || !n) ? o.drawBackground(e, n) : this.background.draw(e), this; } clearBackground(e) { const n = this.getPlugin("scroller"); return n != null && (this.options.background == null || !e) ? n.clearBackground(e) : this.background.clear(), this; } // #endregion // #region virtual-render enableVirtualRender() { return this.virtualRender.enableVirtualRender(), this; } disableVirtualRender() { return this.virtualRender.disableVirtualRender(), this; } // #endregion // #region mousewheel isMouseWheelEnabled() { return !this.mousewheel.disabled; } enableMouseWheel() { return this.mousewheel.enable(), this; } disableMouseWheel() { return this.mousewheel.disable(), this; } toggleMouseWheel(e) { return e == null ? this.isMouseWheelEnabled() ? this.disableMouseWheel() : this.enableMouseWheel() : e ? this.enableMouseWheel() : this.disableMouseWheel(), this; } // #endregion // #region panning isPannable() { const e = this.getPlugin("scroller"); return e ? e.isPannable() : this.panning.pannable; } enablePanning() { const e = this.getPlugin("scroller"); return e ? e.enablePanning() : this.panning.enablePanning(), this; } disablePanning() { const e = this.getPlugin("scroller"); return e ? e.disablePanning() : this.panning.disablePanning(), this; } togglePanning(e) { return e == null ? this.isPannable() ? this.disablePanning() : this.enablePanning() : e !== this.isPannable() && (e ? this.enablePanning() : this.disablePanning()), this; } // #endregion // #region plugin use(e, ...n) { return this.installedPlugins.has(e) || (this.installedPlugins.add(e), e.init(this, ...n)), this; } getPlugin(e) { return Array.from(this.installedPlugins).find((n) => n.name === e); } getPlugins(e) { return Array.from(this.installedPlugins).filter((n) => e.includes(n.name)); } enablePlugins(e) { let n = e; Array.isArray(n) || (n = [n]); const o = this.getPlugins(n); return o == null || o.forEach((s) => { var r; (r = s == null ? void 0 : s.enable) === null || r === void 0 || r.call(s); }), this; } disablePlugins(e) { let n = e; Array.isArray(n) || (n = [n]); const o = this.getPlugins(n); return o == null || o.forEach((s) => { var r; (r = s == null ? void 0 : s.disable) === null || r === void 0 || r.call(s); }), this; } isPluginEnabled(e) { var n; const o = this.getPlugin(e); return (n = o == null ? void 0 : o.isEnabled) === null || n === void 0 ? void 0 : n.call(o); } disposePlugins(e) { let n = e; Array.isArray(n) || (n = [n]); const o = this.getPlugins(n); return o == null || o.forEach((s) => { s.dispose(); }), this; } // #endregion // #region dispose dispose() { this.clearCells(), this.off(), this.css.dispose(), this.defs.dispose(), this.grid.dispose(), this.coord.dispose(), this.transform.dispose(), this.highlight.dispose(), this.background.dispose(), this.mousewheel.dispose(), this.panning.dispose(), this.view.dispose(), this.renderer.dispose(), this.installedPlugins.forEach((e) => { e.dispose(); }); } } zle([ kn.dispose() ], Le.prototype, "dispose", null); (function(t) { t.View = us, t.Renderer = Jg, t.MouseWheel = Zg, t.DefsManager = o8, t.GridManager = Yg, t.CoordManager = s8, t.TransformManager = e8, t.HighlightManager = Tu, t.BackgroundManager = Xg; })(Le || (Le = {})); (function(t) { t.toStringTag = `X6.${t.name}`; function e(n) { if (n == null) return !1; if (n instanceof t) return !0; const o = n[Symbol.toStringTag]; return o == null || o === t.toStringTag; } t.isGraph = e; })(Le || (Le = {})); (function(t) { function e(n, o) { const s = n instanceof HTMLElement ? new t({ container: n }) : new t(n); return o != null && s.fromJSON(o), s; } t.render = e; })(Le || (Le = {})); (function(t) { t.registerNode = Cn.registry.register, t.registerEdge = pn.registry.register, t.registerView = _n.registry.register, t.registerAttr = cs.registry.register, t.registerGrid = Ds.registry.register, t.registerFilter = Hi.registry.register, t.registerNodeTool = Ki.registry.register, t.registerEdgeTool = qi.registry.register, t.registerBackground = wa.registry.register, t.registerHighlighter = xs.registry.register, t.registerPortLayout = Tr.registry.register, t.registerPortLabelLayout = ji.registry.register, t.registerMarker = nr.registry.register, t.registerRouter = Fs.registry.register, t.registerConnector = Or.registry.register, t.registerAnchor = Ui.registry.register, t.registerEdgeAnchor = Gi.registry.register, t.registerConnectionPoint = Yi.registry.register; })(Le || (Le = {})); (function(t) { t.unregisterNode = Cn.registry.unregister, t.unregisterEdge = pn.registry.unregister, t.unregisterView = _n.registry.unregister, t.unregisterAttr = cs.registry.unregister, t.unregisterGrid = Ds.registry.unregister, t.unregisterFilter = Hi.registry.unregister, t.unregisterNodeTool = Ki.registry.unregister, t.unregisterEdgeTool = qi.registry.unregister, t.unregisterBackground = wa.registry.unregister, t.unregisterHighlighter = xs.registry.unregister, t.unregisterPortLayout = Tr.registry.unregister, t.unregisterPortLabelLayout = ji.registry.unregister, t.unregisterMarker = nr.registry.unregister, t.unregisterRouter = Fs.registry.unregister, t.unregisterConnector = Or.registry.unregister, t.unregisterAnchor = Ui.registry.unregister, t.unregisterEdgeAnchor = Gi.registry.unregister, t.unregisterConnectionPoint = Yi.registry.unregister; })(Le || (Le = {})); var Dle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class Ji extends Cn { } (function(t) { class e extends bo { init() { super.init(), this.cell.on("change:*", ({ key: o }) => { const s = t.shapeMaps[this.cell.shape]; if (s) { const { effect: r } = s; (!r || r.includes(o)) && this.renderHTMLComponent(); } }); } confirmUpdate(o) { const s = super.confirmUpdate(o); return this.handleAction(s, e.action, () => this.renderHTMLComponent()); } renderHTMLComponent() { const o = this.selectors && this.selectors.foContent; if (o) { Wa(o); const s = t.shapeMaps[this.cell.shape]; if (!s) return; let { html: r } = s; typeof r == "function" && (r = r(this.cell)), r && (typeof r == "string" ? o.innerHTML = r : Gr(o, r)); } } } t.View = e, function(n) { n.action = "html", n.config({ bootstrap: [n.action], actions: { html: n.action } }), bo.registry.register("html-view", n, !0); }(e = t.View || (t.View = {})); })(Ji || (Ji = {})); (function(t) { t.config({ view: "html-view", markup: [ { tagName: "rect", selector: "body" }, Object.assign({}, en.getForeignObjectMarkup()), { tagName: "text", selector: "label" } ], attrs: { body: { fill: "none", stroke: "none", refWidth: "100%", refHeight: "100%" }, fo: { refWidth: "100%", refHeight: "100%" } } }), Cn.registry.register("html", t, !0); })(Ji || (Ji = {})); (function(t) { t.shapeMaps = {}; function e(n) { const { shape: o, html: s, effect: r, inherit: i } = n, l = Dle(n, ["shape", "html", "effect", "inherit"]); if (!o) throw new Error("should specify shape in config"); t.shapeMaps[o] = { html: s, effect: r }, Le.registerNode(o, Object.assign({ inherit: i || "html" }, l), !0); } t.register = e; })(Ji || (Ji = {})); var Fle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }, Hle = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class i8 extends jt { get model() { return this.graph.model; } get containerClassName() { return this.prefixClassName("widget-snapline"); } get verticalClassName() { return `${this.containerClassName}-vertical`; } get horizontalClassName() { return `${this.containerClassName}-horizontal`; } constructor(e) { super(); const { graph: n } = e, o = Hle(e, ["graph"]); this.graph = n, this.options = Object.assign({}, o), this.offset = { x: 0, y: 0 }, this.render(), this.disabled || this.startListening(); } get disabled() { return this.options.enabled !== !0; } enable() { this.disabled && (this.options.enabled = !0, this.startListening()); } disable() { this.disabled || (this.options.enabled = !1, this.stopListening()); } setFilter(e) { this.options.filter = e; } render() { const e = this.containerWrapper = new vt("svg"), n = this.horizontal = new vt("line"), o = this.vertical = new vt("line"); e.addClass(this.containerClassName), n.addClass(this.horizontalClassName), o.addClass(this.verticalClassName), e.setAttribute("width", "100%"), e.setAttribute("height", "100%"), n.setAttribute("display", "none"), o.setAttribute("display", "none"), e.append([n, o]), this.options.className && e.addClass(this.options.className), this.container = this.containerWrapper.node; } startListening() { this.stopListening(), this.graph.on("node:mousedown", this.captureCursorOffset, this), this.graph.on("node:mousemove", this.snapOnMoving, this), this.model.on("batch:stop", this.onBatchStop, this), this.delegateDocumentEvents({ mouseup: "hide", touchend: "hide" }); } stopListening() { this.graph.off("node:mousedown", this.captureCursorOffset, this), this.graph.off("node:mousemove", this.snapOnMoving, this), this.model.off("batch:stop", this.onBatchStop, this), this.undelegateDocumentEvents(); } onBatchStop({ name: e, data: n }) { e === "resize" && this.snapOnResizing(n.cell, n); } captureCursorOffset({ view: e, x: n, y: o }) { const s = e.getDelegatedView(); if (s && this.isNodeMovable(s)) { const r = e.cell.getPosition(); this.offset = { x: n - r.x, y: o - r.y }; } } isNodeMovable(e) { return e && e.cell.isNode() && e.can("nodeMovable"); } getRestrictArea(e) { const n = this.graph.options.translating.restrict, o = typeof n == "function" ? dt(n, this.graph, e) : n; return typeof o == "number" ? this.graph.transform.getGraphArea().inflate(o) : o === !0 ? this.graph.transform.getGraphArea() : o || null; } snapOnResizing(e, n) { if (this.options.resizing && !n.snapped && n.ui && n.direction && n.trueDirection) { const o = this.graph.renderer.findViewByCell(e); if (o && o.cell.isNode()) { const s = e.getBBox(), r = s.bbox(e.getAngle()), i = r.getTopLeft(), l = r.getBottomRight(), a = Ut.normalize(e.getAngle()), c = this.options.tolerance || 0; let u, d, h, p, m, g; const v = { vertical: 0, horizontal: 0 }, y = n.direction, w = n.trueDirection, b = n.relativeDirection; w.indexOf("right") !== -1 ? v.vertical = l.x : v.vertical = i.x, w.indexOf("bottom") !== -1 ? v.horizontal = l.y : v.horizontal = i.y, this.model.getNodes().some((I) => { if (this.isIgnored(e, I)) return !1; const V = I.getBBox().bbox(I.getAngle()), F = V.getTopLeft(), L = V.getBottomRight(), N = { vertical: [F.x, L.x], horizontal: [F.y, L.y] }, _ = {}; return Object.keys(N).forEach((D) => { const z = D, U = N[z].map((Y) => ({ position: Y, distance: Math.abs(Y - v[z]) })).filter((Y) => Y.distance <= c); _[z] = vp(U, (Y) => Y.distance); }), u == null && _.vertical.length > 0 && (u = _.vertical[0].position, d = Math.min(r.y, V.y), h = Math.max(l.y, L.y) - d), p == null && _.horizontal.length > 0 && (p = _.horizontal[0].position, m = Math.min(r.x, V.x), g = Math.max(l.x, L.x) - m), u != null && p != null; }), this.hide(); let C = 0, S = 0; (p != null || u != null) && (u != null && (C = w.indexOf("right") !== -1 ? u - l.x : i.x - u), p != null && (S = w.indexOf("bottom") !== -1 ? p - l.y : i.y - p)); let k = 0, E = 0; if (a % 90 === 0) a === 90 || a === 270 ? (k = S, E = C) : (k = C, E = S); else { const I = a >= 0 && a < 90 ? 1 : a >= 90 && a < 180 ? 4 : a >= 180 && a < 270 ? 3 : 2; p != null && u != null && (C < S ? (S = 0, p = void 0) : (C = 0, u = void 0)); const V = Ut.toRad(a % 90); C && (k = I === 3 ? C / Math.cos(V) : C / Math.sin(V)), S && (E = I === 3 ? S / Math.cos(V) : S / Math.sin(V)); const F = I === 1 || I === 3; switch (b) { case "top": case "bottom": E = S ? S / (F ? Math.cos(V) : Math.sin(V)) : C / (F ? Math.sin(V) : Math.cos(V)); break; case "left": case "right": k = C ? C / (F ? Math.cos(V) : Math.sin(V)) : S / (F ? Math.sin(V) : Math.cos(V)); break; } } switch (b) { case "top": case "bottom": k = 0; break; case "left": case "right": E = 0; break; } const $ = this.graph.getGridSize(); let T = Math.max(s.width + k, $), P = Math.max(s.height + E, $); n.minWidth && n.minWidth > $ && (T = Math.max(T, n.minWidth)), n.minHeight && n.minHeight > $ && (P = Math.max(P, n.minHeight)), n.maxWidth && (T = Math.min(T, n.maxWidth)), n.maxHeight && (P = Math.min(P, n.maxHeight)), n.preserveAspectRatio && (E < k ? P = T * (s.height / s.width) : T = P * (s.width / s.height)), (T !== s.width || P !== s.height) && (e.resize(T, P, { direction: y, relativeDirection: b, trueDirection: w, snapped: !0, snaplines: this.cid, restrict: this.getRestrictArea(o) }), h && (h += P - s.height), g && (g += T - s.width)); const A = e.getBBox().bbox(a); u && Math.abs(A.x - u) > 1 && Math.abs(A.width + A.x - u) > 1 && (u = void 0), p && Math.abs(A.y - p) > 1 && Math.abs(A.height + A.y - p) > 1 && (p = void 0), this.update({ verticalLeft: u, verticalTop: d, verticalHeight: h, horizontalTop: p, horizontalLeft: m, horizontalWidth: g }); } } } snapOnMoving({ view: e, e: n, x: o, y: s }) { const r = e.getEventData(n).delegatedView || e; if (!this.isNodeMovable(r)) return; const i = r.cell, l = i.getSize(), a = i.getPosition(), c = new Fe(o - this.offset.x, s - this.offset.y, l.width, l.height), u = i.getAngle(), d = c.getCenter(), h = c.bbox(u), p = h.getTopLeft(), m = h.getBottomRight(), g = this.options.tolerance || 0; let v, y, w, b, C, S, k = 0, E = 0; if (this.model.getNodes().some(($) => { if (this.isIgnored(i, $)) return !1; const T = $.getBBox().bbox($.getAngle()), P = T.getCenter(), A = T.getTopLeft(), I = T.getBottomRight(); return v == null && (Math.abs(P.x - d.x) < g ? (v = P.x, k = 0.5) : Math.abs(A.x - p.x) < g ? (v = A.x, k = 0) : Math.abs(A.x - m.x) < g ? (v = A.x, k = 1) : Math.abs(I.x - m.x) < g ? (v = I.x, k = 1) : Math.abs(I.x - p.x) < g && (v = I.x), v != null && (y = Math.min(h.y, T.y), w = Math.max(m.y, I.y) - y)), b == null && (Math.abs(P.y - d.y) < g ? (b = P.y, E = 0.5) : Math.abs(A.y - p.y) < g ? b = A.y : Math.abs(A.y - m.y) < g ? (b = A.y, E = 1) : Math.abs(I.y - m.y) < g ? (b = I.y, E = 1) : Math.abs(I.y - p.y) < g && (b = I.y), b != null && (C = Math.min(h.x, T.x), S = Math.max(m.x, I.x) - C)), v != null && b != null; }), this.hide(), b != null || v != null) { b != null && (h.y = b - E * h.height), v != null && (h.x = v - k * h.width); const $ = h.getCenter(), T = $.x - c.width / 2, P = $.y - c.height / 2, A = T - a.x, I = P - a.y; (A !== 0 || I !== 0) && (i.translate(A, I, { snapped: !0, restrict: this.getRestrictArea(r) }), S && (S += A), w && (w += I)), this.update({ verticalLeft: v, verticalTop: y, verticalHeight: w, horizontalTop: b, horizontalLeft: C, horizontalWidth: S }); } } isIgnored(e, n) { return n.id === e.id || n.isDescendantOf(e) || !this.filter(n); } filter(e) { const n = this.options.filter; return Array.isArray(n) ? n.some((o) => typeof o == "string" ? e.shape === o : e.id === o.id) : typeof n == "function" ? dt(n, this.graph, e) : !0; } update(e) { if (e.horizontalTop) { const n = this.graph.localToGraph(new te(e.horizontalLeft, e.horizontalTop)), o = this.graph.localToGraph(new te(e.horizontalLeft + e.horizontalWidth, e.horizontalTop)); this.horizontal.setAttributes({ x1: this.options.sharp ? `${n.x}` : "0", y1: `${n.y}`, x2: this.options.sharp ? `${o.x}` : "100%", y2: `${o.y}`, display: "inherit" }); } else this.horizontal.setAttribute("display", "none"); if (e.verticalLeft) { const n = this.graph.localToGraph(new te(e.verticalLeft, e.verticalTop)), o = this.graph.localToGraph(new te(e.verticalLeft, e.verticalTop + e.verticalHeight)); this.vertical.setAttributes({ x1: `${n.x}`, y1: this.options.sharp ? `${n.y}` : "0", x2: `${o.x}`, y2: this.options.sharp ? `${o.y}` : "100%", display: "inherit" }); } else this.vertical.setAttribute("display", "none"); this.show(); } resetTimer() { this.timer && (clearTimeout(this.timer), this.timer = null); } show() { return this.resetTimer(), this.container.parentNode == null && this.graph.container.appendChild(this.container), this; } hide() { this.resetTimer(), this.vertical.setAttribute("display", "none"), this.horizontal.setAttribute("display", "none"); const e = this.options.clean, n = typeof e == "number" ? e : e !== !1 ? 3e3 : 0; return n > 0 && (this.timer = window.setTimeout(() => { this.container.parentNode !== null && this.unmount(); }, n)), this; } onRemove() { this.stopListening(), this.hide(); } dispose() { this.remove(); } } Fle([ jt.dispose() ], i8.prototype, "dispose", null); const jle = `.x6-widget-snapline { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; } .x6-widget-snapline-vertical, .x6-widget-snapline-horizontal { stroke: #2ecc71; stroke-width: 1px; } `; Le.prototype.isSnaplineEnabled = function() { const t = this.getPlugin("snapline"); return t ? t.isEnabled() : !1; }; Le.prototype.enableSnapline = function() { const t = this.getPlugin("snapline"); return t && t.enable(), this; }; Le.prototype.disableSnapline = function() { const t = this.getPlugin("snapline"); return t && t.disable(), this; }; Le.prototype.toggleSnapline = function() { const t = this.getPlugin("snapline"); return t && t.toggleEnabled(), this; }; Le.prototype.hideSnapline = function() { const t = this.getPlugin("snapline"); return t && t.hide(), this; }; Le.prototype.setSnaplineFilter = function(t) { const e = this.getPlugin("snapline"); return e && e.setFilter(t), this; }; Le.prototype.isSnaplineOnResizingEnabled = function() { const t = this.getPlugin("snapline"); return t ? t.isOnResizingEnabled() : !1; }; Le.prototype.enableSnaplineOnResizing = function() { const t = this.getPlugin("snapline"); return t && t.enableOnResizing(), this; }; Le.prototype.disableSnaplineOnResizing = function() { const t = this.getPlugin("snapline"); return t && t.disableOnResizing(), this; }; Le.prototype.toggleSnaplineOnResizing = function(t) { const e = this.getPlugin("snapline"); return e && e.toggleOnResizing(t), this; }; Le.prototype.isSharpSnapline = function() { const t = this.getPlugin("snapline"); return t ? t.isSharp() : !1; }; Le.prototype.enableSharpSnapline = function() { const t = this.getPlugin("snapline"); return t && t.enableSharp(), this; }; Le.prototype.disableSharpSnapline = function() { const t = this.getPlugin("snapline"); return t && t.disableSharp(), this; }; Le.prototype.toggleSharpSnapline = function(t) { const e = this.getPlugin("snapline"); return e && e.toggleSharp(t), this; }; Le.prototype.getSnaplineTolerance = function() { const t = this.getPlugin("snapline"); if (t) return t.getTolerance(); }; Le.prototype.setSnaplineTolerance = function(t) { const e = this.getPlugin("snapline"); return e && e.setTolerance(t), this; }; var Wle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class l8 extends uo { constructor(e) { super(), this.name = "snapline", this.options = Object.assign({ tolerance: 10 }, e), Sd(this.name, jle); } init(e) { this.snaplineImpl = new i8(Object.assign(Object.assign({}, this.options), { graph: e })); } // #region api isEnabled() { return !this.snaplineImpl.disabled; } enable() { return this.snaplineImpl.enable(), this; } disable() { return this.snaplineImpl.disable(), this; } toggleEnabled(e) { if (e != null) e !== this.isEnabled() && (e ? this.enable() : this.disable()); else return this.isEnabled() ? this.disable() : this.enable(), this; } hide() { return this.snaplineImpl.hide(), this; } setFilter(e) { return this.snaplineImpl.setFilter(e), this; } isOnResizingEnabled() { return this.snaplineImpl.options.resizing === !0; } enableOnResizing() { return this.snaplineImpl.options.resizing = !0, this; } disableOnResizing() { return this.snaplineImpl.options.resizing = !1, this; } toggleOnResizing(e) { return e != null ? e !== this.isOnResizingEnabled() && (e ? this.enableOnResizing() : this.disableOnResizing()) : this.isOnResizingEnabled() ? this.disableOnResizing() : this.enableOnResizing(), this; } isSharp() { return this.snaplineImpl.options.sharp === !0; } enableSharp() { return this.snaplineImpl.options.sharp = !0, this; } disableSharp() { return this.snaplineImpl.options.sharp = !1, this; } toggleSharp(e) { return e != null ? e !== this.isSharp() && (e ? this.enableSharp() : this.disableSharp()) : this.isSharp() ? this.disableSharp() : this.enableSharp(), this; } getTolerance() { return this.snaplineImpl.options.tolerance; } setTolerance(e) { return this.snaplineImpl.options.tolerance = e, this; } captureCursorOffset(e) { this.snaplineImpl.captureCursorOffset(e); } snapOnMoving(e) { this.snaplineImpl.snapOnMoving(e); } // #endregion dispose() { this.snaplineImpl.dispose(), xd(this.name); } } Wle([ uo.dispose() ], l8.prototype, "dispose", null); class Kle { constructor() { this.cells = []; } copy(e, n, o = {}) { this.options = Object.assign({}, o); const r = (To.isModel(n) ? n : n.model).cloneSubGraph(e, o); this.cells = vp(Object.keys(r).map((i) => r[i]), (i) => i.isEdge() ? 2 : 1), this.serialize(o); } cut(e, n, o = {}) { this.copy(e, n, o), (Le.isGraph(n) ? n.model : n).batchUpdate("cut", () => { e.forEach((r) => r.remove()); }); } paste(e, n = {}) { const o = Object.assign(Object.assign({}, this.options), n), { offset: s, edgeProps: r, nodeProps: i } = o; let l = 20, a = 20; s && (l = typeof s == "number" ? s : s.dx, a = typeof s == "number" ? s : s.dy), this.deserialize(o); const c = this.cells; c.forEach((d) => { d.model = null, d.removeProp("zIndex"), (l || a) && d.translate(l, a), i && d.isNode() && d.prop(i), r && d.isEdge() && d.prop(r); }); const u = Le.isGraph(e) ? e.model : e; return u.batchUpdate("paste", () => { u.addCells(this.cells); }), this.copy(c, e, n), c; } serialize(e) { e.useLocalStorage !== !1 && ql.save(this.cells); } deserialize(e) { if (e.useLocalStorage) { const n = ql.fetch(); n && (this.cells = n); } } isEmpty(e = {}) { return e.useLocalStorage && this.deserialize(e), this.cells.length <= 0; } clean() { this.options = {}, this.cells = [], ql.clean(); } } var ql; (function(t) { const e = `${Io.prefixCls}.clipboard.cells`; function n(r) { if (window.localStorage) { const i = r.map((l) => l.toJSON()); localStorage.setItem(e, JSON.stringify(i)); } } t.save = n; function o() { if (window.localStorage) { const r = localStorage.getItem(e), i = r ? JSON.parse(r) : []; if (i) return To.fromJSON(i); } } t.fetch = o; function s() { window.localStorage && localStorage.removeItem(e); } t.clean = s; })(ql || (ql = {})); Le.prototype.isClipboardEnabled = function() { const t = this.getPlugin("clipboard"); return t ? t.isEnabled() : !1; }; Le.prototype.enableClipboard = function() { const t = this.getPlugin("clipboard"); return t && t.enable(), this; }; Le.prototype.disableClipboard = function() { const t = this.getPlugin("clipboard"); return t && t.disable(), this; }; Le.prototype.toggleClipboard = function(t) { const e = this.getPlugin("clipboard"); return e && e.toggleEnabled(t), this; }; Le.prototype.isClipboardEmpty = function(t) { const e = this.getPlugin("clipboard"); return e ? e.isEmpty(t) : !0; }; Le.prototype.getCellsInClipboard = function() { const t = this.getPlugin("clipboard"); return t ? t.getCellsInClipboard() : []; }; Le.prototype.cleanClipboard = function() { const t = this.getPlugin("clipboard"); return t && t.clean(), this; }; Le.prototype.copy = function(t, e) { const n = this.getPlugin("clipboard"); return n && n.copy(t, e), this; }; Le.prototype.cut = function(t, e) { const n = this.getPlugin("clipboard"); return n && n.cut(t, e), this; }; Le.prototype.paste = function(t, e) { const n = this.getPlugin("clipboard"); return n ? n.paste(t, e) : []; }; var qle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }, Ule = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; class a8 extends kn { constructor(e = { enabled: !0 }) { super(), this.name = "clipboard", this.options = e; } init(e) { this.graph = e, this.clipboardImpl = new Kle(), this.clipboardImpl.deserialize(this.options); } // #region api isEnabled() { return !this.disabled; } enable() { this.disabled && (this.options.enabled = !0); } disable() { this.disabled || (this.options.enabled = !1); } toggleEnabled(e) { return e != null ? e !== this.isEnabled() && (e ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this; } isEmpty(e = {}) { return this.clipboardImpl.isEmpty(e); } getCellsInClipboard() { return this.cells; } clean(e) { return (!this.disabled || e) && (this.clipboardImpl.clean(), this.notify("clipboard:changed", { cells: [] })), this; } copy(e, n = {}) { return this.disabled || (this.clipboardImpl.copy(e, this.graph, Object.assign(Object.assign({}, this.commonOptions), n)), this.notify("clipboard:changed", { cells: e })), this; } cut(e, n = {}) { return this.disabled || (this.clipboardImpl.cut(e, this.graph, Object.assign(Object.assign({}, this.commonOptions), n)), this.notify("clipboard:changed", { cells: e })), this; } paste(e = {}, n = this.graph) { return this.disabled ? [] : this.clipboardImpl.paste(n, Object.assign(Object.assign({}, this.commonOptions), e)); } // #endregion get disabled() { return this.options.enabled !== !0; } get commonOptions() { const e = this.options; return Ule(e, ["enabled"]); } get cells() { return this.clipboardImpl.cells; } notify(e, n) { this.trigger(e, n), this.graph.trigger(e, n); } dispose() { this.clean(!0), this.off(); } } qle([ kn.dispose() ], a8.prototype, "dispose", null); var Jh = {}, Gle = { get exports() { return Jh; }, set exports(t) { Jh = t; } }; (function(t) { (function(e, n, o) { if (!e) return; for (var s = { 8: "backspace", 9: "tab", 13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", 37: "left", 38: "up", 39: "right", 40: "down", 45: "ins", 46: "del", 91: "meta", 93: "meta", 224: "meta" }, r = { 106: "*", 107: "+", 109: "-", 110: ".", 111: "/", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'" }, i = { "~": "`", "!": "1", "@": "2", "#": "3", $: "4", "%": "5", "^": "6", "&": "7", "*": "8", "(": "9", ")": "0", _: "-", "+": "=", ":": ";", '"': "'", "<": ",", ">": ".", "?": "/", "|": "\\" }, l = { option: "alt", command: "meta", return: "enter", escape: "esc", plus: "+", mod: /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "meta" : "ctrl" }, a, c = 1; c < 20; ++c) s[111 + c] = "f" + c; for (c = 0; c <= 9; ++c) s[c + 96] = c.toString(); function u(E, $, T) { if (E.addEventListener) { E.addEventListener($, T, !1); return; } E.attachEvent("on" + $, T); } function d(E) { if (E.type == "keypress") { var $ = String.fromCharCode(E.which); return E.shiftKey || ($ = $.toLowerCase()), $; } return s[E.which] ? s[E.which] : r[E.which] ? r[E.which] : String.fromCharCode(E.which).toLowerCase(); } function h(E, $) { return E.sort().join(",") === $.sort().join(","); } function p(E) { var $ = []; return E.shiftKey && $.push("shift"), E.altKey && $.push("alt"), E.ctrlKey && $.push("ctrl"), E.metaKey && $.push("meta"), $; } function m(E) { if (E.preventDefault) { E.preventDefault(); return; } E.returnValue = !1; } function g(E) { if (E.stopPropagation) { E.stopPropagation(); return; } E.cancelBubble = !0; } function v(E) { return E == "shift" || E == "ctrl" || E == "alt" || E == "meta"; } function y() { if (!a) { a = {}; for (var E in s) E > 95 && E < 112 || s.hasOwnProperty(E) && (a[s[E]] = E); } return a; } function w(E, $, T) { return T || (T = y()[E] ? "keydown" : "keypress"), T == "keypress" && $.length && (T = "keydown"), T; } function b(E) { return E === "+" ? ["+"] : (E = E.replace(/\+{2}/g, "+plus"), E.split("+")); } function C(E, $) { var T, P, A, I = []; for (T = b(E), A = 0; A < T.length; ++A) P = T[A], l[P] && (P = l[P]), $ && $ != "keypress" && i[P] && (P = i[P], I.push("shift")), v(P) && I.push(P); return $ = w(P, I, $), { key: P, modifiers: I, action: $ }; } function S(E, $) { return E === null || E === n ? !1 : E === $ ? !0 : S(E.parentNode, $); } function k(E) { var $ = this; if (E = E || n, !($ instanceof k)) return new k(E); $.target = E, $._callbacks = {}, $._directMap = {}; var T = {}, P, A = !1, I = !1, V = !1; function F(Y) { Y = Y || {}; var K = !1, J; for (J in T) { if (Y[J]) { K = !0; continue; } T[J] = 0; } K || (V = !1); } function L(Y, K, J, oe, de, re) { var ie, Q, se = [], ce = J.type; if (!$._callbacks[Y]) return []; for (ce == "keyup" && v(Y) && (K = [Y]), ie = 0; ie < $._callbacks[Y].length; ++ie) if (Q = $._callbacks[Y][ie], !(!oe && Q.seq && T[Q.seq] != Q.level) && ce == Q.action && (ce == "keypress" && !J.metaKey && !J.ctrlKey || h(K, Q.modifiers))) { var _e = !oe && Q.combo == de, Be = oe && Q.seq == oe && Q.level == re; (_e || Be) && $._callbacks[Y].splice(ie, 1), se.push(Q); } return se; } function N(Y, K, J, oe) { $.stopCallback(K, K.target || K.srcElement, J, oe) || Y(K, J) === !1 && (m(K), g(K)); } $._handleKey = function(Y, K, J) { var oe = L(Y, K, J), de, re = {}, ie = 0, Q = !1; for (de = 0; de < oe.length; ++de) oe[de].seq && (ie = Math.max(ie, oe[de].level)); for (de = 0; de < oe.length; ++de) { if (oe[de].seq) { if (oe[de].level != ie) continue; Q = !0, re[oe[de].seq] = 1, N(oe[de].callback, J, oe[de].combo, oe[de].seq); continue; } Q || N(oe[de].callback, J, oe[de].combo); } var se = J.type == "keypress" && I; J.type == V && !v(Y) && !se && F(re), I = Q && J.type == "keydown"; }; function _(Y) { typeof Y.which != "number" && (Y.which = Y.keyCode); var K = d(Y); if (K) { if (Y.type == "keyup" && A === K) { A = !1; return; } $.handleKey(K, p(Y), Y); } } function D() { clearTimeout(P), P = setTimeout(F, 1e3); } function z(Y, K, J, oe) { T[Y] = 0; function de(ce) { return function() { V = ce, ++T[Y], D(); }; } function re(ce) { N(J, ce, Y), oe !== "keyup" && (A = d(ce)), setTimeout(F, 10); } for (var ie = 0; ie < K.length; ++ie) { var Q = ie + 1 === K.length, se = Q ? re : de(oe || C(K[ie + 1]).action); U(K[ie], se, oe, Y, ie); } } function U(Y, K, J, oe, de) { $._directMap[Y + ":" + J] = K, Y = Y.replace(/\s+/g, " "); var re = Y.split(" "), ie; if (re.length > 1) { z(Y, re, K, J); return; } ie = C(Y, J), $._callbacks[ie.key] = $._callbacks[ie.key] || [], L(ie.key, ie.modifiers, { type: ie.action }, oe, Y, de), $._callbacks[ie.key][oe ? "unshift" : "push"]({ callback: K, modifiers: ie.modifiers, action: ie.action, seq: oe, level: de, combo: Y }); } $._bindMultiple = function(Y, K, J) { for (var oe = 0; oe < Y.length; ++oe) U(Y[oe], K, J); }, u(E, "keypress", _), u(E, "keydown", _), u(E, "keyup", _); } k.prototype.bind = function(E, $, T) { var P = this; return E = E instanceof Array ? E : [E], P._bindMultiple.call(P, E, $, T), P; }, k.prototype.unbind = function(E, $) { var T = this; return T.bind.call(T, E, function() { }, $); }, k.prototype.trigger = function(E, $) { var T = this; return T._directMap[E + ":" + $] && T._directMap[E + ":" + $]({}, E), T; }, k.prototype.reset = function() { var E = this; return E._callbacks = {}, E._directMap = {}, E; }, k.prototype.stopCallback = function(E, $) { var T = this; if ((" " + $.className + " ").indexOf(" mousetrap ") > -1 || S($, T.target)) return !1; if ("composedPath" in E && typeof E.composedPath == "function") { var P = E.composedPath()[0]; P !== E.target && ($ = P); } return $.tagName == "INPUT" || $.tagName == "SELECT" || $.tagName == "TEXTAREA" || $.isContentEditable; }, k.prototype.handleKey = function() { var E = this; return E._handleKey.apply(E, arguments); }, k.addKeycodes = function(E) { for (var $ in E) E.hasOwnProperty($) && (s[$] = E[$]); a = null; }, k.init = function() { var E = k(n); for (var $ in E) $.charAt(0) !== "_" && (k[$] = function(T) { return function() { return E[T].apply(E, arguments); }; }($)); }, k.init(), e.Mousetrap = k, t.exports && (t.exports = k), typeof o == "function" && o.amd && o(function() { return k; }); })(typeof window < "u" ? window : null, typeof window < "u" ? document : null); })(Gle); const Yle = Jh; var Xle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class Qi extends uo { get graph() { return this.options.graph; } constructor(e) { super(), this.options = e; const n = this.graph.getPlugin("scroller"); this.container = n ? n.container : this.graph.container, e.global ? this.target = document : (this.target = this.container, this.disabled || this.target.setAttribute("tabindex", "-1"), this.graph.on("cell:mouseup", this.focus, this), this.graph.on("blank:mouseup", this.focus, this)), this.mousetrap = Qi.createMousetrap(this); } get disabled() { return this.options.enabled !== !0; } enable() { this.disabled && (this.options.enabled = !0, this.target instanceof HTMLElement && this.target.setAttribute("tabindex", "-1")); } disable() { this.disabled || (this.options.enabled = !1, this.target instanceof HTMLElement && this.target.removeAttribute("tabindex")); } on(e, n, o) { this.mousetrap.bind(this.getKeys(e), n, o); } off(e, n) { this.mousetrap.unbind(this.getKeys(e), n); } clear() { this.mousetrap.reset(); } trigger(e, n) { this.mousetrap.trigger(e, n); } focus(e) { if (this.isInputEvent(e.e)) return; this.target.focus({ preventScroll: !0 }); } getKeys(e) { return (Array.isArray(e) ? e : [e]).map((n) => this.formatkey(n)); } formatkey(e) { const n = e.toLowerCase().replace(/\s/g, "").replace("delete", "del").replace("cmd", "command"), o = this.options.format; return o ? dt(o, this.graph, n) : n; } isGraphEvent(e) { const n = e.target, o = e.currentTarget; return n ? n === this.target || o === this.target || n === document.body ? !0 : Fg(this.container, n) : !1; } isInputEvent(e) { var n; const o = e.target, s = (n = o == null ? void 0 : o.tagName) === null || n === void 0 ? void 0 : n.toLowerCase(); let r = ["input", "textarea"].includes(s); return Vt(o, "contenteditable") === "true" && (r = !0), r; } isEnabledForEvent(e) { const n = !this.disabled && this.isGraphEvent(e), o = this.isInputEvent(e); if (n) { if (o && (e.key === "Backspace" || e.key === "Delete")) return !1; if (this.options.guard) return dt(this.options.guard, this.graph, e); } return n; } dispose() { this.mousetrap.reset(); } } Xle([ uo.dispose() ], Qi.prototype, "dispose", null); (function(t) { function e(n) { const o = new Yle(n.target), s = o.stopCallback; return o.stopCallback = (r, i, l) => n.isEnabledForEvent(r) ? s ? s.call(o, r, i, l) : !1 : !0, o; } t.createMousetrap = e; })(Qi || (Qi = {})); Le.prototype.isKeyboardEnabled = function() { const t = this.getPlugin("keyboard"); return t ? t.isEnabled() : !1; }; Le.prototype.enableKeyboard = function() { const t = this.getPlugin("keyboard"); return t && t.enable(), this; }; Le.prototype.disableKeyboard = function() { const t = this.getPlugin("keyboard"); return t && t.disable(), this; }; Le.prototype.toggleKeyboard = function(t) { const e = this.getPlugin("keyboard"); return e && e.toggleEnabled(t), this; }; Le.prototype.bindKey = function(t, e, n) { const o = this.getPlugin("keyboard"); return o && o.bindKey(t, e, n), this; }; Le.prototype.unbindKey = function(t, e) { const n = this.getPlugin("keyboard"); return n && n.unbindKey(t, e), this; }; Le.prototype.clearKeys = function() { const t = this.getPlugin("keyboard"); return t && t.clear(), this; }; Le.prototype.triggerKey = function(t, e) { const n = this.getPlugin("keyboard"); return n && n.trigger(t, e), this; }; var Zle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class c8 extends uo { constructor(e) { super(), this.name = "keyboard", this.options = e; } init(e) { this.keyboardImpl = new Qi(Object.assign(Object.assign({}, this.options), { graph: e })); } // #region api isEnabled() { return !this.keyboardImpl.disabled; } enable() { this.keyboardImpl.enable(); } disable() { this.keyboardImpl.disable(); } toggleEnabled(e) { return e != null ? e !== this.isEnabled() && (e ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this; } bindKey(e, n, o) { return this.keyboardImpl.on(e, n, o), this; } trigger(e, n) { return this.keyboardImpl.trigger(e, n), this; } clear() { return this.keyboardImpl.clear(), this; } unbindKey(e, n) { return this.keyboardImpl.off(e, n), this; } // #endregion dispose() { this.keyboardImpl.dispose(); } } Zle([ uo.dispose() ], c8.prototype, "dispose", null); Le.prototype.isHistoryEnabled = function() { const t = this.getPlugin("history"); return t ? t.isEnabled() : !1; }; Le.prototype.enableHistory = function() { const t = this.getPlugin("history"); return t && t.enable(), this; }; Le.prototype.disableHistory = function() { const t = this.getPlugin("history"); return t && t.disable(), this; }; Le.prototype.toggleHistory = function(t) { const e = this.getPlugin("history"); return e && e.toggleEnabled(t), this; }; Le.prototype.undo = function(t) { const e = this.getPlugin("history"); return e && e.undo(t), this; }; Le.prototype.redo = function(t) { const e = this.getPlugin("history"); return e && e.redo(t), this; }; Le.prototype.undoAndCancel = function(t) { const e = this.getPlugin("history"); return e && e.cancel(t), this; }; Le.prototype.canUndo = function() { const t = this.getPlugin("history"); return t ? t.canUndo() : !1; }; Le.prototype.canRedo = function() { const t = this.getPlugin("history"); return t ? t.canRedo() : !1; }; Le.prototype.cleanHistory = function(t) { const e = this.getPlugin("history"); return e && e.clean(t), this; }; var u8 = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class el extends kn { constructor(e) { 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 } = e; this.stackSize = n, this.options = cn.getOptions(e), this.validator = new el.Validator({ history: this, cancelInvalid: this.options.cancelInvalid }); } init(e) { this.graph = e, 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(e) { return e != null ? e !== this.isEnabled() && (e ? this.enable() : this.disable()) : this.isEnabled() ? this.disable() : this.enable(), this; } undo(e = {}) { if (!this.disabled) { const n = this.undoStack.pop(); n && (this.revertCommand(n, e), this.redoStack.push(n), this.notify("undo", n, e)); } return this; } redo(e = {}) { if (!this.disabled) { const n = this.redoStack.pop(); n && (this.applyCommand(n, e), this.undoStackPush(n), this.notify("redo", n, e)); } return this; } /** * Same as `undo()` but does not store the undo-ed command to the * `redoStack`. Canceled command therefore cannot be redo-ed. */ cancel(e = {}) { if (!this.disabled) { const n = this.undoStack.pop(); n && (this.revertCommand(n, e), this.redoStack = [], this.notify("cancel", n, e)); } return this; } canUndo() { return !this.disabled && this.undoStack.length > 0; } canRedo() { return !this.disabled && this.redoStack.length > 0; } clean(e = {}) { return this.undoStack = [], this.redoStack = [], this.notify("clean", null, e), this; } // #endregion get disabled() { return this.options.enabled !== !0; } validate(e, ...n) { return this.validator.validate(e, ...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((e, n) => { this.handlers[n] = this.addCommand.bind(this, e), this.model.on(e, this.handlers[n]); }), this.validator.on("invalid", (e) => this.trigger("invalid", e)); } stopListening() { this.model.off("batch:start", this.initBatchCommand, this), this.model.off("batch:stop", this.storeBatchCommand, this), this.options.eventNames && (this.options.eventNames.forEach((e, n) => { this.model.off(e, this.handlers[n]); }), this.handlers.length = 0), this.validator.off("invalid"); } createCommand(e) { return { batch: e ? e.batch : !1, data: {} }; } revertCommand(e, n) { this.freezed = !0; const o = Array.isArray(e) ? cn.sortBatchCommands(e) : [e]; for (let s = o.length - 1; s >= 0; s -= 1) { const r = o[s], i = Object.assign(Object.assign({}, n), Bo(r.options, this.options.revertOptionsList || [])); this.executeCommand(r, !0, i); } this.freezed = !1; } applyCommand(e, n) { this.freezed = !0; const o = Array.isArray(e) ? cn.sortBatchCommands(e) : [e]; for (let s = 0; s < o.length; s += 1) { const r = o[s], i = Object.assign(Object.assign({}, n), Bo(r.options, this.options.applyOptionsList || [])); this.executeCommand(r, !1, i); } this.freezed = !1; } executeCommand(e, n, o) { const s = this.model, r = s.getCell(e.data.id), i = e.event; if (cn.isAddEvent(i) && n || cn.isRemoveEvent(i) && !n) r && r.remove(o); else if (cn.isAddEvent(i) && !n || cn.isRemoveEvent(i) && n) { const l = e.data; l.node ? s.addNode(l.props, o) : l.edge && s.addEdge(l.props, o); } else if (cn.isChangeEvent(i)) { const l = e.data, a = l.key; if (a && r) { const c = n ? l.prev[a] : l.next[a]; r.prop(a, c, o); } } else { const l = this.options.executeCommand; l && dt(l, this, e, n, o); } } addCommand(e, n) { if (this.freezed || this.disabled) return; const o = n, s = o.options || {}; if (s.dryrun || cn.isAddEvent(e) && this.options.ignoreAdd || cn.isRemoveEvent(e) && this.options.ignoreRemove || cn.isChangeEvent(e) && this.options.ignoreChange) return; const r = this.options.beforeAddCommand; if (r != null && dt(r, this, e, n) === !1) return; e === "cell:change:*" && (e = `cell:change:${o.key}`); const i = o.cell, l = To.isModel(i); let a; if (this.batchCommands) { a = this.batchCommands[Math.max(this.lastBatchIndex, 0)]; const u = l && !a.modelChange || a.data.id !== i.id, d = a.event !== e; if (this.lastBatchIndex >= 0 && (u || d)) { const h = this.batchCommands.findIndex((p) => (l && p.modelChange || p.data.id === i.id) && p.event === e); h < 0 || cn.isAddEvent(e) || cn.isRemoveEvent(e) ? a = this.createCommand({ batch: !0 }) : (a = this.batchCommands[h], this.batchCommands.splice(h, 1)), this.batchCommands.push(a), this.lastBatchIndex = this.batchCommands.length - 1; } } else a = this.createCommand({ batch: !1 }); if (cn.isAddEvent(e) || cn.isRemoveEvent(e)) { const u = a.data; return a.event = e, a.options = s, u.id = i.id, u.props = Kt(i.toJSON()), i.isEdge() ? u.edge = !0 : i.isNode() && (u.node = !0), this.push(a, s); } if (cn.isChangeEvent(e)) { const u = n.key, d = a.data; return (!a.batch || !a.event) && (a.event = e, a.options = s, d.key = u, d.prev == null && (d.prev = {}), d.prev[u] = Kt(i.previous(u)), l ? a.modelChange = !0 : d.id = i.id), d.next == null && (d.next = {}), d.next[u] = Kt(i.prop(u)), this.push(a, s); } const c = this.options.afterAddCommand; c && dt(c, this, e, n, a), this.push(a, s); } /** * 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(e) { 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(e) { 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, e)), this.batchCommands = null, this.lastBatchIndex = -1, this.batchLevel = 0; } else this.batchCommands && this.batchLevel > 0 && (this.batchLevel -= 1); } filterBatchCommand(e) { let n = e.slice(); const o = []; for (; n.length > 0; ) { const s = n.shift(), r = s.event, i = s.data.id; if (r != null && (i != null || s.modelChange)) { if (cn.isAddEvent(r)) { const l = n.findIndex((a) => cn.isRemoveEvent(a.event) && a.data.id === i); if (l >= 0) { n = n.filter((a, c) => l < c || a.data.id !== i); continue; } } else if (cn.isRemoveEvent(r)) { const l = n.findIndex((a) => cn.isAddEvent(a.event) && a.data.id === i); if (l >= 0) { n.splice(l, 1); continue; } } else if (cn.isChangeEvent(r)) { const l = s.data; if (dn(l.prev, l.next)) continue; } o.push(s); } } return o; } notify(e, n, o) { const s = n == null ? null : Array.isArray(n) ? n : [n]; this.emit(e, { cmds: s, options: o }), this.graph.trigger(`history:${e}`, { cmds: s, options: o }), this.emit("change", { cmds: s, options: o }), this.graph.trigger("history:change", { cmds: s, options: o }); } push(e, n) { this.redoStack = [], e.batch ? (this.lastBatchIndex = Math.max(this.lastBatchIndex, 0), this.emit("batch", { cmd: e, options: n })) : (this.undoStackPush(e), this.consolidateCommands(), this.notify("add", e, 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 e; const n = this.undoStack[this.undoStack.length - 1], o = this.undoStack[this.undoStack.length - 2]; if (!Array.isArray(n)) return; const s = new Set(n.map((i) => i.event)); if (s.size !== 2 || !s.has("cell:change:parent") || !s.has("cell:change:children") || !n.every((i) => { var l; return i.batch && ((l = i.options) === null || l === void 0 ? void 0 : l.ui); }) || !Array.isArray(o) || o.length !== 1) return; const r = o[0]; r.event !== "cell:change:position" || !(!((e = r.options) === null || e === void 0) && e.ui) || (o.push(...n), this.undoStack.pop()); } undoStackPush(e) { if (this.stackSize === 0) { this.undoStack.push(e); return; } this.undoStack.length >= this.stackSize && this.undoStack.shift(), this.undoStack.push(e); } dispose() { this.validator.dispose(), this.clean(), this.stopListening(), this.off(); } } u8([ kn.dispose() ], el.prototype, "dispose", null); (function(t) { class e extends kn { constructor(o) { super(), this.map = {}, this.command = o.history, this.cancelInvalid = o.cancelInvalid !== !1, this.command.on("add", this.onCommandAdded, this); } onCommandAdded({ cmds: o }) { return Array.isArray(o) ? o.every((s) => this.isValidCommand(s)) : this.isValidCommand(o); } isValidCommand(o) { if (o.options && o.options.validation === !1) return !0; const s = o.event && this.map[o.event] || []; let r = null; return s.forEach((i) => { let l = 0; const a = (c) => { const u = i[l]; l += 1; try { if (u) u(c, o, a); else { r = c; return; } } catch (d) { a(d); } }; a(r); }), r ? (this.cancelInvalid && this.command.cancel(), this.emit("invalid", { err: r }), !1) : !0; } validate(o, ...s) { const r = Array.isArray(o) ? o : o.split(/\s+/); return s.forEach((i) => { if (typeof i != "function") throw new Error(`${r.join(" ")} requires callback functions.`); }), r.forEach((i) => { this.map[i] == null && (this.map[i] = []), this.map[i].push(s); }), this; } dispose() { this.command.off("add", this.onCommandAdded, this); } } u8([ kn.dispose() ], e.prototype, "dispose", null), t.Validator = e; })(el || (el = {})); var cn; (function(t) { function e(i) { return i === "cell:added"; } t.isAddEvent = e; function n(i) { return i === "cell:removed"; } t.isRemoveEvent = n; function o(i) { return i != null && i.startsWith("cell:change:"); } t.isChangeEvent = o; function s(i) { const l = [ "cell:added", "cell:removed", "cell:change:*" ], a = ["batch:start", "batch:stop"], c = i.eventNames ? i.eventNames.filter((u) => !(t.isChangeEvent(u) || l.includes(u) || a.includes(u))) : l; return Object.assign(Object.assign({}, i), { eventNames: c, applyOptionsList: i.applyOptionsList || ["propertyPath"], revertOptionsList: i.revertOptionsList || ["propertyPath"] }); } t.getOptions = s; function r(i) { const l = []; for (let a = 0, c = i.length; a < c; a += 1) { const u = i[a]; let d = null; if (t.isAddEvent(u.event)) { const h = u.data.id; for (let p = 0; p < a; p += 1) if (i[p].data.id === h) { d = p; break; } } d !== null ? l.splice(d, 0, u) : l.push(u); } return l; } t.sortBatchCommands = r; })(cn || (cn = {})); const Jle = `.x6-widget-dnd { position: absolute; top: -10000px; left: -10000px; z-index: 999999; display: none; cursor: move; opacity: 0.7; pointer-events: 'cursor'; } .x6-widget-dnd.dragging { display: inline-block; } .x6-widget-dnd.dragging * { pointer-events: none !important; } .x6-widget-dnd .x6-graph { background: transparent; box-shadow: none; } `; var Qle = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class zr extends jt { get targetScroller() { return this.options.target.getPlugin("scroller"); } get targetGraph() { return this.options.target; } get targetModel() { return this.targetGraph.model; } get snapline() { return this.options.target.getPlugin("snapline"); } constructor(e) { super(), this.name = "dnd", Sd(this.name, Jle), this.options = Object.assign(Object.assign({}, zr.defaults), e), this.container = document.createElement("div"), _t(this.container, this.prefixClassName("widget-dnd")), this.draggingGraph = new Le(Object.assign(Object.assign({}, this.options.delegateGraphOptions), { container: document.createElement("div"), width: 1, height: 1, async: !1 })), Gr(this.container, this.draggingGraph.container); } start(e, n) { const o = n; o.preventDefault(), this.targetModel.startBatch("dnd"), _t(this.container, "dragging"), Dl(this.container, this.options.draggingContainer || document.body), this.sourceNode = e, this.prepareDragging(e, o.clientX, o.clientY); const s = this.updateNodePosition(o.clientX, o.clientY); this.isSnaplineEnabled() && (this.snapline.captureCursorOffset({ e: o, node: e, cell: e, view: this.draggingView, x: s.x, y: s.y }), this.draggingNode.on("change:position", this.snap, this)), this.delegateDocumentEvents(zr.documentEvents, o.data); } isSnaplineEnabled() { return this.snapline && this.snapline.isEnabled(); } prepareDragging(e, n, o) { const s = this.draggingGraph, r = s.model, i = this.options.getDragNode(e, { sourceNode: e, draggingGraph: s, targetGraph: this.targetGraph }); i.position(0, 0); let l = 5; if (this.isSnaplineEnabled() && (l += this.snapline.options.tolerance || 0), this.isSnaplineEnabled() || this.options.scaled) { const u = this.targetGraph.transform.getScale(); s.scale(u.sx, u.sy), l *= Math.max(u.sx, u.sy); } else s.scale(1, 1); this.clearDragging(), r.resetCells([i]); const a = s.findViewByCell(i); a.undelegateEvents(), a.cell.off("changed"), s.fitToContent({ padding: l, allowNewOrigin: "any" }); const c = a.getBBox(); this.geometryBBox = a.getBBox({ useCellGeometry: !0 }), this.delta = this.geometryBBox.getTopLeft().diff(c.getTopLeft()), this.draggingNode = i, this.draggingView = a, this.draggingBBox = i.getBBox(), this.padding = l, this.originOffset = this.updateGraphPosition(n, o); } updateGraphPosition(e, n) { const o = document.body.scrollTop || document.documentElement.scrollTop, s = this.delta, r = this.geometryBBox, i = this.padding || 5, l = { left: e - s.x - r.width / 2 - i, top: n - s.y - r.height / 2 - i + o }; return this.draggingGraph && An(this.container, { left: `${l.left}px`, top: `${l.top}px` }), l; } updateNodePosition(e, n) { const o = this.targetGraph.clientToLocal(e, n), s = this.draggingBBox; return o.x -= s.width / 2, o.y -= s.height / 2, this.draggingNode.position(o.x, o.y), o; } snap({ cell: e, current: n, options: o }) { const s = e; if (o.snapped) { const r = this.draggingBBox; s.position(r.x + o.tx, r.y + o.ty, { silent: !0 }), this.draggingView.translate(), s.position(n.x, n.y, { silent: !0 }), this.snapOffset = { x: o.tx, y: o.ty }; } else this.snapOffset = null; } onDragging(e) { const n = this.draggingView; if (n) { e.preventDefault(); const o = this.normalizeEvent(e), s = o.clientX, r = o.clientY; this.updateGraphPosition(s, r); const i = this.updateNodePosition(s, r), l = this.targetGraph.options.embedding.enabled, a = (l || this.isSnaplineEnabled()) && this.isInsideValidArea({ x: s, y: r }); if (l) { n.setEventData(o, { graph: this.targetGraph, candidateEmbedView: this.candidateEmbedView }); const c = n.getEventData(o); a ? n.processEmbedding(o, c) : n.clearEmbedding(c), this.candidateEmbedView = c.candidateEmbedView; } this.isSnaplineEnabled() && (a ? this.snapline.snapOnMoving({ e: o, view: n, x: i.x, y: i.y }) : this.snapline.hide()); } } onDragEnd(e) { const n = this.draggingNode; if (n) { const o = this.normalizeEvent(e), s = this.draggingView, r = this.draggingBBox, i = this.snapOffset; let l = r.x, a = r.y; i && (l += i.x, a += i.y), n.position(l, a, { silent: !0 }); const c = this.drop(n, { x: o.clientX, y: o.clientY }), u = (d) => { d ? (this.onDropped(n), this.targetGraph.options.embedding.enabled && s && (s.setEventData(o, { cell: d, graph: this.targetGraph, candidateEmbedView: this.candidateEmbedView }), s.finalizeEmbedding(o, s.getEventData(o)))) : this.onDropInvalid(), this.candidateEmbedView = null, this.targetModel.stopBatch("dnd"); }; Bh(c) ? (this.undelegateDocumentEvents(), c.then(u)) : u(c); } } clearDragging() { this.draggingNode && (this.sourceNode = null, this.draggingNode.remove(), this.draggingNode = null, this.draggingView = null, this.delta = null, this.padding = null, this.snapOffset = null, this.originOffset = null, this.undelegateDocumentEvents()); } onDropped(e) { this.draggingNode === e && (this.clearDragging(), Hn(this.container, "dragging"), os(this.container)); } onDropInvalid() { const e = this.draggingNode; e && this.onDropped(e); } isInsideValidArea(e) { let n, o = null; const s = this.targetGraph, r = this.targetScroller; this.options.dndContainer && (o = this.getDropArea(this.options.dndContainer)); const i = o && o.containsPoint(e); if (r) if (r.options.autoResize) n = this.getDropArea(r.container); else { const l = this.getDropArea(r.container); n = this.getDropArea(s.container).intersectsWithRect(l); } else n = this.getDropArea(s.container); return !i && n && n.containsPoint(e); } getDropArea(e) { const n = Kh(e), o = document.body.scrollTop || document.documentElement.scrollTop, s = document.body.scrollLeft || document.documentElement.scrollLeft; return Fe.create({ x: n.left + parseInt(An(e, "border-left-width"), 10) - s, y: n.top + parseInt(An(e, "border-top-width"), 10) - o, width: e.clientWidth, height: e.clientHeight }); } drop(e, n) { if (this.isInsideValidArea(n)) { const o = this.targetGraph, s = o.model, r = o.clientToLocal(n), i = this.sourceNode, l = this.options.getDropNode(e, { sourceNode: i, draggingNode: e, targetGraph: this.targetGraph, draggingGraph: this.draggingGraph }), a = l.getBBox(); r.x += a.x - a.width / 2, r.y += a.y - a.height / 2; const c = this.snapOffset ? 1 : o.getGridSize(); l.position(Ht.snapToGrid(r.x, c), Ht.snapToGrid(r.y, c)), l.removeZIndex(); const u = this.options.validateNode, d = u ? u(l, { sourceNode: i, draggingNode: e, droppingNode: l, targetGraph: o, draggingGraph: this.draggingGraph }) : !0; return typeof d == "boolean" ? d ? (s.addCell(l, { stencil: this.cid }), l) : null : Fne(d).then((h) => h ? (s.addCell(l, { stencil: this.cid }), l) : null); } return null; } onRemove() { this.draggingGraph && (this.draggingGraph.view.remove(), this.draggingGraph.dispose()); } dispose() { this.remove(), xd(this.name); } } Qle([ jt.dispose() ], zr.prototype, "dispose", null); (function(t) { t.defaults = { // animation: false, getDragNode: (e) => e.clone(), getDropNode: (e) => e.clone() }, t.documentEvents = { mousemove: "onDragging", touchmove: "onDragging", mouseup: "onDragEnd", touchend: "onDragEnd", touchcancel: "onDragEnd" }; })(zr || (zr = {})); var eae = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class d8 extends jt { get graph() { return this.options.graph; } get boxClassName() { return this.prefixClassName(io.classNames.box); } get $boxes() { return toe(this.container, this.boxClassName); } get handleOptions() { return this.options; } constructor(e) { super(), this.options = e, this.options.model && (this.options.collection = this.options.model.collection), this.options.collection ? this.collection = this.options.collection : (this.collection = new Jw([], { comparator: io.depthComparator }), this.options.collection = this.collection), this.boxCount = 0, this.createContainer(), this.startListening(); } startListening() { const e = this.graph, n = this.collection; this.delegateEvents({ [`mousedown .${this.boxClassName}`]: "onSelectionBoxMouseDown", [`touchstart .${this.boxClassName}`]: "onSelectionBoxMouseDown" }, !0), e.on("scale", this.onGraphTransformed, this), e.on("translate", this.onGraphTransformed, this), e.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 e = this.graph, n = this.collection; this.undelegateEvents(), e.off("scale", this.onGraphTransformed, this), e.off("translate", this.onGraphTransformed, this), e.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: e, options: n }) { const { showNodeSelectionBox: o, pointerEvents: s } = this.options, { ui: r, selection: i, translateBy: l, snapped: a } = n, c = (o !== !0 || s === "none") && !this.translating && !i, u = r && l && e.id === l; if (c && (u || a)) { this.translating = !0; const d = e.position(), h = e.previous("position"), p = d.x - h.x, m = d.y - h.y; (p !== 0 || m !== 0) && this.translateSelectedNodes(p, m, e, n), this.translating = !1; } } onModelUpdated({ removed: e }) { e && e.length && this.unselect(e); } isEmpty() { return this.length <= 0; } isSelected(e) { return this.collection.has(e); } get length() { return this.collection.length; } get cells() { return this.collection.toArray(); } select(e, n = {}) { n.dryrun = !0; const o = this.filter(Array.isArray(e) ? e : [e]); return this.collection.add(o, n), this; } unselect(e, n = {}) { return n.dryrun = !0, this.collection.remove(Array.isArray(e) ? e : [e], n), this; } reset(e, n = {}) { if (e) { if (n.batch) { const c = this.filter(Array.isArray(e) ? e : [e]); return this.collection.reset(c, Object.assign(Object.assign({}, n), { ui: !0 })), this; } const o = this.cells, s = this.filter(Array.isArray(e) ? e : [e]), r = {}, i = {}; o.forEach((c) => r[c.id] = c), s.forEach((c) => i[c.id] = c); const l = [], a = []; return s.forEach((c) => { r[c.id] || l.push(c); }), o.forEach((c) => { i[c.id] || a.push(c); }), a.length && this.unselect(a, Object.assign(Object.assign({}, n), { ui: !0 })), l.length && this.select(l, Object.assign(Object.assign({}, n), { ui: !0 })), a.length === 0 && l.length === 0 && this.updateContainer(), this; } return this.clean(n); } clean(e = {}) { return this.length && (e.batch === !1 ? this.unselect(this.cells, e) : this.collection.reset([], Object.assign(Object.assign({}, e), { ui: !0 }))), this; } setFilter(e) { this.options.filter = e; } setContent(e) { this.options.content = e; } startSelecting(e) { e = this.normalizeEvent(e), this.clean(); let n, o; const s = this.graph.container; if (e.offsetX != null && e.offsetY != null && s.contains(e.target)) n = e.offsetX, o = e.offsetY; else { const r = Kh(s), i = s.scrollLeft, l = s.scrollTop; n = e.clientX - r.left + window.pageXOffset + i, o = e.clientY - r.top + window.pageYOffset + l; } An(this.container, { top: o, left: n, width: 1, height: 1 }), this.setEventData(e, { action: "selecting", clientX: e.clientX, clientY: e.clientY, offsetX: n, offsetY: o, scrollerX: 0, scrollerY: 0, moving: !1 }), this.delegateDocumentEvents(io.documentEvents, e.data); } filter(e) { const n = this.options.filter; return e.filter((o) => Array.isArray(n) ? n.some((s) => typeof s == "string" ? o.shape === s : o.id === s.id) : typeof n == "function" ? dt(n, this.graph, o) : !0); } stopSelecting(e) { const n = this.graph, o = this.getEventData(e); switch (o.action) { case "selecting": { let r = Voe(this.container), i = Boe(this.container); const l = Kh(this.container), a = n.pageToLocal(l.left, l.top), c = n.transform.getScale(); r /= c.sx, i /= c.sy; const u = new Fe(a.x, a.y, r, i), d = this.getCellViewsInArea(u).map((h) => h.cell); this.reset(d, { batch: !0 }), this.hideRubberband(); break; } case "translating": { const r = n.snapToGrid(e.clientX, e.clientY); if (!this.options.following) { const i = o; this.updateSelectedNodesPosition({ dx: i.clientX - i.originX, dy: i.clientY - i.originY }); } this.graph.model.stopBatch("move-selection"), this.notifyBoxEvent("box:mouseup", e, r.x, r.y); break; } default: { this.clean(); break; } } } onMouseUp(e) { this.getEventData(e).action && (this.stopSelecting(e), this.undelegateDocumentEvents()); } onSelectionBoxMouseDown(e) { this.options.following || e.stopPropagation(); const n = this.normalizeEvent(e); this.options.movable && this.startTranslating(n); const o = this.getCellViewFromElem(n.target); this.setEventData(n, { activeView: o }); const s = this.graph.snapToGrid(n.clientX, n.clientY); this.notifyBoxEvent("box:mousedown", n, s.x, s.y), this.delegateDocumentEvents(io.documentEvents, n.data); } startTranslating(e) { this.graph.model.startBatch("move-selection"); const n = this.graph.snapToGrid(e.clientX, e.clientY); this.setEventData(e, { action: "translating", clientX: n.x, clientY: n.y, originX: n.x, originY: n.y }); } getRestrictArea() { const e = this.graph.options.translating.restrict, n = typeof e == "function" ? dt(e, this.graph, null) : e; return typeof n == "number" ? this.graph.transform.getGraphArea().inflate(n) : n === !0 ? this.graph.transform.getGraphArea() : n || null; } getSelectionOffset(e, n) { let o = e.x - n.clientX, s = e.y - n.clientY; const r = this.getRestrictArea(); if (r) { const i = this.collection.toArray(), l = Pt.getCellsBBox(i, { deep: !0 }) || Fe.create(), a = r.x - l.x, c = r.y - l.y, u = r.x + r.width - (l.x + l.width), d = r.y + r.height - (l.y + l.height); if (o < a && (o = a), s < c && (s = c), u < o && (o = u), d < s && (s = d), !this.options.following) { const h = e.x - n.originX, p = e.y - n.originY; o = h <= a || h >= u ? 0 : o, s = p <= c || p >= d ? 0 : s; } } return { dx: o, dy: s }; } updateElementPosition(e, n, o) { const s = An(e, "left"), r = An(e, "top"), i = s ? parseFloat(s) : 0, l = r ? parseFloat(r) : 0; An(e, "left", i + n), An(e, "top", l + o); } updateSelectedNodesPosition(e) { const { dx: n, dy: o } = e; if (n || o) if (this.translateSelectedNodes(n, o), this.boxesUpdated) this.collection.length > 1 && this.updateSelectionBoxes(); else { const s = this.graph.transform.getScale(); for (let r = 0, i = this.$boxes.length; r < i; r += 1) this.updateElementPosition(this.$boxes[r], n * s.sx, o * s.sy); this.updateElementPosition(this.selectionContainer, n * s.sx, o * s.sy); } } autoScrollGraph(e, n) { const o = this.graph.getPlugin("scroller"); return o ? o.autoScroll(e, n) : { scrollerX: 0, scrollerY: 0 }; } adjustSelection(e) { const n = this.normalizeEvent(e), o = this.getEventData(n); switch (o.action) { case "selecting": { const r = o; r.moving !== !0 && (Dl(this.container, this.graph.container), this.showRubberband(), r.moving = !0); const { scrollerX: i, scrollerY: l } = this.autoScrollGraph(n.clientX, n.clientY); r.scrollerX += i, r.scrollerY += l; const a = n.clientX - r.clientX + r.scrollerX, c = n.clientY - r.clientY + r.scrollerY, u = parseInt(An(this.container, "left") || "0", 10), d = parseInt(An(this.container, "top") || "0", 10); An(this.container, { left: a < 0 ? r.offsetX + a : u, top: c < 0 ? r.offsetY + c : d, width: Math.abs(a), height: Math.abs(c) }); break; } case "translating": { const r = this.graph.snapToGrid(n.clientX, n.clientY), i = o, l = this.getSelectionOffset(r, i); this.options.following ? this.updateSelectedNodesPosition(l) : this.updateContainerPosition(l), l.dx && (i.clientX = r.x), l.dy && (i.clientY = r.y), this.notifyBoxEvent("box:mousemove", e, r.x, r.y); break; } } this.boxesUpdated = !1; } translateSelectedNodes(e, n, o, s) { const r = {}, i = []; if (o && (r[o.id] = !0), this.collection.toArray().forEach((l) => { l.getDescendants({ deep: !0 }).forEach((a) => { r[a.id] = !0; }); }), s && s.translateBy) { const l = this.graph.getCellById(s.translateBy); l && (r[l.id] = !0, l.getDescendants({ deep: !0 }).forEach((a) => { r[a.id] = !0; }), i.push(l)); } this.collection.toArray().forEach((l) => { if (!r[l.id]) { const a = Object.assign(Object.assign({}, s), { selection: this.cid, exclude: i }); l.translate(e, n, a), this.graph.model.getConnectedEdges(l).forEach((c) => { r[c.id] || (c.translate(e, n, a), r[c.id] = !0); }); } }); } getCellViewsInArea(e) { const n = this.graph, o = { strict: this.options.strict }; let s = []; return this.options.rubberNode && (s = s.concat(n.model.getNodesInArea(e, o).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), this.options.rubberEdge && (s = s.concat(n.model.getEdgesInArea(e, o).map((r) => n.renderer.findViewByCell(r)).filter((r) => r != null))), s; } notifyBoxEvent(e, n, o, s) { const i = this.getEventData(n).activeView; this.trigger(e, { e: n, view: i, x: o, y: s, cell: i.cell }); } getSelectedClassName(e) { return this.prefixClassName(`${e.isNode() ? "node" : "edge"}-selected`); } addCellSelectedClassName(e) { const n = this.graph.renderer.findViewByCell(e); n && n.addClass(this.getSelectedClassName(e)); } removeCellUnSelectedClassName(e) { const n = this.graph.renderer.findViewByCell(e); n && n.removeClass(this.getSelectedClassName(e)); } destroySelectionBox(e) { this.removeCellUnSelectedClassName(e), this.canShowSelectionBox(e) && (os(this.container.querySelector(`[data-cell-id="${e.id}"]`)), this.$boxes.length === 0 && this.hide(), this.boxCount = Math.max(0, this.boxCount - 1)); } destroyAllSelectionBoxes(e) { e.forEach((n) => this.removeCellUnSelectedClassName(n)), this.hide(), os(this.$boxes), this.boxCount = 0; } hide() { Hn(this.container, this.prefixClassName(io.classNames.rubberband)), Hn(this.container, this.prefixClassName(io.classNames.selected)); } showRubberband() { _t(this.container, this.prefixClassName(io.classNames.rubberband)); } hideRubberband() { Hn(this.container, this.prefixClassName(io.classNames.rubberband)); } showSelected() { jg(this.container, "style"), _t(this.container, this.prefixClassName(io.classNames.selected)); } createContainer() { this.container = document.createElement("div"), _t(this.container, this.prefixClassName(io.classNames.root)), this.options.className && _t(this.container, this.options.className), this.selectionContainer = document.createElement("div"), _t(this.selectionContainer, this.prefixClassName(io.classNames.inner)), this.selectionContent = document.createElement("div"), _t(this.selectionContent, this.prefixClassName(io.classNames.content)), Gr(this.selectionContainer, this.selectionContent), Vt(this.selectionContainer, "data-selection-length", this.collection.length), K4(this.container, this.selectionContainer); } updateContainerPosition(e) { (e.dx || e.dy) && this.updateElementPosition(this.selectionContainer, e.dx, e.dy); } updateContainer() { const e = { x: 1 / 0, y: 1 / 0 }, n = { x: 0, y: 0 }; this.collection.toArray().filter((r) => this.canShowSelectionBox(r)).forEach((r) => { const i = this.graph.renderer.findViewByCell(r); if (i) { const l = i.getBBox({ useCellGeometry: !0 }); e.x = Math.min(e.x, l.x), e.y = Math.min(e.y, l.y), n.x = Math.max(n.x, l.x + l.width), n.y = Math.max(n.y, l.y + l.height); } }), An(this.selectionContainer, { position: "absolute", pointerEvents: "none", left: e.x, top: e.y, width: n.x - e.x, height: n.y - e.y }), Vt(this.selectionContainer, "data-selection-length", this.collection.length); const s = this.options.content; if (s) if (typeof s == "function") { const r = dt(s, this.graph, this, this.selectionContent); r && (this.selectionContent.innerHTML = r); } else this.selectionContent.innerHTML = s; this.collection.length > 0 && !this.container.parentNode ? Dl(this.container, this.graph.container) : this.collection.length <= 0 && this.container.parentNode && this.container.parentNode.removeChild(this.container); } canShowSelectionBox(e) { return e.isNode() && this.options.showNodeSelectionBox === !0 || e.isEdge() && this.options.showEdgeSelectionBox === !0; } createSelectionBox(e) { if (this.addCellSelectedClassName(e), this.canShowSelectionBox(e)) { const n = this.graph.renderer.findViewByCell(e); if (n) { const o = n.getBBox({ useCellGeometry: !0 }), s = this.boxClassName, r = document.createElement("div"); _t(r, s), _t(r, `${s}-${e.isNode() ? "node" : "edge"}`), Vt(r, "data-cell-id", e.id), An(r, { position: "absolute", left: o.x, top: o.y, width: o.width, height: o.height, pointerEvents: this.options.pointerEvents || "auto" }), Dl(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 e = 0, n = this.$boxes.length; e < n; e += 1) { const o = this.$boxes[e], s = Vt(o, "data-cell-id"); os(o); const r = this.collection.get(s); r && this.createSelectionBox(r); } this.updateContainer(); } return 0; } getCellViewFromElem(e) { const n = e.getAttribute("data-cell-id"); if (n) { const o = this.collection.get(n); if (o) return this.graph.renderer.findViewByCell(o); } return null; } onCellRemoved({ cell: e }) { this.destroySelectionBox(e), this.updateContainer(); } onReseted({ previous: e, current: n }) { this.destroyAllSelectionBoxes(e), n.forEach((o) => { this.listenCellRemoveEvent(o), this.createSelectionBox(o); }), this.updateContainer(); } onCellAdded({ cell: e }) { this.listenCellRemoveEvent(e), this.createSelectionBox(e), this.updateContainer(); } listenCellRemoveEvent(e) { e.off("removed", this.onCellRemoved, this), e.on("removed", this.onCellRemoved, this); } onCollectionUpdated({ added: e, removed: n, options: o }) { e.forEach((r) => { this.trigger("cell:selected", { cell: r, options: o }), r.isNode() ? this.trigger("node:selected", { cell: r, options: o, node: r }) : r.isEdge() && this.trigger("edge:selected", { cell: r, options: o, edge: r }); }), n.forEach((r) => { this.trigger("cell:unselected", { cell: r, options: o }), r.isNode() ? this.trigger("node:unselected", { cell: r, options: o, node: r }) : r.isEdge() && this.trigger("edge:unselected", { cell: r, options: o, edge: r }); }); const s = { added: e, removed: n, options: o, selected: this.cells.filter((r) => !!this.graph.getCellById(r.id)) }; this.trigger("selection:changed", s); } // #endregion dispose() { this.clean(), this.remove(), this.off(); } } eae([ jt.dispose() ], d8.prototype, "dispose", null); var io; (function(t) { const e = "widget-selection"; t.classNames = { root: e, inner: `${e}-inner`, box: `${e}-box`, content: `${e}-content`, rubberband: `${e}-rubberband`, selected: `${e}-selected` }, t.documentEvents = { mousemove: "adjustSelection", touchmove: "adjustSelection", mouseup: "onMouseUp", touchend: "onMouseUp", touchcancel: "onMouseUp" }; function n(o) { return o.getAncestors().length; } t.depthComparator = n; })(io || (io = {})); const tae = `.x6-widget-selection { position: absolute; 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; } `; Le.prototype.isSelectionEnabled = function() { const t = this.getPlugin("selection"); return t ? t.isEnabled() : !1; }; Le.prototype.enableSelection = function() { const t = this.getPlugin("selection"); return t && t.enable(), this; }; Le.prototype.disableSelection = function() { const t = this.getPlugin("selection"); return t && t.disable(), this; }; Le.prototype.toggleSelection = function(t) { const e = this.getPlugin("selection"); return e && e.toggleEnabled(t), this; }; Le.prototype.isMultipleSelection = function() { const t = this.getPlugin("selection"); return t ? t.isMultipleSelection() : !1; }; Le.prototype.enableMultipleSelection = function() { const t = this.getPlugin("selection"); return t && t.enableMultipleSelection(), this; }; Le.prototype.disableMultipleSelection = function() { const t = this.getPlugin("selection"); return t && t.disableMultipleSelection(), this; }; Le.prototype.toggleMultipleSelection = function(t) { const e = this.getPlugin("selection"); return e && e.toggleMultipleSelection(t), this; }; Le.prototype.isSelectionMovable = function() { const t = this.getPlugin("selection"); return t ? t.isSelectionMovable() : !1; }; Le.prototype.enableSelectionMovable = function() { const t = this.getPlugin("selection"); return t && t.enableSelectionMovable(), this; }; Le.prototype.disableSelectionMovable = function() { const t = this.getPlugin("selection"); return t && t.disableSelectionMovable(), this; }; Le.prototype.toggleSelectionMovable = function(t) { const e = this.getPlugin("selection"); return e && e.toggleSelectionMovable(t), this; }; Le.prototype.isRubberbandEnabled = function() { const t = this.getPlugin("selection"); return t ? t.isRubberbandEnabled() : !1; }; Le.prototype.enableRubberband = function() { const t = this.getPlugin("selection"); return t && t.enableRubberband(), this; }; Le.prototype.disableRubberband = function() { const t = this.getPlugin("selection"); return t && t.disableRubberband(), this; }; Le.prototype.toggleRubberband = function(t) { const e = this.getPlugin("selection"); return e && e.toggleRubberband(t), this; }; Le.prototype.isStrictRubberband = function() { const t = this.getPlugin("selection"); return t ? t.isStrictRubberband() : !1; }; Le.prototype.enableStrictRubberband = function() { const t = this.getPlugin("selection"); return t && t.enableStrictRubberband(), this; }; Le.prototype.disableStrictRubberband = function() { const t = this.getPlugin("selection"); return t && t.disableStrictRubberband(), this; }; Le.prototype.toggleStrictRubberband = function(t) { const e = this.getPlugin("selection"); return e && e.toggleStrictRubberband(t), this; }; Le.prototype.setRubberbandModifiers = function(t) { const e = this.getPlugin("selection"); return e && e.setRubberbandModifiers(t), this; }; Le.prototype.setSelectionFilter = function(t) { const e = this.getPlugin("selection"); return e && e.setSelectionFilter(t), this; }; Le.prototype.setSelectionDisplayContent = function(t) { const e = this.getPlugin("selection"); return e && e.setSelectionDisplayContent(t), this; }; Le.prototype.isSelectionEmpty = function() { const t = this.getPlugin("selection"); return t ? t.isEmpty() : !0; }; Le.prototype.cleanSelection = function(t) { const e = this.getPlugin("selection"); return e && e.clean(t), this; }; Le.prototype.resetSelection = function(t, e) { const n = this.getPlugin("selection"); return n && n.reset(t, e), this; }; Le.prototype.getSelectedCells = function() { const t = this.getPlugin("selection"); return t ? t.getSelectedCells() : []; }; Le.prototype.getSelectedCellCount = function() { const t = this.getPlugin("selection"); return t ? t.getSelectedCellCount() : 0; }; Le.prototype.isSelected = function(t) { const e = this.getPlugin("selection"); return e ? e.isSelected(t) : !1; }; Le.prototype.select = function(t, e) { const n = this.getPlugin("selection"); return n && n.select(t, e), this; }; Le.prototype.unselect = function(t, e) { const n = this.getPlugin("selection"); return n ? n.unselect(t, e) : this; }; var nae = globalThis && globalThis.__decorate || function(t, e, n, o) { var s = arguments.length, r = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, n) : o, i; if (typeof Reflect == "object" && typeof Reflect.decorate == "function") r = Reflect.decorate(t, e, n, o); else for (var l = t.length - 1; l >= 0; l--) (i = t[l]) && (r = (s < 3 ? i(r) : s > 3 ? i(e, n, r) : i(e, n)) || r); return s > 3 && r && Object.defineProperty(e, n, r), r; }; class tl extends kn { 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(e) { super(), this.movedMap = /* @__PURE__ */ new WeakMap(), this.unselectMap = /* @__PURE__ */ new WeakMap(), this.name = "selection", this.options = rn({}, tl.defaultOptions, e), Sd(this.name, tae); } init(e) { this.graph = e, this.selectionImpl = new d8(Object.assign(Object.assign({}, this.options), { graph: e })), this.setup(), this.startListening(); } // #region api isEnabled() { return !this.disabled; } enable() { return this.disabled && (this.options.enabled = !0), this; } disable() { return this.disabled || (this.options.enabled = !1), this; } toggleEnabled(e) { return e != null ? e !== this.isEnabled() && (e ? 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(e) { return e != null ? e !== this.isMultipleSelection() && (e ? 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(e) { return e != null ? e !== this.isSelectionMovable() && (e ? 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(e) { return e != null ? e !== this.isRubberbandEnabled() && (e ? 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(e) { return e != null ? e !== this.isStrictRubberband() && (e ? this.enableStrictRubberband() : this.disableStrictRubberband()) : this.isStrictRubberband() ? this.disableStrictRubberband() : this.enableStrictRubberband(), this; } setRubberbandModifiers(e) { this.setModifiers(e); } setSelectionFilter(e) { return this.setFilter(e), this; } setSelectionDisplayContent(e) { return this.setContent(e), this; } isEmpty() { return this.length <= 0; } clean(e = {}) { return this.selectionImpl.clean(e), this; } reset(e, n = {}) { return this.selectionImpl.reset(e ? this.getCells(e) : [], n), this; } getSelectedCells() { return this.cells; } getSelectedCellCount() { return this.length; } isSelected(e) { return this.selectionImpl.isSelected(e); } select(e, n = {}) { const o = this.getCells(e); return o.length && (this.isMultiple() ? this.selectionImpl.select(o, n) : this.reset(o.slice(0, 1), n)), this; } unselect(e, n = {}) { return this.selectionImpl.unselect(this.getCells(e), n), this; } // #endregion setup() { this.selectionImpl.on("*", (e, n) => { this.trigger(e, n), this.graph.trigger(e, 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 }) { const n = this.graph.panning.allowPanning(e, !0), o = this.graph.getPlugin("scroller"), s = o && o.allowPanning(e, !0); (this.allowRubberband(e, !0) || this.allowRubberband(e) && !s && !n) && this.startRubberband(e); } onBlankClick() { this.clean(); } allowRubberband(e, n) { return !this.rubberbandDisabled && Vr.isMatch(e, this.options.modifiers, n); } allowMultipleSelection(e) { return this.isMultiple() && Vr.isMatch(e, this.options.multipleSelectionModifiers); } onCellMouseMove({ cell: e }) { this.movedMap.set(e, !0); } onCellMouseUp({ e, cell: n }) { const o = this.options; let s = this.disabled; !s && this.movedMap.has(n) && (s = o.selectCellOnMoved === !1, s || (s = o.selectNodeOnMoved === !1 && n.isNode()), s || (s = o.selectEdgeOnMoved === !1 && n.isEdge())), s || (this.allowMultipleSelection(e) ? 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, cell: n }) { this.disabled || this.allowMultipleSelection(e) && (this.unselect(n), this.unselectMap.set(n, !0)); } getCells(e) { return (Array.isArray(e) ? e : [e]).map((n) => typeof n == "string" ? this.graph.getCellById(n) : n).filter((n) => n != null); } startRubberband(e) { return this.rubberbandDisabled || this.selectionImpl.startSelecting(e), this; } isMultiple() { return this.options.multiple !== !1; } enableMultiple() { return this.options.multiple = !0, this; } disableMultiple() { return this.options.multiple = !1, this; } setModifiers(e) { return this.options.modifiers = e, this; } setContent(e) { return this.selectionImpl.setContent(e), this; } setFilter(e) { return this.selectionImpl.setFilter(e), this; } dispose() { this.stopListening(), this.off(), this.selectionImpl.dispose(), xd(this.name); } } nae([ kn.dispose() ], tl.prototype, "dispose", null); (function(t) { t.defaultOptions = { rubberband: !1, rubberNode: !0, rubberEdge: !1, pointerEvents: "auto", multiple: !0, multipleSelectionModifiers: ["ctrl", "meta"], movable: !0, strict: !1, selectCellOnMoved: !1, selectNodeOnMoved: !1, selectEdgeOnMoved: !1, following: !0, content: null }; })(tl || (tl = {})); class E1 extends Cn { } (function(t) { function e(n) { const o = [], s = en.getForeignObjectMarkup(); return n ? o.push({ tagName: n, selector: "body" }, s) : o.push(s), o; } t.config({ view: "vue-shape-view", markup: e(), attrs: { body: { fill: "none", stroke: "none", refWidth: "100%", refHeight: "100%" }, fo: { refWidth: "100%", refHeight: "100%" } }, propHooks(n) { if (n.markup == null) { const o = n.primer; if (o) { n.markup = e(o); let s = {}; switch (o) { case "circle": s = { refCx: "50%", refCy: "50%", refR: "50%" }; break; case "ellipse": s = { refCx: "50%", refCy: "50%", refRx: "50%", refRy: "50%" }; break; } n.attrs = rn({}, { body: Object.assign({ refWidth: null, refHeight: null }, s) }, n.attrs || {}); } } return n; } }), Cn.registry.register("vue-shape", t, !0); })(E1 || (E1 = {})); var oae = globalThis && globalThis.__rest || function(t, e) { var n = {}; for (var o in t) Object.prototype.hasOwnProperty.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]); if (t != null && typeof Object.getOwnPropertySymbols == "function") for (var s = 0, o = Object.getOwnPropertySymbols(t); s < o.length; s++) e.indexOf(o[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, o[s]) && (n[o[s]] = t[o[s]]); return n; }; const f8 = {}; function sae(t) { const { shape: e, component: n, inherit: o } = t, s = oae(t, ["shape", "component", "inherit"]); if (!e) throw new Error("should specify shape in config"); f8[e] = { component: n }, Le.registerNode(e, Object.assign({ inherit: o || "vue-shape" }, s), !0); } let Ad = !1; const Ou = Nt({}); function rae(t, e, n, o, s) { if (Ad) { const { Teleport: r, markRaw: i } = $1; Ou[t] = i(G({ render: () => Ae(r, { to: n }, [Ae(e)]), provide: () => ({ getNode: () => o, getGraph: () => s }) })); } } function iae(t) { Ad && delete Ou[t]; } function M1() { return Ad; } function lae() { Ad = !0; const { Fragment: t } = $1; return G({ setup() { return () => Ae(t, {}, Object.keys(Ou).map((e) => Ae(Ou[e]))); } }); } class Au extends bo { getComponentContainer() { return this.selectors && this.selectors.foContent; } confirmUpdate(e) { const n = super.confirmUpdate(e); return this.handleAction(n, Au.action, () => { this.renderVueComponent(); }); } targetId() { return `${this.graph.view.cid}:${this.cell.id}`; } renderVueComponent() { this.unmountVueComponent(); const e = this.getComponentContainer(), n = this.cell, o = this.graph; if (e) { const { component: s } = f8[n.shape]; s && (M1() ? rae(this.targetId(), s, e, n, o) : (this.vm = P1({ render() { return Ae(s); }, provide() { return { getNode: () => n, getGraph: () => o }; } }), this.vm.mount(e))); } } unmountVueComponent() { const e = this.getComponentContainer(); return this.vm && (this.vm.unmount(), this.vm = null), e && (e.innerHTML = ""), e; } onMouseDown(e, n, o) { const s = e.target; if (s.tagName.toLowerCase() === "input") { const i = s.getAttribute("type"); if (i == null || [ "text", "password", "number", "email", "search", "tel", "url" ].includes(i)) return; } super.onMouseDown(e, n, o); } unmount() { return M1() && iae(this.targetId()), this.unmountVueComponent(), super.unmount(), this; } } (function(t) { t.action = "vue", t.config({ bootstrap: [t.action], actions: { component: t.action } }), bo.registry.register("vue-shape-view", t, !0); })(Au || (Au = {})); const aae = { name: "CustomNode", inject: ["getNode"], data() { return { node: this.getNode(), nodeInfo: this.getNode().getData() }; }, computed: {}, watch: { flowTargetData: { handler(t) { console.log(t); }, deep: !0 } }, created() { this.node.on("change:data", this.setDataFromNode); }, mounted() { }, methods: { // 设置节点数据 setDataFromNode() { const t = this.node.getData(); this.nodeInfo = t; } } }, cae = { class: "custom-node" }, uae = ["src"], dae = { class: "title" }; function fae(t, e, n, o, s, r) { var l, a, c, u; const i = Ie("common-icon"); return x(), B("div", cae, [ (l = s.nodeInfo) != null && l.isStartNode ? (x(), q(i, { key: 0, class: "identification", name: "flow-start-icon", size: 16 })) : X("", !0), s.nodeInfo.type !== "process" ? (x(), q(i, { key: 1, name: (a = s.nodeInfo) == null ? void 0 : a.icon, size: 32 }, null, 8, ["name"])) : (x(), B("img", { key: 2, class: "img", src: (c = s.nodeInfo) == null ? void 0 : c.icon, alt: "" }, null, 8, uae)), H("span", dae, ue((u = s.nodeInfo) == null ? void 0 : u.label), 1) ]); } const pf = /* @__PURE__ */ gn(aae, [["render", fae], ["__scopeId", "data-v-f040a42f"]]); const hae = { name: "BranchNode", inject: ["getNode"], data() { return { node: this.getNode(), nodeInfo: this.getNode().getData(), caseList: [], baseHeight: 36 }; }, computed: {}, watch: {}, created() { this.setDataFromNode(); }, mounted() { this.node.on("change:data", this.setDataFromNode); }, methods: { // 新增节点port addNewPorts(t, e) { e.forEach((n, o) => { t.getPort(n.id) || t.insertPort(o, n); }), this.deletePort(); }, // 删除非branchlist的节点 deletePort() { this.node.getPorts().forEach((e) => { e.type === "case" && !this.caseList.some((n) => n.uuid === e.id) && this.node.removePort(e.id); }); }, // 循环判断当前节点port与实际传过来的port数组,判断是否有删除,如果有删除的,调用删除函数删除port // 获取非空节点数 getPortsList(t) { return t != null && t.length ? t.filter((e) => e.id !== "") : []; }, // 设置port点 setDataFromNode() { var n, o; const t = this.node.getData(); this.caseList = this.getPortsList((o = (n = t == null ? void 0 : t.attrsData) == null ? void 0 : n.function) == null ? void 0 : o.branchList) || []; const e = []; this.caseList.forEach((s) => { e.push({ group: "output", id: s.uuid, attrs: { circle: { r: 5, magnet: !0, stroke: "#B1B1B1", strokeWidth: 1, fill: "#B1B1B1", connectionCount: 1, refX: -15, refY: -1 } }, type: "case" }); }), this.addNewPorts(this.node, e), this.node.resize( this.node.getSize().width, this.baseHeight + e.length * 36 ); } } }, pae = (t) => ($a("data-v-982f2bcd"), t = t(), _a(), t), gae = { class: "branch-node" }, mae = { class: "branch-list" }, vae = { class: "branch-item" }, yae = /* @__PURE__ */ pae(() => /* @__PURE__ */ H("span", null, "default", -1)); function bae(t, e, n, o, s, r) { const i = Ie("common-icon"); return x(), B("div", gae, [ H("ul", mae, [ (x(!0), B(Se, null, De(s.caseList, (l, a) => (x(), B("li", { key: a, class: "branch-item" }, [ W(i, { name: "flow-if", class: "icon", size: "16" }), H("span", null, "case: " + ue(l.name), 1) ]))), 128)), H("li", vae, [ W(i, { name: "flow-if", class: "icon", size: "16" }), yae ]) ]) ]); } const wae = /* @__PURE__ */ gn(hae, [["render", bae], ["__scopeId", "data-v-982f2bcd"]]); const Cae = { class: "dnd-nodes" }, Sae = { class: "int-box" }, xae = { class: "node-container" }, kae = { class: "c-title" }, Eae = ["data-id", "data-type", "data-name", "data-label", "data-icon"], Mae = ["src"], $ae = { class: "title" }, _ae = { __name: "DndNodes", props: { nodes: { type: Array, default: () => [] }, dnd: { type: Array, default: () => [] }, processDefItemList: { type: Array, default: () => [] }, onDragStart: { type: Function, default: () => null } }, setup(t) { const e = t, n = R(""), o = R([]), s = R([]), r = M(() => { const c = JSON.parse(JSON.stringify(s.value)), u = n.value; return c.reduce((d, h) => { if (h.nodes.some((p) => p.label.indexOf(u) > -1)) { const p = h.nodes.filter((m) => m.label.indexOf(u) > -1); d.push({ ...h, nodes: p }); } else h.label.indexOf(u) > -1 && d.push({ ...h, nodes: [] }); return d; }, []); }), i = M(() => s.value.map((c) => c.name)), l = (c) => { const u = c.map((d) => ({ name: "process", id: d.assetSpecId, label: d.assetSpecName, type: "process", icon: d.iconUrl })); u.length ? s.value = [ { label: "资产模型节点", name: "process", nodes: u }, ...o.value ] : s.value = [...o.value]; }; Jn(() => { o.value = e.nodes, l(e.processDefItemList); }); const a = (c) => { const { currentTarget: u } = c, { id: d, type: h, name: p, label: m, icon: g } = u.dataset, v = c.clientX - u.getBoundingClientRect().left, y = c.clientY - u.getBoundingClientRect().top; e.onDragStart({ id: d, type: h, name: p, label: m, icon: g, offsetX: v, offsetY: y }, c); }; return (c, u) => { const d = Ie("Search"), h = $e, p = un, m = Ie("common-icon"), g = dl, v = ul, y = h3, w = f3; return x(), B("div", Cae, [ H("div", Sae, [ W(p, { modelValue: n.value, "onUpdate:modelValue": u[0] || (u[0] = (b) => n.value = b), class: "int", placeholder: "根据节点名称搜索", onInput: c.searchFilter }, { suffix: j(() => [ W(h, null, { default: j(() => [ W(d, { onClick: Me(c.searchFilter, ["stop"]) }, null, 8, ["onClick"]) ]), _: 1 }) ]), _: 1 }, 8, ["modelValue", "onInput"]) ]), H("div", xae, [ W(w, { modelValue: f(i), "onUpdate:modelValue": u[1] || (u[1] = (b) => jn(i) ? i.value = b : null) }, { default: j(() => [ (x(!0), B(Se, null, De(f(r), (b) => (x(), q(y, { key: b == null ? void 0 : b.name, name: b.name }, { title: j(() => [ H("div", kae, ue(b.label), 1) ]), default: j(() => [ W(v, null, { default: j(() => [ (x(!0), B(Se, null, De(b.nodes, (C) => (x(), q(g, { key: C.id, span: 8 }, { default: j(() => [ H("div", { "data-id": C.id, "data-type": C.type, "data-name": C.name, "data-label": C.label, "data-icon": C.icon, class: "ability-item", onMousedown: a }, [ b.name !== "process" ? (x(), q(m, { key: 0, name: C.icon, size: 36 }, null, 8, ["name"])) : (x(), B("img", { key: 1, class: "img", src: C.icon || c.icon, alt: "" }, null, 8, Mae)), H("span", $ae, ue(C.label), 1) ], 40, Eae) ]), _: 2 }, 1024))), 128)) ]), _: 2 }, 1024) ]), _: 2 }, 1032, ["name"]))), 128)) ]), _: 1 }, 8, ["modelValue"]) ]) ]); }; } }, Tae = /* @__PURE__ */ gn(_ae, [["__scopeId", "data-v-c995f48d"]]); const Oae = { class: "tool-bar" }, Aae = ["onClick"], Pae = { __name: "ToolBar", props: { graph: { type: Object, default: () => { } }, toolList: { type: Array, default: () => [] } }, emits: ["toolHandelClick"], setup(t, { emit: e }) { const n = (o) => { e("toolHandelClick", o); }; return Je(() => { }), (o, s) => { const r = Ie("common-icon"), i = Un; return x(), B("div", Oae, [ (x(!0), B(Se, null, De(t.toolList, (l, a) => (x(), B("div", { key: a, class: "tool-module" }, [ (x(!0), B(Se, null, De(l, (c) => (x(), q(i, { key: c.name, class: "box-item", effect: "dark", content: c.label, placement: "top-start" }, { default: j(() => [ H("div", { class: "tool", onClick: Me((u) => n(c.name), ["stop"]) }, [ W(r, { class: O(["icon", { disabeld: c.disabeld }]), name: c.name, size: 20 }, null, 8, ["class", "name"]) ], 8, Aae) ]), _: 2 }, 1032, ["content"]))), 128)) ]))), 128)) ]); }; } }, Nae = /* @__PURE__ */ gn(Pae, [["__scopeId", "data-v-8fc563b2"]]); function gf(t, e, n = 1) { return { groups: { output: { position: { name: "right" }, attrs: { circle: { r: 5, magnet: !0, stroke: "#B1B1B1", strokeWidth: 1, fill: "#B1B1B1", connectionCount: n, ...t } } }, input: { position: { name: "left" }, attrs: { circle: { r: 5, magnet: !0, stroke: "#B1B1B1", strokeWidth: 1, fill: "#B1B1B1", connectionCount: 100, refX: 10, refY: -10 } } } }, items: e }; } class bc { constructor(e, n, o) { this.graph = n, this.target = o, this.node = e; } // 创建只出不入节点(start) createStartNode() { return this.graph.createNode({ shape: this.node, width: 96, height: 86, data: this.target, ports: gf({ refX: -4, refY: -10 }, [{ group: "output" }], 100) }); } // 创建只入不出节点(end) createEndNode() { return this.graph.createNode({ shape: this.node, width: 96, height: 86, data: this.target, ports: gf({ refX: -4, refY: -10 }, [{ group: "input" }]) }); } // 创建普通输入输出节点(normal) createNormalNode() { return this.graph.createNode({ shape: this.node, width: 96, height: 86, data: this.target, ports: gf({ refX: -4, refY: -10 }, [ { group: "input" }, { group: "output" } ]) }); } // 创建一入多出节点(branch) createBranchNode() { return this.graph.createNode({ shape: this.node, width: 200, height: 36, data: this.target, ports: { groups: { output: { id: "default", position: { name: "right" }, attrs: { circle: { r: 5, magnet: !0, stroke: "#B1B1B1", strokeWidth: 1, fill: "#B1B1B1", connectionCount: 1, refX: -15, refY: 0 } } }, input: { position: { name: "left" }, attrs: { circle: { r: 5, magnet: !0, stroke: "#B1B1B1", strokeWidth: 1, fill: "#B1B1B1", connectionCount: 100, refX: 0, refY: 0 } } } }, items: [{ group: "input" }, { group: "output" }] } }); } } const Iae = { __name: "RightPanel", props: { computedComponents: { type: Object, default: () => { } }, targetNode: { type: Object, default: () => { } }, showModal: { type: Boolean, default: () => !1 } }, emits: ["closeDialog"], setup(t, { emit: e }) { const n = t, o = R(""), s = M(() => n.computedComponents[o.value]), r = R(null); fe(n.targetNode, (a) => { var c; r.value = a.cell.getData(), o.value = (c = r.value) == null ? void 0 : c.name; }); function i() { o.value = "", r.value = null, e("closeDialog"); } function l() { } return (a, c) => { var d; const u = Ie("common-drawer"); return t.showModal ? (x(), q(u, { key: 0, title: ((d = r.value) == null ? void 0 : d.label) || "弹窗", size: "50%", onCloseDialog: i, onConfirmDialog: l }, { default: j(() => [ o.value ? (x(), B(Se, { key: 0 }, [ o.value in t.computedComponents ? (x(), q(ct(f(s)), { key: 0, "target-node": t.targetNode }, null, 8, ["target-node"])) : X("", !0) ], 64)) : X("", !0) ]), _: 1 }, 8, ["title"])) : X("", !0); }; } }; const Lae = (t) => ($a("data-v-b4d71cec"), t = t(), _a(), t), Rae = { class: "subflow-logic" }, Vae = { class: "logic-l" }, Bae = { class: "logic-r" }, zae = { id: "flow-content", class: "flow-content" }, Dae = /* @__PURE__ */ Lae(() => /* @__PURE__ */ H("div", { id: "flow" }, null, -1)), Fae = { name: "CommonX6Flow" }, Hae = /* @__PURE__ */ Object.assign(Fae, { props: { nodes: { type: Array, default: () => [] }, toolList: { type: Array, default: () => [] }, flowData: { type: Object, default: () => { } }, computedComponents: { type: Object, default: () => { } } }, emits: [ "toolHandelClick", "select-node", "change:node", "open:right-panel" ], setup(t, { emit: e }) { var P; const n = t, { proxy: o } = at(), s = R(!1), r = R(null), i = R(null), l = R(1), a = R(null); function c() { const A = document.getElementById("flow"); r.value = new Le({ container: A, autoResize: !0, background: { color: "#F8F8F8" }, panning: { enabled: !0 }, mousewheel: { enabled: !0 }, scaling: { min: 0.5, max: 2 }, // @:网格 grid: { size: 10, visible: !0 }, // 配置全局连线规则 connecting: { snap: !0, anchor: "center", // 锚点位置 allowBlank: !1, // 是否允许连接空白位置 allowLoop: !1, // 是否允许循环创建节点 allowPort: !0, // 是否允许边链接到链接桩, allowNode: !1, highlight: !0, // snap: true, // 自动吸附(50px) createEdge() { return new Qw({ attrs: { line: { stroke: "#B1B1B1", strokeWidth: 1, targetMarker: { name: "block", width: 5, height: 9 } } }, router: "custom", zIndex: 0, connector: { name: "", args: { radius: 90 } } }); }, // 判断节点是否可被连接 validateConnection({ sourcePort: I, targetPort: V, sourceCell: F, targetCell: L }) { var z, U; if (L.getData().name === "start") return !1; const _ = L.getPorts(); return ((z = F.getPorts().filter((Y) => Y.id === I)) == null ? void 0 : z[0].group) === "input" ? (o.$message.error("不能从输入节点进行连线!"), !1) : ((U = _.filter((Y) => Y.id === V)) == null ? void 0 : U[0].group) === "output" ? (o.$message.error("不能连接输出节点!"), !1) : !0; }, // 限制链接桩只能链接一条边(需在ports中设置connectionCount) validateMagnet({ magnet: I, cell: V }) { let F = 0; const L = I.getAttribute("connection-count"), N = L ? parseInt(L, 10) : 1; N === 0 && o.$message.error("请配置路由分发节点!"); const _ = r.value.getOutgoingEdges(V); return _ && _.forEach((D) => { r.value.findViewByCell(D).sourceMagnet === I && (F += 1); }), F < N; } }, // 节点拖拽到另外一个节点中 embedding: { enabled: !0, findParent({ node: I }) { const V = I.getBBox(); return this.getNodes().filter((F) => { const L = F.getData(); if (L && L.parent) { const N = F.getBBox(); return V.isIntersectWithRect(N); } return !1; }); } } }), i.value = new zr({ target: r.value, scaled: !1, validateNode(I, V) { return I.shape === "html" ? new Promise((F) => { const { draggingNode: L, draggingGraph: N } = V, D = N.findView(L).findOne("foreignObject > body > div"); _t(D, "validating"), setTimeout(() => { Hn(D, "validating"), F(!0); }, 3e3); }) : !0; } }), r.value.use( new tl({ enabled: !0, movable: !0, showNodeSelectionBox: !0, multiple: !1 }) ).use( new l8({ enabled: !0 }) ).use( new a8({ enabled: !0, useLocalStorage: !0 }) ).use( new c8({ enabled: !0 }) ).use( new el({ enabled: !0 }) ), b(r.value); } const u = lae(), d = [ { name: "flow-start-node", component: pf, w: 100, h: 100 }, { name: "flow-end-node", component: pf, w: 100, h: 100 }, { name: "flow-input-node", component: pf, w: 100, h: 100 }, { name: "flow-route-node", component: wae, w: 200, h: 100 } ]; function h() { d.forEach((A) => { sae({ shape: A.name, component: A.component, width: A.w, height: A.h }); }); } h(); const p = (A, I) => { if (A.name === "start") { const V = new bc( "flow-start-node", r.value, A ).createStartNode(); i.value.start(V, I); } }, m = (A, I) => { if (A.name === "end") { const V = new bc( "flow-end-node", r.value, A ).createEndNode(); i.value.start(V, I); } }, g = (A, I) => { if (A.type === "logic" || A.type === "data-processing" || A.type === "route") { const V = new bc( "flow-input-node", r.value, A ).createNormalNode(); i.value.start(V, I); } }, v = (A, I) => { if (A.id === "branch") { const V = new bc( "flow-route-node", r.value, A ).createBranchNode(); i.value.start(V, I); } }; function y(A, I) { p(A, I), m(A, I), g(A, I), v(A, I); } function w() { Le.registerRouter("custom", (A, I, V) => { const F = V.sourceAnchor, L = []; return L.push(new te(F.x + 48, F.y)), L.push( new te(V.targetBBox.leftMiddle.x - 20, V.targetBBox.leftMiddle.y) ), L; }); } function b(A) { A.on("edge:mouseenter", ({ cell: I }) => { if (I) { let V = {}; I.isEdge() && (V = { distance: "30%" }), I.isNode() && (A.value.findView(I).addClass(`${I.shape}-selected`), V = { x: 0, y: 0, offset: { x: -5, y: -5 } }), I.addTools({ name: "button-remove", // 工具名称 args: V // 工具对应的参数 }); } }), A.on("edge:mouseleave", ({ cell: I }) => { I.removeTools(); }), A.on("node:added", () => { }), A.on("node:dblclick", (I) => { e("select-node", I.node.store.data), a.value = I.node.store.data, s.value = !0; }), A.on("node:mousedown", () => { }), A.on("node:selected", (I) => { e("select-node", I); }), A.on("cell:dblclick", (I) => { e("select-node", I); }), A.on("edge:click", (I, V) => { console.log(I, V); }), A.on("edge:contextmenu", ({ edge: I }) => { const V = I.getSourceCell(); console.log(V); }), A.on("node:changed", (I) => { e("change:node", I.cell.store.data); }), A.on("node:contextmenu", () => { }), A.on("blank:dblclick", () => { e("open:right-panel"), s.value = !0; }), A.on("blank:mousedown", () => { }), A.bindKey(["meta+c", "ctrl+c"], () => { const I = A.getSelectedCells(); return I.length && A.copy(I), !1; }), A.bindKey(["meta+x", "ctrl+x"], () => { const I = A.getSelectedCells(); return I.length && A.cut(I), !1; }), A.bindKey(["meta+v", "ctrl+v"], () => { if (!A.isClipboardEmpty()) { const I = A.paste({ offset: 100 }); A.cleanSelection(), A.select(I); } return !1; }), A.bindKey(["meta+d", "ctrl+d"], () => { const I = A.getSelectedCells(); return I.length && (A.cut(I), A.cleanClipboard()), !1; }), A.bindKey(["meta+p", "ctrl+p"], () => (localStorage.setItem("grphData", JSON.stringify(A.toJSON())), !1)), A.bindKey(["meta+z", "ctrl+z"], () => (A.history.canUndo() && A.history.undo(), !1)), A.bindKey(["meta+shift+z", "ctrl+shift+z"], () => (A.history.canRedo() && A.history.redo(), !1)), A.bindKey(["ctrl+a", "meta+a"], () => { const I = A.getNodes(); I && A.select(I); }), A.bindKey("backspace", () => { const I = A.getSelectedCells(); I.length && A.removeCells(I); }), A.bindKey(["ctrl+1", "meta+1"], () => { l.value = A.zoom(), l.value < 2 && A.zoom(0.1); }), A.bindKey(["ctrl+2", "meta+2"], () => { l.value = A.zoom(), l.value > 0.5 && A.zoom(-0.1); }), A.bindKey(["ctrl+3", "meta+3"], () => { A.centerContent(); }); } function C() { r.value.centerContent(); } const S = R(JSON.parse(((P = n.flowData) == null ? void 0 : P.jsonData) || "{}")); function k() { r.value && (r.value.fromJSON([]), r.value.fromJSON(S.value), C()); } function E() { Le.unregisterRouter("custom"), w(), r.value || c(), S.value && k(); } function $(A) { e("toolHandelClick", { name: A, graph: r.value }); } function T() { s.value = !1; } return Jn(() => { var A; S.value = JSON.parse(((A = n.flowData) == null ? void 0 : A.jsonData) || "{}"), k(); }), Je(async () => { Te(() => { E(); }); }), (A, I) => (x(), B(Se, null, [ H("div", Rae, [ H("div", Vae, [ W(Tae, { nodes: t.nodes, graph: r.value, "on-drag-start": y }, null, 8, ["nodes", "graph"]) ]), H("div", Bae, [ W(Nae, { graph: r.value, "tool-list": t.toolList, onToolHandelClick: $ }, null, 8, ["graph", "tool-list"]), H("div", zae, [ Dae, W(f(u)) ]) ]) ]), W(Iae, { "computed-components": t.computedComponents, "target-node": a.value, "show-modal": s.value, onCloseDialog: T }, null, 8, ["computed-components", "target-node", "show-modal"]) ], 64)); } }), jae = /* @__PURE__ */ gn(Hae, [["__scopeId", "data-v-b4d71cec"]]); const Wae = { class: "__common-desc-title" }, Kae = ["src"], qae = { key: 1, class: "__common-title" }, Uae = { class: "__common-description-label" }, Gae = { class: "__common-label" }, Yae = { name: "CommonInfo" }, Xae = /* @__PURE__ */ G({ ...Yae, props: { // 描述信息头部btn集合 extras: { type: Array, default: () => [] }, // 描述标题 title: { type: String, default: () => "" }, // 描述信息label集合 descriptions: { type: Array, default: () => [] }, editIcon: { type: String, default: () => "common-bianji" }, saveIcon: { type: String, default: () => "tool-baocun" }, url: { // 标题图片 type: String, default: () => "" }, descData: { // 描述信息数据对象 type: Object, default: () => { } }, hasIcon: { // 是否有标题编辑icon type: Boolean, default: () => !0 } }, emits: ["editTitle"], setup(t, { emit: e }) { const o = R(t.title), s = R(!1); function r() { s.value = !1, e("editTitle", !0); } const i = R(-1); function l(c) { i.value = c; } function a() { i.value = -1; } return (c, u) => { const d = un, h = Ie("common-icon"), p = tn, m = O3, g = T3; return x(), q(g, { class: "__common-description" }, { title: j(() => [ H("div", Wae, [ t.url && t.url.length ? (x(), B("img", { key: 0, class: "__common-desc-img", src: t.url, alt: "" }, null, 8, Kae)) : X("", !0), t.title && !s.value ? (x(), B("h5", qae, ue(t.title), 1)) : X("", !0), s.value ? (x(), q(d, { key: 2, modelValue: o.value, "onUpdate:modelValue": u[0] || (u[0] = (v) => o.value = v), size: "small" }, null, 8, ["modelValue"])) : X("", !0), t.hasIcon && !s.value ? (x(), q(h, { key: 3, name: t.editIcon, size: 18, onClick: u[1] || (u[1] = Me(() => s.value = !0, ["stop"])) }, null, 8, ["name"])) : X("", !0), s.value ? (x(), q(h, { key: 4, name: "common-guanbi", size: 24, onClick: u[2] || (u[2] = Me(() => s.value = !1, ["stop"])) })) : X("", !0), s.value ? (x(), q(h, { key: 5, name: t.saveIcon, size: 24, onClick: Me(r, ["stop"]) }, null, 8, ["name", "onClick"])) : X("", !0) ]) ]), extra: j(() => [ (x(!0), B(Se, null, De(t.extras, (v, y) => (x(), q(p, { key: y, size: "small", type: v.type || "primary", onClick: Me(v.onClick, ["stop"]) }, { default: j(() => [ Ze(ue(v.label), 1) ]), _: 2 }, 1032, ["type", "onClick"]))), 128)) ]), default: j(() => [ (x(!0), B(Se, null, De(t.descriptions, (v, y) => (x(), q(m, { key: y, label: `${v == null ? void 0 : v.label}:`, onMouseover: (w) => l(y), onMouseout: a }, { default: j(() => { var w; return [ H("span", Uae, [ H("span", Gae, ue((w = t.descData) == null ? void 0 : w[v == null ? void 0 : v.name]), 1), v.delete && i.value === y ? (x(), q(h, { key: 0, name: "common-yuanxingguanbi", size: 16 })) : X("", !0) ]) ]; }), _: 2 }, 1032, ["label", "onMouseover"]))), 128)) ]), _: 1 }); }; } }); const Zae = /* @__PURE__ */ gn(Xae, [["__scopeId", "data-v-5b557ba5"]]), Jae = { name: "CommonComplexFormItem" }, mf = /* @__PURE__ */ G({ ...Jae, props: { formItem: { type: Object, default: () => { } }, formValues: { type: Object, default: () => { } } }, emits: ["changeEvent"], setup(t, { expose: e, emit: n }) { const o = (i) => { n("changeEvent", i); }, s = R(null); function r() { s.value.validate((i) => !!i); } return e({ ruleFormRef: s, checkRules: r }), (i, l) => { var v, y, w; const a = un, c = Ie("common-select"), u = za, d = Xp, h = vd, p = no, m = dd, g = id; return x(), q(g, { ref_key: "ruleFormRef", ref: s, class: "aiot-el-form-item", prop: ((v = t.formItem) == null ? void 0 : v.name) || "", rules: ((y = t.formItem) == null ? void 0 : y.rules) || [], label: ((w = t.formItem) == null ? void 0 : w.label) || "" }, { default: j(() => { var b, C, S, k, E, $, T, P, A, I, V, F, L; return [ t.formItem.type === "input" ? (x(), q(a, Re({ key: 0 }, (b = t.formItem) == null ? void 0 : b.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[0] || (l[0] = (N) => t.formValues[t.formItem.name] = N), class: "__common-form-item", onChange: l[1] || (l[1] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "textarea" ? (x(), q(a, Re({ key: 1 }, (C = t.formItem) == null ? void 0 : C.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[2] || (l[2] = (N) => t.formValues[t.formItem.name] = N), type: "textarea", class: "__common-form-item", onChange: l[3] || (l[3] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "select" ? (x(), q(c, Re({ key: 2 }, (S = t.formItem) == null ? void 0 : S.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[4] || (l[4] = (N) => t.formValues[t.formItem.name] = N), class: "__common-form-item", onChange: l[5] || (l[5] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "input-num" ? (x(), q(u, Re({ key: 3 }, (k = t.formItem) == null ? void 0 : k.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[6] || (l[6] = (N) => t.formValues[t.formItem.name] = N), class: "__common-form-item", onChange: l[7] || (l[7] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "radio" ? (x(), q(Og, Re({ key: 4 }, (E = t.formItem) == null ? void 0 : E.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[8] || (l[8] = (N) => t.formValues[t.formItem.name] = N), onChange: l[9] || (l[9] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "cascader" ? (x(), q(d, Re({ key: 5 }, ($ = t.formItem) == null ? void 0 : $.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[10] || (l[10] = (N) => t.formValues[t.formItem.name] = N), class: "__common-form-item", onChange: l[11] || (l[11] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "switch" ? (x(), q(h, Re({ key: 6 }, (T = t.formItem) == null ? void 0 : T.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[12] || (l[12] = (N) => t.formValues[t.formItem.name] = N), onChange: l[13] || (l[13] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "checkbox" ? (x(), q(p, Re({ key: 7 }, (P = t.formItem) == null ? void 0 : P.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[14] || (l[14] = (N) => t.formValues[t.formItem.name] = N), onChange: l[15] || (l[15] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "check-group" ? (x(), q(wd, Re({ key: 8, modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[16] || (l[16] = (N) => t.formValues[t.formItem.name] = N) }, (A = t.formItem) == null ? void 0 : A.attrs, { onChange: l[17] || (l[17] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), ((I = t.formItem) == null ? void 0 : I.type) === "date-picker" ? (x(), q(m, Re({ key: 9 }, (V = t.formItem) == null ? void 0 : V.attrs, { modelValue: t.formValues[t.formItem.name], "onUpdate:modelValue": l[18] || (l[18] = (N) => t.formValues[t.formItem.name] = N), class: "__common-form-item", onChange: l[19] || (l[19] = (N) => o(t.formItem)) }), null, 16, ["modelValue"])) : X("", !0), t.formItem.type === "component" ? (x(), q(ct((F = t.formItem) == null ? void 0 : F.componentId), { key: 10 })) : X("", !0), ((L = t.formItem) == null ? void 0 : L.type) === "slot" ? le(i.$slots, t.formItem.slotName, { key: 11 }) : X("", !0) ]; }), _: 3 }, 8, ["prop", "rules", "label"]); }; } }); const Qae = { name: "CommonComplexForm" }, ece = /* @__PURE__ */ G({ ...Qae, props: { complexForms: { type: Array, default: () => [] }, formValues: { type: Object, default: () => { } } }, setup(t) { return (e, n) => { const o = dl, s = ul, r = Dp; return x(), q(r, { "label-width": "auto", inline: !0 }, { default: j(() => [ W(s, { gutter: 20 }, { default: j(() => [ (x(!0), B(Se, null, De(t.complexForms, (i, l) => { var a; return x(), B(Se, { key: l }, [ i != null && i.childForms ? (x(), B(Se, { key: 0 }, [ W(o, { span: (i == null ? void 0 : i.span) || 12 }, { default: j(() => [ W(mf, { "form-item": i, "form-values": t.formValues }, yo({ _: 2 }, [ i.slotName ? { name: i.slotName, fn: j((c) => [ le(e.$slots, i.slotName, { row: c.row }) ]), key: "0" } : void 0 ]), 1032, ["form-item", "form-values"]) ]), _: 2 }, 1032, ["span"]), t.formValues[i.name] ? (x(!0), B(Se, { key: 0 }, De((a = i == null ? void 0 : i.childForms) == null ? void 0 : a[t.formValues[i.name]], (c, u) => (x(), q(o, { key: u, span: (c == null ? void 0 : c.span) || 12 }, { default: j(() => [ W(mf, { "form-item": c, "form-values": t.formValues }, yo({ _: 2 }, [ i.slotName ? { name: i.slotName, fn: j((d) => [ le(e.$slots, i.slotName, { row: d.row }) ]), key: "0" } : void 0 ]), 1032, ["form-item", "form-values"]) ]), _: 2 }, 1032, ["span"]))), 128)) : X("", !0) ], 64)) : (x(), q(o, { key: 1, span: (i == null ? void 0 : i.span) || 12 }, { default: j(() => [ W(mf, { "form-item": i, "form-values": t.formValues }, yo({ _: 2 }, [ i.slotName ? { name: i.slotName, fn: j((c) => [ le(e.$slots, i.slotName, { row: c.row }) ]), key: "0" } : void 0 ]), 1032, ["form-item", "form-values"]) ]), _: 2 }, 1032, ["span"])) ], 64); }), 128)) ]), _: 3 }) ]), _: 3 }); }; } }), h8 = [ Fee, Yee, nte, ite, fte, gte, bte, Cte, Ite, k4, jte, Xte, nne, $ne, One, Nne, Lne, zne, Zae, ece, wd, Og, jae ], tce = (t) => { h8.forEach((e) => { t.component(e.name, e); }); }, nce = (t) => { tce(t), t.use(ree); }, uce = { ...h8, install: nce }; export { uce as default }; Merge branch 'dev' of http://10.1.235.20:3000/ipu/ios-share into dev · b9d825f760 - Nuosi Git Service
Преглед на файлове

Merge branch 'dev' of http://10.1.235.20:3000/ipu/ios-share into dev

liuql6 преди 3 години
родител
ревизия
b9d825f760

+ 36 - 0
IPUMobileFunc/IPUMobileFunc.xcodeproj/project.pbxproj

@ -15,6 +15,13 @@
15 15
		045994D224247BBF0002F4A3 /* IPUScreenCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 045994D024247BBF0002F4A3 /* IPUScreenCapture.m */; };
16 16
		04C30B9B22E6ADF200BA7B68 /* IPUTipsHUDPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 04C30B9922E6ADF200BA7B68 /* IPUTipsHUDPlugin.m */; };
17 17
		04C30B9C22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
18
		76EC0CDB276056A30019B2F5 /* IPUSignStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 76EC0CD62760569E0019B2F5 /* IPUSignStoryboard.storyboard */; };
19
		76EC0CDC276056A30019B2F5 /* IPUSignViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EC0CD72760569F0019B2F5 /* IPUSignViewController.m */; };
20
		76EC0CDD276056A30019B2F5 /* IPUSignView.h in Headers */ = {isa = PBXBuildFile; fileRef = 76EC0CD8276056A10019B2F5 /* IPUSignView.h */; };
21
		76EC0CDE276056A30019B2F5 /* IPUSignViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 76EC0CD9276056A20019B2F5 /* IPUSignViewController.h */; };
22
		76EC0CDF276056A30019B2F5 /* IPUSignView.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EC0CDA276056A30019B2F5 /* IPUSignView.m */; };
23
		76FEC2E3275F4E2100F87937 /* IPUDialogUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 76FEC2E1275F4E2000F87937 /* IPUDialogUtil.h */; };
24
		76FEC2E4275F4E2100F87937 /* IPUDialogUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 76FEC2E2275F4E2100F87937 /* IPUDialogUtil.m */; };
18 25
		B2074DAB24AC82B700E6E924 /* IPUClipBoardPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = B2074DA924AC82B700E6E924 /* IPUClipBoardPlugin.m */; };
19 26
		B2074DAC24AC82B700E6E924 /* IPUClipBoardPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = B2074DAA24AC82B700E6E924 /* IPUClipBoardPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
20 27
		B20A68DE274B2E1E004393D4 /* IPUNetworkCache.h in Headers */ = {isa = PBXBuildFile; fileRef = B20A68DC274B2E1E004393D4 /* IPUNetworkCache.h */; };
@ -151,6 +158,13 @@
151 158
		045994D024247BBF0002F4A3 /* IPUScreenCapture.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IPUScreenCapture.m; sourceTree = "<group>"; };
152 159
		04C30B9922E6ADF200BA7B68 /* IPUTipsHUDPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUTipsHUDPlugin.m; sourceTree = "<group>"; };
153 160
		04C30B9A22E6ADF200BA7B68 /* IPUTipsHUDPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUTipsHUDPlugin.h; sourceTree = "<group>"; };
161
		76EC0CD62760569E0019B2F5 /* IPUSignStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = IPUSignStoryboard.storyboard; sourceTree = "<group>"; };
162
		76EC0CD72760569F0019B2F5 /* IPUSignViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUSignViewController.m; sourceTree = "<group>"; };
163
		76EC0CD8276056A10019B2F5 /* IPUSignView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUSignView.h; sourceTree = "<group>"; };
164
		76EC0CD9276056A20019B2F5 /* IPUSignViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUSignViewController.h; sourceTree = "<group>"; };
165
		76EC0CDA276056A30019B2F5 /* IPUSignView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUSignView.m; sourceTree = "<group>"; };
166
		76FEC2E1275F4E2000F87937 /* IPUDialogUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUDialogUtil.h; sourceTree = "<group>"; };
167
		76FEC2E2275F4E2100F87937 /* IPUDialogUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUDialogUtil.m; sourceTree = "<group>"; };
154 168
		B2074DA924AC82B700E6E924 /* IPUClipBoardPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPUClipBoardPlugin.m; sourceTree = "<group>"; };
155 169
		B2074DAA24AC82B700E6E924 /* IPUClipBoardPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPUClipBoardPlugin.h; sourceTree = "<group>"; };
156 170
		B20A68DC274B2E1E004393D4 /* IPUNetworkCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPUNetworkCache.h; sourceTree = "<group>"; };
@ -284,6 +298,18 @@
284 298
/* End PBXFrameworksBuildPhase section */
285 299
286 300
/* Begin PBXGroup section */
301
		76EC0CD5276056790019B2F5 /* sign */ = {
302
			isa = PBXGroup;
303
			children = (
304
				76EC0CD62760569E0019B2F5 /* IPUSignStoryboard.storyboard */,
305
				76EC0CD8276056A10019B2F5 /* IPUSignView.h */,
306
				76EC0CDA276056A30019B2F5 /* IPUSignView.m */,
307
				76EC0CD9276056A20019B2F5 /* IPUSignViewController.h */,
308
				76EC0CD72760569F0019B2F5 /* IPUSignViewController.m */,
309
			);
310
			path = sign;
311
			sourceTree = "<group>";
312
		};
287 313
		B2445C7C21F177E8007AB82E /* Utils */ = {
288 314
			isa = PBXGroup;
289 315
			children = (
@ -427,6 +453,7 @@
427 453
		B2D71A0122A6528F00604504 /* Implementation */ = {
428 454
			isa = PBXGroup;
429 455
			children = (
456
				76EC0CD5276056790019B2F5 /* sign */,
430 457
				B2D71A0222A652E400604504 /* IPUBasicUtil.h */,
431 458
				B2D71A0322A652E400604504 /* IPUBasicUtil.m */,
432 459
				B2D71A2A22A66D2500604504 /* IPUEmailUtil.h */,
@ -447,6 +474,8 @@
447 474
				B2464E8722CF2C4E002A159E /* IPUNetworkUtil.m */,
448 475
				B2EE784622D2D25A00E2C466 /* IPUStorageUtil.h */,
449 476
				B2EE784722D2D25A00E2C466 /* IPUStorageUtil.m */,
477
				76FEC2E1275F4E2000F87937 /* IPUDialogUtil.h */,
478
				76FEC2E2275F4E2100F87937 /* IPUDialogUtil.m */,
450 479
			);
451 480
			path = Implementation;
452 481
			sourceTree = "<group>";
@ -507,12 +536,14 @@
507 536
				B264A22B22B33EB200714D0D /* IPUDatabaseUtil.h in Headers */,
508 537
				B28E568621F1A76E00422D15 /* IPUCustomCameraPlugin.h in Headers */,
509 538
				B28E56D621F1C3D100422D15 /* IPUAuthenticationPlugin.h in Headers */,
539
				76EC0CDE276056A30019B2F5 /* IPUSignViewController.h in Headers */,
510 540
				B2D5191D23B5ADE1008086A7 /* IPUBMapPlugin.h in Headers */,
511 541
				B2445C7F21F1780E007AB82E /* IPUDatabaseHelper.h in Headers */,
512 542
				B28E56B221F1B89E00422D15 /* IPUMailPlugin.h in Headers */,
513 543
				B28E56BE21F1BB2C00422D15 /* IPUNetworkPlugin.h in Headers */,
514 544
				B2EB0F1F23A7287E00EBB34D /* IPUQRCodePlugin.h in Headers */,
515 545
				B28E56A221F1B0C900422D15 /* IPUDatabasePlugin.h in Headers */,
546
				76FEC2E3275F4E2100F87937 /* IPUDialogUtil.h in Headers */,
516 547
				B28E56B621F1B92A00422D15 /* IPUFilePlugin.h in Headers */,
517 548
				B28E56A621F1B24F00422D15 /* IPUContactsPlugin.h in Headers */,
518 549
				B2DB0D60273A6BCB0010074A /* EBCustomBannerView.h in Headers */,
@ -526,6 +557,7 @@
526 557
				B28E569A21F1AE0600422D15 /* IPUImageCachePlugin.h in Headers */,
527 558
				B28E567421F188DF00422D15 /* IPUUNIRestUtil.h in Headers */,
528 559
				B2DB0D61273A6BCB0010074A /* EBBannerWindow.h in Headers */,
560
				76EC0CDD276056A30019B2F5 /* IPUSignView.h in Headers */,
529 561
				B28E56D221F1C39700422D15 /* IPUSystemPermissionPlugin.h in Headers */,
530 562
				B2464E8822CF2C4E002A159E /* IPUNetworkUtil.h in Headers */,
531 563
				B22F9162274BAAA30034D77D /* IPUNFCPlugin.h in Headers */,
@ -630,6 +662,7 @@
630 662
			files = (
631 663
				B2DB0D67273A6BCB0010074A /* EBBannerView.xib in Resources */,
632 664
				B2DB0D68273A6BCB0010074A /* EBBannerViewController.xib in Resources */,
665
				76EC0CDB276056A30019B2F5 /* IPUSignStoryboard.storyboard in Resources */,
633 666
			);
634 667
			runOnlyForDeploymentPostprocessing = 0;
635 668
		};
@ -655,6 +688,7 @@
655 688
				045994D224247BBF0002F4A3 /* IPUScreenCapture.m in Sources */,
656 689
				B26A20A123CD9E0200844692 /* UIImage+IPUCompress.m in Sources */,
657 690
				04449845267997990024A808 /* IPUSysLocationPlugin.m in Sources */,
691
				76EC0CDF276056A30019B2F5 /* IPUSignView.m in Sources */,
658 692
				B281A33B22CC85B600D69B25 /* IPUAudioPlugin.m in Sources */,
659 693
				B28E568721F1A76E00422D15 /* IPUCustomCameraPlugin.m in Sources */,
660 694
				B271C33A22ADE4AC0030F3C9 /* IPUUploadDownloadUtil.m in Sources */,
@ -669,6 +703,7 @@
669 703
				B281A33A22CC84A100D69B25 /* IPUContactsPlugin.m in Sources */,
670 704
				B28E56AF21F1B4EA00422D15 /* IPUBasicPlugin.m in Sources */,
671 705
				B2DB0D63273A6BCB0010074A /* EBBannerView.m in Sources */,
706
				76FEC2E4275F4E2100F87937 /* IPUDialogUtil.m in Sources */,
672 707
				B22F915F274B940E0034D77D /* IPUNFCManager.m in Sources */,
673 708
				B22F9163274BAAA30034D77D /* IPUNFCPlugin.m in Sources */,
674 709
				B281A32B22CB3C6300D69B25 /* IPUFilesUtil.m in Sources */,
@ -697,6 +732,7 @@
697 732
				B2DB0D6D273A6BCB0010074A /* EBBannerView+Categories.m in Sources */,
698 733
				B264A22C22B33EB200714D0D /* IPUDatabaseUtil.m in Sources */,
699 734
				B2DB0D70273A6BCB0010074A /* EBBannerViewController.m in Sources */,
735
				76EC0CDC276056A30019B2F5 /* IPUSignViewController.m in Sources */,
700 736
				B29195532539307500AD4C60 /* IPUServiceChangePlugin.m in Sources */,
701 737
				04C30B9B22E6ADF200BA7B68 /* IPUTipsHUDPlugin.m in Sources */,
702 738
				B28E568F21F1A8F500422D15 /* IPUCameraPlugin.m in Sources */,

+ 15 - 0
IPUMobileFunc/IPUMobileFunc/Camera/IPUCameraPlugin.h

@ -50,4 +50,19 @@
50 50
 */
51 51
- (void)getQrCodePhotoViaLibrary:(NSArray *)param;
52 52
53
/**
54
 将图片文件转为base64
55
 @param [图片文件路径]
56
 */
57
- (void)getBase64Picture:(NSArray *)param;
58
59
/**
60
 压缩图片文件,返回base64
61
 @param [图片文件路径, 压缩后最大文件size, 压缩率(100代表不压缩)]
62
 */
63
- (void)compressImage:(NSArray *)param;
64
65
66
67
53 68
@end

+ 21 - 0
IPUMobileFunc/IPUMobileFunc/Camera/IPUCameraPlugin.m

@ -350,6 +350,9 @@ callback: {"result" : "图片base64编码或者路径", "qrcodes" : ["图片中
350 350
}
351 351
352 352
- (void)getBase64Picture:(NSArray *)param {
353
    if (!param) {
354
        return;
355
    }
353 356
    NSString *path = param[0];
354 357
    NSString *base64 = [self base64Encoding:path];
355 358
    [self callback:base64];
@ -439,4 +442,22 @@ callback: {"result" : "图片base64编码或者路径", "qrcodes" : ["图片中
439 442
                                         completion:nil];
440 443
}
441 444
445
446
- (void)compressImage:(NSArray *)param {
447
    if (!param || param.count < 3) {
448
        return;
449
    }
450
    NSString *path = param[0];
451
    int maxLength = [param[1] intValue];
452
    CGFloat quality = [param[2] floatValue] / 100;
453
    UIImage *image = [UIImage imageWithContentsOfFile:path];
454
    NSData *imageData = UIImageJPEGRepresentation(image, quality);
455
    //如果根据压缩率参数压缩,结果大于最大文件大小参数,则进一步处理
456
    if (imageData.length > maxLength) {
457
        imageData = [UIImage compressImage:image maxLength:maxLength minWith:0];
458
    }
459
    NSString *base64 = [imageData base64EncodedStringWithOptions:0];
460
    [self callback:base64];
461
}
462
442 463
@end

+ 5 - 3
IPUMobileFunc/IPUMobileFunc/IPUMobileUIPlugin.h

@ -107,7 +107,9 @@
107 107
- (void)tip:(NSArray *)param;
108 108
//alert弹出框
109 109
- (void)alert:(NSArray *)param;
110
111
112
110
/// 弹出列表选择的alert
111
- (void)getChoice:(NSArray *)params;
112
/// 弹出一个签名的界面,返回签名照片的base64字符串
113
/// 如果需要保存到相册,需要添加权限Privacy - Photo Library Additions Usage Description
114
- (void)getSign:(NSArray *)params;
113 115
@end

+ 32 - 1
IPUMobileFunc/IPUMobileFunc/IPUMobileUIPlugin.m

@ -10,7 +10,8 @@
10 10
11 11
#import "IPUNetworkPlugin.h"
12 12
#import "IPUNetworkUtil.h"
13
13
#import "IPUDialogUtil.h"
14
#import "IPUSignViewController.h"
14 15
#import <IPUFoundation/IPUFoundation.h>
15 16
#import <IPUMobile/IPUMobile.h>
16 17
#import <IPUMobileUI/IPUMobileUI.h>
@ -798,6 +799,36 @@
798 799
                     }];
799 800
}
800 801
802
- (void)getChoice:(NSArray *)params {
803
    UIViewController *vc = [self getViewController];
804
    NSString *nameString = params[0];
805
    NSString *valueString = params[1];
806
    NSString *title = params[2];
807
    if (!nameString) {
808
        [self error:@"参数错误"];
809
        return;
810
    }
811
    NSArray *itemNames = [nameString componentsSeparatedByString:@","];
812
    NSArray *itemValues = @[@""];
813
    if (valueString) {
814
        itemValues = [valueString componentsSeparatedByString:@","];
815
    }
816
    [IPUDialogUtil showListDialog:vc title: title itemNames:itemNames itemValues:itemValues completion:^(NSString *result) {
817
        [self callback: result];
818
    }];
819
}
820
821
- (void)getSign:(NSArray *)params {
822
    IPUSignViewController *vc = [[UIStoryboard storyboardWithName:"IPUSignStoryboard" bundle:nil] instantiateInitialViewController];
823
    vc.modalPresentationStyle = UIModalPresentationCustom
824
    vc.saveToPhotos = false;
825
    vc.completion = ^(NSString * _Nonnull base64) {
826
        [self callback: base64];
827
    }
828
    UIViewController *current = [self getViewController];
829
    [current presentViewController:vc animated:true completion:nil];
830
}
831
801 832
#pragma mark - other method
802 833
- (void)clearBackStack:(NSArray *)param {
803 834
    [[self.mobileDelegate getFlipperView] clearBackStack];

+ 15 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/IPUDialogUtil.h

@ -0,0 +1,15 @@
1
//
2
//  IPUDialogUtil.h
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import <Foundation/Foundation.h>
10
#import <UIKit/UIKit.h>
11
12
@interface IPUDialogUtil : NSObject
13
+ (void) showListDialog: (UIViewController *)controller title: (NSString *)title itemNames: (NSArray *)itemNames itemValues: (NSArray *)itemValues completion:(void (^)(NSString *result))completion;
14
@end
15

+ 35 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/IPUDialogUtil.m

@ -0,0 +1,35 @@
1
//
2
//  IPUDialogUtil.m
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import "IPUDialogUtil.h"
10
11
@implementation IPUDialogUtil
12
+ (void) showListDialog: (UIViewController *)controller title: (NSString *)title itemNames: (NSArray *)itemNames itemValues: (NSArray *)itemValues completion:(void (^)(NSString *result))completion {
13
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:title message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
14
    UIFont *font = [UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
15
    NSMutableAttributedString *s = [[NSMutableAttributedString alloc]initWithString:title attributes:@{NSFontAttributeName: font}];
16
    [alert setValue:s forKey:@"attributedTitle"];
17
    for (int i = 0; i < itemNames.count; i++) {
18
        NSString *name = itemNames[i];
19
        NSString *value = @"";
20
        if (itemValues && itemValues.count == itemNames.count) {
21
            value = itemValues[i];
22
        } else {
23
            value = [NSString stringWithFormat:@"%d", i];
24
        }
25
        [alert addAction: [UIAlertAction actionWithTitle:name style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
26
            completion(value);
27
        }]];
28
    }
29
    [alert addAction: [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
30
        completion(@"");
31
        [alert dismissViewControllerAnimated:true completion:nil];
32
    }]];
33
    [controller presentViewController:alert animated:true completion:nil];
34
}
35
@end

+ 72 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/sign/IPUSignStoryboard.storyboard

@ -0,0 +1,72 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
3
    <device id="retina6_1" orientation="portrait" appearance="light"/>
4
    <dependencies>
5
        <deployment identifier="iOS"/>
6
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
7
        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
8
        <capability name="System colors in document resources" minToolsVersion="11.0"/>
9
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10
    </dependencies>
11
    <scenes>
12
        <!--Sign View Controller-->
13
        <scene sceneID="s0d-6b-0kx">
14
            <objects>
15
                <viewController id="Y6W-OH-hqX" customClass="IPUSignViewController" sceneMemberID="viewController">
16
                    <view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
17
                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
18
                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19
                        <subviews>
20
                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JDQ-qe-blJ" customClass="IPUSignView">
21
                                <rect key="frame" x="0.0" y="44" width="414" height="763"/>
22
                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
23
                            </view>
24
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nZ7-Az-xxi">
25
                                <rect key="frame" x="80" y="812" width="80" height="40"/>
26
                                <constraints>
27
                                    <constraint firstAttribute="height" constant="40" id="9Ed-Eu-Rwv"/>
28
                                    <constraint firstAttribute="width" constant="80" id="rYN-Nu-Jsx"/>
29
                                </constraints>
30
                                <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
31
                                <state key="normal" title="Button"/>
32
                            </button>
33
                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fq0-8T-6Eo">
34
                                <rect key="frame" x="254" y="812" width="80" height="40"/>
35
                                <constraints>
36
                                    <constraint firstAttribute="width" constant="80" id="9xs-5q-bxK"/>
37
                                    <constraint firstAttribute="height" constant="40" id="sbr-57-GDl"/>
38
                                </constraints>
39
                                <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
40
                                <state key="normal" title="Button"/>
41
                            </button>
42
                        </subviews>
43
                        <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
44
                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
45
                        <constraints>
46
                            <constraint firstItem="JDQ-qe-blJ" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" id="XrI-J0-biz"/>
47
                            <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="fq0-8T-6Eo" secondAttribute="trailing" constant="80" id="am9-7w-WM4"/>
48
                            <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="JDQ-qe-blJ" secondAttribute="trailing" id="cWD-2E-6PR"/>
49
                            <constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="JDQ-qe-blJ" secondAttribute="bottom" constant="55" id="ccY-SJ-Z23"/>
50
                            <constraint firstItem="nZ7-Az-xxi" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="80" id="dNO-d2-hmS"/>
51
                            <constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="nZ7-Az-xxi" secondAttribute="bottom" constant="10" id="hVf-iq-PXH"/>
52
                            <constraint firstItem="JDQ-qe-blJ" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="pFJ-rp-u3i"/>
53
                            <constraint firstItem="fq0-8T-6Eo" firstAttribute="centerY" secondItem="nZ7-Az-xxi" secondAttribute="centerY" id="x7e-p8-ce8"/>
54
                        </constraints>
55
                    </view>
56
                    <connections>
57
                        <outlet property="cancelButton" destination="nZ7-Az-xxi" id="fwY-hU-GCo"/>
58
                        <outlet property="confirmButton" destination="fq0-8T-6Eo" id="V6z-aw-p91"/>
59
                        <outlet property="signView" destination="JDQ-qe-blJ" id="xD8-gd-mpB"/>
60
                    </connections>
61
                </viewController>
62
                <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
63
            </objects>
64
            <point key="canvasLocation" x="132" y="117"/>
65
        </scene>
66
    </scenes>
67
    <resources>
68
        <systemColor name="systemBackgroundColor">
69
            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
70
        </systemColor>
71
    </resources>
72
</document>

+ 23 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/sign/IPUSignView.h

@ -0,0 +1,23 @@
1
//
2
//  IPUSignView.m
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import <Foundation/Foundation.h>
10
#import <UIKit/UIKit.h>
11
NS_ASSUME_NONNULL_BEGIN
12
13
IB_DESIGNABLE
14
15
@interface IPUSignView : UIView
16
@property (nonatomic, strong) UIColor *panColor;
17
@property (nonatomic, assign) CGFloat panLineWidth;
18
@property (nonatomic, strong) CAShapeLayer *currentDrawLayer;
19
@property (nonatomic, strong) UIBezierPath *currentDrawPath;
20
@property (nonatomic, strong) NSMutableArray *drawLayerArray;
21
@end
22
23
NS_ASSUME_NONNULL_END

+ 93 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/sign/IPUSignView.m

@ -0,0 +1,93 @@
1
//
2
//  IPUSignView.m
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import "IPUSignView.h"
10
11
@implementation IPUSignView
12
13
- (instancetype)init {
14
    if (self = [super init]) {
15
        self.backgroundColor = [UIColor whiteColor];
16
        self.panColor = [UIColor blackColor];
17
        self.panLineWidth = 2.f;
18
    }
19
    
20
    return self;
21
}
22
23
- (instancetype)initWithCoder:(NSCoder *)coder {
24
    if (self = [super initWithCoder:coder]) {
25
        self.backgroundColor = [UIColor whiteColor];
26
        self.panColor = [UIColor blackColor];
27
        self.panLineWidth = 2.f;
28
    }
29
    return self;
30
}
31
32
- (instancetype)initWithFrame:(CGRect)frame {
33
    if (self = [super initWithFrame:frame]) {
34
        self.backgroundColor = [UIColor whiteColor];
35
        self.panColor = [UIColor blackColor];
36
        self.panLineWidth = 2.f;
37
    }
38
    return self;
39
}
40
41
- (void)dealloc {
42
    [self releaseAllLayers];
43
}
44
45
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
46
    UITouch *touch = touches.anyObject;
47
    CGPoint startPoint = [touch locationInView:self];
48
    
49
    self.currentDrawLayer = [self makeDrawLayer];
50
    self.currentDrawPath = [self makeDrawPath];
51
    [self.currentDrawPath moveToPoint:startPoint];
52
}
53
54
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
55
    UITouch *touch = touches.anyObject;
56
    CGPoint currentPoint = [touch locationInView:self];
57
    
58
    [self.currentDrawPath addLineToPoint:currentPoint];
59
    self.currentDrawLayer.path = self.currentDrawPath.CGPath;
60
}
61
62
- (NSMutableArray *)drawLayerArray {
63
    if (!_drawLayerArray) {
64
        _drawLayerArray = [NSMutableArray arrayWithCapacity:10];
65
    }
66
    return _drawLayerArray;
67
}
68
69
- (CAShapeLayer *)makeDrawLayer {
70
    CAShapeLayer *drawLayer = [CAShapeLayer layer];
71
    drawLayer.frame = self.bounds;
72
    drawLayer.fillColor = [UIColor clearColor].CGColor;
73
    drawLayer.lineWidth = self.panLineWidth;
74
    drawLayer.strokeColor = self.panColor.CGColor;
75
    [self.layer insertSublayer:drawLayer atIndex:(unsigned)self.drawLayerArray.count];
76
    [self.drawLayerArray addObject:drawLayer];
77
    return drawLayer;
78
}
79
80
- (UIBezierPath *)makeDrawPath {
81
    UIBezierPath *drawPath = [UIBezierPath bezierPath];
82
    drawPath.lineCapStyle = kCGLineCapRound;
83
    drawPath.lineJoinStyle = kCGLineJoinRound;
84
    
85
    return drawPath;
86
}
87
88
- (void)releaseAllLayers {
89
    [self.drawLayerArray makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
90
    [self.drawLayerArray removeAllObjects];
91
}
92
93
@end

+ 21 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/sign/IPUSignViewController.h

@ -0,0 +1,21 @@
1
//
2
//  IPUSignViewController.m
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import <Foundation/Foundation.h>
10
#import <UIKit/UIKit.h>
11
#import "IPUSignView.h"
12
NS_ASSUME_NONNULL_BEGIN
13
14
typedef void(^IPUSignCompletion)(NSString * base64);
15
16
@interface IPUSignViewController : UIViewController
17
@property (nonatomic, copy) IPUSignCompletion completion;
18
@property (nonatomic, assign) BOOL saveToPhotos;
19
@end
20
21
NS_ASSUME_NONNULL_END

+ 86 - 0
IPUMobileFunc/IPUMobileFunc/Implementation/sign/IPUSignViewController.m

@ -0,0 +1,86 @@
1
//
2
//  IPUSignViewController.m
3
//  IPUMobileFunc
4
//
5
//  Created by yang dingli on 2021/12/7.
6
//  Copyright © 2021 Asiainfo. All rights reserved.
7
//
8
9
#import "IPUSignViewController.h"
10
#import <Photos/Photos.h>
11
12
@interface IPUSignViewController ()
13
@property (weak, nonatomic) IBOutlet IPUSignView *signView;
14
15
@property (weak, nonatomic) IBOutlet UIButton *cancelButton;
16
@property (weak, nonatomic) IBOutlet UIButton *confirmButton;
17
18
@end
19
20
21
@implementation IPUSignViewController
22
23
- (void)loadView {
24
    [super loadView];
25
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
26
}
27
28
- (void)viewDidLoad {
29
    [super viewDidLoad];
30
    self.view.backgroundColor = UIColor.whiteColor;
31
    _cancelButton.layer.cornerRadius = 5;
32
    _cancelButton.layer.masksToBounds = true;
33
    [_cancelButton setBackgroundColor:UIColor.systemBlueColor];
34
    [_cancelButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
35
    [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
36
    [_cancelButton addTarget:self action:@selector(onCancel:) forControlEvents:UIControlEventTouchUpInside];
37
38
    _confirmButton.layer.cornerRadius = 5;
39
    _confirmButton.layer.masksToBounds = true;
40
    [_confirmButton setBackgroundColor:UIColor.systemBlueColor];
41
    [_confirmButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
42
    [_confirmButton setTitle:@"确定" forState:UIControlStateNormal];
43
    [_confirmButton addTarget:self action:@selector(onConfirm:) forControlEvents:UIControlEventTouchUpInside];
44
}
45
46
- (void)dealloc {
47
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];
48
}
49
50
-(void)onConfirm:(UIButton *)sender {
51
    UIImage *image = [self snapshot:self.signView];
52
    if (_completion) {
53
        _completion([self encodeToBase64String:image]);
54
    }
55
    if(_saveToPhotos) {
56
        [self saveImageToPhotos:image];
57
    }
58
    [self dismissViewControllerAnimated:true completion:nil];
59
}
60
61
62
-(void)onCancel:(UIButton *)sender {
63
    [self dismissViewControllerAnimated:true completion:nil];
64
}
65
66
-(void)saveImageToPhotos:(UIImage*)image{
67
    [PHPhotoLibrary.sharedPhotoLibrary performChanges:^{
68
        [PHAssetChangeRequest creationRequestForAssetFromImage: image];
69
    } completionHandler:^(BOOL success, NSError * _Nullable error) {
70
        NSLog(@"save iamge to photos result:%@  error:%@", success ? @"成功" : @"失败", error.localizedDescription);
71
    }];
72
}
73
74
- (UIImage *)snapshot:(UIView *)view {
75
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0);
76
    [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
77
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
78
    UIGraphicsEndImageContext();
79
    return image;
80
}
81
82
- (NSString*)encodeToBase64String:(UIImage*)image {
83
    return [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
84
}
85
86
@end