@joint/core 4.0.1 → 4.0.2

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,4 +1,4 @@
1
- /*! JointJS v4.0.1 (2024-02-02) - JavaScript diagramming library
1
+ /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -13759,6 +13759,10 @@ var joint = (function (exports) {
13759
13759
  var ry2 = ry * ry;
13760
13760
 
13761
13761
  var k = ((large_arc_flag == sweep_flag) ? -1 : 1) * sqrt(abs(((rx2 * ry2) - (rx2 * y * y) - (ry2 * x * x)) / ((rx2 * y * y) + (ry2 * x * x))));
13762
+ if (!Number.isFinite(k)) {
13763
+ // Arc is a single point
13764
+ return [x1, y1, x2, y2, x2, y2];
13765
+ }
13762
13766
 
13763
13767
  var cx = ((k * rx * y) / ry) + ((x1 + x2) / 2);
13764
13768
  var cy = ((k * -ry * x) / rx) + ((y1 + y2) / 2);
@@ -17519,12 +17523,16 @@ var joint = (function (exports) {
17519
17523
  if (text === undefined) { text = attrs.text; }
17520
17524
  if (text !== undefined) {
17521
17525
  var breakTextFn = value.breakText || breakText;
17526
+ var computedStyles = getComputedStyle(node);
17527
+
17522
17528
  wrappedText = breakTextFn('' + text, size, {
17523
- 'font-weight': attrs['font-weight'],
17524
- 'font-size': attrs['font-size'],
17525
- 'font-family': attrs['font-family'],
17529
+ 'font-weight': computedStyles.fontWeight,
17530
+ 'font-family': computedStyles.fontFamily,
17531
+ 'text-transform': computedStyles.textTransform,
17532
+ 'font-size': computedStyles.fontSize,
17533
+ 'letter-spacing': computedStyles.letterSpacing,
17534
+ // The `line-height` attribute in SVG is JoinJS specific.
17526
17535
  'lineHeight': attrs['line-height'],
17527
- 'letter-spacing': attrs['letter-spacing']
17528
17536
  }, {
17529
17537
  // Provide an existing SVG Document here
17530
17538
  // instead of creating a temporary one over again.
@@ -27319,8 +27327,14 @@ var joint = (function (exports) {
27319
27327
  var ty = target.y0;
27320
27328
 
27321
27329
  if (tx === ax && ty < sy0) { return Directions$2.BOTTOM; }
27322
- if (tx < ax && ty < smy0) { return Directions$2.RIGHT; }
27323
- if (tx > ax && ty < smy0) { return Directions$2.LEFT; }
27330
+ if (tx < ax && ty < smy0) {
27331
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27332
+ return Directions$2.RIGHT;
27333
+ }
27334
+ if (tx > ax && ty < smy0) {
27335
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27336
+ return Directions$2.LEFT;
27337
+ }
27324
27338
  if (tx < smx0 && ty >= sy0) { return Directions$2.TOP; }
27325
27339
  if (tx > smx1 && ty >= sy0) { return Directions$2.TOP; }
27326
27340
  if (tx >= smx0 && tx <= ax && ty > sy1) {
@@ -27359,8 +27373,14 @@ var joint = (function (exports) {
27359
27373
  var ty = target.y0;
27360
27374
 
27361
27375
  if (tx === ax && ty > sy1) { return Directions$2.TOP; }
27362
- if (tx < ax && ty > smy1) { return Directions$2.RIGHT; }
27363
- if (tx > ax && ty > smy1) { return Directions$2.LEFT; }
27376
+ if (tx < ax && ty > smy1) {
27377
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27378
+ return Directions$2.RIGHT;
27379
+ }
27380
+ if (tx > ax && ty > smy1) {
27381
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27382
+ return Directions$2.LEFT;
27383
+ }
27364
27384
  if (tx < smx0 && ty <= sy1) { return Directions$2.BOTTOM; }
27365
27385
  if (tx > smx1 && ty <= sy1) { return Directions$2.BOTTOM; }
27366
27386
  if (tx >= smx0 && tx <= ax && ty < sy0) {
@@ -27571,11 +27591,12 @@ var joint = (function (exports) {
27571
27591
  return outsidePoint;
27572
27592
  }
27573
27593
 
27574
- function routeBetweenPoints(source, target) {
27594
+ function routeBetweenPoints(source, target, opt) {
27595
+ if ( opt === void 0 ) opt = {};
27596
+
27575
27597
  var sourcePoint = source.point;
27576
27598
  var sx0 = source.x0;
27577
27599
  var sy0 = source.y0;
27578
- var sourceView = source.view;
27579
27600
  var sourceWidth = source.width;
27580
27601
  var sourceHeight = source.height;
27581
27602
  var sourceMargin = source.margin;
@@ -27585,14 +27606,13 @@ var joint = (function (exports) {
27585
27606
  var targetWidth = target.width;
27586
27607
  var targetHeight = target.height;
27587
27608
  var targetMargin = target.margin;
27609
+ var targetInSourceBBox = opt.targetInSourceBBox; if ( targetInSourceBBox === void 0 ) targetInSourceBBox = false;
27588
27610
 
27589
27611
  var tx1 = tx0 + targetWidth;
27590
27612
  var ty1 = ty0 + targetHeight;
27591
27613
  var sx1 = sx0 + sourceWidth;
27592
27614
  var sy1 = sy0 + sourceHeight;
27593
27615
 
27594
- var isSourceEl = sourceView && sourceView.model.isElement();
27595
-
27596
27616
  // Key coordinates including the margin
27597
27617
  var smx0 = sx0 - sourceMargin;
27598
27618
  var smx1 = sx1 + sourceMargin;
@@ -27622,10 +27642,15 @@ var joint = (function (exports) {
27622
27642
  var middleOfVerticalSides = (scx < tcx ? (sx1 + tx0) : (tx1 + sx0)) / 2;
27623
27643
  var middleOfHorizontalSides = (scy < tcy ? (sy1 + ty0) : (ty1 + sy0)) / 2;
27624
27644
 
27645
+ var sourceBBox = new Rect(sx0, sy0, sourceWidth, sourceHeight);
27646
+ var targetBBox = new Rect(tx0, ty0, targetWidth, targetHeight);
27647
+ var inflatedSourceBBox = sourceBBox.clone().inflate(sourceMargin);
27648
+ var inflatedTargetBBox = targetBBox.clone().inflate(targetMargin);
27649
+
27625
27650
  if (sourceSide === 'left' && targetSide === 'right') {
27626
27651
  if (smx0 <= tmx1) {
27627
27652
  var y = middleOfHorizontalSides;
27628
- if (sx1 <= tx0) {
27653
+ if (sox <= tmx0) {
27629
27654
  if (ty1 >= smy0 && toy < soy) {
27630
27655
  y = Math.min(tmy0, smy0);
27631
27656
  } else if (ty0 <= smy1 && toy >= soy) {
@@ -27646,7 +27671,7 @@ var joint = (function (exports) {
27646
27671
  { x: x, y: toy }
27647
27672
  ];
27648
27673
  } else if (sourceSide === 'right' && targetSide === 'left') {
27649
- if (smx1 >= tmx0) {
27674
+ if (sox >= tmx0) {
27650
27675
  var y$1 = middleOfHorizontalSides;
27651
27676
  if (sox > tx1) {
27652
27677
  if (ty1 >= smy0 && toy < soy) {
@@ -27670,16 +27695,20 @@ var joint = (function (exports) {
27670
27695
  { x: x$1, y: toy }
27671
27696
  ];
27672
27697
  } else if (sourceSide === 'top' && targetSide === 'bottom') {
27698
+ var isPointInsideSource = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27699
+
27673
27700
  if (soy < toy) {
27674
27701
  var x$2 = middleOfVerticalSides;
27675
27702
  var y$2 = soy;
27676
27703
 
27677
- if (soy < ty0) {
27678
- if (tx1 >= smx0 && tox < sox) {
27679
- x$2 = Math.min(tmx0, smx0);
27680
- } else if (tx0 <= smx1 && tox >= sox) {
27681
- x$2 = Math.max(tmx1, smx1);
27682
- }
27704
+ if (isPointInsideSource) {
27705
+ y$2 = Math.min(y$2, tmy0);
27706
+ }
27707
+
27708
+ if (tx1 >= smx0 && tox < sox) {
27709
+ x$2 = Math.min(tmx0, smx0);
27710
+ } else if (tx0 <= smx1 && tox >= sox) {
27711
+ x$2 = Math.max(tmx1, smx1);
27683
27712
  }
27684
27713
 
27685
27714
  return [
@@ -27695,16 +27724,20 @@ var joint = (function (exports) {
27695
27724
  { x: tox, y: y$3 }
27696
27725
  ];
27697
27726
  } else if (sourceSide === 'bottom' && targetSide === 'top') {
27698
- if (soy - sourceMargin > toy) {
27727
+ var isPointInsideSource$1 = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27728
+
27729
+ if (soy > toy) {
27699
27730
  var x$3 = middleOfVerticalSides;
27700
27731
  var y$4 = soy;
27701
27732
 
27702
- if (soy > ty1) {
27703
- if (tx1 >= smx0 && tox < sox) {
27704
- x$3 = Math.min(tmx0, smx0);
27705
- } else if (tx0 <= smx1 && tox >= sox) {
27706
- x$3 = Math.max(tmx1, smx1);
27707
- }
27733
+ if (isPointInsideSource$1) {
27734
+ y$4 = Math.max(y$4, tmy1);
27735
+ }
27736
+
27737
+ if (tx1 >= smx0 && tox < sox) {
27738
+ x$3 = Math.min(tmx0, smx0);
27739
+ } else if (tx0 <= smx1 && tox >= sox) {
27740
+ x$3 = Math.max(tmx1, smx1);
27708
27741
  }
27709
27742
 
27710
27743
  return [
@@ -27720,28 +27753,31 @@ var joint = (function (exports) {
27720
27753
  { x: tox, y: y$5 }
27721
27754
  ];
27722
27755
  } else if (sourceSide === 'top' && targetSide === 'top') {
27756
+ var useUShapeConnection =
27757
+ targetInSourceBBox ||
27758
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27759
+ (soy <= ty0 && (inflatedSourceBBox.bottomRight().x <= tox || inflatedSourceBBox.bottomLeft().x >= tox)) ||
27760
+ (soy >= ty0 && (inflatedTargetBBox.bottomRight().x <= sox || inflatedTargetBBox.bottomLeft().x >= sox));
27761
+
27762
+ if (useUShapeConnection) {
27763
+ return [
27764
+ { x: sox, y: Math.min(soy, toy) },
27765
+ { x: tox, y: Math.min(soy, toy) }
27766
+ ];
27767
+ }
27768
+
27723
27769
  var x$4;
27724
27770
  var y1 = Math.min((sy1 + ty0) / 2, toy);
27725
27771
  var y2 = Math.min((sy0 + ty1) / 2, soy);
27726
27772
 
27727
27773
  if (toy < soy) {
27728
- if (sox >= tmx1 || sox <= tmx0) {
27729
- return [
27730
- { x: sox, y: Math.min(soy, toy) },
27731
- { x: tox, y: Math.min(soy, toy) }
27732
- ];
27733
- } else if (tox > sox) {
27774
+ if (tox > sox) {
27734
27775
  x$4 = Math.min(sox, tmx0);
27735
27776
  } else {
27736
27777
  x$4 = Math.max(sox, tmx1);
27737
27778
  }
27738
27779
  } else {
27739
- if (tox >= smx1 || tox <= smx0) {
27740
- return [
27741
- { x: sox, y: Math.min(soy, toy) },
27742
- { x: tox, y: Math.min(soy, toy) }
27743
- ];
27744
- } else if (tox >= sox) {
27780
+ if (tox >= sox) {
27745
27781
  x$4 = Math.max(tox, smx1);
27746
27782
  } else {
27747
27783
  x$4 = Math.min(tox, smx0);
@@ -27755,28 +27791,31 @@ var joint = (function (exports) {
27755
27791
  { x: tox, y: y1 }
27756
27792
  ];
27757
27793
  } else if (sourceSide === 'bottom' && targetSide === 'bottom') {
27794
+ var useUShapeConnection$1 =
27795
+ targetInSourceBBox ||
27796
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27797
+ (soy >= toy && (inflatedSourceBBox.topRight().x <= tox || inflatedSourceBBox.topLeft().x >= tox)) ||
27798
+ (soy <= toy && (inflatedTargetBBox.topRight().x <= sox || inflatedTargetBBox.topLeft().x >= sox));
27799
+
27800
+ if (useUShapeConnection$1) {
27801
+ return [
27802
+ { x: sox, y: Math.max(soy, toy) },
27803
+ { x: tox, y: Math.max(soy, toy) }
27804
+ ];
27805
+ }
27806
+
27758
27807
  var x$5;
27759
27808
  var y1$1 = Math.max((sy0 + ty1) / 2, toy);
27760
27809
  var y2$1 = Math.max((sy1 + ty0) / 2, soy);
27761
27810
 
27762
27811
  if (toy > soy) {
27763
- if (sox >= tmx1 || sox <= tmx0) {
27764
- return [
27765
- { x: sox, y: Math.max(soy, toy) },
27766
- { x: tox, y: Math.max(soy, toy) }
27767
- ];
27768
- } else if (tox > sox) {
27812
+ if (tox > sox) {
27769
27813
  x$5 = Math.min(sox, tmx0);
27770
27814
  } else {
27771
27815
  x$5 = Math.max(sox, tmx1);
27772
27816
  }
27773
27817
  } else {
27774
- if (tox >= smx1 || tox <= smx0) {
27775
- return [
27776
- { x: sox, y: Math.max(soy, toy) },
27777
- { x: tox, y: Math.max(soy, toy) }
27778
- ];
27779
- } else if (tox >= sox) {
27818
+ if (tox >= sox) {
27780
27819
  x$5 = Math.max(tox, smx1);
27781
27820
  } else {
27782
27821
  x$5 = Math.min(tox, smx0);
@@ -27790,6 +27829,19 @@ var joint = (function (exports) {
27790
27829
  { x: tox, y: y1$1 }
27791
27830
  ];
27792
27831
  } else if (sourceSide === 'left' && targetSide === 'left') {
27832
+ var useUShapeConnection$2 =
27833
+ targetInSourceBBox ||
27834
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27835
+ (sox <= tox && (inflatedSourceBBox.bottomRight().y <= toy || inflatedSourceBBox.topRight().y >= toy)) ||
27836
+ (sox >= tox && (inflatedTargetBBox.bottomRight().y <= soy || inflatedTargetBBox.topRight().y >= soy));
27837
+
27838
+ if (useUShapeConnection$2) {
27839
+ return [
27840
+ { x: Math.min(sox, tox), y: soy },
27841
+ { x: Math.min(sox, tox), y: toy }
27842
+ ];
27843
+ }
27844
+
27793
27845
  var y$6;
27794
27846
  var x1 = Math.min((sx1 + tx0) / 2, tox);
27795
27847
  var x2 = Math.min((sx0 + tx1) / 2, sox);
@@ -27815,11 +27867,24 @@ var joint = (function (exports) {
27815
27867
  { x: x1, y: toy }
27816
27868
  ];
27817
27869
  } else if (sourceSide === 'right' && targetSide === 'right') {
27870
+ var useUShapeConnection$3 =
27871
+ targetInSourceBBox ||
27872
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27873
+ (sox >= tox && (inflatedSourceBBox.bottomLeft().y <= toy || inflatedSourceBBox.topLeft().y >= toy)) ||
27874
+ (sox <= tox && (inflatedTargetBBox.bottomLeft().y <= soy || inflatedTargetBBox.topLeft().y >= soy));
27875
+
27876
+ if (useUShapeConnection$3) {
27877
+ return [
27878
+ { x: Math.max(sox, tox), y: soy },
27879
+ { x: Math.max(sox, tox), y: toy }
27880
+ ];
27881
+ }
27882
+
27818
27883
  var y$7;
27819
27884
  var x1$1 = Math.max((sx0 + tx1) / 2, tox);
27820
27885
  var x2$1 = Math.max((sx1 + tx0) / 2, sox);
27821
27886
 
27822
- if (tox < sox) {
27887
+ if (tox <= sox) {
27823
27888
  if (toy <= soy) {
27824
27889
  y$7 = Math.min(smy0, toy);
27825
27890
  } else {
@@ -27840,16 +27905,44 @@ var joint = (function (exports) {
27840
27905
  { x: x1$1, y: toy }
27841
27906
  ];
27842
27907
  } else if (sourceSide === 'top' && targetSide === 'right') {
27843
- if (soy > toy) {
27908
+ var isPointInsideSource$2 = inflatedSourceBBox.containsPoint(targetPoint);
27909
+
27910
+ // The target point is inside the source element
27911
+ if (isPointInsideSource$2) {
27912
+ if (sox <= tmx1) {
27913
+ var x$6 = Math.max(sox + sourceMargin, tox);
27914
+ var y$8 = Math.min(smy0, tmy0);
27915
+
27916
+ // Target anchor is on the right side of the source anchor
27917
+ return [
27918
+ { x: sox, y: y$8 },
27919
+ { x: x$6, y: y$8 },
27920
+ { x: x$6, y: toy }
27921
+ ];
27922
+ }
27923
+
27924
+ // Target anchor is on the left side of the source anchor
27925
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
27926
+ var anchorMiddleX = (sox - sourceMargin + tox) / 2;
27927
+
27928
+ return [
27929
+ { x: sox, y: soy },
27930
+ { x: anchorMiddleX, y: soy },
27931
+ { x: anchorMiddleX, y: toy }
27932
+ ];
27933
+ }
27934
+
27935
+ if (smy0 > toy) {
27844
27936
  if (sox < tox) {
27845
- var y$8 = middleOfHorizontalSides;
27937
+ var y$9 = tmy0;
27846
27938
 
27847
- if ((y$8 > tcy || !isSourceEl) && y$8 < tmy1 && sox < tx0) {
27848
- y$8 = tmy0;
27939
+ if (tmy1 <= smy0 && tmx1 >= sox) {
27940
+ y$9 = middleOfHorizontalSides;
27849
27941
  }
27942
+
27850
27943
  return [
27851
- { x: sox, y: y$8 },
27852
- { x: tox, y: y$8 },
27944
+ { x: sox, y: y$9 },
27945
+ { x: tox, y: y$9 },
27853
27946
  { x: tox, y: toy }
27854
27947
  ];
27855
27948
  }
@@ -27857,273 +27950,523 @@ var joint = (function (exports) {
27857
27950
  return [{ x: sox, y: toy }];
27858
27951
  }
27859
27952
 
27860
- var x$6 = Math.max(middleOfVerticalSides, tmx1);
27953
+ var x$7 = Math.max(middleOfVerticalSides, tmx1);
27861
27954
 
27862
- if (tox < sox && toy > sy0 && toy < sy1) {
27955
+ if (sox > tox && sy1 >= toy) {
27863
27956
  return [
27864
27957
  { x: sox, y: soy },
27865
- { x: x$6, y: soy },
27866
- { x: x$6, y: toy }
27958
+ { x: x$7, y: soy },
27959
+ { x: x$7, y: toy }
27867
27960
  ];
27868
27961
  }
27869
27962
 
27870
- if ((x$6 > smx0 && toy > sy0) || tx0 > sx1) {
27871
- var y$9 = Math.min(sy0 - sourceMargin, ty0 - targetMargin);
27872
- var x$7 = Math.max(sx1 + sourceMargin, tx1 + targetMargin);
27963
+ if (x$7 > smx0 && soy < ty1) {
27964
+ var y$10 = Math.min(smy0, tmy0);
27965
+ var x$8 = Math.max(smx1, tmx1);
27873
27966
  return [
27874
- { x: sox, y: y$9 },
27875
- { x: x$7, y: y$9 },
27876
- { x: x$7, y: toy }
27967
+ { x: sox, y: y$10 },
27968
+ { x: x$8, y: y$10 },
27969
+ { x: x$8, y: toy }
27877
27970
  ];
27878
27971
  }
27879
27972
 
27880
27973
  return [
27881
27974
  { x: sox, y: soy },
27882
- { x: Math.max(x$6, tox), y: soy },
27883
- { x: Math.max(x$6, tox), y: toy }
27975
+ { x: x$7, y: soy },
27976
+ { x: x$7, y: toy }
27884
27977
  ];
27885
27978
  } else if (sourceSide === 'top' && targetSide === 'left') {
27886
- if (soy > toy) {
27979
+ var isPointInsideSource$3 = inflatedSourceBBox.containsPoint(targetPoint);
27980
+
27981
+ // The target point is inside the source element
27982
+ if (isPointInsideSource$3) {
27983
+ if (sox >= tmx0) {
27984
+ var x$9 = Math.min(sox - sourceMargin, tox);
27985
+ var y$11 = Math.min(smy0, tmy0);
27986
+
27987
+ // Target anchor is on the left side of the source anchor
27988
+ return [
27989
+ { x: sox, y: y$11 },
27990
+ { x: x$9, y: y$11 },
27991
+ { x: x$9, y: toy }
27992
+ ];
27993
+ }
27994
+
27995
+ // Target anchor is on the right side of the source anchor
27996
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
27997
+ var anchorMiddleX$1 = (sox + sourceMargin + tox) / 2;
27998
+
27999
+ return [
28000
+ { x: sox, y: soy },
28001
+ { x: anchorMiddleX$1, y: soy },
28002
+ { x: anchorMiddleX$1, y: toy }
28003
+ ];
28004
+ }
28005
+
28006
+ if (smy0 > toy) {
27887
28007
  if (sox > tox) {
27888
- var y$10 = middleOfHorizontalSides;
28008
+ var y$12 = tmy0;
27889
28009
 
27890
- if ((y$10 > tcy || !isSourceEl) && y$10 < tmy1 && sox > tx1) {
27891
- y$10 = tmy0;
28010
+ if (tmy1 <= smy0 && tmx0 <= sox) {
28011
+ y$12 = middleOfHorizontalSides;
27892
28012
  }
28013
+
27893
28014
  return [
27894
- { x: sox, y: y$10 },
27895
- { x: tox, y: y$10 },
28015
+ { x: sox, y: y$12 },
28016
+ { x: tox, y: y$12 },
27896
28017
  { x: tox, y: toy }
27897
28018
  ];
27898
28019
  }
28020
+
27899
28021
  return [{ x: sox, y: toy }];
27900
28022
  }
27901
28023
 
27902
- var x$8 = Math.min(tmx0, middleOfVerticalSides);
28024
+ var x$10 = Math.min(tmx0, middleOfVerticalSides);
27903
28025
 
27904
28026
  if (sox < tox && sy1 >= toy) {
27905
28027
  return [
27906
28028
  { x: sox, y: soy },
27907
- { x: x$8, y: soy },
27908
- { x: x$8, y: toy }];
28029
+ { x: x$10, y: soy },
28030
+ { x: x$10, y: toy }];
27909
28031
  }
27910
28032
 
27911
- if (x$8 < smx1 && soy < ty1) {
27912
- var y$11 = Math.min(smy0, tmy0);
27913
- var x$9 = Math.min(smx0, tmx0);
28033
+ if (x$10 < smx1 && soy < ty1) {
28034
+ var y$13 = Math.min(smy0, tmy0);
28035
+ var x$11 = Math.min(smx0, tmx0);
27914
28036
  return [
27915
- { x: sox, y: y$11 },
27916
- { x: x$9, y: y$11 },
27917
- { x: x$9, y: toy }
28037
+ { x: sox, y: y$13 },
28038
+ { x: x$11, y: y$13 },
28039
+ { x: x$11, y: toy }
27918
28040
  ];
27919
28041
  }
28042
+
27920
28043
  return [
27921
28044
  { x: sox, y: soy },
27922
- { x: x$8, y: soy },
27923
- { x: x$8, y: toy }
28045
+ { x: x$10, y: soy },
28046
+ { x: x$10, y: toy }
27924
28047
  ];
27925
28048
  } else if (sourceSide === 'bottom' && targetSide === 'right') {
27926
- if (soy < toy) {
28049
+ var isPointInsideSource$4 = inflatedSourceBBox.containsPoint(targetPoint);
28050
+
28051
+ // The target point is inside the source element
28052
+ if (isPointInsideSource$4) {
28053
+ if (sox <= tmx1) {
28054
+ var x$12 = Math.max(sox + sourceMargin, tox);
28055
+ var y$14 = Math.max(smy1, tmy1);
28056
+
28057
+ // Target anchor is on the right side of the source anchor
28058
+ return [
28059
+ { x: sox, y: y$14 },
28060
+ { x: x$12, y: y$14 },
28061
+ { x: x$12, y: toy }
28062
+ ];
28063
+ }
28064
+
28065
+ // Target anchor is on the left side of the source anchor
28066
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
28067
+ var anchorMiddleX$2 = (sox - sourceMargin + tox) / 2;
28068
+
28069
+ return [
28070
+ { x: sox, y: soy },
28071
+ { x: anchorMiddleX$2, y: soy },
28072
+ { x: anchorMiddleX$2, y: toy }
28073
+ ];
28074
+ }
28075
+
28076
+ if (smy1 < toy) {
27927
28077
  if (sox < tox) {
27928
- var y$12 = middleOfHorizontalSides;
28078
+ var y$15 = tmy1;
27929
28079
 
27930
- if ((y$12 < tcy || !isSourceEl) && y$12 > tmy0 && sox < tx0) {
27931
- y$12 = tmy1;
28080
+ if (tmy0 >= smy1 && tmx1 >= sox) {
28081
+ y$15 = middleOfHorizontalSides;
27932
28082
  }
28083
+
27933
28084
  return [
27934
- { x: sox, y: y$12 },
27935
- { x: tox, y: y$12 },
28085
+ { x: sox, y: y$15 },
28086
+ { x: tox, y: y$15 },
27936
28087
  { x: tox, y: toy }
27937
28088
  ];
27938
28089
  }
28090
+
27939
28091
  return [{ x: sox, y: toy }];
27940
- } else {
27941
- if (sx0 < tox) {
27942
- var y$13 = Math.max(smy1, tmy1);
27943
- var x$10 = Math.max(smx1, tmx1);
27944
- return [
27945
- { x: sox, y: y$13 },
27946
- { x: x$10, y: y$13 },
27947
- { x: x$10, y: toy }
27948
- ];
27949
- }
27950
28092
  }
27951
28093
 
27952
- var x$11 = middleOfVerticalSides;
28094
+ var x$13 = Math.max(middleOfVerticalSides, tmx1);
28095
+
28096
+ if (sox > tox && sy0 <= toy) {
28097
+ return [
28098
+ { x: sox, y: soy },
28099
+ { x: x$13, y: soy },
28100
+ { x: x$13, y: toy }
28101
+ ];
28102
+ }
28103
+
28104
+ if (x$13 > smx0 && soy > ty0) {
28105
+ var y$16 = Math.max(smy1, tmy1);
28106
+ var x$14 = Math.max(smx1, tmx1);
28107
+ return [
28108
+ { x: sox, y: y$16 },
28109
+ { x: x$14, y: y$16 },
28110
+ { x: x$14, y: toy }
28111
+ ];
28112
+ }
27953
28113
 
27954
28114
  return [
27955
28115
  { x: sox, y: soy },
27956
- { x: x$11, y: soy },
27957
- { x: x$11, y: toy }
28116
+ { x: x$13, y: soy },
28117
+ { x: x$13, y: toy }
27958
28118
  ];
27959
28119
  } else if (sourceSide === 'bottom' && targetSide === 'left') {
27960
- if (soy < toy) {
28120
+ var isPointInsideSource$5 = inflatedSourceBBox.containsPoint(targetPoint);
28121
+
28122
+ // The target point is inside the source element
28123
+ if (isPointInsideSource$5) {
28124
+ if (sox >= tmx0) {
28125
+ var x$15 = Math.min(sox - sourceMargin, tox);
28126
+ var y$17 = Math.max(smy1, tmy1);
28127
+
28128
+ // Target anchor is on the left side of the source anchor
28129
+ return [
28130
+ { x: sox, y: y$17 },
28131
+ { x: x$15, y: y$17 },
28132
+ { x: x$15, y: toy }
28133
+ ];
28134
+ }
28135
+
28136
+ // Target anchor is on the right side of the source anchor
28137
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
28138
+ var anchorMiddleX$3 = (sox + sourceMargin + tox) / 2;
28139
+
28140
+ return [
28141
+ { x: sox, y: soy },
28142
+ { x: anchorMiddleX$3, y: soy },
28143
+ { x: anchorMiddleX$3, y: toy }
28144
+ ];
28145
+ }
28146
+
28147
+ if (smy1 < toy) {
27961
28148
  if (sox > tox) {
27962
- var y$14 = middleOfHorizontalSides;
28149
+ var y$18 = tmy1;
27963
28150
 
27964
- if ((y$14 < tcy || !isSourceEl) && y$14 > tmy0 && sox > tx1) {
27965
- y$14 = tmy1;
28151
+ if (tmy0 >= smy1 && tmx0 <= sox) {
28152
+ y$18 = middleOfHorizontalSides;
27966
28153
  }
28154
+
27967
28155
  return [
27968
- { x: sox, y: y$14 },
27969
- { x: tox, y: y$14 },
28156
+ { x: sox, y: y$18 },
28157
+ { x: tox, y: y$18 },
27970
28158
  { x: tox, y: toy }
27971
28159
  ];
27972
28160
  }
28161
+
27973
28162
  return [{ x: sox, y: toy }];
27974
- } else {
27975
- if (sx1 > tox) {
27976
- var y$15 = Math.max(smy1, tmy1);
27977
- var x$12 = Math.min(smx0, tmx0);
27978
- return [
27979
- { x: sox, y: y$15 },
27980
- { x: x$12, y: y$15 },
27981
- { x: x$12, y: toy }
27982
- ];
27983
- }
27984
28163
  }
27985
28164
 
27986
- var x$13 = middleOfVerticalSides;
28165
+ var x$16 = Math.min(tmx0, middleOfVerticalSides);
28166
+
28167
+ if (sox < tox && sy0 <= toy) {
28168
+ return [
28169
+ { x: sox, y: soy },
28170
+ { x: x$16, y: soy },
28171
+ { x: x$16, y: toy }
28172
+ ];
28173
+ }
28174
+
28175
+ if (x$16 < smx1 && soy > ty0) {
28176
+ var y$19 = Math.max(smy1, tmy1);
28177
+ var x$17 = Math.min(smx0, tmx0);
28178
+ return [
28179
+ { x: sox, y: y$19 },
28180
+ { x: x$17, y: y$19 },
28181
+ { x: x$17, y: toy }
28182
+ ];
28183
+ }
27987
28184
 
27988
28185
  return [
27989
28186
  { x: sox, y: soy },
27990
- { x: x$13, y: soy },
27991
- { x: x$13, y: toy }
28187
+ { x: x$16, y: soy },
28188
+ { x: x$16, y: toy }
27992
28189
  ];
27993
- }
27994
- else if (sourceSide === 'left' && targetSide === 'bottom') {
27995
- if (sox >= tox && soy >= tmy1) {
27996
- return [{ x: tox, y: soy }];
27997
- }
28190
+ } else if (sourceSide === 'left' && targetSide === 'bottom') {
28191
+ var isPointInsideSource$6 = inflatedSourceBBox.containsPoint(targetPoint);
28192
+
28193
+ // The target point is inside the source element
28194
+ if (isPointInsideSource$6) {
28195
+ if (soy <= tmy1) {
28196
+ var x$18 = Math.min(smx0, tmx0);
28197
+ var y$20 = Math.max(soy + sourceMargin, toy);
28198
+
28199
+ return [
28200
+ { x: x$18, y: soy },
28201
+ { x: x$18, y: y$20 },
28202
+ { x: tox, y: y$20 }
28203
+ ];
28204
+ }
27998
28205
 
27999
- if (sox >= tx1 && soy < toy) {
28000
- var x$14 = middleOfVerticalSides;
28206
+ // Target anchor is above the source anchor
28207
+ var anchorMiddleY = (soy - sourceMargin + toy) / 2;
28001
28208
 
28002
28209
  return [
28003
- { x: x$14, y: soy },
28004
- { x: x$14, y: toy },
28005
- { x: tox, y: toy }
28210
+ { x: sox, y: soy },
28211
+ { x: sox, y: anchorMiddleY },
28212
+ { x: tox, y: anchorMiddleY }
28006
28213
  ];
28007
28214
  }
28008
28215
 
28009
- if (tox < sx1 && ty1 <= sy0) {
28010
- var y$16 = middleOfHorizontalSides;
28216
+ if (smx0 > tox) {
28217
+ if (soy < toy) {
28218
+ var x$19 = tmx0;
28219
+
28220
+ if (tmx1 <= smx0 && tmy1 >= soy) {
28221
+ x$19 = middleOfVerticalSides;
28222
+ }
28223
+
28224
+ return [
28225
+ { x: x$19, y: soy },
28226
+ { x: x$19, y: toy },
28227
+ { x: tox, y: toy }
28228
+ ];
28229
+ }
28230
+
28231
+ return [{ x: tox, y: soy }];
28232
+ }
28233
+
28234
+ var y$21 = Math.max(tmy1, middleOfHorizontalSides);
28011
28235
 
28236
+ if (soy > toy && sx1 >= tox) {
28012
28237
  return [
28013
28238
  { x: sox, y: soy },
28014
- { x: sox, y: y$16 },
28015
- { x: tox, y: y$16 }
28239
+ { x: sox, y: y$21 },
28240
+ { x: tox, y: y$21 }
28016
28241
  ];
28017
28242
  }
28018
28243
 
28019
- var x$15 = Math.min(tmx0, sox);
28020
- var y$17 = Math.max(smy1, tmy1);
28244
+ if (y$21 > smy0 && sox < tx1) {
28245
+ var x$20 = Math.min(smx0, tmx0);
28246
+ var y$22 = Math.max(smy1, tmy1);
28247
+
28248
+ return [
28249
+ { x: x$20, y: soy },
28250
+ { x: x$20, y: y$22 },
28251
+ { x: tox, y: y$22 }
28252
+ ];
28253
+ }
28021
28254
 
28022
28255
  return [
28023
- { x: x$15, y: soy },
28024
- { x: x$15, y: y$17 },
28025
- { x: tox, y: y$17 }
28256
+ { x: sox, y: soy },
28257
+ { x: sox, y: y$21 },
28258
+ { x: tox, y: y$21 }
28026
28259
  ];
28027
28260
  } else if (sourceSide === 'left' && targetSide === 'top') {
28028
- if (sox > tox && soy < tmy0) {
28029
- return [{ x: tox, y: soy }];
28261
+ var isPointInsideSource$7 = inflatedSourceBBox.containsPoint(targetPoint);
28262
+
28263
+ // The target point is inside the source element
28264
+ if (isPointInsideSource$7) {
28265
+ if (soy >= tmy0) {
28266
+ var y$23 = Math.min(soy - sourceMargin, toy);
28267
+ var x$21 = Math.min(smx0, tmx0);
28268
+
28269
+ // Target anchor is on the top side of the source anchor
28270
+ return [
28271
+ { x: x$21, y: soy },
28272
+ { x: x$21, y: y$23 },
28273
+ { x: tox, y: y$23 }
28274
+ ];
28275
+ }
28276
+
28277
+ // Target anchor is below the source anchor
28278
+ // Add the `sourceMargin` since the source anchor is above the target anchor
28279
+ var anchorMiddleY$1 = (soy + sourceMargin + toy) / 2;
28280
+
28281
+ return [
28282
+ { x: sox, y: soy },
28283
+ { x: sox, y: anchorMiddleY$1 },
28284
+ { x: tox, y: anchorMiddleY$1 }
28285
+ ];
28030
28286
  }
28031
28287
 
28032
- if (sox >= tx1) {
28288
+ if (smx0 > tox) {
28033
28289
  if (soy > toy) {
28034
- var x$16 = middleOfVerticalSides;
28290
+ var x$22 = tmx0;
28291
+
28292
+ if (tmx1 <= smx0 && tmy0 <= soy) {
28293
+ x$22 = middleOfVerticalSides;
28294
+ }
28035
28295
 
28036
28296
  return [
28037
- { x: x$16, y: soy },
28038
- { x: x$16, y: toy },
28297
+ { x: x$22, y: soy },
28298
+ { x: x$22, y: toy },
28039
28299
  { x: tox, y: toy }
28040
28300
  ];
28041
28301
  }
28302
+
28303
+ return [{ x: tox, y: soy }];
28042
28304
  }
28043
28305
 
28044
- if (tox <= sx1 && toy > soy) {
28045
- var y$18 = middleOfHorizontalSides;
28306
+ var y$24 = Math.min(tmy0, middleOfHorizontalSides);
28046
28307
 
28308
+ if (soy < toy && sx1 >= tox) {
28047
28309
  return [
28048
28310
  { x: sox, y: soy },
28049
- { x: sox, y: y$18 },
28050
- { x: tox, y: y$18 } ];
28311
+ { x: sox, y: y$24 },
28312
+ { x: tox, y: y$24 }];
28051
28313
  }
28052
28314
 
28053
- var x$17 = toy < soy ? Math.min(smx0, tmx0) : smx0;
28054
- var y$19 = Math.min(smy0, tmy0);
28315
+ if (y$24 < smy1 && sox < tx1) {
28316
+ var x$23 = Math.min(smx0, tmx0);
28317
+ var y$25 = Math.min(smy0, tmy0);
28318
+ return [
28319
+ { x: x$23, y: soy },
28320
+ { x: x$23, y: y$25 },
28321
+ { x: tox, y: y$25 }
28322
+ ];
28323
+ }
28055
28324
 
28056
28325
  return [
28057
- { x: x$17, y: soy },
28058
- { x: x$17, y: y$19 },
28059
- { x: tox, y: y$19 }
28326
+ { x: sox, y: soy },
28327
+ { x: sox, y: y$24 },
28328
+ { x: tox, y: y$24 }
28060
28329
  ];
28061
-
28062
28330
  } else if (sourceSide === 'right' && targetSide === 'top') {
28063
- if (sox <= tox && soy < tmy0) {
28064
- return [{ x: tox, y: soy }];
28065
- }
28331
+ var isPointInsideSource$8 = inflatedSourceBBox.containsPoint(targetPoint);
28332
+
28333
+ // The target point is inside the source element
28334
+ if (isPointInsideSource$8) {
28335
+ if (soy >= tmy0) {
28336
+ var x$24 = Math.max(smx1, tmx1);
28337
+ var y$26 = Math.min(soy - sourceMargin, toy);
28338
+
28339
+ // Target anchor is on the top side of the source anchor
28340
+ return [
28341
+ { x: x$24, y: soy },
28342
+ { x: x$24, y: y$26 }, // Path adjustment for right side start
28343
+ { x: tox, y: y$26 }
28344
+ ];
28345
+ }
28066
28346
 
28067
- if (sx1 < tx0 && soy > toy) {
28068
- var x$18 = middleOfVerticalSides;
28347
+ // Target anchor is below the source anchor
28348
+ // Adjust sourceMargin calculation since the source anchor is now on the right
28349
+ var anchorMiddleY$2 = (soy + sourceMargin + toy) / 2;
28069
28350
 
28070
28351
  return [
28071
- { x: x$18, y: soy },
28072
- { x: x$18, y: toy },
28073
- { x: tox, y: toy }
28352
+ { x: sox, y: soy },
28353
+ { x: sox, y: anchorMiddleY$2 },
28354
+ { x: tox, y: anchorMiddleY$2 }
28074
28355
  ];
28075
28356
  }
28076
28357
 
28077
- if (tox < sox && ty0 > sy1) {
28078
- var y$20 = middleOfHorizontalSides;
28358
+ if (smx1 < tox) {
28359
+ if (soy > toy) {
28360
+ var x$25 = tmx1;
28361
+
28362
+ if (tmx0 >= smx1 && tmy0 <= soy) {
28363
+ x$25 = middleOfVerticalSides;
28364
+ }
28365
+
28366
+ return [
28367
+ { x: x$25, y: soy },
28368
+ { x: x$25, y: toy },
28369
+ { x: tox, y: toy }
28370
+ ];
28371
+ }
28372
+
28373
+ return [{ x: tox, y: soy }];
28374
+ }
28375
+
28376
+ var y$27 = Math.min(tmy0, middleOfHorizontalSides);
28079
28377
 
28378
+ if (soy < toy && sx0 <= tox) {
28080
28379
  return [
28081
28380
  { x: sox, y: soy },
28082
- { x: sox, y: y$20 },
28083
- { x: tox, y: y$20 }
28084
- ];
28381
+ { x: sox, y: y$27 },
28382
+ { x: tox, y: y$27 }];
28085
28383
  }
28086
28384
 
28087
- var x$19 = Math.max(smx1, tmx1);
28088
- var y$21 = Math.min(smy0, tmy0);
28385
+ if (y$27 < smy1 && sox > tx0) {
28386
+ var x$26 = Math.max(smx1, tmx1);
28387
+ var y$28 = Math.min(smy0, tmy0);
28388
+
28389
+ return [
28390
+ { x: x$26, y: soy },
28391
+ { x: x$26, y: y$28 },
28392
+ { x: tox, y: y$28 }
28393
+ ];
28394
+ }
28089
28395
 
28090
28396
  return [
28091
- { x: x$19, y: soy },
28092
- { x: x$19, y: y$21 },
28093
- { x: tox, y: y$21 }
28397
+ { x: sox, y: soy },
28398
+ { x: sox, y: y$27 },
28399
+ { x: tox, y: y$27 }
28094
28400
  ];
28095
28401
  } else if (sourceSide === 'right' && targetSide === 'bottom') {
28096
- if (sox <= tox && soy >= tmy1) {
28097
- return [{ x: tox, y: soy }];
28098
- }
28402
+ var isPointInsideSource$9 = inflatedSourceBBox.containsPoint(targetPoint);
28403
+
28404
+ // The target point is inside the source element
28405
+ if (isPointInsideSource$9) {
28406
+ if (soy <= tmy1) {
28407
+ var x$27 = Math.max(smx1, tmx1);
28408
+ var y$29 = Math.max(soy + sourceMargin, toy);
28409
+
28410
+ return [
28411
+ { x: x$27, y: soy },
28412
+ { x: x$27, y: y$29 },
28413
+ { x: tox, y: y$29 }
28414
+ ];
28415
+ }
28099
28416
 
28100
- if (sox <= tmx0 && soy < toy) {
28101
- var x$20 = middleOfVerticalSides;
28417
+ // Target anchor is above the source anchor
28418
+ var anchorMiddleY$3 = (soy - sourceMargin + toy) / 2;
28102
28419
 
28103
28420
  return [
28104
- { x: x$20, y: soy },
28105
- { x: x$20, y: toy },
28106
- { x: tox, y: toy }
28421
+ { x: sox, y: soy },
28422
+ { x: sox, y: anchorMiddleY$3 },
28423
+ { x: tox, y: anchorMiddleY$3 }
28107
28424
  ];
28108
28425
  }
28109
28426
 
28110
- if (tox > sx0 && ty1 < sy0) {
28111
- var y$22 = middleOfHorizontalSides;
28427
+ if (smx1 < tox) {
28428
+ if (soy < toy) {
28429
+ var x$28 = tmx1;
28430
+
28431
+ if (tmx0 >= smx1 && tmy1 >= soy) {
28432
+ x$28 = middleOfVerticalSides;
28433
+ }
28434
+
28435
+ return [
28436
+ { x: x$28, y: soy },
28437
+ { x: x$28, y: toy },
28438
+ { x: tox, y: toy }
28439
+ ];
28440
+ }
28441
+
28442
+ return [{ x: tox, y: soy }];
28443
+ }
28444
+
28445
+ var y$30 = Math.max(tmy1, middleOfHorizontalSides);
28112
28446
 
28447
+ if (soy > toy && sx0 <= tox) {
28113
28448
  return [
28114
28449
  { x: sox, y: soy },
28115
- { x: sox, y: y$22 },
28116
- { x: tox, y: y$22 }
28450
+ { x: sox, y: y$30 },
28451
+ { x: tox, y: y$30 }
28117
28452
  ];
28118
28453
  }
28119
28454
 
28120
- var x$21 = Math.max(tmx1, sox);
28121
- var y$23 = Math.max(smy1, tmy1);
28455
+ if (y$30 > smy0 && sox > tx0) {
28456
+ var x$29 = Math.max(smx1, tmx1);
28457
+ var y$31 = Math.max(smy1, tmy1);
28458
+
28459
+ return [
28460
+ { x: x$29, y: soy },
28461
+ { x: x$29, y: y$31 },
28462
+ { x: tox, y: y$31 }
28463
+ ];
28464
+ }
28122
28465
 
28123
28466
  return [
28124
- { x: x$21, y: soy },
28125
- { x: x$21, y: y$23 },
28126
- { x: tox, y: y$23 }
28467
+ { x: sox, y: soy },
28468
+ { x: sox, y: y$30 },
28469
+ { x: tox, y: y$30 }
28127
28470
  ];
28128
28471
  }
28129
28472
  }
@@ -28159,7 +28502,7 @@ var joint = (function (exports) {
28159
28502
  dummySource.direction = fromDirection;
28160
28503
  firstVertex.direction = toDirection;
28161
28504
 
28162
- resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex).concat( [firstVertex.point] ));
28505
+ resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex, { targetInSourceBBox: true }).concat( [firstVertex.point] ));
28163
28506
  } else {
28164
28507
  // The first point responsible for the initial direction of the route
28165
28508
  var next = verticesData[1] || targetPoint;
@@ -34823,6 +35166,8 @@ var joint = (function (exports) {
34823
35166
  },
34824
35167
 
34825
35168
  _resetUpdates: function() {
35169
+ if (this._updates && this._updates.id) { cancelFrame(this._updates.id); }
35170
+
34826
35171
  return this._updates = {
34827
35172
  id: null,
34828
35173
  priorities: [{}, {}, {}],
@@ -39576,7 +39921,7 @@ var joint = (function (exports) {
39576
39921
  Control: Control
39577
39922
  });
39578
39923
 
39579
- var version = "4.0.1";
39924
+ var version = "4.0.2";
39580
39925
 
39581
39926
  var Vectorizer = V;
39582
39927
  var layout = { PortLabel: PortLabel, Port: Port };