@syncfusion/ej2-diagrams
Version:
Feature-rich diagram control to create diagrams like flow charts, organizational charts, mind maps, and BPMN diagrams. Its rich feature set includes built-in shapes, editing, serializing, exporting, printing, overview, data binding, and automatic layouts.
10 lines • 1.55 MB
JavaScript
/*!
* filename: ej2-diagrams.min.js
* version : 30.1.42
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
this.ej=this.ej||{},this.ej.diagrams=function(t,e,i,r,n){"use strict";function o(t){var e,i=[],r=a(t);if(r.length>0)for(var n=0;n<r.length;n++){var o=r[parseInt(n.toString(),10)],s="";switch((s=o[0]).toLowerCase()){case"m":for(e=1;e<o.length;e++)i.push({command:s,x:o[parseInt(e.toString(),10)],y:o[e+1]}),e+=1,"m"===s?s="l":"M"===s&&(s="L");break;case"l":case"t":for(e=1;e<o.length;e++)i.push({command:s,x:o[parseInt(e.toString(),10)],y:o[e+1]}),e+=1;break;case"h":for(e=1;e<o.length;e++)i.push({command:s,x:o[parseInt(e.toString(),10)]});break;case"v":for(e=1;e<o.length;e++)i.push({command:s,y:o[parseInt(e.toString(),10)]});break;case"z":i.push({command:s});break;case"c":for(e=1;e<o.length;e++)i.push({command:s,x1:o[parseInt(e.toString(),10)],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]}),e+=5;break;case"s":for(e=1;e<o.length;e++)i.push({command:s,x2:o[parseInt(e.toString(),10)],y2:o[e+1],x:o[e+2],y:o[e+3]}),e+=3;break;case"q":for(e=1;e<o.length;e++)i.push({command:s,x1:o[parseInt(e.toString(),10)],y1:o[e+1],x:o[e+2],y:o[e+3]}),e+=3;break;case"a":for(e=1;e<o.length;e++)i.push({command:s,r1:o[parseInt(e.toString(),10)],r2:o[e+1],angle:o[e+2],largeArc:o[e+3],sweep:o[e+4],x:o[e+5],y:o[e+6]}),e+=6}}return i}function a(t){var e=/([a-z]+)|([+-]?(?:\d+\.?\d*|\.\d+))/gi,i=[],r=[],n={};e.lastIndex=0;var o=!1;for(n=e.exec(t);n;)"e"===n[1]?o=!0:n[1]?("zm"===n[1].toLowerCase()?(i.length&&r.push(i),r.push(["Z"]),i=[n[1].substring(1,2)]):(i.length&&r.push(i),i=[n[1]]),o=!1):(i.length||(i=[]),o||i.push(Number(n[2])),o=!1),n=e.exec(t);return i.length&&r.push(i),r}function s(t,e,i){var r,n,o="",a=[{x:0+t,y:0},{x:0+i-t,y:0},{x:0+i,y:0+t},{x:0+i,y:0+e-t},{x:0+i-t,y:0+e},{x:0+t,y:0+e},{x:0,y:0+e-t},{x:0,y:0+t}],s=[{x:0+i,y:0},{x:0+i,y:0+e},{x:0,y:0+e},{x:0,y:0}],h=0;o="M"+a[0].x+" "+a[0].y;var d;for(d=0;d<a.length;d+=2)o+="L"+(r=a[d+1]).x+" "+r.y,n=a[d+2]||a[0],o+="Q"+s[parseInt(h.toString(),10)].x+" "+s[parseInt(h.toString(),10)].y+" "+n.x+" "+n.y,h++;return o}function h(t){var e,i="";i="M"+t[0].x+" "+t[0].y;var r;for(r=1;r<t.length;r++)i+="L"+(e=t[parseInt(r.toString(),10)]).x+" "+e.y;return i+="Z"}function d(t){var e;for(e=0;e<t.length;e++)t[parseInt(e.toString(),10)].x=Math.round(t[parseInt(e.toString(),10)].x),t[parseInt(e.toString(),10)].y=Math.round(t[parseInt(e.toString(),10)].y);var i,r="";r="M"+t[0].x+" "+t[0].y;var n;for(n=1;n<t.length;n++)r+="L"+(i=t[parseInt(n.toString(),10)]).x+" "+i.y;return r}function l(t){var e,i,r,n,o,a,s,h,d,l,c=[];for(s=0,h=0,l=0,d=t.length;l<d;++l){var p=t[l],g="";g=p.command,"y1"in p&&(n=p.y1),"y2"in p&&(a=p.y2),"x1"in p&&(r=p.x1),"x2"in p&&(o=p.x2),"x"in p&&(s=p.x),"y"in p&&(h=p.y);var u=c[c.length-1];switch(g){case"M":c.push({command:"M",x:s,y:h});break;case"L":c.push({command:"L",x0:e,y0:i,x:s,y:h});break;case"H":c.push({command:"L",x0:e,y0:i,x:s,y:i});break;case"V":c.push({command:"L",x0:e,y0:i,x:e,y:h});break;case"C":c.push({command:"C",x0:e,y0:i,x1:r,y1:n,x2:o,y2:a,x:s,y:h});break;case"S":if(u){var f=void 0,m={x:2*e-(f="C"===u.command||"S"===u.command?{x:u.x2,y:u.y2}:{x:e,y:i}).x,y:2*i-f.y};c.push({command:"C",x0:e,y0:i,x1:m.x,y1:m.y,x2:o,y2:a,x:s,y:h})}break;case"Q":c.push({command:"Q",x0:e,y0:i,x1:r,y1:n,x:s,y:h});break;case"T":if(u){var f=void 0,m={x:2*e-(f="Q"===u.command?{x:u.x1,y:u.y1}:{x:e,y:i}).x,y:2*i-f.y};c.push({command:"Q",x0:e,y0:i,x1:m.x,y1:m.y,x:s,y:h})}break;case"A":var y=p;y.command="A",c.push(y);break;case"Z":case"z":c.push({command:"Z"}),s=e,h=i}e=s,i=h}return c}function c(t,e,i,r,n,o,a,s){var h,d,l,c,u,m,y,v,b;for(u=0,m=0,v=0,y=t.length;v<y;++v){var S=t[v],w=S.command;"x"in S&&(u=S.x),"y"in S&&(m=S.y),"y1"in S&&(d=S.y1),"y2"in S&&(c=S.y2),"x1"in S&&(h=S.x1),"x2"in S&&(l=S.x2),r?(void 0!==u&&(u=g(u,e,n,a)),void 0!==m&&(m=g(m,i,o,s)),void 0!==h&&(h=g(h,e,n,a)),void 0!==d&&(d=g(d,i,o,s)),void 0!==l&&(l=g(l,e,n,a)),void 0!==c&&(c=g(c,i,o,s))):(void 0!==u&&(u=Number((u+e).toFixed(2))),void 0!==m&&(m=Number((m+i).toFixed(2))),void 0!==h&&(h=Number((h+e).toFixed(2))),void 0!==d&&(d=Number((d+i).toFixed(2))),void 0!==l&&(l=Number((l+e).toFixed(2))),void 0!==c&&(c=Number((c+i).toFixed(2)))),(b=p(S,w,{x:u,y:m,x1:h,y1:d,x2:l,y2:c,r1:S.r1,r2:S.r2},r,e,i))&&(t[v]=b)}return f(t)}function p(t,e,i,r,n,o){switch(e){case"M":case"L":t.x=i.x,t.y=i.y;break;case"H":t.x=i.x;break;case"V":t.y=i.y;break;case"C":t.x=i.x,t.y=i.y,t.x1=i.x1,t.y1=i.y1,t.x2=i.x2,t.y2=i.y2;break;case"S":t.x=i.x,t.y=i.y,t.x2=i.x2,t.y2=i.y2;break;case"Q":t.x=i.x,t.y=i.y,t.x1=i.x1,t.y1=i.y1;break;case"T":t.x=i.x,t.y=i.y;break;case"A":var a=i.r1,s=i.r2;r&&(i.r1=a*=n,i.r2=s*=o),t.x=i.x,t.y=i.y,t.r1=i.r1,t.r2=i.r2;break;case"z":case"Z":t={command:"Z"}}return t}function g(t,e,i,r){return t!==i?t=r!==i?t*e-(Number(i)*e-Number(i))+(r-Number(i)):Number(t)*e-(Number(i)*e-Number(i)):r!==i&&(t=r),Number(t.toFixed(2))}function u(t){var e,i,r,n,o,a,s,h,d,l;for(s=0,h=0,l=0,d=t.length;l<d;++l){var c=t[parseInt(l.toString(),10)],p=c.command;if(/[MLHVCSQTA]/.test(p))"x"in c&&(c.x=s=c.x),"y"in c&&(c.y=h=c.y);else{"x1"in c&&(c.x1=r=s+c.x1),"x2"in c&&(c.x2=o=s+c.x2),"y1"in c&&(c.y1=n=h+c.y1),"y2"in c&&(c.y2=a=h+c.y2),"x"in c&&(c.x=s+=c.x),"y"in c&&(c.y=h+=c.y);var g=void 0;switch(p){case"m":case"M":g={command:"M",x:s,y:h};break;case"l":case"L":g={command:"L",x:s,y:h};break;case"h":case"H":g={command:"H",x:s};break;case"v":case"V":g={command:"V",y:h};break;case"c":case"C":g={command:"C",x:s,y:h,x1:r,y1:n,x2:o,y2:a};break;case"s":case"S":g={command:"S",x:s,y:h,x2:o,y2:a};break;case"q":case"Q":g={command:"Q",x:s,y:h,x1:r,y1:n};break;case"t":case"T":g={command:"T",x:s,y:h};break;case"a":case"A":(g={command:"A",x:s,y:h}).r1=c.r1,g.r2=c.r2,g.angle=c.angle,g.largeArc=c.largeArc,g.sweep=c.sweep;break;case"z":case"Z":g={command:"Z"},s=e,h=i,g=t[parseInt(l.toString(),10)]}g&&(t[parseInt(l.toString(),10)]=g)}"M"!==p&&"m"!==p||(e=s,i=h)}return t}function f(t){var e,i="";for(e=0;e<t.length;e++)i+=0===e?m(t[parseInt(e.toString(),10)]):" "+m(t[parseInt(e.toString(),10)]);return i}function m(t){var e="";switch(t.command){case"Z":case"z":e=t.command;break;case"M":case"m":case"L":case"l":e=t.command+" "+t.x+" "+t.y;break;case"C":case"c":e=t.command+" "+t.x1+" "+t.y1+" "+t.x2+" "+t.y2+" "+t.x+" "+t.y;break;case"Q":case"q":e=t.command+" "+t.x1+" "+t.y1+" "+t.x+" "+t.y;break;case"A":case"a":var i=t.command,r=t.angle,n=t.largeArc?"1":"0",o=t.sweep?"1":"0";e=i+" "+t.r1+" "+t.r2+" "+r+" "+n+" "+o+" "+t.x+" "+t.y;break;case"H":case"h":e=t.command+" "+t.x;break;case"V":case"v":e=t.command+" "+t.y;break;case"S":case"s":e=t.command+" "+t.x2+" "+t.y2+" "+t.x+" "+t.y;break;case"T":case"t":e=t.command+" "+t.x+" "+t.y}return e}function y(){return new ys(1,0,0,1,0,0,t.MatrixTypes.Identity)}function v(t,e){var i=P(t,e.x,e.y);return{x:Math.round(100*i.x)/100,y:Math.round(100*i.y)/100}}function b(t,e){for(var i=[],r=0,n=e;r<n.length;r++){var o=n[r];i.push(v(t,o))}return i}function S(t,e,i,r){D(t,C(.017453292519943295*(e%=360),i||0,r||0))}function w(t,e,i,r,n){void 0===r&&(r=0),void 0===n&&(n=0),D(t,I(e,i,r,n))}function x(e,i,r){e.offsetX+=i,e.offsetY+=r,e.type|=t.MatrixTypes.Translation}function I(e,i,r,n){var o=y();return o.type=r||n?t.MatrixTypes.Scaling|t.MatrixTypes.Translation:t.MatrixTypes.Scaling,A(o,e,0,0,i,r-e*r,n-i*n),o}function C(e,i,r){var n=y(),o=Math.sin(e),a=Math.cos(e),s=i*(1-a)+r*o,h=r*(1-a)-i*o;return n.type=t.MatrixTypes.Unknown,A(n,a,o,-o,a,s,h),n}function P(e,i,r){switch(e.type){case t.MatrixTypes.Translation|t.MatrixTypes.Scaling:i*=e.m11,i+=e.offsetX,r*=e.m22,r+=e.offsetY;break;default:var n=r*e.m21+e.offsetX,o=i*e.m12+e.offsetY;i*=e.m11,i+=n,r*=e.m22,r+=o}return{x:i,y:r}}function D(e,i){var r=e.type,n=i.type;if(r===t.MatrixTypes.Identity)return T(e,i),void(e.type=i.type);if(r!==t.MatrixTypes.Translation){var o=r<<4|n;switch(o){case 50:return e.m11*=i.m11,e.m22*=i.m22,e.offsetX*=i.m11,void(e.offsetY*=i.m22);case 51:return e.m11*=i.m11,e.m22*=i.m22,e.offsetX=i.m11*e.offsetX+i.offsetX,void(e.offsetY=i.m22*e.offsetY+i.offsetY);case 52:break;default:switch(o){case 66:case 67:case 68:break;default:return}}var a=y();return A(a,e.m11*i.m11+e.m12*i.m21,e.m11*i.m12+e.m12*i.m22,e.m21*i.m11+e.m22*i.m21,e.m21*i.m12+e.m22*i.m22,e.offsetX*i.m11+e.offsetY*i.m21+i.offsetX,e.offsetX*i.m12+e.offsetY*i.m22+i.offsetY),a.m21||a.m12?a.type=t.MatrixTypes.Unknown:((a.m11&&1!==a.m11||a.m22&&1!==a.m22)&&(a.type=t.MatrixTypes.Scaling),(a.offsetX||a.offsetY)&&(a.type|=t.MatrixTypes.Translation),(a.type&(t.MatrixTypes.Translation|t.MatrixTypes.Scaling))===t.MatrixTypes.Identity&&(a.type=t.MatrixTypes.Identity),a.type=t.MatrixTypes.Scaling|t.MatrixTypes.Translation),T(e,a),void(e.type=a.type)}var s=e.offsetX,h=e.offsetY;if(e.offsetX=s*i.m11+h*i.m21+i.offsetX,e.offsetY=s*i.m12+h*i.m22+i.offsetY,n===t.MatrixTypes.Unknown)return void(e.type=t.MatrixTypes.Unknown);e.type=t.MatrixTypes.Translation|t.MatrixTypes.Scaling}function A(t,e,i,r,n,o,a){t.m11=e,t.m12=i,t.m21=r,t.m22=n,t.offsetX=o,t.offsetY=a}function T(t,e){t.m11=e.m11,t.m12=e.m12,t.m21=e.m21,t.m22=e.m22,t.offsetX=e.offsetX,t.offsetY=e.offsetY,t.type=e.type}function O(){for(var t,e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",i="",r=0;r<5;r++){if("undefined"!=typeof window&&"crypto"in window&&"getRandomValues"in crypto){var n=new Uint16Array(1);t=(window.msCrypto||window.crypto).getRandomValues(n)[0]%(e.length-1)}else t=Math.floor(Math.random()*e.length);0===r&&t<10?r--:i+=e.substring(t,t+1)}return i}function M(t,e){if(t.nodes&&t.nodes.length>0)for(i=0;i<t.nodes.length;i++)if(t.nodes[parseInt(i.toString(),10)].id===e)return i;if(t.connectors&&t.connectors.length>0)for(var i=0;i<t.connectors.length;i++)if(t.connectors[parseInt(i.toString(),10)].id===e)return i;return null}function E(t){if(t)try{return"function"!=typeof t&&document.querySelectorAll(t).length?e.compile(document.querySelector(t).innerHTML.trim()):e.compile(t)}catch(i){return e.compile(t)}}function L(t){new ms;var e=t.offsetY-t.actualSize.height*t.pivot.y,i=t.offsetY+t.actualSize.height*(1-t.pivot.y),r=t.offsetX-t.actualSize.width*t.pivot.x,n=t.offsetX+t.actualSize.width*(1-t.pivot.x),o={x:r,y:e},a={x:n,y:e},s={x:r,y:i},h={x:n,y:i};return ms.toBounds([o,a,s,h])}function z(t){var e=new ms,i=L(t),r=i.middleLeft,n=i.topCenter,o=i.bottomCenter,a=i.middleRight,s=i.topLeft,h=i.topRight,d=i.bottomLeft,l=i.bottomRight;if(t.corners={topLeft:s,topCenter:n,topRight:h,middleLeft:r,middleRight:a,bottomLeft:d,bottomCenter:o,bottomRight:l},0!==t.rotateAngle||0!==t.parentTransform){var c=y();S(c,t.rotateAngle+t.parentTransform,t.offsetX,t.offsetY),t.corners.topLeft=s=v(c,s),t.corners.topCenter=n=v(c,n),t.corners.topRight=h=v(c,h),t.corners.middleLeft=r=v(c,r),t.corners.middleRight=a=v(c,a),t.corners.bottomLeft=d=v(c,d),t.corners.bottomCenter=o=v(c,o),t.corners.bottomRight=l=v(c,l)}return e=ms.toBounds([s,h,d,l]),t.corners.left=e.left,t.corners.right=e.right,t.corners.top=e.top,t.corners.bottom=e.bottom,t.corners.center=e.center,t.corners.width=e.width,t.corners.height=e.height,e}function k(t,e,i,r){var n={},o="properties";if(t){i=t.propName;var a=t[""+o]||t,s=[],h=[];if((s=s.concat(Object.keys(a))).push("version"),i){var d=Z(e);h=d?d(i):[],s=s.concat(h)}for(var l=B(i),c=0,p=s=s.concat(l);c<p.length;c++){var g=p[c];"historyManager"!==g&&("wrapper"!==g?!(!t[""+g]||!t.hasOwnProperty("observers"))||(t[""+g]instanceof Array?n[""+g]=N(-1===l.indexOf(g)&&t[""+o]?t[""+o][""+g]:t[""+g],e,g):t[""+g]instanceof Array==!1&&t[""+g]instanceof HTMLElement?n[""+g]=t[""+g].cloneNode(!0).innerHTML:t[""+g]instanceof Array==!1&&t[""+g]instanceof Object?n[""+g]=k(-1===l.indexOf(g)&&t[""+o]?t[""+o][""+g]:t[""+g],void 0,void 0):n[""+g]=t[""+g]):t[""+g]&&(n[""+g]={actualSize:{width:t[""+g].actualSize.width,height:t[""+g].actualSize.height},offsetX:t[""+g].offsetX,offsetY:t[""+g].offsetY}))}}return n}function B(t){switch(t){case"nodes":case"children":return["inEdges","outEdges","parentId","processId","nodeId","umlIndex","isPhase","isLane"];case"connectors":return["parentId"];case"annotation":case"annotations":return["nodeId"];case"shape":return["hasHeader"];case"layers":return["objectZIndex"]}return[]}function N(t,e,i,r){var n;if(t){n=[];for(var o=0;o<t.length;o++)t[parseInt(o.toString(),10)]instanceof Array?n.push(t[parseInt(o.toString(),10)]):t[parseInt(o.toString(),10)]instanceof Object?n.push(k(t[parseInt(o.toString(),10)],e,i)):n.push(t[parseInt(o.toString(),10)])}return n}function R(t,e){if(t){e||(e={properties:{}});for(var i=0,r=Object.keys(t);i<r.length;i++){var n=r[i];if(t[""+n]instanceof Array){var o=j(t[""+n],e.properties[""+n]);e.properties[""+n]&&e.properties[""+n].length||(e[""+n]=o)}else if(t[""+n]instanceof Array==!1&&t[""+n]instanceof HTMLElement)e[""+n]=t[""+n].cloneNode(!0).innerHtml;else if(t[""+n]instanceof Array==!1&&t[""+n]instanceof Object){var a=R(t[""+n],e.properties[""+n]);a.properties&&!Object.keys(a.properties).length&&delete a.properties,e[""+n]=a}else e[""+n]=void 0!==e.properties[""+n]?e[""+n]:t[""+n]}}return e}function j(t,e){var i=[],r=!1;e||(e=[]),e.length||(r=!0);for(var n=0;n<t.length;n++)if(t[parseInt(n.toString(),10)]instanceof Array){j(t[parseInt(n.toString(),10)],e[parseInt(n.toString(),10)]);r&&i.push(j)}else if(t[parseInt(n.toString(),10)]instanceof Object){var o=R(t[parseInt(n.toString(),10)],e[parseInt(n.toString(),10)]);r&&i.push(o)}else i.push(t[parseInt(n.toString(),10)]);return i}function H(t){var e="";switch(t){case"Center":e="center";break;case"Left":e="left";break;case"Right":e="right";break;case"Justify":e="justify"}return e}function W(t){var e="";switch(t){case"Wrap":e="breakall";break;case"NoWrap":e="keepall";break;case"WrapWithOverflow":e="normal";break;case"LineThrough":e="line-through"}return e}function _(t,e){return vs.font=(e.bold?"bold":"normal")+" "+e.fontSize+"px "+e.fontFamily,vs.measureText(t).width}function F(t,e){return(t+e)/2}function Y(t,e){var i=0,r=0,n=0,o=0,a="";r=t.length;var s=0;do{o>0&&(i=n),n=Math.floor(F(i,r)),o=_(a+=t.substr(i,n),e)}while(o<=e.width);for(a=a.substr(0,i),s=i;s<r;s++)if(a+=t[parseInt(s.toString(),10)],(o=_(a,e))>=e.width){t=t.substr(0,a.length-1);break}return"Ellipsis"===e.textOverflow?(t=t.substr(0,t.length-3),t+="..."):t=t.substr(0,t.length),t}function X(t,e){if("NoWrap"===e&&"PreserveAll"===t)return"pre";var i="";switch(t){case"CollapseAll":i="nowrap";break;case"CollapseSpace":i="pre-line";break;case"PreserveAll":i="pre-wrap"}return i}function U(t,e){var i=y();S(i,e,0,0);var r=v(i,{x:0,y:0}),n=v(i,{x:t.width,y:0}),o=v(i,{x:0,y:t.height}),a=v(i,{x:t.width,y:t.height}),s=Math.min(r.x,n.x,o.x,a.x),h=Math.min(r.y,n.y,o.y,a.y),d=Math.max(r.x,n.x,o.x,a.x),l=Math.max(r.y,n.y,o.y,a.y);return new ps(d-s,l-h)}function V(t,e,i,r){if(0!==t){var n=y();return S(n,t,e,i),v(n,r)}return r}function G(t,e){return{x:t.x+e.desiredSize.width*e.pivot.x,y:t.y+e.desiredSize.height*e.pivot.y}}function Z(t){return void 0!==t&&"string"==typeof t&&(t=e.getValue(t,window)),t}function q(t){return Us[t.toString()]}function K(t){var e=new i.Tooltip;e=tt(t.tooltip,e);var r=new i.Tooltip(e);return r.beforeCollision=J,r.beforeOpen=Q,r.cssClass="e-diagram-tooltip",r.opensOn="custom",r.appendTo("#"+t.element.id),r.close(),r}function Q(t){""!==this.content&&void 0!==this.content||(t.element.style.display="none")}function J(t){t.collidedPosition&&t.collidedPosition!==this.position&&(t.element.style.display="none")}function $(t,e){var i=t.tooltipObject;return tt(e?e.tooltip:t.tooltip,i),i}function tt(t,i){if(t.content){if(i.content=t.content,"string"==typeof t.content){var r=function(){return t.content};i.content=e.initializeCSPTemplate(r)}i.position=t.position,i.showTipPointer=t.showTipPointer,i.width=t.width,i.height=t.height,t.animation?i.animation=t.animation:i.animation={close:{effect:"None"}}}else i.close();return i}function et(t){return hh[t.toString()]}function it(t,e){return"Custom"===t?e.pathData:dh[""+t]}function rt(t){return lh[""+t]}function nt(t){return ch[""+t]}function ot(t){var e;switch(t.shape){case"Minus":e="M0,50 L100,50";break;case"Plus":e="M0,-50 L0,50 M-50,0 L50,0";break;case"ArrowUp":e="M0,100 L50,0 L100,100 Z";break;case"ArrowDown":e="M0,0 L50,100 L100,0 Z";break;case"Path":e=t.pathData}return e}function at(t){return ph[t.toString()]}function st(t,e,i){var r,n=lt(t,r="Straight"!==t.type&&t.sourceWrapper?t.sourceWrapper.corners.center:ht(t),t.targetPoint,e,i);return Vt(t,n[0],!1),Vt(t,n[n.length-1],!0),n}function ht(t){var e;if(t.sourcePortWrapper){var i=t.sourcePortWrapper;e={x:i.offsetX,y:i.offsetY}}else if(t.sourceID&&t.sourceWrapper)if(t.targetWrapper){var r=t.sourceWrapper.corners.center,n=t.targetWrapper.corners.center;e=Ut(t,t.sourceWrapper,r,n,!1)}else e=t.sourcePoint;else e=t.sourcePoint;return e}function dt(t,e,i){"LeftToRight"===i?(t.direction=t.direction?t.direction:"Right",e.direction=e.direction?e.direction:"Left"):"RightToLeft"===i?(t.direction=t.direction?t.direction:"Left",e.direction=e.direction?e.direction:"Right"):"TopToBottom"===i?(t.direction=t.direction?t.direction:"Bottom",e.direction=e.direction?e.direction:"Top"):"BottomToTop"===i&&(t.direction=t.direction?t.direction:"Top",e.direction=e.direction?e.direction:"Bottom")}function lt(t,e,i,r,n){var o,a,s=t.sourceWrapper,h=t.targetWrapper,d=t.sourcePortWrapper,l=t.targetPortWrapper,c=[],p=Wt(t),g={corners:void 0,point:e,direction:void 0,margin:{left:5,right:5,bottom:5,top:5}},u={corners:void 0,point:i,direction:void 0,margin:{left:5,right:5,bottom:5,top:5}};if(void 0!==s&&void 0!==h&&(o=L(s),a=L(h),g.corners=s.corners,u.corners=h.corners),d&&d.isPathPort&&l&&(i={x:l.offsetX,y:l.offsetY}),void 0!==d){var f={x:d.offsetX,y:d.offsetY};"Left"===d.connectionDirection||"Top"===d.connectionDirection||"Bottom"===d.connectionDirection||"Right"===d.connectionDirection?g.direction=d.connectionDirection:d.isPathPort?g.direction=ct(t.parentObj,t.sourceID,d,i):g.direction=Se(f,o,s.bounds)}if(void 0!==l){var m={x:l.offsetX,y:l.offsetY};"Left"===l.connectionDirection||"Right"===l.connectionDirection||"Bottom"===l.connectionDirection||"Top"===l.connectionDirection?u.direction=l.connectionDirection:l.isPathPort?u.direction=ct(t.parentObj,t.targetID,l,e):u.direction=Se(m,a,h.bounds)}if("Bezier"===t.type&&!t.isBezierEditing&&t.segments.length>0)for(var y=t.segments.length-1;y>=0;)t.segments[parseInt(y.toString(),10)].isInternalSegment&&t.segments.pop(),y--;if(void 0!==s&&void 0!==h)return void 0!==g.direction&&void 0!==u.direction||(r?dt(g,u,r):g.corners.top>u.corners.bottom&&Math.abs(g.corners.top-u.corners.bottom)>p?(g.direction=g.direction?g.direction:"Top",u.direction=u.direction?u.direction:"Bottom"):g.corners.bottom<u.corners.top&&Math.abs(g.corners.bottom-u.corners.top)>p?(g.direction=g.direction?g.direction:"Bottom",u.direction=u.direction?u.direction:"Top"):g.corners.right<u.corners.left&&Math.abs(g.corners.right-u.corners.left)>p||g.corners.right+p<u.corners.left||u.corners.right>=g.corners.left-p&&g.corners.left>u.corners.left?(g.direction=g.direction?g.direction:"Right",u.direction=u.direction?u.direction:"Left"):g.corners.left>u.corners.right&&Math.abs(g.corners.left-u.corners.right)>g.margin.left+g.margin.right||u.corners.right+p<g.corners.left||g.corners.right>=u.corners.left-p&&g.corners.left<u.corners.left?(g.direction=g.direction?g.direction:"Left",u.direction=u.direction?u.direction:"Right"):s.id!==h.id&&!o.equals(o,a)&&a.containsPoint(o.topCenter,g.margin.top)?(g.direction=g.direction?g.direction:"Bottom",u.direction=u.direction?u.direction:"Top"):(g.direction=g.direction?g.direction:"Top",u.direction=u.direction?u.direction:"Bottom")),Ot(t,g.direction,u.direction,g.point,u.point,n,i);if(Lt(t),(t.sourceWrapper||t.targetWrapper)&&It(t,g,u),"Straight"===t.type||"Bezier"===t.type)c=Mt(t,g,u);else if("Orthogonal"===t.type&&t.segments&&t.segments.length>0&&null!==t.segments[0].length&&null!==t.segments[0].direction)c=St(t,g,u,s,h,d,l,i);else{var v=void 0;g.direction?v=se(s.bounds,g,20):g.direction=u.direction?void 0!==t.targetPortWrapper?u.direction:xe(u.direction):fs.direction(g.point,u.point),t.segments[0].points=c=de(t,g,u,v)}return c}function ct(t,e,i,r){var n=null,o=t.nameTable[""+e];if(i&&o){var a={x:i.offsetX,y:i.offsetY},s=pt(a,o);s&&(n="Horizontal"===s?r.y>a.y?"Bottom":"Top":r.x>a.x?"Right":"Left")}return n}function pt(t,e){for(var i=e.intermediatePoints,r=0;r<i.length-1;r++){var n=i[parseInt(r.toString(),10)],o=i[r+1];if(gt(t,n,o))return n.x===o.x?"Vertical":"Horizontal"}if(i.length>=2){var a=i[i.length-2],s=i[i.length-1];return a.x===s.x?"Vertical":"Horizontal"}return null}function gt(t,e,i){return e.x===i.x&&t.x===e.x?t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y):e.y===i.y&&t.y===e.y&&(t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x))}function ut(t,e){t.direction=e.direction,e.points=[],e.points.push(t.point);var i="Left"===e.direction||"Top"===e.direction?-e.length:e.length,r="Left"===e.direction||"Right"===e.direction?0:90,n=Xt(t.point,i,r);return e.points.push(n),n}function ft(t,e,i){var r,n,o;if(e.corners=t.sourceWrapper?t.sourceWrapper.corners:void 0,t.sourcePortWrapper&&(o=Se({x:t.sourcePortWrapper.offsetX,y:t.sourcePortWrapper.offsetY},L(t.sourceWrapper),t.sourceWrapper.bounds),!e.corners||"Bottom"!==e.direction&&"Top"!==e.direction?!e.corners||"Left"!==e.direction&&"Right"!==e.direction||i.point.y>e.corners.top&&i.point.y<e.corners.bottom&&(n=e.point.x>i.point.x?"Left":"Right"):i.point.x>e.corners.left&&i.point.x<e.corners.right&&(n=e.point.y>i.point.y?"Top":"Bottom")),t.sourcePortWrapper&&o===xe(n)){var a;("Left"===o||"Right"===o)&&e.point.y>=e.corners.top&&e.point.y<=e.corners.center.y&&i.point.y>=e.corners.top&&i.point.y<=e.corners.center.y?(e.direction="Top",a=e.point.y-e.corners.top+20):("Left"===o||"Right"===o)&&e.point.y>e.corners.center.y&&e.point.y<=e.corners.bottom&&i.point.y>e.corners.center.y&&i.point.y<=e.corners.bottom?(e.direction="Bottom",a=e.corners.bottom-e.point.y+20):("Top"===o||"Bottom"===o)&&e.point.x>=e.corners.left&&e.point.x<=e.corners.center.x&&i.point.x>=e.corners.left&&i.point.x<=e.corners.center.x?(e.direction="Left",a=e.point.x-e.corners.left+20):("Top"===o||"Bottom"===o)&&e.point.x<=e.corners.right&&e.point.x>e.corners.center.x&&i.point.x<=e.corners.right&&i.point.x<e.corners.center.x&&(e.direction="Right",a=e.corners.right-e.point.x+20),e.direction&&a&&(r=de(t,e,i,a,!0))}else e.direction=n||Et(e.direction,e.point,i.point),r=he(e,i);return r}function mt(t,e,i){var r;i.corners=t.targetWrapper.corners,jt(t.targetWrapper,e,i,t);var n=Et(i.direction,e.point,i.point);return e.direction!==i.direction||"Left"!==e.direction&&"Right"!==e.direction?(e.direction=n,r=he(e,i)):(e.direction=n,r=de(t,e,i,t.targetWrapper.width/2+20),e.point=r[1],jt(t.targetWrapper,e,i,t),r=de(t,e,i)),r}function yt(t,e,i){i.corners=t.targetWrapper.corners;var r,n;"Left"!==e.direction&&"Right"!==e.direction?i.corners.center.y!==e.point.y||i.corners.left<=e.point.x&&e.point.x<=i.corners.right?i.corners.center.y===e.point.y&&"Bottom"===t.segments[t.segments.length-2].direction||i.corners.center.y>e.point.y&&e.point.y>=i.corners.top?(r="Top",n=e.point.y-i.corners.top+20):i.corners.center.y===e.point.y&&"Top"===t.segments[t.segments.length-2].direction||i.corners.center.y<e.point.y&&e.point.y<=i.corners.bottom?(r="Bottom",n=i.corners.bottom-e.point.y+20):void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&e.corners.top<=e.point.y&&e.point.y<=e.corners.bottom&&(r=e.direction,n=e.point.y>i.point.y?e.point.y-e.corners.top+20:e.corners.bottom-e.point.y+20):(r="Top",n=i.corners.height/2+20):i.corners.center.x!==e.point.x||i.corners.top<e.point.y&&e.point.y<=i.corners.bottom?i.corners.center.x===e.point.x&&"Right"===t.segments[t.segments.length-2].direction||i.corners.center.x>e.point.x&&e.point.x>=i.corners.left?(r="Left",n=e.point.x-i.corners.left+20):i.corners.center.x===e.point.x&&"Left"===t.segments[t.segments.length-2].direction||i.corners.center.x<=e.point.x&&e.point.x<=i.corners.right?(r="Right",n=i.corners.right-e.point.x+20):void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&e.corners.left<=e.point.x&&e.point.x<=e.corners.right&&(r=e.direction,n=e.point.x>i.point.x?e.point.x-e.corners.left+20:e.corners.right-e.point.x+20):(r="Left",n=i.corners.width/2+20);var o="Left"===r||"Top"===r?-n:n,a="Left"===r||"Right"===r?0:90,s=e.point;e.point=Xt(e.point,o,a),e.direction=fs.direction(e.point,i.point),void 0===t.sourcePortWrapper||void 0===t.targetPortWrapper||e.corners.center.x!==i.corners.center.x&&e.corners.center.y!==i.corners.center.y||(e.direction=i.direction);var h=de(t,e,i);return h.splice(0,0,s),h}function vt(t,e,i,r){var n=!1;switch(i.direction){case"Left":void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&"Right"===r&&e.point.x>i.point.x&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom||("Bottom"===r&&e.point.y>i.point.y||"Top"===r&&e.point.y<i.point.y)&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right?(e.direction="Right"===r?e.point.y>i.point.y?"Top":"Bottom":e.point.x<i.point.x?"Right":"Left",n=!0):e.point.x>i.point.x&&(e.point.y>i.point.y||e.point.y<i.point.y)&&!(i.corners.top>e.point.y&&i.corners.bottom<e.point.y)?e.direction="Left":e.point.x<i.point.x&&e.point.y>i.point.y||e.point.x>i.point.x&&e.point.y<=i.point.y&&i.corners.top<e.point.y&&i.corners.center.y>=e.point.y?e.direction="Top":e.point.x<i.point.x&&e.point.y<i.point.y||e.point.x>i.point.x&&e.point.y>i.point.y&&i.corners.bottom<e.point.y&&i.corners.center.y>e.point.y?e.direction="Bottom":e.point.y===i.point.y&&e.point.x<i.point.x&&(e.direction="Right");break;case"Right":void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&("Bottom"===r&&e.point.y>i.point.y||"Top"===r&&e.point.y<i.point.y)&&e.point.x>i.point.x&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right?(e.direction=e.point.x>i.point.x?"Left":"Right",n=!0):void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&"Left"===r&&e.point.x<i.point.x&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom?(e.direction=e.point.y>i.point.y?"Top":"Bottom",n=!0):e.point.x<i.point.x&&i.corners.top<=e.point.y&&i.corners.bottom>=e.point.y&&e.point.y===i.point.y?e.direction="Top":e.point.y>i.point.y&&e.point.x>i.point.x?e.direction="Top":e.point.y<i.point.y&&e.point.x>i.point.x?e.direction="Bottom":e.point.x<i.point.x&&(e.point.y>i.point.y||e.point.y<i.point.y)?e.direction="Right":e.point.y===i.point.y&&e.point.x>i.point.x&&(e.direction="Left");break;case"Top":void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&"Bottom"===r&&e.point.y>i.point.y&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right||("Right"===r&&e.point.x>i.point.x||"Left"===r&&i.point.y>e.point.y&&i.point.x>e.point.x)&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom?(e.direction="Bottom"===r?e.point.x>i.point.x?"Left":"Right":e.point.y<i.point.y?"Bottom":"Top",n=!0):e.point.x===i.point.x&&e.point.y<i.point.y?e.direction="Bottom":e.point.y>i.point.y&&e.point.x>i.corners.left&&e.point.x<i.corners.right?e.direction="Left":e.point.y>=i.point.y?e.direction="Top":e.point.y<i.point.y&&e.point.x>i.point.x?e.direction="Left":e.point.y<i.point.y&&e.point.x<i.point.x&&(e.direction="Right");break;case"Bottom":void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&(("Right"===r||"Left"===r&&i.point.x>e.point.x)&&e.point.y>i.point.y&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom||"Top"===r&&e.point.y<i.point.y&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right)?(e.direction="Right"===r||"Left"===r?e.point.y>i.point.y?"Top":"Bottom":e.point.x>i.point.x?"Left":"Right",n=!0):e.point.y<i.point.y&&e.point.x>i.corners.left&&i.corners.right>e.point.x?e.point.y<i.point.y&&e.point.x>i.corners.left&&i.corners.center.x>=e.point.x?e.direction="Left":e.point.y<i.point.y&&e.point.x<i.corners.right&&i.corners.center.x<e.point.x&&(e.direction="Right"):e.point.y>i.point.y&&e.point.x>i.point.x?e.direction="Left":e.point.y>i.point.y&&e.point.x<i.point.x?e.direction="Right":e.point.y<=i.point.y&&(e.point.x>i.point.x||i.point.x>e.point.x)&&(e.direction="Bottom")}return n}function bt(t,e,i){var r;i.corners=t.targetWrapper.corners;var n;void 0!==t.sourcePortWrapper&&(n=Se({x:t.sourcePortWrapper.offsetX,y:t.sourcePortWrapper.offsetY},L(t.sourceWrapper),t.sourceWrapper.bounds));var o=vt(t,e,i,n);return!t.selectedSegmentIndex&&void 0!==t.sourcePortWrapper&&void 0!==t.targetPortWrapper&&i.direction===xe(n)&&(("Left"===i.direction&&e.point.x>i.point.x||"Right"===i.direction&&e.point.x<i.point.x)&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom||"Bottom"===i.direction&&e.point.y<i.point.y&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right)?r=yt(t,e,i):t.selectedSegmentIndex||e.direction!==i.direction?!t.selectedSegmentIndex&&("Left"===i.direction&&e.point.x>i.point.x||"Right"===i.direction&&e.point.x<i.point.x)&&("Top"===e.direction||"Bottom"===e.direction)&&e.point.y<=i.point.y&&i.corners.top<=e.point.y&&i.corners.bottom>=e.point.y||"Top"===i.direction&&e.point.y>i.point.y||"Bottom"===i.direction&&e.point.y<i.point.y&&i.corners.left<=e.point.x&&i.corners.right>=e.point.x?r=t.selectedSegmentIndex?he(e,i):yt(t,e,i):!t.selectedSegmentIndex&&void 0!==t.sourceWrapper&&void 0!==t.targetWrapper&&void 0!==t.targetPortWrapper&&("Left"===e.direction||"Right"===e.direction)&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom&&("Top"===i.direction||"Bottom"===i.direction)&&i.corners.center.x===e.corners.center.x?(e.direction="Top"===i.direction?"Bottom":"Top",r=de(t,e,i,"Top"===i.direction?e.corners.bottom-e.point.y+20:e.point.y-e.corners.top+20)):!t.selectedSegmentIndex&&void 0!==t.sourceWrapper&&void 0!==t.targetWrapper&&void 0!==t.targetPortWrapper&&("Top"===e.direction||"Bottom"===e.direction)&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right&&("Left"===i.direction||"Right"===i.direction)&&i.corners.center.y===e.corners.center.y?(e.direction="Left"===i.direction?"Right":"Left",r=de(t,e,i,"Left"===i.direction?e.corners.right-e.point.x+20:e.point.x-e.corners.left+20)):r=o?de(t,e,i,"Left"===e.direction||"Right"===e.direction?"Left"===e.direction?e.point.x-e.corners.left+20:e.corners.right-e.point.x+20:"Top"===e.direction?e.point.y-e.corners.top+20:e.corners.bottom-e.point.y+20):he(e,i):r=de(t,e,i),r}function St(t,e,i,r,n,o,a,s){var h,d,l,c=[];Lt(t);var p;if(t.segments.length>0){for(var g=0;g<t.segments.length;g++){var u=t.segments[parseInt(g.toString(),10)];if(0===g&&void 0!==t.sourcePortWrapper&&(l=Se({x:o.offsetX,y:o.offsetY},L(r),r.bounds),u.direction===xe(l)&&(u.direction=l)),g>0&&t.segments[g-1].direction===u.direction)g=zt(t,g,e);else{var f=t.segments[g-1];e.point=u.direction?ut(e,u):f.points[f.points.length-1]}if(g===t.segments.length-1&&(a||n?t.targetWrapper&&void 0===t.targetPortWrapper?(Bt(t,e),d=mt(t,e,i)):d=bt(t,e,i):d=ft(t,e,i),d))if(xt(d,t),u.points=[],d.length>=2)for(h=0;h<d.length;h++)u.points.push(d[parseInt(h.toString(),10)]);else p=g;if(o&&0===g){var m=wt(t,o,r,s);m&&(e.point=m)}}void 0!==p&&(p===t.segments.length-1&&(t.segments[p-1].direction=null,t.segments[p-1].length=null),t.segments.splice(p,1)),c=Rt(t,c)}return c}function wt(t,e,i,r){var n,o,a={x:e.offsetX,y:e.offsetY},s=L(i);o=e.isPathPort&&r?ct(t.parentObj,t.sourceID,e,r):Se(a,s,i.bounds);var h=t.segments[0];return h.direction!==o&&(Yt(h,o,s,h.points[0],h.points[h.points.length-1],!1),n=h.points[h.points.length-1],h.direction=fs.direction(h.points[h.points.length-2],h.points[h.points.length-1])),n}function xt(t,e,i){var r,n=e.segments[e.segments.length-2],o=n.points[n.points.length-1];("Top"!==n.direction&&"Bottom"!==n.direction||o.x!==t[1].x)&&("Left"!==n.direction&&"Right"!==n.direction||o.y!==t[1].y)||(n.points[n.points.length-1]=t[1],r=fs.direction(n.points[0],n.points[n.points.length-1]),void 0!==e.sourceWrapper&&void 0===e.sourcePortWrapper&&r===xe(n.direction)&&("Left"===n.direction||"Right"===n.direction?n.points[0].x="Right"===n.direction?n.points[0].x-e.sourceWrapper.corners.width:n.points[0].x+e.sourceWrapper.corners.width:n.points[0].y="Bottom"===n.direction?n.points[0].y-e.sourceWrapper.corners.height:n.points[0].y+e.sourceWrapper.corners.height),n.direction=r,n.length=fs.distancePoints(n.points[0],n.points[n.points.length-1]),t.splice(0,1))}function It(t,e,i){var r=t.sourcePortWrapper,n=t.targetPortWrapper,o=t.sourceWrapper,a=e.point,s={left:0,right:0,top:0,bottom:0},h={x:0,y:0},d="Top";if(o?(a=i.point,s=e.margin):(o=t.targetWrapper,s=i.margin),"Orthogonal"===t.type)if(t.segments&&t.segments.length>0&&t.sourceWrapper&&t.segments[0].direction)e.direction=t.segments[0].direction,h=Ut(t,o,h=Ft(o.corners,e.direction),Ft(o.corners,xe(e.direction)),!1);else{var l={corners:null,direction:null,point:null,margin:null};jt(o,{corners:null,direction:null,point:a,margin:s},l,t),h=l.point,d=l.direction}else{var c=void 0;t.segments&&t.segments.length>1&&(c=o===t.sourceWrapper?t.segments[0].point:t.segments[t.segments.length-2].point),h=Ut(t,o,o.bounds.center,t.segments&&t.segments.length>1?c:a,o===t.targetWrapper)}o===t.sourceWrapper?(e.direction=e.direction||d,e.point=h,t.sourcePortWrapper&&(e.point={x:r.offsetX,y:r.offsetY},t.sourcePadding&&(e.point=Ct(t,e,i,!1)))):(i.direction=i.direction||d,i.point=h,t.targetPortWrapper&&(i.point={x:n.offsetX,y:n.offsetY},t.targetPadding&&(i.point=Ct(t,e,i,!0))))}function Ct(t,e,i,r){var n=t.sourcePortWrapper,o=t.targetPortWrapper,a=r?t.targetPadding:t.sourcePadding,s=r?o:n,h=new ms(s.bounds.x-a,s.bounds.y-a,s.actualSize.width+2*a,s.actualSize.height+2*a),d=[h.topLeft,h.topRight,h.bottomRight,h.bottomLeft];d[d.length]=d[0];var l={x1:e.point.x,y1:e.point.y,x2:i.point.x,y2:i.point.y},c=r?i.point:e.point;return Gt(l,d,!0,c)||c}function Pt(t,e,i){for(var r=Dt(t,i.sourcePadding),n=Dt(e,i.targetPadding),o=0;o<r.length-1;o++)for(var a=r[parseInt(o.toString(),10)],s=0;s<n.length-1;s++)if(fn(a,n[parseInt(s.toString(),10)]).enabled)return!0;return!1}function Dt(t,e){var i=[],r=vn(t,t.corners,e);r.push(r[0]);for(var n=0;n<r.length-1;n++)i.push(At(r[parseInt(n.toString(),10)],r[n+1]));return i}function At(t,e){return{x1:t.x,y1:t.y,x2:e.x,y2:e.y}}function Tt(t,e,i){var r,n=t.rotateAngle+t.parentTransform;if(n){if(n<45)return e;if(n<=135)r={width:e.width,height:e.height,topLeft:e.bottomLeft,topCenter:e.middleLeft,topRight:e.topLeft,middleLeft:e.bottomCenter,center:i.center,middleRight:e.topCenter,bottomLeft:e.bottomRight,bottomCenter:e.middleRight,bottomRight:e.topRight,left:i.left,right:i.right,top:i.top,bottom:i.bottom};else if(n<=225)r={width:e.width,height:e.height,topLeft:e.bottomLeft,topCenter:e.bottomCenter,topRight:e.bottomRight,middleLeft:e.middleRight,center:i.center,middleRight:e.middleLeft,bottomLeft:e.topLeft,bottomCenter:e.topCenter,bottomRight:e.topRight,left:i.left,right:i.right,top:i.top,bottom:i.bottom};else{if(!(n<=315))return e;r={width:e.width,height:e.height,topLeft:e.topRight,topCenter:e.middleRight,topRight:e.bottomRight,middleLeft:e.topCenter,center:i.center,middleRight:e.bottomCenter,bottomLeft:e.topLeft,bottomCenter:e.middleLeft,bottomRight:e.bottomLeft,left:i.left,right:i.right,top:i.top,bottom:i.bottom}}return r}return e}function Ot(t,e,i,r,n,o,a){var s,h=t.sourceWrapper,d=t.targetWrapper,l=t.sourcePortWrapper,c=t.targetPortWrapper,p=[],g=h.corners,u=d.corners,f=(u.center,{corners:g,point:r,direction:e,margin:{left:5,right:5,bottom:5,top:5}}),m={corners:u,point:n,direction:i,margin:{left:5,right:5,bottom:5,top:5}},y=Tt(h,g,t.sourceWrapper.bounds),v=Tt(d,u,t.targetWrapper.bounds),b=!1;if(t.sourceWrapper&&t.targetWrapper&&(b=Pt(t.sourceWrapper,t.targetWrapper,t)),void 0!==l){switch(f.point={x:l.offsetX,y:l.offsetY},f.direction){case"Bottom":case"Top":f.point.y=f.point.y;break;case"Left":case"Right":f.point.x=f.point.x}t.sourcePadding&&!b&&(c&&(m.point={x:c.offsetX,y:c.offsetY}),f.point=Ct(t,f,m,!1))}else"Orthogonal"===t.type||"Bezier"===t.type?(t.segments&&t.segments.length>0&&t.segments[0].direction&&(f.direction=t.segments[0].direction),f.point=Ft(y,f.direction),s=Ft(y,xe(f.direction)),f.point=Ut(t,h,f.point,s,!1)):f.point=h.corners.center;if(void 0!==c){switch(m.point={x:c.offsetX,y:c.offsetY},m.direction){case"Bottom":case"Top":m.point.y=m.point.y;break;case"Left":case"Right":m.point.x=m.point.x}t.targetPadding&&!b&&(m.point=Ct(t,f,m,!0))}else"Orthogonal"===t.type||"Bezier"===t.type?(m.point=Ft(v,m.direction),s=Ft(v,xe(m.direction)),m.point=Ut(t,d,m.point,s,!0)):m.point=d.corners.center;if("Orthogonal"!==t.type){var S=void 0,w=void 0;if("Bezier"===t.type){if(t.bezierSettings.allowSegmentsReset||0===t.segments.length||!fs.isEmptyPoint(t.segments[t.segments.length-1].point))return p=Ht(t,f,m,void 0,o),p=Mt(t,f,m);Lt(t)}else Lt(t);if(void 0===t.sourcePortWrapper){f.point=f.corners.center,t.segments&&t.segments.length>0&&(w=t.segments[0],S=fs.isEmptyPoint(w.point)?void 0:w);var x=void 0!==S?S.point:m.point;if("Bezier"===t.type&&t.segments.length>0&&t.segments[0].vector1.angle&&t.segments[0].vector1.distance){C=Math.max(f.corners.width,f.corners.height);x=fs.transform(f.point,t.segments[0].vector1.angle,C/2)}f.point=b?t.sourceWrapper.bounds.center:Ut(t,h,f.point,x,!1)}if(void 0===t.targetPortWrapper){m.point=m.corners.center,t.segments&&t.segments.length>1&&(w=t.segments[t.segments.length-2],S=fs.isEmptyPoint(w.point)?void 0:w);var I=S?S.point:f.point;if("Bezier"===t.type&&t.segments.length>0&&t.segments[t.segments.length-1].vector2.angle&&t.segments[t.segments.length-1].vector2.distance){var C=Math.max(f.corners.width,f.corners.height);I=fs.transform(m.point,t.segments[0].vector2.angle,C/2)}m.point=b?t.targetWrapper.bounds.center:Ut(t,d,I,m.point,!0)}p=Mt(t,f,m)}else if("Orthogonal"===t.type&&t.segments&&t.segments.length>0&&null!==t.segments[0].direction)p=Nt(t,f,m,l,c,h,d,a);else{if(!t.segments[0]){S=new md(t,"segments",{type:"Orthogonal"},!0);t.segments.push(S)}t.segments[0].points=p=Ht(t,f,m,void 0,o)}return p}function Mt(t,e,i){var r=[];if(t.segments&&t.segments.length>0){var n=void 0,o=[],a=e.point;for(n=0;n<t.segments.length;n++){var s=t.segments[parseInt(n.toString(),10)];if((o=[]).push(a),n!==t.segments.length-1?(o.push(s.point),a=s.point):o.push(i.point),t.segments[parseInt(n.toString(),10)].points=o,t.segments.length>1&&fs.equals(s.points[0],s.points[1])&&t.segments.splice(n,1),s)for(var h=0;h<s.points.length;h++)(h>0||0===n)&&r.push(s.points[parseInt(h.toString(),10)])}}return r}function Et(t,e,i){return"Top"===t||"Bottom"===t?i.x>e.x?"Right":"Left":i.y>e.y?"Bottom":"Top"}function Lt(t){if("Straight"===t.type||"Bezier"===t.type){if(0===t.segments.length||t.segments.length>0&&!fs.isEmptyPoint(t.segments[t.segments.length-1].point))if("Bezier"===t.type){n=new fd(t,"segments",{type:"Bezier",isInternalSegment:!0},!0);t.segments.push(n)}else{n=new ud(t,"segments",{type:"Straight"},!0);t.segments.push(n)}}else{if(t.segments.length>0)for(var e=!1,i=0;i<t.segments.length;){var r=t.segments[parseInt(i.toString(),10)];e||r&&!(r instanceof md||r instanceof ud||r instanceof fd)?(t.segments.splice(i,1),e=!0):i++}if(0===t.segments.length||t.segments[t.segments.length-1].direction){var n=new md(t,"segments",{type:"Orthogonal"},!0);t.segments.push(n)}}}function zt(t,e,i){var r=t.segments[parseInt(e.toString(),10)],n="Left"===r.direction||"Top"===r.direction?-r.length:r.length,o="Left"===r.direction||"Right"===r.direction?0:90,a=Xt(i.point,n,o);return t.segments[e-1].length+=r.length,t.segments[e-1].points[1]=i.point=a,t.segments.splice(e,1),--e}function kt(t,e,i){var r,n;t.sourcePortWrapper&&(n=Se({x:t.sourcePortWrapper.offsetX,y:t.sourcePortWrapper.offsetY},L(t.sourceWrapper),t.sourceWrapper.bounds)),jt(t.targetWrapper,e,i,t);var o=Et(i.direction,e.point,i.point);if(void 0===t.sourcePortWrapper||e.direction!==i.direction||("Top"!==e.direction&&"Bottom"!==e.direction||e.corners.center.x!==i.corners.center.x)&&("Left"!==e.direction&&"Right"!==e.direction||e.corners.center.y!==i.corners.center.y))if(i.point.x>=e.corners.left&&i.point.x<=e.corners.right&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom)e.direction=i.point.y>e.point.y?"Bottom":"Top",r=de(t,e,i,"Top"===e.direction?e.point.y-e.corners.top+20:e.corners.bottom-e.point.y+20);else if(t.sourcePortWrapper&&n===xe(o)){var a;("Left"===n||"Right"===n)&&e.point.y>=e.corners.top&&e.point.y<=e.corners.bottom?(e.direction=i.point.y>e.point.y?"Bottom":"Top",a=e.corners.height/2+20):("Top"===n||"Bottom"===n)&&e.point.x>=e.corners.left&&e.point.x<=e.corners.right&&(e.direction=i.point.x>e.point.x?"Right":"Left",a=e.corners.width/2+20),e.direction&&a?r=de(t,e,i,a,!0):(e.direction=o,r=he(e,i))}else if(!t.sourcePortWrapper||n!==i.direction||"Top"!==n&&"Bottom"!==n||e.corners.center.x!==i.corners.center.x)if(e.direction===i.direction)if(("Left"===e.direction||"Right"===e.direction)&&i.point.y>e.corners.top-20&&i.point.y<e.corners.bottom+20||("Top"===e.direction||"Bottom"===e.direction)&&i.point.x>e.corners.left-20&&i.point.x<e.corners.right+20){var s=e.direction;e.direction=o,r=ce(e,i,s,r,20,!1)}else e.direction=o,r=he(e,i);else e.direction=o,r=he(e,i);else e.direction=i.point.y>e.point.y?"Bottom":"Top",r=de(t,e,i,"Bottom"===e.direction?e.corners.bottom-e.point.y+20:e.point.y-e.corners.top+20);else e.direction=o,r="Top"===o||"Bottom"===o?de(t,e,i,t.sourceWrapper.height/2+20):de(t,e,i,t.sourceWrapper.width/2+20),e.point=r[1],"Left"===o||"Right"===o?(i.direction=o,i.point="Left"===o?i.corners.middleLeft:i.corners.middleRight):jt(t.targetWrapper,e,i,t),r=de(t,e,i);return r}function Bt(t,e){if(void 0!==t.targetWrapper&&void 0===t.targetPortWrapper){if(L(t.targetWrapper).containsPoint(e.point,1)){var i=t.targetWrapper,r=t.segments[t.segments.length-2],n=r.points[r.points.length-1],o=xe(r.direction);"Bottom"===o?n.y<i.corners.bottom+1&&(r.points[r.points.length-1].y=i.corners.bottom+20,r.length=fs.distancePoints(r.points[0],r.points[r.points.length-1])):"Top"===o?n.y>i.corners.top-1&&(r.points[r.points.length-1].y=i.corners.top-20,r.length=fs.distancePoints(r.points[0],r.points[r.points.length-1])):"Left"===o?n.x>i.corners.left-1&&(r.points[r.points.length-1].x=i.corners.left-20,r.length=fs.distancePoints(r.points[0],r.points[r.points.length-1])):"Right"===o&&n.x<i.corners.right+1&&(r.points[r.points.length-1].x=i.corners.right+20,r.length=fs.distancePoints(r.points[0],r.points[r.points.length-1])),e.point=r.points[r.points.length-1]}}}function Nt(t,e,i,r,n,o,a,s){var h,d,l,c,p=[];Lt(t);for(var g=0;g<t.segments.length;g++){if(d=t.segments[parseInt(g.toString(),10)],r&&e.direction===xe(d.direction)&&(d.direction=e.direction),g>0&&t.segments[g-1].direction===d.direction?g=zt(t,g,e):d.direction?e.point=ut(e,t.segments[parseInt(g.toString(),10)]):(f=t.segments[g-1])&&f.points&&f.points.length>0&&(e.point=f.points[f.points.length-1]),g===t.segments.length-1)if(Bt(t,e),h=void 0===n?kt(t,e,i):bt(t,e,i),xt(h,t),d.points=[],h.length>=2)for(l=0;l<h.length;l++)if(t.selectedSegmentIndex)if(l===h.length-1&&h.length>2&&t.segments.length>2){var u={x:h[parseInt(l.toString(),10)].x,y:e.point.y};d.points=[],d.points.push(u),d.points.push(h[parseInt(l.toString(),10)]);var f=t.segments[g-1];t.segments.length<4&&f.points.pop(),f.points=f.points.concat(d.points)}else d.points.push(h[parseInt(l.toString(),10)]);else d.points.push(h[parseInt(l.toString(),10)]);else c=g;if(void 0===c||t.selectedSegmentIndex||(c===t.segments.length-1&&(t.segments[c-1].direction=null,t.segments[c-1].length=null),t.segments.splice(c,1)),r&&0===g){var m=wt(t,r,o,s);m&&(e.point=m)}}return Rt(t,p)}function Rt(t,e){for(var i=0;i<t.segments.length;i++)for(var r=t.segments[parseInt(i.toString(),10)],n=0;n<r.points.length;n++)(n>0||0===i)&&e.push(r.points[parseInt(n.toString(),10)]);return e}function jt(t,e,i,r){var n,o={x:0,y:0},a=Tt(t,t.corners,t.bounds),s=e.margin,h=e.point;if(a.bottomCenter.y+s.bottom<h.y)n="Bottom",o=a.bottomCenter;else if(a.topCenter.y-s.top>h.y)n="Top",o=a.topCenter;else if(a.middleLeft.x-s.left>h.x)n="Left",o=a.middleLeft;else if(a.middleRight.x+s.right<h.x)n="Right",o=a.middleRight;else{var d=Math.abs(h.y-a.topCenter.y),l=Math.abs(h.x-a.middleRight.x),c=Math.abs(h.y-a.bottomCenter.y),p=Math.abs(h.x-a.middleLeft.x),g=Number.MAX_VALUE;g=d,n="Top",o=a.topCenter,g>l&&(g=l,n="Right",o=a.middleRight),g>c&&(g=c,n="Bottom",o=a.bottomCenter),g>p&&(n="Left",o=a.middleLeft)}i.point=o,i.direction=n;var u=Ft(a,xe(i.direction));i.point=Ut(r,t,i.point,u,t===r.targetWrapper)}function Ht(t,e,i,r,n){var o,a=!1,s=[];if((a=ve(e.direction,i.direction))&&be(e,i),"Right"===e.direction&&"Left"===i.direction)o=Kt(t,e,i,a);else if("Right"===e.direction&&"Right"===i.direction)o=Qt(t,e,i);else if("Right"===e.direction&&"Top"===i.direction)o=Jt(t,e,i,a);else if("Right"===e.direction&&"Bottom"===i.direction)o=$t(t,e,i,a);else if("Bottom"===e.direction&&"Top"===i.direction)o=te(t,e,i);else if("Bottom"===e.direction&&"Bottom"===i.direction){var h=Wt(t);e.margin={left:h,right:h,top:h,bottom:h},i.margin={left:h,right:h,top:h,bottom:h},o=ie(t,e,i)}else"Bottom"===e.direction&&"Left"===i.direction?o=ee(t,e,i,a):"Left"===e.direction&&"Left"===i.direction?o=ne(t,e,i):"Left"===e.direction&&"Top"===i.direction?o=re(t,e,i,a):"Top"===e.direction&&"Top"===i.direction&&(o=oe(t,e,i));return a&&be(e,i),s=ae(t,o,e,i,r,n),"Bezier"===t.type&&ye(t,o,s),s}function Wt(t){return t.connectorSpacing>=13?13:t.connectorSpacing<=1?1:t.connectorSpacing}function _t(t,e){var i={x:e.x,y:t.y},r=fs.findLength(i,e),n=fs.findLength(e,t),o=Math.asin(r/n);return o=180*o/Math.PI,t.x<e.x?t.y>e.y&&(o=360-o):o=t.y<e.y?180-o:180+o,o}function Ft(t,e){var i;switch(e){case"Left":i=t.middleLeft;break;case"Top":i=t.topCenter;break;case"Right":i=t.middleRight;break;case"Bottom":i=t.bottomCenter}return i}function Yt(t,e,i,r,n,o){var a,s,h=[];h.push(r),r.y===n.y&&("Left"===e&&n.x<r.x||"Right"===e&&n.x>r.x)||r.x===n.x&&("Top"===e&&n.y<r.y||"Bottom"===e&&n.y>r.y)||("Top"===e||"Bottom"===e?"Top"===e&&n.y<r.y&&n.y>r.y-13||"Bottom"===e&&n.y>r.y&&n.y<r.y+13?(s="Top"===e?i.top-13:i.bottom+13,h.push({x:r.x,y:s}),h.push({x:r.x+(n.x-r.x)/2,y:s}),h.push({x:r.x+(n.x-r.x)/2,y:n.y})):Math.abs(r.x-n.x)>13&&("Top"===e&&n.y<r.y||"Bottom"===e&&n.y>r.y)?h.push({x:r.x,y:n.y}):(s="Top"===e?i.top-13:i.bottom+13,a=n.x<r.x?i.left-13:i.right+13,h.push({x:r.x,y:s}),h.push({x:n.x,y:s})):"Left"===e&&n.x<r.x&&n.x>r.x-13||"right"===e&&n.x>r.x&&n.x<r.x+13?(a="Left"===e?i.left-13:i.right+13,h.push({x:a,y:r.y}),h.push({x:a,y:r.y+(n.y-r.y)/2}),h.push({x:n.x,y:r.y+(n.y-r.y)/2})):Math.abs(r.y-n.y)>13&&("Left"===e&&n.x<r.x||"Right"===e&&n.x>r.x)?h.push({x:n.x,y:r.y}):(a="Left"===e?i.left-13:i.right+13,h.push({x:a,y:r.y}),h.push({x:a,y:n.y})),o&&(h.push(t.points[0]),h.reverse()),t.points=h)}function Xt(t,e,i){return fs.transform(t,i,e)}function Ut(t,e,i,r,n){i={x:i.x,y:i.y},r={x:r.x,y:r.y};var o,a,s=n?t.targetWrapper:t.sourceWrapper,h=n?t.targetPadding:t.sourcePadding,d=n||"Orthogonal"===t.type||"Bezier"===t.type?i:r,l=s,c=V(-s.parentTransform,s.offsetX,s.offsetY,i),p=V(-s.parentTransform,s.offsetX,s.offsetY,r);if("Orthogonal"===t.type||"Bezier"===t.type){c.x===p.x&&(c.y<p.y?c.y-=5:c.y+=5),c.y===p.y&&(c.x<p.x?c.x-=5:c.x+=5),i=V(s.parentTransform,s.offsetX,s.offsetY,c)}else if(n){g=fs.findAngle(i,r);r=fs.transform({x:r.x,y:r.y},g,Math.max(s.actualSize.width,s.actualSize.height))}else{var g=fs.findAngle(r,i);i=fs.transform({x:i.x,y:i.y},g,Math.max(s.actualSize.width,s.actualSize.height))}return(t.sourcePadding||t.targetPadding)&&(o=new ms(s.bounds.x-h,s.bounds.y-h,s.actualSize.width+2*h,s.actualSize.height+2*h)),s instanceof Ws&&s.data?(a=o?[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft]:l.getPoints(),l.data.split("m").length-1+(l.data.split("M").length-1)==1&&(a[a.length]=a[0])):(a=o?[o.topLeft,o.topRight,o.bottomRight,o.bottomLeft]:vn(s,s.corners))[a.length]=a[0],Gt({x1:i.x,y1:i.y,x2:r.x,y2:r.y},a,!0,d)||i}function Vt(t,e,i){return e.x=Math.round(100*e.x)/100,e.y=Math.round(100*e.y)/100,i?t.targetPoint=e:t.sourcePoint=e,e}function Gt(t,e,i,r){var n,o=e.length,a={x1:e[0].x,y1:e[0].y,x2:e[1].x,y2:e[1].y},s=Zt(t,a);if(s&&(n=fs.distancePoints(s,r)),isNaN(n)||n>0)for(var h=1;h<o-1;h++){var d=Zt(t,a={x1:e[parseInt(h.toString(),10)].x,y1:e[parseInt(h.toString(),10)].y,x2:e[h+1].x,y2:e[h+1].y});if(d){var l=fs.distancePoints(d,r);if((isNaN(n)||n>l)&&(n=l,s=d),n>=0&&n<=1)break}}return s}function Zt(t,e){var i,r,n,o,a,s,h,d,l,c,p,g,u,f,m=t.x1,y=t.y1,v=t.x2,b=t.y2,S=e.x1,w=e.y1,x=e.x2,I=e.y2;if(i=b-y,n=m-v,a=v*y-m*b,p=i*S+n*w+a,g=i*x+n*I+a,0!==p&&0!==g&&qt(p,g))return null;if(r=I-w,o=S-x,s=x*w-S*I,l=r*m+o*y+s,c=r*v+o*b+s,0!==l&&0!==c&&qt(l,c))return null;var C=i*o-r*n;return 0===C?null:(u=C<0?-C/2:C/2,u=0,f=n*s-o*a,h=f<0?(f-u)/C:(f+u)/C,f=r*a-i*s,d=f<0?(f-u)/C:(f+u)/C,{x:h,y:d})}function qt(t,e){return t*e>=0}function Kt(e,i,r,n){var o=e.sourcePortWrapper,a=Math.round(Math.abs(i.point.y-r.point.y)),s={x:Math.max(i.point.x,i.corners.right),y:i.point.y},h={x:Math.min(r.point.x,r.corners.left),y:r.point.y},d=Wt(e);if(n){var l=h;h=s,s=l}return i.corners.bottom+d<r.corners.top-d||i.corners.top-d>r.corners.bottom+d||("Bezier"!==e.type?d=0:r.corners.left-i.corners.right<=2*d&&r.corners.left-i.corners.right>=5&&(d=0)),i.margin={left:d,right:d,top:d,bottom:d},r.margin={left:d,right:d,top:d,bottom:d},0===a&&(i.corners.right<r.corners.left||n&&i.corners.right<r.corners.left)?t.NoOfSegments.One:i.point.x+i.margin.right<r.point.x-r.margin.left?t.NoOfSegments.Three:e.sourceWrapper!==e.targetWrapper&&(L(e.sourceWrapper).containsPoint(h)||L(e.targetWrapper).containsPoint(s))?t.NoOfSegments.Three:i.corners.bottom<=r.corners.top?t.NoOfSegments.Five:i.corners.top>=r.corners.top?t.NoOfSegments.Five:void 0!==o&&o.offsetY<=r.corners.top||void 0===o&&i.corners.right<=r.corners.top?t.NoOfSegments.Five:(void 0!==o&&o.offsetY>=r.corners.bottom||void 0===o&&(i.corners.right,r.corners.bottom),t.NoOfSegments.Five)}function Qt(e,i,r){var n=e.sourcePortWrapper,o=e.targetPortWrapper,a=i.point.x-r.point