dishui 0.0.45 → 0.0.46
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/chart.js +46 -0
- package/dist/components/Chart/Chart.d.ts +17 -0
- package/dist/components/Chart/Chart.js +29 -0
- package/dist/components/Chart/Chart.js.map +1 -0
- package/dist/components/Chart/index.d.ts +15 -0
- package/dist/components/Input/index.js +2 -2
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/pro/Flow/Flow.js +492 -392
- package/dist/components/pro/Flow/Flow.js.map +1 -1
- package/dist/components/pro/Flow/FlowCanvas.js +895 -864
- package/dist/components/pro/Flow/FlowCanvas.js.map +1 -1
- package/dist/components/pro/Flow/context/FlowUIContext.d.ts +2 -0
- package/dist/components/pro/Flow/context/FlowUIContext.js +68 -65
- package/dist/components/pro/Flow/context/FlowUIContext.js.map +1 -1
- package/dist/components/pro/Flow/edges/edgePaths.js +234 -216
- package/dist/components/pro/Flow/edges/edgePaths.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useKeyboardShortcuts.js +21 -10
- package/dist/components/pro/Flow/hooks/useKeyboardShortcuts.js.map +1 -1
- package/dist/components/pro/Flow/hooks/useMindMap.js +138 -134
- package/dist/components/pro/Flow/hooks/useMindMap.js.map +1 -1
- package/dist/components/pro/Flow/index.d.ts +1 -1
- package/dist/components/pro/Flow/nodes/MediaContent.js +47 -25
- package/dist/components/pro/Flow/nodes/MediaContent.js.map +1 -1
- package/dist/components/pro/Flow/nodes/Model3DView.d.ts +7 -0
- package/dist/components/pro/Flow/nodes/Model3DView.js +118 -0
- package/dist/components/pro/Flow/nodes/Model3DView.js.map +1 -0
- package/dist/components/pro/Flow/nodes/NodeHandles.d.ts +2 -1
- package/dist/components/pro/Flow/nodes/NodeHandles.js +4 -2
- package/dist/components/pro/Flow/nodes/NodeHandles.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeRenderer.d.ts +2 -0
- package/dist/components/pro/Flow/nodes/NodeRenderer.js +115 -113
- package/dist/components/pro/Flow/nodes/NodeRenderer.js.map +1 -1
- package/dist/components/pro/Flow/nodes/NodeText.d.ts +3 -0
- package/dist/components/pro/Flow/nodes/NodeText.js +26 -17
- package/dist/components/pro/Flow/nodes/NodeText.js.map +1 -1
- package/dist/components/pro/Flow/panels/FlowToolbar.js +85 -79
- package/dist/components/pro/Flow/panels/FlowToolbar.js.map +1 -1
- package/dist/components/pro/Flow/panels/InspectorPanel.js +618 -488
- package/dist/components/pro/Flow/panels/InspectorPanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/OutlinePanel.js +15 -15
- package/dist/components/pro/Flow/panels/OutlinePanel.js.map +1 -1
- package/dist/components/pro/Flow/panels/ShapePalette.js +71 -55
- package/dist/components/pro/Flow/panels/ShapePalette.js.map +1 -1
- package/dist/components/pro/Flow/panels/toolbarIcons.d.ts +1 -0
- package/dist/components/pro/Flow/panels/toolbarIcons.js +59 -41
- package/dist/components/pro/Flow/panels/toolbarIcons.js.map +1 -1
- package/dist/components/pro/Flow/types.d.ts +13 -4
- package/dist/components/pro/Flow/types.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +145 -143
- package/dist/utils/i18n.d.ts +1 -0
- package/dist/utils/i18n.js +200 -6
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +26 -10
- package/dist/utils/menu.js.map +1 -1
- package/package.json +14 -3
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { useFlowContext as
|
|
2
|
-
import { useFlowUI as
|
|
3
|
-
import { usePixiApp as
|
|
4
|
-
import { useViewport as
|
|
5
|
-
import { GridRenderer as
|
|
6
|
-
import { SelectionOverlay as
|
|
7
|
-
import { shapeDrawers as
|
|
8
|
-
import { findClosestHandleWorld as
|
|
9
|
-
import { distToSegment as
|
|
10
|
-
import { NodeRenderer as
|
|
11
|
-
import { buildEdgePath as
|
|
12
|
-
import { EdgeRenderer as
|
|
13
|
-
import { LineRenderer as
|
|
14
|
-
import { FreehandTool as
|
|
15
|
-
import { GeometricLineTool as
|
|
16
|
-
import { computeAlignmentSnap as
|
|
17
|
-
import { AlignmentGuidesRenderer as
|
|
18
|
-
import { getDocumentSlides as
|
|
19
|
-
import { useCallback as
|
|
20
|
-
import { jsx as
|
|
21
|
-
import { Graphics as
|
|
22
|
-
var
|
|
1
|
+
import { useFlowContext as Ve } from "./context/FlowContext.js";
|
|
2
|
+
import { useFlowUI as Be } from "./context/FlowUIContext.js";
|
|
3
|
+
import { usePixiApp as Ke } from "./hooks/usePixiApp.js";
|
|
4
|
+
import { useViewport as je } from "./hooks/useViewport.js";
|
|
5
|
+
import { GridRenderer as Ue } from "./canvas/GridRenderer.js";
|
|
6
|
+
import { SelectionOverlay as $e } from "./canvas/SelectionOverlay.js";
|
|
7
|
+
import { shapeDrawers as Pe } from "./nodes/shapes.js";
|
|
8
|
+
import { findClosestHandleWorld as Dt, getHandlePositions as gt, handleWorldPos as Ot } from "./nodes/NodeHandles.js";
|
|
9
|
+
import { distToSegment as me, generateId as Je, isPointInNode as Ht, rectsOverlap as Qe } from "./nodes/nodeUtils.js";
|
|
10
|
+
import { NodeRenderer as tn } from "./nodes/NodeRenderer.js";
|
|
11
|
+
import { buildEdgePath as _e, linearizeSegments as Ze, resolveEdgeEndpoints as Mt } from "./edges/edgePaths.js";
|
|
12
|
+
import { EdgeRenderer as en } from "./edges/EdgeRenderer.js";
|
|
13
|
+
import { LineRenderer as nn } from "./lines/LineRenderer.js";
|
|
14
|
+
import { FreehandTool as rn } from "./lines/FreehandTool.js";
|
|
15
|
+
import { GeometricLineTool as on } from "./lines/GeometricLineTool.js";
|
|
16
|
+
import { computeAlignmentSnap as ee } from "./hooks/useAlignmentGuides.js";
|
|
17
|
+
import { AlignmentGuidesRenderer as sn } from "./canvas/AlignmentGuides.js";
|
|
18
|
+
import { getDocumentSlides as cn, nextAnimIndex as dn } from "./nodes/animAnchors.js";
|
|
19
|
+
import { useCallback as ne, useEffect as wt, useRef as b, useState as Ge } from "react";
|
|
20
|
+
import { jsx as We, jsxs as an } from "react/jsx-runtime";
|
|
21
|
+
import { Graphics as Vt } from "pixi.js";
|
|
22
|
+
var ln = {
|
|
23
23
|
nw: "nwse-resize",
|
|
24
24
|
ne: "nesw-resize",
|
|
25
25
|
se: "nwse-resize",
|
|
26
26
|
sw: "nesw-resize"
|
|
27
27
|
};
|
|
28
|
-
function
|
|
29
|
-
const { x:
|
|
28
|
+
function Le(_, E, X) {
|
|
29
|
+
const { x: O, y: D } = E.position, T = E.width, k = E.height, N = [
|
|
30
30
|
[
|
|
31
31
|
"nw",
|
|
32
|
-
|
|
32
|
+
O,
|
|
33
33
|
D
|
|
34
34
|
],
|
|
35
35
|
[
|
|
36
36
|
"ne",
|
|
37
|
-
|
|
37
|
+
O + T,
|
|
38
38
|
D
|
|
39
39
|
],
|
|
40
40
|
[
|
|
41
41
|
"se",
|
|
42
|
-
|
|
42
|
+
O + T,
|
|
43
43
|
D + k
|
|
44
44
|
],
|
|
45
45
|
[
|
|
46
46
|
"sw",
|
|
47
|
-
|
|
47
|
+
O,
|
|
48
48
|
D + k
|
|
49
49
|
]
|
|
50
50
|
];
|
|
51
|
-
let M = null, F =
|
|
52
|
-
for (const [
|
|
53
|
-
const U = Math.hypot(
|
|
54
|
-
U < F && (F = U, M =
|
|
51
|
+
let M = null, F = X;
|
|
52
|
+
for (const [j, tt, ct] of N) {
|
|
53
|
+
const U = Math.hypot(_.x - tt, _.y - ct);
|
|
54
|
+
U < F && (F = U, M = j);
|
|
55
55
|
}
|
|
56
56
|
return M;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
let
|
|
60
|
-
for (const
|
|
61
|
-
const M =
|
|
58
|
+
function Ae(_, E, X, O, D) {
|
|
59
|
+
let T = null, k = D;
|
|
60
|
+
for (const N of X) {
|
|
61
|
+
const M = Mt(N, O);
|
|
62
62
|
if (!M) continue;
|
|
63
|
-
const F = Math.hypot(
|
|
64
|
-
F < k && (k = F,
|
|
65
|
-
edgeId:
|
|
63
|
+
const F = Math.hypot(_ - M.sx, E - M.sy);
|
|
64
|
+
F < k && (k = F, T = {
|
|
65
|
+
edgeId: N.id,
|
|
66
66
|
end: "source",
|
|
67
67
|
worldX: M.sx,
|
|
68
68
|
worldY: M.sy
|
|
69
69
|
});
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
edgeId:
|
|
70
|
+
const j = Math.hypot(_ - M.tx, E - M.ty);
|
|
71
|
+
j < k && (k = j, T = {
|
|
72
|
+
edgeId: N.id,
|
|
73
73
|
end: "target",
|
|
74
74
|
worldX: M.tx,
|
|
75
75
|
worldY: M.ty
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return T;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
let D = null,
|
|
82
|
-
for (const k of
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
for (let M = 0; M <
|
|
86
|
-
const F = Math.hypot(
|
|
87
|
-
F <
|
|
80
|
+
function Ye(_, E, X, O) {
|
|
81
|
+
let D = null, T = O;
|
|
82
|
+
for (const k of X) {
|
|
83
|
+
const N = k.data.waypoints;
|
|
84
|
+
if (N)
|
|
85
|
+
for (let M = 0; M < N.length; M++) {
|
|
86
|
+
const F = Math.hypot(_ - N[M].x, E - N[M].y);
|
|
87
|
+
F < T && (T = F, D = {
|
|
88
88
|
edgeId: k.id,
|
|
89
89
|
waypointIndex: M,
|
|
90
|
-
wx:
|
|
91
|
-
wy:
|
|
90
|
+
wx: N[M].x,
|
|
91
|
+
wy: N[M].y
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return D;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
98
|
-
let
|
|
99
|
-
for (const
|
|
100
|
-
if (
|
|
101
|
-
const M =
|
|
97
|
+
function Xe(_, E, X, O, D) {
|
|
98
|
+
let T = null, k = D;
|
|
99
|
+
for (const N of X) {
|
|
100
|
+
if (N.type !== "simplebezier") continue;
|
|
101
|
+
const M = Mt(N, O);
|
|
102
102
|
if (!M) continue;
|
|
103
|
-
const F =
|
|
103
|
+
const F = N.data.waypoints ?? [], j = [
|
|
104
104
|
{
|
|
105
105
|
x: M.sx,
|
|
106
106
|
y: M.sy
|
|
@@ -110,150 +110,154 @@ function Wt(X, C, _, B, D) {
|
|
|
110
110
|
x: M.tx,
|
|
111
111
|
y: M.ty
|
|
112
112
|
}
|
|
113
|
-
],
|
|
114
|
-
for (let U = 0; U <=
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
edgeId:
|
|
113
|
+
], tt = N.data.bezierControls, ct = j.length - 2;
|
|
114
|
+
for (let U = 0; U <= ct; U++) {
|
|
115
|
+
const et = j[U], nt = j[U + 1], Tt = tt?.[U], re = Math.hypot(nt.x - et.x, nt.y - et.y), mt = Math.max(30, re * 0.3), Pt = Tt?.c1x ?? (U === 0 ? et.x + M.snx * mt : et.x + (nt.x - et.x) * 0.4), Rt = Tt?.c1y ?? (U === 0 ? et.y + M.sny * mt : et.y), It = Tt?.c2x ?? (U === ct ? nt.x + M.tnx * mt : nt.x - (nt.x - et.x) * 0.4), yt = Tt?.c2y ?? (U === ct ? nt.y + M.tny * mt : nt.y), St = Math.hypot(_ - Pt, E - Rt);
|
|
116
|
+
St < k && (k = St, T = {
|
|
117
|
+
edgeId: N.id,
|
|
118
118
|
segmentIndex: U,
|
|
119
119
|
controlEnd: "c1",
|
|
120
|
-
wx:
|
|
121
|
-
wy:
|
|
120
|
+
wx: Pt,
|
|
121
|
+
wy: Rt
|
|
122
122
|
});
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
edgeId:
|
|
123
|
+
const Gt = Math.hypot(_ - It, E - yt);
|
|
124
|
+
Gt < k && (k = Gt, T = {
|
|
125
|
+
edgeId: N.id,
|
|
126
126
|
segmentIndex: U,
|
|
127
127
|
controlEnd: "c2",
|
|
128
|
-
wx:
|
|
129
|
-
wy:
|
|
128
|
+
wx: It,
|
|
129
|
+
wy: yt
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return T;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const D =
|
|
135
|
+
function un(_, E, X, O) {
|
|
136
|
+
const D = Mt(X, O);
|
|
137
137
|
if (!D) return 0;
|
|
138
|
-
const
|
|
138
|
+
const T = X.data.waypoints ?? [], k = [
|
|
139
139
|
{
|
|
140
140
|
x: D.sx,
|
|
141
141
|
y: D.sy
|
|
142
142
|
},
|
|
143
|
-
...
|
|
143
|
+
...T,
|
|
144
144
|
{
|
|
145
145
|
x: D.tx,
|
|
146
146
|
y: D.ty
|
|
147
147
|
}
|
|
148
148
|
];
|
|
149
|
-
let
|
|
149
|
+
let N = 1 / 0, M = 0;
|
|
150
150
|
for (let F = 0; F < k.length - 1; F++) {
|
|
151
|
-
const
|
|
152
|
-
|
|
151
|
+
const j = me(_, E, k[F].x, k[F].y, k[F + 1].x, k[F + 1].y);
|
|
152
|
+
j < N && (N = j, M = F);
|
|
153
153
|
}
|
|
154
154
|
return M;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
let { x:
|
|
158
|
-
const F =
|
|
159
|
-
return F && (
|
|
160
|
-
x:
|
|
156
|
+
function fn(_, E, X, O, D = 24) {
|
|
157
|
+
let { x: T, y: k, w: N, h: M } = { ..._ };
|
|
158
|
+
const F = E === "nw" || E === "sw", j = E === "ne" || E === "se", tt = E === "nw" || E === "ne", ct = E === "sw" || E === "se";
|
|
159
|
+
return F && (T += X, N -= X), j && (N += X), tt && (k += O, M -= O), ct && (M += O), N < D && (F && (T = _.x + _.w - D), N = D), M < D && (tt && (k = _.y + _.h - D), M = D), {
|
|
160
|
+
x: T,
|
|
161
161
|
y: k,
|
|
162
|
-
w:
|
|
162
|
+
w: N,
|
|
163
163
|
h: M
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
function
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
169
|
-
const k =
|
|
170
|
-
for (let
|
|
166
|
+
function we(_, E, X, O, D) {
|
|
167
|
+
const T = Mt(X, O);
|
|
168
|
+
if (!T) return !1;
|
|
169
|
+
const k = Ze(_e(X.type, T, X.data.waypoints, X.data.bezierControls));
|
|
170
|
+
for (let N = 0; N < k.length - 1; N++) if (me(_, E, k[N].x, k[N].y, k[N + 1].x, k[N + 1].y) < D) return !0;
|
|
171
171
|
return !1;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const D =
|
|
175
|
-
for (let
|
|
173
|
+
function Fe(_, E, X, O) {
|
|
174
|
+
const D = X.points;
|
|
175
|
+
for (let T = 0; T < D.length - 1; T++) if (me(_, E, D[T].x, D[T].y, D[T + 1].x, D[T + 1].y) < O) return !0;
|
|
176
176
|
return !1;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
178
|
+
function Gn({ onPixiReady: _ }) {
|
|
179
|
+
const E = b(null), { pixiRef: X, readyRef: O } = Ke(E), { setViewportInternal: D, viewportReqRef: T, viewport: k, autoFocus: N, showGrid: M, showAnchors: F, gridSize: j, toolMode: tt, edgeType: ct, focusOnRect: U, setFocusOnRect: et, pendingPlacement: nt, setPendingPlacement: Tt, setContextMenu: re, beginNodeDrag: mt, endNodeDrag: Pt, presentation: Rt, editingNodeId: It, setEditingNodeId: yt } = Be(), { currentCanvas: St, selection: Gt, setSelection: lt, setDoc: J, currentCanvasId: oe, pushCanvas: qe, doc: Ie } = Ve(), zt = b(null), Nt = b(null), Bt = b(null), Kt = b(null), jt = b(null), se = b(null), ie = b(null), Ut = b(null), Wt = b(null), Lt = b(null), $t = b(null), Ct = b([]), ce = b(null), de = b(null), ut = b(null), At = b(null), ve = b({
|
|
180
180
|
time: 0,
|
|
181
181
|
wx: 0,
|
|
182
182
|
wy: 0
|
|
183
|
-
}),
|
|
183
|
+
}), Yt = b({
|
|
184
184
|
time: 0,
|
|
185
185
|
wx: 0,
|
|
186
186
|
wy: 0
|
|
187
|
-
}),
|
|
187
|
+
}), Xt = b(null), be = b({
|
|
188
188
|
x: 0,
|
|
189
189
|
y: 0
|
|
190
|
-
}),
|
|
191
|
-
...
|
|
192
|
-
nodes:
|
|
193
|
-
}, L = b(
|
|
194
|
-
L.current =
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
190
|
+
}), Me = F || Rt ? St : {
|
|
191
|
+
...St,
|
|
192
|
+
nodes: St.nodes.filter((u) => u.type !== "animAnchor")
|
|
193
|
+
}, L = b(Me);
|
|
194
|
+
L.current = Me;
|
|
195
|
+
const V = b(oe);
|
|
196
|
+
V.current = oe;
|
|
197
|
+
const Ft = b(Gt);
|
|
198
|
+
Ft.current = Gt;
|
|
199
|
+
const Re = b(Ie);
|
|
200
|
+
Re.current = Ie;
|
|
201
|
+
const _t = b(tt);
|
|
202
|
+
_t.current = tt;
|
|
203
|
+
const Zt = b(N);
|
|
204
|
+
Zt.current = N;
|
|
205
|
+
const qt = b(U);
|
|
206
|
+
qt.current = U;
|
|
207
|
+
const Se = b(ct);
|
|
208
|
+
Se.current = ct;
|
|
209
|
+
const ze = b(F);
|
|
210
|
+
ze.current = F;
|
|
211
|
+
const Et = b(Rt);
|
|
212
|
+
Et.current = Rt;
|
|
213
|
+
const ae = b(nt);
|
|
214
|
+
ae.current = nt;
|
|
215
|
+
const Ne = b(mt);
|
|
216
|
+
Ne.current = mt;
|
|
217
|
+
const le = b(Pt);
|
|
218
|
+
le.current = Pt;
|
|
219
|
+
const ft = b(null), rt = b(null), ot = b(null), dt = b(null), xt = b(null), pt = b(null), vt = b(null), ue = b(k), fe = b(0), { vmRef: $, screenToWorld: Ce } = je(X, ne((u) => {
|
|
220
|
+
ue.current = u, fe.current || (fe.current = requestAnimationFrame(() => {
|
|
221
|
+
fe.current = 0, D(ue.current);
|
|
218
222
|
}));
|
|
219
|
-
}, [D])),
|
|
220
|
-
|
|
221
|
-
const [
|
|
222
|
-
|
|
223
|
-
const
|
|
223
|
+
}, [D])), st = b(Ce);
|
|
224
|
+
st.current = Ce;
|
|
225
|
+
const [at, he] = Ge(null), [ye, xe] = Ge(null), pe = b(at);
|
|
226
|
+
pe.current = at;
|
|
227
|
+
const Jt = b(() => {
|
|
224
228
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
kind:
|
|
229
|
+
Jt.current = (u, P, A) => {
|
|
230
|
+
yt(u === "node" ? P : null), he({
|
|
231
|
+
kind: u,
|
|
228
232
|
id: P,
|
|
229
233
|
value: A
|
|
230
234
|
});
|
|
231
235
|
};
|
|
232
|
-
const
|
|
233
|
-
const P =
|
|
236
|
+
const Ee = ne((u) => {
|
|
237
|
+
const P = pe.current;
|
|
234
238
|
P && (J((A) => {
|
|
235
|
-
const W =
|
|
236
|
-
if (!
|
|
237
|
-
let Y =
|
|
239
|
+
const W = V.current, Z = A.canvases[W];
|
|
240
|
+
if (!Z) return A;
|
|
241
|
+
let Y = Z;
|
|
238
242
|
if (P.kind === "node") Y = {
|
|
239
|
-
...
|
|
240
|
-
nodes:
|
|
241
|
-
...
|
|
243
|
+
...Z,
|
|
244
|
+
nodes: Z.nodes.map((B) => B.id === P.id ? {
|
|
245
|
+
...B,
|
|
242
246
|
data: {
|
|
243
|
-
...
|
|
244
|
-
label:
|
|
247
|
+
...B.data,
|
|
248
|
+
label: u
|
|
245
249
|
}
|
|
246
|
-
} :
|
|
250
|
+
} : B)
|
|
247
251
|
};
|
|
248
252
|
else if (P.kind === "edge") Y = {
|
|
249
|
-
...
|
|
250
|
-
edges:
|
|
251
|
-
...
|
|
253
|
+
...Z,
|
|
254
|
+
edges: Z.edges.map((B) => B.id === P.id ? {
|
|
255
|
+
...B,
|
|
252
256
|
data: {
|
|
253
|
-
...
|
|
254
|
-
labelText:
|
|
257
|
+
...B.data,
|
|
258
|
+
labelText: u
|
|
255
259
|
}
|
|
256
|
-
} :
|
|
260
|
+
} : B)
|
|
257
261
|
};
|
|
258
262
|
else return A;
|
|
259
263
|
return {
|
|
@@ -263,869 +267,896 @@ function Dn({ onPixiReady: X }) {
|
|
|
263
267
|
[W]: Y
|
|
264
268
|
}
|
|
265
269
|
};
|
|
266
|
-
}),
|
|
267
|
-
}, [J,
|
|
268
|
-
|
|
269
|
-
}, [
|
|
270
|
-
|
|
271
|
-
if (!
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
}, [
|
|
275
|
-
if (!
|
|
276
|
-
const
|
|
277
|
-
if (!
|
|
270
|
+
}), he(null), yt(null), xe(null));
|
|
271
|
+
}, [J, yt]), Oe = ne(() => {
|
|
272
|
+
he(null), yt(null), xe(null);
|
|
273
|
+
}, [yt]);
|
|
274
|
+
wt(() => {
|
|
275
|
+
if (!It || pe.current?.id === It) return;
|
|
276
|
+
const u = L.current.nodes.find((P) => P.id === It);
|
|
277
|
+
u && Jt.current("node", u.id, u.data.label);
|
|
278
|
+
}, [It]), wt(() => {
|
|
279
|
+
if (!at) return;
|
|
280
|
+
const u = $.current;
|
|
281
|
+
if (!u) return;
|
|
278
282
|
const P = L.current;
|
|
279
283
|
let A = null;
|
|
280
|
-
if (
|
|
281
|
-
const W = P.nodes.find((
|
|
284
|
+
if (at.kind === "node") {
|
|
285
|
+
const W = P.nodes.find((Z) => Z.id === at.id);
|
|
282
286
|
W && (A = {
|
|
283
287
|
x: W.position.x + W.width / 2,
|
|
284
288
|
y: W.position.y + W.height / 2
|
|
285
289
|
});
|
|
286
|
-
} else if (
|
|
287
|
-
const W = P.edges.find((Y) => Y.id ===
|
|
288
|
-
for (const Y of P.nodes)
|
|
290
|
+
} else if (at.kind === "edge") {
|
|
291
|
+
const W = P.edges.find((Y) => Y.id === at.id), Z = /* @__PURE__ */ new Map();
|
|
292
|
+
for (const Y of P.nodes) Z.set(Y.id, Y);
|
|
289
293
|
if (W) {
|
|
290
|
-
const Y =
|
|
294
|
+
const Y = Mt(W, Z);
|
|
291
295
|
if (Y) {
|
|
292
|
-
const
|
|
296
|
+
const B = Ze(_e(W.type, Y, W.data.waypoints, W.data.bezierControls)), Q = B[Math.floor(B.length / 2)] ?? {
|
|
293
297
|
x: (Y.sx + Y.tx) / 2,
|
|
294
298
|
y: (Y.sy + Y.ty) / 2
|
|
295
299
|
};
|
|
296
300
|
A = {
|
|
297
|
-
x:
|
|
298
|
-
y:
|
|
301
|
+
x: Q.x,
|
|
302
|
+
y: Q.y
|
|
299
303
|
};
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
306
|
}
|
|
303
307
|
if (A) {
|
|
304
|
-
const W =
|
|
305
|
-
|
|
308
|
+
const W = u.worldToScreen(A.x, A.y);
|
|
309
|
+
xe({
|
|
306
310
|
x: W.x,
|
|
307
311
|
y: W.y
|
|
308
312
|
});
|
|
309
313
|
}
|
|
310
|
-
}, [
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
+
}, [at, $]);
|
|
315
|
+
const ke = b(0);
|
|
316
|
+
wt(() => {
|
|
317
|
+
T.current !== ke.current && (ke.current = T.current, ue.current = k, $.current?.setState(k));
|
|
314
318
|
}, [
|
|
315
319
|
k,
|
|
316
320
|
$,
|
|
317
|
-
|
|
318
|
-
]),
|
|
319
|
-
|
|
320
|
-
const Y = $.current,
|
|
321
|
-
if (!Y || !
|
|
322
|
-
const
|
|
321
|
+
T
|
|
322
|
+
]), wt(() => {
|
|
323
|
+
et((u, P, A, W, Z) => {
|
|
324
|
+
const Y = $.current, B = E.current;
|
|
325
|
+
if (!Y || !B) return;
|
|
326
|
+
const Q = B.clientWidth || 800, it = B.clientHeight || 600, bt = Math.max(0, Z?.padding ?? 60), Qt = Math.max(1, Q - bt * 2), m = Math.max(1, it - bt * 2), s = Z?.preserveZoom ? Y.state.zoom : Math.min(Qt / Math.max(A, 1), m / Math.max(W, 1), Z?.maxZoom ?? 2), l = u + A / 2, v = P + W / 2, G = Q / 2 - l * s, C = it / 2 - v * s;
|
|
323
327
|
Y.animateTo({
|
|
324
|
-
x:
|
|
325
|
-
y:
|
|
326
|
-
zoom:
|
|
327
|
-
},
|
|
328
|
+
x: G,
|
|
329
|
+
y: C,
|
|
330
|
+
zoom: s
|
|
331
|
+
}, Z?.duration ?? 350);
|
|
328
332
|
});
|
|
329
|
-
}, [
|
|
330
|
-
const
|
|
333
|
+
}, [et, $]);
|
|
334
|
+
const De = ne((u) => {
|
|
331
335
|
J((P) => {
|
|
332
|
-
const A = P.canvases[
|
|
336
|
+
const A = P.canvases[V.current];
|
|
333
337
|
return A ? {
|
|
334
338
|
...P,
|
|
335
339
|
canvases: {
|
|
336
340
|
...P.canvases,
|
|
337
|
-
[
|
|
341
|
+
[V.current]: {
|
|
338
342
|
...A,
|
|
339
|
-
lines: [...A.lines,
|
|
343
|
+
lines: [...A.lines, u]
|
|
340
344
|
}
|
|
341
345
|
}
|
|
342
346
|
} : P;
|
|
343
347
|
});
|
|
344
|
-
}, [J,
|
|
345
|
-
return
|
|
346
|
-
const
|
|
347
|
-
if (!
|
|
348
|
+
}, [J, oe]), ge = b(De);
|
|
349
|
+
return ge.current = De, wt(() => {
|
|
350
|
+
const u = X.current;
|
|
351
|
+
if (!u || u.destroyed) return;
|
|
348
352
|
let P = !1;
|
|
349
353
|
const A = () => {
|
|
350
354
|
if (P) return;
|
|
351
|
-
if (!
|
|
355
|
+
if (!O.current) {
|
|
352
356
|
setTimeout(A, 30);
|
|
353
357
|
return;
|
|
354
358
|
}
|
|
355
|
-
|
|
356
|
-
const W = new
|
|
357
|
-
W.label = "connect-line", W.visible = !1,
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const Y = new
|
|
361
|
-
Y.label = "handle-hover",
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
onLineComplete: (
|
|
367
|
-
screenToWorld: (
|
|
368
|
-
}),
|
|
369
|
-
onLineComplete: (
|
|
370
|
-
screenToWorld: (
|
|
371
|
-
}),
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
if (
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
377
|
-
$.current?.startPan(
|
|
359
|
+
zt.current = new Ue(u.app.stage, j, M), Nt.current = new $e(u.app.stage), Bt.current = new tn(u.world), Kt.current = new en(u.world), jt.current = new nn(u.world);
|
|
360
|
+
const W = new Vt();
|
|
361
|
+
W.label = "connect-line", W.visible = !1, u.world.addChild(W), xt.current = W;
|
|
362
|
+
const Z = new Vt();
|
|
363
|
+
Z.label = "transform-handles", u.app.stage.addChild(Z), Wt.current = Z;
|
|
364
|
+
const Y = new Vt();
|
|
365
|
+
Y.label = "handle-hover", u.world.addChild(Y), Lt.current = Y;
|
|
366
|
+
const B = new Vt();
|
|
367
|
+
B.label = "edge-edit-handles", u.world.addChild(B), At.current = B;
|
|
368
|
+
const Q = new Vt();
|
|
369
|
+
Q.label = "ghost-placement", Q.alpha = 0.5, u.world.addChild(Q), Xt.current = Q, $t.current = new sn(u.world), se.current = new rn(u.app.stage, u.world, {
|
|
370
|
+
onLineComplete: (m) => ge.current(m),
|
|
371
|
+
screenToWorld: (m, s) => st.current(m, s)
|
|
372
|
+
}), ie.current = new on(u.app.stage, u.world, {
|
|
373
|
+
onLineComplete: (m) => ge.current(m),
|
|
374
|
+
screenToWorld: (m, s) => st.current(m, s)
|
|
375
|
+
}), _?.(u);
|
|
376
|
+
const it = u.app.stage;
|
|
377
|
+
it.on("pointerdown", (m) => {
|
|
378
|
+
if (E.current?.focus({ preventScroll: !0 }), $.current?.isPanning || $.current?.isSpaceHeld || m.button !== 0) return;
|
|
379
|
+
const s = _t.current;
|
|
380
|
+
if (s === "pan") {
|
|
381
|
+
$.current?.startPan(m.global.x, m.global.y);
|
|
378
382
|
return;
|
|
379
383
|
}
|
|
380
|
-
if (
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
+
if (s === "freehand" || s === "line" || s === "polyline" || s === "arrow") return;
|
|
385
|
+
const l = st.current(m.global.x, m.global.y), v = L.current.nodes, G = L.current.edges, C = L.current.lines, I = Ft.current, S = m.metaKey || m.ctrlKey || m.shiftKey, q = $.current?.state.zoom ?? 1, e = ae.current;
|
|
386
|
+
if (e) {
|
|
387
|
+
const t = Je("node"), c = l.x - e.width / 2, n = l.y - e.height / 2, o = ee([{
|
|
384
388
|
id: "__ghost__",
|
|
385
|
-
type:
|
|
389
|
+
type: e.type,
|
|
386
390
|
position: {
|
|
387
|
-
x:
|
|
388
|
-
y:
|
|
391
|
+
x: c,
|
|
392
|
+
y: n
|
|
389
393
|
},
|
|
390
|
-
width:
|
|
391
|
-
height:
|
|
394
|
+
width: e.width,
|
|
395
|
+
height: e.height,
|
|
392
396
|
data: {}
|
|
393
|
-
}],
|
|
394
|
-
J((
|
|
395
|
-
const g =
|
|
396
|
-
if (!g) return
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
const
|
|
397
|
+
}], v), r = c + o.dx, d = n + o.dy;
|
|
398
|
+
J((w) => {
|
|
399
|
+
const g = w.canvases[V.current];
|
|
400
|
+
if (!g) return w;
|
|
401
|
+
const z = {};
|
|
402
|
+
e.type === "animAnchor" && (z.animIndex = dn(w));
|
|
403
|
+
const H = Math.max(0, ...g.nodes.map((h) => h.zIndex ?? 0), ...g.lines.map((h) => h.zIndex ?? 0));
|
|
400
404
|
return {
|
|
401
|
-
...
|
|
405
|
+
...w,
|
|
402
406
|
canvases: {
|
|
403
|
-
...
|
|
404
|
-
[
|
|
407
|
+
...w.canvases,
|
|
408
|
+
[V.current]: {
|
|
405
409
|
...g,
|
|
406
410
|
nodes: [...g.nodes, {
|
|
407
|
-
id:
|
|
408
|
-
type:
|
|
411
|
+
id: t,
|
|
412
|
+
type: e.type,
|
|
409
413
|
position: {
|
|
410
|
-
x:
|
|
411
|
-
y:
|
|
414
|
+
x: r,
|
|
415
|
+
y: d
|
|
412
416
|
},
|
|
413
|
-
width:
|
|
414
|
-
height:
|
|
415
|
-
zIndex:
|
|
417
|
+
width: e.width,
|
|
418
|
+
height: e.height,
|
|
419
|
+
zIndex: H + 1,
|
|
416
420
|
data: {
|
|
417
|
-
...
|
|
418
|
-
...
|
|
421
|
+
...e.data,
|
|
422
|
+
...z
|
|
419
423
|
}
|
|
420
424
|
}]
|
|
421
425
|
}
|
|
422
426
|
}
|
|
423
427
|
};
|
|
424
|
-
}),
|
|
425
|
-
nodeIds: /* @__PURE__ */ new Set([
|
|
428
|
+
}), lt({
|
|
429
|
+
nodeIds: /* @__PURE__ */ new Set([t]),
|
|
426
430
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
427
431
|
lineIds: /* @__PURE__ */ new Set()
|
|
428
|
-
})
|
|
432
|
+
}), Zt.current && window.setTimeout(() => {
|
|
433
|
+
qt.current(r, d, e.width, e.height, {
|
|
434
|
+
padding: 80,
|
|
435
|
+
preserveZoom: !0,
|
|
436
|
+
duration: 280
|
|
437
|
+
});
|
|
438
|
+
}, 0);
|
|
429
439
|
return;
|
|
430
440
|
}
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
time:
|
|
434
|
-
wx:
|
|
435
|
-
wy:
|
|
436
|
-
},
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
for (const h of
|
|
443
|
-
h.id !==
|
|
441
|
+
const i = Date.now(), y = ve.current, f = i - y.time < 350 && Math.hypot(l.x - y.wx, l.y - y.wy) < 8 / q;
|
|
442
|
+
if (ve.current = {
|
|
443
|
+
time: i,
|
|
444
|
+
wx: l.x,
|
|
445
|
+
wy: l.y
|
|
446
|
+
}, I.nodeIds.size === 1 && !S && s === "select") {
|
|
447
|
+
const t = v.find((c) => c.id === [...I.nodeIds][0]);
|
|
448
|
+
if (t) {
|
|
449
|
+
const c = Le(l, t, Math.min(10 / q, 16));
|
|
450
|
+
if (c) {
|
|
451
|
+
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), r = t.type === "geometryGroup", d = r || t.type === "flowGroup" || t.data.isGroup, w = t.position.x, g = t.position.y, z = t.width, H = t.height;
|
|
452
|
+
for (const h of v)
|
|
453
|
+
h.id !== t.id && (h.parentId === t.id ? n.set(h.id, {
|
|
444
454
|
x: h.position.x,
|
|
445
455
|
y: h.position.y,
|
|
446
456
|
w: h.width,
|
|
447
457
|
h: h.height
|
|
448
|
-
}) :
|
|
458
|
+
}) : r && h.position.x >= w && h.position.y >= g && h.position.x + h.width <= w + z && h.position.y + h.height <= g + H && n.set(h.id, {
|
|
449
459
|
x: h.position.x,
|
|
450
460
|
y: h.position.y,
|
|
451
461
|
w: h.width,
|
|
452
462
|
h: h.height
|
|
453
463
|
}));
|
|
454
|
-
if (
|
|
455
|
-
for (const h of L.current.lines) h.parentId ===
|
|
456
|
-
|
|
464
|
+
if (d)
|
|
465
|
+
for (const h of L.current.lines) h.parentId === t.id ? o.set(h.id, h.points.map((R) => ({ ...R }))) : r && h.points.length > 0 && h.points.every((R) => R.x >= w && R.x <= w + z && R.y >= g && R.y <= g + H) && o.set(h.id, h.points.map((R) => ({ ...R })));
|
|
466
|
+
pt.current = {
|
|
457
467
|
active: !0,
|
|
458
|
-
nodeId:
|
|
459
|
-
handle:
|
|
460
|
-
startWorld:
|
|
468
|
+
nodeId: t.id,
|
|
469
|
+
handle: c,
|
|
470
|
+
startWorld: l,
|
|
461
471
|
startBounds: {
|
|
462
|
-
x:
|
|
463
|
-
y:
|
|
464
|
-
w:
|
|
465
|
-
h:
|
|
472
|
+
x: t.position.x,
|
|
473
|
+
y: t.position.y,
|
|
474
|
+
w: t.width,
|
|
475
|
+
h: t.height
|
|
466
476
|
},
|
|
467
|
-
childStarts:
|
|
468
|
-
childLineStarts:
|
|
477
|
+
childStarts: n,
|
|
478
|
+
childLineStarts: o.size > 0 ? o : void 0
|
|
469
479
|
};
|
|
470
480
|
return;
|
|
471
481
|
}
|
|
472
482
|
}
|
|
473
483
|
}
|
|
474
|
-
let
|
|
475
|
-
for (let
|
|
476
|
-
|
|
484
|
+
let x = null;
|
|
485
|
+
for (let t = v.length - 1; t >= 0; t--) if (Ht(l.x, l.y, v[t])) {
|
|
486
|
+
x = v[t];
|
|
477
487
|
break;
|
|
478
488
|
}
|
|
479
|
-
if (
|
|
480
|
-
const
|
|
481
|
-
|
|
489
|
+
if (x?.parentId) {
|
|
490
|
+
const t = v.find((c) => c.id === x.parentId);
|
|
491
|
+
t && (x = t);
|
|
482
492
|
}
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
if (
|
|
486
|
-
|
|
493
|
+
if (x && (s === "select" || s === "connect")) {
|
|
494
|
+
const t = Dt(gt(x.width, x.height), x, l.x, l.y, Math.min(14 / q, 20));
|
|
495
|
+
if (t) {
|
|
496
|
+
ot.current = {
|
|
487
497
|
active: !0,
|
|
488
|
-
sourceNodeId:
|
|
489
|
-
sourceHandleId:
|
|
498
|
+
sourceNodeId: x.id,
|
|
499
|
+
sourceHandleId: t.id
|
|
490
500
|
};
|
|
491
501
|
return;
|
|
492
502
|
}
|
|
493
503
|
}
|
|
494
|
-
if ((
|
|
495
|
-
const
|
|
496
|
-
for (const
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
|
|
504
|
+
if ((s === "select" || s === "connect") && !S && I.edgeIds.size > 0) {
|
|
505
|
+
const t = /* @__PURE__ */ new Map();
|
|
506
|
+
for (const o of v) t.set(o.id, o);
|
|
507
|
+
const c = G.filter((o) => I.edgeIds.has(o.id)), n = Ae(l.x, l.y, c, t, Math.min(14 / q, 20));
|
|
508
|
+
if (n) {
|
|
509
|
+
const o = G.find((r) => r.id === n.edgeId);
|
|
510
|
+
if (o) {
|
|
511
|
+
const r = n.end === "source" ? "target" : "source";
|
|
512
|
+
dt.current = {
|
|
503
513
|
active: !0,
|
|
504
|
-
edgeId:
|
|
505
|
-
movingEnd:
|
|
506
|
-
fixedNodeId:
|
|
507
|
-
fixedHandleId:
|
|
514
|
+
edgeId: o.id,
|
|
515
|
+
movingEnd: n.end,
|
|
516
|
+
fixedNodeId: r === "source" ? o.source : o.target,
|
|
517
|
+
fixedHandleId: r === "source" ? o.sourceHandle : o.targetHandle
|
|
508
518
|
};
|
|
509
519
|
return;
|
|
510
520
|
}
|
|
511
521
|
}
|
|
512
522
|
}
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
515
|
-
for (const
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
|
|
523
|
+
if (s === "select" && I.edgeIds.size > 0 && !x) {
|
|
524
|
+
const t = /* @__PURE__ */ new Map();
|
|
525
|
+
for (const d of v) t.set(d.id, d);
|
|
526
|
+
const c = G.filter((d) => I.edgeIds.has(d.id)), n = Math.min(10 / q, 14), o = Xe(l.x, l.y, c, t, n);
|
|
527
|
+
if (o) {
|
|
528
|
+
ut.current = {
|
|
519
529
|
active: !0,
|
|
520
|
-
edgeId:
|
|
521
|
-
type:
|
|
522
|
-
index:
|
|
530
|
+
edgeId: o.edgeId,
|
|
531
|
+
type: o.controlEnd === "c1" ? "bezierC1" : "bezierC2",
|
|
532
|
+
index: o.segmentIndex
|
|
523
533
|
};
|
|
524
534
|
return;
|
|
525
535
|
}
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
if (
|
|
529
|
-
J((
|
|
530
|
-
const
|
|
531
|
-
return
|
|
532
|
-
...
|
|
536
|
+
const r = Ye(l.x, l.y, c, n);
|
|
537
|
+
if (r) {
|
|
538
|
+
if (f) {
|
|
539
|
+
J((d) => {
|
|
540
|
+
const w = d.canvases[V.current];
|
|
541
|
+
return w ? {
|
|
542
|
+
...d,
|
|
533
543
|
canvases: {
|
|
534
|
-
...
|
|
535
|
-
[
|
|
536
|
-
...
|
|
537
|
-
edges:
|
|
538
|
-
if (g.id !==
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
const
|
|
544
|
+
...d.canvases,
|
|
545
|
+
[V.current]: {
|
|
546
|
+
...w,
|
|
547
|
+
edges: w.edges.map((g) => {
|
|
548
|
+
if (g.id !== r.edgeId) return g;
|
|
549
|
+
const z = [...g.data.waypoints ?? []];
|
|
550
|
+
z.splice(r.waypointIndex, 1);
|
|
551
|
+
const H = {
|
|
542
552
|
...g.data,
|
|
543
|
-
waypoints:
|
|
553
|
+
waypoints: z.length > 0 ? z : void 0
|
|
544
554
|
};
|
|
545
555
|
if (g.type === "simplebezier" && g.data.bezierControls) {
|
|
546
556
|
const h = [...g.data.bezierControls];
|
|
547
|
-
h.splice(
|
|
557
|
+
h.splice(r.waypointIndex, 2, null), H.bezierControls = h.some((R) => R !== null) ? h : void 0;
|
|
548
558
|
}
|
|
549
559
|
return {
|
|
550
560
|
...g,
|
|
551
|
-
data:
|
|
561
|
+
data: H
|
|
552
562
|
};
|
|
553
563
|
})
|
|
554
564
|
}
|
|
555
565
|
}
|
|
556
|
-
} :
|
|
566
|
+
} : d;
|
|
557
567
|
});
|
|
558
568
|
return;
|
|
559
569
|
}
|
|
560
|
-
|
|
570
|
+
ut.current = {
|
|
561
571
|
active: !0,
|
|
562
|
-
edgeId:
|
|
572
|
+
edgeId: r.edgeId,
|
|
563
573
|
type: "waypoint",
|
|
564
|
-
index:
|
|
574
|
+
index: r.waypointIndex
|
|
565
575
|
};
|
|
566
576
|
return;
|
|
567
577
|
}
|
|
568
|
-
if (
|
|
569
|
-
for (const
|
|
570
|
-
const
|
|
571
|
-
x:
|
|
572
|
-
y:
|
|
578
|
+
if (f) {
|
|
579
|
+
for (const d of c) if (we(l.x, l.y, d, t, Math.min(8 / q, 12))) {
|
|
580
|
+
const w = un(l.x, l.y, d, t), g = {
|
|
581
|
+
x: l.x,
|
|
582
|
+
y: l.y
|
|
573
583
|
};
|
|
574
|
-
J((
|
|
575
|
-
const
|
|
576
|
-
return
|
|
577
|
-
...
|
|
584
|
+
J((z) => {
|
|
585
|
+
const H = z.canvases[V.current];
|
|
586
|
+
return H ? {
|
|
587
|
+
...z,
|
|
578
588
|
canvases: {
|
|
579
|
-
...
|
|
580
|
-
[
|
|
581
|
-
...
|
|
582
|
-
edges:
|
|
583
|
-
if (h.id !==
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
const
|
|
589
|
+
...z.canvases,
|
|
590
|
+
[V.current]: {
|
|
591
|
+
...H,
|
|
592
|
+
edges: H.edges.map((h) => {
|
|
593
|
+
if (h.id !== d.id) return h;
|
|
594
|
+
const R = [...h.data.waypoints ?? []];
|
|
595
|
+
R.splice(w, 0, g);
|
|
596
|
+
const K = {
|
|
587
597
|
...h.data,
|
|
588
|
-
waypoints:
|
|
598
|
+
waypoints: R
|
|
589
599
|
};
|
|
590
600
|
if (h.type === "simplebezier" && h.data.bezierControls) {
|
|
591
|
-
const
|
|
592
|
-
for (;
|
|
593
|
-
|
|
601
|
+
const ht = [...h.data.bezierControls];
|
|
602
|
+
for (; ht.length < (h.data.waypoints ?? []).length + 1; ) ht.push(null);
|
|
603
|
+
ht.splice(w, 1, null, null), K.bezierControls = ht;
|
|
594
604
|
}
|
|
595
605
|
return {
|
|
596
606
|
...h,
|
|
597
|
-
data:
|
|
607
|
+
data: K
|
|
598
608
|
};
|
|
599
609
|
})
|
|
600
610
|
}
|
|
601
611
|
}
|
|
602
|
-
} :
|
|
603
|
-
}),
|
|
612
|
+
} : z;
|
|
613
|
+
}), ut.current = {
|
|
604
614
|
active: !0,
|
|
605
|
-
edgeId:
|
|
615
|
+
edgeId: d.id,
|
|
606
616
|
type: "waypoint",
|
|
607
|
-
index:
|
|
617
|
+
index: w
|
|
608
618
|
};
|
|
609
619
|
return;
|
|
610
620
|
}
|
|
611
621
|
}
|
|
612
622
|
}
|
|
613
|
-
if (
|
|
614
|
-
!
|
|
615
|
-
nodeIds: /* @__PURE__ */ new Set([
|
|
623
|
+
if (x && (s === "select" || s === "connect")) {
|
|
624
|
+
!S && !I.nodeIds.has(x.id) ? lt({
|
|
625
|
+
nodeIds: /* @__PURE__ */ new Set([x.id]),
|
|
616
626
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
617
627
|
lineIds: /* @__PURE__ */ new Set()
|
|
618
|
-
}) :
|
|
619
|
-
const
|
|
620
|
-
return
|
|
621
|
-
nodeIds:
|
|
628
|
+
}) : S && lt((r) => {
|
|
629
|
+
const d = new Set(r.nodeIds);
|
|
630
|
+
return d.has(x.id) ? d.delete(x.id) : d.add(x.id), {
|
|
631
|
+
nodeIds: d,
|
|
622
632
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
623
633
|
lineIds: /* @__PURE__ */ new Set()
|
|
624
634
|
};
|
|
635
|
+
}), Zt.current && qt.current(x.position.x, x.position.y, x.width, x.height, {
|
|
636
|
+
padding: 80,
|
|
637
|
+
preserveZoom: !0,
|
|
638
|
+
duration: 280
|
|
625
639
|
});
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
const
|
|
629
|
-
for (const
|
|
630
|
-
const
|
|
631
|
-
if (!
|
|
632
|
-
const
|
|
633
|
-
for (const
|
|
634
|
-
if (!(
|
|
635
|
-
if (
|
|
636
|
-
|
|
640
|
+
const t = I.nodeIds.has(x.id) ? new Set(I.nodeIds) : /* @__PURE__ */ new Set([x.id]);
|
|
641
|
+
S && !I.nodeIds.has(x.id) && t.add(x.id);
|
|
642
|
+
const c = /* @__PURE__ */ new Set();
|
|
643
|
+
for (const r of [...t]) {
|
|
644
|
+
const d = v.find((R) => R.id === r);
|
|
645
|
+
if (!d || d.type !== "flowGroup" && d.type !== "geometryGroup" && !d.data.isGroup) continue;
|
|
646
|
+
const w = d.type === "geometryGroup", g = d.position.x, z = d.position.y, H = d.width, h = d.height;
|
|
647
|
+
for (const R of v)
|
|
648
|
+
if (!(t.has(R.id) || R.id === r)) {
|
|
649
|
+
if (R.parentId === r) {
|
|
650
|
+
t.add(R.id);
|
|
637
651
|
continue;
|
|
638
652
|
}
|
|
639
|
-
|
|
653
|
+
w && R.position.x >= g && R.position.y >= z && R.position.x + R.width <= g + H && R.position.y + R.height <= z + h && t.add(R.id);
|
|
640
654
|
}
|
|
641
|
-
for (const
|
|
642
|
-
if (
|
|
643
|
-
|
|
655
|
+
for (const R of L.current.lines) R.parentId === r && c.add(R.id);
|
|
656
|
+
if (w) for (const R of L.current.lines)
|
|
657
|
+
c.has(R.id) || R.points.length > 0 && R.points.every((K) => K.x >= g && K.x <= g + H && K.y >= z && K.y <= z + h) && c.add(R.id);
|
|
644
658
|
}
|
|
645
|
-
const
|
|
646
|
-
for (const
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
649
|
-
for (const
|
|
650
|
-
|
|
659
|
+
const n = /* @__PURE__ */ new Map();
|
|
660
|
+
for (const r of v) t.has(r.id) && n.set(r.id, { ...r.position });
|
|
661
|
+
const o = /* @__PURE__ */ new Map();
|
|
662
|
+
if (c.size > 0)
|
|
663
|
+
for (const r of L.current.lines) c.has(r.id) && o.set(r.id, r.points.map((d) => ({ ...d })));
|
|
664
|
+
ft.current = {
|
|
651
665
|
active: !0,
|
|
652
|
-
nodeIds:
|
|
653
|
-
lineIds:
|
|
654
|
-
startWorld:
|
|
655
|
-
nodeStarts:
|
|
656
|
-
linePointStarts:
|
|
657
|
-
},
|
|
666
|
+
nodeIds: t,
|
|
667
|
+
lineIds: c.size > 0 ? c : void 0,
|
|
668
|
+
startWorld: l,
|
|
669
|
+
nodeStarts: n,
|
|
670
|
+
linePointStarts: o.size > 0 ? o : void 0
|
|
671
|
+
}, Ne.current();
|
|
658
672
|
return;
|
|
659
673
|
}
|
|
660
|
-
const
|
|
661
|
-
for (const
|
|
662
|
-
const
|
|
663
|
-
for (const
|
|
664
|
-
|
|
665
|
-
const
|
|
666
|
-
return
|
|
667
|
-
...
|
|
668
|
-
edgeIds:
|
|
674
|
+
const p = /* @__PURE__ */ new Map();
|
|
675
|
+
for (const t of v) p.set(t.id, t);
|
|
676
|
+
const a = Math.min(8 / q, 12);
|
|
677
|
+
for (const t of G) if (we(l.x, l.y, t, p, a)) {
|
|
678
|
+
if (lt(S ? (c) => {
|
|
679
|
+
const n = new Set(c.edgeIds);
|
|
680
|
+
return n.has(t.id) ? n.delete(t.id) : n.add(t.id), {
|
|
681
|
+
...c,
|
|
682
|
+
edgeIds: n
|
|
669
683
|
};
|
|
670
684
|
} : {
|
|
671
685
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
672
|
-
edgeIds: /* @__PURE__ */ new Set([
|
|
686
|
+
edgeIds: /* @__PURE__ */ new Set([t.id]),
|
|
673
687
|
lineIds: /* @__PURE__ */ new Set()
|
|
674
|
-
})
|
|
688
|
+
}), Zt.current) {
|
|
689
|
+
const c = p.get(t.source), n = p.get(t.target);
|
|
690
|
+
if (c && n) {
|
|
691
|
+
const o = Math.min(c.position.x, n.position.x), r = Math.min(c.position.y, n.position.y), d = Math.max(c.position.x + c.width, n.position.x + n.width), w = Math.max(c.position.y + c.height, n.position.y + n.height);
|
|
692
|
+
qt.current(o, r, d - o, w - r, {
|
|
693
|
+
padding: 80,
|
|
694
|
+
preserveZoom: !0,
|
|
695
|
+
duration: 280
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}
|
|
675
699
|
return;
|
|
676
700
|
}
|
|
677
|
-
for (const
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
return
|
|
682
|
-
...
|
|
683
|
-
lineIds:
|
|
701
|
+
for (const t of C) if (Fe(l.x, l.y, t, a)) {
|
|
702
|
+
const c = I.lineIds.has(t.id);
|
|
703
|
+
if (S ? lt((r) => {
|
|
704
|
+
const d = new Set(r.lineIds);
|
|
705
|
+
return d.has(t.id) ? d.delete(t.id) : d.add(t.id), {
|
|
706
|
+
...r,
|
|
707
|
+
lineIds: d
|
|
684
708
|
};
|
|
685
|
-
}) :
|
|
709
|
+
}) : c || lt({
|
|
686
710
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
687
711
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
688
|
-
lineIds: /* @__PURE__ */ new Set([
|
|
689
|
-
})
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
712
|
+
lineIds: /* @__PURE__ */ new Set([t.id])
|
|
713
|
+
}), Zt.current && t.points.length > 0) {
|
|
714
|
+
const r = t.points.map((h) => h.x), d = t.points.map((h) => h.y), w = Math.min(...r), g = Math.min(...d), z = Math.max(...r), H = Math.max(...d);
|
|
715
|
+
qt.current(w, g, Math.max(1, z - w), Math.max(1, H - g), {
|
|
716
|
+
padding: 80,
|
|
717
|
+
preserveZoom: !0,
|
|
718
|
+
duration: 280
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
const n = c ? new Set(I.lineIds) : /* @__PURE__ */ new Set([t.id]), o = /* @__PURE__ */ new Map();
|
|
722
|
+
for (const r of C) n.has(r.id) && o.set(r.id, r.points.map((d) => ({ ...d })));
|
|
723
|
+
vt.current = {
|
|
693
724
|
active: !0,
|
|
694
|
-
lineIds:
|
|
695
|
-
startWorld:
|
|
696
|
-
pointStarts:
|
|
725
|
+
lineIds: n,
|
|
726
|
+
startWorld: l,
|
|
727
|
+
pointStarts: o
|
|
697
728
|
};
|
|
698
729
|
return;
|
|
699
730
|
}
|
|
700
|
-
|
|
731
|
+
S || lt({
|
|
701
732
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
702
733
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
703
734
|
lineIds: /* @__PURE__ */ new Set()
|
|
704
|
-
}),
|
|
735
|
+
}), s === "select" && (rt.current = {
|
|
705
736
|
active: !0,
|
|
706
737
|
startScreen: {
|
|
707
|
-
x:
|
|
708
|
-
y:
|
|
738
|
+
x: m.global.x,
|
|
739
|
+
y: m.global.y
|
|
709
740
|
}
|
|
710
741
|
});
|
|
711
|
-
}),
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const
|
|
717
|
-
let
|
|
718
|
-
for (let
|
|
719
|
-
const
|
|
720
|
-
|
|
742
|
+
}), it.on("globalpointermove", (m) => {
|
|
743
|
+
const s = st.current(m.global.x, m.global.y);
|
|
744
|
+
be.current = s;
|
|
745
|
+
const l = _t.current;
|
|
746
|
+
if (l === "freehand" || l === "line" || l === "polyline" || l === "arrow") return;
|
|
747
|
+
const v = L.current.nodes, G = L.current.edges, C = $.current?.state.zoom ?? 1, I = !ft.current?.active && !ot.current?.active && !pt.current?.active && !dt.current?.active && !ut.current?.active && !vt.current?.active;
|
|
748
|
+
let S = null;
|
|
749
|
+
for (let e = v.length - 1; e >= 0; e--) if (Ht(s.x, s.y, v[e])) {
|
|
750
|
+
const i = v[e];
|
|
751
|
+
S = i.parentId ? v.find((y) => y.id === i.parentId)?.id ?? i.id : i.id;
|
|
721
752
|
break;
|
|
722
753
|
}
|
|
723
|
-
if (
|
|
724
|
-
const
|
|
725
|
-
for (const
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
let
|
|
729
|
-
if (
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
const
|
|
735
|
-
|
|
736
|
-
nodeId:
|
|
737
|
-
handleId:
|
|
738
|
-
wx:
|
|
739
|
-
wy:
|
|
754
|
+
if (Ut.current = S, I && (l === "select" || l === "connect")) {
|
|
755
|
+
const e = /* @__PURE__ */ new Map();
|
|
756
|
+
for (const p of v) e.set(p.id, p);
|
|
757
|
+
const i = Ft.current, y = i.edgeIds.size > 0 ? G.filter((p) => i.edgeIds.has(p.id)) : [], f = y.length > 0 ? Ae(s.x, s.y, y, e, Math.min(12 / C, 18)) : null;
|
|
758
|
+
de.current = f;
|
|
759
|
+
let x = null;
|
|
760
|
+
if (S) {
|
|
761
|
+
const p = v.find((a) => a.id === S);
|
|
762
|
+
if (p) {
|
|
763
|
+
const a = Dt(gt(p.width, p.height), p, s.x, s.y, Math.min(14 / C, 20));
|
|
764
|
+
if (a) {
|
|
765
|
+
const t = Ot(a, p);
|
|
766
|
+
x = {
|
|
767
|
+
nodeId: p.id,
|
|
768
|
+
handleId: a.id,
|
|
769
|
+
wx: t.x,
|
|
770
|
+
wy: t.y
|
|
740
771
|
};
|
|
741
772
|
}
|
|
742
773
|
}
|
|
743
774
|
}
|
|
744
|
-
|
|
775
|
+
ce.current = x;
|
|
745
776
|
}
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
748
|
-
const
|
|
749
|
-
let
|
|
750
|
-
if (
|
|
751
|
-
else if (
|
|
752
|
-
else if (
|
|
753
|
-
const y =
|
|
754
|
-
for (const
|
|
755
|
-
const
|
|
756
|
-
(
|
|
777
|
+
const q = E.current;
|
|
778
|
+
if (q && I) {
|
|
779
|
+
const e = Ft.current;
|
|
780
|
+
let i = "";
|
|
781
|
+
if (de.current) i = "crosshair";
|
|
782
|
+
else if (ce.current) i = "crosshair";
|
|
783
|
+
else if (e.edgeIds.size > 0 && l === "select") {
|
|
784
|
+
const y = G.filter((p) => e.edgeIds.has(p.id)), f = /* @__PURE__ */ new Map();
|
|
785
|
+
for (const p of v) f.set(p.id, p);
|
|
786
|
+
const x = Math.min(10 / C, 14);
|
|
787
|
+
(Ye(s.x, s.y, y, x) || Xe(s.x, s.y, y, f, x)) && (i = "grab");
|
|
757
788
|
}
|
|
758
|
-
if (!
|
|
759
|
-
const y =
|
|
789
|
+
if (!i && e.nodeIds.size === 1 && l === "select") {
|
|
790
|
+
const y = v.find((f) => f.id === [...e.nodeIds][0]);
|
|
760
791
|
if (y) {
|
|
761
|
-
const
|
|
762
|
-
|
|
792
|
+
const f = Le(s, y, Math.min(10 / C, 16));
|
|
793
|
+
f && (i = ln[f]);
|
|
763
794
|
}
|
|
764
795
|
}
|
|
765
|
-
if (!
|
|
766
|
-
const y = L.current.lines,
|
|
767
|
-
for (const
|
|
768
|
-
|
|
796
|
+
if (!i && l === "select") {
|
|
797
|
+
const y = L.current.lines, f = Math.min(8 / C, 12);
|
|
798
|
+
for (const x of y) if (Fe(s.x, s.y, x, f)) {
|
|
799
|
+
i = "move";
|
|
769
800
|
break;
|
|
770
801
|
}
|
|
771
802
|
}
|
|
772
|
-
|
|
803
|
+
q.style.cursor = i;
|
|
773
804
|
}
|
|
774
|
-
if (
|
|
775
|
-
const
|
|
776
|
-
id:
|
|
805
|
+
if (pt.current?.active) {
|
|
806
|
+
const e = pt.current, i = s.x - e.startWorld.x, y = s.y - e.startWorld.y, f = fn(e.startBounds, e.handle, i, y), x = L.current.nodes, p = ee([{
|
|
807
|
+
id: e.nodeId,
|
|
777
808
|
type: "shapeRect",
|
|
778
809
|
position: {
|
|
779
|
-
x:
|
|
780
|
-
y:
|
|
810
|
+
x: f.x,
|
|
811
|
+
y: f.y
|
|
781
812
|
},
|
|
782
|
-
width:
|
|
783
|
-
height:
|
|
813
|
+
width: f.w,
|
|
814
|
+
height: f.h,
|
|
784
815
|
data: {}
|
|
785
|
-
}],
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
J((
|
|
789
|
-
const
|
|
790
|
-
return
|
|
791
|
-
...
|
|
816
|
+
}], x);
|
|
817
|
+
f.x += p.dx, f.y += p.dy, (e.handle === "ne" || e.handle === "se") && (f.w += p.dx), (e.handle === "se" || e.handle === "sw") && (f.h += p.dy), Ct.current = p.guides;
|
|
818
|
+
const a = e.startBounds, t = Math.max(f.w, 24), c = Math.max(f.h, 24), n = a.w > 0 ? t / a.w : 1, o = a.h > 0 ? c / a.h : 1;
|
|
819
|
+
J((r) => {
|
|
820
|
+
const d = r.canvases[V.current];
|
|
821
|
+
return d ? {
|
|
822
|
+
...r,
|
|
792
823
|
canvases: {
|
|
793
|
-
...
|
|
794
|
-
[
|
|
795
|
-
...
|
|
796
|
-
nodes:
|
|
797
|
-
if (
|
|
798
|
-
...
|
|
824
|
+
...r.canvases,
|
|
825
|
+
[V.current]: {
|
|
826
|
+
...d,
|
|
827
|
+
nodes: d.nodes.map((w) => {
|
|
828
|
+
if (w.id === e.nodeId) return {
|
|
829
|
+
...w,
|
|
799
830
|
position: {
|
|
800
|
-
x:
|
|
801
|
-
y:
|
|
831
|
+
x: f.x,
|
|
832
|
+
y: f.y
|
|
802
833
|
},
|
|
803
|
-
width:
|
|
804
|
-
height:
|
|
834
|
+
width: t,
|
|
835
|
+
height: c
|
|
805
836
|
};
|
|
806
|
-
const g =
|
|
837
|
+
const g = e.childStarts.get(w.id);
|
|
807
838
|
return g ? {
|
|
808
|
-
...
|
|
839
|
+
...w,
|
|
809
840
|
position: {
|
|
810
|
-
x:
|
|
811
|
-
y:
|
|
841
|
+
x: f.x + (g.x - a.x) * n,
|
|
842
|
+
y: f.y + (g.y - a.y) * o
|
|
812
843
|
},
|
|
813
|
-
width: Math.max(g.w *
|
|
814
|
-
height: Math.max(g.h *
|
|
815
|
-
} :
|
|
844
|
+
width: Math.max(g.w * n, 24),
|
|
845
|
+
height: Math.max(g.h * o, 24)
|
|
846
|
+
} : w;
|
|
816
847
|
}),
|
|
817
|
-
lines:
|
|
818
|
-
const g =
|
|
848
|
+
lines: e.childLineStarts ? d.lines.map((w) => {
|
|
849
|
+
const g = e.childLineStarts.get(w.id);
|
|
819
850
|
return g ? {
|
|
820
|
-
...
|
|
821
|
-
points: g.map((
|
|
822
|
-
x:
|
|
823
|
-
y:
|
|
851
|
+
...w,
|
|
852
|
+
points: g.map((z) => ({
|
|
853
|
+
x: f.x + (z.x - a.x) * n,
|
|
854
|
+
y: f.y + (z.y - a.y) * o
|
|
824
855
|
}))
|
|
825
|
-
} :
|
|
826
|
-
}) :
|
|
856
|
+
} : w;
|
|
857
|
+
}) : d.lines
|
|
827
858
|
}
|
|
828
859
|
}
|
|
829
|
-
} :
|
|
860
|
+
} : r;
|
|
830
861
|
});
|
|
831
862
|
return;
|
|
832
863
|
}
|
|
833
|
-
if (
|
|
834
|
-
const
|
|
835
|
-
for (const
|
|
836
|
-
J((
|
|
837
|
-
const
|
|
838
|
-
return
|
|
839
|
-
...
|
|
864
|
+
if (ut.current?.active) {
|
|
865
|
+
const e = ut.current, i = L.current.nodes, y = /* @__PURE__ */ new Map();
|
|
866
|
+
for (const f of i) y.set(f.id, f);
|
|
867
|
+
J((f) => {
|
|
868
|
+
const x = f.canvases[V.current];
|
|
869
|
+
return x ? {
|
|
870
|
+
...f,
|
|
840
871
|
canvases: {
|
|
841
|
-
...
|
|
842
|
-
[
|
|
843
|
-
...
|
|
844
|
-
edges:
|
|
845
|
-
if (
|
|
846
|
-
if (
|
|
847
|
-
const
|
|
848
|
-
return
|
|
849
|
-
x:
|
|
850
|
-
y:
|
|
872
|
+
...f.canvases,
|
|
873
|
+
[V.current]: {
|
|
874
|
+
...x,
|
|
875
|
+
edges: x.edges.map((p) => {
|
|
876
|
+
if (p.id !== e.edgeId) return p;
|
|
877
|
+
if (e.type === "waypoint") {
|
|
878
|
+
const kt = [...p.data.waypoints ?? []];
|
|
879
|
+
return e.index < kt.length && (kt[e.index] = {
|
|
880
|
+
x: s.x,
|
|
881
|
+
y: s.y
|
|
851
882
|
}), {
|
|
852
|
-
...
|
|
883
|
+
...p,
|
|
853
884
|
data: {
|
|
854
|
-
...
|
|
855
|
-
waypoints:
|
|
885
|
+
...p.data,
|
|
886
|
+
waypoints: kt
|
|
856
887
|
}
|
|
857
888
|
};
|
|
858
889
|
}
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
861
|
-
const
|
|
890
|
+
const a = Mt(p, y);
|
|
891
|
+
if (!a) return p;
|
|
892
|
+
const t = p.data.waypoints ?? [], c = [
|
|
862
893
|
{
|
|
863
|
-
x:
|
|
864
|
-
y:
|
|
894
|
+
x: a.sx,
|
|
895
|
+
y: a.sy
|
|
865
896
|
},
|
|
866
|
-
...
|
|
897
|
+
...t,
|
|
867
898
|
{
|
|
868
|
-
x:
|
|
869
|
-
y:
|
|
899
|
+
x: a.tx,
|
|
900
|
+
y: a.ty
|
|
870
901
|
}
|
|
871
|
-
],
|
|
872
|
-
for (;
|
|
873
|
-
const
|
|
874
|
-
if (
|
|
875
|
-
const
|
|
876
|
-
return
|
|
877
|
-
c1x:
|
|
878
|
-
c1y:
|
|
879
|
-
c2x: g?.c2x ??
|
|
880
|
-
c2y: g?.c2y ??
|
|
881
|
-
} : r
|
|
882
|
-
c1x: g?.c1x ??
|
|
883
|
-
c1y: g?.c1y ??
|
|
884
|
-
c2x:
|
|
885
|
-
c2y:
|
|
902
|
+
], n = c.length - 1, o = [...p.data.bezierControls ?? []];
|
|
903
|
+
for (; o.length < n; ) o.push(null);
|
|
904
|
+
const r = e.index;
|
|
905
|
+
if (r >= n) return p;
|
|
906
|
+
const d = c[r], w = c[r + 1], g = o[r], z = Math.hypot(w.x - d.x, w.y - d.y), H = Math.max(30, z * 0.3), h = n - 1, R = r === 0 ? d.x + a.snx * H : d.x + (w.x - d.x) * 0.4, K = r === 0 ? d.y + a.sny * H : d.y, ht = r === h ? w.x + a.tnx * H : w.x - (w.x - d.x) * 0.4, te = r === h ? w.y + a.tny * H : w.y;
|
|
907
|
+
return e.type === "bezierC1" ? o[r] = {
|
|
908
|
+
c1x: s.x,
|
|
909
|
+
c1y: s.y,
|
|
910
|
+
c2x: g?.c2x ?? ht,
|
|
911
|
+
c2y: g?.c2y ?? te
|
|
912
|
+
} : o[r] = {
|
|
913
|
+
c1x: g?.c1x ?? R,
|
|
914
|
+
c1y: g?.c1y ?? K,
|
|
915
|
+
c2x: s.x,
|
|
916
|
+
c2y: s.y
|
|
886
917
|
}, {
|
|
887
|
-
...
|
|
918
|
+
...p,
|
|
888
919
|
data: {
|
|
889
|
-
...
|
|
890
|
-
bezierControls:
|
|
920
|
+
...p.data,
|
|
921
|
+
bezierControls: o
|
|
891
922
|
}
|
|
892
923
|
};
|
|
893
924
|
})
|
|
894
925
|
}
|
|
895
926
|
}
|
|
896
|
-
} :
|
|
927
|
+
} : f;
|
|
897
928
|
});
|
|
898
929
|
return;
|
|
899
930
|
}
|
|
900
|
-
if (
|
|
901
|
-
const
|
|
902
|
-
J((
|
|
903
|
-
const
|
|
904
|
-
return
|
|
905
|
-
...
|
|
931
|
+
if (vt.current?.active) {
|
|
932
|
+
const e = vt.current, i = s.x - e.startWorld.x, y = s.y - e.startWorld.y;
|
|
933
|
+
J((f) => {
|
|
934
|
+
const x = f.canvases[V.current];
|
|
935
|
+
return x ? {
|
|
936
|
+
...f,
|
|
906
937
|
canvases: {
|
|
907
|
-
...
|
|
908
|
-
[
|
|
909
|
-
...
|
|
910
|
-
lines:
|
|
911
|
-
const
|
|
912
|
-
return
|
|
913
|
-
...
|
|
914
|
-
points:
|
|
915
|
-
x:
|
|
916
|
-
y:
|
|
938
|
+
...f.canvases,
|
|
939
|
+
[V.current]: {
|
|
940
|
+
...x,
|
|
941
|
+
lines: x.lines.map((p) => {
|
|
942
|
+
const a = e.pointStarts.get(p.id);
|
|
943
|
+
return a ? {
|
|
944
|
+
...p,
|
|
945
|
+
points: a.map((t) => ({
|
|
946
|
+
x: t.x + i,
|
|
947
|
+
y: t.y + y
|
|
917
948
|
}))
|
|
918
|
-
} :
|
|
949
|
+
} : p;
|
|
919
950
|
})
|
|
920
951
|
}
|
|
921
952
|
}
|
|
922
|
-
} :
|
|
953
|
+
} : f;
|
|
923
954
|
});
|
|
924
955
|
return;
|
|
925
956
|
}
|
|
926
|
-
if (
|
|
927
|
-
const
|
|
928
|
-
const
|
|
957
|
+
if (ft.current?.active) {
|
|
958
|
+
const e = ft.current, i = s.x - e.startWorld.x, y = s.y - e.startWorld.y, f = L.current.nodes, x = ee(f.filter((t) => e.nodeIds.has(t.id)).map((t) => {
|
|
959
|
+
const c = e.nodeStarts.get(t.id);
|
|
929
960
|
return {
|
|
930
|
-
...
|
|
961
|
+
...t,
|
|
931
962
|
position: {
|
|
932
|
-
x:
|
|
933
|
-
y:
|
|
963
|
+
x: c.x + i,
|
|
964
|
+
y: c.y + y
|
|
934
965
|
}
|
|
935
966
|
};
|
|
936
|
-
}),
|
|
937
|
-
|
|
938
|
-
const
|
|
939
|
-
return
|
|
940
|
-
...
|
|
967
|
+
}), f), p = i + x.dx, a = y + x.dy;
|
|
968
|
+
Ct.current = x.guides, J((t) => {
|
|
969
|
+
const c = t.canvases[V.current];
|
|
970
|
+
return c ? {
|
|
971
|
+
...t,
|
|
941
972
|
canvases: {
|
|
942
|
-
...
|
|
943
|
-
[
|
|
944
|
-
...
|
|
945
|
-
nodes:
|
|
946
|
-
const
|
|
947
|
-
return
|
|
948
|
-
...
|
|
973
|
+
...t.canvases,
|
|
974
|
+
[V.current]: {
|
|
975
|
+
...c,
|
|
976
|
+
nodes: c.nodes.map((n) => {
|
|
977
|
+
const o = e.nodeStarts.get(n.id);
|
|
978
|
+
return o ? {
|
|
979
|
+
...n,
|
|
949
980
|
position: {
|
|
950
|
-
x:
|
|
951
|
-
y:
|
|
981
|
+
x: o.x + p,
|
|
982
|
+
y: o.y + a
|
|
952
983
|
}
|
|
953
|
-
} :
|
|
984
|
+
} : n;
|
|
954
985
|
}),
|
|
955
|
-
lines:
|
|
956
|
-
const
|
|
957
|
-
return
|
|
958
|
-
...
|
|
959
|
-
points:
|
|
960
|
-
x:
|
|
961
|
-
y:
|
|
986
|
+
lines: e.linePointStarts ? c.lines.map((n) => {
|
|
987
|
+
const o = e.linePointStarts.get(n.id);
|
|
988
|
+
return o ? {
|
|
989
|
+
...n,
|
|
990
|
+
points: o.map((r) => ({
|
|
991
|
+
x: r.x + p,
|
|
992
|
+
y: r.y + a
|
|
962
993
|
}))
|
|
963
|
-
} :
|
|
964
|
-
}) :
|
|
994
|
+
} : n;
|
|
995
|
+
}) : c.lines
|
|
965
996
|
}
|
|
966
997
|
}
|
|
967
|
-
} :
|
|
998
|
+
} : t;
|
|
968
999
|
});
|
|
969
1000
|
return;
|
|
970
1001
|
}
|
|
971
|
-
if (
|
|
972
|
-
const
|
|
973
|
-
|
|
1002
|
+
if (rt.current?.active && Nt.current) {
|
|
1003
|
+
const e = Math.min(rt.current.startScreen.x, m.global.x), i = Math.min(rt.current.startScreen.y, m.global.y), y = Math.abs(m.global.x - rt.current.startScreen.x), f = Math.abs(m.global.y - rt.current.startScreen.y);
|
|
1004
|
+
Nt.current.showMarquee(e, i, y, f);
|
|
974
1005
|
}
|
|
975
|
-
if (
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
979
|
-
if (
|
|
980
|
-
const y =
|
|
981
|
-
let
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
984
|
-
const
|
|
985
|
-
if (
|
|
986
|
-
const
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
-
|
|
1006
|
+
if (ot.current?.active && xt.current) {
|
|
1007
|
+
const e = L.current.nodes.find((i) => i.id === ot.current.sourceNodeId);
|
|
1008
|
+
if (e) {
|
|
1009
|
+
const i = gt(e.width, e.height).find((y) => y.id === ot.current.sourceHandleId);
|
|
1010
|
+
if (i) {
|
|
1011
|
+
const y = Ot(i, e), f = y.x, x = y.y;
|
|
1012
|
+
let p = s.x, a = s.y;
|
|
1013
|
+
const t = Ut.current;
|
|
1014
|
+
if (t && t !== ot.current.sourceNodeId) {
|
|
1015
|
+
const n = L.current.nodes.find((o) => o.id === t);
|
|
1016
|
+
if (n) {
|
|
1017
|
+
const o = Dt(gt(n.width, n.height), n, s.x, s.y, 1 / 0);
|
|
1018
|
+
if (o) {
|
|
1019
|
+
const r = Ot(o, n);
|
|
1020
|
+
p = r.x, a = r.y;
|
|
990
1021
|
}
|
|
991
1022
|
}
|
|
992
1023
|
}
|
|
993
|
-
const
|
|
994
|
-
|
|
1024
|
+
const c = xt.current;
|
|
1025
|
+
c.clear(), c.moveTo(f, x).lineTo(p, a).stroke({
|
|
995
1026
|
color: 3900150,
|
|
996
1027
|
width: 2,
|
|
997
1028
|
alpha: 0.6
|
|
998
|
-
}),
|
|
1029
|
+
}), c.visible = !0;
|
|
999
1030
|
}
|
|
1000
1031
|
}
|
|
1001
1032
|
}
|
|
1002
|
-
if (
|
|
1003
|
-
const
|
|
1004
|
-
if (
|
|
1005
|
-
const y =
|
|
1006
|
-
x:
|
|
1007
|
-
y:
|
|
1008
|
-
},
|
|
1009
|
-
let
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1012
|
-
const
|
|
1013
|
-
if (
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1033
|
+
if (dt.current?.active && xt.current && !xt.current.destroyed) {
|
|
1034
|
+
const e = dt.current, i = L.current.nodes.find((y) => y.id === e.fixedNodeId);
|
|
1035
|
+
if (i) {
|
|
1036
|
+
const y = gt(i.width, i.height).find((o) => o.id === e.fixedHandleId), f = y ? Ot(y, i) : {
|
|
1037
|
+
x: i.position.x + i.width / 2,
|
|
1038
|
+
y: i.position.y + i.height / 2
|
|
1039
|
+
}, x = f.x, p = f.y;
|
|
1040
|
+
let a = s.x, t = s.y;
|
|
1041
|
+
const c = Ut.current;
|
|
1042
|
+
if (c && c !== e.fixedNodeId) {
|
|
1043
|
+
const o = L.current.nodes.find((r) => r.id === c);
|
|
1044
|
+
if (o) {
|
|
1045
|
+
const r = Dt(gt(o.width, o.height), o, s.x, s.y, 1 / 0);
|
|
1046
|
+
if (r) {
|
|
1047
|
+
const d = Ot(r, o);
|
|
1048
|
+
a = d.x, t = d.y;
|
|
1018
1049
|
}
|
|
1019
1050
|
}
|
|
1020
1051
|
}
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1052
|
+
const n = xt.current;
|
|
1053
|
+
n.clear(), n.moveTo(x, p).lineTo(a, t).stroke({
|
|
1023
1054
|
color: 16347926,
|
|
1024
1055
|
width: 2,
|
|
1025
1056
|
alpha: 0.7
|
|
1026
|
-
}),
|
|
1057
|
+
}), n.visible = !0;
|
|
1027
1058
|
}
|
|
1028
1059
|
}
|
|
1029
1060
|
});
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1061
|
+
const bt = () => {
|
|
1062
|
+
Ct.current = [];
|
|
1032
1063
|
try {
|
|
1033
|
-
|
|
1064
|
+
$t.current?.clear();
|
|
1034
1065
|
} catch {
|
|
1035
1066
|
}
|
|
1036
1067
|
try {
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1068
|
+
const m = xt.current;
|
|
1069
|
+
m && !m.destroyed && (m.clear(), m.visible = !1);
|
|
1039
1070
|
} catch {
|
|
1040
1071
|
}
|
|
1041
|
-
|
|
1072
|
+
E.current && (E.current.style.cursor = "");
|
|
1042
1073
|
};
|
|
1043
|
-
|
|
1044
|
-
if (
|
|
1045
|
-
|
|
1074
|
+
it.on("pointerup", (m) => {
|
|
1075
|
+
if (bt(), ut.current?.active) {
|
|
1076
|
+
ut.current = null;
|
|
1046
1077
|
return;
|
|
1047
1078
|
}
|
|
1048
|
-
if (
|
|
1049
|
-
|
|
1079
|
+
if (pt.current?.active) {
|
|
1080
|
+
pt.current = null;
|
|
1050
1081
|
return;
|
|
1051
1082
|
}
|
|
1052
|
-
if (
|
|
1053
|
-
|
|
1083
|
+
if (vt.current?.active) {
|
|
1084
|
+
vt.current = null;
|
|
1054
1085
|
return;
|
|
1055
1086
|
}
|
|
1056
|
-
if (
|
|
1057
|
-
const
|
|
1058
|
-
if (
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
nodeIds: new Set(
|
|
1087
|
+
if (ft.current?.active && (ft.current = null, le.current()), rt.current?.active) {
|
|
1088
|
+
const s = st.current(rt.current.startScreen.x, rt.current.startScreen.y), l = st.current(m.global.x, m.global.y), v = Math.min(s.x, l.x), G = Math.min(s.y, l.y), C = Math.abs(l.x - s.x), I = Math.abs(l.y - s.y);
|
|
1089
|
+
if (C > 4 && I > 4) {
|
|
1090
|
+
const S = L.current.nodes.filter((e) => Qe(v, G, C, I, e.position.x, e.position.y, e.width, e.height)), q = L.current.lines.filter((e) => e.points.length === 0 ? !1 : e.points.every((i) => i.x >= v && i.x <= v + C && i.y >= G && i.y <= G + I));
|
|
1091
|
+
lt({
|
|
1092
|
+
nodeIds: new Set(S.map((e) => e.id)),
|
|
1062
1093
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
1063
|
-
lineIds: new Set(
|
|
1094
|
+
lineIds: new Set(q.map((e) => e.id))
|
|
1064
1095
|
});
|
|
1065
1096
|
}
|
|
1066
|
-
|
|
1097
|
+
rt.current = null, Nt.current?.hideMarquee();
|
|
1067
1098
|
}
|
|
1068
|
-
if (
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
const
|
|
1072
|
-
let
|
|
1073
|
-
for (let
|
|
1074
|
-
|
|
1099
|
+
if (dt.current?.active) {
|
|
1100
|
+
const s = dt.current.edgeId, l = dt.current.movingEnd, v = dt.current.fixedNodeId;
|
|
1101
|
+
dt.current = null;
|
|
1102
|
+
const G = st.current(m.global.x, m.global.y), C = L.current.nodes;
|
|
1103
|
+
let I = null;
|
|
1104
|
+
for (let S = C.length - 1; S >= 0; S--) if (Ht(G.x, G.y, C[S]) && C[S].id !== v) {
|
|
1105
|
+
I = C[S];
|
|
1075
1106
|
break;
|
|
1076
1107
|
}
|
|
1077
|
-
if (
|
|
1078
|
-
const
|
|
1079
|
-
J((
|
|
1080
|
-
const
|
|
1081
|
-
return
|
|
1082
|
-
...
|
|
1108
|
+
if (I) {
|
|
1109
|
+
const S = I.id, q = Dt(gt(I.width, I.height), I, G.x, G.y, 1 / 0)?.id;
|
|
1110
|
+
J((e) => {
|
|
1111
|
+
const i = e.canvases[V.current];
|
|
1112
|
+
return i ? {
|
|
1113
|
+
...e,
|
|
1083
1114
|
canvases: {
|
|
1084
|
-
...
|
|
1085
|
-
[
|
|
1086
|
-
...
|
|
1087
|
-
edges:
|
|
1115
|
+
...e.canvases,
|
|
1116
|
+
[V.current]: {
|
|
1117
|
+
...i,
|
|
1118
|
+
edges: i.edges.map((y) => y.id !== s ? y : l === "source" ? {
|
|
1088
1119
|
...y,
|
|
1089
|
-
source:
|
|
1090
|
-
sourceHandle:
|
|
1120
|
+
source: S,
|
|
1121
|
+
sourceHandle: q
|
|
1091
1122
|
} : {
|
|
1092
1123
|
...y,
|
|
1093
|
-
target:
|
|
1094
|
-
targetHandle:
|
|
1124
|
+
target: S,
|
|
1125
|
+
targetHandle: q
|
|
1095
1126
|
})
|
|
1096
1127
|
}
|
|
1097
1128
|
}
|
|
1098
|
-
} :
|
|
1129
|
+
} : e;
|
|
1099
1130
|
});
|
|
1100
1131
|
}
|
|
1101
1132
|
return;
|
|
1102
1133
|
}
|
|
1103
|
-
if (
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
const
|
|
1107
|
-
let
|
|
1108
|
-
for (let
|
|
1109
|
-
|
|
1134
|
+
if (ot.current?.active) {
|
|
1135
|
+
const s = ot.current.sourceNodeId, l = ot.current.sourceHandleId;
|
|
1136
|
+
ot.current = null;
|
|
1137
|
+
const v = st.current(m.global.x, m.global.y), G = L.current.nodes;
|
|
1138
|
+
let C = null;
|
|
1139
|
+
for (let I = G.length - 1; I >= 0; I--) if (Ht(v.x, v.y, G[I]) && G[I].id !== s) {
|
|
1140
|
+
C = G[I];
|
|
1110
1141
|
break;
|
|
1111
1142
|
}
|
|
1112
|
-
if (
|
|
1113
|
-
const
|
|
1114
|
-
J((
|
|
1115
|
-
const y =
|
|
1116
|
-
return !y || y.edges.some((
|
|
1117
|
-
...
|
|
1143
|
+
if (C) {
|
|
1144
|
+
const I = C.id, S = Dt(gt(C.width, C.height), C, v.x, v.y, 1 / 0)?.id, q = `edge_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`, e = Se.current;
|
|
1145
|
+
J((i) => {
|
|
1146
|
+
const y = i.canvases[V.current];
|
|
1147
|
+
return !y || y.edges.some((f) => f.source === s && f.target === I && f.sourceHandle === l && f.targetHandle === S) ? i : {
|
|
1148
|
+
...i,
|
|
1118
1149
|
canvases: {
|
|
1119
|
-
...
|
|
1120
|
-
[
|
|
1150
|
+
...i.canvases,
|
|
1151
|
+
[V.current]: {
|
|
1121
1152
|
...y,
|
|
1122
1153
|
edges: [...y.edges, {
|
|
1123
|
-
id:
|
|
1124
|
-
source:
|
|
1125
|
-
target:
|
|
1126
|
-
sourceHandle:
|
|
1127
|
-
targetHandle:
|
|
1128
|
-
type:
|
|
1154
|
+
id: q,
|
|
1155
|
+
source: s,
|
|
1156
|
+
target: I,
|
|
1157
|
+
sourceHandle: l,
|
|
1158
|
+
targetHandle: S,
|
|
1159
|
+
type: e,
|
|
1129
1160
|
data: {
|
|
1130
1161
|
strokeColor: "#374151",
|
|
1131
1162
|
strokeWidth: 2,
|
|
@@ -1139,49 +1170,49 @@ function Dn({ onPixiReady: X }) {
|
|
|
1139
1170
|
});
|
|
1140
1171
|
}
|
|
1141
1172
|
}
|
|
1142
|
-
}),
|
|
1143
|
-
|
|
1144
|
-
}),
|
|
1145
|
-
if (
|
|
1146
|
-
const
|
|
1147
|
-
let
|
|
1148
|
-
for (let
|
|
1149
|
-
|
|
1173
|
+
}), it.on("pointerupoutside", () => {
|
|
1174
|
+
bt(), ft.current?.active && le.current(), ft.current = null, pt.current = null, rt.current = null, dt.current = null, ot.current = null, ut.current = null, vt.current = null, Nt.current?.hideMarquee();
|
|
1175
|
+
}), it.on("rightclick", (m) => {
|
|
1176
|
+
if (m.preventDefault?.(), $.current?.didRightPan) return;
|
|
1177
|
+
const s = st.current(m.global.x, m.global.y), l = L.current.nodes;
|
|
1178
|
+
let v = null;
|
|
1179
|
+
for (let S = l.length - 1; S >= 0; S--) if (Ht(s.x, s.y, l[S])) {
|
|
1180
|
+
v = l[S].id;
|
|
1150
1181
|
break;
|
|
1151
1182
|
}
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
x:
|
|
1155
|
-
y:
|
|
1156
|
-
nodeId:
|
|
1183
|
+
const G = m.nativeEvent, C = G?.clientX ?? m.global.x, I = G?.clientY ?? m.global.y;
|
|
1184
|
+
re({
|
|
1185
|
+
x: C,
|
|
1186
|
+
y: I,
|
|
1187
|
+
nodeId: v
|
|
1157
1188
|
});
|
|
1158
|
-
}),
|
|
1159
|
-
if (
|
|
1160
|
-
const
|
|
1161
|
-
if (
|
|
1162
|
-
const
|
|
1163
|
-
for (let
|
|
1164
|
-
const y =
|
|
1165
|
-
if (
|
|
1166
|
-
|
|
1189
|
+
}), it.on("pointertap", (m) => {
|
|
1190
|
+
if (m.button !== 0) return;
|
|
1191
|
+
const s = Date.now(), l = st.current(m.global.x, m.global.y), v = Yt.current, G = l.x - v.wx, C = l.y - v.wy;
|
|
1192
|
+
if (s - v.time < 400 && Math.abs(G) < 10 && Math.abs(C) < 10) {
|
|
1193
|
+
const I = L.current.nodes;
|
|
1194
|
+
for (let i = I.length - 1; i >= 0; i--) if (Ht(l.x, l.y, I[i])) {
|
|
1195
|
+
const y = I[i], f = y.data.childCanvasId;
|
|
1196
|
+
if (f) {
|
|
1197
|
+
qe(f), Yt.current = {
|
|
1167
1198
|
time: 0,
|
|
1168
1199
|
wx: 0,
|
|
1169
1200
|
wy: 0
|
|
1170
1201
|
};
|
|
1171
1202
|
return;
|
|
1172
1203
|
}
|
|
1173
|
-
|
|
1204
|
+
Jt.current("node", y.id, y.data.label ?? ""), Yt.current = {
|
|
1174
1205
|
time: 0,
|
|
1175
1206
|
wx: 0,
|
|
1176
1207
|
wy: 0
|
|
1177
1208
|
};
|
|
1178
1209
|
return;
|
|
1179
1210
|
}
|
|
1180
|
-
const
|
|
1181
|
-
for (const
|
|
1182
|
-
const
|
|
1183
|
-
for (let
|
|
1184
|
-
|
|
1211
|
+
const S = L.current.edges, q = /* @__PURE__ */ new Map();
|
|
1212
|
+
for (const i of I) q.set(i.id, i);
|
|
1213
|
+
const e = $.current?.state.zoom ?? 1;
|
|
1214
|
+
for (let i = S.length - 1; i >= 0; i--) if (we(l.x, l.y, S[i], q, Math.min(8 / e, 12))) {
|
|
1215
|
+
Jt.current("edge", S[i].id, S[i].data.labelText ?? ""), Yt.current = {
|
|
1185
1216
|
time: 0,
|
|
1186
1217
|
wx: 0,
|
|
1187
1218
|
wy: 0
|
|
@@ -1189,161 +1220,161 @@ function Dn({ onPixiReady: X }) {
|
|
|
1189
1220
|
return;
|
|
1190
1221
|
}
|
|
1191
1222
|
}
|
|
1192
|
-
|
|
1193
|
-
time:
|
|
1194
|
-
wx:
|
|
1195
|
-
wy:
|
|
1223
|
+
Yt.current = {
|
|
1224
|
+
time: s,
|
|
1225
|
+
wx: l.x,
|
|
1226
|
+
wy: l.y
|
|
1196
1227
|
};
|
|
1197
1228
|
});
|
|
1198
|
-
let
|
|
1199
|
-
|
|
1200
|
-
if (
|
|
1201
|
-
const
|
|
1229
|
+
let Qt = !1;
|
|
1230
|
+
u.app.ticker.add((m) => {
|
|
1231
|
+
if (u.destroyed) return;
|
|
1232
|
+
const s = m.deltaMS, l = u.app.screen, v = $.current?.state ?? {
|
|
1202
1233
|
x: 0,
|
|
1203
1234
|
y: 0,
|
|
1204
1235
|
zoom: 1
|
|
1205
1236
|
};
|
|
1206
|
-
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1213
|
-
showAnchors:
|
|
1214
|
-
presentation:
|
|
1215
|
-
presentationAnchorId:
|
|
1216
|
-
presentationAnchorVisible:
|
|
1237
|
+
zt.current?.update(v, l.width, l.height);
|
|
1238
|
+
const G = $.current?.isPanning ?? !1;
|
|
1239
|
+
G !== Qt && (Qt = G, E.current && (E.current.style.cursor = G ? "grabbing" : ""));
|
|
1240
|
+
const C = L.current, I = Ft.current, S = cn(Re.current), q = /* @__PURE__ */ new Map();
|
|
1241
|
+
S.forEach((a, t) => q.set(a.node.id, t + 1)), Bt.current?.advanceAnimation(s);
|
|
1242
|
+
const e = Et.current ? S[Et.current.current] : void 0;
|
|
1243
|
+
Bt.current?.sync(C.nodes, I.nodeIds, Ut.current, q, {
|
|
1244
|
+
showAnchors: ze.current,
|
|
1245
|
+
presentation: Et.current !== null,
|
|
1246
|
+
presentationAnchorId: e?.node.id,
|
|
1247
|
+
presentationAnchorVisible: Et.current?.showAnchor ?? !1
|
|
1217
1248
|
});
|
|
1218
|
-
const
|
|
1219
|
-
for (const
|
|
1220
|
-
|
|
1221
|
-
const y =
|
|
1249
|
+
const i = /* @__PURE__ */ new Map();
|
|
1250
|
+
for (const a of C.nodes) i.set(a.id, a);
|
|
1251
|
+
Kt.current?.advanceAnimation(s), Kt.current?.sync(C.edges, i, I.edgeIds, null, { presentation: Et.current !== null }), jt.current?.advanceAnimation(s), jt.current?.sync(C.lines, I.lineIds), $t.current?.update(Ct.current, l.width, l.height, v);
|
|
1252
|
+
const y = Lt.current;
|
|
1222
1253
|
if (y) {
|
|
1223
1254
|
y.clear();
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1255
|
+
const a = ce.current;
|
|
1256
|
+
a && (y.circle(a.wx, a.wy, 10).fill({
|
|
1226
1257
|
color: 3900150,
|
|
1227
1258
|
alpha: 0.12
|
|
1228
1259
|
}).stroke({
|
|
1229
1260
|
color: 3900150,
|
|
1230
1261
|
width: 1.5,
|
|
1231
1262
|
alpha: 0.5
|
|
1232
|
-
}), y.circle(
|
|
1263
|
+
}), y.circle(a.wx, a.wy, 4).fill({
|
|
1233
1264
|
color: 3900150,
|
|
1234
1265
|
alpha: 0.9
|
|
1235
1266
|
}));
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1267
|
+
const t = de.current;
|
|
1268
|
+
t && !a && (y.circle(t.worldX, t.worldY, 10).fill({
|
|
1238
1269
|
color: 16347926,
|
|
1239
1270
|
alpha: 0.12
|
|
1240
1271
|
}).stroke({
|
|
1241
1272
|
color: 16347926,
|
|
1242
1273
|
width: 1.5,
|
|
1243
1274
|
alpha: 0.5
|
|
1244
|
-
}), y.circle(
|
|
1275
|
+
}), y.circle(t.worldX, t.worldY, 4).fill({
|
|
1245
1276
|
color: 16347926,
|
|
1246
1277
|
alpha: 0.9
|
|
1247
1278
|
}));
|
|
1248
1279
|
}
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1251
|
-
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
const
|
|
1280
|
+
const f = Xt.current;
|
|
1281
|
+
if (f) {
|
|
1282
|
+
f.clear();
|
|
1283
|
+
const a = ae.current;
|
|
1284
|
+
if (a) {
|
|
1285
|
+
const t = be.current, c = t.x - a.width / 2, n = t.y - a.height / 2, o = ee([{
|
|
1255
1286
|
id: "__ghost__",
|
|
1256
|
-
type:
|
|
1287
|
+
type: a.type,
|
|
1257
1288
|
position: {
|
|
1258
|
-
x:
|
|
1259
|
-
y:
|
|
1289
|
+
x: c,
|
|
1290
|
+
y: n
|
|
1260
1291
|
},
|
|
1261
|
-
width:
|
|
1262
|
-
height:
|
|
1292
|
+
width: a.width,
|
|
1293
|
+
height: a.height,
|
|
1263
1294
|
data: {}
|
|
1264
|
-
}],
|
|
1265
|
-
|
|
1266
|
-
width:
|
|
1267
|
-
height:
|
|
1295
|
+
}], C.nodes);
|
|
1296
|
+
Ct.current = o.guides, f.position.set(c + o.dx, n + o.dy), (Pe[a.type] ?? Pe.shapeRect)(f, {
|
|
1297
|
+
width: a.width,
|
|
1298
|
+
height: a.height,
|
|
1268
1299
|
fill: "#3b82f6",
|
|
1269
1300
|
stroke: "#3b82f6",
|
|
1270
1301
|
strokeWidth: 1.5,
|
|
1271
|
-
borderStyle:
|
|
1302
|
+
borderStyle: a.data.borderStyle
|
|
1272
1303
|
});
|
|
1273
1304
|
} else
|
|
1274
|
-
|
|
1305
|
+
f.position.set(0, 0), !ft.current?.active && !pt.current?.active && (Ct.current = []);
|
|
1275
1306
|
}
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1278
|
-
const
|
|
1279
|
-
for (const
|
|
1280
|
-
if (!
|
|
1281
|
-
const
|
|
1282
|
-
if (
|
|
1307
|
+
const x = At.current;
|
|
1308
|
+
if (x && (x.clear(), I.edgeIds.size > 0 && _t.current === "select")) {
|
|
1309
|
+
const a = 1 / v.zoom;
|
|
1310
|
+
for (const t of C.edges) {
|
|
1311
|
+
if (!I.edgeIds.has(t.id)) continue;
|
|
1312
|
+
const c = t.data.waypoints;
|
|
1313
|
+
if (c) for (const n of c) x.circle(n.x, n.y, 5 * a).fill({ color: 16777215 }).stroke({
|
|
1283
1314
|
color: 3900150,
|
|
1284
|
-
width: 1.5 *
|
|
1315
|
+
width: 1.5 * a
|
|
1285
1316
|
});
|
|
1286
|
-
if (
|
|
1287
|
-
const
|
|
1288
|
-
if (!
|
|
1289
|
-
const
|
|
1317
|
+
if (t.type === "simplebezier") {
|
|
1318
|
+
const n = Mt(t, i);
|
|
1319
|
+
if (!n) continue;
|
|
1320
|
+
const o = c ?? [], r = [
|
|
1290
1321
|
{
|
|
1291
|
-
x:
|
|
1292
|
-
y:
|
|
1322
|
+
x: n.sx,
|
|
1323
|
+
y: n.sy
|
|
1293
1324
|
},
|
|
1294
|
-
...
|
|
1325
|
+
...o,
|
|
1295
1326
|
{
|
|
1296
|
-
x:
|
|
1297
|
-
y:
|
|
1327
|
+
x: n.tx,
|
|
1328
|
+
y: n.ty
|
|
1298
1329
|
}
|
|
1299
|
-
],
|
|
1300
|
-
for (let g = 0; g <=
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1330
|
+
], d = t.data.bezierControls, w = r.length - 2;
|
|
1331
|
+
for (let g = 0; g <= w; g++) {
|
|
1332
|
+
const z = r[g], H = r[g + 1], h = d?.[g], R = Math.hypot(H.x - z.x, H.y - z.y), K = Math.max(30, R * 0.3), ht = h?.c1x ?? (g === 0 ? z.x + n.snx * K : z.x + (H.x - z.x) * 0.4), te = h?.c1y ?? (g === 0 ? z.y + n.sny * K : z.y), kt = h?.c2x ?? (g === w ? H.x + n.tnx * K : H.x - (H.x - z.x) * 0.4), He = h?.c2y ?? (g === w ? H.y + n.tny * K : H.y);
|
|
1333
|
+
x.moveTo(z.x, z.y).lineTo(ht, te).stroke({
|
|
1303
1334
|
color: 10265519,
|
|
1304
|
-
width: 1 *
|
|
1305
|
-
}),
|
|
1335
|
+
width: 1 * a
|
|
1336
|
+
}), x.moveTo(H.x, H.y).lineTo(kt, He).stroke({
|
|
1306
1337
|
color: 10265519,
|
|
1307
|
-
width: 1 *
|
|
1338
|
+
width: 1 * a
|
|
1308
1339
|
});
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1340
|
+
const Te = 4 * a;
|
|
1341
|
+
x.circle(ht, te, Te).fill({ color: 16777215 }).stroke({
|
|
1311
1342
|
color: 3900150,
|
|
1312
|
-
width: 1.5 *
|
|
1313
|
-
}),
|
|
1343
|
+
width: 1.5 * a
|
|
1344
|
+
}), x.circle(kt, He, Te).fill({ color: 16777215 }).stroke({
|
|
1314
1345
|
color: 3900150,
|
|
1315
|
-
width: 1.5 *
|
|
1346
|
+
width: 1.5 * a
|
|
1316
1347
|
});
|
|
1317
1348
|
}
|
|
1318
1349
|
}
|
|
1319
1350
|
}
|
|
1320
1351
|
}
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1323
|
-
const
|
|
1324
|
-
if (
|
|
1325
|
-
const
|
|
1326
|
-
|
|
1352
|
+
const p = Wt.current;
|
|
1353
|
+
if (p && (p.clear(), I.nodeIds.size === 1 && _t.current === "select")) {
|
|
1354
|
+
const a = [...I.nodeIds][0], t = C.nodes.find((c) => c.id === a);
|
|
1355
|
+
if (t) {
|
|
1356
|
+
const c = v.zoom, n = t.position.x * c + v.x, o = t.position.y * c + v.y, r = t.width * c, d = t.height * c;
|
|
1357
|
+
p.rect(n, o, r, d).stroke({
|
|
1327
1358
|
color: 3900150,
|
|
1328
1359
|
width: 1.5
|
|
1329
1360
|
});
|
|
1330
|
-
const
|
|
1331
|
-
[
|
|
1332
|
-
[
|
|
1333
|
-
[
|
|
1334
|
-
[
|
|
1361
|
+
const w = 7, g = w / 2, z = [
|
|
1362
|
+
[n, o],
|
|
1363
|
+
[n + r, o],
|
|
1364
|
+
[n + r, o + d],
|
|
1365
|
+
[n, o + d]
|
|
1335
1366
|
];
|
|
1336
|
-
for (const [
|
|
1367
|
+
for (const [R, K] of z) p.rect(R - g, K - g, w, w).fill({ color: 16777215 }).stroke({
|
|
1337
1368
|
color: 3900150,
|
|
1338
1369
|
width: 1.5
|
|
1339
1370
|
});
|
|
1340
|
-
const
|
|
1341
|
-
[
|
|
1342
|
-
[
|
|
1343
|
-
[
|
|
1344
|
-
[
|
|
1371
|
+
const H = 4, h = [
|
|
1372
|
+
[n + r / 2, o],
|
|
1373
|
+
[n + r, o + d / 2],
|
|
1374
|
+
[n + r / 2, o + d],
|
|
1375
|
+
[n, o + d / 2]
|
|
1345
1376
|
];
|
|
1346
|
-
for (const [
|
|
1377
|
+
for (const [R, K] of h) p.circle(R, K, H).fill({
|
|
1347
1378
|
color: 3900150,
|
|
1348
1379
|
alpha: 0.9
|
|
1349
1380
|
});
|
|
@@ -1352,18 +1383,18 @@ function Dn({ onPixiReady: X }) {
|
|
|
1352
1383
|
});
|
|
1353
1384
|
};
|
|
1354
1385
|
return A(), () => {
|
|
1355
|
-
if (P = !0,
|
|
1356
|
-
|
|
1386
|
+
if (P = !0, u && !u.destroyed) try {
|
|
1387
|
+
u.app.stage.removeAllListeners();
|
|
1357
1388
|
} catch {
|
|
1358
1389
|
}
|
|
1359
|
-
|
|
1390
|
+
zt.current?.destroy(), Nt.current?.destroy(), Bt.current?.destroy(), Kt.current?.destroy(), jt.current?.destroy(), se.current?.destroy(), ie.current?.destroy(), xt.current?.destroy(), Wt.current && (Wt.current.destroy(), Wt.current = null), Lt.current && (Lt.current.destroy(), Lt.current = null), At.current && (At.current.destroy(), At.current = null), Xt.current && (Xt.current.destroy(), Xt.current = null), $t.current?.destroy();
|
|
1360
1391
|
};
|
|
1361
|
-
}, [
|
|
1362
|
-
const
|
|
1363
|
-
if (!(!
|
|
1364
|
-
switch (
|
|
1392
|
+
}, [X.current]), wt(() => {
|
|
1393
|
+
const u = se.current, P = ie.current;
|
|
1394
|
+
if (!(!u || !P))
|
|
1395
|
+
switch (u.deactivate(), P.deactivate(), tt) {
|
|
1365
1396
|
case "freehand":
|
|
1366
|
-
|
|
1397
|
+
u.activate();
|
|
1367
1398
|
break;
|
|
1368
1399
|
case "line":
|
|
1369
1400
|
P.activate("straight");
|
|
@@ -1375,48 +1406,48 @@ function Dn({ onPixiReady: X }) {
|
|
|
1375
1406
|
P.activate("arrow");
|
|
1376
1407
|
break;
|
|
1377
1408
|
}
|
|
1378
|
-
}, [
|
|
1379
|
-
|
|
1380
|
-
}, [
|
|
1381
|
-
const
|
|
1382
|
-
if (!
|
|
1409
|
+
}, [tt]), wt(() => {
|
|
1410
|
+
zt.current && (zt.current.visible = M, zt.current.gridSize = j);
|
|
1411
|
+
}, [M, j]), wt(() => {
|
|
1412
|
+
const u = E.current;
|
|
1413
|
+
if (!u) return;
|
|
1383
1414
|
const P = 1e-3, A = (W) => {
|
|
1384
1415
|
W.preventDefault();
|
|
1385
|
-
const
|
|
1386
|
-
if (!
|
|
1387
|
-
const Y =
|
|
1388
|
-
|
|
1416
|
+
const Z = $.current;
|
|
1417
|
+
if (!Z) return;
|
|
1418
|
+
const Y = u.getBoundingClientRect(), B = W.clientX - Y.left, Q = W.clientY - Y.top, it = W.ctrlKey ? 3 : 1, bt = -W.deltaY * P * it;
|
|
1419
|
+
Z.zoomAt(B, Q, 1 + bt);
|
|
1389
1420
|
};
|
|
1390
|
-
return
|
|
1391
|
-
}, [$]), /* @__PURE__ */
|
|
1421
|
+
return u.addEventListener("wheel", A, { passive: !1 }), () => u.removeEventListener("wheel", A);
|
|
1422
|
+
}, [$]), /* @__PURE__ */ an("div", {
|
|
1392
1423
|
style: {
|
|
1393
1424
|
position: "relative",
|
|
1394
1425
|
width: "100%",
|
|
1395
1426
|
height: "100%"
|
|
1396
1427
|
},
|
|
1397
|
-
children: [/* @__PURE__ */
|
|
1398
|
-
ref:
|
|
1428
|
+
children: [/* @__PURE__ */ We("div", {
|
|
1429
|
+
ref: E,
|
|
1399
1430
|
className: "flow-canvas-wrapper",
|
|
1400
1431
|
tabIndex: -1,
|
|
1401
|
-
onContextMenu: (
|
|
1402
|
-
}),
|
|
1432
|
+
onContextMenu: (u) => u.preventDefault()
|
|
1433
|
+
}), at && ye && /* @__PURE__ */ We("input", {
|
|
1403
1434
|
className: "flow-label-editor",
|
|
1404
1435
|
autoFocus: !0,
|
|
1405
|
-
defaultValue:
|
|
1436
|
+
defaultValue: at.value,
|
|
1406
1437
|
style: {
|
|
1407
|
-
left:
|
|
1408
|
-
top:
|
|
1438
|
+
left: ye.x,
|
|
1439
|
+
top: ye.y
|
|
1409
1440
|
},
|
|
1410
|
-
onKeyDown: (
|
|
1411
|
-
|
|
1441
|
+
onKeyDown: (u) => {
|
|
1442
|
+
u.key === "Enter" ? (u.preventDefault(), Ee(u.target.value)) : u.key === "Escape" && (u.preventDefault(), Oe()), u.stopPropagation();
|
|
1412
1443
|
},
|
|
1413
|
-
onBlur: (
|
|
1414
|
-
onPointerDown: (
|
|
1444
|
+
onBlur: (u) => Ee(u.target.value),
|
|
1445
|
+
onPointerDown: (u) => u.stopPropagation()
|
|
1415
1446
|
})]
|
|
1416
1447
|
});
|
|
1417
1448
|
}
|
|
1418
1449
|
export {
|
|
1419
|
-
|
|
1450
|
+
Gn as default
|
|
1420
1451
|
};
|
|
1421
1452
|
|
|
1422
1453
|
//# sourceMappingURL=FlowCanvas.js.map
|