(function(){var g=function(){var e=this,h=/MSIE/.test(navigator.userAgent)&&!window.opera,o=null,n=function(){d.repaintEverything()},i=true,j={},s={},r=[],A={},E={},J=true,D=[],G="DEFAULT",aa=1200,O={},ba=function(a,b){var c=O[a];if(!c){c={};O[a]=c}b=b||"DEFAULT";var f=c[b];if(!f){f=0;c[b]=f}c[b]++},P=function(a,b,c){var f=function(l,p){if(l===p)return true;else if(typeof l=="object"&&typeof p=="object"){var t=true;for(var u in l)if(!f(l[u],p[u])){t=false;break}for(u in p)if(!f(p[u],l[u])){t=false; break}return t}};c=+c||0;for(var k=a.length;c=0){delete a[c];a.splice(c,1);return true}}return false},ia=function(a,b){var c=B(a,"id");da(c,function(f){f.canvas.style.display=b})},la=function(a){da(a,function(b){b.canvas.style.display="none"==b.canvas.style.display?"block":"none"})},L=function(a,b,c){if(c||b==null){b=v(a);D[a]=ga(b);r[a]=fa(b)}else r[a]=b},H=function(a,b){a=a||function(){};b=b||function(){};return function(){try{b.apply(this,arguments)}catch(c){}try{a.apply(this,arguments)}catch(f){}}}, ja=function(a){var b=this;this.x=a.x||0;this.y=a.y||0;var c=a.orientation||[0,0],f=null;this.offsets=a.offsets||[0,0];this.compute=function(k,l,p){ba("anchor compute");f=[k[0]+b.x*l[0]+b.offsets[0],k[1]+b.y*l[1]+b.offsets[1]];l=p?p.container:null;k={left:0,top:0};if(l!=null){var t=v(l);l=fa(t);p=d.CurrentLibrary.getScrollLeft(t);t=d.CurrentLibrary.getScrollTop(t);k.left=l.left-p;k.top=l.top-t;f[0]-=k.left;f[1]-=k.top}return f};this.getOrientation=function(){return c};this.equals=function(k){if(!k)return false; var l=k.getOrientation(),p=this.getOrientation();return this.x==k.x&&this.y==k.y&&this.offsets[0]==k.offsets[0]&&this.offsets[1]==k.offsets[1]&&p[0]==l[0]&&p[1]==l[1]}},ma=function(a){var b=a.reference,c=ga(v(a.referenceCanvas)),f=0,k=0,l=null;this.compute=function(p){k=f=0;return[p[0]+c[0]/2,p[1]+c[1]/2]};this.getOrientation=function(){if(l)return l;else{var p=b.getOrientation();return[Math.abs(p[0])*f*-1,Math.abs(p[1])*k*-1]}};this.over=function(p){l=p.getOrientation()};this.out=function(){l=null}}, ka=function(a){var b=this,c=new String("_jsplumb_c_"+(new Date).getTime());this.getId=function(){return c};this.container=a.container||e.Defaults.Container;this.source=v(a.source);this.target=v(a.target);this.sourceId=B(this.source,"id");this.targetId=B(this.target,"id");this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.scope=a.scope;this.endpoints=[];this.endpointStyles=[];var f=function(p,t,u,x){if(p){b.endpoints[t]=p;p.addConnection(b)}else{if(!u.endpoints)u.endpoints=[null, null];p=u.endpoints[t]||u.endpoint||e.Defaults.Endpoints[t]||d.Defaults.Endpoints[t]||e.Defaults.Endpoint||d.Defaults.Endpoint||new d.Endpoints.Dot;if(!u.endpointStyles)u.endpointStyles=[null,null];u=new Y({style:u.endpointStyles[t]||u.endpointStyle||e.Defaults.EndpointStyles[t]||d.Defaults.EndpointStyles[t]||e.Defaults.EndpointStyle||d.Defaults.EndpointStyle,endpoint:p,connections:[b],anchor:u.anchors?u.anchors[t]:e.Defaults.Anchors[t]||d.Defaults.Anchors[t]||e.Defaults.Anchor||d.Defaults.Anchor|| d.Anchors.BottomCenter,source:x,container:b.container});return b.endpoints[t]=u}},k=f(a.sourceEndpoint,0,a,b.source);k&&Q(j,this.sourceId,k);(f=f(a.targetEndpoint,1,a,b.target))&&Q(j,this.targetId,f);if(!this.scope)this.scope=this.endpoints[0].scope;this.connector=this.endpoints[0].connector||this.endpoints[1].connector||a.connector||e.Defaults.Connector||d.Defaults.Connector||new d.Connectors.Bezier;this.paintStyle=this.endpoints[0].connectorStyle||this.endpoints[1].connectorStyle||a.paintStyle|| e.Defaults.PaintStyle||d.Defaults.PaintStyle;L(this.sourceId);L(this.targetId);f=r[this.sourceId];k=D[this.sourceId];f=this.endpoints[0].anchor.compute([f.left,f.top],k,this.endpoints[0]);this.endpoints[0].paint(f);f=r[this.targetId];k=D[this.targetId];f=this.endpoints[1].anchor.compute([f.left,f.top],k,this.endpoints[1]);this.endpoints[1].paint(f);var l=ha(d.connectorClass,b.container);this.canvas=l;this.paint=function(p,t,u){o&&o.debug("Painting Connection; element in motion is "+p+"; ui is ["+ t+"]; recalc is ["+u+"]");var x=p!=this.sourceId,F=x?this.sourceId:this.targetId,w=x?0:1,q=x?1:0;if(this.canvas.getContext){L(p,t,u);L(F);u=r[p];t=r[F];p=D[p];var Z=D[F];F=l.getContext("2d");u=this.endpoints[q].anchor.compute([u.left,u.top],p,this.endpoints[q]);this.endpoints[q].anchor.getOrientation();t=this.endpoints[w].anchor.compute([t.left,t.top],Z,this.endpoints[w]);this.endpoints[w].anchor.getOrientation();w=this.connector.compute(u,t,this.endpoints[q].anchor,this.endpoints[w].anchor,this.paintStyle.lineWidth); d.sizeCanvas(l,w[0],w[1],w[2],w[3]);d.extend(F,this.paintStyle);if(this.paintStyle.gradient&&!h){x=x?F.createLinearGradient(w[4],w[5],w[6],w[7]):F.createLinearGradient(w[6],w[7],w[4],w[5]);for(q=0;q=0&&b.connections.splice(m,1)};this.makeInPlaceCopy=function(){return new Y({anchor:b.anchor,source:l,style:k,endpoint:f})};this.isConnectedTo=function(m){var C=false;if(m)for(var y=0;y=t};this.equals=function(m){return this.anchor.equals(m.anchor)&&true};this.paint=function(m,C,y){o&&o.debug("Painting Endpoint with elementId ["+p+"]; anchorPoint is ["+m+"]");if(m==null){m=r[p];var M=D[p];if(m==null||M==null){L(p);m=r[p];M=D[p]}m=b.anchor.compute([m.left,m.top],M,b)}f.paint(m,b.anchor.getOrientation(),y||b.canvas,k,C||k)};if(a.isSource&&d.CurrentLibrary.isDragSupported(l)){var w= null;var q=c=null,Z=false,N=null,z=a.dragOptions||{},K=d.extend({},d.CurrentLibrary.defaultDragOptions);z=d.extend(K,z);z.scope=z.scope||b.scope;K=d.CurrentLibrary.dragEvents.start;var U=d.CurrentLibrary.dragEvents.stop,V=d.CurrentLibrary.dragEvents.drag;z[K]=H(z[K],function(){F=b.makeInPlaceCopy();F.paint();w=document.createElement("div");var m=v(w);document.body.appendChild(w);var C=""+new String((new Date).getTime());X(m,"id",C);L(C);X(v(b.canvas),"dragId",C);X(v(b.canvas),"elId",p);var y=new ma({reference:b.anchor, referenceCanvas:b.canvas});x=new Y({style:{fillStyle:"rgba(0,0,0,0)"},endpoint:f,anchor:y,source:m});q=b.connections.length==0||b.connections.length0)for(var f=0;f0)for(var k=0;k0?P(f,l)!=-1:true){b[l]=[];for(c=0;c0?P(k,p.sourceId)!=-1:true)&&(a.length>0?P(a,p.targetId)!=-1:true)&&b[l].push({sourceId:p.sourceId,targetId:p.targetId})}}return b};this.getDefaultScope=function(){return G};this.hide=function(a){ia(a,"none")};this.makeAnchor=function(a,b){var c= {};if(arguments.length==1)d.extend(c,a);else{c={x:a,y:b};if(arguments.length>=4)c.orientation=[arguments[2],arguments[3]];if(arguments.length==6)c.offsets=[arguments[4],arguments[5]]}var f=new ja(c);f.clone=function(){return new ja(c)};return f};this.repaint=function(a){var b=function(f){f=v(f);R(f)};if(typeof a=="object")for(var c=0;cj)j=o;if(h<0){r+=h;h=Math.abs(h);j+=h;G[0]+=h;E+=h;D+=h;e[0]+=h}h=Math.min(Math.min(J,i),Math.min(G[1], e[1]));o=Math.max(Math.max(J,i),Math.max(G[1],e[1]));if(o>s)s=o;if(h<0){A+=h;h=Math.abs(h);s+=h;G[1]+=h;J+=h;i+=h;e[1]+=h}return[r,A,j,s,E,J,D,i,G[0],G[1],e[0],e[1]]};this.paint=function(e,h){h.beginPath();h.moveTo(e[4],e[5]);h.bezierCurveTo(e[8],e[9],e[10],e[11],e[6],e[7]);h.stroke()}};jsPlumb.Endpoints.Dot=function(g){g=g||{radius:10};var d=this;this.radius=g.radius;var e=0.5*this.radius,h=this.radius/3,o=function(n){try{return parseInt(n)}catch(i){if(n.substring(n.length-1)=="%")return parseInt(n.substring(0, n-1))}};this.paint=function(n,i,j,s,r){var A=s.radius||d.radius;jsPlumb.sizeCanvas(j,n[0]-A,n[1]-A,A*2,A*2);n=j.getContext("2d");j=jsPlumb.extend({},s);if(j.fillStyle==null)j.fillStyle=r.strokeStyle;jsPlumb.extend(n,j);r=/MSIE/.test(navigator.userAgent)&&!window.opera;if(s.gradient&&!r){r=s.gradient;j=e;var E=h;if(r.offset)j=o(r.offset);if(r.innerRadius)E=o(r.innerRadius);r=[j,E];i=n.createRadialGradient(A,A,A,A+(i[0]==1?r[0]*-1:r[0]),A+(i[1]==1?r[0]*-1:r[0]),r[1]);for(r=0;r