!function(a,b){function c(a,b){return!q(a)||!a.colors||a instanceof E?t(a)?a=new F(a,null,b.context):a instanceof Function&&(a={toCanvasStyle:a.bind(b)}):a=new E(a,null,null,null,b.context),a}function d(){for(var a,b,c=0,e=H._queue.length,f=Date.now();c1&&(b=1),a.now=f,a.pos=a.easing(b),H.fx.step[a.prop](a),0===a.state&&(a.state=1),1===b&&(a.callback&&a.callback.call(a.elem,a),a.elem._queue?(a.elem._queue.shift(),a.elem._queue.length>0?(H._queue[c]=a=a.elem._queue[0],a.startTime=Date.now(),a.endTime=a.startTime+a.duration):(a.elem._queue=null,H._queue.splice(c,1),c--,e--)):(a.elem._queue=null,H._queue.splice(c,1),c--,e--)));a.elem.update(),e>0?P(d):R=!1}function e(a,b){0===a.state&&(a.elem._matrixStart=a.elem._matrix||[1,0,0,1,0,0],a.elem._matrixCur=[],a.elem.corner?a.corner=a.elem.corner(a.elem._origin||"center"):a.corner=[0,0]),a.elem._matrixCur.now!==a.now&&(a.elem._matrixCur=[1,0,0,1,0,0]);var c=b(a);c[4]+=a.corner[0]-a.corner[0]*c[0]-a.corner[1]*c[2],c[5]+=a.corner[1]-a.corner[0]*c[1]-a.corner[1]*c[3],a.elem._matrixCur=H.multiply(a.elem._matrixCur,c),a.elem._matrixCur.now=a.now,a.elem._matrix=H.multiply(a.elem._matrixStart,a.elem._matrixCur)}function f(a){return T?T:(["mozImageSmoothingEnabled","webkitImageSmoothingEnabled","msImageSmoothingEnabled","imageSmoothingEnabled"].forEach(function(b){b in a&&(T=b)}),T)}function g(a){H.easing[V+"In"]=a,H.easing[V+"Out"]=function(b,c){return 1-a(1-b,c)},H.easing[V+"InOut"]=function(b,c){return b<=.5?a(2*b,c)/2:(2-a(2*(1-b),c))/2}}function h(a,b,c,d){c<0&&(c=-c,a-=c),d<0&&(d=-d,b-=d),this.x=this.x1=a,this.y=this.y1=b,this.w=this.width=c,this.h=this.height=d,this.x2=a+c,this.y2=b+d,this.cx=a+c/2,this.cy=b+d/2}function i(a,b,c){b||(b=a,a=null);var d=function(){return(d.prototype.initialize||J).apply(this,arguments)};if(a){d=function(){if(d.prototype.__initialize__)return d.prototype.__initialize__.apply(this,arguments);for(var a=[],c=this.constructor.parent;c;)a.push(c.prototype.initialize),c=c.parent;for(var e=a.length;e--;)a[e]&&a[e].apply(this,arguments);return d.prototype.initialize&&b.initialize===d.prototype.initialize?d.prototype.initialize.apply(this,arguments):void 0};var e=function(){};e.prototype=a.prototype,d.prototype=new e,d.parent=a,d.prototype.constructor=d}return c&&j(d,c),b.mixins&&b.mixins.forEach(function(a){j(d.prototype,a)}),j(d.prototype,b),d}function j(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c]);return a}function k(a){return function(b){return this.argument(a,b)}}function l(a){var b=a[1];return a=L.call(a,2),function(){this[b].apply(this,a)}}function m(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")}function n(a){return"[object String]"===K.call(a)}function o(a){return"[object Boolean]"===K.call(a)}function p(a){return"[object Array]"===K.call(a)}function q(a){return"[object Object]"===K.call(a)}function r(a){return"[object Number]"===K.call(a)}function s(a){return!!r(a)||!(!n(a)||!/^(\d+|(\d+)?\.\d+)(em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|px|pt|pc)?$/.test(a))}function t(a){return a instanceof Image||q(a)&&H.has(a,"image")||n(a)&&!(a.indexOf("http://")&&a.indexOf("https://")&&a.indexOf("./")&&a.indexOf("../")&&a.indexOf("data:image/")&&a.indexOf("1&&this.stroke(a[b+1]),a.length-c.length>0&&this.fill(a[b]));b--;)d[b]?this["_"+c[b]]=d[b](a[b]):this["_"+c[b]]=a[b]},draw:function(a){this._visible&&(a.save(),this.styleToContext(a),this._matrix&&a.transform.apply(a,this._matrix),this.processPath(a),this.styles.fillStyle&&a.fill(),this.styles.strokeStyle&&a.stroke(),a.restore())},update:function(){return this.context?(this.context.update(),this):this},prop:function(a,c){return c===b?this["_"+a]:(this["_"+a]=c,this.update())},mouse:function(a){return this.prop("events",!!a)},z:function(a){var c=this.context.elements.indexOf(this);return a===b?c:("top"===a&&(a=this.context.elements.length),this.context.elements.splice(c,1),this.context.elements.splice(a,0,this),this.update())},clone:function(a,b){var c=new this.constructor([],this.context);for(var d in this)H.has(this,d)&&"_"===d[0]&&("object"!=typeof this[d]||null===this[d]||"_image"===d||a===!0&&"_style"===d?c[d]=this[d]:c[d]=H.clone(this[d]));return b===!0&&(c.listeners=this.listeners),this.context.push(c)},remove:function(){return this.context.elements.splice(this.context.elements.indexOf(this),1),this.update()},cursor:function(a){return a===b?this._cursor:(this._cursor=a,null===a?this.off("mouseover",this._cursorListenerOn).off("mouseout",this._cursorListenerOff):(this._cursorListenerOn||(this._cursorListenerOn=function(){var a=this.context.canvas;this._oldCursor=a.style.cursor,a.style.cursor=this._cursor},this._cursorListenerOff=function(){var a=this.context.canvas;a.style.cursor===this._cursor&&(a.style.cursor=this._oldCursor)},this.mouseover(this._cursorListenerOn).mouseout(this._cursorListenerOff)),this))},on:function(b,c){if(n(c)&&(c=l(arguments)),q(b)){for(var d in b)H.has(b,d)&&(p(b[d])?this.on.apply(this,[d].concat(b[d])):this.on(d,b[d]));return this}return r(b)?(a.setTimeout(c.bind(this),b),this):(this.context.listener(b),(this.listeners[b]||(this.listeners[b]=[])).push(c),this)},once:function(a,b){n(b)&&(b=l(arguments,this));var c;return this.on(a,b),this.on(a,c=function(){this.off(a,b)}),c.proxy=b,this},off:function(a,b){if(!a)return this.listeners={},this;if(!b)return this.listeners[a]=[],this;a=this.listeners[a];var c=a.indexOf(b);return a[c+1].proxy===b?a.splice(c,2):a.splice(c,1),this},fire:function(a,b){if(a=this.listeners[a],!a)return this;for(var c=0,d=a.length;c0?this._queue.push(h):(this._queue=[h],H._queue.push(h),H._checkAnimation()),this},_visible:!0,_events:!0,_origin:"center"}),H._queue=[];var R=!1;H._checkAnimation=function(){R||(P(d),R=!0)},H.fx={},H.fx.step={int:function(a){0===a.state&&(a._prop="_"+a.prop,a.start=a.elem[a._prop],n(a.end)&&(0===a.end.indexOf("+=")?a.end=a.start+Number(a.end.substr(2)):0===a.end.indexOf("-=")&&(a.end=a.start-Number(a.end.substr(2))))),a.elem[a._prop]=Math.round(a.start+(a.end-a.start)*a.pos)},float:function(a){0===a.state&&(a._prop="_"+a.prop,a.start=a.elem[a._prop],n(a.end)&&(0===a.end.indexOf("+=")?a.end=a.start+Number(a.end.substr(2)):0===a.end.indexOf("-=")&&(a.end=a.start-Number(a.end.substr(2))))),a.elem[a._prop]=a.start+(a.end-a.start)*a.pos},opacity:function(a){0===a.state&&(a.start=a.elem.styles.globalAlpha,a.start===b&&(a.start=1)),a.elem.styles.globalAlpha=a.start+(a.end-a.start)*a.pos},fill:function(a){0===a.state&&(a.start=H.color(a.elem.styles.fillStyle),"transparent"===a.end?a.end=a.start.slice(0,3).concat([0]):a.end=H.color(a.end),"transparent"!==a.elem.styles.fillStyle&&a.elem.styles.fillStyle!==b||(a.start=a.end.slice(0,3).concat([0]))),a.elem.styles.fillStyle="rgba("+[Math.round(a.start[0]+(a.end[0]-a.start[0])*a.pos),Math.round(a.start[1]+(a.end[1]-a.start[1])*a.pos),Math.round(a.start[2]+(a.end[2]-a.start[2])*a.pos),a.start[3]+(a.end[3]-a.start[3])*a.pos].join(",")+")"},stroke:function(a){0===a.state&&(a.color1=H.color(a.elem.styles.strokeStyle),a.width1=a.elem.styles.lineWidth||0,a.width2=end.lineWidth,"transparent"===end.strokeStyle?a.color2=a.color1.slice(0,3).concat([0]):end.strokeStyle&&(a.color2=H.color(end.strokeStyle)),"transparent"!==a.elem.styles.strokeStyle&&a.elem.styles.strokeStyle!==b||!end.strokeStyle||(a.color1=a.color2.slice(0,3).concat([0]))),a.color2&&(a.elem.styles.strokeStyle="rgba("+[Math.round(a.color1[0]+(a.color2[0]-a.color1[0])*a.pos),Math.round(a.color1[1]+(a.color2[1]-a.color1[1])*a.pos),Math.round(a.color1[2]+(a.color2[2]-a.color1[2])*a.pos),a.color1[3]+(a.color2[3]-a.color1[3])*a.pos].join(",")+")"),a.width2&&(a.elem.styles.lineWidth=a.width1+(a.width2-a.width1)*a.pos)},translate:function(a){e(a,function(){return[1,0,0,1,a.end[0]*a.pos,a.end[1]*a.pos]})},rotate:function(a){0===a.state&&"grad"===H.angleUnit&&(a.end=a.end*Math.PI/180),e(a,function(){var b=a.end*a.pos,c=Math.cos(b),d=Math.sin(b);return[c,d,-d,c,0,0]})},skew:function(a){0===a.state&&(a.end.length===b&&(a.end=[a.end,a.end]),"grad"===H.angleUnit&&(a.end[0]=a.end[0]*Math.PI/180,a.end[1]=a.end[1]*Math.PI/180)),e(a,function(){return[1,Math.tan(a.end[1]*a.pos),Math.tan(a.end[0]*a.pos),1,0,0]})},scale:function(a){0===a.state&&a.end.length===b&&(a.end=[a.end,a.end]),e(a,function(){return[1+(a.end[0]-1)*a.pos,0,0,1+(a.end[1]-1)*a.pos,0,0]})},origin:function(a){0===a.state&&(a.elem._origin=a.elem.corner(a.end))}},["click","dblclick","mousedown","mousewheel","mouseup","mousemove","mouseover","mouseout","focus","blur","touchstart","touchmove","touchend","keypress","keydown","keyup"].forEach(function(a){w.prototype[a]=v.prototype[a]=function(b){return"function"==typeof b||n(b)?this.on.apply(this,[a].concat(L.call(arguments))):this.fire.apply(this,arguments)}}),["x","y","width","height","cx","cy","radius"].forEach(function(a){H.fx.step[a]=H.fx.step.int}),H.fn=w.prototype,x=new i(w,{initialize:function(){if(this.object){var a=this.object;this._x=a.x,this._y=a.y,this._width=a.width,this._height=a.height,delete this.object}},x:function(a){return this.prop("x",a)},y:function(a){return this.prop("y",a)},width:function(a){return this.prop("width",a)},height:function(a){return this.prop("height",a)},x1:function(a){return a===b?this._x:this.prop("width",this._width-a+this._x).prop("x",a)},y1:function(a){return a===b?this._y:this.prop("height",this._height-a+this._y).prop("y",a)},x2:function(a){return a===b?this._x+this._width:this.prop("width",a-this._x)},y2:function(a){return a===b?this._y+this._height:this.prop("height",a-this._y)},nativeBounds:function(){return new h(this._x,this._y,this._width,this._height)},draw:function(a){this._visible&&this.context.renderer.drawRect([this._x,this._y,this._width,this._height],a,this.styles,this.matrix,this)},processPath:function(a){a.beginPath(),a.rect(this._x,this._y,this._width,this._height)}}),x.props=["x","y","width","height"],x.processStyle=!0,x.firstObject=!0,x.propHandlers=[u,u,u,u],H.rect=function(){return new x(arguments)},y=new i(w,{initialize:function(){if(this.object){var a=this.object;this._cx=a.cx,this._cy=a.cy,this._radius=a.radius,delete this.object}},cx:function(a){return this.prop("cx",a)},cy:function(a){return this.prop("cy",a)},radius:function(a){return this.prop("radius",a)},bounds:function(){return new h(this._cx-this._radius,this._cy-this._radius,2*this._radius,2*this._radius)},draw:function(a){this._visible&&this.context.renderer.drawCircle([this._cx,this._cy,this._radius],a,this.styles,this.matrix,this)},processPath:function(a){a.beginPath(),a.arc(this._cx,this._cy,Math.abs(this._radius),0,2*Math.PI,!0)}}),y.props=["cx","cy","radius"],y.processStyle=!0,y.firstObject=!0,y.propHandlers=[u,u,u],H.circle=function(){return new y(arguments)},z=new i({initialize:function(a,b,c){this.name=a,this.path=c,this.args=b,a in z.curves&&j(this,z.curves[a])},prop:w.prototype.prop,update:function(){return this.path.update(),this},arguments:function(){return this.prop("args",arguments.length>1?arguments:arguments[0])},from:function(){if(!this.path)throw"Error: the curve hasn't path.";var a=this.path._curves.indexOf(this),b=this.path._curves[a-1];if(0===a)return[0,0];if(!(a!==-1&&b&&"endsIn"in b))return null;var c=b.endsIn();return c?c:null},endsIn:function(){return this._slice?this.args.slice(this._slice[0],this._slice[1]):null},process:function(a){return a[this.name].apply(a,this.args),this.endsIn()},_bounds:function(){return null}}),z.curves={moveTo:{_slice:[,],points:function(){return[this.args]},x:k(0),y:k(1)},lineTo:{_slice:[,],points:function(){return[this.args]},_bounds:function(a){var b=this.args;return new h(a[0],a[1],b[0]-a[0],b[1]-a[1])},x:k(0),y:k(1)},quadraticCurveTo:{_slice:[2],points:function(){return[this.args.slice(2),this.args.slice(0,2)]},_bounds:function(a){var b=this.args,c=Math.min(b[0],b[2],a[0]),d=Math.min(b[1],b[3],a[1]),e=Math.max(b[0],b[2],a[0]),f=Math.max(b[1],b[3],a[1]);return new h(c,d,e-c,f-d)},hx:k(0),hy:k(1),x:k(2),y:k(3)},bezierCurveTo:{_slice:[4],points:function(){return[this.args.slice(4),this.args.slice(2,4),this.args.slice(0,2)]},_bounds:function(a){var b=this.args,c=Math.min(b[0],b[2],b[4],a[0]),d=Math.min(b[1],b[3],b[5],a[1]),e=Math.max(b[0],b[2],b[4],a[0]),f=Math.max(b[1],b[3],b[5],a[1]);return new h(c,d,e-c,f-d)},h1x:k(0),h1y:k(1),h2x:k(2),h2y:k(3),x:k(4),y:k(5)},arc:{points:function(){return[this.args.slice(0,2)]},x:k(0),y:k(1),radius:k(2),start:k(3),end:k(4),clockwise:k(5),endsIn:function(){var a=this.args[0],b=this.args[1],c=this.args[2],d=this.args[3],e=this.args[4],f=this.args[5],g=e-d;return f&&(g=-g),[a+Math.cos(g)*c,b+Math.sin(g)*c]}},arcTo:{_slice:[2,4],points:function(){return[this.args.slice(0,2),this.args.slice(2)]},x1:k(0),y1:k(1),x2:k(2),y2:k(3),radius:k(4),clockwise:k(5)}},z.fromArray=function(a,b){if(a===!0)return S;if(a[0]in z.curves)return new z(a[0],a.slice(1),b);switch(a.length){case 2:return new z("lineTo",a,b);case 4:return new z("quadraticCurveTo",a,b);case 6:return new z("bezierCurveTo",a,b)}},H.curves=z.curves;var S=new z("closePath",[]);A=new i(w,{initialize:function(){this.object&&(this._curves=this.object._curves,delete this.object),this._curves=A.parsePath(this._curves,this)},curve:function(a,c){return c===b?this._curves[a]:(c=A.parsePath(c,this,0!==a),this._curves.splice.apply(this._curves,[a,1].concat(c)),this.update())},before:function(a,b,c){return c!==!1&&0===a&&(this._curves[0].name="lineTo"),b=A.parsePath(b,this,0!==a),this._curves.splice.apply(this._curves,[a,0].concat(b)),this.update()},after:function(a,b){return this.before(a+1,b)},remove:function(a){return a===b?w.prototype.remove.call(this):(this._curves.splice(a,1),this.update())},curves:function(a){return a===b?this._curves:(s(a[0])?this._curves=A.parsePath(L.call(arguments),this):this._curves=A.parsePath(a,this),this.update())},push:function(a){return this._curves.push(a),this.update()},add:function(a,b){return this.push(new z(a,b,this))},moveTo:function(a,b){return this.add("moveTo",[a,b])},lineTo:function(a,b){return this.add("lineTo",[a,b])},quadraticCurveTo:function(a,b,c,d){return this.add("quadraticCurveTo",[a,b,c,d])},bezierCurveTo:function(a,b,c,d,e,f){return this.add("bezierCurveTo",[a,b,c,d,e,f])},arcTo:function(a,b,c,d,e,f){return this.add("arcTo",[a,b,c,d,e,!!f])},arc:function(a,b,c,d,e,f){return this.add("arc",[a,b,c,d,e,!!f])},closePath:function(){return this.push(S)},merge:function(a){return this._curves=this._curves.concat(a._curves),this.update()},nativeBounds:function(){for(var a,b,c=this._curves,d=[0,0],e=0,f=c.length,g=1/0,i=1/0,j=-(1/0),k=-(1/0);e1?this._crop=Array.prototype.slice.call(arguments,0):null===a?delete this._crop:this._crop=a,this.update())},smooth:function(a){var c=this.styles,d=f(this.context.context);return a===b?c[d]===b?this.context.context[d]:c[d]:(c[d]=!!a,this.update())},_smooth:!0,draw:function(a){if(this._visible){var b=[this._image,this._x,this._y];this.context.renderer.drawImage(b,a,this.styles,this.matrix,this)}}}),B.props=["image","x","y","width","height","crop"],B.processStyle=!0,B.firstObject=!0,B.propHandlers=[null,u,u,u,u],H.image=function(){var a=new B(arguments);return a.init(),a},H.fx.step.crop=function(a){0===a.state&&(a.start=a.elem._crop,a.start||(a.start=[0,0,a.elem._image.width,a.elem._image.height])),a.elem._crop=[Math.round(a.start[0]+(a.end[0]-a.start[0])*a.pos),Math.round(a.start[1]+(a.end[1]-a.start[1])*a.pos),Math.round(a.start[2]+(a.end[2]-a.start[2])*a.pos),Math.round(a.start[3]+(a.end[3]-a.start[3])*a.pos)]; },C=new i(w,{initialize:function(a){if(this.object){var c=this.object;this._text=c.text+"",this._x=c.x,this._y=c.y,this._font=this._parseFont(c.font||C.font),c.baseline!==b&&(this.styles.textBaseline=c.baseline),c.align!==b&&(this.styles.textAlign=c.align),c.underline!==b&&this.underline(c.underline),this._width=c.width,"block"===c.type&&(this._type=c.type),delete this.object}else{this._text=a[0]+"";var d=1;s(a[3])?this._font=this._parseFont(a[d++]):this._font=this._parseFont(C.font),this._x=a[d++],this._y=a[d++],a[d++]&&this.fill(a[d-1]),a[d]&&this.stroke(a[d])}this._genFont()},_type:"label",_changedText:!0,_lineSpace:0,_genLines:function(){if("label"===this._type)return this;var a=this._text,b=this._lines=[],c=this._lineHeight||this._font.size||10,d=this.context.context,e=this._width||1/0,f=1,g=this.styles.textAlign,h="center"===g?e/2:"right"===g?e:0;return d.save(),this.styleToContext(d),a.split("\n").forEach(function(a){if(d.measureText(a).width>e){var g,i,j,k=a.split(" "),l="";for(i=0,j=k.length;ie?(b.push({text:l,x:h,y:c*f,count:f++}),l=k[i]+" "):l=g;b.push({text:l,x:h,y:c*f,count:f++})}else b.push({text:a,x:h,y:c*f,count:f++})}),this._changedText=!1,d.restore(),this},text:function(a){return this.prop("text",a)},type:function(a){return this.prop("type",a)},x:function(a){return this.prop("x",a)},y:function(a){return this.prop("y",a)},lineSpace:function(a){return this.prop("lineSpace",a)},font:function(a){return a===!0?this.styles.font:a===b?this._font:(j(this._font,this._parseFont(a)),this._genFont())},_setFont:function(a,c){return c===b?this._font[a]:(this._font[a]=c,this._genFont())},_genFont:function(){var a="",b=this._font;return b.italic&&(a+="italic "),b.bold&&(a+="bold "),this.style("font",a+(b.size||10)+"px "+(b.family||"sans-serif"))},_parseFont:function(a){if(q(a))return a.size=H.distance(a.size),a;var b={family:""};return a.split(" ").forEach(function(a){"bold"===a?b.bold=!0:"italic"===a?b.italic=!0:/^\d+(px|pt)?/.test(a)?b.size=H.distance(a):b.family+=" "+a}),""===(b.family=b.family.replace(/^\s*/,"").replace(/\s*$/,""))&&delete b.family,b},family:function(a){return this._setFont("family",a)},size:function(a){return this._setFont("size",a===b?b:H.distance(a))},bold:function(a){return this._setFont("bold",a===b?b:!!a)||!1},italic:function(a){return this._setFont("italic",a===b?b:!!a)||!1},align:function(a){return this.style("textAlign",a)},baseline:function(a){return this.style("textBaseline",a)},underline:function(a){switch(a){case b:return this._underline;case!0:this._underline={color:"auto",height:"auto",visible:!0};break;case!1:this._underline&&(this._underline.visible=!1);break;default:this._underline=a}return this.update()},width:function(a){if(a===b){if("label"===this._type){var c=this.context.context;return c.save(),this.styleToContext(c),a=c.measureText(this._text).width,c.restore(),Math.min(a,this._width||1/0)}if(this._width)return this._width;c.save(),this.styleToContext(c),this._changedText&&this._genLines();var d=0;return this._lines.forEach(function(a){d=Math.max(d,c.measureText(a.text).width)}),c.restore(),d}return this._width=a,this.update()},isPointIn:function(a,b){var c=this.bounds();return a>c.x&&b>c.y&&aa){var g=O.color(c[b]),h=O.color(c[d[e]]);return a=(a-parseFloat(b))/(parseFloat(d[e])-parseFloat(b)),[g[0]+(h[0]-g[0])*a|0,g[1]+(h[1]-g[1])*a|0,g[2]+(h[2]-g[2])*a|0,g[3]+(h[3]-g[3])*a]}b=d[e]}},color:function(a,c){return c===b?this._colors[a]:(this._colors[a]=c,this.update())},colors:function(a){return a===b?this._colors:(this._colors=a,this.update())},reverse:function(){var a,b=this._colors,c={};for(a in b)H.has(b,a)&&(c[1-a]=b[a]);return this._colors=c,this.update()},from:function(a,c,d){return 0===arguments.length,n(a)&&a in H.corners?(this._from=a,this.update()):(p(a)&&(d=a[2],c=a[1],a=a[0]),p(this._from)||(this._from=[]),a!==b&&(this._from[0]=a),c!==b&&(this._from[1]=c),d!==b&&(this._from[2]=d),this.update())},to:function(a,c,d){return 0===arguments.length,n(a)&&a in H.corners?(this._to=a,this.update()):(p(a)&&(d=a[2],c=a[1],a=a[0]),p(this._to)||(this._to=[]),a!==b&&(this._to[0]=a),c!==b&&(this._to[1]=c),d!==b&&(this._to[2]=d),this.update())},clone:function(){return H.clone(this)},update:function(){return this.context.update(),this},_cache:!0,toCanvasStyle:function(a,b){var c,d=this._from,e=this._to;p(d)||(n(d)&&/^\d+(px|pt)?/.test(d)?this._from=d=O.distance(d):d=b.corner(d)),p(e)||(n(d)&&/^\d+(px|pt)?/.test(e)?this._to=e=O.distance(e):e=b.corner(e));var f=this.key(d,e);if(this._cache&&this.context._cache[f])return this.context._cache[f];c="linear"===this._type?a.createLinearGradient(d[0],d[1],e[0],e[1]):a.createRadialGradient(d[0],d[1],d[2]||0,e[0],e[1],e[2]||b.bounds().height);for(var g in this._colors)Object.prototype.hasOwnProperty.call(this._colors,g)&&c.addColorStop(g,this._colors[g]);return this.context._cache[f]=c,c},key:function(a,b){return[this._type,a,b,JSON.stringify(this._colors)].join(",")},toString:function(){return"{ Gradient("+this._type+")["+this._from+","+this._to+"]: "+JSON.stringify(this._colors)+" }"}}),E.gradients={linear:{init:function(){var a=this._from;switch(a){case"vertical":this._from="top",this._to="bottom";break;case"horizontal":this._from="left",this._to="right";case"diag1":this._from="top left",this._to="bottom right";break;case"diag2":this._from="top right",this._to="bottom left"}}},radial:{init:function(a){q(a)&&(this._to||(this._to=[0,0]),this._from||(this._from=[0,0]),a.center&&(this._to=L.call(a.center,0,2)),a.hilite?this._from=[this._to[0]+a.hilite[0],this._to[1]+a.hilite[1],this._from[2]]:a.from||(this._from=L.call(this._to)),a.radius&&(s(a.radius)?this._to[2]=a.radius:this._to[2]=Math.round(Math.sqrt(Math.pow(this._to[0]-a.radius[0],2)+Math.pow(this._to[1]-a.radius[1],2)))),a.startRadius&&(s(a.startRadius)?this._from[2]=a.startRadius:this._from[2]=Math.round(Math.sqrt(Math.pow(this._to[0]-a.startRadius[0],2)+Math.pow(this._to[1]-a.startRadius[1],2)))))},radius:function(a,c){if(a===b)return this._to[2];if(c!==b&&(a=[a,c]),s(a))this._to[2]=O.distance(a);else{var d=this._to[0]-a[0],e=this._to[1]-a[1];this._to[2]=Math.round(Math.sqrt(d*d+e*e))}return this.update()},startRadius:function(a,c){if(a===b)return this._from[2];if(c!==b&&(a=[a,c]),s(a))this._from[2]=O.distance(a);else{var d=this._to[0]-a[0],e=this._to[1]-a[1];this._from[2]=Math.round(Math.sqrt(d*d+e*e))}return this.update()},center:function(a,c){return a===b?this._to.slice(0,2):(c===b&&(c=a[1],a=a[0]),this._to[0]=a,this._to[1]=c,this.update())},hilite:function(a,c){return a===b?[this._from[0]-this._to[0],this._from[1]-this._to[1]]:(c===b&&(c=a[1],a=a[0]),this._from[0]=this._to[0]+a,this._from[1]=this._to[1]+c,this.update())}}};var U={repeat:!0,"no-repeat":!1,"repeat-x":"x","repeat-y":"y"};H.Pattern=F=new i({initialize:function(a,b,c){var d;this._repeat=o(b)?b?"repeat":"no-repeat":n(b)?"repeat-"+b:"repeat",a instanceof Image?this._image=a:n(a)&&("#"===a[0]?this._image=I.getElementById(a.substr(1)):0===a.indexOf("=(7-4*b)/11)return c*c-Math.pow((11-6*b-11*a)/4,2)},elastic:function(a,b){return Math.pow(2,10*--a)*Math.cos(20*a*Math.PI*(b||1)/3)}},["quad","cubic","quart","quint"].forEach(function(a,b){H.easing[a]=function(a){return Math.pow(a,b+2)}});for(var V in H.easing)Object.prototype.hasOwnProperty.call(H.easing,V)&&g(H.easing[V]);H.has=Function.prototype.call.bind(Object.prototype.hasOwnProperty),H.Class=i,H.Bounds=h,H.extend=j,H.argument=k,H.wrap=l,H.trim=m,H.isString=n,H.isBoolean=o,H.isArray=p,H.isObject=q,H.isNumberLike=s,H.isNumber=r,H.isPatternLike=t,H.dashes={shortdash:[4,1],shortdot:[1,1],shortdashdot:[4,1,1,1],shortdashdotdot:[4,1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]},H.corners={left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],center:[.5,.5],"left top":[0,0],"top left":[0,0],"left bottom":[0,1],"bottom left":[0,1],"right top":[1,0],"top right":[1,0],"right bottom":[1,1],"bottom right":[1,1],lt:[0,0],tl:[0,0],lb:[0,1],bl:[0,1],rt:[1,0],tr:[1,0],rb:[1,1],br:[1,1]},H.colors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",chucknorris:"c00000",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},H.clone=function(a){var b=new a.constructor;for(var c in a)H.has(a,c)&&("object"!=typeof a[c]||a[c]instanceof v||a[c]instanceof Image?b[c]=a[c]:b[c]=O.clone(a[c]));return b},H.multiply=function(a,b){return[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1],a[0]*b[2]+a[2]*b[3],a[1]*b[2]+a[3]*b[3],a[0]*b[4]+a[2]*b[5]+a[4],a[1]*b[4]+a[3]*b[5]+a[5]]},H.coordsOfElement=function(b){var c=b.getBoundingClientRect(),d=a.getComputedStyle(b);return{x:c.left+parseInt(d.borderLeftWidth)+parseInt(d.paddingLeft),y:c.top+parseInt(d.borderTopWidth)+parseInt(d.paddingTop)}},H.color=function(a){if(a!==b){if(!n(a))throw"Not a color: "+a.toString();return 0===a.indexOf("rgb")?(a=a.substring(a.indexOf("(")+1,a.length-1).replace(/\s/g,"").split(",").map(function(a){return a.indexOf("%")>0?Math.round(2.55*parseInt(a)):parseInt(a)}),3===a.length&&a.push(1),a):0===a.indexOf("#")?(a=a.substring(1),3===a.length&&(a=a.split("").map(function(a){return a+a}).join("")),[parseInt(a.substring(0,2),16),parseInt(a.substring(2,4),16),parseInt(a.substring(4,6),16),1]):a in H.colors?H.color("#"+H.colors[a]):"rand"===a?[Math.round(255*Math.random()),Math.round(255*Math.random()),Math.round(255*Math.random()),1]:[0,0,0,0]}},H.angleUnit="grad",H.unit="px";var W="pt em in cm mm pc ex ch rem v wvh vmin vmax".split(" "),X={px:1,ch:8,cm:37.78125,em:16,ex:7.15625,in:96,mm:3.765625,pc:16,pt:1.328125,rem:16,v:16,vmax:13.65625,vmin:4.78125,wvh:16};H.snapToPixels=0,H.distance=u,H.Context=v,H.Shape=w,H.Rect=x,H.Circle=y,H.Curve=z,H.Path=A,H.Image=B,H.Text=C,H.TextBlock=D,H.Gradient=E,H.Pattern=F,H.version=Math.PI/3.490658503988659,H.query=function(b,c,d,e){return new v(n(b)?(d||a.document).querySelectorAll(b)[c||0]:b.canvas||b,e)},H.id=function(a,b){return new v(I.getElementById(a),b)},"object"==typeof module&&"object"==typeof module.exports?module.exports=H:"function"==typeof define&&define.amd?define([],function(){return H}):a.Graphics2D=H}("undefined"!=typeof window?window:this);