@blueking/flow-canvas 0.0.1-beta.4 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,24 +1,24 @@
1
- import { ref as z, computed as j, onScopeDispose as Le, defineComponent as re, onBeforeUnmount as Se, createElementBlock as S, openBlock as k, normalizeStyle as me, createElementVNode as A, createVNode as Be, createCommentVNode as H, normalizeClass as W, Transition as ze, withCtx as Ne, withModifiers as He, createTextVNode as De, renderSlot as fe, onMounted as Fe, watch as le, createBlock as ve, Fragment as ie, renderList as ye, toDisplayString as de, unref as Ue, resolveDynamicComponent as qe, inject as Ge } from "vue";
2
- import { Graph as Ve } from "@antv/x6";
3
- import { register as We } from "@antv/x6-vue-shape";
4
- function io() {
1
+ import { ref as L, computed as H, onScopeDispose as Ue, defineComponent as ce, onBeforeUnmount as Re, createElementBlock as N, openBlock as I, normalizeStyle as Ie, createElementVNode as R, createVNode as Ve, createCommentVNode as F, normalizeClass as Q, Transition as We, withCtx as $e, withModifiers as Ze, createTextVNode as Oe, renderSlot as me, onMounted as Je, watch as ge, createBlock as Ce, Fragment as de, renderList as Ee, toDisplayString as he, unref as et, resolveDynamicComponent as tt, inject as ot } from "vue";
2
+ import { Graph as nt } from "@antv/x6";
3
+ import { register as st } from "@antv/x6-vue-shape";
4
+ function mo() {
5
5
  return {
6
6
  version: "1.0",
7
7
  nodes: {},
8
8
  edges: {}
9
9
  };
10
10
  }
11
- class K extends Error {
11
+ class Y extends Error {
12
12
  constructor(e) {
13
13
  super(e), this.name = "CanvasConstraintError";
14
14
  }
15
15
  }
16
- class Qe extends Error {
16
+ class it extends Error {
17
17
  constructor(e) {
18
18
  super(e), this.name = "CanvasSchemaError";
19
19
  }
20
20
  }
21
- function be(s, e, t) {
21
+ function Me(s, e, t) {
22
22
  if (e.length === 0) {
23
23
  if (t === void 0) return;
24
24
  if (typeof t != "object" || t === null || Array.isArray(t))
@@ -34,189 +34,189 @@ function be(s, e, t) {
34
34
  const i = e[e.length - 1];
35
35
  return t === void 0 ? delete n[i] : n[i] = t, o;
36
36
  }
37
- function Me(s, e) {
37
+ function Te(s, e) {
38
38
  switch (e.type) {
39
39
  case "node.add":
40
- return Xe(s, e.node);
40
+ return rt(s, e.node);
41
41
  case "node.move":
42
- return Ke(s, e.nodeId, e.position);
42
+ return at(s, e.nodeId, e.position);
43
43
  case "node.remove":
44
- return Ye(s, e.nodeId);
44
+ return lt(s, e.nodeId);
45
45
  case "node.update":
46
- return Ze(s, e.nodeId, e.patch);
46
+ return dt(s, e.nodeId, e.patch);
47
47
  case "node.set-payload":
48
- return Je(s, e.nodeId, e.path, e.value);
48
+ return ct(s, e.nodeId, e.path, e.value);
49
49
  case "node.set-extensions":
50
- return et(s, e.nodeId, e.path, e.value);
50
+ return ut(s, e.nodeId, e.path, e.value);
51
51
  case "edge.add":
52
- return tt(s, e.edge);
52
+ return ft(s, e.edge);
53
53
  case "edge.remove":
54
- return ot(s, e.edgeId);
54
+ return pt(s, e.edgeId);
55
55
  case "edge.reconnect":
56
- return nt(s, e.edgeId, e.source, e.target);
56
+ return gt(s, e.edgeId, e.source, e.target);
57
57
  case "edge.update":
58
- return st(s, e.edgeId, e.patch);
58
+ return ht(s, e.edgeId, e.patch);
59
59
  case "edge.set-payload":
60
- return it(s, e.edgeId, e.path, e.value);
60
+ return vt(s, e.edgeId, e.path, e.value);
61
61
  case "edge.label.update":
62
- return rt(s, e.edgeId, e.labelId, e.patch);
62
+ return yt(s, e.edgeId, e.labelId, e.patch);
63
63
  case "model.set-meta":
64
- return at(s, e.path, e.value);
64
+ return mt(s, e.path, e.value);
65
65
  default:
66
- throw new K(`Unknown command type: ${e.type}`);
66
+ throw new Y(`Unknown command type: ${e.type}`);
67
67
  }
68
68
  }
69
- function pe(s, e) {
69
+ function be(s, e) {
70
70
  const t = s.nodes[e];
71
- if (!t) throw new K(`Node "${e}" does not exist`);
71
+ if (!t) throw new Y(`Node "${e}" does not exist`);
72
72
  return t;
73
73
  }
74
- function ge(s, e) {
74
+ function we(s, e) {
75
75
  const t = s.edges[e];
76
- if (!t) throw new K(`Edge "${e}" does not exist`);
76
+ if (!t) throw new Y(`Edge "${e}" does not exist`);
77
77
  return t;
78
78
  }
79
- function ce(s, e, t) {
79
+ function ve(s, e, t) {
80
80
  const o = s.nodes[e.nodeId];
81
81
  if (!o)
82
- throw new K(`${t} node "${e.nodeId}" does not exist`);
82
+ throw new Y(`${t} node "${e.nodeId}" does not exist`);
83
83
  if (e.portId && o.ports && !o.ports.some((i) => i.id === e.portId))
84
- throw new K(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
84
+ throw new Y(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
85
85
  }
86
- function we(s, e, t) {
86
+ function Ne(s, e, t) {
87
87
  return { ...s, nodes: { ...s.nodes, [e]: t } };
88
88
  }
89
- function xe(s, e, t) {
89
+ function Se(s, e, t) {
90
90
  return { ...s, edges: { ...s.edges, [e]: t } };
91
91
  }
92
- function Xe(s, e) {
92
+ function rt(s, e) {
93
93
  if (s.nodes[e.id])
94
- throw new K(`Node id "${e.id}" already exists`);
94
+ throw new Y(`Node id "${e.id}" already exists`);
95
95
  return { ...s, nodes: { ...s.nodes, [e.id]: e } };
96
96
  }
97
- function Ke(s, e, t) {
98
- const o = pe(s, e);
99
- return we(s, e, { ...o, position: t });
97
+ function at(s, e, t) {
98
+ const o = be(s, e);
99
+ return Ne(s, e, { ...o, position: t });
100
100
  }
101
- function Ye(s, e) {
102
- pe(s, e);
101
+ function lt(s, e) {
102
+ be(s, e);
103
103
  const { [e]: t, ...o } = s.nodes, n = {};
104
104
  for (const [i, r] of Object.entries(s.edges))
105
105
  r.source.nodeId !== e && r.target.nodeId !== e && (n[i] = r);
106
106
  return { ...s, nodes: o, edges: n };
107
107
  }
108
- function Ze(s, e, t) {
109
- const o = pe(s, e);
110
- return we(s, e, { ...o, ...t, id: o.id });
108
+ function dt(s, e, t) {
109
+ const o = be(s, e);
110
+ return Ne(s, e, { ...o, ...t, id: o.id });
111
111
  }
112
- function Je(s, e, t, o) {
113
- const n = pe(s, e), i = be(n.payload, t, o);
114
- return we(s, e, { ...n, payload: i });
112
+ function ct(s, e, t, o) {
113
+ const n = be(s, e), i = Me(n.payload, t, o);
114
+ return Ne(s, e, { ...n, payload: i });
115
115
  }
116
- function et(s, e, t, o) {
117
- const n = pe(s, e), i = be(n.extensions, t, o);
118
- return we(s, e, { ...n, extensions: i });
116
+ function ut(s, e, t, o) {
117
+ const n = be(s, e), i = Me(n.extensions, t, o);
118
+ return Ne(s, e, { ...n, extensions: i });
119
119
  }
120
- function tt(s, e) {
120
+ function ft(s, e) {
121
121
  if (s.edges[e.id])
122
- throw new K(`Edge id "${e.id}" already exists`);
123
- if (ce(s, e.source, "Source"), ce(s, e.target, "Target"), e.labels) {
122
+ throw new Y(`Edge id "${e.id}" already exists`);
123
+ if (ve(s, e.source, "Source"), ve(s, e.target, "Target"), e.labels) {
124
124
  const t = /* @__PURE__ */ new Set();
125
125
  for (const o of e.labels) {
126
126
  if (t.has(o.id))
127
- throw new K(`Duplicate label id "${o.id}" in edge "${e.id}"`);
127
+ throw new Y(`Duplicate label id "${o.id}" in edge "${e.id}"`);
128
128
  t.add(o.id);
129
129
  }
130
130
  }
131
131
  return { ...s, edges: { ...s.edges, [e.id]: e } };
132
132
  }
133
- function ot(s, e) {
134
- ge(s, e);
133
+ function pt(s, e) {
134
+ we(s, e);
135
135
  const { [e]: t, ...o } = s.edges;
136
136
  return { ...s, edges: o };
137
137
  }
138
- function nt(s, e, t, o) {
139
- const n = ge(s, e), i = t ?? n.source, r = o ?? n.target;
140
- return ce(s, i, "Source"), ce(s, r, "Target"), xe(s, e, { ...n, source: i, target: r });
138
+ function gt(s, e, t, o) {
139
+ const n = we(s, e), i = t ?? n.source, r = o ?? n.target;
140
+ return ve(s, i, "Source"), ve(s, r, "Target"), Se(s, e, { ...n, source: i, target: r });
141
141
  }
142
- function st(s, e, t) {
143
- const o = ge(s, e), n = { ...o, ...t, id: o.id };
144
- return t.source && ce(s, n.source, "Source"), t.target && ce(s, n.target, "Target"), xe(s, e, n);
142
+ function ht(s, e, t) {
143
+ const o = we(s, e), n = { ...o, ...t, id: o.id };
144
+ return t.source && ve(s, n.source, "Source"), t.target && ve(s, n.target, "Target"), Se(s, e, n);
145
145
  }
146
- function it(s, e, t, o) {
147
- const n = ge(s, e), i = be(n.payload, t, o);
148
- return xe(s, e, { ...n, payload: i });
146
+ function vt(s, e, t, o) {
147
+ const n = we(s, e), i = Me(n.payload, t, o);
148
+ return Se(s, e, { ...n, payload: i });
149
149
  }
150
- function rt(s, e, t, o) {
151
- const n = ge(s, e);
150
+ function yt(s, e, t, o) {
151
+ const n = we(s, e);
152
152
  if (!n.labels)
153
- throw new K(`Edge "${e}" has no labels`);
153
+ throw new Y(`Edge "${e}" has no labels`);
154
154
  const i = n.labels.findIndex((l) => l.id === t);
155
155
  if (i === -1)
156
- throw new K(`Label "${t}" not found in edge "${e}"`);
156
+ throw new Y(`Label "${t}" not found in edge "${e}"`);
157
157
  const r = [...n.labels];
158
- return r[i] = { ...r[i], ...o, id: t }, xe(s, e, { ...n, labels: r });
158
+ return r[i] = { ...r[i], ...o, id: t }, Se(s, e, { ...n, labels: r });
159
159
  }
160
- function at(s, e, t) {
161
- const o = be(s.meta, e, t);
160
+ function mt(s, e, t) {
161
+ const o = Me(s.meta, e, t);
162
162
  return { ...s, meta: o };
163
163
  }
164
- function lt(s, e) {
165
- const t = e?.maxHistorySize ?? 100, o = z(s), n = [], i = [], r = z(!1), l = z(!1);
164
+ function bt(s, e) {
165
+ const t = e?.maxHistorySize ?? 100, o = L(s), n = [], i = [], r = L(!1), l = L(!1);
166
166
  function a() {
167
167
  r.value = n.length > 0, l.value = i.length > 0;
168
168
  }
169
- function c(b) {
170
- const y = o.value;
171
- let m = y;
172
- for (const R of b.commands)
173
- m = Me(m, R);
174
- return n.push({ snapshot: y, envelope: b }), n.length > t && n.shift(), i.length = 0, o.value = m, a(), m;
169
+ function f(k) {
170
+ const w = o.value;
171
+ let x = w;
172
+ for (const A of k.commands)
173
+ x = Te(x, A);
174
+ return n.push({ snapshot: w, envelope: k }), n.length > t && n.shift(), i.length = 0, o.value = x, a(), x;
175
175
  }
176
176
  function d() {
177
- const b = n.pop();
178
- return b ? (i.push({ snapshot: o.value, envelope: b.envelope }), o.value = b.snapshot, a(), b.snapshot) : null;
179
- }
180
- function g() {
181
- const b = i.pop();
182
- if (!b) return null;
183
- n.push({ snapshot: o.value, envelope: b.envelope });
184
- let y = o.value;
185
- for (const m of b.envelope.commands)
186
- y = Me(y, m);
187
- return o.value = y, a(), y;
188
- }
189
- function p() {
177
+ const k = n.pop();
178
+ return k ? (i.push({ snapshot: o.value, envelope: k.envelope }), o.value = k.snapshot, a(), k.snapshot) : null;
179
+ }
180
+ function b() {
181
+ const k = i.pop();
182
+ if (!k) return null;
183
+ n.push({ snapshot: o.value, envelope: k.envelope });
184
+ let w = o.value;
185
+ for (const x of k.envelope.commands)
186
+ w = Te(w, x);
187
+ return o.value = w, a(), w;
188
+ }
189
+ function m() {
190
190
  n.length = 0, i.length = 0, a();
191
191
  }
192
- function u() {
192
+ function g() {
193
193
  return o.value;
194
194
  }
195
- function N(b) {
196
- o.value = b, p();
195
+ function S(k) {
196
+ o.value = k, m();
197
197
  }
198
198
  return {
199
199
  currentFlowModel: o,
200
- execute: c,
200
+ execute: f,
201
201
  undo: d,
202
- redo: g,
202
+ redo: b,
203
203
  canUndo: r,
204
204
  canRedo: l,
205
205
  get undoStack() {
206
- return n.map((b) => b.envelope);
206
+ return n.map((k) => k.envelope);
207
207
  },
208
208
  get redoStack() {
209
- return i.map((b) => b.envelope);
209
+ return i.map((k) => k.envelope);
210
210
  },
211
- clear: p,
212
- createSnapshot: u,
213
- replaceFlowModel: N
211
+ clear: m,
212
+ createSnapshot: g,
213
+ replaceFlowModel: S
214
214
  };
215
215
  }
216
- function dt(s) {
216
+ function wt(s) {
217
217
  return s !== null && typeof s == "object" && s.rejected === !0;
218
218
  }
219
- class ct {
219
+ class xt {
220
220
  plugins = [];
221
221
  editorContext = null;
222
222
  runtimeCtx = null;
@@ -281,7 +281,7 @@ class ct {
281
281
  source: o.name
282
282
  }
283
283
  };
284
- if (dt(i))
284
+ if (wt(i))
285
285
  return {
286
286
  rejected: !0,
287
287
  error: {
@@ -374,42 +374,42 @@ class ct {
374
374
  const n = o ?? e.commands;
375
375
  let i = t.flowModel.value;
376
376
  for (const r of n)
377
- i = Me(i, r);
377
+ i = Te(i, r);
378
378
  return i;
379
379
  }
380
380
  };
381
381
  }
382
382
  }
383
- function ro(s) {
384
- const { schema: e, plugins: t = [], historyOptions: o } = s, n = { version: "1.0", ...s.initialFlowModel }, i = lt(n, o), r = z(s.mode ?? "edit"), l = z(!1), a = z(null), c = z([]), d = {}, g = new ct();
385
- function p(y, m, R, h = "user:toolbar") {
386
- const v = {
383
+ function bo(s) {
384
+ const { schema: e, plugins: t = [], historyOptions: o } = s, n = { version: "1.0", ...s.initialFlowModel }, i = bt(n, o), r = L(s.mode ?? "edit"), l = L(!1), a = L(null), f = L([]), d = {}, b = new xt();
385
+ function m(w, x, A, U = "user:toolbar") {
386
+ const O = {
387
387
  id: `history-${Date.now()}`,
388
- source: h,
389
- label: y,
388
+ source: U,
389
+ label: w,
390
390
  timestamp: Date.now(),
391
391
  commands: []
392
392
  };
393
- g.afterCommand(v, m, R), c.value = g.collectToolbarItems(), s.onCommandResult?.({
393
+ b.afterCommand(O, x, A), f.value = b.collectToolbarItems(), s.onCommandResult?.({
394
394
  status: "applied",
395
- envelope: v,
396
- flowModel: R
395
+ envelope: O,
396
+ flowModel: A
397
397
  }), s.onFlowModelChange?.({
398
- flowModel: R,
399
- prevFlowModel: m,
400
- envelope: v,
401
- source: h
398
+ flowModel: A,
399
+ prevFlowModel: x,
400
+ envelope: O,
401
+ source: U
402
402
  });
403
403
  }
404
- const u = {
404
+ const g = {
405
405
  execute: i.execute,
406
406
  undo() {
407
- const y = i.currentFlowModel.value, m = i.undo();
408
- return m && p("撤销", y, m), m;
407
+ const w = i.currentFlowModel.value, x = i.undo();
408
+ return x && m("撤销", w, x), x;
409
409
  },
410
410
  redo() {
411
- const y = i.currentFlowModel.value, m = i.redo();
412
- return m && p("重做", y, m), m;
411
+ const w = i.currentFlowModel.value, x = i.redo();
412
+ return x && m("重做", w, x), x;
413
413
  },
414
414
  get canUndo() {
415
415
  return i.canUndo;
@@ -425,82 +425,89 @@ function ro(s) {
425
425
  },
426
426
  clear: i.clear,
427
427
  createSnapshot: i.createSnapshot,
428
- replaceFlowModel(y) {
429
- const m = i.currentFlowModel.value;
430
- i.replaceFlowModel(y), p("替换 FlowModel", m, y, "system:replace");
428
+ replaceFlowModel(w) {
429
+ const x = i.currentFlowModel.value;
430
+ i.replaceFlowModel(w), m("替换 FlowModel", x, w, "system:replace");
431
431
  }
432
- }, N = {
433
- flowModel: j(() => i.currentFlowModel.value),
434
- history: u,
432
+ }, S = {
433
+ flowModel: H(() => i.currentFlowModel.value),
434
+ history: g,
435
435
  schema: e,
436
436
  mode: r,
437
- executeCommand: b,
438
- replaceFlowModel(y) {
439
- u.replaceFlowModel(y);
437
+ executeCommand: k,
438
+ replaceFlowModel(w) {
439
+ g.replaceFlowModel(w);
440
440
  },
441
- setMode(y) {
442
- r.value = y;
441
+ setMode(w) {
442
+ r.value = w;
443
443
  },
444
444
  selectionMode: l,
445
- setSelectionMode(y) {
446
- l.value = y;
445
+ setSelectionMode(w) {
446
+ l.value = w;
447
447
  },
448
448
  api: a,
449
- toolbarItems: c,
449
+ toolbarItems: f,
450
450
  extendedApi: d,
451
- _pluginManager: g
451
+ _pluginManager: b
452
452
  };
453
- g.install(t, {
454
- flowModel: N.flowModel,
455
- history: u,
453
+ b.install(t, {
454
+ flowModel: S.flowModel,
455
+ history: g,
456
456
  schema: e,
457
457
  mode: r,
458
- executeCommand: b
459
- }), c.value = g.collectToolbarItems(), Le(() => {
460
- g.dispose();
458
+ executeCommand: k
459
+ }), f.value = b.collectToolbarItems(), Ue(() => {
460
+ b.dispose();
461
461
  });
462
- function b(y) {
463
- const m = g.transformCommand(y);
464
- if ("rejected" in m) {
465
- const v = {
462
+ function k(w) {
463
+ const x = b.transformCommand(w);
464
+ if ("rejected" in x) {
465
+ const O = {
466
466
  status: "rejected",
467
- envelope: y,
468
- error: m.error
467
+ envelope: w,
468
+ error: x.error
469
469
  };
470
- return s.onCommandResult?.(v), v;
470
+ return s.onCommandResult?.(O), O;
471
471
  }
472
- const R = m.envelope, h = i.currentFlowModel.value;
472
+ const A = x.envelope, U = i.currentFlowModel.value;
473
473
  try {
474
- const v = i.execute(R), I = {
474
+ const O = i.execute(A), K = {
475
475
  status: "applied",
476
- envelope: R,
477
- flowModel: v
476
+ envelope: A,
477
+ flowModel: O
478
478
  };
479
- return g.afterCommand(R, h, v), c.value = g.collectToolbarItems(), s.onCommandResult?.(I), s.onFlowModelChange?.({
480
- flowModel: v,
481
- prevFlowModel: h,
482
- envelope: R,
483
- source: R.source
484
- }), I;
485
- } catch (v) {
486
- if (v instanceof K) {
487
- const I = {
479
+ return b.afterCommand(A, U, O), f.value = b.collectToolbarItems(), s.onCommandResult?.(K), s.onFlowModelChange?.({
480
+ flowModel: O,
481
+ prevFlowModel: U,
482
+ envelope: A,
483
+ source: A.source
484
+ }), K;
485
+ } catch (O) {
486
+ if (O instanceof Y) {
487
+ const K = {
488
488
  status: "invalid",
489
- envelope: R,
489
+ envelope: A,
490
490
  error: {
491
491
  code: "constraint_violated",
492
- reason: v.message,
492
+ reason: O.message,
493
493
  source: "engine"
494
494
  }
495
495
  };
496
- return s.onCommandResult?.(I), I;
496
+ return s.onCommandResult?.(K), K;
497
497
  }
498
- throw v;
498
+ throw O;
499
499
  }
500
500
  }
501
- return N;
501
+ return S;
502
+ }
503
+ const kt = ["top", "right", "bottom", "left"];
504
+ function Qe() {
505
+ return kt.map((s) => ({ id: s, group: s }));
506
+ }
507
+ function Be(s, e) {
508
+ return e?.(s) ?? s.ports ?? Qe();
502
509
  }
503
- class ut {
510
+ class Ct {
504
511
  graph;
505
512
  schema;
506
513
  shapeRegistry;
@@ -586,10 +593,10 @@ class ut {
586
593
  for (const [o, n] of Object.entries(e.nodes)) {
587
594
  const i = this.schema.nodeTypes[n.type];
588
595
  if (!i)
589
- throw new Qe(
596
+ throw new it(
590
597
  `Unknown node type "${n.type}" for node "${o}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`
591
598
  );
592
- const r = this.shapeRegistry.registerNodeType(n.type, i.component), l = i.getSize(n), a = i.getPorts?.(n) ?? n.ports ?? [];
599
+ const r = this.shapeRegistry.registerNodeType(n.type, i.component), l = i.getSize(n), a = Be(n, i.getPorts);
593
600
  t.set(o, { model: n, definition: i, shapeName: r, size: l, ports: a });
594
601
  }
595
602
  return t;
@@ -668,8 +675,8 @@ class ut {
668
675
  ...l.x6CellConfig
669
676
  };
670
677
  this.graph.addNode(a), this.knownNodeIds.add(e), this.saveNodeDefaultAttrs(e, l);
671
- const c = this.graph.getCellById(e);
672
- c && (this.applyNodeBehavior(c, o, l), this.applyNodeHighlightAndDecoration(c, o));
678
+ const f = this.graph.getCellById(e);
679
+ f && (this.applyNodeBehavior(f, o, l), this.applyNodeHighlightAndDecoration(f, o));
673
680
  }
674
681
  /**
675
682
  * 将 schema 定义的 getBehavior 映射到 X6 节点属性。
@@ -793,8 +800,8 @@ class ut {
793
800
  applyNodeHighlightAndDecoration(e, t) {
794
801
  const o = this.highlightedNodeIds.has(e.id), n = this.resolveNodeDecoration?.(t), i = this.prevNodeDecorationClasses.get(e.id);
795
802
  i && (this.graph.findViewByCell(e)?.container?.classList.remove(i), this.prevNodeDecorationClasses.delete(e.id)), n?.className && (this.graph.findViewByCell(e)?.container?.classList.add(n.className), this.prevNodeDecorationClasses.set(e.id, n.className));
796
- const r = n?.borderColor, a = r ?? (o ? "#3a84ff" : void 0), c = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
797
- a ? (e.setAttrByPath("body/stroke", a), e.setAttrByPath("body/strokeWidth", 2)) : c && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !r ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
803
+ const r = n?.borderColor, a = r ?? (o ? "#3a84ff" : void 0), f = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
804
+ a ? (e.setAttrByPath("body/stroke", a), e.setAttrByPath("body/strokeWidth", 2)) : f && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !r ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
798
805
  }
799
806
  setHoveredEdge(e) {
800
807
  this.hoveredEdgeId = e;
@@ -819,22 +826,22 @@ class ut {
819
826
  applyEdgeStyleAndDecoration(e, t, o) {
820
827
  const n = this.highlightedEdgeIds.has(e.id), i = this.resolveEdgeDecoration?.(t), r = this.prevEdgeDecorationClasses.get(e.id);
821
828
  r && (this.graph.findViewByCell(e)?.container?.classList.remove(r), this.prevEdgeDecorationClasses.delete(e.id)), i?.className && (this.graph.findViewByCell(e)?.container?.classList.add(i.className), this.prevEdgeDecorationClasses.set(e.id, i.className));
822
- let l, a, c;
829
+ let l, a, f;
823
830
  if (o?.style) {
824
- const N = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, y = o.style(t, { selected: N, highlighted: n, hovered: b });
825
- l = y.stroke, a = y.strokeWidth, c = y.strokeDasharray;
831
+ const S = this.graph.isSelected?.(e) ?? !1, k = this.hoveredEdgeId === e.id, w = o.style(t, { selected: S, highlighted: n, hovered: k });
832
+ l = w.stroke, a = w.strokeWidth, f = w.strokeDasharray;
826
833
  }
827
- const d = !o?.style && n ? "#3a84ff" : void 0, g = i?.strokeColor, p = g ?? l ?? d, u = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
828
- p ? e.setAttrByPath("line/stroke", p) : u && this.restoreEdgeAttr(e, "line/stroke", "stroke"), o?.style ? (this.prevEdgeStyleIds.add(e.id), a ? e.setAttrByPath("line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), c ? e.setAttrByPath("line/strokeDasharray", c) : this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray")) : this.prevEdgeStyleIds.has(e.id) && (this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray"), this.prevEdgeStyleIds.delete(e.id)), g ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), d ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
834
+ const d = !o?.style && n ? "#3a84ff" : void 0, b = i?.strokeColor, m = b ?? l ?? d, g = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
835
+ m ? e.setAttrByPath("line/stroke", m) : g && this.restoreEdgeAttr(e, "line/stroke", "stroke"), o?.style ? (this.prevEdgeStyleIds.add(e.id), a ? e.setAttrByPath("line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), f ? e.setAttrByPath("line/strokeDasharray", f) : this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray")) : this.prevEdgeStyleIds.has(e.id) && (this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray"), this.prevEdgeStyleIds.delete(e.id)), b ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), d ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
829
836
  }
830
837
  }
831
- let ft = 0;
832
- function T() {
838
+ let Et = 0;
839
+ function $() {
833
840
  const s = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
834
- return `${s}-${e}-${++ft}`;
841
+ return `${s}-${e}-${++Et}`;
835
842
  }
836
- class pt {
837
- instanceId = T();
843
+ class It {
844
+ instanceId = $();
838
845
  registeredShapes = /* @__PURE__ */ new Map();
839
846
  getShapeName(e) {
840
847
  let t = this.registeredShapes.get(e);
@@ -842,7 +849,7 @@ class pt {
842
849
  }
843
850
  registerNodeType(e, t) {
844
851
  const o = this.getShapeName(e);
845
- return We({
852
+ return st({
846
853
  shape: o,
847
854
  component: t,
848
855
  width: 100,
@@ -853,7 +860,7 @@ class pt {
853
860
  this.registeredShapes.clear();
854
861
  }
855
862
  }
856
- class gt {
863
+ class Mt {
857
864
  graph;
858
865
  onUiEvent;
859
866
  onCommand;
@@ -880,11 +887,11 @@ class gt {
880
887
  }), this.on("edge:click", ({ edge: e, e: t }) => {
881
888
  const n = t.target?.closest?.(".x6-edge-label");
882
889
  if (n) {
883
- const r = e.getData?.()?.labels ?? [], l = n.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(n) : 0, c = r[Math.max(0, a)];
890
+ const r = e.getData?.()?.labels ?? [], l = n.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(n) : 0, f = r[Math.max(0, a)];
884
891
  this.onUiEvent({
885
892
  type: "edge.label.click",
886
893
  edgeId: e.id,
887
- labelId: c?.id ?? `label-${a}`
894
+ labelId: f?.id ?? `label-${a}`
888
895
  });
889
896
  return;
890
897
  }
@@ -900,7 +907,7 @@ class gt {
900
907
  }), this.on("node:moved", ({ node: e }) => {
901
908
  const t = e.getPosition();
902
909
  this.onCommand({
903
- id: T(),
910
+ id: $(),
904
911
  source: "user:drag",
905
912
  label: "移动节点",
906
913
  timestamp: Date.now(),
@@ -911,7 +918,7 @@ class gt {
911
918
  if (!o || !n) return;
912
919
  const i = e.getSourcePortId(), r = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
913
920
  t && !l ? this.onCommand({
914
- id: T(),
921
+ id: $(),
915
922
  source: "user:drag",
916
923
  label: "连线",
917
924
  timestamp: Date.now(),
@@ -926,7 +933,7 @@ class gt {
926
933
  }
927
934
  ]
928
935
  }) : this.onCommand({
929
- id: T(),
936
+ id: $(),
930
937
  source: "user:drag",
931
938
  label: "重连",
932
939
  timestamp: Date.now(),
@@ -946,16 +953,16 @@ class gt {
946
953
  for (let r = 0; r < Math.min(n.length, t.length); r++) {
947
954
  const l = t[r], a = n[r];
948
955
  if (!a?.id) continue;
949
- const c = typeof l.position == "object" ? l.position?.distance : l.position;
950
- c != null && i.push({
956
+ const f = typeof l.position == "object" ? l.position?.distance : l.position;
957
+ f != null && i.push({
951
958
  type: "edge.label.update",
952
959
  edgeId: e.id,
953
960
  labelId: a.id,
954
- patch: { position: c }
961
+ patch: { position: f }
955
962
  });
956
963
  }
957
964
  i.length && this.onCommand({
958
- id: T(),
965
+ id: $(),
959
966
  source: "user:drag",
960
967
  label: "拖动标签",
961
968
  timestamp: Date.now(),
@@ -967,7 +974,7 @@ class gt {
967
974
  this.graph.on(e, t), this.disposers.push(() => this.graph.off(e, t));
968
975
  }
969
976
  }
970
- function ht(s) {
977
+ function Nt(s) {
971
978
  function e(t) {
972
979
  const o = s.getCellById(t);
973
980
  if (!o || !o.isNode()) return null;
@@ -978,8 +985,8 @@ function ht(s) {
978
985
  getNodeScreenRect: e
979
986
  };
980
987
  }
981
- const vt = 100;
982
- function yt({
988
+ const St = 100;
989
+ function Dt({
983
990
  graph: s,
984
991
  overlayManager: e,
985
992
  executeCommand: t,
@@ -990,63 +997,116 @@ function yt({
990
997
  onHighlightChange: l,
991
998
  resolveNodeShape: a
992
999
  }) {
993
- let c = [], d = [], g = null, p = !1, u = null, N = !1;
994
- async function b() {
995
- if (p) return g;
996
- p = !0;
1000
+ let f = [], d = [], b = null, m = !1, g = null, S = !1;
1001
+ async function k() {
1002
+ if (m) return b;
1003
+ m = !0;
997
1004
  try {
998
- const h = await import("@antv/x6-plugin-dnd"), v = h.Dnd ?? h.default;
999
- return v ? (g = new v({
1005
+ const p = await import("@antv/x6-plugin-dnd"), c = p.Dnd ?? p.default;
1006
+ return c ? (b = new c({
1000
1007
  target: s,
1001
1008
  scaled: !0,
1002
1009
  animation: !0,
1003
- getDragNode: (I) => I.clone(),
1004
- getDropNode: (I) => I.clone()
1005
- }), g) : null;
1010
+ getDragNode: (C) => C.clone(),
1011
+ getDropNode: (C) => C.clone()
1012
+ }), b) : null;
1006
1013
  } catch {
1007
1014
  return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"), null;
1008
1015
  }
1009
1016
  }
1010
- async function y() {
1011
- if (!N) {
1012
- N = !0;
1017
+ async function w() {
1018
+ if (!S) {
1019
+ S = !0;
1013
1020
  try {
1014
- const h = await import("@antv/x6-plugin-export"), v = h.Export ?? h.default;
1015
- v && s.use(new v());
1021
+ const p = await import("@antv/x6-plugin-export"), c = p.Export ?? p.default;
1022
+ c && s.use(new c());
1016
1023
  } catch {
1017
1024
  console.warn("[flow-canvas] @antv/x6-plugin-export not available, add it to your dependencies");
1018
1025
  }
1019
1026
  }
1020
1027
  }
1021
- const m = ({ node: h }) => {
1022
- const v = h.getData?.();
1023
- if (!v?._dndSessionId || v._dndSessionId !== u) return;
1024
- u = null;
1025
- const I = h.getPosition();
1026
- s.removeNode(h.id);
1027
- const { _dndSessionId: L, ...D } = v, C = D.id || T();
1028
+ const x = ({ node: p }) => {
1029
+ const c = p.getData?.();
1030
+ if (!c?._dndSessionId || c._dndSessionId !== g) return;
1031
+ g = null;
1032
+ const C = p.getPosition();
1033
+ s.removeNode(p.id);
1034
+ const { _dndSessionId: z, ..._ } = c, j = _.id || $();
1028
1035
  t({
1029
- id: T(),
1036
+ id: $(),
1030
1037
  source: "user:drag",
1031
1038
  label: "拖入节点",
1032
1039
  timestamp: Date.now(),
1033
1040
  commands: [
1034
1041
  {
1035
1042
  type: "node.add",
1036
- node: { ...D, id: C, position: { x: I.x, y: I.y } }
1043
+ node: { ..._, id: j, position: { x: C.x, y: C.y } }
1037
1044
  }
1038
1045
  ]
1039
1046
  });
1040
1047
  };
1041
- return s.on("node:added", m), {
1048
+ s.on("node:added", x);
1049
+ function A(p) {
1050
+ const c = o.nodeTypes[p.type];
1051
+ return Be(p, c?.getPorts);
1052
+ }
1053
+ function U(p, c, C, z, _) {
1054
+ switch (p) {
1055
+ case "left":
1056
+ return {
1057
+ x: c.position.x - _ - z.width,
1058
+ y: c.position.y + (C.height - z.height) / 2
1059
+ };
1060
+ case "top":
1061
+ return {
1062
+ x: c.position.x + (C.width - z.width) / 2,
1063
+ y: c.position.y - _ - z.height
1064
+ };
1065
+ case "bottom":
1066
+ return {
1067
+ x: c.position.x + (C.width - z.width) / 2,
1068
+ y: c.position.y + C.height + _
1069
+ };
1070
+ default:
1071
+ return {
1072
+ x: c.position.x + C.width + _,
1073
+ y: c.position.y + (C.height - z.height) / 2
1074
+ };
1075
+ }
1076
+ }
1077
+ function O(p, c, C) {
1078
+ switch (p) {
1079
+ case "left":
1080
+ return { x: -(c.width + C), y: 0 };
1081
+ case "top":
1082
+ return { x: 0, y: -(c.height + C) };
1083
+ case "bottom":
1084
+ return { x: 0, y: c.height + C };
1085
+ default:
1086
+ return { x: c.width + C, y: 0 };
1087
+ }
1088
+ }
1089
+ function K(p) {
1090
+ switch (p) {
1091
+ case "left":
1092
+ return "right";
1093
+ case "top":
1094
+ return "bottom";
1095
+ case "bottom":
1096
+ return "top";
1097
+ default:
1098
+ return "left";
1099
+ }
1100
+ }
1101
+ return {
1042
1102
  zoomIn() {
1043
1103
  s.zoom(0.1);
1044
1104
  },
1045
1105
  zoomOut() {
1046
1106
  s.zoom(-0.1);
1047
1107
  },
1048
- zoomTo(h) {
1049
- s.zoomTo(h);
1108
+ zoomTo(p) {
1109
+ s.zoomTo(p);
1050
1110
  },
1051
1111
  zoomToFit() {
1052
1112
  s.zoomToFit({ padding: 40, maxScale: 1.5 });
@@ -1060,179 +1120,176 @@ function yt({
1060
1120
  scrollToOrigin() {
1061
1121
  s.translate(0, 0);
1062
1122
  },
1063
- scrollToNode(h) {
1064
- const v = s.getCellById(h);
1065
- v && s.centerCell(v);
1123
+ scrollToNode(p) {
1124
+ const c = s.getCellById(p);
1125
+ c && s.centerCell(c);
1066
1126
  },
1067
1127
  getSelection() {
1068
- const h = s.getSelectedCells?.() ?? [];
1128
+ const p = s.getSelectedCells?.() ?? [];
1069
1129
  return {
1070
- nodeIds: h.filter((v) => v.isNode()).map((v) => v.id),
1071
- edgeIds: h.filter((v) => v.isEdge()).map((v) => v.id)
1130
+ nodeIds: p.filter((c) => c.isNode()).map((c) => c.id),
1131
+ edgeIds: p.filter((c) => c.isEdge()).map((c) => c.id)
1072
1132
  };
1073
1133
  },
1074
- selectNodes(h) {
1075
- const v = h.map((I) => s.getCellById(I)).filter(Boolean);
1076
- s.select?.(v);
1134
+ selectNodes(p) {
1135
+ const c = p.map((C) => s.getCellById(C)).filter(Boolean);
1136
+ s.select?.(c);
1077
1137
  },
1078
- selectEdges(h) {
1079
- const v = h.map((I) => s.getCellById(I)).filter(Boolean);
1080
- s.select?.(v);
1138
+ selectEdges(p) {
1139
+ const c = p.map((C) => s.getCellById(C)).filter(Boolean);
1140
+ s.select?.(c);
1081
1141
  },
1082
1142
  clearSelection() {
1083
- const h = s.getSelectedCells?.();
1084
- h?.length && s.unselect?.(h);
1143
+ const p = s.getSelectedCells?.();
1144
+ p?.length && s.unselect?.(p);
1085
1145
  },
1086
- registerDndSource(h, v) {
1087
- const I = async (L) => {
1088
- const D = await b();
1089
- if (!D) return;
1090
- const C = T();
1091
- u = C;
1092
- const F = v(), Y = a?.(F.type), q = s.createNode({
1093
- width: Y?.width ?? 154,
1094
- height: Y?.height ?? 54,
1095
- shape: Y?.shapeName ?? "rect",
1096
- data: { ...F, _dndSessionId: C }
1146
+ registerDndSource(p, c) {
1147
+ const C = async (z) => {
1148
+ const _ = await k();
1149
+ if (!_) return;
1150
+ const j = $();
1151
+ g = j;
1152
+ const G = c(), q = a?.(G.type), X = s.createNode({
1153
+ width: q?.width ?? 154,
1154
+ height: q?.height ?? 54,
1155
+ shape: q?.shapeName ?? "rect",
1156
+ data: { ...G, _dndSessionId: j }
1097
1157
  });
1098
- D.start(q, L);
1158
+ _.start(X, z);
1099
1159
  };
1100
- return h.addEventListener("mousedown", I), () => {
1101
- h.removeEventListener("mousedown", I);
1160
+ return p.addEventListener("mousedown", C), () => {
1161
+ p.removeEventListener("mousedown", C);
1102
1162
  };
1103
1163
  },
1104
1164
  /**
1105
1165
  * 通过编程方式发起连线:直接命中真实 port 元素,
1106
1166
  * 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
1107
1167
  */
1108
- startConnection(h, v) {
1109
- const I = s.getCellById(h);
1110
- if (!I?.isNode()) return;
1111
- const L = I, D = s.findViewByCell(L);
1112
- if (!D) return;
1113
- const C = D.findPortElem(v, "circle") ?? D.findPortElem(v);
1114
- if (!C) return;
1115
- const Y = (C.matches?.("[magnet]") ? C : C.querySelector?.("[magnet]")) ?? C, q = Y.getBoundingClientRect(), Q = q.left + q.width / 2, X = q.top + q.height / 2, G = new MouseEvent("mousedown", {
1116
- clientX: Q,
1117
- clientY: X,
1168
+ startConnection(p, c) {
1169
+ const C = s.getCellById(p);
1170
+ if (!C?.isNode()) return;
1171
+ const z = C, _ = s.findViewByCell(z);
1172
+ if (!_) return;
1173
+ const j = _.findPortElem(c, "circle") ?? _.findPortElem(c);
1174
+ if (!j) return;
1175
+ const q = (j.matches?.("[magnet]") ? j : j.querySelector?.("[magnet]")) ?? j, X = q.getBoundingClientRect(), ye = X.left + X.width / 2, se = X.top + X.height / 2, ae = new MouseEvent("mousedown", {
1176
+ clientX: ye,
1177
+ clientY: se,
1118
1178
  button: 0,
1119
1179
  buttons: 1,
1120
1180
  bubbles: !0,
1121
1181
  cancelable: !0
1122
1182
  });
1123
- Y.dispatchEvent(G);
1183
+ q.dispatchEvent(ae);
1124
1184
  },
1125
- async exportAsImage(h) {
1126
- await y();
1127
- const v = s;
1128
- return typeof v.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((I) => {
1129
- v.toPNG(
1130
- (L) => {
1131
- fetch(L).then((D) => D.blob()).then(I).catch(() => I(new Blob()));
1185
+ async exportAsImage(p) {
1186
+ await w();
1187
+ const c = s;
1188
+ return typeof c.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((C) => {
1189
+ c.toPNG(
1190
+ (z) => {
1191
+ fetch(z).then((_) => _.blob()).then(C).catch(() => C(new Blob()));
1132
1192
  },
1133
1193
  {
1134
- backgroundColor: h?.backgroundColor ?? "#ffffff",
1135
- padding: h?.padding ?? 20,
1136
- quality: h?.quality,
1194
+ backgroundColor: p?.backgroundColor ?? "#ffffff",
1195
+ padding: p?.padding ?? 20,
1196
+ quality: p?.quality,
1137
1197
  copyStyles: !0
1138
1198
  }
1139
1199
  );
1140
1200
  });
1141
1201
  },
1142
1202
  async exportAsSVG() {
1143
- await y();
1144
- const h = s;
1145
- return typeof h.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((v) => {
1146
- h.toSVG((I) => v(I));
1203
+ await w();
1204
+ const p = s;
1205
+ return typeof p.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((c) => {
1206
+ p.toSVG((C) => c(C));
1147
1207
  });
1148
1208
  },
1149
- highlightNodes(h) {
1150
- c = h, l?.(c, d);
1209
+ highlightNodes(p) {
1210
+ f = p, l?.(f, d);
1151
1211
  },
1152
- highlightEdges(h) {
1153
- d = h, l?.(c, d);
1212
+ highlightEdges(p) {
1213
+ d = p, l?.(f, d);
1154
1214
  },
1155
1215
  clearHighlight() {
1156
- c = [], d = [], l?.([], []);
1216
+ f = [], d = [], l?.([], []);
1157
1217
  },
1158
1218
  overlay: e,
1159
- getContextMenuItems(h) {
1160
- return r?.(h) ?? [];
1219
+ getContextMenuItems(p) {
1220
+ return r?.(p) ?? [];
1161
1221
  },
1162
- insertNodeToRight(h, v, I) {
1163
- const L = n.value, D = L.nodes[h];
1164
- if (!D)
1222
+ insertNodeToRight(p, c, C) {
1223
+ const z = n.value, _ = z.nodes[p];
1224
+ if (!_)
1165
1225
  return {
1166
1226
  status: "invalid",
1167
1227
  envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
1168
- error: { code: "constraint_violated", reason: `Source node "${h}" not found`, source: "api" }
1228
+ error: { code: "constraint_violated", reason: `Source node "${p}" not found`, source: "api" }
1169
1229
  };
1170
- const C = I?.gap ?? i ?? vt, F = o.nodeTypes[D.type], Y = o.nodeTypes[v.type], q = F?.getSize(D) ?? { width: 154, height: 54 }, Q = Y?.getSize({ ...v, position: { x: 0, y: 0 } }) ?? {
1230
+ const j = C?.gap ?? i ?? St, G = C?.direction ?? "right", q = o.nodeTypes[_.type], X = o.nodeTypes[c.type], ye = q?.getSize(_) ?? { width: 154, height: 54 }, se = X?.getSize({ ...c, position: { x: 0, y: 0 } }) ?? {
1171
1231
  width: 154,
1172
1232
  height: 54
1173
- }, X = {
1174
- x: D.position.x + q.width + C,
1175
- y: D.position.y + (q.height - Q.height) / 2
1176
- }, G = v.id || T(), se = { ...v, id: G, position: X }, ee = [{ type: "node.add", node: se }], ke = Q.width + C, te = { x: X.x, y: X.y, width: Q.width, height: Q.height };
1177
- for (const [Z, V] of Object.entries(L.nodes)) {
1178
- if (Z === h || Z === G) continue;
1179
- const oe = o.nodeTypes[V.type]?.getSize(V) ?? { width: 154, height: 54 }, U = te.x < V.position.x + oe.width && te.x + te.width > V.position.x, x = te.y < V.position.y + oe.height && te.y + te.height > V.position.y;
1180
- U && x && ee.push({
1233
+ }, ae = U(G, _, ye, se, j), ie = c.id || $(), xe = { ...c, id: ie, position: ae }, J = [{ type: "node.add", node: xe }], ke = O(G, se, j), ee = { x: ae.x, y: ae.y, width: se.width, height: se.height };
1234
+ for (const [le, V] of Object.entries(z.nodes)) {
1235
+ if (le === p || le === ie) continue;
1236
+ const fe = o.nodeTypes[V.type]?.getSize(V) ?? { width: 154, height: 54 }, oe = ee.x < V.position.x + fe.width && ee.x + ee.width > V.position.x, pe = ee.y < V.position.y + fe.height && ee.y + ee.height > V.position.y;
1237
+ oe && pe && J.push({
1181
1238
  type: "node.move",
1182
- nodeId: Z,
1183
- position: { x: V.position.x + ke, y: V.position.y }
1239
+ nodeId: le,
1240
+ position: { x: V.position.x + ke.x, y: V.position.y + ke.y }
1184
1241
  });
1185
1242
  }
1186
- if (I?.autoWireEdges) {
1187
- const Z = D.ports?.find((U) => U.group === "right"), V = se.ports?.find((U) => U.group === "left"), ue = se.ports?.find((U) => U.group === "right"), oe = Z ? Object.values(L.edges).find(
1188
- (U) => U.source.nodeId === h && U.source.portId === Z.id
1189
- ) : Object.values(L.edges).find((U) => U.source.nodeId === h);
1190
- if (oe) {
1191
- const U = oe.target;
1192
- ee.push({ type: "edge.remove", edgeId: oe.id }), ee.push({
1243
+ if (C?.autoWireEdges) {
1244
+ const le = A(_), V = A(xe), te = G, fe = K(G), oe = le.find((h) => h.group === te), pe = V.find((h) => h.group === fe), Pe = V.find((h) => h.group === te), v = oe ? Object.values(z.edges).find(
1245
+ (h) => h.source.nodeId === p && h.source.portId === oe.id
1246
+ ) : Object.values(z.edges).find((h) => h.source.nodeId === p);
1247
+ if (v) {
1248
+ const h = v.target;
1249
+ J.push({ type: "edge.remove", edgeId: v.id }), J.push({
1193
1250
  type: "edge.add",
1194
1251
  edge: {
1195
- id: T(),
1196
- source: { nodeId: h, portId: Z?.id },
1197
- target: { nodeId: G, portId: V?.id }
1252
+ id: $(),
1253
+ source: { nodeId: p, portId: oe?.id },
1254
+ target: { nodeId: ie, portId: pe?.id }
1198
1255
  }
1199
- }), ee.push({
1256
+ }), J.push({
1200
1257
  type: "edge.add",
1201
1258
  edge: {
1202
- id: T(),
1203
- source: { nodeId: G, portId: ue?.id },
1204
- target: U
1259
+ id: $(),
1260
+ source: { nodeId: ie, portId: Pe?.id },
1261
+ target: h
1205
1262
  }
1206
1263
  });
1207
1264
  } else
1208
- ee.push({
1265
+ J.push({
1209
1266
  type: "edge.add",
1210
1267
  edge: {
1211
- id: T(),
1212
- source: { nodeId: h, portId: Z?.id },
1213
- target: { nodeId: G, portId: V?.id }
1268
+ id: $(),
1269
+ source: { nodeId: p, portId: oe?.id },
1270
+ target: { nodeId: ie, portId: pe?.id }
1214
1271
  }
1215
1272
  });
1216
1273
  }
1217
- const he = {
1218
- id: T(),
1219
- source: I?.source ?? "user:toolbar",
1220
- label: I?.label ?? "插入节点",
1274
+ const De = {
1275
+ id: $(),
1276
+ source: C?.source ?? "user:toolbar",
1277
+ label: C?.label ?? "插入节点",
1221
1278
  timestamp: Date.now(),
1222
- commands: ee
1279
+ commands: J
1223
1280
  };
1224
- return t(he);
1281
+ return t(De);
1225
1282
  },
1226
- onGraphEvent(h, v) {
1227
- return s.on(h, v), () => s.off(h, v);
1283
+ onGraphEvent(p, c) {
1284
+ return s.on(p, c), () => s.off(p, c);
1228
1285
  },
1229
1286
  unsafeGetGraph() {
1230
1287
  return s;
1231
1288
  }
1232
1289
  };
1233
1290
  }
1234
- function mt() {
1235
- const s = z(null), e = z(!1);
1291
+ function Pt() {
1292
+ const s = L(null), e = L(!1);
1236
1293
  let t = null, o = !1;
1237
1294
  function n(d) {
1238
1295
  t && (clearTimeout(t), t = null), s.value = d;
@@ -1251,33 +1308,33 @@ function mt() {
1251
1308
  function a() {
1252
1309
  t && (clearTimeout(t), t = null);
1253
1310
  }
1254
- function c() {
1311
+ function f() {
1255
1312
  t && clearTimeout(t);
1256
1313
  }
1257
- return { hoveredNodeId: s, isDraggingNode: e, enter: n, leave: i, enterOverlay: r, leaveOverlay: l, cancelLeave: a, cleanup: c };
1314
+ return { hoveredNodeId: s, isDraggingNode: e, enter: n, leave: i, enterOverlay: r, leaveOverlay: l, cancelLeave: a, cleanup: f };
1258
1315
  }
1259
- const _e = 10;
1260
- function Pe(s, e) {
1316
+ const ze = 10;
1317
+ function je(s, e) {
1261
1318
  const t = s.getTotalLength();
1262
1319
  if (t === 0) return { ...e, length: 0, totalLength: 0 };
1263
1320
  let o = s.getPointAtLength(0), n = 1 / 0;
1264
1321
  const i = 50, r = t / i;
1265
1322
  let l = 0;
1266
- for (let g = 0; g <= i; g++) {
1267
- const p = g * r, u = s.getPointAtLength(p), N = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
1268
- N < n && (n = N, o = u, l = p);
1323
+ for (let b = 0; b <= i; b++) {
1324
+ const m = b * r, g = s.getPointAtLength(m), S = (g.x - e.x) ** 2 + (g.y - e.y) ** 2;
1325
+ S < n && (n = S, o = g, l = m);
1269
1326
  }
1270
- const a = Math.max(0, l - r), c = Math.min(t, l + r), d = (c - a) / 20;
1271
- for (let g = a; g <= c; g += d) {
1272
- const p = s.getPointAtLength(g), u = (p.x - e.x) ** 2 + (p.y - e.y) ** 2;
1273
- u < n && (n = u, o = p, l = g);
1327
+ const a = Math.max(0, l - r), f = Math.min(t, l + r), d = (f - a) / 20;
1328
+ for (let b = a; b <= f; b += d) {
1329
+ const m = s.getPointAtLength(b), g = (m.x - e.x) ** 2 + (m.y - e.y) ** 2;
1330
+ g < n && (n = g, o = m, l = b);
1274
1331
  }
1275
1332
  return { x: o.x, y: o.y, length: l, totalLength: t };
1276
1333
  }
1277
- function Ae(s, e) {
1278
- return s < _e || s > e - _e;
1334
+ function Ge(s, e) {
1335
+ return s < ze || s > e - ze;
1279
1336
  }
1280
- function Te() {
1337
+ function He() {
1281
1338
  const s = "http://www.w3.org/2000/svg", e = document.createElementNS(s, "g");
1282
1339
  e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
1283
1340
  const t = document.createElementNS(s, "rect");
@@ -1285,37 +1342,37 @@ function Te() {
1285
1342
  const o = document.createElementNS(s, "text");
1286
1343
  return o.setAttribute("font-family", "flow-canvas"), o.setAttribute("font-size", "16"), o.setAttribute("fill", "#ffffff"), o.setAttribute("text-anchor", "middle"), o.setAttribute("dominant-baseline", "central"), o.textContent = "", e.appendChild(o), e;
1287
1344
  }
1288
- function bt(s) {
1345
+ function _t(s) {
1289
1346
  let e = null, t = null;
1290
1347
  function o(l, a) {
1291
1348
  i(), t = l;
1292
- const c = s.getCellById(l);
1293
- if (!c?.isEdge()) return;
1294
- const d = s.findViewByCell(c);
1349
+ const f = s.getCellById(l);
1350
+ if (!f?.isEdge()) return;
1351
+ const d = s.findViewByCell(f);
1295
1352
  if (!d) return;
1296
- const g = d.container.querySelector("path");
1297
- if (!g) return;
1298
- const p = s.clientToLocal(a.clientX, a.clientY), u = Pe(g, p);
1299
- if (Ae(u.length, u.totalLength)) return;
1300
- const N = Te();
1301
- N.setAttribute("transform", `translate(${u.x}, ${u.y})`), d.container.appendChild(N), e = N;
1353
+ const b = d.container.querySelector("path");
1354
+ if (!b) return;
1355
+ const m = s.clientToLocal(a.clientX, a.clientY), g = je(b, m);
1356
+ if (Ge(g.length, g.totalLength)) return;
1357
+ const S = He();
1358
+ S.setAttribute("transform", `translate(${g.x}, ${g.y})`), d.container.appendChild(S), e = S;
1302
1359
  }
1303
1360
  function n(l) {
1304
1361
  if (!t) return;
1305
1362
  const a = s.getCellById(t);
1306
1363
  if (!a?.isEdge()) return;
1307
- const c = s.findViewByCell(a);
1308
- if (!c) return;
1309
- const d = c.container.querySelector("path");
1364
+ const f = s.findViewByCell(a);
1365
+ if (!f) return;
1366
+ const d = f.container.querySelector("path");
1310
1367
  if (!d) return;
1311
- const g = s.clientToLocal(l.clientX, l.clientY), p = Pe(d, g);
1312
- if (Ae(p.length, p.totalLength))
1368
+ const b = s.clientToLocal(l.clientX, l.clientY), m = je(d, b);
1369
+ if (Ge(m.length, m.totalLength))
1313
1370
  e && e.setAttribute("display", "none");
1314
1371
  else if (e)
1315
- e.removeAttribute("display"), e.setAttribute("transform", `translate(${p.x}, ${p.y})`);
1372
+ e.removeAttribute("display"), e.setAttribute("transform", `translate(${m.x}, ${m.y})`);
1316
1373
  else {
1317
- const u = Te();
1318
- u.setAttribute("transform", `translate(${p.x}, ${p.y})`), c.container.appendChild(u), e = u;
1374
+ const g = He();
1375
+ g.setAttribute("transform", `translate(${m.x}, ${m.y})`), f.container.appendChild(g), e = g;
1319
1376
  }
1320
1377
  }
1321
1378
  function i() {
@@ -1326,23 +1383,23 @@ function bt(s) {
1326
1383
  }
1327
1384
  return { show: o, move: n, remove: i, handleEdgeRemoved: r };
1328
1385
  }
1329
- function wt(s) {
1386
+ function At(s) {
1330
1387
  let e = null, t = 0;
1331
1388
  function o(d) {
1332
- const g = d ? "visible" : "hidden";
1333
- for (const p of s.getNodes())
1334
- for (const u of p.getPorts())
1335
- p.setPortProp(u.id, "attrs/circle/visibility", g);
1389
+ const b = d ? "visible" : "hidden";
1390
+ for (const m of s.getNodes())
1391
+ for (const g of m.getPorts())
1392
+ m.setPortProp(g.id, "attrs/circle/visibility", b);
1336
1393
  }
1337
1394
  function n(d) {
1338
1395
  if (!e)
1339
- for (const g of d.getPorts())
1340
- d.setPortProp(g.id, "attrs/circle/visibility", "visible");
1396
+ for (const b of d.getPorts())
1397
+ d.setPortProp(b.id, "attrs/circle/visibility", "visible");
1341
1398
  }
1342
1399
  function i(d) {
1343
1400
  if (!e)
1344
- for (const g of d.getPorts())
1345
- d.setPortProp(g.id, "attrs/circle/visibility", "hidden");
1401
+ for (const b of d.getPorts())
1402
+ d.setPortProp(b.id, "attrs/circle/visibility", "hidden");
1346
1403
  }
1347
1404
  function r(d) {
1348
1405
  d.getTargetCell() || (e = d.id, o(!0));
@@ -1353,7 +1410,7 @@ function wt(s) {
1353
1410
  function a(d) {
1354
1411
  d === e && (e = null, o(!1));
1355
1412
  }
1356
- function c() {
1413
+ function f() {
1357
1414
  return !e && Date.now() >= t;
1358
1415
  }
1359
1416
  return {
@@ -1362,10 +1419,10 @@ function wt(s) {
1362
1419
  handleEdgeAdded: r,
1363
1420
  handleEdgeConnected: l,
1364
1421
  handleEdgeRemoved: a,
1365
- canShowEdgeTool: c
1422
+ canShowEdgeTool: f
1366
1423
  };
1367
1424
  }
1368
- const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1425
+ const Tt = { class: "flow-canvas-node-actions__bar" }, Rt = /* @__PURE__ */ ce({
1369
1426
  __name: "node-actions-toolbar",
1370
1427
  props: {
1371
1428
  node: {},
@@ -1376,14 +1433,14 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1376
1433
  },
1377
1434
  emits: ["action"],
1378
1435
  setup(s, { emit: e }) {
1379
- const t = s, o = j(() => {
1380
- const g = t.actionsOffset?.x ?? 0, p = t.actionsOffset?.y ?? 0, u = g !== 0 || p !== 0;
1436
+ const t = s, o = H(() => {
1437
+ const b = t.actionsOffset?.x ?? 0, m = t.actionsOffset?.y ?? 0, g = b !== 0 || m !== 0;
1381
1438
  return {
1382
1439
  left: `${t.position.x}px`,
1383
1440
  top: `${t.position.y}px`,
1384
- transform: u ? `translate(${g}px, ${p}px)` : "translateX(-100%)"
1441
+ transform: g ? `translate(${b}px, ${m}px)` : "translateX(-100%)"
1385
1442
  };
1386
- }), n = e, i = j(() => ({
1443
+ }), n = e, i = H(() => ({
1387
1444
  debug: {
1388
1445
  visible: t.config.showDebug && t.behavior.debuggable !== !1,
1389
1446
  disabled: t.behavior.debugDisabled === !0
@@ -1404,9 +1461,9 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1404
1461
  visible: t.config.showDisconnect && t.behavior.disconnectable !== !1,
1405
1462
  disabled: t.behavior.disconnectDisabled === !0
1406
1463
  }
1407
- })), r = j(() => i.value.copy.visible || i.value.copyInsert.visible || i.value.disconnect.visible), l = z(!1);
1464
+ })), r = H(() => i.value.copy.visible || i.value.copyInsert.visible || i.value.disconnect.visible), l = L(!1);
1408
1465
  let a = null;
1409
- function c() {
1466
+ function f() {
1410
1467
  a && (clearTimeout(a), a = null), l.value = !0;
1411
1468
  }
1412
1469
  function d() {
@@ -1414,79 +1471,79 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1414
1471
  l.value = !1, a = null;
1415
1472
  }, 100);
1416
1473
  }
1417
- return Se(() => {
1474
+ return Re(() => {
1418
1475
  a && clearTimeout(a);
1419
- }), (g, p) => (k(), S("div", {
1476
+ }), (b, m) => (I(), N("div", {
1420
1477
  class: "flow-canvas-node-actions",
1421
- style: me(o.value)
1478
+ style: Ie(o.value)
1422
1479
  }, [
1423
- A("div", xt, [
1424
- i.value.debug.visible ? (k(), S("i", {
1480
+ R("div", Tt, [
1481
+ i.value.debug.visible ? (I(), N("i", {
1425
1482
  key: 0,
1426
- class: W(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": i.value.debug.disabled }]),
1427
- onClick: p[0] || (p[0] = (u) => !i.value.debug.disabled && n("action", "debug", s.node.id))
1428
- }, null, 2)) : H("", !0),
1429
- i.value.delete.visible ? (k(), S("i", {
1483
+ class: Q(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": i.value.debug.disabled }]),
1484
+ onClick: m[0] || (m[0] = (g) => !i.value.debug.disabled && n("action", "debug", s.node.id))
1485
+ }, null, 2)) : F("", !0),
1486
+ i.value.delete.visible ? (I(), N("i", {
1430
1487
  key: 1,
1431
- class: W(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": i.value.delete.disabled }]),
1432
- onClick: p[1] || (p[1] = (u) => !i.value.delete.disabled && n("action", "delete", s.node.id))
1433
- }, null, 2)) : H("", !0),
1434
- r.value ? (k(), S("div", {
1488
+ class: Q(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": i.value.delete.disabled }]),
1489
+ onClick: m[1] || (m[1] = (g) => !i.value.delete.disabled && n("action", "delete", s.node.id))
1490
+ }, null, 2)) : F("", !0),
1491
+ r.value ? (I(), N("div", {
1435
1492
  key: 2,
1436
1493
  class: "flow-canvas-node-actions__more-wrapper",
1437
- onMouseenter: c,
1494
+ onMouseenter: f,
1438
1495
  onMouseleave: d
1439
- }, [...p[5] || (p[5] = [
1440
- A("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1441
- ])], 32)) : H("", !0)
1496
+ }, [...m[5] || (m[5] = [
1497
+ R("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1498
+ ])], 32)) : F("", !0)
1442
1499
  ]),
1443
- Be(ze, { name: "flow-canvas-fade" }, {
1444
- default: Ne(() => [
1445
- l.value && r.value ? (k(), S("div", {
1500
+ Ve(We, { name: "flow-canvas-fade" }, {
1501
+ default: $e(() => [
1502
+ l.value && r.value ? (I(), N("div", {
1446
1503
  key: 0,
1447
1504
  class: "flow-canvas-node-actions__dropdown",
1448
- onMouseenter: c,
1505
+ onMouseenter: f,
1449
1506
  onMouseleave: d
1450
1507
  }, [
1451
- i.value.copy.visible ? (k(), S("div", {
1508
+ i.value.copy.visible ? (I(), N("div", {
1452
1509
  key: 0,
1453
- class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copy.disabled }]),
1454
- onClick: p[2] || (p[2] = (u) => !i.value.copy.disabled && n("action", "copy", s.node.id))
1455
- }, [...p[6] || (p[6] = [
1456
- A("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1457
- A("span", null, "复制", -1)
1458
- ])], 2)) : H("", !0),
1459
- i.value.copyInsert.visible ? (k(), S("div", {
1510
+ class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copy.disabled }]),
1511
+ onClick: m[2] || (m[2] = (g) => !i.value.copy.disabled && n("action", "copy", s.node.id))
1512
+ }, [...m[6] || (m[6] = [
1513
+ R("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1514
+ R("span", null, "复制", -1)
1515
+ ])], 2)) : F("", !0),
1516
+ i.value.copyInsert.visible ? (I(), N("div", {
1460
1517
  key: 1,
1461
- class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copyInsert.disabled }]),
1462
- onClick: p[3] || (p[3] = (u) => !i.value.copyInsert.disabled && n("action", "copy-insert", s.node.id))
1463
- }, [...p[7] || (p[7] = [
1464
- A("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1465
- A("span", null, "复制并插入", -1)
1466
- ])], 2)) : H("", !0),
1467
- i.value.disconnect.visible ? (k(), S("div", {
1518
+ class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copyInsert.disabled }]),
1519
+ onClick: m[3] || (m[3] = (g) => !i.value.copyInsert.disabled && n("action", "copy-insert", s.node.id))
1520
+ }, [...m[7] || (m[7] = [
1521
+ R("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1522
+ R("span", null, "复制并插入", -1)
1523
+ ])], 2)) : F("", !0),
1524
+ i.value.disconnect.visible ? (I(), N("div", {
1468
1525
  key: 2,
1469
- class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.disconnect.disabled }]),
1470
- onClick: p[4] || (p[4] = (u) => !i.value.disconnect.disabled && n("action", "disconnect", s.node.id))
1471
- }, [...p[8] || (p[8] = [
1472
- A("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1473
- A("span", null, "断开连线", -1)
1474
- ])], 2)) : H("", !0)
1475
- ], 32)) : H("", !0)
1526
+ class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.disconnect.disabled }]),
1527
+ onClick: m[4] || (m[4] = (g) => !i.value.disconnect.disabled && n("action", "disconnect", s.node.id))
1528
+ }, [...m[8] || (m[8] = [
1529
+ R("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1530
+ R("span", null, "断开连线", -1)
1531
+ ])], 2)) : F("", !0)
1532
+ ], 32)) : F("", !0)
1476
1533
  ]),
1477
1534
  _: 1
1478
1535
  })
1479
1536
  ], 4));
1480
1537
  }
1481
- }), ae = (s, e) => {
1538
+ }), ue = (s, e) => {
1482
1539
  const t = s.__vccOpts || s;
1483
1540
  for (const [o, n] of e)
1484
1541
  t[o] = n;
1485
1542
  return t;
1486
- }, Ct = /* @__PURE__ */ ae(kt, [["__scopeId", "data-v-3b39dab5"]]), Et = {
1543
+ }, $t = /* @__PURE__ */ ue(Rt, [["__scopeId", "data-v-3b39dab5"]]), Bt = {
1487
1544
  key: 0,
1488
1545
  class: "flow-canvas-quick-add__tooltip"
1489
- }, It = 5, Mt = /* @__PURE__ */ re({
1546
+ }, Lt = 5, Ot = /* @__PURE__ */ ce({
1490
1547
  __name: "node-quick-add-popover",
1491
1548
  props: {
1492
1549
  node: {},
@@ -1495,98 +1552,98 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1495
1552
  },
1496
1553
  emits: ["open", "close", "start-drag", "mouseenter", "mouseleave"],
1497
1554
  setup(s, { expose: e, emit: t }) {
1498
- const o = s, n = t, i = z(), r = z(), l = z(!1), a = z(!1);
1499
- let c = null, d = !1, g = null;
1500
- function p(D) {
1501
- D.preventDefault(), D.stopPropagation(), c = { x: D.clientX, y: D.clientY }, d = !1, document.addEventListener("mousemove", u), document.addEventListener("mouseup", N);
1555
+ const o = s, n = t, i = L(), r = L(), l = L(!1), a = L(!1);
1556
+ let f = null, d = !1, b = null;
1557
+ function m(p) {
1558
+ p.preventDefault(), p.stopPropagation(), f = { x: p.clientX, y: p.clientY }, d = !1, document.addEventListener("mousemove", g), document.addEventListener("mouseup", S);
1502
1559
  }
1503
- function u(D) {
1504
- if (!c) return;
1505
- const C = D.clientX - c.x, F = D.clientY - c.y;
1506
- Math.sqrt(C * C + F * F) >= It && (d = !0, b(), n("start-drag", o.node.id));
1560
+ function g(p) {
1561
+ if (!f) return;
1562
+ const c = p.clientX - f.x, C = p.clientY - f.y;
1563
+ Math.sqrt(c * c + C * C) >= Lt && (d = !0, k(), n("start-drag", o.node.id));
1507
1564
  }
1508
- function N() {
1509
- b(), d || y(), c = null, d = !1;
1565
+ function S() {
1566
+ k(), d || w(), f = null, d = !1;
1510
1567
  }
1511
- function b() {
1512
- document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", N);
1568
+ function k() {
1569
+ document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", S);
1513
1570
  }
1514
- function y() {
1515
- a.value ? R() : m();
1571
+ function w() {
1572
+ a.value ? A() : x();
1516
1573
  }
1517
- function m() {
1574
+ function x() {
1518
1575
  a.value = !0, n("open", o.node.id), requestAnimationFrame(() => {
1519
- document.addEventListener("mousedown", h);
1576
+ document.addEventListener("mousedown", U);
1520
1577
  });
1521
1578
  }
1522
- function R() {
1523
- a.value = !1, n("close"), document.removeEventListener("mousedown", h);
1579
+ function A() {
1580
+ a.value = !1, n("close"), document.removeEventListener("mousedown", U);
1524
1581
  }
1525
- function h(D) {
1526
- const C = D.target;
1527
- i.value?.contains(C) || r.value?.contains(C) || R();
1582
+ function U(p) {
1583
+ const c = p.target;
1584
+ i.value?.contains(c) || r.value?.contains(c) || A();
1528
1585
  }
1529
- function v() {
1586
+ function O() {
1530
1587
  a.value || n("mouseleave");
1531
1588
  }
1532
- function I() {
1533
- g && (clearTimeout(g), g = null), n("mouseenter");
1589
+ function K() {
1590
+ b && (clearTimeout(b), b = null), n("mouseenter");
1534
1591
  }
1535
- function L() {
1536
- g = setTimeout(() => {
1537
- R(), n("mouseleave"), g = null;
1592
+ function Z() {
1593
+ b = setTimeout(() => {
1594
+ A(), n("mouseleave"), b = null;
1538
1595
  }, 150);
1539
1596
  }
1540
- return Se(() => {
1541
- b(), g && clearTimeout(g), document.removeEventListener("mousedown", h);
1542
- }), e({ closePopover: R }), (D, C) => (k(), S("div", {
1597
+ return Re(() => {
1598
+ k(), b && clearTimeout(b), document.removeEventListener("mousedown", U);
1599
+ }), e({ closePopover: A }), (p, c) => (I(), N("div", {
1543
1600
  class: "flow-canvas-quick-add",
1544
- style: me({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
1545
- onMouseenter: C[2] || (C[2] = (F) => n("mouseenter")),
1546
- onMouseleave: v,
1547
- onClick: C[3] || (C[3] = He(() => {
1601
+ style: Ie({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
1602
+ onMouseenter: c[2] || (c[2] = (C) => n("mouseenter")),
1603
+ onMouseleave: O,
1604
+ onClick: c[3] || (c[3] = Ze(() => {
1548
1605
  }, ["stop"]))
1549
1606
  }, [
1550
- A("div", {
1607
+ R("div", {
1551
1608
  ref_key: "btnRef",
1552
1609
  ref: i,
1553
- class: W(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
1554
- onMouseenter: C[0] || (C[0] = (F) => l.value = !0),
1555
- onMouseleave: C[1] || (C[1] = (F) => l.value = !1),
1556
- onMousedown: p
1557
- }, [...C[4] || (C[4] = [
1558
- A("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
1610
+ class: Q(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
1611
+ onMouseenter: c[0] || (c[0] = (C) => l.value = !0),
1612
+ onMouseleave: c[1] || (c[1] = (C) => l.value = !1),
1613
+ onMousedown: m
1614
+ }, [...c[4] || (c[4] = [
1615
+ R("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
1559
1616
  ])], 34),
1560
- l.value && !a.value ? (k(), S("div", Et, [...C[5] || (C[5] = [
1561
- A("div", null, [
1562
- A("b", null, "点击"),
1563
- De(" 添加节点")
1617
+ l.value && !a.value ? (I(), N("div", Bt, [...c[5] || (c[5] = [
1618
+ R("div", null, [
1619
+ R("b", null, "点击"),
1620
+ Oe(" 添加节点")
1564
1621
  ], -1),
1565
- A("div", null, [
1566
- A("b", null, "拖拽"),
1567
- De(" 连接节点")
1622
+ R("div", null, [
1623
+ R("b", null, "拖拽"),
1624
+ Oe(" 连接节点")
1568
1625
  ], -1)
1569
- ])])) : H("", !0),
1570
- Be(ze, { name: "flow-canvas-fade" }, {
1571
- default: Ne(() => [
1572
- a.value ? (k(), S("div", {
1626
+ ])])) : F("", !0),
1627
+ Ve(We, { name: "flow-canvas-fade" }, {
1628
+ default: $e(() => [
1629
+ a.value ? (I(), N("div", {
1573
1630
  key: 0,
1574
1631
  ref_key: "popoverRef",
1575
1632
  ref: r,
1576
1633
  class: "flow-canvas-quick-add__popover",
1577
- onMouseenter: I,
1578
- onMouseleave: L
1634
+ onMouseenter: K,
1635
+ onMouseleave: Z
1579
1636
  }, [
1580
- fe(D.$slots, "default", {}, () => [
1581
- C[6] || (C[6] = A("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
1637
+ me(p.$slots, "default", {}, () => [
1638
+ c[6] || (c[6] = R("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
1582
1639
  ], !0)
1583
- ], 544)) : H("", !0)
1640
+ ], 544)) : F("", !0)
1584
1641
  ]),
1585
1642
  _: 3
1586
1643
  })
1587
1644
  ], 36));
1588
1645
  }
1589
- }), St = /* @__PURE__ */ ae(Mt, [["__scopeId", "data-v-deb5af25"]]), Nt = { class: "flow-canvas-runtime-core__overlay" }, Dt = /* @__PURE__ */ re({
1646
+ }), zt = /* @__PURE__ */ ue(Ot, [["__scopeId", "data-v-deb5af25"]]), jt = { class: "flow-canvas-runtime-core__overlay" }, Gt = /* @__PURE__ */ ce({
1590
1647
  __name: "canvas-runtime-core",
1591
1648
  props: {
1592
1649
  editor: {},
@@ -1596,46 +1653,46 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1596
1653
  },
1597
1654
  emits: ["ui-event"],
1598
1655
  setup(s, { emit: e }) {
1599
- const t = s, o = e, n = z(), i = z();
1600
- let r, l, a, c;
1601
- const d = mt(), { hoveredNodeId: g, isDraggingNode: p } = d, u = d.enterOverlay, N = () => d.leaveOverlay(), b = z(null);
1602
- let y = null;
1603
- function m(x) {
1604
- return h(), V(x) ? (b.value = x, !0) : (b.value = null, !1);
1605
- }
1606
- function R() {
1607
- y && clearTimeout(y), y = setTimeout(() => {
1608
- b.value = null, y = null;
1656
+ const t = s, o = e, n = L(), i = L();
1657
+ let r, l, a, f;
1658
+ const d = Pt(), { hoveredNodeId: b, isDraggingNode: m } = d, g = d.enterOverlay, S = () => d.leaveOverlay(), k = L(null);
1659
+ let w = null;
1660
+ function x(v) {
1661
+ return U(), J(v) ? (k.value = v, !0) : (k.value = null, !1);
1662
+ }
1663
+ function A() {
1664
+ w && clearTimeout(w), w = setTimeout(() => {
1665
+ k.value = null, w = null;
1609
1666
  }, 150);
1610
1667
  }
1611
- function h() {
1612
- y && (clearTimeout(y), y = null);
1668
+ function U() {
1669
+ w && (clearTimeout(w), w = null);
1613
1670
  }
1614
- function v() {
1615
- h(), d.enterOverlay();
1671
+ function O() {
1672
+ U(), d.enterOverlay();
1616
1673
  }
1617
- function I() {
1618
- R(), d.leaveOverlay();
1674
+ function K() {
1675
+ A(), d.leaveOverlay();
1619
1676
  }
1620
- let L = null, D = null, C = null;
1621
- const F = z(0), Y = j(
1677
+ let Z = null, p = null, c = null;
1678
+ const C = L(0), z = H(
1622
1679
  () => {
1623
- if (F.value, !t.editor.api.value) return [];
1624
- const x = t.editor.flowModel.value, E = t.editor.api.value.overlay, w = [];
1625
- for (const [_, B] of Object.entries(x.nodes)) {
1626
- const P = t.editor._pluginManager.collectNodeDecorations(B);
1680
+ if (C.value, !t.editor.api.value) return [];
1681
+ const v = t.editor.flowModel.value, h = t.editor.api.value.overlay, u = [];
1682
+ for (const [E, D] of Object.entries(v.nodes)) {
1683
+ const P = t.editor._pluginManager.collectNodeDecorations(D);
1627
1684
  if (!P?.badge) continue;
1628
- const O = E.getNodeScreenRect(_);
1629
- O && w.push({
1630
- nodeId: _,
1631
- x: O.x + O.width - 4,
1632
- y: O.y - 8,
1685
+ const T = h.getNodeScreenRect(E);
1686
+ T && u.push({
1687
+ nodeId: E,
1688
+ x: T.x + T.width - 4,
1689
+ y: T.y - 8,
1633
1690
  badge: P.badge
1634
1691
  });
1635
1692
  }
1636
- return w;
1693
+ return u;
1637
1694
  }
1638
- ), q = j(() => ({
1695
+ ), _ = H(() => ({
1639
1696
  showDebug: !1,
1640
1697
  showDelete: !0,
1641
1698
  showCopy: !0,
@@ -1643,155 +1700,229 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1643
1700
  showDisconnect: !0,
1644
1701
  insertGap: 100,
1645
1702
  ...t.nodeActions
1646
- })), Q = j(() => {
1647
- F.value;
1648
- const x = g.value;
1649
- if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1650
- const E = t.editor.flowModel.value, w = E.nodes[x];
1651
- if (!w) return null;
1652
- const _ = t.editor.api.value.overlay.getNodeScreenRect(x);
1653
- if (!_) return null;
1654
- const P = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1703
+ })), j = H(() => {
1704
+ C.value;
1705
+ const v = b.value;
1706
+ if (!v || m.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1707
+ const h = t.editor.flowModel.value, u = h.nodes[v];
1708
+ if (!u) return null;
1709
+ const E = t.editor.api.value.overlay.getNodeScreenRect(v);
1710
+ if (!E) return null;
1711
+ const P = t.editor.schema.nodeTypes[u.type]?.getBehavior?.(u, {
1655
1712
  api: t.editor.api.value,
1656
- flowModel: E,
1713
+ flowModel: h,
1657
1714
  history: t.editor.history,
1658
1715
  mode: t.editor.mode.value
1659
1716
  }) ?? {};
1660
1717
  return P.showActions === !1 ? null : {
1661
- node: w,
1662
- position: { x: _.x + _.width, y: _.y + _.height + 4 },
1718
+ node: u,
1719
+ position: { x: E.x + E.width, y: E.y + E.height + 4 },
1663
1720
  behavior: P
1664
1721
  };
1665
- }), X = j(() => ({
1722
+ }), G = H(() => ({
1666
1723
  enabled: !0,
1667
1724
  tooltipText: "",
1725
+ portGroup: "right",
1668
1726
  ...t.quickAdd
1669
- })), G = j(() => {
1670
- if (F.value, !X.value.enabled) return null;
1671
- const x = b.value;
1672
- if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1673
- const E = t.editor.flowModel.value, w = E.nodes[x];
1674
- if (!w) return null;
1675
- const B = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1727
+ })), q = H(() => {
1728
+ if (C.value, !G.value.enabled) return null;
1729
+ const v = k.value;
1730
+ if (!v || m.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1731
+ const h = t.editor.flowModel.value, u = h.nodes[v];
1732
+ if (!u) return null;
1733
+ const D = t.editor.schema.nodeTypes[u.type]?.getBehavior?.(u, {
1676
1734
  api: t.editor.api.value,
1677
- flowModel: E,
1735
+ flowModel: h,
1678
1736
  history: t.editor.history,
1679
1737
  mode: t.editor.mode.value
1680
1738
  }) ?? {};
1681
- if (B.quickAddEnabled === !1) return null;
1682
- const P = t.editor.api.value.overlay.getNodeScreenRect(x);
1739
+ if (D.quickAddEnabled === !1) return null;
1740
+ const P = te(u);
1683
1741
  return P ? {
1684
- node: w,
1685
- portPosition: { x: P.x + P.width, y: P.y + P.height / 2 },
1686
- behavior: B
1742
+ node: u,
1743
+ portId: P.portId,
1744
+ portGroup: P.portGroup,
1745
+ portPosition: P.portPosition,
1746
+ behavior: D
1687
1747
  } : null;
1688
- }), se = z();
1689
- function ee(x) {
1690
- const E = G.value;
1691
- E && o("ui-event", {
1748
+ }), X = L();
1749
+ function ye(v) {
1750
+ const h = q.value;
1751
+ h && o("ui-event", {
1692
1752
  type: "node.quick-add",
1693
- nodeId: x,
1694
- position: E.portPosition
1753
+ nodeId: v,
1754
+ position: h.portPosition
1695
1755
  });
1696
1756
  }
1697
- function ke(x) {
1698
- const E = t.editor.api.value;
1699
- E && E.startConnection(x, "right");
1700
- }
1701
- function te(x, E) {
1702
- const w = t.editor.api.value;
1703
- if (!w) return;
1704
- const _ = E.id || T(), B = { ...E, id: _ };
1705
- w.insertNodeToRight(x, B, {
1757
+ function se(v) {
1758
+ const h = t.editor.api.value;
1759
+ if (!h) return;
1760
+ const E = t.editor.flowModel.value.nodes[v];
1761
+ if (!E) return;
1762
+ const D = te(E);
1763
+ D && h.startConnection(v, D.portId);
1764
+ }
1765
+ function ae(v, h) {
1766
+ const u = t.editor.api.value;
1767
+ if (!u) return;
1768
+ const E = h.id || $(), D = { ...h, id: E }, P = t.editor.flowModel.value.nodes[v];
1769
+ if (!P) return;
1770
+ u.insertNodeToRight(v, D, {
1706
1771
  autoWireEdges: !0,
1707
- gap: q.value.insertGap,
1772
+ direction: fe(P),
1773
+ gap: _.value.insertGap,
1708
1774
  source: "user:quick-add",
1709
1775
  label: "快捷插入节点"
1710
- }).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: x, newNodeId: _ }), se.value?.closePopover();
1776
+ }).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: v, newNodeId: E }), X.value?.closePopover();
1711
1777
  }
1712
- function he(x) {
1778
+ function ie(v) {
1713
1779
  return {
1714
- id: T(),
1715
- type: x.type,
1716
- label: x.label,
1717
- ports: x.ports ? JSON.parse(JSON.stringify(x.ports)) : void 0,
1718
- payload: x.payload ? JSON.parse(JSON.stringify(x.payload)) : void 0,
1719
- extensions: x.extensions ? JSON.parse(JSON.stringify(x.extensions)) : void 0
1780
+ id: $(),
1781
+ type: v.type,
1782
+ label: v.label,
1783
+ ports: v.ports ? JSON.parse(JSON.stringify(v.ports)) : void 0,
1784
+ payload: v.payload ? JSON.parse(JSON.stringify(v.payload)) : void 0,
1785
+ extensions: v.extensions ? JSON.parse(JSON.stringify(v.extensions)) : void 0
1720
1786
  };
1721
1787
  }
1722
- function Z(x, E) {
1723
- const w = t.editor, _ = w.api.value;
1724
- switch (x) {
1788
+ function xe(v, h) {
1789
+ const u = t.editor, E = u.api.value;
1790
+ switch (v) {
1725
1791
  case "delete": {
1726
- w.executeCommand({
1727
- id: T(),
1792
+ u.executeCommand({
1793
+ id: $(),
1728
1794
  source: "user:toolbar",
1729
1795
  label: "删除节点",
1730
1796
  timestamp: Date.now(),
1731
- commands: [{ type: "node.remove", nodeId: E }]
1732
- }), o("ui-event", { type: "node.action.delete", nodeId: E }), g.value = null;
1797
+ commands: [{ type: "node.remove", nodeId: h }]
1798
+ }), o("ui-event", { type: "node.action.delete", nodeId: h }), b.value = null;
1733
1799
  break;
1734
1800
  }
1735
1801
  case "copy": {
1736
- if (!_) break;
1737
- const B = w.flowModel.value.nodes[E];
1738
- if (!B) break;
1739
- const P = he(B);
1740
- _.insertNodeToRight(E, P, {
1802
+ if (!E) break;
1803
+ const D = u.flowModel.value.nodes[h];
1804
+ if (!D) break;
1805
+ const P = ie(D);
1806
+ E.insertNodeToRight(h, P, {
1741
1807
  autoWireEdges: !1,
1742
- gap: q.value.insertGap,
1808
+ gap: _.value.insertGap,
1743
1809
  label: "复制节点"
1744
- }), o("ui-event", { type: "node.action.copy", sourceNodeId: E, newNodeId: P.id });
1810
+ }), o("ui-event", { type: "node.action.copy", sourceNodeId: h, newNodeId: P.id });
1745
1811
  break;
1746
1812
  }
1747
1813
  case "copy-insert": {
1748
- if (!_) break;
1749
- const B = w.flowModel.value.nodes[E];
1750
- if (!B) break;
1751
- const P = he(B);
1752
- _.insertNodeToRight(E, P, {
1814
+ if (!E) break;
1815
+ const D = u.flowModel.value.nodes[h];
1816
+ if (!D) break;
1817
+ const P = ie(D);
1818
+ E.insertNodeToRight(h, P, {
1753
1819
  autoWireEdges: !0,
1754
- gap: q.value.insertGap,
1820
+ gap: _.value.insertGap,
1755
1821
  label: "复制并插入节点"
1756
- }), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: E, newNodeId: P.id });
1822
+ }), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: h, newNodeId: P.id });
1757
1823
  break;
1758
1824
  }
1759
1825
  case "disconnect": {
1760
- const B = w.flowModel.value, P = Object.entries(B.edges).filter(([, O]) => {
1761
- const J = O;
1762
- return J.source.nodeId === E || J.target.nodeId === E;
1763
- }).map(([O]) => O);
1826
+ const D = u.flowModel.value, P = Object.entries(D.edges).filter(([, T]) => {
1827
+ const W = T;
1828
+ return W.source.nodeId === h || W.target.nodeId === h;
1829
+ }).map(([T]) => T);
1764
1830
  if (P.length === 0) break;
1765
- w.executeCommand({
1766
- id: T(),
1831
+ u.executeCommand({
1832
+ id: $(),
1767
1833
  source: "user:toolbar",
1768
1834
  label: "断开连线",
1769
1835
  timestamp: Date.now(),
1770
- commands: P.map((O) => ({ type: "edge.remove", edgeId: O }))
1771
- }), o("ui-event", { type: "node.action.disconnect", nodeId: E, edgeIds: P });
1836
+ commands: P.map((T) => ({ type: "edge.remove", edgeId: T }))
1837
+ }), o("ui-event", { type: "node.action.disconnect", nodeId: h, edgeIds: P });
1772
1838
  break;
1773
1839
  }
1774
1840
  case "debug": {
1775
- o("ui-event", { type: "node.action.debug", nodeId: E });
1841
+ o("ui-event", { type: "node.action.debug", nodeId: h });
1776
1842
  break;
1777
1843
  }
1778
1844
  }
1779
1845
  }
1780
- function V(x) {
1781
- if (!X.value.enabled || t.editor.mode.value !== "edit") return !1;
1782
- const E = t.editor.flowModel.value, w = E.nodes[x];
1783
- return w ? (t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1846
+ function J(v) {
1847
+ if (!G.value.enabled || t.editor.mode.value !== "edit") return !1;
1848
+ const h = t.editor.flowModel.value, u = h.nodes[v];
1849
+ return !u || (t.editor.schema.nodeTypes[u.type]?.getBehavior?.(u, {
1784
1850
  api: t.editor.api.value,
1785
- flowModel: E,
1851
+ flowModel: h,
1786
1852
  history: t.editor.history,
1787
1853
  mode: t.editor.mode.value
1788
- }) ?? {}).quickAddEnabled !== !1 : !1;
1854
+ }) ?? {}).quickAddEnabled === !1 ? !1 : !!te(u);
1855
+ }
1856
+ function ke(v) {
1857
+ const h = t.editor.schema.nodeTypes[v.type];
1858
+ return Be(v, h?.getPorts);
1859
+ }
1860
+ function ee(v) {
1861
+ return v === "top" || v === "right" || v === "bottom" || v === "left";
1862
+ }
1863
+ function De(v, h) {
1864
+ const u = G.value.getPort?.(v, h);
1865
+ if (!u) return null;
1866
+ const E = typeof u == "string" ? u : u.id;
1867
+ return h.find((D) => D.id === E) ?? null;
1868
+ }
1869
+ function le(v, h) {
1870
+ const u = t.editor.api.value?.overlay.getNodeScreenRect(v);
1871
+ if (!u) return null;
1872
+ switch (h) {
1873
+ case "top":
1874
+ return { x: u.x + u.width / 2, y: u.y };
1875
+ case "bottom":
1876
+ return { x: u.x + u.width / 2, y: u.y + u.height };
1877
+ case "left":
1878
+ return { x: u.x, y: u.y + u.height / 2 };
1879
+ case "right":
1880
+ return { x: u.x + u.width, y: u.y + u.height / 2 };
1881
+ default:
1882
+ return null;
1883
+ }
1789
1884
  }
1790
- function ue(x) {
1885
+ function V(v, h, u) {
1886
+ const E = r.getCellById(v);
1887
+ if (E?.isNode()) {
1888
+ const D = E, P = r.findViewByCell(D), T = P?.findPortElem(h, "circle") ?? P?.findPortElem(h);
1889
+ if (T) {
1890
+ const W = r.container.getBoundingClientRect(), re = T.getBoundingClientRect();
1891
+ return {
1892
+ x: re.left - W.left + re.width / 2,
1893
+ y: re.top - W.top + re.height / 2
1894
+ };
1895
+ }
1896
+ }
1897
+ return le(v, u);
1898
+ }
1899
+ function te(v) {
1900
+ const h = ke(v), u = De(v, h) ?? h.find((D) => D.group === G.value.portGroup) ?? null;
1901
+ if (!u) return null;
1902
+ const E = V(v.id, u.id, u.group);
1903
+ return E ? {
1904
+ portId: u.id,
1905
+ portGroup: u.group,
1906
+ portPosition: E
1907
+ } : null;
1908
+ }
1909
+ function fe(v) {
1910
+ const h = te(v), u = G.value.insertDirection;
1911
+ if (typeof u == "function") {
1912
+ const E = u(
1913
+ v,
1914
+ h ? { id: h.portId, group: h.portGroup } : null
1915
+ );
1916
+ if (E) return E;
1917
+ } else if (u)
1918
+ return u;
1919
+ return h && ee(h.portGroup) ? h.portGroup : ee(G.value.portGroup) ? G.value.portGroup : "right";
1920
+ }
1921
+ function oe(v) {
1791
1922
  if (t.editor.mode.value !== "edit") return;
1792
- t.editor._pluginManager.dispatchKeyboardShortcut(x) && (x.preventDefault(), x.stopPropagation());
1923
+ t.editor._pluginManager.dispatchKeyboardShortcut(v) && (v.preventDefault(), v.stopPropagation());
1793
1924
  }
1794
- function oe() {
1925
+ function pe() {
1795
1926
  return {
1796
1927
  refX: 0,
1797
1928
  children: [
@@ -1812,8 +1943,8 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1812
1943
  ]
1813
1944
  };
1814
1945
  }
1815
- function U(x) {
1816
- const E = t.editor.schema.defaultEdgeType ?? "default", w = t.editor.schema.edgeTypes?.[E], _ = {
1946
+ function Pe(v) {
1947
+ const h = t.editor.schema.defaultEdgeType ?? "default", u = t.editor.schema.edgeTypes?.[h], E = {
1817
1948
  zIndex: -1,
1818
1949
  attrs: {
1819
1950
  line: {
@@ -1823,28 +1954,28 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1823
1954
  }
1824
1955
  }
1825
1956
  };
1826
- w?.router && (_.router = typeof w.router == "string" ? { name: w.router } : w.router), w?.connector && (_.connector = typeof w.connector == "string" ? { name: w.connector } : w.connector), w?.x6EdgeConfig && Object.assign(_, w.x6EdgeConfig);
1827
- const B = _.attrs ?? {}, P = B.line ?? {};
1828
- return _.attrs = {
1829
- ...B,
1957
+ u?.router && (E.router = typeof u.router == "string" ? { name: u.router } : u.router), u?.connector && (E.connector = typeof u.connector == "string" ? { name: u.connector } : u.connector), u?.x6EdgeConfig && Object.assign(E, u.x6EdgeConfig);
1958
+ const D = E.attrs ?? {}, P = D.line ?? {};
1959
+ return E.attrs = {
1960
+ ...D,
1830
1961
  line: {
1831
1962
  ...P,
1832
- targetMarker: oe()
1963
+ targetMarker: pe()
1833
1964
  }
1834
- }, x.createEdge(_);
1965
+ }, v.createEdge(E);
1835
1966
  }
1836
- return Fe(() => {
1967
+ return Je(() => {
1837
1968
  if (!i.value) return;
1838
- const x = /* @__PURE__ */ new Set(["model", "container"]), E = {};
1969
+ const v = /* @__PURE__ */ new Set(["model", "container"]), h = {};
1839
1970
  if (t.graphOptions)
1840
- for (const [f, M] of Object.entries(t.graphOptions)) {
1841
- if (x.has(f)) {
1842
- console.warn(`[flow-canvas] graphOptions.${f} is managed by the engine and will be ignored`);
1971
+ for (const [y, M] of Object.entries(t.graphOptions)) {
1972
+ if (v.has(y)) {
1973
+ console.warn(`[flow-canvas] graphOptions.${y} is managed by the engine and will be ignored`);
1843
1974
  continue;
1844
1975
  }
1845
- E[f] = M;
1976
+ h[y] = M;
1846
1977
  }
1847
- r = new Ve({
1978
+ r = new nt({
1848
1979
  container: i.value,
1849
1980
  autoResize: !0,
1850
1981
  background: { color: "#edf2fc" },
@@ -1852,8 +1983,8 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1852
1983
  panning: { enabled: !0 },
1853
1984
  mousewheel: { enabled: !0, modifiers: ["ctrl", "meta"] },
1854
1985
  interacting: {
1855
- nodeMovable(f) {
1856
- return f.cell.getProp("draggable") !== !1;
1986
+ nodeMovable(y) {
1987
+ return y.cell.getProp("draggable") !== !1;
1857
1988
  }
1858
1989
  },
1859
1990
  connecting: {
@@ -1867,16 +1998,16 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1867
1998
  connectionPoint: "anchor",
1868
1999
  snap: { radius: 30 },
1869
2000
  createEdge() {
1870
- return U(this);
2001
+ return Pe(this);
1871
2002
  }
1872
2003
  },
1873
- ...E
1874
- }), a = new pt(), l = new ut(
2004
+ ...h
2005
+ }), a = new It(), l = new Ct(
1875
2006
  r,
1876
2007
  t.editor.schema,
1877
2008
  a,
1878
- (f) => t.editor._pluginManager.collectNodeDecorations(f),
1879
- (f) => t.editor._pluginManager.collectEdgeDecorations(f),
2009
+ (y) => t.editor._pluginManager.collectNodeDecorations(y),
2010
+ (y) => t.editor._pluginManager.collectEdgeDecorations(y),
1880
2011
  () => t.editor.api.value ? {
1881
2012
  api: t.editor.api.value,
1882
2013
  flowModel: t.editor.flowModel.value,
@@ -1884,261 +2015,263 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1884
2015
  mode: t.editor.mode.value
1885
2016
  } : null
1886
2017
  );
1887
- const w = ht(r), _ = yt({
2018
+ const u = Nt(r), E = Dt({
1888
2019
  graph: r,
1889
- overlayManager: w,
1890
- executeCommand: (f) => t.editor.executeCommand(f),
2020
+ overlayManager: u,
2021
+ executeCommand: (y) => t.editor.executeCommand(y),
1891
2022
  schema: t.editor.schema,
1892
2023
  flowModel: t.editor.flowModel,
1893
2024
  defaultInsertGap: t.nodeActions?.insertGap,
1894
- getContextMenuItems: (f) => t.editor._pluginManager.collectContextMenuItems(f),
1895
- onHighlightChange: (f, M) => {
1896
- l.setHighlightedNodes(f), l.setHighlightedEdges(M), l.refreshNodeHighlights(), l.refreshEdgeStyles();
2025
+ getContextMenuItems: (y) => t.editor._pluginManager.collectContextMenuItems(y),
2026
+ onHighlightChange: (y, M) => {
2027
+ l.setHighlightedNodes(y), l.setHighlightedEdges(M), l.refreshNodeHighlights(), l.refreshEdgeStyles();
1897
2028
  },
1898
- resolveNodeShape: (f) => {
1899
- const M = t.editor.schema.nodeTypes[f];
2029
+ resolveNodeShape: (y) => {
2030
+ const M = t.editor.schema.nodeTypes[y];
1900
2031
  if (!M) return null;
1901
- const $ = a.registerNodeType(f, M.component), ne = M.getSize({ id: "", type: f, position: { x: 0, y: 0 } });
1902
- return { shapeName: $, width: ne.width, height: ne.height };
2032
+ const B = a.registerNodeType(y, M.component), ne = M.getSize({ id: "", type: y, position: { x: 0, y: 0 } });
2033
+ return { shapeName: B, width: ne.width, height: ne.height };
1903
2034
  }
1904
2035
  });
1905
- t.editor.api.value = _;
1906
- const B = {
2036
+ t.editor.api.value = E;
2037
+ const D = {
1907
2038
  flowModel: t.editor.flowModel,
1908
2039
  history: t.editor.history,
1909
2040
  schema: t.editor.schema,
1910
2041
  mode: t.editor.mode,
1911
2042
  executeCommand: t.editor.executeCommand,
1912
- api: _,
1913
- overlay: w,
2043
+ api: E,
2044
+ overlay: u,
1914
2045
  graph: r
1915
2046
  };
1916
- t.editor._pluginManager.attachRuntime(B);
2047
+ t.editor._pluginManager.attachRuntime(D);
1917
2048
  const P = t.editor._pluginManager.collectExtendedApi();
1918
- Object.assign(t.editor.extendedApi, P), c = new gt(
2049
+ Object.assign(t.editor.extendedApi, P), f = new Mt(
1919
2050
  r,
1920
- (f) => {
1921
- (f.type === "node.click" || f.type === "node.dblclick" || f.type === "node.contextmenu") && d.enter(f.nodeId), t.editor._pluginManager.dispatchUiEvent(f), o("ui-event", f);
2051
+ (y) => {
2052
+ (y.type === "node.click" || y.type === "node.dblclick" || y.type === "node.contextmenu") && d.enter(y.nodeId), t.editor._pluginManager.dispatchUiEvent(y), o("ui-event", y);
1922
2053
  },
1923
- (f) => {
2054
+ (y) => {
1924
2055
  if (l.isSyncing) return;
1925
- if (t.editor.executeCommand(f).status !== "applied") {
1926
- for (const $ of f.commands)
1927
- if ($.type === "edge.add") {
1928
- const ne = r.getCellById($.edge.id);
2056
+ if (t.editor.executeCommand(y).status !== "applied") {
2057
+ for (const B of y.commands)
2058
+ if (B.type === "edge.add") {
2059
+ const ne = r.getCellById(B.edge.id);
1929
2060
  ne && r.removeCell(ne);
1930
2061
  }
1931
2062
  }
1932
2063
  },
1933
2064
  t.editor.flowModel
1934
- ), L = bt(r);
1935
- const O = wt(r), J = r, Ce = (f) => {
1936
- const M = J.isRubberbandEnabled?.() ?? !1;
1937
- M && J.disableRubberband?.(), f ? r.enablePanning() : r.disablePanning(), M && J.enableRubberband?.();
1938
- }, Ee = () => {
1939
- F.value++;
2065
+ ), Z = _t(r);
2066
+ const T = At(r), W = r, re = (y) => {
2067
+ const M = W.isRubberbandEnabled?.() ?? !1;
2068
+ M && W.disableRubberband?.(), y ? r.enablePanning() : r.disablePanning(), M && W.enableRubberband?.();
2069
+ }, _e = () => {
2070
+ C.value++;
1940
2071
  };
1941
- r.on("translate", Ee), r.on("scale", Ee), r.on("resize", Ee), r.on("node:move", () => {
1942
- p.value = !0;
2072
+ r.on("translate", _e), r.on("scale", _e), r.on("resize", _e), r.on("node:move", () => {
2073
+ m.value = !0;
1943
2074
  }), r.on("node:moved", () => {
1944
- p.value = !1;
1945
- }), r.on("node:mouseenter", ({ node: f }) => {
1946
- d.enter(f.id), X.value.enabled && m(f.id) || O.showNodePorts(f);
1947
- }), r.on("node:mouseleave", ({ node: f }) => {
1948
- const M = t.editor.flowModel.value.nodes[f.id];
1949
- let $ = 100;
2075
+ m.value = !1;
2076
+ }), r.on("node:mouseenter", ({ node: y }) => {
2077
+ d.enter(y.id), G.value.enabled && x(y.id) || T.showNodePorts(y);
2078
+ }), r.on("node:mouseleave", ({ node: y }) => {
2079
+ const M = t.editor.flowModel.value.nodes[y.id];
2080
+ let B = 100;
1950
2081
  M && t.editor.api.value && t.editor.schema.nodeTypes[M.type]?.getBehavior?.(M, {
1951
2082
  api: t.editor.api.value,
1952
2083
  flowModel: t.editor.flowModel.value,
1953
2084
  history: t.editor.history,
1954
2085
  mode: t.editor.mode.value
1955
- })?.actionsOffset && ($ = 300), d.leave($), X.value.enabled && b.value === f.id ? R() : O.hideNodePorts(f);
2086
+ })?.actionsOffset && (B = 300), d.leave(B), G.value.enabled && k.value === y.id ? A() : T.hideNodePorts(y);
1956
2087
  });
1957
- function Oe(f) {
1958
- const M = r.getCellById(f);
2088
+ function Xe(y) {
2089
+ const M = r.getCellById(y);
1959
2090
  if (!M?.isNode()) return;
1960
- const $ = M, ne = !p.value && V(f);
1961
- for (const Ie of $.getPorts()) {
1962
- const je = ne && Ie.group === "right" ? "hidden" : "visible";
1963
- $.setPortProp(Ie.id, "attrs/circle/visibility", je);
2091
+ const B = M, ne = t.editor.flowModel.value.nodes[y];
2092
+ if (!ne) return;
2093
+ const Ae = te(ne), Ke = !m.value && !!Ae && J(y);
2094
+ for (const Le of B.getPorts()) {
2095
+ const Ye = Ke && Le.id === Ae?.portId ? "hidden" : "visible";
2096
+ B.setPortProp(Le.id, "attrs/circle/visibility", Ye);
1964
2097
  }
1965
2098
  }
1966
- le(
1967
- [b, p],
1968
- ([f], [M]) => {
1969
- if (M && M !== f) {
1970
- const $ = r.getCellById(M);
1971
- $?.isNode() && O.hideNodePorts($);
2099
+ ge(
2100
+ [k, m],
2101
+ ([y], [M]) => {
2102
+ if (M && M !== y) {
2103
+ const B = r.getCellById(M);
2104
+ B?.isNode() && T.hideNodePorts(B);
1972
2105
  }
1973
- f && Oe(f);
2106
+ y && Xe(y);
1974
2107
  },
1975
2108
  { flush: "sync" }
1976
- ), r.on("edge:added", ({ edge: f }) => {
1977
- O.handleEdgeAdded(f);
2109
+ ), r.on("edge:added", ({ edge: y }) => {
2110
+ T.handleEdgeAdded(y);
1978
2111
  }), r.on("edge:connected", () => {
1979
- O.handleEdgeConnected();
1980
- }), r.on("edge:removed", ({ edge: f }) => {
1981
- O.handleEdgeRemoved(f.id), L.handleEdgeRemoved(f.id);
2112
+ T.handleEdgeConnected();
2113
+ }), r.on("edge:removed", ({ edge: y }) => {
2114
+ T.handleEdgeRemoved(y.id), Z.handleEdgeRemoved(y.id);
1982
2115
  }), r.on("selection:changed", () => {
1983
- const f = r.getSelectedCells?.() ?? [], M = {
1984
- nodeIds: f.filter(($) => $.isNode()).map(($) => $.id),
1985
- edgeIds: f.filter(($) => $.isEdge()).map(($) => $.id)
2116
+ const y = r.getSelectedCells?.() ?? [], M = {
2117
+ nodeIds: y.filter((B) => B.isNode()).map((B) => B.id),
2118
+ edgeIds: y.filter((B) => B.isEdge()).map((B) => B.id)
1986
2119
  };
1987
2120
  t.editor._pluginManager.dispatchSelectionChange(M), o("ui-event", {
1988
2121
  type: "selection.change",
1989
2122
  nodeIds: M.nodeIds,
1990
2123
  edgeIds: M.edgeIds
1991
2124
  }), l.refreshEdgeStyles();
1992
- }), r.on("edge:mouseenter", ({ edge: f, e: M }) => {
1993
- l.setHoveredEdge(f.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && O.canShowEdgeTool() && L.show(f.id, M);
1994
- }), D = (f) => L.move(f), r.container.addEventListener("mousemove", D), r.on("edge:mouseleave", () => {
1995
- l.setHoveredEdge(null), l.refreshEdgeStyles(), L.remove();
1996
- }), r.on("edge:click", ({ edge: f, e: M }) => {
1997
- M.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (L.remove(), t.editor.executeCommand({
1998
- id: T(),
2125
+ }), r.on("edge:mouseenter", ({ edge: y, e: M }) => {
2126
+ l.setHoveredEdge(y.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && T.canShowEdgeTool() && Z.show(y.id, M);
2127
+ }), p = (y) => Z.move(y), r.container.addEventListener("mousemove", p), r.on("edge:mouseleave", () => {
2128
+ l.setHoveredEdge(null), l.refreshEdgeStyles(), Z.remove();
2129
+ }), r.on("edge:click", ({ edge: y, e: M }) => {
2130
+ M.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (Z.remove(), t.editor.executeCommand({
2131
+ id: $(),
1999
2132
  source: "user:toolbar",
2000
2133
  label: "删除连线",
2001
2134
  timestamp: Date.now(),
2002
- commands: [{ type: "edge.remove", edgeId: f.id }]
2135
+ commands: [{ type: "edge.remove", edgeId: y.id }]
2003
2136
  }));
2004
- }), n.value?.addEventListener("keydown", ue), l.syncFlowModel(t.editor.flowModel.value), le(
2137
+ }), n.value?.addEventListener("keydown", oe), l.syncFlowModel(t.editor.flowModel.value), ge(
2005
2138
  () => t.editor.flowModel.value,
2006
- (f) => l.syncFlowModel(f)
2007
- ), le(
2139
+ (y) => l.syncFlowModel(y)
2140
+ ), ge(
2008
2141
  () => t.editor.selectionMode.value,
2009
- (f) => {
2010
- if (C?.(), C = null, f) {
2011
- Ce(!1), J.enableRubberband?.();
2142
+ (y) => {
2143
+ if (c?.(), c = null, y) {
2144
+ re(!1), W.enableRubberband?.();
2012
2145
  const M = () => {
2013
- r.container.removeEventListener("mouseup", M), C = null, setTimeout(() => {
2146
+ r.container.removeEventListener("mouseup", M), c = null, setTimeout(() => {
2014
2147
  t.editor.selectionMode.value && t.editor.setSelectionMode(!1);
2015
2148
  }, 50);
2016
2149
  };
2017
- r.container.addEventListener("mouseup", M), C = () => r.container.removeEventListener("mouseup", M);
2150
+ r.container.addEventListener("mouseup", M), c = () => r.container.removeEventListener("mouseup", M);
2018
2151
  } else
2019
- J.disableRubberband?.(), Ce(!0);
2152
+ W.disableRubberband?.(), re(!0);
2020
2153
  }
2021
- ), le(
2154
+ ), ge(
2022
2155
  () => t.editor.mode.value,
2023
- (f) => {
2024
- const M = f === "edit";
2025
- Ce(!0), M ? J.enableSelection?.() : J.disableSelection?.();
2156
+ (y) => {
2157
+ const M = y === "edit";
2158
+ re(!0), M ? W.enableSelection?.() : W.disableSelection?.();
2026
2159
  }
2027
2160
  );
2028
- }), Se(() => {
2029
- d.cleanup(), y && clearTimeout(y), L?.remove(), C?.(), D && r?.container?.removeEventListener("mousemove", D), n.value?.removeEventListener("keydown", ue), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2030
- for (const x of Object.keys(t.editor.extendedApi))
2031
- delete t.editor.extendedApi[x];
2032
- c?.dispose(), l?.dispose(), a?.dispose(), r?.dispose();
2033
- }), (x, E) => (k(), S("div", {
2161
+ }), Re(() => {
2162
+ d.cleanup(), w && clearTimeout(w), Z?.remove(), c?.(), p && r?.container?.removeEventListener("mousemove", p), n.value?.removeEventListener("keydown", oe), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2163
+ for (const v of Object.keys(t.editor.extendedApi))
2164
+ delete t.editor.extendedApi[v];
2165
+ f?.dispose(), l?.dispose(), a?.dispose(), r?.dispose();
2166
+ }), (v, h) => (I(), N("div", {
2034
2167
  ref_key: "rootRef",
2035
2168
  ref: n,
2036
2169
  class: "flow-canvas-runtime-core",
2037
2170
  tabindex: "0"
2038
2171
  }, [
2039
- A("div", {
2172
+ R("div", {
2040
2173
  ref_key: "containerRef",
2041
2174
  ref: i,
2042
2175
  class: "flow-canvas-runtime-core__graph"
2043
2176
  }, null, 512),
2044
- A("div", Nt, [
2045
- (k(!0), S(ie, null, ye(Y.value, (w) => (k(), S("div", {
2046
- key: `badge-${w.nodeId}`,
2177
+ R("div", jt, [
2178
+ (I(!0), N(de, null, Ee(z.value, (u) => (I(), N("div", {
2179
+ key: `badge-${u.nodeId}`,
2047
2180
  class: "flow-canvas-runtime-core__badge",
2048
- style: me({ left: `${w.x}px`, top: `${w.y}px`, backgroundColor: w.badge.color })
2049
- }, de(w.badge.text), 5))), 128)),
2050
- G.value ? (k(), ve(St, {
2181
+ style: Ie({ left: `${u.x}px`, top: `${u.y}px`, backgroundColor: u.badge.color })
2182
+ }, he(u.badge.text), 5))), 128)),
2183
+ q.value ? (I(), Ce(zt, {
2051
2184
  key: 0,
2052
2185
  ref_key: "quickAddPopoverRef",
2053
- ref: se,
2054
- node: G.value.node,
2055
- "port-position": G.value.portPosition,
2056
- "tooltip-text": X.value.tooltipText,
2057
- onOpen: ee,
2058
- onStartDrag: ke,
2059
- onMouseenter: v,
2060
- onMouseleave: I
2186
+ ref: X,
2187
+ node: q.value.node,
2188
+ "port-position": q.value.portPosition,
2189
+ "tooltip-text": G.value.tooltipText,
2190
+ onOpen: ye,
2191
+ onStartDrag: se,
2192
+ onMouseenter: O,
2193
+ onMouseleave: K
2061
2194
  }, {
2062
- default: Ne(() => [
2063
- fe(x.$slots, "quick-add-panel", {
2064
- node: G.value.node,
2195
+ default: $e(() => [
2196
+ me(v.$slots, "quick-add-panel", {
2197
+ node: q.value.node,
2065
2198
  api: s.editor.api.value,
2066
- insertNodeToRight: (w) => te(G.value.node.id, w),
2067
- closePopover: () => se.value?.closePopover()
2199
+ insertNodeToRight: (u) => ae(q.value.node.id, u),
2200
+ closePopover: () => X.value?.closePopover()
2068
2201
  }, void 0, !0)
2069
2202
  ]),
2070
2203
  _: 3
2071
- }, 8, ["node", "port-position", "tooltip-text"])) : H("", !0),
2072
- Q.value ? (k(), ve(Ct, {
2204
+ }, 8, ["node", "port-position", "tooltip-text"])) : F("", !0),
2205
+ j.value ? (I(), Ce($t, {
2073
2206
  key: 1,
2074
- node: Q.value.node,
2075
- position: Q.value.position,
2076
- config: q.value,
2077
- behavior: Q.value.behavior,
2078
- "actions-offset": Q.value.behavior.actionsOffset,
2079
- onAction: Z,
2080
- onMouseenter: Ue(u),
2081
- onMouseleave: N
2082
- }, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : H("", !0)
2207
+ node: j.value.node,
2208
+ position: j.value.position,
2209
+ config: _.value,
2210
+ behavior: j.value.behavior,
2211
+ "actions-offset": j.value.behavior.actionsOffset,
2212
+ onAction: xe,
2213
+ onMouseenter: et(g),
2214
+ onMouseleave: S
2215
+ }, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : F("", !0)
2083
2216
  ])
2084
2217
  ], 512));
2085
2218
  }
2086
- }), ao = /* @__PURE__ */ ae(Dt, [["__scopeId", "data-v-96013976"]]), _t = { class: "flow-canvas-node-palette" }, Pt = ["data-node-type"], At = { class: "flow-canvas-node-palette__item-label" }, Tt = /* @__PURE__ */ re({
2219
+ }), wo = /* @__PURE__ */ ue(Gt, [["__scopeId", "data-v-7e8e2569"]]), Ht = { class: "flow-canvas-node-palette" }, Ft = ["data-node-type"], qt = { class: "flow-canvas-node-palette__item-label" }, Ut = /* @__PURE__ */ ce({
2087
2220
  __name: "canvas-node-palette",
2088
2221
  props: {
2089
2222
  editor: {},
2090
2223
  items: {}
2091
2224
  },
2092
2225
  setup(s) {
2093
- const e = s, t = z(), o = j(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
2226
+ const e = s, t = L(), o = H(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
2094
2227
  type: n,
2095
2228
  label: n.charAt(0).toUpperCase() + n.slice(1)
2096
2229
  })));
2097
- return le(
2230
+ return ge(
2098
2231
  [() => e.editor.api.value, o, t],
2099
2232
  ([n, i, r], l, a) => {
2100
2233
  if (!n || !r) return;
2101
- const c = [];
2234
+ const f = [];
2102
2235
  for (const d of i) {
2103
- const g = r.querySelector(`[data-node-type="${d.type}"]`);
2104
- if (!g) continue;
2105
- const p = n.registerDndSource(g, () => ({
2106
- id: T(),
2236
+ const b = r.querySelector(`[data-node-type="${d.type}"]`);
2237
+ if (!b) continue;
2238
+ const m = n.registerDndSource(b, () => ({
2239
+ id: $(),
2107
2240
  type: d.type,
2108
2241
  label: d.label,
2109
2242
  position: { x: 0, y: 0 }
2110
2243
  }));
2111
- c.push(p);
2244
+ f.push(m);
2112
2245
  }
2113
2246
  a(() => {
2114
- for (const d of c) d();
2247
+ for (const d of f) d();
2115
2248
  });
2116
2249
  },
2117
2250
  { flush: "post" }
2118
- ), (n, i) => (k(), S("div", _t, [
2119
- A("div", {
2251
+ ), (n, i) => (I(), N("div", Ht, [
2252
+ R("div", {
2120
2253
  ref_key: "listRef",
2121
2254
  ref: t,
2122
2255
  class: "flow-canvas-node-palette__list"
2123
2256
  }, [
2124
- (k(!0), S(ie, null, ye(o.value, (r) => (k(), S("div", {
2257
+ (I(!0), N(de, null, Ee(o.value, (r) => (I(), N("div", {
2125
2258
  key: r.type,
2126
2259
  class: "flow-canvas-node-palette__item",
2127
2260
  "data-node-type": r.type
2128
2261
  }, [
2129
- r.icon ? (k(), S("i", {
2262
+ r.icon ? (I(), N("i", {
2130
2263
  key: 0,
2131
- class: W([r.icon, "flow-canvas-node-palette__item-icon"])
2132
- }, null, 2)) : H("", !0),
2133
- A("span", At, de(r.label), 1)
2134
- ], 8, Pt))), 128))
2264
+ class: Q([r.icon, "flow-canvas-node-palette__item-icon"])
2265
+ }, null, 2)) : F("", !0),
2266
+ R("span", qt, he(r.label), 1)
2267
+ ], 8, Ft))), 128))
2135
2268
  ], 512)
2136
2269
  ]));
2137
2270
  }
2138
- }), Rt = /* @__PURE__ */ ae(Tt, [["__scopeId", "data-v-300314b7"]]), $t = { class: "flow-canvas-layout" }, Lt = { class: "flow-canvas-layout__main" }, Bt = { class: "flow-canvas-layout__content" }, zt = {
2271
+ }), Vt = /* @__PURE__ */ ue(Ut, [["__scopeId", "data-v-300314b7"]]), Wt = { class: "flow-canvas-layout" }, Qt = { class: "flow-canvas-layout__main" }, Xt = { class: "flow-canvas-layout__content" }, Kt = {
2139
2272
  key: 0,
2140
2273
  class: "flow-canvas-layout__footer"
2141
- }, Ot = /* @__PURE__ */ re({
2274
+ }, Yt = /* @__PURE__ */ ce({
2142
2275
  __name: "canvas-layout",
2143
2276
  props: {
2144
2277
  sidebarCollapsed: { type: Boolean, default: !1 },
@@ -2150,34 +2283,34 @@ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
2150
2283
  },
2151
2284
  emits: ["update:sidebarCollapsed"],
2152
2285
  setup(s) {
2153
- return (e, t) => (k(), S("div", $t, [
2154
- !s.hideSidebar && (e.$slots.sidebar || s.editor) ? (k(), S("aside", {
2286
+ return (e, t) => (I(), N("div", Wt, [
2287
+ !s.hideSidebar && (e.$slots.sidebar || s.editor) ? (I(), N("aside", {
2155
2288
  key: 0,
2156
- class: W(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
2157
- style: me({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
2289
+ class: Q(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
2290
+ style: Ie({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
2158
2291
  }, [
2159
- fe(e.$slots, "sidebar", {}, () => [
2160
- s.editor ? (k(), ve(Rt, {
2292
+ me(e.$slots, "sidebar", {}, () => [
2293
+ s.editor ? (I(), Ce(Vt, {
2161
2294
  key: 0,
2162
2295
  editor: s.editor,
2163
2296
  items: s.paletteItems
2164
- }, null, 8, ["editor", "items"])) : H("", !0)
2297
+ }, null, 8, ["editor", "items"])) : F("", !0)
2165
2298
  ], !0)
2166
- ], 6)) : H("", !0),
2167
- A("div", Lt, [
2168
- A("div", Bt, [
2169
- fe(e.$slots, "default", {}, void 0, !0)
2299
+ ], 6)) : F("", !0),
2300
+ R("div", Qt, [
2301
+ R("div", Xt, [
2302
+ me(e.$slots, "default", {}, void 0, !0)
2170
2303
  ]),
2171
- !s.hideFooter && e.$slots.footer ? (k(), S("div", zt, [
2172
- fe(e.$slots, "footer", {}, void 0, !0)
2173
- ])) : H("", !0)
2304
+ !s.hideFooter && e.$slots.footer ? (I(), N("div", Kt, [
2305
+ me(e.$slots, "footer", {}, void 0, !0)
2306
+ ])) : F("", !0)
2174
2307
  ])
2175
2308
  ]));
2176
2309
  }
2177
- }), lo = /* @__PURE__ */ ae(Ot, [["__scopeId", "data-v-26f35b6b"]]), jt = ["undo", "redo"];
2178
- function Ht(s) {
2310
+ }), xo = /* @__PURE__ */ ue(Yt, [["__scopeId", "data-v-26f35b6b"]]), Zt = ["undo", "redo"];
2311
+ function Jt(s) {
2179
2312
  const e = new Set(s?.include), t = /* @__PURE__ */ new Set([
2180
- ...jt.filter((a) => !e.has(a)),
2313
+ ...Zt.filter((a) => !e.has(a)),
2181
2314
  ...s?.exclude ?? []
2182
2315
  ]), o = [
2183
2316
  {
@@ -2269,13 +2402,13 @@ function Ht(s) {
2269
2402
  (a) => !t.has(a.type)
2270
2403
  ), ...i, ...r];
2271
2404
  }
2272
- const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2405
+ const eo = { class: "flow-canvas-toolbar" }, to = {
2273
2406
  key: 0,
2274
2407
  class: "flow-canvas-toolbar__separator"
2275
- }, qt = { class: "flow-canvas-toolbar__group" }, Gt = {
2408
+ }, oo = { class: "flow-canvas-toolbar__group" }, no = {
2276
2409
  key: 0,
2277
2410
  class: "flow-canvas-toolbar__zoom-display"
2278
- }, Vt = ["data-description", "disabled", "onClick"], Wt = ["textContent"], Qt = /* @__PURE__ */ re({
2411
+ }, so = ["data-description", "disabled", "onClick"], io = ["textContent"], ro = /* @__PURE__ */ ce({
2279
2412
  __name: "canvas-toolbar",
2280
2413
  props: {
2281
2414
  items: {},
@@ -2283,42 +2416,42 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2283
2416
  editor: {}
2284
2417
  },
2285
2418
  setup(s) {
2286
- const e = s, t = j(() => e.items ? e.items : Ht({ exclude: e.exclude })), o = z(1);
2419
+ const e = s, t = H(() => e.items ? e.items : Jt({ exclude: e.exclude })), o = L(1);
2287
2420
  let n = null;
2288
- le(
2421
+ ge(
2289
2422
  () => e.editor.api.value,
2290
- (u) => {
2291
- n?.(), n = null, u && (o.value = u.getZoom(), n = u.onGraphEvent("scale", () => {
2292
- o.value = u.getZoom();
2423
+ (g) => {
2424
+ n?.(), n = null, g && (o.value = g.getZoom(), n = g.onGraphEvent("scale", () => {
2425
+ o.value = g.getZoom();
2293
2426
  }));
2294
2427
  },
2295
2428
  { immediate: !0 }
2296
- ), Le(() => {
2429
+ ), Ue(() => {
2297
2430
  n?.();
2298
2431
  });
2299
- const i = j(() => `${Math.round(o.value * 100)}%`), r = j(() => e.editor.api.value ? {
2432
+ const i = H(() => `${Math.round(o.value * 100)}%`), r = H(() => e.editor.api.value ? {
2300
2433
  api: e.editor.api.value,
2301
2434
  flowModel: e.editor.flowModel.value,
2302
2435
  history: e.editor.history,
2303
2436
  mode: e.editor.mode.value
2304
2437
  } : null);
2305
- function l(u) {
2306
- return u.visible === !1 ? !1 : typeof u.visible == "function" ? r.value ? u.visible(r.value) : !1 : !0;
2438
+ function l(g) {
2439
+ return g.visible === !1 ? !1 : typeof g.visible == "function" ? r.value ? g.visible(r.value) : !1 : !0;
2307
2440
  }
2308
- function a(u) {
2309
- return u.type === "select" ? e.editor.selectionMode.value : !1;
2441
+ function a(g) {
2442
+ return g.type === "select" ? e.editor.selectionMode.value : !1;
2310
2443
  }
2311
- function c(u) {
2312
- return !r.value || u.disabled === !0 ? !0 : typeof u.disabled == "function" ? u.disabled(r.value) : u.type === "undo" ? !e.editor.history.canUndo.value : u.type === "redo" ? !e.editor.history.canRedo.value : !1;
2444
+ function f(g) {
2445
+ return !r.value || g.disabled === !0 ? !0 : typeof g.disabled == "function" ? g.disabled(r.value) : g.type === "undo" ? !e.editor.history.canUndo.value : g.type === "redo" ? !e.editor.history.canRedo.value : !1;
2313
2446
  }
2314
- function d(u) {
2315
- if (!r.value || c(u)) return;
2316
- if (u.onClick) {
2317
- u.onClick(r.value);
2447
+ function d(g) {
2448
+ if (!r.value || f(g)) return;
2449
+ if (g.onClick) {
2450
+ g.onClick(r.value);
2318
2451
  return;
2319
2452
  }
2320
- const { api: N } = r.value;
2321
- switch (u.type) {
2453
+ const { api: S } = r.value;
2454
+ switch (g.type) {
2322
2455
  case "undo":
2323
2456
  e.editor.history.undo();
2324
2457
  break;
@@ -2326,23 +2459,23 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2326
2459
  e.editor.history.redo();
2327
2460
  break;
2328
2461
  case "zoom-in":
2329
- N.zoomIn(), o.value = N.getZoom();
2462
+ S.zoomIn(), o.value = S.getZoom();
2330
2463
  break;
2331
2464
  case "zoom-out":
2332
- N.zoomOut(), o.value = N.getZoom();
2465
+ S.zoomOut(), o.value = S.getZoom();
2333
2466
  break;
2334
2467
  case "fit":
2335
- N.zoomToFit();
2468
+ S.zoomToFit();
2336
2469
  break;
2337
2470
  case "reset":
2338
- N.zoomTo(1), N.scrollToOrigin(), o.value = 1;
2471
+ S.zoomTo(1), S.scrollToOrigin(), o.value = 1;
2339
2472
  break;
2340
2473
  case "export":
2341
- N.exportAsImage().then((b) => {
2342
- const y = URL.createObjectURL(b), m = document.createElement("a");
2343
- m.href = y, m.download = "canvas-export.png", m.click(), URL.revokeObjectURL(y);
2344
- }).catch((b) => {
2345
- console.warn("[flow-canvas] Export failed:", b);
2474
+ S.exportAsImage().then((k) => {
2475
+ const w = URL.createObjectURL(k), x = document.createElement("a");
2476
+ x.href = w, x.download = "canvas-export.png", x.click(), URL.revokeObjectURL(w);
2477
+ }).catch((k) => {
2478
+ console.warn("[flow-canvas] Export failed:", k);
2346
2479
  });
2347
2480
  break;
2348
2481
  case "select":
@@ -2351,61 +2484,61 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2351
2484
  case "search":
2352
2485
  case "auto-layout":
2353
2486
  case "minimap":
2354
- console.warn(`[flow-canvas] "${u.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2487
+ console.warn(`[flow-canvas] "${g.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2355
2488
  break;
2356
2489
  default:
2357
- u.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${u.type}". Provide an onClick handler.`);
2490
+ g.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${g.type}". Provide an onClick handler.`);
2358
2491
  break;
2359
2492
  }
2360
2493
  }
2361
- const g = j(() => t.value.filter(l)), p = j(() => {
2362
- const u = /* @__PURE__ */ new Map(), N = [];
2363
- for (const b of g.value) {
2364
- const y = b.group ?? "default";
2365
- u.has(y) || (u.set(y, []), N.push(y)), u.get(y).push(b);
2494
+ const b = H(() => t.value.filter(l)), m = H(() => {
2495
+ const g = /* @__PURE__ */ new Map(), S = [];
2496
+ for (const k of b.value) {
2497
+ const w = k.group ?? "default";
2498
+ g.has(w) || (g.set(w, []), S.push(w)), g.get(w).push(k);
2366
2499
  }
2367
- return N.map((b) => ({ name: b, items: u.get(b) })).filter((b) => b.items.length > 0);
2500
+ return S.map((k) => ({ name: k, items: g.get(k) })).filter((k) => k.items.length > 0);
2368
2501
  });
2369
- return (u, N) => (k(), S("div", Ft, [
2370
- (k(!0), S(ie, null, ye(p.value, (b, y) => (k(), S(ie, {
2371
- key: b.name
2502
+ return (g, S) => (I(), N("div", eo, [
2503
+ (I(!0), N(de, null, Ee(m.value, (k, w) => (I(), N(de, {
2504
+ key: k.name
2372
2505
  }, [
2373
- y > 0 ? (k(), S("div", Ut)) : H("", !0),
2374
- A("div", qt, [
2375
- (k(!0), S(ie, null, ye(b.items, (m) => (k(), S(ie, {
2376
- key: m.id
2506
+ w > 0 ? (I(), N("div", to)) : F("", !0),
2507
+ R("div", oo, [
2508
+ (I(!0), N(de, null, Ee(k.items, (x) => (I(), N(de, {
2509
+ key: x.id
2377
2510
  }, [
2378
- m.type === "zoom-display" ? (k(), S("span", Gt, de(i.value), 1)) : (k(), S("button", {
2511
+ x.type === "zoom-display" ? (I(), N("span", no, he(i.value), 1)) : (I(), N("button", {
2379
2512
  key: 1,
2380
- class: W(["flow-canvas-toolbar__btn", { "is-disabled": c(m), "is-active": a(m) }]),
2381
- "data-description": m.description,
2382
- disabled: c(m),
2383
- onClick: (R) => d(m)
2513
+ class: Q(["flow-canvas-toolbar__btn", { "is-disabled": f(x), "is-active": a(x) }]),
2514
+ "data-description": x.description,
2515
+ disabled: f(x),
2516
+ onClick: (A) => d(x)
2384
2517
  }, [
2385
- m.component ? (k(), ve(qe(m.component), { key: 0 })) : m.icon ? (k(), S("i", {
2518
+ x.component ? (I(), Ce(tt(x.component), { key: 0 })) : x.icon ? (I(), N("i", {
2386
2519
  key: 1,
2387
- class: W(m.icon)
2388
- }, null, 2)) : (k(), S("span", {
2520
+ class: Q(x.icon)
2521
+ }, null, 2)) : (I(), N("span", {
2389
2522
  key: 2,
2390
2523
  class: "flow-canvas-toolbar__text",
2391
- textContent: de(m.text ?? m.description ?? m.id)
2392
- }, null, 8, Wt))
2393
- ], 10, Vt))
2524
+ textContent: he(x.text ?? x.description ?? x.id)
2525
+ }, null, 8, io))
2526
+ ], 10, so))
2394
2527
  ], 64))), 128))
2395
2528
  ])
2396
2529
  ], 64))), 128))
2397
2530
  ]));
2398
2531
  }
2399
- }), co = /* @__PURE__ */ ae(Qt, [["__scopeId", "data-v-51b5c98a"]]), Xt = { class: "flow-canvas-default-node__ep-label" }, Kt = {
2532
+ }), ko = /* @__PURE__ */ ue(ro, [["__scopeId", "data-v-51b5c98a"]]), ao = { class: "flow-canvas-default-node__ep-label" }, lo = {
2400
2533
  key: 1,
2401
2534
  class: "flow-canvas-default-node__diamond"
2402
- }, Yt = {
2535
+ }, co = {
2403
2536
  key: 2,
2404
2537
  class: "flow-canvas-default-node__task-label"
2405
- }, Zt = /* @__PURE__ */ re({
2538
+ }, uo = /* @__PURE__ */ ce({
2406
2539
  __name: "default-node",
2407
2540
  setup(s) {
2408
- const t = Ge("getNode")?.(), o = j(() => t?.getData?.() ?? null), n = j(() => o.value?.label || o.value?.type || ""), i = {
2541
+ const t = ot("getNode")?.(), o = H(() => t?.getData?.() ?? null), n = H(() => o.value?.label || o.value?.type || ""), i = {
2409
2542
  start: "canvas-kaishi",
2410
2543
  end: "canvas-stop",
2411
2544
  "parallel-gateway": "canvas-bingxingwangguan",
@@ -2417,28 +2550,28 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2417
2550
  "branch-gateway",
2418
2551
  "converge-gateway",
2419
2552
  "conditional-parallel-gateway"
2420
- ]), a = j(() => {
2553
+ ]), a = H(() => {
2421
2554
  const d = o.value?.type ?? "";
2422
2555
  return r.has(d) ? "endpoint" : l.has(d) ? "gateway" : "task";
2423
- }), c = j(() => i[o.value?.type ?? ""] ?? "");
2424
- return (d, g) => (k(), S("div", {
2425
- class: W(["flow-canvas-default-node", `is-${a.value}`])
2556
+ }), f = H(() => i[o.value?.type ?? ""] ?? "");
2557
+ return (d, b) => (I(), N("div", {
2558
+ class: Q(["flow-canvas-default-node", `is-${a.value}`])
2426
2559
  }, [
2427
- a.value === "endpoint" ? (k(), S(ie, { key: 0 }, [
2428
- c.value ? (k(), S("i", {
2560
+ a.value === "endpoint" ? (I(), N(de, { key: 0 }, [
2561
+ f.value ? (I(), N("i", {
2429
2562
  key: 0,
2430
- class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__ep-icon"])
2431
- }, null, 2)) : H("", !0),
2432
- A("span", Xt, de(n.value), 1)
2433
- ], 64)) : a.value === "gateway" ? (k(), S("div", Kt, [
2434
- c.value ? (k(), S("i", {
2563
+ class: Q([["flow-canvas-icon", f.value], "flow-canvas-default-node__ep-icon"])
2564
+ }, null, 2)) : F("", !0),
2565
+ R("span", ao, he(n.value), 1)
2566
+ ], 64)) : a.value === "gateway" ? (I(), N("div", lo, [
2567
+ f.value ? (I(), N("i", {
2435
2568
  key: 0,
2436
- class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__gw-icon"])
2437
- }, null, 2)) : H("", !0)
2438
- ])) : (k(), S("span", Yt, de(n.value), 1))
2569
+ class: Q([["flow-canvas-icon", f.value], "flow-canvas-default-node__gw-icon"])
2570
+ }, null, 2)) : F("", !0)
2571
+ ])) : (I(), N("span", co, he(n.value), 1))
2439
2572
  ], 2));
2440
2573
  }
2441
- }), Jt = /* @__PURE__ */ ae(Zt, [["__scopeId", "data-v-c88cdae7"]]), eo = {
2574
+ }), fo = /* @__PURE__ */ ue(uo, [["__scopeId", "data-v-c88cdae7"]]), po = {
2442
2575
  start: { label: "开始", icon: "flow-canvas-icon canvas-kaishi", width: 88, height: 40 },
2443
2576
  end: { label: "结束", icon: "flow-canvas-icon canvas-stop", width: 88, height: 40 },
2444
2577
  empty: { label: "空节点", icon: "flow-canvas-icon canvas-jiedi", width: 240, height: 48 },
@@ -2451,43 +2584,44 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2451
2584
  width: 64,
2452
2585
  height: 64
2453
2586
  }
2454
- }, Re = (s, e) => ({
2587
+ }, Fe = (s, e) => ({
2455
2588
  stroke: e.hovered ? "#3a84ff" : "#abb5cc",
2456
2589
  strokeWidth: 2
2457
- }), $e = {
2458
- attrs: {
2459
- line: {
2460
- stroke: "#abb5cc",
2461
- strokeWidth: 2,
2462
- targetMarker: { name: "block", width: 8, height: 8 }
2463
- }
2464
- }
2465
- }, to = {
2466
- manhattan: {
2467
- router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
2468
- connector: { name: "rounded", args: { radius: 8 } },
2469
- style: Re,
2470
- x6EdgeConfig: $e
2471
- },
2472
- bezier: {
2473
- connector: { name: "smooth" },
2474
- style: Re,
2475
- x6EdgeConfig: $e
2476
- }
2477
- };
2478
- function uo(s) {
2479
- const e = s?.nodeTypes ?? eo, t = {}, o = [];
2590
+ });
2591
+ function qe() {
2592
+ return {
2593
+ attrs: {
2594
+ line: {
2595
+ stroke: "#abb5cc",
2596
+ strokeWidth: 2,
2597
+ targetMarker: { name: "block", width: 8, height: 8 }
2598
+ }
2599
+ }
2600
+ };
2601
+ }
2602
+ function go() {
2603
+ return {
2604
+ manhattan: {
2605
+ router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
2606
+ connector: { name: "rounded", args: { radius: 8 } },
2607
+ style: Fe,
2608
+ x6EdgeConfig: qe()
2609
+ },
2610
+ bezier: {
2611
+ connector: { name: "smooth" },
2612
+ style: Fe,
2613
+ x6EdgeConfig: qe()
2614
+ }
2615
+ };
2616
+ }
2617
+ function Co(s) {
2618
+ const e = s?.nodeTypes ?? po, t = {}, o = [];
2480
2619
  for (const [r, l] of Object.entries(e)) {
2481
- const a = l.width ?? 150, c = l.height ?? 50;
2620
+ const a = l.width ?? 150, f = l.height ?? 50;
2482
2621
  t[r] = {
2483
- component: Jt,
2484
- getSize: () => ({ width: a, height: c }),
2485
- getPorts: () => [
2486
- { id: "top", group: "top" },
2487
- { id: "right", group: "right" },
2488
- { id: "bottom", group: "bottom" },
2489
- { id: "left", group: "left" }
2490
- ]
2622
+ component: fo,
2623
+ getSize: () => ({ width: a, height: f }),
2624
+ getPorts: () => Qe()
2491
2625
  }, o.push({
2492
2626
  type: r,
2493
2627
  label: l.label ?? r,
@@ -2495,7 +2629,7 @@ function uo(s) {
2495
2629
  });
2496
2630
  }
2497
2631
  const n = {
2498
- ...to,
2632
+ ...go(),
2499
2633
  ...s?.edgeTypes
2500
2634
  }, i = s?.defaultEdgeType ?? "manhattan";
2501
2635
  return {
@@ -2503,7 +2637,7 @@ function uo(s) {
2503
2637
  paletteItems: o
2504
2638
  };
2505
2639
  }
2506
- function fo(s) {
2640
+ function Eo(s) {
2507
2641
  return {
2508
2642
  name: "connection-validator",
2509
2643
  priority: 10,
@@ -2512,20 +2646,20 @@ function fo(s) {
2512
2646
  if (n.type !== "edge.add" && n.type !== "edge.reconnect") continue;
2513
2647
  const i = o.flowModel.value, r = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId, l = n.type === "edge.add" ? n.edge.target.nodeId : n.target?.nodeId;
2514
2648
  if (!r || !l) continue;
2515
- const a = i.nodes[r], c = i.nodes[l];
2516
- if (!a || !c) continue;
2517
- const d = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, g = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, p = d ? a.ports?.find((m) => m.id === d) : void 0, u = g ? c.ports?.find((m) => m.id === g) : void 0, N = n.type === "edge.reconnect" ? n.edgeId : void 0, b = Object.values(i.edges).filter((m) => m.id !== N), y = s({
2649
+ const a = i.nodes[r], f = i.nodes[l];
2650
+ if (!a || !f) continue;
2651
+ const d = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, b = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, m = d ? a.ports?.find((x) => x.id === d) : void 0, g = b ? f.ports?.find((x) => x.id === b) : void 0, S = n.type === "edge.reconnect" ? n.edgeId : void 0, k = Object.values(i.edges).filter((x) => x.id !== S), w = s({
2518
2652
  flowModel: i,
2519
2653
  sourceNode: a,
2520
- targetNode: c,
2521
- sourcePort: p,
2522
- targetPort: u,
2523
- existingEdges: b
2654
+ targetNode: f,
2655
+ sourcePort: m,
2656
+ targetPort: g,
2657
+ existingEdges: k
2524
2658
  });
2525
- if (!y.valid)
2659
+ if (!w.valid)
2526
2660
  return {
2527
2661
  rejected: !0,
2528
- reason: y.reason ?? "Connection validation failed",
2662
+ reason: w.reason ?? "Connection validation failed",
2529
2663
  code: "validation_failed"
2530
2664
  };
2531
2665
  }
@@ -2533,7 +2667,7 @@ function fo(s) {
2533
2667
  }
2534
2668
  };
2535
2669
  }
2536
- function po(s) {
2670
+ function Io(s) {
2537
2671
  const { rubberband: e = !0, multiple: t = !0, movable: o = !0 } = s ?? {};
2538
2672
  return {
2539
2673
  name: "selection",
@@ -2553,7 +2687,7 @@ function po(s) {
2553
2687
  }
2554
2688
  };
2555
2689
  }
2556
- function go(s) {
2690
+ function Mo(s) {
2557
2691
  const { tolerance: e = 10, color: t = "#3a84ff" } = s ?? {};
2558
2692
  let o = null;
2559
2693
  return {
@@ -2574,7 +2708,7 @@ function go(s) {
2574
2708
  }
2575
2709
  };
2576
2710
  }
2577
- function ho(s) {
2711
+ function No(s) {
2578
2712
  let e = null;
2579
2713
  return {
2580
2714
  name: "minimap",
@@ -2612,7 +2746,7 @@ function ho(s) {
2612
2746
  }
2613
2747
  };
2614
2748
  }
2615
- function vo() {
2749
+ function So() {
2616
2750
  let s = null, e = 0;
2617
2751
  return {
2618
2752
  name: "clipboard",
@@ -2624,22 +2758,22 @@ function vo() {
2624
2758
  if (!i.length) return !1;
2625
2759
  const r = o.flowModel.value, l = new Set(i.filter((d) => d.isNode()).map((d) => d.id)), a = [...l].map((d) => r.nodes[d]).filter(Boolean);
2626
2760
  if (!a.length) return !1;
2627
- const c = Object.values(r.edges).filter(
2761
+ const f = Object.values(r.edges).filter(
2628
2762
  (d) => l.has(d.source.nodeId) && l.has(d.target.nodeId)
2629
2763
  );
2630
- return s = { nodes: a, edges: c }, e = 0, !0;
2764
+ return s = { nodes: a, edges: f }, e = 0, !0;
2631
2765
  }
2632
2766
  if (n && t.key === "v") {
2633
2767
  if (!s?.nodes.length) return !1;
2634
2768
  e++;
2635
2769
  const i = e * 30, r = /* @__PURE__ */ new Map(), l = [];
2636
2770
  for (const a of s.nodes) {
2637
- const c = `${a.id}_cp${T().slice(0, 6)}`;
2638
- r.set(a.id, c), l.push({
2771
+ const f = `${a.id}_cp${$().slice(0, 6)}`;
2772
+ r.set(a.id, f), l.push({
2639
2773
  type: "node.add",
2640
2774
  node: {
2641
2775
  ...a,
2642
- id: c,
2776
+ id: f,
2643
2777
  position: {
2644
2778
  x: a.position.x + i,
2645
2779
  y: a.position.y + i
@@ -2650,21 +2784,21 @@ function vo() {
2650
2784
  });
2651
2785
  }
2652
2786
  for (const a of s.edges) {
2653
- const c = r.get(a.source.nodeId), d = r.get(a.target.nodeId);
2654
- !c || !d || l.push({
2787
+ const f = r.get(a.source.nodeId), d = r.get(a.target.nodeId);
2788
+ !f || !d || l.push({
2655
2789
  type: "edge.add",
2656
2790
  edge: {
2657
2791
  ...a,
2658
- id: `${a.id}_cp${T().slice(0, 6)}`,
2659
- source: { ...a.source, nodeId: c },
2792
+ id: `${a.id}_cp${$().slice(0, 6)}`,
2793
+ source: { ...a.source, nodeId: f },
2660
2794
  target: { ...a.target, nodeId: d },
2661
- labels: a.labels?.map((g) => ({ ...g, id: `${g.id}_cp${T().slice(0, 6)}` })),
2795
+ labels: a.labels?.map((b) => ({ ...b, id: `${b.id}_cp${$().slice(0, 6)}` })),
2662
2796
  payload: a.payload ? { ...a.payload } : {}
2663
2797
  }
2664
2798
  });
2665
2799
  }
2666
2800
  return l.length && o.executeCommand({
2667
- id: T(),
2801
+ id: $(),
2668
2802
  source: "user:keyboard",
2669
2803
  label: "粘贴",
2670
2804
  timestamp: Date.now(),
@@ -2676,25 +2810,26 @@ function vo() {
2676
2810
  };
2677
2811
  }
2678
2812
  export {
2679
- K as CanvasConstraintError,
2680
- lo as CanvasLayout,
2681
- Rt as CanvasNodePalette,
2682
- ao as CanvasRuntime,
2683
- Qe as CanvasSchemaError,
2684
- co as CanvasToolbar,
2685
- Jt as DefaultNode,
2686
- Ct as NodeActionsToolbar,
2687
- St as NodeQuickAddPopover,
2688
- Me as applyCanvasCommand,
2689
- vo as clipboardPlugin,
2690
- fo as connectionValidatorPlugin,
2691
- lt as createCanvasHistory,
2692
- uo as createDefaultSchema,
2693
- Ht as createDefaultToolbarItems,
2694
- io as createEmptyFlowModel,
2695
- T as generateId,
2696
- ho as minimapPlugin,
2697
- po as selectionPlugin,
2698
- go as snaplinePlugin,
2699
- ro as useCanvasEditor
2813
+ Y as CanvasConstraintError,
2814
+ xo as CanvasLayout,
2815
+ Vt as CanvasNodePalette,
2816
+ wo as CanvasRuntime,
2817
+ it as CanvasSchemaError,
2818
+ ko as CanvasToolbar,
2819
+ fo as DefaultNode,
2820
+ $t as NodeActionsToolbar,
2821
+ zt as NodeQuickAddPopover,
2822
+ Te as applyCanvasCommand,
2823
+ So as clipboardPlugin,
2824
+ Eo as connectionValidatorPlugin,
2825
+ go as createBuiltinEdgeTypes,
2826
+ bt as createCanvasHistory,
2827
+ Co as createDefaultSchema,
2828
+ Jt as createDefaultToolbarItems,
2829
+ mo as createEmptyFlowModel,
2830
+ $ as generateId,
2831
+ No as minimapPlugin,
2832
+ Io as selectionPlugin,
2833
+ Mo as snaplinePlugin,
2834
+ bo as useCanvasEditor
2700
2835
  };