diff --git a/enjoyhint.js b/enjoyhint.js index e9d0893..74f5ab4 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -249,11 +249,19 @@ var EnjoyHint = function (_options) { }); } - var max_habarites = Math.max($element.outerWidth(), $element.outerHeight()); - var radius = step_data.radius || Math.round(max_habarites / 2) + 5; - var offset = $element.offset(); var w = $element.outerWidth(); var h = $element.outerHeight(); + + if (w == 0) { + w = $element[0].getBoundingClientRect().width; + } + if (h == 0) { + h = $element[0].getBoundingClientRect().height; + } + + var max_habarites = Math.max(w, h); + var radius = step_data.radius || Math.round(max_habarites / 2) + 5; + var offset = $element.offset(); var shape_margin = (step_data.margin !== undefined) ? step_data.margin : 10; var coords = { @@ -1573,4 +1581,4 @@ a.children=[];for(var b=this.getChildren(),c=b.length,d=0;c>d;d++){var e=b[d];a. * @author Ariel Flesler * @version 2.1.2 */ -;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1=f[g]?0:Math.min(f[g],n));!a&&1",{class:b.cl.enjoy_hint+" "+b.cl.svg_transparent}).appendTo(r),b.enjoyhint_svg_wrapper=a("
",{class:b.cl.svg_wrapper+" "+b.cl.svg_transparent}).appendTo(b.enjoyhint),b.$stage_container=a('
').appendTo(b.enjoyhint),b.$canvas=a('').appendTo(b.enjoyhint),b.$svg=a('').appendTo(b.enjoyhint_svg_wrapper);var t=a(p("defs")),u=a(p("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(p("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20"}));t.append(u.append(v)).appendTo(b.$svg),b.kinetic_stage=new Kinetic.Stage({container:b.cl.kinetic_container,width:b.canvas_size.w,height:b.canvas_size.h,scaleX:1}),b.layer=new Kinetic.Layer,b.rect=new Kinetic.Rect({fill:"rgba(0,0,0,0.6)",width:b.canvas_size.w,height:b.canvas_size.h});var w=a("
",{class:b.cl.disable_events_element}).appendTo(b.enjoyhint),x=w.clone().appendTo(b.enjoyhint),y=w.clone().appendTo(b.enjoyhint),z=w.clone().appendTo(b.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),b.$skip_btn=a("
",{class:b.cl.skip_btn}).appendTo(b.enjoyhint).html("Skip").click(function(a){b.hide(),b.options.onSkipClick()}),b.$next_btn=a("
",{class:b.cl.next_btn}).appendTo(b.enjoyhint).html("Next").click(function(a){b.options.onNextClick()}),b.$close_btn=a("
",{class:b.cl.close_btn}).appendTo(b.enjoyhint).html("").click(function(a){b.hide(),b.options.onSkipClick()}),b.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;b.shape=new Kinetic.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fillStyle="red",b.fill(),b.globalCompositeOperation=c}}),b.shape.radius=B,b.layer.add(b.rect),b.layer.add(b.shape),b.kinetic_stage.add(b.layer),a(window).on("resize",function(){if(!a(b.stepData.enjoyHintElementSelector).is(":visible"))return b.stopFunction(),void a(window).off("resize");k=window.innerWidth,l=window.innerHeight;var o=a(b.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();b.shape.attrs.center_x=Math.round(o.left+o.width/2),b.shape.attrs.center_y=Math.round(o.top+o.height/2),b.shape.attrs.width=o.width+11,b.shape.attrs.height=o.height+11;var p=window.innerWidth,q=window.innerHeight,r=p/m,s=q/n;if(b.kinetic_stage.setAttr("width",m*r),b.kinetic_stage.setAttr("height",n*s),null!=b.stepData){if(k=window.innerWidth,l=window.innerHeight,g||(g=b.shape.attrs.center_x,h=b.shape.attrs.center_y),!e){e=[];var t=a("#enjoyhint_arrpw_line").attr("d");e.push(t.substr(1).split(",")[0]),e.push(t.substr(t.indexOf("Q")+1).split(",")[0]),e.push(t.split(" ")[2].split(",")[0]),f=[],f.push(t.split(",")[1].split(" ")[0]),f.push(t.split(",")[2].split(" ")[0]),f.push(t.split(",")[3])}var u=a(".enjoy_hint_label");c||(c=u[0].getBoundingClientRect().left,d=u[0].getBoundingClientRect().top);var v=a(".enjoyhint_skip_btn");i||(i=v[0].getBoundingClientRect().left,j=v[0].getBoundingClientRect().top),u.css("left",window.innerWidth/2-u.outerWidth()/2);var w=u[0].getBoundingClientRect();if(window.innerWidth<640)a("#enjoyhint_arrpw_line").hide(),u.css("top",window.innerHeight/2-u.outerHeight()/2);else{a("#enjoyhint_arrpw_line").show(),u.css("top",d);var x,y,z,A,B=w.left+w.width/2=640){var d=c.x_from||0,e=c.y_from||0,f=c.x_to||0,g=c.y_to||0,h=c.by_top_side,i=0,j=0;h?e>=g?(j=g,i=d):(j=e,i=f):e>=g?(j=e,i=f):(j=g,i=d)}c.text||"";b.enjoyhint.addClass(b.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var c="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;b.$svg.append(p("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:c,id:"enjoyhint_arrpw_line"})),b.enjoyhint.removeClass(b.cl.svg_transparent)},b.options.animation_time/2)},b.getLabelElement=function(c){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:c.y+"px",left:c.x+"px"}).html(c.text).appendTo(b.enjoyhint)},b.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(jQuery),b.renderLabelWithShape=function(c){function d(b){return"MD-DIALOG"===b.tagName?b:"undefined"==typeof b.tagName?null:d(a(b).parent()[0])}function e(a,b,c){H=a,I=b,G=c}function f(a,b,c,d,f){var g=[];g=L?a:O?b:N?c:P?d:f,g&&e(g[0],g[1],g[2])}b.stepData=c;var g=d(a(b.stepData.enjoyHintElementSelector)[0]);null!=g&&a(g).on("dialogClosing",function(){b.stopFunction()}),b.resetComponentStuff();var h=c.shape||"rect",i={},j=0,k=0,l={top:c.top||0,bottom:c.bottom||0,left:c.left||0,right:c.right||0};switch(h){case"circle":j=k=c.radius;var m={top:c.center_y-k+l.top,bottom:c.center_y+k-l.bottom,left:c.center_x-j+l.left,right:c.center_x+j-l.right},n=m.right-m.left,o=m.bottom-m.top;c.radius=Math.round(Math.min(n,o)/2),j=k=Math.round(c.radius/2);var p=Math.round(n/2),q=Math.round(o/2);c.center_x=m.left+p,c.center_y=m.top+q,i=b.renderCircle({x:c.center_x,y:c.center_y,r:c.radius});break;case"rect":j=Math.round(c.width/2),k=Math.round(c.height/2);var m={top:c.center_y-k+l.top,bottom:c.center_y+k-l.bottom,left:c.center_x-j+l.left,right:c.center_x+j-l.right};c.width=m.right-m.left,c.height=m.bottom-m.top,j=Math.round(c.width/2),k=Math.round(c.height/2),c.center_x=m.left+j,c.center_y=m.top+k,i=b.renderRect({x:c.center_x,y:c.center_y,w:c.width,h:c.height,r:c.radius},.2)}var r={w:b.enjoyhint.width(),h:b.enjoyhint.height()},s=b.getLabelElement({x:0,y:0,text:c.text}),t=s.outerWidth(),u=s.outerHeight();s.remove();var v=c.center_y-k,w=r.h-(c.center_y+k),x=(c.center_x-j,r.w-(c.center_x+j),r.w-c.center_x=i.x,K=E.righti.x,E.righti.right,E.bottomi.bottom,N=E.bottom>=i.y&&E.top<=i.y,O=E.bottom<=i.y&&!L,P=E.top>=i.y&&!M;if(J)if(L)e("bottom","top","top");else{if(!M)return;e("top","bottom","bottom")}else K?f(["right","top","top"],["bottom","left","bottom"],["right","left","top"],["top","left","top"],["right","bottom","bottom"]):f(["left","top","top"],["bottom","right","bottom"],["left","right","top"],["top","right","top"],["left","bottom","bottom"]);var Q=E.conn[H],R=i.conn[I],S="top"==G;b.renderArrow({x_from:Q.x,y_from:Q.y,x_to:window.innerWidth<640?i.left+(i.left>0):R.x,y_to:window.innerWidth<640?i.conn.left.y:R.y,by_top_side:S})},b.clear=function(){b.ctx.clearRect(0,0,3e3,2e3)},this})},set:function(a){return this.each(function(){this.enjoyhint_obj.setValue(a)}),this},show:function(){return this.each(function(){this.enjoyhint_obj.show()}),this},hide:function(){return this.each(function(){this.enjoyhint_obj.hide()}),this},hide_next:function(){return this.each(function(){this.enjoyhint_obj.hideNextBtn()}),this},show_next:function(){return this.each(function(){this.enjoyhint_obj.showNextBtn()}),this},hide_skip:function(){return this.each(function(){this.enjoyhint_obj.hideSkipBtn()}),this},show_skip:function(){return this.each(function(){this.enjoyhint_obj.showSkipBtn()}),this},render_circle:function(a,b,c){return this.each(function(){this.enjoyhint_obj.renderCircle(a,b,c)}),this},render_label:function(a,b,c){return this.each(function(){this.enjoyhint_obj.renderLabel(a,b,c)}),this},render_label_with_shape:function(a,c){return this.each(function(){b.stopFunction=c,this.enjoyhint_obj.renderLabelWithShape(a)}),this},redo_events_near_rect:function(a){b.disableEventsNearRect({top:a.top,bottom:a.bottom,left:a.left,right:a.right})},clear:function(){return this.each(function(){this.enjoyhint_obj.clear()}),this},close:function(a){return this.each(function(){this.enjoyhint_obj.closePopdown()}),this}};a.fn.enjoyhint=function(b){return o[b]?o[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?(a.error("Method "+b+" does not exist on $.numinput"),this):o.init.apply(this,arguments)}}(window.jQuery);var Kinetic={};!function(a){var b=Math.PI/180;Kinetic={version:"5.2.0",stages:[],idCounter:0,ids:{},names:{},shapes:{},listenClickTap:!1,inDblClickWindow:!1,enableTrace:!1,traceArrMax:100,dblClickWindow:400,pixelRatio:void 0,dragDistance:0,angleDeg:!0,showWarnings:!0,Filters:{},Node:function(a){this._init(a)},Shape:function(a){this.__init(a)},Container:function(a){this.__init(a)},Stage:function(a){this.___init(a)},BaseLayer:function(a){this.___init(a)},Layer:function(a){this.____init(a)},FastLayer:function(a){this.____init(a)},Group:function(a){this.___init(a)},isDragging:function(){var a=Kinetic.DD;return!!a&&a.isDragging},isDragReady:function(){var a=Kinetic.DD;return!!a&&!!a.node},_addId:function(a,b){void 0!==b&&(this.ids[b]=a)},_removeId:function(a){void 0!==a&&delete this.ids[a]},_addName:function(a,b){if(void 0!==b)for(var c=b.split(/\s/g),d=0;d"),Kinetic.window=Kinetic.document.createWindow(),Kinetic.window.Image=d.Image,Kinetic._nodeCanvas=d}return Kinetic.root=a,void(module.exports=c)}"function"==typeof define&&define.amd&&define(b),Kinetic.document=document,Kinetic.window=window,Kinetic.root=a}(this,function(){return Kinetic}),function(){Kinetic.Collection=function(){var a=[].slice.call(arguments),b=a.length,c=0;for(this.length=b;b>c;c++)this[c]=a[c];return this},Kinetic.Collection.prototype=[],Kinetic.Collection.prototype.each=function(a){for(var b=0;ba;a++)b.push(this[a]);return b},Kinetic.Collection.toCollection=function(a){var b,c=new Kinetic.Collection,d=a.length;for(b=0;d>b;b++)c.push(a[b]);return c},Kinetic.Collection._mapMethod=function(a){Kinetic.Collection.prototype[a]=function(){var b,c=this.length,d=[].slice.call(arguments);for(b=0;c>b;b++)this[b][a].apply(this[b],d);return this}},Kinetic.Collection.mapMethods=function(a){var b=a.prototype;for(var c in b)Kinetic.Collection._mapMethod(c)},Kinetic.Transform=function(a){this.m=a&&a.slice()||[1,0,0,1,0,0]},Kinetic.Transform.prototype={copy:function(){return new Kinetic.Transform(this.m)},point:function(a){var b=this.m;return{x:b[0]*a.x+b[2]*a.y+b[4],y:b[1]*a.x+b[3]*a.y+b[5]}},translate:function(a,b){return this.m[4]+=this.m[0]*a+this.m[2]*b,this.m[5]+=this.m[1]*a+this.m[3]*b,this},scale:function(a,b){return this.m[0]*=a,this.m[1]*=a,this.m[2]*=b,this.m[3]*=b,this},rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=this.m[0]*b+this.m[2]*c,e=this.m[1]*b+this.m[3]*c,f=this.m[0]*-c+this.m[2]*b,g=this.m[1]*-c+this.m[3]*b;return this.m[0]=d,this.m[1]=e,this.m[2]=f,this.m[3]=g,this},getTranslation:function(){return{x:this.m[4],y:this.m[5]}},skew:function(a,b){var c=this.m[0]+this.m[2]*b,d=this.m[1]+this.m[3]*b,e=this.m[2]+this.m[0]*a,f=this.m[3]+this.m[1]*a;return this.m[0]=c,this.m[1]=d,this.m[2]=e,this.m[3]=f,this},multiply:function(a){var b=this.m[0]*a.m[0]+this.m[2]*a.m[1],c=this.m[1]*a.m[0]+this.m[3]*a.m[1],d=this.m[0]*a.m[2]+this.m[2]*a.m[3],e=this.m[1]*a.m[2]+this.m[3]*a.m[3],f=this.m[0]*a.m[4]+this.m[2]*a.m[5]+this.m[4],g=this.m[1]*a.m[4]+this.m[3]*a.m[5]+this.m[5];return this.m[0]=b,this.m[1]=c,this.m[2]=d,this.m[3]=e,this.m[4]=f,this.m[5]=g,this},invert:function(){var a=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),b=this.m[3]*a,c=-this.m[1]*a,d=-this.m[2]*a,e=this.m[0]*a,f=a*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),g=a*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=b,this.m[1]=c,this.m[2]=d,this.m[3]=e,this.m[4]=f,this.m[5]=g,this},getMatrix:function(){return this.m},setAbsolutePosition:function(a,b){var c=this.m[0],d=this.m[1],e=this.m[2],f=this.m[3],g=this.m[4],h=this.m[5],i=(c*(b-h)-d*(a-g))/(c*f-d*e),j=(a-g-e*i)/c;return this.translate(j,i)}};var a="2d",b="[object Array]",c="[object Number]",d="[object String]",e=Math.PI/180,f=180/Math.PI,g="#",h="",i="0",j="Kinetic warning: ",k="Kinetic error: ",l="rgb(",m={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},n=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;Kinetic.Util={_isElement:function(a){return!(!a||1!=a.nodeType)},_isFunction:function(a){return!!(a&&a.constructor&&a.call&&a.apply)},_isObject:function(a){return!!a&&a.constructor==Object},_isArray:function(a){return Object.prototype.toString.call(a)==b},_isNumber:function(a){return Object.prototype.toString.call(a)==c},_isString:function(a){return Object.prototype.toString.call(a)==d},_throttle:function(a,b,c){var d,e,f,g=null,h=0,i=c||{},j=function(){h=i.leading===!1?0:(new Date).getTime(),g=null,f=a.apply(d,e),d=e=null};return function(){var c=(new Date).getTime();h||i.leading!==!1||(h=c);var k=b-(c-h);return d=this,e=arguments,0>=k?(clearTimeout(g),g=null,h=c,f=a.apply(d,e),d=e=null):g||i.trailing===!1||(g=setTimeout(j,k)),f}},_hasMethods:function(a){var b,c=[];for(b in a)this._isFunction(a[b])&&c.push(b);return c.length>0},createCanvasElement:function(){var a=Kinetic.document.createElement("canvas");try{a.style=a.style||{}}catch(b){}return a},isBrowser:function(){return"object"!=typeof exports},_isInDocument:function(a){for(;a=a.parentNode;)if(a==Kinetic.document)return!0;return!1},_simplifyArray:function(a){var b,c,d=[],e=a.length,f=Kinetic.Util;for(b=0;e>b;b++)c=a[b],f._isNumber(c)?c=Math.round(1e3*c)/1e3:f._isString(c)||(c=c.toString()),d.push(c);return d},_getImage:function(b,c){var d,e;if(b)if(this._isElement(b))c(b);else if(this._isString(b))d=new Kinetic.window.Image,d.onload=function(){c(d)},d.src=b;else if(b.data){e=Kinetic.Util.createCanvasElement(),e.width=b.width,e.height=b.height;var f=e.getContext(a);f.putImageData(b,0,0),this._getImage(e.toDataURL(),c)}else c(null);else c(null)},_getRGBAString:function(a){var b=a.red||0,c=a.green||0,d=a.blue||0,e=a.alpha||1;return["rgba(",b,",",c,",",d,",",e,")"].join(h)},_rgbToHex:function(a,b,c){return((1<<24)+(a<<16)+(b<<8)+c).toString(16).slice(1)},_hexToRgb:function(a){a=a.replace(g,h);var b=parseInt(a,16);return{r:b>>16&255,g:b>>8&255,b:255&b}},getRandomColor:function(){for(var a=(16777215*Math.random()<<0).toString(16);a.length<6;)a=i+a;return g+a},get:function(a,b){return void 0===a?b:a},getRGB:function(a){var b;return a in m?(b=m[a],{r:b[0],g:b[1],b:b[2]}):a[0]===g?this._hexToRgb(a.substring(1)):a.substr(0,4)===l?(b=n.exec(a.replace(/ /g,"")),{r:parseInt(b[1],10),g:parseInt(b[2],10),b:parseInt(b[3],10)}):{r:0,g:0,b:0}},_merge:function(a,b){var c=this._clone(b);for(var d in a)c[d]=this._isObject(a[d])?this._merge(a[d],c[d]):a[d];return c},cloneObject:function(a){var b={};for(var c in a)b[c]=this._isObject(a[c])?this.cloneObject(a[c]):this._isArray(a[c])?this.cloneArray(a[c]):a[c];return b},cloneArray:function(a){return a.slice(0)},_degToRad:function(a){return a*e},_radToDeg:function(a){return a*f},_capitalize:function(a){return a.charAt(0).toUpperCase()+a.slice(1)},error:function(a){throw new Error(k+a)},warn:function(a){Kinetic.root.console&&console.warn&&Kinetic.showWarnings&&console.warn(j+a)},extend:function(a,b){function c(){this.constructor=a}c.prototype=b.prototype;var d=a.prototype;a.prototype=new c;for(var e in d)d.hasOwnProperty(e)&&(a.prototype[e]=d[e]);a.__super__=b.prototype},addMethods:function(a,b){var c;for(c in b)a.prototype[c]=b[c]},_getControlPoints:function(a,b,c,d,e,f,g){var h=Math.sqrt(Math.pow(c-a,2)+Math.pow(d-b,2)),i=Math.sqrt(Math.pow(e-c,2)+Math.pow(f-d,2)),j=g*h/(h+i),k=g*i/(h+i),l=c-j*(e-a),m=d-j*(f-b),n=c+k*(e-a),o=d+k*(f-b);return[l,m,n,o]},_expandPoints:function(a,b){var c,d,e=a.length,f=[];for(c=2;e-2>c;c+=2)d=Kinetic.Util._getControlPoints(a[c-2],a[c-1],a[c],a[c+1],a[c+2],a[c+3],b),f.push(d[0]),f.push(d[1]),f.push(a[c]),f.push(a[c+1]),f.push(d[2]),f.push(d[3]);return f},_removeLastLetter:function(a){return a.substring(0,a.length-1)}}}(),function(){var a=Kinetic.Util.createCanvasElement(),b=a.getContext("2d"),c=Kinetic.UA.mobile?function(){var a=window.devicePixelRatio||1,c=b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return a/c}():1;Kinetic.Canvas=function(a){this.init(a)},Kinetic.Canvas.prototype={init:function(a){var b=a||{},d=b.pixelRatio||Kinetic.pixelRatio||c;this.pixelRatio=d,this._canvas=Kinetic.Util.createCanvasElement(),this._canvas.style.padding=0,this._canvas.style.margin=0,this._canvas.style.border=0,this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top=0,this._canvas.style.left=0},getContext:function(){return this.context},getPixelRatio:function(){return this.pixelRatio},setPixelRatio:function(a){this.pixelRatio=a,this.setSize(this.getWidth(),this.getHeight())},setWidth:function(a){this.width=this._canvas.width=a*this.pixelRatio,this._canvas.style.width=a+"px"},setHeight:function(a){this.height=this._canvas.height=a*this.pixelRatio,this._canvas.style.height=a+"px"},getWidth:function(){return this.width},getHeight:function(){return this.height},setSize:function(a,b){this.setWidth(a),this.setHeight(b)},toDataURL:function(a,b){try{return this._canvas.toDataURL(a,b)}catch(c){try{return this._canvas.toDataURL()}catch(d){return Kinetic.Util.warn("Unable to get data URL. "+d.message),""}}}},Kinetic.SceneCanvas=function(a){var b=a||{},c=b.width||0,d=b.height||0;Kinetic.Canvas.call(this,b),this.context=new Kinetic.SceneContext(this),this.setSize(c,d)},Kinetic.SceneCanvas.prototype={setWidth:function(a){var b=this.pixelRatio,c=this.getContext()._context;Kinetic.Canvas.prototype.setWidth.call(this,a),c.scale(b,b)},setHeight:function(a){var b=this.pixelRatio,c=this.getContext()._context;Kinetic.Canvas.prototype.setHeight.call(this,a),c.scale(b,b)}},Kinetic.Util.extend(Kinetic.SceneCanvas,Kinetic.Canvas),Kinetic.HitCanvas=function(a){var b=a||{},c=b.width||0,d=b.height||0;Kinetic.Canvas.call(this,b),this.context=new Kinetic.HitContext(this),this.setSize(c,d),this.hitCanvas=!0},Kinetic.Util.extend(Kinetic.HitCanvas,Kinetic.Canvas)}(),function(){var a=",",b="(",c=")",d="([",e="])",f=";",g="()",h="=",i=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];Kinetic.Context=function(a){this.init(a)},Kinetic.Context.prototype={init:function(a){this.canvas=a,this._context=a._canvas.getContext("2d"),Kinetic.enableTrace&&(this.traceArr=[],this._enableTrace())},fillShape:function(a){a.getFillEnabled()&&this._fill(a)},strokeShape:function(a){a.getStrokeEnabled()&&this._stroke(a)},fillStrokeShape:function(a){var b=a.getFillEnabled();b&&this._fill(a),a.getStrokeEnabled()&&this._stroke(a)},getTrace:function(i){var j,k,l,m,n=this.traceArr,o=n.length,p="";for(j=0;o>j;j++)k=n[j],l=k.method,l?(m=k.args,p+=l,p+=i?g:Kinetic.Util._isArray(m[0])?d+m.join(a)+e:b+m.join(a)+c):(p+=k.property,i||(p+=h+k.val)),p+=f;return p},clearTrace:function(){this.traceArr=[]},_trace:function(a){var b,c=this.traceArr;c.push(a),b=c.length,b>=Kinetic.traceArrMax&&c.shift()},reset:function(){var a=this.getCanvas().getPixelRatio();this.setTransform(1*a,0,0,1*a,0,0)},getCanvas:function(){return this.canvas},clear:function(a){var b=this.getCanvas();a?this.clearRect(a.x||0,a.y||0,a.width||0,a.height||0):this.clearRect(0,0,b.getWidth(),b.getHeight())},_applyLineCap:function(a){var b=a.getLineCap();b&&this.setAttr("lineCap",b)},_applyOpacity:function(a){var b=a.getAbsoluteOpacity();1!==b&&this.setAttr("globalAlpha",b)},_applyLineJoin:function(a){var b=a.getLineJoin();b&&this.setAttr("lineJoin",b)},setAttr:function(a,b){this._context[a]=b},arc:function(){var a=arguments;this._context.arc(a[0],a[1],a[2],a[3],a[4],a[5])},beginPath:function(){this._context.beginPath()},bezierCurveTo:function(){var a=arguments;this._context.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5])},clearRect:function(){var a=arguments;this._context.clearRect(a[0],a[1],a[2],a[3])},clip:function(){this._context.clip()},closePath:function(){this._context.closePath()},createImageData:function(){var a=arguments;return 2===a.length?this._context.createImageData(a[0],a[1]):1===a.length?this._context.createImageData(a[0]):void 0},createLinearGradient:function(){var a=arguments;return this._context.createLinearGradient(a[0],a[1],a[2],a[3])},createPattern:function(){var a=arguments;return this._context.createPattern(a[0],a[1])},createRadialGradient:function(){var a=arguments;return this._context.createRadialGradient(a[0],a[1],a[2],a[3],a[4],a[5])},drawImage:function(){var a=arguments,b=this._context;3===a.length?b.drawImage(a[0],a[1],a[2]):5===a.length?b.drawImage(a[0],a[1],a[2],a[3],a[4]):9===a.length&&b.drawImage(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8])},fill:function(){this._context.fill()},fillText:function(){var a=arguments;this._context.fillText(a[0],a[1],a[2])},getImageData:function(){var a=arguments;return this._context.getImageData(a[0],a[1],a[2],a[3])},lineTo:function(){var a=arguments;this._context.lineTo(a[0],a[1])},moveTo:function(){var a=arguments;this._context.moveTo(a[0],a[1])},rect:function(){var a=arguments;this._context.rect(a[0],a[1],a[2],a[3])},putImageData:function(){var a=arguments;this._context.putImageData(a[0],a[1],a[2])},quadraticCurveTo:function(){ -var a=arguments;this._context.quadraticCurveTo(a[0],a[1],a[2],a[3])},restore:function(){this._context.restore()},rotate:function(){var a=arguments;this._context.rotate(a[0])},save:function(){this._context.save()},scale:function(){var a=arguments;this._context.scale(a[0],a[1])},setLineDash:function(){var a=arguments,b=this._context;this._context.setLineDash?b.setLineDash(a[0]):"mozDash"in b?b.mozDash=a[0]:"webkitLineDash"in b&&(b.webkitLineDash=a[0])},setTransform:function(){var a=arguments;this._context.setTransform(a[0],a[1],a[2],a[3],a[4],a[5])},stroke:function(){this._context.stroke()},strokeText:function(){var a=arguments;this._context.strokeText(a[0],a[1],a[2])},transform:function(){var a=arguments;this._context.transform(a[0],a[1],a[2],a[3],a[4],a[5])},translate:function(){var a=arguments;this._context.translate(a[0],a[1])},_enableTrace:function(){var a,b,c=this,d=i.length,e=Kinetic.Util._simplifyArray,f=this.setAttr,g=function(a){var d,f=c[a];c[a]=function(){return b=e(Array.prototype.slice.call(arguments,0)),d=f.apply(c,arguments),c._trace({method:a,args:b}),d}};for(a=0;d>a;a++)g(i[a]);c.setAttr=function(){f.apply(c,arguments),c._trace({property:arguments[0],val:arguments[1]})}}},Kinetic.SceneContext=function(a){Kinetic.Context.call(this,a)},Kinetic.SceneContext.prototype={_fillColor:function(a){var b=a.fill()||Kinetic.Util._getRGBAString({red:a.fillRed(),green:a.fillGreen(),blue:a.fillBlue(),alpha:a.fillAlpha()});this.setAttr("fillStyle",b),a._fillFunc(this)},_fillPattern:function(a){var b=a.getFillPatternImage(),c=a.getFillPatternX(),d=a.getFillPatternY(),e=a.getFillPatternScale(),f=Kinetic.getAngle(a.getFillPatternRotation()),g=a.getFillPatternOffset(),h=a.getFillPatternRepeat();(c||d)&&this.translate(c||0,d||0),f&&this.rotate(f),e&&this.scale(e.x,e.y),g&&this.translate(-1*g.x,-1*g.y),this.setAttr("fillStyle",this.createPattern(b,h||"repeat")),this.fill()},_fillLinearGradient:function(a){var b=a.getFillLinearGradientStartPoint(),c=a.getFillLinearGradientEndPoint(),d=a.getFillLinearGradientColorStops(),e=this.createLinearGradient(b.x,b.y,c.x,c.y);if(d){for(var f=0;fh;h++)i=e[h],a[i]=this.getAttr(d+k(i));return a},c.prototype[m]=function(a){var b,c=this.attrs[d];f&&(a=f.call(this,a));for(b in a)this._setAttr(d+k(b),a[b]);return this._fireChangeEvent(d,c,a),g&&g.call(this),this},this.addOverloadedGetterSetter(c,d)},addOverloadedGetterSetter:function(c,d){var e=Kinetic.Util._capitalize(d),f=b+e,g=a+e;c.prototype[d]=function(){return arguments.length?(this[f](arguments[0]),this):this[g]()}},backCompat:function(a,b){var c;for(c in b)a.prototype[c]=a.prototype[b[c]]},afterSetFilter:function(){this._filterUpToDate=!1}},Kinetic.Validators={RGBComponent:function(a){return a>255?255:0>a?0:Math.round(a)},alphaComponent:function(a){return a>1?1:1e-4>a?1e-4:a}}}(),function(){var a="absoluteOpacity",b="absoluteTransform",c="Change",d="children",e=".",f="",g="get",h="id",i="kinetic",j="listening",k="mouseenter",l="mouseleave",m="name",n="set",o="Shape",p=" ",q="stage",r="transform",s="Stage",t="visible",u=["id"],v=["xChange.kinetic","yChange.kinetic","scaleXChange.kinetic","scaleYChange.kinetic","skewXChange.kinetic","skewYChange.kinetic","rotationChange.kinetic","offsetXChange.kinetic","offsetYChange.kinetic","transformsEnabledChange.kinetic"].join(p);Kinetic.Util.addMethods(Kinetic.Node,{_init:function(c){var d=this;this._id=Kinetic.idCounter++,this.eventListeners={},this.attrs={},this._cache={},this._filterUpToDate=!1,this.setAttrs(c),this.on(v,function(){this._clearCache(r),d._clearSelfAndDescendantCache(b)}),this.on("visibleChange.kinetic",function(){d._clearSelfAndDescendantCache(t)}),this.on("listeningChange.kinetic",function(){d._clearSelfAndDescendantCache(j)}),this.on("opacityChange.kinetic",function(){d._clearSelfAndDescendantCache(a)})},_clearCache:function(a){a?delete this._cache[a]:this._cache={}},_getCache:function(a,b){var c=this._cache[a];return void 0===c&&(this._cache[a]=b.call(this)),this._cache[a]},_clearSelfAndDescendantCache:function(a){this._clearCache(a),this.children&&this.getChildren().each(function(b){b._clearSelfAndDescendantCache(a)})},clearCache:function(){return delete this._cache.canvas,this._filterUpToDate=!1,this},cache:function(a){var b=a||{},c=b.x||0,d=b.y||0,e=b.width||this.width(),f=b.height||this.height(),g=b.drawBorder||!1;if(0===e||0===f)return void Kinetic.Util.warn("Width or height of caching configuration equals 0. Cache is ignored.");var h=new Kinetic.SceneCanvas({pixelRatio:1,width:e,height:f}),i=new Kinetic.SceneCanvas({pixelRatio:1,width:e,height:f}),j=new Kinetic.HitCanvas({width:e,height:f}),k=h.getContext(),l=j.getContext();return j.isCache=!0,this.clearCache(),k.save(),l.save(),g&&(k.save(),k.beginPath(),k.rect(0,0,e,f),k.closePath(),k.setAttr("strokeStyle","red"),k.setAttr("lineWidth",5),k.stroke(),k.restore()),k.translate(-1*c,-1*d),l.translate(-1*c,-1*d),"Shape"===this.nodeType&&(k.translate(-1*this.x(),-1*this.y()),l.translate(-1*this.x(),-1*this.y())),this.drawScene(h,this),this.drawHit(j,this),k.restore(),l.restore(),this._cache.canvas={scene:h,filter:i,hit:j},this},_drawCachedSceneCanvas:function(a){a.save(),this.getLayer()._applyTransform(this,a),a._applyOpacity(this),a.drawImage(this._getCachedSceneCanvas()._canvas,0,0),a.restore()},_getCachedSceneCanvas:function(){var a,b,c,d,e=this.filters(),f=this._cache.canvas,g=f.scene,h=f.filter,i=h.getContext();if(e){if(!this._filterUpToDate){try{for(a=e.length,i.clear(),i.drawImage(g._canvas,0,0),b=i.getImageData(0,0,h.getWidth(),h.getHeight()),c=0;a>c;c++)d=e[c],d.call(this,b),i.putImageData(b,0,0)}catch(j){Kinetic.Util.warn("Unable to apply filter. "+j.message)}this._filterUpToDate=!0}return h}return g},_drawCachedHitCanvas:function(a){var b=this._cache.canvas,c=b.hit;a.save(),this.getLayer()._applyTransform(this,a),a.drawImage(c._canvas,0,0),a.restore()},on:function(a,b){var c,d,g,h,i,j=a.split(p),k=j.length;for(c=0;k>c;c++)d=j[c],g=d.split(e),h=g[0],i=g[1]||f,this.eventListeners[h]||(this.eventListeners[h]=[]),this.eventListeners[h].push({name:i,handler:b});return this},off:function(a){var b,c,d,f,g,h,i=(a||"").split(p),j=i.length;if(!a)for(c in this.eventListeners)this._off(c);for(b=0;j>b;b++)if(d=i[b],f=d.split(e),g=f[0],h=f[1],g)this.eventListeners[g]&&this._off(g,h);else for(c in this.eventListeners)this._off(c,h);return this},dispatchEvent:function(a){var b={target:this,type:a.type,evt:a};this.fire(a.type,b)},addEventListener:function(a,b){this.on(a,function(a){b.call(this,a.evt)})},removeEventListener:function(a){this.off(a)},remove:function(){var c=this.getParent();return c&&c.children&&(c.children.splice(this.index,1),c._setChildrenIndices(),delete this.parent),this._clearSelfAndDescendantCache(q),this._clearSelfAndDescendantCache(b),this._clearSelfAndDescendantCache(t),this._clearSelfAndDescendantCache(j),this._clearSelfAndDescendantCache(a),this},destroy:function(){Kinetic._removeId(this.getId()),Kinetic._removeName(this.getName(),this._id),this.remove()},getAttr:function(a){var b=g+Kinetic.Util._capitalize(a);return Kinetic.Util._isFunction(this[b])?this[b]():this.attrs[a]},getAncestors:function(){for(var a=this.getParent(),b=new Kinetic.Collection;a;)b.push(a),a=a.getParent();return b},getAttrs:function(){return this.attrs||{}},setAttrs:function(a){var b,c;if(a)for(b in a)b===d||a[b]instanceof Kinetic.Node||(c=n+Kinetic.Util._capitalize(b),Kinetic.Util._isFunction(this[c])?this[c](a[b]):this._setAttr(b,a[b]));return this},isListening:function(){return this._getCache(j,this._isListening)},_isListening:function(){var a=this.getListening(),b=this.getParent();return"inherit"===a?!b||b.isListening():a},isVisible:function(){return this._getCache(t,this._isVisible)},_isVisible:function(){var a=this.getVisible(),b=this.getParent();return"inherit"===a?!b||b.isVisible():a},shouldDrawHit:function(a){var b=this.getLayer();return a&&a.isCache||b&&b.hitGraphEnabled()&&this.isListening()&&this.isVisible()},show:function(){return this.setVisible(!0),this},hide:function(){return this.setVisible(!1),this},getZIndex:function(){return this.index||0},getAbsoluteZIndex:function(){function a(i){for(b=[],c=i.length,d=0;c>d;d++)e=i[d],h++,e.nodeType!==o&&(b=b.concat(e.getChildren().toArray())),e._id===g._id&&(d=c);b.length>0&&b[0].getDepth()<=f&&a(b)}var b,c,d,e,f=this.getDepth(),g=this,h=0;return g.nodeType!==s&&a(g.getStage().getChildren()),h},getDepth:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},setPosition:function(a){return this.setX(a.x),this.setY(a.y),this},getPosition:function(){return{x:this.getX(),y:this.getY()}},getAbsolutePosition:function(){var a=this.getAbsoluteTransform().getMatrix(),b=new Kinetic.Transform,c=this.offset();return b.m=a.slice(),b.translate(c.x,c.y),b.getTranslation()},setAbsolutePosition:function(a){var b,c=this._clearTransform();return this.attrs.x=c.x,this.attrs.y=c.y,delete c.x,delete c.y,b=this.getAbsoluteTransform(),b.invert(),b.translate(a.x,a.y),a={x:this.attrs.x+b.getTranslation().x,y:this.attrs.y+b.getTranslation().y},this.setPosition({x:a.x,y:a.y}),this._setTransform(c),this},_setTransform:function(a){var c;for(c in a)this.attrs[c]=a[c];this._clearCache(r),this._clearSelfAndDescendantCache(b)},_clearTransform:function(){var a={x:this.getX(),y:this.getY(),rotation:this.getRotation(),scaleX:this.getScaleX(),scaleY:this.getScaleY(),offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),skewX:this.getSkewX(),skewY:this.getSkewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,this._clearCache(r),this._clearSelfAndDescendantCache(b),a},move:function(a){var b=a.x,c=a.y,d=this.getX(),e=this.getY();return void 0!==b&&(d+=b),void 0!==c&&(e+=c),this.setPosition({x:d,y:e}),this},_eachAncestorReverse:function(a,b){var c,d,e=[],f=this.getParent();if(b&&b._id===this._id)return a(this),!0;for(e.unshift(this);f&&(!b||f._id!==b._id);)e.unshift(f),f=f.parent;for(c=e.length,d=0;c>d;d++)a(e[d])},rotate:function(a){return this.setRotation(this.getRotation()+a),this},moveToTop:function(){if(!this.parent)return void Kinetic.Util.warn("Node has no parent. moveToTop function is ignored.");var a=this.index;return this.parent.children.splice(a,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0},moveUp:function(){if(!this.parent)return void Kinetic.Util.warn("Node has no parent. moveUp function is ignored.");var a=this.index,b=this.parent.getChildren().length;return b-1>a&&(this.parent.children.splice(a,1),this.parent.children.splice(a+1,0,this),this.parent._setChildrenIndices(),!0)},moveDown:function(){if(!this.parent)return void Kinetic.Util.warn("Node has no parent. moveDown function is ignored.");var a=this.index;return a>0&&(this.parent.children.splice(a,1),this.parent.children.splice(a-1,0,this),this.parent._setChildrenIndices(),!0)},moveToBottom:function(){if(!this.parent)return void Kinetic.Util.warn("Node has no parent. moveToBottom function is ignored.");var a=this.index;return a>0&&(this.parent.children.splice(a,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)},setZIndex:function(a){if(!this.parent)return void Kinetic.Util.warn("Node has no parent. zIndex parameter is ignored.");var b=this.index;return this.parent.children.splice(b,1),this.parent.children.splice(a,0,this),this.parent._setChildrenIndices(),this},getAbsoluteOpacity:function(){return this._getCache(a,this._getAbsoluteOpacity)},_getAbsoluteOpacity:function(){var a=this.getOpacity();return this.getParent()&&(a*=this.getParent().getAbsoluteOpacity()),a},moveTo:function(a){return this.getParent()!==a&&(this.remove(),a.add(this)),this},toObject:function(){var a,b,c,d,e=Kinetic.Util,f={},g=this.getAttrs();f.attrs={};for(a in g)b=g[a],e._isFunction(b)||e._isElement(b)||e._isObject(b)&&e._hasMethods(b)||(c=this[a],delete g[a],d=c?c.call(this):null,g[a]=b,d!==b&&(f.attrs[a]=b));return f.className=this.getClassName(),f},toJSON:function(){return JSON.stringify(this.toObject())},getParent:function(){return this.parent},getLayer:function(){var a=this.getParent();return a?a.getLayer():null},getStage:function(){return this._getCache(q,this._getStage)},_getStage:function(){var a=this.getParent();return a?a.getStage():void 0},fire:function(a,b,c){return c?this._fireAndBubble(a,b||{}):this._fire(a,b||{}),this},getAbsoluteTransform:function(a){return a?this._getAbsoluteTransform(a):this._getCache(b,this._getAbsoluteTransform)},_getAbsoluteTransform:function(a){var b,c,d=new Kinetic.Transform;return this._eachAncestorReverse(function(a){b=a.transformsEnabled(),c=a.getTransform(),"all"===b?d.multiply(c):"position"===b&&d.translate(a.x(),a.y())},a),d},getTransform:function(){return this._getCache(r,this._getTransform)},_getTransform:function(){var a=new Kinetic.Transform,b=this.getX(),c=this.getY(),d=Kinetic.getAngle(this.getRotation()),e=this.getScaleX(),f=this.getScaleY(),g=this.getSkewX(),h=this.getSkewY(),i=this.getOffsetX(),j=this.getOffsetY();return(0!==b||0!==c)&&a.translate(b,c),0!==d&&a.rotate(d),(0!==g||0!==h)&&a.skew(g,h),(1!==e||1!==f)&&a.scale(e,f),(0!==i||0!==j)&&a.translate(-1*i,-1*j),a},clone:function(a){var b,c,d,e,f,g=this.getClassName(),h=Kinetic.Util.cloneObject(this.attrs);for(var j in u){var k=u[j];delete h[k]}for(b in a)h[b]=a[b];var l=new Kinetic[g](h);for(b in this.eventListeners)for(c=this.eventListeners[b],d=c.length,e=0;d>e;e++)f=c[e],f.name.indexOf(i)<0&&(l.eventListeners[b]||(l.eventListeners[b]=[]),l.eventListeners[b].push(f));return l},toDataURL:function(a){a=a||{};var b=a.mimeType||null,c=a.quality||null,d=this.getStage(),e=a.x||0,f=a.y||0,g=new Kinetic.SceneCanvas({width:a.width||this.getWidth()||(d?d.getWidth():0),height:a.height||this.getHeight()||(d?d.getHeight():0),pixelRatio:1}),h=g.getContext();return h.save(),(e||f)&&h.translate(-1*e,-1*f),this.drawScene(g),h.restore(),g.toDataURL(b,c)},toImage:function(a){Kinetic.Util._getImage(this.toDataURL(a),function(b){a.callback(b)})},setSize:function(a){return this.setWidth(a.width),this.setHeight(a.height),this},getSize:function(){return{width:this.getWidth(),height:this.getHeight()}},getWidth:function(){return this.attrs.width||0},getHeight:function(){return this.attrs.height||0},getClassName:function(){return this.className||this.nodeType},getType:function(){return this.nodeType},getDragDistance:function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Kinetic.dragDistance},_get:function(a){return this.className===a||this.nodeType===a?[this]:[]},_off:function(a,b){var c,d,e=this.eventListeners[a];for(c=0;ce;e++)c.add(this._createNode(g[e]));return c},Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"position"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"x",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"y",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"opacity",1),Kinetic.Factory.addGetter(Kinetic.Node,"name"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"name"),Kinetic.Factory.addGetter(Kinetic.Node,"id"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"id"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"rotation",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"scale",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"scaleX",1),Kinetic.Factory.addGetterSetter(Kinetic.Node,"scaleY",1),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"skew",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"skewX",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"skewY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"offset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"offsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"offsetY",0),Kinetic.Factory.addSetter(Kinetic.Node,"dragDistance"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"dragDistance"),Kinetic.Factory.addSetter(Kinetic.Node,"width",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"width"),Kinetic.Factory.addSetter(Kinetic.Node,"height",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"height"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"listening","inherit"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"filters",void 0,function(a){return this._filterUpToDate=!1,a}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"visible","inherit"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"transformsEnabled","all"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"size"),Kinetic.Factory.backCompat(Kinetic.Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Kinetic.Collection.mapMethods(Kinetic.Node)}(),function(){Kinetic.Filters.Grayscale=function(a){var b,c,d=a.data,e=d.length;for(b=0;e>b;b+=4)c=.34*d[b]+.5*d[b+1]+.16*d[b+2],d[b]=c,d[b+1]=c,d[b+2]=c}}(),function(){Kinetic.Filters.Brighten=function(a){var b,c=255*this.brightness(),d=a.data,e=d.length;for(b=0;e>b;b+=4)d[b]+=c,d[b+1]+=c,d[b+2]+=c},Kinetic.Factory.addGetterSetter(Kinetic.Node,"brightness",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Invert=function(a){var b,c=a.data,d=c.length;for(b=0;d>b;b+=4)c[b]=255-c[b],c[b+1]=255-c[b+1],c[b+2]=255-c[b+2]}}(),function(){function a(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function b(b,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D=b.data,E=b.width,F=b.height,G=e+e+1,H=E-1,I=F-1,J=e+1,K=J*(J+1)/2,L=new a,M=null,N=L,O=null,P=null,Q=c[e],R=d[e];for(h=1;G>h;h++)N=N.next=new a,h==J&&(M=N);for(N.next=L,l=k=0,g=0;F>g;g++){for(u=v=w=x=m=n=o=p=0,q=J*(y=D[k]),r=J*(z=D[k+1]),s=J*(A=D[k+2]),t=J*(B=D[k+3]),m+=K*y,n+=K*z,o+=K*A,p+=K*B,N=L,h=0;J>h;h++)N.r=y,N.g=z,N.b=A,N.a=B,N=N.next;for(h=1;J>h;h++)i=k+((h>H?H:h)<<2),m+=(N.r=y=D[i])*(C=J-h),n+=(N.g=z=D[i+1])*C,o+=(N.b=A=D[i+2])*C,p+=(N.a=B=D[i+3])*C,u+=y,v+=z,w+=A,x+=B,N=N.next;for(O=L,P=M,f=0;E>f;f++)D[k+3]=B=p*Q>>R,0!==B?(B=255/B,D[k]=(m*Q>>R)*B,D[k+1]=(n*Q>>R)*B,D[k+2]=(o*Q>>R)*B):D[k]=D[k+1]=D[k+2]=0,m-=q,n-=r,o-=s,p-=t,q-=O.r,r-=O.g,s-=O.b,t-=O.a,i=l+((i=f+e+1)f;f++){for(v=w=x=u=n=o=p=m=0,k=f<<2,q=J*(y=D[k]),r=J*(z=D[k+1]),s=J*(A=D[k+2]),t=J*(B=D[k+3]),m+=K*y,n+=K*z,o+=K*A,p+=K*B,N=L,h=0;J>h;h++)N.r=y,N.g=z,N.b=A,N.a=B,N=N.next;for(j=E,h=1;e>=h;h++)k=j+f<<2,m+=(N.r=y=D[k])*(C=J-h),n+=(N.g=z=D[k+1])*C,o+=(N.b=A=D[k+2])*C,p+=(N.a=B=D[k+3])*C,u+=y,v+=z,w+=A,x+=B,N=N.next,I>h&&(j+=E);for(k=f,O=L,P=M,g=0;F>g;g++)i=k<<2,D[i+3]=B=p*Q>>R,B>0?(B=255/B,D[i]=(m*Q>>R)*B,D[i+1]=(n*Q>>R)*B,D[i+2]=(o*Q>>R)*B):D[i]=D[i+1]=D[i+2]=0,m-=q,n-=r,o-=s,p-=t,q-=O.r,r-=O.g,s-=O.b,t-=O.a,i=f+((i=g+J)0&&b(a,c)},Kinetic.Factory.addGetterSetter(Kinetic.Node,"blurRadius",0,null,Kinetic.Factory.afterSetFilter)}(),function(){function a(a,b,c){var d=4*(c*a.width+b),e=[];return e.push(a.data[d++],a.data[d++],a.data[d++],a.data[d++]),e}function b(a,b){return Math.sqrt(Math.pow(a[0]-b[0],2)+Math.pow(a[1]-b[1],2)+Math.pow(a[2]-b[2],2))}function c(a){for(var b=[0,0,0],c=0;cn?0:255}return l}}function e(a,b){for(var c=0;ch;h++)for(var i=0;b>i;i++){for(var j=h*b+i,k=0,l=0;e>l;l++)for(var m=0;e>m;m++){var n=h+l-f,o=i+m-f;if(n>=0&&c>n&&o>=0&&b>o){var p=n*b+o,q=d[l*e+m];k+=a[p]*q}}g[j]=2040===k?255:0}return g}function g(a,b,c){for(var d=[1,1,1,1,1,1,1,1,1],e=Math.round(Math.sqrt(d.length)),f=Math.floor(e/2),g=[],h=0;c>h;h++)for(var i=0;b>i;i++){for(var j=h*b+i,k=0,l=0;e>l;l++)for(var m=0;e>m;m++){var n=h+l-f,o=i+m-f;if(n>=0&&c>n&&o>=0&&b>o){var p=n*b+o,q=d[l*e+m];k+=a[p]*q}}g[j]=k>=1020?255:0}return g}function h(a,b,c){for(var d=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],e=Math.round(Math.sqrt(d.length)),f=Math.floor(e/2),g=[],h=0;c>h;h++)for(var i=0;b>i;i++){for(var j=h*b+i,k=0,l=0;e>l;l++)for(var m=0;e>m;m++){var n=h+l-f,o=i+m-f;if(n>=0&&c>n&&o>=0&&b>o){var p=n*b+o,q=d[l*e+m];k+=a[p]*q}}g[j]=k}return g}Kinetic.Filters.Mask=function(a){var b=this.threshold(),c=d(a,b);return c&&(c=f(c,a.width,a.height),c=g(c,a.width,a.height),c=h(c,a.width,a.height),e(a,c)),a},Kinetic.Factory.addGetterSetter(Kinetic.Node,"threshold",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.RGB=function(a){var b,c,d=a.data,e=d.length,f=this.red(),g=this.green(),h=this.blue();for(b=0;e>b;b+=4)c=(.34*d[b]+.5*d[b+1]+.16*d[b+2])/255,d[b]=c*f,d[b+1]=c*g,d[b+2]=c*h,d[b+3]=d[b+3]},Kinetic.Factory.addGetterSetter(Kinetic.Node,"red",0,function(a){return this._filterUpToDate=!1,a>255?255:0>a?0:Math.round(a)}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"green",0,function(a){return this._filterUpToDate=!1,a>255?255:0>a?0:Math.round(a)}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"blue",0,Kinetic.Validators.RGBComponent,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.HSV=function(a){var b,c,d,e,f,g=a.data,h=g.length,i=Math.pow(2,this.value()),j=Math.pow(2,this.saturation()),k=Math.abs(this.hue()+360)%360,l=i*j*Math.cos(k*Math.PI/180),m=i*j*Math.sin(k*Math.PI/180),n=.299*i+.701*l+.167*m,o=.587*i-.587*l+.33*m,p=.114*i-.114*l-.497*m,q=.299*i-.299*l-.328*m,r=.587*i+.413*l+.035*m,s=.114*i-.114*l+.293*m,t=.299*i-.3*l+1.25*m,u=.587*i-.586*l-1.05*m,v=.114*i+.886*l-.2*m;for(b=0;h>b;b+=4)c=g[b+0],d=g[b+1],e=g[b+2],f=g[b+3],g[b+0]=n*c+o*d+p*e,g[b+1]=q*c+r*d+s*e,g[b+2]=t*c+u*d+v*e,g[b+3]=f},Kinetic.Factory.addGetterSetter(Kinetic.Node,"hue",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"saturation",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"value",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Factory.addGetterSetter(Kinetic.Node,"hue",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"saturation",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"luminance",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Filters.HSL=function(a){var b,c,d,e,f,g=a.data,h=g.length,i=1,j=Math.pow(2,this.saturation()),k=Math.abs(this.hue()+360)%360,l=127*this.luminance(),m=i*j*Math.cos(k*Math.PI/180),n=i*j*Math.sin(k*Math.PI/180),o=.299*i+.701*m+.167*n,p=.587*i-.587*m+.33*n,q=.114*i-.114*m-.497*n,r=.299*i-.299*m-.328*n,s=.587*i+.413*m+.035*n,t=.114*i-.114*m+.293*n,u=.299*i-.3*m+1.25*n,v=.587*i-.586*m-1.05*n,w=.114*i+.886*m-.2*n;for(b=0;h>b;b+=4)c=g[b+0],d=g[b+1],e=g[b+2],f=g[b+3],g[b+0]=o*c+p*d+q*e+l,g[b+1]=r*c+s*d+t*e+l,g[b+2]=u*c+v*d+w*e+l,g[b+3]=f}}(),function(){Kinetic.Filters.Emboss=function(a){var b=10*this.embossStrength(),c=255*this.embossWhiteLevel(),d=this.embossDirection(),e=this.embossBlend(),f=0,g=0,h=a.data,i=a.width,j=a.height,k=4*i,l=j;switch(d){case"top-left":f=-1,g=-1;break;case"top":f=-1,g=0;break;case"top-right":f=-1,g=1;break;case"right":f=0,g=1;break;case"bottom-right":f=1,g=1;break;case"bottom":f=1,g=0;break;case"bottom-left":f=1,g=-1;break;case"left":f=0,g=-1}do{var m=(l-1)*k,n=f;1>l+n&&(n=0),l+n>j&&(n=0);var o=(l-1+n)*i*4,p=i;do{var q=m+4*(p-1),r=g;1>p+r&&(r=0),p+r>i&&(r=0);var s=o+4*(p-1+r),t=h[q]-h[s],u=h[q+1]-h[s+1],v=h[q+2]-h[s+2],w=t,x=w>0?w:-w,y=u>0?u:-u,z=v>0?v:-v;if(y>x&&(w=u),z>x&&(w=v),w*=b,e){var A=h[q]+w,B=h[q+1]+w,C=h[q+2]+w;h[q]=A>255?255:0>A?0:A,h[q+1]=B>255?255:0>B?0:B,h[q+2]=C>255?255:0>C?0:C}else{var D=c-w;0>D?D=0:D>255&&(D=255),h[q]=h[q+1]=h[q+2]=D}}while(--p)}while(--l)},Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossStrength",.5,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossWhiteLevel",.5,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossDirection","top-left",null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossBlend",!1,null,Kinetic.Factory.afterSetFilter)}(),function(){function a(a,b,c,d,e){var f,g=c-b,h=e-d;return 0===g?d+h/2:0===h?d:(f=(a-b)/g,f=h*f+d)}Kinetic.Filters.Enhance=function(b){var c,d,e,f,g=b.data,h=g.length,i=g[0],j=i,k=g[1],l=k,m=g[2],n=m,o=this.enhance();if(0!==o){for(f=0;h>f;f+=4)c=g[f+0],i>c?i=c:c>j&&(j=c),d=g[f+1],k>d?k=d:d>l&&(l=d),e=g[f+2],m>e?m=e:e>n&&(n=e);j===i&&(j=255,i=0),l===k&&(l=255,k=0),n===m&&(n=255,m=0);var p,q,r,s,t,u,v,w,x;for(o>0?(q=j+o*(255-j),r=i-o*(i-0),t=l+o*(255-l),u=k-o*(k-0),w=n+o*(255-n),x=m-o*(m-0)):(p=.5*(j+i),q=j+o*(j-p),r=i+o*(i-p),s=.5*(l+k),t=l+o*(l-s),u=k+o*(k-s),v=.5*(n+m),w=n+o*(n-v),x=m+o*(m-v)),f=0;h>f;f+=4)g[f+0]=a(g[f+0],i,j,r,q),g[f+1]=a(g[f+1],k,l,u,t),g[f+2]=a(g[f+2],m,n,x,w)}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"enhance",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Posterize=function(a){var b,c=Math.round(254*this.levels())+1,d=a.data,e=d.length,f=255/c;for(b=0;e>b;b+=1)d[b]=Math.floor(d[b]/f)*f},Kinetic.Factory.addGetterSetter(Kinetic.Node,"levels",.5,null,Kinetic.Factory.afterSetFilter); -}(),function(){Kinetic.Filters.Noise=function(a){var b,c=255*this.noise(),d=a.data,e=d.length,f=c/2;for(b=0;e>b;b+=4)d[b+0]+=f-2*f*Math.random(),d[b+1]+=f-2*f*Math.random(),d[b+2]+=f-2*f*Math.random()},Kinetic.Factory.addGetterSetter(Kinetic.Node,"noise",.2,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Pixelate=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p=Math.ceil(this.pixelSize()),q=a.width,r=a.height,s=Math.ceil(q/p),t=Math.ceil(r/p);for(a=a.data,m=0;s>m;m+=1)for(n=0;t>n;n+=1){for(e=0,f=0,g=0,h=0,i=m*p,j=i+p,k=n*p,l=k+p,o=0,b=i;j>b;b+=1)if(!(b>=q))for(c=k;l>c;c+=1)c>=r||(d=4*(q*c+b),e+=a[d+0],f+=a[d+1],g+=a[d+2],h+=a[d+3],o+=1);for(e/=o,f/=o,g/=o,b=i;j>b;b+=1)if(!(b>=q))for(c=k;l>c;c+=1)c>=r||(d=4*(q*c+b),a[d+0]=e,a[d+1]=f,a[d+2]=g,a[d+3]=h)}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"pixelSize",8,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Threshold=function(a){var b,c=255*this.threshold(),d=a.data,e=d.length;for(b=0;e>b;b+=1)d[b]=d[b]255?255:h,k[d+1]=i>255?255:i,k[d+2]=j>255?255:j,k[d+3]=k[d+3];while(--c)}while(--m)}}(),function(){Kinetic.Filters.Solarize=function(a){var b=a.data,c=a.width,d=a.height,e=4*c,f=d;do{var g=(f-1)*e,h=c;do{var i=g+4*(h-1),j=b[i],k=b[i+1],l=b[i+2];j>127&&(j=255-j),k>127&&(k=255-k),l>127&&(l=255-l),b[i]=j,b[i+1]=k,b[i+2]=l}while(--h)}while(--f)}}(),function(){var a=function(a,b,c){var d,e,f,g,h=a.data,i=b.data,j=a.width,k=a.height,l=c.polarCenterX||j/2,m=c.polarCenterY||k/2,n=0,o=0,p=0,q=0,r=Math.sqrt(l*l+m*m);e=j-l,f=k-m,g=Math.sqrt(e*e+f*f),r=g>r?g:r;var s,t,u,v,w=k,x=j,y=360/x*Math.PI/180;for(t=0;x>t;t+=1)for(u=Math.sin(t*y),v=Math.cos(t*y),s=0;w>s;s+=1)e=Math.floor(l+r*s/w*v),f=Math.floor(m+r*s/w*u),d=4*(f*j+e),n=h[d+0],o=h[d+1],p=h[d+2],q=h[d+3],d=4*(t+s*j),i[d+0]=n,i[d+1]=o,i[d+2]=p,i[d+3]=q},b=function(a,b,c){var d,e,f,g,h,i,j=a.data,k=b.data,l=a.width,m=a.height,n=c.polarCenterX||l/2,o=c.polarCenterY||m/2,p=0,q=0,r=0,s=0,t=Math.sqrt(n*n+o*o);e=l-n,f=m-o,i=Math.sqrt(e*e+f*f),t=i>t?i:t;var u,v,w,x,y=m,z=l,A=c.polarRotation||0;for(e=0;l>e;e+=1)for(f=0;m>f;f+=1)g=e-n,h=f-o,u=Math.sqrt(g*g+h*h)*y/t,v=(180*Math.atan2(h,g)/Math.PI+360+A)%360,v=v*z/360,w=Math.floor(v),x=Math.floor(u),d=4*(x*l+w),p=j[d+0],q=j[d+1],r=j[d+2],s=j[d+3],d=4*(f*l+e),k[d+0]=p,k[d+1]=q,k[d+2]=r,k[d+3]=s},c=Kinetic.Util.createCanvasElement();Kinetic.Filters.Kaleidoscope=function(d){var e,f,g,h,i,j,k,l,m,n,o=d.width,p=d.height,q=Math.round(this.kaleidoscopePower()),r=Math.round(this.kaleidoscopeAngle()),s=Math.floor(o*(r%360)/360);if(!(1>q)){c.width=o,c.height=p;var t=c.getContext("2d").getImageData(0,0,o,p);a(d,t,{polarCenterX:o/2,polarCenterY:p/2});for(var u=o/Math.pow(2,q);8>=u;)u=2*u,q-=1;u=Math.ceil(u);var v=u,w=0,x=v,y=1;for(s+u>o&&(w=v,x=0,y=-1),f=0;p>f;f+=1)for(e=w;e!==x;e+=y)g=Math.round(e+s)%o,m=4*(o*f+g),i=t.data[m+0],j=t.data[m+1],k=t.data[m+2],l=t.data[m+3],n=4*(o*f+e),t.data[n+0]=i,t.data[n+1]=j,t.data[n+2]=k,t.data[n+3]=l;for(f=0;p>f;f+=1)for(v=Math.floor(u),h=0;q>h;h+=1){for(e=0;v+1>e;e+=1)m=4*(o*f+e),i=t.data[m+0],j=t.data[m+1],k=t.data[m+2],l=t.data[m+3],n=4*(o*f+2*v-e-1),t.data[n+0]=i,t.data[n+1]=j,t.data[n+2]=k,t.data[n+3]=l;v*=2}b(t,d,{polarRotation:0})}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"kaleidoscopePower",2,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"kaleidoscopeAngle",0,null,Kinetic.Factory.afterSetFilter)}(),function(){function a(a){setTimeout(a,1e3/60)}function b(){return e.apply(Kinetic.root,arguments)}var c=500,d=function(){return Kinetic.root.performance&&Kinetic.root.performance.now?function(){return Kinetic.root.performance.now()}:function(){return(new Date).getTime()}}(),e=function(){return Kinetic.root.requestAnimationFrame||Kinetic.root.webkitRequestAnimationFrame||Kinetic.root.mozRequestAnimationFrame||Kinetic.root.oRequestAnimationFrame||Kinetic.root.msRequestAnimationFrame||a}();Kinetic.Animation=function(a,b){var c=Kinetic.Animation;this.func=a,this.setLayers(b),this.id=c.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:d()}},Kinetic.Animation.prototype={setLayers:function(a){var b=[];b=a?a.length>0?a:[a]:[],this.layers=b},getLayers:function(){return this.layers},addLayer:function(a){var b,c,d=this.layers;if(d){for(b=d.length,c=0;b>c;c++)if(d[c]._id===a._id)return!1}else this.layers=[];return this.layers.push(a),!0},isRunning:function(){var a,b=Kinetic.Animation,c=b.animations,d=c.length;for(a=0;d>a;a++)if(c[a].id===this.id)return!0;return!1},start:function(){var a=Kinetic.Animation;this.stop(),this.frame.timeDiff=0,this.frame.lastTime=d(),a._addAnimation(this)},stop:function(){Kinetic.Animation._removeAnimation(this)},_updateFrameObject:function(a){this.frame.timeDiff=a-this.frame.lastTime,this.frame.lastTime=a,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}},Kinetic.Animation.animations=[],Kinetic.Animation.animIdCounter=0,Kinetic.Animation.animRunning=!1,Kinetic.Animation._addAnimation=function(a){this.animations.push(a),this._handleAnimation()},Kinetic.Animation._removeAnimation=function(a){var b,c=a.id,d=this.animations,e=d.length;for(b=0;e>b;b++)if(d[b].id===c){this.animations.splice(b,1);break}},Kinetic.Animation._runFrames=function(){var a,b,c,e,f,g,h,i,j,k={},l=this.animations;for(e=0;ef;f++)h=b[f],void 0!==h._id&&(k[h._id]=h);for(i in k)k[i].draw()},Kinetic.Animation._animationLoop=function(){var a=Kinetic.Animation;a.animations.length?(b(a._animationLoop),a._runFrames()):a.animRunning=!1},Kinetic.Animation._handleAnimation=function(){var a=this;this.animRunning||(this.animRunning=!0,a._animationLoop())};var f=Kinetic.Node.prototype.moveTo;Kinetic.Node.prototype.moveTo=function(a){f.call(this,a)},Kinetic.BaseLayer.prototype.batchDraw=function(){var a=this,b=Kinetic.Animation;this.batchAnim||(this.batchAnim=new b(function(){a.lastBatchDrawTime&&d()-a.lastBatchDrawTime>c&&a.batchAnim.stop()},this)),this.lastBatchDrawTime=d(),this.batchAnim.isRunning()||(this.draw(),this.batchAnim.start())},Kinetic.Stage.prototype.batchDraw=function(){this.getChildren().each(function(a){a.batchDraw()})}}(this),function(){var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},b=1,c=2,d=3,e=0;Kinetic.Tween=function(b){var c,d,g=this,h=b.node,i=h._id,j=b.easing||Kinetic.Easings.Linear,k=!!b.yoyo;c="undefined"==typeof b.duration?1:0===b.duration?.001:b.duration,this.node=h,this._id=e++,this.anim=new Kinetic.Animation(function(){g.tween.onEnterFrame()},h.getLayer()||(h instanceof Kinetic.Stage?h.getLayers():null)),this.tween=new f(d,function(a){g._tweenFunc(a)},j,0,1,1e3*c,k),this._addListeners(),Kinetic.Tween.attrs[i]||(Kinetic.Tween.attrs[i]={}),Kinetic.Tween.attrs[i][this._id]||(Kinetic.Tween.attrs[i][this._id]={}),Kinetic.Tween.tweens[i]||(Kinetic.Tween.tweens[i]={});for(d in b)void 0===a[d]&&this._addAttr(d,b[d]);this.reset(),this.onFinish=b.onFinish,this.onReset=b.onReset},Kinetic.Tween.attrs={},Kinetic.Tween.tweens={},Kinetic.Tween.prototype={_addAttr:function(a,b){var c,d,e,f,g,h=this.node,i=h._id;if(e=Kinetic.Tween.tweens[i][a],e&&delete Kinetic.Tween.attrs[i][e][a],c=h.getAttr(a),Kinetic.Util._isArray(b))for(d=[],g=b.length,f=0;g>f;f++)d.push(b[f]-c[f]);else d=b-c;Kinetic.Tween.attrs[i][this._id][a]={start:c,diff:d},Kinetic.Tween.tweens[i][a]=this._id},_tweenFunc:function(a){var b,c,d,e,f,g,h,i=this.node,j=Kinetic.Tween.attrs[i._id][this._id];for(b in j){if(c=j[b],d=c.start,e=c.diff,Kinetic.Util._isArray(d))for(f=[],h=d.length,g=0;h>g;g++)f.push(d[g]+e[g]*a);else f=d+e*a;i.setAttr(b,f)}},_addListeners:function(){var a=this;this.tween.onPlay=function(){a.anim.start()},this.tween.onReverse=function(){a.anim.start()},this.tween.onPause=function(){a.anim.stop()},this.tween.onFinish=function(){a.onFinish&&a.onFinish()},this.tween.onReset=function(){a.onReset&&a.onReset()}},play:function(){return this.tween.play(),this},reverse:function(){return this.tween.reverse(),this},reset:function(){return this.tween.reset(),this},seek:function(a){return this.tween.seek(1e3*a),this},pause:function(){return this.tween.pause(),this},finish:function(){return this.tween.finish(),this},destroy:function(){var a,b=this.node._id,c=this._id,d=Kinetic.Tween.tweens[b];this.pause();for(a in d)delete Kinetic.Tween.tweens[b][a];delete Kinetic.Tween.attrs[b][c]}};var f=function(a,b,c,d,e,f,g){this.prop=a,this.propFunc=b,this.begin=d,this._pos=d,this.duration=f,this._change=0,this.prevPos=0,this.yoyo=g,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=c,this._change=e-this.begin,this.pause()};f.prototype={fire:function(a){var b=this[a];b&&b()},setTime:function(a){a>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():0>a?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=a,this.update())},getTime:function(){return this._time},setPosition:function(a){this.prevPos=this._pos,this.propFunc(a),this._pos=a},getPosition:function(a){return void 0===a&&(a=this._time),this.func(a,this.begin,this._change,this.duration)},play:function(){this.state=c,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=d,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(a){this.pause(),this._time=a,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var a=this.getTimer()-this._startTime;this.state===c?this.setTime(a):this.state===d&&this.setTime(this.duration-a)},pause:function(){this.state=b,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Kinetic.Easings={BackEaseIn:function(a,b,c,d){var e=1.70158;return c*(a/=d)*a*((e+1)*a-e)+b},BackEaseOut:function(a,b,c,d){var e=1.70158;return c*((a=a/d-1)*a*((e+1)*a+e)+1)+b},BackEaseInOut:function(a,b,c,d){var e=1.70158;return(a/=d/2)<1?c/2*a*a*(((e*=1.525)+1)*a-e)+b:c/2*((a-=2)*a*(((e*=1.525)+1)*a+e)+2)+b},ElasticEaseIn:function(a,b,c,d,e,f){var g=0;return 0===a?b:1==(a/=d)?b+c:(f||(f=.3*d),!e||ea?-.5*e*Math.pow(2,10*(a-=1))*Math.sin(2*(a*d-g)*Math.PI/f)+b:e*Math.pow(2,-10*(a-=1))*Math.sin(2*(a*d-g)*Math.PI/f)*.5+c+b)},BounceEaseOut:function(a,b,c,d){return(a/=d)<1/2.75?7.5625*c*a*a+b:2/2.75>a?c*(7.5625*(a-=1.5/2.75)*a+.75)+b:2.5/2.75>a?c*(7.5625*(a-=2.25/2.75)*a+.9375)+b:c*(7.5625*(a-=2.625/2.75)*a+.984375)+b},BounceEaseIn:function(a,b,c,d){return c-Kinetic.Easings.BounceEaseOut(d-a,0,c,d)+b},BounceEaseInOut:function(a,b,c,d){return d/2>a?.5*Kinetic.Easings.BounceEaseIn(2*a,0,c,d)+b:.5*Kinetic.Easings.BounceEaseOut(2*a-d,0,c,d)+.5*c+b},EaseIn:function(a,b,c,d){return c*(a/=d)*a+b},EaseOut:function(a,b,c,d){return-c*(a/=d)*(a-2)+b},EaseInOut:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a+b:-c/2*(--a*(a-2)-1)+b},StrongEaseIn:function(a,b,c,d){return c*(a/=d)*a*a*a*a+b},StrongEaseOut:function(a,b,c,d){return c*((a=a/d-1)*a*a*a*a+1)+b},StrongEaseInOut:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a*a*a+b:c/2*((a-=2)*a*a*a*a+2)+b},Linear:function(a,b,c,d){return c*a/d+b}}}(),function(){Kinetic.DD={anim:new Kinetic.Animation(function(){var a=this.dirty;return this.dirty=!1,a}),isDragging:!1,justDragged:!1,offset:{x:0,y:0},node:null,_drag:function(a){var b=Kinetic.DD,c=b.node;if(c){if(!b.isDragging){var d=c.getStage().getPointerPosition(),e=c.dragDistance(),f=Math.max(Math.abs(d.x-b.startPointerPos.x),Math.abs(d.y-b.startPointerPos.y));if(e>f)return}c._setDragPosition(a),b.isDragging||(b.isDragging=!0,c.fire("dragstart",{type:"dragstart",target:c,evt:a},!0)),c.fire("dragmove",{type:"dragmove",target:c,evt:a},!0)}},_endDragBefore:function(a){var b,c,d=Kinetic.DD,e=d.node;e&&(b=e.nodeType,c=e.getLayer(),d.anim.stop(),d.isDragging&&(d.isDragging=!1,d.justDragged=!0,Kinetic.listenClickTap=!1,a&&(a.dragEndNode=e)),delete d.node,(c||e).draw())},_endDragAfter:function(a){a=a||{};var b=a.dragEndNode;a&&b&&b.fire("dragend",{type:"dragend",target:b,evt:a},!0)}},Kinetic.Node.prototype.startDrag=function(){var a=Kinetic.DD,b=this.getStage(),c=this.getLayer(),d=b.getPointerPosition(),e=this.getAbsolutePosition();d&&(a.node&&a.node.stopDrag(),a.node=this,a.startPointerPos=d,a.offset.x=d.x-e.x,a.offset.y=d.y-e.y,a.anim.setLayers(c||this.getLayers()),a.anim.start(),this._setDragPosition())},Kinetic.Node.prototype._setDragPosition=function(a){var b=Kinetic.DD,c=this.getStage().getPointerPosition(),d=this.getDragBoundFunc();if(c){var e={x:c.x-b.offset.x,y:c.y-b.offset.y};void 0!==d&&(e=d.call(this,e,a)),this.setAbsolutePosition(e),this._lastPos&&this._lastPos.x===e.x&&this._lastPos.y===e.y||(b.anim.dirty=!0),this._lastPos=e}},Kinetic.Node.prototype.stopDrag=function(){var a=Kinetic.DD,b={};a._endDragBefore(b),a._endDragAfter(b)},Kinetic.Node.prototype.setDraggable=function(a){this._setAttr("draggable",a),this._dragChange()};var a=Kinetic.Node.prototype.destroy;Kinetic.Node.prototype.destroy=function(){var b=Kinetic.DD;b.node&&b.node._id===this._id&&this.stopDrag(),a.call(this)},Kinetic.Node.prototype.isDragging=function(){var a=Kinetic.DD;return!(!a.node||a.node._id!==this._id||!a.isDragging)},Kinetic.Node.prototype._listenDrag=function(){var a=this;this._dragCleanup(),"Stage"===this.getClassName()?this.on("contentMousedown.kinetic contentTouchstart.kinetic",function(b){Kinetic.DD.node||a.startDrag(b)}):this.on("mousedown.kinetic touchstart.kinetic",function(b){1!==b.evt.button&&2!==b.evt.button&&(Kinetic.DD.node||a.startDrag(b))})},Kinetic.Node.prototype._dragChange=function(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var a=this.getStage(),b=Kinetic.DD;a&&b.node&&b.node._id===this._id&&b.node.stopDrag()}},Kinetic.Node.prototype._dragCleanup=function(){"Stage"===this.getClassName()?(this.off("contentMousedown.kinetic"),this.off("contentTouchstart.kinetic")):(this.off("mousedown.kinetic"),this.off("touchstart.kinetic"))},Kinetic.Factory.addGetterSetter(Kinetic.Node,"dragBoundFunc"),Kinetic.Factory.addGetter(Kinetic.Node,"draggable",!1),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"draggable");var b=Kinetic.document.documentElement;b.addEventListener("mouseup",Kinetic.DD._endDragBefore,!0),b.addEventListener("touchend",Kinetic.DD._endDragBefore,!0),b.addEventListener("mouseup",Kinetic.DD._endDragAfter,!1),b.addEventListener("touchend",Kinetic.DD._endDragAfter,!1)}(),function(){Kinetic.Util.addMethods(Kinetic.Container,{__init:function(a){this.children=new Kinetic.Collection,Kinetic.Node.call(this,a)},getChildren:function(a){if(a){var b=new Kinetic.Collection;return this.children.each(function(c){a(c)&&b.push(c)}),b}return this.children},hasChildren:function(){return this.getChildren().length>0},removeChildren:function(){for(var a,b=Kinetic.Collection.toCollection(this.children),c=0;c1){for(var b=0;bb;b++)if(d=j[b],"#"===d.charAt(0))f=this._getNodeById(d.slice(1)),f&&i.push(f);else if("."===d.charAt(0))e=this._getNodesByName(d.slice(1)),i=i.concat(e);else for(g=this.getChildren(),h=g.length,c=0;h>c;c++)i=i.concat(g[c]._get(d));return Kinetic.Collection.toCollection(i)},_getNodeById:function(a){var b=Kinetic.ids[a];return void 0!==b&&this.isAncestorOf(b)?b:null},_getNodesByName:function(a){var b=Kinetic.names[a]||[];return this._getDescendants(b)},_get:function(a){for(var b=Kinetic.Node.prototype._get.call(this,a),c=this.getChildren(),d=c.length,e=0;d>e;e++)b=b.concat(c[e]._get(a));return b},toObject:function(){var a=Kinetic.Node.prototype.toObject.call(this);a.children=[];for(var b=this.getChildren(),c=b.length,d=0;c>d;d++){var e=b[d];a.children.push(e.toObject())}return a},_getDescendants:function(a){for(var b=[],c=a.length,d=0;c>d;d++){var e=a[d];this.isAncestorOf(e)&&b.push(e)}return b},isAncestorOf:function(a){for(var b=a.getParent();b;){if(b._id===this._id)return!0;b=b.getParent()}return!1},clone:function(a){var b=Kinetic.Node.prototype.clone.call(this,a);return this.getChildren().each(function(a){b.add(a.clone())}),b},getAllIntersections:function(a){var b=[];return this.find("Shape").each(function(c){c.isVisible()&&c.intersects(a)&&b.push(c)}),b},_setChildrenIndices:function(){this.children.each(function(a,b){a.index=b})},drawScene:function(a,b){var c=this.getLayer(),d=a||c&&c.getCanvas(),e=d&&d.getContext(),f=this._cache.canvas,g=f&&f.scene;return this.isVisible()&&(g?this._drawCachedSceneCanvas(e):this._drawChildren(d,"drawScene",b)),this},drawHit:function(a,b){var c=this.getLayer(),d=a||c&&c.hitCanvas,e=d&&d.getContext(),f=this._cache.canvas,g=f&&f.hit;return this.shouldDrawHit(d)&&(c&&c.clearHitCache(),g?this._drawCachedHitCanvas(e):this._drawChildren(d,"drawHit",b)),this},_drawChildren:function(a,b,c){var d,e,f=this.getLayer(),g=a&&a.getContext(),h=this.getClipWidth(),i=this.getClipHeight(),j=h&&i;j&&f&&(d=this.getClipX(),e=this.getClipY(),g.save(),f._applyTransform(this,g),g.beginPath(),g.rect(d,e,h,i),g.clip(),g.reset()),this.children.each(function(d){d[b](a,c)}),j&&g.restore()},shouldDrawHit:function(a){var b=this.getLayer(),c=Kinetic.DD,d=c&&Kinetic.isDragging()&&-1!==Kinetic.DD.anim.getLayers().indexOf(b);return a&&a.isCache||b&&b.hitGraphEnabled()&&this.isVisible()&&!d}}),Kinetic.Util.extend(Kinetic.Container,Kinetic.Node),Kinetic.Container.prototype.get=Kinetic.Container.prototype.find,Kinetic.Factory.addComponentsGetterSetter(Kinetic.Container,"clip",["x","y","width","height"]),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipX"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipY"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipWidth"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipHeight"),Kinetic.Collection.mapMethods(Kinetic.Container)}(),function(){function a(a){a.fill()}function b(a){a.stroke()}function c(a){a.fill()}function d(a){a.stroke()}function e(){this._clearCache(f)}var f="hasShadow";Kinetic.Util.addMethods(Kinetic.Shape,{__init:function(f){this.nodeType="Shape",this._fillFunc=a,this._strokeFunc=b,this._fillFuncHit=c,this._strokeFuncHit=d;for(var g,h=Kinetic.shapes;g=Kinetic.Util.getRandomColor(),!g||g in h;);this.colorKey=g,h[g]=this,Kinetic.Node.call(this,f),this.on("shadowColorChange.kinetic shadowBlurChange.kinetic shadowOffsetChange.kinetic shadowOpacityChange.kinetic shadowEnabledChange.kinetic",e)},hasChildren:function(){return!1},getChildren:function(){return[]},getContext:function(){return this.getLayer().getContext()},getCanvas:function(){return this.getLayer().getCanvas()},hasShadow:function(){return this._getCache(f,this._hasShadow)},_hasShadow:function(){return this.getShadowEnabled()&&0!==this.getShadowOpacity()&&!!(this.getShadowColor()||this.getShadowBlur()||this.getShadowOffsetX()||this.getShadowOffsetY())},hasFill:function(){return!!(this.getFill()||this.getFillPatternImage()||this.getFillLinearGradientColorStops()||this.getFillRadialGradientColorStops())},hasStroke:function(){return!!(this.stroke()||this.strokeRed()||this.strokeGreen()||this.strokeBlue())},intersects:function(a){var b,c=this.getStage(),d=c.bufferHitCanvas;return d.getContext().clear(),this.drawScene(d),b=d.context.getImageData(Math.round(a.x),Math.round(a.y),1,1).data,b[3]>0},destroy:function(){Kinetic.Node.prototype.destroy.call(this),delete Kinetic.shapes[this.colorKey]},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasFill()&&this.hasStroke()&&this.getStage()},drawScene:function(a,b){var c,d,e,f=this.getLayer(),g=a||f.getCanvas(),h=g.getContext(),i=this._cache.canvas,j=this.sceneFunc(),k=this.hasShadow();if(this.isVisible())if(i)this._drawCachedSceneCanvas(h);else if(j){if(h.save(),this._useBufferCanvas()){if(c=this.getStage(),d=c.bufferCanvas,e=d.getContext(),e.clear(),e.save(),e._applyLineJoin(this),f)f._applyTransform(this,e,b);else{var l=this.getAbsoluteTransform(b).getMatrix();h.transform(l[0],l[1],l[2],l[3],l[4],l[5])}j.call(this,e),e.restore(),k&&!g.hitCanvas&&(h.save(),h._applyShadow(this),h.drawImage(d._canvas,0,0),h.restore()),h._applyOpacity(this),h.drawImage(d._canvas,0,0)}else{if(h._applyLineJoin(this),f)f._applyTransform(this,h,b);else{var m=this.getAbsoluteTransform(b).getMatrix();h.transform(m[0],m[1],m[2],m[3],m[4],m[5])}k&&!g.hitCanvas&&(h.save(),h._applyShadow(this),j.call(this,h),h.restore()),h._applyOpacity(this),j.call(this,h)}h.restore()}return this},drawHit:function(a,b){var c=this.getLayer(),d=a||c.hitCanvas,e=d.getContext(),f=this.hitFunc()||this.sceneFunc(),g=this._cache.canvas,h=g&&g.hit;if(this.shouldDrawHit(d))if(c&&c.clearHitCache(),h)this._drawCachedHitCanvas(e);else if(f){if(e.save(),e._applyLineJoin(this),c)c._applyTransform(this,e,b);else{var i=this.getAbsoluteTransform(b).getMatrix();e.transform(i[0],i[1],i[2],i[3],i[4],i[5])}f.call(this,e),e.restore()}return this},drawHitFromCache:function(a){var b,c,d,e,f,g,h,i,j=a||0,k=this._cache.canvas,l=this._getCachedSceneCanvas(),m=l.getContext(),n=k.hit,o=n.getContext(),p=l.getWidth(),q=l.getHeight();o.clear();try{for(b=m.getImageData(0,0,p,q),c=b.data,d=o.getImageData(0,0,p,q),e=d.data,f=c.length,g=Kinetic.Util._hexToRgb(this.colorKey),h=0;f>h;h+=4)i=c[h+3],i>j&&(e[h]=g.r,e[h+1]=g.g,e[h+2]=g.b,e[h+3]=255);o.putImageData(d,0,0)}catch(r){Kinetic.Util.warn("Unable to draw hit graph from cached scene canvas. "+r.message)}return this}}),Kinetic.Util.extend(Kinetic.Shape,Kinetic.Node),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"stroke"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeWidth",2),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"lineJoin"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"lineCap"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"sceneFunc"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"hitFunc"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"dash"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowColor"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowBlur"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOpacity"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"shadowOffset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOffsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOffsetY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternImage"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fill"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientColorStops"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientColorStops"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternRepeat","repeat"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"dashEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeScaleEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPriority","color"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillPatternOffset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternOffsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternOffsetY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillPatternScale",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternScaleX",1),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternScaleY",1),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillLinearGradientStartPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientStartPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientStartPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillLinearGradientEndPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientEndPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientEndPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillRadialGradientStartPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillRadialGradientEndPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndPointY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternRotation",0),Kinetic.Factory.backCompat(Kinetic.Shape,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"}),Kinetic.Collection.mapMethods(Kinetic.Shape)}(),function(){function a(a,b){a.content.addEventListener(b,function(c){a[L+b](c)},!1)}var b="Stage",c="string",d="px",e="mouseout",f="mouseleave",g="mouseover",h="mouseenter",i="mousemove",j="mousedown",k="mouseup",l="click",m="dblclick",n="touchstart",o="touchend",p="tap",q="dbltap",r="touchmove",s="DOMMouseScroll",t="mousewheel",u="wheel",v="contentMouseout",w="contentMouseover",x="contentMousemove",y="contentMousedown",z="contentMouseup",A="contentClick",B="contentDblclick",C="contentTouchstart",D="contentTouchend",E="contentDbltap",F="contentTouchmove",G="div",H="relative",I="inline-block",J="kineticjs-content",K=" ",L="_",M="container",N="",O=[j,i,k,e,n,r,o,g,s,t,u],P=O.length;Kinetic.Util.addMethods(Kinetic.Stage,{___init:function(a){this.nodeType=b,Kinetic.Container.call(this,a),this._id=Kinetic.idCounter++,this._buildDOM(),this._bindContentEvents(),this._enableNestedTransforms=!1,Kinetic.stages.push(this)},_validateAdd:function(a){"Layer"!==a.getType()&&Kinetic.Util.error("You may only add layers to the stage.")},setContainer:function(a){if(typeof a===c){var b=a;if(a=Kinetic.document.getElementById(a),!a)throw"Can not find container in document with id "+b}return this._setAttr(M,a),this},shouldDrawHit:function(){return!0},draw:function(){return Kinetic.Node.prototype.draw.call(this),this},setHeight:function(a){return Kinetic.Node.prototype.setHeight.call(this,a),this._resizeDOM(),this},setWidth:function(a){return Kinetic.Node.prototype.setWidth.call(this,a),this._resizeDOM(),this},clear:function(){var a,b=this.children,c=b.length;for(a=0;c>a;a++)b[a].clear();return this},clone:function(a){return a||(a={}),a.container=Kinetic.document.createElement(G),Kinetic.Container.prototype.clone.call(this,a)},destroy:function(){var a=this.content;Kinetic.Container.prototype.destroy.call(this),a&&Kinetic.Util._isInDocument(a)&&this.getContainer().removeChild(a);var b=Kinetic.stages.indexOf(this);b>-1&&Kinetic.stages.splice(b,1)},getPointerPosition:function(){return this.pointerPos},getStage:function(){return this},getContent:function(){return this.content},toDataURL:function(a){function b(e){var f=i[e],j=f.toDataURL(),k=new Kinetic.window.Image;k.onload=function(){h.drawImage(k,0,0),e=0;b--)if(c=d[b].getIntersection(a))return c;return null},_resizeDOM:function(){if(this.content){var a,b,c=this.getWidth(),e=this.getHeight(),f=this.getChildren(),g=f.length;for(this.content.style.width=c+d,this.content.style.height=e+d,this.bufferCanvas.setSize(c,e),this.bufferHitCanvas.setSize(c,e),a=0;g>a;a++)b=f[a],b.setSize(c,e),b.draw()}},add:function(a){if(!(arguments.length>1))return Kinetic.Container.prototype.add.call(this,a),a._setCanvasSize(this.width(),this.height()),a.draw(),this.content.appendChild(a.canvas._canvas),this;for(var b=0;bb;b++)a(this,O[b])},_mouseover:function(a){Kinetic.UA.mobile||(this._setPointerPosition(a),this._fire(w,{evt:a}))},_mouseout:function(a){if(!Kinetic.UA.mobile){this._setPointerPosition(a);var b=this.targetShape;b&&!Kinetic.isDragging()&&(b._fireAndBubble(e,{evt:a}),b._fireAndBubble(f,{evt:a}),this.targetShape=null),this.pointerPos=void 0,this._fire(v,{evt:a})}},_mousemove:function(a){if(Kinetic.UA.ieMobile)return this._touchmove(a);if(("undefined"==typeof a.webkitMovementX&&"undefined"==typeof a.webkitMovementY||0!==a.webkitMovementY||0!==a.webkitMovementX)&&!Kinetic.UA.mobile){ -this._setPointerPosition(a);var b,c=Kinetic.DD;Kinetic.isDragging()||(b=this.getIntersection(this.getPointerPosition()),b&&b.isListening()?Kinetic.isDragging()||this.targetShape&&this.targetShape._id===b._id?b._fireAndBubble(i,{evt:a}):(this.targetShape&&(this.targetShape._fireAndBubble(e,{evt:a},b),this.targetShape._fireAndBubble(f,{evt:a},b)),b._fireAndBubble(g,{evt:a},this.targetShape),b._fireAndBubble(h,{evt:a},this.targetShape),this.targetShape=b):this.targetShape&&!Kinetic.isDragging()&&(this.targetShape._fireAndBubble(e,{evt:a}),this.targetShape._fireAndBubble(f,{evt:a}),this.targetShape=null),this._fire(x,{evt:a})),c&&c._drag(a),a.preventDefault&&a.preventDefault()}},_mousedown:function(a){if(Kinetic.UA.ieMobile)return this._touchstart(a);if(!Kinetic.UA.mobile){this._setPointerPosition(a);var b=this.getIntersection(this.getPointerPosition());Kinetic.listenClickTap=!0,b&&b.isListening()&&(this.clickStartShape=b,b._fireAndBubble(j,{evt:a})),this._fire(y,{evt:a})}a.preventDefault&&a.preventDefault()},_mouseup:function(a){if(Kinetic.UA.ieMobile)return this._touchend(a);if(!Kinetic.UA.mobile){this._setPointerPosition(a);var b=this.getIntersection(this.getPointerPosition()),c=this.clickStartShape,d=!1,e=Kinetic.DD;Kinetic.inDblClickWindow?(d=!0,Kinetic.inDblClickWindow=!1):e&&e.justDragged?e&&(e.justDragged=!1):Kinetic.inDblClickWindow=!0,setTimeout(function(){Kinetic.inDblClickWindow=!1},Kinetic.dblClickWindow),b&&b.isListening()&&(b._fireAndBubble(k,{evt:a}),Kinetic.listenClickTap&&c&&c._id===b._id&&(b._fireAndBubble(l,{evt:a}),d&&b._fireAndBubble(m,{evt:a}))),this._fire(z,{evt:a}),Kinetic.listenClickTap&&(this._fire(A,{evt:a}),d&&this._fire(B,{evt:a})),Kinetic.listenClickTap=!1}a.preventDefault&&a.preventDefault()},_touchstart:function(a){this._setPointerPosition(a);var b=this.getIntersection(this.getPointerPosition());Kinetic.listenClickTap=!0,b&&b.isListening()&&(this.tapStartShape=b,b._fireAndBubble(n,{evt:a}),b.isListening()&&a.preventDefault&&a.preventDefault()),this._fire(C,{evt:a})},_touchend:function(a){this._setPointerPosition(a);var b=this.getIntersection(this.getPointerPosition()),c=!1;Kinetic.inDblClickWindow?(c=!0,Kinetic.inDblClickWindow=!1):Kinetic.inDblClickWindow=!0,setTimeout(function(){Kinetic.inDblClickWindow=!1},Kinetic.dblClickWindow),b&&b.isListening()&&(b._fireAndBubble(o,{evt:a}),Kinetic.listenClickTap&&b._id===this.tapStartShape._id&&(b._fireAndBubble(p,{evt:a}),c&&b._fireAndBubble(q,{evt:a})),b.isListening()&&a.preventDefault&&a.preventDefault()),Kinetic.listenClickTap&&(this._fire(D,{evt:a}),c&&this._fire(E,{evt:a})),Kinetic.listenClickTap=!1},_touchmove:function(a){this._setPointerPosition(a);var b,c=Kinetic.DD;Kinetic.isDragging()||(b=this.getIntersection(this.getPointerPosition()),b&&b.isListening()&&(b._fireAndBubble(r,{evt:a}),b.isListening()&&a.preventDefault&&a.preventDefault()),this._fire(F,{evt:a})),c&&(c._drag(a),Kinetic.isDragging()&&a.preventDefault())},_DOMMouseScroll:function(a){this._mousewheel(a)},_mousewheel:function(a){this._setPointerPosition(a);var b=this.getIntersection(this.getPointerPosition());b&&b.isListening()&&b._fireAndBubble(t,{evt:a})},_wheel:function(a){this._mousewheel(a)},_setPointerPosition:function(a){var b,c=this._getContentPosition(),d=a.offsetX,e=a.clientX,f=null,g=null;a=a?a:window.event,void 0!==a.touches?a.touches.length>0&&(b=a.touches[0],f=b.clientX-c.left,g=b.clientY-c.top):void 0!==d?(f=d,g=a.offsetY):"mozilla"===Kinetic.UA.browser?(f=a.layerX,g=a.layerY):void 0!==e&&c&&(f=e-c.left,g=a.clientY-c.top),null!==f&&null!==g&&(this.pointerPos={x:f,y:g})},_getContentPosition:function(){var a=this.content.getBoundingClientRect?this.content.getBoundingClientRect():{top:0,left:0};return{top:a.top,left:a.left}},_buildDOM:function(){var a=this.getContainer();if(!a){if(Kinetic.Util.isBrowser())throw"Stage has no container. A container is required.";a=Kinetic.document.createElement(G)}a.innerHTML=N,this.content=Kinetic.document.createElement(G),this.content.style.position=H,this.content.style.display=I,this.content.className=J,this.content.setAttribute("role","presentation"),a.appendChild(this.content),this.bufferCanvas=new Kinetic.SceneCanvas({pixelRatio:1}),this.bufferHitCanvas=new Kinetic.HitCanvas,this._resizeDOM()},_onContent:function(a,b){var c,d,e=a.split(K),f=e.length;for(c=0;f>c;c++)d=e[c],this.content.addEventListener(d,b,!1)},cache:function(){Kinetic.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.")},clearCache:function(){}}),Kinetic.Util.extend(Kinetic.Stage,Kinetic.Container),Kinetic.Factory.addGetter(Kinetic.Stage,"container"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Stage,"container")}(),function(){Kinetic.Util.addMethods(Kinetic.BaseLayer,{___init:function(a){this.nodeType="Layer",Kinetic.Container.call(this,a)},createPNGStream:function(){return this.canvas._canvas.createPNGStream()},getCanvas:function(){return this.canvas},getHitCanvas:function(){return this.hitCanvas},getContext:function(){return this.getCanvas().getContext()},clear:function(a){return this.getContext().clear(a),this.getHitCanvas().getContext().clear(a),this},clearHitCache:function(){this._hitImageData=void 0},setZIndex:function(a){Kinetic.Node.prototype.setZIndex.call(this,a);var b=this.getStage();return b&&(b.content.removeChild(this.getCanvas()._canvas),ac;c++){if(f=d[c],b=this._getIntersection({x:a.x+f.x*h,y:a.y+f.y*h}),g=b.shape)return g;b.antialiased&&(i=!0)}if(!i)return;h+=1}},_getImageData:function(a,b){var c=this.hitCanvas.width||1,d=this.hitCanvas.height||1,e=Math.round(b)*c+Math.round(a);return this._hitImageData||(this._hitImageData=this.hitCanvas.context.getImageData(0,0,c,d)),[this._hitImageData.data[4*e+0],this._hitImageData.data[4*e+1],this._hitImageData.data[4*e+2],this._hitImageData.data[4*e+3]]},_getIntersection:function(b){var c,d,e=this.hitCanvas.context.getImageData(b.x,b.y,1,1).data,f=e[3];return 255===f?(c=Kinetic.Util._rgbToHex(e[0],e[1],e[2]),d=Kinetic.shapes[a+c],{shape:d}):f>0?{antialiased:!0}:{}},drawScene:function(a,d){var e=this.getLayer(),f=a||e&&e.getCanvas();return this._fire(b,{node:this}),this.getClearBeforeDraw()&&f.getContext().clear(),Kinetic.Container.prototype.drawScene.call(this,f,d),this._fire(c,{node:this}),this},_applyTransform:function(a,b,c){var d=a.getAbsoluteTransform(c).getMatrix();b.transform(d[0],d[1],d[2],d[3],d[4],d[5])},drawHit:function(a,b){var c=this.getLayer(),d=a||c&&c.hitCanvas;return c&&c.getClearBeforeDraw()&&c.getHitCanvas().getContext().clear(),Kinetic.Container.prototype.drawHit.call(this,d,b),this.imageData=null,this},clear:function(a){return this.getContext().clear(a),this.getHitCanvas().getContext().clear(a),this.imageData=null,this},setVisible:function(a){return Kinetic.Node.prototype.setVisible.call(this,a),a?(this.getCanvas()._canvas.style.display="block",this.hitCanvas._canvas.style.display="block"):(this.getCanvas()._canvas.style.display="none",this.hitCanvas._canvas.style.display="none"),this},enableHitGraph:function(){return this.setHitGraphEnabled(!0),this},disableHitGraph:function(){return this.setHitGraphEnabled(!1),this},setSize:function(a,b){Kinetic.BaseLayer.prototype.setSize.call(this,a,b),this.hitCanvas.setSize(a,b)}}),Kinetic.Util.extend(Kinetic.Layer,Kinetic.BaseLayer),Kinetic.Factory.addGetterSetter(Kinetic.Layer,"hitGraphEnabled",!0),Kinetic.Collection.mapMethods(Kinetic.Layer)}(),function(){Kinetic.Util.addMethods(Kinetic.FastLayer,{____init:function(a){this.nodeType="Layer",this.canvas=new Kinetic.SceneCanvas,Kinetic.BaseLayer.call(this,a)},_validateAdd:function(a){var b=a.getType();"Shape"!==b&&Kinetic.Util.error("You may only add shapes to a fast layer.")},_setCanvasSize:function(a,b){this.canvas.setSize(a,b)},hitGraphEnabled:function(){return!1},getIntersection:function(){return null},drawScene:function(a){var b=this.getLayer(),c=a||b&&b.getCanvas();return this.getClearBeforeDraw()&&c.getContext().clear(),Kinetic.Container.prototype.drawScene.call(this,c),this},_applyTransform:function(a,b,c){if(!c||c._id!==this._id){var d=a.getTransform().getMatrix();b.transform(d[0],d[1],d[2],d[3],d[4],d[5])}},draw:function(){return this.drawScene(),this},clear:function(a){return this.getContext().clear(a),this},setVisible:function(a){return Kinetic.Node.prototype.setVisible.call(this,a),this.getCanvas()._canvas.style.display=a?"block":"none",this}}),Kinetic.Util.extend(Kinetic.FastLayer,Kinetic.BaseLayer),Kinetic.Collection.mapMethods(Kinetic.FastLayer)}(),function(){Kinetic.Util.addMethods(Kinetic.Group,{___init:function(a){this.nodeType="Group",Kinetic.Container.call(this,a)},_validateAdd:function(a){var b=a.getType();"Group"!==b&&"Shape"!==b&&Kinetic.Util.error("You may only add groups and shapes to groups.")}}),Kinetic.Util.extend(Kinetic.Group,Kinetic.Container),Kinetic.Collection.mapMethods(Kinetic.Group)}(),function(){Kinetic.Rect=function(a){this.___init(a)},Kinetic.Rect.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Rect",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b=this.getCornerRadius(),c=this.getWidth(),d=this.getHeight();a.beginPath(),b?(a.moveTo(b,0),a.lineTo(c-b,0),a.arc(c-b,b,b,3*Math.PI/2,0,!1),a.lineTo(c,d-b),a.arc(c-b,d-b,b,0,Math.PI/2,!1),a.lineTo(b,d),a.arc(b,d-b,b,Math.PI/2,Math.PI,!1),a.lineTo(0,b),a.arc(b,b,b,Math.PI,3*Math.PI/2,!1)):a.rect(0,0,c,d),a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Rect,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Rect,"cornerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Rect)}(),function(){var a=2*Math.PI-1e-4,b="Circle";Kinetic.Circle=function(a){this.___init(a)},Kinetic.Circle.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className=b,this.sceneFunc(this._sceneFunc)},_sceneFunc:function(b){b.beginPath(),b.arc(0,0,this.getRadius(),0,a,!1),b.closePath(),b.fillStrokeShape(this)},getWidth:function(){return 2*this.getRadius()},getHeight:function(){return 2*this.getRadius()},setWidth:function(a){Kinetic.Node.prototype.setWidth.call(this,a),this.radius()!==a/2&&this.setRadius(a/2)},setHeight:function(a){Kinetic.Node.prototype.setHeight.call(this,a),this.radius()!==a/2&&this.setRadius(a/2)},setRadius:function(a){this._setAttr("radius",a),this.setWidth(2*a),this.setHeight(2*a)}},Kinetic.Util.extend(Kinetic.Circle,Kinetic.Shape),Kinetic.Factory.addGetter(Kinetic.Circle,"radius",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Circle,"radius"),Kinetic.Collection.mapMethods(Kinetic.Circle)}(),function(){var a=2*Math.PI-1e-4,b="Ellipse";Kinetic.Ellipse=function(a){this.___init(a)},Kinetic.Ellipse.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className=b,this.sceneFunc(this._sceneFunc)},_sceneFunc:function(b){var c=this.getRadiusX(),d=this.getRadiusY();b.beginPath(),b.save(),c!==d&&b.scale(1,d/c),b.arc(0,0,c,0,a,!1),b.restore(),b.closePath(),b.fillStrokeShape(this)},getWidth:function(){return 2*this.getRadiusX()},getHeight:function(){return 2*this.getRadiusY()},setWidth:function(a){Kinetic.Node.prototype.setWidth.call(this,a),this.setRadius({x:a/2})},setHeight:function(a){Kinetic.Node.prototype.setHeight.call(this,a),this.setRadius({y:a/2})}},Kinetic.Util.extend(Kinetic.Ellipse,Kinetic.Shape),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Ellipse,"radius",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Ellipse,"radiusX",0),Kinetic.Factory.addGetterSetter(Kinetic.Ellipse,"radiusY",0),Kinetic.Collection.mapMethods(Kinetic.Ellipse)}(),function(){var a=2*Math.PI-1e-4;Kinetic.Ring=function(a){this.___init(a)},Kinetic.Ring.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Ring",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(b){b.beginPath(),b.arc(0,0,this.getInnerRadius(),0,a,!1),b.moveTo(this.getOuterRadius(),0),b.arc(0,0,this.getOuterRadius(),a,0,!0),b.closePath(),b.fillStrokeShape(this)},getWidth:function(){return 2*this.getOuterRadius()},getHeight:function(){return 2*this.getOuterRadius()},setWidth:function(a){Kinetic.Node.prototype.setWidth.call(this,a),this.outerRadius()!==a/2&&this.setOuterRadius(a/2)},setHeight:function(a){Kinetic.Node.prototype.setHeight.call(this,a),this.outerRadius()!==a/2&&this.setOuterRadius(a/2)},setOuterRadius:function(a){this._setAttr("outerRadius",a),this.setWidth(2*a),this.setHeight(2*a)}},Kinetic.Util.extend(Kinetic.Ring,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Ring,"innerRadius",0),Kinetic.Factory.addGetter(Kinetic.Ring,"outerRadius",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Ring,"outerRadius"),Kinetic.Collection.mapMethods(Kinetic.Ring)}(),function(){Kinetic.Wedge=function(a){this.___init(a)},Kinetic.Wedge.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Wedge",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){a.beginPath(),a.arc(0,0,this.getRadius(),0,Kinetic.getAngle(this.getAngle()),this.getClockwise()),a.lineTo(0,0),a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Wedge,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"radius",0),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"angle",0),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"clockwise",!1),Kinetic.Factory.backCompat(Kinetic.Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),Kinetic.Collection.mapMethods(Kinetic.Wedge)}(),function(){Kinetic.Arc=function(a){this.___init(a)},Kinetic.Arc.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Arc",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b=Kinetic.getAngle(this.angle()),c=this.clockwise();a.beginPath(),a.arc(0,0,this.getOuterRadius(),0,b,c),a.arc(0,0,this.getInnerRadius(),b,0,!c),a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Arc,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"innerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"outerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"angle",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"clockwise",!1),Kinetic.Collection.mapMethods(Kinetic.Arc)}(),function(){var a="Image";Kinetic.Image=function(a){this.___init(a)},Kinetic.Image.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className=a,this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()&&this.getStage()},_sceneFunc:function(a){var b,c,d,e=this.getWidth(),f=this.getHeight(),g=this.getImage();g&&(b=this.getCropWidth(),c=this.getCropHeight(),d=b&&c?[g,this.getCropX(),this.getCropY(),b,c,0,0,e,f]:[g,0,0,e,f]),(this.hasFill()||this.hasStroke()||this.hasShadow())&&(a.beginPath(),a.rect(0,0,e,f),a.closePath(),a.fillStrokeShape(this)),g&&a.drawImage.apply(a,d)},_hitFunc:function(a){var b=this.getWidth(),c=this.getHeight();a.beginPath(),a.rect(0,0,b,c),a.closePath(),a.fillStrokeShape(this)},getWidth:function(){var a=this.getImage();return this.attrs.width||(a?a.width:0)},getHeight:function(){var a=this.getImage();return this.attrs.height||(a?a.height:0)}},Kinetic.Util.extend(Kinetic.Image,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Image,"image"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Image,"crop",["x","y","width","height"]),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropX",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropY",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropWidth",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropHeight",0),Kinetic.Collection.mapMethods(Kinetic.Image)}(),function(){function a(a){a.fillText(this.partialText,0,0)}function b(a){a.strokeText(this.partialText,0,0)}var c="auto",d="center",e="Change.kinetic",f="2d",g="-",h="",i="left",j="text",k="Text",l="middle",m="normal",n="px ",o=" ",p="right",q="word",r="char",s="none",t=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","lineHeight","text","width","height","wrap"],u=t.length,v=Kinetic.Util.createCanvasElement().getContext(f);Kinetic.Text=function(a){this.___init(a)},Kinetic.Text.prototype={___init:function(d){d=d||{},d.fill=d.fill||"black",void 0===d.width&&(d.width=c),void 0===d.height&&(d.height=c),Kinetic.Shape.call(this,d),this._fillFunc=a,this._strokeFunc=b,this.className=k;for(var f=0;u>f;f++)this.on(t[f]+e,this._setTextData);this._setTextData(),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(a){var b,c=this.getPadding(),e=this.getTextHeight(),f=this.getLineHeight()*e,g=this.textArr,h=g.length,j=this.getWidth();for(a.setAttr("font",this._getContextFont()),a.setAttr("textBaseline",l),a.setAttr("textAlign",i),a.save(),a.translate(c,0),a.translate(0,c+e/2),b=0;h>b;b++){var k=g[b],m=k.text,n=k.width;a.save(),this.getAlign()===p?a.translate(j-n-2*c,0):this.getAlign()===d&&a.translate((j-n-2*c)/2,0),this.partialText=m,a.fillStrokeShape(this),a.restore(),a.translate(0,f)}a.restore()},_hitFunc:function(a){var b=this.getWidth(),c=this.getHeight();a.beginPath(),a.rect(0,0,b,c),a.closePath(),a.fillStrokeShape(this)},setText:function(a){var b=Kinetic.Util._isString(a)?a:a.toString();return this._setAttr(j,b),this},getWidth:function(){return this.attrs.width===c?this.getTextWidth()+2*this.getPadding():this.attrs.width},getHeight:function(){return this.attrs.height===c?this.getTextHeight()*this.textArr.length*this.getLineHeight()+2*this.getPadding():this.attrs.height},getTextWidth:function(){return this.textWidth},getTextHeight:function(){return this.textHeight},_getTextSize:function(a){var b,c=v,d=this.getFontSize();return c.save(),c.font=this._getContextFont(),b=c.measureText(a),c.restore(),{width:b.width,height:parseInt(d,10)}},_getContextFont:function(){return this.getFontStyle()+o+this.getFontVariant()+o+this.getFontSize()+n+this.getFontFamily()},_addTextLine:function(a,b){return this.textArr.push({text:a,width:b})},_getTextWidth:function(a){return v.measureText(a).width},_setTextData:function(){var a=this.getText().split("\n"),b=+this.getFontSize(),d=0,e=this.getLineHeight()*b,f=this.attrs.width,h=this.attrs.height,i=f!==c,j=h!==c,k=this.getPadding(),l=f-2*k,m=h-2*k,n=0,p=this.getWrap(),q=p!==s,t=p!==r&&q;this.textArr=[],v.save(),v.font=this._getContextFont();for(var u=0,w=a.length;w>u;++u){var x=a[u],y=this._getTextWidth(x);if(i&&y>l)for(;x.length>0;){for(var z=0,A=x.length,B="",C=0;A>z;){var D=z+A>>>1,E=x.slice(0,D+1),F=this._getTextWidth(E);l>=F?(z=D+1,B=E,C=F):A=D}if(!B)break;if(t){var G=Math.max(B.lastIndexOf(o),B.lastIndexOf(g))+1;G>0&&(z=G,B=B.slice(0,z),C=this._getTextWidth(B))}if(this._addTextLine(B,C),d=Math.max(d,C),n+=e,!q||j&&n+e>m)break;if(x=x.slice(z),x.length>0&&(y=this._getTextWidth(x),l>=y)){this._addTextLine(x,y),n+=e,d=Math.max(d,y);break}}else this._addTextLine(x,y),n+=e,d=Math.max(d,y);if(j&&n+e>m)break}v.restore(),this.textHeight=b,this.textWidth=d}},Kinetic.Util.extend(Kinetic.Text,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontFamily","Arial"),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontSize",12),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontStyle",m),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontVariant",m),Kinetic.Factory.addGetterSetter(Kinetic.Text,"padding",0),Kinetic.Factory.addGetterSetter(Kinetic.Text,"align",i),Kinetic.Factory.addGetterSetter(Kinetic.Text,"lineHeight",1),Kinetic.Factory.addGetterSetter(Kinetic.Text,"wrap",q),Kinetic.Factory.addGetter(Kinetic.Text,"text",h),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Text,"text"),Kinetic.Collection.mapMethods(Kinetic.Text)}(),function(){Kinetic.Line=function(a){this.___init(a)},Kinetic.Line.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Line",this.on("pointsChange.kinetic tensionChange.kinetic closedChange.kinetic",function(){this._clearCache("tensionPoints")}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b,c,d,e=this.getPoints(),f=e.length,g=this.getTension(),h=this.getClosed();if(f){if(a.beginPath(),a.moveTo(e[0],e[1]),0!==g&&f>4){for(b=this.getTensionPoints(),c=b.length,d=h?0:4,h||a.quadraticCurveTo(b[0],b[1],b[2],b[3]);c-2>d;)a.bezierCurveTo(b[d++],b[d++],b[d++],b[d++],b[d++],b[d++]);h||a.quadraticCurveTo(b[c-2],b[c-1],e[f-2],e[f-1])}else for(d=2;f>d;d+=2)a.lineTo(e[d],e[d+1]);h?(a.closePath(),a.fillStrokeShape(this)):a.strokeShape(this)}},getTensionPoints:function(){return this._getCache("tensionPoints",this._getTensionPoints)},_getTensionPoints:function(){return this.getClosed()?this._getTensionPointsClosed():Kinetic.Util._expandPoints(this.getPoints(),this.getTension())},_getTensionPointsClosed:function(){var a=this.getPoints(),b=a.length,c=this.getTension(),d=Kinetic.Util,e=d._getControlPoints(a[b-2],a[b-1],a[0],a[1],a[2],a[3],c),f=d._getControlPoints(a[b-4],a[b-3],a[b-2],a[b-1],a[0],a[1],c),g=Kinetic.Util._expandPoints(a,c),h=[e[2],e[3]].concat(g).concat([f[0],f[1],a[b-2],a[b-1],f[2],f[3],e[0],e[1],a[0],a[1]]);return h}},Kinetic.Util.extend(Kinetic.Line,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Line,"closed",!1),Kinetic.Factory.addGetterSetter(Kinetic.Line,"tension",0),Kinetic.Factory.addGetterSetter(Kinetic.Line,"points",[]),Kinetic.Collection.mapMethods(Kinetic.Line)}(),function(){Kinetic.Sprite=function(a){this.___init(a)},Kinetic.Sprite.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Sprite",this._updated=!0;var b=this;this.anim=new Kinetic.Animation(function(){var a=b._updated;return b._updated=!1,a}),this.on("animationChange.kinetic",function(){this.frameIndex(0)}),this.on("frameIndexChange.kinetic",function(){this._updated=!0}),this.on("frameRateChange.kinetic",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(a){var b=this.getAnimation(),c=this.frameIndex(),d=4*c,e=this.getAnimations()[b],f=this.frameOffsets(),g=e[d+0],h=e[d+1],i=e[d+2],j=e[d+3],k=this.getImage();if(k)if(f){var l=f[b],m=2*c;a.drawImage(k,g,h,i,j,l[m+0],l[m+1],i,j)}else a.drawImage(k,g,h,i,j,0,0,i,j)},_hitFunc:function(a){var b=this.getAnimation(),c=this.frameIndex(),d=4*c,e=this.getAnimations()[b],f=this.frameOffsets(),g=e[d+2],h=e[d+3];if(a.beginPath(),f){var i=f[b],j=2*c;a.rect(i[j+0],i[j+1],g,h)}else a.rect(0,0,g,h);a.closePath(),a.fillShape(this)},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()},_setInterval:function(){var a=this;this.interval=setInterval(function(){a._updateIndex()},1e3/this.getFrameRate())},start:function(){var a=this.getLayer();this.anim.setLayers(a),this._setInterval(),this.anim.start()},stop:function(){this.anim.stop(),clearInterval(this.interval)},isRunning:function(){return this.anim.isRunning()},_updateIndex:function(){var a=this.frameIndex(),b=this.getAnimation(),c=this.getAnimations(),d=c[b],e=d.length/4;this.frameIndex(e-1>a?a+1:0)}},Kinetic.Util.extend(Kinetic.Sprite,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"animation"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"animations"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameOffsets"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"image"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameIndex",0),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameRate",17),Kinetic.Factory.backCompat(Kinetic.Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Kinetic.Collection.mapMethods(Kinetic.Sprite)}(),function(){Kinetic.Path=function(a){this.___init(a)},Kinetic.Path.prototype={___init:function(a){this.dataArray=[];var b=this;Kinetic.Shape.call(this,a),this.className="Path",this.dataArray=Kinetic.Path.parsePathData(this.getData()),this.on("dataChange.kinetic",function(){b.dataArray=Kinetic.Path.parsePathData(this.getData())}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b=this.dataArray,c=!1;a.beginPath();for(var d=0;dj?i:j,p=i>j?1:i/j,q=i>j?j/i:1;a.translate(g,h),a.rotate(m),a.scale(p,q),a.arc(0,0,o,k,k+l,1-n),a.scale(1/p,1/q),a.rotate(-m),a.translate(-g,-h);break;case"z":a.closePath(),c=!0}}c?a.fillStrokeShape(this):a.strokeShape(this)}},Kinetic.Util.extend(Kinetic.Path,Kinetic.Shape),Kinetic.Path.getLineLength=function(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))},Kinetic.Path.getPointOnLine=function(a,b,c,d,e,f,g){void 0===f&&(f=b),void 0===g&&(g=c);var h=(e-c)/(d-b+1e-8),i=Math.sqrt(a*a/(1+h*h));b>d&&(i*=-1);var j,k=h*i;if(d===b)j={x:f,y:g+k};else if((g-c)/(f-b+1e-8)===h)j={x:f+i,y:g+k};else{var l,m,n=this.getLineLength(b,c,d,e);if(1e-8>n)return;var o=(f-b)*(d-b)+(g-c)*(e-c);o/=n*n,l=b+o*(d-b),m=c+o*(e-c);var p=this.getLineLength(f,g,l,m),q=Math.sqrt(a*a-p*p);i=Math.sqrt(q*q/(1+h*h)),b>d&&(i*=-1),k=h*i,j={x:l+i,y:m+k}}return j},Kinetic.Path.getPointOnCubicBezier=function(a,b,c,d,e,f,g,h,i){function j(a){return a*a*a}function k(a){return 3*a*a*(1-a)}function l(a){return 3*a*(1-a)*(1-a)}function m(a){return(1-a)*(1-a)*(1-a)}var n=h*j(a)+f*k(a)+d*l(a)+b*m(a),o=i*j(a)+g*k(a)+e*l(a)+c*m(a);return{x:n,y:o}},Kinetic.Path.getPointOnQuadraticBezier=function(a,b,c,d,e,f,g){function h(a){return a*a}function i(a){return 2*a*(1-a)}function j(a){return(1-a)*(1-a)}var k=f*h(a)+d*i(a)+b*j(a),l=g*h(a)+e*i(a)+c*j(a);return{x:k,y:l}},Kinetic.Path.getPointOnEllipticalArc=function(a,b,c,d,e,f){var g=Math.cos(f),h=Math.sin(f),i={x:c*Math.cos(e),y:d*Math.sin(e)};return{x:a+(i.x*g-i.y*h),y:b+(i.x*h+i.y*g)}},Kinetic.Path.parsePathData=function(a){if(!a)return[];var b=a,c=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];b=b.replace(new RegExp(" ","g"),",");for(var d=0;d0&&""===k[0]&&k.shift();for(var l=0;l0&&!isNaN(k[0]);){var m,n,o,p,q,r,s,t,u,v,w=null,x=[],y=g,z=h;switch(j){case"l":g+=k.shift(),h+=k.shift(),w="L",x.push(g,h);break;case"L":g=k.shift(),h=k.shift(),x.push(g,h);break;case"m":var A=k.shift(),B=k.shift();if(g+=A,h+=B,w="M",f.length>2&&"z"===f[f.length-1].command)for(var C=f.length-2;C>=0;C--)if("M"===f[C].command){g=f[C].points[0]+A,h=f[C].points[1]+B;break}x.push(g,h),j="l";break;case"M":g=k.shift(),h=k.shift(),w="M",x.push(g,h),j="L";break;case"h":g+=k.shift(),w="L",x.push(g,h);break;case"H":g=k.shift(),w="L",x.push(g,h);break;case"v":h+=k.shift(),w="L",x.push(g,h);break;case"V":h=k.shift(),w="L",x.push(g,h);break;case"C":x.push(k.shift(),k.shift(),k.shift(),k.shift()),g=k.shift(),h=k.shift(),x.push(g,h);break;case"c":x.push(g+k.shift(),h+k.shift(),g+k.shift(),h+k.shift()),g+=k.shift(),h+=k.shift(),w="C",x.push(g,h);break;case"S":n=g,o=h,m=f[f.length-1],"C"===m.command&&(n=g+(g-m.points[2]),o=h+(h-m.points[3])),x.push(n,o,k.shift(),k.shift()),g=k.shift(),h=k.shift(),w="C",x.push(g,h);break;case"s":n=g,o=h,m=f[f.length-1],"C"===m.command&&(n=g+(g-m.points[2]),o=h+(h-m.points[3])),x.push(n,o,g+k.shift(),h+k.shift()),g+=k.shift(),h+=k.shift(),w="C",x.push(g,h);break;case"Q":x.push(k.shift(),k.shift()),g=k.shift(),h=k.shift(),x.push(g,h);break;case"q":x.push(g+k.shift(),h+k.shift()),g+=k.shift(),h+=k.shift(),w="Q",x.push(g,h);break;case"T":n=g,o=h,m=f[f.length-1],"Q"===m.command&&(n=g+(g-m.points[0]),o=h+(h-m.points[1])),g=k.shift(),h=k.shift(),w="Q",x.push(n,o,g,h);break;case"t":n=g,o=h,m=f[f.length-1],"Q"===m.command&&(n=g+(g-m.points[0]),o=h+(h-m.points[1])),g+=k.shift(),h+=k.shift(),w="Q",x.push(n,o,g,h);break;case"A":p=k.shift(),q=k.shift(),r=k.shift(),s=k.shift(),t=k.shift(),u=g,v=h,g=k.shift(),h=k.shift(),w="A",x=this.convertEndpointToCenterParameterization(u,v,g,h,s,t,p,q,r);break;case"a":p=k.shift(),q=k.shift(),r=k.shift(),s=k.shift(),t=k.shift(),u=g,v=h,g+=k.shift(),h+=k.shift(),w="A",x=this.convertEndpointToCenterParameterization(u,v,g,h,s,t,p,q,r)}f.push({command:w||j,points:x,start:{x:y,y:z},pathLength:this.calcLength(y,z,w||j,x)})}("z"===j||"Z"===j)&&f.push({command:"z",points:[],start:void 0,pathLength:0})}return f},Kinetic.Path.calcLength=function(a,b,c,d){var e,f,g,h,i=Kinetic.Path;switch(c){case"L":return i.getLineLength(a,b,d[0],d[1]);case"C":for(e=0,f=i.getPointOnCubicBezier(0,a,b,d[0],d[1],d[2],d[3],d[4],d[5]),h=.01;1>=h;h+=.01)g=i.getPointOnCubicBezier(h,a,b,d[0],d[1],d[2],d[3],d[4],d[5]),e+=i.getLineLength(f.x,f.y,g.x,g.y),f=g;return e;case"Q":for(e=0,f=i.getPointOnQuadraticBezier(0,a,b,d[0],d[1],d[2],d[3]),h=.01;1>=h;h+=.01)g=i.getPointOnQuadraticBezier(h,a,b,d[0],d[1],d[2],d[3]),e+=i.getLineLength(f.x,f.y,g.x,g.y),f=g;return e;case"A":e=0;var j=d[4],k=d[5],l=d[4]+k,m=Math.PI/180;if(Math.abs(j-l)k)for(h=j-m;h>l;h-=m)g=i.getPointOnEllipticalArc(d[0],d[1],d[2],d[3],h,0),e+=i.getLineLength(f.x,f.y,g.x,g.y),f=g;else for(h=j+m;l>h;h+=m)g=i.getPointOnEllipticalArc(d[0],d[1],d[2],d[3],h,0), -e+=i.getLineLength(f.x,f.y,g.x,g.y),f=g;return g=i.getPointOnEllipticalArc(d[0],d[1],d[2],d[3],l,0),e+=i.getLineLength(f.x,f.y,g.x,g.y)}return 0},Kinetic.Path.convertEndpointToCenterParameterization=function(a,b,c,d,e,f,g,h,i){var j=i*(Math.PI/180),k=Math.cos(j)*(a-c)/2+Math.sin(j)*(b-d)/2,l=-1*Math.sin(j)*(a-c)/2+Math.cos(j)*(b-d)/2,m=k*k/(g*g)+l*l/(h*h);m>1&&(g*=Math.sqrt(m),h*=Math.sqrt(m));var n=Math.sqrt((g*g*h*h-g*g*l*l-h*h*k*k)/(g*g*l*l+h*h*k*k));e===f&&(n*=-1),isNaN(n)&&(n=0);var o=n*g*l/h,p=n*-h*k/g,q=(a+c)/2+Math.cos(j)*o-Math.sin(j)*p,r=(b+d)/2+Math.sin(j)*o+Math.cos(j)*p,s=function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])},t=function(a,b){return(a[0]*b[0]+a[1]*b[1])/(s(a)*s(b))},u=function(a,b){return(a[0]*b[1]=1&&(y=0),0===f&&y>0&&(y-=2*Math.PI),1===f&&0>y&&(y+=2*Math.PI),[q,r,g,h,v,y,j,f]},Kinetic.Factory.addGetterSetter(Kinetic.Path,"data"),Kinetic.Collection.mapMethods(Kinetic.Path)}(),function(){function a(a){a.fillText(this.partialText,0,0)}function b(a){a.strokeText(this.partialText,0,0)}var c="",d="normal";Kinetic.TextPath=function(a){this.___init(a)},Kinetic.TextPath.prototype={___init:function(c){var d=this;this.dummyCanvas=Kinetic.Util.createCanvasElement(),this.dataArray=[],Kinetic.Shape.call(this,c),this._fillFunc=a,this._strokeFunc=b,this._fillFuncHit=a,this._strokeFuncHit=b,this.className="TextPath",this.dataArray=Kinetic.Path.parsePathData(this.attrs.data),this.on("dataChange.kinetic",function(){d.dataArray=Kinetic.Path.parsePathData(this.attrs.data)}),this.on("textChange.kinetic textStroke.kinetic textStrokeWidth.kinetic",d._setTextData),d._setTextData(),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){a.setAttr("font",this._getContextFont()),a.setAttr("textBaseline","middle"),a.setAttr("textAlign","left"),a.save();for(var b=this.glyphInfo,c=0;c0)return g=d,b[d];"M"==b[d].command&&(c={x:b[d].points[0],y:b[d].points[1]})}return{}},j=function(b){var f=a._getTextSize(b).width,g=0,j=0;for(d=void 0;Math.abs(f-g)/f>.01&&25>j;){j++;for(var k=g;void 0===e;)e=i(),e&&k+e.pathLengthf?d=Kinetic.Path.getPointOnLine(f,c.x,c.y,e.points[0],e.points[1],c.x,c.y):e=void 0;break;case"A":var m=e.points[4],n=e.points[5],o=e.points[4]+n;0===h?h=m+1e-8:f>g?h+=Math.PI/180*n/Math.abs(n):h-=Math.PI/360*n/Math.abs(n),(0>n&&o>h||n>=0&&h>o)&&(h=o,l=!0),d=Kinetic.Path.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],h,e.points[6]);break;case"C":0===h?h=f>e.pathLength?1e-8:f/e.pathLength:f>g?h+=(f-g)/e.pathLength:h-=(g-f)/e.pathLength,h>1&&(h=1,l=!0),d=Kinetic.Path.getPointOnCubicBezier(h,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3],e.points[4],e.points[5]);break;case"Q":0===h?h=f/e.pathLength:f>g?h+=(f-g)/e.pathLength:h-=(g-f)/e.pathLength,h>1&&(h=1,l=!0),d=Kinetic.Path.getPointOnQuadraticBezier(h,e.start.x,e.start.y,e.points[0],e.points[1],e.points[2],e.points[3])}void 0!==d&&(g=Kinetic.Path.getLineLength(c.x,c.y,d.x,d.y)),l&&(l=!1,e=void 0)}},k=0;kb;b++)c=f*Math.sin(2*b*Math.PI/e),d=-1*f*Math.cos(2*b*Math.PI/e),a.lineTo(c,d);a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.RegularPolygon,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.RegularPolygon,"radius",0),Kinetic.Factory.addGetterSetter(Kinetic.RegularPolygon,"sides",0),Kinetic.Collection.mapMethods(Kinetic.RegularPolygon)}(),function(){Kinetic.Star=function(a){this.___init(a)},Kinetic.Star.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Star",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b=this.innerRadius(),c=this.outerRadius(),d=this.numPoints();a.beginPath(),a.moveTo(0,0-c);for(var e=1;2*d>e;e++){var f=e%2===0?c:b,g=f*Math.sin(e*Math.PI/d),h=-1*f*Math.cos(e*Math.PI/d);a.lineTo(g,h)}a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Star,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Star,"numPoints",5),Kinetic.Factory.addGetterSetter(Kinetic.Star,"innerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Star,"outerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Star)}(),function(){var a=["fontFamily","fontSize","fontStyle","padding","lineHeight","text"],b="Change.kinetic",c="none",d="up",e="right",f="down",g="left",h="Label",i=a.length;Kinetic.Label=function(a){this.____init(a)},Kinetic.Label.prototype={____init:function(a){var b=this;Kinetic.Group.call(this,a),this.className=h,this.on("add.kinetic",function(a){b._addListeners(a.child),b._sync()})},getText:function(){return this.find("Text")[0]},getTag:function(){return this.find("Tag")[0]},_addListeners:function(c){var d,e=this,f=function(){e._sync()};for(d=0;i>d;d++)c.on(a[d]+b,f)},getWidth:function(){return this.getText().getWidth()},getHeight:function(){return this.getText().getHeight()},_sync:function(){var a,b,c,h,i,j,k,l=this.getText(),m=this.getTag();if(l&&m){switch(a=l.getWidth(),b=l.getHeight(),c=m.getPointerDirection(),h=m.getPointerWidth(),k=m.getPointerHeight(),i=0,j=0,c){case d:i=a/2,j=-1*k;break;case e:i=a+h,j=b/2;break;case f:i=a/2,j=b+k;break;case g:i=-1*h,j=b/2}m.setAttrs({x:-1*i,y:-1*j,width:a,height:b}),l.setAttrs({x:-1*i,y:-1*j})}}},Kinetic.Util.extend(Kinetic.Label,Kinetic.Group),Kinetic.Collection.mapMethods(Kinetic.Label),Kinetic.Tag=function(a){this.___init(a)},Kinetic.Tag.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className="Tag",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var b=this.getWidth(),c=this.getHeight(),h=this.getPointerDirection(),i=this.getPointerWidth(),j=this.getPointerHeight(),k=this.getCornerRadius();a.beginPath(),a.moveTo(0,0),h===d&&(a.lineTo((b-i)/2,0),a.lineTo(b/2,-1*j),a.lineTo((b+i)/2,0)),k?(a.lineTo(b-k,0),a.arc(b-k,k,k,3*Math.PI/2,0,!1)):a.lineTo(b,0),h===e&&(a.lineTo(b,(c-j)/2),a.lineTo(b+i,c/2),a.lineTo(b,(c+j)/2)),k?(a.lineTo(b,c-k),a.arc(b-k,c-k,k,0,Math.PI/2,!1)):a.lineTo(b,c),h===f&&(a.lineTo((b+i)/2,c),a.lineTo(b/2,c+j),a.lineTo((b-i)/2,c)),k?(a.lineTo(k,c),a.arc(k,c-k,k,Math.PI/2,Math.PI,!1)):a.lineTo(0,c),h===g&&(a.lineTo(0,(c+j)/2),a.lineTo(-1*i,c/2),a.lineTo(0,(c-j)/2)),k&&(a.lineTo(0,k),a.arc(k,k,k,Math.PI,3*Math.PI/2,!1)),a.closePath(),a.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Tag,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerDirection",c),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerWidth",0),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerHeight",0),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"cornerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Tag)}(),function(){Kinetic.Arrow=function(a){this.____init(a)},Kinetic.Arrow.prototype={____init:function(a){Kinetic.Line.call(this,a),this.className="Arrow"},_sceneFunc:function(a){var b=2*Math.PI,c=this.points(),d=c.length,e=c[d-2]-c[d-4],f=c[d-1]-c[d-3],g=(Math.atan2(f,e)+b)%b,h=this.pointerLength(),i=this.pointerWidth();a.save(),a.beginPath(),a.translate(c[d-2],c[d-1]),a.rotate(g),a.moveTo(0,0),a.lineTo(-h,i/2),a.lineTo(-h,-i/2),a.closePath(),a.restore(),this.pointerAtBeginning()&&(a.save(),a.translate(c[0],c[1]),e=c[2]-c[0],f=c[3]-c[1],a.rotate((Math.atan2(-f,-e)+b)%b),a.moveTo(0,0),a.lineTo(-10,6),a.lineTo(-10,-6),a.closePath(),a.restore()),a.fillStrokeShape(this),Kinetic.Line.prototype._sceneFunc.apply(this,arguments)}},Kinetic.Util.extend(Kinetic.Arrow,Kinetic.Line),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerLength",10),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerWidth",10),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerAtBeginning",!1),Kinetic.Collection.mapMethods(Kinetic.Arrow)}(),function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){"use strict";function b(b){return!b.nodeName||-1!==a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"])}function c(b){return a.isFunction(b)||a.isPlainObject(b)?b:{top:b,left:b}}var d=a.scrollTo=function(b,c,d){return a(window).scrollTo(b,c,d)};return d.defaults={axis:"xy",duration:0,limit:!0},a.fn.scrollTo=function(e,f,g){"object"==typeof f&&(g=f,f=0),"function"==typeof g&&(g={onAfter:g}),"max"===e&&(e=9e9),g=a.extend({},d.defaults,g),f=f||g.duration;var h=g.queue&&1=o[f]?0:Math.min(o[f],r)),!a&&1",{"class":i.cl.enjoy_hint+" "+i.cl.svg_transparent}).appendTo(z);i.enjoyhint_svg_wrapper=f("
",{"class":i.cl.svg_wrapper+" "+i.cl.svg_transparent}).appendTo(i.enjoyhint);i.$stage_container=f('
').appendTo(i.enjoyhint);i.$canvas=f('').appendTo(i.enjoyhint);i.$svg=f('').appendTo(i.enjoyhint_svg_wrapper);var y=f(v("defs"));var A=f(v("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"}));var C=f(v("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20"}));y.append(A.append(C)).appendTo(i.$svg);i.kinetic_stage=new Kinetic.Stage({container:i.cl.kinetic_container,width:i.canvas_size.w,height:i.canvas_size.h,scaleX:1});i.layer=new Kinetic.Layer();i.rect=new Kinetic.Rect({fill:"rgba(0,0,0,0.6)",width:i.canvas_size.w,height:i.canvas_size.h});var u=f("
",{"class":i.cl.disable_events_element}).appendTo(i.enjoyhint);var B=u.clone().appendTo(i.enjoyhint);var r=u.clone().appendTo(i.enjoyhint);var q=u.clone().appendTo(i.enjoyhint);var E=function(F){F.stopImmediatePropagation()};f("button").focusout(E);u.click(E);B.click(E);r.click(E);q.click(E);i.$skip_btn=f("
",{"class":i.cl.skip_btn}).appendTo(i.enjoyhint).html("Skip").click(function(F){i.hide();i.options.onSkipClick()});i.$next_btn=f("
",{"class":i.cl.next_btn}).appendTo(i.enjoyhint).html("Next").click(function(F){i.options.onNextClick()});i.$close_btn=f("
",{"class":i.cl.close_btn}).appendTo(i.enjoyhint).html("").click(function(F){i.hide();i.options.onSkipClick()});i.$canvas.mousedown(function(G){f("canvas").css({left:"4000px"});var F=document.elementFromPoint(G.clientX,G.clientY);f("canvas").css({left:"0px"});f(F).click();return false});var x=0;var s=130;i.shape=new Kinetic.Shape({radius:x,center_x:-s,center_y:-s,width:0,height:0,sceneFunc:function(H){var G=this.getContext("2d")._context;var K=this.pos;var I=G.globalCompositeOperation;G.globalCompositeOperation="destination-out";G.beginPath();var F=this.attrs.center_x-Math.round(this.attrs.width/2);var J=this.attrs.center_y-Math.round(this.attrs.height/2);G.roundRect(F,J,this.attrs.width,this.attrs.height,this.attrs.radius);G.fillStyle="red";G.fill();G.globalCompositeOperation=I}});i.shape.radius=x;i.layer.add(i.rect);i.layer.add(i.shape);i.kinetic_stage.add(i.layer);f(window).on("resize",function(){if(!(f(i.stepData.enjoyHintElementSelector).is(":visible"))){i.stopFunction();f(window).off("resize");return}n=window.innerWidth;o=window.innerHeight;var X=f(i.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();i.shape.attrs.center_x=Math.round(X.left+X.width/2);i.shape.attrs.center_y=Math.round(X.top+X.height/2);i.shape.attrs.width=X.width+11;i.shape.attrs.height=X.height+11;var L=window.innerWidth;var Q=window.innerHeight;var Z=L/a;var Y=Q/e;i.kinetic_stage.setAttr("width",a*Z);i.kinetic_stage.setAttr("height",e*Y);if(i.stepData!=null){n=window.innerWidth;o=window.innerHeight;if(!m){m=i.shape.attrs.center_x;l=i.shape.attrs.center_y}if(!g){g=[];var O=f("#enjoyhint_arrpw_line").attr("d");g.push(O.substr(1).split(",")[0]);g.push(O.substr(O.indexOf("Q")+1).split(",")[0]);g.push(O.split(" ")[2].split(",")[0]);h=[];h.push(O.split(",")[1].split(" ")[0]);h.push(O.split(",")[2].split(" ")[0]);h.push(O.split(",")[3])}var F=f(".enjoy_hint_label");if(!k){k=F[0].getBoundingClientRect().left;c=F[0].getBoundingClientRect().top}var R=f(".enjoyhint_skip_btn");if(!b){b=R[0].getBoundingClientRect().left;j=R[0].getBoundingClientRect().top}F.css("left",window.innerWidth/2-F.outerWidth()/2);var V=F[0].getBoundingClientRect();if(window.innerWidth<640){f("#enjoyhint_arrpw_line").hide();F.css("top",window.innerHeight/2-F.outerHeight()/2)}else{f("#enjoyhint_arrpw_line").show();F.css("top",c);var U,T,J,I;var S=V.left+V.width/2=640){var J=K.x_from||0;var L=K.y_from||0;var H=K.x_to||0;var N=K.y_to||0;var I=K.by_top_side;var G=0;var F=0;if(I){if(L>=N){F=N;G=J}else{F=L;G=H}}else{if(L>=N){F=L;G=H}else{F=N;G=J}}}var M=K.text||"";i.enjoyhint.addClass(i.cl.svg_transparent);setTimeout(function(){f("#enjoyhint_arrpw_line").remove();var O="M"+J+","+L+" Q"+G+","+F+" "+H+","+N;i.$svg.append(v("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:O,id:"enjoyhint_arrpw_line"}));i.enjoyhint.removeClass(i.cl.svg_transparent)},i.options.animation_time/2)};i.getLabelElement=function(F){return f("
",{"class":"enjoy_hint_label",id:"enjoyhint_label"}).css({top:F.y+"px",left:F.x+"px"}).html(F.text).appendTo(i.enjoyhint)};i.disableEventsNearRect=function(F){u.css({top:"0",left:"0"}).height(F.top);B.css({top:F.bottom+"px",left:"0"});r.css({top:"0",left:0+"px"}).width(F.left);q.css({top:"0",left:F.right+"px"})};(function(F){F.event.special.destroyed={remove:function(G){if(G.handler){G.handler()}}}})(jQuery);i.renderLabelWithShape=function(aC){i.stepData=aC;function aG(aH){if(aH.tagName==="MD-DIALOG"){return aH}else{if(typeof aH.tagName=="undefined"){return null}else{return aG(f(aH).parent()[0])}}}var az=aG(f(i.stepData.enjoyHintElementSelector)[0]);if(az!=null){f(az).on("dialogClosing",function(){i.stopFunction();return})}i.resetComponentStuff();var Q=aC.shape||"rect";var L={};var Y=0;var ag=0;var N={top:aC.top||0,bottom:aC.bottom||0,left:aC.left||0,right:aC.right||0};switch(Q){case"circle":Y=ag=aC.radius;var ao={top:aC.center_y-ag+N.top,bottom:aC.center_y+ag-N.bottom,left:aC.center_x-Y+N.left,right:aC.center_x+Y-N.right};var F=ao.right-ao.left;var H=ao.bottom-ao.top;aC.radius=Math.round(Math.min(F,H)/2);Y=ag=Math.round(aC.radius/2);var av=Math.round(F/2);var aF=Math.round(H/2);aC.center_x=ao.left+av;aC.center_y=ao.top+aF;L=i.renderCircle({x:aC.center_x,y:aC.center_y,r:aC.radius});break;case"rect":Y=Math.round(aC.width/2);ag=Math.round(aC.height/2);var ao={top:aC.center_y-ag+N.top,bottom:aC.center_y+ag-N.bottom,left:aC.center_x-Y+N.left,right:aC.center_x+Y-N.right};aC.width=ao.right-ao.left;aC.height=ao.bottom-ao.top;Y=Math.round(aC.width/2);ag=Math.round(aC.height/2);aC.center_x=ao.left+Y;aC.center_y=ao.top+ag;L=i.renderRect({x:aC.center_x,y:aC.center_y,w:aC.width,h:aC.height,r:aC.radius},0.2);break}var U={w:i.enjoyhint.width(),h:i.enjoyhint.height()};var at=i.getLabelElement({x:0,y:0,text:aC.text});var T=at.outerWidth();var al=at.outerHeight();at.remove();var J=aC.center_y-ag;var I=U.h-(aC.center_y+ag);var am=aC.center_x-Y;var G=U.w-(aC.center_x+Y);var O=(U.w-aC.center_x)=L.x);var ap=(X.rightL.x);var ae=(X.rightL.right);var ay=(X.bottomL.bottom);var ar=(X.bottom>=L.y&&X.top<=L.y);var ac=(X.bottom<=L.y&&!ay);var ab=(X.top>=L.y&&!aD);function ah(aI,aJ,aH){K=aI;ak=aJ;an=aH}function aB(aJ,aM,aK,aI,aH){var aL=[];if(ay){aL=aJ}else{if(ac){aL=aM}else{if(ar){aL=aK}else{if(ab){aL=aI}else{aL=aH}}}}if(!aL){return}else{ah(aL[0],aL[1],aL[2])}}if(aE){if(ay){ah("bottom","top","top")}else{if(aD){ah("top","bottom","bottom")}else{return}}}else{if(ap){aB(["right","top","top"],["bottom","left","bottom"],["right","left","top"],["top","left","top"],["right","bottom","bottom"])}else{aB(["left","top","top"],["bottom","right","bottom"],["left","right","top"],["top","right","top"],["left","bottom","bottom"])}}var af=X.conn[K];var V=L.conn[ak];var aA=(an=="top");i.renderArrow({x_from:af.x,y_from:af.y,x_to:window.innerWidth<640?L.left+(L.left>0):V.x,y_to:window.innerWidth<640?L.conn.left.y:V.y,by_top_side:aA})};i.clear=function(){i.ctx.clearRect(0,0,3000,2000)};return this})},set:function(p){this.each(function(){this.enjoyhint_obj.setValue(p)});return this},show:function(){this.each(function(){this.enjoyhint_obj.show()});return this},hide:function(){this.each(function(){this.enjoyhint_obj.hide()});return this},hide_next:function(){this.each(function(){this.enjoyhint_obj.hideNextBtn()});return this},show_next:function(){this.each(function(){this.enjoyhint_obj.showNextBtn()});return this},hide_skip:function(){this.each(function(){this.enjoyhint_obj.hideSkipBtn()});return this},show_skip:function(){this.each(function(){this.enjoyhint_obj.showSkipBtn()});return this},render_circle:function(p,s,q){this.each(function(){this.enjoyhint_obj.renderCircle(p,s,q)});return this},render_label:function(p,s,q){this.each(function(){this.enjoyhint_obj.renderLabel(p,s,q)});return this},render_label_with_shape:function(q,p){this.each(function(){i.stopFunction=p;this.enjoyhint_obj.renderLabelWithShape(q)});return this},redo_events_near_rect:function(p){i.disableEventsNearRect({top:p.top,bottom:p.bottom,left:p.left,right:p.right})},clear:function(){this.each(function(){this.enjoyhint_obj.clear()});return this},close:function(p){this.each(function(){this.enjoyhint_obj.closePopdown()});return this}};f.fn.enjoyhint=function(p){if(d[p]){return d[p].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof p==="object"||!p){return d.init.apply(this,arguments)}else{f.error("Method "+p+" does not exist on $.numinput")}}return this}})(window.jQuery); +/* KineticJS v5.2.0 2015-01-22 http://lavrton.github.io/KineticJS/ by Eric Rowell @ericdrowell, Anton Lavrenov @lavrton - MIT License https://github.com/lavrton/KineticJS/wiki/License*/ +var Kinetic={};!function(d){var c=Math.PI/180;Kinetic={version:"5.2.0",stages:[],idCounter:0,ids:{},names:{},shapes:{},listenClickTap:!1,inDblClickWindow:!1,enableTrace:!1,traceArrMax:100,dblClickWindow:400,pixelRatio:void 0,dragDistance:0,angleDeg:!0,showWarnings:!0,Filters:{},Node:function(b){this._init(b)},Shape:function(b){this.__init(b)},Container:function(b){this.__init(b)},Stage:function(b){this.___init(b)},BaseLayer:function(b){this.___init(b)},Layer:function(b){this.____init(b)},FastLayer:function(b){this.____init(b)},Group:function(b){this.___init(b)},isDragging:function(){var b=Kinetic.DD;return b?b.isDragging:!1},isDragReady:function(){var b=Kinetic.DD;return b?!!b.node:!1},_addId:function(f,e){void 0!==e&&(this.ids[e]=f)},_removeId:function(b){void 0!==b&&delete this.ids[b]},_addName:function(g,f){if(void 0!==f){for(var j=f.split(/\s/g),i=0;i"),Kinetic.window=Kinetic.document.createWindow(),Kinetic.window.Image=i.Image,Kinetic._nodeCanvas=i}return Kinetic.root=g,void (module.exports=j)}"function"==typeof define&&define.amd&&define(f),Kinetic.document=document,Kinetic.window=window,Kinetic.root=g}(this,function(){return Kinetic}),function(){Kinetic.Collection=function(){var e=[].slice.call(arguments),d=e.length,f=0;for(this.length=d;d>f;f++){this[f]=e[f]}return this},Kinetic.Collection.prototype=[],Kinetic.Collection.prototype.each=function(d){for(var c=0;ce;e++){d.push(this[e])}return d},Kinetic.Collection.toCollection=function(f){var e,h=new Kinetic.Collection,g=f.length;for(e=0;g>e;e++){h.push(f[e])}return h},Kinetic.Collection._mapMethod=function(b){Kinetic.Collection.prototype[b]=function(){var a,f=this.length,e=[].slice.call(arguments);for(a=0;f>a;a++){this[a][b].apply(this[a],e)}return this}},Kinetic.Collection.mapMethods=function(e){var d=e.prototype;for(var f in d){Kinetic.Collection._mapMethod(f)}},Kinetic.Transform=function(b){this.m=b&&b.slice()||[1,0,0,1,0,0]},Kinetic.Transform.prototype={copy:function(){return new Kinetic.Transform(this.m)},point:function(d){var c=this.m;return{x:c[0]*d.x+c[2]*d.y+c[4],y:c[1]*d.x+c[3]*d.y+c[5]}},translate:function(d,c){return this.m[4]+=this.m[0]*d+this.m[2]*c,this.m[5]+=this.m[1]*d+this.m[3]*c,this},scale:function(d,c){return this.m[0]*=d,this.m[1]*=d,this.m[2]*=c,this.m[3]*=c,this},rotate:function(i){var h=Math.cos(i),n=Math.sin(i),m=this.m[0]*h+this.m[2]*n,l=this.m[1]*h+this.m[3]*n,k=this.m[0]*-n+this.m[2]*h,j=this.m[1]*-n+this.m[3]*h;return this.m[0]=m,this.m[1]=l,this.m[2]=k,this.m[3]=j,this},getTranslation:function(){return{x:this.m[4],y:this.m[5]}},skew:function(h,g){var l=this.m[0]+this.m[2]*g,k=this.m[1]+this.m[3]*g,j=this.m[2]+this.m[0]*h,i=this.m[3]+this.m[1]*h;return this.m[0]=l,this.m[1]=k,this.m[2]=j,this.m[3]=i,this},multiply:function(i){var h=this.m[0]*i.m[0]+this.m[2]*i.m[1],n=this.m[1]*i.m[0]+this.m[3]*i.m[1],m=this.m[0]*i.m[2]+this.m[2]*i.m[3],l=this.m[1]*i.m[2]+this.m[3]*i.m[3],k=this.m[0]*i.m[4]+this.m[2]*i.m[5]+this.m[4],j=this.m[1]*i.m[4]+this.m[3]*i.m[5]+this.m[5];return this.m[0]=h,this.m[1]=n,this.m[2]=m,this.m[3]=l,this.m[4]=k,this.m[5]=j,this},invert:function(){var i=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),h=this.m[3]*i,n=-this.m[1]*i,m=-this.m[2]*i,l=this.m[0]*i,k=i*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),j=i*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=h,this.m[1]=n,this.m[2]=m,this.m[3]=l,this.m[4]=k,this.m[5]=j,this},getMatrix:function(){return this.m},setAbsolutePosition:function(H,G){var F=this.m[0],E=this.m[1],D=this.m[2],C=this.m[3],n=this.m[4],m=this.m[5],l=(F*(G-m)-E*(H-n))/(F*C-E*D),k=(H-n-D*l)/F;return this.translate(k,l)}};var B="2d",A="[object Array]",z="[object Number]",y="[object String]",x=Math.PI/180,w=180/Math.PI,v="#",u="",t="0",s="Kinetic warning: ",r="Kinetic error: ",q="rgb(",p={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},o=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;Kinetic.Util={_isElement:function(b){return !(!b||1!=b.nodeType)},_isFunction:function(b){return !!(b&&b.constructor&&b.call&&b.apply)},_isObject:function(b){return !!b&&b.constructor==Object},_isArray:function(b){return Object.prototype.toString.call(b)==A},_isNumber:function(b){return Object.prototype.toString.call(b)==z},_isString:function(b){return Object.prototype.toString.call(b)==y},_throttle:function(H,G,F){var E,D,C,n=null,m=0,l=F||{},k=function(){m=l.leading===!1?0:(new Date).getTime(),n=null,C=H.apply(E,D),E=D=null};return function(){var b=(new Date).getTime();m||l.leading!==!1||(m=b);var a=G-(b-m);return E=this,D=arguments,0>=a?(clearTimeout(n),n=null,m=b,C=H.apply(E,D),E=D=null):n||l.trailing===!1||(n=setTimeout(k,a)),C}},_hasMethods:function(e){var d,f=[];for(d in e){this._isFunction(e[d])&&f.push(d)}return f.length>0},createCanvasElement:function(){var d=Kinetic.document.createElement("canvas");try{d.style=d.style||{}}catch(c){}return d},isBrowser:function(){return"object"!=typeof exports},_isInDocument:function(b){for(;b=b.parentNode;){if(b==Kinetic.document){return !0}}return !1},_simplifyArray:function(h){var g,l,k=[],j=h.length,i=Kinetic.Util;for(g=0;j>g;g++){l=h[g],i._isNumber(l)?l=Math.round(1000*l)/1000:i._isString(l)||(l=l.toString()),k.push(l)}return k},_getImage:function(a,j){var i,h;if(a){if(this._isElement(a)){j(a)}else{if(this._isString(a)){i=new Kinetic.window.Image,i.onload=function(){j(i)},i.src=a}else{if(a.data){h=Kinetic.Util.createCanvasElement(),h.width=a.width,h.height=a.height;var g=h.getContext(B);g.putImageData(a,0,0),this._getImage(h.toDataURL(),j)}else{j(null)}}}}else{j(null)}},_getRGBAString:function(g){var f=g.red||0,j=g.green||0,i=g.blue||0,h=g.alpha||1;return["rgba(",f,",",j,",",i,",",h,")"].join(u)},_rgbToHex:function(e,d,f){return((1<<24)+(e<<16)+(d<<8)+f).toString(16).slice(1)},_hexToRgb:function(d){d=d.replace(v,u);var c=parseInt(d,16);return{r:c>>16&255,g:c>>8&255,b:255&c}},getRandomColor:function(){for(var b=(16777215*Math.random()<<0).toString(16);b.length<6;){b=t+b}return v+b},get:function(d,c){return void 0===d?c:d},getRGB:function(d){var c;return d in p?(c=p[d],{r:c[0],g:c[1],b:c[2]}):d[0]===v?this._hexToRgb(d.substring(1)):d.substr(0,4)===q?(c=o.exec(d.replace(/ /g,"")),{r:parseInt(c[1],10),g:parseInt(c[2],10),b:parseInt(c[3],10)}):{r:0,g:0,b:0}},_merge:function(f,e){var h=this._clone(e);for(var g in f){h[g]=this._isObject(f[g])?this._merge(f[g],h[g]):f[g]}return h},cloneObject:function(e){var d={};for(var f in e){d[f]=this._isObject(e[f])?this.cloneObject(e[f]):this._isArray(e[f])?this.cloneArray(e[f]):e[f]}return d},cloneArray:function(b){return b.slice(0)},_degToRad:function(b){return b*x},_radToDeg:function(b){return b*w},_capitalize:function(b){return b.charAt(0).toUpperCase()+b.slice(1)},error:function(b){throw new Error(r+b)},warn:function(b){Kinetic.root.console&&console.warn&&Kinetic.showWarnings&&console.warn(s+b)},extend:function(g,f){function j(){this.constructor=g}j.prototype=f.prototype;var i=g.prototype;g.prototype=new j;for(var h in i){i.hasOwnProperty(h)&&(g.prototype[h]=i[h])}g.__super__=f.prototype},addMethods:function(e,d){var f;for(f in d){e.prototype[f]=d[f]}},_getControlPoints:function(Q,P,O,N,M,L,K){var J=Math.sqrt(Math.pow(O-Q,2)+Math.pow(N-P,2)),I=Math.sqrt(Math.pow(M-O,2)+Math.pow(L-N,2)),H=K*J/(J+I),G=K*I/(J+I),F=O-H*(M-Q),E=N-H*(L-P),D=O+G*(M-Q),C=N+G*(L-P);return[F,E,D,C]},_expandPoints:function(h,g){var l,k,j=h.length,i=[];for(l=2;j-2>l;l+=2){k=Kinetic.Util._getControlPoints(h[l-2],h[l-1],h[l],h[l+1],h[l+2],h[l+3],g),i.push(k[0]),i.push(k[1]),i.push(h[l]),i.push(h[l+1]),i.push(k[2]),i.push(k[3])}return i},_removeLastLetter:function(b){return b.substring(0,b.length-1)}}}(),function(){var e=Kinetic.Util.createCanvasElement(),d=e.getContext("2d"),f=Kinetic.UA.mobile?function(){var b=window.devicePixelRatio||1,g=d.webkitBackingStorePixelRatio||d.mozBackingStorePixelRatio||d.msBackingStorePixelRatio||d.oBackingStorePixelRatio||d.backingStorePixelRatio||1;return b/g}():1;Kinetic.Canvas=function(b){this.init(b)},Kinetic.Canvas.prototype={init:function(g){var c=g||{},h=c.pixelRatio||Kinetic.pixelRatio||f;this.pixelRatio=h,this._canvas=Kinetic.Util.createCanvasElement(),this._canvas.style.padding=0,this._canvas.style.margin=0,this._canvas.style.border=0,this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top=0,this._canvas.style.left=0},getContext:function(){return this.context},getPixelRatio:function(){return this.pixelRatio},setPixelRatio:function(b){this.pixelRatio=b,this.setSize(this.getWidth(),this.getHeight())},setWidth:function(b){this.width=this._canvas.width=b*this.pixelRatio,this._canvas.style.width=b+"px"},setHeight:function(b){this.height=this._canvas.height=b*this.pixelRatio,this._canvas.style.height=b+"px"},getWidth:function(){return this.width},getHeight:function(){return this.height},setSize:function(g,c){this.setWidth(g),this.setHeight(c)},toDataURL:function(h,g){try{return this._canvas.toDataURL(h,g)}catch(j){try{return this._canvas.toDataURL()}catch(i){return Kinetic.Util.warn("Unable to get data URL. "+i.message),""}}}},Kinetic.SceneCanvas=function(h){var g=h||{},j=g.width||0,i=g.height||0;Kinetic.Canvas.call(this,g),this.context=new Kinetic.SceneContext(this),this.setSize(j,i)},Kinetic.SceneCanvas.prototype={setWidth:function(h){var g=this.pixelRatio,i=this.getContext()._context;Kinetic.Canvas.prototype.setWidth.call(this,h),i.scale(g,g)},setHeight:function(h){var g=this.pixelRatio,i=this.getContext()._context;Kinetic.Canvas.prototype.setHeight.call(this,h),i.scale(g,g)}},Kinetic.Util.extend(Kinetic.SceneCanvas,Kinetic.Canvas),Kinetic.HitCanvas=function(h){var g=h||{},j=g.width||0,i=g.height||0;Kinetic.Canvas.call(this,g),this.context=new Kinetic.HitContext(this),this.setSize(j,i),this.hitCanvas=!0},Kinetic.Util.extend(Kinetic.HitCanvas,Kinetic.Canvas)}(),function(){var r=",",q="(",p=")",o="([",n="])",m=";",l="()",k="=",j=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];Kinetic.Context=function(b){this.init(b)},Kinetic.Context.prototype={init:function(b){this.canvas=b,this._context=b._canvas.getContext("2d"),Kinetic.enableTrace&&(this.traceArr=[],this._enableTrace())},fillShape:function(b){b.getFillEnabled()&&this._fill(b)},strokeShape:function(b){b.getStrokeEnabled()&&this._stroke(b)},fillStrokeShape:function(d){var c=d.getFillEnabled();c&&this._fill(d),d.getStrokeEnabled()&&this._stroke(d)},getTrace:function(e){var d,c,b,a,h=this.traceArr,g=h.length,f="";for(d=0;g>d;d++){c=h[d],b=c.method,b?(a=c.args,f+=b,f+=e?l:Kinetic.Util._isArray(a[0])?o+a.join(r)+n:q+a.join(r)+p):(f+=c.property,e||(f+=k+c.val)),f+=m}return f},clearTrace:function(){this.traceArr=[]},_trace:function(e){var d,f=this.traceArr;f.push(e),d=f.length,d>=Kinetic.traceArrMax&&f.shift()},reset:function(){var b=this.getCanvas().getPixelRatio();this.setTransform(1*b,0,0,1*b,0,0)},getCanvas:function(){return this.canvas},clear:function(d){var c=this.getCanvas();d?this.clearRect(d.x||0,d.y||0,d.width||0,d.height||0):this.clearRect(0,0,c.getWidth(),c.getHeight())},_applyLineCap:function(d){var c=d.getLineCap();c&&this.setAttr("lineCap",c)},_applyOpacity:function(d){var c=d.getAbsoluteOpacity();1!==c&&this.setAttr("globalAlpha",c)},_applyLineJoin:function(d){var c=d.getLineJoin();c&&this.setAttr("lineJoin",c)},setAttr:function(d,c){this._context[d]=c},arc:function(){var b=arguments;this._context.arc(b[0],b[1],b[2],b[3],b[4],b[5])},beginPath:function(){this._context.beginPath()},bezierCurveTo:function(){var b=arguments;this._context.bezierCurveTo(b[0],b[1],b[2],b[3],b[4],b[5])},clearRect:function(){var b=arguments;this._context.clearRect(b[0],b[1],b[2],b[3])},clip:function(){this._context.clip()},closePath:function(){this._context.closePath()},createImageData:function(){var b=arguments;return 2===b.length?this._context.createImageData(b[0],b[1]):1===b.length?this._context.createImageData(b[0]):void 0},createLinearGradient:function(){var b=arguments;return this._context.createLinearGradient(b[0],b[1],b[2],b[3])},createPattern:function(){var b=arguments;return this._context.createPattern(b[0],b[1])},createRadialGradient:function(){var b=arguments;return this._context.createRadialGradient(b[0],b[1],b[2],b[3],b[4],b[5])},drawImage:function(){var d=arguments,c=this._context;3===d.length?c.drawImage(d[0],d[1],d[2]):5===d.length?c.drawImage(d[0],d[1],d[2],d[3],d[4]):9===d.length&&c.drawImage(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8])},fill:function(){this._context.fill()},fillText:function(){var b=arguments;this._context.fillText(b[0],b[1],b[2])},getImageData:function(){var b=arguments;return this._context.getImageData(b[0],b[1],b[2],b[3])},lineTo:function(){var b=arguments;this._context.lineTo(b[0],b[1])},moveTo:function(){var b=arguments;this._context.moveTo(b[0],b[1])},rect:function(){var b=arguments;this._context.rect(b[0],b[1],b[2],b[3])},putImageData:function(){var b=arguments;this._context.putImageData(b[0],b[1],b[2])},quadraticCurveTo:function(){var b=arguments;this._context.quadraticCurveTo(b[0],b[1],b[2],b[3])},restore:function(){this._context.restore()},rotate:function(){var b=arguments;this._context.rotate(b[0])},save:function(){this._context.save()},scale:function(){var b=arguments;this._context.scale(b[0],b[1])},setLineDash:function(){var d=arguments,c=this._context;this._context.setLineDash?c.setLineDash(d[0]):"mozDash" in c?c.mozDash=d[0]:"webkitLineDash" in c&&(c.webkitLineDash=d[0])},setTransform:function(){var b=arguments;this._context.setTransform(b[0],b[1],b[2],b[3],b[4],b[5])},stroke:function(){this._context.stroke()},strokeText:function(){var b=arguments;this._context.strokeText(b[0],b[1],b[2])},transform:function(){var b=arguments;this._context.transform(b[0],b[1],b[2],b[3],b[4],b[5])},translate:function(){var b=arguments;this._context.translate(b[0],b[1])},_enableTrace:function(){var i,h,w=this,v=j.length,u=Kinetic.Util._simplifyArray,t=this.setAttr,s=function(b){var e,c=w[b];w[b]=function(){return h=u(Array.prototype.slice.call(arguments,0)),e=c.apply(w,arguments),w._trace({method:b,args:h}),e}};for(i=0;v>i;i++){s(j[i])}w.setAttr=function(){t.apply(w,arguments),w._trace({property:arguments[0],val:arguments[1]})}}},Kinetic.SceneContext=function(b){Kinetic.Context.call(this,b)},Kinetic.SceneContext.prototype={_fillColor:function(d){var c=d.fill()||Kinetic.Util._getRGBAString({red:d.fillRed(),green:d.fillGreen(),blue:d.fillBlue(),alpha:d.fillAlpha()});this.setAttr("fillStyle",c),d._fillFunc(this)},_fillPattern:function(s){var i=s.getFillPatternImage(),y=s.getFillPatternX(),x=s.getFillPatternY(),w=s.getFillPatternScale(),v=Kinetic.getAngle(s.getFillPatternRotation()),u=s.getFillPatternOffset(),t=s.getFillPatternRepeat();(y||x)&&this.translate(y||0,x||0),v&&this.rotate(v),w&&this.scale(w.x,w.y),u&&this.translate(-1*u.x,-1*u.y),this.setAttr("fillStyle",this.createPattern(i,t||"repeat")),this.fill()},_fillLinearGradient:function(h){var g=h.getFillLinearGradientStartPoint(),u=h.getFillLinearGradientEndPoint(),t=h.getFillLinearGradientColorStops(),s=this.createLinearGradient(g.x,g.y,u.x,u.y);if(t){for(var i=0;iq;q++){p=t[q],e[p]=this.getAttr(u+n(p))}return e},v.prototype[a]=function(f){var e,g=this.attrs[u];s&&(f=s.call(this,f));for(e in f){this._setAttr(u+n(e),f[e])}return this._fireChangeEvent(u,g,f),r&&r.call(this),this},this.addOverloadedGetterSetter(v,u)},addOverloadedGetterSetter:function(j,i){var h=Kinetic.Util._capitalize(i),b=c+h,a=d+h;j.prototype[i]=function(){return arguments.length?(this[b](arguments[0]),this):this[a]()}},backCompat:function(f,e){var g;for(g in e){f.prototype[g]=f.prototype[e[g]]}},afterSetFilter:function(){this._filterUpToDate=!1}},Kinetic.Validators={RGBComponent:function(b){return b>255?255:0>b?0:Math.round(b)},alphaComponent:function(b){return b>1?1:0.0001>b?0.0001:b}}}(),function(){var R="absoluteOpacity",Q="absoluteTransform",P="Change",O="children",N=".",M="",L="get",K="id",J="kinetic",I="listening",H="mouseenter",G="mouseleave",F="name",E="set",D="Shape",C=" ",B="stage",A="transform",z="Stage",y="visible",x=["id"],w=["xChange.kinetic","yChange.kinetic","scaleXChange.kinetic","scaleYChange.kinetic","skewXChange.kinetic","skewYChange.kinetic","rotationChange.kinetic","offsetXChange.kinetic","offsetYChange.kinetic","transformsEnabledChange.kinetic"].join(C);Kinetic.Util.addMethods(Kinetic.Node,{_init:function(b){var a=this;this._id=Kinetic.idCounter++,this.eventListeners={},this.attrs={},this._cache={},this._filterUpToDate=!1,this.setAttrs(b),this.on(w,function(){this._clearCache(A),a._clearSelfAndDescendantCache(Q)}),this.on("visibleChange.kinetic",function(){a._clearSelfAndDescendantCache(y)}),this.on("listeningChange.kinetic",function(){a._clearSelfAndDescendantCache(I)}),this.on("opacityChange.kinetic",function(){a._clearSelfAndDescendantCache(R)})},_clearCache:function(b){b?delete this._cache[b]:this._cache={}},_getCache:function(e,d){var f=this._cache[e];return void 0===f&&(this._cache[e]=d.call(this)),this._cache[e]},_clearSelfAndDescendantCache:function(b){this._clearCache(b),this.children&&this.getChildren().each(function(a){a._clearSelfAndDescendantCache(b)})},clearCache:function(){return delete this._cache.canvas,this._filterUpToDate=!1,this},cache:function(T){var S=T||{},v=S.x||0,u=S.y||0,t=S.width||this.width(),s=S.height||this.height(),r=S.drawBorder||!1;if(0===t||0===s){return void Kinetic.Util.warn("Width or height of caching configuration equals 0. Cache is ignored.")}var q=new Kinetic.SceneCanvas({pixelRatio:1,width:t,height:s}),p=new Kinetic.SceneCanvas({pixelRatio:1,width:t,height:s}),o=new Kinetic.HitCanvas({width:t,height:s}),n=q.getContext(),m=o.getContext();return o.isCache=!0,this.clearCache(),n.save(),m.save(),r&&(n.save(),n.beginPath(),n.rect(0,0,t,s),n.closePath(),n.setAttr("strokeStyle","red"),n.setAttr("lineWidth",5),n.stroke(),n.restore()),n.translate(-1*v,-1*u),m.translate(-1*v,-1*u),"Shape"===this.nodeType&&(n.translate(-1*this.x(),-1*this.y()),m.translate(-1*this.x(),-1*this.y())),this.drawScene(q,this),this.drawHit(o,this),n.restore(),m.restore(),this._cache.canvas={scene:q,filter:p,hit:o},this},_drawCachedSceneCanvas:function(b){b.save(),this.getLayer()._applyTransform(this,b),b._applyOpacity(this),b.drawImage(this._getCachedSceneCanvas()._canvas,0,0),b.restore()},_getCachedSceneCanvas:function(){var t,s,r,q,p=this.filters(),o=this._cache.canvas,n=o.scene,m=o.filter,l=m.getContext();if(p){if(!this._filterUpToDate){try{for(t=p.length,l.clear(),l.drawImage(n._canvas,0,0),s=l.getImageData(0,0,m.getWidth(),m.getHeight()),r=0;t>r;r++){q=p[r],q.call(this,s),l.putImageData(s,0,0)}}catch(k){Kinetic.Util.warn("Unable to apply filter. "+k.message)}this._filterUpToDate=!0}return m}return n},_drawCachedHitCanvas:function(e){var d=this._cache.canvas,f=d.hit;e.save(),this.getLayer()._applyTransform(this,e),e.drawImage(f._canvas,0,0),e.restore()},on:function(r,q){var p,o,n,m,l,f=r.split(C),e=f.length;for(p=0;e>p;p++){o=f[p],n=o.split(N),m=n[0],l=n[1]||M,this.eventListeners[m]||(this.eventListeners[m]=[]),this.eventListeners[m].push({name:l,handler:q})}return this},off:function(r){var q,p,o,n,m,l,k=(r||"").split(C),e=k.length;if(!r){for(p in this.eventListeners){this._off(p)}}for(q=0;e>q;q++){if(o=k[q],n=o.split(N),m=n[0],l=n[1],m){this.eventListeners[m]&&this._off(m,l)}else{for(p in this.eventListeners){this._off(p,l)}}}return this},dispatchEvent:function(d){var c={target:this,type:d.type,evt:d};this.fire(d.type,c)},addEventListener:function(d,c){this.on(d,function(b){c.call(this,b.evt)})},removeEventListener:function(b){this.off(b)},remove:function(){var a=this.getParent();return a&&a.children&&(a.children.splice(this.index,1),a._setChildrenIndices(),delete this.parent),this._clearSelfAndDescendantCache(B),this._clearSelfAndDescendantCache(Q),this._clearSelfAndDescendantCache(y),this._clearSelfAndDescendantCache(I),this._clearSelfAndDescendantCache(R),this},destroy:function(){Kinetic._removeId(this.getId()),Kinetic._removeName(this.getName(),this._id),this.remove()},getAttr:function(d){var c=L+Kinetic.Util._capitalize(d);return Kinetic.Util._isFunction(this[c])?this[c]():this.attrs[d]},getAncestors:function(){for(var d=this.getParent(),c=new Kinetic.Collection;d;){c.push(d),d=d.getParent()}return c},getAttrs:function(){return this.attrs||{}},setAttrs:function(e){var d,f;if(e){for(d in e){d===O||e[d] instanceof Kinetic.Node||(f=E+Kinetic.Util._capitalize(d),Kinetic.Util._isFunction(this[f])?this[f](e[d]):this._setAttr(d,e[d]))}}return this},isListening:function(){return this._getCache(I,this._isListening)},_isListening:function(){var d=this.getListening(),c=this.getParent();return"inherit"===d?c?c.isListening():!0:d},isVisible:function(){return this._getCache(y,this._isVisible)},_isVisible:function(){var d=this.getVisible(),c=this.getParent();return"inherit"===d?c?c.isVisible():!0:d},shouldDrawHit:function(d){var c=this.getLayer();return d&&d.isCache||c&&c.hitGraphEnabled()&&this.isListening()&&this.isVisible()},show:function(){return this.setVisible(!0),this},hide:function(){return this.setVisible(!1),this},getZIndex:function(){return this.index||0},getAbsoluteZIndex:function(){function j(a){for(i=[],p=a.length,o=0;p>o;o++){n=a[o],k++,n.nodeType!==D&&(i=i.concat(n.getChildren().toArray())),n._id===l._id&&(o=p)}i.length>0&&i[0].getDepth()<=m&&j(i)}var i,p,o,n,m=this.getDepth(),l=this,k=0;return l.nodeType!==z&&j(l.getStage().getChildren()),k},getDepth:function(){for(var d=0,c=this.parent;c;){d++,c=c.parent}return d},setPosition:function(b){return this.setX(b.x),this.setY(b.y),this},getPosition:function(){return{x:this.getX(),y:this.getY()}},getAbsolutePosition:function(){var e=this.getAbsoluteTransform().getMatrix(),d=new Kinetic.Transform,f=this.offset();return d.m=e.slice(),d.translate(f.x,f.y),d.getTranslation()},setAbsolutePosition:function(e){var d,f=this._clearTransform();return this.attrs.x=f.x,this.attrs.y=f.y,delete f.x,delete f.y,d=this.getAbsoluteTransform(),d.invert(),d.translate(e.x,e.y),e={x:this.attrs.x+d.getTranslation().x,y:this.attrs.y+d.getTranslation().y},this.setPosition({x:e.x,y:e.y}),this._setTransform(f),this},_setTransform:function(b){var d;for(d in b){this.attrs[d]=b[d]}this._clearCache(A),this._clearSelfAndDescendantCache(Q)},_clearTransform:function(){var b={x:this.getX(),y:this.getY(),rotation:this.getRotation(),scaleX:this.getScaleX(),scaleY:this.getScaleY(),offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),skewX:this.getSkewX(),skewY:this.getSkewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,this._clearCache(A),this._clearSelfAndDescendantCache(Q),b},move:function(g){var f=g.x,j=g.y,i=this.getX(),h=this.getY();return void 0!==f&&(i+=f),void 0!==j&&(h+=j),this.setPosition({x:i,y:h}),this},_eachAncestorReverse:function(h,g){var l,k,j=[],i=this.getParent();if(g&&g._id===this._id){return h(this),!0}for(j.unshift(this);i&&(!g||i._id!==g._id);){j.unshift(i),i=i.parent}for(l=j.length,k=0;l>k;k++){h(j[k])}},rotate:function(b){return this.setRotation(this.getRotation()+b),this},moveToTop:function(){if(!this.parent){return void Kinetic.Util.warn("Node has no parent. moveToTop function is ignored.")}var b=this.index;return this.parent.children.splice(b,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0},moveUp:function(){if(!this.parent){return void Kinetic.Util.warn("Node has no parent. moveUp function is ignored.")}var d=this.index,c=this.parent.getChildren().length;return c-1>d?(this.parent.children.splice(d,1),this.parent.children.splice(d+1,0,this),this.parent._setChildrenIndices(),!0):!1},moveDown:function(){if(!this.parent){return void Kinetic.Util.warn("Node has no parent. moveDown function is ignored.")}var b=this.index;return b>0?(this.parent.children.splice(b,1),this.parent.children.splice(b-1,0,this),this.parent._setChildrenIndices(),!0):!1},moveToBottom:function(){if(!this.parent){return void Kinetic.Util.warn("Node has no parent. moveToBottom function is ignored.")}var b=this.index;return b>0?(this.parent.children.splice(b,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1},setZIndex:function(d){if(!this.parent){return void Kinetic.Util.warn("Node has no parent. zIndex parameter is ignored.")}var c=this.index;return this.parent.children.splice(c,1),this.parent.children.splice(d,0,this),this.parent._setChildrenIndices(),this},getAbsoluteOpacity:function(){return this._getCache(R,this._getAbsoluteOpacity)},_getAbsoluteOpacity:function(){var b=this.getOpacity();return this.getParent()&&(b*=this.getParent().getAbsoluteOpacity()),b},moveTo:function(b){return this.getParent()!==b&&(this.remove(),b.add(this)),this},toObject:function(){var i,h,n,m,l=Kinetic.Util,k={},j=this.getAttrs();k.attrs={};for(i in j){h=j[i],l._isFunction(h)||l._isElement(h)||l._isObject(h)&&l._hasMethods(h)||(n=this[i],delete j[i],m=n?n.call(this):null,j[i]=h,m!==h&&(k.attrs[i]=h))}return k.className=this.getClassName(),k},toJSON:function(){return JSON.stringify(this.toObject())},getParent:function(){return this.parent},getLayer:function(){var b=this.getParent();return b?b.getLayer():null},getStage:function(){return this._getCache(B,this._getStage)},_getStage:function(){var b=this.getParent();return b?b.getStage():void 0},fire:function(e,d,f){return f?this._fireAndBubble(e,d||{}):this._fire(e,d||{}),this},getAbsoluteTransform:function(b){return b?this._getAbsoluteTransform(b):this._getCache(Q,this._getAbsoluteTransform)},_getAbsoluteTransform:function(f){var e,h,g=new Kinetic.Transform;return this._eachAncestorReverse(function(b){e=b.transformsEnabled(),h=b.getTransform(),"all"===e?g.multiply(h):"position"===e&&g.translate(b.x(),b.y())},f),g},getTransform:function(){return this._getCache(A,this._getTransform)},_getTransform:function(){var t=new Kinetic.Transform,s=this.getX(),r=this.getY(),q=Kinetic.getAngle(this.getRotation()),p=this.getScaleX(),o=this.getScaleY(),n=this.getSkewX(),m=this.getSkewY(),l=this.getOffsetX(),k=this.getOffsetY();return(0!==s||0!==r)&&t.translate(s,r),0!==q&&t.rotate(q),(0!==n||0!==m)&&t.skew(n,m),(1!==p||1!==o)&&t.scale(p,o),(0!==l||0!==k)&&t.translate(-1*l,-1*k),t},clone:function(v){var u,t,s,r,q,p=this.getClassName(),o=Kinetic.Util.cloneObject(this.attrs);for(var n in x){var m=x[n];delete o[m]}for(u in v){o[u]=v[u]}var i=new Kinetic[p](o);for(u in this.eventListeners){for(t=this.eventListeners[u],s=t.length,r=0;s>r;r++){q=t[r],q.name.indexOf(J)<0&&(i.eventListeners[u]||(i.eventListeners[u]=[]),i.eventListeners[u].push(q))}}return i},toDataURL:function(j){j=j||{};var i=j.mimeType||null,p=j.quality||null,o=this.getStage(),n=j.x||0,m=j.y||0,l=new Kinetic.SceneCanvas({width:j.width||this.getWidth()||(o?o.getWidth():0),height:j.height||this.getHeight()||(o?o.getHeight():0),pixelRatio:1}),k=l.getContext();return k.save(),(n||m)&&k.translate(-1*n,-1*m),this.drawScene(l),k.restore(),l.toDataURL(i,p)},toImage:function(b){Kinetic.Util._getImage(this.toDataURL(b),function(a){b.callback(a)})},setSize:function(b){return this.setWidth(b.width),this.setHeight(b.height),this},getSize:function(){return{width:this.getWidth(),height:this.getHeight()}},getWidth:function(){return this.attrs.width||0},getHeight:function(){return this.attrs.height||0},getClassName:function(){return this.className||this.nodeType},getType:function(){return this.nodeType},getDragDistance:function(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Kinetic.dragDistance},_get:function(b){return this.className===b||this.nodeType===b?[this]:[]},_off:function(g,f){var j,i,h=this.eventListeners[g];for(j=0;jl;l++){n.add(this._createNode(j[l]))}}return n},Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"position"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"x",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"y",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"opacity",1),Kinetic.Factory.addGetter(Kinetic.Node,"name"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"name"),Kinetic.Factory.addGetter(Kinetic.Node,"id"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"id"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"rotation",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"scale",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"scaleX",1),Kinetic.Factory.addGetterSetter(Kinetic.Node,"scaleY",1),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"skew",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"skewX",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"skewY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Node,"offset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Node,"offsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Node,"offsetY",0),Kinetic.Factory.addSetter(Kinetic.Node,"dragDistance"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"dragDistance"),Kinetic.Factory.addSetter(Kinetic.Node,"width",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"width"),Kinetic.Factory.addSetter(Kinetic.Node,"height",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"height"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"listening","inherit"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"filters",void 0,function(b){return this._filterUpToDate=!1,b}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"visible","inherit"),Kinetic.Factory.addGetterSetter(Kinetic.Node,"transformsEnabled","all"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"size"),Kinetic.Factory.backCompat(Kinetic.Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"}),Kinetic.Collection.mapMethods(Kinetic.Node)}(),function(){Kinetic.Filters.Grayscale=function(g){var f,j,i=g.data,h=i.length;for(f=0;h>f;f+=4){j=0.34*i[f]+0.5*i[f+1]+0.16*i[f+2],i[f]=j,i[f+1]=j,i[f+2]=j}}}(),function(){Kinetic.Filters.Brighten=function(g){var f,j=255*this.brightness(),i=g.data,h=i.length;for(f=0;h>f;f+=4){i[f]+=j,i[f+1]+=j,i[f+2]+=j}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"brightness",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Invert=function(f){var e,h=f.data,g=h.length;for(e=0;g>e;e+=4){h[e]=255-h[e],h[e+1]=255-h[e+1],h[e+2]=255-h[e+2]}}}(),function(){function f(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function e(aE,aD){var aC,aB,aA,az,ay,ax,aw,av,au,at,ar,aq,ap,ao,an,am,al,ak,aj,ai,ah,ag,af,ae,ad=aE.data,ac=aE.width,ab=aE.height,aa=aD+aD+1,Z=ac-1,Y=ab-1,X=aD+1,W=X*(X+1)/2,V=new f,U=null,T=V,S=null,d=null,c=h[aD],a=g[aD];for(aA=1;aa>aA;aA++){T=T.next=new f,aA==X&&(U=T)}for(T.next=V,aw=ax=0,aB=0;ab>aB;aB++){for(am=al=ak=aj=av=au=at=ar=0,aq=X*(ai=ad[ax]),ap=X*(ah=ad[ax+1]),ao=X*(ag=ad[ax+2]),an=X*(af=ad[ax+3]),av+=W*ai,au+=W*ah,at+=W*ag,ar+=W*af,T=V,aA=0;X>aA;aA++){T.r=ai,T.g=ah,T.b=ag,T.a=af,T=T.next}for(aA=1;X>aA;aA++){az=ax+((aA>Z?Z:aA)<<2),av+=(T.r=ai=ad[az])*(ae=X-aA),au+=(T.g=ah=ad[az+1])*ae,at+=(T.b=ag=ad[az+2])*ae,ar+=(T.a=af=ad[az+3])*ae,am+=ai,al+=ah,ak+=ag,aj+=af,T=T.next}for(S=V,d=U,aC=0;ac>aC;aC++){ad[ax+3]=af=ar*c>>a,0!==af?(af=255/af,ad[ax]=(av*c>>a)*af,ad[ax+1]=(au*c>>a)*af,ad[ax+2]=(at*c>>a)*af):ad[ax]=ad[ax+1]=ad[ax+2]=0,av-=aq,au-=ap,at-=ao,ar-=an,aq-=S.r,ap-=S.g,ao-=S.b,an-=S.a,az=aw+((az=aC+aD+1)aC;aC++){for(al=ak=aj=am=au=at=ar=av=0,ax=aC<<2,aq=X*(ai=ad[ax]),ap=X*(ah=ad[ax+1]),ao=X*(ag=ad[ax+2]),an=X*(af=ad[ax+3]),av+=W*ai,au+=W*ah,at+=W*ag,ar+=W*af,T=V,aA=0;X>aA;aA++){T.r=ai,T.g=ah,T.b=ag,T.a=af,T=T.next}for(ay=ac,aA=1;aD>=aA;aA++){ax=ay+aC<<2,av+=(T.r=ai=ad[ax])*(ae=X-aA),au+=(T.g=ah=ad[ax+1])*ae,at+=(T.b=ag=ad[ax+2])*ae,ar+=(T.a=af=ad[ax+3])*ae,am+=ai,al+=ah,ak+=ag,aj+=af,T=T.next,Y>aA&&(ay+=ac)}for(ax=aC,S=V,d=U,aB=0;ab>aB;aB++){az=ax<<2,ad[az+3]=af=ar*c>>a,af>0?(af=255/af,ad[az]=(av*c>>a)*af,ad[az+1]=(au*c>>a)*af,ad[az+2]=(at*c>>a)*af):ad[az]=ad[az+1]=ad[az+2]=0,av-=aq,au-=ap,at-=ao,ar-=an,aq-=S.r,ap-=S.g,ao-=S.b,an-=S.a,az=aC+((az=aB+X)0&&e(b,d)},Kinetic.Factory.addGetterSetter(Kinetic.Node,"blurRadius",0,null,Kinetic.Factory.afterSetFilter)}(),function(){function j(g,f,r){var q=4*(r*g.width+f),h=[];return h.push(g.data[q++],g.data[q++],g.data[q++],g.data[q++]),h}function i(d,c){return Math.sqrt(Math.pow(d[0]-c[0],2)+Math.pow(d[1]-c[1],2)+Math.pow(d[2]-c[2],2))}function p(e){for(var d=[0,0,0],f=0;fa?0:255}return c}}function n(e,d){for(var f=0;fA;A++){for(var z=0;G>z;z++){for(var y=A*G+z,x=0,w=0;D>w;w++){for(var v=0;D>v;v++){var u=A+w-C,t=z+v-C;if(u>=0&&F>u&&t>=0&&G>t){var s=u*G+t,r=E[w*D+v];x+=H[s]*r}}}B[y]=2040===x?255:0}}return B}function l(H,G,F){for(var E=[1,1,1,1,1,1,1,1,1],D=Math.round(Math.sqrt(E.length)),C=Math.floor(D/2),B=[],A=0;F>A;A++){for(var z=0;G>z;z++){for(var y=A*G+z,x=0,w=0;D>w;w++){for(var v=0;D>v;v++){var u=A+w-C,t=z+v-C;if(u>=0&&F>u&&t>=0&&G>t){var s=u*G+t,r=E[w*D+v];x+=H[s]*r}}}B[y]=x>=1020?255:0}}return B}function k(H,G,F){for(var E=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],D=Math.round(Math.sqrt(E.length)),C=Math.floor(D/2),B=[],A=0;F>A;A++){for(var z=0;G>z;z++){for(var y=A*G+z,x=0,w=0;D>w;w++){for(var v=0;D>v;v++){var u=A+w-C,t=z+v-C;if(u>=0&&F>u&&t>=0&&G>t){var s=u*G+t,r=E[w*D+v];x+=H[s]*r}}}B[y]=x}}return B}Kinetic.Filters.Mask=function(e){var d=this.threshold(),f=o(e,d);return f&&(f=m(f,e.width,e.height),f=l(f,e.width,e.height),f=k(f,e.width,e.height),n(e,f)),e},Kinetic.Factory.addGetterSetter(Kinetic.Node,"threshold",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.RGB=function(j){var i,p,o=j.data,n=o.length,m=this.red(),l=this.green(),k=this.blue();for(i=0;n>i;i+=4){p=(0.34*o[i]+0.5*o[i+1]+0.16*o[i+2])/255,o[i]=p*m,o[i+1]=p*l,o[i+2]=p*k,o[i+3]=o[i+3]}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"red",0,function(b){return this._filterUpToDate=!1,b>255?255:0>b?0:Math.round(b)}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"green",0,function(b){return this._filterUpToDate=!1,b>255?255:0>b?0:Math.round(b)}),Kinetic.Factory.addGetterSetter(Kinetic.Node,"blue",0,Kinetic.Validators.RGBComponent,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.HSV=function(R){var Q,P,O,N,M,L=R.data,K=L.length,J=Math.pow(2,this.value()),I=Math.pow(2,this.saturation()),H=Math.abs(this.hue()+360)%360,G=J*I*Math.cos(H*Math.PI/180),F=J*I*Math.sin(H*Math.PI/180),E=0.299*J+0.701*G+0.167*F,D=0.587*J-0.587*G+0.33*F,C=0.114*J-0.114*G-0.497*F,B=0.299*J-0.299*G-0.328*F,A=0.587*J+0.413*G+0.035*F,z=0.114*J-0.114*G+0.293*F,y=0.299*J-0.3*G+1.25*F,x=0.587*J-0.586*G-1.05*F,w=0.114*J+0.886*G-0.2*F;for(Q=0;K>Q;Q+=4){P=L[Q+0],O=L[Q+1],N=L[Q+2],M=L[Q+3],L[Q+0]=E*P+D*O+C*N,L[Q+1]=B*P+A*O+z*N,L[Q+2]=y*P+x*O+w*N,L[Q+3]=M}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"hue",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"saturation",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"value",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Factory.addGetterSetter(Kinetic.Node,"hue",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"saturation",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"luminance",0,null,Kinetic.Factory.afterSetFilter),Kinetic.Filters.HSL=function(T){var S,R,Q,P,O,N=T.data,M=N.length,L=1,K=Math.pow(2,this.saturation()),J=Math.abs(this.hue()+360)%360,I=127*this.luminance(),H=L*K*Math.cos(J*Math.PI/180),G=L*K*Math.sin(J*Math.PI/180),F=0.299*L+0.701*H+0.167*G,E=0.587*L-0.587*H+0.33*G,D=0.114*L-0.114*H-0.497*G,C=0.299*L-0.299*H-0.328*G,B=0.587*L+0.413*H+0.035*G,A=0.114*L-0.114*H+0.293*G,z=0.299*L-0.3*H+1.25*G,y=0.587*L-0.586*H-1.05*G,x=0.114*L+0.886*H-0.2*G;for(S=0;M>S;S+=4){R=N[S+0],Q=N[S+1],P=N[S+2],O=N[S+3],N[S+0]=F*R+E*Q+D*P+I,N[S+1]=C*R+B*Q+A*P+I,N[S+2]=z*R+y*Q+x*P+I,N[S+3]=O}}}(),function(){Kinetic.Filters.Emboss=function(ah){var ag=10*this.embossStrength(),af=255*this.embossWhiteLevel(),ae=this.embossDirection(),ad=this.embossBlend(),ac=0,ab=0,aa=ah.data,Z=ah.width,Y=ah.height,X=4*Z,W=Y;switch(ae){case"top-left":ac=-1,ab=-1;break;case"top":ac=-1,ab=0;break;case"top-right":ac=-1,ab=1;break;case"right":ac=0,ab=1;break;case"bottom-right":ac=1,ab=1;break;case"bottom":ac=1,ab=0;break;case"bottom-left":ac=1,ab=-1;break;case"left":ac=0,ab=-1}do{var V=(W-1)*X,U=ac;1>W+U&&(U=0),W+U>Y&&(U=0);var T=(W-1+U)*Z*4,S=Z;do{var Q=V+4*(S-1),O=ab;1>S+O&&(O=0),S+O>Z&&(O=0);var M=T+4*(S-1+O),K=aa[Q]-aa[M],J=aa[Q+1]-aa[M+1],I=aa[Q+2]-aa[M+2],H=K,G=H>0?H:-H,F=J>0?J:-J,E=I>0?I:-I;if(F>G&&(H=J),E>G&&(H=I),H*=ag,ad){var R=aa[Q]+H,P=aa[Q+1]+H,N=aa[Q+2]+H;aa[Q]=R>255?255:0>R?0:R,aa[Q+1]=P>255?255:0>P?0:P,aa[Q+2]=N>255?255:0>N?0:N}else{var L=af-H;0>L?L=0:L>255&&(L=255),aa[Q]=aa[Q+1]=aa[Q+2]=L}}while(--S)}while(--W)},Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossStrength",0.5,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossWhiteLevel",0.5,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossDirection","top-left",null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"embossBlend",!1,null,Kinetic.Factory.afterSetFilter)}(),function(){function b(j,i,p,o,n){var m,l=p-i,k=n-o;return 0===l?o+k/2:0===k?o:(m=(j-i)/l,m=k*m+o)}Kinetic.Filters.Enhance=function(T){var S,R,Q,P,O=T.data,N=O.length,M=O[0],L=M,K=O[1],J=K,I=O[2],H=I,G=this.enhance();if(0!==G){for(P=0;N>P;P+=4){S=O[P+0],M>S?M=S:S>L&&(L=S),R=O[P+1],K>R?K=R:R>J&&(J=R),Q=O[P+2],I>Q?I=Q:Q>H&&(H=Q)}L===M&&(L=255,M=0),J===K&&(J=255,K=0),H===I&&(H=255,I=0);var F,E,D,C,B,A,z,y,a;for(G>0?(E=L+G*(255-L),D=M-G*(M-0),B=J+G*(255-J),A=K-G*(K-0),y=H+G*(255-H),a=I-G*(I-0)):(F=0.5*(L+M),E=L+G*(L-F),D=M+G*(M-F),C=0.5*(J+K),B=J+G*(J-C),A=K+G*(K-C),z=0.5*(H+I),y=H+G*(H-z),a=I+G*(I-z)),P=0;N>P;P+=4){O[P+0]=b(O[P+0],M,L,D,E),O[P+1]=b(O[P+1],K,J,A,B),O[P+2]=b(O[P+2],I,H,a,y)}}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"enhance",0,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Posterize=function(h){var g,l=Math.round(254*this.levels())+1,k=h.data,j=k.length,i=255/l;for(g=0;j>g;g+=1){k[g]=Math.floor(k[g]/i)*i}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"levels",0.5,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Noise=function(h){var g,l=255*this.noise(),k=h.data,j=k.length,i=l/2;for(g=0;j>g;g+=4){k[g+0]+=i-2*i*Math.random(),k[g+1]+=i-2*i*Math.random(),k[g+2]+=i-2*i*Math.random()}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"noise",0.2,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Pixelate=function(N){var M,L,K,J,I,H,G,F,E,D,C,B,A,z,y=Math.ceil(this.pixelSize()),x=N.width,w=N.height,v=Math.ceil(x/y),u=Math.ceil(w/y);for(N=N.data,B=0;v>B;B+=1){for(A=0;u>A;A+=1){for(J=0,I=0,H=0,G=0,F=B*y,E=F+y,D=A*y,C=D+y,z=0,M=F;E>M;M+=1){if(!(M>=x)){for(L=D;C>L;L+=1){L>=w||(K=4*(x*L+M),J+=N[K+0],I+=N[K+1],H+=N[K+2],G+=N[K+3],z+=1)}}}for(J/=z,I/=z,H/=z,M=F;E>M;M+=1){if(!(M>=x)){for(L=D;C>L;L+=1){L>=w||(K=4*(x*L+M),N[K+0]=J,N[K+1]=I,N[K+2]=H,N[K+3]=G)}}}}}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"pixelSize",8,null,Kinetic.Factory.afterSetFilter)}(),function(){Kinetic.Filters.Threshold=function(g){var f,j=255*this.threshold(),i=g.data,h=i.length;for(f=0;h>f;f+=1){i[f]=i[f]255?255:u,r[y+1]=t>255?255:t,r[y+2]=s>255?255:s,r[y+3]=r[y+3]}while(--z)}while(--p)}}(),function(){Kinetic.Filters.Solarize=function(x){var w=x.data,v=x.width,u=x.height,t=4*v,s=u;do{var r=(s-1)*t,q=v;do{var p=r+4*(q-1),o=w[p],n=w[p+1],m=w[p+2];o>127&&(o=255-o),n>127&&(n=255-n),m>127&&(m=255-m),w[p]=o,w[p+1]=n,w[p+2]=m}while(--q)}while(--s)}}(),function(){var e=function(X,W,V){var U,T,S,R,Q=X.data,P=W.data,O=X.width,N=X.height,M=V.polarCenterX||O/2,L=V.polarCenterY||N/2,K=0,J=0,I=0,H=0,G=Math.sqrt(M*M+L*L);T=O-M,S=N-L,R=Math.sqrt(T*T+S*S),G=R>G?R:G;var F,E,D,C,B=N,A=O,z=360/A*Math.PI/180;for(E=0;A>E;E+=1){for(D=Math.sin(E*z),C=Math.cos(E*z),F=0;B>F;F+=1){T=Math.floor(M+G*F/B*C),S=Math.floor(L+G*F/B*D),U=4*(S*O+T),K=Q[U+0],J=Q[U+1],I=Q[U+2],H=Q[U+3],U=4*(E+F*O),P[U+0]=K,P[U+1]=J,P[U+2]=I,P[U+3]=H}}},d=function(ab,aa,Z){var Y,X,W,V,U,T,S=ab.data,R=aa.data,Q=ab.width,P=ab.height,O=Z.polarCenterX||Q/2,N=Z.polarCenterY||P/2,M=0,K=0,J=0,I=0,H=Math.sqrt(O*O+N*N);X=Q-O,W=P-N,T=Math.sqrt(X*X+W*W),H=T>H?T:H;var G,F,E,D,C=P,B=Q,L=Z.polarRotation||0;for(X=0;Q>X;X+=1){for(W=0;P>W;W+=1){V=X-O,U=W-N,G=Math.sqrt(V*V+U*U)*C/H,F=(180*Math.atan2(U,V)/Math.PI+360+L)%360,F=F*B/360,E=Math.floor(F),D=Math.floor(G),Y=4*(D*Q+E),M=S[Y+0],K=S[Y+1],J=S[Y+2],I=S[Y+3],Y=4*(W*Q+X),R[Y+0]=M,R[Y+1]=K,R[Y+2]=J,R[Y+3]=I}}},f=Kinetic.Util.createCanvasElement();Kinetic.Filters.Kaleidoscope=function(R){var Q,P,O,N,M,L,K,J,I,H,G=R.width,F=R.height,E=Math.round(this.kaleidoscopePower()),D=Math.round(this.kaleidoscopeAngle()),C=Math.floor(G*(D%360)/360);if(!(1>E)){f.width=G,f.height=F;var B=f.getContext("2d").getImageData(0,0,G,F);e(R,B,{polarCenterX:G/2,polarCenterY:F/2});for(var A=G/Math.pow(2,E);8>=A;){A=2*A,E-=1}A=Math.ceil(A);var z=A,c=0,b=z,a=1;for(C+A>G&&(c=z,b=0,a=-1),P=0;F>P;P+=1){for(Q=c;Q!==b;Q+=a){O=Math.round(Q+C)%G,I=4*(G*P+O),M=B.data[I+0],L=B.data[I+1],K=B.data[I+2],J=B.data[I+3],H=4*(G*P+Q),B.data[H+0]=M,B.data[H+1]=L,B.data[H+2]=K,B.data[H+3]=J}}for(P=0;F>P;P+=1){for(z=Math.floor(A),N=0;E>N;N+=1){for(Q=0;z+1>Q;Q+=1){I=4*(G*P+Q),M=B.data[I+0],L=B.data[I+1],K=B.data[I+2],J=B.data[I+3],H=4*(G*P+2*z-Q-1),B.data[H+0]=M,B.data[H+1]=L,B.data[H+2]=K,B.data[H+3]=J}z*=2}}d(B,R,{polarRotation:0})}},Kinetic.Factory.addGetterSetter(Kinetic.Node,"kaleidoscopePower",2,null,Kinetic.Factory.afterSetFilter),Kinetic.Factory.addGetterSetter(Kinetic.Node,"kaleidoscopeAngle",0,null,Kinetic.Factory.afterSetFilter)}(),function(){function h(b){setTimeout(b,1000/60)}function g(){return j.apply(Kinetic.root,arguments)}var l=500,k=function(){return Kinetic.root.performance&&Kinetic.root.performance.now?function(){return Kinetic.root.performance.now()}:function(){return(new Date).getTime()}}(),j=function(){return Kinetic.root.requestAnimationFrame||Kinetic.root.webkitRequestAnimationFrame||Kinetic.root.mozRequestAnimationFrame||Kinetic.root.oRequestAnimationFrame||Kinetic.root.msRequestAnimationFrame||h}();Kinetic.Animation=function(e,d){var f=Kinetic.Animation;this.func=e,this.setLayers(d),this.id=f.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:k()}},Kinetic.Animation.prototype={setLayers:function(d){var c=[];c=d?d.length>0?d:[d]:[],this.layers=c},getLayers:function(){return this.layers},addLayer:function(f){var e,n,m=this.layers;if(m){for(e=m.length,n=0;e>n;n++){if(m[n]._id===f._id){return !1}}}else{this.layers=[]}return this.layers.push(f),!0},isRunning:function(){var f,e=Kinetic.Animation,n=e.animations,m=n.length;for(f=0;m>f;f++){if(n[f].id===this.id){return !0}}return !1},start:function(){var b=Kinetic.Animation;this.stop(),this.frame.timeDiff=0,this.frame.lastTime=k(),b._addAnimation(this)},stop:function(){Kinetic.Animation._removeAnimation(this)},_updateFrameObject:function(b){this.frame.timeDiff=b-this.frame.lastTime,this.frame.lastTime=b,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1000/this.frame.timeDiff}},Kinetic.Animation.animations=[],Kinetic.Animation.animIdCounter=0,Kinetic.Animation.animRunning=!1,Kinetic.Animation._addAnimation=function(b){this.animations.push(b),this._handleAnimation()},Kinetic.Animation._removeAnimation=function(m){var f,p=m.id,o=this.animations,n=o.length;for(f=0;n>f;f++){if(o[f].id===p){this.animations.splice(f,1);break}}},Kinetic.Animation._runFrames=function(){var v,u,t,s,r,q,p,o,n,m={},d=this.animations;for(s=0;sr;r++){p=u[r],void 0!==p._id&&(m[p._id]=p)}}}for(o in m){m[o].draw()}},Kinetic.Animation._animationLoop=function(){var b=Kinetic.Animation;b.animations.length?(g(b._animationLoop),b._runFrames()):b.animRunning=!1},Kinetic.Animation._handleAnimation=function(){var b=this;this.animRunning||(this.animRunning=!0,b._animationLoop())};var i=Kinetic.Node.prototype.moveTo;Kinetic.Node.prototype.moveTo=function(b){i.call(this,b)},Kinetic.BaseLayer.prototype.batchDraw=function(){var d=this,c=Kinetic.Animation;this.batchAnim||(this.batchAnim=new c(function(){d.lastBatchDrawTime&&k()-d.lastBatchDrawTime>l&&d.batchAnim.stop()},this)),this.lastBatchDrawTime=k(),this.batchAnim.isRunning()||(this.draw(),this.batchAnim.start())},Kinetic.Stage.prototype.batchDraw=function(){this.getChildren().each(function(b){b.batchDraw()})}}(this),function(){var h={node:1,duration:1,easing:1,onFinish:1,yoyo:1},g=1,l=2,k=3,j=0;Kinetic.Tween=function(a){var q,p,o=this,n=a.node,m=n._id,f=a.easing||Kinetic.Easings.Linear,e=!!a.yoyo;q="undefined"==typeof a.duration?1:0===a.duration?0.001:a.duration,this.node=n,this._id=j++,this.anim=new Kinetic.Animation(function(){o.tween.onEnterFrame()},n.getLayer()||(n instanceof Kinetic.Stage?n.getLayers():null)),this.tween=new i(p,function(b){o._tweenFunc(b)},f,0,1,1000*q,e),this._addListeners(),Kinetic.Tween.attrs[m]||(Kinetic.Tween.attrs[m]={}),Kinetic.Tween.attrs[m][this._id]||(Kinetic.Tween.attrs[m][this._id]={}),Kinetic.Tween.tweens[m]||(Kinetic.Tween.tweens[m]={});for(p in a){void 0===h[p]&&this._addAttr(p,a[p])}this.reset(),this.onFinish=a.onFinish,this.onReset=a.onReset},Kinetic.Tween.attrs={},Kinetic.Tween.tweens={},Kinetic.Tween.prototype={_addAttr:function(u,t){var s,r,q,p,o,n=this.node,m=n._id;if(q=Kinetic.Tween.tweens[m][u],q&&delete Kinetic.Tween.attrs[m][q][u],s=n.getAttr(u),Kinetic.Util._isArray(t)){for(r=[],o=t.length,p=0;o>p;p++){r.push(t[p]-s[p])}}else{r=t-s}Kinetic.Tween.attrs[m][this._id][u]={start:s,diff:r},Kinetic.Tween.tweens[m][u]=this._id},_tweenFunc:function(v){var u,t,s,r,q,p,o,n=this.node,m=Kinetic.Tween.attrs[n._id][this._id];for(u in m){if(t=m[u],s=t.start,r=t.diff,Kinetic.Util._isArray(s)){for(q=[],o=s.length,p=0;o>p;p++){q.push(s[p]+r[p]*v)}}else{q=s+r*v}n.setAttr(u,q)}},_addListeners:function(){var b=this;this.tween.onPlay=function(){b.anim.start()},this.tween.onReverse=function(){b.anim.start()},this.tween.onPause=function(){b.anim.stop()},this.tween.onFinish=function(){b.onFinish&&b.onFinish()},this.tween.onReset=function(){b.onReset&&b.onReset()}},play:function(){return this.tween.play(),this},reverse:function(){return this.tween.reverse(),this},reset:function(){return this.tween.reset(),this},seek:function(b){return this.tween.seek(1000*b),this},pause:function(){return this.tween.pause(),this},finish:function(){return this.tween.finish(),this},destroy:function(){var f,e=this.node._id,n=this._id,m=Kinetic.Tween.tweens[e];this.pause();for(f in m){delete Kinetic.Tween.tweens[e][f]}delete Kinetic.Tween.attrs[e][n]}};var i=function(n,m,s,r,q,p,o){this.prop=n,this.propFunc=m,this.begin=r,this._pos=r,this.duration=p,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=s,this._change=q-this.begin,this.pause()};i.prototype={fire:function(d){var c=this[d];c&&c()},setTime:function(b){b>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():0>b?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=b,this.update())},getTime:function(){return this._time},setPosition:function(b){this.prevPos=this._pos,this.propFunc(b),this._pos=b},getPosition:function(b){return void 0===b&&(b=this._time),this.func(b,this.begin,this._change,this.duration)},play:function(){this.state=l,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")},reverse:function(){this.state=k,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")},seek:function(b){this.pause(),this._time=b,this.update(),this.fire("onSeek")},reset:function(){this.pause(),this._time=0,this.update(),this.fire("onReset")},finish:function(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")},update:function(){this.setPosition(this.getPosition(this._time))},onEnterFrame:function(){var b=this.getTimer()-this._startTime;this.state===l?this.setTime(b):this.state===k&&this.setTime(this.duration-b)},pause:function(){this.state=g,this.fire("onPause")},getTimer:function(){return(new Date).getTime()}},Kinetic.Easings={BackEaseIn:function(m,f,p,o){var n=1.70158;return p*(m/=o)*m*((n+1)*m-n)+f},BackEaseOut:function(m,f,p,o){var n=1.70158;return p*((m=m/o-1)*m*((n+1)*m+n)+1)+f},BackEaseInOut:function(m,f,p,o){var n=1.70158;return(m/=o/2)<1?p/2*m*m*(((n*=1.525)+1)*m-n)+f:p/2*((m-=2)*m*(((n*=1.525)+1)*m+n)+2)+f},ElasticEaseIn:function(n,m,s,r,q,p){var o=0;return 0===n?m:1==(n/=r)?m+s:(p||(p=0.3*r),!q||qn?-0.5*q*Math.pow(2,10*(n-=1))*Math.sin(2*(n*r-o)*Math.PI/p)+m:q*Math.pow(2,-10*(n-=1))*Math.sin(2*(n*r-o)*Math.PI/p)*0.5+s+m)},BounceEaseOut:function(f,e,n,m){return(f/=m)<1/2.75?7.5625*n*f*f+e:2/2.75>f?n*(7.5625*(f-=1.5/2.75)*f+0.75)+e:2.5/2.75>f?n*(7.5625*(f-=2.25/2.75)*f+0.9375)+e:n*(7.5625*(f-=2.625/2.75)*f+0.984375)+e},BounceEaseIn:function(f,e,n,m){return n-Kinetic.Easings.BounceEaseOut(m-f,0,n,m)+e},BounceEaseInOut:function(f,e,n,m){return m/2>f?0.5*Kinetic.Easings.BounceEaseIn(2*f,0,n,m)+e:0.5*Kinetic.Easings.BounceEaseOut(2*f-m,0,n,m)+0.5*n+e},EaseIn:function(f,e,n,m){return n*(f/=m)*f+e},EaseOut:function(f,e,n,m){return -n*(f/=m)*(f-2)+e},EaseInOut:function(f,e,n,m){return(f/=m/2)<1?n/2*f*f+e:-n/2*(--f*(f-2)-1)+e},StrongEaseIn:function(f,e,n,m){return n*(f/=m)*f*f*f*f+e},StrongEaseOut:function(f,e,n,m){return n*((f=f/m-1)*f*f*f*f+1)+e},StrongEaseInOut:function(f,e,n,m){return(f/=m/2)<1?n/2*f*f*f*f*f+e:n/2*((f-=2)*f*f*f*f+2)+e},Linear:function(f,e,n,m){return n*f/m+e}}}(),function(){Kinetic.DD={anim:new Kinetic.Animation(function(){var b=this.dirty;return this.dirty=!1,b}),isDragging:!1,justDragged:!1,offset:{x:0,y:0},node:null,_drag:function(h){var g=Kinetic.DD,l=g.node;if(l){if(!g.isDragging){var k=l.getStage().getPointerPosition(),j=l.dragDistance(),i=Math.max(Math.abs(k.x-g.startPointerPos.x),Math.abs(k.y-g.startPointerPos.y));if(j>i){return}}l._setDragPosition(h),g.isDragging||(g.isDragging=!0,l.fire("dragstart",{type:"dragstart",target:l,evt:h},!0)),l.fire("dragmove",{type:"dragmove",target:l,evt:h},!0)}},_endDragBefore:function(g){var f,j,i=Kinetic.DD,h=i.node;h&&(f=h.nodeType,j=h.getLayer(),i.anim.stop(),i.isDragging&&(i.isDragging=!1,i.justDragged=!0,Kinetic.listenClickTap=!1,g&&(g.dragEndNode=h)),delete i.node,(j||h).draw())},_endDragAfter:function(f){f=f||{};var e=f.dragEndNode;f&&e&&e.fire("dragend",{type:"dragend",target:e,evt:f},!0)}},Kinetic.Node.prototype.startDrag=function(){var g=Kinetic.DD,f=this.getStage(),j=this.getLayer(),i=f.getPointerPosition(),h=this.getAbsolutePosition();i&&(g.node&&g.node.stopDrag(),g.node=this,g.startPointerPos=i,g.offset.x=i.x-h.x,g.offset.y=i.y-h.y,g.anim.setLayers(j||this.getLayers()),g.anim.start(),this._setDragPosition())},Kinetic.Node.prototype._setDragPosition=function(g){var f=Kinetic.DD,j=this.getStage().getPointerPosition(),i=this.getDragBoundFunc();if(j){var h={x:j.x-f.offset.x,y:j.y-f.offset.y};void 0!==i&&(h=i.call(this,h,g)),this.setAbsolutePosition(h),this._lastPos&&this._lastPos.x===h.x&&this._lastPos.y===h.y||(f.anim.dirty=!0),this._lastPos=h}},Kinetic.Node.prototype.stopDrag=function(){var f=Kinetic.DD,e={};f._endDragBefore(e),f._endDragAfter(e)},Kinetic.Node.prototype.setDraggable=function(b){this._setAttr("draggable",b),this._dragChange()};var d=Kinetic.Node.prototype.destroy;Kinetic.Node.prototype.destroy=function(){var a=Kinetic.DD;a.node&&a.node._id===this._id&&this.stopDrag(),d.call(this)},Kinetic.Node.prototype.isDragging=function(){var b=Kinetic.DD;return !(!b.node||b.node._id!==this._id||!b.isDragging)},Kinetic.Node.prototype._listenDrag=function(){var b=this;this._dragCleanup(),"Stage"===this.getClassName()?this.on("contentMousedown.kinetic contentTouchstart.kinetic",function(a){Kinetic.DD.node||b.startDrag(a)}):this.on("mousedown.kinetic touchstart.kinetic",function(a){1!==a.evt.button&&2!==a.evt.button&&(Kinetic.DD.node||b.startDrag(a))})},Kinetic.Node.prototype._dragChange=function(){if(this.attrs.draggable){this._listenDrag()}else{this._dragCleanup();var f=this.getStage(),e=Kinetic.DD;f&&e.node&&e.node._id===this._id&&e.node.stopDrag()}},Kinetic.Node.prototype._dragCleanup=function(){"Stage"===this.getClassName()?(this.off("contentMousedown.kinetic"),this.off("contentTouchstart.kinetic")):(this.off("mousedown.kinetic"),this.off("touchstart.kinetic"))},Kinetic.Factory.addGetterSetter(Kinetic.Node,"dragBoundFunc"),Kinetic.Factory.addGetter(Kinetic.Node,"draggable",!1),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node,"draggable");var c=Kinetic.document.documentElement;c.addEventListener("mouseup",Kinetic.DD._endDragBefore,!0),c.addEventListener("touchend",Kinetic.DD._endDragBefore,!0),c.addEventListener("mouseup",Kinetic.DD._endDragAfter,!1),c.addEventListener("touchend",Kinetic.DD._endDragAfter,!1)}(),function(){Kinetic.Util.addMethods(Kinetic.Container,{__init:function(b){this.children=new Kinetic.Collection,Kinetic.Node.call(this,b)},getChildren:function(d){if(d){var c=new Kinetic.Collection;return this.children.each(function(a){d(a)&&c.push(a)}),c}return this.children},hasChildren:function(){return this.getChildren().length>0},removeChildren:function(){for(var e,d=Kinetic.Collection.toCollection(this.children),f=0;f1){for(var d=0;du;u++){if(s=m[u],"#"===s.charAt(0)){q=this._getNodeById(s.slice(1)),q&&n.push(q)}else{if("."===s.charAt(0)){r=this._getNodesByName(s.slice(1)),n=n.concat(r)}else{for(p=this.getChildren(),o=p.length,t=0;o>t;t++){n=n.concat(p[t]._get(s))}}}}return Kinetic.Collection.toCollection(n)},_getNodeById:function(d){var c=Kinetic.ids[d];return void 0!==c&&this.isAncestorOf(c)?c:null},_getNodesByName:function(d){var c=Kinetic.names[d]||[];return this._getDescendants(c)},_get:function(g){for(var f=Kinetic.Node.prototype._get.call(this,g),j=this.getChildren(),i=j.length,h=0;i>h;h++){f=f.concat(j[h]._get(g))}return f},toObject:function(){var g=Kinetic.Node.prototype.toObject.call(this);g.children=[];for(var f=this.getChildren(),j=f.length,i=0;j>i;i++){var h=f[i];g.children.push(h.toObject())}return g},_getDescendants:function(g){for(var f=[],j=g.length,i=0;j>i;i++){var h=g[i];this.isAncestorOf(h)&&f.push(h)}return f},isAncestorOf:function(d){for(var c=d.getParent();c;){if(c._id===this._id){return !0}c=c.getParent()}return !1},clone:function(d){var c=Kinetic.Node.prototype.clone.call(this,d);return this.getChildren().each(function(b){c.add(b.clone())}),c},getAllIntersections:function(d){var c=[];return this.find("Shape").each(function(a){a.isVisible()&&a.intersects(d)&&c.push(a)}),c},_setChildrenIndices:function(){this.children.each(function(d,c){d.index=c})},drawScene:function(i,h){var n=this.getLayer(),m=i||n&&n.getCanvas(),l=m&&m.getContext(),k=this._cache.canvas,j=k&&k.scene;return this.isVisible()&&(j?this._drawCachedSceneCanvas(l):this._drawChildren(m,"drawScene",h)),this},drawHit:function(i,h){var n=this.getLayer(),m=i||n&&n.hitCanvas,l=m&&m.getContext(),k=this._cache.canvas,j=k&&k.hit;return this.shouldDrawHit(m)&&(n&&n.clearHitCache(),j?this._drawCachedHitCanvas(l):this._drawChildren(m,"drawHit",h)),this},_drawChildren:function(t,s,r){var q,p,o=this.getLayer(),n=t&&t.getContext(),m=this.getClipWidth(),l=this.getClipHeight(),k=m&&l;k&&o&&(q=this.getClipX(),p=this.getClipY(),n.save(),o._applyTransform(this,n),n.beginPath(),n.rect(q,p,m,l),n.clip(),n.reset()),this.children.each(function(a){a[s](t,r)}),k&&n.restore()},shouldDrawHit:function(f){var e=this.getLayer(),h=Kinetic.DD,g=h&&Kinetic.isDragging()&&-1!==Kinetic.DD.anim.getLayers().indexOf(e);return f&&f.isCache||e&&e.hitGraphEnabled()&&this.isVisible()&&!g}}),Kinetic.Util.extend(Kinetic.Container,Kinetic.Node),Kinetic.Container.prototype.get=Kinetic.Container.prototype.find,Kinetic.Factory.addComponentsGetterSetter(Kinetic.Container,"clip",["x","y","width","height"]),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipX"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipY"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipWidth"),Kinetic.Factory.addGetterSetter(Kinetic.Container,"clipHeight"),Kinetic.Collection.mapMethods(Kinetic.Container)}(),function(){function h(b){b.fill()}function g(b){b.stroke()}function l(b){b.fill()}function k(b){b.stroke()}function j(){this._clearCache(i)}var i="hasShadow";Kinetic.Util.addMethods(Kinetic.Shape,{__init:function(c){this.nodeType="Shape",this._fillFunc=h,this._strokeFunc=g,this._fillFuncHit=l,this._strokeFuncHit=k;for(var b,a=Kinetic.shapes;;){if(b=Kinetic.Util.getRandomColor(),b&&!(b in a)){break}}this.colorKey=b,a[b]=this,Kinetic.Node.call(this,c),this.on("shadowColorChange.kinetic shadowBlurChange.kinetic shadowOffsetChange.kinetic shadowOpacityChange.kinetic shadowEnabledChange.kinetic",j)},hasChildren:function(){return !1},getChildren:function(){return[]},getContext:function(){return this.getLayer().getContext()},getCanvas:function(){return this.getLayer().getCanvas()},hasShadow:function(){return this._getCache(i,this._hasShadow)},_hasShadow:function(){return this.getShadowEnabled()&&0!==this.getShadowOpacity()&&!!(this.getShadowColor()||this.getShadowBlur()||this.getShadowOffsetX()||this.getShadowOffsetY())},hasFill:function(){return !!(this.getFill()||this.getFillPatternImage()||this.getFillLinearGradientColorStops()||this.getFillRadialGradientColorStops())},hasStroke:function(){return !!(this.stroke()||this.strokeRed()||this.strokeGreen()||this.strokeBlue())},intersects:function(f){var e,n=this.getStage(),m=n.bufferHitCanvas;return m.getContext().clear(),this.drawScene(m),e=m.context.getImageData(Math.round(f.x),Math.round(f.y),1,1).data,e[3]>0},destroy:function(){Kinetic.Node.prototype.destroy.call(this),delete Kinetic.shapes[this.colorKey]},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasFill()&&this.hasStroke()&&this.getStage()},drawScene:function(z,y){var x,w,v,u=this.getLayer(),t=z||u.getCanvas(),s=t.getContext(),r=this._cache.canvas,q=this.sceneFunc(),p=this.hasShadow();if(this.isVisible()){if(r){this._drawCachedSceneCanvas(s)}else{if(q){if(s.save(),this._useBufferCanvas()){if(x=this.getStage(),w=x.bufferCanvas,v=w.getContext(),v.clear(),v.save(),v._applyLineJoin(this),u){u._applyTransform(this,v,y)}else{var o=this.getAbsoluteTransform(y).getMatrix();s.transform(o[0],o[1],o[2],o[3],o[4],o[5])}q.call(this,v),v.restore(),p&&!t.hitCanvas&&(s.save(),s._applyShadow(this),s.drawImage(w._canvas,0,0),s.restore()),s._applyOpacity(this),s.drawImage(w._canvas,0,0)}else{if(s._applyLineJoin(this),u){u._applyTransform(this,s,y)}else{var n=this.getAbsoluteTransform(y).getMatrix();s.transform(n[0],n[1],n[2],n[3],n[4],n[5])}p&&!t.hitCanvas&&(s.save(),s._applyShadow(this),q.call(this,s),s.restore()),s._applyOpacity(this),q.call(this,s)}s.restore()}}}return this},drawHit:function(u,t){var s=this.getLayer(),r=u||s.hitCanvas,q=r.getContext(),p=this.hitFunc()||this.sceneFunc(),o=this._cache.canvas,n=o&&o.hit;if(this.shouldDrawHit(r)){if(s&&s.clearHitCache(),n){this._drawCachedHitCanvas(q)}else{if(p){if(q.save(),q._applyLineJoin(this),s){s._applyTransform(this,q,t)}else{var m=this.getAbsoluteTransform(t).getMatrix();q.transform(m[0],m[1],m[2],m[3],m[4],m[5])}p.call(this,q),q.restore()}}}return this},drawHitFromCache:function(J){var I,H,G,F,E,D,C,B,A=J||0,z=this._cache.canvas,y=this._getCachedSceneCanvas(),x=y.getContext(),w=z.hit,v=w.getContext(),u=y.getWidth(),t=y.getHeight();v.clear();try{for(I=x.getImageData(0,0,u,t),H=I.data,G=v.getImageData(0,0,u,t),F=G.data,E=H.length,D=Kinetic.Util._hexToRgb(this.colorKey),C=0;E>C;C+=4){B=H[C+3],B>A&&(F[C]=D.r,F[C+1]=D.g,F[C+2]=D.b,F[C+3]=255)}v.putImageData(G,0,0)}catch(s){Kinetic.Util.warn("Unable to draw hit graph from cached scene canvas. "+s.message)}return this}}),Kinetic.Util.extend(Kinetic.Shape,Kinetic.Node),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"stroke"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeWidth",2),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"lineJoin"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"lineCap"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"sceneFunc"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"hitFunc"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"dash"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowColor"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowBlur"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOpacity"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"shadowOffset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOffsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowOffsetY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternImage"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fill"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRed",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillGreen",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillBlue",0,Kinetic.Validators.RGBComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillAlpha",1,Kinetic.Validators.alphaComponent),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientColorStops"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientColorStops"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternRepeat","repeat"),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"shadowEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"dashEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"strokeScaleEnabled",!0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPriority","color"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillPatternOffset",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternOffsetX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternOffsetY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillPatternScale",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternScaleX",1),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternScaleY",1),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillLinearGradientStartPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientStartPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientStartPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillLinearGradientEndPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientEndPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillLinearGradientEndPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillRadialGradientStartPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientStartPointY",0),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Shape,"fillRadialGradientEndPoint",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndPointX",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillRadialGradientEndPointY",0),Kinetic.Factory.addGetterSetter(Kinetic.Shape,"fillPatternRotation",0),Kinetic.Factory.backCompat(Kinetic.Shape,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"}),Kinetic.Collection.mapMethods(Kinetic.Shape)}(),function(){function aG(d,c){d.content.addEventListener(c,function(a){d[U+c](a)},!1)}var aF="Stage",aE="string",aD="px",aC="mouseout",aB="mouseleave",aA="mouseover",az="mouseenter",ay="mousemove",ax="mousedown",aw="mouseup",av="click",au="dblclick",at="touchstart",ar="touchend",aq="tap",ap="dbltap",ao="touchmove",an="DOMMouseScroll",am="mousewheel",al="wheel",ak="contentMouseout",aj="contentMouseover",ai="contentMousemove",ah="contentMousedown",ag="contentMouseup",af="contentClick",ae="contentDblclick",ad="contentTouchstart",ac="contentTouchend",ab="contentDbltap",aa="contentTouchmove",Z="div",Y="relative",X="inline-block",W="kineticjs-content",V=" ",U="_",T="container",S="",R=[ax,ay,aw,aC,at,ao,ar,aA,an,am,al],Q=R.length;Kinetic.Util.addMethods(Kinetic.Stage,{___init:function(b){this.nodeType=aF,Kinetic.Container.call(this,b),this._id=Kinetic.idCounter++,this._buildDOM(),this._bindContentEvents(),this._enableNestedTransforms=!1,Kinetic.stages.push(this)},_validateAdd:function(b){"Layer"!==b.getType()&&Kinetic.Util.error("You may only add layers to the stage.")},setContainer:function(d){if(typeof d===aE){var c=d;if(d=Kinetic.document.getElementById(d),!d){throw"Can not find container in document with id "+c}}return this._setAttr(T,d),this},shouldDrawHit:function(){return !0},draw:function(){return Kinetic.Node.prototype.draw.call(this),this},setHeight:function(b){return Kinetic.Node.prototype.setHeight.call(this,b),this._resizeDOM(),this},setWidth:function(b){return Kinetic.Node.prototype.setWidth.call(this,b),this._resizeDOM(),this},clear:function(){var e,d=this.children,f=d.length;for(e=0;f>e;e++){d[e].clear()}return this},clone:function(b){return b||(b={}),b.container=Kinetic.document.createElement(Z),Kinetic.Container.prototype.clone.call(this,b)},destroy:function(){var d=this.content;Kinetic.Container.prototype.destroy.call(this),d&&Kinetic.Util._isInDocument(d)&&this.getContainer().removeChild(d);var c=Kinetic.stages.indexOf(this);c>-1&&Kinetic.stages.splice(c,1)},getPointerPosition:function(){return this.pointerPos},getStage:function(){return this},getContent:function(){return this.content},toDataURL:function(r){function q(d){var c=j[d],b=c.toDataURL(),a=new Kinetic.window.Image;a.onload=function(){k.drawImage(a,0,0),d=0;g--){if(l=k[g].getIntersection(h)){return l}}return null},_resizeDOM:function(){if(this.content){var h,d,l=this.getWidth(),k=this.getHeight(),j=this.getChildren(),i=j.length;for(this.content.style.width=l+aD,this.content.style.height=k+aD,this.bufferCanvas.setSize(l,k),this.bufferHitCanvas.setSize(l,k),h=0;i>h;h++){d=j[h],d.setSize(l,k),d.draw()}}},add:function(d){if(!(arguments.length>1)){return Kinetic.Container.prototype.add.call(this,d),d._setCanvasSize(this.width(),this.height()),d.draw(),this.content.appendChild(d.canvas._canvas),this}for(var c=0;ca;a++){aG(this,R[a])}},_mouseover:function(b){Kinetic.UA.mobile||(this._setPointerPosition(b),this._fire(aj,{evt:b}))},_mouseout:function(d){if(!Kinetic.UA.mobile){this._setPointerPosition(d);var c=this.targetShape;c&&!Kinetic.isDragging()&&(c._fireAndBubble(aC,{evt:d}),c._fireAndBubble(aB,{evt:d}),this.targetShape=null),this.pointerPos=void 0,this._fire(ak,{evt:d})}},_mousemove:function(e){if(Kinetic.UA.ieMobile){return this._touchmove(e)}if(("undefined"==typeof e.webkitMovementX&&"undefined"==typeof e.webkitMovementY||0!==e.webkitMovementY||0!==e.webkitMovementX)&&!Kinetic.UA.mobile){this._setPointerPosition(e);var d,f=Kinetic.DD;Kinetic.isDragging()||(d=this.getIntersection(this.getPointerPosition()),d&&d.isListening()?Kinetic.isDragging()||this.targetShape&&this.targetShape._id===d._id?d._fireAndBubble(ay,{evt:e}):(this.targetShape&&(this.targetShape._fireAndBubble(aC,{evt:e},d),this.targetShape._fireAndBubble(aB,{evt:e},d)),d._fireAndBubble(aA,{evt:e},this.targetShape),d._fireAndBubble(az,{evt:e},this.targetShape),this.targetShape=d):this.targetShape&&!Kinetic.isDragging()&&(this.targetShape._fireAndBubble(aC,{evt:e}),this.targetShape._fireAndBubble(aB,{evt:e}),this.targetShape=null),this._fire(ai,{evt:e})),f&&f._drag(e),e.preventDefault&&e.preventDefault()}},_mousedown:function(d){if(Kinetic.UA.ieMobile){return this._touchstart(d)}if(!Kinetic.UA.mobile){this._setPointerPosition(d);var c=this.getIntersection(this.getPointerPosition());Kinetic.listenClickTap=!0,c&&c.isListening()&&(this.clickStartShape=c,c._fireAndBubble(ax,{evt:d})),this._fire(ah,{evt:d})}d.preventDefault&&d.preventDefault()},_mouseup:function(g){if(Kinetic.UA.ieMobile){return this._touchend(g)}if(!Kinetic.UA.mobile){this._setPointerPosition(g);var f=this.getIntersection(this.getPointerPosition()),j=this.clickStartShape,i=!1,h=Kinetic.DD;Kinetic.inDblClickWindow?(i=!0,Kinetic.inDblClickWindow=!1):h&&h.justDragged?h&&(h.justDragged=!1):Kinetic.inDblClickWindow=!0,setTimeout(function(){Kinetic.inDblClickWindow=!1},Kinetic.dblClickWindow),f&&f.isListening()&&(f._fireAndBubble(aw,{evt:g}),Kinetic.listenClickTap&&j&&j._id===f._id&&(f._fireAndBubble(av,{evt:g}),i&&f._fireAndBubble(au,{evt:g}))),this._fire(ag,{evt:g}),Kinetic.listenClickTap&&(this._fire(af,{evt:g}),i&&this._fire(ae,{evt:g})),Kinetic.listenClickTap=!1}g.preventDefault&&g.preventDefault()},_touchstart:function(d){this._setPointerPosition(d);var c=this.getIntersection(this.getPointerPosition());Kinetic.listenClickTap=!0,c&&c.isListening()&&(this.tapStartShape=c,c._fireAndBubble(at,{evt:d}),c.isListening()&&d.preventDefault&&d.preventDefault()),this._fire(ad,{evt:d})},_touchend:function(e){this._setPointerPosition(e);var d=this.getIntersection(this.getPointerPosition()),f=!1;Kinetic.inDblClickWindow?(f=!0,Kinetic.inDblClickWindow=!1):Kinetic.inDblClickWindow=!0,setTimeout(function(){Kinetic.inDblClickWindow=!1},Kinetic.dblClickWindow),d&&d.isListening()&&(d._fireAndBubble(ar,{evt:e}),Kinetic.listenClickTap&&d._id===this.tapStartShape._id&&(d._fireAndBubble(aq,{evt:e}),f&&d._fireAndBubble(ap,{evt:e})),d.isListening()&&e.preventDefault&&e.preventDefault()),Kinetic.listenClickTap&&(this._fire(ac,{evt:e}),f&&this._fire(ab,{evt:e})),Kinetic.listenClickTap=!1},_touchmove:function(e){this._setPointerPosition(e);var d,f=Kinetic.DD;Kinetic.isDragging()||(d=this.getIntersection(this.getPointerPosition()),d&&d.isListening()&&(d._fireAndBubble(ao,{evt:e}),d.isListening()&&e.preventDefault&&e.preventDefault()),this._fire(aa,{evt:e})),f&&(f._drag(e),Kinetic.isDragging()&&e.preventDefault())},_DOMMouseScroll:function(b){this._mousewheel(b)},_mousewheel:function(d){this._setPointerPosition(d);var c=this.getIntersection(this.getPointerPosition());c&&c.isListening()&&c._fireAndBubble(am,{evt:d})},_wheel:function(b){this._mousewheel(b)},_setPointerPosition:function(i){var h,n=this._getContentPosition(),m=i.offsetX,l=i.clientX,k=null,j=null;i=i?i:window.event,void 0!==i.touches?i.touches.length>0&&(h=i.touches[0],k=h.clientX-n.left,j=h.clientY-n.top):void 0!==m?(k=m,j=i.offsetY):"mozilla"===Kinetic.UA.browser?(k=i.layerX,j=i.layerY):void 0!==l&&n&&(k=l-n.left,j=i.clientY-n.top),null!==k&&null!==j&&(this.pointerPos={x:k,y:j})},_getContentPosition:function(){var b=this.content.getBoundingClientRect?this.content.getBoundingClientRect():{top:0,left:0};return{top:b.top,left:b.left}},_buildDOM:function(){var b=this.getContainer();if(!b){if(Kinetic.Util.isBrowser()){throw"Stage has no container. A container is required."}b=Kinetic.document.createElement(Z)}b.innerHTML=S,this.content=Kinetic.document.createElement(Z),this.content.style.position=Y,this.content.style.display=X,this.content.className=W,this.content.setAttribute("role","presentation"),b.appendChild(this.content),this.bufferCanvas=new Kinetic.SceneCanvas({pixelRatio:1}),this.bufferHitCanvas=new Kinetic.HitCanvas,this._resizeDOM()},_onContent:function(h,g){var l,k,j=h.split(V),i=j.length;for(l=0;i>l;l++){k=j[l],this.content.addEventListener(k,g,!1)}},cache:function(){Kinetic.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.")},clearCache:function(){}}),Kinetic.Util.extend(Kinetic.Stage,Kinetic.Container),Kinetic.Factory.addGetter(Kinetic.Stage,"container"),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Stage,"container")}(),function(){Kinetic.Util.addMethods(Kinetic.BaseLayer,{___init:function(b){this.nodeType="Layer",Kinetic.Container.call(this,b)},createPNGStream:function(){return this.canvas._canvas.createPNGStream()},getCanvas:function(){return this.canvas},getHitCanvas:function(){return this.hitCanvas},getContext:function(){return this.getCanvas().getContext()},clear:function(b){return this.getContext().clear(b),this.getHitCanvas().getContext().clear(b),this},clearHitCache:function(){this._hitImageData=void 0},setZIndex:function(d){Kinetic.Node.prototype.setZIndex.call(this,d);var c=this.getStage();return c&&(c.content.removeChild(this.getCanvas()._canvas),do;o++){if(n=i[o],d=this._getIntersection({x:e.x+n.x*l,y:e.y+n.y*l}),m=d.shape){return m}d.antialiased&&(k=!0)}if(!k){return}l+=1}},_getImageData:function(l,k){var o=this.hitCanvas.width||1,n=this.hitCanvas.height||1,m=Math.round(k)*o+Math.round(l);return this._hitImageData||(this._hitImageData=this.hitCanvas.context.getImageData(0,0,o,n)),[this._hitImageData.data[4*m+0],this._hitImageData.data[4*m+1],this._hitImageData.data[4*m+2],this._hitImageData.data[4*m+3]]},_getIntersection:function(a){var n,m,l=this.hitCanvas.context.getImageData(a.x,a.y,1,1).data,k=l[3];return 255===k?(n=Kinetic.Util._rgbToHex(l[0],l[1],l[2]),m=Kinetic.shapes[g+n],{shape:m}):k>0?{antialiased:!0}:{}},drawScene:function(b,l){var k=this.getLayer(),c=b||k&&k.getCanvas();return this._fire(f,{node:this}),this.getClearBeforeDraw()&&c.getContext().clear(),Kinetic.Container.prototype.drawScene.call(this,c,l),this._fire(j,{node:this}),this},_applyTransform:function(k,e,m){var l=k.getAbsoluteTransform(m).getMatrix();e.transform(l[0],l[1],l[2],l[3],l[4],l[5])},drawHit:function(k,e){var m=this.getLayer(),l=k||m&&m.hitCanvas;return m&&m.getClearBeforeDraw()&&m.getHitCanvas().getContext().clear(),Kinetic.Container.prototype.drawHit.call(this,l,e),this.imageData=null,this},clear:function(b){return this.getContext().clear(b),this.getHitCanvas().getContext().clear(b),this.imageData=null,this},setVisible:function(b){return Kinetic.Node.prototype.setVisible.call(this,b),b?(this.getCanvas()._canvas.style.display="block",this.hitCanvas._canvas.style.display="block"):(this.getCanvas()._canvas.style.display="none",this.hitCanvas._canvas.style.display="none"),this},enableHitGraph:function(){return this.setHitGraphEnabled(!0),this},disableHitGraph:function(){return this.setHitGraphEnabled(!1),this},setSize:function(d,c){Kinetic.BaseLayer.prototype.setSize.call(this,d,c),this.hitCanvas.setSize(d,c)}}),Kinetic.Util.extend(Kinetic.Layer,Kinetic.BaseLayer),Kinetic.Factory.addGetterSetter(Kinetic.Layer,"hitGraphEnabled",!0),Kinetic.Collection.mapMethods(Kinetic.Layer)}(),function(){Kinetic.Util.addMethods(Kinetic.FastLayer,{____init:function(b){this.nodeType="Layer",this.canvas=new Kinetic.SceneCanvas,Kinetic.BaseLayer.call(this,b)},_validateAdd:function(d){var c=d.getType();"Shape"!==c&&Kinetic.Util.error("You may only add shapes to a fast layer.")},_setCanvasSize:function(d,c){this.canvas.setSize(d,c)},hitGraphEnabled:function(){return !1},getIntersection:function(){return null},drawScene:function(e){var d=this.getLayer(),f=e||d&&d.getCanvas();return this.getClearBeforeDraw()&&f.getContext().clear(),Kinetic.Container.prototype.drawScene.call(this,f),this},_applyTransform:function(f,e,h){if(!h||h._id!==this._id){var g=f.getTransform().getMatrix();e.transform(g[0],g[1],g[2],g[3],g[4],g[5])}},draw:function(){return this.drawScene(),this},clear:function(b){return this.getContext().clear(b),this},setVisible:function(b){return Kinetic.Node.prototype.setVisible.call(this,b),this.getCanvas()._canvas.style.display=b?"block":"none",this}}),Kinetic.Util.extend(Kinetic.FastLayer,Kinetic.BaseLayer),Kinetic.Collection.mapMethods(Kinetic.FastLayer)}(),function(){Kinetic.Util.addMethods(Kinetic.Group,{___init:function(b){this.nodeType="Group",Kinetic.Container.call(this,b)},_validateAdd:function(d){var c=d.getType();"Group"!==c&&"Shape"!==c&&Kinetic.Util.error("You may only add groups and shapes to groups.")}}),Kinetic.Util.extend(Kinetic.Group,Kinetic.Container),Kinetic.Collection.mapMethods(Kinetic.Group)}(),function(){Kinetic.Rect=function(b){this.___init(b)},Kinetic.Rect.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Rect",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(f){var e=this.getCornerRadius(),h=this.getWidth(),g=this.getHeight();f.beginPath(),e?(f.moveTo(e,0),f.lineTo(h-e,0),f.arc(h-e,e,e,3*Math.PI/2,0,!1),f.lineTo(h,g-e),f.arc(h-e,g-e,e,0,Math.PI/2,!1),f.lineTo(e,g),f.arc(e,g-e,e,Math.PI/2,Math.PI,!1),f.lineTo(0,e),f.arc(e,e,e,Math.PI,3*Math.PI/2,!1)):f.rect(0,0,h,g),f.closePath(),f.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Rect,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Rect,"cornerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Rect)}(),function(){var d=2*Math.PI-0.0001,c="Circle";Kinetic.Circle=function(b){this.___init(b)},Kinetic.Circle.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className=c,this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){a.beginPath(),a.arc(0,0,this.getRadius(),0,d,!1),a.closePath(),a.fillStrokeShape(this)},getWidth:function(){return 2*this.getRadius()},getHeight:function(){return 2*this.getRadius()},setWidth:function(b){Kinetic.Node.prototype.setWidth.call(this,b),this.radius()!==b/2&&this.setRadius(b/2)},setHeight:function(b){Kinetic.Node.prototype.setHeight.call(this,b),this.radius()!==b/2&&this.setRadius(b/2)},setRadius:function(b){this._setAttr("radius",b),this.setWidth(2*b),this.setHeight(2*b)}},Kinetic.Util.extend(Kinetic.Circle,Kinetic.Shape),Kinetic.Factory.addGetter(Kinetic.Circle,"radius",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Circle,"radius"),Kinetic.Collection.mapMethods(Kinetic.Circle)}(),function(){var d=2*Math.PI-0.0001,c="Ellipse";Kinetic.Ellipse=function(b){this.___init(b)},Kinetic.Ellipse.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className=c,this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){var f=this.getRadiusX(),e=this.getRadiusY();a.beginPath(),a.save(),f!==e&&a.scale(1,e/f),a.arc(0,0,f,0,d,!1),a.restore(),a.closePath(),a.fillStrokeShape(this)},getWidth:function(){return 2*this.getRadiusX()},getHeight:function(){return 2*this.getRadiusY()},setWidth:function(b){Kinetic.Node.prototype.setWidth.call(this,b),this.setRadius({x:b/2})},setHeight:function(b){Kinetic.Node.prototype.setHeight.call(this,b),this.setRadius({y:b/2})}},Kinetic.Util.extend(Kinetic.Ellipse,Kinetic.Shape),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Ellipse,"radius",["x","y"]),Kinetic.Factory.addGetterSetter(Kinetic.Ellipse,"radiusX",0),Kinetic.Factory.addGetterSetter(Kinetic.Ellipse,"radiusY",0),Kinetic.Collection.mapMethods(Kinetic.Ellipse)}(),function(){var b=2*Math.PI-0.0001;Kinetic.Ring=function(c){this.___init(c)},Kinetic.Ring.prototype={___init:function(c){Kinetic.Shape.call(this,c),this.className="Ring",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(a){a.beginPath(),a.arc(0,0,this.getInnerRadius(),0,b,!1),a.moveTo(this.getOuterRadius(),0),a.arc(0,0,this.getOuterRadius(),b,0,!0),a.closePath(),a.fillStrokeShape(this)},getWidth:function(){return 2*this.getOuterRadius()},getHeight:function(){return 2*this.getOuterRadius()},setWidth:function(c){Kinetic.Node.prototype.setWidth.call(this,c),this.outerRadius()!==c/2&&this.setOuterRadius(c/2)},setHeight:function(c){Kinetic.Node.prototype.setHeight.call(this,c),this.outerRadius()!==c/2&&this.setOuterRadius(c/2)},setOuterRadius:function(c){this._setAttr("outerRadius",c),this.setWidth(2*c),this.setHeight(2*c)}},Kinetic.Util.extend(Kinetic.Ring,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Ring,"innerRadius",0),Kinetic.Factory.addGetter(Kinetic.Ring,"outerRadius",0),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Ring,"outerRadius"),Kinetic.Collection.mapMethods(Kinetic.Ring)}(),function(){Kinetic.Wedge=function(b){this.___init(b)},Kinetic.Wedge.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Wedge",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(b){b.beginPath(),b.arc(0,0,this.getRadius(),0,Kinetic.getAngle(this.getAngle()),this.getClockwise()),b.lineTo(0,0),b.closePath(),b.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Wedge,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"radius",0),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"angle",0),Kinetic.Factory.addGetterSetter(Kinetic.Wedge,"clockwise",!1),Kinetic.Factory.backCompat(Kinetic.Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"}),Kinetic.Collection.mapMethods(Kinetic.Wedge)}(),function(){Kinetic.Arc=function(b){this.___init(b)},Kinetic.Arc.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Arc",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(e){var d=Kinetic.getAngle(this.angle()),f=this.clockwise();e.beginPath(),e.arc(0,0,this.getOuterRadius(),0,d,f),e.arc(0,0,this.getInnerRadius(),d,0,!f),e.closePath(),e.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Arc,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"innerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"outerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"angle",0),Kinetic.Factory.addGetterSetter(Kinetic.Arc,"clockwise",!1),Kinetic.Collection.mapMethods(Kinetic.Arc)}(),function(){var b="Image";Kinetic.Image=function(c){this.___init(c)},Kinetic.Image.prototype={___init:function(a){Kinetic.Shape.call(this,a),this.className=b,this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()&&this.getStage()},_sceneFunc:function(i){var h,n,m,l=this.getWidth(),k=this.getHeight(),j=this.getImage();j&&(h=this.getCropWidth(),n=this.getCropHeight(),m=h&&n?[j,this.getCropX(),this.getCropY(),h,n,0,0,l,k]:[j,0,0,l,k]),(this.hasFill()||this.hasStroke()||this.hasShadow())&&(i.beginPath(),i.rect(0,0,l,k),i.closePath(),i.fillStrokeShape(this)),j&&i.drawImage.apply(i,m)},_hitFunc:function(e){var d=this.getWidth(),f=this.getHeight();e.beginPath(),e.rect(0,0,d,f),e.closePath(),e.fillStrokeShape(this)},getWidth:function(){var c=this.getImage();return this.attrs.width||(c?c.width:0)},getHeight:function(){var c=this.getImage();return this.attrs.height||(c?c.height:0)}},Kinetic.Util.extend(Kinetic.Image,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Image,"image"),Kinetic.Factory.addComponentsGetterSetter(Kinetic.Image,"crop",["x","y","width","height"]),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropX",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropY",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropWidth",0),Kinetic.Factory.addGetterSetter(Kinetic.Image,"cropHeight",0),Kinetic.Collection.mapMethods(Kinetic.Image)}(),function(){function R(b){b.fillText(this.partialText,0,0)}function Q(b){b.strokeText(this.partialText,0,0)}var P="auto",O="center",N="Change.kinetic",M="2d",L="-",K="",J="left",I="text",H="Text",G="middle",F="normal",E="px ",D=" ",C="right",B="word",A="char",z="none",y=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","lineHeight","text","width","height","wrap"],x=y.length,w=Kinetic.Util.createCanvasElement().getContext(M);Kinetic.Text=function(b){this.___init(b)},Kinetic.Text.prototype={___init:function(b){b=b||{},b.fill=b.fill||"black",void 0===b.width&&(b.width=P),void 0===b.height&&(b.height=P),Kinetic.Shape.call(this,b),this._fillFunc=R,this._strokeFunc=Q,this.className=H;for(var a=0;x>a;a++){this.on(y[a]+N,this._setTextData)}this._setTextData(),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(v){var u,t=this.getPadding(),s=this.getTextHeight(),r=this.getLineHeight()*s,q=this.textArr,p=q.length,o=this.getWidth();for(v.setAttr("font",this._getContextFont()),v.setAttr("textBaseline",G),v.setAttr("textAlign",J),v.save(),v.translate(t,0),v.translate(0,t+s/2),u=0;p>u;u++){var l=q[u],i=l.text,d=l.width;v.save(),this.getAlign()===C?v.translate(o-d-2*t,0):this.getAlign()===O&&v.translate((o-d-2*t)/2,0),this.partialText=i,v.fillStrokeShape(this),v.restore(),v.translate(0,r)}v.restore()},_hitFunc:function(e){var d=this.getWidth(),f=this.getHeight();e.beginPath(),e.rect(0,0,d,f),e.closePath(),e.fillStrokeShape(this)},setText:function(d){var c=Kinetic.Util._isString(d)?d:d.toString();return this._setAttr(I,c),this},getWidth:function(){return this.attrs.width===P?this.getTextWidth()+2*this.getPadding():this.attrs.width},getHeight:function(){return this.attrs.height===P?this.getTextHeight()*this.textArr.length*this.getLineHeight()+2*this.getPadding():this.attrs.height},getTextWidth:function(){return this.textWidth},getTextHeight:function(){return this.textHeight},_getTextSize:function(f){var e,h=w,g=this.getFontSize();return h.save(),h.font=this._getContextFont(),e=h.measureText(f),h.restore(),{width:e.width,height:parseInt(g,10)}},_getContextFont:function(){return this.getFontStyle()+D+this.getFontVariant()+D+this.getFontSize()+E+this.getFontFamily()},_addTextLine:function(d,c){return this.textArr.push({text:d,width:c})},_getTextWidth:function(b){return w.measureText(b).width},_setTextData:function(){var am=this.getText().split("\n"),al=+this.getFontSize(),ak=0,aj=this.getLineHeight()*al,ai=this.attrs.width,ah=this.attrs.height,ag=ai!==P,af=ah!==P,ae=this.getPadding(),ad=ai-2*ae,ac=ah-2*ae,ab=0,aa=this.getWrap(),Y=aa!==z,U=aa!==A&&Y;this.textArr=[],w.save(),w.font=this._getContextFont();for(var S=0,r=am.length;r>S;++S){var o=am[S],g=this._getTextWidth(o);if(ag&&g>ad){for(;o.length>0;){for(var c=0,Z=o.length,X="",W=0;Z>c;){var V=c+Z>>>1,T=o.slice(0,V+1),v=this._getTextWidth(T);ad>=v?(c=V+1,X=T,W=v):Z=V}if(!X){break}if(U){var s=Math.max(X.lastIndexOf(D),X.lastIndexOf(L))+1;s>0&&(c=s,X=X.slice(0,c),W=this._getTextWidth(X))}if(this._addTextLine(X,W),ak=Math.max(ak,W),ab+=aj,!Y||af&&ab+aj>ac){break}if(o=o.slice(c),o.length>0&&(g=this._getTextWidth(o),ad>=g)){this._addTextLine(o,g),ab+=aj,ak=Math.max(ak,g);break}}}else{this._addTextLine(o,g),ab+=aj,ak=Math.max(ak,g)}if(af&&ab+aj>ac){break}}w.restore(),this.textHeight=al,this.textWidth=ak}},Kinetic.Util.extend(Kinetic.Text,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontFamily","Arial"),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontSize",12),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontStyle",F),Kinetic.Factory.addGetterSetter(Kinetic.Text,"fontVariant",F),Kinetic.Factory.addGetterSetter(Kinetic.Text,"padding",0),Kinetic.Factory.addGetterSetter(Kinetic.Text,"align",J),Kinetic.Factory.addGetterSetter(Kinetic.Text,"lineHeight",1),Kinetic.Factory.addGetterSetter(Kinetic.Text,"wrap",B),Kinetic.Factory.addGetter(Kinetic.Text,"text",K),Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Text,"text"),Kinetic.Collection.mapMethods(Kinetic.Text)}(),function(){Kinetic.Line=function(b){this.___init(b)},Kinetic.Line.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Line",this.on("pointsChange.kinetic tensionChange.kinetic closedChange.kinetic",function(){this._clearCache("tensionPoints")}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(j){var i,p,o,n=this.getPoints(),m=n.length,l=this.getTension(),k=this.getClosed();if(m){if(j.beginPath(),j.moveTo(n[0],n[1]),0!==l&&m>4){for(i=this.getTensionPoints(),p=i.length,o=k?0:4,k||j.quadraticCurveTo(i[0],i[1],i[2],i[3]);p-2>o;){j.bezierCurveTo(i[o++],i[o++],i[o++],i[o++],i[o++],i[o++])}k||j.quadraticCurveTo(i[p-2],i[p-1],n[m-2],n[m-1])}else{for(o=2;m>o;o+=2){j.lineTo(n[o],n[o+1])}}k?(j.closePath(),j.fillStrokeShape(this)):j.strokeShape(this)}},getTensionPoints:function(){return this._getCache("tensionPoints",this._getTensionPoints)},_getTensionPoints:function(){return this.getClosed()?this._getTensionPointsClosed():Kinetic.Util._expandPoints(this.getPoints(),this.getTension())},_getTensionPointsClosed:function(){var j=this.getPoints(),i=j.length,p=this.getTension(),o=Kinetic.Util,n=o._getControlPoints(j[i-2],j[i-1],j[0],j[1],j[2],j[3],p),m=o._getControlPoints(j[i-4],j[i-3],j[i-2],j[i-1],j[0],j[1],p),l=Kinetic.Util._expandPoints(j,p),k=[n[2],n[3]].concat(l).concat([m[0],m[1],j[i-2],j[i-1],m[2],m[3],n[0],n[1],j[0],j[1]]);return k}},Kinetic.Util.extend(Kinetic.Line,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Line,"closed",!1),Kinetic.Factory.addGetterSetter(Kinetic.Line,"tension",0),Kinetic.Factory.addGetterSetter(Kinetic.Line,"points",[]),Kinetic.Collection.mapMethods(Kinetic.Line)}(),function(){Kinetic.Sprite=function(b){this.___init(b)},Kinetic.Sprite.prototype={___init:function(d){Kinetic.Shape.call(this,d),this.className="Sprite",this._updated=!0;var c=this;this.anim=new Kinetic.Animation(function(){var b=c._updated;return c._updated=!1,b}),this.on("animationChange.kinetic",function(){this.frameIndex(0)}),this.on("frameIndexChange.kinetic",function(){this._updated=!0}),this.on("frameRateChange.kinetic",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}),this.sceneFunc(this._sceneFunc),this.hitFunc(this._hitFunc)},_sceneFunc:function(z){var y=this.getAnimation(),x=this.frameIndex(),w=4*x,v=this.getAnimations()[y],u=this.frameOffsets(),t=v[w+0],s=v[w+1],r=v[w+2],q=v[w+3],p=this.getImage();if(p){if(u){var o=u[y],n=2*x;z.drawImage(p,t,s,r,q,o[n+0],o[n+1],r,q)}else{z.drawImage(p,t,s,r,q,0,0,r,q)}}},_hitFunc:function(t){var s=this.getAnimation(),r=this.frameIndex(),q=4*r,p=this.getAnimations()[s],o=this.frameOffsets(),n=p[q+2],m=p[q+3];if(t.beginPath(),o){var l=o[s],k=2*r;t.rect(l[k+0],l[k+1],n,m)}else{t.rect(0,0,n,m)}t.closePath(),t.fillShape(this)},_useBufferCanvas:function(){return(this.hasShadow()||1!==this.getAbsoluteOpacity())&&this.hasStroke()},_setInterval:function(){var b=this;this.interval=setInterval(function(){b._updateIndex()},1000/this.getFrameRate())},start:function(){var b=this.getLayer();this.anim.setLayers(b),this._setInterval(),this.anim.start()},stop:function(){this.anim.stop(),clearInterval(this.interval)},isRunning:function(){return this.anim.isRunning()},_updateIndex:function(){var g=this.frameIndex(),f=this.getAnimation(),j=this.getAnimations(),i=j[f],h=i.length/4;this.frameIndex(h-1>g?g+1:0)}},Kinetic.Util.extend(Kinetic.Sprite,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"animation"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"animations"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameOffsets"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"image"),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameIndex",0),Kinetic.Factory.addGetterSetter(Kinetic.Sprite,"frameRate",17),Kinetic.Factory.backCompat(Kinetic.Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"}),Kinetic.Collection.mapMethods(Kinetic.Sprite)}(),function(){Kinetic.Path=function(b){this.___init(b)},Kinetic.Path.prototype={___init:function(d){this.dataArray=[];var c=this;Kinetic.Shape.call(this,d),this.className="Path",this.dataArray=Kinetic.Path.parsePathData(this.getData()),this.on("dataChange.kinetic",function(){c.dataArray=Kinetic.Path.parsePathData(this.getData())}),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(H){var G=this.dataArray,F=!1;H.beginPath();for(var E=0;Ey?z:y,s=z>y?1:z/y,r=z>y?y/z:1;H.translate(B,A),H.rotate(v),H.scale(s,r),H.arc(0,0,t,x,x+w,1-u),H.scale(1/s,1/r),H.rotate(-v),H.translate(-B,-A);break;case"z":H.closePath(),F=!0}}F?H.fillStrokeShape(this):H.strokeShape(this)}},Kinetic.Util.extend(Kinetic.Path,Kinetic.Shape),Kinetic.Path.getLineLength=function(f,e,h,g){return Math.sqrt((h-f)*(h-f)+(g-e)*(g-e))},Kinetic.Path.getPointOnLine=function(H,G,F,E,D,C,B){void 0===C&&(C=G),void 0===B&&(B=F);var A=(D-F)/(E-G+1e-8),z=Math.sqrt(H*H/(1+A*A));G>E&&(z*=-1);var y,x=A*z;if(E===G){y={x:C,y:B+x}}else{if((B-F)/(C-G+1e-8)===A){y={x:C+z,y:B+x}}else{var w,v,u=this.getLineLength(G,F,E,D);if(1e-8>u){return void 0}var t=(C-G)*(E-G)+(B-F)*(D-F);t/=u*u,w=G+t*(E-G),v=F+t*(D-F);var s=this.getLineLength(C,B,w,v),r=Math.sqrt(H*H-s*s);z=Math.sqrt(r*r/(1+A*A)),G>E&&(z*=-1),x=A*z,y={x:w+z,y:v+x}}}return y},Kinetic.Path.getPointOnCubicBezier=function(D,C,B,A,z,y,x,w,v){function u(b){return b*b*b}function t(b){return 3*b*b*(1-b)}function s(b){return 3*b*(1-b)*(1-b)}function r(b){return(1-b)*(1-b)*(1-b)}var q=w*u(D)+y*t(D)+A*s(D)+C*r(D),p=v*u(D)+x*t(D)+z*s(D)+B*r(D);return{x:q,y:p}},Kinetic.Path.getPointOnQuadraticBezier=function(x,w,v,u,t,s,r){function q(b){return b*b}function p(b){return 2*b*(1-b)}function o(b){return(1-b)*(1-b)}var n=s*q(x)+u*p(x)+w*o(x),m=r*q(x)+t*p(x)+v*o(x);return{x:n,y:m}},Kinetic.Path.getPointOnEllipticalArc=function(r,q,p,o,n,m){var l=Math.cos(m),k=Math.sin(m),j={x:p*Math.cos(n),y:o*Math.sin(n)};return{x:r+(j.x*l-j.y*k),y:q+(j.x*k+j.y*l)}},Kinetic.Path.parsePathData=function(af){if(!af){return[]}var ae=af,ad=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];ae=ae.replace(new RegExp(" ","g"),",");for(var ac=0;ac0&&""===V[0]&&V.shift();for(var U=0;U0&&!isNaN(V[0]);){var T,S,R,Q,O,M,K,J,I,H,G=null,F=[],E=Z,D=Y;switch(W){case"l":Z+=V.shift(),Y+=V.shift(),G="L",F.push(Z,Y);break;case"L":Z=V.shift(),Y=V.shift(),F.push(Z,Y);break;case"m":var P=V.shift(),N=V.shift();if(Z+=P,Y+=N,G="M",aa.length>2&&"z"===aa[aa.length-1].command){for(var L=aa.length-2;L>=0;L--){if("M"===aa[L].command){Z=aa[L].points[0]+P,Y=aa[L].points[1]+N;break}}}F.push(Z,Y),W="l";break;case"M":Z=V.shift(),Y=V.shift(),G="M",F.push(Z,Y),W="L";break;case"h":Z+=V.shift(),G="L",F.push(Z,Y);break;case"H":Z=V.shift(),G="L",F.push(Z,Y);break;case"v":Y+=V.shift(),G="L",F.push(Z,Y);break;case"V":Y=V.shift(),G="L",F.push(Z,Y);break;case"C":F.push(V.shift(),V.shift(),V.shift(),V.shift()),Z=V.shift(),Y=V.shift(),F.push(Z,Y);break;case"c":F.push(Z+V.shift(),Y+V.shift(),Z+V.shift(),Y+V.shift()),Z+=V.shift(),Y+=V.shift(),G="C",F.push(Z,Y);break;case"S":S=Z,R=Y,T=aa[aa.length-1],"C"===T.command&&(S=Z+(Z-T.points[2]),R=Y+(Y-T.points[3])),F.push(S,R,V.shift(),V.shift()),Z=V.shift(),Y=V.shift(),G="C",F.push(Z,Y);break;case"s":S=Z,R=Y,T=aa[aa.length-1],"C"===T.command&&(S=Z+(Z-T.points[2]),R=Y+(Y-T.points[3])),F.push(S,R,Z+V.shift(),Y+V.shift()),Z+=V.shift(),Y+=V.shift(),G="C",F.push(Z,Y);break;case"Q":F.push(V.shift(),V.shift()),Z=V.shift(),Y=V.shift(),F.push(Z,Y);break;case"q":F.push(Z+V.shift(),Y+V.shift()),Z+=V.shift(),Y+=V.shift(),G="Q",F.push(Z,Y);break;case"T":S=Z,R=Y,T=aa[aa.length-1],"Q"===T.command&&(S=Z+(Z-T.points[0]),R=Y+(Y-T.points[1])),Z=V.shift(),Y=V.shift(),G="Q",F.push(S,R,Z,Y);break;case"t":S=Z,R=Y,T=aa[aa.length-1],"Q"===T.command&&(S=Z+(Z-T.points[0]),R=Y+(Y-T.points[1])),Z+=V.shift(),Y+=V.shift(),G="Q",F.push(S,R,Z,Y);break;case"A":Q=V.shift(),O=V.shift(),M=V.shift(),K=V.shift(),J=V.shift(),I=Z,H=Y,Z=V.shift(),Y=V.shift(),G="A",F=this.convertEndpointToCenterParameterization(I,H,Z,Y,K,J,Q,O,M);break;case"a":Q=V.shift(),O=V.shift(),M=V.shift(),K=V.shift(),J=V.shift(),I=Z,H=Y,Z+=V.shift(),Y+=V.shift(),G="A",F=this.convertEndpointToCenterParameterization(I,H,Z,Y,K,J,Q,O,M)}aa.push({command:G||W,points:F,start:{x:E,y:D},pathLength:this.calcLength(E,D,G||W,F)})}("z"===W||"Z"===W)&&aa.push({command:"z",points:[],start:void 0,pathLength:0})}return aa},Kinetic.Path.calcLength=function(z,y,x,w){var v,u,t,s,r=Kinetic.Path;switch(x){case"L":return r.getLineLength(z,y,w[0],w[1]);case"C":for(v=0,u=r.getPointOnCubicBezier(0,z,y,w[0],w[1],w[2],w[3],w[4],w[5]),s=0.01;1>=s;s+=0.01){t=r.getPointOnCubicBezier(s,z,y,w[0],w[1],w[2],w[3],w[4],w[5]),v+=r.getLineLength(u.x,u.y,t.x,t.y),u=t}return v;case"Q":for(v=0,u=r.getPointOnQuadraticBezier(0,z,y,w[0],w[1],w[2],w[3]),s=0.01;1>=s;s+=0.01){t=r.getPointOnQuadraticBezier(s,z,y,w[0],w[1],w[2],w[3]),v+=r.getLineLength(u.x,u.y,t.x,t.y),u=t}return v;case"A":v=0;var q=w[4],p=w[5],o=w[4]+p,n=Math.PI/180;if(Math.abs(q-o)p){for(s=q-n;s>o;s-=n){t=r.getPointOnEllipticalArc(w[0],w[1],w[2],w[3],s,0),v+=r.getLineLength(u.x,u.y,t.x,t.y),u=t}}else{for(s=q+n;o>s;s+=n){t=r.getPointOnEllipticalArc(w[0],w[1],w[2],w[3],s,0),v+=r.getLineLength(u.x,u.y,t.x,t.y),u=t}}return t=r.getPointOnEllipticalArc(w[0],w[1],w[2],w[3],o,0),v+=r.getLineLength(u.x,u.y,t.x,t.y)}return 0},Kinetic.Path.convertEndpointToCenterParameterization=function(X,W,V,U,T,S,R,Q,P){var O=P*(Math.PI/180),N=Math.cos(O)*(X-V)/2+Math.sin(O)*(W-U)/2,M=-1*Math.sin(O)*(X-V)/2+Math.cos(O)*(W-U)/2,L=N*N/(R*R)+M*M/(Q*Q);L>1&&(R*=Math.sqrt(L),Q*=Math.sqrt(L));var K=Math.sqrt((R*R*Q*Q-R*R*M*M-Q*Q*N*N)/(R*R*M*M+Q*Q*N*N));T===S&&(K*=-1),isNaN(K)&&(K=0);var J=K*R*M/Q,I=K*-Q*N/R,H=(X+V)/2+Math.cos(O)*J-Math.sin(O)*I,G=(W+U)/2+Math.sin(O)*J+Math.cos(O)*I,F=function(b){return Math.sqrt(b[0]*b[0]+b[1]*b[1])},E=function(d,c){return(d[0]*c[0]+d[1]*c[1])/(F(d)*F(c))},D=function(d,c){return(d[0]*c[1]=1&&(z=0),0===S&&z>0&&(z-=2*Math.PI),1===S&&0>z&&(z+=2*Math.PI),[H,G,R,Q,C,z,O,S]},Kinetic.Factory.addGetterSetter(Kinetic.Path,"data"),Kinetic.Collection.mapMethods(Kinetic.Path)}(),function(){function f(b){b.fillText(this.partialText,0,0)}function e(b){b.strokeText(this.partialText,0,0)}var h="",g="normal";Kinetic.TextPath=function(b){this.___init(b)},Kinetic.TextPath.prototype={___init:function(b){var a=this;this.dummyCanvas=Kinetic.Util.createCanvasElement(),this.dataArray=[],Kinetic.Shape.call(this,b),this._fillFunc=f,this._strokeFunc=e,this._fillFuncHit=f,this._strokeFuncHit=e,this.className="TextPath",this.dataArray=Kinetic.Path.parsePathData(this.attrs.data),this.on("dataChange.kinetic",function(){a.dataArray=Kinetic.Path.parsePathData(this.attrs.data)}),this.on("textChange.kinetic textStroke.kinetic textStrokeWidth.kinetic",a._setTextData),a._setTextData(),this.sceneFunc(this._sceneFunc)},_sceneFunc:function(j){j.setAttr("font",this._getContextFont()),j.setAttr("textBaseline","middle"),j.setAttr("textAlign","left"),j.save();for(var i=this.glyphInfo,l=0;l0){return x=c,a[c]}"M"==a[c].command&&(B={x:a[c].points[0],y:a[c].points[1]})}return{}},u=function(I){var H=D._getTextSize(I).width,G=0,F=0;for(A=void 0;Math.abs(H-G)/H>0.01&&25>F;){F++;for(var E=G;void 0===z;){z=v(),z&&E+z.pathLengthH?A=Kinetic.Path.getPointOnLine(H,B.x,B.y,z.points[0],z.points[1],B.x,B.y):z=void 0;break;case"A":var d=z.points[4],c=z.points[5],a=z.points[4]+c;0===w?w=d+1e-8:H>G?w+=Math.PI/180*c/Math.abs(c):w-=Math.PI/360*c/Math.abs(c),(0>c&&a>w||c>=0&&w>a)&&(w=a,i=!0),A=Kinetic.Path.getPointOnEllipticalArc(z.points[0],z.points[1],z.points[2],z.points[3],w,z.points[6]);break;case"C":0===w?w=H>z.pathLength?1e-8:H/z.pathLength:H>G?w+=(H-G)/z.pathLength:w-=(G-H)/z.pathLength,w>1&&(w=1,i=!0),A=Kinetic.Path.getPointOnCubicBezier(w,z.start.x,z.start.y,z.points[0],z.points[1],z.points[2],z.points[3],z.points[4],z.points[5]);break;case"Q":0===w?w=H/z.pathLength:H>G?w+=(H-G)/z.pathLength:w-=(G-H)/z.pathLength,w>1&&(w=1,i=!0),A=Kinetic.Path.getPointOnQuadraticBezier(w,z.start.x,z.start.y,z.points[0],z.points[1],z.points[2],z.points[3])}void 0!==A&&(G=Kinetic.Path.getLineLength(B.x,B.y,A.x,A.y)),i&&(i=!1,z=void 0)}},t=0;tg;g++){l=i*Math.sin(2*g*Math.PI/j),k=-1*i*Math.cos(2*g*Math.PI/j),h.lineTo(l,k)}h.closePath(),h.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.RegularPolygon,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.RegularPolygon,"radius",0),Kinetic.Factory.addGetterSetter(Kinetic.RegularPolygon,"sides",0),Kinetic.Collection.mapMethods(Kinetic.RegularPolygon)}(),function(){Kinetic.Star=function(b){this.___init(b)},Kinetic.Star.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Star",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(j){var i=this.innerRadius(),p=this.outerRadius(),o=this.numPoints();j.beginPath(),j.moveTo(0,0-p);for(var n=1;2*o>n;n++){var m=n%2===0?p:i,l=m*Math.sin(n*Math.PI/o),k=-1*m*Math.cos(n*Math.PI/o);j.lineTo(l,k)}j.closePath(),j.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Star,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Star,"numPoints",5),Kinetic.Factory.addGetterSetter(Kinetic.Star,"innerRadius",0),Kinetic.Factory.addGetterSetter(Kinetic.Star,"outerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Star)}(),function(){var r=["fontFamily","fontSize","fontStyle","padding","lineHeight","text"],q="Change.kinetic",p="none",o="up",n="right",m="down",l="left",k="Label",j=r.length;Kinetic.Label=function(b){this.____init(b)},Kinetic.Label.prototype={____init:function(d){var c=this;Kinetic.Group.call(this,d),this.className=k,this.on("add.kinetic",function(b){c._addListeners(b.child),c._sync()})},getText:function(){return this.find("Text")[0]},getTag:function(){return this.find("Tag")[0]},_addListeners:function(h){var g,b=this,a=function(){b._sync()};for(g=0;j>g;g++){h.on(r[g]+q,a)}},getWidth:function(){return this.getText().getWidth()},getHeight:function(){return this.getText().getHeight()},_sync:function(){var w,v,u,t,s,g,f,e=this.getText(),d=this.getTag();if(e&&d){switch(w=e.getWidth(),v=e.getHeight(),u=d.getPointerDirection(),t=d.getPointerWidth(),f=d.getPointerHeight(),s=0,g=0,u){case o:s=w/2,g=-1*f;break;case n:s=w+t,g=v/2;break;case m:s=w/2,g=v+f;break;case l:s=-1*t,g=v/2}d.setAttrs({x:-1*s,y:-1*g,width:w,height:v}),e.setAttrs({x:-1*s,y:-1*g})}}},Kinetic.Util.extend(Kinetic.Label,Kinetic.Group),Kinetic.Collection.mapMethods(Kinetic.Label),Kinetic.Tag=function(b){this.___init(b)},Kinetic.Tag.prototype={___init:function(b){Kinetic.Shape.call(this,b),this.className="Tag",this.sceneFunc(this._sceneFunc)},_sceneFunc:function(e){var d=this.getWidth(),u=this.getHeight(),t=this.getPointerDirection(),s=this.getPointerWidth(),g=this.getPointerHeight(),f=this.getCornerRadius();e.beginPath(),e.moveTo(0,0),t===o&&(e.lineTo((d-s)/2,0),e.lineTo(d/2,-1*g),e.lineTo((d+s)/2,0)),f?(e.lineTo(d-f,0),e.arc(d-f,f,f,3*Math.PI/2,0,!1)):e.lineTo(d,0),t===n&&(e.lineTo(d,(u-g)/2),e.lineTo(d+s,u/2),e.lineTo(d,(u+g)/2)),f?(e.lineTo(d,u-f),e.arc(d-f,u-f,f,0,Math.PI/2,!1)):e.lineTo(d,u),t===m&&(e.lineTo((d+s)/2,u),e.lineTo(d/2,u+g),e.lineTo((d-s)/2,u)),f?(e.lineTo(f,u),e.arc(f,u-f,f,Math.PI/2,Math.PI,!1)):e.lineTo(0,u),t===l&&(e.lineTo(0,(u+g)/2),e.lineTo(-1*s,u/2),e.lineTo(0,(u-g)/2)),f&&(e.lineTo(0,f),e.arc(f,f,f,Math.PI,3*Math.PI/2,!1)),e.closePath(),e.fillStrokeShape(this)}},Kinetic.Util.extend(Kinetic.Tag,Kinetic.Shape),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerDirection",p),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerWidth",0),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"pointerHeight",0),Kinetic.Factory.addGetterSetter(Kinetic.Tag,"cornerRadius",0),Kinetic.Collection.mapMethods(Kinetic.Tag)}(),function(){Kinetic.Arrow=function(b){this.____init(b)},Kinetic.Arrow.prototype={____init:function(b){Kinetic.Line.call(this,b),this.className="Arrow"},_sceneFunc:function(r){var q=2*Math.PI,p=this.points(),o=p.length,n=p[o-2]-p[o-4],m=p[o-1]-p[o-3],l=(Math.atan2(m,n)+q)%q,k=this.pointerLength(),j=this.pointerWidth();r.save(),r.beginPath(),r.translate(p[o-2],p[o-1]),r.rotate(l),r.moveTo(0,0),r.lineTo(-k,j/2),r.lineTo(-k,-j/2),r.closePath(),r.restore(),this.pointerAtBeginning()&&(r.save(),r.translate(p[0],p[1]),n=p[2]-p[0],m=p[3]-p[1],r.rotate((Math.atan2(-m,-n)+q)%q),r.moveTo(0,0),r.lineTo(-10,6),r.lineTo(-10,-6),r.closePath(),r.restore()),r.fillStrokeShape(this),Kinetic.Line.prototype._sceneFunc.apply(this,arguments)}},Kinetic.Util.extend(Kinetic.Arrow,Kinetic.Line),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerLength",10),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerWidth",10),Kinetic.Factory.addGetterSetter(Kinetic.Arrow,"pointerAtBeginning",!1),Kinetic.Collection.mapMethods(Kinetic.Arrow)}();(function(a){"function"===typeof define&&define.amd?define(["jquery"],a):"undefined"!==typeof module&&module.exports?module.exports=a(require("jquery")):a(jQuery)})(function(b){function d(e){return !e.nodeName||-1!==b.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])}function a(e){return b.isFunction(e)||b.isPlainObject(e)?e:{top:e,left:e}}var c=b.scrollTo=function(f,g,e){return b(window).scrollTo(f,g,e)};c.defaults={axis:"xy",duration:0,limit:!0};b.fn.scrollTo=function(f,h,e){"object"===typeof h&&(e=h,h=0);"function"===typeof e&&(e={onAfter:e});"max"===f&&(f=9000000000);e=b.extend({},c.defaults,e);h=h||e.duration;var g=e.queue&&1=p[r]?0:Math.min(p[r],v));!l&&1