@infinit-canvas/react 0.1.2 → 0.1.3

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