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