/*
  Copyright (c) 2010, Nicolas Garcia Belmonte
  All rights reserved

  > Redistribution and use in source and binary forms, with or without
  > modification, are permitted provided that the following conditions are met:
  >      * Redistributions of source code must retain the above copyright
  >        notice, this list of conditions and the following disclaimer.
  >      * Redistributions in binary form must reproduce the above copyright
  >        notice, this list of conditions and the following disclaimer in the
  >        documentation and/or other materials provided with the distribution.
  >      * Neither the name of the organization nor the
  >        names of its contributors may be used to endorse or promote products
  >        derived from this software without specific prior written permission.
  >
  >  THIS SOFTWARE IS PROVIDED BY NICOLAS GARCIA BELMONTE ``AS IS'' AND ANY
  >  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  >  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  >  DISCLAIMED. IN NO EVENT SHALL NICOLAS GARCIA BELMONTE BE LIABLE FOR ANY
  >  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  >  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  >  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  >  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  >  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  >  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 (function(){window.$jit=function(z){z=z||window;for(var A in $jit){if($jit[A].$extend){z[A]=$jit[A]}}};$jit.version="2.0.0a";var d=function(z){return document.getElementById(z)};d.empty=function(){};d.extend=function(B,z){for(var A in (z||{})){B[A]=z[A]}return B};d.lambda=function(z){return(typeof z=="function")?z:function(){return z}};d.time=Date.now||function(){return +new Date};d.splat=function(A){var z=d.type(A);return z?((z!="array")?[A]:A):[]};d.type=function(A){var z=d.type.s.call(A).match(/^\[object\s(.*)\]$/)[1].toLowerCase();if(z!="object"){return z}if(A&&A.$$family){return A.$$family}return(A&&A.nodeName&&A.nodeType==1)?"element":z};d.type.s=Object.prototype.toString;d.each=function(E,D){var C=d.type(E);if(C=="object"){for(var B in E){D(E[B],B)}}else{for(var A=0,z=E.length;A<z;A++){D(E[A],A)}}};d.indexOf=function(C,B){if(Array.indexOf){return C.indexOf(B)}for(var A=0,z=C.length;A<z;A++){if(C[A]===B){return A}}return -1};d.map=function(B,A){var z=[];d.each(B,function(D,C){z.push(A(D,C))});return z};d.reduce=function(D,B,A){var z=D.length;if(z==0){return A}var C=arguments.length==3?A:D[--z];while(z--){C=B(C,D[z])}return C};d.merge=function(){var D={};for(var C=0,z=arguments.length;C<z;C++){var A=arguments[C];if(d.type(A)!="object"){continue}for(var B in A){var F=A[B],E=D[B];D[B]=(E&&d.type(F)=="object"&&d.type(E)=="object")?d.merge(E,F):d.unlink(F)}}return D};d.unlink=function(B){var A;switch(d.type(B)){case"object":A={};for(var D in B){A[D]=d.unlink(B[D])}break;case"array":A=[];for(var C=0,z=B.length;C<z;C++){A[C]=d.unlink(B[C])}break;default:return B}return A};d.zip=function(){if(arguments.length===0){return[]}for(var B=0,A=[],z=arguments.length,E=arguments[0].length;B<E;B++){for(var C=0,D=[];C<z;C++){D.push(arguments[C][B])}A.push(D)}return A};d.rgbToHex=function(D,C){if(D.length<3){return null}if(D.length==4&&D[3]==0&&!C){return"transparent"}var A=[];for(var z=0;z<3;z++){var B=(D[z]-0).toString(16);A.push(B.length==1?"0"+B:B)}return C?A:"#"+A.join("")};d.hexToRgb=function(B){if(B.length!=7){B=B.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);B.shift();if(B.length!=3){return null}var z=[];for(var A=0;A<3;A++){var C=B[A];if(C.length==1){C+=C}z.push(parseInt(C,16))}return z}else{B=parseInt(B.slice(1),16);return[B>>16,B>>8&255,B&255]}};d.rgbToHsl=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=(z+C)/2;if(z==C){E=D=0}else{var F=z-C;D=A>0.5?F/(2-z-C):F/(z+C);switch(z){case r:E=(g-b)/F+(g<b?6:0);break;case g:E=(b-r)/F+2;break;case b:E=(r-g)/F+4;break}E/=6}return[Math.round(E*360),Math.round(D*100),Math.round(A*100)]};d.hslToRgb=function(D){var F=D[0]/360,I=D[1]/100,E=D[2]/100;var z,G,H;if(I==0){z=G=H=E}else{function C(L,K,J){if(J<0){J+=1}if(J>1){J-=1}if(J<1/6){return L+(K-L)*6*J}if(J<1/2){return K}if(J<2/3){return L+(K-L)*(2/3-J)*6}return L}var A=E<0.5?E*(1+I):E+I-E*I;var B=2*E-A;z=C(B,A,F+1/3);G=C(B,A,F);H=C(B,A,F-1/3)}return[Math.round(z*255),Math.round(G*255),Math.round(H*255)]};d.hslToHex=function(z){return d.rgbToHex(d.hslToRgb(z))};d.rgbToHsv=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=z;var F=z-C;D=z==0?0:F/z;if(z==C){E=0}else{switch(z){case r:E=(g-b)/F+(g<b?6:0);break;case g:E=(b-r)/F+2;break;case b:E=(r-g)/F+4;break}E/=6}return[Math.round(E*360),Math.round(D*100),Math.round(A*100)]};d.hsvToRgb=function(C){var E=C[0]/360,K=C[1]/100,I=C[2]/100;var z,F,H;var D=Math.floor(E*6);var G=E*6-D;var B=I*(1-K);var A=I*(1-G*K);var J=I*(1-(1-G)*K);switch(D%6){case 0:z=I,F=J,H=B;break;case 1:z=A,F=I,H=B;break;case 2:z=B,F=I,H=J;break;case 3:z=B,F=A,H=I;break;case 4:z=J,F=B,H=I;break;case 5:z=I,F=B,H=A;break}return[Math.round(z*255),Math.round(F*255),Math.round(H*255)]};d.hsvToHex=function(z){return d.rgbToHex(d.hsvToRgb(z))};d.destroy=function(z){d.clean(z);if(z.parentNode){z.parentNode.removeChild(z)}if(z.clearAttributes){z.clearAttributes()}};d.clean=function(C){for(var B=C.childNodes,A=0,z=B.length;A<z;A++){d.destroy(B[A])}};d.addEvent=function(B,A,z){if(B.addEventListener){B.addEventListener(A,z,false)}else{B.attachEvent("on"+A,z)}};d.addEvents=function(A,B){for(var z in B){d.addEvent(A,z,B[z])}};d.hasClass=function(A,z){return(" "+A.className+" ").indexOf(" "+z+" ")>-1};d.addClass=function(A,z){if(!d.hasClass(A,z)){A.className=(A.className+" "+z)}};d.removeClass=function(A,z){A.className=A.className.replace(new RegExp("(^|\\s)"+z+"(?:\\s|$)"),"$1")};d.getPos=function(B){var E=D(B);var z=C(B);return{x:E.x-z.x,y:E.y-z.y};function D(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.offsetLeft;F.y+=G.offsetTop;G=G.offsetParent}return F}function C(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.scrollLeft;F.y+=G.scrollTop;G=G.parentNode}return F}function A(F){return(/^(?:body|html)$/i).test(F.tagName)}};d.event={get:function(A,z){z=z||window;return A||z.event},getWheel:function(z){return z.wheelDelta?z.wheelDelta/120:-(z.detail||0)/3},isRightClick:function(z){return(z.which==3||z.button==2)},getPos:function(C,B){B=B||window;C=C||B.event;var A=B.document;A=A.documentElement||A.body;if(C.touches&&C.touches.length){C=C.touches[0]}var z={x:C.pageX||(C.clientX+A.scrollLeft),y:C.pageY||(C.clientY+A.scrollTop)};return z},stop:function(z){if(z.stopPropagation){z.stopPropagation()}z.cancelBubble=true;if(z.preventDefault){z.preventDefault()}else{z.returnValue=false}}};$jit.util=$jit.id=d;var t=function(A){A=A||{};var z=function(){for(var D in this){if(typeof this[D]!="function"){this[D]=d.unlink(this[D])}}this.constructor=z;if(t.prototyping){return this}var C=this.initialize?this.initialize.apply(this,arguments):this;this.$$family="class";return C};for(var B in t.Mutators){if(!A[B]){continue}A=t.Mutators[B](A,A[B]);delete A[B]}d.extend(z,this);z.constructor=t;z.prototype=A;return z};t.Mutators={Implements:function(z,A){d.each(d.splat(A),function(C){t.prototyping=C;var B=(typeof C=="function")?new C:C;for(var D in B){if(!(D in z)){z[D]=B[D]}}delete t.prototyping});return z}};d.extend(t,{inherit:function(z,C){for(var B in C){var A=C[B];var E=z[B];var D=d.type(A);if(E&&D=="function"){if(A!=E){t.override(z,B,A)}}else{if(D=="object"){z[B]=d.merge(E,A)}else{z[B]=A}}}return z},override:function(A,z,D){var C=t.prototyping;if(C&&A[z]!=C[z]){C=null}var B=function(){var E=this.parent;this.parent=C?C[z]:A[z];var F=D.apply(this,arguments);this.parent=E;return F};A[z]=B}});t.prototype.implement=function(){var z=this.prototype;d.each(Array.prototype.slice.call(arguments||[]),function(A){t.inherit(z,A)});return this};$jit.Class=t;$jit.json={prune:function(A,z){this.each(A,function(C,B){if(B==z&&C.children){delete C.children;C.children=[]}})},getParent:function(z,D){if(z.id==D){return false}var C=z.children;if(C&&C.length>0){for(var B=0;B<C.length;B++){if(C[B].id==D){return z}else{var A=this.getParent(C[B],D);if(A){return A}}}}return false},getSubtree:function(z,D){if(z.id==D){return z}for(var B=0,C=z.children;B<C.length;B++){var A=this.getSubtree(C[B],D);if(A!=null){return A}}return null},eachLevel:function(z,E,B,D){if(E<=B){D(z,E);if(!z.children){return}for(var A=0,C=z.children;A<C.length;A++){this.eachLevel(C[A],E+1,B,D)}}},each:function(z,A){this.eachLevel(z,0,Number.MAX_VALUE,A)}};$jit.Trans={$extend:true,linear:function(z){return z}};var k=$jit.Trans;(function(){var z=function(C,B){B=d.splat(B);return d.extend(C,{easeIn:function(D){return C(D,B)},easeOut:function(D){return 1-C(1-D,B)},easeInOut:function(D){return(D<=0.5)?C(2*D,B)/2:(2-C(2*(1-D),B))/2}})};var A={Pow:function(C,B){return Math.pow(C,B[0]||6)},Expo:function(B){return Math.pow(2,8*(B-1))},Circ:function(B){return 1-Math.sin(Math.acos(B))},Sine:function(B){return 1-Math.sin((1-B)*Math.PI/2)},Back:function(C,B){B=B[0]||1.618;return Math.pow(C,2)*((B+1)*C-B)},Bounce:function(E){var D;for(var C=0,B=1;1;C+=B,B/=2){if(E>=(7-4*C)/11){D=B*B-Math.pow((11-6*C-11*E)/4,2);break}}return D},Elastic:function(C,B){return Math.pow(2,10*--C)*Math.cos(20*C*Math.PI*(B[0]||1)/3)}};d.each(A,function(C,B){k[B]=z(C)});d.each(["Quad","Cubic","Quart","Quint"],function(C,B){k[C]=z(function(D){return Math.pow(D,[B+2])})})})();var x=new t({initialize:function(z){this.setOptions(z)},setOptions:function(z){var A={duration:2500,fps:40,transition:k.Quart.easeInOut,compute:d.empty,complete:d.empty,link:"ignore"};this.opt=d.merge(A,z||{});return this},step:function(){var A=d.time(),z=this.opt;if(A<this.time+z.duration){var B=z.transition((A-this.time)/z.duration);z.compute(B)}else{this.timer=clearInterval(this.timer);z.compute(1);z.complete()}},start:function(){if(!this.check()){return this}this.time=0;this.startTimer();return this},startTimer:function(){var z=this,A=this.opt.fps;if(this.timer){return false}this.time=d.time()-this.time;this.timer=setInterval((function(){z.step()}),Math.round(1000/A));return true},pause:function(){this.stopTimer();return this},resume:function(){this.startTimer();return this},stopTimer:function(){if(!this.timer){return false}this.time=d.time()-this.time;this.timer=clearInterval(this.timer);return true},check:function(){if(!this.timer){return true}if(this.opt.link=="cancel"){this.stopTimer();return true}return false}});var p=function(){var B=arguments;for(var D=0,z=B.length,A={};D<z;D++){var C=p[B[D]];if(C.$extend){d.extend(A,C)}else{A[B[D]]=C}}return A};p.AreaChart={$extend:true,animate:true,offset:25,labelOffset:3,type:"stacked",Tips:{enable:false,onShow:d.empty,onHide:d.empty},Events:{enable:false,onClick:d.empty},selectOnHover:true,showAggregates:true,showLabels:true,filterOnClick:false,restoreOnRightClick:false};p.Canvas={$extend:true,injectInto:"id",width:false,height:false,useCanvas:false,withLabels:true,background:false};p.Tree={$extend:true,orientation:"left",subtreeOffset:8,siblingOffset:5,indent:10,multitree:false,align:"center"};p.Node={$extend:false,overridable:false,type:"circle",color:"#ccb",alpha:1,dim:3,height:20,width:90,autoHeight:false,autoWidth:false,lineWidth:1,transform:true,align:"center",angularWidth:1,span:1,CanvasStyles:{}};p.Edge={$extend:false,overridable:false,type:"line",color:"#ccb",lineWidth:1,dim:15,alpha:1,CanvasStyles:{}};p.Fx={$extend:true,fps:40,duration:2500,transition:$jit.Trans.Quart.easeInOut,clearCanvas:true};p.Label={$extend:false,overridable:false,type:"HTML",style:" ",size:10,family:"sans-serif",textAlign:"center",textBaseline:"alphabetic",color:"#fff"};p.Tips={$extend:false,enable:false,type:"auto",offsetX:20,offsetY:20,force:false,onShow:d.empty,onHide:d.empty};p.NodeStyles={$extend:false,enable:false,type:"auto",stylesHover:false,stylesClick:false};p.Events={$extend:false,enable:false,type:"auto",onClick:d.empty,onRightClick:d.empty,onMouseMove:d.empty,onMouseEnter:d.empty,onMouseLeave:d.empty,onDragStart:d.empty,onDragMove:d.empty,onDragCancel:d.empty,onDragEnd:d.empty,onTouchStart:d.empty,onTouchMove:d.empty,onTouchEnd:d.empty,onMouseWheel:d.empty};p.Navigation={$extend:false,enable:false,type:"auto",panning:false,zooming:false};p.Controller={$extend:true,onBeforeCompute:d.empty,onAfterCompute:d.empty,onCreateLabel:d.empty,onPlaceLabel:d.empty,onComplete:d.empty,onBeforePlotLine:d.empty,onAfterPlotLine:d.empty,onBeforePlotNode:d.empty,onAfterPlotNode:d.empty,request:false};var w={initialize:function(B,z){this.viz=z;this.canvas=z.canvas;this.config=z.config[B];this.nodeTypes=z.fx.nodeTypes;var A=this.config.type;this.dom=A=="auto"?(z.config.Label.type!="Native"):(A!="Native");this.labelContainer=this.dom&&z.labels.getLabelContainer();this.isEnabled()&&this.initializePost()},initializePost:d.empty,setAsProperty:d.lambda(false),isEnabled:function(){return this.config.enable},isLabel:function(C,B){C=d.event.get(C,B);var z=this.labelContainer,A=C.target||C.srcElement;if(A&&A.parentNode==z){return A}return false}};var j={onMouseUp:d.empty,onMouseDown:d.empty,onMouseMove:d.empty,onMouseOver:d.empty,onMouseOut:d.empty,onMouseWheel:d.empty,onTouchStart:d.empty,onTouchMove:d.empty,onTouchEnd:d.empty,onTouchCancel:d.empty};var v=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.node=false;this.registeredObjects=[];this.attachEvents()},attachEvents:function(){var B=this.canvas.getElement(),A=this;B.oncontextmenu=d.lambda(false);d.addEvents(B,{mouseup:function(E,D){var C=d.event.get(E,D);A.handleEvent("MouseUp",E,D,A.makeEventObject(E,D),d.event.isRightClick(C))},mousedown:function(E,D){var C=d.event.get(E,D);A.handleEvent("MouseDown",E,D,A.makeEventObject(E,D),d.event.isRightClick(C))},mousemove:function(D,C){A.handleEvent("MouseMove",D,C,A.makeEventObject(D,C))},mouseover:function(D,C){A.handleEvent("MouseOver",D,C,A.makeEventObject(D,C))},mouseout:function(D,C){A.handleEvent("MouseOut",D,C,A.makeEventObject(D,C))},touchstart:function(D,C){A.handleEvent("TouchStart",D,C,A.makeEventObject(D,C))},touchmove:function(D,C){A.handleEvent("TouchMove",D,C,A.makeEventObject(D,C))},touchend:function(D,C){A.handleEvent("TouchEnd",D,C,A.makeEventObject(D,C))}});var z=function(F,E){var D=d.event.get(F,E);var C=d.event.getWheel(D);A.handleEvent("MouseWheel",F,E,C)};if(!document.getBoxObjectFor&&window.mozInnerScreenX==null){d.addEvent(B,"mousewheel",z)}else{B.addEventListener("DOMMouseScroll",z,false)}},register:function(z){this.registeredObjects.push(z)},handleEvent:function(){var A=Array.prototype.slice.call(arguments),D=A.shift();for(var C=0,B=this.registeredObjects,z=B.length;C<z;C++){B[C]["on"+D].apply(B[C],A)}},makeEventObject:function(E,D){var B=this,C=this.viz.graph,A=this.viz.fx,z=A.nodeTypes;return{pos:false,node:false,contains:false,getNodeCalled:false,getPos:function(){if(this.pos){return this.pos}var H=B.viz.canvas,I=H.getSize(),J=H.getPos(),G=H.translateOffsetX,F=H.translateOffsetY,M=H.scaleOffsetX,K=H.scaleOffsetY,L=d.event.getPos(E,D);this.pos={x:(L.x-J.x-I.width/2-G)*1/M,y:(L.y-J.y-I.height/2-F)*1/K};return this.pos},getNode:function(){if(this.getNodeCalled){return this.node}this.getNodeCalled=true;if(B.node){var I=C.getNode(B.node),G=I&&z[I.getData("type")],F=G&&G.contains&&G.contains.call(A,I,this.getPos());if(F){this.contains=F;return this.node=I}}for(var H in C.nodes){var I=C.nodes[H],G=I&&z[I.getData("type")],F=G&&G.contains&&G.contains.call(A,I,this.getPos());if(F){this.contains=F;return B.node=this.node=I}}return B.node=this.node=false},getContains:function(){if(this.getNodeCalled){return this.contains}this.getNode();return this.contains}}}});var q={initializeExtras:function(){var A=new v(this),z=this;d.each(["NodeStyles","Tips","Navigation","Events"],function(B){var C=new q.Classes[B](B,z);if(C.isEnabled()){A.register(C)}if(C.setAsProperty()){z[B.toLowerCase()]=C}})}};q.Classes={};q.Classes.Events=new t({Implements:[w,j],initializePost:function(){this.fx=this.viz.fx;this.types=this.viz.fx.nodeTypes;this.hoveredNode=false;this.pressedNode=false;this.touchedNode=false;this.touchMoved=false;this.moved=false},setAsProperty:d.lambda(true),onMouseUp:function(D,C,A,B){var z=d.event.get(D,C);if(B){this.config.onRightClick(this.hoveredNode,A,z)}else{this.config.onClick(this.pressedNode,A,z)}if(this.pressedNode){if(this.moved){this.config.onDragEnd(this.pressedNode,A,z)}else{this.config.onDragCancel(this.pressedNode,A,z)}this.pressedNode=this.moved=false}},onMouseOut:function(E,D,C){var A=d.event.get(E,D),B;if(this.dom&&(B=this.isLabel(E,D))){this.config.onMouseLeave(this.viz.graph.getNode(B.id),C,A);this.hoveredNode=false;return}var z=A.relatedTarget,F=this.canvas.getElement();while(z&&z.parentNode){if(F==z.parentNode){return}z=z.parentNode}if(this.hoveredNode){this.config.onMouseLeave(this.hoveredNode,C,A);this.hoveredNode=false}},onMouseOver:function(D,C,B){var z=d.event.get(D,C),A;if(this.dom&&(A=this.isLabel(D,C))){this.hoveredNode=this.viz.graph.getNode(A.id);this.config.onMouseEnter(this.hoveredNode,B,z)}},onMouseMove:function(F,E,D){var A,z=d.event.get(F,E);if(this.pressedNode){this.moved=true;this.config.onDragMove(this.pressedNode,D,z);return}if(this.dom){this.config.onMouseMove(this.hoveredNode,D,z)}else{if(this.hoveredNode){var G=this.hoveredNode;var C=this.types[G.getData("type")];var B=C&&C.contains&&C.contains.call(this.fx,G,D.getPos());if(B){this.config.onMouseMove(G,D,z);return}else{this.config.onMouseLeave(G,D,z);this.hoveredNode=false}}if(this.hoveredNode=D.getNode()){this.config.onMouseEnter(this.hoveredNode,D,z)}else{this.config.onMouseMove(false,D,z)}}},onMouseWheel:function(A,z,B){this.config.onMouseWheel(B,d.event.get(A,z))},onMouseDown:function(C,B,A){var z=d.event.get(C,B);this.pressedNode=A.getNode();this.config.onDragStart(this.pressedNode,A,z)},onTouchStart:function(C,B,A){var z=d.event.get(C,B);this.touchedNode=A.getNode();this.config.onTouchStart(this.touchedNode,A,z)},onTouchMove:function(C,B,A){var z=d.event.get(C,B);if(this.touchedNode){this.touchMoved=true;this.config.onTouchMove(this.touchedNode,A,z)}},onTouchEnd:function(C,B,A){var z=d.event.get(C,B);if(this.touchedNode){if(this.touchMoved){this.config.onTouchEnd(this.touchedNode,A,z)}else{this.config.onTouchCancel(this.touchedNode,A,z)}this.touchedNode=this.touchMoved=false}}});q.Classes.Tips=new t({Implements:[w,j],initializePost:function(){if(document.body){var z=d("_tooltip")||document.createElement("div");z.id="_tooltip";z.className="tip";d.extend(z.style,{position:"absolute",display:"none",zIndex:13000});document.body.appendChild(z);this.tip=z;this.node=false}},setAsProperty:d.lambda(true),onMouseOut:function(B,A){if(this.dom&&this.isLabel(B,A)){this.hide(true);return}var z=B.relatedTarget,C=this.canvas.getElement();while(z&&z.parentNode){if(C==z.parentNode){return}z=z.parentNode}this.hide(false)},onMouseOver:function(B,A){var z;if(this.dom&&(z=this.isLabel(B,A))){this.node=this.viz.graph.getNode(z.id);this.config.onShow(this.tip,this.node,z)}},onMouseMove:function(C,B,z){if(this.dom&&this.isLabel(C,B)){this.setTooltipPosition(d.event.getPos(C,B))}if(!this.dom){var A=z.getNode();if(!A){this.hide(true);return}if(this.config.force||!this.node||this.node.id!=A.id){this.node=A;this.config.onShow(this.tip,A,z.getContains())}this.setTooltipPosition(d.event.getPos(C,B))}},setTooltipPosition:function(G){var C=this.tip,B=C.style,A=this.config;B.display="";var E={height:document.body.clientHeight,width:document.body.clientWidth};var D={width:C.offsetWidth,height:C.offsetHeight};var z=A.offsetX,F=A.offsetY;B.top=((G.y+F+D.height>E.height)?(G.y-D.height-F):G.y+F)+"px";B.left=((G.x+D.width+z>E.width)?(G.x-D.width-z):G.x+z)+"px"},hide:function(z){this.tip.style.display="none";z&&this.config.onHide()}});q.Classes.NodeStyles=new t({Implements:[w,j],initializePost:function(){this.fx=this.viz.fx;this.types=this.viz.fx.nodeTypes;this.nStyles=this.config;this.nodeStylesOnHover=this.nStyles.stylesHover;this.nodeStylesOnClick=this.nStyles.stylesClick;this.hoveredNode=false;this.fx.nodeFxAnimation=new x();this.down=false;this.move=false},onMouseOut:function(B,A){this.down=this.move=false;if(!this.hoveredNode){return}if(this.dom&&this.isLabel(B,A)){this.toggleStylesOnHover(this.hoveredNode,false)}var z=B.relatedTarget,C=this.canvas.getElement();while(z&&z.parentNode){if(C==z.parentNode){return}z=z.parentNode}this.toggleStylesOnHover(this.hoveredNode,false);this.hoveredNode=false},onMouseOver:function(C,B){var z;if(this.dom&&(z=this.isLabel(C,B))){var A=this.viz.graph.getNode(z.id);if(A.selected){return}this.hoveredNode=A;this.toggleStylesOnHover(this.hoveredNode,true)}},onMouseDown:function(D,C,A,B){if(B){return}var z;if(this.dom&&(z=this.isLabel(D,C))){this.down=this.viz.graph.getNode(z.id)}else{if(!this.dom){this.down=A.getNode()}}this.move=false},onMouseUp:function(C,B,z,A){if(A){return}if(!this.move){this.onClick(z.getNode())}this.down=this.move=false},getRestoredStyles:function(A,z){var C={},B=this["nodeStylesOn"+z];for(var D in B){C[D]=A.styles["$"+D]}return C},toggleStylesOnHover:function(z,A){if(this.nodeStylesOnHover){this.toggleStylesOn("Hover",z,A)}},toggleStylesOnClick:function(z,A){if(this.nodeStylesOnClick){this.toggleStylesOn("Click",z,A)}},toggleStylesOn:function(D,z,F){var G=this.viz;var E=this.nStyles;if(F){var C=this;if(!z.styles){z.styles=d.merge(z.data,{})}for(var H in this["nodeStylesOn"+D]){var A="$"+H;if(!(A in z.styles)){z.styles[A]=z.getData(H)}}G.fx.nodeFx(d.extend({elements:{id:z.id,properties:C["nodeStylesOn"+D]},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}else{var B=this.getRestoredStyles(z,D);G.fx.nodeFx(d.extend({elements:{id:z.id,properties:B},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}},onClick:function(z){if(!z){return}var A=this.nodeStylesOnClick;if(!A){return}if(z.selected){this.toggleStylesOnClick(z,false);delete z.selected}else{this.viz.graph.eachNode(function(C){if(C.selected){for(var B in A){C.setData(B,C.styles["$"+B],"end")}delete C.selected}});this.toggleStylesOnClick(z,true);z.selected=true;delete z.hovered;this.hoveredNode=false}},onMouseMove:function(F,E,C){if(this.down){this.move=true}if(this.dom&&this.isLabel(F,E)){return}var D=this.nodeStylesOnHover;if(!D){return}if(!this.dom){if(this.hoveredNode){var A=this.types[this.hoveredNode.getData("type")];var z=A&&A.contains&&A.contains.call(this.fx,this.hoveredNode,C.getPos());if(z){return}}var B=C.getNode();if(!this.hoveredNode&&!B){return}if(B.hovered){return}if(B&&!B.selected){this.fx.nodeFxAnimation.stopTimer();this.viz.graph.eachNode(function(H){if(H.hovered&&!H.selected){for(var G in D){H.setData(G,H.styles["$"+G],"end")}delete H.hovered}});B.hovered=true;this.hoveredNode=B;this.toggleStylesOnHover(B,true)}else{if(this.hoveredNode&&!this.hoveredNode.selected){this.fx.nodeFxAnimation.stopTimer();this.toggleStylesOnHover(this.hoveredNode,false);delete this.hoveredNode.hovered;this.hoveredNode=false}}}}});q.Classes.Navigation=new t({Implements:[w,j],initializePost:function(){this.pos=false;this.pressed=false},onMouseWheel:function(C,B,z){if(!this.config.zooming){return}d.event.stop(d.event.get(C,B));var D=this.config.zooming/1000,A=1+z*D;this.canvas.scale(A,A)},onMouseDown:function(E,D,C){if(!this.config.panning){return}if(this.config.panning=="avoid nodes"&&C.getNode()){return}this.pressed=true;this.pos=C.getPos();var B=this.canvas,A=B.translateOffsetX,z=B.translateOffsetY,G=B.scaleOffsetX,F=B.scaleOffsetY;this.pos.x*=G;this.pos.x+=A;this.pos.y*=F;this.pos.y+=z},onMouseMove:function(E,D,G){if(!this.config.panning){return}if(!this.pressed){return}if(this.config.panning=="avoid nodes"&&G.getNode()){return}var C=this.pos,F=G.getPos(),A=this.canvas,B=A.translateOffsetX,z=A.translateOffsetY,K=A.scaleOffsetX,I=A.scaleOffsetY;F.x*=K;F.y*=I;F.x+=B;F.y+=z;var J=F.x-C.x,H=F.y-C.y;this.pos=F;this.canvas.translate(J*1/K,H*1/I)},onMouseUp:function(C,B,A,z){if(!this.config.panning){return}this.pressed=false}});var n;(function(){var z=typeof HTMLCanvasElement,B=(z=="object"||z=="function");function A(C,D){var E=document.createElement(C);for(var F in D){if(typeof D[F]=="object"){d.extend(E[F],D[F])}else{E[F]=D[F]}}if(C=="canvas"&&!B&&G_vmlCanvasManager){E=G_vmlCanvasManager.initElement(document.body.appendChild(E))}return E}$jit.Canvas=n=new t({canvases:[],pos:false,element:false,labelContainer:false,translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(N,H){this.viz=N;this.opt=H;var E=d.type(H.injectInto)=="string"?H.injectInto:H.injectInto.id,F=E+"-label",C=d(E),G=H.width||C.offsetWidth,O=H.height||C.offsetHeight;this.id=E;var I={injectInto:E,width:G,height:O};this.element=A("div",{id:E+"-canvaswidget",style:{position:"relative",width:G+"px",height:O+"px"}});this.labelContainer=this.createLabelContainer(H.Label.type,F,I);this.canvases.push(new n.Base({config:d.extend({idSuffix:"-canvas"},I),plot:function(P){N.fx.plot()},resize:function(){N.refresh()}}));var J=H.background;if(J){var M=new n.Background[J.type](N,d.extend(J,I));this.canvases.push(new n.Base(M))}var L=this.canvases.length;while(L--){this.element.appendChild(this.canvases[L].canvas);if(L>0){this.canvases[L].plot()}}this.element.appendChild(this.labelContainer);C.appendChild(this.element);var D=null,K=this;d.addEvent(window,"scroll",function(){clearTimeout(D);D=setTimeout(function(){K.getPos(true)},500)})},getCtx:function(C){return this.canvases[C||0].getCtx()},getConfig:function(){return this.opt},getElement:function(){return this.element},getSize:function(C){return this.canvases[C||0].getSize()},resize:function(G,C){this.getPos(true);this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;for(var E=0,D=this.canvases.length;E<D;E++){this.canvases[E].resize(G,C)}var F=this.element.style;F.width=G+"px";F.height=C+"px";if(this.labelContainer){this.labelContainer.style.width=G+"px"}},translate:function(C,G,F){this.translateOffsetX+=C*this.scaleOffsetX;this.translateOffsetY+=G*this.scaleOffsetY;for(var E=0,D=this.canvases.length;E<D;E++){this.canvases[E].translate(C,G,F)}},scale:function(H,E,F){var I=this.scaleOffsetX*H,G=this.scaleOffsetY*E;var K=this.translateOffsetX*(H-1)/I,J=this.translateOffsetY*(E-1)/G;this.scaleOffsetX=I;this.scaleOffsetY=G;for(var D=0,C=this.canvases.length;D<C;D++){this.canvases[D].scale(H,E,true)}this.translate(K,J,false)},getPos:function(C){if(C||!this.pos){return this.pos=d.getPos(this.getElement())}return this.pos},clear:function(C){this.canvases[C||0].clear()},path:function(D,E){var C=this.canvases[0].getCtx();C.beginPath();E(C);C[D]();C.closePath()},createLabelContainer:function(E,I,H){var G="http://www.w3.org/2000/svg";if(E=="HTML"||E=="Native"){return A("div",{id:I,style:{overflow:"visible",position:"absolute",top:0,left:0,width:H.width+"px",height:0}})}else{if(E=="SVG"){var F=document.createElementNS(G,"svg:svg");F.setAttribute("width",H.width);F.setAttribute("height",H.height);var D=F.style;D.position="absolute";D.left=D.top="0px";var C=document.createElementNS(G,"svg:g");C.setAttribute("width",H.width);C.setAttribute("height",H.height);C.setAttribute("x",0);C.setAttribute("y",0);C.setAttribute("id",I);F.appendChild(C);return F}}}});n.Base=new t({translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(C){this.viz=C;this.opt=C.config;this.size=false;this.createCanvas();this.translateToCenter()},createCanvas:function(){var D=this.opt,E=D.width,C=D.height;this.canvas=A("canvas",{id:D.injectInto+D.idSuffix,width:E,height:C,style:{position:"absolute",top:0,left:0,width:E+"px",height:C+"px"}})},getCtx:function(){if(!this.ctx){return this.ctx=this.canvas.getContext("2d")}return this.ctx},getSize:function(){if(this.size){return this.size}var C=this.canvas;return this.size={width:C.width,height:C.height}},translateToCenter:function(F){var D=this.getSize(),E=F?(D.width-F.width-this.translateOffsetX*2):D.width;height=F?(D.height-F.height-this.translateOffsetY*2):D.height;var C=this.getCtx();F&&C.scale(1/this.scaleOffsetX,1/this.scaleOffsetY);C.translate(E/2,height/2)},resize:function(F,C){var E=this.getSize(),D=this.canvas,G=D.style;this.size=false;D.width=F;D.height=C;G.width=F+"px";G.height=C+"px";if(!B){this.translateToCenter(E)}else{this.translateToCenter()}this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;this.clear();this.viz.resize(F,C,this)},translate:function(C,G,D){var F=this.scaleOffsetX,E=this.scaleOffsetY;this.translateOffsetX+=C*F;this.translateOffsetY+=G*E;this.getCtx().translate(C,G);!D&&this.plot()},scale:function(C,E,D){this.scaleOffsetX*=C;this.scaleOffsetY*=E;this.getCtx().scale(C,E);!D&&this.plot()},clear:function(){var E=this.getSize(),D=this.translateOffsetX,C=this.translateOffsetY,G=this.scaleOffsetX,F=this.scaleOffsetY;this.getCtx().clearRect((-E.width/2-D)*1/G,(-E.height/2-C)*1/F,E.width*1/G,E.height*1/F)},plot:function(){this.clear();this.viz.plot(this)}});n.Background={};n.Background.Circles=new t({initialize:function(C,D){this.viz=C;this.config=d.merge({idSuffix:"-bkcanvas",levelDistance:100,numberOfCircles:6,CanvasStyles:{},offset:0},D)},resize:function(D,C,E){this.plot(E)},plot:function(C){var D=C.canvas,J=C.getCtx(),G=this.config,I=G.CanvasStyles;for(var K in I){J[K]=I[K]}var E=G.numberOfCircles,H=G.levelDistance;for(var F=1;F<=E;F++){J.beginPath();J.arc(0,0,H*F,0,2*Math.PI,false);J.stroke();J.closePath()}}})})();var c=function(A,z){this.theta=A;this.rho=z};$jit.Polar=c;c.prototype={getc:function(z){return this.toComplex(z)},getp:function(){return this},set:function(z){z=z.getp();this.theta=z.theta;this.rho=z.rho},setc:function(z,A){this.rho=Math.sqrt(z*z+A*A);this.theta=Math.atan2(A,z);if(this.theta<0){this.theta+=Math.PI*2}},setp:function(A,z){this.theta=A;this.rho=z},clone:function(){return new c(this.theta,this.rho)},toComplex:function(B){var z=Math.cos(this.theta)*this.rho;var A=Math.sin(this.theta)*this.rho;if(B){return{x:z,y:A}}return new s(z,A)},add:function(z){return new c(this.theta+z.theta,this.rho+z.rho)},scale:function(z){return new c(this.theta,this.rho*z)},equals:function(z){return this.theta==z.theta&&this.rho==z.rho},$add:function(z){this.theta=this.theta+z.theta;this.rho+=z.rho;return this},$madd:function(z){this.theta=(this.theta+z.theta)%(Math.PI*2);this.rho+=z.rho;return this},$scale:function(z){this.rho*=z;return this},interpolate:function(B,I){var C=Math.PI,F=C*2;var A=function(K){var J=(K<0)?(K%F)+F:K%F;return J};var E=this.theta,H=B.theta;var D,G=Math.abs(E-H);if(G==C){if(E>H){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H))*I))}}else{if(G>=C){if(E>H){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H-F))*I))}}else{D=A((H+(E-H)*I))}}var z=(this.rho-B.rho)*I+B.rho;return{theta:D,rho:z}}};var m=function(A,z){return new c(A,z)};c.KER=m(0,0);var s=function(z,A){this.x=z;this.y=A};$jit.Complex=s;s.prototype={getc:function(){return this},getp:function(z){return this.toPolar(z)},set:function(z){z=z.getc(true);this.x=z.x;this.y=z.y},setc:function(z,A){this.x=z;this.y=A},setp:function(A,z){this.x=Math.cos(A)*z;this.y=Math.sin(A)*z},clone:function(){return new s(this.x,this.y)},toPolar:function(B){var z=this.norm();var A=Math.atan2(this.y,this.x);if(A<0){A+=Math.PI*2}if(B){return{theta:A,rho:z}}return new c(A,z)},norm:function(){return Math.sqrt(this.squaredNorm())},squaredNorm:function(){return this.x*this.x+this.y*this.y},add:function(z){return new s(this.x+z.x,this.y+z.y)},prod:function(z){return new s(this.x*z.x-this.y*z.y,this.y*z.x+this.x*z.y)},conjugate:function(){return new s(this.x,-this.y)},scale:function(z){return new s(this.x*z,this.y*z)},equals:function(z){return this.x==z.x&&this.y==z.y},$add:function(z){this.x+=z.x;this.y+=z.y;return this},$prod:function(B){var z=this.x,A=this.y;this.x=z*B.x-A*B.y;this.y=A*B.x+z*B.y;return this},$conjugate:function(){this.y=-this.y;return this},$scale:function(z){this.x*=z;this.y*=z;return this},$div:function(C){var z=this.x,B=this.y;var A=C.squaredNorm();this.x=z*C.x+B*C.y;this.y=B*C.x-z*C.y;return this.$scale(1/A)}};var u=function(A,z){return new s(A,z)};s.KER=u(0,0);$jit.Graph=new t({initialize:function(B,A,z,F){var D={complex:false,Node:{}};this.Node=A;this.Edge=z;this.Label=F;this.opt=d.merge(D,B||{});this.nodes={};this.edges={};var C=this;this.nodeList={};for(var E in l){C.nodeList[E]=(function(G){return function(){var H=Array.prototype.slice.call(arguments);C.eachNode(function(I){I[G].apply(I,H)})}})(E)}},getNode:function(z){if(this.hasNode(z)){return this.nodes[z]}return false},getByName:function(z){for(var B in this.nodes){var A=this.nodes[B];if(A.name==z){return A}}return false},getAdjacence:function(A,z){if(A in this.edges){return this.edges[A][z]}return false},addNode:function(A){if(!this.nodes[A.id]){var z=this.edges[A.id]={};this.nodes[A.id]=new f.Node(d.extend({id:A.id,name:A.name,data:A.data||{},adjacencies:z},this.opt.Node),this.opt.complex,this.Node,this.Edge,this.Label)}return this.nodes[A.id]},addAdjacence:function(C,B,A){if(!this.hasNode(C.id)){this.addNode(C)}if(!this.hasNode(B.id)){this.addNode(B)}C=this.nodes[C.id];B=this.nodes[B.id];var D=this.edges[C.id]=this.edges[C.id]||{};var z=this.edges[B.id]=this.edges[B.id]||{};D[B.id]=z[C.id]=new f.Adjacence(C,B,A,this.Edge,this.Label);return D[B.id]},removeNode:function(B){if(this.hasNode(B)){delete this.nodes[B];var A=this.edges[B];for(var z in A){delete this.edges[z][B]}delete this.edges[B]}},removeAdjacence:function(A,z){delete this.edges[A][z];delete this.edges[z][A]},hasNode:function(z){return z in this.nodes},empty:function(){this.nodes={};this.edges={}}});var f=$jit.Graph;var l;(function(){var z=function(G,I,D,F,H){var E;D=D||"current";G="$"+(G?G+"-":"");if(D=="current"){E=this.data}else{if(D=="start"){E=this.startData}else{if(D=="end"){E=this.endData}}}var C=G+I;if(F){return E[C]}if(!this.Config.overridable){return H[I]||0}return(C in E)?E[C]:((C in this.data)?this.data[C]:(H[I]||0))};var B=function(F,G,E,C){C=C||"current";F="$"+(F?F+"-":"");var D;if(C=="current"){D=this.data}else{if(C=="start"){D=this.startData}else{if(C=="end"){D=this.endData}}}D[F+G]=E};var A=function(E,C){E="$"+(E?E+"-":"");var D=this;d.each(C,function(G){var F=E+G;delete D.data[F];delete D.endData[F];delete D.startData[F]})};l={getData:function(E,C,D){return z.call(this,"",E,C,D,this.Config)},setData:function(E,D,C){B.call(this,"",E,D,C)},setDataset:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setData(C,H[E],F[E])}}},removeData:function(){A.call(this,"",Array.prototype.slice.call(arguments))},getCanvasStyle:function(E,C,D){return z.call(this,"canvas",E,C,D,this.Config.CanvasStyles)},setCanvasStyle:function(E,D,C){B.call(this,"canvas",E,D,C)},setCanvasStyles:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setCanvasStyle(C,H[E],F[E])}}},removeCanvasStyle:function(){A.call(this,"canvas",Array.prototype.slice.call(arguments))},getLabelData:function(E,C,D){return z.call(this,"label",E,C,D,this.Label)},setLabelData:function(E,D,C){B.call(this,"label",E,D,C)},setLabelDataset:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setLabelData(C,H[E],F[E])}}},removeLabelData:function(){A.call(this,"label",Array.prototype.slice.call(arguments))}}})();f.Node=new t({initialize:function(B,D,A,z,E){var C={id:"",name:"",data:{},startData:{},endData:{},adjacencies:{},selected:false,drawn:false,exist:false,angleSpan:{begin:0,end:0},pos:(D&&u(0,0))||m(0,0),startPos:(D&&u(0,0))||m(0,0),endPos:(D&&u(0,0))||m(0,0)};d.extend(this,d.extend(C,B));this.Config=this.Node=A;this.Edge=z;this.Label=E},adjacentTo:function(z){return z.id in this.adjacencies},getAdjacency:function(z){return this.adjacencies[z]},getPos:function(z){z=z||"current";if(z=="current"){return this.pos}else{if(z=="end"){return this.endPos}else{if(z=="start"){return this.startPos}}}},setPos:function(A,z){z=z||"current";var B;if(z=="current"){B=this.pos}else{if(z=="end"){B=this.endPos}else{if(z=="start"){B=this.startPos}}}B.set(A)}});f.Node.implement(l);f.Adjacence=new t({initialize:function(A,D,B,z,C){this.nodeFrom=A;this.nodeTo=D;this.data=B||{};this.startData={};this.endData={};this.Config=this.Edge=z;this.Label=C}});f.Adjacence.implement(l);f.Util={filter:function(A){if(!A||!(d.type(A)=="string")){return function(){return true}}var z=A.split(" ");return function(C){for(var B=0;B<z.length;B++){if(C[z[B]]){return false}}return true}},getNode:function(z,A){return z.nodes[A]},eachNode:function(D,C,z){var B=this.filter(z);for(var A in D.nodes){if(B(D.nodes[A])){C(D.nodes[A])}}},eachAdjacency:function(E,F,A){var B=E.adjacencies,D=this.filter(A);for(var G in B){var z=B[G];if(D(z)){if(z.nodeFrom!=E){var C=z.nodeFrom;z.nodeFrom=z.nodeTo;z.nodeTo=C}F(z,G)}}},computeLevels:function(F,G,C,B){C=C||0;var D=this.filter(B);this.eachNode(F,function(H){H._flag=false;H._depth=-1},B);var A=F.getNode(G);A._depth=C;var z=[A];while(z.length!=0){var E=z.pop();E._flag=true;this.eachAdjacency(E,function(H){var I=H.nodeTo;if(I._flag==false&&D(I)){if(I._depth<0){I._depth=E._depth+1+C}z.unshift(I)}},B)}},eachBFS:function(E,F,D,A){var B=this.filter(A);this.clean(E);var z=[E.getNode(F)];while(z.length!=0){var C=z.pop();C._flag=true;D(C,C._depth);this.eachAdjacency(C,function(G){var H=G.nodeTo;if(H._flag==false&&B(H)){H._flag=true;z.unshift(H)}},A)}},eachLevel:function(D,H,A,E,C){var G=D._depth,z=this.filter(C),F=this;A=A===false?Number.MAX_VALUE-G:A;(function B(K,I,J){var L=K._depth;if(L>=I&&L<=J&&z(K)){E(K,L)}if(L<J){F.eachAdjacency(K,function(M){var N=M.nodeTo;if(N._depth>L){B(N,I,J)}})}})(D,H+G,A+G)},eachSubgraph:function(A,B,z){this.eachLevel(A,0,false,B,z)},eachSubnode:function(A,B,z){this.eachLevel(A,1,1,B,z)},anySubnode:function(C,B,A){var z=false;B=B||d.lambda(true);var D=d.type(B)=="string"?function(E){return E[B]}:B;this.eachSubnode(C,function(E){if(D(E)){z=true}},A);return z},getSubnodes:function(E,F,z){var B=[],D=this;F=F||0;var C,A;if(d.type(F)=="array"){C=F[0];A=F[1]}else{C=F;A=Number.MAX_VALUE-E._depth}this.eachLevel(E,C,A,function(G){B.push(G)},z);return B},getParents:function(A){var z=[];this.eachAdjacency(A,function(B){var C=B.nodeTo;if(C._depth<A._depth){z.push(C)}});return z},isDescendantOf:function(C,D){if(C.id==D){return true}var B=this.getParents(C),z=false;for(var A=0;!z&&A<B.length;A++){z=z||this.isDescendantOf(B[A],D)}return z},clean:function(z){this.eachNode(z,function(A){A._flag=false})},getClosestNodeToOrigin:function(A,B,z){return this.getClosestNodeToPos(A,c.KER,B,z)},getClosestNodeToPos:function(B,E,D,z){var A=null;D=D||"current";E=E&&E.getc(true)||s.KER;var C=function(G,F){var I=G.x-F.x,H=G.y-F.y;return I*I+H*H};this.eachNode(B,function(F){A=(A==null||C(F.getPos(D).getc(true),E)<C(A.getPos(D).getc(true),E))?F:A},z);return A}};d.each(["getNode","eachNode","computeLevels","eachBFS","clean","getClosestNodeToPos","getClosestNodeToOrigin"],function(z){f.prototype[z]=function(){return f.Util[z].apply(f.Util,[this].concat(Array.prototype.slice.call(arguments)))}});d.each(["eachAdjacency","eachLevel","eachSubgraph","eachSubnode","anySubnode","getSubnodes","getParents","isDescendantOf"],function(z){f.Node.prototype[z]=function(){return f.Util[z].apply(f.Util,[this].concat(Array.prototype.slice.call(arguments)))}});f.Op={options:{type:"nothing",duration:2000,hideLabels:true,fps:30},removeNode:function(E,C){var z=this.viz;var A=d.merge(this.options,z.controller,C);var G=d.splat(E);var B,D,F;switch(A.type){case"nothing":for(B=0;B<G.length;B++){z.graph.removeNode(G[B])}break;case"replot":this.removeNode(G,{type:"nothing"});z.labels.clearLabels();z.refresh(true);break;case"fade:seq":case"fade":D=this;for(B=0;B<G.length;B++){F=z.graph.getNode(G[B]);F.setData("alpha",0,"end")}z.fx.animate(d.merge(A,{modes:["node-property:alpha"],onComplete:function(){D.removeNode(G,{type:"nothing"});z.labels.clearLabels();z.reposition();z.fx.animate(d.merge(A,{modes:["linear"]}))}}));break;case"fade:con":D=this;for(B=0;B<G.length;B++){F=z.graph.getNode(G[B]);F.setData("alpha",0,"end");F.ignore=true}z.reposition();z.fx.animate(d.merge(A,{modes:["node-property:alpha","linear"],onComplete:function(){D.removeNode(G,{type:"nothing"})}}));break;case"iter":D=this;z.fx.sequence({condition:function(){return G.length!=0},step:function(){D.removeNode(G.shift(),{type:"nothing"});z.labels.clearLabels()},onComplete:function(){A.onComplete()},duration:Math.ceil(A.duration/G.length)});break;default:this.doError()}},removeEdge:function(G,E){var z=this.viz;var C=d.merge(this.options,z.controller,E);var B=(d.type(G[0])=="string")?[G]:G;var D,F,A;switch(C.type){case"nothing":for(D=0;D<B.length;D++){z.graph.removeAdjacence(B[D][0],B[D][1])}break;case"replot":this.removeEdge(B,{type:"nothing"});z.refresh(true);break;case"fade:seq":case"fade":F=this;for(D=0;D<B.length;D++){A=z.graph.getAdjacence(B[D][0],B[D][1]);if(A){A.setData("alpha",0,"end")}}z.fx.animate(d.merge(C,{modes:["edge-property:alpha"],onComplete:function(){F.removeEdge(B,{type:"nothing"});z.reposition();z.fx.animate(d.merge(C,{modes:["linear"]}))}}));break;case"fade:con":F=this;for(D=0;D<B.length;D++){A=z.graph.getAdjacence(B[D][0],B[D][1]);if(A){A.setData("alpha",0,"end");A.ignore=true}}z.reposition();z.fx.animate(d.merge(C,{modes:["edge-property:alpha","linear"],onComplete:function(){F.removeEdge(B,{type:"nothing"})}}));break;case"iter":F=this;z.fx.sequence({condition:function(){return B.length!=0},step:function(){F.removeEdge(B.shift(),{type:"nothing"});z.labels.clearLabels()},onComplete:function(){C.onComplete()},duration:Math.ceil(C.duration/B.length)});break;default:this.doError()}},sum:function(D,C){var z=this.viz;var B=d.merge(this.options,z.controller,C),A=z.root;var F;z.root=C.id||z.root;switch(B.type){case"nothing":F=z.construct(D);F.eachNode(function(H){H.eachAdjacency(function(I){z.graph.addAdjacence(I.nodeFrom,I.nodeTo,I.data)})});break;case"replot":z.refresh(true);this.sum(D,{type:"nothing"});z.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;F=z.construct(D);var G=this.preprocessSum(F);var E=!G?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];z.reposition();if(B.type!="fade:con"){z.fx.animate(d.merge(B,{modes:["linear"],onComplete:function(){z.fx.animate(d.merge(B,{modes:E,onComplete:function(){B.onComplete()}}))}}))}else{z.graph.eachNode(function(H){if(H.id!=A&&H.pos.getp().equals(c.KER)){H.pos.set(H.endPos);H.startPos.set(H.endPos)}});z.fx.animate(d.merge(B,{modes:["linear"].concat(E)}))}break;default:this.doError()}},morph:function(G,A,C){var E=this.viz;var H=d.merge(this.options,E.controller,A),D=E.root;var F;E.root=A.id||E.root;switch(H.type){case"nothing":F=E.construct(G);F.eachNode(function(K){var J=E.graph.hasNode(K.id);K.eachAdjacency(function(O){var N=!!E.graph.getAdjacence(O.nodeFrom.id,O.nodeTo.id);E.graph.addAdjacence(O.nodeFrom,O.nodeTo,O.data);if(N){var M=E.graph.getAdjacence(O.nodeFrom.id,O.nodeTo.id);for(var P in (O.data||{})){M.data[P]=O.data[P]}}});if(J){var I=E.graph.getNode(K.id);for(var L in (K.data||{})){I.data[L]=K.data[L]}}});E.graph.eachNode(function(I){I.eachAdjacency(function(J){if(!F.getAdjacence(J.nodeFrom.id,J.nodeTo.id)){E.graph.removeAdjacence(J.nodeFrom.id,J.nodeTo.id)}});if(!F.hasNode(I.id)){E.graph.removeNode(I.id)}});break;case"replot":E.labels.clearLabels(true);this.morph(G,{type:"nothing"});E.refresh(true);E.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;F=E.construct(G);E.graph.eachNode(function(J){var K=F.getNode(J.id);if(!K){J.setData("alpha",1);J.setData("alpha",1,"start");J.setData("alpha",0,"end");J.ignore=true}else{var I=K.data;for(var L in I){if(L[0]=="$"&&L!="$type"){J.endData[L]=I[L]}else{J.data[L]=I[L]}}}});E.graph.eachNode(function(I){if(I.ignore){return}I.eachAdjacency(function(J){if(J.nodeFrom.ignore||J.nodeTo.ignore){return}var K=F.getNode(J.nodeFrom.id);var L=F.getNode(J.nodeTo.id);if(!K.adjacentTo(L)){var J=E.graph.getAdjacence(K.id,L.id);z=true;J.setData("alpha",1);J.setData("alpha",1,"start");J.setData("alpha",0,"end")}})});var z=this.preprocessSum(F);var B=!z?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];B[0]=B[0]+((C&&("node-property" in C))?d.splat(C["node-property"]).join(":"):"");B[1]=(B[1]||"edge-property:alpha")+((C&&("edge-property" in C))?d.splat(C["edge-property"]).join(":"):"");if(C&&("label-property" in C)){B.push("label-property"+d.splat(C["label-property"]).join(":"))}E.reposition();E.graph.eachNode(function(I){if(I.id!=D&&I.pos.getp().equals(c.KER)){I.pos.set(I.endPos);I.startPos.set(I.endPos)}});E.fx.animate(d.merge(H,{modes:["polar"].concat(B),onComplete:function(){E.graph.eachNode(function(I){if(I.ignore){E.graph.removeNode(I.id)}});E.graph.eachNode(function(I){I.eachAdjacency(function(J){if(J.ignore){E.graph.removeAdjacence(J.nodeFrom.id,J.nodeTo.id)}})});H.onComplete()}}));break;default:}},contract:function(B,A){var z=this.viz;if(B.collapsed||!B.anySubnode(d.lambda(true))){return}A=d.merge(this.options,z.config,A||{},{modes:["node-property:alpha:span","linear"]});B.collapsed=true;(function C(D){D.eachSubnode(function(E){E.ignore=true;E.setData("alpha",0,A.type=="animate"?"end":"current");C(E)})})(B);if(A.type=="animate"){z.compute("end");if(z.rotated){z.rotate(z.rotated,"none",{property:"end"})}(function C(D){D.eachSubnode(function(E){E.setPos(B.getPos("end"),"end");C(E)})})(B);z.fx.animate(A)}else{if(A.type=="replot"){z.refresh()}}},expand:function(B,A){if(!("collapsed" in B)){return}var z=this.viz;A=d.merge(this.options,z.config,A||{},{modes:["node-property:alpha:span","linear"]});delete B.collapsed;(function C(D){D.eachSubnode(function(E){delete E.ignore;E.setData("alpha",1,A.type=="animate"?"end":"current");C(E)})})(B);if(A.type=="animate"){z.compute("end");if(z.rotated){z.rotate(z.rotated,"none",{property:"end"})}z.fx.animate(A)}else{if(A.type=="replot"){z.refresh()}}},preprocessSum:function(A){var z=this.viz;A.eachNode(function(C){if(!z.graph.hasNode(C.id)){z.graph.addNode(C);var D=z.graph.getNode(C.id);D.setData("alpha",0);D.setData("alpha",0,"start");D.setData("alpha",1,"end")}});var B=false;A.eachNode(function(C){C.eachAdjacency(function(D){var E=z.graph.getNode(D.nodeFrom.id);var F=z.graph.getNode(D.nodeTo.id);if(!E.adjacentTo(F)){var D=z.graph.addAdjacence(E,F,D.data);if(E.startAlpha==E.endAlpha&&F.startAlpha==F.endAlpha){B=true;D.setData("alpha",0);D.setData("alpha",0,"start");D.setData("alpha",1,"end")}}})});return B}};var a={none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(C,D,z,B){var A=B.getCtx();A.beginPath();A.arc(D.x,D.y,z,0,Math.PI*2,true);A.closePath();A[C]()},contains:function(E,D,z){var B=E.x-D.x,A=E.y-D.y,C=B*B+A*A;return C<=z*z}},ellipse:{render:function(D,E,C,z,B){var A=B.getCtx();z/=2;C/=2;A.save();A.scale(C/z,z/C);A.beginPath();A.arc(E.x*(z/C),E.y*(C/z),z,0,Math.PI*2,true);A.closePath();A[D]();A.restore()},contains:function(G,F,C,z){C/=2;z/=2;var E=(C+z)/2,B=G.x-F.x,A=G.y-F.y,D=B*B+A*A;return D<=E*E}},square:{render:function(A,C,B,z){z.getCtx()[A+"Rect"](C.x-B,C.y-B,2*B,2*B)},contains:function(B,A,z){return Math.abs(A.x-B.x)<=z&&Math.abs(A.y-B.y)<=z}},rectangle:{render:function(C,D,B,z,A){A.getCtx()[C+"Rect"](D.x-B/2,D.y-z/2,B,z)},contains:function(C,B,A,z){return Math.abs(B.x-C.x)<=A/2&&Math.abs(B.y-C.y)<=z/2}},triangle:{render:function(F,G,C,z){var J=z.getCtx(),B=G.x,A=G.y-C,I=B-C,H=G.y+C,E=B+C,D=H;J.beginPath();J.moveTo(B,A);J.lineTo(I,H);J.lineTo(E,D);J.closePath();J[F]()},contains:function(B,A,z){return a.circle.contains(B,A,z)}},star:{render:function(D,F,E,A){var z=A.getCtx(),C=Math.PI/5;z.save();z.translate(F.x,F.y);z.beginPath();z.moveTo(E,0);for(var B=0;B<9;B++){z.rotate(C);if(B%2==0){z.lineTo((E/0.525731)*0.200811,0)}else{z.lineTo(E,0)}}z.closePath();z[D]();z.restore()},contains:function(B,A,z){return a.circle.contains(B,A,z)}}};var o={line:function(C,B,A){var z=A.getCtx();z.beginPath();z.moveTo(C.x,C.y);z.lineTo(B.x,B.y);z.stroke()},arrow:function(I,J,C,A,z){var K=z.getCtx();if(A){var B=I;I=J;J=B}var F=new s(J.x-I.x,J.y-I.y);F.$scale(C/F.norm());var D=new s(J.x-F.x,J.y-F.y),E=new s(-F.y/2,F.x/2),H=D.add(E),G=D.$add(E.$scale(-1));K.beginPath();K.moveTo(I.x,I.y);K.lineTo(J.x,J.y);K.stroke();K.beginPath();K.moveTo(H.x,H.y);K.lineTo(G.x,G.y);K.lineTo(J.x,J.y);K.closePath();K.fill()},hyperline:function(G,H,z,B){var I=B.getCtx();var C=D(G,H);if(C.a>1000||C.b>1000||C.ratio<0){I.beginPath();I.moveTo(G.x*z,G.y*z);I.lineTo(H.x*z,H.y*z);I.stroke()}else{var F=Math.atan2(H.y-C.y,H.x-C.x);var E=Math.atan2(G.y-C.y,G.x-C.x);var A=A(F,E);I.beginPath();I.arc(C.x*z,C.y*z,C.ratio*z,F,E,A);I.stroke()}function D(V,U){var N=(V.x*U.y-V.y*U.x),J=N;var M=V.squaredNorm(),L=U.squaredNorm();if(N==0){return{x:0,y:0,ratio:-1}}var T=(V.y*L-U.y*M+V.y-U.y)/N;var R=(U.x*M-V.x*L+U.x-V.x)/J;var S=-T/2;var Q=-R/2;var P=(T*T+R*R)/4-1;if(P<0){return{x:0,y:0,ratio:-1}}var O=Math.sqrt(P);var K={x:S,y:Q,ratio:O>1000?-1:O,a:T,b:R};return K}function A(J,K){return(J<K)?((J+Math.PI>K)?false:true):((K+Math.PI>J)?true:false)}}};f.Plot={nodeHelper:a,edgeHelper:o,Interpolator:{map:{border:"color",color:"color",width:"number",height:"number",dim:"number",alpha:"number",lineWidth:"number",angularWidth:"number",span:"number",valueArray:"array-number",dimArray:"array-number"},canvas:{globalAlpha:"number",fillStyle:"color",strokeStyle:"color",lineWidth:"number",shadowBlur:"number",shadowColor:"color",shadowOffsetX:"number",shadowOffsetY:"number",miterLimit:"number"},label:{size:"number",color:"color"},compute:function(B,A,z){return B+(A-B)*z},moebius:function(E,D,G,A){var C=A.scale(-G);if(C.norm()<1){var z=C.x,F=C.y;var B=E.startPos.getc().moebiusTransformation(C);E.pos.setc(B.x,B.y);C.x=z;C.y=F}},linear:function(A,z,D){var C=A.startPos.getc(true);var B=A.endPos.getc(true);A.pos.setc(this.compute(C.x,B.x,D),this.compute(C.y,B.y,D))},polar:function(B,A,E){var D=B.startPos.getp(true);var C=B.endPos.getp();var z=C.interpolate(D,E);B.pos.setp(z.theta,z.rho)},number:function(A,F,E,z,D){var C=A[z](F,"start");var B=A[z](F,"end");A[D](F,this.compute(C,B,E))},color:function(B,z,H,E,C){var F=d.hexToRgb(B[E](z,"start"));var G=d.hexToRgb(B[E](z,"end"));var D=this.compute;var A=d.rgbToHex([parseInt(D(F[0],G[0],H)),parseInt(D(F[1],G[1],H)),parseInt(D(F[2],G[2],H))]);B[C](z,A)},"array-number":function(C,B,M,J,E){var K=C[J](B,"start"),L=C[J](B,"end"),N=[];for(var H=0,D=K.length;H<D;H++){var A=K[H],z=L[H];if(A.length){for(var G=0,I=A.length,F=[];G<I;G++){F.push(this.compute(A[G],z[G],M))}N.push(F)}else{N.push(this.compute(A,z,M))}}C[E](B,N)},node:function(A,F,H,z,G,B){z=this[z];if(F){var E=F.length;for(var C=0;C<E;C++){var D=F[C];this[z[D]](A,D,H,G,B)}}else{for(var D in z){this[z[D]](A,D,H,G,B)}}},edge:function(B,A,G,C,z,F){var E=B.adjacencies;for(var D in E){this["node"](E[D],A,G,C,z,F)}},"node-property":function(A,z,B){this["node"](A,z,B,"map","getData","setData")},"edge-property":function(A,z,B){this["edge"](A,z,B,"map","getData","setData")},"label-property":function(A,z,B){this["node"](A,z,B,"label","getLabelData","setLabelData")},"node-style":function(A,z,B){this["node"](A,z,B,"canvas","getCanvasStyle","setCanvasStyle")},"edge-style":function(A,z,B){this["edge"](A,z,B,"canvas","getCanvasStyle","setCanvasStyle")}},sequence:function(A){var B=this;A=d.merge({condition:d.lambda(false),step:d.empty,onComplete:d.empty,duration:200},A||{});var z=setInterval(function(){if(A.condition()){A.step()}else{clearInterval(z);A.onComplete()}B.viz.refresh(true)},A.duration)},prepare:function(F){var E=this.viz.graph,C={"node-property":{getter:"getData",setter:"setData"},"edge-property":{getter:"getData",setter:"setData"},"node-style":{getter:"getCanvasStyle",setter:"setCanvasStyle"},"edge-style":{getter:"getCanvasStyle",setter:"setCanvasStyle"}};var A={};if(d.type(F)=="array"){for(var D=0,z=F.length;D<z;D++){var B=F[D].split(":");A[B.shift()]=B}}else{for(var G in F){if(G=="position"){A[F.position]=[]}else{A[G]=d.splat(F[G])}}}E.eachNode(function(H){H.startPos.set(H.pos);d.each(["node-property","node-style"],function(K){if(K in A){var L=A[K];for(var J=0,I=L.length;J<I;J++){H[C[K].setter](L[J],H[C[K].getter](L[J]),"start")}}});d.each(["edge-property","edge-style"],function(I){if(I in A){var J=A[I];H.eachAdjacency(function(L){for(var M=0,K=J.length;M<K;M++){L[C[I].setter](J[M],L[C[I].getter](J[M]),"start")}})}})});return A},animate:function(C,B){C=d.merge(this.viz.config,C||{});var D=this,A=this.viz,F=A.graph,G=this.Interpolator,E=C.type==="nodefx"?this.nodeFxAnimation:this.animation;var z=this.prepare(C.modes);if(C.hideLabels){this.labels.hideLabels(true)}E.setOptions(d.merge(C,{$animating:false,compute:function(H){F.eachNode(function(I){for(var J in z){G[J](I,z[J],H,B)}});D.plot(C,this.$animating,H);this.$animating=true},complete:function(){if(C.hideLabels){D.labels.hideLabels(false)}D.plot(C);C.onComplete();C.onAfterCompute()}})).start()},nodeFx:function(B){var G=this.viz,H=G.graph,E=this.nodeFxAnimation,I=d.merge(this.viz.config,{elements:{id:false,properties:{}},reposition:false});B=d.merge(I,B||{},{onBeforeCompute:d.empty,onAfterCompute:d.empty});E.stopTimer();var F=B.elements.properties;if(!B.elements.id){H.eachNode(function(K){for(var J in F){K.setData(J,F[J],"end")}})}else{var z=d.splat(B.elements.id);d.each(z,function(L){var K=H.getNode(L);if(K){for(var J in F){K.setData(J,F[J],"end")}}})}var D=[];for(var A in F){D.push(A)}var C=["node-property:"+D.join(":")];if(B.reposition){C.push("linear");G.compute("end")}this.animate(d.merge(B,{modes:C,type:"nodefx"}))},plot:function(A,I){var G=this.viz,E=G.graph,B=G.canvas,z=G.root,F=this,H=B.getCtx(),D=Math.min,A=A||this.viz.controller;A.clearCanvas&&B.clear();var C=!!E.getNode(z).visited;E.eachNode(function(K){var J=K.getData("alpha");K.eachAdjacency(function(L){var M=L.nodeTo;if(!!M.visited===C&&K.drawn&&M.drawn){!I&&A.onBeforePlotLine(L);H.save();H.globalAlpha=D(J,M.getData("alpha"),L.getData("alpha"));F.plotLine(L,B,I);H.restore();!I&&A.onAfterPlotLine(L)}});H.save();if(K.drawn){!I&&A.onBeforePlotNode(K);F.plotNode(K,B,I);!I&&A.onAfterPlotNode(K)}if(!F.labelsHidden&&A.withLabels){if(K.drawn&&J>=0.95){F.labels.plotLabel(B,K,A)}else{F.labels.hideLabel(K,false)}}H.restore();K.visited=!C})},plotTree:function(D,A,H){var E=this,F=this.viz,B=F.canvas,C=this.config,G=B.getCtx();var z=D.getData("alpha");D.eachSubnode(function(J){if(A.plotSubtree(D,J)&&J.exist&&J.drawn){var I=D.getAdjacency(J.id);!H&&A.onBeforePlotLine(I);G.globalAlpha=Math.min(z,J.getData("alpha"));E.plotLine(I,B,H);!H&&A.onAfterPlotLine(I);E.plotTree(J,A,H)}});if(D.drawn){!H&&A.onBeforePlotNode(D);this.plotNode(D,B,H);!H&&A.onAfterPlotNode(D);if(!A.hideLabels&&A.withLabels&&z>=0.95){this.labels.plotLabel(B,D,A)}else{this.labels.hideLabel(D,false)}}else{this.labels.hideLabel(D,true)}},plotNode:function(B,A,I){var F=B.getData("type"),E=this.node.CanvasStyles;if(F!="none"){var z=B.getData("lineWidth"),D=B.getData("color"),C=B.getData("alpha"),G=A.getCtx();G.lineWidth=z;G.fillStyle=G.strokeStyle=D;G.globalAlpha=C;for(var H in E){G[H]=B.getCanvasStyle(H)}this.nodeTypes[F].render.call(this,B,A,I)}},plotLine:function(E,A,H){var D=E.getData("type"),C=this.edge.CanvasStyles;if(D!="none"){var z=E.getData("lineWidth"),B=E.getData("color"),F=A.getCtx();F.lineWidth=z;F.fillStyle=F.strokeStyle=B;for(var G in C){F[G]=E.getCanvasStyle(G)}this.edgeTypes[D].call(this,E,A,H)}}};f.Label={};f.Label.Native=new t({plotLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.font=C.getLabelData("style")+" "+C.getLabelData("size")+"px "+C.getLabelData("family");z.textAlign=C.getLabelData("textAlign");z.fillStyle=z.strokeStyle=C.getLabelData("color");z.textBaseline=C.getLabelData("textBaseline");this.renderLabel(B,C,A)},renderLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.fillText(C.name,D.x,D.y+C.getData("height")/2)},hideLabel:d.empty,hideLabels:d.empty});f.Label.DOM=new t({labelsHidden:false,labelContainer:false,labels:{},getLabelContainer:function(){return this.labelContainer?this.labelContainer:this.labelContainer=document.getElementById(this.viz.config.labelContainer)},getLabel:function(z){return(z in this.labels&&this.labels[z]!=null)?this.labels[z]:this.labels[z]=document.getElementById(z)},hideLabels:function(A){var z=this.getLabelContainer();if(A){z.style.display="none"}else{z.style.display=""}this.labelsHidden=A},clearLabels:function(z){for(var A in this.labels){if(z||!this.viz.graph.hasNode(A)){this.disposeLabel(A);delete this.labels[A]}}},disposeLabel:function(A){var z=this.getLabel(A);if(z&&z.parentNode){z.parentNode.removeChild(z)}},hideLabel:function(D,z){D=d.splat(D);var A=z?"":"none",B,C=this;d.each(D,function(F){var E=C.getLabel(F.id);if(E){E.style.display=A}})},fitsInCanvas:function(B,z){var A=z.getSize();if(B.x>=A.width||B.x<0||B.y>=A.height||B.y<0){return false}return true}});f.Label.HTML=new t({Implements:f.Label.DOM,plotLabel:function(C,D,B){var E=D.id,z=this.getLabel(E);if(!z&&!(z=document.getElementById(E))){z=document.createElement("div");var A=this.getLabelContainer();z.id=E;z.className="node";z.style.position="absolute";B.onCreateLabel(z,D);A.appendChild(z);this.labels[D.id]=z}this.placeLabel(z,D,B)}});f.Label.SVG=new t({Implements:f.Label.DOM,plotLabel:function(C,E,B){var G=E.id,z=this.getLabel(G);if(!z&&!(z=document.getElementById(G))){var D="http://www.w3.org/2000/svg";z=document.createElementNS(D,"svg:text");var F=document.createElementNS(D,"svg:tspan");z.appendChild(F);var A=this.getLabelContainer();z.setAttribute("id",G);z.setAttribute("class","node");A.appendChild(z);B.onCreateLabel(z,E);this.labels[E.id]=z}this.placeLabel(z,E,B)}});f.Geom=new t({initialize:function(z){this.viz=z;this.config=z.config;this.node=z.config.Node;this.edge=z.config.Edge},translate:function(A,z){z=d.splat(z);this.viz.graph.eachNode(function(B){d.each(z,function(C){B.getPos(C).$add(A)})})},setRightLevelToShow:function(C,z,E){var D=this.getRightLevelToShow(C,z),B=this.viz.labels,A=d.merge({execShow:true,execHide:true,onHide:d.empty,onShow:d.empty},E||{});C.eachLevel(0,this.config.levelsToShow,function(G){var F=G._depth-C._depth;if(F>D){A.onHide(G);if(A.execHide){G.drawn=false;G.exist=false;B.hideLabel(G,false)}}else{A.onShow(G);if(A.execShow){G.exist=true}}});C.drawn=true},getRightLevelToShow:function(C,A){var z=this.config;var D=z.levelsToShow;var B=z.constrained;if(!B){return D}while(!this.treeFitsInCanvas(C,A,D)&&D>1){D--}return D}});var e={construct:function(A){var B=(d.type(A)=="array");var z=new f(this.graphOptions,this.config.Node,this.config.Edge,this.config.Label);if(!B){(function(C,E){C.addNode(E);if(E.children){for(var D=0,F=E.children;D<F.length;D++){C.addAdjacence(E,F[D]);arguments.callee(C,F[D])}}})(z,A)}else{(function(K,L){var D=function(P){for(var O=0,M=L.length;O<M;O++){if(L[O].id==P){return L[O]}}var N={id:P,name:P};return K.addNode(N)};for(var H=0,E=L.length;H<E;H++){K.addNode(L[H]);var I=L[H].adjacencies;if(I){for(var F=0,J=I.length;F<J;F++){var C=I[F],G={};if(typeof I[F]!="string"){G=C.data;C=C.nodeTo}K.addAdjacence(L[H],D(C),G)}}}})(z,A)}return z},loadJSON:function(A,z){this.json=A;if(this.labels&&this.labels.clearLabels){this.labels.clearLabels(true)}this.graph=this.construct(A);if(d.type(A)!="array"){this.root=A.id}else{this.root=A[z?z:0].id}},toJSON:function(D){D=D||"tree";if(D=="tree"){var B={};var A=this.graph.getNode(this.root);var B=(function z(G){var E={};E.id=G.id;E.name=G.name;E.data=G.data;var F=[];G.eachSubnode(function(H){F.push(z(H))});E.children=F;return E})(A);return B}else{var B=[];var C=!!this.graph.getNode(this.root).visited;this.graph.eachNode(function(F){var E={};E.id=F.id;E.name=F.name;E.data=F.data;var G=[];F.eachAdjacency(function(H){var J=H.nodeTo;if(!!J.visited===C){var I={};I.nodeTo=J.id;I.data=H.data;G.push(I)}});E.adjacencies=G;B.push(E);F.visited=!C});return B}}};var i=$jit.Layouts={};var h={label:null,compute:function(C,D,A){this.initializeLabel(A);var z=this.label,B=z.style;C.eachNode(function(G){var K=G.getData("autoWidth"),L=G.getData("autoHeight");if(K||L){delete G.data.$width;delete G.data.$height;delete G.data.$dim;var E=G.getData("width"),M=G.getData("height");B.width=K?"auto":E+"px";B.height=L?"auto":M+"px";z.innerHTML=G.name;var I=z.offsetWidth,F=z.offsetHeight;var J=G.getData("type");if(d.indexOf(["circle","square","triangle","star"],J)===-1){G.setData("width",I);G.setData("height",F)}else{var H=I>F?I:F;G.setData("width",H);G.setData("height",H);G.setData("dim",H)}}})},initializeLabel:function(z){if(!this.label){this.label=document.createElement("div");document.body.appendChild(this.label)}this.setLabelStyles(z)},setLabelStyles:function(z){d.extend(this.label.style,{visibility:"hidden",position:"absolute",width:"auto",height:"auto"});this.label.className="jit-autoadjust-label"}};i.Tree=(function(){var I=Array.prototype.slice;function G(S,N,K,Q,L){var P=N.Node;var M=N.multitree;if(P.overridable){var R=-1,O=-1;S.eachNode(function(V){if(V._depth==K&&(!M||("$orn" in V.data)&&V.data.$orn==Q)){var T=V.getData("width",L);var U=V.getData("height",L);R=(R<T)?T:R;O=(O<U)?U:O}});return{width:R<0?P.width:R,height:O<0?P.height:O}}else{return P}}function J(L,O,N,K){var M=(K=="left"||K=="right")?"y":"x";L.getPos(O)[M]+=N}function E(L,M){var K=[];d.each(L,function(N){N=I.call(N);N[0]+=M;N[1]+=M;K.push(N)});return K}function H(N,K){if(N.length==0){return K}if(K.length==0){return N}var M=N.shift(),L=K.shift();return[[M[0],L[1]]].concat(H(N,K))}function C(K,L){L=L||[];if(K.length==0){return L}var M=K.pop();return C(K,H(M,L))}function F(N,L,O,K,M){if(N.length<=M||L.length<=M){return 0}var Q=N[M][1],P=L[M][0];return Math.max(F(N,L,O,K,++M)+O,Q-P+K)}function D(N,L,K){function M(Q,S,P){if(S.length<=P){return[]}var R=S[P],O=F(Q,R,L,K,0);return[O].concat(M(H(Q,E(R,O)),S,++P))}return M([],N,0)}function A(O,N,M){function K(R,T,Q){if(T.length<=Q){return[]}var S=T[Q],P=-F(S,R,N,M,0);return[P].concat(K(H(E(S,P),R),T,++Q))}O=I.call(O);var L=K([],O.reverse(),0);return L.reverse()}function z(Q,O,L,R){var M=D(Q,O,L),P=A(Q,O,L);if(R=="left"){P=M}else{if(R=="right"){M=P}}for(var N=0,K=[];N<M.length;N++){K[N]=(M[N]+P[N])/2}return K}function B(K,U,L,ab,Z){var N=ab.multitree;var T=["x","y"],Q=["width","height"];var M=+(Z=="left"||Z=="right");var R=T[M],aa=T[1-M];var W=ab.Node;var P=Q[M],Y=Q[1-M];var O=ab.siblingOffset;var X=ab.subtreeOffset;var V=ab.align;function S(ae,ai,am){var ad=ae.getData(P,L);var al=ai||(ae.getData(Y,L));var ap=[],an=[],aj=false;var ac=al+ab.levelDistance;ae.eachSubnode(function(ar){if(ar.exist&&(!N||("$orn" in ar.data)&&ar.data.$orn==Z)){if(!aj){aj=G(K,ab,ar._depth,Z,L)}var aq=S(ar,aj[Y],am+ac);ap.push(aq.tree);an.push(aq.extent)}});var ah=z(an,X,O,V);for(var ag=0,af=[],ak=[];ag<ap.length;ag++){J(ap[ag],L,ah[ag],Z);ak.push(E(an[ag],ah[ag]))}var ao=[[-ad/2,ad/2]].concat(C(ak));ae.getPos(L)[R]=0;if(Z=="top"||Z=="left"){ae.getPos(L)[aa]=am}else{ae.getPos(L)[aa]=-am}return{tree:ae,extent:ao}}S(U,false,0)}return new t({compute:function(M,L){var N=M||"start";var K=this.graph.getNode(this.root);d.extend(K,{drawn:true,exist:true,selected:true});h.compute(this.graph,N,this.config);if(!!L||!("_depth" in K)){this.graph.computeLevels(this.root,0,"ignore")}this.computePositions(K,N)},computePositions:function(O,K){var M=this.config;var L=M.multitree;var R=M.align;var N=R!=="center"&&M.indent;var S=M.orientation;var Q=L?["top","right","bottom","left"]:[S];var P=this;d.each(Q,function(T){B(P.graph,O,K,P.config,T,K);var U=["x","y"][+(T=="left"||T=="right")];(function V(W){W.eachSubnode(function(X){if(X.exist&&(!L||("$orn" in X.data)&&X.data.$orn==T)){X.getPos(K)[U]+=W.getPos(K)[U];if(N){X.getPos(K)[U]+=R=="left"?N:-N}V(X)}})})(O)})}})})();$jit.ST=(function(){var A=[];function B(G){G=G||this.clickedNode;if(!this.config.constrained){return[]}var D=this.geom;var K=this.graph;var E=this.canvas;var C=G._depth,H=[];K.eachNode(function(L){if(L.exist&&!L.selected){if(L.isDescendantOf(G.id)){if(L._depth<=C){H.push(L)}}else{H.push(L)}}});var I=D.getRightLevelToShow(G,E);G.eachLevel(I,I,function(L){if(L.exist&&!L.selected){H.push(L)}});for(var J=0;J<A.length;J++){var F=this.graph.getNode(A[J]);if(!F.isDescendantOf(G.id)){H.push(F)}}return H}function z(E){var D=[],C=this.config;E=E||this.clickedNode;this.clickedNode.eachLevel(0,C.levelsToShow,function(F){if(C.multitree&&!("$orn" in F.data)&&F.anySubnode(function(G){return G.exist&&!G.drawn})){D.push(F)}else{if(F.drawn&&!F.anySubnode("drawn")){D.push(F)}}});return D}return new t({Implements:[e,q,i.Tree],initialize:function(C){var E=$jit.ST;var D={levelsToShow:2,levelDistance:30,constrained:true,Node:{type:"rectangle"},duration:700,offsetX:0,offsetY:0};this.controller=this.config=d.merge(p("Canvas","Fx","Tree","Node","Edge","Controller","Tips","NodeStyles","Events","Navigation","Label"),D,C);var F=this.config;if(F.useCanvas){this.canvas=F.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(F.background){F.background=d.merge({type:"Circles"},F.background)}this.canvas=new n(this,F);this.config.labelContainer=(typeof F.injectInto=="string"?F.injectInto:F.injectInto.id)+"-label"}this.graphOptions={complex:true};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new E.Label[F.Label.type](this);this.fx=new E.Plot(this);this.op=new E.Op(this);this.group=new E.Group(this);this.geom=new E.Geom(this);this.clickedNode=null;this.initializeExtras()},plot:function(){this.fx.plot(this.controller)},switchPosition:function(H,G,F){var C=this.geom,D=this.fx,E=this;if(!D.busy){D.busy=true;this.contract({onComplete:function(){C.switchOrientation(H);E.compute("end",false);D.busy=false;if(G=="animate"){E.onClick(E.clickedNode.id,F)}else{if(G=="replot"){E.select(E.clickedNode.id,F)}}}},H)}},switchAlignment:function(E,D,C){this.config.align=E;if(D=="animate"){this.select(this.clickedNode.id,C)}else{if(D=="replot"){this.onClick(this.clickedNode.id,C)}}},addNodeInPath:function(C){A.push(C);this.select((this.clickedNode&&this.clickedNode.id)||this.root)},clearNodesInPath:function(C){A.length=0;this.select((this.clickedNode&&this.clickedNode.id)||this.root)},refresh:function(){this.reposition();this.select((this.clickedNode&&this.clickedNode.id)||this.root)},reposition:function(){this.graph.computeLevels(this.root,0,"ignore");this.geom.setRightLevelToShow(this.clickedNode,this.canvas);this.graph.eachNode(function(C){if(C.exist){C.drawn=true}});this.compute("end")},requestNodes:function(E,F){var D=d.merge(this.controller,F),C=this.config.levelsToShow;if(D.request){var H=[],G=E._depth;E.eachLevel(0,C,function(I){if(I.drawn&&!I.anySubnode()){H.push(I);I._level=C-(I._depth-G)}});this.group.requestNodes(H,D)}else{D.onComplete()}},contract:function(G,H){var F=this.config.orientation;var C=this.geom,E=this.group;if(H){C.switchOrientation(H)}var D=B.call(this);if(H){C.switchOrientation(F)}E.contract(D,d.merge(this.controller,G))},move:function(D,E){this.compute("end",false);var C=E.Move,F={x:C.offsetX,y:C.offsetY};if(C.enable){this.geom.translate(D.endPos.add(F).$scale(-1),"end")}this.fx.animate(d.merge(this.controller,{modes:["linear"]},E))},expand:function(D,E){var C=z.call(this,D);this.group.expand(C,d.merge(this.controller,E))},selectPath:function(F){var E=this;this.graph.eachNode(function(H){H.selected=false});function G(I){if(I==null||I.selected){return}I.selected=true;d.each(E.group.getSiblings([I])[I.id],function(J){J.exist=true;J.drawn=true});var H=I.getParents();H=(H.length>0)?H[0]:null;G(H)}for(var C=0,D=[F.id].concat(A);C<D.length;C++){G(this.graph.getNode(D[C]))}},setRoot:function(J,I,H){if(this.busy){return}this.busy=true;var G=this,E=this.canvas;var C=this.graph.getNode(this.root);var D=this.graph.getNode(J);function F(){if(this.config.multitree&&D.data.$orn){var L=D.data.$orn;var M={left:"right",right:"left",top:"bottom",bottom:"top"}[L];C.data.$orn=M;(function K(N){N.eachSubnode(function(O){if(O.id!=J){O.data.$orn=M;K(O)}})})(C);delete D.data.$orn}this.root=J;this.clickedNode=D;this.graph.computeLevels(this.root,0,"ignore");this.geom.setRightLevelToShow(D,E,{execHide:false,onShow:function(N){if(!N.drawn){N.drawn=true;N.setData("alpha",1,"end");N.setData("alpha",0);N.pos.setc(D.pos.x,D.pos.y)}}});this.compute("end");this.busy=true;this.fx.animate({modes:["linear","node-property:alpha"],onComplete:function(){G.busy=false;G.onClick(J,{onComplete:function(){H&&H.onComplete()}})}})}delete C.data.$orns;if(I=="animate"){F.call(this);G.selectPath(D)}else{if(I=="replot"){F.call(this);this.select(this.root)}}},addSubtree:function(C,E,D){if(E=="replot"){this.op.sum(C,d.extend({type:"replot"},D||{}))}else{if(E=="animate"){this.op.sum(C,d.extend({type:"fade:seq"},D||{}))}}},removeSubtree:function(H,D,G,F){var E=this.graph.getNode(H),C=[];E.eachLevel(+!D,false,function(I){C.push(I.id)});if(G=="replot"){this.op.removeNode(C,d.extend({type:"replot"},F||{}))}else{if(G=="animate"){this.op.removeNode(C,d.extend({type:"fade:seq"},F||{}))}}},select:function(C,F){var K=this.group,I=this.geom;var G=this.graph.getNode(C),E=this.canvas;var J=this.graph.getNode(this.root);var D=d.merge(this.controller,F);var H=this;D.onBeforeCompute(G);this.selectPath(G);this.clickedNode=G;this.requestNodes(G,{onComplete:function(){K.hide(K.prepare(B.call(H)),D);I.setRightLevelToShow(G,E);H.compute("current");H.graph.eachNode(function(N){var M=N.pos.getc(true);N.startPos.setc(M.x,M.y);N.endPos.setc(M.x,M.y);N.visited=false});var L={x:D.offsetX,y:D.offsetY};H.geom.translate(G.endPos.add(L).$scale(-1),["start","current","end"]);K.show(z.call(H));H.plot();D.onAfterCompute(H.clickedNode);D.onComplete()}})},onClick:function(D,K){var F=this.canvas,J=this,C=this.geom,G=this.config;var I={Move:{enable:true,offsetX:G.offsetX||0,offsetY:G.offsetY||0},setRightLevelToShowConfig:false,onBeforeRequest:d.empty,onBeforeContract:d.empty,onBeforeMove:d.empty,onBeforeExpand:d.empty};var E=d.merge(this.controller,I,K);if(!this.busy){this.busy=true;var H=this.graph.getNode(D);this.selectPath(H,this.clickedNode);this.clickedNode=H;E.onBeforeCompute(H);E.onBeforeRequest(H);this.requestNodes(H,{onComplete:function(){E.onBeforeContract(H);J.contract({onComplete:function(){C.setRightLevelToShow(H,F,E.setRightLevelToShowConfig);E.onBeforeMove(H);J.move(H,{Move:E.Move,onComplete:function(){E.onBeforeExpand(H);J.expand(H,{onComplete:function(){J.busy=false;E.onAfterCompute(D);E.onComplete()}})}})}})}})}}})})();$jit.ST.$extend=true;$jit.ST.Op=new t({Implements:f.Op,initialize:function(z){this.viz=z}});$jit.ST.Group=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.config=z.config;this.animation=new x;this.nodes=null},requestNodes:function(E,D){var C=0,A=E.length,G={};var B=function(){D.onComplete()};var z=this.viz;if(A==0){B()}for(var F=0;F<A;F++){G[E[F].id]=E[F];D.request(E[F].id,E[F]._level,{onComplete:function(I,H){if(H&&H.children){H.id=I;z.op.sum(H,{type:"nothing"})}if(++C==A){z.graph.computeLevels(z.root,0);B()}}})}},contract:function(B,A){var z=this.viz;var C=this;B=this.prepare(B);this.animation.setOptions(d.merge(A,{$animating:false,compute:function(D){if(D==1){D=0.99}C.plotStep(1-D,A,this.$animating);this.$animating="contract"},complete:function(){C.hide(B,A)}})).start()},hide:function(B,A){var z=this.viz;for(var C=0;C<B.length;C++){if(true||!A||!A.request){B[C].eachLevel(1,false,function(E){if(E.exist){d.extend(E,{drawn:false,exist:false})}})}else{var D=[];B[C].eachLevel(1,false,function(E){D.push(E.id)});z.op.removeNode(D,{type:"nothing"});z.labels.clearLabels()}}A.onComplete()},expand:function(A,z){var B=this;this.show(A);this.animation.setOptions(d.merge(z,{$animating:false,compute:function(C){B.plotStep(C,z,this.$animating);this.$animating="expand"},complete:function(){B.plotStep(undefined,z,false);z.onComplete()}})).start()},show:function(z){var A=this.config;this.prepare(z);d.each(z,function(C){if(A.multitree&&!("$orn" in C.data)){delete C.data.$orns;var B=" ";C.eachSubnode(function(D){if(("$orn" in D.data)&&B.indexOf(D.data.$orn)<0&&D.exist&&!D.drawn){B+=D.data.$orn+" "}});C.data.$orns=B}C.eachLevel(0,A.levelsToShow,function(D){if(D.exist){D.drawn=true}})})},prepare:function(z){this.nodes=this.getNodesWithChildren(z);return this.nodes},getNodesWithChildren:function(B){var A=[],D=this.config,z=this.viz.root;B.sort(function(H,G){return(H._depth<=G._depth)-(H._depth>=G._depth)});for(var E=0;E<B.length;E++){if(B[E].anySubnode("exist")){for(var C=E+1,F=false;!F&&C<B.length;C++){if(!D.multitree||"$orn" in B[C].data){F=F||B[E].isDescendantOf(B[C].id)}}if(!F){A.push(B[E])}}}return A},plotStep:function(J,F,L){var I=this.viz,C=this.config,B=I.canvas,K=B.getCtx(),z=this.nodes;var E,D;var A={};for(E=0;E<z.length;E++){D=z[E];A[D.id]=[];var H=C.multitree&&!("$orn" in D.data);var G=H&&D.data.$orns;D.eachSubgraph(function(M){if(H&&G&&G.indexOf(M.data.$orn)>0&&M.drawn){M.drawn=false;A[D.id].push(M)}else{if((!H||!G)&&M.drawn){M.drawn=false;A[D.id].push(M)}}});D.drawn=true}if(z.length>0){I.fx.plot()}for(E in A){d.each(A[E],function(M){M.drawn=true})}for(E=0;E<z.length;E++){D=z[E];K.save();I.fx.plotSubtree(D,F,J,L);K.restore()}},getSiblings:function(z){var A={};d.each(z,function(D){var C=D.getParents();if(C.length==0){A[D.id]=[D]}else{var B=[];C[0].eachSubnode(function(E){B.push(E)});A[D.id]=B}});return A}});$jit.ST.Geom=new t({Implements:f.Geom,switchOrientation:function(z){this.config.orientation=z},dispatch:function(){var A=Array.prototype.slice.call(arguments);var B=A.shift(),z=A.length;var C=function(D){return typeof D=="function"?D():D};if(z==2){return(B=="top"||B=="bottom")?C(A[0]):C(A[1])}else{if(z==4){switch(B){case"top":return C(A[0]);case"right":return C(A[1]);case"bottom":return C(A[2]);case"left":return C(A[3])}}}return undefined},getSize:function(G,F){var E=G.data,B=this.config;var A=B.siblingOffset;var D=(B.multitree&&("$orn" in E)&&E.$orn)||B.orientation;var z=G.getData("width")+A;var C=G.getData("height")+A;if(!F){return this.dispatch(D,C,z)}else{return this.dispatch(D,z,C)}},getTreeBaseSize:function(D,E,A){var B=this.getSize(D,true),z=0,C=this;if(A(E,D)){return B}if(E===0){return 0}D.eachSubnode(function(F){z+=C.getTreeBaseSize(F,E-1,A)});return(B>z?B:z)+this.config.subtreeOffset},getEdge:function(E,D,C){var A=function(H,G){return function(){return E.pos.add(new s(H,G))}};var F=this.node;var z=E.getData("width");var B=E.getData("height");if(D=="begin"){if(F.align=="center"){return this.dispatch(C,A(0,B/2),A(-z/2,0),A(0,-B/2),A(z/2,0))}else{if(F.align=="left"){return this.dispatch(C,A(0,B),A(0,0),A(0,0),A(z,0))}else{if(F.align=="right"){return this.dispatch(C,A(0,0),A(-z,0),A(0,-B),A(0,0))}else{throw"align: not implemented"}}}}else{if(D=="end"){if(F.align=="center"){return this.dispatch(C,A(0,-B/2),A(z/2,0),A(0,B/2),A(-z/2,0))}else{if(F.align=="left"){return this.dispatch(C,A(0,0),A(z,0),A(0,B),A(0,0))}else{if(F.align=="right"){return this.dispatch(C,A(0,-B),A(0,0),A(0,0),A(-z,0))}else{throw"align: not implemented"}}}}}},getScaledTreePosition:function(D,F){var E=this.node;var z=D.getData("width");var C=D.getData("height");var B=(this.config.multitree&&("$orn" in D.data)&&D.data.$orn)||this.config.orientation;var A=function(H,G){return function(){return D.pos.add(new s(H,G)).$scale(1-F)}};if(E.align=="left"){return this.dispatch(B,A(0,C),A(0,0),A(0,0),A(z,0))}else{if(E.align=="center"){return this.dispatch(B,A(0,C/2),A(-z/2,0),A(0,-C/2),A(z/2,0))}else{if(E.align=="right"){return this.dispatch(B,A(0,0),A(-z,0),A(0,-C),A(0,0))}else{throw"align: not implemented"}}}},treeFitsInCanvas:function(E,z,F){var B=z.getSize();var C=(this.config.multitree&&("$orn" in E.data)&&E.data.$orn)||this.config.orientation;var A=this.dispatch(C,B.width,B.height);var D=this.getTreeBaseSize(E,F,function(H,G){return H===0||!G.anySubnode()});return(D<A)}});$jit.ST.Plot=new t({Implements:f.Plot,initialize:function(z){this.viz=z;this.config=z.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new $jit.ST.Plot.NodeTypes;this.edgeTypes=new $jit.ST.Plot.EdgeTypes;this.labels=z.labels},plotSubtree:function(C,z,D,H){var F=this.viz,A=F.canvas,B=F.config;D=Math.min(Math.max(0.001,D),1);if(D>=0){C.drawn=false;var G=A.getCtx();var E=F.geom.getScaledTreePosition(C,D);G.translate(E.x,E.y);G.scale(D,D)}this.plotTree(C,d.merge(z,{withLabels:true,hideLabels:!!D,plotSubtree:function(L,J){var I=B.multitree&&!("$orn" in C.data);var K=I&&C.getData("orns");return !I||K.indexOf(elem.getData("orn"))>-1}}),H);if(D>=0){C.drawn=true}},getAlignedPos:function(E,C,z){var B=this.node;var D,A;if(B.align=="center"){D={x:E.x-C/2,y:E.y-z/2}}else{if(B.align=="left"){A=this.config.orientation;if(A=="bottom"||A=="top"){D={x:E.x-C/2,y:E.y}}else{D={x:E.x,y:E.y-z/2}}}else{if(B.align=="right"){A=this.config.orientation;if(A=="bottom"||A=="top"){D={x:E.x-C/2,y:E.y-z}}else{D={x:E.x-C,y:E.y-z/2}}}else{throw"align: not implemented"}}}return D},getOrientation:function(z){var B=this.config;var A=B.orientation;if(B.multitree){var C=z.nodeFrom;var D=z.nodeTo;A=(("$orn" in C.data)&&C.data.$orn)||(("$orn" in D.data)&&D.data.$orn)}return A}});$jit.ST.Label={};$jit.ST.Label.Native=new t({Implements:f.Label.Native,renderLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.fillText(C.name,D.x,D.y)}});$jit.ST.Label.DOM=new t({Implements:f.Label.DOM,placeLabel:function(R,L,H){var D=L.pos.getc(true),Q=this.viz.config,M=Q.Node,z=this.viz.canvas,E=L.getData("width"),O=L.getData("height"),A=z.getSize(),I,P;var C=z.translateOffsetX,B=z.translateOffsetY,G=z.scaleOffsetX,F=z.scaleOffsetY,K=D.x*G+C,J=D.y*F+B;if(M.align=="center"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J-O/2+A.height/2)}}else{if(M.align=="left"){P=Q.orientation;if(P=="bottom"||P=="top"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J+A.height/2)}}else{I={x:Math.round(K+A.width/2),y:Math.round(J-O/2+A.height/2)}}}else{if(M.align=="right"){P=Q.orientation;if(P=="bottom"||P=="top"){I={x:Math.round(K-E/2+A.width/2),y:Math.round(J-O+A.height/2)}}else{I={x:Math.round(K-E+A.width/2),y:Math.round(J-O/2+A.height/2)}}}else{throw"align: not implemented"}}}var N=R.style;N.left=I.x+"px";N.top=I.y+"px";N.display=this.fitsInCanvas(I,z)?"":"none";H.onPlaceLabel(R,L)}});$jit.ST.Label.SVG=new t({Implements:[$jit.ST.Label.DOM,f.Label.SVG],initialize:function(z){this.viz=z}});$jit.ST.Label.HTML=new t({Implements:[$jit.ST.Label.DOM,f.Label.HTML],initialize:function(z){this.viz=z}});$jit.ST.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(A,z){var C=A.getData("dim"),D=this.getAlignedPos(A.pos.getc(true),C,C),B=C/2;this.nodeHelper.circle.render("fill",{x:D.x+B,y:D.y+B},B,z)},contains:function(z,D){var B=z.getData("dim"),C=this.getAlignedPos(z.pos.getc(true),B,B),A=B/2;this.nodeHelper.circle.contains({x:C.x+A,y:C.y+A},A)}},square:{render:function(A,z){var C=A.getData("dim"),B=C/2,D=this.getAlignedPos(A.pos.getc(true),C,C);this.nodeHelper.square.render("fill",{x:D.x+B,y:D.y+B},B,z)},contains:function(z,D){var B=z.getData("dim"),C=this.getAlignedPos(z.pos.getc(true),B,B),A=B/2;this.nodeHelper.square.contains({x:C.x+A,y:C.y+A},A)}},ellipse:{render:function(C,A){var B=C.getData("width"),z=C.getData("height"),D=this.getAlignedPos(C.pos.getc(true),B,z);this.nodeHelper.ellipse.render("fill",{x:D.x+B/2,y:D.y+z/2},B,z,A)},contains:function(B,D){var A=B.getData("width"),z=B.getData("height"),C=this.getAlignedPos(B.pos.getc(true),A,z);this.nodeHelper.ellipse.contains({x:C.x+A/2,y:C.y+z/2},A,z,canvas)}},rectangle:{render:function(C,A){var B=C.getData("width"),z=C.getData("height"),D=this.getAlignedPos(C.pos.getc(true),B,z);this.nodeHelper.rectangle.render("fill",{x:D.x+B/2,y:D.y+z/2},B,z,A)},contains:function(B,D){var A=B.getData("width"),z=B.getData("height"),C=this.getAlignedPos(B.pos.getc(true),A,z);this.nodeHelper.rectangle.contains({x:C.x+A/2,y:C.y+z/2},A,z,canvas)}}});$jit.ST.Plot.EdgeTypes=new t({none:d.empty,line:function(A,C){var B=this.getOrientation(A),D=A.nodeFrom,E=A.nodeTo,z=D._depth<E._depth,G=this.viz.geom.getEdge(z?D:E,"begin",B),F=this.viz.geom.getEdge(z?E:D,"end",B);this.edgeHelper.line(G,F,C)},arrow:function(F,A){var E=this.getOrientation(F),B=F.nodeFrom,z=F.nodeTo,D=F.getData("dim"),H=this.viz.geom.getEdge(B,"begin",E),I=this.viz.geom.getEdge(z,"end",E),G=F.data.$direction,C=(G&&G.length>1&&G[0]!=B.id);this.edgeHelper.arrow(H,I,D,C,A)},"quadratic:begin":function(F,z){var E=this.getOrientation(F);var D=F.nodeFrom,G=F.nodeTo,I=D._depth<G._depth,A=this.viz.geom.getEdge(I?D:G,"begin",E),B=this.viz.geom.getEdge(I?G:D,"end",E),C=F.getData("dim"),H=z.getCtx();H.beginPath();H.moveTo(A.x,A.y);switch(E){case"left":H.quadraticCurveTo(A.x+C,A.y,B.x,B.y);break;case"right":H.quadraticCurveTo(A.x-C,A.y,B.x,B.y);break;case"top":H.quadraticCurveTo(A.x,A.y+C,B.x,B.y);break;case"bottom":H.quadraticCurveTo(A.x,A.y-C,B.x,B.y);break}H.stroke()},"quadratic:end":function(F,z){var E=this.getOrientation(F);var D=F.nodeFrom,G=F.nodeTo,I=D._depth<G._depth,A=this.viz.geom.getEdge(I?D:G,"begin",E),B=this.viz.geom.getEdge(I?G:D,"end",E),C=F.getData("dim"),H=z.getCtx();H.beginPath();H.moveTo(A.x,A.y);switch(E){case"left":H.quadraticCurveTo(B.x-C,B.y,B.x,B.y);break;case"right":H.quadraticCurveTo(B.x+C,B.y,B.x,B.y);break;case"top":H.quadraticCurveTo(B.x,B.y-C,B.x,B.y);break;case"bottom":H.quadraticCurveTo(B.x,B.y+C,B.x,B.y);break}H.stroke()},bezier:function(F,z){var E=this.getOrientation(F),D=F.nodeFrom,G=F.nodeTo,I=D._depth<G._depth,A=this.viz.geom.getEdge(I?D:G,"begin",E),B=this.viz.geom.getEdge(I?G:D,"end",E),C=F.getData("dim"),H=z.getCtx();H.beginPath();H.moveTo(A.x,A.y);switch(E){case"left":H.bezierCurveTo(A.x+C,A.y,B.x-C,B.y,B.x,B.y);break;case"right":H.bezierCurveTo(A.x-C,A.y,B.x+C,B.y,B.x,B.y);break;case"top":H.bezierCurveTo(A.x,A.y+C,B.x,B.y-C,B.x,B.y);break;case"bottom":H.bezierCurveTo(A.x,A.y-C,B.x,B.y+C,B.x,B.y);break}H.stroke()}});$jit.ST.Plot.NodeTypes.implement({"areachart-stacked":{render:function(W,E){var U=W.pos.getc(true),z=W.getData("width"),B=W.getData("height"),H=this.getAlignedPos(U,z,B),ab=H.x,aa=H.y,M=W.getData("stringArray"),G=W.getData("dimArray"),C=W.getData("valueArray"),ad=d.reduce(C,function(aj,ak){return aj+ak[0]},0),ac=d.reduce(C,function(aj,ak){return aj+ak[1]},0),J=W.getData("colorArray"),D=J.length,Y=W.getData("config"),K=W.getData("gradient"),ai=Y.showLabels,O=Y.showAggregates,ae=Y.Label,T=W.getData("prev");var N=E.getCtx(),I=W.getData("border");if(J&&G&&M){for(var ah=0,af=G.length,L=0,F=0,X=0;ah<af;ah++){N.fillStyle=N.strokeStyle=J[ah%D];N.save();if(K&&(G[ah][0]>0||G[ah][1]>0)){var R=L+G[ah][0],P=F+G[ah][1],ag=Math.atan((P-R)/z),Z=55;var V=N.createLinearGradient(ab+z/2,aa-(R+P)/2,ab+z/2+Z*Math.sin(ag),aa-(R+P)/2+Z*Math.cos(ag));var Q=d.rgbToHex(d.map(d.hexToRgb(J[ah%D].slice(1)),function(aj){return(aj*0.85)>>0}));V.addColorStop(0,J[ah%D]);V.addColorStop(1,Q);N.fillStyle=V}N.beginPath();N.moveTo(ab,aa-L);N.lineTo(ab+z,aa-F);N.lineTo(ab+z,aa-F-G[ah][1]);N.lineTo(ab,aa-L-G[ah][0]);N.lineTo(ab,aa-L);N.fill();N.restore();if(I){var S=I.name==M[ah];var A=S?0.7:0.8;var Q=d.rgbToHex(d.map(d.hexToRgb(J[ah%D].slice(1)),function(aj){return(aj*A)>>0}));N.strokeStyle=Q;N.lineWidth=S?4:1;N.save();N.beginPath();if(I.index===0){N.moveTo(ab,aa-L);N.lineTo(ab,aa-L-G[ah][0])}else{N.moveTo(ab+z,aa-F);N.lineTo(ab+z,aa-F-G[ah][1])}N.stroke();N.restore()}L+=(G[ah][0]||0);F+=(G[ah][1]||0);if(G[ah][0]>0){X+=(C[ah][0]||0)}}if(T&&ae.type=="Native"){N.save();N.beginPath();N.fillStyle=N.strokeStyle=ae.color;N.font=ae.style+" "+ae.size+"px "+ae.family;N.textAlign="center";N.textBaseline="middle";if(O(W.name,ad,ac,W)){N.fillText(X,ab,aa-L-Y.labelOffset-ae.size/2,z)}if(ai(W.name,ad,ac,W)){N.fillText(W.name,ab,aa+ae.size/2+Y.labelOffset)}N.restore()}}},contains:function(D,F){var K=D.pos.getc(true),A=D.getData("width"),O=D.getData("height"),N=this.getAlignedPos(K,A,O),M=N.x,L=N.y,P=D.getData("dimArray"),z=F.x-M;if(F.x<M||F.x>M+A||F.y>L||F.y<L-O){return false}for(var G=0,E=P.length,J=L,B=L;G<E;G++){var C=P[G];J-=C[0];B-=C[1];var H=J+(B-J)*z/A;if(F.y>=H){var I=+(z>A/2);return{name:D.getData("stringArray")[G],color:D.getData("colorArray")[G],value:D.getData("valueArray")[G][I],index:I}}}return false}}});$jit.AreaChart=new t({st:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(B){this.controller=this.config=d.merge(p("Canvas","Label","AreaChart"),{Label:{type:"Native"}},B);var C=this.config.showLabels,A=d.type(C),D=this.config.showAggregates,z=d.type(D);this.config.showLabels=A=="function"?C:d.lambda(C);this.config.showAggregates=z=="function"?D:d.lambda(D);this.initializeViz()},initializeViz:function(){var B=this.config,E=this,z=B.type.split(":")[0],D={};var A=new $jit.ST({injectInto:B.injectInto,orientation:"bottom",levelDistance:0,siblingOffset:0,subtreeOffset:0,withLabels:B.Label.type!="Native",useCanvas:B.useCanvas,Label:{type:B.Label.type},Node:{overridable:true,type:"areachart-"+z,align:"left",width:1,height:1},Edge:{type:"none"},Tips:{enable:B.Tips.enable,type:"Native",force:true,onShow:function(I,H,F){var G=F;B.Tips.onShow(I,G,H)}},Events:{enable:true,type:"Native",onClick:function(H,I,F){if(!B.filterOnClick&&!B.Events.enable){return}var G=I.getContains();if(G){B.filterOnClick&&E.filter(G.name)}B.Events.enable&&B.Events.onClick(G,I,F)},onRightClick:function(G,H,F){if(!B.restoreOnRightClick){return}E.restore()},onMouseMove:function(H,I,F){if(!B.selectOnHover){return}if(H){var G=I.getContains();E.select(H.id,G.name,G.index)}else{E.select(false,false,false)}}},onCreateLabel:function(L,I){var R=B.Label,Q=I.getData("valueArray"),J=d.reduce(Q,function(S,T){return S+T[0]},0),O=d.reduce(Q,function(S,T){return S+T[1]},0);if(I.getData("prev")){var N={wrapper:document.createElement("div"),aggregate:document.createElement("div"),label:document.createElement("div")};var F=N.wrapper,P=N.label,G=N.aggregate,H=F.style,M=P.style,K=G.style;D[I.id]=N;F.appendChild(P);F.appendChild(G);if(!B.showLabels(I.name,J,O,I)){P.style.display="none"}if(!B.showAggregates(I.name,J,O,I)){G.style.display="none"}H.position="relative";H.overflow="visible";H.fontSize=R.size+"px";H.fontFamily=R.family;H.color=R.color;H.textAlign="center";K.position=M.position="absolute";L.style.width=I.getData("width")+"px";L.style.height=I.getData("height")+"px";P.innerHTML=I.name;L.appendChild(F)}},onPlaceLabel:function(W,Q){if(!Q.getData("prev")){return}var U=D[Q.id],G=U.wrapper.style,F=U.label.style,P=U.aggregate.style,N=Q.getData("width"),L=Q.getData("height"),K=Q.getData("dimArray"),H=Q.getData("valueArray"),M=d.reduce(H,function(X,Y){return X+Y[0]},0),I=d.reduce(H,function(X,Y){return X+Y[1]},0),J=parseInt(G.fontSize,10),O=W.style;if(K&&H){if(B.showLabels(Q.name,M,I,Q)){F.display=""}else{F.display="none"}if(B.showAggregates(Q.name,M,I,Q)){P.display=""}else{P.display="none"}G.width=P.width=F.width=W.style.width=N+"px";P.left=F.left=-N/2+"px";for(var T=0,R=H.length,S=0,V=0;T<R;T++){if(K[T][0]>0){S+=H[T][0];V+=K[T][0]}}P.top=(-J-B.labelOffset)+"px";F.top=(B.labelOffset+V)+"px";W.style.top=parseInt(W.style.top,10)-V+"px";W.style.height=G.height=V+"px";U.aggregate.innerHTML=S}}});var C=A.canvas.getSize();A.config.offsetY=-C.height/2+B.offset+(B.showLabels&&(B.labelOffset+B.Label.size));this.st=A;this.canvas=this.st.canvas},loadJSON:function(Q){var N=d.time(),E=[],J=this.st,T=d.splat(Q.label),M=d.splat(Q.color||this.colors),R=this.config,A=!!R.type.split(":")[1],C=R.animate;for(var O=0,B=Q.values,L=B.length;O<L-1;O++){var S=B[O],H=B[O-1],I=B[O+1];var P=d.splat(B[O].values),z=d.splat(B[O+1].values);var D=d.zip(P,z);var G=0,F=0;E.push({id:N+S.label,name:S.label,data:{value:D,"$valueArray":D,"$colorArray":M,"$stringArray":T,"$next":I.label,"$prev":H?H.label:null,"$config":R,"$gradient":A},children:[]})}var K={id:N+"$root",name:"",data:{"$type":"none","$width":1,"$height":1},children:E};J.loadJSON(K);this.normalizeDims();J.compute();J.select(J.root);if(C){J.fx.animate({modes:["node-property:height:dimArray"],duration:1500})}},updateJSON:function(C,F){if(this.busy){return}this.busy=true;var B=this.st,E=B.graph,G=C.label&&d.splat(C.label),A=C.values,z=this.config.animate,D=this;d.each(A,function(H){var M=E.getByName(H.label);if(M){H.values=d.splat(H.values);var I=M.getData("stringArray"),L=M.getData("valueArray");d.each(L,function(N,O){N[0]=H.values[O];if(G){I[O]=G[O]}});M.setData("valueArray",L);var J=M.getData("prev");if(J){var K=E.getByName(J);var L=K.getData("valueArray");d.each(L,function(N,O){N[1]=H.values[O]});K.setData("valueArray",L)}}});this.normalizeDims();B.compute();B.select(B.root);if(z){B.fx.animate({modes:["node-property:height:dimArray"],duration:1500,onComplete:function(){D.busy=false;F&&F.onComplete()}})}},filter:function(){if(this.busy){return}this.busy=true;if(this.config.Tips.enable){this.st.tips.hide()}this.select(false,false,false);var A=Array.prototype.slice.call(arguments);var z=this.st.graph.getNode(this.st.root);var B=this;z.eachAdjacency(function(C){var F=C.nodeTo,E=F.getData("dimArray"),D=F.getData("stringArray");F.setData("dimArray",d.map(E,function(H,G){return(d.indexOf(A,D[G])>-1)?H:[0,0]}),"end")});this.st.fx.animate({modes:["node-property:dimArray"],duration:1500,onComplete:function(){B.busy=false}})},restore:function(){if(this.busy){return}this.busy=true;if(this.config.Tips.enable){this.st.tips.hide()}this.select(false,false,false);this.normalizeDims();var z=this;this.st.fx.animate({modes:["node-property:height:dimArray"],duration:1500,onComplete:function(){z.busy=false}})},select:function(E,A,z){if(!this.config.selectOnHover){return}var B=this.selected;if(B.id!=E||B.name!=A||B.index!=z){B.id=E;B.name=A;B.index=z;this.st.graph.eachNode(function(F){F.setData("border",false)});if(E){var D=this.st.graph.getNode(E);D.setData("border",B);var C=z===0?"prev":"next";C=D.getData(C);if(C){D=this.st.graph.getByName(C);if(D){D.setData("border",{name:A,index:1-z})}}}this.st.plot()}},getLegend:function(){var B={};var C;this.st.graph.getNode(this.st.root).eachAdjacency(function(D){C=D.nodeTo});var A=C.getData("colorArray"),z=A.length;d.each(C.getData("stringArray"),function(E,D){B[E]=A[D%z]});return B},getMaxValue:function(){var z=0;this.st.graph.eachNode(function(E){var B=E.getData("valueArray"),A=0,D=0;d.each(B,function(F){A+=+F[0];D+=+F[1]});var C=D>A?D:A;z=z>C?z:C});return z},normalizeDims:function(){var F=this.st.graph.getNode(this.st.root),C=0;F.eachAdjacency(function(){C++});var E=this.getMaxValue(),I=this.st.canvas.getSize(),B=this.config,D=B.offset,G=B.labelOffset+B.Label.size,z=(I.width-2*D)/C,A=B.animate,H=I.height-2*D-(B.showAggregates&&G)-(B.showLabels&&G);this.st.graph.eachNode(function(O){var L=0,N=0,J=[];d.each(O.getData("valueArray"),function(P){L+=+P[0];N+=+P[1];J.push([0,0])});var M=N>L?N:L;O.setData("width",z);if(A){O.setData("height",M*H/E,"end");O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return[P[0]*H/E,P[1]*H/E]}),"end");var K=O.getData("dimArray");if(!K){O.setData("dimArray",J)}}else{O.setData("height",M*H/E);O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return[P[0]*H/E,P[1]*H/E]}))}})}});i.Radial=new t({compute:function(A){var B=d.splat(A||["current","start","end"]);h.compute(this.graph,B,this.config);this.graph.computeLevels(this.root,0,"ignore");var z=this.createLevelDistanceFunc();this.computeAngularWidths(B);this.computePositions(B,z)},computePositions:function(G,D){var I=G;var H=this.graph;var E=H.getNode(this.root);var F=this.parent;var z=this.config;for(var B=0,A=I.length;B<A;B++){var C=I[B];E.setPos(m(0,0),C);E.setData("span",Math.PI*2,C)}E.angleSpan={begin:0,end:2*Math.PI};H.eachBFS(this.root,function(N){var T=N.angleSpan.end-N.angleSpan.begin;var V=N.angleSpan.begin;var U=D(N);var W=0,J=[],M={};N.eachSubnode(function(Z){W+=Z._treeAngularWidth;for(var aa=0,Y=I.length;aa<Y;aa++){var ac=I[aa],ab=Z.getData("dim",ac);M[ac]=(ac in M)?(ab>M[ac]?ab:M[ac]):ab}J.push(Z)},"ignore");if(F&&F.id==N.id&&J.length>0&&J[0].dist){J.sort(function(Z,Y){return(Z.dist>=Y.dist)-(Z.dist<=Y.dist)})}for(var P=0,R=J.length;P<R;P++){var L=J[P];if(!L._flag){var X=L._treeAngularWidth/W*T;var K=V+X/2;for(var Q=0,O=I.length;Q<O;Q++){var S=I[Q];L.setPos(m(K,U),S);L.setData("span",X,S);L.setData("dim-quotient",L.getData("dim",S)/M[S],S)}L.angleSpan={begin:V,end:V+X};V+=X}}},"ignore")},setAngularWidthForNodes:function(z){this.graph.eachBFS(this.root,function(C,A){var B=C.getData("angularWidth",z[0])||5;C._angularWidth=B/A},"ignore")},setSubtreesAngularWidth:function(){var z=this;this.graph.eachNode(function(A){z.setSubtreeAngularWidth(A)},"ignore")},setSubtreeAngularWidth:function(C){var B=this,A=C._angularWidth,z=0;C.eachSubnode(function(D){B.setSubtreeAngularWidth(D);z+=D._treeAngularWidth},"ignore");C._treeAngularWidth=Math.max(A,z)},computeAngularWidths:function(z){this.setAngularWidthForNodes(z);this.setSubtreesAngularWidth()}});s.prototype.moebiusTransformation=function(B){var z=this.add(B);var A=B.$conjugate().$prod(this);A.x++;return z.$div(A)};f.Util.moebiusTransformation=function(B,D,C,A,z){this.eachNode(B,function(F){for(var E=0;E<C.length;E++){var H=D[E].scale(-1),G=A?A:C[E];F.getPos(C[E]).set(F.getPos(G).getc().moebiusTransformation(H))}},z)};$jit.Hypertree=new t({Implements:[e,q,i.Radial],initialize:function(z){var C=$jit.Hypertree;var A={radius:"auto",offset:0,Edge:{type:"hyperline"},duration:1500,fps:35};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Tips","NodeStyles","Events","Navigation","Controller","Label"),A,z);var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(B.background){B.background=d.merge({type:"Circles"},B.background)}this.canvas=new n(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={complex:false,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new C.Label[B.Label.type](this);this.fx=new C.Plot(this);this.op=new C.Op(this);this.json=null;this.root=null;this.busy=false;this.initializeExtras()},createLevelDistanceFunc:function(){var D=this.getRadius();var F=0,z=Math.max,A=this.config;this.graph.eachNode(function(G){F=z(G._depth,F)},"ignore");F++;var E=function(G){return function(I){I.scale=D;var K=I._depth+1;var J=0,H=Math.pow;while(K){J+=H(G,K--)}return J-A.offset}};for(var C=0.51;C<=1;C+=0.01){var B=(1-Math.pow(C,F))/(1-C);if(B>=2){return E(C-0.01)}}return E(0.75)},getRadius:function(){var z=this.config.radius;if(z!=="auto"){return z}var A=this.canvas.getSize();return Math.min(A.width,A.height)/2},refresh:function(z){if(z){this.reposition();this.graph.eachNode(function(A){A.startPos.rho=A.pos.rho=A.endPos.rho;A.startPos.theta=A.pos.theta=A.endPos.theta})}else{this.compute()}this.plot()},reposition:function(){this.compute("end");var z=this.graph.getNode(this.root).pos.getc().scale(-1);f.Util.moebiusTransformation(this.graph,[z],["end"],"end","ignore");this.graph.eachNode(function(A){if(A.ignore){A.endPos.rho=A.pos.rho;A.endPos.theta=A.pos.theta}})},plot:function(){this.fx.plot()},onClick:function(B,z){var A=this.graph.getNode(B).pos.getc(true);this.move(A,z)},move:function(D,B){var A=u(D.x,D.y);if(this.busy===false&&A.norm()<1){this.busy=true;var z=this.graph.getClosestNodeToPos(A),C=this;this.graph.computeLevels(z.id,0);this.controller.onBeforeCompute(z);B=d.merge({onComplete:d.empty},B||{});this.fx.animate(d.merge({modes:["moebius"],hideLabels:true},B,{onComplete:function(){C.busy=false;B.onComplete()}}),A)}}});$jit.Hypertree.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native,initialize:function(A){this.viz=A},renderLabel:function(C,E,B){var A=C.getCtx();var F=E.pos.getc(true);var D=this.viz.getRadius();A.fillText(E.name,F.x*D,F.y*D)}});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(L,F,G){var J=F.pos.getc(true),C=this.viz.canvas,D=C.translateOffsetX,B=C.translateOffsetY,K=C.scaleOffsetX,I=C.scaleOffsetY,H=C.getSize(),A=this.viz.getRadius();var E={x:Math.round((J.x*K)*A+D+H.width/2),y:Math.round((J.y*I)*A+B+H.height/2)};L.setAttribute("x",E.x);L.setAttribute("y",E.y);G.onPlaceLabel(L,F)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(M,G,H){var K=G.pos.getc(true),D=this.viz.canvas,E=D.translateOffsetX,C=D.translateOffsetY,L=D.scaleOffsetX,J=D.scaleOffsetY,I=D.getSize(),A=this.viz.getRadius();var F={x:Math.round((K.x*L)*A+E+I.width/2),y:Math.round((K.y*J)*A+C+I.height/2)};var B=M.style;B.left=F.x+"px";B.top=F.y+"px";B.display=this.fitsInCanvas(F,D)?"":"none";H.onPlaceLabel(M,G)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.circle.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.circle.contains(C,D,B)}},ellipse:{render:function(D,B){var E=D.pos.getc().$scale(D.scale),C=D.getData("width"),A=D.getData("height");this.nodeHelper.ellipse.render("fill",E,C,A,B)},contains:function(C,E){var B=C.getData("width"),A=C.getData("height"),D=C.pos.getc().$scale(C.scale);return this.nodeHelper.circle.contains(D,E,B,A)}},square:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.square.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.square.contains(C,D,B)}},rectangle:{render:function(E,B){var D=this.node,C=E.getData("width"),A=E.getData("height"),F=E.pos.getc();C=D.transform?C*(1-F.squaredNorm()):C;A=D.transform?A*(1-F.squaredNorm()):A;F.$scale(E.scale);if(C>0.2&&A>0.2){this.nodeHelper.rectangle.render("fill",F,C,A,B)}},contains:function(C,E){var B=C.getData("width"),A=C.getData("height"),D=C.pos.getc().$scale(C.scale);return this.nodeHelper.square.contains(D,E,B,A)}},triangle:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.triangle.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.triangle.contains(C,D,B)}},star:{render:function(C,A){var B=this.node,E=C.getData("dim"),D=C.pos.getc();E=B.transform?E*(1-D.squaredNorm()):E;D.$scale(C.scale);if(E>0.2){this.nodeHelper.star.render("fill",D,E,A)}},contains:function(A,D){var B=A.getData("dim"),C=A.pos.getc().$scale(A.scale);return this.nodeHelper.star.contains(C,D,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var E=A.nodeFrom.pos.getc(true),D=A.nodeTo.pos.getc(true),C=A.nodeFrom.scale;this.edgeHelper.line({x:E.x*C,y:E.y*C},{x:D.x*C,y:D.y*C},B)},arrow:function(B,C){var H=B.nodeFrom.pos.getc(true),G=B.nodeTo.pos.getc(true),D=B.nodeFrom.scale,F=B.getData("dim"),E=B.data.$direction,A=(E&&E.length>1&&E[0]!=B.nodeFrom.id);this.edgeHelper.arrow({x:H.x*D,y:H.y*D},{x:G.x*D,y:G.y*D},F,A,C)},hyperline:function(A,B){var E=A.nodeFrom.pos.getc(),D=A.nodeTo.pos.getc(),C=this.viz.getRadius();this.edgeHelper.hyperline(E,D,C,B)}})})($jit.Hypertree);i.TM={};i.TM.SliceAndDice=new t({compute:function(E){var A=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(A);var C=this.canvas.getSize(),B=this.config,D=C.width,z=C.height;this.graph.computeLevels(this.root,0,"ignore");A.getPos(E).setc(-D/2,-z/2);A.setData("width",D,E);A.setData("height",z+B.titleHeight,E);this.computePositions(A,A,this.layout.orientation,E);this.controller.onAfterCompute(A)},computePositions:function(I,G,S,B){var P=0;I.eachSubnode(function(U){P+=U.getData("area",B)});var T=this.config,Q=T.offset,M=I.getData("width",B),K=I.getData("height",B)-T.titleHeight,A=I==G?1:(G.getData("area",B)/P);var L,J,O,E,D,H,F;var R=(S=="h");if(R){S="v";L=K;J=M*A;O="height";E="y";D="x";H=T.titleHeight;F=0}else{S="h";L=K*A;J=M;O="width";E="x";D="y";H=0;F=T.titleHeight}var z=G.getPos(B);G.setData("width",J,B);G.setData("height",L,B);var N=0,C=this;G.eachSubnode(function(V){var U=V.getPos(B);U[E]=N+z[E]+H;U[D]=z[D]+F;C.computePositions(G,V,S,B);N+=V.getData(O,B)})}});i.TM.Area={compute:function(z){z=z||"current";var F=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(F);var B=this.config,I=this.canvas.getSize(),A=I.width,H=I.height,G=B.offset,C=A-G,E=H-G;this.graph.computeLevels(this.root,0,"ignore");F.getPos(z).setc(-A/2,-H/2);F.setData("width",A,z);F.setData("height",H,z);var D={top:-H/2+B.titleHeight,left:-A/2,width:C,height:E-B.titleHeight};this.computePositions(F,D,z);this.controller.onAfterCompute(F)},computeDim:function(D,E,G,C,B,z){if(D.length+E.length==1){var A=(D.length==1)?D:E;this.layoutLast(A,G,C,z);return}if(D.length>=2&&E.length==0){E=[D.shift()]}if(D.length==0){if(E.length>0){this.layoutRow(E,G,C,z)}return}var F=D[0];if(B(E,G)>=B([F].concat(E),G)){this.computeDim(D.slice(1),E.concat([F]),G,C,B,z)}else{var H=this.layoutRow(E,G,C,z);this.computeDim(D,[],H.dim,H,B,z)}},worstAspectRatio:function(z,H){if(!z||z.length==0){return Number.MAX_VALUE}var A=0,I=0,D=Number.MAX_VALUE;for(var F=0,E=z.length;F<E;F++){var B=z[F]._area;A+=B;D=D<B?D:B;I=I>B?I:B}var G=H*H,C=A*A;return Math.max(G*I/C,C/(G*D))},avgAspectRatio:function(D,A){if(!D||D.length==0){return Number.MAX_VALUE}var F=0;for(var B=0,z=D.length;B<z;B++){var E=D[B]._area;var C=E/A;F+=A>C?A/C:C/A}return F/z},layoutLast:function(A,z,D,C){var B=A[0];B.getPos(C).setc(D.left,D.top);B.setData("width",D.width,C);B.setData("height",D.height,C)}};i.TM.Squarified=new t({Implements:i.TM.Area,computePositions:function(D,G,A){var C=this.config;if(!(G.width>=G.height&&this.layout.horizontal())){this.layout.change()}var z=D.getSubnodes([1,1],"ignore");if(z.length>0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;F<E;F++){var I=z[F];var J=C.offset,K=I.getData("height",A)-J-C.titleHeight,B=I.getData("width",A)-J;var H=I.getPos(A);G={width:B,height:K,top:H.y+C.titleHeight,left:H.x};this.computePositions(I,G,A)}}},processChildrenLayout:function(J,z,F,A){var D=F.width*F.height;var E,B=z.length,G=0,K=[];for(E=0;E<B;E++){K[E]=parseFloat(z[E].getData("area",A));G+=K[E]}for(E=0;E<B;E++){z[E]._area=D*K[E]/G}var C=this.layout.horizontal()?F.height:F.width;z.sort(function(M,L){return(M._area<=L._area)-(M._area>=L._area)});var I=[z[0]];var H=z.slice(1);this.squarify(H,I,C,F,A)},squarify:function(A,D,z,C,B){this.computeDim(A,D,z,C,this.worstAspectRatio,B)},layoutRow:function(A,z,C,B){if(this.layout.horizontal()){return this.layoutV(A,z,C,B)}else{return this.layoutH(A,z,C,B)}},layoutV:function(z,K,G,A){var L=0,C=function(M){return M};d.each(z,function(M){L+=M._area});var B=C(L/K),H=0;for(var E=0,D=z.length;E<D;E++){var F=C(z[E]._area/B);var I=z[E];I.getPos(A).setc(G.left,G.top+H);I.setData("width",B,A);I.setData("height",F,A);H+=F}var J={height:G.height,width:G.width-B,top:G.top,left:G.left+B};J.dim=Math.min(J.width,J.height);if(J.dim!=J.height){this.layout.change()}return J},layoutH:function(z,I,E,A){var K=0;d.each(z,function(L){K+=L._area});var J=K/I,F=E.top,B=0;for(var D=0,C=z.length;D<C;D++){var G=z[D];var I=G._area/J;G.getPos(A).setc(E.left+B,F);G.setData("width",I,A);G.setData("height",J,A);B+=I}var H={height:E.height-J,width:E.width,top:E.top+J,left:E.left};H.dim=Math.min(H.width,H.height);if(H.dim!=H.width){this.layout.change()}return H}});i.TM.Strip=new t({Implements:i.TM.Area,computePositions:function(D,G,A){var z=D.getSubnodes([1,1],"ignore"),C=this.config;if(z.length>0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;F<E;F++){var I=z[F];var J=C.offset,K=I.getData("height",A)-J-C.titleHeight,B=I.getData("width",A)-J;var H=I.getPos(A);G={width:B,height:K,top:H.y+C.titleHeight,left:H.x};this.computePositions(I,G,A)}}},processChildrenLayout:function(J,z,E,A){var C=E.width*E.height;var D,B=z.length,F=0,K=[];for(D=0;D<B;D++){K[D]=+z[D].getData("area",A);F+=K[D]}for(D=0;D<B;D++){z[D]._area=C*K[D]/F}var I=this.layout.horizontal()?E.width:E.height;var H=[z[0]];var G=z.slice(1);this.stripify(G,H,I,E,A)},stripify:function(A,D,z,C,B){this.computeDim(A,D,z,C,this.avgAspectRatio,B)},layoutRow:function(A,z,C,B){if(this.layout.horizontal()){return this.layoutH(A,z,C,B)}else{return this.layoutV(A,z,C,B)}},layoutV:function(z,I,F,A){var J=0;d.each(z,function(K){J+=K._area});var B=J/I,G=0;for(var D=0,C=z.length;D<C;D++){var H=z[D];var E=H._area/B;H.getPos(A).setc(F.left,F.top+(I-E-G));H.setData("width",B,A);H.setData("height",E,A);G+=E}return{height:F.height,width:F.width-B,top:F.top,left:F.left+B,dim:I}},layoutH:function(z,H,E,A){var J=0;d.each(z,function(L){J+=L._area});var I=J/H,F=E.height-I,B=0;for(var D=0,C=z.length;D<C;D++){var G=z[D];var K=G._area/I;G.getPos(A).setc(E.left+B,E.top+F);G.setData("width",K,A);G.setData("height",I,A);B+=K}return{height:E.height-I,width:E.width,top:E.top,left:E.left,dim:H}}});i.Icicle=new t({compute:function(H){H=H||"current";var G=this.graph.getNode(this.root),C=this.config,K=this.canvas.getSize(),z=K.width,J=K.height,D=C.offset,F=C.constrained?C.levelsToShow:Number.MAX_VALUE;this.controller.onBeforeCompute(G);f.Util.computeLevels(this.graph,G.id,0,"ignore");var I=0;f.Util.eachLevel(G,0,false,function(M,L){if(L>I){I=L}});var B=this.graph.getNode(this.clickedNode&&this.clickedNode.id||G.id);var A=Math.min(I,F-1);var E=B._depth;if(this.layout.horizontal()){this.computeSubtree(B,-z/2,-J/2,z/(A+1),J,E,A,H)}else{this.computeSubtree(B,-z/2,-J/2,z,J/(A+1),E,A,H)}},computeSubtree:function(H,J,G,z,M,F,B,I){H.getPos(I).setc(J,G);H.setData("width",z,I);H.setData("height",M,I);var D,L=0,K=0;var A=f.Util.getSubnodes(H,[1,1]);if(!A.length){return}d.each(A,function(N){K+=N.getData("dim")});for(var E=0,C=A.length;E<C;E++){if(this.layout.horizontal()){D=M*A[E].getData("dim")/K;this.computeSubtree(A[E],J+z,G,z,D,F,B,I);G+=D}else{D=z*A[E].getData("dim")/K;this.computeSubtree(A[E],J,G+M,D,M,F,B,I);J+=D}}}});$jit.Icicle=new t({Implements:[e,q,i.Icicle],layout:{orientation:"h",vertical:function(){return this.orientation=="v"},horizontal:function(){return this.orientation=="h"},change:function(){this.orientation=this.vertical()?"h":"v"}},initialize:function(z){var A={animate:false,orientation:"h",offset:2,levelsToShow:Number.MAX_VALUE,constrained:false,Node:{type:"rectangle",overridable:true},Edge:{type:"none"},Label:{type:"Native"},duration:700,fps:45};var C=p("Canvas","Node","Edge","Fx","Tips","NodeStyles","Events","Navigation","Controller","Label");this.controller=this.config=d.merge(C,A,z);this.layout.orientation=this.config.orientation;var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{this.canvas=new n(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={complex:true,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge,this.config.Label);this.labels=new $jit.Icicle.Label[this.config.Label.type](this);this.fx=new $jit.Icicle.Plot(this);this.op=new $jit.Icicle.Op(this);this.group=new $jit.Icicle.Group(this);this.clickedNode=null;this.initializeExtras()},refresh:function(){var z=this.config.Label.type;if(z!="Native"){var A=this;this.graph.eachNode(function(B){A.labels.hideLabel(B,false)})}this.compute();this.plot()},plot:function(){this.fx.plot(this.config)},enter:function(B){if(this.busy){return}this.busy=true;var A=this,z=this.config;var C={onComplete:function(){if(z.request){A.compute()}if(z.animate){A.graph.nodeList.setDataset(["current","end"],{alpha:[1,0]});f.Util.eachSubgraph(B,function(D){D.setData("alpha",1,"end")},"ignore");A.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){A.clickedNode=B;A.compute("end");A.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){A.busy=false;A.clickedNode=B}})}})}else{A.clickedNode=B;A.busy=false;A.refresh()}}};if(z.request){this.requestNodes(clickedNode,C)}else{C.onComplete()}},out:function(){if(this.busy){return}var E=this,D=f.Util,B=this.config,G=this.graph,A=D.getParents(G.getNode(this.clickedNode&&this.clickedNode.id||this.root)),C=A[0],z=C,F=this.clickedNode;this.busy=true;this.events.hoveredNode=false;if(!C){this.busy=false;return}callback={onComplete:function(){E.clickedNode=C;if(B.request){E.requestNodes(C,{onComplete:function(){E.compute();E.plot();E.busy=false}})}else{E.compute();E.plot();E.busy=false}}};if(B.animate){this.clickedNode=z;this.compute("end");this.clickedNode=F;this.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){E.clickedNode=z;G.nodeList.setDataset(["current","end"],{alpha:[0,1]});D.eachSubgraph(F,function(H){H.setData("alpha",1)},"ignore");E.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){callback.onComplete()}})}})}else{callback.onComplete()}},requestNodes:function(B,C){var A=d.merge(this.controller,C),z=this.config.constrained?this.config.levelsToShow:Number.MAX_VALUE;if(A.request){var E=[],D=B._depth;f.Util.eachLevel(B,0,z,function(F){if(F.drawn&&!f.Util.anySubnode(F)){E.push(F);F._level=F._depth-D;if(this.config.constrained){F._level=z-F._level}}});this.group.requestNodes(E,A)}else{A.onComplete()}}});$jit.Icicle.Op=new t({Implements:f.Op,initialize:function(z){this.viz=z}});$jit.Icicle.Group=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.config=z.config},requestNodes:function(E,D){var C=0,A=E.length,G={};var B=function(){D.onComplete()};var z=this.viz;if(A==0){B()}for(var F=0;F<A;F++){G[E[F].id]=E[F];D.request(E[F].id,E[F]._level,{onComplete:function(I,H){if(H&&H.children){H.id=I;z.op.sum(H,{type:"nothing"})}if(++C==A){f.Util.computeLevels(z.graph,z.root,0);B()}}})}}});$jit.Icicle.Plot=new t({Implements:f.Plot,initialize:function(z){this.viz=z;this.config=z.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new $jit.Icicle.Plot.NodeTypes;this.edgeTypes=new $jit.Icicle.Plot.EdgeTypes;this.labels=z.labels},plot:function(D,B){D=D||this.viz.controller;var z=this.viz,E=z.graph,A=E.getNode(z.clickedNode&&z.clickedNode.id||z.root),C=A._depth;z.canvas.clear();this.plotTree(A,d.merge(D,{withLabels:true,hideLabels:false,plotSubtree:function(F,G){return !z.config.constrained||(G._depth-C<z.config.levelsToShow)}}),B)}});$jit.Icicle.Label={};$jit.Icicle.Label.Native=new t({Implements:f.Label.Native,renderLabel:function(A,B,D){var G=A.getCtx(),z=B.getData("width"),F=B.getData("height"),H=B.getLabelData("size"),C=G.measureText(B.name);if(F<(H*1.5)||z<C.width){return}var E=B.pos.getc(true);G.fillText(B.name,E.x+z/2,E.y+F/2)}});$jit.Icicle.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(z){this.viz=z},placeLabel:function(A,D,B){var F=D.pos.getc(true),C=this.viz.canvas;var z=C.getSize();var E={x:Math.round(F.x+z.width/2),y:Math.round(F.y+z.height/2)};A.setAttribute("x",E.x);A.setAttribute("y",E.y);B.onPlaceLabel(A,D)}});$jit.Icicle.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(z){this.viz=z},placeLabel:function(A,E,B){var G=E.pos.getc(true),C=this.viz.canvas;var z=C.getSize();var F={x:Math.round(G.x+z.width/2),y:Math.round(G.y+z.height/2)};var D=A.style;D.left=F.x+"px";D.top=F.y+"px";D.display="";B.onPlaceLabel(A,E)}});$jit.Icicle.Plot.NodeTypes=new t({none:{render:d.empty},rectangle:{render:function(C,A,N){var B=this.viz.config;var F=B.offset;var z=C.getData("width");var K=C.getData("height");var E=C.getData("border");var J=C.pos.getc(true);var I=J.x+F/2,G=J.y+F/2;var M=A.getCtx();if(z-F<2||K-F<2){return}if(B.cushion){var D=C.getData("color");var L=M.createRadialGradient(I+(z-F)/2,G+(K-F)/2,1,I+(z-F)/2,G+(K-F)/2,z<K?K:z);var H=d.rgbToHex(d.map(d.hexToRgb(D),function(O){return O*0.3>>0}));L.addColorStop(0,D);L.addColorStop(1,H);M.fillStyle=L}if(E){M.strokeStyle=E;M.lineWidth=3}M.fillRect(I,G,Math.max(0,z-F),Math.max(0,K-F));E&&M.strokeRect(J.x,J.y,z,K)},contains:function(B,D){if(this.viz.clickedNode&&!$jit.Graph.Util.isDescendantOf(B,this.viz.clickedNode.id)){return false}var C=B.pos.getc(true),A=B.getData("width"),z=B.getData("height");return this.nodeHelper.rectangle.contains({x:C.x+A/2,y:C.y+z/2},D,A,z)}}});$jit.Icicle.Plot.EdgeTypes=new t({none:d.empty});$jit.RGraph=new t({Implements:[e,q,i.Radial],initialize:function(z){var A=$jit.RGraph;var B={interpolation:"linear",levelDistance:100};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Controller","Tips","NodeStyles","Events","Navigation","Label"),B,z);var C=this.config;if(C.useCanvas){this.canvas=C.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(C.background){C.background=d.merge({type:"Circles"},C.background)}this.canvas=new n(this,C);this.config.labelContainer=(typeof C.injectInto=="string"?C.injectInto:C.injectInto.id)+"-label"}this.graphOptions={complex:false,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new A.Label[C.Label.type](this);this.fx=new A.Plot(this);this.op=new A.Op(this);this.json=null;this.root=null;this.busy=false;this.parent=false;this.initializeExtras()},createLevelDistanceFunc:function(){var z=this.config.levelDistance;return function(A){return(A._depth+1)*z}},refresh:function(){this.compute();this.plot()},reposition:function(){this.compute("end")},plot:function(){this.fx.plot()},getNodeAndParentAngle:function(G){var B=false;var F=this.graph.getNode(G);var D=F.getParents();var C=(D.length>0)?D[0]:false;if(C){var z=C.pos.getc(),E=F.pos.getc();var A=z.add(E.scale(-1));B=Math.atan2(A.y,A.x);if(B<0){B+=2*Math.PI}}return{parent:C,theta:B}},tagChildren:function(D,F){if(D.angleSpan){var E=[];D.eachAdjacency(function(G){E.push(G.nodeTo)},"ignore");var z=E.length;for(var C=0;C<z&&F!=E[C].id;C++){}for(var B=(C+1)%z,A=0;F!=E[B].id;B=(B+1)%z){E[B].dist=A++}}},onClick:function(D,A){if(this.root!=D&&!this.busy){this.busy=true;this.root=D;that=this;this.controller.onBeforeCompute(this.graph.getNode(D));var B=this.getNodeAndParentAngle(D);this.tagChildren(B.parent,D);this.parent=B.parent;this.compute("end");var z=B.theta-B.parent.endPos.theta;this.graph.eachNode(function(E){E.endPos.set(E.endPos.getp().add(m(z,0)))});var C=this.config.interpolation;A=d.merge({onComplete:d.empty},A||{});this.fx.animate(d.merge({hideLabels:true,modes:[C]},A,{onComplete:function(){that.busy=false;A.onComplete()}}))}}});$jit.RGraph.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=A.config.Node;this.edge=A.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(K,E,F){var I=E.pos.getc(true),B=this.viz.canvas,C=B.translateOffsetX,A=B.translateOffsetY,J=B.scaleOffsetX,H=B.scaleOffsetY,G=B.getSize();var D={x:Math.round(I.x*J+C+G.width/2),y:Math.round(I.y*H+A+G.height/2)};K.setAttribute("x",D.x);K.setAttribute("y",D.y);F.onPlaceLabel(K,E)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(L,F,G){var J=F.pos.getc(true),C=this.viz.canvas,D=C.translateOffsetX,B=C.translateOffsetY,K=C.scaleOffsetX,I=C.scaleOffsetY,H=C.getSize();var E={x:Math.round(J.x*K+D+H.width/2),y:Math.round(J.y*I+B+H.height/2)};var A=L.style;A.left=E.x+"px";A.top=E.y+"px";A.display=this.fitsInCanvas(E,C)?"":"none";G.onPlaceLabel(L,F)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.circle.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.circle.contains(C,D,B)}},ellipse:{render:function(D,B){var E=D.pos.getc(true),C=D.getData("width"),A=D.getData("height");this.nodeHelper.ellipse.render("fill",E,C,A,B)},contains:function(C,E){var D=C.pos.getc(true),B=C.getData("width"),A=C.getData("height");return this.nodeHelper.ellipse.contains(D,E,B,A)}},square:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.square.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.square.contains(C,D,B)}},rectangle:{render:function(D,B){var E=D.pos.getc(true),C=D.getData("width"),A=D.getData("height");this.nodeHelper.rectangle.render("fill",E,C,A,B)},contains:function(C,E){var D=C.pos.getc(true),B=C.getData("width"),A=C.getData("height");return this.nodeHelper.rectangle.contains(D,E,B,A)}},triangle:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.triangle.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.triangle.contains(C,D,B)}},star:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.star.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.star.contains(C,D,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var D=A.nodeFrom.pos.getc(true),C=A.nodeTo.pos.getc(true);this.edgeHelper.line(D,C,B)},arrow:function(B,C){var G=B.nodeFrom.pos.getc(true),F=B.nodeTo.pos.getc(true),E=B.getData("dim"),D=B.data.$direction,A=(D&&D.length>1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)}})})($jit.RGraph);i.ForceDirected=new t({getOptions:function(F){var D=this.canvas.getSize();var A=D.width,C=D.height;var E=0;this.graph.eachNode(function(H){E++});var G=A*C/E,B=Math.sqrt(G);var z=this.config.levelDistance;return{width:A,height:C,tstart:A*0.1,nodef:function(H){return G/(H||1)},edgef:function(H){return B*(H-z)}}},compute:function(A,B){var C=d.splat(A||["current","start","end"]);var z=this.getOptions();h.compute(this.graph,C,this.config);this.graph.computeLevels(this.root,0,"ignore");this.graph.eachNode(function(D){d.each(C,function(E){var F=D.getPos(E);if(F.equals(s.KER)){F.x=z.width/5*(Math.random()-0.5);F.y=z.height/5*(Math.random()-0.5)}D.disp={};d.each(C,function(G){D.disp[G]=u(0,0)})})});this.computePositions(C,z,B)},computePositions:function(D,B,E){var F=this.config.iterations,A=0,C=this;if(E){(function z(){for(var H=E.iter,G=0;G<H;G++){B.t=B.tstart*(1-A++/(F-1));C.computePositionStep(D,B);if(A>=F){E.onComplete();return}}E.onStep(Math.round(A/(F-1)*100));setTimeout(z,1)})()}else{for(;A<F;A++){B.t=B.tstart*(1-A/(F-1));this.computePositionStep(D,B)}}},computePositionStep:function(G,z){var H=this.graph;var B=Math.min,F=Math.max;var E=u(0,0);H.eachNode(function(J){d.each(G,function(K){J.disp[K].x=0;J.disp[K].y=0});H.eachNode(function(K){if(K.id!=J.id){d.each(G,function(O){var M=J.getPos(O),L=K.getPos(O);E.x=M.x-L.x;E.y=M.y-L.y;var N=E.norm()||1;J.disp[O].$add(E.$scale(z.nodef(N)/N))})}})});var A=!!H.getNode(this.root).visited;H.eachNode(function(J){J.eachAdjacency(function(K){var L=K.nodeTo;if(!!L.visited===A){d.each(G,function(P){var N=J.getPos(P),M=L.getPos(P);E.x=N.x-M.x;E.y=N.y-M.y;var O=E.norm()||1;J.disp[P].$add(E.$scale(-z.edgef(O)/O));L.disp[P].$add(E.$scale(-1))})}});J.visited=!A});var I=z.t,C=z.width/2,D=z.height/2;H.eachNode(function(J){d.each(G,function(M){var K=J.disp[M];var L=K.norm()||1;var M=J.getPos(M);M.$add(u(K.x*B(Math.abs(K.x),I)/L,K.y*B(Math.abs(K.y),I)/L));M.x=B(C,F(-C,M.x));M.y=B(D,F(-D,M.y))})})}});$jit.ForceDirected=new t({Implements:[e,q,i.ForceDirected],initialize:function(A){var z=$jit.ForceDirected;var B={iterations:50,levelDistance:50};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Tips","NodeStyles","Events","Navigation","Controller","Label"),B,A);var C=this.config;if(C.useCanvas){this.canvas=C.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(C.background){C.background=d.merge({type:"Circles"},C.background)}this.canvas=new n(this,C);this.config.labelContainer=(typeof C.injectInto=="string"?C.injectInto:C.injectInto.id)+"-label"}this.graphOptions={complex:true,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new z.Label[C.Label.type](this);this.fx=new z.Plot(this);this.op=new z.Op(this);this.json=null;this.busy=false;this.initializeExtras()},refresh:function(){this.compute();this.plot()},reposition:function(){this.compute("end")},computeIncremental:function(z){z=d.merge({iter:20,property:"end",onStep:d.empty,onComplete:d.empty},z||{});this.config.onBeforeCompute(this.graph.getNode(this.root));this.compute(z.property,z)},plot:function(){this.fx.plot()},animate:function(z){this.fx.animate(d.merge({modes:["linear"]},z||{}))}});$jit.ForceDirected.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=A.config.Node;this.edge=A.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(K,E,F){var I=E.pos.getc(true),B=this.viz.canvas,C=B.translateOffsetX,A=B.translateOffsetY,J=B.scaleOffsetX,H=B.scaleOffsetY,G=B.getSize();var D={x:Math.round(I.x*J+C+G.width/2),y:Math.round(I.y*H+A+G.height/2)};K.setAttribute("x",D.x);K.setAttribute("y",D.y);F.onPlaceLabel(K,E)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(L,F,G){var J=F.pos.getc(true),C=this.viz.canvas,D=C.translateOffsetX,B=C.translateOffsetY,K=C.scaleOffsetX,I=C.scaleOffsetY,H=C.getSize();var E={x:Math.round(J.x*K+D+H.width/2),y:Math.round(J.y*I+B+H.height/2)};var A=L.style;A.left=E.x+"px";A.top=E.y+"px";A.display=this.fitsInCanvas(E,C)?"":"none";G.onPlaceLabel(L,F)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.circle.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.circle.contains(C,D,B)}},ellipse:{render:function(D,B){var E=D.pos.getc(true),C=D.getData("width"),A=D.getData("height");this.nodeHelper.ellipse.render("fill",E,C,A,B)},contains:function(C,E){var D=C.pos.getc(true),B=C.getData("width"),A=C.getData("height");return this.nodeHelper.ellipse.contains(D,E,B,A)}},square:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.square.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.square.contains(C,D,B)}},rectangle:{render:function(D,B){var E=D.pos.getc(true),C=D.getData("width"),A=D.getData("height");this.nodeHelper.rectangle.render("fill",E,C,A,B)},contains:function(C,E){var D=C.pos.getc(true),B=C.getData("width"),A=C.getData("height");return this.nodeHelper.rectangle.contains(D,E,B,A)}},triangle:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.triangle.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.triangle.contains(C,D,B)}},star:{render:function(B,A){var D=B.pos.getc(true),C=B.getData("dim");this.nodeHelper.star.render("fill",D,C,A)},contains:function(A,D){var C=A.pos.getc(true),B=A.getData("dim");return this.nodeHelper.star.contains(C,D,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var D=A.nodeFrom.pos.getc(true),C=A.nodeTo.pos.getc(true);this.edgeHelper.line(D,C,B)},arrow:function(B,C){var G=B.nodeFrom.pos.getc(true),F=B.nodeTo.pos.getc(true),E=B.getData("dim"),D=B.data.$direction,A=(D&&D.length>1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)}})})($jit.ForceDirected);$jit.TM={};var y=$jit.TM;$jit.TM.$extend=true;y.Base={layout:{orientation:"h",vertical:function(){return this.orientation=="v"},horizontal:function(){return this.orientation=="h"},change:function(){this.orientation=this.vertical()?"h":"v"}},initialize:function(z){var A={orientation:"h",titleHeight:13,offset:2,levelsToShow:3,constrained:false,animate:false,Node:{type:"rectangle",overridable:true,width:3,height:3,color:"#444"},Label:{textAlign:"center",textBaseline:"top"},Edge:{type:"none"},duration:700,fps:45};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Controller","Tips","NodeStyles","Events","Navigation","Label"),A,z);this.layout.orientation=this.config.orientation;var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(B.background){B.background=d.merge({type:"Circles"},B.background)}this.canvas=new n(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={complex:true,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new y.Label[B.Label.type](this);this.fx=new y.Plot(this);this.op=new y.Op(this);this.group=new y.Group(this);this.geom=new y.Geom(this);this.clickedNode=null;this.busy=false;this.initializeExtras()},refresh:function(){if(this.busy){return}this.busy=true;var A=this;if(this.config.animate){this.compute("end");this.geom.setRightLevelToShow(this.graph.getNode(this.root));this.fx.animate(d.merge(this.config,{modes:["linear","node-property:width:height"],onComplete:function(){A.busy=false}}))}else{var z=this.config.Label.type;if(z!="Native"){var A=this;this.graph.eachNode(function(B){A.labels.hideLabel(B,false)})}this.busy=false;this.compute();this.plot()}},plot:function(){this.fx.plot()},leaf:function(z){return z.getSubnodes([1,1],"ignore").length==0},enter:function(F){if(this.busy){return}this.busy=true;var B=this,A=this.config,D=this.graph,z=F,C=this.clickedNode;var E={onComplete:function(){if(A.levelsToShow>0){B.geom.setRightLevelToShow(F)}if(A.request){B.compute()}if(A.animate){D.nodeList.setDataset(["current","end"],{alpha:[1,0]});F.eachSubgraph(function(G){G.setData("alpha",1,"end")},"ignore");B.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){B.clickedNode=z;B.compute("end");B.clickedNode=C;B.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){B.busy=false;B.clickedNode=z}})}})}else{B.busy=false;B.clickedNode=F;B.refresh()}}};if(A.request){this.requestNodes(z,E)}else{E.onComplete()}},out:function(){if(this.busy){return}this.busy=true;this.events.hoveredNode=false;var D=this,B=this.config,F=this.graph,A=F.getNode(this.clickedNode&&this.clickedNode.id||this.root).getParents(),C=A[0],z=C,E=this.clickedNode;if(!C){this.busy=false;return}callback={onComplete:function(){D.clickedNode=C;if(B.request){D.requestNodes(C,{onComplete:function(){D.compute();D.plot();D.busy=false}})}else{D.compute();D.plot();D.busy=false}}};if(B.levelsToShow>0){this.geom.setRightLevelToShow(C)}if(B.animate){this.clickedNode=z;this.compute("end");this.clickedNode=E;this.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){D.clickedNode=z;F.nodeList.setDataset(["current","end"],{alpha:[0,1]});E.eachSubgraph(function(G){G.setData("alpha",1)},"ignore");D.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){callback.onComplete()}})}})}else{callback.onComplete()}},requestNodes:function(B,C){var A=d.merge(this.controller,C),z=this.config.levelsToShow;if(A.request){var E=[],D=B._depth;B.eachLevel(0,z,function(G){var F=z-(G._depth-D);if(G.drawn&&!G.anySubnode()&&F>0){E.push(G);G._level=F}});this.group.requestNodes(E,A)}else{A.onComplete()}}};y.Op=new t({Implements:f.Op,initialize:function(z){this.viz=z}});y.Geom=new t({Implements:f.Geom,getRightLevelToShow:function(){return this.viz.config.levelsToShow},setRightLevelToShow:function(A){var B=this.getRightLevelToShow(),z=this.viz.labels;A.eachLevel(0,B+1,function(D){var C=D._depth-A._depth;if(C>B){D.drawn=false;D.exist=false;D.ignore=true;z.hideLabel(D,false)}else{D.drawn=true;D.exist=true;delete D.ignore}});A.drawn=true;delete A.ignore}});y.Group=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.config=z.config},requestNodes:function(E,D){var C=0,A=E.length,G={};var B=function(){D.onComplete()};var z=this.viz;if(A==0){B()}for(var F=0;F<A;F++){G[E[F].id]=E[F];D.request(E[F].id,E[F]._level,{onComplete:function(I,H){if(H&&H.children){H.id=I;z.op.sum(H,{type:"nothing"})}if(++C==A){z.graph.computeLevels(z.root,0);B()}}})}}});y.Plot=new t({Implements:f.Plot,initialize:function(z){this.viz=z;this.config=z.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new y.Plot.NodeTypes;this.edgeTypes=new y.Plot.EdgeTypes;this.labels=z.labels},plot:function(B,A){var z=this.viz,C=z.graph;z.canvas.clear();this.plotTree(C.getNode(z.clickedNode&&z.clickedNode.id||z.root),d.merge(z.config,B||{},{withLabels:true,hideLabels:false,plotSubtree:function(E,D){return E.anySubnode("exist")}}),A)}});y.Label={};y.Label.Native=new t({Implements:f.Label.Native,initialize:function(z){this.config=z.config;this.leaf=z.leaf},renderLabel:function(A,B,C){if(!this.leaf(B)&&!this.config.titleHeight){return}var E=B.pos.getc(true),H=A.getCtx(),z=B.getData("width"),G=B.getData("height"),F=E.x+z/2,D=E.y;H.fillText(B.name,F,D,z)}});y.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(z){this.viz=z;this.leaf=z.leaf;this.config=z.config},placeLabel:function(J,D,E){var H=D.pos.getc(true),A=this.viz.canvas,B=A.translateOffsetX,z=A.translateOffsetY,I=A.scaleOffsetX,G=A.scaleOffsetY,F=A.getSize();var C={x:Math.round(H.x*I+B+F.width/2),y:Math.round(H.y*G+z+F.height/2)};J.setAttribute("x",C.x);J.setAttribute("y",C.y);if(!this.leaf(D)&&!this.config.titleHeight){J.style.display="none"}E.onPlaceLabel(J,D)}});y.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(z){this.viz=z;this.leaf=z.leaf;this.config=z.config},placeLabel:function(K,E,F){var I=E.pos.getc(true),B=this.viz.canvas,C=B.translateOffsetX,A=B.translateOffsetY,J=B.scaleOffsetX,H=B.scaleOffsetY,G=B.getSize();var D={x:Math.round(I.x*J+C+G.width/2),y:Math.round(I.y*H+A+G.height/2)};var z=K.style;z.left=D.x+"px";z.top=D.y+"px";z.width=E.getData("width")*J+"px";z.height=E.getData("height")*H+"px";z.zIndex=E._depth*100;z.display="";if(!this.leaf(E)&&!this.config.titleHeight){K.style.display="none"}F.onPlaceLabel(K,E)}});y.Plot.NodeTypes=new t({none:{render:d.empty},rectangle:{render:function(C,A,P){var G=this.viz.leaf(C),B=this.config,L=B.offset,F=B.titleHeight,K=C.pos.getc(true),z=C.getData("width"),M=C.getData("height"),E=C.getData("border"),O=A.getCtx(),J=K.x+L/2,H=K.y+L/2;if(z<=L||M<=L){return}if(G){if(B.cushion){var N=O.createRadialGradient(J+(z-L)/2,H+(M-L)/2,1,J+(z-L)/2,H+(M-L)/2,z<M?M:z);var D=C.getData("color");var I=d.rgbToHex(d.map(d.hexToRgb(D),function(Q){return Q*0.2>>0}));N.addColorStop(0,D);N.addColorStop(1,I);O.fillStyle=N}O.fillRect(J,H,z-L,M-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(J,H,z-L,M-L);O.restore()}}else{if(F>0){O.fillRect(K.x+L/2,K.y+L/2,z-L,F-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(K.x+L/2,K.y+L/2,z-L,M-L);O.restore()}}}},contains:function(C,E){if(this.viz.clickedNode&&!C.isDescendantOf(this.viz.clickedNode.id)){return false}var D=C.pos.getc(true),B=C.getData("width"),A=this.viz.leaf(C),z=A?C.getData("height"):this.config.titleHeight;return this.nodeHelper.rectangle.contains({x:D.x+B/2,y:D.y+z/2},E,B,z)}}});y.Plot.EdgeTypes=new t({none:d.empty});y.SliceAndDice=new t({Implements:[e,q,y.Base,i.TM.SliceAndDice]});y.Squarified=new t({Implements:[e,q,y.Base,i.TM.Squarified]});y.Strip=new t({Implements:[e,q,y.Base,i.TM.Strip]});p.BarChart={$extend:true,animate:true,type:"stacked",offset:25,labelOffset:3,barsOffset:0,hoveredColor:"#9fd4ff",orientation:"horizontal",showAggregates:true,showLabels:true,Tips:{enable:false,onShow:d.empty,onHide:d.empty},Events:{enable:false,onClick:d.empty}};$jit.ST.Plot.NodeTypes.implement({"barchart-stacked":{render:function(R,D){var I=R.pos.getc(true),Q=R.getData("width"),O=R.getData("height"),M=this.getAlignedPos(I,Q,O),L=M.x,K=M.y,N=R.getData("dimArray"),G=R.getData("valueArray"),F=R.getData("colorArray"),C=F.length,Y=R.getData("stringArray");var T=D.getCtx(),z={},U=R.getData("border"),A=R.getData("gradient"),aa=R.getData("config"),B=aa.orientation=="horizontal",E=aa.showAggregates,P=aa.showLabels,J=aa.Label;if(F&&N&&Y){for(var X=0,S=N.length,W=0,H=0;X<S;X++){T.fillStyle=T.strokeStyle=F[X%C];if(A){var Z;if(B){Z=T.createLinearGradient(L+W+N[X]/2,K,L+W+N[X]/2,K+O)}else{Z=T.createLinearGradient(L,K-W-N[X]/2,L+Q,K-W-N[X]/2)}var V=d.rgbToHex(d.map(d.hexToRgb(F[X%C].slice(1)),function(ab){return(ab*0.5)>>0}));Z.addColorStop(0,V);Z.addColorStop(0.5,F[X%C]);Z.addColorStop(1,V);T.fillStyle=Z}if(B){T.fillRect(L+W,K,N[X],O)}else{T.fillRect(L,K-W-N[X],Q,N[X])}if(U&&U.name==Y[X]){z.acum=W;z.dimValue=N[X]}W+=(N[X]||0);H+=(G[X]||0)}if(U){T.save();T.lineWidth=2;T.strokeStyle=U.color;if(B){T.strokeRect(L+z.acum+1,K+1,z.dimValue-2,O-2)}else{T.strokeRect(L+1,K-z.acum-z.dimValue+1,Q-2,z.dimValue-2)}T.restore()}if(J.type=="Native"){T.save();T.fillStyle=T.strokeStyle=J.color;T.font=J.style+" "+J.size+"px "+J.family;T.textBaseline="middle";if(E(R.name,H)){if(B){T.textAlign="right";T.fillText(H,L+W-aa.labelOffset,K+O/2)}else{T.textAlign="center";T.fillText(H,L+Q/2,K-O-J.size/2-aa.labelOffset)}}if(P(R.name,H,R)){if(B){T.textAlign="center";T.translate(L-aa.labelOffset-J.size/2,K+O/2);T.rotate(Math.PI/2);T.fillText(R.name,0,0)}else{T.textAlign="center";T.fillText(R.name,L+Q/2,K+J.size/2+aa.labelOffset)}}T.restore()}}},contains:function(E,G){var J=E.pos.getc(true),B=E.getData("width"),O=E.getData("height"),N=this.getAlignedPos(J,B,O),M=N.x,K=N.y,P=E.getData("dimArray"),C=E.getData("config"),A=G.x-M,z=C.orientation=="horizontal";if(z){if(G.x<M||G.x>M+B||G.y>K+O||G.y<K){return false}}else{if(G.x<M||G.x>M+B||G.y>K||G.y<K-O){return false}}for(var H=0,F=P.length,L=(z?M:K);H<F;H++){var D=P[H];if(z){L+=D;var I=L;if(G.x<=I){return{name:E.getData("stringArray")[H],color:E.getData("colorArray")[H],value:E.getData("valueArray")[H]}}}else{L-=D;var I=L;if(G.y>=I){return{name:E.getData("stringArray")[H],color:E.getData("colorArray")[H],value:E.getData("valueArray")[H]}}}}return false}},"barchart-grouped":{render:function(S,D){var J=S.pos.getc(true),R=S.getData("width"),P=S.getData("height"),N=this.getAlignedPos(J,R,P),M=N.x,L=N.y,O=S.getData("dimArray"),H=S.getData("valueArray"),Y=H.length,G=S.getData("colorArray"),C=G.length,aa=S.getData("stringArray");var U=D.getCtx(),z={},V=S.getData("border"),A=S.getData("gradient"),ac=S.getData("config"),B=ac.orientation=="horizontal",F=ac.showAggregates,Q=ac.showLabels,K=ac.Label,E=(B?P:R)/Y;if(G&&O&&aa){for(var Z=0,T=Y,X=0,I=0;Z<T;Z++){U.fillStyle=U.strokeStyle=G[Z%C];if(A){var ab;if(B){ab=U.createLinearGradient(M+O[Z]/2,L+E*Z,M+O[Z]/2,L+E*(Z+1))}else{ab=U.createLinearGradient(M+E*Z,L-O[Z]/2,M+E*(Z+1),L-O[Z]/2)}var W=d.rgbToHex(d.map(d.hexToRgb(G[Z%C].slice(1)),function(ad){return(ad*0.5)>>0}));ab.addColorStop(0,W);ab.addColorStop(0.5,G[Z%C]);ab.addColorStop(1,W);U.fillStyle=ab}if(B){U.fillRect(M,L+E*Z,O[Z],E)}else{U.fillRect(M+E*Z,L-O[Z],E,O[Z])}if(V&&V.name==aa[Z]){z.acum=E*Z;z.dimValue=O[Z]}X+=(O[Z]||0);I+=(H[Z]||0)}if(V){U.save();U.lineWidth=2;U.strokeStyle=V.color;if(B){U.strokeRect(M+1,L+z.acum+1,z.dimValue-2,E-2)}else{U.strokeRect(M+z.acum+1,L-z.dimValue+1,E-2,z.dimValue-2)}U.restore()}if(K.type=="Native"){U.save();U.fillStyle=U.strokeStyle=K.color;U.font=K.style+" "+K.size+"px "+K.family;U.textBaseline="middle";if(F(S.name,I)){if(B){U.textAlign="right";U.fillText(I,M+Math.max.apply(null,O)-ac.labelOffset,L+P/2)}else{U.textAlign="center";U.fillText(I,M+R/2,L-Math.max.apply(null,O)-K.size/2-ac.labelOffset)}}if(Q(S.name,I,S)){if(B){U.textAlign="center";U.translate(M-ac.labelOffset-K.size/2,L+P/2);U.rotate(Math.PI/2);U.fillText(S.name,0,0)}else{U.textAlign="center";U.fillText(S.name,M+R/2,L+K.size/2+ac.labelOffset)}}U.restore()}}},contains:function(K,G){var C=K.pos.getc(true),J=K.getData("width"),I=K.getData("height"),F=this.getAlignedPos(C,J,I),E=F.x,D=F.y,H=K.getData("dimArray"),N=H.length,Q=K.getData("config"),B=G.x-E,z=Q.orientation=="horizontal",A=(z?I:J)/N;if(z){if(G.x<E||G.x>E+J||G.y>D+I||G.y<D){return false}}else{if(G.x<E||G.x>E+J||G.y>D||G.y<D-I){return false}}for(var M=0,L=H.length;M<L;M++){var P=H[M];if(z){var O=D+A*M;if(G.x<=E+P&&G.y>=O&&G.y<=O+A){return{name:K.getData("stringArray")[M],color:K.getData("colorArray")[M],value:K.getData("valueArray")[M]}}}else{var O=E+A*M;if(G.x>=O&&G.x<=O+A&&G.y>=D-P){return{name:K.getData("stringArray")[M],color:K.getData("colorArray")[M],value:K.getData("valueArray")[M]}}}}return false}}});$jit.BarChart=new t({st:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(B){this.controller=this.config=d.merge(p("Canvas","Label","BarChart"),{Label:{type:"Native"}},B);var C=this.config.showLabels,A=d.type(C),D=this.config.showAggregates,z=d.type(D);this.config.showLabels=A=="function"?C:d.lambda(C);this.config.showAggregates=z=="function"?D:d.lambda(D);this.initializeViz()},initializeViz:function(){var B=this.config,E=this;var z=B.type.split(":")[0],F=B.orientation=="horizontal",D={};var A=new $jit.ST({injectInto:B.injectInto,orientation:F?"left":"bottom",levelDistance:0,siblingOffset:B.barsOffset,subtreeOffset:0,withLabels:B.Label.type!="Native",useCanvas:B.useCanvas,Label:{type:B.Label.type},Node:{overridable:true,type:"barchart-"+z,align:"left",width:1,height:1},Edge:{type:"none"},Tips:{enable:B.Tips.enable,type:"Native",force:true,onShow:function(J,I,G){var H=G;B.Tips.onShow(J,H,I)}},Events:{enable:true,type:"Native",onClick:function(I,J,G){if(!B.Events.enable){return}var H=J.getContains();B.Events.onClick(H,J,G)},onMouseMove:function(I,J,G){if(!B.hoveredColor){return}if(I){var H=J.getContains();E.select(I.id,H.name,H.index)}else{E.select(false,false,false)}}},onCreateLabel:function(L,J){var R=B.Label,P=J.getData("valueArray"),O=d.reduce(P,function(S,T){return S+T},0);var N={wrapper:document.createElement("div"),aggregate:document.createElement("div"),label:document.createElement("div")};var G=N.wrapper,Q=N.label,H=N.aggregate,I=G.style,M=Q.style,K=H.style;D[J.id]=N;G.appendChild(Q);G.appendChild(H);if(!B.showLabels(J.name,O,J)){M.display="none"}if(!B.showAggregates(J.name,O,J)){K.display="none"}I.position="relative";I.overflow="visible";I.fontSize=R.size+"px";I.fontFamily=R.family;I.color=R.color;I.textAlign="center";K.position=M.position="absolute";L.style.width=J.getData("width")+"px";L.style.height=J.getData("height")+"px";K.left=M.left="0px";Q.innerHTML=J.name;L.appendChild(G)},onPlaceLabel:function(N,J){if(!D[J.id]){return}var P=D[J.id],K=P.wrapper.style,R=P.label.style,O=P.aggregate.style,S=B.type.split(":")[0]=="grouped",G=B.orientation=="horizontal",V=J.getData("dimArray"),W=J.getData("valueArray"),H=(S&&G)?Math.max.apply(null,V):J.getData("width"),U=(S&&!G)?Math.max.apply(null,V):J.getData("height"),I=parseInt(K.fontSize,10),Q=N.style;if(V&&W){K.width=O.width=R.width=N.style.width=H+"px";for(var M=0,L=W.length,T=0;M<L;M++){if(V[M]>0){T+=W[M]}}if(B.showLabels(J.name,T,J)){R.display=""}else{R.display="none"}if(B.showAggregates(J.name,T,J)){O.display=""}else{O.display="none"}if(B.orientation=="horizontal"){O.textAlign="right";R.textAlign="left";R.textIndex=O.textIndent=B.labelOffset+"px";O.top=R.top=(U-I)/2+"px";N.style.height=K.height=U+"px"}else{O.top=(-I-B.labelOffset)+"px";R.top=(B.labelOffset+U)+"px";N.style.top=parseInt(N.style.top,10)-U+"px";N.style.height=K.height=U+"px"}P.aggregate.innerHTML=T}}});var C=A.canvas.getSize();if(F){A.config.offsetX=+C.width/2-B.offset-(B.showLabels&&(B.labelOffset+B.Label.size))}else{A.config.offsetY=-C.height/2+B.offset+(B.showLabels&&(B.labelOffset+B.Label.size))}this.st=A;this.canvas=this.st.canvas},loadJSON:function(N){if(this.busy){return}this.busy=true;var L=d.time(),F=[],G=this.st,Q=d.splat(N.label),K=d.splat(N.color||this.colors),O=this.config,z=!!O.type.split(":")[1],C=O.animate,B=O.orientation=="horizontal",D=this;for(var M=0,A=N.values,I=A.length;M<I;M++){var P=A[M];var E=d.splat(A[M].values);var J=0;F.push({id:L+P.label,name:P.label,data:{value:E,"$valueArray":E,"$colorArray":K,"$stringArray":Q,"$gradient":z,"$config":O},children:[]})}var H={id:L+"$root",name:"",data:{"$type":"none","$width":1,"$height":1},children:F};G.loadJSON(H);this.normalizeDims();G.compute();G.select(G.root);if(C){if(B){G.fx.animate({modes:["node-property:width:dimArray"],duration:1500,onComplete:function(){D.busy=false}})}else{G.fx.animate({modes:["node-property:height:dimArray"],duration:1500,onComplete:function(){D.busy=false}})}}else{this.busy=false}},updateJSON:function(C,F){if(this.busy){return}this.busy=true;var B=this.st;var E=B.graph;var A=C.values;var z=this.config.animate;var D=this;var G=this.config.orientation=="horizontal";d.each(A,function(H){var I=E.getByName(H.label);if(I){I.setData("valueArray",d.splat(H.values));if(C.label){I.setData("stringArray",d.splat(C.label))}}});this.normalizeDims();B.compute();B.select(B.root);if(z){if(G){B.fx.animate({modes:["node-property:width:dimArray"],duration:1500,onComplete:function(){D.busy=false;F&&F.onComplete()}})}else{B.fx.animate({modes:["node-property:height:dimArray"],duration:1500,onComplete:function(){D.busy=false;F&&F.onComplete()}})}}},select:function(B,z){if(!this.config.hoveredColor){return}var A=this.selected;if(A.id!=B||A.name!=z){A.id=B;A.name=z;A.color=this.config.hoveredColor;this.st.graph.eachNode(function(C){if(B==C.id){C.setData("border",A)}else{C.setData("border",false)}});this.st.plot()}},getLegend:function(){var B={};var C;this.st.graph.getNode(this.st.root).eachAdjacency(function(D){C=D.nodeTo});var A=C.getData("colorArray"),z=A.length;d.each(C.getData("stringArray"),function(E,D){B[E]=A[D%z]});return B},getMaxValue:function(){var A=0,z=this.config.type.split(":")[0]=="stacked";this.st.graph.eachNode(function(D){var B=D.getData("valueArray"),C=0;if(!B){return}if(z){d.each(B,function(E){C+=+E})}else{C=Math.max.apply(null,B)}A=A>C?A:C});return A},setBarType:function(z){this.config.type=z;this.st.config.Node.type="barchart-"+z.split(":")[0]},normalizeDims:function(){var I=this.st.graph.getNode(this.st.root),D=0;I.eachAdjacency(function(){D++});var F=this.getMaxValue(),K=this.st.canvas.getSize(),C=this.config,E=C.offset,A=C.orientation=="horizontal",z=(K[A?"height":"width"]-2*E-(D-1)*C.barsOffset)/D,B=C.animate,J=K[A?"width":"height"]-2*E-(!A&&C.showAggregates&&(C.Label.size+C.labelOffset))-(C.showLabels&&(C.Label.size+C.labelOffset)),H=A?"height":"width",G=A?"width":"height";this.st.graph.eachNode(function(O){var N=0,L=[];d.each(O.getData("valueArray"),function(P){N+=+P;L.push(0)});O.setData(H,z);if(B){O.setData(G,N*J/F,"end");O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return P*J/F}),"end");var M=O.getData("dimArray");if(!M){O.setData("dimArray",L)}}else{O.setData(G,N*J/F);O.setData("dimArray",d.map(O.getData("valueArray"),function(P){return P*J/F}))}})}});p.PieChart={$extend:true,animate:true,offset:25,sliceOffset:0,labelOffset:3,type:"stacked",hoveredColor:"#9fd4ff",Events:{enable:false,onClick:d.empty},Tips:{enable:false,onShow:d.empty,onHide:d.empty},showLabels:true,resizeLabels:false,updateHeights:false};$jit.Sunburst=new t({Implements:[e,q,i.Radial],initialize:function(z){var B=$jit.Sunburst;var A={interpolation:"linear",levelDistance:100,Node:{type:"multipie",height:0},Edge:{type:"none"},Label:{textAlign:"start",textBaseline:"middle"}};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Tips","NodeStyles","Events","Navigation","Controller","Label"),A,z);var C=this.config;if(C.useCanvas){this.canvas=C.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(C.background){C.background=d.merge({type:"Circles"},C.background)}this.canvas=new n(this,C);this.config.labelContainer=(typeof C.injectInto=="string"?C.injectInto:C.injectInto.id)+"-label"}this.graphOptions={complex:false,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new B.Label[C.Label.type](this);this.fx=new B.Plot(this);this.op=new B.Op(this);this.json=null;this.root=null;this.rotated=null;this.busy=false;this.initializeExtras()},createLevelDistanceFunc:function(){var z=this.config.levelDistance;return function(A){return(A._depth+1)*z}},refresh:function(){this.compute();this.plot()},reposition:function(){this.compute("end")},rotate:function(B,C,A){var z=B.getPos(A.property||"current").getp(true).theta;this.rotated=B;this.rotateAngle(-z,C,A)},rotateAngle:function(B,E,A){var C=this;var z=d.merge(this.config,A||{},{modes:["polar"]});var D=A.property||(E==="animate"?"end":"current");if(E==="animate"){this.fx.animation.pause()}this.graph.eachNode(function(G){var F=G.getPos(D);F.theta+=B;if(F.theta<0){F.theta+=Math.PI*2}});if(E=="animate"){this.fx.animate(z)}else{if(E=="replot"){this.fx.plot();this.busy=false}}},plot:function(){this.fx.plot()}});$jit.Sunburst.$extend=true;(function(z){z.Op=new t({Implements:f.Op,initialize:function(A){this.viz=A}});z.Plot=new t({Implements:f.Plot,initialize:function(A){this.viz=A;this.config=A.config;this.node=A.config.Node;this.edge=A.config.Edge;this.animation=new x;this.nodeTypes=new z.Plot.NodeTypes;this.edgeTypes=new z.Plot.EdgeTypes;this.labels=A.labels}});z.Label={};z.Label.Native=new t({Implements:f.Label.Native,initialize:function(A){this.viz=A;this.label=A.config.Label;this.config=A.config},renderLabel:function(D,F,H){var O=F.getData("span");if(O<Math.PI/2&&Math.tan(O)*this.config.levelDistance*F._depth<10){return}var P=D.getCtx();var B=P.measureText(F.name);if(F.id==this.viz.root){var N=-B.width/2,L=0,M=0;var A=0}else{var E=5;var A=H.levelDistance-E;var K=F.pos.clone();K.rho+=E;var C=K.getp(true);var I=K.getc(true);var N=I.x,L=I.y;var G=Math.PI;var J=(C.theta>G/2&&C.theta<3*G/2);var M=J?C.theta+G:C.theta;if(J){N-=Math.abs(Math.cos(C.theta)*B.width);L+=Math.sin(C.theta)*B.width}else{if(F.id==this.viz.root){N-=B.width/2}}}P.save();P.translate(N,L);P.rotate(M);P.fillText(F.name,0,0);P.restore()}});z.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(A){this.viz=A},placeLabel:function(O,D,F){var K=D.pos.getc(true),N=this.viz,B=this.viz.canvas;var G=B.getSize();var C={x:Math.round(K.x+G.width/2),y:Math.round(K.y+G.height/2)};O.setAttribute("x",C.x);O.setAttribute("y",C.y);var H=O.getBBox();if(H){var M=O.getAttribute("x");var J=O.getAttribute("y");var A=D.pos.getp(true);var E=Math.PI;var I=(A.theta>E/2&&A.theta<3*E/2);if(I){O.setAttribute("x",M-H.width);O.setAttribute("y",J-H.height)}else{if(D.id==N.root){O.setAttribute("x",M-H.width/2)}}var L=I?A.theta+E:A.theta;if(D._depth){O.setAttribute("transform","rotate("+L*360/(2*E)+" "+M+" "+J+")")}}F.onPlaceLabel(O,D)}});z.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(A){this.viz=A},placeLabel:function(J,D,F){var H=D.pos.clone(),B=this.viz.canvas,I=D.getData("height"),E=((I||D._depth==0)?I:this.viz.config.levelDistance)/2,G=B.getSize();H.rho+=E;H=H.getc(true);var C={x:Math.round(H.x+G.width/2),y:Math.round(H.y+G.height/2)};var A=J.style;A.left=C.x+"px";A.top=C.y+"px";A.display=this.fitsInCanvas(C,B)?"":"none";F.onPlaceLabel(J,D)}});z.Plot.NodeTypes=new t({none:{render:d.empty,contains:d.lambda(false),anglecontains:function(E,G){var D=E.getData("span")/2,B=E.pos.theta;var C=B-D,A=B+D;if(C<0){C+=Math.PI*2}var F=Math.atan2(G.y,G.x);if(F<0){F+=Math.PI*2}if(C>A){return(F>C&&F<=Math.PI*2)||F<A}else{return F>C&&F<A}}},pie:{render:function(F,D){var J=F.getData("span")/2,C=F.pos.theta;var E=C-J,G=C+J;var I=F.pos.getp(true);var A=new c(I.rho,E);var B=A.getc(true);A.theta=G;var H=A.getc(true);var K=D.getCtx();K.beginPath();K.moveTo(0,0);K.lineTo(B.x,B.y);K.moveTo(0,0);K.lineTo(H.x,H.y);K.moveTo(0,0);K.arc(0,0,I.rho*F.getData("dim-quotient"),E,G,false);K.fill()},contains:function(C,E){if(this.nodeTypes.none.anglecontains.call(this,C,E)){var A=Math.sqrt(E.x*E.x+E.y*E.y);var B=this.config.levelDistance,D=C._depth;return(A<=B*D)}return false}},multipie:{render:function(G,E){var N=G.getData("height");var H=N?N:this.config.levelDistance;var M=G.getData("span")/2,D=G.pos.theta;var F=D-M,J=D+M;var L=G.pos.getp(true);var B=new c(L.rho,F);var C=B.getc(true);B.theta=J;var K=B.getc(true);B.rho+=H;var A=B.getc(true);B.theta=F;var I=B.getc(true);var O=E.getCtx();O.moveTo(0,0);O.beginPath();O.arc(0,0,L.rho,F,J,false);O.arc(0,0,L.rho+H,J,F,true);O.moveTo(C.x,C.y);O.lineTo(I.x,I.y);O.moveTo(K.x,K.y);O.lineTo(A.x,A.y);O.fill();if(G.collapsed){O.save();O.lineWidth=2;O.moveTo(0,0);O.beginPath();O.arc(0,0,L.rho+H+5,J-0.01,F+0.01,true);O.stroke();O.restore()}},contains:function(D,G){if(this.nodeTypes.none.anglecontains.call(this,D,G)){var B=Math.sqrt(G.x*G.x+G.y*G.y);var A=D.getData("height");var E=A?A:this.config.levelDistance;var C=this.config.levelDistance,F=D._depth;return(B>=C*F)&&(B<=(C*F+E))}return false}},"gradient-multipie":{render:function(D,A){var I=A.getCtx();var H=D.getData("height");var E=H?H:this.config.levelDistance;var B=I.createRadialGradient(0,0,D.getPos().rho,0,0,D.getPos().rho+E);var G=d.hexToRgb(D.getData("color")),F=[];d.each(G,function(J){F.push(parseInt(J*0.5,10))});var C=d.rgbToHex(F);B.addColorStop(0,C);B.addColorStop(1,D.getData("color"));I.fillStyle=B;this.nodeTypes.multipie.render.call(this,D,A)},contains:function(A,B){return this.nodeTypes.multipie.contains.call(this,A,B)}},"gradient-pie":{render:function(F,C){var A=C.getCtx();var G=A.createRadialGradient(0,0,0,0,0,F.getPos().rho);var E=d.hexToRgb(F.getData("color")),B=[];d.each(E,function(H){B.push(parseInt(H*0.5,10))});var D=d.rgbToHex(B);G.addColorStop(1,D);G.addColorStop(0,F.getData("color"));A.fillStyle=G;this.nodeTypes.pie.render.call(this,F,C)},contains:function(A,B){return this.nodeTypes.pie.contains.call(this,A,B)}}});z.Plot.EdgeTypes=new t({none:d.empty,line:function(A,B){var D=A.nodeFrom.pos.getc(true),C=A.nodeTo.pos.getc(true);this.edgeHelper.line(D,C,B)},arrow:function(B,C){var G=B.nodeFrom.pos.getc(true),F=B.nodeTo.pos.getc(true),E=B.getData("dim"),D=B.data.$direction,A=(D&&D.length>1&&D[0]!=B.nodeFrom.id);this.edgeHelper.arrow(G,F,E,A,C)},hyperline:function(A,B){var E=A.nodeFrom.pos.getc(),D=A.nodeTo.pos.getc(),C=Math.max(E.norm(),D.norm());this.edgeHelper.hyperline(E.$scale(1/C),D.$scale(1/C),C,B)}})})($jit.Sunburst);$jit.Sunburst.Plot.NodeTypes.implement({"piechart-stacked":{render:function(X,D){var W=X.pos.getp(true),F=X.getData("dimArray"),V=X.getData("valueArray"),J=X.getData("colorArray"),C=J.length,P=X.getData("stringArray"),S=X.getData("span")/2,N=X.pos.theta,I=N-S,M=N+S,U=new c;var Q=D.getCtx(),O={},L=X.getData("gradient"),G=X.getData("border"),ac=X.getData("config"),al=ac.showLabels,ab=ac.resizeLabels,ae=ac.Label;var ah=ac.sliceOffset*Math.cos((I+M)/2);var H=ac.sliceOffset*Math.sin((I+M)/2);if(J&&F&&P){for(var ai=0,af=F.length,z=0,aa=0;ai<af;ai++){var E=F[ai],aj=J[ai%C];if(E<=0){continue}Q.fillStyle=Q.strokeStyle=aj;if(L&&E){var ag=Q.createRadialGradient(ah,H,z+ac.sliceOffset,ah,H,z+E+ac.sliceOffset);var A=d.hexToRgb(aj),Z=d.map(A,function(ao){return(ao*0.8)>>0}),B=d.rgbToHex(Z);ag.addColorStop(0,aj);ag.addColorStop(0.5,aj);ag.addColorStop(1,B);Q.fillStyle=ag}U.rho=z+ac.sliceOffset;U.theta=I;var ak=U.getc(true);U.theta=M;var R=U.getc(true);U.rho+=E;var am=U.getc(true);U.theta=I;var T=U.getc(true);Q.beginPath();Q.arc(ah,H,z+0.01,I,M,false);Q.arc(ah,H,z+E+0.01,M,I,true);Q.fill();if(G&&G.name==P[ai]){O.acum=z;O.dimValue=F[ai];O.begin=I;O.end=M}z+=(E||0);aa+=(V[ai]||0)}if(G){Q.save();Q.globalCompositeOperation="source-over";Q.lineWidth=2;Q.strokeStyle=G.color;var ad=I<M?1:-1;Q.beginPath();Q.arc(ah,H,O.acum+0.01+1,O.begin,O.end,false);Q.arc(ah,H,O.acum+O.dimValue+0.01-1,O.end,O.begin,true);Q.closePath();Q.stroke();Q.restore()}if(al&&ae.type=="Native"){Q.save();Q.fillStyle=Q.strokeStyle=ae.color;var Y=ab?X.getData("normalizedDim"):1,K=(ae.size*Y)>>0;K=K<+ab?+ab:K;Q.font=ae.style+" "+K+"px "+ae.family;Q.textBaseline="middle";Q.textAlign="center";U.rho=z+ac.labelOffset+ac.sliceOffset;U.theta=X.pos.theta;var an=U.getc(true);Q.fillText(X.name,an.x,an.y);Q.restore()}}},contains:function(C,G){if(this.nodeTypes.none.anglecontains.call(this,C,G)){var I=Math.sqrt(G.x*G.x+G.y*G.y);var z=this.config.levelDistance,F=C._depth;var A=C.getData("config");if(I<=z*F+A.sliceOffset){var J=C.getData("dimArray");for(var E=0,D=J.length,H=A.sliceOffset;E<D;E++){var B=J[E];if(I>=H&&I<=H+B){return{name:C.getData("stringArray")[E],color:C.getData("colorArray")[E],value:C.getData("valueArray")[E],label:C.name}}H+=B}}return false}return false}}});$jit.PieChart=new t({sb:null,colors:["#416D9C","#70A35E","#EBB056","#C74243","#83548B","#909291","#557EAA"],selected:{},busy:false,initialize:function(z){this.controller=this.config=d.merge(p("Canvas","PieChart","Label"),{Label:{type:"Native"}},z);this.initializeViz()},initializeViz:function(){var A=this.config,D=this;var z=A.type.split(":")[0];var E=new $jit.Sunburst({injectInto:A.injectInto,useCanvas:A.useCanvas,withLabels:A.Label.type!="Native",Label:{type:A.Label.type},Node:{overridable:true,type:"piechart-"+z,width:1,height:1},Edge:{type:"none"},Tips:{enable:A.Tips.enable,type:"Native",force:true,onShow:function(I,H,F){var G=F;A.Tips.onShow(I,G,H)}},Events:{enable:true,type:"Native",onClick:function(H,I,F){if(!A.Events.enable){return}var G=I.getContains();A.Events.onClick(G,I,F)},onMouseMove:function(H,I,F){if(!A.hoveredColor){return}if(H){var G=I.getContains();D.select(H.id,G.name,G.index)}else{D.select(false,false,false)}}},onCreateLabel:function(I,H){var F=A.Label;if(A.showLabels){var G=I.style;G.fontSize=F.size+"px";G.fontFamily=F.family;G.color=F.color;G.textAlign="center";I.innerHTML=H.name}},onPlaceLabel:function(V,P){if(!A.showLabels){return}var J=P.pos.getp(true),M=P.getData("dimArray"),S=P.getData("span")/2,K=P.pos.theta,U=K-S,G=K+S,X=new c;var O=A.showLabels,I=A.resizeLabels,L=A.Label;if(M){for(var T=0,Q=M.length,R=0;T<Q;T++){R+=M[T]}var W=I?P.getData("normalizedDim"):1,F=(L.size*W)>>0;F=F<+I?+I:F;V.style.fontSize=F+"px";X.rho=R+A.labelOffset+A.sliceOffset;X.theta=(U+G)/2;var J=X.getc(true);var H=D.canvas.getSize();var N={x:Math.round(J.x+H.width/2),y:Math.round(J.y+H.height/2)};V.style.left=N.x+"px";V.style.top=N.y+"px"}}});var C=E.canvas.getSize(),B=Math.min;E.config.levelDistance=B(C.width,C.height)/2-A.offset-A.sliceOffset;this.sb=E;this.canvas=this.sb.canvas;this.canvas.getCtx().globalCompositeOperation="lighter"},loadJSON:function(N){var L=d.time(),F=[],z=this.sb,Q=d.splat(N.label),H=Q.length,K=d.splat(N.color||this.colors),C=K.length,O=this.config,A=!!O.type.split(":")[1],D=O.animate,J=H==1;for(var M=0,B=N.values,I=B.length;M<I;M++){var P=B[M];var E=d.splat(P.values);F.push({id:L+P.label,name:P.label,data:{value:E,"$valueArray":E,"$colorArray":J?d.splat(K[M%C]):K,"$stringArray":Q,"$gradient":A,"$config":O,"$angularWidth":d.reduce(E,function(R,S){return R+S})},children:[]})}var G={id:L+"$root",name:"",data:{"$type":"none","$width":1,"$height":1},children:F};z.loadJSON(G);this.normalizeDims();z.refresh();if(D){z.fx.animate({modes:["node-property:dimArray"],duration:1500})}},updateJSON:function(B,E){if(this.busy){return}this.busy=true;var F=this.sb;var D=F.graph;var A=B.values;var z=this.config.animate;var C=this;d.each(A,function(G){var I=D.getByName(G.label),H=d.splat(G.values);if(I){I.setData("valueArray",H);I.setData("angularWidth",d.reduce(H,function(J,K){return J+K}));if(B.label){I.setData("stringArray",d.splat(B.label))}}});this.normalizeDims();if(z){F.compute("end");F.fx.animate({modes:["node-property:dimArray:span","linear"],duration:1500,onComplete:function(){C.busy=false;E&&E.onComplete()}})}else{F.refresh()}},select:function(B,z){if(!this.config.hoveredColor){return}var A=this.selected;if(A.id!=B||A.name!=z){A.id=B;A.name=z;A.color=this.config.hoveredColor;this.sb.graph.eachNode(function(C){if(B==C.id){C.setData("border",A)}else{C.setData("border",false)}});this.sb.plot()}},getLegend:function(){var B={};var C;this.sb.graph.getNode(this.sb.root).eachAdjacency(function(D){C=D.nodeTo});var A=C.getData("colorArray"),z=A.length;d.each(C.getData("stringArray"),function(E,D){B[E]=A[D%z]});return B},getMaxValue:function(){var z=0;this.sb.graph.eachNode(function(C){var A=C.getData("valueArray"),B=0;d.each(A,function(D){B+=+D});z=z>B?z:B});return z},normalizeDims:function(){var A=this.sb.graph.getNode(this.sb.root),z=0;A.eachAdjacency(function(){z++});var E=this.getMaxValue(),D=this.config,B=D.animate,C=this.sb.config.levelDistance;this.sb.graph.eachNode(function(J){var I=0,F=[];d.each(J.getData("valueArray"),function(K){I+=+K;F.push(1)});var H=(F.length==1)&&!D.updateHeights;if(B){J.setData("dimArray",d.map(J.getData("valueArray"),function(K){return H?C:(K*C/E)}),"end");var G=J.getData("dimArray");if(!G){J.setData("dimArray",F)}}else{J.setData("dimArray",d.map(J.getData("valueArray"),function(K){return H?C:(K*C/E)}))}J.setData("normalizedDim",I/E)})}})})();