diff --git a/potiboard5/chickenpaint/js/chickenpaint.js b/potiboard5/chickenpaint/js/chickenpaint.js index bdb5d41..a2b3037 100644 --- a/potiboard5/chickenpaint/js/chickenpaint.js +++ b/potiboard5/chickenpaint/js/chickenpaint.js @@ -70,68 +70,68 @@ L[wa];d[J]=G[S]+na*U+.5|0;G[S+1]+=na*X;Ia[S]+=na*ia;Ia[S+1]=na*Y}d[J++]=G[S]+.5| l<<8|a.value;case 4:return c<<16|b<<8|a.value;case 5:return a.value<<16|b<<8|l;default:return 0}}function Bb(a){this.value=this.saturation=this.hue=this.rgb=0;this.setRgb(a||0)}function vh(){var a,c=!1;this.nextGaussian=function(){if(c)return c=!1,a;do var d=(b=2*Math.random()-1)*b+(l=2*Math.random()-1)*l;while(1<=d||0==d);var b,l;d=Math.sqrt(-2*Math.log(d)/d);return a=l*d,c=!0,b*d}}function Kb(){this.setToIdentity()}function of(a){for(var c=["imageSmoothingEnabled","mozImageSmoothingEnabled","webkitImageSmoothingEnabled", "msImageSmoothingEnabled"],d=0;dXa.invalidateLayerRect(M,P));let F=!1;if(ea)for(let M of(Fb.union(P),D))M instanceof Na&&(Va.add(M),F=!0);ha&&(Ma.union(P),D.forEach(M=>{ec.add(M);Ja&&Ja.layer==M&&Ja.invalidateRect(P)}),F=!0);F&&(fb&&(clearTimeout(fb),fb=null),Ic||(fb=setTimeout(e,1E3)));l(P)}function m(D,P){k(D,P,!Ta,Ta)}function h(){return Ta?qa.mask:qa.image}function n(){if(!Ca.isEmpty()){if(Ta){var D=qa.mask;hb.brushMode==Da.BRUSH_MODE_ERASE?Oa[Da.BRUSH_MODE_PAINT].mergeOntoMask(D, +function b(){ha.emitEvent("changeSelection",[])}function l(D){ha.emitEvent("updateRegion",[D])}function p(){ha.emitEvent("changeStructure");Xa.resetTree();x();l(ha.getBounds())}function g(D,P,da){ha.emitEvent("changeLayer",[D]);da||(Xa.layerPropertyChanged(D,P),l(ha.getBounds()))}function e(){for(let D of Va)D.rebuildImageThumbnail(),ha.emitEvent("changeLayerImageThumb",[D]);for(let D of ec)D.rebuildMaskThumbnail(),ha.emitEvent("changeLayerMaskThumb",[D]);Va.clear();fb&&(clearTimeout(fb),fb=null)} +function k(D,P,da,fa){Array.isArray(D)||(D=[D]);D.forEach(M=>Xa.invalidateLayerRect(M,P));let F=!1;if(da)for(let M of(Fb.union(P),D))M instanceof Na&&(Va.add(M),F=!0);fa&&(Ma.union(P),D.forEach(M=>{ec.add(M);Ja&&Ja.layer==M&&Ja.invalidateRect(P)}),F=!0);F&&(fb&&(clearTimeout(fb),fb=null),Ic||(fb=setTimeout(e,1E3)));l(P)}function m(D,P){k(D,P,!Ta,Ta)}function h(){return Ta?qa.mask:qa.image}function n(){if(!Ca.isEmpty()){if(Ta){var D=qa.mask;hb.brushMode==Da.BRUSH_MODE_ERASE?Oa[Da.BRUSH_MODE_PAINT].mergeOntoMask(D, Ka,4278190080):Oa[hb.brushMode].mergeOntoMask(D,Ka,255&Yb)}else{D=qa.image;let P=qa.getLockAlpha();hb.brushMode==Da.BRUSH_MODE_ERASE&&P?Oa[Da.BRUSH_MODE_PAINT].mergeOntoImage(D,Lb,16777215):Oa[hb.brushMode].mergeOntoImage(D,Lb,Yb);P&&D.copyAlphaFrom(Lb,Ca)}Ca.makeEmpty()}}function r(){qa instanceof Na&&!Fb.isEmpty()&&(Lb.copyBitmapRect(qa.image,Fb.left,Fb.top,Fb),Fb.makeEmpty())}function u(){qa.mask&&!Ma.isEmpty()&&(Ka.copyBitmapRect(qa.mask,Ma.left,Ma.top,Ma),Ma.makeEmpty())}function v(){Ta?u(): -r()}function x(){let D=fa.getBounds();Fb.set(D);Ma.set(D)}function C(D){fa.setHasUnsavedChanges(!0);0M.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,ea){let ha=D.parent,F=D.parent.indexOf(D),M=Ta,da=ha.layers[ha.indexOf(D)+1],ka=P.layers[ea],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(),db=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;Eada["get"+ea]());this.to=M;this.redo()};return ha.prototype=Object.create(zc.prototype),ha.prototype.constructor=ha,ha.prototype.undo=function(){this.layers.forEach((F,M)=>F["set"+ea](this.from[M]));this.layers.forEach(F=> -g(F,D,!P))},ha.prototype.redo=function(){this.layers.forEach(F=>F["set"+ea](this.to));this.layers.forEach(F=>g(F,D,!P))},ha.prototype.merge=function(F){var M;if(M=F instanceof ha)a:{M=this.layers;var da=F.layers;if(M.length!=da.length)M=!1;else{for(let ka=0;ka -P.addLayer(F));this.addLayerObject(D,P)};this.isRemoveLayerAllowed=function(){return qa instanceof Na?mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&D!=qa):qa instanceof ob&&mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&!D.hasAncestor(qa))};this.removeLayer=function(){return!!this.isRemoveLayerAllowed()&&(C(new U(qa)),!0)};this.duplicateLayer=function(){C(new W(qa))};this.isMergeDownAllowed=function(){let D=qa.parent.indexOf(qa);return 0T.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===T.LM_MULTIPLY&&(ea=ha)}if(-1!==ea){ha=new H(this.width,this.height);let M=F=!0,da=this.getBounds();ha.clearAll(da,16777215);for(let ka=0;ka<=ea;ka++){let xa=P[ka];M||(F=F&&ha.hasAlphaInRect(da));xa.blendMode===T.LM_MULTIPLY&&("bake"===D?!F&&0F){let M=Tb,da=vb,ka=Rb;ha=(F-.001)/ha;for(F=ha;1>=F;F+=ha)M=F*D+(1-F)*Tb,da=F*P+(1-F)*vb,ka=F*ea+(1-F)*Rb,this.paintDab(M,da,ka);Tb=M;vb=da;Rb=ka}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),kb.clipTo(this.getBounds()),kb.isEmpty()||(C(new K),v()),d(!1))};this.hasAlpha= -function(){return Nb.hasAlpha()};this.getFlatPNG=function(D){return this.fusionLayers(),Nb.getAsPNG(D)};this.getFlatPNGBuffer=function(D){return this.fusionLayers(),Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Na&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(zc.prototype);K.prototype.constructor=K;J.prototype=Object.create(zc.prototype);J.prototype.constructor=J;G.prototype=Object.create(zc.prototype); -G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.constructor=L;W.prototype=Object.create(zc.prototype);W.prototype.constructor=W;U.prototype=Object.create(zc.prototype);U.prototype.constructor=U;X.prototype=Object.create(zc.prototype);X.prototype.constructor=X;Y.prototype=Object.create(zc.prototype);Y.prototype.constructor=Y;ia.prototype=Object.create(zc.prototype);ia.prototype.constructor=ia;wa.prototype=Object.create(zc.prototype);wa.prototype.constructor=wa;let Rc= -Ia("alpha",!0),Sc=Ia("blendMode",!0),A=Ia("visible",!0),ta=Ia("clip",!0),uc=Ia("maskVisible",!0),Nc=Ia("name",!1),Xb=Ia("lockAlpha",!1),$c=Ia("maskLinked",!1);S.prototype=Object.create(zc.prototype);S.prototype.constructor=S;class ua extends zc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(ea=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,ea.left,ea.top,ea); -P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,ea.left,ea.top,ea)}):(P.moveImage&&P.imageRect.forEach((ea,ha)=>{P.layer.image.copyBitmapRect(ea,ha.left,ha.top,ea.getBounds())}),P.moveMask&&P.maskRect.forEach((ea,ha)=>{P.layer.mask.copyBitmapRect(ea,ha.left,ha.top,ea.getBounds())}))});k(this.movingLayers.map(P=>P.layer),D.reduce((P,ea)=>P.getUnion(ea),new Ha(0,0,0,0)),!0,!0);this.dstRect.makeEmpty();fa.setSelection(this.fromSelection);fa.setActiveLayer(this.layer,this.fromMaskMode);b()}getMemoryUsed(D, -P){return this.movingLayers.map(function(ea){return[ea.imageUndo,ea.maskUndo,ea.imageRect,ea.maskRect].map(ha=>ha?ha.getMemorySize():0).reduce(De,0)}).reduce(De,0)}buildFullUndo(){this.hasFullUndo||(this.movingLayers.forEach(function(D){D.moveImage&&(D.imageUndo=D.layer.image.clone());D.moveMask&&(D.maskUndo=D.layer.mask.clone());D.imageRect.clear();D.maskRect.clear()}),this.hasFullUndo=!0)}compact(){if(this.hasFullUndo){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&& -(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{P.imageRect.clear();P.maskRect.clear();D.forEach(ea=>{P.moveImage&&P.imageRect.set(ea,P.imageUndo.cloneRect(ea));P.moveMask&&P.maskRect.set(ea,P.maskUndo.cloneRect(ea))});P.imageUndo=null;P.maskUndo=null});this.hasFullUndo=!1}}constructor(){super();this.layer=qa;this.fromSelection=fa.getSelection();this.fromMaskMode=Ta;this.movingWholeLayer=this.fromSelection.isEmpty();this.movingImage=!Ta||this.movingWholeLayer&&this.layer.maskLinked; -this.movingMask=Ta||this.movingWholeLayer&&this.layer.maskLinked;this.erasesSourceRect=this.hasFullUndo=!1;this.dstRect=new Ha(0,0,0,0);this.movingLayers=[{layer:this.layer,moveImage:this.layer instanceof Na&&this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new Map,maskRect:new Map}];this.layer instanceof ob&&this.movingImage&&this.movingWholeLayer&&(this.movingLayers=this.movingLayers.concat(this.layer.getLinearizedLayerList(!1).map(ha=>({layer:ha,moveImage:ha instanceof -Na,moveMask:null!==ha.mask&&ha.maskLinked,imageRect:new Map,maskRect:new Map}))));let D=new Ha(0,0,0,0);if(this.movingWholeLayer){this.srcRect=fa.getBounds();for(var P=0;P{if(D.moveImage){var P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight());P.getContext("2d").putImageData(D.layer.image.getImageData(),-this.srcRect.left,-this.srcRect.top,this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(), -this.srcRect.getHeight());D.imageSourceCanvas=P}D.moveMask&&(P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight()),P.getContext("2d").putImageData(D.layer.mask.getImageData(this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(),this.srcRect.getHeight()),0,0),D.maskSourceCanvas=P)}),this.composeCanvas=Zc(fa.width,fa.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),pf(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0, -0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(fa.getBounds()));let ea=Ha.subtract(this.dstRect,this.srcRect),ha=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),M=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(da=> -{if(ha.forEach(ka=>{da.moveImage&&da.layer.image.clearRect(ka,16777215);da.moveMask&&(this.movingWholeLayer?da.layer.mask.clearRect(ka,255):da.layer.mask.clearRect(ka,0))}),!this.dstRect.isEmpty()){if(da.moveImage){let ka=da.imageUndo.getImageData();ea.forEach(xa=>{this.composeCanvasContext.putImageData(ka,0,0,xa.left,xa.top,xa.getWidth(),xa.getHeight())});this.composeCanvasContext.clearRect(F.left,F.top,F.getWidth(),F.getHeight());this.composeCanvasContext.save();this.composeCanvasContext.setTransform(this.affineTransform.m[0], -this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]);this.composeCanvasContext.drawImage(da.imageSourceCanvas,this.srcRect.left,this.srcRect.top);this.composeCanvasContext.restore();da.layer.image.copyBitmapRect(new H(this.composeCanvasContext.getImageData(this.dstRect.left,this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight())),this.dstRect.left,this.dstRect.top,new Ha(0,0,this.dstRect.getWidth(),this.dstRect.getHeight()))}da.moveMask&& -(ea.forEach(ka=>{this.composeCanvasContext.putImageData(da.layer.mask.getImageData(ka.left,ka.top,ka.getWidth(),ka.getHeight()),ka.left,ka.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle="#FFF":this.composeCanvasContext.fillStyle="#000",this.composeCanvasContext.fillRect(F.left,F.top,F.getWidth(),F.getHeight()),this.composeCanvasContext.save(),this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3], -this.affineTransform.m[4],this.affineTransform.m[5]),this.composeCanvasContext.drawImage(da.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),da.layer.mask.pasteImageData(this.composeCanvasContext.getImageData(this.dstRect.left,this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight()),this.dstRect.left,this.dstRect.top))}M.forEach(ka=>{da.moveImage&&da.layer.image.copyBitmapRect(da.imageUndo,ka.left,ka.top,ka);da.moveMask&&da.layer.mask.copyBitmapRect(da.maskUndo, -ka.left,ka.top,ka)})}),k(this.movingLayers.map(da=>da.layer),D,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.toPoints(),this.affineTransform.transformPoints(D),(D=Ha.createBoundingBox(D)).roundNearest(),fa.setSelection(D),b());fa.setActiveLayer(this.layer,this.fromMaskMode)}amend(D){this.hasFullUndo||this.undo();this.affineTransform=D.clone();this.redo()}setInterpolation(D){D!=this.interpolation&&(this.interpolation=D,this.composeCanvasContext&&pf(this.composeCanvasContext,"smooth"== -this.interpolation),this.undo(),this.redo())}compact(){super.compact();this.composeCanvasContext=this.composeCanvas=null;this.movingLayers.forEach(D=>D.imageSourceCanvas=null)}getMemoryUsed(D,P){D=super.getMemoryUsed(D,P);return D+=pg(this.composeCanvas),D+=this.movingLayers.map(ea=>pg(ea.imageSourceCanvas)).reduce(De,0)}getTransform(){return this.affineTransform.clone()}getInitialTransformRect(){return this.srcRect.clone()}getInitialSelectionRect(){return this.fromSelection.clone()}constructor(D, -P){super();this.erasesSourceRect=!0;this.affineTransform=D.clone();this.interpolation=P||"smooth";this.composeCanvasContext=this.composeCanvas=null}}class vc extends ua{redo(){var D=this.dstRect.clone();let P,ea,ha=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect),this.dstRect.translate(this.offsetX,this.offsetY),P=this.dstRect.clone(),this.dstRect.clipTo(fa.getBounds()),this.erasesSourceRect?(F=D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),ha.union(F),ea=D.subtract(this.srcRect)): -ea=[D],this.movingLayers.forEach(M=>{F&&(M.moveImage&&M.layer.image.clearRect(F,16777215),M.moveMask&&M.layer.mask.clearRect(F,this.movingWholeLayer?255:0));ea.forEach(function(da){M.moveImage&&M.layer.image.copyBitmapRect(M.imageUndo,da.left,da.top,da);M.moveMask&&M.layer.mask.copyBitmapRect(M.maskUndo,da.left,da.top,da)});M.moveImage&&T.normalFuseImageOntoImageAtPosition(M.layer.image,M.imageUndo,P.left,P.top,this.srcRect);M.moveMask&&M.layer.mask.copyBitmapRect(M.maskUndo,P.left,P.top,this.srcRect)}), -ha.union(this.dstRect),k(this.movingLayers.map(M=>M.layer),ha,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.clone(),D.translate(this.offsetX,this.offsetY),fa.setSelection(D),b())}amend(D,P){this.hasFullUndo||this.undo();this.offsetX+=D;this.offsetY+=P;this.redo()}constructor(D,P,ea){super();this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!ea}}za.prototype=Object.create(zc.prototype);za.prototype.constructor=za;na.prototype=Object.create(zc.prototype);na.prototype.constructor=na; +r()}function x(){let D=ha.getBounds();Fb.set(D);Ma.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0M.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),M=Ta,ea=fa.layers[fa.indexOf(D)+1],ka=P.layers[da],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(), +db=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;Eaea["get"+da]());this.to=M;this.redo()};return fa.prototype=Object.create(zc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,M)=>F["set"+da](this.from[M]));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.merge=function(F){var M;if(M=F instanceof fa)a:{M=this.layers;var ea=F.layers;if(M.length!=ea.length)M=!1;else{for(let ka= +0;kaP.addLayer(F));this.addLayerObject(D,P)};this.isRemoveLayerAllowed=function(){return qa instanceof Na?mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&D!=qa):qa instanceof ob&&mb.getLinearizedLayerList(!1).some(D=>D instanceof Na&&!D.hasAncestor(qa))};this.removeLayer=function(){return!!this.isRemoveLayerAllowed()&& +(C(new U(qa)),!0)};this.duplicateLayer=function(){C(new W(qa))};this.isMergeDownAllowed=function(){let D=qa.parent.indexOf(qa);return 0T.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===T.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let M=F=!0,ea=this.getBounds();fa.clearAll(ea,16777215);for(let ka=0;ka<=da;ka++){let xa=P[ka]; +M||(F=F&&fa.hasAlphaInRect(ea));xa.blendMode===T.LM_MULTIPLY&&("bake"===D?!F&&0F){let M=Tb,ea=vb,ka=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)M=F*D+(1-F)*Tb,ea=F*P+(1-F)*vb,ka=F*da+(1-F)*Rb,this.paintDab(M,ea,ka);Tb=M;vb=ea;Rb=ka}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),kb.clipTo(this.getBounds()),kb.isEmpty()|| +(C(new K),v()),d(!1))};this.hasAlpha=function(){return Nb.hasAlpha()};this.getFlatPNG=function(D){return this.fusionLayers(),Nb.getAsPNG(D)};this.getFlatPNGBuffer=function(D){return this.fusionLayers(),Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Na&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(zc.prototype);K.prototype.constructor=K;J.prototype=Object.create(zc.prototype);J.prototype.constructor=J; +G.prototype=Object.create(zc.prototype);G.prototype.constructor=G;L.prototype=Object.create(zc.prototype);L.prototype.constructor=L;W.prototype=Object.create(zc.prototype);W.prototype.constructor=W;U.prototype=Object.create(zc.prototype);U.prototype.constructor=U;X.prototype=Object.create(zc.prototype);X.prototype.constructor=X;Y.prototype=Object.create(zc.prototype);Y.prototype.constructor=Y;ia.prototype=Object.create(zc.prototype);ia.prototype.constructor=ia;wa.prototype=Object.create(zc.prototype); +wa.prototype.constructor=wa;let Rc=Ia("alpha",!0),Sc=Ia("blendMode",!0),A=Ia("visible",!0),ta=Ia("clip",!0),uc=Ia("maskVisible",!0),Nc=Ia("name",!1),Xb=Ia("lockAlpha",!1),$c=Ia("maskLinked",!1);S.prototype=Object.create(zc.prototype);S.prototype.constructor=S;class ua extends zc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(da=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo, +da.left,da.top,da);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,da.left,da.top,da)}):(P.moveImage&&P.imageRect.forEach((da,fa)=>{P.layer.image.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}),P.moveMask&&P.maskRect.forEach((da,fa)=>{P.layer.mask.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}))});k(this.movingLayers.map(P=>P.layer),D.reduce((P,da)=>P.getUnion(da),new Ha(0,0,0,0)),!0,!0);this.dstRect.makeEmpty();ha.setSelection(this.fromSelection);ha.setActiveLayer(this.layer,this.fromMaskMode); +b()}getMemoryUsed(D,P){return this.movingLayers.map(function(da){return[da.imageUndo,da.maskUndo,da.imageRect,da.maskRect].map(fa=>fa?fa.getMemorySize():0).reduce(De,0)}).reduce(De,0)}buildFullUndo(){this.hasFullUndo||(this.movingLayers.forEach(function(D){D.moveImage&&(D.imageUndo=D.layer.image.clone());D.moveMask&&(D.maskUndo=D.layer.mask.clone());D.imageRect.clear();D.maskRect.clear()}),this.hasFullUndo=!0)}compact(){if(this.hasFullUndo){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&& +(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{P.imageRect.clear();P.maskRect.clear();D.forEach(da=>{P.moveImage&&P.imageRect.set(da,P.imageUndo.cloneRect(da));P.moveMask&&P.maskRect.set(da,P.maskUndo.cloneRect(da))});P.imageUndo=null;P.maskUndo=null});this.hasFullUndo=!1}}constructor(){super();this.layer=qa;this.fromSelection=ha.getSelection();this.fromMaskMode=Ta;this.movingWholeLayer=this.fromSelection.isEmpty();this.movingImage=!Ta||this.movingWholeLayer&&this.layer.maskLinked; +this.movingMask=Ta||this.movingWholeLayer&&this.layer.maskLinked;this.erasesSourceRect=this.hasFullUndo=!1;this.dstRect=new Ha(0,0,0,0);this.movingLayers=[{layer:this.layer,moveImage:this.layer instanceof Na&&this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new Map,maskRect:new Map}];this.layer instanceof ob&&this.movingImage&&this.movingWholeLayer&&(this.movingLayers=this.movingLayers.concat(this.layer.getLinearizedLayerList(!1).map(fa=>({layer:fa,moveImage:fa instanceof +Na,moveMask:null!==fa.mask&&fa.maskLinked,imageRect:new Map,maskRect:new Map}))));let D=new Ha(0,0,0,0);if(this.movingWholeLayer){this.srcRect=ha.getBounds();for(var P=0;P{if(D.moveImage){var P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight());P.getContext("2d").putImageData(D.layer.image.getImageData(),-this.srcRect.left,-this.srcRect.top,this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(), +this.srcRect.getHeight());D.imageSourceCanvas=P}D.moveMask&&(P=Zc(this.srcRect.getWidth(),this.srcRect.getHeight()),P.getContext("2d").putImageData(D.layer.mask.getImageData(this.srcRect.left,this.srcRect.top,this.srcRect.getWidth(),this.srcRect.getHeight()),0,0),D.maskSourceCanvas=P)}),this.composeCanvas=Zc(ha.width,ha.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),pf(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0, +0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(ha.getBounds()));let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),M=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ea=> +{if(fa.forEach(ka=>{ea.moveImage&&ea.layer.image.clearRect(ka,16777215);ea.moveMask&&(this.movingWholeLayer?ea.layer.mask.clearRect(ka,255):ea.layer.mask.clearRect(ka,0))}),!this.dstRect.isEmpty()){if(ea.moveImage){let ka=ea.imageUndo.getImageData();da.forEach(xa=>{this.composeCanvasContext.putImageData(ka,0,0,xa.left,xa.top,xa.getWidth(),xa.getHeight())});this.composeCanvasContext.clearRect(F.left,F.top,F.getWidth(),F.getHeight());this.composeCanvasContext.save();this.composeCanvasContext.setTransform(this.affineTransform.m[0], +this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]);this.composeCanvasContext.drawImage(ea.imageSourceCanvas,this.srcRect.left,this.srcRect.top);this.composeCanvasContext.restore();ea.layer.image.copyBitmapRect(new H(this.composeCanvasContext.getImageData(this.dstRect.left,this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight())),this.dstRect.left,this.dstRect.top,new Ha(0,0,this.dstRect.getWidth(),this.dstRect.getHeight()))}ea.moveMask&& +(da.forEach(ka=>{this.composeCanvasContext.putImageData(ea.layer.mask.getImageData(ka.left,ka.top,ka.getWidth(),ka.getHeight()),ka.left,ka.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle="#FFF":this.composeCanvasContext.fillStyle="#000",this.composeCanvasContext.fillRect(F.left,F.top,F.getWidth(),F.getHeight()),this.composeCanvasContext.save(),this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3], +this.affineTransform.m[4],this.affineTransform.m[5]),this.composeCanvasContext.drawImage(ea.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),ea.layer.mask.pasteImageData(this.composeCanvasContext.getImageData(this.dstRect.left,this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight()),this.dstRect.left,this.dstRect.top))}M.forEach(ka=>{ea.moveImage&&ea.layer.image.copyBitmapRect(ea.imageUndo,ka.left,ka.top,ka);ea.moveMask&&ea.layer.mask.copyBitmapRect(ea.maskUndo, +ka.left,ka.top,ka)})}),k(this.movingLayers.map(ea=>ea.layer),D,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.toPoints(),this.affineTransform.transformPoints(D),(D=Ha.createBoundingBox(D)).roundNearest(),ha.setSelection(D),b());ha.setActiveLayer(this.layer,this.fromMaskMode)}amend(D){this.hasFullUndo||this.undo();this.affineTransform=D.clone();this.redo()}setInterpolation(D){D!=this.interpolation&&(this.interpolation=D,this.composeCanvasContext&&pf(this.composeCanvasContext,"smooth"== +this.interpolation),this.undo(),this.redo())}compact(){super.compact();this.composeCanvasContext=this.composeCanvas=null;this.movingLayers.forEach(D=>D.imageSourceCanvas=null)}getMemoryUsed(D,P){D=super.getMemoryUsed(D,P);return D+=pg(this.composeCanvas),D+=this.movingLayers.map(da=>pg(da.imageSourceCanvas)).reduce(De,0)}getTransform(){return this.affineTransform.clone()}getInitialTransformRect(){return this.srcRect.clone()}getInitialSelectionRect(){return this.fromSelection.clone()}constructor(D, +P){super();this.erasesSourceRect=!0;this.affineTransform=D.clone();this.interpolation=P||"smooth";this.composeCanvasContext=this.composeCanvas=null}}class vc extends ua{redo(){var D=this.dstRect.clone();let P,da,fa=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect),this.dstRect.translate(this.offsetX,this.offsetY),P=this.dstRect.clone(),this.dstRect.clipTo(ha.getBounds()),this.erasesSourceRect?(F=D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),fa.union(F),da=D.subtract(this.srcRect)): +da=[D],this.movingLayers.forEach(M=>{F&&(M.moveImage&&M.layer.image.clearRect(F,16777215),M.moveMask&&M.layer.mask.clearRect(F,this.movingWholeLayer?255:0));da.forEach(function(ea){M.moveImage&&M.layer.image.copyBitmapRect(M.imageUndo,ea.left,ea.top,ea);M.moveMask&&M.layer.mask.copyBitmapRect(M.maskUndo,ea.left,ea.top,ea)});M.moveImage&&T.normalFuseImageOntoImageAtPosition(M.layer.image,M.imageUndo,P.left,P.top,this.srcRect);M.moveMask&&M.layer.mask.copyBitmapRect(M.maskUndo,P.left,P.top,this.srcRect)}), +fa.union(this.dstRect),k(this.movingLayers.map(M=>M.layer),fa,!0,!0),this.fromSelection.isEmpty())||(D=this.fromSelection.clone(),D.translate(this.offsetX,this.offsetY),ha.setSelection(D),b())}amend(D,P){this.hasFullUndo||this.undo();this.offsetX+=D;this.offsetY+=P;this.redo()}constructor(D,P,da){super();this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}za.prototype=Object.create(zc.prototype);za.prototype.constructor=za;na.prototype=Object.create(zc.prototype);na.prototype.constructor=na; Oa=[Nd,xh,yh,zh,fe,Ah,Bh,Ch].map(D=>new D(la,Ca));this.width=a;this.height=c}function wb(a,c,d){this.data=a;this.eof=!1;this.start=void 0===c?0:c;this.end=void 0===d?a.length:d;this.pos=this.start}function Od(a){for(var c=a.length;0<=--c;)a[c]=0}function qf(a,c,d,b,l){this.static_tree=a;this.extra_bits=c;this.extra_base=d;this.elems=b;this.max_length=l;this.has_stree=a&&a.length}function rf(a,c){this.dyn_tree=a;this.max_code=0;this.stat_desc=c}function qg(a){return 256>a?ge[a]:ge[256+(a>>>7)]}function he(a, c){a.pending_buf[a.pending++]=255&c;a.pending_buf[a.pending++]=c>>>8&255}function Ec(a,c,d){a.bi_valid>16-d?(a.bi_buf|=c<>16-a.bi_valid,a.bi_valid+=d-16):(a.bi_buf|=c<>>=1,d<<=1;while(0<--c);return d>>>1}function sg(a,c,d){var b,l=Array(16),p=0;for(b=1;15>=b;b++)l[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=rg(l[b]++,b))}function tg(a){var c; for(c=0;286>c;c++)a.dyn_ltree[2*c]=0;for(c=0;30>c;c++)a.dyn_dtree[2*c]=0;for(c=0;19>c;c++)a.bl_tree[2*c]=0;a.dyn_ltree[512]=1;a.opt_len=a.static_len=0;a.last_lit=a.matches=0}function ug(a){8Aa;Aa++)Ja.continueStroke(db[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,db){if(this.capture)return Aa=L({x:rb,y:hb}),1==F?da=Aa:2==F&&(ka=Aa),Ka.repaintAll(),!0;b.prototype.mouseMove.call(this,Aa,db)};this.paint=function(){if(this.capture){var Aa=new Mg;let db=U(M),gb=U(da),Ea=U(ka),jb=U(xa);Aa.x0=db.x;Aa.y0=db.y;Aa.x1=gb.x;Aa.y1=gb.y;Aa.x2=Ea.x;Aa.y2=Ea.y;Aa.x3=jb.x;Aa.y3=jb.y;let Vb=Array(100),kc=Array(100);Aa.compute(Vb, -kc,100);fa.beginPath();fa.moveTo(Vb[0],kc[0]);for(Aa=1;100>Aa;Aa++)fa.lineTo(Vb[Aa],kc[Aa]);fa.moveTo(~~db.x,~~db.y);fa.lineTo(~~gb.x,~~gb.y);fa.moveTo(~~Ea.x,~~Ea.y);fa.lineTo(~~jb.x,~~jb.y);fa.stroke()}else b.prototype.paint.call(this)};b.call(this)}function e(){var F;this.mouseDown=function(M,da,ka){return!!this.capture||(Z(Sb).isPressed("space")||(0!=da||this.transient&&!M.altKey)&&2!=da?void(this.transient&&ua.pop()):(F=da,this.capture=!0,x("crosshair"),this.mouseDrag(M),!0))};this.mouseDrag= -function(M){if(this.capture)return M=L({x:rb,y:hb}),Ja.isPointWithin(M.x,M.y)&&a.setCurColor(new Bb(Ja.colorPicker(M.x,M.y))),!0};this.mouseUp=function(M,da,ka){if(this.capture&&da==F)return F=-1,this.capture=!1,x("default"),this.transient&&ua.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function k(){var F,M,da,ka;this.keyDown=function(xa){if(" "===xa.key)return this.capture||x("grab"),!0};this.keyUp=function(xa){if(this.transient&&1!=ka&&" "===xa.key)return x("default"),ua.pop(), -!0};this.mouseDown=function(xa,Aa,db){return!!this.capture||(1==Aa||Z(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,ka=Aa,F=xa.pageX,M=xa.pageY,da=Ka.getOffset(),x("grabbing"),!0):void(this.transient&&ua.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ka.setOffset(da.x+xa.pageX-F,da.y+xa.pageY-M),!0};this.mouseUp=function(xa,Aa,db){if(this.capture&&Aa==ka)return ka=-1,this.capture=!1,this.transient&&!Z(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= -function(){x("grab")}}function m(){}function h(){var F,M=new Ha(0,0,0,0),da=-1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!ka.altKey&&!Z(Sb).isPressed("space"))return ka=W({x:rb,y:hb}),da=xa,M.makeEmpty(),F=ka,Ka.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(ka){if(!this.capture)return!1;var xa=W({x:rb,y:hb});ka=ka.shiftKey;var Aa=~~Math.max(Math.abs(xa.x-F.x),Math.abs(xa.y-F.y));return xa.x>=F.x?(M.left=F.x,M.right=(ka?F.x+Aa:xa.x)+1):(M.left=ka?F.x-Aa:xa.x,M.right=F.x+ -1),xa.y>=F.y?(M.top=F.y,M.bottom=(ka?F.y+Aa:xa.y)+1):(M.top=ka?F.y-Aa:xa.y,M.bottom=F.y+1),Ka.repaintAll(),!0};this.mouseUp=function(ka,xa,Aa){if(this.capture&&xa==da)return Ja.rectangleSelection(M),M.makeEmpty(),Ka.repaintAll(),this.capture=!1,da=-1,!0};this.paint=function(){M.isEmpty()||(fa.lineWidth=1,ia(fa,M))}}function n(){var F,M,da=!1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!Z(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),M=ka.altKey,da=!0,this.capture=!0,!0};this.mouseDrag= -Ng(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,Aa=ka.y-F.y,db=~~xa,gb=~~Aa;return(0!=db||0!=gb)&&(Ja.move(db,gb,M&&da),da=!1),F.x=ka.x-(xa-db),F.y=ka.y-(Aa-gb),!0}});this.mouseUp=function(ka,xa,Aa){if(this.capture&&0==xa)return this.capture=!1,this.transient&&ua.pop(),!0}}function r(){function F(Fa,La){return{x:(Fa.x+La.x)/2,y:(Fa.y+La.y)/2}}function M(Fa){return{x:Math.round(Fa.x),y:Math.round(Fa.y)}}function da(Fa,La){for(var Ra=0;Ra=(La.x-Fa.points[Ra].x)* +function nc(){this.modes=[]}function Le(a){function c(){}function d(){}function b(){this.shouldPaintBrushPreview=!1;this.oldPreviewRect=null}function l(){b.call(this);this.smoothMouse={x:0,y:0}}function p(){var F,M;this.mouseDown=function(ea,ka,xa){if(!this.capture&&0==ka&&!ea.altKey&&!Z(Sb).isPressed("space")&&K())return this.capture=!0,F=M={x:rb+.5,y:hb+.5},this.eraseBrushPreview(),!0};this.mouseDrag=function(ea){if(this.capture){var ka=new Ha(Math.min(F.x,M.x)-1-1,Math.min(F.y,M.y)-1-1,Math.max(F.x, +M.x)+1+1+1,Math.max(F.y,M.y)+1+1+1);if(M={x:rb+.5,y:hb+.5},ea.shiftKey){var xa=Math.PI/4;ea=Math.round(Math.atan2(M.y-F.y,M.x-F.x)/xa);switch(ea){case 0:case 4:M.y=F.y;break;case 2:case 6:M.x=F.x;break;default:ea*=xa,xa=Math.sqrt((M.y-F.y)*(M.y-F.y)+(M.x-F.x)*(M.x-F.x)),M.x=F.x+xa*Math.cos(ea),M.y=F.y+xa*Math.sin(ea)}}return ka.union(new Ha(Math.min(F.x,M.x)-1-1,Math.min(F.y,M.y)-1-1,Math.max(F.x,M.x)+1+1+1,Math.max(F.y,M.y)+1+1+1)),Xa(ka),!0}this.mouseMove.call(this,ea)};this.mouseUp=function(ea, +ka,xa){if(this.capture&&0==ka)return ea=L(F),ka=L(M),this.capture=!1,this.drawLine(ea,ka),Xa(new Ha(Math.min(F.x,M.x)-1-1,Math.min(F.y,M.y)-1-1,Math.max(F.x,M.x)+1+1+1,Math.max(F.y,M.y)+1+1+1)),!0};this.paint=function(){this.capture?(ha.lineWidth=1,ha.beginPath(),ha.moveTo(F.x,F.y),ha.lineTo(M.x,M.y),ha.stroke()):b.prototype.paint.call(this)};b.call(this)}function g(){let F=0,M,ea,ka,xa;this.mouseDown=function(Aa,db,gb){if(!this.capture&&0==db&&!Aa.altKey&&!Z(Sb).isPressed("space")&&K())return Aa= +L({x:rb,y:hb}),F=0,M=ea=ka=xa=Aa,this.capture=!0,this.eraseBrushPreview(),!0};this.mouseDrag=function(Aa){if(this.capture&&0===F)return ka=xa=L({x:rb,y:hb}),Ka.repaintAll(),!0;this.mouseMove.call(this,Aa)};this.mouseUp=function(Aa,db,gb){if(this.capture&&0==db){switch(F){case 0:F=1;break;case 1:F=2;break;case 2:this.capture=!1;db=M;gb=ea;let Ea=ka,jb=xa;Aa=new Mg;Aa.x0=db.x;Aa.y0=db.y;Aa.x1=gb.x;Aa.y1=gb.y;Aa.x2=Ea.x;Aa.y2=Ea.y;Aa.x3=jb.x;Aa.y3=jb.y;db=Array(500);gb=Array(500);Aa.compute(db,gb,500); +Ja.beginStroke(db[0],gb[0],1);for(Aa=1;500>Aa;Aa++)Ja.continueStroke(db[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,db){if(this.capture)return Aa=L({x:rb,y:hb}),1==F?ea=Aa:2==F&&(ka=Aa),Ka.repaintAll(),!0;b.prototype.mouseMove.call(this,Aa,db)};this.paint=function(){if(this.capture){var Aa=new Mg;let db=U(M),gb=U(ea),Ea=U(ka),jb=U(xa);Aa.x0=db.x;Aa.y0=db.y;Aa.x1=gb.x;Aa.y1=gb.y;Aa.x2=Ea.x;Aa.y2=Ea.y;Aa.x3=jb.x;Aa.y3=jb.y;let Vb=Array(100),kc=Array(100);Aa.compute(Vb, +kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(Aa=1;100>Aa;Aa++)ha.lineTo(Vb[Aa],kc[Aa]);ha.moveTo(~~db.x,~~db.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Ea.x,~~Ea.y);ha.lineTo(~~jb.x,~~jb.y);ha.stroke()}else b.prototype.paint.call(this)};b.call(this)}function e(){var F;this.mouseDown=function(M,ea,ka){return!!this.capture||(Z(Sb).isPressed("space")||(0!=ea||this.transient&&!M.altKey)&&2!=ea?void(this.transient&&ua.pop()):(F=ea,this.capture=!0,x("crosshair"),this.mouseDrag(M),!0))};this.mouseDrag= +function(M){if(this.capture)return M=L({x:rb,y:hb}),Ja.isPointWithin(M.x,M.y)&&a.setCurColor(new Bb(Ja.colorPicker(M.x,M.y))),!0};this.mouseUp=function(M,ea,ka){if(this.capture&&ea==F)return F=-1,this.capture=!1,x("default"),this.transient&&ua.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function k(){var F,M,ea,ka;this.keyDown=function(xa){if(" "===xa.key)return this.capture||x("grab"),!0};this.keyUp=function(xa){if(this.transient&&1!=ka&&" "===xa.key)return x("default"),ua.pop(), +!0};this.mouseDown=function(xa,Aa,db){return!!this.capture||(1==Aa||Z(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,ka=Aa,F=xa.pageX,M=xa.pageY,ea=Ka.getOffset(),x("grabbing"),!0):void(this.transient&&ua.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ka.setOffset(ea.x+xa.pageX-F,ea.y+xa.pageY-M),!0};this.mouseUp=function(xa,Aa,db){if(this.capture&&Aa==ka)return ka=-1,this.capture=!1,this.transient&&!Z(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= +function(){x("grab")}}function m(){}function h(){var F,M=new Ha(0,0,0,0),ea=-1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!ka.altKey&&!Z(Sb).isPressed("space"))return ka=W({x:rb,y:hb}),ea=xa,M.makeEmpty(),F=ka,Ka.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(ka){if(!this.capture)return!1;var xa=W({x:rb,y:hb});ka=ka.shiftKey;var Aa=~~Math.max(Math.abs(xa.x-F.x),Math.abs(xa.y-F.y));return xa.x>=F.x?(M.left=F.x,M.right=(ka?F.x+Aa:xa.x)+1):(M.left=ka?F.x-Aa:xa.x,M.right=F.x+ +1),xa.y>=F.y?(M.top=F.y,M.bottom=(ka?F.y+Aa:xa.y)+1):(M.top=ka?F.y-Aa:xa.y,M.bottom=F.y+1),Ka.repaintAll(),!0};this.mouseUp=function(ka,xa,Aa){if(this.capture&&xa==ea)return Ja.rectangleSelection(M),M.makeEmpty(),Ka.repaintAll(),this.capture=!1,ea=-1,!0};this.paint=function(){M.isEmpty()||(ha.lineWidth=1,ia(ha,M))}}function n(){var F,M,ea=!1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!Z(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),M=ka.altKey,ea=!0,this.capture=!0,!0};this.mouseDrag= +Ng(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,Aa=ka.y-F.y,db=~~xa,gb=~~Aa;return(0!=db||0!=gb)&&(Ja.move(db,gb,M&&ea),ea=!1),F.x=ka.x-(xa-db),F.y=ka.y-(Aa-gb),!0}});this.mouseUp=function(ka,xa,Aa){if(this.capture&&0==xa)return this.capture=!1,this.transient&&ua.pop(),!0}}function r(){function F(Fa,La){return{x:(Fa.x+La.x)/2,y:(Fa.y+La.y)/2}}function M(Fa){return{x:Math.round(Fa.x),y:Math.round(Fa.y)}}function ea(Fa,La){for(var Ra=0;Ra=(La.x-Fa.points[Ra].x)* (La.x-Fa.points[Ra].x)+(La.y-Fa.points[Ra].y)*(La.y-Fa.points[Ra].y))return 2*Ra;for(Ra=0;Ra=Ac&&(pb.scale(Ac),49>=(pb.x-nb.x)*(pb.x-nb.x)+(pb.y-nb.y)*(pb.y-nb.y)))return 2*Ra+1}return Fa.containsPoint(La)?-3:-2}function ka(){var Fa=gb.getTransformed(Db), -La=da(Fa,{x:rb,y:hb});switch(La){case 0:case 2:case 4:case 6:La=~~(La/2);let Ra=Fa.points[La],nb=Fa.points[(La+1)%4];xa(Mb.subtractPoints(Fa.points[(La+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Fa.points[(~~(La/2)+1)%4],Fa.points[~~(La/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Fa){Fa=Math.floor(Math.atan2(-Fa.y,Fa.x)/(Math.PI/4)+.5);switch(0>Fa&&(Fa+=4),Fa){default:Fa="ew-resize"; -break;case 1:Fa="nesw-resize";break;case 2:Fa="ns-resize";break;case 3:Fa="nwse-resize"}x(Fa)}var Aa,db,gb,Ea,jb,Vb,kc=-1;this.mouseDown=function(Fa,La,Ra){if(!this.capture&&0==La&&!Fa.altKey&&!Z(Sb).isPressed("space"))return kc=da(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Ea={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Ng(40,function(Fa){if(this.capture){var La={x:rb,y:hb};switch(kc){case -3:Fa=M(L(La));var Ra=Mb.subtractPoints(Fa,jb);La=Ra.getTruncated();Ra=Ra.subtract(La);var nb=new Kb;nb.translate(La.x, +La=ea(Fa,{x:rb,y:hb});switch(La){case 0:case 2:case 4:case 6:La=~~(La/2);let Ra=Fa.points[La],nb=Fa.points[(La+1)%4];xa(Mb.subtractPoints(Fa.points[(La+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Fa.points[(~~(La/2)+1)%4],Fa.points[~~(La/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Fa){Fa=Math.floor(Math.atan2(-Fa.y,Fa.x)/(Math.PI/4)+.5);switch(0>Fa&&(Fa+=4),Fa){default:Fa="ew-resize"; +break;case 1:Fa="nesw-resize";break;case 2:Fa="ns-resize";break;case 3:Fa="nwse-resize"}x(Fa)}var Aa,db,gb,Ea,jb,Vb,kc=-1;this.mouseDown=function(Fa,La,Ra){if(!this.capture&&0==La&&!Fa.altKey&&!Z(Sb).isPressed("space"))return kc=ea(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Ea={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Ng(40,function(Fa){if(this.capture){var La={x:rb,y:hb};switch(kc){case -3:Fa=M(L(La));var Ra=Mb.subtractPoints(Fa,jb);La=Ra.getTruncated();Ra=Ra.subtract(La);var nb=new Kb;nb.translate(La.x, La.y);Aa.preMultiply(nb);jb=Mb.subtractPoints(Fa,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=U(Ra),wc=Math.atan2(La.y-pb.y,La.x-pb.x)-Math.atan2(Ea.y-pb.y,Ea.x-pb.x);pb=new Kb;Vb+=wc;Fa=Fa.shiftKey?-Aa.decompose().rotate+Math.round(Vb/nb)*nb:wc;pb.rotateAroundPoint(Fa,Ra.x,Ra.y);Aa.preMultiply(pb);Ea=La;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=db.points[nb];pb=Aa.getInverted().getTransformedPoint(M(L(La)));La=db.points[(nb+2)%4];nb=(pb.x-La.x)/(Ra.x-La.x);Ra=(pb.y-La.y)/(Ra.y- La.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Fa.shiftKey&&(Ra=nb=Fa=Math.max(nb,Ra));Aa.scaleAroundPoint(nb,Ra,La.x,La.y);break;case 1:case 5:case 3:case 7:Fa=~~(kc/2);pb=F(db.points[Fa],db.points[(Fa+1)%4]);La=Aa.getInverted().getTransformedPoint(M(L(La)));Fa=F(db.points[(Fa+2)%4],db.points[(Fa+3)%4]);pb=Mb.subtractPoints(pb,Fa);La=Mb.subtractPoints(La,Fa);wc=pb.getLength();La=pb.getDotProduct(La)/wc/wc;if(.001>Math.abs(La)||isNaN(La))return!0;1==kc||5==kc?(Ra=1,nb= La):(Ra=La,nb=1);Aa.scaleAroundPoint(Ra,nb,Fa.x,Fa.y)}return gb=db.getTransformed(Aa),Ja.transformAffineAmend(Aa),Ka.repaintAll(),!0}});this.mouseUp=function(Fa,La,Ra){if(this.capture&&0==La)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||ka()};this.paint=function(){var Fa=gb.getTransformed(Db).points,La=Array(2*Fa.length);for(var Ra=0;RaMath.abs(ka-1)?F=1:.2>Math.abs(ka-2)?F=2:.08>Math.abs(ka-.5)&&(F=.5);S(F,M/2,da/2)}function na(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure?1:"touch"===F.pointerType?(0!==F.pressure&&(Ic=!0), -Ic)?2*F.pressure:1:2*F.pressure}function mb(){fb||(fb=!0,window.requestAnimationFrame(function(){Ka.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ja.getBounds();Ka.repaintAll()}let Fb,Ka=this,Ma=document.createElement("div"),la=document.createElement("div"),Ca=document.createElement("div"),ya=document.createElement("canvas"),fa=ya.getContext("2d"),Oa=document.createElement("canvas"),qa=Oa.getContext("2d"),Ta=Og(fa),Ja=a.getArtwork(),kb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,lb=32,rb= +F.y=Math.floor(F.y),F}function U(F){return Db.getTransformedPoint(F)}function X(F){F=U(F);return F.x=Math.round(F.x),F.y=Math.round(F.y),F}function Y(F,M){F.beginPath();F.moveTo(M[0].x,M[0].y);for(var ea=1;eaMath.abs(ka-1)?F=1:.2>Math.abs(ka-2)?F=2:.08>Math.abs(ka-.5)&&(F=.5);S(F,M/2,ea/2)}function na(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure?1:"touch"===F.pointerType?(0!==F.pressure&&(Ic=!0), +Ic)?2*F.pressure:1:2*F.pressure}function mb(){fb||(fb=!0,window.requestAnimationFrame(function(){Ka.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ja.getBounds();Ka.repaintAll()}let Fb,Ka=this,Ma=document.createElement("div"),la=document.createElement("div"),Ca=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),qa=Oa.getContext("2d"),Ta=Og(ha),Ja=a.getArtwork(),kb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,lb=32,rb= 0,hb=0,Tb=!1,vb=[!1,!1,!1],Rb=!1,Ib=!1,Ic=!1,ec=Ja.getBounds(),Va=new Ha(0,0,0,0),fb=!1,Yb;let Ya,Rc,Sc,A,ta,uc,Nc,Xb,$c=[],ua=new nc,fc,vc=new ne(!1),D=new ne(!0),P=ed.getRef();Math.sign=Math.sign||function(F){return 0==(F=+F)||isNaN(F)?F:0navigator.maxTouchPoints)&&b.prototype.mouseMove.call(this,F,M),this.capture){F=L({x:rb,y:hb});var da=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let ka=1-da;return this.smoothMouse.x=ka*F.x+da*this.smoothMouse.x,this.smoothMouse.y=ka*F.y+da*this.smoothMouse.y,Ja.continueStroke(this.smoothMouse.x,this.smoothMouse.y,M),!0}this.mouseMove(F)}; -l.prototype.mouseUp=function(F,M,da){if(this.capture)return 0==M&&(this.capture=!1,Ja.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,M){Ja.beginStroke(F.x,F.y,1);Ja.continueStroke(M.x,M.y,1);Ja.endStroke()};g.prototype=Object.create(b.prototype);g.prototype.constructor=g;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;k.prototype=Object.create(c.prototype);k.prototype.constructor=k;m.prototype=Object.create(c.prototype); -m.prototype.constructor=m;m.prototype.mouseDown=function(F,M,da){if(0==M&&!F.altKey&&!Z(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ja.isPointWithin(F.x,F.y)&&(Ja.floodFill(F.x,F.y),Ka.repaintAll()),!0};h.prototype=Object.create(c.prototype);h.prototype.constructor=h;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!Z(Sb).isPressed("r"))return x("move"),!0};n.prototype.enter=function(){x("move")};r.prototype=Object.create(c.prototype);r.prototype.constructor= +function(){if(this.shouldPaintBrushPreview){this.shouldPaintBrushPreview=!1;var F=this.getBrushPreviewOval();ha.beginPath();ha.arc((F.left+F.right)/2,(F.top+F.bottom)/2,F.getWidth()/2,0,2*Math.PI);ha.stroke();F.grow(2,2);null==this.oldPreviewRect?this.oldPreviewRect=F:this.oldPreviewRect.union(F)}};l.prototype=Object.create(b.prototype);l.prototype.constructor=l;l.prototype.mouseDown=function(F,M,ea){if(!this.capture&&0==M&&!F.altKey&&!Z(Sb).isPressed("space")&&K()&&(F=L({x:rb,y:hb}),this.eraseBrushPreview(), +Ja.beginStroke(F.x,F.y,ea)))return this.capture=!0,this.smoothMouse=F,!0};l.prototype.mouseDrag=function(F,M){if(("number"!=typeof navigator.maxTouchPoints||3>navigator.maxTouchPoints)&&b.prototype.mouseMove.call(this,F,M),this.capture){F=L({x:rb,y:hb});var ea=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let ka=1-ea;return this.smoothMouse.x=ka*F.x+ea*this.smoothMouse.x,this.smoothMouse.y=ka*F.y+ea*this.smoothMouse.y,Ja.continueStroke(this.smoothMouse.x,this.smoothMouse.y,M),!0}this.mouseMove(F)}; +l.prototype.mouseUp=function(F,M,ea){if(this.capture)return 0==M&&(this.capture=!1,Ja.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,M){Ja.beginStroke(F.x,F.y,1);Ja.continueStroke(M.x,M.y,1);Ja.endStroke()};g.prototype=Object.create(b.prototype);g.prototype.constructor=g;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;k.prototype=Object.create(c.prototype);k.prototype.constructor=k;m.prototype=Object.create(c.prototype); +m.prototype.constructor=m;m.prototype.mouseDown=function(F,M,ea){if(0==M&&!F.altKey&&!Z(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ja.isPointWithin(F.x,F.y)&&(Ja.floodFill(F.x,F.y),Ka.repaintAll()),!0};h.prototype=Object.create(c.prototype);h.prototype.constructor=h;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!Z(Sb).isPressed("r"))return x("move"),!0};n.prototype.enter=function(){x("move")};r.prototype=Object.create(c.prototype);r.prototype.constructor= r;u.prototype=Object.create(c.prototype);u.prototype.constructor=u;v.prototype=Object.create(p.prototype);v.prototype.constructor=v;v.prototype.drawLine=function(F,M){Ja.gradientFill(Math.round(F.x),Math.round(F.y),Math.round(M.x),Math.round(M.y),a.getCurGradient())};v.prototype.queueBrushPreview=function(){};this.setZoom=function(F){kb=F;G()};this.getZoom=function(){return kb};this.setGridSize=function(F){lb=Math.max(Math.round(F),1);this.repaintAll()};this.getGridSize=function(){return lb};this.setOffset= -function(F,M){isNaN(F)||isNaN(M)?console.log("Bad offset"):(bc=F,jc=M,G())};this.getOffset=function(){return{x:bc,y:jc}};this.setInterpolation=function(F){sb=F;pf(fa,F);this.repaintAll()};this.setRotation=function(F){Nb=F%(2*Math.PI);G()};this.getRotation=function(){return Nb};this.getRotation90=function(){var F=Math.round(this.getRotation()/Math.PI*2);return 0>(F%=4)&&(F+=4),F};this.zoomIn=function(){za(1.41*this.getZoom())};this.zoomOut=function(){za(.7092*this.getZoom())};this.zoom100=function(){za(1); -Ia()};this.resetRotation=function(){var F=ya.width/2,M=ya.height/2,da=new Kb;da.rotateAroundPoint(-this.getRotation(),F,M);da.multiply(Db);this.setOffset(~~da.getTranslateX(),~~da.getTranslateY());this.setRotation(0);Ka.emitEvent("canvasRotated90",[0])};let ea=!1;this.getElement=function(){return Ma};this.repaintAll=function(){Va.left=0;Va.top=0;Va.right=ya.width;Va.bottom=ya.height;mb()};this.paint=function(){var F=!1;if(fb=!1,Va.isEmpty()||(fa.save(),fa.clipTo&&(fa.beginPath(),Va.left|=0,Va.top|= -0,fa.rect(Va.left,Va.top,Math.ceil(Va.getWidth()),Math.ceil(Va.getHeight())),fa.clip()),F=!0),!ec.isEmpty()){var M=Yb&&Yb.isOpen()?Yb.getImageData():Ja.fusionLayers().getImageData();qa.putImageData(M,0,0,ec.left,ec.top,ec.getWidth(),ec.getHeight());ec.makeEmpty()}if(fa.fillStyle="#606060",fa.fillRect(0,0,ya.width,ya.height),fa.save(),fa.setTransform(Db.m[0],Db.m[1],Db.m[2],Db.m[3],Db.m[4],Db.m[5]),fa.fillStyle=Ta,fa.fillRect(0,0,Ja.width,Ja.height),fa.drawImage(Oa,0,0,Oa.width,Oa.height),fa.restore(), -Ke(fa,"stroke"),fa.lineWidth=1,Ja.getSelection().isEmpty()||ua.peek()instanceof h&&ua.peek().capture||(fa.setLineDash([3,2]),ia(fa,Ja.getSelection()),fa.setLineDash([])),Wb)if(M=Ja.getBounds(),2(F%=4)&&(F+=4),F};this.zoomIn=function(){za(1.41*this.getZoom())};this.zoomOut=function(){za(.7092*this.getZoom())};this.zoom100=function(){za(1); +Ia()};this.resetRotation=function(){var F=ya.width/2,M=ya.height/2,ea=new Kb;ea.rotateAroundPoint(-this.getRotation(),F,M);ea.multiply(Db);this.setOffset(~~ea.getTranslateX(),~~ea.getTranslateY());this.setRotation(0);Ka.emitEvent("canvasRotated90",[0])};let da=!1;this.getElement=function(){return Ma};this.repaintAll=function(){Va.left=0;Va.top=0;Va.right=ya.width;Va.bottom=ya.height;mb()};this.paint=function(){var F=!1;if(fb=!1,Va.isEmpty()||(ha.save(),ha.clipTo&&(ha.beginPath(),Va.left|=0,Va.top|= +0,ha.rect(Va.left,Va.top,Math.ceil(Va.getWidth()),Math.ceil(Va.getHeight())),ha.clip()),F=!0),!ec.isEmpty()){var M=Yb&&Yb.isOpen()?Yb.getImageData():Ja.fusionLayers().getImageData();qa.putImageData(M,0,0,ec.left,ec.top,ec.getWidth(),ec.getHeight());ec.makeEmpty()}if(ha.fillStyle="#606060",ha.fillRect(0,0,ya.width,ya.height),ha.save(),ha.setTransform(Db.m[0],Db.m[1],Db.m[2],Db.m[3],Db.m[4],Db.m[5]),ha.fillStyle=Ta,ha.fillRect(0,0,Ja.width,Ja.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(), +Ke(ha,"stroke"),ha.lineWidth=1,Ja.getSelection().isEmpty()||ua.peek()instanceof h&&ua.peek().capture||(ha.setLineDash([3,2]),ia(ha,Ja.getSelection()),ha.setLineDash([])),Wb)if(M=Ja.getBounds(),2K&&this.setLocation(this.getX(),Math.max(K-x,0)))};this.userIsDoneWithUs=function(){a.getSmallScreenMode()&& @@ -290,27 +290,27 @@ b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.ap W!==T.LM_MULTIPLY||L.blendMode===W||L.useLegacyMultiply?U.value=W:U.value=T.LM_MULTIPLY2;h.appendChild(U)}})();G.getBlendMode()!=parseInt(h.value,10)&&(h.value=G.getBlendMode());G.getLockAlpha()!=u.checked&&(u.checked=G.getLockAlpha());(function(){var L;let W={"image-layer":(L=l.getActiveLayer())instanceof Na,"layer-group":L instanceof ob,"clipping-mask":L instanceof Na&&L.clip,"no-clipping-mask":L instanceof Na&&!L.clip,"no-clipping-mask-or-is-group":!(L instanceof Na)||!L.clip,mask:L&&null!==L.mask, "no-mask":L&&null===L.mask,"mask-enabled":L&&null!==L.mask&&L.maskVisible,"mask-disabled":L&&null!==L.mask&&!L.maskVisible};for(let U of"mask no-mask clipping-mask no-clipping-mask-or-is-group image-layer layer-group".split(" "))for(let X of x.getElementsByClassName("chickenpaint-action-require-"+U))X.style.display=W[U]?"inline-block":"none";x.querySelectorAll("[data-action]").forEach(function(U){let X=U.getAttribute("data-action");U.classList.toggle("disabled",!a.isActionAllowed(X))})})()}function d(){l= this;k.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,l=a.getArtwork(),p=null,g=this.getBodyElement(),e=this.getElement(),k=new function(){function G(Ma){let la=document.querySelectorAll(".chickenpaint-layer",Xa);return la[la.length-1-Ma]}function L(Ma){Ma=Ma.closest(".chickenpaint-layer");if(!Ma)return-1;let la=Array.from(Xa.querySelectorAll(".chickenpaint-layer"));return la.length-1-la.indexOf(Ma)}function W(){if(2===na.state){let ya=e.getBoundingClientRect(); -var Ma=!0;let fa=!0;if(na.dropTarget=function(Oa,qa){var Ta=Z(ma)(".chickenpaint-layer",Xa);Oa={layer:p[p.length-1],displayIndex:p.length-1,direction:"over"};for(var Ja=0;Jakb.bottom){Oa=l.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=kb.top){Ta=p[Ja];let bc=kb.bottom-kb.top;Oa={layer:Ta,displayIndex:Ja};Ta instanceof ob?qa>=kb.top+.75*bc?Ta.expanded&&0kb.bottom){Oa=l.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=kb.top){Ta=p[Ja];let bc=kb.bottom-kb.top;Oa={layer:Ta,displayIndex:Ja};Ta instanceof ob?qa>=kb.top+.75*bc?Ta.expanded&&0=kb.top+.25*bc?Ta.expanded&&0=kb.top+.5*bc?Oa.direction="under":Oa.direction="over";break}}return Oa.layer.parent==na.layer.parent&&("over"==Oa.direction||"under"==Oa.direction)&&(qa=Oa.layer.parent,Ja=qa.indexOf(Oa.layer),"over"==Oa.direction&&qa.layers[Ja+ 1]==na.layer||"under"==Oa.direction&&qa.layers[Ja-1]==na.layer||Oa.layer==na.layer)?null:na.layer instanceof ob&&(Oa.layer==na.layer&&"inside"==Oa.direction||Oa.layer.hasAncestor(na.layer))?null:Oa}(na.dragX,na.dragY),na.dropTarget){var la=G(na.dropTarget.displayIndex);switch(na.dropTarget.direction){case "over":case "under":Xa.appendChild(na.dropBetweenMarkerElem);Ma=na.dropTarget.layer.getDepth()-1;var Ca;if(la=la.getBoundingClientRect(),"under"==na.dropTarget.direction&&na.dropTarget.layer instanceof ob&&na.dropTarget.layer.expanded){for(Ca=na.dropTarget.displayIndex-1;0<=Ca&&p[Ca].hasAncestor(na.dropTarget.layer);Ca--);Ca=G(Ca+1).getBoundingClientRect().bottom}else Ca=la.bottom;Ma=la.left-ya.left+(0Y(fa,ya)),Ca=document.createDocumentFragment();Z(ma)(Xa).empty();for(let ya=la.length-1;0<=ya;ya--)Ca.appendChild(la[ya]);Xa.appendChild(Ca);W()},this.layerChanged=function(la){let Ca=p.indexOf(la),ya=Z(ma)(G(Ca));0===ya.length||la instanceof ob&&(la.expanded!=Z(ma)(ya).hasClass("chickenpaint-layer-group-expanded")||la.visible!=Z(ma)(ya).hasClass("chickenpaint-layer-visible"))? +Xa=document.createElement("div"),Lb=0,Fb=!1,Ka=null;for(let Ma of(this.buildLayers=function(){let la=(p=l.getLayersRoot().getLinearizedLayerList(!0)).map((ya,ha)=>Y(ha,ya)),Ca=document.createDocumentFragment();Z(ma)(Xa).empty();for(let ya=la.length-1;0<=ya;ya--)Ca.appendChild(la[ya]);Xa.appendChild(Ca);W()},this.layerChanged=function(la){let Ca=p.indexOf(la),ya=Z(ma)(G(Ca));0===ya.length||la instanceof ob&&(la.expanded!=Z(ma)(ya).hasClass("chickenpaint-layer-group-expanded")||la.visible!=Z(ma)(ya).hasClass("chickenpaint-layer-visible"))? this.buildLayers():ya.replaceWith(Y(Ca,la))},this.setRotation90=function(la){if(Lb!=la)for(Lb=la,la=0;lala.preventDefault(),!0),Xa.className="list-group",Xa.addEventListener("dblclick",function(la){0===la.button&&0{3===na.state&&(Ia(),na.dragY=la.clientY,W())},800)):na.state=1,na.dropTarget=null,na.layer=ya,na.layerElem=G(Ca),na.dragX=la.clientX,na.dragY=la.clientY,Xa.setPointerCapture(la.pointerId),Xa.addEventListener("pointermove",S),Xa.addEventListener("pointerup",wa)):2==la.button&&!fa&&(la.preventDefault(),-1!=L(la.target)&&(ia(L(la.target)),la.preventDefault()))}}}}), +if(-1!=Ca){let ya=p[Ca];if(0==la.button&&Z(ma)(la.target).closest(".chickenpaint-layer-eye").length)a.actionPerformed({action:"CPSetLayerVisibility",layer:ya,visible:!ya.visible});else if(0==la.button&&ya instanceof ob&&Z(ma)(la.target).closest(".chickenpaint-layer-group-toggle").length)a.actionPerformed({action:"CPExpandLayerGroup",group:ya,expand:!ya.expanded});else{let ha=l.getActiveLayer()!=ya;if(Fb=0{3===na.state&&(Ia(),na.dragY=la.clientY,W())},800)):na.state=1,na.dropTarget=null,na.layer=ya,na.layerElem=G(Ca),na.dragX=la.clientX,na.dragY=la.clientY,Xa.setPointerCapture(la.pointerId),Xa.addEventListener("pointermove",S),Xa.addEventListener("pointerup",wa)):2==la.button&&!ha&&(la.preventDefault(),-1!=L(la.target)&&(ia(L(la.target)),la.preventDefault()))}}}}), Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(Ma,Sh);mb.appendChild(Xa)},m=new Fc(0,100,!1,!1,208),h=document.createElement("select"),n=new function(){let G=null,L="",W=document.createElement("input"),U=this;this.hide=function(){G=null;let X=Z(ma)(W).parent();X&&(Z(ma)(W).remove(),X.text(L))};this.renameAndHide=function(){G&&G.name!=W.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:W.value});this.hide()};this.show= function(X,Y){L=(G=X).name;W.value=L;(X=Y.querySelector(".chickenpaint-layer-name"))&&X.parentNode&&(Y=X.firstChild)&&Y.nodeType===Node.TEXT_NODE&&(X.removeChild(Y),X.appendChild(W));W.select()};W.type="text";W.className="chickenpaint-layer-rename form-control input-sm";W.addEventListener("keydown",function(X){X.stopPropagation()});W.addEventListener("keydown",function(X){"Enter"===X.key&&U.renameAndHide();X.stopPropagation()});W.addEventListener("keyup",function(X){"Escape"===X.key&&U.hide();X.stopPropagation()}); W.addEventListener("blur",function(X){G&&U.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,J=this.setHeight;this.setSize=function(G,L){C.call(this,G,L);this.dismissNotification();m.resize()};this.setWidth=function(G){K.call(this,G);m.resize();k.resize()};this.setHeight=function(G){J.call(this,G);k.resize()};this.setRotation90=function(G){k.setRotation90(G)};this.dismissNotification=function(){Z(ma)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", @@ -356,7 +356,7 @@ function(){l.togglePalettes()};this.arrangePalettes=function(){setTimeout(l.arra function(m){g!==m&&(g=m,e.resize(),e.arrangePalettes())};this.resize=function(){let m=window.innerHeight,h=p.getElement().getBoundingClientRect().height;b.resize(g?m-h:Math.min(Math.max(m-h-65,500),850),!1);e.constrainPalettes()};p=new Uh(a,this);c.appendChild(p.getElement());d.className="chickenpaint-main-section";d.appendChild(b.getElement());d.appendChild(l.getElement());c.appendChild(d);b.on("canvasRotated90",function(m){l.palettes.layers.setRotation90(m)});screen.orientation&&screen.orientation.addEventListener("change", m=>{this.resize();a.actionPerformed({action:"CPArrangePalettes"});setTimeout(()=>{this.resize();a.actionPerformed({action:"CPArrangePalettes"})},10);Promise.resolve().then(()=>{this.resize()}).then(()=>{a.actionPerformed({action:"CPArrangePalettes"})})});let k=document.getElementById("chickenpaint-main-menu-content");if(document.addEventListener("show.bs.modal",()=>{k&&k.classList.contains("show")&&(new oc.Collapse(k,{toggle:!1})).hide()}),k){let m=document.querySelector(".chickenpaint .widget-nav"); m&&(k.addEventListener("show.bs.collapse",h=>{m.classList.add("hidden")}),k.addEventListener("hidden.bs.collapse",h=>{m.classList.remove("hidden")}));window.addEventListener("resize",()=>{m.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen",m=>this.setFullScreenMode(m));a.on("toolbarStyleChange",m=>{Z(ma)(c).toggleClass("chickenpaint-toolbar-style-old","old"===m)});a.on("unsavedChanges", -m=>{Z(ma)(c).toggleClass("chickenpaint-unsaved",m)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=Z(ma)('