dishui 0.0.60 → 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.
@@ -5,685 +5,687 @@ import { useViewport as zn } from "./hooks/useViewport.js";
5
5
  import { GridRenderer as En } from "./canvas/GridRenderer.js";
6
6
  import { SelectionOverlay as Cn } from "./canvas/SelectionOverlay.js";
7
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";
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
10
  import { NodeRenderer as Tn } from "./nodes/NodeRenderer.js";
11
11
  import { buildEdgePath as wn, linearizeSegments as mn, resolveEdgeEndpoints as St } from "./edges/edgePaths.js";
12
12
  import { EdgeRenderer as Dn } from "./edges/EdgeRenderer.js";
13
13
  import { LineRenderer as Hn } from "./lines/LineRenderer.js";
14
14
  import { FreehandTool as Pn } from "./lines/FreehandTool.js";
15
15
  import { GeometricLineTool as An } from "./lines/GeometricLineTool.js";
16
- import { computeAlignmentSnap as xe } from "./hooks/useAlignmentGuides.js";
16
+ import { computeAlignmentSnap as me } from "./hooks/useAlignmentGuides.js";
17
17
  import { AlignmentGuidesRenderer as Ln } from "./canvas/AlignmentGuides.js";
18
18
  import { getDocumentSlides as Gn, nextAnimIndex as Wn } from "./nodes/animAnchors.js";
19
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";
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
23
  var Xn = {
24
24
  nw: "nwse-resize",
25
25
  ne: "nesw-resize",
26
26
  se: "nwse-resize",
27
27
  sw: "nesw-resize"
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);
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);
31
31
  }
32
32
  var vn = 26;
33
- function fn(A, M) {
33
+ function fn(L, M) {
34
34
  return {
35
- x: A.position.x + A.width / 2,
36
- y: A.position.y - vn / M
35
+ x: L.position.x + L.width / 2,
36
+ y: L.position.y - vn / M
37
37
  };
38
38
  }
39
- function Vt(A, M, D) {
40
- return !D || !(M > 0) ? A : Math.round(A / M) * M;
39
+ function Kt(L, M, H) {
40
+ return !H || !(M > 0) ? L : Math.round(L / M) * M;
41
41
  }
42
- function hn(A, M, D) {
43
- const { x: U, y: T } = M.position, G = M.width, P = M.height, C = [
42
+ function hn(L, M, H) {
43
+ const { x: U, y: D } = M.position, W = M.width, A = M.height, N = [
44
44
  [
45
45
  "nw",
46
46
  U,
47
- T
47
+ D
48
48
  ],
49
49
  [
50
50
  "ne",
51
- U + G,
52
- T
51
+ U + W,
52
+ D
53
53
  ],
54
54
  [
55
55
  "se",
56
- U + G,
57
- T + P
56
+ U + W,
57
+ D + A
58
58
  ],
59
59
  [
60
60
  "sw",
61
61
  U,
62
- T + P
62
+ D + A
63
63
  ]
64
64
  ];
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);
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);
69
69
  }
70
- return z;
70
+ return E;
71
71
  }
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 = {
79
- edgeId: C.id,
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,
80
80
  end: "source",
81
- worldX: z.sx,
82
- worldY: z.sy
81
+ worldX: E.sx,
82
+ worldY: E.sy
83
83
  });
84
- const j = Math.hypot(A - z.tx, M - z.ty);
85
- j < P && (P = j, G = {
86
- edgeId: C.id,
84
+ const j = Math.hypot(L - E.tx, M - E.ty);
85
+ j < A && (A = j, W = {
86
+ edgeId: N.id,
87
87
  end: "target",
88
- worldX: z.tx,
89
- worldY: z.ty
88
+ worldX: E.tx,
89
+ worldY: E.ty
90
90
  });
91
91
  }
92
- return G;
92
+ return W;
93
93
  }
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;
98
- if (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
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
106
106
  });
107
107
  }
108
108
  }
109
- return T;
109
+ return D;
110
110
  }
111
- function xn(A, M, D, U, T) {
112
- let G = null, P = T;
113
- for (const C of D) {
114
- if (C.type !== "simplebezier") continue;
115
- const z = St(C, U);
116
- if (!z) continue;
117
- const q = C.data.waypoints ?? [], j = [
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 = [
118
118
  {
119
- x: z.sx,
120
- y: z.sy
119
+ x: E.sx,
120
+ y: E.sy
121
121
  },
122
122
  ...q,
123
123
  {
124
- x: z.tx,
125
- y: z.ty
124
+ x: E.tx,
125
+ y: E.ty
126
126
  }
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 = {
131
- edgeId: C.id,
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
132
  segmentIndex: $,
133
133
  controlEnd: "c1",
134
- wx: ae,
135
- wy: Zt
134
+ wx: he,
135
+ wy: $t
136
136
  });
137
- const gt = Math.hypot(A - Kt, M - Et);
138
- gt < P && (P = gt, G = {
139
- edgeId: C.id,
137
+ const gt = Math.hypot(L - jt, M - Et);
138
+ gt < A && (A = gt, W = {
139
+ edgeId: N.id,
140
140
  segmentIndex: $,
141
141
  controlEnd: "c2",
142
- wx: Kt,
142
+ wx: jt,
143
143
  wy: Et
144
144
  });
145
145
  }
146
146
  }
147
- return G;
147
+ return W;
148
148
  }
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 = [
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 = [
153
153
  {
154
- x: T.sx,
155
- y: T.sy
154
+ x: D.sx,
155
+ y: D.sy
156
156
  },
157
- ...G,
157
+ ...W,
158
158
  {
159
- x: T.tx,
160
- y: T.ty
159
+ x: D.tx,
160
+ y: D.ty
161
161
  }
162
162
  ];
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);
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);
167
167
  }
168
- return z;
168
+ return E;
169
169
  }
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,
176
- w: C,
177
- h: z
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
178
178
  };
179
179
  }
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;
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;
185
185
  return !1;
186
186
  }
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;
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;
190
190
  return !1;
191
191
  }
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);
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
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({
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({
204
204
  time: 0,
205
205
  wx: 0,
206
206
  wy: 0
207
- }), Gt = b({
207
+ }), Xt = m({
208
208
  time: 0,
209
209
  wx: 0,
210
210
  wy: 0
211
- }), Ve = b(0), te = b(null), qe = b({
211
+ }), Ve = m(0), re = m(null), qe = m({
212
212
  x: 0,
213
213
  y: 0
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);
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
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);
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
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) => {
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
244
  ze.current = f, Ee.current || (Ee.current = requestAnimationFrame(() => {
245
- Ee.current = 0, P(ze.current);
245
+ Ee.current = 0, A(ze.current);
246
246
  }));
247
- }, [P])), it = b(je);
248
- it.current = je;
249
- const [ht, Ce] = ln(null), [Ne, ke] = ln(null), Te = b(ht);
247
+ }, [A])), dt = m(je);
248
+ dt.current = je;
249
+ const [ht, Ce] = ln(null), [Ne, ke] = ln(null), Te = m(ht);
250
250
  Te.current = ht;
251
- const pe = b(() => {
251
+ const we = m(() => {
252
252
  });
253
- pe.current = (f, L, _) => {
254
- gt(f === "node" ? L : null), Ce({
253
+ we.current = (f, G, F) => {
254
+ gt(f === "node" ? G : null), Ce({
255
255
  kind: f,
256
- id: L,
257
- value: _
256
+ id: G,
257
+ value: F
258
258
  });
259
259
  };
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 _;
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
265
  let V = K;
266
- if (L.kind === "node") V = {
266
+ if (G.kind === "node") V = {
267
267
  ...K,
268
- nodes: K.nodes.map((X) => X.id === L.id ? {
269
- ...X,
268
+ nodes: K.nodes.map((O) => O.id === G.id ? {
269
+ ...O,
270
270
  data: {
271
- ...X.data,
271
+ ...O.data,
272
272
  label: f
273
273
  }
274
- } : X)
274
+ } : O)
275
275
  };
276
- else if (L.kind === "edge") V = {
276
+ else if (G.kind === "edge") V = {
277
277
  ...K,
278
- edges: K.edges.map((X) => X.id === L.id ? {
279
- ...X,
278
+ edges: K.edges.map((O) => O.id === G.id ? {
279
+ ...O,
280
280
  data: {
281
- ...X.data,
281
+ ...O.data,
282
282
  labelText: f
283
283
  }
284
- } : X)
284
+ } : O)
285
285
  };
286
- else return _;
286
+ else return F;
287
287
  return {
288
- ..._,
288
+ ...F,
289
289
  canvases: {
290
- ..._.canvases,
291
- [W]: V
290
+ ...F.canvases,
291
+ [Y]: V
292
292
  }
293
293
  };
294
294
  }), Ce(null), gt(null), ke(null));
295
- }, [Q, gt]), bn = ie(() => {
295
+ }, [tt, gt]), bn = le(() => {
296
296
  Ce(null), gt(null), ke(null);
297
297
  }, [gt]);
298
298
  Rt(() => {
299
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);
300
+ const f = X.current.nodes.find((G) => G.id === Ct);
301
+ f && we.current("node", f.id, f.data.label);
302
302
  }, [Ct]), Rt(() => {
303
303
  if (!ht) return;
304
- const f = O.current;
304
+ const f = B.current;
305
305
  if (!f) return;
306
- const L = Y.current;
307
- let _ = null;
306
+ const G = X.current;
307
+ let F = null;
308
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
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
313
313
  });
314
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);
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
319
  if (V) {
320
- const X = mn(wn(W.type, V, W.data.waypoints, W.data.bezierControls)), dt = X[Math.floor(X.length / 2)] ?? {
320
+ const O = mn(wn(Y.type, V, Y.data.waypoints, Y.data.bezierControls)), at = O[Math.floor(O.length / 2)] ?? {
321
321
  x: (V.sx + V.tx) / 2,
322
322
  y: (V.sy + V.ty) / 2
323
323
  };
324
- _ = {
325
- x: dt.x,
326
- y: dt.y
324
+ F = {
325
+ x: at.x,
326
+ y: at.y
327
327
  };
328
328
  }
329
329
  }
330
330
  }
331
- if (_) {
332
- const W = f.worldToScreen(_.x, _.y);
331
+ if (F) {
332
+ const Y = f.worldToScreen(F.x, F.y);
333
333
  ke({
334
- x: W.x,
335
- y: W.y
334
+ x: Y.x,
335
+ y: Y.y
336
336
  });
337
337
  }
338
- }, [ht, O]);
339
- const Qe = b(0);
338
+ }, [ht, B]);
339
+ const Qe = m(0);
340
340
  Rt(() => {
341
- C.current !== Qe.current && (Qe.current = C.current, ze.current = z, O.current?.setState(z));
341
+ N.current !== Qe.current && (Qe.current = N.current, ze.current = E, B.current?.setState(E));
342
342
  }, [
343
- z,
344
- O,
345
- C
343
+ E,
344
+ B,
345
+ N
346
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;
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
351
  V.animateTo({
352
- x: ce,
352
+ x: ae,
353
353
  y: He,
354
- zoom: Ht
354
+ zoom: Pt
355
355
  }, K?.duration ?? 350);
356
356
  });
357
- }, [zt, O]);
358
- const tn = ie((f) => {
359
- Q((L) => {
360
- const _ = L.canvases[Z.current];
361
- return _ ? {
362
- ...L,
357
+ }, [zt, B]);
358
+ const tn = le((f) => {
359
+ tt((G) => {
360
+ const F = G.canvases[Z.current];
361
+ return F ? {
362
+ ...G,
363
363
  canvases: {
364
- ...L.canvases,
364
+ ...G.canvases,
365
365
  [Z.current]: {
366
- ..._,
367
- lines: [..._.lines, f]
366
+ ...F,
367
+ lines: [...F.lines, f]
368
368
  }
369
369
  }
370
- } : L;
370
+ } : G;
371
371
  });
372
- }, [Q, ve]), De = b(tn);
372
+ }, [tt, be]), De = m(tn);
373
373
  return De.current = tn, Rt(() => {
374
- const f = T.current;
374
+ const f = D.current;
375
375
  if (!f || f.destroyed) return;
376
- let L = !1, _ = null, W = null, K = null;
376
+ let G = !1, F = null, Y = null, K = null;
377
377
  const V = () => {
378
- if (L) return;
379
- if (!G.current) {
378
+ if (G) return;
379
+ if (!W.current) {
380
380
  setTimeout(V, 30);
381
381
  return;
382
382
  }
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, {
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
394
  onLineComplete: (x) => De.current(x),
395
- screenToWorld: (x, c) => it.current(x, c)
396
- }), be.current = new An(f.app.stage, f.world, {
395
+ screenToWorld: (x, s) => dt.current(x, s)
396
+ }), Re.current = new An(f.app.stage, f.world, {
397
397
  onLineComplete: (x) => De.current(x),
398
- screenToWorld: (x, c) => it.current(x, c)
399
- }), A?.(f);
398
+ screenToWorld: (x, s) => dt.current(x, s)
399
+ }), L?.(f);
400
400
  const bt = f.app.stage;
401
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);
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);
406
406
  return;
407
407
  }
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;
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
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]);
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
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)) {
419
+ const o = fn(t, T);
420
+ if (Math.hypot(c.x - o.x, c.y - o.y) < Q(T, 12, 24)) {
421
421
  ft.current = {
422
422
  active: !0,
423
423
  nodeId: t.id,
424
424
  cx: t.position.x + t.width / 2,
425
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)),
426
+ startPointerAngle: Math.atan2(c.y - (t.position.y + t.height / 2), c.x - (t.position.x + t.width / 2)),
427
427
  startRotation: t.data.rotation ?? 0
428
428
  }, Se.current();
429
429
  return;
430
430
  }
431
431
  }
432
432
  }
433
- if (R.nodeIds.size === 1 && !S && c === "select") {
434
- const t = y.find((r) => r.id === [...R.nodeIds][0]);
433
+ if (R.nodeIds.size === 1 && !S && s === "select") {
434
+ const t = p.find((o) => o.id === [...R.nodeIds][0]);
435
435
  if (t) {
436
- const r = hn(d, t, J(k, 10, 16));
437
- if (r) {
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, {
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
441
  x: u.position.x,
442
442
  y: u.position.y,
443
443
  w: u.width,
444
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, {
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
446
  x: u.position.x,
447
447
  y: u.position.y,
448
448
  w: u.width,
449
449
  h: u.height
450
450
  }));
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 })));
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
453
  xt.current = {
454
454
  active: !0,
455
455
  nodeId: t.id,
456
- handle: r,
457
- startWorld: d,
456
+ handle: o,
457
+ startWorld: c,
458
458
  startBounds: {
459
459
  x: t.position.x,
460
460
  y: t.position.y,
461
461
  w: t.width,
462
462
  h: t.height
463
463
  },
464
- childStarts: i,
465
- childLineStarts: a.size > 0 ? a : void 0
464
+ childStarts: a,
465
+ childLineStarts: i.size > 0 ? i : void 0
466
466
  };
467
467
  return;
468
468
  }
469
469
  }
470
470
  }
471
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];
472
+ for (let t = p.length - 1; t >= 0; t--) if (qt(c.x, c.y, p[t])) {
473
+ e = p[t];
474
474
  break;
475
475
  }
476
476
  if (e?.parentId) {
477
- const t = y.find((r) => r.id === e.parentId);
477
+ const t = p.find((o) => o.id === e.parentId);
478
478
  t && (e = t);
479
479
  }
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);
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);
487
+ if (!w) continue;
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);
488
490
  }
489
- if (i && a) {
490
- nt.current = {
491
+ if (a && i) {
492
+ rt.current = {
491
493
  active: !0,
492
- sourceNodeId: i.id,
493
- sourceHandleId: a.id
494
+ sourceNodeId: a.id,
495
+ sourceHandleId: i.id
494
496
  };
495
497
  return;
496
498
  }
497
499
  }
498
- if ((c === "select" || c === "connect") && !S && R.edgeIds.size > 0) {
500
+ if ((s === "select" || s === "connect") && !S && R.edgeIds.size > 0) {
499
501
  const t = /* @__PURE__ */ new Map();
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);
504
- if (a) {
505
- const o = i.end === "source" ? "target" : "source";
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";
506
508
  ct.current = {
507
509
  active: !0,
508
- edgeId: a.id,
509
- movingEnd: i.end,
510
- fixedNodeId: o === "source" ? a.source : a.target,
511
- fixedHandleId: o === "source" ? a.sourceHandle : a.targetHandle
510
+ edgeId: i.id,
511
+ movingEnd: a.end,
512
+ fixedNodeId: n === "source" ? i.source : i.target,
513
+ fixedHandleId: n === "source" ? i.sourceHandle : i.targetHandle
512
514
  };
513
515
  return;
514
516
  }
515
517
  }
516
518
  }
517
- if (c === "select" && R.edgeIds.size > 0 && !e) {
519
+ if (s === "select" && R.edgeIds.size > 0 && !e) {
518
520
  const t = /* @__PURE__ */ new Map();
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);
521
- if (a) {
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) {
522
524
  ut.current = {
523
525
  active: !0,
524
- edgeId: a.edgeId,
525
- type: a.controlEnd === "c1" ? "bezierC1" : "bezierC2",
526
- index: a.segmentIndex
526
+ edgeId: i.edgeId,
527
+ type: i.controlEnd === "c1" ? "bezierC1" : "bezierC2",
528
+ index: i.segmentIndex
527
529
  };
528
530
  return;
529
531
  }
530
- const o = pn(d.x, d.y, r, i);
531
- if (o) {
532
+ const n = pn(c.x, c.y, o, a);
533
+ if (n) {
532
534
  if (l) {
533
- Q((n) => {
534
- const v = n.canvases[Z.current];
535
- return v ? {
536
- ...n,
535
+ tt((d) => {
536
+ const w = d.canvases[Z.current];
537
+ return w ? {
538
+ ...d,
537
539
  canvases: {
538
- ...n.canvases,
540
+ ...d.canvases,
539
541
  [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 = {
542
+ ...w,
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 = {
546
548
  ...g.data,
547
- waypoints: m.length > 0 ? m : void 0
549
+ waypoints: z.length > 0 ? z : void 0
548
550
  };
549
551
  if (g.type === "simplebezier" && g.data.bezierControls) {
550
552
  const u = [...g.data.bezierControls];
551
- u.splice(o.waypointIndex, 2, null), E.bezierControls = u.some((w) => w !== null) ? u : void 0;
553
+ u.splice(n.waypointIndex, 2, null), C.bezierControls = u.some((b) => b !== null) ? u : void 0;
552
554
  }
553
555
  return {
554
556
  ...g,
555
- data: E
557
+ data: C
556
558
  };
557
559
  })
558
560
  }
559
561
  }
560
- } : n;
562
+ } : d;
561
563
  });
562
564
  return;
563
565
  }
564
566
  ut.current = {
565
567
  active: !0,
566
- edgeId: o.edgeId,
568
+ edgeId: n.edgeId,
567
569
  type: "waypoint",
568
- index: o.waypointIndex
570
+ index: n.waypointIndex
569
571
  };
570
572
  return;
571
573
  }
572
574
  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
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
577
579
  };
578
- Q((m) => {
579
- const E = m.canvases[Z.current];
580
- return E ? {
581
- ...m,
580
+ tt((z) => {
581
+ const C = z.canvases[Z.current];
582
+ return C ? {
583
+ ...z,
582
584
  canvases: {
583
- ...m.canvases,
585
+ ...z.canvases,
584
586
  [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 = {
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 _ = {
591
593
  ...u.data,
592
- waypoints: w
594
+ waypoints: b
593
595
  };
594
596
  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;
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;
598
600
  }
599
601
  return {
600
602
  ...u,
601
- data: F
603
+ data: _
602
604
  };
603
605
  })
604
606
  }
605
607
  }
606
- } : m;
608
+ } : z;
607
609
  }), ut.current = {
608
610
  active: !0,
609
- edgeId: n.id,
611
+ edgeId: d.id,
610
612
  type: "waypoint",
611
- index: v
613
+ index: w
612
614
  };
613
615
  return;
614
616
  }
615
617
  }
616
618
  }
617
- if (e && (c === "select" || c === "connect")) {
619
+ if (e && (s === "select" || s === "connect")) {
618
620
  !S && !R.nodeIds.has(e.id) ? pt({
619
621
  nodeIds: /* @__PURE__ */ new Set([e.id]),
620
622
  edgeIds: /* @__PURE__ */ new Set(),
621
623
  lineIds: /* @__PURE__ */ new Set()
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,
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,
626
628
  edgeIds: /* @__PURE__ */ new Set(),
627
629
  lineIds: /* @__PURE__ */ new Set()
628
630
  };
629
- }), re.current && oe.current(e.position.x, e.position.y, e.width, e.height, {
631
+ }), ie.current && ce.current(e.position.x, e.position.y, e.width, e.height, {
630
632
  padding: 80,
631
633
  preserveZoom: !0,
632
634
  duration: 280
633
635
  });
634
636
  const t = R.nodeIds.has(e.id) ? new Set(R.nodeIds) : /* @__PURE__ */ new Set([e.id]);
635
637
  S && !R.nodeIds.has(e.id) && t.add(e.id);
636
- const r = /* @__PURE__ */ new Set();
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);
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);
645
647
  continue;
646
648
  }
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);
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);
648
650
  }
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);
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);
652
654
  }
653
- const i = /* @__PURE__ */ new Map();
654
- for (const o of y) t.has(o.id) && i.set(o.id, { ...o.position });
655
655
  const a = /* @__PURE__ */ new Map();
656
- if (r.size > 0)
657
- for (const o of Y.current.lines) r.has(o.id) && a.set(o.id, o.points.map((n) => ({ ...n })));
658
- st.current = {
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 = {
659
661
  active: !0,
660
662
  nodeIds: t,
661
- lineIds: r.size > 0 ? r : void 0,
662
- startWorld: d,
663
- nodeStarts: i,
664
- linePointStarts: a.size > 0 ? a : void 0
663
+ lineIds: o.size > 0 ? o : void 0,
664
+ startWorld: c,
665
+ nodeStarts: a,
666
+ linePointStarts: i.size > 0 ? i : void 0
665
667
  }, Se.current();
666
668
  return;
667
669
  }
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), {
675
- ...r,
676
- edgeIds: i
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
677
679
  };
678
680
  } : {
679
681
  nodeIds: /* @__PURE__ */ new Set(),
680
682
  edgeIds: /* @__PURE__ */ new Set([t.id]),
681
683
  lineIds: /* @__PURE__ */ new Set()
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, {
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, {
687
689
  padding: 80,
688
690
  preserveZoom: !0,
689
691
  duration: 280
@@ -692,33 +694,33 @@ function fr({ onPixiReady: A }) {
692
694
  }
693
695
  return;
694
696
  }
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
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
702
704
  };
703
- }) : r || pt({
705
+ }) : o || pt({
704
706
  nodeIds: /* @__PURE__ */ new Set(),
705
707
  edgeIds: /* @__PURE__ */ new Set(),
706
708
  lineIds: /* @__PURE__ */ new Set([t.id])
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), {
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), {
710
712
  padding: 80,
711
713
  preserveZoom: !0,
712
714
  duration: 280
713
715
  });
714
716
  }
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
+ 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 })));
717
719
  mt.current = {
718
720
  active: !0,
719
- lineIds: i,
720
- startWorld: d,
721
- pointStarts: a
721
+ lineIds: a,
722
+ startWorld: c,
723
+ pointStarts: i
722
724
  };
723
725
  return;
724
726
  }
@@ -726,7 +728,7 @@ function fr({ onPixiReady: A }) {
726
728
  nodeIds: /* @__PURE__ */ new Set(),
727
729
  edgeIds: /* @__PURE__ */ new Set(),
728
730
  lineIds: /* @__PURE__ */ new Set()
729
- }), c === "select" && (et.current = {
731
+ }), s === "select" && (nt.current = {
730
732
  active: !0,
731
733
  startScreen: {
732
734
  x: x.global.x,
@@ -734,75 +736,75 @@ function fr({ onPixiReady: A }) {
734
736
  }
735
737
  });
736
738
  }), 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;
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;
742
744
  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;
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;
746
748
  break;
747
749
  }
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;
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;
753
755
  let I = null;
754
756
  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));
758
- if (t) {
759
- const r = Ot(t, p);
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);
760
762
  I = {
761
- nodeId: p.id,
762
- handleId: t.id,
763
- wx: r.x,
764
- wy: r.y
763
+ nodeId: y.id,
764
+ handleId: v.id,
765
+ wx: t.x,
766
+ wy: t.y
765
767
  };
766
768
  }
767
769
  }
768
770
  }
769
- Me.current = I;
771
+ Wt.current = I;
770
772
  }
771
- const k = M.current;
772
- if (k && R) {
773
- const s = ee.current;
773
+ const T = M.current;
774
+ if (T && R) {
775
+ const r = oe.current;
774
776
  let h = "";
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");
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");
782
784
  }
783
- if (!h && s.nodeIds.size === 1 && d === "select") {
784
- const l = y.find((e) => e.id === [...s.nodeIds][0]);
785
+ if (!h && r.nodeIds.size === 1 && c === "select") {
786
+ const l = p.find((e) => e.id === [...r.nodeIds][0]);
785
787
  if (l) {
786
- const e = hn(c, l, J(N, 10, 16));
788
+ const e = hn(s, l, Q(k, 10, 16));
787
789
  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");
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");
791
793
  }
792
794
  }
793
795
  }
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)) {
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)) {
797
799
  h = "move";
798
800
  break;
799
801
  }
800
802
  }
801
- k.style.cursor = h;
803
+ T.style.cursor = h;
802
804
  }
803
805
  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,
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,
806
808
  type: "shapeRect",
807
809
  position: {
808
810
  x: e.x,
@@ -812,50 +814,50 @@ function fr({ onPixiReady: A }) {
812
814
  height: e.h,
813
815
  data: {}
814
816
  }], 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) {
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) {
816
818
  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);
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);
818
820
  }
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 ? {
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 ? {
823
825
  ...n,
824
826
  canvases: {
825
827
  ...n.canvases,
826
828
  [Z.current]: {
827
- ...v,
828
- nodes: v.nodes.map((g) => {
829
- if (g.id === s.nodeId) return {
830
- ...g,
829
+ ...d,
830
+ nodes: d.nodes.map((w) => {
831
+ if (w.id === r.nodeId) return {
832
+ ...w,
831
833
  position: {
832
834
  x: e.x,
833
835
  y: e.y
834
836
  },
835
- width: r,
836
- height: i
837
+ width: t,
838
+ height: o
837
839
  };
838
- const m = s.childStarts.get(g.id);
839
- return m ? {
840
- ...g,
840
+ const g = r.childStarts.get(w.id);
841
+ return g ? {
842
+ ...w,
841
843
  position: {
842
- x: e.x + (m.x - t.x) * a,
843
- y: e.y + (m.y - t.y) * o
844
+ x: e.x + (g.x - v.x) * a,
845
+ y: e.y + (g.y - v.y) * i
844
846
  },
845
- width: Math.max(m.w * a, 24),
846
- height: Math.max(m.h * o, 24)
847
- } : g;
847
+ width: Math.max(g.w * a, 24),
848
+ height: Math.max(g.h * i, 24)
849
+ } : w;
848
850
  }),
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
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
856
858
  }))
857
- } : g;
858
- }) : v.lines
859
+ } : w;
860
+ }) : d.lines
859
861
  }
860
862
  }
861
863
  } : n;
@@ -863,14 +865,14 @@ function fr({ onPixiReady: A }) {
863
865
  return;
864
866
  }
865
867
  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
+ 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;
868
870
  if (x.shiftKey) l = Math.round(l / 15) * 15 % 360;
869
871
  else {
870
872
  const e = Math.round(l / 45) * 45;
871
873
  Math.abs(l - e) < 4 && (l = (e % 360 + 360) % 360);
872
874
  }
873
- Q((e) => {
875
+ tt((e) => {
874
876
  const I = e.canvases[Z.current];
875
877
  return I ? {
876
878
  ...e,
@@ -878,13 +880,13 @@ function fr({ onPixiReady: A }) {
878
880
  ...e.canvases,
879
881
  [Z.current]: {
880
882
  ...I,
881
- nodes: I.nodes.map((p) => p.id === s.nodeId ? {
882
- ...p,
883
+ nodes: I.nodes.map((y) => y.id === r.nodeId ? {
884
+ ...y,
883
885
  data: {
884
- ...p.data,
886
+ ...y.data,
885
887
  rotation: l
886
888
  }
887
- } : p)
889
+ } : y)
888
890
  }
889
891
  }
890
892
  } : e;
@@ -892,9 +894,9 @@ function fr({ onPixiReady: A }) {
892
894
  return;
893
895
  }
894
896
  if (ut.current?.active) {
895
- const s = ut.current, h = Y.current.nodes, l = /* @__PURE__ */ new Map();
897
+ const r = ut.current, h = X.current.nodes, l = /* @__PURE__ */ new Map();
896
898
  for (const e of h) l.set(e.id, e);
897
- Q((e) => {
899
+ tt((e) => {
898
900
  const I = e.canvases[Z.current];
899
901
  return I ? {
900
902
  ...e,
@@ -902,53 +904,53 @@ function fr({ onPixiReady: A }) {
902
904
  ...e.canvases,
903
905
  [Z.current]: {
904
906
  ...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
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
912
914
  }), {
913
- ...p,
915
+ ...y,
914
916
  data: {
915
- ...p.data,
916
- waypoints: Xt
917
+ ...y.data,
918
+ waypoints: Ft
917
919
  }
918
920
  };
919
921
  }
920
- const t = St(p, l);
921
- if (!t) return p;
922
- const r = p.data.waypoints ?? [], i = [
922
+ const v = St(y, l);
923
+ if (!v) return y;
924
+ const t = y.data.waypoints ?? [], o = [
923
925
  {
924
- x: t.sx,
925
- y: t.sy
926
+ x: v.sx,
927
+ y: v.sy
926
928
  },
927
- ...r,
929
+ ...t,
928
930
  {
929
- x: t.tx,
930
- y: t.ty
931
+ x: v.tx,
932
+ y: v.ty
931
933
  }
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
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
947
949
  }, {
948
- ...p,
950
+ ...y,
949
951
  data: {
950
- ...p.data,
951
- bezierControls: o
952
+ ...y.data,
953
+ bezierControls: i
952
954
  }
953
955
  };
954
956
  })
@@ -959,8 +961,8 @@ function fr({ onPixiReady: A }) {
959
961
  return;
960
962
  }
961
963
  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 r = mt.current, h = s.x - r.startWorld.x, l = s.y - r.startWorld.y;
965
+ tt((e) => {
964
966
  const I = e.canvases[Z.current];
965
967
  return I ? {
966
968
  ...e,
@@ -968,15 +970,15 @@ function fr({ onPixiReady: A }) {
968
970
  ...e.canvases,
969
971
  [Z.current]: {
970
972
  ...I,
971
- lines: I.lines.map((p) => {
972
- const t = s.pointStarts.get(p.id);
973
- return t ? {
974
- ...p,
975
- points: t.map((r) => ({
976
- x: r.x + h,
977
- y: r.y + l
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
978
980
  }))
979
- } : p;
981
+ } : y;
980
982
  })
981
983
  }
982
984
  }
@@ -984,109 +986,109 @@ function fr({ onPixiReady: A }) {
984
986
  });
985
987
  return;
986
988
  }
987
- if (st.current?.active) {
988
- const s = st.current, h = c.x - s.startWorld.x, l = c.y - s.startWorld.y;
989
+ if (it.current?.active) {
990
+ const r = it.current, h = s.x - r.startWorld.x, l = s.y - r.startWorld.y;
989
991
  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);
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);
993
995
  }
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);
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);
996
998
  return {
997
- ...r,
999
+ ...t,
998
1000
  position: {
999
- x: i.x + e,
1000
- y: i.y + I
1001
+ x: o.x + e,
1002
+ y: o.y + I
1001
1003
  }
1002
1004
  };
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 ? {
1007
- ...r,
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,
1008
1010
  canvases: {
1009
- ...r.canvases,
1011
+ ...t.canvases,
1010
1012
  [Z.current]: {
1011
- ...i,
1012
- nodes: i.nodes.map((a) => {
1013
- const o = s.nodeStarts.get(a.id);
1014
- return o ? {
1013
+ ...o,
1014
+ nodes: o.nodes.map((a) => {
1015
+ const i = r.nodeStarts.get(a.id);
1016
+ return i ? {
1015
1017
  ...a,
1016
1018
  position: {
1017
- x: o.x + e,
1018
- y: o.y + I
1019
+ x: i.x + e,
1020
+ y: i.y + I
1019
1021
  }
1020
1022
  } : a;
1021
1023
  }),
1022
- lines: s.linePointStarts ? i.lines.map((a) => {
1023
- const o = s.linePointStarts.get(a.id);
1024
- return o ? {
1024
+ lines: r.linePointStarts ? o.lines.map((a) => {
1025
+ const i = r.linePointStarts.get(a.id);
1026
+ return i ? {
1025
1027
  ...a,
1026
- points: o.map((n) => ({
1028
+ points: i.map((n) => ({
1027
1029
  x: n.x + e,
1028
1030
  y: n.y + I
1029
1031
  }))
1030
1032
  } : a;
1031
- }) : i.lines
1033
+ }) : o.lines
1032
1034
  }
1033
1035
  }
1034
- } : r;
1036
+ } : t;
1035
1037
  });
1036
1038
  return;
1037
1039
  }
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);
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);
1041
1043
  }
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);
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);
1046
1048
  if (h) {
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);
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);
1052
1054
  if (a) {
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;
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;
1057
1059
  }
1058
1060
  }
1059
1061
  }
1060
- const i = wt.current;
1061
- i.clear(), i.moveTo(e, I).lineTo(p, t).stroke({
1062
+ const o = wt.current;
1063
+ o.clear(), o.moveTo(e, I).lineTo(y, v).stroke({
1062
1064
  color: 3900150,
1063
1065
  width: 2,
1064
1066
  alpha: 0.6
1065
- }), i.visible = !0;
1067
+ }), o.visible = !0;
1066
1068
  }
1067
1069
  }
1068
1070
  }
1069
1071
  if (ct.current?.active && wt.current && !wt.current.destroyed) {
1070
- const s = ct.current, h = Y.current.nodes.find((l) => l.id === s.fixedNodeId);
1072
+ const r = ct.current, h = X.current.nodes.find((l) => l.id === r.fixedNodeId);
1071
1073
  if (h) {
1072
- const l = Mt(h.width, h.height).find((o) => o.id === s.fixedHandleId), e = l ? Ot(l, h) : {
1074
+ const l = Mt(h.width, h.height).find((i) => i.id === r.fixedHandleId), e = l ? Vt(l, h) : {
1073
1075
  x: h.position.x + h.width / 2,
1074
1076
  y: h.position.y + h.height / 2
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);
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);
1082
1084
  if (n) {
1083
- const v = Ot(n, o);
1084
- t = v.x, r = v.y;
1085
+ const d = Vt(n, i);
1086
+ v = d.x, t = d.y;
1085
1087
  }
1086
1088
  }
1087
1089
  }
1088
1090
  const a = wt.current;
1089
- a.clear(), a.moveTo(I, p).lineTo(t, r).stroke({
1091
+ a.clear(), a.moveTo(I, y).lineTo(v, t).stroke({
1090
1092
  color: 16347926,
1091
1093
  width: 2,
1092
1094
  alpha: 0.7
@@ -1094,10 +1096,10 @@ function fr({ onPixiReady: A }) {
1094
1096
  }
1095
1097
  }
1096
1098
  });
1097
- const Ht = () => {
1098
- Lt.current = [];
1099
+ const Pt = () => {
1100
+ Gt.current = [];
1099
1101
  try {
1100
- ye.current?.clear();
1102
+ ge.current?.clear();
1101
1103
  } catch {
1102
1104
  }
1103
1105
  try {
@@ -1108,8 +1110,8 @@ function fr({ onPixiReady: A }) {
1108
1110
  M.current && (M.current.style.cursor = "");
1109
1111
  };
1110
1112
  bt.on("pointerup", (x) => {
1111
- if (Ht(), ft.current?.active) {
1112
- ft.current = null, Dt.current();
1113
+ if (Pt(), ft.current?.active) {
1114
+ ft.current = null, Ht.current();
1113
1115
  return;
1114
1116
  }
1115
1117
  if (ut.current?.active) {
@@ -1124,30 +1126,30 @@ function fr({ onPixiReady: A }) {
1124
1126
  mt.current = null;
1125
1127
  return;
1126
1128
  }
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));
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));
1131
1133
  pt({
1132
- nodeIds: new Set(S.map((s) => s.id)),
1134
+ nodeIds: new Set(S.map((r) => r.id)),
1133
1135
  edgeIds: /* @__PURE__ */ new Set(),
1134
- lineIds: new Set(k.map((s) => s.id))
1136
+ lineIds: new Set(T.map((r) => r.id))
1135
1137
  });
1136
1138
  }
1137
- et.current = null, kt.current?.hideMarquee();
1139
+ nt.current = null, kt.current?.hideMarquee();
1138
1140
  }
1139
1141
  if (ct.current?.active) {
1140
- const c = ct.current.edgeId, d = ct.current.movingEnd, y = ct.current.fixedNodeId;
1142
+ const s = ct.current.edgeId, c = ct.current.movingEnd, p = ct.current.fixedNodeId;
1141
1143
  ct.current = null;
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;
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;
1143
1145
  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];
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];
1146
1148
  break;
1147
1149
  }
1148
1150
  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 T = S.id, r = Bt(Mt(S.width, S.height), S, P.x, P.y, 1 / 0)?.id;
1152
+ tt((h) => {
1151
1153
  const l = h.canvases[Z.current];
1152
1154
  return l ? {
1153
1155
  ...h,
@@ -1155,14 +1157,14 @@ function fr({ onPixiReady: A }) {
1155
1157
  ...h.canvases,
1156
1158
  [Z.current]: {
1157
1159
  ...l,
1158
- edges: l.edges.map((e) => e.id !== c ? e : d === "source" ? {
1160
+ edges: l.edges.map((e) => e.id !== s ? e : c === "source" ? {
1159
1161
  ...e,
1160
- source: k,
1161
- sourceHandle: s
1162
+ source: T,
1163
+ sourceHandle: r
1162
1164
  } : {
1163
1165
  ...e,
1164
- target: k,
1165
- targetHandle: s
1166
+ target: T,
1167
+ targetHandle: r
1166
1168
  })
1167
1169
  }
1168
1170
  }
@@ -1171,31 +1173,31 @@ function fr({ onPixiReady: A }) {
1171
1173
  }
1172
1174
  return;
1173
1175
  }
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;
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;
1178
1180
  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];
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];
1181
1183
  break;
1182
1184
  }
1183
1185
  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 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) => {
1186
1188
  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 : {
1189
+ return !e || e.edges.some((I) => I.source === s && I.target === S && I.sourceHandle === c && I.targetHandle === T) ? l : {
1188
1190
  ...l,
1189
1191
  canvases: {
1190
1192
  ...l.canvases,
1191
1193
  [Z.current]: {
1192
1194
  ...e,
1193
1195
  edges: [...e.edges, {
1194
- id: s,
1195
- source: c,
1196
+ id: r,
1197
+ source: s,
1196
1198
  target: S,
1197
- sourceHandle: d,
1198
- targetHandle: k,
1199
+ sourceHandle: c,
1200
+ targetHandle: T,
1199
1201
  type: h,
1200
1202
  data: {
1201
1203
  strokeColor: "theme:base-content",
@@ -1211,97 +1213,97 @@ function fr({ onPixiReady: A }) {
1211
1213
  }
1212
1214
  }
1213
1215
  }), 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();
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();
1215
1217
  });
1216
- const Pt = M.current;
1218
+ const At = M.current;
1217
1219
  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;
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;
1220
1222
  return {
1221
- dist: Math.hypot(H - d, N - y),
1222
- midX: (d + H) / 2 - c.left,
1223
- midY: (y + N) / 2 - c.top
1223
+ dist: Math.hypot(P - c, k - p),
1224
+ midX: (c + P) / 2 - s.left,
1225
+ midY: (p + k) / 2 - s.top
1224
1226
  };
1225
1227
  }, 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();
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();
1227
1229
  }, en = (x) => {
1228
1230
  if (x.touches.length < 2) return;
1229
- const c = O.current;
1230
- c && (c.multiTouchActive = !0, He(), yt = ce(x.touches), x.preventDefault());
1231
+ const s = B.current;
1232
+ s && (s.multiTouchActive = !0, He(), yt = ae(x.touches), x.preventDefault());
1231
1233
  }, nn = (x) => {
1232
1234
  if (!yt || x.touches.length < 2) return;
1233
1235
  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;
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;
1241
1243
  }, Pe = (x) => {
1242
1244
  if (x.touches.length >= 2) {
1243
- yt = ce(x.touches);
1245
+ yt = ae(x.touches);
1244
1246
  return;
1245
1247
  }
1246
1248
  if (yt = null, x.touches.length === 0) {
1247
- const c = O.current;
1248
- c && (c.multiTouchActive = !1), Ve.current = performance.now() + 350;
1249
+ const s = B.current;
1250
+ s && (s.multiTouchActive = !1), Ve.current = performance.now() + 350;
1249
1251
  }
1250
1252
  };
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;
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;
1256
+ let p = null;
1257
+ for (let S = c.length - 1; S >= 0; S--) if (qt(s.x, s.y, c[S])) {
1258
+ p = c[S].id;
1257
1259
  break;
1258
1260
  }
1259
- const H = x.nativeEvent, N = H?.clientX ?? x.global.x, R = H?.clientY ?? x.global.y;
1260
- ae({
1261
- x: N,
1261
+ const P = x.nativeEvent, k = P?.clientX ?? x.global.x, R = P?.clientY ?? x.global.y;
1262
+ he({
1263
+ x: k,
1262
1264
  y: R,
1263
- nodeId: y
1265
+ nodeId: p
1264
1266
  });
1265
1267
  }), 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([{
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;
1270
+ if (p) {
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([{
1270
1272
  id: "__ghost__",
1271
- type: y.type,
1273
+ type: p.type,
1272
1274
  position: {
1273
1275
  x: h,
1274
1276
  y: l
1275
1277
  },
1276
- width: y.width,
1277
- height: y.height,
1278
+ width: p.width,
1279
+ height: p.height,
1278
1280
  data: {}
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));
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));
1286
1288
  return {
1287
- ...t,
1289
+ ...v,
1288
1290
  canvases: {
1289
- ...t.canvases,
1291
+ ...v.canvases,
1290
1292
  [Z.current]: {
1291
- ...r,
1292
- nodes: [...r.nodes, {
1293
+ ...t,
1294
+ nodes: [...t.nodes, {
1293
1295
  id: S,
1294
- type: y.type,
1296
+ type: p.type,
1295
1297
  position: {
1296
1298
  x: I,
1297
- y: p
1299
+ y
1298
1300
  },
1299
- width: y.width,
1300
- height: y.height,
1301
+ width: p.width,
1302
+ height: p.height,
1301
1303
  zIndex: a + 1,
1302
1304
  data: {
1303
- ...y.data,
1304
- ...i
1305
+ ...p.data,
1306
+ ...o
1305
1307
  }
1306
1308
  }]
1307
1309
  }
@@ -1311,44 +1313,44 @@ function fr({ onPixiReady: A }) {
1311
1313
  nodeIds: /* @__PURE__ */ new Set([S]),
1312
1314
  edgeIds: /* @__PURE__ */ new Set(),
1313
1315
  lineIds: /* @__PURE__ */ new Set()
1314
- }), re.current && window.setTimeout(() => {
1315
- oe.current(I, p, y.width, y.height, {
1316
+ }), ie.current && window.setTimeout(() => {
1317
+ ce.current(I, y, p.width, p.height, {
1316
1318
  padding: 80,
1317
1319
  preserveZoom: !0,
1318
1320
  duration: 280
1319
1321
  });
1320
- }, 0), Gt.current = {
1322
+ }, 0), Xt.current = {
1321
1323
  time: 0,
1322
1324
  wx: 0,
1323
1325
  wy: 0
1324
1326
  };
1325
1327
  return;
1326
1328
  }
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])) {
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])) {
1331
1333
  const e = S[l], I = e.data.childCanvasId;
1332
1334
  if (I) {
1333
- In(I), Gt.current = {
1335
+ In(I), Xt.current = {
1334
1336
  time: 0,
1335
1337
  wx: 0,
1336
1338
  wy: 0
1337
1339
  };
1338
1340
  return;
1339
1341
  }
1340
- pe.current("node", e.id, e.data.label ?? ""), Gt.current = {
1342
+ we.current("node", e.id, e.data.label ?? ""), Xt.current = {
1341
1343
  time: 0,
1342
1344
  wx: 0,
1343
1345
  wy: 0
1344
1346
  };
1345
1347
  return;
1346
1348
  }
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 = {
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 = {
1352
1354
  time: 0,
1353
1355
  wx: 0,
1354
1356
  wy: 0
@@ -1356,266 +1358,266 @@ function fr({ onPixiReady: A }) {
1356
1358
  return;
1357
1359
  }
1358
1360
  }
1359
- Gt.current = {
1360
- time: c,
1361
- wx: d.x,
1362
- wy: d.y
1361
+ Xt.current = {
1362
+ time: s,
1363
+ wx: c.x,
1364
+ wy: c.y
1363
1365
  };
1364
1366
  });
1365
1367
  let rn = !1;
1366
1368
  f.app.ticker.add((x) => {
1367
1369
  if (f.destroyed) return;
1368
- const c = x.deltaMS, d = f.app.screen, y = O.current?.state ?? {
1370
+ const s = x.deltaMS, c = f.app.screen, p = B.current?.state ?? {
1369
1371
  x: 0,
1370
1372
  y: 0,
1371
1373
  zoom: 1
1372
1374
  };
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, {
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, {
1380
1382
  showAnchors: $e.current,
1381
- presentation: Tt.current !== null,
1382
- presentationAnchorId: s?.node.id,
1383
- presentationAnchorVisible: Tt.current?.showAnchor ?? !1
1383
+ presentation: Dt.current !== null,
1384
+ presentationAnchorId: r?.node.id,
1385
+ presentationAnchorVisible: Dt.current?.showAnchor ?? !1
1384
1386
  });
1385
1387
  const h = /* @__PURE__ */ new Map();
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
+ for (const t of k.nodes) h.set(t.id, t);
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);
1388
1390
  const l = Fe.current;
1389
1391
  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);
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);
1396
1398
  };
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);
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);
1402
1404
  }
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;
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;
1407
1409
  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`;
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`;
1411
1413
  }
1412
1414
  }
1413
- i && l.style.display !== "none" && (l.style.display = "none");
1415
+ o && l.style.display !== "none" && (l.style.display = "none");
1414
1416
  }
1415
- const e = Jt.current;
1417
+ const e = ee.current;
1416
1418
  if (e) {
1417
1419
  e.clear();
1418
- const r = Me.current;
1419
- r && (e.circle(r.wx, r.wy, 10).fill({
1420
+ const t = Wt.current;
1421
+ t && (e.circle(t.wx, t.wy, 10).fill({
1420
1422
  color: 3900150,
1421
1423
  alpha: 0.12
1422
1424
  }).stroke({
1423
1425
  color: 3900150,
1424
1426
  width: 1.5,
1425
1427
  alpha: 0.5
1426
- }), e.circle(r.wx, r.wy, 4).fill({
1428
+ }), e.circle(t.wx, t.wy, 4).fill({
1427
1429
  color: 3900150,
1428
1430
  alpha: 0.9
1429
1431
  }));
1430
- const i = Re.current;
1431
- i && !r && (e.circle(i.worldX, i.worldY, 10).fill({
1432
+ const o = Yt.current;
1433
+ o && !t && (e.circle(o.worldX, o.worldY, 10).fill({
1432
1434
  color: 16347926,
1433
1435
  alpha: 0.12
1434
1436
  }).stroke({
1435
1437
  color: 16347926,
1436
1438
  width: 1.5,
1437
1439
  alpha: 0.5
1438
- }), e.circle(i.worldX, i.worldY, 4).fill({
1440
+ }), e.circle(o.worldX, o.worldY, 4).fill({
1439
1441
  color: 16347926,
1440
1442
  alpha: 0.9
1441
1443
  }));
1442
1444
  }
1443
- const I = te.current;
1445
+ const I = re.current;
1444
1446
  if (I) {
1445
1447
  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([{
1448
+ const t = de.current;
1449
+ if (t) {
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([{
1449
1451
  id: "__ghost__",
1450
- type: r.type,
1452
+ type: t.type,
1451
1453
  position: {
1452
1454
  x: n,
1453
- y: v
1455
+ y: d
1454
1456
  },
1455
- width: r.width,
1456
- height: r.height,
1457
+ width: t.width,
1458
+ height: t.height,
1457
1459
  data: {}
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,
1460
+ }], k.nodes);
1461
+ Gt.current = w.guides, I.position.set(n + w.dx, d + w.dy), (an[t.type] ?? an.shapeRect)(I, {
1462
+ width: t.width,
1463
+ height: t.height,
1462
1464
  fill: "#3b82f6",
1463
1465
  stroke: "#3b82f6",
1464
1466
  strokeWidth: 1.5,
1465
- borderStyle: r.data.borderStyle
1467
+ borderStyle: t.data.borderStyle
1466
1468
  });
1467
1469
  } else
1468
- I.position.set(0, 0), !st.current?.active && !xt.current?.active && (Lt.current = []);
1470
+ I.position.set(0, 0), !it.current?.active && !xt.current?.active && (Gt.current = []);
1469
1471
  }
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({
1472
+ const y = ne.current;
1473
+ if (y && (y.clear(), R.edgeIds.size > 0 && se.current === "select")) {
1474
+ const t = 1 / p.zoom;
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({
1477
1479
  color: 16347926,
1478
- width: 1.5 * r
1479
- }), p.circle(a.tx, a.ty, 5 * r).fill({ color: 16777215 }).stroke({
1480
+ width: 1.5 * t
1481
+ }), y.circle(a.tx, a.ty, 5 * t).fill({ color: 16777215 }).stroke({
1480
1482
  color: 16347926,
1481
- width: 1.5 * r
1483
+ width: 1.5 * t
1482
1484
  }));
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({
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({
1485
1487
  color: 3900150,
1486
- width: 1.5 * r
1488
+ width: 1.5 * t
1487
1489
  });
1488
- if (i.type === "simplebezier") {
1489
- const n = St(i, h);
1490
+ if (o.type === "simplebezier") {
1491
+ const n = St(o, h);
1490
1492
  if (!n) continue;
1491
- const v = o ?? [], g = [
1493
+ const d = i ?? [], w = [
1492
1494
  {
1493
1495
  x: n.sx,
1494
1496
  y: n.sy
1495
1497
  },
1496
- ...v,
1498
+ ...d,
1497
1499
  {
1498
1500
  x: n.tx,
1499
1501
  y: n.ty
1500
1502
  }
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({
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({
1505
1507
  color: 10265519,
1506
- width: 1 * r
1507
- }), p.moveTo(F.x, F.y).lineTo(sn, cn).stroke({
1508
+ width: 1 * t
1509
+ }), y.moveTo(b.x, b.y).lineTo(sn, cn).stroke({
1508
1510
  color: 10265519,
1509
- width: 1 * r
1511
+ width: 1 * t
1510
1512
  });
1511
- const dn = 4 * r;
1512
- p.circle(Xt, on, dn).fill({ color: 16777215 }).stroke({
1513
+ const dn = 4 * t;
1514
+ y.circle(Ft, on, dn).fill({ color: 16777215 }).stroke({
1513
1515
  color: 3900150,
1514
- width: 1.5 * r
1515
- }), p.circle(sn, cn, dn).fill({ color: 16777215 }).stroke({
1516
+ width: 1.5 * t
1517
+ }), y.circle(sn, cn, dn).fill({ color: 16777215 }).stroke({
1516
1518
  color: 3900150,
1517
- width: 1.5 * r
1519
+ width: 1.5 * t
1518
1520
  });
1519
1521
  }
1520
1522
  }
1521
1523
  }
1522
1524
  }
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({
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({
1529
1531
  color: 3900150,
1530
1532
  width: 1.5
1531
1533
  });
1532
- const m = 7, E = m / 2, u = [
1533
- [o, n],
1534
- [o + v, n],
1535
- [o + v, n + g],
1536
- [o, n + g]
1534
+ const g = 7, z = g / 2, C = [
1535
+ [i, n],
1536
+ [i + d, n],
1537
+ [i + d, n + w],
1538
+ [i, n + w]
1537
1539
  ];
1538
- for (const [B, at] of u) t.rect(B - E, at - E, m, m).fill({ color: 16777215 }).stroke({
1540
+ for (const [_, J] of C) v.rect(_ - z, J - z, g, g).fill({ color: 16777215 }).stroke({
1539
1541
  color: 3900150,
1540
1542
  width: 1.5
1541
1543
  });
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]
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]
1547
1549
  ];
1548
- for (const [B, at] of F) t.circle(B, at, w).fill({
1550
+ for (const [_, J] of b) v.circle(_, J, u).fill({
1549
1551
  color: 3900150,
1550
1552
  alpha: 0.9
1551
1553
  });
1552
- if (!Ut.current) {
1553
- const B = o + v / 2, at = n - vn;
1554
- t.moveTo(B, n).lineTo(B, at).stroke({
1554
+ if (!Jt.current) {
1555
+ const _ = i + d / 2, J = n - vn;
1556
+ v.moveTo(_, n).lineTo(_, J).stroke({
1555
1557
  color: 3900150,
1556
1558
  width: 1.5,
1557
1559
  alpha: 0.85
1558
- }), t.circle(B, at, 6).fill({ color: 16777215 }).stroke({
1560
+ }), v.circle(_, J, 6).fill({ color: 16777215 }).stroke({
1559
1561
  color: 3900150,
1560
1562
  width: 1.5
1561
- }), t.circle(B, at, 2.5).fill({ color: 3900150 });
1563
+ }), v.circle(_, J, 2.5).fill({ color: 3900150 });
1562
1564
  }
1563
1565
  }
1564
1566
  }
1565
1567
  });
1566
1568
  };
1567
1569
  return V(), () => {
1568
- if (L = !0, f && !f.destroyed) try {
1570
+ if (G = !0, f && !f.destroyed) try {
1569
1571
  f.app.stage.removeAllListeners();
1570
1572
  } catch {
1571
1573
  }
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();
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();
1574
1576
  };
1575
- }, [T.current]), Rt(() => {
1576
- const f = Ie.current, L = be.current;
1577
- if (!(!f || !L))
1578
- switch (f.deactivate(), L.deactivate(), $) {
1577
+ }, [D.current]), Rt(() => {
1578
+ const f = Me.current, G = Re.current;
1579
+ if (!(!f || !G))
1580
+ switch (f.deactivate(), G.deactivate(), $) {
1579
1581
  case "freehand":
1580
1582
  f.activate();
1581
1583
  break;
1582
1584
  case "line":
1583
- L.activate("straight");
1585
+ G.activate("straight");
1584
1586
  break;
1585
1587
  case "polyline":
1586
- L.activate("polyline");
1588
+ G.activate("polyline");
1587
1589
  break;
1588
1590
  case "arrow":
1589
- L.activate("arrow");
1591
+ G.activate("arrow");
1590
1592
  break;
1591
1593
  }
1592
1594
  }, [$]), Rt(() => {
1593
- D.current && (D.current.visible = j, D.current.gridSize = tt);
1594
- }, [j, tt]), Rt(() => {
1595
+ H.current && (H.current.visible = j, H.current.gridSize = et);
1596
+ }, [j, et]), Rt(() => {
1595
1597
  const f = M.current;
1596
1598
  if (!f) return;
1597
- const L = 1e-3, _ = (W) => {
1598
- W.preventDefault();
1599
- const K = O.current;
1599
+ const G = 1e-3, F = (Y) => {
1600
+ Y.preventDefault();
1601
+ const K = B.current;
1600
1602
  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);
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);
1603
1605
  };
1604
- return f.addEventListener("wheel", _, { passive: !1 }), () => f.removeEventListener("wheel", _);
1605
- }, [O]), /* @__PURE__ */ ge("div", {
1606
+ return f.addEventListener("wheel", F, { passive: !1 }), () => f.removeEventListener("wheel", F);
1607
+ }, [B]), /* @__PURE__ */ ve("div", {
1606
1608
  style: {
1607
1609
  position: "relative",
1608
1610
  width: "100%",
1609
1611
  height: "100%"
1610
1612
  },
1611
1613
  children: [
1612
- /* @__PURE__ */ Bt("div", {
1614
+ /* @__PURE__ */ Zt("div", {
1613
1615
  ref: M,
1614
1616
  className: "flow-canvas-wrapper",
1615
1617
  tabIndex: -1,
1616
1618
  onContextMenu: (f) => f.preventDefault()
1617
1619
  }),
1618
- ht && Ne && /* @__PURE__ */ Bt("input", {
1620
+ ht && Ne && /* @__PURE__ */ Zt("input", {
1619
1621
  className: "flow-label-editor",
1620
1622
  autoFocus: !0,
1621
1623
  defaultValue: ht.value,
@@ -1630,17 +1632,17 @@ function fr({ onPixiReady: A }) {
1630
1632
  onBlur: (f) => Je(f.target.value),
1631
1633
  onPointerDown: (f) => f.stopPropagation()
1632
1634
  }),
1633
- qt && !Et && /* @__PURE__ */ ge("button", {
1635
+ Ut && !Et && /* @__PURE__ */ ve("button", {
1634
1636
  type: "button",
1635
1637
  className: "flow-esc-button",
1636
- onClick: () => At(null),
1638
+ onClick: () => Lt(null),
1637
1639
  title: "取消连续放置 (Esc)",
1638
- children: [/* @__PURE__ */ Bt("span", {
1640
+ children: [/* @__PURE__ */ Zt("span", {
1639
1641
  "aria-hidden": !0,
1640
1642
  children: "⎋"
1641
1643
  }), " 取消放置 (ESC)"]
1642
1644
  }),
1643
- /* @__PURE__ */ ge("button", {
1645
+ /* @__PURE__ */ ve("button", {
1644
1646
  ref: Fe,
1645
1647
  type: "button",
1646
1648
  className: "flow-delete-button",
@@ -1648,7 +1650,7 @@ function fr({ onPixiReady: A }) {
1648
1650
  onClick: () => Oe.current(),
1649
1651
  title: "删除所选 (Delete)",
1650
1652
  "aria-label": "删除所选",
1651
- children: [/* @__PURE__ */ ge("svg", {
1653
+ children: [/* @__PURE__ */ ve("svg", {
1652
1654
  width: "12",
1653
1655
  height: "12",
1654
1656
  viewBox: "0 0 24 24",
@@ -1659,9 +1661,9 @@ function fr({ onPixiReady: A }) {
1659
1661
  strokeLinejoin: "round",
1660
1662
  "aria-hidden": !0,
1661
1663
  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" })
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" })
1665
1667
  ]
1666
1668
  }), "删除"]
1667
1669
  })