@infinit-canvas/react 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-infinite-canvas.cjs +2 -2
- package/dist/react-infinite-canvas.js +1262 -1254
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
1
|
+
import { jsx as S, jsxs as $t, Fragment as Le } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as tt, useState as Gt, useMemo as St, useEffect as ht, useCallback as F, useContext as qe, createContext as Fn, memo as Zt, useLayoutEffect as kr } from "react";
|
|
3
3
|
import { createPortal as Yn } from "react-dom";
|
|
4
4
|
const Un = 160, qn = 60;
|
|
5
5
|
function ho(t) {
|
|
@@ -63,8 +63,8 @@ function jn(t) {
|
|
|
63
63
|
function xo(t, e, n = { x: 0, y: 0, zoom: 1 }, r = !1) {
|
|
64
64
|
const s = e.x, o = e.y, i = e.x + e.width, c = e.y + e.height;
|
|
65
65
|
return t.filter((u) => {
|
|
66
|
-
const { width: l, height:
|
|
67
|
-
return r ?
|
|
66
|
+
const { width: l, height: y } = jn(u), m = u.position.x, C = u.position.y, z = m + l, M = C + y;
|
|
67
|
+
return r ? m < i && z > s && C < c && M > o : m >= s && z <= i && C >= o && M <= c;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
function mo(t) {
|
|
@@ -961,46 +961,46 @@ function Lr({
|
|
|
961
961
|
onConnect: c,
|
|
962
962
|
onNodeClick: u,
|
|
963
963
|
onNodeDragStart: l,
|
|
964
|
-
onNodeDrag:
|
|
965
|
-
onNodeDragStop:
|
|
966
|
-
onEdgeClick:
|
|
967
|
-
onEdgeDoubleClick:
|
|
964
|
+
onNodeDrag: y,
|
|
965
|
+
onNodeDragStop: m,
|
|
966
|
+
onEdgeClick: C,
|
|
967
|
+
onEdgeDoubleClick: z,
|
|
968
968
|
onEdgeMouseEnter: M,
|
|
969
|
-
onEdgeMouseMove:
|
|
969
|
+
onEdgeMouseMove: $,
|
|
970
970
|
onEdgeMouseLeave: k,
|
|
971
|
-
onEdgeContextMenu:
|
|
972
|
-
onNodeDoubleClick:
|
|
971
|
+
onEdgeContextMenu: E,
|
|
972
|
+
onNodeDoubleClick: _,
|
|
973
973
|
onNodeMouseEnter: D,
|
|
974
|
-
onNodeMouseMove:
|
|
974
|
+
onNodeMouseMove: g,
|
|
975
975
|
onNodeMouseLeave: f,
|
|
976
976
|
onNodeContextMenu: p,
|
|
977
|
-
onPaneClick:
|
|
977
|
+
onPaneClick: v,
|
|
978
978
|
onPaneContextMenu: N,
|
|
979
|
-
onPaneMouseEnter:
|
|
979
|
+
onPaneMouseEnter: w,
|
|
980
980
|
onPaneMouseMove: P,
|
|
981
|
-
onPaneMouseLeave:
|
|
982
|
-
onSelectionChange:
|
|
983
|
-
onConnectStart:
|
|
984
|
-
onConnectEnd:
|
|
985
|
-
onInit:
|
|
986
|
-
onMoveStart:
|
|
987
|
-
onMove:
|
|
981
|
+
onPaneMouseLeave: R,
|
|
982
|
+
onSelectionChange: B,
|
|
983
|
+
onConnectStart: q,
|
|
984
|
+
onConnectEnd: X,
|
|
985
|
+
onInit: K,
|
|
986
|
+
onMoveStart: at,
|
|
987
|
+
onMove: rt,
|
|
988
988
|
onMoveEnd: G,
|
|
989
989
|
onDelete: j,
|
|
990
|
-
onBeforeDelete:
|
|
991
|
-
onError:
|
|
992
|
-
isValidConnection:
|
|
993
|
-
dark:
|
|
994
|
-
gridSize:
|
|
995
|
-
zoomMin:
|
|
996
|
-
zoomMax:
|
|
990
|
+
onBeforeDelete: it,
|
|
991
|
+
onError: dt,
|
|
992
|
+
isValidConnection: ot,
|
|
993
|
+
dark: ft,
|
|
994
|
+
gridSize: It = 40,
|
|
995
|
+
zoomMin: st = 0.1,
|
|
996
|
+
zoomMax: xt = 4,
|
|
997
997
|
initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
|
|
998
|
-
fitView:
|
|
999
|
-
fitViewOptions:
|
|
1000
|
-
nodesDraggable:
|
|
1001
|
-
nodesConnectable:
|
|
1002
|
-
elementsSelectable:
|
|
1003
|
-
multiSelectionKeyCode:
|
|
998
|
+
fitView: gt = !1,
|
|
999
|
+
fitViewOptions: ct,
|
|
1000
|
+
nodesDraggable: zt = !0,
|
|
1001
|
+
nodesConnectable: Rt = !0,
|
|
1002
|
+
elementsSelectable: Lt = !0,
|
|
1003
|
+
multiSelectionKeyCode: wt = "Shift",
|
|
1004
1004
|
selectionOnDrag: ne = !1,
|
|
1005
1005
|
selectionMode: Ie = "partial",
|
|
1006
1006
|
connectionMode: Bt = "loose",
|
|
@@ -1027,7 +1027,7 @@ function Lr({
|
|
|
1027
1027
|
elevateNodesOnSelect: hn = !1,
|
|
1028
1028
|
edgeRouting: fe = !0
|
|
1029
1029
|
} = {}) {
|
|
1030
|
-
const
|
|
1030
|
+
const mt = tt(null), Te = tt(null), Et = tt(null), pt = tt({ ...Nt }), se = tt([...t]), Z = tt([...e]), Pt = tt([...n]), yn = tt(/* @__PURE__ */ new Map()), Se = tt(!1), te = tt(null), [gn, pn] = Gt(!1), _t = tt(null), Wt = tt(null), Me = tt(null), ie = tt(null), Ut = tt(!1), Re = tt(null), [Be, Je] = Gt({ x: Nt.x, y: Nt.y, zoom: Nt.zoom }), [Ve, ae] = Gt(null), Kt = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = tt(!1), O = tt({});
|
|
1031
1031
|
O.current = {
|
|
1032
1032
|
onHudUpdate: r,
|
|
1033
1033
|
onNodesProcessed: s,
|
|
@@ -1036,37 +1036,37 @@ function Lr({
|
|
|
1036
1036
|
onConnect: c,
|
|
1037
1037
|
onNodeClick: u,
|
|
1038
1038
|
onNodeDragStart: l,
|
|
1039
|
-
onNodeDrag:
|
|
1040
|
-
onNodeDragStop:
|
|
1041
|
-
onEdgeClick:
|
|
1042
|
-
onEdgeDoubleClick:
|
|
1039
|
+
onNodeDrag: y,
|
|
1040
|
+
onNodeDragStop: m,
|
|
1041
|
+
onEdgeClick: C,
|
|
1042
|
+
onEdgeDoubleClick: z,
|
|
1043
1043
|
onEdgeMouseEnter: M,
|
|
1044
|
-
onEdgeMouseMove:
|
|
1044
|
+
onEdgeMouseMove: $,
|
|
1045
1045
|
onEdgeMouseLeave: k,
|
|
1046
|
-
onEdgeContextMenu:
|
|
1047
|
-
onNodeDoubleClick:
|
|
1046
|
+
onEdgeContextMenu: E,
|
|
1047
|
+
onNodeDoubleClick: _,
|
|
1048
1048
|
onNodeMouseEnter: D,
|
|
1049
|
-
onNodeMouseMove:
|
|
1049
|
+
onNodeMouseMove: g,
|
|
1050
1050
|
onNodeMouseLeave: f,
|
|
1051
1051
|
onNodeContextMenu: p,
|
|
1052
|
-
onPaneClick:
|
|
1052
|
+
onPaneClick: v,
|
|
1053
1053
|
onPaneContextMenu: N,
|
|
1054
|
-
onPaneMouseEnter:
|
|
1054
|
+
onPaneMouseEnter: w,
|
|
1055
1055
|
onPaneMouseMove: P,
|
|
1056
|
-
onPaneMouseLeave:
|
|
1057
|
-
onSelectionChange:
|
|
1058
|
-
onConnectStart:
|
|
1059
|
-
onConnectEnd:
|
|
1060
|
-
onInit:
|
|
1061
|
-
onMoveStart:
|
|
1062
|
-
onMove:
|
|
1056
|
+
onPaneMouseLeave: R,
|
|
1057
|
+
onSelectionChange: B,
|
|
1058
|
+
onConnectStart: q,
|
|
1059
|
+
onConnectEnd: X,
|
|
1060
|
+
onInit: K,
|
|
1061
|
+
onMoveStart: at,
|
|
1062
|
+
onMove: rt,
|
|
1063
1063
|
onMoveEnd: G,
|
|
1064
1064
|
onDelete: j,
|
|
1065
|
-
onBeforeDelete:
|
|
1066
|
-
onError:
|
|
1067
|
-
isValidConnection:
|
|
1065
|
+
onBeforeDelete: it,
|
|
1066
|
+
onError: dt,
|
|
1067
|
+
isValidConnection: ot
|
|
1068
1068
|
};
|
|
1069
|
-
const
|
|
1069
|
+
const bt = { get current() {
|
|
1070
1070
|
return O.current.onNodesChange;
|
|
1071
1071
|
} }, Dt = { get current() {
|
|
1072
1072
|
return O.current.onEdgesChange;
|
|
@@ -1074,9 +1074,9 @@ function Lr({
|
|
|
1074
1074
|
return O.current.onConnect;
|
|
1075
1075
|
} }, De = { get current() {
|
|
1076
1076
|
return O.current.onNodeClick;
|
|
1077
|
-
} }, He = { get current() {
|
|
1078
|
-
return O.current.onNodeDragStart;
|
|
1079
1077
|
} }, Ae = { get current() {
|
|
1078
|
+
return O.current.onNodeDragStart;
|
|
1079
|
+
} }, He = { get current() {
|
|
1080
1080
|
return O.current.onNodeDrag;
|
|
1081
1081
|
} }, _e = { get current() {
|
|
1082
1082
|
return O.current.onNodeDragStop;
|
|
@@ -1091,387 +1091,387 @@ function Lr({
|
|
|
1091
1091
|
} }, pe = { get current() {
|
|
1092
1092
|
return O.current.onNodesProcessed;
|
|
1093
1093
|
} };
|
|
1094
|
-
|
|
1094
|
+
ht(() => {
|
|
1095
1095
|
const a = (d) => {
|
|
1096
|
-
d.key ===
|
|
1097
|
-
},
|
|
1098
|
-
d.key ===
|
|
1096
|
+
d.key === wt && (Ut.current = !0), d.key === we && (ke.current = !0);
|
|
1097
|
+
}, x = (d) => {
|
|
1098
|
+
d.key === wt && (Ut.current = !1), d.key === we && (ke.current = !1);
|
|
1099
1099
|
};
|
|
1100
|
-
return window.addEventListener("keydown", a), window.addEventListener("keyup",
|
|
1101
|
-
window.removeEventListener("keydown", a), window.removeEventListener("keyup",
|
|
1100
|
+
return window.addEventListener("keydown", a), window.addEventListener("keyup", x), () => {
|
|
1101
|
+
window.removeEventListener("keydown", a), window.removeEventListener("keyup", x);
|
|
1102
1102
|
};
|
|
1103
|
-
}, [
|
|
1103
|
+
}, [wt, we]);
|
|
1104
1104
|
const Jt = F(() => {
|
|
1105
|
-
var
|
|
1106
|
-
const a = Z.current.filter((
|
|
1107
|
-
(
|
|
1108
|
-
for (const
|
|
1105
|
+
var b;
|
|
1106
|
+
const a = Z.current.filter((L) => L.selected), x = Pt.current.filter((L) => L.selected), d = { nodes: a, edges: x };
|
|
1107
|
+
(b = ye.current) == null || b.call(ye, d);
|
|
1108
|
+
for (const L of he) L(d);
|
|
1109
1109
|
}, [he]);
|
|
1110
|
-
|
|
1110
|
+
ht(() => {
|
|
1111
1111
|
var a;
|
|
1112
|
-
se.current = [...t], (a =
|
|
1112
|
+
se.current = [...t], (a = Et.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
|
|
1113
1113
|
}, [t]);
|
|
1114
1114
|
const ze = F((a) => {
|
|
1115
|
-
const
|
|
1116
|
-
for (const d of a)
|
|
1115
|
+
const x = {};
|
|
1116
|
+
for (const d of a) x[d.id] = d;
|
|
1117
1117
|
return a.map((d) => {
|
|
1118
1118
|
if (!d.parentId) return d;
|
|
1119
|
-
const
|
|
1120
|
-
if (!
|
|
1121
|
-
let
|
|
1119
|
+
const b = x[d.parentId];
|
|
1120
|
+
if (!b) return d;
|
|
1121
|
+
let L = d.position.x, I = d.position.y, h = b;
|
|
1122
1122
|
for (; h; )
|
|
1123
|
-
|
|
1124
|
-
return { ...d, _absolutePosition: { x:
|
|
1123
|
+
L += h.position.x, I += h.position.y, h = h.parentId ? x[h.parentId] : null;
|
|
1124
|
+
return { ...d, _absolutePosition: { x: L, y: I } };
|
|
1125
1125
|
});
|
|
1126
|
-
}, []), ee =
|
|
1127
|
-
const
|
|
1128
|
-
if (!
|
|
1126
|
+
}, []), ee = tt([]), Q = F((a) => {
|
|
1127
|
+
const x = yn.current;
|
|
1128
|
+
if (!x || x.size === 0) return a;
|
|
1129
1129
|
const d = {};
|
|
1130
|
-
for (const [,
|
|
1131
|
-
d[
|
|
1132
|
-
return a.map((
|
|
1133
|
-
const
|
|
1134
|
-
return
|
|
1130
|
+
for (const [, b] of x)
|
|
1131
|
+
d[b.nodeId] || (d[b.nodeId] = []), d[b.nodeId].push({ id: b.id, type: b.type, position: b.position, x: b.x, y: b.y });
|
|
1132
|
+
return a.map((b) => {
|
|
1133
|
+
const L = d[b.id];
|
|
1134
|
+
return L && L.length > 0 ? { ...b, handles: L } : b;
|
|
1135
1135
|
});
|
|
1136
1136
|
}, []), Ft = F(() => {
|
|
1137
|
-
var
|
|
1137
|
+
var x;
|
|
1138
1138
|
if (_t.current) return;
|
|
1139
1139
|
const a = Q(ee.current);
|
|
1140
|
-
(
|
|
1140
|
+
(x = Et.current) == null || x.postMessage({ type: "nodes", data: { nodes: a } });
|
|
1141
1141
|
}, [Q]);
|
|
1142
|
-
|
|
1142
|
+
ht(() => {
|
|
1143
1143
|
var d;
|
|
1144
1144
|
if (_t.current) {
|
|
1145
|
-
const
|
|
1145
|
+
const b = _t.current.id, L = /* @__PURE__ */ new Set([b, ..._t.current.selectedStarts.map((h) => h.id)]), I = {};
|
|
1146
1146
|
for (const h of Z.current)
|
|
1147
|
-
|
|
1147
|
+
L.has(h.id) && (I[h.id] = { ...h.position });
|
|
1148
1148
|
Z.current = [...e];
|
|
1149
1149
|
for (const h of Z.current)
|
|
1150
|
-
|
|
1150
|
+
I[h.id] && (h.position = I[h.id]);
|
|
1151
1151
|
ee.current = ze(Z.current);
|
|
1152
1152
|
return;
|
|
1153
1153
|
}
|
|
1154
1154
|
Z.current = [...e];
|
|
1155
1155
|
const a = ze(e);
|
|
1156
1156
|
ee.current = a;
|
|
1157
|
-
const
|
|
1158
|
-
(d =
|
|
1159
|
-
}, [e, ze, Q]),
|
|
1157
|
+
const x = Q(a);
|
|
1158
|
+
(d = Et.current) == null || d.postMessage({ type: "nodes", data: { nodes: x } });
|
|
1159
|
+
}, [e, ze, Q]), ht(() => {
|
|
1160
1160
|
var a;
|
|
1161
|
-
Pt.current = [...n], (a =
|
|
1161
|
+
Pt.current = [...n], (a = Et.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
|
|
1162
1162
|
}, [n]);
|
|
1163
|
-
const
|
|
1164
|
-
const d =
|
|
1163
|
+
const lt = F((a, x) => {
|
|
1164
|
+
const d = mt.current;
|
|
1165
1165
|
if (!d) return { x: 0, y: 0 };
|
|
1166
|
-
const
|
|
1166
|
+
const b = d.getBoundingClientRect(), L = pt.current;
|
|
1167
1167
|
return {
|
|
1168
|
-
x: (a -
|
|
1169
|
-
y: (
|
|
1168
|
+
x: (a - b.left - L.x) / L.zoom,
|
|
1169
|
+
y: (x - b.top - L.y) / L.zoom
|
|
1170
1170
|
};
|
|
1171
|
-
}, []), Tt = F((a,
|
|
1171
|
+
}, []), Tt = F((a, x) => {
|
|
1172
1172
|
const d = ee.current.length > 0 ? ee.current : Z.current;
|
|
1173
|
-
let
|
|
1174
|
-
for (let
|
|
1175
|
-
const
|
|
1176
|
-
if (
|
|
1177
|
-
const h =
|
|
1178
|
-
if (a >= h.x && a <= h.x + A &&
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1173
|
+
let b = null;
|
|
1174
|
+
for (let L = d.length - 1; L >= 0; L--) {
|
|
1175
|
+
const I = d[L];
|
|
1176
|
+
if (I.hidden) continue;
|
|
1177
|
+
const h = I._absolutePosition || I.position, A = I.width || Vt, T = I.height || jt;
|
|
1178
|
+
if (a >= h.x && a <= h.x + A && x >= h.y && x <= h.y + T) {
|
|
1179
|
+
if (I.type === "group") {
|
|
1180
|
+
b || (b = I);
|
|
1181
1181
|
continue;
|
|
1182
1182
|
}
|
|
1183
|
-
return
|
|
1183
|
+
return I;
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
return
|
|
1187
|
-
}, []), xe = F((a,
|
|
1188
|
-
const d =
|
|
1186
|
+
return b;
|
|
1187
|
+
}, []), xe = F((a, x) => {
|
|
1188
|
+
const d = x.width || Vt, b = x.height || jt;
|
|
1189
1189
|
if (a.x !== void 0 && a.y !== void 0)
|
|
1190
|
-
return { x:
|
|
1190
|
+
return { x: x.position.x + a.x, y: x.position.y + a.y };
|
|
1191
1191
|
switch (a.position || (a.type === "source" ? "right" : "left")) {
|
|
1192
1192
|
case "top":
|
|
1193
|
-
return { x:
|
|
1193
|
+
return { x: x.position.x + d / 2, y: x.position.y };
|
|
1194
1194
|
case "bottom":
|
|
1195
|
-
return { x:
|
|
1195
|
+
return { x: x.position.x + d / 2, y: x.position.y + b };
|
|
1196
1196
|
case "left":
|
|
1197
|
-
return { x:
|
|
1197
|
+
return { x: x.position.x, y: x.position.y + b / 2 };
|
|
1198
1198
|
case "right":
|
|
1199
|
-
return { x:
|
|
1199
|
+
return { x: x.position.x + d, y: x.position.y + b / 2 };
|
|
1200
1200
|
default:
|
|
1201
|
-
return { x:
|
|
1201
|
+
return { x: x.position.x + d, y: x.position.y + b / 2 };
|
|
1202
1202
|
}
|
|
1203
1203
|
}, []), Ee = F((a) => {
|
|
1204
|
-
const
|
|
1205
|
-
return a.handles && a.handles.length > 0 ? a.handles.map((
|
|
1206
|
-
const
|
|
1207
|
-
return { id:
|
|
1204
|
+
const x = a.width || Vt, d = a.height || jt;
|
|
1205
|
+
return a.handles && a.handles.length > 0 ? a.handles.map((b) => {
|
|
1206
|
+
const L = xe(b, a);
|
|
1207
|
+
return { id: b.id || null, type: b.type, x: L.x, y: L.y };
|
|
1208
1208
|
}) : [
|
|
1209
1209
|
{ id: null, type: "target", x: a.position.x, y: a.position.y + d / 2 },
|
|
1210
|
-
{ id: null, type: "source", x: a.position.x +
|
|
1210
|
+
{ id: null, type: "source", x: a.position.x + x, y: a.position.y + d / 2 }
|
|
1211
1211
|
];
|
|
1212
|
-
}, [xe]), tn = F((a,
|
|
1213
|
-
const d = Z.current,
|
|
1214
|
-
for (let
|
|
1215
|
-
const h = d[
|
|
1212
|
+
}, [xe]), tn = F((a, x) => {
|
|
1213
|
+
const d = Z.current, b = pt.current, L = Math.max(Nr, Ot) / b.zoom;
|
|
1214
|
+
for (let I = d.length - 1; I >= 0; I--) {
|
|
1215
|
+
const h = d[I];
|
|
1216
1216
|
if (h.hidden) continue;
|
|
1217
1217
|
const A = Ee(h);
|
|
1218
|
-
for (const
|
|
1219
|
-
if (Math.abs(a -
|
|
1220
|
-
return { nodeId: h.id, handleId:
|
|
1218
|
+
for (const T of A)
|
|
1219
|
+
if (Math.abs(a - T.x) < L && Math.abs(x - T.y) < L)
|
|
1220
|
+
return { nodeId: h.id, handleId: T.id, type: T.type, x: T.x, y: T.y };
|
|
1221
1221
|
}
|
|
1222
1222
|
return null;
|
|
1223
|
-
}, [Ee]), ue = F((a,
|
|
1224
|
-
const
|
|
1225
|
-
for (let
|
|
1226
|
-
const
|
|
1223
|
+
}, [Ee]), ue = F((a, x) => {
|
|
1224
|
+
const b = 8 / pt.current.zoom;
|
|
1225
|
+
for (let L = Pt.current.length - 1; L >= 0; L--) {
|
|
1226
|
+
const I = Pt.current[L], h = Z.current.find((Mt) => Mt.id === I.source), A = Z.current.find((Mt) => Mt.id === I.target);
|
|
1227
1227
|
if (!h || !A) continue;
|
|
1228
|
-
const
|
|
1229
|
-
if (Ir(a,
|
|
1228
|
+
const T = h.width || Vt, Y = h.height || jt, H = A.height || jt, J = h.position.x + T, ut = h.position.y + Y / 2, U = A.position.x, nt = A.position.y + H / 2;
|
|
1229
|
+
if (Ir(a, x, J, ut, U, nt) < b) return I;
|
|
1230
1230
|
}
|
|
1231
1231
|
return null;
|
|
1232
1232
|
}, []);
|
|
1233
|
-
|
|
1234
|
-
const a = Te.current,
|
|
1235
|
-
if (!a || !
|
|
1236
|
-
const d =
|
|
1237
|
-
ee.current =
|
|
1238
|
-
const
|
|
1233
|
+
ht(() => {
|
|
1234
|
+
const a = Te.current, x = mt.current;
|
|
1235
|
+
if (!a || !x) return;
|
|
1236
|
+
const d = x.getBoundingClientRect(), b = ft !== void 0 ? ft : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
|
|
1237
|
+
ee.current = L;
|
|
1238
|
+
const I = Q(L), { worker: h } = Cr(a, {
|
|
1239
1239
|
width: d.width,
|
|
1240
1240
|
height: d.height,
|
|
1241
|
-
camera:
|
|
1241
|
+
camera: pt.current,
|
|
1242
1242
|
cards: se.current,
|
|
1243
|
-
nodes:
|
|
1243
|
+
nodes: I,
|
|
1244
1244
|
edges: Pt.current,
|
|
1245
|
-
dark:
|
|
1246
|
-
gridSize:
|
|
1245
|
+
dark: b,
|
|
1246
|
+
gridSize: It,
|
|
1247
1247
|
edgeRouting: fe
|
|
1248
1248
|
});
|
|
1249
|
-
h.onmessage = (
|
|
1250
|
-
var
|
|
1251
|
-
|
|
1252
|
-
},
|
|
1253
|
-
const A = new ResizeObserver((
|
|
1254
|
-
const { width:
|
|
1255
|
-
h.postMessage({ type: "resize", data: { width:
|
|
1249
|
+
h.onmessage = (H) => {
|
|
1250
|
+
var J, ut;
|
|
1251
|
+
H.data.type === "hud" && ((J = ge.current) == null || J.call(ge, H.data.data)), H.data.type === "ready" && pn(!0), H.data.type === "nodesProcessed" && ((ut = pe.current) == null || ut.call(pe, H.data.data));
|
|
1252
|
+
}, Et.current = h;
|
|
1253
|
+
const A = new ResizeObserver((H) => {
|
|
1254
|
+
const { width: J, height: ut } = H[0].contentRect;
|
|
1255
|
+
h.postMessage({ type: "resize", data: { width: J, height: ut } });
|
|
1256
1256
|
});
|
|
1257
|
-
A.observe(
|
|
1258
|
-
let
|
|
1259
|
-
return
|
|
1260
|
-
A.disconnect(),
|
|
1257
|
+
A.observe(x);
|
|
1258
|
+
let T, Y;
|
|
1259
|
+
return ft === void 0 && (T = matchMedia("(prefers-color-scheme: dark)"), Y = (H) => h.postMessage({ type: "theme", data: { dark: H.matches } }), T.addEventListener("change", Y)), () => {
|
|
1260
|
+
A.disconnect(), T && Y && T.removeEventListener("change", Y), Et.current = null;
|
|
1261
1261
|
};
|
|
1262
|
-
}, []),
|
|
1262
|
+
}, []), ht(() => {
|
|
1263
1263
|
var a;
|
|
1264
|
-
|
|
1265
|
-
}, [
|
|
1264
|
+
ft !== void 0 && ((a = Et.current) == null || a.postMessage({ type: "theme", data: { dark: ft } }));
|
|
1265
|
+
}, [ft]), ht(() => {
|
|
1266
1266
|
var a;
|
|
1267
|
-
(a =
|
|
1267
|
+
(a = Et.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
|
|
1268
1268
|
}, [fe]);
|
|
1269
|
-
const Ln =
|
|
1270
|
-
var
|
|
1271
|
-
const
|
|
1269
|
+
const Ln = tt(0), Ct = F((a = null) => {
|
|
1270
|
+
var b, L, I;
|
|
1271
|
+
const x = pt.current;
|
|
1272
1272
|
if (re) {
|
|
1273
|
-
const h =
|
|
1273
|
+
const h = mt.current;
|
|
1274
1274
|
if (h) {
|
|
1275
|
-
const A = h.getBoundingClientRect(),
|
|
1276
|
-
|
|
1275
|
+
const A = h.getBoundingClientRect(), T = -re[1][0] * x.zoom + A.width, Y = -re[1][1] * x.zoom + A.height, H = -re[0][0] * x.zoom, J = -re[0][1] * x.zoom;
|
|
1276
|
+
x.x = Math.min(H, Math.max(T, x.x)), x.y = Math.min(J, Math.max(Y, x.y));
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
|
-
(
|
|
1280
|
-
const d = { x:
|
|
1281
|
-
(
|
|
1279
|
+
(b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...x } } });
|
|
1280
|
+
const d = { x: x.x, y: x.y, zoom: x.zoom };
|
|
1281
|
+
(I = (L = O.current).onMove) == null || I.call(L, a, d);
|
|
1282
1282
|
for (const h of Kt) h(d);
|
|
1283
1283
|
cancelAnimationFrame(Ln.current), Ln.current = requestAnimationFrame(() => {
|
|
1284
|
-
Je({ x:
|
|
1284
|
+
Je({ x: x.x, y: x.y, zoom: x.zoom });
|
|
1285
1285
|
});
|
|
1286
1286
|
}, [Kt, re]), Ce = F(() => {
|
|
1287
|
-
var d,
|
|
1288
|
-
const a = Wt.current,
|
|
1289
|
-
a &&
|
|
1287
|
+
var d, b;
|
|
1288
|
+
const a = Wt.current, x = Me.current;
|
|
1289
|
+
a && x ? ((d = Et.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: x, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((b = Et.current) == null || b.postMessage({ type: "connecting", data: null }), ae(null));
|
|
1290
1290
|
}, []), Ne = F(() => {
|
|
1291
|
-
var
|
|
1291
|
+
var x, d;
|
|
1292
1292
|
const a = ie.current;
|
|
1293
|
-
a ? (
|
|
1293
|
+
a ? (x = Et.current) == null || x.postMessage({ type: "selectionBox", data: a }) : (d = Et.current) == null || d.postMessage({ type: "selectionBox", data: null });
|
|
1294
1294
|
}, []), dr = F((a) => {
|
|
1295
|
-
var I,
|
|
1296
|
-
const
|
|
1297
|
-
if (
|
|
1298
|
-
const
|
|
1299
|
-
if (Yt && Re.current &&
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1302
|
-
const qt =
|
|
1303
|
-
(O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((
|
|
1295
|
+
var L, I, h, A, T, Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht;
|
|
1296
|
+
const x = Z.current.length > 0, d = lt(a.clientX, a.clientY), b = Ut.current;
|
|
1297
|
+
if (x && Rt) {
|
|
1298
|
+
const W = tn(d.x, d.y);
|
|
1299
|
+
if (Yt && Re.current && W) {
|
|
1300
|
+
const V = Re.current;
|
|
1301
|
+
if (W.nodeId !== V.nodeId) {
|
|
1302
|
+
const qt = V.handleType === "target" ? { source: W.nodeId, target: V.nodeId, sourceHandle: W.handleId || null, targetHandle: V.handleId } : { source: V.nodeId, target: W.nodeId, sourceHandle: V.handleId, targetHandle: W.handleId || null };
|
|
1303
|
+
(O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((L = ce.current) == null || L.call(ce, { ...qt, ...be }));
|
|
1304
1304
|
}
|
|
1305
1305
|
Re.current = null;
|
|
1306
1306
|
return;
|
|
1307
1307
|
}
|
|
1308
|
-
if (Bt === "strict" ?
|
|
1308
|
+
if (Bt === "strict" ? W && W.type === "source" : W != null) {
|
|
1309
1309
|
if (Yt) {
|
|
1310
|
-
Re.current = { nodeId:
|
|
1310
|
+
Re.current = { nodeId: W.nodeId, handleId: W.handleId || null, handleType: W.type }, (h = (I = O.current).onConnectStart) == null || h.call(I, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type });
|
|
1311
1311
|
return;
|
|
1312
1312
|
}
|
|
1313
1313
|
Wt.current = {
|
|
1314
|
-
sourceId:
|
|
1315
|
-
sourceHandle:
|
|
1316
|
-
sourceType:
|
|
1317
|
-
startPos: { x:
|
|
1318
|
-
}, Me.current = { x: d.x, y: d.y }, (A =
|
|
1314
|
+
sourceId: W.nodeId,
|
|
1315
|
+
sourceHandle: W.handleId || null,
|
|
1316
|
+
sourceType: W.type,
|
|
1317
|
+
startPos: { x: W.x, y: W.y }
|
|
1318
|
+
}, Me.current = { x: d.x, y: d.y }, (A = mt.current) == null || A.setPointerCapture(a.pointerId), (Y = (T = O.current).onConnectStart) == null || Y.call(T, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type }), Ce();
|
|
1319
1319
|
return;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
if (
|
|
1323
|
-
const
|
|
1324
|
-
if (
|
|
1325
|
-
if (
|
|
1326
|
-
const
|
|
1327
|
-
if (
|
|
1328
|
-
|
|
1329
|
-
else if (!
|
|
1330
|
-
for (const
|
|
1331
|
-
|
|
1322
|
+
if (x) {
|
|
1323
|
+
const W = Tt(d.x, d.y);
|
|
1324
|
+
if (W) {
|
|
1325
|
+
if (bt.current && Lt) {
|
|
1326
|
+
const kt = [];
|
|
1327
|
+
if (b)
|
|
1328
|
+
kt.push({ id: W.id, type: "select", selected: !W.selected });
|
|
1329
|
+
else if (!W.selected) {
|
|
1330
|
+
for (const V of Z.current)
|
|
1331
|
+
V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1332
1332
|
if (Dt.current) {
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1333
|
+
const V = Pt.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1334
|
+
V.length && Dt.current(V);
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
|
-
if (
|
|
1338
|
-
if (
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1341
|
-
{ id:
|
|
1342
|
-
{ type: "add", item: { ...Z.current[
|
|
1337
|
+
if (kt.length) {
|
|
1338
|
+
if (bt.current(kt), hn && !b) {
|
|
1339
|
+
const V = Z.current.findIndex((et) => et.id === W.id);
|
|
1340
|
+
V >= 0 && V < Z.current.length - 1 && bt.current([
|
|
1341
|
+
{ id: W.id, type: "remove" },
|
|
1342
|
+
{ type: "add", item: { ...Z.current[V], selected: !0 } }
|
|
1343
1343
|
]);
|
|
1344
1344
|
}
|
|
1345
1345
|
Jt();
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
if ((
|
|
1349
|
-
const
|
|
1350
|
-
let
|
|
1351
|
-
if (
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1354
|
-
const qt =
|
|
1355
|
-
|
|
1348
|
+
if ((H = De.current) == null || H.call(De, a, W), zt) {
|
|
1349
|
+
const kt = b && W.selected;
|
|
1350
|
+
let V = null;
|
|
1351
|
+
if (W.parentId && W.extent === "parent") {
|
|
1352
|
+
const et = Z.current.find((qt) => qt.id === W.parentId);
|
|
1353
|
+
if (et) {
|
|
1354
|
+
const qt = et.width || Vt, Xe = et.height || jt, en = W.width || ((J = W.measured) == null ? void 0 : J.width) || Vt, Fe = W.height || ((ut = W.measured) == null ? void 0 : ut.height) || jt;
|
|
1355
|
+
V = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
1358
1358
|
if (_t.current = {
|
|
1359
|
-
id:
|
|
1360
|
-
startPos: { ...
|
|
1359
|
+
id: W.id,
|
|
1360
|
+
startPos: { ...W.position },
|
|
1361
1361
|
startMouse: { x: d.x, y: d.y },
|
|
1362
|
-
parentClamp:
|
|
1363
|
-
parentId:
|
|
1364
|
-
selectedStarts:
|
|
1362
|
+
parentClamp: V,
|
|
1363
|
+
parentId: W.parentId || null,
|
|
1364
|
+
selectedStarts: kt ? Z.current.filter((et) => et.selected && et.id !== W.id).map((et) => {
|
|
1365
1365
|
var Xe, en;
|
|
1366
1366
|
let qt = null;
|
|
1367
|
-
if (
|
|
1368
|
-
const Fe = Z.current.find((xn) => xn.id ===
|
|
1367
|
+
if (et.parentId && et.extent === "parent") {
|
|
1368
|
+
const Fe = Z.current.find((xn) => xn.id === et.parentId);
|
|
1369
1369
|
if (Fe) {
|
|
1370
|
-
const xn = Fe.width || Vt, br = Fe.height || jt, Mr =
|
|
1370
|
+
const xn = Fe.width || Vt, br = Fe.height || jt, Mr = et.width || ((Xe = et.measured) == null ? void 0 : Xe.width) || Vt, Rr = et.height || ((en = et.measured) == null ? void 0 : en.height) || jt;
|
|
1371
1371
|
qt = { minX: 0, minY: 0, maxX: xn - Mr, maxY: br - Rr };
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
return { id:
|
|
1374
|
+
return { id: et.id, startPos: { ...et.position }, parentClamp: qt, parentId: et.parentId || null };
|
|
1375
1375
|
}) : []
|
|
1376
|
-
}, (
|
|
1377
|
-
const
|
|
1376
|
+
}, (U = mt.current) == null || U.setPointerCapture(a.pointerId), (nt = Ae.current) == null || nt.call(Ae, a, W), bt.current) {
|
|
1377
|
+
const et = [{ id: W.id, type: "position", dragging: !0 }];
|
|
1378
1378
|
for (const qt of _t.current.selectedStarts)
|
|
1379
|
-
|
|
1380
|
-
|
|
1379
|
+
et.push({ id: qt.id, type: "position", dragging: !0 });
|
|
1380
|
+
bt.current(et);
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
1383
|
return;
|
|
1384
1384
|
}
|
|
1385
1385
|
}
|
|
1386
|
-
if (Pt.current.length > 0 &&
|
|
1387
|
-
const
|
|
1388
|
-
if (
|
|
1386
|
+
if (Pt.current.length > 0 && Lt) {
|
|
1387
|
+
const W = ue(d.x, d.y);
|
|
1388
|
+
if (W) {
|
|
1389
1389
|
if (Dt.current) {
|
|
1390
|
-
const
|
|
1391
|
-
if (
|
|
1392
|
-
|
|
1390
|
+
const kt = [];
|
|
1391
|
+
if (b)
|
|
1392
|
+
kt.push({ id: W.id, type: "select", selected: !W.selected });
|
|
1393
1393
|
else {
|
|
1394
|
-
for (const
|
|
1395
|
-
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1394
|
+
for (const V of Pt.current)
|
|
1395
|
+
V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1396
|
+
if (bt.current) {
|
|
1397
|
+
const V = Z.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1398
|
+
V.length && bt.current(V);
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
|
-
|
|
1401
|
+
kt.length && (Dt.current(kt), Jt());
|
|
1402
1402
|
}
|
|
1403
|
-
(
|
|
1403
|
+
(vt = le.current) == null || vt.call(le, a, W);
|
|
1404
1404
|
return;
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
|
-
if (!
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1407
|
+
if (!b) {
|
|
1408
|
+
const W = Z.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 })), kt = Pt.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 }));
|
|
1409
|
+
W.length && bt.current && bt.current(W), kt.length && Dt.current && Dt.current(kt), (W.length || kt.length) && Jt();
|
|
1410
1410
|
}
|
|
1411
|
-
if ((
|
|
1412
|
-
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (
|
|
1411
|
+
if ((Mt = We.current) == null || Mt.call(We, a), ne || b) {
|
|
1412
|
+
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (At = mt.current) == null || At.setPointerCapture(a.pointerId), Ne();
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
|
-
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt =
|
|
1416
|
-
}, [
|
|
1417
|
-
var d,
|
|
1415
|
+
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = mt.current) == null || Xt.classList.add("dragging"), (Ht = mt.current) == null || Ht.setPointerCapture(a.pointerId);
|
|
1416
|
+
}, [lt, Tt, tn, ue, zt, Rt, Lt, ne, Ce, Ne, Jt]), fr = F((a) => {
|
|
1417
|
+
var d, b;
|
|
1418
1418
|
if (Wt.current) {
|
|
1419
|
-
if (Me.current =
|
|
1420
|
-
const
|
|
1421
|
-
if (
|
|
1422
|
-
const
|
|
1423
|
-
let
|
|
1424
|
-
A < h ?
|
|
1419
|
+
if (Me.current = lt(a.clientX, a.clientY), Ce(), fn) {
|
|
1420
|
+
const L = mt.current;
|
|
1421
|
+
if (L) {
|
|
1422
|
+
const I = L.getBoundingClientRect(), h = 40, A = a.clientX - I.left, T = a.clientY - I.top;
|
|
1423
|
+
let Y = 0, H = 0;
|
|
1424
|
+
A < h ? Y = Qt : A > I.width - h && (Y = -Qt), T < h ? H = Qt : T > I.height - h && (H = -Qt), (Y || H) && (pt.current.x += Y, pt.current.y += H, Ct(a));
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
return;
|
|
1428
1428
|
}
|
|
1429
1429
|
if (ie.current) {
|
|
1430
|
-
ie.current.endWorld =
|
|
1431
|
-
const
|
|
1432
|
-
if (
|
|
1433
|
-
const
|
|
1434
|
-
for (const
|
|
1435
|
-
if (
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1430
|
+
ie.current.endWorld = lt(a.clientX, a.clientY), Ne();
|
|
1431
|
+
const L = ie.current, I = Math.min(L.startWorld.x, L.endWorld.x), h = Math.min(L.startWorld.y, L.endWorld.y), A = Math.max(L.startWorld.x, L.endWorld.x), T = Math.max(L.startWorld.y, L.endWorld.y);
|
|
1432
|
+
if (bt.current) {
|
|
1433
|
+
const Y = [];
|
|
1434
|
+
for (const H of Z.current) {
|
|
1435
|
+
if (H.hidden) continue;
|
|
1436
|
+
const J = H.width || Vt, ut = H.height || jt, U = Ie === "full" ? H.position.x >= I && H.position.x + J <= A && H.position.y >= h && H.position.y + ut <= T : H.position.x + J > I && H.position.x < A && H.position.y + ut > h && H.position.y < T;
|
|
1437
|
+
U !== !!H.selected && Y.push({ id: H.id, type: "select", selected: U });
|
|
1438
1438
|
}
|
|
1439
|
-
|
|
1439
|
+
Y.length && bt.current(Y);
|
|
1440
1440
|
}
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
1443
1443
|
if (_t.current) {
|
|
1444
|
-
const
|
|
1445
|
-
let
|
|
1446
|
-
if (me && (
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1444
|
+
const L = lt(a.clientX, a.clientY), I = _t.current, h = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
|
|
1445
|
+
let T = { x: I.startPos.x + h, y: I.startPos.y + A };
|
|
1446
|
+
if (me && (T = Pn(T, de)), oe && (T = Tn(T, oe)), I.parentClamp) {
|
|
1447
|
+
const U = I.parentClamp;
|
|
1448
|
+
T = { x: Math.max(U.minX, Math.min(T.x, U.maxX)), y: Math.max(U.minY, Math.min(T.y, U.maxY)) };
|
|
1449
1449
|
}
|
|
1450
|
-
const
|
|
1451
|
-
for (const
|
|
1452
|
-
let nt = { x:
|
|
1453
|
-
if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)),
|
|
1454
|
-
const
|
|
1455
|
-
nt = { x: Math.max(
|
|
1450
|
+
const Y = [{ id: I.id, position: T }];
|
|
1451
|
+
for (const U of I.selectedStarts) {
|
|
1452
|
+
let nt = { x: U.startPos.x + h, y: U.startPos.y + A };
|
|
1453
|
+
if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), U.parentClamp) {
|
|
1454
|
+
const vt = U.parentClamp;
|
|
1455
|
+
nt = { x: Math.max(vt.minX, Math.min(nt.x, vt.maxX)), y: Math.max(vt.minY, Math.min(nt.y, vt.maxY)) };
|
|
1456
1456
|
}
|
|
1457
|
-
|
|
1457
|
+
Y.push({ id: U.id, position: nt });
|
|
1458
1458
|
}
|
|
1459
|
-
const
|
|
1460
|
-
for (const
|
|
1461
|
-
const nt = Z.current.find((
|
|
1459
|
+
const H = [];
|
|
1460
|
+
for (const U of Y) {
|
|
1461
|
+
const nt = Z.current.find((vt) => vt.id === U.id);
|
|
1462
1462
|
if (nt) {
|
|
1463
|
-
nt.position =
|
|
1464
|
-
let
|
|
1463
|
+
nt.position = U.position, nt.dragging = !0;
|
|
1464
|
+
let vt = U.position;
|
|
1465
1465
|
if (nt.parentId) {
|
|
1466
|
-
let
|
|
1467
|
-
for (;
|
|
1468
|
-
|
|
1469
|
-
|
|
1466
|
+
let Mt = Z.current.find((Ht) => Ht.id === nt.parentId), At = U.position.x, Xt = U.position.y;
|
|
1467
|
+
for (; Mt; )
|
|
1468
|
+
At += Mt.position.x, Xt += Mt.position.y, Mt = Mt.parentId ? Z.current.find((Ht) => Ht.id === Mt.parentId) : null;
|
|
1469
|
+
vt = { x: At, y: Xt };
|
|
1470
1470
|
}
|
|
1471
|
-
|
|
1472
|
-
id:
|
|
1473
|
-
position:
|
|
1474
|
-
_absolutePosition:
|
|
1471
|
+
H.push({
|
|
1472
|
+
id: U.id,
|
|
1473
|
+
position: U.position,
|
|
1474
|
+
_absolutePosition: vt,
|
|
1475
1475
|
width: nt.width,
|
|
1476
1476
|
height: nt.height,
|
|
1477
1477
|
dragging: !0,
|
|
@@ -1479,43 +1479,43 @@ function Lr({
|
|
|
1479
1479
|
});
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
|
-
const
|
|
1483
|
-
for (const
|
|
1484
|
-
if (
|
|
1485
|
-
let nt = Z.current.find((
|
|
1482
|
+
const J = new Set(Y.map((U) => U.id));
|
|
1483
|
+
for (const U of Z.current)
|
|
1484
|
+
if (U.parentId && J.has(U.parentId) && !J.has(U.id)) {
|
|
1485
|
+
let nt = Z.current.find((At) => At.id === U.parentId), vt = U.position.x, Mt = U.position.y;
|
|
1486
1486
|
for (; nt; )
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
id:
|
|
1490
|
-
position:
|
|
1491
|
-
_absolutePosition: { x:
|
|
1492
|
-
width:
|
|
1493
|
-
height:
|
|
1487
|
+
vt += nt.position.x, Mt += nt.position.y, nt = nt.parentId ? Z.current.find((At) => At.id === nt.parentId) : null;
|
|
1488
|
+
H.push({
|
|
1489
|
+
id: U.id,
|
|
1490
|
+
position: U.position,
|
|
1491
|
+
_absolutePosition: { x: vt, y: Mt },
|
|
1492
|
+
width: U.width,
|
|
1493
|
+
height: U.height,
|
|
1494
1494
|
dragging: !1,
|
|
1495
|
-
selected:
|
|
1495
|
+
selected: U.selected
|
|
1496
1496
|
});
|
|
1497
1497
|
}
|
|
1498
|
-
if ((d =
|
|
1499
|
-
const
|
|
1500
|
-
if (
|
|
1501
|
-
const nt =
|
|
1502
|
-
let Xt = 0,
|
|
1503
|
-
|
|
1498
|
+
if ((d = Et.current) == null || d.postMessage({ type: "nodePositions", data: { updates: H } }), dn) {
|
|
1499
|
+
const U = mt.current;
|
|
1500
|
+
if (U) {
|
|
1501
|
+
const nt = U.getBoundingClientRect(), vt = 40, Mt = a.clientX - nt.left, At = a.clientY - nt.top;
|
|
1502
|
+
let Xt = 0, Ht = 0;
|
|
1503
|
+
Mt < vt ? Xt = Qt : Mt > nt.width - vt && (Xt = -Qt), At < vt ? Ht = Qt : At > nt.height - vt && (Ht = -Qt), (Xt || Ht) && (pt.current.x += Xt, pt.current.y += Ht, Ct(a));
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1506
|
+
const ut = Z.current.find((U) => U.id === I.id);
|
|
1507
|
+
ut && ((b = He.current) == null || b.call(He, a, ut));
|
|
1508
1508
|
return;
|
|
1509
1509
|
}
|
|
1510
1510
|
if (!Se.current) return;
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
}, [
|
|
1514
|
-
var
|
|
1511
|
+
const x = pt.current;
|
|
1512
|
+
x.x += a.clientX - te.current.x, x.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Ct();
|
|
1513
|
+
}, [Ct, lt, Ce, Ne]), hr = F((a) => {
|
|
1514
|
+
var x, d, b, L, I;
|
|
1515
1515
|
if (Wt.current) {
|
|
1516
|
-
const h =
|
|
1516
|
+
const h = lt(a.clientX, a.clientY), A = tn(h.x, h.y);
|
|
1517
1517
|
if (A && A.nodeId !== Wt.current.sourceId && (Bt === "loose" || A.type === "target")) {
|
|
1518
|
-
const
|
|
1518
|
+
const H = Wt.current.sourceType === "target" ? {
|
|
1519
1519
|
source: A.nodeId,
|
|
1520
1520
|
target: Wt.current.sourceId,
|
|
1521
1521
|
sourceHandle: A.handleId || null,
|
|
@@ -1526,9 +1526,9 @@ function Lr({
|
|
|
1526
1526
|
sourceHandle: Wt.current.sourceHandle,
|
|
1527
1527
|
targetHandle: A.handleId || null
|
|
1528
1528
|
};
|
|
1529
|
-
(O.current.isValidConnection ? O.current.isValidConnection(
|
|
1529
|
+
(O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((x = ce.current) == null || x.call(ce, { ...H, ...be }));
|
|
1530
1530
|
}
|
|
1531
|
-
(
|
|
1531
|
+
(b = (d = O.current).onConnectEnd) == null || b.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
|
|
1532
1532
|
return;
|
|
1533
1533
|
}
|
|
1534
1534
|
if (ie.current) {
|
|
@@ -1537,203 +1537,203 @@ function Lr({
|
|
|
1537
1537
|
}
|
|
1538
1538
|
if (_t.current) {
|
|
1539
1539
|
const h = _t.current;
|
|
1540
|
-
if (
|
|
1541
|
-
const
|
|
1540
|
+
if (bt.current) {
|
|
1541
|
+
const T = Z.current.find((H) => H.id === h.id), Y = [{
|
|
1542
1542
|
id: h.id,
|
|
1543
1543
|
type: "position",
|
|
1544
|
-
position:
|
|
1544
|
+
position: T ? { ...T.position } : void 0,
|
|
1545
1545
|
dragging: !1
|
|
1546
1546
|
}];
|
|
1547
|
-
for (const
|
|
1548
|
-
const
|
|
1549
|
-
|
|
1550
|
-
id:
|
|
1547
|
+
for (const H of h.selectedStarts) {
|
|
1548
|
+
const J = Z.current.find((ut) => ut.id === H.id);
|
|
1549
|
+
Y.push({
|
|
1550
|
+
id: H.id,
|
|
1551
1551
|
type: "position",
|
|
1552
|
-
position:
|
|
1552
|
+
position: J ? { ...J.position } : void 0,
|
|
1553
1553
|
dragging: !1
|
|
1554
1554
|
});
|
|
1555
1555
|
}
|
|
1556
|
-
|
|
1556
|
+
bt.current(Y);
|
|
1557
1557
|
}
|
|
1558
1558
|
requestAnimationFrame(() => {
|
|
1559
1559
|
_t.current = null;
|
|
1560
1560
|
});
|
|
1561
|
-
const A = Z.current.find((
|
|
1562
|
-
A && ((
|
|
1561
|
+
const A = Z.current.find((T) => T.id === h.id);
|
|
1562
|
+
A && ((L = _e.current) == null || L.call(_e, a, A));
|
|
1563
1563
|
return;
|
|
1564
1564
|
}
|
|
1565
|
-
Se.current = !1, (
|
|
1566
|
-
}, [
|
|
1567
|
-
|
|
1568
|
-
const a =
|
|
1565
|
+
Se.current = !1, (I = mt.current) == null || I.classList.remove("dragging");
|
|
1566
|
+
}, [lt, tn, Ce, Ne, Jt]);
|
|
1567
|
+
ht(() => {
|
|
1568
|
+
const a = mt.current;
|
|
1569
1569
|
if (!a) return;
|
|
1570
|
-
const
|
|
1570
|
+
const x = (d) => {
|
|
1571
1571
|
Pe && d.preventDefault();
|
|
1572
|
-
const
|
|
1572
|
+
const b = pt.current;
|
|
1573
1573
|
if (Ge || ke.current) {
|
|
1574
|
-
const
|
|
1575
|
-
$e === "horizontal" ?
|
|
1574
|
+
const T = Ze;
|
|
1575
|
+
$e === "horizontal" ? b.x -= d.deltaY * T : ($e === "vertical" || (b.x -= d.deltaX * T), b.y -= d.deltaY * T), Ct(d);
|
|
1576
1576
|
return;
|
|
1577
1577
|
}
|
|
1578
1578
|
if (!Oe) return;
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1579
|
+
const L = d.deltaY > 0 ? 0.92 : 1.08, I = a.getBoundingClientRect(), h = d.clientX - I.left, A = d.clientY - I.top;
|
|
1580
|
+
b.x = h - (h - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(xt, Math.max(st, b.zoom * L)), Ct(d);
|
|
1581
1581
|
};
|
|
1582
|
-
return a.addEventListener("wheel",
|
|
1583
|
-
}, [
|
|
1582
|
+
return a.addEventListener("wheel", x, { passive: !Pe }), () => a.removeEventListener("wheel", x);
|
|
1583
|
+
}, [Ct, st, xt, Ge, $e, Ze, Oe, Pe]), ht(() => {
|
|
1584
1584
|
if (!Ke) return;
|
|
1585
|
-
const a =
|
|
1585
|
+
const a = mt.current;
|
|
1586
1586
|
if (!a) return;
|
|
1587
|
-
let
|
|
1588
|
-
const
|
|
1587
|
+
let x = 0, d = null;
|
|
1588
|
+
const b = (h) => {
|
|
1589
1589
|
if (h.touches.length === 2) {
|
|
1590
|
-
const A = h.touches[0].clientX - h.touches[1].clientX,
|
|
1591
|
-
|
|
1592
|
-
const
|
|
1590
|
+
const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY;
|
|
1591
|
+
x = Math.hypot(A, T);
|
|
1592
|
+
const Y = a.getBoundingClientRect();
|
|
1593
1593
|
d = {
|
|
1594
|
-
x: (h.touches[0].clientX + h.touches[1].clientX) / 2 -
|
|
1595
|
-
y: (h.touches[0].clientY + h.touches[1].clientY) / 2 -
|
|
1594
|
+
x: (h.touches[0].clientX + h.touches[1].clientX) / 2 - Y.left,
|
|
1595
|
+
y: (h.touches[0].clientY + h.touches[1].clientY) / 2 - Y.top
|
|
1596
1596
|
}, h.preventDefault();
|
|
1597
1597
|
}
|
|
1598
|
-
},
|
|
1599
|
-
if (h.touches.length === 2 &&
|
|
1598
|
+
}, L = (h) => {
|
|
1599
|
+
if (h.touches.length === 2 && x > 0) {
|
|
1600
1600
|
h.preventDefault();
|
|
1601
|
-
const A = h.touches[0].clientX - h.touches[1].clientX,
|
|
1602
|
-
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1601
|
+
const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY, Y = Math.hypot(A, T), H = Y / x;
|
|
1602
|
+
x = Y;
|
|
1603
|
+
const J = pt.current, ut = d.x, U = d.y;
|
|
1604
|
+
J.x = ut - (ut - J.x) * H, J.y = U - (U - J.y) * H, J.zoom = Math.min(xt, Math.max(st, J.zoom * H)), Ct(h);
|
|
1605
1605
|
}
|
|
1606
|
-
},
|
|
1607
|
-
|
|
1606
|
+
}, I = () => {
|
|
1607
|
+
x = 0, d = null;
|
|
1608
1608
|
};
|
|
1609
|
-
return a.addEventListener("touchstart",
|
|
1610
|
-
a.removeEventListener("touchstart",
|
|
1609
|
+
return a.addEventListener("touchstart", b, { passive: !1 }), a.addEventListener("touchmove", L, { passive: !1 }), a.addEventListener("touchend", I), () => {
|
|
1610
|
+
a.removeEventListener("touchstart", b), a.removeEventListener("touchmove", L), a.removeEventListener("touchend", I);
|
|
1611
1611
|
};
|
|
1612
|
-
}, [Ke,
|
|
1612
|
+
}, [Ke, Ct, st, xt]), ht(() => {
|
|
1613
1613
|
if (!Qe) return;
|
|
1614
|
-
const a =
|
|
1614
|
+
const a = mt.current;
|
|
1615
1615
|
if (!a) return;
|
|
1616
|
-
const
|
|
1617
|
-
var
|
|
1618
|
-
const
|
|
1619
|
-
if (Tt(
|
|
1620
|
-
(
|
|
1616
|
+
const x = (d) => {
|
|
1617
|
+
var H, J, ut, U;
|
|
1618
|
+
const b = lt(d.clientX, d.clientY);
|
|
1619
|
+
if (Tt(b.x, b.y)) {
|
|
1620
|
+
(J = (H = O.current).onNodeDoubleClick) == null || J.call(H, d, Tt(b.x, b.y));
|
|
1621
1621
|
return;
|
|
1622
1622
|
}
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1625
|
-
(
|
|
1623
|
+
const L = ue(b.x, b.y);
|
|
1624
|
+
if (L) {
|
|
1625
|
+
(U = (ut = O.current).onEdgeDoubleClick) == null || U.call(ut, d, L);
|
|
1626
1626
|
return;
|
|
1627
1627
|
}
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1628
|
+
const I = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, T = d.clientY - h.top, Y = pt.current;
|
|
1629
|
+
Y.x = A - (A - Y.x) * I, Y.y = T - (T - Y.y) * I, Y.zoom = Math.min(xt, Math.max(st, Y.zoom * I)), Ct(d);
|
|
1630
1630
|
};
|
|
1631
|
-
return a.addEventListener("dblclick",
|
|
1632
|
-
}, [Qe,
|
|
1633
|
-
const a =
|
|
1631
|
+
return a.addEventListener("dblclick", x), () => a.removeEventListener("dblclick", x);
|
|
1632
|
+
}, [Qe, Ct, st, xt, lt, Tt, ue]), ht(() => {
|
|
1633
|
+
const a = mt.current;
|
|
1634
1634
|
if (!a) return;
|
|
1635
|
-
const
|
|
1636
|
-
var h, A,
|
|
1637
|
-
const
|
|
1638
|
-
if (
|
|
1639
|
-
(A = (h = O.current).onNodeContextMenu) == null || A.call(h, d,
|
|
1635
|
+
const x = (d) => {
|
|
1636
|
+
var h, A, T, Y, H, J;
|
|
1637
|
+
const b = lt(d.clientX, d.clientY), L = Tt(b.x, b.y);
|
|
1638
|
+
if (L) {
|
|
1639
|
+
(A = (h = O.current).onNodeContextMenu) == null || A.call(h, d, L);
|
|
1640
1640
|
return;
|
|
1641
1641
|
}
|
|
1642
|
-
const
|
|
1643
|
-
if (
|
|
1644
|
-
(
|
|
1642
|
+
const I = ue(b.x, b.y);
|
|
1643
|
+
if (I) {
|
|
1644
|
+
(Y = (T = O.current).onEdgeContextMenu) == null || Y.call(T, d, I);
|
|
1645
1645
|
return;
|
|
1646
1646
|
}
|
|
1647
|
-
(
|
|
1647
|
+
(J = (H = O.current).onPaneContextMenu) == null || J.call(H, d);
|
|
1648
1648
|
};
|
|
1649
|
-
return a.addEventListener("contextmenu",
|
|
1650
|
-
}, [
|
|
1651
|
-
const a =
|
|
1649
|
+
return a.addEventListener("contextmenu", x), () => a.removeEventListener("contextmenu", x);
|
|
1650
|
+
}, [lt, Tt, ue]), ht(() => {
|
|
1651
|
+
const a = mt.current;
|
|
1652
1652
|
if (!a) return;
|
|
1653
|
-
let
|
|
1654
|
-
const
|
|
1655
|
-
var
|
|
1656
|
-
(
|
|
1657
|
-
const A =
|
|
1658
|
-
if (
|
|
1659
|
-
const
|
|
1660
|
-
|
|
1653
|
+
let x = null, d = null;
|
|
1654
|
+
const b = (h) => {
|
|
1655
|
+
var Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht, W, kt, V;
|
|
1656
|
+
(H = (Y = O.current).onPaneMouseMove) == null || H.call(Y, h);
|
|
1657
|
+
const A = lt(h.clientX, h.clientY), T = Tt(A.x, A.y);
|
|
1658
|
+
if (T !== x && (x && ((ut = (J = O.current).onNodeMouseLeave) == null || ut.call(J, h, x)), T && ((nt = (U = O.current).onNodeMouseEnter) == null || nt.call(U, h, T)), x = T), T && ((Mt = (vt = O.current).onNodeMouseMove) == null || Mt.call(vt, h, T)), !T) {
|
|
1659
|
+
const et = ue(A.x, A.y);
|
|
1660
|
+
et !== d && (d && ((Xt = (At = O.current).onEdgeMouseLeave) == null || Xt.call(At, h, d)), et && ((W = (Ht = O.current).onEdgeMouseEnter) == null || W.call(Ht, h, et)), d = et), et && ((V = (kt = O.current).onEdgeMouseMove) == null || V.call(kt, h, et));
|
|
1661
1661
|
}
|
|
1662
|
+
}, L = (h) => {
|
|
1663
|
+
var A, T;
|
|
1664
|
+
return (T = (A = O.current).onPaneMouseEnter) == null ? void 0 : T.call(A, h);
|
|
1662
1665
|
}, I = (h) => {
|
|
1663
|
-
var A,
|
|
1664
|
-
|
|
1665
|
-
}, $ = (h) => {
|
|
1666
|
-
var A, S, U, _, K, it;
|
|
1667
|
-
(S = (A = O.current).onPaneMouseLeave) == null || S.call(A, h), m && ((_ = (U = O.current).onNodeMouseLeave) == null || _.call(U, h, m), m = null), d && ((it = (K = O.current).onEdgeMouseLeave) == null || it.call(K, h, d), d = null);
|
|
1666
|
+
var A, T, Y, H, J, ut;
|
|
1667
|
+
(T = (A = O.current).onPaneMouseLeave) == null || T.call(A, h), x && ((H = (Y = O.current).onNodeMouseLeave) == null || H.call(Y, h, x), x = null), d && ((ut = (J = O.current).onEdgeMouseLeave) == null || ut.call(J, h, d), d = null);
|
|
1668
1668
|
};
|
|
1669
|
-
return a.addEventListener("mousemove",
|
|
1670
|
-
a.removeEventListener("mousemove",
|
|
1669
|
+
return a.addEventListener("mousemove", b), a.addEventListener("mouseenter", L), a.addEventListener("mouseleave", I), () => {
|
|
1670
|
+
a.removeEventListener("mousemove", b), a.removeEventListener("mouseenter", L), a.removeEventListener("mouseleave", I);
|
|
1671
1671
|
};
|
|
1672
|
-
}, [
|
|
1673
|
-
const a = Array.isArray(ve) ? ve : [ve],
|
|
1674
|
-
var
|
|
1672
|
+
}, [lt, Tt, ue]), ht(() => {
|
|
1673
|
+
const a = Array.isArray(ve) ? ve : [ve], x = async (d) => {
|
|
1674
|
+
var b, L;
|
|
1675
1675
|
if (a.includes(d.key)) {
|
|
1676
1676
|
if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA" || d.target.isContentEditable) return;
|
|
1677
|
-
const
|
|
1678
|
-
if (
|
|
1677
|
+
const I = Z.current.filter((T) => T.selected), h = Pt.current.filter((T) => T.selected);
|
|
1678
|
+
if (!I.length && !h.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: I, edges: h }))
|
|
1679
1679
|
return;
|
|
1680
|
-
const A = new Set(
|
|
1681
|
-
if (
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1680
|
+
const A = new Set(I.map((T) => T.id));
|
|
1681
|
+
if (I.length && bt.current && (bt.current(I.map((T) => ({ id: T.id, type: "remove" }))), Dt.current)) {
|
|
1682
|
+
const T = Pt.current.filter((Y) => A.has(Y.source) || A.has(Y.target));
|
|
1683
|
+
T.length && Dt.current(T.map((Y) => ({ id: Y.id, type: "remove" })));
|
|
1684
1684
|
}
|
|
1685
|
-
h.length && Dt.current && Dt.current(h.map((
|
|
1685
|
+
h.length && Dt.current && Dt.current(h.map((T) => ({ id: T.id, type: "remove" }))), (L = (b = O.current).onDelete) == null || L.call(b, { nodes: I, edges: h });
|
|
1686
1686
|
}
|
|
1687
1687
|
if ((d.ctrlKey || d.metaKey) && d.key === "a") {
|
|
1688
1688
|
if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA") return;
|
|
1689
|
-
if (d.preventDefault(),
|
|
1690
|
-
const
|
|
1691
|
-
|
|
1689
|
+
if (d.preventDefault(), bt.current) {
|
|
1690
|
+
const I = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
1691
|
+
I.length && bt.current(I);
|
|
1692
1692
|
}
|
|
1693
1693
|
if (Dt.current) {
|
|
1694
|
-
const
|
|
1695
|
-
|
|
1694
|
+
const I = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
1695
|
+
I.length && Dt.current(I);
|
|
1696
1696
|
}
|
|
1697
1697
|
}
|
|
1698
1698
|
};
|
|
1699
|
-
return window.addEventListener("keydown",
|
|
1699
|
+
return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
|
|
1700
1700
|
}, [ve]);
|
|
1701
|
-
const In =
|
|
1702
|
-
|
|
1703
|
-
var a,
|
|
1704
|
-
if (!In.current &&
|
|
1705
|
-
if (In.current = !0,
|
|
1706
|
-
const d =
|
|
1701
|
+
const In = tt(!1);
|
|
1702
|
+
ht(() => {
|
|
1703
|
+
var a, x;
|
|
1704
|
+
if (!In.current && Et.current) {
|
|
1705
|
+
if (In.current = !0, gt && Z.current.length > 0) {
|
|
1706
|
+
const d = mt.current;
|
|
1707
1707
|
if (d) {
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1708
|
+
const b = d.getBoundingClientRect(), L = (ct == null ? void 0 : ct.padding) ?? 0.1, I = Mn(Z.current), h = Rn(I, b.width, b.height, L);
|
|
1709
|
+
ct != null && ct.maxZoom && (h.zoom = Math.min(h.zoom, ct.maxZoom)), ct != null && ct.minZoom && (h.zoom = Math.max(h.zoom, ct.minZoom)), pt.current = h, Ct();
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
|
-
(
|
|
1712
|
+
(x = (a = O.current).onInit) == null || x.call(a, {
|
|
1713
1713
|
getNodes: () => [...Z.current],
|
|
1714
1714
|
getEdges: () => [...Pt.current],
|
|
1715
|
-
getViewport: () => ({ ...
|
|
1715
|
+
getViewport: () => ({ ...pt.current }),
|
|
1716
1716
|
fitView: (d = {}) => {
|
|
1717
|
-
const
|
|
1718
|
-
if (!
|
|
1719
|
-
const
|
|
1720
|
-
|
|
1717
|
+
const b = mt.current;
|
|
1718
|
+
if (!b || !Z.current.length) return;
|
|
1719
|
+
const L = b.getBoundingClientRect(), I = Mn(Z.current), h = Rn(I, L.width, L.height, d.padding ?? 0.1);
|
|
1720
|
+
pt.current = h, Ct();
|
|
1721
1721
|
}
|
|
1722
1722
|
});
|
|
1723
1723
|
}
|
|
1724
1724
|
});
|
|
1725
1725
|
const yr = F(() => {
|
|
1726
|
-
|
|
1727
|
-
}, [
|
|
1728
|
-
var
|
|
1726
|
+
pt.current = { ...Nt }, Ct();
|
|
1727
|
+
}, [Ct, Nt]), gr = F((a) => {
|
|
1728
|
+
var x;
|
|
1729
1729
|
if (a)
|
|
1730
1730
|
se.current.push(a);
|
|
1731
1731
|
else {
|
|
1732
|
-
const d =
|
|
1733
|
-
if (!
|
|
1734
|
-
const
|
|
1732
|
+
const d = pt.current, b = mt.current;
|
|
1733
|
+
if (!b) return;
|
|
1734
|
+
const L = b.getBoundingClientRect(), I = Math.round(-d.x / d.zoom + L.width / 2 / d.zoom), h = Math.round(-d.y / d.zoom + L.height / 2 / d.zoom);
|
|
1735
1735
|
se.current.push({
|
|
1736
|
-
x:
|
|
1736
|
+
x: I - 80,
|
|
1737
1737
|
y: h - 45,
|
|
1738
1738
|
w: 160,
|
|
1739
1739
|
h: 90,
|
|
@@ -1741,37 +1741,37 @@ function Lr({
|
|
|
1741
1741
|
body: "Added at viewport center"
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
|
-
(
|
|
1744
|
+
(x = Et.current) == null || x.postMessage({ type: "cards", data: { cards: [...se.current] } });
|
|
1745
1745
|
}, []), pr = F((a) => {
|
|
1746
1746
|
if (a.id || (a.id = "node-" + Date.now()), !a.position) {
|
|
1747
|
-
const
|
|
1747
|
+
const x = pt.current, d = mt.current;
|
|
1748
1748
|
if (!d) return;
|
|
1749
|
-
const
|
|
1749
|
+
const b = d.getBoundingClientRect();
|
|
1750
1750
|
a.position = {
|
|
1751
|
-
x: Math.round(-
|
|
1752
|
-
y: Math.round(-
|
|
1751
|
+
x: Math.round(-x.x / x.zoom + b.width / 2 / x.zoom) - Vt / 2,
|
|
1752
|
+
y: Math.round(-x.y / x.zoom + b.height / 2 / x.zoom) - jt / 2
|
|
1753
1753
|
};
|
|
1754
1754
|
}
|
|
1755
|
-
a.data || (a.data = { label: a.id }),
|
|
1756
|
-
}, []), xr = F(() => ({ ...
|
|
1757
|
-
|
|
1758
|
-
}, [
|
|
1759
|
-
wrapRef:
|
|
1755
|
+
a.data || (a.data = { label: a.id }), bt.current && bt.current([{ type: "add", item: a }]);
|
|
1756
|
+
}, []), xr = F(() => ({ ...pt.current }), []), mr = F((a) => {
|
|
1757
|
+
pt.current = { ...pt.current, ...a }, Ct();
|
|
1758
|
+
}, [Ct]), vr = F((a) => lt(a.x, a.y), [lt]), $n = n, wr = St(() => ({
|
|
1759
|
+
wrapRef: mt,
|
|
1760
1760
|
canvasRef: Te,
|
|
1761
|
-
workerRef:
|
|
1762
|
-
cameraRef:
|
|
1761
|
+
workerRef: Et,
|
|
1762
|
+
cameraRef: pt,
|
|
1763
1763
|
nodesRef: Z,
|
|
1764
1764
|
edgesRef: Pt,
|
|
1765
1765
|
handleRegistryRef: yn,
|
|
1766
1766
|
syncNodesToWorker: Ft,
|
|
1767
|
-
onNodesChangeRef:
|
|
1767
|
+
onNodesChangeRef: bt,
|
|
1768
1768
|
onEdgesChangeRef: Dt,
|
|
1769
|
-
sendCamera:
|
|
1770
|
-
screenToWorld:
|
|
1769
|
+
sendCamera: Ct,
|
|
1770
|
+
screenToWorld: lt,
|
|
1771
1771
|
viewportListeners: Kt,
|
|
1772
1772
|
selectionListeners: he,
|
|
1773
|
-
zoomMin:
|
|
1774
|
-
zoomMax:
|
|
1773
|
+
zoomMin: st,
|
|
1774
|
+
zoomMax: xt,
|
|
1775
1775
|
snapToGrid: me,
|
|
1776
1776
|
snapGrid: de,
|
|
1777
1777
|
nodeExtent: oe,
|
|
@@ -1793,9 +1793,9 @@ function Lr({
|
|
|
1793
1793
|
get connection() {
|
|
1794
1794
|
return Ve;
|
|
1795
1795
|
}
|
|
1796
|
-
}), [e, n, $n, Be, Ve,
|
|
1796
|
+
}), [e, n, $n, Be, Ve, Ct, lt, Ft, Kt, he, st, xt, me, de, oe, be, fe]);
|
|
1797
1797
|
return {
|
|
1798
|
-
wrapRef:
|
|
1798
|
+
wrapRef: mt,
|
|
1799
1799
|
canvasRef: Te,
|
|
1800
1800
|
canvasReady: gn,
|
|
1801
1801
|
onPointerDown: dr,
|
|
@@ -1817,7 +1817,7 @@ function Ir(t, e, n, r, s, o) {
|
|
|
1817
1817
|
return l = Math.max(0, Math.min(1, l)), Math.hypot(t - (n + l * i), e - (r + l * c));
|
|
1818
1818
|
}
|
|
1819
1819
|
const Zn = Fn(null);
|
|
1820
|
-
function
|
|
1820
|
+
function yt() {
|
|
1821
1821
|
const t = qe(Zn);
|
|
1822
1822
|
if (!t)
|
|
1823
1823
|
throw new Error("useCanvasStore must be used within <InfiniteCanvas> or <InfiniteCanvasProvider>");
|
|
@@ -1828,119 +1828,127 @@ function Ro() {
|
|
|
1828
1828
|
return qe(je);
|
|
1829
1829
|
}
|
|
1830
1830
|
function $r({ node: t, nodeType: e }) {
|
|
1831
|
-
var
|
|
1832
|
-
const n =
|
|
1833
|
-
|
|
1831
|
+
var m, C, z;
|
|
1832
|
+
const n = yt(), r = tt(null), s = t._absolutePosition || t.position, o = tt(null);
|
|
1833
|
+
ht(() => {
|
|
1834
1834
|
const M = r.current;
|
|
1835
1835
|
if (!M) return;
|
|
1836
|
-
const
|
|
1837
|
-
var D,
|
|
1838
|
-
const { width:
|
|
1839
|
-
if (
|
|
1840
|
-
const
|
|
1841
|
-
(Math.abs((N || 0) -
|
|
1842
|
-
{ id: t.id, type: "dimensions", dimensions: { width:
|
|
1836
|
+
const $ = new ResizeObserver((k) => {
|
|
1837
|
+
var D, g, f, p;
|
|
1838
|
+
const { width: E, height: _ } = k[0].contentRect;
|
|
1839
|
+
if (E > 0 && _ > 0) {
|
|
1840
|
+
const v = n.nodesRef.current.find((P) => P.id === t.id), N = (v == null ? void 0 : v.width) || ((D = v == null ? void 0 : v.measured) == null ? void 0 : D.width), w = (v == null ? void 0 : v.height) || ((g = v == null ? void 0 : v.measured) == null ? void 0 : g.height);
|
|
1841
|
+
(Math.abs((N || 0) - E) > 1 || Math.abs((w || 0) - _) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
|
|
1842
|
+
{ id: t.id, type: "dimensions", dimensions: { width: E, height: _ }, setAttributes: !0 }
|
|
1843
1843
|
]));
|
|
1844
1844
|
}
|
|
1845
1845
|
});
|
|
1846
|
-
return
|
|
1846
|
+
return $.observe(M), () => $.disconnect();
|
|
1847
1847
|
}, [t.id, n]);
|
|
1848
1848
|
const i = F((M) => {
|
|
1849
|
-
var
|
|
1850
|
-
|
|
1851
|
-
|
|
1849
|
+
var B, q, X;
|
|
1850
|
+
M.stopPropagation();
|
|
1851
|
+
const $ = M.target.tagName;
|
|
1852
|
+
if ($ === "INPUT" || $ === "TEXTAREA" || $ === "SELECT" || $ === "BUTTON" || $ === "A" || M.target.isContentEditable) return;
|
|
1853
|
+
let k = M.target;
|
|
1854
|
+
for (; k && k !== r.current; ) {
|
|
1855
|
+
if ((B = k.classList) != null && B.contains("nodrag")) return;
|
|
1856
|
+
k = k.parentElement;
|
|
1857
|
+
}
|
|
1858
|
+
if (n.onNodesChangeRef.current) {
|
|
1859
|
+
const K = [];
|
|
1852
1860
|
if (M.shiftKey)
|
|
1853
|
-
|
|
1861
|
+
K.push({ id: t.id, type: "select", selected: !t.selected });
|
|
1854
1862
|
else
|
|
1855
|
-
for (const
|
|
1856
|
-
|
|
1857
|
-
|
|
1863
|
+
for (const rt of n.nodesRef.current)
|
|
1864
|
+
rt.id === t.id && !rt.selected ? K.push({ id: rt.id, type: "select", selected: !0 }) : rt.id !== t.id && rt.selected && K.push({ id: rt.id, type: "select", selected: !1 });
|
|
1865
|
+
K.length && n.onNodesChangeRef.current(K);
|
|
1858
1866
|
}
|
|
1859
|
-
const
|
|
1860
|
-
if (!
|
|
1861
|
-
const
|
|
1867
|
+
const E = n.cameraRef.current, _ = n.wrapRef.current;
|
|
1868
|
+
if (!_) return;
|
|
1869
|
+
const D = _.getBoundingClientRect(), g = (M.clientX - D.left - E.x) / E.zoom, f = (M.clientY - D.top - E.y) / E.zoom, v = M.shiftKey && t.selected ? n.nodesRef.current.filter((K) => K.selected && K.id !== t.id).map((K) => ({ id: K.id, startPos: { ...K.position } })) : [];
|
|
1862
1870
|
o.current = {
|
|
1863
1871
|
startPos: { ...t.position },
|
|
1864
|
-
startMouse: { x:
|
|
1865
|
-
selectedStarts:
|
|
1872
|
+
startMouse: { x: g, y: f },
|
|
1873
|
+
selectedStarts: v
|
|
1866
1874
|
};
|
|
1867
|
-
const
|
|
1868
|
-
for (const
|
|
1869
|
-
|
|
1870
|
-
(
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1873
|
-
const
|
|
1874
|
-
var
|
|
1875
|
+
const N = [{ id: t.id, type: "position", dragging: !0 }];
|
|
1876
|
+
for (const K of v)
|
|
1877
|
+
N.push({ id: K.id, type: "position", dragging: !0 });
|
|
1878
|
+
(X = (q = n.onNodesChangeRef).current) == null || X.call(q, N);
|
|
1879
|
+
const w = r.current;
|
|
1880
|
+
w && w.setPointerCapture(M.pointerId);
|
|
1881
|
+
const P = (K) => {
|
|
1882
|
+
var It, st, xt, Nt;
|
|
1875
1883
|
if (!o.current) return;
|
|
1876
|
-
const
|
|
1877
|
-
let
|
|
1878
|
-
if (n.snapToGrid && n.snapGrid && (
|
|
1879
|
-
x: n.snapGrid[0] * Math.round(
|
|
1880
|
-
y: n.snapGrid[1] * Math.round(
|
|
1884
|
+
const at = n.cameraRef.current, rt = _.getBoundingClientRect(), G = (K.clientX - rt.left - at.x) / at.zoom, j = (K.clientY - rt.top - at.y) / at.zoom, it = G - o.current.startMouse.x, dt = j - o.current.startMouse.y;
|
|
1885
|
+
let ot = { x: o.current.startPos.x + it, y: o.current.startPos.y + dt };
|
|
1886
|
+
if (n.snapToGrid && n.snapGrid && (ot = {
|
|
1887
|
+
x: n.snapGrid[0] * Math.round(ot.x / n.snapGrid[0]),
|
|
1888
|
+
y: n.snapGrid[1] * Math.round(ot.y / n.snapGrid[1])
|
|
1881
1889
|
}), t.parentId && t.extent === "parent") {
|
|
1882
|
-
const
|
|
1883
|
-
if (
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1886
|
-
x: Math.max(0, Math.min(
|
|
1887
|
-
y: Math.max(0, Math.min(
|
|
1890
|
+
const gt = n.nodesRef.current.find((ct) => ct.id === t.parentId);
|
|
1891
|
+
if (gt) {
|
|
1892
|
+
const ct = gt.width || 160, zt = gt.height || 60, Rt = t.width || ((It = t.measured) == null ? void 0 : It.width) || 160, Lt = t.height || ((st = t.measured) == null ? void 0 : st.height) || 60;
|
|
1893
|
+
ot = {
|
|
1894
|
+
x: Math.max(0, Math.min(ot.x, ct - Rt)),
|
|
1895
|
+
y: Math.max(0, Math.min(ot.y, zt - Lt))
|
|
1888
1896
|
};
|
|
1889
1897
|
}
|
|
1890
1898
|
}
|
|
1891
|
-
const
|
|
1892
|
-
for (const
|
|
1893
|
-
let
|
|
1894
|
-
n.snapToGrid && n.snapGrid && (
|
|
1895
|
-
x: n.snapGrid[0] * Math.round(
|
|
1896
|
-
y: n.snapGrid[1] * Math.round(
|
|
1897
|
-
}),
|
|
1899
|
+
const ft = [{ id: t.id, type: "position", position: ot, dragging: !0 }];
|
|
1900
|
+
for (const gt of o.current.selectedStarts) {
|
|
1901
|
+
let ct = { x: gt.startPos.x + it, y: gt.startPos.y + dt };
|
|
1902
|
+
n.snapToGrid && n.snapGrid && (ct = {
|
|
1903
|
+
x: n.snapGrid[0] * Math.round(ct.x / n.snapGrid[0]),
|
|
1904
|
+
y: n.snapGrid[1] * Math.round(ct.y / n.snapGrid[1])
|
|
1905
|
+
}), ft.push({ id: gt.id, type: "position", position: ct, dragging: !0 });
|
|
1898
1906
|
}
|
|
1899
|
-
(
|
|
1900
|
-
},
|
|
1901
|
-
var
|
|
1907
|
+
(Nt = (xt = n.onNodesChangeRef).current) == null || Nt.call(xt, ft);
|
|
1908
|
+
}, R = (K) => {
|
|
1909
|
+
var rt, G;
|
|
1902
1910
|
if (!o.current) return;
|
|
1903
|
-
const
|
|
1904
|
-
for (const
|
|
1905
|
-
|
|
1906
|
-
(
|
|
1911
|
+
const at = [{ id: t.id, type: "position", dragging: !1 }];
|
|
1912
|
+
for (const j of o.current.selectedStarts)
|
|
1913
|
+
at.push({ id: j.id, type: "position", dragging: !1 });
|
|
1914
|
+
(G = (rt = n.onNodesChangeRef).current) == null || G.call(rt, at), o.current = null, w && w.releasePointerCapture(K.pointerId), w == null || w.removeEventListener("pointermove", P), w == null || w.removeEventListener("pointerup", R);
|
|
1907
1915
|
};
|
|
1908
|
-
|
|
1916
|
+
w == null || w.addEventListener("pointermove", P), w == null || w.addEventListener("pointerup", R);
|
|
1909
1917
|
}, [t, n]), c = F((M) => {
|
|
1910
|
-
var
|
|
1918
|
+
var g, f, p, v, N, w;
|
|
1911
1919
|
if (!t.selected) return;
|
|
1912
|
-
const
|
|
1913
|
-
let k = 0,
|
|
1920
|
+
const $ = M.shiftKey ? 10 : 1;
|
|
1921
|
+
let k = 0, E = 0;
|
|
1914
1922
|
switch (M.key) {
|
|
1915
1923
|
case "ArrowUp":
|
|
1916
|
-
|
|
1924
|
+
E = -$;
|
|
1917
1925
|
break;
|
|
1918
1926
|
case "ArrowDown":
|
|
1919
|
-
|
|
1927
|
+
E = $;
|
|
1920
1928
|
break;
|
|
1921
1929
|
case "ArrowLeft":
|
|
1922
|
-
k =
|
|
1930
|
+
k = -$;
|
|
1923
1931
|
break;
|
|
1924
1932
|
case "ArrowRight":
|
|
1925
|
-
k =
|
|
1933
|
+
k = $;
|
|
1926
1934
|
break;
|
|
1927
1935
|
case "Escape":
|
|
1928
|
-
(f = (
|
|
1936
|
+
(f = (g = n.onNodesChangeRef).current) == null || f.call(g, [{ id: t.id, type: "select", selected: !1 }]);
|
|
1929
1937
|
return;
|
|
1930
1938
|
case "Delete":
|
|
1931
1939
|
case "Backspace":
|
|
1932
|
-
t.deletable !== !1 && ((
|
|
1940
|
+
t.deletable !== !1 && ((v = (p = n.onNodesChangeRef).current) == null || v.call(p, [{ id: t.id, type: "remove" }]));
|
|
1933
1941
|
return;
|
|
1934
1942
|
default:
|
|
1935
1943
|
return;
|
|
1936
1944
|
}
|
|
1937
1945
|
M.preventDefault();
|
|
1938
|
-
const
|
|
1946
|
+
const _ = { x: t.position.x + k, y: t.position.y + E }, D = [{ id: t.id, type: "position", position: _ }];
|
|
1939
1947
|
for (const P of n.nodesRef.current)
|
|
1940
|
-
P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y +
|
|
1941
|
-
(
|
|
1942
|
-
}, [t, n]), u = t.width || ((
|
|
1943
|
-
return /* @__PURE__ */
|
|
1948
|
+
P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y + E } });
|
|
1949
|
+
(w = (N = n.onNodesChangeRef).current) == null || w.call(N, D);
|
|
1950
|
+
}, [t, n]), u = t.width || ((m = t.measured) == null ? void 0 : m.width), l = t.height || ((C = t.measured) == null ? void 0 : C.height), y = !!(u && l);
|
|
1951
|
+
return /* @__PURE__ */ S(je.Provider, { value: t.id, children: /* @__PURE__ */ S(
|
|
1944
1952
|
"div",
|
|
1945
1953
|
{
|
|
1946
1954
|
ref: r,
|
|
@@ -1952,18 +1960,18 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1952
1960
|
zIndex: t.type === "group" ? 0 : t.zIndex || 1,
|
|
1953
1961
|
pointerEvents: t.type === "group" ? "none" : "all",
|
|
1954
1962
|
cursor: t.dragging ? "grabbing" : "grab",
|
|
1955
|
-
visibility:
|
|
1963
|
+
visibility: y ? "visible" : "hidden",
|
|
1956
1964
|
userSelect: "none",
|
|
1957
1965
|
outline: "none"
|
|
1958
1966
|
},
|
|
1959
1967
|
"data-nodeid": t.id,
|
|
1960
1968
|
tabIndex: t.selectable !== !1 ? 0 : void 0,
|
|
1961
1969
|
role: "button",
|
|
1962
|
-
"aria-label": `Node ${((
|
|
1970
|
+
"aria-label": `Node ${((z = t.data) == null ? void 0 : z.label) || t.id}`,
|
|
1963
1971
|
"aria-selected": !!t.selected,
|
|
1964
1972
|
onPointerDown: i,
|
|
1965
1973
|
onKeyDown: c,
|
|
1966
|
-
children: /* @__PURE__ */
|
|
1974
|
+
children: /* @__PURE__ */ S(
|
|
1967
1975
|
e,
|
|
1968
1976
|
{
|
|
1969
1977
|
id: t.id,
|
|
@@ -1994,32 +2002,32 @@ function Bn(t, e, n, r) {
|
|
|
1994
2002
|
var c, u;
|
|
1995
2003
|
const s = t.width || ((c = t.measured) == null ? void 0 : c.width) || On, o = t.height || ((u = t.measured) == null ? void 0 : u.height) || Qn, i = t._absolutePosition || t.position;
|
|
1996
2004
|
if (t.handleBounds) {
|
|
1997
|
-
const l = t.handleBounds[e] || [],
|
|
1998
|
-
if (
|
|
1999
|
-
const
|
|
2000
|
-
return { x: i.x +
|
|
2005
|
+
const l = t.handleBounds[e] || [], y = n ? l.find((m) => m.id === n) : l[0];
|
|
2006
|
+
if (y && y.x !== void 0 && y.y !== void 0) {
|
|
2007
|
+
const m = y.position || (e === "source" ? "right" : "left");
|
|
2008
|
+
return { x: i.x + y.x, y: i.y + y.y, position: m };
|
|
2001
2009
|
}
|
|
2002
2010
|
}
|
|
2003
2011
|
if (r) {
|
|
2004
|
-
const l = `${t.id}__${n || e}`,
|
|
2005
|
-
if (
|
|
2006
|
-
return { x: i.x +
|
|
2012
|
+
const l = `${t.id}__${n || e}`, y = r.get(l);
|
|
2013
|
+
if (y && y.x !== void 0 && y.y !== void 0)
|
|
2014
|
+
return { x: i.x + y.x, y: i.y + y.y, position: y.position || (e === "source" ? "right" : "left") };
|
|
2007
2015
|
}
|
|
2008
2016
|
if (t.handles && t.handles.length) {
|
|
2009
2017
|
for (const l of t.handles)
|
|
2010
2018
|
if (l.type === e && (!n || l.id === n)) {
|
|
2011
2019
|
if (l.x !== void 0 && l.y !== void 0)
|
|
2012
2020
|
return { x: i.x + l.x, y: i.y + l.y, position: l.position || (e === "source" ? "right" : "left") };
|
|
2013
|
-
const
|
|
2014
|
-
switch (
|
|
2021
|
+
const y = l.position || (e === "source" ? "right" : "left");
|
|
2022
|
+
switch (y) {
|
|
2015
2023
|
case "top":
|
|
2016
|
-
return { x: i.x + s / 2, y: i.y, position:
|
|
2024
|
+
return { x: i.x + s / 2, y: i.y, position: y };
|
|
2017
2025
|
case "bottom":
|
|
2018
|
-
return { x: i.x + s / 2, y: i.y + o, position:
|
|
2026
|
+
return { x: i.x + s / 2, y: i.y + o, position: y };
|
|
2019
2027
|
case "left":
|
|
2020
|
-
return { x: i.x, y: i.y + o / 2, position:
|
|
2028
|
+
return { x: i.x, y: i.y + o / 2, position: y };
|
|
2021
2029
|
default:
|
|
2022
|
-
return { x: i.x + s, y: i.y + o / 2, position:
|
|
2030
|
+
return { x: i.x + s, y: i.y + o / 2, position: y };
|
|
2023
2031
|
}
|
|
2024
2032
|
}
|
|
2025
2033
|
}
|
|
@@ -2032,7 +2040,7 @@ function Sr(t, e, n) {
|
|
|
2032
2040
|
return n === "top" ? t - e : n === "bottom" ? t + e : t;
|
|
2033
2041
|
}
|
|
2034
2042
|
function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
2035
|
-
return /* @__PURE__ */
|
|
2043
|
+
return /* @__PURE__ */ S(
|
|
2036
2044
|
"circle",
|
|
2037
2045
|
{
|
|
2038
2046
|
className: `ric-edge-anchor ric-edge-anchor-${r}`,
|
|
@@ -2047,77 +2055,77 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
|
2047
2055
|
);
|
|
2048
2056
|
}
|
|
2049
2057
|
function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
2050
|
-
var
|
|
2051
|
-
const s =
|
|
2052
|
-
var
|
|
2058
|
+
var g, f, p;
|
|
2059
|
+
const s = yt(), [o, i] = Gt(null), c = F((v, N, w, P) => {
|
|
2060
|
+
var rt;
|
|
2053
2061
|
N.stopPropagation(), N.preventDefault();
|
|
2054
|
-
const
|
|
2055
|
-
if (!
|
|
2056
|
-
const
|
|
2057
|
-
(
|
|
2062
|
+
const R = s.wrapRef.current;
|
|
2063
|
+
if (!R) return;
|
|
2064
|
+
const B = v === "source" ? P : w, q = v === "source" ? t.target : t.source;
|
|
2065
|
+
(rt = s.workerRef.current) == null || rt.postMessage({
|
|
2058
2066
|
type: "connecting",
|
|
2059
|
-
data: { from: { x:
|
|
2067
|
+
data: { from: { x: B.x, y: B.y }, to: { x: B.x, y: B.y } }
|
|
2060
2068
|
});
|
|
2061
|
-
const
|
|
2062
|
-
var
|
|
2063
|
-
const j = s.cameraRef.current,
|
|
2064
|
-
(
|
|
2069
|
+
const X = R.getBoundingClientRect(), K = (G) => {
|
|
2070
|
+
var ot;
|
|
2071
|
+
const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom;
|
|
2072
|
+
(ot = s.workerRef.current) == null || ot.postMessage({
|
|
2065
2073
|
type: "connecting",
|
|
2066
|
-
data: { from: { x:
|
|
2074
|
+
data: { from: { x: B.x, y: B.y }, to: { x: it, y: dt } }
|
|
2067
2075
|
});
|
|
2068
|
-
},
|
|
2069
|
-
var
|
|
2070
|
-
const j = s.cameraRef.current,
|
|
2071
|
-
let
|
|
2072
|
-
const
|
|
2073
|
-
for (const
|
|
2074
|
-
if (
|
|
2075
|
-
const
|
|
2076
|
-
if (
|
|
2077
|
-
for (const [, Bt] of
|
|
2078
|
-
Bt.nodeId ===
|
|
2079
|
-
const Ie = ne.length > 0 ? ne :
|
|
2076
|
+
}, at = (G) => {
|
|
2077
|
+
var xt, Nt, gt, ct;
|
|
2078
|
+
const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom, ot = 20 / j.zoom;
|
|
2079
|
+
let ft = null, It = null;
|
|
2080
|
+
const st = (xt = s.handleRegistryRef) == null ? void 0 : xt.current;
|
|
2081
|
+
for (const zt of s.nodesRef.current) {
|
|
2082
|
+
if (zt.hidden) continue;
|
|
2083
|
+
const Rt = zt.width || On, Lt = zt.height || Qn, wt = zt._absolutePosition || zt.position, ne = [];
|
|
2084
|
+
if (st)
|
|
2085
|
+
for (const [, Bt] of st)
|
|
2086
|
+
Bt.nodeId === zt.id && ne.push(Bt);
|
|
2087
|
+
const Ie = ne.length > 0 ? ne : zt.handles || [
|
|
2080
2088
|
{ type: "target", position: "left" },
|
|
2081
2089
|
{ type: "source", position: "right" }
|
|
2082
2090
|
];
|
|
2083
2091
|
for (const Bt of Ie) {
|
|
2084
2092
|
let Ot, Yt;
|
|
2085
2093
|
if (Bt.x !== void 0 && Bt.y !== void 0)
|
|
2086
|
-
Ot =
|
|
2094
|
+
Ot = wt.x + Bt.x, Yt = wt.y + Bt.y;
|
|
2087
2095
|
else
|
|
2088
2096
|
switch (Bt.position || (Bt.type === "source" ? "right" : "left")) {
|
|
2089
2097
|
case "top":
|
|
2090
|
-
Ot =
|
|
2098
|
+
Ot = wt.x + Rt / 2, Yt = wt.y;
|
|
2091
2099
|
break;
|
|
2092
2100
|
case "bottom":
|
|
2093
|
-
Ot =
|
|
2101
|
+
Ot = wt.x + Rt / 2, Yt = wt.y + Lt;
|
|
2094
2102
|
break;
|
|
2095
2103
|
case "left":
|
|
2096
|
-
Ot =
|
|
2104
|
+
Ot = wt.x, Yt = wt.y + Lt / 2;
|
|
2097
2105
|
break;
|
|
2098
2106
|
default:
|
|
2099
|
-
Ot =
|
|
2107
|
+
Ot = wt.x + Rt, Yt = wt.y + Lt / 2;
|
|
2100
2108
|
break;
|
|
2101
2109
|
}
|
|
2102
|
-
if (Math.abs(
|
|
2103
|
-
|
|
2110
|
+
if (Math.abs(it - Ot) < ot && Math.abs(dt - Yt) < ot) {
|
|
2111
|
+
ft = zt, It = Bt.id || null;
|
|
2104
2112
|
break;
|
|
2105
2113
|
}
|
|
2106
2114
|
}
|
|
2107
|
-
if (
|
|
2115
|
+
if (ft) break;
|
|
2108
2116
|
}
|
|
2109
|
-
if (
|
|
2110
|
-
const
|
|
2111
|
-
(
|
|
2117
|
+
if (ft) {
|
|
2118
|
+
const zt = v === "source" ? { source: ft.id, target: q, sourceHandle: It, targetHandle: t.targetHandle } : { source: q, target: ft.id, sourceHandle: t.sourceHandle, targetHandle: It };
|
|
2119
|
+
(gt = (Nt = s.onEdgesChangeRef).current) == null || gt.call(Nt, [
|
|
2112
2120
|
{ id: t.id, type: "remove" },
|
|
2113
|
-
{ type: "add", item: { id: t.id, ...
|
|
2121
|
+
{ type: "add", item: { id: t.id, ...zt } }
|
|
2114
2122
|
]);
|
|
2115
2123
|
}
|
|
2116
|
-
(
|
|
2124
|
+
(ct = s.workerRef.current) == null || ct.postMessage({ type: "connecting", data: null }), R.removeEventListener("pointermove", K), R.removeEventListener("pointerup", at);
|
|
2117
2125
|
};
|
|
2118
|
-
|
|
2119
|
-
}, [t, s]), u = n.find((
|
|
2120
|
-
return !
|
|
2126
|
+
R.addEventListener("pointermove", K), R.addEventListener("pointerup", at);
|
|
2127
|
+
}, [t, s]), u = n.find((v) => v.id === t.source), l = n.find((v) => v.id === t.target), y = u && !!(u.width || (g = u.measured) != null && g.width), m = l && !!(l.width || (f = l.measured) != null && f.width), C = (p = s.handleRegistryRef) == null ? void 0 : p.current, z = y ? Bn(u, "source", t.sourceHandle, C) : null, M = m ? Bn(l, "target", t.targetHandle, C) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, E = k == null ? void 0 : k.find((v) => v.id === t.id), _ = $ ? null : (E == null ? void 0 : E._routedPoints) || t._routedPoints || null, D = r !== !1 && t.reconnectable !== !1;
|
|
2128
|
+
return !z || !M ? null : /* @__PURE__ */ $t(
|
|
2121
2129
|
"g",
|
|
2122
2130
|
{
|
|
2123
2131
|
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
@@ -2125,17 +2133,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2125
2133
|
onMouseEnter: () => i(!0),
|
|
2126
2134
|
onMouseLeave: () => i(!1),
|
|
2127
2135
|
children: [
|
|
2128
|
-
/* @__PURE__ */
|
|
2136
|
+
/* @__PURE__ */ S(
|
|
2129
2137
|
e,
|
|
2130
2138
|
{
|
|
2131
2139
|
id: t.id,
|
|
2132
2140
|
source: t.source,
|
|
2133
2141
|
target: t.target,
|
|
2134
|
-
sourceX:
|
|
2135
|
-
sourceY:
|
|
2142
|
+
sourceX: z.x,
|
|
2143
|
+
sourceY: z.y,
|
|
2136
2144
|
targetX: M.x,
|
|
2137
2145
|
targetY: M.y,
|
|
2138
|
-
sourcePosition:
|
|
2146
|
+
sourcePosition: z.position,
|
|
2139
2147
|
targetPosition: M.position,
|
|
2140
2148
|
sourceHandleId: t.sourceHandle,
|
|
2141
2149
|
targetHandleId: t.targetHandle,
|
|
@@ -2147,28 +2155,28 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2147
2155
|
style: t.style,
|
|
2148
2156
|
selectable: t.selectable !== !1,
|
|
2149
2157
|
deletable: t.deletable !== !1,
|
|
2150
|
-
routedPoints:
|
|
2158
|
+
routedPoints: _
|
|
2151
2159
|
}
|
|
2152
2160
|
),
|
|
2153
|
-
D && (o || t.selected) && /* @__PURE__ */
|
|
2154
|
-
/* @__PURE__ */
|
|
2161
|
+
D && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
|
|
2162
|
+
/* @__PURE__ */ S(
|
|
2155
2163
|
Dn,
|
|
2156
2164
|
{
|
|
2157
|
-
x:
|
|
2158
|
-
y:
|
|
2159
|
-
position:
|
|
2165
|
+
x: z.x,
|
|
2166
|
+
y: z.y,
|
|
2167
|
+
position: z.position,
|
|
2160
2168
|
type: "source",
|
|
2161
|
-
onPointerDown: (
|
|
2169
|
+
onPointerDown: (v) => c("source", v, z, M)
|
|
2162
2170
|
}
|
|
2163
2171
|
),
|
|
2164
|
-
/* @__PURE__ */
|
|
2172
|
+
/* @__PURE__ */ S(
|
|
2165
2173
|
Dn,
|
|
2166
2174
|
{
|
|
2167
2175
|
x: M.x,
|
|
2168
2176
|
y: M.y,
|
|
2169
2177
|
position: M.position,
|
|
2170
2178
|
type: "target",
|
|
2171
|
-
onPointerDown: (
|
|
2179
|
+
onPointerDown: (v) => c("target", v, z, M)
|
|
2172
2180
|
}
|
|
2173
2181
|
)
|
|
2174
2182
|
] })
|
|
@@ -2178,59 +2186,59 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2178
2186
|
}
|
|
2179
2187
|
const Dr = Zt(Br);
|
|
2180
2188
|
function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
2181
|
-
var
|
|
2182
|
-
const n =
|
|
2183
|
-
if (
|
|
2189
|
+
var $;
|
|
2190
|
+
const n = yt(), [r, s] = Gt(null), o = tt(null);
|
|
2191
|
+
if (ht(() => {
|
|
2184
2192
|
const k = n.wrapRef.current;
|
|
2185
2193
|
if (!k) return;
|
|
2186
|
-
let
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2189
|
-
}, f = (
|
|
2190
|
-
|
|
2191
|
-
}, p = (
|
|
2194
|
+
let E = !1, _ = null, D = !1;
|
|
2195
|
+
const g = (w) => {
|
|
2196
|
+
w.key === t && (D = !0);
|
|
2197
|
+
}, f = (w) => {
|
|
2198
|
+
w.key === t && (D = !1);
|
|
2199
|
+
}, p = (w) => {
|
|
2192
2200
|
if (!D) return;
|
|
2193
|
-
const P =
|
|
2201
|
+
const P = w.target;
|
|
2194
2202
|
if (P.closest(".ric-node-wrapper") || P.closest(".ric-handle")) return;
|
|
2195
|
-
|
|
2196
|
-
const
|
|
2197
|
-
|
|
2198
|
-
},
|
|
2199
|
-
if (!
|
|
2200
|
-
const P = n.cameraRef.current,
|
|
2201
|
-
s({ startX:
|
|
2202
|
-
}, N = (
|
|
2203
|
-
var
|
|
2204
|
-
if (!
|
|
2205
|
-
|
|
2206
|
-
const P = n.cameraRef.current,
|
|
2207
|
-
x: Math.min(
|
|
2208
|
-
y: Math.min(
|
|
2209
|
-
width: Math.abs(
|
|
2210
|
-
height: Math.abs(
|
|
2211
|
-
},
|
|
2203
|
+
E = !0;
|
|
2204
|
+
const R = n.cameraRef.current, B = k.getBoundingClientRect(), q = (w.clientX - B.left - R.x) / R.zoom, X = (w.clientY - B.top - R.y) / R.zoom;
|
|
2205
|
+
_ = { x: q, y: X }, s({ startX: q, startY: X, endX: q, endY: X }), w.stopPropagation();
|
|
2206
|
+
}, v = (w) => {
|
|
2207
|
+
if (!E || !_) return;
|
|
2208
|
+
const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom;
|
|
2209
|
+
s({ startX: _.x, startY: _.y, endX: B, endY: q });
|
|
2210
|
+
}, N = (w) => {
|
|
2211
|
+
var at, rt;
|
|
2212
|
+
if (!E || !_) return;
|
|
2213
|
+
E = !1;
|
|
2214
|
+
const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom, X = {
|
|
2215
|
+
x: Math.min(_.x, B),
|
|
2216
|
+
y: Math.min(_.y, q),
|
|
2217
|
+
width: Math.abs(B - _.x),
|
|
2218
|
+
height: Math.abs(q - _.y)
|
|
2219
|
+
}, K = [];
|
|
2212
2220
|
for (const G of n.nodesRef.current) {
|
|
2213
|
-
const j = G._absolutePosition || G.position,
|
|
2214
|
-
let
|
|
2215
|
-
e === "full" ?
|
|
2221
|
+
const j = G._absolutePosition || G.position, it = G.width || 160, dt = G.height || 60;
|
|
2222
|
+
let ot;
|
|
2223
|
+
e === "full" ? ot = j.x >= X.x && j.y >= X.y && j.x + it <= X.x + X.width && j.y + dt <= X.y + X.height : ot = j.x + it > X.x && j.x < X.x + X.width && j.y + dt > X.y && j.y < X.y + X.height, K.push({ id: G.id, type: "select", selected: ot });
|
|
2216
2224
|
}
|
|
2217
|
-
|
|
2225
|
+
K.length && ((rt = (at = n.onNodesChangeRef).current) == null || rt.call(at, K)), _ = null, s(null);
|
|
2218
2226
|
};
|
|
2219
|
-
return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove",
|
|
2220
|
-
k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove",
|
|
2227
|
+
return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove", v), k.addEventListener("pointerup", N), window.addEventListener("keydown", g), window.addEventListener("keyup", f), () => {
|
|
2228
|
+
k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove", v), k.removeEventListener("pointerup", N), window.removeEventListener("keydown", g), window.removeEventListener("keyup", f);
|
|
2221
2229
|
};
|
|
2222
2230
|
}, [n, t, e]), !r) return null;
|
|
2223
|
-
const i = ((
|
|
2224
|
-
return /* @__PURE__ */
|
|
2231
|
+
const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), y = Math.abs(r.endY - r.startY), m = c * i.zoom + i.x, C = u * i.zoom + i.y, z = l * i.zoom, M = y * i.zoom;
|
|
2232
|
+
return /* @__PURE__ */ S(
|
|
2225
2233
|
"div",
|
|
2226
2234
|
{
|
|
2227
2235
|
ref: o,
|
|
2228
2236
|
className: "ric-selection-box",
|
|
2229
2237
|
style: {
|
|
2230
2238
|
position: "absolute",
|
|
2231
|
-
left:
|
|
2232
|
-
top:
|
|
2233
|
-
width:
|
|
2239
|
+
left: m,
|
|
2240
|
+
top: C,
|
|
2241
|
+
width: z,
|
|
2234
2242
|
height: M,
|
|
2235
2243
|
border: "1px dashed #3b82f6",
|
|
2236
2244
|
background: "rgba(59, 130, 246, 0.08)",
|
|
@@ -2241,7 +2249,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2241
2249
|
);
|
|
2242
2250
|
}
|
|
2243
2251
|
Kn.displayName = "SelectionBox";
|
|
2244
|
-
const
|
|
2252
|
+
const Ar = Zt(Kn);
|
|
2245
2253
|
function Jn(t, e) {
|
|
2246
2254
|
var s, o, i, c;
|
|
2247
2255
|
const n = (s = t.handleRegistryRef) == null ? void 0 : s.current;
|
|
@@ -2257,12 +2265,12 @@ function Jn(t, e) {
|
|
|
2257
2265
|
]), (c = t.syncNodesToWorker) == null || c.call(t);
|
|
2258
2266
|
}
|
|
2259
2267
|
const vn = /* @__PURE__ */ new Set();
|
|
2260
|
-
function
|
|
2268
|
+
function An(t, e) {
|
|
2261
2269
|
vn.has(e) || (vn.add(e), queueMicrotask(() => {
|
|
2262
2270
|
vn.delete(e), Jn(t, e);
|
|
2263
2271
|
}));
|
|
2264
2272
|
}
|
|
2265
|
-
function
|
|
2273
|
+
function Hr(t, e) {
|
|
2266
2274
|
const n = t.closest(".ric-node-wrapper");
|
|
2267
2275
|
if (!n) return null;
|
|
2268
2276
|
const r = n.getBoundingClientRect(), s = t.getBoundingClientRect(), o = e || 1;
|
|
@@ -2282,145 +2290,145 @@ function on({
|
|
|
2282
2290
|
className: c = "",
|
|
2283
2291
|
style: u = {},
|
|
2284
2292
|
onConnect: l,
|
|
2285
|
-
...
|
|
2293
|
+
...y
|
|
2286
2294
|
}) {
|
|
2287
|
-
const
|
|
2288
|
-
M.current =
|
|
2289
|
-
const
|
|
2290
|
-
var
|
|
2291
|
-
const D =
|
|
2292
|
-
if (!D || !
|
|
2293
|
-
const
|
|
2295
|
+
const m = qe(je), C = yt(), z = tt(null), M = tt(C);
|
|
2296
|
+
M.current = C;
|
|
2297
|
+
const $ = F(() => {
|
|
2298
|
+
var w, P, R;
|
|
2299
|
+
const D = z.current;
|
|
2300
|
+
if (!D || !m) return;
|
|
2301
|
+
const g = M.current, f = (w = g.handleRegistryRef) == null ? void 0 : w.current;
|
|
2294
2302
|
if (!f) return;
|
|
2295
|
-
const p = `${
|
|
2303
|
+
const p = `${m}__${n || t}`, v = (R = (P = g.cameraRef) == null ? void 0 : P.current) == null ? void 0 : R.zoom, N = Hr(D, v);
|
|
2296
2304
|
if (N) {
|
|
2297
|
-
const
|
|
2298
|
-
f.set(p,
|
|
2305
|
+
const B = { nodeId: m, id: n || null, type: t, position: e, x: N.x, y: N.y };
|
|
2306
|
+
f.set(p, B);
|
|
2299
2307
|
}
|
|
2300
|
-
}, [
|
|
2308
|
+
}, [m, n, t, e]);
|
|
2301
2309
|
kr(() => {
|
|
2302
|
-
|
|
2303
|
-
}, [
|
|
2304
|
-
if (!
|
|
2310
|
+
$();
|
|
2311
|
+
}, [$]), ht(() => {
|
|
2312
|
+
if (!m) return;
|
|
2305
2313
|
const D = M.current;
|
|
2306
|
-
|
|
2307
|
-
const
|
|
2308
|
-
|
|
2314
|
+
An(D, m);
|
|
2315
|
+
const g = z.current, f = g == null ? void 0 : g.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
|
|
2316
|
+
$(), An(M.current, m);
|
|
2309
2317
|
});
|
|
2310
2318
|
return f && p.observe(f), () => {
|
|
2311
2319
|
var P;
|
|
2312
2320
|
p.disconnect();
|
|
2313
|
-
const
|
|
2314
|
-
N == null || N.delete(
|
|
2321
|
+
const v = M.current, N = (P = v.handleRegistryRef) == null ? void 0 : P.current, w = `${m}__${n || t}`;
|
|
2322
|
+
N == null || N.delete(w), Jn(v, m);
|
|
2315
2323
|
};
|
|
2316
|
-
}, [
|
|
2324
|
+
}, [m, n, t, e, $]);
|
|
2317
2325
|
const k = F(() => {
|
|
2318
|
-
var
|
|
2319
|
-
const D = M.current,
|
|
2320
|
-
if (!
|
|
2321
|
-
const f =
|
|
2326
|
+
var R;
|
|
2327
|
+
const D = M.current, g = D.nodesRef.current.find((B) => B.id === m);
|
|
2328
|
+
if (!g) return null;
|
|
2329
|
+
const f = g._absolutePosition || g.position, p = (R = D.handleRegistryRef) == null ? void 0 : R.current, v = `${m}__${n || t}`, N = p == null ? void 0 : p.get(v);
|
|
2322
2330
|
if (N && N.x !== void 0 && N.y !== void 0)
|
|
2323
2331
|
return { x: f.x + N.x, y: f.y + N.y };
|
|
2324
|
-
const
|
|
2332
|
+
const w = g.width || 160, P = g.height || 60;
|
|
2325
2333
|
switch (e) {
|
|
2326
2334
|
case "top":
|
|
2327
|
-
return { x: f.x +
|
|
2335
|
+
return { x: f.x + w / 2, y: f.y };
|
|
2328
2336
|
case "bottom":
|
|
2329
|
-
return { x: f.x +
|
|
2337
|
+
return { x: f.x + w / 2, y: f.y + P };
|
|
2330
2338
|
case "left":
|
|
2331
2339
|
return { x: f.x, y: f.y + P / 2 };
|
|
2332
2340
|
default:
|
|
2333
|
-
return { x: f.x +
|
|
2341
|
+
return { x: f.x + w, y: f.y + P / 2 };
|
|
2334
2342
|
}
|
|
2335
|
-
}, [
|
|
2336
|
-
var
|
|
2343
|
+
}, [m, n, t, e]), E = F((D) => {
|
|
2344
|
+
var q;
|
|
2337
2345
|
if (!r || !s) return;
|
|
2338
2346
|
D.stopPropagation(), D.preventDefault();
|
|
2339
|
-
const
|
|
2347
|
+
const g = M.current, f = g.cameraRef.current, p = g.wrapRef.current;
|
|
2340
2348
|
if (!p) return;
|
|
2341
|
-
const
|
|
2349
|
+
const v = p.getBoundingClientRect(), N = k();
|
|
2342
2350
|
if (!N) return;
|
|
2343
|
-
const
|
|
2344
|
-
(
|
|
2351
|
+
const w = N.x, P = N.y;
|
|
2352
|
+
(q = g.workerRef.current) == null || q.postMessage({
|
|
2345
2353
|
type: "connecting",
|
|
2346
|
-
data: { from: { x:
|
|
2354
|
+
data: { from: { x: w, y: P }, to: { x: w, y: P } }
|
|
2347
2355
|
}), p.setPointerCapture(D.pointerId);
|
|
2348
|
-
const
|
|
2349
|
-
var
|
|
2350
|
-
const
|
|
2351
|
-
(
|
|
2356
|
+
const R = (X) => {
|
|
2357
|
+
var rt;
|
|
2358
|
+
const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom;
|
|
2359
|
+
(rt = g.workerRef.current) == null || rt.postMessage({
|
|
2352
2360
|
type: "connecting",
|
|
2353
|
-
data: { from: { x:
|
|
2361
|
+
data: { from: { x: w, y: P }, to: { x: K, y: at } }
|
|
2354
2362
|
});
|
|
2355
|
-
},
|
|
2356
|
-
var
|
|
2357
|
-
const
|
|
2363
|
+
}, B = (X) => {
|
|
2364
|
+
var dt, ot, ft, It;
|
|
2365
|
+
const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom, rt = 20 / f.zoom;
|
|
2358
2366
|
let G = null, j = null;
|
|
2359
|
-
const
|
|
2360
|
-
for (const
|
|
2361
|
-
if (
|
|
2362
|
-
const
|
|
2363
|
-
if (
|
|
2364
|
-
for (const [,
|
|
2365
|
-
|
|
2366
|
-
const
|
|
2367
|
+
const it = (dt = g.handleRegistryRef) == null ? void 0 : dt.current;
|
|
2368
|
+
for (const st of g.nodesRef.current) {
|
|
2369
|
+
if (st.id === m || st.hidden) continue;
|
|
2370
|
+
const xt = st.width || 160, Nt = st.height || 60, gt = st._absolutePosition || st.position, ct = [];
|
|
2371
|
+
if (it)
|
|
2372
|
+
for (const [, Rt] of it)
|
|
2373
|
+
Rt.nodeId === st.id && ct.push(Rt);
|
|
2374
|
+
const zt = ct.length > 0 ? ct : st.handles || [
|
|
2367
2375
|
{ type: "target", position: "left" },
|
|
2368
2376
|
{ type: "source", position: "right" }
|
|
2369
2377
|
];
|
|
2370
|
-
for (const
|
|
2371
|
-
let
|
|
2372
|
-
if (
|
|
2373
|
-
|
|
2378
|
+
for (const Rt of zt) {
|
|
2379
|
+
let Lt, wt;
|
|
2380
|
+
if (Rt.x !== void 0 && Rt.y !== void 0)
|
|
2381
|
+
Lt = gt.x + Rt.x, wt = gt.y + Rt.y;
|
|
2374
2382
|
else
|
|
2375
|
-
switch (
|
|
2383
|
+
switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
|
|
2376
2384
|
case "top":
|
|
2377
|
-
|
|
2385
|
+
Lt = gt.x + xt / 2, wt = gt.y;
|
|
2378
2386
|
break;
|
|
2379
2387
|
case "bottom":
|
|
2380
|
-
|
|
2388
|
+
Lt = gt.x + xt / 2, wt = gt.y + Nt;
|
|
2381
2389
|
break;
|
|
2382
2390
|
case "left":
|
|
2383
|
-
|
|
2391
|
+
Lt = gt.x, wt = gt.y + Nt / 2;
|
|
2384
2392
|
break;
|
|
2385
2393
|
default:
|
|
2386
|
-
|
|
2394
|
+
Lt = gt.x + xt, wt = gt.y + Nt / 2;
|
|
2387
2395
|
break;
|
|
2388
2396
|
}
|
|
2389
|
-
if (Math.abs(
|
|
2390
|
-
G =
|
|
2397
|
+
if (Math.abs(K - Lt) < rt && Math.abs(at - wt) < rt) {
|
|
2398
|
+
G = st, j = Rt.id || null;
|
|
2391
2399
|
break;
|
|
2392
2400
|
}
|
|
2393
2401
|
}
|
|
2394
2402
|
if (G) break;
|
|
2395
2403
|
}
|
|
2396
2404
|
if (G) {
|
|
2397
|
-
const
|
|
2398
|
-
source: t === "source" ?
|
|
2399
|
-
target: t === "source" ? G.id :
|
|
2405
|
+
const st = {
|
|
2406
|
+
source: t === "source" ? m : G.id,
|
|
2407
|
+
target: t === "source" ? G.id : m,
|
|
2400
2408
|
sourceHandle: t === "source" ? n || null : j,
|
|
2401
2409
|
targetHandle: t === "source" ? j : n || null
|
|
2402
2410
|
};
|
|
2403
|
-
(
|
|
2411
|
+
(ft = (ot = g.onEdgesChangeRef) == null ? void 0 : ot.current) == null || ft.call(ot, [{ type: "add", item: { id: `e-${st.source}-${st.target}`, ...st } }]);
|
|
2404
2412
|
}
|
|
2405
|
-
(
|
|
2413
|
+
(It = g.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", R), p.removeEventListener("pointerup", B);
|
|
2406
2414
|
};
|
|
2407
|
-
p.addEventListener("pointermove",
|
|
2408
|
-
}, [
|
|
2415
|
+
p.addEventListener("pointermove", R), p.addEventListener("pointerup", B);
|
|
2416
|
+
}, [m, n, t, e, r, s, k]), _ = {
|
|
2409
2417
|
top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
|
|
2410
2418
|
bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
|
|
2411
2419
|
left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
|
|
2412
2420
|
right: { top: "50%", right: 0, transform: "translate(50%, -50%)" }
|
|
2413
2421
|
}[e] || {};
|
|
2414
|
-
return /* @__PURE__ */
|
|
2422
|
+
return /* @__PURE__ */ S(
|
|
2415
2423
|
"div",
|
|
2416
2424
|
{
|
|
2417
|
-
ref:
|
|
2425
|
+
ref: z,
|
|
2418
2426
|
className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
|
|
2419
2427
|
"data-handleid": n || null,
|
|
2420
|
-
"data-nodeid":
|
|
2428
|
+
"data-nodeid": m,
|
|
2421
2429
|
"data-handlepos": e,
|
|
2422
2430
|
"data-handletype": t,
|
|
2423
|
-
onPointerDown:
|
|
2431
|
+
onPointerDown: E,
|
|
2424
2432
|
style: {
|
|
2425
2433
|
position: "absolute",
|
|
2426
2434
|
width: 8,
|
|
@@ -2431,10 +2439,10 @@ function on({
|
|
|
2431
2439
|
zIndex: 10,
|
|
2432
2440
|
cursor: r ? "crosshair" : "default",
|
|
2433
2441
|
boxSizing: "border-box",
|
|
2434
|
-
...
|
|
2442
|
+
..._,
|
|
2435
2443
|
...u
|
|
2436
2444
|
},
|
|
2437
|
-
...
|
|
2445
|
+
...y,
|
|
2438
2446
|
children: i
|
|
2439
2447
|
}
|
|
2440
2448
|
);
|
|
@@ -2448,7 +2456,7 @@ function ko({
|
|
|
2448
2456
|
hideSourceHandle: o = !1,
|
|
2449
2457
|
hideTargetHandle: i = !1
|
|
2450
2458
|
}) {
|
|
2451
|
-
return /* @__PURE__ */
|
|
2459
|
+
return /* @__PURE__ */ $t(
|
|
2452
2460
|
"div",
|
|
2453
2461
|
{
|
|
2454
2462
|
className: `ric-default-node${n ? " selected" : ""}`,
|
|
@@ -2463,9 +2471,9 @@ function ko({
|
|
|
2463
2471
|
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2464
2472
|
},
|
|
2465
2473
|
children: [
|
|
2466
|
-
!i && /* @__PURE__ */
|
|
2467
|
-
/* @__PURE__ */
|
|
2468
|
-
!o && /* @__PURE__ */
|
|
2474
|
+
!i && /* @__PURE__ */ S(on, { type: "target", position: r, isConnectable: e }),
|
|
2475
|
+
/* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
|
|
2476
|
+
!o && /* @__PURE__ */ S(on, { type: "source", position: s, isConnectable: e })
|
|
2469
2477
|
]
|
|
2470
2478
|
}
|
|
2471
2479
|
);
|
|
@@ -2477,7 +2485,7 @@ function _r({
|
|
|
2477
2485
|
sourcePosition: r = "right",
|
|
2478
2486
|
hideSourceHandle: s = !1
|
|
2479
2487
|
}) {
|
|
2480
|
-
return /* @__PURE__ */
|
|
2488
|
+
return /* @__PURE__ */ $t(
|
|
2481
2489
|
"div",
|
|
2482
2490
|
{
|
|
2483
2491
|
className: `ric-input-node${n ? " selected" : ""}`,
|
|
@@ -2493,8 +2501,8 @@ function _r({
|
|
|
2493
2501
|
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2494
2502
|
},
|
|
2495
2503
|
children: [
|
|
2496
|
-
/* @__PURE__ */
|
|
2497
|
-
!s && /* @__PURE__ */
|
|
2504
|
+
/* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
|
|
2505
|
+
!s && /* @__PURE__ */ S(on, { type: "source", position: r, isConnectable: e })
|
|
2498
2506
|
]
|
|
2499
2507
|
}
|
|
2500
2508
|
);
|
|
@@ -2506,7 +2514,7 @@ function Wr({
|
|
|
2506
2514
|
targetPosition: r = "left",
|
|
2507
2515
|
hideTargetHandle: s = !1
|
|
2508
2516
|
}) {
|
|
2509
|
-
return /* @__PURE__ */
|
|
2517
|
+
return /* @__PURE__ */ $t(
|
|
2510
2518
|
"div",
|
|
2511
2519
|
{
|
|
2512
2520
|
className: `ric-output-node${n ? " selected" : ""}`,
|
|
@@ -2522,14 +2530,14 @@ function Wr({
|
|
|
2522
2530
|
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2523
2531
|
},
|
|
2524
2532
|
children: [
|
|
2525
|
-
!s && /* @__PURE__ */
|
|
2526
|
-
/* @__PURE__ */
|
|
2533
|
+
!s && /* @__PURE__ */ S(on, { type: "target", position: r, isConnectable: e }),
|
|
2534
|
+
/* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label })
|
|
2527
2535
|
]
|
|
2528
2536
|
}
|
|
2529
2537
|
);
|
|
2530
2538
|
}
|
|
2531
2539
|
function Xr({ data: t, selected: e, width: n, height: r }) {
|
|
2532
|
-
return /* @__PURE__ */
|
|
2540
|
+
return /* @__PURE__ */ S(
|
|
2533
2541
|
"div",
|
|
2534
2542
|
{
|
|
2535
2543
|
className: `ric-group-node${e ? " selected" : ""}`,
|
|
@@ -2542,7 +2550,7 @@ function Xr({ data: t, selected: e, width: n, height: r }) {
|
|
|
2542
2550
|
padding: 8,
|
|
2543
2551
|
boxSizing: "border-box"
|
|
2544
2552
|
},
|
|
2545
|
-
children: (t == null ? void 0 : t.label) && /* @__PURE__ */
|
|
2553
|
+
children: (t == null ? void 0 : t.label) && /* @__PURE__ */ S(
|
|
2546
2554
|
"div",
|
|
2547
2555
|
{
|
|
2548
2556
|
style: {
|
|
@@ -2568,47 +2576,47 @@ function Vn({
|
|
|
2568
2576
|
labelBgBorderRadius: c = 2,
|
|
2569
2577
|
children: u,
|
|
2570
2578
|
className: l = "",
|
|
2571
|
-
...
|
|
2579
|
+
...y
|
|
2572
2580
|
}) {
|
|
2573
|
-
const [
|
|
2574
|
-
return
|
|
2575
|
-
if (
|
|
2576
|
-
const M =
|
|
2577
|
-
|
|
2581
|
+
const [m, C] = Gt({ x: 1, y: 0, width: 0, height: 0 }), z = tt(null);
|
|
2582
|
+
return ht(() => {
|
|
2583
|
+
if (z.current) {
|
|
2584
|
+
const M = z.current.getBBox();
|
|
2585
|
+
C({
|
|
2578
2586
|
x: M.x,
|
|
2579
2587
|
y: M.y,
|
|
2580
2588
|
width: M.width,
|
|
2581
2589
|
height: M.height
|
|
2582
2590
|
});
|
|
2583
2591
|
}
|
|
2584
|
-
}, [n]), n ? /* @__PURE__ */
|
|
2592
|
+
}, [n]), n ? /* @__PURE__ */ $t(
|
|
2585
2593
|
"g",
|
|
2586
2594
|
{
|
|
2587
|
-
transform: `translate(${t -
|
|
2595
|
+
transform: `translate(${t - m.width / 2} ${e - m.height / 2})`,
|
|
2588
2596
|
className: `ric-edge-textwrapper ${l}`,
|
|
2589
|
-
visibility:
|
|
2590
|
-
...
|
|
2597
|
+
visibility: m.width ? "visible" : "hidden",
|
|
2598
|
+
...y,
|
|
2591
2599
|
children: [
|
|
2592
|
-
s && /* @__PURE__ */
|
|
2600
|
+
s && /* @__PURE__ */ S(
|
|
2593
2601
|
"rect",
|
|
2594
2602
|
{
|
|
2595
|
-
width:
|
|
2603
|
+
width: m.width + 2 * i[0],
|
|
2596
2604
|
x: -i[0],
|
|
2597
2605
|
y: -i[1],
|
|
2598
|
-
height:
|
|
2606
|
+
height: m.height + 2 * i[1],
|
|
2599
2607
|
className: "ric-edge-textbg",
|
|
2600
2608
|
style: o,
|
|
2601
2609
|
rx: c,
|
|
2602
2610
|
ry: c
|
|
2603
2611
|
}
|
|
2604
2612
|
),
|
|
2605
|
-
/* @__PURE__ */
|
|
2613
|
+
/* @__PURE__ */ S(
|
|
2606
2614
|
"text",
|
|
2607
2615
|
{
|
|
2608
2616
|
className: "ric-edge-text",
|
|
2609
|
-
y:
|
|
2617
|
+
y: m.height / 2,
|
|
2610
2618
|
dy: "0.3em",
|
|
2611
|
-
ref:
|
|
2619
|
+
ref: z,
|
|
2612
2620
|
style: r,
|
|
2613
2621
|
children: n
|
|
2614
2622
|
}
|
|
@@ -2620,7 +2628,7 @@ function Vn({
|
|
|
2620
2628
|
}
|
|
2621
2629
|
Vn.displayName = "EdgeText";
|
|
2622
2630
|
const Fr = Zt(Vn);
|
|
2623
|
-
function
|
|
2631
|
+
function Hn(t) {
|
|
2624
2632
|
return t != null && t !== "" && !isNaN(Number(t));
|
|
2625
2633
|
}
|
|
2626
2634
|
function un({
|
|
@@ -2634,15 +2642,15 @@ function un({
|
|
|
2634
2642
|
labelBgStyle: c,
|
|
2635
2643
|
labelBgPadding: u,
|
|
2636
2644
|
labelBgBorderRadius: l,
|
|
2637
|
-
interactionWidth:
|
|
2638
|
-
style:
|
|
2639
|
-
markerEnd:
|
|
2640
|
-
markerStart:
|
|
2645
|
+
interactionWidth: y = 20,
|
|
2646
|
+
style: m,
|
|
2647
|
+
markerEnd: C,
|
|
2648
|
+
markerStart: z,
|
|
2641
2649
|
className: M = "",
|
|
2642
|
-
|
|
2650
|
+
...$
|
|
2643
2651
|
}) {
|
|
2644
|
-
return /* @__PURE__ */
|
|
2645
|
-
/* @__PURE__ */
|
|
2652
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
2653
|
+
/* @__PURE__ */ S(
|
|
2646
2654
|
"path",
|
|
2647
2655
|
{
|
|
2648
2656
|
id: t,
|
|
@@ -2651,24 +2659,24 @@ function un({
|
|
|
2651
2659
|
stroke: "#b1b1b7",
|
|
2652
2660
|
strokeWidth: 1.5,
|
|
2653
2661
|
className: `ric-edge-path ${M}`,
|
|
2654
|
-
style:
|
|
2655
|
-
markerEnd:
|
|
2656
|
-
markerStart:
|
|
2657
|
-
|
|
2662
|
+
style: m,
|
|
2663
|
+
markerEnd: C,
|
|
2664
|
+
markerStart: z,
|
|
2665
|
+
...$
|
|
2658
2666
|
}
|
|
2659
2667
|
),
|
|
2660
|
-
|
|
2668
|
+
y ? /* @__PURE__ */ S(
|
|
2661
2669
|
"path",
|
|
2662
2670
|
{
|
|
2663
2671
|
d: e,
|
|
2664
2672
|
fill: "none",
|
|
2665
2673
|
strokeOpacity: 0,
|
|
2666
|
-
strokeWidth:
|
|
2674
|
+
strokeWidth: y,
|
|
2667
2675
|
className: "ric-edge-interaction",
|
|
2668
2676
|
style: { pointerEvents: "stroke" }
|
|
2669
2677
|
}
|
|
2670
2678
|
) : null,
|
|
2671
|
-
s &&
|
|
2679
|
+
s && Hn(n) && Hn(r) ? /* @__PURE__ */ S(
|
|
2672
2680
|
Fr,
|
|
2673
2681
|
{
|
|
2674
2682
|
x: n,
|
|
@@ -2708,65 +2716,65 @@ const tr = Zt(function({
|
|
|
2708
2716
|
targetPosition: c = "top",
|
|
2709
2717
|
label: u,
|
|
2710
2718
|
labelStyle: l,
|
|
2711
|
-
labelShowBg:
|
|
2712
|
-
labelBgStyle:
|
|
2713
|
-
labelBgPadding:
|
|
2714
|
-
labelBgBorderRadius:
|
|
2719
|
+
labelShowBg: y,
|
|
2720
|
+
labelBgStyle: m,
|
|
2721
|
+
labelBgPadding: C,
|
|
2722
|
+
labelBgBorderRadius: z,
|
|
2715
2723
|
style: M,
|
|
2716
|
-
markerEnd:
|
|
2724
|
+
markerEnd: $,
|
|
2717
2725
|
markerStart: k,
|
|
2718
|
-
interactionWidth:
|
|
2726
|
+
interactionWidth: E
|
|
2719
2727
|
}) {
|
|
2720
|
-
let
|
|
2721
|
-
const f = _n(n, r, i), p = _n(s, o, c),
|
|
2722
|
-
let
|
|
2728
|
+
let _, D, g;
|
|
2729
|
+
const f = _n(n, r, i), p = _n(s, o, c), v = Math.abs(p.x - f.x), N = Math.max(50, v * 0.5);
|
|
2730
|
+
let w, P, R, B;
|
|
2723
2731
|
switch (i) {
|
|
2724
2732
|
case "left":
|
|
2725
|
-
|
|
2733
|
+
w = f.x - N, P = f.y;
|
|
2726
2734
|
break;
|
|
2727
2735
|
case "top":
|
|
2728
|
-
|
|
2736
|
+
w = f.x, P = f.y - N;
|
|
2729
2737
|
break;
|
|
2730
2738
|
case "bottom":
|
|
2731
|
-
|
|
2739
|
+
w = f.x, P = f.y + N;
|
|
2732
2740
|
break;
|
|
2733
2741
|
default:
|
|
2734
|
-
|
|
2742
|
+
w = f.x + N, P = f.y;
|
|
2735
2743
|
break;
|
|
2736
2744
|
}
|
|
2737
2745
|
switch (c) {
|
|
2738
2746
|
case "right":
|
|
2739
|
-
|
|
2747
|
+
R = p.x + N, B = p.y;
|
|
2740
2748
|
break;
|
|
2741
2749
|
case "top":
|
|
2742
|
-
|
|
2750
|
+
R = p.x, B = p.y - N;
|
|
2743
2751
|
break;
|
|
2744
2752
|
case "bottom":
|
|
2745
|
-
|
|
2753
|
+
R = p.x, B = p.y + N;
|
|
2746
2754
|
break;
|
|
2747
2755
|
default:
|
|
2748
|
-
|
|
2756
|
+
R = p.x - N, B = p.y;
|
|
2749
2757
|
break;
|
|
2750
2758
|
}
|
|
2751
|
-
|
|
2752
|
-
const
|
|
2753
|
-
return D =
|
|
2759
|
+
_ = `M ${n},${r} L ${f.x},${f.y} C ${w},${P} ${R},${B} ${p.x},${p.y} L ${s},${o}`;
|
|
2760
|
+
const q = 0.5, X = 0.5;
|
|
2761
|
+
return D = X * X * X * f.x + 3 * X * X * q * w + 3 * X * q * q * R + q * q * q * p.x, g = X * X * X * f.y + 3 * X * X * q * P + 3 * X * q * q * B + q * q * q * p.y, /* @__PURE__ */ S(
|
|
2754
2762
|
un,
|
|
2755
2763
|
{
|
|
2756
2764
|
id: e,
|
|
2757
|
-
path:
|
|
2765
|
+
path: _,
|
|
2758
2766
|
labelX: D,
|
|
2759
|
-
labelY:
|
|
2767
|
+
labelY: g,
|
|
2760
2768
|
label: u,
|
|
2761
2769
|
labelStyle: l,
|
|
2762
|
-
labelShowBg:
|
|
2763
|
-
labelBgStyle:
|
|
2764
|
-
labelBgPadding:
|
|
2765
|
-
labelBgBorderRadius:
|
|
2770
|
+
labelShowBg: y,
|
|
2771
|
+
labelBgStyle: m,
|
|
2772
|
+
labelBgPadding: C,
|
|
2773
|
+
labelBgBorderRadius: z,
|
|
2766
2774
|
style: M,
|
|
2767
|
-
markerEnd:
|
|
2775
|
+
markerEnd: $,
|
|
2768
2776
|
markerStart: k,
|
|
2769
|
-
interactionWidth:
|
|
2777
|
+
interactionWidth: E
|
|
2770
2778
|
}
|
|
2771
2779
|
);
|
|
2772
2780
|
});
|
|
@@ -2784,42 +2792,42 @@ function nr({
|
|
|
2784
2792
|
targetPosition: o = "left",
|
|
2785
2793
|
curvature: i = 0.25
|
|
2786
2794
|
}) {
|
|
2787
|
-
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u),
|
|
2788
|
-
let
|
|
2795
|
+
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), y = Math.max(l * i, 50);
|
|
2796
|
+
let m, C, z, M;
|
|
2789
2797
|
switch (s) {
|
|
2790
2798
|
case "top":
|
|
2791
|
-
|
|
2799
|
+
m = t, C = e - y;
|
|
2792
2800
|
break;
|
|
2793
2801
|
case "bottom":
|
|
2794
|
-
|
|
2802
|
+
m = t, C = e + y;
|
|
2795
2803
|
break;
|
|
2796
2804
|
case "left":
|
|
2797
|
-
|
|
2805
|
+
m = t - y, C = e;
|
|
2798
2806
|
break;
|
|
2799
2807
|
default:
|
|
2800
|
-
|
|
2808
|
+
m = t + y, C = e;
|
|
2801
2809
|
break;
|
|
2802
2810
|
}
|
|
2803
2811
|
switch (o) {
|
|
2804
2812
|
case "top":
|
|
2805
|
-
|
|
2813
|
+
z = n, M = r - y;
|
|
2806
2814
|
break;
|
|
2807
2815
|
case "bottom":
|
|
2808
|
-
|
|
2816
|
+
z = n, M = r + y;
|
|
2809
2817
|
break;
|
|
2810
2818
|
case "right":
|
|
2811
|
-
|
|
2819
|
+
z = n + y, M = r;
|
|
2812
2820
|
break;
|
|
2813
2821
|
default:
|
|
2814
|
-
|
|
2822
|
+
z = n - y, M = r;
|
|
2815
2823
|
break;
|
|
2816
2824
|
}
|
|
2817
|
-
const
|
|
2818
|
-
return [
|
|
2825
|
+
const $ = `M ${t},${e} C ${m},${C} ${z},${M} ${n},${r}`, k = 0.5, E = 1 - k, _ = E * E * E * t + 3 * E * E * k * m + 3 * E * k * k * z + k * k * k * n, D = E * E * E * e + 3 * E * E * k * C + 3 * E * k * k * M + k * k * k * r;
|
|
2826
|
+
return [$, _, D, 0, 0];
|
|
2819
2827
|
}
|
|
2820
2828
|
function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2821
|
-
const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5,
|
|
2822
|
-
return [u,
|
|
2829
|
+
const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5, y = 0.5, m = y * y * y * t + 3 * y * y * l * i + 3 * y * l * l * c + l * l * l * n, C = y * y * y * e + 3 * y * y * l * e + 3 * y * l * l * r + l * l * l * r;
|
|
2830
|
+
return [u, m, C, 0, 0];
|
|
2823
2831
|
}
|
|
2824
2832
|
function kn({
|
|
2825
2833
|
sourceX: t,
|
|
@@ -2835,11 +2843,11 @@ function kn({
|
|
|
2835
2843
|
if (u) {
|
|
2836
2844
|
if (Math.abs(r - e) < 1)
|
|
2837
2845
|
return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
|
|
2838
|
-
const
|
|
2839
|
-
return [`M ${t},${e} L ${
|
|
2846
|
+
const z = (t + n) / 2, M = r > e ? 1 : -1;
|
|
2847
|
+
return [`M ${t},${e} L ${z - l},${e} Q ${z},${e} ${z},${e + M * l} L ${z},${r - M * l} Q ${z},${r} ${z + (n > z ? l : -l)},${r} L ${n},${r}`, z, (e + r) / 2, 0, 0];
|
|
2840
2848
|
}
|
|
2841
|
-
const
|
|
2842
|
-
return [`M ${t},${e} L ${t},${
|
|
2849
|
+
const y = (e + r) / 2, m = n > t ? 1 : -1;
|
|
2850
|
+
return [`M ${t},${e} L ${t},${y - l} Q ${t},${y} ${t + m * l},${y} L ${n - m * l},${y} Q ${n},${y} ${n},${y + (r > y ? l : -l)} L ${n},${r}`, (t + n) / 2, y, 0, 0];
|
|
2843
2851
|
}
|
|
2844
2852
|
function zo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2845
2853
|
const [, s, o] = nr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
@@ -2897,20 +2905,20 @@ function ln(t, e) {
|
|
|
2897
2905
|
}
|
|
2898
2906
|
}
|
|
2899
2907
|
function Yr(t, e, n, r, s, o, i, c) {
|
|
2900
|
-
const u = Math.min(t, n), l = Math.max(t, n),
|
|
2901
|
-
if (l <= s || u >= s + i ||
|
|
2902
|
-
const
|
|
2903
|
-
if (t > s +
|
|
2904
|
-
const
|
|
2905
|
-
if (
|
|
2906
|
-
const
|
|
2908
|
+
const u = Math.min(t, n), l = Math.max(t, n), y = Math.min(e, r), m = Math.max(e, r);
|
|
2909
|
+
if (l <= s || u >= s + i || m <= o || y >= o + c) return !1;
|
|
2910
|
+
const C = 0.5;
|
|
2911
|
+
if (t > s + C && t < s + i - C && e > o + C && e < o + c - C || n > s + C && n < s + i - C && r > o + C && r < o + c - C) return !0;
|
|
2912
|
+
const z = (t + n) / 2, M = (e + r) / 2;
|
|
2913
|
+
if (z > s + C && z < s + i - C && M > o + C && M < o + c - C) return !0;
|
|
2914
|
+
const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
|
|
2907
2915
|
for (let k = 0; k < 4; k++)
|
|
2908
|
-
if (Ur(t, e, n, r,
|
|
2916
|
+
if (Ur(t, e, n, r, $[k][0], $[k][1], $[(k + 1) % 4][0], $[(k + 1) % 4][1])) return !0;
|
|
2909
2917
|
return !1;
|
|
2910
2918
|
}
|
|
2911
2919
|
function Ur(t, e, n, r, s, o, i, c) {
|
|
2912
|
-
const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s),
|
|
2913
|
-
return (u > 0 && l < 0 || u < 0 && l > 0) && (
|
|
2920
|
+
const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s), y = (n - t) * (o - e) - (r - e) * (s - t), m = (n - t) * (c - e) - (r - e) * (i - t);
|
|
2921
|
+
return (u > 0 && l < 0 || u < 0 && l > 0) && (y > 0 && m < 0 || y < 0 && m > 0);
|
|
2914
2922
|
}
|
|
2915
2923
|
function zn(t, e, n, r, s) {
|
|
2916
2924
|
for (let o = 0; o < s.length; o++) {
|
|
@@ -2950,44 +2958,44 @@ function sr(t, e, n) {
|
|
|
2950
2958
|
r.add(t.x), r.add(e.x), s.add(t.y), s.add(e.y);
|
|
2951
2959
|
const o = Ue + 5;
|
|
2952
2960
|
t.dir === "right" ? r.add(t.x + o) : t.dir === "left" ? r.add(t.x - o) : t.dir === "top" ? s.add(t.y - o) : t.dir === "bottom" && s.add(t.y + o), e.dir === "right" ? r.add(e.x + o) : e.dir === "left" ? r.add(e.x - o) : e.dir === "top" ? s.add(e.y - o) : e.dir === "bottom" && s.add(e.y + o);
|
|
2953
|
-
for (let
|
|
2954
|
-
const
|
|
2955
|
-
r.add(
|
|
2961
|
+
for (let R = 0; R < n.length; R++) {
|
|
2962
|
+
const B = n[R];
|
|
2963
|
+
r.add(B.x), r.add(B.x + B.w), s.add(B.y), s.add(B.y + B.h);
|
|
2956
2964
|
}
|
|
2957
|
-
const i = [...r].sort((
|
|
2958
|
-
for (let
|
|
2959
|
-
for (let
|
|
2960
|
-
const
|
|
2961
|
-
if (
|
|
2962
|
-
const
|
|
2963
|
-
D[
|
|
2964
|
-
const N = [
|
|
2965
|
+
const i = [...r].sort((R, B) => R - B), c = [...s].sort((R, B) => R - B), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2966
|
+
for (let R = 0; R < i.length; R++) u.set(i[R], R);
|
|
2967
|
+
for (let R = 0; R < c.length; R++) l.set(c[R], R);
|
|
2968
|
+
const y = i.length, m = c.length, C = (R, B) => B * y + R, z = u.get(t.x), M = l.get(t.y), $ = u.get(e.x), k = l.get(e.y);
|
|
2969
|
+
if (z === void 0 || M === void 0 || $ === void 0 || k === void 0) return null;
|
|
2970
|
+
const E = C(z, M), _ = C($, k), D = new Float64Array(y * m).fill(1 / 0), g = new Float64Array(y * m).fill(1 / 0), f = new Int32Array(y * m).fill(-1), p = new Int8Array(y * m).fill(-1), v = new Uint8Array(y * m);
|
|
2971
|
+
D[E] = 0, g[E] = Math.abs(i[$] - t.x) + Math.abs(c[k] - t.y);
|
|
2972
|
+
const N = [E], w = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
|
|
2965
2973
|
for (; N.length > 0; ) {
|
|
2966
|
-
let
|
|
2974
|
+
let R = 0;
|
|
2967
2975
|
for (let G = 1; G < N.length; G++)
|
|
2968
|
-
|
|
2969
|
-
const
|
|
2970
|
-
if (N[
|
|
2976
|
+
g[N[G]] < g[N[R]] && (R = G);
|
|
2977
|
+
const B = N[R];
|
|
2978
|
+
if (N[R] = N[N.length - 1], N.pop(), B === _) {
|
|
2971
2979
|
const G = [];
|
|
2972
|
-
let j =
|
|
2973
|
-
for (; j !== -1 && j !==
|
|
2974
|
-
const
|
|
2975
|
-
G.unshift({ x: i[
|
|
2980
|
+
let j = _;
|
|
2981
|
+
for (; j !== -1 && j !== E; ) {
|
|
2982
|
+
const it = j / y | 0, dt = j % y;
|
|
2983
|
+
G.unshift({ x: i[dt], y: c[it] }), j = f[j];
|
|
2976
2984
|
}
|
|
2977
2985
|
return G.unshift({ x: t.x, y: t.y }), jr(G, n);
|
|
2978
2986
|
}
|
|
2979
|
-
if (
|
|
2980
|
-
|
|
2981
|
-
const
|
|
2987
|
+
if (v[B]) continue;
|
|
2988
|
+
v[B] = 1;
|
|
2989
|
+
const q = B / y | 0, X = B % y, K = i[X], at = c[q], rt = p[B];
|
|
2982
2990
|
for (let G = 0; G < 4; G++) {
|
|
2983
|
-
const j =
|
|
2984
|
-
if (j < 0 || j >=
|
|
2985
|
-
const
|
|
2986
|
-
if (
|
|
2987
|
-
const
|
|
2988
|
-
if (qr(
|
|
2989
|
-
const
|
|
2990
|
-
|
|
2991
|
+
const j = X + P[G][0], it = q + P[G][1];
|
|
2992
|
+
if (j < 0 || j >= y || it < 0 || it >= m) continue;
|
|
2993
|
+
const dt = C(j, it);
|
|
2994
|
+
if (v[dt]) continue;
|
|
2995
|
+
const ot = i[j], ft = c[it];
|
|
2996
|
+
if (qr(ot, ft, n) || !zn(K, at, ot, ft, n)) continue;
|
|
2997
|
+
const It = Math.abs(ot - K) + Math.abs(ft - at), st = rt >= 0 && rt !== G ? w : 0, xt = D[B] + It + st;
|
|
2998
|
+
xt < D[dt] && (f[dt] = B, p[dt] = G, D[dt] = xt, g[dt] = xt + Math.abs(i[$] - ot) + Math.abs(c[k] - ft), N.push(dt));
|
|
2991
2999
|
}
|
|
2992
3000
|
}
|
|
2993
3001
|
return null;
|
|
@@ -3027,8 +3035,8 @@ function Gr(t) {
|
|
|
3027
3035
|
if (i.length < 2) continue;
|
|
3028
3036
|
const c = (i.length - 1) * nn / 2;
|
|
3029
3037
|
for (let u = 0; u < i.length; u++) {
|
|
3030
|
-
const l = i[u],
|
|
3031
|
-
|
|
3038
|
+
const l = i[u], y = -c + u * nn, m = r.get(l.edgeId);
|
|
3039
|
+
m && (m[l.segIdx].y += y, m[l.segIdx + 1].y += y);
|
|
3032
3040
|
}
|
|
3033
3041
|
}
|
|
3034
3042
|
}
|
|
@@ -3039,8 +3047,8 @@ function Gr(t) {
|
|
|
3039
3047
|
if (i.length < 2) continue;
|
|
3040
3048
|
const c = (i.length - 1) * nn / 2;
|
|
3041
3049
|
for (let u = 0; u < i.length; u++) {
|
|
3042
|
-
const l = i[u],
|
|
3043
|
-
|
|
3050
|
+
const l = i[u], y = -c + u * nn, m = r.get(l.edgeId);
|
|
3051
|
+
m && (m[l.segIdx].x += y, m[l.segIdx + 1].x += y);
|
|
3044
3052
|
}
|
|
3045
3053
|
}
|
|
3046
3054
|
}
|
|
@@ -3065,10 +3073,10 @@ function En(t, e = 6, n = !1) {
|
|
|
3065
3073
|
const r = e;
|
|
3066
3074
|
let s = `M ${t[0].x},${t[0].y}`;
|
|
3067
3075
|
for (let o = 1; o < t.length - 1; o++) {
|
|
3068
|
-
const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y),
|
|
3069
|
-
if (
|
|
3070
|
-
const
|
|
3071
|
-
s += ` L ${c.x -
|
|
3076
|
+
const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y), y = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), m = Math.min(r, l / 2, y / 2);
|
|
3077
|
+
if (m > 0.5) {
|
|
3078
|
+
const C = c.x - i.x, z = c.y - i.y, M = u.x - c.x, $ = u.y - c.y, k = Math.sqrt(C * C + z * z) || 1, E = Math.sqrt(M * M + $ * $) || 1;
|
|
3079
|
+
s += ` L ${c.x - C / k * m},${c.y - z / k * m}`, s += ` Q ${c.x},${c.y} ${c.x + M / E * m},${c.y + $ / E * m}`;
|
|
3072
3080
|
} else
|
|
3073
3081
|
s += ` L ${c.x},${c.y}`;
|
|
3074
3082
|
}
|
|
@@ -3082,8 +3090,8 @@ function Zr(t) {
|
|
|
3082
3090
|
const e = 0.3;
|
|
3083
3091
|
let n = `M ${t[0].x},${t[0].y}`;
|
|
3084
3092
|
for (let r = 0; r < t.length - 1; r++) {
|
|
3085
|
-
const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e,
|
|
3086
|
-
n += ` C ${u},${l} ${
|
|
3093
|
+
const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e, y = i.x - (c.x - o.x) * e, m = i.y - (c.y - o.y) * e;
|
|
3094
|
+
n += ` C ${u},${l} ${y},${m} ${i.x},${i.y}`;
|
|
3087
3095
|
}
|
|
3088
3096
|
return n;
|
|
3089
3097
|
}
|
|
@@ -3111,25 +3119,25 @@ function No(t, e) {
|
|
|
3111
3119
|
const n = {};
|
|
3112
3120
|
for (const o of t) n[o.id] = o;
|
|
3113
3121
|
const r = or(t, null), s = e.map((o) => {
|
|
3114
|
-
var p,
|
|
3122
|
+
var p, v, N, w;
|
|
3115
3123
|
const i = o.type || "default";
|
|
3116
3124
|
if (i === "bezier" || i === "simplebezier" || i === "default") return o;
|
|
3117
3125
|
const c = n[o.source], u = n[o.target];
|
|
3118
3126
|
if (!c || !u || c.hidden || u.hidden) return o;
|
|
3119
|
-
const l = Wn(c, "source", o.sourceHandle),
|
|
3120
|
-
M.push({ id: o.source, x:
|
|
3121
|
-
const
|
|
3122
|
-
if (M.push({ id: o.target, x:
|
|
3123
|
-
const f = sr(
|
|
3124
|
-
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x:
|
|
3127
|
+
const l = Wn(c, "source", o.sourceHandle), y = Wn(u, "target", o.targetHandle), m = ln(l, cn), C = ln(y, cn), z = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), $ = c._absolutePosition || c.position, k = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, E = c.height || ((v = c.measured) == null ? void 0 : v.height) || an;
|
|
3128
|
+
M.push({ id: o.source, x: $.x - z, y: $.y - z, w: k + 2 * z, h: E + 2 * z });
|
|
3129
|
+
const _ = u._absolutePosition || u.position, D = u.width || ((N = u.measured) == null ? void 0 : N.width) || sn, g = u.height || ((w = u.measured) == null ? void 0 : w.height) || an;
|
|
3130
|
+
if (M.push({ id: o.target, x: _.x - z, y: _.y - z, w: D + 2 * z, h: g + 2 * z }), M.length === 0) return o;
|
|
3131
|
+
const f = sr(m, C, M);
|
|
3132
|
+
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: y.x, y: y.y }), { ...o, _routedPoints: f }) : o;
|
|
3125
3133
|
});
|
|
3126
3134
|
return Gr(s);
|
|
3127
3135
|
}
|
|
3128
3136
|
function Lo(t, e, n, r, s, o, i, c) {
|
|
3129
3137
|
const u = or(i, c ? new Set(c) : null);
|
|
3130
3138
|
if (u.length === 0) return null;
|
|
3131
|
-
const l = { x: t, y: e, dir: s || "right" },
|
|
3132
|
-
return
|
|
3139
|
+
const l = { x: t, y: e, dir: s || "right" }, y = { x: n, y: r, dir: o || "left" }, m = ln(l, cn), C = ln(y, cn), z = sr(m, C, u);
|
|
3140
|
+
return z && z.length >= 2 ? (z.unshift({ x: l.x, y: l.y }), z.push({ x: y.x, y: y.y }), z) : null;
|
|
3133
3141
|
}
|
|
3134
3142
|
const ir = Zt(function({
|
|
3135
3143
|
id: e,
|
|
@@ -3141,38 +3149,38 @@ const ir = Zt(function({
|
|
|
3141
3149
|
labelStyle: c,
|
|
3142
3150
|
labelShowBg: u,
|
|
3143
3151
|
labelBgStyle: l,
|
|
3144
|
-
labelBgPadding:
|
|
3145
|
-
labelBgBorderRadius:
|
|
3146
|
-
style:
|
|
3147
|
-
markerEnd:
|
|
3152
|
+
labelBgPadding: y,
|
|
3153
|
+
labelBgBorderRadius: m,
|
|
3154
|
+
style: C,
|
|
3155
|
+
markerEnd: z,
|
|
3148
3156
|
markerStart: M,
|
|
3149
|
-
interactionWidth:
|
|
3157
|
+
interactionWidth: $,
|
|
3150
3158
|
routedPoints: k
|
|
3151
3159
|
}) {
|
|
3152
|
-
let
|
|
3160
|
+
let E, _, D;
|
|
3153
3161
|
if (k && k.length >= 2) {
|
|
3154
|
-
|
|
3155
|
-
const
|
|
3156
|
-
|
|
3162
|
+
E = En(k);
|
|
3163
|
+
const g = Cn(k);
|
|
3164
|
+
_ = g.x, D = g.y;
|
|
3157
3165
|
} else
|
|
3158
|
-
[
|
|
3159
|
-
return /* @__PURE__ */
|
|
3166
|
+
[E, _, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
|
|
3167
|
+
return /* @__PURE__ */ S(
|
|
3160
3168
|
un,
|
|
3161
3169
|
{
|
|
3162
3170
|
id: e,
|
|
3163
|
-
path:
|
|
3164
|
-
labelX:
|
|
3171
|
+
path: E,
|
|
3172
|
+
labelX: _,
|
|
3165
3173
|
labelY: D,
|
|
3166
3174
|
label: i,
|
|
3167
3175
|
labelStyle: c,
|
|
3168
3176
|
labelShowBg: u,
|
|
3169
3177
|
labelBgStyle: l,
|
|
3170
|
-
labelBgPadding:
|
|
3171
|
-
labelBgBorderRadius:
|
|
3172
|
-
style:
|
|
3173
|
-
markerEnd:
|
|
3178
|
+
labelBgPadding: y,
|
|
3179
|
+
labelBgBorderRadius: m,
|
|
3180
|
+
style: C,
|
|
3181
|
+
markerEnd: z,
|
|
3174
3182
|
markerStart: M,
|
|
3175
|
-
interactionWidth:
|
|
3183
|
+
interactionWidth: $
|
|
3176
3184
|
}
|
|
3177
3185
|
);
|
|
3178
3186
|
});
|
|
@@ -3187,50 +3195,50 @@ const ar = Zt(function({
|
|
|
3187
3195
|
targetPosition: c = "top",
|
|
3188
3196
|
label: u,
|
|
3189
3197
|
labelStyle: l,
|
|
3190
|
-
labelShowBg:
|
|
3191
|
-
labelBgStyle:
|
|
3192
|
-
labelBgPadding:
|
|
3193
|
-
labelBgBorderRadius:
|
|
3198
|
+
labelShowBg: y,
|
|
3199
|
+
labelBgStyle: m,
|
|
3200
|
+
labelBgPadding: C,
|
|
3201
|
+
labelBgBorderRadius: z,
|
|
3194
3202
|
style: M,
|
|
3195
|
-
markerEnd:
|
|
3203
|
+
markerEnd: $,
|
|
3196
3204
|
markerStart: k,
|
|
3197
|
-
pathOptions:
|
|
3198
|
-
interactionWidth:
|
|
3205
|
+
pathOptions: E,
|
|
3206
|
+
interactionWidth: _,
|
|
3199
3207
|
routedPoints: D
|
|
3200
3208
|
}) {
|
|
3201
|
-
let
|
|
3209
|
+
let g, f, p;
|
|
3202
3210
|
if (D && D.length >= 2) {
|
|
3203
|
-
|
|
3204
|
-
const
|
|
3205
|
-
f =
|
|
3211
|
+
g = En(D);
|
|
3212
|
+
const v = Cn(D);
|
|
3213
|
+
f = v.x, p = v.y;
|
|
3206
3214
|
} else
|
|
3207
|
-
[
|
|
3215
|
+
[g, f, p] = kn({
|
|
3208
3216
|
sourceX: n,
|
|
3209
3217
|
sourceY: r,
|
|
3210
3218
|
sourcePosition: i,
|
|
3211
3219
|
targetX: s,
|
|
3212
3220
|
targetY: o,
|
|
3213
3221
|
targetPosition: c,
|
|
3214
|
-
borderRadius:
|
|
3215
|
-
offset:
|
|
3222
|
+
borderRadius: E == null ? void 0 : E.borderRadius,
|
|
3223
|
+
offset: E == null ? void 0 : E.offset
|
|
3216
3224
|
});
|
|
3217
|
-
return /* @__PURE__ */
|
|
3225
|
+
return /* @__PURE__ */ S(
|
|
3218
3226
|
un,
|
|
3219
3227
|
{
|
|
3220
3228
|
id: e,
|
|
3221
|
-
path:
|
|
3229
|
+
path: g,
|
|
3222
3230
|
labelX: f,
|
|
3223
3231
|
labelY: p,
|
|
3224
3232
|
label: u,
|
|
3225
3233
|
labelStyle: l,
|
|
3226
|
-
labelShowBg:
|
|
3227
|
-
labelBgStyle:
|
|
3228
|
-
labelBgPadding:
|
|
3229
|
-
labelBgBorderRadius:
|
|
3234
|
+
labelShowBg: y,
|
|
3235
|
+
labelBgStyle: m,
|
|
3236
|
+
labelBgPadding: C,
|
|
3237
|
+
labelBgBorderRadius: z,
|
|
3230
3238
|
style: M,
|
|
3231
|
-
markerEnd:
|
|
3239
|
+
markerEnd: $,
|
|
3232
3240
|
markerStart: k,
|
|
3233
|
-
interactionWidth:
|
|
3241
|
+
interactionWidth: _
|
|
3234
3242
|
}
|
|
3235
3243
|
);
|
|
3236
3244
|
});
|
|
@@ -3244,7 +3252,7 @@ const Or = Zt(function({ id: e, ...n }) {
|
|
|
3244
3252
|
},
|
|
3245
3253
|
[(s = n.pathOptions) == null ? void 0 : s.offset]
|
|
3246
3254
|
);
|
|
3247
|
-
return /* @__PURE__ */
|
|
3255
|
+
return /* @__PURE__ */ S(ar, { ...n, id: e, pathOptions: r });
|
|
3248
3256
|
});
|
|
3249
3257
|
Or.displayName = "StepEdge";
|
|
3250
3258
|
const cr = Zt(function({
|
|
@@ -3257,45 +3265,45 @@ const cr = Zt(function({
|
|
|
3257
3265
|
targetPosition: c,
|
|
3258
3266
|
label: u,
|
|
3259
3267
|
labelStyle: l,
|
|
3260
|
-
labelShowBg:
|
|
3261
|
-
labelBgStyle:
|
|
3262
|
-
labelBgPadding:
|
|
3263
|
-
labelBgBorderRadius:
|
|
3268
|
+
labelShowBg: y,
|
|
3269
|
+
labelBgStyle: m,
|
|
3270
|
+
labelBgPadding: C,
|
|
3271
|
+
labelBgBorderRadius: z,
|
|
3264
3272
|
style: M,
|
|
3265
|
-
markerEnd:
|
|
3273
|
+
markerEnd: $,
|
|
3266
3274
|
markerStart: k,
|
|
3267
|
-
interactionWidth:
|
|
3268
|
-
routedPoints:
|
|
3275
|
+
interactionWidth: E,
|
|
3276
|
+
routedPoints: _
|
|
3269
3277
|
}) {
|
|
3270
|
-
let D,
|
|
3271
|
-
if (
|
|
3272
|
-
D = En(
|
|
3273
|
-
const p = Cn(
|
|
3274
|
-
|
|
3278
|
+
let D, g, f;
|
|
3279
|
+
if (_ && _.length >= 2) {
|
|
3280
|
+
D = En(_);
|
|
3281
|
+
const p = Cn(_);
|
|
3282
|
+
g = p.x, f = p.y;
|
|
3275
3283
|
} else
|
|
3276
|
-
[D,
|
|
3284
|
+
[D, g, f] = rr({
|
|
3277
3285
|
sourceX: n,
|
|
3278
3286
|
sourceY: r,
|
|
3279
3287
|
targetX: s,
|
|
3280
3288
|
targetY: o
|
|
3281
3289
|
});
|
|
3282
|
-
return /* @__PURE__ */
|
|
3290
|
+
return /* @__PURE__ */ S(
|
|
3283
3291
|
un,
|
|
3284
3292
|
{
|
|
3285
3293
|
id: e,
|
|
3286
3294
|
path: D,
|
|
3287
|
-
labelX:
|
|
3295
|
+
labelX: g,
|
|
3288
3296
|
labelY: f,
|
|
3289
3297
|
label: u,
|
|
3290
3298
|
labelStyle: l,
|
|
3291
|
-
labelShowBg:
|
|
3292
|
-
labelBgStyle:
|
|
3293
|
-
labelBgPadding:
|
|
3294
|
-
labelBgBorderRadius:
|
|
3299
|
+
labelShowBg: y,
|
|
3300
|
+
labelBgStyle: m,
|
|
3301
|
+
labelBgPadding: C,
|
|
3302
|
+
labelBgBorderRadius: z,
|
|
3295
3303
|
style: M,
|
|
3296
|
-
markerEnd:
|
|
3304
|
+
markerEnd: $,
|
|
3297
3305
|
markerStart: k,
|
|
3298
|
-
interactionWidth:
|
|
3306
|
+
interactionWidth: E
|
|
3299
3307
|
}
|
|
3300
3308
|
);
|
|
3301
3309
|
});
|
|
@@ -3324,49 +3332,49 @@ function Io({
|
|
|
3324
3332
|
width: c = "100%",
|
|
3325
3333
|
height: u = "420px",
|
|
3326
3334
|
className: l = "",
|
|
3327
|
-
style:
|
|
3335
|
+
style: y = {},
|
|
3328
3336
|
// Zoom/Camera
|
|
3329
|
-
zoomMin:
|
|
3330
|
-
zoomMax:
|
|
3331
|
-
initialCamera:
|
|
3337
|
+
zoomMin: m,
|
|
3338
|
+
zoomMax: C,
|
|
3339
|
+
initialCamera: z,
|
|
3332
3340
|
fitView: M,
|
|
3333
|
-
fitViewOptions:
|
|
3341
|
+
fitViewOptions: $,
|
|
3334
3342
|
// Node/Edge callbacks
|
|
3335
3343
|
onNodesChange: k,
|
|
3336
|
-
onEdgesChange:
|
|
3337
|
-
onConnect:
|
|
3344
|
+
onEdgesChange: E,
|
|
3345
|
+
onConnect: _,
|
|
3338
3346
|
onConnectStart: D,
|
|
3339
|
-
onConnectEnd:
|
|
3347
|
+
onConnectEnd: g,
|
|
3340
3348
|
onNodeClick: f,
|
|
3341
3349
|
onNodeDoubleClick: p,
|
|
3342
|
-
onNodeMouseEnter:
|
|
3350
|
+
onNodeMouseEnter: v,
|
|
3343
3351
|
onNodeMouseMove: N,
|
|
3344
|
-
onNodeMouseLeave:
|
|
3352
|
+
onNodeMouseLeave: w,
|
|
3345
3353
|
onNodeContextMenu: P,
|
|
3346
|
-
onNodeDragStart:
|
|
3347
|
-
onNodeDrag:
|
|
3348
|
-
onNodeDragStop:
|
|
3349
|
-
onEdgeClick:
|
|
3350
|
-
onEdgeDoubleClick:
|
|
3351
|
-
onEdgeMouseEnter:
|
|
3352
|
-
onEdgeMouseMove:
|
|
3354
|
+
onNodeDragStart: R,
|
|
3355
|
+
onNodeDrag: B,
|
|
3356
|
+
onNodeDragStop: q,
|
|
3357
|
+
onEdgeClick: X,
|
|
3358
|
+
onEdgeDoubleClick: K,
|
|
3359
|
+
onEdgeMouseEnter: at,
|
|
3360
|
+
onEdgeMouseMove: rt,
|
|
3353
3361
|
onEdgeMouseLeave: G,
|
|
3354
3362
|
onEdgeContextMenu: j,
|
|
3355
|
-
onPaneClick:
|
|
3356
|
-
onPaneContextMenu:
|
|
3357
|
-
onPaneMouseEnter:
|
|
3358
|
-
onPaneMouseMove:
|
|
3359
|
-
onPaneMouseLeave:
|
|
3360
|
-
onSelectionChange:
|
|
3361
|
-
onInit:
|
|
3363
|
+
onPaneClick: it,
|
|
3364
|
+
onPaneContextMenu: dt,
|
|
3365
|
+
onPaneMouseEnter: ot,
|
|
3366
|
+
onPaneMouseMove: ft,
|
|
3367
|
+
onPaneMouseLeave: It,
|
|
3368
|
+
onSelectionChange: st,
|
|
3369
|
+
onInit: xt,
|
|
3362
3370
|
onMoveStart: Nt,
|
|
3363
|
-
onMove:
|
|
3364
|
-
onMoveEnd:
|
|
3365
|
-
onDelete:
|
|
3366
|
-
onBeforeDelete:
|
|
3367
|
-
onError:
|
|
3371
|
+
onMove: gt,
|
|
3372
|
+
onMoveEnd: ct,
|
|
3373
|
+
onDelete: zt,
|
|
3374
|
+
onBeforeDelete: Rt,
|
|
3375
|
+
onError: Lt,
|
|
3368
3376
|
// Drag and drop
|
|
3369
|
-
onDragOver:
|
|
3377
|
+
onDragOver: wt,
|
|
3370
3378
|
onDrop: ne,
|
|
3371
3379
|
onDragEnter: Ie,
|
|
3372
3380
|
onDragLeave: Bt,
|
|
@@ -3393,10 +3401,10 @@ function Io({
|
|
|
3393
3401
|
zoomOnDoubleClick: Nn,
|
|
3394
3402
|
zoomOnPinch: hn,
|
|
3395
3403
|
preventScrolling: fe,
|
|
3396
|
-
translateExtent:
|
|
3404
|
+
translateExtent: mt,
|
|
3397
3405
|
nodeExtent: Te,
|
|
3398
|
-
autoPanOnNodeDrag:
|
|
3399
|
-
autoPanOnConnect:
|
|
3406
|
+
autoPanOnNodeDrag: Et,
|
|
3407
|
+
autoPanOnConnect: pt,
|
|
3400
3408
|
autoPanSpeed: se,
|
|
3401
3409
|
edgesReconnectable: Z,
|
|
3402
3410
|
elevateNodesOnSelect: Pt,
|
|
@@ -3412,71 +3420,71 @@ function Io({
|
|
|
3412
3420
|
children: Me,
|
|
3413
3421
|
...ie
|
|
3414
3422
|
}) {
|
|
3415
|
-
const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be =
|
|
3423
|
+
const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be = tt(null), Je = tt(null), Ve = F(
|
|
3416
3424
|
(Q) => {
|
|
3417
3425
|
Re(Q), te == null || te(Q);
|
|
3418
3426
|
},
|
|
3419
3427
|
[te]
|
|
3420
3428
|
), ae = St(() => ({ ...Qr, ...r }), [r]), Kt = St(() => ({ ...Kr, ...s }), [s]), he = St(() => {
|
|
3421
3429
|
const Q = e.filter((Ft) => Ft.type && ae[Ft.type]);
|
|
3422
|
-
return Q.sort((Ft,
|
|
3423
|
-
const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe =
|
|
3430
|
+
return Q.sort((Ft, lt) => {
|
|
3431
|
+
const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe = lt.type === "group" || !lt.parentId && Q.some((Ee) => Ee.parentId === lt.id);
|
|
3424
3432
|
return Tt && !xe ? -1 : !Tt && xe ? 1 : 0;
|
|
3425
3433
|
});
|
|
3426
|
-
}, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]),
|
|
3434
|
+
}, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]), bt = St(() => n.map((Q) => Q.type && Kt[Q.type] ? { ...Q, _customRendered: !0 } : Q), [n, Kt]), {
|
|
3427
3435
|
wrapRef: Dt,
|
|
3428
3436
|
canvasRef: ce,
|
|
3429
3437
|
canvasReady: De,
|
|
3430
|
-
onPointerDown:
|
|
3431
|
-
onPointerMove:
|
|
3438
|
+
onPointerDown: Ae,
|
|
3439
|
+
onPointerMove: He,
|
|
3432
3440
|
onPointerUp: _e,
|
|
3433
3441
|
store: le
|
|
3434
3442
|
} = Lr({
|
|
3435
3443
|
cards: t,
|
|
3436
3444
|
nodes: O,
|
|
3437
|
-
edges:
|
|
3445
|
+
edges: bt,
|
|
3438
3446
|
dark: o,
|
|
3439
3447
|
gridSize: i,
|
|
3440
|
-
zoomMin:
|
|
3441
|
-
zoomMax:
|
|
3442
|
-
initialCamera:
|
|
3448
|
+
zoomMin: m,
|
|
3449
|
+
zoomMax: C,
|
|
3450
|
+
initialCamera: z,
|
|
3443
3451
|
fitView: M,
|
|
3444
|
-
fitViewOptions:
|
|
3452
|
+
fitViewOptions: $,
|
|
3445
3453
|
onHudUpdate: Ve,
|
|
3446
3454
|
onNodesProcessed: gn,
|
|
3447
3455
|
onNodesChange: k,
|
|
3448
|
-
onEdgesChange:
|
|
3449
|
-
onConnect:
|
|
3456
|
+
onEdgesChange: E,
|
|
3457
|
+
onConnect: _,
|
|
3450
3458
|
onConnectStart: D,
|
|
3451
|
-
onConnectEnd:
|
|
3459
|
+
onConnectEnd: g,
|
|
3452
3460
|
onNodeClick: f,
|
|
3453
3461
|
onNodeDoubleClick: p,
|
|
3454
|
-
onNodeMouseEnter:
|
|
3462
|
+
onNodeMouseEnter: v,
|
|
3455
3463
|
onNodeMouseMove: N,
|
|
3456
|
-
onNodeMouseLeave:
|
|
3464
|
+
onNodeMouseLeave: w,
|
|
3457
3465
|
onNodeContextMenu: P,
|
|
3458
|
-
onNodeDragStart:
|
|
3459
|
-
onNodeDrag:
|
|
3460
|
-
onNodeDragStop:
|
|
3461
|
-
onEdgeClick:
|
|
3462
|
-
onEdgeDoubleClick:
|
|
3463
|
-
onEdgeMouseEnter:
|
|
3464
|
-
onEdgeMouseMove:
|
|
3466
|
+
onNodeDragStart: R,
|
|
3467
|
+
onNodeDrag: B,
|
|
3468
|
+
onNodeDragStop: q,
|
|
3469
|
+
onEdgeClick: X,
|
|
3470
|
+
onEdgeDoubleClick: K,
|
|
3471
|
+
onEdgeMouseEnter: at,
|
|
3472
|
+
onEdgeMouseMove: rt,
|
|
3465
3473
|
onEdgeMouseLeave: G,
|
|
3466
3474
|
onEdgeContextMenu: j,
|
|
3467
|
-
onPaneClick:
|
|
3468
|
-
onPaneContextMenu:
|
|
3469
|
-
onPaneMouseEnter:
|
|
3470
|
-
onPaneMouseMove:
|
|
3471
|
-
onPaneMouseLeave:
|
|
3472
|
-
onSelectionChange:
|
|
3473
|
-
onInit:
|
|
3475
|
+
onPaneClick: it,
|
|
3476
|
+
onPaneContextMenu: dt,
|
|
3477
|
+
onPaneMouseEnter: ot,
|
|
3478
|
+
onPaneMouseMove: ft,
|
|
3479
|
+
onPaneMouseLeave: It,
|
|
3480
|
+
onSelectionChange: st,
|
|
3481
|
+
onInit: xt,
|
|
3474
3482
|
onMoveStart: Nt,
|
|
3475
|
-
onMove:
|
|
3476
|
-
onMoveEnd:
|
|
3477
|
-
onDelete:
|
|
3478
|
-
onBeforeDelete:
|
|
3479
|
-
onError:
|
|
3483
|
+
onMove: gt,
|
|
3484
|
+
onMoveEnd: ct,
|
|
3485
|
+
onDelete: zt,
|
|
3486
|
+
onBeforeDelete: Rt,
|
|
3487
|
+
onError: Lt,
|
|
3480
3488
|
nodesDraggable: Ot,
|
|
3481
3489
|
nodesConnectable: Yt,
|
|
3482
3490
|
elementsSelectable: me,
|
|
@@ -3499,10 +3507,10 @@ function Io({
|
|
|
3499
3507
|
zoomOnDoubleClick: Nn,
|
|
3500
3508
|
zoomOnPinch: hn,
|
|
3501
3509
|
preventScrolling: fe,
|
|
3502
|
-
translateExtent:
|
|
3510
|
+
translateExtent: mt,
|
|
3503
3511
|
nodeExtent: Te,
|
|
3504
|
-
autoPanOnNodeDrag:
|
|
3505
|
-
autoPanOnConnect:
|
|
3512
|
+
autoPanOnNodeDrag: Et,
|
|
3513
|
+
autoPanOnConnect: pt,
|
|
3506
3514
|
autoPanSpeed: se,
|
|
3507
3515
|
edgesReconnectable: Z,
|
|
3508
3516
|
elevateNodesOnSelect: Pt,
|
|
@@ -3518,34 +3526,34 @@ function Io({
|
|
|
3518
3526
|
get edges() {
|
|
3519
3527
|
return n;
|
|
3520
3528
|
}
|
|
3521
|
-
}), [le, e, n]), ye =
|
|
3522
|
-
|
|
3529
|
+
}), [le, e, n]), ye = tt(null), ge = tt(null), pe = tt(null), Jt = tt(null);
|
|
3530
|
+
ht(() => {
|
|
3523
3531
|
let Q;
|
|
3524
3532
|
const Ft = () => {
|
|
3525
|
-
const
|
|
3533
|
+
const lt = le.cameraRef.current, Tt = `translate(${lt.x}px, ${lt.y}px) scale(${lt.zoom})`, xe = `translate(${lt.x}, ${lt.y}) scale(${lt.zoom})`;
|
|
3526
3534
|
ye.current && (ye.current.style.transform = Tt), ge.current && ge.current.setAttribute("transform", xe), pe.current && (pe.current.style.transform = Tt), Jt.current && (Jt.current.style.transform = Tt), Q = requestAnimationFrame(Ft);
|
|
3527
3535
|
};
|
|
3528
3536
|
return Q = requestAnimationFrame(Ft), () => cancelAnimationFrame(Q);
|
|
3529
3537
|
}, [le]);
|
|
3530
3538
|
const ze = he.length > 0, ee = ke.length > 0;
|
|
3531
|
-
return /* @__PURE__ */
|
|
3539
|
+
return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */ $t(
|
|
3532
3540
|
"div",
|
|
3533
3541
|
{
|
|
3534
3542
|
ref: Dt,
|
|
3535
3543
|
className: `ric-wrap ${l}`,
|
|
3536
|
-
style: { width: c, height: u, ...
|
|
3537
|
-
onPointerDown:
|
|
3538
|
-
onPointerMove:
|
|
3544
|
+
style: { width: c, height: u, ...y },
|
|
3545
|
+
onPointerDown: Ae,
|
|
3546
|
+
onPointerMove: He,
|
|
3539
3547
|
onPointerUp: _e,
|
|
3540
|
-
onDragOver:
|
|
3548
|
+
onDragOver: wt,
|
|
3541
3549
|
onDrop: ne,
|
|
3542
3550
|
onDragEnter: Ie,
|
|
3543
3551
|
onDragLeave: Bt,
|
|
3544
3552
|
tabIndex: 0,
|
|
3545
3553
|
children: [
|
|
3546
|
-
/* @__PURE__ */
|
|
3547
|
-
!De && /* @__PURE__ */
|
|
3548
|
-
ee && /* @__PURE__ */
|
|
3554
|
+
/* @__PURE__ */ S("canvas", { ref: ce, className: "ric-canvas" }),
|
|
3555
|
+
!De && /* @__PURE__ */ S("div", { className: "ric-loader", children: /* @__PURE__ */ S("div", { className: "ric-spinner" }) }),
|
|
3556
|
+
ee && /* @__PURE__ */ S(
|
|
3549
3557
|
"svg",
|
|
3550
3558
|
{
|
|
3551
3559
|
className: "ric-edges-overlay",
|
|
@@ -3558,7 +3566,7 @@ function Io({
|
|
|
3558
3566
|
pointerEvents: "none",
|
|
3559
3567
|
overflow: "visible"
|
|
3560
3568
|
},
|
|
3561
|
-
children: /* @__PURE__ */
|
|
3569
|
+
children: /* @__PURE__ */ S("g", { ref: ge, children: ke.map((Q) => /* @__PURE__ */ S(
|
|
3562
3570
|
Dr,
|
|
3563
3571
|
{
|
|
3564
3572
|
edge: Q,
|
|
@@ -3570,7 +3578,7 @@ function Io({
|
|
|
3570
3578
|
)) })
|
|
3571
3579
|
}
|
|
3572
3580
|
),
|
|
3573
|
-
ze && /* @__PURE__ */
|
|
3581
|
+
ze && /* @__PURE__ */ S(
|
|
3574
3582
|
"div",
|
|
3575
3583
|
{
|
|
3576
3584
|
ref: ye,
|
|
@@ -3585,7 +3593,7 @@ function Io({
|
|
|
3585
3593
|
pointerEvents: "none",
|
|
3586
3594
|
zIndex: 10
|
|
3587
3595
|
},
|
|
3588
|
-
children: he.map((Q) => /* @__PURE__ */
|
|
3596
|
+
children: he.map((Q) => /* @__PURE__ */ S(
|
|
3589
3597
|
Pr,
|
|
3590
3598
|
{
|
|
3591
3599
|
node: Q,
|
|
@@ -3595,7 +3603,7 @@ function Io({
|
|
|
3595
3603
|
))
|
|
3596
3604
|
}
|
|
3597
3605
|
),
|
|
3598
|
-
/* @__PURE__ */
|
|
3606
|
+
/* @__PURE__ */ S(
|
|
3599
3607
|
"div",
|
|
3600
3608
|
{
|
|
3601
3609
|
ref: (Q) => {
|
|
@@ -3614,7 +3622,7 @@ function Io({
|
|
|
3614
3622
|
}
|
|
3615
3623
|
}
|
|
3616
3624
|
),
|
|
3617
|
-
/* @__PURE__ */
|
|
3625
|
+
/* @__PURE__ */ S(
|
|
3618
3626
|
"div",
|
|
3619
3627
|
{
|
|
3620
3628
|
ref: (Q) => {
|
|
@@ -3633,8 +3641,8 @@ function Io({
|
|
|
3633
3641
|
}
|
|
3634
3642
|
}
|
|
3635
3643
|
),
|
|
3636
|
-
_t && /* @__PURE__ */
|
|
3637
|
-
pn && /* @__PURE__ */
|
|
3644
|
+
_t && /* @__PURE__ */ S("div", { className: "ric-hint", children: Wt }),
|
|
3645
|
+
pn && /* @__PURE__ */ $t("div", { className: "ric-info", children: [
|
|
3638
3646
|
"world: (",
|
|
3639
3647
|
Ut.wx,
|
|
3640
3648
|
", ",
|
|
@@ -3642,17 +3650,17 @@ function Io({
|
|
|
3642
3650
|
") zoom: ",
|
|
3643
3651
|
Ut.zoom,
|
|
3644
3652
|
"x",
|
|
3645
|
-
Ut.nodeCount > 0 && /* @__PURE__ */
|
|
3653
|
+
Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3646
3654
|
" nodes: ",
|
|
3647
3655
|
Ut.nodeCount
|
|
3648
3656
|
] }),
|
|
3649
|
-
Ut.edgeCount > 0 && /* @__PURE__ */
|
|
3657
|
+
Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3650
3658
|
" edges: ",
|
|
3651
3659
|
Ut.edgeCount
|
|
3652
3660
|
] })
|
|
3653
3661
|
] }),
|
|
3654
|
-
/* @__PURE__ */
|
|
3655
|
-
|
|
3662
|
+
/* @__PURE__ */ S(
|
|
3663
|
+
Ar,
|
|
3656
3664
|
{
|
|
3657
3665
|
selectionKeyCode: de || "Shift",
|
|
3658
3666
|
selectionMode: we || "partial"
|
|
@@ -3739,96 +3747,96 @@ function So(t) {
|
|
|
3739
3747
|
return [e, n, r];
|
|
3740
3748
|
}
|
|
3741
3749
|
function eo() {
|
|
3742
|
-
const t =
|
|
3743
|
-
var f, p,
|
|
3744
|
-
if (typeof
|
|
3745
|
-
const
|
|
3750
|
+
const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((g) => t.nodesRef.current.find((f) => f.id === g), [t]), s = F((g) => t.edgesRef.current.find((f) => f.id === g), [t]), o = F((g) => {
|
|
3751
|
+
var f, p, v, N;
|
|
3752
|
+
if (typeof g == "function") {
|
|
3753
|
+
const w = g(t.nodesRef.current);
|
|
3746
3754
|
(p = (f = t.onNodesChangeRef).current) == null || p.call(f, [
|
|
3747
3755
|
...t.nodesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3748
|
-
...
|
|
3756
|
+
...w.map((P) => ({ type: "add", item: P }))
|
|
3749
3757
|
]);
|
|
3750
3758
|
} else
|
|
3751
|
-
(N = (
|
|
3752
|
-
...t.nodesRef.current.map((
|
|
3753
|
-
...
|
|
3759
|
+
(N = (v = t.onNodesChangeRef).current) == null || N.call(v, [
|
|
3760
|
+
...t.nodesRef.current.map((w) => ({ id: w.id, type: "remove" })),
|
|
3761
|
+
...g.map((w) => ({ type: "add", item: w }))
|
|
3754
3762
|
]);
|
|
3755
|
-
}, [t]), i = F((
|
|
3756
|
-
var f, p,
|
|
3757
|
-
if (typeof
|
|
3758
|
-
const
|
|
3763
|
+
}, [t]), i = F((g) => {
|
|
3764
|
+
var f, p, v, N;
|
|
3765
|
+
if (typeof g == "function") {
|
|
3766
|
+
const w = g(t.edgesRef.current);
|
|
3759
3767
|
(p = (f = t.onEdgesChangeRef).current) == null || p.call(f, [
|
|
3760
3768
|
...t.edgesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3761
|
-
...
|
|
3769
|
+
...w.map((P) => ({ type: "add", item: P }))
|
|
3762
3770
|
]);
|
|
3763
3771
|
} else
|
|
3764
|
-
(N = (
|
|
3765
|
-
...t.edgesRef.current.map((
|
|
3766
|
-
...
|
|
3772
|
+
(N = (v = t.onEdgesChangeRef).current) == null || N.call(v, [
|
|
3773
|
+
...t.edgesRef.current.map((w) => ({ id: w.id, type: "remove" })),
|
|
3774
|
+
...g.map((w) => ({ type: "add", item: w }))
|
|
3767
3775
|
]);
|
|
3768
|
-
}, [t]), c = F((
|
|
3769
|
-
var p,
|
|
3770
|
-
const f = Array.isArray(
|
|
3771
|
-
(
|
|
3772
|
-
}, [t]), u = F((
|
|
3773
|
-
var p,
|
|
3774
|
-
const f = Array.isArray(
|
|
3775
|
-
(
|
|
3776
|
-
}, [t]), l = F(({ nodes:
|
|
3777
|
-
if (
|
|
3778
|
-
t.onNodesChangeRef.current(
|
|
3779
|
-
const p = zr(
|
|
3780
|
-
p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((
|
|
3776
|
+
}, [t]), c = F((g) => {
|
|
3777
|
+
var p, v;
|
|
3778
|
+
const f = Array.isArray(g) ? g : [g];
|
|
3779
|
+
(v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3780
|
+
}, [t]), u = F((g) => {
|
|
3781
|
+
var p, v;
|
|
3782
|
+
const f = Array.isArray(g) ? g : [g];
|
|
3783
|
+
(v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3784
|
+
}, [t]), l = F(({ nodes: g = [], edges: f = [] }) => {
|
|
3785
|
+
if (g.length && t.onNodesChangeRef.current) {
|
|
3786
|
+
t.onNodesChangeRef.current(g.map((v) => ({ id: v.id, type: "remove" })));
|
|
3787
|
+
const p = zr(g, t.edgesRef.current);
|
|
3788
|
+
p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((v) => ({ id: v.id, type: "remove" })));
|
|
3781
3789
|
}
|
|
3782
3790
|
f.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(f.map((p) => ({ id: p.id, type: "remove" })));
|
|
3783
|
-
}, [t]),
|
|
3784
|
-
const
|
|
3785
|
-
return { x:
|
|
3786
|
-
}, [t]),
|
|
3791
|
+
}, [t]), y = F(() => {
|
|
3792
|
+
const g = t.cameraRef.current;
|
|
3793
|
+
return { x: g.x, y: g.y, zoom: g.zoom };
|
|
3794
|
+
}, [t]), m = F((g, f) => {
|
|
3787
3795
|
t.cameraRef.current = {
|
|
3788
|
-
x:
|
|
3789
|
-
y:
|
|
3790
|
-
zoom:
|
|
3796
|
+
x: g.x ?? t.cameraRef.current.x,
|
|
3797
|
+
y: g.y ?? t.cameraRef.current.y,
|
|
3798
|
+
zoom: g.zoom ?? t.cameraRef.current.zoom
|
|
3791
3799
|
}, t.sendCamera();
|
|
3792
|
-
}, [t]),
|
|
3800
|
+
}, [t]), C = F(() => t.cameraRef.current.zoom, [t]), z = F((g) => {
|
|
3793
3801
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3794
3802
|
if (!p) return;
|
|
3795
|
-
const
|
|
3796
|
-
f.x = N - (N - f.x) * P, f.y =
|
|
3797
|
-
}, [t]), M = F((
|
|
3803
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1.2;
|
|
3804
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
|
|
3805
|
+
}, [t]), M = F((g) => {
|
|
3798
3806
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3799
3807
|
if (!p) return;
|
|
3800
|
-
const
|
|
3801
|
-
f.x = N - (N - f.x) * P, f.y =
|
|
3802
|
-
}, [t]),
|
|
3808
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1 / 1.2;
|
|
3809
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
|
|
3810
|
+
}, [t]), $ = F((g) => {
|
|
3803
3811
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3804
3812
|
if (!p) return;
|
|
3805
|
-
const
|
|
3806
|
-
f.x = N - (N - f.x) * P, f.y =
|
|
3807
|
-
}, [t]), k = F((
|
|
3813
|
+
const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = g / f.zoom;
|
|
3814
|
+
f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, g)), t.sendCamera();
|
|
3815
|
+
}, [t]), k = F((g = {}) => {
|
|
3808
3816
|
const f = t.nodesRef.current;
|
|
3809
3817
|
if (!f.length) return;
|
|
3810
3818
|
const p = t.wrapRef.current;
|
|
3811
3819
|
if (!p) return;
|
|
3812
|
-
const
|
|
3813
|
-
if (!
|
|
3814
|
-
const P = Mn(
|
|
3815
|
-
|
|
3816
|
-
}, [t]),
|
|
3817
|
-
const
|
|
3818
|
-
if (!
|
|
3819
|
-
const N =
|
|
3820
|
+
const v = p.getBoundingClientRect(), N = g.padding ?? 0.1, w = g.nodes ? f.filter((B) => g.nodes.some((q) => q.id === B.id)) : f;
|
|
3821
|
+
if (!w.length) return;
|
|
3822
|
+
const P = Mn(w), R = Rn(P, v.width, v.height, N);
|
|
3823
|
+
g.maxZoom && (R.zoom = Math.min(R.zoom, g.maxZoom)), g.minZoom && (R.zoom = Math.max(R.zoom, g.minZoom)), t.cameraRef.current = R, t.sendCamera();
|
|
3824
|
+
}, [t]), E = F((g, f, p = {}) => {
|
|
3825
|
+
const v = t.wrapRef.current;
|
|
3826
|
+
if (!v) return;
|
|
3827
|
+
const N = v.getBoundingClientRect(), w = p.zoom ?? t.cameraRef.current.zoom;
|
|
3820
3828
|
t.cameraRef.current = {
|
|
3821
|
-
x: N.width / 2 -
|
|
3822
|
-
y: N.height / 2 - f *
|
|
3823
|
-
zoom:
|
|
3829
|
+
x: N.width / 2 - g * w,
|
|
3830
|
+
y: N.height / 2 - f * w,
|
|
3831
|
+
zoom: w
|
|
3824
3832
|
}, t.sendCamera();
|
|
3825
|
-
}, [t]),
|
|
3833
|
+
}, [t]), _ = F((g) => t.screenToWorld(g.x, g.y), [t]), D = F((g) => {
|
|
3826
3834
|
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3827
3835
|
if (!p) return { x: 0, y: 0 };
|
|
3828
|
-
const
|
|
3836
|
+
const v = p.getBoundingClientRect();
|
|
3829
3837
|
return {
|
|
3830
|
-
x:
|
|
3831
|
-
y:
|
|
3838
|
+
x: g.x * f.zoom + f.x + v.left,
|
|
3839
|
+
y: g.y * f.zoom + f.y + v.top
|
|
3832
3840
|
};
|
|
3833
3841
|
}, [t]);
|
|
3834
3842
|
return {
|
|
@@ -3841,54 +3849,54 @@ function eo() {
|
|
|
3841
3849
|
addNodes: c,
|
|
3842
3850
|
addEdges: u,
|
|
3843
3851
|
deleteElements: l,
|
|
3844
|
-
getViewport:
|
|
3845
|
-
setViewport:
|
|
3846
|
-
getZoom:
|
|
3847
|
-
zoomIn:
|
|
3852
|
+
getViewport: y,
|
|
3853
|
+
setViewport: m,
|
|
3854
|
+
getZoom: C,
|
|
3855
|
+
zoomIn: z,
|
|
3848
3856
|
zoomOut: M,
|
|
3849
|
-
zoomTo:
|
|
3857
|
+
zoomTo: $,
|
|
3850
3858
|
fitView: k,
|
|
3851
|
-
setCenter:
|
|
3852
|
-
screenToFlowPosition:
|
|
3859
|
+
setCenter: E,
|
|
3860
|
+
screenToFlowPosition: _,
|
|
3853
3861
|
flowToScreenPosition: D
|
|
3854
3862
|
};
|
|
3855
3863
|
}
|
|
3856
3864
|
function Bo() {
|
|
3857
|
-
return
|
|
3865
|
+
return yt().nodes;
|
|
3858
3866
|
}
|
|
3859
3867
|
function Do() {
|
|
3860
|
-
return
|
|
3861
|
-
}
|
|
3862
|
-
function Ho() {
|
|
3863
|
-
return ht().viewport;
|
|
3868
|
+
return yt().edges;
|
|
3864
3869
|
}
|
|
3865
3870
|
function Ao() {
|
|
3866
|
-
return
|
|
3871
|
+
return yt().viewport;
|
|
3872
|
+
}
|
|
3873
|
+
function Ho() {
|
|
3874
|
+
return yt().connection;
|
|
3867
3875
|
}
|
|
3868
3876
|
function _o(t) {
|
|
3869
|
-
const e =
|
|
3877
|
+
const e = yt(), n = Array.isArray(t) ? t : [t];
|
|
3870
3878
|
return St(() => n.map((r) => {
|
|
3871
3879
|
const s = e.nodes.find((o) => o.id === r);
|
|
3872
3880
|
return s ? { id: s.id, type: s.type, data: s.data } : null;
|
|
3873
3881
|
}).filter(Boolean), [e.nodes, ...n]);
|
|
3874
3882
|
}
|
|
3875
3883
|
function Wo(t) {
|
|
3876
|
-
const e =
|
|
3884
|
+
const e = yt();
|
|
3877
3885
|
return St(() => e.edges.filter((n) => n.source === t || n.target === t), [e.edges, t]);
|
|
3878
3886
|
}
|
|
3879
3887
|
function Xo({ nodeId: t, type: e, handleId: n }) {
|
|
3880
|
-
const r =
|
|
3888
|
+
const r = yt();
|
|
3881
3889
|
return St(() => r.edges.filter((s) => e === "source" ? s.source === t && (n ? s.sourceHandle === n : !0) : s.target === t && (n ? s.targetHandle === n : !0)), [r.edges, t, e, n]);
|
|
3882
3890
|
}
|
|
3883
3891
|
function Fo({ onChange: t, onStart: e, onEnd: n }) {
|
|
3884
|
-
const r =
|
|
3885
|
-
|
|
3892
|
+
const r = yt(), s = tt(t), o = tt(e), i = tt(n);
|
|
3893
|
+
ht(() => {
|
|
3886
3894
|
s.current = t;
|
|
3887
|
-
}, [t]),
|
|
3895
|
+
}, [t]), ht(() => {
|
|
3888
3896
|
o.current = e;
|
|
3889
|
-
}, [e]),
|
|
3897
|
+
}, [e]), ht(() => {
|
|
3890
3898
|
i.current = n;
|
|
3891
|
-
}, [n]),
|
|
3899
|
+
}, [n]), ht(() => {
|
|
3892
3900
|
const c = (u) => {
|
|
3893
3901
|
var l;
|
|
3894
3902
|
(l = s.current) == null || l.call(s, { x: u.x, y: u.y, zoom: u.zoom });
|
|
@@ -3897,10 +3905,10 @@ function Fo({ onChange: t, onStart: e, onEnd: n }) {
|
|
|
3897
3905
|
}, [r]);
|
|
3898
3906
|
}
|
|
3899
3907
|
function Yo({ onChange: t }) {
|
|
3900
|
-
const e =
|
|
3901
|
-
|
|
3908
|
+
const e = yt(), n = tt(t);
|
|
3909
|
+
ht(() => {
|
|
3902
3910
|
n.current = t;
|
|
3903
|
-
}, [t]),
|
|
3911
|
+
}, [t]), ht(() => {
|
|
3904
3912
|
const r = (s) => {
|
|
3905
3913
|
var o;
|
|
3906
3914
|
(o = n.current) == null || o.call(n, s);
|
|
@@ -3910,7 +3918,7 @@ function Yo({ onChange: t }) {
|
|
|
3910
3918
|
}
|
|
3911
3919
|
function Uo(t) {
|
|
3912
3920
|
const [e, n] = Gt(!1), r = Array.isArray(t) ? t : [t];
|
|
3913
|
-
return
|
|
3921
|
+
return ht(() => {
|
|
3914
3922
|
const s = (i) => {
|
|
3915
3923
|
r.includes(i.key) && n(!0);
|
|
3916
3924
|
}, o = (i) => {
|
|
@@ -3922,7 +3930,7 @@ function Uo(t) {
|
|
|
3922
3930
|
}, [r.join(",")]), e;
|
|
3923
3931
|
}
|
|
3924
3932
|
function qo() {
|
|
3925
|
-
const t =
|
|
3933
|
+
const t = yt();
|
|
3926
3934
|
return F((e) => {
|
|
3927
3935
|
var n;
|
|
3928
3936
|
(n = t.workerRef.current) == null || n.postMessage({
|
|
@@ -3932,18 +3940,18 @@ function qo() {
|
|
|
3932
3940
|
}, [t]);
|
|
3933
3941
|
}
|
|
3934
3942
|
function jo(t = {}) {
|
|
3935
|
-
return
|
|
3943
|
+
return yt().nodes.length > 0;
|
|
3936
3944
|
}
|
|
3937
3945
|
function Go(t) {
|
|
3938
|
-
const e =
|
|
3946
|
+
const e = yt();
|
|
3939
3947
|
return St(() => e.nodes.find((n) => n.id === t) || void 0, [e.nodes, t]);
|
|
3940
3948
|
}
|
|
3941
3949
|
function Zo(t) {
|
|
3942
|
-
const e =
|
|
3950
|
+
const e = yt();
|
|
3943
3951
|
return typeof t == "function" ? t(e) : e;
|
|
3944
3952
|
}
|
|
3945
3953
|
function Oo() {
|
|
3946
|
-
const t =
|
|
3954
|
+
const t = yt();
|
|
3947
3955
|
return St(() => ({
|
|
3948
3956
|
getState: () => t,
|
|
3949
3957
|
setState: () => {
|
|
@@ -3961,52 +3969,52 @@ function Qo({
|
|
|
3961
3969
|
style: o = {},
|
|
3962
3970
|
className: i = ""
|
|
3963
3971
|
}) {
|
|
3964
|
-
const c =
|
|
3965
|
-
const
|
|
3966
|
-
if (!
|
|
3967
|
-
const
|
|
3968
|
-
|
|
3972
|
+
const c = yt(), u = tt(null), l = tt(null), y = F(() => {
|
|
3973
|
+
const m = u.current;
|
|
3974
|
+
if (!m) return;
|
|
3975
|
+
const C = m.getContext("2d"), z = window.devicePixelRatio || 1;
|
|
3976
|
+
m.width = t * z, m.height = e * z, C.scale(z, z), C.clearRect(0, 0, t, e);
|
|
3969
3977
|
const M = c.nodesRef.current;
|
|
3970
3978
|
if (!M.length) return;
|
|
3971
|
-
let
|
|
3972
|
-
for (const
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3979
|
+
let $ = 1 / 0, k = 1 / 0, E = -1 / 0, _ = -1 / 0;
|
|
3980
|
+
for (const R of M) {
|
|
3981
|
+
const B = R.width || wn, q = R.height || bn;
|
|
3982
|
+
R.position.x < $ && ($ = R.position.x), R.position.y < k && (k = R.position.y), R.position.x + B > E && (E = R.position.x + B), R.position.y + q > _ && (_ = R.position.y + q);
|
|
3975
3983
|
}
|
|
3976
3984
|
const D = 40;
|
|
3977
|
-
|
|
3978
|
-
const
|
|
3979
|
-
for (const
|
|
3980
|
-
if (
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3985
|
+
$ -= D, k -= D, E += D, _ += D;
|
|
3986
|
+
const g = E - $, f = _ - k, p = Math.min(t / g, e / f), v = (t - g * p) / 2, N = (e - f * p) / 2;
|
|
3987
|
+
for (const R of M) {
|
|
3988
|
+
if (R.hidden) continue;
|
|
3989
|
+
const B = R.width || wn, q = R.height || bn, X = (R.position.x - $) * p + v, K = (R.position.y - k) * p + N, at = B * p, rt = q * p;
|
|
3990
|
+
C.fillStyle = R.selected ? "#f59e0b" : typeof n == "function" ? n(R) : n, C.fillRect(X, K, Math.max(at, 2), Math.max(rt, 2));
|
|
3983
3991
|
}
|
|
3984
|
-
const
|
|
3992
|
+
const w = c.cameraRef.current, P = c.wrapRef.current;
|
|
3985
3993
|
if (P) {
|
|
3986
|
-
const
|
|
3987
|
-
|
|
3988
|
-
const
|
|
3989
|
-
|
|
3990
|
-
for (const
|
|
3991
|
-
if (
|
|
3992
|
-
const
|
|
3993
|
-
|
|
3994
|
+
const R = P.getBoundingClientRect(), B = -w.x / w.zoom, q = -w.y / w.zoom, X = R.width / w.zoom, K = R.height / w.zoom;
|
|
3995
|
+
C.fillStyle = s, C.fillRect(0, 0, t, e);
|
|
3996
|
+
const at = (B - $) * p + v, rt = (q - k) * p + N, G = X * p, j = K * p;
|
|
3997
|
+
C.clearRect(at, rt, G, j);
|
|
3998
|
+
for (const it of M) {
|
|
3999
|
+
if (it.hidden) continue;
|
|
4000
|
+
const dt = it.width || wn, ot = it.height || bn, ft = (it.position.x - $) * p + v, It = (it.position.y - k) * p + N;
|
|
4001
|
+
C.fillStyle = it.selected ? "#f59e0b" : typeof n == "function" ? n(it) : n, C.fillRect(ft, It, Math.max(dt * p, 2), Math.max(ot * p, 2));
|
|
3994
4002
|
}
|
|
3995
|
-
|
|
4003
|
+
C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(at, rt, G, j);
|
|
3996
4004
|
}
|
|
3997
4005
|
}, [c, t, e, n, r, s]);
|
|
3998
|
-
return
|
|
3999
|
-
let
|
|
4000
|
-
function
|
|
4001
|
-
|
|
4006
|
+
return ht(() => {
|
|
4007
|
+
let m = !0;
|
|
4008
|
+
function C() {
|
|
4009
|
+
m && (y(), l.current = requestAnimationFrame(C));
|
|
4002
4010
|
}
|
|
4003
|
-
const
|
|
4004
|
-
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(
|
|
4011
|
+
const z = setInterval(() => {
|
|
4012
|
+
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(C);
|
|
4005
4013
|
}, 66);
|
|
4006
|
-
return
|
|
4007
|
-
|
|
4014
|
+
return y(), () => {
|
|
4015
|
+
m = !1, clearInterval(z), cancelAnimationFrame(l.current);
|
|
4008
4016
|
};
|
|
4009
|
-
}, [
|
|
4017
|
+
}, [y]), /* @__PURE__ */ S(
|
|
4010
4018
|
"canvas",
|
|
4011
4019
|
{
|
|
4012
4020
|
ref: u,
|
|
@@ -4027,31 +4035,31 @@ function Qo({
|
|
|
4027
4035
|
);
|
|
4028
4036
|
}
|
|
4029
4037
|
function no() {
|
|
4030
|
-
return /* @__PURE__ */
|
|
4031
|
-
/* @__PURE__ */
|
|
4032
|
-
/* @__PURE__ */
|
|
4038
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4039
|
+
/* @__PURE__ */ S("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
4040
|
+
/* @__PURE__ */ S("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
4033
4041
|
] });
|
|
4034
4042
|
}
|
|
4035
4043
|
function ro() {
|
|
4036
|
-
return /* @__PURE__ */
|
|
4044
|
+
return /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ S("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
|
|
4037
4045
|
}
|
|
4038
4046
|
function oo() {
|
|
4039
|
-
return /* @__PURE__ */
|
|
4047
|
+
return /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ S("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
|
|
4040
4048
|
}
|
|
4041
4049
|
function so() {
|
|
4042
|
-
return /* @__PURE__ */
|
|
4043
|
-
/* @__PURE__ */
|
|
4044
|
-
/* @__PURE__ */
|
|
4050
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4051
|
+
/* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4052
|
+
/* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
4045
4053
|
] });
|
|
4046
4054
|
}
|
|
4047
4055
|
function io() {
|
|
4048
|
-
return /* @__PURE__ */
|
|
4049
|
-
/* @__PURE__ */
|
|
4050
|
-
/* @__PURE__ */
|
|
4056
|
+
return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4057
|
+
/* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4058
|
+
/* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
|
|
4051
4059
|
] });
|
|
4052
4060
|
}
|
|
4053
4061
|
function rn({ children: t, className: e = "", ...n }) {
|
|
4054
|
-
return /* @__PURE__ */
|
|
4062
|
+
return /* @__PURE__ */ S(
|
|
4055
4063
|
"button",
|
|
4056
4064
|
{
|
|
4057
4065
|
className: `ric-controls-button ${e}`,
|
|
@@ -4072,21 +4080,21 @@ function ao({
|
|
|
4072
4080
|
onInteractiveChange: c,
|
|
4073
4081
|
position: u = "bottom-left",
|
|
4074
4082
|
orientation: l = "vertical",
|
|
4075
|
-
style:
|
|
4076
|
-
className:
|
|
4077
|
-
"aria-label":
|
|
4078
|
-
children:
|
|
4083
|
+
style: y = {},
|
|
4084
|
+
className: m = "",
|
|
4085
|
+
"aria-label": C = "Canvas controls",
|
|
4086
|
+
children: z
|
|
4079
4087
|
}) {
|
|
4080
|
-
const M =
|
|
4081
|
-
|
|
4082
|
-
}, [
|
|
4088
|
+
const M = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [D, g] = Gt(!0), f = _() <= M.zoomMin, p = _() >= M.zoomMax, v = F(() => {
|
|
4089
|
+
$(), s == null || s();
|
|
4090
|
+
}, [$, s]), N = F(() => {
|
|
4083
4091
|
k(), o == null || o();
|
|
4084
|
-
}, [k, o]),
|
|
4085
|
-
|
|
4086
|
-
}, [
|
|
4087
|
-
const
|
|
4088
|
-
|
|
4089
|
-
}, [D, c]),
|
|
4092
|
+
}, [k, o]), w = F(() => {
|
|
4093
|
+
E(r || { padding: 0.1 }), i == null || i();
|
|
4094
|
+
}, [E, r, i]), P = F(() => {
|
|
4095
|
+
const B = !D;
|
|
4096
|
+
g(B), c == null || c(B);
|
|
4097
|
+
}, [D, c]), R = {
|
|
4090
4098
|
"top-left": { top: 10, left: 10 },
|
|
4091
4099
|
"top-right": { top: 10, right: 10 },
|
|
4092
4100
|
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -4094,35 +4102,35 @@ function ao({
|
|
|
4094
4102
|
"bottom-right": { bottom: 30, right: 10 },
|
|
4095
4103
|
"bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
|
|
4096
4104
|
}[u] || { bottom: 30, left: 10 };
|
|
4097
|
-
return /* @__PURE__ */
|
|
4105
|
+
return /* @__PURE__ */ $t(
|
|
4098
4106
|
"div",
|
|
4099
4107
|
{
|
|
4100
|
-
className: `ric-controls ${
|
|
4108
|
+
className: `ric-controls ${m}`,
|
|
4101
4109
|
style: {
|
|
4102
4110
|
position: "absolute",
|
|
4103
4111
|
display: "flex",
|
|
4104
4112
|
flexDirection: l === "horizontal" ? "row" : "column",
|
|
4105
4113
|
gap: 2,
|
|
4106
4114
|
zIndex: 5,
|
|
4107
|
-
...
|
|
4108
|
-
...
|
|
4115
|
+
...R,
|
|
4116
|
+
...y
|
|
4109
4117
|
},
|
|
4110
4118
|
role: "toolbar",
|
|
4111
|
-
"aria-label":
|
|
4119
|
+
"aria-label": C,
|
|
4112
4120
|
children: [
|
|
4113
|
-
t && /* @__PURE__ */
|
|
4114
|
-
/* @__PURE__ */
|
|
4121
|
+
t && /* @__PURE__ */ $t(Le, { children: [
|
|
4122
|
+
/* @__PURE__ */ S(
|
|
4115
4123
|
rn,
|
|
4116
4124
|
{
|
|
4117
|
-
onClick:
|
|
4125
|
+
onClick: v,
|
|
4118
4126
|
disabled: p,
|
|
4119
4127
|
title: "Zoom in",
|
|
4120
4128
|
"aria-label": "Zoom in",
|
|
4121
4129
|
className: "ric-controls-zoomin",
|
|
4122
|
-
children: /* @__PURE__ */
|
|
4130
|
+
children: /* @__PURE__ */ S(no, {})
|
|
4123
4131
|
}
|
|
4124
4132
|
),
|
|
4125
|
-
/* @__PURE__ */
|
|
4133
|
+
/* @__PURE__ */ S(
|
|
4126
4134
|
rn,
|
|
4127
4135
|
{
|
|
4128
4136
|
onClick: N,
|
|
@@ -4130,31 +4138,31 @@ function ao({
|
|
|
4130
4138
|
title: "Zoom out",
|
|
4131
4139
|
"aria-label": "Zoom out",
|
|
4132
4140
|
className: "ric-controls-zoomout",
|
|
4133
|
-
children: /* @__PURE__ */
|
|
4141
|
+
children: /* @__PURE__ */ S(ro, {})
|
|
4134
4142
|
}
|
|
4135
4143
|
)
|
|
4136
4144
|
] }),
|
|
4137
|
-
e && /* @__PURE__ */
|
|
4145
|
+
e && /* @__PURE__ */ S(
|
|
4138
4146
|
rn,
|
|
4139
4147
|
{
|
|
4140
|
-
onClick:
|
|
4148
|
+
onClick: w,
|
|
4141
4149
|
title: "Fit view",
|
|
4142
4150
|
"aria-label": "Fit view",
|
|
4143
4151
|
className: "ric-controls-fitview",
|
|
4144
|
-
children: /* @__PURE__ */
|
|
4152
|
+
children: /* @__PURE__ */ S(oo, {})
|
|
4145
4153
|
}
|
|
4146
4154
|
),
|
|
4147
|
-
n && /* @__PURE__ */
|
|
4155
|
+
n && /* @__PURE__ */ S(
|
|
4148
4156
|
rn,
|
|
4149
4157
|
{
|
|
4150
4158
|
onClick: P,
|
|
4151
4159
|
title: D ? "Lock interactivity" : "Unlock interactivity",
|
|
4152
4160
|
"aria-label": D ? "Lock interactivity" : "Unlock interactivity",
|
|
4153
4161
|
className: "ric-controls-interactive",
|
|
4154
|
-
children: D ? /* @__PURE__ */
|
|
4162
|
+
children: D ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
|
|
4155
4163
|
}
|
|
4156
4164
|
),
|
|
4157
|
-
|
|
4165
|
+
z
|
|
4158
4166
|
]
|
|
4159
4167
|
}
|
|
4160
4168
|
);
|
|
@@ -4182,7 +4190,7 @@ function Jo({
|
|
|
4182
4190
|
style: s = {},
|
|
4183
4191
|
className: o = ""
|
|
4184
4192
|
}) {
|
|
4185
|
-
const i =
|
|
4193
|
+
const i = yt();
|
|
4186
4194
|
return i.workerRef.current && i.workerRef.current.postMessage({
|
|
4187
4195
|
type: "background",
|
|
4188
4196
|
data: { variant: t, gap: e, size: n, color: r }
|
|
@@ -4202,7 +4210,7 @@ function Vo({
|
|
|
4202
4210
|
"bottom-right": { bottom: 10, right: 10 },
|
|
4203
4211
|
"bottom-center": { bottom: 10, left: "50%", transform: "translateX(-50%)" }
|
|
4204
4212
|
}[t] || { top: 10, left: 10 };
|
|
4205
|
-
return /* @__PURE__ */
|
|
4213
|
+
return /* @__PURE__ */ S(
|
|
4206
4214
|
"div",
|
|
4207
4215
|
{
|
|
4208
4216
|
className: `ric-panel ${n}`,
|
|
@@ -4229,98 +4237,98 @@ function ts({
|
|
|
4229
4237
|
color: c = "#3b82f6",
|
|
4230
4238
|
onResizeStart: u,
|
|
4231
4239
|
onResize: l,
|
|
4232
|
-
onResizeEnd:
|
|
4240
|
+
onResizeEnd: y
|
|
4233
4241
|
}) {
|
|
4234
|
-
const
|
|
4235
|
-
|
|
4236
|
-
const D =
|
|
4242
|
+
const m = qe(je), C = yt(), z = tt(null), M = F((E, _) => {
|
|
4243
|
+
E.stopPropagation(), E.preventDefault();
|
|
4244
|
+
const D = C.nodesRef.current.find((p) => p.id === m);
|
|
4237
4245
|
if (!D) return;
|
|
4238
|
-
|
|
4239
|
-
direction:
|
|
4240
|
-
startX:
|
|
4241
|
-
startY:
|
|
4246
|
+
z.current = {
|
|
4247
|
+
direction: _,
|
|
4248
|
+
startX: E.clientX,
|
|
4249
|
+
startY: E.clientY,
|
|
4242
4250
|
width: D.width || 160,
|
|
4243
4251
|
height: D.height || 60
|
|
4244
|
-
}, u == null || u(
|
|
4245
|
-
const
|
|
4246
|
-
var
|
|
4247
|
-
if (!
|
|
4248
|
-
const
|
|
4249
|
-
let
|
|
4250
|
-
|
|
4251
|
-
{ id:
|
|
4252
|
-
]), l == null || l(p, { width:
|
|
4252
|
+
}, u == null || u(E, { width: z.current.width, height: z.current.height });
|
|
4253
|
+
const g = (p) => {
|
|
4254
|
+
var q, X;
|
|
4255
|
+
if (!z.current) return;
|
|
4256
|
+
const v = z.current, N = C.cameraRef.current, w = (p.clientX - v.startX) / N.zoom, P = (p.clientY - v.startY) / N.zoom;
|
|
4257
|
+
let R = v.width, B = v.height;
|
|
4258
|
+
v.direction.includes("e") && (R = Math.min(n, Math.max(t, v.width + w))), v.direction.includes("w") && (R = Math.min(n, Math.max(t, v.width - w))), v.direction.includes("s") && (B = Math.min(r, Math.max(e, v.height + P))), v.direction.includes("n") && (B = Math.min(r, Math.max(e, v.height - P))), (X = (q = C.onNodesChangeRef).current) == null || X.call(q, [
|
|
4259
|
+
{ id: m, type: "dimensions", dimensions: { width: R, height: B }, setAttributes: !0 }
|
|
4260
|
+
]), l == null || l(p, { width: R, height: B });
|
|
4253
4261
|
}, f = (p) => {
|
|
4254
|
-
|
|
4262
|
+
z.current = null, y == null || y(p, {}), window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", f);
|
|
4255
4263
|
};
|
|
4256
|
-
window.addEventListener("pointermove",
|
|
4257
|
-
}, [
|
|
4264
|
+
window.addEventListener("pointermove", g), window.addEventListener("pointerup", f);
|
|
4265
|
+
}, [m, C, t, e, n, r, u, l, y]);
|
|
4258
4266
|
if (!s) return null;
|
|
4259
|
-
const
|
|
4267
|
+
const $ = 8, k = {
|
|
4260
4268
|
position: "absolute",
|
|
4261
|
-
width:
|
|
4262
|
-
height:
|
|
4269
|
+
width: $,
|
|
4270
|
+
height: $,
|
|
4263
4271
|
background: c,
|
|
4264
4272
|
border: "1px solid #fff",
|
|
4265
4273
|
borderRadius: 2,
|
|
4266
4274
|
zIndex: 20,
|
|
4267
4275
|
...o
|
|
4268
4276
|
};
|
|
4269
|
-
return /* @__PURE__ */
|
|
4270
|
-
/* @__PURE__ */
|
|
4277
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
4278
|
+
/* @__PURE__ */ S(
|
|
4271
4279
|
"div",
|
|
4272
4280
|
{
|
|
4273
|
-
style: { ...k, bottom:
|
|
4274
|
-
onPointerDown: (
|
|
4281
|
+
style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
|
|
4282
|
+
onPointerDown: (E) => M(E, "se")
|
|
4275
4283
|
}
|
|
4276
4284
|
),
|
|
4277
|
-
/* @__PURE__ */
|
|
4285
|
+
/* @__PURE__ */ S(
|
|
4278
4286
|
"div",
|
|
4279
4287
|
{
|
|
4280
|
-
style: { ...k, bottom:
|
|
4281
|
-
onPointerDown: (
|
|
4288
|
+
style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
|
|
4289
|
+
onPointerDown: (E) => M(E, "sw")
|
|
4282
4290
|
}
|
|
4283
4291
|
),
|
|
4284
|
-
/* @__PURE__ */
|
|
4292
|
+
/* @__PURE__ */ S(
|
|
4285
4293
|
"div",
|
|
4286
4294
|
{
|
|
4287
|
-
style: { ...k, top:
|
|
4288
|
-
onPointerDown: (
|
|
4295
|
+
style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
|
|
4296
|
+
onPointerDown: (E) => M(E, "ne")
|
|
4289
4297
|
}
|
|
4290
4298
|
),
|
|
4291
|
-
/* @__PURE__ */
|
|
4299
|
+
/* @__PURE__ */ S(
|
|
4292
4300
|
"div",
|
|
4293
4301
|
{
|
|
4294
|
-
style: { ...k, top:
|
|
4295
|
-
onPointerDown: (
|
|
4302
|
+
style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
|
|
4303
|
+
onPointerDown: (E) => M(E, "nw")
|
|
4296
4304
|
}
|
|
4297
4305
|
),
|
|
4298
|
-
/* @__PURE__ */
|
|
4306
|
+
/* @__PURE__ */ S(
|
|
4299
4307
|
"div",
|
|
4300
4308
|
{
|
|
4301
|
-
style: { ...k, top: "50%", right:
|
|
4302
|
-
onPointerDown: (
|
|
4309
|
+
style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4310
|
+
onPointerDown: (E) => M(E, "e")
|
|
4303
4311
|
}
|
|
4304
4312
|
),
|
|
4305
|
-
/* @__PURE__ */
|
|
4313
|
+
/* @__PURE__ */ S(
|
|
4306
4314
|
"div",
|
|
4307
4315
|
{
|
|
4308
|
-
style: { ...k, top: "50%", left:
|
|
4309
|
-
onPointerDown: (
|
|
4316
|
+
style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4317
|
+
onPointerDown: (E) => M(E, "w")
|
|
4310
4318
|
}
|
|
4311
4319
|
),
|
|
4312
|
-
/* @__PURE__ */
|
|
4320
|
+
/* @__PURE__ */ S(
|
|
4313
4321
|
"div",
|
|
4314
4322
|
{
|
|
4315
|
-
style: { ...k, left: "50%", top:
|
|
4316
|
-
onPointerDown: (
|
|
4323
|
+
style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4324
|
+
onPointerDown: (E) => M(E, "n")
|
|
4317
4325
|
}
|
|
4318
4326
|
),
|
|
4319
|
-
/* @__PURE__ */
|
|
4327
|
+
/* @__PURE__ */ S(
|
|
4320
4328
|
"div",
|
|
4321
4329
|
{
|
|
4322
|
-
style: { ...k, left: "50%", bottom:
|
|
4323
|
-
onPointerDown: (
|
|
4330
|
+
style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4331
|
+
onPointerDown: (E) => M(E, "s")
|
|
4324
4332
|
}
|
|
4325
4333
|
)
|
|
4326
4334
|
] });
|
|
@@ -4334,15 +4342,15 @@ function es({
|
|
|
4334
4342
|
style: o = {},
|
|
4335
4343
|
className: i = ""
|
|
4336
4344
|
}) {
|
|
4337
|
-
const c = qe(je), l =
|
|
4345
|
+
const c = qe(je), l = yt().nodes.find((C) => C.id === c);
|
|
4338
4346
|
if (!(t !== void 0 ? t : l == null ? void 0 : l.selected)) return null;
|
|
4339
|
-
const
|
|
4347
|
+
const m = {
|
|
4340
4348
|
top: { bottom: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginBottom: n },
|
|
4341
4349
|
bottom: { top: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginTop: n },
|
|
4342
4350
|
left: { right: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginRight: n },
|
|
4343
4351
|
right: { left: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginLeft: n }
|
|
4344
4352
|
}[e] || {};
|
|
4345
|
-
return /* @__PURE__ */
|
|
4353
|
+
return /* @__PURE__ */ S(
|
|
4346
4354
|
"div",
|
|
4347
4355
|
{
|
|
4348
4356
|
className: `ric-node-toolbar ${i}`,
|
|
@@ -4350,10 +4358,10 @@ function es({
|
|
|
4350
4358
|
position: "absolute",
|
|
4351
4359
|
zIndex: 1e3,
|
|
4352
4360
|
pointerEvents: "all",
|
|
4353
|
-
...
|
|
4361
|
+
...m,
|
|
4354
4362
|
...o
|
|
4355
4363
|
},
|
|
4356
|
-
onPointerDown: (
|
|
4364
|
+
onPointerDown: (C) => C.stopPropagation(),
|
|
4357
4365
|
children: s
|
|
4358
4366
|
}
|
|
4359
4367
|
);
|
|
@@ -4370,7 +4378,7 @@ function ns({
|
|
|
4370
4378
|
}) {
|
|
4371
4379
|
if (!t) return null;
|
|
4372
4380
|
const u = r === "center" ? "-50%" : r === "right" ? "-100%" : "0", l = s === "center" ? "-50%" : s === "bottom" ? "-100%" : "0";
|
|
4373
|
-
return /* @__PURE__ */
|
|
4381
|
+
return /* @__PURE__ */ S(
|
|
4374
4382
|
"div",
|
|
4375
4383
|
{
|
|
4376
4384
|
className: `ric-edge-toolbar ${c}`,
|
|
@@ -4389,12 +4397,12 @@ function ns({
|
|
|
4389
4397
|
}
|
|
4390
4398
|
function rs({ children: t }) {
|
|
4391
4399
|
var r;
|
|
4392
|
-
const n = (r =
|
|
4400
|
+
const n = (r = yt().edgeLabelContainerRef) == null ? void 0 : r.current;
|
|
4393
4401
|
return n ? Yn(t, n) : null;
|
|
4394
4402
|
}
|
|
4395
4403
|
function os({ children: t }) {
|
|
4396
4404
|
var r;
|
|
4397
|
-
const n = (r =
|
|
4405
|
+
const n = (r = yt().viewportPortalRef) == null ? void 0 : r.current;
|
|
4398
4406
|
return n ? Yn(t, n) : null;
|
|
4399
4407
|
}
|
|
4400
4408
|
function ur({
|
|
@@ -4409,7 +4417,7 @@ function ur({
|
|
|
4409
4417
|
connectionLineComponent: u
|
|
4410
4418
|
}) {
|
|
4411
4419
|
if (u)
|
|
4412
|
-
return /* @__PURE__ */
|
|
4420
|
+
return /* @__PURE__ */ S(
|
|
4413
4421
|
u,
|
|
4414
4422
|
{
|
|
4415
4423
|
fromX: t,
|
|
@@ -4460,7 +4468,7 @@ function ur({
|
|
|
4460
4468
|
});
|
|
4461
4469
|
break;
|
|
4462
4470
|
}
|
|
4463
|
-
return /* @__PURE__ */
|
|
4471
|
+
return /* @__PURE__ */ S(
|
|
4464
4472
|
"path",
|
|
4465
4473
|
{
|
|
4466
4474
|
d: l,
|
|
@@ -4509,7 +4517,7 @@ export {
|
|
|
4509
4517
|
Wr as OutputNode,
|
|
4510
4518
|
Vo as Panel,
|
|
4511
4519
|
is as Position,
|
|
4512
|
-
|
|
4520
|
+
Ar as SelectionBox,
|
|
4513
4521
|
cr as SimpleBezierEdge,
|
|
4514
4522
|
ar as SmoothStepEdge,
|
|
4515
4523
|
Or as StepEdge,
|
|
@@ -4547,7 +4555,7 @@ export {
|
|
|
4547
4555
|
Lo as routeSinglePath,
|
|
4548
4556
|
En as routedPointsToPath,
|
|
4549
4557
|
Pn as snapPosition,
|
|
4550
|
-
|
|
4558
|
+
Ho as useConnection,
|
|
4551
4559
|
Do as useEdges,
|
|
4552
4560
|
So as useEdgesState,
|
|
4553
4561
|
Xo as useHandleConnections,
|
|
@@ -4566,5 +4574,5 @@ export {
|
|
|
4566
4574
|
Zo as useStore,
|
|
4567
4575
|
Oo as useStoreApi,
|
|
4568
4576
|
qo as useUpdateNodeInternals,
|
|
4569
|
-
|
|
4577
|
+
Ao as useViewport
|
|
4570
4578
|
};
|