@html-graph/html-graph 7.3.0 → 7.5.0

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,7 +1,7 @@
1
- var ke = Object.defineProperty;
2
- var ze = (r, e, t) => e in r ? ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => ze(r, typeof e != "symbol" ? e + "" : e, t);
4
- const D = (r, e) => ({
1
+ var ze = Object.defineProperty;
2
+ var ke = (r, e, t) => e in r ? ze(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => ke(r, typeof e != "symbol" ? e + "" : e, t);
4
+ const C = (r, e) => ({
5
5
  x: r.scale * e.x + r.x,
6
6
  y: r.scale * e.y + r.y
7
7
  });
@@ -90,7 +90,7 @@ class me {
90
90
  const n = {
91
91
  x: t.left - s.left,
92
92
  y: t.top - s.top
93
- }, a = D(o, n);
93
+ }, a = C(o, n);
94
94
  return {
95
95
  x: a.x,
96
96
  y: a.y,
@@ -198,7 +198,7 @@ class je {
198
198
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
199
199
  }
200
200
  }
201
- class Ke {
201
+ class qe {
202
202
  constructor(e, t) {
203
203
  i(this, "deferredNodes", /* @__PURE__ */ new Set());
204
204
  i(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -507,10 +507,10 @@ class ve {
507
507
  this.onAfterEdgeShapeUpdated
508
508
  ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
509
509
  this.onAfterEdgePriorityUpdated
510
- ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
510
+ ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.viewportStore.destroy(), this.destroyed = !0);
511
511
  }
512
512
  }
513
- class Qe {
513
+ class Ke {
514
514
  constructor() {
515
515
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
516
516
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -550,7 +550,7 @@ class Qe {
550
550
  return this.multiToSingleMap.get(e) !== void 0;
551
551
  }
552
552
  }
553
- class xe {
553
+ class Ae {
554
554
  constructor() {
555
555
  i(this, "nodes", /* @__PURE__ */ new Map());
556
556
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -559,7 +559,7 @@ class xe {
559
559
  i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
560
560
  i(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
561
561
  i(this, "portCycleEdges", /* @__PURE__ */ new Map());
562
- i(this, "elementPorts", new Qe());
562
+ i(this, "elementPorts", new Ke());
563
563
  i(this, "afterNodeAddedEmitter");
564
564
  i(this, "onAfterNodeAdded");
565
565
  i(this, "afterNodeUpdatedEmitter");
@@ -766,13 +766,20 @@ const ce = (r) => ({
766
766
  x: 0,
767
767
  y: 0
768
768
  };
769
- class Ze {
770
- constructor() {
769
+ class Qe {
770
+ constructor(e) {
771
771
  i(this, "viewportMatrix", le);
772
772
  i(this, "contentMatrix", le);
773
+ i(this, "beforeUpdateEmitter");
774
+ i(this, "onBeforeUpdated");
773
775
  i(this, "afterUpdateEmitter");
774
776
  i(this, "onAfterUpdated");
775
- [this.afterUpdateEmitter, this.onAfterUpdated] = E();
777
+ i(this, "afterResizeEmitter");
778
+ i(this, "onAfterResize");
779
+ i(this, "observer", new ResizeObserver(() => {
780
+ this.afterResizeEmitter.emit();
781
+ }));
782
+ this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E(), [this.afterResizeEmitter, this.onAfterResize] = E(), this.observer.observe(this.host);
776
783
  }
777
784
  getViewportMatrix() {
778
785
  return this.viewportMatrix;
@@ -785,17 +792,24 @@ class Ze {
785
792
  scale: e.scale ?? this.viewportMatrix.scale,
786
793
  x: e.x ?? this.viewportMatrix.x,
787
794
  y: e.y ?? this.viewportMatrix.y
788
- }, this.contentMatrix = ce(this.viewportMatrix), this.afterUpdateEmitter.emit();
795
+ }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ce(this.viewportMatrix), this.afterUpdateEmitter.emit();
789
796
  }
790
797
  patchContentMatrix(e) {
791
798
  this.contentMatrix = {
792
799
  scale: e.scale ?? this.contentMatrix.scale,
793
800
  x: e.x ?? this.contentMatrix.x,
794
801
  y: e.y ?? this.contentMatrix.y
795
- }, this.viewportMatrix = ce(this.contentMatrix), this.afterUpdateEmitter.emit();
802
+ }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ce(this.contentMatrix), this.afterUpdateEmitter.emit();
803
+ }
804
+ getDimensions() {
805
+ const { width: e, height: t } = this.host.getBoundingClientRect();
806
+ return { width: e, height: t };
807
+ }
808
+ destroy() {
809
+ this.observer.disconnect();
796
810
  }
797
811
  }
798
- class K {
812
+ class q {
799
813
  constructor(e) {
800
814
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
801
815
  i(this, "nodesResizeObserver");
@@ -818,17 +832,17 @@ class K {
818
832
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
819
833
  }
820
834
  static configure(e) {
821
- new K(e);
835
+ new q(e);
822
836
  }
823
837
  handleNodeResize(e) {
824
838
  const t = this.elementToNodeId.get(e);
825
839
  this.canvas.updateNode(t);
826
840
  }
827
841
  }
828
- const Je = (r, e, t) => {
842
+ const Ze = (r, e, t) => {
829
843
  const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
830
844
  return e >= s && e <= s + n && t >= o && t <= o + a;
831
- }, qe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, F = (r, e, t, s) => Je(e, t, s) && qe(r, t, s), U = (r, e) => {
845
+ }, Je = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, V = (r, e, t, s) => Ze(e, t, s) && Je(r, t, s), U = (r, e) => {
832
846
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
833
847
  }, B = (r) => {
834
848
  const e = document.createElement("div");
@@ -864,19 +878,19 @@ const Je = (r, e, t) => {
864
878
  status: "notFound"
865
879
  };
866
880
  };
867
- function* Ae(r, e) {
881
+ function* Ee(r, e) {
868
882
  const t = r.elementsFromPoint(e.x, e.y);
869
883
  for (const s of t) {
870
884
  if (s.shadowRoot !== null) {
871
- const o = Ae(s.shadowRoot, e);
885
+ const o = Ee(s.shadowRoot, e);
872
886
  for (const n of o)
873
887
  yield n;
874
888
  }
875
889
  yield s;
876
890
  }
877
891
  }
878
- const Ee = (r, e) => {
879
- const t = Ae(document, e);
892
+ const xe = (r, e) => {
893
+ const t = Ee(document, e);
880
894
  for (const s of t) {
881
895
  const o = _e(r, s);
882
896
  if (o.status === "portFound")
@@ -977,10 +991,10 @@ class tt {
977
991
  }, y = {
978
992
  x: c.x + this.params.curvature * this.params.sourceDirection.x,
979
993
  y: c.y + this.params.curvature * this.params.sourceDirection.y
980
- }, x = {
994
+ }, A = {
981
995
  x: l.x - this.params.curvature * this.params.targetDirection.x,
982
996
  y: l.y - this.params.curvature * this.params.targetDirection.y
983
- }, A = {
997
+ }, x = {
984
998
  x: c.x + h,
985
999
  y: c.y + d
986
1000
  }, S = {
@@ -990,27 +1004,27 @@ class tt {
990
1004
  this.path = [
991
1005
  `M ${t.x} ${t.y}`,
992
1006
  `L ${c.x} ${c.y}`,
993
- `C ${y.x} ${y.y} ${A.x} ${A.y} ${w.x} ${w.y}`,
994
- `C ${S.x} ${S.y} ${x.x} ${x.y} ${l.x} ${l.y}`,
1007
+ `C ${y.x} ${y.y} ${x.x} ${x.y} ${w.x} ${w.y}`,
1008
+ `C ${S.x} ${S.y} ${A.x} ${A.y} ${l.x} ${l.y}`,
995
1009
  `L ${s.x} ${s.y}`
996
1010
  ].join(" "), this.midpoint = W(w, e.flipX, e.flipY, e.to);
997
1011
  }
998
1012
  }
999
- const Q = Object.freeze({
1013
+ const K = Object.freeze({
1000
1014
  edgeColor: "--edge-color"
1001
1015
  }), Pe = (r) => {
1002
1016
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1003
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(Q.edgeColor, r), e;
1017
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(K.edgeColor, r), e;
1004
1018
  }, Te = (r) => {
1005
1019
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1006
- return e.setAttribute("stroke", `var(${Q.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1020
+ return e.setAttribute("stroke", `var(${K.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1007
1021
  }, O = () => {
1008
1022
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
1009
- return r.setAttribute("fill", `var(${Q.edgeColor})`), r;
1010
- }, Ce = () => {
1023
+ return r.setAttribute("fill", `var(${K.edgeColor})`), r;
1024
+ }, De = () => {
1011
1025
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1012
1026
  return r.style.transformOrigin = "50% 50%", r;
1013
- }, De = (r, e) => {
1027
+ }, Ce = (r, e) => {
1014
1028
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${Math.max(e.width, 1)}px`, r.style.height = `${Math.max(e.height, 1)}px`;
1015
1029
  }, L = (r, e) => {
1016
1030
  const t = [];
@@ -1021,10 +1035,10 @@ const Q = Object.freeze({
1021
1035
  let c = 0, g = 0, l = 0;
1022
1036
  const u = d > 0, w = d < s, y = u && w;
1023
1037
  if (u && (c = -o, g = -n, l = a), w) {
1024
- const V = r[d + 1];
1025
- o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
1038
+ const F = r[d + 1];
1039
+ o = F.x - h.x, n = F.y - h.y, a = Math.sqrt(o * o + n * n);
1026
1040
  }
1027
- const A = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, S = y ? { x: h.x + o * A, y: h.y + n * A } : h, P = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + c * P, y: h.y + g * P } : h;
1041
+ const x = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, S = y ? { x: h.x + o * x, y: h.y + n * x } : h, P = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + c * P, y: h.y + g * P } : h;
1028
1042
  d > 0 && t.push(`L ${N.x} ${N.y}`), y && t.push(
1029
1043
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${S.x} ${S.y}`
1030
1044
  );
@@ -1171,7 +1185,7 @@ class it {
1171
1185
  );
1172
1186
  }
1173
1187
  }
1174
- class Z {
1188
+ class Q {
1175
1189
  constructor(e) {
1176
1190
  i(this, "path");
1177
1191
  i(this, "midpoint");
@@ -1353,10 +1367,10 @@ const f = Object.freeze({
1353
1367
  interactiveWidth: 10,
1354
1368
  preOffset: 0
1355
1369
  }), ge = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1356
- class k {
1370
+ class z {
1357
1371
  constructor(e) {
1358
1372
  i(this, "svg");
1359
- i(this, "group", Ce());
1373
+ i(this, "group", De());
1360
1374
  i(this, "line");
1361
1375
  i(this, "sourceArrow", null);
1362
1376
  i(this, "targetArrow", null);
@@ -1370,7 +1384,7 @@ class k {
1370
1384
  e.from,
1371
1385
  e.to
1372
1386
  );
1373
- De(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1387
+ Ce(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1374
1388
  const d = ge(
1375
1389
  e.from.direction,
1376
1390
  a,
@@ -1399,15 +1413,15 @@ class k {
1399
1413
  shift: p,
1400
1414
  arrowLength: this.params.arrowLength
1401
1415
  }), this.sourceArrow.setAttribute("d", y));
1402
- let x = null;
1403
- this.targetArrow && (x = this.arrowRenderer({
1416
+ let A = null;
1417
+ this.targetArrow && (A = this.arrowRenderer({
1404
1418
  direction: l,
1405
1419
  shift: g,
1406
1420
  arrowLength: this.params.arrowLength
1407
- }), this.targetArrow.setAttribute("d", x)), this.afterRenderEmitter.emit({
1421
+ }), this.targetArrow.setAttribute("d", A)), this.afterRenderEmitter.emit({
1408
1422
  edgePath: w,
1409
1423
  sourceArrowPath: y,
1410
- targetArrowPath: x
1424
+ targetArrowPath: A
1411
1425
  });
1412
1426
  }
1413
1427
  }
@@ -1519,7 +1533,7 @@ class ut {
1519
1533
  hasSourceArrow: this.hasSourceArrow,
1520
1534
  hasTargetArrow: this.hasTargetArrow
1521
1535
  }));
1522
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1536
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
1523
1537
  color: (e == null ? void 0 : e.color) ?? f.color,
1524
1538
  width: (e == null ? void 0 : e.width) ?? f.width,
1525
1539
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1551,7 +1565,7 @@ class pt {
1551
1565
  i(this, "hasSourceArrow");
1552
1566
  i(this, "hasTargetArrow");
1553
1567
  i(this, "pathShape");
1554
- i(this, "createCyclePath", (e) => new Z({
1568
+ i(this, "createCyclePath", (e) => new Q({
1555
1569
  sourceDirection: e,
1556
1570
  arrowLength: this.arrowLength,
1557
1571
  side: this.cycleSquareSide,
@@ -1590,7 +1604,7 @@ class pt {
1590
1604
  t,
1591
1605
  this.arrowOffset,
1592
1606
  this.cycleSquareSide / 2
1593
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1607
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
1594
1608
  color: (e == null ? void 0 : e.color) ?? f.color,
1595
1609
  width: (e == null ? void 0 : e.width) ?? f.width,
1596
1610
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1623,7 +1637,7 @@ class wt {
1623
1637
  i(this, "hasSourceArrow");
1624
1638
  i(this, "hasTargetArrow");
1625
1639
  i(this, "pathShape");
1626
- i(this, "createCyclePath", (e) => new Z({
1640
+ i(this, "createCyclePath", (e) => new Q({
1627
1641
  sourceDirection: e,
1628
1642
  arrowLength: this.arrowLength,
1629
1643
  side: this.cycleSquareSide,
@@ -1662,7 +1676,7 @@ class wt {
1662
1676
  t,
1663
1677
  this.arrowOffset,
1664
1678
  this.cycleSquareSide / 2
1665
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1679
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
1666
1680
  color: (e == null ? void 0 : e.color) ?? f.color,
1667
1681
  width: (e == null ? void 0 : e.width) ?? f.width,
1668
1682
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1694,7 +1708,7 @@ class ft {
1694
1708
  i(this, "hasSourceArrow");
1695
1709
  i(this, "hasTargetArrow");
1696
1710
  i(this, "pathShape");
1697
- i(this, "createCyclePath", (e) => new Z({
1711
+ i(this, "createCyclePath", (e) => new Q({
1698
1712
  sourceDirection: e,
1699
1713
  arrowLength: this.arrowLength,
1700
1714
  side: this.cycleSquareSide,
@@ -1733,7 +1747,7 @@ class ft {
1733
1747
  t,
1734
1748
  this.arrowOffset,
1735
1749
  this.cycleSquareSide / 2
1736
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1750
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new z({
1737
1751
  color: (e == null ? void 0 : e.color) ?? f.color,
1738
1752
  width: (e == null ? void 0 : e.width) ?? f.width,
1739
1753
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1752,7 +1766,7 @@ class ft {
1752
1766
  class Ne {
1753
1767
  constructor(e) {
1754
1768
  i(this, "svg");
1755
- i(this, "group", Ce());
1769
+ i(this, "group", De());
1756
1770
  i(this, "line");
1757
1771
  i(this, "sourceArrow", null);
1758
1772
  i(this, "targetArrow", null);
@@ -1771,7 +1785,7 @@ class Ne {
1771
1785
  e.from,
1772
1786
  e.to
1773
1787
  );
1774
- De(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1788
+ Ce(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1775
1789
  const d = { x: o, y: n }, c = new at({
1776
1790
  to: d,
1777
1791
  sourceOffset: this.sourceOffset,
@@ -1976,8 +1990,10 @@ class Le {
1976
1990
  }
1977
1991
  class Re {
1978
1992
  constructor(e) {
1993
+ i(this, "onBeforeUpdated");
1979
1994
  i(this, "onAfterUpdated");
1980
- this.viewportStore = e, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
1995
+ i(this, "onAfterResize");
1996
+ this.viewportStore = e, this.onBeforeUpdated = this.viewportStore.onBeforeUpdated, this.onAfterUpdated = this.viewportStore.onAfterUpdated, this.onAfterResize = this.viewportStore.onAfterResize;
1981
1997
  }
1982
1998
  getViewportMatrix() {
1983
1999
  return { ...this.viewportStore.getViewportMatrix() };
@@ -1985,9 +2001,12 @@ class Re {
1985
2001
  getContentMatrix() {
1986
2002
  return { ...this.viewportStore.getContentMatrix() };
1987
2003
  }
2004
+ getDimensions() {
2005
+ return this.viewportStore.getDimensions();
2006
+ }
1988
2007
  }
1989
- const Fe = (r, e) => {
1990
- const t = new xe(), s = new Le(t), o = new Re(e), n = new me(t, e, r), a = {
2008
+ const Ve = (r, e) => {
2009
+ const t = new Ae(), s = new Le(t), o = new Re(e), n = new me(t, e, r), a = {
1991
2010
  nodes: {
1992
2011
  centerFn: Se,
1993
2012
  priorityFn: () => 0
@@ -2009,7 +2028,7 @@ const Fe = (r, e) => {
2009
2028
  a
2010
2029
  );
2011
2030
  };
2012
- class z {
2031
+ class k {
2013
2032
  constructor(e, t, s, o) {
2014
2033
  i(this, "onAfterPortMarked", (e) => {
2015
2034
  const t = this.canvas.graph.getPort(e);
@@ -2033,7 +2052,7 @@ class z {
2033
2052
  }));
2034
2053
  });
2035
2054
  i(this, "onWindowMouseMove", (e) => {
2036
- if (!F(
2055
+ if (!V(
2037
2056
  this.window,
2038
2057
  this.element,
2039
2058
  e.clientX,
@@ -2064,7 +2083,7 @@ class z {
2064
2083
  });
2065
2084
  i(this, "onWindowTouchMove", (e) => {
2066
2085
  const t = e.touches[0];
2067
- if (!F(
2086
+ if (!V(
2068
2087
  this.window,
2069
2088
  this.element,
2070
2089
  t.clientX,
@@ -2091,7 +2110,7 @@ class z {
2091
2110
  this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2092
2111
  }
2093
2112
  static configure(e, t, s, o) {
2094
- new z(e, t, s, o);
2113
+ new k(e, t, s, o);
2095
2114
  }
2096
2115
  hookPortEvents(e) {
2097
2116
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2116,7 +2135,7 @@ class z {
2116
2135
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2117
2136
  }
2118
2137
  }
2119
- class J {
2138
+ class Z {
2120
2139
  constructor(e, t, s, o) {
2121
2140
  i(this, "grabbedNode", null);
2122
2141
  i(this, "maxNodePriority", 0);
@@ -2196,7 +2215,7 @@ class J {
2196
2215
  });
2197
2216
  });
2198
2217
  i(this, "onWindowMouseMove", (e) => {
2199
- if (!F(
2218
+ if (!V(
2200
2219
  this.window,
2201
2220
  this.element,
2202
2221
  e.clientX,
@@ -2217,7 +2236,7 @@ class J {
2217
2236
  if (e.touches.length !== 1)
2218
2237
  return;
2219
2238
  const t = e.touches[0];
2220
- if (!F(
2239
+ if (!V(
2221
2240
  this.window,
2222
2241
  this.element,
2223
2242
  t.clientX,
@@ -2237,7 +2256,7 @@ class J {
2237
2256
  this.canvas = e, this.element = t, this.window = s, this.params = o, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2238
2257
  }
2239
2258
  static configure(e, t, s, o) {
2240
- new J(e, t, s, o);
2259
+ new Z(e, t, s, o);
2241
2260
  }
2242
2261
  moveNode(e, t) {
2243
2262
  if (this.graph.getNode(e.nodeId) === null)
@@ -2292,7 +2311,7 @@ class J {
2292
2311
  x: e.x - t.x,
2293
2312
  y: e.y - t.y
2294
2313
  }, o = this.canvas.viewport.getViewportMatrix();
2295
- return D(o, s);
2314
+ return C(o, s);
2296
2315
  }
2297
2316
  adjustNodeCoords(e) {
2298
2317
  const t = this.params.gridSize;
@@ -2306,11 +2325,11 @@ class J {
2306
2325
  return e;
2307
2326
  }
2308
2327
  }
2309
- const xt = (r, e, t) => ({
2328
+ const At = (r, e, t) => ({
2310
2329
  scale: r.scale,
2311
2330
  x: r.x + r.scale * e,
2312
2331
  y: r.y + r.scale * t
2313
- }), At = (r, e, t, s) => ({
2332
+ }), Et = (r, e, t, s) => ({
2314
2333
  scale: r.scale * e,
2315
2334
  x: r.scale * (1 - e) * t + r.x,
2316
2335
  y: r.scale * (1 - e) * s + r.y
@@ -2350,7 +2369,7 @@ class H {
2350
2369
  }), this.startRegisteredTransform());
2351
2370
  });
2352
2371
  i(this, "onWindowMouseMove", (e) => {
2353
- const t = F(
2372
+ const t = V(
2354
2373
  this.window,
2355
2374
  this.element,
2356
2375
  e.clientX,
@@ -2364,7 +2383,7 @@ class H {
2364
2383
  this.moveViewport(s, o);
2365
2384
  });
2366
2385
  i(this, "onWindowMouseUp", (e) => {
2367
- this.element === null || !this.params.mouseUpEventVerifier(e) || this.stopMouseDrag();
2386
+ this.params.mouseUpEventVerifier(e) && this.stopMouseDrag();
2368
2387
  });
2369
2388
  i(this, "onWheelScroll", (e) => {
2370
2389
  if (!this.params.mouseWheelEventVerifier(e))
@@ -2390,7 +2409,7 @@ class H {
2390
2409
  i(this, "onWindowTouchMove", (e) => {
2391
2410
  const t = $(e);
2392
2411
  if (!t.touches.every(
2393
- (o) => F(this.window, this.element, o[0], o[1])
2412
+ (o) => V(this.window, this.element, o[0], o[1])
2394
2413
  )) {
2395
2414
  this.stopTouchDrag();
2396
2415
  return;
@@ -2407,21 +2426,14 @@ class H {
2407
2426
  i(this, "onWindowTouchFinish", (e) => {
2408
2427
  e.touches.length > 0 ? this.prevTouches = $(e) : this.stopTouchDrag();
2409
2428
  });
2410
- i(this, "observer", new ResizeObserver(() => {
2411
- const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), o = this.params.transformPreprocessor({
2412
- prevTransform: e,
2413
- nextTransform: e,
2414
- canvasWidth: t,
2415
- canvasHeight: s
2416
- });
2417
- this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
2418
- }));
2419
2429
  i(this, "preventWheelScaleListener", (e) => {
2420
2430
  e.preventDefault();
2421
2431
  });
2422
2432
  this.canvas = e, this.element = t, this.window = s, this.params = o, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
2423
2433
  passive: !1
2424
- }), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
2434
+ }), this.viewport = e.viewport, this.handleResize(), this.viewport.onAfterResize.subscribe(() => {
2435
+ this.handleResize();
2436
+ }), this.element.addEventListener("mousedown", this.onMouseDown, {
2425
2437
  passive: !0
2426
2438
  }), this.element.addEventListener("wheel", this.onWheelScroll, {
2427
2439
  passive: !0
@@ -2433,7 +2445,7 @@ class H {
2433
2445
  new H(e, t, s, o);
2434
2446
  }
2435
2447
  moveViewport(e, t) {
2436
- const s = this.viewport.getViewportMatrix(), o = xt(s, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2448
+ const s = this.viewport.getViewportMatrix(), o = At(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2437
2449
  prevTransform: s,
2438
2450
  nextTransform: o,
2439
2451
  canvasWidth: n,
@@ -2442,7 +2454,7 @@ class H {
2442
2454
  this.performTransform(h);
2443
2455
  }
2444
2456
  scaleViewport(e, t, s) {
2445
- const o = this.canvas.viewport.getViewportMatrix(), n = At(o, e, t, s), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2457
+ const o = this.canvas.viewport.getViewportMatrix(), n = Et(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2446
2458
  prevTransform: o,
2447
2459
  nextTransform: n,
2448
2460
  canvasWidth: a,
@@ -2471,16 +2483,22 @@ class H {
2471
2483
  finishRegisteredTransform() {
2472
2484
  this.transformInProgress = !1, this.params.onTransformFinished();
2473
2485
  }
2486
+ handleResize() {
2487
+ const e = this.viewport.getViewportMatrix(), { width: t, height: s } = this.viewport.getDimensions(), o = this.params.transformPreprocessor({
2488
+ prevTransform: e,
2489
+ nextTransform: e,
2490
+ canvasWidth: t,
2491
+ canvasHeight: s
2492
+ });
2493
+ this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(o), this.params.onResizeTransformFinished();
2494
+ }
2474
2495
  }
2475
- class q {
2496
+ class J {
2476
2497
  constructor(e, t, s, o, n, a) {
2477
- i(this, "canvasResizeObserver");
2478
2498
  i(this, "nodeHorizontal");
2479
2499
  i(this, "nodeVertical");
2480
2500
  i(this, "viewport");
2481
- i(this, "viewportWidth", 0);
2482
- i(this, "viewportHeight", 0);
2483
- i(this, "viewportMatrix");
2501
+ i(this, "currentScale");
2484
2502
  i(this, "loadedArea", {
2485
2503
  xFrom: 1 / 0,
2486
2504
  xTo: 1 / 0,
@@ -2496,13 +2514,12 @@ class q {
2496
2514
  };
2497
2515
  });
2498
2516
  i(this, "onAfterViewportUpdated", () => {
2499
- this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
2517
+ this.userTransformInProgress || this.loadAreaAroundViewport();
2500
2518
  });
2501
2519
  i(this, "userTransformInProgress", !1);
2502
- this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeVerticalRadius, this.nodeVertical = this.params.nodeHorizontalRadius, this.canvasResizeObserver = new ResizeObserver((d) => {
2503
- const c = d[0];
2504
- this.viewportWidth = c.contentRect.width, this.viewportHeight = c.contentRect.height, this.scheduleLoadAreaAroundViewport();
2505
- }), this.viewport = e.viewport;
2520
+ this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeVerticalRadius, this.nodeVertical = this.params.nodeHorizontalRadius, this.viewport = e.viewport, this.currentScale = this.viewport.getViewportMatrix().scale, this.scheduleLoadAreaAroundViewport(), this.viewport.onAfterResize.subscribe(() => {
2521
+ this.scheduleLoadAreaAroundViewport();
2522
+ });
2506
2523
  const h = {
2507
2524
  ...o,
2508
2525
  onResizeTransformStarted: () => {
@@ -2516,8 +2533,8 @@ class q {
2516
2533
  },
2517
2534
  onTransformChange: () => {
2518
2535
  this.userTransformInProgress = !1;
2519
- const d = this.viewportMatrix;
2520
- this.viewportMatrix = this.viewport.getViewportMatrix(), d.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), o.onTransformChange();
2536
+ const d = this.currentScale;
2537
+ this.currentScale = this.viewport.getViewportMatrix().scale, d !== this.currentScale && this.scheduleEnsureViewportAreaLoaded(), o.onTransformChange();
2521
2538
  },
2522
2539
  onTransformFinished: () => {
2523
2540
  this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
@@ -2528,10 +2545,10 @@ class q {
2528
2545
  this.element,
2529
2546
  this.window,
2530
2547
  h
2531
- ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
2548
+ ), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
2532
2549
  }
2533
2550
  static configure(e, t, s, o, n, a) {
2534
- new q(
2551
+ new J(
2535
2552
  e,
2536
2553
  t,
2537
2554
  s,
@@ -2546,15 +2563,22 @@ class q {
2546
2563
  });
2547
2564
  }
2548
2565
  scheduleEnsureViewportAreaLoaded() {
2549
- const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, o = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, a = this.viewportMatrix.y + t + this.nodeVertical;
2550
- this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < o && this.loadedArea.yTo > a || this.scheduleLoadAreaAroundViewport();
2566
+ setTimeout(() => {
2567
+ const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - this.nodeHorizontal, c = n - this.nodeVertical, g = o + a + this.nodeHorizontal, l = n + h + this.nodeVertical;
2568
+ this.loadedArea.xFrom < d && this.loadedArea.xTo > g && this.loadedArea.yFrom < c && this.loadedArea.yTo > l || this.loadAreaAroundViewport();
2569
+ });
2551
2570
  }
2552
2571
  loadAreaAroundViewport() {
2553
- const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, o = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, a = 3 * t + 2 * this.nodeVertical;
2554
- this.trigger.emit({ x: s, y: o, width: n, height: a });
2572
+ const { width: e, height: t } = this.viewport.getDimensions(), { scale: s, x: o, y: n } = this.viewport.getViewportMatrix(), a = e * s, h = t * s, d = o - a - this.nodeHorizontal, c = n - h - this.nodeVertical, g = 3 * a + 2 * this.nodeHorizontal, l = 3 * h + 2 * this.nodeVertical;
2573
+ this.trigger.emit({
2574
+ x: d,
2575
+ y: c,
2576
+ width: g,
2577
+ height: l
2578
+ });
2555
2579
  }
2556
2580
  }
2557
- const Et = () => {
2581
+ const xt = () => {
2558
2582
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2559
2583
  return r.style.position = "absolute", r.style.inset = "0", r;
2560
2584
  }, St = () => {
@@ -2569,7 +2593,7 @@ const Et = () => {
2569
2593
  };
2570
2594
  class _ {
2571
2595
  constructor(e, t, s) {
2572
- i(this, "svg", Et());
2596
+ i(this, "svg", xt());
2573
2597
  i(this, "patternRenderingRectangle", St());
2574
2598
  i(this, "pattern", bt());
2575
2599
  i(this, "patternContent");
@@ -2579,12 +2603,6 @@ class _ {
2579
2603
  i(this, "halfTileHeight");
2580
2604
  i(this, "maxViewportScale");
2581
2605
  i(this, "visible", !1);
2582
- i(this, "resizeObserver", new ResizeObserver((e) => {
2583
- const t = e[0], { width: s, height: o } = t.contentRect;
2584
- this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${o}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${o}`);
2585
- const n = this.tileWidth / s, a = this.tileHeight / o;
2586
- this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${a}`);
2587
- }));
2588
2606
  i(this, "onAfterTransformUpdated", () => {
2589
2607
  const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, o = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
2590
2608
  this.pattern.setAttribute("patternTransform", o), this.updateVisibility();
@@ -2593,7 +2611,9 @@ class _ {
2593
2611
  const o = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
2594
2612
  this.patternContent.setAttribute("transform", o), this.pattern.appendChild(this.patternContent);
2595
2613
  const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
2596
- n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.backgroundHost), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
2614
+ n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.updateDimensions(), this.canvas.viewport.onAfterResize.subscribe(() => {
2615
+ this.updateDimensions();
2616
+ }), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
2597
2617
  }
2598
2618
  static configure(e, t, s) {
2599
2619
  new _(e, t, s);
@@ -2602,6 +2622,12 @@ class _ {
2602
2622
  const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2603
2623
  t && this.visible ? (this.visible = !1, this.backgroundHost.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.backgroundHost.appendChild(this.svg));
2604
2624
  }
2625
+ updateDimensions() {
2626
+ const { width: e, height: t } = this.canvas.viewport.getDimensions();
2627
+ this.svg.setAttribute("width", `${e}`), this.svg.setAttribute("height", `${t}`), this.patternRenderingRectangle.setAttribute("width", `${e}`), this.patternRenderingRectangle.setAttribute("height", `${t}`);
2628
+ const s = this.tileWidth / e, o = this.tileHeight / t;
2629
+ this.pattern.setAttribute("width", `${s}`), this.pattern.setAttribute("height", `${o}`);
2630
+ }
2605
2631
  }
2606
2632
  class ee {
2607
2633
  constructor(e, t, s, o, n) {
@@ -2611,10 +2637,10 @@ class ee {
2611
2637
  i(this, "onEdgeCreated", (e) => {
2612
2638
  this.params.onAfterEdgeCreated(e);
2613
2639
  });
2614
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Fe(
2640
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
2615
2641
  this.overlayLayer,
2616
2642
  this.viewportStore
2617
- ), z.configure(
2643
+ ), k.configure(
2618
2644
  this.canvas,
2619
2645
  this.overlayLayer,
2620
2646
  this.window,
@@ -2649,10 +2675,10 @@ class ee {
2649
2675
  grabPort(e, t, s) {
2650
2676
  const o = this.canvas.graph.getPort(e);
2651
2677
  this.staticPortId = e;
2652
- const n = o.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), g = D(c, {
2678
+ const n = o.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), g = C(c, {
2653
2679
  x: a - d.x,
2654
2680
  y: h - d.y
2655
- }), l = D(c, {
2681
+ }), l = C(c, {
2656
2682
  x: t.x - d.x,
2657
2683
  y: t.y - d.y
2658
2684
  }), u = {
@@ -2665,10 +2691,10 @@ class ee {
2665
2691
  portDirection: this.params.dragPortDirection
2666
2692
  };
2667
2693
  this.isTargetDragging = s === "direct";
2668
- const [y, x] = this.isTargetDragging ? [u, w] : [w, u];
2669
- this.overlayCanvas.addNode(B(y)), this.overlayCanvas.addNode(B(x)), this.overlayCanvas.addEdge({
2694
+ const [y, A] = this.isTargetDragging ? [u, w] : [w, u];
2695
+ this.overlayCanvas.addNode(B(y)), this.overlayCanvas.addNode(B(A)), this.overlayCanvas.addEdge({
2670
2696
  from: y.overlayId,
2671
- to: x.overlayId,
2697
+ to: A.overlayId,
2672
2698
  shape: this.params.edgeShapeFactory(T.Edge)
2673
2699
  });
2674
2700
  }
@@ -2676,7 +2702,7 @@ class ee {
2676
2702
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2677
2703
  }
2678
2704
  tryCreateConnection(e) {
2679
- const t = Ee(this.canvas.graph, e), s = this.staticPortId;
2705
+ const t = xe(this.canvas.graph, e), s = this.staticPortId;
2680
2706
  if (t === null) {
2681
2707
  this.params.onEdgeCreationInterrupted({
2682
2708
  staticPortId: s,
@@ -2691,7 +2717,7 @@ class ee {
2691
2717
  const t = this.overlayLayer.getBoundingClientRect(), s = {
2692
2718
  x: e.x - t.x,
2693
2719
  y: e.y - t.y
2694
- }, o = this.canvas.viewport.getViewportMatrix(), n = D(o, s);
2720
+ }, o = this.canvas.viewport.getViewportMatrix(), n = C(o, s);
2695
2721
  this.overlayCanvas.updateNode(T.Dragging, {
2696
2722
  x: n.x,
2697
2723
  y: n.y
@@ -2707,10 +2733,10 @@ class te {
2707
2733
  i(this, "onEdgeReattached", (e) => {
2708
2734
  this.params.onAfterEdgeReattached(e);
2709
2735
  });
2710
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Fe(
2736
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Ve(
2711
2737
  this.overlayLayer,
2712
2738
  this.viewportStore
2713
- ), z.configure(
2739
+ ), k.configure(
2714
2740
  this.canvas,
2715
2741
  this.overlayLayer,
2716
2742
  this.window,
@@ -2751,10 +2777,10 @@ class te {
2751
2777
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
2752
2778
  x: g.x + g.width / 2,
2753
2779
  y: g.y + g.height / 2
2754
- }, u = this.canvas.viewport.getViewportMatrix(), w = this.overlayLayer.getBoundingClientRect(), y = D(u, {
2780
+ }, u = this.canvas.viewport.getViewportMatrix(), w = this.overlayLayer.getBoundingClientRect(), y = C(u, {
2755
2781
  x: l.x - w.x,
2756
2782
  y: l.y - w.y
2757
- }), x = D(u, {
2783
+ }), A = C(u, {
2758
2784
  x: t.x - w.x,
2759
2785
  y: t.y - w.y
2760
2786
  });
@@ -2765,20 +2791,20 @@ class te {
2765
2791
  shape: o.shape,
2766
2792
  priority: o.priority
2767
2793
  }, this.canvas.removeEdge(s);
2768
- const A = {
2794
+ const x = {
2769
2795
  overlayId: T.Static,
2770
2796
  portCoords: y,
2771
2797
  portDirection: c.direction
2772
2798
  }, S = {
2773
2799
  overlayId: T.Dragging,
2774
- portCoords: x,
2800
+ portCoords: A,
2775
2801
  portDirection: d.direction
2776
- }, [C, P] = this.isTargetDragging ? [A, S] : [S, A];
2777
- this.overlayCanvas.addNode(B(C)), this.overlayCanvas.addNode(B(P));
2802
+ }, [D, P] = this.isTargetDragging ? [x, S] : [S, x];
2803
+ this.overlayCanvas.addNode(B(D)), this.overlayCanvas.addNode(B(P));
2778
2804
  const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(T.Edge) : o.shape;
2779
2805
  return this.overlayCanvas.addEdge({
2780
2806
  id: T.Edge,
2781
- from: C.overlayId,
2807
+ from: D.overlayId,
2782
2808
  to: P.overlayId,
2783
2809
  shape: N
2784
2810
  }), !0;
@@ -2790,14 +2816,14 @@ class te {
2790
2816
  const t = this.overlayLayer.getBoundingClientRect(), s = {
2791
2817
  x: e.x - t.x,
2792
2818
  y: e.y - t.y
2793
- }, o = this.canvas.viewport.getViewportMatrix(), n = D(o, s);
2819
+ }, o = this.canvas.viewport.getViewportMatrix(), n = C(o, s);
2794
2820
  this.overlayCanvas.updateNode(T.Dragging, {
2795
2821
  x: n.x,
2796
2822
  y: n.y
2797
2823
  });
2798
2824
  }
2799
2825
  tryCreateConnection(e) {
2800
- const t = Ee(this.canvas.graph, e);
2826
+ const t = xe(this.canvas.graph, e);
2801
2827
  if (this.overlayCanvas.removeEdge(T.Edge), t === null) {
2802
2828
  const d = this.draggingEdgePayload;
2803
2829
  this.params.onEdgeReattachInterrupted({
@@ -2932,7 +2958,7 @@ class oe {
2932
2958
  new oe(e, t, s, o);
2933
2959
  }
2934
2960
  }
2935
- const Ct = () => {
2961
+ const Dt = () => {
2936
2962
  const r = document.createElement("div");
2937
2963
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
2938
2964
  }, Y = () => {
@@ -2942,13 +2968,13 @@ const Ct = () => {
2942
2968
  const r = Y();
2943
2969
  return r.style.pointerEvents = "none", r;
2944
2970
  };
2945
- class Dt {
2971
+ class Ct {
2946
2972
  constructor(e) {
2947
2973
  i(this, "background", Y());
2948
2974
  i(this, "main", Y());
2949
2975
  i(this, "overlayConnectablePorts", pe());
2950
2976
  i(this, "overlayDraggableEdges", pe());
2951
- i(this, "host", Ct());
2977
+ i(this, "host", Dt());
2952
2978
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
2953
2979
  }
2954
2980
  destroy() {
@@ -3055,11 +3081,11 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3055
3081
  }
3056
3082
  };
3057
3083
  }, Rt = (r) => {
3058
- var w, y, x, A, S, C;
3084
+ var w, y, A, x, S, D;
3059
3085
  const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3060
3086
  }), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
3061
- }), s = r.nodeDragVerifier ?? (() => !0), o = ((x = r.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
3062
- }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (A = r.mouse) == null ? void 0 : A.dragCursor, d = h !== void 0 ? h : "grab", c = (S = r.mouse) == null ? void 0 : S.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (C = r.mouse) == null ? void 0 : C.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
3087
+ }), s = r.nodeDragVerifier ?? (() => !0), o = ((A = r.events) == null ? void 0 : A.onNodeDragFinished) ?? (() => {
3088
+ }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (S = r.mouse) == null ? void 0 : S.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (D = r.mouse) == null ? void 0 : D.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
3063
3089
  return {
3064
3090
  moveOnTop: n,
3065
3091
  moveEdgesOnTop: a,
@@ -3072,7 +3098,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3072
3098
  nodeDragVerifier: s,
3073
3099
  onNodeDragFinished: o
3074
3100
  };
3075
- }, Ft = (r) => {
3101
+ }, Vt = (r) => {
3076
3102
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, o = r.maxY !== null ? r.maxY : 1 / 0;
3077
3103
  return (n) => {
3078
3104
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3082,7 +3108,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3082
3108
  const g = n.canvasHeight * n.prevTransform.scale, l = o - g;
3083
3109
  return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
3084
3110
  };
3085
- }, Vt = (r) => {
3111
+ }, Ft = (r) => {
3086
3112
  const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, o = t !== null ? 1 / t : 1 / 0;
3087
3113
  return (n) => {
3088
3114
  const a = n.prevTransform, h = n.nextTransform;
@@ -3116,12 +3142,12 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3116
3142
  return r;
3117
3143
  switch (r.type) {
3118
3144
  case "scale-limit":
3119
- return Vt({
3145
+ return Ft({
3120
3146
  minContentScale: r.minContentScale ?? 0,
3121
3147
  maxContentScale: r.maxContentScale ?? 1 / 0
3122
3148
  });
3123
3149
  case "shift-limit":
3124
- return Ft({
3150
+ return Vt({
3125
3151
  minX: r.minX ?? -1 / 0,
3126
3152
  maxX: r.maxX ?? 1 / 0,
3127
3153
  minY: r.minY ?? -1 / 0,
@@ -3129,7 +3155,7 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3129
3155
  });
3130
3156
  }
3131
3157
  }, ye = (r) => {
3132
- var y, x, A, S, C, P, N, V, ne, ae, he, de;
3158
+ var y, A, x, S, D, P, N, F, ne, ae, he, de;
3133
3159
  const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3134
3160
  let o;
3135
3161
  s !== void 0 ? Array.isArray(s) ? o = It(
@@ -3137,12 +3163,12 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3137
3163
  (M) => fe(M)
3138
3164
  )
3139
3165
  ) : o = fe(s) : o = (M) => M.nextTransform;
3140
- const n = ((x = r == null ? void 0 : r.shift) == null ? void 0 : x.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((A = r == null ? void 0 : r.events) == null ? void 0 : A.onBeforeTransformChange) ?? (() => {
3166
+ const n = ((A = r == null ? void 0 : r.shift) == null ? void 0 : A.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
3141
3167
  }), h = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onTransformChange) ?? (() => {
3142
- }), d = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (M) => M.button === 0, u = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
3168
+ }), d = (D = r == null ? void 0 : r.shift) == null ? void 0 : D.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (M) => M.button === 0, u = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
3143
3169
  return {
3144
3170
  wheelSensitivity: t,
3145
- onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
3171
+ onTransformStarted: ((F = r == null ? void 0 : r.events) == null ? void 0 : F.onTransformStarted) ?? (() => {
3146
3172
  }),
3147
3173
  onTransformFinished: ((ne = r == null ? void 0 : r.events) == null ? void 0 : ne.onTransformFinished) ?? (() => {
3148
3174
  }),
@@ -3212,10 +3238,10 @@ const G = (r) => () => r, we = G(0), Nt = () => {
3212
3238
  onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
3213
3239
  onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
3214
3240
  };
3215
- }, kt = (r) => ({
3241
+ }, zt = (r) => ({
3216
3242
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3217
3243
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3218
- }), zt = (r) => {
3244
+ }), kt = (r) => {
3219
3245
  var e, t;
3220
3246
  return {
3221
3247
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3230,7 +3256,7 @@ class Ht extends Error {
3230
3256
  i(this, "name", "CanvasBuilderError");
3231
3257
  }
3232
3258
  }
3233
- class Ve {
3259
+ class Fe {
3234
3260
  constructor(e, t, s) {
3235
3261
  i(this, "dt");
3236
3262
  i(this, "nodeMass");
@@ -3241,17 +3267,22 @@ class Ve {
3241
3267
  this.graph = e, this.currentCoords = t, this.dt = s.dtSec, this.nodeMass = s.nodeMass, this.edgeEquilibriumLength = s.edgeEquilibriumLength, this.edgeStiffness = s.edgeStiffness, this.distanceVectorGenerator = s.distanceVectorGenerator, this.nodeForcesApplicationStrategy = s.nodeForcesApplicationStrategy;
3242
3268
  }
3243
3269
  apply() {
3244
- let e = 0;
3245
- const t = /* @__PURE__ */ new Map();
3246
- return this.graph.getAllNodeIds().forEach((o) => {
3247
- t.set(o, { x: 0, y: 0 });
3248
- }), this.nodeForcesApplicationStrategy.apply(this.currentCoords, t), this.applyEdgeForces(t), this.currentCoords.forEach((o, n) => {
3249
- const a = t.get(n), h = {
3250
- x: a.x / this.nodeMass * this.dt,
3251
- y: a.y / this.nodeMass * this.dt
3252
- }, d = h.x * this.dt, c = h.y * this.dt;
3253
- o.x += d, o.y += c, e = Math.max(e, Math.sqrt(d * d + c * c));
3254
- }), e;
3270
+ let e = 0, t = 0;
3271
+ const s = /* @__PURE__ */ new Map();
3272
+ return this.graph.getAllNodeIds().forEach((n) => {
3273
+ s.set(n, { x: 0, y: 0 });
3274
+ }), this.nodeForcesApplicationStrategy.apply(this.currentCoords, s), this.applyEdgeForces(s), this.currentCoords.forEach((n, a) => {
3275
+ const h = s.get(a), d = {
3276
+ x: h.x / this.nodeMass * this.dt,
3277
+ y: h.y / this.nodeMass * this.dt
3278
+ };
3279
+ t = Math.max(
3280
+ t,
3281
+ Math.sqrt(d.x * d.x + d.y * d.y)
3282
+ );
3283
+ const c = d.x * this.dt, g = d.y * this.dt;
3284
+ n.x += c, n.y += g, e = Math.max(e, Math.sqrt(c * c + g * g));
3285
+ }), [e, t];
3255
3286
  }
3256
3287
  applyEdgeForces(e) {
3257
3288
  this.graph.getAllEdgeIds().forEach((t) => {
@@ -3263,17 +3294,7 @@ class Ve {
3263
3294
  });
3264
3295
  }
3265
3296
  }
3266
- const Ie = (r, e, t) => {
3267
- const s = /* @__PURE__ */ new Map(), o = r.getAllNodeIds(), n = Math.sqrt(o.length) * t;
3268
- return o.forEach((a) => {
3269
- const h = r.getNode(a);
3270
- s.set(a, {
3271
- x: h.x ?? n * e(),
3272
- y: h.y ?? n * e()
3273
- });
3274
- }), s;
3275
- };
3276
- class $e {
3297
+ class Ie {
3277
3298
  constructor(e) {
3278
3299
  i(this, "PI2", 2 * Math.PI);
3279
3300
  this.rand = e;
@@ -3292,7 +3313,7 @@ class $e {
3292
3313
  return { ex: h, ey: d, d: a };
3293
3314
  }
3294
3315
  }
3295
- const Ue = (r) => {
3316
+ const $e = (r) => {
3296
3317
  if (r.distance === 0)
3297
3318
  return r.maxForce;
3298
3319
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
@@ -3317,14 +3338,14 @@ class Xt {
3317
3338
  );
3318
3339
  if (l.d > this.effectiveDistance)
3319
3340
  continue;
3320
- const u = Ue({
3341
+ const u = $e({
3321
3342
  coefficient: 1,
3322
3343
  sourceCharge: this.nodeCharge,
3323
3344
  targetCharge: this.nodeCharge,
3324
3345
  distance: l.d,
3325
3346
  maxForce: this.maxForce
3326
- }), w = u * l.ex, y = u * l.ey, x = t.get(a), A = t.get(d);
3327
- x.x -= w, x.y -= y, A.x += w, A.y += y;
3347
+ }), w = u * l.ex, y = u * l.ey, A = t.get(a), x = t.get(d);
3348
+ A.x -= w, A.y -= y, x.x += w, x.y += y;
3328
3349
  }
3329
3350
  }
3330
3351
  }
@@ -3631,7 +3652,7 @@ class jt {
3631
3652
  const t = this.distanceVectorGenerator.create(
3632
3653
  e.sourceCoords,
3633
3654
  e.targetCoords
3634
- ), s = Ue({
3655
+ ), s = $e({
3635
3656
  coefficient: this.nodeForceCoefficient,
3636
3657
  sourceCharge: e.sourceCharge,
3637
3658
  targetCharge: e.targetCharge,
@@ -3666,7 +3687,7 @@ class jt {
3666
3687
  }
3667
3688
  }
3668
3689
  }
3669
- const Be = (r) => r.theta !== 0 ? new jt({
3690
+ const Ue = (r) => r.theta !== 0 ? new jt({
3670
3691
  nodeCharge: r.nodeCharge,
3671
3692
  nodeForceCoefficient: r.nodeForceCoefficient,
3672
3693
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -3681,80 +3702,111 @@ const Be = (r) => r.theta !== 0 ? new jt({
3681
3702
  effectiveDistance: r.effectiveDistance,
3682
3703
  maxForce: r.maxForce
3683
3704
  });
3684
- class Kt {
3705
+ class Be {
3706
+ constructor(e) {
3707
+ i(this, "rand");
3708
+ i(this, "sparsity");
3709
+ this.rand = e.rand, this.sparsity = e.sparsity;
3710
+ }
3711
+ calculateCoordinates(e) {
3712
+ const t = /* @__PURE__ */ new Map(), s = e.getAllNodeIds(), o = Math.sqrt(s.length) * this.sparsity;
3713
+ return s.forEach((n) => {
3714
+ const a = e.getNode(n);
3715
+ t.set(n, {
3716
+ x: a.x ?? o * this.rand(),
3717
+ y: a.y ?? o * this.rand()
3718
+ });
3719
+ }), t;
3720
+ }
3721
+ }
3722
+ class qt {
3685
3723
  constructor(e) {
3686
3724
  i(this, "distanceVectorGenerator");
3687
3725
  i(this, "nodeForcesApplicationStrategy");
3688
- this.params = e, this.distanceVectorGenerator = new $e(
3689
- this.params.rand
3690
- ), this.nodeForcesApplicationStrategy = Be({
3726
+ i(this, "fillerLayoutAlgorithm");
3727
+ i(this, "maxIterations");
3728
+ i(this, "dtSec");
3729
+ i(this, "nodeMass");
3730
+ i(this, "edgeEquilibriumLength");
3731
+ i(this, "edgeStiffness");
3732
+ i(this, "convergenceDelta");
3733
+ i(this, "convergenceVelocity");
3734
+ this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceDelta = e.convergenceDelta, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
3691
3735
  distanceVectorGenerator: this.distanceVectorGenerator,
3692
- nodeCharge: this.params.nodeCharge,
3693
- effectiveDistance: this.params.effectiveDistance,
3694
- maxForce: this.params.maxForce,
3695
- nodeForceCoefficient: this.params.nodeForceCoefficient,
3696
- theta: this.params.barnesHutTheta,
3697
- areaRadiusThreshold: this.params.barnesHutAreaRadiusThreshold,
3698
- nodeMass: this.params.nodeMass
3736
+ nodeCharge: e.nodeCharge,
3737
+ effectiveDistance: e.effectiveDistance,
3738
+ maxForce: e.maxForce,
3739
+ nodeForceCoefficient: e.nodeForceCoefficient,
3740
+ theta: e.barnesHutTheta,
3741
+ areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3742
+ nodeMass: e.nodeMass
3743
+ }), this.fillerLayoutAlgorithm = new Be({
3744
+ rand: e.rand,
3745
+ sparsity: e.edgeEquilibriumLength
3699
3746
  });
3700
3747
  }
3701
3748
  calculateCoordinates(e) {
3702
- const t = Ie(
3703
- e,
3704
- this.params.rand,
3705
- this.params.edgeEquilibriumLength
3706
- );
3707
- for (let s = 0; s < this.params.maxIterations && !(new Ve(
3708
- e,
3709
- t,
3710
- {
3711
- distanceVectorGenerator: this.distanceVectorGenerator,
3712
- nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
3713
- dtSec: this.params.dtSec,
3714
- nodeMass: this.params.nodeMass,
3715
- edgeEquilibriumLength: this.params.edgeEquilibriumLength,
3716
- edgeStiffness: this.params.edgeStiffness
3717
- }
3718
- ).apply() < this.params.convergenceDelta); s++)
3719
- ;
3749
+ const t = this.fillerLayoutAlgorithm.calculateCoordinates(e);
3750
+ for (let s = 0; s < this.maxIterations; s++) {
3751
+ const o = new Fe(
3752
+ e,
3753
+ t,
3754
+ {
3755
+ distanceVectorGenerator: this.distanceVectorGenerator,
3756
+ nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
3757
+ dtSec: this.dtSec,
3758
+ nodeMass: this.nodeMass,
3759
+ edgeEquilibriumLength: this.edgeEquilibriumLength,
3760
+ edgeStiffness: this.edgeStiffness
3761
+ }
3762
+ ), [n, a] = o.apply();
3763
+ if (n < this.convergenceDelta || a < this.convergenceVelocity)
3764
+ break;
3765
+ }
3720
3766
  return t;
3721
3767
  }
3722
3768
  }
3723
- class Qt {
3769
+ class Kt {
3724
3770
  constructor(e) {
3725
3771
  i(this, "distanceVectorGenerator");
3726
3772
  i(this, "nodeForcesApplicationStrategy");
3727
- this.params = e, this.distanceVectorGenerator = new $e(e.rand), this.nodeForcesApplicationStrategy = Be({
3773
+ i(this, "convergenceDelta");
3774
+ i(this, "convergenceVelocity");
3775
+ i(this, "maxTimeDeltaSec");
3776
+ i(this, "nodeMass");
3777
+ i(this, "edgeEquilibriumLength");
3778
+ i(this, "edgeStiffness");
3779
+ i(this, "fillerLayoutAlgorithm");
3780
+ this.convergenceDelta = e.convergenceDelta, this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ie(e.rand), this.nodeForcesApplicationStrategy = Ue({
3728
3781
  distanceVectorGenerator: this.distanceVectorGenerator,
3729
- nodeCharge: this.params.nodeCharge,
3730
- effectiveDistance: this.params.effectiveDistance,
3731
- maxForce: this.params.maxForce,
3732
- nodeForceCoefficient: this.params.nodeForceCoefficient,
3733
- theta: this.params.barnesHutTheta,
3734
- areaRadiusThreshold: this.params.barnesHutAreaRadiusThreshold,
3735
- nodeMass: this.params.nodeMass
3782
+ nodeCharge: e.nodeCharge,
3783
+ effectiveDistance: e.effectiveDistance,
3784
+ maxForce: e.maxForce,
3785
+ nodeForceCoefficient: e.nodeForceCoefficient,
3786
+ theta: e.barnesHutTheta,
3787
+ areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3788
+ nodeMass: e.nodeMass
3789
+ }), this.fillerLayoutAlgorithm = new Be({
3790
+ rand: e.rand,
3791
+ sparsity: e.edgeEquilibriumLength
3736
3792
  });
3737
3793
  }
3738
3794
  calculateNextCoordinates(e, t) {
3739
- const s = Ie(
3740
- e,
3741
- this.params.rand,
3742
- this.params.edgeEquilibriumLength
3743
- );
3744
- return new Ve(
3795
+ const s = this.fillerLayoutAlgorithm.calculateCoordinates(e), o = new Fe(
3745
3796
  e,
3746
3797
  s,
3747
3798
  {
3748
3799
  distanceVectorGenerator: this.distanceVectorGenerator,
3749
3800
  nodeForcesApplicationStrategy: this.nodeForcesApplicationStrategy,
3750
- dtSec: Math.min(t, this.params.maxTimeDeltaSec),
3751
- nodeMass: this.params.nodeMass,
3752
- edgeEquilibriumLength: this.params.edgeEquilibriumLength,
3753
- edgeStiffness: this.params.edgeStiffness
3801
+ dtSec: Math.min(t, this.maxTimeDeltaSec),
3802
+ nodeMass: this.nodeMass,
3803
+ edgeEquilibriumLength: this.edgeEquilibriumLength,
3804
+ edgeStiffness: this.edgeStiffness
3754
3805
  }
3755
- ).apply() < this.params.convergenceDelta && !e.getAllNodeIds().some((h) => {
3756
- const d = e.getNode(h);
3757
- return d.x === null || d.y === null;
3806
+ ), [n, a] = o.apply();
3807
+ return (n < this.convergenceDelta || a < this.convergenceVelocity) && !e.getAllNodeIds().some((d) => {
3808
+ const c = e.getNode(d);
3809
+ return c.x === null || c.y === null;
3758
3810
  }) ? /* @__PURE__ */ new Map() : s;
3759
3811
  }
3760
3812
  }
@@ -3777,19 +3829,20 @@ const Oe = (r) => {
3777
3829
  effectiveDistance: 1e3,
3778
3830
  dtSec: 0.01,
3779
3831
  maxIterations: 1e3,
3780
- convergenceDelta: 1,
3832
+ convergenceDelta: 0,
3833
+ convergenceVelocity: 10,
3781
3834
  maxForce: 1e7,
3782
3835
  nodeForceCoefficient: 1,
3783
3836
  barnesHutAreaRadiusThreshold: 0.01,
3784
3837
  barnesHutTheta: 1
3785
- }), Zt = (r) => {
3838
+ }), Qt = (r) => {
3786
3839
  var e, t, s;
3787
3840
  switch ((e = r == null ? void 0 : r.algorithm) == null ? void 0 : e.type) {
3788
3841
  case "custom":
3789
3842
  return r.algorithm.instance;
3790
3843
  default: {
3791
3844
  const o = r == null ? void 0 : r.algorithm, n = Oe((o == null ? void 0 : o.seed) ?? v.seed), a = We(n[0], n[1], n[2], n[3]);
3792
- return new Qt({
3845
+ return new Kt({
3793
3846
  rand: a,
3794
3847
  maxTimeDeltaSec: (o == null ? void 0 : o.maxTimeDeltaSec) ?? v.maxTimeDeltaSec,
3795
3848
  nodeCharge: (o == null ? void 0 : o.nodeCharge) ?? v.nodeCharge,
@@ -3798,6 +3851,7 @@ const Oe = (r) => {
3798
3851
  effectiveDistance: v.effectiveDistance,
3799
3852
  edgeStiffness: (o == null ? void 0 : o.edgeStiffness) ?? v.edgeStiffness,
3800
3853
  convergenceDelta: (o == null ? void 0 : o.convergenceDelta) ?? v.convergenceDelta,
3854
+ convergenceVelocity: (o == null ? void 0 : o.convergenceVelocity) ?? v.convergenceVelocity,
3801
3855
  maxForce: (o == null ? void 0 : o.maxForce) ?? v.maxForce,
3802
3856
  nodeForceCoefficient: (o == null ? void 0 : o.nodeForceCoefficient) ?? v.nodeForceCoefficient,
3803
3857
  barnesHutTheta: ((t = o == null ? void 0 : o.barnesHut) == null ? void 0 : t.theta) ?? v.barnesHutTheta,
@@ -3805,19 +3859,19 @@ const Oe = (r) => {
3805
3859
  });
3806
3860
  }
3807
3861
  }
3808
- }, Jt = (r) => r instanceof j ? {
3862
+ }, Zt = (r) => r instanceof j ? {
3809
3863
  type: "manual",
3810
3864
  trigger: r
3811
3865
  } : {
3812
3866
  type: "topologyChangeTimeout"
3813
- }, qt = (r) => {
3867
+ }, Jt = (r) => {
3814
3868
  var e, t;
3815
3869
  switch (r == null ? void 0 : r.type) {
3816
3870
  case "custom":
3817
3871
  return r.instance;
3818
3872
  default: {
3819
3873
  const s = Oe((r == null ? void 0 : r.seed) ?? v.seed), o = We(s[0], s[1], s[2], s[3]);
3820
- return new Kt({
3874
+ return new qt({
3821
3875
  dtSec: (r == null ? void 0 : r.dtSec) ?? v.dtSec,
3822
3876
  maxIterations: (r == null ? void 0 : r.maxIterations) ?? v.maxIterations,
3823
3877
  rand: o,
@@ -3827,6 +3881,7 @@ const Oe = (r) => {
3827
3881
  edgeStiffness: (r == null ? void 0 : r.edgeStiffness) ?? v.edgeStiffness,
3828
3882
  effectiveDistance: (r == null ? void 0 : r.effectiveDistance) ?? v.effectiveDistance,
3829
3883
  convergenceDelta: (r == null ? void 0 : r.convergenceDelta) ?? v.convergenceDelta,
3884
+ convergenceVelocity: (r == null ? void 0 : r.convergenceVelocity) ?? v.convergenceVelocity,
3830
3885
  maxForce: (r == null ? void 0 : r.maxForce) ?? v.maxForce,
3831
3886
  nodeForceCoefficient: (r == null ? void 0 : r.nodeForceCoefficient) ?? v.nodeForceCoefficient,
3832
3887
  barnesHutTheta: ((e = r == null ? void 0 : r.barnesHut) == null ? void 0 : e.theta) ?? v.barnesHutTheta,
@@ -3835,8 +3890,8 @@ const Oe = (r) => {
3835
3890
  }
3836
3891
  }
3837
3892
  }, _t = (r) => ({
3838
- algorithm: qt(r == null ? void 0 : r.algorithm),
3839
- applyOn: Jt(r == null ? void 0 : r.applyOn)
3893
+ algorithm: Jt(r == null ? void 0 : r.algorithm),
3894
+ applyOn: Zt(r == null ? void 0 : r.applyOn)
3840
3895
  }), er = (r, e) => ({
3841
3896
  ...r,
3842
3897
  onNodeDragStarted: (t) => {
@@ -3873,13 +3928,13 @@ class or {
3873
3928
  i(this, "hasAnimatedLayout", !1);
3874
3929
  i(this, "hasLayout", !1);
3875
3930
  i(this, "boxRenderingTrigger", new j());
3876
- i(this, "graphStore", new xe());
3877
- i(this, "viewportStore", new Ze());
3878
- i(this, "graph", new Le(this.graphStore));
3879
- i(this, "viewport", new Re(this.viewportStore));
3931
+ i(this, "graphStore");
3932
+ i(this, "viewportStore");
3933
+ i(this, "graph");
3934
+ i(this, "viewport");
3880
3935
  i(this, "window", window);
3881
3936
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
3882
- this.element = e;
3937
+ this.element = e, this.viewportStore = new Qe(this.element), this.viewport = new Re(this.viewportStore), this.graphStore = new Ae(), this.graph = new Le(this.graphStore);
3883
3938
  }
3884
3939
  /**
3885
3940
  * specifies default values for graph entities
@@ -3949,19 +4004,7 @@ class or {
3949
4004
  if (this.used)
3950
4005
  throw new Ht("CanvasBuilder is a single use object");
3951
4006
  this.used = !0;
3952
- const e = new Dt(this.element);
3953
- let t = new me(
3954
- this.graphStore,
3955
- this.viewportStore,
3956
- e.main
3957
- );
3958
- this.virtualScrollConfig !== void 0 && (t = new je(
3959
- t,
3960
- this.graphStore,
3961
- this.boxRenderingTrigger,
3962
- zt(this.virtualScrollConfig)
3963
- )), t = new Ke(t, this.graphStore);
3964
- const s = Lt(this.canvasDefaults), o = new ve(
4007
+ const e = new Ct(this.element), t = this.createHtmlView(e.main), s = Lt(this.canvasDefaults), o = new ve(
3965
4008
  this.graph,
3966
4009
  this.viewport,
3967
4010
  this.graphStore,
@@ -3973,12 +4016,12 @@ class or {
3973
4016
  o,
3974
4017
  Bt(this.backgroundConfig),
3975
4018
  e.background
3976
- ), this.hasNodeResizeReactiveEdges && K.configure(o), this.hasDraggableNodes) {
4019
+ ), this.hasNodeResizeReactiveEdges && q.configure(o), this.hasDraggableNodes) {
3977
4020
  let a = Rt(this.dragConfig);
3978
4021
  this.hasAnimatedLayout && (a = er(
3979
4022
  a,
3980
4023
  this.animationStaticNodes
3981
- )), J.configure(
4024
+ )), Z.configure(
3982
4025
  o,
3983
4026
  e.main,
3984
4027
  this.window,
@@ -4012,13 +4055,13 @@ class or {
4012
4055
  a
4013
4056
  );
4014
4057
  }
4015
- this.virtualScrollConfig !== void 0 ? q.configure(
4058
+ this.virtualScrollConfig !== void 0 ? J.configure(
4016
4059
  o,
4017
4060
  e.main,
4018
4061
  this.window,
4019
4062
  ye(this.transformConfig),
4020
4063
  this.boxRenderingTrigger,
4021
- kt(this.virtualScrollConfig)
4064
+ zt(this.virtualScrollConfig)
4022
4065
  ) : this.hasTransformableViewport && H.configure(
4023
4066
  o,
4024
4067
  e.main,
@@ -4032,7 +4075,7 @@ class or {
4032
4075
  this.animationStaticNodes
4033
4076
  ), oe.configure(
4034
4077
  o,
4035
- Zt(this.animatedLayoutConfig),
4078
+ Qt(this.animatedLayoutConfig),
4036
4079
  this.animationStaticNodes,
4037
4080
  this.window
4038
4081
  ));
@@ -4041,6 +4084,19 @@ class or {
4041
4084
  };
4042
4085
  return o.onBeforeDestroy.subscribe(n), o;
4043
4086
  }
4087
+ createHtmlView(e) {
4088
+ let t = new me(
4089
+ this.graphStore,
4090
+ this.viewportStore,
4091
+ e
4092
+ );
4093
+ return this.virtualScrollConfig !== void 0 && (t = new je(
4094
+ t,
4095
+ this.graphStore,
4096
+ this.boxRenderingTrigger,
4097
+ kt(this.virtualScrollConfig)
4098
+ )), new qe(t, this.graphStore);
4099
+ }
4044
4100
  }
4045
4101
  export {
4046
4102
  ut as BezierEdgeShape,