/*
* Kendo UI v2015.3.1111 (http://www.telerik.com/kendo-ui)
* Copyright 2015 Telerik AD. All rights reserved.
*
* Kendo UI commercial licenses may be obtained at
* http://www.telerik.com/purchase/license-agreement/kendo-ui-complete
* If you do not own a commercial license, this file shall be governed by the trial license terms.
*/
!function(e,define){define(["./kendo.data.min","./kendo.draganddrop.min","./kendo.userevents.min","./kendo.mobile.scroller.min","./kendo.drawing.min","./kendo.core.min","./kendo.dataviz.core.min","./kendo.toolbar.min","./kendo.editable.min","./kendo.window.min","./kendo.dropdownlist.min","./kendo.dataviz.themes.min"],e)}(function(){return function(){!function(e,t){function n(e,n,i){function r(e){for(var t=1;e*t%1;)t*=10;return t}var o,a,s,l;if(t===e||t===n)return[];if(i&&d.sign(n-e)!=d.sign(i))throw"The sign of the increment should allow to reach the stop-value.";if(i=i||1,e=e||0,n=n||e,(n-e)/i===1/0)throw"Infinite range defined.";if(o=[],a=-1,l=r(Math.abs(i)),e*=l,n*=l,i*=l,e>n&&i>0&&(i=-i),0>i)for(;(s=e+i*++a)>=n;)o.push(s/l);else for(;(s=e+i*++a)<=n;)o.push(s/l);return o}function i(e,t){if(e==t)return 0;var n=t.x-e.x,i=e.y-t.y,r=Math.atan(n/i);return i>=0?0>n?r+2*Math.PI:r:r+Math.PI}var r,o,a=window.kendo,s=a.dataviz.diagram={},l=a.deepExtend,c=e.isArray,u=1e-6,d={};l(d,{isNearZero:function(e){return Math.abs(e)n;++n)i[n]=t;return i},serializePoints:function(e){var t,n,i=[];for(t=0;e.length>t;t++)n=e[t],i.push(n.x+";"+n.y);return i.join(";")},deserializePoints:function(e){var t,n=e.split(";"),i=[];if(n.length%2!==0)throw"Not an array of points.";for(t=0;n.length>t;t+=2)i.push(new s.Point(parseInt(n[t],10),parseInt(n[t+1],10)));return i},randomInteger:function(e,t){return parseInt(Math.floor(Math.random()*t)+e,10)},DFT:function(e,t){var n,i;if(t(e),e.childNodes)for(n=0;e.childNodes.length>n;n++)i=e.childNodes[n],this.DFT(i,t)},getMatrixAngle:function(e){return null===e||0===e.d?0:180*Math.atan2(e.b,e.d)/Math.PI},getMatrixScaling:function(e){var t=Math.sqrt(e.a*e.a+e.c*e.c),n=Math.sqrt(e.b*e.b+e.d*e.d);return[t,n]}}),d.sign=function(e){return e?0>e?-1:1:0},d.findAngle=function(e,t){return 180*i(e,t)/Math.PI},d.forEach=function(e,t,n){for(var i=0;e.length>i;i++)t.call(n,e[i],i,e)},d.any=function(e,t){for(var n=0;e.length>n;++n)if(t(e[n]))return e[n];return null},d.remove=function(e,t){for(var n;-1!==(n=d.indexOf(e,t));)e.splice(n,1);return e},d.contains=function(e,t){return-1!==d.indexOf(e,t)},d.indexOf=function(t,n){return e.inArray(n,t)},d.fold=function(e,t,n,i){var r,o,a=arguments.length>2;for(r=0;e.length>r;r++)o=e[r],a?n=t.call(i,n,o,r,e):(n=o,a=!0);if(!a)throw"Reduce of empty array with no initial value";return n},d.find=function(e,t,n){var i;return d.any(e,function(e,r,o){return t.call(n,e,r,o)?(i=e,!0):!1}),i},d.first=function(e,t,n){return 0===e.length?null:d.isUndefined(t)?e[0]:d.find(e,t,n)},d.insert=function(e,t,n){return e.splice(n,0,t),e},d.all=function(e,t,n){var i,r,o=!0;for(r=0;e.length>r&&(i=e[r],o=o&&t.call(n,i,r,e),o);r++);return o},d.clear=function(e){e.splice(0,e.length)},d.bisort=function(e,t,n){if(d.isUndefined(e))throw"First array is not specified.";if(d.isUndefined(t))throw"Second array is not specified.";if(e.length!=t.length)throw"The two arrays should have equal length";var i,r=[];for(i=0;e.length>i;i++)r.push({x:e[i],y:t[i]});for(r.sort(d.isUndefined(n)?function(e,t){return e.x-t.x}:function(e,t){return n(e.x,t.x)}),d.clear(e),d.clear(t),i=0;r.length>i;i++)e.push(r[i].x),t.push(r[i].y)},d.addRange=function(e,t){e.push.apply(e,t)},r={easeInOut:function(e){return-Math.cos(e*Math.PI)/2+.5}},o=a.Class.extend({init:function(){this.adapters=[],this.target=0,this.tick=0,this.interval=20,this.duration=800,this.lastTime=null,this.handlers=[];var e=this;this.transition=r.easeInOut,this.timerDelegate=function(){e.onTimerEvent()}},addAdapter:function(e){this.adapters.push(e)},onComplete:function(e){this.handlers.push(e)},removeHandler:function(t){this.handlers=e.grep(this.handlers,function(e){return e!==t})},trigger:function(){var e=this;this.handlers&&d.forEach(this.handlers,function(t){return t.call(null!==e.caller?e.caller:e)})},onStep:function(){},seekTo:function(e){this.seekFromTo(this.tick,e)},seekFromTo:function(e,t){this.target=Math.max(0,Math.min(1,t)),this.tick=Math.max(0,Math.min(1,e)),this.lastTime=(new Date).getTime(),this.intervalId||(this.intervalId=window.setInterval(this.timerDelegate,this.interval))},stop:function(){this.intervalId&&(window.clearInterval(this.intervalId),this.intervalId=null,this.trigger())},play:function(e){0!==this.adapters.length&&(null!==e&&(this.caller=e),this.initState(),this.seekFromTo(0,1))},reverse:function(){this.seekFromTo(1,0)},initState:function(){if(0!==this.adapters.length)for(var e=0;this.adapters.length>e;e++)this.adapters[e].initState()},propagate:function(){var e,t=this.transition(this.tick);for(e=0;this.adapters.length>e;e++)this.adapters[e].update(t)},onTimerEvent:function(){var e,t=(new Date).getTime(),n=t-this.lastTime;this.lastTime=t,e=n/this.duration*(this.target>this.tick?1:-1),Math.abs(e)>=Math.abs(this.tick-this.target)?this.tick=this.target:this.tick+=e;try{this.propagate()}finally{this.onStep.call(this),this.target==this.tick&&this.stop()}}}),a.deepExtend(s,{init:function(e){a.init(e,s.ui)},Utils:d,Range:n,Ticker:o})}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e){return Math.abs(e)
l||l>1||0>c||c>1)))return new A(e.x+l*(t.x-e.x),e.y+l*(t.y-e.y))}function r(e,t){var n,i,r;do n=2*Math.random()-1,i=2*Math.random()-1,r=n*n+i*i;while(!r||r>1);return e+t*n*Math.sqrt(-2*Math.log(r)/r)}function o(e){var t,n,i;for(D.isUndefined(e)&&(e=10),t="",n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",i=e;i>0;--i)t+=n.charAt(Math.round(Math.random()*(n.length-1)));return t}var a,s,l,c,u,d,h,f,p,g,m,v,_,b,y,w,x=window.kendo,k=x.dataviz.diagram,C=x.Class,S=x.deepExtend,T=x.dataviz,D=k.Utils,A=T.Point2D,M=x.isFunction,E=D.contains,I=e.map,R=3,P=1e-6;S(A.fn,{plus:function(e){return new A(this.x+e.x,this.y+e.y)},minus:function(e){return new A(this.x-e.x,this.y-e.y)},offset:function(e){return new A(this.x-e,this.y-e)},times:function(e){return new A(this.x*e,this.y*e)},normalize:function(){return 0===this.length()?new A:this.times(1/this.length())},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},toString:function(){return"("+this.x+","+this.y+")"},lengthSquared:function(){return this.x*this.x+this.y*this.y},middleOf:function(e,t){return new A(t.x-e.x,t.y-e.y).times(.5).plus(e)},toPolar:function(e){var t,n,i,r=1;if(e&&(r=180/Math.PI),t=Math.atan2(Math.abs(this.y),Math.abs(this.x)),n=Math.PI/2,i=this.length(),0===this.x){if(0===this.y)return new d(0,0);if(this.y>0)return new d(i,r*n);if(0>this.y)return new d(i,3*r*n)}else if(this.x>0){if(0===this.y)return new d(i,0);if(this.y>0)return new d(i,r*t);if(0>this.y)return new d(i,r*(4*n-t))}else{if(0===this.y)return new d(i,2*n);if(this.y>0)return new d(i,r*(2*n-t));if(0>this.y)return new d(i,r*(2*n+t))}},isOnLine:function(e,t){var n,i,r,o,a;return e.x>t.x&&(n=t,t=e,e=n),i=new s(e.x,e.y).inflate(R,R),r=new s(t.x,t.y).inflate(R,R),i.union(r).contains(this)?e.x===t.x||e.y===t.y?!0:(t.y>e.y?(o=i.x+(r.x-i.x)*(this.y-(i.y+i.height))/(r.y+r.height-(i.y+i.height)),a=i.x+i.width+(r.x+r.width-(i.x+i.width))*(this.y-i.y)/(r.y-i.y)):(o=i.x+(r.x-i.x)*(this.y-i.y)/(r.y-i.y),a=i.x+i.width+(r.x+r.width-(i.x+i.width))*(this.y-(i.y+i.height))/(r.y+r.height-(i.y+i.height))),this.x>o&&a>this.x):!1}}),S(A,{parse:function(e){var n=e.slice(1,e.length-1),i=n.split(","),r=parseInt(i[0],10),o=parseInt(i[1],10);return isNaN(r)||isNaN(o)?t:new A(r,o)}}),a=C.extend({init:function(e,t,n){this.point=e,this.left=t,this.right=n}}),s=C.extend({init:function(e,t,n,i){this.x=e||0,this.y=t||0,this.width=n||0,this.height=i||0},contains:function(e){return e.x>=this.x&&this.x+this.width>=e.x&&e.y>=this.y&&this.y+this.height>=e.y},inflate:function(e,n){return n===t&&(n=e),this.x-=e,this.y-=n,this.width+=2*e+1,this.height+=2*n+1,this},offset:function(e,t){var n=e,i=t;return e instanceof A&&(n=e.x,i=e.y),this.x+=n,this.y+=i,this},union:function(e){var t=Math.min(this.x,e.x),n=Math.min(this.y,e.y),i=Math.max(this.x+this.width,e.x+e.width),r=Math.max(this.y+this.height,e.y+e.height);return new s(t,n,i-t,r-n)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},top:function(){return new A(this.x+this.width/2,this.y)},right:function(){return new A(this.x+this.width,this.y+this.height/2)},bottom:function(){return new A(this.x+this.width/2,this.y+this.height)},left:function(){return new A(this.x,this.y+this.height/2)},topLeft:function(){return new A(this.x,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomRight:function(){return new A(this.x+this.width,this.y+this.height)},clone:function(){return new s(this.x,this.y,this.width,this.height)},isEmpty:function(){return!this.width&&!this.height},equals:function(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height},rotatedBounds:function(e){var t=this.clone(),n=this.rotatedPoints(e),i=n[0],r=n[1],o=n[2],a=n[3];return t.x=Math.min(o.x,i.x,r.x,a.x),t.y=Math.min(o.y,i.y,r.y,a.y),t.width=Math.max(o.x,i.x,r.x,a.x)-t.x,t.height=Math.max(o.y,i.y,r.y,a.y)-t.y,t},rotatedPoints:function(e){var t=this,n=t.center(),i=t.bottomRight().rotate(n,360-e),r=t.topLeft().rotate(n,360-e),o=t.topRight().rotate(n,360-e),a=t.bottomLeft().rotate(n,360-e);return[r,o,i,a]},toString:function(e){return e=e||" ",this.x+e+this.y+e+this.width+e+this.height},scale:function(e,t,n,i,r){var o,a,s,l=this.topLeft(),c=this.center();l.rotate(c,360-r).rotate(i,r),o=n.minus(l),a=new A(o.x*e,o.y*t),s=o.minus(a),l=l.plus(s),l.rotate(i,360-r).rotate(c,r),this.x=l.x,this.y=l.y,this.width*=e,this.height*=t},zoom:function(e){return this.x*=e,this.y*=e,this.width*=e,this.height*=e,this},overlaps:function(e){var t=this.bottomRight(),n=e.bottomRight(),i=!(e.x>t.x||e.y>t.y||this.x>n.x||this.y>n.y);return i}}),l=C.extend({init:function(e,t){this.width=e,this.height=t}}),l.prototype.Empty=new l(0,0),s.toRect=function(e){return e instanceof s||(e=new s(e.x,e.y,e.width,e.height)),e},s.empty=function(){return new s(0,0,0,0)},s.fromPoints=function(e,t){if(isNaN(e.x)||isNaN(e.y)||isNaN(t.x)||isNaN(t.y))throw"Some values are NaN.";return new s(Math.min(e.x,t.x),Math.min(e.y,t.y),Math.abs(e.x-t.x),Math.abs(e.y-t.y))},c={lines:function(e,t,n,r){return i(e,t,n,r)},segments:function(e,t,n,r){return i(e,t,n,r,!0)},rectWithLine:function(e,t,n){return c.segments(t,n,e.topLeft(),e.topRight())||c.segments(t,n,e.topRight(),e.bottomRight())||c.segments(t,n,e.bottomLeft(),e.bottomRight())||c.segments(t,n,e.topLeft(),e.bottomLeft())},rects:function(e,t,n){var i,r,o=t.topLeft(),a=t.topRight(),s=t.bottomLeft(),l=t.bottomRight(),u=t.center();return n&&(o=o.rotate(u,n),a=a.rotate(u,n),s=s.rotate(u,n),l=l.rotate(u,n)),i=e.contains(o)||e.contains(a)||e.contains(s)||e.contains(l)||c.rectWithLine(e,o,a)||c.rectWithLine(e,o,s)||c.rectWithLine(e,a,l)||c.rectWithLine(e,s,l),i||(o=e.topLeft(),a=e.topRight(),s=e.bottomLeft(),l=e.bottomRight(),n&&(r=360-n,o=o.rotate(u,r),a=a.rotate(u,r),s=s.rotate(u,r),l=l.rotate(u,r)),i=t.contains(o)||t.contains(a)||t.contains(s)||t.contains(l)),i}},u=C.extend({init:function(e){this.container=s.toRect(e)},align:function(e,t){var n,i=t.toLowerCase().split(" ");for(n=0;i.length>n;n++)e=this._singleAlign(e,i[n]);return e},_singleAlign:function(e,t){return M(this[t])?this[t](e):e},left:function(e){return this._align(e,this._left)},center:function(e){return this._align(e,this._center)},right:function(e){return this._align(e,this._right)},stretch:function(e){return this._align(e,this._stretch)},top:function(e){return this._align(e,this._top)},middle:function(e){return this._align(e,this._middle)},bottom:function(e){return this._align(e,this._bottom)},_left:function(e,t){t.x=e.x},_center:function(e,t){t.x=(e.width-t.width)/2||0},_right:function(e,t){t.x=e.width-t.width},_top:function(e,t){t.y=e.y},_middle:function(e,t){t.y=(e.height-t.height)/2||0},_bottom:function(e,t){t.y=e.height-t.height},_stretch:function(e,t){t.x=0,t.y=0,t.height=e.height,t.width=e.width},_align:function(e,t){return e=s.toRect(e),t(this.container,e),e}}),d=C.extend({init:function(e,t){this.r=e,this.angle=t}}),h=C.extend({init:function(e,t,n,i,r,o){this.a=e||0,this.b=t||0,this.c=n||0,this.d=i||0,this.e=r||0,this.f=o||0},plus:function(e){this.a+=e.a,this.b+=e.b,this.c+=e.c,this.d+=e.d,this.e+=e.e,this.f+=e.f},minus:function(e){this.a-=e.a,this.b-=e.b,this.c-=e.c,this.d-=e.d,this.e-=e.e,this.f-=e.f},times:function(e){return new h(this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f)},apply:function(e){return new A(this.a*e.x+this.c*e.y+this.e,this.b*e.x+this.d*e.y+this.f)},applyRect:function(e){return s.fromPoints(this.apply(e.topLeft()),this.apply(e.bottomRight()))},toString:function(){return"matrix("+this.a+" "+this.b+" "+this.c+" "+this.d+" "+this.e+" "+this.f+")"}}),S(h,{fromSVGMatrix:function(e){var t=new h;return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},fromMatrixVector:function(e){var t=new h;return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},fromList:function(e){if(6!==e.length)throw"The given list should consist of six elements.";var t=new h;return t.a=e[0],t.b=e[1],t.c=e[2],t.d=e[3],t.e=e[4],t.f=e[5],t},translation:function(e,t){var n=new h;return n.a=1,n.b=0,n.c=0,n.d=1,n.e=e,n.f=t,n},unit:function(){return new h(1,0,0,1,0,0)},rotation:function(e,t,n){var i=new h;return i.a=Math.cos(e*Math.PI/180),i.b=Math.sin(e*Math.PI/180),i.c=-i.b,i.d=i.a,i.e=t-t*i.a+n*i.b||0,i.f=n-n*i.a-t*i.b||0,i},scaling:function(e,t){var n=new h;return n.a=e,n.b=0,n.c=0,n.d=t,n.e=0,n.f=0,n},parse:function(e){var t,n;if(e){if(e=e.trim(),"matrix"===e.slice(0,6).toLowerCase()){if(n=e.slice(7,e.length-1).trim(),t=n.split(","),6===t.length)return h.fromList(I(t,function(e){return parseFloat(e)}));if(t=n.split(" "),6===t.length)return h.fromList(I(t,function(e){return parseFloat(e)}))}if("("===e.slice(0,1)&&")"===e.slice(e.length-1)&&(e=e.substr(1,e.length-1)),e.indexOf(",")>0&&(t=e.split(","),6===t.length))return h.fromList(I(t,function(e){return parseFloat(e)}));if(e.indexOf(" ")>0&&(t=e.split(" "),6===t.length))return h.fromList(I(t,function(e){return parseFloat(e)}))}return t}}),f=C.extend({init:function(e,t,n,i,r,o){this.a=e||0,this.b=t||0,this.c=n||0,this.d=i||0,this.e=r||0,this.f=o||0},fromMatrix:function(e){var t=new f;return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t}}),p={_distanceToLineSquared:function(e,t,n){function i(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)}if(t===n)return i(e,t);var r=n.x-t.x,o=n.y-t.y,a=(e.x-t.x)*r+(e.y-t.y)*o;return 0>a?i(t,e):(a=(n.x-e.x)*r+(n.y-e.y)*o,0>a?i(n,e):(a=(n.x-e.x)*o-(n.y-e.y)*r,a*a/(r*r+o*o)))},distanceToLine:function(e,t,n){return Math.sqrt(this._distanceToLineSquared(e,t,n))},distanceToPolyline:function(e,t){var n,i,r,o,a=Number.MAX_VALUE;if(D.isUndefined(t)||0===t.length)return Number.MAX_VALUE;for(n=0;t.length-1>n;n++)i=t[n],r=t[n+1],o=this._distanceToLineSquared(e,i,r),a>o&&(a=o);return Math.sqrt(a)}},g=x.Class.extend({init:function(){this._buckets=[],this.length=0},add:function(e,t){var n=this._createGetBucket(e);return D.isDefined(t)&&(n.value=t),n},get:function(e){return this._bucketExists(e)?this._createGetBucket(e):null},set:function(e,t){this.add(e,t)},containsKey:function(e){return this._bucketExists(e)},remove:function(e){if(this._bucketExists(e)){var t=this._hash(e);return delete this._buckets[t],this.length--,e}},forEach:function(e){var t,n,i,r,o=this._hashes();for(t=0,n=o.length;n>t;t++)i=o[t],r=this._buckets[i],D.isUndefined(r)||e(r)},clone:function(){var e,t,n,i,r=new g,o=this._hashes();for(e=0,t=o.length;t>e;e++)n=o[e],i=this._buckets[n],D.isUndefined(i)||r.add(i.key,i.value);return r},_hashes:function(){var e,t=[];for(e in this._buckets)this._buckets.hasOwnProperty(e)&&t.push(e);return t},_bucketExists:function(e){var t=this._hash(e);return D.isDefined(this._buckets[t])},_createGetBucket:function(e){var t=this._hash(e),n=this._buckets[t];return D.isUndefined(n)&&(n={key:e},this._buckets[t]=n,this.length++),n},_hash:function(e){if(D.isNumber(e))return e;if(D.isString(e))return this._hashString(e);if(D.isObject(e))return this._objectHashId(e);throw"Unsupported key type."},_hashString:function(e){var t,n,i=0;if(0===e.length)return i;for(t=0;e.length>t;t++)n=e.charCodeAt(t),i=32*i-i+n;return i},_objectHashId:function(e){var t=e._hashId;return D.isUndefined(t)&&(t=o(),e._hashId=t),t}}),m=x.Observable.extend({init:function(t){var n,i=this;if(x.Observable.fn.init.call(i),this._hashTable=new g,this.length=0,D.isDefined(t))if(e.isArray(t))for(n=0;t.length>n;n++)this.add(t[n]);else t.forEach(function(e,t){this.add(e,t)},this)},add:function(e,t){var n=this._hashTable.get(e);n||(n=this._hashTable.add(e),this.length++,this.trigger("changed")),n.value=t},set:function(e,t){this.add(e,t)},get:function(e){var t=this._hashTable.get(e);if(t)return t.value;throw Error("Cannot find key "+e)},containsKey:function(e){return this._hashTable.containsKey(e)},remove:function(e){return this.containsKey(e)?(this.trigger("changed"),this.length--,this._hashTable.remove(e)):t},forEach:function(e,t){this._hashTable.forEach(function(n){e.call(t,n.key,n.value)})},forEachValue:function(e,t){this._hashTable.forEach(function(n){e.call(t,n.value)})},forEachKey:function(e,t){this._hashTable.forEach(function(n){e.call(t,n.key)})},keys:function(){var e=[];return this.forEachKey(function(t){e.push(t)}),e}}),v=x.Class.extend({init:function(){this._tail=null,this._head=null,this.length=0},enqueue:function(e){var t={value:e,next:null};this._head?(this._tail.next=t,this._tail=this._tail.next):(this._head=t,this._tail=this._head),this.length++},dequeue:function(){if(1>this.length)throw Error("The queue is empty.");var e=this._head.value;return this._head=this._head.next,this.length--,e},contains:function(e){for(var t=this._head;t;){if(t.value===e)return!0;t=t.next}return!1}}),_=x.Observable.extend({init:function(e){var t=this;x.Observable.fn.init.call(t),this._hashTable=new g,this.length=0,D.isDefined(e)&&(e instanceof g?e.forEach(function(e){this.add(e)}):e instanceof m&&e.forEach(function(e,t){this.add({key:e,value:t})},this))},contains:function(e){return this._hashTable.containsKey(e)},add:function(e){var t=this._hashTable.get(e);t||(this._hashTable.add(e,e),this.length++,this.trigger("changed"))},get:function(e){return this.contains(e)?this._hashTable.get(e).value:null},hash:function(e){return this._hashTable._hash(e)},remove:function(e){this.contains(e)&&(this._hashTable.remove(e),this.length--,this.trigger("changed"))},forEach:function(e,t){this._hashTable.forEach(function(t){e(t.value)},t)},toArray:function(){var e=[];return this.forEach(function(t){e.push(t)}),e}}),b=x.Class.extend({init:function(e,t){if(this.links=[],this.outgoing=[],this.incoming=[],this.weight=1,this.id=D.isDefined(e)?e:o(),D.isDefined(t)){this.associatedShape=t;var n=t.bounds();this.width=n.width,this.height=n.height,this.x=n.x,this.y=n.y}else this.associatedShape=null;this.data=null,this.type="Node",this.shortForm="Node '"+this.id+"'",this.isVirtual=!1},isIsolated:function(){return D.isEmpty(this.links)},bounds:function(e){return D.isDefined(e)?(this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,t):new k.Rect(this.x,this.y,this.width,this.height)},isLinkedTo:function(e){var t=this;return D.any(t.links,function(n){return n.getComplement(t)===e})},getChildren:function(){var e,t,n,i;if(0===this.outgoing.length)return[];for(e=[],t=0,n=this.outgoing.length;n>t;t++)i=this.outgoing[t],e.push(i.getComplement(this));return e},getParents:function(){var e,t,n,i;if(0===this.incoming.length)return[];for(e=[],t=0,n=this.incoming.length;n>t;t++)i=this.incoming[t],e.push(i.getComplement(this));return e},clone:function(){var e=new b;return D.isDefined(this.weight)&&(e.weight=this.weight),D.isDefined(this.balance)&&(e.balance=this.balance),D.isDefined(this.owner)&&(e.owner=this.owner),e.associatedShape=this.associatedShape,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e},adjacentTo:function(e){return null!==this.isLinkedTo(e)},removeLink:function(e){e.source===this&&(D.remove(this.links,e),D.remove(this.outgoing,e),e.source=null),e.target===this&&(D.remove(this.links,e),D.remove(this.incoming,e),e.target=null)},hasLinkTo:function(e){return D.any(this.outgoing,function(t){return t.target===e})},degree:function(){return this.links.length},incidentWith:function(e){return E(this.links,e)},getLinksWith:function(e){return D.all(this.links,function(t){return t.getComplement(this)===e},this)},getNeighbors:function(){var e=[];return D.forEach(this.incoming,function(t){e.push(t.getComplement(this))},this),D.forEach(this.outgoing,function(t){e.push(t.getComplement(this))},this),e}}),y=x.Class.extend({init:function(e,t,n,i){if(D.isUndefined(e))throw"The source of the new link is not set.";if(D.isUndefined(t))throw"The target of the new link is not set.";var r,a;r=D.isString(e)?new b(e):e,a=D.isString(t)?new b(t):t,this.source=r,this.target=a,this.source.links.push(this),this.target.links.push(this),this.source.outgoing.push(this),this.target.incoming.push(this),this.id=D.isDefined(n)?n:o(),this.associatedConnection=D.isDefined(i)?i:null,this.type="Link",this.shortForm="Link '"+this.source.id+"->"+this.target.id+"'"},getComplement:function(e){if(this.source!==e&&this.target!==e)throw"The given node is not incident with this link.";return this.source===e?this.target:this.source},getCommonNode:function(e){return this.source===e.source||this.source===e.target?this.source:this.target===e.source||this.target===e.target?this.target:null},isBridging:function(e,t){return this.source===e&&this.target===t||this.source===t&&this.target===e},getNodes:function(){return[this.source,this.target]},incidentWith:function(e){return this.source===e||this.target===e},adjacentTo:function(e){return E(this.source.links,e)||E(this.target.links,e)},changeSource:function(e){D.remove(this.source.links,this),D.remove(this.source.outgoing,this),e.links.push(this),e.outgoing.push(this),this.source=e},changeTarget:function(e){D.remove(this.target.links,this),D.remove(this.target.incoming,this),e.links.push(this),e.incoming.push(this),this.target=e},changesNodes:function(e,t){this.source===e?this.changeSource(t):this.target===e&&this.changeTarget(t)},reverse:function(){var e=this.source,t=this.target;return this.source=t,D.remove(e.outgoing,this),this.source.outgoing.push(this),this.target=e,D.remove(t.incoming,this),this.target.incoming.push(this),this},directTo:function(e){if(this.source!==e&&this.target!==e)throw"The given node is not incident with this link.";this.target!==e&&this.reverse()},createReverseEdge:function(){var e=this.clone();return e.reverse(),e.reversed=!0,e},clone:function(){var e=new y(this.source,this.target);return e}}),w=x.Class.extend({init:function(e){this.links=[],this.nodes=[],this._nodeMap=new m,this.diagram=null,this._root=null,D.isDefined(e)?D.isString(e)?this.id=e:(this.diagram=e,this.id=e.id):this.id=o(),this.bounds=new s,this._hasCachedRelationships=!1,this.type="Graph"},cacheRelationships:function(e){var t,n,i;if(D.isUndefined(e)&&(e=!1),!this._hasCachedRelationships||e){for(t=0,n=this.nodes.length;n>t;t++)i=this.nodes[t],i.children=this.getChildren(i),i.parents=this.getParents(i);this._hasCachedRelationships=!0}},assignLevels:function(e,t,n){var i,r,o,a;if(!e)throw"Start node not specified.";for(D.isUndefined(t)&&(t=0),this.cacheRelationships(),D.isUndefined(n)&&(n=new m,D.forEach(this.nodes,function(e){n.add(e,!1)})),n.set(e,!0),e.level=t,i=e.children,r=0,o=i.length;o>r;r++)a=i[r],a&&!n.get(a)&&this.assignLevels(a,t+1,n)},root:function(e){if(D.isUndefined(e)){if(this._root)return this._root;var t=D.first(this.nodes,function(e){return 0===e.incoming.length});return t?t:D.first(this.nodes)}this._root=e},getConnectedComponents:function(){var e,t,n,i,r;for(this.componentIndex=0,this.setItemIndices(),e=D.initArray(this.nodes.length,-1),t=0;this.nodes.length>t;t++)-1===e[t]&&(this._collectConnectedNodes(e,t),this.componentIndex++);for(n=[],i=0;this.componentIndex>i;++i)n[i]=new w;for(i=0;e.length>i;++i)r=n[e[i]],r.addNodeAndOutgoings(this.nodes[i]);return n.sort(function(e,t){return t.nodes.length-e.nodes.length}),n},_collectConnectedNodes:function(e,t){e[t]=this.componentIndex;var n=this.nodes[t];D.forEach(n.links,function(t){var i=t.getComplement(n),r=i.index;-1===e[r]&&this._collectConnectedNodes(e,r)},this)},calcBounds:function(){var e,t,n,i;if(this.isEmpty())return this.bounds=new s;for(e=null,t=0,n=this.nodes.length;n>t;t++)i=this.nodes[t],e=e?e.union(i.bounds()):i.bounds();return this.bounds=e},getSpanningTree:function(e){var t,n,i,r,o,a,s,l,c,u,d,h,f=new w,p=new m;for(f.root=e.clone(),f.root.level=0,f.root.id=e.id,p.add(e,f.root),e.level=0,i=[],r=[],f._addNode(f.root),i.push(e),r.push(e),o=1;r.length>0;)for(a=r.pop(),s=0;a.links.length>s;s++)l=a.links[s],c=l.getComplement(a),E(i,c)||(c.level=a.level+1,c.level+1>o&&(o=c.level+1),E(r,c)||r.push(c),E(i,c)||i.push(c),p.containsKey(a)?t=p.get(a):(t=a.clone(),t.level=a.level,t.id=a.id,p.add(a,t)),p.containsKey(c)?n=p.get(c):(n=c.clone(),n.level=c.level,n.id=c.id,p.add(c,n)),u=new y(t,n),f.addLink(u));for(d=[],h=0;o>h;h++)d.push([]);return D.forEach(f.nodes,function(e){d[e.level].push(e)}),f.treeLevels=d,f.cacheRelationships(),f},takeRandomNode:function(t,n){if(D.isUndefined(t)&&(t=[]),D.isUndefined(n)&&(n=4),0===this.nodes.length)return null;if(1===this.nodes.length)return E(t,this.nodes[0])?null:this.nodes[0];var i=e.grep(this.nodes,function(e){return!E(t,e)&&e.degree()<=n});return D.isEmpty(i)?null:i[D.randomInteger(0,i.length)]},isEmpty:function(){return D.isEmpty(this.nodes)},isHealthy:function(){return D.all(this.links,function(e){return E(this.nodes,e.source)&&E(this.nodes,e.target)},this)},getParents:function(e){if(!this.hasNode(e))throw"The given node is not part of this graph.";return e.getParents()},getChildren:function(e){if(!this.hasNode(e))throw"The given node is not part of this graph.";return e.getChildren()},addLink:function(e,n,i){var r,o,a;if(D.isUndefined(e))throw"The source of the link is not defined.";if(D.isUndefined(n)){if(D.isDefined(e.type)&&"Link"===e.type)return this.addExistingLink(e),t;throw"The target of the link is not defined."}return r=this.getNode(e),D.isUndefined(r)&&(r=this.addNode(e)),o=this.getNode(n),D.isUndefined(o)&&(o=this.addNode(n)),a=new y(r,o),D.isDefined(i)&&(a.owner=i),this.links.push(a),a},removeAllLinks:function(){for(;this.links.length>0;){var e=this.links[0];this.removeLink(e)}},addExistingLink:function(e){var t,n;this.hasLink(e)||(this.links.push(e),this.hasNode(e.source.id)?(t=this.getNode(e.source.id),e.changeSource(t)):this.addNode(e.source),this.hasNode(e.target.id)?(n=this.getNode(e.target.id),e.changeTarget(n)):this.addNode(e.target))},hasLink:function(e){if(D.isString(e))return D.any(this.links,function(t){return t.id===e});if("Link"===e.type)return E(this.links,e);throw"The given object is neither an identifier nor a Link."},getNode:function(e){var n=e.id||e;return this._nodeMap.containsKey(n)?this._nodeMap.get(n):t},hasNode:function(e){var t=e.id||e;return this._nodeMap.containsKey(t)},_addNode:function(e){this.nodes.push(e),this._nodeMap.add(e.id,e)},_removeNode:function(e){D.remove(this.nodes,e),this._nodeMap.remove(e.id)},removeNode:function(e){var t,n,i,r,o=e;if(D.isString(e)&&(o=this.getNode(e)),!D.isDefined(o))throw"The identifier should be a Node or the Id (string) of a node.";for(t=o.links,o.links=[],n=0,i=t.length;i>n;n++)r=t[n],this.removeLink(r);this._removeNode(o)},areConnected:function(e,t){return D.any(this.links,function(n){return n.source==e&&n.target==t||n.source==t&&n.target==e})},removeLink:function(e){D.remove(this.links,e),D.remove(e.source.outgoing,e),D.remove(e.source.links,e),D.remove(e.target.incoming,e),D.remove(e.target.links,e)},addNode:function(e,t,n){var i=null;if(!D.isDefined(e))throw"No Node or identifier for a new Node is given.";if(D.isString(e)){if(this.hasNode(e))return this.getNode(e);i=new b(e)}else{if(this.hasNode(e))return this.getNode(e);i=e}return D.isDefined(t)&&i.bounds(t),D.isDefined(n)&&(i.owner=n),this._addNode(i),i},addNodeAndOutgoings:function(e){this.hasNode(e)||this._addNode(e);var t=e.outgoing;e.outgoing=[],D.forEach(t,function(e){this.addExistingLink(e)},this)},setItemIndices:function(){var e;for(e=0;this.nodes.length>e;++e)this.nodes[e].index=e;for(e=0;this.links.length>e;++e)this.links[e].index=e},clone:function(e){var t,n=new w,i=D.isDefined(e)&&e===!0;return i&&(n.nodeMap=new m,n.linkMap=new m),t=new m,D.forEach(this.nodes,function(e){var r=e.clone();t.set(e,r),n._addNode(r),i&&n.nodeMap.set(r,e)}),D.forEach(this.links,function(e){if(t.containsKey(e.source)&&t.containsKey(e.target)){var r=n.addLink(t.get(e.source),t.get(e.target));i&&n.linkMap.set(r,e)}}),n},linearize:function(e){return w.Utils.linearize(this,e)},depthFirstTraversal:function(e,t){var n,i;if(D.isUndefined(e))throw"You need to supply a starting node.";if(D.isUndefined(t))throw"You need to supply an action.";if(!this.hasNode(e))throw"The given start-node is not part of this graph";n=this.getNode(e),i=[],this._dftIterator(n,t,i)},_dftIterator:function(e,t,n){var i,r,o,a;for(t(e),n.push(e),i=e.getChildren(),r=0,o=i.length;o>r;r++)a=i[r],E(n,a)||this._dftIterator(a,t,n)},breadthFirstTraversal:function(e,t){var n,i,r,o,a,s,l,c;if(D.isUndefined(e))throw"You need to supply a starting node.";if(D.isUndefined(t))throw"You need to supply an action.";if(!this.hasNode(e))throw"The given start-node is not part of this graph";for(n=this.getNode(e),i=new v,r=[],i.enqueue(n);i.length>0;)for(o=i.dequeue(),t(o),r.push(o),a=o.getChildren(),s=0,l=a.length;l>s;s++)c=a[s],E(r,c)||E(i,c)||i.enqueue(c)},_stronglyConnectedComponents:function(e,t,n,i,r,o,a){var s,l,c,u,d;for(n.add(t,a),i.add(t,a),a++,o.push(t),s=t.getChildren(),c=0,u=s.length;u>c;c++)l=s[c],n.containsKey(l)?E(o,l)&&i.add(t,Math.min(i.get(t),n.get(l))):(this._stronglyConnectedComponents(e,l,n,i,r,o,a),i.add(t,Math.min(i.get(t),i.get(l))));if(i.get(t)===n.get(t)){d=[];do l=o.pop(),d.push(l);while(l!==t);(!e||d.length>1)&&r.push(d)}},findCycles:function(e){var t,n,i,r,o,a,s;for(D.isUndefined(e)&&(e=!0),t=new m,n=new m,i=[],r=[],o=0,a=this.nodes.length;a>o;o++)s=this.nodes[o],t.containsKey(s)||this._stronglyConnectedComponents(e,s,t,n,i,r,0);return i},isAcyclic:function(){return D.isEmpty(this.findCycles())},isSubGraph:function(e){var t=e.linearize(),n=this.linearize();return D.all(t,function(e){return E(n,e)})},makeAcyclic:function(){var e,t,n,i,r,o,a,s,l,c,u,d,h,f,p,g,v,_,b,y,w,x,k,C,S,T,A,M,E,I,R,P;if(this.isEmpty()||1>=this.nodes.length||1>=this.links.length)return[];if(2==this.nodes.length){if(e=[],this.links.length>1)for(t=this.links[0],n=t.source,i=0,r=this.links.length;r>i;i++)o=this.links[i],o.source!=n&&(a=o.reverse(),e.push(a));return e}for(s=this.clone(!0),l=this.nodes.length,c=new m,u=function(e){return 0===e.outgoing.length?2-l:0===e.incoming.length?l-2:e.outgoing.length-e.incoming.length},d=function(e,t){var n=u(e,l);t.containsKey(n)||t.set(n,[]),t.get(n).push(e)},D.forEach(s.nodes,function(e){
d(e,c)}),h=[],f=[];s.nodes.length>0;){if(c.containsKey(2-l))for(_=c.get(2-l);_.length>0;){for(g=_.pop(),b=0;g.links.length>b;b++)y=g.links[b],p=y.getComplement(g),v=u(p,l),D.remove(c.get(v),p),p.removeLink(y),d(p,c);s._removeNode(g),f.unshift(g)}if(c.containsKey(l-2))for(w=c.get(l-2);w.length>0;){for(p=w.pop(),x=0;p.links.length>x;x++)k=p.links[x],g=k.getComplement(p),v=u(g,l),D.remove(c.get(v),g),g.removeLink(k),d(g,c);h.push(p),s._removeNode(p)}if(s.nodes.length>0)for(C=l-3;C>2-l;C--)if(c.containsKey(C)&&c.get(C).length>0){for(S=c.get(C),T=S.pop(),A=0;T.links.length>A;A++)M=T.links[A],E=M.getComplement(T),v=u(E,l),D.remove(c.get(v),E),E.removeLink(M),d(E,c);h.push(T),s._removeNode(T);break}}for(h=h.concat(f),I=new m,R=0;this.nodes.length>R;R++)I.set(s.nodeMap.get(h[R]),R);return P=[],D.forEach(this.links,function(e){I.get(e.source)>I.get(e.target)&&(e.reverse(),P.push(e))}),P}}),w.Predefined={EightGraph:function(){return w.Utils.parse(["1->2","2->3","3->4","4->1","3->5","5->6","6->7","7->3"])},Mindmap:function(){return w.Utils.parse(["0->1","0->2","0->3","0->4","0->5","1->6","1->7","7->8","2->9","9->10","9->11","3->12","12->13","13->14","4->15","4->16","15->17","15->18","18->19","18->20","14->21","14->22","5->23","23->24","23->25","6->26"])},ThreeGraph:function(){return w.Utils.parse(["1->2","2->3","3->1"])},BinaryTree:function(e){return D.isUndefined(e)&&(e=5),w.Utils.createBalancedTree(e,2)},Linear:function(e){return D.isUndefined(e)&&(e=10),w.Utils.createBalancedTree(e,1)},Tree:function(e,t){return w.Utils.createBalancedTree(e,t)},Forest:function(e,t,n){return w.Utils.createBalancedForest(e,t,n)},Workflow:function(){return w.Utils.parse(["0->1","1->2","2->3","1->4","4->3","3->5","5->6","6->3","6->7","5->4"])},Grid:function(e,t){var n,i,r,o,a,s=new k.Graph;if(0>=e&&0>=t)return s;for(n=0;e+1>n;n++)for(i=null,r=0;t+1>r;r++)o=new b(""+n+"."+r),s.addNode(o),i&&s.addLink(i,o),n>0&&(a=s.getNode(""+(n-1)+"."+r),s.addLink(a,o)),i=o;return s}},w.Utils={parse:function(e){var t,n,i,r,o,a=new k.Graph,s=e.slice();for(n=0,i=s.length;i>n;n++){if(r=s[n],D.isString(r)){if(r.indexOf("->")<0)throw"The link should be specified as 'a->b'.";if(o=r.split("->"),2!=o.length)throw"The link should be specified as 'a->b'.";t=new y(o[0],o[1]),a.addLink(t)}if(D.isObject(r)){if(!t)throw"Specification found before Link definition.";x.deepExtend(t,r)}}return a},linearize:function(e,t){var n,i,r,o;if(D.isUndefined(e))throw"Expected an instance of a Graph object in slot one.";for(D.isUndefined(t)&&(t=!1),n=[],i=0,r=e.links.length;r>i;i++)o=e.links[i],n.push(o.source.id+"->"+o.target.id),t&&n.push({id:o.id});return n},_addShape:function(e,t,n,i){return D.isUndefined(t)&&(t=new k.Point(0,0)),D.isUndefined(n)&&(n=o()),i=x.deepExtend({width:20,height:20,id:n,radius:10,fill:"#778899",data:"circle",undoable:!1,x:t.x,y:t.y},i),e.addShape(i)},_addConnection:function(e,t,n,i){return e.connect(t,n,i)},createDiagramFromGraph:function(e,t,n,i){var r,o,a,l,c,u,d,h,f,p,g,m,v,_,b,y;if(D.isUndefined(e))throw"The diagram surface is undefined.";if(D.isUndefined(t))throw"No graph specification defined.";for(D.isUndefined(n)&&(n=!0),D.isUndefined(i)&&(i=!1),r=e.element.clientWidth||200,o=e.element.clientHeight||200,a=[],u=0,d=t.nodes.length;d>u;u++)l=t.nodes[u],h=l.position,D.isUndefined(h)&&(h=D.isDefined(l.x)&&D.isDefined(l.y)?new A(l.x,l.y):new A(D.randomInteger(10,r-20),D.randomInteger(10,o-20))),f={},"0"===l.id||i&&x.deepExtend(f,{width:150*Math.random()+20,height:80*Math.random()+50,data:"rectangle",fill:{color:"#778899"}}),c=this._addShape(e,h,l.id,f),p=c.bounds(),D.isDefined(p)&&(l.x=p.x,l.y=p.y,l.width=p.width,l.height=p.height),a[l.id]=c;for(g=0;t.links.length>g;g++)m=t.links[g],v=a[m.source.id],D.isUndefined(v)||(_=a[m.target.id],D.isUndefined(_)||this._addConnection(e,v,_,{id:m.id}));if(n)for(b=new e.SpringLayout(e),b.layoutGraph(t,{limitToView:!1}),y=0;t.nodes.length>y;y++)l=t.nodes[y],c=a[l.id],c.bounds(new s(l.x,l.y,l.width,l.height))},createBalancedTree:function(e,t){var n,i,r,o,a,s,l,c,u,d;if(D.isUndefined(e)&&(e=3),D.isUndefined(t)&&(t=3),n=new k.Graph,i=-1,r=[],0>=e||0>=t)return n;for(a=new b(""+ ++i),n.addNode(a),n.root=a,r.push(a),s=0;e>s;s++){for(o=[],l=0;r.length>l;l++)for(c=r[l],u=0;t>u;u++)d=new b(""+ ++i),n.addLink(c,d),o.push(d);r=o}return n},createBalancedForest:function(e,t,n){var i,r,o,a,s,l,c,u,d,h,f;if(D.isUndefined(e)&&(e=3),D.isUndefined(t)&&(t=3),D.isUndefined(n)&&(n=5),i=new k.Graph,r=-1,o=[],0>=e||0>=t||0>=n)return i;for(s=0;n>s;s++)for(l=new b(""+ ++r),i.addNode(l),o=[l],c=0;e>c;c++){for(a=[],u=0;o.length>u;u++)for(d=o[u],h=0;t>h;h++)f=new b(""+ ++r),i.addLink(d,f),a.push(f);o=a}return i},createRandomConnectedGraph:function(e,t,n){var i,r,o,a,s,l,c,u,d,h;if(D.isUndefined(e)&&(e=40),D.isUndefined(t)&&(t=4),D.isUndefined(n)&&(n=!1),i=new k.Graph,r=-1,0>=e)return i;if(o=new b(""+ ++r),i.addNode(o),1===e)return i;if(e>1){for(a=1;e>a&&(s=i.takeRandomNode([],t),s);a++)l=i.addNode(""+a),i.addLink(s,l);if(!n&&e>1)for(c=D.randomInteger(1,e),u=0;c>u;u++)d=i.takeRandomNode([],t),h=i.takeRandomNode([],t),d&&h&&!i.areConnected(d,h)&&i.addLink(d,h);return i}},randomDiagram:function(e,t,n,i,r){var o=x.dataviz.diagram.Graph.Utils.createRandomConnectedGraph(t,n,i);w.Utils.createDiagramFromGraph(e,o,!1,r)}},x.deepExtend(k,{init:function(e){x.init(e,k.ui)},Point:A,Intersect:c,Geometry:p,Rect:s,Size:l,RectAlign:u,Matrix:h,MatrixVector:f,normalVariable:r,randomId:o,Dictionary:m,HashTable:g,Queue:v,Set:_,Node:b,Link:y,Graph:w,PathDefiner:a})}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e,t){var n,i,r,o=this.options,a=!1;for(r=0;t.length>r;r++)i=t[r],n=e[i],H(n)&&o[i]!==n&&(o[i]=n,a=!0);return a}function i(e){return{x:e.x||0,y:e.y||0,width:e.width||0,height:e.height||0}}function r(e){if(e){var t=e;return N(t)&&(t={color:t}),t.color&&(t.color=o(t.color)),t}}function o(e){var t;return t=e!=q?new U.Color(e).toHex():e}function a(e,t){var n=t.x-e.x,i=t.y-e.y,r=E.util.deg(Math.atan2(i,n));return r}function s(e,t){return new U.Segment(new V.Point(e,t))}function l(e){return e?new V.Rect([e.x,e.y],[e.width,e.height]):t}var c,u,d,h,f,p,g,m,v,_,b,y,w,x,k,C,S,T,D,A,M,E=window.kendo,I=E.dataviz.diagram,R=E.Class,P=E.deepExtend,F=I.Point,B=I.Rect,z=I.Matrix,L=I.Utils,H=L.isNumber,N=L.isString,O=I.MatrixVector,V=E.geometry,U=E.drawing,W=E.util.defined,j=e.inArray,q="transparent",G={none:"none",arrowStart:"ArrowStart",filledCircle:"FilledCircle",arrowEnd:"ArrowEnd"},$=360,Y="start",K="end",Q="width",X="height",J="x",Z="y";I.Markers=G,c=R.extend({init:function(e,t){this.x=e,this.y=t},toMatrix:function(){return z.scaling(this.x,this.y)},toString:function(){return E.format("scale({0},{1})",this.x,this.y)},invert:function(){return new c(1/this.x,1/this.y)}}),u=R.extend({init:function(e,t){this.x=e,this.y=t},toMatrixVector:function(){return new O(0,0,0,0,this.x,this.y)},toMatrix:function(){return z.translation(this.x,this.y)},toString:function(){return E.format("translate({0},{1})",this.x,this.y)},plus:function(e){this.x+=e.x,this.y+=e.y},times:function(e){this.x*=e,this.y*=e},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){0!==this.Length&&this.times(1/this.length())},invert:function(){return new u(-this.x,-this.y)}}),d=R.extend({init:function(e,t,n){this.x=t||0,this.y=n||0,this.angle=e},toString:function(){return this.x&&this.y?E.format("rotate({0},{1},{2})",this.angle,this.x,this.y):E.format("rotate({0})",this.angle)},toMatrix:function(){return z.rotation(this.angle,this.x,this.y)},center:function(){return new F(this.x,this.y)},invert:function(){return new d($-this.angle,this.x,this.y)}}),d.ZERO=new d(0),d.create=function(e){return new d(e.angle,e.x,e.y)},d.parse=function(e){var t=e.slice(1,e.length-1).split(","),n=t[0],i=t[1],r=t[2],o=new d(n,i,r);return o},h=R.extend({init:function(e,n,i,r,o,a){this.translate=new u(e,n),i!==t&&r!==t&&(this.scale=new c(i,r)),o!==t&&(this.rotate=a?new d(o,a.x,a.y):new d(o))},toString:function(){var e=function(e){return e?""+e:""};return e(this.translate)+e(this.rotate)+e(this.scale)},render:function(e){e._transform=this,e._renderTransform()},toMatrix:function(){var e=z.unit();return this.translate&&(e=e.times(this.translate.toMatrix())),this.rotate&&(e=e.times(this.rotate.toMatrix())),this.scale&&(e=e.times(this.scale.toMatrix())),e},invert:function(){var e,n,i=this.rotate?this.rotate.invert():t,r=i?i.toMatrix():z.unit(),o=this.scale?this.scale.invert():t,a=o?o.toMatrix():z.unit(),s=new F(-this.translate.x,-this.translate.y);return s=r.times(a).apply(s),e=new u(s.x,s.y),n=new h,n.translate=e,n.rotate=i,n.scale=o,n}}),f={_setScale:function(){var e=this.options,t=this._originWidth,n=this._originHeight,i=e.width/t,r=e.height/n;H(i)||(i=1),H(r)||(r=1),this._transform.scale=new c(i,r)},_setTranslate:function(){var e=this.options,t=e.x||0,n=e.y||0;this._transform.translate=new u(t,n)},_initSize:function(){var e=this.options,t=!1;e.autoSize!==!1&&(W(e.width)||W(e.height))&&(this._measure(!0),this._setScale(),t=!0),(W(e.x)||W(e.y))&&(this._setTranslate(),t=!0),t&&this._renderTransform()},_updateSize:function(e){var t=!1;return this.options.autoSize!==!1&&this._diffNumericOptions(e,[Q,X])&&(t=!0,this._measure(!0),this._setScale()),this._diffNumericOptions(e,[J,Z])&&(t=!0,this._setTranslate()),t&&this._renderTransform(),t}},p=R.extend({init:function(e){var t=this;t.options=P({},t.options,e),t.id=t.options.id,t._originSize=B.empty(),t._transform=new h},visible:function(e){return this.drawingContainer().visible(e)},redraw:function(e){e&&e.id&&(this.id=e.id)},position:function(e,n){var i=this.options;return W(e)?(W(n)?(i.x=e,i.y=n):e instanceof F&&(i.x=e.x,i.y=e.y),this._transform.translate=new u(i.x,i.y),this._renderTransform(),t):new F(i.x,i.y)},rotate:function(e,t){return W(e)&&(this._transform.rotate=new d(e,t.x,t.y),this._renderTransform()),this._transform.rotate||d.ZERO},drawingContainer:function(){return this.drawingElement},_renderTransform:function(){var e=this._transform.toMatrix();this.drawingContainer().transform(new V.Matrix(e.a,e.b,e.c,e.d,e.e,e.f))},_hover:function(){},_diffNumericOptions:n,_measure:function(e){var t,n,i;return!this._measured||e?(n=this._boundingBox()||new V.Rect,i=n.topLeft(),t=new B(i.x,i.y,n.width(),n.height()),this._originSize=t,this._originWidth=t.width,this._originHeight=t.height,this._measured=!0):t=this._originSize,t},_boundingBox:function(){return this.drawingElement.rawBBox()}}),g=p.extend({init:function(e){p.fn.init.call(this,e),e=this.options,e.fill=r(e.fill),e.stroke=r(e.stroke)},options:{stroke:{color:"gray",width:1},fill:{color:q}},fill:function(e,t){this._fill({color:o(e),opacity:t})},stroke:function(e,t,n){this._stroke({color:o(e),width:t,opacity:n})},redraw:function(e){var t,n;e&&(t=e.stroke,n=e.fill,t&&this._stroke(r(t)),n&&this._fill(r(n)),p.fn.redraw.call(this,e))},_hover:function(e){var t,n=this.drawingElement,i=this.options,o=i.hover;o&&o.fill&&(t=e?r(o.fill):i.fill,n.fill(t.color,t.opacity))},_stroke:function(e){var t,n=this.options;P(n,{stroke:e}),e=n.stroke,t=null,e.width>0&&(t={color:e.color,width:e.width,opacity:e.opacity,dashType:e.dashType}),this.drawingElement.options.set("stroke",t)},_fill:function(e){var t,n,i,r=this.options;P(r,{fill:e||{}}),t=r.fill,t.gradient?(n=t.gradient,i="radial"===n.type?U.RadialGradient:U.LinearGradient,this.drawingElement.fill(new i(n))):this.drawingElement.fill(t.color,t.opacity)}}),m=g.extend({init:function(e){this._textColor(e),g.fn.init.call(this,e),this._font(),this._initText(),this._initSize()},options:{fontSize:15,fontFamily:"sans-serif",stroke:{width:0},fill:{color:"black"},autoSize:!0},_initText:function(){var e=this.options;this.drawingElement=new U.Text(W(e.text)?e.text:"",new V.Point,{font:e.font}),this._fill(),this._stroke()},_textColor:function(e){e&&e.color&&P(e,{fill:{color:e.color}})},_font:function(){var e=this.options;e.fontFamily&&W(e.fontSize)?e.font=e.fontSize+"px "+e.fontFamily:delete e.font},content:function(e){return this.drawingElement.content(e)},redraw:function(e){var t,n;e&&(t=!1,n=this.options,this._textColor(e),g.fn.redraw.call(this,e),(e.fontFamily||W(e.fontSize))&&(P(n,{fontFamily:e.fontFamily,fontSize:e.fontSize}),this._font(),this.drawingElement.options.set("font",n.font),t=!0),e.text&&(this.content(e.text),t=!0),!this._updateSize(e)&&t&&this._initSize())}}),P(m.fn,f),v=g.extend({init:function(e){g.fn.init.call(this,e),this._initPath(),this._setPosition()},_setPosition:function(){var e=this.options,t=e.x,n=e.y;(W(t)||W(n))&&this.position(t||0,n||0)},redraw:function(e){e&&(g.fn.redraw.call(this,e),this._diffNumericOptions(e,[Q,X])&&this._drawPath(),this._diffNumericOptions(e,[J,Z])&&this._setPosition())},_initPath:function(){var e=this.options;this.drawingElement=new U.Path({stroke:e.stroke,closed:!0}),this._fill(),this._drawPath()},_drawPath:function(){var e=this.drawingElement,t=i(this.options),n=t.width,r=t.height;e.segments.elements([s(0,0),s(n,0),s(n,r),s(0,r)])}}),_=g.extend({init:function(e){g.fn.init.call(this,e);var t=this.options.anchor;this.anchor=new V.Point(t.x,t.y),this.createElement()},options:{stroke:{color:q,width:0},fill:{color:"black"}},_transformToPath:function(e,t){var n=t.transform();return e&&n&&(e=e.transformCopy(n)),e},redraw:function(e){e&&(e.position&&(this.options.position=e.position),g.fn.redraw.call(this,e))}}),b=_.extend({options:{radius:4,anchor:{x:0,y:0}},createElement:function(){var e=this.options;this.drawingElement=new U.Circle(new V.Circle(this.anchor,e.radius),{fill:e.fill,stroke:e.stroke})},positionMarker:function(e){var t,n,i=this.options,r=i.position,o=e.segments;t=r==Y?o[0]:o[o.length-1],t&&(n=this._transformToPath(t.anchor(),e),this.drawingElement.transform(V.transform().translate(n.x,n.y)))}}),y=_.extend({options:{path:"M 0 0 L 10 5 L 0 10 L 3 5 z",anchor:{x:10,y:5}},createElement:function(){var e=this.options;this.drawingElement=U.Path.parse(e.path,{fill:e.fill,stroke:e.stroke})},positionMarker:function(e){var t,n,i=this._linePoints(e),r=i.start,o=i.end,s=V.transform();r&&s.rotate(a(r,o),o),o&&(t=this.anchor,n=o.clone().translate(-t.x,-t.y),s.translate(n.x,n.y)),this.drawingElement.transform(s)},_linePoints:function(e){var n,i,r,o,a,s=this.options,l=e.segments;return s.position==Y?(r=l[0],r&&(i=r.anchor(),n=r.controlOut(),o=l[1],!n&&o&&(n=o.anchor()))):(r=l[l.length-1],r&&(i=r.anchor(),n=r.controlIn(),a=l[l.length-2],!n&&a&&(n=a.anchor()))),i?{start:this._transformToPath(n,e),end:this._transformToPath(i,e)}:t}}),w={_getPath:function(e){var n=this.drawingElement;return n instanceof U.MultiPath&&(n=e==Y?n.paths[0]:n.paths[n.paths.length-1]),n&&n.segments.length?n:t},_normalizeMarkerOptions:function(e){var t=e.startCap,n=e.endCap;N(t)&&(e.startCap={type:t}),N(n)&&(e.endCap={type:n})},_removeMarker:function(e){var t=this._markers[e];t&&(this.drawingContainer().remove(t.drawingElement),delete this._markers[e])},_createMarkers:function(){var e=this.options;this._normalizeMarkerOptions(e),this._markers={},this._markers[Y]=this._createMarker(e.startCap,Y),this._markers[K]=this._createMarker(e.endCap,K)},_createMarker:function(e,n){var i,r,o=(e||{}).type,a=this._getPath(n);return a?(o==G.filledCircle?i=b:o==G.arrowStart||o==G.arrowEnd?i=y:this._removeMarker(n),i?(r=new i(P({},e,{position:n})),r.positionMarker(a),this.drawingContainer().append(r.drawingElement),r):t):(this._removeMarker(n),t)},_positionMarker:function(e){var t,n=this._markers[e];n&&(t=this._getPath(e),t?n.positionMarker(t):this._removeMarker(e))},_capMap:{start:"startCap",end:"endCap"},_redrawMarker:function(e,t,n){var i,r,o,a,s;return this._normalizeMarkerOptions(n),i=this.options,r=this._capMap[t],o=(i[r]||{}).type,a=n[r],s=!1,a?(i[r]=P({},i[r],a),a.type&&o!=a.type?(this._removeMarker(t),this._markers[t]=this._createMarker(i[r],t),s=!0):this._markers[t]&&this._markers[t].redraw(a)):e&&!this._markers[t]&&i[r]&&(this._markers[t]=this._createMarker(i[r],t),s=!0),s},_redrawMarkers:function(e,t){!this._redrawMarker(e,Y,t)&&e&&this._positionMarker(Y),!this._redrawMarker(e,K,t)&&e&&this._positionMarker(K)}},x=g.extend({init:function(e){g.fn.init.call(this,e),this.container=new U.Group,this._createElements(),this._initSize()},options:{autoSize:!0},drawingContainer:function(){return this.container},data:function(e){var n=this.options;return e?(n.data!=e&&(n.data=e,this._setData(e),this._initSize(),this._redrawMarkers(!0,{})),t):n.data},redraw:function(e){var t,n;e&&(g.fn.redraw.call(this,e),t=this.options,n=e.data,W(n)&&t.data!=n?(t.data=n,this._setData(n),this._updateSize(e)||this._initSize(),this._redrawMarkers(!0,e)):(this._updateSize(e),this._redrawMarkers(!1,e)))},_createElements:function(){var e=this.options;this.drawingElement=U.Path.parse(e.data||"",{stroke:e.stroke}),this._fill(),this.container.append(this.drawingElement),this._createMarkers()},_setData:function(e){var t=this.drawingElement,n=U.Path.parse(e||""),i=n.paths.slice(0);n.paths.elements([]),t.paths.elements(i)}}),P(x.fn,f),P(x.fn,w),k=g.extend({init:function(e){g.fn.init.call(this,e),this.container=new U.Group,this._initPath(),this._createMarkers()},drawingContainer:function(){return this.container},redraw:function(e){var t,n;e&&(e=e||{},t=e.from,n=e.to,t&&(this.options.from=t),n&&(this.options.to=n),t||n?(this._drawPath(),this._redrawMarkers(!0,e)):this._redrawMarkers(!1,e),g.fn.redraw.call(this,e))},_initPath:function(){var e=this.options,t=this.drawingElement=new U.Path({stroke:e.stroke});this._fill(),this._drawPath(),this.container.append(t)},_drawPath:function(){var e=this.options,t=this.drawingElement,n=e.from||new F,i=e.to||new F;t.segments.elements([s(n.x,n.y),s(i.x,i.y)])}}),P(k.fn,w),C=g.extend({init:function(e){g.fn.init.call(this,e),this.container=new U.Group,this._initPath(),this._createMarkers()},drawingContainer:function(){return this.container},points:function(e){var n=this.options;return e?(n.points=e,this._updatePath(),t):n.points},redraw:function(e){if(e){var t=e.points;g.fn.redraw.call(this,e),t&&this._pointsDiffer(t)?(this.points(t),this._redrawMarkers(!0,e)):this._redrawMarkers(!1,e)}},_initPath:function(){var e=this.options;this.drawingElement=new U.Path({stroke:e.stroke}),this._fill(),this.container.append(this.drawingElement),e.points&&this._updatePath()},_pointsDiffer:function(e){var t,n=this.options.points,i=n.length!==e.length;if(!i)for(t=0;e.length>t;t++)if(n[t].x!==e[t].x||n[t].y!==e[t].y){i=!0;break}return i},_updatePath:function(){var e,t,n=this.drawingElement,i=this.options,r=i.points,o=[];for(t=0;r.length>t;t++)e=r[t],o.push(s(e.x,e.y));n.segments.elements(o)},options:{points:[]}}),P(C.fn,w),S=p.extend({init:function(e){p.fn.init.call(this,e),this._initImage()},redraw:function(e){e&&(e.source&&this.drawingElement.src(e.source),this._diffNumericOptions(e,[Q,X,J,Z])&&this.drawingElement.rect(this._rect()),p.fn.redraw.call(this,e))},_initImage:function(){var e=this.options,t=this._rect();this.drawingElement=new U.Image(e.source,t,{})},_rect:function(){var e=i(this.options),t=new V.Point(e.x,e.y),n=new V.Size(e.width,e.height);return new V.Rect(t,n)}}),T=p.extend({init:function(e){this.children=[],p.fn.init.call(this,e),this.drawingElement=new U.Group,this._initSize()},options:{autoSize:!1},append:function(e){this.drawingElement.append(e.drawingContainer()),this.children.push(e),this._childrenChange=!0},remove:function(e){this._remove(e)&&(this._childrenChange=!0)},_remove:function(e){var n=j(e,this.children);return n>=0?(this.drawingElement.removeAt(n),this.children.splice(n,1),!0):t},clear:function(){this.drawingElement.clear(),this.children=[],this._childrenChange=!0},toFront:function(e){var t,n;for(n=0;e.length>n;n++)t=e[n],this._remove(t)&&this.append(t)},toBack:function(e){this._reorderChildren(e,0)},toIndex:function(e,t){this._reorderChildren(e,t)},_reorderChildren:function(e,t){var n,i,r,o,a,s=this.drawingElement,l=s.children.slice(0),c=this.children,u=H(t);for(n=0;e.length>n;n++)a=e[n],o=a.drawingContainer(),i=j(a,c),i>=0&&(l.splice(i,1),c.splice(i,1),r=u?t:t[n],l.splice(r,0,o),c.splice(r,0,a));s.clear(),s.append.apply(s,l)},redraw:function(e){e&&(this._childrenChange?(this._childrenChange=!1,this._updateSize(e)||this._initSize()):this._updateSize(e),p.fn.redraw.call(this,e))},_boundingBox:function(){var e,t,n,i,r=this.children;for(i=0;r.length>i;i++)t=r[i],t.visible()&&t._includeInBBox!==!1&&(n=t.drawingContainer().clippedBBox(null),n&&(e=e?B.union(e,n):n));return e}}),P(T.fn,f),D=T.extend({init:function(e,t){this.children=[],p.fn.init.call(this,t),this.drawingElement=new U.Layout(l(e),t),this._initSize()},rect:function(e){if(e)this.drawingElement.rect(l(e));else{var t=this.drawingElement.rect();if(t)return new B(t.origin.x,t.origin.y,t.size.width,t.size.height)}},reflow:function(){this.drawingElement.reflow()},redraw:function(e){E.deepExtend(this.drawingElement.options,e),T.fn.redraw.call(this,e)}}),A=g.extend({init:function(e){g.fn.init.call(this,e),this._initCircle(),this._initSize()},redraw:function(e){if(e){var t=this.options;e.center&&(P(t,{center:e.center}),this._center.move(t.center.x,t.center.y)),this._diffNumericOptions(e,["radius"])&&this._circle.setRadius(t.radius),this._updateSize(e),g.fn.redraw.call(this,e)}},_initCircle:function(){var e,t=this.options,n=t.width,i=t.height,r=t.radius;W(r)||(W(n)||(n=i),W(i)||(i=n),t.radius=r=Math.min(n,i)/2),e=t.center||{x:r,y:r},this._center=new V.Point(e.x,e.y),this._circle=new V.Circle(this._center,r),this.drawingElement=new U.Circle(this._circle,{stroke:t.stroke}),this._fill()}}),P(A.fn,f),M=R.extend({init:function(e,t){t=t||{},this.element=e,this.surface=U.Surface.create(e,t),E.isFunction(this.surface.translate)&&(this.translate=this._translate),this.drawingElement=new U.Group,this._viewBox=new B(0,0,t.width,t.height),this.size(this._viewBox)},bounds:function(){var e=this.drawingElement.clippedBBox();return new B(0,0,e.width(),e.height())},size:function(e){var t=this._viewBox;return W(e)&&(t.width=e.width,t.height=e.height,this.surface.setSize(e)),{width:t.width,height:t.height}},_translate:function(e,t){var n=this._viewBox;return W(e)&&W(t)&&(n.x=e,n.y=t,this.surface.translate({x:e,y:t})),{x:n.x,y:n.y}},draw:function(){this.surface.draw(this.drawingElement)},append:function(e){return this.drawingElement.append(e.drawingContainer()),this},remove:function(e){this.drawingElement.remove(e.drawingContainer())},insertBefore:function(){},clear:function(){this.drawingElement.clear()},destroy:function(t){this.surface.destroy(),t&&e(this.element).remove()}}),E.deepExtend(I,{init:function(e){E.init(e,I.ui)},diffNumericOptions:n,Element:p,Scale:c,Translation:u,Rotation:d,Circle:A,Group:T,Rectangle:v,Canvas:M,Path:x,Layout:D,Line:k,MarkerBase:_,ArrowMarker:y,CircleMarker:b,Polyline:C,CompositeTransform:h,TextBlock:m,Image:S,VisualBase:g})}(window.kendo.jQuery)}(),function(){!function(e,t){function n(e,t){e.isSelected?t.ctrlKey&&e.select(!1):e.diagram.select(e,{addToSelection:t.ctrlKey})}function i(e){return e.ctrlKey===!1&&e.altKey===!1&&e.shiftKey===!1}function r(e,t){var n=e!==!1;return e.key&&"none"!=e.key&&(n=t[e.key+"Key"]),n}function o(e,t){return t.charCodeAt(0)==e||t.toUpperCase().charCodeAt(0)==e}function a(e,t){var n;return-1==e.x&&-1==e.y?n=t.bottomRight():1==e.x&&1==e.y?n=t.topLeft():-1==e.x&&1==e.y?n=t.topRight():1==e.x&&-1==e.y?n=t.bottomLeft():0===e.x&&-1==e.y?n=t.bottom():0===e.x&&1==e.y?n=t.top():1==e.x&&0===e.y?n=t.left():-1==e.x&&0===e.y&&(n=t.right()),n}function s(e){var t=e.options.editable;return t&&t.drag!==!1}function l(e,t){var n,i,r,o;for(o=0;e.connectors.length>o;o++)if(n=e.connectors[o],i=n.position(),r=new G(i.x,i.y),r.inflate(ae,ae),r.contains(t))return n}var c,u,d,h,f,p,g,m,v,_,b,y,w,x,k,C,S,T,D,A,M,E,I,R,P,F,B,z,L,H,N,O,V=window.kendo,U=V.dataviz,W=U.diagram,j=V.Class,q=W.Group,G=W.Rect,$=W.Rectangle,Y=W.Utils,K=Y.isUndefined,Q=W.Point,X=W.Circle,J=W.Ticker,Z=V.deepExtend,ee=V.ui.Movable,te=V.support.browser,ne=V.util.defined,ie=e.inArray,re=e.proxy,oe={arrow:"default",grip:"pointer",cross:"pointer",add:"pointer",move:"move",select:"pointer",south:"s-resize",east:"e-resize",west:"w-resize",north:"n-resize",rowresize:"row-resize",colresize:"col-resize"},ae=10,se="Auto",le="Top",ce="Right",ue="Left",de="Bottom",he=10,fe=10,pe="dragStart",ge="drag",me="dragEnd",ve="itemRotate",_e="itemBoundsChange",be=5,ye=5,we="mouseEnter",xe="mouseLeave",ke="zoomStart",Ce="zoomEnd",Se=-2e4,Te=2e4,De=.9,Ae=.93,Me=5,Ee="transparent",Ie="pan",Re="rotated";W.Cursors=oe,c=V.Class.extend({init:function(e){this.layoutState=e,this.diagram=e.diagram},initState:function(){function e(e,t){var n=this.diagram.getShapeById(e);n&&(this.subjects.push(n),this.froms.push(n.bounds().topLeft()),this.tos.push(t.topLeft()))}this.froms=[],this.tos=[],this.subjects=[],this.layoutState.nodeMap.forEach(e,this)},update:function(e){if(!(0>=this.subjects.length))for(var t=0;this.subjects.length>t;t++)this.subjects[t].position(new Q(this.froms[t].x+(this.tos[t].x-this.froms[t].x)*e,this.froms[t].y+(this.tos[t].y-this.froms[t].y)*e))}}),u=j.extend({init:function(e,t,n){this.animate=K(n)?!1:n,this._initialState=e,this._finalState=t,this.title="Diagram layout"},undo:function(){this.setState(this._initialState)},redo:function(){this.setState(this._finalState)},setState:function(e){var t,n=e.diagram;this.animate?(e.linkMap.forEach(function(e,t){var i=n.getShapeById(e);i.visible(!1),i&&i.points(t)}),t=new J,t.addAdapter(new c(e)),t.onComplete(function(){e.linkMap.forEach(function(e){var t=n.getShapeById(e);t.visible(!0)})}),t.play()):(e.nodeMap.forEach(function(e,t){var i=n.getShapeById(e);i&&i.position(t.topLeft())}),e.linkMap.forEach(function(e,t){var i=n.getShapeById(e);i&&i.points(t)}))}}),d=j.extend({init:function(e){this.units=[],this.title="Composite unit",e!==t&&this.units.push(e)},add:function(e){this.units.push(e)},undo:function(){for(var e=0;this.units.length>e;e++)this.units[e].undo()},redo:function(){for(var e=0;this.units.length>e;e++)this.units[e].redo()}}),h=j.extend({init:function(e,t,n){this.item=e,this._redoSource=t,this._redoTarget=n,ne(t)&&(this._undoSource=e.source()),ne(n)&&(this._undoTarget=e.target()),this.title="Connection Editing"},undo:function(){this._undoSource!==t&&this.item._updateConnector(this._undoSource,"source"),this._undoTarget!==t&&this.item._updateConnector(this._undoTarget,"target"),this.item.updateModel()},redo:function(){this._redoSource!==t&&this.item._updateConnector(this._redoSource,"source"),this._redoTarget!==t&&this.item._updateConnector(this._redoTarget,"target"),this.item.updateModel()}}),f=j.extend({init:function(e,t,n){this.item=e,this._undoSource=t,this._undoTarget=n,this._redoSource=e.source(),this._redoTarget=e.target(),this.title="Connection Editing"},undo:function(){this.item._updateConnector(this._undoSource,"source"),this.item._updateConnector(this._undoTarget,"target"),this.item.updateModel()},redo:function(){this.item._updateConnector(this._redoSource,"source"),this.item._updateConnector(this._redoTarget,"target"),this.item.updateModel()}}),p=j.extend({init:function(e){this.connection=e,this.diagram=e.diagram,this.targetConnector=e.targetConnector,this.title="Delete connection"},undo:function(){this.diagram._addConnection(this.connection,!1)},redo:function(){this.diagram.remove(this.connection,!1)}}),g=j.extend({init:function(e){this.shape=e,this.diagram=e.diagram,this.title="Deletion"},undo:function(){this.diagram._addShape(this.shape,!1),this.shape.select(!1)},redo:function(){this.shape.select(!1),this.diagram.remove(this.shape,!1)}}),m=j.extend({init:function(e,t,n){var i,r;for(this.shapes=e,this.undoStates=t,this.title="Transformation",this.redoStates=[],this.adorner=n,i=0;this.shapes.length>i;i++)r=this.shapes[i],this.redoStates.push(r.bounds())},undo:function(){var e,t;for(e=0;this.shapes.length>e;e++)t=this.shapes[e],t.bounds(this.undoStates[e]),t.hasOwnProperty("layout")&&t.layout(t,this.redoStates[e],this.undoStates[e]),t.updateModel();this.adorner&&(this.adorner.refreshBounds(),this.adorner.refresh())},redo:function(){var e,t;for(e=0;this.shapes.length>e;e++)t=this.shapes[e],t.bounds(this.redoStates[e]),t.hasOwnProperty("layout")&&t.layout(t,this.undoStates[e],this.redoStates[e]),t.updateModel();this.adorner&&(this.adorner.refreshBounds(),this.adorner.refresh())}}),v=j.extend({init:function(e,t){this.connection=e,this.diagram=t,this.title="New connection"},undo:function(){this.diagram.remove(this.connection,!1)},redo:function(){this.diagram._addConnection(this.connection,!1)}}),_=j.extend({init:function(e,t){this.shape=e,this.diagram=t,this.title="New shape"},undo:function(){this.diagram.deselect(),this.diagram.remove(this.shape,!1)},redo:function(){this.diagram._addShape(this.shape,!1)}}),b=j.extend({init:function(e,t,n){this.initial=e,this.finalPos=t,this.diagram=n,this.title="Pan Unit"},undo:function(){this.diagram.pan(this.initial)},redo:function(){this.diagram.pan(this.finalPos)}}),y=j.extend({init:function(e,t,n){var i,r;for(this.shapes=t,this.undoRotates=n,this.title="Rotation",this.redoRotates=[],this.redoAngle=e._angle,this.adorner=e,this.center=e._innerBounds.center(),i=0;this.shapes.length>i;i++)r=this.shapes[i],this.redoRotates.push(r.rotate().angle)},undo:function(){var e,t;for(e=0;this.shapes.length>e;e++)t=this.shapes[e],t.rotate(this.undoRotates[e],this.center,!1),t.hasOwnProperty("layout")&&t.layout(t),t.updateModel();this.adorner&&(this.adorner._initialize(),this.adorner.refresh())},redo:function(){var e,t;for(e=0;this.shapes.length>e;e++)t=this.shapes[e],t.rotate(this.redoRotates[e],this.center,!1),t.hasOwnProperty("layout")&&t.layout(t),t.updateModel();this.adorner&&(this.adorner._initialize(),this.adorner.refresh())}}),w=j.extend({init:function(e,t,n){this.diagram=e,this.indices=n,this.items=t,this.title="Rotate Unit"},undo:function(){this.diagram._toIndex(this.items,this.indices)},redo:function(){this.diagram.toFront(this.items,!1)}}),x=j.extend({init:function(e,t,n){this.diagram=e,this.indices=n,this.items=t,this.title="Rotate Unit"},undo:function(){this.diagram._toIndex(this.items,this.indices)},redo:function(){this.diagram.toBack(this.items,!1)}}),k=V.Observable.extend({init:function(e){V.Observable.fn.init.call(this,e),this.bind(this.events,e),this.stack=[],this.index=0,this.capacity=100},events:["undone","redone"],begin:function(){this.composite=new d},cancel:function(){this.composite=t},commit:function(e){this.composite.units.length>0&&this._restart(this.composite,e),this.composite=t},addCompositeItem:function(e){this.composite?this.composite.add(e):this.add(e)},add:function(e,t){this._restart(e,t)},pop:function(){this.index>0&&(this.stack.pop(),this.index--)},count:function(){return this.stack.length},undo:function(){this.index>0&&(this.index--,this.stack[this.index].undo(),this.trigger("undone"))},redo:function(){this.stack.length>0&&this.stack.length>this.index&&(this.stack[this.index].redo(),this.index++,this.trigger("redone"))},_restart:function(e,t){this.stack.splice(this.index,this.stack.length-this.index),this.stack.push(e),t!==!1?this.redo():this.index++,this.stack.length>this.capacity&&(this.stack.splice(0,this.stack.length-this.capacity),this.index=this.capacity)},clear:function(){this.stack=[],this.index=0}}),C=j.extend({init:function(e){this.toolService=e},start:function(){},move:function(){},end:function(){},tryActivate:function(){return!1},getCursor:function(){return oe.arrow}}),S=C.extend({init:function(t){var n,i,r,o,a=this,s=V.support.mobileOS?Ae:De;C.fn.init.call(a,t),n=a.toolService.diagram,i=n.canvas,r=n.scroller=a.scroller=e(n.scrollable).kendoMobileScroller({friction:s,velocityMultiplier:Me,mousewheelScrolling:!1,zoom:!1,scroll:re(a._move,a)}).data("kendoMobileScroller"),i.translate&&(a.movableCanvas=new ee(i.element)),o=function(e,t,n){e.makeVirtual(),e.virtualSize(t||Se,n||Te)},o(r.dimensions.x),o(r.dimensions.y),r.disable()},tryActivate:function(e,t){var n=this.toolService,r=n.diagram.options.pannable,o=t.ctrlKey;return ne(r.key)&&(o=r.key&&"none"!=r.key?t[r.key+"Key"]&&!(t.ctrlKey&&ne(n.hoveredItem)):i(t)),
r!==!1&&o&&!ne(n.hoveredAdorner)&&!ne(n._hoveredConnector)},start:function(){this.scroller.enable()},move:function(){},_move:function(e){var t=this,n=t.toolService.diagram,i=n.canvas,r=new Q(e.scrollLeft,e.scrollTop);i.translate?(n._storePan(r.times(-1)),t.movableCanvas.moveTo(r),i.translate(r.x,r.y)):r=r.plus(n._pan.times(-1)),n.trigger(Ie,{pan:r})},end:function(){this.scroller.disable()},getCursor:function(){return oe.move}}),T=j.extend({init:function(e){this.toolService=e},tryActivate:function(){return!0},start:function(e,t){var i=this.toolService,o=i.diagram,a=i.hoveredItem,s=o.options.selectable;a&&(r(s,t)&&n(a,t),a.adorner&&(this.adorner=a.adorner,this.handle=this.adorner._hitTest(e))),this.handle||(this.handle=o._resizingAdorner._hitTest(e),this.handle&&(this.adorner=o._resizingAdorner)),this.adorner&&(this.adorner.isDragHandle(this.handle)&&o.trigger(pe,{shapes:this.adorner.shapes,connections:[]})?(i.startPoint=e,i.end(e)):this.adorner.start(e))},move:function(e){this.adorner&&(this.adorner.move(this.handle,e),this.adorner.isDragHandle(this.handle)&&this.toolService.diagram.trigger(ge,{shapes:this.adorner.shapes,connections:[]}))},end:function(e,n){var i,r=this.toolService.diagram,o=this.toolService,a=this.adorner;a&&(a.isDragHandle(this.handle)&&r.trigger(me,{shapes:a.shapes,connections:[]})?a.cancel():(i=a.stop(),i&&r.undoRedoService.add(i,!1))),o.hoveredItem&&this.toolService.triggerClick({item:o.hoveredItem,point:e,meta:n}),this.adorner=t,this.handle=t},getCursor:function(e){return this.toolService.hoveredItem?this.toolService.hoveredItem._getCursor(e):oe.arrow}}),D=j.extend({init:function(e){this.toolService=e},tryActivate:function(e,t){var n=this.toolService,i=r(n.diagram.options.selectable,t);return i&&!ne(n.hoveredItem)&&!ne(n.hoveredAdorner)},start:function(e){var t=this.toolService.diagram;t.deselect(),t.selector.start(e)},move:function(e){var t=this.toolService.diagram;t.selector.move(e)},end:function(e,t){var n=this.toolService.diagram,i=this.toolService.hoveredItem,r=n.selector.bounds();i&&i.isSelected||t.ctrlKey||n.deselect(),r.isEmpty()||n.selectArea(r),n.selector.end()},getCursor:function(){return oe.arrow}}),A=j.extend({init:function(e){this.toolService=e,this.type="ConnectionTool"},tryActivate:function(){return this.toolService._hoveredConnector},start:function(e,t){var i=this.toolService.diagram,r=this.toolService._hoveredConnector,o=i._createConnection({},r._c,e);s(o)&&!i.trigger(pe,{shapes:[],connections:[o]})&&i._addConnection(o)?(this.toolService._connectionManipulation(o,r._c.shape,!0),this.toolService._removeHover(),n(this.toolService.activeConnection,t)):(o.source(null),this.toolService.end(e))},move:function(e){var t=this.toolService,n=t.activeConnection;return n.target(e),t.diagram.trigger(ge,{shapes:[],connections:[n]}),!0},end:function(e){var t,n=this.toolService,i=n.diagram,r=n.activeConnection,o=n.hoveredItem,a=n._hoveredConnector;r&&(t=a&&a._c!=r.sourceConnector?a._c:o&&o instanceof W.Shape?o.getConnector(se)||o.getConnector(e):e,r.target(t),i.trigger(me,{shapes:[],connections:[r]})?(i.remove(r,!1),i.undoRedoService.pop()):(r.updateModel(),i._syncConnectionChanges()),n._connectionManipulation())},getCursor:function(){return oe.arrow}}),M=j.extend({init:function(e){this.toolService=e,this.type="ConnectionTool"},tryActivate:function(e,t){var n=this.toolService,i=n.diagram,o=i.options.selectable,a=n.hoveredItem,s=r(o,t)&&a&&a.path&&!(a.isSelected&&t.ctrlKey);return s&&(this._c=a),s},start:function(e,t){var i,r=this._c;n(r,t),i=r.adorner,s(r)&&i&&!this.toolService.diagram.trigger(pe,{shapes:[],connections:[r]})?(this.handle=i._hitTest(e),i.start(e)):(this.toolService.startPoint=e,this.toolService.end(e))},move:function(e){var n=this._c.adorner;return s(this._c)&&n?(n.move(this.handle,e),this.toolService.diagram.trigger(ge,{shapes:[],connections:[this._c]}),!0):t},end:function(e,t){var n,i=this._c,r=i.adorner,o=this.toolService,a=o.diagram;r&&(o.triggerClick({item:i,point:e,meta:t}),s(i)&&(n=r.stop(e),a.trigger(me,{shapes:[],connections:[i]})?n.undo():(a.undoRedoService.add(n,!1),i.updateModel(),a._syncConnectionChanges())))},getCursor:function(){return oe.move}}),E=j.extend({init:function(e){this.diagram=e,this.tools=[new S(this),new M(this),new A(this),new D(this),new T(this)],this.activeTool=t},start:function(e,t){return t=Z({},t),this.activeTool&&this.activeTool.end(e,t),this._updateHoveredItem(e),this._activateTool(e,t),this.activeTool.start(e,t),this._updateCursor(e),this.diagram.focus(),this.startPoint=e,!0},move:function(e,t){t=Z({},t);var n=!0;return this.activeTool&&(n=this.activeTool.move(e,t)),n&&this._updateHoveredItem(e),this._updateCursor(e),!0},end:function(e,n){return n=Z({},n),this.activeTool&&this.activeTool.end(e,n),this.activeTool=t,this._updateCursor(e),!0},keyDown:function(e,t){var n,i=this.diagram;if(t=Z({ctrlKey:!1,metaKey:!1,altKey:!1},t),!t.ctrlKey&&!t.metaKey||t.altKey){if(46===e||8===e)return n=this.diagram._triggerRemove(i.select()),n.length&&(this.diagram.remove(n,!0),this.diagram._syncChanges(),this.diagram._destroyToolBar()),!0;if(27===e)return this._discardNewConnection(),i.deselect(),i._destroyToolBar(),!0}else{if(o(e,"a"))return i.selectAll(),i._destroyToolBar(),!0;if(o(e,"z"))return i.undo(),i._destroyToolBar(),!0;if(o(e,"y"))return i.redo(),i._destroyToolBar(),!0;o(e,"c")?(i.copy(),i._destroyToolBar()):o(e,"x")?(i.cut(),i._destroyToolBar()):o(e,"v")?(i.paste(),i._destroyToolBar()):o(e,"l")?(i.layout(),i._destroyToolBar()):o(e,"d")&&(i._destroyToolBar(),i.copy(),i.paste())}},wheel:function(e,t){var n=this.diagram,i=t.delta,r=n.zoom(),o=n.options,a=o.zoomRate,s={point:e,meta:t,zoom:r};if(!n.trigger(ke,s))return 0>i?r+=a:r-=a,r=V.dataviz.round(Math.max(o.zoomMin,Math.min(o.zoomMax,r)),2),s.zoom=r,n.zoom(r,s),n.trigger(Ce,s),!0},setTool:function(e,t){e.toolService=this,this.tools[t]=e},triggerClick:function(e){this.startPoint.equals(e.point)&&this.diagram.trigger("click",e)},_discardNewConnection:function(){this.newConnection&&(this.diagram.remove(this.newConnection),this.newConnection=t)},_activateTool:function(e,t){var n,i;for(n=0;this.tools.length>n;n++)if(i=this.tools[n],i.tryActivate(e,t)){this.activeTool=i;break}},_updateCursor:function(e){var t=this.diagram.element,n=this.activeTool?this.activeTool.getCursor(e):this.hoveredAdorner?this.hoveredAdorner._getCursor(e):this.hoveredItem?this.hoveredItem._getCursor(e):oe.arrow;t.css({cursor:n}),te.msie&&7==te.version&&(t[0].style.cssText=t[0].style.cssText)},_connectionManipulation:function(e,n,i){this.activeConnection=e,this.disabledShape=n,this.newConnection=i?this.activeConnection:t},_updateHoveredItem:function(e){var n=this._hitTest(e),i=this.diagram;n==this.hoveredItem||this.disabledShape&&n==this.disabledShape||(this.hoveredItem&&(i.trigger(xe,{item:this.hoveredItem}),this.hoveredItem._hover(!1)),n&&n.options.enable?(i.trigger(we,{item:n}),this.hoveredItem=n,this.hoveredItem._hover(!0)):this.hoveredItem=t)},_removeHover:function(){this.hoveredItem&&(this.hoveredItem._hover(!1),this.hoveredItem=t)},_hitTest:function(e){var n,i,r,o,a=this.diagram;if(this._hoveredConnector&&(this._hoveredConnector._hover(!1),this._hoveredConnector=t),a._connectorsAdorner._visible&&(n=a._connectorsAdorner._hitTest(e)))return n;if(n=this.diagram._resizingAdorner._hitTest(e)){if(this.hoveredAdorner=a._resizingAdorner,0!==n.x||0!==n.y)return;n=t}else this.hoveredAdorner=t;if(!this.activeTool||"ConnectionTool"!==this.activeTool.type){for(o=[],r=0;a._selectedItems.length>r;r++)i=a._selectedItems[r],i instanceof W.Connection&&o.push(i);n=this._hitTestItems(o,e)}return n||this._hitTestElements(e)},_hitTestElements:function(e){var t,n,i,r,o=this.diagram,a=this._hitTestItems(o.shapes,e),s=this._hitTestItems(o.connections,e);return this.activeTool&&"ConnectionTool"==this.activeTool.type||!a||!s||l(a,e)||(n=o.mainLayer,i=ie(a.visual,n.children),r=ie(s.visual,n.children),t=i>r?a:s),t||a||s},_hitTestItems:function(e,t){var n,i,r;for(n=e.length-1;n>=0;n--)if(i=e[n],r=i._hitTest(t))return r}}),I=V.Class.extend({init:function(){}}),R=I.extend({init:function(e){var t=this;I.fn.init.call(t),this.connection=e},hitTest:function(e){var t=this.getBounds().inflate(ae);return t.contains(e)?W.Geometry.distanceToPolyline(e,this.connection.allPoints())e;++e)r=Math.max(r,t[e].x),o=Math.min(o,t[e].x),a=Math.min(a,t[e].y),s=Math.max(s,t[e].y);return new G(o,a,r-o,s-a)}}),P=R.extend({init:function(e){var t=this;R.fn.init.call(t),this.connection=e},route:function(){}}),F=R.extend({SAME_SIDE_DISTANCE_RATIO:5,init:function(e){var t=this;R.fn.init.call(t),this.connection=e},routePoints:function(e,t,n,i){var r;return r=n&&i?this._connectorPoints(e,t,n,i):this._floatingPoints(e,t,n)},route:function(){var e=this.connection._resolvedSourceConnector,t=this.connection._resolvedTargetConnector,n=this.connection.sourcePoint(),i=this.connection.targetPoint(),r=this.routePoints(n,i,e,t);this.connection.points(r)},_connectorSides:[{name:"Top",axis:"y",boundsPoint:"topLeft",secondarySign:1},{name:"Left",axis:"x",boundsPoint:"topLeft",secondarySign:1},{name:"Bottom",axis:"y",boundsPoint:"bottomRight",secondarySign:-1},{name:"Right",axis:"x",boundsPoint:"bottomRight",secondarySign:-1}],_connectorSide:function(e,t){var n,i,r,o,a,s=e.position(),l=e.shape.bounds(Re),c={topLeft:l.topLeft(),bottomRight:l.bottomRight()},u=this._connectorSides,d=V.util.MAX_NUM;for(a=0;u.length>a;a++)o=u[a],r=o.axis,n=Math.round(Math.abs(s[r]-c[o.boundsPoint][r])),d>n?(d=n,i=o):n===d&&(s[r]-t[r])*o.secondarySign>(s[i.axis]-t[i.axis])*i.secondarySign&&(i=o);return i.name},_sameSideDistance:function(e){var t=e.shape.bounds(Re);return Math.min(t.width,t.height)/this.SAME_SIDE_DISTANCE_RATIO},_connectorPoints:function(e,t,n,i){var r,o,a=this._connectorSide(n,t),s=this._connectorSide(i,e),l=t.x-e.x,c=t.y-e.y,u=this._sameSideDistance(n),d=[];return a===le||a==de?s==le||s==de?a==s?(o=a==le?Math.min(e.y,t.y)-u:Math.max(e.y,t.y)+u,d=[new Q(e.x,o),new Q(t.x,o)]):d=[new Q(e.x,e.y+c/2),new Q(t.x,e.y+c/2)]:d=[new Q(e.x,t.y)]:s==ue||s==ce?a==s?(r=a==ue?Math.min(e.x,t.x)-u:Math.max(e.x,t.x)+u,d=[new Q(r,e.y),new Q(r,t.y)]):d=[new Q(e.x+l/2,e.y),new Q(e.x+l/2,e.y+c)]:d=[new Q(t.x,e.y)],d},_floatingPoints:function(e,t,n){var i,r,o,a=n?this._connectorSide(n,t):null,s=this._startHorizontal(e,t,a),l=[e,e,t,t],c=t.x-e.x,u=t.y-e.y,d=l.length;for(o=1;d-1>o;++o)s?o%2!==0?(i=c/(d/2),r=0):(i=0,r=u/((d-1)/2)):o%2!==0?(i=0,r=u/(d/2)):(i=c/((d-1)/2),r=0),l[o]=new Q(l[o-1].x+i,l[o-1].y+r);return o--,l[d-2]=s&&o%2!==0||!s&&o%2===0?new Q(l[d-1].x,l[d-2].y):new Q(l[d-2].x,l[d-1].y),[l[1],l[2]]},_startHorizontal:function(e,t,n){var i;return i=null===n||n!==ce&&n!==ue?Math.abs(e.x-t.x)>Math.abs(e.y-t.y):!0}}),B=j.extend({init:function(e,t){var n=this;n.diagram=e,n.options=Z({},n.options,t),n.visual=new q,n.diagram._adorners.push(n)},refresh:function(){}}),z=B.extend({init:function(e,t){var n,i,r,o=this;o.connection=e,n=o.connection.diagram,o._ts=n.toolService,B.fn.init.call(o,n,t),i=o.connection.sourcePoint(),r=o.connection.targetPoint(),o.spVisual=new X(Z(o.options.handles,{center:i})),o.epVisual=new X(Z(o.options.handles,{center:r})),o.visual.append(o.spVisual),o.visual.append(o.epVisual)},options:{handles:{}},_getCursor:function(){return oe.move},start:function(e){switch(this.handle=this._hitTest(e),this.startPoint=e,this._initialSource=this.connection.source(),this._initialTarget=this.connection.target(),this.handle){case-1:this.connection.targetConnector&&this._ts._connectionManipulation(this.connection,this.connection.targetConnector.shape);break;case 1:this.connection.sourceConnector&&this._ts._connectionManipulation(this.connection,this.connection.sourceConnector.shape)}},move:function(e,t){switch(e){case-1:this.connection.source(t);break;case 1:this.connection.target(t);break;default:var n=t.minus(this.startPoint);this.startPoint=t,this.connection.sourceConnector||this.connection.source(this.connection.sourcePoint().plus(n)),this.connection.targetConnector||this.connection.target(this.connection.targetPoint().plus(n))}return this.refresh(),!0},stop:function(e){var n,i=this.diagram.toolService,r=i.hoveredItem;return n=i._hoveredConnector?i._hoveredConnector._c:r&&r instanceof W.Shape?r.getConnector(se)||r.getConnector(e):e,-1===this.handle?this.connection.source(n):1===this.handle&&this.connection.target(n),this.handle=t,this._ts._connectionManipulation(),new f(this.connection,this._initialSource,this._initialTarget)},_hitTest:function(e){var t=this.connection.sourcePoint(),n=this.connection.targetPoint(),i=this.options.handles.width/2,r=this.options.handles.height/2,o=new G(t.x,t.y).inflate(i,r),a=new G(n.x,n.y).inflate(i,r);return o.contains(e)?-1:a.contains(e)?1:0},refresh:function(){this.spVisual.redraw({center:this.diagram.modelToLayer(this.connection.sourcePoint())}),this.epVisual.redraw({center:this.diagram.modelToLayer(this.connection.targetPoint())})}}),L=B.extend({init:function(e,t){var n=this;B.fn.init.call(n,e,t),n._refreshHandler=function(e){e.item==n.shape&&n.refresh()}},show:function(e){var t,n,i,r=this;for(r._visible=!0,r.shape=e,r.diagram.bind(_e,r._refreshHandler),t=e.connectors.length,r.connectors=[],r.visual.clear(),n=0;t>n;n++)i=new O(e.connectors[n]),r.connectors.push(i),r.visual.append(i.visual);r.visual.visible(!0),r.refresh()},destroy:function(){var e=this;e.diagram.unbind(_e,e._refreshHandler),e.shape=t,e._visible=t,e.visual.visible(!1)},_hitTest:function(e){var t,n;for(n=0;this.connectors.length>n;n++)if(t=this.connectors[n],t._hitTest(e)){t._hover(!0),this.diagram.toolService._hoveredConnector=t;break}},refresh:function(){if(this.shape){var t=this.shape.bounds();t=this.diagram.modelToLayer(t),this.visual.position(t.topLeft()),e.each(this.connectors,function(){this.refresh()})}}}),H=B.extend({init:function(e,t){var n=this;B.fn.init.call(n,e,t),n._manipulating=!1,n.map=[],n.shapes=[],n._initSelection(),n._createHandles(),n.redraw(),n.diagram.bind("select",function(e){n._initialize(e.selected)}),n._refreshHandler=function(){n._internalChange||(n.refreshBounds(),n.refresh())},n._rotatedHandler=function(){1==n.shapes.length&&(n._angle=n.shapes[0].rotate().angle),n._refreshHandler()},n.diagram.bind(_e,n._refreshHandler).bind(ve,n._rotatedHandler),n.refreshBounds(),n.refresh()},options:{handles:{fill:{color:"#fff"},stroke:{color:"#282828"},height:7,width:7,hover:{fill:{color:"#282828"},stroke:{color:"#282828"}}},selectable:{stroke:{color:"#778899",width:1,dashType:"dash"},fill:{color:Ee}},offset:10},_initSelection:function(){var e=this,t=e.diagram,n=t.options.selectable,i=Z({},e.options.selectable,n);e.rect=new $(i),e.visual.append(e.rect)},_resizable:function(){return this.options.editable&&this.options.editable.resize!==!1},_handleOptions:function(){return(this.options.editable.resize||{}).handles||this.options.handles},_createHandles:function(){var e,t,n,i;if(this._resizable())for(e=this._handleOptions(),i=-1;1>=i;i++)for(n=-1;1>=n;n++)(0!==i||0!==n)&&(t=new $(e),t.drawingElement._hover=re(this._hover,this),this.map.push({x:i,y:n,visual:t}),this.visual.append(t))},bounds:function(e){return e?(this._innerBounds=e.clone(),this._bounds=this.diagram.modelToLayer(e).inflate(this.options.offset,this.options.offset),t):this._bounds},_hitTest:function(e){var n,i,r,o,a=this.diagram.modelToLayer(e),s=this.map.length;if(this._angle&&(a=a.clone().rotate(this._bounds.center(),this._angle)),this._resizable())for(n=0;s>n;n++)if(o=this.map[n],i=new Q(o.x,o.y),r=this._getHandleBounds(i),r.offset(this._bounds.x,this._bounds.y),r.contains(a))return i;return this._bounds.contains(a)?new Q(0,0):t},_getHandleBounds:function(e){if(this._resizable()){var t=this._handleOptions(),n=t.width,i=t.height,r=new G(0,0,n,i);return 0>e.x?r.x=-n/2:0===e.x?r.x=Math.floor(this._bounds.width/2)-n/2:e.x>0&&(r.x=this._bounds.width+1-n/2),0>e.y?r.y=-i/2:0===e.y?r.y=Math.floor(this._bounds.height/2)-i/2:e.y>0&&(r.y=this._bounds.height+1-i/2),r}},_getCursor:function(e){var t,n=this._hitTest(e);if(n&&n.x>=-1&&1>=n.x&&n.y>=-1&&1>=n.y&&this._resizable()){if(t=this._angle,t&&(t=360-t,n.rotate(new Q(0,0),t),n=new Q(Math.round(n.x),Math.round(n.y))),-1==n.x&&-1==n.y)return"nw-resize";if(1==n.x&&1==n.y)return"se-resize";if(-1==n.x&&1==n.y)return"sw-resize";if(1==n.x&&-1==n.y)return"ne-resize";if(0===n.x&&-1==n.y)return"n-resize";if(0===n.x&&1==n.y)return"s-resize";if(1==n.x&&0===n.y)return"e-resize";if(-1==n.x&&0===n.y)return"w-resize"}return this._manipulating?oe.move:oe.select},_initialize:function(){var e,t,n=this,i=n.diagram.select();for(n.shapes=[],e=0;i.length>e;e++)t=i[e],t instanceof W.Shape&&(n.shapes.push(t),t._rotationOffset=new Q);n._angle=1==n.shapes.length?n.shapes[0].rotate().angle:0,n._startAngle=n._angle,n._rotates(),n._positions(),n.refreshBounds(),n.refresh(),n.redraw()},_rotates:function(){var e,t,n=this;for(n.initialRotates=[],e=0;n.shapes.length>e;e++)t=n.shapes[e],n.initialRotates.push(t.rotate().angle)},_positions:function(){var e,t,n=this;for(n.initialStates=[],e=0;n.shapes.length>e;e++)t=n.shapes[e],n.initialStates.push(t.bounds())},_hover:function(e,t){if(this._resizable()){var n=this._handleOptions(),i=n.hover,r=n.stroke,o=n.fill;e&&Y.isDefined(i.stroke)&&(r=Z({},r,i.stroke)),e&&Y.isDefined(i.fill)&&(o=i.fill),t.stroke(r.color,r.width,r.opacity),t.fill(o.color,o.opacity)}},start:function(e){var t,n;for(this._sp=e,this._cp=e,this._lp=e,this._manipulating=!0,this._internalChange=!0,this.shapeStates=[],t=0;this.shapes.length>t;t++)n=this.shapes[t],this.shapeStates.push(n.bounds())},redraw:function(){var e,t,n=this._resizable();for(e=0;this.map.length>e;e++)t=this.map[e],t.visual.visible(n)},angle:function(e){return ne(e)&&(this._angle=e),this._angle},rotate:function(){var e,t,n=this._innerBounds.center(),i=this.angle();for(this._internalChange=!0,e=0;this.shapes.length>e;e++)t=this.shapes[e],i=(i+this.initialRotates[e]-this._startAngle)%360,t.rotate(i,n);this.refresh()},move:function(e,n){var i,r,o,l,c,u,d,h,f,p,g,m,v,_,b=new Q,y=new Q,w=0;if(-2===e.y&&-1===e.x){for(l=this._innerBounds.center(),this._angle=this._truncateAngle(Y.findAngle(l,n)),u=0;this.shapes.length>u;u++)c=this.shapes[u],d=(this._angle+this.initialRotates[u]-this._startAngle)%360,c.rotate(d,l),c.hasOwnProperty("layout")&&c.layout(c),this._rotating=!0;this.refresh()}else{if(this.shouldSnap()){if(m=this._truncateDistance(n.minus(this._lp)),0===m.x&&0===m.y)return this._cp=n,t;i=m,this._lp=new Q(this._lp.x+m.x,this._lp.y+m.y)}else i=n.minus(this._cp);for(this.isDragHandle(e)?(y=b=i,r=!0):(this._angle&&i.rotate(new Q(0,0),this._angle),-1==e.x?b.x=i.x:1==e.x&&(y.x=i.x),-1==e.y?b.y=i.y:1==e.y&&(y.y=i.y)),r||(f=a(e,this._innerBounds),p=(this._innerBounds.width+i.x*e.x)/this._innerBounds.width,g=(this._innerBounds.height+i.y*e.y)/this._innerBounds.height),u=0;this.shapes.length>u;u++){if(c=this.shapes[u],o=c.bounds(),r){if(!s(c))continue;h=this._displaceBounds(o,b,y,r)}else h=o.clone(),h.scale(p,g,f,this._innerBounds.center(),c.rotate().angle),v=h.center(),v.rotate(o.center(),-this._angle),h=new G(v.x-h.width/2,v.y-h.height/2,h.width,h.height);h.width>=c.options.minWidth&&h.height>=c.options.minHeight&&(_=o,c.bounds(h),c.hasOwnProperty("layout")&&c.layout(c,_,h),(_.width!==h.width||_.height!==h.height)&&c.rotate(c.rotate().angle),w+=1)}w&&(w==u?(h=this._displaceBounds(this._innerBounds,b,y,r),this.bounds(h)):this.refreshBounds(),this.refresh()),this._positions()}this._cp=n},isDragHandle:function(e){return 0===e.x&&0===e.y},cancel:function(){var e,n=this.shapes,i=this.shapeStates;for(e=0;n.length>e;e++)n[e].bounds(i[e]);this.refreshBounds(),this.refresh(),this._manipulating=t,this._internalChange=t,this._rotating=t},_truncatePositionToGuides:function(e){return this.diagram.ruler?this.diagram.ruler.truncatePositionToGuides(e):e},_truncateSizeToGuides:function(e){return this.diagram.ruler?this.diagram.ruler.truncateSizeToGuides(e):e},_truncateAngle:function(e){var t=this.snapOptions(),n=Math.max(t.angle||fe,ye);return t?Math.floor(e%360/n)*n:e%360},_truncateDistance:function(e){var t,n;return e instanceof W.Point?new W.Point(this._truncateDistance(e.x),this._truncateDistance(e.y)):(t=this.snapOptions()||{},n=Math.max(t.size||he,be),t?Math.floor(e/n)*n:e)},snapOptions:function(){var e=this.diagram.options.editable,t=((e||{}).drag||{}).snap||{};return t},shouldSnap:function(){var e=this.diagram.options.editable,t=(e||{}).drag,n=(t||{}).snap;return e!==!1&&t!==!1&&n!==!1},_displaceBounds:function(e,t,n,i){var r,o=e.topLeft().plus(t),a=e.bottomRight().plus(n),s=G.fromPoints(o,a);return i||(r=s.center(),r.rotate(e.center(),-this._angle),s=new G(r.x-s.width/2,r.y-s.height/2,s.width,s.height)),s},stop:function(){var e,n,i,r;if(this._cp!=this._sp)if(this._rotating)e=new y(this,this.shapes,this.initialRotates),this._rotating=!1;else if(this._diffStates()){if(this.diagram.ruler)for(n=0;this.shapes.length>n;n++)i=this.shapes[n],r=i.bounds(),r=this._truncateSizeToGuides(this._truncatePositionToGuides(r)),i.bounds(r),this.refreshBounds(),this.refresh();for(n=0;this.shapes.length>n;n++)i=this.shapes[n],i.updateModel();e=new m(this.shapes,this.shapeStates,this),this.diagram._syncShapeChanges()}return this._manipulating=t,this._internalChange=t,this._rotating=t,e},_diffStates:function(){var e,t=this.shapes,n=this.shapeStates;for(e=0;t.length>e;e++)if(!t[e].bounds().equals(n[e]))return!0;return!1},refreshBounds:function(){var e=1==this.shapes.length?this.shapes[0].bounds().clone():this.diagram.boundingBox(this.shapes,!0);this.bounds(e)},refresh:function(){var t,n,i,r,o=this;this.shapes.length>0?(n=this.bounds(),this.visual.visible(!0),this.visual.position(n.topLeft()),e.each(this.map,function(){t=o._getHandleBounds(new Q(this.x,this.y)),this.visual.position(t.topLeft())}),this.visual.position(n.topLeft()),i=new Q(n.width/2,n.height/2),this.visual.rotate(this._angle,i),this.rect.redraw({width:n.width,height:n.height}),this.rotationThumb&&(r=this.options.editable.rotate.thumb,this._rotationThumbBounds=new G(n.center().x,n.y+r.y,0,0).inflate(r.width),this.rotationThumb.redraw({x:n.width/2-r.width/2}))):this.visual.visible(!1)}}),N=j.extend({init:function(e){var t=e.options.selectable;this.options=Z({},this.options,t),this.visual=new $(this.options),this.diagram=e},options:{stroke:{color:"#778899",width:1,dashType:"dash"},fill:{color:Ee}},start:function(e){this._sp=this._ep=e,this.refresh(),this.diagram._adorn(this,!0)},end:function(){this._sp=this._ep=t,this.diagram._adorn(this,!1)},bounds:function(e){return e&&(this._bounds=e),this._bounds},move:function(e){this._ep=e,this.refresh()},refresh:function(){if(this._sp){var e=G.fromPoints(this.diagram.modelToLayer(this._sp),this.diagram.modelToLayer(this._ep));this.bounds(G.fromPoints(this._sp,this._ep)),this.visual.position(e.topLeft()),this.visual.redraw({height:e.height+1,width:e.width+1})}}}),O=j.extend({init:function(e){this.options=Z({},e.options),this._c=e,this.visual=new X(this.options),this.refresh()},_hover:function(e){var t=this.options,n=t.hover,i=t.stroke,r=t.fill;e&&Y.isDefined(n.stroke)&&(i=Z({},i,n.stroke)),e&&Y.isDefined(n.fill)&&(r=n.fill),this.visual.redraw({stroke:i,fill:r})},refresh:function(){var e=this._c.shape.diagram.modelToView(this._c.position()),t=e.minus(this._c.shape.bounds("transformed").topLeft()),n=new G(e.x,e.y,0,0);n.inflate(this.options.width/2,this.options.height/2),this._visualBounds=n,this.visual.redraw({center:new Q(t.x,t.y)})},_hitTest:function(e){var t=this._c.shape.diagram.modelToView(e);return this._visualBounds.contains(t)}}),Z(W,{CompositeUnit:d,TransformUnit:m,PanUndoUnit:b,AddShapeUnit:_,AddConnectionUnit:v,DeleteShapeUnit:g,DeleteConnectionUnit:p,ConnectionEditAdorner:z,ConnectionTool:A,ConnectorVisual:O,UndoRedoService:k,ResizingAdorner:H,Selector:N,ToolService:E,ConnectorsAdorner:L,LayoutUndoUnit:u,ConnectionEditUnit:h,ToFrontUnit:w,ToBackUnit:x,ConnectionRouterBase:I,PolylineRouter:P,CascadingRouter:F,SelectionTool:D,ScrollerTool:S,PointerTool:T,ConnectionEditTool:M,RotateUnit:y})}(window.kendo.jQuery)}(),function(){!function(e){var t=window.kendo,n=t.dataviz.diagram,i=n.Graph,r=n.Node,o=n.Link,a=t.deepExtend,s=n.Size,l=n.Rect,c=n.Dictionary,u=n.Set,d=n.Graph,h=n.Utils,f=n.Point,p=1e-6,g=Math.PI/180,m=h.contains,v=e.grep,_=t.Class.extend({defaultOptions:{type:"Tree",subtype:"Down",roots:null,animate:!1,limitToView:!1,friction:.9,nodeDistance:50,iterations:300,horizontalSeparation:90,verticalSeparation:50,underneathVerticalTopOffset:15,underneathHorizontalOffset:15,underneathVerticalSeparation:15,grid:{width:1500,offsetX:50,offsetY:50,componentSpacingX:20,componentSpacingY:20},layerSeparation:50,layeredIterations:2,startRadialAngle:0,endRadialAngle:360,radialSeparation:150,radialFirstLevelSeparation:200,keepComponentsInOneRadialLayout:!1,ignoreContainers:!0,layoutContainerChildren:!1,ignoreInvisible:!0,animateTransitions:!1},init:function(){},gridLayoutComponents:function(e){var t,n,i,r,o,a,s,l,c,u,d,p,g,m,v;if(!e)throw"No components supplied.";for(h.forEach(e,function(e){e.calcBounds()}),e.sort(function(e,t){return t.bounds.width-e.bounds.width}),t=this.options.grid.width,n=this.options.grid.componentSpacingX,i=this.options.grid.componentSpacingY,r=0,o=this.options.grid.offsetX,a=this.options.grid.offsetY,s=o,l=a,u=[],d=[];e.length>0;){for(s>=t&&(s=o,l+=r+i,r=0),p=e.pop(),this.moveToOffset(p,new f(s,l)),c=0;p.nodes.length>c;c++)d.push(p.nodes[c]);for(c=0;p.links.length>c;c++)u.push(p.links[c]);g=p.bounds,m=g.height,(0>=m||isNaN(m))&&(m=0),v=g.width,(0>=v||isNaN(v))&&(v=0),m>=r&&(r=m),s+=v+n}return{nodes:d,links:u}},moveToOffset:function(e,t){var n,i,r,o,a,s,c,u,d=e.bounds,h=t.x-d.x,p=t.y-d.y;for(n=0;e.nodes.length>n;n++)r=e.nodes[n],o=r.bounds(),0===o.width&&0===o.height&&0===o.x&&0===o.y&&(o=new l(0,0,0,0)),o.x+=h,o.y+=p,r.bounds(o);for(n=0;e.links.length>n;n++)if(a=e.links[n],a.points){for(s=[],c=a.points,i=0;c.length>i;i++)u=c[i],u.x+=h,u.y+=p,s.push(u);a.points=s}return this.currentHorizontalOffset+=d.width+this.options.grid.offsetX,new f(h,p)},transferOptions:function(e){this.options=t.deepExtend({},this.defaultOptions),h.isUndefined(e)||(this.options=t.deepExtend(this.options,e||{}))}}),b=t.Class.extend({init:function(e){this.nodeMap=new c,this.shapeMap=new c,this.nodes=[],this.edges=[],this.edgeMap=new c,this.finalNodes=[],this.finalLinks=[],this.ignoredConnections=[],this.ignoredShapes=[],this.hyperMap=new c,this.hyperTree=new i,this.finalGraph=null,this.diagram=e},convert:function(e){if(h.isUndefined(this.diagram))throw"No diagram to convert.";return this.options=t.deepExtend({ignoreInvisible:!0,ignoreContainers:!0,layoutContainerChildren:!1},e||{}),this.clear(),this._renormalizeShapes(),this._renormalizeConnections(),this.finalNodes=new c(this.nodes),this.finalLinks=new c(this.edges),this.finalGraph=new i,this.finalNodes.forEach(function(e){this.finalGraph.addNode(e)},this),this.finalLinks.forEach(function(e){this.finalGraph.addExistingLink(e)},this),this.finalGraph},mapConnection:function(e){return this.edgeMap.get(e.id)},mapShape:function(e){return this.nodeMap.get(e.id)},getEdge:function(e,t){return h.first(e.links,function(n){return n.getComplement(e)===t})},clear:function(){this.finalGraph=null,this.hyperTree=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new d:null,this.hyperMap=!this.options.ignoreContainers&&this.options.layoutContainerChildren?new c:null,this.nodeMap=new c,this.shapeMap=new c,this.nodes=[],this.edges=[],this.edgeMap=new c,this.ignoredConnections=[],this.ignoredShapes=[],this.finalNodes=[],this.finalLinks=[]},listToRoot:function(e){var t=[],n=e.container;if(!n)return t;for(t.push(n);n.parentContainer;)n=n.parentContainer,t.push(n);return t.reverse(),t},firstNonIgnorableContainer:function(e){return e.isContainer&&!this._isIgnorableItem(e)?e:e.parentContainer?this.firstNonIgnorableContainer(e.parentContainer):null},isContainerConnection:function(e,t){return e.isContainer&&this.isDescendantOf(e,t)?!0:t.isContainer&&this.isDescendantOf(t,e)},isDescendantOf:function(e,t){var n,i,r,o;if(!e.isContainer)throw"Expecting a container.";if(e===t)return!1;if(m(e.children,t))return!0;for(n=[],i=0,r=e.children.length;r>i;i++)o=e.children[i],o.isContainer&&this.isDescendantOf(o,t)&&n.push(o);return n.length>0},isIgnorableItem:function(e){return this.options.ignoreInvisible?e.isCollapsed&&this._isVisible(e)?!1:!e.isCollapsed&&this._isVisible(e)?!1:!0:e.isCollapsed&&!this._isTop(e)},isShapeMapped:function(e){return e.isCollapsed&&!this._isVisible(e)&&!this._isTop(e)},leastCommonAncestor:function(e,t){var n,i,r,o,a,s;if(!e)throw"Parameter should not be null.";if(!t)throw"Parameter should not be null.";if(!this.hyperTree)throw"No hypertree available.";if(n=this.listToRoot(e),i=this.listToRoot(t),r=null,h.isEmpty(n)||h.isEmpty(i))return this.hyperTree.root.data;for(o=n[0],a=i[0],s=0;o===a&&(r=n[s],s++,!(s>=n.length||s>=i.length));)o=n[s],a=i[s];return r?v(this.hyperTree.nodes,function(e){return e.data.container===r}):this.hyperTree.root.data},_isTop:function(e){return!e.parentContainer},_isVisible:function(e){return e.visible()?e.parentContainer?this._isVisible(e.parentContainer):e.visible():!1},_isCollapsed:function(e){return e.isContainer&&e.isCollapsed?!0:e.parentContainer&&this._isCollapsed(e.parentContainer)},_renormalizeShapes:function(){var e,t,n,i;if(!this.options.ignoreContainers)throw"Containers are not supported yet, but stay tuned.";for(e=0,t=this.diagram.shapes.length;t>e;e++)n=this.diagram.shapes[e],this.options.ignoreInvisible&&!this._isVisible(n)||n.isContainer?this.ignoredShapes.push(n):(i=new r(n.id,n),i.isVirtual=!1,this.nodeMap.add(n.id,i),this.nodes.push(i))},_renormalizeConnections:function(){var e,t,n,i,r,a,s,l;if(0!==this.diagram.connections.length)for(e=0,t=this.diagram.connections.length;t>e;e++)if(n=this.diagram.connections[e],this.isIgnorableItem(n))this.ignoredConnections.push(n);else if(i=n.sourceConnector?n.sourceConnector.shape:null,r=n.targetConnector?n.targetConnector.shape:null,i&&r)if(!m(this.ignoredShapes,i)||this.shapeMap.containsKey(i))if(!m(this.ignoredShapes,r)||this.shapeMap.containsKey(r))if(this.shapeMap.containsKey(i)&&(i=this.shapeMap[i]),this.shapeMap.containsKey(r)&&(r=this.shapeMap[r]),a=this.mapShape(i),s=this.mapShape(r),a===s||this.areConnectedAlready(a,s))this.ignoredConnections.push(n);else{if(null===a||null===s)throw"A shape was not mapped to a node.";if(!this.options.ignoreContainers)throw"Containers are not supported yet, but stay tuned.";a.isVirtual||s.isVirtual?this.ignoredConnections.push(n):(l=new o(a,s,n.id,n),this.edgeMap.add(n.id,l),this.edges.push(l))}else this.ignoredConnections.push(n);else this.ignoredConnections.push(n);else this.ignoredConnections.push(n)},areConnectedAlready:function(e,t){return h.any(this.edges,function(n){return n.source===e&&n.target===t||n.source===t&&n.target===e})}}),y=_.extend({init:function(e){var t=this;if(_.fn.init.call(t),h.isUndefined(e))throw"Diagram is not specified.";this.diagram=e},layout:function(e){var t,i,r,o,a,s;if(this.transferOptions(e),t=new b(this.diagram),i=t.convert(e),!i.isEmpty()&&(r=i.getConnectedComponents(),!h.isEmpty(r))){for(o=0;r.length>o;o++)a=r[o],this.layoutGraph(a,e);return s=this.gridLayoutComponents(r),new n.LayoutState(this.diagram,s)}},layoutGraph:function(e,t){var n,i,r;for(h.isDefined(t)&&this.transferOptions(t),this.graph=e,n=9*this.options.nodeDistance,this.temperature=n,i=this._expectedBounds(),this.width=i.width,this.height=i.height,r=0;this.options.iterations>r;r++)this.refineStage=r>=5*this.options.iterations/6,this.tick(),this.temperature=this.refineStage?n/30:n*(1-r/(2*this.options.iterations))},tick:function(){var e,t,n;for(e=0;this.graph.nodes.length>e;e++)this._repulsion(this.graph.nodes[e]);for(e=0;this.graph.links.length>e;e++)this._attraction(this.graph.links[e]);for(e=0;this.graph.nodes.length>e;e++){
if(t=this.graph.nodes[e],n=Math.sqrt(t.dx*t.dx+t.dy*t.dy),0===n)return;t.x+=Math.min(n,this.temperature)*t.dx/n,t.y+=Math.min(n,this.temperature)*t.dy/n,this.options.limitToView&&(t.x=Math.min(this.width,Math.max(t.width/2,t.x)),t.y=Math.min(this.height,Math.max(t.height/2,t.y)))}},_shake:function(e){var t=Math.random()*this.options.nodeDistance/4,n=2*Math.random()*Math.PI;e.x+=t*Math.cos(n),e.y-=t*Math.sin(n)},_InverseSquareForce:function(e,t,n){var i,r,o,a,s,l,c;return this.refineStage?(r=t.x-n.x,o=t.y-n.y,a=t.width/2,s=t.height/2,l=n.width/2,c=n.height/2,i=Math.pow(r,2)/Math.pow(a+l+this.options.nodeDistance,2)+Math.pow(o,2)/Math.pow(s+c+this.options.nodeDistance,2)):i=Math.pow(e,2)/Math.pow(this.options.nodeDistance,2),4*i/3},_SquareForce:function(e,t,n){return 1/this._InverseSquareForce(e,t,n)},_repulsion:function(e){e.dx=0,e.dy=0,h.forEach(this.graph.nodes,function(t){var n,i,r,o;if(t!==e){for(;e.x===t.x&&e.y===t.y;)this._shake(t);n=e.x-t.x,i=e.y-t.y,r=Math.sqrt(n*n+i*i),o=2*this._SquareForce(r,e,t),e.dx+=n/r*o,e.dy+=i/r*o}},this)},_attraction:function(e){var t,n,i,r,o,a,s=e.target,l=e.source;if(l!==s){for(;l.x===s.x&&l.y===s.y;)this._shake(s);t=l.x-s.x,n=l.y-s.y,i=Math.sqrt(t*t+n*n),r=5*this._InverseSquareForce(i,l,s),o=t/i*r,a=n/i*r,s.dx+=o,s.dy+=a,l.dx-=o,l.dy-=a}},_expectedBounds:function(){var e,t,n,i,r,o=this.graph.nodes.length,a=1.5,s=4;return 0===o?e:(e=h.fold(this.graph.nodes,function(e,t){var n=t.width*t.height;return n>0?e+=Math.sqrt(n):0},0,this),t=e/o,n=t*Math.ceil(Math.sqrt(o)),i=n*Math.sqrt(a),r=n/Math.sqrt(a),{width:i*s,height:r*s})}}),w=t.Class.extend({init:function(e){this.center=null,this.options=e},layout:function(e,t){if(this.graph=e,this.graph.nodes&&0!==this.graph.nodes.length){if(!m(this.graph.nodes,t))throw"The given root is not in the graph.";this.center=t,this.graph.cacheRelationships(),this.layoutSwitch()}},layoutLeft:function(e){var t,n,i,r,o,a,l,c;for(this.setChildrenDirection(this.center,"Left",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,n=0,r=0;e.length>r;r++)o=e[r],o.TreeDirection="Left",a=this.measure(o,s.Empty),n=Math.max(n,a.Width),t+=a.height+this.options.verticalSeparation;for(t-=this.options.verticalSeparation,l=this.center.x-this.options.horizontalSeparation,i=this.center.y+(this.center.height-t)/2,r=0;e.length>r;r++)o=e[r],c=new f(l-o.Size.width,i),this.arrange(o,c),i+=o.Size.height+this.options.verticalSeparation},layoutRight:function(e){var t,n,i,r,o,a,l,c;for(this.setChildrenDirection(this.center,"Right",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,n=0,r=0;e.length>r;r++)o=e[r],o.TreeDirection="Right",a=this.measure(o,s.Empty),n=Math.max(n,a.Width),t+=a.height+this.options.verticalSeparation;for(t-=this.options.verticalSeparation,l=this.center.x+this.options.horizontalSeparation+this.center.width,i=this.center.y+(this.center.height-t)/2,r=0;e.length>r;r++)o=e[r],c=new f(l,i),this.arrange(o,c),i+=o.Size.height+this.options.verticalSeparation},layoutUp:function(e){var t,n,i,r,o,a,l;for(this.setChildrenDirection(this.center,"Up",!1),this.setChildrenLayout(this.center,"Default",!1),t=0,r=0;e.length>r;r++)i=e[r],i.TreeDirection="Up",o=this.measure(i,s.Empty),t+=o.width+this.options.horizontalSeparation;for(t-=this.options.horizontalSeparation,a=this.center.x+this.center.width/2-t/2,r=0;e.length>r;r++)i=e[r],n=this.center.y-this.options.verticalSeparation-i.Size.height,l=new f(a,n),this.arrange(i,l),a+=i.Size.width+this.options.horizontalSeparation},layoutDown:function(e){var t,n,i,r,o,a,l;for(this.setChildrenDirection(this.center,"Down",!1),this.setChildrenLayout(this.center,"Default",!1),i=0,n=0;e.length>n;n++)t=e[n],t.treeDirection="Down",o=this.measure(t,s.Empty),i+=o.width+this.options.horizontalSeparation;for(i-=this.options.horizontalSeparation,a=this.center.x+this.center.width/2-i/2,r=this.center.y+this.options.verticalSeparation+this.center.height,n=0;e.length>n;n++)t=e[n],l=new f(a,r),this.arrange(t,l),a+=t.Size.width+this.options.horizontalSeparation},layoutRadialTree:function(){var e,t;if(this.setChildrenDirection(this.center,"Radial",!1),this.setChildrenLayout(this.center,"Default",!1),this.previousRoot=null,e=this.options.startRadialAngle*g,t=this.options.endRadialAngle*g,e>=t)throw"Final angle should not be less than the start angle.";this.maxDepth=0,this.origin=new f(this.center.x,this.center.y),this.calculateAngularWidth(this.center,0),this.maxDepth>0&&this.radialLayout(this.center,this.options.radialFirstLevelSeparation,e,t),this.center.Angle=t-e},tipOverTree:function(e,t){var n,i,r,o,a,l,c;for(h.isUndefined(t)&&(t=0),this.setChildrenDirection(this.center,"Down",!1),this.setChildrenLayout(this.center,"Default",!1),this.setChildrenLayout(this.center,"Underneath",!1,t),n=0,o=0;e.length>o;o++)r=e[o],r.TreeDirection="Down",a=this.measure(r,s.Empty),n+=a.width+this.options.horizontalSeparation;for(n-=this.options.horizontalSeparation,n-=e[e.length-1].width,n+=e[e.length-1].associatedShape.bounds().width,l=this.center.x+this.center.width/2-n/2,i=this.center.y+this.options.verticalSeparation+this.center.height,o=0;e.length>o;o++)r=e[o],c=new f(l,i),this.arrange(r,c),l+=r.Size.width+this.options.horizontalSeparation},calculateAngularWidth:function(e,t){var n,i,r,o,a,s,l;if(t>this.maxDepth&&(this.maxDepth=t),n=0,i=1e3,r=1e3,o=0===t?0:Math.sqrt(i*i+r*r)/t,e.children.length>0){for(a=0,s=e.children.length;s>a;a++)l=e.children[a],n+=this.calculateAngularWidth(l,t+1);n=Math.max(o,n)}else n=o;return e.sectorAngle=n,n},sortChildren:function(e){var t,n,i,r,o,a,s,l,c,u,d,p=0;if(e.parents.length>1)throw"Node is not part of a tree.";if(n=e.parents[0],n&&(i=new f(n.x,n.y),r=new f(e.x,e.y),p=this.normalizeAngle(Math.atan2(i.y-r.y,i.x-r.x))),o=e.children.length,0===o)return null;for(a=[],s=[],t=0;o>t;++t)l=e.children[t],c=new f(l.x,l.y),s[t]=t,a[t]=this.normalizeAngle(-p+Math.atan2(c.y-c.y,c.x-c.x));for(h.bisort(a,s),u=[],d=e.children,t=0;o>t;++t)u.push(d[s[t]]);return u},normalizeAngle:function(e){for(;e>2*Math.PI;)e-=2*Math.PI;for(;0>e;)e+=2*Math.PI;return e},radialLayout:function(e,t,n,i){var r,o,a,s,l,c=i-n,u=c/2,d=e.sectorAngle,h=0,f=this.sortChildren(e);for(r=0,o=f.length;o>r;r++)a=f[r],s=a,l=s.sectorAngle/d,a.children.length>0&&this.radialLayout(a,t+this.options.radialSeparation,n+h*c,n+(h+l)*c),this.setPolarLocation(a,t,n+h*c+l*u),s.angle=l*c,h+=l},setPolarLocation:function(e,t,n){e.x=this.origin.x+t*Math.cos(n),e.y=this.origin.y+t*Math.sin(n),e.BoundingRectangle=new l(e.x,e.y,e.width,e.height)},setChildrenDirection:function(e,t,n){var i=e.treeDirection;this.graph.depthFirstTraversal(e,function(e){e.treeDirection=t}),n||(e.treeDirection=i)},setChildrenLayout:function(e,t,n,i){h.isUndefined(i)&&(i=0);var r=e.childrenLayout;i>0?(this.graph.assignLevels(e),this.graph.depthFirstTraversal(e,function(e){e.level>=i+1&&(e.childrenLayout=t)})):(this.graph.depthFirstTraversal(e,function(e){e.childrenLayout=t}),n||(e.childrenLayout=r))},measure:function(e,t){var n,i,r,o,a,l,c,u=0,d=0,f=new s(0,0);if(!e)throw"";if(i=e.associatedShape.bounds(),r=i.width,o=i.height,1!==e.parents.length)throw"Node not in a spanning tree.";if(a=e.parents[0],"Undefined"===e.treeDirection&&(e.treeDirection=a.treeDirection),h.isEmpty(e.children))f=new s(Math.abs(r)
l;l++)c=e.children[l],n=this.measure(c,t),u=Math.max(u,n.width+this.options.underneathHorizontalOffset),d+=n.height+this.options.underneathVerticalSeparation;d-=this.options.underneathVerticalSeparation;break;case"Default":for(u=r,d=0,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),u=Math.max(u,r+this.options.horizontalSeparation+n.width),d+=n.height+this.options.verticalSeparation;d-=this.options.verticalSeparation;break;default:throw"Unhandled TreeDirection in the Right layout measuring."}break;case"Up":case"Down":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(u=r,d=o+this.options.underneathVerticalTopOffset,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),u=Math.max(u,n.width+this.options.underneathHorizontalOffset),d+=n.height+this.options.underneathVerticalSeparation;d-=this.options.underneathVerticalSeparation;break;case"Default":for(u=0,d=0,l=0;e.children.length>l;l++)c=e.children[l],n=this.measure(c,t),u+=n.width+this.options.horizontalSeparation,d=Math.max(d,n.height+this.options.verticalSeparation+o);u-=this.options.horizontalSeparation;break;default:throw"Unhandled TreeDirection in the Down layout measuring."}break;default:throw"Unhandled TreeDirection in the layout measuring."}f=new s(u,d)}return e.SectorAngle=Math.sqrt(u*u/4+d*d/4),e.Size=f,f},arrange:function(e,t){var n,i,r,o,a,s,c,u,d=e.associatedShape.bounds(),g=d.width,m=d.height;if(h.isEmpty(e.children))e.x=t.x,e.y=t.y,e.BoundingRectangle=new l(t.x,t.y,g,m);else switch(e.treeDirection){case"Left":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(u=t,e.x=u.x,e.y=u.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),c=t.y+m+this.options.underneathVerticalTopOffset,n=0;o.children.length>n;n++)o=o.children[n],s=u.x-o.associatedShape.width-this.options.underneathHorizontalOffset,i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.underneathVerticalSeparation;break;case"Default":for(u=new f(t.x+e.Size.width-g,t.y+(e.Size.height-m)/2),e.x=u.x,e.y=u.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=u.x-this.options.horizontalSeparation,c=t.y,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s-o.Size.width,c),this.arrange(o,i),c+=o.Size.height+this.options.verticalSeparation;break;default:throw"Unsupported TreeDirection"}break;case"Right":switch(e.childrenLayout){case"TopAlignedWithParent":case"BottomAlignedWithParent":break;case"Underneath":for(u=t,e.x=u.x,e.y=u.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=t.x+g+this.options.underneathHorizontalOffset,c=t.y+m+this.options.underneathVerticalTopOffset,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.underneathVerticalSeparation;break;case"Default":for(u=new f(t.x,t.y+(e.Size.height-m)/2),e.x=u.x,e.y=u.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),s=t.x+g+this.options.horizontalSeparation,c=t.y,n=0;e.children.length>n;n++)o=e.children[n],i=new f(s,c),this.arrange(o,i),c+=o.Size.height+this.options.verticalSeparation;break;default:throw"Unsupported TreeDirection"}break;case"Up":if(u=new f(t.x+(e.Size.width-g)/2,t.y+e.Size.height-m),e.x=u.x,e.y=u.y,e.BoundingRectangle=new l(e.x,e.y,e.width,e.height),Math.abs(u.x-t.x)