3 Copyright 2016 Caleb Evans
4 Released under the MIT license
6 (function(g,U,J){"object"===typeof module&&"object"===typeof module.exports?module.exports=function(g,U){return J(g,U)}:J(g,U)})("undefined"!==typeof window?window.jQuery:{},"undefined"!==typeof window?window:this,function(g,U){function J(d){for(var c in d)d.hasOwnProperty(c)&&(this[c]=d[c]);return this}function na(){Z(this,na.baseDefaults)}function ja(d){return"string"===aa(d)}function va(d){return!isNaN(wa(d))&&!isNaN(ba(d))}function L(d){return d&&d.getContext?d.getContext("2d"):null}function ka(d){var c,
7 a,b;for(c in d)d.hasOwnProperty(c)&&(b=d[c],a=aa(b),"string"===a&&va(b)&&"text"!==c&&(d[c]=ba(b)));void 0!==d.text&&(d.text=String(d.text))}function la(d){d=Z({},d);d.masks=d.masks.slice(0);return d}function fa(d,c){var a;d.save();a=la(c.transforms);c.savedTransforms.push(a)}function xa(d,c,a,b){a[b]&&(da(a[b])?c[b]=a[b].call(d,a):c[b]=a[b])}function R(d,c,a){xa(d,c,a,"fillStyle");xa(d,c,a,"strokeStyle");c.lineWidth=a.strokeWidth;a.rounded?c.lineCap=c.lineJoin="round":(c.lineCap=a.strokeCap,c.lineJoin=
8 a.strokeJoin,c.miterLimit=a.miterLimit);a.strokeDash||(a.strokeDash=[]);c.setLineDash&&c.setLineDash(a.strokeDash);c.webkitLineDash=a.strokeDash;c.lineDashOffset=c.webkitLineDashOffset=c.mozDashOffset=a.strokeDashOffset;c.shadowOffsetX=a.shadowX;c.shadowOffsetY=a.shadowY;c.shadowBlur=a.shadowBlur;c.shadowColor=a.shadowColor;c.globalAlpha=a.opacity;c.globalCompositeOperation=a.compositing;a.imageSmoothing&&(c.imageSmoothingEnabled=c.mozImageSmoothingEnabled=a.imageSmoothingEnabled)}function ya(d,c,
9 a){a.mask&&(a.autosave&&fa(d,c),d.clip(),c.transforms.masks.push(a._args))}function W(d,c,a){a.closed&&c.closePath();a.shadowStroke&&0!==a.strokeWidth?(c.stroke(),c.fill(),c.shadowColor="transparent",c.shadowBlur=0,c.stroke()):(c.fill(),"transparent"!==a.fillStyle&&(c.shadowColor="transparent"),0!==a.strokeWidth&&c.stroke());a.closed||c.closePath();a._transformed&&c.restore();a.mask&&(d=H(d),ya(c,d,a))}function Q(d,c,a,b,f){a._toRad=a.inDegrees?E/180:1;a._transformed=!0;c.save();a.fromCenter||a._centered||
10 void 0===b||(void 0===f&&(f=b),a.x+=b/2,a.y+=f/2,a._centered=!0);a.rotate&&za(c,a,null);1===a.scale&&1===a.scaleX&&1===a.scaleY||Aa(c,a,null);(a.translate||a.translateX||a.translateY)&&Ba(c,a,null)}function H(d){var c=ca.dataCache,a;c._canvas===d&&c._data?a=c._data:(a=g.data(d,"jCanvas"),a||(a={canvas:d,layers:[],layer:{names:{},groups:{}},eventHooks:{},intersecting:[],lastIntersected:null,cursor:g(d).css("cursor"),drag:{layer:null,dragging:!1},event:{type:null,x:null,y:null},events:{},transforms:la(oa),
11 savedTransforms:[],animating:!1,animated:null,pixelRatio:1,scaled:!1},g.data(d,"jCanvas",a)),c._canvas=d,c._data=a);return a}function Ca(d,c,a){for(var b in Y.events)Y.events.hasOwnProperty(b)&&(a[b]||a.cursors&&a.cursors[b])&&Da(d,c,a,b);c.events.mouseout||(d.bind("mouseout.jCanvas",function(){var a=c.drag.layer,b;a&&(c.drag={},O(d,c,a,"dragcancel"));for(b=0;b<c.layers.length;b+=1)a=c.layers[b],a._hovered&&d.triggerLayerEvent(c.layers[b],"mouseout");d.drawLayers()}),c.events.mouseout=!0)}function Da(d,
12 c,a,b){Y.events[b](d,c);a._event=!0}function Ea(d,c,a){var b,f,e;if(a.draggable||a.cursors){b=["mousedown","mousemove","mouseup"];for(e=0;e<b.length;e+=1)f=b[e],Da(d,c,a,f);a._event=!0}}function pa(d,c,a,b){d=c.layer.names;b?void 0!==b.name&&ja(a.name)&&a.name!==b.name&&delete d[a.name]:b=a;ja(b.name)&&(d[b.name]=a)}function qa(d,c,a,b){d=c.layer.groups;var f,e,h,g;if(!b)b=a;else if(void 0!==b.groups&&null!==a.groups)for(e=0;e<a.groups.length;e+=1)if(f=a.groups[e],c=d[f]){for(g=0;g<c.length;g+=1)if(c[g]===
13 a){h=g;c.splice(g,1);break}0===c.length&&delete d[f]}if(void 0!==b.groups&&null!==b.groups)for(e=0;e<b.groups.length;e+=1)f=b.groups[e],c=d[f],c||(c=d[f]=[],c.name=f),void 0===h&&(h=c.length),c.splice(h,0,a)}function ra(d,c,a,b,f){b[a]&&c._running&&!c._running[a]&&(c._running[a]=!0,b[a].call(d[0],c,f),c._running[a]=!1)}function O(d,c,a,b,f){if(!(a.disableEvents||a.intangible&&-1!==g.inArray(b,Ua))){if("mouseout"!==b){var e;a.cursors&&(e=a.cursors[b]);-1!==g.inArray(e,V.cursors)&&(e=V.prefix+e);e&&
14 d.css({cursor:e})}ra(d,a,b,a,f);ra(d,a,b,c.eventHooks,f);ra(d,a,b,Y.eventHooks,f)}}function N(d,c,a,b){var f,e=c._layer?a:c;c._args=a;if(c.draggable||c.dragGroups)c.layer=!0,c.draggable=!0;c._method||(c._method=b?b:c.method?g.fn[c.method]:c.type?g.fn[X.drawings[c.type]]:function(){});if(c.layer&&!c._layer){if(a=g(d),b=H(d),f=b.layers,null===e.name||ja(e.name)&&void 0===b.layer.names[e.name])ka(c),e=new J(c),e.canvas=d,e.layer=!0,e._layer=!0,e._running={},e.data=null!==e.data?Z({},e.data):{},e.groups=
15 null!==e.groups?e.groups.slice(0):[],pa(a,b,e),qa(a,b,e),Ca(a,b,e),Ea(a,b,e),c._event=e._event,e._method===g.fn.drawText&&a.measureText(e),null===e.index&&(e.index=f.length),f.splice(e.index,0,e),c._args=e,O(a,b,e,"add")}else c.layer||ka(c);return e}function Fa(d,c){var a,b;for(b=0;b<V.props.length;b+=1)a=V.props[b],void 0!==d[a]&&(d["_"+a]=d[a],V.propsObj[a]=!0,c&&delete d[a])}function Va(d,c,a){var b,f,e,h;for(b in a)if(a.hasOwnProperty(b)&&(f=a[b],da(f)&&(a[b]=f.call(d,c,b)),"object"===aa(f)&&
16 Ga(f))){for(e in f)f.hasOwnProperty(e)&&(h=f[e],void 0!==c[b]&&(c[b+"."+e]=c[b][e],a[b+"."+e]=h));delete a[b]}return a}function Ha(d){var c,a,b=[],f=1;"transparent"===d?d="rgba(0, 0, 0, 0)":d.match(/^([a-z]+|#[0-9a-f]+)$/gi)&&(a=Ia.head,c=a.style.color,a.style.color=d,d=g.css(a,"color"),a.style.color=c);d.match(/^rgb/gi)&&(b=d.match(/(\d+(\.\d+)?)/gi),d.match(/%/gi)&&(f=2.55),b[0]*=f,b[1]*=f,b[2]*=f,b[3]=void 0!==b[3]?ba(b[3]):1);return b}function Wa(d){var c=3,a;"array"!==aa(d.start)&&(d.start=Ha(d.start),
17 d.end=Ha(d.end));d.now=[];if(1!==d.start[3]||1!==d.end[3])c=4;for(a=0;a<c;a+=1)d.now[a]=d.start[a]+(d.end[a]-d.start[a])*d.pos,3>a&&(d.now[a]=Xa(d.now[a]));1!==d.start[3]||1!==d.end[3]?d.now="rgba( "+d.now.join(",")+" )":(d.now.slice(0,3),d.now="rgb( "+d.now.join(",")+" )");d.elem.nodeName?d.elem.style[d.prop]=d.now:d.elem[d.prop]=d.now}function Ya(d){X.touchEvents[d]&&(d=X.touchEvents[d]);return d}function Za(d){Y.events[d]=function(c,a){function b(a){h.x=a.offsetX;h.y=a.offsetY;h.type=f;h.event=
18 a;c.drawLayers({resetFire:!0});a.preventDefault()}var f,e,h;h=a.event;f="mouseover"===d||"mouseout"===d?"mousemove":d;e=Ya(f);a.events[f]||(e!==f?c.bind(f+".jCanvas "+e+".jCanvas",b):c.bind(f+".jCanvas",b),a.events[f]=!0)}}function T(d,c,a){var b,f,e,h;if(a=a._args)d=H(d),b=d.event,null!==b.x&&null!==b.y&&(e=b.x*d.pixelRatio,h=b.y*d.pixelRatio,f=c.isPointInPath(e,h)||c.isPointInStroke&&c.isPointInStroke(e,h)),c=d.transforms,a.eventX=b.x,a.eventY=b.y,a.event=b.event,b=d.transforms.rotate,e=a.eventX,
19 h=a.eventY,0!==b?(a._eventX=e*M(-b)-h*P(-b),a._eventY=h*M(-b)+e*P(-b)):(a._eventX=e,a._eventY=h),a._eventX/=c.scaleX,a._eventY/=c.scaleY,f&&d.intersecting.push(a),a.intersects=!!f}function za(d,c,a){c._toRad=c.inDegrees?E/180:1;d.translate(c.x,c.y);d.rotate(c.rotate*c._toRad);d.translate(-c.x,-c.y);a&&(a.rotate+=c.rotate*c._toRad)}function Aa(d,c,a){1!==c.scale&&(c.scaleX=c.scaleY=c.scale);d.translate(c.x,c.y);d.scale(c.scaleX,c.scaleY);d.translate(-c.x,-c.y);a&&(a.scaleX*=c.scaleX,a.scaleY*=c.scaleY)}
20 function Ba(d,c,a){c.translate&&(c.translateX=c.translateY=c.translate);d.translate(c.translateX,c.translateY);a&&(a.translateX+=c.translateX,a.translateY+=c.translateY)}function Ja(d){for(;0>d;)d+=2*E;return d}function Ka(d,c,a,b){var f,e,h,g,p,v,z;a===b?z=v=0:(v=a.x,z=a.y);b.inDegrees||360!==b.end||(b.end=2*E);b.start*=a._toRad;b.end*=a._toRad;b.start-=E/2;b.end-=E/2;p=E/180;b.ccw&&(p*=-1);f=b.x+b.radius*M(b.start+p);e=b.y+b.radius*P(b.start+p);h=b.x+b.radius*M(b.start);g=b.y+b.radius*P(b.start);
21 ga(d,c,a,b,f,e,h,g);c.arc(b.x+v,b.y+z,b.radius,b.start,b.end,b.ccw);f=b.x+b.radius*M(b.end+p);p=b.y+b.radius*P(b.end+p);e=b.x+b.radius*M(b.end);h=b.y+b.radius*P(b.end);ha(d,c,a,b,e,h,f,p)}function La(d,c,a,b,f,e,h,g){var p,v;b.arrowRadius&&!a.closed&&(v=$a(g-e,h-f),v-=E,d=a.strokeWidth*M(v),p=a.strokeWidth*P(v),a=h+b.arrowRadius*M(v+b.arrowAngle/2),f=g+b.arrowRadius*P(v+b.arrowAngle/2),e=h+b.arrowRadius*M(v-b.arrowAngle/2),b=g+b.arrowRadius*P(v-b.arrowAngle/2),c.moveTo(a-d,f-p),c.lineTo(h-d,g-p),
22 c.lineTo(e-d,b-p),c.moveTo(h-d,g-p),c.lineTo(h+d,g+p),c.moveTo(h,g))}function ga(d,c,a,b,f,e,h,g){b._arrowAngleConverted||(b.arrowAngle*=a._toRad,b._arrowAngleConverted=!0);b.startArrow&&La(d,c,a,b,f,e,h,g)}function ha(d,c,a,b,f,e,h,g){b._arrowAngleConverted||(b.arrowAngle*=a._toRad,b._arrowAngleConverted=!0);b.endArrow&&La(d,c,a,b,f,e,h,g)}function Ma(d,c,a,b){var f,e,h;f=2;ga(d,c,a,b,b.x2+a.x,b.y2+a.y,b.x1+a.x,b.y1+a.y);for(void 0!==b.x1&&void 0!==b.y1&&c.moveTo(b.x1+a.x,b.y1+a.y);;)if(e=b["x"+
23 f],h=b["y"+f],void 0!==e&&void 0!==h)c.lineTo(e+a.x,h+a.y),f+=1;else break;--f;ha(d,c,a,b,b["x"+(f-1)]+a.x,b["y"+(f-1)]+a.y,b["x"+f]+a.x,b["y"+f]+a.y)}function Na(d,c,a,b){var f,e,h,g,p;f=2;ga(d,c,a,b,b.cx1+a.x,b.cy1+a.y,b.x1+a.x,b.y1+a.y);for(void 0!==b.x1&&void 0!==b.y1&&c.moveTo(b.x1+a.x,b.y1+a.y);;)if(e=b["x"+f],h=b["y"+f],g=b["cx"+(f-1)],p=b["cy"+(f-1)],void 0!==e&&void 0!==h&&void 0!==g&&void 0!==p)c.quadraticCurveTo(g+a.x,p+a.y,e+a.x,h+a.y),f+=1;else break;--f;ha(d,c,a,b,b["cx"+(f-1)]+a.x,
24 b["cy"+(f-1)]+a.y,b["x"+f]+a.x,b["y"+f]+a.y)}function Oa(d,c,a,b){var f,e,h,g,p,v,z,D;f=2;e=1;ga(d,c,a,b,b.cx1+a.x,b.cy1+a.y,b.x1+a.x,b.y1+a.y);for(void 0!==b.x1&&void 0!==b.y1&&c.moveTo(b.x1+a.x,b.y1+a.y);;)if(h=b["x"+f],g=b["y"+f],p=b["cx"+e],v=b["cy"+e],z=b["cx"+(e+1)],D=b["cy"+(e+1)],void 0!==h&&void 0!==g&&void 0!==p&&void 0!==v&&void 0!==z&&void 0!==D)c.bezierCurveTo(p+a.x,v+a.y,z+a.x,D+a.y,h+a.x,g+a.y),f+=1,e+=2;else break;--f;e-=2;ha(d,c,a,b,b["cx"+(e+1)]+a.x,b["cy"+(e+1)]+a.y,b["x"+f]+a.x,
25 b["y"+f]+a.y)}function Pa(d,c,a){c*=d._toRad;c-=E/2;return a*M(c)}function Qa(d,c,a){c*=d._toRad;c-=E/2;return a*P(c)}function Ra(d,c,a,b){var f,e,h,g,p,v,z;a===b?p=g=0:(g=a.x,p=a.y);f=1;e=g=v=b.x+g;h=p=z=b.y+p;ga(d,c,a,b,e+Pa(a,b.a1,b.l1),h+Qa(a,b.a1,b.l1),e,h);for(void 0!==b.x&&void 0!==b.y&&c.moveTo(e,h);;)if(e=b["a"+f],h=b["l"+f],void 0!==e&&void 0!==h)g=v,p=z,v+=Pa(a,e,h),z+=Qa(a,e,h),c.lineTo(v,z),f+=1;else break;ha(d,c,a,b,g,p,v,z)}function sa(d,c,a){isNaN(wa(a.fontSize))||(a.fontSize+="px");
26 c.font=a.fontStyle+" "+a.fontSize+" "+a.fontFamily}function ta(d,c,a,b){var f,e;f=ca.propCache;if(f.text===a.text&&f.fontStyle===a.fontStyle&&f.fontSize===a.fontSize&&f.fontFamily===a.fontFamily&&f.maxWidth===a.maxWidth&&f.lineHeight===a.lineHeight)a.width=f.width,a.height=f.height;else{a.width=c.measureText(b[0]).width;for(e=1;e<b.length;e+=1)f=c.measureText(b[e]).width,f>a.width&&(a.width=f);c=d.style.fontSize;d.style.fontSize=a.fontSize;a.height=ba(g.css(d,"fontSize"))*b.length*a.lineHeight;d.style.fontSize=
27 c}}function Sa(d,c){var a=c.maxWidth,b=String(c.text).split("\n"),f=[],e,h,g,p,v;for(g=0;g<b.length;g+=1){p=b[g];v=p.split(" ");e=[];h="";if(1===v.length||d.measureText(p).width<a)e=[p];else{for(p=0;p<v.length;p+=1)d.measureText(h+v[p]).width>a&&(""!==h&&e.push(h),h=""),h+=v[p],p!==v.length-1&&(h+=" ");e.push(h)}f=f.concat(e.join("\n").replace(/( (\n))|( $)/gi,"$2").split("\n"))}return f}var Ia=U.document,Ta=U.Image,ab=U.getComputedStyle,ea=U.Math,wa=U.Number,ba=U.parseFloat,ma,Z=g.extend,ia=g.inArray,
28 aa=function(d){return Object.prototype.toString.call(d).slice(8,-1).toLowerCase()},da=g.isFunction,Ga=g.isPlainObject,E=ea.PI,Xa=ea.round,bb=ea.abs,P=ea.sin,M=ea.cos,$a=ea.atan2,ua=U.Array.prototype.slice,cb=g.event.fix,X={},ca={dataCache:{},propCache:{},imageCache:{}},oa={rotate:0,scaleX:1,scaleY:1,translateX:0,translateY:0,masks:[]},V={},Ua="mousedown mousemove mouseup mouseover mouseout touchstart touchmove touchend".split(" "),Y={events:{},eventHooks:{},future:{}};na.baseDefaults={align:"center",
29 arrowAngle:90,arrowRadius:0,autosave:!0,baseline:"middle",bringToFront:!1,ccw:!1,closed:!1,compositing:"source-over",concavity:0,cornerRadius:0,count:1,cropFromCenter:!0,crossOrigin:null,cursors:null,disableEvents:!1,draggable:!1,dragGroups:null,groups:null,data:null,dx:null,dy:null,end:360,eventX:null,eventY:null,fillStyle:"transparent",fontStyle:"normal",fontSize:"12pt",fontFamily:"sans-serif",fromCenter:!0,height:null,imageSmoothing:!0,inDegrees:!0,intangible:!1,index:null,letterSpacing:null,lineHeight:1,
30 layer:!1,mask:!1,maxWidth:null,miterLimit:10,name:null,opacity:1,r1:null,r2:null,radius:0,repeat:"repeat",respectAlign:!1,restrictDragToAxis:null,rotate:0,rounded:!1,scale:1,scaleX:1,scaleY:1,shadowBlur:0,shadowColor:"transparent",shadowStroke:!1,shadowX:0,shadowY:0,sHeight:null,sides:0,source:"",spread:0,start:0,strokeCap:"butt",strokeDash:null,strokeDashOffset:0,strokeJoin:"miter",strokeStyle:"transparent",strokeWidth:1,sWidth:null,sx:null,sy:null,text:"",translate:0,translateX:0,translateY:0,type:null,
31 visible:!0,width:null,x:0,y:0};ma=new na;J.prototype=ma;Y.extend=function(d){d.name&&(d.props&&Z(ma,d.props),g.fn[d.name]=function a(b){var f,e,h,g;for(e=0;e<this.length;e+=1)if(f=this[e],h=L(f))g=new J(b),N(f,g,b,a),R(f,h,g),d.fn.call(f,h,g);return this},d.type&&(X.drawings[d.type]=d.name));return g.fn[d.name]};g.fn.getEventHooks=function(){var d;d={};0!==this.length&&(d=this[0],d=H(d),d=d.eventHooks);return d};g.fn.setEventHooks=function(d){var c,a;for(c=0;c<this.length;c+=1)g(this[c]),a=H(this[c]),
32 Z(a.eventHooks,d);return this};g.fn.getLayers=function(d){var c,a,b,f,e=[];if(0!==this.length)if(c=this[0],a=H(c),a=a.layers,da(d))for(f=0;f<a.length;f+=1)b=a[f],d.call(c,b)&&e.push(b);else e=a;return e};g.fn.getLayer=function(d){var c,a,b,f;if(0!==this.length)if(c=this[0],a=H(c),c=a.layers,f=aa(d),d&&d.layer)b=d;else if("number"===f)0>d&&(d=c.length+d),b=c[d];else if("regexp"===f)for(a=0;a<c.length;a+=1){if(ja(c[a].name)&&c[a].name.match(d)){b=c[a];break}}else b=a.layer.names[d];return b};g.fn.getLayerGroup=
33 function(d){var c,a,b,f=aa(d);if(0!==this.length)if(c=this[0],"array"===f)b=d;else if("regexp"===f)for(a in c=H(c),c=c.layer.groups,c){if(a.match(d)){b=c[a];break}}else c=H(c),b=c.layer.groups[d];return b};g.fn.getLayerIndex=function(d){var c=this.getLayers();d=this.getLayer(d);return ia(d,c)};g.fn.setLayer=function(d,c){var a,b,f,e,h,K,p;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=H(this[b]),e=g(this[b]).getLayer(d)){pa(a,f,e,c);qa(a,f,e,c);ka(c);for(h in c)c.hasOwnProperty(h)&&(K=c[h],p=aa(K),
34 "object"===p&&Ga(K)?(e[h]=Z({},K),ka(e[h])):"array"===p?e[h]=K.slice(0):"string"===p?0===K.indexOf("+=")?e[h]+=ba(K.substr(2)):0===K.indexOf("-=")?e[h]-=ba(K.substr(2)):!isNaN(K)&&va(K)&&"text"!==h?e[h]=ba(K):e[h]=K:e[h]=K);Ca(a,f,e);Ea(a,f,e);!1===g.isEmptyObject(c)&&O(a,f,e,"change",c)}return this};g.fn.setLayers=function(d,c){var a,b,f,e;for(b=0;b<this.length;b+=1)for(a=g(this[b]),f=a.getLayers(c),e=0;e<f.length;e+=1)a.setLayer(f[e],d);return this};g.fn.setLayerGroup=function(d,c){var a,b,f,e;
35 for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=a.getLayerGroup(d))for(e=0;e<f.length;e+=1)a.setLayer(f[e],c);return this};g.fn.moveLayer=function(d,c){var a,b,f,e,h;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=H(this[b]),e=f.layers,h=a.getLayer(d))h.index=ia(h,e),e.splice(h.index,1),e.splice(c,0,h),0>c&&(c=e.length+c),h.index=c,O(a,f,h,"move");return this};g.fn.removeLayer=function(d){var c,a,b,f,e;for(a=0;a<this.length;a+=1)if(c=g(this[a]),b=H(this[a]),f=c.getLayers(),e=c.getLayer(d))e.index=ia(e,
36 f),f.splice(e.index,1),delete e._layer,pa(c,b,e,{name:null}),qa(c,b,e,{groups:null}),O(c,b,e,"remove");return this};g.fn.removeLayers=function(d){var c,a,b,f,e,h;for(a=0;a<this.length;a+=1){c=g(this[a]);b=H(this[a]);f=c.getLayers(d);for(h=0;h<f.length;h+=1)e=f[h],c.removeLayer(e),--h;b.layer.names={};b.layer.groups={}}return this};g.fn.removeLayerGroup=function(d){var c,a,b,f;if(void 0!==d)for(a=0;a<this.length;a+=1)if(c=g(this[a]),H(this[a]),c.getLayers(),b=c.getLayerGroup(d))for(b=b.slice(0),f=
37 0;f<b.length;f+=1)c.removeLayer(b[f]);return this};g.fn.addLayerToGroup=function(d,c){var a,b,f,e=[c];for(b=0;b<this.length;b+=1)a=g(this[b]),f=a.getLayer(d),f.groups&&(e=f.groups.slice(0),-1===ia(c,f.groups)&&e.push(c)),a.setLayer(f,{groups:e});return this};g.fn.removeLayerFromGroup=function(d,c){var a,b,f,e,h;for(b=0;b<this.length;b+=1)a=g(this[b]),f=a.getLayer(d),f.groups&&(h=ia(c,f.groups),-1!==h&&(e=f.groups.slice(0),e.splice(h,1),a.setLayer(f,{groups:e})));return this};V.cursors=["grab","grabbing",
38 "zoom-in","zoom-out"];V.prefix=function(){var d=ab(Ia.documentElement,"");return"-"+(ua.call(d).join("").match(/-(moz|webkit|ms)-/)||""===d.OLink&&["","o"])[1]+"-"}();g.fn.triggerLayerEvent=function(d,c){var a,b,f;for(b=0;b<this.length;b+=1)a=g(this[b]),f=H(this[b]),(d=a.getLayer(d))&&O(a,f,d,c);return this};g.fn.drawLayer=function(d){var c,a,b;for(c=0;c<this.length;c+=1)b=g(this[c]),(a=L(this[c]))&&(a=b.getLayer(d))&&a.visible&&a._method&&(a._next=null,a._method.call(b,a));return this};g.fn.drawLayers=
39 function(d){var c,a,b=d||{},f,e,h,K,p,v,z,D;(K=b.index)||(K=0);for(c=0;c<this.length;c+=1)if(d=g(this[c]),a=L(this[c])){p=H(this[c]);!1!==b.clear&&d.clearCanvas();a=p.layers;for(h=K;h<a.length;h+=1)if(f=a[h],f.index=h,b.resetFire&&(f._fired=!1),v=d,z=f,e=h+1,z&&z.visible&&z._method&&(z._next=e?e:null,z._method.call(v,z)),f._masks=p.transforms.masks.slice(0),f._method===g.fn.drawImage&&f.visible){D=!0;break}if(D)break;f=p;var m;v=null;for(z=f.intersecting.length-1;0<=z;--z)if(v=f.intersecting[z],v._masks){for(m=
40 v._masks.length-1;0<=m;--m)if(e=v._masks[m],!e.intersects){v.intersects=!1;break}if(v.intersects&&!v.intangible)break}v&&v.intangible&&(v=null);f=v;v=p.event;z=v.type;if(p.drag.layer){var B=d;e=p;var r=z,t,l,x;l=e.drag;x=(m=l.layer)&&m.dragGroups||[];t=e.layers;if("mousemove"===r||"touchmove"===r){if(l.dragging||(l.dragging=!0,m.dragging=!0,m.bringToFront&&(t.splice(m.index,1),m.index=t.push(m)),m._startX=m.x,m._startY=m.y,m._endX=m._eventX,m._endY=m._eventY,O(B,e,m,"dragstart")),l.dragging)for(r=
41 m._eventX-(m._endX-m._startX),t=m._eventY-(m._endY-m._startY),m.dx=r-m.x,m.dy=t-m.y,"y"!==m.restrictDragToAxis&&(m.x=r),"x"!==m.restrictDragToAxis&&(m.y=t),O(B,e,m,"drag"),B=0;B<x.length;B+=1)if(r=x[B],t=e.layer.groups[r],m.groups&&t)for(r=0;r<t.length;r+=1)t[r]!==m&&("y"!==m.restrictDragToAxis&&"y"!==t[r].restrictDragToAxis&&(t[r].x+=m.dx),"x"!==m.restrictDragToAxis&&"x"!==t[r].restrictDragToAxis&&(t[r].y+=m.dy))}else if("mouseup"===r||"touchend"===r)l.dragging&&(m.dragging=!1,l.dragging=!1,O(B,
42 e,m,"dragstop")),e.drag={}}e=p.lastIntersected;null===e||f===e||!e._hovered||e._fired||p.drag.dragging||(p.lastIntersected=null,e._fired=!0,e._hovered=!1,O(d,p,e,"mouseout"),d.css({cursor:p.cursor}));f&&(f[z]||X.mouseEvents[z]&&(z=X.mouseEvents[z]),f._event&&f.intersects&&(p.lastIntersected=f,!(f.mouseover||f.mouseout||f.cursors)||p.drag.dragging||f._hovered||f._fired||(f._fired=!0,f._hovered=!0,O(d,p,f,"mouseover")),f._fired||(f._fired=!0,v.type=null,O(d,p,f,z)),!f.draggable||f.disableEvents||"mousedown"!==
43 z&&"touchstart"!==z||(p.drag.layer=f)));null!==f||p.drag.dragging||d.css({cursor:p.cursor});h===a.length&&(p.intersecting.length=0,p.transforms=la(oa),p.savedTransforms.length=0)}return this};g.fn.addLayer=function(d){var c,a;for(c=0;c<this.length;c+=1)if(a=L(this[c]))a=new J(d),a.layer=!0,N(this[c],a,d);return this};V.props=["width","height","opacity","lineHeight"];V.propsObj={};g.fn.animateLayer=function(){function d(a,b,c){return function(){var d,f;for(f=0;f<V.props.length;f+=1)d=V.props[f],c[d]=
44 c["_"+d];for(var h in c)c.hasOwnProperty(h)&&-1!==h.indexOf(".")&&delete c[h];b.animating&&b.animated!==c||a.drawLayers();c._animating=!1;b.animating=!1;b.animated=null;e[4]&&e[4].call(a[0],c);O(a,b,c,"animateend")}}function c(a,b,c){return function(d,f){var h,g,t=!1;"_"===f.prop[0]&&(t=!0,f.prop=f.prop.replace("_",""),c[f.prop]=c["_"+f.prop]);-1!==f.prop.indexOf(".")&&(h=f.prop.split("."),g=h[0],h=h[1],c[g]&&(c[g][h]=f.now));c._pos!==f.pos&&(c._pos=f.pos,c._animating||b.animating||(c._animating=
45 !0,b.animating=!0,b.animated=c),b.animating&&b.animated!==c||a.drawLayers());e[5]&&e[5].call(a[0],d,f,c);O(a,b,c,"animate",f);t&&(f.prop="_"+f.prop)}}var a,b,f,e=ua.call(arguments,0),h,K;"object"===aa(e[2])?(e.splice(2,0,e[2].duration||null),e.splice(3,0,e[3].easing||null),e.splice(4,0,e[4].complete||null),e.splice(5,0,e[5].step||null)):(void 0===e[2]?(e.splice(2,0,null),e.splice(3,0,null),e.splice(4,0,null)):da(e[2])&&(e.splice(2,0,null),e.splice(3,0,null)),void 0===e[3]?(e[3]=null,e.splice(4,0,
46 null)):da(e[3])&&e.splice(3,0,null));for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=L(this[b]))f=H(this[b]),(h=a.getLayer(e[0]))&&h._method!==g.fn.draw&&(K=Z({},e[1]),K=Va(this[b],h,K),Fa(K,!0),Fa(h),h.style=V.propsObj,g(h).animate(K,{duration:e[2],easing:g.easing[e[3]]?e[3]:null,complete:d(a,f,h),step:c(a,f,h)}),O(a,f,h,"animatestart"));return this};g.fn.animateLayerGroup=function(d){var c,a,b=ua.call(arguments,0),f,e;for(a=0;a<this.length;a+=1)if(c=g(this[a]),f=c.getLayerGroup(d))for(e=0;e<f.length;e+=
47 1)b[0]=f[e],c.animateLayer.apply(c,b);return this};g.fn.delayLayer=function(d,c){var a,b,f,e;c=c||0;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=H(this[b]),e=a.getLayer(d))g(e).delay(c),O(a,f,e,"delay");return this};g.fn.delayLayerGroup=function(d,c){var a,b,f,e,h;c=c||0;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=a.getLayerGroup(d))for(h=0;h<f.length;h+=1)e=f[h],a.delayLayer(e,c);return this};g.fn.stopLayer=function(d,c){var a,b,f,e;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=H(this[b]),e=a.getLayer(d))g(e).stop(c),
48 O(a,f,e,"stop");return this};g.fn.stopLayerGroup=function(d,c){var a,b,f,e,h;for(b=0;b<this.length;b+=1)if(a=g(this[b]),f=a.getLayerGroup(d))for(h=0;h<f.length;h+=1)e=f[h],a.stopLayer(e,c);return this};(function(d){var c;for(c=0;c<d.length;c+=1)g.fx.step[d[c]]=Wa})("color backgroundColor borderColor borderTopColor borderRightColor borderBottomColor borderLeftColor fillStyle outlineColor strokeStyle shadowColor".split(" "));X.touchEvents={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};
49 X.mouseEvents={touchstart:"mousedown",touchend:"mouseup",touchmove:"mousemove"};(function(d){var c;for(c=0;c<d.length;c+=1)Za(d[c])})("click dblclick mousedown mouseup mousemove mouseover mouseout touchstart touchmove touchend contextmenu".split(" "));g.event.fix=function(d){var c,a;d=cb.call(g.event,d);if(c=d.originalEvent)if(a=c.changedTouches,void 0!==d.pageX&&void 0===d.offsetX){if(c=g(d.currentTarget).offset())d.offsetX=d.pageX-c.left,d.offsetY=d.pageY-c.top}else a&&(c=g(d.currentTarget).offset())&&
50 (d.offsetX=a[0].pageX-c.left,d.offsetY=a[0].pageY-c.top);return d};X.drawings={arc:"drawArc",bezier:"drawBezier",ellipse:"drawEllipse","function":"draw",image:"drawImage",line:"drawLine",path:"drawPath",polygon:"drawPolygon",slice:"drawSlice",quadratic:"drawQuadratic",rectangle:"drawRect",text:"drawText",vector:"drawVector",save:"saveCanvas",restore:"restoreCanvas",rotate:"rotateCanvas",scale:"scaleCanvas",translate:"translateCanvas"};g.fn.draw=function c(a){var b,f,e=new J(a);if(X.drawings[e.type]&&
51 "function"!==e.type)this[X.drawings[e.type]](a);else for(b=0;b<this.length;b+=1)if(g(this[b]),f=L(this[b]))e=new J(a),N(this[b],e,a,c),e.visible&&e.fn&&e.fn.call(this[b],f,e);return this};g.fn.clearCanvas=function a(b){var f,e,h=new J(b);for(f=0;f<this.length;f+=1)if(e=L(this[f]))null===h.width||null===h.height?(e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this[f].width,this[f].height),e.restore()):(N(this[f],h,b,a),Q(this[f],e,h,h.width,h.height),e.clearRect(h.x-h.width/2,h.y-h.height/2,
52 h.width,h.height),h._transformed&&e.restore());return this};g.fn.saveCanvas=function b(f){var e,h,g,p,v;for(e=0;e<this.length;e+=1)if(h=L(this[e]))for(p=H(this[e]),g=new J(f),N(this[e],g,f,b),v=0;v<g.count;v+=1)fa(h,p);return this};g.fn.restoreCanvas=function f(e){var h,g,p,v,z;for(h=0;h<this.length;h+=1)if(g=L(this[h]))for(v=H(this[h]),p=new J(e),N(this[h],p,e,f),z=0;z<p.count;z+=1){var D=g,m=v;0===m.savedTransforms.length?m.transforms=la(oa):(D.restore(),m.transforms=m.savedTransforms.pop())}return this};
53 g.fn.rotateCanvas=function e(g){var K,p,v,z;for(K=0;K<this.length;K+=1)if(p=L(this[K]))z=H(this[K]),v=new J(g),N(this[K],v,g,e),v.autosave&&fa(p,z),za(p,v,z.transforms);return this};g.fn.scaleCanvas=function h(g){var p,v,z,D;for(p=0;p<this.length;p+=1)if(v=L(this[p]))D=H(this[p]),z=new J(g),N(this[p],z,g,h),z.autosave&&fa(v,D),Aa(v,z,D.transforms);return this};g.fn.translateCanvas=function K(g){var v,z,D,m;for(v=0;v<this.length;v+=1)if(z=L(this[v]))m=H(this[v]),D=new J(g),N(this[v],D,g,K),D.autosave&&
54 fa(z,m),Ba(z,D,m.transforms);return this};g.fn.drawRect=function p(g){var z,D,m,B,r,t,l,x,F;for(z=0;z<this.length;z+=1)if(D=L(this[z]))m=new J(g),N(this[z],m,g,p),m.visible&&(Q(this[z],D,m,m.width,m.height),R(this[z],D,m),D.beginPath(),m.width&&m.height&&(B=m.x-m.width/2,r=m.y-m.height/2,(x=bb(m.cornerRadius))?(t=m.x+m.width/2,l=m.y+m.height/2,0>m.width&&(F=B,B=t,t=F),0>m.height&&(F=r,r=l,l=F),0>t-B-2*x&&(x=(t-B)/2),0>l-r-2*x&&(x=(l-r)/2),D.moveTo(B+x,r),D.lineTo(t-x,r),D.arc(t-x,r+x,x,3*E/2,2*E,
55 !1),D.lineTo(t,l-x),D.arc(t-x,l-x,x,0,E/2,!1),D.lineTo(B+x,l),D.arc(B+x,l-x,x,E/2,E,!1),D.lineTo(B,r+x),D.arc(B+x,r+x,x,E,3*E/2,!1),m.closed=!0):D.rect(B,r,m.width,m.height)),T(this[z],D,m),W(this[z],D,m));return this};g.fn.drawArc=function v(g){var D,m,B;for(D=0;D<this.length;D+=1)if(m=L(this[D]))B=new J(g),N(this[D],B,g,v),B.visible&&(Q(this[D],m,B,2*B.radius),R(this[D],m,B),m.beginPath(),Ka(this[D],m,B,B),T(this[D],m,B),W(this[D],m,B));return this};g.fn.drawEllipse=function z(g){var m,B,r,t,l;
56 for(m=0;m<this.length;m+=1)if(B=L(this[m]))r=new J(g),N(this[m],r,g,z),r.visible&&(Q(this[m],B,r,r.width,r.height),R(this[m],B,r),t=4/3*r.width,l=r.height,B.beginPath(),B.moveTo(r.x,r.y-l/2),B.bezierCurveTo(r.x-t/2,r.y-l/2,r.x-t/2,r.y+l/2,r.x,r.y+l/2),B.bezierCurveTo(r.x+t/2,r.y+l/2,r.x+t/2,r.y-l/2,r.x,r.y-l/2),T(this[m],B,r),r.closed=!0,W(this[m],B,r));return this};g.fn.drawPolygon=function D(g){var B,r,t,l,x,F,y,A,n,k;for(B=0;B<this.length;B+=1)if(r=L(this[B]))if(t=new J(g),N(this[B],t,g,D),t.visible){Q(this[B],
57 r,t,2*t.radius);R(this[B],r,t);x=2*E/t.sides;F=x/2;l=F+E/2;y=t.radius*M(F);r.beginPath();for(k=0;k<t.sides;k+=1)A=t.x+t.radius*M(l),n=t.y+t.radius*P(l),r.lineTo(A,n),t.concavity&&(A=t.x+(y+-y*t.concavity)*M(l+F),n=t.y+(y+-y*t.concavity)*P(l+F),r.lineTo(A,n)),l+=x;T(this[B],r,t);t.closed=!0;W(this[B],r,t)}return this};g.fn.drawSlice=function m(B){var r,t,l,x,F;for(r=0;r<this.length;r+=1)if(g(this[r]),t=L(this[r]))l=new J(B),N(this[r],l,B,m),l.visible&&(Q(this[r],t,l,2*l.radius),R(this[r],t,l),l.start*=
58 l._toRad,l.end*=l._toRad,l.start-=E/2,l.end-=E/2,l.start=Ja(l.start),l.end=Ja(l.end),l.end<l.start&&(l.end+=2*E),x=(l.start+l.end)/2,F=l.radius*l.spread*M(x),x=l.radius*l.spread*P(x),l.x+=F,l.y+=x,t.beginPath(),t.arc(l.x,l.y,l.radius,l.start,l.end,l.ccw),t.lineTo(l.x,l.y),T(this[r],t,l),l.closed=!0,W(this[r],t,l));return this};g.fn.drawLine=function B(g){var t,l,x;for(t=0;t<this.length;t+=1)if(l=L(this[t]))x=new J(g),N(this[t],x,g,B),x.visible&&(Q(this[t],l,x),R(this[t],l,x),l.beginPath(),Ma(this[t],
59 l,x,x),T(this[t],l,x),W(this[t],l,x));return this};g.fn.drawQuadratic=function r(g){var l,x,F;for(l=0;l<this.length;l+=1)if(x=L(this[l]))F=new J(g),N(this[l],F,g,r),F.visible&&(Q(this[l],x,F),R(this[l],x,F),x.beginPath(),Na(this[l],x,F,F),T(this[l],x,F),W(this[l],x,F));return this};g.fn.drawBezier=function t(g){var x,F,y;for(x=0;x<this.length;x+=1)if(F=L(this[x]))y=new J(g),N(this[x],y,g,t),y.visible&&(Q(this[x],F,y),R(this[x],F,y),F.beginPath(),Oa(this[x],F,y,y),T(this[x],F,y),W(this[x],F,y));return this};
60 g.fn.drawVector=function l(g){var F,y,A;for(F=0;F<this.length;F+=1)if(y=L(this[F]))A=new J(g),N(this[F],A,g,l),A.visible&&(Q(this[F],y,A),R(this[F],y,A),y.beginPath(),Ra(this[F],y,A,A),T(this[F],y,A),W(this[F],y,A));return this};g.fn.drawPath=function x(g){var y,A,n,k,w;for(y=0;y<this.length;y+=1)if(A=L(this[y]))if(n=new J(g),N(this[y],n,g,x),n.visible){Q(this[y],A,n);R(this[y],A,n);A.beginPath();for(k=1;;)if(w=n["p"+k],void 0!==w)w=new J(w),"line"===w.type?Ma(this[y],A,n,w):"quadratic"===w.type?
61 Na(this[y],A,n,w):"bezier"===w.type?Oa(this[y],A,n,w):"vector"===w.type?Ra(this[y],A,n,w):"arc"===w.type&&Ka(this[y],A,n,w),k+=1;else break;T(this[y],A,n);W(this[y],A,n)}return this};g.fn.drawText=function F(y){var A,n,k,w,C,u,G,S,I,H;for(A=0;A<this.length;A+=1)if(g(this[A]),n=L(this[A]))if(k=new J(y),w=N(this[A],k,y,F),k.visible){n.textBaseline=k.baseline;n.textAlign=k.align;sa(this[A],n,k);C=null!==k.maxWidth?Sa(n,k):k.text.toString().split("\n");ta(this[A],n,k,C);w&&(w.width=k.width,w.height=k.height);
62 Q(this[A],n,k,k.width,k.height);R(this[A],n,k);G=k.x;"left"===k.align?k.respectAlign?k.x+=k.width/2:G-=k.width/2:"right"===k.align&&(k.respectAlign?k.x-=k.width/2:G+=k.width/2);if(k.radius)for(G=ba(k.fontSize),null===k.letterSpacing&&(k.letterSpacing=G/500),w=0;w<C.length;w+=1){n.save();n.translate(k.x,k.y);u=C[w];k.flipArcText&&(u=u.split(""),u.reverse(),u=u.join(""));S=u.length;n.rotate(-(E*k.letterSpacing*(S-1))/2);for(H=0;H<S;H+=1)I=u[H],0!==H&&n.rotate(E*k.letterSpacing),n.save(),n.translate(0,
63 -k.radius),k.flipArcText&&n.scale(-1,-1),n.fillText(I,0,0),"transparent"!==k.fillStyle&&(n.shadowColor="transparent"),0!==k.strokeWidth&&n.strokeText(I,0,0),n.restore();k.radius-=G;k.letterSpacing+=G/(1E3*E);n.restore()}else for(w=0;w<C.length;w+=1)u=C[w],S=k.y+w*k.height/C.length-(C.length-1)*k.height/C.length/2,n.shadowColor=k.shadowColor,n.fillText(u,G,S),"transparent"!==k.fillStyle&&(n.shadowColor="transparent"),0!==k.strokeWidth&&n.strokeText(u,G,S);S=0;"top"===k.baseline?S+=k.height/2:"bottom"===
64 k.baseline&&(S-=k.height/2);k._event&&(n.beginPath(),n.rect(k.x-k.width/2,k.y-k.height/2+S,k.width,k.height),T(this[A],n,k),n.closePath());k._transformed&&n.restore()}ca.propCache=k;return this};g.fn.measureText=function(g){var y,A;y=this.getLayer(g);if(!y||y&&!y._layer)y=new J(g);if(g=L(this[0]))sa(this[0],g,y),A=Sa(g,y),ta(this[0],g,y,A);return y};g.fn.drawImage=function y(A){function n(k,n,y,q,u){return function(){var w=g(k);null===q.width&&null===q.sWidth&&(q.width=q.sWidth=I.width);null===q.height&&
65 null===q.sHeight&&(q.height=q.sHeight=I.height);u&&(u.width=q.width,u.height=q.height);null!==q.sWidth&&null!==q.sHeight&&null!==q.sx&&null!==q.sy?(null===q.width&&(q.width=q.sWidth),null===q.height&&(q.height=q.sHeight),q.cropFromCenter&&(q.sx+=q.sWidth/2,q.sy+=q.sHeight/2),0>q.sy-q.sHeight/2&&(q.sy=q.sHeight/2),q.sy+q.sHeight/2>I.height&&(q.sy=I.height-q.sHeight/2),0>q.sx-q.sWidth/2&&(q.sx=q.sWidth/2),q.sx+q.sWidth/2>I.width&&(q.sx=I.width-q.sWidth/2),Q(k,n,q,q.width,q.height),R(k,n,q),n.drawImage(I,
66 q.sx-q.sWidth/2,q.sy-q.sHeight/2,q.sWidth,q.sHeight,q.x-q.width/2,q.y-q.height/2,q.width,q.height)):(Q(k,n,q,q.width,q.height),R(k,n,q),n.drawImage(I,q.x-q.width/2,q.y-q.height/2,q.width,q.height));n.beginPath();n.rect(q.x-q.width/2,q.y-q.height/2,q.width,q.height);T(k,n,q);n.closePath();q._transformed&&n.restore();ya(n,y,q);q.layer?O(w,y,u,"load"):q.load&&q.load.call(w[0],u);q.layer&&(u._masks=y.transforms.masks.slice(0),q._next&&w.drawLayers({clear:!1,resetFire:!0,index:q._next}))}}var k,w,C,u,
67 G,S,I,E,M,P=ca.imageCache;for(w=0;w<this.length;w+=1)if(k=this[w],C=L(this[w]))u=H(this[w]),G=new J(A),S=N(this[w],G,A,y),G.visible&&(M=G.source,E=M.getContext,M.src||E?I=M:M&&(P[M]&&P[M].complete?I=P[M]:(I=new Ta,M.match(/^data:/i)||(I.crossOrigin=G.crossOrigin),I.src=M,P[M]=I)),I&&(I.complete||E?n(k,C,u,G,S)():(I.onload=n(k,C,u,G,S),I.src=I.src)));return this};g.fn.createPattern=function(y){function A(){u=k.createPattern(C,w.repeat);w.load&&w.load.call(n[0],u)}var n=this,k,w,C,u,G;(k=L(n[0]))?(w=
68 new J(y),G=w.source,da(G)?(C=g("<canvas />")[0],C.width=w.width,C.height=w.height,y=L(C),G.call(C,y),A()):(y=G.getContext,G.src||y?C=G:(C=new Ta,G.match(/^data:/i)||(C.crossOrigin=w.crossOrigin),C.src=G),C.complete||y?A():(C.onload=A,C.src=C.src))):u=null;return u};g.fn.createGradient=function(g){var A,n=[],k,w,C,u,G,H,I;g=new J(g);if(A=L(this[0])){g.x1=g.x1||0;g.y1=g.y1||0;g.x2=g.x2||0;g.y2=g.y2||0;A=null!==g.r1&&null!==g.r2?A.createRadialGradient(g.x1,g.y1,g.r1,g.x2,g.y2,g.r2):A.createLinearGradient(g.x1,
69 g.y1,g.x2,g.y2);for(u=1;void 0!==g["c"+u];u+=1)void 0!==g["s"+u]?n.push(g["s"+u]):n.push(null);k=n.length;null===n[0]&&(n[0]=0);null===n[k-1]&&(n[k-1]=1);for(u=0;u<k;u+=1){if(null!==n[u]){H=1;I=0;w=n[u];for(G=u+1;G<k;G+=1)if(null!==n[G]){C=n[G];break}else H+=1;w>C&&(n[G]=n[u])}else null===n[u]&&(I+=1,n[u]=w+(C-w)/H*I);A.addColorStop(n[u],g["c"+(u+1)])}}else A=null;return A};g.fn.setPixels=function A(g){var k,w,C,u,G,H,I,E,M;for(w=0;w<this.length;w+=1)if(k=this[w],C=L(k)){u=new J(g);N(k,u,g,A);Q(this[w],
70 C,u,u.width,u.height);if(null===u.width||null===u.height)u.width=k.width,u.height=k.height,u.x=u.width/2,u.y=u.height/2;if(0!==u.width&&0!==u.height){H=C.getImageData(u.x-u.width/2,u.y-u.height/2,u.width,u.height);I=H.data;M=I.length;if(u.each)for(E=0;E<M;E+=4)G={r:I[E],g:I[E+1],b:I[E+2],a:I[E+3]},u.each.call(k,G,u),I[E]=G.r,I[E+1]=G.g,I[E+2]=G.b,I[E+3]=G.a;C.putImageData(H,u.x-u.width/2,u.y-u.height/2);C.restore()}}return this};g.fn.getCanvasImage=function(g,n){var k,w=null;0!==this.length&&(k=this[0],
71 k.toDataURL&&(void 0===n&&(n=1),w=k.toDataURL("image/"+g,n)));return w};g.fn.detectPixelRatio=function(A){var n,k,w,C,u,G,E;for(k=0;k<this.length;k+=1)n=this[k],g(this[k]),w=L(n),E=H(this[k]),E.scaled||(C=U.devicePixelRatio||1,u=w.webkitBackingStorePixelRatio||w.mozBackingStorePixelRatio||w.msBackingStorePixelRatio||w.oBackingStorePixelRatio||w.backingStorePixelRatio||1,C/=u,1!==C&&(u=n.width,G=n.height,n.width=u*C,n.height=G*C,n.style.width=u+"px",n.style.height=G+"px",w.scale(C,C)),E.pixelRatio=
72 C,E.scaled=!0,A&&A.call(n,C));return this};Y.clearCache=function(){for(var g in ca)ca.hasOwnProperty(g)&&(ca[g]={})};g.support.canvas=void 0!==g("<canvas />")[0].getContext;Z(Y,{defaults:ma,setGlobalProps:R,transformShape:Q,detectEvents:T,closePath:W,setCanvasFont:sa,measureText:ta});g.jCanvas=Y;g.jCanvasObject=J});