k?-1:1)*n+r,z=m*(x-r)+q);this.Bk();this.ke(f);this.Hf(u,y);this.Hf(x,z);this.ke(p);this.Wc(0,this.getLinkPoint(a,b,g,!0,!1,d,e));this.Wc(3,this.getLinkPoint(d,e,c,!1,!1,a,b))}else if(f=d,p=e,d=this.getLinkPoint(a,b,g,!0,!1,f,p),e=this.getLinkPoint(f,p,c,!1,!1,a,b),this.hasCurviness())p=e.x-d.x,c=e.y-d.y,g=this.computeCurviness(),a=d.x+p/2,b=d.y+c/2,f=a,h=b,K.B(c,0)?h=0g&&(f=-f),f=(0>c?-1:1)*f+a,h=p*(f-a)+b),this.ke(d),this.Hf(f,h),this.ke(e);else{this.ke(d);this.ke(e);h=L.alloc();b.xj(h);k=h.ca(e);p.xj(h);l=h.ca(d);if(k||l)g=b.ja(Np(g),new J),this.Wc(0,this.getLinkPointFromPoint(a,b,g,e,!0,g)),c=p.ja(Np(c),new J),this.Wc(1,this.getLinkPointFromPoint(f,p,c,d,!1,c));L.free(h)}}else{n=this.isAvoiding;p&&(m&&n||l)&&this.Bk();var B=l?this.computeCurviness():0;n=this.getLinkPoint(a,b,g,!0,m,d,e);r=u=q=0;if(m||!h||l)y=this.computeEndSegmentLength(a,b,g,!0),r=
+this.getLinkDirection(a,b,n,g,!0,m,d,e),l&&(h||g.A(c)||!m&&1===g.x+c.x&&1===g.y+c.y)&&(r-=m?90:30,0>B&&(r-=180)),0>r?r+=360:360<=r&&(r-=360),l&&(y+=Math.abs(B)*(m?1:2)),0===r?q=y:90===r?u=y:180===r?q=-y:270===r?u=-y:(q=y*Math.cos(r*Math.PI/180),u=y*Math.sin(r*Math.PI/180)),g.Sb()&&l&&(y=b.ja(Kc,J.alloc()),x=J.allocAt(y.x+1E3*q,y.y+1E3*u),this.getLinkPointFromPoint(a,b,y,x,!0,n),J.free(y),J.free(x));y=this.getLinkPoint(d,e,c,!1,m,a,b);var D=z=x=0;if(m||!k||l){var G=this.computeEndSegmentLength(d,e,
+c,!1);D=this.getLinkDirection(d,e,y,c,!1,m,a,b);l&&(k||g.A(c)||!m&&1===g.x+c.x&&1===g.y+c.y)&&(D+=m?0:30,0>B&&(D+=180));0>D?D+=360:360<=D&&(D-=360);l&&(G+=Math.abs(B)*(m?1:2));0===D?x=G:90===D?z=G:180===D?x=-G:270===D?z=-G:(x=G*Math.cos(D*Math.PI/180),z=G*Math.sin(D*Math.PI/180));c.Sb()&&l&&(c=e.ja(Kc,J.alloc()),g=J.allocAt(c.x+1E3*x,c.y+1E3*z),this.getLinkPointFromPoint(d,e,c,g,!1,y),J.free(c),J.free(g))}c=n;if(m||!h||l)c=new J(n.x+q,n.y+u);g=y;if(m||!k||l)g=new J(y.x+x,y.y+z);!p&&!m&&h&&3Math.abs(b.y-a.y)?(b.x>=a.x?b.x=a.x+9E9:b.x=a.x-9E9,b.y=a.y):(b.y>=a.y?b.y=a.y+9E9:b.y=a.y-9E9,b.x=a.x);return b}
+S.prototype.getLinkPointFromPoint=function(a,b,c,d,e,f){void 0===f&&(f=new J);if(null===a||null===b)return f.assign(c),f;a.isVisible()||(e=a.findVisibleNode(),null!==e&&e!==a&&(b=e.port));a=null;e=b.panel;null===e||e.pe()||(e=e.panel);if(null===e){e=d.x;d=d.y;var g=c.x;c=c.y}else{a=e.Md;e=1/(a.m11*a.m22-a.m12*a.m21);g=a.m22*e;var h=-a.m12*e,k=-a.m21*e,l=a.m11*e,m=e*(a.m21*a.dy-a.m22*a.dx),n=e*(a.m12*a.dx-a.m11*a.dy);e=d.x*g+d.y*k+m;d=d.x*h+d.y*l+n;g=c.x*g+c.y*k+m;c=c.x*h+c.y*l+n}b.Lk(e,d,g,c,f);null!==
+a&&f.transform(a);return f};function Pp(a,b){var c=b.Lp;null===c&&(c=new Qp,c.port=b,c.node=b.part,b.Lp=c);return Rp(c,a)}
+S.prototype.getLinkPoint=function(a,b,c,d,e,f,g,h){void 0===h&&(h=new J);if(c.eb()&&!Mp(c))return b.ja(c,h),h;if(c.Uc()){var k=Pp(this,b);if(null!==k){h.assign(k.dr);if(e&&this.routing===Sp){var l=Pp(this,g);if(null!==l&&k.Km=m.y&&a.y<=m.y+m.height?h.y=a.y:(c.Qf(Pc)||c.Qf(Tc))&&a.x>=m.x&&a.x<=m.x+m.width&&(h.x=a.x);J.free(k);J.free(l)}}return h}}c=
+b.ja(Np(c),J.alloc());this.pointsCount>(e?6:2)?(g=d?this.i(1):this.i(this.pointsCount-2),e&&(g=Op(c,g.copy()))):(k=this.computeSpot(!d,g),f=J.alloc(),g=g.ja(Np(k),f),e&&(g=Op(c,g)),J.free(f));this.getLinkPointFromPoint(a,b,c,g,d,h);J.free(c);return h};
+S.prototype.getLinkDirection=function(a,b,c,d,e,f,g,h){a:if(d.eb())var k=d.x>d.y?d.x>1-d.y?0:d.x<1-d.y?270:315:d.x1-d.y?90:d.x<1-d.y?180:135:.5>d.x?225:.5(f?6:2)?(h=e?this.i(1):this.i(this.pointsCount-2),h=f?Op(k,h.copy()):c):(c=J.alloc(),h=h.ja(Kc,c),J.free(c));c=Math.abs(h.x-k.x)>Math.abs(h.y-k.y)?h.x>=
+k.x?0:180:h.y>=k.y?90:270;J.free(k);k=c}d.Sb()&&g.Qd(a)&&(k+=180,360<=k&&(k-=360));if(Mp(d))return k;a=b.wj();if(0===a)return k;45<=a&&135>a?k+=90:135<=a&&225>a?k+=180:225<=a&&315>a&&(k+=270);360<=k&&(k-=360);return k};S.prototype.computeEndSegmentLength=function(a,b,c,d){if(null!==b&&c.Uc()&&(a=Pp(this,b),null!==a))return a.dw;a=d?this.fromEndSegmentLength:this.toEndSegmentLength;null!==b&&isNaN(a)&&(a=d?b.fromEndSegmentLength:b.toEndSegmentLength);isNaN(a)&&(a=10);return a};
+S.prototype.computeSpot=function(a,b){void 0===b&&(b=null);a?(a=b?b:this.fromPort,null===a?a=Kc:(b=this.fromSpot,b.Ib()&&(b=a.fromSpot),a=b===fd?Bc:b)):(a=b?b:this.toPort,null===a?a=Kc:(b=this.toSpot,b.Ib()&&(b=a.toSpot),a=b===fd?Bc:b));return a};function Mp(a){return a===Bc||.5===a.x&&.5===a.y}function Np(a){return.5===a.x&&.5===a.y?a:Kc}
+S.prototype.computeOtherPoint=function(a,b){if(this.computeAdjusting()!==ng&&4p.width||n.y>p.height||0>n.x+n.width||0>n.y+n.height)){n=Gb.alloc();n.set(g);
+if(m instanceof W)h=m.Lf(a,b,c,d,e,n);else if(this.path===m){if(m instanceof Uf)if(h=a,p=d,!1===m.pickable)h=!1;else if(n.multiply(m.transform),p)b:{var r=h,q=n;if(m.Uh(r,q))h=!0;else{if(void 0===q&&(q=m.transform,r.Te(m.actualBounds))){h=!0;break b}h=r.left;p=r.right;var u=r.top;r=r.bottom;var y=J.alloc(),x=J.alloc(),z=J.alloc(),B=Gb.alloc();B.set(q);B.xw(m.transform);B.eu();x.x=p;x.y=u;x.transform(B);y.x=h;y.y=u;y.transform(B);q=!1;Tn(m,y,x,z)?q=!0:(y.x=p,y.y=r,y.transform(B),Tn(m,y,x,z)?q=!0:(x.x=
+h,x.y=r,x.transform(B),Tn(m,y,x,z)?q=!0:(y.x=h,y.y=u,y.transform(B),Tn(m,y,x,z)&&(q=!0))));Gb.free(B);J.free(y);J.free(x);J.free(z);h=q}}else h=m.Uh(h,n)}else h=El(m,a,d,n);h&&(p=m,null!==b&&(p=b(m)),p&&(null===c||c(p))&&e.add(p));Gb.free(n)}}}void 0===f&&Gb.free(g);return h||null!==this.background||null!==this.areaBackground}void 0===f&&Gb.free(g);return!1};
+S.prototype.computeCurve=function(){if(null===this.gg){var a=this.fromPort,b=this.isOrthogonal;this.gg=null!==a&&a===this.toPort&&!b}return this.gg?qg:this.curve};S.prototype.computeCorner=function(){if(this.curve===qg)return 0;var a=this.corner;if(isNaN(a)||0>a)a=10;return a};
+S.prototype.findMidLabel=function(){for(var a=this.path,b=this.$.j,c=b.length,d=0;dk?-Math.PI/2:Math.PI/2;else m=Math.atan(k/Math.abs(h)),0>h&&(m=Math.PI-m);g=b.x;var n=b.y;h=d.x-g;var p=d.y-n;k=Math.sqrt(h*h+p*p);K.da(h,0)?p=0>p?-Math.PI/2:Math.PI/2:(p=Math.atan(p/Math.abs(h)),0>h&&(p=Math.PI-p));
+l=k/l;m=p-m;this.Wc(a,b);for(a+=1;ak?-Math.PI/2:Math.PI/2:(k=Math.atan(k/Math.abs(h)),0>h&&(k=Math.PI-k)),h=k+m,b*=l,this.O(a,g+b*Math.cos(h),n+b*Math.sin(h)));this.Wc(c,d)}}return!0;case Dp:f=this.i(a);n=this.i(c);if(!f.Wa(b)||!n.Wa(d)){e=f.x;f=f.y;g=n.x;n=n.y;l=(g-e)*(g-e)+(n-f)*(n-f);h=b.x;m=b.y;k=d.x;p=d.y;var r=1;if(0!==k-h){var q=(p-m)/(k-h);r=Math.sqrt(1+1/(q*q))}else q=9E9;this.Wc(a,b);for(a+=1;ab?b+=360:360<=b&&(b-=360);0>d?d+=360:360<=d&&(d-=360);var g=d;b=315<=b||45>b?0:45<=b&&135>b?90:135<=b&&225>b?180:270;d=315<=d||45>d?0:45<=d&&135>d?90:135<=d&&225>d?180:270;var h=e.actualBounds.copy(),k=f.actualBounds.copy();if(h.o()&&k.o()){h.Pc(Vp,Vp);k.Pc(Vp,Vp);h.af(a);k.af(c);if(0===b)if(c.x>a.x||270===d&&c.ya.x||90===d&&c.y>a.y&&k.right>a.x){var l=new J(c.x,a.y);var m=new J(c.x,(a.y+c.y)/2);180===d?(l.x=this.computeMidOrthoPosition(a.x,
+a.y,c.x,c.y,!1),m.x=l.x,m.y=c.y):270===d&&c.ya.y?(l.x=a.xk.bottom)?this.computeMidOrthoPosition(a.x,a.y,c.x,c.y,!1):k.right,m.x=l.x,m.y=c.y):0===d&&a.xk.top&&a.yh.bottom)180===d&&(k.ca(a)||
+h.ca(c))?l.y=this.computeMidOrthoPosition(a.x,a.y,c.x,c.y,!0):c.ya.y&&(180===d||270===d)&&(l.y=this.computeMidOrthoPosition(a.x,h.bottom,c.x,Math.min(c.y,k.top),!0)),m.x=c.x,m.y=l.y;if(l.y>h.top&&l.y=h.left&&c.x<=a.x||a.x<=k.right&&a.x>=c.x){if(90===d||270===d)l=new J(Math.max((a.x+c.x)/2,a.x),a.y),m=new J(l.x,c.y)}else l.y=270===d||(0===d||180===d)&&c.ya.y&&k.lefta.y?(l.x=a.x>k.right?this.computeMidOrthoPosition(a.x,a.y,k.right,c.y,!1):a.x>k.left&&(270===d&&a.y