From 07a4708f554ffe5be508c8c6e47479620cb246e3 Mon Sep 17 00:00:00 2001 From: satopian Date: Wed, 16 Oct 2024 09:52:51 +0900 Subject: [PATCH] chickenpaint.js --- potiboard5/chickenpaint/js/chickenpaint.js | 144 +++++++++--------- .../chickenpaint/js/chickenpaint.min.js | 144 +++++++++--------- 2 files changed, 144 insertions(+), 144 deletions(-) diff --git a/potiboard5/chickenpaint/js/chickenpaint.js b/potiboard5/chickenpaint/js/chickenpaint.js index cc7201dc..c6d8302a 100644 --- a/potiboard5/chickenpaint/js/chickenpaint.js +++ b/potiboard5/chickenpaint/js/chickenpaint.js @@ -75,19 +75,19 @@ eb&&(clearTimeout(eb),eb=null)}function m(D,P,da,fa){Array.isArray(D)||(D=[D]);D Oa[Ca.BRUSH_MODE_PAINT].mergeOntoMask(D,Ja,4278190080):Oa[hb.brushMode].mergeOntoMask(D,Ja,255&Yb)}else{D=pa.image;let P=pa.getLockAlpha();hb.brushMode==Ca.BRUSH_MODE_ERASE&&P?Oa[Ca.BRUSH_MODE_PAINT].mergeOntoImage(D,Lb,16777215):Oa[hb.brushMode].mergeOntoImage(D,Lb,Yb);P&&D.copyAlphaFrom(Lb,Ba)}Ba.makeEmpty()}}function r(){pa instanceof Ma&&!Fb.isEmpty()&&(Lb.copyBitmapRect(pa.image,Fb.left,Fb.top,Fb),Fb.makeEmpty())}function u(){pa.mask&&!La.isEmpty()&&(Ja.copyBitmapRect(pa.mask,La.left,La.top, La),La.makeEmpty())}function v(){Ta?u():r()}function x(){let D=ha.getBounds();Fb.set(D);La.set(D)}function C(D){ha.setHasUnsavedChanges(!0);0N.getMemoryUsed()).reduce(Ce,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],la=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;Daca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(yc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> -F["set"+da](this.from[N]));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var ca=F.layers;if(N.length!=ca.length)N=!1;else{for(let la=0;laN.getMemoryUsed()).reduce(Ce,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],ka=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;Daca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(yc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> +F["set"+da](this.from[N]));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var ca=F.layers;if(N.length!=ca.length)N=!1;else{for(let ka=0;kaS.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===S.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let N=F=!0,ca=this.getBounds();fa.clearAll(ca,16777215);for(let la=0;la<=da;la++){let xa=P[la];N||(F=F&&fa.hasAlphaInRect(ca));xa.blendMode===S.LM_MULTIPLY&&("bake"===D?!F&&0S.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===S.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let N=F=!0,ca=this.getBounds();fa.clearAll(ca,16777215);for(let ka=0;ka<=da;ka++){let xa=P[ka];N||(F=F&&fa.hasAlphaInRect(ca));xa.blendMode===S.LM_MULTIPLY&&("bake"===D?!F&&0F){let N=Tb,ca=vb,la=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,ca=F*P+(1-F)*vb,la=F*da+(1-F)*Rb,this.paintDab(N,ca,la);Tb=N;vb=ca;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(), +this.setLayerLockAlpha=function(D){pa.getLockAlpha()!=D&&C(new Xb(pa,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,da){return!(null===hb||!this.isActiveLayerDrawable())&&(v(),lb.makeEmpty(),la.clearAll(0),Ba.makeEmpty(),Tb=D,vb=P,Rb=da,Hc=!0,Oa[hb.brushMode].beginStroke(),this.paintDab(D,P,da),!0)};this.continueStroke=function(D,P,da){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,ca=vb,ka=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,ca=F*P+(1-F)*vb,ka=F*da+(1-F)*Rb,this.paintDab(N,ca,ka);Tb=N;vb=ca;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(), Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Ma&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(yc.prototype);K.prototype.constructor=K;I.prototype=Object.create(yc.prototype);I.prototype.constructor=I;G.prototype=Object.create(yc.prototype);G.prototype.constructor=G;L.prototype=Object.create(yc.prototype);L.prototype.constructor=L;U.prototype=Object.create(yc.prototype);U.prototype.constructor=U;T.prototype= Object.create(yc.prototype);T.prototype.constructor=T;Y.prototype=Object.create(yc.prototype);Y.prototype.constructor=Y;ea.prototype=Object.create(yc.prototype);ea.prototype.constructor=ea;ja.prototype=Object.create(yc.prototype);ja.prototype.constructor=ja;ra.prototype=Object.create(yc.prototype);ra.prototype.constructor=ra;let Qc=Na("alpha",!0),Rc=Na("blendMode",!0),A=Na("visible",!0),ua=Na("clip",!0),tc=Na("maskVisible",!0),Mc=Na("name",!1),Xb=Na("lockAlpha",!1),Zc=Na("maskLinked",!1);V.prototype= Object.create(yc.prototype);V.prototype.constructor=V;class va extends yc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(da=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,da.left,da.top,da);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,da.left,da.top,da)}):(P.moveImage&&P.imageRect.forEach((da,fa)=>{P.layer.image.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}), @@ -122,16 +122,16 @@ this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new this.movingLayers[P];da.moveMask&&D.union(da.layer.mask.getValueBounds(this.srcRect,255));da.moveImage&&D.union(da.layer.image.getNonTransparentBounds(this.srcRect))}}else for(this.srcRect=this.fromSelection.clone(),P=0;P{if(D.moveImage){var P=Yc(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=Yc(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=Yc(ha.width,ha.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),nf(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0,0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(ha.getBounds())); -let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ca=>{if(fa.forEach(la=>{ca.moveImage&&ca.layer.image.clearRect(la,16777215);ca.moveMask&&(this.movingWholeLayer?ca.layer.mask.clearRect(la,255):ca.layer.mask.clearRect(la,0))}),!this.dstRect.isEmpty()){if(ca.moveImage){let la= -ca.imageUndo.getImageData();da.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(ca.imageSourceCanvas,this.srcRect.left, -this.srcRect.top);this.composeCanvasContext.restore();ca.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()))}ca.moveMask&&(da.forEach(la=>{this.composeCanvasContext.putImageData(ca.layer.mask.getImageData(la.left,la.top,la.getWidth(),la.getHeight()),la.left,la.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle= +let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ca=>{if(fa.forEach(ka=>{ca.moveImage&&ca.layer.image.clearRect(ka,16777215);ca.moveMask&&(this.movingWholeLayer?ca.layer.mask.clearRect(ka,255):ca.layer.mask.clearRect(ka,0))}),!this.dstRect.isEmpty()){if(ca.moveImage){let ka= +ca.imageUndo.getImageData();da.forEach(xa=>{this.composeCanvasContext.putImageData(ka,0,0,xa.left,xa.top,xa.getWidth(),xa.getHeight())});this.composeCanvasContext.clearRect(F.left,F.top,F.getWidth(),F.getHeight());this.composeCanvasContext.save();this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]);this.composeCanvasContext.drawImage(ca.imageSourceCanvas,this.srcRect.left, +this.srcRect.top);this.composeCanvasContext.restore();ca.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()))}ca.moveMask&&(da.forEach(ka=>{this.composeCanvasContext.putImageData(ca.layer.mask.getImageData(ka.left,ka.top,ka.getWidth(),ka.getHeight()),ka.left,ka.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle= "#FFF":this.composeCanvasContext.fillStyle="#000",this.composeCanvasContext.fillRect(F.left,F.top,F.getWidth(),F.getHeight()),this.composeCanvasContext.save(),this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]),this.composeCanvasContext.drawImage(ca.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),ca.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(la=>{ca.moveImage&&ca.layer.image.copyBitmapRect(ca.imageUndo,la.left,la.top,la);ca.moveMask&&ca.layer.mask.copyBitmapRect(ca.maskUndo,la.left,la.top,la)})}),m(this.movingLayers.map(ca=>ca.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(ka=>{ca.moveImage&&ca.layer.image.copyBitmapRect(ca.imageUndo,ka.left,ka.top,ka);ca.moveMask&&ca.layer.mask.copyBitmapRect(ca.maskUndo,ka.left,ka.top,ka)})}),m(this.movingLayers.map(ca=>ca.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&&nf(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+=og(this.composeCanvas),D+=this.movingLayers.map(da=> og(da.imageSourceCanvas)).reduce(Ce,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 uc extends va{redo(){var D=this.dstRect.clone();let P,da,fa=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect), this.dstRect.translate(this.offsetX,this.offsetY),P=this.dstRect.clone(),this.dstRect.clipTo(ha.getBounds()),this.erasesSourceRect?(F=D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),fa.union(F),da=D.subtract(this.srcRect)):da=[D],this.movingLayers.forEach(N=>{F&&(N.moveImage&&N.layer.image.clearRect(F,16777215),N.moveMask&&N.layer.mask.clearRect(F,this.movingWholeLayer?255:0));da.forEach(function(ca){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,ca.left,ca.top,ca);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo, ca.left,ca.top,ca)});N.moveImage&&S.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),m(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,da){super(); -this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(yc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(yc.prototype);qa.prototype.constructor=qa;Oa=[Md,xh,yh,zh,ee,Ah,Bh,Ch].map(D=>new D(ka,Ba));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 Nd(a){for(var c=a.length;0<=--c;)a[c]=0}function of(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; +this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(yc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(yc.prototype);qa.prototype.constructor=qa;Oa=[Md,xh,yh,zh,ee,Ah,Bh,Ch].map(D=>new D(la,Ba));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 Nd(a){for(var c=a.length;0<=--c;)a[c]=0}function of(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; this.extra_base=d;this.elems=b;this.max_length=k;this.has_stree=a&&a.length}function pf(a,c){this.dyn_tree=a;this.max_code=0;this.stat_desc=c}function pg(a){return 256>a?fe[a]:fe[256+(a>>>7)]}function ge(a,c){a.pending_buf[a.pending++]=255&c;a.pending_buf[a.pending++]=c>>>8&255}function Dc(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 rg(a,c,d){var b,k=Array(16),p=0;for(b=1;15>=b;b++)k[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=qg(k[b]++,b))}function sg(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 tg(a){8za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(la=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Lg;let cb=T(N),gb=T(ca),Da=T(la),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; -za.x3=jb.x;za.y3=jb.y;let Vb=Array(100),kc=Array(100);za.compute(Vb,kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(za=1;100>za;za++)ha.lineTo(Vb[za],kc[za]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Da.x,~~Da.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,ca,la){return!!this.capture||(X(Sb).isPressed("space")||(0!=ca||this.transient&&!N.altKey)&&2!=ca?void(this.transient&&va.pop()):(F=ca,this.capture= -!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag=function(N){if(this.capture)return N=L({x:rb,y:hb}),Ia.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ia.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,ca,la){if(this.capture&&ca==F)return F=-1,this.capture=!1,x("default"),this.transient&&va.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function m(){var F,N,ca,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"),va.pop(),!0};this.mouseDown=function(xa,za,cb){return!!this.capture||(1==za||X(Sb).isPressed("space")&&0==za||!this.transient&&0==za?(this.capture=!0,la=za,F=xa.pageX,N=xa.pageY,ca=Ja.getOffset(),x("grabbing"),!0):void(this.transient&&va.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ja.setOffset(ca.x+xa.pageX-F,ca.y+xa.pageY-N),!0};this.mouseUp=function(xa,za,cb){if(this.capture&&za==la)return la=-1,this.capture=!1,this.transient&&!X(Sb).isPressed("space")&& -(x("default"),va.pop()),!0};this.enter=function(){x("grab")}}function l(){}function g(){var F,N=new Ha(0,0,0,0),ca=-1;this.mouseDown=function(la,xa,za){if(!this.capture&&0==xa&&!la.altKey&&!X(Sb).isPressed("space"))return la=U({x:rb,y:hb}),ca=xa,N.makeEmpty(),F=la,Ja.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(la){if(!this.capture)return!1;var xa=U({x:rb,y:hb});la=la.shiftKey;var za=~~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+za:xa.x)+ -1):(N.left=la?F.x-za:xa.x,N.right=F.x+1),xa.y>=F.y?(N.top=F.y,N.bottom=(la?F.y+za:xa.y)+1):(N.top=la?F.y-za:xa.y,N.bottom=F.y+1),Ja.repaintAll(),!0};this.mouseUp=function(la,xa,za){if(this.capture&&xa==ca)return Ia.rectangleSelection(N),N.makeEmpty(),Ja.repaintAll(),this.capture=!1,ca=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ja(ha,N))}}function n(){var F,N,ca=!1;this.mouseDown=function(la,xa,za){if(!this.capture&&0==xa&&!X(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=la.altKey, -ca=!0,this.capture=!0,!0};this.mouseDrag=Mg(25,function(la){if(this.capture){la=L({x:rb,y:hb});var xa=la.x-F.x,za=la.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=la.x-(xa-cb),F.y=la.y-(za-gb),!0}});this.mouseUp=function(la,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< +"top":"left"],10)?e-=l:e+=l,v.emitEvent("valueChanged",[e]),c())})}function nc(){this.modes=[]}function Ke(a){function c(){}function d(){}function b(){this.shouldPaintBrushPreview=!1;this.oldPreviewRect=null}function k(){b.call(this);this.smoothMouse={x:0,y:0}}function p(){var F,N;this.mouseDown=function(ca,ka,xa){if(!this.capture&&0==ka&&!ca.altKey&&!X(Sb).isPressed("space")&&K())return this.capture=!0,F=N={x:rb+.5,y:hb+.5},this.eraseBrushPreview(),!0};this.mouseDrag=function(ca){if(this.capture){var ka= +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},ca.shiftKey){var xa=Math.PI/4;ca=Math.round(Math.atan2(N.y-F.y,N.x-F.x)/xa);switch(ca){case 0:case 4:N.y=F.y;break;case 2:case 6:N.x=F.x;break;default:ca*=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(ca),N.y=F.y+xa*Math.sin(ca)}}return ka.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(ka),!0}this.mouseMove.call(this,ca)};this.mouseUp=function(ca,ka,xa){if(this.capture&&0==ka)return ca=L(F),ka=L(N),this.capture=!1,this.drawLine(ca,ka),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 h(){let F=0,N,ca,ka,xa;this.mouseDown=function(za,cb,gb){if(!this.capture&& +0==cb&&!za.altKey&&!X(Sb).isPressed("space")&&K())return za=L({x:rb,y:hb}),F=0,N=ca=ka=xa=za,this.capture=!0,this.eraseBrushPreview(),!0};this.mouseDrag=function(za){if(this.capture&&0===F)return ka=xa=L({x:rb,y:hb}),Ja.repaintAll(),!0;this.mouseMove.call(this,za)};this.mouseUp=function(za,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=ca;let Da=ka,jb=xa;za=new Lg;za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y;za.x3=jb.x; +za.y3=jb.y;cb=Array(500);gb=Array(500);za.compute(cb,gb,500);Ia.beginStroke(cb[0],gb[0],1);for(za=1;500>za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(ka=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Lg;let cb=T(N),gb=T(ca),Da=T(ka),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; +za.x3=jb.x;za.y3=jb.y;let Vb=Array(100),kc=Array(100);za.compute(Vb,kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(za=1;100>za;za++)ha.lineTo(Vb[za],kc[za]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Da.x,~~Da.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,ca,ka){return!!this.capture||(X(Sb).isPressed("space")||(0!=ca||this.transient&&!N.altKey)&&2!=ca?void(this.transient&&va.pop()):(F=ca,this.capture= +!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag=function(N){if(this.capture)return N=L({x:rb,y:hb}),Ia.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ia.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,ca,ka){if(this.capture&&ca==F)return F=-1,this.capture=!1,x("default"),this.transient&&va.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function m(){var F,N,ca,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"),va.pop(),!0};this.mouseDown=function(xa,za,cb){return!!this.capture||(1==za||X(Sb).isPressed("space")&&0==za||!this.transient&&0==za?(this.capture=!0,ka=za,F=xa.pageX,N=xa.pageY,ca=Ja.getOffset(),x("grabbing"),!0):void(this.transient&&va.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ja.setOffset(ca.x+xa.pageX-F,ca.y+xa.pageY-N),!0};this.mouseUp=function(xa,za,cb){if(this.capture&&za==ka)return ka=-1,this.capture=!1,this.transient&&!X(Sb).isPressed("space")&& +(x("default"),va.pop()),!0};this.enter=function(){x("grab")}}function l(){}function g(){var F,N=new Ha(0,0,0,0),ca=-1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!ka.altKey&&!X(Sb).isPressed("space"))return ka=U({x:rb,y:hb}),ca=xa,N.makeEmpty(),F=ka,Ja.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(ka){if(!this.capture)return!1;var xa=U({x:rb,y:hb});ka=ka.shiftKey;var za=~~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+za:xa.x)+ +1):(N.left=ka?F.x-za:xa.x,N.right=F.x+1),xa.y>=F.y?(N.top=F.y,N.bottom=(ka?F.y+za:xa.y)+1):(N.top=ka?F.y-za:xa.y,N.bottom=F.y+1),Ja.repaintAll(),!0};this.mouseUp=function(ka,xa,za){if(this.capture&&xa==ca)return Ia.rectangleSelection(N),N.makeEmpty(),Ja.repaintAll(),this.capture=!1,ca=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ja(ha,N))}}function n(){var F,N,ca=!1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!X(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=ka.altKey, +ca=!0,this.capture=!0,!0};this.mouseDrag=Mg(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,za=ka.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=ka.x-(xa-cb),F.y=ka.y-(za-gb),!0}});this.mouseUp=function(ka,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< Ea.points.length;Ra++)if(49>=(Ka.x-Ea.points[Ra].x)*(Ka.x-Ea.points[Ra].x)+(Ka.y-Ea.points[Ra].y)*(Ka.y-Ea.points[Ra].y))return 2*Ra;for(Ra=0;Ra=zc&&(pb.scale(zc),49>=(pb.x-nb.x)*(pb.x-nb.x)+(pb.y-nb.y)*(pb.y-nb.y)))return 2*Ra+1}return Ea.containsPoint(Ka)? --3:-2}function la(){var Ea=gb.getTransformed(Db),Ka=ca(Ea,{x:rb,y:hb});switch(Ka){case 0:case 2:case 4:case 6:Ka=~~(Ka/2);let Ra=Ea.points[Ka],nb=Ea.points[(Ka+1)%4];xa(Mb.subtractPoints(Ea.points[(Ka+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Ea.points[(~~(Ka/2)+1)%4],Ea.points[~~(Ka/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Ea){Ea=Math.floor(Math.atan2(-Ea.y,Ea.x)/(Math.PI/ -4)+.5);switch(0>Ea&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,la(),!0};this.mouseDrag=Mg(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); +-3:-2}function ka(){var Ea=gb.getTransformed(Db),Ka=ca(Ea,{x:rb,y:hb});switch(Ka){case 0:case 2:case 4:case 6:Ka=~~(Ka/2);let Ra=Ea.points[Ka],nb=Ea.points[(Ka+1)%4];xa(Mb.subtractPoints(Ea.points[(Ka+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Ea.points[(~~(Ka/2)+1)%4],Ea.points[~~(Ka/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Ea){Ea=Math.floor(Math.atan2(-Ea.y,Ea.x)/(Math.PI/ +4)+.5);switch(0>Ea&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Mg(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); Ka=Ra.getTruncated();Ra=Ra.subtract(Ka);var nb=new Kb;nb.translate(Ka.x,Ka.y);za.preMultiply(nb);jb=Mb.subtractPoints(Ea,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=T(Ra),vc=Math.atan2(Ka.y-pb.y,Ka.x-pb.x)-Math.atan2(Da.y-pb.y,Da.x-pb.x);pb=new Kb;Vb+=vc;Ea=Ea.shiftKey?-za.decompose().rotate+Math.round(Vb/nb)*nb:vc;pb.rotateAroundPoint(Ea,Ra.x,Ra.y);za.preMultiply(pb);Da=Ka;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=cb.points[nb];pb=za.getInverted().getTransformedPoint(N(L(Ka))); Ka=cb.points[(nb+2)%4];nb=(pb.x-Ka.x)/(Ra.x-Ka.x);Ra=(pb.y-Ka.y)/(Ra.y-Ka.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Ea.shiftKey&&(Ra=nb=Ea=Math.max(nb,Ra));za.scaleAroundPoint(nb,Ra,Ka.x,Ka.y);break;case 1:case 5:case 3:case 7:Ea=~~(kc/2);pb=F(cb.points[Ea],cb.points[(Ea+1)%4]);Ka=za.getInverted().getTransformedPoint(N(L(Ka)));Ea=F(cb.points[(Ea+2)%4],cb.points[(Ea+3)%4]);pb=Mb.subtractPoints(pb,Ea);Ka=Mb.subtractPoints(Ka,Ea);vc=pb.getLength();Ka=pb.getDotProduct(Ka)/ -vc/vc;if(.001>Math.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||la()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaMath.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||ka()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaMath.abs(la-1)?F=1:.2>Math.abs(la-2)?F=2:.08>Math.abs(la-.5)&&(F=.5);V(F,N/2,ca/2)}function qa(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure? -1:"touch"===F.pointerType?(0!==F.pressure&&(Hc=!0),Hc)?2*F.pressure:1:2*F.pressure}function mb(){eb||(eb=!0,window.requestAnimationFrame(function(){Ja.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ia.getBounds();Ja.repaintAll()}let Fb,Ja=this,La=document.createElement("div"),ka=document.createElement("div"),Ba=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),pa=Oa.getContext("2d"),Ta=Ng(ha),Ia=a.getArtwork(), +F&&ya.setAttribute("data-cursor",F)}function C(){var F=Ia.getActiveLayer();return F.visible&&F.ancestorsAreVisible()?0!=F.alpha||(a.showLayerNotification(F,ma("Whoops! This layer's opacity is currently 0%"),"opacity"),!1):(a.showLayerNotification(F,ma("Whoops! This layer is currently hidden"),"layer"),!1)}function K(){var F=Ia.getActiveLayer();return F instanceof ob&&!Ia.isEditingMask()?(a.showLayerNotification(F,ma("Whoops! You can't draw on a group"),"layer"),!1):C()}function I(F,N,ca,ka,xa){F.setValues(-xa, +ka,N-ka-xa+ca/4,N+ca-xa-ca/4);F.setBlockIncrement(Math.max(1,~~(.66*ka)));F.setUnitIncrement(Math.max(1,~~(.05*ka)))}function G(){Db.setToIdentity();Db.translate(bc,jc);Db.scale(lb,lb);Db.rotate(Nb);if(null!=uc&&null!=D&&!uc.getValueIsAdjusting()&&!D.getValueIsAdjusting()){var F=ra(new Ha(0,0,Oa.width,Oa.height));I(uc,F.left,F.getWidth(),X(ia)(ya).width(),Ja.getOffset().x);I(D,F.top,F.getHeight(),X(ia)(ya).height(),Ja.getOffset().y)}Ja.repaintAll()}function L(F){return Db.getInverted().getTransformedPoint(F)} +function U(F){F=L(F);return F.x=Math.floor(F.x),F.y=Math.floor(F.y),F}function T(F){return Db.getTransformedPoint(F)}function Y(F){F=T(F);return F.x=Math.round(F.x),F.y=Math.round(F.y),F}function ea(F,N){F.beginPath();F.moveTo(N[0].x,N[0].y);for(var ca=1;caMath.abs(ka-1)?F=1:.2>Math.abs(ka-2)?F=2:.08>Math.abs(ka-.5)&&(F=.5);V(F,N/2,ca/2)}function qa(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure? +1:"touch"===F.pointerType?(0!==F.pressure&&(Hc=!0),Hc)?2*F.pressure:1:2*F.pressure}function mb(){eb||(eb=!0,window.requestAnimationFrame(function(){Ja.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ia.getBounds();Ja.repaintAll()}let Fb,Ja=this,La=document.createElement("div"),la=document.createElement("div"),Ba=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),pa=Oa.getContext("2d"),Ta=Ng(ha),Ia=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,Hc=!1,ec=Ia.getBounds(),Va=new Ha(0,0,0,0),eb=!1,Yb;let Ya,Qc,Rc,A,ua,tc,Mc,Xb,Zc=[],va=new nc,fc,uc=new me(!1),D=new me(!0),P=dd.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 ca=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));return this.smoothMouse.x=(1-ca)*F.x+ca*this.smoothMouse.x,this.smoothMouse.y=(1-ca)*F.y+ca*this.smoothMouse.y,Ia.continueStroke(this.smoothMouse.x, +K()&&(F=L({x:rb,y:hb}),this.eraseBrushPreview(),Ia.beginStroke(F.x,F.y,ca)))return this.capture=!0,this.smoothMouse=F,!0};k.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 ca=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let ka=1-ca;return this.smoothMouse.x=ka*F.x+ca*this.smoothMouse.x,this.smoothMouse.y=ka*F.y+ca*this.smoothMouse.y,Ia.continueStroke(this.smoothMouse.x, this.smoothMouse.y,N),!0}this.mouseMove(F)};k.prototype.mouseUp=function(F,N,ca){if(this.capture)return 0==N&&(this.capture=!1,Ia.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ia.beginStroke(F.x,F.y,1);Ia.continueStroke(N.x,N.y,1);Ia.endStroke()};h.prototype=Object.create(b.prototype);h.prototype.constructor=h;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;m.prototype=Object.create(c.prototype);m.prototype.constructor= m;l.prototype=Object.create(c.prototype);l.prototype.constructor=l;l.prototype.mouseDown=function(F,N,ca){if(0==N&&!F.altKey&&!X(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ia.isPointWithin(F.x,F.y)&&(Ia.floodFill(F.x,F.y),Ja.repaintAll()),!0};g.prototype=Object.create(c.prototype);g.prototype.constructor=g;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!X(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){Ia.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;nf(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(){Fa(1.41*this.getZoom())}; this.zoomOut=function(){Fa(.7092*this.getZoom())};this.zoom100=function(){Fa(1);Na()};this.resetRotation=function(){var F=ya.width/2,N=ya.height/2,ca=new Kb;ca.rotateAroundPoint(-this.getRotation(),F,N);ca.multiply(Db);this.setOffset(~~ca.getTranslateX(),~~ca.getTranslateY());this.setRotation(0);Ja.emitEvent("canvasRotated90",[0])};let da=!1;this.getElement=function(){return La};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(eb=!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():Ia.fusionLayers().getImageData();pa.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,Ia.width,Ia.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(),Je(ha,"stroke"),ha.lineWidth=1,Ia.getSelection().isEmpty()||va.peek()instanceof g&&va.peek().capture||(ha.setLineDash([3,2]),ja(ha,Ia.getSelection()),ha.setLineDash([])),Wb)if(N=Ia.getBounds(),2lb.bottom){Oa=k.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(pa>=lb.top){Ta=p[Ia];let bc=lb.bottom-lb.top;Oa={layer:Ta,displayIndex:Ia};Ta instanceof ob?pa>=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==qa.layer.parent&&("over"==Oa.direction||"under"==Oa.direction)&&(pa=Oa.layer.parent,Ia=pa.indexOf(Oa.layer),"over"==Oa.direction&&pa.layers[Ia+1]==qa.layer||"under"==Oa.direction&& -pa.layers[Ia-1]==qa.layer||Oa.layer==qa.layer)?null:qa.layer instanceof ob&&(Oa.layer==qa.layer&&"inside"==Oa.direction||Oa.layer.hasAncestor(qa.layer))?null:Oa}(qa.dragX,qa.dragY),qa.dropTarget){var ka=G(qa.dropTarget.displayIndex);switch(qa.dropTarget.direction){case "over":case "under":Xa.appendChild(qa.dropBetweenMarkerElem);La=qa.dropTarget.layer.getDepth()-1;var Ba;if(ka=ka.getBoundingClientRect(),"under"==qa.dropTarget.direction&&qa.dropTarget.layer instanceof ob&&qa.dropTarget.layer.expanded){for(Ba= -qa.dropTarget.displayIndex-1;0<=Ba&&p[Ba].hasAncestor(qa.dropTarget.layer);Ba--);Ba=G(Ba+1).getBoundingClientRect().bottom}else Ba=ka.bottom;La=ka.left-ya.left+(0ea(ha,ya)),Ba=document.createDocumentFragment();X(ia)(Xa).empty();for(let ya=ka.length-1;0<=ya;ya--)Ba.appendChild(ka[ya]);Xa.appendChild(Ba);U()},this.layerChanged=function(ka){let Ba=p.indexOf(ka),ya=X(ia)(G(Ba));0===ya.length||ka instanceof ob&&(ka.expanded!=X(ia)(ya).hasClass("chickenpaint-layer-group-expanded")||ka.visible!=X(ia)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(ea(Ba,ka))},this.setRotation90= -function(ka){if(Lb!=ka)for(Lb=ka,ka=0;kaka.preventDefault(),!0),Xa.className="list-group",Xa.addEventListener("dblclick",function(ka){0===ka.button&&0{3===qa.state&&(Na(),qa.dragY=ka.clientY,U())},800)):qa.state=1,qa.dropTarget=null,qa.layer=ya,qa.layerElem=G(Ba),qa.dragX=ka.clientX,qa.dragY=ka.clientY,Xa.setPointerCapture(ka.pointerId),Xa.addEventListener("pointermove",V),Xa.addEventListener("pointerup",ra)):2==ka.button&&!ha&&(ka.preventDefault(),-1!=L(ka.target)&&(ja(L(ka.target)),ka.preventDefault()))}}}}), +case 1:if(5ea(ha,ya)),Ba=document.createDocumentFragment();X(ia)(Xa).empty();for(let ya=la.length-1;0<=ya;ya--)Ba.appendChild(la[ya]);Xa.appendChild(Ba);U()},this.layerChanged=function(la){let Ba=p.indexOf(la),ya=X(ia)(G(Ba));0===ya.length||la instanceof ob&&(la.expanded!=X(ia)(ya).hasClass("chickenpaint-layer-group-expanded")||la.visible!=X(ia)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(ea(Ba,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===qa.state&&(Na(),qa.dragY=la.clientY,U())},800)):qa.state=1,qa.dropTarget=null,qa.layer=ya,qa.layerElem=G(Ba),qa.dragX=la.clientX,qa.dragY=la.clientY,Xa.setPointerCapture(la.pointerId),Xa.addEventListener("pointermove",V),Xa.addEventListener("pointerup",ra)):2==la.button&&!ha&&(la.preventDefault(),-1!=L(la.target)&&(ja(L(la.target)),la.preventDefault()))}}}}), Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(La,Sh);mb.appendChild(Xa)},l=new Ec(0,100,!1,!1,208),g=document.createElement("select"),n=new function(){let G=null,L="",U=document.createElement("input"),T=this;this.hide=function(){G=null;let Y=X(ia)(U).parent();Y&&(X(ia)(U).remove(),Y.text(L))};this.renameAndHide=function(){G&&G.name!=U.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:U.value});this.hide()};this.show= function(Y,ea){L=(G=Y).name;U.value=L;(Y=ea.querySelector(".chickenpaint-layer-name"))&&Y.parentNode&&(ea=Y.firstChild)&&ea.nodeType===Node.TEXT_NODE&&(Y.removeChild(ea),Y.appendChild(U));U.select()};U.type="text";U.className="chickenpaint-layer-rename form-control input-sm";U.addEventListener("keydown",function(Y){Y.stopPropagation()});U.addEventListener("keydown",function(Y){"Enter"===Y.key&&T.renameAndHide();Y.stopPropagation()});U.addEventListener("keyup",function(Y){"Escape"===Y.key&&T.hide(); Y.stopPropagation()});U.addEventListener("blur",function(Y){G&&T.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,I=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();m.resize()};this.setHeight=function(G){I.call(this,G);m.resize()};this.setRotation90=function(G){m.setRotation90(G)};this.dismissNotification=function(){X(ia)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", @@ -703,7 +703,7 @@ y.isImmediatePropagationStopped=T)}})):void 0===Da.get(f,t)&&A.event.add(f,t,T)} (oa=A.clone(oa,!0,!0),J&&A.merge(E,G(oa,"script")));w.call(f[O],oa,O)}if(J)for(B=E[E.length-1].ownerDocument,A.map(E,V),O=0;OJ;J+=2)"margin"===w&&(W+=A.css(f,w+Ra[J],!0,B)),y?("content"===w&&(M-=A.css(f,"padding"+Ra[J],!0, -B)),"margin"!==w&&(M-=A.css(f,"border"+Ra[J]+"Width",!0,B))):(M+=A.css(f,"padding"+Ra[J],!0,B),"padding"!==w?M+=A.css(f,"border"+Ra[J]+"Width",!0,B):O+=A.css(f,"border"+Ra[J]+"Width",!0,B));return!y&&0<=E&&(M+=Math.max(0,Math.ceil(f["offset"+t[0].toUpperCase()+t.slice(1)]-E-M-O-.5))||0),M+W}function ka(f,t,w){var y=Vd(f),B=(!Va.boxSizingReliable()||w)&&"border-box"===A.css(f,"boxSizing",!1,y),E=B,J=Xa(f,t,y),O="offset"+t[0].toUpperCase()+t.slice(1);if(Dd.test(J)){if(!w)return J;J="auto"}return(!Va.boxSizingReliable()&& +B)),"margin"!==w&&(M-=A.css(f,"border"+Ra[J]+"Width",!0,B))):(M+=A.css(f,"padding"+Ra[J],!0,B),"padding"!==w?M+=A.css(f,"border"+Ra[J]+"Width",!0,B):O+=A.css(f,"border"+Ra[J]+"Width",!0,B));return!y&&0<=E&&(M+=Math.max(0,Math.ceil(f["offset"+t[0].toUpperCase()+t.slice(1)]-E-M-O-.5))||0),M+W}function la(f,t,w){var y=Vd(f),B=(!Va.boxSizingReliable()||w)&&"border-box"===A.css(f,"boxSizing",!1,y),E=B,J=Xa(f,t,y),O="offset"+t[0].toUpperCase()+t.slice(1);if(Dd.test(J)){if(!w)return J;J="auto"}return(!Va.boxSizingReliable()&& B||!Va.reliableTrDimensions()&&p(f,"tr")||"auto"===J||!parseFloat(J)&&"inline"===A.css(f,"display",!1,y))&&f.getClientRects().length&&(B="border-box"===A.css(f,"boxSizing",!1,y),(E=O in f)&&(J=f[O])),(J=parseFloat(J)||0)+La(f,t,w||(B?"border":"content"),E,y,J)+"px"}function Ba(f,t,w,y,B){return new Ba.prototype.init(f,t,w,y,B)}function ya(){return a.setTimeout(function(){qd=void 0}),qd=Date.now()}function ha(f,t){var w,y=0,B={height:f};for(t=t?1:0;4>y;y+=2-t)B["margin"+(w=Ra[y])]=B["padding"+w]=f; return t&&(B.opacity=B.width=f),B}function Oa(f,t,w){for(var y,B=(pa.tweeners[t]||[]).concat(pa.tweeners["*"]),E=0,J=B.length;EZ&&oa)?W:(oa||J.notifyWith(f,[M,1,0]),J.resolveWith(f, [M]),!1)},M=J.promise({elem:f,props:A.extend({},t),opts:A.extend(!0,{specialEasing:{},easing:A.easing._default},w),originalProperties:t,originalOptions:w,startTime:qd||ya(),duration:w.duration,tweens:[],createTween:function(W,Z){W=A.Tween(f,M.opts,W,Z,M.opts.specialEasing[W]||M.opts.easing);return M.tweens.push(W),W},stop:function(W){var Z=0,R=W?M.tweens.length:0;if(y)return this;for(y=!0;Z=W&&(oa!==g&&(wa=void 0,Aa=[Qa]),R.rejectWith(wa,Aa))}};Z?Ua():(A.Deferred.getErrorHook?Ua.error=A.Deferred.getErrorHook():A.Deferred.getStackHook&&(Ua.error=A.Deferred.getStackHook()), a.setTimeout(Ua))}}var W=0;return A.Deferred(function(Z){t[0][3].add(M(0,Z,eb(O)?O:l,Z.notifyWith));t[1][3].add(M(0,Z,eb(E)?E:l));t[2][3].add(M(0,Z,eb(J)?J:g))}).promise()},promise:function(E){return null!=E?A.extend(E,y):y}},B={};return A.each(t,function(E,J){var O=J[2],M=J[5];y[J[1]]=O.add;M&&O.add(function(){w=M},t[3-E][2].disable,t[3-E][3].disable,t[0][2].lock,t[0][3].lock);O.add(J[3].fire);B[J[0]]=function(){return B[J[0]+"With"](this===B?void 0:this,arguments),this};B[J[0]+"With"]=O.fireWith}), y.promise(B),f&&f.call(B,B),B},when:function(f){var t=arguments.length,w=t,y=Array(w),B=kb.call(arguments),E=A.Deferred(),J=function(O){return function(M){y[O]=this;B[O]=1=t&&(n(f,E.done(J(w)).resolve,E.reject,!t),"pending"===E.state()||eb(B[w]&&B[w].then)))return E.then();for(;w--;)n(B[w],J(w),E.reject);return E.promise()}});var ca=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;A.Deferred.exceptionHook=function(f,t){a.console&& -a.console.warn&&f&&ca.test(f.name)&&a.console.warn("jQuery.Deferred exception: "+f.message,f.stack,t)};A.readyException=function(f){a.setTimeout(function(){throw f;})};var la=A.Deferred();A.fn.ready=function(f){return la.then(f).catch(function(t){A.readyException(t)}),this};A.extend({isReady:!1,readyWait:1,ready:function(f){(!0===f?!--A.readyWait:!A.isReady)&&(A.isReady=!0,!0!==f&&0<--A.readyWait||la.resolveWith(Ya,[A]))}});A.ready.then=la.then;"complete"===Ya.readyState||"loading"!==Ya.readyState&& +a.console.warn&&f&&ca.test(f.name)&&a.console.warn("jQuery.Deferred exception: "+f.message,f.stack,t)};A.readyException=function(f){a.setTimeout(function(){throw f;})};var ka=A.Deferred();A.fn.ready=function(f){return ka.then(f).catch(function(t){A.readyException(t)}),this};A.extend({isReady:!1,readyWait:1,ready:function(f){(!0===f?!--A.readyWait:!A.isReady)&&(A.isReady=!0,!0!==f&&0<--A.readyWait||ka.resolveWith(Ya,[A]))}});A.ready.then=ka.then;"complete"===Ya.readyState||"loading"!==Ya.readyState&& !Ya.documentElement.doScroll?a.setTimeout(A.ready):(Ya.addEventListener("DOMContentLoaded",r),a.addEventListener("load",r));var xa=function(f,t,w,y,B,E,J){var O=0,M=f.length,W=null==w;if("object"===b(w))for(O in B=!0,w)xa(f,t,O,w[O],!0,E,J);else if(void 0!==y&&(B=!0,eb(y)||(J=!0),W&&(J?(t.call(f,y),t=null):(W=t,t=function(Z,R,oa){return W.call(A(Z),oa)})),t))for(;Oy;y++)B[f+Ra[y]+t]=w[y]||w[y-2]||w[0];return B}};"margin"!==f&&(A.cssHooks[f+t].set=Ja)});A.fn.extend({css:function(f,t){return xa(this,function(w,y,B){var E,J={},O=0;if(Array.isArray(y)){B=Vd(w);for(E=y.length;O=(wa.devicePixelRatio||1)?"translate("+q+"px, "+Z+"px)":"translate3d("+q+"px, "+Z+"px, 0)",bb)):Object.assign({},t,((z={})[ta]=B?Z+"px":"",z[oa]=R?q+"px":"",z.transform="",z))}function mb(q){return q.replace(/left|right|bottom|top/g,function(z){return Hd[z]})}function Xa(q){return q.replace(/start|end/g,function(z){return Xe[z]})}function Lb(q){q=n(q);return{scrollLeft:q.pageXOffset,scrollTop:q.pageYOffset}}function Fb(q){return I(T(q)).left+Lb(q).scrollLeft} -function Ja(q){q=U(q);return/auto|scroll|overlay|hidden/.test(q.overflow+q.overflowY+q.overflowX)}function La(q,z){void 0===z&&(z=[]);var f,t=function B(y){return 0<=["html","body","#document"].indexOf(g(y))?y.ownerDocument.body:u(y)&&Ja(y)?y:B(Y(y))}(q);q=t===(null==(f=q.ownerDocument)?void 0:f.body);f=n(t);t=q?[f].concat(f.visualViewport||[],Ja(t)?t:[]):t;z=z.concat(t);return q?z:z.concat(La(Y(t)))}function ka(q){return Object.assign({},q,{left:q.x,top:q.y,right:q.x+q.width,bottom:q.y+q.height})} -function Ba(q,z,f){var t,w,y,B,E,J,O;if("viewport"===z){z=n(q);var M=T(q);z=z.visualViewport;var W=M.clientWidth;M=M.clientHeight;var Z=t=0;z&&(W=z.width,M=z.height,((w=K())||!w&&"fixed"===f)&&(t=z.offsetLeft,Z=z.offsetTop));q={width:W,height:M,x:t+Fb(q),y:Z};f=ka(q)}else f=r(z)?((W=I(z,!1,"fixed"===f)).top=W.top+z.clientTop,W.left+=z.clientLeft,W.bottom=W.top+z.clientHeight,W.right=W.left+z.clientWidth,W.width=z.clientWidth,W.height=z.clientHeight,W.x=W.left,W.y=W.top,W):ka((M=T(q),Z=T(M),w=Lb(M), +function Ja(q){q=U(q);return/auto|scroll|overlay|hidden/.test(q.overflow+q.overflowY+q.overflowX)}function La(q,z){void 0===z&&(z=[]);var f,t=function B(y){return 0<=["html","body","#document"].indexOf(g(y))?y.ownerDocument.body:u(y)&&Ja(y)?y:B(Y(y))}(q);q=t===(null==(f=q.ownerDocument)?void 0:f.body);f=n(t);t=q?[f].concat(f.visualViewport||[],Ja(t)?t:[]):t;z=z.concat(t);return q?z:z.concat(La(Y(t)))}function la(q){return Object.assign({},q,{left:q.x,top:q.y,right:q.x+q.width,bottom:q.y+q.height})} +function Ba(q,z,f){var t,w,y,B,E,J,O;if("viewport"===z){z=n(q);var M=T(q);z=z.visualViewport;var W=M.clientWidth;M=M.clientHeight;var Z=t=0;z&&(W=z.width,M=z.height,((w=K())||!w&&"fixed"===f)&&(t=z.offsetLeft,Z=z.offsetTop));q={width:W,height:M,x:t+Fb(q),y:Z};f=la(q)}else f=r(z)?((W=I(z,!1,"fixed"===f)).top=W.top+z.clientTop,W.left+=z.clientLeft,W.bottom=W.top+z.clientHeight,W.right=W.left+z.clientWidth,W.width=z.clientWidth,W.height=z.clientHeight,W.x=W.left,W.y=W.top,W):la((M=T(q),Z=T(M),w=Lb(M), y=null==(t=M.ownerDocument)?void 0:t.body,B=Ea(Z.scrollWidth,Z.clientWidth,y?y.scrollWidth:0,y?y.clientWidth:0),E=Ea(Z.scrollHeight,Z.clientHeight,y?y.scrollHeight:0,y?y.clientHeight:0),J=-w.scrollLeft+Fb(M),O=-w.scrollTop,"rtl"===U(y||Z).direction&&(J+=Ea(Z.clientWidth,y?y.clientWidth:0)-B),{width:B,height:E,x:J,y:O}));return f}function ya(q){var z=q.reference,f=q.element,t=(q=q.placement)?x(q):null;q=q?Fa(q):null;var w=z.x+z.width/2-f.width/2;var y=z.y+z.height/2-f.height/2;switch(t){case "top":w= {x:w,y:z.y-f.height};break;case "bottom":w={x:w,y:z.y+z.height};break;case "right":w={x:z.x+z.width,y};break;case "left":w={x:z.x-f.width,y};break;default:w={x:z.x,y:z.y}}t=t?ra(t):null;if(null!=t)switch(y="y"===t?"height":"width",q){case "start":w[t]-=z[y]/2-f[y]/2;break;case "end":w[t]+=z[y]/2-f[y]/2}return w}function ha(q,z){void 0===z&&(z={});var f,t,w,y,B,E,J=z;z=J.placement;z=void 0===z?q.placement:z;var O=J.strategy,M=void 0===O?q.strategy:O;O=J.boundary;var W=void 0===O?"clippingParents": O,Z=J.rootBoundary;O=J.elementContext;O=void 0===O?"popper":O;var R=J.altBoundary;J=J.padding;J=void 0===J?0:J;J=Na("number"!=typeof J?J:V(J,gb));var oa=q.rects.popper;R=q.elements[void 0!==R&&R?"popper"===O?"reference":"popper":O];R=(f=r(R)?R:R.contextElement||T(q.elements.popper),B=(y=[].concat("clippingParents"===W?(t=La(Y(f)),r(w=0<=["absolute","fixed"].indexOf(U(f).position)&&u(f)?ja(f):f)?t.filter(function(Aa){return r(Aa)&&L(Aa,w)&&"body"!==g(Aa)}):[]):[].concat(W),[void 0===Z?"viewport":Z]))[0], -(E=y.reduce(function(Aa,Wa){Wa=Ba(f,Wa,M);return Aa.top=Ea(Wa.top,Aa.top),Aa.right=Ka(Wa.right,Aa.right),Aa.bottom=Ka(Wa.bottom,Aa.bottom),Aa.left=Ea(Wa.left,Aa.left),Aa},Ba(f,B,M))).width=E.right-E.left,E.height=E.bottom-E.top,E.x=E.left,E.y=E.top,E);t=I(q.elements.reference);y=ya({reference:t,element:oa,strategy:"absolute",placement:z});y=ka(Object.assign({},oa,y));t="popper"===O?y:t;var ta={top:R.top-t.top+J.top,bottom:t.bottom-R.bottom+J.bottom,left:R.left-t.left+J.left,right:t.right-R.right+ +(E=y.reduce(function(Aa,Wa){Wa=Ba(f,Wa,M);return Aa.top=Ea(Wa.top,Aa.top),Aa.right=Ka(Wa.right,Aa.right),Aa.bottom=Ka(Wa.bottom,Aa.bottom),Aa.left=Ea(Wa.left,Aa.left),Aa},Ba(f,B,M))).width=E.right-E.left,E.height=E.bottom-E.top,E.x=E.left,E.y=E.top,E);t=I(q.elements.reference);y=ya({reference:t,element:oa,strategy:"absolute",placement:z});y=la(Object.assign({},oa,y));t="popper"===O?y:t;var ta={top:R.top-t.top+J.top,bottom:t.bottom-R.bottom+J.bottom,left:R.left-t.left+J.left,right:t.right-R.right+ J.right};q=q.modifiersData.offset;if("popper"===O&&q){var wa=q[z];Object.keys(ta).forEach(function(Aa){var Wa=0<=["right","bottom"].indexOf(Aa)?1:-1,Ua=0<=["top","bottom"].indexOf(Aa)?"y":"x";ta[Aa]+=wa[Ua]*Wa})}return ta}function Oa(q,z,f){return void 0===f&&(f={x:0,y:0}),{top:q.top-z.height-f.y,right:q.right-z.width+f.x,bottom:q.bottom-z.height+f.y,left:q.left-z.width-f.x}}function pa(q){return["top","right","bottom","left"].some(function(z){return 0<=q[z]})}function Ta(){for(var q=arguments.length, z=Array(q),f=0;f=q||(q/=this._deltaX,this._deltaX=0,q&&Ib(0this._start(q)),ua.on(this._element,"pointerup.bs.swipe",q=>this._end(q)),this._element.classList.add("pointer-event")):(ua.on(this._element,"touchstart.bs.swipe", q=>this._start(q)),ua.on(this._element,"touchmove.bs.swipe",q=>this._move(q)),ua.on(this._element,"touchend.bs.swipe",q=>this._end(q)))}_eventIsPointerPenTouch(q){return this._supportPointerEvents&&("pen"===q.pointerType||"touch"===q.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||0this.nextWhenVisible(),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?ua.one(this._element,"slid.bs.carousel",()=>this.cycle()):this.cycle())}to(q){let z=this._getItems();if(!(q>z.length-1||0>q)){if(this._isSliding)return void ua.one(this._element,"slid.bs.carousel",()=>this.to(q));var f=this._getItemIndex(this._getActive()); f!==q&&this._slide(q>f?"next":"prev",z[q])}}dispose(){this._swipeHelper&&this._swipeHelper.dispose();super.dispose()}_configAfterMerge(q){return q.defaultInterval=q.interval,q}_addEventListeners(){this._config.keyboard&&ua.on(this._element,"keydown.bs.carousel",q=>this._keydown(q));"hover"===this._config.pause&&(ua.on(this._element,"mouseenter.bs.carousel",()=>this.pause()),ua.on(this._element,"mouseleave.bs.carousel",()=>this._maybeEnableCycle()));this._config.touch&&fa.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(let q of va.find(".carousel-item img", this._element))ua.on(q,"dragstart.bs.carousel",z=>z.preventDefault());this._swipeHelper=new fa(this._element,{leftCallback:()=>this._slide(this._directionToOrder("left")),rightCallback:()=>this._slide(this._directionToOrder("right")),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout(()=>this._maybeEnableCycle(),500+this._config.interval))}})}_keydown(q){if(!/input|textarea/i.test(q.target.tagName)){var z=F[q.key]; z&&(q.preventDefault(),this._slide(this._directionToOrder(z)))}}_getItemIndex(q){return this._getItems().indexOf(q)}_setActiveIndicatorElement(q){if(this._indicatorsElement){var z=va.findOne(".active",this._indicatorsElement);z.classList.remove("active");z.removeAttribute("aria-current");(q=va.findOne(`[data-bs-slide-to="${q}"]`,this._indicatorsElement))&&(q.classList.add("active"),q.setAttribute("aria-current","true"))}}_updateInterval(){var q=this._activeElement||this._getActive();q&&(q=Number.parseInt(q.getAttribute("data-bs-interval"), 10),this._config.interval=q||this._config.defaultInterval)}_slide(q,z=null){if(!this._isSliding){var f=this._getActive(),t="next"===q,w=z||ec(this._getItems(),f,t,this._config.wrap);if(w!==f){var y=this._getItemIndex(w),B=O=>ua.trigger(this._element,O,{relatedTarget:w,direction:this._orderToDirection(q),from:this._getItemIndex(f),to:y});if(!B("slide.bs.carousel").defaultPrevented&&f&&w){z=!!this._interval;this.pause();this._isSliding=!0;this._setActiveIndicatorElement(y);this._activeElement=w;var E= t?"carousel-item-start":"carousel-item-end",J=t?"carousel-item-next":"carousel-item-prev";w.classList.add(J);w.offsetHeight;f.classList.add(E);w.classList.add(E);this._queueCallback(()=>{w.classList.remove(E,J);w.classList.add("active");f.classList.remove("active",J,E);this._isSliding=!1;B("slid.bs.carousel")},f,this._isAnimated());z&&this.cycle()}}}}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return va.findOne(".active.carousel-item",this._element)}_getItems(){return va.find(".carousel-item", -this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(q){return"rtl"===document.documentElement.dir?"left"===q?"prev":"next":"left"===q?"next":"prev"}_orderToDirection(q){return"rtl"===document.documentElement.dir?"prev"===q?"left":"right":"prev"===q?"right":"left"}static jQueryInterface(q){return this.each(function(){let z=la.getOrCreateInstance(this,q);if("number"!=typeof q){if("string"==typeof q){if(void 0===z[q]||q.startsWith("_")|| +this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(q){return"rtl"===document.documentElement.dir?"left"===q?"prev":"next":"left"===q?"next":"prev"}_orderToDirection(q){return"rtl"===document.documentElement.dir?"prev"===q?"left":"right":"prev"===q?"right":"left"}static jQueryInterface(q){return this.each(function(){let z=ka.getOrCreateInstance(this,q);if("number"!=typeof q){if("string"==typeof q){if(void 0===z[q]||q.startsWith("_")|| "constructor"===q)throw TypeError(`No method named "${q}"`);z[q]()}}else z.to(q)})}constructor(q,z){super(q,z);this._activeElement=this._interval=null;this._isSliding=!1;this._swipeHelper=this.touchTimeout=null;this._indicatorsElement=va.findOne(".carousel-indicators",this._element);this._addEventListeners();"carousel"===this._config.ride&&this.cycle()}}ua.on(document,"click.bs.carousel.data-api","[data-bs-slide], [data-bs-slide-to]",function(q){var z=va.getElementFromSelector(this);if(z&&z.classList.contains("carousel"))return q.preventDefault(), -q=la.getOrCreateInstance(z),z=this.getAttribute("data-bs-slide-to"),z?q.to(z):"next"===tc.getDataAttribute(this,"slide")?q.next():q.prev(),void q._maybeEnableCycle()});ua.on(window,"load.bs.carousel.data-api",()=>{for(let q of va.find('[data-bs-ride="carousel"]'))la.getOrCreateInstance(q)});Rb(la);let xa={parent:null,toggle:!0},za={parent:"(null|element)",toggle:"boolean"};class cb extends Xb{static get Default(){return xa}static get DefaultType(){return za}static get NAME(){return"collapse"}toggle(){this._isShown()? +q=ka.getOrCreateInstance(z),z=this.getAttribute("data-bs-slide-to"),z?q.to(z):"next"===tc.getDataAttribute(this,"slide")?q.next():q.prev(),void q._maybeEnableCycle()});ua.on(window,"load.bs.carousel.data-api",()=>{for(let q of va.find('[data-bs-ride="carousel"]'))ka.getOrCreateInstance(q)});Rb(ka);let xa={parent:null,toggle:!0},za={parent:"(null|element)",toggle:"boolean"};class cb extends Xb{static get Default(){return xa}static get DefaultType(){return za}static get NAME(){return"collapse"}toggle(){this._isShown()? this.hide():this.show()}show(){if(!this._isTransitioning&&!this._isShown()){var q=[];if(!(this._config.parent&&(q=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter(f=>f!==this._element).map(f=>cb.getOrCreateInstance(f,{toggle:!1}))),q.length&&q[0]._isTransitioning||ua.trigger(this._element,"show.bs.collapse").defaultPrevented)){for(let f of q)f.hide();var z=this._getDimension();this._element.classList.remove("collapse");this._element.classList.add("collapsing");this._element.style[z]= 0;this._addAriaAndCollapsedClass(this._triggerArray,!0);this._isTransitioning=!0;q=`scroll${z[0].toUpperCase()+z.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1;this._element.classList.remove("collapsing");this._element.classList.add("collapse","show");this._element.style[z]="";ua.trigger(this._element,"shown.bs.collapse")},this._element,!0);this._element.style[z]=`${this._element[q]}px`}}}hide(){if(!this._isTransitioning&&this._isShown()&&!ua.trigger(this._element,"hide.bs.collapse").defaultPrevented){var q= this._getDimension();for(let z of(this._element.style[q]=`${this._element.getBoundingClientRect()[q]}px`,hb(this._element),this._element.classList.add("collapsing"),this._element.classList.remove("collapse","show"),this._triggerArray)){let f=va.getElementFromSelector(z);f&&!this._isShown(f)&&this._addAriaAndCollapsedClass([z],!1)}this._isTransitioning=!0;this._element.style[q]="";this._queueCallback(()=>{this._isTransitioning=!1;this._element.classList.remove("collapsing");this._element.classList.add("collapse"); @@ -1019,7 +1019,7 @@ Rb(Pc);let hf={animation:"boolean",autohide:"boolean",delay:"number"},we={animat {this._element.classList.remove("showing");ua.trigger(this._element,"shown.bs.toast");this._maybeScheduleHide()},this._element,this._config.animation))}hide(){this.isShown()&&(ua.trigger(this._element,"hide.bs.toast").defaultPrevented||(this._element.classList.add("showing"),this._queueCallback(()=>{this._element.classList.add("hide");this._element.classList.remove("showing","show");ua.trigger(this._element,"hidden.bs.toast")},this._element,this._config.animation)))}dispose(){this._clearTimeout(); this.isShown()&&this._element.classList.remove("show");super.dispose()}isShown(){return this._element.classList.contains("show")}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout(()=>{this.hide()},this._config.delay)))}_onInteraction(q,z){switch(q.type){case "mouseover":case "mouseout":this._hasMouseInteraction=z;break;case "focusin":case "focusout":this._hasKeyboardInteraction=z}if(z)return void this._clearTimeout();q= q.relatedTarget;this._element===q||this._element.contains(q)||this._maybeScheduleHide()}_setListeners(){ua.on(this._element,"mouseover.bs.toast",q=>this._onInteraction(q,!0));ua.on(this._element,"mouseout.bs.toast",q=>this._onInteraction(q,!1));ua.on(this._element,"focusin.bs.toast",q=>this._onInteraction(q,!0));ua.on(this._element,"focusout.bs.toast",q=>this._onInteraction(q,!1))}_clearTimeout(){clearTimeout(this._timeout);this._timeout=null}static jQueryInterface(q){return this.each(function(){let z= -be.getOrCreateInstance(this,q);if("string"==typeof q){if(void 0===z[q])throw TypeError(`No method named "${q}"`);z[q](this)}})}constructor(q,z){super(q,z);this._timeout=null;this._hasKeyboardInteraction=this._hasMouseInteraction=!1;this._setListeners()}}return fc(be),Rb(be),{Alert:uc,Button:D,Carousel:la,Collapse:cb,Dropdown:Lc,Modal:ud,Offcanvas:Gc,Popover:Ed,ScrollSpy:ae,Tab:Pc,Toast:be,Tooltip:vd}}();(function(){for(var a=0,c=["ms","moz","webkit","o"],d=0;dN.getMemoryUsed()).reduce(Ce,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],la=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;Daca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(yc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> -F["set"+da](this.from[N]));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var ca=F.layers;if(N.length!=ca.length)N=!1;else{for(let la=0;laN.getMemoryUsed()).reduce(Ce,0)};this.redo()}function ra(D,P,da){let fa=D.parent,F=D.parent.indexOf(D),N=Ta,ca=fa.layers[fa.indexOf(D)+1],ka=P.layers[da],xa=D instanceof Ma&&D.clip,za=!!xa&&D.getClippingBase(),cb=0,gb=0;if(D instanceof Ma&&!D.clip)for(var Da=F+1;Daca["get"+da]());this.to=N;this.redo()};return fa.prototype=Object.create(yc.prototype),fa.prototype.constructor=fa,fa.prototype.undo=function(){this.layers.forEach((F,N)=> +F["set"+da](this.from[N]));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.redo=function(){this.layers.forEach(F=>F["set"+da](this.to));this.layers.forEach(F=>h(F,D,!P))},fa.prototype.merge=function(F){var N;if(N=F instanceof fa)a:{N=this.layers;var ca=F.layers;if(N.length!=ca.length)N=!1;else{for(let ka=0;kaS.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===S.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let N=F=!0,ca=this.getBounds();fa.clearAll(ca,16777215);for(let la=0;la<=da;la++){let xa=P[la];N||(F=F&&fa.hasAlphaInRect(ca));xa.blendMode===S.LM_MULTIPLY&&("bake"===D?!F&&0S.LM_LAST_CHIBIPAINT)throw Error("Bad layer type during multiply upgrade");F.blendMode===S.LM_MULTIPLY&&(da=fa)}if(-1!==da){fa=new H(this.width,this.height);let N=F=!0,ca=this.getBounds();fa.clearAll(ca,16777215);for(let ka=0;ka<=da;ka++){let xa=P[ka];N||(F=F&&fa.hasAlphaInRect(ca));xa.blendMode===S.LM_MULTIPLY&&("bake"===D?!F&&0F){let N=Tb,ca=vb,la=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,ca=F*P+(1-F)*vb,la=F*da+(1-F)*Rb,this.paintDab(N,ca,la);Tb=N;vb=ca;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(), +this.setLayerLockAlpha=function(D){pa.getLockAlpha()!=D&&C(new Xb(pa,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,da){return!(null===hb||!this.isActiveLayerDrawable())&&(v(),lb.makeEmpty(),la.clearAll(0),Ba.makeEmpty(),Tb=D,vb=P,Rb=da,Hc=!0,Oa[hb.brushMode].beginStroke(),this.paintDab(D,P,da),!0)};this.continueStroke=function(D,P,da){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,ca=vb,ka=Rb;fa=(F-.001)/fa;for(F=fa;1>=F;F+=fa)N=F*D+(1-F)*Tb,ca=F*P+(1-F)*vb,ka=F*da+(1-F)*Rb,this.paintDab(N,ca,ka);Tb=N;vb=ca;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(), Nb.getAsPNGBuffer(D)};this.isSimpleDrawing=function(){return 1==mb.layers.length&&mb.layers[0]instanceof Ma&&!mb.layers[0].mask&&100==mb.layers[0].getEffectiveAlpha()};K.prototype=Object.create(yc.prototype);K.prototype.constructor=K;I.prototype=Object.create(yc.prototype);I.prototype.constructor=I;G.prototype=Object.create(yc.prototype);G.prototype.constructor=G;L.prototype=Object.create(yc.prototype);L.prototype.constructor=L;U.prototype=Object.create(yc.prototype);U.prototype.constructor=U;T.prototype= Object.create(yc.prototype);T.prototype.constructor=T;Y.prototype=Object.create(yc.prototype);Y.prototype.constructor=Y;ea.prototype=Object.create(yc.prototype);ea.prototype.constructor=ea;ja.prototype=Object.create(yc.prototype);ja.prototype.constructor=ja;ra.prototype=Object.create(yc.prototype);ra.prototype.constructor=ra;let Qc=Na("alpha",!0),Rc=Na("blendMode",!0),A=Na("visible",!0),ua=Na("clip",!0),tc=Na("maskVisible",!0),Mc=Na("name",!1),Xb=Na("lockAlpha",!1),Zc=Na("maskLinked",!1);V.prototype= Object.create(yc.prototype);V.prototype.constructor=V;class va extends yc{undo(){let D=[];this.dstRect.isEmpty()||D.push(this.dstRect);this.erasesSourceRect&&(D.push(this.srcRect),D=Ha.union(D));this.movingLayers.forEach(P=>{this.hasFullUndo?D.forEach(da=>{P.moveImage&&P.layer.image.copyBitmapRect(P.imageUndo,da.left,da.top,da);P.moveMask&&P.layer.mask.copyBitmapRect(P.maskUndo,da.left,da.top,da)}):(P.moveImage&&P.imageRect.forEach((da,fa)=>{P.layer.image.copyBitmapRect(da,fa.left,fa.top,da.getBounds())}), @@ -122,16 +122,16 @@ this.movingImage,moveMask:null!==this.layer.mask&&this.movingMask,imageRect:new this.movingLayers[P];da.moveMask&&D.union(da.layer.mask.getValueBounds(this.srcRect,255));da.moveImage&&D.union(da.layer.image.getNonTransparentBounds(this.srcRect))}}else for(this.srcRect=this.fromSelection.clone(),P=0;P{if(D.moveImage){var P=Yc(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=Yc(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=Yc(ha.width,ha.height),this.composeCanvasContext=this.composeCanvas.getContext("2d",{willReadFrequently:!0}),nf(this.composeCanvasContext,"smooth"==this.interpolation),this.junk=this.composeCanvasContext.getImageData(0,0,1,1))}redo(){this.buildFullUndo();var D=this.dstRect.clone();let P=this.srcRect.toPoints();this.affineTransform.transformPoints(P);this.dstRect.set(Ha.createBoundingBox(P).roundContain().clipTo(ha.getBounds())); -let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ca=>{if(fa.forEach(la=>{ca.moveImage&&ca.layer.image.clearRect(la,16777215);ca.moveMask&&(this.movingWholeLayer?ca.layer.mask.clearRect(la,255):ca.layer.mask.clearRect(la,0))}),!this.dstRect.isEmpty()){if(ca.moveImage){let la= -ca.imageUndo.getImageData();da.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(ca.imageSourceCanvas,this.srcRect.left, -this.srcRect.top);this.composeCanvasContext.restore();ca.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()))}ca.moveMask&&(da.forEach(la=>{this.composeCanvasContext.putImageData(ca.layer.mask.getImageData(la.left,la.top,la.getWidth(),la.getHeight()),la.left,la.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle= +let da=Ha.subtract(this.dstRect,this.srcRect),fa=Ha.subtract(D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),this.dstRect),F=this.srcRect.getIntersection(this.dstRect),N=Ha.subtract(D,[this.dstRect,this.srcRect]);D=this.srcRect.getUnion(this.dstRect).getUnion(D);(this.movingLayers.forEach(ca=>{if(fa.forEach(ka=>{ca.moveImage&&ca.layer.image.clearRect(ka,16777215);ca.moveMask&&(this.movingWholeLayer?ca.layer.mask.clearRect(ka,255):ca.layer.mask.clearRect(ka,0))}),!this.dstRect.isEmpty()){if(ca.moveImage){let ka= +ca.imageUndo.getImageData();da.forEach(xa=>{this.composeCanvasContext.putImageData(ka,0,0,xa.left,xa.top,xa.getWidth(),xa.getHeight())});this.composeCanvasContext.clearRect(F.left,F.top,F.getWidth(),F.getHeight());this.composeCanvasContext.save();this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]);this.composeCanvasContext.drawImage(ca.imageSourceCanvas,this.srcRect.left, +this.srcRect.top);this.composeCanvasContext.restore();ca.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()))}ca.moveMask&&(da.forEach(ka=>{this.composeCanvasContext.putImageData(ca.layer.mask.getImageData(ka.left,ka.top,ka.getWidth(),ka.getHeight()),ka.left,ka.top)}),this.movingWholeLayer?this.composeCanvasContext.fillStyle= "#FFF":this.composeCanvasContext.fillStyle="#000",this.composeCanvasContext.fillRect(F.left,F.top,F.getWidth(),F.getHeight()),this.composeCanvasContext.save(),this.composeCanvasContext.setTransform(this.affineTransform.m[0],this.affineTransform.m[1],this.affineTransform.m[2],this.affineTransform.m[3],this.affineTransform.m[4],this.affineTransform.m[5]),this.composeCanvasContext.drawImage(ca.maskSourceCanvas,this.srcRect.left,this.srcRect.top),this.composeCanvasContext.restore(),ca.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(la=>{ca.moveImage&&ca.layer.image.copyBitmapRect(ca.imageUndo,la.left,la.top,la);ca.moveMask&&ca.layer.mask.copyBitmapRect(ca.maskUndo,la.left,la.top,la)})}),m(this.movingLayers.map(ca=>ca.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(ka=>{ca.moveImage&&ca.layer.image.copyBitmapRect(ca.imageUndo,ka.left,ka.top,ka);ca.moveMask&&ca.layer.mask.copyBitmapRect(ca.maskUndo,ka.left,ka.top,ka)})}),m(this.movingLayers.map(ca=>ca.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&&nf(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+=og(this.composeCanvas),D+=this.movingLayers.map(da=> og(da.imageSourceCanvas)).reduce(Ce,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 uc extends va{redo(){var D=this.dstRect.clone();let P,da,fa=D.clone(),F=null;(this.buildFullUndo(),this.dstRect.set(this.srcRect), this.dstRect.translate(this.offsetX,this.offsetY),P=this.dstRect.clone(),this.dstRect.clipTo(ha.getBounds()),this.erasesSourceRect?(F=D.isEmpty()?this.srcRect:this.srcRect.getIntersection(D),fa.union(F),da=D.subtract(this.srcRect)):da=[D],this.movingLayers.forEach(N=>{F&&(N.moveImage&&N.layer.image.clearRect(F,16777215),N.moveMask&&N.layer.mask.clearRect(F,this.movingWholeLayer?255:0));da.forEach(function(ca){N.moveImage&&N.layer.image.copyBitmapRect(N.imageUndo,ca.left,ca.top,ca);N.moveMask&&N.layer.mask.copyBitmapRect(N.maskUndo, ca.left,ca.top,ca)});N.moveImage&&S.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),m(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,da){super(); -this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(yc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(yc.prototype);qa.prototype.constructor=qa;Oa=[Md,xh,yh,zh,ee,Ah,Bh,Ch].map(D=>new D(ka,Ba));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 Nd(a){for(var c=a.length;0<=--c;)a[c]=0}function of(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; +this.offsetX=D;this.offsetY=P;this.erasesSourceRect=!da}}Fa.prototype=Object.create(yc.prototype);Fa.prototype.constructor=Fa;qa.prototype=Object.create(yc.prototype);qa.prototype.constructor=qa;Oa=[Md,xh,yh,zh,ee,Ah,Bh,Ch].map(D=>new D(la,Ba));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 Nd(a){for(var c=a.length;0<=--c;)a[c]=0}function of(a,c,d,b,k){this.static_tree=a;this.extra_bits=c; this.extra_base=d;this.elems=b;this.max_length=k;this.has_stree=a&&a.length}function pf(a,c){this.dyn_tree=a;this.max_code=0;this.stat_desc=c}function pg(a){return 256>a?fe[a]:fe[256+(a>>>7)]}function ge(a,c){a.pending_buf[a.pending++]=255&c;a.pending_buf[a.pending++]=c>>>8&255}function Dc(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 rg(a,c,d){var b,k=Array(16),p=0;for(b=1;15>=b;b++)k[b]=p=p+d[b-1]<<1;for(d=0;d<=c;d++)b=a[2*d+1],0!==b&&(a[2*d]=qg(k[b]++,b))}function sg(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 tg(a){8za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(la=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Lg;let cb=T(N),gb=T(ca),Da=T(la),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; -za.x3=jb.x;za.y3=jb.y;let Vb=Array(100),kc=Array(100);za.compute(Vb,kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(za=1;100>za;za++)ha.lineTo(Vb[za],kc[za]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Da.x,~~Da.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,ca,la){return!!this.capture||(X(Sb).isPressed("space")||(0!=ca||this.transient&&!N.altKey)&&2!=ca?void(this.transient&&va.pop()):(F=ca,this.capture= -!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag=function(N){if(this.capture)return N=L({x:rb,y:hb}),Ia.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ia.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,ca,la){if(this.capture&&ca==F)return F=-1,this.capture=!1,x("default"),this.transient&&va.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function m(){var F,N,ca,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"),va.pop(),!0};this.mouseDown=function(xa,za,cb){return!!this.capture||(1==za||X(Sb).isPressed("space")&&0==za||!this.transient&&0==za?(this.capture=!0,la=za,F=xa.pageX,N=xa.pageY,ca=Ja.getOffset(),x("grabbing"),!0):void(this.transient&&va.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ja.setOffset(ca.x+xa.pageX-F,ca.y+xa.pageY-N),!0};this.mouseUp=function(xa,za,cb){if(this.capture&&za==la)return la=-1,this.capture=!1,this.transient&&!X(Sb).isPressed("space")&& -(x("default"),va.pop()),!0};this.enter=function(){x("grab")}}function l(){}function g(){var F,N=new Ha(0,0,0,0),ca=-1;this.mouseDown=function(la,xa,za){if(!this.capture&&0==xa&&!la.altKey&&!X(Sb).isPressed("space"))return la=U({x:rb,y:hb}),ca=xa,N.makeEmpty(),F=la,Ja.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(la){if(!this.capture)return!1;var xa=U({x:rb,y:hb});la=la.shiftKey;var za=~~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+za:xa.x)+ -1):(N.left=la?F.x-za:xa.x,N.right=F.x+1),xa.y>=F.y?(N.top=F.y,N.bottom=(la?F.y+za:xa.y)+1):(N.top=la?F.y-za:xa.y,N.bottom=F.y+1),Ja.repaintAll(),!0};this.mouseUp=function(la,xa,za){if(this.capture&&xa==ca)return Ia.rectangleSelection(N),N.makeEmpty(),Ja.repaintAll(),this.capture=!1,ca=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ja(ha,N))}}function n(){var F,N,ca=!1;this.mouseDown=function(la,xa,za){if(!this.capture&&0==xa&&!X(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=la.altKey, -ca=!0,this.capture=!0,!0};this.mouseDrag=Mg(25,function(la){if(this.capture){la=L({x:rb,y:hb});var xa=la.x-F.x,za=la.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=la.x-(xa-cb),F.y=la.y-(za-gb),!0}});this.mouseUp=function(la,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< +"top":"left"],10)?e-=l:e+=l,v.emitEvent("valueChanged",[e]),c())})}function nc(){this.modes=[]}function Ke(a){function c(){}function d(){}function b(){this.shouldPaintBrushPreview=!1;this.oldPreviewRect=null}function k(){b.call(this);this.smoothMouse={x:0,y:0}}function p(){var F,N;this.mouseDown=function(ca,ka,xa){if(!this.capture&&0==ka&&!ca.altKey&&!X(Sb).isPressed("space")&&K())return this.capture=!0,F=N={x:rb+.5,y:hb+.5},this.eraseBrushPreview(),!0};this.mouseDrag=function(ca){if(this.capture){var ka= +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},ca.shiftKey){var xa=Math.PI/4;ca=Math.round(Math.atan2(N.y-F.y,N.x-F.x)/xa);switch(ca){case 0:case 4:N.y=F.y;break;case 2:case 6:N.x=F.x;break;default:ca*=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(ca),N.y=F.y+xa*Math.sin(ca)}}return ka.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(ka),!0}this.mouseMove.call(this,ca)};this.mouseUp=function(ca,ka,xa){if(this.capture&&0==ka)return ca=L(F),ka=L(N),this.capture=!1,this.drawLine(ca,ka),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 h(){let F=0,N,ca,ka,xa;this.mouseDown=function(za,cb,gb){if(!this.capture&& +0==cb&&!za.altKey&&!X(Sb).isPressed("space")&&K())return za=L({x:rb,y:hb}),F=0,N=ca=ka=xa=za,this.capture=!0,this.eraseBrushPreview(),!0};this.mouseDrag=function(za){if(this.capture&&0===F)return ka=xa=L({x:rb,y:hb}),Ja.repaintAll(),!0;this.mouseMove.call(this,za)};this.mouseUp=function(za,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=ca;let Da=ka,jb=xa;za=new Lg;za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y;za.x3=jb.x; +za.y3=jb.y;cb=Array(500);gb=Array(500);za.compute(cb,gb,500);Ia.beginStroke(cb[0],gb[0],1);for(za=1;500>za;za++)Ia.continueStroke(cb[za],gb[za],1);Ia.endStroke();Ja.repaintAll()}return!0}};this.mouseMove=function(za,cb){if(this.capture)return za=L({x:rb,y:hb}),1==F?ca=za:2==F&&(ka=za),Ja.repaintAll(),!0;b.prototype.mouseMove.call(this,za,cb)};this.paint=function(){if(this.capture){var za=new Lg;let cb=T(N),gb=T(ca),Da=T(ka),jb=T(xa);za.x0=cb.x;za.y0=cb.y;za.x1=gb.x;za.y1=gb.y;za.x2=Da.x;za.y2=Da.y; +za.x3=jb.x;za.y3=jb.y;let Vb=Array(100),kc=Array(100);za.compute(Vb,kc,100);ha.beginPath();ha.moveTo(Vb[0],kc[0]);for(za=1;100>za;za++)ha.lineTo(Vb[za],kc[za]);ha.moveTo(~~cb.x,~~cb.y);ha.lineTo(~~gb.x,~~gb.y);ha.moveTo(~~Da.x,~~Da.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,ca,ka){return!!this.capture||(X(Sb).isPressed("space")||(0!=ca||this.transient&&!N.altKey)&&2!=ca?void(this.transient&&va.pop()):(F=ca,this.capture= +!0,x("crosshair"),this.mouseDrag(N),!0))};this.mouseDrag=function(N){if(this.capture)return N=L({x:rb,y:hb}),Ia.isPointWithin(N.x,N.y)&&a.setCurColor(new Bb(Ia.colorPicker(N.x,N.y))),!0};this.mouseUp=function(N,ca,ka){if(this.capture&&ca==F)return F=-1,this.capture=!1,x("default"),this.transient&&va.pop(),!0};this.enter=function(){c.prototype.enter.call(this);F=-1}}function m(){var F,N,ca,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"),va.pop(),!0};this.mouseDown=function(xa,za,cb){return!!this.capture||(1==za||X(Sb).isPressed("space")&&0==za||!this.transient&&0==za?(this.capture=!0,ka=za,F=xa.pageX,N=xa.pageY,ca=Ja.getOffset(),x("grabbing"),!0):void(this.transient&&va.pop()))};this.mouseDrag=function(xa){if(this.capture)return Ja.setOffset(ca.x+xa.pageX-F,ca.y+xa.pageY-N),!0};this.mouseUp=function(xa,za,cb){if(this.capture&&za==ka)return ka=-1,this.capture=!1,this.transient&&!X(Sb).isPressed("space")&& +(x("default"),va.pop()),!0};this.enter=function(){x("grab")}}function l(){}function g(){var F,N=new Ha(0,0,0,0),ca=-1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!ka.altKey&&!X(Sb).isPressed("space"))return ka=U({x:rb,y:hb}),ca=xa,N.makeEmpty(),F=ka,Ja.repaintAll(),this.capture=!0,!0};this.mouseDrag=function(ka){if(!this.capture)return!1;var xa=U({x:rb,y:hb});ka=ka.shiftKey;var za=~~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+za:xa.x)+ +1):(N.left=ka?F.x-za:xa.x,N.right=F.x+1),xa.y>=F.y?(N.top=F.y,N.bottom=(ka?F.y+za:xa.y)+1):(N.top=ka?F.y-za:xa.y,N.bottom=F.y+1),Ja.repaintAll(),!0};this.mouseUp=function(ka,xa,za){if(this.capture&&xa==ca)return Ia.rectangleSelection(N),N.makeEmpty(),Ja.repaintAll(),this.capture=!1,ca=-1,!0};this.paint=function(){N.isEmpty()||(ha.lineWidth=1,ja(ha,N))}}function n(){var F,N,ca=!1;this.mouseDown=function(ka,xa,za){if(!this.capture&&0==xa&&!X(Sb).isPressed("space")&&C())return F=L({x:rb,y:hb}),N=ka.altKey, +ca=!0,this.capture=!0,!0};this.mouseDrag=Mg(25,function(ka){if(this.capture){ka=L({x:rb,y:hb});var xa=ka.x-F.x,za=ka.y-F.y,cb=~~xa,gb=~~za;return(0!=cb||0!=gb)&&(Ia.move(cb,gb,N&&ca),ca=!1),F.x=ka.x-(xa-cb),F.y=ka.y-(za-gb),!0}});this.mouseUp=function(ka,xa,za){if(this.capture&&0==xa)return this.capture=!1,this.transient&&va.pop(),!0}}function r(){function F(Ea,Ka){return{x:(Ea.x+Ka.x)/2,y:(Ea.y+Ka.y)/2}}function N(Ea){return{x:Math.round(Ea.x),y:Math.round(Ea.y)}}function ca(Ea,Ka){for(var Ra=0;Ra< Ea.points.length;Ra++)if(49>=(Ka.x-Ea.points[Ra].x)*(Ka.x-Ea.points[Ra].x)+(Ka.y-Ea.points[Ra].y)*(Ka.y-Ea.points[Ra].y))return 2*Ra;for(Ra=0;Ra=zc&&(pb.scale(zc),49>=(pb.x-nb.x)*(pb.x-nb.x)+(pb.y-nb.y)*(pb.y-nb.y)))return 2*Ra+1}return Ea.containsPoint(Ka)? --3:-2}function la(){var Ea=gb.getTransformed(Db),Ka=ca(Ea,{x:rb,y:hb});switch(Ka){case 0:case 2:case 4:case 6:Ka=~~(Ka/2);let Ra=Ea.points[Ka],nb=Ea.points[(Ka+1)%4];xa(Mb.subtractPoints(Ea.points[(Ka+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Ea.points[(~~(Ka/2)+1)%4],Ea.points[~~(Ka/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Ea){Ea=Math.floor(Math.atan2(-Ea.y,Ea.x)/(Math.PI/ -4)+.5);switch(0>Ea&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,la(),!0};this.mouseDrag=Mg(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); +-3:-2}function ka(){var Ea=gb.getTransformed(Db),Ka=ca(Ea,{x:rb,y:hb});switch(Ka){case 0:case 2:case 4:case 6:Ka=~~(Ka/2);let Ra=Ea.points[Ka],nb=Ea.points[(Ka+1)%4];xa(Mb.subtractPoints(Ea.points[(Ka+3)%4],Ra).normalize().add(Mb.subtractPoints(nb,Ra).normalize()));break;case 1:case 3:case 5:case 7:xa(Mb.subtractPoints(Ea.points[(~~(Ka/2)+1)%4],Ea.points[~~(Ka/2)]).getPerpendicular());break;case -3:x("move");break;default:x("default")}}function xa(Ea){Ea=Math.floor(Math.atan2(-Ea.y,Ea.x)/(Math.PI/ +4)+.5);switch(0>Ea&&(Ea+=4),Ea){default:Ea="ew-resize";break;case 1:Ea="nesw-resize";break;case 2:Ea="ns-resize";break;case 3:Ea="nwse-resize"}x(Ea)}var za,cb,gb,Da,jb,Vb,kc=-1;this.mouseDown=function(Ea,Ka,Ra){if(!this.capture&&0==Ka&&!Ea.altKey&&!X(Sb).isPressed("space"))return kc=ca(gb.getTransformed(Db),{x:rb,y:hb}),jb=L(Da={x:rb,y:hb}),this.capture=!0,ka(),!0};this.mouseDrag=Mg(40,function(Ea){if(this.capture){var Ka={x:rb,y:hb};switch(kc){case -3:Ea=N(L(Ka));var Ra=Mb.subtractPoints(Ea,jb); Ka=Ra.getTruncated();Ra=Ra.subtract(Ka);var nb=new Kb;nb.translate(Ka.x,Ka.y);za.preMultiply(nb);jb=Mb.subtractPoints(Ea,Ra);break;case -2:nb=Math.PI/4;Ra=gb.getCenter();var pb=T(Ra),vc=Math.atan2(Ka.y-pb.y,Ka.x-pb.x)-Math.atan2(Da.y-pb.y,Da.x-pb.x);pb=new Kb;Vb+=vc;Ea=Ea.shiftKey?-za.decompose().rotate+Math.round(Vb/nb)*nb:vc;pb.rotateAroundPoint(Ea,Ra.x,Ra.y);za.preMultiply(pb);Da=Ka;break;case 0:case 2:case 4:case 6:nb=~~(kc/2);Ra=cb.points[nb];pb=za.getInverted().getTransformedPoint(N(L(Ka))); Ka=cb.points[(nb+2)%4];nb=(pb.x-Ka.x)/(Ra.x-Ka.x);Ra=(pb.y-Ka.y)/(Ra.y-Ka.y);if(.001>Math.abs(nb)||.001>Math.abs(Ra)||isNaN(nb)||isNaN(Ra))return!0;Ea.shiftKey&&(Ra=nb=Ea=Math.max(nb,Ra));za.scaleAroundPoint(nb,Ra,Ka.x,Ka.y);break;case 1:case 5:case 3:case 7:Ea=~~(kc/2);pb=F(cb.points[Ea],cb.points[(Ea+1)%4]);Ka=za.getInverted().getTransformedPoint(N(L(Ka)));Ea=F(cb.points[(Ea+2)%4],cb.points[(Ea+3)%4]);pb=Mb.subtractPoints(pb,Ea);Ka=Mb.subtractPoints(Ka,Ea);vc=pb.getLength();Ka=pb.getDotProduct(Ka)/ -vc/vc;if(.001>Math.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||la()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaMath.abs(Ka)||isNaN(Ka))return!0;1==kc||5==kc?(Ra=1,nb=Ka):(Ra=Ka,nb=1);za.scaleAroundPoint(Ra,nb,Ea.x,Ea.y)}return gb=cb.getTransformed(za),Ia.transformAffineAmend(za),Ja.repaintAll(),!0}});this.mouseUp=function(Ea,Ka,Ra){if(this.capture&&0==Ka)return this.capture=!1,kc=-1,!0};this.mouseMove=function(){this.capture||ka()};this.paint=function(){var Ea=gb.getTransformed(Db).points,Ka=Array(2*Ea.length);for(var Ra=0;RaMath.abs(la-1)?F=1:.2>Math.abs(la-2)?F=2:.08>Math.abs(la-.5)&&(F=.5);V(F,N/2,ca/2)}function qa(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure? -1:"touch"===F.pointerType?(0!==F.pressure&&(Hc=!0),Hc)?2*F.pressure:1:2*F.pressure}function mb(){eb||(eb=!0,window.requestAnimationFrame(function(){Ja.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ia.getBounds();Ja.repaintAll()}let Fb,Ja=this,La=document.createElement("div"),ka=document.createElement("div"),Ba=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),pa=Oa.getContext("2d"),Ta=Ng(ha),Ia=a.getArtwork(), +F&&ya.setAttribute("data-cursor",F)}function C(){var F=Ia.getActiveLayer();return F.visible&&F.ancestorsAreVisible()?0!=F.alpha||(a.showLayerNotification(F,ma("Whoops! This layer's opacity is currently 0%"),"opacity"),!1):(a.showLayerNotification(F,ma("Whoops! This layer is currently hidden"),"layer"),!1)}function K(){var F=Ia.getActiveLayer();return F instanceof ob&&!Ia.isEditingMask()?(a.showLayerNotification(F,ma("Whoops! You can't draw on a group"),"layer"),!1):C()}function I(F,N,ca,ka,xa){F.setValues(-xa, +ka,N-ka-xa+ca/4,N+ca-xa-ca/4);F.setBlockIncrement(Math.max(1,~~(.66*ka)));F.setUnitIncrement(Math.max(1,~~(.05*ka)))}function G(){Db.setToIdentity();Db.translate(bc,jc);Db.scale(lb,lb);Db.rotate(Nb);if(null!=uc&&null!=D&&!uc.getValueIsAdjusting()&&!D.getValueIsAdjusting()){var F=ra(new Ha(0,0,Oa.width,Oa.height));I(uc,F.left,F.getWidth(),X(ia)(ya).width(),Ja.getOffset().x);I(D,F.top,F.getHeight(),X(ia)(ya).height(),Ja.getOffset().y)}Ja.repaintAll()}function L(F){return Db.getInverted().getTransformedPoint(F)} +function U(F){F=L(F);return F.x=Math.floor(F.x),F.y=Math.floor(F.y),F}function T(F){return Db.getTransformedPoint(F)}function Y(F){F=T(F);return F.x=Math.round(F.x),F.y=Math.round(F.y),F}function ea(F,N){F.beginPath();F.moveTo(N[0].x,N[0].y);for(var ca=1;caMath.abs(ka-1)?F=1:.2>Math.abs(ka-2)?F=2:.08>Math.abs(ka-.5)&&(F=.5);V(F,N/2,ca/2)}function qa(F){return Rb?P.getPressure():"mouse"===F.pointerType&&0!==F.buttons&&0===F.pressure? +1:"touch"===F.pointerType?(0!==F.pressure&&(Hc=!0),Hc)?2*F.pressure:1:2*F.pressure}function mb(){eb||(eb=!0,window.requestAnimationFrame(function(){Ja.paint()}))}function Xa(F){Va.union(F);mb()}function Lb(){ec=Ia.getBounds();Ja.repaintAll()}let Fb,Ja=this,La=document.createElement("div"),la=document.createElement("div"),Ba=document.createElement("div"),ya=document.createElement("canvas"),ha=ya.getContext("2d"),Oa=document.createElement("canvas"),pa=Oa.getContext("2d"),Ta=Ng(ha),Ia=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,Hc=!1,ec=Ia.getBounds(),Va=new Ha(0,0,0,0),eb=!1,Yb;let Ya,Qc,Rc,A,ua,tc,Mc,Xb,Zc=[],va=new nc,fc,uc=new me(!1),D=new me(!0),P=dd.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 ca=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));return this.smoothMouse.x=(1-ca)*F.x+ca*this.smoothMouse.x,this.smoothMouse.y=(1-ca)*F.y+ca*this.smoothMouse.y,Ia.continueStroke(this.smoothMouse.x, +K()&&(F=L({x:rb,y:hb}),this.eraseBrushPreview(),Ia.beginStroke(F.x,F.y,ca)))return this.capture=!0,this.smoothMouse=F,!0};k.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 ca=Math.min(.999,Math.pow(a.getBrushInfo().smoothing,.3));let ka=1-ca;return this.smoothMouse.x=ka*F.x+ca*this.smoothMouse.x,this.smoothMouse.y=ka*F.y+ca*this.smoothMouse.y,Ia.continueStroke(this.smoothMouse.x, this.smoothMouse.y,N),!0}this.mouseMove(F)};k.prototype.mouseUp=function(F,N,ca){if(this.capture)return 0==N&&(this.capture=!1,Ia.endStroke()),!0};p.prototype=Object.create(b.prototype);p.prototype.constructor=p;p.prototype.drawLine=function(F,N){Ia.beginStroke(F.x,F.y,1);Ia.continueStroke(N.x,N.y,1);Ia.endStroke()};h.prototype=Object.create(b.prototype);h.prototype.constructor=h;e.prototype=Object.create(c.prototype);e.prototype.constructor=e;m.prototype=Object.create(c.prototype);m.prototype.constructor= m;l.prototype=Object.create(c.prototype);l.prototype.constructor=l;l.prototype.mouseDown=function(F,N,ca){if(0==N&&!F.altKey&&!X(Sb).isPressed("space")&&K())return F=L({x:rb,y:hb}),Ia.isPointWithin(F.x,F.y)&&(Ia.floodFill(F.x,F.y),Ja.repaintAll()),!0};g.prototype=Object.create(c.prototype);g.prototype.constructor=g;n.prototype=Object.create(c.prototype);n.prototype.constructor=n;n.prototype.mouseMove=function(F){if(!X(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){Ia.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;nf(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(){Fa(1.41*this.getZoom())}; this.zoomOut=function(){Fa(.7092*this.getZoom())};this.zoom100=function(){Fa(1);Na()};this.resetRotation=function(){var F=ya.width/2,N=ya.height/2,ca=new Kb;ca.rotateAroundPoint(-this.getRotation(),F,N);ca.multiply(Db);this.setOffset(~~ca.getTranslateX(),~~ca.getTranslateY());this.setRotation(0);Ja.emitEvent("canvasRotated90",[0])};let da=!1;this.getElement=function(){return La};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(eb=!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():Ia.fusionLayers().getImageData();pa.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,Ia.width,Ia.height),ha.drawImage(Oa,0,0,Oa.width,Oa.height),ha.restore(),Je(ha,"stroke"),ha.lineWidth=1,Ia.getSelection().isEmpty()||va.peek()instanceof g&&va.peek().capture||(ha.setLineDash([3,2]),ja(ha,Ia.getSelection()),ha.setLineDash([])),Wb)if(N=Ia.getBounds(),2lb.bottom){Oa=k.getLayersRoot().layers[0];Oa={layer:Oa,displayIndex:p.indexOf(Oa),direction:"under"};break}if(pa>=lb.top){Ta=p[Ia];let bc=lb.bottom-lb.top;Oa={layer:Ta,displayIndex:Ia};Ta instanceof ob?pa>=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==qa.layer.parent&&("over"==Oa.direction||"under"==Oa.direction)&&(pa=Oa.layer.parent,Ia=pa.indexOf(Oa.layer),"over"==Oa.direction&&pa.layers[Ia+1]==qa.layer||"under"==Oa.direction&& -pa.layers[Ia-1]==qa.layer||Oa.layer==qa.layer)?null:qa.layer instanceof ob&&(Oa.layer==qa.layer&&"inside"==Oa.direction||Oa.layer.hasAncestor(qa.layer))?null:Oa}(qa.dragX,qa.dragY),qa.dropTarget){var ka=G(qa.dropTarget.displayIndex);switch(qa.dropTarget.direction){case "over":case "under":Xa.appendChild(qa.dropBetweenMarkerElem);La=qa.dropTarget.layer.getDepth()-1;var Ba;if(ka=ka.getBoundingClientRect(),"under"==qa.dropTarget.direction&&qa.dropTarget.layer instanceof ob&&qa.dropTarget.layer.expanded){for(Ba= -qa.dropTarget.displayIndex-1;0<=Ba&&p[Ba].hasAncestor(qa.dropTarget.layer);Ba--);Ba=G(Ba+1).getBoundingClientRect().bottom}else Ba=ka.bottom;La=ka.left-ya.left+(0ea(ha,ya)),Ba=document.createDocumentFragment();X(ia)(Xa).empty();for(let ya=ka.length-1;0<=ya;ya--)Ba.appendChild(ka[ya]);Xa.appendChild(Ba);U()},this.layerChanged=function(ka){let Ba=p.indexOf(ka),ya=X(ia)(G(Ba));0===ya.length||ka instanceof ob&&(ka.expanded!=X(ia)(ya).hasClass("chickenpaint-layer-group-expanded")||ka.visible!=X(ia)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(ea(Ba,ka))},this.setRotation90= -function(ka){if(Lb!=ka)for(Lb=ka,ka=0;kaka.preventDefault(),!0),Xa.className="list-group",Xa.addEventListener("dblclick",function(ka){0===ka.button&&0{3===qa.state&&(Na(),qa.dragY=ka.clientY,U())},800)):qa.state=1,qa.dropTarget=null,qa.layer=ya,qa.layerElem=G(Ba),qa.dragX=ka.clientX,qa.dragY=ka.clientY,Xa.setPointerCapture(ka.pointerId),Xa.addEventListener("pointermove",V),Xa.addEventListener("pointerup",ra)):2==ka.button&&!ha&&(ka.preventDefault(),-1!=L(ka.target)&&(ja(L(ka.target)),ka.preventDefault()))}}}}), +case 1:if(5ea(ha,ya)),Ba=document.createDocumentFragment();X(ia)(Xa).empty();for(let ya=la.length-1;0<=ya;ya--)Ba.appendChild(la[ya]);Xa.appendChild(Ba);U()},this.layerChanged=function(la){let Ba=p.indexOf(la),ya=X(ia)(G(Ba));0===ya.length||la instanceof ob&&(la.expanded!=X(ia)(ya).hasClass("chickenpaint-layer-group-expanded")||la.visible!=X(ia)(ya).hasClass("chickenpaint-layer-visible"))?this.buildLayers():ya.replaceWith(ea(Ba,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===qa.state&&(Na(),qa.dragY=la.clientY,U())},800)):qa.state=1,qa.dropTarget=null,qa.layer=ya,qa.layerElem=G(Ba),qa.dragX=la.clientX,qa.dragY=la.clientY,Xa.setPointerCapture(la.pointerId),Xa.addEventListener("pointermove",V),Xa.addEventListener("pointerup",ra)):2==la.button&&!ha&&(la.preventDefault(),-1!=L(la.target)&&(ja(L(la.target)),la.preventDefault()))}}}}), Xa.setAttribute("touch-action","none"),["ontouchstart","ontouchmove","ontouchend","ontouchcancel"]))Xa.addEventListener(La,Sh);mb.appendChild(Xa)},l=new Ec(0,100,!1,!1,208),g=document.createElement("select"),n=new function(){let G=null,L="",U=document.createElement("input"),T=this;this.hide=function(){G=null;let Y=X(ia)(U).parent();Y&&(X(ia)(U).remove(),Y.text(L))};this.renameAndHide=function(){G&&G.name!=U.value&&a.actionPerformed({action:"CPSetLayerName",layer:G,name:U.value});this.hide()};this.show= function(Y,ea){L=(G=Y).name;U.value=L;(Y=ea.querySelector(".chickenpaint-layer-name"))&&Y.parentNode&&(ea=Y.firstChild)&&ea.nodeType===Node.TEXT_NODE&&(Y.removeChild(ea),Y.appendChild(U));U.select()};U.type="text";U.className="chickenpaint-layer-rename form-control input-sm";U.addEventListener("keydown",function(Y){Y.stopPropagation()});U.addEventListener("keydown",function(Y){"Enter"===Y.key&&T.renameAndHide();Y.stopPropagation()});U.addEventListener("keyup",function(Y){"Escape"===Y.key&&T.hide(); Y.stopPropagation()});U.addEventListener("blur",function(Y){G&&T.renameAndHide()})},r=document.createElement("input"),u=document.createElement("input"),v=!1,x,C=this.setSize,K=this.setWidth,I=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();m.resize()};this.setHeight=function(G){I.call(this,G);m.resize()};this.setRotation90=function(G){m.setRotation90(G)};this.dismissNotification=function(){X(ia)(".chickenpaint-layer[aria-describedby],.chickenpaint-slider[aria-describedby]", @@ -703,7 +703,7 @@ y.isImmediatePropagationStopped=T)}})):void 0===Da.get(f,t)&&A.event.add(f,t,T)} (oa=A.clone(oa,!0,!0),J&&A.merge(E,G(oa,"script")));w.call(f[O],oa,O)}if(J)for(B=E[E.length-1].ownerDocument,A.map(E,V),O=0;OJ;J+=2)"margin"===w&&(W+=A.css(f,w+Ra[J],!0,B)),y?("content"===w&&(M-=A.css(f,"padding"+Ra[J],!0, -B)),"margin"!==w&&(M-=A.css(f,"border"+Ra[J]+"Width",!0,B))):(M+=A.css(f,"padding"+Ra[J],!0,B),"padding"!==w?M+=A.css(f,"border"+Ra[J]+"Width",!0,B):O+=A.css(f,"border"+Ra[J]+"Width",!0,B));return!y&&0<=E&&(M+=Math.max(0,Math.ceil(f["offset"+t[0].toUpperCase()+t.slice(1)]-E-M-O-.5))||0),M+W}function ka(f,t,w){var y=Vd(f),B=(!Va.boxSizingReliable()||w)&&"border-box"===A.css(f,"boxSizing",!1,y),E=B,J=Xa(f,t,y),O="offset"+t[0].toUpperCase()+t.slice(1);if(Dd.test(J)){if(!w)return J;J="auto"}return(!Va.boxSizingReliable()&& +B)),"margin"!==w&&(M-=A.css(f,"border"+Ra[J]+"Width",!0,B))):(M+=A.css(f,"padding"+Ra[J],!0,B),"padding"!==w?M+=A.css(f,"border"+Ra[J]+"Width",!0,B):O+=A.css(f,"border"+Ra[J]+"Width",!0,B));return!y&&0<=E&&(M+=Math.max(0,Math.ceil(f["offset"+t[0].toUpperCase()+t.slice(1)]-E-M-O-.5))||0),M+W}function la(f,t,w){var y=Vd(f),B=(!Va.boxSizingReliable()||w)&&"border-box"===A.css(f,"boxSizing",!1,y),E=B,J=Xa(f,t,y),O="offset"+t[0].toUpperCase()+t.slice(1);if(Dd.test(J)){if(!w)return J;J="auto"}return(!Va.boxSizingReliable()&& B||!Va.reliableTrDimensions()&&p(f,"tr")||"auto"===J||!parseFloat(J)&&"inline"===A.css(f,"display",!1,y))&&f.getClientRects().length&&(B="border-box"===A.css(f,"boxSizing",!1,y),(E=O in f)&&(J=f[O])),(J=parseFloat(J)||0)+La(f,t,w||(B?"border":"content"),E,y,J)+"px"}function Ba(f,t,w,y,B){return new Ba.prototype.init(f,t,w,y,B)}function ya(){return a.setTimeout(function(){qd=void 0}),qd=Date.now()}function ha(f,t){var w,y=0,B={height:f};for(t=t?1:0;4>y;y+=2-t)B["margin"+(w=Ra[y])]=B["padding"+w]=f; return t&&(B.opacity=B.width=f),B}function Oa(f,t,w){for(var y,B=(pa.tweeners[t]||[]).concat(pa.tweeners["*"]),E=0,J=B.length;EZ&&oa)?W:(oa||J.notifyWith(f,[M,1,0]),J.resolveWith(f, [M]),!1)},M=J.promise({elem:f,props:A.extend({},t),opts:A.extend(!0,{specialEasing:{},easing:A.easing._default},w),originalProperties:t,originalOptions:w,startTime:qd||ya(),duration:w.duration,tweens:[],createTween:function(W,Z){W=A.Tween(f,M.opts,W,Z,M.opts.specialEasing[W]||M.opts.easing);return M.tweens.push(W),W},stop:function(W){var Z=0,R=W?M.tweens.length:0;if(y)return this;for(y=!0;Z=W&&(oa!==g&&(wa=void 0,Aa=[Qa]),R.rejectWith(wa,Aa))}};Z?Ua():(A.Deferred.getErrorHook?Ua.error=A.Deferred.getErrorHook():A.Deferred.getStackHook&&(Ua.error=A.Deferred.getStackHook()), a.setTimeout(Ua))}}var W=0;return A.Deferred(function(Z){t[0][3].add(M(0,Z,eb(O)?O:l,Z.notifyWith));t[1][3].add(M(0,Z,eb(E)?E:l));t[2][3].add(M(0,Z,eb(J)?J:g))}).promise()},promise:function(E){return null!=E?A.extend(E,y):y}},B={};return A.each(t,function(E,J){var O=J[2],M=J[5];y[J[1]]=O.add;M&&O.add(function(){w=M},t[3-E][2].disable,t[3-E][3].disable,t[0][2].lock,t[0][3].lock);O.add(J[3].fire);B[J[0]]=function(){return B[J[0]+"With"](this===B?void 0:this,arguments),this};B[J[0]+"With"]=O.fireWith}), y.promise(B),f&&f.call(B,B),B},when:function(f){var t=arguments.length,w=t,y=Array(w),B=kb.call(arguments),E=A.Deferred(),J=function(O){return function(M){y[O]=this;B[O]=1=t&&(n(f,E.done(J(w)).resolve,E.reject,!t),"pending"===E.state()||eb(B[w]&&B[w].then)))return E.then();for(;w--;)n(B[w],J(w),E.reject);return E.promise()}});var ca=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;A.Deferred.exceptionHook=function(f,t){a.console&& -a.console.warn&&f&&ca.test(f.name)&&a.console.warn("jQuery.Deferred exception: "+f.message,f.stack,t)};A.readyException=function(f){a.setTimeout(function(){throw f;})};var la=A.Deferred();A.fn.ready=function(f){return la.then(f).catch(function(t){A.readyException(t)}),this};A.extend({isReady:!1,readyWait:1,ready:function(f){(!0===f?!--A.readyWait:!A.isReady)&&(A.isReady=!0,!0!==f&&0<--A.readyWait||la.resolveWith(Ya,[A]))}});A.ready.then=la.then;"complete"===Ya.readyState||"loading"!==Ya.readyState&& +a.console.warn&&f&&ca.test(f.name)&&a.console.warn("jQuery.Deferred exception: "+f.message,f.stack,t)};A.readyException=function(f){a.setTimeout(function(){throw f;})};var ka=A.Deferred();A.fn.ready=function(f){return ka.then(f).catch(function(t){A.readyException(t)}),this};A.extend({isReady:!1,readyWait:1,ready:function(f){(!0===f?!--A.readyWait:!A.isReady)&&(A.isReady=!0,!0!==f&&0<--A.readyWait||ka.resolveWith(Ya,[A]))}});A.ready.then=ka.then;"complete"===Ya.readyState||"loading"!==Ya.readyState&& !Ya.documentElement.doScroll?a.setTimeout(A.ready):(Ya.addEventListener("DOMContentLoaded",r),a.addEventListener("load",r));var xa=function(f,t,w,y,B,E,J){var O=0,M=f.length,W=null==w;if("object"===b(w))for(O in B=!0,w)xa(f,t,O,w[O],!0,E,J);else if(void 0!==y&&(B=!0,eb(y)||(J=!0),W&&(J?(t.call(f,y),t=null):(W=t,t=function(Z,R,oa){return W.call(A(Z),oa)})),t))for(;Oy;y++)B[f+Ra[y]+t]=w[y]||w[y-2]||w[0];return B}};"margin"!==f&&(A.cssHooks[f+t].set=Ja)});A.fn.extend({css:function(f,t){return xa(this,function(w,y,B){var E,J={},O=0;if(Array.isArray(y)){B=Vd(w);for(E=y.length;O=(wa.devicePixelRatio||1)?"translate("+q+"px, "+Z+"px)":"translate3d("+q+"px, "+Z+"px, 0)",bb)):Object.assign({},t,((z={})[ta]=B?Z+"px":"",z[oa]=R?q+"px":"",z.transform="",z))}function mb(q){return q.replace(/left|right|bottom|top/g,function(z){return Hd[z]})}function Xa(q){return q.replace(/start|end/g,function(z){return Xe[z]})}function Lb(q){q=n(q);return{scrollLeft:q.pageXOffset,scrollTop:q.pageYOffset}}function Fb(q){return I(T(q)).left+Lb(q).scrollLeft} -function Ja(q){q=U(q);return/auto|scroll|overlay|hidden/.test(q.overflow+q.overflowY+q.overflowX)}function La(q,z){void 0===z&&(z=[]);var f,t=function B(y){return 0<=["html","body","#document"].indexOf(g(y))?y.ownerDocument.body:u(y)&&Ja(y)?y:B(Y(y))}(q);q=t===(null==(f=q.ownerDocument)?void 0:f.body);f=n(t);t=q?[f].concat(f.visualViewport||[],Ja(t)?t:[]):t;z=z.concat(t);return q?z:z.concat(La(Y(t)))}function ka(q){return Object.assign({},q,{left:q.x,top:q.y,right:q.x+q.width,bottom:q.y+q.height})} -function Ba(q,z,f){var t,w,y,B,E,J,O;if("viewport"===z){z=n(q);var M=T(q);z=z.visualViewport;var W=M.clientWidth;M=M.clientHeight;var Z=t=0;z&&(W=z.width,M=z.height,((w=K())||!w&&"fixed"===f)&&(t=z.offsetLeft,Z=z.offsetTop));q={width:W,height:M,x:t+Fb(q),y:Z};f=ka(q)}else f=r(z)?((W=I(z,!1,"fixed"===f)).top=W.top+z.clientTop,W.left+=z.clientLeft,W.bottom=W.top+z.clientHeight,W.right=W.left+z.clientWidth,W.width=z.clientWidth,W.height=z.clientHeight,W.x=W.left,W.y=W.top,W):ka((M=T(q),Z=T(M),w=Lb(M), +function Ja(q){q=U(q);return/auto|scroll|overlay|hidden/.test(q.overflow+q.overflowY+q.overflowX)}function La(q,z){void 0===z&&(z=[]);var f,t=function B(y){return 0<=["html","body","#document"].indexOf(g(y))?y.ownerDocument.body:u(y)&&Ja(y)?y:B(Y(y))}(q);q=t===(null==(f=q.ownerDocument)?void 0:f.body);f=n(t);t=q?[f].concat(f.visualViewport||[],Ja(t)?t:[]):t;z=z.concat(t);return q?z:z.concat(La(Y(t)))}function la(q){return Object.assign({},q,{left:q.x,top:q.y,right:q.x+q.width,bottom:q.y+q.height})} +function Ba(q,z,f){var t,w,y,B,E,J,O;if("viewport"===z){z=n(q);var M=T(q);z=z.visualViewport;var W=M.clientWidth;M=M.clientHeight;var Z=t=0;z&&(W=z.width,M=z.height,((w=K())||!w&&"fixed"===f)&&(t=z.offsetLeft,Z=z.offsetTop));q={width:W,height:M,x:t+Fb(q),y:Z};f=la(q)}else f=r(z)?((W=I(z,!1,"fixed"===f)).top=W.top+z.clientTop,W.left+=z.clientLeft,W.bottom=W.top+z.clientHeight,W.right=W.left+z.clientWidth,W.width=z.clientWidth,W.height=z.clientHeight,W.x=W.left,W.y=W.top,W):la((M=T(q),Z=T(M),w=Lb(M), y=null==(t=M.ownerDocument)?void 0:t.body,B=Ea(Z.scrollWidth,Z.clientWidth,y?y.scrollWidth:0,y?y.clientWidth:0),E=Ea(Z.scrollHeight,Z.clientHeight,y?y.scrollHeight:0,y?y.clientHeight:0),J=-w.scrollLeft+Fb(M),O=-w.scrollTop,"rtl"===U(y||Z).direction&&(J+=Ea(Z.clientWidth,y?y.clientWidth:0)-B),{width:B,height:E,x:J,y:O}));return f}function ya(q){var z=q.reference,f=q.element,t=(q=q.placement)?x(q):null;q=q?Fa(q):null;var w=z.x+z.width/2-f.width/2;var y=z.y+z.height/2-f.height/2;switch(t){case "top":w= {x:w,y:z.y-f.height};break;case "bottom":w={x:w,y:z.y+z.height};break;case "right":w={x:z.x+z.width,y};break;case "left":w={x:z.x-f.width,y};break;default:w={x:z.x,y:z.y}}t=t?ra(t):null;if(null!=t)switch(y="y"===t?"height":"width",q){case "start":w[t]-=z[y]/2-f[y]/2;break;case "end":w[t]+=z[y]/2-f[y]/2}return w}function ha(q,z){void 0===z&&(z={});var f,t,w,y,B,E,J=z;z=J.placement;z=void 0===z?q.placement:z;var O=J.strategy,M=void 0===O?q.strategy:O;O=J.boundary;var W=void 0===O?"clippingParents": O,Z=J.rootBoundary;O=J.elementContext;O=void 0===O?"popper":O;var R=J.altBoundary;J=J.padding;J=void 0===J?0:J;J=Na("number"!=typeof J?J:V(J,gb));var oa=q.rects.popper;R=q.elements[void 0!==R&&R?"popper"===O?"reference":"popper":O];R=(f=r(R)?R:R.contextElement||T(q.elements.popper),B=(y=[].concat("clippingParents"===W?(t=La(Y(f)),r(w=0<=["absolute","fixed"].indexOf(U(f).position)&&u(f)?ja(f):f)?t.filter(function(Aa){return r(Aa)&&L(Aa,w)&&"body"!==g(Aa)}):[]):[].concat(W),[void 0===Z?"viewport":Z]))[0], -(E=y.reduce(function(Aa,Wa){Wa=Ba(f,Wa,M);return Aa.top=Ea(Wa.top,Aa.top),Aa.right=Ka(Wa.right,Aa.right),Aa.bottom=Ka(Wa.bottom,Aa.bottom),Aa.left=Ea(Wa.left,Aa.left),Aa},Ba(f,B,M))).width=E.right-E.left,E.height=E.bottom-E.top,E.x=E.left,E.y=E.top,E);t=I(q.elements.reference);y=ya({reference:t,element:oa,strategy:"absolute",placement:z});y=ka(Object.assign({},oa,y));t="popper"===O?y:t;var ta={top:R.top-t.top+J.top,bottom:t.bottom-R.bottom+J.bottom,left:R.left-t.left+J.left,right:t.right-R.right+ +(E=y.reduce(function(Aa,Wa){Wa=Ba(f,Wa,M);return Aa.top=Ea(Wa.top,Aa.top),Aa.right=Ka(Wa.right,Aa.right),Aa.bottom=Ka(Wa.bottom,Aa.bottom),Aa.left=Ea(Wa.left,Aa.left),Aa},Ba(f,B,M))).width=E.right-E.left,E.height=E.bottom-E.top,E.x=E.left,E.y=E.top,E);t=I(q.elements.reference);y=ya({reference:t,element:oa,strategy:"absolute",placement:z});y=la(Object.assign({},oa,y));t="popper"===O?y:t;var ta={top:R.top-t.top+J.top,bottom:t.bottom-R.bottom+J.bottom,left:R.left-t.left+J.left,right:t.right-R.right+ J.right};q=q.modifiersData.offset;if("popper"===O&&q){var wa=q[z];Object.keys(ta).forEach(function(Aa){var Wa=0<=["right","bottom"].indexOf(Aa)?1:-1,Ua=0<=["top","bottom"].indexOf(Aa)?"y":"x";ta[Aa]+=wa[Ua]*Wa})}return ta}function Oa(q,z,f){return void 0===f&&(f={x:0,y:0}),{top:q.top-z.height-f.y,right:q.right-z.width+f.x,bottom:q.bottom-z.height+f.y,left:q.left-z.width-f.x}}function pa(q){return["top","right","bottom","left"].some(function(z){return 0<=q[z]})}function Ta(){for(var q=arguments.length, z=Array(q),f=0;f=q||(q/=this._deltaX,this._deltaX=0,q&&Ib(0this._start(q)),ua.on(this._element,"pointerup.bs.swipe",q=>this._end(q)),this._element.classList.add("pointer-event")):(ua.on(this._element,"touchstart.bs.swipe", q=>this._start(q)),ua.on(this._element,"touchmove.bs.swipe",q=>this._move(q)),ua.on(this._element,"touchend.bs.swipe",q=>this._end(q)))}_eventIsPointerPenTouch(q){return this._supportPointerEvents&&("pen"===q.pointerType||"touch"===q.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||0this.nextWhenVisible(),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?ua.one(this._element,"slid.bs.carousel",()=>this.cycle()):this.cycle())}to(q){let z=this._getItems();if(!(q>z.length-1||0>q)){if(this._isSliding)return void ua.one(this._element,"slid.bs.carousel",()=>this.to(q));var f=this._getItemIndex(this._getActive()); f!==q&&this._slide(q>f?"next":"prev",z[q])}}dispose(){this._swipeHelper&&this._swipeHelper.dispose();super.dispose()}_configAfterMerge(q){return q.defaultInterval=q.interval,q}_addEventListeners(){this._config.keyboard&&ua.on(this._element,"keydown.bs.carousel",q=>this._keydown(q));"hover"===this._config.pause&&(ua.on(this._element,"mouseenter.bs.carousel",()=>this.pause()),ua.on(this._element,"mouseleave.bs.carousel",()=>this._maybeEnableCycle()));this._config.touch&&fa.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(let q of va.find(".carousel-item img", this._element))ua.on(q,"dragstart.bs.carousel",z=>z.preventDefault());this._swipeHelper=new fa(this._element,{leftCallback:()=>this._slide(this._directionToOrder("left")),rightCallback:()=>this._slide(this._directionToOrder("right")),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout(()=>this._maybeEnableCycle(),500+this._config.interval))}})}_keydown(q){if(!/input|textarea/i.test(q.target.tagName)){var z=F[q.key]; z&&(q.preventDefault(),this._slide(this._directionToOrder(z)))}}_getItemIndex(q){return this._getItems().indexOf(q)}_setActiveIndicatorElement(q){if(this._indicatorsElement){var z=va.findOne(".active",this._indicatorsElement);z.classList.remove("active");z.removeAttribute("aria-current");(q=va.findOne(`[data-bs-slide-to="${q}"]`,this._indicatorsElement))&&(q.classList.add("active"),q.setAttribute("aria-current","true"))}}_updateInterval(){var q=this._activeElement||this._getActive();q&&(q=Number.parseInt(q.getAttribute("data-bs-interval"), 10),this._config.interval=q||this._config.defaultInterval)}_slide(q,z=null){if(!this._isSliding){var f=this._getActive(),t="next"===q,w=z||ec(this._getItems(),f,t,this._config.wrap);if(w!==f){var y=this._getItemIndex(w),B=O=>ua.trigger(this._element,O,{relatedTarget:w,direction:this._orderToDirection(q),from:this._getItemIndex(f),to:y});if(!B("slide.bs.carousel").defaultPrevented&&f&&w){z=!!this._interval;this.pause();this._isSliding=!0;this._setActiveIndicatorElement(y);this._activeElement=w;var E= t?"carousel-item-start":"carousel-item-end",J=t?"carousel-item-next":"carousel-item-prev";w.classList.add(J);w.offsetHeight;f.classList.add(E);w.classList.add(E);this._queueCallback(()=>{w.classList.remove(E,J);w.classList.add("active");f.classList.remove("active",J,E);this._isSliding=!1;B("slid.bs.carousel")},f,this._isAnimated());z&&this.cycle()}}}}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return va.findOne(".active.carousel-item",this._element)}_getItems(){return va.find(".carousel-item", -this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(q){return"rtl"===document.documentElement.dir?"left"===q?"prev":"next":"left"===q?"next":"prev"}_orderToDirection(q){return"rtl"===document.documentElement.dir?"prev"===q?"left":"right":"prev"===q?"right":"left"}static jQueryInterface(q){return this.each(function(){let z=la.getOrCreateInstance(this,q);if("number"!=typeof q){if("string"==typeof q){if(void 0===z[q]||q.startsWith("_")|| +this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(q){return"rtl"===document.documentElement.dir?"left"===q?"prev":"next":"left"===q?"next":"prev"}_orderToDirection(q){return"rtl"===document.documentElement.dir?"prev"===q?"left":"right":"prev"===q?"right":"left"}static jQueryInterface(q){return this.each(function(){let z=ka.getOrCreateInstance(this,q);if("number"!=typeof q){if("string"==typeof q){if(void 0===z[q]||q.startsWith("_")|| "constructor"===q)throw TypeError(`No method named "${q}"`);z[q]()}}else z.to(q)})}constructor(q,z){super(q,z);this._activeElement=this._interval=null;this._isSliding=!1;this._swipeHelper=this.touchTimeout=null;this._indicatorsElement=va.findOne(".carousel-indicators",this._element);this._addEventListeners();"carousel"===this._config.ride&&this.cycle()}}ua.on(document,"click.bs.carousel.data-api","[data-bs-slide], [data-bs-slide-to]",function(q){var z=va.getElementFromSelector(this);if(z&&z.classList.contains("carousel"))return q.preventDefault(), -q=la.getOrCreateInstance(z),z=this.getAttribute("data-bs-slide-to"),z?q.to(z):"next"===tc.getDataAttribute(this,"slide")?q.next():q.prev(),void q._maybeEnableCycle()});ua.on(window,"load.bs.carousel.data-api",()=>{for(let q of va.find('[data-bs-ride="carousel"]'))la.getOrCreateInstance(q)});Rb(la);let xa={parent:null,toggle:!0},za={parent:"(null|element)",toggle:"boolean"};class cb extends Xb{static get Default(){return xa}static get DefaultType(){return za}static get NAME(){return"collapse"}toggle(){this._isShown()? +q=ka.getOrCreateInstance(z),z=this.getAttribute("data-bs-slide-to"),z?q.to(z):"next"===tc.getDataAttribute(this,"slide")?q.next():q.prev(),void q._maybeEnableCycle()});ua.on(window,"load.bs.carousel.data-api",()=>{for(let q of va.find('[data-bs-ride="carousel"]'))ka.getOrCreateInstance(q)});Rb(ka);let xa={parent:null,toggle:!0},za={parent:"(null|element)",toggle:"boolean"};class cb extends Xb{static get Default(){return xa}static get DefaultType(){return za}static get NAME(){return"collapse"}toggle(){this._isShown()? this.hide():this.show()}show(){if(!this._isTransitioning&&!this._isShown()){var q=[];if(!(this._config.parent&&(q=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter(f=>f!==this._element).map(f=>cb.getOrCreateInstance(f,{toggle:!1}))),q.length&&q[0]._isTransitioning||ua.trigger(this._element,"show.bs.collapse").defaultPrevented)){for(let f of q)f.hide();var z=this._getDimension();this._element.classList.remove("collapse");this._element.classList.add("collapsing");this._element.style[z]= 0;this._addAriaAndCollapsedClass(this._triggerArray,!0);this._isTransitioning=!0;q=`scroll${z[0].toUpperCase()+z.slice(1)}`;this._queueCallback(()=>{this._isTransitioning=!1;this._element.classList.remove("collapsing");this._element.classList.add("collapse","show");this._element.style[z]="";ua.trigger(this._element,"shown.bs.collapse")},this._element,!0);this._element.style[z]=`${this._element[q]}px`}}}hide(){if(!this._isTransitioning&&this._isShown()&&!ua.trigger(this._element,"hide.bs.collapse").defaultPrevented){var q= this._getDimension();for(let z of(this._element.style[q]=`${this._element.getBoundingClientRect()[q]}px`,hb(this._element),this._element.classList.add("collapsing"),this._element.classList.remove("collapse","show"),this._triggerArray)){let f=va.getElementFromSelector(z);f&&!this._isShown(f)&&this._addAriaAndCollapsedClass([z],!1)}this._isTransitioning=!0;this._element.style[q]="";this._queueCallback(()=>{this._isTransitioning=!1;this._element.classList.remove("collapsing");this._element.classList.add("collapse"); @@ -1019,7 +1019,7 @@ Rb(Pc);let hf={animation:"boolean",autohide:"boolean",delay:"number"},we={animat {this._element.classList.remove("showing");ua.trigger(this._element,"shown.bs.toast");this._maybeScheduleHide()},this._element,this._config.animation))}hide(){this.isShown()&&(ua.trigger(this._element,"hide.bs.toast").defaultPrevented||(this._element.classList.add("showing"),this._queueCallback(()=>{this._element.classList.add("hide");this._element.classList.remove("showing","show");ua.trigger(this._element,"hidden.bs.toast")},this._element,this._config.animation)))}dispose(){this._clearTimeout(); this.isShown()&&this._element.classList.remove("show");super.dispose()}isShown(){return this._element.classList.contains("show")}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout(()=>{this.hide()},this._config.delay)))}_onInteraction(q,z){switch(q.type){case "mouseover":case "mouseout":this._hasMouseInteraction=z;break;case "focusin":case "focusout":this._hasKeyboardInteraction=z}if(z)return void this._clearTimeout();q= q.relatedTarget;this._element===q||this._element.contains(q)||this._maybeScheduleHide()}_setListeners(){ua.on(this._element,"mouseover.bs.toast",q=>this._onInteraction(q,!0));ua.on(this._element,"mouseout.bs.toast",q=>this._onInteraction(q,!1));ua.on(this._element,"focusin.bs.toast",q=>this._onInteraction(q,!0));ua.on(this._element,"focusout.bs.toast",q=>this._onInteraction(q,!1))}_clearTimeout(){clearTimeout(this._timeout);this._timeout=null}static jQueryInterface(q){return this.each(function(){let z= -be.getOrCreateInstance(this,q);if("string"==typeof q){if(void 0===z[q])throw TypeError(`No method named "${q}"`);z[q](this)}})}constructor(q,z){super(q,z);this._timeout=null;this._hasKeyboardInteraction=this._hasMouseInteraction=!1;this._setListeners()}}return fc(be),Rb(be),{Alert:uc,Button:D,Carousel:la,Collapse:cb,Dropdown:Lc,Modal:ud,Offcanvas:Gc,Popover:Ed,ScrollSpy:ae,Tab:Pc,Toast:be,Tooltip:vd}}();(function(){for(var a=0,c=["ms","moz","webkit","o"],d=0;d