jsPlumbUtil={isArray:function(t){return Object.prototype.toString.call(t)==="[object Array]"},isString:function(t){return typeof t==="string"},isBoolean:function(t){return typeof t==="boolean"},isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},isDate:function(t){return Object.prototype.toString.call(t)==="[object Date]"},isFunction:function(t){return Object.prototype.toString.call(t)==="[object Function]"},clone:function(t){if(this.isString(t)){return new String(t)}else{if(this.isBoolean(t)){return new Boolean(t)}else{if(this.isDate(t)){return new Date(t.getTime())}else{if(this.isFunction(t)){return t}else{if(this.isArray(t)){var e=[];for(var n=0;nt[0]){return e[1]>t[1]?2:1}else{return e[1]>t[1]?3:4}},intersects:function(t,e){var n=t.x,r=t.x+t.w,i=t.y,o=t.y+t.h,a=e.x,s=e.x+e.w,l=e.y,u=e.y+e.h;return n<=a&&a<=r&&i<=l&&l<=o||n<=s&&s<=r&&i<=l&&l<=o||n<=a&&a<=r&&i<=u&&u<=o||n<=s&&a<=r&&i<=u&&u<=o||a<=n&&n<=s&&l<=i&&i<=u||a<=r&&r<=s&&l<=i&&i<=u||a<=n&&n<=s&&l<=o&&o<=u||a<=r&&n<=s&&l<=o&&o<=u},segmentMultipliers:[null,[1,-1],[1,1],[-1,1],[-1,-1]],inverseSegmentMultipliers:[null,[-1,-1],[-1,1],[1,1],[1,-1]],pointOnLine:function(t,e,n){var r=jsPlumbUtil.gradient(t,e),i=jsPlumbUtil.segment(t,e),o=n>0?jsPlumbUtil.segmentMultipliers[i]:jsPlumbUtil.inverseSegmentMultipliers[i],a=Math.atan(r),s=Math.abs(n*Math.sin(a))*o[1],l=Math.abs(n*Math.cos(a))*o[0];return{x:t.x+l,y:t.y+s}},perpendicularLineTo:function(t,e,n){var r=jsPlumbUtil.gradient(t,e),i=Math.atan(-1/r),o=n/2*Math.sin(i),a=n/2*Math.cos(i);return[{x:e.x+a,y:e.y+o},{x:e.x-a,y:e.y-o}]},findWithFunction:function(t,e){if(t){for(var n=0;n-1){t.splice(n,1)}return n!=-1},remove:function(t,e){var n=jsPlumbUtil.indexOf(t,e);if(n>-1){t.splice(n,1)}return n!=-1},addWithFunction:function(t,e,n){if(jsPlumbUtil.findWithFunction(t,n)==-1){t.push(e)}},addToList:function(t,e,n){var r=t[e];if(r==null){r=[],t[e]=r}r.push(n);return r},EventGenerator:function(){var t={},e=this;var n=["ready"];this.bind=function(n,r){jsPlumbUtil.addToList(t,n,r);return e};this.fire=function(r,i,o){if(t[r]){for(var a=0;a';var e=t.firstChild;e.style.behavior="url(#default#VML)";n.vml=e?typeof e.adj=="object":true;t.parentNode.removeChild(t)}return n.vml};var r=function(t){var e={},n=[],r={},i={};this.register=function(o){var a=jsPlumb.CurrentLibrary;o=a.getElementObject(o);var s=t.getId(o),l=a.getDOMElement(o),u=a.getOffset(o);if(!e[s]){e[s]=o;n.push(o);r[s]={}}var c=function(e,n){if(e){for(var o=0;o0){var h=a.getOffset(l);r[s][f]={id:f,offset:{left:h.left-u.left,top:h.top-u.top}}}c(e.childNodes[o])}}}};c(l)};this.endpointAdded=function(n){var o=jsPlumb.CurrentLibrary,a=document.body,s=t.getId(n),l=o.getDOMElement(n),u=l.parentNode,c=u==a;i[s]=i[s]?i[s]+1:1;while(u!=a){var f=t.getId(u,null,true);if(f&&e[f]){var h=-1,p=o.getElementObject(u),d=o.getOffset(p);if(r[f][s]==null){var v=jsPlumb.CurrentLibrary.getOffset(n);r[f][s]={id:s,offset:{left:v.left-d.left,top:v.top-d.top}}}break}u=u.parentNode}};this.endpointDeleted=function(t){if(i[t.elementId]){i[t.elementId]--;if(i[t.elementId]<=0){for(var e in r){delete r[e][t.elementId]}}}};this.getElementsForDraggable=function(t){return r[t]};this.reset=function(){e={};n=[];r={};i={}}};if(!window.console){window.console={time:function(){},timeEnd:function(){},group:function(){},groupEnd:function(){},log:function(){}}}window.jsPlumbAdapter={headless:false,appendToRoot:function(t){document.body.appendChild(t)},getRenderModes:function(){return["canvas","svg","vml"]},isRenderModeAvailable:function(r){return{canvas:t,svg:e,vml:n()}[r]},getDragManager:function(t){return new r(t)},setRenderMode:function(t){var e;if(t){t=t.toLowerCase();var n=this.isRenderModeAvailable("canvas"),r=this.isRenderModeAvailable("svg"),i=this.isRenderModeAvailable("vml");if(t==="svg"){if(r){e="svg"}else{if(n){e="canvas"}else{if(i){e="vml"}}}}else{if(t==="canvas"&&n){e="canvas"}else{if(i){e="vml"}}}}return e}}})();(function(){var t=jsPlumbUtil.findWithFunction,e=jsPlumbUtil.indexOf,n=jsPlumbUtil.removeWithFunction,r=jsPlumbUtil.remove,i=jsPlumbUtil.addWithFunction,o=jsPlumbUtil.addToList,a=jsPlumbUtil.isArray,s=jsPlumbUtil.isString,l=jsPlumbUtil.isObject;var u=null,c=function(t,e){return M.CurrentLibrary.getAttribute(v(t),e)},f=function(t,e,n){M.CurrentLibrary.setAttribute(v(t),e,n)},h=function(t,e){M.CurrentLibrary.addClass(v(t),e)},p=function(t,e){return M.CurrentLibrary.hasClass(v(t),e)},d=function(t,e){M.CurrentLibrary.removeClass(v(t),e)},v=function(t){return M.CurrentLibrary.getElementObject(t)},m=function(t,e){var n=M.CurrentLibrary.getOffset(v(t));if(e!=null){var r=e.getZoom();return{left:n.left/r,top:n.top/r}}else{return n}},g=function(t){return M.CurrentLibrary.getSize(v(t))},y=jsPlumbUtil.log,b=jsPlumbUtil.group,P=jsPlumbUtil.groupEnd,C=jsPlumbUtil.time,j=jsPlumbUtil.timeEnd,E=function(){return""+(new Date).getTime()},x=function(t){var e=this,n=arguments,r=false,i=t.parameters||{},o=e.idPrefix,a=o+(new Date).getTime(),s=null,l=null;e._jsPlumb=t._jsPlumb;e.getId=function(){return a};e.tooltip=t.tooltip;e.hoverClass=t.hoverClass||e._jsPlumb.Defaults.HoverClass||M.Defaults.HoverClass;jsPlumbUtil.EventGenerator.apply(this);this.clone=function(){var t=new Object;e.constructor.apply(t,n);return t};this.getParameter=function(t){return i[t]},this.getParameters=function(){return i},this.setParameter=function(t,e){i[t]=e},this.setParameters=function(t){i=t},this.overlayPlacements=[];var u=t.beforeDetach;this.isDetachAllowed=function(t){var n=e._jsPlumb.checkCondition("beforeDetach",t);if(u){try{n=u(t)}catch(r){y("jsPlumb: beforeDetach callback failed",r)}}return n};var c=t.beforeDrop;this.isDropAllowed=function(t,n,r,i,o){var a=e._jsPlumb.checkCondition("beforeDrop",{sourceId:t,targetId:n,scope:r,connection:i,dropEndpoint:o});if(c){try{a=c({sourceId:t,targetId:n,scope:r,connection:i,dropEndpoint:o})}catch(s){y("jsPlumb: beforeDrop callback failed",s)}}return a};var f=function(){if(s&&l){var t={};M.extend(t,s);M.extend(t,l);delete e.hoverPaintStyle;if(t.gradient&&s.fillStyle){delete t.gradient}l=t}};this.setPaintStyle=function(t,n){s=t;e.paintStyleInUse=s;f();if(!n){e.repaint()}};this.getPaintStyle=function(){return s};this.setHoverPaintStyle=function(t,n){l=t;f();if(!n){e.repaint()}};this.getHoverPaintStyle=function(){return l};this.setHover=function(t,n,i){if(!e._jsPlumb.currentlyDragging&&!e._jsPlumb.isHoverSuspended()){r=t;if(e.hoverClass!=null&&e.canvas!=null){if(t){p.addClass(e.canvas,e.hoverClass)}else{p.removeClass(e.canvas,e.hoverClass)}}if(l!=null){e.paintStyleInUse=t?l:s;i=i||E();e.repaint({timestamp:i,recalc:false})}if(e.getAttachedElements&&!n){b(t,E(),e)}}};this.isHover=function(){return r};var h=null;this.setZIndex=function(t){h=t};this.getZIndex=function(){return h};var p=M.CurrentLibrary,d=["click","dblclick","mouseenter","mouseout","mousemove","mousedown","mouseup","contextmenu"],v={mouseout:"mouseexit"},m=function(t,e,n){var r=v[n]||n;p.bind(t,n,function(t){e.fire(r,e,t)})},g=function(t,e){var n=v[e]||e;p.unbind(t,e)};this.attachListeners=function(t,e){for(var n=0;n1){for(var n=0;n=0?e.overlays[n]:null};this.getOverlays=function(){return e.overlays};this.hideOverlay=function(t){var n=e.getOverlay(t);if(n){n.hide()}};this.hideOverlays=function(){for(var t=0;t0){try{for(var i=0;i0?e(t,n)!=-1:!r};this.getConnections=function(t,e){if(!t){t={}}else{if(t.constructor==String){t={scope:t}}}var n=t.scope||b.getDefaultScope(),r=De(n,true),i=De(t.source),o=De(t.target),a=!e&&r.length>1?{}:[],s=function(t,n){if(!e&&r.length>1){var i=a[t];if(i==null){i=[];a[t]=i}i.push(n)}else{a.push(n)}};for(var l in T){if(Se(r,l)){for(var u=0;u0&&!d.isSource,m=h&&i.length>0&&!d.isTarget;if(v||m){continue t}a.push(d)}}}}return Ae(a)};this.getAllConnections=function(){return T};this.getDefaultScope=function(){return B};this.getEndpoint=J;this.getEndpoints=function(t){return _[me(t)]};this.getId=me;this.getOffset=function(t){var e=F[t];return de({elId:t})};this.getSelector=function(t){return M.CurrentLibrary.getSelector(t)};this.getSize=function(t){var e=R[t];if(!e){de({elId:t})}return R[t]};this.appendElement=Z;var we=false;this.isHoverSuspended=function(){return we};this.setHoverSuspended=function(t){we=t};var ke=function(t){return function(){return jsPlumbAdapter.isRenderModeAvailable(t)}};this.isCanvasAvailable=ke("canvas");this.isSVGAvailable=ke("svg");this.isVMLAvailable=ke("vml");this.hide=function(t,e){fe(t,"none",e)};this.idstamp=Y;this.init=function(){if(!k){b.setRenderMode(b.Defaults.RenderMode);var t=function(t){M.CurrentLibrary.bind(document,t,function(e){if(!b.currentlyDragging&&z==M.CANVAS){for(var n in T){var r=T[n];for(var i=0;i=4?[t[2],t[3]]:[0,0],offsets:t.length==6?[t[4],t[5]]:[0,0],elementId:e};r=new Je(o);r.clone=function(){return new Je(o)}}}}}if(!r.id){r.id="anchor_"+Y()}return r};this.makeAnchors=function(t,e,n){var r=[];for(var i=0;i0&&o>=Fe[e]){if(l){l({element:t,connection:h},n)}return false}p.anchor.locked=false;if(f){i.setDragScope(s,f)}var y=proxyComponent.isDropAllowed(h.sourceId,me(t),h.scope,h,null);if(h.endpointsToDeleteOnDetach){if(p===h.endpointsToDeleteOnDetach[0]){h.endpointsToDeleteOnDetach[0]=null}else{if(p===h.endpointsToDeleteOnDetach[1]){h.endpointsToDeleteOnDetach[1]=null}}}if(h.suspendedEndpoint){h.targetId=h.suspendedEndpoint.elementId;h.target=i.getElementObject(h.suspendedEndpoint.elementId);h.endpoints[1]=h.suspendedEndpoint}if(y){p.detach(h,false,true,false);var P=_e[e]||b.addEndpoint(t,r);if(r.uniqueEndpoint){_e[e]=P}P._makeTargetCreator=true;if(P.anchor.positionFinder!=null){var C=i.getUIPosition(arguments,b.getZoom()),j=m(t,b),E=g(t),x=P.anchor.positionFinder(C,j,E,P.anchor.constructorParams);P.anchor.x=x[0];P.anchor.y=x[1]}var D=b.connect({source:p,target:P,scope:f,previousConnection:h,container:h.parent,deleteEndpointsOnDetach:a,doNotFireConnectionEvent:p.endpointWillMoveAfterConnection});if(h.endpoints[1]._makeTargetCreator&&h.endpoints[1].connections.length<2){b.deleteEndpoint(h.endpoints[1])}if(a){D.endpointsToDeleteOnDetach=[p,P]}D.repaint()}else{if(h.suspendedEndpoint){if(p.isReattach){h.setHover(false);h.floatingAnchorIndex=null;h.suspendedEndpoint.addConnection(h);b.repaint(p.elementId)}else{p.detach(h,false,true,true,n)}}}};var f=i.dragEvents.drop;n.scope=n.scope||o;n[f]=ge(n[f],u);i.initDroppable(t,n,true)};t=X(t);var u=t.length&&t.constructor!=String?t:[t];for(var f=0;f=0&&l>=ze[u]){if(s){s({element:t,maxConnections:a},n)}return false}if(e.filter){var c=e.filter(o.getOriginalEvent(n),t);if(c===false){return}}var f=de({elId:r});var p=((n.pageX||n.page.x)-f.left)/f.width,d=((n.pageY||n.page.y)-f.top)/f.height,g=p,y=d;if(i.parent){var P=o.getElementObject(i.parent),C=me(P);f=de({elId:C});g=((n.pageX||n.page.x)-f.left)/f.width,y=((n.pageY||n.page.y)-f.top)/f.height}var j={};M.extend(j,i);j.isSource=true;j.anchor=[p,d,0,0];j.parentAnchor=[g,y,0,0];j.dragOptions=h;if(i.parent){var E=j.container||b.Defaults.Container||M.Defaults.Container;if(E){j.container=E}else{j.container=M.CurrentLibrary.getParent(i.parent)}}v=b.addEndpoint(r,j);m=true;v.endpointWillMoveAfterConnection=i.parent!=null;v.endpointWillMoveTo=i.parent?o.getElementObject(i.parent):null;var x=function(){if(m){b.deleteEndpoint(v)}};b.registerListener(v.canvas,"mouseup",x);b.registerListener(t,"mouseup",x);o.trigger(v.canvas,"mousedown",n)};b.registerListener(t,"mousedown",g);Be[r]=g};t=X(t);var u=t.length&&t.constructor!=String?t:[t];for(var c=0;c0?r[0]:null,l=r.length>0?0:-1,i=this,u=function(t,e,n,r,i){var o=r[0]+t.x*i[0],a=r[1]+t.y*i[1];return Math.sqrt(Math.pow(e-o,2)+Math.pow(n-a,2))},c=e||function(t,e,n,r,i){var o=n[0]+r[0]/2,a=n[1]+r[1]/2;var s=-1,l=Infinity;for(var c=0;c=r.left||n.left<=r.right&&n.right>=r.right||n.left<=r.left&&n.right>=r.right||r.left<=n.left&&r.right>=n.right,s=n.top<=r.top&&n.bottom>=r.top||n.top<=r.bottom&&n.bottom>=r.bottom||n.top<=r.top&&n.bottom>=r.bottom||r.top<=n.top&&r.bottom>=n.bottom;if(!(a||s)){var l=null,u=false,c=false,f=null;if(r.left>n.left&&r.top>n.top){l=["right","top"]}else{if(r.left>n.left&&n.top>r.top){l=["top","left"]}else{if(r.leftn.top){l=["left","top"]}}}}return{orientation:on.DIAGONAL,a:l,theta:i,theta2:o}}else{if(a){return{orientation:on.HORIZONTAL,a:n.tope[0]?1:-1},un=function(t){return function(e,n){var r=true;if(t){if(e[0][0]n[0][1]}}else{if(e[0][0]>n[0][0]){r=true}else{r=e[0][1]>n[0][1]}}return r===false?-1:1}},cn=function(t,e){var n=t[0][0]<0?-Math.PI-t[0][0]:Math.PI-t[0][0],r=e[0][0]<0?-Math.PI-e[0][0]:Math.PI-e[0][0];if(n>r){return 1}else{return t[0][1]>e[0][1]?1:-1}},fn={top:ln,right:un(true),bottom:un(true),left:cn},hn=function(t,e){return t.sort(e)},pn=function(t,e){var n=R[t],r=F[t],i=function(e,n,r,i,o,a,s){if(i.length>0){var l=hn(i,fn[e]),u=e==="right"||e==="top",c=sn(e,n,r,l,o,a,u);var f=function(t,e){var n=Qe([e[0],e[1]],t.canvas);nn[t.id]=[n[0],n[1],e[2],e[3]];rn[t.id]=s};for(var h=0;h0){r.connections[0].setHover(t,false)}else{r.setHover(t)}};S(r.endpoint,r,x);this.setPaintStyle(e.paintStyle||e.style||b.Defaults.EndpointStyle||M.Defaults.EndpointStyle,true);this.setHoverPaintStyle(e.hoverPaintStyle||b.Defaults.EndpointHoverStyle||M.Defaults.EndpointHoverStyle,true);this.paintStyleInUse=this.getPaintStyle();var I=this.getPaintStyle();this.connectorStyle=e.connectorStyle;this.connectorHoverStyle=e.connectorHoverStyle;this.connectorOverlays=e.connectorOverlays;this.connector=e.connector;this.connectorTooltip=e.connectorTooltip;this.connectorClass=e.connectorClass;this.connectorHoverClass=e.connectorHoverClass;this.isSource=e.isSource||false;this.isTarget=e.isTarget||false;var O=e.maxConnections||b.Defaults.MaxConnections;this.getAttachedElements=function(){return r.connections};this.canvas=this.endpoint.canvas;this.connections=e.connections||[];this.scope=e.scope||B;this.connectionType=e.connectionType;this.timestamp=null;r.isReattach=e.reattach||false;r.connectionsDetachable=b.Defaults.ConnectionsDetachable;if(e.connectionsDetachable===false||e.detachable===false){r.connectionsDetachable=false}var L=e.dragAllowedWhenFull||true;if(e.onMaxConnections){r.bind("maxConnections",e.onMaxConnections)}this.computeAnchor=function(t){return r.anchor.compute(t)};this.addConnection=function(t){r.connections.push(t)};this.detach=function(e,i,o,a,s){var l=t(r.connections,function(t){return t.id==e.id}),u=false;a=a!==false;if(l>=0){if(o||e._forceDetach||e.isDetachable()||e.isDetachAllowed(e)){var c=e.endpoints[0]==r?e.endpoints[1]:e.endpoints[0];if(o||e._forceDetach||r.isDetachAllowed(e)){r.connections.splice(l,1);if(!i){c.detach(e,true,o);if(e.endpointsToDeleteOnDetach){for(var f=0;f0){r.detach(r.connections[0],false,true,t,e) }};this.detachFrom=function(t,e,n){var i=[];for(var o=0;o=0){r.connections.splice(n,1)}};this.getElement=function(){return u};this.setElement=function(t,e){var i=me(t);n(_[r.elementId],function(t){return t.id==r.id});u=v(t);g=me(u);r.elementId=g;var o=ie({source:i,container:e}),a=q.getParent(r.canvas);q.removeElement(r.canvas,a);q.appendElement(r.canvas,o);for(var s=0;s0){var u=A(t.elementWithPrecedence),c=u.endpoints[0]==r?1:0,f=c==0?u.sourceId:u.targetId,h=F[f],p=R[f];l.txy=[h.left,h.top];l.twh=p;l.tElement=u.endpoints[c]}o=r.anchor.compute(l)}var d=C.compute(o,r.anchor.getOrientation(r),r.paintStyleInUse,a||r.paintStyleInUse);C.paint(d,r.paintStyleInUse,r.anchor);r.timestamp=e;for(var v=0;v0?t:d+t:t*d;return jsPlumbUtil.pointOnLine({x:u,y:c},{x:f,y:h},n)}}};this.gradientAtPoint=function(t){return n};this.pointAlongPathFrom=function(e,n,r){var i=t.pointOnPath(e,r),o=e==1?{x:u+(f-u)*10,y:c+(c-h)*10}:{x:f,y:h};return jsPlumbUtil.pointOnLine(i,o,n)}};jsPlumb.Connectors.Bezier=function(t){var e=this;t=t||{};this.majorAnchor=t.curviness||150;this.minorAnchor=10;var n=null;this.type="Bezier";this._findControlPoint=function(t,n,r,i,o,a,s){var l=a.getOrientation(i),u=s.getOrientation(o),c=l[0]!=u[0]||l[1]==u[1],f=[],h=e.majorAnchor,p=e.minorAnchor;if(!c){if(l[0]==0){f.push(n[0]f){f=D}if(j<0){u+=j;var S=Math.abs(j);f+=S;r[0]+=S;o+=S;a+=S;i[0]+=S}var I=Math.min(l,s),O=Math.min(r[1],i[1]),L=Math.min(I,O),M=Math.max(l,s),A=Math.max(r[1],i[1]),w=Math.max(M,A);if(w>h){h=w}if(L<0){c+=L;var k=Math.abs(L);h+=k;r[1]+=k;l+=k;s+=k;i[1]+=k}if(b&&f0?0:1,e)}return e};this.pointOnPath=function(t,e){var n=g();t=y(n,t,e);return jsBezier.pointOnCurve(n,t)};this.gradientAtPoint=function(t,e){var n=g();t=y(n,t,e);return jsBezier.gradientAtPoint(n,t)};this.pointAlongPathFrom=function(t,e,n){var r=g();t=y(r,t,n);return jsBezier.pointAlongCurveFrom(r,t,e)}};jsPlumb.Connectors.Flowchart=function(t){this.type="Flowchart";t=t||{};var e=this,n=t.stub||t.minStubLength||30,r=jsPlumbUtil.isArray(n)?n[0]:n,i=jsPlumbUtil.isArray(n)?n[1]:n,o=t.gap||0,a=[],s=0,l=[],u=[],c=[],f,h,p=-Infinity,d=-Infinity,v=Infinity,m=Infinity,g=t.grid,y=function(t,e){var n=t%e,r=Math.floor(t/e),i=n>e/2?1:0;return(r+i)*e},b=function(t,e,n,r){return[n||g==null?t:y(t,g[0]),r||g==null?e:y(e,g[1])]},P=function(t,e,n,r){var i=0;for(var o=0;o0?t/s:(s+t)/s}var n=l.length-1,r=1;for(var i=0;i=t){n=i;r=(t-l[i][0])/u[i];break}}return{segment:a[n],proportion:r,index:n}};this.compute=function(t,e,n,g,y,b,E,x,D,S){a=[];l=[];s=0;u=[];p=d=-Infinity;v=m=Infinity;f=e[0]F?0:1,N=[1,0][H];w=[];k=[];w[H]=t[H]>e[H]?-1:1;k[H]=t[H]>e[H]?1:-1;w[N]=0;k[N]=0}var W=f?U-L+o*w[0]:O+o*w[0],V=h?F-A+o*w[1]:M+o*w[1],R=f?O+o*k[0]:U-L+o*k[0],B=h?M+o*k[1]:F-A+o*k[1],z=W+w[0]*r,G=V+w[1]*r,Z=R+k[0]*i,q=B+k[1]*i,Y=Math.abs(W-R)>r+i,X=Math.abs(V-B)>r+i,K=z+(Z-z)/2,Q=G+(q-G)/2,J=w[0]*k[0]+w[1]*k[1],$=J==-1,te=J==0,ee=J==1;T-=O;_-=M;c=[T,_,U,F,W,V,R,B];var ne=[];var re=w[0]==0?"y":"x",ie=$?"opposite":ee?"orthogonal":"perpendicular",oe=jsPlumbUtil.segment([W,V],[R,B]),ae=w[re=="x"?0:1]==-1,se={x:[null,4,3,2,1],y:[null,2,1,4,3]};if(ae){oe=se[re][oe]}j(z,G,W,V,R,B);var le=function(t,e,n,o){return t+(e*(1-n)*o+Math.max(r,i))},ue={oppositex:function(){if(n.elementId==g.elementId){var t=G+(1-y.y)*D.height+Math.max(r,i);return[[z,t],[Z,t]]}else{if(Y&&(oe==1||oe==2)){return[[K,V],[K,B]]}else{return[[z,Q],[Z,Q]]}}},orthogonalx:function(){if(oe==1||oe==2){return[[Z,G]]}else{return[[z,q]]}},perpendicularx:function(){var t=(B+V)/2;if(oe==1&&k[1]==1||oe==2&&k[1]==-1){if(Math.abs(R-W)>Math.max(r,i)){return[[Z,G]]}else{return[[z,G],[z,t],[Z,t]]}}else{if(oe==3&&k[1]==-1||oe==4&&k[1]==1){return[[z,t],[Z,t]]}else{if(oe==3&&k[1]==1||oe==4&&k[1]==-1){return[[z,q]]}else{if(oe==1&&k[1]==-1||oe==2&&k[1]==1){if(Math.abs(R-W)>Math.max(r,i)){return[[K,G],[K,q]]}else{return[[z,q]]}}}}}},oppositey:function(){if(n.elementId==g.elementId){var t=z+(1-y.x)*D.width+Math.max(r,i);return[[t,G],[t,q]]}else{if(X&&(oe==2||oe==3)){return[[W,Q],[R,Q]]}else{return[[K,G],[K,q]]}}},orthogonaly:function(){if(oe==2||oe==3){return[[z,q]]}else{return[[Z,G]]}},perpendiculary:function(){var t=(R+W)/2;if(oe==2&&k[0]==-1||oe==3&&k[0]==1){if(Math.abs(R-W)>Math.max(r,i)){return[[z,q]]}else{return[[z,Q],[Z,Q]]}}else{if(oe==1&&k[0]==-1||oe==4&&k[0]==1){var t=(R+W)/2;return[[t,G],[t,q]]}else{if(oe==1&&k[0]==1||oe==4&&k[0]==-1){return[[Z,G]]}else{if(oe==2&&k[0]==1||oe==3&&k[0]==-1){if(Math.abs(B-V)>Math.max(r,i)){return[[z,Q],[Z,Q]]}else{return[[Z,G]]}}}}}}};var ce=ue[ie+re]();if(ce){for(var fe=0;fec[3]){c[3]=d+E*2}if(p>c[2]){c[2]=p+E*2}return c};this.pointOnPath=function(t,n){return e.pointAlongPathFrom(t,0,n)};this.gradientAtPoint=function(t,e){return a[E(t,e)["index"]][4]};this.pointAlongPathFrom=function(t,e,n){var r=E(t,n),i=r.segment,o=r.proportion,s=a[r.index][5],l=a[r.index][4];var u={x:l==Infinity?i[2]:i[2]>i[0]?i[0]+(1-o)*s-e:i[2]+o*s+e,y:l==0?i[3]:i[3]>i[1]?i[1]+(1-o)*s-e:i[3]+o*s+e,segmentInfo:r};return u}};jsPlumb.Endpoints.Dot=function(t){this.type="Dot";var e=this;t=t||{};this.radius=t.radius||10;this.defaultOffset=.5*this.radius;this.defaultInnerRadius=this.radius/3;this.compute=function(t,n,r,i){var o=r.radius||e.radius,a=t[0]-o,s=t[1]-o;return[a,s,o*2,o*2,o]}};jsPlumb.Endpoints.Rectangle=function(t){this.type="Rectangle";var e=this;t=t||{};this.width=t.width||20;this.height=t.height||20;this.compute=function(t,n,r,i){var o=r.width||e.width,a=r.height||e.height,s=t[0]-o/2,l=t[1]-a/2;return[s,l,o,a]}};var t=function(t){jsPlumb.DOMElementComponent.apply(this,arguments);var e=this;var n=[];this.getDisplayElements=function(){return n};this.appendDisplayElement=function(t){n.push(t)}};jsPlumb.Endpoints.Image=function(e){this.type="Image";t.apply(this,arguments);var n=this,r=false,i=false,o=e.width,a=e.height,s=null,l=e.endpoint;this.img=new Image;n.ready=false;this.img.onload=function(){n.ready=true;o=o||n.img.width;a=a||n.img.height;if(s){s(n)}};l.setImage=function(t,e){var r=t.constructor==String?t:t.src;s=e;n.img.src=t;if(n.canvas!=null){n.canvas.setAttribute("src",t)}};l.setImage(e.src||e.url,e.onload);this.compute=function(t,e,r,i){n.anchorPoint=t;if(n.ready){return[t[0]-o/2,t[1]-a/2,o,a]}else{return[0,0,0,0]}};n.canvas=document.createElement("img"),r=false;n.canvas.style.margin=0;n.canvas.style.padding=0;n.canvas.style.outline=0;n.canvas.style.position="absolute";var u=e.cssClass?" "+e.cssClass:"";n.canvas.className=jsPlumb.endpointClass+u;if(o){n.canvas.setAttribute("width",o)}if(a){n.canvas.setAttribute("height",a)}jsPlumb.appendElement(n.canvas,e.parent);n.attachListeners(n.canvas,n);n.cleanup=function(){i=true};var c=function(t,e,s){if(!i){if(!r){n.canvas.setAttribute("src",n.img.src);n.appendDisplayElement(n.canvas);r=true}var l=n.anchorPoint[0]-o/2,u=n.anchorPoint[1]-a/2;jsPlumb.sizeCanvas(n.canvas,l,u,o,a)}};this.paint=function(t,e,r){if(n.ready){c(t,e,r)}else{window.setTimeout(function(){n.paint(t,e,r)},200)}}};jsPlumb.Endpoints.Blank=function(e){var n=this;this.type="Blank";t.apply(this,arguments);this.compute=function(t,e,n,r){return[t[0],t[1],10,0]};n.canvas=document.createElement("div");n.canvas.style.display="block";n.canvas.style.width="1px";n.canvas.style.height="1px";n.canvas.style.background="transparent";n.canvas.style.position="absolute";n.canvas.className=n._jsPlumb.endpointClass;jsPlumb.appendElement(n.canvas,e.parent);this.paint=function(t,e,r){jsPlumb.sizeCanvas(n.canvas,t[0],t[1],t[2],t[3])}};jsPlumb.Endpoints.Triangle=function(t){this.type="Triangle";t=t||{};t.width=t.width||55;t.height=t.height||55;this.width=t.width;this.height=t.height;this.compute=function(t,e,n,r){var i=n.width||self.width,o=n.height||self.height,a=t[0]-i/2,s=t[1]-o/2;return[a,s,i,o]}};var e=function(t){var e=true,n=this;this.isAppendedAtTopLevel=true;this.component=t.component;this.loc=t.location==null?.5:t.location;this.endpointLoc=t.endpointLocation==null?[.5,.5]:t.endpointLocation;this.setVisible=function(t){e=t;n.component.repaint()};this.isVisible=function(){return e};this.hide=function(){n.setVisible(false)};this.show=function(){n.setVisible(true)};this.incrementLocation=function(t){n.loc+=t;n.component.repaint()};this.setLocation=function(t){n.loc=t;n.component.repaint()};this.getLocation=function(){return n.loc}};jsPlumb.Overlays.Arrow=function(t){this.type="Arrow";e.apply(this,arguments);this.isAppendedAtTopLevel=false;t=t||{};var n=this;this.length=t.length||20;this.width=t.width||20;this.id=t.id;var r=(t.direction||1)<0?-1:1,i=t.paintStyle||{lineWidth:1},o=t.foldback||.623;this.computeMaxSize=function(){return n.width*1.5};this.cleanup=function(){};this.draw=function(t,e,a){var s,l,u,c,f;if(t.pointAlongPathFrom){if(jsPlumbUtil.isString(n.loc)||n.loc>1||n.loc<0){var h=parseInt(n.loc);s=t.pointAlongPathFrom(h,r*n.length/2,true),l=t.pointOnPath(h,true),u=jsPlumbUtil.pointOnLine(s,l,n.length)}else{if(n.loc==1){s=t.pointOnPath(n.loc);l=t.pointAlongPathFrom(n.loc,-1);u=jsPlumbUtil.pointOnLine(s,l,n.length)}else{if(n.loc==0){u=t.pointOnPath(n.loc);l=t.pointAlongPathFrom(n.loc,1);s=jsPlumbUtil.pointOnLine(u,l,n.length)}else{s=t.pointAlongPathFrom(n.loc,r*n.length/2),l=t.pointOnPath(n.loc),u=jsPlumbUtil.pointOnLine(s,l,n.length)}}}c=jsPlumbUtil.perpendicularLineTo(s,u,n.width);f=jsPlumbUtil.pointOnLine(s,u,o*n.length);var p=Math.min(s.x,c[0].x,c[1].x),d=Math.max(s.x,c[0].x,c[1].x),v=Math.min(s.y,c[0].y,c[1].y),m=Math.max(s.y,c[0].y,c[1].y);var g={hxy:s,tail:c,cxy:f},y=i.strokeStyle||e.strokeStyle,b=i.fillStyle||e.strokeStyle,P=i.lineWidth||e.lineWidth;n.paint(t,g,P,y,b,a);return[p,d,v,m]}else{return[0,0,0,0]}}};jsPlumb.Overlays.PlainArrow=function(t){t=t||{};var e=jsPlumb.extend(t,{foldback:1});jsPlumb.Overlays.Arrow.call(this,e);this.type="PlainArrow"};jsPlumb.Overlays.Diamond=function(t){t=t||{};var e=t.length||40,n=jsPlumb.extend(t,{length:e/2,foldback:2});jsPlumb.Overlays.Arrow.call(this,n);this.type="Diamond"};var n=function(t){jsPlumb.DOMElementComponent.apply(this,arguments);e.apply(this,arguments);var n=this,r=false;t=t||{};this.id=t.id;var i;var o=function(){i=t.create(t.component);i=jsPlumb.CurrentLibrary.getDOMElement(i);i.style.position="absolute";var e=t._jsPlumb.overlayClass+" "+(n.cssClass?n.cssClass:t.cssClass?t.cssClass:"");i.className=e;jsPlumb.appendElement(i,t.component.parent);t._jsPlumb.getId(i);n.attachListeners(i,n);n.canvas=i};this.getElement=function(){if(i==null){o()}return i};this.getDimensions=function(){return jsPlumb.CurrentLibrary.getSize(jsPlumb.CurrentLibrary.getElementObject(n.getElement()))};var a=null,s=function(t){if(a==null){a=n.getDimensions()}return a};this.clearCachedDimensions=function(){a=null};this.computeMaxSize=function(){var t=s();return Math.max(t[0],t[1])};var l=n.setVisible;n.setVisible=function(t){l(t);i.style.display=t?"block":"none"};this.cleanup=function(){if(i!=null){jsPlumb.CurrentLibrary.removeElement(i)}};this.paint=function(t,e,o){if(!r){n.getElement();t.appendDisplayElement(i);n.attachListeners(i,t);r=true}i.style.left=o[0]+e.minx+"px";i.style.top=o[1]+e.miny+"px"};this.draw=function(t,e,r){var i=s();if(i!=null&&i.length==2){var o={x:0,y:0};if(t.pointOnPath){var a=n.loc,l=false;if(jsPlumbUtil.isString(n.loc)||n.loc<0||n.loc>1){a=parseInt(n.loc);l=true}o=t.pointOnPath(a,l)}else{var u=n.loc.constructor==Array?n.loc:n.endpointLoc;o={x:u[0]*r[2],y:u[1]*r[3]}}minx=o.x-i[0]/2,miny=o.y-i[1]/2;n.paint(t,{minx:minx,miny:miny,td:i,cxy:o},r);return[minx,minx+i[0],miny,miny+i[1]]}else{return[0,0,0,0]}};this.reattachListeners=function(t){if(i){n.reattachListenersForElement(i,n,t)}}};jsPlumb.Overlays.Custom=function(t){this.type="Custom";n.apply(this,arguments)};jsPlumb.Overlays.Label=function(t){var e=this;this.labelStyle=t.labelStyle||jsPlumb.Defaults.LabelStyle;this.cssClass=this.labelStyle!=null?this.labelStyle.cssClass:null;t.create=function(){return document.createElement("div")};jsPlumb.Overlays.Custom.apply(this,arguments);this.type="Label";var n=t.label||"",e=this,r=null;this.setLabel=function(t){n=t;r=null;e.clearCachedDimensions();i();e.component.repaint()};var i=function(){if(typeof n=="function"){var t=n(e);e.getElement().innerHTML=t.replace(/\r\n/g,"
")}else{if(r==null){r=n;e.getElement().innerHTML=r.replace(/\r\n/g,"
")}}};this.getLabel=function(){return n};var o=this.getDimensions;this.getDimensions=function(){i();return o()}}})();(function(){var t=function(t,e,n,r){this.m=(r-e)/(n-t);this.b=-1*(this.m*t-e);this.rectIntersect=function(t,e,n,r){var i=[];var o=(e-this.b)/this.m;if(o>=t&&o<=t+n){i.push([o,this.m*o+this.b])}var a=this.m*(t+n)+this.b;if(a>=e&&a<=e+r){i.push([(a-this.b)/this.m,a])}var o=(e+r-this.b)/this.m;if(o>=t&&o<=t+n){i.push([o,this.m*o+this.b])}var a=this.m*t+this.b;if(a>=e&&a<=e+r){i.push([(a-this.b)/this.m,a])}if(i.length==2){var s=(i[0][0]+i[1][0])/2,l=(i[0][1]+i[1][1])/2;i.push([s,l]);var u=s<=t+n/2?-1:1,c=l<=e+r/2?-1:1;i.push([u,c]);return i}return null}},e=function(t,e,n,r){if(t<=n&&r<=e){return 1}else{if(t<=n&&e<=r){return 2}else{if(n<=t&&r>=e){return 3}}}return 4},n=function(t,e,n,r,i,o,a,s,l){if(s<=l){return[t,e]}if(n==1){if(r[3]<=0&&i[3]>=1){return[t+(r[2]<.5?-1*o:o),e]}else{if(r[2]>=1&&i[2]<=0){return[t,e+(r[3]<.5?-1*a:a)]}else{return[t+-1*o,e+-1*a]}}}else{if(n==2){if(r[3]>=1&&i[3]<=0){return[t+(r[2]<.5?-1*o:o),e]}else{if(r[2]>=1&&i[2]<=0){return[t,e+(r[3]<.5?-1*a:a)]}else{return[t+1*o,e+-1*a]}}}else{if(n==3){if(r[3]>=1&&i[3]<=0){return[t+(r[2]<.5?-1*o:o),e]}else{if(r[2]<=0&&i[2]>=1){return[t,e+(r[3]<.5?-1*a:a)]}else{return[t+-1*o,e+-1*a]}}}else{if(n==4){if(r[3]<=0&&i[3]>=1){return[t+(r[2]<.5?-1*o:o),e]}else{if(r[2]<=0&&i[2]>=1){return[t,e+(r[3]<.5?-1*a:a)]}else{return[t+1*o,e+-1*a]}}}}}}};jsPlumb.Connectors.StateMachine=function(t){var r=this,i=null,o,a,s,l,u=[],c=t.curviness||10,f=t.margin||5,h=t.proximityLimit||80,p=t.orientation&&t.orientation=="clockwise",d=t.loopbackRadius||25,v=false,m=t.showLoopback!==false;this.type="StateMachine";t=t||{};this.compute=function(t,r,g,y,b,P,C,j){var E=Math.abs(t[0]-r[0]),x=Math.abs(t[1]-r[1]),D=.45*E,S=.45*x;E*=1.9;x*=1.9;C=C||1;var I=Math.min(t[0],r[0])-D,O=Math.min(t[1],r[1])-S;if(!m||g.elementId!=y.elementId){v=false;o=t[0]0?0:1,e)}return e};this.pointOnPath=function(t,e){if(v){if(e){var n=Math.PI*2*d;t=t/n}if(t>0&&t<1){t=1-t}var r=t*2*Math.PI+Math.PI/2,o=i[4]+i[6]*Math.cos(r),a=i[5]+i[6]*Math.sin(r);return{x:o,y:a}}else{var s=g();t=y(s,t,e);return jsBezier.pointOnCurve(s,t)}};this.gradientAtPoint=function(t,e){if(v){if(e){var n=Math.PI*2*d;t=t/n}return Math.atan(t*2*Math.PI)}else{var r=g();t=y(r,t,e);return jsBezier.gradientAtPoint(r,t)}};this.pointAlongPathFrom=function(t,e,n){if(v){if(n){var r=Math.PI*2*d;t=t/r}if(t>0&&t<1){t=1-t}var r=2*Math.PI*i[6],o=e/r*2*Math.PI,a=t*2*Math.PI-o+Math.PI/2,s=i[4]+i[6]*Math.cos(a),l=i[5]+i[6]*Math.sin(a);return{x:s,y:l}}else{var u=g();t=y(u,t,n);return jsBezier.pointAlongCurveFrom(u,t,e)}}};jsPlumb.Connectors.canvas.StateMachine=function(t){t=t||{};var e=this,n=t.drawGuideline||true,r=t.avoidSelector;jsPlumb.Connectors.StateMachine.apply(this,arguments);jsPlumb.CanvasConnector.apply(this,arguments);this._paint=function(t){if(t.length==10){e.ctx.beginPath();e.ctx.moveTo(t[4],t[5]);e.ctx.bezierCurveTo(t[8],t[9],t[8],t[9],t[6],t[7]);e.ctx.stroke()}else{e.ctx.save();e.ctx.beginPath();var n=0,r=2*Math.PI,i=t[7];e.ctx.arc(t[4],t[5],t[6],0,r,i);e.ctx.stroke();e.ctx.closePath();e.ctx.restore()}};this.createGradient=function(t,e){return e.createLinearGradient(t[4],t[5],t[6],t[7])}};jsPlumb.Connectors.svg.StateMachine=function(){var t=this;jsPlumb.Connectors.StateMachine.apply(this,arguments);jsPlumb.SvgConnector.apply(this,arguments);this.getPath=function(t){if(t.length==10){return"M "+t[4]+" "+t[5]+" C "+t[8]+" "+t[9]+" "+t[8]+" "+t[9]+" "+t[6]+" "+t[7]}else{return"M"+(t[8]+4)+" "+t[9]+" A "+t[6]+" "+t[6]+" 0 1,0 "+(t[8]-4)+" "+t[9]}}};jsPlumb.Connectors.vml.StateMachine=function(){jsPlumb.Connectors.StateMachine.apply(this,arguments);jsPlumb.VmlConnector.apply(this,arguments);var t=jsPlumb.vml.convertValue;this.getPath=function(e){if(e.length==10){return"m"+t(e[4])+","+t(e[5])+" c"+t(e[8])+","+t(e[9])+","+t(e[8])+","+t(e[9])+","+t(e[6])+","+t(e[7])+" e"}else{var n=t(e[8]-e[6]),r=t(e[9]-2*e[6]),i=n+t(2*e[6]),o=r+t(2*e[6]),a=n+","+r+","+i+","+o;var s="ar "+a+","+t(e[8])+","+t(e[9])+","+t(e[8])+","+t(e[9])+" e";return s}}}})();(function(){var t={"stroke-linejoin":"joinstyle",joinstyle:"joinstyle",endcap:"endcap",miterlimit:"miterlimit"},e=null;if(document.createStyleSheet&&document.namespaces){var n=[".jsplumb_vml","jsplumb\\:textbox","jsplumb\\:oval","jsplumb\\:rect","jsplumb\\:stroke","jsplumb\\:shape","jsplumb\\:group"],r="behavior:url(#default#VML);position:absolute;";e=document.createStyleSheet();for(var i=0;i0&&l>0&&s=s&&c[2]<=l&&c[3]>=l){return true}}var f=a.canvas.getContext("2d").getImageData(parseInt(s),parseInt(l),1,1);return f.data[0]!=0||f.data[1]!=0||f.data[2]!=0||f.data[3]!=0}return false};var s=false,l=false,u=null,c=false,f=function(t,n){return t!=null&&e(t,n)};this.mousemove=function(e){var n=i(e),r=o(e),l=document.elementFromPoint(r[0],r[1]),u=f(l,"_jsPlumb_overlay");var c=t==null&&(f(l,"_jsPlumb_endpoint")||f(l,"_jsPlumb_connector"));if(!s&&c&&a._over(e)){s=true;a.fire("mouseenter",a,e);return true}else{if(s&&(!a._over(e)||!c)&&!u){s=false;a.fire("mouseexit",a,e)}}a.fire("mousemove",a,e)};this.click=function(t){if(s&&a._over(t)&&!c){a.fire("click",a,t)}c=false};this.dblclick=function(t){if(s&&a._over(t)&&!c){a.fire("dblclick",a,t)}c=false};this.mousedown=function(t){if(a._over(t)&&!l){l=true;u=r(n(a.canvas));a.fire("mousedown",a,t)}};this.mouseup=function(t){l=false;a.fire("mouseup",a,t)};this.contextmenu=function(t){if(s&&a._over(t)&&!c){a.fire("contextmenu",a,t)}c=false}};var s=function(t){var e=document.createElement("canvas");t._jsPlumb.appendElement(e,t.parent);e.style.position="absolute";if(t["class"]){e.className=t["class"]}t._jsPlumb.getId(e,t.uuid);if(t.tooltip){e.setAttribute("title",t.tooltip)}return e};var l=function(t){a.apply(this,arguments);var e=[];this.getDisplayElements=function(){return e};this.appendDisplayElement=function(t){e.push(t)}};var u=jsPlumb.CanvasConnector=function(t){l.apply(this,arguments);var e=function(t,e){n.ctx.save();jsPlumb.extend(n.ctx,e);if(e.gradient){var r=n.createGradient(t,n.ctx);for(var i=0;i0?e[0].tagName:null},getUIPosition:function(t,e){e=e||1;if(t.length==1){ret={left:t[0].pageX,top:t[0].pageY}}else{var n=t[1],r=n.offset;ret=r||n.absolutePosition;n.position.left/=e;n.position.top/=e}return{left:ret.left/e,top:ret.top/e}},hasClass:function(t,e){return t.hasClass(e)},initDraggable:function(t,e,n){e=e||{};e.helper=null;if(n){e.scope=e.scope||jsPlumb.Defaults.Scope}t.draggable(e)},initDroppable:function(t,e){e.scope=e.scope||jsPlumb.Defaults.Scope;t.droppable(e)},isAlreadyDraggable:function(t){t=jsPlumb.CurrentLibrary.getElementObject(t);return t.hasClass("ui-draggable")},isDragSupported:function(t,e){return t.draggable},isDropSupported:function(t,e){return t.droppable},removeClass:function(t,e){t=jsPlumb.CurrentLibrary.getElementObject(t);try{if(t[0].className.constructor==SVGAnimatedString){jsPlumb.util.svg.removeClass(t[0],e)}}catch(n){}t.removeClass(e)},removeElement:function(t,e){jsPlumb.CurrentLibrary.getElementObject(t).remove()},setAttribute:function(t,e,n){t.attr(e,n)},setDraggable:function(t,e){t.draggable("option","disabled",!e)},setDragScope:function(t,e){t.draggable("option","scope",e)},setOffset:function(t,e){jsPlumb.CurrentLibrary.getElementObject(t).offset(e)},trigger:function(t,e,n){var r=jQuery._data(jsPlumb.CurrentLibrary.getElementObject(t)[0],"handle");r(n)},unbind:function(t,e,n){t=jsPlumb.CurrentLibrary.getElementObject(t);t.unbind(e,n)}};t(document).ready(jsPlumb.init)})(jQuery);(function(){"undefined"==typeof Math.sgn&&(Math.sgn=function(t){return 0==t?0:0=64){o[0]=(t[0].x+t[n].x)/2;return 1}var v,f=t[0].y-t[n].y;p=t[n].x-t[0].x;d=t[0].x*t[n].y-t[n].x*t[0].y;h=max_distance_below=0;for(v=1;vh?h=m:m0?1:-1,a=null;i1){e.location=1}if(e.location<0){e.location=0}return u(t,e.location)},nearestPointOnCurve:function(t,e){var r=n(t,e);return{point:i(e,e.length-1,r.location,null,null),location:r.location}},pointOnCurve:s,pointAlongCurveFrom:function(t,e,n){return l(t,e,n).point},perpendicularToCurveAt:function(t,e,n,r){e=l(t,e,r==null?0:r);t=u(t,e.location);r=Math.atan(-1/t);t=n/2*Math.sin(r);n=n/2*Math.cos(r);return[{x:e.point.x+n,y:e.point.y+t},{x:e.point.x-n,y:e.point.y-t}]},locationAlongCurveFrom:function(t,e,n){return l(t,e,n).location}}})();