From cd18fc940ac0fedd95d137e5869c749d4cf28dcf Mon Sep 17 00:00:00 2001 From: satopian Date: Wed, 6 Nov 2024 19:50:37 +0900 Subject: [PATCH] =?UTF-8?q?chickenpaint.js=20=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- potiboard5/chickenpaint/js/chickenpaint.js | 367 +++++++++--------- .../chickenpaint/js/chickenpaint.min.js | 367 +++++++++--------- 2 files changed, 368 insertions(+), 366 deletions(-) diff --git a/potiboard5/chickenpaint/js/chickenpaint.js b/potiboard5/chickenpaint/js/chickenpaint.js index a3be7aed..bc440b07 100644 --- a/potiboard5/chickenpaint/js/chickenpaint.js +++ b/potiboard5/chickenpaint/js/chickenpaint.js @@ -75,19 +75,19 @@ function k(D,P,ea,fa){Array.isArray(D)||(D=[D]);D.forEach(N=>Xa.invalidateLayerR 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=ha.getBounds();Fb.set(D);Ma.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0N.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,ea){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,da=fa.layers[fa.indexOf(D)+1],ka=P.layers[ea],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;Eada["get"+ea]());this.to=N;this.redo()};return fa.prototype=Object.create(zc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> -F["set"+ea](this.from[N]));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+ea](this.to));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var da=F.layers;if(N.length!=da.length)N=!1;else{for(let ka=0;kaN.getMemoryUsed()).reduce(De,0)};this.redo()}function wa(D,P,ea){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,da=fa.layers[fa.indexOf(D)+1],la=P.layers[ea],xa=D instanceof Na&&D.clip,Aa=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Na&&!D.clip)for(var Ea=F+1;Eada["get"+ea]());this.to=N;this.redo()};return fa.prototype=Object.create(zc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> +F["set"+ea](this.from[N]));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+ea](this.to));this.layers.forEach(F=>g(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var da=F.layers;if(N.length!=da.length)N=!1;else{for(let la=0;laT.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===T.LM_MULTIPLY&&(ea=fa)}if(-1!==ea){fa=new H(this.width,this.height);let N=F=!0,da=this.getBounds();fa.clearAll(da,16777215);for(let ka=0;ka<=ea;ka++){let xa=P[ka];N||(F=F&&fa.hasAlphaInRect(da));xa.blendMode===T.LM_MULTIPLY&&("bake"===D?!F&&0T.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===T.LM_MULTIPLY&&(ea=fa)}if(-1!==ea){fa=new H(this.width,this.height);let N=F=!0,da=this.getBounds();fa.clearAll(da,16777215);for(let la=0;la<=ea;la++){let xa=P[la];N||(F=F&&fa.hasAlphaInRect(da));xa.blendMode===T.LM_MULTIPLY&&("bake"===D?!F&&0F){let N=Tb,da=vb,ka=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,da=F*P+(1-F)*vb,ka=F*ea+(1-F)*Rb,this.paintDab(N,da,ka);Tb=N;vb=da;Rb=ka}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),lb.clipTo(this.getBounds()),lb.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(), +this.setLayerLockAlpha=function(D){qa.getLockAlpha()!=D&&C(new Xb(qa,D))};this.setForegroundColor=function(D){Yb=D};this.setBrush=function(D){hb=D};this.setBrushTexture=function(D){ya.setTexture(D)};this.beginStroke=function(D,P,ea){return!(null===hb||!this.isActiveLayerDrawable())&&(v(),lb.makeEmpty(),ma.clearAll(0),Ca.makeEmpty(),Tb=D,vb=P,Rb=ea,Ic=!0,Oa[hb.brushMode].beginStroke(),this.paintDab(D,P,ea),!0)};this.continueStroke=function(D,P,ea){if(null!=hb){var fa=Math.sqrt((Tb-D)*(Tb-D)+(vb-P)* +(vb-P)),F=Math.max(hb.minSpacing,hb.curSize*hb.spacing);if(fa>F){let N=Tb,da=vb,la=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,da=F*P+(1-F)*vb,la=F*ea+(1-F)*Rb,this.paintDab(N,da,la);Tb=N;vb=da;Rb=la}}};this.endStroke=function(){null!=hb&&(n(),Oa[hb.brushMode].endStroke(),lb.clipTo(this.getBounds()),lb.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;Z.prototype=Object.create(zc.prototype);Z.prototype.constructor=Z;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,fa)=>{P.layer.image.copyBitmapRect(ea,fa.left,fa.top,ea.getBounds())}), @@ -122,16 +122,16 @@ this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new this.movingLayers[P];ea.moveMask&&D.union(ea.layer.mask.getValueBounds(this.srcRect,255));ea.moveImage&&D.union(ea.layer.image.getNonTransparentBounds(this.srcRect))}}else for(this.srcRect=this.fromSelection.clone(),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}),of(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 ea=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),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(da=>{if(fa.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= +let ea=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),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(da=>{if(fa.forEach(la=>{da.moveImage&&da.layer.image.clearRect(la,16777215);da.moveMask&&(this.movingWholeLayer?da.layer.mask.clearRect(la,255):da.layer.mask.clearRect(la,0))}),!this.dstRect.isEmpty()){if(da.moveImage){let la= +da.imageUndo.getImageData();ea.forEach(xa=>{this.composeCanvasContext.putImageData(la,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(la=>{this.composeCanvasContext.putImageData(da.layer.mask.getImageData(la.left,la.top,la.getWidth(),la.getHeight()),la.left,la.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))}N.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(),ha.setSelection(D),b());ha.setActiveLayer(this.layer, +this.dstRect.top,this.dstRect.getWidth(),this.dstRect.getHeight()),this.dstRect.left,this.dstRect.top))}N.forEach(la=>{da.moveImage&&da.layer.image.copyBitmapRect(da.imageUndo,la.left,la.top,la);da.moveMask&&da.layer.mask.copyBitmapRect(da.maskUndo,la.left,la.top,la)})}),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(),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&&of(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,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),ea=D.subtract(this.srcRect)):ea=[D],this.movingLayers.forEach(N=>{F&&(N.moveImage&&N.layer.image.clearRect(F,16777215),N.moveMask&&N.layer.mask.clearRect(F,this.movingWholeLayer?255:0));ea.forEach(function(da){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,da.left,da.top,da);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo, da.left,da.top,da)});N.moveImage&&T.normalFuseImageOntoImageAtPosition(N.layer.image,N.imageUndo,P.left,P.top,this.srcRect);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo,P.left,P.top,this.srcRect)}),fa.union(this.dstRect),k(this.movingLayers.map(N=>N.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,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;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 pf(a,c,d,b,m){this.static_tree=a;this.extra_bits=c; +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;Oa=[Nd,xh,yh,zh,fe,Ah,Bh,Ch].map(D=>new D(ma,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 pf(a,c,d,b,m){this.static_tree=a;this.extra_bits=c; this.extra_base=d;this.elems=b;this.max_length=m;this.has_stree=a&&a.length}function qf(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,m=Array(16),p=0;for(b=1;15>=b;b++)m[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=rg(m[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){8new Promise(function(ia,wa){let Ia=new Uint8Array(Z);(function(S){for(let za=0;8>za;za++)if(S[za]!="CHIBIOEK".charCodeAt(za))return!1;return!0})(Ia)? (Ia=Ia.subarray(8),x.onData=v,x.onEnd=function(S){0===S&&45==C?(!1!==u.upgradeMultiplyLayers&&10>W.version&&K.upgradeMultiplyLayers(u.upgradeMultiplyLayers),K.selectTopmostVisibleLayer(),ia(K)):wa("Fatal error decoding ChibiFile: "+S)},x.push(Ia,!0)):wa("This doesn't appear to be a ChibiPaint layers file, is it damaged?")}))}(n);default:return Promise.reject("Unexpected resource type '"+h.name+"'")}})(g,l).then(function(h){b[g.name]=h;m.load()},function(){m.emitEvent("loadingFailure",["Failed to read your "+ -g.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(g,g.noProgress?null:0);e.open("GET",g.url,!0);e.responseType="arraybuffer";e.send()}}}function Df(a){(a=a.split(/[-_]/,1)[0].toLowerCase())in Ef?(Ie=Ef[a],Ff=a):(Ie=Je,Ff="en")}function ma(a){return a in Ie?Ie[a]:a}function le(a){function c(e){null===e?p.emitEvent("savingProgress",[1,ma("Saving drawing...")]):p.emitEvent("savingProgress",[e,ma("Saving drawing...")+" ("+Math.round(100*e)+"%)"])}function d(e){p.emitEvent("savingFailure", -[e])}async function b(e){try{let k=await m(e),l=`${(k/1024/1024).toFixed(3)}MB`;if(console.log("Total size of FormData:",l),console.log("post_max_size:",a.post_max_size,"MB"),a&&a.post_max_size&&k&&!isNaN(k)&&k>1048576*a.post_max_size){d(`${ma("The file size exceeds the maximum allowed by the server.")} -${ma("Current size")}:${l}`);return}console.log(ma("The total size of FormData is within the acceptable range."))}catch(k){console.error("Error details:",k);d("An error occurred in the getFormDataSize function.");return}c(.5);fetch(a.url,{method:"POST",mode:"same-origin",headers:{"X-Requested-With":"chickenpaint"},body:e}).then(k=>{if(!k.ok)throw Error("Network response was not ok (".concat(k.status,")"));return k.text()}).then(k=>{/^CHIBIOK/.test(k)?(c(1),p.emitEvent("savingComplete")):d(k)}).catch(k=> +g.friendly])})},0)}else p()},!1);e.addEventListener("error",p);c(g,g.noProgress?null:0);e.open("GET",g.url,!0);e.responseType="arraybuffer";e.send()}}}function Df(a){(a=a.split(/[-_]/,1)[0].toLowerCase())in Ef?(Ie=Ef[a],Ff=a):(Ie=Je,Ff="en")}function ka(a){return a in Ie?Ie[a]:a}function le(a){function c(e){null===e?p.emitEvent("savingProgress",[1,ka("Saving drawing...")]):p.emitEvent("savingProgress",[e,ka("Saving drawing...")+" ("+Math.round(100*e)+"%)"])}function d(e){p.emitEvent("savingFailure", +[e])}async function b(e){try{let k=await m(e),l=`${(k/1024/1024).toFixed(3)}MB`,h=`${a.post_max_size}MB`;if(console.log("Total size of FormData:",l),console.log("post_max_size:",h),a&&a.post_max_size&&k&&!isNaN(k)&&k>1048576*a.post_max_size){d(`${ka("The file size exceeds the server limit.")} +${ka("Limit size")}:${h} +${ka("Current size")}:${l}`);return}console.log(ka("The total size of FormData is within the acceptable range."))}catch(k){console.error("Error details:",k);d("An error occurred in the getFormDataSize function.");return}c(.5);fetch(a.url,{method:"POST",mode:"same-origin",headers:{"X-Requested-With":"chickenpaint"},body:e}).then(k=>{if(!k.ok)throw Error("Network response was not ok (".concat(k.status,")"));return k.text()}).then(k=>{/^CHIBIOK/.test(k)?(c(1),p.emitEvent("savingComplete")):d(k)}).catch(k=> {d(k.message)})}async function m(e){if(a.post_max_size)return e=Array.from(e.entries()).map(([k,l])=>"string"==typeof l?new Blob([`${k}=${l}`]):l),(new Blob(e)).size}var p=this,g=!1;a.rotation=a.rotation||0;this.save=function(){var e,k,l,h,n;(e=new Blob([function(r){for(var u=new Uint8Array(r.length),v=0;v {var r,u;let v,x=new (Y(Cf).Deflate)({level:7}),C=[],K=new Uint8Array(8),J=h.getLayersRoot().getLinearizedLayerList(!1),G=n.forceOldVersion?0:function(W){for(let U of W.getLayersRoot().getLinearizedLayerList(!1))if(U instanceof ob||U.mask||U.clip||U.blendMode>T.LM_LAST_CHIBIPAINT||U.blendMode===T.LM_MULTIPLY)return 10;return 0}(h),L=0===(u=Kg(G)).major&&0===u.minor?"ChibiPaint v0.0":"ChickenPaint v"+u.major+"."+u.minor;u=Promise.resolve();x.onData=function(W){C.push(W)};for(let W=0;8>W;W++)K[W]="CHIBIOEK".charCodeAt(W); for(let W of(C.push(K),x.push((r=J.length,(v=Bf("HEAD",Af.FIXED_HEADER_LENGTH)).writeU32BE(G),v.writeU32BE(h.width),v.writeU32BE(h.height),v.writeU32BE(r),v.getAsDataArray()),!1),J))u=u.then(()=>new Promise(function(U){var X=x.push,Z=W,ia=Z instanceof Na,wa=4*(ia?5:6),Ia=Z.name.length;var S=Bf(ia?"LAYR":"GRUP",wa+Ia+((ia?Z.image.data.length:0)+(Z.mask?Z.mask.data.length:0)));var za=0;let na;Z.visible&&(za|=1);ia&&Z.clip&&(za|=2);Z.mask&&(za|=4);Z.maskLinked&&(za|=8);Z.maskVisible&&(za|=16);Z.lockAlpha&& @@ -190,55 +191,55 @@ d.apply(e,l)}var e=this,k=+new Date-p,l=arguments;b&&!m&&g();m&&clearTimeout(m); document.createElement("div"),b=document.createElement("div"),m=document.createElement("div"),p=0,g=1,e=0,k=1,l=10,h=!1,n=1,r=!1,u,v=this;this.setValues=function(x,C,K,J){e=x;k=C;p=K;g=J;c()};this.setBlockIncrement=function(x){l=x};this.setUnitIncrement=function(x){};this.getElement=function(){return d};this.getValueIsAdjusting=function(){return h};d.className="chickenpaint-scrollbar "+(a?"chickenpaint-scrollbar-vertical":"chickenpaint-scrollbar-horizontal");b.className="chickenpaint-scrollbar-handle"; b.setAttribute("touch-action","none");m.className="chickenpaint-scrollbar-handle-inner";b.appendChild(m);d.appendChild(b);b.addEventListener("pointerdown",function(x){x.stopPropagation();u=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;b.setPointerCapture(x.pointerId);Y(ja)(b).addClass("dragging");r=!0});b.addEventListener("pointermove",function(x){if(r){h=!0;let C=a?Y(ja)(d).height():Y(ja)(d).width();x=a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left;e+=(x-u)*(g-p)/ (C-n);e=Math.min(Math.max(e,p),g);u=x;v.emitEvent("valueChanged",[e]);c();h=!1}});b.addEventListener("pointerup",function(x){if(x.stopPropagation(),r){try{b.releasePointerCapture(x.pointerId)}catch(C){}Y(ja)(b).removeClass("dragging");r=!1}});b.addEventListener("click",function(x){x.stopPropagation()});d.addEventListener("click",function(x){this==d&&((a?x.pageY-Y(ja)(d).offset().top:x.pageX-Y(ja)(d).offset().left)Aa;Aa++)Ja.continueStroke(cb[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,cb){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,cb)};this.paint=function(){if(this.capture){var Aa=new Mg;let cb=U(N),gb=U(da),Ea=U(ka),jb=U(xa);Aa.x0=cb.x;Aa.y0=cb.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(~~cb.x,~~cb.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(N,da,ka){return!!this.capture||(Y(Sb).isPressed("space")||(0!=da||this.transient&&!N.altKey)&&2!=da?void(this.transient&&ua.pop()):(F=da,this.capture=!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag= -function(N){if(this.capture)return N=L({x:rb,y:hb}),Ja.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ja.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,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,N,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,cb){return!!this.capture||(1==Aa||Y(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,ka=Aa,F=xa.pageX,N=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-N),!0};this.mouseUp=function(xa,Aa,cb){if(this.capture&&Aa==ka)return ka=-1,this.capture=!1,this.transient&&!Y(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= -function(){x("grab")}}function l(){}function h(){var F,N=new Ha(0,0,0,0),da=-1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!ka.altKey&&!Y(Sb).isPressed("space"))return ka=W({x:rb,y:hb}),da=xa,N.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?(N.left=F.x,N.right=(ka?F.x+Aa:xa.x)+1):(N.left=ka?F.x-Aa:xa.x,N.right=F.x+ -1),xa.y>=F.y?(N.top=F.y,N.bottom=(ka?F.y+Aa:xa.y)+1):(N.top=ka?F.y-Aa:xa.y,N.bottom=F.y+1),Ka.repaintAll(),!0};this.mouseUp=function(ka,xa,Aa){if(this.capture&&xa==da)return Ja.rectangleSelection(N),N.makeEmpty(),Ka.repaintAll(),this.capture=!1,da=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ia(ha,N))}}function n(){var F,N,da=!1;this.mouseDown=function(ka,xa,Aa){if(!this.capture&&0==xa&&!Y(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=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,cb=~~xa,gb=~~Aa;return(0!=cb||0!=gb)&&(Ja.move(cb,gb,N&&da),da=!1),F.x=ka.x-(xa-cb),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 N(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)* -(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), +function nc(){this.modes=[]}function Le(a){function c(){}function d(){}function b(){this.shouldPaintBrushPreview=!1;this.oldPreviewRect=null}function m(){b.call(this);this.smoothMouse={x:0,y:0}}function p(){var F,N;this.mouseDown=function(da,la,xa){if(!this.capture&&0==la&&!da.altKey&&!Y(Sb).isPressed("space")&&K())return this.capture=!0,F=N={x:rb+.5,y:hb+.5},this.eraseBrushPreview(),!0};this.mouseDrag=function(da){if(this.capture){var la=new Ha(Math.min(F.x,N.x)-1-1,Math.min(F.y,N.y)-1-1,Math.max(F.x, +N.x)+1+1+1,Math.max(F.y,N.y)+1+1+1);if(N={x:rb+.5,y:hb+.5},da.shiftKey){var xa=Math.PI/4;da=Math.round(Math.atan2(N.y-F.y,N.x-F.x)/xa);switch(da){case 0:case 4:N.y=F.y;break;case 2:case 6:N.x=F.x;break;default:da*=xa,xa=Math.sqrt((N.y-F.y)*(N.y-F.y)+(N.x-F.x)*(N.x-F.x)),N.x=F.x+xa*Math.cos(da),N.y=F.y+xa*Math.sin(da)}}return la.union(new Ha(Math.min(F.x,N.x)-1-1,Math.min(F.y,N.y)-1-1,Math.max(F.x,N.x)+1+1+1,Math.max(F.y,N.y)+1+1+1)),Xa(la),!0}this.mouseMove.call(this,da)};this.mouseUp=function(da, +la,xa){if(this.capture&&0==la)return da=L(F),la=L(N),this.capture=!1,this.drawLine(da,la),Xa(new Ha(Math.min(F.x,N.x)-1-1,Math.min(F.y,N.y)-1-1,Math.max(F.x,N.x)+1+1+1,Math.max(F.y,N.y)+1+1+1)),!0};this.paint=function(){this.capture?(ha.lineWidth=1,ha.beginPath(),ha.moveTo(F.x,F.y),ha.lineTo(N.x,N.y),ha.stroke()):b.prototype.paint.call(this)};b.call(this)}function g(){let F=0,N,da,la,xa;this.mouseDown=function(Aa,cb,gb){if(!this.capture&&0==cb&&!Aa.altKey&&!Y(Sb).isPressed("space")&&K())return Aa= +L({x:rb,y:hb}),F=0,N=da=la=xa=Aa,this.capture=!0,this.eraseBrushPreview(),!0};this.mouseDrag=function(Aa){if(this.capture&&0===F)return la=xa=L({x:rb,y:hb}),Ka.repaintAll(),!0;this.mouseMove.call(this,Aa)};this.mouseUp=function(Aa,cb,gb){if(this.capture&&0==cb){switch(F){case 0:F=1;break;case 1:F=2;break;case 2:this.capture=!1;cb=N;gb=da;let Ea=la,jb=xa;Aa=new Mg;Aa.x0=cb.x;Aa.y0=cb.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;cb=Array(500);gb=Array(500);Aa.compute(cb,gb,500); +Ja.beginStroke(cb[0],gb[0],1);for(Aa=1;500>Aa;Aa++)Ja.continueStroke(cb[Aa],gb[Aa],1);Ja.endStroke();Ka.repaintAll()}return!0}};this.mouseMove=function(Aa,cb){if(this.capture)return Aa=L({x:rb,y:hb}),1==F?da=Aa:2==F&&(la=Aa),Ka.repaintAll(),!0;b.prototype.mouseMove.call(this,Aa,cb)};this.paint=function(){if(this.capture){var Aa=new Mg;let cb=U(N),gb=U(da),Ea=U(la),jb=U(xa);Aa.x0=cb.x;Aa.y0=cb.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(~~cb.x,~~cb.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(N,da,la){return!!this.capture||(Y(Sb).isPressed("space")||(0!=da||this.transient&&!N.altKey)&&2!=da?void(this.transient&&ua.pop()):(F=da,this.capture=!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag= +function(N){if(this.capture)return N=L({x:rb,y:hb}),Ja.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ja.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,da,la){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,N,da,la;this.keyDown=function(xa){if(" "===xa.key)return this.capture||x("grab"),!0};this.keyUp=function(xa){if(this.transient&&1!=la&&" "===xa.key)return x("default"),ua.pop(), +!0};this.mouseDown=function(xa,Aa,cb){return!!this.capture||(1==Aa||Y(Sb).isPressed("space")&&0==Aa||!this.transient&&0==Aa?(this.capture=!0,la=Aa,F=xa.pageX,N=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-N),!0};this.mouseUp=function(xa,Aa,cb){if(this.capture&&Aa==la)return la=-1,this.capture=!1,this.transient&&!Y(Sb).isPressed("space")&&(x("default"),ua.pop()),!0};this.enter= +function(){x("grab")}}function l(){}function h(){var F,N=new Ha(0,0,0,0),da=-1;this.mouseDown=function(la,xa,Aa){if(!this.capture&&0==xa&&!la.altKey&&!Y(Sb).isPressed("space"))return la=W({x:rb,y:hb}),da=xa,N.makeEmpty(),F=la,Ka.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(la){if(!this.capture)return!1;var xa=W({x:rb,y:hb});la=la.shiftKey;var Aa=~~Math.max(Math.abs(xa.x-F.x),Math.abs(xa.y-F.y));return xa.x>=F.x?(N.left=F.x,N.right=(la?F.x+Aa:xa.x)+1):(N.left=la?F.x-Aa:xa.x,N.right=F.x+ +1),xa.y>=F.y?(N.top=F.y,N.bottom=(la?F.y+Aa:xa.y)+1):(N.top=la?F.y-Aa:xa.y,N.bottom=F.y+1),Ka.repaintAll(),!0};this.mouseUp=function(la,xa,Aa){if(this.capture&&xa==da)return Ja.rectangleSelection(N),N.makeEmpty(),Ka.repaintAll(),this.capture=!1,da=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ia(ha,N))}}function n(){var F,N,da=!1;this.mouseDown=function(la,xa,Aa){if(!this.capture&&0==xa&&!Y(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=la.altKey,da=!0,this.capture=!0,!0};this.mouseDrag= +Ng(25,function(la){if(this.capture){la=L({x:rb,y:hb});var xa=la.x-F.x,Aa=la.y-F.y,cb=~~xa,gb=~~Aa;return(0!=cb||0!=gb)&&(Ja.move(cb,gb,N&&da),da=!1),F.x=la.x-(xa-cb),F.y=la.y-(Aa-gb),!0}});this.mouseUp=function(la,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 N(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)* +(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 la(){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,cb,gb,Ea,jb,Vb,kc=-1;this.mouseDown=function(Fa,La,Ra){if(!this.capture&&0==La&&!Fa.altKey&&!Y(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=N(L(La));var Ra=Mb.subtractPoints(Fa,jb);La=Ra.getTruncated();Ra=Ra.subtract(La);var nb=new Kb;nb.translate(La.x, +break;case 1:Fa="nesw-resize";break;case 2:Fa="ns-resize";break;case 3:Fa="nwse-resize"}x(Fa)}var Aa,cb,gb,Ea,jb,Vb,kc=-1;this.mouseDown=function(Fa,La,Ra){if(!this.capture&&0==La&&!Fa.altKey&&!Y(Sb).isPressed("space"))return kc=da(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Ea={x:rb,y:hb}),this.capture=!0,la(),!0};this.mouseDrag=Ng(40,function(Fa){if(this.capture){var La={x:rb,y:hb};switch(kc){case -3:Fa=N(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=cb.points[nb];pb=Aa.getInverted().getTransformedPoint(N(L(La)));La=cb.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(cb.points[Fa],cb.points[(Fa+1)%4]);La=Aa.getInverted().getTransformedPoint(N(L(La)));Fa=F(cb.points[(Fa+2)%4],cb.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=cb.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,N/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"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),qa=Oa.getContext("2d"),Ta=Og(ha),Ja=a.getArtwork(),lb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,kb=32,rb= +Ja.getActiveLayer();return F.visible&&F.ancestorsAreVisible()?0!=F.alpha||(a.showLayerNotification(F,ka("Whoops! This layer's opacity is currently 0%"),"opacity"),!1):(a.showLayerNotification(F,ka("Whoops! This layer is currently hidden"),"layer"),!1)}function K(){var F=Ja.getActiveLayer();return F instanceof ob&&!Ja.isEditingMask()?(a.showLayerNotification(F,ka("Whoops! You can't draw on a group"),"layer"),!1):C()}function J(F,N,da,la,xa){F.setValues(-xa,la,N-la-xa+da/4,N+da-xa-da/4);F.setBlockIncrement(Math.max(1, +~~(.66*la)));F.setUnitIncrement(Math.max(1,~~(.05*la)))}function G(){Db.setToIdentity();Db.translate(bc,jc);Db.scale(lb,lb);Db.rotate(Nb);if(null!=vc&&null!=D&&!vc.getValueIsAdjusting()&&!D.getValueIsAdjusting()){var F=wa(new Ha(0,0,Oa.width,Oa.height));J(vc,F.left,F.getWidth(),Y(ja)(ya).width(),Ka.getOffset().x);J(D,F.top,F.getHeight(),Y(ja)(ya).height(),Ka.getOffset().y)}Ka.repaintAll()}function L(F){return Db.getInverted().getTransformedPoint(F)}function W(F){F=L(F);return F.x=Math.floor(F.x), +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 Z(F,N){F.beginPath();F.moveTo(N[0].x,N[0].y);for(var da=1;daMath.abs(la-1)?F=1:.2>Math.abs(la-2)?F=2:.08>Math.abs(la-.5)&&(F=.5);S(F,N/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"),ma=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(),lb=1,bc=0,jc=0,Nb=0,Db=new Kb,sb=!1,Wb=!1,kb=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,N),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,N),!0}this.mouseMove(F)}; +Ja.beginStroke(F.x,F.y,da)))return this.capture=!0,this.smoothMouse=F,!0};m.prototype.mouseDrag=function(F,N){if(("number"!=typeof navigator.maxTouchPoints||3>navigator.maxTouchPoints)&&b.prototype.mouseMove.call(this,F,N),this.capture){F=L({x:rb,y:hb});var da=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let la=1-da;return this.smoothMouse.x=la*F.x+da*this.smoothMouse.x,this.smoothMouse.y=la*F.y+da*this.smoothMouse.y,Ja.continueStroke(this.smoothMouse.x,this.smoothMouse.y,N),!0}this.mouseMove(F)}; m.prototype.mouseUp=function(F,N,da){if(this.capture)return 0==N&&(this.capture=!1,Ja.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ja.beginStroke(F.x,F.y,1);Ja.continueStroke(N.x,N.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;l.prototype=Object.create(c.prototype); l.prototype.constructor=l;l.prototype.mouseDown=function(F,N,da){if(0==N&&!F.altKey&&!Y(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(!Y(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,N){Ja.gradientFill(Math.round(F.x),Math.round(F.y),Math.round(N.x),Math.round(N.y),a.getCurGradient())};v.prototype.queueBrushPreview=function(){};this.setZoom=function(F){lb=F;G()};this.getZoom=function(){return lb};this.setGridSize=function(F){kb=Math.max(Math.round(F),1);this.repaintAll()};this.getGridSize=function(){return kb};this.setOffset= function(F,N){isNaN(F)||isNaN(N)?console.log("Bad offset"):(bc=F,jc=N,G())};this.getOffset=function(){return{x:bc,y:jc}};this.setInterpolation=function(F){sb=F;of(ha,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,N=ya.height/2,da=new Kb;da.rotateAroundPoint(-this.getRotation(),F,N);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()||(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 N=Yb&&Yb.isOpen()?Yb.getImageData():Ja.fusionLayers().getImageData();qa.putImageData(N,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(N=Ja.getBounds(),2K&&this.setLocation(this.getX(),Math.max(K-x,0)))};this.userIsDoneWithUs=function(){a.getSmallScreenMode()&& this.toggleCollapse(!0)};p.className="collapse-icon fas icon-angle-down";g.type="button";g.className="btn btn-close";g.textContent="";g.tabIndex=-1;m.className="chickenpaint-palette chickenpaint-palette-"+c;d.className="chickenpaint-palette-head";d.setAttribute("touch-action","none");c=document.createElement("div");let v=document.createElement("h5");c.className="modal-header";v.className="modal-title";v.appendChild(document.createTextNode(this.title));v.appendChild(p);c.appendChild(v);c.appendChild(g); @@ -251,91 +252,91 @@ toolTip:"Color picker",shortcut:"i",mode:oa.M_COLOR_PICKER},{className:"chickenp mode:oa.M_DRAW,tool:oa.T_AIRBRUSH},{className:"chickenpaint-tool-water",command:"CPWater",toolTip:"Waterpaint",shortcut:"w",mode:oa.M_DRAW,tool:oa.T_WATER},{className:"chickenpaint-tool-eraser",command:"CPEraser",toolTip:"Eraser",shortcut:"e",mode:oa.M_DRAW,tool:oa.T_ERASER},{className:"chickenpaint-tool-soft-eraser",command:"CPSoftEraser",toolTip:"Soft eraser",shortcut:"s",mode:oa.M_DRAW,tool:oa.T_SOFTERASER},{className:"chickenpaint-tool-smudge",command:"CPSmudge",toolTip:"Smudge",shortcut:"d", mode:oa.M_DRAW,tool:oa.T_SMUDGE},{className:"chickenpaint-tool-blender",command:"CPBlender",toolTip:"Blender",shortcut:"c",mode:oa.M_DRAW,tool:oa.T_BLENDER},{className:"chickenpaint-tool-dodge",command:"CPDodge",toolTip:"Dodge (tool)",shortcut:"o",mode:oa.M_DRAW,tool:oa.T_DODGE},{className:"chickenpaint-tool-burn",command:"CPBurn",toolTip:"Burn (tool)",shortcut:"p",mode:oa.M_DRAW,tool:oa.T_BURN},{className:"chickenpaint-tool-rotate-canvas",command:"CPRotateCanvas",commandDoubleClick:"CPResetCanvasRotation", toolTip:"Rotate canvas",mode:oa.M_ROTATE_CANVAS},{className:"chickenpaint-tool-pan-canvas",command:"CPPanCanvas",toolTip:"Grab canvas",mode:oa.M_PAN_CANVAS}],m=document.createElement("ul");a.on("modeChange",function(p){let g=d.getBodyElement();Y(ja)("li",g).removeClass("selected");p==oa.M_DRAW?Y(ja)("li[data-tool="+a.getCurTool()+"]",g).addClass("selected"):Y(ja)("li[data-mode="+p+"]",g).addClass("selected")});a.on("toolChange",function(p){let g=d.getBodyElement();a.getCurMode()==oa.M_DRAW&&(Y(ja)("li", -g).removeClass("selected"),Y(ja)("li[data-tool="+p+"]",g).addClass("selected"))});(function(){let p=d.getBodyElement();for(let g in m.className="chickenpaint-tools list-unstyled",b)!function(e){let k=b[e],l=document.createElement("li"),h=document.createElement("div");l.className="chickenpaint-toolbar-button "+k.className;l.setAttribute("data-buttonIndex",e);l.setAttribute("data-mode",k.mode);void 0!==k.tool&&l.setAttribute("data-tool",k.tool);l.title=ma(k.toolTip);k.shortcut&&(l.title+=" ("+k.shortcut.toUpperCase()+ +g).removeClass("selected"),Y(ja)("li[data-tool="+p+"]",g).addClass("selected"))});(function(){let p=d.getBodyElement();for(let g in m.className="chickenpaint-tools list-unstyled",b)!function(e){let k=b[e],l=document.createElement("li"),h=document.createElement("div");l.className="chickenpaint-toolbar-button "+k.className;l.setAttribute("data-buttonIndex",e);l.setAttribute("data-mode",k.mode);void 0!==k.tool&&l.setAttribute("data-tool",k.tool);l.title=ka(k.toolTip);k.shortcut&&(l.title+=" ("+k.shortcut.toUpperCase()+ ")",Y(Sb)(k.shortcut,function(){return c.call(l),!1}));k.selected&&(l.className+=" selected");h.className="chickenpaint-toolbar-button-icon";l.appendChild(h);m.appendChild(l)}(g);Y(ja)(m).on("click","li",c).on("dblclick","li",function(g){g=b[parseInt(this.getAttribute("data-buttonIndex"),10)];g.commandDoubleClick&&a.actionPerformed({action:g.commandDoubleClick})});p.appendChild(m)})()}function Ne(a){lc.call(this,a,"misc","Misc");let c=this,d=[{className:"chickenpaint-tool-zoom-in",command:"CPZoomIn", toolTip:"Zoom in"},{className:"chickenpaint-tool-zoom-out",command:"CPZoomOut",toolTip:"Zoom out"},{className:"chickenpaint-tool-zoom-100",command:"CPZoom100",toolTip:"Zoom 100%"},{className:"chickenpaint-tool-flip-horizontal",command:"CPHFlip",toolTip:"Flip horizontal"},{className:"chickenpaint-tool-undo",command:"CPUndo",toolTip:"Undo"},{className:"chickenpaint-tool-redo",command:"CPRedo",toolTip:"Redo"},{className:"chickenpaint-tool-send",command:"CPSend",toolTip:"Save Oekaki"}];!function(){let b= -c.getBodyElement(),m=document.createElement("ul");for(let p in m.className="chickenpaint-misc-tools list-unstyled",d){let g=d[p],e=document.createElement("li"),k=document.createElement("div");"CPSend"!=g.command||a.isActionSupported("CPContinue")||(g.toolTip="Post Oekaki",g.className="chickenpaint-tool-send-and-end");e.className="chickenpaint-toolbar-button "+g.className;e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ma(g.toolTip));k.className="chickenpaint-toolbar-button-icon";e.appendChild(k); -m.appendChild(e)}Y(ja)(m).on("mousedown","li",function(p){Y(ja)(this).addClass("selected")}).on("mouseup","li",function(p){Y(ja)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(m)}()}function Oe(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand",command:"CPFreeHand",toolTip:ma("Free-hand"),selected:!0},{className:"chickenpaint-tool-line",command:"CPLine", -toolTip:ma("Straight line")},{className:"chickenpaint-tool-bezier",command:"CPBezier",toolTip:ma("Bezier curve")}],d=this.getBodyElement();!function(){let b=document.createElement("ul");for(let m in b.className="chickenpaint-stroke-tools list-unstyled",c){let p=c[m],g=document.createElement("li"),e=document.createElement("div");g.className="chickenpaint-toolbar-button "+p.className;g.setAttribute("data-buttonIndex",m);g.setAttribute("title",p.toolTip);p.selected&&(g.className+=" selected");e.className= +c.getBodyElement(),m=document.createElement("ul");for(let p in m.className="chickenpaint-misc-tools list-unstyled",d){let g=d[p],e=document.createElement("li"),k=document.createElement("div");"CPSend"!=g.command||a.isActionSupported("CPContinue")||(g.toolTip="Post Oekaki",g.className="chickenpaint-tool-send-and-end");e.className="chickenpaint-toolbar-button "+g.className;e.setAttribute("data-buttonIndex",p);e.setAttribute("title",ka(g.toolTip));k.className="chickenpaint-toolbar-button-icon";e.appendChild(k); +m.appendChild(e)}Y(ja)(m).on("mousedown","li",function(p){Y(ja)(this).addClass("selected")}).on("mouseup","li",function(p){Y(ja)(this).removeClass("selected")}).on("click","li",function(p){p=d[parseInt(this.getAttribute("data-buttonIndex"),10)];a.actionPerformed({action:p.command})});b.appendChild(m)}()}function Oe(a){lc.call(this,a,"stroke","Stroke");let c=[{className:"chickenpaint-tool-freehand",command:"CPFreeHand",toolTip:ka("Free-hand"),selected:!0},{className:"chickenpaint-tool-line",command:"CPLine", +toolTip:ka("Straight line")},{className:"chickenpaint-tool-bezier",command:"CPBezier",toolTip:ka("Bezier curve")}],d=this.getBodyElement();!function(){let b=document.createElement("ul");for(let m in b.className="chickenpaint-stroke-tools list-unstyled",c){let p=c[m],g=document.createElement("li"),e=document.createElement("div");g.className="chickenpaint-toolbar-button "+p.className;g.setAttribute("data-buttonIndex",m);g.setAttribute("title",p.toolTip);p.selected&&(g.className+=" selected");e.className= "chickenpaint-toolbar-button-icon";g.appendChild(e);b.appendChild(g)}Y(ja)(b).on("click","li",function(m){m=c[parseInt(this.getAttribute("data-buttonIndex"),10)];Y(ja)("li",b).removeClass("selected");Y(ja)(this).addClass("selected");a.actionPerformed({action:m.command})});d.appendChild(b)}();a.on("toolChange",function(b,m){Y(ja)(".chickenpaint-tool-freehand",d).toggleClass("selected",m.strokeMode==Da.STROKE_MODE_FREEHAND);Y(ja)(".chickenpaint-tool-line",d).toggleClass("selected",m.strokeMode==Da.STROKE_MODE_LINE); Y(ja)(".chickenpaint-tool-bezier",d).toggleClass("selected",m.strokeMode==Da.STROKE_MODE_BEZIER)})}function Bc(a,c,d){return c in a?Object.defineProperty(a,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[c]=d,a}function Pe(a){lc.call(this,a,"color","Color (picker)");let c=new Pg(a),d=new Qg(a,c);a=new Nh(a);let b=this.getBodyElement(),m=document.createElement("div");m.className="chickenpaint-colorpicker-top";m.appendChild(c.getElement());m.appendChild(d.getElement());b.appendChild(m);b.appendChild(a.getElement())} -function Nh(a){function c(p,g,e){for(;p.length=h/2?l.rect(x/2,0,(v.value-h/2)*x/h,C):l.rect(v.value*x/h,0,(h/2-v.value)*x/h,C),l.fill(),l.clip(),l.fillStyle= +b.title=c||"";b.className="chickenpaint-checkbox";b.width=20;b.height=20;b.fillStyle="black";b.strokeStyle="black";d()}function Fc(a,c,d,b,m=150){function p(){let x=k.width||m,C=k.height,K="string"==typeof v.title?ka(v.title):v.title(v.value),J=3*window.devicePixelRatio,G=.75*k.height;if(d)l.save(),l.fillStyle="white",l.fillRect(0,0,x,C),l.fillStyle="black",l.fillText(K,J,G),l.beginPath(),v.value>=h/2?l.rect(x/2,0,(v.value-h/2)*x/h,C):l.rect(v.value*x/h,0,(h/2-v.value)*x/h,C),l.fill(),l.clip(),l.fillStyle= "white";else{var L=(v.value-a)/h;b&&(L=Math.pow(L,.6666666666666666));L*=x;l.save();l.save();l.fillStyle="black";l.beginPath();l.rect(0,0,L,C);l.fill();l.clip();l.fillStyle="white";l.fillText(K,J,G);l.restore();l.fillStyle="white";l.beginPath();l.rect(L,0,x,C);l.fill();l.clip();l.fillStyle="black"}l.fillText(K,J,G);l.restore()}function g(x){let C=k.clientWidth,K=k.getBoundingClientRect().left+window.scrollX;proportion=(x.pageX-K)/C;b&&(proportion=Math.pow(Math.max(proportion,0),1.5));v.setValue(proportion* -h+a)}function e(x){switch(n){case 1:return g(x);case 2:var C=v.title();if(!C.includes(ma("Brush size"))&&!C.includes(ma("Opacity")))return g(x);C=(x.pageX-r)/4;if(0!==C){C=v.value+C;let K=Math.floor(C);v.setValue(K);r=x.pageX-4*(C-K)}}}let k=document.createElement("canvas"),l=k.getContext("2d"),h=c-a,n=0,r,u=!1,v=this;this.value=void 0;this.title="";d=d||!1;k.addEventListener("pointerup",x=>{if(0===n)return k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",e);if(0!==n)switch(n){case 1:0!== +h+a)}function e(x){switch(n){case 1:return g(x);case 2:var C=v.title();if(!C.includes(ka("Brush size"))&&!C.includes(ka("Opacity")))return g(x);C=(x.pageX-r)/4;if(0!==C){C=v.value+C;let K=Math.floor(C);v.setValue(K);r=x.pageX-4*(C-K)}}}let k=document.createElement("canvas"),l=k.getContext("2d"),h=c-a,n=0,r,u=!1,v=this;this.value=void 0;this.title="";d=d||!1;k.addEventListener("pointerup",x=>{if(0===n)return k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",e);if(0!==n)switch(n){case 1:0!== x.button||x.shiftKey||(n=0);break;case 2:(2==x.button||0===x.button&&x.shiftKey)&&(n=0);break;default:return}return k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",e)});this.setValue=function(x){x=~~Math.max(a,Math.min(c,x));this.value!=x&&(this.value=x,this.emitEvent("valueChange",[this.value]),u?p():(u=!0,this.resize()))};this.getElement=function(){return k};this.resize=function(){k.width=k.clientWidth||m;k.height=k.clientHeight||20;1n.length;)n="0"+n;h.backgroundColor="#"+n}let m=this,p=new Bb(0),g=255,e=document.createElement("div");this.getElement=function(){return e};this.setColor=function(h){p.isEqual(h)||(p.copyFrom(h),b(),this.emitEvent("colorChange",[p]))};this.setAlpha=function(h){h!=g&&(g=h,b(),this.emitEvent("alphaChange",[g]))};this.getColorRgb=function(){return p.getRgb()};this.getAlpha=function(){return g};this.setCurColor=this.setColor; -e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(g=c);let k=new oc.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",l),function(){let h=document.createElement("div"),n=document.createElement("div"),r=new Pg(m,p),u=new Qg(m,r,p.getHue()),v=new Fc(0,255);return h.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()),h.appendChild(n),v.value=g,v.title=function(x){return ma("Opacity: ")+ +e.className="chickenpaint-color-pick-swatch";a&&p.copyFrom(a);c&&(g=c);let k=new oc.Popover(e,{html:!0,content:function(){return window.addEventListener("mousedown",l),function(){let h=document.createElement("div"),n=document.createElement("div"),r=new Pg(m,p),u=new Qg(m,r,p.getHue()),v=new Fc(0,255);return h.className="chickenpaint-color-pick-panel",n.className="chickenpaint-colorpicker-top",n.appendChild(r.getElement()),n.appendChild(u.getElement()),h.appendChild(n),v.value=g,v.title=function(x){return ka("Opacity: ")+ x},v.on("valueChange",function(x){m.setAlpha(x)}),h.appendChild(v.getElement()),setTimeout(function(){v.resize()},0),h}()},trigger:"manual",placement:"bottom",container:d||!1}),l=function(h){var n=h.target;n=n.closest(".popover-body")||n.classList.contains("chickenpaint-color-pick-panel")||n.classList.contains("chickenpaint-colorpicker-select")||n.classList.contains("chickenpaint-colorpicker-slider");h.preventDefault();n||k.hide()};e.addEventListener("click",function(h){h.preventDefault();k.toggle()}); -e.addEventListener("hidden.bs.popover",function(){window.removeEventListener("mousedown",l)});b()}function Gf(a,c){let d=document.createElement("div");return d.className="chickenpaint-checkbox-slider-group",d.appendChild(a.getElement()),d.appendChild(c.getElement()),d}function Rg(a,c){for(let d in c)if(c.hasOwnProperty(d)){let b=document.createElement("option");b.appendChild(document.createTextNode(ma(c[d])));b.value=d;a.appendChild(b)}}function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width, +e.addEventListener("hidden.bs.popover",function(){window.removeEventListener("mousedown",l)});b()}function Gf(a,c){let d=document.createElement("div");return d.className="chickenpaint-checkbox-slider-group",d.appendChild(a.getElement()),d.appendChild(c.getElement()),d}function Rg(a,c){for(let d in c)if(c.hasOwnProperty(d)){let b=document.createElement("option");b.appendChild(document.createTextNode(ka(c[d])));b.value=d;a.appendChild(b)}}function Oh(a){function c(){p.gradient(p.getBounds(),0,0,p.width, 0,k,!0);e.putImageData(p.imageData,0,0,0,0,150,32);b.fillRect(0,0,d.width,d.height);b.drawImage(g,0,0)}let d=document.createElement("canvas"),b=d.getContext("2d"),m=Og(b),p=new H(150,32),g=document.createElement("canvas"),e=g.getContext("2d"),k=a.getCurGradient();this.getElement=function(){return d};a.on("gradientChange",function(l){k=l;c()});d.width=g.width=150;d.height=g.height=32;d.className="chickenpaint-gradient-preview";b.fillStyle=m;c()}function Td(a){lc.call(this,a,"brush","Tool options"); let c=new Ph(a),d=new Qh(a),b=new Rh(a),m=this.getBodyElement();m.addEventListener("touchmove",p=>{p.preventDefault()},{passive:!1});m.appendChild(c.getElement());m.appendChild(d.getElement());m.appendChild(b.getElement());a.on("modeChange",function(p){switch(c.getElement().style.display="none",d.getElement().style.display="none",b.getElement().style.display="none",p){case oa.M_GRADIENTFILL:d.getElement().style.display="block";break;case oa.M_TRANSFORM:b.getElement().style.display="block";break;default:c.getElement().style.display= -"block"}})}function Ph(a){let c=[1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50,60,70,80,90,100,125,150,175,200],d=document.createElement("div"),b=document.createElement("select"),m=new Sd(!1,ma("Control brush opacity with pen pressure")),p=new Fc(1,255),g=new Sd(!0,ma("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),k=new Sd(!1,ma("Control brush scattering with pen pressure")),l=new Fc(0,1E3,!1,!0),h=new Fc(0,100,!1,!0),n=new Fc(0,100,!1,!0),r=new Fc(0,100,!1,!0),u=new Fc(0,100,!1,!0), -v=new Td.CPBrushPreview(a);this.getElement=function(){return d};p.title=function(x){return ma("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ma("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});h.title=function(x){return ma("Color")+": "+x+"%"};h.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ma("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= -x/100;a.callToolListeners()});r.title=function(x){return ma("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});l.title=function(x){return ma("Scattering")+": "+x+"%"};l.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ma("Smoothing")+": "+x+"%"};u.on("valueChange",function(x){a.getBrushInfo().smoothing=x/100;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureScattering= +"block"}})}function Ph(a){let c=[1,2,3,4,5,6,7,8,9,10,15,20,25,30,35,40,45,50,60,70,80,90,100,125,150,175,200],d=document.createElement("div"),b=document.createElement("select"),m=new Sd(!1,ka("Control brush opacity with pen pressure")),p=new Fc(1,255),g=new Sd(!0,ka("Control brush size with pen pressure")),e=new Fc(1,200,!1,!0),k=new Sd(!1,ka("Control brush scattering with pen pressure")),l=new Fc(0,1E3,!1,!0),h=new Fc(0,100,!1,!0),n=new Fc(0,100,!1,!0),r=new Fc(0,100,!1,!0),u=new Fc(0,100,!1,!0), +v=new Td.CPBrushPreview(a);this.getElement=function(){return d};p.title=function(x){return ka("Opacity")+": "+x};p.on("valueChange",function(x){a.setAlpha(x)});e.title=function(x){return ka("Brush size")+": "+x};e.on("valueChange",function(x){a.setBrushSize(x)});h.title=function(x){return ka("Color")+": "+x+"%"};h.on("valueChange",function(x){a.getBrushInfo().resat=x/100;a.callToolListeners()});n.title=function(x){return ka("Blend")+": "+x+"%"};n.on("valueChange",function(x){a.getBrushInfo().bleed= +x/100;a.callToolListeners()});r.title=function(x){return ka("Spacing")+": "+x+"%"};r.on("valueChange",function(x){a.getBrushInfo().spacing=x/100;a.callToolListeners()});l.title=function(x){return ka("Scattering")+": "+x+"%"};l.on("valueChange",function(x){a.getBrushInfo().scattering=x/100;a.callToolListeners()});u.title=function(x){return ka("Smoothing")+": "+x+"%"};u.on("valueChange",function(x){a.getBrushInfo().smoothing=x/100;a.callToolListeners()});k.on("valueChange",function(x){a.getBrushInfo().pressureScattering= x;a.callToolListeners()});m.on("valueChange",function(x){a.getBrushInfo().pressureAlpha=x;a.callToolListeners()});g.on("valueChange",function(x){a.getBrushInfo().pressureSize=x;a.callToolListeners()});b.addEventListener("change",function(x){a.getBrushInfo().tip=parseInt(b.value,10);b.blur()});b.className="form-control form-control-sm";b.tabIndex=-1;Rg(b,["Round Pixelated","Round Hard Edge","Round Soft","Square Pixelated","Square Hard Edge"]);d.appendChild(b);d.appendChild(v.getElement());d.appendChild(Gf(g, e));d.appendChild(Gf(m,p));d.appendChild(h.getElement());d.appendChild(n.getElement());d.appendChild(r.getElement());d.appendChild(Gf(k,l));d.appendChild(u.getElement());m.setValue(a.getBrushInfo().pressureAlpha);p.setValue(a.getAlpha());g.setValue(a.getBrushInfo().pressureSize);e.setValue(a.getBrushSize());k.setValue(a.getBrushInfo().pressureScattering);l.setValue(~~(100*a.getBrushInfo().scattering));b.value=a.getBrushInfo().tip;h.setValue(~~(100*a.getBrushInfo().resat));n.setValue(~~(100*a.getBrushInfo().bleed)); r.setValue(~~(100*a.getBrushInfo().spacing));u.setValue(~~(100*a.getBrushInfo().smoothing));a.on("toolChange",function(x,C){p.setValue(C.alpha);e.setValue(C.size);g.setValue(C.pressureSize);m.setValue(C.pressureAlpha);b.value=C.tip;k.setValue(C.pressureScattering);~~(100*C.resat)!=h.value&&h.setValue(~~(100*C.resat));~~(100*C.bleed)!=n.value&&n.setValue(~~(100*C.bleed));~~(100*C.spacing)!=r.value&&r.setValue(~~(100*C.spacing));~~(100*C.scattering)!=l.value&&l.setValue(~~(100*C.scattering));~~(100* C.smoothing)!=u.value&&u.setValue(~~(100*C.smoothing))});Y(Sb)("1,2,3,4,5,6,7,8,9,0",function(x,C){x=parseInt(C.shortcut,10);0==x&&(x=10);a.setAlpha(Math.round(x/10*255))});Y(Sb)("{,[",function(){let x=a.getBrushSize();for(let C=c.length-1;0<=C;C--)if(x>c[C]){a.setBrushSize(c[C]);break}});Y(Sb)("},]",function(){let x=a.getBrushSize();for(let C=0;C>>24,b),g=new oe(new Bb(16777215&a.getCurGradient()[1]),a.getCurGradient()[1]>>>24,b);this.getElement=function(){return b};b.className="chickenpaint-gradient-panel";b.style.display="none";p.on("colorChange",c);p.on("alphaChange",c);g.on("colorChange",c);g.on("alphaChange",c);(d=document.createElement("p")).textContent=ma("Gradient");b.appendChild(d); -b.appendChild(m.getElement());(d=document.createElement("div")).className="chickenpaint-gradient-colors";(m=document.createElement("div")).className="chickenpaint-gradient-start-color";m.appendChild(p.getElement());d.appendChild(m);(m=document.createElement("div")).className="chickenpaint-gradient-end-color";m.appendChild(g.getElement());d.appendChild(m);b.appendChild(d)}function Rh(a){var c={smooth:ma("Smooth"),sharp:ma("Sharp")};let d=document.createElement("div"),b=document.createElement("button"), -m=document.createElement("button");var p=document.createElement("select");if(this.getElement=function(){return d},d.className="chickenpaint-transform-panel",d.style.display="none",b.type="button",m.type="button",b.className="btn btn-primary btn-block",m.className="btn btn-light btn-block",b.textContent=ma("Apply transform"),m.textContent=ma("Cancel"),p.addEventListener("change",function(g){a.setTransformInterpolation(this.value)}),p.className="form-control chickenpaint-transform-interpolation",Rg(p, -c),nf(Zc(0,0).getContext("2d"))){c=document.createElement("div");let g=document.createElement("label");g.textContent=ma("Transform style");c.className="form-group";c.appendChild(g);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(m);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformAccept"});g.preventDefault()});m.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformReject"}); +a.setCurGradient(e)}var d;let b=document.createElement("div");var m=new Oh(a);let p=new oe(new Bb(16777215&a.getCurGradient()[0]),a.getCurGradient()[0]>>>24,b),g=new oe(new Bb(16777215&a.getCurGradient()[1]),a.getCurGradient()[1]>>>24,b);this.getElement=function(){return b};b.className="chickenpaint-gradient-panel";b.style.display="none";p.on("colorChange",c);p.on("alphaChange",c);g.on("colorChange",c);g.on("alphaChange",c);(d=document.createElement("p")).textContent=ka("Gradient");b.appendChild(d); +b.appendChild(m.getElement());(d=document.createElement("div")).className="chickenpaint-gradient-colors";(m=document.createElement("div")).className="chickenpaint-gradient-start-color";m.appendChild(p.getElement());d.appendChild(m);(m=document.createElement("div")).className="chickenpaint-gradient-end-color";m.appendChild(g.getElement());d.appendChild(m);b.appendChild(d)}function Rh(a){var c={smooth:ka("Smooth"),sharp:ka("Sharp")};let d=document.createElement("div"),b=document.createElement("button"), +m=document.createElement("button");var p=document.createElement("select");if(this.getElement=function(){return d},d.className="chickenpaint-transform-panel",d.style.display="none",b.type="button",m.type="button",b.className="btn btn-primary btn-block",m.className="btn btn-light btn-block",b.textContent=ka("Apply transform"),m.textContent=ka("Cancel"),p.addEventListener("change",function(g){a.setTransformInterpolation(this.value)}),p.className="form-control chickenpaint-transform-interpolation",Rg(p, +c),nf(Zc(0,0).getContext("2d"))){c=document.createElement("div");let g=document.createElement("label");g.textContent=ka("Transform style");c.className="form-group";c.appendChild(g);c.appendChild(p);d.appendChild(c)}p=document.createElement("div");p.appendChild(b);p.appendChild(m);p.className="form-group";d.appendChild(p);b.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformAccept"});g.preventDefault()});m.addEventListener("click",function(g){a.actionPerformed({action:"CPTransformReject"}); g.preventDefault()})}function Sh(a){a.preventDefault();a.stopPropagation()}function Jc(a){let c=document.createElement("span");return c.className="fa "+a,c}function Hf(a){let c=document.createElement("span");return c.className="chickenpaint-icon chickenpaint-icon-"+a,c}function Sg(a,c){let d=document.createElement("div"),b=document.createElement("label");return b.tabIndex=-1,a.tabIndex=-1,d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id), -b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Qe(a){function c(){let G=m.getActiveLayer();G.getAlpha()!=l.value&&l.setValue(G.getAlpha());(function(){let L=m.getActiveLayer();for(;h.lastChild;)h.removeChild(h.lastChild);for(let W=T.LM_FIRST;W<=T.LM_LAST;W++)if(W!=T.LM_MULTIPLY2&&(W==L.blendMode||W===T.LM_PASSTHROUGH&&L instanceof ob||W<=T.LM_LAST_CHIBIPAINT)){let U=document.createElement("option");U.appendChild(document.createTextNode(ma(T.BLEND_MODE_DISPLAY_NAMES[W]))); +b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Qe(a){function c(){let G=m.getActiveLayer();G.getAlpha()!=l.value&&l.setValue(G.getAlpha());(function(){let L=m.getActiveLayer();for(;h.lastChild;)h.removeChild(h.lastChild);for(let W=T.LM_FIRST;W<=T.LM_LAST;W++)if(W!=T.LM_MULTIPLY2&&(W==L.blendMode||W===T.LM_PASSTHROUGH&&L instanceof ob||W<=T.LM_LAST_CHIBIPAINT)){let U=document.createElement("option");U.appendChild(document.createTextNode(ka(T.BLEND_MODE_DISPLAY_NAMES[W]))); 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=m.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(){m= -this;k.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,m=a.getArtwork(),p=null,g=this.getBodyElement(),e=this.getElement(),k=new function(){function G(Ma){let la=Y(ja)(".chickenpaint-layer",Xa);return la.get(la.length-1-Ma)}function L(Ma){Ma=Y(ja)(Ma).closest(".chickenpaint-layer");if(!Ma.length)return-1;let la=Y(ja)(".chickenpaint-layer",Xa);return la.length-1-la.index(Ma)}function W(){if(2===na.state){let ya=e.getBoundingClientRect();var Ma=!0;let ha=!0;if(na.dropTarget= +this;k.resize();c()}lc.call(this,a,"layers","Layers",{resizeHorz:!0,resizeVert:!0});let b=this,m=a.getArtwork(),p=null,g=this.getBodyElement(),e=this.getElement(),k=new function(){function G(Ma){let ma=Y(ja)(".chickenpaint-layer",Xa);return ma.get(ma.length-1-Ma)}function L(Ma){Ma=Y(ja)(Ma).closest(".chickenpaint-layer");if(!Ma.length)return-1;let ma=Y(ja)(".chickenpaint-layer",Xa);return ma.length-1-ma.index(Ma)}function W(){if(2===na.state){let ya=e.getBoundingClientRect();var Ma=!0;let ha=!0;if(na.dropTarget= function(Oa,qa){var Ta=Y(ja)(".chickenpaint-layer",Xa);Oa={layer:p[p.length-1],displayIndex:p.length-1,direction:"over"};for(var Ja=0;Jalb.bottom){Oa=m.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(qa>=lb.top){Ta=p[Ja];let bc=lb.bottom-lb.top;Oa={layer:Ta,displayIndex:Ja};Ta instanceof ob?qa>=lb.top+.75*bc?Ta.expanded&&0=lb.top+.25*bc?Ta.expanded&&0=lb.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+(0Z(ha,ya)),Ca=document.createDocumentFragment();Y(ja)(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=Y(ja)(G(Ca));0===ya.length||la instanceof ob&&(la.expanded!=Y(ja)(ya).hasClass("chickenpaint-layer-group-expanded")||la.visible!=Y(ja)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(Z(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&&!ha&&(la.preventDefault(),-1!=L(la.target)&&(ia(L(la.target)),la.preventDefault()))}}}}), +case 1:if(5Z(ha,ya)),Ca=document.createDocumentFragment();Y(ja)(Xa).empty();for(let ya=ma.length-1;0<=ya;ya--)Ca.appendChild(ma[ya]);Xa.appendChild(Ca);W()},this.layerChanged=function(ma){let Ca=p.indexOf(ma),ya=Y(ja)(G(Ca));0===ya.length||ma instanceof ob&&(ma.expanded!=Y(ja)(ya).hasClass("chickenpaint-layer-group-expanded")||ma.visible!=Y(ja)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(Z(Ca,ma))},this.setRotation90= +function(ma){if(Lb!=ma)for(Lb=ma,ma=0;mama.preventDefault(),!0),Xa.className="list-group",Xa.addEventListener("dblclick",function(ma){0===ma.button&&0{3===na.state&&(Ia(),na.dragY=ma.clientY,W())},800)):na.state=1,na.dropTarget=null,na.layer=ya,na.layerElem=G(Ca),na.dragX=ma.clientX,na.dragY=ma.clientY,Xa.setPointerCapture(ma.pointerId),Xa.addEventListener("pointermove",S),Xa.addEventListener("pointerup",wa)):2==ma.button&&!ha&&(ma.preventDefault(),-1!=L(ma.target)&&(ia(L(ma.target)),ma.preventDefault()))}}}}), Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(Ma,Sh);mb.appendChild(Xa)},l=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=Y(ja)(W).parent();X&&(Y(ja)(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,Z){L=(G=X).name;W.value=L;(X=Z.querySelector(".chickenpaint-layer-name"))&&X.parentNode&&(Z=X.firstChild)&&Z.nodeType===Node.TEXT_NODE&&(X.removeChild(Z),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();l.resize()};this.setWidth=function(G){K.call(this,G);l.resize();k.resize()};this.setHeight=function(G){J.call(this,G);k.resize()};this.setRotation90=function(G){k.setRotation90(G)};this.dismissNotification=function(){Y(ja)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", g).each((G,L)=>{L=Y(ja)(L);(G=oc.Popover.getInstance(L[0]))&&G.dispose()});v&&(clearTimeout(v),v=!1)};this.showNotification=(G,L,W)=>{let U=p.indexOf(G);G=m.getActiveLayer()==G&&"opacity"==W?l.getElement():k.revealLayer(U);this.dismissNotification();(new oc.Popover(G,{html:!1,content:L,placement:"left",trigger:"manual",fallbackPlacement:[],boundary:"window",container:b.getElement()})).show();v=setTimeout(()=>{v=!1;this.dismissNotification()},Math.max(Math.round(70*L.length),3E3))};h.className="form-control form-control-sm"; -h.tabIndex=-1;h.title=ma("Layer blending mode");h.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(h.value,10)});h.blur()});g.appendChild(h);l.title=function(G){return ma("Opacity")+": "+G+"%"};l.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});g.appendChild(l.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){m.setSampleAllLayers(r.checked);document.activeElement.blur()}); -g.appendChild(Sg(r,ma("Sample all layers")));u.id="chickenpaint-chk-lock-alpha";u.type="checkbox";u.addEventListener("click",function(G){a.actionPerformed({action:"CPSetLayerLockAlpha",lock:u.checked});document.activeElement.blur()});g.appendChild(Sg(u,ma("Lock transparency")));g.appendChild(k.getElement());x=function(){var G=[{title:"Add layer",icon:Jc("icon-file"),action:"CPAddLayer"},{title:"Add group",icon:Jc("icon-folder"),action:"CPAddGroup"},{title:"Merge down",icon:Jc("icon-download_FILL"), +h.tabIndex=-1;h.title=ka("Layer blending mode");h.addEventListener("change",function(G){a.actionPerformed({action:"CPSetLayerBlendMode",blendMode:parseInt(h.value,10)});h.blur()});g.appendChild(h);l.title=function(G){return ka("Opacity")+": "+G+"%"};l.on("valueChange",function(G){a.actionPerformed({action:"CPSetLayerAlpha",alpha:G})});g.appendChild(l.getElement());r.id="chickenpaint-chk-sample-all-layers";r.type="checkbox";r.addEventListener("click",function(G){m.setSampleAllLayers(r.checked);document.activeElement.blur()}); +g.appendChild(Sg(r,ka("Sample all layers")));u.id="chickenpaint-chk-lock-alpha";u.type="checkbox";u.addEventListener("click",function(G){a.actionPerformed({action:"CPSetLayerLockAlpha",lock:u.checked});document.activeElement.blur()});g.appendChild(Sg(u,ka("Lock transparency")));g.appendChild(k.getElement());x=function(){var G=[{title:"Add layer",icon:Jc("icon-file"),action:"CPAddLayer"},{title:"Add group",icon:Jc("icon-folder"),action:"CPAddGroup"},{title:"Merge down",icon:Jc("icon-download_FILL"), action:"CPLayerMergeDown",require:["image-layer"]},{title:"Merge group",icon:Jc("icon-collapse_all_FILL"),action:"CPGroupMerge",require:["layer-group"]},{title:"Clip to the layer below",icon:Jc("icon-level-down-alt fa-flip-horizontal"),action:"CPCreateClippingMask",require:"no-clipping-mask-or-is-group"},{title:"Unclip from the layer below",icon:Jc("icon-level-down-alt fa-flip-horizontal"),action:"CPReleaseClippingMask",require:"clipping-mask"},{title:"Add layer mask",icon:Hf("mask"),action:"CPAddLayerMask", require:["no-mask"]},{title:"Apply mask",icon:Hf("mask"),action:"CPApplyLayerMask",require:["mask"]},{title:"Duplicate",icon:Jc("icon-clone"),action:"CPLayerDuplicate"},{title:"Delete layer",icon:Jc("icon-trash"),action:"CPRemoveLayer"}];let L=document.createElement("ul");for(let W of(L.className="chickenpaint-layer-buttons list-unstyled",G))G=document.createElement("li"),G.setAttribute("data-action",W.action),G.className="chickenpaint-small-toolbar-button "+(W.require?"chickenpaint-action-require-"+ -W.require:""),G.title=ma(W.title),G.appendChild(W.icon),G.addEventListener("click",function(){a.actionPerformed({action:W.action})}),L.appendChild(G);return L}();g.appendChild(x);m.on("changeActiveLayer",function(G,L,W){k.activeLayerChanged(L,W);c()});m.on("changeLayer",function(G){m=this;b.dismissNotification();k.layerChanged(G);c()});m.on("changeStructure",d);m.on("changeLayerMaskThumb",function(G){m=this;k.layerMaskThumbChanged(G)});m.on("changeLayerImageThumb",function(G){m=this;k.layerImageThumbChanged(G)}); +W.require:""),G.title=ka(W.title),G.appendChild(W.icon),G.addEventListener("click",function(){a.actionPerformed({action:W.action})}),L.appendChild(G);return L}();g.appendChild(x);m.on("changeActiveLayer",function(G,L,W){k.activeLayerChanged(L,W);c()});m.on("changeLayer",function(G){m=this;b.dismissNotification();k.layerChanged(G);c()});m.on("changeStructure",d);m.on("changeLayerMaskThumb",function(G){m=this;k.layerMaskThumbChanged(G)});m.on("changeLayerImageThumb",function(G){m=this;k.layerImageThumbChanged(G)}); a.on("layerNotification",this.showNotification.bind(this));d.call(m)}function Th(){this.table=new Uint8Array(256);this.loadIdentity=function(){for(var a=0;256>a;a++)this.table[a]=a};this.loadBrightnessContrast=function(a,c){c=0d;d++)this.table[d]=Math.min(255,Math.max(~~(255*(d/255*c+a)),0))};this.invert=function(){for(var a=0;256>a;a++)this.table[a]=255-this.table[a]}}function Tg(a,c){let d=document.createElement("div"),b=document.createElement("label"); return d.className="form-check",a.className="form-check-input",b.className="form-check-label",b.setAttribute("for",a.id),b.appendChild(a),b.appendChild(document.createTextNode(c)),d.appendChild(a),d.appendChild(b),d}function Re(a){function c(U){for(let X=0;X=U&&(Z.data[ia]=255);return Z}function p(U,X){let Z=new eb(X,X,8);for(let ia=0;ia=U&&(Z.data[ia]=255);return Z}function g(){if(null!=r){u=r.clone();v&&u.mirrorHorizontally();let U=new Th;U.loadBrightnessContrast(C,K);x&&U.invert();u.applyLUT(U)}else u=null;a.getArtwork().setBrushTexture(u);null!=J&&J.updateTexture()}function e(U, X,Z){let ia=document.createElement("canvas"),wa=ia.getContext("2d"),Ia=this;this.setTexture=function(S){this.texture=S;this.paint()};this.getElement=function(){return ia};this.paint=function(){null!=this.texture?wa.fillStyle=wa.createPattern(this.texture.getAsCanvas(),"repeat"):wa.fillStyle="white";wa.fillRect(0,0,ia.width,ia.height)};ia.addEventListener("click",function(){Ia.emit("click")});ia.width=X;ia.height=Z;this.setTexture(U)}var k;let l,h,n;lc.call(this,a,"textures","Textures");let r,u,v= !1,x=!1,C=0,K=0,J,G=document.createElement("div"),L=this.getBodyElement();e.prototype=Object.create(Y(Zb).prototype);e.prototype.constructor=e;J=new function(){function U(){Ia.checked=x;S.checked=v;za.setValue(100*C+100);na.setValue(100*K+100)}let X,Z,ia,wa=document.createElement("div"),Ia=document.createElement("input"),S=document.createElement("input"),za=new Fc(0,200,!0),na=new Fc(0,200,!0),mb=new e(null,64,64),Xa=document.createElement("button"),Lb,Fb=new oc.Popover(Xa,{html:!0,content:()=>Lb, -trigger:"manual",placement:"right",container:L});this.updateTexture=function(){Xa.disabled=null==u;mb.setTexture(u)};this.getElement=function(){return wa};wa.className="chickenpaint-texture-options";wa.appendChild(mb.getElement());Xa.type="button";Xa.className="btn btn-light btn-sm";Xa.setAttribute("data-bs-toggle","popover");Xa.setAttribute("data-bs-placement","right");Xa.textContent=ma("Customize");(X=document.createElement("div")).className="chickenpaint-texture-controls";Ia.id="chickenpaint-chk-texture-invert"; -Ia.type="checkbox";Ia.addEventListener("click",function(Ka){x=this.checked;g()});X.appendChild(Tg(Ia,ma("Inverse")));S.id="chickenpaint-chk-texture-mirror";S.type="checkbox";S.addEventListener("click",function(Ka){v=this.checked;g()});X.appendChild(Tg(S,ma("Mirror")));za.title=function(Ka){return ma("Brightness")+": "+(Ka-100)+"%"};za.on("valueChange",function(Ka){C=(Ka-100)/100;g()});X.appendChild(za.getElement());na.title=function(Ka){return ma("Contrast")+": "+(Ka-100)+"%"};na.on("valueChange", +trigger:"manual",placement:"right",container:L});this.updateTexture=function(){Xa.disabled=null==u;mb.setTexture(u)};this.getElement=function(){return wa};wa.className="chickenpaint-texture-options";wa.appendChild(mb.getElement());Xa.type="button";Xa.className="btn btn-light btn-sm";Xa.setAttribute("data-bs-toggle","popover");Xa.setAttribute("data-bs-placement","right");Xa.textContent=ka("Customize");(X=document.createElement("div")).className="chickenpaint-texture-controls";Ia.id="chickenpaint-chk-texture-invert"; +Ia.type="checkbox";Ia.addEventListener("click",function(Ka){x=this.checked;g()});X.appendChild(Tg(Ia,ka("Inverse")));S.id="chickenpaint-chk-texture-mirror";S.type="checkbox";S.addEventListener("click",function(Ka){v=this.checked;g()});X.appendChild(Tg(S,ka("Mirror")));za.title=function(Ka){return ka("Brightness")+": "+(Ka-100)+"%"};za.on("valueChange",function(Ka){C=(Ka-100)/100;g()});X.appendChild(za.getElement());na.title=function(Ka){return ka("Contrast")+": "+(Ka-100)+"%"};na.on("valueChange", function(Ka){K=(Ka-100)/100;g()});X.appendChild(na.getElement());Z=document.createElement("button");ia=document.createElement("button");Z.textContent="Ok";Z.className="btn btn-primary btn-sm";Z.type="button";Z.addEventListener("click",function(Ka){Fb.hide()});X.appendChild(Z);X.appendChild(document.createTextNode(" "));ia.textContent="Reset";ia.className="btn btn-secondary btn-sm";ia.type="button";ia.addEventListener("click",function(Ka){K=C=0;x=v=!1;U();g()});X.appendChild(ia);U();Lb=X;Xa.addEventListener("click", function(){Fb.toggle()});wa.appendChild(Xa);this.updateTexture()};L.appendChild(J.getElement());G.className="chickenpaint-texture-swatches";L.appendChild(G);c((k=[null],(l=new eb(2,2,8)).data[0]=255,l.data[3]=255,k.push(l),k.push(d(2)),k.push(d(3)),k.push(d(4)),k.push(d(6)),k.push(d(8)),k.push(m(1,2)),k.push(m(2,4)),k.push(p(1,2)),k.push(p(2,4)),k.push(b(2)),k.push(b(4)),k.push(b(8)),k.push(b(16)),k.push(function(U){let X=new eb(256,256,8);for(let Z=0;ZU;U++){X.drawImage(h,0,32*U,32,32,0,0,32,32);try{let Z=X.getImageData(0,0,32,32),ia=new eb(32,32,8);for(let wa=0;1024>wa;wa++)ia.data[wa]=Z.data[4*wa];n.push(ia)}catch(Z){console.log(Z)}}W(n)}; h.src=k}function Se(a){function c(K){let J=document.createElement("div"),G=document.createElement("a"),L=document.createElement("ul"),W=document.createElement("a"),U=document.createElement("a"),X=this;this.getElement=function(){return J};this.setColor=function(ia){G.setAttribute("data-color",ia);var wa=G.style;for(ia=""+Number(ia).toString(16);6>ia.length;)ia="0"+ia;wa.backgroundColor="#"+ia};this.setColor(K);G.href="#";G.className="chickenpaint-color-swatch dropdown-toggle";W.className="dropdown-item"; -W.href="#";W.textContent=ma("Remove");W.addEventListener("click",function(ia){ia.preventDefault();Y(ja)(J).remove();n=!0});U.className="dropdown-item";U.href="#";U.textContent=ma("Replace with current color");U.addEventListener("click",function(ia){ia.preventDefault();X.setColor(a.getCurColor().getRgb());n=!0});L.className="dropdown-menu";K=document.createElement("li");let Z=document.createElement("li");K.appendChild(W);Z.appendChild(U);L.appendChild(K);L.appendChild(Z);J.className="chickenpaint-color-swatch-wrapper"; +W.href="#";W.textContent=ka("Remove");W.addEventListener("click",function(ia){ia.preventDefault();Y(ja)(J).remove();n=!0});U.className="dropdown-item";U.href="#";U.textContent=ka("Replace with current color");U.addEventListener("click",function(ia){ia.preventDefault();X.setColor(a.getCurColor().getRgb());n=!0});L.className="dropdown-menu";K=document.createElement("li");let Z=document.createElement("li");K.appendChild(W);Z.appendChild(U);L.appendChild(K);L.appendChild(Z);J.className="chickenpaint-color-swatch-wrapper"; J.appendChild(G);J.appendChild(L)}function d(K){K=new c(K);r.appendChild(K.getElement())}function b(K){let J=document.createElement("span");return J.className="fa icon-"+K,J}let m,p,g;let e,k,l;lc.call(this,a,"swatches","Color swatches");let h=[16777215,0,16711680,65280,255,16776960],n=!1,r=document.createElement("ul"),u=document.createElement("div"),v,x=this;this.getSwatches=function(){let K=Y(ja)(".chickenpaint-color-swatch",r),J=Array(K.length);for(let G=0;GJ.length)){J=J[0];var G=new FileReader;G.onload=function(){let L=(new Rd).read(this.result);null!=L&&0J.length)){J=J[0];var G=new FileReader;G.onload=function(){let L=(new Rd).read(this.result);null!=L&&0 .chickenpaint-palette",g).each(function(){e.showPaletteByName(this.getAttribute("data-paletteName"),!1);l.push(this)});else{for(let n= 0;nn.width&&u.setLocation(n.width-u.getWidth(),u.getY());u.getY()+u.getHeight()/2>n.height&&u.setLocation(u.getX(),n.height-u.getHeight())}r=0
'), -m=navigator.userAgent.toLowerCase().includes("mac os");b[0].addEventListener("touchmove",g=>{g.preventDefault()},{passive:!1});this.getElement=function(){return b[0]};(function(g,e){g.append(e.map(k=>{let l=Y(ja)(''),h=Y(ja)(".dropdown-toggle",l),n=Y(ja)(".dropdown-menu",l);return h[0].addEventListener("show.bs.dropdown", +m=navigator.userAgent.toLowerCase().includes("mac os");b[0].addEventListener("touchmove",g=>{g.preventDefault()},{passive:!1});this.getElement=function(){return b[0]};(function(g,e){g.append(e.map(k=>{let l=Y(ja)(''),h=Y(ja)(".dropdown-toggle",l),n=Y(ja)(".dropdown-menu",l);return h[0].addEventListener("show.bs.dropdown", r=>{!function(u){Y(ja)("[data-action]",u).each(function(){let x=Y(ja)(this);var C=this.getAttribute("data-action");C=a.isActionAllowed(C);x.toggleClass("disabled",!C).toggleClass("hidden",!C&&!0===x.data("hideIfNotAvailable"))});Y(ja)(".dropdown-divider",u).removeClass("hidden");u=Y(ja)(".dropdown-item:not(.hidden),.dropdown-divider:not(.hidden)",u);let v=null;for(let x=0;x{let u;if(!r.action||a.isActionSupported(r.action)){if("CPSend"!=r.action||a.isActionSupported("CPContinue")||(r.name=ma("Post Oekaki"),r.shortcut="ctrl+p"),"-"==r.name?u=Y(ja)(''):(u=Y(ja)(''+ma(r.name)+""),r.checkbox&&Y(ja)(u).data("checkbox",!0).toggleClass("selected",!!r.checked),r.hideIfNotAvailable&&u.data("hideIfNotAvailable",!0)),r.title&&u.attr("title", -ma(r.title)),r.shortcut){var v;let x=u,C=document.createElement("small");m&&(r.shortcut=r.shortcut.replace(/SHIFT/im,"\u21e7"),r.shortcut=r.shortcut.replace(/ALT/im,"\u2325"),r.shortcut=r.shortcut.replace(/CTRL/im,"\u2318"));C.className="chickenpaint-shortcut";C.textContent=(v=(v=(v=(v=r.shortcut).toUpperCase()).replace(/(,.+)$/,"")).replace("=","+"),v=m?v.replace(/([^+])\+/g,"$1"):v.replace(/([^+])\+/g,"$1 "));x.append(C);Y(Sb)(r.shortcut,function(K){return d(x),K.preventDefault(),K.stopPropagation(), +n.append(k.children.map(r=>{let u;if(!r.action||a.isActionSupported(r.action)){if("CPSend"!=r.action||a.isActionSupported("CPContinue")||(r.name=ka("Post Oekaki"),r.shortcut="ctrl+p"),"-"==r.name?u=Y(ja)(''):(u=Y(ja)(''+ka(r.name)+""),r.checkbox&&Y(ja)(u).data("checkbox",!0).toggleClass("selected",!!r.checked),r.hideIfNotAvailable&&u.data("hideIfNotAvailable",!0)),r.title&&u.attr("title", +ka(r.title)),r.shortcut){var v;let x=u,C=document.createElement("small");m&&(r.shortcut=r.shortcut.replace(/SHIFT/im,"\u21e7"),r.shortcut=r.shortcut.replace(/ALT/im,"\u2325"),r.shortcut=r.shortcut.replace(/CTRL/im,"\u2318"));C.className="chickenpaint-shortcut";C.textContent=(v=(v=(v=(v=r.shortcut).toUpperCase()).replace(/(,.+)$/,"")).replace("=","+"),v=m?v.replace(/([^+])\+/g,"$1"):v.replace(/([^+])\+/g,"$1 "));x.append(C);Y(Sb)(r.shortcut,function(K){return d(x),K.preventDefault(),K.stopPropagation(), !1})}return Y(ja)("
  • ").append(u)}})),l}))})(Y(ja)(".navbar-nav",b),Ug);(function(g,e){g.append(e.filter(k=>!!k.mnemonic&&a.isActionSupported(k.action)).map(k=>{let l=Y(ja)(`");return l.on("click",h=>{d(l);h.preventDefault()}),l}))})(Y(ja)(".widget-nav",b),Ug[5].children);Y(ja)(b).on("click","a:not(.dropdown-toggle)",function(g){d(Y(ja)(this)); g.preventDefault()});Y(ja)(".navbar-toggler",b).on("click",g=>{g.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(g,e){Y(ja)('[data-action="CPPal'+g.substring(0,1).toUpperCase()+g.substring(1)+'"]',b).toggleClass("selected",e)});let p=Y(ja)(".dropdown-item[data-action=CPFullScreen]",b);a.on("fullScreen",g=>p.toggleClass("selected",g));p.toggleClass("selected",a.isFullScreen())}function Ue(a,c){let d=document.createElement("div"),b=new Le(a),m=new Te(a),p,g=!1,e=this;this.togglePalettes= function(){m.togglePalettes()};this.arrangePalettes=function(){setTimeout(m.arrangePalettes.bind(m),0)};this.constrainPalettes=function(){m.constrainPalettes()};this.showPalette=function(l,h){m.showPaletteByName(l,h)};this.getSwatches=function(){return m.palettes.swatches.getSwatches()};this.setSwatches=function(l){m.palettes.swatches.setSwatches(l)};this.getPaletteManager=function(){return m};this.setRotation90=function(l){b.setRotation(l*Math.PI/2);m.palettes.layers.setRotation90(l)};this.setFullScreenMode= function(l){g!==l&&(g=l,e.resize(),e.arrangePalettes())};this.resize=function(){let l=window.innerHeight,h=p.getElement().getBoundingClientRect().height;b.resize(g?l-h:Math.min(Math.max(l-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(m.getElement());c.appendChild(d);b.on("canvasRotated90",function(l){m.palettes.layers.setRotation90(l)});screen.orientation&&screen.orientation.addEventListener("change", l=>{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 l=document.querySelector(".chickenpaint .widget-nav"); l&&(k.addEventListener("show.bs.collapse",h=>{l.classList.add("hidden")}),k.addEventListener("hidden.bs.collapse",h=>{l.classList.remove("hidden")}));window.addEventListener("resize",()=>{l.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen",l=>this.setFullScreenMode(l));a.on("toolbarStyleChange",l=>{Y(ja)(c).toggleClass("chickenpaint-toolbar-style-old","old"===l)});a.on("unsavedChanges", -l=>{Y(ja)(c).toggleClass("chickenpaint-unsaved",l)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=Y(ja)('
  • ").append(u)}})),l}))})(Y(ja)(".navbar-nav",b),Ug);(function(g,e){g.append(e.filter(k=>!!k.mnemonic&&a.isActionSupported(k.action)).map(k=>{let l=Y(ja)(`");return l.on("click",h=>{d(l);h.preventDefault()}),l}))})(Y(ja)(".widget-nav",b),Ug[5].children);Y(ja)(b).on("click","a:not(.dropdown-toggle)",function(g){d(Y(ja)(this)); g.preventDefault()});Y(ja)(".navbar-toggler",b).on("click",g=>{g.preventDefault()});c.getPaletteManager().on("paletteVisChange",function(g,e){Y(ja)('[data-action="CPPal'+g.substring(0,1).toUpperCase()+g.substring(1)+'"]',b).toggleClass("selected",e)});let p=Y(ja)(".dropdown-item[data-action=CPFullScreen]",b);a.on("fullScreen",g=>p.toggleClass("selected",g));p.toggleClass("selected",a.isFullScreen())}function Ue(a,c){let d=document.createElement("div"),b=new Le(a),m=new Te(a),p,g=!1,e=this;this.togglePalettes= function(){m.togglePalettes()};this.arrangePalettes=function(){setTimeout(m.arrangePalettes.bind(m),0)};this.constrainPalettes=function(){m.constrainPalettes()};this.showPalette=function(l,h){m.showPaletteByName(l,h)};this.getSwatches=function(){return m.palettes.swatches.getSwatches()};this.setSwatches=function(l){m.palettes.swatches.setSwatches(l)};this.getPaletteManager=function(){return m};this.setRotation90=function(l){b.setRotation(l*Math.PI/2);m.palettes.layers.setRotation90(l)};this.setFullScreenMode= function(l){g!==l&&(g=l,e.resize(),e.arrangePalettes())};this.resize=function(){let l=window.innerHeight,h=p.getElement().getBoundingClientRect().height;b.resize(g?l-h:Math.min(Math.max(l-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(m.getElement());c.appendChild(d);b.on("canvasRotated90",function(l){m.palettes.layers.setRotation90(l)});screen.orientation&&screen.orientation.addEventListener("change", l=>{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 l=document.querySelector(".chickenpaint .widget-nav"); l&&(k.addEventListener("show.bs.collapse",h=>{l.classList.add("hidden")}),k.addEventListener("hidden.bs.collapse",h=>{l.classList.remove("hidden")}));window.addEventListener("resize",()=>{l.classList.remove("hidden")})}document.addEventListener("hidden.bs.collapse",this.resize.bind(this));window.addEventListener("resize",this.resize.bind(this));a.on("fullScreen",l=>this.setFullScreenMode(l));a.on("toolbarStyleChange",l=>{Y(ja)(c).toggleClass("chickenpaint-toolbar-style-old","old"===l)});a.on("unsavedChanges", -l=>{Y(ja)(c).toggleClass("chickenpaint-unsaved",l)});setTimeout(this.resize.bind(this),0)}function Vh(a){var c=Y(ja)('