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