diff --git a/addon/codemirror-colorpicker.js b/addon/codemirror-colorpicker.js index be89930..eb68c8a 100644 --- a/addon/codemirror-colorpicker.js +++ b/addon/codemirror-colorpicker.js @@ -2194,7 +2194,13 @@ function gradient() { }).join(','); var $colors = color.gradient(params, $scale).map(function (c) { - return color.parse(c); + var _Color$parse = color.parse(c), + r = _Color$parse.r, + g = _Color$parse.g, + b = _Color$parse.b, + a = _Color$parse.a; + + return { r: r, g: g, b: b, a: a }; }); return pixel(function () { @@ -2379,7 +2385,8 @@ function thresholdColor() { var $hasColor = hasColor; return pixel(function () { - var v = $C * color.brightness($r, $g, $b) >= $scale ? 255 : 0; + // refer to Color.brightness + var v = $C * Math.ceil($r * 0.2126 + $g * 0.7152 + $b * 0.0722) >= $scale ? 255 : 0; if ($hasColor) { @@ -2536,17 +2543,6 @@ function negative() { return convolution(weight([-1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1], amount / 100)); } -function random() { - var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; - var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createRandomCount(); - - amount = parseParamNumber$1(amount); - return function (pixels, width, height) { - var rand = createRandRange(-1, 5, count); - return convolution(rand)(pixels, width, height); - }; -} - function sepia2() { var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; @@ -3088,7 +3084,6 @@ var matrix = { motionBlur3: motionBlur3, 'motion-blur-3': motionBlur3, negative: negative, - random: random, sepia2: sepia2, sharpen: sharpen, sobelHorizontal: sobelHorizontal, @@ -3527,46 +3522,44 @@ function fillPixelColor(targetPixels, targetIndex, sourcePixels, sourceIndex) { fillColor(targetPixels, targetIndex, sourcePixels[sourceIndex], sourcePixels[sourceIndex + 1], sourcePixels[sourceIndex + 2], sourcePixels[sourceIndex + 3]); } + + +function createSubPixelWeightFunction(weights, width, height, opaque) { + var side = Math.round(Math.sqrt(weights.length)); + var halfSide = Math.floor(side / 2); + var alphaFac = opaque ? 1 : 0; + + var FunctionCode = 'let r = 0, g = 0, b = 0, a = 0, scy = 0, scx =0, si = 0; '; + + weights.forEach(function (wt, index) { + var cy = Math.floor(index / side); + var cx = index % side; + var distY = cy - halfSide; + var distX = cx - halfSide; + + FunctionCode += 'scy = $sy + (' + distY + '); scx = $sx + (' + distX + '); if (scy >= 0 && scy < ' + height + ' && scx >= 0 && scx < ' + width + ') { si = (scy * ' + width + ' + scx) << 2; r += $sp[si] * (' + wt + '); g += $sp[si + 1] * (' + wt + '); b += $sp[si + 2] * (' + wt + '); a += $sp[si + 3] * (' + wt + '); }\n '; + }); + + FunctionCode += '$dp[$di] = r; $dp[$di+1] = g;$dp[$di+2] = b;$dp[$di+3] = a + (' + alphaFac + ')*(255-a); '; + + var subPixelFunction = new Function('$dp', '$sp', '$di', '$sx', '$sy', FunctionCode); + + return subPixelFunction; +} + function convolution(weights) { + var opaque = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return function (bitmap, done) { var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var side = Math.round(Math.sqrt(weights.length)); - var halfSide = Math.floor(side / 2); - - var w = bitmap.width; - var h = bitmap.height; - var sw = w; - var sh = h; var newBitmap = createBitmap(bitmap.pixels.length, bitmap.width, bitmap.height); - packXY(function (pixels, dstIndex, x, y) { - var sy = y; - var sx = x; - // const dstIndex = (y * w + x) * 4; - - var r = 0, - g = 0, - b = 0, - a = 0; - for (var cy = 0; cy < side; cy++) { - for (var cx = 0; cx < side; cx++) { - - var scy = sy + cy - halfSide; - var scx = sx + cx - halfSide; - - if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) { - var srcIndex = (scy * sw + scx) * 4; - var wt = weights[cy * side + cx]; - r += pixels[srcIndex] * wt; - g += pixels[srcIndex + 1] * wt; - b += pixels[srcIndex + 2] * wt; - a += pixels[srcIndex + 3] * wt; // weight 를 곱한 값을 계속 더한다. - } - } - } - fillColor(newBitmap.pixels, dstIndex, r, g, b, a); - })(bitmap, function () { + var subPixelWeightFunction = createSubPixelWeightFunction(weights, bitmap.width, bitmap.height, opaque); + + packXY(function (pixels, i, x, y) { + subPixelWeightFunction(pixels, bitmap.pixels, i, x, y); + })(newBitmap, function () { done(newBitmap); }, opt); }; diff --git a/dist/codemirror-colorpicker.js b/dist/codemirror-colorpicker.js index 45a87a1..67f0de0 100644 --- a/dist/codemirror-colorpicker.js +++ b/dist/codemirror-colorpicker.js @@ -2212,7 +2212,13 @@ function gradient() { }).join(','); var $colors = color.gradient(params, $scale).map(function (c) { - return color.parse(c); + var _Color$parse = color.parse(c), + r = _Color$parse.r, + g = _Color$parse.g, + b = _Color$parse.b, + a = _Color$parse.a; + + return { r: r, g: g, b: b, a: a }; }); return pixel(function () { @@ -2416,7 +2422,8 @@ function thresholdColor() { var $hasColor = hasColor; return pixel(function () { - var v = $C * color.brightness($r, $g, $b) >= $scale ? 255 : 0; + // refer to Color.brightness + var v = $C * Math.ceil($r * 0.2126 + $g * 0.7152 + $b * 0.0722) >= $scale ? 255 : 0; if ($hasColor) { @@ -2581,17 +2588,6 @@ function negative() { return convolution(weight([-1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1], amount / 100)); } -function random() { - var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; - var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createRandomCount(); - - amount = parseParamNumber$1(amount); - return function (pixels, width, height) { - var rand = createRandRange(-1, 5, count); - return convolution(rand)(pixels, width, height); - }; -} - function sepia2() { var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100; @@ -3133,7 +3129,6 @@ var matrix = { motionBlur3: motionBlur3, 'motion-blur-3': motionBlur3, negative: negative, - random: random, sepia2: sepia2, sharpen: sharpen, sobelHorizontal: sobelHorizontal, @@ -3572,46 +3567,44 @@ function fillPixelColor(targetPixels, targetIndex, sourcePixels, sourceIndex) { fillColor(targetPixels, targetIndex, sourcePixels[sourceIndex], sourcePixels[sourceIndex + 1], sourcePixels[sourceIndex + 2], sourcePixels[sourceIndex + 3]); } + + +function createSubPixelWeightFunction(weights, width, height, opaque) { + var side = Math.round(Math.sqrt(weights.length)); + var halfSide = Math.floor(side / 2); + var alphaFac = opaque ? 1 : 0; + + var FunctionCode = 'let r = 0, g = 0, b = 0, a = 0, scy = 0, scx =0, si = 0; '; + + weights.forEach(function (wt, index) { + var cy = Math.floor(index / side); + var cx = index % side; + var distY = cy - halfSide; + var distX = cx - halfSide; + + FunctionCode += 'scy = $sy + (' + distY + '); scx = $sx + (' + distX + '); if (scy >= 0 && scy < ' + height + ' && scx >= 0 && scx < ' + width + ') { si = (scy * ' + width + ' + scx) << 2; r += $sp[si] * (' + wt + '); g += $sp[si + 1] * (' + wt + '); b += $sp[si + 2] * (' + wt + '); a += $sp[si + 3] * (' + wt + '); }\n '; + }); + + FunctionCode += '$dp[$di] = r; $dp[$di+1] = g;$dp[$di+2] = b;$dp[$di+3] = a + (' + alphaFac + ')*(255-a); '; + + var subPixelFunction = new Function('$dp', '$sp', '$di', '$sx', '$sy', FunctionCode); + + return subPixelFunction; +} + function convolution(weights) { + var opaque = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + return function (bitmap, done) { var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - var side = Math.round(Math.sqrt(weights.length)); - var halfSide = Math.floor(side / 2); - - var w = bitmap.width; - var h = bitmap.height; - var sw = w; - var sh = h; var newBitmap = createBitmap(bitmap.pixels.length, bitmap.width, bitmap.height); - packXY(function (pixels, dstIndex, x, y) { - var sy = y; - var sx = x; - // const dstIndex = (y * w + x) * 4; - - var r = 0, - g = 0, - b = 0, - a = 0; - for (var cy = 0; cy < side; cy++) { - for (var cx = 0; cx < side; cx++) { - - var scy = sy + cy - halfSide; - var scx = sx + cx - halfSide; - - if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) { - var srcIndex = (scy * sw + scx) * 4; - var wt = weights[cy * side + cx]; - r += pixels[srcIndex] * wt; - g += pixels[srcIndex + 1] * wt; - b += pixels[srcIndex + 2] * wt; - a += pixels[srcIndex + 3] * wt; // weight 를 곱한 값을 계속 더한다. - } - } - } - fillColor(newBitmap.pixels, dstIndex, r, g, b, a); - })(bitmap, function () { + var subPixelWeightFunction = createSubPixelWeightFunction(weights, bitmap.width, bitmap.height, opaque); + + packXY(function (pixels, i, x, y) { + subPixelWeightFunction(pixels, bitmap.pixels, i, x, y); + })(newBitmap, function () { done(newBitmap); }, opt); }; diff --git a/dist/codemirror-colorpicker.min.js b/dist/codemirror-colorpicker.min.js index e4e62e4..0aa229f 100644 --- a/dist/codemirror-colorpicker.min.js +++ b/dist/codemirror-colorpicker.min.js @@ -1 +1 @@ -var CodeMirrorColorPicker=function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb(0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb(0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb(0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb(95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(237, 20, 61)",cyan:"rgb(0, 255, 255)",darkblue:"rgb(0, 0, 139)",darkcyan:"rgb(0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgrey:"rgb(169, 169, 169)",darkgreen:"rgb(0, 100, 0)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb(85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb(72, 61, 139)",darkslategray:"rgb(47, 79, 79)",darkslategrey:"rgb(47, 79, 79)",darkturquoise:"rgb(0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb(0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb(30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb(34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb(0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb(75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgreen:"rgb(144, 238, 144)",lightgray:"rgb(211, 211, 211)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb(32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb(0, 255, 0)",limegreen:"rgb(50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb(0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb(60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb(0, 250, 154)",mediumturquoise:"rgb(72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb(25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb(0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",rebeccapurple:"rgb(102, 51, 153)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb(65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb(46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb(0, 255, 127)",steelblue:"rgb(70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb(0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb(64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)",transparent:"rgba(0, 0, 0, 0)"};var r={isColorName:function(t){return!!e[t]},getColorByName:function(t){return e[t]}};function n(t,e){if(t.length!==e.length)return!1;for(var r=0,n=t.length;r0)h=l(c);else h=e[Math.floor(a()*e.length)];o=!n(h,u),i[s]=h}return o}function u(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"linear";t=t,e=e||Math.max(2,Math.ceil(Math.sqrt(t.length/2)));var l=r||"euclidean";"string"==typeof l&&(l=i[l]);for(var u=0,h=function(){return(u=(9301*u+49297)%233280)/233280},f=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"linear";return o[r](t.length,e).map(function(e){return t[e]})}(t,e,a),g=!0,v=0;g;){if(g=c(e,t,s(e,t,f,l),f,!1,h),++v%n==0)break}return f}var h={create:function(t,e){var r=document.createElement("canvas");return r.width=t||0,r.height=e||0,r},drawPixels:function(t){var e=this.create(t.width,t.height),r=e.getContext("2d"),n=r.getImageData(0,0,e.width,e.height);return n.data.set(t.pixels),r.putImageData(n,0,0),e},createHistogram:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{black:!0,red:!1,green:!1,blue:!1},o=this.create(t,e),a=o.getContext("2d");a.clearRect(0,0,t,e),a.fillStyle="white",a.fillRect(0,0,t,e),a.globalAlpha=.7;var l={black:!1};i.black?l.black=!1:l.black=!0,i.red?l.red=!1:l.red=!0,i.green?l.green=!1:l.green=!0,i.blue?l.blue=!1:l.blue=!0,Object.keys(r).forEach(function(n){if(!l[n]){var i=r[n],o=Math.max.apply(Math,i),s=t/i.length;a.fillStyle=n,i.forEach(function(t,r){var n=e*(t/o),i=r*s;a.fillRect(i,e-n,s,n)})}}),"function"==typeof n&&n(o)},getHistogram:function(t){for(var e,r,n=new Array(256),i=new Array(256),o=new Array(256),a=new Array(256),l=0;l<256;l++)n[l]=0,i[l]=0,o[l]=0,a[l]=0;return r=function(t,e){var r=Math.round(w.brightness(t[e],t[e+1],t[e+2]));n[r]++,i[t[e]]++,o[t[e+1]]++,a[t[e+2]]++},function(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};g(this,t),this.isLoaded=!1,this.imageUrl=e,this.opt=r,this.initialize()}return v(t,[{key:"initialize",value:function(){this.canvas=this.createCanvas(),this.context=this.canvas.getContext("2d")}},{key:"createCanvas",value:function(){return document.createElement("canvas")}},{key:"load",value:function(t){this.loadImage(t)}},{key:"loadImage",value:function(t){var e=this,r=this.context,n=new Image;n.onload=function(){var i=n.height/n.width;e.opt.canvasWidth&&e.opt.canvasHeight?(e.canvas.width=e.opt.canvasWidth,e.canvas.height=e.opt.canvasHeight):(e.canvas.width=e.opt.maxWidth?e.opt.maxWidth:n.width,e.canvas.height=e.canvas.width*i),r.drawImage(n,0,0,n.width,n.height,0,0,e.canvas.width,e.canvas.height),e.isLoaded=!0,t&&t()},this.getImageUrl(function(t){n.src=t})}},{key:"getImageUrl",value:function(t){if("string"==typeof this.imageUrl)return t(this.imageUrl);if(this.imageUrl instanceof Blob){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(this.imageUrl)}}},{key:"getRGBA",value:function(t,e,r,n){return[t,e,r,n]}},{key:"toArray",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=n.width,o=n.height,a=new Uint8ClampedArray(n.data);t||(t=function(t,e){e(t)}),t({pixels:a,width:i,height:o},function(t){var n=h.drawPixels(t);"canvas"==r.returnTo?e(n):e(n.toDataURL(r.outputFormat||"image/png"))},r)}},{key:"toHistogram",value:function(t){var e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),r=e.width,n=e.height,i={pixels:new Uint8ClampedArray(e.data),width:r,height:n};return h.getHistogram(i)}},{key:"toRGB",value:function(){for(var t=this.context.getImageData(0,0,this.canvas.width,this.canvas.height).data,e=[],r=0,n=t.length;r-1||e[i].indexOf("rgb")>-1||e[i].indexOf("hsl")>-1)n.push({color:e[i]});else{var a=r.getColorByName(e[i]);a&&n.push({color:e[i],nameColor:a})}var l={next:0};return n.forEach(function(e){var r=t.indexOf(e.color,l.next);e.startIndex=r,e.endIndex=r+e.color.length,l.next=e.endIndex}),n},convertMatches:function(t){var e=this.matches(t);return e.forEach(function(e,r){t=t.replace(e.color,"@"+r)}),{str:t,matches:e}},convertMatchesArray:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",",n=this.convertMatches(t);return n.str.split(r).map(function(t,r){return t=e.trim(t),n.matches[r]&&(t=t.replace("@"+r,n.matches[r].color)),t})},reverseMatches:function(t,e){return e.forEach(function(e,r){t=t.replace("@"+r,e.color)}),t},trim:function(t){return t.replace(/^\s+|\s+$/g,"")},round:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.round(t*e)/e},format:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgba(0, 0, 0, 0)";return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),"hex"==e?this.hex(t):"rgb"==e?this.rgb(t,r):"hsl"==e?this.hsl(t):t},hex:function(t){Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]});var e=t.r.toString(16);t.r<16&&(e="0"+e);var r=t.g.toString(16);t.g<16&&(r="0"+r);var n=t.b.toString(16);return t.b<16&&(n="0"+n),"#"+e+r+n},rgb:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgba(0, 0, 0, 0)";if(Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),void 0!==t)return 1==t.a||void 0===t.a?isNaN(t.r)?e:"rgb("+t.r+","+t.g+","+t.b+")":"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},hsl:function(t){return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),1==t.a||void 0===t.a?"hsl("+t.h+","+t.s+"%,"+t.l+"%)":"hsla("+t.h+","+t.s+"%,"+t.l+"%,"+t.a+")"},parse:function(t){if("string"==typeof t){if(r.isColorName(t)&&(t=r.getColorByName(t)),t.indexOf("rgb(")>-1){for(var e=0,n=(o=t.replace("rgb(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("rgba(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("hsl(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("hsla(","").replace(")","").split(",")).length;e>16,g:(65280&t)>>8,b:(255&t)>>0,a:1};return i=Object.assign(i,this.RGBtoHSL(i))}if(0<=t&&t<=4294967295){i={type:"hex",r:(4278190080&t)>>24,g:(16711680&t)>>16,b:(65280&t)>>8,a:(255&t)/255};return i=Object.assign(i,this.RGBtoHSL(i))}}return t},HSVtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=t,o=r;360==i&&(i=0);var a=e*o,l=a*(1-Math.abs(i/60%2-1)),s=o-a,c=[];return 0<=i&&i<60?c=[a,l,0]:60<=i&&i<120?c=[l,a,0]:120<=i&&i<180?c=[0,a,l]:180<=i&&i<240?c=[0,l,a]:240<=i&&i<300?c=[l,0,a]:300<=i&&i<360&&(c=[a,0,l]),{r:this.round(255*(c[0]+s)),g:this.round(255*(c[1]+s)),b:this.round(255*(c[2]+s))}},RGBtoHSV:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=Math.max(i,o,a),s=l-Math.min(i,o,a),c=0;0==s?c=0:l==i?c=(o-a)/s%6*60:l==o?c=60*((a-i)/s+2):l==a&&(c=60*((i-o)/s+4)),c<0&&(c=360+c);return{h:c,s:0==l?0:s/l,v:l}},HSVtoHSL:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=this.HSVtoRGB(t,e,r);return this.RGBtoHSL(i.r,i.g,i.b)},RGBtoCMYK:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=1-Math.max(i,o,a);return{c:(1-i-l)/(1-l),m:(1-o-l)/(1-l),y:(1-a-l)/(1-l),k:l}},CMYKtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.c,e=i.m,r=i.y,n=i.k}return{r:255*(1-t)*(1-n),g:255*(1-e)*(1-n),b:255*(1-r)*(1-n)}},RGBtoHSL:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}t/=255,e/=255,r/=255;var i,o,a=Math.max(t,e,r),l=Math.min(t,e,r),s=(a+l)/2;if(a==l)i=o=0;else{var c=a-l;switch(o=s>.5?c/(2-a-l):c/(a+l),a){case t:i=(e-r)/c+(e1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t},HSLtoHSV:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,n.v}var i=this.HSLtoRGB(t,e,r);return this.RGBtoHSV(i.r,i.g,i.b)},HSLtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.l}var i,o,a;if(t/=360,r/=100,0==(e/=100))i=o=a=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;i=this.HUEtoRGB(s,l,t+1/3),o=this.HUEtoRGB(s,l,t),a=this.HUEtoRGB(s,l,t-1/3)}return{r:this.round(255*i),g:this.round(255*o),b:this.round(255*a)}},c:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray((t+e+r)/3>90?0:255)},gray:function(t){return{r:t,g:t,b:t}},RGBtoSimpleGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray(Math.ceil((t+e+r)/3))},RGBtoGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray(this.RGBtoYCrCb(t,e,r).y)},brightness:function(t,e,r){return Math.ceil(.2126*t+.7152*e+.0722*r)},RGBtoYCrCb:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=this.brightness(t,e,r);return{y:i,cr:.713*(t-i),cb:.564*(r-i)}},YCrCbtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.y,e=i.cr,r=i.cb;n=(n=i.bit)||0}var o=t+1.402*(e-n),a=t-.344*(r-n)-.714*(e-n),l=t+1.772*(r-n);return{r:Math.ceil(o),g:Math.ceil(a),b:Math.ceil(l)}},ReverseRGB:function(t){return t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t},XYZtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.x,e=n.y,r=n.z}var i=t/100,o=e/100,a=r/100,l=3.2406*i+-1.5372*o+-.4986*a,s=-.9689*i+1.8758*o+.0415*a,c=.0557*i+-.204*o+1.057*a;return l=this.ReverseRGB(l),s=this.ReverseRGB(s),c=this.ReverseRGB(c),{r:this.round(255*l),g:this.round(255*s),b:this.round(255*c)}},PivotRGB:function(t){return 100*(t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)},RGBtoXYZ:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255;return{x:.4124*(i=this.PivotRGB(i))+.3576*(o=this.PivotRGB(o))+.1805*(a=this.PivotRGB(a)),y:.2126*i+.7152*o+.0722*a,z:.0193*i+.1192*o+.9505*a}},ReverseXyz:function(t){return Math.pow(t,3)>.008856?Math.pow(t,3):(t-16/116)/7.787},LABtoXYZ:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}var i=(t+16)/116,o=e/500+i,a=i-r/200;return i=this.ReverseXyz(i),{x:95.047*(o=this.ReverseXyz(o)),y:100*i,z:108.883*(a=this.ReverseXyz(a))}},PivotXyz:function(t){return t>.008856?Math.pow(t,1/3):(7.787*t+16)/116},XYZtoLAB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.x,e=n.y,r=n.z}var i=t/95.047,o=e/100,a=r/108.883;return i=this.PivotXyz(i),{l:116*(o=this.PivotXyz(o))-16,a:500*(i-o),b:200*(o-(a=this.PivotXyz(a)))}},RGBtoLAB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.XYZtoLAB(this.RGBtoXYZ(t,e,r))},LABtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}return this.XYZtoRGB(this.LABtoXYZ(t,e,r))},blend:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex",i=this.parse(t),o=this.parse(e);return this.interpolateRGB(i,o,r,n)},mix:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex";return this.blend(t,e,r,n)},contrast:function(t){t=this.parse(t);var e=(Math.round(299*t.r)+Math.round(587*t.g)+Math.round(114*t.b))/1e3;return e},contrastColor:function(t){return this.contrast(t)>=128?"black":"white"},interpolateRGB:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex",i={r:this.round(t.r+(e.r-t.r)*r),g:this.round(t.g+(e.g-t.g)*r),b:this.round(t.b+(e.b-t.b)*r),a:this.round(t.a+(e.a-t.a)*r,100)};return this.format(i,i.a<1?"rgb":n)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(!t)return[];"string"==typeof t&&(t=this.convertMatchesArray(t));for(var r=(t=t||[]).length,n=[],i=0;i0){var n=(1-t.filter(function(t){return"*"!=t[1]&&1!=t[1]}).map(function(t){return t[1]}).reduce(function(t,e){return t+e},0))/r;t.forEach(function(e,r){"*"==e[1]&&r>0&&(t.length-1==r||(e[1]=n))})}return t},gradient:function(t){for(var e=[],r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:10)-((t=this.parseGradient(t)).length-1),n=r,i=1,o=t.length;i1&&void 0!==arguments[1]?arguments[1]:"h",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"rgb",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,l=this.parse(t),s=this.RGBtoHSV(l),c=(o-i)*a/r,u=[],h=1;h<=r;h++)s[e]=Math.abs((a-c*h)/a),u.push(this.format(this.HSVtoRGB(s),n));return u},scaleH:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:360;return this.scaleHSV(t,"h",e,r,n,i,1)},scaleS:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return this.scaleHSV(t,"s",e,r,n,i,100)},scaleV:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return this.scaleHSV(t,"v",e,r,n,i,100)},palette:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hex";return t.length>r&&(t=u(t,r)),t.map(function(t){return e.format(t,n)})},ImageToRGB:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];if(r){if(r){var n;(n=new $(t,e)).loadImage(function(){"function"==typeof r&&r(n.toRGB())})}}else(n=new $(t)).loadImage(function(){"function"==typeof e&&e(n.toRGB())})},ImageToCanvas:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"},i=new $(t);i.loadImage(function(){i.toArray(e,function(t){"function"==typeof r&&r(t)},Object.assign({returnTo:"canvas"},n))})},ImageToURL:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"},i=new $(t);i.loadImage(function(){i.toArray(e,function(t){"function"==typeof r&&r(t)},n)})},histogram:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=new $(t);n.loadImage(function(){"function"==typeof e&&e(n.toHistogram(r))})},ImageToHistogram:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{width:200,height:100},n=new $(t);n.loadImage(function(){h.createHistogram(r.width||200,r.height||100,n.toHistogram(r),function(t){"function"==typeof e&&e(t.toDataURL("image/png"))},r)})}};w.scale.parula=function(t){return w.scale(["#352a87","#0f5cdd","#00b5a6","#ffc337","#fdff00"],t)},w.scale.jet=function(t){return w.scale(["#00008f","#0020ff","#00ffff","#51ff77","#fdff00","#ff0000","#800000"],t)},w.scale.hsv=function(t){return w.scale(["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"],t)},w.scale.hot=function(t){return w.scale(["#0b0000","#ff0000","#ffff00","#ffffff"],t)},w.scale.pink=function(t){return w.scale(["#1e0000","#bd7b7b","#e7e5b2","#ffffff"],t)},w.scale.bone=function(t){return w.scale(["#000000","#4a4a68","#a6c6c6","#ffffff"],t)},w.scale.copper=function(t){return w.scale(["#000000","#3d2618","#9d623e","#ffa167","#ffc77f"],t)};var _=[{rgb:"#ff0000",start:0},{rgb:"#ffff00",start:.17},{rgb:"#00ff00",start:.33},{rgb:"#00ffff",start:.5},{rgb:"#0000ff",start:.67},{rgb:"#ff00ff",start:.83},{rgb:"#ff0000",start:1}];!function(){for(var t=0,e=_.length;t=t){e=_[n-1],r=_[n];break}return e&&r?w.interpolateRGB(e,r,(t-e.start)/(r.start-e.start)):_[0].rgb}},M={identity:function(){return[1,0,0,0,1,0,0,0,1]},stretching:function(t){return[t,0,0,0,1,0,0,0,1]},squeezing:function(t){return[t,0,0,0,1/t,0,0,0,1]},scale:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return[t=t||0===t?t:1,0,0,0,e=e||0===e?e:1,0,0,0,1]},scaleX:function(t){return this.scale(t)},scaleY:function(t){return this.scale(1,t)},translate:function(t,e){return[1,0,t,0,1,e,0,0,1]},rotate:function(t){var e=this.radian(t);return[Math.cos(e),-Math.sin(e),0,Math.sin(e),Math.cos(e),0,0,0,1]},rotate90:function(){return[0,-1,0,1,0,0,0,0,1]},rotate180:function(){return[-1,0,0,0,-1,0,0,0,1]},rotate270:function(){return[0,1,0,-1,0,0,0,0,1]},radian:function(t){return t*Math.PI/180},skew:function(t,e){var r=this.radian(t),n=this.radian(e);return[1,Math.tan(r),0,Math.tan(n),1,0,0,0,1]},skewX:function(t){var e=this.radian(t);return[1,Math.tan(e),0,0,1,0,0,0,1]},skewY:function(t){var e=this.radian(t);return[1,0,0,Math.tan(e),1,0,0,0,1]},shear1:function(t){return[1,-Math.tan(this.radian(t)/2),0,0,1,0,0,0,1]},shear2:function(t){return[1,0,0,Math.sin(this.radian(t)),1,0,0,0,1]}},H={CONSTANT:M,radian:function(t){return M.radian(t)},multiply:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]},identity:function(t){return this.multiply(M.identity(),t)},translate:function(t,e,r){return this.multiply(M.translate(t,e),r)},rotate:function(t,e){return this.multiply(M.rotate(t),e)},shear1:function(t,e){return this.multiply(M.shear1(t),e)},shear2:function(t,e){return this.multiply(M.shear2(t),e)},rotateShear:function(t,e){var r=e;return r=this.shear1(t,r),r=this.shear2(t,r),r=this.shear1(t,r)}};function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"center";return function(n,i){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=ot(n.pixels.length,n.width,n.height),l=n.width,s=n.height;"center"==e&&(e=Math.floor(l/2)),"center"==r&&(r=Math.floor(s/2));var c=H.CONSTANT.translate(-e,-r),u=H.CONSTANT.translate(e,r),h=H.CONSTANT.shear1(t),f=H.CONSTANT.shear2(t);vt(function(t,e,r,i){var o=H.multiply(c,[r,i,1]);o=H.multiply(h,o).map(Math.round),o=H.multiply(f,o).map(Math.round),o=H.multiply(h,o).map(Math.round),o=H.multiply(u,o);var a=k(o,2),g=a[0],v=a[1];g<0||(v<0||g>l-1||v>s-1||mt(t,v*l+g<<2,n.pixels,e))})(a,function(){i(a)},o)}}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=st(t),i=(e=st(e))/100,o=r;return ht(function(){var t=i*w.brightness($r,$g,$b)>=n?255:0;if(o)0==t&&($r=0,$g=0,$b=0);else{var e=Math.round(t);$r=e,$g=e,$b=e}},{$C:i,$scale:n,$hasColor:o})}function R(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([1,2,1,2,4,2,1,2,1],1/16*((t=st(t))/100)))}function E(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1],1/256*((t=st(t))/100)))}function A(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return t=st(t),yt([5,5,5,-3,0,-3,-3,-3,-3])}function O(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return t=st(t),yt([5,-3,-3,5,0,-3,5,-3,-3])}function L(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],(t=st(t))/100))}function F(){return yt(J([1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1],1/9))}function P(){return yt(J([1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1],1/9))}function G(){return yt(J([1,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1],1/9))}function T(){return yt([-1,-2,-1,0,0,0,1,2,1])}function N(){return yt([-1,0,1,-2,0,2,-1,0,1])}var j=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],D=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function V(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function z(t,e,r){return r?function(t,e,r,n){if(isNaN(n)||n<1)return t;n|=0;var i,o,a,l,s,c,u,h,f,g,v,d,p,m,y,b,k,C,$,x,w,_,S,M,H=t.pixels,I=t.width,B=t.height,R=n+n+1,E=I-1,A=B-1,O=n+1,L=O*(O+1)/2,F=new V,P=F;for(a=1;a>U,0!=S?(S=255/S,H[c]=(h*z>>U)*S,H[c+1]=(f*z>>U)*S,H[c+2]=(g*z>>U)*S):H[c]=H[c+1]=H[c+2]=0,h-=d,f-=p,g-=m,v-=y,d-=T.r,p-=T.g,m-=T.b,y-=T.a,l=u+((l=i+n+1)>U,S>0?(S=255/S,H[l]=(h*z>>U)*S,H[l+1]=(f*z>>U)*S,H[l+2]=(g*z>>U)*S):H[l]=H[l+1]=H[l+2]=0,h-=d,f-=p,g-=m,v-=y,d-=T.r,p-=T.g,m-=T.b,y-=T.a,l=i+((l=o+O)0&&void 0!==arguments[0]?arguments[0]:10,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t=st(t),function(r,n){n(z(r,t,e))}}function X(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return yt(J([1,4,6,4,1,4,16,24,16,4,6,24,-476,24,6,4,16,24,16,4,1,4,6,4,1],-1/(t=st(t))))}var Y,q=p({},{crop:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],n=arguments[3],i=ot(r*n*4,r,n);return function(o,a){for(var l=e,s=0;l0&&void 0!==arguments[0]?arguments[0]:0;return t=st(t),t%=360,function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(0==t)return e;if(90==t||270==t)var i=ot(e.pixels.length,e.height,e.width);else{if(180!=t)return I(t)(e,r,n);i=ot(e.pixels.length,e.width,e.height)}vt(function(r,n,o,a){if(90==t)var l=o*i.width+(i.width-1-a)<<2;else 270==t?l=(i.height-1-o)*i.width+a<<2:180==t&&(l=(i.height-1-a)*i.width+(i.width-1-o)<<2);mt(i.pixels,l,e.pixels,n)})(e,function(){r(i)},n)}},rotateDegree:I,"rotate-degree":I},{bitonal:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100,n=w.parse(t),i=w.parse(e),o=r;return ht(function(){var t=$r+$g+$b<=o?n:i;$r=t.r,$g=t.g,$b=t.b},{$darkColor:n,$lightColor:i,$threshold:o})},brightness:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;t=st(t);var e=Math.floor(t/100*255);return ht(function(){$r+=e,$g+=e,$b+=e},{$C:e})},clip:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=st(t);var e=2.55*Math.abs(t);return ht(function(){$r=$r>255-e?255:0,$g=$g>255-e?255:0,$b=$b>255-e?255:0},{$C:e})},contrast:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=st(t);var e=Math.max((128+t)/128,0);return ht(function(){$r*=e,$g*=e,$b*=e},{$C:e})},gamma:function(){var t=st(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1);return ht(function(){$r=255*Math.pow($r/255,t),$g=255*Math.pow($g/255,t),$b=255*Math.pow($b/255,t)},{$C:t})},gradient:function(){var t=[].concat(Array.prototype.slice.call(arguments));1===t.length&&"string"==typeof t[0]&&(t=w.convertMatchesArray(t[0]));var e=(t=t.map(function(t){return w.matches(t).length?{type:"param",value:t}:{type:"scale",value:t}})).filter(function(t){return"scale"==t.type})[0];e=e?+e.value:256,t=t.filter(function(t){return"param"==t.type}).map(function(t){return t.value}).join(",");var r=w.gradient(t,e).map(function(t){return w.parse(t)});return ht(function(){var t=$clamp($Color.brightness($r,$g,$b)),n=$clamp(Math.floor(t*(e/256))),i=r[n];$r=i.r,$g=i.g,$b=i.b,$a=$clamp(Math.floor(256*i.a))},{$colors:r,$scale:e})},grayscale:function(t){var e=(t=st(t))/100;e>1&&(e=1);var r=[.2126+.7874*(1-e),.7152-.7152*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152+.2848*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152-.7152*(1-e),.0722+.9278*(1-e),0,0,0,0,1];return ht(function(){$r=r[0]*$r+r[1]*$g+r[2]*$b+r[3]*$a,$g=r[4]*$r+r[5]*$g+r[6]*$b+r[7]*$a,$b=r[8]*$r+r[9]*$g+r[10]*$b+r[11]*$a,$a=r[12]*$r+r[13]*$g+r[14]*$b+r[15]*$a},{$matrix:r})},hue:function(){return ht(function(){var t=Color.RGBtoHSV($r,$g,$b),e=t.h;e+=Math.abs($amount),e%=360,t.h=e;var r=Color.HSVtoRGB(t);$r=r.r,$g=r.g,$b=r.b},{$C:st(arguments.length>0&&void 0!==arguments[0]?arguments[0]:360)})},invert:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=st(t))/100;return ht(function(){$r=(255-$r)*e,$g=(255-$g)*e,$b=(255-$b)*e},{$C:e})},noise:function(){var t=st(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1);return ht(function(){var e=5*Math.abs(t),r=-e,n=e,i=Math.round(r+Math.random()*(n-r));$r+=i,$g+=i,$b+=i},{$C:t})},opacity:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=st(t))/100;return ht(function(){$a*=e},{$C:e})},saturation:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=st(t))/100,r=1-Math.abs(e),n=[r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,r];return ht(function(){$r=n[0]*$r+n[1]*$g+n[2]*$b+n[3]*$a,$g=n[4]*$r+n[5]*$g+n[6]*$b+n[7]*$a,$b=n[8]*$r+n[9]*$g+n[10]*$b+n[11]*$a,$a=n[12]*$r+n[13]*$g+n[14]*$b+n[15]*$a},{$matrix:n})},sepia:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=st(t))/100;e>1&&(e=1);var r=[.393+.607*(1-e),.769-.769*(1-e),.189-.189*(1-e),0,.349-.349*(1-e),.686+.314*(1-e),.168-.168*(1-e),0,.272-.272*(1-e),.534-.534*(1-e),.131+.869*(1-e),0,0,0,0,1];return ht(function(){$r=r[0]*$r+r[1]*$g+r[2]*$b+r[3]*$a,$g=r[4]*$r+r[5]*$g+r[6]*$b+r[7]*$a,$b=r[8]*$r+r[9]*$g+r[10]*$b+r[11]*$a,$a=r[12]*$r+r[13]*$g+r[14]*$b+r[15]*$a},{$matrix:r})},shade:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=st(t),i=st(e),o=st(r);return ht(function(){$r*=n,$g*=i,$b*=o},{$redValue:n,$greenValue:i,$blueValue:o})},solarize:function(t,e,r){var n=st(t),i=st(e),o=st(r);return ht(function(){$r=$r0&&void 0!==arguments[0]?arguments[0]:200,arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,!1)},"threshold-color":B,tint:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=parseParamNumber(t),i=parseParamNumber(e),o=parseParamNumber(r);return ht(function(){$r+=(255-$r)*n,$g+=(255-$g)*i,$b+=(255-$b)*o},{$redTint:n,$greenTint:i,$blueTint:o})}},{blur:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;return yt(dt(t=st(t)))},emboss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return yt([-2*(t=st(t)),-t,0,-t,1,t,0,t,2*t])},gaussianBlur:R,"gaussian-blur":R,gaussianBlur5x:E,"gaussian-blur-5x":E,grayscale2:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([.3,.3,.3,0,0,.59,.59,.59,0,0,.11,.11,.11,0,0,0,0,0,0,0,0,0,0,0,0],(t=st(t))/100))},identity:function(){return yt([0,0,0,0,1,0,0,0,0])},kirschHorizontal:A,"kirsch-horizontal":A,kirschVertical:O,"kirsch-vertical":O,laplacian:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([-1,-1,-1,-1,8,-1,-1,-1,-1],(t=st(t))/100))},laplacian5x:L,"laplacian-5x":L,motionBlur:F,"motion-blur":F,motionBlur2:P,"motion-blur-2":P,motionBlur3:G,"motion-blur-3":G,negative:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([-1,0,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0,0,0,1,0,1,1,1,1,1],(t=st(t))/100))},random:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:it();return t=st(t),function(t,r,n){return yt(nt(-1,5,e))(t,r,n)}},sepia2:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([.393,.349,.272,0,0,.769,.686,.534,0,0,.189,.168,.131,0,0,0,0,0,0,0,0,0,0,0,0],(t=st(t))/100))},sharpen:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([0,-1,0,-1,5,-1,0,-1,0],(t=st(t))/100))},sobelHorizontal:T,"sobel-horizontal":T,sobelVertical:N,"sobel-vertical":N,stackBlur:U,"stack-blur":U,transparency:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return yt(J([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,.3,0,0,0,0,0,1],(t=st(t))/100))},unsharpMasking:X,"unsharp-masking":X},{kirsch:function(){return $t("kirsch-horizontal kirsch-vertical")},sobel:function(){return $t("sobel-horizontal sobel-vertical")},vintage:function(){return $t("brightness(15) saturation(-20) gamma(1.8)")}}),K=0,W=(d(Y={partial:St,multi:wt,merge:_t,weight:J,repeat:Q,colorMatrix:function(t,e,r){var n=t[e],i=t[e+1],o=t[e+2],a=t[e+3];pt(t,e,r[0]*n+r[1]*i+r[2]*o+r[3]*a,r[4]*n+r[5]*i+r[6]*o+r[7]*a,r[8]*n+r[9]*i+r[10]*o+r[11]*a,r[12]*n+r[13]*i+r[14]*o+r[15]*a)},each:et,eachXY:rt,createRandomCount:it,createRandRange:nt,createBitmap:ot,createBlurMatrix:dt,pack:function(t){return function(e,r){et(e.pixels.length,function(r,n){t(e.pixels,r,n,e.pixels[r],e.pixels[r+1],e.pixels[r+2],e.pixels[r+3])},function(){r(e)})}},packXY:vt,pixel:ht,getBitmap:at,putBitmap:lt,radian:function(t){return H.CONSTANT.radian(t)},convolution:yt,parseParamNumber:st,filter:$t,clamp:Ct,fillColor:pt,fillPixelColor:mt},"multi",wt),d(Y,"merge",_t),d(Y,"matches",bt),d(Y,"parseFilter",kt),d(Y,"partial",St),Y),Z=W;function J(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t.map(function(t){return t*e})}function Q(t,e){for(var r=new Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments[3],i=arguments[4],o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1e4,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"full",l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:50,s=e,c=function(t){setTimeout(t,0)};function u(){for(var e=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=[].concat(C(Array(t))).map(function(t){return"\n currentRunIndex = runIndex + i * step\n if (currentRunIndex >= max) return {currentRunIndex: currentRunIndex, i: null};\n callback(currentRunIndex); i++;\n "}).join("\n\n");return new Function("runIndex","i","step","max","callback","\n let currentRunIndex = runIndex;\n \n "+e+"\n \n return {currentRunIndex: currentRunIndex, i: i} \n ")}(l),a=s,h={},f=0;f=t)return void i();c?c(u):u()}(a)}"requestAnimationFrame"==a&&(c=requestAnimationFrame,o=1e3),"full"==a&&(c=null,o=t),u()}function et(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};tt(t,0,4,function(t){e(t,t>>2)},function(){r()},n.functionDumpCount,n.frameTimer)}function rt(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};tt(t,0,4,function(t){var n=t>>2;r(t,n%e,Math.floor(n/e))},function(){n()},i.functionDumpCount,i.frameTimer)}function nt(t,e,r){for(var n=[],i=1;i<=r;i++){var o=Math.random()*(e-t)+t,a=Math.floor(10*Math.random())%2==0?-1:1;n.push(a*o)}n.sort();var l=Math.floor(r>>1),s=n[l];return n[l]=n[0],n[0]=s,n}function it(){return[9,16,25,36,49,64,81,100].sort(function(t,e){return.5-Math.random()})[0]}function ot(t,e,r){return{pixels:new Uint8ClampedArray(t),width:e,height:r}}function at(t,e){return h.getBitmap(t,e)}function lt(t,e,r){return h.putBitmap(t,e,r)}function st(t){return"string"==typeof t&&(t=(t=t.replace(/deg/,"")).replace(/px/,"")),+t}var ct=/(([\w_\-]+)(\(([^\)]*)\))?)+/gi;function ut(t,e){return function(t){var e=t.map(function(t){var e=[];Object.keys(t.context).forEach(function(t,r){e[t]="n$"+K+++t+"$"});var r=Object.keys(t.context).filter(function(e){return"number"!=typeof t.context[e]&&"string"!=typeof t.context[e]&&(!Array.isArray(t.context[e])||"number"!=typeof t.context[e][0]&&"string"!=typeof t.context[e][0])}).map(function(r,n){return[e[r],JSON.stringify(t.context[r])].join(" = ")}),n=t.callback.toString().split("{");return n.shift(),(n=(n=n.join("{")).split("}")).pop(),n=n.join("}"),Object.keys(e).forEach(function(r){var i=e[r];"number"==typeof t.context[r]||"string"==typeof t.context[r]?n=n.replace(new RegExp("\\"+r,"g"),t.context[r]):!Array.isArray(t.context[r])||"number"!=typeof t.context[r][0]&&"string"!=typeof t.context[r][0]?n=n.replace(new RegExp("\\"+r,"g"),i):t.context[r].forEach(function(t,e){n=n.replace(new RegExp("\\"+r+"\\["+e+"\\]","g"),t)})}),{preCallbackString:n,preContext:r}});e.forEach(function(t,e){t.strPreContext=t.preContext.length?"const "+t.preContext+";":""});var r=e.map(function(t,e){return t.strPreContext}).join("\n\n"),n=e.map(function(t){return t.preCallbackString}).join("\n\n"),i=new Function("$pixels","$pixelIndex","$clamp","$Color"," \n let $r = $pixels[$pixelIndex], $g = $pixels[$pixelIndex+1], $b = $pixels[$pixelIndex+2], $a = $pixels[$pixelIndex+3];\n \n "+r+"\n\n "+n+"\n \n $pixels[$pixelIndex] = $r\n $pixels[$pixelIndex+1] = $g \n $pixels[$pixelIndex+2] = $b \n $pixels[$pixelIndex+3] = $a \n ");return i.$preCallbackString=n,i.$preContext=r,i}([{callback:t,context:e}])}function ht(t,e){var r=ut(t,e),n=function(t,e){};return n.userFunction=r,n}var ft=[0,1,2,3];function gt(t,e,r){ft.forEach(function(n){var i=t[e+n];t[e+n]=t[r+n],t[r+n]=i})}function vt(t){return function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};rt(e.pixels.length,e.width,function(r,n,i){t(e.pixels,r,n,i)},function(){r(e)},n)}}function dt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,e=Math.pow(t,2);return Q(1/e,e)}function pt(t,e,r,n,i,o){if(3==arguments.length){var a=arguments[2];r=a.r,n=a.g,i=a.b,o=a.a}"number"==typeof r&&(t[e]=r),"number"==typeof n&&(t[e+1]=n),"number"==typeof i&&(t[e+2]=i),"number"==typeof o&&(t[e+3]=o)}function mt(t,e,r,n){pt(t,e,r[n],r[n+1],r[n+2],r[n+3])}function yt(t){return function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=Math.round(Math.sqrt(t.length)),o=Math.floor(i/2),a=e.width,l=e.height,s=ot(e.pixels.length,e.width,e.height);vt(function(e,r,n,c){for(var u=c,h=n,f=0,g=0,v=0,d=0,p=0;p=0&&y=0&&b0&&void 0!==arguments[0]?arguments[0]:[],e=[],r=[],n=0,i=t.length;n2&&void 0!==arguments[2]?arguments[2]:{},o=t,a=0;function l(){e[a].call(null,o,function(t){o=t,function(){if(++a>=n)return void r(o);l()}()},i)}l()}}function _t(t){return wt.apply(void 0,C(t))}function St(t){for(var e=null,r=arguments.length,n=Array(r>1?r-1:0),i=1;i2&&void 0!==arguments[2]?arguments[2]:{};e(at(r,t),function(e){n(lt(r,e,t))},i)}}var Mt=p({},q,W),Ht=0,It=[],Bt=function(){function t(e,r,n){if(g(this,t),"string"!=typeof e)this.el=e;else{var i=document.createElement(e);for(var o in this.uniqId=Ht++,r&&(i.className=r),n=n||{})i.setAttribute(o,n[o]);this.el=i}}return v(t,[{key:"attr",value:function(t,e){return 1==arguments.length?this.el.getAttribute(t):(this.el.setAttribute(t,e),this)}},{key:"closest",value:function(e){for(var r=this,n=!1;!(n=r.hasClass(e));){if(!r.el.parentNode)return null;r=new t(r.el.parentNode)}return n?r:null}},{key:"removeClass",value:function(t){this.el.className=(" "+this.el.className+" ").replace(" "+t+" "," ").trim()}},{key:"hasClass",value:function(t){return!!this.el.className&&(" "+this.el.className+" ").indexOf(" "+t+" ")>-1}},{key:"addClass",value:function(t){this.hasClass(t)||(this.el.className=this.el.className+" "+t)}},{key:"toggleClass",value:function(t){this.hasClass(t)?this.removeClass(t):this.addClass(t)}},{key:"html",value:function(t){return"string"==typeof t?this.el.innerHTML=t:this.empty().append(t),this}},{key:"empty",value:function(){return this.html("")}},{key:"append",value:function(t){return"string"==typeof t?this.el.appendChild(document.createTextNode(t)):this.el.appendChild(t.el||t),this}},{key:"appendTo",value:function(t){return(t.el?t.el:t).appendChild(this.el),this}},{key:"remove",value:function(){return this.el.parentNode&&this.el.parentNode.removeChild(this.el),this}},{key:"text",value:function(){return this.el.textContent}},{key:"css",value:function(t,e){var r=this;if(2==arguments.length)this.el.style[t]=e;else if(1==arguments.length){if("string"==typeof t)return getComputedStyle(this.el)[t];var n=t||{};Object.keys(n).forEach(function(t){r.el.style[t]=n[t]})}return this}},{key:"cssFloat",value:function(t){return parseFloat(this.css(t))}},{key:"cssInt",value:function(t){return parseInt(this.css(t))}},{key:"offset",value:function(){var t=this.el.getBoundingClientRect();return{top:t.top+document.documentElement.scrollTop,left:t.left+document.documentElement.scrollLeft}}},{key:"position",value:function(){return this.el.style.top?{top:parseFloat(this.css("top")),left:parseFloat(this.css("left"))}:this.el.getBoundingClientRect()}},{key:"width",value:function(){return this.el.offsetWidth}},{key:"contentWidth",value:function(){return this.width()-this.cssFloat("padding-left")-this.cssFloat("padding-right")}},{key:"height",value:function(){return this.el.offsetHeight}},{key:"contentHeight",value:function(){return this.height()-this.cssFloat("padding-top")-this.cssFloat("padding-bottom")}},{key:"dataKey",value:function(t){return this.uniqId+"."+t}},{key:"data",value:function(t,e){if(2!=arguments.length){if(1==arguments.length)return It[this.dataKey(t)];var r=Object.keys(It),n=this.uniqId+".";return r.filter(function(t){return 0==t.indexOf(n)}).map(function(t){return It[t]})}return It[this.dataKey(t)]=e,this}},{key:"val",value:function(t){return 0==arguments.length?this.el.value:(1==arguments.length&&(this.el.value=t),this)}},{key:"int",value:function(){return parseInt(this.val(),10)}},{key:"float",value:function(){return parseFloat(this.val())}},{key:"show",value:function(){return this.css("display","block")}},{key:"hide",value:function(){return this.css("display","none")}},{key:"toggle",value:function(){return"none"==this.css("display")?this.show():this.hide()}},{key:"scrollTop",value:function(){return this.el===document.body?document.documentElement.scrollTop:this.el.scrollTop}},{key:"scrollLeft",value:function(){return this.el===document.body?document.documentElement.scrollLeft:this.el.scrollLeft}},{key:"on",value:function(t,e,r,n){return this.el.addEventListener(t,e,r,n),this}},{key:"off",value:function(t,e){return this.el.removeEventListener(t,e),this}},{key:"getElement",value:function(){return this.el}},{key:"createChild",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=new t(e,r,n);return o.css(i),this.append(o),o}}]),t}(),Rt={addEvent:function(t,e,r){t.addEventListener(e,r)},removeEvent:function(t,e,r){t.removeEventListener(e,r)},pos:function(t){return t.touches&&t.touches[0]?t.touches[0]:t}},Et=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(this,t),this.masterObj=e,this.settingObj=r}return v(t,[{key:"set",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.settingObj[t]=e||r}},{key:"init",value:function(t){if(!this.has(t)){var e=t.split("."),r=this.masterObj[e[0]]||this.masterObj,n=e.pop();if(r[n]){for(var i=arguments.length,o=Array(i>1?i-1:0),a=1;a1&&void 0!==arguments[1]?arguments[1]:"";return this.init(t,e),this.settingObj[t]||e}},{key:"has",value:function(t){return!!this.settingObj[t]}}]),t}(),At=/^(click|mouse(down|up|move|enter|leave)|key(down|up|press)|contextmenu|change|input)/gi,Ot=["Control","Shift","Alt","Meta"],Lt=function(){function t(){g(this,t),this.state=new Et(this)}return v(t,[{key:"initializeEvent",value:function(){this.initializeEventMachin()}},{key:"destroy",value:function(){this.destroyEventMachin()}},{key:"destroyEventMachin",value:function(){this.removeEventAll()}},{key:"initializeEventMachin",value:function(){this.filterProps(At).forEach(this.parseEvent.bind(this))}},{key:"filterProps",value:function(t){return Object.getOwnPropertyNames(this.__proto__).filter(function(e){return e.match(t)})}},{key:"parseEvent",value:function(t){var e=t.split(" ");this.bindingEvent(e,this[t].bind(this))}},{key:"getDefaultDomElement",value:function(t){var e=void 0;return(e=t?this[t]||window[t]:this.el||this.$el||this.$root)instanceof Bt?e.getElement():e}},{key:"getDefaultEventObject",value:function(t){var e=this,r=t.split("."),n=r.shift(),i=r.includes("Control"),o=r.includes("Shift"),a=r.includes("Alt"),l=r.includes("Meta"),s=(r=r.filter(function(t){return!1===Ot.includes(t)})).filter(function(t){return!!e[t]});return{eventName:n,isControl:i,isShift:o,isAlt:a,isMeta:l,codes:r=r.filter(function(t){return!1===s.includes(t)}).map(function(t){return t.toLowerCase()}),checkMethodList:s}}},{key:"bindingEvent",value:function(t,e){var r,n=(r=t,Array.isArray(r)?r:Array.from(r)),i=n[0],o=n[1],a=n.slice(2);o=this.getDefaultDomElement(o);var l=this.getDefaultEventObject(i);l.dom=o,l.delegate=a.join(" "),this.addEvent(l,e)}},{key:"matchPath",value:function(t,e){return t?t.matches(e)?t:this.matchPath(t.parentElement,e):null}},{key:"getBindings",value:function(){return this._bindings||this.initBindings(),this._bindings}},{key:"addBinding",value:function(t){this.getBindings().push(t)}},{key:"initBindings",value:function(){this._bindings=[]}},{key:"checkEventType",value:function(t,e){var r=this,n=!t.ctrlKey||e.isControl,i=!t.shiftKey||e.isShift,o=!t.altKey||e.isAlt,a=!t.metaKey||e.isMeta,l=!0;e.codes.length&&(l=e.codes.includes(t.code.toLowerCase())||e.codes.includes(t.key.toLowerCase()));var s=!0;return e.checkMethodList.length&&(s=e.checkMethodList.every(function(e){return r[e].call(r,t)})),n&&o&&i&&a&&l&&s}},{key:"makeCallback",value:function(t,e){var r=this;return t.delegate?function(n){if(r.checkEventType(n,t)){var i=r.matchPath(n.target||n.srcElement,t.delegate);if(i)return n.delegateTarget=i,n.$delegateTarget=new Bt(i),e(n)}}:function(n){if(r.checkEventType(n,t))return e(n)}}},{key:"addEvent",value:function(t,e){t.callback=this.makeCallback(t,e),this.addBinding(t),Rt.addEvent(t.dom,t.eventName,t.callback)}},{key:"removeEventAll",value:function(){var t=this;this.getBindings().forEach(function(e){t.removeEvent(e)}),this.initBindings()}},{key:"removeEvent",value:function(t){var e=t.eventName,r=t.dom,n=t.callback;Rt.removeEvent(r,e,n)}}]),t}(),Ft=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,Lt),v(e,[{key:"initialize",value:function(){this.$el=new Bt("div","control"),this.$hue=this.$el.createChild("div","hue"),this.$opacity=this.$el.createChild("div","opacity"),this.$controlPattern=this.$el.createChild("div","empty"),this.$controlColor=this.$el.createChild("div","color"),this.$hueContainer=this.$hue.createChild("div","hue-container"),this.$drag_bar=this.$hueContainer.createChild("div","drag-bar"),this.drag_bar_pos={},this.$opacityContainer=this.$opacity.createChild("div","opacity-container"),this.$opacityColorBar=this.$opacityContainer.createChild("div","color-bar"),this.$opacity_drag_bar=this.$opacityContainer.createChild("div","drag-bar2"),this.opacity_drag_bar_pos={}}},{key:"setBackgroundColor",value:function(t){this.$controlColor.css("background-color",t)}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){var t=this.state.get("$el.width")*this.colorpicker.currentS,e=this.state.get("$el.height")*(1-this.colorpicker.currentV);this.$drag_pointer.css({left:t+"px",top:e+"px"})}},{key:"setOpacityColorBar",value:function(t){var e=w.parse(t);e.a=0;var r=w.format(e,"rgb");e.a=1;var n=w.format(e,"rgb");this.$opacityColorBar.css("background","linear-gradient(to right, "+r+", "+n+")")}},{key:"setOpacity",value:function(t){var e,r=this.$opacityContainer.offset().left,n=r+this.state.get("$opacityContainer.width"),i=Rt.pos(t).clientX;e=in?100:(i-r)/(n-r)*100;var o=this.state.get("$opacityContainer.width")*(e/100);this.$opacity_drag_bar.css({left:o-Math.ceil(this.state.get("$opacity_drag_bar.width")/2)+"px"}),this.opacity_drag_bar_pos={x:o},this.colorpicker.setCurrentA(this.caculateOpacity()),this.colorpicker.currentFormat(),this.colorpicker.setInputColor()}},{key:"setInputColor",value:function(){this.setBackgroundColor(this.colorpicker.getFormattedColor("rgb"));var t=this.colorpicker.convertRGB(),e=w.format(t,"rgb");this.setOpacityColorBar(e)}},{key:"setColorUI",value:function(){var t=this.state.get("$hueContainer.width")*(this.colorpicker.currentH/360);this.$drag_bar.css({left:t-7.5+"px"}),this.drag_bar_pos={x:t};var e=this.state.get("$opacityContainer.width")*(this.colorpicker.currentA||0);this.$opacity_drag_bar.css({left:e-7.5+"px"}),this.opacity_drag_bar_pos={x:e}}},{key:"caculateH",value:function(){return{h:(this.drag_bar_pos||{x:0}).x/this.state.get("$hueContainer.width")*360}}},{key:"caculateOpacity",value:function(){var t=this.opacity_drag_bar_pos||{x:0},e=Math.round(t.x/this.state.get("$opacityContainer.width")*100)/100;return isNaN(e)?1:e}},{key:"EventDocumentMouseMove",value:function(t){this.isHueDown&&this.setHueColor(t),this.isOpacityDown&&this.setOpacity(t)}},{key:"EventDocumentMouseUp",value:function(t){this.isHueDown=!1,this.isOpacityDown=!1}},{key:"setControlColor",value:function(t){this.$controlColor.css("background-color",t)}},{key:"setHueColor",value:function(t){var e,r=this.$hueContainer.offset().left,n=r+this.state.get("$hueContainer.width"),i=t?Rt.pos(t).clientX:r+(n-r)*(this.colorpicker.currentH/360);e=in?100:(i-r)/(n-r)*100;var o=this.state.get("$hueContainer.width")*(e/100);this.$drag_bar.css({left:o-Math.ceil(this.state.get("$drag_bar.width")/2)+"px"}),this.drag_bar_pos={x:o};var a=S.checkHueColor(e/100);this.colorpicker.setBackgroundColor(a),this.colorpicker.setCurrentH(e/100*360),this.colorpicker.setInputColor()}},{key:"setOnlyHueColor",value:function(){var t,e=this.$hueContainer.offset().left,r=e+this.state.get("$hueContainer.width"),n=e+(r-e)*(this.colorpicker.currentH/360);t=nr?100:(n-e)/(r-e)*100;var i=this.state.get("$hueContainer.width")*(t/100);this.$drag_bar.css({left:i-Math.ceil(this.state.get("$drag_bar.width")/2)+"px"}),this.drag_bar_pos={x:i};var o=S.checkHueColor(t/100);this.colorpicker.setBackgroundColor(o),this.colorpicker.setCurrentH(t/100*360)}},{key:"mousedown $drag_bar",value:function(t){t.preventDefault(),this.isHueDown=!0}},{key:"mousedown $opacity_drag_bar",value:function(t){t.preventDefault(),this.isOpacityDown=!0}},{key:"mousedown $hueContainer",value:function(t){this.isHueDown=!0,this.setHueColor(t)}},{key:"mousedown $opacityContainer",value:function(t){this.isOpacityDown=!0,this.setOpacity(t)}}]),e}(),Pt=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,Lt),v(e,[{key:"initialize",value:function(){this.$el=new Bt("div","information hex"),this.$informationChange=this.$el.createChild("div","information-change"),this.$formatChangeButton=this.$informationChange.createChild("button","format-change-button arrow-button",{type:"button"}),this.$el.append(this.makeInputFieldHex()),this.$el.append(this.makeInputFieldRgb()),this.$el.append(this.makeInputFieldHsl()),this.format="hex"}},{key:"makeInputFieldHex",value:function(){var t=new Bt("div","information-item hex"),e=t.createChild("div","input-field hex");return this.$hexCode=e.createChild("input","input",{type:"text"}),e.createChild("div","title").html("HEX"),t}},{key:"makeInputFieldRgb",value:function(){var t=new Bt("div","information-item rgb"),e=t.createChild("div","input-field rgb-r");return this.$rgb_r=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("R"),e=t.createChild("div","input-field rgb-g"),this.$rgb_g=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("G"),e=t.createChild("div","input-field rgb-b"),this.$rgb_b=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("B"),e=t.createChild("div","input-field rgb-a"),this.$rgb_a=e.createChild("input","input",{type:"number",step:.01,min:0,max:1}),e.createChild("div","title").html("A"),t}},{key:"makeInputFieldHsl",value:function(){var t=new Bt("div","information-item hsl"),e=t.createChild("div","input-field hsl-h");return this.$hsl_h=e.createChild("input","input",{type:"number",step:1,min:0,max:360}),e.createChild("div","title").html("H"),e=t.createChild("div","input-field hsl-s"),this.$hsl_s=e.createChild("input","input",{type:"number",step:1,min:0,max:100}),e.createChild("div","postfix").html("%"),e.createChild("div","title").html("S"),e=t.createChild("div","input-field hsl-l"),this.$hsl_l=e.createChild("input","input",{type:"number",step:1,min:0,max:100}),e.createChild("div","postfix").html("%"),e.createChild("div","title").html("L"),e=t.createChild("div","input-field hsl-a"),this.$hsl_a=e.createChild("input","input",{type:"number",step:.01,min:0,max:1}),e.createChild("div","title").html("A"),t}},{key:"currentFormat",value:function(){var t=this.format||"hex";if(this.colorpicker.currentA<1&&"hex"==t){this.$el.removeClass(t),this.$el.addClass("rgb"),this.format="rgb",this.colorpicker.setInputColor()}}},{key:"setCurrentFormat",value:function(t){this.format=t,this.initFormat()}},{key:"initFormat",value:function(){var t=this.format||"hex";this.$el.removeClass("hex"),this.$el.removeClass("rgb"),this.$el.removeClass("hsl"),this.$el.addClass(t)}},{key:"nextFormat",value:function(){var t=this.format||"hex",e="hex";"hex"==t?e="rgb":"rgb"==t?e="hsl":"hsl"==t&&(e=1==this.colorpicker.currentA?"hex":"rgb"),this.$el.removeClass(t),this.$el.addClass(e),this.format=e,this.setInputColor(),this.colorpicker.changeInputColorAfterNextFormat()}},{key:"setRGBInput",value:function(t,e,r){this.$rgb_r.val(t),this.$rgb_g.val(e),this.$rgb_b.val(r),this.$rgb_a.val(this.colorpicker.currentA)}},{key:"setHSLInput",value:function(t,e,r){this.$hsl_h.val(t),this.$hsl_s.val(e),this.$hsl_l.val(r),this.$hsl_a.val(this.colorpicker.currentA)}},{key:"getHexFormat",value:function(){return w.format({r:this.$rgb_r.int(),g:this.$rgb_g.int(),b:this.$rgb_b.int()},"hex",this.colorpicker.opt.color)}},{key:"getRgbFormat",value:function(){return w.format({r:this.$rgb_r.int(),g:this.$rgb_g.int(),b:this.$rgb_b.int(),a:this.$rgb_a.float()},"rgb",this.colorpicker.opt.color)}},{key:"getHslFormat",value:function(){return w.format({h:this.$hsl_h.val(),s:this.$hsl_s.val(),l:this.$hsl_l.val(),a:this.$hsl_a.float()},"hsl",this.colorpicker.opt.color)}},{key:"convertRGB",value:function(){return this.colorpicker.convertRGB()}},{key:"convertHEX",value:function(){return this.colorpicker.convertHEX()}},{key:"convertHSL",value:function(){return this.colorpicker.convertHSL()}},{key:"getFormattedColor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"hex"==(t=t||this.getFormat())?this.$hexCode.val():"rgb"==t?this.getRgbFormat(e):"hsl"==t?this.getHslFormat(e):void 0}},{key:"getFormat",value:function(){return this.format||"hex"}},{key:"setInputColor",value:function(){var t=this.getFormat(),e=null;if("hex"==t){this.$hexCode.val(this.convertHEX());e=this.convertRGB();this.setRGBInput(e.r,e.g,e.b,e.a)}else if("rgb"==t){e=this.convertRGB();this.setRGBInput(e.r,e.g,e.b,e.a),this.$hexCode.val(this.convertHEX())}else if("hsl"==t){var r=this.convertHSL();this.setHSLInput(r.h,r.s,r.l,r.a)}}},{key:"checkNumberKey",value:function(t){return Rt.checkNumberKey(t)}},{key:"checkNotNumberKey",value:function(t){return!Rt.checkNumberKey(t)}},{key:"changeRgbColor",value:function(){this.colorpicker.changeInformationColor(this.getRgbFormat())}},{key:"changeHslColor",value:function(){this.colorpicker.changeInformationColor(this.getHslFormat())}},{key:"change $rgb_r",value:function(t){this.changeRgbColor()}},{key:"change $rgb_g",value:function(t){this.changeRgbColor()}},{key:"change $rgb_b",value:function(t){this.changeRgbColor()}},{key:"change $rgb_a",value:function(t){this.changeRgbColor()}},{key:"change $hsl_h",value:function(t){this.changeHslColor()}},{key:"change $hsl_s",value:function(t){this.changeHslColor()}},{key:"change $hsl_l",value:function(t){this.changeHslColor()}},{key:"change $hsl_a",value:function(t){this.changeHslColor()}},{key:"keydown $hexCode",value:function(t){if(t.which<65||t.which>70)return this.checkNumberKey(t)}},{key:"keyup $hexCode",value:function(t){var e=this.$hexCode.val();"#"==e.charAt(0)&&7==e.length&&(this.colorpicker.changeInformationColor(e),this.setInputColor())}},{key:"click $formatChangeButton",value:function(t){this.nextFormat()}},{key:"refresh",value:function(){}}]),e}(),Gt=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,Lt),v(e,[{key:"initialize",value:function(){this.$el=new Bt("div","color"),this.$saturation=this.$el.createChild("div","saturation"),this.$value=this.$saturation.createChild("div","value"),this.$drag_pointer=this.$value.createChild("div","drag-pointer")}},{key:"setBackgroundColor",value:function(t){this.$el.css("background-color",t)}},{key:"refresh",value:function(){this.setColorUI()}},{key:"caculateSV",value:function(){var t=this.drag_pointer_pos||{x:0,y:0},e=this.state.get("$el.width"),r=this.state.get("$el.height");return{s:t.x/e,v:(r-t.y)/r,width:e,height:r}}},{key:"setColorUI",value:function(){var t=this.state.get("$el.width")*this.colorpicker.currentS,e=this.state.get("$el.height")*(1-this.colorpicker.currentV);this.$drag_pointer.css({left:t-5+"px",top:e-5+"px"}),this.drag_pointer_pos={x:t,y:e}}},{key:"setMainColor",value:function(t){t.preventDefault();var e=this.$el.position(),r=this.state.get("$el.contentWidth"),n=this.state.get("$el.contentHeight"),i=t.clientX-e.left,o=t.clientY-e.top;i<0?i=0:i>r&&(i=r),o<0?o=0:o>n&&(o=n),this.$drag_pointer.css({left:i-5+"px",top:o-5+"px"}),this.drag_pointer_pos={x:i,y:o},this.colorpicker.caculateHSV(),this.colorpicker.setInputColor()}},{key:"EventDocumentMouseUp",value:function(t){this.isDown=!1}},{key:"EventDocumentMouseMove",value:function(t){this.isDown&&this.setMainColor(t)}},{key:"mousedown",value:function(t){this.isDown=!0,this.setMainColor(t)}},{key:"mouseup",value:function(t){this.isDown=!1}}]),e}(),Tt="data-colorsets-index",Nt=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,Lt),v(e,[{key:"initialize",value:function(){this.$el=new Bt("div","color-chooser");var t=this.$el.createChild("div","color-chooser-container"),e=t.createChild("div","colorsets-item colorsets-item-header");e.createChild("h1","title").html("Color Paletts"),this.$toggleButton=e.createChild("span","items").html("×"),this.$colorsetsList=t.createChild("div","colorsets-list"),this.refresh()}},{key:"refresh",value:function(){this.$colorsetsList.html(this.makeColorSetsList())}},{key:"makeColorItemList",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=new Bt("div"),n=0;n1&&void 0!==arguments[1]&&arguments[1];if("object"==(void 0===t?"undefined":f(t))){if(!t.r||!t.g||!t.b)return;e?this.callbackColorValue(w.format(t,"hex")):this.initColor(w.format(t,"hex"))}else"string"==typeof t&&(e?this.callbackColorValue(t):this.initColor(t))}},{key:"getColor",value:function(t){this.caculateHSV();var e=this.convertRGB();return t?w.format(e,t):e}},{key:"definePositionForArrow",value:function(t,e,r){}},{key:"definePosition",value:function(t){var e=this.$root.width(),r=this.$root.height(),n=t.left-this.$body.scrollLeft();e+n>window.innerWidth&&(n-=e+n-window.innerWidth),n<0&&(n=0);var i=t.top-this.$body.scrollTop();r+i>window.innerHeight&&(i-=r+i-window.innerHeight),i<0&&(i=0),this.$root.css({left:n+"px",top:i+"px"})}},{key:"getInitalizePosition",value:function(){return"inline"==this.opt.position?{position:"relative",left:"auto",top:"auto",display:"inline-block"}:{position:"fixed",left:"-10000px",top:"-10000px"}}},{key:"show",value:function(t,e,r){this.destroy(),this.initializeEvent(),this.$root.appendTo(this.$body),this.$root.css(this.getInitalizePosition()).show(),this.definePosition(t),this.isColorPickerShow=!0,this.isShortCut=t.isShortCut||!1,this.initColor(e),this.colorpickerCallback=r,this.hideDelay=t.hideDelay||2e3,this.hideDelay>0&&this.setHideDelay(this.hideDelay)}},{key:"setHideDelay",value:function(t){var e=this;t=t||0,this.$root.off("mouseenter"),this.$root.off("mouseleave"),this.$root.on("mouseenter",function(){clearTimeout(e.timerCloseColorPicker)}),this.$root.on("mouseleave",function(){clearTimeout(e.timerCloseColorPicker),e.timerCloseColorPicker=setTimeout(e.hide.bind(e),t)}),clearTimeout(this.timerCloseColorPicker),this.timerCloseColorPicker=setTimeout(this.hide.bind(this),t)}},{key:"hide",value:function(){this.isColorPickerShow&&(this.destroy(),this.$root.hide(),this.$root.remove(),this.isColorPickerShow=!1)}},{key:"convertRGB",value:function(){return w.HSVtoRGB(this.currentH,this.currentS,this.currentV)}},{key:"convertHEX",value:function(){return w.format(this.convertRGB(),"hex")}},{key:"convertHSL",value:function(){return w.HSVtoHSL(this.currentH,this.currentS,this.currentV)}},{key:"getCurrentColor",value:function(){return this.information.getFormattedColor()}},{key:"getFormattedColor",value:function(t){if("rgb"==(t=t||"hex"))return(r=this.convertRGB()).a=this.currentA,w.format(r,"rgb");if("hsl"==t){var e=this.convertHSL();return e.a=this.currentA,w.format(e,"hsl")}var r=this.convertRGB();return w.format(r,"hex")}},{key:"setInputColor",value:function(t){this.information.setInputColor(t),this.control.setInputColor(t),this.callbackColorValue()}},{key:"changeInputColorAfterNextFormat",value:function(){this.control.setInputColor(),this.callbackColorValue()}},{key:"callbackColorValue",value:function(t){t=t||this.getCurrentColor(),isNaN(this.currentA)||("function"==typeof this.opt.onChange&&this.opt.onChange.call(this,t),"function"==typeof this.colorpickerCallback&&this.colorpickerCallback(t))}},{key:"caculateHSV",value:function(){var t=this.palette.caculateSV(),e=this.control.caculateH(),r=t.s,n=t.v,i=e.h;0==t.width&&(i=0,r=0,n=0),this.currentH=i,this.currentS=r,this.currentV=n}},{key:"setColorUI",value:function(){this.control.setColorUI(),this.palette.setColorUI()}},{key:"setCurrentHSV",value:function(t,e,r,n){this.currentA=n,this.currentH=t,this.currentS=e,this.currentV=r}},{key:"setCurrentH",value:function(t){this.currentH=t}},{key:"setCurrentA",value:function(t){this.currentA=t}},{key:"setBackgroundColor",value:function(t){this.palette.setBackgroundColor(t)}},{key:"setCurrentFormat",value:function(t){this.format=t,this.information.setCurrentFormat(t)}},{key:"getHSV",value:function(t){return"hsl"==t.type?w.HSLtoHSV(t):w.RGBtoHSV(t)}},{key:"initColor",value:function(t,e){var r=t||"#FF0000",n=w.parse(r);e=e||n.type,this.setCurrentFormat(e);var i=this.getHSV(n);this.setCurrentHSV(i.h,i.s,i.v,n.a),this.setColorUI(),this.setHueColor(),this.setInputColor()}},{key:"changeInformationColor",value:function(t){var e=t||"#FF0000",r=w.parse(e),n=this.getHSV(r);this.setCurrentHSV(n.h,n.s,n.v,r.a),this.setColorUI(),this.setHueColor(),this.control.setInputColor(),this.callbackColorValue()}},{key:"setHueColor",value:function(){this.control.setOnlyHueColor()}},{key:"checkColorPickerClass",value:function(t){var e=new Bt(t).closest("codemirror-colorview"),r=new Bt(t).closest("codemirror-colorpicker"),n=new Bt(t).closest("CodeMirror");t.nodeName;return!!(r||e||n)}},{key:"checkInHtml",value:function(t){return"HTML"==t.nodeName}},{key:"mouseup document",value:function(t){this.palette.EventDocumentMouseUp(t),this.control.EventDocumentMouseUp(t),this.checkInHtml(t.target)||0==this.checkColorPickerClass(t.target)&&this.hide()}},{key:"mousemove document",value:function(t){this.palette.EventDocumentMouseMove(t),this.control.EventDocumentMouseMove(t)}},{key:"initializeEvent",value:function(){this.initializeEventMachin(),this.palette.initializeEvent(),this.control.initializeEvent(),this.information.initializeEvent(),this.currentColorSets.initializeEvent(),this.colorSetsChooser.initializeEvent(),this.contextMenu.initializeEvent()}},{key:"currentFormat",value:function(){this.information.currentFormat()}},{key:"toggleColorChooser",value:function(){this.colorSetsChooser.toggle()}},{key:"refreshColorSetsChooser",value:function(){this.colorSetsChooser.refresh()}},{key:"getColorSetsList",value:function(){return this.colorSetsList.getColorSetsList()}},{key:"setCurrentColorSets",value:function(t){this.colorSetsList.setCurrentColorSets(t),this.currentColorSets.refresh()}},{key:"setColorSets",value:function(t){this.colorSetsList.setUserList(t)}},{key:"destroy",value:function(){m(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this.control.destroy(),this.palette.destroy(),this.information.destroy(),this.colorSetsChooser.destroy(),this.colorSetsList.destroy(),this.currentColorSets.destroy(),this.contextMenu.destroy(),this.colorpickerCallback=void 0}}]),e}(),Xt="codemirror-colorview",Yt="codemirror-colorview-background",qt=["comment"];function Kt(t,e){"setValue"==e.origin?(t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update()):t.state.colorpicker.style_color_update(t.getCursor().line)}function Wt(t,e){t.state.colorpicker.isUpdate||(t.state.colorpicker.isUpdate=!0,t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update())}function Zt(t,e){Kt(t,{origin:"setValue"})}function Jt(t,e){t.state.colorpicker.keyup(e)}function Qt(t,e){t.state.colorpicker.is_edit_mode()&&t.state.colorpicker.check_mousedown(e)}function te(t,e){Kt(t,{origin:"setValue"})}function ee(t){t.state.colorpicker.close_color_picker()}var re=function(){function t(e,r){g(this,t),r="boolean"==typeof r?{mode:"edit"}:Object.assign({mode:"edit"},r||{}),this.opt=r,this.cm=e,this.markers={},this.excluded_token=this.opt.excluded_token||qt,this.opt.colorpicker?this.colorpicker=this.opt.colorpicker(this.opt):this.colorpicker=new Ut(this.opt),this.init_event()}return v(t,[{key:"init_event",value:function(){var t,e,r,n,i;this.cm.on("mousedown",Qt),this.cm.on("keyup",Jt),this.cm.on("change",Kt),this.cm.on("update",Wt),this.cm.on("refresh",Zt),this.onPasteCallback=(t=this.cm,e=te,function(r){e.call(this,t,r)}),this.cm.getWrapperElement().addEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.on("scroll",(r=ee,n=50,i=void 0,function(t,e){i&&clearTimeout(i),i=setTimeout(function(){r(t,e)},n||300)}))}},{key:"is_edit_mode",value:function(){return"edit"==this.opt.mode}},{key:"is_view_mode",value:function(){return"view"==this.opt.mode}},{key:"destroy",value:function(){this.cm.off("mousedown",Qt),this.cm.off("keyup",Jt),this.cm.off("change",Kt),this.cm.getWrapperElement().removeEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.off("scroll")}},{key:"hasClass",value:function(t,e){return!!t.className&&(" "+t.className+" ").indexOf(" "+e+" ")>-1}},{key:"check_mousedown",value:function(t){this.hasClass(t.target,Yt)?this.open_color_picker(t.target.parentNode):this.close_color_picker()}},{key:"popup_color_picker",value:function(t){var e=this.cm.getCursor(),r=this,n={lineNo:e.line,ch:e.ch,color:t||"#FFFFFF",isShortCut:!0};Object.keys(this.markers).forEach(function(t){if(("#"+t).indexOf("#"+n.lineNo+":")>-1){var e=r.markers[t];e.ch<=n.ch&&n.ch<=e.ch+e.color.length&&(n.ch=e.ch,n.color=e.color,n.nameColor=e.nameColor)}}),this.open_color_picker(n)}},{key:"open_color_picker",value:function(t){var e=t.lineNo,r=t.ch,n=t.nameColor,i=t.color;if(this.colorpicker){var o=this,a=i,l=this.cm.charCoords({line:e,ch:r});this.colorpicker.show({left:l.left,top:l.bottom,isShortCut:t.isShortCut||!1,hideDelay:o.opt.hideDelay||2e3},n||i,function(t){o.cm.replaceRange(t,{line:e,ch:r},{line:e,ch:r+a.length},"*colorpicker"),a=t})}}},{key:"close_color_picker",value:function(t){this.colorpicker&&this.colorpicker.hide()}},{key:"key",value:function(t,e){return[t,e].join(":")}},{key:"keyup",value:function(t){this.colorpicker&&("Escape"==t.key?this.colorpicker.hide():0==this.colorpicker.isShortCut&&this.colorpicker.hide())}},{key:"init_color_update",value:function(){this.markers={}}},{key:"style_color_update",value:function(t){if(t)this.match(t);else for(var e=this.cm.lineCount(),r=0;r-1)&&(delete this.markers[l],i[o].marker.clear())}}},{key:"match_result",value:function(t){return w.matches(t.text)}},{key:"submatch",value:function(t,e){var r=this;this.empty_marker(t,e);var n={next:0};this.match_result(e).forEach(function(i){r.render(n,t,e,i.color,i.nameColor)})}},{key:"match",value:function(t){var e=this.cm.getLineHandle(t),r=this;this.cm.operation(function(){r.submatch(t,e)})}},{key:"make_element",value:function(){var t=document.createElement("div");return t.className=Xt,this.is_edit_mode()?t.title="open color picker":t.title="",t.back_element=this.make_background_element(),t.appendChild(t.back_element),t}},{key:"make_background_element",value:function(){var t=document.createElement("div");return t.className=Yt,t}},{key:"set_state",value:function(t,e,r,n){var i=this.create_marker(t,e);return i.lineNo=t,i.ch=e,i.color=r,i.nameColor=n,i}},{key:"create_marker",value:function(t,e){var r=this.key(t,e);return this.markers[r]||(this.markers[r]=this.make_element()),this.markers[r]}},{key:"has_marker",value:function(t,e){var r=this.key(t,e);return!!this.markers[r]}},{key:"update_element",value:function(t,e){t.back_element.style.backgroundColor=e}},{key:"set_mark",value:function(t,e,r){this.cm.setBookmark({line:t,ch:e},{widget:r,handleMouseEvents:!0})}},{key:"is_excluded_token",value:function(t,e){for(var r=this.cm.getTokenTypeAt({line:t,ch:e}),n=0,i=0,o=this.excluded_token.length;i0}},{key:"render",value:function(t,e,r,n,i){var o=r.text.indexOf(n,t.next);if(!0!==this.is_excluded_token(e,o)){if(t.next=o+n.length,this.has_marker(e,o))return this.update_element(this.create_marker(e,o),i||n),void this.set_state(e,o,n,i);var a=this.create_marker(e,o);this.update_element(a,i||n),this.set_state(e,o,n,i||n),this.set_mark(e,o,a)}}}]),t}();return t&&t.defineOption("colorpicker",!1,function(e,r,n){n&&n!=t.Init&&e.state.colorpicker&&(e.state.colorpicker.destroy(),e.state.colorpicker=null),r&&(e.state.colorpicker=new re(e,r))}),{Color:w,ColorNames:r,ColorPicker:Ut,ImageFilter:Mt,HueColor:S,Canvas:h,ImageLoader:$}}(CodeMirror); +var CodeMirrorColorPicker=function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",aqua:"rgb(0, 255, 255)",aquamarine:"rgb(127, 255, 212)",azure:"rgb(240, 255, 255)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",black:"rgb(0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb(0, 0, 255)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",burlywood:"rgb(222, 184, 135)",cadetblue:"rgb(95, 158, 160)",chartreuse:"rgb(127, 255, 0)",chocolate:"rgb(210, 105, 30)",coral:"rgb(255, 127, 80)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",crimson:"rgb(237, 20, 61)",cyan:"rgb(0, 255, 255)",darkblue:"rgb(0, 0, 139)",darkcyan:"rgb(0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgray:"rgb(169, 169, 169)",darkgrey:"rgb(169, 169, 169)",darkgreen:"rgb(0, 100, 0)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb(85, 107, 47)",darkorange:"rgb(255, 140, 0)",darkorchid:"rgb(153, 50, 204)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkslateblue:"rgb(72, 61, 139)",darkslategray:"rgb(47, 79, 79)",darkslategrey:"rgb(47, 79, 79)",darkturquoise:"rgb(0, 206, 209)",darkviolet:"rgb(148, 0, 211)",deeppink:"rgb(255, 20, 147)",deepskyblue:"rgb(0, 191, 255)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb(30, 144, 255)",firebrick:"rgb(178, 34, 34)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb(34, 139, 34)",fuchsia:"rgb(255, 0, 255)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",goldenrod:"rgb(218, 165, 32)",gray:"rgb(128, 128, 128)",grey:"rgb(128, 128, 128)",green:"rgb(0, 128, 0)",greenyellow:"rgb(173, 255, 47)",honeydew:"rgb(240, 255, 240)",hotpink:"rgb(255, 105, 180)",indianred:"rgb(205, 92, 92)",indigo:"rgb(75, 0, 130)",ivory:"rgb(255, 255, 240)",khaki:"rgb(240, 230, 140)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lightblue:"rgb(173, 216, 230)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgreen:"rgb(144, 238, 144)",lightgray:"rgb(211, 211, 211)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightsalmon:"rgb(255, 160, 122)",lightseagreen:"rgb(32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightyellow:"rgb(255, 255, 224)",lime:"rgb(0, 255, 0)",limegreen:"rgb(50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",maroon:"rgb(128, 0, 0)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb(0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumpurple:"rgb(147, 112, 219)",mediumseagreen:"rgb(60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb(0, 250, 154)",mediumturquoise:"rgb(72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb(25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navy:"rgb(0, 0, 128)",oldlace:"rgb(253, 245, 230)",olive:"rgb(128, 128, 0)",olivedrab:"rgb(107, 142, 35)",orange:"rgb(255, 165, 0)",orangered:"rgb(255, 69, 0)",orchid:"rgb(218, 112, 214)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",paleturquoise:"rgb(175, 238, 238)",palevioletred:"rgb(219, 112, 147)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",plum:"rgb(221, 160, 221)",powderblue:"rgb(176, 224, 230)",purple:"rgb(128, 0, 128)",rebeccapurple:"rgb(102, 51, 153)",red:"rgb(255, 0, 0)",rosybrown:"rgb(188, 143, 143)",royalblue:"rgb(65, 105, 225)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb(46, 139, 87)",seashell:"rgb(255, 245, 238)",sienna:"rgb(160, 82, 45)",silver:"rgb(192, 192, 192)",skyblue:"rgb(135, 206, 235)",slateblue:"rgb(106, 90, 205)",slategray:"rgb(112, 128, 144)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",springgreen:"rgb(0, 255, 127)",steelblue:"rgb(70, 130, 180)",tan:"rgb(210, 180, 140)",teal:"rgb(0, 128, 128)",thistle:"rgb(216, 191, 216)",tomato:"rgb(255, 99, 71)",turquoise:"rgb(64, 224, 208)",violet:"rgb(238, 130, 238)",wheat:"rgb(245, 222, 179)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellowgreen:"rgb(154, 205, 50)",transparent:"rgba(0, 0, 0, 0)"};var r={isColorName:function(t){return!!e[t]},getColorByName:function(t){return e[t]}};function n(t,e){if(t.length!==e.length)return!1;for(var r=0,n=t.length;r0)h=l(c);else h=e[Math.floor(a()*e.length)];o=!n(h,u),i[s]=h}return o}function u(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"linear";t=t,e=e||Math.max(2,Math.ceil(Math.sqrt(t.length/2)));var l=r||"euclidean";"string"==typeof l&&(l=i[l]);for(var u=0,h=function(){return(u=(9301*u+49297)%233280)/233280},f=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"linear";return o[r](t.length,e).map(function(e){return t[e]})}(t,e,a),g=!0,v=0;g;){if(g=c(e,t,s(e,t,f,l),f,!1,h),++v%n==0)break}return f}var h={create:function(t,e){var r=document.createElement("canvas");return r.width=t||0,r.height=e||0,r},drawPixels:function(t){var e=this.create(t.width,t.height),r=e.getContext("2d"),n=r.getImageData(0,0,e.width,e.height);return n.data.set(t.pixels),r.putImageData(n,0,0),e},createHistogram:function(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{black:!0,red:!1,green:!1,blue:!1},o=this.create(t,e),a=o.getContext("2d");a.clearRect(0,0,t,e),a.fillStyle="white",a.fillRect(0,0,t,e),a.globalAlpha=.7;var l={black:!1};i.black?l.black=!1:l.black=!0,i.red?l.red=!1:l.red=!0,i.green?l.green=!1:l.green=!0,i.blue?l.blue=!1:l.blue=!0,Object.keys(r).forEach(function(n){if(!l[n]){var i=r[n],o=Math.max.apply(Math,i),s=t/i.length;a.fillStyle=n,i.forEach(function(t,r){var n=e*(t/o),i=r*s;a.fillRect(i,e-n,s,n)})}}),"function"==typeof n&&n(o)},getHistogram:function(t){for(var e,r,n=new Array(256),i=new Array(256),o=new Array(256),a=new Array(256),l=0;l<256;l++)n[l]=0,i[l]=0,o[l]=0,a[l]=0;return r=function(t,e){var r=Math.round(w.brightness(t[e],t[e+1],t[e+2]));n[r]++,i[t[e]]++,o[t[e+1]]++,a[t[e+2]]++},function(t,e){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};g(this,t),this.isLoaded=!1,this.imageUrl=e,this.opt=r,this.initialize()}return v(t,[{key:"initialize",value:function(){this.canvas=this.createCanvas(),this.context=this.canvas.getContext("2d")}},{key:"createCanvas",value:function(){return document.createElement("canvas")}},{key:"load",value:function(t){this.loadImage(t)}},{key:"loadImage",value:function(t){var e=this,r=this.context,n=new Image;n.onload=function(){var i=n.height/n.width;e.opt.canvasWidth&&e.opt.canvasHeight?(e.canvas.width=e.opt.canvasWidth,e.canvas.height=e.opt.canvasHeight):(e.canvas.width=e.opt.maxWidth?e.opt.maxWidth:n.width,e.canvas.height=e.canvas.width*i),r.drawImage(n,0,0,n.width,n.height,0,0,e.canvas.width,e.canvas.height),e.isLoaded=!0,t&&t()},this.getImageUrl(function(t){n.src=t})}},{key:"getImageUrl",value:function(t){if("string"==typeof this.imageUrl)return t(this.imageUrl);if(this.imageUrl instanceof Blob){var e=new FileReader;e.onload=function(e){t(e.target.result)},e.readAsDataURL(this.imageUrl)}}},{key:"getRGBA",value:function(t,e,r,n){return[t,e,r,n]}},{key:"toArray",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=n.width,o=n.height,a=new Uint8ClampedArray(n.data);t||(t=function(t,e){e(t)}),t({pixels:a,width:i,height:o},function(t){var n=h.drawPixels(t);"canvas"==r.returnTo?e(n):e(n.toDataURL(r.outputFormat||"image/png"))},r)}},{key:"toHistogram",value:function(t){var e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),r=e.width,n=e.height,i={pixels:new Uint8ClampedArray(e.data),width:r,height:n};return h.getHistogram(i)}},{key:"toRGB",value:function(){for(var t=this.context.getImageData(0,0,this.canvas.width,this.canvas.height).data,e=[],r=0,n=t.length;r-1||e[i].indexOf("rgb")>-1||e[i].indexOf("hsl")>-1)n.push({color:e[i]});else{var a=r.getColorByName(e[i]);a&&n.push({color:e[i],nameColor:a})}var l={next:0};return n.forEach(function(e){var r=t.indexOf(e.color,l.next);e.startIndex=r,e.endIndex=r+e.color.length,l.next=e.endIndex}),n},convertMatches:function(t){var e=this.matches(t);return e.forEach(function(e,r){t=t.replace(e.color,"@"+r)}),{str:t,matches:e}},convertMatchesArray:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",",n=this.convertMatches(t);return n.str.split(r).map(function(t,r){return t=e.trim(t),n.matches[r]&&(t=t.replace("@"+r,n.matches[r].color)),t})},reverseMatches:function(t,e){return e.forEach(function(e,r){t=t.replace("@"+r,e.color)}),t},trim:function(t){return t.replace(/^\s+|\s+$/g,"")},round:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.round(t*e)/e},format:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgba(0, 0, 0, 0)";return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),"hex"==e?this.hex(t):"rgb"==e?this.rgb(t,r):"hsl"==e?this.hsl(t):t},hex:function(t){Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]});var e=t.r.toString(16);t.r<16&&(e="0"+e);var r=t.g.toString(16);t.g<16&&(r="0"+r);var n=t.b.toString(16);return t.b<16&&(n="0"+n),"#"+e+r+n},rgb:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgba(0, 0, 0, 0)";if(Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),void 0!==t)return 1==t.a||void 0===t.a?isNaN(t.r)?e:"rgb("+t.r+","+t.g+","+t.b+")":"rgba("+t.r+","+t.g+","+t.b+","+t.a+")"},hsl:function(t){return Array.isArray(t)&&(t={r:t[0],g:t[1],b:t[2],a:t[3]}),1==t.a||void 0===t.a?"hsl("+t.h+","+t.s+"%,"+t.l+"%)":"hsla("+t.h+","+t.s+"%,"+t.l+"%,"+t.a+")"},parse:function(t){if("string"==typeof t){if(r.isColorName(t)&&(t=r.getColorByName(t)),t.indexOf("rgb(")>-1){for(var e=0,n=(o=t.replace("rgb(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("rgba(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("hsl(","").replace(")","").split(",")).length;e-1){for(e=0,n=(o=t.replace("hsla(","").replace(")","").split(",")).length;e>16,g:(65280&t)>>8,b:(255&t)>>0,a:1};return i=Object.assign(i,this.RGBtoHSL(i))}if(0<=t&&t<=4294967295){i={type:"hex",r:(4278190080&t)>>24,g:(16711680&t)>>16,b:(65280&t)>>8,a:(255&t)/255};return i=Object.assign(i,this.RGBtoHSL(i))}}return t},HSVtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=t,o=r;360==i&&(i=0);var a=e*o,l=a*(1-Math.abs(i/60%2-1)),s=o-a,c=[];return 0<=i&&i<60?c=[a,l,0]:60<=i&&i<120?c=[l,a,0]:120<=i&&i<180?c=[0,a,l]:180<=i&&i<240?c=[0,l,a]:240<=i&&i<300?c=[l,0,a]:300<=i&&i<360&&(c=[a,0,l]),{r:this.round(255*(c[0]+s)),g:this.round(255*(c[1]+s)),b:this.round(255*(c[2]+s))}},RGBtoHSV:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=Math.max(i,o,a),s=l-Math.min(i,o,a),c=0;0==s?c=0:l==i?c=(o-a)/s%6*60:l==o?c=60*((a-i)/s+2):l==a&&(c=60*((i-o)/s+4)),c<0&&(c=360+c);return{h:c,s:0==l?0:s/l,v:l}},HSVtoHSL:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.v}var i=this.HSVtoRGB(t,e,r);return this.RGBtoHSL(i.r,i.g,i.b)},RGBtoCMYK:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255,l=1-Math.max(i,o,a);return{c:(1-i-l)/(1-l),m:(1-o-l)/(1-l),y:(1-a-l)/(1-l),k:l}},CMYKtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.c,e=i.m,r=i.y,n=i.k}return{r:255*(1-t)*(1-n),g:255*(1-e)*(1-n),b:255*(1-r)*(1-n)}},RGBtoHSL:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}t/=255,e/=255,r/=255;var i,o,a=Math.max(t,e,r),l=Math.min(t,e,r),s=(a+l)/2;if(a==l)i=o=0;else{var c=a-l;switch(o=s>.5?c/(2-a-l):c/(a+l),a){case t:i=(e-r)/c+(e1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t},HSLtoHSV:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,n.v}var i=this.HSLtoRGB(t,e,r);return this.RGBtoHSV(i.r,i.g,i.b)},HSLtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.h,e=n.s,r=n.l}var i,o,a;if(t/=360,r/=100,0==(e/=100))i=o=a=r;else{var l=r<.5?r*(1+e):r+e-r*e,s=2*r-l;i=this.HUEtoRGB(s,l,t+1/3),o=this.HUEtoRGB(s,l,t),a=this.HUEtoRGB(s,l,t-1/3)}return{r:this.round(255*i),g:this.round(255*o),b:this.round(255*a)}},c:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray((t+e+r)/3>90?0:255)},gray:function(t){return{r:t,g:t,b:t}},RGBtoSimpleGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray(Math.ceil((t+e+r)/3))},RGBtoGray:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.gray(this.RGBtoYCrCb(t,e,r).y)},brightness:function(t,e,r){return Math.ceil(.2126*t+.7152*e+.0722*r)},RGBtoYCrCb:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=this.brightness(t,e,r);return{y:i,cr:.713*(t-i),cb:.564*(r-i)}},YCrCbtoRGB:function(t,e,r,n){if(1==arguments.length){var i=arguments[0];t=i.y,e=i.cr,r=i.cb;n=(n=i.bit)||0}var o=t+1.402*(e-n),a=t-.344*(r-n)-.714*(e-n),l=t+1.772*(r-n);return{r:Math.ceil(o),g:Math.ceil(a),b:Math.ceil(l)}},ReverseRGB:function(t){return t>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t},XYZtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.x,e=n.y,r=n.z}var i=t/100,o=e/100,a=r/100,l=3.2406*i+-1.5372*o+-.4986*a,s=-.9689*i+1.8758*o+.0415*a,c=.0557*i+-.204*o+1.057*a;return l=this.ReverseRGB(l),s=this.ReverseRGB(s),c=this.ReverseRGB(c),{r:this.round(255*l),g:this.round(255*s),b:this.round(255*c)}},PivotRGB:function(t){return 100*(t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)},RGBtoXYZ:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}var i=t/255,o=e/255,a=r/255;return{x:.4124*(i=this.PivotRGB(i))+.3576*(o=this.PivotRGB(o))+.1805*(a=this.PivotRGB(a)),y:.2126*i+.7152*o+.0722*a,z:.0193*i+.1192*o+.9505*a}},ReverseXyz:function(t){return Math.pow(t,3)>.008856?Math.pow(t,3):(t-16/116)/7.787},LABtoXYZ:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}var i=(t+16)/116,o=e/500+i,a=i-r/200;return i=this.ReverseXyz(i),{x:95.047*(o=this.ReverseXyz(o)),y:100*i,z:108.883*(a=this.ReverseXyz(a))}},PivotXyz:function(t){return t>.008856?Math.pow(t,1/3):(7.787*t+16)/116},XYZtoLAB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.x,e=n.y,r=n.z}var i=t/95.047,o=e/100,a=r/108.883;return i=this.PivotXyz(i),{l:116*(o=this.PivotXyz(o))-16,a:500*(i-o),b:200*(o-(a=this.PivotXyz(a)))}},RGBtoLAB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.r,e=n.g,r=n.b}return this.XYZtoLAB(this.RGBtoXYZ(t,e,r))},LABtoRGB:function(t,e,r){if(1==arguments.length){var n=arguments[0];t=n.l,e=n.a,r=n.b}return this.XYZtoRGB(this.LABtoXYZ(t,e,r))},blend:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex",i=this.parse(t),o=this.parse(e);return this.interpolateRGB(i,o,r,n)},mix:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex";return this.blend(t,e,r,n)},contrast:function(t){t=this.parse(t);var e=(Math.round(299*t.r)+Math.round(587*t.g)+Math.round(114*t.b))/1e3;return e},contrastColor:function(t){return this.contrast(t)>=128?"black":"white"},interpolateRGB:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hex",i={r:this.round(t.r+(e.r-t.r)*r),g:this.round(t.g+(e.g-t.g)*r),b:this.round(t.b+(e.b-t.b)*r),a:this.round(t.a+(e.a-t.a)*r,100)};return this.format(i,i.a<1?"rgb":n)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(!t)return[];"string"==typeof t&&(t=this.convertMatchesArray(t));for(var r=(t=t||[]).length,n=[],i=0;i0){var n=(1-t.filter(function(t){return"*"!=t[1]&&1!=t[1]}).map(function(t){return t[1]}).reduce(function(t,e){return t+e},0))/r;t.forEach(function(e,r){"*"==e[1]&&r>0&&(t.length-1==r||(e[1]=n))})}return t},gradient:function(t){for(var e=[],r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:10)-((t=this.parseGradient(t)).length-1),n=r,i=1,o=t.length;i1&&void 0!==arguments[1]?arguments[1]:"h",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:9,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"rgb",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:100,l=this.parse(t),s=this.RGBtoHSV(l),c=(o-i)*a/r,u=[],h=1;h<=r;h++)s[e]=Math.abs((a-c*h)/a),u.push(this.format(this.HSVtoRGB(s),n));return u},scaleH:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:360;return this.scaleHSV(t,"h",e,r,n,i,1)},scaleS:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return this.scaleHSV(t,"s",e,r,n,i,100)},scaleV:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"rgb",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;return this.scaleHSV(t,"v",e,r,n,i,100)},palette:function(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hex";return t.length>r&&(t=u(t,r)),t.map(function(t){return e.format(t,n)})},ImageToRGB:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments[2];if(r){if(r){var n;(n=new $(t,e)).loadImage(function(){"function"==typeof r&&r(n.toRGB())})}}else(n=new $(t)).loadImage(function(){"function"==typeof e&&e(n.toRGB())})},ImageToCanvas:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"},i=new $(t);i.loadImage(function(){i.toArray(e,function(t){"function"==typeof r&&r(t)},Object.assign({returnTo:"canvas"},n))})},ImageToURL:function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{frameTimer:"full"},i=new $(t);i.loadImage(function(){i.toArray(e,function(t){"function"==typeof r&&r(t)},n)})},histogram:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=new $(t);n.loadImage(function(){"function"==typeof e&&e(n.toHistogram(r))})},ImageToHistogram:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{width:200,height:100},n=new $(t);n.loadImage(function(){h.createHistogram(r.width||200,r.height||100,n.toHistogram(r),function(t){"function"==typeof e&&e(t.toDataURL("image/png"))},r)})}};w.scale.parula=function(t){return w.scale(["#352a87","#0f5cdd","#00b5a6","#ffc337","#fdff00"],t)},w.scale.jet=function(t){return w.scale(["#00008f","#0020ff","#00ffff","#51ff77","#fdff00","#ff0000","#800000"],t)},w.scale.hsv=function(t){return w.scale(["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"],t)},w.scale.hot=function(t){return w.scale(["#0b0000","#ff0000","#ffff00","#ffffff"],t)},w.scale.pink=function(t){return w.scale(["#1e0000","#bd7b7b","#e7e5b2","#ffffff"],t)},w.scale.bone=function(t){return w.scale(["#000000","#4a4a68","#a6c6c6","#ffffff"],t)},w.scale.copper=function(t){return w.scale(["#000000","#3d2618","#9d623e","#ffa167","#ffc77f"],t)};var _=[{rgb:"#ff0000",start:0},{rgb:"#ffff00",start:.17},{rgb:"#00ff00",start:.33},{rgb:"#00ffff",start:.5},{rgb:"#0000ff",start:.67},{rgb:"#ff00ff",start:.83},{rgb:"#ff0000",start:1}];!function(){for(var t=0,e=_.length;t=t){e=_[n-1],r=_[n];break}return e&&r?w.interpolateRGB(e,r,(t-e.start)/(r.start-e.start)):_[0].rgb}},M={identity:function(){return[1,0,0,0,1,0,0,0,1]},stretching:function(t){return[t,0,0,0,1,0,0,0,1]},squeezing:function(t){return[t,0,0,0,1/t,0,0,0,1]},scale:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return[t=t||0===t?t:1,0,0,0,e=e||0===e?e:1,0,0,0,1]},scaleX:function(t){return this.scale(t)},scaleY:function(t){return this.scale(1,t)},translate:function(t,e){return[1,0,t,0,1,e,0,0,1]},rotate:function(t){var e=this.radian(t);return[Math.cos(e),-Math.sin(e),0,Math.sin(e),Math.cos(e),0,0,0,1]},rotate90:function(){return[0,-1,0,1,0,0,0,0,1]},rotate180:function(){return[-1,0,0,0,-1,0,0,0,1]},rotate270:function(){return[0,1,0,-1,0,0,0,0,1]},radian:function(t){return t*Math.PI/180},skew:function(t,e){var r=this.radian(t),n=this.radian(e);return[1,Math.tan(r),0,Math.tan(n),1,0,0,0,1]},skewX:function(t){var e=this.radian(t);return[1,Math.tan(e),0,0,1,0,0,0,1]},skewY:function(t){var e=this.radian(t);return[1,0,0,Math.tan(e),1,0,0,0,1]},shear1:function(t){return[1,-Math.tan(this.radian(t)/2),0,0,1,0,0,0,1]},shear2:function(t){return[1,0,0,Math.sin(this.radian(t)),1,0,0,0,1]}},H={CONSTANT:M,radian:function(t){return M.radian(t)},multiply:function(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]},identity:function(t){return this.multiply(M.identity(),t)},translate:function(t,e,r){return this.multiply(M.translate(t,e),r)},rotate:function(t,e){return this.multiply(M.rotate(t),e)},shear1:function(t,e){return this.multiply(M.shear1(t),e)},shear2:function(t,e){return this.multiply(M.shear2(t),e)},rotateShear:function(t,e){var r=e;return r=this.shear1(t,r),r=this.shear2(t,r),r=this.shear1(t,r)}};function I(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"center";return function(n,i){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=nt(n.pixels.length,n.width,n.height),l=n.width,s=n.height;"center"==e&&(e=Math.floor(l/2)),"center"==r&&(r=Math.floor(s/2));var c=H.CONSTANT.translate(-e,-r),u=H.CONSTANT.translate(e,r),h=H.CONSTANT.shear1(t),f=H.CONSTANT.shear2(t);ft(function(t,e,r,i){var o=H.multiply(c,[r,i,1]);o=H.multiply(h,o).map(Math.round),o=H.multiply(f,o).map(Math.round),o=H.multiply(h,o).map(Math.round),o=H.multiply(u,o);var a=k(o,2),g=a[0],v=a[1];g<0||(v<0||g>l-1||v>s-1||dt(t,v*l+g<<2,n.pixels,e))})(a,function(){i(a)},o)}}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:200,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=at(t),i=(e=at(e))/100,o=r;return ct(function(){var t=i*Math.ceil(.2126*$r+.7152*$g+.0722*$b)>=n?255:0;if(o)0==t&&($r=0,$g=0,$b=0);else{var e=Math.round(t);$r=e,$g=e,$b=e}},{$C:i,$scale:n,$hasColor:o})}function R(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([1,2,1,2,4,2,1,2,1],1/16*((t=at(t))/100)))}function E(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([1,4,6,4,1,4,16,24,16,4,6,24,36,24,6,4,16,24,16,4,1,4,6,4,1],1/256*((t=at(t))/100)))}function A(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return t=at(t),pt([5,5,5,-3,0,-3,-3,-3,-3])}function O(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return t=at(t),pt([5,-3,-3,5,0,-3,5,-3,-3])}function L(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,24,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],(t=at(t))/100))}function F(){return pt(J([1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1],1/9))}function P(){return pt(J([1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1],1/9))}function G(){return pt(J([1,0,0,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1],1/9))}function T(){return pt([-1,-2,-1,0,0,0,1,2,1])}function N(){return pt([-1,0,1,-2,0,2,-1,0,1])}var j=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],D=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function V(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}function z(t,e,r){return r?function(t,e,r,n){if(isNaN(n)||n<1)return t;n|=0;var i,o,a,l,s,c,u,h,f,g,v,d,p,m,y,b,k,C,$,x,w,_,S,M,H=t.pixels,I=t.width,B=t.height,R=n+n+1,E=I-1,A=B-1,O=n+1,L=O*(O+1)/2,F=new V,P=F;for(a=1;a>U,0!=S?(S=255/S,H[c]=(h*z>>U)*S,H[c+1]=(f*z>>U)*S,H[c+2]=(g*z>>U)*S):H[c]=H[c+1]=H[c+2]=0,h-=d,f-=p,g-=m,v-=y,d-=T.r,p-=T.g,m-=T.b,y-=T.a,l=u+((l=i+n+1)>U,S>0?(S=255/S,H[l]=(h*z>>U)*S,H[l+1]=(f*z>>U)*S,H[l+2]=(g*z>>U)*S):H[l]=H[l+1]=H[l+2]=0,h-=d,f-=p,g-=m,v-=y,d-=T.r,p-=T.g,m-=T.b,y-=T.a,l=i+((l=o+O)0&&void 0!==arguments[0]?arguments[0]:10,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t=at(t),function(r,n){n(z(r,t,e))}}function X(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return pt(J([1,4,6,4,1,4,16,24,16,4,6,24,-476,24,6,4,16,24,16,4,1,4,6,4,1],-1/(t=at(t))))}var Y,q=p({},{crop:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],n=arguments[3],i=nt(r*n*4,r,n);return function(o,a){for(var l=e,s=0;l0&&void 0!==arguments[0]?arguments[0]:0;return t=at(t),t%=360,function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(0==t)return e;if(90==t||270==t)var i=nt(e.pixels.length,e.height,e.width);else{if(180!=t)return I(t)(e,r,n);i=nt(e.pixels.length,e.width,e.height)}ft(function(r,n,o,a){if(90==t)var l=o*i.width+(i.width-1-a)<<2;else 270==t?l=(i.height-1-o)*i.width+a<<2:180==t&&(l=(i.height-1-a)*i.width+(i.width-1-o)<<2);dt(i.pixels,l,e.pixels,n)})(e,function(){r(i)},n)}},rotateDegree:I,"rotate-degree":I},{bitonal:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100,n=w.parse(t),i=w.parse(e),o=r;return ct(function(){var t=$r+$g+$b<=o?n:i;$r=t.r,$g=t.g,$b=t.b},{$darkColor:n,$lightColor:i,$threshold:o})},brightness:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;t=at(t);var e=Math.floor(t/100*255);return ct(function(){$r+=e,$g+=e,$b+=e},{$C:e})},clip:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=at(t);var e=2.55*Math.abs(t);return ct(function(){$r=$r>255-e?255:0,$g=$g>255-e?255:0,$b=$b>255-e?255:0},{$C:e})},contrast:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=at(t);var e=Math.max((128+t)/128,0);return ct(function(){$r*=e,$g*=e,$b*=e},{$C:e})},gamma:function(){var t=at(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1);return ct(function(){$r=255*Math.pow($r/255,t),$g=255*Math.pow($g/255,t),$b=255*Math.pow($b/255,t)},{$C:t})},gradient:function(){var t=[].concat(Array.prototype.slice.call(arguments));1===t.length&&"string"==typeof t[0]&&(t=w.convertMatchesArray(t[0]));var e=(t=t.map(function(t){return w.matches(t).length?{type:"param",value:t}:{type:"scale",value:t}})).filter(function(t){return"scale"==t.type})[0];e=e?+e.value:256,t=t.filter(function(t){return"param"==t.type}).map(function(t){return t.value}).join(",");var r=w.gradient(t,e).map(function(t){var e=w.parse(t);return{r:e.r,g:e.g,b:e.b,a:e.a}});return ct(function(){var t=$clamp($Color.brightness($r,$g,$b)),n=$clamp(Math.floor(t*(e/256))),i=r[n];$r=i.r,$g=i.g,$b=i.b,$a=$clamp(Math.floor(256*i.a))},{$colors:r,$scale:e})},grayscale:function(t){var e=(t=at(t))/100;e>1&&(e=1);var r=[.2126+.7874*(1-e),.7152-.7152*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152+.2848*(1-e),.0722-.0722*(1-e),0,.2126-.2126*(1-e),.7152-.7152*(1-e),.0722+.9278*(1-e),0,0,0,0,1];return ct(function(){$r=r[0]*$r+r[1]*$g+r[2]*$b+r[3]*$a,$g=r[4]*$r+r[5]*$g+r[6]*$b+r[7]*$a,$b=r[8]*$r+r[9]*$g+r[10]*$b+r[11]*$a,$a=r[12]*$r+r[13]*$g+r[14]*$b+r[15]*$a},{$matrix:r})},hue:function(){return ct(function(){var t=Color.RGBtoHSV($r,$g,$b),e=t.h;e+=Math.abs($amount),e%=360,t.h=e;var r=Color.HSVtoRGB(t);$r=r.r,$g=r.g,$b=r.b},{$C:at(arguments.length>0&&void 0!==arguments[0]?arguments[0]:360)})},invert:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=at(t))/100;return ct(function(){$r=(255-$r)*e,$g=(255-$g)*e,$b=(255-$b)*e},{$C:e})},noise:function(){var t=at(arguments.length>0&&void 0!==arguments[0]?arguments[0]:1);return ct(function(){var e=5*Math.abs(t),r=-e,n=e,i=Math.round(r+Math.random()*(n-r));$r+=i,$g+=i,$b+=i},{$C:t})},opacity:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=at(t))/100;return ct(function(){$a*=e},{$C:e})},saturation:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=at(t))/100,r=1-Math.abs(e),n=[r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,r];return ct(function(){$r=n[0]*$r+n[1]*$g+n[2]*$b+n[3]*$a,$g=n[4]*$r+n[5]*$g+n[6]*$b+n[7]*$a,$b=n[8]*$r+n[9]*$g+n[10]*$b+n[11]*$a,$a=n[12]*$r+n[13]*$g+n[14]*$b+n[15]*$a},{$matrix:n})},sepia:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=(t=at(t))/100;e>1&&(e=1);var r=[.393+.607*(1-e),.769-.769*(1-e),.189-.189*(1-e),0,.349-.349*(1-e),.686+.314*(1-e),.168-.168*(1-e),0,.272-.272*(1-e),.534-.534*(1-e),.131+.869*(1-e),0,0,0,0,1];return ct(function(){$r=r[0]*$r+r[1]*$g+r[2]*$b+r[3]*$a,$g=r[4]*$r+r[5]*$g+r[6]*$b+r[7]*$a,$b=r[8]*$r+r[9]*$g+r[10]*$b+r[11]*$a,$a=r[12]*$r+r[13]*$g+r[14]*$b+r[15]*$a},{$matrix:r})},shade:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=at(t),i=at(e),o=at(r);return ct(function(){$r*=n,$g*=i,$b*=o},{$redValue:n,$greenValue:i,$blueValue:o})},solarize:function(t,e,r){var n=at(t),i=at(e),o=at(r);return ct(function(){$r=$r0&&void 0!==arguments[0]?arguments[0]:200,arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,!1)},"threshold-color":B,tint:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=parseParamNumber(t),i=parseParamNumber(e),o=parseParamNumber(r);return ct(function(){$r+=(255-$r)*n,$g+=(255-$g)*i,$b+=(255-$b)*o},{$redTint:n,$greenTint:i,$blueTint:o})}},{blur:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;return pt(gt(t=at(t)))},emboss:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return pt([-2*(t=at(t)),-t,0,-t,1,t,0,t,2*t])},gaussianBlur:R,"gaussian-blur":R,gaussianBlur5x:E,"gaussian-blur-5x":E,grayscale2:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([.3,.3,.3,0,0,.59,.59,.59,0,0,.11,.11,.11,0,0,0,0,0,0,0,0,0,0,0,0],(t=at(t))/100))},identity:function(){return pt([0,0,0,0,1,0,0,0,0])},kirschHorizontal:A,"kirsch-horizontal":A,kirschVertical:O,"kirsch-vertical":O,laplacian:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([-1,-1,-1,-1,8,-1,-1,-1,-1],(t=at(t))/100))},laplacian5x:L,"laplacian-5x":L,motionBlur:F,"motion-blur":F,motionBlur2:P,"motion-blur-2":P,motionBlur3:G,"motion-blur-3":G,negative:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([-1,0,0,0,0,0,-1,0,0,0,0,0,-1,0,0,0,0,0,1,0,1,1,1,1,1],(t=at(t))/100))},sepia2:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([.393,.349,.272,0,0,.769,.686,.534,0,0,.189,.168,.131,0,0,0,0,0,0,0,0,0,0,0,0],(t=at(t))/100))},sharpen:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([0,-1,0,-1,5,-1,0,-1,0],(t=at(t))/100))},sobelHorizontal:T,"sobel-horizontal":T,sobelVertical:N,"sobel-vertical":N,stackBlur:U,"stack-blur":U,transparency:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;return pt(J([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,.3,0,0,0,0,0,1],(t=at(t))/100))},unsharpMasking:X,"unsharp-masking":X},{kirsch:function(){return kt("kirsch-horizontal kirsch-vertical")},sobel:function(){return kt("sobel-horizontal sobel-vertical")},vintage:function(){return kt("brightness(15) saturation(-20) gamma(1.8)")}}),K=0,W=(d(Y={partial:wt,multi:$t,merge:xt,weight:J,repeat:Q,colorMatrix:function(t,e,r){var n=t[e],i=t[e+1],o=t[e+2],a=t[e+3];vt(t,e,r[0]*n+r[1]*i+r[2]*o+r[3]*a,r[4]*n+r[5]*i+r[6]*o+r[7]*a,r[8]*n+r[9]*i+r[10]*o+r[11]*a,r[12]*n+r[13]*i+r[14]*o+r[15]*a)},each:et,eachXY:rt,createRandomCount:function(){return[9,16,25,36,49,64,81,100].sort(function(t,e){return.5-Math.random()})[0]},createRandRange:function(t,e,r){for(var n=[],i=1;i<=r;i++){var o=Math.random()*(e-t)+t,a=Math.floor(10*Math.random())%2==0?-1:1;n.push(a*o)}n.sort();var l=Math.floor(r>>1),s=n[l];return n[l]=n[0],n[0]=s,n},createBitmap:nt,createBlurMatrix:gt,pack:function(t){return function(e,r){et(e.pixels.length,function(r,n){t(e.pixels,r,n,e.pixels[r],e.pixels[r+1],e.pixels[r+2],e.pixels[r+3])},function(){r(e)})}},packXY:ft,pixel:ct,getBitmap:it,putBitmap:ot,radian:function(t){return H.CONSTANT.radian(t)},convolution:pt,parseParamNumber:at,filter:kt,clamp:bt,fillColor:vt,fillPixelColor:dt},"multi",$t),d(Y,"merge",xt),d(Y,"matches",mt),d(Y,"parseFilter",yt),d(Y,"partial",wt),Y),Z=W;function J(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t.map(function(t){return t*e})}function Q(t,e){for(var r=new Array(e),n=0;n1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments[3],i=arguments[4],o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1e4,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"full",l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:50,s=e,c=function(t){setTimeout(t,0)};function u(){for(var e=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20,e=[].concat(C(Array(t))).map(function(t){return"\n currentRunIndex = runIndex + i * step\n if (currentRunIndex >= max) return {currentRunIndex: currentRunIndex, i: null};\n callback(currentRunIndex); i++;\n "}).join("\n\n");return new Function("runIndex","i","step","max","callback","\n let currentRunIndex = runIndex;\n \n "+e+"\n \n return {currentRunIndex: currentRunIndex, i: i} \n ")}(l),a=s,h={},f=0;f=t)return void i();c?c(u):u()}(a)}"requestAnimationFrame"==a&&(c=requestAnimationFrame,o=1e3),"full"==a&&(c=null,o=t),u()}function et(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};tt(t,0,4,function(t){e(t,t>>2)},function(){r()},n.functionDumpCount,n.frameTimer)}function rt(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};tt(t,0,4,function(t){var n=t>>2;r(t,n%e,Math.floor(n/e))},function(){n()},i.functionDumpCount,i.frameTimer)}function nt(t,e,r){return{pixels:new Uint8ClampedArray(t),width:e,height:r}}function it(t,e){return h.getBitmap(t,e)}function ot(t,e,r){return h.putBitmap(t,e,r)}function at(t){return"string"==typeof t&&(t=(t=t.replace(/deg/,"")).replace(/px/,"")),+t}var lt=/(([\w_\-]+)(\(([^\)]*)\))?)+/gi;function st(t,e){return function(t){var e=t.map(function(t){var e=[];Object.keys(t.context).forEach(function(t,r){e[t]="n$"+K+++t+"$"});var r=Object.keys(t.context).filter(function(e){return"number"!=typeof t.context[e]&&"string"!=typeof t.context[e]&&(!Array.isArray(t.context[e])||"number"!=typeof t.context[e][0]&&"string"!=typeof t.context[e][0])}).map(function(r,n){return[e[r],JSON.stringify(t.context[r])].join(" = ")}),n=t.callback.toString().split("{");return n.shift(),(n=(n=n.join("{")).split("}")).pop(),n=n.join("}"),Object.keys(e).forEach(function(r){var i=e[r];"number"==typeof t.context[r]||"string"==typeof t.context[r]?n=n.replace(new RegExp("\\"+r,"g"),t.context[r]):!Array.isArray(t.context[r])||"number"!=typeof t.context[r][0]&&"string"!=typeof t.context[r][0]?n=n.replace(new RegExp("\\"+r,"g"),i):t.context[r].forEach(function(t,e){n=n.replace(new RegExp("\\"+r+"\\["+e+"\\]","g"),t)})}),{preCallbackString:n,preContext:r}});e.forEach(function(t,e){t.strPreContext=t.preContext.length?"const "+t.preContext+";":""});var r=e.map(function(t,e){return t.strPreContext}).join("\n\n"),n=e.map(function(t){return t.preCallbackString}).join("\n\n"),i=new Function("$pixels","$pixelIndex","$clamp","$Color"," \n let $r = $pixels[$pixelIndex], $g = $pixels[$pixelIndex+1], $b = $pixels[$pixelIndex+2], $a = $pixels[$pixelIndex+3];\n \n "+r+"\n\n "+n+"\n \n $pixels[$pixelIndex] = $r\n $pixels[$pixelIndex+1] = $g \n $pixels[$pixelIndex+2] = $b \n $pixels[$pixelIndex+3] = $a \n ");return i.$preCallbackString=n,i.$preContext=r,i}([{callback:t,context:e}])}function ct(t,e){var r=st(t,e),n=function(t,e){};return n.userFunction=r,n}var ut=[0,1,2,3];function ht(t,e,r){ut.forEach(function(n){var i=t[e+n];t[e+n]=t[r+n],t[r+n]=i})}function ft(t){return function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};rt(e.pixels.length,e.width,function(r,n,i){t(e.pixels,r,n,i)},function(){r(e)},n)}}function gt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,e=Math.pow(t,2);return Q(1/e,e)}function vt(t,e,r,n,i,o){if(3==arguments.length){var a=arguments[2];r=a.r,n=a.g,i=a.b,o=a.a}"number"==typeof r&&(t[e]=r),"number"==typeof n&&(t[e+1]=n),"number"==typeof i&&(t[e+2]=i),"number"==typeof o&&(t[e+3]=o)}function dt(t,e,r,n){vt(t,e,r[n],r[n+1],r[n+2],r[n+3])}function pt(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function(r,n){var i,o,a,l,s,c,u,h,f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},g=nt(r.pixels.length,r.width,r.height),v=(i=t,o=r.width,a=r.height,l=e,s=Math.round(Math.sqrt(i.length)),c=Math.floor(s/2),u=l?1:0,h="let r = 0, g = 0, b = 0, a = 0, scy = 0, scx =0, si = 0; ",i.forEach(function(t,e){var r=Math.floor(e/s);h+="scy = $sy + ("+(r-c)+"); scx = $sx + ("+(e%s-c)+"); if (scy >= 0 && scy < "+a+" && scx >= 0 && scx < "+o+") { si = (scy * "+o+" + scx) << 2; r += $sp[si] * ("+t+"); g += $sp[si + 1] * ("+t+"); b += $sp[si + 2] * ("+t+"); a += $sp[si + 3] * ("+t+"); }\n "}),h+="$dp[$di] = r; $dp[$di+1] = g;$dp[$di+2] = b;$dp[$di+3] = a + ("+u+")*(255-a); ",new Function("$dp","$sp","$di","$sx","$sy",h));ft(function(t,e,n,i){v(t,r.pixels,e,n,i)})(g,function(){n(g)},f)}}function mt(t){var e=Color.convertMatches(t),r=e.str.match(lt),n=[];if(!r)return n;var i={next:0};return n=(n=r.map(function(t){return{filter:t,origin:Color.reverseMatches(t,e.matches)}})).map(function(e){var r=t.indexOf(e.origin,i.next);return e.startIndex=r,e.endIndex=r+e.origin.length,e.arr=yt(e.origin),i.next=e.endIndex,e}).filter(function(t){return!!t.arr.length})}function yt(t){var e=Color.convertMatches(t),r=e.str.match(lt);if(!r[0])return[];var n=r[0].split("("),i=n.shift(),o=[];return n.length&&(o=n.shift().split(")")[0].split(",").map(function(t){return Color.reverseMatches(t,e.matches)})),[i].concat(C(o)).map(Color.trim)}function bt(t){return Math.min(255,t)}function kt(t){return xt(mt(t).map(function(t){return t.arr}))}function Ct(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=[],r=[],n=0,i=t.length;n2&&void 0!==arguments[2]?arguments[2]:{},o=t,a=0;function l(){e[a].call(null,o,function(t){o=t,function(){if(++a>=n)return void r(o);l()}()},i)}l()}}function xt(t){return $t.apply(void 0,C(t))}function wt(t){for(var e=null,r=arguments.length,n=Array(r>1?r-1:0),i=1;i2&&void 0!==arguments[2]?arguments[2]:{};e(it(r,t),function(e){n(ot(r,e,t))},i)}}var _t=p({},q,W),St=0,Mt=[],Ht=function(){function t(e,r,n){if(g(this,t),"string"!=typeof e)this.el=e;else{var i=document.createElement(e);for(var o in this.uniqId=St++,r&&(i.className=r),n=n||{})i.setAttribute(o,n[o]);this.el=i}}return v(t,[{key:"attr",value:function(t,e){return 1==arguments.length?this.el.getAttribute(t):(this.el.setAttribute(t,e),this)}},{key:"closest",value:function(e){for(var r=this,n=!1;!(n=r.hasClass(e));){if(!r.el.parentNode)return null;r=new t(r.el.parentNode)}return n?r:null}},{key:"removeClass",value:function(t){this.el.className=(" "+this.el.className+" ").replace(" "+t+" "," ").trim()}},{key:"hasClass",value:function(t){return!!this.el.className&&(" "+this.el.className+" ").indexOf(" "+t+" ")>-1}},{key:"addClass",value:function(t){this.hasClass(t)||(this.el.className=this.el.className+" "+t)}},{key:"toggleClass",value:function(t){this.hasClass(t)?this.removeClass(t):this.addClass(t)}},{key:"html",value:function(t){return"string"==typeof t?this.el.innerHTML=t:this.empty().append(t),this}},{key:"empty",value:function(){return this.html("")}},{key:"append",value:function(t){return"string"==typeof t?this.el.appendChild(document.createTextNode(t)):this.el.appendChild(t.el||t),this}},{key:"appendTo",value:function(t){return(t.el?t.el:t).appendChild(this.el),this}},{key:"remove",value:function(){return this.el.parentNode&&this.el.parentNode.removeChild(this.el),this}},{key:"text",value:function(){return this.el.textContent}},{key:"css",value:function(t,e){var r=this;if(2==arguments.length)this.el.style[t]=e;else if(1==arguments.length){if("string"==typeof t)return getComputedStyle(this.el)[t];var n=t||{};Object.keys(n).forEach(function(t){r.el.style[t]=n[t]})}return this}},{key:"cssFloat",value:function(t){return parseFloat(this.css(t))}},{key:"cssInt",value:function(t){return parseInt(this.css(t))}},{key:"offset",value:function(){var t=this.el.getBoundingClientRect();return{top:t.top+document.documentElement.scrollTop,left:t.left+document.documentElement.scrollLeft}}},{key:"position",value:function(){return this.el.style.top?{top:parseFloat(this.css("top")),left:parseFloat(this.css("left"))}:this.el.getBoundingClientRect()}},{key:"width",value:function(){return this.el.offsetWidth}},{key:"contentWidth",value:function(){return this.width()-this.cssFloat("padding-left")-this.cssFloat("padding-right")}},{key:"height",value:function(){return this.el.offsetHeight}},{key:"contentHeight",value:function(){return this.height()-this.cssFloat("padding-top")-this.cssFloat("padding-bottom")}},{key:"dataKey",value:function(t){return this.uniqId+"."+t}},{key:"data",value:function(t,e){if(2!=arguments.length){if(1==arguments.length)return Mt[this.dataKey(t)];var r=Object.keys(Mt),n=this.uniqId+".";return r.filter(function(t){return 0==t.indexOf(n)}).map(function(t){return Mt[t]})}return Mt[this.dataKey(t)]=e,this}},{key:"val",value:function(t){return 0==arguments.length?this.el.value:(1==arguments.length&&(this.el.value=t),this)}},{key:"int",value:function(){return parseInt(this.val(),10)}},{key:"float",value:function(){return parseFloat(this.val())}},{key:"show",value:function(){return this.css("display","block")}},{key:"hide",value:function(){return this.css("display","none")}},{key:"toggle",value:function(){return"none"==this.css("display")?this.show():this.hide()}},{key:"scrollTop",value:function(){return this.el===document.body?document.documentElement.scrollTop:this.el.scrollTop}},{key:"scrollLeft",value:function(){return this.el===document.body?document.documentElement.scrollLeft:this.el.scrollLeft}},{key:"on",value:function(t,e,r,n){return this.el.addEventListener(t,e,r,n),this}},{key:"off",value:function(t,e){return this.el.removeEventListener(t,e),this}},{key:"getElement",value:function(){return this.el}},{key:"createChild",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=new t(e,r,n);return o.css(i),this.append(o),o}}]),t}(),It={addEvent:function(t,e,r){t.addEventListener(e,r)},removeEvent:function(t,e,r){t.removeEventListener(e,r)},pos:function(t){return t.touches&&t.touches[0]?t.touches[0]:t}},Bt=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(this,t),this.masterObj=e,this.settingObj=r}return v(t,[{key:"set",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.settingObj[t]=e||r}},{key:"init",value:function(t){if(!this.has(t)){var e=t.split("."),r=this.masterObj[e[0]]||this.masterObj,n=e.pop();if(r[n]){for(var i=arguments.length,o=Array(i>1?i-1:0),a=1;a1&&void 0!==arguments[1]?arguments[1]:"";return this.init(t,e),this.settingObj[t]||e}},{key:"has",value:function(t){return!!this.settingObj[t]}}]),t}(),Rt=/^(click|mouse(down|up|move|enter|leave)|key(down|up|press)|contextmenu|change|input)/gi,Et=["Control","Shift","Alt","Meta"],At=function(){function t(){g(this,t),this.state=new Bt(this)}return v(t,[{key:"initializeEvent",value:function(){this.initializeEventMachin()}},{key:"destroy",value:function(){this.destroyEventMachin()}},{key:"destroyEventMachin",value:function(){this.removeEventAll()}},{key:"initializeEventMachin",value:function(){this.filterProps(Rt).forEach(this.parseEvent.bind(this))}},{key:"filterProps",value:function(t){return Object.getOwnPropertyNames(this.__proto__).filter(function(e){return e.match(t)})}},{key:"parseEvent",value:function(t){var e=t.split(" ");this.bindingEvent(e,this[t].bind(this))}},{key:"getDefaultDomElement",value:function(t){var e=void 0;return(e=t?this[t]||window[t]:this.el||this.$el||this.$root)instanceof Ht?e.getElement():e}},{key:"getDefaultEventObject",value:function(t){var e=this,r=t.split("."),n=r.shift(),i=r.includes("Control"),o=r.includes("Shift"),a=r.includes("Alt"),l=r.includes("Meta"),s=(r=r.filter(function(t){return!1===Et.includes(t)})).filter(function(t){return!!e[t]});return{eventName:n,isControl:i,isShift:o,isAlt:a,isMeta:l,codes:r=r.filter(function(t){return!1===s.includes(t)}).map(function(t){return t.toLowerCase()}),checkMethodList:s}}},{key:"bindingEvent",value:function(t,e){var r,n=(r=t,Array.isArray(r)?r:Array.from(r)),i=n[0],o=n[1],a=n.slice(2);o=this.getDefaultDomElement(o);var l=this.getDefaultEventObject(i);l.dom=o,l.delegate=a.join(" "),this.addEvent(l,e)}},{key:"matchPath",value:function(t,e){return t?t.matches(e)?t:this.matchPath(t.parentElement,e):null}},{key:"getBindings",value:function(){return this._bindings||this.initBindings(),this._bindings}},{key:"addBinding",value:function(t){this.getBindings().push(t)}},{key:"initBindings",value:function(){this._bindings=[]}},{key:"checkEventType",value:function(t,e){var r=this,n=!t.ctrlKey||e.isControl,i=!t.shiftKey||e.isShift,o=!t.altKey||e.isAlt,a=!t.metaKey||e.isMeta,l=!0;e.codes.length&&(l=e.codes.includes(t.code.toLowerCase())||e.codes.includes(t.key.toLowerCase()));var s=!0;return e.checkMethodList.length&&(s=e.checkMethodList.every(function(e){return r[e].call(r,t)})),n&&o&&i&&a&&l&&s}},{key:"makeCallback",value:function(t,e){var r=this;return t.delegate?function(n){if(r.checkEventType(n,t)){var i=r.matchPath(n.target||n.srcElement,t.delegate);if(i)return n.delegateTarget=i,n.$delegateTarget=new Ht(i),e(n)}}:function(n){if(r.checkEventType(n,t))return e(n)}}},{key:"addEvent",value:function(t,e){t.callback=this.makeCallback(t,e),this.addBinding(t),It.addEvent(t.dom,t.eventName,t.callback)}},{key:"removeEventAll",value:function(){var t=this;this.getBindings().forEach(function(e){t.removeEvent(e)}),this.initBindings()}},{key:"removeEvent",value:function(t){var e=t.eventName,r=t.dom,n=t.callback;It.removeEvent(r,e,n)}}]),t}(),Ot=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,At),v(e,[{key:"initialize",value:function(){this.$el=new Ht("div","control"),this.$hue=this.$el.createChild("div","hue"),this.$opacity=this.$el.createChild("div","opacity"),this.$controlPattern=this.$el.createChild("div","empty"),this.$controlColor=this.$el.createChild("div","color"),this.$hueContainer=this.$hue.createChild("div","hue-container"),this.$drag_bar=this.$hueContainer.createChild("div","drag-bar"),this.drag_bar_pos={},this.$opacityContainer=this.$opacity.createChild("div","opacity-container"),this.$opacityColorBar=this.$opacityContainer.createChild("div","color-bar"),this.$opacity_drag_bar=this.$opacityContainer.createChild("div","drag-bar2"),this.opacity_drag_bar_pos={}}},{key:"setBackgroundColor",value:function(t){this.$controlColor.css("background-color",t)}},{key:"refresh",value:function(){this.setColorUI()}},{key:"setColorUI",value:function(){var t=this.state.get("$el.width")*this.colorpicker.currentS,e=this.state.get("$el.height")*(1-this.colorpicker.currentV);this.$drag_pointer.css({left:t+"px",top:e+"px"})}},{key:"setOpacityColorBar",value:function(t){var e=w.parse(t);e.a=0;var r=w.format(e,"rgb");e.a=1;var n=w.format(e,"rgb");this.$opacityColorBar.css("background","linear-gradient(to right, "+r+", "+n+")")}},{key:"setOpacity",value:function(t){var e,r=this.$opacityContainer.offset().left,n=r+this.state.get("$opacityContainer.width"),i=It.pos(t).clientX;e=in?100:(i-r)/(n-r)*100;var o=this.state.get("$opacityContainer.width")*(e/100);this.$opacity_drag_bar.css({left:o-Math.ceil(this.state.get("$opacity_drag_bar.width")/2)+"px"}),this.opacity_drag_bar_pos={x:o},this.colorpicker.setCurrentA(this.caculateOpacity()),this.colorpicker.currentFormat(),this.colorpicker.setInputColor()}},{key:"setInputColor",value:function(){this.setBackgroundColor(this.colorpicker.getFormattedColor("rgb"));var t=this.colorpicker.convertRGB(),e=w.format(t,"rgb");this.setOpacityColorBar(e)}},{key:"setColorUI",value:function(){var t=this.state.get("$hueContainer.width")*(this.colorpicker.currentH/360);this.$drag_bar.css({left:t-7.5+"px"}),this.drag_bar_pos={x:t};var e=this.state.get("$opacityContainer.width")*(this.colorpicker.currentA||0);this.$opacity_drag_bar.css({left:e-7.5+"px"}),this.opacity_drag_bar_pos={x:e}}},{key:"caculateH",value:function(){return{h:(this.drag_bar_pos||{x:0}).x/this.state.get("$hueContainer.width")*360}}},{key:"caculateOpacity",value:function(){var t=this.opacity_drag_bar_pos||{x:0},e=Math.round(t.x/this.state.get("$opacityContainer.width")*100)/100;return isNaN(e)?1:e}},{key:"EventDocumentMouseMove",value:function(t){this.isHueDown&&this.setHueColor(t),this.isOpacityDown&&this.setOpacity(t)}},{key:"EventDocumentMouseUp",value:function(t){this.isHueDown=!1,this.isOpacityDown=!1}},{key:"setControlColor",value:function(t){this.$controlColor.css("background-color",t)}},{key:"setHueColor",value:function(t){var e,r=this.$hueContainer.offset().left,n=r+this.state.get("$hueContainer.width"),i=t?It.pos(t).clientX:r+(n-r)*(this.colorpicker.currentH/360);e=in?100:(i-r)/(n-r)*100;var o=this.state.get("$hueContainer.width")*(e/100);this.$drag_bar.css({left:o-Math.ceil(this.state.get("$drag_bar.width")/2)+"px"}),this.drag_bar_pos={x:o};var a=S.checkHueColor(e/100);this.colorpicker.setBackgroundColor(a),this.colorpicker.setCurrentH(e/100*360),this.colorpicker.setInputColor()}},{key:"setOnlyHueColor",value:function(){var t,e=this.$hueContainer.offset().left,r=e+this.state.get("$hueContainer.width"),n=e+(r-e)*(this.colorpicker.currentH/360);t=nr?100:(n-e)/(r-e)*100;var i=this.state.get("$hueContainer.width")*(t/100);this.$drag_bar.css({left:i-Math.ceil(this.state.get("$drag_bar.width")/2)+"px"}),this.drag_bar_pos={x:i};var o=S.checkHueColor(t/100);this.colorpicker.setBackgroundColor(o),this.colorpicker.setCurrentH(t/100*360)}},{key:"mousedown $drag_bar",value:function(t){t.preventDefault(),this.isHueDown=!0}},{key:"mousedown $opacity_drag_bar",value:function(t){t.preventDefault(),this.isOpacityDown=!0}},{key:"mousedown $hueContainer",value:function(t){this.isHueDown=!0,this.setHueColor(t)}},{key:"mousedown $opacityContainer",value:function(t){this.isOpacityDown=!0,this.setOpacity(t)}}]),e}(),Lt=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,At),v(e,[{key:"initialize",value:function(){this.$el=new Ht("div","information hex"),this.$informationChange=this.$el.createChild("div","information-change"),this.$formatChangeButton=this.$informationChange.createChild("button","format-change-button arrow-button",{type:"button"}),this.$el.append(this.makeInputFieldHex()),this.$el.append(this.makeInputFieldRgb()),this.$el.append(this.makeInputFieldHsl()),this.format="hex"}},{key:"makeInputFieldHex",value:function(){var t=new Ht("div","information-item hex"),e=t.createChild("div","input-field hex");return this.$hexCode=e.createChild("input","input",{type:"text"}),e.createChild("div","title").html("HEX"),t}},{key:"makeInputFieldRgb",value:function(){var t=new Ht("div","information-item rgb"),e=t.createChild("div","input-field rgb-r");return this.$rgb_r=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("R"),e=t.createChild("div","input-field rgb-g"),this.$rgb_g=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("G"),e=t.createChild("div","input-field rgb-b"),this.$rgb_b=e.createChild("input","input",{type:"number",step:1,min:0,max:255}),e.createChild("div","title").html("B"),e=t.createChild("div","input-field rgb-a"),this.$rgb_a=e.createChild("input","input",{type:"number",step:.01,min:0,max:1}),e.createChild("div","title").html("A"),t}},{key:"makeInputFieldHsl",value:function(){var t=new Ht("div","information-item hsl"),e=t.createChild("div","input-field hsl-h");return this.$hsl_h=e.createChild("input","input",{type:"number",step:1,min:0,max:360}),e.createChild("div","title").html("H"),e=t.createChild("div","input-field hsl-s"),this.$hsl_s=e.createChild("input","input",{type:"number",step:1,min:0,max:100}),e.createChild("div","postfix").html("%"),e.createChild("div","title").html("S"),e=t.createChild("div","input-field hsl-l"),this.$hsl_l=e.createChild("input","input",{type:"number",step:1,min:0,max:100}),e.createChild("div","postfix").html("%"),e.createChild("div","title").html("L"),e=t.createChild("div","input-field hsl-a"),this.$hsl_a=e.createChild("input","input",{type:"number",step:.01,min:0,max:1}),e.createChild("div","title").html("A"),t}},{key:"currentFormat",value:function(){var t=this.format||"hex";if(this.colorpicker.currentA<1&&"hex"==t){this.$el.removeClass(t),this.$el.addClass("rgb"),this.format="rgb",this.colorpicker.setInputColor()}}},{key:"setCurrentFormat",value:function(t){this.format=t,this.initFormat()}},{key:"initFormat",value:function(){var t=this.format||"hex";this.$el.removeClass("hex"),this.$el.removeClass("rgb"),this.$el.removeClass("hsl"),this.$el.addClass(t)}},{key:"nextFormat",value:function(){var t=this.format||"hex",e="hex";"hex"==t?e="rgb":"rgb"==t?e="hsl":"hsl"==t&&(e=1==this.colorpicker.currentA?"hex":"rgb"),this.$el.removeClass(t),this.$el.addClass(e),this.format=e,this.setInputColor(),this.colorpicker.changeInputColorAfterNextFormat()}},{key:"setRGBInput",value:function(t,e,r){this.$rgb_r.val(t),this.$rgb_g.val(e),this.$rgb_b.val(r),this.$rgb_a.val(this.colorpicker.currentA)}},{key:"setHSLInput",value:function(t,e,r){this.$hsl_h.val(t),this.$hsl_s.val(e),this.$hsl_l.val(r),this.$hsl_a.val(this.colorpicker.currentA)}},{key:"getHexFormat",value:function(){return w.format({r:this.$rgb_r.int(),g:this.$rgb_g.int(),b:this.$rgb_b.int()},"hex",this.colorpicker.opt.color)}},{key:"getRgbFormat",value:function(){return w.format({r:this.$rgb_r.int(),g:this.$rgb_g.int(),b:this.$rgb_b.int(),a:this.$rgb_a.float()},"rgb",this.colorpicker.opt.color)}},{key:"getHslFormat",value:function(){return w.format({h:this.$hsl_h.val(),s:this.$hsl_s.val(),l:this.$hsl_l.val(),a:this.$hsl_a.float()},"hsl",this.colorpicker.opt.color)}},{key:"convertRGB",value:function(){return this.colorpicker.convertRGB()}},{key:"convertHEX",value:function(){return this.colorpicker.convertHEX()}},{key:"convertHSL",value:function(){return this.colorpicker.convertHSL()}},{key:"getFormattedColor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"hex"==(t=t||this.getFormat())?this.$hexCode.val():"rgb"==t?this.getRgbFormat(e):"hsl"==t?this.getHslFormat(e):void 0}},{key:"getFormat",value:function(){return this.format||"hex"}},{key:"setInputColor",value:function(){var t=this.getFormat(),e=null;if("hex"==t){this.$hexCode.val(this.convertHEX());e=this.convertRGB();this.setRGBInput(e.r,e.g,e.b,e.a)}else if("rgb"==t){e=this.convertRGB();this.setRGBInput(e.r,e.g,e.b,e.a),this.$hexCode.val(this.convertHEX())}else if("hsl"==t){var r=this.convertHSL();this.setHSLInput(r.h,r.s,r.l,r.a)}}},{key:"checkNumberKey",value:function(t){return It.checkNumberKey(t)}},{key:"checkNotNumberKey",value:function(t){return!It.checkNumberKey(t)}},{key:"changeRgbColor",value:function(){this.colorpicker.changeInformationColor(this.getRgbFormat())}},{key:"changeHslColor",value:function(){this.colorpicker.changeInformationColor(this.getHslFormat())}},{key:"change $rgb_r",value:function(t){this.changeRgbColor()}},{key:"change $rgb_g",value:function(t){this.changeRgbColor()}},{key:"change $rgb_b",value:function(t){this.changeRgbColor()}},{key:"change $rgb_a",value:function(t){this.changeRgbColor()}},{key:"change $hsl_h",value:function(t){this.changeHslColor()}},{key:"change $hsl_s",value:function(t){this.changeHslColor()}},{key:"change $hsl_l",value:function(t){this.changeHslColor()}},{key:"change $hsl_a",value:function(t){this.changeHslColor()}},{key:"keydown $hexCode",value:function(t){if(t.which<65||t.which>70)return this.checkNumberKey(t)}},{key:"keyup $hexCode",value:function(t){var e=this.$hexCode.val();"#"==e.charAt(0)&&7==e.length&&(this.colorpicker.changeInformationColor(e),this.setInputColor())}},{key:"click $formatChangeButton",value:function(t){this.nextFormat()}},{key:"refresh",value:function(){}}]),e}(),Ft=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,At),v(e,[{key:"initialize",value:function(){this.$el=new Ht("div","color"),this.$saturation=this.$el.createChild("div","saturation"),this.$value=this.$saturation.createChild("div","value"),this.$drag_pointer=this.$value.createChild("div","drag-pointer")}},{key:"setBackgroundColor",value:function(t){this.$el.css("background-color",t)}},{key:"refresh",value:function(){this.setColorUI()}},{key:"caculateSV",value:function(){var t=this.drag_pointer_pos||{x:0,y:0},e=this.state.get("$el.width"),r=this.state.get("$el.height");return{s:t.x/e,v:(r-t.y)/r,width:e,height:r}}},{key:"setColorUI",value:function(){var t=this.state.get("$el.width")*this.colorpicker.currentS,e=this.state.get("$el.height")*(1-this.colorpicker.currentV);this.$drag_pointer.css({left:t-5+"px",top:e-5+"px"}),this.drag_pointer_pos={x:t,y:e}}},{key:"setMainColor",value:function(t){t.preventDefault();var e=this.$el.position(),r=this.state.get("$el.contentWidth"),n=this.state.get("$el.contentHeight"),i=t.clientX-e.left,o=t.clientY-e.top;i<0?i=0:i>r&&(i=r),o<0?o=0:o>n&&(o=n),this.$drag_pointer.css({left:i-5+"px",top:o-5+"px"}),this.drag_pointer_pos={x:i,y:o},this.colorpicker.caculateHSV(),this.colorpicker.setInputColor()}},{key:"EventDocumentMouseUp",value:function(t){this.isDown=!1}},{key:"EventDocumentMouseMove",value:function(t){this.isDown&&this.setMainColor(t)}},{key:"mousedown",value:function(t){this.isDown=!0,this.setMainColor(t)}},{key:"mouseup",value:function(t){this.isDown=!1}}]),e}(),Pt="data-colorsets-index",Gt=function(t){function e(t){g(this,e);var r=b(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.colorpicker=t,r.initialize(),r}return y(e,At),v(e,[{key:"initialize",value:function(){this.$el=new Ht("div","color-chooser");var t=this.$el.createChild("div","color-chooser-container"),e=t.createChild("div","colorsets-item colorsets-item-header");e.createChild("h1","title").html("Color Paletts"),this.$toggleButton=e.createChild("span","items").html("×"),this.$colorsetsList=t.createChild("div","colorsets-list"),this.refresh()}},{key:"refresh",value:function(){this.$colorsetsList.html(this.makeColorSetsList())}},{key:"makeColorItemList",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5,r=new Ht("div"),n=0;n1&&void 0!==arguments[1]&&arguments[1];if("object"==(void 0===t?"undefined":f(t))){if(!t.r||!t.g||!t.b)return;e?this.callbackColorValue(w.format(t,"hex")):this.initColor(w.format(t,"hex"))}else"string"==typeof t&&(e?this.callbackColorValue(t):this.initColor(t))}},{key:"getColor",value:function(t){this.caculateHSV();var e=this.convertRGB();return t?w.format(e,t):e}},{key:"definePositionForArrow",value:function(t,e,r){}},{key:"definePosition",value:function(t){var e=this.$root.width(),r=this.$root.height(),n=t.left-this.$body.scrollLeft();e+n>window.innerWidth&&(n-=e+n-window.innerWidth),n<0&&(n=0);var i=t.top-this.$body.scrollTop();r+i>window.innerHeight&&(i-=r+i-window.innerHeight),i<0&&(i=0),this.$root.css({left:n+"px",top:i+"px"})}},{key:"getInitalizePosition",value:function(){return"inline"==this.opt.position?{position:"relative",left:"auto",top:"auto",display:"inline-block"}:{position:"fixed",left:"-10000px",top:"-10000px"}}},{key:"show",value:function(t,e,r){this.destroy(),this.initializeEvent(),this.$root.appendTo(this.$body),this.$root.css(this.getInitalizePosition()).show(),this.definePosition(t),this.isColorPickerShow=!0,this.isShortCut=t.isShortCut||!1,this.initColor(e),this.colorpickerCallback=r,this.hideDelay=t.hideDelay||2e3,this.hideDelay>0&&this.setHideDelay(this.hideDelay)}},{key:"setHideDelay",value:function(t){var e=this;t=t||0,this.$root.off("mouseenter"),this.$root.off("mouseleave"),this.$root.on("mouseenter",function(){clearTimeout(e.timerCloseColorPicker)}),this.$root.on("mouseleave",function(){clearTimeout(e.timerCloseColorPicker),e.timerCloseColorPicker=setTimeout(e.hide.bind(e),t)}),clearTimeout(this.timerCloseColorPicker),this.timerCloseColorPicker=setTimeout(this.hide.bind(this),t)}},{key:"hide",value:function(){this.isColorPickerShow&&(this.destroy(),this.$root.hide(),this.$root.remove(),this.isColorPickerShow=!1)}},{key:"convertRGB",value:function(){return w.HSVtoRGB(this.currentH,this.currentS,this.currentV)}},{key:"convertHEX",value:function(){return w.format(this.convertRGB(),"hex")}},{key:"convertHSL",value:function(){return w.HSVtoHSL(this.currentH,this.currentS,this.currentV)}},{key:"getCurrentColor",value:function(){return this.information.getFormattedColor()}},{key:"getFormattedColor",value:function(t){if("rgb"==(t=t||"hex"))return(r=this.convertRGB()).a=this.currentA,w.format(r,"rgb");if("hsl"==t){var e=this.convertHSL();return e.a=this.currentA,w.format(e,"hsl")}var r=this.convertRGB();return w.format(r,"hex")}},{key:"setInputColor",value:function(t){this.information.setInputColor(t),this.control.setInputColor(t),this.callbackColorValue()}},{key:"changeInputColorAfterNextFormat",value:function(){this.control.setInputColor(),this.callbackColorValue()}},{key:"callbackColorValue",value:function(t){t=t||this.getCurrentColor(),isNaN(this.currentA)||("function"==typeof this.opt.onChange&&this.opt.onChange.call(this,t),"function"==typeof this.colorpickerCallback&&this.colorpickerCallback(t))}},{key:"caculateHSV",value:function(){var t=this.palette.caculateSV(),e=this.control.caculateH(),r=t.s,n=t.v,i=e.h;0==t.width&&(i=0,r=0,n=0),this.currentH=i,this.currentS=r,this.currentV=n}},{key:"setColorUI",value:function(){this.control.setColorUI(),this.palette.setColorUI()}},{key:"setCurrentHSV",value:function(t,e,r,n){this.currentA=n,this.currentH=t,this.currentS=e,this.currentV=r}},{key:"setCurrentH",value:function(t){this.currentH=t}},{key:"setCurrentA",value:function(t){this.currentA=t}},{key:"setBackgroundColor",value:function(t){this.palette.setBackgroundColor(t)}},{key:"setCurrentFormat",value:function(t){this.format=t,this.information.setCurrentFormat(t)}},{key:"getHSV",value:function(t){return"hsl"==t.type?w.HSLtoHSV(t):w.RGBtoHSV(t)}},{key:"initColor",value:function(t,e){var r=t||"#FF0000",n=w.parse(r);e=e||n.type,this.setCurrentFormat(e);var i=this.getHSV(n);this.setCurrentHSV(i.h,i.s,i.v,n.a),this.setColorUI(),this.setHueColor(),this.setInputColor()}},{key:"changeInformationColor",value:function(t){var e=t||"#FF0000",r=w.parse(e),n=this.getHSV(r);this.setCurrentHSV(n.h,n.s,n.v,r.a),this.setColorUI(),this.setHueColor(),this.control.setInputColor(),this.callbackColorValue()}},{key:"setHueColor",value:function(){this.control.setOnlyHueColor()}},{key:"checkColorPickerClass",value:function(t){var e=new Ht(t).closest("codemirror-colorview"),r=new Ht(t).closest("codemirror-colorpicker"),n=new Ht(t).closest("CodeMirror");t.nodeName;return!!(r||e||n)}},{key:"checkInHtml",value:function(t){return"HTML"==t.nodeName}},{key:"mouseup document",value:function(t){this.palette.EventDocumentMouseUp(t),this.control.EventDocumentMouseUp(t),this.checkInHtml(t.target)||0==this.checkColorPickerClass(t.target)&&this.hide()}},{key:"mousemove document",value:function(t){this.palette.EventDocumentMouseMove(t),this.control.EventDocumentMouseMove(t)}},{key:"initializeEvent",value:function(){this.initializeEventMachin(),this.palette.initializeEvent(),this.control.initializeEvent(),this.information.initializeEvent(),this.currentColorSets.initializeEvent(),this.colorSetsChooser.initializeEvent(),this.contextMenu.initializeEvent()}},{key:"currentFormat",value:function(){this.information.currentFormat()}},{key:"toggleColorChooser",value:function(){this.colorSetsChooser.toggle()}},{key:"refreshColorSetsChooser",value:function(){this.colorSetsChooser.refresh()}},{key:"getColorSetsList",value:function(){return this.colorSetsList.getColorSetsList()}},{key:"setCurrentColorSets",value:function(t){this.colorSetsList.setCurrentColorSets(t),this.currentColorSets.refresh()}},{key:"setColorSets",value:function(t){this.colorSetsList.setUserList(t)}},{key:"destroy",value:function(){m(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this),this.control.destroy(),this.palette.destroy(),this.information.destroy(),this.colorSetsChooser.destroy(),this.colorSetsList.destroy(),this.currentColorSets.destroy(),this.contextMenu.destroy(),this.colorpickerCallback=void 0}}]),e}(),zt="codemirror-colorview",Ut="codemirror-colorview-background",Xt=["comment"];function Yt(t,e){"setValue"==e.origin?(t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update()):t.state.colorpicker.style_color_update(t.getCursor().line)}function qt(t,e){t.state.colorpicker.isUpdate||(t.state.colorpicker.isUpdate=!0,t.state.colorpicker.close_color_picker(),t.state.colorpicker.init_color_update(),t.state.colorpicker.style_color_update())}function Kt(t,e){Yt(t,{origin:"setValue"})}function Wt(t,e){t.state.colorpicker.keyup(e)}function Zt(t,e){t.state.colorpicker.is_edit_mode()&&t.state.colorpicker.check_mousedown(e)}function Jt(t,e){Yt(t,{origin:"setValue"})}function Qt(t){t.state.colorpicker.close_color_picker()}var te=function(){function t(e,r){g(this,t),r="boolean"==typeof r?{mode:"edit"}:Object.assign({mode:"edit"},r||{}),this.opt=r,this.cm=e,this.markers={},this.excluded_token=this.opt.excluded_token||Xt,this.opt.colorpicker?this.colorpicker=this.opt.colorpicker(this.opt):this.colorpicker=new Vt(this.opt),this.init_event()}return v(t,[{key:"init_event",value:function(){var t,e,r,n,i;this.cm.on("mousedown",Zt),this.cm.on("keyup",Wt),this.cm.on("change",Yt),this.cm.on("update",qt),this.cm.on("refresh",Kt),this.onPasteCallback=(t=this.cm,e=Jt,function(r){e.call(this,t,r)}),this.cm.getWrapperElement().addEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.on("scroll",(r=Qt,n=50,i=void 0,function(t,e){i&&clearTimeout(i),i=setTimeout(function(){r(t,e)},n||300)}))}},{key:"is_edit_mode",value:function(){return"edit"==this.opt.mode}},{key:"is_view_mode",value:function(){return"view"==this.opt.mode}},{key:"destroy",value:function(){this.cm.off("mousedown",Zt),this.cm.off("keyup",Wt),this.cm.off("change",Yt),this.cm.getWrapperElement().removeEventListener("paste",this.onPasteCallback),this.is_edit_mode()&&this.cm.off("scroll")}},{key:"hasClass",value:function(t,e){return!!t.className&&(" "+t.className+" ").indexOf(" "+e+" ")>-1}},{key:"check_mousedown",value:function(t){this.hasClass(t.target,Ut)?this.open_color_picker(t.target.parentNode):this.close_color_picker()}},{key:"popup_color_picker",value:function(t){var e=this.cm.getCursor(),r=this,n={lineNo:e.line,ch:e.ch,color:t||"#FFFFFF",isShortCut:!0};Object.keys(this.markers).forEach(function(t){if(("#"+t).indexOf("#"+n.lineNo+":")>-1){var e=r.markers[t];e.ch<=n.ch&&n.ch<=e.ch+e.color.length&&(n.ch=e.ch,n.color=e.color,n.nameColor=e.nameColor)}}),this.open_color_picker(n)}},{key:"open_color_picker",value:function(t){var e=t.lineNo,r=t.ch,n=t.nameColor,i=t.color;if(this.colorpicker){var o=this,a=i,l=this.cm.charCoords({line:e,ch:r});this.colorpicker.show({left:l.left,top:l.bottom,isShortCut:t.isShortCut||!1,hideDelay:o.opt.hideDelay||2e3},n||i,function(t){o.cm.replaceRange(t,{line:e,ch:r},{line:e,ch:r+a.length},"*colorpicker"),a=t})}}},{key:"close_color_picker",value:function(t){this.colorpicker&&this.colorpicker.hide()}},{key:"key",value:function(t,e){return[t,e].join(":")}},{key:"keyup",value:function(t){this.colorpicker&&("Escape"==t.key?this.colorpicker.hide():0==this.colorpicker.isShortCut&&this.colorpicker.hide())}},{key:"init_color_update",value:function(){this.markers={}}},{key:"style_color_update",value:function(t){if(t)this.match(t);else for(var e=this.cm.lineCount(),r=0;r-1)&&(delete this.markers[l],i[o].marker.clear())}}},{key:"match_result",value:function(t){return w.matches(t.text)}},{key:"submatch",value:function(t,e){var r=this;this.empty_marker(t,e);var n={next:0};this.match_result(e).forEach(function(i){r.render(n,t,e,i.color,i.nameColor)})}},{key:"match",value:function(t){var e=this.cm.getLineHandle(t),r=this;this.cm.operation(function(){r.submatch(t,e)})}},{key:"make_element",value:function(){var t=document.createElement("div");return t.className=zt,this.is_edit_mode()?t.title="open color picker":t.title="",t.back_element=this.make_background_element(),t.appendChild(t.back_element),t}},{key:"make_background_element",value:function(){var t=document.createElement("div");return t.className=Ut,t}},{key:"set_state",value:function(t,e,r,n){var i=this.create_marker(t,e);return i.lineNo=t,i.ch=e,i.color=r,i.nameColor=n,i}},{key:"create_marker",value:function(t,e){var r=this.key(t,e);return this.markers[r]||(this.markers[r]=this.make_element()),this.markers[r]}},{key:"has_marker",value:function(t,e){var r=this.key(t,e);return!!this.markers[r]}},{key:"update_element",value:function(t,e){t.back_element.style.backgroundColor=e}},{key:"set_mark",value:function(t,e,r){this.cm.setBookmark({line:t,ch:e},{widget:r,handleMouseEvents:!0})}},{key:"is_excluded_token",value:function(t,e){for(var r=this.cm.getTokenTypeAt({line:t,ch:e}),n=0,i=0,o=this.excluded_token.length;i0}},{key:"render",value:function(t,e,r,n,i){var o=r.text.indexOf(n,t.next);if(!0!==this.is_excluded_token(e,o)){if(t.next=o+n.length,this.has_marker(e,o))return this.update_element(this.create_marker(e,o),i||n),void this.set_state(e,o,n,i);var a=this.create_marker(e,o);this.update_element(a,i||n),this.set_state(e,o,n,i||n),this.set_mark(e,o,a)}}}]),t}();return t&&t.defineOption("colorpicker",!1,function(e,r,n){n&&n!=t.Init&&e.state.colorpicker&&(e.state.colorpicker.destroy(),e.state.colorpicker=null),r&&(e.state.colorpicker=new te(e,r))}),{Color:w,ColorNames:r,ColorPicker:Vt,ImageFilter:_t,HueColor:S,Canvas:h,ImageLoader:$}}(CodeMirror); diff --git a/index.html b/index.html index e303f10..ff34b82 100644 --- a/index.html +++ b/index.html @@ -651,6 +651,30 @@

Image Filter

+
+ +
+
+ +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
@@ -666,7 +690,7 @@

Image Filter

- +
@@ -714,9 +738,6 @@

Image Filter

-
- -
@@ -732,30 +753,7 @@

Image Filter

-
- -
-
- -
-
- -
-
- - -
-
- - -
-
- - -
-
- -
+ diff --git a/package.json b/package.json index 25cb68e..6783988 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codemirror-colorpicker", - "version": "1.9.1", + "version": "1.9.2", "description": "colorpicker for codemirror", "main": "./dist/codemirror-colorpicker.js", "scripts": { diff --git a/src/util/filter/functions.js b/src/util/filter/functions.js index 67e5f98..436c857 100644 --- a/src/util/filter/functions.js +++ b/src/util/filter/functions.js @@ -433,47 +433,64 @@ export function fillPixelColor (targetPixels, targetIndex, sourcePixels, source ) } +export function subPixelWeight (dstPixels, pixels, dstIndex, sx, sy, sw, sh, halfSide, side, weights) { + var r = 0, g = 0, b = 0, a = 0, len = side ** 2 ; + + for (var i = 0; i < len; i++) { + const cy = Math.floor(i / side) + const cx = i % side + + const scy = sy + cy - halfSide; + const scx = sx + cx - halfSide; + + if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) { + var srcIndex = (scy * sw + scx) * 4; + var wt = weights[cy * side + cx]; + r += pixels[srcIndex] * wt; + g += pixels[srcIndex + 1] * wt; + b += pixels[srcIndex + 2] * wt; + a += pixels[srcIndex + 3] * wt; // weight 를 곱한 값을 계속 더한다. + } + } + + fillColor(dstPixels, dstIndex, r, g, b, a) +} + +export function createSubPixelWeightFunction(weights, width, height, opaque) { + const side = Math.round(Math.sqrt(weights.length)); + const halfSide = Math.floor(side / 2); + const alphaFac = opaque ? 1 : 0; + + let FunctionCode = `let r = 0, g = 0, b = 0, a = 0, scy = 0, scx =0, si = 0; ` + + weights.forEach((wt, index) => { + const cy = Math.floor(index / side) + const cx = index % side + const distY = cy - halfSide + const distX = cx - halfSide + + FunctionCode += `scy = $sy + (${distY}); scx = $sx + (${distX}); if (scy >= 0 && scy < ${height} && scx >= 0 && scx < ${width}) { si = (scy * ${width} + scx) << 2; r += $sp[si] * (${wt}); g += $sp[si + 1] * (${wt}); b += $sp[si + 2] * (${wt}); a += $sp[si + 3] * (${wt}); } + ` + }) + + FunctionCode += `$dp[$di] = r; $dp[$di+1] = g;$dp[$di+2] = b;$dp[$di+3] = a + (${alphaFac})*(255-a); ` + + const subPixelFunction = new Function ('$dp', '$sp', '$di', '$sx', '$sy', FunctionCode ) + + return subPixelFunction +} + export function convolution(weights, opaque = true) { return function (bitmap, done, opt = {}) { - const side = Math.round(Math.sqrt(weights.length)); - const halfSide = Math.floor(side / 2); - - var w = bitmap.width; - var h = bitmap.height; - var sw = w; - var sh = h; let newBitmap = createBitmap(bitmap.pixels.length, bitmap.width, bitmap.height) - const alphaFac = opaque ? 1 : 0; - - packXY((pixels, dstIndex, x, y) => { - const sy = y; - const sx = x; - // const dstIndex = (y * w + x) * 4; - - var r = 0, g = 0, b = 0, a = 0; - for (var cy = 0; cy < side; cy++) { - for (var cx = 0; cx < side; cx++) { - - const scy = sy + cy - halfSide; - const scx = sx + cx - halfSide; - - if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) { - var srcIndex = (scy * sw + scx) * 4; - var wt = weights[cy * side + cx]; - r += pixels[srcIndex] * wt; - g += pixels[srcIndex + 1] * wt; - b += pixels[srcIndex + 2] * wt; - a += pixels[srcIndex + 3] * wt; // weight 를 곱한 값을 계속 더한다. - } - } - } - fillColor(newBitmap.pixels, dstIndex, r, g, b, a) - - })(bitmap, function () { + const subPixelWeightFunction = createSubPixelWeightFunction(weights, bitmap.width, bitmap.height, opaque) + + packXY((pixels, i, x, y) => { + subPixelWeightFunction (pixels, bitmap.pixels, i, x, y) + })(newBitmap, function () { done(newBitmap) }, opt) - } } @@ -545,12 +562,10 @@ export function parseFilter (filterString) { return result } -export function clamp (num) {ß +export function clamp (num) { return Math.min(255, num) } - - export function filter (str) { return merge(matches(str).map(it => { return it.arr diff --git a/src/util/filter/matrix/index.js b/src/util/filter/matrix/index.js index d8090e0..34e2bd6 100644 --- a/src/util/filter/matrix/index.js +++ b/src/util/filter/matrix/index.js @@ -12,7 +12,6 @@ import motionBlur from './motion-blur' import motionBlur2 from './motion-blur-2' import motionBlur3 from './motion-blur-3' import negative from './negative' -import random from './random' import sepia2 from './sepia2' import sharpen from './sharpen' import sobelHorizontal from './sobel-horizontal' @@ -45,7 +44,6 @@ export default { motionBlur3, 'motion-blur-3': motionBlur3, negative, - random, sepia2, sharpen, sobelHorizontal, diff --git a/src/util/filter/matrix/random.js b/src/util/filter/matrix/random.js deleted file mode 100644 index be5bd27..0000000 --- a/src/util/filter/matrix/random.js +++ /dev/null @@ -1,14 +0,0 @@ -import { - createRandomCount, - parseParamNumber, - createRandRange, - convolution -} from '../functions' - -export default function random (amount = 10, count = createRandomCount()) { - amount = parseParamNumber(amount) - return function (pixels, width, height) { - var rand = createRandRange(-1, 5, count); - return convolution(rand)(pixels, width, height); - } -} diff --git a/src/util/filter/pixel/gradient.js b/src/util/filter/pixel/gradient.js index 77569d2..ee12a24 100644 --- a/src/util/filter/pixel/gradient.js +++ b/src/util/filter/pixel/gradient.js @@ -34,7 +34,10 @@ export default function gradient () { return it.value }).join(',') - let $colors = Color.gradient(params, $scale).map(c => { return Color.parse(c) }) + let $colors = Color.gradient(params, $scale).map(c => { + const { r, g, b, a } = Color.parse(c) + return {r, g, b, a} + }) return pixel(() => { const colorIndex = $clamp($Color.brightness($r , $g , $b)) diff --git a/src/util/filter/pixel/threshold-color.js b/src/util/filter/pixel/threshold-color.js index a613227..6670e23 100644 --- a/src/util/filter/pixel/threshold-color.js +++ b/src/util/filter/pixel/threshold-color.js @@ -1,5 +1,3 @@ -import Color from '../../Color' - import { parseParamNumber, pixel @@ -13,7 +11,8 @@ export default function thresholdColor (scale = 200, amount = 100, hasColor = tr const $hasColor = hasColor return pixel(() => { - const v = ($C * Color.brightness($r, $g, $b) ) >= $scale ? 255 : 0; + // refer to Color.brightness + const v = ($C * Math.ceil($r * 0.2126 + $g * 0.7152 + $b * 0.0722) ) >= $scale ? 255 : 0; if ($hasColor) {