vard=c&&"left"===c?"scrollLeft":"scrollTop",e=!1;returnb[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)}})}(jQuery),function(a,b){varc=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(varc,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(b,c,d){vare,f,g,h,i={},j=b.split(".")[0];b=b.split(".")[1],e=j+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][e.toLowerCase()]=function(b){return!!a.data(b,e)},a[j]=a[j]||{},f=a[j][b],g=a[j][b]=function(a,b){returnthis._createWidget?(arguments.length&&this._createWidget(a,b),void0):newg(a,b)},a.extend(g,f,{version:d.version,_proto:a.extend({},d),_childConstructors:[]}),h=newc,h.options=a.widget.extend({},h.options),a.each(d,function(b,d){returna.isFunction(d)?(i[b]=function(){vara=function(){returnc.prototype[b].apply(this,arguments)},e=function(a){returnc.prototype[b].apply(this,a)};returnfunction(){varb,c=this._super,f=this._superApply;returnthis._super=a,this._superApply=e,b=d.apply(this,arguments),this._super=c,this._superApply=f,b}}(),void0):(i[b]=d,void0)}),g.prototype=a.widget.extend(h,{widgetEventPrefix:f?h.widgetEventPrefix:b},i,{constructor:g,namespace:j,widgetName:b,widgetFullName:e}),f?(a.each(f._childConstructors,function(b,c){vard=c.prototype;a.widget(d.namespace+"."+d.widgetName,g,c._proto)}),deletef._childConstructors):c._childConstructors.push(g),a.widget.bridge(b,g)},a.widget.extend=function(c){for(vare,f,g=d.call(arguments,1),h=0,i=g.length;i>h;h++)for(eing[h])f=g[h][e],g[h].hasOwnProperty(e)&&f!==b&&(c[e]=a.isPlainObject(f)?a.isPlainObject(c[e])?a.widget.extend({},c[e],f):a.widget.extend({},f):f);returnc},a.widget.bridge=function(c,e){varf=e.prototype.widgetFullName||c;a.fn[c]=function(g){varh="string"==typeofg,i=d.call(arguments,1),j=this;returng=!h&&i.length?a.widget.extend.apply(null,[g].concat(i)):g,h?this.each(function(){vard,e=a.data(this,f);returne?a.isFunction(e[g])&&"_"!==g.charAt(0)?(d=e[g].apply(e,i),d!==e&&d!==b?(j=d&&d.jquery?j.pushStack(d.get()):d,!1):void0):a.error("no such method '"+g+"' for "+c+" widget instance"):a.error("cannot call methods on "+c+" prior to initialization; "+"attempted to call method '"+g+"'")}):this.each(function(){varb=a.data(this,f);b?b.option(g||{})._init():a.data(this,f,newe(g,this))}),j}},a.Widget=function(){},a.Widget._childConstructors=[],a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(b,d){d=a(d||this.defaultElement||this)[0],this.element=a(d),this.uuid=c++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=a.widget.extend({},this.options,this._getCreateOptions(),b),this.bindings=a(),this.hoverable=a(),this.focusable=a(),d!==this&&(a.data(d,this.widgetFullName,this),this._on(!0,this.element,{remove:function(a){a.target===d&&this.destroy()}}),this.document=a(d.style?d.ownerDocument:d.document||d),this.window=a(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:a.noop,_getCreateEventData:a.noop,_create:a.noop,_init:a.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(a.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:a.noop,widget:function(){returnthis.element},option:function(c,d){vare,f,g,h=c;if(0===arguments.length)returna.widget.extend({},this.options);if("string"==typeofc)if(h={},e=c.split("."),c=e.shift(),e.length){for(f=h[c]=a.widget.extend({},this.options[c]),g=0;g<e.length-1;g++)f[e[g]]=f[e[g]]||{},f=f[e[g]];if(c=e.pop(),d===b)returnf[c]===b?null:f[c];f[c]=d}else{if(d===b)returnthis.options[c]===b?null:this.options[c];h[c]=d}returnthis._setOptions(h),this},_setOption
}}.call(this,this.containers[c])),this.containers[c].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!b){for(this._trigger("beforeStop",a,this._uiHash()),c=0;c<d.length;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}returnthis.fromOutside=!1,!1}if(b||this._trigger("beforeStop",a,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!b){for(c=0;c<d.length;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}returnthis.fromOutside=!1,!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){varc=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}})}(jQuery),function(a){varb=a({});a.subscribe=function(){b.on.apply(b,arguments)},a.unsubscribe=function(){b.off.apply(b,arguments)},a.publish=function(){b.trigger.apply(b,arguments)}}(jQuery),!function(a){"use strict";varb=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){vare,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,"click"==this.options.trigger?this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this)):"manual"!=this.options.trigger&&(e="hover"==this.options.trigger?"mouseenter":"focus",f="hover"==this.options.trigger?"mouseleave":"blur",this.$element.on(e+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f+"."+this.type,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){returnb=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&"number"==typeofb.delay&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){varc=a(b.currentTarget)[this.type](this._options).data(this.type);returnc.options.delay&&c.options.delay.show?(clearTimeout(this.timeout),c.hoverState="in",this.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show),void0):c.show()},leave:function(b){varc=a(b.currentTarget)[this.type](this._options).data(this.type);returnthis.timeout&&clearTimeout(this.timeout),c.options.delay&&c.options.delay.hide?(c.hoverState="out",this.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide),void0):c.hide()},show:function(){vara,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){switch(a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f="function"==typeofthis.options.placement?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight,b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){vara=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){functionb(){varb=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}varc=this.tip();returnc.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?b():c.remove(),this},fixTitle:function(){vara=this.$element;(a.attr("title"
},a.PiskelController.prototype.getFrameByIndex=a.PiskelController.prototype.getMergedFrameAt,a.PiskelController.prototype.addEmptyFrame=function(){vara=this.getLayers();a.forEach(function(a){a.addFrame(this.createEmptyFrame_())}.bind(this))},a.PiskelController.prototype.createEmptyFrame_=function(){vara=this.piskel.getWidth(),b=this.piskel.getHeight();returnnewpskl.model.Frame(a,b)},a.PiskelController.prototype.removeFrameAt=function(a){varb=this.getLayers();b.forEach(function(b){b.removeFrameAt(a)}),this.currentFrameIndex>=a&&this.setCurrentFrameIndex(this.currentFrameIndex-1),$.publish(Events.PISKEL_RESET)},a.PiskelController.prototype.duplicateFrameAt=function(a){varb=this.getLayers();b.forEach(function(b){b.duplicateFrameAt(a)})},a.PiskelController.prototype.moveFrame=function(a,b){varc=this.getLayers();c.forEach(function(c){c.moveFrame(a,b)})},a.PiskelController.prototype.getFrameCount=function(){vara=this.piskel.getLayerAt(0);returna.length()},a.PiskelController.prototype.setCurrentFrameIndex=function(a){this.currentFrameIndex=a,$.publish(Events.PISKEL_RESET)},a.PiskelController.prototype.setCurrentLayerIndex=function(a){this.currentLayerIndex=a,$.publish(Events.PISKEL_RESET)},a.PiskelController.prototype.selectLayer=function(a){varb=this.getLayers().indexOf(a);-1!=b&&this.setCurrentLayerIndex(b)},a.PiskelController.prototype.selectLayerByName=function(a){if(this.hasLayerForName_(a)){varb=this.piskel.getLayersByName(a)[0];this.selectLayer(b)}},a.PiskelController.prototype.generateLayerName_=function(){for(vara="Layer "+this.layerIdCounter;this.hasLayerForName_(a);)this.layerIdCounter++,a="Layer "+this.layerIdCounter;returna},a.PiskelController.prototype.createLayer=function(a){if(a||(a=this.generateLayerName_()),this.hasLayerForName_(a))throw"Layer name should be unique";for(varb=newpskl.model.Layer(a),c=0;c<this.getFrameCount();c++)b.addFrame(this.createEmptyFrame_());this.piskel.addLayer(b),this.setCurrentLayerIndex(this.piskel.getLayers().length-1)},a.PiskelController.prototype.hasLayerForName_=function(a){returnthis.piskel.getLayersByName(a).length>0},a.PiskelController.prototype.moveLayerUp=function(){vara=this.getCurrentLayer();this.piskel.moveLayerUp(a),this.selectLayer(a)},a.PiskelController.prototype.moveLayerDown=function(){vara=this.getCurrentLayer();this.piskel.moveLayerDown(a),this.selectLayer(a)},a.PiskelController.prototype.removeCurrentLayer=function(){if(this.getLayers().length>1){vara=this.getCurrentLayer();this.piskel.removeLayer(a),this.setCurrentLayerIndex(0)}},a.PiskelController.prototype.serialize=function(){returnpskl.utils.Serializer.serializePiskel(this.piskel)},a.PiskelController.prototype.load=function(a){this.deserialize(JSON.stringify(a))}}(),function(){vara=$.namespace("pskl.controller");a.DrawingController=function(a,b){this.piskelController=a,this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(a.getCurrentFrame()),this.container=b,this.zoom=this.calculateZoom_(),this.xOffset=0,this.yOffset=0;varc={zoom:this.zoom,supportGridRendering:!0,height:this.getContainerHeight_(),width:this.getContainerWidth_(),xOffset:this.xOffset,yOffset:this.yOffset};this.overlayRenderer=newpskl.rendering.FrameRenderer(this.container,c,["canvas-overlay"]),this.renderer=newpskl.rendering.FrameRenderer(this.container,c,["drawing-canvas"]),this.layersBelowRenderer=newpskl.rendering.FrameRenderer(this.container,c,["layers-canvas","layers-below-canvas"]),this.layersAboveRenderer=newpskl.rendering.FrameRenderer(this.container,c,["layers-canvas","layers-above-canvas"]),this.isClicked=!1,this.isRightClicked=!1,this.previousMousemoveTime=0,this.currentToolBehavior=null,this.primaryColor=Constants.DEFAULT_PEN_COLOR,this.secondaryColor=Constants.TRANSPARENT_COLOR},a.DrawingController.prototype.init=function(){this.initMouseBehavior(),$.subscribe(Events.TOOL_SELECTED,$.proxy(function(a,b){console.log("Tool selected: ",b),this.currentToolBehavior=b,this.overlayFrame.clear()},this)),$.subscribe(Events.PRIMARY_COLOR_SELECTED,$.proxy(function(a,b){console.log("Primary color selected: ",b),thi