@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 206 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kendo.data.js"),require("kendo.draganddrop.js"),require("kendo.userevents.js"),require("kendo.mobile.scroller.js"),require("kendo.core.js"),require("kendo.dataviz.core.js"),require("kendo.drawing.js"),require("kendo.toolbar.js"),require("kendo.editable.js"),require("kendo.window.js"),require("kendo.dropdownlist.js"),require("kendo.dataviz.themes.js"),require("kendo.html.button.js")):"function"==typeof define&&define.amd?define(["exports","kendo.data","kendo.draganddrop","kendo.userevents","kendo.mobile.scroller","kendo.core.min","kendo.dataviz.core","kendo.drawing","kendo.toolbar","kendo.editable","kendo.window","kendo.dropdownlist","kendo.dataviz.themes","kendo.html.button"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).kendo=t.kendo||{},t.kendo._globals=t.kendo._globals||{},t.kendo._globals.DatavizDiagram={}))}(this,(function(t){!function(t){var e=window.kendo,i=e.dataviz.diagram={},n=e.deepExtend,o=Array.isArray,s={};n(s,{isNearZero:function(t){return Math.abs(t)<1e-6},isDefined:function(t){return void 0!==t},isUndefined:function(t){return null==t},isObject:function(t){return t===Object(t)},has:function(t,e){return Object.hasOwnProperty.call(t,e)},isString:function(t){return"[object String]"==Object.prototype.toString.call(t)},isBoolean:function(t){return"[object Boolean]"==Object.prototype.toString.call(t)},isType:function(t,e){return Object.prototype.toString.call(t)=="[object "+e+"]"},isNumber:function(t){return!isNaN(parseFloat(t))&&isFinite(t)},isEmpty:function(t){if(null===t)return!0;if(o(t)||s.isString(t))return 0===t.length;for(var e in t)if(s.has(t,e))return!1;return!0},simpleExtend:function(t,e){if(s.isObject(e))for(var i in e)t[i]=e[i]},initArray:function(t,e){for(var i=[],n=0;n<t;++n)i[n]=e;return i},serializePoints:function(t){for(var e=[],i=0;i<t.length;i++){var n=t[i];e.push(n.x+";"+n.y)}return e.join(";")},deserializePoints:function(t){var e=t.split(";"),n=[];if(e.length%2!=0)throw"Not an array of points.";for(var o=0;o<e.length;o+=2)n.push(new i.Point(parseInt(e[o],10),parseInt(e[o+1],10)));return n},randomInteger:function(t,e){return parseInt(Math.floor(Math.random()*e)+t,10)},DFT:function(t,e){if(e(t),t.childNodes)for(var i=0;i<t.childNodes.length;i++){var n=t.childNodes[i];this.DFT(n,e)}},getMatrixAngle:function(t){return null===t||0===t.d?0:180*Math.atan2(t.b,t.d)/Math.PI},getMatrixScaling:function(t){return[Math.sqrt(t.a*t.a+t.c*t.c),Math.sqrt(t.b*t.b+t.d*t.d)]}}),s.sign=function(t){return t?t<0?-1:1:0},s.findAngle=function(t,e){return 180*function(t,e){if(t==e)return 0;var i=e.x-t.x,n=t.y-e.y,o=Math.atan(i/n);return n>=0?i<0?o+2*Math.PI:o:o+Math.PI}(t,e)/Math.PI},s.forEach=function(t,e,i){for(var n=0;n<t.length;n++)e.call(i,t[n],n,t)},s.any=function(t,e){for(var i=0;i<t.length;++i)if(e(t[i]))return t[i];return null},s.remove=function(t,e){for(var i;-1!==(i=s.indexOf(t,e));)t.splice(i,1);return t},s.contains=function(t,e){return-1!==s.indexOf(t,e)},s.indexOf=function(e,i){return t.inArray(i,e)},s.fold=function(t,e,i,n){for(var o=arguments.length>2,s=0;s<t.length;s++){var r=t[s];o?i=e.call(n,i,r,s,t):(i=r,o=!0)}if(!o)throw"Reduce of empty array with no initial value";return i},s.find=function(t,e,i){var n;return s.any(t,(function(t,o,s){return!!e.call(i,t,o,s)&&(n=t,!0)})),n},s.first=function(t,e,i){return 0===t.length?null:s.isUndefined(e)?t[0]:s.find(t,e,i)},s.insert=function(t,e,i){return t.splice(i,0,e),t},s.all=function(t,e,i){for(var n,o=!0,s=0;s<t.length&&(n=t[s],o=o&&e.call(i,n,s,t));s++);return o},s.clear=function(t){t.splice(0,t.length)},s.bisort=function(t,e,i){if(s.isUndefined(t))throw"First array is not specified.";if(s.isUndefined(e))throw"Second array is not specified.";if(t.length!=e.length)throw"The two arrays should have equal length";var n,o=[];for(n=0;n<t.length;n++)o.push({x:t[n],y:e[n]});for(s.isUndefined(i)?o.sort((function(t,e){return t.x-e.x})):o.sort((function(t,e){return i(t.x,e.x)})),s.clear(t),s.clear(e),n=0;n<o.length;n++)t.push(o[n].x),e.push(o[n].y)},s.addRange=function(t,e){t.push.apply(t,e)};var r=function(t){return-Math.cos(t*Math.PI)/2+.5},a=e.Class.extend({init:function(){this.adapters=[],this.target=0,this.tick=0,this.interval=20,this.duration=800,this.lastTime=null,this.handlers=[];var t=this;this.transition=r,this.timerDelegate=function(){t.onTimerEvent()}},addAdapter:function(t){this.adapters.push(t)},onComplete:function(t){this.handlers.push(t)},removeHandler:function(e){this.handlers=t.grep(this.handlers,(function(t){return t!==e}))},trigger:function(){var t=this;this.handlers&&s.forEach(this.handlers,(function(e){return e.call(null!==t.caller?t.caller:t)}))},onStep:function(){},seekTo:function(t){this.seekFromTo(this.tick,t)},seekFromTo:function(t,e){this.target=Math.max(0,Math.min(1,e)),this.tick=Math.max(0,Math.min(1,t)),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(t){0!==this.adapters.length&&(null!==t&&(this.caller=t),this.initState(),this.seekFromTo(0,1))},reverse:function(){this.seekFromTo(1,0)},initState:function(){if(0!==this.adapters.length)for(var t=0;t<this.adapters.length;t++)this.adapters[t].initState()},propagate:function(){for(var t=this.transition(this.tick),e=0;e<this.adapters.length;e++)this.adapters[e].update(t)},onTimerEvent:function(){var t=(new Date).getTime(),e=t-this.lastTime;this.lastTime=t;var i=e/this.duration*(this.tick<this.target?1:-1);Math.abs(i)>=Math.abs(this.tick-this.target)?this.tick=this.target:this.tick+=i;try{this.propagate()}finally{this.onStep.call(this),this.target==this.tick&&this.stop()}}});e.deepExtend(i,{init:function(t){e.init(t,i.ui)},Utils:s,Range:function(t,e,i){if(void 0===t||void 0===e)return[];if(i&&s.sign(e-t)!=s.sign(i))throw"The sign of the increment should allow to reach the stop-value.";if(t=t||0,((e=e||t)-t)/(i=i||1)==1/0)throw"Infinite range defined.";var n,o=[],r=-1,a=function(t){for(var e=1;t*e%1;)e*=10;return e}(Math.abs(i));if(i*=a,(t*=a)>(e*=a)&&i>0&&(i=-i),i<0)for(;(n=t+i*++r)>=e;)o.push(n/a);else for(;(n=t+i*++r)<=e;)o.push(n/a);return o},Ticker:a})}(window.kendo.jQuery),function(t){var e=window.kendo,i=e.dataviz.diagram,n=e.Class,o=e.deepExtend,s=i.Utils,r=e.geometry.Point,a=e.isFunction,h=s.contains,c=t.map;class d extends r{constructor(t,e){super(t,e)}clone(){return new d(this.x,this.y)}plus(t){return new d(this.x+t.x,this.y+t.y)}minus(t){return new d(this.x-t.x,this.y-t.y)}offset(t){return new d(this.x-t,this.y-t)}times(t){return new d(this.x*t,this.y*t)}normalize(){return 0===this.length()?new d:this.times(1/this.length())}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}toString(){return"("+this.x+","+this.y+")"}lengthSquared(){return this.x*this.x+this.y*this.y}middleOf(t,e){return new d(e.x-t.x,e.y-t.y).times(.5).plus(t)}toPolar(t){var e=1;t&&(e=180/Math.PI);var i=Math.atan2(Math.abs(this.y),Math.abs(this.x)),n=Math.PI/2,o=this.length();if(0===this.x){if(0===this.y)return new v(0,0);if(this.y>0)return new v(o,e*n);if(this.y<0)return new v(o,3*e*n)}else if(this.x>0){if(0===this.y)return new v(o,0);if(this.y>0)return new v(o,e*i);if(this.y<0)return new v(o,e*(4*n-i))}else{if(0===this.y)return new v(o,2*n);if(this.y>0)return new v(o,e*(2*n-i));if(this.y<0)return new v(o,e*(2*n+i))}}isOnLine(t,e){if(t.x>e.x){var i=e;e=t,t=i}var n,o,s=new u(t.x,t.y).inflate(3,3),r=new u(e.x,e.y).inflate(3,3);return!!s.union(r).contains(this)&&(t.x===e.x||t.y===e.y||(t.y<e.y?(n=s.x+(r.x-s.x)*(this.y-(s.y+s.height))/(r.y+r.height-(s.y+s.height)),o=s.x+s.width+(r.x+r.width-(s.x+s.width))*(this.y-s.y)/(r.y-s.y)):(n=s.x+(r.x-s.x)*(this.y-s.y)/(r.y-s.y),o=s.x+s.width+(r.x+r.width-(s.x+s.width))*(this.y-(s.y+s.height))/(r.y+r.height-(s.y+s.height))),this.x>n&&this.x<o))}parse(t){var e=t.slice(1,t.length-1).split(","),i=parseInt(e[0],10),n=parseInt(e[1],10);if(!isNaN(i)&&!isNaN(n))return new d(i,n)}}var l=n.extend({init:function(t,e,i){this.point=t,this.left=e,this.right=i}}),u=n.extend({init:function(t,e,i,n){this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0},contains:function(t){return t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},inflate:function(t,e){return undefined===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t+1,this.height+=2*e+1,this},offset:function(t,e){var i=t,n=e;return t instanceof d&&(i=t.x,n=t.y),this.x+=i,this.y+=n,this},union:function(t){var e=Math.min(this.x,t.x),i=Math.min(this.y,t.y),n=Math.max(this.x+this.width,t.x+t.width),o=Math.max(this.y+this.height,t.y+t.height);return new u(e,i,n-e,o-i)},center:function(){return new d(this.x+this.width/2,this.y+this.height/2)},top:function(){return new d(this.x+this.width/2,this.y)},right:function(){return new d(this.x+this.width,this.y+this.height/2)},bottom:function(){return new d(this.x+this.width/2,this.y+this.height)},left:function(){return new d(this.x,this.y+this.height/2)},topLeft:function(){return new d(this.x,this.y)},topRight:function(){return new d(this.x+this.width,this.y)},bottomLeft:function(){return new d(this.x,this.y+this.height)},bottomRight:function(){return new d(this.x+this.width,this.y+this.height)},clone:function(){return new u(this.x,this.y,this.width,this.height)},isEmpty:function(){return!this.width&&!this.height},equals:function(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},rotatedBounds:function(t){var e=this.clone(),i=this.rotatedPoints(t),n=i[0],o=i[1],s=i[2],r=i[3];return e.x=Math.min(s.x,n.x,o.x,r.x),e.y=Math.min(s.y,n.y,o.y,r.y),e.width=Math.max(s.x,n.x,o.x,r.x)-e.x,e.height=Math.max(s.y,n.y,o.y,r.y)-e.y,e},rotatedPoints:function(t){var e=this,i=e.center(),n=e.bottomRight().rotate(t,i);return[e.topLeft().rotate(t,i),e.topRight().rotate(t,i),n,e.bottomLeft().rotate(t,i)]},toString:function(t){return t=t||" ",this.x+t+this.y+t+this.width+t+this.height},scale:function(t,e,i,n,o){var s=this.topLeft(),r=this.center();s.rotate(o,r).rotate(o,n);var a=i.minus(s),h=new d(a.x*t,a.y*e),c=a.minus(h);(s=s.plus(c)).rotate(o,n).rotate(o,r),this.x=s.x,this.y=s.y,this.width*=t,this.height*=e},zoom:function(t){return this.x*=t,this.y*=t,this.width*=t,this.height*=t,this},overlaps:function(t){var e=this.bottomRight(),i=t.bottomRight();return!(e.x<t.x||e.y<t.y||i.x<this.x||i.y<this.y)}}),f=n.extend({init:function(t,e){this.width=t,this.height=e}});function p(t,e,i,n,o){var s=(e.x-t.x)*(n.y-i.y)-(e.y-t.y)*(n.x-i.x);if(r=s,!(Math.abs(r)<1e-6)){var r,a=((t.y-i.y)*(n.x-i.x)-(t.x-i.x)*(n.y-i.y))/s,h=((t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y))/s;if(!o||!(a<0||a>1||h<0||h>1))return new d(t.x+a*(e.x-t.x),t.y+a*(e.y-t.y))}}f.prototype.Empty=new f(0,0),u.toRect=function(t){return t instanceof u||(t=new u(t.x,t.y,t.width,t.height)),t},u.empty=function(){return new u(0,0,0,0)},u.fromPoints=function(t,e){if(isNaN(t.x)||isNaN(t.y)||isNaN(e.x)||isNaN(e.y))throw"Some values are NaN.";return new u(Math.min(t.x,e.x),Math.min(t.y,e.y),Math.abs(t.x-e.x),Math.abs(t.y-e.y))};var g={lines:function(t,e,i,n){return p(t,e,i,n)},segments:function(t,e,i,n){return p(t,e,i,n,!0)},rectWithLine:function(t,e,i){return g.segments(e,i,t.topLeft(),t.topRight())||g.segments(e,i,t.topRight(),t.bottomRight())||g.segments(e,i,t.bottomLeft(),t.bottomRight())||g.segments(e,i,t.topLeft(),t.bottomLeft())},rects:function(t,e,i){var n=e.topLeft(),o=e.topRight(),s=e.bottomLeft(),r=e.bottomRight(),a=e.center();i&&(n=n.rotate(i,a),o=o.rotate(i,a),s=s.rotate(i,a),r=r.rotate(i,a));var h=t.contains(n)||t.contains(o)||t.contains(s)||t.contains(r)||g.rectWithLine(t,n,o)||g.rectWithLine(t,n,s)||g.rectWithLine(t,o,r)||g.rectWithLine(t,s,r);if(!h){if(n=t.topLeft(),o=t.topRight(),s=t.bottomLeft(),r=t.bottomRight(),i){var c=360-i;n=n.rotate(c,a),o=o.rotate(c,a),s=s.rotate(c,a),r=r.rotate(c,a)}h=e.contains(n)||e.contains(o)||e.contains(s)||e.contains(r)}return h}},m=n.extend({init:function(t){this.container=u.toRect(t)},align:function(t,e){for(var i=e.toLowerCase().split(" "),n=0;n<i.length;n++)t=this._singleAlign(t,i[n]);return t},_singleAlign:function(t,e){return a(this[e])?this[e](t):t},left:function(t){return this._align(t,this._left)},center:function(t){return this._align(t,this._center)},right:function(t){return this._align(t,this._right)},stretch:function(t){return this._align(t,this._stretch)},top:function(t){return this._align(t,this._top)},middle:function(t){return this._align(t,this._middle)},bottom:function(t){return this._align(t,this._bottom)},_left:function(t,e){e.x=t.x},_center:function(t,e){e.x=(t.width-e.width)/2||0},_right:function(t,e){e.x=t.width-e.width},_top:function(t,e){e.y=t.y},_middle:function(t,e){e.y=(t.height-e.height)/2||0},_bottom:function(t,e){e.y=t.height-e.height},_stretch:function(t,e){e.x=0,e.y=0,e.height=t.height,e.width=t.width},_align:function(t,e){return t=u.toRect(t),e(this.container,t),t}}),v=n.extend({init:function(t,e){this.r=t,this.angle=e}}),_=n.extend({init:function(t,e,i,n,o,s){this.a=t||0,this.b=e||0,this.c=i||0,this.d=n||0,this.e=o||0,this.f=s||0},plus:function(t){this.a+=t.a,this.b+=t.b,this.c+=t.c,this.d+=t.d,this.e+=t.e,this.f+=t.f},minus:function(t){this.a-=t.a,this.b-=t.b,this.c-=t.c,this.d-=t.d,this.e-=t.e,this.f-=t.f},times:function(t){return new _(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.e+this.c*t.f+this.e,this.b*t.e+this.d*t.f+this.f)},apply:function(t){return new d(this.a*t.x+this.c*t.y+this.e,this.b*t.x+this.d*t.y+this.f)},applyRect:function(t){return u.fromPoints(this.apply(t.topLeft()),this.apply(t.bottomRight()))},toString:function(){return"matrix("+this.a+" "+this.b+" "+this.c+" "+this.d+" "+this.e+" "+this.f+")"}});o(_,{fromSVGMatrix:function(t){var e=new _;return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.e=t.e,e.f=t.f,e},fromMatrixVector:function(t){var e=new _;return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.e=t.e,e.f=t.f,e},fromList:function(t){if(6!==t.length)throw"The given list should consist of six elements.";var e=new _;return e.a=t[0],e.b=t[1],e.c=t[2],e.d=t[3],e.e=t[4],e.f=t[5],e},translation:function(t,e){var i=new _;return i.a=1,i.b=0,i.c=0,i.d=1,i.e=t,i.f=e,i},unit:function(){return new _(1,0,0,1,0,0)},rotation:function(t,e,i){var n=new _;return n.a=Math.cos(t*Math.PI/180),n.b=Math.sin(t*Math.PI/180),n.c=-n.b,n.d=n.a,n.e=e-e*n.a+i*n.b||0,n.f=i-i*n.a-e*n.b||0,n},scaling:function(t,e){var i=new _;return i.a=t,i.b=0,i.c=0,i.d=e,i.e=0,i.f=0,i},parse:function(t){var e,i;if(t){if("matrix"===(t=t.trim()).slice(0,6).toLowerCase()){if(6===(e=(i=t.slice(7,t.length-1).trim()).split(",")).length)return _.fromList(c(e,(function(t){return parseFloat(t)})));if(6===(e=i.split(" ")).length)return _.fromList(c(e,(function(t){return parseFloat(t)})))}if("("===t.slice(0,1)&&")"===t.slice(t.length-1)&&(t=t.substr(1,t.length-1)),t.indexOf(",")>0&&6===(e=t.split(",")).length)return _.fromList(c(e,(function(t){return parseFloat(t)})));if(t.indexOf(" ")>0&&6===(e=t.split(" ")).length)return _.fromList(c(e,(function(t){return parseFloat(t)})))}return e}});var y=n.extend({init:function(t,e,i,n,o,s){this.a=t||0,this.b=e||0,this.c=i||0,this.d=n||0,this.e=o||0,this.f=s||0},fromMatrix:function(t){var e=new y;return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e.e=t.e,e.f=t.f,e}});function w(t){s.isUndefined(t)&&(t=10);for(var e="",i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=t;n>0;--n)e+=i.charAt(Math.round(61*Math.random()));return e}var x={_distanceToLineSquared:function(t,e,i){function n(t,e){return(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)}if(e===i)return n(t,e);var o=i.x-e.x,s=i.y-e.y,r=(t.x-e.x)*o+(t.y-e.y)*s;return r<0?n(e,t):(r=(i.x-t.x)*o+(i.y-t.y)*s)<0?n(i,t):(r=(i.x-t.x)*s-(i.y-t.y)*o)*r/(o*o+s*s)},distanceToLine:function(t,e,i){return Math.sqrt(this._distanceToLineSquared(t,e,i))},distanceToPolyline:function(t,e){var i=Number.MAX_VALUE;if(s.isUndefined(e)||0===e.length)return Number.MAX_VALUE;for(var n=0;n<e.length-1;n++){var o=e[n],r=e[n+1],a=this._distanceToLineSquared(t,o,r);a<i&&(i=a)}return Math.sqrt(i)}},b=e.Class.extend({init:function(){this._buckets=[],this.length=0},add:function(t,e){var i=this._createGetBucket(t);return s.isDefined(e)&&(i.value=e),i},get:function(t){return this._bucketExists(t)?this._createGetBucket(t):null},set:function(t,e){this.add(t,e)},containsKey:function(t){return this._bucketExists(t)},remove:function(t){if(this._bucketExists(t)){var e=this._hash(t);return delete this._buckets[e],this.length--,t}},forEach:function(t){for(var e=this._hashes(),i=0,n=e.length;i<n;i++){var o=e[i],r=this._buckets[o];s.isUndefined(r)||t(r)}},clone:function(){for(var t=new b,e=this._hashes(),i=0,n=e.length;i<n;i++){var o=e[i],r=this._buckets[o];s.isUndefined(r)||t.add(r.key,r.value)}return t},_hashes:function(){var t=[];for(var e in this._buckets)this._buckets.hasOwnProperty(e)&&t.push(e);return t},_bucketExists:function(t){var e=this._hash(t);return s.isDefined(this._buckets[e])},_createGetBucket:function(t){var e=this._hash(t),i=this._buckets[e];return s.isUndefined(i)&&(i={key:t},this._buckets[e]=i,this.length++),i},_hash:function(t){if(s.isNumber(t))return t;if(s.isString(t))return this._hashString(t);if(s.isObject(t))return this._objectHashId(t);throw"Unsupported key type."},_hashString:function(t){var e=0;if(0===t.length)return e;for(var i=0;i<t.length;i++){e=32*e-e+t.charCodeAt(i)}return e},_objectHashId:function(t){var e=t._hashId;return s.isUndefined(e)&&(e=w(),t._hashId=e),e}}),C=e.Observable.extend({init:function(t){if(e.Observable.fn.init.call(this),this._hashTable=new b,this.length=0,s.isDefined(t))if(Array.isArray(t))for(var i=0;i<t.length;i++)this.add(t[i]);else t.forEach((function(t,e){this.add(t,e)}),this)},add:function(t,e){var i=this._hashTable.get(t);i||(i=this._hashTable.add(t),this.length++,this.trigger("changed")),i.value=e},set:function(t,e){this.add(t,e)},get:function(t){var e=this._hashTable.get(t);if(e)return e.value;throw new Error("Cannot find key "+t)},containsKey:function(t){return this._hashTable.containsKey(t)},remove:function(t){if(this.containsKey(t))return this.trigger("changed"),this.length--,this._hashTable.remove(t)},forEach:function(t,e){this._hashTable.forEach((function(i){t.call(e,i.key,i.value)}))},forEachValue:function(t,e){this._hashTable.forEach((function(i){t.call(e,i.value)}))},forEachKey:function(t,e){this._hashTable.forEach((function(i){t.call(e,i.key)}))},keys:function(){var t=[];return this.forEachKey((function(e){t.push(e)})),t}}),S=e.Class.extend({init:function(){this._tail=null,this._head=null,this.length=0},enqueue:function(t){var e={value:t,next:null};this._head?(this._tail.next=e,this._tail=this._tail.next):(this._head=e,this._tail=this._head),this.length++},dequeue:function(){if(this.length<1)throw new Error("The queue is empty.");var t=this._head.value;return this._head=this._head.next,this.length--,t},contains:function(t){for(var e=this._head;e;){if(e.value===t)return!0;e=e.next}return!1}}),k=e.Observable.extend({init:function(t){e.Observable.fn.init.call(this),this._hashTable=new b,this.length=0,s.isDefined(t)&&(t instanceof b?t.forEach((function(t){this.add(t)})):t instanceof C&&t.forEach((function(t,e){this.add({key:t,value:e})}),this))},contains:function(t){return this._hashTable.containsKey(t)},add:function(t){this._hashTable.get(t)||(this._hashTable.add(t,t),this.length++,this.trigger("changed"))},get:function(t){return this.contains(t)?this._hashTable.get(t).value:null},hash:function(t){return this._hashTable._hash(t)},remove:function(t){this.contains(t)&&(this._hashTable.remove(t),this.length--,this.trigger("changed"))},forEach:function(t,e){this._hashTable.forEach((function(e){t(e.value)}),e)},toArray:function(){var t=[];return this.forEach((function(e){t.push(e)})),t}}),T=e.Class.extend({init:function(t,e){if(this.links=[],this.outgoing=[],this.incoming=[],this.weight=1,s.isDefined(t)?this.id=t:this.id=w(),s.isDefined(e)){this.associatedShape=e;var i=e.bounds();this.width=i.width,this.height=i.height,this.x=i.x,this.y=i.y}else this.associatedShape=null;this.data=null,this.type="Node",this.shortForm="Node '"+this.id+"'",this.isVirtual=!1},isIsolated:function(){return s.isEmpty(this.links)},bounds:function(t){if(!s.isDefined(t))return new i.Rect(this.x,this.y,this.width,this.height);this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},isLinkedTo:function(t){var e=this;return s.any(e.links,(function(i){return i.getComplement(e)===t}))},getChildren:function(){if(0===this.outgoing.length)return[];for(var t=[],e=0,i=this.outgoing.length;e<i;e++){var n=this.outgoing[e];t.push(n.getComplement(this))}return t},getParents:function(){if(0===this.incoming.length)return[];for(var t=[],e=0,i=this.incoming.length;e<i;e++){var n=this.incoming[e];t.push(n.getComplement(this))}return t},clone:function(){var t=new T;return s.isDefined(this.weight)&&(t.weight=this.weight),s.isDefined(this.balance)&&(t.balance=this.balance),s.isDefined(this.owner)&&(t.owner=this.owner),t.associatedShape=this.associatedShape,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},adjacentTo:function(t){return null!==this.isLinkedTo(t)},removeLink:function(t){t.source===this&&(s.remove(this.links,t),s.remove(this.outgoing,t),t.source=null),t.target===this&&(s.remove(this.links,t),s.remove(this.incoming,t),t.target=null)},hasLinkTo:function(t){return s.any(this.outgoing,(function(e){return e.target===t}))},degree:function(){return this.links.length},incidentWith:function(t){return h(this.links,t)},getLinksWith:function(t){return s.all(this.links,(function(e){return e.getComplement(this)===t}),this)},getNeighbors:function(){var t=[];return s.forEach(this.incoming,(function(e){t.push(e.getComplement(this))}),this),s.forEach(this.outgoing,(function(e){t.push(e.getComplement(this))}),this),t}}),M=e.Class.extend({init:function(t,e,i,n){if(s.isUndefined(t))throw"The source of the new link is not set.";if(s.isUndefined(e))throw"The target of the new link is not set.";var o,r;o=s.isString(t)?new T(t):t,r=s.isString(e)?new T(e):e,this.source=o,this.target=r,this.source.links.push(this),this.target.links.push(this),this.source.outgoing.push(this),this.target.incoming.push(this),s.isDefined(i)?this.id=i:this.id=w(),s.isDefined(n)?this.associatedConnection=n:this.associatedConnection=null,this.type="Link",this.shortForm="Link '"+this.source.id+"->"+this.target.id+"'"},getComplement:function(t){if(this.source!==t&&this.target!==t)throw"The given node is not incident with this link.";return this.source===t?this.target:this.source},getCommonNode:function(t){return this.source===t.source||this.source===t.target?this.source:this.target===t.source||this.target===t.target?this.target:null},isBridging:function(t,e){return this.source===t&&this.target===e||this.source===e&&this.target===t},getNodes:function(){return[this.source,this.target]},incidentWith:function(t){return this.source===t||this.target===t},adjacentTo:function(t){return h(this.source.links,t)||h(this.target.links,t)},changeSource:function(t){s.remove(this.source.links,this),s.remove(this.source.outgoing,this),t.links.push(this),t.outgoing.push(this),this.source=t},changeTarget:function(t){s.remove(this.target.links,this),s.remove(this.target.incoming,this),t.links.push(this),t.incoming.push(this),this.target=t},changesNodes:function(t,e){this.source===t?this.changeSource(e):this.target===t&&this.changeTarget(e)},reverse:function(){var t=this.source,e=this.target;return this.source=e,s.remove(t.outgoing,this),this.source.outgoing.push(this),this.target=t,s.remove(e.incoming,this),this.target.incoming.push(this),this},directTo:function(t){if(this.source!==t&&this.target!==t)throw"The given node is not incident with this link.";this.target!==t&&this.reverse()},createReverseEdge:function(){var t=this.clone();return t.reverse(),t.reversed=!0,t},clone:function(){return new M(this.source,this.target)}}),D=e.Class.extend({init:function(t){this.links=[],this.nodes=[],this._nodeMap=new C,this.diagram=null,this._root=null,s.isDefined(t)?s.isString(t)?this.id=t:(this.diagram=t,this.id=t.id):this.id=w(),this.bounds=new u,this._hasCachedRelationships=!1,this.type="Graph"},cacheRelationships:function(t){if(s.isUndefined(t)&&(t=!1),!this._hasCachedRelationships||t){for(var e=0,i=this.nodes.length;e<i;e++){var n=this.nodes[e];n.children=this.getChildren(n),n.parents=this.getParents(n)}this._hasCachedRelationships=!0}},assignLevels:function(t,e,i){if(!t)throw"Start node not specified.";s.isUndefined(e)&&(e=0),this.cacheRelationships(),s.isUndefined(i)&&(i=new C,s.forEach(this.nodes,(function(t){i.add(t,!1)}))),i.set(t,!0),t.level=e;for(var n=t.children,o=0,r=n.length;o<r;o++){var a=n[o];a&&!i.get(a)&&this.assignLevels(a,e+1,i)}},root:function(t){if(s.isUndefined(t)){if(this._root)return this._root;var e=s.first(this.nodes,(function(t){return 0===t.incoming.length}));return e||s.first(this.nodes)}this._root=t},getConnectedComponents:function(){this.componentIndex=0,this.setItemIndices();for(var t=s.initArray(this.nodes.length,-1),e=0;e<this.nodes.length;e++)-1===t[e]&&(this._collectConnectedNodes(t,e),this.componentIndex++);var i,n=[];for(i=0;i<this.componentIndex;++i)n[i]=new D;for(i=0;i<t.length;++i){n[t[i]].addNodeAndOutgoings(this.nodes[i])}return n.sort((function(t,e){return e.nodes.length-t.nodes.length})),n},_collectConnectedNodes:function(t,e){t[e]=this.componentIndex;var i=this.nodes[e];s.forEach(i.links,(function(e){var n=e.getComplement(i).index;-1===t[n]&&this._collectConnectedNodes(t,n)}),this)},calcBounds:function(){if(this.isEmpty())return this.bounds=new u,this.bounds;for(var t=null,e=0,i=this.nodes.length;e<i;e++){var n=this.nodes[e];t=t?t.union(n.bounds()):n.bounds()}return this.bounds=t,this.bounds},getSpanningTree:function(t){var e,i,n=new D,o=new C;n.root=t.clone(),n.root.level=0,n.root.id=t.id,o.add(t,n.root),t.level=0;var r=[],a=[];n._addNode(n.root),r.push(t),a.push(t);for(var c=1;a.length>0;)for(var d=a.pop(),l=0;l<d.links.length;l++){var u=d.links[l].getComplement(d);if(!h(r,u)){u.level=d.level+1,c<u.level+1&&(c=u.level+1),h(a,u)||a.push(u),h(r,u)||r.push(u),o.containsKey(d)?e=o.get(d):((e=d.clone()).level=d.level,e.id=d.id,o.add(d,e)),o.containsKey(u)?i=o.get(u):((i=u.clone()).level=u.level,i.id=u.id,o.add(u,i));var f=new M(e,i);n.addLink(f)}}for(var p=[],g=0;g<c;g++)p.push([]);return s.forEach(n.nodes,(function(t){p[t.level].push(t)})),n.treeLevels=p,n.cacheRelationships(),n},takeRandomNode:function(e,i){if(s.isUndefined(e)&&(e=[]),s.isUndefined(i)&&(i=4),0===this.nodes.length)return null;if(1===this.nodes.length)return h(e,this.nodes[0])?null:this.nodes[0];var n=t.grep(this.nodes,(function(t){return!h(e,t)&&t.degree()<=i}));return s.isEmpty(n)?null:n[s.randomInteger(0,n.length)]},isEmpty:function(){return s.isEmpty(this.nodes)},isHealthy:function(){return s.all(this.links,(function(t){return h(this.nodes,t.source)&&h(this.nodes,t.target)}),this)},getParents:function(t){if(!this.hasNode(t))throw"The given node is not part of this graph.";return t.getParents()},getChildren:function(t){if(!this.hasNode(t))throw"The given node is not part of this graph.";return t.getChildren()},addLink:function(t,e,i){if(s.isUndefined(t))throw"The source of the link is not defined.";if(s.isUndefined(e)){if(s.isDefined(t.type)&&"Link"===t.type)return void this.addExistingLink(t);throw"The target of the link is not defined."}var n=this.getNode(t);s.isUndefined(n)&&(n=this.addNode(t));var o=this.getNode(e);s.isUndefined(o)&&(o=this.addNode(e));var r=new M(n,o);return s.isDefined(i)&&(r.owner=i),this.links.push(r),r},removeAllLinks:function(){for(;this.links.length>0;){var t=this.links[0];this.removeLink(t)}},addExistingLink:function(t){if(!this.hasLink(t)){if(this.links.push(t),this.hasNode(t.source.id)){var e=this.getNode(t.source.id);t.changeSource(e)}else this.addNode(t.source);if(this.hasNode(t.target.id)){var i=this.getNode(t.target.id);t.changeTarget(i)}else this.addNode(t.target)}},hasLink:function(t){if(s.isString(t))return s.any(this.links,(function(e){return e.id===t}));if("Link"===t.type)return h(this.links,t);throw"The given object is neither an identifier nor a Link."},getNode:function(t){var e=t.id||t;if(this._nodeMap.containsKey(e))return this._nodeMap.get(e)},hasNode:function(t){var e=t.id||t;return this._nodeMap.containsKey(e)},_addNode:function(t){this.nodes.push(t),this._nodeMap.add(t.id,t)},_removeNode:function(t){s.remove(this.nodes,t),this._nodeMap.remove(t.id)},removeNode:function(t){var e=t;if(s.isString(t)&&(e=this.getNode(t)),!s.isDefined(e))throw"The identifier should be a Node or the Id (string) of a node.";var i=e.links;e.links=[];for(var n=0,o=i.length;n<o;n++){var r=i[n];this.removeLink(r)}this._removeNode(e)},areConnected:function(t,e){return s.any(this.links,(function(i){return i.source==t&&i.target==e||i.source==e&&i.target==t}))},removeLink:function(t){s.remove(this.links,t),s.remove(t.source.outgoing,t),s.remove(t.source.links,t),s.remove(t.target.incoming,t),s.remove(t.target.links,t)},addNode:function(t,e,i){var n=null;if(!s.isDefined(t))throw"No Node or identifier for a new Node is given.";if(s.isString(t)){if(this.hasNode(t))return this.getNode(t);n=new T(t)}else{if(this.hasNode(t))return this.getNode(t);n=t}return s.isDefined(e)&&n.bounds(e),s.isDefined(i)&&(n.owner=i),this._addNode(n),n},addNodeAndOutgoings:function(t){this.hasNode(t)||this._addNode(t);var e=t.outgoing;t.outgoing=[],s.forEach(e,(function(t){this.addExistingLink(t)}),this)},setItemIndices:function(){var t;for(t=0;t<this.nodes.length;++t)this.nodes[t].index=t;for(t=0;t<this.links.length;++t)this.links[t].index=t},clone:function(t){var e=new D,i=s.isDefined(t)&&!0===t;i&&(e.nodeMap=new C,e.linkMap=new C);var n=new C;return s.forEach(this.nodes,(function(t){var o=t.clone();n.set(t,o),e._addNode(o),i&&e.nodeMap.set(o,t)})),s.forEach(this.links,(function(t){if(n.containsKey(t.source)&&n.containsKey(t.target)){var o=e.addLink(n.get(t.source),n.get(t.target));i&&e.linkMap.set(o,t)}})),e},linearize:function(t){return D.Utils.linearize(this,t)},depthFirstTraversal:function(t,e){if(s.isUndefined(t))throw"You need to supply a starting node.";if(s.isUndefined(e))throw"You need to supply an action.";if(!this.hasNode(t))throw"The given start-node is not part of this graph";var i=this.getNode(t);this._dftIterator(i,e,[])},_dftIterator:function(t,e,i){e(t),i.push(t);for(var n=t.getChildren(),o=0,s=n.length;o<s;o++){var r=n[o];h(i,r)||this._dftIterator(r,e,i)}},breadthFirstTraversal:function(t,e){if(s.isUndefined(t))throw"You need to supply a starting node.";if(s.isUndefined(e))throw"You need to supply an action.";if(!this.hasNode(t))throw"The given start-node is not part of this graph";var i=this.getNode(t),n=new S,o=[];for(n.enqueue(i);n.length>0;){var r=n.dequeue();e(r),o.push(r);for(var a=r.getChildren(),c=0,d=a.length;c<d;c++){var l=a[c];h(o,l)||h(n,l)||n.enqueue(l)}}},_stronglyConnectedComponents:function(t,e,i,n,o,s,r){i.add(e,r),n.add(e,r),r++,s.push(e);for(var a,c=e.getChildren(),d=0,l=c.length;d<l;d++)a=c[d],i.containsKey(a)?h(s,a)&&n.add(e,Math.min(n.get(e),i.get(a))):(this._stronglyConnectedComponents(t,a,i,n,o,s,r),n.add(e,Math.min(n.get(e),n.get(a))));if(n.get(e)===i.get(e)){var u=[];do{a=s.pop(),u.push(a)}while(a!==e);(!t||u.length>1)&&o.push(u)}},findCycles:function(t){s.isUndefined(t)&&(t=!0);for(var e=new C,i=new C,n=[],o=[],r=0,a=this.nodes.length;r<a;r++){var h=this.nodes[r];e.containsKey(h)||this._stronglyConnectedComponents(t,h,e,i,n,o,0)}return n},isAcyclic:function(){return s.isEmpty(this.findCycles())},isSubGraph:function(t){var e=t.linearize(),i=this.linearize();return s.all(e,(function(t){return h(i,t)}))},makeAcyclic:function(){if(this.isEmpty()||this.nodes.length<=1||this.links.length<=1)return[];if(2==this.nodes.length){var t=[];if(this.links.length>1)for(var e=this.links[0].source,i=0,n=this.links.length;i<n;i++){var o=this.links[i];if(o.source!=e){var r=o.reverse();t.push(r)}}return t}var a=this.clone(!0),h=this.nodes.length,c=new C,d=function(t,e){return 0===t.outgoing.length?2-e:0===t.incoming.length?e-2:t.outgoing.length-t.incoming.length},l=function(t,e){var i=d(t,h);e.containsKey(i)||e.set(i,[]),e.get(i).push(t)};s.forEach(a.nodes,(function(t){l(t,c)}));for(var u=[],f=[];a.nodes.length>0;){var p,g,m;if(c.containsKey(2-h))for(var v=c.get(2-h);v.length>0;){g=v.pop();for(var _=0;_<g.links.length;_++){var y=g.links[_];p=y.getComplement(g),m=d(p,h),s.remove(c.get(m),p),p.removeLink(y),l(p,c)}a._removeNode(g),f.unshift(g)}if(c.containsKey(h-2))for(var w=c.get(h-2);w.length>0;){p=w.pop();for(var x=0;x<p.links.length;x++){var b=p.links[x];g=b.getComplement(p),m=d(g,h),s.remove(c.get(m),g),g.removeLink(b),l(g,c)}u.push(p),a._removeNode(p)}if(a.nodes.length>0)for(var S=h-3;S>2-h;S--)if(c.containsKey(S)&&c.get(S).length>0){for(var k=c.get(S).pop(),T=0;T<k.links.length;T++){var M=k.links[T],D=M.getComplement(k);m=d(D,h),s.remove(c.get(m),D),D.removeLink(M),l(D,c)}u.push(k),a._removeNode(k);break}}u=u.concat(f);for(var I=new C,P=0;P<this.nodes.length;P++)I.set(a.nodeMap.get(u[P]),P);var L=[];return s.forEach(this.links,(function(t){I.get(t.source)>I.get(t.target)&&(t.reverse(),L.push(t))})),L}});D.Predefined={EightGraph:function(){return D.Utils.parse(["1->2","2->3","3->4","4->1","3->5","5->6","6->7","7->3"])},Mindmap:function(){return D.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 D.Utils.parse(["1->2","2->3","3->1"])},BinaryTree:function(t){return s.isUndefined(t)&&(t=5),D.Utils.createBalancedTree(t,2)},Linear:function(t){return s.isUndefined(t)&&(t=10),D.Utils.createBalancedTree(t,1)},Tree:function(t,e){return D.Utils.createBalancedTree(t,e)},Forest:function(t,e,i){return D.Utils.createBalancedForest(t,e,i)},Workflow:function(){return D.Utils.parse(["0->1","1->2","2->3","1->4","4->3","3->5","5->6","6->3","6->7","5->4"])},Grid:function(t,e){var n=new i.Graph;if(t<=0&&e<=0)return n;for(var o=0;o<t+1;o++)for(var s=null,r=0;r<e+1;r++){var a=new T(o.toString()+"."+r.toString());if(n.addNode(a),s&&n.addLink(s,a),o>0){var h=n.getNode((o-1).toString()+"."+r.toString());n.addLink(h,a)}s=a}return n}},D.Utils={parse:function(t){for(var n,o=new i.Graph,r=t.slice(),a=0,h=r.length;a<h;a++){var c=r[a];if(s.isString(c)){if(c.indexOf("->")<0)throw"The link should be specified as 'a->b'.";var d=c.split("->");if(2!=d.length)throw"The link should be specified as 'a->b'.";n=new M(d[0],d[1]),o.addLink(n)}if(s.isObject(c)){if(!n)throw"Specification found before Link definition.";e.deepExtend(n,c)}}return o},linearize:function(t,e){if(s.isUndefined(t))throw"Expected an instance of a Graph object in slot one.";s.isUndefined(e)&&(e=!1);for(var i=[],n=0,o=t.links.length;n<o;n++){var r=t.links[n];i.push(r.source.id+"->"+r.target.id),e&&i.push({id:r.id})}return i},_addShape:function(t,i,n,o){return s.isUndefined(i)&&(i=new d(0,0)),s.isUndefined(n)&&(n=w()),o=e.deepExtend({width:20,height:20,id:n,radius:10,fill:"#778899",data:"circle",undoable:!1,x:i.x,y:i.y},o),t.addShape(o)},_addConnection:function(t,e,i,n){return t.connect(e,i,n)},createDiagramFromGraph:function(t,i,n,o){if(s.isUndefined(t))throw"The diagram surface is undefined.";if(s.isUndefined(i))throw"No graph specification defined.";s.isUndefined(n)&&(n=!0),s.isUndefined(o)&&(o=!1);for(var r,a,h=t.element.clientWidth||200,c=t.element.clientHeight||200,l=[],f=0,p=i.nodes.length;f<p;f++){var g=(r=i.nodes[f]).position;s.isUndefined(g)&&(g=s.isDefined(r.x)&&s.isDefined(r.y)?new d(r.x,r.y):new d(s.randomInteger(10,h-20),s.randomInteger(10,c-20)));var m={};"0"===r.id||o&&e.deepExtend(m,{width:150*Math.random()+20,height:80*Math.random()+50,data:"rectangle",fill:{color:"#778899"}});var v=(a=this._addShape(t,g,r.id,m)).bounds();s.isDefined(v)&&(r.x=v.x,r.y=v.y,r.width=v.width,r.height=v.height),l[r.id]=a}for(var _=0;_<i.links.length;_++){var y=i.links[_],w=l[y.source.id];if(!s.isUndefined(w)){var x=l[y.target.id];s.isUndefined(x)||this._addConnection(t,w,x,{id:y.id})}}if(n){new t.SpringLayout(t).layoutGraph(i,{limitToView:!1});for(var b=0;b<i.nodes.length;b++)(a=l[(r=i.nodes[b]).id]).bounds(new u(r.x,r.y,r.width,r.height))}},createBalancedTree:function(t,e){s.isUndefined(t)&&(t=3),s.isUndefined(e)&&(e=3);var n,o=new i.Graph,r=-1,a=[];if(t<=0||e<=0)return o;var h=new T((++r).toString());o.addNode(h),o.root=h,a.push(h);for(var c=0;c<t;c++){n=[];for(var d=0;d<a.length;d++)for(var l=a[d],u=0;u<e;u++){var f=new T((++r).toString());o.addLink(l,f),n.push(f)}a=n}return o},createBalancedForest:function(t,e,n){s.isUndefined(t)&&(t=3),s.isUndefined(e)&&(e=3),s.isUndefined(n)&&(n=5);var o,r=new i.Graph,a=-1,h=[];if(t<=0||e<=0||n<=0)return r;for(var c=0;c<n;c++){var d=new T((++a).toString());r.addNode(d),h=[d];for(var l=0;l<t;l++){o=[];for(var u=0;u<h.length;u++)for(var f=h[u],p=0;p<e;p++){var g=new T((++a).toString());r.addLink(f,g),o.push(g)}h=o}}return r},createRandomConnectedGraph:function(t,e,n){s.isUndefined(t)&&(t=40),s.isUndefined(e)&&(e=4),s.isUndefined(n)&&(n=!1);var o=new i.Graph,r=-1;if(t<=0)return o;var a=new T((++r).toString());if(o.addNode(a),1===t)return o;if(t>1){for(var h=1;h<t;h++){var c=o.takeRandomNode([],e);if(!c)break;var d=o.addNode(h.toString());o.addLink(c,d)}if(!n&&t>1)for(var l=s.randomInteger(1,t),u=0;u<l;u++){var f=o.takeRandomNode([],e),p=o.takeRandomNode([],e);f&&p&&!o.areConnected(f,p)&&o.addLink(f,p)}return o}},randomDiagram:function(t,i,n,o,s){var r=e.dataviz.diagram.Graph.Utils.createRandomConnectedGraph(i,n,o);D.Utils.createDiagramFromGraph(t,r,!1,s)}},e.deepExtend(i,{init:function(t){e.init(t,i.ui)},Point:d,Intersect:g,Geometry:x,Rect:u,Size:f,RectAlign:m,Matrix:_,MatrixVector:y,normalVariable:function(t,e){var i,n,o;do{o=(i=2*Math.random()-1)*i+(n=2*Math.random()-1)*n}while(!o||o>1);return t+e*i*Math.sqrt(-2*Math.log(o)/o)},randomId:w,Dictionary:C,HashTable:b,Queue:S,Set:k,Node:T,Link:M,Graph:D,PathDefiner:l})}(window.kendo.jQuery),function(t,e){var i=window.kendo,n=i.dataviz.diagram,o=i.Class,s=i.deepExtend,r=n.Point,a=n.Rect,h=n.Matrix,c=n.Utils,d=c.isNumber,l=c.isString,u=n.MatrixVector,f=i.geometry,p=i.drawing,g=p.util.defined,m=t.inArray,v="transparent",_={none:"none",arrowStart:"ArrowStart",filledCircle:"FilledCircle",arrowEnd:"ArrowEnd"},y="start",w="end",x="width",b="height";function C(t,e){for(var i,n,o=this.options,s=!1,r=0;r<e.length;r++)i=t[n=e[r]],d(i)&&o[n]!==i&&(o[n]=i,s=!0);return s}n.Markers=_;var S=o.extend({init:function(t,e){this.x=t,this.y=e},toMatrix:function(){return h.scaling(this.x,this.y)},toString:function(){return i.format("scale({0},{1})",this.x,this.y)},invert:function(){return new S(1/this.x,1/this.y)}}),k=o.extend({init:function(t,e){this.x=t,this.y=e},toMatrixVector:function(){return new u(0,0,0,0,this.x,this.y)},toMatrix:function(){return h.translation(this.x,this.y)},toString:function(){return i.format("translate({0},{1})",this.x,this.y)},plus:function(t){this.x+=t.x,this.y+=t.y},times:function(t){this.x*=t,this.y*=t},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 k(-this.x,-this.y)}}),T=o.extend({init:function(t,e,i){this.x=e||0,this.y=i||0,this.angle=t},toString:function(){return this.x&&this.y?i.format("rotate({0},{1},{2})",this.angle,this.x,this.y):i.format("rotate({0})",this.angle)},toMatrix:function(){return h.rotation(this.angle,this.x,this.y)},center:function(){return new r(this.x,this.y)},invert:function(){return new T(360-this.angle,this.x,this.y)}});T.ZERO=new T(0),T.create=function(t){return new T(t.angle,t.x,t.y)},T.parse=function(t){var e=t.slice(1,t.length-1).split(","),i=e[0],n=e[1],o=e[2];return new T(i,n,o)};var M=o.extend({init:function(t,i,n,o,s,r){this.translate=new k(t,i),n!==e&&o!==e&&(this.scale=new S(n,o)),s!==e&&(this.rotate=r?new T(s,r.x,r.y):new T(s))},toString:function(){var t=function(t){return t?t.toString():""};return t(this.translate)+t(this.rotate)+t(this.scale)},render:function(t){t._transform=this,t._renderTransform()},toMatrix:function(){var t=h.unit();return this.translate&&(t=t.times(this.translate.toMatrix())),this.rotate&&(t=t.times(this.rotate.toMatrix())),this.scale&&(t=t.times(this.scale.toMatrix())),t},invert:function(){var t=this.rotate?this.rotate.invert():e,i=t?t.toMatrix():h.unit(),n=this.scale?this.scale.invert():e,o=n?n.toMatrix():h.unit(),s=new r(-this.translate.x,-this.translate.y);s=i.times(o).apply(s);var a=new k(s.x,s.y),c=new M;return c.translate=a,c.rotate=t,c.scale=n,c}}),D={_setScale:function(){var t=this.options,e=this._originWidth,i=this._originHeight,n=t.width/e,o=t.height/i;d(n)||(n=1),d(o)||(o=1),this._transform.scale=new S(n,o)},_setTranslate:function(){var t=this.options,e=t.x||0,i=t.y||0;this._transform.translate=new k(e,i)},_initSize:function(){var t=this.options,e=!1;!1!==t.autoSize&&(g(t.width)||g(t.height))&&(this._measure(!0),this._setScale(),e=!0),(g(t.x)||g(t.y))&&(this._setTranslate(),e=!0),e&&this._renderTransform()},_updateSize:function(t){var e=!1;return!1!==this.options.autoSize&&this._diffNumericOptions(t,[x,b])&&(e=!0,this._measure(!0),this._setScale()),this._diffNumericOptions(t,["x","y"])&&(e=!0,this._setTranslate()),e&&this._renderTransform(),e}},I=o.extend({init:function(t){var e=this;e.options=s({},e.options,t),e.id=e.options.id,e._originSize=a.empty(),e._transform=new M},visible:function(t){return this.drawingContainer().visible(t)},redraw:function(t){t&&t.id&&(this.id=t.id)},position:function(t,e){var i=this.options;if(!g(t))return new r(i.x,i.y);g(e)?(i.x=t,i.y=e):t instanceof r&&(i.x=t.x,i.y=t.y),this._transform.translate=new k(i.x,i.y),this._renderTransform()},rotate:function(t,e){return g(t)&&(this._transform.rotate=new T(t,e.x,e.y),this._renderTransform()),this._transform.rotate||T.ZERO},drawingContainer:function(){return this.drawingElement},_renderTransform:function(){var t=this._transform.toMatrix();this.drawingContainer().transform(new f.Matrix(t.a,t.b,t.c,t.d,t.e,t.f))},_hover:function(){},_diffNumericOptions:C,_measure:function(t){var e;if(!this._measured||t){var i=this._boundingBox()||new f.Rect,n=i.topLeft();e=new a(n.x,n.y,i.width(),i.height()),this._originSize=e,this._originWidth=e.width,this._originHeight=e.height,this._measured=!0}else e=this._originSize;return e},_boundingBox:function(){return this.drawingElement.rawBBox()}}),P=I.extend({init:function(t){I.fn.init.call(this,t),(t=this.options).fill=W(t.fill),t.stroke=W(t.stroke)},options:{stroke:{color:"gray",width:1},fill:{color:v}},fill:function(t,e){this._fill({color:j(t),opacity:e})},stroke:function(t,e,i){this._stroke({color:j(t),width:e,opacity:i})},redraw:function(t){if(t){var e=t.stroke,i=t.fill;e&&this._stroke(W(e)),i&&this._fill(W(i)),I.fn.redraw.call(this,t)}},_hover:function(t){var e=this.drawingElement,i=this.options,n=i.hover;if(n&&n.fill){var o=t?W(n.fill):i.fill;e.fill(o.color,o.opacity)}},_stroke:function(t){var e=this.options;s(e,{stroke:t});var i=null;(t=e.stroke).width>0&&(i={color:t.color,width:t.width,opacity:t.opacity,dashType:t.dashType}),this.drawingElement.options.set("stroke",i)},_fill:function(t){var e=this.options;s(e,{fill:t||{}});var i=e.fill;if(i.gradient){var n=i.gradient,o="radial"===n.type?p.RadialGradient:p.LinearGradient;this.drawingElement.fill(new o(n))}else this.drawingElement.fill(i.color,i.opacity)}}),L=P.extend({init:function(t){t=this._textColor(t),P.fn.init.call(this,t),this._font(),this._initText(),this._initSize()},options:{fontSize:15,fontFamily:"sans-serif",stroke:{width:0},fill:{color:"black"},autoSize:!0},_initText:function(){var t=this.options;this.drawingElement=new p.Text(g(t.text)?t.text:"",new f.Point,{font:t.font}),this._fill(),this._stroke()},_textColor:function(t){return t&&t.color&&(t=s({},t,{fill:{color:t.color}})),t},_font:function(){var t=this.options;if(t.fontFamily&&g(t.fontSize)){var e=[];t.fontStyle&&e.push(t.fontStyle),t.fontWeight&&e.push(t.fontWeight),e.push(t.fontSize+(d(t.fontSize)?"px":"")),e.push(t.fontFamily),t.font=e.join(" ")}else delete t.font},content:function(t){return this.drawingElement.content(t)},redraw:function(t){if(t){var e=!1,i=this.options;t=this._textColor(t),P.fn.redraw.call(this,t),(t.fontFamily||g(t.fontSize)||t.fontStyle||t.fontWeight)&&(s(i,{fontFamily:t.fontFamily,fontSize:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight}),this._font(),this.drawingElement.options.set("font",i.font),e=!0),t.text&&(this.content(t.text),e=!0),!this._updateSize(t)&&e&&this._initSize()}}});s(L.fn,D);var E=P.extend({init:function(t){P.fn.init.call(this,t),this._initPath(),this._setPosition()},_setPosition:function(){var t=this.options,e=t.x,i=t.y;(g(e)||g(i))&&this.position(e||0,i||0)},redraw:function(t){t&&(P.fn.redraw.call(this,t),this._diffNumericOptions(t,[x,b])&&this._drawPath(),this._diffNumericOptions(t,["x","y"])&&this._setPosition())},_initPath:function(){var t=this.options;this.drawingElement=new p.Path({stroke:t.stroke,closed:!0}),this._fill(),this._drawPath()},_drawPath:function(){var t=this.drawingElement,e=K(this.options),i=e.width,n=e.height;t.segments.elements([X(0,0),X(i,0),X(i,n),X(0,n)])}}),z=P.extend({init:function(t){P.fn.init.call(this,t);var e=this.options.anchor;this.anchor=new f.Point(e.x,e.y),this.createElement()},options:{stroke:{color:v,width:0},fill:{color:"black"}},_transformToPath:function(t,e){var i=e.transform();return t&&i&&(t=t.transformCopy(i)),t},redraw:function(t){t&&(t.position&&(this.options.position=t.position),P.fn.redraw.call(this,t))}}),B=z.extend({options:{radius:4,anchor:{x:0,y:0}},createElement:function(){var t=this.options;this.drawingElement=new p.Circle(new f.Circle(this.anchor,t.radius),{fill:t.fill,stroke:t.stroke})},positionMarker:function(t){var e,i,n=this.options.position,o=t.segments;(e=n==y?o[0]:o[o.length-1])&&(i=this._transformToPath(e.anchor(),t),this.drawingElement.transform(f.transform().translate(i.x,i.y)))}}),R=z.extend({options:{path:"M 0 0 L 10 5 L 0 10 L 3 5 z",anchor:{x:10,y:5}},createElement:function(){var t=this.options;this.drawingElement=p.Path.parse(t.path,{fill:t.fill,stroke:t.stroke})},positionMarker:function(t){var e,i,n,o,s=this._linePoints(t),r=s.start,a=s.end,h=f.transform();if(r&&h.rotate((e=r,n=(i=a).x-e.x,o=i.y-e.y,p.util.deg(Math.atan2(o,n))),a),a){var c=this.anchor,d=a.clone().translate(-c.x,-c.y);h.translate(d.x,d.y)}this.drawingElement.transform(h)},_linePoints:function(t){var e,i,n,o=this.options,s=t.segments;if(o.position==y){if(n=s[0]){i=n.anchor(),e=n.controlOut();var r=s[1];!e&&r&&(e=r.anchor())}}else if(n=s[s.length-1]){i=n.anchor(),e=n.controlIn();var a=s[s.length-2];!e&&a&&(e=a.anchor())}if(i)return{start:this._transformToPath(e,t),end:this._transformToPath(i,t)}}}),N={_getPath:function(t){var e=this.drawingElement;if(e instanceof p.MultiPath&&(e=t==y?e.paths[0]:e.paths[e.paths.length-1]),e&&e.segments.length)return e},_normalizeMarkerOptions:function(t){var e=t.startCap,i=t.endCap;l(e)&&(t.startCap={type:e}),l(i)&&(t.endCap={type:i})},_removeMarker:function(t){var e=this._markers[t];e&&(this.drawingContainer().remove(e.drawingElement),delete this._markers[t])},_createMarkers:function(){var t=this.options;this._normalizeMarkerOptions(t),this._markers={},this._markers[y]=this._createMarker(t.startCap,y),this._markers[w]=this._createMarker(t.endCap,w)},_createMarker:function(t,e){var i,n,o=(t||{}).type,r=this._getPath(e);if(r)return o==_.filledCircle?i=B:o==_.arrowStart||o==_.arrowEnd?i=R:this._removeMarker(e),i?((n=new i(s({},t,{position:e}))).positionMarker(r),this.drawingContainer().append(n.drawingElement),n):void 0;this._removeMarker(e)},_positionMarker:function(t){var e=this._markers[t];if(e){var i=this._getPath(t);i?e.positionMarker(i):this._removeMarker(t)}},_capMap:{start:"startCap",end:"endCap"},_redrawMarker:function(t,e,i){this._normalizeMarkerOptions(i);var n=this.options,o=this._capMap[e],r=(n[o]||{}).type,a=i[o],h=!1;return a?(n[o]=s({},n[o],a),a.type&&r!=a.type?(this._removeMarker(e),this._markers[e]=this._createMarker(n[o],e),h=!0):this._markers[e]&&this._markers[e].redraw(a)):t&&!this._markers[e]&&n[o]&&(this._markers[e]=this._createMarker(n[o],e),h=!0),h},_redrawMarkers:function(t,e){!this._redrawMarker(t,y,e)&&t&&this._positionMarker(y),!this._redrawMarker(t,w,e)&&t&&this._positionMarker(w)}},A=P.extend({init:function(t){P.fn.init.call(this,t),this.container=new p.Group,this._createElements(),this._initSize()},options:{autoSize:!0},drawingContainer:function(){return this.container},data:function(t){var e=this.options;if(!t)return e.data;e.data!=t&&(e.data=t,this._setData(t),this._initSize(),this._redrawMarkers(!0,{}))},redraw:function(t){if(t){P.fn.redraw.call(this,t);var e=this.options,i=t.data;g(i)&&e.data!=i?(e.data=i,this._setData(i),this._updateSize(t)||this._initSize(),this._redrawMarkers(!0,t)):(this._updateSize(t),this._redrawMarkers(!1,t))}},_createElements:function(){var t=this.options;this.drawingElement=p.Path.parse(t.data||"",{stroke:t.stroke}),this._fill(),this.container.append(this.drawingElement),this._createMarkers()},_setData:function(t){var e=this.drawingElement,i=p.Path.parse(t||""),n=i.paths.slice(0);i.paths.elements([]),e.paths.elements(n)}});s(A.fn,D),s(A.fn,N);var O=P.extend({init:function(t){P.fn.init.call(this,t),this.container=new p.Group,this._initPath(),this._createMarkers()},drawingContainer:function(){return this.container},redraw:function(t){if(t){var e=(t=t||{}).from,i=t.to;e&&(this.options.from=e),i&&(this.options.to=i),e||i?(this._drawPath(),this._redrawMarkers(!0,t)):this._redrawMarkers(!1,t),P.fn.redraw.call(this,t)}},_initPath:function(){var t=this.options,e=this.drawingElement=new p.Path({stroke:t.stroke});this._fill(),this._drawPath(),this.container.append(e)},_drawPath:function(){var t=this.options,e=this.drawingElement,i=t.fr