From d711698c55daa5e9c4f1ea12641ceae2063037be Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Mon, 14 Sep 2015 10:06:46 +0200 Subject: [PATCH] gh-pages : preview v0.5.5 --- js/lib/gif/gif.ie.worker.js | 2 +- js/piskel-packaged-min.js | 24 +++++++++--------- piskel-boot.js | 4 +-- piskelapp-partials/main-partial.html | 38 ++++++++++++++-------------- templates/cheatsheet.html | 8 +++--- templates/dialogs/import-image.html | 34 ++++++++++++++++++++----- templates/drawing-tools.html | 2 +- templates/popup-preview.html | 4 +-- templates/preview.html | 6 ++++- templates/settings/application.html | 18 +++++++++---- templates/settings/export.html | 10 ++++++-- templates/settings/resize.html | 4 +-- 12 files changed, 98 insertions(+), 56 deletions(-) diff --git a/js/lib/gif/gif.ie.worker.js b/js/lib/gif/gif.ie.worker.js index 675f9d5e..b6150c93 100644 --- a/js/lib/gif/gif.ie.worker.js +++ b/js/lib/gif/gif.ie.worker.js @@ -1 +1 @@ -(function(b){function a(b,d){if({}.hasOwnProperty.call(a.cache,b))return a.cache[b];var e=a.resolve(b);if(!e)throw new Error('Failed to resolve module '+b);var c={id:b,require:a,filename:b,exports:{},loaded:!1,parent:d,children:[]};d&&d.children.push(c);var f=b.slice(0,b.lastIndexOf('/')+1);return a.cache[b]=c.exports,e.call(c.exports,c,c.exports,f,b),c.loaded=!0,a.cache[b]=c.exports}a.modules={},a.cache={},a.resolve=function(b){return{}.hasOwnProperty.call(a.modules,b)?a.modules[b]:void 0},a.define=function(b,c){a.modules[b]=c},a.define('/gif.worker.coffee',function(d,e,f,g){var b,c;b=a('/GIFEncoder.js',d),c=function(a){var c,e,d,f;return c=new b(a.width,a.height),a.index===0?c.writeHeader():c.firstFrame=!1,c.setTransparent(a.transparent),c.setRepeat(a.repeat),c.setDelay(a.delay),c.setQuality(a.quality),c.setPreserveColors(a.preserveColors),c.addFrame(a.data),a.last&&c.finish(),d=c.stream(),a.data=d.pages,a.cursor=d.cursor,a.pageSize=d.constructor.pageSize,a.canTransfer?(f=function(c){for(var b=0,d=a.data.length;b=c.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=a},c.prototype.writeUTFBytes=function(b){for(var c=b.length,a=0;a=0&&(this.dispose=a)},b.prototype.setRepeat=function(a){this.repeat=a},b.prototype.setTransparent=function(a){this.transparent=a},b.prototype.addFrame=function(a){this.image=a,this.getImagePixels(),this.analyzePixels(),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.writePixels(),this.firstFrame=!1},b.prototype.finish=function(){this.out.writeByte(59)},b.prototype.setQuality=function(a){a<1&&(a=1),this.sample=a},b.prototype.setPreserveColors=function(a){this.preserveColors=a},b.prototype.writeHeader=function(){this.out.writeUTFBytes('GIF89a')},b.prototype.analyzePixels=function(){var h=this.pixels.length,d=h/3;this.indexedPixels=new Uint8Array(d);var a;this.preserveColors?a=new g(this.pixels,this.sample):a=new f(this.pixels,this.sample),a.buildColormap(),this.colorTab=a.getColormap();var b=0;for(var c=0;c>16,l=(e&65280)>>8,m=e&255,c=0,d=16777216,j=this.colorTab.length;for(var a=0;a=0&&(a=dispose&7),a<<=2,this.out.writeByte(0|a|0|b),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},b.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},b.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},b.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes('NETSCAPE2.0'),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},b.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var b=768-this.colorTab.length;for(var a=0;a>8&255)},b.prototype.writePixels=function(){var a=new h(this.width,this.height,this.indexedPixels,this.colorDepth);a.encode(this.out)},b.prototype.stream=function(){return this.out},e.exports=b}),a.define('/LZWEncoder.js',function(e,g,h,i){function f(y,D,C,B){function w(a,b){r[f++]=a,f>=254&&t(b)}function x(b){u(a),k=i+2,j=!0,l(i,b)}function u(b){for(var a=0;a=0){y=w-d,d===0&&(y=1);do if((d-=y)<0&&(d+=w),h[d]===g){e=n[d];continue a}while(h[d]>=0)}l(e,r),e=t,k<1<0&&(a.writeByte(f),a.writeBytes(r,0,f),f=0)}function p(a){return(1<0?g|=a<=8)w(g&255,c),g>>=8,e-=8;if((k>m||j)&&(j?(m=p(n_bits=q),j=!1):(++n_bits,n_bits==b?m=1<0)w(g&255,c),g>>=8,e-=8;t(c)}}var s=Math.max(2,B),r=new Uint8Array(256),h=new Int32Array(a),n=new Int32Array(a),g,e=0,f,k=0,m,j=!1,q,i,o;this.encode=z}var c=-1,b=12,a=5003,d=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=f}),a.define('/SimpleQuant.js',function(b,d,e,f){function a(a,b,c){return[a,b,c].join('.')}function c(b){this.pixels=b,this.palette=[],this.paletteIndex={},this.getColormap=function(){return this.palette},this.buildColormap=function(){var h=this.pixels.length/3,b=0;for(var c=0;c>3);var c,d;for(c=0;c>=b,o[c][1]>>=b,o[c][2]>>=b,o[c][3]=c}function K(b,a,c,e,f){o[a][0]-=b*(o[a][0]-c)/d,o[a][1]-=b*(o[a][1]-e)/d,o[a][2]-=b*(o[a][2]-f)/d}function L(j,e,n,l,k){var h=Math.abs(e-j),i=Math.min(e+j,a),g=e+1,f=e-1,m=1,b,d;while(gh)d=z[m++],gh&&(b=o[f--],b[0]-=d*(b[0]-n)/c,b[1]-=d*(b[1]-l)/c,b[2]-=d*(b[2]-k)/c)}function C(p,s,q){var h=2147483647,k=h,d=-1,m=d,c,j,e,n,l;for(c=0;c>i-b),n>g,y[c]-=l,t[c]+=l<>1,b=f+1;b>1,b=f+1;b<256;b++)q[b]=n}function E(j,i,k){var b,d,c,e=1e3,h=-1,f=q[i],g=f-1;while(f=0)f=e?f=a:(f++,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c=0&&(d=o[g],c=i-d[1],c>=e?g=-1:(g--,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c>h;for(a<=1&&(a=0),c=0;c=f&&(g-=f),c++,q===0&&(q=1),c%q===0)for(n-=n/D,o-=o/v,a=o>>h,a<=1&&(a=0),e=0;e>g,r=e<>3,h=6,t=1<=c.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=a},c.prototype.writeUTFBytes=function(b){for(var c=b.length,a=0;a=0&&(this.dispose=a)},b.prototype.setRepeat=function(a){this.repeat=a},b.prototype.setTransparent=function(a){this.transparent=a},b.prototype.setPreserveColors=function(a){this.preserveColors=a},b.prototype.addFrame=function(a){this.image=a,this.getImagePixels(),this.analyzePixels(),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.writePixels(),this.firstFrame=!1},b.prototype.finish=function(){this.out.writeByte(59)},b.prototype.setQuality=function(a){a<1&&(a=1),this.sample=a},b.prototype.writeHeader=function(){this.out.writeUTFBytes('GIF89a')},b.prototype.analyzePixels=function(){var h=this.pixels.length,d=h/3;this.indexedPixels=new Uint8Array(d);var a;if(this.preserveColors){var i=this.toRGBComponents(this.transparent);a=new g(this.pixels,this.sample,i)}else a=new f(this.pixels,this.sample);a.buildColormap(),this.colorTab=a.getColormap();var b=0;for(var c=0;c>16,g:(a&65280)>>8,b:a&255}),b},b.prototype.findClosest=function(e){if(this.colorTab===null)return-1;var k=(e&16711680)>>16,l=(e&65280)>>8,m=e&255,c=0,d=16777216,j=this.colorTab.length;for(var a=0;a=0&&(a=dispose&7),a<<=2,this.out.writeByte(0|a|0|b),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},b.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},b.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},b.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes('NETSCAPE2.0'),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},b.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var b=768-this.colorTab.length;for(var a=0;a>8&255)},b.prototype.writePixels=function(){var a=new h(this.width,this.height,this.indexedPixels,this.colorDepth);a.encode(this.out)},b.prototype.stream=function(){return this.out},e.exports=b}),a.define('/LZWEncoder.js',function(e,g,h,i){function f(y,D,C,B){function w(a,b){r[f++]=a,f>=254&&t(b)}function x(b){u(a),k=i+2,j=!0,l(i,b)}function u(b){for(var a=0;a=0){y=w-d,d===0&&(y=1);do if((d-=y)<0&&(d+=w),h[d]===g){e=n[d];continue a}while(h[d]>=0)}l(e,r),e=t,k<1<0&&(a.writeByte(f),a.writeBytes(r,0,f),f=0)}function p(a){return(1<0?g|=a<=8)w(g&255,c),g>>=8,e-=8;if((k>m||j)&&(j?(m=p(n_bits=q),j=!1):(++n_bits,n_bits==b?m=1<0)w(g&255,c),g>>=8,e-=8;t(c)}}var s=Math.max(2,B),r=new Uint8Array(256),h=new Int32Array(a),n=new Int32Array(a),g,e=0,f,k=0,m,j=!1,q,i,o;this.encode=z}var c=-1,b=12,a=5003,d=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=f}),a.define('/SimpleQuant.js',function(b,d,e,f){function a(a,b,c){return[a,b,c].join('.')}function c(c,d,b){this.pixels=c,this.palette=[],this.paletteIndex={},this.getColormap=function(){return this.palette},this.buildColormap=function(){var d=this.pixels.length/3,a=0;for(var c=0;c>3);var c,d;for(c=0;c>=b,o[c][1]>>=b,o[c][2]>>=b,o[c][3]=c}function K(b,a,c,e,f){o[a][0]-=b*(o[a][0]-c)/d,o[a][1]-=b*(o[a][1]-e)/d,o[a][2]-=b*(o[a][2]-f)/d}function L(j,e,n,l,k){var h=Math.abs(e-j),i=Math.min(e+j,a),g=e+1,f=e-1,m=1,b,d;while(gh)d=z[m++],gh&&(b=o[f--],b[0]-=d*(b[0]-n)/c,b[1]-=d*(b[1]-l)/c,b[2]-=d*(b[2]-k)/c)}function C(p,s,q){var h=2147483647,k=h,d=-1,m=d,c,j,e,n,l;for(c=0;c>i-b),n>g,y[c]-=l,t[c]+=l<>1,b=f+1;b>1,b=f+1;b<256;b++)q[b]=n}function E(j,i,k){var b,d,c,e=1e3,h=-1,f=q[i],g=f-1;while(f=0)f=e?f=a:(f++,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c=0&&(d=o[g],c=i-d[1],c>=e?g=-1:(g--,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c>h;for(a<=1&&(a=0),c=0;c=f&&(g-=f),c++,q===0&&(q=1),c%q===0)for(n-=n/D,o-=o/v,a=o>>h,a<=1&&(a=0),e=0;e>g,r=e<>3,h=6,t=1<",""]),$.fn.extend({text:function(a){return $.access(this,function(a){return a===b?$.text(this):this.empty().append((this[0]&&this[0].ownerDocument||P).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if($.isFunction(a))return this.each(function(b){$(this).wrapAll(a.call(this,b))});if(this[0]){var b=$(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return this.each($.isFunction(a)?function(b){$(this).wrapInner(a.call(this,b))}:function(){var b=$(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=$.isFunction(a);return this.each(function(c){$(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){$.nodeName(this,"body")||$(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(1===this.nodeType||11===this.nodeType)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(1===this.nodeType||11===this.nodeType)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=$.clean(arguments);return this.pushStack($.merge(a,this),"before",this.selector)}},after:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=$.clean(arguments);return this.pushStack($.merge(this,a),"after",this.selector)}},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||$.filter(a,[c]).length)&&(b||1!==c.nodeType||($.cleanData(c.getElementsByTagName("*")),$.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)for(1===a.nodeType&&$.cleanData(a.getElementsByTagName("*"));a.firstChild;)a.removeChild(a.firstChild);return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return $.clone(this,a,b)})},html:function(a){return $.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Oa,""):b;if(!("string"!=typeof a||Ua.test(a)||!$.support.htmlSerialize&&Wa.test(a)||!$.support.leadingWhitespace&&Pa.test(a)||_a[(Ra.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(Qa,"<$1>");try{for(;e>d;d++)c=this[d]||{},1===c.nodeType&&($.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(f){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){return h(this[0])?this.length?this.pushStack($($.isFunction(a)?a():a),"replaceWith",a):this:$.isFunction(a)?this.each(function(b){var c=$(this),d=c.html();c.replaceWith(a.call(this,b,d))}):("string"!=typeof a&&(a=$(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;$(this).remove(),b?$(b).before(a):$(c).append(a)}))},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){a=[].concat.apply([],a);var e,f,g,h,i=0,j=a[0],k=[],m=this.length;if(!$.support.checkClone&&m>1&&"string"==typeof j&&Ya.test(j))return this.each(function(){$(this).domManip(a,c,d)});if($.isFunction(j))return this.each(function(e){var f=$(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){if(e=$.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,1===g.childNodes.length&&(g=f),f)for(c=c&&$.nodeName(f,"tr"),h=e.cacheable||m-1;m>i;i++)d.call(c&&$.nodeName(this[i],"table")?l(this[i],"tbody"):this[i],i===h?g:$.clone(g,!0,!0));g=f=null,k.length&&$.each(k,function(a,b){b.src?$.ajax?$.ajax({url:b.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):$.error("no ajax"):$.globalEval((b.text||b.textContent||b.innerHTML||"").replace($a,"")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),$.buildFragment=function(a,c,d){var e,f,g,h=a[0];return c=c||P,c=(c[0]||c).ownerDocument||c[0]||c,"undefined"==typeof c.createDocumentFragment&&(c=P),!(1===a.length&&"string"==typeof h&&h.length<512&&c===P&&"<"===h.charAt(0))||Va.test(h)||!$.support.checkClone&&Ya.test(h)||!$.support.html5Clone&&Wa.test(h)||(f=!0,e=$.fragments[h],g=e!==b),e||(e=c.createDocumentFragment(),$.clean(a,c,e,d),f&&($.fragments[h]=g&&e)),{fragment:e,cacheable:f}},$.fragments={},$.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){$.fn[a]=function(c){var d,e=0,f=[],g=$(c),h=g.length,i=1===this.length&&this[0].parentNode;if((null==i||i&&11===i.nodeType&&1===i.childNodes.length)&&1===h)return g[b](this[0]),this;for(;h>e;e++)d=(e>0?this.clone(!0):this).get(),$(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),$.extend({clone:function(a,b,c){var d,e,f,g;if($.support.html5Clone||$.isXMLDoc(a)||!Wa.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bb.innerHTML=a.outerHTML,bb.removeChild(g=bb.firstChild)),!($.support.noCloneEvent&&$.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||$.isXMLDoc(a)))for(n(a,g),d=o(a),e=o(g),f=0;d[f];++f)e[f]&&n(d[f],e[f]);if(b&&(m(a,g),c))for(d=o(a),e=o(g),f=0;d[f];++f)m(d[f],e[f]);return d=e=null,g},clean:function(a,b,c,d){var e,f,g,h,i,j,l,m,n,o,q,r=0,s=[];for(b&&"undefined"!=typeof b.createDocumentFragment||(b=P),f=b===P&&ab;null!=(g=a[r]);r++)if("number"==typeof g&&(g+=""),g){if("string"==typeof g)if(Ta.test(g)){for(f=f||k(b),l=l||f.appendChild(b.createElement("div")),g=g.replace(Qa,"<$1>"),h=(Ra.exec(g)||["",""])[1].toLowerCase(),i=_a[h]||_a._default,j=i[0],l.innerHTML=i[1]+g+i[2];j--;)l=l.lastChild;if(!$.support.tbody)for(m=Sa.test(g),n="table"!==h||m?""!==i[1]||m?[]:l.childNodes:l.firstChild&&l.firstChild.childNodes,e=n.length-1;e>=0;--e)$.nodeName(n[e],"tbody")&&!n[e].childNodes.length&&n[e].parentNode.removeChild(n[e]);!$.support.leadingWhitespace&&Pa.test(g)&&l.insertBefore(b.createTextNode(Pa.exec(g)[0]),l.firstChild),g=l.childNodes,l=f.lastChild}else g=b.createTextNode(g);g.nodeType?s.push(g):s=$.merge(s,g)}if(l&&(f.removeChild(l),g=l=f=null),!$.support.appendChecked)for(r=0;null!=(g=s[r]);r++)$.nodeName(g,"input")?p(g):"undefined"!=typeof g.getElementsByTagName&&$.grep(g.getElementsByTagName("input"),p);if(c)for(o=function(a){return!a.type||Za.test(a.type)?d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a):void 0},r=0;null!=(g=s[r]);r++)$.nodeName(g,"script")&&o(g)||(c.appendChild(g),"undefined"!=typeof g.getElementsByTagName&&(q=$.grep($.merge([],g.getElementsByTagName("script")),o),s.splice.apply(s,[r+1,0].concat(q)),r+=q.length));return s},cleanData:function(a,b){for(var c,d,e,f,g=0,h=$.expando,i=$.cache,j=$.support.deleteExpando,k=$.event.special;null!=(e=a[g]);g++)if((b||$.acceptData(e))&&(d=e[h],c=d&&i[d])){if(c.events)for(f in c.events)k[f]?$.event.remove(e,f):$.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,$.deletedIds.push(d))}}}),function(){var a,b;$.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=$.uaMatch(R.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.webkit&&(b.safari=!0),$.browser=b,$.sub=function(){function a(b,c){return new a.fn.init(b,c)}$.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(c,d){return d&&d instanceof $&&!(d instanceof a)&&(d=a(d)),$.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(P);return a}}();var cb,db,eb,fb=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/^(top|right|bottom|left)$/,ib=/^margin/,jb=new RegExp("^("+_+")(.*)$","i"),kb=new RegExp("^("+_+")(?!px)[a-z%]+$","i"),lb=new RegExp("^([-+])=("+_+")","i"),mb={},nb={position:"absolute",visibility:"hidden",display:"block"},ob={letterSpacing:0,fontWeight:400,lineHeight:1},pb=["Top","Right","Bottom","Left"],qb=["Webkit","O","Moz","ms"],rb=$.fn.toggle;$.fn.extend({css:function(a,c){return $.access(this,function(a,c,d){return d!==b?$.style(a,c,d):$.css(a,c)},a,c,arguments.length>1)},show:function(){return s(this,!0)},hide:function(){return s(this)},toggle:function(a,b){var c="boolean"==typeof a;return $.isFunction(a)&&$.isFunction(b)?rb.apply(this,arguments):this.each(function(){(c?a:r(this))?$(this).show():$(this).hide()})}}),$.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=cb(a,"opacity");return""===c?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":$.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=$.camelCase(c),j=a.style;if(c=$.cssProps[i]||($.cssProps[i]=q(j,i)),h=$.cssHooks[c]||$.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=lb.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat($.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||$.cssNumber[i]||(d+="px"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=$.camelCase(c);return c=$.cssProps[i]||($.cssProps[i]=q(a.style,i)),h=$.cssHooks[c]||$.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=cb(a,c)),"normal"===f&&c in ob&&(f=ob[c]),d||e!==b?(g=parseFloat(f),d||$.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?cb=function(a,b){var c,d,e,f,g=getComputedStyle(a,null),h=a.style;return g&&(c=g[b],""!==c||$.contains(a.ownerDocument.documentElement,a)||(c=$.style(a,b)),kb.test(c)&&ib.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=c,c=g.width,h.width=d,h.minWidth=e,h.maxWidth=f)),c}:P.documentElement.currentStyle&&(cb=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return null==e&&f&&f[b]&&(e=f[b]),kb.test(e)&&!hb.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left="fontSize"===b?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),""===e?"auto":e}),$.each(["height","width"],function(a,b){$.cssHooks[b]={get:function(a,c,d){return c?0!==a.offsetWidth||"none"!==cb(a,"display")?v(a,b,d):$.swap(a,nb,function(){return v(a,b,d)}):void 0},set:function(a,c,d){return t(a,c,d?u(a,b,d,$.support.boxSizing&&"border-box"===$.css(a,"boxSizing")):0)}}}),$.support.opacity||($.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=$.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,b>=1&&""===$.trim(f.replace(fb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),d&&!d.filter)||(c.filter=fb.test(f)?f.replace(fb,e):f+" "+e)}}),$(function(){$.support.reliableMarginRight||($.cssHooks.marginRight={get:function(a,b){return $.swap(a,{display:"inline-block"},function(){return b?cb(a,"marginRight"):void 0})}}),!$.support.pixelPosition&&$.fn.position&&$.each(["top","left"],function(a,b){$.cssHooks[b]={get:function(a,c){if(c){var d=cb(a,b);return kb.test(d)?$(a).position()[b]+"px":d}}}})}),$.expr&&$.expr.filters&&($.expr.filters.hidden=function(a){return 0===a.offsetWidth&&0===a.offsetHeight||!$.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||cb(a,"display"))},$.expr.filters.visible=function(a){return!$.expr.filters.hidden(a)}),$.each({margin:"",padding:"",border:"Width"},function(a,b){$.cssHooks[a+b]={expand:function(c){var d,e="string"==typeof c?c.split(" "):[c],f={};for(d=0;4>d;d++)f[a+pb[d]+b]=e[d]||e[d-2]||e[0];return f}},ib.test(a)||($.cssHooks[a+b].set=t)});var sb=/%20/g,tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,wb=/^(?:select|textarea)/i;$.fn.extend({serialize:function(){return $.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?$.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||wb.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){var c=$(this).val();return null==c?null:$.isArray(c)?$.map(c,function(a,c){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}}),$.param=function(a,c){var d,e=[],f=function(a,b){b=$.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=$.ajaxSettings&&$.ajaxSettings.traditional),$.isArray(a)||a.jquery&&!$.isPlainObject(a))$.each(a,function(){f(this.name,this.value)});else for(d in a)x(d,a[d],c,f);return e.join("&").replace(sb,"+")};var xb,yb,zb=/#.*$/,Ab=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Bb=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,Cb=/^(?:GET|HEAD)$/,Db=/^\/\//,Eb=/\?/,Fb=/)<[^<]*)*<\/script>/gi,Gb=/([?&])_=[^&]*/,Hb=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Ib=$.fn.load,Jb={},Kb={},Lb=["*/"]+["*"];try{xb=Q.href}catch(Mb){xb=P.createElement("a"),xb.href="",xb=xb.href}yb=Hb.exec(xb.toLowerCase())||[],$.fn.load=function(a,c,d){if("string"!=typeof a&&Ib)return Ib.apply(this,arguments);if(!this.length)return this;var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),$.isFunction(c)?(d=c,c=b):"object"==typeof c&&(f="POST"),$.ajax({url:a,type:f,dataType:"html",data:c,complete:function(a,b){d&&h.each(d,g||[a.responseText,b,a])}}).done(function(a){g=arguments,h.html(e?$("
").append(a.replace(Fb,"")).find(e):a)}),this},$.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){$.fn[b]=function(a){return this.on(b,a)}}),$.each(["get","post"],function(a,c){$[c]=function(a,d,e,f){return $.isFunction(d)&&(f=f||e,e=d,d=b),$.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),$.extend({getScript:function(a,c){return $.get(a,b,c,"script")},getJSON:function(a,b,c){return $.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?A(a,$.ajaxSettings):(b=a,a=$.ajaxSettings),A(a,b),a},ajaxSettings:{url:xb,isLocal:Bb.test(yb[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Lb},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":$.parseJSON,"text xml":$.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:y(Jb),ajaxTransport:y(Kb),ajax:function(a,c){function d(a,c,d,g){var j,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),h=b,f=g||"",w.readyState=a>0?4:0,d&&(t=B(m,w,d)),a>=200&&300>a||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&($.lastModified[e]=v),v=w.getResponseHeader("Etag"),v&&($.etag[e]=v)),304===a?(x="notmodified",j=!0):(j=C(m,t),x=j.state,l=j.data,s=j.error,j=!s)):(s=x,(!x||a)&&(x="error",0>a&&(a=0))),w.status=a,w.statusText=""+(c||x),j?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,k&&o.trigger("ajax"+(j?"Success":"Error"),[w,m,j?l:s]),q.fireWith(n,[w,x]),k&&(o.trigger("ajaxComplete",[w,m]),--$.active||$.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=$.ajaxSetup({},c),n=m.context||m,o=n!==m&&(n.nodeType||n instanceof $)?$(n):$.event,p=$.Deferred(),q=$.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,setRequestHeader:function(a,b){if(!u){var c=a.toLowerCase();a=t[c]=t[c]||a,s[a]=b}return this},getAllResponseHeaders:function(){return 2===u?f:null},getResponseHeader:function(a){var c;if(2===u){if(!g)for(g={};c=Ab.exec(f);)g[c[1].toLowerCase()]=c[2];c=g[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return u||(m.mimeType=a),this},abort:function(a){return a=a||v,h&&h.abort(a),d(0,a),this}};if(p.promise(w),w.success=w.done,w.error=w.fail,w.complete=q.add,w.statusCode=function(a){if(a){var b;if(2>u)for(b in a)r[b]=[r[b],a[b]];else b=a[w.status],w.always(b)}return this},m.url=((a||m.url)+"").replace(zb,"").replace(Db,yb[1]+"//"),m.dataTypes=$.trim(m.dataType||"*").toLowerCase().split(ba),null==m.crossDomain&&(j=Hb.exec(m.url.toLowerCase()),m.crossDomain=!(!j||j[1]==yb[1]&&j[2]==yb[2]&&(j[3]||("http:"===j[1]?80:443))==(yb[3]||("http:"===yb[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=$.param(m.data,m.traditional)),z(Jb,m,c,w),2===u)return w;if(k=m.global,m.type=m.type.toUpperCase(),m.hasContent=!Cb.test(m.type),k&&0===$.active++&&$.event.trigger("ajaxStart"),!m.hasContent&&(m.data&&(m.url+=(Eb.test(m.url)?"&":"?")+m.data,delete m.data),e=m.url,m.cache===!1)){var x=$.now(),y=m.url.replace(Gb,"$1_="+x);m.url=y+(y===m.url?(Eb.test(m.url)?"&":"?")+"_="+x:"")}(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),m.ifModified&&(e=e||m.url,$.lastModified[e]&&w.setRequestHeader("If-Modified-Since",$.lastModified[e]),$.etag[e]&&w.setRequestHeader("If-None-Match",$.etag[e])),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Lb+"; q=0.01":""):m.accepts["*"]);for(l in m.headers)w.setRequestHeader(l,m.headers[l]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(l in{success:1,error:1,complete:1})w[l](m[l]);if(h=z(Kb,m,c,w)){w.readyState=1,k&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,h.send(s,d)}catch(A){if(!(2>u))throw A;d(-1,A)}}else d(-1,"No Transport");return w},active:0,lastModified:{},etag:{}});var Nb=[],Ob=/\?/,Pb=/(=)\?(?=&|$)|\?\?/,Qb=$.now();$.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Nb.pop()||$.expando+"_"+Qb++;return this[a]=!0,a}}),$.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.data,j=c.url,k=c.jsonp!==!1,l=k&&Pb.test(j),m=k&&!l&&"string"==typeof i&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Pb.test(i);return"jsonp"===c.dataTypes[0]||l||m?(f=c.jsonpCallback=$.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,g=a[f],l?c.url=j.replace(Pb,"$1"+f):m?c.data=i.replace(Pb,"$1"+f):k&&(c.url+=(Ob.test(j)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||$.error(f+" was not called"),h[0]},c.dataTypes[0]="json",a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Nb.push(f)),h&&$.isFunction(g)&&g(h[0]),h=g=b}),"script"):void 0}),$.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return $.globalEval(a),a}}}),$.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),$.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=P.head||P.getElementsByTagName("head")[0]||P.documentElement;return{send:function(e,f){c=P.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){(e||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||f(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var Rb,Sb=a.ActiveXObject?function(){for(var a in Rb)Rb[a](0,1)}:!1,Tb=0;$.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&D()||E()}:D,function(a){$.extend($.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}($.ajaxSettings.xhr()),$.support.ajax&&$.ajaxTransport(function(c){if(!c.crossDomain||$.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l,m;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=$.noop,Sb&&delete Rb[g]),e)4!==i.readyState&&i.abort();else{h=i.status,k=i.getAllResponseHeaders(),l={},m=i.responseXML,m&&m.documentElement&&(l.xml=m);try{l.text=i.responseText}catch(a){}try{j=i.statusText}catch(n){j=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(o){e||f(-1,o)}l&&f(h,j,l,k)},c.async?4===i.readyState?setTimeout(d,0):(g=++Tb,Sb&&(Rb||(Rb={},$(a).unload(Sb)),Rb[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(0,1)}}}});var Ub,Vb,Wb=/^(?:toggle|show|hide)$/,Xb=new RegExp("^(?:([-+])=|)("+_+")([a-z%]*)$","i"),Yb=/queueHooks$/,Zb=[J],$b={"*":[function(a,b){var c,d,e,f=this.createTween(a,b),g=Xb.exec(b),h=f.cur(),i=+h||0,j=1;if(g){if(c=+g[2],d=g[3]||($.cssNumber[a]?"":"px"),"px"!==d&&i){i=$.css(f.elem,a,!0)||c||1;do e=j=j||".5",i/=j,$.style(f.elem,a,i+d),j=f.cur()/h;while(1!==j&&j!==e)}f.unit=d,f.start=i,f.end=g[1]?i+(g[1]+1)*c:c}return f}]};$.Animation=$.extend(H,{tweener:function(a,b){$.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],$b[c]=$b[c]||[],$b[c].unshift(b)},prefilter:function(a,b){b?Zb.unshift(a):Zb.push(a)}}),$.Tween=K,K.prototype={constructor:K,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||($.cssNumber[c]?"":"px")},cur:function(){var a=K.propHooks[this.prop];return a&&a.get?a.get(this):K.propHooks._default.get(this)},run:function(a){var b,c=K.propHooks[this.prop];return this.pos=b=$.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration),this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):K.propHooks._default.set(this),this}},K.prototype.init.prototype=K.prototype,K.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=$.css(a.elem,a.prop,!1,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){$.fx.step[a.prop]?$.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[$.cssProps[a.prop]]||$.cssHooks[a.prop])?$.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},K.propHooks.scrollTop=K.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},$.each(["toggle","show","hide"],function(a,b){var c=$.fn[b];$.fn[b]=function(d,e,f){return null==d||"boolean"==typeof d||!a&&$.isFunction(d)&&$.isFunction(e)?c.apply(this,arguments):this.animate(L(b,!0),d,e,f)}}),$.fn.extend({fadeTo:function(a,b,c,d){return this.filter(r).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=$.isEmptyObject(a),f=$.speed(b,c,d),g=function(){var b=H(this,$.extend({},a),f);e&&b.stop(!0)};return e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,c,d){var e=function(a){var b=a.stop;delete a.stop,b(d)};return"string"!=typeof a&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,c=null!=a&&a+"queueHooks",f=$.timers,g=$._data(this);if(c)g[c]&&g[c].stop&&e(g[c]);else for(c in g)g[c]&&g[c].stop&&Yb.test(c)&&e(g[c]);for(c=f.length;c--;)f[c].elem!==this||null!=a&&f[c].queue!==a||(f[c].anim.stop(d),b=!1,f.splice(c,1));(b||!d)&&$.dequeue(this,a)})}}),$.each({slideDown:L("show"),slideUp:L("hide"),slideToggle:L("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){$.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),$.speed=function(a,b,c){var d=a&&"object"==typeof a?$.extend({},a):{complete:c||!c&&b||$.isFunction(a)&&a,duration:a,easing:c&&b||b&&!$.isFunction(b)&&b};return d.duration=$.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in $.fx.speeds?$.fx.speeds[d.duration]:$.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){$.isFunction(d.old)&&d.old.call(this),d.queue&&$.dequeue(this,d.queue)},d},$.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},$.timers=[],$.fx=K.prototype.init,$.fx.tick=function(){for(var a,b=$.timers,c=0;c-1,l={},m={};k?(m=g.position(),e=m.top,f=m.left):(e=parseFloat(i)||0,f=parseFloat(j)||0),$.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(l.top=b.top-h.top+e),null!=b.left&&(l.left=b.left-h.left+f),"using"in b?b.using.call(a,l):g.css(l)}},$.fn.extend({position:function(){if(this[0]){var a=this[0],b=this.offsetParent(),c=this.offset(),d=_b.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat($.css(a,"marginTop"))||0,c.left-=parseFloat($.css(a,"marginLeft"))||0,d.top+=parseFloat($.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat($.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||P.body;a&&!_b.test(a.nodeName)&&"static"===$.css(a,"position");)a=a.offsetParent;return a||P.body})}}),$.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);$.fn[a]=function(e){return $.access(this,function(a,e,f){var g=M(a);return f===b?g?c in g?g[c]:g.document.documentElement[e]:a[e]:void(g?g.scrollTo(d?$(g).scrollLeft():f,d?f:$(g).scrollTop()):a[e]=f)},a,e,arguments.length,null)}}),$.each({Height:"height",Width:"width"},function(a,c){$.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){$.fn[e]=function(e,f){var g=arguments.length&&(d||"boolean"!=typeof e),h=d||(e===!0||f===!0?"margin":"border");return $.access(this,function(c,d,e){var f;return $.isWindow(c)?c.document.documentElement["client"+a]:9===c.nodeType?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?$.css(c,d,e,h):$.style(c,d,e,h)},c,g?e:b,g)}})}),a.jQuery=a.$=$,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return $})}(window),function(a,b){function c(b,c){var e,f,g,h=b.nodeName.toLowerCase();return"area"===h?(e=b.parentNode,f=e.name,b.href&&f&&"map"===e.nodeName.toLowerCase()?(g=a("img[usemap=#"+f+"]")[0],!!g&&d(g)):!1):(/input|select|textarea|button|object/.test(h)?!b.disabled:"a"===h?b.href||c:c)&&d(b)}function d(b){return a.expr.filters.visible(b)&&!a(b).parents().addBack().filter(function(){return"hidden"===a.css(this,"visibility")}).length}var e=0,f=/^ui-id-\d+$/;a.ui=a.ui||{},a.extend(a.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),a.fn.extend({focus:function(b){return function(c,d){return"number"==typeof c?this.each(function(){var b=this;setTimeout(function(){a(b).focus(),d&&d.call(b)},c)}):b.apply(this,arguments)}}(a.fn.focus),scrollParent:function(){var b;return b=a.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.css(this,"position"))&&/(auto|scroll)/.test(a.css(this,"overflow")+a.css(this,"overflow-y")+a.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(a.css(this,"overflow")+a.css(this,"overflow-y")+a.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length)for(var d,e,f=a(this[0]);f.length&&f[0]!==document;){if(d=f.css("position"),("absolute"===d||"relative"===d||"fixed"===d)&&(e=parseInt(f.css("zIndex"),10),!isNaN(e)&&0!==e))return e;f=f.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})},removeUniqueId:function(){return this.each(function(){f.test(this.id)&&a(this).removeAttr("id")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a("").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function e(b,c,d,e){return a.each(f,function(){c-=parseFloat(a.css(b,"padding"+this))||0,d&&(c-=parseFloat(a.css(b,"border"+this+"Width"))||0),e&&(c-=parseFloat(a.css(b,"margin"+this))||0)}),c}var f="Width"===d?["Left","Right"]:["Top","Bottom"],g=d.toLowerCase(),h={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?h["inner"+d].call(this):this.each(function(){a(this).css(g,e(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return"number"!=typeof b?h["outer"+d].call(this,b):this.each(function(){a(this).css(g,e(this,b,!0,c)+"px")})}}),a.fn.addBack||(a.fn.addBack=function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}),a("").data("a-b","a").removeData("a-b").data("a-b")&&(a.fn.removeData=function(b){return function(c){return arguments.length?b.call(this,a.camelCase(c)):b.call(this)}}(a.fn.removeData)),a.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),a.support.selectstart="onselectstart"in document.createElement("div"),a.fn.extend({disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e,f=a.ui[b].prototype;for(e in d)f.plugins[e]=f.plugins[e]||[],f.plugins[e].push([c,d[e]])},call:function(a,b,c){var d,e=a.plugins[b];if(e&&a.element[0].parentNode&&11!==a.element[0].parentNode.nodeType)for(d=0;d0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)}})}(jQuery),function(a,b){var c=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(var c,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(b,c,d){var e,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){return this._createWidget?void(arguments.length&&this._createWidget(a,b)):new g(a,b)},a.extend(g,f,{version:d.version,_proto:a.extend({},d),_childConstructors:[]}),h=new c,h.options=a.widget.extend({},h.options),a.each(d,function(b,d){return a.isFunction(d)?void(i[b]=function(){var a=function(){return c.prototype[b].apply(this,arguments)},e=function(a){return c.prototype[b].apply(this,a)};return function(){var b,c=this._super,f=this._superApply;return this._super=a,this._superApply=e,b=d.apply(this,arguments),this._super=c,this._superApply=f,b}}()):void(i[b]=d)}),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){var d=c.prototype;a.widget(d.namespace+"."+d.widgetName,g,c._proto)}),delete f._childConstructors):c._childConstructors.push(g),a.widget.bridge(b,g)},a.widget.extend=function(c){for(var e,f,g=d.call(arguments,1),h=0,i=g.length;i>h;h++)for(e in g[h])f=g[h][e],g[h].hasOwnProperty(e)&&f!==b&&(a.isPlainObject(f)?c[e]=a.isPlainObject(c[e])?a.widget.extend({},c[e],f):a.widget.extend({},f):c[e]=f);return c},a.widget.bridge=function(c,e){var f=e.prototype.widgetFullName||c;a.fn[c]=function(g){var h="string"==typeof g,i=d.call(arguments,1),j=this;return g=!h&&i.length?a.widget.extend.apply(null,[g].concat(i)):g,this.each(h?function(){var d,e=a.data(this,f);return e?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):void 0):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+"'")}:function(){var b=a.data(this,f);b?b.option(g||{})._init():a.data(this,f,new e(g,this))}),j}},a.Widget=function(){},a.Widget._childConstructors=[],a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",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(){return this.element},option:function(c,d){var e,f,g,h=c;if(0===arguments.length)return a.widget.extend({},this.options);if("string"==typeof c)if(h={},e=c.split("."),c=e.shift(),e.length){for(f=h[c]=a.widget.extend({},this.options[c]),g=0;g=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(a,b){function c(a,b,c){return a>b&&b+c>a}function d(a){return/left|right/.test(a.css("float"))||/inline|table-cell/.test(a.css("display"))}a.widget("ui.sortable",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===a.axis||d(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){"disabled"===b?(this.options[b]=c,this.widget().toggleClass("ui-sortable-disabled",!!c)):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=null,e=!1,f=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(b),a(b.target).parents().each(function(){return a.data(this,f.widgetName+"-item")===f?(d=a(this),!1):void 0}),a.data(b.target,f.widgetName+"-item")===f&&(d=a(b.target)),d&&(!this.options.handle||c||(a(this.options.handle,d).find("*").addBack().each(function(){this===b.target&&(e=!0)}),e))?(this.currentItem=d,this._removeCurrentsFromItems(),!0):!1)},_mouseStart:function(b,c,d){var e,f,g=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,g.cursorAt&&this._adjustOffsetFromHelper(g.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),g.containment&&this._setContainment(),g.cursor&&"auto"!==g.cursor&&(f=this.document.find("body"),this.storedCursor=f.css("cursor"),f.css("cursor",g.cursor),this.storedStylesheet=a("").appendTo(f)),g.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",g.opacity)),g.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",g.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!d)for(e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("activate",b,this._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!g.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){var c,d,e,f,g=this.options,h=!1;for(this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY=0;c--)if(d=this.items[c],e=d.item[0],f=this._intersectsWithPointer(d),f&&d.instance===this.currentContainer&&e!==this.currentItem[0]&&this.placeholder[1===f?"next":"prev"]()[0]!==e&&!a.contains(this.placeholder[0],e)&&("semi-dynamic"===this.options.type?!a.contains(this.element[0],e):!0)){if(this.direction=1===f?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(d))break;this._rearrange(b,d),this._trigger("change",b,this._uiHash());break}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(b){if(a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b),this.options.revert){var d=this,e=this.placeholder.offset(),f=this.options.axis,g={};f&&"x"!==f||(g.left=e.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),f&&"y"!==f||(g.top=e.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,a(this.helper).animate(g,parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--)this.containers[b]._trigger("deactivate",null,this._uiHash(this)),this.containers[b].containerCache.over&&(this.containers[b]._trigger("out",null,this._uiHash(this)),this.containers[b].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[\-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l="x"===this.options.axis||d+j>h&&i>d+j,m="y"===this.options.axis||b+k>f&&g>b+k,n=l&&m;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?n:f0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return 0!==a&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor===String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c,d,e,f,g=[],h=[],i=this._connectWith();if(i&&b)for(c=i.length-1;c>=0;c--)for(e=a(i[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&h.push([a.isFunction(f.options.items)?f.options.items.call(f.element):a(f.options.items,f.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),f]);for(h.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),c=h.length-1;c>=0;c--)h[c][0].each(function(){g.push(this)});return a(g)},_removeCurrentsFromItems:function(){var b=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=a.grep(this.items,function(a){for(var c=0;c=0;c--)for(e=a(m[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&(l.push([a.isFunction(f.options.items)?f.options.items.call(f.element[0],b,{item:this.currentItem}):a(f.options.items,f.element),f]),this.containers.push(f));for(c=l.length-1;c>=0;c--)for(g=l[c][1],h=l[c][0],d=0,j=h.length;j>d;d++)i=a(h[d]),i.data(this.widgetName+"-item",g),k.push({item:i,instance:g,width:0,height:0,left:0,top:0})},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var c,d,e,f;for(c=this.items.length-1;c>=0;c--)d=this.items[c],d.instance!==this.currentContainer&&this.currentContainer&&d.item[0]!==this.currentItem[0]||(e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item,b||(d.width=e.outerWidth(),d.height=e.outerHeight()),f=e.offset(),d.left=f.left,d.top=f.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(c=this.containers.length-1;c>=0;c--)f=this.containers[c].element.offset(),this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight();return this},_createPlaceholder:function(b){b=b||this;var c,d=b.options;d.placeholder&&d.placeholder.constructor!==String||(c=d.placeholder,d.placeholder={element:function(){var d=b.currentItem[0].nodeName.toLowerCase(),e=a("<"+d+">",b.document[0]).addClass(c||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===d?b.currentItem.children().each(function(){a("
",b.document[0]).attr("colspan",a(this).attr("colspan")||1).appendTo(e)}):"img"===d&&e.attr("src",b.currentItem.attr("src")),c||e.css("visibility","hidden"),e},update:function(a,e){(!c||d.forcePlaceholderSize)&&(e.height()||e.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10)))}}),b.placeholder=a(d.placeholder.element.call(b.element,b.currentItem)),b.currentItem.after(b.placeholder),d.placeholder.update(b,b.placeholder)},_contactContainers:function(b){var e,f,g,h,i,j,k,l,m,n,o=null,p=null;for(e=this.containers.length-1;e>=0;e--)if(!a.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(o&&a.contains(this.containers[e].element[0],o.element[0]))continue;o=this.containers[e],p=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0);if(o)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",b,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(g=1e4,h=null,n=o.floating||d(this.currentItem),i=n?"left":"top",j=n?"width":"height",k=this.positionAbs[i]+this.offset.click[i],f=this.items.length-1;f>=0;f--)a.contains(this.containers[p].element[0],this.items[f].item[0])&&this.items[f].item[0]!==this.currentItem[0]&&(!n||c(this.positionAbs.top+this.offset.click.top,this.items[f].top,this.items[f].height))&&(l=this.items[f].item.offset()[i],m=!1,Math.abs(l-k)>Math.abs(l+this.items[f][j]-k)&&(m=!0,l+=this.items[f][j]),Math.abs(l-k)this.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top)),e.grid&&(c=this.originalPageY+Math.round((g-this.originalPageY)/e.grid[1])*e.grid[1],g=this.containment?c-this.offset.click.top>=this.containment[1]&&c-this.offset.click.top<=this.containment[3]?c:c-this.offset.click.top>=this.containment[1]?c-e.grid[1]:c+e.grid[1]:c,d=this.originalPageX+Math.round((f-this.originalPageX)/e.grid[0])*e.grid[0],f=this.containment?d-this.offset.click.left>=this.containment[0]&&d-this.offset.click.left<=this.containment[2]?d:d-this.offset.click.left>=this.containment[0]?d-e.grid[0]:d+e.grid[0]:d)),{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():i?0:h.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():i?0:h.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this.counter;this._delay(function(){e===this.counter&&this.refreshPositions(!d)})},_clear:function(a,b){this.reverting=!1;var c,d=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(c in this._storedCSS)("auto"===this._storedCSS[c]||"static"===this._storedCSS[c])&&(this._storedCSS[c]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!b&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||b||d.push(function(a){this._trigger("update",a,this._uiHash())}),this!==this.currentContainer&&(b||(d.push(function(a){this._trigger("remove",a,this._uiHash())}),d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.currentContainer)),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.currentContainer)))),c=this.containers.length-1;c>=0;c--)b||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this)); +var d=c&&"left"===c?"scrollLeft":"scrollTop",e=!1;return b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)}})}(jQuery),function(a,b){var c=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(var c,d=0;null!=(c=b[d]);d++)try{a(c).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(b,c,d){var e,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){return this._createWidget?void(arguments.length&&this._createWidget(a,b)):new g(a,b)},a.extend(g,f,{version:d.version,_proto:a.extend({},d),_childConstructors:[]}),h=new c,h.options=a.widget.extend({},h.options),a.each(d,function(b,d){return a.isFunction(d)?void(i[b]=function(){var a=function(){return c.prototype[b].apply(this,arguments)},e=function(a){return c.prototype[b].apply(this,a)};return function(){var b,c=this._super,f=this._superApply;return this._super=a,this._superApply=e,b=d.apply(this,arguments),this._super=c,this._superApply=f,b}}()):void(i[b]=d)}),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){var d=c.prototype;a.widget(d.namespace+"."+d.widgetName,g,c._proto)}),delete f._childConstructors):c._childConstructors.push(g),a.widget.bridge(b,g)},a.widget.extend=function(c){for(var e,f,g=d.call(arguments,1),h=0,i=g.length;i>h;h++)for(e in g[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);return c},a.widget.bridge=function(c,e){var f=e.prototype.widgetFullName||c;a.fn[c]=function(g){var h="string"==typeof g,i=d.call(arguments,1),j=this;return g=!h&&i.length?a.widget.extend.apply(null,[g].concat(i)):g,this.each(h?function(){var d,e=a.data(this,f);return e?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):void 0):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+"'")}:function(){var b=a.data(this,f);b?b.option(g||{})._init():a.data(this,f,new e(g,this))}),j}},a.Widget=function(){},a.Widget._childConstructors=[],a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",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(){return this.element},option:function(c,d){var e,f,g,h=c;if(0===arguments.length)return a.widget.extend({},this.options);if("string"==typeof c)if(h={},e=c.split("."),c=e.shift(),e.length){for(f=h[c]=a.widget.extend({},this.options[c]),g=0;g=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(a,b){function c(a,b,c){return a>b&&b+c>a}function d(a){return/left|right/.test(a.css("float"))||/inline|table-cell/.test(a.css("display"))}a.widget("ui.sortable",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===a.axis||d(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){"disabled"===b?(this.options[b]=c,this.widget().toggleClass("ui-sortable-disabled",!!c)):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=null,e=!1,f=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(b),a(b.target).parents().each(function(){return a.data(this,f.widgetName+"-item")===f?(d=a(this),!1):void 0}),a.data(b.target,f.widgetName+"-item")===f&&(d=a(b.target)),d&&(!this.options.handle||c||(a(this.options.handle,d).find("*").addBack().each(function(){this===b.target&&(e=!0)}),e))?(this.currentItem=d,this._removeCurrentsFromItems(),!0):!1)},_mouseStart:function(b,c,d){var e,f,g=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,g.cursorAt&&this._adjustOffsetFromHelper(g.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),g.containment&&this._setContainment(),g.cursor&&"auto"!==g.cursor&&(f=this.document.find("body"),this.storedCursor=f.css("cursor"),f.css("cursor",g.cursor),this.storedStylesheet=a("").appendTo(f)),g.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",g.opacity)),g.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",g.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!d)for(e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("activate",b,this._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!g.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){var c,d,e,f,g=this.options,h=!1;for(this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY=0;c--)if(d=this.items[c],e=d.item[0],f=this._intersectsWithPointer(d),f&&d.instance===this.currentContainer&&e!==this.currentItem[0]&&this.placeholder[1===f?"next":"prev"]()[0]!==e&&!a.contains(this.placeholder[0],e)&&("semi-dynamic"===this.options.type?!a.contains(this.element[0],e):!0)){if(this.direction=1===f?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(d))break;this._rearrange(b,d),this._trigger("change",b,this._uiHash());break}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(b){if(a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b),this.options.revert){var d=this,e=this.placeholder.offset(),f=this.options.axis,g={};f&&"x"!==f||(g.left=e.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),f&&"y"!==f||(g.top=e.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,a(this.helper).animate(g,parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--)this.containers[b]._trigger("deactivate",null,this._uiHash(this)),this.containers[b].containerCache.over&&(this.containers[b]._trigger("out",null,this._uiHash(this)),this.containers[b].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[\-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l="x"===this.options.axis||d+j>h&&i>d+j,m="y"===this.options.axis||b+k>f&&g>b+k,n=l&&m;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?n:f0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return 0!==a&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor===String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c,d,e,f,g=[],h=[],i=this._connectWith();if(i&&b)for(c=i.length-1;c>=0;c--)for(e=a(i[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&h.push([a.isFunction(f.options.items)?f.options.items.call(f.element):a(f.options.items,f.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),f]);for(h.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),c=h.length-1;c>=0;c--)h[c][0].each(function(){g.push(this)});return a(g)},_removeCurrentsFromItems:function(){var b=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=a.grep(this.items,function(a){for(var c=0;c=0;c--)for(e=a(m[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&(l.push([a.isFunction(f.options.items)?f.options.items.call(f.element[0],b,{item:this.currentItem}):a(f.options.items,f.element),f]),this.containers.push(f));for(c=l.length-1;c>=0;c--)for(g=l[c][1],h=l[c][0],d=0,j=h.length;j>d;d++)i=a(h[d]),i.data(this.widgetName+"-item",g),k.push({item:i,instance:g,width:0,height:0,left:0,top:0})},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var c,d,e,f;for(c=this.items.length-1;c>=0;c--)d=this.items[c],d.instance!==this.currentContainer&&this.currentContainer&&d.item[0]!==this.currentItem[0]||(e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item,b||(d.width=e.outerWidth(),d.height=e.outerHeight()),f=e.offset(),d.left=f.left,d.top=f.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(c=this.containers.length-1;c>=0;c--)f=this.containers[c].element.offset(),this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight();return this},_createPlaceholder:function(b){b=b||this;var c,d=b.options;d.placeholder&&d.placeholder.constructor!==String||(c=d.placeholder,d.placeholder={element:function(){var d=b.currentItem[0].nodeName.toLowerCase(),e=a("<"+d+">",b.document[0]).addClass(c||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===d?b.currentItem.children().each(function(){a("
",b.document[0]).attr("colspan",a(this).attr("colspan")||1).appendTo(e)}):"img"===d&&e.attr("src",b.currentItem.attr("src")),c||e.css("visibility","hidden"),e},update:function(a,e){(!c||d.forcePlaceholderSize)&&(e.height()||e.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10)))}}),b.placeholder=a(d.placeholder.element.call(b.element,b.currentItem)),b.currentItem.after(b.placeholder),d.placeholder.update(b,b.placeholder)},_contactContainers:function(b){var e,f,g,h,i,j,k,l,m,n,o=null,p=null;for(e=this.containers.length-1;e>=0;e--)if(!a.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(o&&a.contains(this.containers[e].element[0],o.element[0]))continue;o=this.containers[e],p=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0);if(o)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",b,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(g=1e4,h=null,n=o.floating||d(this.currentItem),i=n?"left":"top",j=n?"width":"height",k=this.positionAbs[i]+this.offset.click[i],f=this.items.length-1;f>=0;f--)a.contains(this.containers[p].element[0],this.items[f].item[0])&&this.items[f].item[0]!==this.currentItem[0]&&(!n||c(this.positionAbs.top+this.offset.click.top,this.items[f].top,this.items[f].height))&&(l=this.items[f].item.offset()[i],m=!1,Math.abs(l-k)>Math.abs(l+this.items[f][j]-k)&&(m=!0,l+=this.items[f][j]),Math.abs(l-k)this.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top)),e.grid&&(c=this.originalPageY+Math.round((g-this.originalPageY)/e.grid[1])*e.grid[1],g=this.containment?c-this.offset.click.top>=this.containment[1]&&c-this.offset.click.top<=this.containment[3]?c:c-this.offset.click.top>=this.containment[1]?c-e.grid[1]:c+e.grid[1]:c,d=this.originalPageX+Math.round((f-this.originalPageX)/e.grid[0])*e.grid[0],f=this.containment?d-this.offset.click.left>=this.containment[0]&&d-this.offset.click.left<=this.containment[2]?d:d-this.offset.click.left>=this.containment[0]?d-e.grid[0]:d+e.grid[0]:d)),{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():i?0:h.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():i?0:h.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this.counter;this._delay(function(){e===this.counter&&this.refreshPositions(!d)})},_clear:function(a,b){this.reverting=!1;var c,d=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(c in this._storedCSS)("auto"===this._storedCSS[c]||"static"===this._storedCSS[c])&&(this._storedCSS[c]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!b&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||b||d.push(function(a){this._trigger("update",a,this._uiHash())}),this!==this.currentContainer&&(b||(d.push(function(a){this._trigger("remove",a,this._uiHash())}),d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.currentContainer)),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.currentContainer)))),c=this.containers.length-1;c>=0;c--)b||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this)); -}}.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
',trigger:"hover",title:"",delay:0,html:!0}}(window.jQuery);var Constants={DEFAULT:{HEIGHT:32,WIDTH:32,FPS:12},MODEL_VERSION:2,MAX_HEIGHT:1024,MAX_WIDTH:1024,MAX_PALETTE_COLORS:100,MINIMUM_ZOOM:1,PREVIEW_FILM_SIZE:96,ANIMATED_PREVIEW_WIDTH:200,DEFAULT_PEN_COLOR:"#000000",TRANSPARENT_COLOR:"rgba(0, 0, 0, 0)",CURRENT_COLORS_PALETTE_ID:"__current-colors",SELECTION_TRANSPARENT_COLOR:"rgba(255, 255, 255, 0.6)",TOOL_TARGET_HIGHLIGHT_COLOR:"rgba(255, 255, 255, 0.2)",ZOOMED_OUT_BACKGROUND_COLOR:"#A0A0A0",LEFT_BUTTON:0,MIDDLE_BUTTON:1,RIGHT_BUTTON:2,MOUSEMOVE_THROTTLING:10,ABSTRACT_FUNCTION:function(){throw"abstract method should be implemented"},EMPTY_FUNCTION:function(){},DRAWING_TEST_FOLDER:"drawing",APPENGINE_SAVE_URL:"save",IMAGE_SERVICE_UPLOAD_URL:"http://piskel-imgstore-b.appspot.com/__/upload",IMAGE_SERVICE_GET_URL:"http://piskel-imgstore-b.appspot.com/img/"},Events={TOOL_SELECTED:"TOOL_SELECTED",SELECT_TOOL:"SELECT_TOOL",TOOL_RELEASED:"TOOL_RELEASED",TOOL_PRESSED:"TOOL_PRESSED",SELECT_PRIMARY_COLOR:"SELECT_PRIMARY_COLOR",SELECT_SECONDARY_COLOR:"SELECT_SECONDARY_COLOR",PRIMARY_COLOR_SELECTED:"PRIMARY_COLOR_SELECTED",SECONDARY_COLOR_SELECTED:"SECONDARY_COLOR_SELECTED",CURSOR_MOVED:"CURSOR_MOVED",DRAG_START:"DRAG_START",DRAG_END:"DRAG_END",DIALOG_DISPLAY:"DIALOG_DISPLAY",DIALOG_HIDE:"DIALOG_HIDE",PALETTE_LIST_UPDATED:"PALETTE_LIST_UPDATED",USER_SETTINGS_CHANGED:"USER_SETTINGS_CHANGED",CLOSE_SETTINGS_DRAWER:"CLOSE_SETTINGS_DRAWER",PISKEL_RESET:"PISKEL_RESET",PISKEL_SAVE_STATE:"PISKEL_SAVE_STATE",HISTORY_STATE_SAVED:"HISTORY_STATE_SAVED",HISTORY_STATE_LOADED:"HISTORY_STATE_LOADED",PISKEL_SAVED:"PISKEL_SAVED",FRAME_SIZE_CHANGED:"FRAME_SIZE_CHANGED",SELECTION_CREATED:"SELECTION_CREATED",SELECTION_MOVE_REQUEST:"SELECTION_MOVE_REQUEST",SELECTION_DISMISSED:"SELECTION_DISMISSED",SHOW_NOTIFICATION:"SHOW_NOTIFICATION",HIDE_NOTIFICATION:"HIDE_NOTIFICATION",SHOW_PROGRESS:"SHOW_PROGRESS",UPDATE_PROGRESS:"UPDATE_PROGRESS",HIDE_PROGRESS:"HIDE_PROGRESS",ZOOM_CHANGED:"ZOOM_CHANGED",CURRENT_COLORS_UPDATED:"CURRENT_COLORS_UPDATED",MOUSE_EVENT:"MOUSE_EVENT",TEST_RECORD_END:"TEST_RECORD_END",TEST_CASE_END:"TEST_CASE_END",TEST_SUITE_END:"TEST_SUITE_END"};jQuery.namespace=function(){for(var a=arguments,b=null,c=0;cc;c++){var e=a.charCodeAt(c);b=(b<<5)-b+e,b|=0}return b},a.copy=function(a){return JSON.parse(JSON.stringify(a))};var b={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};a.escapeHtml=function(a){return String(a).replace(/[&<>"'\/]/g,function(a){return b[a]})};var c={};a.unescapeHtml=function(a){return Object.keys(b).forEach(function(d){c[d]=c[d]||new RegExp(b[d],"g"),a=a.replace(c[d],d)}),a}}(),function(){var a=$.namespace("pskl.utils"),b=navigator.userAgent;a.UserAgent={isIE:/MSIE/i.test(b),isIE11:/trident/i.test(b),isChrome:/Chrome/i.test(b),isFirefox:/Firefox/i.test(b),isMac:/Mac/.test(b)},a.UserAgent.version=function(){return pskl.utils.UserAgent.isIE?parseInt(/MSIE\s?(\d+)/i.exec(b)[1],10):pskl.utils.UserAgent.isChrome?parseInt(/Chrome\/(\d+)/i.exec(b)[1],10):pskl.utils.UserAgent.isFirefox?parseInt(/Firefox\/(\d+)/i.exec(b)[1],10):void 0}()}(),function(){var a=$.namespace("pskl.utils");a.Array={find:function(a,b){var c=null;a=Array.isArray(a)?a:[];var d=a.filter(b);return d.length&&(c=d[0]),c}}}(),function(){var a,b=$.namespace("pskl.utils");Uint8Array&&(a=new Uint8Array([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),b.Base64={toText:function(a){return window.atob(a.replace(/data\:.*?\;base64\,/,""))},decode:function(b){for(var c,d=0,e=[0,0],f=0,g=0,h=b.length,i=0,j=new Uint8Array(h/4*3|0);h--;){var k=b.charCodeAt(i++),l=a[k-43];255!==l&&l!==c&&(e[1]=e[0],e[0]=k,g=g<<6|l,f++,4===f&&(j[d++]=g>>>16,61!==e[1]&&(j[d++]=g>>>8),61!==e[0]&&(j[d++]=g),f=0))}return j.buffer}}}(),function(){var a=$.namespace("pskl.utils"),b=/\s*;\s*base64\s*(?:;|$)/i;a.BlobUtils={dataToBlob:function(a,c,d){var e,f=a.indexOf(","),g=a.substring(f+1),h=b.test(a.substring(0,f));if(Blob.fake)e=new Blob,e.encoding=h?"base64":"URI",e.data=g,e.size=g.length;else if(Uint8Array){var i=h?pskl.utils.Base64.decode(g):decodeURIComponent(g);e=new Blob([i],{type:c})}d(e)},canvasToBlob:function(a,b,c){if(c=c||"image/png",a.mozGetAsFile)b(a.mozGetAsFile("canvas",c));else{var d=Array.prototype.slice.call(arguments,2),e=a.toDataURL.apply(a,d);pskl.utils.BlobUtils.dataToBlob(e,c,b)}},stringToBlob:function(a,b,c){c=c||"text/plain",pskl.utils.BlobUtils.dataToBlob("data:"+c+","+a,c,b)}}}(),function(){var a=$.namespace("pskl.utils");a.CanvasUtils={createCanvas:function(a,b,c){var d=document.createElement("canvas");if(d.setAttribute("width",a),d.setAttribute("height",b),"string"==typeof c&&(c=[c]),Array.isArray(c))for(var e=0;ea?"0"+a:""+a};a.DateUtils={format:function(a,c){return a=new Date(a),pskl.utils.Template.replace(c,{Y:a.getFullYear(),M:b(a.getMonth()+1),D:b(a.getDate()),H:b(a.getHours()),m:b(a.getMinutes()),s:b(a.getSeconds())})}}}(),function(){var a=$.namespace("pskl.utils");a.Dom={isParent:function(a,b,c){if(a&&b)for(c&&(a=a.parentNode);a;){if(a===b)return!0;a=a.parentNode}return!1},getParentWithData:function(a,b){for(;a;){if(a.dataset&&"undefined"!=typeof a.dataset[b])return a;a=a.parentNode}return null}}}(),function(){var a=$.namespace("pskl.utils");a.Event={},a.Event.addEventListener=function(a,b,c,d,e){"string"==typeof a&&(a=document.querySelector(a));var f={el:a,type:b,callback:c,handler:e?c.bind(d,e):c.bind(d)};d.__pskl_listeners=d.__pskl_listeners||[],d.__pskl_listeners.push(f),a.addEventListener(b,f.handler)},a.Event.removeEventListener=function(a,b,c,d){if(d&&d.__pskl_listeners)for(var e=d.__pskl_listeners,f=0;f',f=$(e);f.change(function(b){var e=$(this).val();e=pskl.utils.FileUtilsDesktop.addExtensionIfNeeded(e,c),pskl.utils.FileUtilsDesktop.saveToFile(a,e,function(){d(e)})}),f.trigger("click")},saveToFile:function(a,b,c){var d=window.require("fs");d.writeFile(b,a,function(a){a&&console.log("FileUtilsDesktop::savetoFile() - error saving file:",b,"Error:",a),c()})},readFile:function(a,b){var c=window.require("fs");c.readFile(a,"utf8",function(c,d){c&&console.log("FileUtilsDesktop::readFile() - error reading file:",a,"Error:",c),b(d)})}}}(),function(){var a=$.namespace("pskl.utils");a.FrameTransform={VERTICAL:"vertical",HORIZONTAL:"HORIZONTAL",flip:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight();return d.forEachPixel(function(d,g,h){c===a.FrameTransform.VERTICAL?g=e-g-1:c===a.FrameTransform.HORIZONTAL&&(h=f-h-1),b.pixels[g][h]=d}),b.version++,b},CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise",rotate:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight(),g=Math.max(e,f),h=Math.ceil((g-e)/2),i=Math.ceil((g-f)/2);return b.forEachPixel(function(e,f,j){var k=f,l=j;f+=h,j+=i;var m=f,n=j;c===a.FrameTransform.CLOCKWISE?(f=n,j=g-1-m):c===a.FrameTransform.COUNTERCLOCKWISE&&(j=m,f=g-1-n),f-=h,j-=i,d.containsPixel(f,j)?b.pixels[k][l]=d.getPixel(f,j):b.pixels[k][l]=Constants.TRANSPARENT_COLOR}),b.version++,b}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.FrameUtils={toImage:function(a,b){b=b||1;var c=new pskl.rendering.CanvasRenderer(a,b);return c.drawTransparentAs(Constants.TRANSPARENT_COLOR),c.render()},merge:function(a){var b=null;if(a.length){b=a[0].clone();for(var c=1;ce;e++){d[e]=[];for(var f=0;c>f;f++){var g=4*(f*b+e),h=a[g],i=a[g+1],j=a[g+2],k=a[g+3];125>k?d[e][f]=Constants.TRANSPARENT_COLOR:d[e][f]=pskl.utils.rgbToHex(h,i,j)}}return pskl.model.Frame.fromPixelGrid(d)},mergePixels__:function(a,b,c){var d=pskl.utils.FrameUtils.toRgba__(a),e=pskl.utils.FrameUtils.toRgba__(b);"number"==typeof c&&(d=JSON.parse(JSON.stringify(d)),d.a=c*d.a);var f=d.a+e.a*(1-d.a),g=(d.r*d.a+e.r*e.a*(1-d.a))/f|0,h=(d.g*d.a+e.g*e.a*(1-d.a))/f|0,i=(d.b*d.a+e.b*e.a*(1-d.a))/f|0;return"rgba("+g+","+h+","+i+","+f+")"},toRgba__:function(a){if(b[a])return b[a];var c,d;return"TRANSPARENT"===a?c={r:0,g:0,b:0,a:0}:-1!=a.indexOf("rgba(")?(d=/rgba\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(1|0\.\d+)\s*\)/.exec(a),c={r:parseInt(d[1],10),g:parseInt(d[2],10),b:parseInt(d[3],10),a:parseFloat(d[4])}):-1!=a.indexOf("rgb(")?(d=/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(a),c={r:parseInt(d[1],10),g:parseInt(d[2],10),b:parseInt(d[3],10),a:1}):(d=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a),c={r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16),a:1}),b[a]=c,c}}}(),function(){var a=$.namespace("pskl.utils");a.LayerUtils={createLayerFromSpritesheet:function(a,b){for(var c=a.width,d=a.height,e=c/b,f=pskl.utils.CanvasUtils.createCanvas(e,d),g=f.getContext("2d"),h=[],i=0;b>i;i++){g.clearRect(0,0,e,d),g.drawImage(a,e*i,0,e,d,0,0,e,d);var j=pskl.utils.FrameUtils.createFromImage(f);h.push(j)}return h},mergeLayers:function(a,b){var c=a.getFrames(),d=b.getFrames(),e=[];c.forEach(function(a,b){var c=d[b];e.push(pskl.utils.FrameUtils.merge([c,a]))});var f=pskl.model.Layer.fromFrames(a.getName(),e);return f}}}(),function(){var a=$.namespace("pskl.utils");a.ImageResizer={resize:function(a,b,c,d){var e=pskl.utils.CanvasUtils.createCanvas(b,c),f=e.getContext("2d");return f.save(),d||pskl.utils.CanvasUtils.disableImageSmoothing(e),f.translate(e.width/2,e.height/2),f.scale(b/a.width,c/a.height),f.drawImage(a,-a.width/2,-a.height/2),f.restore(),e},resizeNearestNeighbour:function(a,b,c,d){c=c||0;for(var e=pskl.utils.CanvasUtils.createCanvas(b*a.width,b*a.height),f=e.getContext("2d"),g=pskl.utils.CanvasUtils.getImageDataFromCanvas(a),h={},i=0,j=0,k=0;k0;){k++;var m=g.pop();a.setPixel(m.col,m.row,d),f.push({col:m.col,row:m.row});for(var n=0;4>n;n++){var o=m.col+i[n],p=m.row+h[n];try{a.containsPixel(o,p)&&a.getPixel(o,p)==e&&g.push({col:o,row:p})}catch(j){}}if(k>10*l){console.log("loop breaker called");break}}return f}},calculateZoomForContainer:function(a,b,c){return this.calculateZoom(a.height(),a.width(),b,c)}}}(),function(){var a=$.namespace("pskl.utils");a.PiskelFileUtils={loadFromFile:function(b,c,d){pskl.utils.FileUtils.readFile(b,function(e){var f=pskl.utils.Base64.toText(e);a.PiskelFileUtils.decodePiskelFile(f,function(a,d,e){pskl.utils.Environment.detectNodeWebkit()&&(a.savePath=b.path),c(a,d,e)},d)})},decodePiskelFile:function(a,b,c){var d=JSON.parse(a),e=d.piskel.fps,f=d.piskel,g=new pskl.model.piskel.Descriptor(f.name,f.description,!0);pskl.utils.serialization.Deserializer.deserialize(d,function(a){b(a,g,e)})}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.Template={get:function(a){if(!b[a]){var c=document.getElementById(a);c?b[a]=c.innerHTML:console.error("Could not find template for id :",a)}return b[a]},createFromHTML:function(a){var b=document.createElement("div");return b.innerHTML=a,b.children[0]},insert:function(a,b,c,d){var e=pskl.utils.Template.getAndReplace(c,d);a.insertAdjacentHTML(b,e)},getAndReplace:function(a,b){var c="",d=pskl.utils.Template.get(a);return d&&(c=pskl.utils.Template.replace(d,b)),c},replace:function(a,b){for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];-1!==c.indexOf(":")&&(d===!0?d=c.split(":")[1]:d===!1&&(d="")),a=a.replace(new RegExp("\\{\\{"+c+"\\}\\}","g"),d)}return a}}}(),function(){var a=$.namespace("pskl.utils");a.TooltipFormatter={},a.TooltipFormatter.formatForTool=function(a,b,c){var d=pskl.utils.Template.get("drawingTool-tooltipContainer-template");return pskl.utils.Template.replace(d,{helptext:c,shortcut:a,descriptors:this.formatToolDescriptors_(b)})},a.TooltipFormatter.formatToolDescriptors_=function(a){return a=a||[],a.reduce(function(a,b){return a+=this.formatToolDescriptor_(b)}.bind(this),"")},a.TooltipFormatter.formatToolDescriptor_=function(a){var b;return a.key?(b=pskl.utils.Template.get("drawingTool-tooltipDescriptor-template"),a.key=a.key.toUpperCase(),pskl.utils.UserAgent.isMac&&(a.key=a.key.replace("CTRL","CMD"))):b=pskl.utils.Template.get("drawingTool-simpleTooltipDescriptor-template"),pskl.utils.Template.replace(b,a)}}(),function(){var a=$.namespace("pskl");a.UserSettings={GRID_WIDTH:"GRID_WIDTH",MAX_FPS:"MAX_FPS",DEFAULT_SIZE:"DEFAULT_SIZE",CANVAS_BACKGROUND:"CANVAS_BACKGROUND",SELECTED_PALETTE:"SELECTED_PALETTE",TILED_PREVIEW:"TILED_PREVIEW",ONION_SKIN:"ONION_SKIN",LAYER_PREVIEW:"LAYER_PREVIEW",KEY_TO_DEFAULT_VALUE_MAP_:{GRID_WIDTH:0,MAX_FPS:24,DEFAULT_SIZE:{width:Constants.DEFAULT.WIDTH,height:Constants.DEFAULT.HEIGHT},CANVAS_BACKGROUND:"lowcont-dark-canvas-background",SELECTED_PALETTE:Constants.CURRENT_COLORS_PALETTE_ID,TILED_PREVIEW:!1,ONION_SKIN:!1,LAYER_PREVIEW:!0},cache_:{},get:function(a){if(this.checkKeyValidity_(a),!(a in this.cache_)){var b=this.readFromLocalStorage_(a);"undefined"!=typeof b&&null!==b?this.cache_[a]=b:this.cache_[a]=this.readFromDefaults_(a)}return this.cache_[a]},set:function(a,b){this.checkKeyValidity_(a),this.cache_[a]=b,this.writeToLocalStorage_(a,b),$.publish(Events.USER_SETTINGS_CHANGED,[a,b])},readFromLocalStorage_:function(a){var b=window.localStorage[a];return"undefined"!=typeof b&&(b=JSON.parse(b)),b},writeToLocalStorage_:function(a,b){window.localStorage[a]=JSON.stringify(b)},readFromDefaults_:function(a){return this.KEY_TO_DEFAULT_VALUE_MAP_[a]},checkKeyValidity_:function(a){var b=a in this.KEY_TO_DEFAULT_VALUE_MAP_;b||console.error("UserSettings key <"+a+"> not found in supported keys.")}}}(),function(){var a=$.namespace("pskl.utils"),b=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};a.Uuid={generate:function(){return"ss-s-s-s-sss".replace(/s/g,function(){return b()})}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.WorkerUtils={createWorker:function(c,d){return b[d]||(b[d]=a.WorkerUtils.createWorkerURL(c)),new Worker(b[d])},createWorkerURL:function(a){var b=[(a+"").replace(/function\s*\(\)\s*\{/,"").replace(/\}[^}]*$/,"")],c=new Blob(b,{type:"application/javascript"});return window.URL.createObjectURL(c)}}}(),function(){var a=$.namespace("pskl.utils");a.Xhr={get:function(b,c,d){var e=a.Xhr.xhr_(b,"GET",c,d);e.send()},post:function(b,c,d,e){var f=a.Xhr.xhr_(b,"POST",d,e),g=new FormData;if("object"==typeof c)for(var h in c)c.hasOwnProperty(h)&&g.append(h,c[h]);f.send(g)},xhr_:function(a,b,c,d){c=c||function(){},d=d||function(){};var e=new XMLHttpRequest;return e.open(b,a,!0),e.onload=function(a){200==this.status?c(this):this.onerror(this,a)},e.onerror=function(a){d(a,this)},e}}}(),function(){var a=$.namespace("pskl.utils");a.Serializer={serializePiskel:function(a,b){var c=a.getLayers().map(function(a){return pskl.utils.Serializer.serializeLayer(a,b)});return JSON.stringify({modelVersion:Constants.MODEL_VERSION,piskel:{name:a.getDescriptor().name,description:a.getDescriptor().description,fps:pskl.app.piskelController.getFPS(),height:a.getHeight(),width:a.getWidth(),layers:c,expanded:b}})},serializeLayer:function(a,b){var c=a.getFrames(),d=new pskl.rendering.FramesheetRenderer(c),e={name:a.getName(),frameCount:c.length};return b?(e.grids=c.map(function(a){return a.pixels}),e):(e.base64PNG=d.renderAsCanvas().toDataURL(),JSON.stringify(e))}}}(),function(){var a=$.namespace("pskl.utils.serialization");a.Deserializer=function(a,b){this.layersToLoad_=0,this.data_=a,this.callback_=b,this.piskel_=null},a.Deserializer.deserialize=function(b,c){var d;d=b.modelVersion==Constants.MODEL_VERSION?new a.Deserializer(b,c):1==b.modelVersion?new a.backward.Deserializer_v1(b,c):new a.backward.Deserializer_v0(b,c),d.deserialize()},a.Deserializer.prototype.deserialize=function(a){var b=this.data_,c=b.piskel;a=a||"Deserialized piskel";var d=new pskl.model.piskel.Descriptor(a,"");this.piskel_=new pskl.model.Piskel(c.width,c.height,d),this.layersToLoad_=c.layers.length,c.layers.forEach(c.expanded?this.loadExpandedLayer.bind(this):this.deserializeLayer.bind(this))},a.Deserializer.prototype.deserializeLayer=function(a){var b=JSON.parse(a),c=new pskl.model.Layer(b.name),d=b.base64PNG,e=new Image;return e.onload=function(){var a=pskl.utils.LayerUtils.createLayerFromSpritesheet(e,b.frameCount);this.addFramesToLayer(a,c)}.bind(this),e.src=d,c},a.Deserializer.prototype.loadExpandedLayer=function(a){var b=new pskl.model.Layer(a.name),c=a.grids.map(function(a){return pskl.model.Frame.fromPixelGrid(a)});return this.addFramesToLayer(c,b),b},a.Deserializer.prototype.addFramesToLayer=function(a,b){a.forEach(b.addFrame.bind(b)),this.piskel_.addLayer(b),this.onLayerLoaded_()},a.Deserializer.prototype.onLayerLoaded_=function(){this.layersToLoad_=this.layersToLoad_-1,0===this.layersToLoad_&&this.callback_(this.piskel_)}}(),function(){var a=$.namespace("pskl.utils.serialization.backward");a.Deserializer_v0=function(a,b){this.data_=a,this.callback_=b},a.Deserializer_v0.prototype.deserialize=function(){var a=this.data_,b=a.map(function(a){return pskl.model.Frame.fromPixelGrid(a)}),c=new pskl.model.piskel.Descriptor("Deserialized piskel",""),d=pskl.model.Layer.fromFrames("Layer 1",b);this.callback_(pskl.model.Piskel.fromLayers([d],c))}}(),function(){var a=$.namespace("pskl.utils.serialization.backward");a.Deserializer_v1=function(a,b){this.callback_=b,this.data_=a},a.Deserializer_v1.prototype.deserialize=function(){var a=this.data_.piskel,b=new pskl.model.piskel.Descriptor("Deserialized piskel",""),c=new pskl.model.Piskel(a.width,a.height,b);a.layers.forEach(function(a){var b=this.deserializeLayer(a);c.addLayer(b)}.bind(this)),this.callback_(c)},a.Deserializer_v1.prototype.deserializeLayer=function(a){var b=JSON.parse(a),c=new pskl.model.Layer(b.name);return b.frames.forEach(function(a){var b=this.deserializeFrame(a);c.addFrame(b)}.bind(this)),c},a.Deserializer_v1.prototype.deserializeFrame=function(a){var b=JSON.parse(a);return pskl.model.Frame.fromPixelGrid(b)}}(),function(){var a=function(){(function(a){function b(a,c){if({}.hasOwnProperty.call(b.cache,a))return b.cache[a];var d=b.resolve(a);if(!d)throw new Error("Failed to resolve module "+a);var e={id:a,require:b,filename:a,exports:{},loaded:!1,parent:c,children:[]};c&&c.children.push(e);var f=a.slice(0,a.lastIndexOf("/")+1);return b.cache[a]=e.exports,d.call(e.exports,e,e.exports,f,a),e.loaded=!0,b.cache[a]=e.exports}b.modules={},b.cache={},b.resolve=function(a){return{}.hasOwnProperty.call(b.modules,a)?b.modules[a]:void 0},b.define=function(a,c){b.modules[a]=c},b.define("/gif.worker.coffee",function(a,c,d,e){var f,g;f=b("/GIFEncoder.js",a),g=function(a){var b,c,d,e;return b=new f(a.width,a.height),0===a.index?b.writeHeader():b.firstFrame=!1,b.setTransparent(a.transparent),b.setRepeat(a.repeat),b.setDelay(a.delay),b.setQuality(a.quality),b.setPreserveColors(a.preserveColors),b.addFrame(a.data),a.last&&b.finish(),d=b.stream(),a.data=d.pages,a.cursor=d.cursor,a.pageSize=d.constructor.pageSize,a.canTransfer?(e=function(b){for(var d=0,e=a.data.length;e>d;++d)c=a.data[d],b.push(c.buffer);return b}.call(this,[]),self.postMessage(a,e)):self.postMessage(a)},self.onmessage=function(a){return g(a.data)}}),b.define("/GIFEncoder.js",function(a,c,d,e){function f(){this.page=-1,this.pages=[],this.newPage()}function g(a,b){this.width=~~a,this.height=~~b,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.preserveColors=!1,this.out=new f}var h=b("/TypedNeuQuant.js",a),i=b("/SimpleQuant.js",a),j=b("/LZWEncoder.js",a);f.pageSize=4096,f.charMap={};for(var k=0;256>k;k++)f.charMap[k]=String.fromCharCode(k);f.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(f.pageSize),this.cursor=0},f.prototype.getData=function(){for(var a="",b=0;b=f.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=a},f.prototype.writeUTFBytes=function(a){for(var b=a.length,c=0;b>c;c++)this.writeByte(a.charCodeAt(c))},f.prototype.writeBytes=function(a,b,c){for(var d=c||a.length,e=b||0;d>e;e++)this.writeByte(a[e])},g.prototype.setDelay=function(a){this.delay=Math.round(a/10)},g.prototype.setFrameRate=function(a){ -this.delay=Math.round(100/a)},g.prototype.setDispose=function(a){a>=0&&(this.dispose=a)},g.prototype.setRepeat=function(a){this.repeat=a},g.prototype.setTransparent=function(a){this.transparent=a},g.prototype.addFrame=function(a){this.image=a,this.getImagePixels(),this.analyzePixels(),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.writePixels(),this.firstFrame=!1},g.prototype.finish=function(){this.out.writeByte(59)},g.prototype.setQuality=function(a){1>a&&(a=1),this.sample=a},g.prototype.setPreserveColors=function(a){this.preserveColors=a},g.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},g.prototype.analyzePixels=function(){var a=this.pixels.length,b=a/3;this.indexedPixels=new Uint8Array(b);var c;c=this.preserveColors?new i(this.pixels,this.sample):new h(this.pixels,this.sample),c.buildColormap(),this.colorTab=c.getColormap();for(var d=0,e=0;b>e;e++){var f=c.lookupRGB(255&this.pixels[d++],255&this.pixels[d++],255&this.pixels[d++]);this.usedEntry[f]=!0,this.indexedPixels[e]=f}this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent))},g.prototype.findClosest=function(a){if(null===this.colorTab)return-1;for(var b=(16711680&a)>>16,c=(65280&a)>>8,d=255&a,e=0,f=16777216,g=this.colorTab.length,h=0;g>h;){var i=b-(255&this.colorTab[h++]),j=c-(255&this.colorTab[h++]),k=d-(255&this.colorTab[h]),l=i*i+j*j+k*k,m=parseInt(h/3);this.usedEntry[m]&&f>l&&(f=l,e=m),h++}return e},g.prototype.getImagePixels=function(){var a=this.width,b=this.height;this.pixels=new Uint8Array(a*b*3);for(var c=this.image,d=0,e=0;b>e;e++)for(var f=0;a>f;f++){var g=e*a*4+4*f;this.pixels[d++]=c[g],this.pixels[d++]=c[g+1],this.pixels[d++]=c[g+2]}},g.prototype.writeGraphicCtrlExt=function(){this.out.writeByte(33),this.out.writeByte(249),this.out.writeByte(4);var a,b;null===this.transparent?(a=0,b=0):(a=1,b=2),this.dispose>=0&&(b=7&dispose),b<<=2,this.out.writeByte(0|b|0|a),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},g.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(this.firstFrame?0:128|this.palSize)},g.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},g.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},g.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var a=768-this.colorTab.length,b=0;a>b;b++)this.out.writeByte(0)},g.prototype.writeShort=function(a){this.out.writeByte(255&a),this.out.writeByte(a>>8&255)},g.prototype.writePixels=function(){var a=new j(this.width,this.height,this.indexedPixels,this.colorDepth);a.encode(this.out)},g.prototype.stream=function(){return this.out},a.exports=g}),b.define("/LZWEncoder.js",function(a,b,c,d){function e(a,b,c,d){function e(a,b){y[s++]=a,s>=254&&n(b)}function j(a){k(h),C=v+2,D=!0,q(v,a)}function k(a){for(var b=0;a>b;++b)z[b]=-1}function l(a,b){var c,d,e,i,l,m,n;for(u=a,D=!1,n_bits=u,t=o(n_bits),v=1<c;c*=2)++n;n=8-n,m=h,k(m),q(v,b);a:for(;(d=p())!=f;)if(c=(d<=0){l=m-e,0===e&&(l=1);do if((e-=l)<0&&(e+=m),z[e]===c){i=A[e];continue a}while(z[e]>=0)}q(i,b),i=d,1<C?(A[e]=C++,z[e]=c):j(b)}else i=A[e];q(i,b),q(w,b)}function m(c){c.writeByte(x),remaining=a*b,curPixel=0,l(x+1,c),c.writeByte(0)}function n(a){s>0&&(a.writeByte(s),a.writeBytes(y,0,s),s=0)}function o(a){return(1<0?r|=a<=8;)e(255&r,b),r>>=8,B-=8;if((C>t||D)&&(D?(t=o(n_bits=u),D=!1):(++n_bits,t=n_bits==g?1<0;)e(255&r,b),r>>=8,B-=8;n(b)}}var r,s,t,u,v,w,x=Math.max(2,d),y=new Uint8Array(256),z=new Int32Array(h),A=new Int32Array(h),B=0,C=0,D=!1;this.encode=m}var f=-1,g=12,h=5003,i=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];a.exports=e}),b.define("/SimpleQuant.js",function(a,b,c,d){function e(a,b,c){return[a,b,c].join(".")}function f(a){this.pixels=a,this.palette=[],this.paletteIndex={},this.getColormap=function(){return this.palette},this.buildColormap=function(){for(var a=this.pixels.length/3,b=0,c=0;a>c;c++){var d=this.pixels[b++],f=this.pixels[b++],g=this.pixels[b++],h=e(d,f,g);this.paletteIndex[h]||(this.palette.push(d),this.palette.push(f),this.palette.push(g),this.paletteIndex[h]=this.palette.length/3-1)}},this.lookupRGB=function(a,b,c){return this.paletteIndex[e(a,b,c)]}}a.exports=f}),b.define("/TypedNeuQuant.js",function(a,b,c,d){function e(a,b){function c(){H=[],I=new Int32Array(256),J=new Int32Array(g),K=new Int32Array(g),L=new Int32Array(g>>3);var a,b;for(a=0;g>a;a++)b=(a<a;a++)H[a][0]>>=i,H[a][1]>>=i,H[a][2]>>=i,H[a][3]=a}function e(a,b,c,d,e){H[b][0]-=a*(H[b][0]-c)/v,H[b][1]-=a*(H[b][1]-d)/v,H[b][2]-=a*(H[b][2]-e)/v}function p(a,b,c,d,e){for(var f,h,i=Math.abs(b-a),j=Math.min(b+a,g),k=b+1,l=b-1,m=1;j>k||l>i;)h=L[m++],j>k&&(f=H[k++],f[0]-=h*(f[0]-c)/z,f[1]-=h*(f[1]-d)/z,f[2]-=h*(f[2]-e)/z),l>i&&(f=H[l--],f[0]-=h*(f[0]-c)/z,f[1]-=h*(f[1]-d)/z,f[2]-=h*(f[2]-e)/z)}function r(a,b,c){var d,e,f,h,k,p=2147483647,q=p,r=-1,s=r;for(d=0;g>d;d++)e=H[d],f=Math.abs(e[0]-a)+Math.abs(e[1]-b)+Math.abs(e[2]-c),p>f&&(p=f,r=d),h=f-(J[d]>>j-i),q>h&&(q=h,s=d),k=K[d]>>m,K[d]-=k,J[d]+=k<a;a++){for(c=H[a],e=a,f=c[1],b=a+1;g>b;b++)d=H[b],d[1]>1,b=i+1;f>b;b++)I[b]=a;i=f,j=a}}for(I[i]=j+h>>1,b=i+1;256>b;b++)I[b]=h}function w(a,b,c){for(var d,e,f,h=1e3,i=-1,j=I[b],k=j-1;g>j||k>=0;)g>j&&(e=H[j],f=e[1]-b,f>=h?j=g:(j++,0>f&&(f=-f),d=e[0]-a,0>d&&(d=-d),f+=d,h>f&&(d=e[2]-c,0>d&&(d=-d),f+=d,h>f&&(h=f,i=e[3])))),k>=0&&(e=H[k],f=b-e[1],f>=h?k=-1:(k--,0>f&&(f=-f),d=e[0]-a,0>d&&(d=-d),f+=d,h>f&&(d=e[2]-c,0>d&&(d=-d),f+=d,h>f&&(h=f,i=e[3]))));return i}function y(){var c,d=a.length,g=30+(b-1)/3,h=d/(3*b),j=~~(h/f),k=v,l=s,m=l>>q;for(1>=m&&(m=0),c=0;m>c;c++)L[c]=k*((m*m-c*c)*x/(m*m));var n;E>d?(b=1,n=3):n=d%A!==0?3*A:d%B!==0?3*B:d%C!==0?3*C:3*D;var o,u,w,y,z=0;for(c=0;h>c;)if(o=(255&a[z])<=d&&(z-=d),c++,0===j&&(j=1),c%j===0)for(k-=k/g,l-=l/t,m=l>>q,1>=m&&(m=0),y=0;m>y;y++)L[y]=k*((m*m-y*y)*x/(m*m))}function F(){c(),y(),d(),u()}function G(){for(var a=[],b=[],c=0;g>c;c++)b[H[c][3]]=c;for(var d=0,e=0;g>e;e++){var f=b[e];a[d++]=H[f][0],a[d++]=H[f][1],a[d++]=H[f][2]}return a}var H,I,J,K,L;this.buildColormap=F,this.getColormap=G,this.lookupRGB=w}var f=100,g=256,h=g-1,i=4,j=16,k=1<>m,o=k<>3,q=6,r=1<c;++c)if(c in b&&b[c]===a)return!0;return!1}function h(a,b){function c(){this.constructor=a}for(var d in b)f(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a}var i,j,k,l,m;k=b("events",a).EventEmitter,i=b("/browser.coffee",a),m=function(a){function b(a){var b,c;this.running=!1,this.options={},this.frames=[],this.freeWorkers=[],this.activeWorkers=[],this.setOptions(a);for(b in j)c=j[b],null!=this.options[b]?this.options[b]:this.options[b]=c}return h(b,a),j={workerScript:window.GifWorkerURL,workers:2,repeat:0,background:"#fff",quality:10,width:null,height:null,transparent:null,preserveColors:!1},l={delay:500,copy:!1},b.prototype.setOption=function(a,b){return this.options[a]=b,null==this._canvas||"width"!==a&&"height"!==a?void 0:this._canvas[a]=b},b.prototype.setOptions=function(a){var b,c;return function(d){for(b in a)f(a,b)&&(c=a[b],d.push(this.setOption(b,c)));return d}.call(this,[])},b.prototype.addFrame=function(a,b){var c,d;null==b&&(b={}),c={},c.transparent=this.options.transparent;for(d in l)c[d]=b[d]||l[d];if(null!=this.options.width||this.setOption("width",a.width),null!=this.options.height||this.setOption("height",a.height),"undefined"!=typeof ImageData&&null!=ImageData&&a instanceof ImageData)c.data=a.data;else if("undefined"!=typeof CanvasRenderingContext2D&&null!=CanvasRenderingContext2D&&a instanceof CanvasRenderingContext2D||"undefined"!=typeof WebGLRenderingContext&&null!=WebGLRenderingContext&&a instanceof WebGLRenderingContext)b.copy?c.data=this.getContextData(a):c.context=a;else{if(null==a.childNodes)throw new Error("Invalid image");b.copy?c.data=this.getImageData(a):c.image=a}return this.frames.push(c)},b.prototype.render=function(){var a,b;if(this.running)throw new Error("Already running");if(null==this.options.width||null==this.options.height)throw new Error("Width and height must be set prior to rendering");this.running=!0,this.nextFrame=0,this.finishedFrames=0,this.imageParts=function(b){for(var c=function(){var a;a=[];for(var b=0;0<=this.frames.length?bthis.frames.length;0<=this.frames.length?++b:--b)a.push(b);return a}.apply(this,arguments),d=0,e=c.length;e>d;++d)a=c[d],b.push(null);return b}.call(this,[]),b=this.spawnWorkers();for(var c=function(){var a;a=[];for(var c=0;b>=0?b>c:c>b;b>=0?++c:--c)a.push(c);return a}.apply(this,arguments),d=0,e=c.length;e>d;++d)a=c[d],this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},b.prototype.abort=function(){for(var a;;){if(a=this.activeWorkers.shift(),!(null!=a))break;console.log("killing active worker"),a.terminate()}return this.running=!1,this.emit("abort")},b.prototype.spawnWorkers=function(){var a;return a=Math.min(this.options.workers,this.frames.length),function(){var b;b=[];for(var c=this.freeWorkers.length;this.freeWorkers.length<=a?a>c:c>a;this.freeWorkers.length<=a?++c:--c)b.push(c);return b}.apply(this,arguments).forEach(function(a){return function(b){var c;return console.log("spawning worker "+b),c=new Worker(a.options.workerScript),c.onmessage=function(a){return function(b){return a.activeWorkers.splice(a.activeWorkers.indexOf(c),1),a.freeWorkers.push(c),a.frameFinished(b.data)}}(a),a.freeWorkers.push(c)}}(this)),a},b.prototype.frameFinished=function(a){return console.log("frame "+a.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[a.index]=a,g(null,this.imageParts)?this.renderNextFrame():this.finishRendering()},b.prototype.finishRendering=function(){var a,b,c,d,e,f,g;e=0;for(var h=0,i=this.imageParts.length;i>h;++h)b=this.imageParts[h],e+=(b.data.length-1)*b.pageSize+b.cursor;e+=b.pageSize-b.cursor,console.log("rendering finished - filesize "+Math.round(e/1e3)+"kb"),a=new Uint8Array(e),f=0;for(var j=0,k=this.imageParts.length;k>j;++j){b=this.imageParts[j];for(var l=0,m=b.data.length;m>l;++l)g=b.data[l],c=l,a.set(g,f),f+=c===b.data.length-1?b.cursor:b.pageSize}return d=new Blob([a],{type:"image/gif"}),this.emit("finished",d,a)},b.prototype.renderNextFrame=function(){var a,b,c;if(0===this.freeWorkers.length)throw new Error("No free workers");return this.nextFrame>=this.frames.length?void 0:(a=this.frames[this.nextFrame++],c=this.freeWorkers.shift(),b=this.getTask(a),console.log("starting frame "+(b.index+1)+" of "+this.frames.length),this.activeWorkers.push(c),c.postMessage(b))},b.prototype.getContextData=function(a){return a.getImageData(0,0,this.options.width,this.options.height).data},b.prototype.getImageData=function(a){var b;return null!=this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),b=this._canvas.getContext("2d"),b.setFill=this.options.background,b.fillRect(0,0,this.options.width,this.options.height),b.drawImage(a,0,0),this.getContextData(b)},b.prototype.getTask=function(a){var b,c;if(b=this.frames.indexOf(a),c={index:b,last:b===this.frames.length-1,delay:a.delay,transparent:a.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,preserveColors:this.options.preserveColors,repeat:this.options.repeat,canTransfer:"chrome"===i.name},null!=a.data)c.data=a.data;else if(null!=a.context)c.data=this.getContextData(a.context);else{if(null==a.image)throw new Error("Invalid frame");c.data=this.getImageData(a.image)}return c},b}(k),a.exports=m}),b.define("/browser.coffee",function(a,b,c,d){var e,f,g,h,i;h=navigator.userAgent.toLowerCase(),g=navigator.platform.toLowerCase(),i=h.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0],f="ie"===i[1]&&document.documentMode,e={name:"version"===i[1]?i[3]:i[1],version:f||parseFloat("opera"===i[1]&&i[4]?i[4]:i[2]),platform:{name:h.match(/ip(?:ad|od|hone)/)?"ios":(h.match(/(?:webos|android)/)||g.match(/mac|win|linux/)||["other"])[0]}},e[e.name]=!0,e[e.name+parseInt(e.version,10)]=!0,e.platform[e.platform.name]=!0,a.exports=e}),b.define("events",function(a,b,d,e){c.EventEmitter||(c.EventEmitter=function(){});var f=b.EventEmitter=c.EventEmitter,g="function"==typeof Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if("error"===a&&(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if("function"!=typeof b){if(g(b)){for(var c=Array.prototype.slice.call(arguments,1),d=b.slice(),e=0,f=d.length;f>e;e++)d[e].apply(this,c);return!0}return!1}switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(0>d)return this;c.splice(d,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),a.GIF=b("/gif.coffee")}.call(this,this),function(a){"use strict";var b=function(a){this.data=a,this.len=this.data.length,this.pos=0};b.prototype.readByte=function(){if(this.pos>=this.data.length)throw new Error("Attempted to read past end of stream.");return 255&this.data.charCodeAt(this.pos++)},b.prototype.readBytes=function(a){for(var b=[],c=0;a>c;c++)b.push(this.readByte());return b},b.prototype.read=function(a){for(var b="",c=0;a>c;c++)b+=String.fromCharCode(this.readByte());return b},b.prototype.readUnsigned=function(){var a=this.readBytes(2);return(a[1]<<8)+a[0]};var c=a.SuperGIF=a.SuperGIF||{};c.Stream=b}(window),function(a){"use strict";var b=function(a){return a.reduce(function(a,b){return 2*a+b},0)},c=function(a){for(var b=[],c=7;c>=0;c--)b.push(!!(a&1<=this.data.length)throw new Error("Attempted to read past end of stream.");return 255&a.charCodeAt(this.pos++)},this.readBytes=function(a){for(var b=[],c=0;a>c;c++)b.push(this.readByte());return b},this.read=function(a){for(var b="",c=0;a>c;c++)b+=String.fromCharCode(this.readByte());return b},this.readUnsigned=function(){var a=this.readBytes(2);return(a[1]<<8)+a[0]}},e=function(a,b){for(var c,d,e=0,f=function(a){for(var c=0,d=0;a>d;d++)b.charCodeAt(e>>3)&1<<(7&e)&&(c|=1<b;b++)k[b]=[b];k[h]=[],k[i]=null};;)if(d=c,c=f(j),c!==h){if(c===i)break;if(cj&&j++}else l();return g},f=function(a,d){d||(d={});var f=function(b){for(var c=[],d=0;b>d;d++)c.push(a.readBytes(3));return c},g=function(){var b,c;c="";do b=a.readByte(),c+=a.read(b);while(0!==b);return c},h=function(){var e={};if(e.sig=a.read(3),e.ver=a.read(3),"GIF"!==e.sig)throw d.onError(),new Error("Not a GIF file.");e.width=a.readUnsigned(),e.height=a.readUnsigned();var g=c(a.readByte());e.gctFlag=g.shift(),e.colorRes=b(g.splice(0,3)),e.sorted=g.shift(),e.gctSize=b(g.splice(0,3)),e.bgColor=a.readByte(),e.pixelAspectRatio=a.readByte(),e.gctFlag&&(e.gct=f(1<i;i++)for(var j=f[i];d>j;j+=g[i])e(j,h),h++;return c};h.leftPos=a.readUnsigned(),h.topPos=a.readUnsigned(),h.width=a.readUnsigned(),h.height=a.readUnsigned();var j=c(a.readByte());h.lctFlag=j.shift(),h.interlaced=j.shift(),h.sorted=j.shift(),h.reserved=j.splice(0,2),h.lctSize=b(j.splice(0,3)),h.lctFlag&&(h.lct=f(1<0&&(3===o?p.putImageData(r[n].data,0,0):n=b-1,2===o&&p.clearRect(q.leftPos,q.topPos,q.width,q.height));var d=p.getImageData(a.leftPos,a.topPos,a.width,a.height),e=d.data;a.pixels.forEach(function(a,b){a!==k&&(e[4*b+0]=c[a][0],e[4*b+1]=c[a][1],e[4*b+2]=c[a][2],e[4*b+3]=255)}),p.putImageData(d,a.leftPos,a.topPos),q=a},B={hdr:x,gce:y,img:A,eof:function(a){z(),j=!1,C&&C()},onError:function(a){E&&E()}},C=!1,D=!1,E=!1,F=document.createElement("canvas");return{load:function(b){if(C=b.success,D=b.step,E=b.error,j=!0,-1!==s.src.indexOf("data:")){var c=s.src.substring(s.src.indexOf(",")+1);g=new d(a.atob(c)),u()}else{var e=new XMLHttpRequest;e.overrideMimeType("text/plain; charset=x-user-defined"),e.onload=function(a){g=new d(e.responseText),setTimeout(u,0)},e.onerror=function(){w("xhr")},e.open("GET",s.getAttribute("data-animated-src")||s.src,!0),e.send()}},getFrames:function(){return r}}};a.SuperGif=g}(window),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZip=a():"undefined"!=typeof global?global.JSZip=a():"undefined"!=typeof self&&(self.JSZip=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":6}],4:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":14}],5:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.date=null,c.compression=null},{}],6:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("zlibjs/bin/rawdeflate.min").Zlib,f=a("zlibjs/bin/rawinflate.min").Zlib;c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a){var b=new e.RawDeflate(a);return b.compress()},c.uncompress=function(a){var b=new f.RawInflate(a);return b.decompress()}},{"zlibjs/bin/rawdeflate.min":19,"zlibjs/bin/rawinflate.min":20}],7:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./utils"),c.base64=a("./base64"),c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":5,"./load":8,"./object":9,"./support":12,"./utils":14}],8:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},r=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},v=function(a){return"/"!=a.slice(-1)&&(a+="/"),this.files[a]||t.call(this,a,null,{dir:!0}),this.files[a]},w=function(a,b){var c,d=new k;return a._data instanceof k?(d.uncompressedSize=a._data.uncompressedSize,d.crc32=a._data.crc32,0===d.uncompressedSize||a.options.dir?(b=j.STORE,d.compressedContent="",d.crc32=0):a._data.compressionMethod===b.magic?d.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c)))):(c=n(a),(!c||0===c.length||a.options.dir)&&(b=j.STORE,c=""),d.uncompressedSize=c.length,d.crc32=this.crc32(c),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c))),d.compressedSize=d.compressedContent.length,d.compressionMethod=b.magic,d},x=function(a,b,c,d){var e,f,h=(c.compressedContent,this.utf8encode(b.name)),i=h!==b.name,j=b.options,k="",l="";e=j.date.getHours(),e<<=6,e|=j.date.getMinutes(),e<<=5,e|=j.date.getSeconds()/2,f=j.date.getFullYear()-1980,f<<=4,f|=j.date.getMonth()+1,f<<=5,f|=j.date.getDate(),i&&(l=q(1,1)+q(this.crc32(h),4)+h,k+="up"+q(l.length,2)+l);var m="";m+="\n\x00",m+=i?"\x00\b":"\x00\x00",m+=c.compressionMethod,m+=q(e,2),m+=q(f,2),m+=q(c.crc32,4),m+=q(c.compressedSize,4),m+=q(c.uncompressedSize,4),m+=q(h.length,2),m+=q(k.length,2);var n=g.LOCAL_FILE_HEADER+m+h+k,o=g.CENTRAL_FILE_HEADER+"\x00"+m+"\x00\x00\x00\x00\x00\x00"+(b.options.dir===!0?"\x00\x00\x00":"\x00\x00\x00\x00")+q(d,4)+h+k;return{fileRecord:n,dirRecord:o,compressedObject:c}},y=function(){this.data=[]};y.prototype={append:function(a){a=f.transformTo("string",a),this.data.push(a)},finalize:function(){return this.data.join("")}};var z=function(a){this.data=new Uint8Array(a),this.index=0};z.prototype={append:function(a){0!==a.length&&(a=f.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}};var A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new p(d.name,d._data,r(d.options)),c=b.slice(this.root.length,b.length), -b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(f.isRegExp(a)){var d=a;return this.filter(function(a,b){return!b.options.dir&&d.test(a)})}return this.filter(function(b,c){return!c.options.dir&&b===a})[0]||null}return a=this.root+a,t.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(f.isRegExp(a))return this.filter(function(b,c){return c.options.dir&&a.test(b)});var b=this.root+a,c=v.call(this,b),d=this.clone();return d.root=c.name,d},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b)if(b.options.dir)for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;di;i++)h=c?a[i]:a.charCodeAt(i),g=255&(b^h),e=d[g],b=b>>>8^e;return-1^b},utf8encode:function(a){if(c){var b=c.encode(a);return f.transformTo("string",b)}if(e.nodebuffer)return f.transformTo("string",l(a,"utf-8"));for(var d=[],g=0,h=0;hi?d[g++]=String.fromCharCode(i):i>127&&2048>i?(d[g++]=String.fromCharCode(i>>6|192),d[g++]=String.fromCharCode(63&i|128)):(d[g++]=String.fromCharCode(i>>12|224),d[g++]=String.fromCharCode(i>>6&63|128),d[g++]=String.fromCharCode(63&i|128))}return d.join("")},utf8decode:function(a){var b=[],c=0,g=f.getTypeOf(a),h="string"!==g,i=0,j=0,k=0,l=0;if(d)return d.decode(f.transformTo("uint8array",a));if(e.nodebuffer)return f.transformTo("nodebuffer",a).toString("utf-8");for(;ij?(b[c++]=String.fromCharCode(j),i++):j>191&&224>j?(k=h?a[i+1]:a.charCodeAt(i+1),b[c++]=String.fromCharCode((31&j)<<6|63&k),i+=2):(k=h?a[i+1]:a.charCodeAt(i+1),l=h?a[i+2]:a.charCodeAt(i+2),b[c++]=String.fromCharCode((15&j)<<12|(63&k)<<6|63&l),i+=3);return b.join("")}};b.exports=A},{"./base64":1,"./compressedObject":2,"./compressions":3,"./defaults":5,"./nodeBuffer":17,"./signature":10,"./support":12,"./utils":14}],10:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],11:[function(a,b){"use strict";function c(a,b){this.data=a,b||(this.data=e.string2binary(this.data)),this.length=this.data.length,this.index=0}var d=a("./dataReader"),e=a("./utils");c.prototype=new d,c.prototype.byteAt=function(a){return this.data.charCodeAt(a)},c.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4,"./utils":14}],12:[function(a,b,c){var d=a("__browserify_process");if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c.nodebuffer=!d.browser,c.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)c.blob=!1;else{var e=new ArrayBuffer(0);try{c.blob=0===new Blob([e],{type:"application/zip"}).size}catch(f){try{var g=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,h=new g;h.append(e),c.blob=0===h.getBlob("application/zip").size}catch(f){c.blob=!1}}}},{__browserify_process:18}],13:[function(a,b){"use strict";function c(a){a&&(this.data=a,this.length=this.data.length,this.index=0)}var d=a("./dataReader");c.prototype=new d,c.prototype.byteAt=function(a){return this.data[a]},c.prototype.lastIndexOfSignature=function(a){for(var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.length-4;f>=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4}],14:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":17,"./support":12}],15:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],19:[function(){(function(){"use strict";function a(a,b){var c=a.split("."),d=n;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||b===l?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a,b){if(this.index="number"==typeof b?b:0,this.d=0,this.buffer=a instanceof(o?Uint8Array:Array)?a:new(o?Uint8Array:Array)(32768),2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&c(this)}function c(a){var b,c=a.buffer,d=c.length,e=new(o?Uint8Array:Array)(d<<1);if(o)e.set(c);else for(b=0;d>b;++b)e[b]=c[b];return a.buffer=e}function d(a){this.buffer=new(o?Uint16Array:Array)(2*a),this.length=0}function e(a,b){this.e=w,this.f=0,this.input=o&&a instanceof Array?new Uint8Array(a):a,this.c=0,b&&(b.lazy&&(this.f=b.lazy),"number"==typeof b.compressionType&&(this.e=b.compressionType),b.outputBuffer&&(this.b=o&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"==typeof b.outputIndex&&(this.c=b.outputIndex)),this.b||(this.b=new(o?Uint8Array:Array)(32768))}function f(a,b){this.length=a,this.g=b}function g(a,b){function c(a,b){var c,d=a.g,e=[],f=0;c=z[a.length],e[f++]=65535&c,e[f++]=c>>16&255,e[f++]=c>>24;var g;switch(m){case 1===d:g=[0,d-1,0];break;case 2===d:g=[1,d-2,0];break;case 3===d:g=[2,d-3,0];break;case 4===d:g=[3,d-4,0];break;case 6>=d:g=[4,d-5,1];break;case 8>=d:g=[5,d-7,1];break;case 12>=d:g=[6,d-9,2];break;case 16>=d:g=[7,d-13,2];break;case 24>=d:g=[8,d-17,3];break;case 32>=d:g=[9,d-25,3];break;case 48>=d:g=[10,d-33,4];break;case 64>=d:g=[11,d-49,4];break;case 96>=d:g=[12,d-65,5];break;case 128>=d:g=[13,d-97,5];break;case 192>=d:g=[14,d-129,6];break;case 256>=d:g=[15,d-193,6];break;case 384>=d:g=[16,d-257,7];break;case 512>=d:g=[17,d-385,7];break;case 768>=d:g=[18,d-513,8];break;case 1024>=d:g=[19,d-769,8];break;case 1536>=d:g=[20,d-1025,9];break;case 2048>=d:g=[21,d-1537,9];break;case 3072>=d:g=[22,d-2049,10];break;case 4096>=d:g=[23,d-3073,10];break;case 6144>=d:g=[24,d-4097,11];break;case 8192>=d:g=[25,d-6145,11];break;case 12288>=d:g=[26,d-8193,12];break;case 16384>=d:g=[27,d-12289,12];break;case 24576>=d:g=[28,d-16385,13];break;case 32768>=d:g=[29,d-24577,13];break;default:throw"invalid distance"}c=g,e[f++]=c[0],e[f++]=c[1],e[f++]=c[2];var h,i;for(h=0,i=e.length;i>h;++h)r[s++]=e[h];u[e[0]]++,v[e[3]]++,t=a.length+b-1,n=null}var d,e,f,g,i,j,k,n,p,q={},r=o?new Uint16Array(2*b.length):[],s=0,t=0,u=new(o?Uint32Array:Array)(286),v=new(o?Uint32Array:Array)(30),w=a.f;if(!o){for(f=0;285>=f;)u[f++]=0;for(f=0;29>=f;)v[f++]=0}for(u[256]=1,d=0,e=b.length;e>d;++d){for(f=i=0,g=3;g>f&&d+f!==e;++f)i=i<<8|b[d+f];if(q[i]===l&&(q[i]=[]),j=q[i],!(0=e){for(n&&c(n,-1),f=0,g=e-d;g>f;++f)p=b[d+f],r[s++]=p,++u[p];break}0h;h++){if(d=c[j-h-1],g=3,k>3){for(i=k;i>3;i--)if(a[d+i-1]!==a[b+i-1])continue a;g=k}for(;258>g&&l>b+g&&a[d+g]===a[b+g];)++g;if(g>k&&(e=d,k=g),258===g)break}return new f(k,b-e)}function i(a,b){var c,e,f,g,h,i=a.length,k=new d(572),l=new(o?Uint8Array:Array)(i);if(!o)for(g=0;i>g;g++)l[g]=0;for(g=0;i>g;++g)0g;++g)c[g]=k.pop(),e[g]=c[g].value;for(f=j(e,e.length,b),g=0,h=c.length;h>g;++g)l[c[g].index]=f[g];return l}function j(a,b,c){function d(a){var c=n[a][p[a]];c===b?(d(a+1),d(a+1)):--l[c],++p[a]}var e,f,g,h,i,j=new(o?Uint16Array:Array)(c),k=new(o?Uint8Array:Array)(c),l=new(o?Uint8Array:Array)(b),m=Array(c),n=Array(c),p=Array(c),q=(1<f;++f)r>q?k[f]=0:(k[f]=1,q-=r),q<<=1,j[c-2-f]=(j[c-1-f]/2|0)+b;for(j[0]=k[0],m[0]=Array(j[0]),n[0]=Array(j[0]),f=1;c>f;++f)j[f]>2*j[f-1]+k[f]&&(j[f]=2*j[f-1]+k[f]),m[f]=Array(j[f]),n[f]=Array(j[f]);for(e=0;b>e;++e)l[e]=c;for(g=0;ge;++e)p[e]=0;for(1===k[c-1]&&(--l[0],++p[c-1]),f=c-2;f>=0;--f){for(h=e=0,i=p[f+1],g=0;ga[e]?(m[f][g]=h,n[f][g]=b,i+=2):(m[f][g]=a[e],n[f][g]=e,++e);p[f]=0,1===k[f]&&d(f)}return l}function k(a){var b,c,d,e,f=new(o?Uint16Array:Array)(a.length),g=[],h=[],i=0;for(b=0,c=a.length;c>b;b++)g[a[b]]=(0|g[a[b]])+1;for(b=1,c=16;c>=b;b++)h[b]=i,i+=0|g[b],i<<=1;for(b=0,c=a.length;c>b;b++)for(i=h[a[b]],h[a[b]]+=1,d=f[b]=0,e=a[b];e>d;d++)f[b]=f[b]<<1|1&i,i>>>=1;return f}var l=void 0,m=!0,n=this,o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;b.prototype.a=function(a,b,d){var e,f=this.buffer,g=this.index,h=this.d,i=f[g];if(d&&b>1&&(a=b>8?(u[255&a]<<24|u[a>>>8&255]<<16|u[a>>>16&255]<<8|u[a>>>24&255])>>32-b:u[a]>>8-b),8>b+h)i=i<e;++e)i=i<<1|a>>b-e-1&1,8===++h&&(h=0,f[g++]=u[i],i=0,g===f.length&&(f=c(this)));f[g]=i,this.buffer=f,this.d=h,this.index=g},b.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0p;++p){for(var r=p,s=r,t=7,r=r>>>1;r;r>>>=1)s<<=1,s|=1&r,--t;q[p]=(s<>>0}var u=q;d.prototype.getParent=function(a){return 2*((a-2)/4|0)},d.prototype.push=function(a,b){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=b,f[this.length++]=a;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},d.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;for(b=f[0],a=f[1],this.length-=2,f[0]=f[this.length],f[1]=f[this.length+1],e=0;d=2*e+2,!(d>=this.length)&&(d+2f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.length}};var v,w=2,x=[];for(v=0;288>v;v++)switch(m){case 143>=v:x.push([v+48,8]);break;case 255>=v:x.push([v-144+400,9]);break;case 279>=v:x.push([v-256+0,7]);break;case 287>=v:x.push([v-280+192,8]);break;default:throw"invalid literal: "+v}e.prototype.h=function(){var a,c,d,e,f=this.input;switch(this.e){case 0:for(d=0,e=f.length;e>d;){c=o?f.subarray(d,d+65535):f.slice(d,d+65535),d+=c.length;var h=c,j=d===e,n=l,p=l,q=l,r=l,s=l,t=this.b,u=this.c;if(o){for(t=new Uint8Array(this.b.buffer);t.length<=u+h.length+5;)t=new Uint8Array(t.length<<1);t.set(this.b)}if(n=j?1:0,t[u++]=0|n,p=h.length,q=~p+65536&65535,t[u++]=255&p,t[u++]=p>>>8&255,t[u++]=255&q,t[u++]=q>>>8&255,o)t.set(h,u),u+=h.length,t=t.subarray(0,u);else{for(r=0,s=h.length;s>r;++r)t[u++]=h[r];t.length=u}this.c=u,this.b=t}break;case 1:var v=new b(o?new Uint8Array(this.b.buffer):this.b,this.c);v.a(1,1,m),v.a(1,2,m);var y,z,A,B=g(this,f);for(y=0,z=B.length;z>y;y++)if(A=B[y],b.prototype.a.apply(v,x[A]),A>256)v.a(B[++y],B[++y],m),v.a(B[++y],5),v.a(B[++y],B[++y],m);else if(256===A)break;this.b=v.finish(),this.c=this.b.length;break;case w:var C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R=new b(o?new Uint8Array(this.b.buffer):this.b,this.c),S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T=Array(19);for(C=w,R.a(1,1,m),R.a(C,2,m),D=g(this,f),H=i(this.j,15),I=k(H),J=i(this.i,7),K=k(J),E=286;E>257&&0===H[E-1];E--);for(F=30;F>1&&0===J[F-1];F--);var U,V,W,X,Y,Z,$=E,_=F,aa=new(o?Uint32Array:Array)($+_),ba=new(o?Uint32Array:Array)(316),ca=new(o?Uint8Array:Array)(19);for(U=V=0;$>U;U++)aa[V++]=H[U];for(U=0;_>U;U++)aa[V++]=J[U];if(!o)for(U=0,X=ca.length;X>U;++U)ca[U]=0;for(U=Y=0,X=aa.length;X>U;U+=V){for(V=1;X>U+V&&aa[U+V]===aa[U];++V);if(W=V,0===aa[U])if(3>W)for(;00;)Z=138>W?W:138,Z>W-3&&W>Z&&(Z=W-3),10>=Z?(ba[Y++]=17,ba[Y++]=Z-3,ca[17]++):(ba[Y++]=18,ba[Y++]=Z-11,ca[18]++),W-=Z;else if(ba[Y++]=aa[U],ca[aa[U]]++,W--,3>W)for(;00;)Z=6>W?W:6,Z>W-3&&W>Z&&(Z=W-3),ba[Y++]=16,ba[Y++]=Z-3,ca[16]++,W-=Z}for(a=o?ba.subarray(0,Y):ba.slice(0,Y),L=i(ca,7),P=0;19>P;P++)T[P]=L[S[P]];for(G=19;G>4&&0===T[G-1];G--);for(M=k(L),R.a(E-257,5,m),R.a(F-1,5,m),R.a(G-4,4,m),P=0;G>P;P++)R.a(T[P],3,m);for(P=0,Q=a.length;Q>P;P++)if(N=a[P],R.a(M[N],L[N],m),N>=16){switch(P++,N){case 16:O=2;break;case 17:O=3;break;case 18:O=7;break;default:throw"invalid code: "+N}R.a(a[P],O,m)}var da,ea,fa,ga,ha,ia,ja,ka,la=[I,H],ma=[K,J];for(ha=la[0],ia=la[1],ja=ma[0],ka=ma[1],da=0,ea=D.length;ea>da;++da)if(fa=D[da],R.a(ha[fa],ia[fa],m),fa>256)R.a(D[++da],D[++da],m),ga=D[++da],R.a(ja[ga],ka[ga],m),R.a(D[++da],D[++da],m);else if(256===fa)break;this.b=R.finish(),this.c=this.b.length;break;default:throw"invalid compression type"}return this.b};var y=function(){function a(a){switch(m){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:throw"invalid length: "+a}}var b,c,d=[];for(b=3;258>=b;b++)c=a(b),d[b]=c[2]<<24|c[1]<<16|c[0];return d}(),z=o?new Uint32Array(y):y;a("Zlib.RawDeflate",e),a("Zlib.RawDeflate.prototype.compress",e.prototype.h);var A,B,C,D,E={NONE:0,FIXED:1,DYNAMIC:w};if(Object.keys)A=Object.keys(E);else for(B in A=[],C=0,E)A[C++]=B;for(C=0,D=A.length;D>C;++C)B=A[C],a("Zlib.RawDeflate.CompressionType."+B,E[B])}).call(this)},{}],20:[function(){(function(){"use strict";function a(a,b){var c=a.split("."),d=g;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a){var b,c,d,e,f,g,i,j,k,l,m=a.length,n=0,o=Number.POSITIVE_INFINITY;for(j=0;m>j;++j)a[j]>n&&(n=a[j]),a[j]=d;){for(j=0;m>j;++j)if(a[j]===d){for(g=0,i=e,k=0;d>k;++k)g=g<<1|1&i,i>>=1;for(l=d<<16|j,k=g;b>k;k+=f)c[k]=l;++e}++d,e<<=1,f<<=1}return[c,n,o]}function c(a,b){switch(this.g=[],this.h=32768,this.c=this.f=this.d=this.k=0,this.input=h?new Uint8Array(a):a,this.l=!1,this.i=j,this.q=!1,(b||!(b={}))&&(b.index&&(this.d=b.index),b.bufferSize&&(this.h=b.bufferSize),b.bufferType&&(this.i=b.bufferType),b.resize&&(this.q=b.resize)),this.i){case i:this.a=32768,this.b=new(h?Uint8Array:Array)(32768+this.h+258);break;case j:this.a=0,this.b=new(h?Uint8Array:Array)(this.h),this.e=this.v,this.m=this.s,this.j=this.t;break;default:throw Error("invalid inflate mode")}}function d(a,b){for(var c,d=a.f,e=a.c,f=a.input,g=a.d,h=f.length;b>e;){if(g>=h)throw Error("input buffer is broken");d|=f[g++]<>>b,a.c=e-b,a.d=g,c}function e(a,b){for(var c,d,e=a.f,f=a.c,g=a.input,h=a.d,i=g.length,j=b[0],k=b[1];k>f&&!(h>=i);)e|=g[h++]<>>16,a.f=e>>d,a.c=f-d,a.d=h,65535&c}function f(a){function c(a,b,c){var f,g,h,i=this.p;for(h=0;a>h;)switch(f=e(this,b)){case 16:for(g=3+d(this,2);g--;)c[h++]=i;break;case 17:for(g=3+d(this,3);g--;)c[h++]=0;i=0;break;case 18:for(g=11+d(this,7);g--;)c[h++]=0;i=0;break;default:i=c[h++]=f}return this.p=i,c}var f,g,i,j,k=d(a,5)+257,l=d(a,5)+1,m=d(a,4)+4,o=new(h?Uint8Array:Array)(n.length);for(j=0;m>j;++j)o[n[j]]=d(a,3);if(!h)for(j=m,m=o.length;m>j;++j)o[n[j]]=0;f=b(o),g=new(h?Uint8Array:Array)(k),i=new(h?Uint8Array:Array)(l),a.p=0,a.j(b(c.call(a,k,f,g)),b(c.call(a,l,f,i)))}var g=this,h="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView,i=0,j=1;c.prototype.u=function(){for(;!this.l;){var a=d(this,3);switch(1&a&&(this.l=!0),a>>>=1){case 0: -var b=this.input,c=this.d,e=this.b,g=this.a,k=b.length,l=void 0,m=void 0,n=e.length,o=void 0;if(this.c=this.f=0,c+1>=k)throw Error("invalid uncompressed block header: LEN");if(l=b[c++]|b[c++]<<8,c+1>=k)throw Error("invalid uncompressed block header: NLEN");if(m=b[c++]|b[c++]<<8,l===~m)throw Error("invalid uncompressed block header: length verify");if(c+l>b.length)throw Error("input buffer is broken");switch(this.i){case i:for(;g+l>e.length;){if(o=n-g,l-=o,h)e.set(b.subarray(c,c+o),g),g+=o,c+=o;else for(;o--;)e[g++]=b[c++];this.a=g,e=this.e(),g=this.a}break;case j:for(;g+l>e.length;)e=this.e({o:2});break;default:throw Error("invalid inflate mode")}if(h)e.set(b.subarray(c,c+l),g),g+=l,c+=l;else for(;l--;)e[g++]=b[c++];this.d=c,this.a=g,this.b=e;break;case 1:this.j(z,B);break;case 2:f(this);break;default:throw Error("unknown BTYPE: "+a)}}return this.m()};var k,l,m=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n=h?new Uint16Array(m):m,o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],p=h?new Uint16Array(o):o,q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],r=h?new Uint8Array(q):q,s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],t=h?new Uint16Array(s):s,u=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],v=h?new Uint8Array(u):u,w=new(h?Uint8Array:Array)(288);for(k=0,l=w.length;l>k;++k)w[k]=143>=k?8:255>=k?9:279>=k?7:8;var x,y,z=b(w),A=new(h?Uint8Array:Array)(30);for(x=0,y=A.length;y>x;++x)A[x]=5;var B=b(A);c.prototype.j=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length-258;256!==(g=e(this,a));)if(256>g)f>=k&&(this.a=f,c=this.e(),f=this.a),c[f++]=g;else for(h=g-257,j=p[h],0=k&&(this.a=f,c=this.e(),f=this.a);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.t=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length;256!==(g=e(this,a));)if(256>g)f>=k&&(c=this.e(),k=c.length),c[f++]=g;else for(h=g-257,j=p[h],0k&&(c=this.e(),k=c.length);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.e=function(){var a,b,c=new(h?Uint8Array:Array)(this.a-32768),d=this.a-32768,e=this.b;if(h)c.set(e.subarray(32768,c.length));else for(a=0,b=c.length;b>a;++a)c[a]=e[a+32768];if(this.g.push(c),this.k+=c.length,h)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];return this.a=32768,e},c.prototype.v=function(a){var b,c,d,e,f=this.input.length/this.d+1|0,g=this.input,i=this.b;return a&&("number"==typeof a.o&&(f=a.o),"number"==typeof a.r&&(f+=a.r)),2>f?(c=(g.length-this.d)/this.n[2],e=258*(c/2)|0,d=eb;++b)for(a=i[b],d=0,e=a.length;e>d;++d)j[f++]=a[d];for(b=32768,c=this.a;c>b;++b)j[f++]=g[b];return this.g=[],this.buffer=j},c.prototype.s=function(){var a,b=this.a;return h?this.q?(a=new Uint8Array(b),a.set(this.b.subarray(0,b))):a=this.b.subarray(0,b):(this.b.length>b&&(this.b.length=b),a=this.b),this.buffer=a},a("Zlib.RawInflate",c),a("Zlib.RawInflate.prototype.decompress",c.prototype.u);var C,D,E,F,G={ADAPTIVE:j,BLOCK:i};if(Object.keys)C=Object.keys(G);else for(D in C=[],E=0,G)C[E++]=D;for(E=0,F=C.length;F>E;++E)D=C[E],a("Zlib.RawInflate.BufferType."+D,G[D])}).call(this)},{}]},{},[7])(7)}),function(a,b,c){function d(a,b,c){for(var d=[],e=0;e')}return"
"+d.join("")+"
"}function e(){for(var a=0;a1&&(delete a.localStorage[W],b.each(e,function(a,b){t(b)}))}catch(f){}try{na=a.localStorage[W].split(";")}catch(f){}}Ka.bind("click.spectrum touchstart.spectrum",function(a){ta||B(),a.stopPropagation(),b(a.target).is("input")||a.preventDefault()}),(sa.is(":disabled")||T.disabled===!0)&&S(),ua.click(j),Ca.change(A),Ca.bind("paste",function(){setTimeout(A,1)}),Ca.keydown(function(a){13==a.keyCode&&A()}),Fa.text(T.cancelText),Fa.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),F("cancel")}),Ga.text(T.chooseText),Ga.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),J()&&(N(!0),F())}),l(Aa,function(a,b,c){ka=a/ea,c.shiftKey&&(ka=Math.round(10*ka)/10),K()}),l(xa,function(a,b){ha=parseFloat(b/ca),K()},y,z),l(va,function(a,b,c){if(c.shiftKey){if(!qa){var d=ia*_,e=aa-ja*aa,f=Math.abs(a-d)>Math.abs(b-e);qa=f?"x":"y"}}else qa=null;var g=!qa||"x"===qa,h=!qa||"y"===qa;g&&(ia=parseFloat(a/_)),h&&(ja=parseFloat((aa-b)/aa)),K()},y,z),Ma?(H(Ma),L(),Pa=Oa||u(Ma).format,t(Ma)):L(),U&&C();var g=p?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Da.delegate(".sp-thumb-el",g,c),Ea.delegate(".sp-thumb-el:nth-child(1)",g,{ignore:!0},c)}function t(c){if(V){var d=u(c).toRgbString();if(-1===b.inArray(d,na))for(na.push(d);na.length>oa;)na.shift();if(W&&a.localStorage)try{a.localStorage[W]=na.join(";")}catch(e){}}}function v(){var a,b=[],c=na,d={};if(T.showPalette){for(var e=0;e=aa||0>=_||0>=ca)&&O(),ua.addClass(pa),qa=null}function z(){ua.removeClass(pa)}function A(){var a=u(Ca.val());a.ok?H(a):Ca.addClass("sp-validation-error")}function B(){$?F():C()}function C(){var c=b.Event("beforeShow.spectrum");return $?void O():(Na=I(),sa.trigger(c,[Na]),void(Y.beforeShow(Na)===!1||c.isDefaultPrevented()||(H(Na),e(),$=!0,b(ra).bind("mousedown.spectrum",D),U||b(ra).bind("mouseup.spectrum",E),b(a).bind("resize.spectrum",Z),Ja.addClass("sp-active"),ua.removeClass("sp-hidden"),T.showPalette&&w(),O(),L(),x(),Y.show(Na),sa.trigger("show.spectrum",[Na]))))}function D(a){var c=b(a.target),d=c.parents(),e=!d.is(ua)&&!c.is(ua);e&&F(a)}function E(a){var b=!u.equals(I(),Na);b&&(Qa&&"cancel"!==a?N(!0):G())}function F(c){c&&"click"==c.type&&2==c.button||$&&!U&&($=!1,b(ra).unbind("mousedown.spectrum",D),b(ra).unbind("mouseup.spectrum",E),b(a).unbind("resize.spectrum",Z),Ja.removeClass("sp-active"),ua.addClass("sp-hidden"),E(c),t(I()),Y.hide(I()),sa.trigger("hide.spectrum",[I()]))}function G(){H(Na,!0)}function H(a,b){if(!u.equals(a,I())){var c=u(a),d=c.toHsv();ha=d.h%360/360,ia=d.s,ja=d.v,ka=d.a,L(),c.ok&&!b&&(Pa=Oa||c.format)}}function I(a){return a=a||{},u.fromRatio({h:ha,s:ia,v:ja,a:Math.round(100*ka)/100},{format:a.format||Pa})}function J(){return!Ca.hasClass("sp-validation-error")}function K(){L(),Y.move(I()),sa.trigger("move.spectrum",[I()])}function L(){Ca.removeClass("sp-validation-error"),M();var a=u.fromRatio({h:ha,s:1,v:1});va.css("background-color",a.toHexString());var b=Pa;1>ka&&("hex"===b||"hex3"===b||"hex6"===b||"name"===b)&&(b="rgb");var c=I({format:b}),d=c.toHexString(),e=c.toRgbString();if(q||1===c.alpha?La.css("background-color",e):(La.css("background-color","transparent"),La.css("filter",c.toFilter())),T.showAlpha){var f=c.toRgb();f.a=0;var g=u(f).toRgbString(),h="linear-gradient(left, "+g+", "+d+")";p?za.css("filter",u(g).toFilter({gradientType:1},d)):(za.css("background","-webkit-"+h),za.css("background","-moz-"+h),za.css("background","-ms-"+h),za.css("background",h))}T.showInput&&Ca.val(c.toString(b)),T.showPalette&&w(),x()}function M(){var a=ia,b=ja,c=a*_,d=aa-b*aa;c=Math.max(-ba/2,Math.min(_-ba/2,c-ba/2)),d=Math.max(-ba/2,Math.min(aa-ba/2,d-ba/2)),wa.css({top:d,left:c});var e=ka*ea;Ba.css({left:e-fa/2});var f=ha*ca;ya.css({top:f-ga/2})}function N(a){var b=I();Ha&&sa.val(b.toString(Pa));var c=!u.equals(b,Na);Na=b,a&&c&&(Y.change(b),sa.trigger("change",[b]))}function O(){_=va.width(),aa=va.height(),ba=wa.height()+4,da=xa.width(),ca=xa.height(),ga=ya.height()+4,ea=Aa.width(),fa=Ba.width(),U||(ua.css("position","absolute"),ua.offset(h(ua,Ka))),M()}function P(){sa.show(),Ka.unbind("click.spectrum touchstart.spectrum"),ua.remove(),Ja.remove(),o[Ra.id]=null}function Q(a,d){return a===c?b.extend({},T):d===c?T[a]:(T[a]=d,void k())}function R(){ta=!1,sa.attr("disabled",!1),Ka.removeClass("sp-disabled")}function S(){F(),ta=!0,sa.attr("disabled",!0),Ka.addClass("sp-disabled")}var T=f(i,g),U=T.flat,V=T.showSelectionPalette,W=T.localStorageKey,X=T.theme,Y=T.callbacks,Z=m(O,10),$=!1,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=1,la=T.palette.slice(0),ma=b.isArray(la[0])?la:[la],na=T.selectionPalette.slice(0),oa=T.maxSelectionSize,pa="sp-dragging",qa=null,ra=g.ownerDocument,sa=(ra.body,b(g)),ta=!1,ua=b(s,ra).addClass(X),va=ua.find(".sp-color"),wa=ua.find(".sp-dragger"),xa=ua.find(".sp-hue"),ya=ua.find(".sp-slider"),za=ua.find(".sp-alpha-inner"),Aa=ua.find(".sp-alpha"),Ba=ua.find(".sp-alpha-handle"),Ca=ua.find(".sp-input"),Da=ua.find(".sp-palette"),Ea=ua.find(".sp-initial"),Fa=ua.find(".sp-cancel"),Ga=ua.find(".sp-choose"),Ha=sa.is("input"),Ia=Ha&&!U,Ja=Ia?b(r).addClass(X).addClass(T.className):b([]),Ka=Ia?Ja:sa,La=Ja.find(".sp-preview-inner"),Ma=T.color||Ha&&sa.val(),Na=!1,Oa=T.preferredFormat,Pa=Oa,Qa=!T.showButtons||T.clickoutFiresChange;n();var Ra={show:C,hide:F,toggle:B,reflow:O,option:Q,enable:R,disable:S,set:function(a){H(a),N()},get:I,destroy:P,container:ua};return Ra.id=o.push(Ra)-1,Ra}function h(a,c){var d=0,e=a.outerWidth(),f=a.outerHeight(),g=c.outerHeight(),h=a[0].ownerDocument,i=h.documentElement,j=i.clientWidth+b(h).scrollLeft(),k=i.clientHeight+b(h).scrollTop(),l=c.offset();return l.top+=g,Math.min(l.left,l.left+e>j&&j>e)?(l.left-=Math.abs(l.left+e-j),a.attr("data-x-position","right")):(l.left-=0,a.attr("data-x-position","left")),Math.min(l.top,l.top+f>k&&k>f)?(l.top-=Math.abs(f+g-d),a.attr("data-y-position","top")):(l.top-=d,a.attr("data-y-position","bottom")),l}function i(){}function j(a){a.stopPropagation()}function k(a,b){var c=Array.prototype.slice,d=c.call(arguments,2);return function(){return a.apply(b,d.concat(c.call(arguments)))}}function l(c,d,e,f){function g(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.returnValue=!1}function h(a){if(l){if(p&&document.documentMode<9&&!a.button)return j();var b=a.originalEvent.touches,e=b?b[0].pageX:a.pageX,f=b?b[0].pageY:a.pageY,h=Math.max(0,Math.min(e-m.left,o)),i=Math.max(0,Math.min(f-m.top,n));q&&g(a),d.apply(c,[h,i,a])}}function i(a){{var d=a.which?3==a.which:2==a.button;a.originalEvent.touches}d||l||e.apply(c,arguments)!==!1&&(l=!0,n=b(c).height(),o=b(c).width(),m=b(c).offset(),b(k).bind(r),b(k.body).addClass("sp-dragging"),q||h(a),g(a))}function j(){l&&(b(k).unbind(r),b(k.body).removeClass("sp-dragging"),f.apply(c,arguments)),l=!1}d=d||function(){},e=e||function(){},f=f||function(){};var k=c.ownerDocument||document,l=!1,m={},n=0,o=0,q="ontouchstart"in a,r={};r.selectstart=g,r.dragstart=g,r["touchmove mousemove"]=h,r["touchend mouseup"]=j,b(c).bind("touchstart mousedown",i)}function m(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d),(c||!d)&&(d=setTimeout(g,b))}}var n={beforeShow:i,move:i,change:i,show:i,hide:i,color:!1,flat:!1,showInput:!1,showButtons:!0,clickoutFiresChange:!1,showInitial:!1,showPalette:!1,showPaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",preferredFormat:!1,className:"",showAlpha:!1,theme:"sp-light",palette:["fff","000"],selectionPalette:[],disabled:!1},o=[],p=!!/msie/i.exec(a.navigator.userAgent),q=function(){function a(a,b){return!!~(""+a).indexOf(b)}var b=document.createElement("div"),c=b.style;return c.cssText="background-color:rgba(0,0,0,.5)",a(c.backgroundColor,"rgba")||a(c.backgroundColor,"hsla")}(),r=["
","
","
","
"].join(""),s=function(){var a="";if(p)for(var b=1;6>=b;b++)a+="
";return["
"].join("")}(),t="spectrum.id";b.fn.spectrum=function(a,c){if("string"==typeof a){var d=this,e=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=o[b(this).data(t)];if(c){var f=c[a];if(!f)throw new Error("Spectrum: no such method: '"+a+"'");"get"==a?d=c.get():"container"==a?d=c.container:"option"==a?d=c.option.apply(c,e):"destroy"==a?(c.destroy(),b(this).removeData(t)):f.apply(c,e)}}),d}return this.spectrum("destroy").each(function(){var c=g(this,a);b(this).data(t,c.id)})},b.fn.spectrum.load=!0,b.fn.spectrum.loadOpts={},b.fn.spectrum.draggable=l,b.fn.spectrum.defaults=n,b.spectrum={},b.spectrum.localization={},b.spectrum.palettes={},b.fn.spectrum.processNativeColorInputs=function(){var a=b("")[0],c="color"===a.type&&"!"!=a.value;c||b("input[type=color]").spectrum({preferredFormat:"hex6"})},function(){function b(a,d){if(a=a?a:"",d=d||{},"object"==typeof a&&a.hasOwnProperty("_tc_id"))return a;var f=c(a),h=f.r,j=f.g,m=f.b,n=f.a,o=x(100*n)/100,p=d.format||f.format;return 1>h&&(h=x(h)),1>j&&(j=x(j)),1>m&&(m=x(m)),{ok:f.ok,format:p,_tc_id:v++,alpha:n,getAlpha:function(){return n},setAlpha:function(a){n=k(a),o=x(100*n)/100},toHsv:function(){var a=g(h,j,m);return{h:360*a.h,s:a.s,v:a.v,a:n}},toHsvString:function(){var a=g(h,j,m),b=x(360*a.h),c=x(100*a.s),d=x(100*a.v);return 1==n?"hsv("+b+", "+c+"%, "+d+"%)":"hsva("+b+", "+c+"%, "+d+"%, "+o+")"},toHsl:function(){var a=e(h,j,m);return{h:360*a.h,s:a.s,l:a.l,a:n}},toHslString:function(){var a=e(h,j,m),b=x(360*a.h),c=x(100*a.s),d=x(100*a.l);return 1==n?"hsl("+b+", "+c+"%, "+d+"%)":"hsla("+b+", "+c+"%, "+d+"%, "+o+")"},toHex:function(a){return i(h,j,m,a)},toHexString:function(a){return"#"+i(h,j,m,a)},toRgb:function(){return{r:x(h),g:x(j),b:x(m),a:n}},toRgbString:function(){return 1==n?"rgb("+x(h)+", "+x(j)+", "+x(m)+")":"rgba("+x(h)+", "+x(j)+", "+x(m)+", "+o+")"},toPercentageRgb:function(){return{r:x(100*l(h,255))+"%",g:x(100*l(j,255))+"%",b:x(100*l(m,255))+"%",a:n}},toPercentageRgbString:function(){return 1==n?"rgb("+x(100*l(h,255))+"%, "+x(100*l(j,255))+"%, "+x(100*l(m,255))+"%)":"rgba("+x(100*l(h,255))+"%, "+x(100*l(j,255))+"%, "+x(100*l(m,255))+"%, "+o+")"},toName:function(){return 0===n?"transparent":C[i(h,j,m,!0)]||!1},toFilter:function(a){var c=i(h,j,m),e=c,f=Math.round(255*parseFloat(n)).toString(16),g=f,k=d&&d.gradientType?"GradientType = 1, ":"";if(a){var l=b(a);e=l.toHex(),g=Math.round(255*parseFloat(l.alpha)).toString(16)}return"progid:DXImageTransform.Microsoft.gradient("+k+"startColorstr=#"+q(f)+c+",endColorstr=#"+q(g)+e+")"},toString:function(a){var b=!!a;a=a||this.format;var c=!1,d=!b&&1>n&&n>0,e=d&&("hex"===a||"hex6"===a||"hex3"===a||"name"===a);return"rgb"===a&&(c=this.toRgbString()),"prgb"===a&&(c=this.toPercentageRgbString()),("hex"===a||"hex6"===a)&&(c=this.toHexString()),"hex3"===a&&(c=this.toHexString(!0)),"name"===a&&(c=this.toName()),"hsl"===a&&(c=this.toHslString()),"hsv"===a&&(c=this.toHsvString()),e?this.toRgbString():c||this.toHexString()}}}function c(a){var b={r:0,g:0,b:0},c=1,e=!1,g=!1;return"string"==typeof a&&(a=s(a)),"object"==typeof a&&(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b")?(b=d(a.r,a.g,a.b),e=!0,g="%"===String(a.r).substr(-1)?"prgb":"rgb"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")?(a.s=r(a.s),a.v=r(a.v),b=h(a.h,a.s,a.v),e=!0,g="hsv"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=r(a.s),a.l=r(a.l),b=f(a.h,a.s,a.l),e=!0,g="hsl"),a.hasOwnProperty("a")&&(c=a.a)),c=k(c),{ok:e,format:a.format||g,r:y(255,z(b.r,0)),g:y(255,z(b.g,0)),b:y(255,z(b.b,0)),a:c}}function d(a,b,c){return{r:255*l(a,255),g:255*l(b,255),b:255*l(c,255)}}function e(a,b,c){a=l(a,255),b=l(b,255),c=l(c,255);var d,e,f=z(a,b,c),g=y(a,b,c),h=(f+g)/2;if(f==g)d=e=0;else{var i=f-g;switch(e=h>.5?i/(2-f-g):i/(f+g),f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,l:h}}function f(a,b,c){function d(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a}var e,f,g;if(a=l(a,360),b=l(b,100),c=l(c,100),0===b)e=f=g=c;else{var h=.5>c?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function g(a,b,c){a=l(a,255),b=l(b,255),c=l(c,255);var d,e,f=z(a,b,c),g=y(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function h(a,b,c){a=6*l(a,360),b=l(b,100),c=l(c,100);var d=w.floor(a),e=a-d,f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=d%6,j=[c,g,f,f,h,c][i],k=[h,c,c,g,f,f][i],m=[f,f,h,c,c,g][i];return{r:255*j,g:255*k,b:255*m}}function i(a,b,c,d){var e=[q(x(a).toString(16)),q(x(b).toString(16)),q(x(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function j(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function k(a){return a=parseFloat(a),(isNaN(a)||0>a||a>1)&&(a=1),a}function l(a,b){o(a)&&(a="100%");var c=p(a);return a=y(b,z(0,parseFloat(a))),c&&(a=parseInt(a*b,10)/100),w.abs(a-b)<1e-6?1:a%b/parseFloat(b)}function m(a){return y(1,z(0,a))}function n(a){return parseInt(a,16)}function o(a){return"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)}function p(a){return"string"==typeof a&&-1!=a.indexOf("%")}function q(a){return 1==a.length?"0"+a:""+a}function r(a){return 1>=a&&(a=100*a+"%"),a}function s(a){a=a.replace(t,"").replace(u,"").toLowerCase();var b=!1;if(B[a])a=B[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};var c;return(c=D.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=D.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=D.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=D.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=D.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=D.hex6.exec(a))?{r:n(c[1]),g:n(c[2]),b:n(c[3]),format:b?"name":"hex"}:(c=D.hex3.exec(a))?{r:n(c[1]+""+c[1]),g:n(c[2]+""+c[2]),b:n(c[3]+""+c[3]),format:b?"name":"hex"}:!1}var t=/^[\s,#]+/,u=/\s+$/,v=0,w=Math,x=w.round,y=w.min,z=w.max,A=w.random;b.fromRatio=function(a,c){if("object"==typeof a){var d={};for(var e in a)a.hasOwnProperty(e)&&("a"===e?d[e]=a[e]:d[e]=r(a[e]));a=d}return b(a,c)},b.equals=function(a,c){return a&&c?b(a).toRgbString()==b(c).toRgbString():!1},b.random=function(){return b.fromRatio({r:A(),g:A(),b:A()})},b.desaturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s-=c/100,d.s=m(d.s),b(d)},b.saturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s+=c/100,d.s=m(d.s),b(d)},b.greyscale=function(a){return b.desaturate(a,100)},b.lighten=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l+=c/100,d.l=m(d.l),b(d)},b.darken=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l-=c/100,d.l=m(d.l),b(d)},b.complement=function(a){var c=b(a).toHsl();return c.h=(c.h+180)%360,b(c)},b.triad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+120)%360,s:c.s,l:c.l}),b({h:(d+240)%360,s:c.s,l:c.l})]},b.tetrad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+90)%360,s:c.s,l:c.l}),b({h:(d+180)%360,s:c.s,l:c.l}),b({h:(d+270)%360,s:c.s,l:c.l})]},b.splitcomplement=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+72)%360,s:c.s,l:c.l}),b({h:(d+216)%360,s:c.s,l:c.l})]},b.analogous=function(a,c,d){c=c||6,d=d||30;var e=b(a).toHsl(),f=360/d,g=[b(a)];for(e.h=(e.h-(f*c>>1)+720)%360;--c;)e.h=(e.h+f)%360,g.push(b(e));return g},b.monochromatic=function(a,c){c=c||6;for(var d=b(a).toHsv(),e=d.h,f=d.s,g=d.v,h=[],i=1/c;c--;)h.push(b({h:e,s:f,v:g})),g=(g+i)%1;return h},b.readability=function(a,c){var d=b(a).toRgb(),e=b(c).toRgb(),f=(299*d.r+587*d.g+114*d.b)/1e3,g=(299*e.r+587*e.g+114*e.b)/1e3,h=Math.max(d.r,e.r)-Math.min(d.r,e.r)+Math.max(d.g,e.g)-Math.min(d.g,e.g)+Math.max(d.b,e.b)-Math.min(d.b,e.b);return{brightness:Math.abs(f-g),color:h}},b.readable=function(a,c){var d=b.readability(a,c);return d.brightness>125&&d.color>500},b.mostReadable=function(a,c){for(var d=null,e=0,f=!1,g=0;g125&&h.color>500,j=3*(h.brightness/125)+h.color/500;(i&&!f||i&&f&&j>e||!i&&!f&&j>e)&&(f=i,e=j,d=b(c[g]))}return d};var B=b.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=b.hexNames=j(B),D=function(){var a="[-\\+]?\\d+%?",b="[-\\+]?\\d*\\.\\d+%?",c="(?:"+b+")|(?:"+a+")",d="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?",e="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?";return{rgb:new RegExp("rgb"+d),rgba:new RegExp("rgba"+e),hsl:new RegExp("hsl"+d),hsla:new RegExp("hsla"+e),hsv:new RegExp("hsv"+d),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();a.tinycolor=b}();var u=a.tinycolor;b(function(){b.fn.spectrum.load&&b.fn.spectrum.processNativeColorInputs()})}(window,jQuery),function(a){"use strict";if("function"==typeof bootstrap)bootstrap("promise",a);else if("object"==typeof exports&&"object"==typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=a}else{if("undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");self.Q=a()}}(function(){"use strict";function a(a){return function(){return W.apply(a,arguments)}}function b(a){return a===Object(a)}function c(a){return"[object StopIteration]"===ca(a)||a instanceof S}function d(a,b){if(P&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(da)){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var f=c.join("\n"+da+"\n");a.stack=e(f)}}function e(a){for(var b=a.split("\n"),c=[],d=0;d=T&&ha>=d}function i(){if(P)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=g(c);if(!d)return;return R=d[0],d[1]}}function j(a,b,c){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(b+" is deprecated, use "+c+" instead.",new Error("").stack),a.apply(a,arguments)}}function k(a){return a instanceof o?a:s(a)?B(a):A(a)}function l(){function a(a){b=a,f.source=a,Y(c,function(b,c){k.nextTick(function(){a.promiseDispatch.apply(a,c)})},void 0),c=void 0,d=void 0}var b,c=[],d=[],e=_(l.prototype),f=_(o.prototype);if(f.promiseDispatch=function(a,e,f){var g=X(arguments);c?(c.push(g),"when"===e&&f[1]&&d.push(f[1])):k.nextTick(function(){b.promiseDispatch.apply(b,g)})},f.valueOf=function(){if(c)return f;var a=q(b);return r(a)&&(b=a),a},f.inspect=function(){return b?b.inspect():{state:"pending"}},k.longStackSupport&&P)try{throw new Error}catch(g){f.stack=g.stack.substring(g.stack.indexOf("\n")+1)}return e.promise=f,e.resolve=function(c){b||a(k(c))},e.fulfill=function(c){b||a(A(c))},e.reject=function(c){b||a(z(c))},e.notify=function(a){b||Y(d,function(b,c){k.nextTick(function(){c(a)})},void 0)},e}function m(a){if("function"!=typeof a)throw new TypeError("resolver must be a function.");var b=l();try{a(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}return b.promise}function n(a){return m(function(b,c){for(var d=0,e=a.length;e>d;d++)k(a[d]).then(b,c)})}function o(a,b,c){void 0===b&&(b=function(a){return z(new Error("Promise does not support operation: "+a))}),void 0===c&&(c=function(){return{state:"unknown"}});var d=_(o.prototype);if(d.promiseDispatch=function(c,e,f){var g;try{g=a[e]?a[e].apply(d,f):b.call(d,e,f)}catch(h){g=z(h)}c&&c(g)},d.inspect=c,c){var e=c();"rejected"===e.state&&(d.exception=e.reason),d.valueOf=function(){var a=c();return"pending"===a.state||"rejected"===a.state?d:a.value}}return d}function p(a,b,c,d){return k(a).then(b,c,d)}function q(a){if(r(a)){var b=a.inspect();if("fulfilled"===b.state)return b.value}return a}function r(a){return a instanceof o}function s(a){return b(a)&&"function"==typeof a.then}function t(a){return r(a)&&"pending"===a.inspect().state}function u(a){return!r(a)||"fulfilled"===a.inspect().state}function v(a){return r(a)&&"rejected"===a.inspect().state}function w(){ea.length=0,fa.length=0,ga||(ga=!0)}function x(a,b){ga&&(fa.push(a),ea.push(b&&"undefined"!=typeof b.stack?b.stack:"(no stack) "+b))}function y(a){if(ga){var b=Z(fa,a);-1!==b&&(fa.splice(b,1),ea.splice(b,1))}}function z(a){var b=o({when:function(b){return b&&y(this),b?b(a):this}},function(){return this},function(){return{state:"rejected",reason:a}});return x(b,a),b}function A(a){return o({when:function(){return a},get:function(b){return a[b]},set:function(b,c){a[b]=c},"delete":function(b){delete a[b]},post:function(b,c){return null===b||void 0===b?a.apply(void 0,c):a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},keys:function(){return ba(a)}},void 0,function(){return{state:"fulfilled",value:a}})}function B(a){var b=l();return k.nextTick(function(){try{a.then(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}}),b.promise}function C(a){return o({isDef:function(){}},function(b,c){return I(a,b,c)},function(){return k(a).inspect()})}function D(a,b,c){return k(a).spread(b,c)}function E(a){return function(){function b(a,b){var g;if("undefined"==typeof StopIteration){try{g=d[a](b)}catch(h){return z(h)}return g.done?k(g.value):p(g.value,e,f)}try{g=d[a](b)}catch(h){return c(h)?k(h.value):z(h)}return p(g,e,f)}var d=a.apply(this,arguments),e=b.bind(b,"next"),f=b.bind(b,"throw");return e()}}function F(a){k.done(k.async(a)())}function G(a){throw new S(a)}function H(a){return function(){return D([this,J(arguments)],function(b,c){return a.apply(b,c)})}}function I(a,b,c){return k(a).dispatch(b,c)}function J(a){return p(a,function(a){var b=0,c=l();return Y(a,function(d,e,f){var g;r(e)&&"fulfilled"===(g=e.inspect()).state?a[f]=g.value:(++b,p(e,function(d){a[f]=d,0===--b&&c.resolve(a)},c.reject,function(a){c.notify({index:f,value:a})}))},void 0),0===b&&c.resolve(a),c.promise})}function K(a){if(0===a.length)return k.resolve();var b=k.defer(),c=0;return Y(a,function(d,e,f){function g(a){b.resolve(a)}function h(){c--,0===c&&b.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected.")); +}}.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
',trigger:"hover",title:"",delay:0,html:!0}}(window.jQuery);var Constants={DEFAULT:{HEIGHT:32,WIDTH:32,FPS:12,LAYER_OPACITY:.2},MODEL_VERSION:2,MAX_HEIGHT:1024,MAX_WIDTH:1024,MAX_PALETTE_COLORS:100,MINIMUM_ZOOM:1,PREVIEW_FILM_SIZE:96,ANIMATED_PREVIEW_WIDTH:200,DEFAULT_PEN_COLOR:"#000000",TRANSPARENT_COLOR:"rgba(0, 0, 0, 0)",CURRENT_COLORS_PALETTE_ID:"__current-colors",SELECTION_TRANSPARENT_COLOR:"rgba(160, 215, 240, 0.6)",TOOL_HIGHLIGHT_COLOR_LIGHT:"rgba(255, 255, 255, 0.2)",TOOL_HIGHLIGHT_COLOR_DARK:"rgba(0, 0, 0, 0.2)",ZOOMED_OUT_BACKGROUND_COLOR:"#A0A0A0",LEFT_BUTTON:0,MIDDLE_BUTTON:1,RIGHT_BUTTON:2,MOUSEMOVE_THROTTLING:10,ABSTRACT_FUNCTION:function(){throw"abstract method should be implemented"},EMPTY_FUNCTION:function(){},DRAWING_TEST_FOLDER:"drawing",APPENGINE_SAVE_URL:"save",IMAGE_SERVICE_UPLOAD_URL:"http://piskel-imgstore-b.appspot.com/__/upload",IMAGE_SERVICE_GET_URL:"http://piskel-imgstore-b.appspot.com/img/"},Events={TOOL_SELECTED:"TOOL_SELECTED",SELECT_TOOL:"SELECT_TOOL",TOOL_RELEASED:"TOOL_RELEASED",TOOL_PRESSED:"TOOL_PRESSED",SELECT_PRIMARY_COLOR:"SELECT_PRIMARY_COLOR",SELECT_SECONDARY_COLOR:"SELECT_SECONDARY_COLOR",PRIMARY_COLOR_SELECTED:"PRIMARY_COLOR_SELECTED",SECONDARY_COLOR_SELECTED:"SECONDARY_COLOR_SELECTED",CURSOR_MOVED:"CURSOR_MOVED",DRAG_START:"DRAG_START",DRAG_END:"DRAG_END",DIALOG_DISPLAY:"DIALOG_DISPLAY",DIALOG_HIDE:"DIALOG_HIDE",PALETTE_LIST_UPDATED:"PALETTE_LIST_UPDATED",USER_SETTINGS_CHANGED:"USER_SETTINGS_CHANGED",CLOSE_SETTINGS_DRAWER:"CLOSE_SETTINGS_DRAWER",SET_OVERLAY_OPACITY:"SET_OVERLAY_OPACITY",PISKEL_RESET:"PISKEL_RESET",PISKEL_SAVE_STATE:"PISKEL_SAVE_STATE",HISTORY_STATE_SAVED:"HISTORY_STATE_SAVED",HISTORY_STATE_LOADED:"HISTORY_STATE_LOADED",PISKEL_SAVED:"PISKEL_SAVED",FRAME_SIZE_CHANGED:"FRAME_SIZE_CHANGED",SELECTION_CREATED:"SELECTION_CREATED",SELECTION_MOVE_REQUEST:"SELECTION_MOVE_REQUEST",SELECTION_DISMISSED:"SELECTION_DISMISSED",SHOW_NOTIFICATION:"SHOW_NOTIFICATION",HIDE_NOTIFICATION:"HIDE_NOTIFICATION",SHOW_PROGRESS:"SHOW_PROGRESS",UPDATE_PROGRESS:"UPDATE_PROGRESS",HIDE_PROGRESS:"HIDE_PROGRESS",ZOOM_CHANGED:"ZOOM_CHANGED",CURRENT_COLORS_UPDATED:"CURRENT_COLORS_UPDATED",MOUSE_EVENT:"MOUSE_EVENT",KEYBOARD_EVENT:"KEYBOARD_EVENT",TEST_RECORD_END:"TEST_RECORD_END",TEST_CASE_END:"TEST_CASE_END",TEST_SUITE_END:"TEST_SUITE_END"};jQuery.namespace=function(){for(var a=arguments,b=null,c=0;cc;c++){var e=a.charCodeAt(c);b=(b<<5)-b+e,b|=0}return b},a.copy=function(a){return JSON.parse(JSON.stringify(a))};var b={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};a.escapeHtml=function(a){return String(a).replace(/[&<>"'\/]/g,function(a){return b[a]})};var c={};a.unescapeHtml=function(a){return Object.keys(b).forEach(function(d){c[d]=c[d]||new RegExp(b[d],"g"),a=a.replace(c[d],d)}),a}}(),function(){var a=$.namespace("pskl.utils"),b=navigator.userAgent;a.UserAgent={isIE:/MSIE/i.test(b),isIE11:/trident/i.test(b),isChrome:/Chrome/i.test(b),isFirefox:/Firefox/i.test(b),isMac:/Mac/.test(b)},a.UserAgent.version=function(){return pskl.utils.UserAgent.isIE?parseInt(/MSIE\s?(\d+)/i.exec(b)[1],10):pskl.utils.UserAgent.isChrome?parseInt(/Chrome\/(\d+)/i.exec(b)[1],10):pskl.utils.UserAgent.isFirefox?parseInt(/Firefox\/(\d+)/i.exec(b)[1],10):void 0}()}(),function(){var a=$.namespace("pskl.utils");a.Array={find:function(a,b){var c=null;a=Array.isArray(a)?a:[];var d=a.filter(b);return d.length&&(c=d[0]),c}}}(),function(){var a,b=$.namespace("pskl.utils");Uint8Array&&(a=new Uint8Array([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),b.Base64={toText:function(a){return window.atob(a.replace(/data\:.*?\;base64\,/,""))},decode:function(b){for(var c,d=0,e=[0,0],f=0,g=0,h=b.length,i=0,j=new Uint8Array(h/4*3|0);h--;){var k=b.charCodeAt(i++),l=a[k-43];255!==l&&l!==c&&(e[1]=e[0],e[0]=k,g=g<<6|l,f++,4===f&&(j[d++]=g>>>16,61!==e[1]&&(j[d++]=g>>>8),61!==e[0]&&(j[d++]=g),f=0))}return j.buffer}}}(),function(){var a=$.namespace("pskl.utils"),b=/\s*;\s*base64\s*(?:;|$)/i;a.BlobUtils={dataToBlob:function(a,c,d){var e,f=a.indexOf(","),g=a.substring(f+1),h=b.test(a.substring(0,f));if(Blob.fake)e=new Blob,e.encoding=h?"base64":"URI",e.data=g,e.size=g.length;else if(Uint8Array){var i=h?pskl.utils.Base64.decode(g):decodeURIComponent(g);e=new Blob([i],{type:c})}d(e)},canvasToBlob:function(a,b,c){if(c=c||"image/png",a.mozGetAsFile)b(a.mozGetAsFile("canvas",c));else{var d=Array.prototype.slice.call(arguments,2),e=a.toDataURL.apply(a,d);pskl.utils.BlobUtils.dataToBlob(e,c,b)}},stringToBlob:function(a,b,c){c=c||"text/plain",pskl.utils.BlobUtils.dataToBlob("data:"+c+","+a,c,b)}}}(),function(){var a=$.namespace("pskl.utils");a.CanvasUtils={createCanvas:function(a,b,c){var d=document.createElement("canvas");if(d.setAttribute("width",a),d.setAttribute("height",b),"string"==typeof c&&(c=[c]),Array.isArray(c))for(var e=0;ea.width&&(i=b,j+=e)):(j+=e,j+e>a.height&&(i+=d,j=c))}return h},disableImageSmoothing:function(a){pskl.utils.CanvasUtils.setImageSmoothing(a,!1)},enableImageSmoothing:function(a){pskl.utils.CanvasUtils.setImageSmoothing(a,!0)},setImageSmoothing:function(a,b){var c=a.getContext("2d");c.imageSmoothingEnabled=b,c.mozImageSmoothingEnabled=b,c.oImageSmoothingEnabled=b,c.webkitImageSmoothingEnabled=b,c.msImageSmoothingEnabled=b},clear:function(a){a&&a.getContext("2d").clearRect(0,0,a.width,a.height)},clone:function(a){var b=pskl.utils.CanvasUtils.createCanvas(a.width,a.height);return b.getContext("2d").drawImage(a,0,0),b},getImageDataFromCanvas:function(a){var b=a.getContext("2d");return b.getImageData(0,0,a.width,a.height).data},getBase64FromCanvas:function(a,b){b=b||"png";var c=a.toDataURL("image/"+b);return c.substr(c.indexOf(",")+1)}}}(),function(){var a=$.namespace("pskl.utils");a.ColorUtils={getUnusedColor:function(a){a=a||[];var b={};a.forEach(function(a){b[a.toUpperCase()]=!0});for(var c={r:255,g:255,b:0},d=null;;){var e=window.tinycolor(c).toHexString().toUpperCase();if(!b[e]){d=e;break}var f=c.r&&"r"||c.g&&"g"||c.b&&"b";if(!f)break;c[f]=c[f]-1}return d}}}(),function(){var a=$.namespace("pskl.utils"),b=function(a){return 10>a?"0"+a:""+a};a.DateUtils={format:function(a,c){return a=new Date(a),pskl.utils.Template.replace(c,{Y:a.getFullYear(),M:b(a.getMonth()+1),D:b(a.getDate()),H:b(a.getHours()),m:b(a.getMinutes()),s:b(a.getSeconds())})}}}(),function(){var a=$.namespace("pskl.utils");a.Dom={isParent:function(a,b,c){if(a&&b)for(c&&(a=a.parentNode);a;){if(a===b)return!0;a=a.parentNode}return!1},getParentWithData:function(a,b){for(;a;){if(a.dataset&&"undefined"!=typeof a.dataset[b])return a;a=a.parentNode}return null}}}(),function(){var a=$.namespace("pskl.utils");a.Event={},a.Event.addEventListener=function(a,b,c,d,e){"string"==typeof a&&(a=document.querySelector(a));var f={el:a,type:b,callback:c,handler:e?c.bind(d,e):c.bind(d)};d.__pskl_listeners=d.__pskl_listeners||[],d.__pskl_listeners.push(f),a.addEventListener(b,f.handler)},a.Event.removeEventListener=function(a,b,c,d){if(d&&d.__pskl_listeners)for(var e=d.__pskl_listeners,f=0;f',f=$(e);f.change(function(b){var e=$(this).val();e=pskl.utils.FileUtilsDesktop.addExtensionIfNeeded(e,c),pskl.utils.FileUtilsDesktop.saveToFile(a,e,function(){d(e)})}),f.trigger("click")},saveToFile:function(a,b,c){var d=window.require("fs");d.writeFile(b,a,function(a){a&&console.log("FileUtilsDesktop::savetoFile() - error saving file:",b,"Error:",a),c()})},readFile:function(a,b){var c=window.require("fs");c.readFile(a,"utf8",function(c,d){c&&console.log("FileUtilsDesktop::readFile() - error reading file:",a,"Error:",c),b(d)})}}}(),function(){var a=$.namespace("pskl.utils");a.FrameTransform={VERTICAL:"vertical",HORIZONTAL:"HORIZONTAL",flip:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight();return d.forEachPixel(function(d,g,h){c===a.FrameTransform.VERTICAL?g=e-g-1:c===a.FrameTransform.HORIZONTAL&&(h=f-h-1),b.pixels[g][h]=d}),b.version++,b},CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise",rotate:function(b,c){var d=b.clone(),e=b.getWidth(),f=b.getHeight(),g=Math.max(e,f),h=Math.ceil((g-e)/2),i=Math.ceil((g-f)/2);return b.forEachPixel(function(e,f,j){var k=f,l=j;f+=h,j+=i;var m=f,n=j;c===a.FrameTransform.CLOCKWISE?(f=n,j=g-1-m):c===a.FrameTransform.COUNTERCLOCKWISE&&(j=m,f=g-1-n),f-=h,j-=i,b.pixels[k][l]=d.containsPixel(f,j)?d.getPixel(f,j):Constants.TRANSPARENT_COLOR}),b.version++,b}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.FrameUtils={toImage:function(a,b){b=b||1;var c=new pskl.rendering.CanvasRenderer(a,b);return c.drawTransparentAs(Constants.TRANSPARENT_COLOR),c.render()},drawToCanvas:function(a,b,c){var d=b.getContext("2d");c=c||Constants.TRANSPARENT_COLOR;for(var e=0,f=a.getWidth();f>e;e++)for(var g=0,h=a.getHeight();h>g;g++){for(var i=a.getPixel(e,g),j=1;i===a.getPixel(e,g+j)&&h>g+j;)j++;i==Constants.TRANSPARENT_COLOR&&(i=c),pskl.utils.FrameUtils.renderLine_(i,e,g,j,d),g=g+j-1}},renderLine_:function(a,b,c,d,e){a!==Constants.TRANSPARENT_COLOR&&null!==a&&(e.fillStyle=a,e.fillRect(b,c,1,d))},merge:function(a){var b=null;if(a.length){b=a[0].clone();for(var c=1;ce;e++){d[e]=[];for(var f=0;c>f;f++){var g=4*(f*b+e),h=a[g],i=a[g+1],j=a[g+2],k=a[g+3];d[e][f]=125>k?Constants.TRANSPARENT_COLOR:pskl.utils.rgbToHex(h,i,j)}}return pskl.model.Frame.fromPixelGrid(d)},mergePixels__:function(a,b,c){var d=pskl.utils.FrameUtils.toRgba__(a),e=pskl.utils.FrameUtils.toRgba__(b);"number"==typeof c&&(d=JSON.parse(JSON.stringify(d)),d.a=c*d.a);var f=d.a+e.a*(1-d.a),g=(d.r*d.a+e.r*e.a*(1-d.a))/f|0,h=(d.g*d.a+e.g*e.a*(1-d.a))/f|0,i=(d.b*d.a+e.b*e.a*(1-d.a))/f|0;return"rgba("+g+","+h+","+i+","+f+")"},toRgba__:function(a){if(b[a])return b[a];var c,d;return"TRANSPARENT"===a?c={r:0,g:0,b:0,a:0}:-1!=a.indexOf("rgba(")?(d=/rgba\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(1|0\.\d+)\s*\)/.exec(a),c={r:parseInt(d[1],10),g:parseInt(d[2],10),b:parseInt(d[3],10),a:parseFloat(d[4])}):-1!=a.indexOf("rgb(")?(d=/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/.exec(a),c={r:parseInt(d[1],10),g:parseInt(d[2],10),b:parseInt(d[3],10),a:1}):(d=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a),c={r:parseInt(d[1],16),g:parseInt(d[2],16),b:parseInt(d[3],16),a:1}),b[a]=c,c}}}(),function(){var a=$.namespace("pskl.utils");a.LayerUtils={createLayerFromSpritesheet:function(a,b){for(var c=a.width,d=a.height,e=c/b,f=pskl.utils.CanvasUtils.createCanvas(e,d),g=f.getContext("2d"),h=[],i=0;b>i;i++){g.clearRect(0,0,e,d),g.drawImage(a,e*i,0,e,d,0,0,e,d);var j=pskl.utils.FrameUtils.createFromImage(f);h.push(j)}return h},mergeLayers:function(a,b){var c=a.getFrames(),d=b.getFrames(),e=[];c.forEach(function(a,b){var c=d[b];e.push(pskl.utils.FrameUtils.merge([c,a]))});var f=pskl.model.Layer.fromFrames(a.getName(),e);return f}}}(),function(){var a=$.namespace("pskl.utils");a.ImageResizer={resize:function(a,b,c,d){var e=pskl.utils.CanvasUtils.createCanvas(b,c),f=e.getContext("2d");return f.save(),d||pskl.utils.CanvasUtils.disableImageSmoothing(e),f.translate(e.width/2,e.height/2),f.scale(b/a.width,c/a.height),f.drawImage(a,-a.width/2,-a.height/2),f.restore(),e},resizeNearestNeighbour:function(a,b,c,d){c=c||0;for(var e=pskl.utils.CanvasUtils.createCanvas(b*a.width,b*a.height),f=e.getContext("2d"),g=pskl.utils.CanvasUtils.getImageDataFromCanvas(a),h={},i=0,j=0,k=0;k0;){k++;var m=g.pop();a.setPixel(m.col,m.row,d),f.push({col:m.col,row:m.row});for(var n=0;4>n;n++){var o=m.col+i[n],p=m.row+h[n];try{a.containsPixel(o,p)&&a.getPixel(o,p)==e&&g.push({col:o,row:p})}catch(j){}}if(k>10*l){console.log("loop breaker called");break}}return f}},calculateZoomForContainer:function(a,b,c){return this.calculateZoom(a.height(),a.width(),b,c)}}}(),function(){var a=$.namespace("pskl.utils");a.PiskelFileUtils={loadFromFile:function(b,c,d){pskl.utils.FileUtils.readFile(b,function(e){var f=pskl.utils.Base64.toText(e);a.PiskelFileUtils.decodePiskelFile(f,function(a,d,e){pskl.utils.Environment.detectNodeWebkit()&&(a.savePath=b.path),c(a,d,e)},d)})},decodePiskelFile:function(a,b,c){var d=JSON.parse(a),e=d.piskel.fps,f=d.piskel,g=new pskl.model.piskel.Descriptor(f.name,f.description,!0);pskl.utils.serialization.Deserializer.deserialize(d,function(a){b(a,g,e)})}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.Template={get:function(a){if(!b[a]){var c=document.getElementById(a);c?b[a]=c.innerHTML:console.error("Could not find template for id :",a)}return b[a]},createFromHTML:function(a){var b=document.createElement("div");return b.innerHTML=a,b.children[0]},insert:function(a,b,c,d){var e=pskl.utils.Template.getAndReplace(c,d);a.insertAdjacentHTML(b,e)},getAndReplace:function(a,b){var c="",d=pskl.utils.Template.get(a);return d&&(c=pskl.utils.Template.replace(d,b)),c},replace:function(a,b){for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];-1!==c.indexOf(":")&&(d===!0?d=c.split(":")[1]:d===!1&&(d="")),a=a.replace(new RegExp("\\{\\{"+c+"\\}\\}","g"),d)}return a}}}(),function(){var a=$.namespace("pskl.utils");a.TooltipFormatter={},a.TooltipFormatter.formatForTool=function(a,b,c){var d=pskl.utils.Template.get("drawingTool-tooltipContainer-template");return pskl.utils.Template.replace(d,{helptext:c,shortcut:a,descriptors:this.formatToolDescriptors_(b)})},a.TooltipFormatter.formatToolDescriptors_=function(a){return a=a||[],a.reduce(function(a,b){return a+=this.formatToolDescriptor_(b)}.bind(this),"")},a.TooltipFormatter.formatToolDescriptor_=function(a){var b;return a.key?(b=pskl.utils.Template.get("drawingTool-tooltipDescriptor-template"),a.key=a.key.toUpperCase(),pskl.utils.UserAgent.isMac&&(a.key=a.key.replace("CTRL","CMD"))):b=pskl.utils.Template.get("drawingTool-simpleTooltipDescriptor-template"),pskl.utils.Template.replace(b,a)}}(),function(){var a=$.namespace("pskl");a.UserSettings={GRID_WIDTH:"GRID_WIDTH",MAX_FPS:"MAX_FPS",DEFAULT_SIZE:"DEFAULT_SIZE",CANVAS_BACKGROUND:"CANVAS_BACKGROUND",SELECTED_PALETTE:"SELECTED_PALETTE",TILED_PREVIEW:"TILED_PREVIEW",ORIGINAL_SIZE_PREVIEW:"ORIGINAL_SIZE_PREVIEW",ONION_SKIN:"ONION_SKIN",LAYER_PREVIEW:"LAYER_PREVIEW",LAYER_OPACITY:"LAYER_OPACITY",KEY_TO_DEFAULT_VALUE_MAP_:{GRID_WIDTH:0,MAX_FPS:24,DEFAULT_SIZE:{width:Constants.DEFAULT.WIDTH,height:Constants.DEFAULT.HEIGHT},CANVAS_BACKGROUND:"lowcont-dark-canvas-background",SELECTED_PALETTE:Constants.CURRENT_COLORS_PALETTE_ID,TILED_PREVIEW:!1,ORIGINAL_SIZE_PREVIEW:!1,ONION_SKIN:!1,LAYER_OPACITY:.2,LAYER_PREVIEW:!0},cache_:{},get:function(a){if(this.checkKeyValidity_(a),!(a in this.cache_)){var b=this.readFromLocalStorage_(a);this.cache_[a]="undefined"!=typeof b&&null!==b?b:this.readFromDefaults_(a)}return this.cache_[a]},set:function(a,b){this.checkKeyValidity_(a),this.cache_[a]=b,this.writeToLocalStorage_(a,b),$.publish(Events.USER_SETTINGS_CHANGED,[a,b])},readFromLocalStorage_:function(a){var b=window.localStorage[a];return"undefined"!=typeof b&&(b=JSON.parse(b)),b},writeToLocalStorage_:function(a,b){window.localStorage[a]=JSON.stringify(b)},readFromDefaults_:function(a){return this.KEY_TO_DEFAULT_VALUE_MAP_[a]},checkKeyValidity_:function(a){var b=a in this.KEY_TO_DEFAULT_VALUE_MAP_;b||console.error("UserSettings key <"+a+"> not found in supported keys.")}}}(),function(){var a=$.namespace("pskl.utils"),b=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};a.Uuid={generate:function(){return"ss-s-s-s-sss".replace(/s/g,function(){return b()})}}}(),function(){var a=$.namespace("pskl.utils"),b={};a.WorkerUtils={createWorker:function(c,d){return b[d]||(b[d]=a.WorkerUtils.createWorkerURL(c)),new Worker(b[d])},createWorkerURL:function(a){var b=[(a+"").replace(/function\s*\(\)\s*\{/,"").replace(/\}[^}]*$/,"")],c=new Blob(b,{type:"application/javascript"});return window.URL.createObjectURL(c)}}}(),function(){var a=$.namespace("pskl.utils");a.Xhr={get:function(b,c,d){var e=a.Xhr.xhr_(b,"GET",c,d);e.send()},post:function(b,c,d,e){var f=a.Xhr.xhr_(b,"POST",d,e),g=new FormData;if("object"==typeof c)for(var h in c)c.hasOwnProperty(h)&&g.append(h,c[h]);f.send(g)},xhr_:function(a,b,c,d){c=c||function(){},d=d||function(){};var e=new XMLHttpRequest;return e.open(b,a,!0),e.onload=function(a){200==this.status?c(this):this.onerror(this,a)},e.onerror=function(a){d(a,this)},e}}}(),function(){var a=$.namespace("pskl.utils");a.Serializer={serializePiskel:function(a,b){var c=a.getLayers().map(function(a){return pskl.utils.Serializer.serializeLayer(a,b)});return JSON.stringify({modelVersion:Constants.MODEL_VERSION,piskel:{name:a.getDescriptor().name,description:a.getDescriptor().description,fps:pskl.app.piskelController.getFPS(),height:a.getHeight(),width:a.getWidth(),layers:c,expanded:b}})},serializeLayer:function(a,b){var c=a.getFrames(),d=new pskl.rendering.FramesheetRenderer(c),e={name:a.getName(),frameCount:c.length};return b?(e.grids=c.map(function(a){return a.pixels}),e):(e.base64PNG=d.renderAsCanvas().toDataURL(),JSON.stringify(e))}}}(),function(){var a=$.namespace("pskl.utils.serialization");a.Deserializer=function(a,b){this.layersToLoad_=0,this.data_=a,this.callback_=b,this.piskel_=null},a.Deserializer.deserialize=function(b,c){var d;d=b.modelVersion==Constants.MODEL_VERSION?new a.Deserializer(b,c):1==b.modelVersion?new a.backward.Deserializer_v1(b,c):new a.backward.Deserializer_v0(b,c),d.deserialize()},a.Deserializer.prototype.deserialize=function(a){var b=this.data_,c=b.piskel;a=a||"Deserialized piskel";var d=new pskl.model.piskel.Descriptor(a,"");this.piskel_=new pskl.model.Piskel(c.width,c.height,d),this.layersToLoad_=c.layers.length,c.layers.forEach(c.expanded?this.loadExpandedLayer.bind(this):this.deserializeLayer.bind(this))},a.Deserializer.prototype.deserializeLayer=function(a){var b=JSON.parse(a),c=new pskl.model.Layer(b.name),d=b.base64PNG,e=new Image;return e.onload=function(){var a=pskl.utils.LayerUtils.createLayerFromSpritesheet(e,b.frameCount);this.addFramesToLayer(a,c)}.bind(this),e.src=d,c},a.Deserializer.prototype.loadExpandedLayer=function(a){var b=new pskl.model.Layer(a.name),c=a.grids.map(function(a){return pskl.model.Frame.fromPixelGrid(a)});return this.addFramesToLayer(c,b),b},a.Deserializer.prototype.addFramesToLayer=function(a,b){a.forEach(b.addFrame.bind(b)),this.piskel_.addLayer(b),this.onLayerLoaded_()},a.Deserializer.prototype.onLayerLoaded_=function(){this.layersToLoad_=this.layersToLoad_-1,0===this.layersToLoad_&&this.callback_(this.piskel_)}}(),function(){var a=$.namespace("pskl.utils.serialization.backward");a.Deserializer_v0=function(a,b){this.data_=a,this.callback_=b},a.Deserializer_v0.prototype.deserialize=function(){var a=this.data_,b=a.map(function(a){return pskl.model.Frame.fromPixelGrid(a)}),c=new pskl.model.piskel.Descriptor("Deserialized piskel",""),d=pskl.model.Layer.fromFrames("Layer 1",b);this.callback_(pskl.model.Piskel.fromLayers([d],c))}}(),function(){var a=$.namespace("pskl.utils.serialization.backward");a.Deserializer_v1=function(a,b){this.callback_=b,this.data_=a},a.Deserializer_v1.prototype.deserialize=function(){var a=this.data_.piskel,b=new pskl.model.piskel.Descriptor("Deserialized piskel",""),c=new pskl.model.Piskel(a.width,a.height,b);a.layers.forEach(function(a){var b=this.deserializeLayer(a);c.addLayer(b)}.bind(this)),this.callback_(c)},a.Deserializer_v1.prototype.deserializeLayer=function(a){var b=JSON.parse(a),c=new pskl.model.Layer(b.name);return b.frames.forEach(function(a){var b=this.deserializeFrame(a);c.addFrame(b)}.bind(this)),c},a.Deserializer_v1.prototype.deserializeFrame=function(a){var b=JSON.parse(a);return pskl.model.Frame.fromPixelGrid(b)}}(),function(){var a=function(){(function(a){function b(a,c){if({}.hasOwnProperty.call(b.cache,a))return b.cache[a];var d=b.resolve(a);if(!d)throw new Error("Failed to resolve module "+a);var e={id:a,require:b,filename:a,exports:{},loaded:!1,parent:c,children:[]};c&&c.children.push(e);var f=a.slice(0,a.lastIndexOf("/")+1);return b.cache[a]=e.exports,d.call(e.exports,e,e.exports,f,a),e.loaded=!0,b.cache[a]=e.exports}b.modules={},b.cache={},b.resolve=function(a){return{}.hasOwnProperty.call(b.modules,a)?b.modules[a]:void 0},b.define=function(a,c){b.modules[a]=c},b.define("/gif.worker.coffee",function(a,c,d,e){var f,g;f=b("/GIFEncoder.js",a),g=function(a){var b,c,d,e;return b=new f(a.width,a.height),0===a.index?b.writeHeader():b.firstFrame=!1,b.setTransparent(a.transparent),b.setRepeat(a.repeat),b.setDelay(a.delay),b.setQuality(a.quality),b.setPreserveColors(a.preserveColors),b.addFrame(a.data),a.last&&b.finish(),d=b.stream(),a.data=d.pages,a.cursor=d.cursor,a.pageSize=d.constructor.pageSize,a.canTransfer?(e=function(b){for(var d=0,e=a.data.length;e>d;++d)c=a.data[d],b.push(c.buffer);return b}.call(this,[]),self.postMessage(a,e)):self.postMessage(a)},self.onmessage=function(a){return g(a.data)}}),b.define("/GIFEncoder.js",function(a,c,d,e){function f(){this.page=-1,this.pages=[],this.newPage()}function g(a,b){this.width=~~a,this.height=~~b,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null, +this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.out=new f}var h=b("/TypedNeuQuant.js",a),i=b("/SimpleQuant.js",a),j=b("/LZWEncoder.js",a);f.pageSize=4096,f.charMap={};for(var k=0;256>k;k++)f.charMap[k]=String.fromCharCode(k);f.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(f.pageSize),this.cursor=0},f.prototype.getData=function(){for(var a="",b=0;b=f.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=a},f.prototype.writeUTFBytes=function(a){for(var b=a.length,c=0;b>c;c++)this.writeByte(a.charCodeAt(c))},f.prototype.writeBytes=function(a,b,c){for(var d=c||a.length,e=b||0;d>e;e++)this.writeByte(a[e])},g.prototype.setDelay=function(a){this.delay=Math.round(a/10)},g.prototype.setFrameRate=function(a){this.delay=Math.round(100/a)},g.prototype.setDispose=function(a){a>=0&&(this.dispose=a)},g.prototype.setRepeat=function(a){this.repeat=a},g.prototype.setTransparent=function(a){this.transparent=a},g.prototype.setPreserveColors=function(a){this.preserveColors=a},g.prototype.addFrame=function(a){this.image=a,this.getImagePixels(),this.analyzePixels(),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.writePixels(),this.firstFrame=!1},g.prototype.finish=function(){this.out.writeByte(59)},g.prototype.setQuality=function(a){1>a&&(a=1),this.sample=a},g.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},g.prototype.analyzePixels=function(){var a=this.pixels.length,b=a/3;this.indexedPixels=new Uint8Array(b);var c;if(this.preserveColors){var d=this.toRGBComponents(this.transparent);c=new i(this.pixels,this.sample,d)}else c=new h(this.pixels,this.sample);c.buildColormap(),this.colorTab=c.getColormap();for(var e=0,f=0;b>f;f++){var g=c.lookupRGB(255&this.pixels[e++],255&this.pixels[e++],255&this.pixels[e++]);this.usedEntry[g]=!0,this.indexedPixels[f]=g}this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent))},g.prototype.toRGBComponents=function(a){var b=null;return a&&(b={r:(16711680&a)>>16,g:(65280&a)>>8,b:255&a}),b},g.prototype.findClosest=function(a){if(null===this.colorTab)return-1;for(var b=(16711680&a)>>16,c=(65280&a)>>8,d=255&a,e=0,f=16777216,g=this.colorTab.length,h=0;g>h;){var i=b-(255&this.colorTab[h++]),j=c-(255&this.colorTab[h++]),k=d-(255&this.colorTab[h]),l=i*i+j*j+k*k,m=parseInt(h/3);(this.preserveColors||this.usedEntry[m])&&f>l&&(f=l,e=m),h++}return e},g.prototype.getImagePixels=function(){var a=this.width,b=this.height;this.pixels=new Uint8Array(a*b*3);for(var c=this.image,d=0,e=0;b>e;e++)for(var f=0;a>f;f++){var g=e*a*4+4*f;this.pixels[d++]=c[g],this.pixels[d++]=c[g+1],this.pixels[d++]=c[g+2]}},g.prototype.writeGraphicCtrlExt=function(){this.out.writeByte(33),this.out.writeByte(249),this.out.writeByte(4);var a,b;null===this.transparent?(a=0,b=0):(a=1,b=2),this.dispose>=0&&(b=7&dispose),b<<=2,this.out.writeByte(0|b|0|a),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},g.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(this.firstFrame?0:128|this.palSize)},g.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},g.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},g.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var a=768-this.colorTab.length,b=0;a>b;b++)this.out.writeByte(0)},g.prototype.writeShort=function(a){this.out.writeByte(255&a),this.out.writeByte(a>>8&255)},g.prototype.writePixels=function(){var a=new j(this.width,this.height,this.indexedPixels,this.colorDepth);a.encode(this.out)},g.prototype.stream=function(){return this.out},a.exports=g}),b.define("/LZWEncoder.js",function(a,b,c,d){function e(a,b,c,d){function e(a,b){y[s++]=a,s>=254&&n(b)}function j(a){k(h),C=v+2,D=!0,q(v,a)}function k(a){for(var b=0;a>b;++b)z[b]=-1}function l(a,b){var c,d,e,i,l,m,n;for(u=a,D=!1,n_bits=u,t=o(n_bits),v=1<c;c*=2)++n;n=8-n,m=h,k(m),q(v,b);a:for(;(d=p())!=f;)if(c=(d<=0){l=m-e,0===e&&(l=1);do if((e-=l)<0&&(e+=m),z[e]===c){i=A[e];continue a}while(z[e]>=0)}q(i,b),i=d,1<C?(A[e]=C++,z[e]=c):j(b)}else i=A[e];q(i,b),q(w,b)}function m(c){c.writeByte(x),remaining=a*b,curPixel=0,l(x+1,c),c.writeByte(0)}function n(a){s>0&&(a.writeByte(s),a.writeBytes(y,0,s),s=0)}function o(a){return(1<0?r|=a<=8;)e(255&r,b),r>>=8,B-=8;if((C>t||D)&&(D?(t=o(n_bits=u),D=!1):(++n_bits,t=n_bits==g?1<0;)e(255&r,b),r>>=8,B-=8;n(b)}}var r,s,t,u,v,w,x=Math.max(2,d),y=new Uint8Array(256),z=new Int32Array(h),A=new Int32Array(h),B=0,C=0,D=!1;this.encode=m}var f=-1,g=12,h=5003,i=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];a.exports=e}),b.define("/SimpleQuant.js",function(a,b,c,d){function e(a,b,c){return[a,b,c].join(".")}function f(a,b,c){this.pixels=a,this.palette=[],this.paletteIndex={},this.getColormap=function(){return this.palette},this.buildColormap=function(){for(var a=this.pixels.length/3,b=0,d=0;a>d;d++){var e=this.pixels[b++],f=this.pixels[b++],g=this.pixels[b++];this.addColorToPalette(e,f,g)}c&&this.addColorToPalette(c.r,c.g,c.b)},this.addColorToPalette=function(a,b,c){var d=e(a,b,c);this.paletteIndex.hasOwnProperty(d)||(this.palette.push(a),this.palette.push(b),this.palette.push(c),this.paletteIndex[d]=this.palette.length/3-1)},this.lookupRGB=function(a,b,c){return this.paletteIndex[e(a,b,c)]}}a.exports=f}),b.define("/TypedNeuQuant.js",function(a,b,c,d){function e(a,b){function c(){H=[],I=new Int32Array(256),J=new Int32Array(g),K=new Int32Array(g),L=new Int32Array(g>>3);var a,b;for(a=0;g>a;a++)b=(a<a;a++)H[a][0]>>=i,H[a][1]>>=i,H[a][2]>>=i,H[a][3]=a}function e(a,b,c,d,e){H[b][0]-=a*(H[b][0]-c)/v,H[b][1]-=a*(H[b][1]-d)/v,H[b][2]-=a*(H[b][2]-e)/v}function p(a,b,c,d,e){for(var f,h,i=Math.abs(b-a),j=Math.min(b+a,g),k=b+1,l=b-1,m=1;j>k||l>i;)h=L[m++],j>k&&(f=H[k++],f[0]-=h*(f[0]-c)/z,f[1]-=h*(f[1]-d)/z,f[2]-=h*(f[2]-e)/z),l>i&&(f=H[l--],f[0]-=h*(f[0]-c)/z,f[1]-=h*(f[1]-d)/z,f[2]-=h*(f[2]-e)/z)}function r(a,b,c){var d,e,f,h,k,p=2147483647,q=p,r=-1,s=r;for(d=0;g>d;d++)e=H[d],f=Math.abs(e[0]-a)+Math.abs(e[1]-b)+Math.abs(e[2]-c),p>f&&(p=f,r=d),h=f-(J[d]>>j-i),q>h&&(q=h,s=d),k=K[d]>>m,K[d]-=k,J[d]+=k<a;a++){for(c=H[a],e=a,f=c[1],b=a+1;g>b;b++)d=H[b],d[1]>1,b=i+1;f>b;b++)I[b]=a;i=f,j=a}}for(I[i]=j+h>>1,b=i+1;256>b;b++)I[b]=h}function w(a,b,c){for(var d,e,f,h=1e3,i=-1,j=I[b],k=j-1;g>j||k>=0;)g>j&&(e=H[j],f=e[1]-b,f>=h?j=g:(j++,0>f&&(f=-f),d=e[0]-a,0>d&&(d=-d),f+=d,h>f&&(d=e[2]-c,0>d&&(d=-d),f+=d,h>f&&(h=f,i=e[3])))),k>=0&&(e=H[k],f=b-e[1],f>=h?k=-1:(k--,0>f&&(f=-f),d=e[0]-a,0>d&&(d=-d),f+=d,h>f&&(d=e[2]-c,0>d&&(d=-d),f+=d,h>f&&(h=f,i=e[3]))));return i}function y(){var c,d=a.length,g=30+(b-1)/3,h=d/(3*b),j=~~(h/f),k=v,l=s,m=l>>q;for(1>=m&&(m=0),c=0;m>c;c++)L[c]=k*((m*m-c*c)*x/(m*m));var n;E>d?(b=1,n=3):n=d%A!==0?3*A:d%B!==0?3*B:d%C!==0?3*C:3*D;var o,u,w,y,z=0;for(c=0;h>c;)if(o=(255&a[z])<=d&&(z-=d),c++,0===j&&(j=1),c%j===0)for(k-=k/g,l-=l/t,m=l>>q,1>=m&&(m=0),y=0;m>y;y++)L[y]=k*((m*m-y*y)*x/(m*m))}function F(){c(),y(),d(),u()}function G(){for(var a=[],b=[],c=0;g>c;c++)b[H[c][3]]=c;for(var d=0,e=0;g>e;e++){var f=b[e];a[d++]=H[f][0],a[d++]=H[f][1],a[d++]=H[f][2]}return a}var H,I,J,K,L;this.buildColormap=F,this.getColormap=G,this.lookupRGB=w}var f=100,g=256,h=g-1,i=4,j=16,k=1<>m,o=k<>3,q=6,r=1<c;++c)if(c in b&&b[c]===a)return!0;return!1}function h(a,b){function c(){this.constructor=a}for(var d in b)f(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a}var i,j,k,l,m;k=b("events",a).EventEmitter,i=b("/browser.coffee",a),m=function(a){function b(a){var b,c;this.running=!1,this.options={},this.frames=[],this.freeWorkers=[],this.activeWorkers=[],this.setOptions(a);for(b in j)c=j[b],null!=this.options[b]?this.options[b]:this.options[b]=c}return h(b,a),j={workerScript:window.GifWorkerURL,workers:2,repeat:0,background:"#fff",quality:10,width:null,height:null,transparent:null,preserveColors:!1},l={delay:500,copy:!1},b.prototype.setOption=function(a,b){return this.options[a]=b,null==this._canvas||"width"!==a&&"height"!==a?void 0:this._canvas[a]=b},b.prototype.setOptions=function(a){var b,c;return function(d){for(b in a)f(a,b)&&(c=a[b],d.push(this.setOption(b,c)));return d}.call(this,[])},b.prototype.addFrame=function(a,b){var c,d;null==b&&(b={}),c={},c.transparent=this.options.transparent;for(d in l)c[d]=b[d]||l[d];if(null!=this.options.width||this.setOption("width",a.width),null!=this.options.height||this.setOption("height",a.height),"undefined"!=typeof ImageData&&null!=ImageData&&a instanceof ImageData)c.data=a.data;else if("undefined"!=typeof CanvasRenderingContext2D&&null!=CanvasRenderingContext2D&&a instanceof CanvasRenderingContext2D||"undefined"!=typeof WebGLRenderingContext&&null!=WebGLRenderingContext&&a instanceof WebGLRenderingContext)b.copy?c.data=this.getContextData(a):c.context=a;else{if(null==a.childNodes)throw new Error("Invalid image");b.copy?c.data=this.getImageData(a):c.image=a}return this.frames.push(c)},b.prototype.render=function(){var a,b;if(this.running)throw new Error("Already running");if(null==this.options.width||null==this.options.height)throw new Error("Width and height must be set prior to rendering");this.running=!0,this.nextFrame=0,this.finishedFrames=0,this.imageParts=function(b){for(var c=function(){var a;a=[];for(var b=0;0<=this.frames.length?bthis.frames.length;0<=this.frames.length?++b:--b)a.push(b);return a}.apply(this,arguments),d=0,e=c.length;e>d;++d)a=c[d],b.push(null);return b}.call(this,[]),b=this.spawnWorkers();for(var c=function(){var a;a=[];for(var c=0;b>=0?b>c:c>b;b>=0?++c:--c)a.push(c);return a}.apply(this,arguments),d=0,e=c.length;e>d;++d)a=c[d],this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},b.prototype.abort=function(){for(var a;;){if(a=this.activeWorkers.shift(),!(null!=a))break;console.log("killing active worker"),a.terminate()}return this.running=!1,this.emit("abort")},b.prototype.spawnWorkers=function(){var a;return a=Math.min(this.options.workers,this.frames.length),function(){var b;b=[];for(var c=this.freeWorkers.length;this.freeWorkers.length<=a?a>c:c>a;this.freeWorkers.length<=a?++c:--c)b.push(c);return b}.apply(this,arguments).forEach(function(a){return function(b){var c;return console.log("spawning worker "+b),c=new Worker(a.options.workerScript),c.onmessage=function(a){return function(b){return a.activeWorkers.splice(a.activeWorkers.indexOf(c),1),a.freeWorkers.push(c),a.frameFinished(b.data)}}(a),a.freeWorkers.push(c)}}(this)),a},b.prototype.frameFinished=function(a){return console.log("frame "+a.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[a.index]=a,g(null,this.imageParts)?this.renderNextFrame():this.finishRendering()},b.prototype.finishRendering=function(){var a,b,c,d,e,f,g;e=0;for(var h=0,i=this.imageParts.length;i>h;++h)b=this.imageParts[h],e+=(b.data.length-1)*b.pageSize+b.cursor;e+=b.pageSize-b.cursor,console.log("rendering finished - filesize "+Math.round(e/1e3)+"kb"),a=new Uint8Array(e),f=0;for(var j=0,k=this.imageParts.length;k>j;++j){b=this.imageParts[j];for(var l=0,m=b.data.length;m>l;++l)g=b.data[l],c=l,a.set(g,f),f+=c===b.data.length-1?b.cursor:b.pageSize}return d=new Blob([a],{type:"image/gif"}),this.emit("finished",d,a)},b.prototype.renderNextFrame=function(){var a,b,c;if(0===this.freeWorkers.length)throw new Error("No free workers");return this.nextFrame>=this.frames.length?void 0:(a=this.frames[this.nextFrame++],c=this.freeWorkers.shift(),b=this.getTask(a),console.log("starting frame "+(b.index+1)+" of "+this.frames.length),this.activeWorkers.push(c),c.postMessage(b))},b.prototype.getContextData=function(a){return a.getImageData(0,0,this.options.width,this.options.height).data},b.prototype.getImageData=function(a){var b;return null!=this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),b=this._canvas.getContext("2d"),b.setFill=this.options.background,b.fillRect(0,0,this.options.width,this.options.height),b.drawImage(a,0,0),this.getContextData(b)},b.prototype.getTask=function(a){var b,c;if(b=this.frames.indexOf(a),c={index:b,last:b===this.frames.length-1,delay:a.delay,transparent:a.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,preserveColors:this.options.preserveColors,repeat:this.options.repeat,canTransfer:"chrome"===i.name},null!=a.data)c.data=a.data;else if(null!=a.context)c.data=this.getContextData(a.context);else{if(null==a.image)throw new Error("Invalid frame");c.data=this.getImageData(a.image)}return c},b}(k),a.exports=m}),b.define("/browser.coffee",function(a,b,c,d){var e,f,g,h,i;h=navigator.userAgent.toLowerCase(),g=navigator.platform.toLowerCase(),i=h.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0],f="ie"===i[1]&&document.documentMode,e={name:"version"===i[1]?i[3]:i[1],version:f||parseFloat("opera"===i[1]&&i[4]?i[4]:i[2]),platform:{name:h.match(/ip(?:ad|od|hone)/)?"ios":(h.match(/(?:webos|android)/)||g.match(/mac|win|linux/)||["other"])[0]}},e[e.name]=!0,e[e.name+parseInt(e.version,10)]=!0,e.platform[e.platform.name]=!0,a.exports=e}),b.define("events",function(a,b,d,e){c.EventEmitter||(c.EventEmitter=function(){});var f=b.EventEmitter=c.EventEmitter,g="function"==typeof Array.isArray?Array.isArray:function(a){return"[object Array]"===Object.prototype.toString.call(a)},h=10;f.prototype.setMaxListeners=function(a){this._events||(this._events={}),this._events.maxListeners=a},f.prototype.emit=function(a){if("error"===a&&(!this._events||!this._events.error||g(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var b=this._events[a];if(!b)return!1;if("function"!=typeof b){if(g(b)){for(var c=Array.prototype.slice.call(arguments,1),d=b.slice(),e=0,f=d.length;f>e;e++)d[e].apply(this,c);return!0}return!1}switch(arguments.length){case 1:b.call(this);break;case 2:b.call(this,arguments[1]);break;case 3:b.call(this,arguments[1],arguments[2]);break;default:var c=Array.prototype.slice.call(arguments,1);b.apply(this,c)}return!0},f.prototype.addListener=function(a,b){if("function"!=typeof b)throw new Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",a,b),this._events[a])if(g(this._events[a])){if(!this._events[a].warned){var c;c=void 0!==this._events.maxListeners?this._events.maxListeners:h,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];else this._events[a]=b;return this},f.prototype.on=f.prototype.addListener,f.prototype.once=function(a,b){var c=this;return c.on(a,function d(){c.removeListener(a,d),b.apply(this,arguments)}),this},f.prototype.removeListener=function(a,b){if("function"!=typeof b)throw new Error("removeListener only takes instances of Function");if(!this._events||!this._events[a])return this;var c=this._events[a];if(g(c)){var d=c.indexOf(b);if(0>d)return this;c.splice(d,1),0==c.length&&delete this._events[a]}else this._events[a]===b&&delete this._events[a];return this},f.prototype.removeAllListeners=function(a){return a&&this._events&&this._events[a]&&(this._events[a]=null),this},f.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),g(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}),a.GIF=b("/gif.coffee")}.call(this,this),function(a){"use strict";var b=function(a){this.data=a,this.len=this.data.length,this.pos=0};b.prototype.readByte=function(){if(this.pos>=this.data.length)throw new Error("Attempted to read past end of stream.");return 255&this.data.charCodeAt(this.pos++)},b.prototype.readBytes=function(a){for(var b=[],c=0;a>c;c++)b.push(this.readByte());return b},b.prototype.read=function(a){for(var b="",c=0;a>c;c++)b+=String.fromCharCode(this.readByte());return b},b.prototype.readUnsigned=function(){var a=this.readBytes(2);return(a[1]<<8)+a[0]};var c=a.SuperGIF=a.SuperGIF||{};c.Stream=b}(window),function(a){"use strict";var b=function(a){return a.reduce(function(a,b){return 2*a+b},0)},c=function(a){for(var b=[],c=7;c>=0;c--)b.push(!!(a&1<=this.data.length)throw new Error("Attempted to read past end of stream.");return 255&a.charCodeAt(this.pos++)},this.readBytes=function(a){for(var b=[],c=0;a>c;c++)b.push(this.readByte());return b},this.read=function(a){for(var b="",c=0;a>c;c++)b+=String.fromCharCode(this.readByte());return b},this.readUnsigned=function(){var a=this.readBytes(2);return(a[1]<<8)+a[0]}},e=function(a,b){for(var c,d,e=0,f=function(a){for(var c=0,d=0;a>d;d++)b.charCodeAt(e>>3)&1<<(7&e)&&(c|=1<b;b++)k[b]=[b];k[h]=[],k[i]=null};;)if(d=c,c=f(j),c!==h){if(c===i)break;if(cj&&j++}else l();return g},f=function(a,d){d||(d={});var f=function(b){for(var c=[],d=0;b>d;d++)c.push(a.readBytes(3));return c},g=function(){var b,c;c="";do b=a.readByte(),c+=a.read(b);while(0!==b);return c},h=function(){var e={};if(e.sig=a.read(3),e.ver=a.read(3),"GIF"!==e.sig)throw d.onError(),new Error("Not a GIF file.");e.width=a.readUnsigned(),e.height=a.readUnsigned();var g=c(a.readByte());e.gctFlag=g.shift(),e.colorRes=b(g.splice(0,3)),e.sorted=g.shift(),e.gctSize=b(g.splice(0,3)),e.bgColor=a.readByte(),e.pixelAspectRatio=a.readByte(),e.gctFlag&&(e.gct=f(1<i;i++)for(var j=f[i];d>j;j+=g[i])e(j,h),h++;return c};h.leftPos=a.readUnsigned(),h.topPos=a.readUnsigned(),h.width=a.readUnsigned(),h.height=a.readUnsigned();var j=c(a.readByte());h.lctFlag=j.shift(),h.interlaced=j.shift(),h.sorted=j.shift(),h.reserved=j.splice(0,2),h.lctSize=b(j.splice(0,3)),h.lctFlag&&(h.lct=f(1<0&&(3===o?p.putImageData(r[n].data,0,0):n=b-1,2===o&&p.clearRect(q.leftPos,q.topPos,q.width,q.height));var d=p.getImageData(a.leftPos,a.topPos,a.width,a.height),e=d.data;a.pixels.forEach(function(a,b){a!==k&&(e[4*b+0]=c[a][0],e[4*b+1]=c[a][1],e[4*b+2]=c[a][2],e[4*b+3]=255)}),p.putImageData(d,a.leftPos,a.topPos),q=a},B={hdr:x,gce:y,img:A,eof:function(a){z(),j=!1,C&&C()},onError:function(a){E&&E()}},C=!1,D=!1,E=!1,F=document.createElement("canvas");return{load:function(b){if(C=b.success,D=b.step,E=b.error,j=!0,-1!==s.src.indexOf("data:")){var c=s.src.substring(s.src.indexOf(",")+1);g=new d(a.atob(c)),u()}else{var e=new XMLHttpRequest;e.overrideMimeType("text/plain; charset=x-user-defined"),e.onload=function(a){g=new d(e.responseText),setTimeout(u,0)},e.onerror=function(){w("xhr")},e.open("GET",s.getAttribute("data-animated-src")||s.src,!0),e.send()}},getFrames:function(){return r}}};a.SuperGif=g}(window),!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZip=a():"undefined"!=typeof global?global.JSZip=a():"undefined"!=typeof self&&(self.JSZip=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":6}],4:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":14}],5:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.date=null,c.compression=null},{}],6:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("zlibjs/bin/rawdeflate.min").Zlib,f=a("zlibjs/bin/rawinflate.min").Zlib;c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a){var b=new e.RawDeflate(a);return b.compress()},c.uncompress=function(a){var b=new f.RawInflate(a);return b.decompress()}},{"zlibjs/bin/rawdeflate.min":19,"zlibjs/bin/rawinflate.min":20}],7:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./utils"),c.base64=a("./base64"),c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":5,"./load":8,"./object":9,"./support":12,"./utils":14}],8:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},r=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},v=function(a){return"/"!=a.slice(-1)&&(a+="/"),this.files[a]||t.call(this,a,null,{dir:!0}),this.files[a]},w=function(a,b){var c,d=new k;return a._data instanceof k?(d.uncompressedSize=a._data.uncompressedSize,d.crc32=a._data.crc32,0===d.uncompressedSize||a.options.dir?(b=j.STORE,d.compressedContent="",d.crc32=0):a._data.compressionMethod===b.magic?d.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c)))):(c=n(a),(!c||0===c.length||a.options.dir)&&(b=j.STORE,c=""),d.uncompressedSize=c.length,d.crc32=this.crc32(c),d.compressedContent=b.compress(f.transformTo(b.compressInputType,c))),d.compressedSize=d.compressedContent.length,d.compressionMethod=b.magic,d},x=function(a,b,c,d){var e,f,h=(c.compressedContent,this.utf8encode(b.name)),i=h!==b.name,j=b.options,k="",l=""; -}function i(a){b.notify({index:f,value:a})}var j=a[f];c++,p(j,g,h,i)},void 0),b.promise}function L(a){return p(a,function(a){return a=$(a,k),p(J($(a,function(a){return p(a,U,U)})),function(){return a})})}function M(a){return k(a).allSettled()}function N(a,b){return k(a).then(void 0,void 0,b)}function O(a,b){return k(a).nodeify(b)}var P=!1;try{throw new Error}catch(Q){P=!!Q.stack}var R,S,T=i(),U=function(){},V=function(){function a(){for(;b.next;){b=b.next;var c=b.task;b.task=void 0;var e=b.domain;e&&(b.domain=void 0,e.enter());try{c()}catch(g){if(f)throw e&&e.exit(),setTimeout(a,0),e&&e.enter(),g;setTimeout(function(){throw g},0)}e&&e.exit()}d=!1}var b={task:void 0,next:null},c=b,d=!1,e=void 0,f=!1;if(V=function(a){c=c.next={task:a,domain:f&&process.domain,next:null},d||(d=!0,e())},"undefined"!=typeof process&&process.nextTick)f=!0,e=function(){process.nextTick(a)};else if("function"==typeof setImmediate)e="undefined"!=typeof window?setImmediate.bind(window,a):function(){setImmediate(a)};else if("undefined"!=typeof MessageChannel){var g=new MessageChannel;g.port1.onmessage=function(){e=h,g.port1.onmessage=a,a()};var h=function(){g.port2.postMessage(0)};e=function(){setTimeout(a,0),h()}}else e=function(){setTimeout(a,0)};return V}(),W=Function.call,X=a(Array.prototype.slice),Y=a(Array.prototype.reduce||function(a,b){var c=0,d=this.length;if(1===arguments.length)for(;;){if(c in this){b=this[c++];break}if(++c>=d)throw new TypeError}for(;d>c;c++)c in this&&(b=a(b,this[c],c));return b}),Z=a(Array.prototype.indexOf||function(a){for(var b=0;b2?X(arguments,1):c)}},k.Promise=m,k.promise=m,m.race=n,m.all=J,m.reject=z,m.resolve=k,k.passByCopy=function(a){return a},o.prototype.passByCopy=function(){return this},k.join=function(a,b){return k(a).join(b)},o.prototype.join=function(a){return k([this,a]).spread(function(a,b){if(a===b)return a;throw new Error("Can't join: not the same: "+a+" "+b)})},k.race=n,o.prototype.race=function(){return this.then(k.race)},k.makePromise=o,o.prototype.toString=function(){return"[object Promise]"},o.prototype.then=function(a,b,c){function e(b){try{return"function"==typeof a?a(b):b}catch(c){return z(c)}}function f(a){if("function"==typeof b){d(a,h);try{return b(a)}catch(c){return z(c)}}return z(a)}function g(a){return"function"==typeof c?c(a):a}var h=this,i=l(),j=!1;return k.nextTick(function(){h.promiseDispatch(function(a){j||(j=!0,i.resolve(e(a)))},"when",[function(a){j||(j=!0,i.resolve(f(a)))}])}),h.promiseDispatch(void 0,"when",[void 0,function(a){var b,c=!1;try{b=g(a)}catch(d){if(c=!0,!k.onerror)throw d;k.onerror(d)}c||i.notify(b)}]),i.promise},k.tap=function(a,b){return k(a).tap(b)},o.prototype.tap=function(a){return a=k(a),this.then(function(b){return a.fcall(b).thenResolve(b)})},k.when=p,o.prototype.thenResolve=function(a){return this.then(function(){return a})},k.thenResolve=function(a,b){return k(a).thenResolve(b)},o.prototype.thenReject=function(a){return this.then(function(){throw a})},k.thenReject=function(a,b){return k(a).thenReject(b)},k.nearer=q,k.isPromise=r,k.isPromiseAlike=s,k.isPending=t,o.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=u,o.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=v,o.prototype.isRejected=function(){return"rejected"===this.inspect().state};var ea=[],fa=[],ga=!0;k.resetUnhandledRejections=w,k.getUnhandledReasons=function(){return ea.slice()},k.stopUnhandledRejectionTracking=function(){w(),ga=!1},w(),k.reject=z,k.fulfill=A,k.master=C,k.spread=D,o.prototype.spread=function(a,b){return this.all().then(function(b){return a.apply(void 0,b)},b)},k.async=E,k.spawn=F,k["return"]=G,k.promised=H,k.dispatch=I,o.prototype.dispatch=function(a,b){var c=this,d=l();return k.nextTick(function(){c.promiseDispatch(d.resolve,a,b)}),d.promise},k.get=function(a,b){return k(a).dispatch("get",[b])},o.prototype.get=function(a){return this.dispatch("get",[a])},k.set=function(a,b,c){return k(a).dispatch("set",[b,c])},o.prototype.set=function(a,b){return this.dispatch("set",[a,b])},k.del=k["delete"]=function(a,b){return k(a).dispatch("delete",[b])},o.prototype.del=o.prototype["delete"]=function(a){return this.dispatch("delete",[a])},k.mapply=k.post=function(a,b,c){return k(a).dispatch("post",[b,c])},o.prototype.mapply=o.prototype.post=function(a,b){return this.dispatch("post",[a,b])},k.send=k.mcall=k.invoke=function(a,b){return k(a).dispatch("post",[b,X(arguments,2)])},o.prototype.send=o.prototype.mcall=o.prototype.invoke=function(a){return this.dispatch("post",[a,X(arguments,1)])},k.fapply=function(a,b){return k(a).dispatch("apply",[void 0,b])},o.prototype.fapply=function(a){return this.dispatch("apply",[void 0,a])},k["try"]=k.fcall=function(a){return k(a).dispatch("apply",[void 0,X(arguments,1)])},o.prototype.fcall=function(){return this.dispatch("apply",[void 0,X(arguments)])},k.fbind=function(a){var b=k(a),c=X(arguments,1);return function(){return b.dispatch("apply",[this,c.concat(X(arguments))])}},o.prototype.fbind=function(){var a=this,b=X(arguments);return function(){return a.dispatch("apply",[this,b.concat(X(arguments))])}},k.keys=function(a){return k(a).dispatch("keys",[])},o.prototype.keys=function(){return this.dispatch("keys",[])},k.all=J,o.prototype.all=function(){return J(this)},k.any=K,o.prototype.any=function(){return K(this)},k.allResolved=j(L,"allResolved","allSettled"),o.prototype.allResolved=function(){return L(this)},k.allSettled=M,o.prototype.allSettled=function(){return this.then(function(a){return J($(a,function(a){function b(){return a.inspect()}return a=k(a),a.then(b,b)}))})},k.fail=k["catch"]=function(a,b){return k(a).then(void 0,b)},o.prototype.fail=o.prototype["catch"]=function(a){return this.then(void 0,a)},k.progress=N,o.prototype.progress=function(a){return this.then(void 0,void 0,a)},k.fin=k["finally"]=function(a,b){return k(a)["finally"](b)},o.prototype.fin=o.prototype["finally"]=function(a){return a=k(a),this.then(function(b){return a.fcall().then(function(){return b})},function(b){return a.fcall().then(function(){throw b})})},k.done=function(a,b,c,d){return k(a).done(b,c,d)},o.prototype.done=function(a,b,c){var e=function(a){k.nextTick(function(){if(d(a,f),!k.onerror)throw a;k.onerror(a)})},f=a||b||c?this.then(a,b,c):this;"object"==typeof process&&process&&process.domain&&(e=process.domain.bind(e)),f.then(void 0,e)},k.timeout=function(a,b,c){return k(a).timeout(b,c)},o.prototype.timeout=function(a,b){var c=l(),d=setTimeout(function(){b&&"string"!=typeof b||(b=new Error(b||"Timed out after "+a+" ms"),b.code="ETIMEDOUT"),c.reject(b)},a);return this.then(function(a){clearTimeout(d),c.resolve(a)},function(a){clearTimeout(d),c.reject(a)},c.notify),c.promise},k.delay=function(a,b){return void 0===b&&(b=a,a=void 0),k(a).delay(b)},o.prototype.delay=function(a){return this.then(function(b){var c=l();return setTimeout(function(){c.resolve(b)},a),c.promise})},k.nfapply=function(a,b){return k(a).nfapply(b)},o.prototype.nfapply=function(a){var b=l(),c=X(a);return c.push(b.makeNodeResolver()),this.fapply(c).fail(b.reject),b.promise},k.nfcall=function(a){var b=X(arguments,1);return k(a).nfapply(b)},o.prototype.nfcall=function(){var a=X(arguments),b=l();return a.push(b.makeNodeResolver()),this.fapply(a).fail(b.reject),b.promise},k.nfbind=k.denodeify=function(a){var b=X(arguments,1);return function(){var c=b.concat(X(arguments)),d=l();return c.push(d.makeNodeResolver()),k(a).fapply(c).fail(d.reject),d.promise}},o.prototype.nfbind=o.prototype.denodeify=function(){var a=X(arguments);return a.unshift(this),k.denodeify.apply(void 0,a)},k.nbind=function(a,b){var c=X(arguments,2);return function(){function d(){return a.apply(b,arguments)}var e=c.concat(X(arguments)),f=l();return e.push(f.makeNodeResolver()),k(d).fapply(e).fail(f.reject),f.promise}},o.prototype.nbind=function(){var a=X(arguments,0);return a.unshift(this),k.nbind.apply(void 0,a)},k.nmapply=k.npost=function(a,b,c){return k(a).npost(b,c)},o.prototype.nmapply=o.prototype.npost=function(a,b){var c=X(b||[]),d=l();return c.push(d.makeNodeResolver()),this.dispatch("post",[a,c]).fail(d.reject),d.promise},k.nsend=k.nmcall=k.ninvoke=function(a,b){var c=X(arguments,2),d=l();return c.push(d.makeNodeResolver()),k(a).dispatch("post",[b,c]).fail(d.reject),d.promise},o.prototype.nsend=o.prototype.nmcall=o.prototype.ninvoke=function(a){var b=X(arguments,1),c=l();return b.push(c.makeNodeResolver()),this.dispatch("post",[a,b]).fail(c.reject),c.promise},k.nodeify=O,o.prototype.nodeify=function(a){return a?void this.then(function(b){k.nextTick(function(){a(null,b)})},function(b){k.nextTick(function(){a(b)})}):this};var ha=i();return k}),function(){var a=$.namespace("pskl.rendering");a.DrawingLoop=function(){this.requestAnimationFrame=this.getRequestAnimationFrameShim_(),this.isRunning=!1,this.previousTime=0,this.callbacks=[]},a.DrawingLoop.prototype.addCallback=function(a,b,c){var d={fn:a,scope:b,args:c};return this.callbacks.push(d),d},a.DrawingLoop.prototype.removeCallback=function(a){var b=this.callbacks.indexOf(a);-1!=b&&this.callbacks.splice(b,1)},a.DrawingLoop.prototype.start=function(){this.isRunning=!0,this.loop_()},a.DrawingLoop.prototype.loop_=function(){var a=Date.now(),b=a-this.previousTime;this.executeCallbacks_(b),this.previousTime=a,this.requestAnimationFrame.call(window,this.loop_.bind(this))},a.DrawingLoop.prototype.executeCallbacks_=function(a){for(var b=0;bd;d++){for(var e=[],f=0;b>f;f++)e.push(Constants.TRANSPARENT_COLOR);c[d]=e}return c},a.Frame.createEmptyFromFrame=function(b){return new a.Frame(b.getWidth(),b.getHeight())},a.Frame.prototype.clone=function(){var b=new a.Frame(this.width,this.height);return b.setPixels(this.getPixels()),b},a.Frame.prototype.getPixels=function(){return this.clonePixels_(this.pixels)},a.Frame.prototype.setPixels=function(a){this.pixels=this.clonePixels_(a),this.version++},a.Frame.prototype.clear=function(){var b=a.Frame.createEmptyPixelGrid_(this.getWidth(),this.getHeight());this.setPixels(b)},a.Frame.prototype.clonePixels_=function(a){for(var b=[],c=0;cd;d++)for(var e=0;c>e;e++)a(this.pixels[d][e],d,e,this)},a.Frame.prototype.getWidth=function(){return this.width},a.Frame.prototype.getHeight=function(){return this.height},a.Frame.prototype.containsPixel=function(a,b){return a>=0&&b>=0&&a0&&a[0].size()>0))throw"Piskel.fromLayers expects array of non empty pskl.model.Layer as first argument";var d=a[0].getFrameAt(0);return c=new pskl.model.Piskel(d.getWidth(),d.getHeight(),b),a.forEach(c.addLayer.bind(c)),c},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getHeight=function(){return this.height},a.Piskel.prototype.getWidth=function(){return this.width},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getLayerAt=function(a){return this.layers[a]},a.Piskel.prototype.getLayersByName=function(a){return this.layers.filter(function(b){return b.getName()==a})},a.Piskel.prototype.addLayer=function(a){this.layers.push(a)},a.Piskel.prototype.addLayerAt=function(a,b){this.layers.splice(b,0,a)},a.Piskel.prototype.moveLayerUp=function(a){var b=this.layers.indexOf(a);b>-1&&b0&&(this.layers[b]=this.layers[b-1],this.layers[b-1]=a)},a.Piskel.prototype.removeLayer=function(a){var b=this.layers.indexOf(a);-1!=b&&this.layers.splice(b,1)},a.Piskel.prototype.removeLayerAt=function(a){this.layers.splice(a,1)},a.Piskel.prototype.getDescriptor=function(){return this.descriptor},a.Piskel.prototype.setDescriptor=function(a){this.descriptor=a;$(".piskel-name").html(this.descriptor.name)},a.Piskel.prototype.getHash=function(){return this.layers.map(function(a){return a.getHash()}).join("-")}}(),function(){var a=$.namespace("pskl.selection"),b={PASTE:"REPLAY_PASTE",ERASE:"REPLAY_ERASE"};a.SelectionManager=function(a){this.piskelController=a,this.currentSelection=null},a.SelectionManager.prototype.init=function(){$.subscribe(Events.SELECTION_CREATED,$.proxy(this.onSelectionCreated_,this)),$.subscribe(Events.SELECTION_DISMISSED,$.proxy(this.onSelectionDismissed_,this)),$.subscribe(Events.SELECTION_MOVE_REQUEST,$.proxy(this.onSelectionMoved_,this)),pskl.app.shortcutService.addShortcut("ctrl+V",this.paste.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+X",this.cut.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+C",this.copy.bind(this)),pskl.app.shortcutService.addShortcut("del",this.erase.bind(this)),pskl.app.shortcutService.addShortcut("back",this.onBackPressed_.bind(this)),$.subscribe(Events.TOOL_SELECTED,$.proxy(this.onToolSelected_,this))},a.SelectionManager.prototype.cleanSelection_=function(){this.currentSelection&&(this.currentSelection.reset(),this.currentSelection=null)},a.SelectionManager.prototype.onToolSelected_=function(a,b){var c=b instanceof pskl.tools.drawing.BaseSelect;c||this.cleanSelection_()},a.SelectionManager.prototype.onSelectionDismissed_=function(a){this.cleanSelection_()},a.SelectionManager.prototype.onBackPressed_=function(a){return this.currentSelection?void this.erase():!0},a.SelectionManager.prototype.erase=function(){for(var a=this.currentSelection.pixels,c=this.piskelController.getCurrentFrame(),d=0,e=a.length;e>d;d++)c.setPixel(a[d].col,a[d].row,Constants.TRANSPARENT_COLOR);$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{type:b.ERASE,pixels:JSON.parse(JSON.stringify(a.slice(0)))}})},a.SelectionManager.prototype.cut=function(){this.currentSelection&&(this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame()),this.erase())},a.SelectionManager.prototype.paste=function(){if(this.currentSelection&&this.currentSelection.hasPastedContent){var a=this.currentSelection.pixels,b=a.filter(function(a){return a.color!==Constants.TRANSPARENT_COLOR});this.pastePixels(b)}},a.SelectionManager.prototype.pastePixels=function(a){var c=this.piskelController.getCurrentFrame();a.forEach(function(a){c.setPixel(a.col,a.row,a.color)}),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{type:b.PASTE,pixels:JSON.parse(JSON.stringify(a.slice(0)))}})},a.SelectionManager.prototype.replay=function(a,c){var d=c.pixels;d.forEach(function(d){var e=c.type===b.PASTE?d.color:Constants.TRANSPARENT_COLOR;a.setPixel(d.col,d.row,e)})},a.SelectionManager.prototype.copy=function(){this.currentSelection&&this.piskelController.getCurrentFrame()&&this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame())},a.SelectionManager.prototype.onSelectionCreated_=function(a,b){b?this.currentSelection=b:console.error("No selection provided to SelectionManager")},a.SelectionManager.prototype.onSelectionMoved_=function(a,b,c){this.currentSelection?this.currentSelection.move(b,c):console.error("Bad state: No currentSelection set when trying to move it in SelectionManager")}}(),function(){var a=$.namespace("pskl.selection");a.BaseSelection=function(){this.reset()},a.BaseSelection.prototype.reset=function(){this.pixels=[],this.hasPastedContent=!1},a.BaseSelection.prototype.move=function(a,b){for(var c=[],d=0,e=this.pixels.length;e>d;d++){var f=this.pixels[d];f.col+=a,f.row+=b,c.push(f)}this.pixels=c},a.BaseSelection.prototype.fillSelectionFromFrame=function(a){this.pixels.forEach(function(b){b.color=a.getPixel(b.col,b.row)}),this.hasPastedContent=!0}}(),function(){var a=$.namespace("pskl.selection");a.RectangularSelection=function(a,b,c,d){this.pixels=pskl.PixelUtils.getRectanglePixels(a,b,c,d)},pskl.utils.inherit(a.RectangularSelection,a.BaseSelection)}(),function(){var a=$.namespace("pskl.selection");a.ShapeSelection=function(a){this.pixels=a},pskl.utils.inherit(a.ShapeSelection,a.BaseSelection)}(),function(){var a=$.namespace("pskl.rendering");a.AbstractRenderer=function(){},a.AbstractRenderer.prototype.clear=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.render=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getCoordinates=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setGridWidth=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getGridWidth=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setZoom=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getZoom=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setOffset=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getOffset=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setDisplaySize=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getDisplaySize=Constants.ABSTRACT_FUNCTION}(),function(){var a=$.namespace("pskl.rendering");a.CompositeRenderer=function(){this.renderers=[]},pskl.utils.inherit(pskl.rendering.CompositeRenderer,pskl.rendering.AbstractRenderer),a.CompositeRenderer.prototype.add=function(a){return this.renderers.push(a),this},a.CompositeRenderer.prototype.clear=function(){this.renderers.forEach(function(a){a.clear()})},a.CompositeRenderer.prototype.setZoom=function(a){this.renderers.forEach(function(b){b.setZoom(a)})},a.CompositeRenderer.prototype.getZoom=function(){return this.getSampleRenderer_().getZoom()},a.CompositeRenderer.prototype.setDisplaySize=function(a,b){this.renderers.forEach(function(c){c.setDisplaySize(a,b)})},a.CompositeRenderer.prototype.getDisplaySize=function(){return this.getSampleRenderer_().getDisplaySize()},a.CompositeRenderer.prototype.setOffset=function(a,b){this.renderers.forEach(function(c){c.setOffset(a,b)})},a.CompositeRenderer.prototype.getOffset=function(){return this.getSampleRenderer_().getOffset()},a.CompositeRenderer.prototype.setGridWidth=function(a){this.renderers.forEach(function(b){b.setGridWidth(a)})},a.CompositeRenderer.prototype.getGridWidth=function(){return this.getSampleRenderer_().getGridWidth()},a.CompositeRenderer.prototype.getSampleRenderer_=function(){if(this.renderers.length>0)return this.renderers[0];throw"Renderer manager is empty"}}(),function(){var a=$.namespace("pskl.rendering.layer");a.LayersRenderer=function(a,b,c){pskl.rendering.CompositeRenderer.call(this),this.piskelController=c,this.belowRenderer=new pskl.rendering.frame.FrameRenderer(a,b,["layers-canvas","layers-below-canvas"]),this.aboveRenderer=new pskl.rendering.frame.FrameRenderer(a,b,["layers-canvas","layers-above-canvas"]),this.add(this.belowRenderer),this.add(this.aboveRenderer),this.serializedRendering="",$.subscribe(Events.PISKEL_RESET,this.flush.bind(this))},pskl.utils.inherit(pskl.rendering.layer.LayersRenderer,pskl.rendering.CompositeRenderer),a.LayersRenderer.prototype.render=function(){var a=this.getOffset(),b=this.getDisplaySize(),c=this.piskelController.getLayers(),d=this.piskelController.getCurrentFrameIndex(),e=this.piskelController.getCurrentLayerIndex(),f=c.slice(0,e),g=c.slice(e+1,c.length),h=[this.getZoom(),this.getGridWidth(),a.x,a.y,b.width,b.height,this.getHashForLayersAt_(d,f),this.getHashForLayersAt_(d,g),c.length].join("-");if(this.serializedRendering!=h){if(this.serializedRendering=h,this.clear(),f.length>0){var i=this.getFrameForLayersAt_(d,f);this.belowRenderer.render(i)}if(g.length>0){var j=this.getFrameForLayersAt_(d,g);this.aboveRenderer.render(j)}}},a.LayersRenderer.prototype.setDisplaySize=function(a,b){var c=this.getDisplaySize();(c.width!==a||c.height!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.LayersRenderer.prototype.getFrameForLayersAt_=function(a,b){var c=b.map(function(b){return b.getFrameAt(a)});return pskl.utils.FrameUtils.merge(c)},a.LayersRenderer.prototype.getHashForLayersAt_=function(a,b){var c=b.map(function(b){return b.getFrameAt(a).getHash()});return c.join("-")},a.LayersRenderer.prototype.flush=function(){this.serializedRendering=""}}(),function(){var a=$.namespace("pskl.rendering.frame");a.FrameRenderer=function(a,b,c){if(this.defaultRenderingOptions={supportGridRendering:!1,zoom:1},b=$.extend(!0,{},this.defaultRenderingOptions,b),void 0===a)throw"Bad FrameRenderer initialization. undefined.";if(isNaN(b.zoom))throw"Bad FrameRenderer initialization. not well defined.";this.container=a,this.zoom=b.zoom,this.offset={x:0,y:0},this.margin={x:0,y:0},this.supportGridRendering=b.supportGridRendering,this.classList=c||[],this.classList.push("canvas"),this.canvas=null,this.displayCanvas=null,this.setDisplaySize(b.width,b.height),this.setGridWidth(pskl.UserSettings.get(pskl.UserSettings.GRID_WIDTH)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this))},pskl.utils.inherit(pskl.rendering.frame.FrameRenderer,pskl.rendering.AbstractRenderer),a.FrameRenderer.prototype.render=function(a){a&&(this.clear(),this.renderFrame_(a))},a.FrameRenderer.prototype.clear=function(){pskl.utils.CanvasUtils.clear(this.canvas),pskl.utils.CanvasUtils.clear(this.displayCanvas)},a.FrameRenderer.prototype.setZoom=function(a){if(a>Constants.MINIMUM_ZOOM){var b=this.offset.x+this.displayWidth/(2*this.zoom),c=this.offset.y+this.displayHeight/(2*this.zoom);this.zoom=a,this.setOffset(b-this.displayWidth/(2*this.zoom),c-this.displayHeight/(2*this.zoom))}},a.FrameRenderer.prototype.getZoom=function(){return this.zoom},a.FrameRenderer.prototype.setDisplaySize=function(a,b){this.displayWidth=a,this.displayHeight=b,this.displayCanvas&&($(this.displayCanvas).remove(),this.displayCanvas=null),this.createDisplayCanvas_()},a.FrameRenderer.prototype.getDisplaySize=function(){return{height:this.displayHeight,width:this.displayWidth}},a.FrameRenderer.prototype.getOffset=function(){return{x:this.offset.x,y:this.offset.y}},a.FrameRenderer.prototype.setOffset=function(a,b){var c=pskl.app.piskelController.getWidth(),d=pskl.app.piskelController.getHeight(),e=c-this.displayWidth/this.zoom;a=pskl.utils.Math.minmax(a,0,e);var f=d-this.displayHeight/this.zoom;b=pskl.utils.Math.minmax(b,0,f),this.offset.x=a,this.offset.y=b},a.FrameRenderer.prototype.setGridWidth=function(a){this.gridWidth_=a},a.FrameRenderer.prototype.getGridWidth=function(){return this.supportGridRendering?this.gridWidth_:0},a.FrameRenderer.prototype.updateMargins_=function(a){var b=this.displayWidth-this.zoom*a.getWidth();this.margin.x=Math.max(0,b)/2;var c=this.displayHeight-this.zoom*a.getHeight();this.margin.y=Math.max(0,c)/2},a.FrameRenderer.prototype.createDisplayCanvas_=function(){var a=this.displayHeight,b=this.displayWidth;this.displayCanvas=pskl.utils.CanvasUtils.createCanvas(b,a,this.classList),pskl.utils.CanvasUtils.disableImageSmoothing(this.displayCanvas),this.container.append(this.displayCanvas)},a.FrameRenderer.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.GRID_WIDTH&&this.setGridWidth(c)},a.FrameRenderer.prototype.getCoordinates=function(a,b){var c=this.container.offset();a-=c.left,b-=c.top,a-=this.margin.x,b-=this.margin.y;var d=this.zoom;return a+=this.offset.x*d,b+=this.offset.y*d,{x:Math.floor(a/d),y:Math.floor(b/d)}},a.FrameRenderer.prototype.reverseCoordinates=function(a,b){var c=this.zoom;a*=c,b*=c,a-=this.offset.x*c,b-=this.offset.y*c,a+=this.margin.x,b+=this.margin.y;var d=this.container.offset();return a+=d.left,b+=d.top,{x:a+c/2,y:b+c/2}},a.FrameRenderer.prototype.renderFrame_=function(a){this.canvas&&a.getWidth()==this.canvas.width&&a.getHeight()==this.canvas.height||(this.canvas=pskl.utils.CanvasUtils.createCanvas(a.getWidth(),a.getHeight()));for(var b=this.canvas.getContext("2d"),c=0,d=a.getWidth();d>c;c++)for(var e=0,f=a.getHeight();f>e;e++){for(var g=a.getPixel(c,e),h=1;g===a.getPixel(c,e+h);)h++;this.renderLine_(g,c,e,h,b),e=e+h-1}this.updateMargins_(a);var i=this.displayCanvas.getContext("2d");i.save();var j=this.canvas.height*this.zoom0;if(n||l){var o=pskl.utils.ImageResizer.resizeNearestNeighbour(this.canvas,this.zoom,m);i.drawImage(o,0,0)}else i.scale(this.zoom,this.zoom),i.drawImage(this.canvas,0,0);i.restore()},a.FrameRenderer.prototype.renderPixel_=function(a,b,c,d){a!=Constants.TRANSPARENT_COLOR&&(d.fillStyle=a,d.fillRect(b,c,1,1))},a.FrameRenderer.prototype.renderLine_=function(a,b,c,d,e){a!=Constants.TRANSPARENT_COLOR&&(e.fillStyle=a,e.fillRect(b,c,1,d))}}(),function(){var a=$.namespace("pskl.rendering");a.OnionSkinRenderer=function(a,b){pskl.rendering.CompositeRenderer.call(this),this.piskelController=b,this.renderer=a,this.add(this.renderer),this.hash=""},a.OnionSkinRenderer.createInContainer=function(b,c,d){var e=new pskl.rendering.frame.FrameRenderer(b,c,["onion-skin-canvas"]);return new a.OnionSkinRenderer(e,d)},pskl.utils.inherit(pskl.rendering.OnionSkinRenderer,pskl.rendering.CompositeRenderer),a.OnionSkinRenderer.prototype.render=function(){var a=this.getOnionFrames_(),b=this.computeHash_(a);if(this.hash!=b&&(this.hash=b,this.clear(),a.length>0)){var c=pskl.utils.FrameUtils.merge(a);this.renderer.render(c)}},a.OnionSkinRenderer.prototype.getOnionFrames_=function(){var a=[],b=this.piskelController.getCurrentFrameIndex(),c=this.piskelController.getCurrentLayer(),d=b-1,e=c.getFrameAt(d); +e=j.date.getHours(),e<<=6,e|=j.date.getMinutes(),e<<=5,e|=j.date.getSeconds()/2,f=j.date.getFullYear()-1980,f<<=4,f|=j.date.getMonth()+1,f<<=5,f|=j.date.getDate(),i&&(l=q(1,1)+q(this.crc32(h),4)+h,k+="up"+q(l.length,2)+l);var m="";m+="\n\x00",m+=i?"\x00\b":"\x00\x00",m+=c.compressionMethod,m+=q(e,2),m+=q(f,2),m+=q(c.crc32,4),m+=q(c.compressedSize,4),m+=q(c.uncompressedSize,4),m+=q(h.length,2),m+=q(k.length,2);var n=g.LOCAL_FILE_HEADER+m+h+k,o=g.CENTRAL_FILE_HEADER+"\x00"+m+"\x00\x00\x00\x00\x00\x00"+(b.options.dir===!0?"\x00\x00\x00":"\x00\x00\x00\x00")+q(d,4)+h+k;return{fileRecord:n,dirRecord:o,compressedObject:c}},y=function(){this.data=[]};y.prototype={append:function(a){a=f.transformTo("string",a),this.data.push(a)},finalize:function(){return this.data.join("")}};var z=function(a){this.data=new Uint8Array(a),this.index=0};z.prototype={append:function(a){0!==a.length&&(a=f.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}};var A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new p(d.name,d._data,r(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(f.isRegExp(a)){var d=a;return this.filter(function(a,b){return!b.options.dir&&d.test(a)})}return this.filter(function(b,c){return!c.options.dir&&b===a})[0]||null}return a=this.root+a,t.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(f.isRegExp(a))return this.filter(function(b,c){return c.options.dir&&a.test(b)});var b=this.root+a,c=v.call(this,b),d=this.clone();return d.root=c.name,d},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b)if(b.options.dir)for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;di;i++)h=c?a[i]:a.charCodeAt(i),g=255&(b^h),e=d[g],b=b>>>8^e;return-1^b},utf8encode:function(a){if(c){var b=c.encode(a);return f.transformTo("string",b)}if(e.nodebuffer)return f.transformTo("string",l(a,"utf-8"));for(var d=[],g=0,h=0;hi?d[g++]=String.fromCharCode(i):i>127&&2048>i?(d[g++]=String.fromCharCode(i>>6|192),d[g++]=String.fromCharCode(63&i|128)):(d[g++]=String.fromCharCode(i>>12|224),d[g++]=String.fromCharCode(i>>6&63|128),d[g++]=String.fromCharCode(63&i|128))}return d.join("")},utf8decode:function(a){var b=[],c=0,g=f.getTypeOf(a),h="string"!==g,i=0,j=0,k=0,l=0;if(d)return d.decode(f.transformTo("uint8array",a));if(e.nodebuffer)return f.transformTo("nodebuffer",a).toString("utf-8");for(;ij?(b[c++]=String.fromCharCode(j),i++):j>191&&224>j?(k=h?a[i+1]:a.charCodeAt(i+1),b[c++]=String.fromCharCode((31&j)<<6|63&k),i+=2):(k=h?a[i+1]:a.charCodeAt(i+1),l=h?a[i+2]:a.charCodeAt(i+2),b[c++]=String.fromCharCode((15&j)<<12|(63&k)<<6|63&l),i+=3);return b.join("")}};b.exports=A},{"./base64":1,"./compressedObject":2,"./compressions":3,"./defaults":5,"./nodeBuffer":17,"./signature":10,"./support":12,"./utils":14}],10:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],11:[function(a,b){"use strict";function c(a,b){this.data=a,b||(this.data=e.string2binary(this.data)),this.length=this.data.length,this.index=0}var d=a("./dataReader"),e=a("./utils");c.prototype=new d,c.prototype.byteAt=function(a){return this.data.charCodeAt(a)},c.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4,"./utils":14}],12:[function(a,b,c){var d=a("__browserify_process");if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c.nodebuffer=!d.browser,c.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)c.blob=!1;else{var e=new ArrayBuffer(0);try{c.blob=0===new Blob([e],{type:"application/zip"}).size}catch(f){try{var g=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,h=new g;h.append(e),c.blob=0===h.getBlob("application/zip").size}catch(f){c.blob=!1}}}},{__browserify_process:18}],13:[function(a,b){"use strict";function c(a){a&&(this.data=a,this.length=this.data.length,this.index=0)}var d=a("./dataReader");c.prototype=new d,c.prototype.byteAt=function(a){return this.data[a]},c.prototype.lastIndexOfSignature=function(a){for(var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.length-4;f>=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){this.checkOffset(a);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":4}],14:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":17,"./support":12}],15:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],19:[function(){(function(){"use strict";function a(a,b){var c=a.split("."),d=n;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||b===l?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a,b){if(this.index="number"==typeof b?b:0,this.d=0,this.buffer=a instanceof(o?Uint8Array:Array)?a:new(o?Uint8Array:Array)(32768),2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&c(this)}function c(a){var b,c=a.buffer,d=c.length,e=new(o?Uint8Array:Array)(d<<1);if(o)e.set(c);else for(b=0;d>b;++b)e[b]=c[b];return a.buffer=e}function d(a){this.buffer=new(o?Uint16Array:Array)(2*a),this.length=0}function e(a,b){this.e=w,this.f=0,this.input=o&&a instanceof Array?new Uint8Array(a):a,this.c=0,b&&(b.lazy&&(this.f=b.lazy),"number"==typeof b.compressionType&&(this.e=b.compressionType),b.outputBuffer&&(this.b=o&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"==typeof b.outputIndex&&(this.c=b.outputIndex)),this.b||(this.b=new(o?Uint8Array:Array)(32768))}function f(a,b){this.length=a,this.g=b}function g(a,b){function c(a,b){var c,d=a.g,e=[],f=0;c=z[a.length],e[f++]=65535&c,e[f++]=c>>16&255,e[f++]=c>>24;var g;switch(m){case 1===d:g=[0,d-1,0];break;case 2===d:g=[1,d-2,0];break;case 3===d:g=[2,d-3,0];break;case 4===d:g=[3,d-4,0];break;case 6>=d:g=[4,d-5,1];break;case 8>=d:g=[5,d-7,1];break;case 12>=d:g=[6,d-9,2];break;case 16>=d:g=[7,d-13,2];break;case 24>=d:g=[8,d-17,3];break;case 32>=d:g=[9,d-25,3];break;case 48>=d:g=[10,d-33,4];break;case 64>=d:g=[11,d-49,4];break;case 96>=d:g=[12,d-65,5];break;case 128>=d:g=[13,d-97,5];break;case 192>=d:g=[14,d-129,6];break;case 256>=d:g=[15,d-193,6];break;case 384>=d:g=[16,d-257,7];break;case 512>=d:g=[17,d-385,7];break;case 768>=d:g=[18,d-513,8];break;case 1024>=d:g=[19,d-769,8];break;case 1536>=d:g=[20,d-1025,9];break;case 2048>=d:g=[21,d-1537,9];break;case 3072>=d:g=[22,d-2049,10];break;case 4096>=d:g=[23,d-3073,10];break;case 6144>=d:g=[24,d-4097,11];break;case 8192>=d:g=[25,d-6145,11];break;case 12288>=d:g=[26,d-8193,12];break;case 16384>=d:g=[27,d-12289,12];break;case 24576>=d:g=[28,d-16385,13];break;case 32768>=d:g=[29,d-24577,13];break;default:throw"invalid distance"}c=g,e[f++]=c[0],e[f++]=c[1],e[f++]=c[2];var h,i;for(h=0,i=e.length;i>h;++h)r[s++]=e[h];u[e[0]]++,v[e[3]]++,t=a.length+b-1,n=null}var d,e,f,g,i,j,k,n,p,q={},r=o?new Uint16Array(2*b.length):[],s=0,t=0,u=new(o?Uint32Array:Array)(286),v=new(o?Uint32Array:Array)(30),w=a.f;if(!o){for(f=0;285>=f;)u[f++]=0;for(f=0;29>=f;)v[f++]=0}for(u[256]=1,d=0,e=b.length;e>d;++d){for(f=i=0,g=3;g>f&&d+f!==e;++f)i=i<<8|b[d+f];if(q[i]===l&&(q[i]=[]),j=q[i],!(0=e){for(n&&c(n,-1),f=0,g=e-d;g>f;++f)p=b[d+f],r[s++]=p,++u[p];break}0h;h++){if(d=c[j-h-1],g=3,k>3){for(i=k;i>3;i--)if(a[d+i-1]!==a[b+i-1])continue a;g=k}for(;258>g&&l>b+g&&a[d+g]===a[b+g];)++g;if(g>k&&(e=d,k=g),258===g)break}return new f(k,b-e)}function i(a,b){var c,e,f,g,h,i=a.length,k=new d(572),l=new(o?Uint8Array:Array)(i);if(!o)for(g=0;i>g;g++)l[g]=0;for(g=0;i>g;++g)0g;++g)c[g]=k.pop(),e[g]=c[g].value;for(f=j(e,e.length,b),g=0,h=c.length;h>g;++g)l[c[g].index]=f[g];return l}function j(a,b,c){function d(a){var c=n[a][p[a]];c===b?(d(a+1),d(a+1)):--l[c],++p[a]}var e,f,g,h,i,j=new(o?Uint16Array:Array)(c),k=new(o?Uint8Array:Array)(c),l=new(o?Uint8Array:Array)(b),m=Array(c),n=Array(c),p=Array(c),q=(1<f;++f)r>q?k[f]=0:(k[f]=1,q-=r),q<<=1,j[c-2-f]=(j[c-1-f]/2|0)+b;for(j[0]=k[0],m[0]=Array(j[0]),n[0]=Array(j[0]),f=1;c>f;++f)j[f]>2*j[f-1]+k[f]&&(j[f]=2*j[f-1]+k[f]),m[f]=Array(j[f]),n[f]=Array(j[f]);for(e=0;b>e;++e)l[e]=c;for(g=0;ge;++e)p[e]=0;for(1===k[c-1]&&(--l[0],++p[c-1]),f=c-2;f>=0;--f){for(h=e=0,i=p[f+1],g=0;ga[e]?(m[f][g]=h,n[f][g]=b,i+=2):(m[f][g]=a[e],n[f][g]=e,++e);p[f]=0,1===k[f]&&d(f)}return l}function k(a){var b,c,d,e,f=new(o?Uint16Array:Array)(a.length),g=[],h=[],i=0;for(b=0,c=a.length;c>b;b++)g[a[b]]=(0|g[a[b]])+1;for(b=1,c=16;c>=b;b++)h[b]=i,i+=0|g[b],i<<=1;for(b=0,c=a.length;c>b;b++)for(i=h[a[b]],h[a[b]]+=1,d=f[b]=0,e=a[b];e>d;d++)f[b]=f[b]<<1|1&i,i>>>=1;return f}var l=void 0,m=!0,n=this,o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;b.prototype.a=function(a,b,d){var e,f=this.buffer,g=this.index,h=this.d,i=f[g];if(d&&b>1&&(a=b>8?(u[255&a]<<24|u[a>>>8&255]<<16|u[a>>>16&255]<<8|u[a>>>24&255])>>32-b:u[a]>>8-b),8>b+h)i=i<e;++e)i=i<<1|a>>b-e-1&1,8===++h&&(h=0,f[g++]=u[i],i=0,g===f.length&&(f=c(this)));f[g]=i,this.buffer=f,this.d=h,this.index=g},b.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0p;++p){for(var r=p,s=r,t=7,r=r>>>1;r;r>>>=1)s<<=1,s|=1&r,--t;q[p]=(s<>>0}var u=q;d.prototype.getParent=function(a){return 2*((a-2)/4|0)},d.prototype.push=function(a,b){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=b,f[this.length++]=a;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},d.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;for(b=f[0],a=f[1],this.length-=2,f[0]=f[this.length],f[1]=f[this.length+1],e=0;d=2*e+2,!(d>=this.length)&&(d+2f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.length}};var v,w=2,x=[];for(v=0;288>v;v++)switch(m){case 143>=v:x.push([v+48,8]);break;case 255>=v:x.push([v-144+400,9]);break;case 279>=v:x.push([v-256+0,7]);break;case 287>=v:x.push([v-280+192,8]);break;default:throw"invalid literal: "+v}e.prototype.h=function(){var a,c,d,e,f=this.input;switch(this.e){case 0:for(d=0,e=f.length;e>d;){c=o?f.subarray(d,d+65535):f.slice(d,d+65535),d+=c.length;var h=c,j=d===e,n=l,p=l,q=l,r=l,s=l,t=this.b,u=this.c;if(o){for(t=new Uint8Array(this.b.buffer);t.length<=u+h.length+5;)t=new Uint8Array(t.length<<1);t.set(this.b)}if(n=j?1:0,t[u++]=0|n,p=h.length,q=~p+65536&65535,t[u++]=255&p,t[u++]=p>>>8&255,t[u++]=255&q,t[u++]=q>>>8&255,o)t.set(h,u),u+=h.length,t=t.subarray(0,u);else{for(r=0,s=h.length;s>r;++r)t[u++]=h[r];t.length=u}this.c=u,this.b=t}break;case 1:var v=new b(o?new Uint8Array(this.b.buffer):this.b,this.c);v.a(1,1,m),v.a(1,2,m);var y,z,A,B=g(this,f);for(y=0,z=B.length;z>y;y++)if(A=B[y],b.prototype.a.apply(v,x[A]),A>256)v.a(B[++y],B[++y],m),v.a(B[++y],5),v.a(B[++y],B[++y],m);else if(256===A)break;this.b=v.finish(),this.c=this.b.length;break;case w:var C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R=new b(o?new Uint8Array(this.b.buffer):this.b,this.c),S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T=Array(19);for(C=w,R.a(1,1,m),R.a(C,2,m),D=g(this,f),H=i(this.j,15),I=k(H),J=i(this.i,7),K=k(J),E=286;E>257&&0===H[E-1];E--);for(F=30;F>1&&0===J[F-1];F--);var U,V,W,X,Y,Z,$=E,_=F,aa=new(o?Uint32Array:Array)($+_),ba=new(o?Uint32Array:Array)(316),ca=new(o?Uint8Array:Array)(19);for(U=V=0;$>U;U++)aa[V++]=H[U];for(U=0;_>U;U++)aa[V++]=J[U];if(!o)for(U=0,X=ca.length;X>U;++U)ca[U]=0;for(U=Y=0,X=aa.length;X>U;U+=V){for(V=1;X>U+V&&aa[U+V]===aa[U];++V);if(W=V,0===aa[U])if(3>W)for(;00;)Z=138>W?W:138,Z>W-3&&W>Z&&(Z=W-3),10>=Z?(ba[Y++]=17,ba[Y++]=Z-3,ca[17]++):(ba[Y++]=18,ba[Y++]=Z-11,ca[18]++),W-=Z;else if(ba[Y++]=aa[U],ca[aa[U]]++,W--,3>W)for(;00;)Z=6>W?W:6,Z>W-3&&W>Z&&(Z=W-3),ba[Y++]=16,ba[Y++]=Z-3,ca[16]++,W-=Z}for(a=o?ba.subarray(0,Y):ba.slice(0,Y),L=i(ca,7),P=0;19>P;P++)T[P]=L[S[P]];for(G=19;G>4&&0===T[G-1];G--);for(M=k(L),R.a(E-257,5,m),R.a(F-1,5,m),R.a(G-4,4,m),P=0;G>P;P++)R.a(T[P],3,m);for(P=0,Q=a.length;Q>P;P++)if(N=a[P],R.a(M[N],L[N],m),N>=16){switch(P++,N){case 16:O=2;break;case 17:O=3;break;case 18:O=7;break;default:throw"invalid code: "+N}R.a(a[P],O,m)}var da,ea,fa,ga,ha,ia,ja,ka,la=[I,H],ma=[K,J];for(ha=la[0],ia=la[1],ja=ma[0],ka=ma[1],da=0,ea=D.length;ea>da;++da)if(fa=D[da],R.a(ha[fa],ia[fa],m),fa>256)R.a(D[++da],D[++da],m),ga=D[++da],R.a(ja[ga],ka[ga],m),R.a(D[++da],D[++da],m);else if(256===fa)break;this.b=R.finish(),this.c=this.b.length;break;default:throw"invalid compression type"}return this.b};var y=function(){function a(a){switch(m){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:throw"invalid length: "+a}}var b,c,d=[];for(b=3;258>=b;b++)c=a(b),d[b]=c[2]<<24|c[1]<<16|c[0];return d}(),z=o?new Uint32Array(y):y;a("Zlib.RawDeflate",e),a("Zlib.RawDeflate.prototype.compress",e.prototype.h);var A,B,C,D,E={NONE:0,FIXED:1,DYNAMIC:w};if(Object.keys)A=Object.keys(E);else for(B in A=[],C=0,E)A[C++]=B;for(C=0,D=A.length;D>C;++C)B=A[C],a("Zlib.RawDeflate.CompressionType."+B,E[B])}).call(this)},{}],20:[function(){(function(){"use strict";function a(a,b){var c=a.split("."),d=g;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d=d[e]?d[e]:d[e]={}:d[e]=b}function b(a){var b,c,d,e,f,g,i,j,k,l,m=a.length,n=0,o=Number.POSITIVE_INFINITY;for(j=0;m>j;++j)a[j]>n&&(n=a[j]),a[j]=d;){for(j=0;m>j;++j)if(a[j]===d){for(g=0,i=e,k=0;d>k;++k)g=g<<1|1&i,i>>=1;for(l=d<<16|j,k=g;b>k;k+=f)c[k]=l;++e}++d,e<<=1,f<<=1}return[c,n,o]}function c(a,b){switch(this.g=[],this.h=32768,this.c=this.f=this.d=this.k=0,this.input=h?new Uint8Array(a):a,this.l=!1,this.i=j,this.q=!1,(b||!(b={}))&&(b.index&&(this.d=b.index),b.bufferSize&&(this.h=b.bufferSize),b.bufferType&&(this.i=b.bufferType),b.resize&&(this.q=b.resize)),this.i){case i:this.a=32768,this.b=new(h?Uint8Array:Array)(32768+this.h+258); -e&&a.push(e);var f=b+1,g=c.getFrameAt(f);return g&&a.push(g),a},a.OnionSkinRenderer.prototype.computeHash_=function(a){var b=this.getOffset(),c=this.getDisplaySize(),d=this.piskelController.getLayers();return[this.getZoom(),this.getGridWidth(),b.x,b.y,c.width,c.height,a.map(function(a){return a.getHash()}).join("-"),d.length].join("-")},a.OnionSkinRenderer.prototype.setDisplaySize=function(a,b){var c=this.getDisplaySize();(c.width!==a||c.height!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.OnionSkinRenderer.prototype.flush=function(){this.hash=""}}(),function(){var a=$.namespace("pskl.rendering.frame");a.TiledFrameRenderer=function(a,b){this.container=a,this.setZoom(b);var c=a.get(0),d=c.ownerDocument;this.displayContainer=d.createElement("div"),this.displayContainer.classList.add("tiled-frame-container"),a.get(0).appendChild(this.displayContainer),this.cachedFrameProcessor=new pskl.model.frame.CachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.frameToDataUrl_.bind(this))},a.TiledFrameRenderer.prototype.frameToDataUrl_=function(a){var b=new pskl.utils.FrameUtils.toImage(a,this.zoom);return b.toDataURL("image/png")},a.TiledFrameRenderer.prototype.render=function(a){var b=this.cachedFrameProcessor.get(a,this.zoom);this.displayContainer.style.backgroundImage="url("+b+")"},a.TiledFrameRenderer.prototype.show=function(){this.displayContainer&&(this.displayContainer.style.display="block")},a.TiledFrameRenderer.prototype.setZoom=function(a){this.zoom=a},a.TiledFrameRenderer.prototype.getZoom=function(){return this.zoom}}(),function(){var a=$.namespace("pskl.rendering.frame");a.CachedFrameRenderer=function(a,b,c){pskl.rendering.frame.FrameRenderer.call(this,a,b,c),this.serializedFrame=""},pskl.utils.inherit(pskl.rendering.frame.CachedFrameRenderer,pskl.rendering.frame.FrameRenderer),a.CachedFrameRenderer.prototype.setDisplaySize=function(a,b){(this.displayWidth!==a||this.displayHeight!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.CachedFrameRenderer.prototype.render=function(a){var b=this.getOffset(),c=this.getDisplaySize(),d=[this.getZoom(),this.getGridWidth(),b.x,b.y,c.width,c.height,a.getHash()].join("-");this.serializedFrame!=d&&(this.serializedFrame=d,this.superclass.render.call(this,a))}}(),function(){var a=$.namespace("pskl.rendering");a.CanvasRenderer=function(a,b){this.frame=a,this.zoom=b,this.transparentColor_="white"},a.CanvasRenderer.prototype.drawTransparentAs=function(a){this.transparentColor_=a},a.CanvasRenderer.prototype.render=function(){for(var a=this.createCanvas_(),b=a.getContext("2d"),c=0,d=this.frame.getWidth();d>c;c++)for(var e=0,f=this.frame.getHeight();f>e;e++){for(var g=this.frame.getPixel(c,e),h=1;g===this.frame.getPixel(c,e+h);)h++;this.renderLine_(g,c,e,h,b),e=e+h-1}var i=this.createCanvas_(this.zoom),j=i.getContext("2d");return pskl.utils.CanvasUtils.disableImageSmoothing(i),j.scale(this.zoom,this.zoom),j.drawImage(a,0,0),i},a.CanvasRenderer.prototype.renderPixel_=function(a,b,c,d){a==Constants.TRANSPARENT_COLOR&&(a=this.transparentColor_),d.fillStyle=a,d.fillRect(b,c,1,1)},a.CanvasRenderer.prototype.renderLine_=function(a,b,c,d,e){a==Constants.TRANSPARENT_COLOR&&(a=this.transparentColor_),e.fillStyle=a,e.fillRect(b,c,1,d)},a.CanvasRenderer.prototype.createCanvas_=function(a){a=a||1;var b=this.frame.getWidth()*a,c=this.frame.getHeight()*a;return pskl.utils.CanvasUtils.createCanvas(b,c)}}(),function(){var a=$.namespace("pskl.rendering");a.FramesheetRenderer=function(a){if(!(a.length>0))throw"FramesheetRenderer : Invalid argument : frames is empty";this.frames=a},a.FramesheetRenderer.prototype.renderAsCanvas=function(){for(var a=this.createCanvas_(),b=0;b=a&&this.currentFrameIndex>0&&this.setCurrentFrameIndex(this.currentFrameIndex-1)},a.PiskelController.prototype.duplicateCurrentFrame=function(){this.duplicateFrameAt(this.currentFrameIndex)},a.PiskelController.prototype.duplicateFrameAt=function(a){this.getLayers().forEach(function(b){b.duplicateFrameAt(a)}),this.setCurrentFrameIndex(a+1)},a.PiskelController.prototype.moveFrame=function(a,b){this.getLayers().forEach(function(c){c.moveFrame(a,b)})},a.PiskelController.prototype.getFrameCount=function(){var a=this.piskel.getLayerAt(0);return a.size()},a.PiskelController.prototype.setCurrentFrameIndex=function(a){this.hasFrameAt(a)?this.currentFrameIndex=a:window.console.error("Could not set current frame index to "+a)},a.PiskelController.prototype.selectNextFrame=function(){var a=this.currentFrameIndex+1;a=0&&this.setCurrentFrameIndex(a)},a.PiskelController.prototype.setCurrentLayerIndex=function(a){this.hasLayerAt(a)?this.currentLayerIndex=a:window.console.error("Could not set current layer index to "+a)},a.PiskelController.prototype.selectLayer=function(a){var b=this.getLayers().indexOf(a);-1!=b&&this.setCurrentLayerIndex(b)},a.PiskelController.prototype.renameLayerAt=function(a,b){var c=this.getLayerByIndex(a);c&&c.setName(b)},a.PiskelController.prototype.mergeDownLayerAt=function(a){var b=this.getLayerByIndex(a),c=this.getLayerByIndex(a-1);if(b&&c){var d=pskl.utils.LayerUtils.mergeLayers(b,c);this.removeLayerAt(a),this.piskel.addLayerAt(d,a),this.removeLayerAt(a-1),this.selectLayer(d)}},a.PiskelController.prototype.generateLayerName_=function(){for(var a="Layer "+this.layerIdCounter;this.hasLayerForName_(a);)this.layerIdCounter++,a="Layer "+this.layerIdCounter;return a},a.PiskelController.prototype.createLayer=function(a){if(a||(a=this.generateLayerName_()),this.hasLayerForName_(a))throw"Layer name should be unique";for(var b=new pskl.model.Layer(a),c=0;c0},a.PiskelController.prototype.moveLayerUp=function(){var a=this.getCurrentLayer();this.piskel.moveLayerUp(a),this.selectLayer(a)},a.PiskelController.prototype.moveLayerDown=function(){var a=this.getCurrentLayer();this.piskel.moveLayerDown(a),this.selectLayer(a)},a.PiskelController.prototype.removeCurrentLayer=function(){var a=this.getCurrentLayerIndex();this.removeLayerAt(a)},a.PiskelController.prototype.removeLayerAt=function(a){if(this.getLayers().length>1){var b=this.getLayerAt(a);b&&(this.piskel.removeLayer(b),this.setCurrentLayerIndex(0))}},a.PiskelController.prototype.serialize=function(a){return pskl.utils.Serializer.serializePiskel(this.piskel,a)}}(),function(){var a=$.namespace("pskl.controller.piskel");a.PublicPiskelController=function(a){this.piskelController=a,pskl.utils.wrap(this,this.piskelController)},a.PublicPiskelController.prototype.init=function(){this.resetWrap_("setCurrentFrameIndex"),this.resetWrap_("selectNextFrame"),this.resetWrap_("selectPreviousFrame"),this.resetWrap_("setCurrentLayerIndex"),this.resetWrap_("selectLayer"),this.saveWrap_("renameLayerAt",!1),this.saveWrap_("removeCurrentLayer",!0),this.saveWrap_("addFrame",!0),this.saveWrap_("addFrameAtCurrentIndex",!0),this.saveWrap_("addFrameAt",!0),this.saveWrap_("removeFrameAt",!0),this.saveWrap_("duplicateCurrentFrame",!0),this.saveWrap_("duplicateFrameAt",!0),this.saveWrap_("moveFrame",!0),this.saveWrap_("createLayer",!0),this.saveWrap_("mergeDownLayerAt",!0),this.saveWrap_("moveLayerUp",!0),this.saveWrap_("moveLayerDown",!0),this.saveWrap_("removeCurrentLayer",!0),pskl.app.shortcutService.addShortcut("up",this.selectPreviousFrame.bind(this)),pskl.app.shortcutService.addShortcut("down",this.selectNextFrame.bind(this)),pskl.app.shortcutService.addShortcut("n",this.addFrameAtCurrentIndex.bind(this)),pskl.app.shortcutService.addShortcut("shift+n",this.duplicateCurrentFrame.bind(this))},a.PublicPiskelController.prototype.setPiskel=function(a,b){this.piskelController.setPiskel(a,b),$.publish(Events.FRAME_SIZE_CHANGED),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})},a.PublicPiskelController.prototype.resetWrap_=function(a){this[a]=function(){this.piskelController[a].apply(this.piskelController,arguments),$.publish(Events.PISKEL_RESET)}},a.PublicPiskelController.prototype.saveWrap_=function(a,b){this[a]=b?function(){var b=this.getStateInfo_();this.piskelController[a].apply(this.piskelController,arguments),this.raiseSaveStateEvent_(this.piskelController[a],arguments,b),$.publish(Events.PISKEL_RESET)}:function(){var b=this.getStateInfo_();this.piskelController[a].apply(this.piskelController,arguments),this.raiseSaveStateEvent_(this.piskelController[a],arguments,b)}},a.PublicPiskelController.prototype.getStateInfo_=function(){var a={frameIndex:this.piskelController.currentFrameIndex,layerIndex:this.piskelController.currentLayerIndex};return a},a.PublicPiskelController.prototype.raiseSaveStateEvent_=function(a,b,c){$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{fn:a,args:b},state:c})},a.PublicPiskelController.prototype.setSavePath=function(a){this.piskelController.piskel.savePath=a},a.PublicPiskelController.prototype.getSavePath=function(){return this.piskelController.piskel.savePath},a.PublicPiskelController.prototype.replay=function(a,b){b.fn.apply(this.piskelController,b.args)}}(),function(){var a=$.namespace("pskl.controller");a.CursorCoordinatesController=function(a){this.piskelController=a,this.origin=null,this.coordinates={x:-1,y:-1}},a.CursorCoordinatesController.prototype.init=function(){this.coordinatesContainer=document.querySelector(".cursor-coordinates"),$.subscribe(Events.CURSOR_MOVED,this.onCursorMoved_.bind(this)),$.subscribe(Events.DRAG_START,this.onDragStart_.bind(this)),$.subscribe(Events.DRAG_END,this.onDragEnd_.bind(this)),$.subscribe(Events.FRAME_SIZE_CHANGED,this.redraw.bind(this)),this.redraw()},a.CursorCoordinatesController.prototype.redraw=function(){var a="";this.origin&&(a+=this.origin.x+":"+this.origin.y+" to ");var b=this.coordinates.x,c=this.coordinates.y,d=this.piskelController.getCurrentFrame();if(d.containsPixel(b,c)&&(a+=b+":"+c,this.origin)){var e=Math.abs(b-this.origin.x)+1,f=Math.abs(c-this.origin.y)+1;a+=" ("+e+"x"+f+")"}this.coordinatesContainer.innerHTML=this.getFrameSizeHTML_()+a},a.CursorCoordinatesController.prototype.getFrameSizeHTML_=function(){var a=this.piskelController.getWidth(),b=this.piskelController.getHeight();return"["+a+"x"+b+"] "},a.CursorCoordinatesController.prototype.onCursorMoved_=function(a,b,c){this.coordinates={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragStart_=function(a,b,c){this.origin={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragEnd_=function(a,b,c){this.origin=null,this.redraw()}}(),function(){var a=$.namespace("pskl.controller");a.DrawingController=function(b,c,d){this.piskelController=b,this.paletteController=c,this.dragHandler=new a.drawing.DragHandler(this),this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(b.getCurrentFrame()),this.container=d;var e={zoom:this.calculateZoom_(),supportGridRendering:!0,height:this.getContainerHeight_(),width:this.getContainerWidth_(),xOffset:0,yOffset:0};this.overlayRenderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,e,["canvas-overlay"]),this.renderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,e,["drawing-canvas"]),this.onionSkinRenderer=pskl.rendering.OnionSkinRenderer.createInContainer(this.container,e,b),this.layersRenderer=new pskl.rendering.layer.LayersRenderer(this.container,e,b),this.compositeRenderer=new pskl.rendering.CompositeRenderer,this.compositeRenderer.add(this.overlayRenderer).add(this.renderer).add(this.layersRenderer).add(this.onionSkinRenderer),this.isClicked=!1,this.previousMousemoveTime=0,this.currentToolBehavior=null,this.currentMouseButton_=Constants.LEFT_BUTTON},a.DrawingController.prototype.init=function(){this.initMouseBehavior(),$.subscribe(Events.TOOL_SELECTED,$.proxy(function(a,b){this.currentToolBehavior=b,this.overlayFrame.clear()},this)),$(window).resize($.proxy(this.startResizeTimer_,this)),$.subscribe(Events.USER_SETTINGS_CHANGED,$.proxy(this.onUserSettingsChange_,this)),$.subscribe(Events.FRAME_SIZE_CHANGED,$.proxy(this.onFrameSizeChange_,this)),pskl.app.shortcutService.addShortcut("0",this.resetZoom_.bind(this)),pskl.app.shortcutService.addShortcut("+",this.increaseZoom_.bind(this,1)),pskl.app.shortcutService.addShortcut("-",this.decreaseZoom_.bind(this,1)),window.setTimeout(function(){this.afterWindowResize_(),this.resetZoom_()}.bind(this),100)},a.DrawingController.prototype.initMouseBehavior=function(){var a=$("body");this.container.mousedown($.proxy(this.onMousedown_,this)),pskl.utils.UserAgent.isChrome||pskl.utils.UserAgent.isIE11?this.container.on("mousewheel",$.proxy(this.onMousewheel_,this)):this.container.on("wheel",$.proxy(this.onMousewheel_,this)),window.addEventListener("mouseup",this.onMouseup_.bind(this)),window.addEventListener("mousemove",this.onMousemove_.bind(this)),window.addEventListener("keyup",this.onKeyup_.bind(this)),a.contextmenu(this.onCanvasContextMenu_)},a.DrawingController.prototype.startResizeTimer_=function(){this.resizeTimer&&window.clearInterval(this.resizeTimer),this.resizeTimer=window.setTimeout($.proxy(this.afterWindowResize_,this),200)},a.DrawingController.prototype.afterWindowResize_=function(){var a=this.compositeRenderer.getDisplaySize().width;this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getContainerHeight_()),this.centerColumnWrapperHorizontally_();var b=this.compositeRenderer.getDisplaySize().width/a,c=b*this.compositeRenderer.getZoom();this.compositeRenderer.setZoom(c),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.SHOW_GRID?console.warn("DrawingController:onUserSettingsChange_ not implemented !"):(b==pskl.UserSettings.ONION_SKIN||b==pskl.UserSettings.LAYER_PREVIEW)&&(this.onionSkinRenderer.clear(),this.onionSkinRenderer.flush(),this.layersRenderer.clear(),this.layersRenderer.flush(),this.render())},a.DrawingController.prototype.onFrameSizeChange_=function(){this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getContainerHeight_()),this.centerColumnWrapperHorizontally_(),this.compositeRenderer.setZoom(this.calculateZoom_()),this.compositeRenderer.setOffset(0,0),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.onMousedown_=function(a){$.publish(Events.MOUSE_EVENT,[a,this]);var b=this.piskelController.getCurrentFrame(),c=this.getSpriteCoordinates(a.clientX,a.clientY);this.isClicked=!0,this.setCurrentButton(a),a.button===Constants.MIDDLE_BUTTON?this.dragHandler.startDrag(a.clientX,a.clientY):(this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame),$.publish(Events.TOOL_PRESSED),this.currentToolBehavior.applyToolAt(c.x,c.y,this.getCurrentColor_(),b,this.overlayFrame,a))},a.DrawingController.prototype.onMousemove_=function(a){this._clientX=a.clientX,this._clientY=a.clientY;var b=(new Date).getTime();b-this.previousMousemoveTime>Constants.MOUSEMOVE_THROTTLING&&(this.moveTool_(this._clientX,this._clientY,a),this.previousMousemoveTime=b)},a.DrawingController.prototype.onKeyup_=function(a){this.moveTool_(this._clientX,this._clientY,a)},a.DrawingController.prototype.moveTool_=function(a,b,c){var d=this.getSpriteCoordinates(a,b),e=this.piskelController.getCurrentFrame();this.isClicked?this.currentMouseButton_==Constants.MIDDLE_BUTTON?this.dragHandler.updateDrag(a,b):($.publish(Events.MOUSE_EVENT,[c,this]),this.currentToolBehavior.moveToolAt(0|d.x,0|d.y,this.getCurrentColor_(),e,this.overlayFrame,c)):this.currentToolBehavior.moveUnactiveToolAt(d.x,d.y,this.getCurrentColor_(),e,this.overlayFrame,c),$.publish(Events.CURSOR_MOVED,[d.x,d.y])},a.DrawingController.prototype.onMousewheel_=function(a){var b,c=a.originalEvent;pskl.utils.UserAgent.isChrome?b=c.wheelDeltaY:pskl.utils.UserAgent.isIE11?b=c.wheelDelta:pskl.utils.UserAgent.isFirefox&&(b=-40*c.deltaY);var d=Math.abs(b/120);b>0?this.increaseZoom_(d):0>b&&this.decreaseZoom_(d)},a.DrawingController.prototype.increaseZoom_=function(a){var b=(a||1)*this.getZoomStep_();this.setZoom_(this.renderer.getZoom()+b)},a.DrawingController.prototype.decreaseZoom_=function(a){var b=(a||1)*this.getZoomStep_();this.setZoom_(this.renderer.getZoom()-b)},a.DrawingController.prototype.onMouseup_=function(a){var b=this.piskelController.getCurrentFrame(),c=this.getSpriteCoordinates(a.clientX,a.clientY);this.isClicked&&($.publish(Events.MOUSE_EVENT,[a,this]),this.isClicked=!1,this.setCurrentButton(a),a.button===Constants.MIDDLE_BUTTON?this.dragHandler.isDragging()?this.dragHandler.stopDrag():b.containsPixel(c.x,c.y)&&$.publish(Events.SELECT_PRIMARY_COLOR,[b.getPixel(c.x,c.y)]):(this.currentToolBehavior.releaseToolAt(c.x,c.y,this.getCurrentColor_(),this.piskelController.getCurrentFrame(),this.overlayFrame,a),$.publish(Events.TOOL_RELEASED)))},a.DrawingController.prototype.getSpriteCoordinates=function(a,b){return this.renderer.getCoordinates(a,b)},a.DrawingController.prototype.getScreenCoordinates=function(a,b){return this.renderer.reverseCoordinates(a,b)},a.DrawingController.prototype.setCurrentButton=function(a){this.currentMouseButton_=a.button},a.DrawingController.prototype.getCurrentColor_=function(){return this.currentMouseButton_==Constants.RIGHT_BUTTON?this.paletteController.getSecondaryColor():this.currentMouseButton_==Constants.LEFT_BUTTON?this.paletteController.getPrimaryColor():Constants.DEFAULT_PEN_COLOR},a.DrawingController.prototype.onCanvasContextMenu_=function(a){return $(a.target).closest("#drawing-canvas-container").length?(a.preventDefault(),a.stopPropagation(),a.cancelBubble=!0,!1):void 0},a.DrawingController.prototype.render=function(){var a=this.piskelController.getCurrentFrame();a.isSameSize(this.overlayFrame)||(this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(a)),pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN)&&this.onionSkinRenderer.render(),pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW)&&this.layersRenderer.render(),this.renderer.render(a),this.overlayRenderer.render(this.overlayFrame)},a.DrawingController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame().getHeight(),b=this.piskelController.getCurrentFrame().getWidth();return Math.min(this.getAvailableWidth_()/b,this.getAvailableHeight_()/a)},a.DrawingController.prototype.getAvailableHeight_=function(){return $("#main-wrapper").height()},a.DrawingController.prototype.getAvailableWidth_=function(){var a=$(".left-column").outerWidth(!0),b=$(".right-column").outerWidth(!0),c=$("#tool-section").outerWidth(!0),d=$("#application-action-section").outerWidth(!0),e=a+b+c+d,f=$("#main-wrapper").width()-e,g=10;return f-g},a.DrawingController.prototype.getContainerHeight_=function(){return this.getAvailableHeight_()},a.DrawingController.prototype.getContainerWidth_=function(){return this.getAvailableWidth_()},a.DrawingController.prototype.centerColumnWrapperHorizontally_=function(){var a=this.getContainerHeight_(),b=Math.floor(($("#main-wrapper").height()-a)/2);$("#column-wrapper").css({top:b+"px"})},a.DrawingController.prototype.getRenderer=function(){return this.compositeRenderer},a.DrawingController.prototype.getOffset=function(){return this.compositeRenderer.getOffset()},a.DrawingController.prototype.setOffset=function(a,b){this.compositeRenderer.setOffset(a,b),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.resetZoom_=function(){this.setZoom_(this.calculateZoom_())},a.DrawingController.prototype.getZoomStep_=function(){return this.calculateZoom_()/10},a.DrawingController.prototype.setZoom_=function(a){this.compositeRenderer.setZoom(a),$.publish(Events.ZOOM_CHANGED)}}(),function(){var a=$.namespace("pskl.controller.drawing"),b=2;a.DragHandler=function(a){this.drawingController=a,this.isDragging_=!1,this.updateOrigin_(-1,-1)},a.DragHandler.prototype.startDrag=function(a,b){var c=this.drawingController.getSpriteCoordinates(a,b);this.updateOrigin_(c.x,c.y)},a.DragHandler.prototype.updateDrag=function(a,b){var c=this.drawingController.getOffset(),d=this.calculateOffset_(a,b);if(c.y!==d.y||c.x!==d.x){this.isDragging_=!0,this.drawingController.setOffset(d.x,d.y);var e=this.drawingController.getSpriteCoordinates(a,b);this.updateOrigin_(e.x,e.y)}},a.DragHandler.prototype.stopDrag=function(){this.isDragging_=!1,this.origin=null},a.DragHandler.prototype.isDragging=function(){return this.isDragging_},a.DragHandler.prototype.calculateOffset_=function(a,c){var d=this.drawingController.getSpriteCoordinates(a,c),e=this.drawingController.getOffset(),f={x:e.x-b*(d.x-this.origin.x),y:e.y-b*(d.y-this.origin.y)};return f},a.DragHandler.prototype.updateOrigin_=function(a,b){this.origin=this.origin||{},this.origin.x=a,this.origin.y=b}}(),function(){var a=$.namespace("pskl.controller"),b={SELECT:"select",CLONE:"clone",DELETE:"delete",NEW_FRAME:"newframe"};a.FramesListController=function(a,b){this.piskelController=a,this.container=b,this.refreshZoom_(),this.redrawFlag=!0,this.cachedFrameProcessor=new pskl.model.frame.CachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.frameToPreviewCanvas_.bind(this)),this.cachedFrameProcessor.setOutputCloner(this.clonePreviewCanvas_.bind(this))},a.FramesListController.prototype.init=function(){$.subscribe(Events.TOOL_RELEASED,this.flagForRedraw_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.flagForRedraw_.bind(this)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.flagForRedraw_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.refreshZoom_.bind(this)),$("#preview-list-scroller").scroll(this.updateScrollerOverflows.bind(this)),this.container.get(0).addEventListener("click",this.onContainerClick_.bind(this)),this.updateScrollerOverflows()},a.FramesListController.prototype.flagForRedraw_=function(){this.redrawFlag=!0},a.FramesListController.prototype.refreshZoom_=function(){this.zoom=this.calculateZoom_()},a.FramesListController.prototype.render=function(){this.redrawFlag&&(this.createPreviews_(),this.redrawFlag=!1)},a.FramesListController.prototype.updateScrollerOverflows=function(){var a=$("#preview-list-scroller"),b=a.height(),c=a.scrollTop(),d=$("#preview-list").height(),e=$(".top-overflow").height(),f=!1,g=!1;if(d>b){c>e&&(f=!0);var h=d-c-b;h>e&&(g=!0)}var i=$("#preview-list-wrapper");i.toggleClass("top-overflow-visible",f),i.toggleClass("bottom-overflow-visible",g)},a.FramesListController.prototype.onContainerClick_=function(a){var c=pskl.utils.Dom.getParentWithData(a.target,"tileAction");if(c){var d=c.dataset.tileAction,e=parseInt(c.dataset.tileNumber,10);d===b.CLONE?(this.piskelController.duplicateFrameAt(e),this.updateScrollerOverflows()):d===b.DELETE?(this.piskelController.removeFrameAt(e),this.updateScrollerOverflows()):d===b.SELECT?this.piskelController.setCurrentFrameIndex(e):d===b.NEW_FRAME&&(this.piskelController.addFrame(),this.updateScrollerOverflows())}},a.FramesListController.prototype.createPreviews_=function(){this.container.html(""),$(".tooltip").remove();for(var a=this.piskelController.getFrameCount(),c=0;a>c;c++)this.container.append(this.createPreviewTile_(c));var d=document.createElement("div");d.id="add-frame-action",d.className="add-frame-action",d.setAttribute("data-tile-action",b.NEW_FRAME),d.innerHTML='

Add new frame

',this.container.append(d);var e=a>1;e&&this.initDragndropBehavior_(),this.updateScrollerOverflows()},a.FramesListController.prototype.initDragndropBehavior_=function(){$("#preview-list").sortable({placeholder:"preview-tile-drop-proxy",update:$.proxy(this.onUpdate_,this),items:".preview-tile"}),$("#preview-list").disableSelection()},a.FramesListController.prototype.onUpdate_=function(a,b){var c=parseInt(b.item.data("tile-number"),10),d=$(".preview-tile").index(b.item);this.piskelController.moveFrame(c,d),this.piskelController.setCurrentFrameIndex(d)},a.FramesListController.prototype.createPreviewTile_=function(a){var c=this.piskelController.getCurrentLayer().getFrameAt(a),d=document.createElement("li");d.setAttribute("data-tile-number",a),d.setAttribute("data-tile-action",b.SELECT),d.classList.add("preview-tile"),this.piskelController.getCurrentFrame()==c&&d.classList.add("selected");var e=document.createElement("div");e.classList.add("canvas-container",pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND));var f=this.zoom*this.piskelController.getCurrentFrame().getHeight(),g=(Constants.PREVIEW_FILM_SIZE-f)/2;e.style.marginTop=g+"px";var h=this.zoom*this.piskelController.getCurrentFrame().getWidth(),i=(Constants.PREVIEW_FILM_SIZE-h)/2;e.style.marginLeft=i+"px",e.style.marginRight=i+"px";var j=document.createElement("div");j.className="canvas-background",e.appendChild(j);var k=document.createElement("button");if(k.setAttribute("rel","tooltip"),k.setAttribute("data-placement","right"),k.setAttribute("data-tile-number",a),k.setAttribute("data-tile-action",b.CLONE),k.setAttribute("title","Duplicate this frame"),k.className="tile-overlay duplicate-frame-action",d.appendChild(k),e.appendChild(this.getCanvasForFrame(c)),d.appendChild(e),a>0||this.piskelController.getFrameCount()>1){var l=document.createElement("button");l.setAttribute("rel","tooltip"),l.setAttribute("data-placement","right"),l.setAttribute("title","Delete this frame"),l.setAttribute("data-tile-number",a),l.setAttribute("data-tile-action",b.DELETE),l.className="tile-overlay delete-frame-action",d.appendChild(l);var m=document.createElement("div");m.className="tile-overlay dnd-action",d.appendChild(m)}var n=document.createElement("div");return n.className="tile-overlay tile-count",n.innerHTML=a+1,d.appendChild(n),d},a.FramesListController.prototype.getCanvasForFrame=function(a){var b=this.cachedFrameProcessor.get(a,this.zoom);return b},a.FramesListController.prototype.frameToPreviewCanvas_=function(a){var b=new pskl.rendering.CanvasRenderer(a,this.zoom);b.drawTransparentAs(Constants.TRANSPARENT_COLOR);var c=b.render();return c.classList.add("tile-view","canvas"),c},a.FramesListController.prototype.clonePreviewCanvas_=function(a){var b=pskl.utils.CanvasUtils.clone(a);return b.classList.add("tile-view","canvas"),b},a.FramesListController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame(),b=Math.max(a.getHeight(),a.getWidth());return Constants.PREVIEW_FILM_SIZE/b}}(),function(){var a=$.namespace("pskl.controller");a.LayersListController=function(a){this.piskelController=a},a.LayersListController.prototype.init=function(){this.layerItemTemplate_=pskl.utils.Template.get("layer-item-template"),this.rootEl=document.querySelector(".layers-list-container"),this.layersListEl=document.querySelector(".layers-list"),this.toggleLayerPreviewEl=document.querySelector(".layers-toggle-preview"),this.rootEl.addEventListener("click",this.onClick_.bind(this)),this.toggleLayerPreviewEl.addEventListener("click",this.toggleLayerPreview_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.renderLayerList_.bind(this)),pskl.app.shortcutService.addShortcut("alt+L",this.toggleLayerPreview_.bind(this)),this.renderLayerList_(),this.updateToggleLayerPreview_(),$.subscribe(Events.USER_SETTINGS_CHANGED,$.proxy(this.onUserSettingsChange_,this))},a.LayersListController.prototype.renderLayerList_=function(){this.layersListEl.innerHTML="";var a=this.piskelController.getLayers();a.forEach(this.addLayerItem.bind(this)),this.updateButtonStatus_()},a.LayersListController.prototype.updateButtonStatus_=function(){var a=this.piskelController.getLayers(),b=(this.piskelController.getCurrentLayer(),this.piskelController.getCurrentLayerIndex()),c=0===b,d=1===a.length,e=b===a.length-1;this.toggleButtonDisabledState_("up",e),this.toggleButtonDisabledState_("down",c),this.toggleButtonDisabledState_("merge",c),this.toggleButtonDisabledState_("delete",d)},a.LayersListController.prototype.toggleButtonDisabledState_=function(a,b){var c=document.querySelector('.layers-button[data-action="'+a+'"]');b?c.setAttribute("disabled","disabled"):c.removeAttribute("disabled")},a.LayersListController.prototype.updateToggleLayerPreview_=function(){var a="layers-toggle-preview-enabled";pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW)?this.toggleLayerPreviewEl.classList.add(a):this.toggleLayerPreviewEl.classList.remove(a)},a.LayersListController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.LAYER_PREVIEW&&this.updateToggleLayerPreview_()},a.LayersListController.prototype.addLayerItem=function(a,b){var c=this.piskelController.getCurrentLayer()===a,d=pskl.utils.Template.replace(this.layerItemTemplate_,{layername:a.getName(),layerindex:b,"isselected:current-layer-item":c}),e=pskl.utils.Template.createFromHTML(d);this.layersListEl.insertBefore(e,this.layersListEl.firstChild); +break;case j:this.a=0,this.b=new(h?Uint8Array:Array)(this.h),this.e=this.v,this.m=this.s,this.j=this.t;break;default:throw Error("invalid inflate mode")}}function d(a,b){for(var c,d=a.f,e=a.c,f=a.input,g=a.d,h=f.length;b>e;){if(g>=h)throw Error("input buffer is broken");d|=f[g++]<>>b,a.c=e-b,a.d=g,c}function e(a,b){for(var c,d,e=a.f,f=a.c,g=a.input,h=a.d,i=g.length,j=b[0],k=b[1];k>f&&!(h>=i);)e|=g[h++]<>>16,a.f=e>>d,a.c=f-d,a.d=h,65535&c}function f(a){function c(a,b,c){var f,g,h,i=this.p;for(h=0;a>h;)switch(f=e(this,b)){case 16:for(g=3+d(this,2);g--;)c[h++]=i;break;case 17:for(g=3+d(this,3);g--;)c[h++]=0;i=0;break;case 18:for(g=11+d(this,7);g--;)c[h++]=0;i=0;break;default:i=c[h++]=f}return this.p=i,c}var f,g,i,j,k=d(a,5)+257,l=d(a,5)+1,m=d(a,4)+4,o=new(h?Uint8Array:Array)(n.length);for(j=0;m>j;++j)o[n[j]]=d(a,3);if(!h)for(j=m,m=o.length;m>j;++j)o[n[j]]=0;f=b(o),g=new(h?Uint8Array:Array)(k),i=new(h?Uint8Array:Array)(l),a.p=0,a.j(b(c.call(a,k,f,g)),b(c.call(a,l,f,i)))}var g=this,h="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView,i=0,j=1;c.prototype.u=function(){for(;!this.l;){var a=d(this,3);switch(1&a&&(this.l=!0),a>>>=1){case 0:var b=this.input,c=this.d,e=this.b,g=this.a,k=b.length,l=void 0,m=void 0,n=e.length,o=void 0;if(this.c=this.f=0,c+1>=k)throw Error("invalid uncompressed block header: LEN");if(l=b[c++]|b[c++]<<8,c+1>=k)throw Error("invalid uncompressed block header: NLEN");if(m=b[c++]|b[c++]<<8,l===~m)throw Error("invalid uncompressed block header: length verify");if(c+l>b.length)throw Error("input buffer is broken");switch(this.i){case i:for(;g+l>e.length;){if(o=n-g,l-=o,h)e.set(b.subarray(c,c+o),g),g+=o,c+=o;else for(;o--;)e[g++]=b[c++];this.a=g,e=this.e(),g=this.a}break;case j:for(;g+l>e.length;)e=this.e({o:2});break;default:throw Error("invalid inflate mode")}if(h)e.set(b.subarray(c,c+l),g),g+=l,c+=l;else for(;l--;)e[g++]=b[c++];this.d=c,this.a=g,this.b=e;break;case 1:this.j(z,B);break;case 2:f(this);break;default:throw Error("unknown BTYPE: "+a)}}return this.m()};var k,l,m=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],n=h?new Uint16Array(m):m,o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],p=h?new Uint16Array(o):o,q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],r=h?new Uint8Array(q):q,s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],t=h?new Uint16Array(s):s,u=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],v=h?new Uint8Array(u):u,w=new(h?Uint8Array:Array)(288);for(k=0,l=w.length;l>k;++k)w[k]=143>=k?8:255>=k?9:279>=k?7:8;var x,y,z=b(w),A=new(h?Uint8Array:Array)(30);for(x=0,y=A.length;y>x;++x)A[x]=5;var B=b(A);c.prototype.j=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length-258;256!==(g=e(this,a));)if(256>g)f>=k&&(this.a=f,c=this.e(),f=this.a),c[f++]=g;else for(h=g-257,j=p[h],0=k&&(this.a=f,c=this.e(),f=this.a);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.t=function(a,b){var c=this.b,f=this.a;this.n=a;for(var g,h,i,j,k=c.length;256!==(g=e(this,a));)if(256>g)f>=k&&(c=this.e(),k=c.length),c[f++]=g;else for(h=g-257,j=p[h],0k&&(c=this.e(),k=c.length);j--;)c[f]=c[f++-i];for(;8<=this.c;)this.c-=8,this.d--;this.a=f},c.prototype.e=function(){var a,b,c=new(h?Uint8Array:Array)(this.a-32768),d=this.a-32768,e=this.b;if(h)c.set(e.subarray(32768,c.length));else for(a=0,b=c.length;b>a;++a)c[a]=e[a+32768];if(this.g.push(c),this.k+=c.length,h)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];return this.a=32768,e},c.prototype.v=function(a){var b,c,d,e,f=this.input.length/this.d+1|0,g=this.input,i=this.b;return a&&("number"==typeof a.o&&(f=a.o),"number"==typeof a.r&&(f+=a.r)),2>f?(c=(g.length-this.d)/this.n[2],e=258*(c/2)|0,d=eb;++b)for(a=i[b],d=0,e=a.length;e>d;++d)j[f++]=a[d];for(b=32768,c=this.a;c>b;++b)j[f++]=g[b];return this.g=[],this.buffer=j},c.prototype.s=function(){var a,b=this.a;return h?this.q?(a=new Uint8Array(b),a.set(this.b.subarray(0,b))):a=this.b.subarray(0,b):(this.b.length>b&&(this.b.length=b),a=this.b),this.buffer=a},a("Zlib.RawInflate",c),a("Zlib.RawInflate.prototype.decompress",c.prototype.u);var C,D,E,F,G={ADAPTIVE:j,BLOCK:i};if(Object.keys)C=Object.keys(G);else for(D in C=[],E=0,G)C[E++]=D;for(E=0,F=C.length;F>E;++E)D=C[E],a("Zlib.RawInflate.BufferType."+D,G[D])}).call(this)},{}]},{},[7])(7)}),function(a,b,c){function d(a,b,c){for(var d=[],e=0;e')}return"
"+d.join("")+"
"}function e(){for(var a=0;a1&&(delete a.localStorage[W],b.each(e,function(a,b){t(b)}))}catch(f){}try{na=a.localStorage[W].split(";")}catch(f){}}Ka.bind("click.spectrum touchstart.spectrum",function(a){ta||B(),a.stopPropagation(),b(a.target).is("input")||a.preventDefault()}),(sa.is(":disabled")||T.disabled===!0)&&S(),ua.click(j),Ca.change(A),Ca.bind("paste",function(){setTimeout(A,1)}),Ca.keydown(function(a){13==a.keyCode&&A()}),Fa.text(T.cancelText),Fa.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),F("cancel")}),Ga.text(T.chooseText),Ga.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),J()&&(N(!0),F())}),l(Aa,function(a,b,c){ka=a/ea,c.shiftKey&&(ka=Math.round(10*ka)/10),K()}),l(xa,function(a,b){ha=parseFloat(b/ca),K()},y,z),l(va,function(a,b,c){if(c.shiftKey){if(!qa){var d=ia*_,e=aa-ja*aa,f=Math.abs(a-d)>Math.abs(b-e);qa=f?"x":"y"}}else qa=null;var g=!qa||"x"===qa,h=!qa||"y"===qa;g&&(ia=parseFloat(a/_)),h&&(ja=parseFloat((aa-b)/aa)),K()},y,z),Ma?(H(Ma),L(),Pa=Oa||u(Ma).format,t(Ma)):L(),U&&C();var g=p?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Da.delegate(".sp-thumb-el",g,c),Ea.delegate(".sp-thumb-el:nth-child(1)",g,{ignore:!0},c)}function t(c){if(V){var d=u(c).toRgbString();if(-1===b.inArray(d,na))for(na.push(d);na.length>oa;)na.shift();if(W&&a.localStorage)try{a.localStorage[W]=na.join(";")}catch(e){}}}function v(){var a,b=[],c=na,d={};if(T.showPalette){for(var e=0;e=aa||0>=_||0>=ca)&&O(),ua.addClass(pa),qa=null}function z(){ua.removeClass(pa)}function A(){var a=u(Ca.val());a.ok?H(a):Ca.addClass("sp-validation-error")}function B(){$?F():C()}function C(){var c=b.Event("beforeShow.spectrum");return $?void O():(Na=I(),sa.trigger(c,[Na]),void(Y.beforeShow(Na)===!1||c.isDefaultPrevented()||(H(Na),e(),$=!0,b(ra).bind("mousedown.spectrum",D),U||b(ra).bind("mouseup.spectrum",E),b(a).bind("resize.spectrum",Z),Ja.addClass("sp-active"),ua.removeClass("sp-hidden"),T.showPalette&&w(),O(),L(),x(),Y.show(Na),sa.trigger("show.spectrum",[Na]))))}function D(a){var c=b(a.target),d=c.parents(),e=!d.is(ua)&&!c.is(ua);e&&F(a)}function E(a){var b=!u.equals(I(),Na);b&&(Qa&&"cancel"!==a?N(!0):G())}function F(c){c&&"click"==c.type&&2==c.button||$&&!U&&($=!1,b(ra).unbind("mousedown.spectrum",D),b(ra).unbind("mouseup.spectrum",E),b(a).unbind("resize.spectrum",Z),Ja.removeClass("sp-active"),ua.addClass("sp-hidden"),E(c),t(I()),Y.hide(I()),sa.trigger("hide.spectrum",[I()]))}function G(){H(Na,!0)}function H(a,b){if(!u.equals(a,I())){var c=u(a),d=c.toHsv();ha=d.h%360/360,ia=d.s,ja=d.v,ka=d.a,L(),c.ok&&!b&&(Pa=Oa||c.format)}}function I(a){return a=a||{},u.fromRatio({h:ha,s:ia,v:ja,a:Math.round(100*ka)/100},{format:a.format||Pa})}function J(){return!Ca.hasClass("sp-validation-error")}function K(){L(),Y.move(I()),sa.trigger("move.spectrum",[I()])}function L(){Ca.removeClass("sp-validation-error"),M();var a=u.fromRatio({h:ha,s:1,v:1});va.css("background-color",a.toHexString());var b=Pa;1>ka&&("hex"===b||"hex3"===b||"hex6"===b||"name"===b)&&(b="rgb");var c=I({format:b}),d=c.toHexString(),e=c.toRgbString();if(q||1===c.alpha?La.css("background-color",e):(La.css("background-color","transparent"),La.css("filter",c.toFilter())),T.showAlpha){var f=c.toRgb();f.a=0;var g=u(f).toRgbString(),h="linear-gradient(left, "+g+", "+d+")";p?za.css("filter",u(g).toFilter({gradientType:1},d)):(za.css("background","-webkit-"+h),za.css("background","-moz-"+h),za.css("background","-ms-"+h),za.css("background",h))}T.showInput&&Ca.val(c.toString(b)),T.showPalette&&w(),x()}function M(){var a=ia,b=ja,c=a*_,d=aa-b*aa;c=Math.max(-ba/2,Math.min(_-ba/2,c-ba/2)),d=Math.max(-ba/2,Math.min(aa-ba/2,d-ba/2)),wa.css({top:d,left:c});var e=ka*ea;Ba.css({left:e-fa/2});var f=ha*ca;ya.css({top:f-ga/2})}function N(a){var b=I();Ha&&sa.val(b.toString(Pa));var c=!u.equals(b,Na);Na=b,a&&c&&(Y.change(b),sa.trigger("change",[b]))}function O(){_=va.width(),aa=va.height(),ba=wa.height()+4,da=xa.width(),ca=xa.height(),ga=ya.height()+4,ea=Aa.width(),fa=Ba.width(),U||(ua.css("position","absolute"),ua.offset(h(ua,Ka))),M()}function P(){sa.show(),Ka.unbind("click.spectrum touchstart.spectrum"),ua.remove(),Ja.remove(),o[Ra.id]=null}function Q(a,d){return a===c?b.extend({},T):d===c?T[a]:(T[a]=d,void k())}function R(){ta=!1,sa.attr("disabled",!1),Ka.removeClass("sp-disabled")}function S(){F(),ta=!0,sa.attr("disabled",!0),Ka.addClass("sp-disabled")}var T=f(i,g),U=T.flat,V=T.showSelectionPalette,W=T.localStorageKey,X=T.theme,Y=T.callbacks,Z=m(O,10),$=!1,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=1,la=T.palette.slice(0),ma=b.isArray(la[0])?la:[la],na=T.selectionPalette.slice(0),oa=T.maxSelectionSize,pa="sp-dragging",qa=null,ra=g.ownerDocument,sa=(ra.body,b(g)),ta=!1,ua=b(s,ra).addClass(X),va=ua.find(".sp-color"),wa=ua.find(".sp-dragger"),xa=ua.find(".sp-hue"),ya=ua.find(".sp-slider"),za=ua.find(".sp-alpha-inner"),Aa=ua.find(".sp-alpha"),Ba=ua.find(".sp-alpha-handle"),Ca=ua.find(".sp-input"),Da=ua.find(".sp-palette"),Ea=ua.find(".sp-initial"),Fa=ua.find(".sp-cancel"),Ga=ua.find(".sp-choose"),Ha=sa.is("input"),Ia=Ha&&!U,Ja=Ia?b(r).addClass(X).addClass(T.className):b([]),Ka=Ia?Ja:sa,La=Ja.find(".sp-preview-inner"),Ma=T.color||Ha&&sa.val(),Na=!1,Oa=T.preferredFormat,Pa=Oa,Qa=!T.showButtons||T.clickoutFiresChange;n();var Ra={show:C,hide:F,toggle:B,reflow:O,option:Q,enable:R,disable:S,set:function(a){H(a),N()},get:I,destroy:P,container:ua};return Ra.id=o.push(Ra)-1,Ra}function h(a,c){var d=0,e=a.outerWidth(),f=a.outerHeight(),g=c.outerHeight(),h=a[0].ownerDocument,i=h.documentElement,j=i.clientWidth+b(h).scrollLeft(),k=i.clientHeight+b(h).scrollTop(),l=c.offset();return l.top+=g,Math.min(l.left,l.left+e>j&&j>e)?(l.left-=Math.abs(l.left+e-j),a.attr("data-x-position","right")):(l.left-=0,a.attr("data-x-position","left")),Math.min(l.top,l.top+f>k&&k>f)?(l.top-=Math.abs(f+g-d),a.attr("data-y-position","top")):(l.top-=d,a.attr("data-y-position","bottom")),l}function i(){}function j(a){a.stopPropagation()}function k(a,b){var c=Array.prototype.slice,d=c.call(arguments,2);return function(){return a.apply(b,d.concat(c.call(arguments)))}}function l(c,d,e,f){function g(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.returnValue=!1}function h(a){if(l){if(p&&document.documentMode<9&&!a.button)return j();var b=a.originalEvent.touches,e=b?b[0].pageX:a.pageX,f=b?b[0].pageY:a.pageY,h=Math.max(0,Math.min(e-m.left,o)),i=Math.max(0,Math.min(f-m.top,n));q&&g(a),d.apply(c,[h,i,a])}}function i(a){{var d=a.which?3==a.which:2==a.button;a.originalEvent.touches}d||l||e.apply(c,arguments)!==!1&&(l=!0,n=b(c).height(),o=b(c).width(),m=b(c).offset(),b(k).bind(r),b(k.body).addClass("sp-dragging"),q||h(a),g(a))}function j(){l&&(b(k).unbind(r),b(k.body).removeClass("sp-dragging"),f.apply(c,arguments)),l=!1}d=d||function(){},e=e||function(){},f=f||function(){};var k=c.ownerDocument||document,l=!1,m={},n=0,o=0,q="ontouchstart"in a,r={};r.selectstart=g,r.dragstart=g,r["touchmove mousemove"]=h,r["touchend mouseup"]=j,b(c).bind("touchstart mousedown",i)}function m(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d),(c||!d)&&(d=setTimeout(g,b))}}var n={beforeShow:i,move:i,change:i,show:i,hide:i,color:!1,flat:!1,showInput:!1,showButtons:!0,clickoutFiresChange:!1,showInitial:!1,showPalette:!1,showPaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",preferredFormat:!1,className:"",showAlpha:!1,theme:"sp-light",palette:["fff","000"],selectionPalette:[],disabled:!1},o=[],p=!!/msie/i.exec(a.navigator.userAgent),q=function(){function a(a,b){return!!~(""+a).indexOf(b)}var b=document.createElement("div"),c=b.style;return c.cssText="background-color:rgba(0,0,0,.5)",a(c.backgroundColor,"rgba")||a(c.backgroundColor,"hsla")}(),r=["
","
","
","
"].join(""),s=function(){var a="";if(p)for(var b=1;6>=b;b++)a+="
";return["
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
",a,"
","
","
","
","
","","
","
","
","","","
","
","
"].join("")}(),t="spectrum.id";b.fn.spectrum=function(a,c){if("string"==typeof a){var d=this,e=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=o[b(this).data(t)];if(c){var f=c[a];if(!f)throw new Error("Spectrum: no such method: '"+a+"'");"get"==a?d=c.get():"container"==a?d=c.container:"option"==a?d=c.option.apply(c,e):"destroy"==a?(c.destroy(),b(this).removeData(t)):f.apply(c,e)}}),d}return this.spectrum("destroy").each(function(){var c=g(this,a);b(this).data(t,c.id)})},b.fn.spectrum.load=!0,b.fn.spectrum.loadOpts={},b.fn.spectrum.draggable=l,b.fn.spectrum.defaults=n,b.spectrum={},b.spectrum.localization={},b.spectrum.palettes={},b.fn.spectrum.processNativeColorInputs=function(){var a=b("")[0],c="color"===a.type&&"!"!=a.value;c||b("input[type=color]").spectrum({preferredFormat:"hex6"})},function(){function b(a,d){if(a=a?a:"",d=d||{},"object"==typeof a&&a.hasOwnProperty("_tc_id"))return a;var f=c(a),h=f.r,j=f.g,m=f.b,n=f.a,o=x(100*n)/100,p=d.format||f.format;return 1>h&&(h=x(h)),1>j&&(j=x(j)),1>m&&(m=x(m)),{ok:f.ok,format:p,_tc_id:v++,alpha:n,getAlpha:function(){return n},setAlpha:function(a){n=k(a),o=x(100*n)/100},toHsv:function(){var a=g(h,j,m);return{h:360*a.h,s:a.s,v:a.v,a:n}},toHsvString:function(){var a=g(h,j,m),b=x(360*a.h),c=x(100*a.s),d=x(100*a.v);return 1==n?"hsv("+b+", "+c+"%, "+d+"%)":"hsva("+b+", "+c+"%, "+d+"%, "+o+")"},toHsl:function(){var a=e(h,j,m);return{h:360*a.h,s:a.s,l:a.l,a:n}},toHslString:function(){var a=e(h,j,m),b=x(360*a.h),c=x(100*a.s),d=x(100*a.l);return 1==n?"hsl("+b+", "+c+"%, "+d+"%)":"hsla("+b+", "+c+"%, "+d+"%, "+o+")"},toHex:function(a){return i(h,j,m,a)},toHexString:function(a){return"#"+i(h,j,m,a)},toRgb:function(){return{r:x(h),g:x(j),b:x(m),a:n}},toRgbString:function(){return 1==n?"rgb("+x(h)+", "+x(j)+", "+x(m)+")":"rgba("+x(h)+", "+x(j)+", "+x(m)+", "+o+")"},toPercentageRgb:function(){return{r:x(100*l(h,255))+"%",g:x(100*l(j,255))+"%",b:x(100*l(m,255))+"%",a:n}},toPercentageRgbString:function(){return 1==n?"rgb("+x(100*l(h,255))+"%, "+x(100*l(j,255))+"%, "+x(100*l(m,255))+"%)":"rgba("+x(100*l(h,255))+"%, "+x(100*l(j,255))+"%, "+x(100*l(m,255))+"%, "+o+")"},toName:function(){return 0===n?"transparent":C[i(h,j,m,!0)]||!1},toFilter:function(a){var c=i(h,j,m),e=c,f=Math.round(255*parseFloat(n)).toString(16),g=f,k=d&&d.gradientType?"GradientType = 1, ":"";if(a){var l=b(a);e=l.toHex(),g=Math.round(255*parseFloat(l.alpha)).toString(16)}return"progid:DXImageTransform.Microsoft.gradient("+k+"startColorstr=#"+q(f)+c+",endColorstr=#"+q(g)+e+")"},toString:function(a){var b=!!a;a=a||this.format;var c=!1,d=!b&&1>n&&n>0,e=d&&("hex"===a||"hex6"===a||"hex3"===a||"name"===a);return"rgb"===a&&(c=this.toRgbString()),"prgb"===a&&(c=this.toPercentageRgbString()),("hex"===a||"hex6"===a)&&(c=this.toHexString()),"hex3"===a&&(c=this.toHexString(!0)),"name"===a&&(c=this.toName()),"hsl"===a&&(c=this.toHslString()),"hsv"===a&&(c=this.toHsvString()),e?this.toRgbString():c||this.toHexString()}}}function c(a){var b={r:0,g:0,b:0},c=1,e=!1,g=!1;return"string"==typeof a&&(a=s(a)),"object"==typeof a&&(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b")?(b=d(a.r,a.g,a.b),e=!0,g="%"===String(a.r).substr(-1)?"prgb":"rgb"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")?(a.s=r(a.s),a.v=r(a.v),b=h(a.h,a.s,a.v),e=!0,g="hsv"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=r(a.s),a.l=r(a.l),b=f(a.h,a.s,a.l),e=!0,g="hsl"),a.hasOwnProperty("a")&&(c=a.a)),c=k(c),{ok:e,format:a.format||g,r:y(255,z(b.r,0)),g:y(255,z(b.g,0)),b:y(255,z(b.b,0)),a:c}}function d(a,b,c){return{r:255*l(a,255),g:255*l(b,255),b:255*l(c,255)}}function e(a,b,c){a=l(a,255),b=l(b,255),c=l(c,255);var d,e,f=z(a,b,c),g=y(a,b,c),h=(f+g)/2;if(f==g)d=e=0;else{var i=f-g;switch(e=h>.5?i/(2-f-g):i/(f+g),f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,l:h}}function f(a,b,c){function d(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a}var e,f,g;if(a=l(a,360),b=l(b,100),c=l(c,100),0===b)e=f=g=c;else{var h=.5>c?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function g(a,b,c){a=l(a,255),b=l(b,255),c=l(c,255);var d,e,f=z(a,b,c),g=y(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function h(a,b,c){a=6*l(a,360),b=l(b,100),c=l(c,100);var d=w.floor(a),e=a-d,f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=d%6,j=[c,g,f,f,h,c][i],k=[h,c,c,g,f,f][i],m=[f,f,h,c,c,g][i];return{r:255*j,g:255*k,b:255*m}}function i(a,b,c,d){var e=[q(x(a).toString(16)),q(x(b).toString(16)),q(x(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function j(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function k(a){return a=parseFloat(a),(isNaN(a)||0>a||a>1)&&(a=1),a}function l(a,b){o(a)&&(a="100%");var c=p(a);return a=y(b,z(0,parseFloat(a))),c&&(a=parseInt(a*b,10)/100),w.abs(a-b)<1e-6?1:a%b/parseFloat(b)}function m(a){return y(1,z(0,a))}function n(a){return parseInt(a,16)}function o(a){return"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)}function p(a){return"string"==typeof a&&-1!=a.indexOf("%")}function q(a){return 1==a.length?"0"+a:""+a}function r(a){return 1>=a&&(a=100*a+"%"),a}function s(a){a=a.replace(t,"").replace(u,"").toLowerCase();var b=!1;if(B[a])a=B[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};var c;return(c=D.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=D.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=D.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=D.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=D.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=D.hex6.exec(a))?{r:n(c[1]),g:n(c[2]),b:n(c[3]),format:b?"name":"hex"}:(c=D.hex3.exec(a))?{r:n(c[1]+""+c[1]),g:n(c[2]+""+c[2]),b:n(c[3]+""+c[3]),format:b?"name":"hex"}:!1}var t=/^[\s,#]+/,u=/\s+$/,v=0,w=Math,x=w.round,y=w.min,z=w.max,A=w.random;b.fromRatio=function(a,c){if("object"==typeof a){var d={};for(var e in a)a.hasOwnProperty(e)&&(d[e]="a"===e?a[e]:r(a[e]));a=d}return b(a,c)},b.equals=function(a,c){return a&&c?b(a).toRgbString()==b(c).toRgbString():!1},b.random=function(){return b.fromRatio({r:A(),g:A(),b:A()})},b.desaturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s-=c/100,d.s=m(d.s),b(d)},b.saturate=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.s+=c/100,d.s=m(d.s),b(d)},b.greyscale=function(a){return b.desaturate(a,100)},b.lighten=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l+=c/100,d.l=m(d.l),b(d)},b.darken=function(a,c){c=0===c?0:c||10;var d=b(a).toHsl();return d.l-=c/100,d.l=m(d.l),b(d)},b.complement=function(a){var c=b(a).toHsl();return c.h=(c.h+180)%360,b(c)},b.triad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+120)%360,s:c.s,l:c.l}),b({h:(d+240)%360,s:c.s,l:c.l})]},b.tetrad=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+90)%360,s:c.s,l:c.l}),b({h:(d+180)%360,s:c.s,l:c.l}),b({h:(d+270)%360,s:c.s,l:c.l})]},b.splitcomplement=function(a){var c=b(a).toHsl(),d=c.h;return[b(a),b({h:(d+72)%360,s:c.s,l:c.l}),b({h:(d+216)%360,s:c.s,l:c.l})]},b.analogous=function(a,c,d){c=c||6,d=d||30;var e=b(a).toHsl(),f=360/d,g=[b(a)];for(e.h=(e.h-(f*c>>1)+720)%360;--c;)e.h=(e.h+f)%360,g.push(b(e));return g},b.monochromatic=function(a,c){c=c||6;for(var d=b(a).toHsv(),e=d.h,f=d.s,g=d.v,h=[],i=1/c;c--;)h.push(b({h:e,s:f,v:g})),g=(g+i)%1;return h},b.readability=function(a,c){var d=b(a).toRgb(),e=b(c).toRgb(),f=(299*d.r+587*d.g+114*d.b)/1e3,g=(299*e.r+587*e.g+114*e.b)/1e3,h=Math.max(d.r,e.r)-Math.min(d.r,e.r)+Math.max(d.g,e.g)-Math.min(d.g,e.g)+Math.max(d.b,e.b)-Math.min(d.b,e.b);return{brightness:Math.abs(f-g),color:h}},b.readable=function(a,c){var d=b.readability(a,c);return d.brightness>125&&d.color>500},b.mostReadable=function(a,c){for(var d=null,e=0,f=!1,g=0;g125&&h.color>500,j=3*(h.brightness/125)+h.color/500;(i&&!f||i&&f&&j>e||!i&&!f&&j>e)&&(f=i,e=j,d=b(c[g]))}return d};var B=b.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},C=b.hexNames=j(B),D=function(){var a="[-\\+]?\\d+%?",b="[-\\+]?\\d*\\.\\d+%?",c="(?:"+b+")|(?:"+a+")",d="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?",e="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?";return{rgb:new RegExp("rgb"+d),rgba:new RegExp("rgba"+e),hsl:new RegExp("hsl"+d),hsla:new RegExp("hsla"+e),hsv:new RegExp("hsv"+d),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();a.tinycolor=b}();var u=a.tinycolor;b(function(){b.fn.spectrum.load&&b.fn.spectrum.processNativeColorInputs()})}(window,jQuery),function(a){"use strict";if("function"==typeof bootstrap)bootstrap("promise",a);else if("object"==typeof exports&&"object"==typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=a}else{if("undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");self.Q=a()}}(function(){"use strict";function a(a){return function(){return W.apply(a,arguments)}}function b(a){return a===Object(a)}function c(a){return"[object StopIteration]"===ca(a)||a instanceof S}function d(a,b){if(P&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(da)){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var f=c.join("\n"+da+"\n");a.stack=e(f)}}function e(a){for(var b=a.split("\n"),c=[],d=0;d=T&&ha>=d}function i(){if(P)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=g(c);if(!d)return;return R=d[0],d[1]}}function j(a,b,c){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(b+" is deprecated, use "+c+" instead.",new Error("").stack),a.apply(a,arguments)}}function k(a){return a instanceof o?a:s(a)?B(a):A(a)}function l(){function a(a){b=a,f.source=a,Y(c,function(b,c){k.nextTick(function(){a.promiseDispatch.apply(a,c)})},void 0),c=void 0,d=void 0}var b,c=[],d=[],e=_(l.prototype),f=_(o.prototype);if(f.promiseDispatch=function(a,e,f){var g=X(arguments);c?(c.push(g),"when"===e&&f[1]&&d.push(f[1])):k.nextTick(function(){b.promiseDispatch.apply(b,g)})},f.valueOf=function(){if(c)return f;var a=q(b);return r(a)&&(b=a),a},f.inspect=function(){return b?b.inspect():{state:"pending"}},k.longStackSupport&&P)try{throw new Error}catch(g){f.stack=g.stack.substring(g.stack.indexOf("\n")+1)}return e.promise=f,e.resolve=function(c){b||a(k(c))},e.fulfill=function(c){b||a(A(c))},e.reject=function(c){b||a(z(c))},e.notify=function(a){b||Y(d,function(b,c){k.nextTick(function(){c(a)})},void 0)},e}function m(a){if("function"!=typeof a)throw new TypeError("resolver must be a function.");var b=l();try{a(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}return b.promise}function n(a){return m(function(b,c){for(var d=0,e=a.length;e>d;d++)k(a[d]).then(b,c)})}function o(a,b,c){void 0===b&&(b=function(a){return z(new Error("Promise does not support operation: "+a))}),void 0===c&&(c=function(){return{state:"unknown"}});var d=_(o.prototype);if(d.promiseDispatch=function(c,e,f){var g;try{g=a[e]?a[e].apply(d,f):b.call(d,e,f)}catch(h){g=z(h)}c&&c(g)},d.inspect=c,c){var e=c();"rejected"===e.state&&(d.exception=e.reason),d.valueOf=function(){var a=c();return"pending"===a.state||"rejected"===a.state?d:a.value}}return d}function p(a,b,c,d){return k(a).then(b,c,d)}function q(a){if(r(a)){var b=a.inspect();if("fulfilled"===b.state)return b.value}return a}function r(a){return a instanceof o}function s(a){return b(a)&&"function"==typeof a.then}function t(a){return r(a)&&"pending"===a.inspect().state}function u(a){return!r(a)||"fulfilled"===a.inspect().state}function v(a){return r(a)&&"rejected"===a.inspect().state}function w(){ea.length=0,fa.length=0,ga||(ga=!0)}function x(a,b){ga&&(fa.push(a),ea.push(b&&"undefined"!=typeof b.stack?b.stack:"(no stack) "+b))}function y(a){if(ga){var b=Z(fa,a);-1!==b&&(fa.splice(b,1),ea.splice(b,1))}}function z(a){var b=o({when:function(b){return b&&y(this),b?b(a):this}},function(){return this},function(){return{state:"rejected",reason:a}});return x(b,a),b}function A(a){return o({when:function(){return a},get:function(b){return a[b]},set:function(b,c){a[b]=c},"delete":function(b){delete a[b]},post:function(b,c){return null===b||void 0===b?a.apply(void 0,c):a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},keys:function(){return ba(a)}},void 0,function(){return{state:"fulfilled",value:a}})}function B(a){var b=l();return k.nextTick(function(){ +try{a.then(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}}),b.promise}function C(a){return o({isDef:function(){}},function(b,c){return I(a,b,c)},function(){return k(a).inspect()})}function D(a,b,c){return k(a).spread(b,c)}function E(a){return function(){function b(a,b){var g;if("undefined"==typeof StopIteration){try{g=d[a](b)}catch(h){return z(h)}return g.done?k(g.value):p(g.value,e,f)}try{g=d[a](b)}catch(h){return c(h)?k(h.value):z(h)}return p(g,e,f)}var d=a.apply(this,arguments),e=b.bind(b,"next"),f=b.bind(b,"throw");return e()}}function F(a){k.done(k.async(a)())}function G(a){throw new S(a)}function H(a){return function(){return D([this,J(arguments)],function(b,c){return a.apply(b,c)})}}function I(a,b,c){return k(a).dispatch(b,c)}function J(a){return p(a,function(a){var b=0,c=l();return Y(a,function(d,e,f){var g;r(e)&&"fulfilled"===(g=e.inspect()).state?a[f]=g.value:(++b,p(e,function(d){a[f]=d,0===--b&&c.resolve(a)},c.reject,function(a){c.notify({index:f,value:a})}))},void 0),0===b&&c.resolve(a),c.promise})}function K(a){if(0===a.length)return k.resolve();var b=k.defer(),c=0;return Y(a,function(d,e,f){function g(a){b.resolve(a)}function h(){c--,0===c&&b.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function i(a){b.notify({index:f,value:a})}var j=a[f];c++,p(j,g,h,i)},void 0),b.promise}function L(a){return p(a,function(a){return a=$(a,k),p(J($(a,function(a){return p(a,U,U)})),function(){return a})})}function M(a){return k(a).allSettled()}function N(a,b){return k(a).then(void 0,void 0,b)}function O(a,b){return k(a).nodeify(b)}var P=!1;try{throw new Error}catch(Q){P=!!Q.stack}var R,S,T=i(),U=function(){},V=function(){function a(){for(;b.next;){b=b.next;var c=b.task;b.task=void 0;var e=b.domain;e&&(b.domain=void 0,e.enter());try{c()}catch(g){if(f)throw e&&e.exit(),setTimeout(a,0),e&&e.enter(),g;setTimeout(function(){throw g},0)}e&&e.exit()}d=!1}var b={task:void 0,next:null},c=b,d=!1,e=void 0,f=!1;if(V=function(a){c=c.next={task:a,domain:f&&process.domain,next:null},d||(d=!0,e())},"undefined"!=typeof process&&process.nextTick)f=!0,e=function(){process.nextTick(a)};else if("function"==typeof setImmediate)e="undefined"!=typeof window?setImmediate.bind(window,a):function(){setImmediate(a)};else if("undefined"!=typeof MessageChannel){var g=new MessageChannel;g.port1.onmessage=function(){e=h,g.port1.onmessage=a,a()};var h=function(){g.port2.postMessage(0)};e=function(){setTimeout(a,0),h()}}else e=function(){setTimeout(a,0)};return V}(),W=Function.call,X=a(Array.prototype.slice),Y=a(Array.prototype.reduce||function(a,b){var c=0,d=this.length;if(1===arguments.length)for(;;){if(c in this){b=this[c++];break}if(++c>=d)throw new TypeError}for(;d>c;c++)c in this&&(b=a(b,this[c],c));return b}),Z=a(Array.prototype.indexOf||function(a){for(var b=0;b2?X(arguments,1):c)}},k.Promise=m,k.promise=m,m.race=n,m.all=J,m.reject=z,m.resolve=k,k.passByCopy=function(a){return a},o.prototype.passByCopy=function(){return this},k.join=function(a,b){return k(a).join(b)},o.prototype.join=function(a){return k([this,a]).spread(function(a,b){if(a===b)return a;throw new Error("Can't join: not the same: "+a+" "+b)})},k.race=n,o.prototype.race=function(){return this.then(k.race)},k.makePromise=o,o.prototype.toString=function(){return"[object Promise]"},o.prototype.then=function(a,b,c){function e(b){try{return"function"==typeof a?a(b):b}catch(c){return z(c)}}function f(a){if("function"==typeof b){d(a,h);try{return b(a)}catch(c){return z(c)}}return z(a)}function g(a){return"function"==typeof c?c(a):a}var h=this,i=l(),j=!1;return k.nextTick(function(){h.promiseDispatch(function(a){j||(j=!0,i.resolve(e(a)))},"when",[function(a){j||(j=!0,i.resolve(f(a)))}])}),h.promiseDispatch(void 0,"when",[void 0,function(a){var b,c=!1;try{b=g(a)}catch(d){if(c=!0,!k.onerror)throw d;k.onerror(d)}c||i.notify(b)}]),i.promise},k.tap=function(a,b){return k(a).tap(b)},o.prototype.tap=function(a){return a=k(a),this.then(function(b){return a.fcall(b).thenResolve(b)})},k.when=p,o.prototype.thenResolve=function(a){return this.then(function(){return a})},k.thenResolve=function(a,b){return k(a).thenResolve(b)},o.prototype.thenReject=function(a){return this.then(function(){throw a})},k.thenReject=function(a,b){return k(a).thenReject(b)},k.nearer=q,k.isPromise=r,k.isPromiseAlike=s,k.isPending=t,o.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=u,o.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=v,o.prototype.isRejected=function(){return"rejected"===this.inspect().state};var ea=[],fa=[],ga=!0;k.resetUnhandledRejections=w,k.getUnhandledReasons=function(){return ea.slice()},k.stopUnhandledRejectionTracking=function(){w(),ga=!1},w(),k.reject=z,k.fulfill=A,k.master=C,k.spread=D,o.prototype.spread=function(a,b){return this.all().then(function(b){return a.apply(void 0,b)},b)},k.async=E,k.spawn=F,k["return"]=G,k.promised=H,k.dispatch=I,o.prototype.dispatch=function(a,b){var c=this,d=l();return k.nextTick(function(){c.promiseDispatch(d.resolve,a,b)}),d.promise},k.get=function(a,b){return k(a).dispatch("get",[b])},o.prototype.get=function(a){return this.dispatch("get",[a])},k.set=function(a,b,c){return k(a).dispatch("set",[b,c])},o.prototype.set=function(a,b){return this.dispatch("set",[a,b])},k.del=k["delete"]=function(a,b){return k(a).dispatch("delete",[b])},o.prototype.del=o.prototype["delete"]=function(a){return this.dispatch("delete",[a])},k.mapply=k.post=function(a,b,c){return k(a).dispatch("post",[b,c])},o.prototype.mapply=o.prototype.post=function(a,b){return this.dispatch("post",[a,b])},k.send=k.mcall=k.invoke=function(a,b){return k(a).dispatch("post",[b,X(arguments,2)])},o.prototype.send=o.prototype.mcall=o.prototype.invoke=function(a){return this.dispatch("post",[a,X(arguments,1)])},k.fapply=function(a,b){return k(a).dispatch("apply",[void 0,b])},o.prototype.fapply=function(a){return this.dispatch("apply",[void 0,a])},k["try"]=k.fcall=function(a){return k(a).dispatch("apply",[void 0,X(arguments,1)])},o.prototype.fcall=function(){return this.dispatch("apply",[void 0,X(arguments)])},k.fbind=function(a){var b=k(a),c=X(arguments,1);return function(){return b.dispatch("apply",[this,c.concat(X(arguments))])}},o.prototype.fbind=function(){var a=this,b=X(arguments);return function(){return a.dispatch("apply",[this,b.concat(X(arguments))])}},k.keys=function(a){return k(a).dispatch("keys",[])},o.prototype.keys=function(){return this.dispatch("keys",[])},k.all=J,o.prototype.all=function(){return J(this)},k.any=K,o.prototype.any=function(){return K(this)},k.allResolved=j(L,"allResolved","allSettled"),o.prototype.allResolved=function(){return L(this)},k.allSettled=M,o.prototype.allSettled=function(){return this.then(function(a){return J($(a,function(a){function b(){return a.inspect()}return a=k(a),a.then(b,b)}))})},k.fail=k["catch"]=function(a,b){return k(a).then(void 0,b)},o.prototype.fail=o.prototype["catch"]=function(a){return this.then(void 0,a)},k.progress=N,o.prototype.progress=function(a){return this.then(void 0,void 0,a)},k.fin=k["finally"]=function(a,b){return k(a)["finally"](b)},o.prototype.fin=o.prototype["finally"]=function(a){return a=k(a),this.then(function(b){return a.fcall().then(function(){return b})},function(b){return a.fcall().then(function(){throw b})})},k.done=function(a,b,c,d){return k(a).done(b,c,d)},o.prototype.done=function(a,b,c){var e=function(a){k.nextTick(function(){if(d(a,f),!k.onerror)throw a;k.onerror(a)})},f=a||b||c?this.then(a,b,c):this;"object"==typeof process&&process&&process.domain&&(e=process.domain.bind(e)),f.then(void 0,e)},k.timeout=function(a,b,c){return k(a).timeout(b,c)},o.prototype.timeout=function(a,b){var c=l(),d=setTimeout(function(){b&&"string"!=typeof b||(b=new Error(b||"Timed out after "+a+" ms"),b.code="ETIMEDOUT"),c.reject(b)},a);return this.then(function(a){clearTimeout(d),c.resolve(a)},function(a){clearTimeout(d),c.reject(a)},c.notify),c.promise},k.delay=function(a,b){return void 0===b&&(b=a,a=void 0),k(a).delay(b)},o.prototype.delay=function(a){return this.then(function(b){var c=l();return setTimeout(function(){c.resolve(b)},a),c.promise})},k.nfapply=function(a,b){return k(a).nfapply(b)},o.prototype.nfapply=function(a){var b=l(),c=X(a);return c.push(b.makeNodeResolver()),this.fapply(c).fail(b.reject),b.promise},k.nfcall=function(a){var b=X(arguments,1);return k(a).nfapply(b)},o.prototype.nfcall=function(){var a=X(arguments),b=l();return a.push(b.makeNodeResolver()),this.fapply(a).fail(b.reject),b.promise},k.nfbind=k.denodeify=function(a){var b=X(arguments,1);return function(){var c=b.concat(X(arguments)),d=l();return c.push(d.makeNodeResolver()),k(a).fapply(c).fail(d.reject),d.promise}},o.prototype.nfbind=o.prototype.denodeify=function(){var a=X(arguments);return a.unshift(this),k.denodeify.apply(void 0,a)},k.nbind=function(a,b){var c=X(arguments,2);return function(){function d(){return a.apply(b,arguments)}var e=c.concat(X(arguments)),f=l();return e.push(f.makeNodeResolver()),k(d).fapply(e).fail(f.reject),f.promise}},o.prototype.nbind=function(){var a=X(arguments,0);return a.unshift(this),k.nbind.apply(void 0,a)},k.nmapply=k.npost=function(a,b,c){return k(a).npost(b,c)},o.prototype.nmapply=o.prototype.npost=function(a,b){var c=X(b||[]),d=l();return c.push(d.makeNodeResolver()),this.dispatch("post",[a,c]).fail(d.reject),d.promise},k.nsend=k.nmcall=k.ninvoke=function(a,b){var c=X(arguments,2),d=l();return c.push(d.makeNodeResolver()),k(a).dispatch("post",[b,c]).fail(d.reject),d.promise},o.prototype.nsend=o.prototype.nmcall=o.prototype.ninvoke=function(a){var b=X(arguments,1),c=l();return b.push(c.makeNodeResolver()),this.dispatch("post",[a,b]).fail(c.reject),c.promise},k.nodeify=O,o.prototype.nodeify=function(a){return a?void this.then(function(b){k.nextTick(function(){a(null,b)})},function(b){k.nextTick(function(){a(b)})}):this};var ha=i();return k}),function(){var a=$.namespace("pskl.rendering");a.DrawingLoop=function(){this.requestAnimationFrame=this.getRequestAnimationFrameShim_(),this.isRunning=!1,this.previousTime=0,this.callbacks=[]},a.DrawingLoop.prototype.addCallback=function(a,b,c){var d={fn:a,scope:b,args:c};return this.callbacks.push(d),d},a.DrawingLoop.prototype.removeCallback=function(a){var b=this.callbacks.indexOf(a);-1!=b&&this.callbacks.splice(b,1)},a.DrawingLoop.prototype.start=function(){this.isRunning=!0,this.loop_()},a.DrawingLoop.prototype.loop_=function(){var a=Date.now(),b=a-this.previousTime;this.executeCallbacks_(b),this.previousTime=a,this.requestAnimationFrame.call(window,this.loop_.bind(this))},a.DrawingLoop.prototype.executeCallbacks_=function(a){for(var b=0;bd;d++){for(var e=[],f=0;b>f;f++)e.push(Constants.TRANSPARENT_COLOR);c[d]=e}return c},a.Frame.createEmptyFromFrame=function(b){return new a.Frame(b.getWidth(),b.getHeight())},a.Frame.prototype.clone=function(){var b=new a.Frame(this.width,this.height);return b.setPixels(this.getPixels()),b},a.Frame.prototype.getPixels=function(){return this.clonePixels_(this.pixels)},a.Frame.prototype.setPixels=function(a){this.pixels=this.clonePixels_(a),this.version++},a.Frame.prototype.clear=function(){var b=a.Frame.createEmptyPixelGrid_(this.getWidth(),this.getHeight());this.setPixels(b)},a.Frame.prototype.clonePixels_=function(a){for(var b=[],c=0;cd;d++)for(var e=0;c>e;e++)a(this.pixels[d][e],d,e,this)},a.Frame.prototype.getWidth=function(){return this.width},a.Frame.prototype.getHeight=function(){return this.height},a.Frame.prototype.containsPixel=function(a,b){return a>=0&&b>=0&&a0&&a[0].size()>0))throw"Piskel.fromLayers expects array of non empty pskl.model.Layer as first argument";var d=a[0].getFrameAt(0);return c=new pskl.model.Piskel(d.getWidth(),d.getHeight(),b),a.forEach(c.addLayer.bind(c)),c},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getHeight=function(){return this.height},a.Piskel.prototype.getWidth=function(){return this.width},a.Piskel.prototype.getLayers=function(){return this.layers},a.Piskel.prototype.getLayerAt=function(a){return this.layers[a]},a.Piskel.prototype.getLayersByName=function(a){return this.layers.filter(function(b){return b.getName()==a})},a.Piskel.prototype.addLayer=function(a){this.layers.push(a)},a.Piskel.prototype.addLayerAt=function(a,b){this.layers.splice(b,0,a)},a.Piskel.prototype.moveLayerUp=function(a){var b=this.layers.indexOf(a);b>-1&&b0&&(this.layers[b]=this.layers[b-1],this.layers[b-1]=a)},a.Piskel.prototype.removeLayer=function(a){var b=this.layers.indexOf(a);-1!=b&&this.layers.splice(b,1)},a.Piskel.prototype.removeLayerAt=function(a){this.layers.splice(a,1)},a.Piskel.prototype.getDescriptor=function(){return this.descriptor},a.Piskel.prototype.setDescriptor=function(a){this.descriptor=a;$(".piskel-name").html(this.descriptor.name)},a.Piskel.prototype.getHash=function(){return this.layers.map(function(a){return a.getHash()}).join("-")}}(),function(){var a=$.namespace("pskl.selection"),b={PASTE:"REPLAY_PASTE",ERASE:"REPLAY_ERASE"};a.SelectionManager=function(a){this.piskelController=a,this.currentSelection=null},a.SelectionManager.prototype.init=function(){$.subscribe(Events.SELECTION_CREATED,$.proxy(this.onSelectionCreated_,this)),$.subscribe(Events.SELECTION_DISMISSED,$.proxy(this.onSelectionDismissed_,this)),$.subscribe(Events.SELECTION_MOVE_REQUEST,$.proxy(this.onSelectionMoved_,this)),pskl.app.shortcutService.addShortcut("ctrl+V",this.paste.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+X",this.cut.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+C",this.copy.bind(this)),pskl.app.shortcutService.addShortcut("del",this.erase.bind(this)),pskl.app.shortcutService.addShortcut("back",this.onBackPressed_.bind(this)),$.subscribe(Events.TOOL_SELECTED,$.proxy(this.onToolSelected_,this))},a.SelectionManager.prototype.cleanSelection_=function(){this.currentSelection&&(this.currentSelection.reset(),this.currentSelection=null)},a.SelectionManager.prototype.onToolSelected_=function(a,b){var c=b instanceof pskl.tools.drawing.BaseSelect;c||this.cleanSelection_()},a.SelectionManager.prototype.onSelectionDismissed_=function(a){this.cleanSelection_()},a.SelectionManager.prototype.onBackPressed_=function(a){return this.currentSelection?void this.erase():!0},a.SelectionManager.prototype.erase=function(){for(var a=this.currentSelection.pixels,c=this.piskelController.getCurrentFrame(),d=0,e=a.length;e>d;d++)c.setPixel(a[d].col,a[d].row,Constants.TRANSPARENT_COLOR);$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{type:b.ERASE,pixels:JSON.parse(JSON.stringify(a.slice(0)))}})},a.SelectionManager.prototype.cut=function(){this.currentSelection&&(this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame()),this.erase())},a.SelectionManager.prototype.paste=function(){if(this.currentSelection&&this.currentSelection.hasPastedContent){var a=this.currentSelection.pixels,c=this.piskelController.getCurrentFrame();this.pastePixels_(c,a),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{type:b.PASTE,pixels:JSON.parse(JSON.stringify(a.slice(0)))}})}},a.SelectionManager.prototype.replay=function(a,c){c.type===b.PASTE?this.pastePixels_(a,c.pixels):c.type===b.ERASE&&c.pixels.forEach(function(b){a.setPixel(b.col,b.row,Constants.TRANSPARENT_COLOR)})},a.SelectionManager.prototype.pastePixels_=function(a,b){b.forEach(function(b){b.color!==Constants.TRANSPARENT_COLOR&&null!==b.color&&a.setPixel(b.col,b.row,b.color)})},a.SelectionManager.prototype.copy=function(){this.currentSelection&&this.piskelController.getCurrentFrame()&&this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame())},a.SelectionManager.prototype.onSelectionCreated_=function(a,b){b?this.currentSelection=b:console.error("No selection provided to SelectionManager")},a.SelectionManager.prototype.onSelectionMoved_=function(a,b,c){this.currentSelection?this.currentSelection.move(b,c):console.error("Bad state: No currentSelection set when trying to move it in SelectionManager")}}(),function(){var a=$.namespace("pskl.selection");a.BaseSelection=function(){this.reset()},a.BaseSelection.prototype.reset=function(){this.pixels=[],this.hasPastedContent=!1},a.BaseSelection.prototype.move=function(a,b){for(var c=[],d=0,e=this.pixels.length;e>d;d++){var f=this.pixels[d];f.col+=a,f.row+=b,c.push(f)}this.pixels=c},a.BaseSelection.prototype.fillSelectionFromFrame=function(a){this.pixels.forEach(function(b){var c=a.getPixel(b.col,b.row);b.color=c||Constants.TRANSPARENT_COLOR}),this.hasPastedContent=!0}}(),function(){var a=$.namespace("pskl.selection");a.RectangularSelection=function(a,b,c,d){this.pixels=pskl.PixelUtils.getRectanglePixels(a,b,c,d)},pskl.utils.inherit(a.RectangularSelection,a.BaseSelection)}(),function(){var a=$.namespace("pskl.selection");a.ShapeSelection=function(a){this.pixels=a},pskl.utils.inherit(a.ShapeSelection,a.BaseSelection)}(),function(){var a=$.namespace("pskl.rendering");a.AbstractRenderer=function(){},a.AbstractRenderer.prototype.clear=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.render=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getCoordinates=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setGridWidth=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getGridWidth=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setZoom=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getZoom=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setOffset=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getOffset=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.setDisplaySize=Constants.ABSTRACT_FUNCTION,a.AbstractRenderer.prototype.getDisplaySize=Constants.ABSTRACT_FUNCTION}(),function(){var a=$.namespace("pskl.rendering");a.CompositeRenderer=function(){this.renderers=[]},pskl.utils.inherit(pskl.rendering.CompositeRenderer,pskl.rendering.AbstractRenderer),a.CompositeRenderer.prototype.add=function(a){return this.renderers.push(a),this},a.CompositeRenderer.prototype.clear=function(){this.renderers.forEach(function(a){a.clear()})},a.CompositeRenderer.prototype.setZoom=function(a){this.renderers.forEach(function(b){b.setZoom(a)})},a.CompositeRenderer.prototype.getZoom=function(){return this.getSampleRenderer_().getZoom()},a.CompositeRenderer.prototype.setDisplaySize=function(a,b){this.renderers.forEach(function(c){c.setDisplaySize(a,b)})},a.CompositeRenderer.prototype.getDisplaySize=function(){return this.getSampleRenderer_().getDisplaySize()},a.CompositeRenderer.prototype.setOffset=function(a,b){this.renderers.forEach(function(c){c.setOffset(a,b)})},a.CompositeRenderer.prototype.getOffset=function(){return this.getSampleRenderer_().getOffset()},a.CompositeRenderer.prototype.setGridWidth=function(a){this.renderers.forEach(function(b){b.setGridWidth(a)})},a.CompositeRenderer.prototype.getGridWidth=function(){return this.getSampleRenderer_().getGridWidth()},a.CompositeRenderer.prototype.getSampleRenderer_=function(){if(this.renderers.length>0)return this.renderers[0];throw"Renderer manager is empty"}}(),function(){var a=$.namespace("pskl.rendering.layer");a.LayersRenderer=function(a,b,c){pskl.rendering.CompositeRenderer.call(this),this.piskelController=c,this.belowRenderer=new pskl.rendering.frame.FrameRenderer(a,b,["layers-canvas","layers-below-canvas"]),this.aboveRenderer=new pskl.rendering.frame.FrameRenderer(a,b,["layers-canvas","layers-above-canvas"]),this.add(this.belowRenderer),this.add(this.aboveRenderer),this.serializedRendering="",this.stylesheet_=document.createElement("style"),document.head.appendChild(this.stylesheet_),this.updateLayersCanvasOpacity_(pskl.UserSettings.get(pskl.UserSettings.LAYER_OPACITY)),$.subscribe(Events.PISKEL_RESET,this.flush.bind(this)),$.subscribe(Events.USER_SETTINGS_CHANGED,$.proxy(this.onUserSettingsChange_,this))},pskl.utils.inherit(pskl.rendering.layer.LayersRenderer,pskl.rendering.CompositeRenderer),a.LayersRenderer.prototype.render=function(){var a=this.getOffset(),b=this.getDisplaySize(),c=this.piskelController.getLayers(),d=this.piskelController.getCurrentFrameIndex(),e=this.piskelController.getCurrentLayerIndex(),f=c.slice(0,e),g=c.slice(e+1,c.length),h=[this.getZoom(),this.getGridWidth(),a.x,a.y,b.width,b.height,this.getHashForLayersAt_(d,f),this.getHashForLayersAt_(d,g),c.length].join("-");if(this.serializedRendering!=h){if(this.serializedRendering=h,this.clear(),f.length>0){var i=this.getFrameForLayersAt_(d,f);this.belowRenderer.render(i)}if(g.length>0){var j=this.getFrameForLayersAt_(d,g);this.aboveRenderer.render(j)}}},a.LayersRenderer.prototype.setDisplaySize=function(a,b){var c=this.getDisplaySize();(c.width!==a||c.height!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.LayersRenderer.prototype.getFrameForLayersAt_=function(a,b){var c=b.map(function(b){return b.getFrameAt(a)});return pskl.utils.FrameUtils.merge(c)},a.LayersRenderer.prototype.getHashForLayersAt_=function(a,b){var c=b.map(function(b){return b.getFrameAt(a).getHash()});return c.join("-")},a.LayersRenderer.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.LAYER_OPACITY&&this.updateLayersCanvasOpacity_(c)},a.LayersRenderer.prototype.updateLayersCanvasOpacity_=function(a){this.stylesheet_.innerHTML=".layers-canvas { opacity : "+a+"}"},a.LayersRenderer.prototype.flush=function(){this.serializedRendering=""}}(),function(){var a=$.namespace("pskl.rendering.frame");a.FrameRenderer=function(a,b,c){if(this.defaultRenderingOptions={supportGridRendering:!1,zoom:1},b=$.extend(!0,{},this.defaultRenderingOptions,b),void 0===a)throw"Bad FrameRenderer initialization. undefined.";if(isNaN(b.zoom))throw"Bad FrameRenderer initialization. not well defined.";this.container=a,this.zoom=b.zoom,this.offset={x:0,y:0},this.margin={x:0,y:0},this.supportGridRendering=b.supportGridRendering,this.classList=c||[],this.classList.push("canvas"),this.canvas=null,this.displayCanvas=null,this.setDisplaySize(b.width,b.height),this.setGridWidth(pskl.UserSettings.get(pskl.UserSettings.GRID_WIDTH)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this))},pskl.utils.inherit(pskl.rendering.frame.FrameRenderer,pskl.rendering.AbstractRenderer),a.FrameRenderer.prototype.render=function(a){a&&(this.clear(),this.renderFrame_(a))},a.FrameRenderer.prototype.clear=function(){pskl.utils.CanvasUtils.clear(this.canvas),pskl.utils.CanvasUtils.clear(this.displayCanvas)},a.FrameRenderer.prototype.setZoom=function(a){if(a0;if(g||e){var h=pskl.utils.ImageResizer.resizeNearestNeighbour(this.canvas,this.zoom,f);b.drawImage(h,0,0)}else b.scale(this.zoom,this.zoom),b.drawImage(this.canvas,0,0);b.restore()}}(),function(){var a=$.namespace("pskl.rendering");a.OnionSkinRenderer=function(a,b){pskl.rendering.CompositeRenderer.call(this),this.piskelController=b,this.renderer=a,this.add(this.renderer),this.hash=""},a.OnionSkinRenderer.createInContainer=function(b,c,d){var e=new pskl.rendering.frame.FrameRenderer(b,c,["onion-skin-canvas"]);return new a.OnionSkinRenderer(e,d)},pskl.utils.inherit(pskl.rendering.OnionSkinRenderer,pskl.rendering.CompositeRenderer),a.OnionSkinRenderer.prototype.render=function(){var a=this.getOnionFrames_(),b=this.computeHash_(a);if(this.hash!=b&&(this.hash=b,this.clear(),a.length>0)){var c=pskl.utils.FrameUtils.merge(a);this.renderer.render(c)}},a.OnionSkinRenderer.prototype.getOnionFrames_=function(){var a=[],b=this.piskelController.getCurrentFrameIndex(),c=this.piskelController.getCurrentLayer(),d=b-1,e=c.getFrameAt(d);e&&a.push(e);var f=b+1,g=c.getFrameAt(f);return g&&a.push(g),a},a.OnionSkinRenderer.prototype.computeHash_=function(a){var b=this.getOffset(),c=this.getDisplaySize(),d=this.piskelController.getLayers();return[this.getZoom(),this.getGridWidth(),b.x,b.y,c.width,c.height,a.map(function(a){return a.getHash()}).join("-"),d.length].join("-")},a.OnionSkinRenderer.prototype.setDisplaySize=function(a,b){var c=this.getDisplaySize();(c.width!==a||c.height!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.OnionSkinRenderer.prototype.flush=function(){this.hash=""}}(),function(){var a=$.namespace("pskl.rendering.frame");a.BackgroundImageFrameRenderer=function(a,b){this.container=a,this.setZoom(b);var c=a.get(0),d=c.ownerDocument;this.frameContainer=d.createElement("div"),this.frameContainer.classList.add("background-image-frame-container"),a.get(0).appendChild(this.frameContainer),this.cachedFrameProcessor=new pskl.model.frame.CachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.frameToDataUrl_.bind(this))},a.BackgroundImageFrameRenderer.prototype.frameToDataUrl_=function(a){var b=new pskl.utils.FrameUtils.toImage(a,this.zoom);return b.toDataURL("image/png")},a.BackgroundImageFrameRenderer.prototype.render=function(a){var b=this.cachedFrameProcessor.get(a,this.zoom);this.frameContainer.style.backgroundImage="url("+b+")"},a.BackgroundImageFrameRenderer.prototype.show=function(){this.frameContainer&&(this.frameContainer.style.display="block")},a.BackgroundImageFrameRenderer.prototype.setZoom=function(a){this.zoom=a},a.BackgroundImageFrameRenderer.prototype.getZoom=function(){return this.zoom},a.BackgroundImageFrameRenderer.prototype.setRepeated=function(a){var b;b=a?"repeat":"no-repeat",this.frameContainer.style.backgroundRepeat=b}}(),function(){var a=$.namespace("pskl.rendering.frame");a.CachedFrameRenderer=function(a,b,c){pskl.rendering.frame.FrameRenderer.call(this,a,b,c),this.serializedFrame=""},pskl.utils.inherit(pskl.rendering.frame.CachedFrameRenderer,pskl.rendering.frame.FrameRenderer),a.CachedFrameRenderer.prototype.setDisplaySize=function(a,b){(this.displayWidth!==a||this.displayHeight!==b)&&this.superclass.setDisplaySize.call(this,a,b)},a.CachedFrameRenderer.prototype.render=function(a){var b=this.getOffset(),c=this.getDisplaySize(),d=[this.getZoom(),this.getGridWidth(),b.x,b.y,c.width,c.height,a.getHash()].join("-");this.serializedFrame!=d&&(this.serializedFrame=d,this.superclass.render.call(this,a))}}(),function(){var a=$.namespace("pskl.rendering");a.CanvasRenderer=function(a,b){this.frame=a,this.zoom=b,this.transparentColor_="white"},a.CanvasRenderer.prototype.drawTransparentAs=function(a){this.transparentColor_=a},a.CanvasRenderer.prototype.render=function(){var a=this.createCanvas_();pskl.utils.FrameUtils.drawToCanvas(this.frame,a,this.transparentColor_);var b=this.createCanvas_(this.zoom),c=b.getContext("2d");return pskl.utils.CanvasUtils.disableImageSmoothing(b),c.scale(this.zoom,this.zoom),c.drawImage(a,0,0),b},a.CanvasRenderer.prototype.createCanvas_=function(a){a=a||1;var b=this.frame.getWidth()*a,c=this.frame.getHeight()*a;return pskl.utils.CanvasUtils.createCanvas(b,c)}}(),function(){var a=$.namespace("pskl.rendering");a.FramesheetRenderer=function(a){if(!(a.length>0))throw"FramesheetRenderer : Invalid argument : frames is empty";this.frames=a},a.FramesheetRenderer.prototype.renderAsCanvas=function(){for(var a=this.createCanvas_(),b=0;b=a&&this.currentFrameIndex>0&&this.setCurrentFrameIndex(this.currentFrameIndex-1)},a.PiskelController.prototype.duplicateCurrentFrame=function(){this.duplicateFrameAt(this.currentFrameIndex)},a.PiskelController.prototype.duplicateFrameAt=function(a){this.getLayers().forEach(function(b){b.duplicateFrameAt(a)}),this.setCurrentFrameIndex(a+1)},a.PiskelController.prototype.moveFrame=function(a,b){this.getLayers().forEach(function(c){c.moveFrame(a,b)})},a.PiskelController.prototype.getFrameCount=function(){var a=this.piskel.getLayerAt(0);return a.size()},a.PiskelController.prototype.setCurrentFrameIndex=function(a){this.hasFrameAt(a)?this.currentFrameIndex=a:window.console.error("Could not set current frame index to "+a)},a.PiskelController.prototype.selectNextFrame=function(){var a=this.currentFrameIndex+1;a=0&&this.setCurrentFrameIndex(a)},a.PiskelController.prototype.setCurrentLayerIndex=function(a){this.hasLayerAt(a)?this.currentLayerIndex=a:window.console.error("Could not set current layer index to "+a)},a.PiskelController.prototype.selectLayer=function(a){var b=this.getLayers().indexOf(a);-1!=b&&this.setCurrentLayerIndex(b)},a.PiskelController.prototype.renameLayerAt=function(a,b){var c=this.getLayerByIndex(a);c&&c.setName(b)},a.PiskelController.prototype.mergeDownLayerAt=function(a){var b=this.getLayerByIndex(a),c=this.getLayerByIndex(a-1);if(b&&c){var d=pskl.utils.LayerUtils.mergeLayers(b,c);this.removeLayerAt(a),this.piskel.addLayerAt(d,a),this.removeLayerAt(a-1),this.selectLayer(d)}},a.PiskelController.prototype.generateLayerName_=function(){for(var a="Layer "+this.layerIdCounter;this.hasLayerForName_(a);)this.layerIdCounter++,a="Layer "+this.layerIdCounter;return a},a.PiskelController.prototype.createLayer=function(a){if(a||(a=this.generateLayerName_()),this.hasLayerForName_(a))throw"Layer name should be unique";for(var b=new pskl.model.Layer(a),c=0;c0},a.PiskelController.prototype.moveLayerUp=function(){var a=this.getCurrentLayer();this.piskel.moveLayerUp(a),this.selectLayer(a)},a.PiskelController.prototype.moveLayerDown=function(){var a=this.getCurrentLayer();this.piskel.moveLayerDown(a),this.selectLayer(a)},a.PiskelController.prototype.removeCurrentLayer=function(){var a=this.getCurrentLayerIndex();this.removeLayerAt(a)},a.PiskelController.prototype.removeLayerAt=function(a){if(this.getLayers().length>1){var b=this.getLayerAt(a);b&&(this.piskel.removeLayer(b),this.setCurrentLayerIndex(0))}},a.PiskelController.prototype.serialize=function(a){return pskl.utils.Serializer.serializePiskel(this.piskel,a)}}(),function(){var a=$.namespace("pskl.controller.piskel");a.PublicPiskelController=function(a){this.piskelController=a,pskl.utils.wrap(this,this.piskelController)},a.PublicPiskelController.prototype.init=function(){this.resetWrap_("setCurrentFrameIndex"),this.resetWrap_("selectNextFrame"),this.resetWrap_("selectPreviousFrame"),this.resetWrap_("setCurrentLayerIndex"),this.resetWrap_("selectLayer"),this.saveWrap_("renameLayerAt",!1),this.saveWrap_("removeCurrentLayer",!0),this.saveWrap_("addFrame",!0),this.saveWrap_("addFrameAtCurrentIndex",!0),this.saveWrap_("addFrameAt",!0),this.saveWrap_("removeFrameAt",!0),this.saveWrap_("duplicateCurrentFrame",!0),this.saveWrap_("duplicateFrameAt",!0),this.saveWrap_("moveFrame",!0),this.saveWrap_("createLayer",!0),this.saveWrap_("mergeDownLayerAt",!0),this.saveWrap_("moveLayerUp",!0),this.saveWrap_("moveLayerDown",!0),this.saveWrap_("removeCurrentLayer",!0),pskl.app.shortcutService.addShortcut("up",this.selectPreviousFrame.bind(this)),pskl.app.shortcutService.addShortcut("down",this.selectNextFrame.bind(this)),pskl.app.shortcutService.addShortcut("n",this.addFrameAtCurrentIndex.bind(this)),pskl.app.shortcutService.addShortcut("shift+n",this.duplicateCurrentFrame.bind(this))},a.PublicPiskelController.prototype.setPiskel=function(a,b){this.piskelController.setPiskel(a,b),$.publish(Events.FRAME_SIZE_CHANGED),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})},a.PublicPiskelController.prototype.resetWrap_=function(a){this[a]=function(){this.piskelController[a].apply(this.piskelController,arguments),$.publish(Events.PISKEL_RESET)}},a.PublicPiskelController.prototype.saveWrap_=function(a,b){this[a]=b?function(){var b=this.getStateInfo_();this.piskelController[a].apply(this.piskelController,arguments),this.raiseSaveStateEvent_(this.piskelController[a],arguments,b),$.publish(Events.PISKEL_RESET)}:function(){var b=this.getStateInfo_();this.piskelController[a].apply(this.piskelController,arguments),this.raiseSaveStateEvent_(this.piskelController[a],arguments,b)}},a.PublicPiskelController.prototype.getStateInfo_=function(){var a={frameIndex:this.piskelController.currentFrameIndex,layerIndex:this.piskelController.currentLayerIndex};return a},a.PublicPiskelController.prototype.raiseSaveStateEvent_=function(a,b,c){$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:{fn:a,args:b},state:c})},a.PublicPiskelController.prototype.setSavePath=function(a){this.piskelController.piskel.savePath=a},a.PublicPiskelController.prototype.getSavePath=function(){return this.piskelController.piskel.savePath},a.PublicPiskelController.prototype.replay=function(a,b){b.fn.apply(this.piskelController,b.args)}}(),function(){var a=$.namespace("pskl.controller");a.CursorCoordinatesController=function(a){this.piskelController=a,this.origin=null,this.coordinates={x:-1,y:-1}},a.CursorCoordinatesController.prototype.init=function(){this.coordinatesContainer=document.querySelector(".cursor-coordinates"),$.subscribe(Events.CURSOR_MOVED,this.onCursorMoved_.bind(this)),$.subscribe(Events.DRAG_START,this.onDragStart_.bind(this)),$.subscribe(Events.DRAG_END,this.onDragEnd_.bind(this)),$.subscribe(Events.FRAME_SIZE_CHANGED,this.redraw.bind(this)),this.redraw()},a.CursorCoordinatesController.prototype.redraw=function(){var a="";this.origin&&(a+=this.origin.x+":"+this.origin.y+" to ");var b=this.coordinates.x,c=this.coordinates.y,d=this.piskelController.getCurrentFrame();if(d.containsPixel(b,c)&&(a+=b+":"+c,this.origin)){var e=Math.abs(b-this.origin.x)+1,f=Math.abs(c-this.origin.y)+1;a+=" ("+e+"x"+f+")"}this.coordinatesContainer.innerHTML=this.getFrameSizeHTML_()+a},a.CursorCoordinatesController.prototype.getFrameSizeHTML_=function(){var a=this.piskelController.getWidth(),b=this.piskelController.getHeight();return"["+a+"x"+b+"] "},a.CursorCoordinatesController.prototype.onCursorMoved_=function(a,b,c){this.coordinates={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragStart_=function(a,b,c){this.origin={x:b,y:c},this.redraw()},a.CursorCoordinatesController.prototype.onDragEnd_=function(a,b,c){this.origin=null,this.redraw()}}(),function(){var a=$.namespace("pskl.controller");a.DrawingController=function(b,c,d){this.piskelController=b,this.paletteController=c,this.dragHandler=new a.drawing.DragHandler(this),this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(b.getCurrentFrame()),this.container=d;var e={zoom:this.calculateZoom_(),supportGridRendering:!0,height:this.getContainerHeight_(),width:this.getContainerWidth_(),xOffset:0,yOffset:0};this.overlayRenderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,e,["canvas-overlay"]),this.renderer=new pskl.rendering.frame.CachedFrameRenderer(this.container,e,["drawing-canvas"]),this.onionSkinRenderer=pskl.rendering.OnionSkinRenderer.createInContainer(this.container,e,b),this.layersRenderer=new pskl.rendering.layer.LayersRenderer(this.container,e,b),this.compositeRenderer=new pskl.rendering.CompositeRenderer,this.compositeRenderer.add(this.overlayRenderer).add(this.renderer).add(this.layersRenderer).add(this.onionSkinRenderer),this.isClicked=!1,this.previousMousemoveTime=0,this.currentToolBehavior=null,this.currentMouseButton_=Constants.LEFT_BUTTON},a.DrawingController.prototype.init=function(){this.initMouseBehavior(),$.subscribe(Events.TOOL_SELECTED,$.proxy(function(a,b){this.currentToolBehavior=b,this.overlayFrame.clear()},this)),$(window).resize($.proxy(this.startResizeTimer_,this)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this)),$.subscribe(Events.FRAME_SIZE_CHANGED,this.onFrameSizeChange_.bind(this)),$.subscribe(Events.SET_OVERLAY_OPACITY,this.onSetOverlayOpacity_.bind(this)),pskl.app.shortcutService.addShortcut("0",this.resetZoom_.bind(this)),pskl.app.shortcutService.addShortcut("+",this.increaseZoom_.bind(this,1)),pskl.app.shortcutService.addShortcut("-",this.decreaseZoom_.bind(this,1)),window.setTimeout(function(){this.afterWindowResize_(),this.resetZoom_()}.bind(this),100)},a.DrawingController.prototype.initMouseBehavior=function(){var a=$("body");this.container.mousedown($.proxy(this.onMousedown_,this)),pskl.utils.UserAgent.isChrome||pskl.utils.UserAgent.isIE11?this.container.on("mousewheel",$.proxy(this.onMousewheel_,this)):this.container.on("wheel",$.proxy(this.onMousewheel_,this)),window.addEventListener("mouseup",this.onMouseup_.bind(this)),window.addEventListener("mousemove",this.onMousemove_.bind(this)),window.addEventListener("keyup",this.onKeyup_.bind(this)),a.contextmenu(this.onCanvasContextMenu_)},a.DrawingController.prototype.startResizeTimer_=function(){this.resizeTimer&&window.clearInterval(this.resizeTimer),this.resizeTimer=window.setTimeout($.proxy(this.afterWindowResize_,this),200)},a.DrawingController.prototype.afterWindowResize_=function(){var a=this.compositeRenderer.getDisplaySize().width;this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getContainerHeight_()),this.centerColumnWrapperHorizontally_();var b=this.compositeRenderer.getDisplaySize().width/a,c=b*this.compositeRenderer.getZoom();this.compositeRenderer.setZoom(c),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.SHOW_GRID?console.warn("DrawingController:onUserSettingsChange_ not implemented !"):(b==pskl.UserSettings.ONION_SKIN||b==pskl.UserSettings.LAYER_PREVIEW)&&(this.onionSkinRenderer.clear(),this.onionSkinRenderer.flush(),this.layersRenderer.clear(),this.layersRenderer.flush(),this.render())},a.DrawingController.prototype.onFrameSizeChange_=function(){this.compositeRenderer.setDisplaySize(this.getContainerWidth_(),this.getContainerHeight_()),this.centerColumnWrapperHorizontally_(),this.compositeRenderer.setZoom(this.calculateZoom_()),this.compositeRenderer.setOffset(0,0),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.onSetOverlayOpacity_=function(a,b){this.overlayRenderer.setCanvasOpacity(b)},a.DrawingController.prototype.onMousedown_=function(a){$.publish(Events.MOUSE_EVENT,[a,this]);var b=this.piskelController.getCurrentFrame(),c=this.getSpriteCoordinates(a.clientX,a.clientY);this.isClicked=!0,this.setCurrentButton(a),a.button===Constants.MIDDLE_BUTTON?this.dragHandler.startDrag(a.clientX,a.clientY):(this.currentToolBehavior.hideHighlightedPixel(this.overlayFrame),$.publish(Events.TOOL_PRESSED),this.currentToolBehavior.applyToolAt(c.x,c.y,this.getCurrentColor_(),b,this.overlayFrame,a))},a.DrawingController.prototype.onMousemove_=function(a){this._clientX=a.clientX,this._clientY=a.clientY;var b=(new Date).getTime();b-this.previousMousemoveTime>Constants.MOUSEMOVE_THROTTLING&&(this.moveTool_(this._clientX,this._clientY,a),this.previousMousemoveTime=b)},a.DrawingController.prototype.onKeyup_=function(a){this.moveTool_(this._clientX,this._clientY,a)},a.DrawingController.prototype.moveTool_=function(a,b,c){var d=this.getSpriteCoordinates(a,b),e=this.piskelController.getCurrentFrame();this.isClicked?this.currentMouseButton_==Constants.MIDDLE_BUTTON?this.dragHandler.updateDrag(a,b):($.publish(Events.MOUSE_EVENT,[c,this]),this.currentToolBehavior.moveToolAt(0|d.x,0|d.y,this.getCurrentColor_(),e,this.overlayFrame,c)):this.currentToolBehavior.moveUnactiveToolAt(d.x,d.y,this.getCurrentColor_(),e,this.overlayFrame,c),$.publish(Events.CURSOR_MOVED,[d.x,d.y])},a.DrawingController.prototype.onMousewheel_=function(a){var b,c=a.originalEvent;pskl.utils.UserAgent.isChrome?b=c.wheelDeltaY:pskl.utils.UserAgent.isIE11?b=c.wheelDelta:pskl.utils.UserAgent.isFirefox&&(b=-40*c.deltaY);var d=Math.abs(b/120);(pskl.utils.UserAgent.isMac?c.metaKey:c.ctrlKey)&&(d=5*d,c.preventDefault()),b>0?this.increaseZoom_(d):0>b&&this.decreaseZoom_(d)},a.DrawingController.prototype.increaseZoom_=function(a){var b=(a||1)*this.getZoomStep_();this.setZoom_(this.renderer.getZoom()+b)},a.DrawingController.prototype.decreaseZoom_=function(a){var b=(a||1)*this.getZoomStep_();this.setZoom_(this.renderer.getZoom()-b)},a.DrawingController.prototype.onMouseup_=function(a){var b=this.piskelController.getCurrentFrame(),c=this.getSpriteCoordinates(a.clientX,a.clientY);this.isClicked&&($.publish(Events.MOUSE_EVENT,[a,this]),this.isClicked=!1,this.setCurrentButton(a),a.button===Constants.MIDDLE_BUTTON?this.dragHandler.isDragging()?this.dragHandler.stopDrag():b.containsPixel(c.x,c.y)&&$.publish(Events.SELECT_PRIMARY_COLOR,[b.getPixel(c.x,c.y)]):(this.currentToolBehavior.releaseToolAt(c.x,c.y,this.getCurrentColor_(),this.piskelController.getCurrentFrame(),this.overlayFrame,a),$.publish(Events.TOOL_RELEASED)))},a.DrawingController.prototype.getSpriteCoordinates=function(a,b){return this.renderer.getCoordinates(a,b)},a.DrawingController.prototype.getScreenCoordinates=function(a,b){return this.renderer.reverseCoordinates(a,b)},a.DrawingController.prototype.setCurrentButton=function(a){this.currentMouseButton_=a.button},a.DrawingController.prototype.getCurrentColor_=function(){return this.currentMouseButton_==Constants.RIGHT_BUTTON?this.paletteController.getSecondaryColor():this.currentMouseButton_==Constants.LEFT_BUTTON?this.paletteController.getPrimaryColor():Constants.DEFAULT_PEN_COLOR},a.DrawingController.prototype.onCanvasContextMenu_=function(a){return $(a.target).closest("#drawing-canvas-container").length?(a.preventDefault(),a.stopPropagation(),a.cancelBubble=!0,!1):void 0},a.DrawingController.prototype.render=function(){var a=this.piskelController.getCurrentFrame();a.isSameSize(this.overlayFrame)||(this.overlayFrame=pskl.model.Frame.createEmptyFromFrame(a)),pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN)&&this.onionSkinRenderer.render(),pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW)&&this.layersRenderer.render(),this.renderer.render(a),this.overlayRenderer.render(this.overlayFrame)},a.DrawingController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame().getHeight(),b=this.piskelController.getCurrentFrame().getWidth();return Math.min(this.getAvailableWidth_()/b,this.getAvailableHeight_()/a)},a.DrawingController.prototype.getAvailableHeight_=function(){return $("#main-wrapper").height()},a.DrawingController.prototype.getAvailableWidth_=function(){var a=$(".left-column").outerWidth(!0),b=$(".right-column").outerWidth(!0),c=$("#tool-section").outerWidth(!0),d=$("#application-action-section").outerWidth(!0),e=a+b+c+d,f=$("#main-wrapper").width()-e,g=10;return f-g},a.DrawingController.prototype.getContainerHeight_=function(){return this.getAvailableHeight_()},a.DrawingController.prototype.getContainerWidth_=function(){return this.getAvailableWidth_()},a.DrawingController.prototype.centerColumnWrapperHorizontally_=function(){var a=this.getContainerHeight_(),b=Math.floor(($("#main-wrapper").height()-a)/2);$("#column-wrapper").css({top:b+"px"})},a.DrawingController.prototype.getRenderer=function(){return this.compositeRenderer},a.DrawingController.prototype.getOffset=function(){return this.compositeRenderer.getOffset()},a.DrawingController.prototype.setOffset=function(a,b){this.compositeRenderer.setOffset(a,b),$.publish(Events.ZOOM_CHANGED)},a.DrawingController.prototype.resetZoom_=function(){this.setZoom_(this.calculateZoom_())},a.DrawingController.prototype.getZoomStep_=function(){return Math.max(.1,this.renderer.getZoom()/15)},a.DrawingController.prototype.setZoom_=function(a){this.compositeRenderer.setZoom(a),$.publish(Events.ZOOM_CHANGED)}}(),function(){var a=$.namespace("pskl.controller.drawing"),b=2;a.DragHandler=function(a){this.drawingController=a,this.isDragging_=!1,this.updateOrigin_(-1,-1)},a.DragHandler.prototype.startDrag=function(a,b){var c=this.drawingController.getSpriteCoordinates(a,b);this.updateOrigin_(c.x,c.y)},a.DragHandler.prototype.updateDrag=function(a,b){var c=this.drawingController.getOffset(),d=this.calculateOffset_(a,b);if(c.y!==d.y||c.x!==d.x){this.isDragging_=!0,this.drawingController.setOffset(d.x,d.y);var e=this.drawingController.getSpriteCoordinates(a,b);this.updateOrigin_(e.x,e.y)}},a.DragHandler.prototype.stopDrag=function(){this.isDragging_=!1,this.origin=null},a.DragHandler.prototype.isDragging=function(){return this.isDragging_},a.DragHandler.prototype.calculateOffset_=function(a,c){var d=this.drawingController.getSpriteCoordinates(a,c),e=this.drawingController.getOffset(),f={x:e.x-b*(d.x-this.origin.x),y:e.y-b*(d.y-this.origin.y)};return f},a.DragHandler.prototype.updateOrigin_=function(a,b){this.origin=this.origin||{},this.origin.x=a,this.origin.y=b}}(),function(){var a=$.namespace("pskl.controller"),b={SELECT:"select",CLONE:"clone",DELETE:"delete",NEW_FRAME:"newframe"};a.FramesListController=function(a,b){this.piskelController=a,this.container=b,this.refreshZoom_(),this.redrawFlag=!0,this.cachedFrameProcessor=new pskl.model.frame.CachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.frameToPreviewCanvas_.bind(this)),this.cachedFrameProcessor.setOutputCloner(this.clonePreviewCanvas_.bind(this))},a.FramesListController.prototype.init=function(){$.subscribe(Events.TOOL_RELEASED,this.flagForRedraw_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.flagForRedraw_.bind(this)),$.subscribe(Events.USER_SETTINGS_CHANGED,this.flagForRedraw_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.refreshZoom_.bind(this)),$("#preview-list-scroller").scroll(this.updateScrollerOverflows.bind(this)),this.container.get(0).addEventListener("click",this.onContainerClick_.bind(this)),this.updateScrollerOverflows()},a.FramesListController.prototype.flagForRedraw_=function(){this.redrawFlag=!0},a.FramesListController.prototype.refreshZoom_=function(){this.zoom=this.calculateZoom_()},a.FramesListController.prototype.render=function(){this.redrawFlag&&(this.createPreviews_(),this.redrawFlag=!1)},a.FramesListController.prototype.updateScrollerOverflows=function(){var a=$("#preview-list-scroller"),b=a.height(),c=a.scrollTop(),d=$("#preview-list").height(),e=$(".top-overflow").height(),f=!1,g=!1;if(d>b){c>e&&(f=!0);var h=d-c-b;h>e&&(g=!0)}var i=$("#preview-list-wrapper");i.toggleClass("top-overflow-visible",f),i.toggleClass("bottom-overflow-visible",g)},a.FramesListController.prototype.onContainerClick_=function(a){var c=pskl.utils.Dom.getParentWithData(a.target,"tileAction");if(c){var d=c.dataset.tileAction,e=parseInt(c.dataset.tileNumber,10);d===b.CLONE?(this.piskelController.duplicateFrameAt(e),this.updateScrollerOverflows()):d===b.DELETE?(this.piskelController.removeFrameAt(e),this.updateScrollerOverflows()):d===b.SELECT?this.piskelController.setCurrentFrameIndex(e):d===b.NEW_FRAME&&(this.piskelController.addFrame(),this.updateScrollerOverflows())}},a.FramesListController.prototype.createPreviews_=function(){this.container.html(""),$(".tooltip").remove();for(var a=this.piskelController.getFrameCount(),c=0;a>c;c++)this.container.append(this.createPreviewTile_(c));var d=document.createElement("div");d.id="add-frame-action",d.className="add-frame-action",d.setAttribute("data-tile-action",b.NEW_FRAME),d.innerHTML='

Add new frame

',this.container.append(d);var e=a>1;e&&this.initDragndropBehavior_(),this.updateScrollerOverflows()},a.FramesListController.prototype.initDragndropBehavior_=function(){$("#preview-list").sortable({placeholder:"preview-tile-drop-proxy",update:$.proxy(this.onUpdate_,this),items:".preview-tile"}),$("#preview-list").disableSelection()},a.FramesListController.prototype.onUpdate_=function(a,b){var c=parseInt(b.item.data("tile-number"),10),d=$(".preview-tile").index(b.item);this.piskelController.moveFrame(c,d),this.piskelController.setCurrentFrameIndex(d)},a.FramesListController.prototype.createPreviewTile_=function(a){var c=this.piskelController.getCurrentLayer().getFrameAt(a),d=document.createElement("li");d.setAttribute("data-tile-number",a),d.setAttribute("data-tile-action",b.SELECT),d.classList.add("preview-tile"),this.piskelController.getCurrentFrame()==c&&d.classList.add("selected");var e=document.createElement("div");e.classList.add("canvas-container",pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND));var f=this.zoom*this.piskelController.getCurrentFrame().getHeight(),g=(Constants.PREVIEW_FILM_SIZE-f)/2;e.style.marginTop=g+"px";var h=this.zoom*this.piskelController.getCurrentFrame().getWidth(),i=(Constants.PREVIEW_FILM_SIZE-h)/2;e.style.marginLeft=i+"px",e.style.marginRight=i+"px";var j=document.createElement("div");j.className="canvas-background",e.appendChild(j);var k=document.createElement("button");if(k.setAttribute("rel","tooltip"),k.setAttribute("data-placement","right"),k.setAttribute("data-tile-number",a),k.setAttribute("data-tile-action",b.CLONE),k.setAttribute("title","Duplicate this frame"),k.className="tile-overlay duplicate-frame-action",d.appendChild(k),e.appendChild(this.getCanvasForFrame(c)),d.appendChild(e),a>0||this.piskelController.getFrameCount()>1){var l=document.createElement("button");l.setAttribute("rel","tooltip"),l.setAttribute("data-placement","right"),l.setAttribute("title","Delete this frame"),l.setAttribute("data-tile-number",a),l.setAttribute("data-tile-action",b.DELETE),l.className="tile-overlay delete-frame-action",d.appendChild(l);var m=document.createElement("div");m.className="tile-overlay dnd-action",d.appendChild(m)}var n=document.createElement("div");return n.className="tile-overlay tile-count",n.innerHTML=a+1,d.appendChild(n),d},a.FramesListController.prototype.getCanvasForFrame=function(a){var b=this.cachedFrameProcessor.get(a,this.zoom);return b},a.FramesListController.prototype.frameToPreviewCanvas_=function(a){var b=new pskl.rendering.CanvasRenderer(a,this.zoom);b.drawTransparentAs(Constants.TRANSPARENT_COLOR);var c=b.render();return c.classList.add("tile-view","canvas"),c},a.FramesListController.prototype.clonePreviewCanvas_=function(a){var b=pskl.utils.CanvasUtils.clone(a);return b.classList.add("tile-view","canvas"),b},a.FramesListController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame(),b=Math.max(a.getHeight(),a.getWidth());return Constants.PREVIEW_FILM_SIZE/b}}(),function(){var a=$.namespace("pskl.controller");a.LayersListController=function(a){this.piskelController=a},a.LayersListController.prototype.init=function(){this.layerItemTemplate_=pskl.utils.Template.get("layer-item-template"),this.rootEl=document.querySelector(".layers-list-container"),this.layersListEl=document.querySelector(".layers-list"),this.toggleLayerPreviewEl=document.querySelector(".layers-toggle-preview"),this.rootEl.addEventListener("click",this.onClick_.bind(this)),this.toggleLayerPreviewEl.addEventListener("click",this.toggleLayerPreview_.bind(this)),$.subscribe(Events.PISKEL_RESET,this.renderLayerList_.bind(this)),pskl.app.shortcutService.addShortcut("alt+L",this.toggleLayerPreview_.bind(this)),this.renderLayerList_(), +this.updateToggleLayerPreview_(),$.subscribe(Events.USER_SETTINGS_CHANGED,$.proxy(this.onUserSettingsChange_,this))},a.LayersListController.prototype.renderLayerList_=function(){this.layersListEl.innerHTML="";var a=this.piskelController.getLayers();a.forEach(this.addLayerItem.bind(this)),this.updateButtonStatus_()},a.LayersListController.prototype.updateButtonStatus_=function(){var a=this.piskelController.getLayers(),b=(this.piskelController.getCurrentLayer(),this.piskelController.getCurrentLayerIndex()),c=0===b,d=1===a.length,e=b===a.length-1;this.toggleButtonDisabledState_("up",e),this.toggleButtonDisabledState_("down",c),this.toggleButtonDisabledState_("merge",c),this.toggleButtonDisabledState_("delete",d)},a.LayersListController.prototype.toggleButtonDisabledState_=function(a,b){var c=document.querySelector('.layers-button[data-action="'+a+'"]');b?c.setAttribute("disabled","disabled"):c.removeAttribute("disabled")},a.LayersListController.prototype.updateToggleLayerPreview_=function(){var a="layers-toggle-preview-enabled";pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW)?this.toggleLayerPreviewEl.classList.add(a):this.toggleLayerPreviewEl.classList.remove(a)},a.LayersListController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.LAYER_PREVIEW&&this.updateToggleLayerPreview_()},a.LayersListController.prototype.addLayerItem=function(a,b){var c=this.piskelController.getCurrentLayer()===a,d=pskl.utils.Template.replace(this.layerItemTemplate_,{layername:a.getName(),layerindex:b,"isselected:current-layer-item":c}),e=pskl.utils.Template.createFromHTML(d);this.layersListEl.insertBefore(e,this.layersListEl.firstChild)},a.LayersListController.prototype.onClick_=function(a){var b,c=a.target||a.srcElement;c.classList.contains("button")?this.onButtonClick_(c):c.classList.contains("layer-item")&&(b=c.dataset.layerIndex,this.piskelController.setCurrentLayerIndex(parseInt(b,10)))},a.LayersListController.prototype.renameCurrentLayer_=function(){var a=this.piskelController.getCurrentLayer(),b=window.prompt("Please enter the layer name",a.getName());if(b){var c=this.piskelController.getCurrentLayerIndex();this.piskelController.renameLayerAt(c,b),this.renderLayerList_()}},a.LayersListController.prototype.mergeDownCurrentLayer_=function(){var a=this.piskelController.getCurrentLayerIndex();this.piskelController.mergeDownLayerAt(a),this.renderLayerList_()},a.LayersListController.prototype.onButtonClick_=function(a){var b=a.getAttribute("data-action");"up"==b?this.piskelController.moveLayerUp():"down"==b?this.piskelController.moveLayerDown():"add"==b?this.piskelController.createLayer():"delete"==b?this.piskelController.removeCurrentLayer():"merge"==b?this.mergeDownCurrentLayer_():"edit"==b&&this.renameCurrentLayer_()},a.LayersListController.prototype.toggleLayerPreview_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.LAYER_PREVIEW),b=pskl.UserSettings.get(pskl.UserSettings.LAYER_OPACITY),c=!a;pskl.UserSettings.set(pskl.UserSettings.LAYER_PREVIEW,c),c&&0===b&&pskl.UserSettings.set(pskl.UserSettings.LAYER_OPACITY,Constants.DEFAULT.LAYER_OPACITY)}}(),function(){var a=$.namespace("pskl.controller.preview"),b="Piskel - preview";a.PopupPreviewController=function(a){this.piskelController=a,this.popup=null,this.renderer=null,this.renderFlag=!1},a.PopupPreviewController.prototype.init=function(){pskl.utils.Event.addEventListener(window,"unload",this.onMainWindowUnload_,this)},a.PopupPreviewController.prototype.isOpen=function(){return!!this.popup},a.PopupPreviewController.prototype.open=function(){this.isOpen()?this.popup.focus():(this.popup=window.open("about:blank","","width=320,height=320"),window.setTimeout(this.onPopupLoaded.bind(this),500))},a.PopupPreviewController.prototype.onPopupLoaded=function(){this.popup.document.title=b,this.popup.document.body.innerHTML=pskl.utils.Template.get("popup-preview-partial"),pskl.utils.Event.addEventListener(this.popup,"resize",this.onWindowResize_,this),pskl.utils.Event.addEventListener(this.popup,"unload",this.onPopupClosed_,this);var a=this.popup.document.querySelector(".preview-container");this.renderer=new pskl.rendering.frame.BackgroundImageFrameRenderer($(a)),this.updateZoom_(),this.renderFlag=!0},a.PopupPreviewController.prototype.render=function(a){this.isOpen()&&this.renderer&&(this.renderer.render(a),this.renderFlag=!1)},a.PopupPreviewController.prototype.onWindowResize_=function(a){this.updateZoom_(),this.renderFlag=!0},a.PopupPreviewController.prototype.updateZoom_=function(){var a=this.popup.document.documentElement,b=a.clientWidth/this.piskelController.getWidth(),c=a.clientHeight/this.piskelController.getHeight(),d=Math.min(b,c);this.renderer.setZoom(d);var e=this.piskelController.getHeight()*d,f=this.piskelController.getWidth()*d,g=this.popup.document.querySelector(".preview-container");g.style.height=e+"px",g.style.width=f+"px";var h=(a.clientHeight-e)/2;g.style.marginTop=h+"px",g.style.marginBottom=h+"px";var i=(a.clientWidth-f)/2;g.style.marginLeft=i+"px",g.style.marginRight=i+"px"},a.PopupPreviewController.prototype.onPopupClosed_=function(){this.popup;this.popup=null},a.PopupPreviewController.prototype.onMainWindowUnload_=function(){this.isOpen()&&this.popup.close()}}(),function(){var a=$.namespace("pskl.controller.preview"),b=200;a.PreviewController=function(b,c){this.piskelController=b,this.container=c,this.elapsedTime=0,this.currentIndex=0,this.renderFlag=!0,this.fpsRangeInput=document.querySelector("#preview-fps"),this.fpsCounterDisplay=document.querySelector("#display-fps"),this.openPopupPreview=document.querySelector(".open-popup-preview-button"),this.originalSizeButton=document.querySelector(".original-size-button"),this.setFPS(Constants.DEFAULT.FPS);this.piskelController.getCurrentFrame();this.renderer=new pskl.rendering.frame.BackgroundImageFrameRenderer(this.container),this.popupPreviewController=new a.PopupPreviewController(b)},a.PreviewController.prototype.init=function(){this.fpsRangeInput.addEventListener("change",this.onFpsRangeInputUpdate_.bind(this)),this.fpsRangeInput.addEventListener("input",this.onFpsRangeInputUpdate_.bind(this)),document.querySelector(".right-column").style.width=Constants.ANIMATED_PREVIEW_WIDTH+"px",this.toggleOnionSkinEl=document.querySelector(".preview-toggle-onion-skin"),this.toggleOnionSkinEl.addEventListener("click",this.toggleOnionSkin_.bind(this)),pskl.utils.Event.addEventListener(this.openPopupPreview,"click",this.onOpenPopupPreviewClick_,this),pskl.utils.Event.addEventListener(this.originalSizeButton,"click",this.onOriginalSizeButtonClick_,this),pskl.app.shortcutService.addShortcut("alt+O",this.toggleOnionSkin_.bind(this)),pskl.app.shortcutService.addShortcut("alt+1",this.onOriginalSizeButtonClick_.bind(this)),$.subscribe(Events.FRAME_SIZE_CHANGED,this.onFrameSizeChange_.bind(this)),$.subscribe(Events.USER_SETTINGS_CHANGED,$.proxy(this.onUserSettingsChange_,this)),$.subscribe(Events.PISKEL_SAVE_STATE,this.setRenderFlag_.bind(this,!0)),$.subscribe(Events.PISKEL_RESET,this.setRenderFlag_.bind(this,!0)),this.popupPreviewController.init(),this.updateZoom_(),this.updateOnionSkinPreview_(),this.updateOriginalSizeButton_(),this.updateMaxFPS_(),this.updateContainerDimensions_()},a.PreviewController.prototype.onOpenPopupPreviewClick_=function(){this.popupPreviewController.open()},a.PreviewController.prototype.onOriginalSizeButtonClick_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.ORIGINAL_SIZE_PREVIEW);pskl.UserSettings.set(pskl.UserSettings.ORIGINAL_SIZE_PREVIEW,!a)},a.PreviewController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.ONION_SKIN?this.updateOnionSkinPreview_():b==pskl.UserSettings.MAX_FPS?this.updateMaxFPS_():(this.updateZoom_(),this.updateOriginalSizeButton_(),this.updateContainerDimensions_())},a.PreviewController.prototype.updateOnionSkinPreview_=function(){var a="preview-toggle-onion-skin-enabled",b=pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN);this.toggleOnionSkinEl.classList.toggle(a,b)},a.PreviewController.prototype.updateOriginalSizeButton_=function(){var a="original-size-button-enabled",b=pskl.UserSettings.get(pskl.UserSettings.ORIGINAL_SIZE_PREVIEW);this.originalSizeButton.classList.toggle(a,b)},a.PreviewController.prototype.updateMaxFPS_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS);this.fpsRangeInput.setAttribute("max",a),this.setFPS(Math.min(this.fps,a))},a.PreviewController.prototype.updateZoom_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.ORIGINAL_SIZE_PREVIEW),b=pskl.UserSettings.get(pskl.UserSettings.TILED_PREVIEW),c=a||b,d=c?1:this.calculateZoom_();this.renderer.setZoom(d),this.setRenderFlag_(!0)},a.PreviewController.prototype.getZoom=function(){return this.calculateZoom_()},a.PreviewController.prototype.getCoordinates=function(a,b){var c=this.container.offset();a-=c.left,b-=c.top;var d=this.getZoom();return{x:Math.floor(a/d),y:Math.floor(b/d)}},a.PreviewController.prototype.onFpsRangeInputUpdate_=function(a){this.setFPS(parseInt(this.fpsRangeInput.value,10)),"change"===a.type&&this.fpsRangeInput.blur()},a.PreviewController.prototype.setFPS=function(a){"number"==typeof a&&(this.fps=a,this.fpsRangeInput.value=0,this.fpsRangeInput.value=this.fps,this.fpsCounterDisplay.innerHTML=this.fps+" FPS")},a.PreviewController.prototype.getFPS=function(){return this.fps},a.PreviewController.prototype.render=function(a){this.elapsedTime+=a;var b=this.getNextIndex_(a);if(this.shoudlRender_()||this.currentIndex!=b){this.currentIndex=b;var c=this.piskelController.getFrameAt(this.currentIndex);this.renderer.render(c),this.renderFlag=!1,this.popupPreviewController.render(c)}},a.PreviewController.prototype.getNextIndex_=function(a){if(0===this.fps)return this.piskelController.getCurrentFrameIndex();var b=Math.floor(this.elapsedTime/(1e3/this.fps));return this.piskelController.hasFrameAt(b)||(this.elapsedTime=0,b=0),b},a.PreviewController.prototype.calculateZoom_=function(){var a=this.piskelController.getCurrentFrame(),c=b/a.getHeight(),d=b/a.getWidth();return Math.min(c,d)},a.PreviewController.prototype.onFrameSizeChange_=function(){this.updateZoom_(),this.updateContainerDimensions_()},a.PreviewController.prototype.updateContainerDimensions_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.TILED_PREVIEW);this.renderer.setRepeated(a);var c,d;if(a)c=b,d=b;else{var e=this.getZoom(),f=this.piskelController.getCurrentFrame();c=f.getHeight()*e,d=f.getWidth()*e}var g=this.container.get(0);g.style.height=c+"px",g.style.width=d+"px";var h=(b-c)/2;g.style.marginTop=h+"px",g.style.marginBottom=h+"px";var i=(b-d)/2;g.style.marginLeft=i+"px",g.style.marginRight=i+"px"},a.PreviewController.prototype.setRenderFlag_=function(a){this.renderFlag=a},a.PreviewController.prototype.shoudlRender_=function(){return this.renderFlag||this.popupPreviewController.renderFlag},a.PreviewController.prototype.toggleOnionSkin_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.ONION_SKIN);pskl.UserSettings.set(pskl.UserSettings.ONION_SKIN,!a)}}(),function(){var a=$.namespace("pskl.controller");a.MinimapController=function(a,b,c,d){this.piskelController=a,this.previewController=b,this.drawingController=c,this.container=d,this.isClicked=!1,this.isVisible=!1},a.MinimapController.prototype.init=function(){this.minimapEl=document.createElement("DIV"),this.minimapEl.className="minimap-crop-frame",this.minimapEl.style.display="none",$(this.container).append(this.minimapEl),$(this.container).mousedown(this.onMinimapMousedown_.bind(this)),$("body").mousemove(this.onMinimapMousemove_.bind(this)),$("body").mouseup(this.onMinimapMouseup_.bind(this)),$.subscribe(Events.ZOOM_CHANGED,$.proxy(this.renderMinimap_,this))},a.MinimapController.prototype.renderMinimap_=function(){var a=this.getVerticalRatio_(),b=this.getHorizontalRatio_();a>1||b>1?this.displayMinimap_():this.hideMinimap_()},a.MinimapController.prototype.displayMinimap_=function(){var a=this.getMinimapSize_(),b=this.getPreviewSize_(),c=this.container.height(),d=this.container.width(),e=this.drawingController.getRenderer().getOffset(),f=(d-Math.max(a.width,b.width))/2,g=e.x*this.previewController.getZoom(),h=f+g,i=(c-Math.max(a.height,b.height))/2,j=e.y*this.previewController.getZoom(),k=i+j;this.minimapEl.style.display="block",this.minimapEl.style.width=Math.min(a.width,d)+"px",this.minimapEl.style.height=Math.min(a.height,c)+"px",this.minimapEl.style.left=Math.max(0,h)+"px",this.minimapEl.style.top=Math.max(0,k)+"px",this.isVisible=!0},a.MinimapController.prototype.getMinimapSize_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.previewController.getZoom(),c=a/b,d=this.drawingController.getRenderer().getDisplaySize(),e=d.width/c,f=d.height/c;return{width:e,height:f}},a.MinimapController.prototype.getPreviewSize_=function(){var a=this.piskelController.getCurrentFrame(),b=a.getWidth()*this.previewController.getZoom(),c=a.getHeight()*this.previewController.getZoom();return{width:b,height:c}},a.MinimapController.prototype.hideMinimap_=function(){this.minimapEl.style.display="none",this.isVisible=!1},a.MinimapController.prototype.onMinimapMousemove_=function(a){if(this.isVisible&&this.isClicked){var b=this.getCoordinatesCenteredAround_(a.clientX,a.clientY);this.drawingController.setOffset(b.x,b.y)}},a.MinimapController.prototype.onMinimapMousedown_=function(a){this.isClicked=!0},a.MinimapController.prototype.onMinimapMouseup_=function(a){this.isClicked=!1},a.MinimapController.prototype.getCoordinatesCenteredAround_=function(a,b){var c=this.previewController.getCoordinates(a,b),d=this.piskelController.getCurrentFrame().getWidth(),e=this.piskelController.getCurrentFrame().getHeight(),f=d/this.getHorizontalRatio_(),g=e/this.getVerticalRatio_();return{x:c.x-f/2,y:c.y-g/2}},a.MinimapController.prototype.getVerticalRatio_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.piskelController.getCurrentFrame(),c=b.getHeight()*a,d=this.drawingController.getRenderer().getDisplaySize().height;return c/d},a.MinimapController.prototype.getHorizontalRatio_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.piskelController.getCurrentFrame(),c=b.getWidth()*a,d=this.drawingController.getRenderer().getDisplaySize().width;return c/d}}(),function(){var a=$.namespace("pskl.controller");a.ToolController=function(){var a=function(a,b,c){return{id:a,shortcut:b,instance:c}};this.tools=[a("simplePen","P",new pskl.tools.drawing.SimplePen),a("verticalMirrorPen","V",new pskl.tools.drawing.VerticalMirrorPen),a("paintBucket","B",new pskl.tools.drawing.PaintBucket),a("colorSwap","A",new pskl.tools.drawing.ColorSwap),a("eraser","E",new pskl.tools.drawing.Eraser),a("stroke","L",new pskl.tools.drawing.Stroke),a("rectangle","R",new pskl.tools.drawing.Rectangle),a("circle","C",new pskl.tools.drawing.Circle),a("move","M",new pskl.tools.drawing.Move),a("rectangleSelect","S",new pskl.tools.drawing.RectangleSelect),a("shapeSelect","Z",new pskl.tools.drawing.ShapeSelect),a("lighten","U",new pskl.tools.drawing.Lighten),a("colorPicker","O",new pskl.tools.drawing.ColorPicker)],this.toolIconRenderer=new pskl.tools.IconMarkupRenderer},a.ToolController.prototype.init=function(){this.createToolsDom_(),this.addKeyboardShortcuts_(),this.selectTool_(this.tools[0]),$("#tool-section").mousedown($.proxy(this.onToolIconClicked_,this)),$.subscribe(Events.SELECT_TOOL,this.onSelectToolEvent_.bind(this))},a.ToolController.prototype.activateToolOnStage_=function(a){var b=$("body"),c=b.data("selected-tool-class");c&&(b.removeClass(c),b.removeClass(pskl.tools.drawing.Move.TOOL_ID)),b.addClass(a.instance.toolId),b.data("selected-tool-class",a.instance.toolId)},a.ToolController.prototype.onSelectToolEvent_=function(a,b){var c=this.getToolById_(b);c&&this.selectTool_(c)},a.ToolController.prototype.selectTool_=function(a){this.currentSelectedTool=a,this.activateToolOnStage_(this.currentSelectedTool);var b=$("#tool-section .tool-icon.selected"),c=$("[data-tool-id="+a.instance.toolId+"]");b.removeClass("selected"),c.addClass("selected"),$.publish(Events.TOOL_SELECTED,[a.instance])},a.ToolController.prototype.onToolIconClicked_=function(a){var b=$(a.target),c=b.closest(".tool-icon");if(c.length){var d=c.data().toolId,e=this.getToolById_(d);e&&this.selectTool_(e)}},a.ToolController.prototype.onKeyboardShortcut_=function(a){for(var b=0;b","shift+>"],this.selectNextColor_.bind(this)),pskl.app.shortcutService.addShortcut("<",this.selectPreviousColor_.bind(this)),pskl.app.shortcutService.addShortcuts("123465789".split(""),this.selectColorForKey_.bind(this)),this.fillPaletteList(),this.updateFromUserSettings(),this.fillColorListContainer()},a.PalettesListController.prototype.fillPaletteList=function(){var a=this.paletteService.getPalettes(),b=a.map(function(a){return pskl.utils.Template.replace('',a)}).join("");this.colorPaletteSelect_.innerHTML=b},a.PalettesListController.prototype.fillColorListContainer=function(){var a=this.getSelectedPaletteColors_();if(a.length>0){var b=a.map(function(a,b){return pskl.utils.Template.replace(this.paletteColorTemplate_,{color:a,index:b})}.bind(this)).join("");this.colorListContainer_.innerHTML=b,this.highlightSelectedColors();var c=a.length>e;c&&!pskl.utils.UserAgent.isChrome?this.colorListContainer_.classList.add(d):this.colorListContainer_.classList.remove(d)}else this.colorListContainer_.innerHTML=pskl.utils.Template.get("palettes-list-no-colors-partial")},a.PalettesListController.prototype.selectPalette=function(a){pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE,a)},a.PalettesListController.prototype.getSelectedPaletteColors_=function(){var a=[],b=this.getSelectedPalette_();return b&&(a=b.getColors()),a.length>Constants.MAX_PALETTE_COLORS&&(a=a.slice(0,Constants.MAX_PALETTE_COLORS)),a},a.PalettesListController.prototype.getSelectedPalette_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);return this.paletteService.getPaletteById(a)},a.PalettesListController.prototype.selectNextColor_=function(){this.selectColor_(this.getCurrentColorIndex_()+1)},a.PalettesListController.prototype.selectPreviousColor_=function(){this.selectColor_(this.getCurrentColorIndex_()-1)},a.PalettesListController.prototype.getCurrentColorIndex_=function(){var a=0,c=document.querySelector("."+b);return c&&(a=parseInt(c.dataset.colorIndex,10)),a},a.PalettesListController.prototype.selectColorForKey_=function(a){var b=parseInt(a,10);b=(b+9)%10,this.selectColor_(b)},a.PalettesListController.prototype.selectColor_=function(a){var b=this.getSelectedPaletteColors_(),c=b[a];c&&$.publish(Events.SELECT_PRIMARY_COLOR,[c])},a.PalettesListController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.SELECTED_PALETTE&&this.updateFromUserSettings()},a.PalettesListController.prototype.updateFromUserSettings=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);this.fillColorListContainer(),this.colorPaletteSelect_.value=a},a.PalettesListController.prototype.onPaletteSelected_=function(a){var b=this.colorPaletteSelect_.value;this.selectPalette(b),this.colorPaletteSelect_.blur()},a.PalettesListController.prototype.onCreatePaletteClick_=function(a){$.publish(Events.DIALOG_DISPLAY,"create-palette")},a.PalettesListController.prototype.onEditPaletteClick_=function(a){var b=this.colorPaletteSelect_.value;$.publish(Events.DIALOG_DISPLAY,{dialogId:"create-palette",initArgs:b})},a.PalettesListController.prototype.onColorContainerContextMenu=function(a){a.preventDefault()},a.PalettesListController.prototype.onColorContainerMouseup=function(a){var b=a.target,c=b.dataset.color;c&&(a.button==Constants.LEFT_BUTTON?$.publish(Events.SELECT_PRIMARY_COLOR,[c]):a.button==Constants.RIGHT_BUTTON&&$.publish(Events.SELECT_SECONDARY_COLOR,[c]))},a.PalettesListController.prototype.highlightSelectedColors=function(){this.removeClass_(b),this.removeClass_(c);var a=this.getColorContainer_(this.paletteController.getSecondaryColor());a&&(a.classList.remove(b),a.classList.add(c)),a=this.getColorContainer_(this.paletteController.getPrimaryColor()),a&&(a.classList.remove(c),a.classList.add(b))},a.PalettesListController.prototype.getColorContainer_=function(a){return this.colorListContainer_.querySelector('.palettes-list-color[data-color="'+a+'"]')},a.PalettesListController.prototype.removeClass_=function(a){var b=document.querySelector("."+a);b&&b.classList.remove(a)},a.PalettesListController.prototype.onPaletteListUpdated=function(){this.fillPaletteList(),this.updateFromUserSettings()}}(),function(){var a=$.namespace("pskl.controller");a.ProgressBarController=function(){this.template=pskl.utils.Template.get("progress-bar-template"),this.progressBar=null,this.progressBarStatus=null,this.showProgressTimer_=0},a.ProgressBarController.prototype.init=function(){$.subscribe(Events.SHOW_PROGRESS,$.proxy(this.showProgress_,this)),$.subscribe(Events.UPDATE_PROGRESS,$.proxy(this.updateProgress_,this)),$.subscribe(Events.HIDE_PROGRESS,$.proxy(this.hideProgress_,this))},a.ProgressBarController.prototype.showProgress_=function(a,b){this.removeProgressBar_(),this.showProgressTimer_=window.setTimeout(this.onTimerExpired_.bind(this,b),300)},a.ProgressBarController.prototype.onTimerExpired_=function(a){var b=pskl.utils.Template.replace(this.template,{name:a.name,status:0}),c=pskl.utils.Template.createFromHTML(b);document.body.appendChild(c),this.progressBar=document.querySelector(".progress-bar"),this.progressBarStatus=document.querySelector(".progress-bar-status")},a.ProgressBarController.prototype.updateProgress_=function(a,b){if(this.progressBar&&this.progressBarStatus){var c=b.progress,d=this.progressBar.offsetWidth,e=d-c*d/100;this.progressBar.style.backgroundPosition=-e+"px 0",this.progressBarStatus.innerHTML=c+"%"}},a.ProgressBarController.prototype.hideProgress_=function(a,b){this.showProgressTimer_&&window.clearTimeout(this.showProgressTimer_),this.removeProgressBar_()},a.ProgressBarController.prototype.removeProgressBar_=function(){var a=document.querySelector(".progress-bar-container");a&&(a.parentNode.removeChild(a),this.progressBar=null,this.progressBarStatus=null)}}(),function(){var a=$.namespace("pskl.controller");a.NotificationController=function(){},a.NotificationController.prototype.init=function(){$.subscribe(Events.SHOW_NOTIFICATION,$.proxy(this.displayMessage_,this)),$.subscribe(Events.HIDE_NOTIFICATION,$.proxy(this.removeMessage_,this))},a.NotificationController.prototype.displayMessage_=function(a,b){this.removeMessage_();var c=document.createElement("div");c.id="user-message",c.className="user-message",c.innerHTML=b.content,c.innerHTML=c.innerHTML+'
x
',document.body.appendChild(c),c.querySelector(".close").addEventListener("click",this.removeMessage_.bind(this)),b.behavior&&b.behavior(c),b.hideDelay&&window.setTimeout(this.removeMessage_.bind(this),b.hideDelay)},a.NotificationController.prototype.removeMessage_=function(a){var b=$("#user-message");b.length&&b.remove()}}(),function(){var a=$.namespace("pskl.controller");a.TransformationsController=function(){var a=function(a,b,c){return{id:a,shortcut:b,instance:c}};this.tools=[a("flip","",new pskl.tools.transform.Flip),a("rotate","",new pskl.tools.transform.Rotate),a("clone","",new pskl.tools.transform.Clone)],this.toolIconRenderer=new pskl.tools.IconMarkupRenderer},a.TransformationsController.prototype.init=function(){var a=document.querySelector(".transformations-container");this.toolsContainer=a.querySelector(".tools-wrapper"),a.addEventListener("click",this.onTransformationClick.bind(this)),this.createToolsDom_()},a.TransformationsController.prototype.onTransformationClick=function(a){var b=a.target.dataset.toolId;this.tools.forEach(function(c){c.instance.toolId===b&&c.instance.apply(a)}.bind(this))},a.TransformationsController.prototype.createToolsDom_=function(){var a=this.tools.reduce(function(a,b){return a+this.toolIconRenderer.render(b.instance,b.shortcut,"left")}.bind(this),"");this.toolsContainer.innerHTML=a}}(),function(){var a=$.namespace("pskl.controller");a.CanvasBackgroundController=function(){this.body=document.body},a.CanvasBackgroundController.prototype.init=function(){$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this)),this.updateBackgroundClass_(pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND))},a.CanvasBackgroundController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.CANVAS_BACKGROUND&&this.updateBackgroundClass_(c)},a.CanvasBackgroundController.prototype.updateBackgroundClass_=function(a){var b=this.body.dataset.currentBackgroundClass;b&&this.body.classList.remove(b),this.body.classList.add(a),this.body.dataset.currentBackgroundClass=a}}(),function(){var a=$.namespace("pskl.controller.settings");a.AbstractSettingController=function(){},a.AbstractSettingController.prototype.addEventListener=function(a,b,c){pskl.utils.Event.addEventListener(a,b,c,this)},a.AbstractSettingController.prototype.destroy=function(){pskl.utils.Event.removeAllEventListeners(this),this.nullifyDomReferences_()},a.AbstractSettingController.prototype.nullifyDomReferences_=function(){for(var a in this)if(this.hasOwnProperty(a)){var b=this[a]&&this[a].nodeName;b&&(this[a]=null)}}}(),function(){var a=$.namespace("pskl.controller.settings");a.ApplicationSettingsController=function(){},pskl.utils.inherit(a.ApplicationSettingsController,pskl.controller.settings.AbstractSettingController),a.ApplicationSettingsController.prototype.init=function(){this.backgroundContainer=document.querySelector(".background-picker-wrapper"),this.addEventListener(this.backgroundContainer,"click",this.onBackgroundClick_);var a=pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND),b=this.backgroundContainer.querySelector("[data-background="+a+"]");b&&b.classList.add("selected");var c=pskl.UserSettings.get(pskl.UserSettings.GRID_WIDTH),d=document.querySelector(".grid-width-select"),e=d.querySelector('option[value="'+c+'"]');e&&e.setAttribute("selected","selected"),this.addEventListener(d,"change",this.onGridWidthChange_);var f=pskl.UserSettings.get(pskl.UserSettings.TILED_PREVIEW),g=document.querySelector(".tiled-preview-checkbox");f&&g.setAttribute("checked",f),this.addEventListener(g,"change",this.onTiledPreviewChange_);var h=document.querySelector(".max-fps-input");h.value=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS),this.addEventListener(h,"change",this.onMaxFpsChange_);var i=document.querySelector(".layer-opacity-input");i.value=pskl.UserSettings.get(pskl.UserSettings.LAYER_OPACITY),this.addEventListener(i,"change",this.onLayerOpacityChange_),this.updateLayerOpacityText_(i.value),this.applicationSettingsForm=document.querySelector('[name="application-settings-form"]'),this.addEventListener(this.applicationSettingsForm,"submit",this.onFormSubmit_)},a.ApplicationSettingsController.prototype.onGridWidthChange_=function(a){var b=parseInt(a.target.value,10);pskl.UserSettings.set(pskl.UserSettings.GRID_WIDTH,b)},a.ApplicationSettingsController.prototype.onTiledPreviewChange_=function(a){pskl.UserSettings.set(pskl.UserSettings.TILED_PREVIEW,a.currentTarget.checked)},a.ApplicationSettingsController.prototype.onBackgroundClick_=function(a){ +var b=a.target,c=b.dataset.background;if(c){pskl.UserSettings.set(pskl.UserSettings.CANVAS_BACKGROUND,c);var d=this.backgroundContainer.querySelector(".selected");d&&d.classList.remove("selected"),b.classList.add("selected")}},a.ApplicationSettingsController.prototype.onMaxFpsChange_=function(a){var b=a.target,c=parseInt(b.value,10);c&&!isNaN(c)?pskl.UserSettings.set(pskl.UserSettings.MAX_FPS,c):b.value=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS)},a.ApplicationSettingsController.prototype.onLayerOpacityChange_=function(a){var b=a.target,c=parseFloat(b.value);isNaN(c)?b.value=pskl.UserSettings.get(pskl.UserSettings.LAYER_OPACITY):(pskl.UserSettings.set(pskl.UserSettings.LAYER_OPACITY,c),pskl.UserSettings.set(pskl.UserSettings.LAYER_PREVIEW,0!==c),this.updateLayerOpacityText_(c))},a.ApplicationSettingsController.prototype.updateLayerOpacityText_=function(a){var b=document.querySelector(".layer-opacity-text");b.innerHTML=a},a.ApplicationSettingsController.prototype.onFormSubmit_=function(a){a.preventDefault(),$.publish(Events.CLOSE_SETTINGS_DRAWER)}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage");a.ImageExportController=function(b){this.piskelController=b,this.pngExportController=new a.PngExportController(b),this.gifExportController=new a.GifExportController(b)},a.ImageExportController.prototype.init=function(){this.pngExportController.init(),this.gifExportController.init()},a.ImageExportController.prototype.destroy=function(){this.pngExportController.destroy(),this.gifExportController.destroy()}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage"),b=30,c=256,d=20,e="#FF00FF";a.GifExportController=function(a){this.piskelController=a},pskl.utils.inherit(a.GifExportController,pskl.controller.settings.AbstractSettingController),a.GifExportController.RESOLUTIONS=[];for(var f=1;d>=f;f++)a.GifExportController.RESOLUTIONS.push({zoom:f});a.GifExportController.prototype.init=function(){this.uploadStatusContainerEl=document.querySelector(".gif-upload-status"),this.previewContainerEl=document.querySelector(".gif-export-preview"),this.widthInput=document.querySelector(".export-gif-resize-width"),this.heightInput=document.querySelector(".export-gif-resize-height"),this.uploadButton=document.querySelector(".gif-upload-button"),this.downloadButton=document.querySelector(".gif-download-button"),this.sizeInputWidget=new pskl.widgets.SizeInput(this.widthInput,this.heightInput,this.piskelController.getWidth(),this.piskelController.getHeight()),this.addEventListener(this.uploadButton,"click",this.onUploadButtonClick_),this.addEventListener(this.downloadButton,"click",this.onDownloadButtonClick_)},a.GifExportController.prototype.destroy=function(){this.sizeInputWidget.destroy(),this.superclass.destroy.call(this)},a.GifExportController.prototype.onUploadButtonClick_=function(a){a.preventDefault();var b=this.getZoom_(),c=this.piskelController.getFPS();this.renderAsImageDataAnimatedGIF(b,c,this.uploadImageData_.bind(this))},a.GifExportController.prototype.onDownloadButtonClick_=function(a){var b=this.getZoom_(),c=this.piskelController.getFPS();this.renderAsImageDataAnimatedGIF(b,c,this.downloadImageData_.bind(this))},a.GifExportController.prototype.downloadImageData_=function(a){var b=this.piskelController.getPiskel().getDescriptor().name+".gif";pskl.utils.BlobUtils.dataToBlob(a,"image/gif",function(a){pskl.utils.FileUtils.downloadAsFile(a,b)})},a.GifExportController.prototype.uploadImageData_=function(a){this.updatePreview_(a),this.previewContainerEl.classList.add("preview-upload-ongoing"),pskl.app.imageUploadService.upload(a,this.onImageUploadCompleted_.bind(this),this.onImageUploadFailed_.bind(this))},a.GifExportController.prototype.onImageUploadCompleted_=function(a){this.updatePreview_(a),this.updateStatus_(a),this.previewContainerEl.classList.remove("preview-upload-ongoing")},a.GifExportController.prototype.onImageUploadFailed_=function(a,b){500===b.status&&$.publish(Events.SHOW_NOTIFICATION,[{content:"Upload failed : "+b.responseText,hideDelay:5e3}])},a.GifExportController.prototype.updatePreview_=function(a){this.previewContainerEl.innerHTML='
'},a.GifExportController.prototype.getZoom_=function(){return parseInt(this.widthInput.value,10)/this.piskelController.getWidth()},a.GifExportController.prototype.renderAsImageDataAnimatedGIF=function(a,b,d){for(var e=pskl.app.currentColorsService.getCurrentColors(),f=e.lengthb){var d=Math.round((b-c.length)/2),e=a.substring(0,d),f=a.substring(a.length-d,a.length);a=e+c+f}return a}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage"),b=60;a.PngExportController=function(a){this.piskelController=a},pskl.utils.inherit(a.PngExportController,pskl.controller.settings.AbstractSettingController),a.PngExportController.prototype.init=function(){this.pngFilePrefixInput=document.querySelector(".zip-prefix-name"),this.pngFilePrefixInput.value="sprite_",this.splitByLayersCheckbox=document.querySelector(".zip-split-layers-checkbox");var a=document.querySelector(".png-download-button");this.addEventListener(a,"click",this.onPngDownloadButtonClick_);var b=document.querySelector(".zip-generate-button");this.addEventListener(b,"click",this.onZipButtonClick_)},a.PngExportController.prototype.onPngDownloadButtonClick_=function(a){var b=this.getPiskelName_()+".png";pskl.utils.BlobUtils.canvasToBlob(this.getFramesheetAsCanvas(),function(a){pskl.utils.FileUtils.downloadAsFile(a,b)})},a.PngExportController.prototype.onZipButtonClick_=function(){var a=new window.JSZip;this.splitByLayersCheckbox.checked?this.splittedExport_(a):this.mergedExport_(a);var b=this.getPiskelName_()+".zip",c=a.generate({type:"blob"});pskl.utils.FileUtils.downloadAsFile(c,b)},a.PngExportController.prototype.mergedExport_=function(a){for(var b=0;bb&&(a=a.substring(0,b),a+=c),a}}(),function(){var a=$.namespace("pskl.controller.settings.resize"),b="resize-origin-option";a.AnchorWidget=function(a){this.container=a,this.disabled=!1,pskl.utils.Event.addEventListener(this.container,"click",this.onResizeOriginClick_,this)},a.AnchorWidget.ORIGIN={TOPLEFT:"TOPLEFT",TOP:"TOP",TOPRIGHT:"TOPRIGHT",MIDDLELEFT:"MIDDLELEFT",MIDDLE:"MIDDLE",MIDDLERIGHT:"MIDDLERIGHT",BOTTOMLEFT:"BOTTOMLEFT",BOTTOM:"BOTTOM",BOTTOMRIGHT:"BOTTOMRIGHT"},a.AnchorWidget.prototype.destroy=function(a){pskl.utils.Event.removeAllEventListeners(this),this.container=null},a.AnchorWidget.prototype.onResizeOriginClick_=function(b){var c=b.target.dataset.origin;c&&a.AnchorWidget.ORIGIN[c]&&!this.disabled&&this.setOrigin(c)},a.AnchorWidget.prototype.setOrigin=function(a){this.origin=a;var c=document.querySelector("."+b+".selected");c&&c.classList.remove("selected");var d=document.querySelector("."+b+'[data-origin="'+a+'"]');d&&(d.classList.add("selected"),this.refreshNeighbors_(d))},a.AnchorWidget.prototype.getOrigin=function(){return this.origin},a.AnchorWidget.prototype.disable=function(){this.disabled=!0,this.container.classList.add("transition"),this.container.classList.add("disabled")},a.AnchorWidget.prototype.enable=function(){this.disabled=!1,this.container.classList.remove("disabled"),window.setTimeout(this.container.classList.remove.bind(this.container.classList,"transition"),250)},a.AnchorWidget.prototype.refreshNeighbors_=function(a){for(var c=document.querySelectorAll("."+b),d=0;d1||b>1?this.displayMinimap_():this.hideMinimap_()},a.MinimapController.prototype.displayMinimap_=function(){var a=this.getMinimapSize_(),b=this.getPreviewSize_(),c=this.container.height(),d=this.container.width(),e=this.drawingController.getRenderer().getOffset(),f=(d-Math.max(a.width,b.width))/2,g=e.x*this.previewController.getZoom(),h=f+g,i=(c-Math.max(a.height,b.height))/2,j=e.y*this.previewController.getZoom(),k=i+j;this.minimapEl.style.display="block",this.minimapEl.style.width=Math.min(a.width,d)+"px",this.minimapEl.style.height=Math.min(a.height,c)+"px",this.minimapEl.style.left=Math.max(0,h)+"px",this.minimapEl.style.top=Math.max(0,k)+"px",this.isVisible=!0},a.MinimapController.prototype.getMinimapSize_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.previewController.getZoom(),c=a/b,d=this.drawingController.getRenderer().getDisplaySize(),e=d.width/c,f=d.height/c;return{width:e,height:f}},a.MinimapController.prototype.getPreviewSize_=function(){var a=this.piskelController.getCurrentFrame(),b=a.getWidth()*this.previewController.getZoom(),c=a.getHeight()*this.previewController.getZoom();return{width:b,height:c}},a.MinimapController.prototype.hideMinimap_=function(){this.minimapEl.style.display="none",this.isVisible=!1},a.MinimapController.prototype.onMinimapMousemove_=function(a){if(this.isVisible&&this.isClicked){var b=this.getCoordinatesCenteredAround_(a.clientX,a.clientY);this.drawingController.setOffset(b.x,b.y)}},a.MinimapController.prototype.onMinimapMousedown_=function(a){this.isClicked=!0},a.MinimapController.prototype.onMinimapMouseup_=function(a){this.isClicked=!1},a.MinimapController.prototype.getCoordinatesCenteredAround_=function(a,b){var c=this.previewController.getCoordinates(a,b),d=this.piskelController.getCurrentFrame().getWidth(),e=this.piskelController.getCurrentFrame().getHeight(),f=d/this.getHorizontalRatio_(),g=e/this.getVerticalRatio_();return{x:c.x-f/2,y:c.y-g/2}},a.MinimapController.prototype.getVerticalRatio_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.piskelController.getCurrentFrame(),c=b.getHeight()*a,d=this.drawingController.getRenderer().getDisplaySize().height;return c/d},a.MinimapController.prototype.getHorizontalRatio_=function(){var a=this.drawingController.getRenderer().getZoom(),b=this.piskelController.getCurrentFrame(),c=b.getWidth()*a,d=this.drawingController.getRenderer().getDisplaySize().width;return c/d}}(),function(){var a=$.namespace("pskl.controller");a.ToolController=function(){var a=function(a,b,c){return{id:a,shortcut:b,instance:c}};this.tools=[a("simplePen","P",new pskl.tools.drawing.SimplePen),a("verticalMirrorPen","V",new pskl.tools.drawing.VerticalMirrorPen),a("paintBucket","B",new pskl.tools.drawing.PaintBucket),a("colorSwap","A",new pskl.tools.drawing.ColorSwap),a("eraser","E",new pskl.tools.drawing.Eraser),a("stroke","L",new pskl.tools.drawing.Stroke),a("rectangle","R",new pskl.tools.drawing.Rectangle),a("circle","C",new pskl.tools.drawing.Circle),a("move","M",new pskl.tools.drawing.Move),a("rectangleSelect","S",new pskl.tools.drawing.RectangleSelect),a("shapeSelect","Z",new pskl.tools.drawing.ShapeSelect),a("lighten","U",new pskl.tools.drawing.Lighten),a("colorPicker","O",new pskl.tools.drawing.ColorPicker)],this.toolIconRenderer=new pskl.tools.IconMarkupRenderer},a.ToolController.prototype.init=function(){this.createToolsDom_(),this.addKeyboardShortcuts_(),this.selectTool_(this.tools[0]),$("#tool-section").mousedown($.proxy(this.onToolIconClicked_,this)),$.subscribe(Events.SELECT_TOOL,this.onSelectToolEvent_.bind(this))},a.ToolController.prototype.activateToolOnStage_=function(a){var b=$("body"),c=b.data("selected-tool-class");c&&(b.removeClass(c),b.removeClass(pskl.tools.drawing.Move.TOOL_ID)),b.addClass(a.instance.toolId),b.data("selected-tool-class",a.instance.toolId)},a.ToolController.prototype.onSelectToolEvent_=function(a,b){var c=this.getToolById_(b);c&&this.selectTool_(c)},a.ToolController.prototype.selectTool_=function(a){this.currentSelectedTool=a,this.activateToolOnStage_(this.currentSelectedTool);var b=$("#tool-section .tool-icon.selected"),c=$("[data-tool-id="+a.instance.toolId+"]");b.removeClass("selected"),c.addClass("selected"),$.publish(Events.TOOL_SELECTED,[a.instance])},a.ToolController.prototype.onToolIconClicked_=function(a){var b=$(a.target),c=b.closest(".tool-icon");if(c.length){var d=c.data().toolId,e=this.getToolById_(d);e&&this.selectTool_(e)}},a.ToolController.prototype.onKeyboardShortcut_=function(a){for(var b=0;b","shift+>"],this.selectNextColor_.bind(this)),pskl.app.shortcutService.addShortcut("<",this.selectPreviousColor_.bind(this)),this.fillPaletteList(),this.updateFromUserSettings(),this.fillColorListContainer()},a.PalettesListController.prototype.fillPaletteList=function(){var a=this.paletteService.getPalettes(),b=a.map(function(a){return pskl.utils.Template.replace('',a)}).join("");this.colorPaletteSelect_.innerHTML=b},a.PalettesListController.prototype.fillColorListContainer=function(){var a=this.getSelectedPaletteColors_();if(a.length>0){var b=a.map(function(a,b){return pskl.utils.Template.replace(this.paletteColorTemplate_,{color:a,index:b})}.bind(this)).join("");this.colorListContainer_.innerHTML=b,this.highlightSelectedColors();var c=a.length>e;c&&!pskl.utils.UserAgent.isChrome?this.colorListContainer_.classList.add(d):this.colorListContainer_.classList.remove(d)}else this.colorListContainer_.innerHTML=pskl.utils.Template.get("palettes-list-no-colors-partial")},a.PalettesListController.prototype.selectPalette=function(a){pskl.UserSettings.set(pskl.UserSettings.SELECTED_PALETTE,a)},a.PalettesListController.prototype.getSelectedPaletteColors_=function(){var a=[],b=this.getSelectedPalette_();return b&&(a=b.getColors()),a.length>Constants.MAX_PALETTE_COLORS&&(a=a.slice(0,Constants.MAX_PALETTE_COLORS)),a},a.PalettesListController.prototype.getSelectedPalette_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);return this.paletteService.getPaletteById(a)},a.PalettesListController.prototype.selectNextColor_=function(){this.selectColor_(this.getCurrentColorIndex_()+1)},a.PalettesListController.prototype.selectPreviousColor_=function(){this.selectColor_(this.getCurrentColorIndex_()-1)},a.PalettesListController.prototype.getCurrentColorIndex_=function(){var a=0,c=document.querySelector("."+b);return c&&(a=parseInt(c.dataset.colorIndex,10)),a},a.PalettesListController.prototype.selectColor_=function(a){var b=this.getSelectedPaletteColors_(),c=b[a];c&&$.publish(Events.SELECT_PRIMARY_COLOR,[c])},a.PalettesListController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.SELECTED_PALETTE&&this.updateFromUserSettings()},a.PalettesListController.prototype.updateFromUserSettings=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE);this.fillColorListContainer(),this.colorPaletteSelect_.value=a},a.PalettesListController.prototype.onPaletteSelected_=function(a){var b=this.colorPaletteSelect_.value;this.selectPalette(b),this.colorPaletteSelect_.blur()},a.PalettesListController.prototype.onCreatePaletteClick_=function(a){$.publish(Events.DIALOG_DISPLAY,"create-palette")},a.PalettesListController.prototype.onEditPaletteClick_=function(a){var b=this.colorPaletteSelect_.value;$.publish(Events.DIALOG_DISPLAY,{dialogId:"create-palette",initArgs:b})},a.PalettesListController.prototype.onColorContainerContextMenu=function(a){a.preventDefault()},a.PalettesListController.prototype.onColorContainerMouseup=function(a){var b=a.target,c=b.dataset.color;c&&(a.button==Constants.LEFT_BUTTON?$.publish(Events.SELECT_PRIMARY_COLOR,[c]):a.button==Constants.RIGHT_BUTTON&&$.publish(Events.SELECT_SECONDARY_COLOR,[c]))},a.PalettesListController.prototype.highlightSelectedColors=function(){this.removeClass_(b),this.removeClass_(c);var a=this.getColorContainer_(this.paletteController.getSecondaryColor());a&&(a.classList.remove(b),a.classList.add(c)),a=this.getColorContainer_(this.paletteController.getPrimaryColor()),a&&(a.classList.remove(c),a.classList.add(b))},a.PalettesListController.prototype.getColorContainer_=function(a){return this.colorListContainer_.querySelector('.palettes-list-color[data-color="'+a+'"]')},a.PalettesListController.prototype.removeClass_=function(a){var b=document.querySelector("."+a);b&&b.classList.remove(a)},a.PalettesListController.prototype.onPaletteListUpdated=function(){this.fillPaletteList(),this.updateFromUserSettings()}}(),function(){var a=$.namespace("pskl.controller");a.ProgressBarController=function(){this.template=pskl.utils.Template.get("progress-bar-template"),this.progressBar=null,this.progressBarStatus=null,this.showProgressTimer_=0},a.ProgressBarController.prototype.init=function(){$.subscribe(Events.SHOW_PROGRESS,$.proxy(this.showProgress_,this)),$.subscribe(Events.UPDATE_PROGRESS,$.proxy(this.updateProgress_,this)),$.subscribe(Events.HIDE_PROGRESS,$.proxy(this.hideProgress_,this))},a.ProgressBarController.prototype.showProgress_=function(a,b){this.removeProgressBar_(),this.showProgressTimer_=window.setTimeout(this.onTimerExpired_.bind(this,b),300)},a.ProgressBarController.prototype.onTimerExpired_=function(a){var b=pskl.utils.Template.replace(this.template,{name:a.name,status:0}),c=pskl.utils.Template.createFromHTML(b);document.body.appendChild(c),this.progressBar=document.querySelector(".progress-bar"),this.progressBarStatus=document.querySelector(".progress-bar-status")},a.ProgressBarController.prototype.updateProgress_=function(a,b){if(this.progressBar&&this.progressBarStatus){var c=b.progress,d=this.progressBar.offsetWidth,e=d-c*d/100;this.progressBar.style.backgroundPosition=-e+"px 0",this.progressBarStatus.innerHTML=c+"%"}},a.ProgressBarController.prototype.hideProgress_=function(a,b){this.showProgressTimer_&&window.clearTimeout(this.showProgressTimer_),this.removeProgressBar_()},a.ProgressBarController.prototype.removeProgressBar_=function(){var a=document.querySelector(".progress-bar-container");a&&(a.parentNode.removeChild(a),this.progressBar=null,this.progressBarStatus=null)}}(),function(){var a=$.namespace("pskl.controller");a.NotificationController=function(){},a.NotificationController.prototype.init=function(){$.subscribe(Events.SHOW_NOTIFICATION,$.proxy(this.displayMessage_,this)),$.subscribe(Events.HIDE_NOTIFICATION,$.proxy(this.removeMessage_,this))},a.NotificationController.prototype.displayMessage_=function(a,b){this.removeMessage_();var c=document.createElement("div");c.id="user-message",c.className="user-message",c.innerHTML=b.content,c.innerHTML=c.innerHTML+'
x
',document.body.appendChild(c),c.querySelector(".close").addEventListener("click",this.removeMessage_.bind(this)),b.behavior&&b.behavior(c),b.hideDelay&&window.setTimeout(this.removeMessage_.bind(this),b.hideDelay)},a.NotificationController.prototype.removeMessage_=function(a){var b=$("#user-message");b.length&&b.remove()}}(),function(){var a=$.namespace("pskl.controller");a.TransformationsController=function(){var a=function(a,b,c){return{id:a,shortcut:b,instance:c}};this.tools=[a("flip","",new pskl.tools.transform.Flip),a("rotate","",new pskl.tools.transform.Rotate),a("clone","",new pskl.tools.transform.Clone)],this.toolIconRenderer=new pskl.tools.IconMarkupRenderer},a.TransformationsController.prototype.init=function(){var a=document.querySelector(".transformations-container");this.toolsContainer=a.querySelector(".tools-wrapper"),a.addEventListener("click",this.onTransformationClick.bind(this)),this.createToolsDom_()},a.TransformationsController.prototype.onTransformationClick=function(a){var b=a.target.dataset.toolId;this.tools.forEach(function(c){c.instance.toolId===b&&c.instance.apply(a)}.bind(this))},a.TransformationsController.prototype.createToolsDom_=function(){var a=this.tools.reduce(function(a,b){return a+this.toolIconRenderer.render(b.instance,b.shortcut,"left")}.bind(this),"");this.toolsContainer.innerHTML=a}}(),function(){var a=$.namespace("pskl.controller");a.CanvasBackgroundController=function(){this.body=document.body},a.CanvasBackgroundController.prototype.init=function(){$.subscribe(Events.USER_SETTINGS_CHANGED,this.onUserSettingsChange_.bind(this)),this.updateBackgroundClass_(pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND))},a.CanvasBackgroundController.prototype.onUserSettingsChange_=function(a,b,c){b==pskl.UserSettings.CANVAS_BACKGROUND&&this.updateBackgroundClass_(c)},a.CanvasBackgroundController.prototype.updateBackgroundClass_=function(a){var b=this.body.dataset.currentBackgroundClass;b&&this.body.classList.remove(b),this.body.classList.add(a),this.body.dataset.currentBackgroundClass=a}}(),function(){var a=$.namespace("pskl.controller.settings");a.AbstractSettingController=function(){},a.AbstractSettingController.prototype.addEventListener=function(a,b,c){pskl.utils.Event.addEventListener(a,b,c,this)},a.AbstractSettingController.prototype.destroy=function(){pskl.utils.Event.removeAllEventListeners(this),this.nullifyDomReferences_()},a.AbstractSettingController.prototype.nullifyDomReferences_=function(){for(var a in this)if(this.hasOwnProperty(a)){var b=this[a]&&this[a].nodeName;b&&(this[a]=null)}}}(),function(){var a=$.namespace("pskl.controller.settings");a.ApplicationSettingsController=function(){},pskl.utils.inherit(a.ApplicationSettingsController,pskl.controller.settings.AbstractSettingController),a.ApplicationSettingsController.prototype.init=function(){this.backgroundContainer=document.querySelector(".background-picker-wrapper"),this.addEventListener(this.backgroundContainer,"click",this.onBackgroundClick_);var a=pskl.UserSettings.get(pskl.UserSettings.CANVAS_BACKGROUND),b=this.backgroundContainer.querySelector("[data-background="+a+"]");b&&b.classList.add("selected");var c=pskl.UserSettings.get(pskl.UserSettings.GRID_WIDTH),d=document.querySelector(".grid-width-select"),e=d.querySelector('option[value="'+c+'"]');e&&e.setAttribute("selected","selected"),this.addEventListener(d,"change",this.onGridWidthChange_);var f=pskl.UserSettings.get(pskl.UserSettings.TILED_PREVIEW),g=document.querySelector(".tiled-preview-checkbox");f&&g.setAttribute("checked",f),this.addEventListener(g,"change",this.onTiledPreviewChange_);var h=document.querySelector(".max-fps-input");h.value=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS),this.addEventListener(h,"change",this.onMaxFpsChange_),this.applicationSettingsForm=document.querySelector('[name="application-settings-form"]'),this.addEventListener(this.applicationSettingsForm,"submit",this.onFormSubmit_)},a.ApplicationSettingsController.prototype.onGridWidthChange_=function(a){var b=parseInt(a.target.value,10);pskl.UserSettings.set(pskl.UserSettings.GRID_WIDTH,b)},a.ApplicationSettingsController.prototype.onTiledPreviewChange_=function(a){pskl.UserSettings.set(pskl.UserSettings.TILED_PREVIEW,a.currentTarget.checked)},a.ApplicationSettingsController.prototype.onBackgroundClick_=function(a){var b=a.target,c=b.dataset.background;if(c){pskl.UserSettings.set(pskl.UserSettings.CANVAS_BACKGROUND,c);var d=this.backgroundContainer.querySelector(".selected");d&&d.classList.remove("selected"),b.classList.add("selected")}},a.ApplicationSettingsController.prototype.onMaxFpsChange_=function(a){var b=a.target,c=parseInt(b.value,10);c&&!isNaN(c)?pskl.UserSettings.set(pskl.UserSettings.MAX_FPS,c):b.value=pskl.UserSettings.get(pskl.UserSettings.MAX_FPS)},a.ApplicationSettingsController.prototype.onFormSubmit_=function(a){a.preventDefault(),$.publish(Events.CLOSE_SETTINGS_DRAWER)}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage");a.ImageExportController=function(b){this.piskelController=b,this.pngExportController=new a.PngExportController(b),this.gifExportController=new a.GifExportController(b)},a.ImageExportController.prototype.init=function(){this.pngExportController.init(),this.gifExportController.init()},a.ImageExportController.prototype.destroy=function(){this.pngExportController.destroy(),this.gifExportController.destroy()}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage"),b=30,c=256,d=20,e="#FF00FF";a.GifExportController=function(a){this.piskelController=a},pskl.utils.inherit(a.GifExportController,pskl.controller.settings.AbstractSettingController),a.GifExportController.RESOLUTIONS=[];for(var f=1;d>=f;f++)a.GifExportController.RESOLUTIONS.push({zoom:f});a.GifExportController.prototype.init=function(){this.optionTemplate_=pskl.utils.Template.get("gif-export-option-template"),this.uploadStatusContainerEl=document.querySelector(".gif-upload-status"),this.previewContainerEl=document.querySelector(".gif-export-preview"),this.widthInput=document.querySelector(".export-gif-resize-width"),this.heightInput=document.querySelector(".export-gif-resize-height"),this.uploadButton=document.querySelector(".gif-upload-button"),this.downloadButton=document.querySelector(".gif-download-button"),this.sizeInputWidget=new pskl.widgets.SizeInput(this.widthInput,this.heightInput,this.piskelController.getWidth(),this.piskelController.getHeight()),this.addEventListener(this.uploadButton,"click",this.onUploadButtonClick_),this.addEventListener(this.downloadButton,"click",this.onDownloadButtonClick_)},a.GifExportController.prototype.destroy=function(){this.sizeInputWidget.destroy(),this.superclass.destroy.call(this)},a.GifExportController.prototype.onUploadButtonClick_=function(a){a.preventDefault();var b=this.getZoom_(),c=this.piskelController.getFPS();this.renderAsImageDataAnimatedGIF(b,c,this.uploadImageData_.bind(this))},a.GifExportController.prototype.onDownloadButtonClick_=function(a){var b=this.getZoom_(),c=this.piskelController.getFPS();this.renderAsImageDataAnimatedGIF(b,c,this.downloadImageData_.bind(this))},a.GifExportController.prototype.downloadImageData_=function(a){var b=this.piskelController.getPiskel().getDescriptor().name+".gif";pskl.utils.BlobUtils.dataToBlob(a,"image/gif",function(a){pskl.utils.FileUtils.downloadAsFile(a,b)})},a.GifExportController.prototype.uploadImageData_=function(a){this.updatePreview_(a),this.previewContainerEl.classList.add("preview-upload-ongoing"),pskl.app.imageUploadService.upload(a,this.onImageUploadCompleted_.bind(this),this.onImageUploadFailed_.bind(this)); +},a.ImportImageController.prototype.onFrameInputKeyUp_=function(a,b){this.importedImage_&&this.synchronizeFrameFields_(b.target.value,a)},a.ImportImageController.prototype.synchronizeResizeFields_=function(a,b){a=parseInt(a,10),isNaN(a)&&(a=0);var c=this.importedImage_.height,d=this.importedImage_.width;this.importType.filter('[value="single"]').attr("checked","checked"),"width"===b?this.resizeHeight.val(Math.round(a*c/d)):this.resizeWidth.val(Math.round(a*d/c))},a.ImportImageController.prototype.synchronizeFrameFields_=function(a,b){a=parseInt(a,10),isNaN(a)&&(a=0);var c=this.sanitizeInputValue_(this.frameSizeX,1),d=this.sanitizeInputValue_(this.frameSizeY,1),e=this.sanitizeInputValue_(this.frameOffsetX,0),f=this.sanitizeInputValue_(this.frameOffsetY,0);this.importType.filter('[value="sheet"]').attr("checked","checked"),this.drawFrameGrid_(e,f,c,d)},a.ImportImageController.prototype.sanitizeInputValue_=function(a,b){var c=parseInt(a.val(),10);return(b>=c||isNaN(c))&&(a.val(b),c=b),c},a.ImportImageController.prototype.getImportType_=function(){return this.importType.filter(":checked").val()},a.ImportImageController.prototype.onImageLoaded_=function(a){this.importedImage_=a;var b=this.importedImage_.width,c=this.importedImage_.height;this.importedImage_.onload=function(){};var d=this.extractFileNameFromPath_(this.file_.name);this.fileNameContainer.html(d),this.fileNameContainer.attr("title",d),this.resizeWidth.val(b),this.resizeHeight.val(c),this.frameSizeX.val(b),this.frameSizeY.val(c),this.frameOffsetX.val(0),this.frameOffsetY.val(0),this.importPreview.width("auto"),this.importPreview.height("auto"),this.importPreview.html(""),this.importPreview.append(this.createImagePreview_())},a.ImportImageController.prototype.createImagePreview_=function(){var a=document.createElement("IMG");return a.src=this.importedImage_.src,a},a.ImportImageController.prototype.extractFileNameFromPath_=function(a){var b=[];return b=-1!==a.indexOf("/")?a.split("/"):-1!==a.indexOf("\\")?a.split("\\"):[a],b[b.length-1]},a.ImportImageController.prototype.importImageToPiskel_=function(){var a=this.importedImage_;if(a&&window.confirm("You are about to create a new Piskel, unsaved changes will be lost.")){var b=new window.SuperGif({gif:a}),c=this.resizeWidth.val(),d=this.resizeHeight.val();b.load({success:function(){var a=b.getFrames().map(function(a){return pskl.utils.CanvasUtils.createFromImageData(a.data)});"single"===this.getImportType_()||a.length>1?this.createPiskelFromImages_(a,c,d):this.createImagesFromSheet_(a[0]),this.closeDialog()}.bind(this),error:function(){"single"===this.getImportType_()?this.createPiskelFromImages_([a],c,d):this.createImagesFromSheet_(a),this.closeDialog()}.bind(this)})}},a.ImportImageController.prototype.createImagesFromSheet_=function(a){var b=this.sanitizeInputValue_(this.frameOffsetX,0),c=this.sanitizeInputValue_(this.frameOffsetY,0),d=this.sanitizeInputValue_(this.frameSizeX,1),e=this.sanitizeInputValue_(this.frameSizeY,1),f=pskl.utils.CanvasUtils.createFramesFromImage(a,b,c,d,e,!0,!0);this.createPiskelFromImages_(f,d,e)},a.ImportImageController.prototype.createFramesFromImages_=function(a,b,c){var d=!!this.smoothResize.prop("checked"),e=a.map(function(a){var e=pskl.utils.ImageResizer.resize(a,b,c,d);return pskl.utils.FrameUtils.createFromImage(e)});return e},a.ImportImageController.prototype.createPiskelFromImages_=function(a,b,c){var d=this.createFramesFromImages_(a,b,c),e=pskl.model.Layer.fromFrames("Layer 1",d),f=new pskl.model.piskel.Descriptor("Imported piskel",""),g=pskl.model.Piskel.fromLayers([e],f);pskl.app.piskelController.setPiskel(g),pskl.app.previewController.setFPS(Constants.DEFAULT.FPS)},a.ImportImageController.prototype.drawFrameGrid_=function(a,b,c,d){if(this.importedImage_){var e=this.importedImage_.width,f=this.importedImage_.height,g=this.importPreview.width(),h=this.importPreview.height(),i=this.importPreview.children("canvas"),j=i.get(0);i.length||(j=pskl.utils.CanvasUtils.createCanvas(g+1,h+1),this.importPreview.append(j),i=$(j));var k=j.getContext("2d");k.clearRect(0,0,j.width,j.height),k.beginPath();var l=Math.floor((e-a)/c),m=Math.floor((f-b)/d);if(l>0&&m>0){for(var n=g/e,o=h/f,p=l*c+a,q=m*d+b,r=a+.5;p+1>r&&e+1>r;r+=c)k.moveTo(r*n,b*o),k.lineTo(r*n,q*o);for(var s=b+.5;q+1>s&&f+1>s;s+=d)k.moveTo(a*n,s*o),k.lineTo(p*n,s*o);k.lineWidth=1,k.setLineDash([2,1]),k.strokeStyle="#000000",k.stroke(),i.show(),this.importPreview.addClass("no-border")}else this.hideFrameGrid_()}},a.ImportImageController.prototype.hideFrameGrid_=function(){this.importPreview.children("canvas").hide(),this.importPreview.removeClass("no-border")}}(),function(){var a=$.namespace("pskl.controller.dialogs");a.BrowseLocalController=function(a){},pskl.utils.inherit(a.BrowseLocalController,a.AbstractDialogController),a.BrowseLocalController.prototype.init=function(){this.superclass.init.call(this),this.localStorageItemTemplate_=pskl.utils.Template.get("local-storage-item-template"),this.service_=pskl.app.localStorageService,this.piskelList=$(".local-piskel-list"),this.prevSessionContainer=$(".previous-session"),this.fillLocalPiskelsList_(),this.piskelList.click(this.onPiskelsListClick_.bind(this))},a.BrowseLocalController.prototype.onPiskelsListClick_=function(a){var b=a.target.getAttribute("data-action"),c=a.target.getAttribute("data-name");"load"===b?window.confirm("This will erase your current piskel. Continue ?")&&(this.service_.load(c),this.closeDialog()):"delete"===b&&window.confirm("This will permanently DELETE this piskel from your computer. Continue ?")&&(this.service_.remove(c),this.fillLocalPiskelsList_())},a.BrowseLocalController.prototype.fillLocalPiskelsList_=function(){var a="",b=this.service_.getKeys();b.sort(function(a,b){return a.dateb.date?-1:0}),b.forEach(function(b){var c=pskl.utils.DateUtils.format(b.date,"{{Y}}/{{M}}/{{D}} {{H}}:{{m}}");a+=pskl.utils.Template.replace(this.localStorageItemTemplate_,{name:b.name,date:c})}.bind(this));var c=this.piskelList.get(0).tBodies[0];c.innerHTML=a}}(),function(){var a=$.namespace("pskl.controller.dialogs"),b={"create-palette":{template:"templates/dialogs/create-palette.html",controller:a.CreatePaletteController},"browse-local":{template:"templates/dialogs/browse-local.html",controller:a.BrowseLocalController},"import-image":{template:"templates/dialogs/import-image.html",controller:a.ImportImageController}};a.DialogsController=function(a){this.piskelController=a,this.currentDialog_=null},a.DialogsController.prototype.init=function(){this.dialogContainer_=document.getElementById("dialog-container"),this.dialogWrapper_=document.getElementById("dialog-container-wrapper"),$.subscribe(Events.DIALOG_DISPLAY,this.onDialogDisplayEvent_.bind(this)),$.subscribe(Events.DIALOG_HIDE,this.onDialogHideEvent_.bind(this)),pskl.app.shortcutService.addShortcut("alt+P",this.onDialogDisplayEvent_.bind(this,null,"create-palette")),this.dialogWrapper_.classList.add("animated")},a.DialogsController.prototype.onDialogDisplayEvent_=function(a,c){var d,e;if("string"==typeof c?d=c:(d=c.dialogId,e=c.initArgs),!this.isDisplayed()){var f=b[d];if(f){this.dialogContainer_.classList.add(d),this.dialogContainer_.innerHTML=pskl.utils.Template.get(f.template);var g=new f.controller(this.piskelController);g.init(e),this.showDialogWrapper_(),this.currentDialog_={id:d,controller:g}}else console.error("Could not find dialog configuration for dialogId : "+d)}},a.DialogsController.prototype.onDialogHideEvent_=function(){this.hideDialog()},a.DialogsController.prototype.showDialogWrapper_=function(){pskl.app.shortcutService.addShortcut("ESC",this.hideDialog.bind(this)),this.dialogWrapper_.classList.add("show")},a.DialogsController.prototype.hideDialog=function(){var a=this.currentDialog_;if(a){a.controller.destroy();var b=this.currentDialog_.id;window.setTimeout(function(){this.dialogContainer_.classList.remove(b)}.bind(this),800)}this.hideDialogWrapper_(),this.currentDialog_=null},a.DialogsController.prototype.hideDialogWrapper_=function(){pskl.app.shortcutService.removeShortcut("ESC"),this.dialogWrapper_.classList.remove("show")},a.DialogsController.prototype.isDisplayed=function(){return null!==this.currentDialog_}}(),function(){var a=$.namespace("pskl.widgets"),b="#000000";a.ColorsList=function(a){this.selectedIndex=-1,this.palette=new pskl.model.Palette("tmp","tmp",[]),this.container=a,this.colorsList=this.container.querySelector(".colors-list"),this.colorPreviewEl=this.container.querySelector(".color-preview"),$(a).sortable({placeholder:"colors-list-drop-proxy",update:this.onColorDrop_.bind(this),items:".create-palette-color"}),this.colorsList.addEventListener("click",this.onColorContainerClick_.bind(this));var b=a.querySelector(".color-picker-container");this.hslRgbColorPicker=new pskl.widgets.HslRgbColorPicker(b,this.onColorUpdated_.bind(this)),this.hslRgbColorPicker.init()},a.ColorsList.prototype.setColors=function(a){0===a.length&&a.push(b),this.palette.setColors(a),this.selectColor_(0),this.refresh_()},a.ColorsList.prototype.getColors=function(){return this.palette.getColors()},a.ColorsList.prototype.destroy=function(){this.hslRgbColorPicker.destroy(),this.container=null,this.colorsList=null,this.colorPreviewEl=null},a.ColorsList.prototype.refreshColorElement_=function(a){var b=this.palette.get(this.selectedIndex),c=document.querySelector('[data-palette-index="'+a+'"]');c&&(c.style.background=b,c.classList.toggle("light-color",this.isLight_(b)))},a.ColorsList.prototype.onColorContainerClick_=function(a){var b=a.target;b.classList.contains("create-palette-color")?this.onPaletteColorClick_(a,b):b.classList.contains("create-palette-new-color")?this.onNewColorClick_(a,b):b.classList.contains("create-palette-remove-color")&&this.onRemoveColorClick_(a,b),this.refresh_()},a.ColorsList.prototype.onColorUpdated_=function(a){var b=a.toRgbString();this.colorPreviewEl.style.background=b,this.palette&&(this.palette.set(this.selectedIndex,b),this.refreshColorElement_(this.selectedIndex))},a.ColorsList.prototype.onPaletteColorClick_=function(a,b){var c=parseInt(b.dataset.paletteIndex,10);this.selectColor_(c)},a.ColorsList.prototype.onRemoveColorClick_=function(a,b){var c=b.parentNode,d=parseInt(c.dataset.paletteIndex,10);this.removeColor_(d)},a.ColorsList.prototype.onNewColorClick_=function(a,b){var c=this.palette.get(this.selectedIndex)||"#000000";this.palette.add(c),this.selectColor_(this.palette.size()-1)},a.ColorsList.prototype.refresh_=function(){var a="",b=pskl.utils.Template.get("create-palette-color-template"),c=this.palette.getColors();c.forEach(function(c,d){var e=d===this.selectedIndex;a+=pskl.utils.Template.replace(b,{color:c,index:d,":selected":e,":light-color":this.isLight_(c)})}.bind(this)),a+='
  • +
  • ',this.colorsList.innerHTML=a},a.ColorsList.prototype.selectColor_=function(a){this.selectedIndex=a,this.hslRgbColorPicker.setColor(this.palette.get(a))},a.ColorsList.prototype.removeColor_=function(a){this.palette.removeAt(a),this.refresh_()},a.ColorsList.prototype.isLight_=function(a){var b=window.tinycolor(a).toRgb();return b.r+b.b+b.g>384},a.ColorsList.prototype.onColorDrop_=function(a,b){var c=b.item.get(0),d=parseInt(c.dataset.paletteIndex,10),e=$(".create-palette-color").index(b.item);this.palette.move(d,e),this.selectedIndex=e,this.refresh_()}}(),function(){var a=$.namespace("pskl.widgets");a.HslRgbColorPicker=function(a,b){this.container=a,this.colorUpdatedCallback=b,this.tinyColor=null,this.hsvColor=null,this.rgbColor=null,this.lastInputTimestamp_=0},a.HslRgbColorPicker.prototype.init=function(){var a=pskl.utils.UserAgent.isFirefox,b=pskl.utils.UserAgent.isChrome,c=b||a?"input":"change";this.container.addEventListener(c,this.onPickerChange_.bind(this)),this.container.addEventListener("keydown",this.onKeydown_.bind(this)),this.container.addEventListener("blur",this.onBlur_.bind(this),!0),this.spectrumEl=this.container.querySelector(".color-picker-spectrum"),$(this.spectrumEl).spectrum({flat:!0,showButtons:!1,move:this.setColor.bind(this),change:this.setColor.bind(this)}),this.setColor("#000000")},a.HslRgbColorPicker.prototype.destroy=function(){this.container=null,this.spectrumEl=null},a.HslRgbColorPicker.prototype.onPickerChange_=function(a){var b=a.target;if(b.dataset.dimension){var c=b.dataset.model,d=b.dataset.dimension,e=b.value;this.updateColor_(e,c,d)}},a.HslRgbColorPicker.prototype.onKeydown_=function(a){var b=a.target,c="text"===b.getAttribute("type").toLowerCase();if(c&&b.dataset.dimension){var d=b.dataset.model;if("rgb"===d||"hsv"===d){var e=this.getIncrement_(a);if(e){var f=b.dataset.dimension,g=parseInt(b.value,10);this.updateColor_(g+e,d,f)}}}},a.HslRgbColorPicker.prototype.getIncrement_=function(a){var b=0,c=pskl.service.keyboard.KeycodeTranslator.toChar(a.keyCode);return"up"===c?b=1:"down"===c&&(b=-1),a.shiftKey&&(b=5*b),b},a.HslRgbColorPicker.prototype.updateColor_=function(a,b,c){var d=this.toModelValue_(a,b,c);if("hsv"===b||"rgb"===b){if(!isNaN(d)){var e=this.getColor_(b);e[c]=this.normalizeDimension_(d,c),this.setColor(e)}}else"hex"===b&&/^#([a-f0-9]{3}){1,2}$/i.test(d)&&this.setColor(d)},a.HslRgbColorPicker.prototype.onBlur_=function(a){var b=a.target,c="text"===b.getAttribute("type").toLowerCase();if(c&&b.dataset.dimension){var d=b.dataset.model,e=b.dataset.dimension;b.value=this.toInputValue_(d,e)}},a.HslRgbColorPicker.prototype.setColor=function(a){this.unplugged||(this.unplugged=!0,this.hsvColor=this.toHsvColor_(a),this.tinyColor=this.toTinyColor_(a),this.rgbColor=this.tinyColor.toRgb(),this.updateInputs(),$(".color-picker-spectrum").spectrum("set",this.tinyColor),this.colorUpdatedCallback(this.tinyColor),this.unplugged=!1)},a.HslRgbColorPicker.prototype.updateInputs=function(){for(var a=this.container.querySelectorAll("input"),b=0;b";this.piskelController=a},a.LocalStorageService.prototype.init=function(){},a.LocalStorageService.prototype.save=function(a,b,c){this.removeFromKeys_(a),this.addToKeys_(a,b,Date.now()),window.localStorage.setItem("piskel."+a,c)},a.LocalStorageService.prototype.load=function(a){var b=this.getPiskel(a),c=(this.getKey_(a),JSON.parse(b)),d=c.piskel.fps,e=c.piskel.description;pskl.utils.serialization.Deserializer.deserialize(c,function(b){b.setDescriptor(new pskl.model.piskel.Descriptor(a,e,!0)),pskl.app.piskelController.setPiskel(b),pskl.app.previewController.setFPS(d)})},a.LocalStorageService.prototype.remove=function(a){this.removeFromKeys_(a),window.localStorage.removeItem("piskel."+a)},a.LocalStorageService.prototype.saveKeys_=function(a){window.localStorage.setItem("piskel.keys",JSON.stringify(a))},a.LocalStorageService.prototype.removeFromKeys_=function(a){var b=this.getKeys(),c=b.filter(function(b){return b.name!==a});this.saveKeys_(c)},a.LocalStorageService.prototype.getKey_=function(a){var b=this.getKeys().filter(function(b){return b.name===a});return b.length>0?b[0]:null},a.LocalStorageService.prototype.addToKeys_=function(a,b,c){var d=this.getKeys();d.push({name:a,description:b,date:c}),this.saveKeys_(d)},a.LocalStorageService.prototype.getPiskel=function(a){return window.localStorage.getItem("piskel."+a)},a.LocalStorageService.prototype.getKeys=function(a){var b=window.localStorage.getItem("piskel.keys");return JSON.parse(b)||[]}}(),function(){var a=$.namespace("pskl.service");a.GithubStorageService=function(a){this.piskelController=a},a.GithubStorageService.prototype.init=function(){},a.GithubStorageService.prototype.store=function(a){throw"Github save is no longer available. Use local save instead"}}(),function(){var a=$.namespace("pskl.service");a.AppEngineStorageService=function(a){this.piskelController=a},a.AppEngineStorageService.prototype.init=function(){},a.AppEngineStorageService.prototype.store=function(a){var b=this.piskelController.getPiskel(),c=b.getDescriptor(),d={framesheet:this.piskelController.serialize(),fps:this.piskelController.getFPS(),name:c.name,description:c.description,frames:this.piskelController.getFrameCount(),first_frame_as_png:pskl.app.getFirstFrameAsPng(),framesheet_as_png:pskl.app.getFramesheetAsPng()};c.isPublic&&(d["public"]=!0);var e=function(){a.success(),a.after()},f=function(b){a.error(b.status),a.after()};pskl.utils.Xhr.post(Constants.APPENGINE_SAVE_URL,d,e,f)}}(),function(){var a=$.namespace("pskl.service");a.DesktopStorageService=function(a){this.piskelController=a||pskl.app.piskelController,this.hideNotificationTimeoutID=0},a.DesktopStorageService.prototype.init=function(){pskl.utils.Environment.detectNodeWebkit()&&(pskl.app.shortcutService.addShortcut("ctrl+o",this.openPiskel.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+s",this.save.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+shift+s",this.savePiskelAs.bind(this)))},a.DesktopStorageService.prototype.save=function(){var a=this.piskelController.getSavePath();a?this.savePiskel(a):this.savePiskelAs()},a.DesktopStorageService.prototype.savePiskel=function(a){var b=this.piskelController.serialize();pskl.utils.FileUtilsDesktop.saveToFile(b,a,function(){this.onSaveSuccess_()}.bind(this))},a.DesktopStorageService.prototype.openPiskel=function(){pskl.utils.FileUtilsDesktop.chooseFileDialog(function(a){var b=a;pskl.utils.FileUtilsDesktop.readFile(b,function(a){pskl.utils.PiskelFileUtils.decodePiskelFile(a,function(a,c,d){a.setDescriptor(c),a.savePath=b,pskl.app.piskelController.setPiskel(a),pskl.app.previewController.setFPS(d)})})})},a.DesktopStorageService.prototype.savePiskelAs=function(){var a=this.piskelController.serialize(),b=this.piskelController.getPiskel().getDescriptor().name;pskl.utils.FileUtilsDesktop.saveAs(a,b,"piskel",function(a){this.piskelController.setSavePath(a);var b=this.extractFilename_(a);if(b){var c=this.piskelController.getPiskel().getDescriptor();c.name=b,this.piskelController.getPiskel().setDescriptor(c)}this.onSaveSuccess_()}.bind(this))},a.DesktopStorageService.prototype.extractFilename_=function(a){var b=/[\/\\]([^\/\\]*)\.piskel$/gi.exec(a);return b&&b[1]?b[1]:void 0},a.DesktopStorageService.prototype.onSaveSuccess_=function(){var a=this.piskelController.getSavePath();$.publish(Events.CLOSE_SETTINGS_DRAWER),$.publish(Events.SHOW_NOTIFICATION,[{content:"Successfully saved: "+a}]),$.publish(Events.PISKEL_SAVED),window.clearTimeout(this.hideNotificationTimeoutID),this.hideNotificationTimeoutID=window.setTimeout($.publish.bind($,Events.HIDE_NOTIFICATION),3e3)}}(),function(){var a=$.namespace("pskl.service"),b=6e4;a.BackupService=function(a){this.piskelController=a,this.lastHash=null},a.BackupService.prototype.init=function(){var a=window.localStorage.getItem("bkp.next.piskel"),c=window.localStorage.getItem("bkp.next.info");a&&c&&this.savePiskel_("prev",a,c),window.setInterval(this.backup.bind(this),b)},a.BackupService.prototype.backup=function(){var a=this.piskelController.getPiskel(),b=a.getDescriptor(),c=a.getHash(),d={name:b.name,description:b.info,fps:this.piskelController.getFPS(),date:Date.now(),hash:c};c!==this.lastHash&&(this.lastHash=c,this.savePiskel_("next",this.piskelController.serialize(),JSON.stringify(d)))},a.BackupService.prototype.getPreviousPiskelInfo=function(){var a=window.localStorage.getItem("bkp.prev.info");return a?JSON.parse(a):void 0},a.BackupService.prototype.load=function(){var a=window.localStorage.getItem("bkp.prev.piskel"),b=window.localStorage.getItem("bkp.prev.info");a=JSON.parse(a),b=JSON.parse(b),pskl.utils.serialization.Deserializer.deserialize(a,function(a){a.setDescriptor(new pskl.model.piskel.Descriptor(b.name,b.description,!0)),pskl.app.piskelController.setPiskel(a),pskl.app.previewController.setFPS(b.fps)})},a.BackupService.prototype.savePiskel_=function(a,b,c){try{window.localStorage.setItem("bkp."+a+".piskel",b),window.localStorage.setItem("bkp."+a+".info",c)}catch(d){console.error("Could not save piskel backup in localStorage.",d)}}}(),function(){var a=$.namespace("pskl.service");a.BeforeUnloadService=function(a){this.piskelController=a},a.BeforeUnloadService.prototype.init=function(){window.addEventListener("beforeunload",this.onBeforeUnload.bind(this))},a.BeforeUnloadService.prototype.onBeforeUnload=function(a){if(pskl.app.backupService.backup(),pskl.app.savedStatusService.isDirty()){var b="Your Piskel seems to have unsaved changes";return(a||window.event).returnValue=b,b}}}(),function(){var a=$.namespace("pskl.service");a.HistoryService=function(a,b,c){this.piskelController=a||pskl.app.piskelController,this.shortcutService=b||pskl.app.shortcutService,this.deserializer=c||pskl.utils.serialization.Deserializer,this.stateQueue=[],this.currentIndex=-1,this.lastLoadState=-1},a.HistoryService.SNAPSHOT="SNAPSHOT",a.HistoryService.REPLAY="REPLAY",a.HistoryService.SNAPSHOT_PERIOD=50,a.HistoryService.LOAD_STATE_INTERVAL=50,a.HistoryService.prototype.init=function(){$.subscribe(Events.PISKEL_SAVE_STATE,this.onSaveStateEvent.bind(this)),this.shortcutService.addShortcut("ctrl+Z",this.undo.bind(this)),this.shortcutService.addShortcut("ctrl+Y",this.redo.bind(this)),this.saveState({type:a.HistoryService.SNAPSHOT})},a.HistoryService.prototype.onSaveStateEvent=function(a,b){this.saveState(b)},a.HistoryService.prototype.saveState=function(b){this.stateQueue=this.stateQueue.slice(0,this.currentIndex+1),this.currentIndex=this.currentIndex+1;var c={action:b,frameIndex:b.state?b.state.frameIndex:this.piskelController.currentFrameIndex,layerIndex:b.state?b.state.layerIndex:this.piskelController.currentLayerIndex},d=b.type===a.HistoryService.SNAPSHOT,e=this.currentIndex%a.HistoryService.SNAPSHOT_PERIOD===0;(d||e)&&(c.piskel=this.piskelController.serialize(!0)),this.stateQueue.push(c),$.publish(Events.HISTORY_STATE_SAVED)},a.HistoryService.prototype.undo=function(){this.loadState(this.currentIndex-1)},a.HistoryService.prototype.redo=function(){this.loadState(this.currentIndex+1)},a.HistoryService.prototype.isLoadStateAllowed_=function(b){var c=Date.now()-this.lastLoadState>a.HistoryService.LOAD_STATE_INTERVAL,d=b>=0&&bb)throw"Could not find previous SNAPSHOT saved in history stateQueue";var c=this.getSnapshotFromState_(b),d=this.onPiskelLoaded_.bind(this,a,b);this.deserializer.deserialize(c,d)}}catch(e){console.error("[CRITICAL ERROR] : Unable to load a history state."),this.logError_(e),this.stateQueue=[],this.currentIndex=-1}},a.HistoryService.prototype.logError_=function(a){"string"==typeof a?console.error(a):(console.error(a.message),console.error(a.stack))},a.HistoryService.prototype.getSnapshotFromState_=function(a){var b=this.stateQueue[a],c=b.piskel;return"string"==typeof c&&(c=JSON.parse(c),b.piskel=c),c},a.HistoryService.prototype.onPiskelLoaded_=function(a,b,c){var d=this.getPiskelSize_();c.setDescriptor(this.piskelController.piskel.getDescriptor()),c.savePath=this.piskelController.piskel.savePath,this.piskelController.setPiskel(c);for(var e=b+1;a>=e;e++){var f=this.stateQueue[e];this.setupState(f),this.replayState(f)}var g=this.stateQueue[a+1];g&&this.setupState(g),this.currentIndex=a,$.publish(Events.PISKEL_RESET),$.publish(Events.HISTORY_STATE_LOADED),d!==this.getPiskelSize_()&&$.publish(Events.FRAME_SIZE_CHANGED)},a.HistoryService.prototype.getPiskelSize_=function(){return this.piskelController.getWidth()+"x"+this.piskelController.getHeight()},a.HistoryService.prototype.setupState=function(a){this.piskelController.setCurrentFrameIndex(a.frameIndex),this.piskelController.setCurrentLayerIndex(a.layerIndex)},a.HistoryService.prototype.replayState=function(a){var b=a.action,c=(b.type,this.piskelController.getLayerAt(a.layerIndex)),d=c.getFrameAt(a.frameIndex);b.scope.replay(d,b.replay)}}(),function(){for(var a=$.namespace("pskl.service.color"),b=.1,c=.1,d=.9,e=36,f=10,g=[],h=0;f>h;h++)g.push(h*e);a.ColorSorter=function(){this.colorsHslMap_={}},a.ColorSorter.prototype.sort=function(a){this.colorsHslMap_={},a.forEach(function(a){this.colorsHslMap_[a]=window.tinycolor(a).toHsl()}.bind(this));var f=a.filter(function(a){var b=this.colorsHslMap_[a];return b.l<=c}.bind(this)),h=a.filter(function(a){var b=this.colorsHslMap_[a];return b.l>=d}.bind(this)),i=a.filter(function(a){return-1===h.indexOf(a)&&-1===f.indexOf(a)}).filter(function(a){var c=this.colorsHslMap_[a];return c.s<=b}.bind(this));f=this.sortOnHslProperty_(f,"l"),h=this.sortOnHslProperty_(h,"l"),i=this.sortOnHslProperty_(i,"h");var j=f.concat(h,i),k=a.filter(function(a){return-1===j.indexOf(a)}),l=g.map(function(a){var b=k.filter(function(b){var c=this.colorsHslMap_[b];return c.h>=a&&c.he?f>g?this.compareValues_(c.s,d.s):this.compareValues_(c.l,d.l):this.compareValues_(c.h,d.h)}.bind(this));return b},a.ColorSorter.prototype.sortOnHslProperty_=function(a,b){return a.sort(function(a,c){var d=this.colorsHslMap_[a],e=this.colorsHslMap_[c];return this.compareValues_(d[b],e[b])}.bind(this))},a.ColorSorter.prototype.compareValues_=function(a,b){return a>b?1:b>a?-1:0}}(),function(){var a=$.namespace("pskl.service.palette");a.CurrentColorsPalette=function(){this.name="Current colors",this.id=Constants.CURRENT_COLORS_PALETTE_ID,this.colorSorter=new pskl.service.color.ColorSorter},a.CurrentColorsPalette.prototype.getColors=function(){var a=pskl.app.currentColorsService.getCurrentColors();return a=a.slice(0,Constants.MAX_PALETTE_COLORS),this.colorSorter.sort(a)}}(),function(){var a=$.namespace("pskl.service.palette");a.PaletteService=function(){this.dynamicPalettes=[],this.localStorageService=window.localStorage},a.PaletteService.prototype.getPalettes=function(){var a=this.localStorageService.getItem("piskel.palettes"),b=JSON.parse(a)||[];return b=b.map(function(a){return pskl.model.Palette.fromObject(a)}),this.dynamicPalettes.concat(b)},a.PaletteService.prototype.getPaletteById=function(a){var b=this.getPalettes();return this.findPaletteInArray_(a,b)},a.PaletteService.prototype.savePalette=function(a){var b=this.getPalettes(),c=this.findPaletteInArray_(a.id,b);if(c){var d=b.indexOf(c);b.splice(d,1,a)}else b.push(a);this.savePalettes_(b),$.publish(Events.SHOW_NOTIFICATION,[{content:"Palette "+a.name+" successfully saved !"}]),window.setTimeout($.publish.bind($,Events.HIDE_NOTIFICATION),2e3)},a.PaletteService.prototype.addDynamicPalette=function(a){this.dynamicPalettes.push(a)},a.PaletteService.prototype.deletePaletteById=function(a){var b=this.getPalettes(),c=b.filter(function(b){return b.id!==a});this.savePalettes_(c)},a.PaletteService.prototype.savePalettes_=function(a){a=a.filter(function(a){return-1===this.dynamicPalettes.indexOf(a)}.bind(this)),this.localStorageService.setItem("piskel.palettes",JSON.stringify(a)),$.publish(Events.PALETTE_LIST_UPDATED)},a.PaletteService.prototype.findPaletteInArray_=function(a,b){var c=null;return b.forEach(function(b){b.id===a&&(c=b)}),c}}(),function(){var a=$.namespace("pskl.service.palette");a.PaletteGplWriter=function(a){this.palette=a},a.PaletteGplWriter.prototype.write=function(){var a=[];return a.push("GIMP Palette"),a.push("Name: "+this.palette.name),a.push("Columns: 0"),a.push("#"),this.palette.getColors().forEach(function(b){a.push(this.writeColorLine(b))}.bind(this)),a.push("\r\n"),a.join("\r\n")},a.PaletteGplWriter.prototype.writeColorLine=function(a){var b=window.tinycolor(a),c=b.toRgb(),d=[];return d.push(this.padString(c.r,3)),d.push(this.padString(c.g,3)),d.push(this.padString(c.b,3)),d.push("Untitled"),d.join(" ")},a.PaletteGplWriter.prototype.padString=function(a,b){a=a.toString();var c=new Array(1+b-a.length).join(" ");return c+a}}(),function(){var a=$.namespace("pskl.service.palette.reader");a.AbstractPaletteFileReader=function(a,b,c,d){this.file=a,this.onSuccess=b,this.onError=c,this.colorLineRegexp=d},a.AbstractPaletteFileReader.prototype.extractColorFromLine=Constants.ABSTRACT_FUNCTION,a.AbstractPaletteFileReader.prototype.read=function(){pskl.utils.FileUtils.readFile(this.file,this.onFileLoaded_.bind(this))},a.AbstractPaletteFileReader.prototype.onFileLoaded_=function(a){var b=pskl.utils.Base64.toText(a),c=b.match(/[^\r\n]+/g),d=c.filter(function(a){return this.colorLineRegexp.test(a)}.bind(this)),e=d.map(this.extractColorFromLine.bind(this));if(e.length){var f=pskl.utils.Uuid.generate(),g=new pskl.model.Palette(f,this.file.name,e);this.onSuccess(g)}else this.onError()}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^(\s*\d{1,3})(\s*\d{1,3})(\s*\d{1,3})/; -},a.GifExportController.prototype.onImageUploadCompleted_=function(a){this.updatePreview_(a),this.updateStatus_(a),this.previewContainerEl.classList.remove("preview-upload-ongoing")},a.GifExportController.prototype.onImageUploadFailed_=function(a,b){500===b.status&&$.publish(Events.SHOW_NOTIFICATION,[{content:"Upload failed : "+b.responseText,hideDelay:5e3}])},a.GifExportController.prototype.updatePreview_=function(a){this.previewContainerEl.innerHTML='
    '},a.GifExportController.prototype.getZoom_=function(){return parseInt(this.widthInput.value,10)/this.piskelController.getWidth()},a.GifExportController.prototype.renderAsImageDataAnimatedGIF=function(a,b,d){for(var e=pskl.app.currentColorsService.getCurrentColors(),f=e.lengthb){var d=Math.round((b-c.length)/2),e=a.substring(0,d),f=a.substring(a.length-d,a.length);a=e+c+f}return a}}(),function(){var a=$.namespace("pskl.controller.settings.exportimage"),b=60;a.PngExportController=function(a){this.piskelController=a},pskl.utils.inherit(a.PngExportController,pskl.controller.settings.AbstractSettingController),a.PngExportController.prototype.init=function(){this.pngFilePrefixInput=document.getElementById("zip-prefix-name"),this.pngFilePrefixInput.value="sprite_";var a=document.querySelector(".png-download-button");this.addEventListener(a,"click",this.onPngDownloadButtonClick_);var b=document.querySelector(".zip-generate-button");this.addEventListener(b,"click",this.onZipButtonClick_)},a.PngExportController.prototype.onPngDownloadButtonClick_=function(a){var b=this.getPiskelName_()+".png";pskl.utils.BlobUtils.canvasToBlob(this.getFramesheetAsCanvas(),function(a){pskl.utils.FileUtils.downloadAsFile(a,b)})},a.PngExportController.prototype.onZipButtonClick_=function(){for(var a=new window.JSZip,b=0;bb&&(a=a.substring(0,b),a+=c),a}}(),function(){var a=$.namespace("pskl.controller.settings.resize"),b="resize-origin-option";a.AnchorWidget=function(a){this.container=a,this.disabled=!1,pskl.utils.Event.addEventListener(this.container,"click",this.onResizeOriginClick_,this)},a.AnchorWidget.ORIGIN={TOPLEFT:"TOPLEFT",TOP:"TOP",TOPRIGHT:"TOPRIGHT",MIDDLELEFT:"MIDDLELEFT",MIDDLE:"MIDDLE",MIDDLERIGHT:"MIDDLERIGHT",BOTTOMLEFT:"BOTTOMLEFT",BOTTOM:"BOTTOM",BOTTOMRIGHT:"BOTTOMRIGHT"},a.AnchorWidget.prototype.destroy=function(a){pskl.utils.Event.removeAllEventListeners(this),this.container=null},a.AnchorWidget.prototype.onResizeOriginClick_=function(b){var c=b.target.dataset.origin;c&&a.AnchorWidget.ORIGIN[c]&&!this.disabled&&this.setOrigin(c)},a.AnchorWidget.prototype.setOrigin=function(a){this.origin=a;var c=document.querySelector("."+b+".selected");c&&c.classList.remove("selected");var d=document.querySelector("."+b+'[data-origin="'+a+'"]');d&&(d.classList.add("selected"),this.refreshNeighbors_(d))},a.AnchorWidget.prototype.getOrigin=function(){return this.origin},a.AnchorWidget.prototype.disable=function(){this.disabled=!0,this.container.classList.add("transition"),this.container.classList.add("disabled")},a.AnchorWidget.prototype.enable=function(){this.disabled=!1,this.container.classList.remove("disabled"),window.setTimeout(this.container.classList.remove.bind(this.container.classList,"transition"),250)},a.AnchorWidget.prototype.refreshNeighbors_=function(a){for(var c=document.querySelectorAll("."+b),d=0;db.date?-1:0}),b.forEach(function(b){var c=pskl.utils.DateUtils.format(b.date,"{{Y}}/{{M}}/{{D}} {{H}}:{{m}}");a+=pskl.utils.Template.replace(this.localStorageItemTemplate_,{name:b.name,date:c})}.bind(this));var c=this.piskelList.get(0).tBodies[0];c.innerHTML=a}}(),function(){var a=$.namespace("pskl.controller.dialogs"),b={"create-palette":{template:"templates/dialogs/create-palette.html",controller:a.CreatePaletteController},"browse-local":{template:"templates/dialogs/browse-local.html",controller:a.BrowseLocalController},"import-image":{template:"templates/dialogs/import-image.html",controller:a.ImportImageController}};a.DialogsController=function(a){this.piskelController=a,this.currentDialog_=null},a.DialogsController.prototype.init=function(){this.dialogContainer_=document.getElementById("dialog-container"),this.dialogWrapper_=document.getElementById("dialog-container-wrapper"),$.subscribe(Events.DIALOG_DISPLAY,this.onDialogDisplayEvent_.bind(this)),$.subscribe(Events.DIALOG_HIDE,this.onDialogHideEvent_.bind(this)),pskl.app.shortcutService.addShortcut("alt+P",this.onDialogDisplayEvent_.bind(this,null,"create-palette")),this.dialogWrapper_.classList.add("animated")},a.DialogsController.prototype.onDialogDisplayEvent_=function(a,c){var d,e;if("string"==typeof c?d=c:(d=c.dialogId,e=c.initArgs),!this.isDisplayed()){var f=b[d];if(f){this.dialogContainer_.classList.add(d),this.dialogContainer_.innerHTML=pskl.utils.Template.get(f.template);var g=new f.controller(this.piskelController);g.init(e),this.showDialogWrapper_(),this.currentDialog_={id:d,controller:g}}else console.error("Could not find dialog configuration for dialogId : "+d)}},a.DialogsController.prototype.onDialogHideEvent_=function(){this.hideDialog()},a.DialogsController.prototype.showDialogWrapper_=function(){pskl.app.shortcutService.addShortcut("ESC",this.hideDialog.bind(this)),this.dialogWrapper_.classList.add("show")},a.DialogsController.prototype.hideDialog=function(){ -var a=this.currentDialog_;if(a){a.controller.destroy();var b=this.currentDialog_.id;window.setTimeout(function(){this.dialogContainer_.classList.remove(b)}.bind(this),800)}this.hideDialogWrapper_(),this.currentDialog_=null},a.DialogsController.prototype.hideDialogWrapper_=function(){pskl.app.shortcutService.removeShortcut("ESC"),this.dialogWrapper_.classList.remove("show")},a.DialogsController.prototype.isDisplayed=function(){return null!==this.currentDialog_}}(),function(){var a=$.namespace("pskl.widgets"),b="#000000";a.ColorsList=function(a){this.selectedIndex=-1,this.palette=new pskl.model.Palette("tmp","tmp",[]),this.container=a,this.colorsList=this.container.querySelector(".colors-list"),this.colorPreviewEl=this.container.querySelector(".color-preview"),$(a).sortable({placeholder:"colors-list-drop-proxy",update:this.onColorDrop_.bind(this),items:".create-palette-color"}),this.colorsList.addEventListener("click",this.onColorContainerClick_.bind(this));var b=a.querySelector(".color-picker-container");this.hslRgbColorPicker=new pskl.widgets.HslRgbColorPicker(b,this.onColorUpdated_.bind(this)),this.hslRgbColorPicker.init()},a.ColorsList.prototype.setColors=function(a){0===a.length&&a.push(b),this.palette.setColors(a),this.selectColor_(0),this.refresh_()},a.ColorsList.prototype.getColors=function(){return this.palette.getColors()},a.ColorsList.prototype.destroy=function(){this.hslRgbColorPicker.destroy(),this.container=null,this.colorsList=null,this.colorPreviewEl=null},a.ColorsList.prototype.refreshColorElement_=function(a){var b=this.palette.get(this.selectedIndex),c=document.querySelector('[data-palette-index="'+a+'"]');c&&(c.style.background=b,c.classList.toggle("light-color",this.isLight_(b)))},a.ColorsList.prototype.onColorContainerClick_=function(a){var b=a.target;b.classList.contains("create-palette-color")?this.onPaletteColorClick_(a,b):b.classList.contains("create-palette-new-color")?this.onNewColorClick_(a,b):b.classList.contains("create-palette-remove-color")&&this.onRemoveColorClick_(a,b),this.refresh_()},a.ColorsList.prototype.onColorUpdated_=function(a){var b=a.toRgbString();this.colorPreviewEl.style.background=b,this.palette&&(this.palette.set(this.selectedIndex,b),this.refreshColorElement_(this.selectedIndex))},a.ColorsList.prototype.onPaletteColorClick_=function(a,b){var c=parseInt(b.dataset.paletteIndex,10);this.selectColor_(c)},a.ColorsList.prototype.onRemoveColorClick_=function(a,b){var c=b.parentNode,d=parseInt(c.dataset.paletteIndex,10);this.removeColor_(d)},a.ColorsList.prototype.onNewColorClick_=function(a,b){var c=this.palette.get(this.selectedIndex)||"#000000";this.palette.add(c),this.selectColor_(this.palette.size()-1)},a.ColorsList.prototype.refresh_=function(){var a="",b=pskl.utils.Template.get("create-palette-color-template"),c=this.palette.getColors();c.forEach(function(c,d){var e=d===this.selectedIndex;a+=pskl.utils.Template.replace(b,{color:c,index:d,":selected":e,":light-color":this.isLight_(c)})}.bind(this)),a+='
  • +
  • ',this.colorsList.innerHTML=a},a.ColorsList.prototype.selectColor_=function(a){this.selectedIndex=a,this.hslRgbColorPicker.setColor(this.palette.get(a))},a.ColorsList.prototype.removeColor_=function(a){this.palette.removeAt(a),this.refresh_()},a.ColorsList.prototype.isLight_=function(a){var b=window.tinycolor(a).toRgb();return b.r+b.b+b.g>384},a.ColorsList.prototype.onColorDrop_=function(a,b){var c=b.item.get(0),d=parseInt(c.dataset.paletteIndex,10),e=$(".create-palette-color").index(b.item);this.palette.move(d,e),this.selectedIndex=e,this.refresh_()}}(),function(){var a=$.namespace("pskl.widgets");a.HslRgbColorPicker=function(a,b){this.container=a,this.colorUpdatedCallback=b,this.tinyColor=null,this.hsvColor=null,this.rgbColor=null,this.lastInputTimestamp_=0},a.HslRgbColorPicker.prototype.init=function(){var a=pskl.utils.UserAgent.isChrome||pskl.utils.UserAgent.isFirefox,b=a?"input":"change";this.container.addEventListener(b,this.onPickerChange_.bind(this)),this.container.addEventListener("keydown",this.onKeydown_.bind(this)),this.container.addEventListener("focusout",this.onBlur_.bind(this)),this.spectrumEl=this.container.querySelector(".color-picker-spectrum"),$(this.spectrumEl).spectrum({flat:!0,showButtons:!1,move:this.setColor.bind(this),change:this.setColor.bind(this)}),this.setColor("#000000")},a.HslRgbColorPicker.prototype.destroy=function(){this.container=null,this.spectrumEl=null},a.HslRgbColorPicker.prototype.onPickerChange_=function(a){var b=a.target;if(b.dataset.dimension){var c=b.dataset.model,d=b.dataset.dimension,e=b.value;this.updateColor_(e,c,d)}},a.HslRgbColorPicker.prototype.onKeydown_=function(a){var b=a.target,c="text"===b.getAttribute("type").toLowerCase();if(c&&b.dataset.dimension){var d=b.dataset.model;if("rgb"===d||"hsv"===d){var e=this.getIncrement_(a);if(e){var f=b.dataset.dimension,g=parseInt(b.value,10);this.updateColor_(g+e,d,f)}}}},a.HslRgbColorPicker.prototype.getIncrement_=function(a){var b=0,c=pskl.service.keyboard.KeycodeTranslator.toChar(a.keyCode);return"up"===c?b=1:"down"===c&&(b=-1),a.shiftKey&&(b=5*b),b},a.HslRgbColorPicker.prototype.updateColor_=function(a,b,c){var d=this.toModelValue_(a,b,c);if("hsv"===b||"rgb"===b){if(!isNaN(d)){var e=this.getColor_(b);e[c]=this.normalizeDimension_(d,c),this.setColor(e)}}else"hex"===b&&/^#([a-f0-9]{3}) {1,2}$/i.test(d)&&this.setColor(d)},a.HslRgbColorPicker.prototype.onBlur_=function(a){var b=a.target,c="text"===b.getAttribute("type").toLowerCase();if(c&&b.dataset.dimension){var d=b.dataset.model,e=b.dataset.dimension;b.value=this.toInputValue_(d,e)}},a.HslRgbColorPicker.prototype.setColor=function(a){this.unplugged||(this.unplugged=!0,this.hsvColor=this.toHsvColor_(a),this.tinyColor=this.toTinyColor_(a),this.rgbColor=this.tinyColor.toRgb(),this.updateInputs(),$(".color-picker-spectrum").spectrum("set",this.tinyColor),this.colorUpdatedCallback(this.tinyColor),this.unplugged=!1)},a.HslRgbColorPicker.prototype.updateInputs=function(){for(var a=this.container.querySelectorAll("input"),b=0;b";this.piskelController=a},a.LocalStorageService.prototype.init=function(){},a.LocalStorageService.prototype.save=function(a,b,c){this.removeFromKeys_(a),this.addToKeys_(a,b,Date.now()),window.localStorage.setItem("piskel."+a,c)},a.LocalStorageService.prototype.load=function(a){var b=this.getPiskel(a),c=(this.getKey_(a),JSON.parse(b)),d=c.piskel.fps,e=c.piskel.description;pskl.utils.serialization.Deserializer.deserialize(c,function(b){b.setDescriptor(new pskl.model.piskel.Descriptor(a,e,!0)),pskl.app.piskelController.setPiskel(b),pskl.app.previewController.setFPS(d)})},a.LocalStorageService.prototype.remove=function(a){this.removeFromKeys_(a),window.localStorage.removeItem("piskel."+a)},a.LocalStorageService.prototype.saveKeys_=function(a){window.localStorage.setItem("piskel.keys",JSON.stringify(a))},a.LocalStorageService.prototype.removeFromKeys_=function(a){var b=this.getKeys(),c=b.filter(function(b){return b.name!==a});this.saveKeys_(c)},a.LocalStorageService.prototype.getKey_=function(a){var b=this.getKeys().filter(function(b){return b.name===a});return b.length>0?b[0]:null},a.LocalStorageService.prototype.addToKeys_=function(a,b,c){var d=this.getKeys();d.push({name:a,description:b,date:c}),this.saveKeys_(d)},a.LocalStorageService.prototype.getPiskel=function(a){return window.localStorage.getItem("piskel."+a)},a.LocalStorageService.prototype.getKeys=function(a){var b=window.localStorage.getItem("piskel.keys");return JSON.parse(b)||[]}}(),function(){var a=$.namespace("pskl.service");a.GithubStorageService=function(a){this.piskelController=a},a.GithubStorageService.prototype.init=function(){},a.GithubStorageService.prototype.store=function(a){throw"Github save is no longer available. Use local save instead"}}(),function(){var a=$.namespace("pskl.service");a.AppEngineStorageService=function(a){this.piskelController=a},a.AppEngineStorageService.prototype.init=function(){},a.AppEngineStorageService.prototype.store=function(a){var b=this.piskelController.getPiskel(),c=b.getDescriptor(),d={framesheet:this.piskelController.serialize(),fps:this.piskelController.getFPS(),name:c.name,description:c.description,frames:this.piskelController.getFrameCount(),first_frame_as_png:pskl.app.getFirstFrameAsPng(),framesheet_as_png:pskl.app.getFramesheetAsPng()};c.isPublic&&(d["public"]=!0);var e=function(){a.success(),a.after()},f=function(b){a.error(b.status),a.after()};pskl.utils.Xhr.post(Constants.APPENGINE_SAVE_URL,d,e,f)}}(),function(){var a=$.namespace("pskl.service");a.DesktopStorageService=function(a){this.piskelController=a||pskl.app.piskelController,this.hideNotificationTimeoutID=0},a.DesktopStorageService.prototype.init=function(){pskl.utils.Environment.detectNodeWebkit()&&(pskl.app.shortcutService.addShortcut("ctrl+o",this.openPiskel.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+s",this.save.bind(this)),pskl.app.shortcutService.addShortcut("ctrl+shift+s",this.savePiskelAs.bind(this)))},a.DesktopStorageService.prototype.save=function(){var a=this.piskelController.getSavePath();a?this.savePiskel(a):this.savePiskelAs()},a.DesktopStorageService.prototype.savePiskel=function(a){var b=this.piskelController.serialize();pskl.utils.FileUtilsDesktop.saveToFile(b,a,function(){this.onSaveSuccess_()}.bind(this))},a.DesktopStorageService.prototype.openPiskel=function(){pskl.utils.FileUtilsDesktop.chooseFileDialog(function(a){var b=a;pskl.utils.FileUtilsDesktop.readFile(b,function(a){pskl.utils.PiskelFileUtils.decodePiskelFile(a,function(a,c,d){a.setDescriptor(c),a.savePath=b,pskl.app.piskelController.setPiskel(a),pskl.app.previewController.setFPS(d)})})})},a.DesktopStorageService.prototype.savePiskelAs=function(){var a=this.piskelController.serialize(),b=this.piskelController.getPiskel().getDescriptor().name;pskl.utils.FileUtilsDesktop.saveAs(a,b,"piskel",function(a){this.piskelController.setSavePath(a);var b=this.extractFilename_(a);if(b){var c=this.piskelController.getPiskel().getDescriptor();c.name=b,this.piskelController.getPiskel().setDescriptor(c)}this.onSaveSuccess_()}.bind(this))},a.DesktopStorageService.prototype.extractFilename_=function(a){var b=/[\/\\]([^\/\\]*)\.piskel$/gi.exec(a);return b&&b[1]?b[1]:void 0},a.DesktopStorageService.prototype.onSaveSuccess_=function(){var a=this.piskelController.getSavePath();$.publish(Events.CLOSE_SETTINGS_DRAWER),$.publish(Events.SHOW_NOTIFICATION,[{content:"Successfully saved: "+a}]),$.publish(Events.PISKEL_SAVED),window.clearTimeout(this.hideNotificationTimeoutID),this.hideNotificationTimeoutID=window.setTimeout($.publish.bind($,Events.HIDE_NOTIFICATION),3e3)}}(),function(){var a=$.namespace("pskl.service"),b=6e4;a.BackupService=function(a){this.piskelController=a,this.lastHash=null},a.BackupService.prototype.init=function(){var a=window.localStorage.getItem("bkp.next.piskel"),c=window.localStorage.getItem("bkp.next.info");a&&c&&this.savePiskel_("prev",a,c),window.setInterval(this.backup.bind(this),b)},a.BackupService.prototype.backup=function(){var a=this.piskelController.getPiskel(),b=a.getDescriptor(),c=a.getHash(),d={name:b.name,description:b.info,fps:this.piskelController.getFPS(),date:Date.now(),hash:c};c!==this.lastHash&&(this.lastHash=c,this.savePiskel_("next",this.piskelController.serialize(),JSON.stringify(d)))},a.BackupService.prototype.getPreviousPiskelInfo=function(){var a=window.localStorage.getItem("bkp.prev.info");return a?JSON.parse(a):void 0},a.BackupService.prototype.load=function(){var a=window.localStorage.getItem("bkp.prev.piskel"),b=window.localStorage.getItem("bkp.prev.info");a=JSON.parse(a),b=JSON.parse(b),pskl.utils.serialization.Deserializer.deserialize(a,function(a){a.setDescriptor(new pskl.model.piskel.Descriptor(b.name,b.description,!0)),pskl.app.piskelController.setPiskel(a),pskl.app.previewController.setFPS(b.fps)})},a.BackupService.prototype.savePiskel_=function(a,b,c){try{window.localStorage.setItem("bkp."+a+".piskel",b),window.localStorage.setItem("bkp."+a+".info",c)}catch(d){console.error("Could not save piskel backup in localStorage.",d)}}}(),function(){var a=$.namespace("pskl.service");a.BeforeUnloadService=function(a){this.piskelController=a},a.BeforeUnloadService.prototype.init=function(){window.addEventListener("beforeunload",this.onBeforeUnload.bind(this))},a.BeforeUnloadService.prototype.onBeforeUnload=function(a){if(pskl.app.backupService.backup(),pskl.app.savedStatusService.isDirty()){var b="Your Piskel seems to have unsaved changes";return(a||window.event).returnValue=b,b}}}(),function(){var a=$.namespace("pskl.service");a.HistoryService=function(a,b,c){this.piskelController=a||pskl.app.piskelController,this.shortcutService=b||pskl.app.shortcutService,this.deserializer=c||pskl.utils.serialization.Deserializer,this.stateQueue=[],this.currentIndex=-1,this.lastLoadState=-1},a.HistoryService.SNAPSHOT="SNAPSHOT",a.HistoryService.REPLAY="REPLAY",a.HistoryService.SNAPSHOT_PERIOD=50,a.HistoryService.LOAD_STATE_INTERVAL=50,a.HistoryService.prototype.init=function(){$.subscribe(Events.PISKEL_SAVE_STATE,this.onSaveStateEvent.bind(this)),this.shortcutService.addShortcut("ctrl+Z",this.undo.bind(this)),this.shortcutService.addShortcut("ctrl+Y",this.redo.bind(this)),this.saveState({type:a.HistoryService.SNAPSHOT})},a.HistoryService.prototype.onSaveStateEvent=function(a,b){this.saveState(b)},a.HistoryService.prototype.saveState=function(b){this.stateQueue=this.stateQueue.slice(0,this.currentIndex+1),this.currentIndex=this.currentIndex+1;var c={action:b,frameIndex:b.state?b.state.frameIndex:this.piskelController.currentFrameIndex,layerIndex:b.state?b.state.layerIndex:this.piskelController.currentLayerIndex},d=b.type===a.HistoryService.SNAPSHOT,e=this.currentIndex%a.HistoryService.SNAPSHOT_PERIOD===0;(d||e)&&(c.piskel=this.piskelController.serialize(!0)),this.stateQueue.push(c),$.publish(Events.HISTORY_STATE_SAVED)},a.HistoryService.prototype.undo=function(){this.loadState(this.currentIndex-1)},a.HistoryService.prototype.redo=function(){this.loadState(this.currentIndex+1)},a.HistoryService.prototype.isLoadStateAllowed_=function(b){var c=Date.now()-this.lastLoadState>a.HistoryService.LOAD_STATE_INTERVAL,d=b>=0&&bb)throw"Could not find previous SNAPSHOT saved in history stateQueue";var c=this.getSnapshotFromState_(b),d=this.onPiskelLoaded_.bind(this,a,b);this.deserializer.deserialize(c,d)}}catch(e){console.error("[CRITICAL ERROR] : Unable to load a history state."),this.logError_(e),this.stateQueue=[],this.currentIndex=-1}},a.HistoryService.prototype.logError_=function(a){"string"==typeof a?console.error(a):(console.error(a.message),console.error(a.stack))},a.HistoryService.prototype.getSnapshotFromState_=function(a){var b=this.stateQueue[a],c=b.piskel;return"string"==typeof c&&(c=JSON.parse(c),b.piskel=c),c},a.HistoryService.prototype.onPiskelLoaded_=function(a,b,c){var d=this.getPiskelSize_();c.setDescriptor(this.piskelController.piskel.getDescriptor()),c.savePath=this.piskelController.piskel.savePath,this.piskelController.setPiskel(c);for(var e=b+1;a>=e;e++){var f=this.stateQueue[e];this.setupState(f),this.replayState(f)}var g=this.stateQueue[a+1];g&&this.setupState(g),this.currentIndex=a,$.publish(Events.PISKEL_RESET),$.publish(Events.HISTORY_STATE_LOADED),d!==this.getPiskelSize_()&&$.publish(Events.FRAME_SIZE_CHANGED)},a.HistoryService.prototype.getPiskelSize_=function(){return this.piskelController.getWidth()+"x"+this.piskelController.getHeight()},a.HistoryService.prototype.setupState=function(a){this.piskelController.setCurrentFrameIndex(a.frameIndex),this.piskelController.setCurrentLayerIndex(a.layerIndex)},a.HistoryService.prototype.replayState=function(a){var b=a.action,c=(b.type,this.piskelController.getLayerAt(a.layerIndex)),d=c.getFrameAt(a.frameIndex);b.scope.replay(d,b.replay)}}(),function(){for(var a=$.namespace("pskl.service.color"),b=.1,c=.1,d=.9,e=36,f=10,g=[],h=0;f>h;h++)g.push(h*e);a.ColorSorter=function(){this.colorsHslMap_={}},a.ColorSorter.prototype.sort=function(a){this.colorsHslMap_={},a.forEach(function(a){this.colorsHslMap_[a]=window.tinycolor(a).toHsl()}.bind(this));var f=a.filter(function(a){var b=this.colorsHslMap_[a];return b.l<=c}.bind(this)),h=a.filter(function(a){var b=this.colorsHslMap_[a];return b.l>=d}.bind(this)),i=a.filter(function(a){return-1===h.indexOf(a)&&-1===f.indexOf(a)}).filter(function(a){var c=this.colorsHslMap_[a];return c.s<=b}.bind(this));f=this.sortOnHslProperty_(f,"l"),h=this.sortOnHslProperty_(h,"l"),i=this.sortOnHslProperty_(i,"h");var j=f.concat(h,i),k=a.filter(function(a){return-1===j.indexOf(a)}),l=g.map(function(a){var b=k.filter(function(b){var c=this.colorsHslMap_[b];return c.h>=a&&c.he?f>g?this.compareValues_(c.s,d.s):this.compareValues_(c.l,d.l):this.compareValues_(c.h,d.h)}.bind(this));return b},a.ColorSorter.prototype.sortOnHslProperty_=function(a,b){return a.sort(function(a,c){var d=this.colorsHslMap_[a],e=this.colorsHslMap_[c];return this.compareValues_(d[b],e[b])}.bind(this))},a.ColorSorter.prototype.compareValues_=function(a,b){return a>b?1:b>a?-1:0}}(),function(){var a=$.namespace("pskl.service.palette");a.CurrentColorsPalette=function(){this.name="Current colors",this.id=Constants.CURRENT_COLORS_PALETTE_ID,this.colorSorter=new pskl.service.color.ColorSorter},a.CurrentColorsPalette.prototype.getColors=function(){var a=pskl.app.currentColorsService.getCurrentColors();return a=a.slice(0,Constants.MAX_PALETTE_COLORS),this.colorSorter.sort(a)}}(),function(){var a=$.namespace("pskl.service.palette");a.PaletteService=function(){this.dynamicPalettes=[],this.localStorageService=window.localStorage},a.PaletteService.prototype.getPalettes=function(){var a=this.localStorageService.getItem("piskel.palettes"),b=JSON.parse(a)||[];return b=b.map(function(a){return pskl.model.Palette.fromObject(a)}),this.dynamicPalettes.concat(b)},a.PaletteService.prototype.getPaletteById=function(a){var b=this.getPalettes();return this.findPaletteInArray_(a,b)},a.PaletteService.prototype.savePalette=function(a){var b=this.getPalettes(),c=this.findPaletteInArray_(a.id,b);if(c){var d=b.indexOf(c);b.splice(d,1,a)}else b.push(a);this.savePalettes_(b),$.publish(Events.SHOW_NOTIFICATION,[{content:"Palette "+a.name+" successfully saved !"}]),window.setTimeout($.publish.bind($,Events.HIDE_NOTIFICATION),2e3)},a.PaletteService.prototype.addDynamicPalette=function(a){this.dynamicPalettes.push(a)},a.PaletteService.prototype.deletePaletteById=function(a){var b=this.getPalettes(),c=b.filter(function(b){return b.id!==a});this.savePalettes_(c)},a.PaletteService.prototype.savePalettes_=function(a){a=a.filter(function(a){return-1===this.dynamicPalettes.indexOf(a)}.bind(this)),this.localStorageService.setItem("piskel.palettes",JSON.stringify(a)),$.publish(Events.PALETTE_LIST_UPDATED)},a.PaletteService.prototype.findPaletteInArray_=function(a,b){var c=null;return b.forEach(function(b){b.id===a&&(c=b)}),c}}(),function(){var a=$.namespace("pskl.service.palette");a.PaletteGplWriter=function(a){this.palette=a},a.PaletteGplWriter.prototype.write=function(){var a=[];return a.push("GIMP Palette"),a.push("Name: "+this.palette.name),a.push("Columns: 0"),a.push("#"),this.palette.getColors().forEach(function(b){a.push(this.writeColorLine(b))}.bind(this)),a.push("\r\n"),a.join("\r\n")},a.PaletteGplWriter.prototype.writeColorLine=function(a){var b=window.tinycolor(a),c=b.toRgb(),d=[];return d.push(this.padString(c.r,3)),d.push(this.padString(c.g,3)),d.push(this.padString(c.b,3)),d.push("Untitled"),d.join(" ")},a.PaletteGplWriter.prototype.padString=function(a,b){a=a.toString();var c=new Array(1+b-a.length).join(" ");return c+a}}(),function(){var a=$.namespace("pskl.service.palette.reader");a.AbstractPaletteFileReader=function(a,b,c,d){this.file=a,this.onSuccess=b,this.onError=c,this.colorLineRegexp=d},a.AbstractPaletteFileReader.prototype.extractColorFromLine=Constants.ABSTRACT_FUNCTION,a.AbstractPaletteFileReader.prototype.read=function(){pskl.utils.FileUtils.readFile(this.file,this.onFileLoaded_.bind(this))},a.AbstractPaletteFileReader.prototype.onFileLoaded_=function(a){var b=pskl.utils.Base64.toText(a),c=b.match(/[^\r\n]+/g),d=c.filter(function(a){return this.colorLineRegexp.test(a)}.bind(this)),e=d.map(this.extractColorFromLine.bind(this));if(e.length){var f=pskl.utils.Uuid.generate(),g=new pskl.model.Palette(f,this.file.name,e);this.onSuccess(g)}else this.onError()}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^(\s*\d{1,3})(\s*\d{1,3})(\s*\d{1,3})/;a.PaletteGplReader=function(a,c,d){this.superclass.constructor.call(this,a,c,d,b)},pskl.utils.inherit(a.PaletteGplReader,a.AbstractPaletteFileReader),a.PaletteGplReader.prototype.extractColorFromLine=function(a){var c=a.match(b),d=window.tinycolor({r:parseInt(c[1],10),g:parseInt(c[2],10),b:parseInt(c[3],10)});return d.toRgbString()}}(),function(){var a=$.namespace("pskl.service.palette.reader");a.PaletteImageReader=function(a,b,c){this.file=a,this.onSuccess=b,this.onError=c,this.colorSorter_=new pskl.service.color.ColorSorter},a.PaletteImageReader.prototype.read=function(){pskl.utils.FileUtils.readImageFile(this.file,this.onImageLoaded_.bind(this))},a.PaletteImageReader.prototype.onImageLoaded_=function(a){var b=new pskl.worker.imageprocessor.ImageProcessor(a,this.onWorkerSuccess_.bind(this),this.onWorkerStep_.bind(this),this.onWorkerError_.bind(this));$.publish(Events.SHOW_PROGRESS,[{name:"Processing image colors ..."}]),b.process()},a.PaletteImageReader.prototype.onWorkerSuccess_=function(a){var b=a.data,c=b.colorsMap,d=Object.keys(c);if(d.length>Constants.MAX_PALETTE_COLORS)this.onError("Too many colors : "+d.length);else{var e=pskl.utils.Uuid.generate(),f=this.colorSorter_.sort(d),g=new pskl.model.Palette(e,this.file.name+" palette",f);this.onSuccess(g)}$.publish(Events.HIDE_PROGRESS)},a.PaletteImageReader.prototype.onWorkerStep_=function(a){var b=a.data.progress;$.publish(Events.UPDATE_PROGRESS,[{progress:b}])},a.PaletteImageReader.prototype.onWorkerError_=function(a){$.publish(Events.HIDE_PROGRESS),this.onError("Unable to process the image : "+a.data.message)}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})/;a.PalettePalReader=function(a,c,d){this.superclass.constructor.call(this,a,c,d,b)},pskl.utils.inherit(a.PalettePalReader,a.AbstractPaletteFileReader),a.PalettePalReader.prototype.extractColorFromLine=function(a){var c=a.match(b),d="rgb("+c[1]+","+c[2]+","+c[3]+")";return d}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^[A-F0-9]{2}([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})/;a.PaletteTxtReader=function(a,c,d){this.superclass.constructor.call(this,a,c,d,b)},pskl.utils.inherit(a.PaletteTxtReader,a.AbstractPaletteFileReader),a.PaletteTxtReader.prototype.extractColorFromLine=function(a){var c=a.match(b),d="#"+c[1]+c[2]+c[3];return d}}(),function(){var a=$.namespace("pskl.service.palette"),b={gpl:a.reader.PaletteGplReader,pal:a.reader.PalettePalReader,txt:a.reader.PaletteTxtReader,img:a.reader.PaletteImageReader};a.PaletteImportService=function(){},a.PaletteImportService.prototype.read=function(a,b,c){var d=this.getReader_(a,b,c);d?d.read():console.error("Could not find reader for file : %s",a.name)},a.PaletteImportService.prototype.isImage_=function(a){return 0===a.type.indexOf("image")},a.PaletteImportService.prototype.getReader_=function(a,b,c){var d=this.getReaderClass_(a);return d?new d(a,b,c):null},a.PaletteImportService.prototype.getReaderClass_=function(a){var c;if(this.isImage_(a))c=b.img;else{var d=this.getExtension_(a);c=b[d]}return c},a.PaletteImportService.prototype.getExtension_=function(a){var b=a.name.split("."),c=b[b.length-1];return c.toLowerCase()}}(),function(){var a=$.namespace("pskl.service");a.SavedStatusService=function(a){this.piskelController=a},a.SavedStatusService.prototype.init=function(){$.subscribe(Events.TOOL_RELEASED,this.onToolReleased.bind(this)),$.subscribe(Events.PISKEL_RESET,this.onPiskelReset.bind(this)),$.subscribe(Events.PISKEL_SAVED,this.onPiskelSaved.bind(this))},a.SavedStatusService.prototype.onPiskelReset=function(){var a=this.piskelController.getPiskel();a.firstResetDone_?this.updateDirtyStatus(!0):a.firstResetDone_=!0},a.SavedStatusService.prototype.onToolReleased=function(){this.updateDirtyStatus(!0)},a.SavedStatusService.prototype.onPiskelSaved=function(){this.updateDirtyStatus(!1)},a.SavedStatusService.prototype.updateDirtyStatus=function(a){var b=this.piskelController.getPiskel();b.isDirty_!==a&&(b.isDirty_=a,this.updatePiskelName())},a.SavedStatusService.prototype.updatePiskelName=function(){var a=this.piskelController.getPiskel(),b=a.getDescriptor().name;$(".piskel-name").html(a.isDirty_?b+" *":b)},a.SavedStatusService.prototype.isDirty=function(a){var b=this.piskelController.getPiskel();return b.isDirty_}}(),function(){var a=$.namespace("pskl.service.keyboard");a.ShortcutService=function(){this.shortcuts_={}},a.ShortcutService.prototype.init=function(){$(document.body).keydown($.proxy(this.onKeyUp_,this))},a.ShortcutService.prototype.addShortcut=function(a,b){var c=this.parseKey_(a.toLowerCase()),d=c.key,e=c.meta;if(this.shortcuts_[d]=this.shortcuts_[d]||{},this.shortcuts_[d][e]){var f=("normal"!==e?e+" + ":"")+d;console.error("[ShortcutService] >>> Shortcut ["+f+"] already registered")}else this.shortcuts_[d][e]=b},a.ShortcutService.prototype.addShortcuts=function(a,b){a.forEach(function(a){this.addShortcut(a,b)}.bind(this))},a.ShortcutService.prototype.removeShortcut=function(a){var b=this.parseKey_(a.toLowerCase()),c=b.key,d=b.meta;this.shortcuts_[c]=this.shortcuts_[c]||{},this.shortcuts_[c][d]=null},a.ShortcutService.prototype.parseKey_=function(a){var b=this.getMetaKey_({alt:-1!=a.indexOf("alt+"),shift:-1!=a.indexOf("shift+"),ctrl:-1!=a.indexOf("ctrl+")}),c=a.split(/\+(?!$)/);return a=c[c.length-1],{meta:b,key:a}},a.ShortcutService.prototype.getMetaKey_=function(a){var b=[];return["alt","ctrl","shift"].forEach(function(c){a[c]&&b.push(c)}),b.length>0?b.join("+"):"normal"},a.ShortcutService.prototype.onKeyUp_=function(a){if(!this.isInInput_(a)){var b=a.which,c=(a.target.nodeName.toUpperCase(),pskl.service.keyboard.KeycodeTranslator.toChar(b)),d=this.shortcuts_[c];if(d){var e=this.getMetaKey_({alt:this.isAltKeyPressed_(a),shift:this.isShiftKeyPressed_(a),ctrl:this.isCtrlKeyPressed_(a)}),f=d[e];if(f){var g=f(c);g!==!0&&a.preventDefault()}}}},a.ShortcutService.prototype.isInInput_=function(a){var b=a.target.nodeName.toUpperCase();return"INPUT"===b||"TEXTAREA"===b},a.ShortcutService.prototype.isCtrlKeyPressed_=function(a){return pskl.utils.UserAgent.isMac?a.metaKey:a.ctrlKey},a.ShortcutService.prototype.isShiftKeyPressed_=function(a){return a.shiftKey},a.ShortcutService.prototype.isAltKeyPressed_=function(a){return a.altKey}}(),function(){var a={191:"?",8:"back",27:"esc",38:"up",40:"down",46:"del",189:"-",187:"+",188:"<",190:">"},b=$.namespace("pskl.service.keyboard");b.KeycodeTranslator={toChar:function(b){return b>=48&&57>=b?b-48+"":b>=65&&90>=b?(b-65+10).toString(36):a[b]}}}(),function(){var a=$.namespace("pskl.service.keyboard");a.CheatsheetService=function(){this.isDisplayed=!1},a.CheatsheetService.prototype.init=function(){if(this.cheatsheetLinkEl=document.querySelector(".cheatsheet-link"),this.cheatsheetEl=document.getElementById("cheatsheet-wrapper"),!this.cheatsheetEl)throw"cheatsheetEl DOM element could not be retrieved";this.initMarkup_(),pskl.app.shortcutService.addShortcuts(["?","shift+?"],this.toggleCheatsheet_.bind(this)),pskl.utils.Event.addEventListener(document.body,"click",this.onBodyClick_,this),$.subscribe(Events.TOGGLE_HELP,this.toggleCheatsheet_.bind(this)),$.subscribe(Events.ESCAPE,this.onEscape_.bind(this))},a.CheatsheetService.prototype.onBodyClick_=function(a){var b=this.cheatsheetEl.contains(a.target),c=this.cheatsheetLinkEl.contains(a.target);c?this.toggleCheatsheet_():b||this.hideCheatsheet_()},a.CheatsheetService.prototype.toggleCheatsheet_=function(){this.isDisplayed?this.hideCheatsheet_():this.showCheatsheet_()},a.CheatsheetService.prototype.onEscape_=function(){this.isDisplayed&&this.hideCheatsheet_()},a.CheatsheetService.prototype.showCheatsheet_=function(){ -pskl.app.shortcutService.addShortcut("ESC",this.hideCheatsheet_.bind(this)),this.cheatsheetEl.style.display="block",this.isDisplayed=!0},a.CheatsheetService.prototype.hideCheatsheet_=function(){pskl.app.shortcutService.removeShortcut("ESC"),this.cheatsheetEl.style.display="none",this.isDisplayed=!1},a.CheatsheetService.prototype.initMarkup_=function(){this.initMarkupForTools_(),this.initMarkupForMisc_(),this.initMarkupForSelection_()},a.CheatsheetService.prototype.initMarkupForTools_=function(){var a=pskl.app.toolController.tools.map(function(a){return this.toDescriptor_(a.shortcut,a.instance.getHelpText(),"tool-icon "+a.instance.toolId)}.bind(this)),b=this.cheatsheetEl.querySelector(".cheatsheet-tool-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.initMarkupForMisc_=function(){var a=[this.toDescriptor_("0","Reset zoom level"),this.toDescriptor_("+/-","Zoom in/Zoom out"),this.toDescriptor_("X","Swap primary/secondary colors"),this.toDescriptor_("D","Reset default colors"),this.toDescriptor_("ctrl + Z","Undo"),this.toDescriptor_("ctrl + Y","Redo"),this.toDescriptor_("↑","Select previous frame"),this.toDescriptor_("↓","Select next frame"),this.toDescriptor_("N","Create new frame"),this.toDescriptor_("shift + N","Duplicate selected frame"),this.toDescriptor_("shift + ?","Open/Close this popup"),this.toDescriptor_("alt + P","Create a Palette"),this.toDescriptor_("</>","Select previous/next palette color"),this.toDescriptor_("alt + O","Toggle Onion Skin"),this.toDescriptor_("alt + L","Toggle Layer Preview")],b=this.cheatsheetEl.querySelector(".cheatsheet-misc-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.initMarkupForSelection_=function(){var a=[this.toDescriptor_("ctrl + X","Cut selection"),this.toDescriptor_("ctrl + C","Copy selection"),this.toDescriptor_("ctrl + V","Paste selection"),this.toDescriptor_("del","Delete selection")],b=this.cheatsheetEl.querySelector(".cheatsheet-selection-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.toDescriptor_=function(a,b,c){return pskl.utils.UserAgent.isMac&&(a=a.replace("ctrl","cmd")),{shortcut:a,description:b,icon:c}},a.CheatsheetService.prototype.initMarkupForDescriptors_=function(a,b){a.forEach(function(a){var c=this.getDomFromDescriptor_(a);b.appendChild(c)}.bind(this))},a.CheatsheetService.prototype.getDomFromDescriptor_=function(a){var b=pskl.utils.Template.get("cheatsheet-shortcut-template"),c=pskl.utils.Template.replace(b,{shortcutIcon:a.icon,shortcutDescription:a.description,shortcutKey:a.shortcut});return pskl.utils.Template.createFromHTML(c)}}(),function(){var a=$.namespace("pskl.service");a.ImageUploadService=function(){},a.ImageUploadService.prototype.init=function(){},a.ImageUploadService.prototype.upload=function(a,b,c){var d={data:a},e=function(a){b(Constants.IMAGE_SERVICE_GET_URL+a.responseText)};pskl.utils.Xhr.post(Constants.IMAGE_SERVICE_UPLOAD_URL,d,e,c)}}(),function(){var a=$.namespace("pskl.service");a.CurrentColorsService=function(a){this.piskelController=a,this.cache={},this.currentColors=[],this.cachedFrameProcessor=new pskl.model.frame.AsyncCachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.getFrameColors_.bind(this)),this.paletteService=pskl.app.paletteService},a.CurrentColorsService.prototype.init=function(){$.subscribe(Events.HISTORY_STATE_SAVED,this.updateCurrentColors_.bind(this)),$.subscribe(Events.HISTORY_STATE_LOADED,this.loadColorsFromCache_.bind(this))},a.CurrentColorsService.prototype.getCurrentColors=function(){return this.currentColors},a.CurrentColorsService.prototype.setCurrentColors=function(a){var b=pskl.app.historyService.currentIndex;this.cache[b]=a,a.join("")!==this.currentColors.join("")&&(this.currentColors=a,$.publish(Events.CURRENT_COLORS_UPDATED))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b?this.setCurrentColors(b):this.updateCurrentColors_()},a.CurrentColorsService.prototype.updateCurrentColors_=function(){var a=this.piskelController.getLayers(),b=a.map(function(a){return a.getFrames()}).reduce(function(a,b){return a.concat(b)});Q.all(b.map(function(a){return this.cachedFrameProcessor.get(a)}.bind(this))).done(function(a){var b={};a.forEach(function(a){Object.keys(a).forEach(function(a){b[a]=!0})}),delete b[Constants.TRANSPARENT_COLOR],this.setCurrentColors(Object.keys(b))}.bind(this))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b&&b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b&&this.setCurrentColors(b)},a.CurrentColorsService.prototype.getFrameColors_=function(a,b){var c=new pskl.worker.framecolors.FrameColors(a,function(a){b(a.data.colors)},function(){},function(a){b({})});c.process()}}(),function(){var a=$.namespace("pskl.service");a.FileDropperService=function(a,b){this.piskelController=a,this.drawingAreaContainer=b,this.dropPosition_=null},a.FileDropperService.prototype.init=function(){document.body.addEventListener("drop",this.onFileDrop.bind(this),!1),document.body.addEventListener("dragover",this.onFileDragOver.bind(this),!1)},a.FileDropperService.prototype.onFileDragOver=function(a){a.stopPropagation(),a.preventDefault(),a.dataTransfer.dropEffect="copy"},a.FileDropperService.prototype.onFileDrop=function(a){a.preventDefault(),a.stopPropagation(),this.dropPosition_={x:a.clientX,y:a.clientY};for(var b=a.dataTransfer.files,c=0;ca?1:-1,i=d>c?1:-1,j=f-g;;){if(e.push({col:a,row:c}),a==b&&c==d)break;var k=2*j;k>-g&&(j-=g,a+=h),f>k&&(j+=f,c+=i)}return e}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ShapeTool=function(){this.startCol=null,this.startRow=null,this.tooltipDescriptors=[{key:"shift",description:"Keep 1 to 1 ratio"}]},pskl.utils.inherit(a.ShapeTool,a.BaseTool),a.ShapeTool.prototype.applyToolAt=function(a,b,c,d,e,f){$.publish(Events.DRAG_START,[a,b]),this.startCol=a,this.startRow=b,e.setPixel(a,b,c)},a.ShapeTool.prototype.moveToolAt=function(a,b,c,d,e,f){var g=this.getCoordinates_(a,b,f);$.publish(Events.CURSOR_MOVED,[g.col,g.row]),e.clear(),c==Constants.TRANSPARENT_COLOR&&(c=Constants.SELECTION_TRANSPARENT_COLOR),this.draw_(g.col,g.row,c,e)},a.ShapeTool.prototype.releaseToolAt=function(a,b,c,d,e,f){e.clear();var g=this.getCoordinates_(a,b,f);this.draw_(g.col,g.row,c,d),$.publish(Events.DRAG_END,[g.col,g.row]),this.raiseSaveStateEvent({col:g.col,row:g.row,startCol:this.startCol,startRow:this.startRow,color:c})},a.ShapeTool.prototype.replay=function(a,b){this.startCol=b.startCol,this.startRow=b.startRow,this.draw_(b.col,b.row,b.color,a)},a.ShapeTool.prototype.getCoordinates_=function(a,b,c){return c.shiftKey?this.getScaledCoordinates_(a,b):{col:a,row:b}},a.ShapeTool.prototype.getScaledCoordinates_=function(a,b){var c=this.startCol-a,d=Math.abs(c),e=this.startRow-b,f=Math.abs(e),g=Math.min(d,f);return b=this.startRow-e/f*g,a=this.startCol-c/d*g,{col:a,row:b}},a.ShapeTool.prototype.draw_=Constants.ABSTRACT_FUNCTION}(),function(){var a=$.namespace("pskl.tools.drawing");a.SimplePen=function(){this.toolId="tool-pen",this.helpText="Pen tool",this.previousCol=null,this.previousRow=null,this.pixels=[]},pskl.utils.inherit(a.SimplePen,a.BaseTool),a.SimplePen.prototype.applyToolAt=function(a,b,c,d,e,f){this.previousCol=a,this.previousRow=b,e.setPixel(a,b,c),c===Constants.TRANSPARENT_COLOR&&d.setPixel(a,b,c),this.pixels.push({col:a,row:b,color:c})},a.SimplePen.prototype.moveToolAt=function(a,b,c,d,e,f){if(Math.abs(a-this.previousCol)>1||Math.abs(b-this.previousRow)>1)for(var g=this.getLinePixels_(a,this.previousCol,b,this.previousRow),h=0,i=g.length;i>h;h++){var j=g[h];this.applyToolAt(j.col,j.row,c,d,e,f)}else this.applyToolAt(a,b,c,d,e,f);this.previousCol=a,this.previousRow=b},a.SimplePen.prototype.releaseToolAt=function(a,b,c,d,e,f){this.setPixelsToFrame_(d,this.pixels),this.raiseSaveStateEvent({pixels:this.pixels.slice(0),color:c}),this.resetUsedPixels_()},a.SimplePen.prototype.replay=function(a,b){this.setPixelsToFrame_(a,b.pixels,b.color)},a.SimplePen.prototype.setPixelsToFrame_=function(a,b,c){b.forEach(function(b){a.setPixel(b.col,b.row,b.color)})},a.SimplePen.prototype.resetUsedPixels_=function(){this.pixels=[]}}(),function(){var a=$.namespace("pskl.tools.drawing"),b=3;a.Lighten=function(){this.superclass.constructor.call(this),this.toolId="tool-lighten",this.helpText="Lighten",this.tooltipDescriptors=[{key:"ctrl",description:"Darken"},{key:"shift",description:"Apply only once per pixel"}],this.usedPixels_={darken:{},lighten:{}}},pskl.utils.inherit(a.Lighten,a.SimplePen),a.Lighten.prototype.resetUsedPixels_=function(){this.usedPixels_={darken:{},lighten:{}},this.superclass.resetUsedPixels_.call(this)},a.Lighten.prototype.applyToolAt=function(a,c,d,e,f,g,h){var i=f.getPixel(a,c),j=e.getPixel(a,c),k=i===Constants.TRANSPARENT_COLOR?j:i,l=pskl.utils.UserAgent.isMac?g.metaKey:g.ctrlKey,m=g.shiftKey,n=k===Constants.TRANSPARENT_COLOR,o=l?this.usedPixels_.darken:this.usedPixels_.lighten,p=a+"-"+c,q=n||m&&o[p];if(q)d=window.tinycolor(k);else{var r=m?2*b:b;d=l?window.tinycolor.darken(k,r):window.tinycolor.lighten(k,r)}d&&(o[p]=!0,this.superclass.applyToolAt.call(this,a,c,d.toRgbString(),e,f,g))}}(),function(){var a=$.namespace("pskl.tools.drawing");a.VerticalMirrorPen=function(){this.superclass.constructor.call(this),this.toolId="tool-vertical-mirror-pen",this.helpText="Vertical Mirror pen",this.tooltipDescriptors=[{key:"ctrl",description:"Use horizontal axis"},{key:"shift",description:"Use horizontal and vertical axis"}]},pskl.utils.inherit(a.VerticalMirrorPen,a.SimplePen),a.VerticalMirrorPen.prototype.backupPreviousPositions_=function(){this.backupPreviousCol=this.previousCol,this.backupPreviousRow=this.previousRow},a.VerticalMirrorPen.prototype.restorePreviousPositions_=function(){this.previousCol=this.backupPreviousCol,this.previousRow=this.backupPreviousRow},a.VerticalMirrorPen.prototype.applyToolAt=function(a,b,c,d,e,f){this.superclass.applyToolAt.call(this,a,b,c,d,e),this.backupPreviousPositions_();var g=this.getSymmetricCol_(a,d),h=this.getSymmetricRow_(b,d),i=pskl.utils.UserAgent.isMac?f.metaKey:f.ctrlKey;i||this.superclass.applyToolAt.call(this,g,b,c,d,e),(f.shiftKey||i)&&this.superclass.applyToolAt.call(this,a,h,c,d,e),f.shiftKey&&this.superclass.applyToolAt.call(this,g,h,c,d,e),this.restorePreviousPositions_()},a.VerticalMirrorPen.prototype.getSymmetricCol_=function(a,b){return b.getWidth()-a-1},a.VerticalMirrorPen.prototype.getSymmetricRow_=function(a,b){return b.getHeight()-a-1}}(),function(){var a=$.namespace("pskl.tools.drawing");a.Eraser=function(){this.superclass.constructor.call(this),this.toolId="tool-eraser",this.helpText="Eraser tool"},pskl.utils.inherit(a.Eraser,a.SimplePen),a.Eraser.prototype.applyToolAt=function(a,b,c,d,e,f){this.superclass.applyToolAt.call(this,a,b,Constants.TRANSPARENT_COLOR,d,e,f)},a.Eraser.prototype.releaseToolAt=function(a,b,c,d,e,f){this.superclass.releaseToolAt.call(this,a,b,Constants.TRANSPARENT_COLOR,d,e,f)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.Stroke=function(){this.toolId="tool-stroke",this.helpText="Stroke tool",this.startCol=null,this.startRow=null},pskl.utils.inherit(a.Stroke,a.BaseTool),a.Stroke.prototype.applyToolAt=function(a,b,c,d,e,f){this.startCol=a,this.startRow=b,e.setPixel(a,b,c)},a.Stroke.prototype.moveToolAt=function(a,b,c,d,e,f){e.clear();for(var g=this.getLinePixels_(this.startCol,a,this.startRow,b),h=0;hi;i++)for(var j=0;h>j;j++){var k=i-a,l=j-b;e.shiftKey&&(k=(k+g)%g,l=(l+h)%h),f=d.containsPixel(k,l)?d.getPixel(k,l):Constants.TRANSPARENT_COLOR,c.setPixel(i,j,f)}},a.Move.prototype.releaseToolAt=function(a,b,c,d,e,f){this.moveToolAt(a,b,c,d,e,f),this.raiseSaveStateEvent({colDiff:a-this.startCol,rowDiff:b-this.startRow,shiftKey:f.shiftKey})},a.Move.prototype.replay=function(a,b){var c={shiftKey:b.shiftKey};this.shiftFrame(b.colDiff,b.rowDiff,a,a.clone(),c)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.BaseSelect=function(){this.secondaryToolId=pskl.tools.drawing.Move.TOOL_ID,this.BodyRoot=$("body"),this.startCol=null,this.startRow=null,this.selection=null,this.tooltipDescriptors=[{description:"Drag the selection to move it. You may switch to other layers and frames."},{key:"ctrl+c",description:"Copy the selected area"},{key:"ctrl+v",description:"Paste the copied area"}]},pskl.utils.inherit(a.BaseSelect,a.BaseTool),a.BaseSelect.prototype.applyToolAt=function(a,b,c,d,e,f){this.startCol=a,this.startRow=b,this.lastCol=a,this.lastRow=b,this.isInSelection(a,b)?(this.mode="moveSelection",this.onSelectionDragStart_(a,b,c,d,e)):(this.mode="select",this.onSelectStart_(a,b,c,d,e))},a.BaseSelect.prototype.moveToolAt=function(a,b,c,d,e,f){"select"==this.mode?this.onSelect_(a,b,c,d,e):"moveSelection"==this.mode&&this.onSelectionDrag_(a,b,c,d,e)},a.BaseSelect.prototype.releaseToolAt=function(a,b,c,d,e,f){"select"==this.mode?this.onSelectEnd_(a,b,c,d,e):"moveSelection"==this.mode&&this.onSelectionDragEnd_(a,b,c,d,e)},a.BaseSelect.prototype.moveUnactiveToolAt=function(a,b,c,d,e,f){e.containsPixel(a,b)&&(this.isInSelection(a,b)?(this.BodyRoot.addClass(this.secondaryToolId),this.BodyRoot.removeClass(this.toolId)):(this.BodyRoot.addClass(this.toolId),this.BodyRoot.removeClass(this.secondaryToolId)))},a.BaseSelect.prototype.isInSelection=function(a,b){return this.selection&&this.selection.pixels.some(function(c){return c.col===a&&c.row===b})},a.BaseSelect.prototype.hideHighlightedPixel=function(){},a.BaseSelect.prototype.drawSelectionOnOverlay_=function(a){for(var b=this.selection.pixels,c=0,d=b.length;d>c;c++){var e=b[c],f=e.color&&e.color!==Constants.TRANSPARENT_COLOR,g=f?this.getTransparentVariant(e.color):Constants.SELECTION_TRANSPARENT_COLOR;a.setPixel(b[c].col,b[c].row,g)}},a.BaseSelect.prototype.getTransparentVariant=function(a){var b=window.tinycolor(a);return b=window.tinycolor.lighten(b,10),b.setAlpha(.5),b.toRgbString()},a.BaseSelect.prototype.onSelectStart_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelect_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectEnd_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectionDragStart_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectionDrag_=function(a,b,c,d,e){{var f=a-this.lastCol,g=b-this.lastRow;a-this.startCol,b-this.startRow}this.selection.move(f,g),e.clear(),this.drawSelectionOnOverlay_(e),this.lastCol=a,this.lastRow=b},a.BaseSelect.prototype.onSelectionDragEnd_=function(a,b,c,d,e){this.onSelectionDrag_(a,b,c,d,e)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.RectangleSelect=function(){this.toolId="tool-rectangle-select",this.helpText="Rectangle selection",a.BaseSelect.call(this),this.hasSelection=!1},pskl.utils.inherit(a.RectangleSelect,a.BaseSelect),a.RectangleSelect.prototype.onSelectStart_=function(a,b,c,d,e){this.hasSelection?(this.hasSelection=!1,e.clear(),$.publish(Events.SELECTION_DISMISSED)):(this.hasSelection=!0,$.publish(Events.DRAG_START,[a,b]),e.setPixel(a,b,c))},a.RectangleSelect.prototype.onSelect_=function(a,b,c,d,e){this.hasSelection&&(e.clear(),this.selection=new pskl.selection.RectangularSelection(this.startCol,this.startRow,a,b),$.publish(Events.SELECTION_CREATED,[this.selection]),this.drawSelectionOnOverlay_(e))},a.RectangleSelect.prototype.onSelectEnd_=function(a,b,c,d,e){this.hasSelection&&(this.onSelect_(a,b,c,d,e),$.publish(Events.DRAG_END,[a,b]))}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ShapeSelect=function(){this.toolId="tool-shape-select",this.helpText="Shape selection",a.BaseSelect.call(this)},pskl.utils.inherit(a.ShapeSelect,a.BaseSelect),a.ShapeSelect.prototype.onSelectStart_=function(a,b,c,d,e){$.publish(Events.SELECTION_DISMISSED),e.clear();var f=pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(d,a,b);this.selection=new pskl.selection.ShapeSelection(f),$.publish(Events.SELECTION_CREATED,[this.selection]),this.drawSelectionOnOverlay_(e)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ColorPicker=function(){this.toolId="tool-colorpicker",this.helpText="Color picker"},pskl.utils.inherit(a.ColorPicker,a.BaseTool),a.ColorPicker.prototype.applyToolAt=function(a,b,c,d,e,f){if(d.containsPixel(a,b)){var g=d.getPixel(a,b);f.button==Constants.LEFT_BUTTON?$.publish(Events.SELECT_PRIMARY_COLOR,[g]):f.button==Constants.RIGHT_BUTTON&&$.publish(Events.SELECT_SECONDARY_COLOR,[g])}}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ColorSwap=function(){this.toolId="tool-colorswap",this.helpText="Paint all pixels of the same color",this.tooltipDescriptors=[{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.ColorSwap,a.BaseTool),a.ColorSwap.prototype.applyToolAt=function(a,b,c,d,e,f){if(d.containsPixel(a,b)){var g=d.getPixel(a,b),h=pskl.utils.UserAgent.isMac?f.metaKey:f.ctrlKey,i=f.shiftKey;this.swapColors(g,c,h,i),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}},a.ColorSwap.prototype.swapColors=function(a,b,c,d){var e=function(c,d,e,f){c==a&&(f.pixels[d][e]=b)},f=pskl.app.piskelController.getCurrentLayer(),g=pskl.app.piskelController.getCurrentFrameIndex();pskl.app.piskelController.getPiskel().getLayers().forEach(function(a){(c||a===f)&&a.getFrames().forEach(function(a,b){(d||b===g)&&(a.forEachPixel(e),a.version++)})})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Transform=function(){this.toolId="tool-transform",this.helpText="Transform tool",this.tooltipDescriptors=[]},pskl.utils.inherit(a.Transform,pskl.tools.Tool),a.Transform.prototype.apply=function(a){var b=a.shiftKey,c=a.ctrlKey;this.applyTool_(a.altKey,b,c)},a.Transform.prototype.applyTool_=function(a,b,c){var d=pskl.app.piskelController.getCurrentFrameIndex(),e=c?pskl.app.piskelController.getLayers():[pskl.app.piskelController.getCurrentLayer()];e.forEach(function(c){var e=b?c.getFrames():[c.getFrameAt(d)];e.forEach(function(b){this.applyToolOnFrame_(b,a)}.bind(this))}.bind(this)),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Clone=function(){this.toolId="tool-clone",this.helpText="Clone current layer to all frames",this.tooltipDescriptors=[]},pskl.utils.inherit(a.Clone,a.Transform),a.Clone.prototype.apply=function(a){var b=pskl.app.piskelController.getCurrentFrame(),c=pskl.app.piskelController.getCurrentLayer();c.getFrames().forEach(function(a){a!==b&&a.setPixels(b.getPixels())}),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Flip=function(){this.toolId="tool-flip",this.helpText="Flip vertically",this.tooltipDescriptors=[{key:"alt",description:"Flip horizontally"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Flip,a.Transform),a.Flip.prototype.applyToolOnFrame_=function(a,b){var c;c=b?pskl.utils.FrameTransform.HORIZONTAL:pskl.utils.FrameTransform.VERTICAL,pskl.utils.FrameTransform.flip(a,c)}}(),function(){var a=$.namespace("pskl.tools.transform");a.Rotate=function(){this.toolId="tool-rotate",this.helpText="Counter-clockwise rotation",this.tooltipDescriptors=[{key:"alt",description:"Clockwise rotation"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Rotate,a.Transform),a.Rotate.prototype.applyToolOnFrame_=function(a,b){var c;c=b?pskl.utils.FrameTransform.CLOCKWISE:pskl.utils.FrameTransform.COUNTERCLOCKWISE,pskl.utils.FrameTransform.rotate(a,c)}}(),function(){var a=$.namespace("pskl.worker.framecolors");if("rgba(0, 0, 0, 0)"!==Constants.TRANSPARENT_COLOR)throw"Constants.TRANSPARENT_COLOR, please update FrameColorsWorker";a.FrameColorsWorker=function(){var a="rgba(0, 0, 0, 0)",b=function(b){if(b===a)return b;b=b.replace(/\s/g,"");var d=/^#([a-f0-9]{3}){1,2}$/i,e=/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i;if(d.test(b))return b.toUpperCase();if(e.test(b)){var f=e.exec(b);return c(1*f[1],1*f[2],1*f[3])}},c=function(a,b,c){return"#"+d(a)+d(b)+d(c)},d=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b},e=function(a){for(var c={},d=0;dc;c++){var e=a.charCodeAt(c);b=(b<<5)-b+e,b|=0}return b};this.onmessage=function(b){try{var c=b.data,d=c.str,e=a(d);this.postMessage({type:"SUCCESS",hash:e})}catch(f){this.postMessage({type:"ERROR",message:f.message})}}}}(),function(){var a=$.namespace("pskl.worker.hash");a.Hash=function(b,c,d,e){this.str=b,this.onStep=d,this.onSuccess=c,this.onError=e,this.worker=pskl.utils.WorkerUtils.createWorker(a.HashWorker,"hash"),this.worker.onmessage=this.onWorkerMessage.bind(this)},a.Hash.prototype.process=function(){this.worker.postMessage({str:this.str})},a.Hash.prototype.onWorkerMessage=function(a){"STEP"===a.data.type?this.onStep(a):"SUCCESS"===a.data.type?(this.onSuccess(a),this.worker.terminate()):"ERROR"===a.data.type&&(this.onError(a),this.worker.terminate())}}(),function(){var a=$.namespace("pskl.worker.imageprocessor");a.ImageProcessorWorker=function(){var a,b,c,d=function(d){a=0,b=0,c=d},e=function(){a+=1;var d=(a/c*100).toFixed(1);d!=b&&(b=d,this.postMessage({type:"STEP",progress:b,currentStep:a,total:c}))},f=function(a,b,c){return"#"+g(a)+g(b)+g(c)},g=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b},h=function(a,b,c,d){for(var g=[],h=0;b>h;h++){g[h]=[],e();for(var i=0;c>i;i++){var j=4*(i*b+h),k=a[j],l=a[j+1],m=a[j+2],n=a[j+3];125>n?g[h][i]=d:g[h][i]=f(k,l,m)}}return g},i=function(a,b,c){for(var d=h(a,b,c,"transparent"),f={},g=0;gConstants.MAX_PALETTE_COLORS)this.onError("Too many colors : "+d.length);else{var e=pskl.utils.Uuid.generate(),f=this.colorSorter_.sort(d),g=new pskl.model.Palette(e,this.file.name+" palette",f);this.onSuccess(g)}$.publish(Events.HIDE_PROGRESS)},a.PaletteImageReader.prototype.onWorkerStep_=function(a){var b=a.data.progress;$.publish(Events.UPDATE_PROGRESS,[{progress:b}])},a.PaletteImageReader.prototype.onWorkerError_=function(a){$.publish(Events.HIDE_PROGRESS),this.onError("Unable to process the image : "+a.data.message)}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})/;a.PalettePalReader=function(a,c,d){this.superclass.constructor.call(this,a,c,d,b)},pskl.utils.inherit(a.PalettePalReader,a.AbstractPaletteFileReader),a.PalettePalReader.prototype.extractColorFromLine=function(a){var c=a.match(b),d="rgb("+c[1]+","+c[2]+","+c[3]+")";return d}}(),function(){var a=$.namespace("pskl.service.palette.reader"),b=/^[A-F0-9]{2}([A-F0-9]{2})([A-F0-9]{2})([A-F0-9]{2})/;a.PaletteTxtReader=function(a,c,d){this.superclass.constructor.call(this,a,c,d,b)},pskl.utils.inherit(a.PaletteTxtReader,a.AbstractPaletteFileReader),a.PaletteTxtReader.prototype.extractColorFromLine=function(a){var c=a.match(b),d="#"+c[1]+c[2]+c[3];return d}}(),function(){var a=$.namespace("pskl.service.palette"),b={gpl:a.reader.PaletteGplReader,pal:a.reader.PalettePalReader,txt:a.reader.PaletteTxtReader,img:a.reader.PaletteImageReader};a.PaletteImportService=function(){},a.PaletteImportService.prototype.read=function(a,b,c){var d=this.getReader_(a,b,c);d?d.read():console.error("Could not find reader for file : %s",a.name)},a.PaletteImportService.prototype.isImage_=function(a){return 0===a.type.indexOf("image")},a.PaletteImportService.prototype.getReader_=function(a,b,c){var d=this.getReaderClass_(a);return d?new d(a,b,c):null},a.PaletteImportService.prototype.getReaderClass_=function(a){var c;if(this.isImage_(a))c=b.img;else{var d=this.getExtension_(a);c=b[d]}return c},a.PaletteImportService.prototype.getExtension_=function(a){var b=a.name.split("."),c=b[b.length-1];return c.toLowerCase()}}(),function(){var a=$.namespace("pskl.service");a.SavedStatusService=function(a){this.piskelController=a},a.SavedStatusService.prototype.init=function(){$.subscribe(Events.TOOL_RELEASED,this.onToolReleased.bind(this)),$.subscribe(Events.PISKEL_RESET,this.onPiskelReset.bind(this)),$.subscribe(Events.PISKEL_SAVED,this.onPiskelSaved.bind(this))},a.SavedStatusService.prototype.onPiskelReset=function(){var a=this.piskelController.getPiskel();a.firstResetDone_?this.updateDirtyStatus(!0):a.firstResetDone_=!0},a.SavedStatusService.prototype.onToolReleased=function(){this.updateDirtyStatus(!0)},a.SavedStatusService.prototype.onPiskelSaved=function(){this.updateDirtyStatus(!1)},a.SavedStatusService.prototype.updateDirtyStatus=function(a){var b=this.piskelController.getPiskel();b.isDirty_!==a&&(b.isDirty_=a,this.updatePiskelName())},a.SavedStatusService.prototype.updatePiskelName=function(){var a=this.piskelController.getPiskel(),b=a.getDescriptor().name;$(".piskel-name").html(a.isDirty_?b+" *":b)},a.SavedStatusService.prototype.isDirty=function(a){var b=this.piskelController.getPiskel();return b.isDirty_}}(),function(){var a=$.namespace("pskl.service.keyboard");a.ShortcutService=function(){this.shortcuts_={}},a.ShortcutService.prototype.init=function(){$(document.body).keydown($.proxy(this.onKeyUp_,this))},a.ShortcutService.prototype.addShortcut=function(a,b){var c=this.parseKey_(a.toLowerCase()),d=c.key,e=c.meta;if(this.shortcuts_[d]=this.shortcuts_[d]||{},this.shortcuts_[d][e]){var f=("normal"!==e?e+" + ":"")+d;console.error("[ShortcutService] >>> Shortcut ["+f+"] already registered")}else this.shortcuts_[d][e]=b},a.ShortcutService.prototype.addShortcuts=function(a,b){a.forEach(function(a){this.addShortcut(a,b)}.bind(this))},a.ShortcutService.prototype.removeShortcut=function(a){var b=this.parseKey_(a.toLowerCase()),c=b.key,d=b.meta;this.shortcuts_[c]=this.shortcuts_[c]||{},this.shortcuts_[c][d]=null},a.ShortcutService.prototype.parseKey_=function(a){var b=this.getMetaKey_({alt:-1!=a.indexOf("alt+"),shift:-1!=a.indexOf("shift+"),ctrl:-1!=a.indexOf("ctrl+")}),c=a.split(/\+(?!$)/);return a=c[c.length-1],{meta:b,key:a}},a.ShortcutService.prototype.getMetaKey_=function(a){var b=[];return["alt","ctrl","shift"].forEach(function(c){a[c]&&b.push(c)}),b.length>0?b.join("+"):"normal"},a.ShortcutService.prototype.onKeyUp_=function(a){if(!this.isInInput_(a)){var b=a.which,c=pskl.service.keyboard.KeycodeTranslator.toChar(b),d=this.shortcuts_[c];if(d){var e=this.getMetaKey_({alt:this.isAltKeyPressed_(a),shift:this.isShiftKeyPressed_(a),ctrl:this.isCtrlKeyPressed_(a)}),f=d[e];if(f){var g=f(c);g!==!0&&a.preventDefault(),$.publish(Events.KEYBOARD_EVENT,[a])}}}},a.ShortcutService.prototype.isInInput_=function(a){var b=a.target.nodeName.toUpperCase();return"INPUT"===b||"TEXTAREA"===b},a.ShortcutService.prototype.isCtrlKeyPressed_=function(a){return pskl.utils.UserAgent.isMac?a.metaKey:a.ctrlKey},a.ShortcutService.prototype.isShiftKeyPressed_=function(a){return a.shiftKey},a.ShortcutService.prototype.isAltKeyPressed_=function(a){return a.altKey}}(),function(){var a={191:"?",8:"back",27:"esc",38:"up",40:"down",46:"del",189:"-",109:"-",173:"-",187:"+",107:"+",61:"+",188:"<",190:">"},b=$.namespace("pskl.service.keyboard");b.KeycodeTranslator={toChar:function(b){return b>=48&&57>=b?b-48+"":b>=96&&105>=b?b-96+"":b>=65&&90>=b?(b-65+10).toString(36):a[b]}}}(),function(){var a=$.namespace("pskl.service.keyboard");a.CheatsheetService=function(){this.isDisplayed=!1},a.CheatsheetService.prototype.init=function(){if(this.cheatsheetLinkEl=document.querySelector(".cheatsheet-link"),this.cheatsheetEl=document.getElementById("cheatsheet-wrapper"),!this.cheatsheetEl)throw"cheatsheetEl DOM element could not be retrieved";this.initMarkup_(),pskl.app.shortcutService.addShortcuts(["?","shift+?"],this.toggleCheatsheet_.bind(this)),pskl.utils.Event.addEventListener(document.body,"click",this.onBodyClick_,this),$.subscribe(Events.TOGGLE_HELP,this.toggleCheatsheet_.bind(this)),$.subscribe(Events.ESCAPE,this.onEscape_.bind(this))},a.CheatsheetService.prototype.onBodyClick_=function(a){var b=this.cheatsheetEl.contains(a.target),c=this.cheatsheetLinkEl.contains(a.target);c?this.toggleCheatsheet_():b||this.hideCheatsheet_()},a.CheatsheetService.prototype.toggleCheatsheet_=function(){this.isDisplayed?this.hideCheatsheet_():this.showCheatsheet_()},a.CheatsheetService.prototype.onEscape_=function(){this.isDisplayed&&this.hideCheatsheet_()},a.CheatsheetService.prototype.showCheatsheet_=function(){pskl.app.shortcutService.addShortcut("ESC",this.hideCheatsheet_.bind(this)),this.cheatsheetEl.style.display="block",this.isDisplayed=!0},a.CheatsheetService.prototype.hideCheatsheet_=function(){pskl.app.shortcutService.removeShortcut("ESC"),this.cheatsheetEl.style.display="none",this.isDisplayed=!1},a.CheatsheetService.prototype.initMarkup_=function(){this.initMarkupForTools_(),this.initMarkupForMisc_(),this.initMarkupForColors_(),this.initMarkupForSelection_()},a.CheatsheetService.prototype.initMarkupForTools_=function(){var a=pskl.app.toolController.tools.map(function(a){return this.toDescriptor_(a.shortcut,a.instance.getHelpText(),"tool-icon "+a.instance.toolId)}.bind(this)),b=this.cheatsheetEl.querySelector(".cheatsheet-tool-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.initMarkupForMisc_=function(){var a=[this.toDescriptor_("0","Reset zoom level"),this.toDescriptor_("+/-","Zoom in/Zoom out"),this.toDescriptor_("ctrl + Z","Undo"),this.toDescriptor_("ctrl + Y","Redo"),this.toDescriptor_("↑","Select previous frame"),this.toDescriptor_("↓","Select next frame"),this.toDescriptor_("N","Create new frame"),this.toDescriptor_("shift + N","Duplicate selected frame"),this.toDescriptor_("shift + ?","Open/Close this popup"),this.toDescriptor_("alt + 1","Toggle original size preview"),this.toDescriptor_("alt + O","Toggle Onion Skin"),this.toDescriptor_("alt + L","Toggle Layer Preview")],b=this.cheatsheetEl.querySelector(".cheatsheet-misc-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.initMarkupForColors_=function(){var a=[this.toDescriptor_("X","Swap primary/secondary colors"),this.toDescriptor_("D","Reset default colors"),this.toDescriptor_("alt + P","Create a Palette"),this.toDescriptor_("</>","Select prev/next palette color"),this.toDescriptor_("1 to 9","Select palette color at index")],b=this.cheatsheetEl.querySelector(".cheatsheet-colors-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.initMarkupForSelection_=function(){var a=[this.toDescriptor_("ctrl + X","Cut selection"),this.toDescriptor_("ctrl + C","Copy selection"),this.toDescriptor_("ctrl + V","Paste selection"),this.toDescriptor_("del","Delete selection")],b=this.cheatsheetEl.querySelector(".cheatsheet-selection-shortcuts");this.initMarkupForDescriptors_(a,b)},a.CheatsheetService.prototype.toDescriptor_=function(a,b,c){return pskl.utils.UserAgent.isMac&&(a=a.replace("ctrl","cmd")),{shortcut:a,description:b,icon:c}},a.CheatsheetService.prototype.initMarkupForDescriptors_=function(a,b){a.forEach(function(a){var c=this.getDomFromDescriptor_(a);b.appendChild(c)}.bind(this))},a.CheatsheetService.prototype.getDomFromDescriptor_=function(a){var b=pskl.utils.Template.get("cheatsheet-shortcut-template"),c=pskl.utils.Template.replace(b,{shortcutIcon:a.icon,shortcutDescription:a.description,shortcutKey:a.shortcut});return pskl.utils.Template.createFromHTML(c)}}(),function(){var a=$.namespace("pskl.service");a.ImageUploadService=function(){},a.ImageUploadService.prototype.init=function(){},a.ImageUploadService.prototype.upload=function(a,b,c){var d={data:a},e=function(a){b(Constants.IMAGE_SERVICE_GET_URL+a.responseText)};pskl.utils.Xhr.post(Constants.IMAGE_SERVICE_UPLOAD_URL,d,e,c)}}(),function(){var a=$.namespace("pskl.service");a.CurrentColorsService=function(a){this.piskelController=a,this.cache={},this.currentColors=[],this.cachedFrameProcessor=new pskl.model.frame.AsyncCachedFrameProcessor,this.cachedFrameProcessor.setFrameProcessor(this.getFrameColors_.bind(this)),this.paletteService=pskl.app.paletteService},a.CurrentColorsService.prototype.init=function(){$.subscribe(Events.HISTORY_STATE_SAVED,this.updateCurrentColors_.bind(this)),$.subscribe(Events.HISTORY_STATE_LOADED,this.loadColorsFromCache_.bind(this))},a.CurrentColorsService.prototype.getCurrentColors=function(){return this.currentColors},a.CurrentColorsService.prototype.setCurrentColors=function(a){var b=pskl.app.historyService.currentIndex;this.cache[b]=a,a.join("")!==this.currentColors.join("")&&(this.currentColors=a,$.publish(Events.CURRENT_COLORS_UPDATED))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b?this.setCurrentColors(b):this.updateCurrentColors_()};var b=function(a,b){var c=[];for(a=a.slice(0);a.length;)c.push(a.splice(0,10));var d=Q([]);return c.forEach(function(a){d=d.then(function(c){return Q.all(a.map(b)).then(function(a){return c.concat(a)})})}),d};a.CurrentColorsService.prototype.updateCurrentColors_=function(){var a=this.piskelController.getLayers(),c=a.map(function(a){return a.getFrames()}).reduce(function(a,b){return a.concat(b)}),d=function(a){return this.cachedFrameProcessor.get(a)}.bind(this);b(c,d).then(function(a){var b={};a.forEach(function(a){Object.keys(a).forEach(function(a){b[a]=!0})}),delete b[Constants.TRANSPARENT_COLOR],this.setCurrentColors(Object.keys(b))}.bind(this))},a.CurrentColorsService.prototype.isCurrentColorsPaletteSelected_=function(){var a=pskl.UserSettings.get(pskl.UserSettings.SELECTED_PALETTE),b=this.paletteService.getPaletteById(a);return b&&b.id===Constants.CURRENT_COLORS_PALETTE_ID},a.CurrentColorsService.prototype.loadColorsFromCache_=function(){var a=pskl.app.historyService.currentIndex,b=this.cache[a];b&&this.setCurrentColors(b)},a.CurrentColorsService.prototype.getFrameColors_=function(a,b){var c=new pskl.worker.framecolors.FrameColors(a,function(a){b(a.data.colors)},function(){},function(a){b({})});c.process()}}(),function(){var a=$.namespace("pskl.service");a.FileDropperService=function(a,b){this.piskelController=a,this.drawingAreaContainer=b,this.dropPosition_=null},a.FileDropperService.prototype.init=function(){document.body.addEventListener("drop",this.onFileDrop.bind(this),!1),document.body.addEventListener("dragover",this.onFileDragOver.bind(this),!1)},a.FileDropperService.prototype.onFileDragOver=function(a){a.stopPropagation(),a.preventDefault(),a.dataTransfer.dropEffect="copy"},a.FileDropperService.prototype.onFileDrop=function(a){a.preventDefault(),a.stopPropagation(),this.dropPosition_={x:a.clientX,y:a.clientY};for(var b=a.dataTransfer.files,c=0;c.5?Constants.TOOL_HIGHLIGHT_COLOR_DARK:Constants.TOOL_HIGHLIGHT_COLOR_LIGHT},a.BaseTool.prototype.hideHighlightedPixel=function(a){if(null!==this.highlightedPixelRow&&null!==this.highlightedPixelCol){try{a.setPixel(this.highlightedPixelCol,this.highlightedPixelRow,Constants.TRANSPARENT_COLOR)}catch(b){window.console.warn("ns.BaseTool.prototype.hideHighlightedPixel failed")}this.highlightedPixelRow=null,this.highlightedPixelCol=null}},a.BaseTool.prototype.raiseSaveStateEvent=function(a){$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.REPLAY,scope:this,replay:a})},a.BaseTool.prototype.releaseToolAt=function(a,b,c,d,e,f){},a.BaseTool.prototype.getLinePixels_=function(a,b,c,d){b=pskl.utils.normalize(b,0),d=pskl.utils.normalize(d,0);for(var e=[],f=Math.abs(b-a),g=Math.abs(d-c),h=b>a?1:-1,i=d>c?1:-1,j=f-g;;){if(e.push({col:a,row:c}),a==b&&c==d)break;var k=2*j;k>-g&&(j-=g,a+=h),f>k&&(j+=f,c+=i)}return e}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ShapeTool=function(){this.startCol=null,this.startRow=null,this.tooltipDescriptors=[{key:"shift",description:"Keep 1 to 1 ratio"}]},pskl.utils.inherit(a.ShapeTool,a.BaseTool),a.ShapeTool.prototype.applyToolAt=function(a,b,c,d,e,f){$.publish(Events.DRAG_START,[a,b]),this.startCol=a,this.startRow=b,e.setPixel(a,b,c)},a.ShapeTool.prototype.moveToolAt=function(a,b,c,d,e,f){var g=this.getCoordinates_(a,b,f);$.publish(Events.CURSOR_MOVED,[g.col,g.row]),e.clear(),c==Constants.TRANSPARENT_COLOR&&(c=Constants.SELECTION_TRANSPARENT_COLOR),this.draw_(g.col,g.row,c,e)},a.ShapeTool.prototype.releaseToolAt=function(a,b,c,d,e,f){e.clear();var g=this.getCoordinates_(a,b,f);this.draw_(g.col,g.row,c,d),$.publish(Events.DRAG_END,[g.col,g.row]),this.raiseSaveStateEvent({col:g.col,row:g.row,startCol:this.startCol,startRow:this.startRow,color:c})},a.ShapeTool.prototype.replay=function(a,b){this.startCol=b.startCol,this.startRow=b.startRow,this.draw_(b.col,b.row,b.color,a)},a.ShapeTool.prototype.getCoordinates_=function(a,b,c){return c.shiftKey?this.getScaledCoordinates_(a,b):{col:a,row:b}},a.ShapeTool.prototype.getScaledCoordinates_=function(a,b){var c=this.startCol-a,d=Math.abs(c),e=this.startRow-b,f=Math.abs(e),g=Math.min(d,f);return b=this.startRow-e/f*g,a=this.startCol-c/d*g,{col:a,row:b}},a.ShapeTool.prototype.draw_=Constants.ABSTRACT_FUNCTION}(),function(){var a=$.namespace("pskl.tools.drawing");a.SimplePen=function(){this.toolId="tool-pen",this.helpText="Pen tool",this.previousCol=null,this.previousRow=null,this.pixels=[]},pskl.utils.inherit(a.SimplePen,a.BaseTool),a.SimplePen.prototype.applyToolAt=function(a,b,c,d,e,f){this.previousCol=a,this.previousRow=b,e.setPixel(a,b,c),c===Constants.TRANSPARENT_COLOR&&d.setPixel(a,b,c),this.pixels.push({col:a,row:b,color:c})},a.SimplePen.prototype.moveToolAt=function(a,b,c,d,e,f){if(Math.abs(a-this.previousCol)>1||Math.abs(b-this.previousRow)>1)for(var g=this.getLinePixels_(a,this.previousCol,b,this.previousRow),h=0,i=g.length;i>h;h++){var j=g[h];this.applyToolAt(j.col,j.row,c,d,e,f)}else this.applyToolAt(a,b,c,d,e,f);this.previousCol=a,this.previousRow=b},a.SimplePen.prototype.releaseToolAt=function(a,b,c,d,e,f){this.setPixelsToFrame_(d,this.pixels),this.raiseSaveStateEvent({pixels:this.pixels.slice(0),color:c}),this.resetUsedPixels_()},a.SimplePen.prototype.replay=function(a,b){this.setPixelsToFrame_(a,b.pixels,b.color)},a.SimplePen.prototype.setPixelsToFrame_=function(a,b,c){b.forEach(function(b){a.setPixel(b.col,b.row,b.color)})},a.SimplePen.prototype.resetUsedPixels_=function(){this.pixels=[]}}(),function(){var a=$.namespace("pskl.tools.drawing"),b=3;a.Lighten=function(){this.superclass.constructor.call(this),this.toolId="tool-lighten",this.helpText="Lighten",this.tooltipDescriptors=[{key:"ctrl",description:"Darken"},{key:"shift",description:"Apply only once per pixel"}],this.usedPixels_={darken:{},lighten:{}}},pskl.utils.inherit(a.Lighten,a.SimplePen),a.Lighten.prototype.resetUsedPixels_=function(){this.usedPixels_={darken:{},lighten:{}},this.superclass.resetUsedPixels_.call(this)},a.Lighten.prototype.applyToolAt=function(a,c,d,e,f,g,h){var i=f.getPixel(a,c),j=e.getPixel(a,c),k=i===Constants.TRANSPARENT_COLOR?j:i,l=pskl.utils.UserAgent.isMac?g.metaKey:g.ctrlKey,m=g.shiftKey,n=k===Constants.TRANSPARENT_COLOR,o=l?this.usedPixels_.darken:this.usedPixels_.lighten,p=a+"-"+c,q=n||m&&o[p];if(q)d=window.tinycolor(k);else{var r=m?2*b:b;d=l?window.tinycolor.darken(k,r):window.tinycolor.lighten(k,r)}d&&(o[p]=!0,this.superclass.applyToolAt.call(this,a,c,d.toRgbString(),e,f,g))}}(),function(){var a=$.namespace("pskl.tools.drawing");a.VerticalMirrorPen=function(){this.superclass.constructor.call(this),this.toolId="tool-vertical-mirror-pen",this.helpText="Vertical Mirror pen",this.tooltipDescriptors=[{key:"ctrl",description:"Use horizontal axis"},{key:"shift",description:"Use horizontal and vertical axis"}]},pskl.utils.inherit(a.VerticalMirrorPen,a.SimplePen),a.VerticalMirrorPen.prototype.backupPreviousPositions_=function(){this.backupPreviousCol=this.previousCol,this.backupPreviousRow=this.previousRow},a.VerticalMirrorPen.prototype.restorePreviousPositions_=function(){this.previousCol=this.backupPreviousCol,this.previousRow=this.backupPreviousRow},a.VerticalMirrorPen.prototype.applyToolAt=function(a,b,c,d,e,f){this.superclass.applyToolAt.call(this,a,b,c,d,e),this.backupPreviousPositions_();var g=this.getSymmetricCol_(a,d),h=this.getSymmetricRow_(b,d),i=pskl.utils.UserAgent.isMac?f.metaKey:f.ctrlKey;i||this.superclass.applyToolAt.call(this,g,b,c,d,e),(f.shiftKey||i)&&this.superclass.applyToolAt.call(this,a,h,c,d,e),f.shiftKey&&this.superclass.applyToolAt.call(this,g,h,c,d,e),this.restorePreviousPositions_()},a.VerticalMirrorPen.prototype.getSymmetricCol_=function(a,b){return b.getWidth()-a-1},a.VerticalMirrorPen.prototype.getSymmetricRow_=function(a,b){return b.getHeight()-a-1}}(),function(){var a=$.namespace("pskl.tools.drawing");a.Eraser=function(){this.superclass.constructor.call(this),this.toolId="tool-eraser",this.helpText="Eraser tool"},pskl.utils.inherit(a.Eraser,a.SimplePen),a.Eraser.prototype.applyToolAt=function(a,b,c,d,e,f){this.superclass.applyToolAt.call(this,a,b,Constants.TRANSPARENT_COLOR,d,e,f)},a.Eraser.prototype.releaseToolAt=function(a,b,c,d,e,f){this.superclass.releaseToolAt.call(this,a,b,Constants.TRANSPARENT_COLOR,d,e,f)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.Stroke=function(){this.toolId="tool-stroke",this.helpText="Stroke tool",this.startCol=null,this.startRow=null},pskl.utils.inherit(a.Stroke,a.BaseTool),a.Stroke.prototype.applyToolAt=function(a,b,c,d,e,f){this.startCol=a,this.startRow=b,e.setPixel(a,b,c)},a.Stroke.prototype.moveToolAt=function(a,b,c,d,e,f){e.clear();for(var g=this.getLinePixels_(this.startCol,a,this.startRow,b),h=0;hi;i++)for(var j=0;h>j;j++){var k=i-a,l=j-b;e.altKey&&(k=(k+g)%g,l=(l+h)%h),f=d.containsPixel(k,l)?d.getPixel(k,l):Constants.TRANSPARENT_COLOR,c.setPixel(i,j,f)}},a.Move.prototype.releaseToolAt=function(a,b,c,d,e,f){var g=a-this.startCol,h=b-this.startRow;pskl.tools.ToolsHelper.getTargetFrames(f.ctrlKey,f.shiftKey).forEach(function(a){var b=this.currentFrame==a?this.currentFrameClone:a.clone();this.shiftFrame(g,h,a,b,f)}.bind(this)),this.raiseSaveStateEvent({colDiff:g,rowDiff:h,ctrlKey:f.ctrlKey,altKey:f.altKey,shiftKey:f.shiftKey})},a.Move.prototype.replay=function(a,b){var c={shiftKey:b.shiftKey,altKey:b.altKey,ctrlKey:b.ctrlKey};pskl.tools.ToolsHelper.getTargetFrames(c.ctrlKey,c.shiftKey).forEach(function(a){this.shiftFrame(b.colDiff,b.rowDiff,a,a.clone(),c)}.bind(this))}}(),function(){var a=$.namespace("pskl.tools.drawing");a.BaseSelect=function(){this.secondaryToolId=pskl.tools.drawing.Move.TOOL_ID,this.bodyRoot=$("body"),this.startCol=null,this.startRow=null,this.selection=null,this.tooltipDescriptors=[{description:"Drag the selection to move it. You may switch to other layers and frames."},{key:"ctrl+c",description:"Copy the selected area"},{key:"ctrl+v",description:"Paste the copied area"}]},pskl.utils.inherit(a.BaseSelect,a.BaseTool),a.BaseSelect.prototype.applyToolAt=function(a,b,c,d,e,f){this.startCol=a,this.startRow=b,this.lastCol=a,this.lastRow=b,$.publish(Events.SET_OVERLAY_OPACITY,[.5]),this.isInSelection(a,b)?(this.mode="moveSelection",this.onSelectionDragStart_(a,b,c,d,e)):(this.mode="select",this.onSelectStart_(a,b,c,d,e))},a.BaseSelect.prototype.moveToolAt=function(a,b,c,d,e,f){"select"==this.mode?this.onSelect_(a,b,c,d,e):"moveSelection"==this.mode&&this.onSelectionDrag_(a,b,c,d,e)},a.BaseSelect.prototype.releaseToolAt=function(a,b,c,d,e,f){"select"==this.mode?this.onSelectEnd_(a,b,c,d,e):"moveSelection"==this.mode&&this.onSelectionDragEnd_(a,b,c,d,e),$.publish(Events.SET_OVERLAY_OPACITY,[1])},a.BaseSelect.prototype.moveUnactiveToolAt=function(a,b,c,d,e,f){e.containsPixel(a,b)&&(this.isInSelection(a,b)?(this.bodyRoot.addClass(this.secondaryToolId),this.bodyRoot.removeClass(this.toolId)):(this.bodyRoot.addClass(this.toolId),this.bodyRoot.removeClass(this.secondaryToolId)))},a.BaseSelect.prototype.isInSelection=function(a,b){return this.selection&&this.selection.pixels.some(function(c){return c.col===a&&c.row===b})},a.BaseSelect.prototype.hideHighlightedPixel=function(){},a.BaseSelect.prototype.drawSelectionOnOverlay_=function(a){for(var b=this.selection.pixels,c=0,d=b.length;d>c;c++){var e=b[c],f=e.color&&e.color!==Constants.TRANSPARENT_COLOR,g=f?e.color:Constants.SELECTION_TRANSPARENT_COLOR;a.setPixel(b[c].col,b[c].row,g)}},a.BaseSelect.prototype.onSelectStart_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelect_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectEnd_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectionDragStart_=function(a,b,c,d,e){},a.BaseSelect.prototype.onSelectionDrag_=function(a,b,c,d,e){{var f=a-this.lastCol,g=b-this.lastRow;a-this.startCol,b-this.startRow}this.selection.move(f,g),e.clear(),this.drawSelectionOnOverlay_(e),this.lastCol=a,this.lastRow=b},a.BaseSelect.prototype.onSelectionDragEnd_=function(a,b,c,d,e){this.onSelectionDrag_(a,b,c,d,e)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.RectangleSelect=function(){this.toolId="tool-rectangle-select",this.helpText="Rectangle selection",a.BaseSelect.call(this),this.hasSelection=!1,this.selectionOrigin_=null},pskl.utils.inherit(a.RectangleSelect,a.BaseSelect),a.RectangleSelect.prototype.onSelectStart_=function(a,b,c,d,e){this.selectionOrigin_={col:a,row:b},this.hasSelection?(this.hasSelection=!1, +e.clear(),$.publish(Events.SELECTION_DISMISSED)):(this.startSelection_(),e.setPixel(a,b,c))},a.RectangleSelect.prototype.startSelection_=function(a,b,c){this.hasSelection=!0,$.publish(Events.DRAG_START,[a,b])},a.RectangleSelect.prototype.onSelect_=function(a,b,c,d,e){this.hasSelection||this.selectionOrigin_.col===a&&this.selectionOrigin_.row===b||this.startSelection_(),this.hasSelection&&(e.clear(),this.selection=new pskl.selection.RectangularSelection(this.startCol,this.startRow,a,b),$.publish(Events.SELECTION_CREATED,[this.selection]),this.drawSelectionOnOverlay_(e))},a.RectangleSelect.prototype.onSelectEnd_=function(a,b,c,d,e){this.hasSelection&&(this.onSelect_(a,b,c,d,e),$.publish(Events.DRAG_END,[a,b]))}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ShapeSelect=function(){this.toolId="tool-shape-select",this.helpText="Shape selection",a.BaseSelect.call(this)},pskl.utils.inherit(a.ShapeSelect,a.BaseSelect),a.ShapeSelect.prototype.onSelectStart_=function(a,b,c,d,e){$.publish(Events.SELECTION_DISMISSED),e.clear();var f=pskl.PixelUtils.getSimilarConnectedPixelsFromFrame(d,a,b);this.selection=new pskl.selection.ShapeSelection(f),$.publish(Events.SELECTION_CREATED,[this.selection]),this.drawSelectionOnOverlay_(e)}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ColorPicker=function(){this.toolId="tool-colorpicker",this.helpText="Color picker"},pskl.utils.inherit(a.ColorPicker,a.BaseTool),a.ColorPicker.prototype.applyToolAt=function(a,b,c,d,e,f){if(d.containsPixel(a,b)){var g=d.getPixel(a,b);f.button==Constants.LEFT_BUTTON?$.publish(Events.SELECT_PRIMARY_COLOR,[g]):f.button==Constants.RIGHT_BUTTON&&$.publish(Events.SELECT_SECONDARY_COLOR,[g])}}}(),function(){var a=$.namespace("pskl.tools.drawing");a.ColorSwap=function(){this.toolId="tool-colorswap",this.helpText="Paint all pixels of the same color",this.tooltipDescriptors=[{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.ColorSwap,a.BaseTool),a.ColorSwap.prototype.applyToolAt=function(a,b,c,d,e,f){if(d.containsPixel(a,b)){var g=d.getPixel(a,b),h=pskl.utils.UserAgent.isMac?f.metaKey:f.ctrlKey,i=f.shiftKey;this.swapColors(g,c,h,i),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}},a.ColorSwap.prototype.swapColors=function(a,b,c,d){var e=function(c,d,e,f){c==a&&(f.pixels[d][e]=b)},f=pskl.app.piskelController.getCurrentLayer(),g=pskl.app.piskelController.getCurrentFrameIndex();pskl.app.piskelController.getPiskel().getLayers().forEach(function(a){(c||a===f)&&a.getFrames().forEach(function(a,b){(d||b===g)&&(a.forEachPixel(e),a.version++)})})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Transform=function(){this.toolId="tool-transform",this.helpText="Transform tool",this.tooltipDescriptors=[]},pskl.utils.inherit(a.Transform,pskl.tools.Tool),a.Transform.prototype.apply=function(a){var b=a.shiftKey,c=a.ctrlKey;this.applyTool_(a.altKey,b,c)},a.Transform.prototype.applyTool_=function(a,b,c){var d=pskl.app.piskelController.getCurrentFrameIndex(),e=c?pskl.app.piskelController.getLayers():[pskl.app.piskelController.getCurrentLayer()];e.forEach(function(c){var e=b?c.getFrames():[c.getFrameAt(d)];e.forEach(function(b){this.applyToolOnFrame_(b,a)}.bind(this))}.bind(this)),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Clone=function(){this.toolId="tool-clone",this.helpText="Clone current layer to all frames",this.tooltipDescriptors=[]},pskl.utils.inherit(a.Clone,a.Transform),a.Clone.prototype.apply=function(a){var b=pskl.app.piskelController.getCurrentFrame(),c=pskl.app.piskelController.getCurrentLayer();c.getFrames().forEach(function(a){a!==b&&a.setPixels(b.getPixels())}),$.publish(Events.PISKEL_RESET),$.publish(Events.PISKEL_SAVE_STATE,{type:pskl.service.HistoryService.SNAPSHOT})}}(),function(){var a=$.namespace("pskl.tools.transform");a.Flip=function(){this.toolId="tool-flip",this.helpText="Flip vertically",this.tooltipDescriptors=[{key:"alt",description:"Flip horizontally"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Flip,a.Transform),a.Flip.prototype.applyToolOnFrame_=function(a,b){var c;c=b?pskl.utils.FrameTransform.HORIZONTAL:pskl.utils.FrameTransform.VERTICAL,pskl.utils.FrameTransform.flip(a,c)}}(),function(){var a=$.namespace("pskl.tools.transform");a.Rotate=function(){this.toolId="tool-rotate",this.helpText="Counter-clockwise rotation",this.tooltipDescriptors=[{key:"alt",description:"Clockwise rotation"},{key:"ctrl",description:"Apply to all layers"},{key:"shift",description:"Apply to all frames"}]},pskl.utils.inherit(a.Rotate,a.Transform),a.Rotate.prototype.applyToolOnFrame_=function(a,b){var c;c=b?pskl.utils.FrameTransform.CLOCKWISE:pskl.utils.FrameTransform.COUNTERCLOCKWISE,pskl.utils.FrameTransform.rotate(a,c)}}(),function(){var a=$.namespace("pskl.worker.framecolors");if("rgba(0, 0, 0, 0)"!==Constants.TRANSPARENT_COLOR)throw"Constants.TRANSPARENT_COLOR, please update FrameColorsWorker";a.FrameColorsWorker=function(){var a="rgba(0, 0, 0, 0)",b=function(b){if(b===a)return b;b=b.replace(/\s/g,"");var d=/^#([a-f0-9]{3}){1,2}$/i,e=/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/i;if(d.test(b))return b.toUpperCase();if(e.test(b)){var f=e.exec(b);return c(1*f[1],1*f[2],1*f[3])}},c=function(a,b,c){return"#"+d(a)+d(b)+d(c)},d=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b},e=function(a){for(var c={},d=0;dc;c++){var e=a.charCodeAt(c);b=(b<<5)-b+e,b|=0}return b};this.onmessage=function(b){try{var c=b.data,d=c.str,e=a(d);this.postMessage({type:"SUCCESS",hash:e})}catch(f){this.postMessage({type:"ERROR",message:f.message})}}}}(),function(){var a=$.namespace("pskl.worker.hash");a.Hash=function(b,c,d,e){this.str=b,this.onStep=d,this.onSuccess=c,this.onError=e,this.worker=pskl.utils.WorkerUtils.createWorker(a.HashWorker,"hash"),this.worker.onmessage=this.onWorkerMessage.bind(this)},a.Hash.prototype.process=function(){this.worker.postMessage({str:this.str})},a.Hash.prototype.onWorkerMessage=function(a){"STEP"===a.data.type?this.onStep(a):"SUCCESS"===a.data.type?(this.onSuccess(a),this.worker.terminate()):"ERROR"===a.data.type&&(this.onError(a),this.worker.terminate())}}(),function(){var a=$.namespace("pskl.worker.imageprocessor");a.ImageProcessorWorker=function(){var a,b,c,d=function(d){a=0,b=0,c=d},e=function(){a+=1;var d=(a/c*100).toFixed(1);d!=b&&(b=d,this.postMessage({type:"STEP",progress:b,currentStep:a,total:c}))},f=function(a,b,c){return"#"+g(a)+g(b)+g(c)},g=function(a){var b=a.toString(16);return 1==b.length?"0"+b:b},h=function(a,b,c,d){for(var g=[],h=0;b>h;h++){g[h]=[],e();for(var i=0;c>i;i++){var j=4*(i*b+h),k=a[j],l=a[j+1],m=a[j+2],n=a[j+3];g[h][i]=125>n?d:f(k,l,m)}}return g},i=function(a,b,c){for(var d=h(a,b,c,"transparent"),f={},g=0;g after build, -2015-04-27-12-01 is replaced by the build version + * See @Gruntfile.js => after build, -2015-09-14-10-01 is replaced by the build version */ - var version = '-2015-04-27-12-01'; + var version = '-2015-09-14-10-01'; var versionHasNotBeenReplaced = version.indexOf('@@') === 0; if (versionHasNotBeenReplaced) { version = ''; diff --git a/piskelapp-partials/main-partial.html b/piskelapp-partials/main-partial.html index a5f27e4f..d809593b 100644 --- a/piskelapp-partials/main-partial.html +++ b/piskelapp-partials/main-partial.html @@ -1,10 +1,10 @@
    - +
    - +
    @@ -14,24 +14,24 @@
    - - - - + + + +
    - +
    - - - - - + + + + +
    @@ -40,14 +40,14 @@
    - - - + + +
    - - - + + + - + diff --git a/templates/cheatsheet.html b/templates/cheatsheet.html index 5377bad3..d4fbdb03 100644 --- a/templates/cheatsheet.html +++ b/templates/cheatsheet.html @@ -1,16 +1,18 @@ diff --git a/templates/dialogs/import-image.html b/templates/dialogs/import-image.html index 95795799..f37e95cb 100644 --- a/templates/dialogs/import-image.html +++ b/templates/dialogs/import-image.html @@ -9,19 +9,41 @@ Name :
    - Info : +
    Preview :
    - Size : + +
    +
    + Resize to x
    -
    - Smooth resize : - +
    + Smooth resize +
    - +
    + +
    +
    + Frame size + x + +
    +
    + Offset + x + +
    +
    \ No newline at end of file diff --git a/templates/drawing-tools.html b/templates/drawing-tools.html index 20fb8290..08f4bbac 100644 --- a/templates/drawing-tools.html +++ b/templates/drawing-tools.html @@ -41,7 +41,7 @@ diff --git a/templates/popup-preview.html b/templates/popup-preview.html index be408762..4996cec6 100644 --- a/templates/popup-preview.html +++ b/templates/popup-preview.html @@ -4,7 +4,7 @@ body, .popup-container , .preview-container, - .tiled-frame-container { + .background-image-frame-container { width : 100%; height : 100%; } @@ -22,7 +22,7 @@ position: relative; } - .tiled-frame-container { + .background-image-frame-container { position: relative; background-repeat : no-repeat; } diff --git a/templates/preview.html b/templates/preview.html index 5b245a35..468a6054 100644 --- a/templates/preview.html +++ b/templates/preview.html @@ -1,6 +1,10 @@
    -
    +
    +
    1x
    +
    +
    +
    diff --git a/templates/settings/application.html b/templates/settings/application.html index d42585d3..af487ff1 100644 --- a/templates/settings/application.html +++ b/templates/settings/application.html @@ -1,10 +1,10 @@
    -
    +
    General
    - +
    @@ -20,8 +20,9 @@
    +
    - +
    + +
    + + + +
    +
    @@ -39,14 +47,14 @@
    - +
    diff --git a/templates/settings/export.html b/templates/settings/export.html index d3d61870..6163fd28 100644 --- a/templates/settings/export.html +++ b/templates/settings/export.html @@ -13,8 +13,14 @@ ZIP with one PNG file per frame. File names will start with the prefix below.
    - - + + +
    +
    +
    diff --git a/templates/settings/resize.html b/templates/settings/resize.html index 838670c4..f321111b 100644 --- a/templates/settings/resize.html +++ b/templates/settings/resize.html @@ -17,13 +17,13 @@