From 4eea4e5eac416241643067335888fea1cf737173 Mon Sep 17 00:00:00 2001 From: bhavayAnand9 Date: Tue, 27 Nov 2018 13:18:08 +0530 Subject: [PATCH] align add-step button with select-module input --- dist/image-sequencer.js | 9126 +++++++++++++++++------------------ dist/image-sequencer.min.js | 2 +- examples/demo.css | 2 +- 3 files changed, 4565 insertions(+), 4565 deletions(-) diff --git a/dist/image-sequencer.js b/dist/image-sequencer.js index ffa4a44257..51b44ac34e 100644 --- a/dist/image-sequencer.js +++ b/dist/image-sequencer.js @@ -22639,1000 +22639,1000 @@ var info = { } module.exports = [Invert,info]; },{}],62:[function(require,module,exports){ -/** - * Copyright (c) 2015 Guyon Roche - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions:

- * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -"use strict"; - -var _ = require("underscore"); - -var main = module.exports = { - Bitmap: require("./lib/bitmap") -}; - -_.extend(main, require("./lib/enums")); +/** + * Copyright (c) 2015 Guyon Roche + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions:

+ * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +"use strict"; + +var _ = require("underscore"); + +var main = module.exports = { + Bitmap: require("./lib/bitmap") +}; + +_.extend(main, require("./lib/enums")); },{"./lib/bitmap":63,"./lib/enums":64,"underscore":145}],63:[function(require,module,exports){ (function (Buffer){ -/** - * Copyright (c) 2015 Guyon Roche - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions:

- * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -"use strict"; - -var fs = require("fs"); -var _ = require("underscore"); -var Promise = require("bluebird"); -var jpeg = require("jpeg-js"); -//var png = require("png-js"); -var PNG = require("node-png").PNG; - -var Enums = require("./enums"); -var Utils = require("./utils"); -var Resize = require("./resize"); -//var Graphics = require("./graphics"); - -// default pad colour -var transparentBlack = { - r: 0, g: 0, b: 0, a: 0 -}; - -var Bitmap = module.exports = function(options) { - if (options) { - if (options instanceof Bitmap) { - this._data = { - data: new Buffer(options.data.data), - width: options.width, - height: options.height - }; - } else if (options.data) { - // attach to supplied data - this._data = options; - } else if (options.width && options.height) { - // construct new bitmap - this._data = { - data: new Buffer(4 * options.width * options.height), - width: options.width, - height: options.height - }; - - // optional colour - if (options.color) { - this._fill(options.color); - } - } - } -}; - -Bitmap.prototype = { - get width() { - return this._data.width; - }, - get height() { - return this._data.height; - }, - //get graphics() { - // if (!this._graphics) { - // this._graphics = new Graphics(this); - // } - // return this._graphics; - //}, - - attach: function(data) { - var prev = this._data; - this._data = data; - return prev; - }, - detach: function() { - var data = this._data; - delete this._data; - return data; - }, - - _deduceFileType: function(filename) { - if (!filename) { - throw new Error("Can't determine image type"); - } - switch (filename.substr(-4).toLowerCase()) { - case ".jpg": - return Enums.ImageType.JPG; - case ".png": - return Enums.ImageType.PNG; - } - if (filename.substr(-5).toLowerCase() == ".jpeg") { - return Enums.ImageType.JPG; - } - throw new Error("Can't recognise image type: " + filename); - }, - - _readStream: function(stream) { - var self = this; - var deferred = Promise.defer(); - - var chunks = []; - stream.on('data', function(chunk) { - chunks.push(chunk); - }); - stream.on('end', function() { - var data = Buffer.concat(chunks); - deferred.resolve(data); - }); - stream.on('error', function(error) { - deferred.reject(error); - }); - - return deferred.promise; - }, - _readPNG: function(stream) { - var deferred = Promise.defer(); - - var png = new PNG({filterType: 4}); - png.on('parsed', function() { - deferred.resolve(png); - }); - png.on('error', function(error) { - deferred.rejecyt(error); - }); - stream.pipe(png); - - return deferred.promise; - }, - _parseOptions: function(options, filename) { - options = options || {}; - if (typeof options === "number") { - options = { type: options }; - } - options.type = options.type || this._deduceFileType(filename); - return options; - }, - read: function(stream, options) { - var self = this; - options = this._parseOptions(options); - - switch(options.type) { - case Enums.ImageType.JPG: - return this._readStream(stream) - .then(function(data) { - self._data = jpeg.decode(data); - }); - case Enums.ImageType.PNG: - return this._readPNG(stream) - .then(function(png) { - self._data = { - data: png.data, - width: png.width, - height: png.height - }; - }); - default: - return Promise.reject(new Error("Not supported: ImageType " + options.type)); - } - }, - readFile: function(filename, options) { - var self = this; - return Utils.fs.exists(filename) - .then(function(exists) { - if (exists) { - options = self._parseOptions(options, filename); - var stream = fs.createReadStream(filename); - return self.read(stream, options); - } else { - throw new Error("File Not Found: " + filename); - } - }); - }, - - write: function(stream, options) { - options = this._parseOptions(options); - var deferred = Promise.defer(); - try { - stream.on('finish', function() { - deferred.resolve(); - }); - stream.on('error', function(error) { - deferred.reject(error); - }); - - switch(options.type) { - case Enums.ImageType.JPG: - var buffer = jpeg.encode(this._data, options.quality || 90).data; - stream.write(buffer); - stream.end(); - break; - case Enums.ImageType.PNG: - var png = new PNG(); - png.width = this.width; - png.height = this.height; - png.data = this._data.data; - png.on('end', function() { - deferred.resolve(); - }); - png.on('error', function(error) { - deferred.reject(error); - }); - png.pack().pipe(stream); - break; - default: - throw new Error("Not supported: ImageType " + options.type); - } - } - catch(ex) { - deferred.reject(ex); - } - return deferred.promise; - }, - writeFile: function(filename, options) { - options = this._parseOptions(options, filename); - var stream = fs.createWriteStream(filename); - return this.write(stream, options); - }, - - clone: function() { - return new Bitmap({ - width: this.width, - height: this.height, - data: new Buffer(this._data.data) - }); - }, - - setPixel: function(x,y, r,g,b,a) { - if (g === undefined) { - var color = r; - r = color.r; - g = color.g; - b = color.b; - a = color.a; - } - if (a === undefined) a = 255; - var pos = (y * this.width + x) * 4; - var buffer = this._data.data; - buffer[pos++] = r; - buffer[pos++] = g; - buffer[pos++] = b; - buffer[pos++] = a; - }, - getPixel: function(x,y, color) { - var pos = (y * this.width + x) * 4; - color = color || {}; - var buffer = this._data.data; - color.r = buffer[pos++]; - color.g = buffer[pos++]; - color.b = buffer[pos++]; - color.a = buffer[pos++]; - return color; - }, - - negative: function() { - var that = new Bitmap({width: this.width, height: this.height}); - var n = this.width * this.height; - - var src = this._data.data; - var dst = that._data.data; - var srcPos = 0; - var dstPos = 0; - for (var i = 0; i < n; i++) { - dst[dstPos++] = 255 - src[srcPos++]; - dst[dstPos++] = 255 - src[srcPos++]; - dst[dstPos++] = 255 - src[srcPos++]; - dst[dstPos++] = src[srcPos++]; - } - return that; - }, - - resize: function(options) { - var that = new Bitmap(options); - var temp; - switch (options.fit) { - case "pad": // fit all of src in dst with aspect ratio preserved. - var padColor = options.padColor || transparentBlack; - var srcAr = this.width / this.height; - var w2 = Math.round(srcAr * that.height); - var h2 = Math.round(that.width / srcAr); - var wMargin = 0; - var hMargin = 0; - if (w2 < that.width) { - // pad sides - temp = new Bitmap({width: w2, height: that.height}); - wMargin = (that.width - w2) / 2; - that._fill(padColor, 0, 0, Math.floor(wMargin), that.height); - that._fill(padColor, that.width - Math.ceil(wMargin), 0, Math.ceil(wMargin), that.height); - - Resize[options.algorithm](this, temp, options); - that._blt(temp, {left: Math.floor(wMargin), top: Math.floor(hMargin)}); - } else if (h2 < that.height) { - // pad top & bottom - temp = new Bitmap({width: that.width, height: h2}); - hMargin = (that.height - h2) / 2; - that._fill(padColor, 0, 0, that.width, Math.floor(hMargin)); - that._fill(padColor, 0, that.height - Math.ceil(hMargin), that.width, Math.ceil(hMargin)); - - Resize[options.algorithm](this, temp, options); - that._blt(temp, {left: Math.floor(wMargin), top: Math.floor(hMargin)}); - } else { - // stretch straight into that - Resize[options.algorithm](this, that, options); - } - break; - case "crop": // crop original to fit in dst with aspect ratio preserved - var gravity = options.gravity || {x: 0.5, y: 0.5}; - var dstAr = that.width / that.height; - var w2 = Math.round(dstAr * this.height); - var h2 = Math.round(this.width / dstAr); - if (w2 < this.width) { - // crop src width - var dw = this.width - w2; - temp = this.crop({left: Math.round(gravity.x * dw), top: 0, width: w2, height: this.height}); - } else if (h2 < this.height) { - // crop src height - var dh = this.height - h2; - temp = this.crop({left: 0, top: Math.round(gravity.y * dh), width: this.width, height: h2}); - } else { - temp = this; - } - Resize[options.algorithm](temp, that, options); - break; - case "stretch": - default: - Resize[options.algorithm](this, that, options); - break; - } - - return that; - }, - - rotate: function(options) { - // TODO: crop, user supplied dst width, height - - // options.degrees || options.radians; - // options.fit = ['pad','crop','same'] - // options.padColor - var radians = options.radians !== undefined ? options.radians : 3.141592653589793 * options.degrees / 180; - if (radians < 0.000000001) { - return new Bitmap(this); - } - //console.log("radians=" + radians); - - var rotators = { - forward: { - cos: Math.cos(radians), - sin: Math.sin(radians) - }, - backward: { - cos: Math.cos(-radians), - sin: Math.sin(-radians) - } - } - //console.log("cos=" + cos + ", sin=" + sin) - - var srcWidth = this.width; - var srcHeight = this.height; - var srcWidthHalf = srcWidth / 2; - var srcHeightHalf = srcHeight / 2; - - var padColor = options.padColor || transparentBlack; - var padArray = [padColor.r, padColor.g, padColor.b, padColor.a]; - var rotate = function(point, rotator) { - // in-place rotation of point - var x = rotator.cos * point.x - rotator.sin * point.y; - var y = rotator.sin * point.x + rotator.cos * point.y; - point.x = x; - point.y = y; - return point; - }; - var cropToSource = function(point) { - var m = Math.abs(point.x/srcWidthHalf); - var n = Math.abs(point.y/srcHeightHalf); - return Math.max(m,n); - }; - - var dstWidth, dstHeight; - switch (options.fit) { - case 'custom': - dstWidth = options.width; - dstHeight = options.height; - break; - case 'pad': - // entire src fits in dst - var tl = rotate({x:-srcWidthHalf,y:srcHeightHalf}, rotators.forward); - var tr = rotate({x:srcWidthHalf,y:srcHeightHalf}, rotators.forward); - var bl = rotate({x:-srcWidthHalf,y:-srcHeightHalf}, rotators.forward); - var br = rotate({x:srcWidthHalf,y:-srcHeightHalf}, rotators.forward); - dstWidth = Math.round(Math.max(tl.x,tr.x,bl.x,br.x) - Math.min(tl.x,tr.x,bl.x,br.x)); - dstHeight = Math.round(Math.max(tl.y,tr.y,bl.y,br.y) - Math.min(tl.y,tr.y,bl.y,br.y)); - break; - case 'crop': - var tl = rotate({x:-srcWidthHalf,y:srcHeightHalf}, rotators.forward); - var tr = rotate({x:srcWidthHalf,y:srcHeightHalf}, rotators.forward); - var bl = rotate({x:-srcWidthHalf,y:-srcHeightHalf}, rotators.forward); - var br = rotate({x:srcWidthHalf,y:-srcHeightHalf}, rotators.forward); - var d = Math.max(cropToSource(tl), cropToSource(tr), cropToSource(bl), cropToSource(br)); - dstWidth = Math.floor(srcWidth / d); - dstHeight = Math.floor(srcHeight / d); - break; - case 'same': - default: - // dst is same size as src - dstWidth = srcWidth; - dstHeight = srcHeight; - break; - } - - var that = new Bitmap({width: dstWidth, height: dstHeight}); - - var srcBuf = this._data.data; - var dstBuf = that._data.data; - - // we will rotate the destination pixels back to the source and interpolate the colour - var srcCoord = {}; - var dstWidthHalf = dstWidth / 2; - var dstHeightHalf = dstHeight / 2; - var dstWidth4 = dstWidth * 4; - var srcWidth4 = srcWidth * 4; - - //console.log("src=[" + srcWidth + "," + srcHeight + "]") - //console.log("dst=[" + dstWidth + "," + dstHeight + "]") - for (var i = 0; i < dstHeight; i++) { - for (var j = 0; j < dstWidth; j++) { - // calculate src coords - srcCoord.x = j - dstWidthHalf; - srcCoord.y = dstHeightHalf - i; - //console.log("x=" + srcCoord.x + ", y=" + srcCoord.y); - rotate(srcCoord, rotators.backward); - //console.log(" ==> x=" + srcCoord.x + ", y=" + srcCoord.y); - - // srcX and SrcY are in src coords - var srcX = srcCoord.x + srcWidthHalf; - var srcY = srcHeightHalf - srcCoord.y; - //console.log("srcX=" + srcX + ", srcY=" + srcY); - - // now interpolate (bilinear! - var dstPos = (i * dstWidth + j) * 4; - //console.log("dstPos=" + dstPos) - if ((srcX > -1) && (srcX < srcWidth) && (srcY > -1) && (srcY < srcHeight)) { - var srcPosX = Math.floor(srcX); - var srcPosY = Math.floor(srcY); - var srcPos = (srcPosY * srcWidth + srcPosX) * 4; - for (var k = 0; k < 4; k++) { - var kSrcPos = srcPos + k; - var kPad = padArray[k]; - - var tl = ((srcX >= 0) && (srcY >= 0)) ? srcBuf[kSrcPos] : kPad; - var tr = ((srcX < srcWidth-1) && (srcY >= 0)) ? srcBuf[kSrcPos+4] : kPad; - var bl = ((srcX >= 0) && (srcY < srcHeight-1)) ? srcBuf[kSrcPos + srcWidth4] : kPad; - var br = ((srcX < srcWidth-1) && (srcY < srcHeight-1)) ? srcBuf[kSrcPos + srcWidth4 + 4] : kPad; - - var tx = srcX - srcPosX; - var ty = srcY - srcPosY; - - var t = (1-tx) * tl + tx * tr; - var b = (1-tx) * bl + tx * br; - dstBuf[dstPos++] = (1-ty) * t + ty * b; - } - } else { - dstBuf[dstPos++] = padColor.r; - dstBuf[dstPos++] = padColor.g; - dstBuf[dstPos++] = padColor.b; - dstBuf[dstPos++] = padColor.a; - } - } - } - return that; - }, - - crop: function(options) { - var t = options.top; - var l = options.left; - var w = options.width; - var h = options.height; - //console.log("Crop: l="+l + ", t="+t + ", w="+w + ", h="+h); - - var that = new Bitmap({width: w, height: h}); - - var srcBuf = this._data.data; - var dstBuf = that._data.data; - - var w4 = w * 4; - for (var i = 0; i < h; i++) { - var srcPos = ((i+t)*this.width + l) * 4; - var dstPos = i * w * 4; - srcBuf.copy(dstBuf, dstPos, srcPos, srcPos + w4); - } - return that; - }, - - blur: function(options) { - // todo: expand to own file with different blur algorithms - var that = new Bitmap({width: this.width, height: this.height}); - var w = this.width; - var h = this.height; - - var W = w-1; - var H = h-1; - - var V = w*4; // used for i offsets - - var src = this._data.data; - var dst = that._data.data; - for (var i = 0; i < h; i++) { - for (var j = 0; j < w; j++) { - for (var k = 0; k < 4; k++) { - var pos = (i*w + j) * 4 + k; - var t = src[pos -(i>0?V:0) - (j>0?4:0)] * 1 + // 1/16 - src[pos -(i>0?V:0) ] * 2 + // 2/16 - src[pos -(i>0?V:0) + (j0?4:0)] * 2 + // 2/16 - src[pos ] * 4 + // 4/16 - src[pos + (j0?4:0)] * 1 + // 1/16 - src[pos +(i + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +"use strict"; + +var fs = require("fs"); +var _ = require("underscore"); +var Promise = require("bluebird"); +var jpeg = require("jpeg-js"); +//var png = require("png-js"); +var PNG = require("node-png").PNG; + +var Enums = require("./enums"); +var Utils = require("./utils"); +var Resize = require("./resize"); +//var Graphics = require("./graphics"); + +// default pad colour +var transparentBlack = { + r: 0, g: 0, b: 0, a: 0 +}; + +var Bitmap = module.exports = function(options) { + if (options) { + if (options instanceof Bitmap) { + this._data = { + data: new Buffer(options.data.data), + width: options.width, + height: options.height + }; + } else if (options.data) { + // attach to supplied data + this._data = options; + } else if (options.width && options.height) { + // construct new bitmap + this._data = { + data: new Buffer(4 * options.width * options.height), + width: options.width, + height: options.height + }; + + // optional colour + if (options.color) { + this._fill(options.color); + } + } + } +}; + +Bitmap.prototype = { + get width() { + return this._data.width; + }, + get height() { + return this._data.height; + }, + //get graphics() { + // if (!this._graphics) { + // this._graphics = new Graphics(this); + // } + // return this._graphics; + //}, + + attach: function(data) { + var prev = this._data; + this._data = data; + return prev; + }, + detach: function() { + var data = this._data; + delete this._data; + return data; + }, + + _deduceFileType: function(filename) { + if (!filename) { + throw new Error("Can't determine image type"); + } + switch (filename.substr(-4).toLowerCase()) { + case ".jpg": + return Enums.ImageType.JPG; + case ".png": + return Enums.ImageType.PNG; + } + if (filename.substr(-5).toLowerCase() == ".jpeg") { + return Enums.ImageType.JPG; + } + throw new Error("Can't recognise image type: " + filename); + }, + + _readStream: function(stream) { + var self = this; + var deferred = Promise.defer(); + + var chunks = []; + stream.on('data', function(chunk) { + chunks.push(chunk); + }); + stream.on('end', function() { + var data = Buffer.concat(chunks); + deferred.resolve(data); + }); + stream.on('error', function(error) { + deferred.reject(error); + }); + + return deferred.promise; + }, + _readPNG: function(stream) { + var deferred = Promise.defer(); + + var png = new PNG({filterType: 4}); + png.on('parsed', function() { + deferred.resolve(png); + }); + png.on('error', function(error) { + deferred.rejecyt(error); + }); + stream.pipe(png); + + return deferred.promise; + }, + _parseOptions: function(options, filename) { + options = options || {}; + if (typeof options === "number") { + options = { type: options }; + } + options.type = options.type || this._deduceFileType(filename); + return options; + }, + read: function(stream, options) { + var self = this; + options = this._parseOptions(options); + + switch(options.type) { + case Enums.ImageType.JPG: + return this._readStream(stream) + .then(function(data) { + self._data = jpeg.decode(data); + }); + case Enums.ImageType.PNG: + return this._readPNG(stream) + .then(function(png) { + self._data = { + data: png.data, + width: png.width, + height: png.height + }; + }); + default: + return Promise.reject(new Error("Not supported: ImageType " + options.type)); + } + }, + readFile: function(filename, options) { + var self = this; + return Utils.fs.exists(filename) + .then(function(exists) { + if (exists) { + options = self._parseOptions(options, filename); + var stream = fs.createReadStream(filename); + return self.read(stream, options); + } else { + throw new Error("File Not Found: " + filename); + } + }); + }, + + write: function(stream, options) { + options = this._parseOptions(options); + var deferred = Promise.defer(); + try { + stream.on('finish', function() { + deferred.resolve(); + }); + stream.on('error', function(error) { + deferred.reject(error); + }); + + switch(options.type) { + case Enums.ImageType.JPG: + var buffer = jpeg.encode(this._data, options.quality || 90).data; + stream.write(buffer); + stream.end(); + break; + case Enums.ImageType.PNG: + var png = new PNG(); + png.width = this.width; + png.height = this.height; + png.data = this._data.data; + png.on('end', function() { + deferred.resolve(); + }); + png.on('error', function(error) { + deferred.reject(error); + }); + png.pack().pipe(stream); + break; + default: + throw new Error("Not supported: ImageType " + options.type); + } + } + catch(ex) { + deferred.reject(ex); + } + return deferred.promise; + }, + writeFile: function(filename, options) { + options = this._parseOptions(options, filename); + var stream = fs.createWriteStream(filename); + return this.write(stream, options); + }, + + clone: function() { + return new Bitmap({ + width: this.width, + height: this.height, + data: new Buffer(this._data.data) + }); + }, + + setPixel: function(x,y, r,g,b,a) { + if (g === undefined) { + var color = r; + r = color.r; + g = color.g; + b = color.b; + a = color.a; + } + if (a === undefined) a = 255; + var pos = (y * this.width + x) * 4; + var buffer = this._data.data; + buffer[pos++] = r; + buffer[pos++] = g; + buffer[pos++] = b; + buffer[pos++] = a; + }, + getPixel: function(x,y, color) { + var pos = (y * this.width + x) * 4; + color = color || {}; + var buffer = this._data.data; + color.r = buffer[pos++]; + color.g = buffer[pos++]; + color.b = buffer[pos++]; + color.a = buffer[pos++]; + return color; + }, + + negative: function() { + var that = new Bitmap({width: this.width, height: this.height}); + var n = this.width * this.height; + + var src = this._data.data; + var dst = that._data.data; + var srcPos = 0; + var dstPos = 0; + for (var i = 0; i < n; i++) { + dst[dstPos++] = 255 - src[srcPos++]; + dst[dstPos++] = 255 - src[srcPos++]; + dst[dstPos++] = 255 - src[srcPos++]; + dst[dstPos++] = src[srcPos++]; + } + return that; + }, + + resize: function(options) { + var that = new Bitmap(options); + var temp; + switch (options.fit) { + case "pad": // fit all of src in dst with aspect ratio preserved. + var padColor = options.padColor || transparentBlack; + var srcAr = this.width / this.height; + var w2 = Math.round(srcAr * that.height); + var h2 = Math.round(that.width / srcAr); + var wMargin = 0; + var hMargin = 0; + if (w2 < that.width) { + // pad sides + temp = new Bitmap({width: w2, height: that.height}); + wMargin = (that.width - w2) / 2; + that._fill(padColor, 0, 0, Math.floor(wMargin), that.height); + that._fill(padColor, that.width - Math.ceil(wMargin), 0, Math.ceil(wMargin), that.height); + + Resize[options.algorithm](this, temp, options); + that._blt(temp, {left: Math.floor(wMargin), top: Math.floor(hMargin)}); + } else if (h2 < that.height) { + // pad top & bottom + temp = new Bitmap({width: that.width, height: h2}); + hMargin = (that.height - h2) / 2; + that._fill(padColor, 0, 0, that.width, Math.floor(hMargin)); + that._fill(padColor, 0, that.height - Math.ceil(hMargin), that.width, Math.ceil(hMargin)); + + Resize[options.algorithm](this, temp, options); + that._blt(temp, {left: Math.floor(wMargin), top: Math.floor(hMargin)}); + } else { + // stretch straight into that + Resize[options.algorithm](this, that, options); + } + break; + case "crop": // crop original to fit in dst with aspect ratio preserved + var gravity = options.gravity || {x: 0.5, y: 0.5}; + var dstAr = that.width / that.height; + var w2 = Math.round(dstAr * this.height); + var h2 = Math.round(this.width / dstAr); + if (w2 < this.width) { + // crop src width + var dw = this.width - w2; + temp = this.crop({left: Math.round(gravity.x * dw), top: 0, width: w2, height: this.height}); + } else if (h2 < this.height) { + // crop src height + var dh = this.height - h2; + temp = this.crop({left: 0, top: Math.round(gravity.y * dh), width: this.width, height: h2}); + } else { + temp = this; + } + Resize[options.algorithm](temp, that, options); + break; + case "stretch": + default: + Resize[options.algorithm](this, that, options); + break; + } + + return that; + }, + + rotate: function(options) { + // TODO: crop, user supplied dst width, height + + // options.degrees || options.radians; + // options.fit = ['pad','crop','same'] + // options.padColor + var radians = options.radians !== undefined ? options.radians : 3.141592653589793 * options.degrees / 180; + if (radians < 0.000000001) { + return new Bitmap(this); + } + //console.log("radians=" + radians); + + var rotators = { + forward: { + cos: Math.cos(radians), + sin: Math.sin(radians) + }, + backward: { + cos: Math.cos(-radians), + sin: Math.sin(-radians) + } + } + //console.log("cos=" + cos + ", sin=" + sin) + + var srcWidth = this.width; + var srcHeight = this.height; + var srcWidthHalf = srcWidth / 2; + var srcHeightHalf = srcHeight / 2; + + var padColor = options.padColor || transparentBlack; + var padArray = [padColor.r, padColor.g, padColor.b, padColor.a]; + var rotate = function(point, rotator) { + // in-place rotation of point + var x = rotator.cos * point.x - rotator.sin * point.y; + var y = rotator.sin * point.x + rotator.cos * point.y; + point.x = x; + point.y = y; + return point; + }; + var cropToSource = function(point) { + var m = Math.abs(point.x/srcWidthHalf); + var n = Math.abs(point.y/srcHeightHalf); + return Math.max(m,n); + }; + + var dstWidth, dstHeight; + switch (options.fit) { + case 'custom': + dstWidth = options.width; + dstHeight = options.height; + break; + case 'pad': + // entire src fits in dst + var tl = rotate({x:-srcWidthHalf,y:srcHeightHalf}, rotators.forward); + var tr = rotate({x:srcWidthHalf,y:srcHeightHalf}, rotators.forward); + var bl = rotate({x:-srcWidthHalf,y:-srcHeightHalf}, rotators.forward); + var br = rotate({x:srcWidthHalf,y:-srcHeightHalf}, rotators.forward); + dstWidth = Math.round(Math.max(tl.x,tr.x,bl.x,br.x) - Math.min(tl.x,tr.x,bl.x,br.x)); + dstHeight = Math.round(Math.max(tl.y,tr.y,bl.y,br.y) - Math.min(tl.y,tr.y,bl.y,br.y)); + break; + case 'crop': + var tl = rotate({x:-srcWidthHalf,y:srcHeightHalf}, rotators.forward); + var tr = rotate({x:srcWidthHalf,y:srcHeightHalf}, rotators.forward); + var bl = rotate({x:-srcWidthHalf,y:-srcHeightHalf}, rotators.forward); + var br = rotate({x:srcWidthHalf,y:-srcHeightHalf}, rotators.forward); + var d = Math.max(cropToSource(tl), cropToSource(tr), cropToSource(bl), cropToSource(br)); + dstWidth = Math.floor(srcWidth / d); + dstHeight = Math.floor(srcHeight / d); + break; + case 'same': + default: + // dst is same size as src + dstWidth = srcWidth; + dstHeight = srcHeight; + break; + } + + var that = new Bitmap({width: dstWidth, height: dstHeight}); + + var srcBuf = this._data.data; + var dstBuf = that._data.data; + + // we will rotate the destination pixels back to the source and interpolate the colour + var srcCoord = {}; + var dstWidthHalf = dstWidth / 2; + var dstHeightHalf = dstHeight / 2; + var dstWidth4 = dstWidth * 4; + var srcWidth4 = srcWidth * 4; + + //console.log("src=[" + srcWidth + "," + srcHeight + "]") + //console.log("dst=[" + dstWidth + "," + dstHeight + "]") + for (var i = 0; i < dstHeight; i++) { + for (var j = 0; j < dstWidth; j++) { + // calculate src coords + srcCoord.x = j - dstWidthHalf; + srcCoord.y = dstHeightHalf - i; + //console.log("x=" + srcCoord.x + ", y=" + srcCoord.y); + rotate(srcCoord, rotators.backward); + //console.log(" ==> x=" + srcCoord.x + ", y=" + srcCoord.y); + + // srcX and SrcY are in src coords + var srcX = srcCoord.x + srcWidthHalf; + var srcY = srcHeightHalf - srcCoord.y; + //console.log("srcX=" + srcX + ", srcY=" + srcY); + + // now interpolate (bilinear! + var dstPos = (i * dstWidth + j) * 4; + //console.log("dstPos=" + dstPos) + if ((srcX > -1) && (srcX < srcWidth) && (srcY > -1) && (srcY < srcHeight)) { + var srcPosX = Math.floor(srcX); + var srcPosY = Math.floor(srcY); + var srcPos = (srcPosY * srcWidth + srcPosX) * 4; + for (var k = 0; k < 4; k++) { + var kSrcPos = srcPos + k; + var kPad = padArray[k]; + + var tl = ((srcX >= 0) && (srcY >= 0)) ? srcBuf[kSrcPos] : kPad; + var tr = ((srcX < srcWidth-1) && (srcY >= 0)) ? srcBuf[kSrcPos+4] : kPad; + var bl = ((srcX >= 0) && (srcY < srcHeight-1)) ? srcBuf[kSrcPos + srcWidth4] : kPad; + var br = ((srcX < srcWidth-1) && (srcY < srcHeight-1)) ? srcBuf[kSrcPos + srcWidth4 + 4] : kPad; + + var tx = srcX - srcPosX; + var ty = srcY - srcPosY; + + var t = (1-tx) * tl + tx * tr; + var b = (1-tx) * bl + tx * br; + dstBuf[dstPos++] = (1-ty) * t + ty * b; + } + } else { + dstBuf[dstPos++] = padColor.r; + dstBuf[dstPos++] = padColor.g; + dstBuf[dstPos++] = padColor.b; + dstBuf[dstPos++] = padColor.a; + } + } + } + return that; + }, + + crop: function(options) { + var t = options.top; + var l = options.left; + var w = options.width; + var h = options.height; + //console.log("Crop: l="+l + ", t="+t + ", w="+w + ", h="+h); + + var that = new Bitmap({width: w, height: h}); + + var srcBuf = this._data.data; + var dstBuf = that._data.data; + + var w4 = w * 4; + for (var i = 0; i < h; i++) { + var srcPos = ((i+t)*this.width + l) * 4; + var dstPos = i * w * 4; + srcBuf.copy(dstBuf, dstPos, srcPos, srcPos + w4); + } + return that; + }, + + blur: function(options) { + // todo: expand to own file with different blur algorithms + var that = new Bitmap({width: this.width, height: this.height}); + var w = this.width; + var h = this.height; + + var W = w-1; + var H = h-1; + + var V = w*4; // used for i offsets + + var src = this._data.data; + var dst = that._data.data; + for (var i = 0; i < h; i++) { + for (var j = 0; j < w; j++) { + for (var k = 0; k < 4; k++) { + var pos = (i*w + j) * 4 + k; + var t = src[pos -(i>0?V:0) - (j>0?4:0)] * 1 + // 1/16 + src[pos -(i>0?V:0) ] * 2 + // 2/16 + src[pos -(i>0?V:0) + (j0?4:0)] * 2 + // 2/16 + src[pos ] * 4 + // 4/16 + src[pos + (j0?4:0)] * 1 + // 1/16 + src[pos +(i - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -"use strict"; - -module.exports = { - ImageType: { - JPG: 1, - PNG: 2 - } +/** + * Copyright (c) 2015 Guyon Roche + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions:

+ * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +"use strict"; + +module.exports = { + ImageType: { + JPG: 1, + PNG: 2 + } }; },{}],65:[function(require,module,exports){ (function (Buffer){ -/** - * Copyright (c) 2015 Guyon Roche - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions:

- * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -"use strict"; - -var _ = require("underscore"); -var Promise = require("bluebird"); - -module.exports = { - _writeFile: function(width, height, data, filename) { - // for debugging - - var Bitmap = require("./bitmap"); - var bmp = new Bitmap({ - width: width, height: height, - data: data - }); - bmp.writeFile(filename); - }, - - nearestNeighbor: function(src, dst, options) { - - var wSrc = src.width; - var hSrc = src.height; - //console.log("wSrc="+wSrc + ", hSrc="+hSrc); - - var wDst = dst.width; - var hDst = dst.height; - //console.log("wDst="+wDst + ", hDst="+hDst); - - var bufSrc = src._data.data; - var bufDst = dst._data.data; - - for (var i = 0; i < hDst; i++) { - for (var j = 0; j < wDst; j++) { - var posDst = (i * wDst + j) * 4; - - var iSrc = Math.round(i * hSrc / hDst); - var jSrc = Math.round(j * wSrc / wDst); - var posSrc = (iSrc * wSrc + jSrc) * 4; - - bufDst[posDst++] = bufSrc[posSrc++]; - bufDst[posDst++] = bufSrc[posSrc++]; - bufDst[posDst++] = bufSrc[posSrc++]; - bufDst[posDst++] = bufSrc[posSrc++]; - } - } - }, - bilinearInterpolation: function(src, dst, options) { - - var wSrc = src.width; - var hSrc = src.height; - //console.log("wSrc="+wSrc + ", hSrc="+hSrc); - - var wDst = dst.width; - var hDst = dst.height; - //console.log("wDst="+wDst + ", hDst="+hDst); - - var bufSrc = src._data.data; - var bufDst = dst._data.data; - - var interpolate = function(k, kMin, vMin, kMax, vMax) { - // special case - k is integer - if (kMin === kMax) { - return vMin; - } - - return Math.round((k - kMin) * vMax + (kMax - k) * vMin); - }; - var assign = function(pos, offset, x, xMin, xMax, y, yMin, yMax) { - var posMin = (yMin * wSrc + xMin) * 4 + offset; - var posMax = (yMin * wSrc + xMax) * 4 + offset; - var vMin = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]); - - // special case, y is integer - if (yMax === yMin) { - bufDst[pos+offset] = vMin; - } else { - posMin = (yMax * wSrc + xMin) * 4 + offset; - posMax = (yMax * wSrc + xMax) * 4 + offset; - var vMax = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]); - - bufDst[pos+offset] = interpolate(y, yMin, vMin, yMax, vMax); - } - } - - for (var i = 0; i < hDst; i++) { - for (var j = 0; j < wDst; j++) { - var posDst = (i * wDst + j) * 4; - - // x & y in src coordinates - var x = j * wSrc / wDst; - var xMin = Math.floor(x); - var xMax = Math.min(Math.ceil(x), wSrc-1); - - var y = i * hSrc / hDst; - var yMin = Math.floor(y); - var yMax = Math.min(Math.ceil(y), hSrc-1); - - assign(posDst, 0, x, xMin, xMax, y, yMin, yMax); - assign(posDst, 1, x, xMin, xMax, y, yMin, yMax); - assign(posDst, 2, x, xMin, xMax, y, yMin, yMax); - assign(posDst, 3, x, xMin, xMax, y, yMin, yMax); - } - } - }, - - _interpolate2D: function(src, dst, options, interpolate) { - - var bufSrc = src._data.data; - var bufDst = dst._data.data; - - var wSrc = src.width; - var hSrc = src.height; - //console.log("wSrc="+wSrc + ", hSrc="+hSrc + ", srcLen="+bufSrc.length); - - var wDst = dst.width; - var hDst = dst.height; - //console.log("wDst="+wDst + ", hDst="+hDst + ", dstLen="+bufDst.length); - - // when dst smaller than src/2, interpolate first to a multiple between 0.5 and 1.0 src, then sum squares - var wM = Math.max(1, Math.floor(wSrc / wDst)); - var wDst2 = wDst * wM; - var hM = Math.max(1, Math.floor(hSrc / hDst)); - var hDst2 = hDst * hM; - //console.log("wM="+wM + ", wDst2="+wDst2 + ", hM="+hM + ", hDst2="+hDst2); - - // =========================================================== - // Pass 1 - interpolate rows - // buf1 has width of dst2 and height of src - var buf1 = new Buffer(wDst2 * hSrc * 4); - for (var i = 0; i < hSrc; i++) { - for (var j = 0; j < wDst2; j++) { - // i in src coords, j in dst coords - - // calculate x in src coords - // this interpolation requires 4 sample points and the two inner ones must be real - // the outer points can be fudged for the edges. - // therefore (wSrc-1)/wDst2 - var x = j * (wSrc-1) / wDst2; - var xPos = Math.floor(x); - var t = x - xPos; - var srcPos = (i * wSrc + xPos) * 4; - - var buf1Pos = (i * wDst2 + j) * 4; - for (var k = 0; k < 4; k++) { - var kPos = srcPos + k; - var x0 = (xPos > 0) ? bufSrc[kPos - 4] : 2*bufSrc[kPos]-bufSrc[kPos+4]; - var x1 = bufSrc[kPos]; - var x2 = bufSrc[kPos + 4]; - var x3 = (xPos < wSrc - 2) ? bufSrc[kPos + 8] : 2*bufSrc[kPos + 4]-bufSrc[kPos]; - buf1[buf1Pos+k] = interpolate(x0,x1,x2,x3,t); - } - } - } - //this._writeFile(wDst2, hSrc, buf1, "out/buf1.jpg"); - - // =========================================================== - // Pass 2 - interpolate columns - // buf2 has width and height of dst2 - var buf2 = new Buffer(wDst2 * hDst2 * 4); - for (var i = 0; i < hDst2; i++) { - for (var j = 0; j < wDst2; j++) { - // i&j in dst2 coords - - // calculate y in buf1 coords - // this interpolation requires 4 sample points and the two inner ones must be real - // the outer points can be fudged for the edges. - // therefore (hSrc-1)/hDst2 - var y = i * (hSrc-1) / hDst2; - var yPos = Math.floor(y); - var t = y - yPos; - var buf1Pos = (yPos * wDst2 + j) * 4; - var buf2Pos = (i * wDst2 + j) * 4; - for (var k = 0; k < 4; k++) { - var kPos = buf1Pos + k; - var y0 = (yPos > 0) ? buf1[kPos - wDst2*4] : 2*buf1[kPos]-buf1[kPos + wDst2*4]; - var y1 = buf1[kPos]; - var y2 = buf1[kPos + wDst2*4]; - var y3 = (yPos < hSrc-2) ? buf1[kPos + wDst2*8] : 2*buf1[kPos + wDst2*4]-buf1[kPos]; - - buf2[buf2Pos + k] = interpolate(y0,y1,y2,y3,t); - } - } - } - //this._writeFile(wDst2, hDst2, buf2, "out/buf2.jpg"); - - // =========================================================== - // Pass 3 - scale to dst - var m = wM * hM; - if (m > 1) { - for (var i = 0; i < hDst; i++) { - for (var j = 0; j < wDst; j++) { - // i&j in dst bounded coords - var r = 0; - var g = 0; - var b = 0; - var a = 0; - for (var y = 0; y < hM; y++) { - var yPos = i * hM + y; - for (var x = 0; x < wM; x++) { - var xPos = j * wM + x; - var xyPos = (yPos * wDst2 + xPos) * 4; - r += buf2[xyPos]; - g += buf2[xyPos+1]; - b += buf2[xyPos+2]; - a += buf2[xyPos+3]; - } - } - - var pos = (i*wDst + j) * 4; - bufDst[pos] = Math.round(r / m); - bufDst[pos+1] = Math.round(g / m); - bufDst[pos+2] = Math.round(b / m); - bufDst[pos+3] = Math.round(a / m); - } - } - } else { - // replace dst buffer with buf2 - dst._data.data = buf2; - } - }, - - bicubicInterpolation: function(src, dst, options) { - var interpolateCubic = function(x0, x1, x2, x3, t) { - var a0 = x3 - x2 - x0 + x1; - var a1 = x0 - x1 - a0; - var a2 = x2 - x0; - var a3 = x1; - return Math.max(0,Math.min(255,(a0 * (t * t * t)) + (a1 * (t * t)) + (a2 * t) + (a3))); - } - return this._interpolate2D(src, dst, options, interpolateCubic); - }, - - hermiteInterpolation: function(src, dst, options) { - var interpolateHermite = function(x0, x1, x2, x3, t) - { - var c0 = x1; - var c1 = 0.5 * (x2 - x0); - var c2 = x0 - (2.5 * x1) + (2 * x2) - (0.5 * x3); - var c3 = (0.5 * (x3 - x0)) + (1.5 * (x1 - x2)); - return Math.max(0,Math.min(255,Math.round((((((c3 * t) + c2) * t) + c1) * t) + c0))); - } - return this._interpolate2D(src, dst, options, interpolateHermite); - }, - - bezierInterpolation: function(src, dst, options) { - // between 2 points y(n), y(n+1), use next points out, y(n-1), y(n+2) - // to predict control points (a & b) to be placed at n+0.5 - // ya(n) = y(n) + (y(n+1)-y(n-1))/4 - // yb(n) = y(n+1) - (y(n+2)-y(n))/4 - // then use std bezier to interpolate [n,n+1) - // y(n+t) = y(n)*(1-t)^3 + 3 * ya(n)*(1-t)^2*t + 3 * yb(n)*(1-t)*t^2 + y(n+1)*t^3 - // note the 3* factor for the two control points - // for edge cases, can choose: - // y(-1) = y(0) - 2*(y(1)-y(0)) - // y(w) = y(w-1) + 2*(y(w-1)-y(w-2)) - // but can go with y(-1) = y(0) and y(w) = y(w-1) - var interpolateBezier = function(x0, x1, x2, x3, t) { - // x1, x2 are the knots, use x0 and x3 to calculate control points - var cp1 = x1 + (x2-x0)/4; - var cp2 = x2 - (x3-x1)/4; - var nt = 1-t; - var c0 = x1 * nt * nt * nt; - var c1 = 3 * cp1 * nt * nt * t; - var c2 = 3 * cp2 * nt * t * t; - var c3 = x2 * t * t * t; - return Math.max(0,Math.min(255,Math.round(c0 + c1 + c2 + c3))); - } - return this._interpolate2D(src, dst, options, interpolateBezier); - } +/** + * Copyright (c) 2015 Guyon Roche + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions:

+ * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +"use strict"; + +var _ = require("underscore"); +var Promise = require("bluebird"); + +module.exports = { + _writeFile: function(width, height, data, filename) { + // for debugging + + var Bitmap = require("./bitmap"); + var bmp = new Bitmap({ + width: width, height: height, + data: data + }); + bmp.writeFile(filename); + }, + + nearestNeighbor: function(src, dst, options) { + + var wSrc = src.width; + var hSrc = src.height; + //console.log("wSrc="+wSrc + ", hSrc="+hSrc); + + var wDst = dst.width; + var hDst = dst.height; + //console.log("wDst="+wDst + ", hDst="+hDst); + + var bufSrc = src._data.data; + var bufDst = dst._data.data; + + for (var i = 0; i < hDst; i++) { + for (var j = 0; j < wDst; j++) { + var posDst = (i * wDst + j) * 4; + + var iSrc = Math.round(i * hSrc / hDst); + var jSrc = Math.round(j * wSrc / wDst); + var posSrc = (iSrc * wSrc + jSrc) * 4; + + bufDst[posDst++] = bufSrc[posSrc++]; + bufDst[posDst++] = bufSrc[posSrc++]; + bufDst[posDst++] = bufSrc[posSrc++]; + bufDst[posDst++] = bufSrc[posSrc++]; + } + } + }, + bilinearInterpolation: function(src, dst, options) { + + var wSrc = src.width; + var hSrc = src.height; + //console.log("wSrc="+wSrc + ", hSrc="+hSrc); + + var wDst = dst.width; + var hDst = dst.height; + //console.log("wDst="+wDst + ", hDst="+hDst); + + var bufSrc = src._data.data; + var bufDst = dst._data.data; + + var interpolate = function(k, kMin, vMin, kMax, vMax) { + // special case - k is integer + if (kMin === kMax) { + return vMin; + } + + return Math.round((k - kMin) * vMax + (kMax - k) * vMin); + }; + var assign = function(pos, offset, x, xMin, xMax, y, yMin, yMax) { + var posMin = (yMin * wSrc + xMin) * 4 + offset; + var posMax = (yMin * wSrc + xMax) * 4 + offset; + var vMin = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]); + + // special case, y is integer + if (yMax === yMin) { + bufDst[pos+offset] = vMin; + } else { + posMin = (yMax * wSrc + xMin) * 4 + offset; + posMax = (yMax * wSrc + xMax) * 4 + offset; + var vMax = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]); + + bufDst[pos+offset] = interpolate(y, yMin, vMin, yMax, vMax); + } + } + + for (var i = 0; i < hDst; i++) { + for (var j = 0; j < wDst; j++) { + var posDst = (i * wDst + j) * 4; + + // x & y in src coordinates + var x = j * wSrc / wDst; + var xMin = Math.floor(x); + var xMax = Math.min(Math.ceil(x), wSrc-1); + + var y = i * hSrc / hDst; + var yMin = Math.floor(y); + var yMax = Math.min(Math.ceil(y), hSrc-1); + + assign(posDst, 0, x, xMin, xMax, y, yMin, yMax); + assign(posDst, 1, x, xMin, xMax, y, yMin, yMax); + assign(posDst, 2, x, xMin, xMax, y, yMin, yMax); + assign(posDst, 3, x, xMin, xMax, y, yMin, yMax); + } + } + }, + + _interpolate2D: function(src, dst, options, interpolate) { + + var bufSrc = src._data.data; + var bufDst = dst._data.data; + + var wSrc = src.width; + var hSrc = src.height; + //console.log("wSrc="+wSrc + ", hSrc="+hSrc + ", srcLen="+bufSrc.length); + + var wDst = dst.width; + var hDst = dst.height; + //console.log("wDst="+wDst + ", hDst="+hDst + ", dstLen="+bufDst.length); + + // when dst smaller than src/2, interpolate first to a multiple between 0.5 and 1.0 src, then sum squares + var wM = Math.max(1, Math.floor(wSrc / wDst)); + var wDst2 = wDst * wM; + var hM = Math.max(1, Math.floor(hSrc / hDst)); + var hDst2 = hDst * hM; + //console.log("wM="+wM + ", wDst2="+wDst2 + ", hM="+hM + ", hDst2="+hDst2); + + // =========================================================== + // Pass 1 - interpolate rows + // buf1 has width of dst2 and height of src + var buf1 = new Buffer(wDst2 * hSrc * 4); + for (var i = 0; i < hSrc; i++) { + for (var j = 0; j < wDst2; j++) { + // i in src coords, j in dst coords + + // calculate x in src coords + // this interpolation requires 4 sample points and the two inner ones must be real + // the outer points can be fudged for the edges. + // therefore (wSrc-1)/wDst2 + var x = j * (wSrc-1) / wDst2; + var xPos = Math.floor(x); + var t = x - xPos; + var srcPos = (i * wSrc + xPos) * 4; + + var buf1Pos = (i * wDst2 + j) * 4; + for (var k = 0; k < 4; k++) { + var kPos = srcPos + k; + var x0 = (xPos > 0) ? bufSrc[kPos - 4] : 2*bufSrc[kPos]-bufSrc[kPos+4]; + var x1 = bufSrc[kPos]; + var x2 = bufSrc[kPos + 4]; + var x3 = (xPos < wSrc - 2) ? bufSrc[kPos + 8] : 2*bufSrc[kPos + 4]-bufSrc[kPos]; + buf1[buf1Pos+k] = interpolate(x0,x1,x2,x3,t); + } + } + } + //this._writeFile(wDst2, hSrc, buf1, "out/buf1.jpg"); + + // =========================================================== + // Pass 2 - interpolate columns + // buf2 has width and height of dst2 + var buf2 = new Buffer(wDst2 * hDst2 * 4); + for (var i = 0; i < hDst2; i++) { + for (var j = 0; j < wDst2; j++) { + // i&j in dst2 coords + + // calculate y in buf1 coords + // this interpolation requires 4 sample points and the two inner ones must be real + // the outer points can be fudged for the edges. + // therefore (hSrc-1)/hDst2 + var y = i * (hSrc-1) / hDst2; + var yPos = Math.floor(y); + var t = y - yPos; + var buf1Pos = (yPos * wDst2 + j) * 4; + var buf2Pos = (i * wDst2 + j) * 4; + for (var k = 0; k < 4; k++) { + var kPos = buf1Pos + k; + var y0 = (yPos > 0) ? buf1[kPos - wDst2*4] : 2*buf1[kPos]-buf1[kPos + wDst2*4]; + var y1 = buf1[kPos]; + var y2 = buf1[kPos + wDst2*4]; + var y3 = (yPos < hSrc-2) ? buf1[kPos + wDst2*8] : 2*buf1[kPos + wDst2*4]-buf1[kPos]; + + buf2[buf2Pos + k] = interpolate(y0,y1,y2,y3,t); + } + } + } + //this._writeFile(wDst2, hDst2, buf2, "out/buf2.jpg"); + + // =========================================================== + // Pass 3 - scale to dst + var m = wM * hM; + if (m > 1) { + for (var i = 0; i < hDst; i++) { + for (var j = 0; j < wDst; j++) { + // i&j in dst bounded coords + var r = 0; + var g = 0; + var b = 0; + var a = 0; + for (var y = 0; y < hM; y++) { + var yPos = i * hM + y; + for (var x = 0; x < wM; x++) { + var xPos = j * wM + x; + var xyPos = (yPos * wDst2 + xPos) * 4; + r += buf2[xyPos]; + g += buf2[xyPos+1]; + b += buf2[xyPos+2]; + a += buf2[xyPos+3]; + } + } + + var pos = (i*wDst + j) * 4; + bufDst[pos] = Math.round(r / m); + bufDst[pos+1] = Math.round(g / m); + bufDst[pos+2] = Math.round(b / m); + bufDst[pos+3] = Math.round(a / m); + } + } + } else { + // replace dst buffer with buf2 + dst._data.data = buf2; + } + }, + + bicubicInterpolation: function(src, dst, options) { + var interpolateCubic = function(x0, x1, x2, x3, t) { + var a0 = x3 - x2 - x0 + x1; + var a1 = x0 - x1 - a0; + var a2 = x2 - x0; + var a3 = x1; + return Math.max(0,Math.min(255,(a0 * (t * t * t)) + (a1 * (t * t)) + (a2 * t) + (a3))); + } + return this._interpolate2D(src, dst, options, interpolateCubic); + }, + + hermiteInterpolation: function(src, dst, options) { + var interpolateHermite = function(x0, x1, x2, x3, t) + { + var c0 = x1; + var c1 = 0.5 * (x2 - x0); + var c2 = x0 - (2.5 * x1) + (2 * x2) - (0.5 * x3); + var c3 = (0.5 * (x3 - x0)) + (1.5 * (x1 - x2)); + return Math.max(0,Math.min(255,Math.round((((((c3 * t) + c2) * t) + c1) * t) + c0))); + } + return this._interpolate2D(src, dst, options, interpolateHermite); + }, + + bezierInterpolation: function(src, dst, options) { + // between 2 points y(n), y(n+1), use next points out, y(n-1), y(n+2) + // to predict control points (a & b) to be placed at n+0.5 + // ya(n) = y(n) + (y(n+1)-y(n-1))/4 + // yb(n) = y(n+1) - (y(n+2)-y(n))/4 + // then use std bezier to interpolate [n,n+1) + // y(n+t) = y(n)*(1-t)^3 + 3 * ya(n)*(1-t)^2*t + 3 * yb(n)*(1-t)*t^2 + y(n+1)*t^3 + // note the 3* factor for the two control points + // for edge cases, can choose: + // y(-1) = y(0) - 2*(y(1)-y(0)) + // y(w) = y(w-1) + 2*(y(w-1)-y(w-2)) + // but can go with y(-1) = y(0) and y(w) = y(w-1) + var interpolateBezier = function(x0, x1, x2, x3, t) { + // x1, x2 are the knots, use x0 and x3 to calculate control points + var cp1 = x1 + (x2-x0)/4; + var cp2 = x2 - (x3-x1)/4; + var nt = 1-t; + var c0 = x1 * nt * nt * nt; + var c1 = 3 * cp1 * nt * nt * t; + var c2 = 3 * cp2 * nt * t * t; + var c3 = x2 * t * t * t; + return Math.max(0,Math.min(255,Math.round(c0 + c1 + c2 + c3))); + } + return this._interpolate2D(src, dst, options, interpolateBezier); + } } }).call(this,require("buffer").Buffer) },{"./bitmap":63,"bluebird":3,"buffer":5,"underscore":145}],66:[function(require,module,exports){ -/** - * Copyright (c) 2015 Guyon Roche - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions:

- * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -"use strict"; - -var fs = require("fs"); -var _ = require("underscore"); -var Promise = require("bluebird"); - - -var utils = module.exports = { - - // Promisification of fs - fs: { - exists: function(filename) { - var deferred = Promise.defer(); - fs.exists(filename, function(exists) { - deferred.resolve(exists); - }); - return deferred.promise; - } - } +/** + * Copyright (c) 2015 Guyon Roche + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions:

+ * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ +"use strict"; + +var fs = require("fs"); +var _ = require("underscore"); +var Promise = require("bluebird"); + + +var utils = module.exports = { + + // Promisification of fs + fs: { + exists: function(filename) { + var deferred = Promise.defer(); + fs.exists(filename, function(exists) { + deferred.resolve(exists); + }); + return deferred.promise; + } + } } },{"bluebird":3,"fs":47,"underscore":145}],67:[function(require,module,exports){ var encode = require('./lib/encoder'), @@ -25502,2669 +25502,2669 @@ return /******/ (function(modules) { // webpackBootstrap /* 0 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - /// - var binarizer_1 = __webpack_require__(1); - var locator_1 = __webpack_require__(3); - var extractor_1 = __webpack_require__(4); - var decoder_1 = __webpack_require__(9); - var bitmatrix_1 = __webpack_require__(2); - var binarizeImage = binarizer_1.binarize; - exports.binarizeImage = binarizeImage; - var locateQRInBinaryImage = locator_1.locate; - exports.locateQRInBinaryImage = locateQRInBinaryImage; - var extractQRFromBinaryImage = extractor_1.extract; - exports.extractQRFromBinaryImage = extractQRFromBinaryImage; - function decodeQR(matrix) { - return byteArrayToString(decoder_1.decode(matrix)); - } - exports.decodeQR = decodeQR; - // return bytes.reduce((p, b) => p + String.fromCharCode(b), ""); - function byteArrayToString(bytes) { - var str = ""; - if (bytes != null && bytes != undefined) { - for (var i = 0; i < bytes.length; i++) { - str += String.fromCharCode(bytes[i]); - } - } - return str; - } - function createBitMatrix(data, width) { - return new bitmatrix_1.BitMatrix(data, width); - } - exports.createBitMatrix = createBitMatrix; - function decodeQRFromImage(data, width, height) { - return byteArrayToString(decodeQRFromImageAsByteArray(data, width, height)); - } - exports.decodeQRFromImage = decodeQRFromImage; - function decodeQRFromImageAsByteArray(data, width, height) { - var binarizedImage = binarizeImage(data, width, height); - var location = locator_1.locate(binarizedImage); - if (!location) { - return null; - } - var rawQR = extractor_1.extract(binarizedImage, location); - if (!rawQR) { - return null; - } - return decoder_1.decode(rawQR); - } - exports.decodeQRFromImageAsByteArray = decodeQRFromImageAsByteArray; + "use strict"; + /// + var binarizer_1 = __webpack_require__(1); + var locator_1 = __webpack_require__(3); + var extractor_1 = __webpack_require__(4); + var decoder_1 = __webpack_require__(9); + var bitmatrix_1 = __webpack_require__(2); + var binarizeImage = binarizer_1.binarize; + exports.binarizeImage = binarizeImage; + var locateQRInBinaryImage = locator_1.locate; + exports.locateQRInBinaryImage = locateQRInBinaryImage; + var extractQRFromBinaryImage = extractor_1.extract; + exports.extractQRFromBinaryImage = extractQRFromBinaryImage; + function decodeQR(matrix) { + return byteArrayToString(decoder_1.decode(matrix)); + } + exports.decodeQR = decodeQR; + // return bytes.reduce((p, b) => p + String.fromCharCode(b), ""); + function byteArrayToString(bytes) { + var str = ""; + if (bytes != null && bytes != undefined) { + for (var i = 0; i < bytes.length; i++) { + str += String.fromCharCode(bytes[i]); + } + } + return str; + } + function createBitMatrix(data, width) { + return new bitmatrix_1.BitMatrix(data, width); + } + exports.createBitMatrix = createBitMatrix; + function decodeQRFromImage(data, width, height) { + return byteArrayToString(decodeQRFromImageAsByteArray(data, width, height)); + } + exports.decodeQRFromImage = decodeQRFromImage; + function decodeQRFromImageAsByteArray(data, width, height) { + var binarizedImage = binarizeImage(data, width, height); + var location = locator_1.locate(binarizedImage); + if (!location) { + return null; + } + var rawQR = extractor_1.extract(binarizedImage, location); + if (!rawQR) { + return null; + } + return decoder_1.decode(rawQR); + } + exports.decodeQRFromImageAsByteArray = decodeQRFromImageAsByteArray; /***/ }, /* 1 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - var bitmatrix_1 = __webpack_require__(2); - // Magic Constants - var BLOCK_SIZE_POWER = 3; - var BLOCK_SIZE = 1 << BLOCK_SIZE_POWER; - var BLOCK_SIZE_MASK = BLOCK_SIZE - 1; - var MIN_DYNAMIC_RANGE = 24; - function calculateBlackPoints(luminances, subWidth, subHeight, width, height) { - var blackPoints = new Array(subHeight); - for (var i = 0; i < subHeight; i++) { - blackPoints[i] = new Array(subWidth); - } - for (var y = 0; y < subHeight; y++) { - var yoffset = y << BLOCK_SIZE_POWER; - var maxYOffset = height - BLOCK_SIZE; - if (yoffset > maxYOffset) { - yoffset = maxYOffset; - } - for (var x = 0; x < subWidth; x++) { - var xoffset = x << BLOCK_SIZE_POWER; - var maxXOffset = width - BLOCK_SIZE; - if (xoffset > maxXOffset) { - xoffset = maxXOffset; - } - var sum = 0; - var min = 0xFF; - var max = 0; - for (var yy = 0, offset = yoffset * width + xoffset; yy < BLOCK_SIZE; yy++, offset += width) { - for (var xx = 0; xx < BLOCK_SIZE; xx++) { - var pixel = luminances[offset + xx] & 0xFF; - // still looking for good contrast - sum += pixel; - if (pixel < min) { - min = pixel; - } - if (pixel > max) { - max = pixel; - } - } - // short-circuit min/max tests once dynamic range is met - if (max - min > MIN_DYNAMIC_RANGE) { - // finish the rest of the rows quickly - for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) { - for (var xx = 0; xx < BLOCK_SIZE; xx++) { - sum += luminances[offset + xx] & 0xFF; - } - } - } - } - // The default estimate is the average of the values in the block. - var average = sum >> (BLOCK_SIZE_POWER * 2); - if (max - min <= MIN_DYNAMIC_RANGE) { - // If variation within the block is low, assume this is a block with only light or only - // dark pixels. In that case we do not want to use the average, as it would divide this - // low contrast area into black and white pixels, essentially creating data out of noise. - // - // The default assumption is that the block is light/background. Since no estimate for - // the level of dark pixels exists locally, use half the min for the block. - average = min >> 1; - if (y > 0 && x > 0) { - // Correct the "white background" assumption for blocks that have neighbors by comparing - // the pixels in this block to the previously calculated black points. This is based on - // the fact that dark barcode symbology is always surrounded by some amount of light - // background for which reasonable black point estimates were made. The bp estimated at - // the boundaries is used for the interior. - // The (min < bp) is arbitrary but works better than other heuristics that were tried. - var averageNeighborBlackPoint = (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) >> 2; - if (min < averageNeighborBlackPoint) { - average = averageNeighborBlackPoint; - } - } - } - blackPoints[y][x] = average; - } - } - return blackPoints; - } - function calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints) { - function cap(value, min, max) { - return value < min ? min : value > max ? max : value; - } - // var outArray = new Array(width * height); - var outMatrix = bitmatrix_1.BitMatrix.createEmpty(width, height); - function thresholdBlock(luminances, xoffset, yoffset, threshold, stride) { - var offset = (yoffset * stride) + xoffset; - for (var y = 0; y < BLOCK_SIZE; y++, offset += stride) { - for (var x = 0; x < BLOCK_SIZE; x++) { - var pixel = luminances[offset + x] & 0xff; - // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. - outMatrix.set(xoffset + x, yoffset + y, pixel <= threshold); - } - } - } - for (var y = 0; y < subHeight; y++) { - var yoffset = y << BLOCK_SIZE_POWER; - var maxYOffset = height - BLOCK_SIZE; - if (yoffset > maxYOffset) { - yoffset = maxYOffset; - } - for (var x = 0; x < subWidth; x++) { - var xoffset = x << BLOCK_SIZE_POWER; - var maxXOffset = width - BLOCK_SIZE; - if (xoffset > maxXOffset) { - xoffset = maxXOffset; - } - var left = cap(x, 2, subWidth - 3); - var top = cap(y, 2, subHeight - 3); - var sum = 0; - for (var z = -2; z <= 2; z++) { - var blackRow = blackPoints[top + z]; - sum += blackRow[left - 2]; - sum += blackRow[left - 1]; - sum += blackRow[left]; - sum += blackRow[left + 1]; - sum += blackRow[left + 2]; - } - var average = sum / 25; - thresholdBlock(luminances, xoffset, yoffset, average, width); - } - } - return outMatrix; - } - function binarize(data, width, height) { - if (data.length !== width * height * 4) { - throw new Error("Binarizer data.length != width * height * 4"); - } - var gsArray = new Array(width * height); - for (var x = 0; x < width; x++) { - for (var y = 0; y < height; y++) { - var startIndex = (y * width + x) * 4; - var r = data[startIndex]; - var g = data[startIndex + 1]; - var b = data[startIndex + 2]; - // Magic lumosity constants - var lum = 0.2126 * r + 0.7152 * g + 0.0722 * b; - gsArray[y * width + x] = lum; - } - } - var subWidth = width >> BLOCK_SIZE_POWER; - if ((width & BLOCK_SIZE_MASK) != 0) { - subWidth++; - } - var subHeight = height >> BLOCK_SIZE_POWER; - if ((height & BLOCK_SIZE_MASK) != 0) { - subHeight++; - } - var blackPoints = calculateBlackPoints(gsArray, subWidth, subHeight, width, height); - return calculateThresholdForBlock(gsArray, subWidth, subHeight, width, height, blackPoints); - } - exports.binarize = binarize; + "use strict"; + var bitmatrix_1 = __webpack_require__(2); + // Magic Constants + var BLOCK_SIZE_POWER = 3; + var BLOCK_SIZE = 1 << BLOCK_SIZE_POWER; + var BLOCK_SIZE_MASK = BLOCK_SIZE - 1; + var MIN_DYNAMIC_RANGE = 24; + function calculateBlackPoints(luminances, subWidth, subHeight, width, height) { + var blackPoints = new Array(subHeight); + for (var i = 0; i < subHeight; i++) { + blackPoints[i] = new Array(subWidth); + } + for (var y = 0; y < subHeight; y++) { + var yoffset = y << BLOCK_SIZE_POWER; + var maxYOffset = height - BLOCK_SIZE; + if (yoffset > maxYOffset) { + yoffset = maxYOffset; + } + for (var x = 0; x < subWidth; x++) { + var xoffset = x << BLOCK_SIZE_POWER; + var maxXOffset = width - BLOCK_SIZE; + if (xoffset > maxXOffset) { + xoffset = maxXOffset; + } + var sum = 0; + var min = 0xFF; + var max = 0; + for (var yy = 0, offset = yoffset * width + xoffset; yy < BLOCK_SIZE; yy++, offset += width) { + for (var xx = 0; xx < BLOCK_SIZE; xx++) { + var pixel = luminances[offset + xx] & 0xFF; + // still looking for good contrast + sum += pixel; + if (pixel < min) { + min = pixel; + } + if (pixel > max) { + max = pixel; + } + } + // short-circuit min/max tests once dynamic range is met + if (max - min > MIN_DYNAMIC_RANGE) { + // finish the rest of the rows quickly + for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) { + for (var xx = 0; xx < BLOCK_SIZE; xx++) { + sum += luminances[offset + xx] & 0xFF; + } + } + } + } + // The default estimate is the average of the values in the block. + var average = sum >> (BLOCK_SIZE_POWER * 2); + if (max - min <= MIN_DYNAMIC_RANGE) { + // If variation within the block is low, assume this is a block with only light or only + // dark pixels. In that case we do not want to use the average, as it would divide this + // low contrast area into black and white pixels, essentially creating data out of noise. + // + // The default assumption is that the block is light/background. Since no estimate for + // the level of dark pixels exists locally, use half the min for the block. + average = min >> 1; + if (y > 0 && x > 0) { + // Correct the "white background" assumption for blocks that have neighbors by comparing + // the pixels in this block to the previously calculated black points. This is based on + // the fact that dark barcode symbology is always surrounded by some amount of light + // background for which reasonable black point estimates were made. The bp estimated at + // the boundaries is used for the interior. + // The (min < bp) is arbitrary but works better than other heuristics that were tried. + var averageNeighborBlackPoint = (blackPoints[y - 1][x] + (2 * blackPoints[y][x - 1]) + blackPoints[y - 1][x - 1]) >> 2; + if (min < averageNeighborBlackPoint) { + average = averageNeighborBlackPoint; + } + } + } + blackPoints[y][x] = average; + } + } + return blackPoints; + } + function calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints) { + function cap(value, min, max) { + return value < min ? min : value > max ? max : value; + } + // var outArray = new Array(width * height); + var outMatrix = bitmatrix_1.BitMatrix.createEmpty(width, height); + function thresholdBlock(luminances, xoffset, yoffset, threshold, stride) { + var offset = (yoffset * stride) + xoffset; + for (var y = 0; y < BLOCK_SIZE; y++, offset += stride) { + for (var x = 0; x < BLOCK_SIZE; x++) { + var pixel = luminances[offset + x] & 0xff; + // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. + outMatrix.set(xoffset + x, yoffset + y, pixel <= threshold); + } + } + } + for (var y = 0; y < subHeight; y++) { + var yoffset = y << BLOCK_SIZE_POWER; + var maxYOffset = height - BLOCK_SIZE; + if (yoffset > maxYOffset) { + yoffset = maxYOffset; + } + for (var x = 0; x < subWidth; x++) { + var xoffset = x << BLOCK_SIZE_POWER; + var maxXOffset = width - BLOCK_SIZE; + if (xoffset > maxXOffset) { + xoffset = maxXOffset; + } + var left = cap(x, 2, subWidth - 3); + var top = cap(y, 2, subHeight - 3); + var sum = 0; + for (var z = -2; z <= 2; z++) { + var blackRow = blackPoints[top + z]; + sum += blackRow[left - 2]; + sum += blackRow[left - 1]; + sum += blackRow[left]; + sum += blackRow[left + 1]; + sum += blackRow[left + 2]; + } + var average = sum / 25; + thresholdBlock(luminances, xoffset, yoffset, average, width); + } + } + return outMatrix; + } + function binarize(data, width, height) { + if (data.length !== width * height * 4) { + throw new Error("Binarizer data.length != width * height * 4"); + } + var gsArray = new Array(width * height); + for (var x = 0; x < width; x++) { + for (var y = 0; y < height; y++) { + var startIndex = (y * width + x) * 4; + var r = data[startIndex]; + var g = data[startIndex + 1]; + var b = data[startIndex + 2]; + // Magic lumosity constants + var lum = 0.2126 * r + 0.7152 * g + 0.0722 * b; + gsArray[y * width + x] = lum; + } + } + var subWidth = width >> BLOCK_SIZE_POWER; + if ((width & BLOCK_SIZE_MASK) != 0) { + subWidth++; + } + var subHeight = height >> BLOCK_SIZE_POWER; + if ((height & BLOCK_SIZE_MASK) != 0) { + subHeight++; + } + var blackPoints = calculateBlackPoints(gsArray, subWidth, subHeight, width, height); + return calculateThresholdForBlock(gsArray, subWidth, subHeight, width, height, blackPoints); + } + exports.binarize = binarize; /***/ }, /* 2 */ /***/ function(module, exports) { - "use strict"; - var BitMatrix = (function () { - function BitMatrix(data, width) { - this.width = width; - this.height = data.length / width; - this.data = data; - } - BitMatrix.createEmpty = function (width, height) { - var data = new Array(width * height); - for (var i = 0; i < data.length; i++) { - data[i] = false; - } - return new BitMatrix(data, width); - }; - BitMatrix.prototype.get = function (x, y) { - return this.data[y * this.width + x]; - }; - BitMatrix.prototype.set = function (x, y, v) { - this.data[y * this.width + x] = v; - }; - BitMatrix.prototype.copyBit = function (x, y, versionBits) { - return this.get(x, y) ? (versionBits << 1) | 0x1 : versionBits << 1; - }; - BitMatrix.prototype.setRegion = function (left, top, width, height) { - var right = left + width; - var bottom = top + height; - for (var y = top; y < bottom; y++) { - for (var x = left; x < right; x++) { - this.set(x, y, true); - } - } - }; - BitMatrix.prototype.mirror = function () { - for (var x = 0; x < this.width; x++) { - for (var y = x + 1; y < this.height; y++) { - if (this.get(x, y) != this.get(y, x)) { - this.set(x, y, !this.get(x, y)); - this.set(y, x, !this.get(y, x)); - } - } - } - }; - return BitMatrix; - }()); - exports.BitMatrix = BitMatrix; + "use strict"; + var BitMatrix = (function () { + function BitMatrix(data, width) { + this.width = width; + this.height = data.length / width; + this.data = data; + } + BitMatrix.createEmpty = function (width, height) { + var data = new Array(width * height); + for (var i = 0; i < data.length; i++) { + data[i] = false; + } + return new BitMatrix(data, width); + }; + BitMatrix.prototype.get = function (x, y) { + return this.data[y * this.width + x]; + }; + BitMatrix.prototype.set = function (x, y, v) { + this.data[y * this.width + x] = v; + }; + BitMatrix.prototype.copyBit = function (x, y, versionBits) { + return this.get(x, y) ? (versionBits << 1) | 0x1 : versionBits << 1; + }; + BitMatrix.prototype.setRegion = function (left, top, width, height) { + var right = left + width; + var bottom = top + height; + for (var y = top; y < bottom; y++) { + for (var x = left; x < right; x++) { + this.set(x, y, true); + } + } + }; + BitMatrix.prototype.mirror = function () { + for (var x = 0; x < this.width; x++) { + for (var y = x + 1; y < this.height; y++) { + if (this.get(x, y) != this.get(y, x)) { + this.set(x, y, !this.get(x, y)); + this.set(y, x, !this.get(y, x)); + } + } + } + }; + return BitMatrix; + }()); + exports.BitMatrix = BitMatrix; /***/ }, /* 3 */ /***/ function(module, exports) { - "use strict"; - var CENTER_QUORUM = 2; - var MIN_SKIP = 3; - var MAX_MODULES = 57; - var INTEGER_MATH_SHIFT = 8; - var FinderPattern = (function () { - function FinderPattern(x, y, estimatedModuleSize, count) { - this.x = x; - this.y = y; - this.estimatedModuleSize = estimatedModuleSize; - if (count == null) { - this.count = 1; - } - else { - this.count = count; - } - } - FinderPattern.prototype.aboutEquals = function (moduleSize, i, j) { - if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) { - var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize); - return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize; - } - return false; - }; - FinderPattern.prototype.combineEstimate = function (i, j, newModuleSize) { - var combinedCount = this.count + 1; - var combinedX = (this.count * this.x + j) / combinedCount; - var combinedY = (this.count * this.y + i) / combinedCount; - var combinedModuleSize = (this.count * this.estimatedModuleSize + newModuleSize) / combinedCount; - return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); - }; - return FinderPattern; - }()); - function foundPatternCross(stateCount) { - var totalModuleSize = 0; - for (var i = 0; i < 5; i++) { - var count = stateCount[i]; - if (count === 0) - return false; - totalModuleSize += count; - } - if (totalModuleSize < 7) - return false; - var moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; - var maxVariance = moduleSize / 2; - // Allow less than 50% variance from 1-1-3-1-1 proportions - return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && - Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance; - } - function centerFromEnd(stateCount, end) { - var result = (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2; - // Fix this. - if (result !== result) { - return null; - } - return result; - } - function distance(pattern1, pattern2) { - var a = pattern1.x - pattern2.x; - var b = pattern1.y - pattern2.y; - return Math.sqrt(a * a + b * b); - } - function crossProductZ(pointA, pointB, pointC) { - var bX = pointB.x; - var bY = pointB.y; - return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); - } - function ReorderFinderPattern(patterns) { - // Find distances between pattern centers - var zeroOneDistance = distance(patterns[0], patterns[1]); - var oneTwoDistance = distance(patterns[1], patterns[2]); - var zeroTwoDistance = distance(patterns[0], patterns[2]); - var pointA, pointB, pointC; - // Assume one closest to other two is B; A and C will just be guesses at first - if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { - pointB = patterns[0]; - pointA = patterns[1]; - pointC = patterns[2]; - } - else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) { - pointB = patterns[1]; - pointA = patterns[0]; - pointC = patterns[2]; - } - else { - pointB = patterns[2]; - pointA = patterns[0]; - pointC = patterns[1]; - } - // Use cross product to figure out whether A and C are correct or flipped. - // This asks whether BC x BA has a positive z component, which is the arrangement - // we want for A, B, C. If it's negative, then we've got it flipped around and - // should swap A and C. - if (crossProductZ(pointA, pointB, pointC) < 0) { - var temp = pointA; - pointA = pointC; - pointC = temp; - } - return { - bottomLeft: { x: pointA.x, y: pointA.y }, - topLeft: { x: pointB.x, y: pointB.y }, - topRight: { x: pointC.x, y: pointC.y } - }; - } - function locate(matrix) { - // Global state :( - var possibleCenters = []; - var hasSkipped = false; - function get(x, y) { - x = Math.floor(x); - y = Math.floor(y); - return matrix.get(x, y); - } - // Methods - function crossCheckDiagonal(startI, centerJ, maxCount, originalStateCountTotal) { - var maxI = matrix.height; - var maxJ = matrix.width; - var stateCount = [0, 0, 0, 0, 0]; - // Start counting up, left from center finding black center mass - var i = 0; - while (startI - i >= 0 && get(centerJ - i, startI - i)) { - stateCount[2]++; - i++; - } - if ((startI - i < 0) || (centerJ - i < 0)) { - return false; - } - // Continue up, left finding white space - while ((startI - i >= 0) && (centerJ - i >= 0) && !get(centerJ - i, startI - i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i++; - } - // If already too many modules in this state or ran off the edge: - if ((startI - i < 0) || (centerJ - i < 0) || stateCount[1] > maxCount) { - return false; - } - // Continue up, left finding black border - while ((startI - i >= 0) && (centerJ - i >= 0) && get(centerJ - i, startI - i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i++; - } - if (stateCount[0] > maxCount) { - return false; - } - // Now also count down, right from center - i = 1; - while ((startI + i < maxI) && (centerJ + i < maxJ) && get(centerJ + i, startI + i)) { - stateCount[2]++; - i++; - } - // Ran off the edge? - if ((startI + i >= maxI) || (centerJ + i >= maxJ)) { - return false; - } - while ((startI + i < maxI) && (centerJ + i < maxJ) && !get(centerJ + i, startI + i) && stateCount[3] < maxCount) { - stateCount[3]++; - i++; - } - if ((startI + i >= maxI) || (centerJ + i >= maxJ) || stateCount[3] >= maxCount) { - return false; - } - while ((startI + i < maxI) && (centerJ + i < maxJ) && get(centerJ + i, startI + i) && stateCount[4] < maxCount) { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) { - return false; - } - // If we found a finder-pattern-like section, but its size is more than 100% different than - // the original, assume it's a false positive - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - return Math.abs(stateCountTotal - originalStateCountTotal) < 2 * originalStateCountTotal && - foundPatternCross(stateCount); - } - function crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal) { - var maxI = matrix.height; - var stateCount = [0, 0, 0, 0, 0]; - // Start counting up from center - var i = startI; - while (i >= 0 && get(centerJ, i)) { - stateCount[2]++; - i--; - } - if (i < 0) { - return null; - } - while (i >= 0 && !get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return null; - } - while (i >= 0 && get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return null; - } - // Now also count down from center - i = startI + 1; - while (i < maxI && get(centerJ, i)) { - stateCount[2]++; - i++; - } - if (i == maxI) { - return null; - } - while (i < maxI && !get(centerJ, i) && stateCount[3] < maxCount) { - stateCount[3]++; - i++; - } - if (i == maxI || stateCount[3] >= maxCount) { - return null; - } - while (i < maxI && get(centerJ, i) && stateCount[4] < maxCount) { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) { - return null; - } - // If we found a finder-pattern-like section, but its size is more than 40% different than - // the original, assume it's a false positive - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return null; - } - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : null; - } - function haveMultiplyConfirmedCenters() { - var confirmedCount = 0; - var totalModuleSize = 0; - var max = possibleCenters.length; - possibleCenters.forEach(function (pattern) { - if (pattern.count >= CENTER_QUORUM) { - confirmedCount++; - totalModuleSize += pattern.estimatedModuleSize; - } - }); - if (confirmedCount < 3) { - return false; - } - // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" - // and that we need to keep looking. We detect this by asking if the estimated module sizes - // vary too much. We arbitrarily say that when the total deviation from average exceeds - // 5% of the total module size estimates, it's too much. - var average = totalModuleSize / max; - var totalDeviation = 0; - for (var i = 0; i < max; i++) { - var pattern = possibleCenters[i]; - totalDeviation += Math.abs(pattern.estimatedModuleSize - average); - } - return totalDeviation <= 0.05 * totalModuleSize; - } - function crossCheckHorizontal(startJ, centerI, maxCount, originalStateCountTotal) { - var maxJ = matrix.width; - var stateCount = [0, 0, 0, 0, 0]; - var j = startJ; - while (j >= 0 && get(j, centerI)) { - stateCount[2]++; - j--; - } - if (j < 0) { - return null; - } - while (j >= 0 && !get(j, centerI) && stateCount[1] <= maxCount) { - stateCount[1]++; - j--; - } - if (j < 0 || stateCount[1] > maxCount) { - return null; - } - while (j >= 0 && get(j, centerI) && stateCount[0] <= maxCount) { - stateCount[0]++; - j--; - } - if (stateCount[0] > maxCount) { - return null; - } - j = startJ + 1; - while (j < maxJ && get(j, centerI)) { - stateCount[2]++; - j++; - } - if (j == maxJ) { - return null; - } - while (j < maxJ && !get(j, centerI) && stateCount[3] < maxCount) { - stateCount[3]++; - j++; - } - if (j == maxJ || stateCount[3] >= maxCount) { - return null; - } - while (j < maxJ && get(j, centerI) && stateCount[4] < maxCount) { - stateCount[4]++; - j++; - } - if (stateCount[4] >= maxCount) { - return null; - } - // If we found a finder-pattern-like section, but its size is significantly different than - // the original, assume it's a false positive - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { - return null; - } - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : null; - } - function handlePossibleCenter(stateCount, i, j, pureBarcode) { - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - var centerJ = centerFromEnd(stateCount, j); - if (centerJ == null) - return false; - var centerI = crossCheckVertical(i, Math.floor(centerJ), stateCount[2], stateCountTotal); - if (centerI != null) { - // Re-cross check - centerJ = crossCheckHorizontal(Math.floor(centerJ), Math.floor(centerI), stateCount[2], stateCountTotal); - if (centerJ != null && (!pureBarcode || crossCheckDiagonal(Math.floor(centerI), Math.floor(centerJ), stateCount[2], stateCountTotal))) { - var estimatedModuleSize = stateCountTotal / 7; - var found = false; - for (var index = 0; index < possibleCenters.length; index++) { - var center = possibleCenters[index]; - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { - possibleCenters.splice(index, 1, center.combineEstimate(centerI, centerJ, estimatedModuleSize)); - found = true; - break; - } - } - if (!found) { - // var point = new FinderPattern(centerJ.Value, centerI.Value, estimatedModuleSize); - var point = new FinderPattern(centerJ, centerI, estimatedModuleSize); - possibleCenters.push(point); - } - return true; - } - } - return false; - } - function findRowSkip() { - var max = possibleCenters.length; - if (max <= 1) { - return 0; - } - var firstConfirmedCenter = null; - possibleCenters.forEach(function (center) { - if (center.count >= CENTER_QUORUM) { - if (firstConfirmedCenter == null) { - firstConfirmedCenter = center; - } - else { - // We have two confirmed centers - // How far down can we skip before resuming looking for the next - // pattern? In the worst case, only the difference between the - // difference in the x / y coordinates of the two centers. - // This is the case where you find top left last. - hasSkipped = true; - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - return Math.floor(Math.abs(firstConfirmedCenter.x - center.x) - Math.abs(firstConfirmedCenter.y - center.y)) / 2; - } - } - }); - return 0; - } - function selectBestPatterns() { - var startSize = possibleCenters.length; - if (startSize < 3) { - // Couldn't find enough finder patterns - return null; - } - // Filter outlier possibilities whose module size is too different - if (startSize > 3) { - // But we can only afford to do so if we have at least 4 possibilities to choose from - var totalModuleSize = 0; - var square = 0; - possibleCenters.forEach(function (center) { - var size = center.estimatedModuleSize; - totalModuleSize += size; - square += size * size; - }); - var average = totalModuleSize / startSize; - var stdDev = Math.sqrt(square / startSize - average * average); - //possibleCenters.Sort(new FurthestFromAverageComparator(average)); - possibleCenters.sort(function (x, y) { - var dA = Math.abs(y.estimatedModuleSize - average); - var dB = Math.abs(x.estimatedModuleSize - average); - return dA < dB ? -1 : dA == dB ? 0 : 1; - }); - var limit = Math.max(0.2 * average, stdDev); - for (var i = 0; i < possibleCenters.length && possibleCenters.length > 3; i++) { - var pattern = possibleCenters[i]; - if (Math.abs(pattern.estimatedModuleSize - average) > limit) { - possibleCenters.splice(i, 1); - ///possibleCenters.RemoveAt(i); - i--; - } - } - } - if (possibleCenters.length > 3) { - // Throw away all but those first size candidate points we found. - var totalModuleSize = 0; - possibleCenters.forEach(function (possibleCenter) { - totalModuleSize += possibleCenter.estimatedModuleSize; - }); - var average = totalModuleSize / possibleCenters.length; - // possibleCenters.Sort(new CenterComparator(average)); - possibleCenters.sort(function (x, y) { - if (y.count === x.count) { - var dA = Math.abs(y.estimatedModuleSize - average); - var dB = Math.abs(x.estimatedModuleSize - average); - return dA < dB ? 1 : dA == dB ? 0 : -1; - } - return y.count - x.count; - }); - //possibleCenters.subList(3, possibleCenters.Count).clear(); - ///possibleCenters = possibleCenters.GetRange(0, 3); - possibleCenters = possibleCenters.slice(0, 3); - } - return [possibleCenters[0], possibleCenters[1], possibleCenters[2]]; - } - var pureBarcode = false; - var maxI = matrix.height; - var maxJ = matrix.width; - var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES)); - if (iSkip < MIN_SKIP || false) { - iSkip = MIN_SKIP; - } - var done = false; - var stateCount = [0, 0, 0, 0, 0]; - for (var i = iSkip - 1; i < maxI && !done; i += iSkip) { - stateCount = [0, 0, 0, 0, 0]; - var currentState = 0; - for (var j = 0; j < maxJ; j++) { - if (get(j, i)) { - // Black pixel - if ((currentState & 1) === 1) { - currentState++; - } - stateCount[currentState]++; - } - else { - // White pixel - if ((currentState & 1) === 0) { - // Counting black pixels - if (currentState === 4) { - // A winner? - if (foundPatternCross(stateCount)) { - // Yes - var confirmed = handlePossibleCenter(stateCount, i, j, pureBarcode); - if (confirmed) { - // Start examining every other line. Checking each line turned out to be too - // expensive and didn't improve performance. - iSkip = 2; - if (hasSkipped) { - done = haveMultiplyConfirmedCenters(); - } - else { - var rowSkip = findRowSkip(); - if (rowSkip > stateCount[2]) { - // Skip rows between row of lower confirmed center - // and top of presumed third confirmed center - // but back up a bit to get a full chance of detecting - // it, entire width of center of finder pattern - // Skip by rowSkip, but back off by stateCount[2] (size of last center - // of pattern we saw) to be conservative, and also back off by iSkip which - // is about to be re-added - i += rowSkip - stateCount[2] - iSkip; - j = maxJ - 1; - } - } - } - else { - stateCount = [stateCount[2], stateCount[3], stateCount[4], 1, 0]; - currentState = 3; - continue; - } - // Clear state to start looking again - stateCount = [0, 0, 0, 0, 0]; - currentState = 0; - } - else { - stateCount = [stateCount[2], stateCount[3], stateCount[4], 1, 0]; - currentState = 3; - } - } - else { - // Should I really have copy/pasted this fuckery? - stateCount[++currentState]++; - } - } - else { - // Counting the white pixels - stateCount[currentState]++; - } - } - } - if (foundPatternCross(stateCount)) { - var confirmed = handlePossibleCenter(stateCount, i, maxJ, pureBarcode); - if (confirmed) { - iSkip = stateCount[0]; - if (hasSkipped) { - // Found a third one - done = haveMultiplyConfirmedCenters(); - } - } - } - } - var patternInfo = selectBestPatterns(); - if (!patternInfo) - return null; - return ReorderFinderPattern(patternInfo); - } - exports.locate = locate; + "use strict"; + var CENTER_QUORUM = 2; + var MIN_SKIP = 3; + var MAX_MODULES = 57; + var INTEGER_MATH_SHIFT = 8; + var FinderPattern = (function () { + function FinderPattern(x, y, estimatedModuleSize, count) { + this.x = x; + this.y = y; + this.estimatedModuleSize = estimatedModuleSize; + if (count == null) { + this.count = 1; + } + else { + this.count = count; + } + } + FinderPattern.prototype.aboutEquals = function (moduleSize, i, j) { + if (Math.abs(i - this.y) <= moduleSize && Math.abs(j - this.x) <= moduleSize) { + var moduleSizeDiff = Math.abs(moduleSize - this.estimatedModuleSize); + return moduleSizeDiff <= 1.0 || moduleSizeDiff <= this.estimatedModuleSize; + } + return false; + }; + FinderPattern.prototype.combineEstimate = function (i, j, newModuleSize) { + var combinedCount = this.count + 1; + var combinedX = (this.count * this.x + j) / combinedCount; + var combinedY = (this.count * this.y + i) / combinedCount; + var combinedModuleSize = (this.count * this.estimatedModuleSize + newModuleSize) / combinedCount; + return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); + }; + return FinderPattern; + }()); + function foundPatternCross(stateCount) { + var totalModuleSize = 0; + for (var i = 0; i < 5; i++) { + var count = stateCount[i]; + if (count === 0) + return false; + totalModuleSize += count; + } + if (totalModuleSize < 7) + return false; + var moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; + var maxVariance = moduleSize / 2; + // Allow less than 50% variance from 1-1-3-1-1 proportions + return Math.abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && + Math.abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && + Math.abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance; + } + function centerFromEnd(stateCount, end) { + var result = (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2; + // Fix this. + if (result !== result) { + return null; + } + return result; + } + function distance(pattern1, pattern2) { + var a = pattern1.x - pattern2.x; + var b = pattern1.y - pattern2.y; + return Math.sqrt(a * a + b * b); + } + function crossProductZ(pointA, pointB, pointC) { + var bX = pointB.x; + var bY = pointB.y; + return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); + } + function ReorderFinderPattern(patterns) { + // Find distances between pattern centers + var zeroOneDistance = distance(patterns[0], patterns[1]); + var oneTwoDistance = distance(patterns[1], patterns[2]); + var zeroTwoDistance = distance(patterns[0], patterns[2]); + var pointA, pointB, pointC; + // Assume one closest to other two is B; A and C will just be guesses at first + if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { + pointB = patterns[0]; + pointA = patterns[1]; + pointC = patterns[2]; + } + else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) { + pointB = patterns[1]; + pointA = patterns[0]; + pointC = patterns[2]; + } + else { + pointB = patterns[2]; + pointA = patterns[0]; + pointC = patterns[1]; + } + // Use cross product to figure out whether A and C are correct or flipped. + // This asks whether BC x BA has a positive z component, which is the arrangement + // we want for A, B, C. If it's negative, then we've got it flipped around and + // should swap A and C. + if (crossProductZ(pointA, pointB, pointC) < 0) { + var temp = pointA; + pointA = pointC; + pointC = temp; + } + return { + bottomLeft: { x: pointA.x, y: pointA.y }, + topLeft: { x: pointB.x, y: pointB.y }, + topRight: { x: pointC.x, y: pointC.y } + }; + } + function locate(matrix) { + // Global state :( + var possibleCenters = []; + var hasSkipped = false; + function get(x, y) { + x = Math.floor(x); + y = Math.floor(y); + return matrix.get(x, y); + } + // Methods + function crossCheckDiagonal(startI, centerJ, maxCount, originalStateCountTotal) { + var maxI = matrix.height; + var maxJ = matrix.width; + var stateCount = [0, 0, 0, 0, 0]; + // Start counting up, left from center finding black center mass + var i = 0; + while (startI - i >= 0 && get(centerJ - i, startI - i)) { + stateCount[2]++; + i++; + } + if ((startI - i < 0) || (centerJ - i < 0)) { + return false; + } + // Continue up, left finding white space + while ((startI - i >= 0) && (centerJ - i >= 0) && !get(centerJ - i, startI - i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + // If already too many modules in this state or ran off the edge: + if ((startI - i < 0) || (centerJ - i < 0) || stateCount[1] > maxCount) { + return false; + } + // Continue up, left finding black border + while ((startI - i >= 0) && (centerJ - i >= 0) && get(centerJ - i, startI - i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i++; + } + if (stateCount[0] > maxCount) { + return false; + } + // Now also count down, right from center + i = 1; + while ((startI + i < maxI) && (centerJ + i < maxJ) && get(centerJ + i, startI + i)) { + stateCount[2]++; + i++; + } + // Ran off the edge? + if ((startI + i >= maxI) || (centerJ + i >= maxJ)) { + return false; + } + while ((startI + i < maxI) && (centerJ + i < maxJ) && !get(centerJ + i, startI + i) && stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if ((startI + i >= maxI) || (centerJ + i >= maxJ) || stateCount[3] >= maxCount) { + return false; + } + while ((startI + i < maxI) && (centerJ + i < maxJ) && get(centerJ + i, startI + i) && stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return false; + } + // If we found a finder-pattern-like section, but its size is more than 100% different than + // the original, assume it's a false positive + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; + return Math.abs(stateCountTotal - originalStateCountTotal) < 2 * originalStateCountTotal && + foundPatternCross(stateCount); + } + function crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal) { + var maxI = matrix.height; + var stateCount = [0, 0, 0, 0, 0]; + // Start counting up from center + var i = startI; + while (i >= 0 && get(centerJ, i)) { + stateCount[2]++; + i--; + } + if (i < 0) { + return null; + } + while (i >= 0 && !get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return null; + } + while (i >= 0 && get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return null; + } + // Now also count down from center + i = startI + 1; + while (i < maxI && get(centerJ, i)) { + stateCount[2]++; + i++; + } + if (i == maxI) { + return null; + } + while (i < maxI && !get(centerJ, i) && stateCount[3] < maxCount) { + stateCount[3]++; + i++; + } + if (i == maxI || stateCount[3] >= maxCount) { + return null; + } + while (i < maxI && get(centerJ, i) && stateCount[4] < maxCount) { + stateCount[4]++; + i++; + } + if (stateCount[4] >= maxCount) { + return null; + } + // If we found a finder-pattern-like section, but its size is more than 40% different than + // the original, assume it's a false positive + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return null; + } + return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : null; + } + function haveMultiplyConfirmedCenters() { + var confirmedCount = 0; + var totalModuleSize = 0; + var max = possibleCenters.length; + possibleCenters.forEach(function (pattern) { + if (pattern.count >= CENTER_QUORUM) { + confirmedCount++; + totalModuleSize += pattern.estimatedModuleSize; + } + }); + if (confirmedCount < 3) { + return false; + } + // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" + // and that we need to keep looking. We detect this by asking if the estimated module sizes + // vary too much. We arbitrarily say that when the total deviation from average exceeds + // 5% of the total module size estimates, it's too much. + var average = totalModuleSize / max; + var totalDeviation = 0; + for (var i = 0; i < max; i++) { + var pattern = possibleCenters[i]; + totalDeviation += Math.abs(pattern.estimatedModuleSize - average); + } + return totalDeviation <= 0.05 * totalModuleSize; + } + function crossCheckHorizontal(startJ, centerI, maxCount, originalStateCountTotal) { + var maxJ = matrix.width; + var stateCount = [0, 0, 0, 0, 0]; + var j = startJ; + while (j >= 0 && get(j, centerI)) { + stateCount[2]++; + j--; + } + if (j < 0) { + return null; + } + while (j >= 0 && !get(j, centerI) && stateCount[1] <= maxCount) { + stateCount[1]++; + j--; + } + if (j < 0 || stateCount[1] > maxCount) { + return null; + } + while (j >= 0 && get(j, centerI) && stateCount[0] <= maxCount) { + stateCount[0]++; + j--; + } + if (stateCount[0] > maxCount) { + return null; + } + j = startJ + 1; + while (j < maxJ && get(j, centerI)) { + stateCount[2]++; + j++; + } + if (j == maxJ) { + return null; + } + while (j < maxJ && !get(j, centerI) && stateCount[3] < maxCount) { + stateCount[3]++; + j++; + } + if (j == maxJ || stateCount[3] >= maxCount) { + return null; + } + while (j < maxJ && get(j, centerI) && stateCount[4] < maxCount) { + stateCount[4]++; + j++; + } + if (stateCount[4] >= maxCount) { + return null; + } + // If we found a finder-pattern-like section, but its size is significantly different than + // the original, assume it's a false positive + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) { + return null; + } + return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : null; + } + function handlePossibleCenter(stateCount, i, j, pureBarcode) { + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; + var centerJ = centerFromEnd(stateCount, j); + if (centerJ == null) + return false; + var centerI = crossCheckVertical(i, Math.floor(centerJ), stateCount[2], stateCountTotal); + if (centerI != null) { + // Re-cross check + centerJ = crossCheckHorizontal(Math.floor(centerJ), Math.floor(centerI), stateCount[2], stateCountTotal); + if (centerJ != null && (!pureBarcode || crossCheckDiagonal(Math.floor(centerI), Math.floor(centerJ), stateCount[2], stateCountTotal))) { + var estimatedModuleSize = stateCountTotal / 7; + var found = false; + for (var index = 0; index < possibleCenters.length; index++) { + var center = possibleCenters[index]; + // Look for about the same center and module size: + if (center.aboutEquals(estimatedModuleSize, centerI, centerJ)) { + possibleCenters.splice(index, 1, center.combineEstimate(centerI, centerJ, estimatedModuleSize)); + found = true; + break; + } + } + if (!found) { + // var point = new FinderPattern(centerJ.Value, centerI.Value, estimatedModuleSize); + var point = new FinderPattern(centerJ, centerI, estimatedModuleSize); + possibleCenters.push(point); + } + return true; + } + } + return false; + } + function findRowSkip() { + var max = possibleCenters.length; + if (max <= 1) { + return 0; + } + var firstConfirmedCenter = null; + possibleCenters.forEach(function (center) { + if (center.count >= CENTER_QUORUM) { + if (firstConfirmedCenter == null) { + firstConfirmedCenter = center; + } + else { + // We have two confirmed centers + // How far down can we skip before resuming looking for the next + // pattern? In the worst case, only the difference between the + // difference in the x / y coordinates of the two centers. + // This is the case where you find top left last. + hasSkipped = true; + //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" + return Math.floor(Math.abs(firstConfirmedCenter.x - center.x) - Math.abs(firstConfirmedCenter.y - center.y)) / 2; + } + } + }); + return 0; + } + function selectBestPatterns() { + var startSize = possibleCenters.length; + if (startSize < 3) { + // Couldn't find enough finder patterns + return null; + } + // Filter outlier possibilities whose module size is too different + if (startSize > 3) { + // But we can only afford to do so if we have at least 4 possibilities to choose from + var totalModuleSize = 0; + var square = 0; + possibleCenters.forEach(function (center) { + var size = center.estimatedModuleSize; + totalModuleSize += size; + square += size * size; + }); + var average = totalModuleSize / startSize; + var stdDev = Math.sqrt(square / startSize - average * average); + //possibleCenters.Sort(new FurthestFromAverageComparator(average)); + possibleCenters.sort(function (x, y) { + var dA = Math.abs(y.estimatedModuleSize - average); + var dB = Math.abs(x.estimatedModuleSize - average); + return dA < dB ? -1 : dA == dB ? 0 : 1; + }); + var limit = Math.max(0.2 * average, stdDev); + for (var i = 0; i < possibleCenters.length && possibleCenters.length > 3; i++) { + var pattern = possibleCenters[i]; + if (Math.abs(pattern.estimatedModuleSize - average) > limit) { + possibleCenters.splice(i, 1); + ///possibleCenters.RemoveAt(i); + i--; + } + } + } + if (possibleCenters.length > 3) { + // Throw away all but those first size candidate points we found. + var totalModuleSize = 0; + possibleCenters.forEach(function (possibleCenter) { + totalModuleSize += possibleCenter.estimatedModuleSize; + }); + var average = totalModuleSize / possibleCenters.length; + // possibleCenters.Sort(new CenterComparator(average)); + possibleCenters.sort(function (x, y) { + if (y.count === x.count) { + var dA = Math.abs(y.estimatedModuleSize - average); + var dB = Math.abs(x.estimatedModuleSize - average); + return dA < dB ? 1 : dA == dB ? 0 : -1; + } + return y.count - x.count; + }); + //possibleCenters.subList(3, possibleCenters.Count).clear(); + ///possibleCenters = possibleCenters.GetRange(0, 3); + possibleCenters = possibleCenters.slice(0, 3); + } + return [possibleCenters[0], possibleCenters[1], possibleCenters[2]]; + } + var pureBarcode = false; + var maxI = matrix.height; + var maxJ = matrix.width; + var iSkip = Math.floor((3 * maxI) / (4 * MAX_MODULES)); + if (iSkip < MIN_SKIP || false) { + iSkip = MIN_SKIP; + } + var done = false; + var stateCount = [0, 0, 0, 0, 0]; + for (var i = iSkip - 1; i < maxI && !done; i += iSkip) { + stateCount = [0, 0, 0, 0, 0]; + var currentState = 0; + for (var j = 0; j < maxJ; j++) { + if (get(j, i)) { + // Black pixel + if ((currentState & 1) === 1) { + currentState++; + } + stateCount[currentState]++; + } + else { + // White pixel + if ((currentState & 1) === 0) { + // Counting black pixels + if (currentState === 4) { + // A winner? + if (foundPatternCross(stateCount)) { + // Yes + var confirmed = handlePossibleCenter(stateCount, i, j, pureBarcode); + if (confirmed) { + // Start examining every other line. Checking each line turned out to be too + // expensive and didn't improve performance. + iSkip = 2; + if (hasSkipped) { + done = haveMultiplyConfirmedCenters(); + } + else { + var rowSkip = findRowSkip(); + if (rowSkip > stateCount[2]) { + // Skip rows between row of lower confirmed center + // and top of presumed third confirmed center + // but back up a bit to get a full chance of detecting + // it, entire width of center of finder pattern + // Skip by rowSkip, but back off by stateCount[2] (size of last center + // of pattern we saw) to be conservative, and also back off by iSkip which + // is about to be re-added + i += rowSkip - stateCount[2] - iSkip; + j = maxJ - 1; + } + } + } + else { + stateCount = [stateCount[2], stateCount[3], stateCount[4], 1, 0]; + currentState = 3; + continue; + } + // Clear state to start looking again + stateCount = [0, 0, 0, 0, 0]; + currentState = 0; + } + else { + stateCount = [stateCount[2], stateCount[3], stateCount[4], 1, 0]; + currentState = 3; + } + } + else { + // Should I really have copy/pasted this fuckery? + stateCount[++currentState]++; + } + } + else { + // Counting the white pixels + stateCount[currentState]++; + } + } + } + if (foundPatternCross(stateCount)) { + var confirmed = handlePossibleCenter(stateCount, i, maxJ, pureBarcode); + if (confirmed) { + iSkip = stateCount[0]; + if (hasSkipped) { + // Found a third one + done = haveMultiplyConfirmedCenters(); + } + } + } + } + var patternInfo = selectBestPatterns(); + if (!patternInfo) + return null; + return ReorderFinderPattern(patternInfo); + } + exports.locate = locate; /***/ }, /* 4 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - /// - var alignment_finder_1 = __webpack_require__(5); - var perspective_transform_1 = __webpack_require__(7); - var version_1 = __webpack_require__(8); - var bitmatrix_1 = __webpack_require__(2); - var helpers_1 = __webpack_require__(6); - function checkAndNudgePoints(width, height, points) { - // Check and nudge points from start until we see some that are OK: - var nudged = true; - for (var offset = 0; offset < points.length && nudged; offset += 2) { - var x = Math.floor(points[offset]); - var y = Math.floor(points[offset + 1]); - if (x < -1 || x > width || y < -1 || y > height) { - throw new Error(); - } - nudged = false; - if (x == -1) { - points[offset] = 0; - nudged = true; - } - else if (x == width) { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) { - points[offset + 1] = 0; - nudged = true; - } - else if (y == height) { - points[offset + 1] = height - 1; - nudged = true; - } - } - // Check and nudge points from end: - nudged = true; - for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) { - var x = Math.floor(points[offset]); - var y = Math.floor(points[offset + 1]); - if (x < -1 || x > width || y < -1 || y > height) { - throw new Error(); - } - nudged = false; - if (x == -1) { - points[offset] = 0; - nudged = true; - } - else if (x == width) { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) { - points[offset + 1] = 0; - nudged = true; - } - else if (y == height) { - points[offset + 1] = height - 1; - nudged = true; - } - } - return points; - } - function bitArrayFromImage(image, dimension, transform) { - if (dimension <= 0) { - return null; - } - var bits = bitmatrix_1.BitMatrix.createEmpty(dimension, dimension); - var points = new Array(dimension << 1); - for (var y = 0; y < dimension; y++) { - var max = points.length; - var iValue = y + 0.5; - for (var x = 0; x < max; x += 2) { - points[x] = (x >> 1) + 0.5; - points[x + 1] = iValue; - } - points = perspective_transform_1.transformPoints(transform, points); - // Quick check to see if points transformed to something inside the image; - // sufficient to check the endpoints - try { - var nudgedPoints = checkAndNudgePoints(image.width, image.height, points); - } - catch (e) { - return null; - } - // try { - for (var x = 0; x < max; x += 2) { - bits.set(x >> 1, y, image.get(Math.floor(nudgedPoints[x]), Math.floor(nudgedPoints[x + 1]))); - } - } - return bits; - } - function createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension) { - var dimMinusThree = dimension - 3.5; - var bottomRightX; - var bottomRightY; - var sourceBottomRightX; - var sourceBottomRightY; - if (alignmentPattern != null) { - bottomRightX = alignmentPattern.x; - bottomRightY = alignmentPattern.y; - sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3; - } - else { - // Don't have an alignment pattern, just make up the bottom-right point - bottomRightX = (topRight.x - topLeft.x) + bottomLeft.x; - bottomRightY = (topRight.y - topLeft.y) + bottomLeft.y; - sourceBottomRightX = sourceBottomRightY = dimMinusThree; - } - return perspective_transform_1.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.x, topLeft.y, topRight.x, topRight.y, bottomRightX, bottomRightY, bottomLeft.x, bottomLeft.y); - } - // Taken from 6th grade algebra - function distance(x1, y1, x2, y2) { - return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); - } - // Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. - // overallEstModuleSize - estimated module size so far - // estAlignmentX - coordinate of center of area probably containing alignment pattern - // estAlignmentY - y coordinate of above - // allowanceFactor - number of pixels in all directions to search from the center - function findAlignmentInRegion(overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor, image) { - estAlignmentX = Math.floor(estAlignmentX); - estAlignmentY = Math.floor(estAlignmentY); - // Look for an alignment pattern (3 modules in size) around where it should be - var allowance = Math.floor(allowanceFactor * overallEstModuleSize); - var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance); - var alignmentAreaRightX = Math.min(image.width, estAlignmentX + allowance); - if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { - return null; - } - var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance); - var alignmentAreaBottomY = Math.min(image.height - 1, estAlignmentY + allowance); - return alignment_finder_1.findAlignment(alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, image); - } - // Computes the dimension (number of modules on a size) of the QR Code based on the position of the finder - // patterns and estimated module size. - function computeDimension(topLeft, topRight, bottomLeft, moduleSize) { - var tltrCentersDimension = Math.round(distance(topLeft.x, topLeft.y, topRight.x, topRight.y) / moduleSize); - var tlblCentersDimension = Math.round(distance(topLeft.x, topLeft.y, bottomLeft.x, bottomLeft.y) / moduleSize); - var dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; - switch (dimension & 0x03) { - // mod 4 - case 0: - dimension++; - break; - // 1? do nothing - case 2: - dimension--; - break; - } - return dimension; - } - // Deduces version information purely from QR Code dimensions. - // http://chan.catiewayne.com/z/src/131044167276.jpg - function getProvisionalVersionForDimension(dimension) { - if (dimension % 4 != 1) { - return null; - } - var versionNumber = (dimension - 17) >> 2; - if (versionNumber < 1 || versionNumber > 40) { - return null; - } - return version_1.getVersionForNumber(versionNumber); - } - // This method traces a line from a point in the image, in the direction towards another point. - // It begins in a black region, and keeps going until it finds white, then black, then white again. - // It reports the distance from the start to this point.

- // - // This is used when figuring out how wide a finder pattern is, when the finder pattern - // may be skewed or rotated. - function sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY, image) { - fromX = Math.floor(fromX); - fromY = Math.floor(fromY); - toX = Math.floor(toX); - toY = Math.floor(toY); - // Mild variant of Bresenham's algorithm; - // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm - var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); - if (steep) { - var temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - var dx = Math.abs(toX - fromX); - var dy = Math.abs(toY - fromY); - var error = -dx >> 1; - var xstep = fromX < toX ? 1 : -1; - var ystep = fromY < toY ? 1 : -1; - // In black pixels, looking for white, first or second time. - var state = 0; - // Loop up until x == toX, but not beyond - var xLimit = toX + xstep; - for (var x = fromX, y = fromY; x != xLimit; x += xstep) { - var realX = steep ? y : x; - var realY = steep ? x : y; - // Does current pixel mean we have moved white to black or vice versa? - // Scanning black in state 0,2 and white in state 1, so if we find the wrong - // color, advance to next state or end if we are in state 2 already - if ((state == 1) === image.get(realX, realY)) { - if (state == 2) { - return distance(x, y, fromX, fromY); - } - state++; - } - error += dy; - if (error > 0) { - if (y == toY) { - break; - } - y += ystep; - error -= dx; - } - } - // Found black-white-black; give the benefit of the doubt that the next pixel outside the image - // is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a - // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. - if (state == 2) { - return distance(toX + xstep, toY, fromX, fromY); - } - // else we didn't find even black-white-black; no estimate is really possible - return NaN; - } - // Computes the total width of a finder pattern by looking for a black-white-black run from the center - // in the direction of another point (another finder pattern center), and in the opposite direction too. - function sizeOfBlackWhiteBlackRunBothWays(fromX, fromY, toX, toY, image) { - var result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY, image); - // Now count other way -- don't run off image though of course - var scale = 1; - var otherToX = fromX - (toX - fromX); - if (otherToX < 0) { - scale = fromX / (fromX - otherToX); - otherToX = 0; - } - else if (otherToX >= image.width) { - scale = (image.width - 1 - fromX) / (otherToX - fromX); - otherToX = image.width - 1; - } - var otherToY = (fromY - (toY - fromY) * scale); - scale = 1; - if (otherToY < 0) { - scale = fromY / (fromY - otherToY); - otherToY = 0; - } - else if (otherToY >= image.height) { - scale = (image.height - 1 - fromY) / (otherToY - fromY); - otherToY = image.height - 1; - } - otherToX = (fromX + (otherToX - fromX) * scale); - result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY, image); - return result - 1; // -1 because we counted the middle pixel twice - } - function calculateModuleSizeOneWay(pattern, otherPattern, image) { - var moduleSizeEst1 = sizeOfBlackWhiteBlackRunBothWays(pattern.x, pattern.y, otherPattern.x, otherPattern.y, image); - var moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays(otherPattern.x, otherPattern.y, pattern.x, pattern.y, image); - if (helpers_1.isNaN(moduleSizeEst1)) { - return moduleSizeEst2 / 7; - } - if (helpers_1.isNaN(moduleSizeEst2)) { - return moduleSizeEst1 / 7; - } - // Average them, and divide by 7 since we've counted the width of 3 black modules, - // and 1 white and 1 black module on either side. Ergo, divide sum by 14. - return (moduleSizeEst1 + moduleSizeEst2) / 14; - } - // Computes an average estimated module size based on estimated derived from the positions of the three finder patterns. - function calculateModuleSize(topLeft, topRight, bottomLeft, image) { - return (calculateModuleSizeOneWay(topLeft, topRight, image) + calculateModuleSizeOneWay(topLeft, bottomLeft, image)) / 2; - } - function extract(image, location) { - var moduleSize = calculateModuleSize(location.topLeft, location.topRight, location.bottomLeft, image); - if (moduleSize < 1) { - return null; - } - var dimension = computeDimension(location.topLeft, location.topRight, location.bottomLeft, moduleSize); - if (!dimension) { - return null; - } - var provisionalVersion = getProvisionalVersionForDimension(dimension); - if (provisionalVersion == null) { - return null; - } - var modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7; - var alignmentPattern = null; - // Anything above version 1 has an alignment pattern - if (provisionalVersion.alignmentPatternCenters.length > 0) { - // Guess where a "bottom right" finder pattern would have been - var bottomRightX = location.topRight.x - location.topLeft.x + location.bottomLeft.x; - var bottomRightY = location.topRight.y - location.topLeft.y + location.bottomLeft.y; - // Estimate that alignment pattern is closer by 3 modules - // from "bottom right" to known top left location - var correctionToTopLeft = 1 - 3 / modulesBetweenFPCenters; - var estAlignmentX = location.topLeft.x + correctionToTopLeft * (bottomRightX - location.topLeft.x); - var estAlignmentY = location.topLeft.y + correctionToTopLeft * (bottomRightY - location.topLeft.y); - // Kind of arbitrary -- expand search radius before giving up - for (var i = 4; i <= 16; i <<= 1) { - alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i, image); - if (!alignmentPattern) { - continue; - } - break; - } - } - var transform = createTransform(location.topLeft, location.topRight, location.bottomLeft, alignmentPattern, dimension); - return bitArrayFromImage(image, dimension, transform); - } - exports.extract = extract; + "use strict"; + /// + var alignment_finder_1 = __webpack_require__(5); + var perspective_transform_1 = __webpack_require__(7); + var version_1 = __webpack_require__(8); + var bitmatrix_1 = __webpack_require__(2); + var helpers_1 = __webpack_require__(6); + function checkAndNudgePoints(width, height, points) { + // Check and nudge points from start until we see some that are OK: + var nudged = true; + for (var offset = 0; offset < points.length && nudged; offset += 2) { + var x = Math.floor(points[offset]); + var y = Math.floor(points[offset + 1]); + if (x < -1 || x > width || y < -1 || y > height) { + throw new Error(); + } + nudged = false; + if (x == -1) { + points[offset] = 0; + nudged = true; + } + else if (x == width) { + points[offset] = width - 1; + nudged = true; + } + if (y == -1) { + points[offset + 1] = 0; + nudged = true; + } + else if (y == height) { + points[offset + 1] = height - 1; + nudged = true; + } + } + // Check and nudge points from end: + nudged = true; + for (var offset = points.length - 2; offset >= 0 && nudged; offset -= 2) { + var x = Math.floor(points[offset]); + var y = Math.floor(points[offset + 1]); + if (x < -1 || x > width || y < -1 || y > height) { + throw new Error(); + } + nudged = false; + if (x == -1) { + points[offset] = 0; + nudged = true; + } + else if (x == width) { + points[offset] = width - 1; + nudged = true; + } + if (y == -1) { + points[offset + 1] = 0; + nudged = true; + } + else if (y == height) { + points[offset + 1] = height - 1; + nudged = true; + } + } + return points; + } + function bitArrayFromImage(image, dimension, transform) { + if (dimension <= 0) { + return null; + } + var bits = bitmatrix_1.BitMatrix.createEmpty(dimension, dimension); + var points = new Array(dimension << 1); + for (var y = 0; y < dimension; y++) { + var max = points.length; + var iValue = y + 0.5; + for (var x = 0; x < max; x += 2) { + points[x] = (x >> 1) + 0.5; + points[x + 1] = iValue; + } + points = perspective_transform_1.transformPoints(transform, points); + // Quick check to see if points transformed to something inside the image; + // sufficient to check the endpoints + try { + var nudgedPoints = checkAndNudgePoints(image.width, image.height, points); + } + catch (e) { + return null; + } + // try { + for (var x = 0; x < max; x += 2) { + bits.set(x >> 1, y, image.get(Math.floor(nudgedPoints[x]), Math.floor(nudgedPoints[x + 1]))); + } + } + return bits; + } + function createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension) { + var dimMinusThree = dimension - 3.5; + var bottomRightX; + var bottomRightY; + var sourceBottomRightX; + var sourceBottomRightY; + if (alignmentPattern != null) { + bottomRightX = alignmentPattern.x; + bottomRightY = alignmentPattern.y; + sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3; + } + else { + // Don't have an alignment pattern, just make up the bottom-right point + bottomRightX = (topRight.x - topLeft.x) + bottomLeft.x; + bottomRightY = (topRight.y - topLeft.y) + bottomLeft.y; + sourceBottomRightX = sourceBottomRightY = dimMinusThree; + } + return perspective_transform_1.quadrilateralToQuadrilateral(3.5, 3.5, dimMinusThree, 3.5, sourceBottomRightX, sourceBottomRightY, 3.5, dimMinusThree, topLeft.x, topLeft.y, topRight.x, topRight.y, bottomRightX, bottomRightY, bottomLeft.x, bottomLeft.y); + } + // Taken from 6th grade algebra + function distance(x1, y1, x2, y2) { + return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + } + // Attempts to locate an alignment pattern in a limited region of the image, which is guessed to contain it. + // overallEstModuleSize - estimated module size so far + // estAlignmentX - coordinate of center of area probably containing alignment pattern + // estAlignmentY - y coordinate of above + // allowanceFactor - number of pixels in all directions to search from the center + function findAlignmentInRegion(overallEstModuleSize, estAlignmentX, estAlignmentY, allowanceFactor, image) { + estAlignmentX = Math.floor(estAlignmentX); + estAlignmentY = Math.floor(estAlignmentY); + // Look for an alignment pattern (3 modules in size) around where it should be + var allowance = Math.floor(allowanceFactor * overallEstModuleSize); + var alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance); + var alignmentAreaRightX = Math.min(image.width, estAlignmentX + allowance); + if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) { + return null; + } + var alignmentAreaTopY = Math.max(0, estAlignmentY - allowance); + var alignmentAreaBottomY = Math.min(image.height - 1, estAlignmentY + allowance); + return alignment_finder_1.findAlignment(alignmentAreaLeftX, alignmentAreaTopY, alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, image); + } + // Computes the dimension (number of modules on a size) of the QR Code based on the position of the finder + // patterns and estimated module size. + function computeDimension(topLeft, topRight, bottomLeft, moduleSize) { + var tltrCentersDimension = Math.round(distance(topLeft.x, topLeft.y, topRight.x, topRight.y) / moduleSize); + var tlblCentersDimension = Math.round(distance(topLeft.x, topLeft.y, bottomLeft.x, bottomLeft.y) / moduleSize); + var dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; + switch (dimension & 0x03) { + // mod 4 + case 0: + dimension++; + break; + // 1? do nothing + case 2: + dimension--; + break; + } + return dimension; + } + // Deduces version information purely from QR Code dimensions. + // http://chan.catiewayne.com/z/src/131044167276.jpg + function getProvisionalVersionForDimension(dimension) { + if (dimension % 4 != 1) { + return null; + } + var versionNumber = (dimension - 17) >> 2; + if (versionNumber < 1 || versionNumber > 40) { + return null; + } + return version_1.getVersionForNumber(versionNumber); + } + // This method traces a line from a point in the image, in the direction towards another point. + // It begins in a black region, and keeps going until it finds white, then black, then white again. + // It reports the distance from the start to this point.

+ // + // This is used when figuring out how wide a finder pattern is, when the finder pattern + // may be skewed or rotated. + function sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY, image) { + fromX = Math.floor(fromX); + fromY = Math.floor(fromY); + toX = Math.floor(toX); + toY = Math.floor(toY); + // Mild variant of Bresenham's algorithm; + // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm + var steep = Math.abs(toY - fromY) > Math.abs(toX - fromX); + if (steep) { + var temp = fromX; + fromX = fromY; + fromY = temp; + temp = toX; + toX = toY; + toY = temp; + } + var dx = Math.abs(toX - fromX); + var dy = Math.abs(toY - fromY); + var error = -dx >> 1; + var xstep = fromX < toX ? 1 : -1; + var ystep = fromY < toY ? 1 : -1; + // In black pixels, looking for white, first or second time. + var state = 0; + // Loop up until x == toX, but not beyond + var xLimit = toX + xstep; + for (var x = fromX, y = fromY; x != xLimit; x += xstep) { + var realX = steep ? y : x; + var realY = steep ? x : y; + // Does current pixel mean we have moved white to black or vice versa? + // Scanning black in state 0,2 and white in state 1, so if we find the wrong + // color, advance to next state or end if we are in state 2 already + if ((state == 1) === image.get(realX, realY)) { + if (state == 2) { + return distance(x, y, fromX, fromY); + } + state++; + } + error += dy; + if (error > 0) { + if (y == toY) { + break; + } + y += ystep; + error -= dx; + } + } + // Found black-white-black; give the benefit of the doubt that the next pixel outside the image + // is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a + // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. + if (state == 2) { + return distance(toX + xstep, toY, fromX, fromY); + } + // else we didn't find even black-white-black; no estimate is really possible + return NaN; + } + // Computes the total width of a finder pattern by looking for a black-white-black run from the center + // in the direction of another point (another finder pattern center), and in the opposite direction too. + function sizeOfBlackWhiteBlackRunBothWays(fromX, fromY, toX, toY, image) { + var result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY, image); + // Now count other way -- don't run off image though of course + var scale = 1; + var otherToX = fromX - (toX - fromX); + if (otherToX < 0) { + scale = fromX / (fromX - otherToX); + otherToX = 0; + } + else if (otherToX >= image.width) { + scale = (image.width - 1 - fromX) / (otherToX - fromX); + otherToX = image.width - 1; + } + var otherToY = (fromY - (toY - fromY) * scale); + scale = 1; + if (otherToY < 0) { + scale = fromY / (fromY - otherToY); + otherToY = 0; + } + else if (otherToY >= image.height) { + scale = (image.height - 1 - fromY) / (otherToY - fromY); + otherToY = image.height - 1; + } + otherToX = (fromX + (otherToX - fromX) * scale); + result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY, image); + return result - 1; // -1 because we counted the middle pixel twice + } + function calculateModuleSizeOneWay(pattern, otherPattern, image) { + var moduleSizeEst1 = sizeOfBlackWhiteBlackRunBothWays(pattern.x, pattern.y, otherPattern.x, otherPattern.y, image); + var moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays(otherPattern.x, otherPattern.y, pattern.x, pattern.y, image); + if (helpers_1.isNaN(moduleSizeEst1)) { + return moduleSizeEst2 / 7; + } + if (helpers_1.isNaN(moduleSizeEst2)) { + return moduleSizeEst1 / 7; + } + // Average them, and divide by 7 since we've counted the width of 3 black modules, + // and 1 white and 1 black module on either side. Ergo, divide sum by 14. + return (moduleSizeEst1 + moduleSizeEst2) / 14; + } + // Computes an average estimated module size based on estimated derived from the positions of the three finder patterns. + function calculateModuleSize(topLeft, topRight, bottomLeft, image) { + return (calculateModuleSizeOneWay(topLeft, topRight, image) + calculateModuleSizeOneWay(topLeft, bottomLeft, image)) / 2; + } + function extract(image, location) { + var moduleSize = calculateModuleSize(location.topLeft, location.topRight, location.bottomLeft, image); + if (moduleSize < 1) { + return null; + } + var dimension = computeDimension(location.topLeft, location.topRight, location.bottomLeft, moduleSize); + if (!dimension) { + return null; + } + var provisionalVersion = getProvisionalVersionForDimension(dimension); + if (provisionalVersion == null) { + return null; + } + var modulesBetweenFPCenters = provisionalVersion.getDimensionForVersion() - 7; + var alignmentPattern = null; + // Anything above version 1 has an alignment pattern + if (provisionalVersion.alignmentPatternCenters.length > 0) { + // Guess where a "bottom right" finder pattern would have been + var bottomRightX = location.topRight.x - location.topLeft.x + location.bottomLeft.x; + var bottomRightY = location.topRight.y - location.topLeft.y + location.bottomLeft.y; + // Estimate that alignment pattern is closer by 3 modules + // from "bottom right" to known top left location + var correctionToTopLeft = 1 - 3 / modulesBetweenFPCenters; + var estAlignmentX = location.topLeft.x + correctionToTopLeft * (bottomRightX - location.topLeft.x); + var estAlignmentY = location.topLeft.y + correctionToTopLeft * (bottomRightY - location.topLeft.y); + // Kind of arbitrary -- expand search radius before giving up + for (var i = 4; i <= 16; i <<= 1) { + alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, i, image); + if (!alignmentPattern) { + continue; + } + break; + } + } + var transform = createTransform(location.topLeft, location.topRight, location.bottomLeft, alignmentPattern, dimension); + return bitArrayFromImage(image, dimension, transform); + } + exports.extract = extract; /***/ }, /* 5 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - var helpers_1 = __webpack_require__(6); - function aboutEquals(center, moduleSize, i, j) { - if (Math.abs(i - center.y) <= moduleSize && Math.abs(j - center.x) <= moduleSize) { - var moduleSizeDiff = Math.abs(moduleSize - center.estimatedModuleSize); - return moduleSizeDiff <= 1 || moduleSizeDiff <= center.estimatedModuleSize; - } - return false; - } - function combineEstimate(center, i, j, newModuleSize) { - var combinedX = (center.x + j) / 2; - var combinedY = (center.y + i) / 2; - var combinedModuleSize = (center.estimatedModuleSize + newModuleSize) / 2; - return { x: combinedX, y: combinedY, estimatedModuleSize: combinedModuleSize }; - } - // returns true if the proportions of the counts is close enough to the 1/1/1 ratios used by alignment - // patterns to be considered a match - function foundPatternCross(stateCount, moduleSize) { - var maxVariance = moduleSize / 2; - for (var i = 0; i < 3; i++) { - if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { - return false; - } - } - return true; - } - // Given a count of black/white/black pixels just seen and an end position, - // figures the location of the center of this black/white/black run. - function centerFromEnd(stateCount, end) { - var result = (end - stateCount[2]) - stateCount[1] / 2; - if (helpers_1.isNaN(result)) { - return null; - } - return result; - } - // After a horizontal scan finds a potential alignment pattern, this method - // "cross-checks" by scanning down vertically through the center of the possible - // alignment pattern to see if the same proportion is detected.

- // - // startI - row where an alignment pattern was detected - // centerJ - center of the section that appears to cross an alignment pattern - // maxCount - maximum reasonable number of modules that should be observed in any reading state, based - // on the results of the horizontal scan - // originalStateCountTotal - The original state count total - function crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal, moduleSize, image) { - var maxI = image.height; - var stateCount = [0, 0, 0]; - // Start counting up from center - var i = startI; - while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) { - return null; - } - while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) { - return null; - } - // Now also count down from center - i = startI + 1; - while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { - stateCount[1]++; - i++; - } - if (i == maxI || stateCount[1] > maxCount) { - return null; - } - while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { - stateCount[2]++; - i++; - } - if (stateCount[2] > maxCount) { - return null; - } - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { - return null; - } - return foundPatternCross(stateCount, moduleSize) ? centerFromEnd(stateCount, i) : null; - } - function findAlignment(startX, startY, width, height, moduleSize, image) { - // Global State :( - var possibleCenters = []; - // This is called when a horizontal scan finds a possible alignment pattern. It will - // cross check with a vertical scan, and if successful, will see if this pattern had been - // found on a previous horizontal scan. If so, we consider it confirmed and conclude we have - // found the alignment pattern.

- // - // stateCount - reading state module counts from horizontal scan - // i - where alignment pattern may be found - // j - end of possible alignment pattern in row - function handlePossibleCenter(stateCount, i, j, moduleSize) { - var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - var centerJ = centerFromEnd(stateCount, j); - if (centerJ == null) { - return null; - } - var centerI = crossCheckVertical(i, Math.floor(centerJ), 2 * stateCount[1], stateCountTotal, moduleSize, image); - if (centerI != null) { - var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3; - for (var i2 in possibleCenters) { - var center = possibleCenters[i2]; - // Look for about the same center and module size: - if (aboutEquals(center, estimatedModuleSize, centerI, centerJ)) { - return combineEstimate(center, centerI, centerJ, estimatedModuleSize); - } - } - // Hadn't found this before; save it - var point = { x: centerJ, y: centerI, estimatedModuleSize: estimatedModuleSize }; - possibleCenters.push(point); - } - return null; - } - var maxJ = startX + width; - var middleI = startY + (height >> 1); - // We are looking for black/white/black modules in 1:1:1 ratio; - // this tracks the number of black/white/black modules seen so far - var stateCount = [0, 0, 0]; // WTF - for (var iGen = 0; iGen < height; iGen++) { - // Search from middle outwards - var i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - var j = startX; - // Burn off leading white pixels before anything else; if we start in the middle of - // a white run, it doesn't make sense to count its length, since we don't know if the - // white run continued to the left of the start point - while (j < maxJ && !image.get(j, i)) { - j++; - } - var currentState = 0; - while (j < maxJ) { - if (image.get(j, i)) { - // Black pixel - if (currentState == 1) { - // Counting black pixels - stateCount[currentState]++; - } - else { - // Counting white pixels - if (currentState == 2) { - // A winner? - if (foundPatternCross(stateCount, moduleSize)) { - // Yes - confirmed = handlePossibleCenter(stateCount, i, j, moduleSize); - if (confirmed != null) { - return confirmed; - } - } - stateCount[0] = stateCount[2]; - stateCount[1] = 1; - stateCount[2] = 0; - currentState = 1; - } - else { - stateCount[++currentState]++; - } - } - } - else { - // White pixel - if (currentState == 1) { - // Counting black pixels - currentState++; - } - stateCount[currentState]++; - } - j++; - } - if (foundPatternCross(stateCount, moduleSize)) { - var confirmed = handlePossibleCenter(stateCount, i, moduleSize, maxJ); - if (confirmed != null) { - return confirmed; - } - } - } - // Hmm, nothing we saw was observed and confirmed twice. If we had - // any guess at all, return it. - if (possibleCenters.length != 0) { - return possibleCenters[0]; - } - return null; - } - exports.findAlignment = findAlignment; + "use strict"; + var helpers_1 = __webpack_require__(6); + function aboutEquals(center, moduleSize, i, j) { + if (Math.abs(i - center.y) <= moduleSize && Math.abs(j - center.x) <= moduleSize) { + var moduleSizeDiff = Math.abs(moduleSize - center.estimatedModuleSize); + return moduleSizeDiff <= 1 || moduleSizeDiff <= center.estimatedModuleSize; + } + return false; + } + function combineEstimate(center, i, j, newModuleSize) { + var combinedX = (center.x + j) / 2; + var combinedY = (center.y + i) / 2; + var combinedModuleSize = (center.estimatedModuleSize + newModuleSize) / 2; + return { x: combinedX, y: combinedY, estimatedModuleSize: combinedModuleSize }; + } + // returns true if the proportions of the counts is close enough to the 1/1/1 ratios used by alignment + // patterns to be considered a match + function foundPatternCross(stateCount, moduleSize) { + var maxVariance = moduleSize / 2; + for (var i = 0; i < 3; i++) { + if (Math.abs(moduleSize - stateCount[i]) >= maxVariance) { + return false; + } + } + return true; + } + // Given a count of black/white/black pixels just seen and an end position, + // figures the location of the center of this black/white/black run. + function centerFromEnd(stateCount, end) { + var result = (end - stateCount[2]) - stateCount[1] / 2; + if (helpers_1.isNaN(result)) { + return null; + } + return result; + } + // After a horizontal scan finds a potential alignment pattern, this method + // "cross-checks" by scanning down vertically through the center of the possible + // alignment pattern to see if the same proportion is detected.

+ // + // startI - row where an alignment pattern was detected + // centerJ - center of the section that appears to cross an alignment pattern + // maxCount - maximum reasonable number of modules that should be observed in any reading state, based + // on the results of the horizontal scan + // originalStateCountTotal - The original state count total + function crossCheckVertical(startI, centerJ, maxCount, originalStateCountTotal, moduleSize, image) { + var maxI = image.height; + var stateCount = [0, 0, 0]; + // Start counting up from center + var i = startI; + while (i >= 0 && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i--; + } + // If already too many modules in this state or ran off the edge: + if (i < 0 || stateCount[1] > maxCount) { + return null; + } + while (i >= 0 && !image.get(centerJ, i) && stateCount[0] <= maxCount) { + stateCount[0]++; + i--; + } + if (stateCount[0] > maxCount) { + return null; + } + // Now also count down from center + i = startI + 1; + while (i < maxI && image.get(centerJ, i) && stateCount[1] <= maxCount) { + stateCount[1]++; + i++; + } + if (i == maxI || stateCount[1] > maxCount) { + return null; + } + while (i < maxI && !image.get(centerJ, i) && stateCount[2] <= maxCount) { + stateCount[2]++; + i++; + } + if (stateCount[2] > maxCount) { + return null; + } + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + if (5 * Math.abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + return null; + } + return foundPatternCross(stateCount, moduleSize) ? centerFromEnd(stateCount, i) : null; + } + function findAlignment(startX, startY, width, height, moduleSize, image) { + // Global State :( + var possibleCenters = []; + // This is called when a horizontal scan finds a possible alignment pattern. It will + // cross check with a vertical scan, and if successful, will see if this pattern had been + // found on a previous horizontal scan. If so, we consider it confirmed and conclude we have + // found the alignment pattern.

+ // + // stateCount - reading state module counts from horizontal scan + // i - where alignment pattern may be found + // j - end of possible alignment pattern in row + function handlePossibleCenter(stateCount, i, j, moduleSize) { + var stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; + var centerJ = centerFromEnd(stateCount, j); + if (centerJ == null) { + return null; + } + var centerI = crossCheckVertical(i, Math.floor(centerJ), 2 * stateCount[1], stateCountTotal, moduleSize, image); + if (centerI != null) { + var estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3; + for (var i2 in possibleCenters) { + var center = possibleCenters[i2]; + // Look for about the same center and module size: + if (aboutEquals(center, estimatedModuleSize, centerI, centerJ)) { + return combineEstimate(center, centerI, centerJ, estimatedModuleSize); + } + } + // Hadn't found this before; save it + var point = { x: centerJ, y: centerI, estimatedModuleSize: estimatedModuleSize }; + possibleCenters.push(point); + } + return null; + } + var maxJ = startX + width; + var middleI = startY + (height >> 1); + // We are looking for black/white/black modules in 1:1:1 ratio; + // this tracks the number of black/white/black modules seen so far + var stateCount = [0, 0, 0]; // WTF + for (var iGen = 0; iGen < height; iGen++) { + // Search from middle outwards + var i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); + stateCount[0] = 0; + stateCount[1] = 0; + stateCount[2] = 0; + var j = startX; + // Burn off leading white pixels before anything else; if we start in the middle of + // a white run, it doesn't make sense to count its length, since we don't know if the + // white run continued to the left of the start point + while (j < maxJ && !image.get(j, i)) { + j++; + } + var currentState = 0; + while (j < maxJ) { + if (image.get(j, i)) { + // Black pixel + if (currentState == 1) { + // Counting black pixels + stateCount[currentState]++; + } + else { + // Counting white pixels + if (currentState == 2) { + // A winner? + if (foundPatternCross(stateCount, moduleSize)) { + // Yes + confirmed = handlePossibleCenter(stateCount, i, j, moduleSize); + if (confirmed != null) { + return confirmed; + } + } + stateCount[0] = stateCount[2]; + stateCount[1] = 1; + stateCount[2] = 0; + currentState = 1; + } + else { + stateCount[++currentState]++; + } + } + } + else { + // White pixel + if (currentState == 1) { + // Counting black pixels + currentState++; + } + stateCount[currentState]++; + } + j++; + } + if (foundPatternCross(stateCount, moduleSize)) { + var confirmed = handlePossibleCenter(stateCount, i, moduleSize, maxJ); + if (confirmed != null) { + return confirmed; + } + } + } + // Hmm, nothing we saw was observed and confirmed twice. If we had + // any guess at all, return it. + if (possibleCenters.length != 0) { + return possibleCenters[0]; + } + return null; + } + exports.findAlignment = findAlignment; /***/ }, /* 6 */ /***/ function(module, exports) { - "use strict"; - var BITS_SET_IN_HALF_BYTE = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4]; - function numBitsDiffering(a, b) { - a ^= b; // a now has a 1 bit exactly where its bit differs with b's - // Count bits set quickly with a series of lookups: - return BITS_SET_IN_HALF_BYTE[a & 0x0F] + - BITS_SET_IN_HALF_BYTE[((a >> 4) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 8) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 12) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 16) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 20) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 24) & 0x0F)] + - BITS_SET_IN_HALF_BYTE[((a >> 28) & 0x0F)]; - } - exports.numBitsDiffering = numBitsDiffering; - // Taken from underscore JS - function isNaN(obj) { - return Object.prototype.toString.call(obj) === '[object Number]' && obj !== +obj; - } - exports.isNaN = isNaN; + "use strict"; + var BITS_SET_IN_HALF_BYTE = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4]; + function numBitsDiffering(a, b) { + a ^= b; // a now has a 1 bit exactly where its bit differs with b's + // Count bits set quickly with a series of lookups: + return BITS_SET_IN_HALF_BYTE[a & 0x0F] + + BITS_SET_IN_HALF_BYTE[((a >> 4) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 8) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 12) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 16) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 20) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 24) & 0x0F)] + + BITS_SET_IN_HALF_BYTE[((a >> 28) & 0x0F)]; + } + exports.numBitsDiffering = numBitsDiffering; + // Taken from underscore JS + function isNaN(obj) { + return Object.prototype.toString.call(obj) === '[object Number]' && obj !== +obj; + } + exports.isNaN = isNaN; /***/ }, /* 7 */ /***/ function(module, exports) { - /// - "use strict"; - function squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3) { - var dx3 = x0 - x1 + x2 - x3; - var dy3 = y0 - y1 + y2 - y3; - if (dx3 == 0 && dy3 == 0) { - // Affine - return { - a11: x1 - x0, - a21: x2 - x1, - a31: x0, - a12: y1 - y0, - a22: y2 - y1, - a32: y0, - a13: 0, - a23: 0, - a33: 1 - }; - } - else { - var dx1 = x1 - x2; - var dx2 = x3 - x2; - var dy1 = y1 - y2; - var dy2 = y3 - y2; - var denominator = dx1 * dy2 - dx2 * dy1; - var a13 = (dx3 * dy2 - dx2 * dy3) / denominator; - var a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - return { - a11: x1 - x0 + a13 * x1, - a21: x3 - x0 + a23 * x3, - a31: x0, - a12: y1 - y0 + a13 * y1, - a22: y3 - y0 + a23 * y3, - a32: y0, - a13: a13, - a23: a23, - a33: 1 - }; - } - } - function buildAdjoint(i) { - return { - a11: i.a22 * i.a33 - i.a23 * i.a32, - a21: i.a23 * i.a31 - i.a21 * i.a33, - a31: i.a21 * i.a32 - i.a22 * i.a31, - a12: i.a13 * i.a32 - i.a12 * i.a33, - a22: i.a11 * i.a33 - i.a13 * i.a31, - a32: i.a12 * i.a31 - i.a11 * i.a32, - a13: i.a12 * i.a23 - i.a13 * i.a22, - a23: i.a13 * i.a21 - i.a11 * i.a23, - a33: i.a11 * i.a22 - i.a12 * i.a21 - }; - } - function times(a, b) { - return { - a11: a.a11 * b.a11 + a.a21 * b.a12 + a.a31 * b.a13, - a21: a.a11 * b.a21 + a.a21 * b.a22 + a.a31 * b.a23, - a31: a.a11 * b.a31 + a.a21 * b.a32 + a.a31 * b.a33, - a12: a.a12 * b.a11 + a.a22 * b.a12 + a.a32 * b.a13, - a22: a.a12 * b.a21 + a.a22 * b.a22 + a.a32 * b.a23, - a32: a.a12 * b.a31 + a.a22 * b.a32 + a.a32 * b.a33, - a13: a.a13 * b.a11 + a.a23 * b.a12 + a.a33 * b.a13, - a23: a.a13 * b.a21 + a.a23 * b.a22 + a.a33 * b.a23, - a33: a.a13 * b.a31 + a.a23 * b.a32 + a.a33 * b.a33 - }; - } - function quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3) { - // Here, the adjoint serves as the inverse: - return buildAdjoint(squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); - } - function transformPoints(transform, points) { - var max = points.length; - var a11 = transform.a11; - var a12 = transform.a12; - var a13 = transform.a13; - var a21 = transform.a21; - var a22 = transform.a22; - var a23 = transform.a23; - var a31 = transform.a31; - var a32 = transform.a32; - var a33 = transform.a33; - for (var i = 0; i < max; i += 2) { - var x = points[i]; - var y = points[i + 1]; - var denominator = a13 * x + a23 * y + a33; - points[i] = (a11 * x + a21 * y + a31) / denominator; - points[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } - return points; - } - exports.transformPoints = transformPoints; - function quadrilateralToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p) { - var qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); - var sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); - return times(sToQ, qToS); - } - exports.quadrilateralToQuadrilateral = quadrilateralToQuadrilateral; + /// + "use strict"; + function squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3) { + var dx3 = x0 - x1 + x2 - x3; + var dy3 = y0 - y1 + y2 - y3; + if (dx3 == 0 && dy3 == 0) { + // Affine + return { + a11: x1 - x0, + a21: x2 - x1, + a31: x0, + a12: y1 - y0, + a22: y2 - y1, + a32: y0, + a13: 0, + a23: 0, + a33: 1 + }; + } + else { + var dx1 = x1 - x2; + var dx2 = x3 - x2; + var dy1 = y1 - y2; + var dy2 = y3 - y2; + var denominator = dx1 * dy2 - dx2 * dy1; + var a13 = (dx3 * dy2 - dx2 * dy3) / denominator; + var a23 = (dx1 * dy3 - dx3 * dy1) / denominator; + return { + a11: x1 - x0 + a13 * x1, + a21: x3 - x0 + a23 * x3, + a31: x0, + a12: y1 - y0 + a13 * y1, + a22: y3 - y0 + a23 * y3, + a32: y0, + a13: a13, + a23: a23, + a33: 1 + }; + } + } + function buildAdjoint(i) { + return { + a11: i.a22 * i.a33 - i.a23 * i.a32, + a21: i.a23 * i.a31 - i.a21 * i.a33, + a31: i.a21 * i.a32 - i.a22 * i.a31, + a12: i.a13 * i.a32 - i.a12 * i.a33, + a22: i.a11 * i.a33 - i.a13 * i.a31, + a32: i.a12 * i.a31 - i.a11 * i.a32, + a13: i.a12 * i.a23 - i.a13 * i.a22, + a23: i.a13 * i.a21 - i.a11 * i.a23, + a33: i.a11 * i.a22 - i.a12 * i.a21 + }; + } + function times(a, b) { + return { + a11: a.a11 * b.a11 + a.a21 * b.a12 + a.a31 * b.a13, + a21: a.a11 * b.a21 + a.a21 * b.a22 + a.a31 * b.a23, + a31: a.a11 * b.a31 + a.a21 * b.a32 + a.a31 * b.a33, + a12: a.a12 * b.a11 + a.a22 * b.a12 + a.a32 * b.a13, + a22: a.a12 * b.a21 + a.a22 * b.a22 + a.a32 * b.a23, + a32: a.a12 * b.a31 + a.a22 * b.a32 + a.a32 * b.a33, + a13: a.a13 * b.a11 + a.a23 * b.a12 + a.a33 * b.a13, + a23: a.a13 * b.a21 + a.a23 * b.a22 + a.a33 * b.a23, + a33: a.a13 * b.a31 + a.a23 * b.a32 + a.a33 * b.a33 + }; + } + function quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3) { + // Here, the adjoint serves as the inverse: + return buildAdjoint(squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); + } + function transformPoints(transform, points) { + var max = points.length; + var a11 = transform.a11; + var a12 = transform.a12; + var a13 = transform.a13; + var a21 = transform.a21; + var a22 = transform.a22; + var a23 = transform.a23; + var a31 = transform.a31; + var a32 = transform.a32; + var a33 = transform.a33; + for (var i = 0; i < max; i += 2) { + var x = points[i]; + var y = points[i + 1]; + var denominator = a13 * x + a23 * y + a33; + points[i] = (a11 * x + a21 * y + a31) / denominator; + points[i + 1] = (a12 * x + a22 * y + a32) / denominator; + } + return points; + } + exports.transformPoints = transformPoints; + function quadrilateralToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3, x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p) { + var qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); + var sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); + return times(sToQ, qToS); + } + exports.quadrilateralToQuadrilateral = quadrilateralToQuadrilateral; /***/ }, /* 8 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - var helpers_1 = __webpack_require__(6); - var VERSION_DECODE_INFO = [ - 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, - 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, - 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, - 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, - 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, - 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, - 0x2542E, 0x26A64, 0x27541, 0x28C69, - ]; - var ECB = (function () { - function ECB(_count, _dataCodewords) { - this.count = _count; - this.dataCodewords = _dataCodewords; - } - return ECB; - }()); - var ECBlocks = (function () { - function ECBlocks(_ecCodewordsPerBlock) { - var _ecBlocks = []; - for (var _i = 1; _i < arguments.length; _i++) { - _ecBlocks[_i - 1] = arguments[_i]; - } - this.ecCodewordsPerBlock = _ecCodewordsPerBlock; - this.ecBlocks = _ecBlocks; - } - ECBlocks.prototype.getNumBlocks = function () { - return this.ecBlocks.reduce(function (a, b) { return (a + b.count); }, 0); - }; - ECBlocks.prototype.getTotalECCodewords = function () { - return this.ecCodewordsPerBlock * this.getNumBlocks(); - }; - return ECBlocks; - }()); - var Version = (function () { - function Version(_versionNumber, _alignmentPatternCenters) { - var _ecBlocks = []; - for (var _i = 2; _i < arguments.length; _i++) { - _ecBlocks[_i - 2] = arguments[_i]; - } - this.versionNumber = _versionNumber; - this.alignmentPatternCenters = _alignmentPatternCenters; - this.ecBlocks = _ecBlocks; - var total = 0; - var ecCodewords = this.ecBlocks[0].ecCodewordsPerBlock; - var ecbArray = this.ecBlocks[0].ecBlocks; - ecbArray.forEach(function (ecBlock) { - total += ecBlock.count * (ecBlock.dataCodewords + ecCodewords); - }); - this.totalCodewords = total; - } - Version.prototype.getDimensionForVersion = function () { - return 17 + 4 * this.versionNumber; - }; - Version.prototype.getECBlocksForLevel = function (ecLevel) { - return this.ecBlocks[ecLevel.ordinal]; - }; - Version.decodeVersionInformation = function (versionBits) { - var bestDifference = Infinity; - var bestVersion = 0; - for (var i = 0; i < VERSION_DECODE_INFO.length; i++) { - var targetVersion = VERSION_DECODE_INFO[i]; - // Do the version info bits match exactly? done. - if (targetVersion == versionBits) { - return getVersionForNumber(i + 7); - } - // Otherwise see if this is the closest to a real version info bit string - // we have seen so far - var bitsDifference = helpers_1.numBitsDiffering(versionBits, targetVersion); - if (bitsDifference < bestDifference) { - bestVersion = i + 7; - bestDifference = bitsDifference; - } - } - // We can tolerate up to 3 bits of error since no two version info codewords will - // differ in less than 8 bits. - if (bestDifference <= 3) { - return getVersionForNumber(bestVersion); - } - // If we didn't find a close enough match, fail - return null; - }; - return Version; - }()); - exports.Version = Version; - var VERSIONS = [ - new Version(1, [], new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))), - new Version(2, [6, 18], new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))), - new Version(3, [6, 22], new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))), - new Version(4, [6, 26], new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))), - new Version(5, [6, 30], new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))), - new Version(6, [6, 34], new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))), - new Version(7, [6, 22, 38], new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))), - new Version(8, [6, 24, 42], new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))), - new Version(9, [6, 26, 46], new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))), - new Version(10, [6, 28, 50], new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))), - new Version(11, [6, 30, 54], new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))), - new Version(12, [6, 32, 58], new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))), - new Version(13, [6, 34, 62], new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))), - new Version(14, [6, 26, 46, 66], new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))), - new Version(15, [6, 26, 48, 70], new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))), - new Version(16, [6, 26, 50, 74], new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))), - new Version(17, [6, 30, 54, 78], new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))), - new Version(18, [6, 30, 56, 82], new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))), - new Version(19, [6, 30, 58, 86], new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))), - new Version(20, [6, 34, 62, 90], new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))), - new Version(21, [6, 28, 50, 72, 94], new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))), - new Version(22, [6, 26, 50, 74, 98], new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))), - new Version(23, [6, 30, 54, 74, 102], new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))), - new Version(24, [6, 28, 54, 80, 106], new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))), - new Version(25, [6, 32, 58, 84, 110], new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))), - new Version(26, [6, 30, 58, 86, 114], new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))), - new Version(27, [6, 34, 62, 90, 118], new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))), - new Version(28, [6, 26, 50, 74, 98, 122], new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))), - new Version(29, [6, 30, 54, 78, 102, 126], new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))), - new Version(30, [6, 26, 52, 78, 104, 130], new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))), - new Version(31, [6, 30, 56, 82, 108, 134], new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))), - new Version(32, [6, 34, 60, 86, 112, 138], new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))), - new Version(33, [6, 30, 58, 86, 114, 142], new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))), - new Version(34, [6, 34, 62, 90, 118, 146], new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))), - new Version(35, [6, 30, 54, 78, 102, 126, 150], new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))), - new Version(36, [6, 24, 50, 76, 102, 128, 154], new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))), - new Version(37, [6, 28, 54, 80, 106, 132, 158], new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))), - new Version(38, [6, 32, 58, 84, 110, 136, 162], new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))), - new Version(39, [6, 26, 54, 82, 110, 138, 166], new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))), - new Version(40, [6, 30, 58, 86, 114, 142, 170], new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))), - ]; - function getVersionForNumber(versionNumber) { - if (versionNumber < 1 || versionNumber > 40) { - throw new Error("Invalid version number " + versionNumber); - } - return VERSIONS[versionNumber - 1]; - } - exports.getVersionForNumber = getVersionForNumber; + "use strict"; + var helpers_1 = __webpack_require__(6); + var VERSION_DECODE_INFO = [ + 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, + 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, + 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, + 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, + 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, + 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, + 0x2542E, 0x26A64, 0x27541, 0x28C69, + ]; + var ECB = (function () { + function ECB(_count, _dataCodewords) { + this.count = _count; + this.dataCodewords = _dataCodewords; + } + return ECB; + }()); + var ECBlocks = (function () { + function ECBlocks(_ecCodewordsPerBlock) { + var _ecBlocks = []; + for (var _i = 1; _i < arguments.length; _i++) { + _ecBlocks[_i - 1] = arguments[_i]; + } + this.ecCodewordsPerBlock = _ecCodewordsPerBlock; + this.ecBlocks = _ecBlocks; + } + ECBlocks.prototype.getNumBlocks = function () { + return this.ecBlocks.reduce(function (a, b) { return (a + b.count); }, 0); + }; + ECBlocks.prototype.getTotalECCodewords = function () { + return this.ecCodewordsPerBlock * this.getNumBlocks(); + }; + return ECBlocks; + }()); + var Version = (function () { + function Version(_versionNumber, _alignmentPatternCenters) { + var _ecBlocks = []; + for (var _i = 2; _i < arguments.length; _i++) { + _ecBlocks[_i - 2] = arguments[_i]; + } + this.versionNumber = _versionNumber; + this.alignmentPatternCenters = _alignmentPatternCenters; + this.ecBlocks = _ecBlocks; + var total = 0; + var ecCodewords = this.ecBlocks[0].ecCodewordsPerBlock; + var ecbArray = this.ecBlocks[0].ecBlocks; + ecbArray.forEach(function (ecBlock) { + total += ecBlock.count * (ecBlock.dataCodewords + ecCodewords); + }); + this.totalCodewords = total; + } + Version.prototype.getDimensionForVersion = function () { + return 17 + 4 * this.versionNumber; + }; + Version.prototype.getECBlocksForLevel = function (ecLevel) { + return this.ecBlocks[ecLevel.ordinal]; + }; + Version.decodeVersionInformation = function (versionBits) { + var bestDifference = Infinity; + var bestVersion = 0; + for (var i = 0; i < VERSION_DECODE_INFO.length; i++) { + var targetVersion = VERSION_DECODE_INFO[i]; + // Do the version info bits match exactly? done. + if (targetVersion == versionBits) { + return getVersionForNumber(i + 7); + } + // Otherwise see if this is the closest to a real version info bit string + // we have seen so far + var bitsDifference = helpers_1.numBitsDiffering(versionBits, targetVersion); + if (bitsDifference < bestDifference) { + bestVersion = i + 7; + bestDifference = bitsDifference; + } + } + // We can tolerate up to 3 bits of error since no two version info codewords will + // differ in less than 8 bits. + if (bestDifference <= 3) { + return getVersionForNumber(bestVersion); + } + // If we didn't find a close enough match, fail + return null; + }; + return Version; + }()); + exports.Version = Version; + var VERSIONS = [ + new Version(1, [], new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), new ECBlocks(17, new ECB(1, 9))), + new Version(2, [6, 18], new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), new ECBlocks(28, new ECB(1, 16))), + new Version(3, [6, 22], new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), new ECBlocks(22, new ECB(2, 13))), + new Version(4, [6, 26], new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), new ECBlocks(16, new ECB(4, 9))), + new Version(5, [6, 30], new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), new ECB(2, 12))), + new Version(6, [6, 34], new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), new ECBlocks(28, new ECB(4, 15))), + new Version(7, [6, 22, 38], new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), new ECB(1, 14))), + new Version(8, [6, 24, 42], new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), new ECB(2, 15))), + new Version(9, [6, 26, 46], new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), new ECB(4, 13))), + new Version(10, [6, 28, 50], new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), new ECB(1, 44)), new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), new ECB(2, 16))), + new Version(11, [6, 30, 54], new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), new ECB(8, 13))), + new Version(12, [6, 32, 58], new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), new ECB(2, 37)), new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), new ECB(4, 15))), + new Version(13, [6, 34, 62], new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), new ECB(4, 12))), + new Version(14, [6, 26, 46, 66], new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), new ECB(5, 41)), new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), new ECB(5, 13))), + new Version(15, [6, 26, 48, 70], new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), new ECB(5, 42)), new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), new ECB(7, 13))), + new Version(16, [6, 26, 50, 74], new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), new ECB(3, 46)), new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), new ECB(13, 16))), + new Version(17, [6, 30, 54, 78], new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), new ECB(1, 47)), new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(17, 15))), + new Version(18, [6, 30, 56, 82], new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), new ECB(4, 44)), new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), new ECB(19, 15))), + new Version(19, [6, 30, 58, 86], new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), new ECB(11, 45)), new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), new ECB(16, 14))), + new Version(20, [6, 34, 62, 90], new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), new ECB(13, 42)), new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), new ECB(10, 16))), + new Version(21, [6, 28, 50, 72, 94], new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), new ECB(6, 17))), + new Version(22, [6, 26, 50, 74, 98], new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), new ECBlocks(24, new ECB(34, 13))), + new Version(23, [6, 30, 54, 74, 102], new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), new ECB(14, 48)), new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), new ECB(14, 16))), + new Version(24, [6, 28, 54, 80, 106], new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), new ECB(14, 46)), new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), new ECB(2, 17))), + new Version(25, [6, 32, 58, 84, 110], new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), new ECB(13, 48)), new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(13, 16))), + new Version(26, [6, 30, 58, 86, 114], new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), new ECB(4, 47)), new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), new ECB(4, 17))), + new Version(27, [6, 34, 62, 90, 118], new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), new ECB(3, 46)), new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), new ECB(28, 16))), + new Version(28, [6, 26, 50, 74, 98, 122], new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), new ECB(23, 46)), new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(31, 16))), + new Version(29, [6, 30, 54, 78, 102, 126], new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), new ECB(7, 46)), new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), new ECB(26, 16))), + new Version(30, [6, 26, 52, 78, 104, 130], new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), new ECB(10, 48)), new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(25, 16))), + new Version(31, [6, 30, 56, 82, 108, 134], new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), new ECB(29, 47)), new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), new ECB(28, 16))), + new Version(32, [6, 34, 60, 86, 112, 138], new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), new ECB(35, 16))), + new Version(33, [6, 30, 58, 86, 114, 142], new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(21, 47)), new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), new ECB(46, 16))), + new Version(34, [6, 34, 62, 90, 118, 146], new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), new ECB(1, 17))), + new Version(35, [6, 30, 54, 78, 102, 126, 150], new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), new ECBlocks(28, new ECB(12, 47), new ECB(26, 48)), new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(22, 15), new ECB(41, 16))), + new Version(36, [6, 24, 50, 76, 102, 128, 154], new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), new ECBlocks(28, new ECB(6, 47), new ECB(34, 48)), new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), new ECB(64, 16))), + new Version(37, [6, 28, 54, 80, 106, 132, 158], new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(29, 46), new ECB(14, 47)), new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), new ECB(46, 16))), + new Version(38, [6, 32, 58, 84, 110, 136, 162], new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), new ECBlocks(28, new ECB(13, 46), new ECB(32, 47)), new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), new ECB(32, 16))), + new Version(39, [6, 26, 54, 82, 110, 138, 166], new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(40, 47), new ECB(7, 48)), new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), new ECB(67, 16))), + new Version(40, [6, 30, 58, 86, 114, 142, 170], new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), new ECBlocks(28, new ECB(18, 47), new ECB(31, 48)), new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))), + ]; + function getVersionForNumber(versionNumber) { + if (versionNumber < 1 || versionNumber > 40) { + throw new Error("Invalid version number " + versionNumber); + } + return VERSIONS[versionNumber - 1]; + } + exports.getVersionForNumber = getVersionForNumber; /***/ }, /* 9 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - var bitmatrix_1 = __webpack_require__(2); - var decodeqrdata_1 = __webpack_require__(10); - var helpers_1 = __webpack_require__(6); - var reedsolomon_1 = __webpack_require__(12); - var version_1 = __webpack_require__(8); - var FORMAT_INFO_MASK_QR = 0x5412; - var FORMAT_INFO_DECODE_LOOKUP = [ - [0x5412, 0x00], - [0x5125, 0x01], - [0x5E7C, 0x02], - [0x5B4B, 0x03], - [0x45F9, 0x04], - [0x40CE, 0x05], - [0x4F97, 0x06], - [0x4AA0, 0x07], - [0x77C4, 0x08], - [0x72F3, 0x09], - [0x7DAA, 0x0A], - [0x789D, 0x0B], - [0x662F, 0x0C], - [0x6318, 0x0D], - [0x6C41, 0x0E], - [0x6976, 0x0F], - [0x1689, 0x10], - [0x13BE, 0x11], - [0x1CE7, 0x12], - [0x19D0, 0x13], - [0x0762, 0x14], - [0x0255, 0x15], - [0x0D0C, 0x16], - [0x083B, 0x17], - [0x355F, 0x18], - [0x3068, 0x19], - [0x3F31, 0x1A], - [0x3A06, 0x1B], - [0x24B4, 0x1C], - [0x2183, 0x1D], - [0x2EDA, 0x1E], - [0x2BED, 0x1F], - ]; - var DATA_MASKS = [ - function (i, j) { return ((i + j) & 0x01) === 0; }, - function (i, j) { return (i & 0x01) === 0; }, - function (i, j) { return j % 3 == 0; }, - function (i, j) { return (i + j) % 3 === 0; }, - function (i, j) { return (((i >> 1) + (j / 3)) & 0x01) === 0; }, - function (i, j) { return ((i * j) & 0x01) + ((i * j) % 3) === 0; }, - function (i, j) { return ((((i * j) & 0x01) + ((i * j) % 3)) & 0x01) === 0; }, - function (i, j) { return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) === 0; }, - ]; - var ERROR_CORRECTION_LEVELS = [ - { ordinal: 1, bits: 0x00, name: "M" }, - { ordinal: 0, bits: 0x01, name: "L" }, - { ordinal: 3, bits: 0x02, name: "H" }, - { ordinal: 2, bits: 0x03, name: "Q" }, - ]; - function buildFunctionPattern(version) { - var dimension = version.getDimensionForVersion(); - var emptyArray = new Array(dimension * dimension); - for (var i = 0; i < emptyArray.length; i++) { - emptyArray[i] = false; - } - var bitMatrix = new bitmatrix_1.BitMatrix(emptyArray, dimension); - ///BitMatrix bitMatrix = new BitMatrix(dimension); - // Top left finder pattern + separator + format - bitMatrix.setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - bitMatrix.setRegion(dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - bitMatrix.setRegion(0, dimension - 8, 9, 8); - // Alignment patterns - var max = version.alignmentPatternCenters.length; - for (var x = 0; x < max; x++) { - var i = version.alignmentPatternCenters[x] - 2; - for (var y = 0; y < max; y++) { - if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { - // No alignment patterns near the three finder paterns - continue; - } - bitMatrix.setRegion(version.alignmentPatternCenters[y] - 2, i, 5, 5); - } - } - // Vertical timing pattern - bitMatrix.setRegion(6, 9, 1, dimension - 17); - // Horizontal timing pattern - bitMatrix.setRegion(9, 6, dimension - 17, 1); - if (version.versionNumber > 6) { - // Version info, top right - bitMatrix.setRegion(dimension - 11, 0, 3, 6); - // Version info, bottom left - bitMatrix.setRegion(0, dimension - 11, 6, 3); - } - return bitMatrix; - } - function readCodewords(matrix, version, formatInfo) { - // Get the data mask for the format used in this QR Code. This will exclude - // some bits from reading as we wind through the bit matrix. - var dataMask = DATA_MASKS[formatInfo.dataMask]; - var dimension = matrix.height; - var funcPattern = buildFunctionPattern(version); - var readingUp = true; - var result = []; - var resultOffset = 0; - var currentByte = 0; - var bitsRead = 0; - // Read columns in pairs, from right to left - for (var j = dimension - 1; j > 0; j -= 2) { - if (j == 6) { - // Skip whole column with vertical alignment pattern; - // saves time and makes the other code proceed more cleanly - j--; - } - // Read alternatingly from bottom to top then top to bottom - for (var count = 0; count < dimension; count++) { - var i = readingUp ? dimension - 1 - count : count; - for (var col = 0; col < 2; col++) { - // Ignore bits covered by the function pattern - if (!funcPattern.get(j - col, i)) { - // Read a bit - bitsRead++; - currentByte <<= 1; - if (matrix.get(j - col, i) !== dataMask(i, j - col)) { - currentByte |= 1; - } - // If we've made a whole byte, save it off - if (bitsRead == 8) { - result[resultOffset++] = currentByte & 0xFF; - bitsRead = 0; - currentByte = 0; - } - } - } - } - readingUp = !readingUp; // switch directions - } - if (resultOffset != version.totalCodewords) { - return null; - } - return result; - } - function readVersion(matrix) { - var dimension = matrix.height; - var provisionalVersion = (dimension - 17) >> 2; - if (provisionalVersion <= 6) { - return version_1.getVersionForNumber(provisionalVersion); - } - // Read top-right version info: 3 wide by 6 tall - var versionBits = 0; - var ijMin = dimension - 11; - for (var j = 5; j >= 0; j--) { - for (var i = dimension - 9; i >= ijMin; i--) { - versionBits = matrix.copyBit(i, j, versionBits); - } - } - var parsedVersion = version_1.Version.decodeVersionInformation(versionBits); - if (parsedVersion != null && parsedVersion.getDimensionForVersion() == dimension) { - return parsedVersion; - } - // Hmm, failed. Try bottom left: 6 wide by 3 tall - versionBits = 0; - for (var i = 5; i >= 0; i--) { - for (var j = dimension - 9; j >= ijMin; j--) { - versionBits = matrix.copyBit(i, j, versionBits); - } - } - parsedVersion = version_1.Version.decodeVersionInformation(versionBits); - if (parsedVersion != null && parsedVersion.getDimensionForVersion() == dimension) { - return parsedVersion; - } - return null; - } - function newFormatInformation(formatInfo) { - return { - errorCorrectionLevel: ERROR_CORRECTION_LEVELS[(formatInfo >> 3) & 0x03], - dataMask: formatInfo & 0x07 - }; - } - function doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2) { - // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing - var bestDifference = Infinity; - var bestFormatInfo = 0; - for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) { - var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i]; - var targetInfo = decodeInfo[0]; - if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2) { - // Found an exact match - return newFormatInformation(decodeInfo[1]); - } - var bitsDifference = helpers_1.numBitsDiffering(maskedFormatInfo1, targetInfo); - if (bitsDifference < bestDifference) { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - if (maskedFormatInfo1 != maskedFormatInfo2) { - // also try the other option - bitsDifference = helpers_1.numBitsDiffering(maskedFormatInfo2, targetInfo); - if (bitsDifference < bestDifference) { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - } - } - // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits - // differing means we found a match - if (bestDifference <= 3) - return newFormatInformation(bestFormatInfo); - return null; - } - function decodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2) { - var formatInfo = doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2); - if (formatInfo) { - return formatInfo; - } - // Should return null, but, some QR codes apparently - // do not mask this info. Try again by actually masking the pattern - // first - return doDecodeFormatInformation(maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR, maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR); - } - function readFormatInformation(matrix) { - // Read top-left format info bits - var formatInfoBits1 = 0; - for (var i = 0; i < 6; i++) { - formatInfoBits1 = matrix.copyBit(i, 8, formatInfoBits1); - } - // .. and skip a bit in the timing pattern ... - formatInfoBits1 = matrix.copyBit(7, 8, formatInfoBits1); - formatInfoBits1 = matrix.copyBit(8, 8, formatInfoBits1); - formatInfoBits1 = matrix.copyBit(8, 7, formatInfoBits1); - // .. and skip a bit in the timing pattern ... - for (var j = 5; j >= 0; j--) { - formatInfoBits1 = matrix.copyBit(8, j, formatInfoBits1); - } - // Read the top-right/bottom-left pattern too - var dimension = matrix.height; - var formatInfoBits2 = 0; - var jMin = dimension - 7; - for (var j = dimension - 1; j >= jMin; j--) { - formatInfoBits2 = matrix.copyBit(8, j, formatInfoBits2); - } - for (var i = dimension - 8; i < dimension; i++) { - formatInfoBits2 = matrix.copyBit(i, 8, formatInfoBits2); - } - // parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); - var parsedFormatInfo = decodeFormatInformation(formatInfoBits1, formatInfoBits2); - if (parsedFormatInfo != null) { - return parsedFormatInfo; - } - return null; - } - function getDataBlocks(rawCodewords, version, ecLevel) { - if (rawCodewords.length != version.totalCodewords) { - throw new Error("Invalid number of codewords for version; got " + rawCodewords.length + " expected " + version.totalCodewords); - } - // Figure out the number and size of data blocks used by this version and - // error correction level - var ecBlocks = version.getECBlocksForLevel(ecLevel); - // First count the total number of data blocks - var totalBlocks = 0; - var ecBlockArray = ecBlocks.ecBlocks; - ecBlockArray.forEach(function (ecBlock) { - totalBlocks += ecBlock.count; - }); - // Now establish DataBlocks of the appropriate size and number of data codewords - var result = new Array(totalBlocks); - var numResultBlocks = 0; - ecBlockArray.forEach(function (ecBlock) { - for (var i = 0; i < ecBlock.count; i++) { - var numDataCodewords = ecBlock.dataCodewords; - var numBlockCodewords = ecBlocks.ecCodewordsPerBlock + numDataCodewords; - result[numResultBlocks++] = { numDataCodewords: numDataCodewords, codewords: new Array(numBlockCodewords) }; - } - }); - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 more byte. Figure out where these start. - var shorterBlocksTotalCodewords = result[0].codewords.length; - var longerBlocksStartAt = result.length - 1; - while (longerBlocksStartAt >= 0) { - var numCodewords = result[longerBlocksStartAt].codewords.length; - if (numCodewords == shorterBlocksTotalCodewords) { - break; - } - longerBlocksStartAt--; - } - longerBlocksStartAt++; - var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ecCodewordsPerBlock; - // The last elements of result may be 1 element longer; - // first fill out as many elements as all of them have - var rawCodewordsOffset = 0; - for (var i = 0; i < shorterBlocksNumDataCodewords; i++) { - for (var j = 0; j < numResultBlocks; j++) { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - // Fill out the last data block in the longer ones - for (var j = longerBlocksStartAt; j < numResultBlocks; j++) { - result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; - } - // Now add in error correction blocks - var max = result[0].codewords.length; - for (var i = shorterBlocksNumDataCodewords; i < max; i++) { - for (var j = 0; j < numResultBlocks; j++) { - var iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - return result; - } - function correctErrors(codewordBytes, numDataCodewords) { - var rsDecoder = new reedsolomon_1.ReedSolomonDecoder(); - var numCodewords = codewordBytes.length; - // First read into an array of ints - var codewordsInts = new Array(numCodewords); - for (var i = 0; i < numCodewords; i++) { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - var numECCodewords = codewordBytes.length - numDataCodewords; - if (!rsDecoder.decode(codewordsInts, numECCodewords)) - return false; - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (var i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = codewordsInts[i]; - } - return true; - } - function decodeMatrix(matrix) { - var version = readVersion(matrix); - if (!version) { - return null; - } - var formatInfo = readFormatInformation(matrix); - if (!formatInfo) { - return null; - } - var ecLevel = formatInfo.errorCorrectionLevel; - // Read codewords - var codewords = readCodewords(matrix, version, formatInfo); - if (!codewords) { - return null; - } - // Separate into data blocks - var dataBlocks = getDataBlocks(codewords, version, ecLevel); - // Count total number of data bytes - var totalBytes = 0; - dataBlocks.forEach(function (dataBlock) { - totalBytes += dataBlock.numDataCodewords; - }); - var resultBytes = new Array(totalBytes); - var resultOffset = 0; - // Error-correct and copy data blocks together into a stream of bytes - for (var _i = 0, dataBlocks_1 = dataBlocks; _i < dataBlocks_1.length; _i++) { - var dataBlock = dataBlocks_1[_i]; - var codewordBytes = dataBlock.codewords; - var numDataCodewords = dataBlock.numDataCodewords; - if (!correctErrors(codewordBytes, numDataCodewords)) - return null; - for (var i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = codewordBytes[i]; - } - } - return decodeqrdata_1.decodeQRdata(resultBytes, version.versionNumber, ecLevel.name); - } - function decode(matrix) { - if (matrix == null) { - return null; - } - var result = decodeMatrix(matrix); - if (result) { - return result; - } - // Decoding didn't work, try mirroring the QR - matrix.mirror(); - return decodeMatrix(matrix); - } - exports.decode = decode; + "use strict"; + var bitmatrix_1 = __webpack_require__(2); + var decodeqrdata_1 = __webpack_require__(10); + var helpers_1 = __webpack_require__(6); + var reedsolomon_1 = __webpack_require__(12); + var version_1 = __webpack_require__(8); + var FORMAT_INFO_MASK_QR = 0x5412; + var FORMAT_INFO_DECODE_LOOKUP = [ + [0x5412, 0x00], + [0x5125, 0x01], + [0x5E7C, 0x02], + [0x5B4B, 0x03], + [0x45F9, 0x04], + [0x40CE, 0x05], + [0x4F97, 0x06], + [0x4AA0, 0x07], + [0x77C4, 0x08], + [0x72F3, 0x09], + [0x7DAA, 0x0A], + [0x789D, 0x0B], + [0x662F, 0x0C], + [0x6318, 0x0D], + [0x6C41, 0x0E], + [0x6976, 0x0F], + [0x1689, 0x10], + [0x13BE, 0x11], + [0x1CE7, 0x12], + [0x19D0, 0x13], + [0x0762, 0x14], + [0x0255, 0x15], + [0x0D0C, 0x16], + [0x083B, 0x17], + [0x355F, 0x18], + [0x3068, 0x19], + [0x3F31, 0x1A], + [0x3A06, 0x1B], + [0x24B4, 0x1C], + [0x2183, 0x1D], + [0x2EDA, 0x1E], + [0x2BED, 0x1F], + ]; + var DATA_MASKS = [ + function (i, j) { return ((i + j) & 0x01) === 0; }, + function (i, j) { return (i & 0x01) === 0; }, + function (i, j) { return j % 3 == 0; }, + function (i, j) { return (i + j) % 3 === 0; }, + function (i, j) { return (((i >> 1) + (j / 3)) & 0x01) === 0; }, + function (i, j) { return ((i * j) & 0x01) + ((i * j) % 3) === 0; }, + function (i, j) { return ((((i * j) & 0x01) + ((i * j) % 3)) & 0x01) === 0; }, + function (i, j) { return ((((i + j) & 0x01) + ((i * j) % 3)) & 0x01) === 0; }, + ]; + var ERROR_CORRECTION_LEVELS = [ + { ordinal: 1, bits: 0x00, name: "M" }, + { ordinal: 0, bits: 0x01, name: "L" }, + { ordinal: 3, bits: 0x02, name: "H" }, + { ordinal: 2, bits: 0x03, name: "Q" }, + ]; + function buildFunctionPattern(version) { + var dimension = version.getDimensionForVersion(); + var emptyArray = new Array(dimension * dimension); + for (var i = 0; i < emptyArray.length; i++) { + emptyArray[i] = false; + } + var bitMatrix = new bitmatrix_1.BitMatrix(emptyArray, dimension); + ///BitMatrix bitMatrix = new BitMatrix(dimension); + // Top left finder pattern + separator + format + bitMatrix.setRegion(0, 0, 9, 9); + // Top right finder pattern + separator + format + bitMatrix.setRegion(dimension - 8, 0, 8, 9); + // Bottom left finder pattern + separator + format + bitMatrix.setRegion(0, dimension - 8, 9, 8); + // Alignment patterns + var max = version.alignmentPatternCenters.length; + for (var x = 0; x < max; x++) { + var i = version.alignmentPatternCenters[x] - 2; + for (var y = 0; y < max; y++) { + if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) { + // No alignment patterns near the three finder paterns + continue; + } + bitMatrix.setRegion(version.alignmentPatternCenters[y] - 2, i, 5, 5); + } + } + // Vertical timing pattern + bitMatrix.setRegion(6, 9, 1, dimension - 17); + // Horizontal timing pattern + bitMatrix.setRegion(9, 6, dimension - 17, 1); + if (version.versionNumber > 6) { + // Version info, top right + bitMatrix.setRegion(dimension - 11, 0, 3, 6); + // Version info, bottom left + bitMatrix.setRegion(0, dimension - 11, 6, 3); + } + return bitMatrix; + } + function readCodewords(matrix, version, formatInfo) { + // Get the data mask for the format used in this QR Code. This will exclude + // some bits from reading as we wind through the bit matrix. + var dataMask = DATA_MASKS[formatInfo.dataMask]; + var dimension = matrix.height; + var funcPattern = buildFunctionPattern(version); + var readingUp = true; + var result = []; + var resultOffset = 0; + var currentByte = 0; + var bitsRead = 0; + // Read columns in pairs, from right to left + for (var j = dimension - 1; j > 0; j -= 2) { + if (j == 6) { + // Skip whole column with vertical alignment pattern; + // saves time and makes the other code proceed more cleanly + j--; + } + // Read alternatingly from bottom to top then top to bottom + for (var count = 0; count < dimension; count++) { + var i = readingUp ? dimension - 1 - count : count; + for (var col = 0; col < 2; col++) { + // Ignore bits covered by the function pattern + if (!funcPattern.get(j - col, i)) { + // Read a bit + bitsRead++; + currentByte <<= 1; + if (matrix.get(j - col, i) !== dataMask(i, j - col)) { + currentByte |= 1; + } + // If we've made a whole byte, save it off + if (bitsRead == 8) { + result[resultOffset++] = currentByte & 0xFF; + bitsRead = 0; + currentByte = 0; + } + } + } + } + readingUp = !readingUp; // switch directions + } + if (resultOffset != version.totalCodewords) { + return null; + } + return result; + } + function readVersion(matrix) { + var dimension = matrix.height; + var provisionalVersion = (dimension - 17) >> 2; + if (provisionalVersion <= 6) { + return version_1.getVersionForNumber(provisionalVersion); + } + // Read top-right version info: 3 wide by 6 tall + var versionBits = 0; + var ijMin = dimension - 11; + for (var j = 5; j >= 0; j--) { + for (var i = dimension - 9; i >= ijMin; i--) { + versionBits = matrix.copyBit(i, j, versionBits); + } + } + var parsedVersion = version_1.Version.decodeVersionInformation(versionBits); + if (parsedVersion != null && parsedVersion.getDimensionForVersion() == dimension) { + return parsedVersion; + } + // Hmm, failed. Try bottom left: 6 wide by 3 tall + versionBits = 0; + for (var i = 5; i >= 0; i--) { + for (var j = dimension - 9; j >= ijMin; j--) { + versionBits = matrix.copyBit(i, j, versionBits); + } + } + parsedVersion = version_1.Version.decodeVersionInformation(versionBits); + if (parsedVersion != null && parsedVersion.getDimensionForVersion() == dimension) { + return parsedVersion; + } + return null; + } + function newFormatInformation(formatInfo) { + return { + errorCorrectionLevel: ERROR_CORRECTION_LEVELS[(formatInfo >> 3) & 0x03], + dataMask: formatInfo & 0x07 + }; + } + function doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2) { + // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing + var bestDifference = Infinity; + var bestFormatInfo = 0; + for (var i = 0; i < FORMAT_INFO_DECODE_LOOKUP.length; i++) { + var decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i]; + var targetInfo = decodeInfo[0]; + if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2) { + // Found an exact match + return newFormatInformation(decodeInfo[1]); + } + var bitsDifference = helpers_1.numBitsDiffering(maskedFormatInfo1, targetInfo); + if (bitsDifference < bestDifference) { + bestFormatInfo = decodeInfo[1]; + bestDifference = bitsDifference; + } + if (maskedFormatInfo1 != maskedFormatInfo2) { + // also try the other option + bitsDifference = helpers_1.numBitsDiffering(maskedFormatInfo2, targetInfo); + if (bitsDifference < bestDifference) { + bestFormatInfo = decodeInfo[1]; + bestDifference = bitsDifference; + } + } + } + // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits + // differing means we found a match + if (bestDifference <= 3) + return newFormatInformation(bestFormatInfo); + return null; + } + function decodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2) { + var formatInfo = doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2); + if (formatInfo) { + return formatInfo; + } + // Should return null, but, some QR codes apparently + // do not mask this info. Try again by actually masking the pattern + // first + return doDecodeFormatInformation(maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR, maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR); + } + function readFormatInformation(matrix) { + // Read top-left format info bits + var formatInfoBits1 = 0; + for (var i = 0; i < 6; i++) { + formatInfoBits1 = matrix.copyBit(i, 8, formatInfoBits1); + } + // .. and skip a bit in the timing pattern ... + formatInfoBits1 = matrix.copyBit(7, 8, formatInfoBits1); + formatInfoBits1 = matrix.copyBit(8, 8, formatInfoBits1); + formatInfoBits1 = matrix.copyBit(8, 7, formatInfoBits1); + // .. and skip a bit in the timing pattern ... + for (var j = 5; j >= 0; j--) { + formatInfoBits1 = matrix.copyBit(8, j, formatInfoBits1); + } + // Read the top-right/bottom-left pattern too + var dimension = matrix.height; + var formatInfoBits2 = 0; + var jMin = dimension - 7; + for (var j = dimension - 1; j >= jMin; j--) { + formatInfoBits2 = matrix.copyBit(8, j, formatInfoBits2); + } + for (var i = dimension - 8; i < dimension; i++) { + formatInfoBits2 = matrix.copyBit(i, 8, formatInfoBits2); + } + // parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); + var parsedFormatInfo = decodeFormatInformation(formatInfoBits1, formatInfoBits2); + if (parsedFormatInfo != null) { + return parsedFormatInfo; + } + return null; + } + function getDataBlocks(rawCodewords, version, ecLevel) { + if (rawCodewords.length != version.totalCodewords) { + throw new Error("Invalid number of codewords for version; got " + rawCodewords.length + " expected " + version.totalCodewords); + } + // Figure out the number and size of data blocks used by this version and + // error correction level + var ecBlocks = version.getECBlocksForLevel(ecLevel); + // First count the total number of data blocks + var totalBlocks = 0; + var ecBlockArray = ecBlocks.ecBlocks; + ecBlockArray.forEach(function (ecBlock) { + totalBlocks += ecBlock.count; + }); + // Now establish DataBlocks of the appropriate size and number of data codewords + var result = new Array(totalBlocks); + var numResultBlocks = 0; + ecBlockArray.forEach(function (ecBlock) { + for (var i = 0; i < ecBlock.count; i++) { + var numDataCodewords = ecBlock.dataCodewords; + var numBlockCodewords = ecBlocks.ecCodewordsPerBlock + numDataCodewords; + result[numResultBlocks++] = { numDataCodewords: numDataCodewords, codewords: new Array(numBlockCodewords) }; + } + }); + // All blocks have the same amount of data, except that the last n + // (where n may be 0) have 1 more byte. Figure out where these start. + var shorterBlocksTotalCodewords = result[0].codewords.length; + var longerBlocksStartAt = result.length - 1; + while (longerBlocksStartAt >= 0) { + var numCodewords = result[longerBlocksStartAt].codewords.length; + if (numCodewords == shorterBlocksTotalCodewords) { + break; + } + longerBlocksStartAt--; + } + longerBlocksStartAt++; + var shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ecCodewordsPerBlock; + // The last elements of result may be 1 element longer; + // first fill out as many elements as all of them have + var rawCodewordsOffset = 0; + for (var i = 0; i < shorterBlocksNumDataCodewords; i++) { + for (var j = 0; j < numResultBlocks; j++) { + result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; + } + } + // Fill out the last data block in the longer ones + for (var j = longerBlocksStartAt; j < numResultBlocks; j++) { + result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; + } + // Now add in error correction blocks + var max = result[0].codewords.length; + for (var i = shorterBlocksNumDataCodewords; i < max; i++) { + for (var j = 0; j < numResultBlocks; j++) { + var iOffset = j < longerBlocksStartAt ? i : i + 1; + result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; + } + } + return result; + } + function correctErrors(codewordBytes, numDataCodewords) { + var rsDecoder = new reedsolomon_1.ReedSolomonDecoder(); + var numCodewords = codewordBytes.length; + // First read into an array of ints + var codewordsInts = new Array(numCodewords); + for (var i = 0; i < numCodewords; i++) { + codewordsInts[i] = codewordBytes[i] & 0xFF; + } + var numECCodewords = codewordBytes.length - numDataCodewords; + if (!rsDecoder.decode(codewordsInts, numECCodewords)) + return false; + // Copy back into array of bytes -- only need to worry about the bytes that were data + // We don't care about errors in the error-correction codewords + for (var i = 0; i < numDataCodewords; i++) { + codewordBytes[i] = codewordsInts[i]; + } + return true; + } + function decodeMatrix(matrix) { + var version = readVersion(matrix); + if (!version) { + return null; + } + var formatInfo = readFormatInformation(matrix); + if (!formatInfo) { + return null; + } + var ecLevel = formatInfo.errorCorrectionLevel; + // Read codewords + var codewords = readCodewords(matrix, version, formatInfo); + if (!codewords) { + return null; + } + // Separate into data blocks + var dataBlocks = getDataBlocks(codewords, version, ecLevel); + // Count total number of data bytes + var totalBytes = 0; + dataBlocks.forEach(function (dataBlock) { + totalBytes += dataBlock.numDataCodewords; + }); + var resultBytes = new Array(totalBytes); + var resultOffset = 0; + // Error-correct and copy data blocks together into a stream of bytes + for (var _i = 0, dataBlocks_1 = dataBlocks; _i < dataBlocks_1.length; _i++) { + var dataBlock = dataBlocks_1[_i]; + var codewordBytes = dataBlock.codewords; + var numDataCodewords = dataBlock.numDataCodewords; + if (!correctErrors(codewordBytes, numDataCodewords)) + return null; + for (var i = 0; i < numDataCodewords; i++) { + resultBytes[resultOffset++] = codewordBytes[i]; + } + } + return decodeqrdata_1.decodeQRdata(resultBytes, version.versionNumber, ecLevel.name); + } + function decode(matrix) { + if (matrix == null) { + return null; + } + var result = decodeMatrix(matrix); + if (result) { + return result; + } + // Decoding didn't work, try mirroring the QR + matrix.mirror(); + return decodeMatrix(matrix); + } + exports.decode = decode; /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; - var bitstream_1 = __webpack_require__(11); - function toAlphaNumericByte(value) { - var ALPHANUMERIC_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - ' ', '$', '%', '*', '+', '-', '.', '/', ':']; - if (value >= ALPHANUMERIC_CHARS.length) { - throw new Error("Could not decode alphanumeric char"); - } - return ALPHANUMERIC_CHARS[value].charCodeAt(0); - } - var Mode = (function () { - function Mode(characterCountBitsForVersions, bits) { - this.characterCountBitsForVersions = characterCountBitsForVersions; - this.bits = bits; - } - Mode.prototype.getCharacterCountBits = function (version) { - if (this.characterCountBitsForVersions == null) { - throw new Error("Character count doesn't apply to this mode"); - } - var offset; - if (version <= 9) { - offset = 0; - } - else if (version <= 26) { - offset = 1; - } - else { - offset = 2; - } - return this.characterCountBitsForVersions[offset]; - }; - return Mode; - }()); - var TERMINATOR_MODE = new Mode([0, 0, 0], 0x00); // Not really a mod... - var NUMERIC_MODE = new Mode([10, 12, 14], 0x01); - var ALPHANUMERIC_MODE = new Mode([9, 11, 13], 0x02); - var STRUCTURED_APPEND_MODE = new Mode([0, 0, 0], 0x03); // Not supported - var BYTE_MODE = new Mode([8, 16, 16], 0x04); - var ECI_MODE = new Mode(null, 0x07); // character counts don't apply - var KANJI_MODE = new Mode([8, 10, 12], 0x08); - var FNC1_FIRST_POSITION_MODE = new Mode(null, 0x05); - var FNC1_SECOND_POSITION_MODE = new Mode(null, 0x09); - var HANZI_MODE = new Mode([8, 10, 12], 0x0D); - function modeForBits(bits) { - switch (bits) { - case 0x0: - return TERMINATOR_MODE; - case 0x1: - return NUMERIC_MODE; - case 0x2: - return ALPHANUMERIC_MODE; - case 0x3: - return STRUCTURED_APPEND_MODE; - case 0x4: - return BYTE_MODE; - case 0x5: - return FNC1_FIRST_POSITION_MODE; - case 0x7: - return ECI_MODE; - case 0x8: - return KANJI_MODE; - case 0x9: - return FNC1_SECOND_POSITION_MODE; - case 0xD: - // 0xD is defined in GBT 18284-2000, may not be supported in foreign country - return HANZI_MODE; - default: - throw new Error("Couldn't decode mode from byte array"); - } - } - function parseECIValue(bits) { - var firstByte = bits.readBits(8); - if ((firstByte & 0x80) == 0) { - // just one byte - return firstByte & 0x7F; - } - if ((firstByte & 0xC0) == 0x80) { - // two bytes - var secondByte = bits.readBits(8); - return ((firstByte & 0x3F) << 8) | secondByte; - } - if ((firstByte & 0xE0) == 0xC0) { - // three bytes - var secondThirdBytes = bits.readBits(16); - return ((firstByte & 0x1F) << 16) | secondThirdBytes; - } - throw new Error("Bad ECI bits starting with byte " + firstByte); - } - function decodeHanziSegment(bits, result, count) { - // Don't crash trying to read more bits than we have available. - if (count * 13 > bits.available()) { - return false; - } - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as GB2312 afterwards - var buffer = new Array(2 * count); - var offset = 0; - while (count > 0) { - // Each 13 bits encodes a 2-byte character - var twoBytes = bits.readBits(13); - var assembledTwoBytes = (Math.floor(twoBytes / 0x060) << 8) | (twoBytes % 0x060); - if (assembledTwoBytes < 0x003BF) { - // In the 0xA1A1 to 0xAAFE range - assembledTwoBytes += 0x0A1A1; - } - else { - // In the 0xB0A1 to 0xFAFE range - assembledTwoBytes += 0x0A6A1; - } - buffer[offset] = ((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (assembledTwoBytes & 0xFF); - offset += 2; - count--; - } - result.val = buffer; - return true; - } - function decodeNumericSegment(bits, result, count) { - // Read three digits at a time - while (count >= 3) { - // Each 10 bits encodes three digits - if (bits.available() < 10) { - return false; - } - var threeDigitsBits = bits.readBits(10); - if (threeDigitsBits >= 1000) { - return false; - } - result.val.push(toAlphaNumericByte(Math.floor(threeDigitsBits / 100))); - result.val.push(toAlphaNumericByte(Math.floor(threeDigitsBits / 10) % 10)); - result.val.push(toAlphaNumericByte(threeDigitsBits % 10)); - count -= 3; - } - if (count == 2) { - // Two digits left over to read, encoded in 7 bits - if (bits.available() < 7) { - return false; - } - var twoDigitsBits = bits.readBits(7); - if (twoDigitsBits >= 100) { - return false; - } - result.val.push(toAlphaNumericByte(Math.floor(twoDigitsBits / 10))); - result.val.push(toAlphaNumericByte(twoDigitsBits % 10)); - } - else if (count == 1) { - // One digit left over to read - if (bits.available() < 4) { - return false; - } - var digitBits = bits.readBits(4); - if (digitBits >= 10) { - return false; - } - result.val.push(toAlphaNumericByte(digitBits)); - } - return true; - } - function decodeAlphanumericSegment(bits, result, count, fc1InEffect) { - // Read two characters at a time - var start = result.val.length; - while (count > 1) { - if (bits.available() < 11) { - return false; - } - var nextTwoCharsBits = bits.readBits(11); - result.val.push(toAlphaNumericByte(Math.floor(nextTwoCharsBits / 45))); - result.val.push(toAlphaNumericByte(nextTwoCharsBits % 45)); - count -= 2; - } - if (count == 1) { - // special case: one character left - if (bits.available() < 6) { - return false; - } - result.val.push(toAlphaNumericByte(bits.readBits(6))); - } - // See section 6.4.8.1, 6.4.8.2 - if (fc1InEffect) { - // We need to massage the result a bit if in an FNC1 mode: - for (var i = start; i < result.val.length; i++) { - if (result.val[i] == '%'.charCodeAt(0)) { - if (i < result.val.length - 1 && result.val[i + 1] == '%'.charCodeAt(0)) { - // %% is rendered as % - result.val = result.val.slice(0, i + 1).concat(result.val.slice(i + 2)); - } - else { - // In alpha mode, % should be converted to FNC1 separator 0x1D - // THIS IS ALMOST CERTAINLY INVALID - result.val[i] = 0x1D; - } - } - } - } - return true; - } - function decodeByteSegment(bits, result, count) { - // Don't crash trying to read more bits than we have available. - if (count << 3 > bits.available()) { - return false; - } - var readBytes = new Array(count); - for (var i = 0; i < count; i++) { - readBytes[i] = bits.readBits(8); - } - Array.prototype.push.apply(result.val, readBytes); - return true; - } - var GB2312_SUBSET = 1; - // Takes in a byte array, a qr version number and an error correction level. - // Returns decoded data. - function decodeQRdata(data, version, ecl) { - var symbolSequence = -1; - var parityData = -1; - var bits = new bitstream_1.BitStream(data); - var result = { val: [] }; // Have to pass this around so functions can share a reference to a number[] - var fc1InEffect = false; - var mode; - while (mode != TERMINATOR_MODE) { - // While still another segment to read... - if (bits.available() < 4) { - // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here - mode = TERMINATOR_MODE; - } - else { - mode = modeForBits(bits.readBits(4)); // mode is encoded by 4 bits - } - if (mode != TERMINATOR_MODE) { - if (mode == FNC1_FIRST_POSITION_MODE || mode == FNC1_SECOND_POSITION_MODE) { - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1InEffect = true; - } - else if (mode == STRUCTURED_APPEND_MODE) { - if (bits.available() < 16) { - return null; - } - // not really supported; but sequence number and parity is added later to the result metadata - // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue - symbolSequence = bits.readBits(8); - parityData = bits.readBits(8); - } - else if (mode == ECI_MODE) { - // Ignore since we don't do character encoding in JS - var value = parseECIValue(bits); - if (value < 0 || value > 30) { - return null; - } - } - else { - // First handle Hanzi mode which does not start with character count - if (mode == HANZI_MODE) { - //chinese mode contains a sub set indicator right after mode indicator - var subset = bits.readBits(4); - var countHanzi = bits.readBits(mode.getCharacterCountBits(version)); - if (subset == GB2312_SUBSET) { - if (!decodeHanziSegment(bits, result, countHanzi)) { - return null; - } - } - } - else { - // "Normal" QR code modes: - // How many characters will follow, encoded in this mode? - var count = bits.readBits(mode.getCharacterCountBits(version)); - if (mode == NUMERIC_MODE) { - if (!decodeNumericSegment(bits, result, count)) { - return null; - } - } - else if (mode == ALPHANUMERIC_MODE) { - if (!decodeAlphanumericSegment(bits, result, count, fc1InEffect)) { - return null; - } - } - else if (mode == BYTE_MODE) { - if (!decodeByteSegment(bits, result, count)) { - return null; - } - } - else if (mode == KANJI_MODE) { - } - else { - return null; - } - } - } - } - } - return result.val; - } - exports.decodeQRdata = decodeQRdata; + "use strict"; + var bitstream_1 = __webpack_require__(11); + function toAlphaNumericByte(value) { + var ALPHANUMERIC_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + ' ', '$', '%', '*', '+', '-', '.', '/', ':']; + if (value >= ALPHANUMERIC_CHARS.length) { + throw new Error("Could not decode alphanumeric char"); + } + return ALPHANUMERIC_CHARS[value].charCodeAt(0); + } + var Mode = (function () { + function Mode(characterCountBitsForVersions, bits) { + this.characterCountBitsForVersions = characterCountBitsForVersions; + this.bits = bits; + } + Mode.prototype.getCharacterCountBits = function (version) { + if (this.characterCountBitsForVersions == null) { + throw new Error("Character count doesn't apply to this mode"); + } + var offset; + if (version <= 9) { + offset = 0; + } + else if (version <= 26) { + offset = 1; + } + else { + offset = 2; + } + return this.characterCountBitsForVersions[offset]; + }; + return Mode; + }()); + var TERMINATOR_MODE = new Mode([0, 0, 0], 0x00); // Not really a mod... + var NUMERIC_MODE = new Mode([10, 12, 14], 0x01); + var ALPHANUMERIC_MODE = new Mode([9, 11, 13], 0x02); + var STRUCTURED_APPEND_MODE = new Mode([0, 0, 0], 0x03); // Not supported + var BYTE_MODE = new Mode([8, 16, 16], 0x04); + var ECI_MODE = new Mode(null, 0x07); // character counts don't apply + var KANJI_MODE = new Mode([8, 10, 12], 0x08); + var FNC1_FIRST_POSITION_MODE = new Mode(null, 0x05); + var FNC1_SECOND_POSITION_MODE = new Mode(null, 0x09); + var HANZI_MODE = new Mode([8, 10, 12], 0x0D); + function modeForBits(bits) { + switch (bits) { + case 0x0: + return TERMINATOR_MODE; + case 0x1: + return NUMERIC_MODE; + case 0x2: + return ALPHANUMERIC_MODE; + case 0x3: + return STRUCTURED_APPEND_MODE; + case 0x4: + return BYTE_MODE; + case 0x5: + return FNC1_FIRST_POSITION_MODE; + case 0x7: + return ECI_MODE; + case 0x8: + return KANJI_MODE; + case 0x9: + return FNC1_SECOND_POSITION_MODE; + case 0xD: + // 0xD is defined in GBT 18284-2000, may not be supported in foreign country + return HANZI_MODE; + default: + throw new Error("Couldn't decode mode from byte array"); + } + } + function parseECIValue(bits) { + var firstByte = bits.readBits(8); + if ((firstByte & 0x80) == 0) { + // just one byte + return firstByte & 0x7F; + } + if ((firstByte & 0xC0) == 0x80) { + // two bytes + var secondByte = bits.readBits(8); + return ((firstByte & 0x3F) << 8) | secondByte; + } + if ((firstByte & 0xE0) == 0xC0) { + // three bytes + var secondThirdBytes = bits.readBits(16); + return ((firstByte & 0x1F) << 16) | secondThirdBytes; + } + throw new Error("Bad ECI bits starting with byte " + firstByte); + } + function decodeHanziSegment(bits, result, count) { + // Don't crash trying to read more bits than we have available. + if (count * 13 > bits.available()) { + return false; + } + // Each character will require 2 bytes. Read the characters as 2-byte pairs + // and decode as GB2312 afterwards + var buffer = new Array(2 * count); + var offset = 0; + while (count > 0) { + // Each 13 bits encodes a 2-byte character + var twoBytes = bits.readBits(13); + var assembledTwoBytes = (Math.floor(twoBytes / 0x060) << 8) | (twoBytes % 0x060); + if (assembledTwoBytes < 0x003BF) { + // In the 0xA1A1 to 0xAAFE range + assembledTwoBytes += 0x0A1A1; + } + else { + // In the 0xB0A1 to 0xFAFE range + assembledTwoBytes += 0x0A6A1; + } + buffer[offset] = ((assembledTwoBytes >> 8) & 0xFF); + buffer[offset + 1] = (assembledTwoBytes & 0xFF); + offset += 2; + count--; + } + result.val = buffer; + return true; + } + function decodeNumericSegment(bits, result, count) { + // Read three digits at a time + while (count >= 3) { + // Each 10 bits encodes three digits + if (bits.available() < 10) { + return false; + } + var threeDigitsBits = bits.readBits(10); + if (threeDigitsBits >= 1000) { + return false; + } + result.val.push(toAlphaNumericByte(Math.floor(threeDigitsBits / 100))); + result.val.push(toAlphaNumericByte(Math.floor(threeDigitsBits / 10) % 10)); + result.val.push(toAlphaNumericByte(threeDigitsBits % 10)); + count -= 3; + } + if (count == 2) { + // Two digits left over to read, encoded in 7 bits + if (bits.available() < 7) { + return false; + } + var twoDigitsBits = bits.readBits(7); + if (twoDigitsBits >= 100) { + return false; + } + result.val.push(toAlphaNumericByte(Math.floor(twoDigitsBits / 10))); + result.val.push(toAlphaNumericByte(twoDigitsBits % 10)); + } + else if (count == 1) { + // One digit left over to read + if (bits.available() < 4) { + return false; + } + var digitBits = bits.readBits(4); + if (digitBits >= 10) { + return false; + } + result.val.push(toAlphaNumericByte(digitBits)); + } + return true; + } + function decodeAlphanumericSegment(bits, result, count, fc1InEffect) { + // Read two characters at a time + var start = result.val.length; + while (count > 1) { + if (bits.available() < 11) { + return false; + } + var nextTwoCharsBits = bits.readBits(11); + result.val.push(toAlphaNumericByte(Math.floor(nextTwoCharsBits / 45))); + result.val.push(toAlphaNumericByte(nextTwoCharsBits % 45)); + count -= 2; + } + if (count == 1) { + // special case: one character left + if (bits.available() < 6) { + return false; + } + result.val.push(toAlphaNumericByte(bits.readBits(6))); + } + // See section 6.4.8.1, 6.4.8.2 + if (fc1InEffect) { + // We need to massage the result a bit if in an FNC1 mode: + for (var i = start; i < result.val.length; i++) { + if (result.val[i] == '%'.charCodeAt(0)) { + if (i < result.val.length - 1 && result.val[i + 1] == '%'.charCodeAt(0)) { + // %% is rendered as % + result.val = result.val.slice(0, i + 1).concat(result.val.slice(i + 2)); + } + else { + // In alpha mode, % should be converted to FNC1 separator 0x1D + // THIS IS ALMOST CERTAINLY INVALID + result.val[i] = 0x1D; + } + } + } + } + return true; + } + function decodeByteSegment(bits, result, count) { + // Don't crash trying to read more bits than we have available. + if (count << 3 > bits.available()) { + return false; + } + var readBytes = new Array(count); + for (var i = 0; i < count; i++) { + readBytes[i] = bits.readBits(8); + } + Array.prototype.push.apply(result.val, readBytes); + return true; + } + var GB2312_SUBSET = 1; + // Takes in a byte array, a qr version number and an error correction level. + // Returns decoded data. + function decodeQRdata(data, version, ecl) { + var symbolSequence = -1; + var parityData = -1; + var bits = new bitstream_1.BitStream(data); + var result = { val: [] }; // Have to pass this around so functions can share a reference to a number[] + var fc1InEffect = false; + var mode; + while (mode != TERMINATOR_MODE) { + // While still another segment to read... + if (bits.available() < 4) { + // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here + mode = TERMINATOR_MODE; + } + else { + mode = modeForBits(bits.readBits(4)); // mode is encoded by 4 bits + } + if (mode != TERMINATOR_MODE) { + if (mode == FNC1_FIRST_POSITION_MODE || mode == FNC1_SECOND_POSITION_MODE) { + // We do little with FNC1 except alter the parsed result a bit according to the spec + fc1InEffect = true; + } + else if (mode == STRUCTURED_APPEND_MODE) { + if (bits.available() < 16) { + return null; + } + // not really supported; but sequence number and parity is added later to the result metadata + // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue + symbolSequence = bits.readBits(8); + parityData = bits.readBits(8); + } + else if (mode == ECI_MODE) { + // Ignore since we don't do character encoding in JS + var value = parseECIValue(bits); + if (value < 0 || value > 30) { + return null; + } + } + else { + // First handle Hanzi mode which does not start with character count + if (mode == HANZI_MODE) { + //chinese mode contains a sub set indicator right after mode indicator + var subset = bits.readBits(4); + var countHanzi = bits.readBits(mode.getCharacterCountBits(version)); + if (subset == GB2312_SUBSET) { + if (!decodeHanziSegment(bits, result, countHanzi)) { + return null; + } + } + } + else { + // "Normal" QR code modes: + // How many characters will follow, encoded in this mode? + var count = bits.readBits(mode.getCharacterCountBits(version)); + if (mode == NUMERIC_MODE) { + if (!decodeNumericSegment(bits, result, count)) { + return null; + } + } + else if (mode == ALPHANUMERIC_MODE) { + if (!decodeAlphanumericSegment(bits, result, count, fc1InEffect)) { + return null; + } + } + else if (mode == BYTE_MODE) { + if (!decodeByteSegment(bits, result, count)) { + return null; + } + } + else if (mode == KANJI_MODE) { + } + else { + return null; + } + } + } + } + } + return result.val; + } + exports.decodeQRdata = decodeQRdata; /***/ }, /* 11 */ /***/ function(module, exports) { - "use strict"; - var BitStream = (function () { - function BitStream(bytes) { - this.byteOffset = 0; - this.bitOffset = 0; - this.bytes = bytes; - } - BitStream.prototype.readBits = function (numBits) { - if (numBits < 1 || numBits > 32 || numBits > this.available()) { - throw new Error("Cannot read " + numBits.toString() + " bits"); - } - var result = 0; - // First, read remainder from current byte - if (this.bitOffset > 0) { - var bitsLeft = 8 - this.bitOffset; - var toRead = numBits < bitsLeft ? numBits : bitsLeft; - var bitsToNotRead = bitsLeft - toRead; - var mask = (0xFF >> (8 - toRead)) << bitsToNotRead; - result = (this.bytes[this.byteOffset] & mask) >> bitsToNotRead; - numBits -= toRead; - this.bitOffset += toRead; - if (this.bitOffset == 8) { - this.bitOffset = 0; - this.byteOffset++; - } - } - // Next read whole bytes - if (numBits > 0) { - while (numBits >= 8) { - result = (result << 8) | (this.bytes[this.byteOffset] & 0xFF); - this.byteOffset++; - numBits -= 8; - } - // Finally read a partial byte - if (numBits > 0) { - var bitsToNotRead = 8 - numBits; - var mask = (0xFF >> bitsToNotRead) << bitsToNotRead; - result = (result << numBits) | ((this.bytes[this.byteOffset] & mask) >> bitsToNotRead); - this.bitOffset += numBits; - } - } - return result; - }; - BitStream.prototype.available = function () { - return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset; - }; - return BitStream; - }()); - exports.BitStream = BitStream; + "use strict"; + var BitStream = (function () { + function BitStream(bytes) { + this.byteOffset = 0; + this.bitOffset = 0; + this.bytes = bytes; + } + BitStream.prototype.readBits = function (numBits) { + if (numBits < 1 || numBits > 32 || numBits > this.available()) { + throw new Error("Cannot read " + numBits.toString() + " bits"); + } + var result = 0; + // First, read remainder from current byte + if (this.bitOffset > 0) { + var bitsLeft = 8 - this.bitOffset; + var toRead = numBits < bitsLeft ? numBits : bitsLeft; + var bitsToNotRead = bitsLeft - toRead; + var mask = (0xFF >> (8 - toRead)) << bitsToNotRead; + result = (this.bytes[this.byteOffset] & mask) >> bitsToNotRead; + numBits -= toRead; + this.bitOffset += toRead; + if (this.bitOffset == 8) { + this.bitOffset = 0; + this.byteOffset++; + } + } + // Next read whole bytes + if (numBits > 0) { + while (numBits >= 8) { + result = (result << 8) | (this.bytes[this.byteOffset] & 0xFF); + this.byteOffset++; + numBits -= 8; + } + // Finally read a partial byte + if (numBits > 0) { + var bitsToNotRead = 8 - numBits; + var mask = (0xFF >> bitsToNotRead) << bitsToNotRead; + result = (result << numBits) | ((this.bytes[this.byteOffset] & mask) >> bitsToNotRead); + this.bitOffset += numBits; + } + } + return result; + }; + BitStream.prototype.available = function () { + return 8 * (this.bytes.length - this.byteOffset) - this.bitOffset; + }; + return BitStream; + }()); + exports.BitStream = BitStream; /***/ }, /* 12 */ /***/ function(module, exports) { - "use strict"; - var ReedSolomonDecoder = (function () { - function ReedSolomonDecoder() { - this.field = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1 - } - ReedSolomonDecoder.prototype.decode = function (received, twoS) { - var poly = new GenericGFPoly(this.field, received); - var syndromeCoefficients = new Array(twoS); - var noError = true; - for (var i = 0; i < twoS; i++) { - var evaluation = poly.evaluateAt(this.field.exp(i + this.field.generatorBase)); - syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evaluation; - if (evaluation != 0) { - noError = false; - } - } - if (noError) { - return true; - } - var syndrome = new GenericGFPoly(this.field, syndromeCoefficients); - var sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS); - if (sigmaOmega == null) - return false; - var sigma = sigmaOmega[0]; - var errorLocations = this.findErrorLocations(sigma); - if (errorLocations == null) - return false; - var omega = sigmaOmega[1]; - var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations); - for (var i = 0; i < errorLocations.length; i++) { - var position = received.length - 1 - this.field.log(errorLocations[i]); - if (position < 0) { - // throw new ReedSolomonException("Bad error location"); - return false; - } - received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]); - } - return true; - }; - ReedSolomonDecoder.prototype.runEuclideanAlgorithm = function (a, b, R) { - // Assume a's degree is >= b's - if (a.degree() < b.degree()) { - var temp = a; - a = b; - b = temp; - } - var rLast = a; - var r = b; - var tLast = this.field.zero; - var t = this.field.one; - // Run Euclidean algorithm until r's degree is less than R/2 - while (r.degree() >= R / 2) { - var rLastLast = rLast; - var tLastLast = tLast; - rLast = r; - tLast = t; - // Divide rLastLast by rLast, with quotient in q and remainder in r - if (rLast.isZero()) { - // Oops, Euclidean algorithm already terminated? - // throw new ReedSolomonException("r_{i-1} was zero"); - return null; - } - r = rLastLast; - var q = this.field.zero; - var denominatorLeadingTerm = rLast.getCoefficient(rLast.degree()); - var dltInverse = this.field.inverse(denominatorLeadingTerm); - while (r.degree() >= rLast.degree() && !r.isZero()) { - var degreeDiff = r.degree() - rLast.degree(); - var scale = this.field.multiply(r.getCoefficient(r.degree()), dltInverse); - q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale)); - r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale)); - } - t = q.multiplyPoly(tLast).addOrSubtract(tLastLast); - if (r.degree() >= rLast.degree()) { - // throw new IllegalStateException("Division algorithm failed to reduce polynomial?"); - return null; - } - } - var sigmaTildeAtZero = t.getCoefficient(0); - if (sigmaTildeAtZero == 0) { - // throw new ReedSolomonException("sigmaTilde(0) was zero"); - return null; - } - var inverse = this.field.inverse(sigmaTildeAtZero); - var sigma = t.multiply(inverse); - var omega = r.multiply(inverse); - return [sigma, omega]; - }; - ReedSolomonDecoder.prototype.findErrorLocations = function (errorLocator) { - // This is a direct application of Chien's search - var numErrors = errorLocator.degree(); - if (numErrors == 1) { - // shortcut - return [errorLocator.getCoefficient(1)]; - } - var result = new Array(numErrors); - var e = 0; - for (var i = 1; i < this.field.size && e < numErrors; i++) { - if (errorLocator.evaluateAt(i) == 0) { - result[e] = this.field.inverse(i); - e++; - } - } - if (e != numErrors) { - // throw new ReedSolomonException("Error locator degree does not match number of roots"); - return null; - } - return result; - }; - ReedSolomonDecoder.prototype.findErrorMagnitudes = function (errorEvaluator, errorLocations) { - // This is directly applying Forney's Formula - var s = errorLocations.length; - var result = new Array(s); - for (var i = 0; i < s; i++) { - var xiInverse = this.field.inverse(errorLocations[i]); - var denominator = 1; - for (var j = 0; j < s; j++) { - if (i != j) { - //denominator = field.multiply(denominator, - // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); - // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. - // Below is a funny-looking workaround from Steven Parkes - var term = this.field.multiply(errorLocations[j], xiInverse); - var termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1; - denominator = this.field.multiply(denominator, termPlus1); - } - } - result[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator)); - if (this.field.generatorBase != 0) { - result[i] = this.field.multiply(result[i], xiInverse); - } - } - return result; - }; - return ReedSolomonDecoder; - }()); - exports.ReedSolomonDecoder = ReedSolomonDecoder; - var GenericGFPoly = (function () { - function GenericGFPoly(field, coefficients) { - if (coefficients.length == 0) { - throw new Error("No coefficients."); - } - this.field = field; - var coefficientsLength = coefficients.length; - if (coefficientsLength > 1 && coefficients[0] == 0) { - // Leading term must be non-zero for anything except the constant polynomial "0" - var firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - this.coefficients = field.zero.coefficients; - } - else { - this.coefficients = new Array(coefficientsLength - firstNonZero); - /*Array.Copy(coefficients, // Source array - firstNonZero, // Source index - this.coefficients, // Destination array - 0, // Destination index - this.coefficients.length); // length*/ - for (var i = 0; i < this.coefficients.length; i++) { - this.coefficients[i] = coefficients[firstNonZero + i]; - } - } - } - else { - this.coefficients = coefficients; - } - } - GenericGFPoly.prototype.evaluateAt = function (a) { - var result = 0; - if (a == 0) { - // Just return the x^0 coefficient - return this.getCoefficient(0); - } - var size = this.coefficients.length; - if (a == 1) { - // Just the sum of the coefficients - this.coefficients.forEach(function (coefficient) { - result = GenericGF.addOrSubtract(result, coefficient); - }); - return result; - } - result = this.coefficients[0]; - for (var i = 1; i < size; i++) { - result = GenericGF.addOrSubtract(this.field.multiply(a, result), this.coefficients[i]); - } - return result; - }; - GenericGFPoly.prototype.getCoefficient = function (degree) { - return this.coefficients[this.coefficients.length - 1 - degree]; - }; - GenericGFPoly.prototype.degree = function () { - return this.coefficients.length - 1; - }; - GenericGFPoly.prototype.isZero = function () { - return this.coefficients[0] == 0; - }; - GenericGFPoly.prototype.addOrSubtract = function (other) { - /* TODO, fix this. - if (!this.field.Equals(other.field)) - { - throw new Error("GenericGFPolys do not have same GenericGF field"); - }*/ - if (this.isZero()) { - return other; - } - if (other.isZero()) { - return this; - } - var smallerCoefficients = this.coefficients; - var largerCoefficients = other.coefficients; - if (smallerCoefficients.length > largerCoefficients.length) { - var temp = smallerCoefficients; - smallerCoefficients = largerCoefficients; - largerCoefficients = temp; - } - var sumDiff = new Array(largerCoefficients.length); - var lengthDiff = largerCoefficients.length - smallerCoefficients.length; - // Copy high-order terms only found in higher-degree polynomial's coefficients - ///Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff); - for (var i = 0; i < lengthDiff; i++) { - sumDiff[i] = largerCoefficients[i]; - } - for (var i = lengthDiff; i < largerCoefficients.length; i++) { - sumDiff[i] = GenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); - } - return new GenericGFPoly(this.field, sumDiff); - }; - GenericGFPoly.prototype.multiply = function (scalar) { - if (scalar == 0) { - return this.field.zero; - } - if (scalar == 1) { - return this; - } - var size = this.coefficients.length; - var product = new Array(size); - for (var i = 0; i < size; i++) { - product[i] = this.field.multiply(this.coefficients[i], scalar); - } - return new GenericGFPoly(this.field, product); - }; - GenericGFPoly.prototype.multiplyPoly = function (other) { - /* TODO Fix this. - if (!field.Equals(other.field)) - { - throw new Error("GenericGFPolys do not have same GenericGF field"); - }*/ - if (this.isZero() || other.isZero()) { - return this.field.zero; - } - var aCoefficients = this.coefficients; - var aLength = aCoefficients.length; - var bCoefficients = other.coefficients; - var bLength = bCoefficients.length; - var product = new Array(aLength + bLength - 1); - for (var i = 0; i < aLength; i++) { - var aCoeff = aCoefficients[i]; - for (var j = 0; j < bLength; j++) { - product[i + j] = GenericGF.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j])); - } - } - return new GenericGFPoly(this.field, product); - }; - GenericGFPoly.prototype.multiplyByMonomial = function (degree, coefficient) { - if (degree < 0) { - throw new Error("Invalid degree less than 0"); - } - if (coefficient == 0) { - return this.field.zero; - } - var size = this.coefficients.length; - var product = new Array(size + degree); - for (var i = 0; i < size; i++) { - product[i] = this.field.multiply(this.coefficients[i], coefficient); - } - return new GenericGFPoly(this.field, product); - }; - return GenericGFPoly; - }()); - var GenericGF = (function () { - function GenericGF(primitive, size, genBase) { - // ok. - this.INITIALIZATION_THRESHOLD = 0; - this.initialized = false; - this.primitive = primitive; - this.size = size; - this.generatorBase = genBase; - if (size <= this.INITIALIZATION_THRESHOLD) { - this.initialize(); - } - } - GenericGF.prototype.initialize = function () { - this.expTable = new Array(this.size); - this.logTable = new Array(this.size); - var x = 1; - for (var i = 0; i < this.size; i++) { - this.expTable[i] = x; - x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 - if (x >= this.size) { - x ^= this.primitive; - x &= this.size - 1; - } - } - for (var i = 0; i < this.size - 1; i++) { - this.logTable[this.expTable[i]] = i; - } - // logTable[0] == 0 but this should never be used - this.zero = new GenericGFPoly(this, [0]); - this.one = new GenericGFPoly(this, [1]); - this.initialized = true; - }; - GenericGF.addOrSubtract = function (a, b) { - return a ^ b; - }; - GenericGF.prototype.checkInit = function () { - if (!this.initialized) - this.initialize(); - }; - GenericGF.prototype.multiply = function (a, b) { - this.checkInit(); - if (a == 0 || b == 0) { - return 0; - } - return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)]; - }; - GenericGF.prototype.exp = function (a) { - this.checkInit(); - return this.expTable[a]; - }; - GenericGF.prototype.log = function (a) { - this.checkInit(); - if (a == 0) { - throw new Error("Can't take log(0)"); - } - return this.logTable[a]; - }; - GenericGF.prototype.inverse = function (a) { - this.checkInit(); - if (a == 0) { - throw new Error("Can't invert 0"); - } - return this.expTable[this.size - this.logTable[a] - 1]; - }; - GenericGF.prototype.buildMonomial = function (degree, coefficient) { - this.checkInit(); - if (degree < 0) { - throw new Error("Invalid monomial degree less than 0"); - } - if (coefficient == 0) { - return this.zero; - } - var coefficients = new Array(degree + 1); - coefficients[0] = coefficient; - return new GenericGFPoly(this, coefficients); - }; - return GenericGF; - }()); + "use strict"; + var ReedSolomonDecoder = (function () { + function ReedSolomonDecoder() { + this.field = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1 + } + ReedSolomonDecoder.prototype.decode = function (received, twoS) { + var poly = new GenericGFPoly(this.field, received); + var syndromeCoefficients = new Array(twoS); + var noError = true; + for (var i = 0; i < twoS; i++) { + var evaluation = poly.evaluateAt(this.field.exp(i + this.field.generatorBase)); + syndromeCoefficients[syndromeCoefficients.length - 1 - i] = evaluation; + if (evaluation != 0) { + noError = false; + } + } + if (noError) { + return true; + } + var syndrome = new GenericGFPoly(this.field, syndromeCoefficients); + var sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS); + if (sigmaOmega == null) + return false; + var sigma = sigmaOmega[0]; + var errorLocations = this.findErrorLocations(sigma); + if (errorLocations == null) + return false; + var omega = sigmaOmega[1]; + var errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations); + for (var i = 0; i < errorLocations.length; i++) { + var position = received.length - 1 - this.field.log(errorLocations[i]); + if (position < 0) { + // throw new ReedSolomonException("Bad error location"); + return false; + } + received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]); + } + return true; + }; + ReedSolomonDecoder.prototype.runEuclideanAlgorithm = function (a, b, R) { + // Assume a's degree is >= b's + if (a.degree() < b.degree()) { + var temp = a; + a = b; + b = temp; + } + var rLast = a; + var r = b; + var tLast = this.field.zero; + var t = this.field.one; + // Run Euclidean algorithm until r's degree is less than R/2 + while (r.degree() >= R / 2) { + var rLastLast = rLast; + var tLastLast = tLast; + rLast = r; + tLast = t; + // Divide rLastLast by rLast, with quotient in q and remainder in r + if (rLast.isZero()) { + // Oops, Euclidean algorithm already terminated? + // throw new ReedSolomonException("r_{i-1} was zero"); + return null; + } + r = rLastLast; + var q = this.field.zero; + var denominatorLeadingTerm = rLast.getCoefficient(rLast.degree()); + var dltInverse = this.field.inverse(denominatorLeadingTerm); + while (r.degree() >= rLast.degree() && !r.isZero()) { + var degreeDiff = r.degree() - rLast.degree(); + var scale = this.field.multiply(r.getCoefficient(r.degree()), dltInverse); + q = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale)); + r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale)); + } + t = q.multiplyPoly(tLast).addOrSubtract(tLastLast); + if (r.degree() >= rLast.degree()) { + // throw new IllegalStateException("Division algorithm failed to reduce polynomial?"); + return null; + } + } + var sigmaTildeAtZero = t.getCoefficient(0); + if (sigmaTildeAtZero == 0) { + // throw new ReedSolomonException("sigmaTilde(0) was zero"); + return null; + } + var inverse = this.field.inverse(sigmaTildeAtZero); + var sigma = t.multiply(inverse); + var omega = r.multiply(inverse); + return [sigma, omega]; + }; + ReedSolomonDecoder.prototype.findErrorLocations = function (errorLocator) { + // This is a direct application of Chien's search + var numErrors = errorLocator.degree(); + if (numErrors == 1) { + // shortcut + return [errorLocator.getCoefficient(1)]; + } + var result = new Array(numErrors); + var e = 0; + for (var i = 1; i < this.field.size && e < numErrors; i++) { + if (errorLocator.evaluateAt(i) == 0) { + result[e] = this.field.inverse(i); + e++; + } + } + if (e != numErrors) { + // throw new ReedSolomonException("Error locator degree does not match number of roots"); + return null; + } + return result; + }; + ReedSolomonDecoder.prototype.findErrorMagnitudes = function (errorEvaluator, errorLocations) { + // This is directly applying Forney's Formula + var s = errorLocations.length; + var result = new Array(s); + for (var i = 0; i < s; i++) { + var xiInverse = this.field.inverse(errorLocations[i]); + var denominator = 1; + for (var j = 0; j < s; j++) { + if (i != j) { + //denominator = field.multiply(denominator, + // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); + // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. + // Below is a funny-looking workaround from Steven Parkes + var term = this.field.multiply(errorLocations[j], xiInverse); + var termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1; + denominator = this.field.multiply(denominator, termPlus1); + } + } + result[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator)); + if (this.field.generatorBase != 0) { + result[i] = this.field.multiply(result[i], xiInverse); + } + } + return result; + }; + return ReedSolomonDecoder; + }()); + exports.ReedSolomonDecoder = ReedSolomonDecoder; + var GenericGFPoly = (function () { + function GenericGFPoly(field, coefficients) { + if (coefficients.length == 0) { + throw new Error("No coefficients."); + } + this.field = field; + var coefficientsLength = coefficients.length; + if (coefficientsLength > 1 && coefficients[0] == 0) { + // Leading term must be non-zero for anything except the constant polynomial "0" + var firstNonZero = 1; + while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) { + firstNonZero++; + } + if (firstNonZero == coefficientsLength) { + this.coefficients = field.zero.coefficients; + } + else { + this.coefficients = new Array(coefficientsLength - firstNonZero); + /*Array.Copy(coefficients, // Source array + firstNonZero, // Source index + this.coefficients, // Destination array + 0, // Destination index + this.coefficients.length); // length*/ + for (var i = 0; i < this.coefficients.length; i++) { + this.coefficients[i] = coefficients[firstNonZero + i]; + } + } + } + else { + this.coefficients = coefficients; + } + } + GenericGFPoly.prototype.evaluateAt = function (a) { + var result = 0; + if (a == 0) { + // Just return the x^0 coefficient + return this.getCoefficient(0); + } + var size = this.coefficients.length; + if (a == 1) { + // Just the sum of the coefficients + this.coefficients.forEach(function (coefficient) { + result = GenericGF.addOrSubtract(result, coefficient); + }); + return result; + } + result = this.coefficients[0]; + for (var i = 1; i < size; i++) { + result = GenericGF.addOrSubtract(this.field.multiply(a, result), this.coefficients[i]); + } + return result; + }; + GenericGFPoly.prototype.getCoefficient = function (degree) { + return this.coefficients[this.coefficients.length - 1 - degree]; + }; + GenericGFPoly.prototype.degree = function () { + return this.coefficients.length - 1; + }; + GenericGFPoly.prototype.isZero = function () { + return this.coefficients[0] == 0; + }; + GenericGFPoly.prototype.addOrSubtract = function (other) { + /* TODO, fix this. + if (!this.field.Equals(other.field)) + { + throw new Error("GenericGFPolys do not have same GenericGF field"); + }*/ + if (this.isZero()) { + return other; + } + if (other.isZero()) { + return this; + } + var smallerCoefficients = this.coefficients; + var largerCoefficients = other.coefficients; + if (smallerCoefficients.length > largerCoefficients.length) { + var temp = smallerCoefficients; + smallerCoefficients = largerCoefficients; + largerCoefficients = temp; + } + var sumDiff = new Array(largerCoefficients.length); + var lengthDiff = largerCoefficients.length - smallerCoefficients.length; + // Copy high-order terms only found in higher-degree polynomial's coefficients + ///Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff); + for (var i = 0; i < lengthDiff; i++) { + sumDiff[i] = largerCoefficients[i]; + } + for (var i = lengthDiff; i < largerCoefficients.length; i++) { + sumDiff[i] = GenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); + } + return new GenericGFPoly(this.field, sumDiff); + }; + GenericGFPoly.prototype.multiply = function (scalar) { + if (scalar == 0) { + return this.field.zero; + } + if (scalar == 1) { + return this; + } + var size = this.coefficients.length; + var product = new Array(size); + for (var i = 0; i < size; i++) { + product[i] = this.field.multiply(this.coefficients[i], scalar); + } + return new GenericGFPoly(this.field, product); + }; + GenericGFPoly.prototype.multiplyPoly = function (other) { + /* TODO Fix this. + if (!field.Equals(other.field)) + { + throw new Error("GenericGFPolys do not have same GenericGF field"); + }*/ + if (this.isZero() || other.isZero()) { + return this.field.zero; + } + var aCoefficients = this.coefficients; + var aLength = aCoefficients.length; + var bCoefficients = other.coefficients; + var bLength = bCoefficients.length; + var product = new Array(aLength + bLength - 1); + for (var i = 0; i < aLength; i++) { + var aCoeff = aCoefficients[i]; + for (var j = 0; j < bLength; j++) { + product[i + j] = GenericGF.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j])); + } + } + return new GenericGFPoly(this.field, product); + }; + GenericGFPoly.prototype.multiplyByMonomial = function (degree, coefficient) { + if (degree < 0) { + throw new Error("Invalid degree less than 0"); + } + if (coefficient == 0) { + return this.field.zero; + } + var size = this.coefficients.length; + var product = new Array(size + degree); + for (var i = 0; i < size; i++) { + product[i] = this.field.multiply(this.coefficients[i], coefficient); + } + return new GenericGFPoly(this.field, product); + }; + return GenericGFPoly; + }()); + var GenericGF = (function () { + function GenericGF(primitive, size, genBase) { + // ok. + this.INITIALIZATION_THRESHOLD = 0; + this.initialized = false; + this.primitive = primitive; + this.size = size; + this.generatorBase = genBase; + if (size <= this.INITIALIZATION_THRESHOLD) { + this.initialize(); + } + } + GenericGF.prototype.initialize = function () { + this.expTable = new Array(this.size); + this.logTable = new Array(this.size); + var x = 1; + for (var i = 0; i < this.size; i++) { + this.expTable[i] = x; + x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 + if (x >= this.size) { + x ^= this.primitive; + x &= this.size - 1; + } + } + for (var i = 0; i < this.size - 1; i++) { + this.logTable[this.expTable[i]] = i; + } + // logTable[0] == 0 but this should never be used + this.zero = new GenericGFPoly(this, [0]); + this.one = new GenericGFPoly(this, [1]); + this.initialized = true; + }; + GenericGF.addOrSubtract = function (a, b) { + return a ^ b; + }; + GenericGF.prototype.checkInit = function () { + if (!this.initialized) + this.initialize(); + }; + GenericGF.prototype.multiply = function (a, b) { + this.checkInit(); + if (a == 0 || b == 0) { + return 0; + } + return this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)]; + }; + GenericGF.prototype.exp = function (a) { + this.checkInit(); + return this.expTable[a]; + }; + GenericGF.prototype.log = function (a) { + this.checkInit(); + if (a == 0) { + throw new Error("Can't take log(0)"); + } + return this.logTable[a]; + }; + GenericGF.prototype.inverse = function (a) { + this.checkInit(); + if (a == 0) { + throw new Error("Can't invert 0"); + } + return this.expTable[this.size - this.logTable[a] - 1]; + }; + GenericGF.prototype.buildMonomial = function (degree, coefficient) { + this.checkInit(); + if (degree < 0) { + throw new Error("Invalid monomial degree less than 0"); + } + if (coefficient == 0) { + return this.zero; + } + var coefficients = new Array(degree + 1); + coefficients[0] = coefficient; + return new GenericGFPoly(this, coefficients); + }; + return GenericGF; + }()); /***/ } @@ -45397,352 +45397,352 @@ module.exports = mime; },{"./types.json":77,"_process":117,"fs":47,"path":95}],77:[function(require,module,exports){ module.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/bdoc":["bdoc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mpd"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":[],"application/font-woff2":[],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js","mjs"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":[],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":[],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":[],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":[],"application/x-msdownload":["com","bat"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":[],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":[],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp3":[],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/wav":["wav"],"audio/wave":[],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":[],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":[],"audio/x-wav":[],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/apng":["apng"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpm":["jpm"],"image/jpx":["jpx","jpf"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":[],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":[],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["markdown","md"],"text/mathml":["mml"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/rtf":[],"text/sgml":["sgml","sgm"],"text/slim":["slim","slm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":[],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/xml":[],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]} },{}],78:[function(require,module,exports){ -'use strict' - -var ops = require('ndarray-ops') -var ndarray = require('ndarray') -var pool = require('typedarray-pool') -var fftm = require('./lib/fft-matrix.js') - -function ndfft(dir, x, y) { - var shape = x.shape - , d = shape.length - , size = 1 - , stride = new Array(d) - , pad = 0 - , i, j - for(i=d-1; i>=0; --i) { - stride[i] = size - size *= shape[i] - pad = Math.max(pad, fftm.scratchMemory(shape[i])) - if(x.shape[i] !== y.shape[i]) { - throw new Error('Shape mismatch, real and imaginary arrays must have same size') - } - } - var buf_size = 4 * size + pad - var buffer - if( x.dtype === 'array' || - x.dtype === 'float64' || - x.dtype === 'custom' ) { - buffer = pool.mallocDouble(buf_size) - } else { - buffer = pool.mallocFloat(buf_size) - } - var x1 = ndarray(buffer, shape.slice(0), stride, 0) - , y1 = ndarray(buffer, shape.slice(0), stride.slice(0), size) - , x2 = ndarray(buffer, shape.slice(0), stride.slice(0), 2*size) - , y2 = ndarray(buffer, shape.slice(0), stride.slice(0), 3*size) - , tmp, n, s1, s2 - , scratch_ptr = 4 * size - - //Copy into x1/y1 - ops.assign(x1, x) - ops.assign(y1, y) - - for(i=d-1; i>=0; --i) { - fftm(dir, size/shape[i], shape[i], buffer, x1.offset, y1.offset, scratch_ptr) - if(i === 0) { - break - } - - //Compute new stride for x2/y2 - n = 1 - s1 = x2.stride - s2 = y2.stride - for(j=i-1; j=0; --j) { - s2[j] = s1[j] = n - n *= shape[j] - } - - //Transpose - ops.assign(x2, x1) - ops.assign(y2, y1) - - //Swap buffers - tmp = x1 - x1 = x2 - x2 = tmp - tmp = y1 - y1 = y2 - y2 = tmp - } - - //Copy result back into x - ops.assign(x, x1) - ops.assign(y, y1) - - pool.free(buffer) -} - +'use strict' + +var ops = require('ndarray-ops') +var ndarray = require('ndarray') +var pool = require('typedarray-pool') +var fftm = require('./lib/fft-matrix.js') + +function ndfft(dir, x, y) { + var shape = x.shape + , d = shape.length + , size = 1 + , stride = new Array(d) + , pad = 0 + , i, j + for(i=d-1; i>=0; --i) { + stride[i] = size + size *= shape[i] + pad = Math.max(pad, fftm.scratchMemory(shape[i])) + if(x.shape[i] !== y.shape[i]) { + throw new Error('Shape mismatch, real and imaginary arrays must have same size') + } + } + var buf_size = 4 * size + pad + var buffer + if( x.dtype === 'array' || + x.dtype === 'float64' || + x.dtype === 'custom' ) { + buffer = pool.mallocDouble(buf_size) + } else { + buffer = pool.mallocFloat(buf_size) + } + var x1 = ndarray(buffer, shape.slice(0), stride, 0) + , y1 = ndarray(buffer, shape.slice(0), stride.slice(0), size) + , x2 = ndarray(buffer, shape.slice(0), stride.slice(0), 2*size) + , y2 = ndarray(buffer, shape.slice(0), stride.slice(0), 3*size) + , tmp, n, s1, s2 + , scratch_ptr = 4 * size + + //Copy into x1/y1 + ops.assign(x1, x) + ops.assign(y1, y) + + for(i=d-1; i>=0; --i) { + fftm(dir, size/shape[i], shape[i], buffer, x1.offset, y1.offset, scratch_ptr) + if(i === 0) { + break + } + + //Compute new stride for x2/y2 + n = 1 + s1 = x2.stride + s2 = y2.stride + for(j=i-1; j=0; --j) { + s2[j] = s1[j] = n + n *= shape[j] + } + + //Transpose + ops.assign(x2, x1) + ops.assign(y2, y1) + + //Swap buffers + tmp = x1 + x1 = x2 + x2 = tmp + tmp = y1 + y1 = y2 + y2 = tmp + } + + //Copy result back into x + ops.assign(x, x1) + ops.assign(y, y1) + + pool.free(buffer) +} + module.exports = ndfft },{"./lib/fft-matrix.js":79,"ndarray":84,"ndarray-ops":81,"typedarray-pool":144}],79:[function(require,module,exports){ -var bits = require('bit-twiddle') - -function fft(dir, nrows, ncols, buffer, x_ptr, y_ptr, scratch_ptr) { - dir |= 0 - nrows |= 0 - ncols |= 0 - x_ptr |= 0 - y_ptr |= 0 - if(bits.isPow2(ncols)) { - fftRadix2(dir, nrows, ncols, buffer, x_ptr, y_ptr) - } else { - fftBluestein(dir, nrows, ncols, buffer, x_ptr, y_ptr, scratch_ptr) - } -} -module.exports = fft - -function scratchMemory(n) { - if(bits.isPow2(n)) { - return 0 - } - return 2 * n + 4 * bits.nextPow2(2*n + 1) -} -module.exports.scratchMemory = scratchMemory - - -//Radix 2 FFT Adapted from Paul Bourke's C Implementation -function fftRadix2(dir, nrows, ncols, buffer, x_ptr, y_ptr) { - dir |= 0 - nrows |= 0 - ncols |= 0 - x_ptr |= 0 - y_ptr |= 0 - var nn,m,i,i1,j,k,i2,l,l1,l2 - var c1,c2,t,t1,t2,u1,u2,z,row,a,b,c,d,k1,k2,k3 - - // Calculate the number of points - nn = ncols - m = bits.log2(nn) - - for(row=0; row> 1; - j = 0; - for(i=0;i>= 1 - } - j += k - } - - // Compute the FFT - c1 = -1.0 - c2 = 0.0 - l2 = 1 - for(l=0;l> 1; + j = 0; + for(i=0;i>= 1 + } + j += k + } + + // Compute the FFT + c1 = -1.0 + c2 = 0.0 + l2 = 1 + for(l=0;l 0) { - thisStep = images[image].steps[index]; - thisStep.UI.onRemove(thisStep.options.step); - images[image].steps.splice(index, 1); - } - //tell the UI a step has been removed - } - - function removeSteps(image, index) { - var run = {}, indices; - var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; - var args = (this.name == "ImageSequencer") ? [] : [this.images]; - for (var arg in arguments) args.push(copy(arguments[arg])); - - var json_q = formatInput.call(this_, args, "-"); - inputlog.push({ method: "removeSteps", json_q: copy(json_q) }); - - for (var img in json_q) { - indices = json_q[img].sort(function(a, b) { return b - a }); - run[img] = indices[indices.length - 1]; - for (var i in indices) - removeStep(img, indices[i]); - } - // this.run(run); // This is creating problems - return this; - } - - function insertSteps(image, index, name, o) { - var run = {}; - var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; - var args = (this.name == "ImageSequencer") ? [] : [this.images]; - for (var arg in arguments) args.push(arguments[arg]); - - var json_q = formatInput.call(this_, args, "^"); - inputlog.push({ method: "insertSteps", json_q: copy(json_q) }); - - for (var img in json_q) { - var details = json_q[img]; - details = details.sort(function(a, b) { return b.index - a.index }); - for (var i in details) - require("./InsertStep")(this_, img, details[i].index, details[i].name, details[i].o); - run[img] = details[details.length - 1].index; - } - // this.run(run); // This is Creating issues - return this; - } - - // Config is an object which contains the runtime configuration like progress bar - // information and index from which the sequencer should run - function run(config, t_image, t_from) { - let progressObj, index = 0; - config = config || { mode: 'no-arg' }; - if (config.index) index = config.index; - - if (config.mode != 'test') { - if (config.mode != "no-arg" && typeof config != 'function') { - if (config.progressObj) progressObj = config.progressObj; - delete arguments['0']; - } - } - else { - arguments['0'] = config.mode; - } - - var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; - var args = (this.name == "ImageSequencer") ? [] : [this.images]; - for (var arg in arguments) args.push(copy(arguments[arg])); - - var callback = function() { }; - for (var arg in args) - if (objTypeOf(args[arg]) == "Function") - callback = args.splice(arg, 1)[0]; - - var json_q = formatInput.call(this_, args, "r"); - - require('./Run')(this_, json_q, callback, index, progressObj); - - return true; - } - - function loadImages() { - var args = []; - var sequencer = this; - for (var arg in arguments) args.push(copy(arguments[arg])); - var json_q = formatInput.call(this, args, "l"); - - inputlog.push({ method: "loadImages", json_q: copy(json_q) }); - var loadedimages = this.copy(json_q.loadedimages); - - var ret = { - name: "ImageSequencer Wrapper", - sequencer: this, - addSteps: this.addSteps, - removeSteps: this.removeSteps, - insertSteps: this.insertSteps, - run: this.run, - UI: this.UI, - setUI: this.setUI, - images: loadedimages - }; - - function load(i) { - if (i == loadedimages.length) { - json_q.callback.call(ret); - return; - } - var img = loadedimages[i]; - require('./ui/LoadImage')(sequencer, img, json_q.images[img], function() { - load(++i); - }); - } - - load(0); - } - - function replaceImage(selector, steps, options) { - options = options || {}; - options.callback = options.callback || function() { }; - return require('./ReplaceImage')(this, selector, steps, options); - } - - function setUI(UI) { - this.events = require('./ui/UserInterface')(UI); - } - - var exportBin = function(dir, basic, filename) { - return require('./ExportBin')(dir, this, basic, filename); - } - - function modulesInfo(name) { - var modulesdata = {} - if (name == "load-image") return {}; - if (arguments.length == 0) { - for (var modulename in this.modules) { - modulesdata[modulename] = modules[modulename][1]; - } - for (var sequencename in this.sequences) { - modulesdata[sequencename] = { name: sequencename, steps: sequences[sequencename] }; - } - } - else { - if (modules[name]) - modulesdata = modules[name][1]; - else - modulesdata = { 'inputs': sequences[name]['options'] }; - } - return modulesdata; - } - - // Genates a CLI string for the current sequence - function toCliString() { - var cliStringSteps = `"`, cliOptions = {}; - for (var step in this.steps) { - if (this.steps[step].options.name !== "load-image") - cliStringSteps += `${this.steps[step].options.name} `; - for (var inp in modulesInfo(this.steps[step].options.name).inputs) { - cliOptions[inp] = this.steps[step].options[inp]; - } - } - cliStringSteps = cliStringSteps.substr(0, cliStringSteps.length - 1) + `"`; - return `sequencer -i [PATH] -s ${cliStringSteps} -d '${JSON.stringify(cliOptions)}'` - } - - // Strigifies the current sequence - function toString(step) { - if (step) { - return stepToString(step); - } else { - return copy(this.images.image1.steps).map(stepToString).slice(1).join(','); - } - } - - // Stringifies one step of the sequence - function stepToString(step) { - let inputs = modulesInfo(step.options.name).inputs || {}, op = {}; - - for (let input in inputs) { - - if (!!step.options[input] && step.options[input] != inputs[input].default) { - op[input] = step.options[input]; - op[input] = encodeURIComponent(op[input]); - } - - } - - var configurations = Object.keys(op).map(key => key + ':' + op[key]).join('|'); - return `${step.options.name}{${configurations}}`; - } - - // exports the current sequence as an array of JSON steps - function toJSON() { - return this.stringToJSON(this.toString()); - } - - // Coverts stringified sequence into an array of JSON steps - function stringToJSON(str) { - let steps; - if (str.includes(',')) - steps = str.split(','); - else - steps = [str]; - return steps.map(stringToJSONstep); - } - - // Converts one stringified step into JSON - function stringToJSONstep(str) { - var bracesStrings; - if (str.includes('{')) - if (str.includes('(') && str.indexOf('(') < str.indexOf('{')) - bracesStrings = ['(', ')']; - else - bracesStrings = ['{', '}']; - else - bracesStrings = ['(', ')']; - - if (str.indexOf(bracesStrings[0]) === -1) { // if there are no settings specified - var moduleName = str.substr(0); - stepSettings = ""; - } else { - var moduleName = str.substr(0, str.indexOf(bracesStrings[0])); - stepSettings = str.slice(str.indexOf(bracesStrings[0]) + 1, -1); - } - - stepSettings = stepSettings.split('|').reduce(function formatSettings(accumulator, current, i) { - var settingName = current.substr(0, current.indexOf(':')), - settingValue = current.substr(current.indexOf(':') + 1); - settingValue = settingValue.replace(/^\(/, '').replace(/\)$/, ''); // strip () at start/end - settingValue = settingValue.replace(/^\{/, '').replace(/\}$/, ''); // strip {} at start/end - settingValue = decodeURIComponent(settingValue); - current = [ - settingName, - settingValue - ]; - if (!!settingName) accumulator[settingName] = settingValue; - return accumulator; - }, {}); - - return { - name: moduleName, - options: stepSettings - } - } - - // imports a string into the sequencer steps - function importString(str) { - let sequencer = this; - if (this.name != "ImageSequencer") - sequencer = this.sequencer; - var stepsFromString = stringToJSON(str); - stepsFromString.forEach(function eachStep(stepObj) { - sequencer.addSteps(stepObj.name, stepObj.options); - }); - } - - // imports a array of JSON steps into the sequencer steps - function importJSON(obj) { - let sequencer = this; - if (this.name != "ImageSequencer") - sequencer = this.sequencer; - obj.forEach(function eachStep(stepObj) { - sequencer.addSteps(stepObj.name, stepObj.options); - }); - } - - function loadNewModule(name, options) { - - if (!options) { - return this; - - } else if (Array.isArray(options)) { - // contains the array of module and info - this.modules[name] = options; - - } else if (options.func && options.info) { - // passed in options object - this.modules[name] = [ - options.func, options.info - ]; - - } else if (options.path && !this.inBrowser) { - // load from path(only in node) - const module = [ - require(`${options.path}/Module.js`), - require(`${options.path}/info.json`) - ]; - this.modules[name] = module; - } - return this; - } - - function saveNewModule(name, path) { - if (options.inBrowser) { - // Not for browser context - return; - } - var mods = fs.readFileSync('./src/Modules.js').toString(); - mods = mods.substr(0, mods.length - 1) + " '" + name + "': require('" + path + "'),\n}"; - fs.writeFileSync('./src/Modules.js', mods); - } - - function createMetaModule(stepsCollection, info) { - var stepsArr = stepsCollection; - if (typeof stepsCollection === 'string') - stepsArr = stringToJSON(stepsCollection); - var metaMod = function() { - this.expandSteps(stepsArr); - return { - isMeta: true - } - } - return [metaMod, info]; - } - - function saveSequence(name, sequenceString) { - const sequence = stringToJSON(sequenceString); - // Save the given sequence string as a module - if (options.inBrowser) { - // Inside the browser we save the meta-modules using the Web Storage API - var sequences = JSON.parse(window.localStorage.getItem('sequences')); - sequences[name] = sequence; - window.localStorage.setItem('sequences', JSON.stringify(sequences)); - } - else { - // In node we save the sequences in the json file SavedSequences.json - var sequences = require('./SavedSequences.json'); - sequences[name] = sequence; - fs.writeFileSync('./src/SavedSequences.json', JSON.stringify(sequences)); - } - } - - function loadModules() { - // This function loads the modules and saved sequences - this.modules = require('./Modules'); - if (options.inBrowser) - this.sequences = JSON.parse(window.localStorage.getItem('sequences')); - else - this.sequences = require('./SavedSequences.json'); - } - - return { - //literals and objects - name: "ImageSequencer", - options: options, - inputlog: inputlog, - modules: modules, - sequences: sequences, - images: images, - events: events, - - //user functions - loadImages: loadImages, - loadImage: loadImages, - addSteps: addSteps, - removeSteps: removeSteps, - insertSteps: insertSteps, - replaceImage: replaceImage, - run: run, - setUI: setUI, - exportBin: exportBin, - modulesInfo: modulesInfo, - toCliString: toCliString, - toString: toString, - stepToString: stepToString, - toJSON: toJSON, - stringToJSON: stringToJSON, - stringToJSONstep: stringToJSONstep, - importString: importString, - importJSON: importJSON, - loadNewModule: loadNewModule, - saveNewModule: saveNewModule, - createMetaModule: createMetaModule, - saveSequence: saveSequence, - loadModules: loadModules, - - //other functions - log: log, - objTypeOf: objTypeOf, - copy: copy, - - setInputStep: require('./ui/SetInputStep')(sequencer) - } - -} -module.exports = ImageSequencer; +if (typeof window !== 'undefined') { isBrowser = true } +else { var isBrowser = false } +require('./util/getStep.js'); + +ImageSequencer = function ImageSequencer(options) { + + var sequencer = (this.name == "ImageSequencer") ? this : this.sequencer; + options = options || {}; + options.inBrowser = options.inBrowser || isBrowser; + options.sequencerCounter = 0; + + function objTypeOf(object) { + return Object.prototype.toString.call(object).split(" ")[1].slice(0, -1) + } + + function log(color, msg) { + if (options.ui != "none") { + if (arguments.length == 1) console.log(arguments[0]); + else if (arguments.length == 2) console.log(color, msg); + } + } + + function copy(a) { + if (!typeof (a) == "object") return a; + if (objTypeOf(a) == "Array") return a.slice(); + if (objTypeOf(a) == "Object") { + var b = {}; + for (var v in a) { + b[v] = copy(a[v]); + } + return b; + } + return a; + } + + function makeArray(input) { + return (objTypeOf(input) == "Array") ? input : [input]; + } + + var image, + steps = [], + modules = require('./Modules'), + sequences = require('./SavedSequences.json'), + formatInput = require('./FormatInput'), + images = {}, + inputlog = [], + events = require('./ui/UserInterface')(), + fs = require('fs'); + + + + if (options.inBrowser) { + for (o in sequencer) { + modules[o] = sequencer[o]; + } + sequences = JSON.parse(window.localStorage.getItem('sequences')); + if (!sequences) { + sequences = {}; + window.localStorage.setItem('sequences', JSON.stringify(sequences)); + } + } + + // if in browser, prompt for an image + // if (options.imageSelect || options.inBrowser) addStep('image-select'); + // else if (options.imageUrl) loadImage(imageUrl); + + function addSteps() { + var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; + var args = (this.name == "ImageSequencer") ? [] : [this.images]; + var json_q = {}; + for (var arg in arguments) { args.push(copy(arguments[arg])); } + json_q = formatInput.call(this_, args, "+"); + + inputlog.push({ method: "addSteps", json_q: copy(json_q) }); + + for (var i in json_q) + for (var j in json_q[i]) + require("./AddStep")(this_, i, json_q[i][j].name, json_q[i][j].o); + + return this; + } + + function removeStep(image, index) { + //remove the step from images[image].steps and redraw remaining images + if (index > 0) { + thisStep = images[image].steps[index]; + thisStep.UI.onRemove(thisStep.options.step); + images[image].steps.splice(index, 1); + } + //tell the UI a step has been removed + } + + function removeSteps(image, index) { + var run = {}, indices; + var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; + var args = (this.name == "ImageSequencer") ? [] : [this.images]; + for (var arg in arguments) args.push(copy(arguments[arg])); + + var json_q = formatInput.call(this_, args, "-"); + inputlog.push({ method: "removeSteps", json_q: copy(json_q) }); + + for (var img in json_q) { + indices = json_q[img].sort(function(a, b) { return b - a }); + run[img] = indices[indices.length - 1]; + for (var i in indices) + removeStep(img, indices[i]); + } + // this.run(run); // This is creating problems + return this; + } + + function insertSteps(image, index, name, o) { + var run = {}; + var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; + var args = (this.name == "ImageSequencer") ? [] : [this.images]; + for (var arg in arguments) args.push(arguments[arg]); + + var json_q = formatInput.call(this_, args, "^"); + inputlog.push({ method: "insertSteps", json_q: copy(json_q) }); + + for (var img in json_q) { + var details = json_q[img]; + details = details.sort(function(a, b) { return b.index - a.index }); + for (var i in details) + require("./InsertStep")(this_, img, details[i].index, details[i].name, details[i].o); + run[img] = details[details.length - 1].index; + } + // this.run(run); // This is Creating issues + return this; + } + + // Config is an object which contains the runtime configuration like progress bar + // information and index from which the sequencer should run + function run(config, t_image, t_from) { + let progressObj, index = 0; + config = config || { mode: 'no-arg' }; + if (config.index) index = config.index; + + if (config.mode != 'test') { + if (config.mode != "no-arg" && typeof config != 'function') { + if (config.progressObj) progressObj = config.progressObj; + delete arguments['0']; + } + } + else { + arguments['0'] = config.mode; + } + + var this_ = (this.name == "ImageSequencer") ? this : this.sequencer; + var args = (this.name == "ImageSequencer") ? [] : [this.images]; + for (var arg in arguments) args.push(copy(arguments[arg])); + + var callback = function() { }; + for (var arg in args) + if (objTypeOf(args[arg]) == "Function") + callback = args.splice(arg, 1)[0]; + + var json_q = formatInput.call(this_, args, "r"); + + require('./Run')(this_, json_q, callback, index, progressObj); + + return true; + } + + function loadImages() { + var args = []; + var sequencer = this; + for (var arg in arguments) args.push(copy(arguments[arg])); + var json_q = formatInput.call(this, args, "l"); + + inputlog.push({ method: "loadImages", json_q: copy(json_q) }); + var loadedimages = this.copy(json_q.loadedimages); + + var ret = { + name: "ImageSequencer Wrapper", + sequencer: this, + addSteps: this.addSteps, + removeSteps: this.removeSteps, + insertSteps: this.insertSteps, + run: this.run, + UI: this.UI, + setUI: this.setUI, + images: loadedimages + }; + + function load(i) { + if (i == loadedimages.length) { + json_q.callback.call(ret); + return; + } + var img = loadedimages[i]; + require('./ui/LoadImage')(sequencer, img, json_q.images[img], function() { + load(++i); + }); + } + + load(0); + } + + function replaceImage(selector, steps, options) { + options = options || {}; + options.callback = options.callback || function() { }; + return require('./ReplaceImage')(this, selector, steps, options); + } + + function setUI(UI) { + this.events = require('./ui/UserInterface')(UI); + } + + var exportBin = function(dir, basic, filename) { + return require('./ExportBin')(dir, this, basic, filename); + } + + function modulesInfo(name) { + var modulesdata = {} + if (name == "load-image") return {}; + if (arguments.length == 0) { + for (var modulename in this.modules) { + modulesdata[modulename] = modules[modulename][1]; + } + for (var sequencename in this.sequences) { + modulesdata[sequencename] = { name: sequencename, steps: sequences[sequencename] }; + } + } + else { + if (modules[name]) + modulesdata = modules[name][1]; + else + modulesdata = { 'inputs': sequences[name]['options'] }; + } + return modulesdata; + } + + // Genates a CLI string for the current sequence + function toCliString() { + var cliStringSteps = `"`, cliOptions = {}; + for (var step in this.steps) { + if (this.steps[step].options.name !== "load-image") + cliStringSteps += `${this.steps[step].options.name} `; + for (var inp in modulesInfo(this.steps[step].options.name).inputs) { + cliOptions[inp] = this.steps[step].options[inp]; + } + } + cliStringSteps = cliStringSteps.substr(0, cliStringSteps.length - 1) + `"`; + return `sequencer -i [PATH] -s ${cliStringSteps} -d '${JSON.stringify(cliOptions)}'` + } + + // Strigifies the current sequence + function toString(step) { + if (step) { + return stepToString(step); + } else { + return copy(this.images.image1.steps).map(stepToString).slice(1).join(','); + } + } + + // Stringifies one step of the sequence + function stepToString(step) { + let inputs = modulesInfo(step.options.name).inputs || {}, op = {}; + + for (let input in inputs) { + + if (!!step.options[input] && step.options[input] != inputs[input].default) { + op[input] = step.options[input]; + op[input] = encodeURIComponent(op[input]); + } + + } + + var configurations = Object.keys(op).map(key => key + ':' + op[key]).join('|'); + return `${step.options.name}{${configurations}}`; + } + + // exports the current sequence as an array of JSON steps + function toJSON() { + return this.stringToJSON(this.toString()); + } + + // Coverts stringified sequence into an array of JSON steps + function stringToJSON(str) { + let steps; + if (str.includes(',')) + steps = str.split(','); + else + steps = [str]; + return steps.map(stringToJSONstep); + } + + // Converts one stringified step into JSON + function stringToJSONstep(str) { + var bracesStrings; + if (str.includes('{')) + if (str.includes('(') && str.indexOf('(') < str.indexOf('{')) + bracesStrings = ['(', ')']; + else + bracesStrings = ['{', '}']; + else + bracesStrings = ['(', ')']; + + if (str.indexOf(bracesStrings[0]) === -1) { // if there are no settings specified + var moduleName = str.substr(0); + stepSettings = ""; + } else { + var moduleName = str.substr(0, str.indexOf(bracesStrings[0])); + stepSettings = str.slice(str.indexOf(bracesStrings[0]) + 1, -1); + } + + stepSettings = stepSettings.split('|').reduce(function formatSettings(accumulator, current, i) { + var settingName = current.substr(0, current.indexOf(':')), + settingValue = current.substr(current.indexOf(':') + 1); + settingValue = settingValue.replace(/^\(/, '').replace(/\)$/, ''); // strip () at start/end + settingValue = settingValue.replace(/^\{/, '').replace(/\}$/, ''); // strip {} at start/end + settingValue = decodeURIComponent(settingValue); + current = [ + settingName, + settingValue + ]; + if (!!settingName) accumulator[settingName] = settingValue; + return accumulator; + }, {}); + + return { + name: moduleName, + options: stepSettings + } + } + + // imports a string into the sequencer steps + function importString(str) { + let sequencer = this; + if (this.name != "ImageSequencer") + sequencer = this.sequencer; + var stepsFromString = stringToJSON(str); + stepsFromString.forEach(function eachStep(stepObj) { + sequencer.addSteps(stepObj.name, stepObj.options); + }); + } + + // imports a array of JSON steps into the sequencer steps + function importJSON(obj) { + let sequencer = this; + if (this.name != "ImageSequencer") + sequencer = this.sequencer; + obj.forEach(function eachStep(stepObj) { + sequencer.addSteps(stepObj.name, stepObj.options); + }); + } + + function loadNewModule(name, options) { + + if (!options) { + return this; + + } else if (Array.isArray(options)) { + // contains the array of module and info + this.modules[name] = options; + + } else if (options.func && options.info) { + // passed in options object + this.modules[name] = [ + options.func, options.info + ]; + + } else if (options.path && !this.inBrowser) { + // load from path(only in node) + const module = [ + require(`${options.path}/Module.js`), + require(`${options.path}/info.json`) + ]; + this.modules[name] = module; + } + return this; + } + + function saveNewModule(name, path) { + if (options.inBrowser) { + // Not for browser context + return; + } + var mods = fs.readFileSync('./src/Modules.js').toString(); + mods = mods.substr(0, mods.length - 1) + " '" + name + "': require('" + path + "'),\n}"; + fs.writeFileSync('./src/Modules.js', mods); + } + + function createMetaModule(stepsCollection, info) { + var stepsArr = stepsCollection; + if (typeof stepsCollection === 'string') + stepsArr = stringToJSON(stepsCollection); + var metaMod = function() { + this.expandSteps(stepsArr); + return { + isMeta: true + } + } + return [metaMod, info]; + } + + function saveSequence(name, sequenceString) { + const sequence = stringToJSON(sequenceString); + // Save the given sequence string as a module + if (options.inBrowser) { + // Inside the browser we save the meta-modules using the Web Storage API + var sequences = JSON.parse(window.localStorage.getItem('sequences')); + sequences[name] = sequence; + window.localStorage.setItem('sequences', JSON.stringify(sequences)); + } + else { + // In node we save the sequences in the json file SavedSequences.json + var sequences = require('./SavedSequences.json'); + sequences[name] = sequence; + fs.writeFileSync('./src/SavedSequences.json', JSON.stringify(sequences)); + } + } + + function loadModules() { + // This function loads the modules and saved sequences + this.modules = require('./Modules'); + if (options.inBrowser) + this.sequences = JSON.parse(window.localStorage.getItem('sequences')); + else + this.sequences = require('./SavedSequences.json'); + } + + return { + //literals and objects + name: "ImageSequencer", + options: options, + inputlog: inputlog, + modules: modules, + sequences: sequences, + images: images, + events: events, + + //user functions + loadImages: loadImages, + loadImage: loadImages, + addSteps: addSteps, + removeSteps: removeSteps, + insertSteps: insertSteps, + replaceImage: replaceImage, + run: run, + setUI: setUI, + exportBin: exportBin, + modulesInfo: modulesInfo, + toCliString: toCliString, + toString: toString, + stepToString: stepToString, + toJSON: toJSON, + stringToJSON: stringToJSON, + stringToJSONstep: stringToJSONstep, + importString: importString, + importJSON: importJSON, + loadNewModule: loadNewModule, + saveNewModule: saveNewModule, + createMetaModule: createMetaModule, + saveSequence: saveSequence, + loadModules: loadModules, + + //other functions + log: log, + objTypeOf: objTypeOf, + copy: copy, + + setInputStep: require('./ui/SetInputStep')(sequencer) + } + +} +module.exports = ImageSequencer; },{"./AddStep":151,"./ExportBin":152,"./FormatInput":153,"./InsertStep":155,"./Modules":156,"./ReplaceImage":157,"./Run":158,"./SavedSequences.json":160,"./ui/LoadImage":243,"./ui/SetInputStep":244,"./ui/UserInterface":245,"./util/getStep.js":247,"fs":47}],155:[function(require,module,exports){ const getStepUtils = require('./util/getStep.js'); @@ -58338,7 +58338,7 @@ module.exports = { 'saturation': require('./modules/Saturation') } -},{"./modules/Average":162,"./modules/Blend":165,"./modules/Blur":169,"./modules/Brightness":172,"./modules/Channel":175,"./modules/Colorbar":178,"./modules/Colormap":182,"./modules/Contrast":186,"./modules/Convolution":190,"./modules/Crop":195,"./modules/DecodeQr":198,"./modules/Dynamic":201,"./modules/EdgeDetect":205,"./modules/FisheyeGl":208,"./modules/GammaCorrection":211,"./modules/Gradient":214,"./modules/Histogram":217,"./modules/ImportImage":221,"./modules/Ndvi":228,"./modules/NdviColormap":224,"./modules/Overlay":231,"./modules/Resize":234,"./modules/Rotate":237,"./modules/Saturation":240,"image-sequencer-invert":61}],157:[function(require,module,exports){ +},{"./modules/Average":162,"./modules/Blend":165,"./modules/Blur":169,"./modules/Brightness":172,"./modules/Channel":175,"./modules/Colorbar":178,"./modules/Colormap":182,"./modules/Contrast":186,"./modules/Convolution":190,"./modules/Crop":195,"./modules/DecodeQr":198,"./modules/Dynamic":201,"./modules/EdgeDetect":205,"./modules/FisheyeGl":208,"./modules/GammaCorrection":211,"./modules/Gradient":214,"./modules/Histogram":217,"./modules/ImportImage":221,"./modules/Ndvi":225,"./modules/NdviColormap":228,"./modules/Overlay":231,"./modules/Resize":234,"./modules/Rotate":237,"./modules/Saturation":240,"image-sequencer-invert":61}],157:[function(require,module,exports){ // Uses a given image as input and replaces it with the output. // Works only in the browser. function ReplaceImage(ref,selector,steps,options) { @@ -60772,25 +60772,6 @@ module.exports={ } } },{}],223:[function(require,module,exports){ -/* - * Sample Meta Module for demonstration purpose only - */ -module.exports = function NdviColormapfunction() { - this.expandSteps([{ 'name': 'ndvi', 'options': {} }, { 'name': 'colormap', options: {} }]); - return { - isMeta: true - } -} -},{}],224:[function(require,module,exports){ -arguments[4][162][0].apply(exports,arguments) -},{"./Module":223,"./info.json":225,"dup":162}],225:[function(require,module,exports){ -module.exports={ - "name": "NDVI-Colormap", - "description": "Sequentially Applies NDVI and Colormap steps", - "inputs": {}, - "length": 2 -} -},{}],226:[function(require,module,exports){ /* * NDVI with red filter (blue channel is infrared) */ @@ -60850,7 +60831,7 @@ module.exports = function Ndvi(options, UI) { } } -},{"../_nomodule/PixelManipulation.js":242,"./Ui.js":227}],227:[function(require,module,exports){ +},{"../_nomodule/PixelManipulation.js":242,"./Ui.js":224}],224:[function(require,module,exports){ // hide on save module.exports = function CropModuleUi(step, ui) { @@ -60886,9 +60867,9 @@ module.exports = function CropModuleUi(step, ui) { } } -},{}],228:[function(require,module,exports){ +},{}],225:[function(require,module,exports){ arguments[4][162][0].apply(exports,arguments) -},{"./Module":226,"./info.json":229,"dup":162}],229:[function(require,module,exports){ +},{"./Module":223,"./info.json":226,"dup":162}],226:[function(require,module,exports){ module.exports={ "name": "NDVI", "description": "Normalized Difference Vegetation Index, or NDVI, is an image analysis technique used with aerial photography. It's a way to visualize the amounts of infrared and other wavelengths of light reflected from vegetation by comparing ratios of blue and red light absorbed versus green and IR light reflected. NDVI is used to evaluate the health of vegetation in satellite imagery, where it correlates with how much photosynthesis is happening. This is helpful in assessing vegetative health or stress. Read more.

This is designed for use with red-filtered single camera DIY Infragram cameras; change to 'blue' for blue filters", @@ -60902,6 +60883,25 @@ module.exports={ } } +},{}],227:[function(require,module,exports){ +/* + * Sample Meta Module for demonstration purpose only + */ +module.exports = function NdviColormapfunction() { + this.expandSteps([{ 'name': 'ndvi', 'options': {} }, { 'name': 'colormap', options: {} }]); + return { + isMeta: true + } +} +},{}],228:[function(require,module,exports){ +arguments[4][162][0].apply(exports,arguments) +},{"./Module":227,"./info.json":229,"dup":162}],229:[function(require,module,exports){ +module.exports={ + "name": "NDVI-Colormap", + "description": "Sequentially Applies NDVI and Colormap steps", + "inputs": {}, + "length": 2 +} },{}],230:[function(require,module,exports){ module.exports = function Dynamic(options, UI, util) { diff --git a/dist/image-sequencer.min.js b/dist/image-sequencer.min.js index 023aa7111b..0986e36a61 100644 --- a/dist/image-sequencer.min.js +++ b/dist/image-sequencer.min.js @@ -1 +1 @@ -!function(){return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o0?r-4:r,f=0;f>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[u++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},n.fromByteArray=function(t){for(var e,n=t.length,i=n%3,a=[],o=0,s=n-i;os?s:o+16383));1===i?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return a.join("")};for(var r=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var i,a,o=[],s=e;s>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],2:[function(t,e,n){"use strict";"use restrict";function r(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}n.INT_BITS=32,n.INT_MAX=2147483647,n.INT_MIN=-1<<31,n.sign=function(t){return(t>0)-(t<0)},n.abs=function(t){var e=t>>31;return(t^e)-e},n.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=n=((t>>>=e)>255)<<3,e|=n=((t>>>=n)>15)<<2,(e|=n=((t>>>=n)>3)<<1)|(t>>>=n)>>1},n.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},n.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.countTrailingZeros=r,n.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},n.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},n.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,r=e,i=7;for(n>>>=1;n;n>>>=1)r<<=1,r|=1&n,--i;t[e]=r<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},n.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},n.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},n.interleave3=function(t,e,n){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},n.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},n.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>r(t)+1}},{}],3:[function(t,e,n){(function(t,r,i){!function(t){if("object"==typeof n&&void 0!==e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:void 0!==r?i=r:"undefined"!=typeof self&&(i=self),i.Promise=t()}}(function(){var e,n,a;return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){var n=e[o][1][t];return i(n||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof _dereq_&&_dereq_,o=0;o0;)p(t)}function p(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}u.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},u.prototype.hasCustomScheduler=function(){return this._customScheduler},u.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},u.prototype.disableTrampolineIfNecessary=function(){s.hasDevTools&&(this._trampolineEnabled=!1)},u.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},u.prototype.fatalError=function(e,n){n?(t.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),t.exit(2)):this.throwLater(e)},u.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},s.hasDevTools?(u.prototype.invokeLater=function(t,e,n){this._trampolineEnabled?l.call(this,t,e,n):this._schedule(function(){setTimeout(function(){t.call(e,n)},100)})},u.prototype.invoke=function(t,e,n){this._trampolineEnabled?c.call(this,t,e,n):this._schedule(function(){t.call(e,n)})},u.prototype.settlePromises=function(t){this._trampolineEnabled?f.call(this,t):this._schedule(function(){t._settlePromises()})}):(u.prototype.invokeLater=l,u.prototype.invoke=c,u.prototype.settlePromises=f),u.prototype._drainQueues=function(){h(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,h(this._lateQueue)},u.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},u.prototype._reset=function(){this._isTickUsed=!1},n.exports=u,n.exports.firstLineError=i},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,a=function(t,e){this._reject(e)},o=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(a,a,null,this,t)},s=function(t,e){0==(50397184&this._bitField)&&this._resolveCallback(e.target)},u=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(a){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(a),c=new t(e);c._propagateFrom(this,1);var f=this._target();if(c._setBoundTo(l),l instanceof t){var h={promiseRejectionQueued:!1,promise:c,target:f,bindingPromise:l};f._then(e,o,void 0,c,h),l._then(s,u,void 0,c,h),c._setOnCancel(l)}else c._resolveCallback(f);return c},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152==(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";var r;"undefined"!=typeof Promise&&(r=Promise);var i=t("./promise")();i.noConflict=function(){try{Promise===i&&(Promise=r)}catch(t){}return i},e.exports=i},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),a=r(null);i[" size"]=a[" size"]=0}e.exports=function(e){var n,r=t("./util"),i=r.canEvaluate;r.isIdentifier;function a(t,n){var i;if(null!=t&&(i=t[n]),"function"!=typeof i){var a="Object "+r.classString(t)+" has no method '"+r.toString(n)+"'";throw new e.TypeError(a)}return i}function o(t){return a(t,this.pop()).apply(t,this)}function s(t){return t[this]}function u(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(o,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e;if("number"==typeof t)e=u;else if(i){var r=n(t);e=null!==r?r:s}else e=s;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var a=t("./util"),o=a.tryCatch,s=a.errorObj,u=e._async;e.prototype.break=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(a.isArray(t))for(var n=0;n=0)return n[t]}return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},r.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,n.push(this._trace))},r.prototype._popContext=function(){if(void 0!==this._trace){var t=n.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},r.CapturedTrace=null,r.create=function(){if(e)return new r},r.deactivateLongStackTraces=function(){},r.activateLongStackTraces=function(){var n=t.prototype._pushContext,a=t.prototype._popContext,o=t._peekContext,s=t.prototype._peekContext,u=t.prototype._promiseCreated;r.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=a,t._peekContext=o,t.prototype._peekContext=s,t.prototype._promiseCreated=u,e=!1},e=!0,t.prototype._pushContext=r.prototype._pushContext,t.prototype._popContext=r.prototype._popContext,t._peekContext=t.prototype._peekContext=i,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},r}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){var i,a,o,s=n._getDomain,u=n._async,l=e("./errors").Warning,c=e("./util"),f=e("./es5"),h=c.canAttachTrace,p=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,d=/\((?:timers\.js):\d+:\d+\)/,v=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,g=null,m=null,_=!1,y=!(0==c.env("BLUEBIRD_DEBUG")),w=!(0==c.env("BLUEBIRD_WARNINGS")||!y&&!c.env("BLUEBIRD_WARNINGS")),b=!(0==c.env("BLUEBIRD_LONG_STACK_TRACES")||!y&&!c.env("BLUEBIRD_LONG_STACK_TRACES")),x=0!=c.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(w||!!c.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},n.prototype._ensurePossibleRejectionHandled=function(){if(0==(524288&this._bitField)){this._setRejectionIsUnhandled();var t=this;setTimeout(function(){t._notifyUnhandledRejection()},1)}},n.prototype._notifyUnhandledRejectionIsHandled=function(){H("rejectionHandled",i,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!=(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),H("unhandledRejection",a,t,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(t,e,n){return z(t,e,n||this)},n.onPossiblyUnhandledRejection=function(t){var e=s();a="function"==typeof t?null===e?t:c.domainBind(e,t):void 0},n.onUnhandledRejectionHandled=function(t){var e=s();i="function"==typeof t?null===e?t:c.domainBind(e,t):void 0};var k=function(){};n.longStackTraces=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!K.longStackTraces&&Z()){var t=n.prototype._captureStackTrace,e=n.prototype._attachExtraTrace,i=n.prototype._dereferenceTrace;K.longStackTraces=!0,k=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=t,n.prototype._attachExtraTrace=e,n.prototype._dereferenceTrace=i,r.deactivateLongStackTraces(),u.enableTrampoline(),K.longStackTraces=!1},n.prototype._captureStackTrace=D,n.prototype._attachExtraTrace=N,n.prototype._dereferenceTrace=U,r.activateLongStackTraces(),u.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return K.longStackTraces&&Z()};var E=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n={detail:e,cancelable:!0};f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason});var r=new CustomEvent(t.toLowerCase(),n);return!c.global.dispatchEvent(r)}}if("function"==typeof Event){t=new Event("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason}),!c.global.dispatchEvent(n)}}return(t=document.createEvent("CustomEvent")).initCustomEvent("testingtheevent",!1,!0,{}),c.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!c.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),S=c.isNode?function(){return t.emit.apply(t,arguments)}:c.global?function(t){var e="on"+t.toLowerCase(),n=c.global[e];return!!n&&(n.apply(c.global,[].slice.call(arguments,1)),!0)}:function(){return!1};function j(t,e){return{promise:e}}var T={promiseCreated:j,promiseFulfilled:j,promiseRejected:j,promiseResolved:j,promiseCancelled:j,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:j},A=function(t){var e=!1;try{e=S.apply(null,arguments)}catch(t){u.throwLater(t),e=!0}var n=!1;try{n=E(t,T[t].apply(null,arguments))}catch(t){u.throwLater(t),n=!0}return n||e};function C(){return!1}function M(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+c.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function I(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?c.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function R(){return this._onCancelField}function L(t){this._onCancelField=t}function B(){this._cancellationParent=void 0,this._onCancelField=void 0}function F(t,e){if(0!=(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}n.config=function(t){if("longStackTraces"in(t=Object(t))&&(t.longStackTraces?n.longStackTraces():!t.longStackTraces&&n.hasLongStackTraces()&&k()),"warnings"in t){var e=t.warnings;K.warnings=!!e,x=K.warnings,c.isObject(e)&&"wForgottenReturn"in e&&(x=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!K.cancellation){if(u.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=B,n.prototype._propagateFrom=F,n.prototype._onCancel=R,n.prototype._setOnCancel=L,n.prototype._attachCancellationCallback=I,n.prototype._execute=M,P=F,K.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!K.monitoring?(K.monitoring=!0,n.prototype._fireEvent=A):!t.monitoring&&K.monitoring&&(K.monitoring=!1,n.prototype._fireEvent=C)),n},n.prototype._fireEvent=C,n.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(t){},n.prototype._attachCancellationCallback=function(t){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._dereferenceTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(t,e){};var P=function(t,e){0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)};function O(){var t=this._boundTo;return void 0!==t&&t instanceof n?t.isFulfilled()?t.value():void 0:t}function D(){this._trace=new J(this._peekContext())}function N(t,e){if(h(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=V(t);c.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),c.notEnumerableProp(t,"__stackCleaned__",!0)}}}function U(){this._trace=void 0}function z(t,e,r){if(K.warnings){var i,a=new l(t);if(e)r._attachExtraTrace(a);else if(K.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(a);else{var o=V(a);a.stack=o.message+"\n"+o.stack.join("\n")}A("warning",a)||G(a,"",!0)}}function q(t){for(var e=[],n=0;n0?function(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:q(e)}}function G(t,e,n){if("undefined"!=typeof console){var r;if(c.isObject(t)){var i=t.stack;r=e+m(i,t)}else r=e+String(t);"function"==typeof o?o(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function H(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){u.throwLater(t)}"unhandledRejection"===t?A(t,n,r)||i||G(n,"Unhandled rejection "):A(t,r)}function W(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():c.toString(t);if(/\[object [a-zA-Z0-9$_]+\]/.test(e))try{e=JSON.stringify(t)}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+function(t){if(t.length<41)return t;return t.substr(0,38)+"..."}(e)+">, no stack trace)"}function Z(){return"function"==typeof Q}var Y=function(){return!1},X=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function $(t){var e=t.match(X);if(e)return{fileName:e[1],line:parseInt(e[2],10)}}function J(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);Q(this,J),e>32&&this.uncycle()}c.inherits(J,Error),r.CapturedTrace=J,J.prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;for(r=(t=this._length=r)-1;r>=0;--r){var a=e[r].stack;void 0===n[a]&&(n[a]=r)}for(r=0;r0&&(e[o-1]._parent=void 0,e[o-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var s=r>0?e[r-1]:this;o=0;--l)e[l]._length=u,u++;return}}}},J.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=V(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(q(i.stack.split("\n"))),i=i._parent;!function(t){for(var e=t[0],n=1;n=0;--s)if(r[s]===a){o=s;break}for(s=o;s>=0;--s){var u=r[s];if(e[i]!==u)break;e.pop(),i--}e=r}}(r),function(t){for(var e=0;e=0)return g=/@/,m=e,_=!0,function(t){t.stack=(new Error).stack};try{throw new Error}catch(t){r="stack"in t}return"stack"in i||!r||"number"!=typeof Error.stackTraceLimit?(m=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?W(e):e.toString()},null):(g=t,m=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}();"undefined"!=typeof console&&void 0!==console.warn&&(o=function(t){console.warn(t)},c.isNode&&t.stderr.isTTY?o=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:c.isNode||"string"!=typeof(new Error).stack||(o=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var K={warnings:w,longStackTraces:!1,cancellation:!1,monitoring:!1};return b&&n.longStackTraces(),{longStackTraces:function(){return K.longStackTraces},warnings:function(){return K.warnings},cancellation:function(){return K.cancellation},monitoring:function(){return K.monitoring},propagateFromFunction:function(){return P},boundValueFunction:function(){return O},checkForgottenReturns:function(t,e,n,r,i){if(void 0===t&&null!==e&&x){if(void 0!==i&&i._returnedNonUndefined())return;if(0==(65535&r._bitField))return;n&&(n+=" ");var a="",o="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=q(s),l=u.length-1;l>=0;--l){var c=u[l];if(!d.test(c)){var f=c.match(v);f&&(a="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0){var h=u[0];for(l=0;l0&&(o="\n"+s[l-1]);break}}}var p="a promise was created in a "+n+"handler "+a+"but was not returned from it, see http://goo.gl/rRqMUw"+o;r._warn(p,!0,e)}},setBounds:function(t,e){if(Z()){for(var n,r,i=t.stack.split("\n"),a=e.stack.split("\n"),o=-1,s=-1,u=0;u=s||(Y=function(t){if(p.test(t))return!0;var e=$(t);return!!(e&&e.fileName===n&&o<=e.line&&e.line<=s)})}},warn:z,deprecated:function(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),z(n)},CapturedTrace:J,fireDomEvent:E,fireGlobalEvent:S}}},{"./errors":12,"./es5":13,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype.return=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1];return this.caught(t,function(){throw e})},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();return this.caught(n,function(){return r})}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){var n=t.reduce,r=t.all;function i(){return r(this)}t.prototype.each=function(t){return n(this,t,e,0)._then(i,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return n(this,t,e,e)},t.each=function(t,r){return n(t,r,e,0)._then(i,void 0,void 0,t,void 0)},t.mapSeries=function(t,r){return n(t,r,e,e)}}},{}],12:[function(t,e,n){"use strict";var r,i,a=t("./es5"),o=a.freeze,s=t("./util"),u=s.inherits,l=s.notEnumerableProp;function c(t,e){function n(r){if(!(this instanceof n))return new n(r);l(this,"message","string"==typeof r?r:e),l(this,"name",t),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return u(n,Error),n}var f=c("Warning","warning"),h=c("CancellationError","cancellation error"),p=c("TimeoutError","timeout error"),d=c("AggregateError","aggregate error");try{r=TypeError,i=RangeError}catch(t){r=c("TypeError","type error"),i=c("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0)}function f(){return p.call(this,this.promise._target()._settledValue())}function h(t){if(!c(this,t))return o.e=t,o}function p(t){var i=this.promise,s=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?s.call(i._boundValue()):s.call(i._boundValue(),t);if(u===r)return u;if(void 0!==u){i._setReturnedNonUndefined();var p=n(u,i);if(p instanceof e){if(null!=this.cancelPromise){if(p._isCancelled()){var d=new a("late cancellation observer");return i._attachExtraTrace(d),o.e=d,o}p.isPending()&&p._attachCancellationCallback(new l(this))}return p._then(f,h,void 0,this,void 0)}}}return i.isRejected()?(c(this),o.e=t,o):(c(this),t)}return u.prototype.isFinallyHandler=function(){return 0===this.type},l.prototype._resultCancelled=function(){c(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new u(this,e,t),void 0)},e.prototype.lastly=e.prototype.finally=function(t){return this._passThrough(t,0,p,p)},e.prototype.tap=function(t){return this._passThrough(t,1,p)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,p);var r,a=new Array(n-1),o=0;for(r=0;r0&&"function"==typeof arguments[e]&&(t=arguments[e]);var r=[].slice.call(arguments);t&&r.pop();var i=new n(r).promise();return void 0!==t?i.spread(t):i}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=e._getDomain,u=t("./util"),l=u.tryCatch,c=u.errorObj,f=e._async;function h(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=s();this._callback=null===i?e:u.domainBind(i,e),this._preservedValues=r===a?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=[],f.invoke(this._asyncInit,this,void 0)}function p(t,n,i,a){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var o=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));o=i.concurrency}return new h(t,n,o="number"==typeof o&&isFinite(o)&&o>=1?o:0,a).promise()}u.inherits(h,n),h.prototype._asyncInit=function(){this._init$(void 0,-2)},h.prototype._init=function(){},h.prototype._promiseFulfilled=function(t,n){var r=this._values,a=this.length(),s=this._preservedValues,u=this._limit;if(n<0){if(r[n=-1*n-1]=t,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=t,this._queue.push(n),!1;null!==s&&(s[n]=t);var f=this._promise,h=this._callback,p=f._boundValue();f._pushContext();var d=l(h).call(p,t,n,a),v=f._popContext();if(o.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",f),d===c)return this._reject(d.e),!0;var g=i(d,this._promise);if(g instanceof e){var m=(g=g._target())._bitField;if(0==(50397184&m))return u>=1&&this._inFlight++,r[n]=g,g._proxy(this,-1*(n+1)),!1;if(0==(33554432&m))return 0!=(16777216&m)?(this._reject(g._reason()),!0):(this._cancel(),!0);d=g._value()}r[n]=d}return++this._totalResolved>=a&&(null!==s?this._filter(r,s):this._resolve(r),!0)},h.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlight1){a.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],c=arguments[2];r=o.isArray(l)?s(t).apply(c,l):s(t).call(c,l)}else r=s(t)();var f=u._popContext();return a.checkForgottenReturns(r,f,"Promise.try",u),u._resolveFromSyncValue(r),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";var r=t("./util"),i=r.maybeWrapAsError,a=t("./errors").OperationalError,o=t("./es5");var s=/^(?:name|message|stack|cause)$/;function u(t){var e;if(function(t){return t instanceof Error&&o.getPrototypeOf(t)===Error.prototype}(t)){(e=new a(t)).name=t.name,e.message=t.message,e.stack=t.stack;for(var n=o.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;n0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+l.classString(t);arguments.length>1&&(n+=", "+l.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},C.prototype.done=function(t,e){this._then(t,e,void 0,void 0,void 0)._setIsFinal()},C.prototype.spread=function(t){return"function"!=typeof t?a("expecting a function but got "+l.classString(t)):this.all()._then(t,void 0,void 0,m,void 0)},C.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},C.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new w(this).promise()},C.prototype.error=function(t){return this.caught(l.originatesFromRejection,t)},C.getNewLibraryCopy=n.exports,C.is=function(t){return t instanceof C},C.fromNode=C.fromCallback=function(t){var e=new C(g);e._captureStackTrace();var n=arguments.length>1&&!!Object(arguments[1]).multiArgs,r=A(t)(j(e,n));return r===T&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},C.all=function(t){return new w(t).promise()},C.cast=function(t){var e=y(t);return e instanceof C||((e=new C(g))._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},C.resolve=C.fulfilled=C.cast,C.reject=C.rejected=function(t){var e=new C(g);return e._captureStackTrace(),e._rejectCallback(t,!0),e},C.setScheduler=function(t){if("function"!=typeof t)throw new d("expecting a function but got "+l.classString(t));return h.setScheduler(t)},C.prototype._then=function(t,e,n,r,i){var a=void 0!==i,o=a?i:new C(g),u=this._target(),c=u._bitField;a||(o._propagateFrom(this,3),o._captureStackTrace(),void 0===r&&0!=(2097152&this._bitField)&&(r=0!=(50397184&c)?this._boundValue():u===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,o));var f=s();if(0!=(50397184&c)){var p,d,m=u._settlePromiseCtx;0!=(33554432&c)?(d=u._rejectionHandler0,p=t):0!=(16777216&c)?(d=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(m=u._settlePromiseLateCancellationObserver,d=new v("late cancellation observer"),u._attachExtraTrace(d),p=e),h.invoke(m,u,{handler:null===f?p:"function"==typeof p&&l.domainBind(f,p),promise:o,receiver:r,value:d})}else u._addCallbacks(t,e,o,r,f);return o},C.prototype._length=function(){return 65535&this._bitField},C.prototype._isFateSealed=function(){return 0!=(117506048&this._bitField)},C.prototype._isFollowing=function(){return 67108864==(67108864&this._bitField)},C.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},C.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},C.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},C.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},C.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},C.prototype._isFinal=function(){return(4194304&this._bitField)>0},C.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},C.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},C.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},C.prototype._setAsyncGuaranteed=function(){h.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},C.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==u)return void 0===e&&this._isBound()?this._boundValue():e},C.prototype._promiseAt=function(t){return this[4*t-4+2]},C.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},C.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},C.prototype._boundValue=function(){},C.prototype._migrateCallback0=function(t){t._bitField;var e=t._fulfillmentHandler0,n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=u),this._addCallbacks(e,n,r,i,null)},C.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),a=t._receiverAt(e);void 0===a&&(a=u),this._addCallbacks(n,r,i,a,null)},C.prototype._addCallbacks=function(t,e,n,r,i){var a=this._length();if(a>=65531&&(a=0,this._setLength(0)),0===a)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:l.domainBind(i,e));else{var o=4*a-4;this[o+2]=n,this[o+3]=r,"function"==typeof t&&(this[o+0]=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this[o+1]=null===i?e:l.domainBind(i,e))}return this._setLength(a+1),a},C.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},C.prototype._resolveCallback=function(t,e){if(0==(117506048&this._bitField)){if(t===this)return this._rejectCallback(r(),!1);var n=y(t,this);if(!(n instanceof C))return this._fulfill(t);e&&this._propagateFrom(n,2);var i=n._target();if(i!==this){var a=i._bitField;if(0==(50397184&a)){var o=this._length();o>0&&i._migrateCallback0(this);for(var s=1;s>>16)){if(t===this){var n=r();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!=(134217728&e)?this._settlePromises():h.settlePromises(this),this._dereferenceTrace())}},C.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(this._setRejected(),this._fulfillmentHandler0=t,this._isFinal())return h.fatalError(t,l.isNode);(65535&e)>0?h.settlePromises(this):this._ensurePossibleRejectionHandled()}},C.prototype._fulfillPromises=function(t,e){for(var n=1;n0){if(0!=(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},C.prototype._settledValue=function(){var t=this._bitField;return 0!=(33554432&t)?this._rejectionHandler0:0!=(16777216&t)?this._fulfillmentHandler0:void 0},C.defer=C.pending=function(){return k.deprecated("Promise.defer","new Promise"),{promise:new C(g),resolve:M,reject:I}},l.notEnumerableProp(C,"_makeSelfResolutionError",r),e("./method")(C,g,y,a,k),e("./bind")(C,g,y,k),e("./cancel")(C,w,a,k),e("./direct_resolve")(C),e("./synchronous_inspection")(C),e("./join")(C,w,y,g,h,s),C.Promise=C,C.version="3.5.2",e("./map.js")(C,w,a,y,g,k),e("./call_get.js")(C),e("./using.js")(C,a,y,x,g,k),e("./timers.js")(C,g,k),e("./generators.js")(C,a,g,y,o,k),e("./nodeify.js")(C),e("./promisify.js")(C,g),e("./props.js")(C,w,y,a),e("./race.js")(C,g,y,a),e("./reduce.js")(C,w,a,y,g,k),e("./settle.js")(C,w,k),e("./some.js")(C,w,a),e("./filter.js")(C,g),e("./each.js")(C,g),e("./any.js")(C),l.toFastProperties(C),l.toFastProperties(C.prototype),R({a:1}),R({b:2}),R({c:3}),R(1),R(function(){}),R(void 0),R(!1),R(new C(g)),k.setBounds(f.firstLineError,l.lastLineError),C}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a){var o=t("./util");o.isArray;function s(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return o.inherits(s,a),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function t(n,a){var s=r(this._values,this._promise);if(s instanceof e){var u=(s=s._target())._bitField;if(this._values=s,0==(50397184&u))return this._promise._setAsyncGuaranteed(),s._then(t,this._reject,void 0,this,a);if(0==(33554432&u))return 0!=(16777216&u)?this._reject(s._reason()):this._cancel();s=s._value()}if(null!==(s=o.asArray(s)))0!==s.length?this._iterate(s):-5===a?this._resolveEmptyArray():this._resolve(function(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}(a));else{var l=i("expecting an array or an iterable object but got "+o.classString(s)).reason();this._promise._rejectCallback(l,!1)}},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,a=!1,o=null,s=0;s=this._length&&(this._resolve(this._values),!0)},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n=this._length){var n;if(this._isMap)n=function(t){for(var e=new a,n=t.length/2|0,r=0;r>1},e.prototype.props=function(){return f(this)},e.props=function(t){return f(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t){this._capacity=t,this._length=0,this._front=0}r.prototype._willBeOverCapacity=function(t){return this._capacity=this._length&&(this._resolve(this._values),!0)},a.prototype._promiseFulfilled=function(t,e){var n=new i;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},a.prototype._promiseRejected=function(t,e){var n=new i;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new a(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=t("./errors").RangeError,o=t("./errors").AggregateError,s=i.isArray,u={};function l(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function c(t,e){if((0|e)!==e||e<0)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new l(t),i=n.promise();return n.setHowMany(e),n.init(),i}i.inherits(l,n),l.prototype._init=function(){if(this._initialized)if(0!==this._howMany){this._init$(void 0,-5);var t=s(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}else this._resolve([])},l.prototype.init=function(){this._initialized=!0,this._init()},l.prototype.setUnwrap=function(){this._unwrap=!0},l.prototype.howMany=function(){return this._howMany},l.prototype.setHowMany=function(t){this._howMany=t},l.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0)},l.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},l.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(u),this._checkOutcome())},l.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new o,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},l.prototype._fulfilled=function(){return this._totalResolved},l.prototype._rejected=function(){return this._values.length-this.length()},l.prototype._addRejected=function(t){this._values.push(t)},l.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},l.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},l.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},l.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return c(t,e)},e.prototype.some=function(t){return c(this,t)},e._SomePromiseArray=l}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!=(33554432&this._bitField)},a=e.prototype.isRejected=function(){return 0!=(16777216&this._bitField)},o=e.prototype.isPending=function(){return 0==(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!=(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!=(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536==(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!=(8454144&this._target()._bitField)},t.prototype.isPending=function(){return o.call(this._target())},t.prototype.isRejected=function(){return a.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){var r=t("./util"),i=r.errorObj,a=r.isObject;var o={}.hasOwnProperty;return function(t,s){if(a(t)){if(t instanceof e)return t;var u=function(t){try{return function(t){return t.then}(t)}catch(t){return i.e=t,i}}(t);if(u===i){s&&s._pushContext();var l=e.reject(u.e);return s&&s._popContext(),l}if("function"==typeof u)return function(t){try{return o.call(t,"_promise0")}catch(t){return!1}}(t)?(l=new e(n),t._then(l._fulfill,l._reject,void 0,l,null),l):function(t,a,o){var s=new e(n),u=s;o&&o._pushContext(),s._captureStackTrace(),o&&o._popContext();var l=!0,c=r.tryCatch(a).call(t,function(t){s&&(s._resolveCallback(t),s=null)},function(t){s&&(s._rejectCallback(t,l,!0),s=null)});return l=!1,s&&c===i&&(s._rejectCallback(c.e,!0,!0),s=null),u}(t,u,s)}return t}}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=e.TimeoutError;function o(t){this.handle=t}o.prototype._resultCancelled=function(){clearTimeout(this.handle)};var s=function(t){return u(+this).thenReturn(t)},u=e.delay=function(t,i){var a,u;return void 0!==i?(a=e.resolve(i)._then(s,null,null,t,void 0),r.cancellation()&&i instanceof e&&a._setOnCancel(i)):(a=new e(n),u=setTimeout(function(){a._fulfill()},+t),r.cancellation()&&a._setOnCancel(new o(u)),a._captureStackTrace()),a._setAsyncGuaranteed(),a};e.prototype.delay=function(t){return u(t,this)};function l(t){return clearTimeout(this.handle),t}function c(t){throw clearTimeout(this.handle),t}e.prototype.timeout=function(t,e){var n,s;t=+t;var u=new o(setTimeout(function(){n.isPending()&&function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new a("operation timed out"):new a(e),i.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()}(n,e,s)},t));return r.cancellation()?(s=this.then(),(n=s._then(l,c,void 0,u,void 0))._setOnCancel(u)):n=this._then(l,c,void 0,u,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=t("./util"),u=t("./errors").TypeError,l=t("./util").inherits,c=s.errorObj,f=s.tryCatch,h={};function p(t){setTimeout(function(){throw t},0)}function d(t,n){var i=0,o=t.length,s=new e(a);return function a(){if(i>=o)return s._fulfill();var u=function(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}(t[i++]);if(u instanceof e&&u._isDisposable()){try{u=r(u._getDisposer().tryDispose(n),t.promise)}catch(t){return p(t)}if(u instanceof e)return u._then(a,p,null,null,null)}a()}(),s}function v(t,e,n){this._data=t,this._promise=e,this._context=n}function g(t,e,n){this.constructor$(t,e,n)}function m(t){return v.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function _(t){this.length=t,this.promise=null,this[t-1]=null}v.prototype.data=function(){return this._data},v.prototype.promise=function(){return this._promise},v.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():h},v.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==h?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},v.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},l(g,v),g.prototype.doDispose=function(t,e){return this.data().call(t,t,e)},_.prototype._resultCancelled=function(){for(var t=this.length,n=0;n0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new g(t,this,i());throw new u}}},{"./errors":12,"./util":36}],36:[function(e,n,i){"use strict";var a=e("./es5"),o="undefined"==typeof navigator,s={e:{}},u,l="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r?r:void 0!==this?this:null;function c(){try{var t=u;return u=null,t.apply(this,arguments)}catch(t){return s.e=t,s}}function f(t){return u=t,c}var h=function(t,e){var n={}.hasOwnProperty;function r(){for(var r in this.constructor=t,this.constructor$=e,e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}return r.prototype=e.prototype,t.prototype=new r,t.prototype};function p(t){return null==t||!0===t||!1===t||"string"==typeof t||"number"==typeof t}function d(t){return"function"==typeof t||"object"==typeof t&&null!==t}function v(t){return p(t)?new Error(T(t)):t}function g(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;n1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=b.test(t+"")&&a.names(t).length>0;if(n||r||i)return!0}return!1}catch(t){return!1}}function k(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.foo}return r(),r(),t}var E=/^[a-z$_][a-z$_0-9]*$/i;function S(t){return E.test(t)}function j(t,e,n){for(var r=new Array(t),i=0;i10||V[0]>0),q.isNode&&q.toFastProperties(t);try{throw new Error}catch(t){q.lastLineError=t}n.exports=q},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{_process:117,timers:142}],4:[function(t,e,n){},{}],5:[function(t,e,n){"use strict";var r=t("base64-js"),i=t("ieee754");n.Buffer=s,n.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},n.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(t)}return u(t,e,n)}function u(t,e,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return U(t)?function(t,e,n){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(z(t)||U(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return O(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return D(t).length;default:if(r)return O(t).length;e=(""+e).toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,i){var a,o=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,s/=2,u/=2,n/=2}function l(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(a=n;as&&(n=s-u),a=n;a>=0;a--){for(var f=!0,h=0;hi&&(r=i):r=i;var a=e.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o>8,i=n%256,a.push(i),a.push(r);return a}(e,t.length-n),t,n,r)}function k(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function E(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:l>223?3:l>191?2:1;if(i+f<=n)switch(f){case 1:l<128&&(c=l);break;case 2:128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)>127&&(c=u);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(u=(15&l)<<12|(63&a)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=f}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,n);case"utf8":case"utf-8":return E(this,e,n);case"ascii":return j(this,e,n);case"latin1":case"binary":return T(this,e,n);case"base64":return k(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var a=i-r,o=n-e,u=Math.min(a,o),l=this.slice(r,i),c=t.slice(e,n),f=0;f>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return y(this,t,e,n);case"latin1":case"binary":return w(this,t,e,n);case"base64":return b(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function j(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",a=e;an)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,n,r,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,n,r,i,a){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,a){return e=+e,n>>>=0,a||R(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,a){return e=+e,n>>>=0,a||R(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t],i=1,a=0;++a>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t],i=1,a=0;++a=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||M(t,e,this.length);for(var r=e,i=1,a=this[t+--r];r>0&&(i*=256);)a+=this[t+--r]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||I(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,n>>>=0,r)||I(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);I(this,t,e,n,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);I(this,t,e,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(a<1e3)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;a.push(n)}else if(n<2048){if((e-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function D(t){return r.toByteArray(function(t){if((t=t.trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function U(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function z(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function q(t){return t!=t}},{"base64-js":1,ieee754:60}],6:[function(t,e,n){(function(n){var r=t("tty"),i=t("./lib/encode"),a=t("stream").Stream,o=e.exports=function(){var t=null;function e(e){if(t)throw new Error("multiple inputs specified");t=e}var i=null;function a(t){if(i)throw new Error("multiple outputs specified");i=t}for(var o=0;o0&&this.down(e),t>0?this.right(t):t<0&&this.left(-t),this},s.prototype.up=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"A")),this},s.prototype.down=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"B")),this},s.prototype.right=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"C")),this},s.prototype.left=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"D")),this},s.prototype.column=function(t){return this.write(i("["+Math.floor(t)+"G")),this},s.prototype.push=function(t){return this.write(i(t?"7":"[s")),this},s.prototype.pop=function(t){return this.write(i(t?"8":"[u")),this},s.prototype.erase=function(t){return"end"===t||"$"===t?this.write(i("[K")):"start"===t||"^"===t?this.write(i("[1K")):"line"===t?this.write(i("[2K")):"down"===t?this.write(i("[J")):"up"===t?this.write(i("[1J")):"screen"===t?this.write(i("[1J")):this.emit("error",new Error("Unknown erase type: "+t)),this},s.prototype.display=function(t){var e={reset:0,bright:1,dim:2,underscore:4,blink:5,reverse:7,hidden:8}[t];return void 0===e&&this.emit("error",new Error("Unknown attribute: "+t)),this.write(i("["+e+"m")),this},s.prototype.foreground=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[38;5;"+t+"m"));else{var e={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.background=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[48;5;"+t+"m"));else{var e={black:40,red:41,green:42,yellow:43,blue:44,magenta:45,cyan:46,white:47}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.cursor=function(t){return this.write(i(t?"[?25h":"[?25l")),this};var u=o.extractCodes=function(t){for(var e=[],n=-1,r=0;r=0&&e.push(t.slice(n,r)),n=r):n>=0&&r===t.length-1&&e.push(t.slice(n));return e}}).call(this,t("_process"))},{"./lib/encode":7,_process:117,stream:139,tty:143}],7:[function(t,e,n){(function(t){var n=(e.exports=function(e){return new t([27].concat(function t(e){return"string"==typeof e?e.split("").map(n):Array.isArray(e)?e.reduce(function(e,n){return e.concat(t(n))},[]):void 0}(e)))}).ord=function(t){return t.charCodeAt(0)}}).call(this,t("buffer").Buffer)},{buffer:5}],8:[function(t,e,n){(function(n){"use strict";var r=t("readable-stream").Readable,i=t("util");function a(t,e){if(!(this instanceof a))return new a(t,e);r.call(this,e),null!==t&&void 0!==t||(t=String(t)),this._obj=t}e.exports=a,i.inherits(a,r),a.prototype._read=function(t){var e=this._obj;"string"==typeof e?this.push(new n(e)):n.isBuffer(e)?this.push(e):this.push(new n(JSON.stringify(e))),this.push(null)}}).call(this,t("buffer").Buffer)},{buffer:5,"readable-stream":14,util:150}],9:[function(t,e,n){(function(n){e.exports=s;var r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},i=t("core-util-is");i.inherits=t("inherits");var a=t("./_stream_readable"),o=t("./_stream_writable");function s(t){if(!(this instanceof s))return new s(t);a.call(this,t),o.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",u)}function u(){this.allowHalfOpen||this._writableState.ended||n.nextTick(this.end.bind(this))}i.inherits(s,a),function(t,e){for(var n=0,r=t.length;n0?d(t):w(t)}(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!o){var u=new Error("stream.push() after EOF");t.emit("error",u)}else if(e.endEmitted&&o){u=new Error("stream.unshift() after end event");t.emit("error",u)}else!e.decoder||o||a||(r=e.decoder.write(r)),e.length+=e.objectMode?1:r.length,o?e.buffer.unshift(r):(e.reading=!1,e.buffer.push(r)),e.needReadable&&d(t),function(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(function(){!function(t,e){var n=e.length;for(;!e.reading&&!e.flowing&&!e.ended&&e.lengthe.highWaterMark&&(e.highWaterMark=function(t){if(t>=h)t=h;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function d(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,e.sync?n.nextTick(function(){v(t)}):v(t))}function v(t){t.emit("readable")}function g(t){var e,n=t._readableState;function r(t,r,i){!1===t.write(e)&&n.awaitDrain++}for(n.awaitDrain=0;n.pipesCount&&null!==(e=t.read());)if(1===n.pipesCount?r(n.pipes):b(n.pipes,r),t.emit("data",e),n.awaitDrain>0)return;if(0===n.pipesCount)return n.flowing=!1,void(a.listenerCount(t,"data")>0&&_(t));n.ranOut=!0}function m(){this._readableState.ranOut&&(this._readableState.ranOut=!1,g(this))}function _(t,e){if(t._readableState.flowing)throw new Error("Cannot switch to old mode now.");var r=e||!1,i=!1;t.readable=!0,t.pipe=s.prototype.pipe,t.on=t.addListener=s.prototype.on,t.on("readable",function(){var e;for(i=!0;!r&&null!==(e=t.read());)t.emit("data",e);null===e&&(i=!1,t._readableState.needReadable=!0)}),t.pause=function(){r=!0,this.emit("pause")},t.resume=function(){r=!1,i?n.nextTick(function(){t.emit("readable")}):this.read(0),this.emit("resume")},t.emit("readable")}function y(t,e){var n,r=e.buffer,a=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===r.length)return null;if(0===a)n=null;else if(s)n=r.shift();else if(!t||t>=a)n=o?r.join(""):i.concat(r,a),r.length=0;else{if(t0)throw new Error("endReadable called on non-empty stream");!e.endEmitted&&e.calledRead&&(e.ended=!0,n.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function b(t,e){for(var n=0,r=t.length;n0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return d(this),null;if(0===(t=p(t,e))&&e.ended)return n=null,e.length>0&&e.decoder&&(n=y(t,e),e.length-=n.length),0===e.length&&w(this),n;var i=e.needReadable;return e.length-t<=e.highWaterMark&&(i=!0),(e.ended||e.reading)&&(i=!1),i&&(e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),i&&!e.reading&&(t=p(r,e)),null===(n=t>0?y(t,e):null)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),e.ended&&!e.endEmitted&&0===e.length&&w(this),n},c.prototype._read=function(t){this.emit("error",new Error("not implemented"))},c.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1;var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?l:f;function u(t){t===i&&f()}function l(){t.end()}o.endEmitted?n.nextTick(s):i.once("end",s),t.on("unpipe",u);var c=function(t){return function(){var e=t._readableState;e.awaitDrain--,0===e.awaitDrain&&g(t)}}(i);function f(){t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",u),i.removeListener("end",l),i.removeListener("end",f),t._writableState&&!t._writableState.needDrain||c()}function h(e){v(),t.removeListener("error",h),0===a.listenerCount(t,"error")&&t.emit("error",e)}function p(){t.removeListener("finish",d),v()}function d(){t.removeListener("close",p),v()}function v(){i.unpipe(t)}return t.on("drain",c),t._events&&t._events.error?r(t._events.error)?t._events.error.unshift(h):t._events.error=[h,t._events.error]:t.on("error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",i),o.flowing||(this.on("readable",m),o.flowing=!0,n.nextTick(function(){g(i)})),t},c.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===a){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(i),in.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,r(e)}},{"./lib/thunk.js":18}],17:[function(t,e,n){"use strict";var r=t("uniq");function i(t,e,n){var r,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,u=[],l=[],c=0,f=0;for(r=0;r0&&u.push("var "+l.join(",")),r=a-1;r>=0;--r)c=t[r],u.push(["for(i",r,"=0;i",r,"0&&u.push(["index[",f,"]-=s",f].join("")),u.push(["++index[",c,"]"].join(""))),u.push("}")}return u.join("\n")}function a(t,e,n){for(var r=t.body,i=[],a=[],o=0;o0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){var y=new Array(n);for(u=0;u0&&m.push("var "+_.join(",")),u=0;u3&&m.push(a(t.pre,t,s));var k=a(t.body,t,s),E=function(t){for(var e=0,n=t[0].length;e0,l=[],c=0;c0;){"].join("")),l.push(["if(j",c,"<",s,"){"].join("")),l.push(["s",e[c],"=j",c].join("")),l.push(["j",c,"=0"].join("")),l.push(["}else{s",e[c],"=",s].join("")),l.push(["j",c,"-=",s,"}"].join("")),u&&l.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var S=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",E,function(t){for(var e=new Array(t.length),n=!0,r=0;r0&&(n=n&&e[r]===e[r-1])}return n?e[0]:e.join("")}(s)].join("");return new Function(["function ",S,"(",g.join(","),"){",m.join("\n"),"} return ",S].join(""))()}},{uniq:146}],18:[function(t,e,n){"use strict";var r=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],n=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],l=[],c=0;c0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),l.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;c0)return function(t,e){var n,r;for(n=new Array(t),r=0;r 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],25:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat correctionRadius = 0.5;\n\tfloat distance = sqrt(vPosition.x * vPosition.x + vPosition.y * vPosition.y) / correctionRadius;\n\tfloat theta = 1.0;\n\tif(distance != 0.0){\n\t\ttheta = atan(distance);\n\t}\n\tvec2 vMapping = theta * vPosition.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\t\t\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],26:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 uLensS;\nuniform vec2 uLensF;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord * vec2(1.0, -1.0)/ 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat scale = uLensS.z;\n\tvec3 vPos = vPosition;\n\tfloat Fx = uLensF.x;\n\tfloat Fy = uLensF.y;\n\tvec2 vMapping = vPos.xy;\n\tvMapping.x = vMapping.x + ((pow(vPos.y, 2.0)/scale)*vPos.x/scale)*-Fx;\n\tvMapping.y = vMapping.y + ((pow(vPos.x, 2.0)/scale)*vPos.y/scale)*-Fy;\n\tvMapping = vMapping * uLensS.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping/scale);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t}\n\tgl_FragColor = texture;\n}\n"},{}],27:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TODO insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],28:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TOD insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],29:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvoid main(void){\n\tvPosition = aVertexPosition;\n\tvTextureCoord = aTextureCoord;\n\tgl_Position = vec4(vPosition,1.0);\n}\n"},{}],30:[function(t,e,n){(function(n,r){"use strict";var i=t("path"),a=t("ndarray"),o=t("omggif").GifReader,s=(t("ndarray-pack"),t("through"),t("data-uri-to-buffer"));function u(t,e){var n;try{n=new o(t)}catch(t){return void e(t)}if(n.numFrames()>0){var r=[n.numFrames(),n.height,n.width,4],i=new Uint8Array(r[0]*r[1]*r[2]*r[3]),s=a(i,r);try{for(var u=0;u=0&&(this.dispose=t)},u.prototype.setRepeat=function(t){this.repeat=t},u.prototype.setTransparent=function(t){this.transparent=t},u.prototype.analyzeImage=function(t){this.setImagePixels(this.removeAlphaChannel(t)),this.analyzePixels()},u.prototype.writeImageInfo=function(){this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.firstFrame=!1},u.prototype.outputImage=function(){this.writePixels()},u.prototype.addFrame=function(t){this.emit("frame#start"),this.analyzeImage(t),this.writeImageInfo(),this.outputImage(),this.emit("frame#stop")},u.prototype.finish=function(){this.emit("finish#start"),this.writeByte(59),this.emit("finish#stop")},u.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},u.prototype.writeHeader=function(){this.emit("writeHeader#start"),this.writeUTFBytes("GIF89a"),this.emit("writeHeader#stop")},u.prototype.analyzePixels=function(){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);var e=new a(this.pixels,this.sample);e.buildColormap(),this.colorTab=e.getColormap();for(var n=0,r=0;r>16,n=(65280&t)>>8,r=255&t,i=0,a=16777216,o=this.colorTab.length,s=0;s=0&&(e=7&dispose),e<<=2,this.writeByte(0|e|t),this.writeShort(this.delay),this.writeByte(this.transIndex),this.writeByte(0)},u.prototype.writeImageDesc=function(){this.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.writeByte(0):this.writeByte(128|this.palSize)},u.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.writeByte(240|this.palSize),this.writeByte(0),this.writeByte(0)},u.prototype.writeNetscapeExt=function(){this.writeByte(33),this.writeByte(255),this.writeByte(11),this.writeUTFBytes("NETSCAPE2.0"),this.writeByte(3),this.writeByte(1),this.writeShort(this.repeat),this.writeByte(0)},u.prototype.writePalette=function(){this.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},u.prototype.writePixels=function(){new o(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this)},u.prototype.stream=function(){return this},u.ByteCapacitor=s,e.exports=u}).call(this,t("buffer").Buffer)},{"./LZWEncoder.js":33,"./TypedNeuQuant.js":34,assert:41,buffer:5,events:48,"readable-stream":40,util:150}],33:[function(t,e,n){var r=-1,i=12,a=5003,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,n,s){var u,l,c,f,h,p,d,v,g,m=Math.max(2,s),_=new Uint8Array(256),y=new Int32Array(a),w=new Int32Array(a),b=0,x=0,k=!1;function E(t,e){_[l++]=t,l>=254&&T(e)}function S(t){j(a),x=v+2,k=!0,M(v,t)}function j(t){for(var e=0;e0&&(t.writeByte(l),t.writeBytes(_,0,l),l=0)}function A(t){return(1<0?u|=t<=8;)E(255&u,e),u>>=8,b-=8;if((x>c||k)&&(k?(c=A(p=d),k=!1):c=++p==i?1<0;)E(255&u,e),u>>=8,b-=8;T(e)}}this.encode=function(n){n.writeByte(m),f=t*e,h=0,function(t,e){var n,o,s,u,f,h,m;for(k=!1,c=A(p=d=t),g=1+(v=1<=0){f=h-s,0===s&&(f=1);do{if((s-=f)<0&&(s+=h),y[s]===n){u=w[s];continue t}}while(y[s]>=0)}M(u,e),u=o,x<1<>c,h=u<>3)*(1<l;)u=T[p++],fl&&((s=n[h--])[0]-=u*(s[0]-r)/_,s[1]-=u*(s[1]-a)/_,s[2]-=u*(s[2]-o)/_)}function M(t,e,r){var a,u,p,d,v,g=~(1<<31),m=g,_=-1,y=_;for(a=0;a>s-o))>c,j[a]-=v,S[a]+=v<>3),t=0;t>p;for(j<=1&&(j=0),n=0;n=c&&(I-=c),n++,0===_&&(_=1),n%_==0)for(E-=E/f,(j=(S-=S/v)>>p)<=1&&(j=0),l=0;l>=o,n[t][1]>>=o,n[t][2]>>=o,n[t][3]=t}(),function(){var t,e,r,o,s,u,l=0,c=0;for(t=0;t>1,e=l+1;e>1,e=l+1;e<256;e++)E[e]=a}()},this.getColormap=function(){for(var t=[],e=[],r=0;r=0;)c=u?c=i:(c++,s<0&&(s=-s),(a=o[0]-t)<0&&(a=-a),(s+=a)=0&&((s=e-(o=n[f])[1])>=u?f=-1:(f--,s<0&&(s=-s),(a=o[0]-t)<0&&(a=-a),(s+=a)0)if(e.ended&&!a){var s=new Error("stream.push() after EOF");t.emit("error",s)}else if(e.endEmitted&&a){s=new Error("stream.unshift() after end event");t.emit("error",s)}else!e.decoder||a||i||(r=e.decoder.write(r)),a||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,a?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&v(t)),function(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(function(){!function(t,e){var n=e.length;for(;!e.reading&&!e.flowing&&!e.ended&&e.lengthe.highWaterMark&&(e.highWaterMark=function(t){if(t>=p)t=p;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function v(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(function(){g(t)}):g(t))}function g(t){l("emit readable"),t.emit("readable"),m(t)}function m(t){var e=t._readableState;if(l("flow",e.flowing),e.flowing)do{var n=t.read()}while(null!==n&&e.flowing)}function _(t,e){var n,r=e.buffer,a=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===r.length)return null;if(0===a)n=null;else if(s)n=r.shift();else if(!t||t>=a)n=o?r.join(""):i.concat(r,a),r.length=0;else{if(t0)throw new Error("endReadable called on non-empty stream");e.endEmitted||(e.ended=!0,n.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}f.prototype.read=function(t){l("read",t);var e=this._readableState,n=t;if((!u.isNumber(t)||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?y(this):v(this),null;if(0===(t=d(t,e))&&e.ended)return 0===e.length&&y(this),null;var r,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?_(t,e):null,u.isNull(r)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),n!==t&&e.ended&&0===e.length&&y(this),u.isNull(r)||this.emit("data",r),r},f.prototype._read=function(t){this.emit("error",new Error("not implemented"))},f.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?c:h;function u(t){l("onunpipe"),t===i&&h()}function c(){l("onend"),t.end()}o.endEmitted?n.nextTick(s):i.once("end",s),t.on("unpipe",u);var f=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a.listenerCount(t,"data")&&(e.flowing=!0,m(t))}}(i);function h(){l("cleanup"),t.removeListener("close",v),t.removeListener("finish",g),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",u),i.removeListener("end",c),i.removeListener("end",h),i.removeListener("data",p),!o.awaitDrain||t._writableState&&!t._writableState.needDrain||f()}function p(e){l("ondata"),!1===t.write(e)&&(l("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,i.pause())}function d(e){l("onerror",e),_(),t.removeListener("error",d),0===a.listenerCount(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",g),_()}function g(){l("onfinish"),t.removeListener("close",v),_()}function _(){l("unpipe"),i.unpipe(t)}return t.on("drain",f),i.on("data",p),t._events&&t._events.error?r(t._events.error)?t._events.error.unshift(d):t._events.error=[d,t._events.error]:t.on("error",d),t.once("close",v),t.once("finish",g),t.emit("pipe",i),o.flowing||(l("pipe resume"),i.resume()),t},f.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i1){for(var n=[],r=0;r=0;l--)if(c[l]!==f[l])return!1;for(l=c.length-1;l>=0;l--)if(u=c[l],!_(t[u],e[u],n,r))return!1;return!0}(t,e,n,o))}return n?t===e:t==e}function y(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function w(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function b(t,e,n,r){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),t&&!i&&g(i,n,"Missing expected exception"+r);var o="string"==typeof r,s=!t&&a.isError(i),u=!t&&i&&!n;if((s&&o&&w(i,n)||u)&&g(i,n,"Got unwanted exception"+r),t&&i&&n&&!w(i,n)||!t&&i)throw i}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=d(v((e=this).actual),128)+" "+e.operator+" "+d(v(e.expected),128),this.generatedMessage=!0);var n=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,a=p(n),o=i.indexOf("\n"+a);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},a.inherits(f.AssertionError,Error),f.fail=g,f.ok=m,f.equal=function(t,e,n){t!=e&&g(t,e,n,"==",f.equal)},f.notEqual=function(t,e,n){t==e&&g(t,e,n,"!=",f.notEqual)},f.deepEqual=function(t,e,n){_(t,e,!1)||g(t,e,n,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,n){_(t,e,!0)||g(t,e,n,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,n){_(t,e,!1)&&g(t,e,n,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,n,r){_(e,n,!0)&&g(e,n,r,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,n){t!==e&&g(t,e,n,"===",f.strictEqual)},f.notStrictEqual=function(t,e,n){t===e&&g(t,e,n,"!==",f.notStrictEqual)},f.throws=function(t,e,n){b(!0,t,e,n)},f.doesNotThrow=function(t,e,n){b(!1,t,e,n)},f.ifError=function(t){if(t)throw t};var x=Object.keys||function(t){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":44}],42:[function(t,e,n){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},{}],43:[function(t,e,n){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],44:[function(t,e,n){(function(e,r){var i=/%[sdj%]/g;n.format=function(t){if(!m(t)){for(var e=[],n=0;n=a)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),u=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),c(r,t,r.depth)}function u(t,e){var n=s.styles[e];return n?"["+s.colors[n][0]+"m"+t+"["+s.colors[n][1]+"m":t}function l(t,e){return t}function c(t,e,r){if(t.customInspect&&e&&k(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return m(i)||(i=c(t,i,r)),i}var a=function(t,e){if(_(e))return t.stylize("undefined","undefined");if(m(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(g(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(v(e))return t.stylize("null","null")}(t,e);if(a)return a;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),x(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(k(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(y(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(b(e))return t.stylize(Date.prototype.toString.call(e),"date");if(x(e))return f(e)}var l,w="",E=!1,S=["{","}"];(p(e)&&(E=!0,S=["[","]"]),k(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return y(e)&&(w=" "+RegExp.prototype.toString.call(e)),b(e)&&(w=" "+Date.prototype.toUTCString.call(e)),x(e)&&(w=" "+f(e)),0!==o.length||E&&0!=e.length?r<0?y(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),l=E?function(t,e,n,r,i){for(var a=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(l,w,S)):S[0]+w+S[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,n,r,i,a){var o,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),T(r,i)||(o="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=v(n)?c(t,u.value,null):c(t,u.value,n-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),_(o)){if(a&&i.match(/^\d+$/))return s;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function v(t){return null===t}function g(t){return"number"==typeof t}function m(t){return"string"==typeof t}function _(t){return void 0===t}function y(t){return w(t)&&"[object RegExp]"===E(t)}function w(t){return"object"==typeof t&&null!==t}function b(t){return w(t)&&"[object Date]"===E(t)}function x(t){return w(t)&&("[object Error]"===E(t)||t instanceof Error)}function k(t){return"function"==typeof t}function E(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}n.debuglog=function(t){if(_(a)&&(a=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var r=e.pid;o[t]=function(){var e=n.format.apply(n,arguments);console.error("%s %d: %s",t,r,e)}}else o[t]=function(){};return o[t]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=v,n.isNullOrUndefined=function(t){return null==t},n.isNumber=g,n.isString=m,n.isSymbol=function(t){return"symbol"==typeof t},n.isUndefined=_,n.isRegExp=y,n.isObject=w,n.isDate=b,n.isError=x,n.isFunction=k,n.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},n.isBuffer=t("./support/isBuffer");var j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(t,e){return Object.prototype.hasOwnProperty.call(t,e)}n.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":"),[t.getDate(),j[t.getMonth()],e].join(" ")),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":43,_process:117,inherits:42}],45:[function(t,e,n){(function(e,r){"use strict";var i=t("assert"),a=t("pako/lib/zlib/zstream"),o=t("pako/lib/zlib/deflate.js"),s=t("pako/lib/zlib/inflate.js"),u=t("pako/lib/zlib/constants");for(var l in u)n[l]=u[l];n.NONE=0,n.DEFLATE=1,n.INFLATE=2,n.GZIP=3,n.GUNZIP=4,n.DEFLATERAW=5,n.INFLATERAW=6,n.UNZIP=7;function c(t){if("number"!=typeof t||tn.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}c.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,i(this.init_done,"close before init"),i(this.mode<=n.UNZIP),this.mode===n.DEFLATE||this.mode===n.GZIP||this.mode===n.DEFLATERAW?o.deflateEnd(this.strm):this.mode!==n.INFLATE&&this.mode!==n.GUNZIP&&this.mode!==n.INFLATERAW&&this.mode!==n.UNZIP||s.inflateEnd(this.strm),this.mode=n.NONE,this.dictionary=null)},c.prototype.write=function(t,e,n,r,i,a,o){return this._write(!0,t,e,n,r,i,a,o)},c.prototype.writeSync=function(t,e,n,r,i,a,o){return this._write(!1,t,e,n,r,i,a,o)},c.prototype._write=function(t,a,o,s,u,l,c,f){if(i.equal(arguments.length,8),i(this.init_done,"write before init"),i(this.mode!==n.NONE,"already finalized"),i.equal(!1,this.write_in_progress,"write already in progress"),i.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,i.equal(!1,void 0===a,"must provide flush value"),this.write_in_progress=!0,a!==n.Z_NO_FLUSH&&a!==n.Z_PARTIAL_FLUSH&&a!==n.Z_SYNC_FLUSH&&a!==n.Z_FULL_FLUSH&&a!==n.Z_FINISH&&a!==n.Z_BLOCK)throw new Error("Invalid flush value");if(null==o&&(o=r.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=o,this.strm.next_in=s,this.strm.avail_out=f,this.strm.output=l,this.strm.next_out=c,this.flush=a,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return e.nextTick(function(){h._process(),h._after()}),this},c.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},c.prototype._process=function(){var t=null;switch(this.mode){case n.DEFLATE:case n.GZIP:case n.DEFLATERAW:this.err=o.deflate(this.strm,this.flush);break;case n.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=n.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=n.GUNZIP):this.mode=n.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case n.INFLATE:case n.GUNZIP:case n.INFLATERAW:for(this.err=s.inflate(this.strm,this.flush),this.err===n.Z_NEED_DICT&&this.dictionary&&(this.err=s.inflateSetDictionary(this.strm,this.dictionary),this.err===n.Z_OK?this.err=s.inflate(this.strm,this.flush):this.err===n.Z_DATA_ERROR&&(this.err=n.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===n.GUNZIP&&this.err===n.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=s.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},c.prototype._checkError=function(){switch(this.err){case n.Z_OK:case n.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===n.Z_FINISH)return this._error("unexpected end of file"),!1;break;case n.Z_STREAM_END:break;case n.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},c.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},c.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},c.prototype.init=function(t,e,r,a,o){i(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),i(t>=8&&t<=15,"invalid windowBits"),i(e>=-1&&e<=9,"invalid compression level"),i(r>=1&&r<=9,"invalid memlevel"),i(a===n.Z_FILTERED||a===n.Z_HUFFMAN_ONLY||a===n.Z_RLE||a===n.Z_FIXED||a===n.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(e,t,r,a,o),this._setDictionary()},c.prototype.params=function(){throw new Error("deflateParams Not supported")},c.prototype.reset=function(){this._reset(),this._setDictionary()},c.prototype._init=function(t,e,r,i,u){switch(this.level=t,this.windowBits=e,this.memLevel=r,this.strategy=i,this.flush=n.Z_NO_FLUSH,this.err=n.Z_OK,this.mode!==n.GZIP&&this.mode!==n.GUNZIP||(this.windowBits+=16),this.mode===n.UNZIP&&(this.windowBits+=32),this.mode!==n.DEFLATERAW&&this.mode!==n.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case n.DEFLATE:case n.GZIP:case n.DEFLATERAW:this.err=o.deflateInit2(this.strm,this.level,n.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case n.INFLATE:case n.GUNZIP:case n.INFLATERAW:case n.UNZIP:this.err=s.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==n.Z_OK&&this._error("Init error"),this.dictionary=u,this.write_in_progress=!1,this.init_done=!0},c.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=n.Z_OK,this.mode){case n.DEFLATE:case n.DEFLATERAW:this.err=o.deflateSetDictionary(this.strm,this.dictionary)}this.err!==n.Z_OK&&this._error("Failed to set dictionary")}},c.prototype._reset=function(){switch(this.err=n.Z_OK,this.mode){case n.DEFLATE:case n.DEFLATERAW:case n.GZIP:this.err=o.deflateReset(this.strm);break;case n.INFLATE:case n.INFLATERAW:case n.GUNZIP:this.err=s.inflateReset(this.strm)}this.err!==n.Z_OK&&this._error("Failed to reset stream")},n.Zlib=c}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,assert:41,buffer:5,"pako/lib/zlib/constants":51,"pako/lib/zlib/deflate.js":53,"pako/lib/zlib/inflate.js":55,"pako/lib/zlib/zstream":59}],46:[function(t,e,n){(function(e){"use strict";var r=t("buffer").Buffer,i=t("stream").Transform,a=t("./binding"),o=t("util"),s=t("assert").ok,u=t("buffer").kMaxLength,l="Cannot create final Buffer. It would be larger than 0x"+u.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var c=Object.keys(a),f=0;f=u?o=new RangeError(l):e=r.concat(i,a),i=[],t.close(),n(o,e)}t.on("error",function(e){t.removeListener("end",s),t.removeListener("readable",o),n(e)}),t.on("end",s),t.end(e),o()}function _(t,e){if("string"==typeof e&&(e=r.from(e)),!r.isBuffer(e))throw new TypeError("Not a string or buffer");var n=t._finishFlushFlag;return t._processChunk(e,n)}function y(t){if(!(this instanceof y))return new y(t);T.call(this,t,a.DEFLATE)}function w(t){if(!(this instanceof w))return new w(t);T.call(this,t,a.INFLATE)}function b(t){if(!(this instanceof b))return new b(t);T.call(this,t,a.GZIP)}function x(t){if(!(this instanceof x))return new x(t);T.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);T.call(this,t,a.DEFLATERAW)}function E(t){if(!(this instanceof E))return new E(t);T.call(this,t,a.INFLATERAW)}function S(t){if(!(this instanceof S))return new S(t);T.call(this,t,a.UNZIP)}function j(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function T(t,e){var o=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||n.Z_DEFAULT_CHUNK,i.call(this,t),t.flush&&!j(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!j(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSizen.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBitsn.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.leveln.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLeveln.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=n.Z_FILTERED&&t.strategy!=n.Z_HUFFMAN_ONLY&&t.strategy!=n.Z_RLE&&t.strategy!=n.Z_FIXED&&t.strategy!=n.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!r.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(e);var s=this;this._hadError=!1,this._handle.onerror=function(t,e){A(s),s._hadError=!0;var r=new Error(t);r.errno=e,r.code=n.codes[e],s.emit("error",r)};var u=n.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var l=n.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(l=t.strategy),this._handle.init(t.windowBits||n.Z_DEFAULT_WINDOWBITS,u,t.memLevel||n.Z_DEFAULT_MEMLEVEL,l,t.dictionary),this._buffer=r.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=l,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!o._handle},configurable:!0,enumerable:!0})}function A(t,n){n&&e.nextTick(n),t._handle&&(t._handle.close(),t._handle=null)}function C(t){t.emit("close")}Object.defineProperty(n,"codes",{enumerable:!0,value:Object.freeze(p),writable:!1}),n.Deflate=y,n.Inflate=w,n.Gzip=b,n.Gunzip=x,n.DeflateRaw=k,n.InflateRaw=E,n.Unzip=S,n.createDeflate=function(t){return new y(t)},n.createInflate=function(t){return new w(t)},n.createDeflateRaw=function(t){return new k(t)},n.createInflateRaw=function(t){return new E(t)},n.createGzip=function(t){return new b(t)},n.createGunzip=function(t){return new x(t)},n.createUnzip=function(t){return new S(t)},n.deflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new y(e),t,n)},n.deflateSync=function(t,e){return _(new y(e),t)},n.gzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new b(e),t,n)},n.gzipSync=function(t,e){return _(new b(e),t)},n.deflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new k(e),t,n)},n.deflateRawSync=function(t,e){return _(new k(e),t)},n.unzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new S(e),t,n)},n.unzipSync=function(t,e){return _(new S(e),t)},n.inflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new w(e),t,n)},n.inflateSync=function(t,e){return _(new w(e),t)},n.gunzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new x(e),t,n)},n.gunzipSync=function(t,e){return _(new x(e),t)},n.inflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new E(e),t,n)},n.inflateRawSync=function(t,e){return _(new E(e),t)},o.inherits(T,i),T.prototype.params=function(t,r,i){if(tn.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=n.Z_FILTERED&&r!=n.Z_HUFFMAN_ONLY&&r!=n.Z_RLE&&r!=n.Z_FIXED&&r!=n.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,function(){s(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())})}else e.nextTick(i)},T.prototype.reset=function(){return s(this._handle,"zlib binding closed"),this._handle.reset()},T.prototype._flush=function(t){this._transform(r.alloc(0),"",t)},T.prototype.flush=function(t,n){var i=this,o=this._writableState;("function"==typeof t||void 0===t&&!n)&&(n=t,t=a.Z_FULL_FLUSH),o.ended?n&&e.nextTick(n):o.ending?n&&this.once("end",n):o.needDrain?n&&this.once("drain",function(){return i.flush(t,n)}):(this._flushFlag=t,this.write(r.alloc(0),"",n))},T.prototype.close=function(t){A(this,t),e.nextTick(C,this)},T.prototype._transform=function(t,e,n){var i,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||r.isBuffer(t)?this._handle?(s?i=this._finishFlushFlag:(i=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,i,n)):n(new Error("zlib binding closed")):n(new Error("invalid input"))},T.prototype._processChunk=function(t,e,n){var i=t&&t.length,a=this._chunkSize-this._offset,o=0,c=this,f="function"==typeof n;if(!f){var h,p=[],d=0;this.on("error",function(t){h=t}),s(this._handle,"zlib binding closed");do{var v=this._handle.writeSync(e,t,o,i,this._buffer,this._offset,a)}while(!this._hadError&&_(v[0],v[1]));if(this._hadError)throw h;if(d>=u)throw A(this),new RangeError(l);var g=r.concat(p,d);return A(this),g}s(this._handle,"zlib binding closed");var m=this._handle.write(e,t,o,i,this._buffer,this._offset,a);function _(u,l){if(this&&(this.buffer=null,this.callback=null),!c._hadError){var h=a-l;if(s(h>=0,"have should not go down"),h>0){var v=c._buffer.slice(c._offset,c._offset+h);c._offset+=h,f?c.push(v):(p.push(v),d+=v.length)}if((0===l||c._offset>=c._chunkSize)&&(a=c._chunkSize,c._offset=0,c._buffer=r.allocUnsafe(c._chunkSize)),0===l){if(o+=i-u,i=u,!f)return!0;var g=c._handle.write(e,t,o,i,c._buffer,c._offset,c._chunkSize);return g.callback=_,void(g.buffer=t)}if(!f)return!1;n()}}m.buffer=t,m.callback=_},o.inherits(y,T),o.inherits(w,T),o.inherits(b,T),o.inherits(x,T),o.inherits(k,T),o.inherits(E,T),o.inherits(S,T)}).call(this,t("_process"))},{"./binding":45,_process:117,assert:41,buffer:5,stream:139,util:150}],47:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],48:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},a=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var s,u=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),s=0===l.x}catch(t){s=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,i){var a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=r(null),t._eventsCount=0),s){if("function"==typeof s?s=o[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),!s.warned&&(a=c(t))&&a>0&&s.length>a){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else s=o[e]=n,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(n=o[t]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),a=0;a=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,a=o;break}if(a<0)return this;0===a?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):v.call(t,e)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],49:[function(t,e,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}n.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(t[r]=n[r])}}return t},n.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var a={arraySet:function(t,e,n,r,i){if(e.subarray&&t.subarray)t.set(e.subarray(n,n+r),i);else for(var a=0;a>>16&65535|0,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+e[r++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0}},{}],51:[function(t,e,n){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],52:[function(t,e,n){"use strict";var r=function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}();e.exports=function(t,e,n,i){var a=r,o=i+n;t^=-1;for(var s=i;s>>8^a[255&(t^e[s])];return-1^t}},{}],53:[function(t,e,n){"use strict";var r,i=t("../utils/common"),a=t("./trees"),o=t("./adler32"),s=t("./crc32"),u=t("./messages"),l=0,c=1,f=3,h=4,p=5,d=0,v=1,g=-2,m=-3,_=-5,y=-1,w=1,b=2,x=3,k=4,E=0,S=2,j=8,T=9,A=15,C=8,M=286,I=30,R=19,L=2*M+1,B=15,F=3,P=258,O=P+F+1,D=32,N=42,U=69,z=73,q=91,V=103,G=113,H=666,W=1,Z=2,Y=3,X=4,$=3;function J(t,e){return t.msg=u[e],e}function Q(t){return(t<<1)-(t>4?9:0)}function K(t){for(var e=t.length;--e>=0;)t[e]=0}function tt(t){var e=t.state,n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(i.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))}function et(t,e){a._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,tt(t.strm)}function nt(t,e){t.pending_buf[t.pending++]=e}function rt(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function it(t,e){var n,r,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-O?t.strstart-(t.w_size-O):0,l=t.window,c=t.w_mask,f=t.prev,h=t.strstart+P,p=l[a+o-1],d=l[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(l[(n=e)+o]===d&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do{}while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ao){if(t.match_start=e,o=r,r>=s)break;p=l[a+o-1],d=l[a+o]}}}while((e=f[e&c])>u&&0!=--i);return o<=t.lookahead?o:t.lookahead}function at(t){var e,n,r,a,u,l,c,f,h,p,d=t.w_size;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=d+(d-O)){i.arraySet(t.window,t.window,d,d,0),t.match_start-=d,t.strstart-=d,t.block_start-=d,e=n=t.hash_size;do{r=t.head[--e],t.head[e]=r>=d?r-d:0}while(--n);e=n=d;do{r=t.prev[--e],t.prev[e]=r>=d?r-d:0}while(--n);a+=d}if(0===t.strm.avail_in)break;if(l=t.strm,c=t.window,f=t.strstart+t.lookahead,h=a,p=void 0,(p=l.avail_in)>h&&(p=h),n=0===p?0:(l.avail_in-=p,i.arraySet(c,l.input,l.next_in,p,f),1===l.state.wrap?l.adler=o(l.adler,c,p,f):2===l.state.wrap&&(l.adler=s(l.adler,c,p,f)),l.next_in+=p,l.total_in+=p,p),t.lookahead+=n,t.lookahead+t.insert>=F)for(u=t.strstart-t.insert,t.ins_h=t.window[u],t.ins_h=(t.ins_h<=F&&(t.ins_h=(t.ins_h<=F)if(r=a._tr_tally(t,t.strstart-t.match_start,t.match_length-F),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=F){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=F&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=F-1)),t.prev_length>=F&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-F,r=a._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-F),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<15&&(s=2,r-=16),a<1||a>T||n!==j||r<8||r>15||e<0||e>9||o<0||o>k)return J(t,g);8===r&&(r=9);var u=new function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=j,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*L),this.dyn_dtree=new i.Buf16(2*(2*I+1)),this.bl_tree=new i.Buf16(2*(2*R+1)),K(this.dyn_ltree),K(this.dyn_dtree),K(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(B+1),this.heap=new i.Buf16(2*M+1),K(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*M+1),K(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0};return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=r,u.w_size=1<t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(at(t),0===t.lookahead&&e===l)return W;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,et(t,!1),0===t.strm.avail_out))return W;if(t.strstart-t.block_start>=t.w_size-O&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):(t.strstart>t.block_start&&(et(t,!1),t.strm.avail_out),W)}),new ut(4,4,8,4,ot),new ut(4,5,16,8,ot),new ut(4,6,32,32,ot),new ut(4,4,16,16,st),new ut(8,16,32,32,st),new ut(8,16,128,128,st),new ut(8,32,128,256,st),new ut(32,128,258,1024,st),new ut(32,258,258,4096,st)],n.deflateInit=function(t,e){return ft(t,e,j,A,C,E)},n.deflateInit2=ft,n.deflateReset=ct,n.deflateResetKeep=lt,n.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?g:(t.state.gzhead=e,d):g},n.deflate=function(t,e){var n,i,o,u;if(!t||!t.state||e>p||e<0)return t?J(t,g):g;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===H&&e!==h)return J(t,0===t.avail_out?_:g);if(i.strm=t,n=i.last_flush,i.last_flush=e,i.status===N)if(2===i.wrap)t.adler=0,nt(i,31),nt(i,139),nt(i,8),i.gzhead?(nt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),nt(i,255&i.gzhead.time),nt(i,i.gzhead.time>>8&255),nt(i,i.gzhead.time>>16&255),nt(i,i.gzhead.time>>24&255),nt(i,9===i.level?2:i.strategy>=b||i.level<2?4:0),nt(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(nt(i,255&i.gzhead.extra.length),nt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=U):(nt(i,0),nt(i,0),nt(i,0),nt(i,0),nt(i,0),nt(i,9===i.level?2:i.strategy>=b||i.level<2?4:0),nt(i,$),i.status=G);else{var m=j+(i.w_bits-8<<4)<<8;m|=(i.strategy>=b||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(m|=D),m+=31-m%31,i.status=G,rt(i,m),0!==i.strstart&&(rt(i,t.adler>>>16),rt(i,65535&t.adler)),t.adler=1}if(i.status===U)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending!==i.pending_buf_size));)nt(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=z)}else i.status=z;if(i.status===z)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindexo&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),0===u&&(i.gzindex=0,i.status=q)}else i.status=q;if(i.status===q)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindexo&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),0===u&&(i.status=V)}else i.status=V;if(i.status===V&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&tt(t),i.pending+2<=i.pending_buf_size&&(nt(i,255&t.adler),nt(i,t.adler>>8&255),t.adler=0,i.status=G)):i.status=G),0!==i.pending){if(tt(t),0===t.avail_out)return i.last_flush=-1,d}else if(0===t.avail_in&&Q(e)<=Q(n)&&e!==h)return J(t,_);if(i.status===H&&0!==t.avail_in)return J(t,_);if(0!==t.avail_in||0!==i.lookahead||e!==l&&i.status!==H){var y=i.strategy===b?function(t,e){for(var n;;){if(0===t.lookahead&&(at(t),0===t.lookahead)){if(e===l)return W;break}if(t.match_length=0,n=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):t.last_lit&&(et(t,!1),0===t.strm.avail_out)?W:Z}(i,e):i.strategy===x?function(t,e){for(var n,r,i,o,s=t.window;;){if(t.lookahead<=P){if(at(t),t.lookahead<=P&&e===l)return W;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=F&&t.strstart>0&&(r=s[i=t.strstart-1])===s[++i]&&r===s[++i]&&r===s[++i]){o=t.strstart+P;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=F?(n=a._tr_tally(t,1,t.match_length-F),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):t.last_lit&&(et(t,!1),0===t.strm.avail_out)?W:Z}(i,e):r[i.level].func(i,e);if(y!==Y&&y!==X||(i.status=H),y===W||y===Y)return 0===t.avail_out&&(i.last_flush=-1),d;if(y===Z&&(e===c?a._tr_align(i):e!==p&&(a._tr_stored_block(i,0,0,!1),e===f&&(K(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),tt(t),0===t.avail_out))return i.last_flush=-1,d}return e!==h?d:i.wrap<=0?v:(2===i.wrap?(nt(i,255&t.adler),nt(i,t.adler>>8&255),nt(i,t.adler>>16&255),nt(i,t.adler>>24&255),nt(i,255&t.total_in),nt(i,t.total_in>>8&255),nt(i,t.total_in>>16&255),nt(i,t.total_in>>24&255)):(rt(i,t.adler>>>16),rt(i,65535&t.adler)),tt(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?d:v)},n.deflateEnd=function(t){var e;return t&&t.state?(e=t.state.status)!==N&&e!==U&&e!==z&&e!==q&&e!==V&&e!==G&&e!==H?J(t,g):(t.state=null,e===G?J(t,m):d):g},n.deflateSetDictionary=function(t,e){var n,r,a,s,u,l,c,f,h=e.length;if(!t||!t.state)return g;if(2===(s=(n=t.state).wrap)||1===s&&n.status!==N||n.lookahead)return g;for(1===s&&(t.adler=o(t.adler,e,h,0)),n.wrap=0,h>=n.w_size&&(0===s&&(K(n.head),n.strstart=0,n.block_start=0,n.insert=0),f=new i.Buf8(n.w_size),i.arraySet(f,e,h-n.w_size,n.w_size,0),e=f,h=n.w_size),u=t.avail_in,l=t.next_in,c=t.input,t.avail_in=h,t.next_in=0,t.input=e,at(n);n.lookahead>=F;){r=n.strstart,a=n.lookahead-(F-1);do{n.ins_h=(n.ins_h<>>=w=y>>>24,d-=w,0===(w=y>>>16&255))j[a++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=v[(65535&y)+(p&(1<>>=w,d-=w),d<15&&(p+=S[r++]<>>=w=y>>>24,d-=w,!(16&(w=y>>>16&255))){if(0==(64&w)){y=g[(65535&y)+(p&(1<u){t.msg="invalid distance too far back",n.mode=30;break t}if(p>>>=w,d-=w,x>(w=a-o)){if((w=x-w)>c&&n.sane){t.msg="invalid distance too far back",n.mode=30;break t}if(k=0,E=h,0===f){if(k+=l-w,w2;)j[a++]=E[k++],j[a++]=E[k++],j[a++]=E[k++],b-=3;b&&(j[a++]=E[k++],b>1&&(j[a++]=E[k++]))}else{k=a-x;do{j[a++]=j[k++],j[a++]=j[k++],j[a++]=j[k++],b-=3}while(b>2);b&&(j[a++]=j[k++],b>1&&(j[a++]=j[k++]))}break}}break}}while(r>3,p&=(1<<(d-=b<<3))-1,t.next_in=r,t.next_out=a,t.avail_in=r>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function it(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=x,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new r.Buf32(tt),e.distcode=e.distdyn=new r.Buf32(et),e.sane=1,e.back=-1,d):m}function at(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,it(t)):m}function ot(t,e){var n,r;return t&&t.state?(r=t.state,e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?m:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,at(t))):m}function st(t,e){var n,i;return t?(i=new function(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},t.state=i,i.window=null,(n=ot(t,e))!==d&&(t.state=null),n):m}var ut,lt,ct=!0;function ft(t){if(ct){var e;for(ut=new r.Buf32(512),lt=new r.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(l,t.lens,0,288,ut,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(c,t.lens,0,32,lt,0,t.work,{bits:5}),ct=!1}t.lencode=ut,t.lenbits=9,t.distcode=lt,t.distbits=5}function ht(t,e,n,i){var a,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(r.arraySet(o.window,e,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>i&&(a=i),r.arraySet(o.window,e,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,e,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,Tt,2,0),st=0,ut=0,n.mode=k;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&st)<<8)+(st>>8))%31){t.msg="incorrect header check",n.mode=J;break}if((15&st)!==b){t.msg="unknown compression method",n.mode=J;break}if(ut-=4,xt=8+(15&(st>>>=4)),0===n.wbits)n.wbits=xt;else if(xt>n.wbits){t.msg="invalid window size",n.mode=J;break}n.dmax=1<>8&1),512&n.flags&&(Tt[0]=255&st,Tt[1]=st>>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0,n.mode=E;case E:for(;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>8&255,Tt[2]=st>>>16&255,Tt[3]=st>>>24&255,n.check=a(n.check,Tt,4,0)),st=0,ut=0,n.mode=S;case S:for(;ut<16;){if(0===at)break t;at--,st+=tt[nt++]<>8),512&n.flags&&(Tt[0]=255&st,Tt[1]=st>>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0,n.mode=j;case j:if(1024&n.flags){for(;ut<16;){if(0===at)break t;at--,st+=tt[nt++]<>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0}else n.head&&(n.head.extra=null);n.mode=T;case T:if(1024&n.flags&&((pt=n.length)>at&&(pt=at),pt&&(n.head&&(xt=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,tt,nt,pt,xt)),512&n.flags&&(n.check=a(n.check,tt,pt,nt)),at-=pt,nt+=pt,n.length-=pt),n.length))break t;n.length=0,n.mode=A;case A:if(2048&n.flags){if(0===at)break t;pt=0;do{xt=tt[nt+pt++],n.head&&xt&&n.length<65536&&(n.head.name+=String.fromCharCode(xt))}while(xt&&pt>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=L;break;case I:for(;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>=7&ut,ut-=7&ut,n.mode=Y;break}for(;ut<3;){if(0===at)break t;at--,st+=tt[nt++]<>>=1)){case 0:n.mode=F;break;case 1:if(ft(n),n.mode=z,e===p){st>>>=2,ut-=2;break t}break;case 2:n.mode=D;break;case 3:t.msg="invalid block type",n.mode=J}st>>>=2,ut-=2;break;case F:for(st>>>=7&ut,ut-=7&ut;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=J;break}if(n.length=65535&st,st=0,ut=0,n.mode=P,e===p)break t;case P:n.mode=O;case O:if(pt=n.length){if(pt>at&&(pt=at),pt>ot&&(pt=ot),0===pt)break t;r.arraySet(et,tt,nt,pt,it),at-=pt,nt+=pt,ot-=pt,it+=pt,n.length-=pt;break}n.mode=L;break;case D:for(;ut<14;){if(0===at)break t;at--,st+=tt[nt++]<>>=5,ut-=5,n.ndist=1+(31&st),st>>>=5,ut-=5,n.ncode=4+(15&st),st>>>=4,ut-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=J;break}n.have=0,n.mode=N;case N:for(;n.have>>=3,ut-=3}for(;n.have<19;)n.lens[At[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,Et={bits:n.lenbits},kt=s(u,n.lens,0,19,n.lencode,0,n.work,Et),n.lenbits=Et.bits,kt){t.msg="invalid code lengths set",n.mode=J;break}n.have=0,n.mode=U;case U:for(;n.have>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=gt,ut-=gt,n.lens[n.have++]=_t;else{if(16===_t){for(St=gt+2;ut>>=gt,ut-=gt,0===n.have){t.msg="invalid bit length repeat",n.mode=J;break}xt=n.lens[n.have-1],pt=3+(3&st),st>>>=2,ut-=2}else if(17===_t){for(St=gt+3;ut>>=gt)),st>>>=3,ut-=3}else{for(St=gt+7;ut>>=gt)),st>>>=7,ut-=7}if(n.have+pt>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=J;break}for(;pt--;)n.lens[n.have++]=xt}}if(n.mode===J)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=J;break}if(n.lenbits=9,Et={bits:n.lenbits},kt=s(l,n.lens,0,n.nlen,n.lencode,0,n.work,Et),n.lenbits=Et.bits,kt){t.msg="invalid literal/lengths set",n.mode=J;break}if(n.distbits=6,n.distcode=n.distdyn,Et={bits:n.distbits},kt=s(c,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,Et),n.distbits=Et.bits,kt){t.msg="invalid distances set",n.mode=J;break}if(n.mode=z,e===p)break t;case z:n.mode=q;case q:if(at>=6&&ot>=258){t.next_out=it,t.avail_out=ot,t.next_in=nt,t.avail_in=at,n.hold=st,n.bits=ut,o(t,ct),it=t.next_out,et=t.output,ot=t.avail_out,nt=t.next_in,tt=t.input,at=t.avail_in,st=n.hold,ut=n.bits,n.mode===L&&(n.back=-1);break}for(n.back=0;mt=(jt=n.lencode[st&(1<>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>yt)])>>>16&255,_t=65535&jt,!(yt+(gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=yt,ut-=yt,n.back+=yt}if(st>>>=gt,ut-=gt,n.back+=gt,n.length=_t,0===mt){n.mode=Z;break}if(32&mt){n.back=-1,n.mode=L;break}if(64&mt){t.msg="invalid literal/length code",n.mode=J;break}n.extra=15&mt,n.mode=V;case V:if(n.extra){for(St=n.extra;ut>>=n.extra,ut-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=G;case G:for(;mt=(jt=n.distcode[st&(1<>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>yt)])>>>16&255,_t=65535&jt,!(yt+(gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=yt,ut-=yt,n.back+=yt}if(st>>>=gt,ut-=gt,n.back+=gt,64&mt){t.msg="invalid distance code",n.mode=J;break}n.offset=_t,n.extra=15&mt,n.mode=H;case H:if(n.extra){for(St=n.extra;ut>>=n.extra,ut-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=J;break}n.mode=W;case W:if(0===ot)break t;if(pt=ct-ot,n.offset>pt){if((pt=n.offset-pt)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=J;break}pt>n.wnext?(pt-=n.wnext,dt=n.wsize-pt):dt=n.wnext-pt,pt>n.length&&(pt=n.length),vt=n.window}else vt=et,dt=it-n.offset,pt=n.length;pt>ot&&(pt=ot),ot-=pt,n.length-=pt;do{et[it++]=vt[dt++]}while(--pt);0===n.length&&(n.mode=q);break;case Z:if(0===ot)break t;et[it++]=n.length,ot--,n.mode=q;break;case Y:if(n.wrap){for(;ut<32;){if(0===at)break t;at--,st|=tt[nt++]<=1&&0===F[j];j--);if(T>j&&(T=j),0===j)return l[c++]=20971520,l[c++]=20971520,h.bits=1,0;for(S=1;S0&&(0===t||1!==j))return-1;for(P[1]=0,k=1;k<15;k++)P[k+1]=P[k]+F[k];for(E=0;E852||2===t&&I>592)return 1;for(;;){y=k-C,f[E]<_?(w=0,b=f[E]):f[E]>_?(w=O[D+f[E]],b=L[B+f[E]]):(w=96,b=0),p=1<>C)+(d-=p)]=y<<24|w<<16|b|0}while(0!==d);for(p=1<>=1;if(0!==p?(R&=p-1,R+=p):R=0,E++,0==--F[k]){if(k===j)break;k=e[n+f[E]]}if(k>T&&(R&g)!==v){for(0===C&&(C=T),m+=S,M=1<<(A=k-C);A+C852||2===t&&I>592)return 1;l[v=R&g]=T<<24|A<<16|m-c|0}}return 0!==R&&(l[m+R]=k-C<<24|64<<16|0),h.bits=T,0}},{"../utils/common":49}],57:[function(t,e,n){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],58:[function(t,e,n){"use strict";var r=t("../utils/common"),i=4,a=0,o=1,s=2;function u(t){for(var e=t.length;--e>=0;)t[e]=0}var l=0,c=1,f=2,h=29,p=256,d=p+1+h,v=30,g=19,m=2*d+1,_=15,y=16,w=7,b=256,x=16,k=17,E=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=new Array(2*(d+2));u(C);var M=new Array(2*v);u(M);var I=new Array(512);u(I);var R=new Array(256);u(R);var L=new Array(h);u(L);var B,F,P,O=new Array(v);function D(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}function N(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function U(t){return t<256?I[t]:I[256+(t>>>7)]}function z(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function q(t,e,n){t.bi_valid>y-n?(t.bi_buf|=e<>y-t.bi_valid,t.bi_valid+=n-y):(t.bi_buf|=e<>>=1,n<<=1}while(--e>0);return n>>>1}function H(t,e,n){var r,i,a=new Array(_+1),o=0;for(r=1;r<=_;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=G(a[s]++,s))}}function W(t){var e;for(e=0;e8?z(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Y(t,e,n,r){var i=2*e,a=2*n;return t[i]>1;n>=1;n--)X(t,a,n);i=u;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],X(t,a,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,a[2*i]=a[2*n]+a[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,a[2*n+1]=a[2*r+1]=i,t.heap[1]=i++,X(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,r,i,a,o,s,u=e.dyn_tree,l=e.max_code,c=e.stat_desc.static_tree,f=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,v=0;for(a=0;a<=_;a++)t.bl_count[a]=0;for(u[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;nd&&(a=d,v++),u[2*r+1]=a,r>l||(t.bl_count[a]++,o=0,r>=p&&(o=h[r-p]),s=u[2*r],t.opt_len+=s*(a+o),f&&(t.static_len+=s*(c[2*r+1]+o)));if(0!==v){do{for(a=d-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[d]--,v-=2}while(v>0);for(a=d;0!==a;a--)for(r=t.bl_count[a];0!==r;)(i=t.heap[--n])>l||(u[2*i+1]!==a&&(t.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),r--)}}(t,e),H(a,l,t.bl_count)}function Q(t,e,n){var r,i,a=-1,o=e[1],s=0,u=7,l=4;for(0===o&&(u=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=e[2*(r+1)+1],++s>=7;r0?(t.strm.data_type===s&&(t.strm.data_type=function(t){var e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return a;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return o;for(e=32;e=3&&0===t.bl_tree[2*A[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),u=t.opt_len+3+7>>>3,(l=t.static_len+3+7>>>3)<=u&&(u=l)):u=l=n+5,n+4<=u&&-1!==e?et(t,e,n,r):t.strategy===i||l===u?(q(t,(c<<1)+(r?1:0),3),$(t,C,M)):(q(t,(f<<1)+(r?1:0),3),function(t,e,n,r){var i;for(q(t,e-257,5),q(t,n-1,5),q(t,r-4,4),i=0;i>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(R[n]+p+1)]++,t.dyn_dtree[2*U(e)]++),t.last_lit===t.lit_bufsize-1},n._tr_align=function(t){q(t,c<<1,3),V(t,b,C),function(t){16===t.bi_valid?(z(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":49}],59:[function(t,e,n){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],60:[function(t,e,n){n.read=function(t,e,n,r,i){var a,o,s=8*i-r-1,u=(1<>1,c=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-c)-1,p>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-l;else{if(a===u)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),a-=l}return(p?-1:1)*o*Math.pow(2,a-r)},n.write=function(t,e,n,r,i,a){var o,s,u,l=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:a-1,d=r?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*u-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[n+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[n+p]=255&o,p+=d,o/=256,l-=8);t[n+p-d]|=128*v}},{}],61:[function(t,e,n){e.exports=[function(t,e){return{options:t,draw:function(e,n,r){r.stop(!0),r.overrideFlag=!0;var i=this;return e.pixelManipulation({output:function(t,e,n){i.output={src:e,format:n}},changePixel:function(t,e,n,r){return[255-t,255-e,255-n,r]},format:e.format,image:t.image,inBrowser:t.inBrowser,callback:n})},output:void 0,UI:e}},{name:"Invert",description:"Inverts the image.",inputs:{}}]},{}],62:[function(t,e,n){"use strict";var r=t("underscore"),i=e.exports={Bitmap:t("./lib/bitmap")};r.extend(i,t("./lib/enums"))},{"./lib/bitmap":63,"./lib/enums":64,underscore:145}],63:[function(t,e,n){(function(n){"use strict";var r=t("fs"),i=(t("underscore"),t("bluebird")),a=t("jpeg-js"),o=t("node-png").PNG,s=t("./enums"),u=t("./utils"),l=t("./resize"),c={r:0,g:0,b:0,a:0},f=e.exports=function(t){t&&(t instanceof f?this._data={data:new n(t.data.data),width:t.width,height:t.height}:t.data?this._data=t:t.width&&t.height&&(this._data={data:new n(4*t.width*t.height),width:t.width,height:t.height},t.color&&this._fill(t.color)))};f.prototype={get width(){return this._data.width},get height(){return this._data.height},attach:function(t){var e=this._data;return this._data=t,e},detach:function(){var t=this._data;return delete this._data,t},_deduceFileType:function(t){if(!t)throw new Error("Can't determine image type");switch(t.substr(-4).toLowerCase()){case".jpg":return s.ImageType.JPG;case".png":return s.ImageType.PNG}if(".jpeg"==t.substr(-5).toLowerCase())return s.ImageType.JPG;throw new Error("Can't recognise image type: "+t)},_readStream:function(t){var e=i.defer(),r=[];return t.on("data",function(t){r.push(t)}),t.on("end",function(){var t=n.concat(r);e.resolve(t)}),t.on("error",function(t){e.reject(t)}),e.promise},_readPNG:function(t){var e=i.defer(),n=new o({filterType:4});return n.on("parsed",function(){e.resolve(n)}),n.on("error",function(t){e.rejecyt(t)}),t.pipe(n),e.promise},_parseOptions:function(t,e){return"number"==typeof(t=t||{})&&(t={type:t}),t.type=t.type||this._deduceFileType(e),t},read:function(t,e){var n=this;switch((e=this._parseOptions(e)).type){case s.ImageType.JPG:return this._readStream(t).then(function(t){n._data=a.decode(t)});case s.ImageType.PNG:return this._readPNG(t).then(function(t){n._data={data:t.data,width:t.width,height:t.height}});default:return i.reject(new Error("Not supported: ImageType "+e.type))}},readFile:function(t,e){var n=this;return u.fs.exists(t).then(function(i){if(i){e=n._parseOptions(e,t);var a=r.createReadStream(t);return n.read(a,e)}throw new Error("File Not Found: "+t)})},write:function(t,e){e=this._parseOptions(e);var n=i.defer();try{switch(t.on("finish",function(){n.resolve()}),t.on("error",function(t){n.reject(t)}),e.type){case s.ImageType.JPG:var r=a.encode(this._data,e.quality||90).data;t.write(r),t.end();break;case s.ImageType.PNG:var u=new o;u.width=this.width,u.height=this.height,u.data=this._data.data,u.on("end",function(){n.resolve()}),u.on("error",function(t){n.reject(t)}),u.pack().pipe(t);break;default:throw new Error("Not supported: ImageType "+e.type)}}catch(t){n.reject(t)}return n.promise},writeFile:function(t,e){e=this._parseOptions(e,t);var n=r.createWriteStream(t);return this.write(n,e)},clone:function(){return new f({width:this.width,height:this.height,data:new n(this._data.data)})},setPixel:function(t,e,n,r,i,a){if(void 0===r){var o=n;n=o.r,r=o.g,i=o.b,a=o.a}void 0===a&&(a=255);var s=4*(e*this.width+t),u=this._data.data;u[s++]=n,u[s++]=r,u[s++]=i,u[s++]=a},getPixel:function(t,e,n){var r=4*(e*this.width+t);n=n||{};var i=this._data.data;return n.r=i[r++],n.g=i[r++],n.b=i[r++],n.a=i[r++],n},negative:function(){for(var t=new f({width:this.width,height:this.height}),e=this.width*this.height,n=this._data.data,r=t._data.data,i=0,a=0,o=0;o-1&&C-1&&M=0&&M>=0?b[P]:O)+D*(g=C=0?b[P+4]:O),z=(1-D)*(m=C>=0&&M0?o:0)-(c>0?4:0)]+2*s[p-(l>0?o:0)]+1*s[p-(l>0?o:0)+(c0?4:0)]+4*s[p]+2*s[p+(c0?4:0)]+2*s[p+(l0?a[x-4]:2*a[x]-a[x+4],E=a[x],S=a[x+4],j=z0?v[x-4*h]:2*v[x]-v[x+4*h],M=v[x],I=v[x+4*h],R=N1)for(g=0;g0&&!t[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(n=0;n0;)u=a.pop();for(u.index++,a.push(u);a.length<=n;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}n+10)return p>>--d&1;if(255==(p=e[n++])){var t=e[n++];if(t)throw"unexpected marker: "+(p<<8|t).toString(16)}return d=7,p>>>7}function g(t){for(var e,n=t;null!==(e=v());){if("number"==typeof(n=n[e]))return n;if("object"!=typeof n)throw"invalid huffman sequence"}return null}function m(t){for(var e=0;t>0;){var n=v();if(null===n)return;e=e<<1|n,t--}return e}function _(t){var e=m(t);return e>=1<0)y--;else for(var r=o,i=s;r<=i;){var a=g(e.huffmanTableAC),u=15&a,c=a>>4;if(0!==u)n[t[r+=c]]=_(u)*(1<>4,0===f)a<15?(y=m(a)+(1<>4;if(0!==s)n[t[a+=u]]=_(s),a++;else{if(u<15)break;a+=16}}};var I,R,L,B,F=0;for(R=1==M?i[0].blocksPerLine*i[0].blocksPerColumn:c*r.mcusPerColumn,a||(a=R);F=65488&&I<=65495))break;n+=2}return n-h}function h(t,l){var c,f,h=[],p=l.blocksPerLine,d=l.blocksPerColumn,v=p<<3,g=new Int32Array(64),m=new Uint8Array(64);function _(t,c,f){var h,p,d,v,g,m,_,y,w,b,x=l.quantizationTable,k=f;for(b=0;b<64;b++)k[b]=t[b]*x[b];for(b=0;b<8;++b){var E=8*b;0!=k[1+E]||0!=k[2+E]||0!=k[3+E]||0!=k[4+E]||0!=k[5+E]||0!=k[6+E]||0!=k[7+E]?(h=s*k[0+E]+128>>8,p=s*k[4+E]+128>>8,d=k[2+E],v=k[6+E],g=u*(k[1+E]-k[7+E])+128>>8,y=u*(k[1+E]+k[7+E])+128>>8,m=k[3+E]<<4,_=k[5+E]<<4,w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+128>>8,d=d*a-v*o+128>>8,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+E]=h+y,k[7+E]=h-y,k[1+E]=p+_,k[6+E]=p-_,k[2+E]=d+m,k[5+E]=d-m,k[3+E]=v+g,k[4+E]=v-g):(w=s*k[0+E]+512>>10,k[0+E]=w,k[1+E]=w,k[2+E]=w,k[3+E]=w,k[4+E]=w,k[5+E]=w,k[6+E]=w,k[7+E]=w)}for(b=0;b<8;++b){var S=b;0!=k[8+S]||0!=k[16+S]||0!=k[24+S]||0!=k[32+S]||0!=k[40+S]||0!=k[48+S]||0!=k[56+S]?(h=s*k[0+S]+2048>>12,p=s*k[32+S]+2048>>12,d=k[16+S],v=k[48+S],g=u*(k[8+S]-k[56+S])+2048>>12,y=u*(k[8+S]+k[56+S])+2048>>12,m=k[24+S],_=k[40+S],w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+2048>>12,d=d*a-v*o+2048>>12,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+S]=h+y,k[56+S]=h-y,k[8+S]=p+_,k[48+S]=p-_,k[16+S]=d+m,k[40+S]=d-m,k[24+S]=v+g,k[32+S]=v-g):(w=s*f[b+0]+8192>>14,k[0+S]=w,k[8+S]=w,k[16+S]=w,k[24+S]=w,k[32+S]=w,k[40+S]=w,k[48+S]=w,k[56+S]=w)}for(b=0;b<64;++b){var j=128+(k[b]+8>>4);c[b]=j<0?0:j>255?255:j}}for(var y=0;y255?255:t}return l.prototype={load:function(t){var e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){var t=new Uint8Array(e.response||e.mozResponseArrayBuffer);this.parse(t),this.onload&&this.onload()}.bind(this),e.send(null)},parse:function(e){var n=0;e.length;function r(){var t=e[n]<<8|e[n+1];return n+=2,t}function i(){var t=r(),i=e.subarray(n,n+t-2);return n+=i.length,i}function a(t){var e,n,r=0,i=0;for(n in t.components)t.components.hasOwnProperty(n)&&(r<(e=t.components[n]).h&&(r=e.h),i>4==0)for(z=0;z<64;z++){b[t[z]]=e[n++]}else{if(w>>4!=1)throw"DQT: invalid table spec";for(z=0;z<64;z++){b[t[z]]=r()}}p[15&w]=b}break;case 65472:case 65473:case 65474:r(),(o={}).extended=65473===m,o.progressive=65474===m,o.precision=e[n++],o.scanLines=r(),o.samplesPerLine=r(),o.components={},o.componentsOrder=[];var x,k=e[n++];for(N=0;N>4,S=15&e[n+1],j=e[n+2];o.componentsOrder.push(x),o.components[x]={h:E,v:S,quantizationIdx:j},n+=3}a(o),d.push(o);break;case 65476:var T=r();for(N=2;N>4==0?g:v)[15&A]=c(C,I)}break;case 65501:r(),s=r();break;case 65498:r();var R=e[n++],L=[];for(N=0;N>4],q.huffmanTableAC=v[15&B],L.push(q)}var F=e[n++],P=e[n++],O=e[n++],D=f(e,n,o,L,s,F,P,O>>4,15&O);n+=D;break;default:if(255==e[n-3]&&e[n-2]>=192&&e[n-2]<=254){n-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}if(1!=d.length)throw"only single frame JPEGs supported";for(var N=0;N=0;)e&1<>8&255),F(255&t)}function O(t,e,n,r,i){var a,o=i[0],s=i[240];for(var u=function(t,e){var n,r,i,a,o,s,u,l,c,f,h=0;for(c=0;c<8;++c){n=t[h],r=t[h+1],i=t[h+2],a=t[h+3],o=t[h+4],s=t[h+5],u=t[h+6];var p=n+(l=t[h+7]),v=n-l,g=r+u,m=r-u,_=i+s,y=i-s,w=a+o,b=a-o,x=p+w,k=p-w,E=g+_,S=g-_;t[h]=x+E,t[h+4]=x-E;var j=.707106781*(S+k);t[h+2]=k+j,t[h+6]=k-j;var T=.382683433*((x=b+y)-(S=m+v)),A=.5411961*x+T,C=1.306562965*S+T,M=.707106781*(E=y+m),I=v+M,R=v-M;t[h+5]=R+A,t[h+3]=R-A,t[h+1]=I+C,t[h+7]=I-C,h+=8}for(h=0,c=0;c<8;++c){n=t[h],r=t[h+8],i=t[h+16],a=t[h+24],o=t[h+32],s=t[h+40],u=t[h+48];var L=n+(l=t[h+56]),B=n-l,F=r+u,P=r-u,O=i+s,D=i-s,N=a+o,U=a-o,z=L+N,q=L-N,V=F+O,G=F-O;t[h]=z+V,t[h+32]=z-V;var H=.707106781*(G+q);t[h+16]=q+H,t[h+48]=q-H;var W=.382683433*((z=U+D)-(G=P+B)),Z=.5411961*z+W,Y=1.306562965*G+W,X=.707106781*(V=D+P),$=B+X,J=B-X;t[h+40]=J+Z,t[h+24]=J-Z,t[h+8]=$+Y,t[h+56]=$-Y,h++}for(c=0;c<64;++c)f=t[c]*e[c],d[c]=f>0?f+.5|0:f-.5|0;return d}(t,e),l=0;l<64;++l)v[E[l]]=u[l];var c=v[0]-n;n=v[0],0==c?B(r[0]):(B(r[p[a=32767+c]]),B(h[a]));for(var f=63;f>0&&0==v[f];f--);if(0==f)return B(o),n;for(var g,m=1;m<=f;){for(var _=m;0==v[m]&&m<=f;++m);var y=m-_;if(y>=16){g=y>>4;for(var w=1;w<=g;++w)B(s);y&=15}a=32767+v[m],B(i[(y<<4)+p[a]]),B(h[a]),m++}return 63!=f&&B(o),n}function D(t){if(t<=0&&(t=1),t>100&&(t=100),o!=t){(function(t){for(var e=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;n<64;n++){var r=s((e[n]*t+50)/100);r<1?r=1:r>255&&(r=255),u[E[n]]=r}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var o=s((i[a]*t+50)/100);o<1?o=1:o>255&&(o=255),l[E[a]]=o}for(var h=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],p=0,d=0;d<8;d++)for(var v=0;v<8;v++)c[p]=1/(u[E[p]]*h[d]*h[v]*8),f[p]=1/(l[E[p]]*h[d]*h[v]*8),p++})(t<50?Math.floor(5e3/t):Math.floor(200-2*t)),o=t}}this.encode=function(e,o){(new Date).getTime();o&&D(o),g=new Array,m=0,_=7,P(65496),P(65504),P(16),F(74),F(70),F(73),F(70),F(0),F(1),F(1),F(0),P(1),P(1),F(0),F(0),function(){P(65499),P(132),F(0);for(var t=0;t<64;t++)F(u[t]);F(1);for(var e=0;e<64;e++)F(l[e])}(),function(t,e){P(65472),P(17),F(8),P(e),P(t),F(3),F(1),F(17),F(0),F(2),F(17),F(1),F(3),F(17),F(1)}(e.width,e.height),function(){P(65476),P(418),F(0);for(var t=0;t<16;t++)F(S[t+1]);for(var e=0;e<=11;e++)F(j[e]);F(16);for(var n=0;n<16;n++)F(T[n+1]);for(var r=0;r<=161;r++)F(A[r]);F(1);for(var i=0;i<16;i++)F(C[i+1]);for(var a=0;a<=11;a++)F(M[a]);F(17);for(var o=0;o<16;o++)F(I[o+1]);for(var s=0;s<=161;s++)F(R[s])}(),P(65498),P(12),F(3),F(1),F(0),F(2),F(17),F(3),F(17),F(0),F(63),F(0);var s=0,h=0,p=0;m=0,_=7,this.encode.displayName="_encode_";for(var d,v,x,E,L,N,U,z,q,V=e.data,G=e.width,H=e.height,W=4*G,Z=0;Z>3)*W+(U=4*(7&q)),Z+z>=H&&(N-=W*(Z+1+z-H)),d+U>=W&&(N-=d+U-W+4),v=V[N++],x=V[N++],E=V[N++],y[q]=(k[v]+k[x+256>>0]+k[E+512>>0]>>16)-128,w[q]=(k[v+768>>0]+k[x+1024>>0]+k[E+1280>>0]>>16)-128,b[q]=(k[v+1280>>0]+k[x+1536>>0]+k[E+1792>>0]>>16)-128;s=O(y,c,s,n,i),h=O(w,f,h,r,a),p=O(b,f,p,r,a),d+=32}Z+=8}if(_>=0){var Y=[];Y[1]=_+1,Y[0]=(1<<_+1)-1,B(Y)}return P(65497),new t(g)},function(){(new Date).getTime();e||(e=50),function(){for(var t=String.fromCharCode,e=0;e<256;e++)x[e]=t(e)}(),n=L(S,j),r=L(C,M),i=L(T,A),a=L(I,R),function(){for(var t=1,e=2,n=1;n<=15;n++){for(var r=t;r>0]=38470*t,k[t+512>>0]=7471*t+32768,k[t+768>>0]=-11059*t,k[t+1024>>0]=-21709*t,k[t+1280>>0]=32768*t+8421375,k[t+1536>>0]=-27439*t,k[t+1792>>0]=-5329*t}(),D(e),(new Date).getTime()}()}e.exports=function(t,e){void 0===e&&(e=50);return{data:new n(e).encode(t,e),width:t.width,height:t.height}}}).call(this,t("buffer").Buffer)},{buffer:5}],70:[function(t,e,n){arguments[4][42][0].apply(n,arguments)},{dup:42}],71:[function(t,e,n){"use strict";e.exports=function(t){for(var e=new Array(t),n=0;n>i;0!=(e&o)&&p++;var d=n>>i;return 0!=(n&o)&&d++,function(t,e,n,o,s,u){function l(t,e,n){return tn?n:t}var c=r.BitMatrix.createEmpty(o,s);function f(t,e,n,r,i){for(var o=n*i+e,s=0;sd&&(p=d);for(var v=0;vm&&(g=m);for(var _=l(v,2,e-3),y=l(h,2,n-3),w=0,b=-2;b<=2;b++){var x=u[y+b];w+=x[_-2],w+=x[_-1],w+=x[_],w+=x[_+1],w+=x[_+2]}f(t,g,p,w/25,o)}}return c}(u,p,d,e,n,function(t,e,n,r,o){for(var u=new Array(n),l=0;lh&&(f=h);for(var p=0;pv&&(d=v);for(var g=0,m=255,_=0,y=0,w=f*r+d;y_&&(_=x)}if(_-m>s)for(y++,w+=r;y>2*i;if(_-m<=s&&(k=m>>1,c>0&&p>0)){var E=u[c-1][p]+2*u[c][p-1]+u[c-1][p-1]>>2;m=n&&(t++,r+=e.estimatedModuleSize)}),t<3)return!1;for(var a=r/i,o=0,s=0;s=0&&c(n,l);)o[2]++,l--;if(l<0)return null;for(;l>=0&&!c(n,l)&&o[1]<=r;)o[1]++,l--;if(l<0||o[1]>r)return null;for(;l>=0&&c(n,l)&&o[0]<=r;)o[0]++,l--;if(o[0]>r)return null;for(l=e+1;l=r)return null;for(;l=r)return null;var f=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(f-i)>=2*i?null:s(o)?u(o,l):null}(r,Math.floor(f),n[2],l);if(null!=h&&null!=(f=function(e,n,r,i){for(var a=t.width,o=[0,0,0,0,0],l=e;l>=0&&c(l,n);)o[2]++,l--;if(l<0)return null;for(;l>=0&&!c(l,n)&&o[1]<=r;)o[1]++,l--;if(l<0||o[1]>r)return null;for(;l>=0&&c(l,n)&&o[0]<=r;)o[0]++,l--;if(o[0]>r)return null;for(l=e+1;l=r)return null;for(;l=r)return null;var f=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(f-i)>=i?null:s(o)?u(o,l):null}(Math.floor(f),Math.floor(h),n[2],l))&&(!a||function(e,n,r,i){for(var a=t.height,o=t.width,u=[0,0,0,0,0],l=0;e-l>=0&&c(n-l,e-l);)u[2]++,l++;if(e-l<0||n-l<0)return!1;for(;e-l>=0&&n-l>=0&&!c(n-l,e-l)&&u[1]<=r;)u[1]++,l++;if(e-l<0||n-l<0||u[1]>r)return!1;for(;e-l>=0&&n-l>=0&&c(n-l,e-l)&&u[0]<=r;)u[0]++,l++;if(u[0]>r)return!1;for(l=1;e+l=a||n+l>=o)return!1;for(;e+l=a||n+l>=o||u[3]>=r)return!1;for(;e+l=r)return!1;var f=u[0]+u[1]+u[2]+u[3]+u[4];return Math.abs(f-i)<2*i&&s(u)}(Math.floor(h),Math.floor(f),n[2],l))){for(var p=l/7,d=!1,v=0;v=n){if(null!=t)return a=!0,Math.floor(Math.abs(t.x-e.x)-Math.abs(t.y-e.y))/2;t=e}}),0}var d=t.height,v=t.width,g=Math.floor(3*d/(4*i));g_[2]&&(y+=x-_[2]-g,b=v-1)}_=[0,0,0,0,0],w=0}else _=[_[2],_[3],_[4],1,0],w=3;else _[++w]++;else _[w]++;s(_)&&h(_,y,v,!1)&&(g=_[0],a&&(m=f()))}var k=function(){var t=e.length;if(t<3)return null;if(t>3){var n=0,r=0;e.forEach(function(t){var e=t.estimatedModuleSize;n+=e,r+=e*e});var i=n/t,a=Math.sqrt(r/t-i*i);e.sort(function(t,e){var n=Math.abs(e.estimatedModuleSize-i),r=Math.abs(t.estimatedModuleSize-i);return n3;s++){var u=e[s];Math.abs(u.estimatedModuleSize-i)>o&&(e.splice(s,1),s--)}}return e.length>3&&(n=0,e.forEach(function(t){n+=t.estimatedModuleSize}),i=n/e.length,e.sort(function(t,e){if(e.count===t.count){var n=Math.abs(e.estimatedModuleSize-i),r=Math.abs(t.estimatedModuleSize-i);return n=i&&a>=o?(n=t[0],e=t[1],r=t[2]):o>=a&&o>=i?(n=t[1],e=t[0],r=t[2]):(n=t[2],e=t[0],r=t[1]),function(t,e,n){var r=e.x,i=e.y;return(n.x-r)*(t.y-i)-(n.y-i)*(t.x-r)}(e,n,r)<0){var s=e;e=r,r=s}return{bottomLeft:{x:e.x,y:e.y},topLeft:{x:n.x,y:n.y},topRight:{x:r.x,y:r.y}}}(k):null}},function(t,e,n){"use strict";var r=n(5),i=n(7),a=n(8),o=n(2),s=n(6);function u(t,e,n){for(var r=!0,i=0;it||o<-1||o>e)throw new Error;r=!1,-1==a?(n[i]=0,r=!0):a==t&&(n[i]=t-1,r=!0),-1==o?(n[i+1]=0,r=!0):o==e&&(n[i+1]=e-1,r=!0)}r=!0;for(i=n.length-2;i>=0&&r;i-=2){a=Math.floor(n[i]),o=Math.floor(n[i+1]);if(a<-1||a>t||o<-1||o>e)throw new Error;r=!1,-1==a?(n[i]=0,r=!0):a==t&&(n[i]=t-1,r=!0),-1==o?(n[i+1]=0,r=!0):o==e&&(n[i+1]=e-1,r=!0)}return n}function l(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}function c(t,e,n,i,a){e=Math.floor(e),n=Math.floor(n);var o=Math.floor(i*t),s=Math.max(0,e-o),u=Math.min(a.width,e+o);if(u-s<3*t)return null;var l=Math.max(0,n-o),c=Math.min(a.height-1,n+o);return r.findAlignment(s,l,u-s,c-l,t,a)}function f(t,e,n,r,i){t=Math.floor(t),e=Math.floor(e),n=Math.floor(n),r=Math.floor(r);var a=Math.abs(r-e)>Math.abs(n-t);if(a){var o=t;t=e,e=o,o=n,n=r,r=o}for(var s=Math.abs(n-t),u=Math.abs(r-e),c=-s>>1,f=t0){if(g==r)break;g+=h,c-=s}}return 2==p?l(n+f,r,t,e):NaN}function h(t,e,n,r,i){var a=f(t,e,n,r,i),o=1,s=t-(n-t);s<0?(o=t/(t-s),s=0):s>=i.width&&(o=(i.width-1-t)/(s-t),s=i.width-1);var u=e-(r-e)*o;return o=1,u<0?(o=e/(e-u),u=0):u>=i.height&&(o=(i.height-1-e)/(u-e),u=i.height-1),(a+=f(t,e,s=t+(s-t)*o,u,i))-1}function p(t,e,n){var r=h(t.x,t.y,e.x,e.y,n),i=h(e.x,e.y,t.x,t.y,n);return s.isNaN(r)?i/7:s.isNaN(i)?r/7:(r+i)/14}e.extract=function(t,e){var n=function(t,e,n,r){return(p(t,e,r)+p(t,n,r))/2}(e.topLeft,e.topRight,e.bottomLeft,t);if(n<1)return null;var r=function(t,e,n,r){var i=7+(Math.round(l(t.x,t.y,e.x,e.y)/r)+Math.round(l(t.x,t.y,n.x,n.y)/r)>>1);switch(3&i){case 0:i++;break;case 2:i--}return i}(e.topLeft,e.topRight,e.bottomLeft,n);if(!r)return null;var s=function(t){if(t%4!=1)return null;var e=t-17>>2;return e<1||e>40?null:a.getVersionForNumber(e)}(r);if(null==s)return null;var f=s.getDimensionForVersion()-7,h=null;if(s.alignmentPatternCenters.length>0)for(var d=e.topRight.x-e.topLeft.x+e.bottomLeft.x,v=e.topRight.y-e.topLeft.y+e.bottomLeft.y,g=1-3/f,m=e.topLeft.x+g*(d-e.topLeft.x),_=e.topLeft.y+g*(v-e.topLeft.y),y=4;y<=16&&!(h=c(n,m,_,y,t));y<<=1);return function(t,e,n){if(e<=0)return null;for(var r=o.BitMatrix.createEmpty(e,e),a=new Array(e<<1),s=0;s>1),a[f+1]=c;a=i.transformPoints(n,a);try{var h=u(t.width,t.height,a)}catch(t){return null}for(f=0;f>1,s,t.get(Math.floor(h[f]),Math.floor(h[f+1])))}return r}(t,r,function(t,e,n,r,a){var o,s,u,l,c=a-3.5;return null!=r?(o=r.x,s=r.y,u=l=c-3):(o=e.x-t.x+n.x,s=e.y-t.y+n.y,u=l=c),i.quadrilateralToQuadrilateral(3.5,3.5,c,3.5,u,l,3.5,c,t.x,t.y,e.x,e.y,o,s,n.x,n.y)}(e.topLeft,e.topRight,e.bottomLeft,h,r))}},function(t,e,n){"use strict";var r=n(6);function i(t,e,n,r){if(Math.abs(n-t.y)<=e&&Math.abs(r-t.x)<=e){var i=Math.abs(e-t.estimatedModuleSize);return i<=1||i<=t.estimatedModuleSize}return!1}function a(t,e,n,r){return{x:(t.x+n)/2,y:(t.y+e)/2,estimatedModuleSize:(t.estimatedModuleSize+r)/2}}function o(t,e){for(var n=e/2,r=0;r<3;r++)if(Math.abs(e-t[r])>=n)return!1;return!0}function s(t,e){var n=e-t[2]-t[1]/2;return r.isNaN(n)?null:n}e.findAlignment=function(t,e,n,r,u,l){var c=[];function f(t,e,n,r){var u=t[0]+t[1]+t[2],f=s(t,n);if(null==f)return null;var h=function(t,e,n,r,i,a){for(var u=a.height,l=[0,0,0],c=t;c>=0&&a.get(e,c)&&l[1]<=n;)l[1]++,c--;if(c<0||l[1]>n)return null;for(;c>=0&&!a.get(e,c)&&l[0]<=n;)l[0]++,c--;if(l[0]>n)return null;for(c=t+1;cn)return null;for(;cn)return null;var f=l[0]+l[1]+l[2];return 5*Math.abs(f-r)>=2*r?null:o(l,i)?s(l,c):null}(e,Math.floor(f),2*t[1],u,r,l);if(null!=h){var p=(t[0]+t[1]+t[2])/3;for(var d in c){var v=c[d];if(i(v,p,h,f))return a(v,h,f,p)}var g={x:f,y:h,estimatedModuleSize:p};c.push(g)}return null}for(var h=t+n,p=e+(r>>1),d=[0,0,0],v=0;v>1:-(v+1>>1));d[0]=0,d[1]=0,d[2]=0;for(var m=t;m>4&15]+n[t>>8&15]+n[t>>12&15]+n[t>>16&15]+n[t>>20&15]+n[t>>24&15]+n[t>>28&15]},e.isNaN=function(t){return"[object Number]"===Object.prototype.toString.call(t)&&t!==+t}},function(t,e){"use strict";function n(t,e,n,r,i,a,o,s){var u=t-n+i-o,l=e-r+a-s;if(0==u&&0==l)return{a11:n-t,a21:i-n,a31:t,a12:r-e,a22:a-r,a32:e,a13:0,a23:0,a33:1};var c=n-i,f=o-i,h=r-a,p=s-a,d=c*p-f*h,v=(u*p-f*l)/d,g=(c*l-u*h)/d;return{a11:n-t+v*n,a21:o-t+g*o,a31:t,a12:r-e+v*r,a22:s-e+g*s,a32:e,a13:v,a23:g,a33:1}}e.transformPoints=function(t,e){for(var n=e.length,r=t.a11,i=t.a12,a=t.a13,o=t.a21,s=t.a22,u=t.a23,l=t.a31,c=t.a32,f=t.a33,h=0;h40)throw new Error("Invalid version number "+t);return u[t-1]}e.getVersionForNumber=l},function(t,e,n){"use strict";var r=n(2),i=n(10),a=n(6),o=n(12),s=n(8),u=21522,l=[[21522,0],[20773,1],[24188,2],[23371,3],[17913,4],[16590,5],[20375,6],[19104,7],[30660,8],[29427,9],[32170,10],[30877,11],[26159,12],[25368,13],[27713,14],[26998,15],[5769,16],[5054,17],[7399,18],[6608,19],[1890,20],[597,21],[3340,22],[2107,23],[13663,24],[12392,25],[16177,26],[14854,27],[9396,28],[8579,29],[11994,30],[11245,31]],c=[function(t,e){return 0==(t+e&1)},function(t,e){return 0==(1&t)},function(t,e){return e%3==0},function(t,e){return(t+e)%3==0},function(t,e){return 0==((t>>1)+e/3&1)},function(t,e){return(t*e&1)+t*e%3==0},function(t,e){return 0==((t*e&1)+t*e%3&1)},function(t,e){return 0==((t+e&1)+t*e%3&1)}],f=[{ordinal:1,bits:0,name:"M"},{ordinal:0,bits:1,name:"L"},{ordinal:3,bits:2,name:"H"},{ordinal:2,bits:3,name:"Q"}];function h(t,e,n){for(var i=c[n.dataMask],a=t.height,o=function(t){for(var e=t.getDimensionForVersion(),n=new Array(e*e),i=0;i6&&(a.setRegion(e-11,0,3,6),a.setRegion(0,e-11,6,3)),a}(e),s=!0,u=[],l=0,f=0,h=0,p=a-1;p>0;p-=2){6==p&&p--;for(var d=0;d>3&3],dataMask:7&t}}function d(t,e){for(var n=1/0,r=0,i=0;i=0;r--)e=t.copyBit(8,r,e);var i=t.height,a=0,o=i-7;for(r=i-1;r>=o;r--)a=t.copyBit(8,r,a);for(n=i-8;n>2;if(n<=6)return s.getVersionForNumber(n);for(var r=0,i=e-11,a=5;a>=0;a--)for(var o=e-9;o>=i;o--)r=t.copyBit(o,a,r);var u=s.Version.decodeVersionInformation(r);if(null!=u&&u.getDimensionForVersion()==e)return u;for(r=0,o=5;o>=0;o--)for(a=e-9;a>=i;a--)r=t.copyBit(o,a,r);return null!=(u=s.Version.decodeVersionInformation(r))&&u.getDimensionForVersion()==e?u:null}(t);if(!e)return null;var n=v(t);if(!n)return null;var r=n.errorCorrectionLevel,a=h(t,e,n);if(!a)return null;var o=function(t,e,n){if(t.length!=e.totalCodewords)throw new Error("Invalid number of codewords for version; got "+t.length+" expected "+e.totalCodewords);var r=e.getECBlocksForLevel(n),i=0,a=r.ecBlocks;a.forEach(function(t){i+=t.count});var o=new Array(i),s=0;a.forEach(function(t){for(var e=0;e=0&&o[l].codewords.length!=u;)l--;l++;for(var c=u-r.ecCodewordsPerBlock,f=0,h=0;h=e.length)throw new Error("Could not decode alphanumeric char");return e[t].charCodeAt(0)}var a=function(){function t(t,e){this.characterCountBitsForVersions=t,this.bits=e}return t.prototype.getCharacterCountBits=function(t){if(null==this.characterCountBitsForVersions)throw new Error("Character count doesn't apply to this mode");var e;return e=t<=9?0:t<=26?1:2,this.characterCountBitsForVersions[e]},t}(),o=new a([0,0,0],0),s=new a([10,12,14],1),u=new a([9,11,13],2),l=new a([0,0,0],3),c=new a([8,16,16],4),f=new a(null,7),h=new a([8,10,12],8),p=new a(null,5),d=new a(null,9),v=new a([8,10,12],13);function g(t){switch(t){case 0:return o;case 1:return s;case 2:return u;case 3:return l;case 4:return c;case 5:return p;case 7:return f;case 8:return h;case 9:return d;case 13:return v;default:throw new Error("Couldn't decode mode from byte array")}}function m(t){var e=t.readBits(8);if(0==(128&e))return 127&e;if(128==(192&e))return(63&e)<<8|t.readBits(8);if(192==(224&e))return(31&e)<<16|t.readBits(16);throw new Error("Bad ECI bits starting with byte "+e)}function _(t,e,n){if(13*n>t.available())return!1;for(var r=new Array(2*n),i=0;n>0;){var a=t.readBits(13),o=Math.floor(a/96)<<8|a%96;o+=o<959?41377:42657,r[i]=o>>8&255,r[i+1]=255&o,i+=2,n--}return e.val=r,!0}function y(t,e,n){for(;n>=3;){if(t.available()<10)return!1;var r=t.readBits(10);if(r>=1e3)return!1;e.val.push(i(Math.floor(r/100))),e.val.push(i(Math.floor(r/10)%10)),e.val.push(i(r%10)),n-=3}if(2==n){if(t.available()<7)return!1;var a=t.readBits(7);if(a>=100)return!1;e.val.push(i(Math.floor(a/10))),e.val.push(i(a%10))}else if(1==n){if(t.available()<4)return!1;var o=t.readBits(4);if(o>=10)return!1;e.val.push(i(o))}return!0}function w(t,e,n,r){for(var a=e.val.length;n>1;){if(t.available()<11)return!1;var o=t.readBits(11);e.val.push(i(Math.floor(o/45))),e.val.push(i(o%45)),n-=2}if(1==n){if(t.available()<6)return!1;e.val.push(i(t.readBits(6)))}if(r)for(var s=a;st.available())return!1;for(var r=new Array(n),i=0;i30)return null}else if(i==v){var j=a.readBits(4),T=a.readBits(i.getCharacterCountBits(e));if(j==x&&!_(a,k,T))return null}else{var A=a.readBits(i.getCharacterCountBits(e));if(i==s){if(!y(a,k,A))return null}else if(i==u){if(!w(a,k,A,E))return null}else if(i==c){if(!b(a,k,A))return null}else if(i!=h)return null}return k.val}},function(t,e){"use strict";var n=function(){function t(t){this.byteOffset=0,this.bitOffset=0,this.bytes=t}return t.prototype.readBits=function(t){if(t<1||t>32||t>this.available())throw new Error("Cannot read "+t.toString()+" bits");var e=0;if(this.bitOffset>0){var n=8-this.bitOffset,r=t>8-r<<(a=n-r);e=(this.bytes[this.byteOffset]&i)>>a,t-=r,this.bitOffset+=r,8==this.bitOffset&&(this.bitOffset=0,this.byteOffset++)}if(t>0){for(;t>=8;)e=e<<8|255&this.bytes[this.byteOffset],this.byteOffset++,t-=8;if(t>0){var a;i=255>>(a=8-t)<>a,this.bitOffset+=t}}return e},t.prototype.available=function(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset},t}();e.BitStream=n},function(t,e){"use strict";var n=function(){function t(){this.field=new i(285,256,0)}return t.prototype.decode=function(t,e){for(var n=new r(this.field,t),a=new Array(e),o=!0,s=0;s=n/2;){var u=i,l=o;if(o=s,(i=a).isZero())return null;a=u;for(var c=this.field.zero,f=i.getCoefficient(i.degree()),h=this.field.inverse(f);a.degree()>=i.degree()&&!a.isZero();){var p=a.degree()-i.degree(),d=this.field.multiply(a.getCoefficient(a.degree()),h);c=c.addOrSubtract(this.field.buildMonomial(p,d)),a=a.addOrSubtract(i.multiplyByMonomial(p,d))}if(s=c.multiplyPoly(o).addOrSubtract(l),a.degree()>=i.degree())return null}var v=s.getCoefficient(0);if(0==v)return null;var g=this.field.inverse(v);return[s.multiply(g),a.multiply(g)]},t.prototype.findErrorLocations=function(t){var e=t.degree();if(1==e)return[t.getCoefficient(1)];for(var n=new Array(e),r=0,i=1;i1&&0==e[0]){for(var r=1;rr.length){var a=n;n=r,r=a}for(var o=new Array(r.length),s=r.length-n.length,u=0;u=this.size&&(t^=this.primitive,t&=this.size-1);for(e=0;e>>1,D=[["ary",x],["bind",v],["bindKey",g],["curry",_],["curryRight",y],["flip",E],["partial",w],["partialRight",b],["rearg",k]],N="[object Arguments]",U="[object Array]",z="[object AsyncFunction]",q="[object Boolean]",V="[object Date]",G="[object DOMException]",H="[object Error]",W="[object Function]",Z="[object GeneratorFunction]",Y="[object Map]",X="[object Number]",$="[object Null]",J="[object Object]",Q="[object Proxy]",K="[object RegExp]",tt="[object Set]",et="[object String]",nt="[object Symbol]",rt="[object Undefined]",it="[object WeakMap]",at="[object WeakSet]",ot="[object ArrayBuffer]",st="[object DataView]",ut="[object Float32Array]",lt="[object Float64Array]",ct="[object Int8Array]",ft="[object Int16Array]",ht="[object Int32Array]",pt="[object Uint8Array]",dt="[object Uint8ClampedArray]",vt="[object Uint16Array]",gt="[object Uint32Array]",mt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,yt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,wt=/&(?:amp|lt|gt|quot|#39);/g,bt=/[&<>"']/g,xt=RegExp(wt.source),kt=RegExp(bt.source),Et=/<%-([\s\S]+?)%>/g,St=/<%([\s\S]+?)%>/g,jt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,At=/^\w*$/,Ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mt=/[\\^$.*+?()[\]{}|]/g,It=RegExp(Mt.source),Rt=/^\s+|\s+$/g,Lt=/^\s+/,Bt=/\s+$/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Pt=/\{\n\/\* \[wrapped with (.+)\] \*/,Ot=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Nt=/\\(\\)?/g,Ut=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Vt=/^0b[01]+$/i,Gt=/^\[object .+?Constructor\]$/,Ht=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yt=/($^)/,Xt=/['\n\r\u2028\u2029\\]/g,$t="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Jt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qt="[\\ud800-\\udfff]",Kt="["+Jt+"]",te="["+$t+"]",ee="\\d+",ne="[\\u2700-\\u27bf]",re="[a-z\\xdf-\\xf6\\xf8-\\xff]",ie="[^\\ud800-\\udfff"+Jt+ee+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ae="\\ud83c[\\udffb-\\udfff]",oe="[^\\ud800-\\udfff]",se="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",le="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ce="(?:"+re+"|"+ie+")",fe="(?:"+le+"|"+ie+")",he="(?:"+te+"|"+ae+")"+"?",pe="[\\ufe0e\\ufe0f]?"+he+("(?:\\u200d(?:"+[oe,se,ue].join("|")+")[\\ufe0e\\ufe0f]?"+he+")*"),de="(?:"+[ne,se,ue].join("|")+")"+pe,ve="(?:"+[oe+te+"?",te,se,ue,Qt].join("|")+")",ge=RegExp("['’]","g"),me=RegExp(te,"g"),_e=RegExp(ae+"(?="+ae+")|"+ve+pe,"g"),ye=RegExp([le+"?"+re+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Kt,le,"$"].join("|")+")",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Kt,le+ce,"$"].join("|")+")",le+"?"+ce+"+(?:['’](?:d|ll|m|re|s|t|ve))?",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ee,de].join("|"),"g"),we=RegExp("[\\u200d\\ud800-\\udfff"+$t+"\\ufe0e\\ufe0f]"),be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,xe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ee={};Ee[ut]=Ee[lt]=Ee[ct]=Ee[ft]=Ee[ht]=Ee[pt]=Ee[dt]=Ee[vt]=Ee[gt]=!0,Ee[N]=Ee[U]=Ee[ot]=Ee[q]=Ee[st]=Ee[V]=Ee[H]=Ee[W]=Ee[Y]=Ee[X]=Ee[J]=Ee[K]=Ee[tt]=Ee[et]=Ee[it]=!1;var Se={};Se[N]=Se[U]=Se[ot]=Se[st]=Se[q]=Se[V]=Se[ut]=Se[lt]=Se[ct]=Se[ft]=Se[ht]=Se[Y]=Se[X]=Se[J]=Se[K]=Se[tt]=Se[et]=Se[nt]=Se[pt]=Se[dt]=Se[vt]=Se[gt]=!0,Se[H]=Se[W]=Se[it]=!1;var je={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Ae=parseInt,Ce="object"==typeof t&&t&&t.Object===Object&&t,Me="object"==typeof self&&self&&self.Object===Object&&self,Ie=Ce||Me||Function("return this")(),Re="object"==typeof n&&n&&!n.nodeType&&n,Le=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Be=Le&&Le.exports===Re,Fe=Be&&Ce.process,Pe=function(){try{var t=Le&&Le.require&&Le.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Oe=Pe&&Pe.isArrayBuffer,De=Pe&&Pe.isDate,Ne=Pe&&Pe.isMap,Ue=Pe&&Pe.isRegExp,ze=Pe&&Pe.isSet,qe=Pe&&Pe.isTypedArray;function Ve(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ge(t,e,n,r){for(var i=-1,a=null==t?0:t.length;++i-1}function $e(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function yn(t,e){for(var n=t.length;n--&&on(e,t[n],0)>-1;);return n}var wn=fn({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),bn=fn({"&":"&","<":"<",">":">",'"':""","'":"'"});function xn(t){return"\\"+je[t]}function kn(t){return we.test(t)}function En(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function Sn(t,e){return function(n){return t(e(n))}}function jn(t,e){for(var n=-1,r=t.length,i=0,a=[];++n",""":'"',"'":"'"});var Rn=function t(e){var n,$t=(e=null==e?Ie:Rn.defaults(Ie.Object(),e,Rn.pick(Ie,xe))).Array,Jt=e.Date,Qt=e.Error,Kt=e.Function,te=e.Math,ee=e.Object,ne=e.RegExp,re=e.String,ie=e.TypeError,ae=$t.prototype,oe=Kt.prototype,se=ee.prototype,ue=e["__core-js_shared__"],le=oe.toString,ce=se.hasOwnProperty,fe=0,he=(n=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",pe=se.toString,de=le.call(ee),ve=Ie._,_e=ne("^"+le.call(ce).replace(Mt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),we=Be?e.Buffer:r,je=e.Symbol,Ce=e.Uint8Array,Me=we?we.allocUnsafe:r,Re=Sn(ee.getPrototypeOf,ee),Le=ee.create,Fe=se.propertyIsEnumerable,Pe=ae.splice,nn=je?je.isConcatSpreadable:r,fn=je?je.iterator:r,Ln=je?je.toStringTag:r,Bn=function(){try{var t=Da(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Fn=e.clearTimeout!==Ie.clearTimeout&&e.clearTimeout,Pn=Jt&&Jt.now!==Ie.Date.now&&Jt.now,On=e.setTimeout!==Ie.setTimeout&&e.setTimeout,Dn=te.ceil,Nn=te.floor,Un=ee.getOwnPropertySymbols,zn=we?we.isBuffer:r,qn=e.isFinite,Vn=ae.join,Gn=Sn(ee.keys,ee),Hn=te.max,Wn=te.min,Zn=Jt.now,Yn=e.parseInt,Xn=te.random,$n=ae.reverse,Jn=Da(e,"DataView"),Qn=Da(e,"Map"),Kn=Da(e,"Promise"),tr=Da(e,"Set"),er=Da(e,"WeakMap"),nr=Da(ee,"create"),rr=er&&new er,ir={},ar=co(Jn),or=co(Qn),sr=co(Kn),ur=co(tr),lr=co(er),cr=je?je.prototype:r,fr=cr?cr.valueOf:r,hr=cr?cr.toString:r;function pr(t){if(As(t)&&!ms(t)&&!(t instanceof mr)){if(t instanceof gr)return t;if(ce.call(t,"__wrapped__"))return fo(t)}return new gr(t)}var dr=function(){function t(){}return function(e){if(!Ts(e))return{};if(Le)return Le(e);t.prototype=e;var n=new t;return t.prototype=r,n}}();function vr(){}function gr(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}function mr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function _r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function Fr(t,e,n,i,a,o){var s,u=e&c,l=e&f,p=e&h;if(n&&(s=a?n(t,i,a,o):n(t)),s!==r)return s;if(!Ts(t))return t;var d=ms(t);if(d){if(s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&ce.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!u)return na(t,s)}else{var v=za(t),g=v==W||v==Z;if(bs(t))return $i(t,u);if(v==J||v==N||g&&!a){if(s=l||g?{}:Va(t),!u)return l?function(t,e){return ra(t,Ua(t),e)}(t,function(t,e){return t&&ra(e,au(e),t)}(s,t)):function(t,e){return ra(t,Na(t),e)}(t,Ir(s,t))}else{if(!Se[v])return a?t:{};s=function(t,e,n){var r,i,a,o=t.constructor;switch(e){case ot:return Ji(t);case q:case V:return new o(+t);case st:return function(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case ut:case lt:case ct:case ft:case ht:case pt:case dt:case vt:case gt:return Qi(t,n);case Y:return new o;case X:case et:return new o(t);case K:return(a=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,a;case tt:return new o;case nt:return r=t,fr?ee(fr.call(r)):{}}}(t,v,u)}}o||(o=new xr);var m=o.get(t);if(m)return m;if(o.set(t,s),Ls(t))return t.forEach(function(r){s.add(Fr(r,e,n,r,t,o))}),s;if(Cs(t))return t.forEach(function(r,i){s.set(i,Fr(r,e,n,i,t,o))}),s;var _=d?r:(p?l?Ia:Ma:l?au:iu)(t);return He(_||t,function(r,i){_&&(r=t[i=r]),Ar(s,i,Fr(r,e,n,i,t,o))}),s}function Pr(t,e,n){var i=n.length;if(null==t)return!i;for(t=ee(t);i--;){var a=n[i],o=e[a],s=t[a];if(s===r&&!(a in t)||!o(s))return!1}return!0}function Or(t,e,n){if("function"!=typeof t)throw new ie(o);return ro(function(){t.apply(r,n)},e)}function Dr(t,e,n,r){var a=-1,o=Xe,s=!0,u=t.length,l=[],c=e.length;if(!u)return l;n&&(e=Je(e,vn(n))),r?(o=$e,s=!1):e.length>=i&&(o=mn,s=!1,e=new br(e));t:for(;++a-1},yr.prototype.set=function(t,e){var n=this.__data__,r=Cr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},wr.prototype.clear=function(){this.size=0,this.__data__={hash:new _r,map:new(Qn||yr),string:new _r}},wr.prototype.delete=function(t){var e=Pa(this,t).delete(t);return this.size-=e?1:0,e},wr.prototype.get=function(t){return Pa(this,t).get(t)},wr.prototype.has=function(t){return Pa(this,t).has(t)},wr.prototype.set=function(t,e){var n=Pa(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},br.prototype.add=br.prototype.push=function(t){return this.__data__.set(t,s),this},br.prototype.has=function(t){return this.__data__.has(t)},xr.prototype.clear=function(){this.__data__=new yr,this.size=0},xr.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},xr.prototype.get=function(t){return this.__data__.get(t)},xr.prototype.has=function(t){return this.__data__.has(t)},xr.prototype.set=function(t,e){var n=this.__data__;if(n instanceof yr){var r=n.__data__;if(!Qn||r.length0&&n(s)?e>1?Gr(s,e-1,n,r,i):Qe(i,s):r||(i[i.length]=s)}return i}var Hr=sa(),Wr=sa(!0);function Zr(t,e){return t&&Hr(t,e,iu)}function Yr(t,e){return t&&Wr(t,e,iu)}function Xr(t,e){return Ye(e,function(e){return Es(t[e])})}function $r(t,e){for(var n=0,i=(e=Wi(e,t)).length;null!=t&&ne}function ti(t,e){return null!=t&&ce.call(t,e)}function ei(t,e){return null!=t&&e in ee(t)}function ni(t,e,n){for(var i=n?$e:Xe,a=t[0].length,o=t.length,s=o,u=$t(o),l=1/0,c=[];s--;){var f=t[s];s&&e&&(f=Je(f,vn(e))),l=Wn(f.length,l),u[s]=!n&&(e||a>=120&&f.length>=120)?new br(s&&f):r}f=t[0];var h=-1,p=u[0];t:for(;++h=s)return u;var l=n[r];return u*("desc"==l?-1:1)}}return t.index-e.index}(t,e,n)})}function _i(t,e,n){for(var r=-1,i=e.length,a={};++r-1;)s!==t&&Pe.call(s,u,1),Pe.call(t,u,1);return t}function wi(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==a){var a=i;Ha(i)?Pe.call(t,i,1):Di(t,i)}}return t}function bi(t,e){return t+Nn(Xn()*(e-t+1))}function xi(t,e){var n="";if(!t||e<1||e>R)return n;do{e%2&&(n+=t),(e=Nn(e/2))&&(t+=t)}while(e);return n}function ki(t,e){return io(Ka(t,e,Mu),t+"")}function Ei(t){return Er(pu(t))}function Si(t,e){var n=pu(t);return so(n,Br(e,0,n.length))}function ji(t,e,n,i){if(!Ts(t))return t;for(var a=-1,o=(e=Wi(e,t)).length,s=o-1,u=t;null!=u&&++ai?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var a=$t(i);++r>>1,o=t[a];null!==o&&!Fs(o)&&(n?o<=e:o=i){var c=e?null:xa(t);if(c)return Tn(c);s=!1,a=mn,l=new br}else l=e?[]:u;t:for(;++r=i?t:Mi(t,e,n)}var Xi=Fn||function(t){return Ie.clearTimeout(t)};function $i(t,e){if(e)return t.slice();var n=t.length,r=Me?Me(n):new t.constructor(n);return t.copy(r),r}function Ji(t){var e=new t.constructor(t.byteLength);return new Ce(e).set(new Ce(t)),e}function Qi(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Ki(t,e){if(t!==e){var n=t!==r,i=null===t,a=t==t,o=Fs(t),s=e!==r,u=null===e,l=e==e,c=Fs(e);if(!u&&!c&&!o&&t>e||o&&s&&l&&!u&&!c||i&&s&&l||!n&&l||!a)return 1;if(!i&&!o&&!c&&t1?n[a-1]:r,s=a>2?n[2]:r;for(o=t.length>3&&"function"==typeof o?(a--,o):r,s&&Wa(n[0],n[1],s)&&(o=a<3?r:o,a=1),e=ee(e);++i-1?a[o?e[s]:s]:r}}function ha(t){return Ca(function(e){var n=e.length,i=n,a=gr.prototype.thru;for(t&&e.reverse();i--;){var s=e[i];if("function"!=typeof s)throw new ie(o);if(a&&!u&&"wrapper"==La(s))var u=new gr([],!0)}for(i=u?i:n;++i1&&_.reverse(),f&&lu))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var f=-1,h=!0,v=n&d?new br:r;for(o.set(t,e),o.set(e,t);++f-1&&t%1==0&&t1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Ft,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return He(D,function(n){var r="_."+n[0];e&n[1]&&!Xe(t,r)&&t.push(r)}),t.sort()}(function(t){var e=t.match(Pt);return e?e[1].split(Ot):[]}(r),n)))}function oo(t){var e=0,n=0;return function(){var i=Zn(),a=A-(i-n);if(n=i,a>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(r,arguments)}}function so(t,e){var n=-1,i=t.length,a=i-1;for(e=e===r?i:e;++n1?t[e-1]:r;return Ro(t,n="function"==typeof n?(t.pop(),n):r)});function No(t){var e=pr(t);return e.__chain__=!0,e}function Uo(t,e){return e(t)}var zo=Ca(function(t){var e=t.length,n=e?t[0]:0,i=this.__wrapped__,a=function(e){return Lr(e,t)};return!(e>1||this.__actions__.length)&&i instanceof mr&&Ha(n)?((i=i.slice(n,+n+(e?1:0))).__actions__.push({func:Uo,args:[a],thisArg:r}),new gr(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(r),t})):this.thru(a)});var qo=ia(function(t,e,n){ce.call(t,n)?++t[n]:Rr(t,n,1)});var Vo=fa(go),Go=fa(mo);function Ho(t,e){return(ms(t)?He:Nr)(t,Fa(e,3))}function Wo(t,e){return(ms(t)?We:Ur)(t,Fa(e,3))}var Zo=ia(function(t,e,n){ce.call(t,n)?t[n].push(e):Rr(t,n,[e])});var Yo=ki(function(t,e,n){var r=-1,i="function"==typeof e,a=ys(t)?$t(t.length):[];return Nr(t,function(t){a[++r]=i?Ve(e,t,n):ri(t,e,n)}),a}),Xo=ia(function(t,e,n){Rr(t,n,e)});function $o(t,e){return(ms(t)?Je:hi)(t,Fa(e,3))}var Jo=ia(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});var Qo=ki(function(t,e){if(null==t)return[];var n=e.length;return n>1&&Wa(t,e[0],e[1])?e=[]:n>2&&Wa(e[0],e[1],e[2])&&(e=[e[0]]),mi(t,Gr(e,1),[])}),Ko=Pn||function(){return Ie.Date.now()};function ts(t,e,n){return e=n?r:e,e=t&&null==e?t.length:e,Ea(t,x,r,r,r,r,e)}function es(t,e){var n;if("function"!=typeof e)throw new ie(o);return t=zs(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=r),n}}var ns=ki(function(t,e,n){var r=v;if(n.length){var i=jn(n,Ba(ns));r|=w}return Ea(t,r,e,n,i)}),rs=ki(function(t,e,n){var r=v|g;if(n.length){var i=jn(n,Ba(rs));r|=w}return Ea(e,r,t,n,i)});function is(t,e,n){var i,a,s,u,l,c,f=0,h=!1,p=!1,d=!0;if("function"!=typeof t)throw new ie(o);function v(e){var n=i,o=a;return i=a=r,f=e,u=t.apply(o,n)}function g(t){var n=t-c;return c===r||n>=e||n<0||p&&t-f>=s}function m(){var t=Ko();if(g(t))return _(t);l=ro(m,function(t){var n=e-(t-c);return p?Wn(n,s-(t-f)):n}(t))}function _(t){return l=r,d&&i?v(t):(i=a=r,u)}function y(){var t=Ko(),n=g(t);if(i=arguments,a=this,c=t,n){if(l===r)return function(t){return f=t,l=ro(m,e),h?v(t):u}(c);if(p)return l=ro(m,e),v(c)}return l===r&&(l=ro(m,e)),u}return e=Vs(e)||0,Ts(n)&&(h=!!n.leading,s=(p="maxWait"in n)?Hn(Vs(n.maxWait)||0,e):s,d="trailing"in n?!!n.trailing:d),y.cancel=function(){l!==r&&Xi(l),f=0,i=c=a=l=r},y.flush=function(){return l===r?u:_(Ko())},y}var as=ki(function(t,e){return Or(t,1,e)}),os=ki(function(t,e,n){return Or(t,Vs(e)||0,n)});function ss(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(o);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=t.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ss.Cache||wr),n}function us(t){if("function"!=typeof t)throw new ie(o);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ss.Cache=wr;var ls=Zi(function(t,e){var n=(e=1==e.length&&ms(e[0])?Je(e[0],vn(Fa())):Je(Gr(e,1),vn(Fa()))).length;return ki(function(r){for(var i=-1,a=Wn(r.length,n);++i=e}),gs=ii(function(){return arguments}())?ii:function(t){return As(t)&&ce.call(t,"callee")&&!Fe.call(t,"callee")},ms=$t.isArray,_s=Oe?vn(Oe):function(t){return As(t)&&Qr(t)==ot};function ys(t){return null!=t&&js(t.length)&&!Es(t)}function ws(t){return As(t)&&ys(t)}var bs=zn||Vu,xs=De?vn(De):function(t){return As(t)&&Qr(t)==V};function ks(t){if(!As(t))return!1;var e=Qr(t);return e==H||e==G||"string"==typeof t.message&&"string"==typeof t.name&&!Is(t)}function Es(t){if(!Ts(t))return!1;var e=Qr(t);return e==W||e==Z||e==z||e==Q}function Ss(t){return"number"==typeof t&&t==zs(t)}function js(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ts(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function As(t){return null!=t&&"object"==typeof t}var Cs=Ne?vn(Ne):function(t){return As(t)&&za(t)==Y};function Ms(t){return"number"==typeof t||As(t)&&Qr(t)==X}function Is(t){if(!As(t)||Qr(t)!=J)return!1;var e=Re(t);if(null===e)return!0;var n=ce.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&le.call(n)==de}var Rs=Ue?vn(Ue):function(t){return As(t)&&Qr(t)==K};var Ls=ze?vn(ze):function(t){return As(t)&&za(t)==tt};function Bs(t){return"string"==typeof t||!ms(t)&&As(t)&&Qr(t)==et}function Fs(t){return"symbol"==typeof t||As(t)&&Qr(t)==nt}var Ps=qe?vn(qe):function(t){return As(t)&&js(t.length)&&!!Ee[Qr(t)]};var Os=ya(fi),Ds=ya(function(t,e){return t<=e});function Ns(t){if(!t)return[];if(ys(t))return Bs(t)?Mn(t):na(t);if(fn&&t[fn])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[fn]());var e=za(t);return(e==Y?En:e==tt?Tn:pu)(t)}function Us(t){return t?(t=Vs(t))===I||t===-I?(t<0?-1:1)*L:t==t?t:0:0===t?t:0}function zs(t){var e=Us(t),n=e%1;return e==e?n?e-n:e:0}function qs(t){return t?Br(zs(t),0,F):0}function Vs(t){if("number"==typeof t)return t;if(Fs(t))return B;if(Ts(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ts(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Rt,"");var n=Vt.test(t);return n||Ht.test(t)?Ae(t.slice(2),n?2:8):qt.test(t)?B:+t}function Gs(t){return ra(t,au(t))}function Hs(t){return null==t?"":Pi(t)}var Ws=aa(function(t,e){if($a(e)||ys(e))ra(e,iu(e),t);else for(var n in e)ce.call(e,n)&&Ar(t,n,e[n])}),Zs=aa(function(t,e){ra(e,au(e),t)}),Ys=aa(function(t,e,n,r){ra(e,au(e),t,r)}),Xs=aa(function(t,e,n,r){ra(e,iu(e),t,r)}),$s=Ca(Lr);var Js=ki(function(t,e){t=ee(t);var n=-1,i=e.length,a=i>2?e[2]:r;for(a&&Wa(e[0],e[1],a)&&(i=1);++n1),e}),ra(t,Ia(t),n),r&&(n=Fr(n,c|f|h,Ta));for(var i=e.length;i--;)Di(n,e[i]);return n});var lu=Ca(function(t,e){return null==t?{}:function(t,e){return _i(t,e,function(e,n){return tu(t,n)})}(t,e)});function cu(t,e){if(null==t)return{};var n=Je(Ia(t),function(t){return[t]});return e=Fa(e),_i(t,n,function(t,n){return e(t,n[0])})}var fu=ka(iu),hu=ka(au);function pu(t){return null==t?[]:gn(t,iu(t))}var du=la(function(t,e,n){return e=e.toLowerCase(),t+(n?vu(e):e)});function vu(t){return ku(Hs(t).toLowerCase())}function gu(t){return(t=Hs(t))&&t.replace(Zt,wn).replace(me,"")}var mu=la(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),_u=la(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),yu=ua("toLowerCase");var wu=la(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});var bu=la(function(t,e,n){return t+(n?" ":"")+ku(e)});var xu=la(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),ku=ua("toUpperCase");function Eu(t,e,n){return t=Hs(t),(e=n?r:e)===r?function(t){return be.test(t)}(t)?function(t){return t.match(ye)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(e)||[]}var Su=ki(function(t,e){try{return Ve(t,r,e)}catch(t){return ks(t)?t:new Qt(t)}}),ju=Ca(function(t,e){return He(e,function(e){e=lo(e),Rr(t,e,ns(t[e],t))}),t});function Tu(t){return function(){return t}}var Au=ha(),Cu=ha(!0);function Mu(t){return t}function Iu(t){return ui("function"==typeof t?t:Fr(t,c))}var Ru=ki(function(t,e){return function(n){return ri(n,t,e)}}),Lu=ki(function(t,e){return function(n){return ri(t,n,e)}});function Bu(t,e,n){var r=iu(e),i=Xr(e,r);null!=n||Ts(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=Xr(e,iu(e)));var a=!(Ts(n)&&"chain"in n&&!n.chain),o=Es(t);return He(i,function(n){var r=e[n];t[n]=r,o&&(t.prototype[n]=function(){var e=this.__chain__;if(a||e){var n=t(this.__wrapped__);return(n.__actions__=na(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Qe([this.value()],arguments))})}),t}function Fu(){}var Pu=ga(Je),Ou=ga(Ze),Du=ga(en);function Nu(t){return Za(t)?cn(lo(t)):function(t){return function(e){return $r(e,t)}}(t)}var Uu=_a(),zu=_a(!0);function qu(){return[]}function Vu(){return!1}var Gu=va(function(t,e){return t+e},0),Hu=ba("ceil"),Wu=va(function(t,e){return t/e},1),Zu=ba("floor");var Yu,Xu=va(function(t,e){return t*e},1),$u=ba("round"),Ju=va(function(t,e){return t-e},0);return pr.after=function(t,e){if("function"!=typeof e)throw new ie(o);return t=zs(t),function(){if(--t<1)return e.apply(this,arguments)}},pr.ary=ts,pr.assign=Ws,pr.assignIn=Zs,pr.assignInWith=Ys,pr.assignWith=Xs,pr.at=$s,pr.before=es,pr.bind=ns,pr.bindAll=ju,pr.bindKey=rs,pr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ms(t)?t:[t]},pr.chain=No,pr.chunk=function(t,e,n){e=(n?Wa(t,e,n):e===r)?1:Hn(zs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var a=0,o=0,s=$t(Dn(i/e));aa?0:a+n),(i=i===r||i>a?a:zs(i))<0&&(i+=a),i=n>i?0:qs(i);n>>0)?(t=Hs(t))&&("string"==typeof e||null!=e&&!Rs(e))&&!(e=Pi(e))&&kn(t)?Yi(Mn(t),0,n):t.split(e,n):[]},pr.spread=function(t,e){if("function"!=typeof t)throw new ie(o);return e=null==e?0:Hn(zs(e),0),ki(function(n){var r=n[e],i=Yi(n,0,e);return r&&Qe(i,r),Ve(t,this,i)})},pr.tail=function(t){var e=null==t?0:t.length;return e?Mi(t,1,e):[]},pr.take=function(t,e,n){return t&&t.length?Mi(t,0,(e=n||e===r?1:zs(e))<0?0:e):[]},pr.takeRight=function(t,e,n){var i=null==t?0:t.length;return i?Mi(t,(e=i-(e=n||e===r?1:zs(e)))<0?0:e,i):[]},pr.takeRightWhile=function(t,e){return t&&t.length?Ui(t,Fa(e,3),!1,!0):[]},pr.takeWhile=function(t,e){return t&&t.length?Ui(t,Fa(e,3)):[]},pr.tap=function(t,e){return e(t),t},pr.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new ie(o);return Ts(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),is(t,e,{leading:r,maxWait:e,trailing:i})},pr.thru=Uo,pr.toArray=Ns,pr.toPairs=fu,pr.toPairsIn=hu,pr.toPath=function(t){return ms(t)?Je(t,lo):Fs(t)?[t]:na(uo(Hs(t)))},pr.toPlainObject=Gs,pr.transform=function(t,e,n){var r=ms(t),i=r||bs(t)||Ps(t);if(e=Fa(e,4),null==n){var a=t&&t.constructor;n=i?r?new a:[]:Ts(t)&&Es(a)?dr(Re(t)):{}}return(i?He:Zr)(t,function(t,r,i){return e(n,t,r,i)}),n},pr.unary=function(t){return ts(t,1)},pr.union=Ao,pr.unionBy=Co,pr.unionWith=Mo,pr.uniq=function(t){return t&&t.length?Oi(t):[]},pr.uniqBy=function(t,e){return t&&t.length?Oi(t,Fa(e,2)):[]},pr.uniqWith=function(t,e){return e="function"==typeof e?e:r,t&&t.length?Oi(t,r,e):[]},pr.unset=function(t,e){return null==t||Di(t,e)},pr.unzip=Io,pr.unzipWith=Ro,pr.update=function(t,e,n){return null==t?t:Ni(t,e,Hi(n))},pr.updateWith=function(t,e,n,i){return i="function"==typeof i?i:r,null==t?t:Ni(t,e,Hi(n),i)},pr.values=pu,pr.valuesIn=function(t){return null==t?[]:gn(t,au(t))},pr.without=Lo,pr.words=Eu,pr.wrap=function(t,e){return cs(Hi(e),t)},pr.xor=Bo,pr.xorBy=Fo,pr.xorWith=Po,pr.zip=Oo,pr.zipObject=function(t,e){return Vi(t||[],e||[],Ar)},pr.zipObjectDeep=function(t,e){return Vi(t||[],e||[],ji)},pr.zipWith=Do,pr.entries=fu,pr.entriesIn=hu,pr.extend=Zs,pr.extendWith=Ys,Bu(pr,pr),pr.add=Gu,pr.attempt=Su,pr.camelCase=du,pr.capitalize=vu,pr.ceil=Hu,pr.clamp=function(t,e,n){return n===r&&(n=e,e=r),n!==r&&(n=(n=Vs(n))==n?n:0),e!==r&&(e=(e=Vs(e))==e?e:0),Br(Vs(t),e,n)},pr.clone=function(t){return Fr(t,h)},pr.cloneDeep=function(t){return Fr(t,c|h)},pr.cloneDeepWith=function(t,e){return Fr(t,c|h,e="function"==typeof e?e:r)},pr.cloneWith=function(t,e){return Fr(t,h,e="function"==typeof e?e:r)},pr.conformsTo=function(t,e){return null==e||Pr(t,e,iu(e))},pr.deburr=gu,pr.defaultTo=function(t,e){return null==t||t!=t?e:t},pr.divide=Wu,pr.endsWith=function(t,e,n){t=Hs(t),e=Pi(e);var i=t.length,a=n=n===r?i:Br(zs(n),0,i);return(n-=e.length)>=0&&t.slice(n,a)==e},pr.eq=ps,pr.escape=function(t){return(t=Hs(t))&&kt.test(t)?t.replace(bt,bn):t},pr.escapeRegExp=function(t){return(t=Hs(t))&&It.test(t)?t.replace(Mt,"\\$&"):t},pr.every=function(t,e,n){var i=ms(t)?Ze:zr;return n&&Wa(t,e,n)&&(e=r),i(t,Fa(e,3))},pr.find=Vo,pr.findIndex=go,pr.findKey=function(t,e){return rn(t,Fa(e,3),Zr)},pr.findLast=Go,pr.findLastIndex=mo,pr.findLastKey=function(t,e){return rn(t,Fa(e,3),Yr)},pr.floor=Zu,pr.forEach=Ho,pr.forEachRight=Wo,pr.forIn=function(t,e){return null==t?t:Hr(t,Fa(e,3),au)},pr.forInRight=function(t,e){return null==t?t:Wr(t,Fa(e,3),au)},pr.forOwn=function(t,e){return t&&Zr(t,Fa(e,3))},pr.forOwnRight=function(t,e){return t&&Yr(t,Fa(e,3))},pr.get=Ks,pr.gt=ds,pr.gte=vs,pr.has=function(t,e){return null!=t&&qa(t,e,ti)},pr.hasIn=tu,pr.head=yo,pr.identity=Mu,pr.includes=function(t,e,n,r){t=ys(t)?t:pu(t),n=n&&!r?zs(n):0;var i=t.length;return n<0&&(n=Hn(i+n,0)),Bs(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&on(t,e,n)>-1},pr.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:zs(n);return i<0&&(i=Hn(r+i,0)),on(t,e,i)},pr.inRange=function(t,e,n){return e=Us(e),n===r?(n=e,e=0):n=Us(n),function(t,e,n){return t>=Wn(e,n)&&t=-R&&t<=R},pr.isSet=Ls,pr.isString=Bs,pr.isSymbol=Fs,pr.isTypedArray=Ps,pr.isUndefined=function(t){return t===r},pr.isWeakMap=function(t){return As(t)&&za(t)==it},pr.isWeakSet=function(t){return As(t)&&Qr(t)==at},pr.join=function(t,e){return null==t?"":Vn.call(t,e)},pr.kebabCase=mu,pr.last=ko,pr.lastIndexOf=function(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var a=i;return n!==r&&(a=(a=zs(n))<0?Hn(i+a,0):Wn(a,i-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,a):an(t,un,a,!0)},pr.lowerCase=_u,pr.lowerFirst=yu,pr.lt=Os,pr.lte=Ds,pr.max=function(t){return t&&t.length?qr(t,Mu,Kr):r},pr.maxBy=function(t,e){return t&&t.length?qr(t,Fa(e,2),Kr):r},pr.mean=function(t){return ln(t,Mu)},pr.meanBy=function(t,e){return ln(t,Fa(e,2))},pr.min=function(t){return t&&t.length?qr(t,Mu,fi):r},pr.minBy=function(t,e){return t&&t.length?qr(t,Fa(e,2),fi):r},pr.stubArray=qu,pr.stubFalse=Vu,pr.stubObject=function(){return{}},pr.stubString=function(){return""},pr.stubTrue=function(){return!0},pr.multiply=Xu,pr.nth=function(t,e){return t&&t.length?gi(t,zs(e)):r},pr.noConflict=function(){return Ie._===this&&(Ie._=ve),this},pr.noop=Fu,pr.now=Ko,pr.pad=function(t,e,n){t=Hs(t);var r=(e=zs(e))?Cn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return ma(Nn(i),n)+t+ma(Dn(i),n)},pr.padEnd=function(t,e,n){t=Hs(t);var r=(e=zs(e))?Cn(t):0;return e&&re){var i=t;t=e,e=i}if(n||t%1||e%1){var a=Xn();return Wn(t+a*(e-t+Te("1e-"+((a+"").length-1))),e)}return bi(t,e)},pr.reduce=function(t,e,n){var r=ms(t)?Ke:hn,i=arguments.length<3;return r(t,Fa(e,4),n,i,Nr)},pr.reduceRight=function(t,e,n){var r=ms(t)?tn:hn,i=arguments.length<3;return r(t,Fa(e,4),n,i,Ur)},pr.repeat=function(t,e,n){return e=(n?Wa(t,e,n):e===r)?1:zs(e),xi(Hs(t),e)},pr.replace=function(){var t=arguments,e=Hs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pr.result=function(t,e,n){var i=-1,a=(e=Wi(e,t)).length;for(a||(a=1,t=r);++iR)return[];var n=F,r=Wn(t,F);e=Fa(e),t-=F;for(var i=dn(r,e);++n=o)return t;var u=n-Cn(i);if(u<1)return i;var l=s?Yi(s,0,u).join(""):t.slice(0,u);if(a===r)return l+i;if(s&&(u+=l.length-u),Rs(a)){if(t.slice(u).search(a)){var c,f=l;for(a.global||(a=ne(a.source,Hs(zt.exec(a))+"g")),a.lastIndex=0;c=a.exec(f);)var h=c.index;l=l.slice(0,h===r?u:h)}}else if(t.indexOf(Pi(a),u)!=u){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i},pr.unescape=function(t){return(t=Hs(t))&&xt.test(t)?t.replace(wt,In):t},pr.uniqueId=function(t){var e=++fe;return Hs(t)+e},pr.upperCase=xu,pr.upperFirst=ku,pr.each=Ho,pr.eachRight=Wo,pr.first=yo,Bu(pr,(Yu={},Zr(pr,function(t,e){ce.call(pr.prototype,e)||(Yu[e]=t)}),Yu),{chain:!1}),pr.VERSION="4.17.11",He(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pr[t].placeholder=pr}),He(["drop","take"],function(t,e){mr.prototype[t]=function(n){n=n===r?1:Hn(zs(n),0);var i=this.__filtered__&&!e?new mr(this):this.clone();return i.__filtered__?i.__takeCount__=Wn(n,i.__takeCount__):i.__views__.push({size:Wn(n,F),type:t+(i.__dir__<0?"Right":"")}),i},mr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),He(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==C||3==n;mr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Fa(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),He(["head","last"],function(t,e){var n="take"+(e?"Right":"");mr.prototype[t]=function(){return this[n](1).value()[0]}}),He(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");mr.prototype[t]=function(){return this.__filtered__?new mr(this):this[n](1)}}),mr.prototype.compact=function(){return this.filter(Mu)},mr.prototype.find=function(t){return this.filter(t).head()},mr.prototype.findLast=function(t){return this.reverse().find(t)},mr.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new mr(this):this.map(function(n){return ri(n,t,e)})}),mr.prototype.reject=function(t){return this.filter(us(Fa(t)))},mr.prototype.slice=function(t,e){t=zs(t);var n=this;return n.__filtered__&&(t>0||e<0)?new mr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==r&&(n=(e=zs(e))<0?n.dropRight(-e):n.take(e-t)),n)},mr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},mr.prototype.toArray=function(){return this.take(F)},Zr(mr.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),a=pr[i?"take"+("last"==e?"Right":""):e],o=i||/^find/.test(e);a&&(pr.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,u=e instanceof mr,l=s[0],c=u||ms(e),f=function(t){var e=a.apply(pr,Qe([t],s));return i&&h?e[0]:e};c&&n&&"function"==typeof l&&1!=l.length&&(u=c=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,v=u&&!p;if(!o&&c){e=v?e:new mr(this);var g=t.apply(e,s);return g.__actions__.push({func:Uo,args:[f],thisArg:r}),new gr(g,h)}return d&&v?t.apply(this,s):(g=this.thru(f),d?i?g.value()[0]:g.value():g)})}),He(["pop","push","shift","sort","splice","unshift"],function(t){var e=ae[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);pr.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(ms(i)?i:[],t)}return this[n](function(n){return e.apply(ms(n)?n:[],t)})}}),Zr(mr.prototype,function(t,e){var n=pr[e];if(n){var r=n.name+"";(ir[r]||(ir[r]=[])).push({name:e,func:n})}}),ir[pa(r,g).name]=[{name:"wrapper",func:r}],mr.prototype.clone=function(){var t=new mr(this.__wrapped__);return t.__actions__=na(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=na(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=na(this.__views__),t},mr.prototype.reverse=function(){if(this.__filtered__){var t=new mr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},mr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=ms(t),r=e<0,i=n?t.length:0,a=function(t,e,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:t,value:t?r:this.__values__[this.__index__++]}},pr.prototype.plant=function(t){for(var e,n=this;n instanceof vr;){var i=fo(n);i.__index__=0,i.__values__=r,e?a.__wrapped__=i:e=i;var a=i;n=n.__wrapped__}return a.__wrapped__=t,e},pr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof mr){var e=t;return this.__actions__.length&&(e=new mr(this)),(e=e.reverse()).__actions__.push({func:Uo,args:[To],thisArg:r}),new gr(e,this.__chain__)}return this.thru(To)},pr.prototype.toJSON=pr.prototype.valueOf=pr.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pr.prototype.first=pr.prototype.head,fn&&(pr.prototype[fn]=function(){return this}),pr}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Ie._=Rn,define(function(){return Rn})):Le?((Le.exports=Rn)._=Rn,Re._=Rn):Ie._=Rn}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],76:[function(t,e,n){(function(n){t("path");var r=t("fs");function i(){this.types=Object.create(null),this.extensions=Object.create(null)}i.prototype.define=function(t){for(var e in t){for(var r=t[e],i=0;i=0;--s)if(h[s]=f,f*=l[s],p=Math.max(p,o.scratchMemory(l[s])),e.shape[s]!==n.shape[s])throw new Error("Shape mismatch, real and imaginary arrays must have same size");var d,v=4*f+p;d="array"===e.dtype||"float64"===e.dtype||"custom"===e.dtype?a.mallocDouble(v):a.mallocFloat(v);var g,m,_,y,w=i(d,l.slice(0),h,0),b=i(d,l.slice(0),h.slice(0),f),x=i(d,l.slice(0),h.slice(0),2*f),k=i(d,l.slice(0),h.slice(0),3*f),E=4*f;for(r.assign(w,e),r.assign(b,n),s=c-1;s>=0&&(o(t,f/l[s],l[s],d,w.offset,b.offset,E),0!==s);--s){for(m=1,_=x.stride,y=k.stride,u=s-1;u=0;--u)y[u]=_[u]=m,m*=l[u];r.assign(x,w),r.assign(k,b),g=w,w=x,x=g,g=b,b=k,k=g}r.assign(e,w),r.assign(n,b),a.free(d)}},{"./lib/fft-matrix.js":79,ndarray:84,"ndarray-ops":81,"typedarray-pool":144}],79:[function(t,e,n){var r=t("bit-twiddle");function i(t,e,n,i,a,o){var s,u,l,c,f,h,p,d,v,g,m,_,y,w,b,x,k,E,S,j,T,A,C,M;for(t|=0,e|=0,a|=0,o|=0,s=n|=0,u=r.log2(s),E=0;E>1,f=0,l=0;l>=1;f+=h}for(m=-1,_=0,g=1,d=0;d>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];n[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),n[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),n[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),n[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in u){var e=u[t];n[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),n[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in l){var e=l[t];n[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),n[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),n[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),n[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),n.norm1=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),n.sup=r({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),n.inf=r({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),n.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),n.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),n.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),n.equals=r({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":16}],82:[function(t,e,n){"use strict";var r=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var n=[],a=t,o=1;Array.isArray(a);)n.push(a.length),o*=a.length,a=a[0];return 0===n.length?r():(e||(e=r(new Float64Array(o),n)),i(e,t),e)}},{"./doConvert.js":83,ndarray:84}],83:[function(t,e,n){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":16}],84:[function(t,e,n){var r=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,n=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+n+"_set("+u.join(",")+",v){"),i?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+n+"_get("+u.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+n+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+n+"_hi("+u.join(",")+"){return new "+n+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),d=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+n+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var v=0;v=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+n+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+n+"_step("+u.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(v=0;v=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(l[t],s)}var l={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,n,r){if(void 0===t)return(0,l.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===n){n=new Array(o);for(var s=o-1,c=1;s>=0;--s)n[s]=c,c*=e[s]}if(void 0===r)for(r=0,s=0;s>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}},{}],86:[function(t,e,n){(function(n,r){"use strict";var i=t("util"),a=t("stream"),o=e.exports=function(){a.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};i.inherits(o,a),o.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),n.nextTick(function(){this._process(),this._paused&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(t,e){return this.writable?(r.isBuffer(t)||(t=new r(t,e||this._encoding)),this._buffers.push(t),this._buffered+=t.length,this._process(),this._reads&&0==this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",new Error("Stream not writable")),!1)},o.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0==this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("There are some read requests waitng on finished stream")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._process=function(){for(;this._buffered>0&&this._reads&&this._reads.length>0;){var t=this._reads[0];if(t.allowLess){this._reads.shift(),(a=this._buffers[0]).length>t.length?(this._buffered-=t.length,this._buffers[0]=a.slice(t.length),t.func.call(this,a.slice(0,t.length))):(this._buffered-=a.length,this._buffers.shift(),t.func.call(this,a))}else{if(!(this._buffered>=t.length))break;this._reads.shift();for(var e=0,n=0,i=new r(t.length);e0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,i)}}this._buffers&&this._buffers.length>0&&null==this._buffers[0]&&this._end()}}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,buffer:5,stream:139,util:150}],87:[function(t,e,n){"use strict";e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLOR_PALETTE:1,COLOR_COLOR:2,COLOR_ALPHA:4}},{}],88:[function(t,e,n){"use strict";var r=t("util"),i=t("stream"),a=e.exports=function(){i.call(this),this._crc=-1,this.writable=!0};r.inherits(a,i),a.prototype.write=function(t){for(var e=0;e>>8;return!0},a.prototype.end=function(t){t&&this.write(t),this.emit("crc",this.crc32())},a.prototype.crc32=function(){return-1^this._crc},a.crc32=function(t){for(var e=-1,n=0;n>>8;return-1^e};for(var o=[],s=0;s<256;s++){for(var u=s,l=0;l<8;l++)1&u?u=3988292384^u>>>1:u>>>=1;o[s]=u}},{stream:139,util:150}],89:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=(t("zlib"),t("./chunkstream")),a=e.exports=function(t,e,n,r,a){i.call(this),this._width=t,this._height=e,this._Bpp=n,this._data=r,this._options=a,this._line=0,"filterType"in a&&-1!=a.filterType?"number"==typeof a.filterType&&(a.filterType=[a.filterType]):a.filterType=[0,1,2,3,4],this._filters={0:this._filterNone.bind(this),1:this._filterSub.bind(this),2:this._filterUp.bind(this),3:this._filterAvg.bind(this),4:this._filterPaeth.bind(this)},this.read(this._width*n+1,this._reverseFilterLine.bind(this))};r.inherits(a,i);var o={1:{0:0,1:0,2:0,3:255},2:{0:0,1:0,2:0,3:1},3:{0:0,1:1,2:2,3:255},4:{0:0,1:1,2:2,3:3}};a.prototype._reverseFilterLine=function(t){var e=this._data,n=this._width<<2,r=this._line*n,i=t[0];if(0==i)for(var a=0;a0?e[u+c-4]:0;e[u+c]=255!=f?t[l+f]+h:255}else if(2==i)for(a=0;a0?e[u-n+c]:0;e[u+c]=255!=f?t[l+f]+p:255}else if(3==i)for(a=0;a0?e[u+c-4]:0,p=this._line>0?e[u-n+c]:0;var d=Math.floor((h+p)/2);e[u+c]=255!=f?t[l+f]+d:255}else if(4==i)for(a=0;a0?e[u+c-4]:0,p=this._line>0?e[u-n+c]:0;var v=a>0&&this._line>0?e[u-n+c-4]:0;d=s(h,p,v);e[u+c]=255!=f?t[l+f]+d:255}this._line++,this._line=4?t[e*r+o-4]:0,u=t[e*r+o]-s;n?n[e*i+1+o]=u:a+=Math.abs(u)}return a},a.prototype._filterUp=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=2);for(var o=0;o0?t[(e-1)*r+o]:0,u=t[e*r+o]-s;n?n[e*i+1+o]=u:a+=Math.abs(u)}return a},a.prototype._filterAvg=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=3);for(var o=0;o=4?t[e*r+o-4]:0,u=e>0?t[(e-1)*r+o]:0,l=t[e*r+o]-(s+u>>1);n?n[e*i+1+o]=l:a+=Math.abs(l)}return a},a.prototype._filterPaeth=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=4);for(var o=0;o=4?t[e*r+o-4]:0,l=e>0?t[(e-1)*r+o]:0,c=o>=4&&e>0?t[(e-1)*r+o-4]:0,f=t[e*r+o]-s(u,l,c);n?n[e*i+1+o]=f:a+=Math.abs(f)}return a};var s=function(t,e,n){var r=t+e-n,i=Math.abs(r-t),a=Math.abs(r-e),o=Math.abs(r-n);return i<=a&&i<=o?t:a<=o?e:n}}).call(this,t("buffer").Buffer)},{"./chunkstream":86,buffer:5,util:150,zlib:46}],90:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("stream"),a=t("zlib"),o=t("./filter"),s=t("./crc"),u=t("./constants"),l=e.exports=function(t){i.call(this),this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel||9,t.deflateStrategy=t.deflateStrategy||3,this.readable=!0};r.inherits(l,i),l.prototype.pack=function(t,e,r){this.emit("data",new n(u.PNG_SIGNATURE)),this.emit("data",this._packIHDR(e,r));t=new o(e,r,4,t,this._options).filter();var i=a.createDeflate({chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy});i.on("error",this.emit.bind(this,"error")),i.on("data",function(t){this.emit("data",this._packIDAT(t))}.bind(this)),i.on("end",function(){this.emit("data",this._packIEND()),this.emit("end")}.bind(this)),i.end(t)},l.prototype._packChunk=function(t,e){var r=e?e.length:0,i=new n(r+12);return i.writeUInt32BE(r,0),i.writeUInt32BE(t,4),e&&e.copy(i,8),i.writeInt32BE(s.crc32(i.slice(4,i.length-4)),i.length-4),i},l.prototype._packIHDR=function(t,e){var r=new n(13);return r.writeUInt32BE(t,0),r.writeUInt32BE(e,4),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0,this._packChunk(u.TYPE_IHDR,r)},l.prototype._packIDAT=function(t){return this._packChunk(u.TYPE_IDAT,t)},l.prototype._packIEND=function(){return this._packChunk(u.TYPE_IEND,null)}}).call(this,t("buffer").Buffer)},{"./constants":87,"./crc":88,"./filter":89,buffer:5,stream:139,util:150,zlib:46}],91:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("zlib"),a=t("./crc"),o=t("./chunkstream"),s=t("./constants"),u=t("./filter"),l=e.exports=function(t){o.call(this),this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._inflate=null,this._filter=null,this._crc=null,this._palette=[],this._colorType=0,this._chunks={},this._chunks[s.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[s.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[s.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[s.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[s.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[s.TYPE_gAMA]=this._handleGAMA.bind(this),this.writable=!0,this.on("error",this._handleError.bind(this)),this._handleSignature()};r.inherits(l,o),l.prototype._handleError=function(){this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy()},l.prototype._handleSignature=function(){this.read(s.PNG_SIGNATURE.length,this._parseSignature.bind(this))},l.prototype._parseSignature=function(t){for(var e=s.PNG_SIGNATURE,n=0;nthis._palette.length)return void this.emit("error",new Error("More transparent colors than palette size"));for(var e=0;e0?this._handleIDAT(t):this._handleChunkEnd()},l.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},l.prototype._parseIEND=function(t){this._crc.write(t),this._inflate.end(),this._hasIEND=!0,this._handleChunkEnd()};var c={0:1,2:3,3:1,4:2,6:4};l.prototype._reverseFiltered=function(t,e,n){if(3==this._colorType)for(var r=e<<2,i=0;i0&&this.height>0?new r(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(t||{}),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new s(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};i.inherits(u,a),u.prototype.pack=function(){return e.nextTick(function(){this._packer.pack(this.data,this.width,this.height)}.bind(this)),this},u.prototype.parse=function(t,e){if(e){var n,r=null;this.once("parsed",n=function(t){this.removeListener("error",r),this.data=t,e(null,this)}.bind(this)),this.once("error",r=function(t){this.removeListener("parsed",n),e(t,null)}.bind(this))}return this.end(t),this},u.prototype.write=function(t){return this._parser.write(t),!0},u.prototype.end=function(t){this._parser.end(t)},u.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.data=t.data,delete t.data,this.emit("metadata",t)},u.prototype._gamma=function(t){this.gamma=t},u.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},u.prototype.bitblt=function(t,e,n,r,i,a,o){if(e>this.width||n>this.height||e+r>this.width||n+i>this.height)throw new Error("bitblt reading outside image");if(a>t.width||o>t.height||a+r>t.width||o+i>t.height)throw new Error("bitblt writing outside image");for(var s=0;s>=u,c-=u,g!==a){if(g===o)break;for(var m=ga;)y=d[y]>>8,++_;var w=y;if(h+_+(m!==g?1:0)>r)return void console.log("Warning, gif stream longer than expected.");n[h++]=w;var b=h+=_;for(m!==g&&(n[h++]=w),y=m;_--;)y=d[y],n[--b]=255&y,y>>=8;null!==v&&s<4096&&(d[s++]=v<<8|w,s>=l+1&&u<12&&(++u,l=l<<1|1)),v=g}else s=o+1,l=(1<<(u=i+1))-1,v=null}return h!==r&&console.log("Warning, gif stream shorter than expected."),n}try{n.GifWriter=function(t,e,n,r){var i=0,a=void 0===(r=void 0===r?{}:r).loop?null:r.loop,o=void 0===r.palette?null:r.palette;if(e<=0||n<=0||e>65535||n>65535)throw new Error("Width/Height invalid.");function s(t){var e=t.length;if(e<2||e>256||e&e-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return e}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;var u=0,l=0;if(null!==o){for(var c=s(o);c>>=1;)++u;if(c=1<=c)throw new Error("Background index out of range.");if(0===l)throw new Error("Background index explicitly passed as 0.")}}if(t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&n,t[i++]=n>>8&255,t[i++]=(null!==o?128:0)|u,t[i++]=l,t[i++]=0,null!==o)for(var f=0,h=o.length;f>16&255,t[i++]=p>>8&255,t[i++]=255&p}if(null!==a){if(a<0||a>65535)throw new Error("Loop count invalid.");t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=255&a,t[i++]=a>>8&255,t[i++]=0}var d=!1;this.addFrame=function(e,n,r,a,u,l){if(!0===d&&(--i,d=!1),l=void 0===l?{}:l,e<0||n<0||e>65535||n>65535)throw new Error("x/y invalid.");if(r<=0||a<=0||r>65535||a>65535)throw new Error("Width/Height invalid.");if(u.length>=1;)++p;h=1<3)throw new Error("Disposal out of range.");var m=!1,_=0;if(void 0!==l.transparent&&null!==l.transparent&&(m=!0,(_=l.transparent)<0||_>=h))throw new Error("Transparent color index.");if((0!==g||m||0!==v)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=g<<2|(!0===m?1:0),t[i++]=255&v,t[i++]=v>>8&255,t[i++]=_,t[i++]=0),t[i++]=44,t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&n,t[i++]=n>>8&255,t[i++]=255&r,t[i++]=r>>8&255,t[i++]=255&a,t[i++]=a>>8&255,t[i++]=!0===c?128|p-1:0,!0===c)for(var y=0,w=f.length;y>16&255,t[i++]=b>>8&255,t[i++]=255&b}return i=function(t,e,n,r){t[e++]=n;var i=e++,a=1<=n;)t[e++]=255&f,f>>=8,c-=8,e===i+256&&(t[i]=255,i=e++)}function p(t){f|=t<=8;)t[e++]=255&f,f>>=8,c-=8,e===i+256&&(t[i]=255,i=e++);4096===u?(p(a),u=s+1,l=n+1,v={}):(u>=1<>7,s=1<<1+(7&a);t[e++],t[e++];var u=null,l=null;o&&(u=e,l=s,e+=3*s);var c=!0,f=[],h=0,p=null,d=0,v=null;for(this.width=n,this.height=i;c&&e=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error("Invalid graphics extension block.");var g=t[e++];h=t[e++]|t[e++]<<8,p=t[e++],0==(1&g)&&(p=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;default:throw new Error("Unknown graphic control label: 0x"+t[e-1].toString(16))}break;case 44:var m=t[e++]|t[e++]<<8,_=t[e++]|t[e++]<<8,y=t[e++]|t[e++]<<8,w=t[e++]|t[e++]<<8,b=t[e++],x=b>>6&1,k=1<<1+(7&b),E=u,S=l,j=!1;b>>7&&(j=!0,E=e,S=k,e+=3*k);var T=e;for(e++;;){var A;if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}f.push({x:m,y:_,width:y,height:w,has_local_palette:j,palette_offset:E,palette_size:S,data_offset:T,data_length:e-T,transparent_index:p,interlaced:!!x,delay:h,disposal:d});break;case 59:c=!1;break;default:throw new Error("Unknown gif block: 0x"+t[e-1].toString(16))}this.numFrames=function(){return f.length},this.loopCount=function(){return v},this.frameInfo=function(t){if(t<0||t>=f.length)throw new Error("Frame index out of range.");return f[t]},this.decodeAndBlitFrameBGRA=function(e,i){var a=this.frameInfo(e),o=a.width*a.height,s=new Uint8Array(o);r(t,a.data_offset,s,o);var u=a.palette_offset,l=a.transparent_index;null===l&&(l=256);var c=a.width,f=n-c,h=c,p=4*(a.y*n+a.x),d=4*((a.y+a.height)*n+a.x),v=p,g=4*f;!0===a.interlaced&&(g+=4*n*7);for(var m=8,_=0,y=s.length;_=d&&(g=4*f+4*n*(m-1),v=p+(c+f)*(m<<1),m>>=1)),w===l)v+=4;else{var b=t[u+3*w],x=t[u+3*w+1],k=t[u+3*w+2];i[v++]=k,i[v++]=x,i[v++]=b,i[v++]=255}--h}},this.decodeAndBlitFrameRGBA=function(e,i){var a=this.frameInfo(e),o=a.width*a.height,s=new Uint8Array(o);r(t,a.data_offset,s,o);var u=a.palette_offset,l=a.transparent_index;null===l&&(l=256);var c=a.width,f=n-c,h=c,p=4*(a.y*n+a.x),d=4*((a.y+a.height)*n+a.x),v=p,g=4*f;!0===a.interlaced&&(g+=4*n*7);for(var m=8,_=0,y=s.length;_=d&&(g=4*f+4*n*(m-1),v=p+(c+f)*(m<<1),m>>=1)),w===l)v+=4;else{var b=t[u+3*w],x=t[u+3*w+1],k=t[u+3*w+2];i[v++]=b,i[v++]=x,i[v++]=k,i[v++]=255}--h}}}}catch(t){}},{}],94:[function(t,e,n){(function(n){var r=t("charm");function i(t){if(!(t=t||{}).total)throw new Error("You MUST specify the total number of operations that will be processed.");this.total=t.total,this.current=0,this.max_burden=t.maxBurden||.5,this.show_burden=t.showBurden||!1,this.started=!1,this.size=50,this.inner_time=0,this.outer_time=0,this.elapsed=0,this.time_start=0,this.time_end=0,this.time_left=0,this.time_burden=0,this.skip_steps=0,this.skipped=0,this.aborted=!1,this.charm=r(),this.charm.pipe(n.stdout),this.charm.write("\n\n\n")}function a(t,e,n){for(n=n||" ";t.length3&&(u[0]=u[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(u[1]||"").length=this.total&&this.finished(),this.time_end=(new Date).getTime(),this.inner_time=this.time_end-this.time_start)},i.prototype.updateTimes=function(){this.elapsed=this.time_start-this.started,this.time_end>0&&(this.outer_time=this.time_start-this.time_end),this.inner_time>0&&this.outer_time>0&&(this.time_burden=this.inner_time/(this.inner_time+this.outer_time)*100,this.time_left=this.elapsed/this.current*(this.total-this.current),this.time_left<0&&(this.time_left=0)),this.time_burden>this.max_burden&&this.skip_steps0&&this.current=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r=-1&&!i;a--){var o=a>=0?arguments[a]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(n=o+"/"+n,i="/"===o.charAt(0))}return n=e(r(n.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(t){var a=n.isAbsolute(t),o="/"===i(t,-1);return(t=e(r(t.split("/"),function(t){return!!t}),!a).join("/"))||a||(t="."),t&&o&&(t+="/"),(a?"/":"")+t},n.isAbsolute=function(t){return"/"===t.charAt(0)},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},n.relative=function(t,e){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),a=r(e.split("/")),o=Math.min(i.length,a.length),s=o,u=0;u=1;--a)if(47===(e=t.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":t.slice(0,r)},n.basename=function(t,e){var n=function(t){"string"!=typeof t&&(t+="");var e,n=0,r=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){n=e+1;break}}else-1===r&&(i=!1,r=e+1);return-1===r?"":t.slice(n,r)}(t);return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,n=0,r=-1,i=!0,a=0,o=t.length-1;o>=0;--o){var s=t.charCodeAt(o);if(47!==s)-1===r&&(i=!1,r=o+1),46===s?-1===e?e=o:1!==a&&(a=1):-1!==e&&(a=-1);else if(!i){n=o+1;break}}return-1===e||-1===r||0===a||1===a&&e===r-1&&e===n+1?"":t.slice(e,r)};var i="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)}}).call(this,t("_process"))},{_process:117}],96:[function(t,e,n){(function(e){"use strict";var r=t("./interlace"),i={1:{0:0,1:0,2:0,3:255},2:{0:0,1:0,2:0,3:1},3:{0:0,1:1,2:2,3:255},4:{0:0,1:1,2:2,3:3}};function a(t,e,n,r,a,o){for(var s=t.width,u=t.height,l=t.index,c=0;c>4,n.push(f,c);break;case 2:u=3&h,l=h>>2&3,c=h>>4&3,f=h>>6&3,n.push(f,c,l,u);break;case 1:i=1&h,a=h>>1&1,o=h>>2&1,s=h>>3&1,u=h>>4&1,l=h>>5&1,c=h>>6&1,f=h>>7&1,n.push(f,c,l,u,s,o,a,i)}}return{get:function(t){for(;n.length0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(t,e){return this.writable?(n=r.isBuffer(t)?t:new r(t,e||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",new Error("Stream not writable")),!1);var n},o.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("There are some read requests waitng on finished stream")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._processReadAllowingLess=function(t){this._reads.shift();var e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))},o.prototype._processRead=function(t){this._reads.shift();for(var e=0,n=0,i=new r(t.length);e0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,i)},o.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){var t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else{if(!(this._buffered>=t.length))break;this._processRead(t)}}this._buffers&&this._buffers.length>0&&null===this._buffers[0]&&this._end()}catch(t){this.emit("error",t)}}}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,buffer:5,stream:139,util:150}],99:[function(t,e,n){"use strict";e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},{}],100:[function(t,e,n){"use strict";var r=[];!function(){for(var t=0;t<256;t++){for(var e=t,n=0;n<8;n++)1&e?e=3988292384^e>>>1:e>>>=1;r[t]=e}}();var i=e.exports=function(){this._crc=-1};i.prototype.write=function(t){for(var e=0;e>>8;return!0},i.prototype.crc32=function(){return-1^this._crc},i.crc32=function(t){for(var e=-1,n=0;n>>8;return-1^e}},{}],101:[function(t,e,n){(function(n){"use strict";var r=t("./paeth-predictor");var i={0:function(t,e,n,r,i){t.copy(r,i,e,e+n)},1:function(t,e,n,r,i,a){for(var o=0;o=a?t[e+o-a]:0,u=t[e+o]-s;r[i+o]=u}},2:function(t,e,n,r,i){for(var a=0;a0?t[e+a-n]:0,s=t[e+a]-o;r[i+a]=s}},3:function(t,e,n,r,i,a){for(var o=0;o=a?t[e+o-a]:0,u=e>0?t[e+o-n]:0,l=t[e+o]-(s+u>>1);r[i+o]=l}},4:function(t,e,n,i,a,o){for(var s=0;s=o?t[e+s-o]:0,l=e>0?t[e+s-n]:0,c=e>0&&s>=o?t[e+s-(n+o)]:0,f=t[e+s]-r(u,l,c);i[a+s]=f}}},a={0:function(t,e,n){for(var r=0,i=e+n,a=e;a=r?t[e+a-r]:0,s=t[e+a]-o;i+=Math.abs(s)}return i},2:function(t,e,n){for(var r=0,i=e+n,a=e;a0?t[a-n]:0,s=t[a]-o;r+=Math.abs(s)}return r},3:function(t,e,n,r){for(var i=0,a=0;a=r?t[e+a-r]:0,s=e>0?t[e+a-n]:0,u=t[e+a]-(o+s>>1);i+=Math.abs(u)}return i},4:function(t,e,n,i){for(var a=0,o=0;o=i?t[e+o-i]:0,u=e>0?t[e+o-n]:0,l=e>0&&o>=i?t[e+o-(n+i)]:0,c=t[e+o]-r(s,u,l);a+=Math.abs(c)}return a}};e.exports=function(t,e,r,o,s){var u;if("filterType"in o&&-1!==o.filterType){if("number"!=typeof o.filterType)throw new Error("unrecognised filter types");u=[o.filterType]}else u=[0,1,2,3,4];for(var l=e*s,c=0,f=0,h=new n((l+1)*r),p=u[0],d=0;d1)for(var v=1/0,g=0;gi?e[a-r]:0;e[a]=o+s}},o.prototype._unFilterType2=function(t,e,n){for(var r=this._lastLine,i=0;ii?e[o-r]:0,c=Math.floor((l+u)/2);e[o]=s+c}},o.prototype._unFilterType4=function(t,e,n){for(var r=this._xComparison,a=r-1,o=this._lastLine,s=0;sa?e[s-r]:0,f=s>a&&o?o[s-r]:0,h=i(c,l,f);e[s]=u+h}},o.prototype._reverseFilterLine=function(t){var e,r=t[0],i=this._images[this._imageIndex],a=i.byteWidth;if(0===r)e=t.slice(1,a+1);else switch(e=new n(a),r){case 1:this._unFilterType1(t,e,a);break;case 2:this._unFilterType2(t,e,a);break;case 3:this._unFilterType3(t,e,a);break;case 4:this._unFilterType4(t,e,a);break;default:throw new Error("Unrecognised filter type - "+r)}this.write(e),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=e,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}}).call(this,t("buffer").Buffer)},{"./interlace":106,"./paeth-predictor":110,buffer:5}],105:[function(t,e,n){(function(t){"use strict";e.exports=function(e,n){var r=n.depth,i=n.width,a=n.height,o=n.colorType,s=n.transColor,u=n.palette,l=e;return 3===o?function(t,e,n,r,i){for(var a=0,o=0;o0&&f>0&&n.push({width:c,height:f,index:u})}return n},n.getInterlaceIterator=function(t){return function(e,n,i){var a=e%r[i].x.length,o=(e-a)/r[i].x.length*8+r[i].x[a],s=n%r[i].y.length;return 4*o+((n-s)/r[i].y.length*8+r[i].y[s])*t*4}}},{}],107:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("stream"),a=t("./constants"),o=t("./packer"),s=e.exports=function(t){i.call(this);var e=t||{};this._packer=new o(e),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(s,i),s.prototype.pack=function(t,e,r,i){this.emit("data",new n(a.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,r)),i&&this.emit("data",this._packer.packGAMA(i));var o=this._packer.filterData(t,e,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(t){this.emit("data",this._packer.packIDAT(t))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(o)}}).call(this,t("buffer").Buffer)},{"./constants":99,"./packer":109,buffer:5,stream:139,util:150}],108:[function(t,e,n){(function(n){"use strict";var r=!0,i=t("zlib");i.deflateSync||(r=!1);var a=t("./constants"),o=t("./packer");e.exports=function(t,e){if(!r)throw new Error("To use the sync capability of this library in old node versions, please also add a dependency on node-zlb-backport");var s=new o(e||{}),u=[];u.push(new n(a.PNG_SIGNATURE)),u.push(s.packIHDR(t.width,t.height)),t.gamma&&u.push(s.packGAMA(t.gamma));var l=s.filterData(t.data,t.width,t.height),c=i.deflateSync(l,s.getDeflateOptions());if(l=null,!c||!c.length)throw new Error("bad png - invalid compressed data response");return u.push(s.packIDAT(c)),u.push(s.packIEND()),n.concat(u)}}).call(this,t("buffer").Buffer)},{"./constants":99,"./packer":109,buffer:5,zlib:46}],109:[function(t,e,n){(function(n){"use strict";var r=t("./constants"),i=t("./crc"),a=t("./bitpacker"),o=t("./filter-pack"),s=t("zlib"),u=e.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=null!=t.deflateLevel?t.deflateLevel:9,t.deflateStrategy=null!=t.deflateStrategy?t.deflateStrategy:3,t.inputHasAlpha=null==t.inputHasAlpha||t.inputHasAlpha,t.deflateFactory=t.deflateFactory||s.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType="number"==typeof t.colorType?t.colorType:r.COLORTYPE_COLOR_ALPHA,t.colorType!==r.COLORTYPE_COLOR&&t.colorType!==r.COLORTYPE_COLOR_ALPHA)throw new Error("option color type:"+t.colorType+" is not supported at present");if(8!==t.bitDepth)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};u.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},u.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},u.prototype.filterData=function(t,e,n){var i=a(t,e,n,this._options),s=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(i,e,n,this._options,s)},u.prototype._packChunk=function(t,e){var r=e?e.length:0,a=new n(r+12);return a.writeUInt32BE(r,0),a.writeUInt32BE(t,4),e&&e.copy(a,8),a.writeInt32BE(i.crc32(a.slice(4,a.length-4)),a.length-4),a},u.prototype.packGAMA=function(t){var e=new n(4);return e.writeUInt32BE(Math.floor(t*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,e)},u.prototype.packIHDR=function(t,e){var i=new n(13);return i.writeUInt32BE(t,0),i.writeUInt32BE(e,4),i[8]=this._options.bitDepth,i[9]=this._options.colorType,i[10]=0,i[11]=0,i[12]=0,this._packChunk(r.TYPE_IHDR,i)},u.prototype.packIDAT=function(t){return this._packChunk(r.TYPE_IDAT,t)},u.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}}).call(this,t("buffer").Buffer)},{"./bitpacker":97,"./constants":99,"./crc":100,"./filter-pack":101,buffer:5,zlib:46}],110:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=t+e-n,i=Math.abs(r-t),a=Math.abs(r-e),o=Math.abs(r-n);return i<=a&&i<=o?t:a<=o?e:n}},{}],111:[function(t,e,n){"use strict";var r=t("util"),i=t("zlib"),a=t("./chunkstream"),o=t("./filter-parse-async"),s=t("./parser"),u=t("./bitmapper"),l=t("./format-normaliser"),c=e.exports=function(t){a.call(this),this._parser=new s(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};r.inherits(c,a),c.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this.errord=!0},c.prototype._inflateData=function(t){this._inflate||(this._inflate=i.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter)),this._inflate.write(t)},c.prototype._handleMetaData=function(t){this.emit("metadata",t),this._bitmapInfo=Object.create(t),this._filter=new o(this._bitmapInfo)},c.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t},c.prototype._handlePalette=function(t){this._bitmapInfo.palette=t},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"),this.destroySoon())},c.prototype._complete=function(t){if(!this.errord){try{var e=u.dataToBitMap(t,this._bitmapInfo),n=l(e,this._bitmapInfo);e=null}catch(t){return void this._handleError(t)}this.emit("parsed",n)}}},{"./bitmapper":96,"./chunkstream":98,"./filter-parse-async":102,"./format-normaliser":105,"./parser":113,util:150,zlib:46}],112:[function(t,e,n){(function(n){"use strict";var r=!0,i=t("zlib");i.deflateSync||(r=!1);var a=t("./sync-reader"),o=t("./filter-parse-sync"),s=t("./parser"),u=t("./bitmapper"),l=t("./format-normaliser");e.exports=function(t,e){if(!r)throw new Error("To use the sync capability of this library in old node versions, please also add a dependency on node-zlb-backport");var c,f,h;var p=[];var d=new a(t);if(new s(e,{read:d.read.bind(d),error:function(t){c=t},metadata:function(t){f=t},gamma:function(t){h=t},palette:function(t){f.palette=t},transColor:function(t){f.transColor=t},inflateData:function(t){p.push(t)}}).start(),d.process(),c)throw c;var v=n.concat(p);p.length=0;var g=i.inflateSync(v);if(v=null,!g||!g.length)throw new Error("bad png - invalid inflate data response");var m=o.process(g,f);v=null;var _=u.dataToBitMap(m,f);m=null;var y=l(_,f);return f.data=y,f.gamma=h||0,f}}).call(this,t("buffer").Buffer)},{"./bitmapper":96,"./filter-parse-sync":103,"./format-normaliser":105,"./parser":113,"./sync-reader":116,buffer:5,zlib:46}],113:[function(t,e,n){(function(n){"use strict";var r=t("./constants"),i=t("./crc"),a=e.exports=function(t,e){this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.inflateData=e.inflateData,this.finished=e.finished};a.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},a.prototype._parseSignature=function(t){for(var e=r.PNG_SIGNATURE,n=0;nthis._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(var e=0;e0?this._handleIDAT(n):this._handleChunkEnd()},a.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},a.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}}).call(this,t("buffer").Buffer)},{"./constants":99,"./crc":100,buffer:5}],114:[function(t,e,n){"use strict";var r=t("./parser-sync"),i=t("./packer-sync");n.read=function(t,e){return r(t,e||{})},n.write=function(t){return i(t)}},{"./packer-sync":108,"./parser-sync":112}],115:[function(t,e,n){(function(e,r){"use strict";var i=t("util"),a=t("stream"),o=t("./parser-async"),s=t("./packer-async"),u=t("./png-sync"),l=n.PNG=function(t){a.call(this),t=t||{},this.width=t.width||0,this.height=t.height||0,this.data=this.width>0&&this.height>0?new r(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new s(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};i.inherits(l,a),l.sync=u,l.prototype.pack=function(){return this.data&&this.data.length?(e.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},l.prototype.parse=function(t,e){var n,r;e&&(n=function(t){this.removeListener("error",r),this.data=t,e(null,this)}.bind(this),r=function(t){this.removeListener("parsed",n),e(t,null)}.bind(this),this.once("parsed",n),this.once("error",r));return this.end(t),this},l.prototype.write=function(t){return this._parser.write(t),!0},l.prototype.end=function(t){this._parser.end(t)},l.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)},l.prototype._gamma=function(t){this.gamma=t},l.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},l.bitblt=function(t,e,n,r,i,a,o,s){if(n>t.width||r>t.height||n+i>t.width||r+a>t.height)throw new Error("bitblt reading outside image");if(o>e.width||s>e.height||o+i>e.width||s+a>e.height)throw new Error("bitblt writing outside image");for(var u=0;u0&&this._buffer.length;){var t=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=t.length||t.allowLess))break;this._reads.shift();var e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}return this._reads.length>0?new Error("There are some read requests waitng on finished stream"):this._buffer.length>0?new Error("unrecognised content at end of stream"):void 0}},{}],117:[function(t,e,n){var r,i,a=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var l,c=[],f=!1,h=-1;function p(){f&&l&&(f=!1,l.length?c=l.concat(c):h=-1,c.length&&d())}function d(){if(!f){var t=u(p);f=!0;for(var e=c.length;e;){for(l=c,c=[];++h1)for(var n=1;n0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===l.prototype||(e=function(t){return l.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):b(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?b(t,o,e,!1):j(t,o)):b(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function E(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(S,t):S(t))}function S(t){p("emit readable"),t.emit("readable"),M(t)}function j(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(T,t,e))}function T(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;ta.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=l.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function R(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function B(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?R(this):E(this),null;if(0===(t=k(t,e))&&e.ended)return 0===e.length&&R(this),null;var r,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&R(this)),null!==r&&this.emit("data",r),r},y.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(t,e){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?c:y;function l(e,n){p("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),t.removeListener("close",m),t.removeListener("finish",_),t.removeListener("drain",f),t.removeListener("error",g),t.removeListener("unpipe",l),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",v),h=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){p("onend"),t.end()}a.endEmitted?i.nextTick(u):r.once("end",u),t.on("unpipe",l);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,M(t))}}(r);t.on("drain",f);var h=!1;var d=!1;function v(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==B(a.pipes,t))&&!h&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function g(e){p("onerror",e),y(),t.removeListener("error",g),0===s(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",_),y()}function _(){p("onfinish"),t.removeListener("close",m),y()}function y(){p("unpipe"),r.unpipe(t)}return r.on("data",v),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",g),t.once("close",m),t.once("finish",_),t.emit("pipe",r),a.flowing||(p("pipe resume"),r.resume()),t},y.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a-1?i:a.nextTick;_.WritableState=m;var l=t("core-util-is");l.inherits=t("inherits");var c={deprecate:t("util-deprecate")},f=t("./internal/streams/stream"),h=t("safe-buffer").Buffer,p=r.Uint8Array||function(){};var d,v=t("./internal/streams/destroy");function g(){}function m(e,n){s=s||t("./_stream_duplex"),e=e||{};var r=n instanceof s;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(a.nextTick(i,r),a.nextTick(E,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),E(t,e))}(t,n,r,e,i);else{var o=x(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||b(t,n),r?u(w,t,n,o,i):w(t,n,o,i)}}(n,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function _(e){if(s=s||t("./_stream_duplex"),!(d.call(_,this)||this instanceof s))return new _(e);this._writableState=new m(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function y(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),E(t,e)}function b(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),a=e.corkedRequestsFree;a.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,y(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,f=n.callback;if(y(t,e,!1,e.objectMode?1:l.length,l,c,f),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final(function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),E(t,e)})}function E(t,e){var n=x(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,a.nextTick(k,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}l.inherits(_,f),m.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(m.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(_,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===_&&(t&&t._writableState instanceof m)}})):d=function(t){return t instanceof this},_.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},_.prototype.write=function(t,e,n){var r,i=this._writableState,o=!1,s=!i.objectMode&&(r=t,h.isBuffer(r)||r instanceof p);return s&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=g),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),a.nextTick(e,n)}(this,n):(s||function(t,e,n,r){var i=!0,o=!1;return null===n?o=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),a.nextTick(r,o),i=!1),i}(this,i,t,n))&&(i.pendingcb++,o=function(t,e,n,r,i,a){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,n));return e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(_.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),_.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},_.prototype._writev=null,_.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,E(t,e),n&&(e.finished?a.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(_.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),_.prototype.destroy=v.destroy,_.prototype._undestroy=v.undestroy,_.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":119,"./internal/streams/destroy":125,"./internal/streams/stream":126,_process:117,"core-util-is":15,inherits:70,"process-nextick-args":128,"safe-buffer":134,timers:142,"util-deprecate":148}],124:[function(t,e,n){"use strict";var r=t("safe-buffer").Buffer,i=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,a=r.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,n=a,i=s,e.copy(n,i),s+=o.data.length,o=o.next;return a},t}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":134,util:4}],125:[function(t,e,n){"use strict";var r=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(r.nextTick(i,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":128}],126:[function(t,e,n){e.exports=t("events").EventEmitter},{events:48}],127:[function(t,e,n){var r={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},{}],128:[function(t,e,n){(function(t){"use strict";!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var a,o,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,n)});case 3:return t.nextTick(function(){e.call(null,n,r)});case 4:return t.nextTick(function(){e.call(null,n,r,i)});default:for(a=new Array(s-1),o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function c(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}n.StringDecoder=a,a.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},a.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":134}],130:[function(t,e,n){e.exports=t("./readable").PassThrough},{"./readable":131}],131:[function(t,e,n){(n=e.exports=t("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=t("./lib/_stream_writable.js"),n.Duplex=t("./lib/_stream_duplex.js"),n.Transform=t("./lib/_stream_transform.js"),n.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":119,"./lib/_stream_passthrough.js":120,"./lib/_stream_readable.js":121,"./lib/_stream_transform.js":122,"./lib/_stream_writable.js":123}],132:[function(t,e,n){e.exports=t("./readable").Transform},{"./readable":131}],133:[function(t,e,n){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":123}],134:[function(t,e,n){var r=t("buffer"),i=r.Buffer;function a(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return i(t,e,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(a(r,n),n.Buffer=o),a(i,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=i(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}},{buffer:5}],135:[function(t,e,n){arguments[4][67][0].apply(n,arguments)},{"./lib/decoder":136,"./lib/encoder":137,dup:67}],136:[function(t,e,n){(function(t){var n=function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),e=4017,n=799,r=3406,i=2276,a=1567,o=3784,s=5793,u=2896;function l(){}function c(t,e){for(var n,r,i=0,a=[],o=16;o>0&&!t[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(n=0;n0;)u=a.pop();for(u.index++,a.push(u);a.length<=n;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}n+10)return p>>--d&1;if(255==(p=e[n++])){var t=e[n++];if(t)throw"unexpected marker: "+(p<<8|t).toString(16)}return d=7,p>>>7}function g(t){for(var e,n=t;null!==(e=v());){if("number"==typeof(n=n[e]))return n;if("object"!=typeof n)throw"invalid huffman sequence"}return null}function m(t){for(var e=0;t>0;){var n=v();if(null===n)return;e=e<<1|n,t--}return e}function _(t){var e=m(t);return e>=1<0)y--;else for(var r=o,i=s;r<=i;){var a=g(e.huffmanTableAC),u=15&a,c=a>>4;if(0!==u)n[t[r+=c]]=_(u)*(1<>4,0===f)a<15?(y=m(a)+(1<>4;if(0!==s)n[t[a+=u]]=_(s),a++;else{if(u<15)break;a+=16}}};var I,R,L,B,F=0;for(R=1==M?i[0].blocksPerLine*i[0].blocksPerColumn:c*r.mcusPerColumn,a||(a=R);F=65488&&I<=65495))break;n+=2}return n-h}function h(t,l){var c,f,h=[],p=l.blocksPerLine,d=l.blocksPerColumn,v=p<<3,g=new Int32Array(64),m=new Uint8Array(64);function _(t,c,f){var h,p,d,v,g,m,_,y,w,b,x=l.quantizationTable,k=f;for(b=0;b<64;b++)k[b]=t[b]*x[b];for(b=0;b<8;++b){var E=8*b;0!=k[1+E]||0!=k[2+E]||0!=k[3+E]||0!=k[4+E]||0!=k[5+E]||0!=k[6+E]||0!=k[7+E]?(h=s*k[0+E]+128>>8,p=s*k[4+E]+128>>8,d=k[2+E],v=k[6+E],g=u*(k[1+E]-k[7+E])+128>>8,y=u*(k[1+E]+k[7+E])+128>>8,m=k[3+E]<<4,_=k[5+E]<<4,w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+128>>8,d=d*a-v*o+128>>8,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+E]=h+y,k[7+E]=h-y,k[1+E]=p+_,k[6+E]=p-_,k[2+E]=d+m,k[5+E]=d-m,k[3+E]=v+g,k[4+E]=v-g):(w=s*k[0+E]+512>>10,k[0+E]=w,k[1+E]=w,k[2+E]=w,k[3+E]=w,k[4+E]=w,k[5+E]=w,k[6+E]=w,k[7+E]=w)}for(b=0;b<8;++b){var S=b;0!=k[8+S]||0!=k[16+S]||0!=k[24+S]||0!=k[32+S]||0!=k[40+S]||0!=k[48+S]||0!=k[56+S]?(h=s*k[0+S]+2048>>12,p=s*k[32+S]+2048>>12,d=k[16+S],v=k[48+S],g=u*(k[8+S]-k[56+S])+2048>>12,y=u*(k[8+S]+k[56+S])+2048>>12,m=k[24+S],_=k[40+S],w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+2048>>12,d=d*a-v*o+2048>>12,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+S]=h+y,k[56+S]=h-y,k[8+S]=p+_,k[48+S]=p-_,k[16+S]=d+m,k[40+S]=d-m,k[24+S]=v+g,k[32+S]=v-g):(w=s*f[b+0]+8192>>14,k[0+S]=w,k[8+S]=w,k[16+S]=w,k[24+S]=w,k[32+S]=w,k[40+S]=w,k[48+S]=w,k[56+S]=w)}for(b=0;b<64;++b){var j=128+(k[b]+8>>4);c[b]=j<0?0:j>255?255:j}}for(var y=0;y255?255:t}return l.prototype={load:function(t){var e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){var t=new Uint8Array(e.response||e.mozResponseArrayBuffer);this.parse(t),this.onload&&this.onload()}.bind(this),e.send(null)},parse:function(e){var n=0;e.length;function r(){var t=e[n]<<8|e[n+1];return n+=2,t}function i(){var t=r(),i=e.subarray(n,n+t-2);return n+=i.length,i}function a(t){var e,n,r=0,i=0;for(n in t.components)t.components.hasOwnProperty(n)&&(r<(e=t.components[n]).h&&(r=e.h),i>4==0)for(_=0;_<64;_++){x[t[_]]=e[n++]}else{if(b>>4!=1)throw"DQT: invalid table spec";for(_=0;_<64;_++){x[t[_]]=r()}}p[15&b]=x}break;case 65472:case 65473:case 65474:r(),(o={}).extended=65473===m,o.progressive=65474===m,o.precision=e[n++],o.scanLines=r(),o.samplesPerLine=r(),o.components={},o.componentsOrder=[];var k,E=e[n++];for(U=0;U>4,j=15&e[n+1],T=e[n+2];o.componentsOrder.push(k),o.components[k]={h:S,v:j,quantizationTable:p[T]},n+=3}a(o),d.push(o);break;case 65476:var A=r();for(U=2;U>4==0?g:v)[15&C]=c(M,R)}break;case 65501:r(),s=r();break;case 65498:r();var L=e[n++],B=[];for(U=0;U>4],z.huffmanTableAC=v[15&F],B.push(z)}var P=e[n++],O=e[n++],D=e[n++],N=f(e,n,o,B,s,P,O,D>>4,15&D);n+=N;break;default:if(255==e[n-3]&&e[n-2]>=192&&e[n-2]<=254){n-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}if(1!=d.length)throw"only single frame JPEGs supported";this.width=o.samplesPerLine,this.height=o.scanLines,this.jfif=u,this.adobe=l,this.components=[];for(var U=0;U=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived);var i;r=(e+=t.toString(this.encoding,0,r)).length-1;if((i=e.charCodeAt(r))>=55296&&i<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),t.copy(this.charBuffer,0,0,a),e.substring(0,r)}return e},a.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},a.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e}},{buffer:5}],141:[function(t,e,n){(function(n){var r=t("stream");function i(t,e,i){t=t||function(t){this.queue(t)},e=e||function(){this.queue(null)};var a=!1,o=!1,s=[],u=!1,l=new r;function c(){for(;s.length&&!l.paused;){var t=s.shift();if(null===t)return l.emit("end");l.emit("data",t)}}return l.readable=l.writable=!0,l.paused=!1,l.autoDestroy=!(i&&!1===i.autoDestroy),l.write=function(e){return t.call(this,e),!l.paused},l.queue=l.push=function(t){return u?l:(null===t&&(u=!0),s.push(t),c(),l)},l.on("end",function(){l.readable=!1,!l.writable&&l.autoDestroy&&n.nextTick(function(){l.destroy()})}),l.end=function(t){if(!a)return a=!0,arguments.length&&l.write(t),l.writable=!1,e.call(l),!l.readable&&l.autoDestroy&&l.destroy(),l},l.destroy=function(){if(!o)return o=!0,a=!0,s.length=0,l.writable=l.readable=!1,l.emit("close"),l},l.pause=function(){if(!l.paused)return l.paused=!0,l},l.resume=function(){return l.paused&&(l.paused=!1,l.emit("resume")),c(),l.paused||l.emit("drain"),l},l}e.exports=i,i.through=i}).call(this,t("_process"))},{_process:117,stream:139}],142:[function(t,e,n){(function(e,r){var i=t("process/browser.js").nextTick,a=Function.prototype.apply,o=Array.prototype.slice,s={},u=0;function l(t,e){this._id=t,this._clearFn=e}n.setTimeout=function(){return new l(a.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new l(a.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n.setImmediate="function"==typeof e?e:function(t){var e=u++,r=!(arguments.length<2)&&o.call(arguments,1);return s[e]=!0,i(function(){s[e]&&(r?t.apply(null,r):t.call(null),n.clearImmediate(e))}),e},n.clearImmediate="function"==typeof r?r:function(t){delete s[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":117,timers:142}],143:[function(t,e,n){n.isatty=function(){return!1},n.ReadStream=function(){throw new Error("tty.ReadStream is not implemented")},n.WriteStream=function(){throw new Error("tty.WriteStream is not implemented")}},{}],144:[function(t,e,n){(function(e,r){"use strict";var i=t("bit-twiddle"),a=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:a([32,0]),UINT16:a([32,0]),UINT32:a([32,0]),INT8:a([32,0]),INT16:a([32,0]),INT32:a([32,0]),FLOAT:a([32,0]),DOUBLE:a([32,0]),DATA:a([32,0]),UINT8C:a([32,0]),BUFFER:a([32,0])});var o="undefined"!=typeof Uint8ClampedArray,s=e.__TYPEDARRAY_POOL;s.UINT8C||(s.UINT8C=a([32,0])),s.BUFFER||(s.BUFFER=a([32,0]));var u=s.DATA,l=s.BUFFER;function c(t){if(t){var e=t.length||t.byteLength,n=i.log2(e);u[n].push(t)}}function f(t){t=i.nextPow2(t);var e=i.log2(t),n=u[e];return n.length>0?n.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function p(t){return new Uint16Array(f(2*t),0,t)}function d(t){return new Uint32Array(f(4*t),0,t)}function v(t){return new Int8Array(f(t),0,t)}function g(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function _(t){return new Float32Array(f(4*t),0,t)}function y(t){return new Float64Array(f(8*t),0,t)}function w(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function b(t){return new DataView(f(t),0,t)}function x(t){t=i.nextPow2(t);var e=i.log2(t),n=l[e];return n.length>0?n.pop():new r(t)}n.free=function(t){if(r.isBuffer(t))l[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,n=0|i.log2(e);u[n].push(t)}},n.freeUint8=n.freeUint16=n.freeUint32=n.freeInt8=n.freeInt16=n.freeInt32=n.freeFloat32=n.freeFloat=n.freeFloat64=n.freeDouble=n.freeUint8Clamped=n.freeDataView=function(t){c(t.buffer)},n.freeArrayBuffer=c,n.freeBuffer=function(t){l[i.log2(t.length)].push(t)},n.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return v(t);case"int16":return g(t);case"int32":return m(t);case"float":case"float32":return _(t);case"double":case"float64":return y(t);case"uint8_clamped":return w(t);case"buffer":return x(t);case"data":case"dataview":return b(t);default:return null}return null},n.mallocArrayBuffer=f,n.mallocUint8=h,n.mallocUint16=p,n.mallocUint32=d,n.mallocInt8=v,n.mallocInt16=g,n.mallocInt32=m,n.mallocFloat32=n.mallocFloat=_,n.mallocFloat64=n.mallocDouble=y,n.mallocUint8Clamped=w,n.mallocDataView=b,n.mallocBuffer=x,n.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,u[t].length=0,l[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":2,buffer:5,dup:21}],145:[function(t,e,n){(function(){var t=this,r=t._,i={},a=Array.prototype,o=Object.prototype,s=Function.prototype,u=a.push,l=a.slice,c=a.concat,f=o.toString,h=o.hasOwnProperty,p=a.forEach,d=a.map,v=a.reduce,g=a.reduceRight,m=a.filter,_=a.every,y=a.some,w=a.indexOf,b=a.lastIndexOf,x=Array.isArray,k=Object.keys,E=s.bind,S=function(t){return t instanceof S?t:this instanceof S?void(this._wrapped=t):new S(t)};void 0!==n?(void 0!==e&&e.exports&&(n=e.exports=S),n._=S):t._=S,S.VERSION="1.4.4";var j=S.each=S.forEach=function(t,e,n){if(null!=t)if(p&&t.forEach===p)t.forEach(e,n);else if(t.length===+t.length){for(var r=0,a=t.length;r2;if(null==t&&(t=[]),v&&t.reduce===v)return r&&(e=S.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(j(t,function(t,a,o){i?n=e.call(r,n,t,a,o):(n=t,i=!0)}),!i)throw new TypeError(T);return n},S.reduceRight=S.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),g&&t.reduceRight===g)return r&&(e=S.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var a=t.length;if(a!==+a){var o=S.keys(t);a=o.length}if(j(t,function(s,u,l){u=o?o[--a]:--a,i?n=e.call(r,n,t[u],u,l):(n=t[u],i=!0)}),!i)throw new TypeError(T);return n},S.find=S.detect=function(t,e,n){var r;return A(t,function(t,i,a){if(e.call(n,t,i,a))return r=t,!0}),r},S.filter=S.select=function(t,e,n){var r=[];return null==t?r:m&&t.filter===m?t.filter(e,n):(j(t,function(t,i,a){e.call(n,t,i,a)&&(r[r.length]=t)}),r)},S.reject=function(t,e,n){return S.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},S.every=S.all=function(t,e,n){e||(e=S.identity);var r=!0;return null==t?r:_&&t.every===_?t.every(e,n):(j(t,function(t,a,o){if(!(r=r&&e.call(n,t,a,o)))return i}),!!r)};var A=S.some=S.any=function(t,e,n){e||(e=S.identity);var r=!1;return null==t?r:y&&t.some===y?t.some(e,n):(j(t,function(t,a,o){if(r||(r=e.call(n,t,a,o)))return i}),!!r)};S.contains=S.include=function(t,e){return null!=t&&(w&&t.indexOf===w?-1!=t.indexOf(e):A(t,function(t){return t===e}))},S.invoke=function(t,e){var n=l.call(arguments,2),r=S.isFunction(e);return S.map(t,function(t){return(r?e:t[e]).apply(t,n)})},S.pluck=function(t,e){return S.map(t,function(t){return t[e]})},S.where=function(t,e,n){return S.isEmpty(e)?n?null:[]:S[n?"find":"filter"](t,function(t){for(var n in e)if(e[n]!==t[n])return!1;return!0})},S.findWhere=function(t,e){return S.where(t,e,!0)},S.max=function(t,e,n){if(!e&&S.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.max.apply(Math,t);if(!e&&S.isEmpty(t))return-1/0;var r={computed:-1/0,value:-1/0};return j(t,function(t,i,a){var o=e?e.call(n,t,i,a):t;o>=r.computed&&(r={value:t,computed:o})}),r.value},S.min=function(t,e,n){if(!e&&S.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.min.apply(Math,t);if(!e&&S.isEmpty(t))return 1/0;var r={computed:1/0,value:1/0};return j(t,function(t,i,a){var o=e?e.call(n,t,i,a):t;or||void 0===n)return 1;if(n>>1;n.call(r,t[s])=0})})},S.difference=function(t){var e=c.apply(a,l.call(arguments,1));return S.filter(t,function(t){return!S.contains(e,t)})},S.zip=function(){for(var t=l.call(arguments),e=S.max(S.pluck(t,"length")),n=new Array(e),r=0;r=0;n--)e=[t[n].apply(this,e)];return e[0]}},S.after=function(t,e){return t<=0?e():function(){if(--t<1)return e.apply(this,arguments)}},S.keys=k||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var n in t)S.has(t,n)&&(e[e.length]=n);return e},S.values=function(t){var e=[];for(var n in t)S.has(t,n)&&e.push(t[n]);return e},S.pairs=function(t){var e=[];for(var n in t)S.has(t,n)&&e.push([n,t[n]]);return e},S.invert=function(t){var e={};for(var n in t)S.has(t,n)&&(e[t[n]]=n);return e},S.functions=S.methods=function(t){var e=[];for(var n in t)S.isFunction(t[n])&&e.push(n);return e.sort()},S.extend=function(t){return j(l.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},S.pick=function(t){var e={},n=c.apply(a,l.call(arguments,1));return j(n,function(n){n in t&&(e[n]=t[n])}),e},S.omit=function(t){var e={},n=c.apply(a,l.call(arguments,1));for(var r in t)S.contains(n,r)||(e[r]=t[r]);return e},S.defaults=function(t){return j(l.call(arguments,1),function(e){if(e)for(var n in e)null==t[n]&&(t[n]=e[n])}),t},S.clone=function(t){return S.isObject(t)?S.isArray(t)?t.slice():S.extend({},t):t},S.tap=function(t,e){return e(t),t};var R=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof S&&(t=t._wrapped),e instanceof S&&(e=e._wrapped);var i=f.call(t);if(i!=f.call(e))return!1;switch(i){case"[object String]":return t==String(e);case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var a=n.length;a--;)if(n[a]==t)return r[a]==e;n.push(t),r.push(e);var o=0,s=!0;if("[object Array]"==i){if(s=(o=t.length)==e.length)for(;o--&&(s=R(t[o],e[o],n,r)););}else{var u=t.constructor,l=e.constructor;if(u!==l&&!(S.isFunction(u)&&u instanceof u&&S.isFunction(l)&&l instanceof l))return!1;for(var c in t)if(S.has(t,c)&&(o++,!(s=S.has(e,c)&&R(t[c],e[c],n,r))))break;if(s){for(c in e)if(S.has(e,c)&&!o--)break;s=!o}}return n.pop(),r.pop(),s};S.isEqual=function(t,e){return R(t,e,[],[])},S.isEmpty=function(t){if(null==t)return!0;if(S.isArray(t)||S.isString(t))return 0===t.length;for(var e in t)if(S.has(t,e))return!1;return!0},S.isElement=function(t){return!(!t||1!==t.nodeType)},S.isArray=x||function(t){return"[object Array]"==f.call(t)},S.isObject=function(t){return t===Object(t)},j(["Arguments","Function","String","Number","Date","RegExp"],function(t){S["is"+t]=function(e){return f.call(e)=="[object "+t+"]"}}),S.isArguments(arguments)||(S.isArguments=function(t){return!(!t||!S.has(t,"callee"))}),"function"!=typeof/./&&(S.isFunction=function(t){return"function"==typeof t}),S.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},S.isNaN=function(t){return S.isNumber(t)&&t!=+t},S.isBoolean=function(t){return!0===t||!1===t||"[object Boolean]"==f.call(t)},S.isNull=function(t){return null===t},S.isUndefined=function(t){return void 0===t},S.has=function(t,e){return h.call(t,e)},S.noConflict=function(){return t._=r,this},S.identity=function(t){return t},S.times=function(t,e,n){for(var r=Array(t),i=0;i":">",'"':""","'":"'","/":"/"}};L.unescape=S.invert(L.escape);var B={escape:new RegExp("["+S.keys(L.escape).join("")+"]","g"),unescape:new RegExp("("+S.keys(L.unescape).join("|")+")","g")};S.each(["escape","unescape"],function(t){S[t]=function(e){return null==e?"":(""+e).replace(B[t],function(e){return L[t][e]})}}),S.result=function(t,e){if(null==t)return null;var n=t[e];return S.isFunction(n)?n.call(t):n},S.mixin=function(t){j(S.functions(t),function(e){var n=S[e]=t[e];S.prototype[e]=function(){var t=[this._wrapped];return u.apply(t,arguments),N.call(this,n.apply(S,t))}})};var F=0;S.uniqueId=function(t){var e=++F+"";return t?t+e:e},S.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;S.template=function(t,e,n){var r;n=S.defaults({},n,S.templateSettings);var i=new RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source].join("|")+"|$","g"),a=0,o="__p+='";t.replace(i,function(e,n,r,i,s){return o+=t.slice(a,s).replace(D,function(t){return"\\"+O[t]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),a=s+e.length,e}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(t){throw t.source=o,t}if(e)return r(e,S);var s=function(t){return r.call(this,t,S)};return s.source="function("+(n.variable||"obj")+"){\n"+o+"}",s},S.chain=function(t){return S(t).chain()};var N=function(t){return this._chain?S(t).chain():t};S.mixin(S),j(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=a[t];S.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],N.call(this,n)}}),j(["concat","join","slice"],function(t){var e=a[t];S.prototype[t]=function(){return N.call(this,e.apply(this._wrapped,arguments))}}),S.extend(S.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],146:[function(t,e,n){"use strict";e.exports=function(t,e,n){return 0===t.length?t:e?(n||t.sort(e),function(t,e){for(var n=1,r=t.length,i=t[0],a=t[0],o=1;o=o?u+1:o}r.mkdir(e+"sequencer"+o,function(){var a=e+"sequencer"+o+"/";for(var s in n.images){var u=n.images[s].steps;if(i){var l=u.slice(-1)[0].output.src,c=u.slice(-1)[0].output.format,f=t("data-uri-to-buffer")(l);r.writeFile(a+s+"_"+(u.length-1)+"."+c,f,function(){})}else for(var h in u){l=u[h].output.src,c=u[h].output.format,f=t("data-uri-to-buffer")(l);r.writeFile(a+s+"_"+h+"."+c,f,function(){})}}})},r.readdir(c,function(t,e){var n=[];if(void 0===e||0==e.length)return f(n),[];for(var i=0;i0&&(thisStep=c[t].steps[e],thisStep.UI.onRemove(thisStep.options.step),c[t].steps.splice(e,1))}function v(){var e=[],n=this;for(var r in arguments)e.push(a(arguments[r]));var i=l.call(this,e,"l");f.push({method:"loadImages",json_q:a(i)});var o=this.copy(i.loadedimages),s={name:"ImageSequencer Wrapper",sequencer:this,addSteps:this.addSteps,removeSteps:this.removeSteps,insertSteps:this.insertSteps,run:this.run,UI:this.UI,setUI:this.setUI,images:o};!function e(r){if(r!=o.length){var a=o[r];t("./ui/LoadImage")(n,a,i.images[a],function(){e(++r)})}else i.callback.call(s)}(0)}function g(t){var e={};if("load-image"==t)return{};if(0==arguments.length){for(var n in this.modules)e[n]=s[n][1];for(var r in this.sequences)e[r]={name:r,steps:u[r]}}else e=s[t]?s[t][1]:{inputs:u[t].options};return e}function m(t){let e=g(t.options.name).inputs||{},n={};for(let r in e)t.options[r]&&t.options[r]!=e[r].default&&(n[r]=t.options[r],n[r]=encodeURIComponent(n[r]));var r=Object.keys(n).map(t=>t+":"+n[t]).join("|");return`${t.options.name}{${r}}`}function _(t){let e;return(e=t.includes(",")?t.split(","):[t]).map(y)}function y(t){var e;if(e=t.includes("{")?t.includes("(")&&t.indexOf("(")=e.images[u].steps.length?{options:{name:void 0}}:e.images[u].steps.slice(f+t)[0]},e.images[u].steps[f].getIndex=function(){return f},r)r.hasOwnProperty(p)&&(e.images[u].steps[f][p]=r[p]);e.images[u].steps[f].UI.onDraw(e.images[u].steps[f].options.step);var d=t("./RunToolkit")(e.copy(h));e.images[u].steps[f].draw(d,function(){e.images[u].steps[f].options.step.output=e.images[u].steps[f].output.src,e.images[u].steps[f].UI.onComplete(e.images[u].steps[f].options.step),n(a,++s)},o)}}(s,a)}(n=function(t){for(var n in t)0==t[n]&&1==e.images[n].steps.length?delete t[n]:0==t[n]&&t[n]++;for(var n in t)for(var r=e.images[n].steps[t[n]-1];void 0===r||void 0===r.output;)r=e.images[n].steps[--t[n]-1];return t}(n))}},{"./RunToolkit":159,"./util/getStep.js":247}],159:[function(t,e,n){const r=t("get-pixels"),i=t("./modules/_nomodule/PixelManipulation"),a=t("lodash"),o=t("data-uri-to-buffer"),s=t("save-pixels");e.exports=function(t){return t.getPixels=r,t.pixelManipulation=i,t.lodash=a,t.dataUriToBuffer=o,t.savePixels=s,t}},{"./modules/_nomodule/PixelManipulation":242,"data-uri-to-buffer":20,"get-pixels":30,lodash:75,"save-pixels":138}],160:[function(t,e,n){e.exports={sample:[{name:"invert",options:{}},{name:"channel",options:{channel:"red"}},{name:"blur",options:{blur:"5"}}]}},{}],161:[function(t,e,n){e.exports=function(e,n){return e.blur=e.blur||2,e.step.metadata=e.step.metadata||{},{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[t,e,n,r]},extraManipulation:function(t){for(var n=[0,0,0,0],r=0;rAverages (r, g, b, a): "+n.join(", ")+"

"),t},format:n.format,image:e.image,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242}],162:[function(t,e,n){e.exports=[t("./Module"),t("./info.json")]},{"./Module":161,"./info.json":163}],163:[function(t,e,n){e.exports={name:"Average",description:"Average all pixel color",inputs:{}}},{}],164:[function(require,module,exports){module.exports=function Dynamic(options,UI,util){var output;function draw(input,callback,progressObj){progressObj.stop(!0),progressObj.overrideFlag=!0;var step=this;"string"==typeof options.func&&eval("options.func = "+options.func);var getPixels=require("get-pixels");"string"==typeof options.offset&&(options.offset=parseInt(options.offset));var priorStep=this.getStep(options.offset);getPixels(priorStep.output.src,function(t,e){return options.firstImagePixels=e,require("../_nomodule/PixelManipulation.js")(input,{output:function(t,e,n){step.output={src:e,format:n}},changePixel:function(t,e,n,r,i,a){var o=options.firstImagePixels;return options.func(t,e,n,r,o.get(i,a,0),o.get(i,a,1),o.get(i,a,2),o.get(i,a,3))},format:input.format,image:options.image,inBrowser:options.inBrowser,callback:callback})})}return options.func=options.func||"function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }",options.offset=options.offset||-2,{options:options,draw:draw,output:output,UI:UI}}},{"../_nomodule/PixelManipulation.js":242,"get-pixels":30}],165:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":164,"./info.json":166,dup:162}],166:[function(t,e,n){e.exports={name:"Blend",description:"Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!",inputs:{offset:{type:"integer",desc:"Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.",default:-2},blend:{type:"input",desc:"Function to use to blend the two images.",default:"function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"}}}},{}],167:[function(t,e,n){e.exports=function(t,e){let n=[[2/159,4/159,5/159,4/159,2/159],[4/159,9/159,12/159,9/159,4/159],[5/159,12/159,15/159,12/159,5/159],[4/159,9/159,12/159,9/159,4/159],[2/159,4/159,5/159,4/159,2/159]],r=t;n=function(t){let e=[];for(let n=t.length-1;n>=0;n--){let r=[];for(let e=t[n].length-1;e>=0;e--)r.push(t[n][e]);e.push(r)}return e}(n);for(let e=0;ev;n=0<=v?++c:--c)r[n]=(e-i)/(a-i)*(u[n]-s[n])+s[n];return r}}e.exports=function(t,e){return e.colormap=e.colormap||i.default,"object"==typeof e.colormap?colormapFunction=r(e.colormap):i.hasOwnProperty(e.colormap)?colormapFunction=i[e.colormap]:colormapFunction=i.default,colormapFunction(t/255)};var i={greyscale:r([[0,[0,0,0],[220,20,60]],[1,[255,255,255],[255,255,255]]]),bluwhtgrngis:r([[0,[6,23,86],[6,25,84]],[.0625,[6,25,84],[6,25,84]],[.125,[6,25,84],[6,25,84]],[.1875,[6,25,84],[6,25,84]],[.25,[6,25,84],[6,25,84]],[.3125,[6,25,84],[9,24,84]],[.3438,[9,24,84],[119,120,162]],[.375,[119,129,162],[249,250,251]],[.406,[249,250,251],[255,255,255]],[.4375,[255,255,255],[255,255,255]],[.5,[255,255,255],[214,205,191]],[.52,[214,205,191],[178,175,96]],[.5625,[178,175,96],[151,176,53]],[.593,[151,176,53],[146,188,12]],[.625,[146,188,12],[96,161,1]],[.6875,[96,161,1],[30,127,3]],[.75,[30,127,3],[0,99,1]],[.8125,[0,99,1],[0,74,1]],[.875,[0,74,1],[0,52,0]],[.9375,[0,52,0],[0,34,0]],[.968,[0,34,0],[68,70,67]]]),brntogrn:r([[0,[110,12,3],[118,6,1]],[.0625,[118,6,1],[141,19,6]],[.125,[141,19,6],[165,35,13]],[.1875,[165,35,13],[177,59,25]],[.2188,[177,59,25],[192,91,36]],[.25,[192,91,36],[214,145,76]],[.3125,[214,145,76],[230,183,134]],[.375,[230,183,134],[243,224,194]],[.4375,[243,224,194],[250,252,229]],[.5,[250,252,229],[217,235,185]],[.5625,[217,235,185],[184,218,143]],[.625,[184,218,143],[141,202,89]],[.6875,[141,202,89],[80,176,61]],[.75,[80,176,61],[0,147,32]],[.8125,[0,147,32],[1,122,22]],[.875,[1,122,22],[0,114,19]],[.9,[0,114,19],[0,105,18]],[.9375,[0,105,18],[7,70,14]]]),blutoredjet:r([[0,[0,0,140],[1,1,186]],[.0625,[1,1,186],[0,1,248]],[.125,[0,1,248],[0,70,254]],[.1875,[0,70,254],[0,130,255]],[.25,[0,130,255],[2,160,255]],[.2813,[2,160,255],[0,187,255]],[.3125,[0,187,255],[6,250,255]],[.375,[8,252,251],[27,254,228]],[.406,[27,254,228],[70,255,187]],[.4375,[70,255,187],[104,254,151]],[.47,[104,254,151],[132,255,19]],[.5,[132,255,19],[195,255,60]],[.5625,[195,255,60],[231,254,25]],[.5976,[231,254,25],[253,246,1]],[.625,[253,246,1],[252,210,1]],[.657,[252,210,1],[255,183,0]],[.6875,[255,183,0],[255,125,2]],[.75,[255,125,2],[255,65,1]],[.8125,[255,65,1],[247,1,1]],[.875,[247,1,1],[200,1,3]],[.9375,[200,1,3],[122,3,2]]]),colors16:r([[0,[0,0,0],[0,0,0]],[.0625,[3,1,172],[3,1,172]],[.125,[3,1,222],[3,1,222]],[.1875,[0,111,255],[0,111,255]],[.25,[3,172,255],[3,172,255]],[.3125,[1,226,255],[1,226,255]],[.375,[2,255,0],[2,255,0]],[.4375,[198,254,0],[190,254,0]],[.5,[252,255,0],[252,255,0]],[.5625,[255,223,3],[255,223,3]],[.625,[255,143,3],[255,143,3]],[.6875,[255,95,3],[255,95,3]],[.75,[242,0,1],[242,0,1]],[.8125,[245,0,170],[245,0,170]],[.875,[223,180,225],[223,180,225]],[.9375,[255,255,255],[255,255,255]]]),default:r([[0,[45,1,121],[25,1,137]],[.125,[25,1,137],[0,6,156]],[.1875,[0,6,156],[7,41,172]],[.25,[7,41,172],[22,84,187]],[.3125,[22,84,187],[25,125,194]],[.375,[25,125,194],[26,177,197]],[.4375,[26,177,197],[23,199,193]],[.47,[23,199,193],[25,200,170]],[.5,[25,200,170],[21,209,27]],[.5625,[21,209,27],[108,215,18]],[.625,[108,215,18],[166,218,19]],[.6875,[166,218,19],[206,221,20]],[.75,[206,221,20],[222,213,19]],[.7813,[222,213,19],[222,191,19]],[.8125,[222,191,19],[227,133,17]],[.875,[227,133,17],[231,83,16]],[.9375,[231,83,16],[220,61,48]]]),fastie:r([[0,[255,255,255],[0,0,0]],[.167,[0,0,0],[255,255,255]],[.33,[2,0,226],[2,0,226]],[.5,[0,0,0],[140,140,255]],[.55,[140,140,255],[0,255,0]],[.63,[0,255,0],[255,255,0]],[.75,[255,255,0],[255,0,0]],[.95,[255,0,0],[255,0,255]]]),stretched:r([[0,[0,0,255],[0,0,255]],[.1,[0,0,255],[38,195,195]],[.5,[0,150,0],[255,255,0]],[.7,[255,255,0],[255,50,50]],[.9,[255,50,50],[255,50,50]]])}},{}],181:[function(t,e,n){e.exports=function(e,n){return{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(n,r,i,a){var o=(n+r+i)/3,s=t("./Colormap")(o,e);return[s[0],s[1],s[2],255]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Colormap":180}],182:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":181,"./info.json":183,dup:162}],183:[function(t,e,n){e.exports={name:"Colormap",description:"Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.",inputs:{colormap:{type:"select",desc:"Name of the Colormap",default:"default",values:["default","greyscale","stretched","fastie","brntogrn","blutoredjet","colors16"]}}}},{}],184:[function(t,e,n){var r=t("lodash");e.exports=function(t,e){let n=r.cloneDeep(t);(e=Number(e))<-100&&(e=-100),e>100&&(e=100),e=(100+e)/100,e*=e;for(let r=0;r255&&(i=255);var a=n.get(r,s,1)/255;a-=.5,a*=e,a+=.5,(a*=255)<0&&(a=0),a>255&&(a=255);var o=n.get(r,s,2)/255;o-=.5,o*=e,o+=.5,(o*=255)<0&&(o=0),o>255&&(o=255),t.set(r,s,0,i),t.set(r,s,1,a),t.set(r,s,2,o)}return t}},{lodash:75}],185:[function(t,e,n){e.exports=function(e,n){return e.contrast=e.contrast||70,{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[t,e,n,r]},extraManipulation:function(n){return n=t("./Contrast")(n,e.contrast)},format:n.format,image:e.image,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Contrast":184}],186:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":185,"./info.json":187,dup:162}],187:[function(t,e,n){e.exports={name:"Contrast",description:"Change the contrast of the image by given value",inputs:{contrast:{type:"Number",desc:"contrast for the new image, typically -100 to 100",default:70}}}},{}],188:[function(t,e,n){var r=t("lodash");e.exports=function(t,e,n){let a=function(t,e){for(e=e.split(" "),i=0;i<9;i++)e[i]=Number(e[i])*t;let n=0,r=[];for(i=0;i<3;i++){let t=[];for(j=0;j<3;j++)t.push(e[n]),n+=1;r.push(t)}return r}(e,n),o=r.cloneDeep(t);a=function(t){let e=[];for(let n=t.length-1;n>=0;n--){let r=[];for(let e=t[n].length-1;e>=0;e--)r.push(t[n][e]);e.push(r)}return e}(a);for(let e=0;eRead more",inputs:{constantFactor:{type:"Float",desc:"a constant factor, multiplies all the kernel values by that factor",default:.1111,placeholder:.1111},kernelValues:{type:"String",desc:"nine space separated numbers representing the kernel values in left to right and top to bottom format.",default:"1 1 1 1 1 1 1 1 1",placeholder:"1 1 1 1 1 1 1 1 1"}}}},{}],192:[function(t,e,n){(function(n){e.exports=function(e,r,i){var a=t("get-pixels"),o=t("save-pixels");r.x=parseInt(r.x)||0,r.y=parseInt(r.y)||0,a(e.src,function(t,a){r.w=parseInt(r.w)||Math.floor(a.shape[0]),r.h=parseInt(r.h)||Math.floor(a.shape[1]);for(var s=r.x,u=r.y,l=r.w,c=r.h,f=a.shape[0],h=new Uint8Array(4*l*c),p=u;pInfragrammar.",inputs:{red:{type:"input",desc:"Expression to return for red channel with R, G, B, and A inputs",default:"r"},green:{type:"input",desc:"Expression to return for green channel with R, G, B, and A inputs",default:"g"},blue:{type:"input",desc:"Expression to return for blue channel with R, G, B, and A inputs",default:"b"},"monochrome (fallback)":{type:"input",desc:"Expression to return with R, G, B, and A inputs; fallback for other channels if none provided",default:"r + g + b"}}}},{}],203:[function(t,e,n){t("lodash");const r=[[-1,0,1],[-2,0,2],[-1,0,1]],i=[[-1,-2,-1],[0,0,0],[1,2,1]];function a(t,e,n,a,o){let s=0;for(let e=0;e<3;e++)for(let n=0;n<3;n++){let i=a+e-1,u=o+n-1;s+=t.get(i,u,0)*r[e][n]}let u=0;for(let e=0;e<3;e++)for(let n=0;n<3;n++){let r=a+e-1,s=o+n-1;u+=t.get(r,s,0)*i[e][n]}return{pixel:[e,e,e,Math.sqrt(Math.pow(s,2)+Math.pow(u,2))],angle:Math.atan2(u,s)}}e.exports=function(t,e,n,r){let i=[],u=[];for(var l=0;lt.map(o));for(let r=1;r=-22.5&&a<=22.5||a<-157.5&&a>=-180?e[r][i]>=e[r][i+1]&&e[r][i]>=e[r][i-1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):a>=22.5&&a<=67.5||a<-112.5&&a>=-157.5?e[r][i]>=e[r+1][i+1]&&e[r][i]>=e[r-1][i-1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):a>=67.5&&a<=112.5||a<-67.5&&a>=-112.5?e[r][r]>=e[r+1][i]&&e[r][i]>=e[r][i]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):(a>=112.5&&a<=157.5||a<-22.5&&a>=-67.5)&&(e[r][i]>=e[r+1][i-1]&&e[r][i]>=e[r-1][i+1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0))}}(t,u,i),function(t,e,n,r,i,a){const o=s(r)*e,u=o*n;for(let e=0;eu?r[e][n]>o?i.push(s):a.push(s):t.set(e,n,3,0)}i.forEach(e=>t.set(e[0],e[1],3,255))}(t,e,n,u,[],[]),t};var o=t=>180*t/Math.PI,s=t=>Math.max(...t.map(t=>t.map(t=>t||0)).map(t=>Math.max(...t)))},{lodash:75}],204:[function(t,e,n){e.exports=function(e,n){return e.blur=e.blur||2,e.highThresholdRatio=e.highThresholdRatio||.2,e.lowThresholdRatio=e.lowThresholdRatio||.15,{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[(t+e+n)/3,(t+e+n)/3,(t+e+n)/3,r]},extraManipulation:function(n){return n=t("ndarray-gaussian-filter")(n,e.blur),n=t("./EdgeUtils")(n,e.highThresholdRatio,e.lowThresholdRatio,e.inBrowser)},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./EdgeUtils":203,"ndarray-gaussian-filter":80}],205:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":204,"./info.json":206,dup:162}],206:[function(t,e,n){e.exports={name:"Detect Edges",description:"this module detects edges using the Canny method, which first Gaussian blurs the image to reduce noise (amount of blur configurable in settings as `options.blur`), then applies a number of steps to highlight edges, resulting in a greyscale image where the brighter the pixel, the stronger the detected edge. Read more. ",inputs:{blur:{type:"integer",desc:"amount of gaussian blur(Less blur gives more detail, typically 0-5)",default:2},highThresholdRatio:{type:"float",desc:"The high threshold ratio for the image",default:.2},lowThresholdRatio:{type:"float",desc:"The low threshold value for the image",default:.15}}}},{}],207:[function(t,e,n){e.exports=function(e,n){return t("fisheyegl"),{options:e,draw:function(t,n){var r=this;if(e.inBrowser){if(document.querySelector("#image-sequencer-canvas"))var i=document.querySelector("#image-sequencer-canvas");else(i=document.createElement("canvas")).style.display="none",i.setAttribute("id","image-sequencer-canvas"),document.body.append(i);distorter=FisheyeGl({selector:"#image-sequencer-canvas"}),e.a=parseFloat(e.a)||distorter.lens.a,e.b=parseFloat(e.b)||distorter.lens.b,e.Fx=parseFloat(e.Fx)||distorter.lens.Fx,e.Fy=parseFloat(e.Fy)||distorter.lens.Fy,e.scale=parseFloat(e.scale)||distorter.lens.scale,e.x=parseFloat(e.x)||distorter.fov.x,e.y=parseFloat(e.y)||distorter.fov.y,distorter.lens.a=e.a,distorter.lens.b=e.b,distorter.lens.Fx=e.Fx,distorter.lens.Fy=e.Fy,distorter.lens.scale=e.scale,distorter.fov.x=e.x,distorter.fov.y=e.y,distorter.setImage(t.src,function(){r.output={src:i.toDataURL(),format:t.format},n()})}else this.output=t,n()},output:void 0,UI:n}}},{fisheyegl:22}],208:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":207,"./info.json":209,dup:162}],209:[function(t,e,n){e.exports={name:"Fisheye GL",description:"Correct fisheye, or barrel distortion, in images (with WebGL -- adapted from fisheye-correction-webgl by @bluemir).",requires:["webgl"],inputs:{a:{type:"float",desc:"a parameter",default:1,min:1,max:4},b:{type:"float",desc:"b parameter",default:1,min:1,max:4},Fx:{type:"float",desc:"Fx parameter",default:0,min:0,max:4},Fy:{type:"float",desc:"Fy parameter",default:0,min:0,max:4},scale:{type:"float",desc:"Image Scaling",default:1.5,min:0,max:20},x:{type:"float",desc:"FOV x parameter",default:1.5,min:0,max:20},y:{type:"float",desc:"FOV y parameter",default:1.5,min:0,max:20},fragmentSrc:{type:"PATH",desc:"Path to a WebGL fragment shader file",default:"(inbuilt)"},vertexSrc:{type:"PATH",desc:"Path to a WebGL vertex shader file",default:"(inbuilt)"}}}},{}],210:[function(t,e,n){e.exports=function(e,n){return{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,n,r,i){var a=e.adjustment||.2;return[t=255*Math.pow(t/255,a),n=255*Math.pow(n/255,a),r=255*Math.pow(r/255,a),i]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242}],211:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":210,"./info.json":212,dup:162}],212:[function(t,e,n){e.exports={name:"Gamma Correction",description:"Apply gamma correction on the image Read more",inputs:{adjustment:{type:"float",desc:"gamma correction (inverse of actual gamma factor) for the new image",default:.2}}}},{}],213:[function(t,e,n){(function(n){e.exports=function(e,r){return{options:e,draw:function(e,r,i){var a=t("get-pixels"),o=t("save-pixels"),s=this;a(e.src,function(t,i){if(t)console.log("Bad Image path");else{for(var a=0,u=0;u

Select or drag in an image to overlay.

';$(t.ui).find(".details").prepend(i),sequencer.setInputStep({dropZoneSelector:"#"+r,fileInputSelector:"#"+r+" .file-input",onLoad:function(e){var n=e.target;t.options.imageUrl=n.result,t.options.url=n.result,sequencer.run(),setUrlHashParameter("steps",sequencer.toString())}}),$(t.ui).find(".btn-save").on("click",function(){var e=$(t.ui).find(".det input").val();t.options.imageUrl=e,sequencer.run()})}}}},{}],221:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":219,"./info.json":222,dup:162}],222:[function(t,e,n){e.exports={name:"Import Image",description:"Import a new image and replace the original with it. Future versions may enable a blend mode. Specify an image by URL or by file selector.",url:"https://github.com/publiclab/image-sequencer/tree/master/MODULES.md",inputs:{url:{type:"string",desc:"URL of image to import",default:"./images/monarch.png"}}}},{}],223:[function(t,e,n){e.exports=function(){return this.expandSteps([{name:"ndvi",options:{}},{name:"colormap",options:{}}]),{isMeta:!0}}},{}],224:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":223,"./info.json":225,dup:162}],225:[function(t,e,n){e.exports={name:"NDVI-Colormap",description:"Sequentially Applies NDVI and Colormap steps",inputs:{},length:2}},{}],226:[function(t,e,n){e.exports=function(e,n){if(e.step.inBrowser)var r=t("./Ui.js")(e.step,n);return e.filter=e.filter||"red",{options:e,draw:function(n,i,a){a.stop(!0),a.overrideFlag=!0;var o=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){o.output={src:e,format:n}},changePixel:function(t,n,r,i){if("red"==e.filter)var a=(r-t)/(1*r+t);"blue"==e.filter&&(a=(t-r)/(1*r+t));var o=255*(a+1)/2;return[o,o,o,i]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:function(){e.step.inBrowser&&r.setup(),i()}})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Ui.js":227}],227:[function(t,e,n){e.exports=function(t,e){return{setup:function(){var e=$(t.imgElement);e.mousemove(function(t){var n=document.createElement("canvas");n.width=e.width(),n.height=e.height(),n.getContext("2d").drawImage(this,0,0);var r=$(this).offset(),i=t.pageX-r.left,a=t.pageY-r.top,o=n.getContext("2d").getImageData(i,a,1,1).data[0];o=(o=o/127.5-1).toFixed(2),e[0].title="NDVI: "+o})}}}},{}],228:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":226,"./info.json":229,dup:162}],229:[function(t,e,n){e.exports={name:"NDVI",description:"Normalized Difference Vegetation Index, or NDVI, is an image analysis technique used with aerial photography. It's a way to visualize the amounts of infrared and other wavelengths of light reflected from vegetation by comparing ratios of blue and red light absorbed versus green and IR light reflected. NDVI is used to evaluate the health of vegetation in satellite imagery, where it correlates with how much photosynthesis is happening. This is helpful in assessing vegetative health or stress. Read more.

This is designed for use with red-filtered single camera DIY Infragram cameras; change to 'blue' for blue filters",inputs:{filter:{type:"select",desc:"Filter color",default:"red",values:["red","blue"]}}}},{}],230:[function(t,e,n){e.exports=function(e,n,r){return e.x=e.x||0,e.y=e.y||0,{options:e,draw:function(n,r,i){e.offset=e.offset||-2,i.stop(!0),i.overrideFlag=!0;var a=this,o=this.getStep(e.offset).image,s=this.getOutput(e.offset);t("get-pixels")(n.src,function(n,i){return e.secondImagePixels=i,t("../_nomodule/PixelManipulation.js")(s,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,n,r,i,a,o){var s=e.secondImagePixels;return a>=e.x&&a=e.y&&o
To work with a new or different image, drag one into the drop zone.",ID:e.options.sequencerCounter++,imageName:t,inBrowser:e.options.inBrowser,ui:e.options.ui},o={src:n,steps:[{options:{id:r.ID,name:"load-image",description:"This initial step loads and displays the original image without any modifications.",title:"Load Image",step:r},UI:e.events,draw:function(){return UI.onDraw(options.step),1==arguments.length?(this.output=a(arguments[0]),options.step.output=this.output,UI.onComplete(options.step),!0):2==arguments.length&&(this.output=a(arguments[0]),options.step.output=this.output,arguments[1](),UI.onComplete(options.step),!0)}}]};a(n,function(n){var r=function(t){return{src:t,format:t.split(":")[1].split(";")[0].split("/")[1]}}(n);e.images[t]=o;var a=e.images[t].steps[0];return a.output=r,a.options.step.output=a.output.src,a.UI.onSetup(a.options.step),a.UI.onDraw(a.options.step),a.UI.onComplete(a.options.step),i(),!0})}(n,r)}},{urify:147}],244:[function(t,e,n){e.exports=function(){return function(t){var e=$(t.dropZoneSelector),n=$(t.fileInputSelector),r=t.onLoad;function i(t){if(t.preventDefault(),t.stopPropagation(),t.target&&t.target.files)var e=t.target.files[0];else e=t.dataTransfer.files[0];if(e){var n=new FileReader;n.onload=r,n.readAsDataURL(e)}}new FileReader,n.on("change",i),e[0].addEventListener("drop",i,!1),e.on("dragover",function(t){t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"},!1),e.on("dragenter",function(t){e.addClass("hover")}),e.on("dragleave",function(t){e.removeClass("hover")})}}},{}],245:[function(t,e,n){e.exports=function(t={}){return t.onSetup=t.onSetup||function(t){0==t.ui||(t.inBrowser?console.log('Added Step "'+t.name+'" to "'+t.imageName+'".'):console.log("%s",'Added Step "'+t.name+'" to "'+t.imageName+'".'))},t.onDraw=t.onDraw||function(t){0==t.ui||(t.inBrowser?console.log('Drawing Step "'+t.name+'" on "'+t.imageName+'".'):console.log("%s",'Drawing Step "'+t.name+'" on "'+t.imageName+'".'))},t.onComplete=t.onComplete||function(t){0==t.ui||(t.inBrowser?console.log('Drawn Step "'+t.name+'" on "'+t.imageName+'".'):console.log("%s",'Drawn Step "'+t.name+'" on "'+t.imageName+'".'))},t.onRemove=t.onRemove||function(t){0==t.ui||(t.inBrowser?console.log('Removing Step "'+t.name+'" of "'+t.imageName+'".'):console.log("%s",'Removing Step "'+t.name+'" of "'+t.imageName+'".'))},t}},{}],246:[function(t,e,n){e.exports=function(t){var e=void 0;return"jpeg"===(e=(e=function(t){return"data:image"===t.substr(0,10)}(t)?t.split(";")[0].split("/").pop():t.split(".").pop()).toLowerCase())&&(e="jpg"),["jpg","jpeg","png","gif","canvas"].includes(e)?e:"jpg"}},{}],247:[function(t,e,n){e.exports={getPreviousStep:function(){return this.getStep(-1)},getNextStep:function(){return this.getStep(1)},getInput:function(t){return t+this.getIndex()===0&&t++,this.getStep(t-1).output},getOutput:function(t){return this.getStep(t).output},getOptions:function(){return this.getStep(0).options},setOptions:function(t){let e=this.getStep(0).options;for(let n in t)e[n]&&(e[n]=t[n])},getFormat:function(){return this.getStep(-1).output.format},getHeight:function(t){let e=new Image;e.onload=function(){t(e.height)},e.src=this.getInput(0).src},getWidth:function(t){let e=new Image;e.onload=function(){t(e.width)},e.src=this.getInput(0).src}}},{}]},{},[154]); \ No newline at end of file +!function(){return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o0?r-4:r,f=0;f>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[u++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},n.fromByteArray=function(t){for(var e,n=t.length,i=n%3,a=[],o=0,s=n-i;os?s:o+16383));1===i?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return a.join("")};for(var r=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var i,a,o=[],s=e;s>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],2:[function(t,e,n){"use strict";"use restrict";function r(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}n.INT_BITS=32,n.INT_MAX=2147483647,n.INT_MIN=-1<<31,n.sign=function(t){return(t>0)-(t<0)},n.abs=function(t){var e=t>>31;return(t^e)-e},n.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=n=((t>>>=e)>255)<<3,e|=n=((t>>>=n)>15)<<2,(e|=n=((t>>>=n)>3)<<1)|(t>>>=n)>>1},n.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},n.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.countTrailingZeros=r,n.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},n.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},n.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,r=e,i=7;for(n>>>=1;n;n>>>=1)r<<=1,r|=1&n,--i;t[e]=r<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},n.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},n.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},n.interleave3=function(t,e,n){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},n.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},n.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>r(t)+1}},{}],3:[function(t,e,n){(function(t,r,i){!function(t){if("object"==typeof n&&void 0!==e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:void 0!==r?i=r:"undefined"!=typeof self&&(i=self),i.Promise=t()}}(function(){var e,n,a;return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){var n=e[o][1][t];return i(n||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof _dereq_&&_dereq_,o=0;o0;)p(t)}function p(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}u.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},u.prototype.hasCustomScheduler=function(){return this._customScheduler},u.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},u.prototype.disableTrampolineIfNecessary=function(){s.hasDevTools&&(this._trampolineEnabled=!1)},u.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},u.prototype.fatalError=function(e,n){n?(t.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),t.exit(2)):this.throwLater(e)},u.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},s.hasDevTools?(u.prototype.invokeLater=function(t,e,n){this._trampolineEnabled?l.call(this,t,e,n):this._schedule(function(){setTimeout(function(){t.call(e,n)},100)})},u.prototype.invoke=function(t,e,n){this._trampolineEnabled?c.call(this,t,e,n):this._schedule(function(){t.call(e,n)})},u.prototype.settlePromises=function(t){this._trampolineEnabled?f.call(this,t):this._schedule(function(){t._settlePromises()})}):(u.prototype.invokeLater=l,u.prototype.invoke=c,u.prototype.settlePromises=f),u.prototype._drainQueues=function(){h(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,h(this._lateQueue)},u.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},u.prototype._reset=function(){this._isTickUsed=!1},n.exports=u,n.exports.firstLineError=i},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,a=function(t,e){this._reject(e)},o=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(a,a,null,this,t)},s=function(t,e){0==(50397184&this._bitField)&&this._resolveCallback(e.target)},u=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(a){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(a),c=new t(e);c._propagateFrom(this,1);var f=this._target();if(c._setBoundTo(l),l instanceof t){var h={promiseRejectionQueued:!1,promise:c,target:f,bindingPromise:l};f._then(e,o,void 0,c,h),l._then(s,u,void 0,c,h),c._setOnCancel(l)}else c._resolveCallback(f);return c},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152==(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";var r;"undefined"!=typeof Promise&&(r=Promise);var i=t("./promise")();i.noConflict=function(){try{Promise===i&&(Promise=r)}catch(t){}return i},e.exports=i},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),a=r(null);i[" size"]=a[" size"]=0}e.exports=function(e){var n,r=t("./util"),i=r.canEvaluate;r.isIdentifier;function a(t,n){var i;if(null!=t&&(i=t[n]),"function"!=typeof i){var a="Object "+r.classString(t)+" has no method '"+r.toString(n)+"'";throw new e.TypeError(a)}return i}function o(t){return a(t,this.pop()).apply(t,this)}function s(t){return t[this]}function u(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(o,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e;if("number"==typeof t)e=u;else if(i){var r=n(t);e=null!==r?r:s}else e=s;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var a=t("./util"),o=a.tryCatch,s=a.errorObj,u=e._async;e.prototype.break=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(a.isArray(t))for(var n=0;n=0)return n[t]}return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},r.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,n.push(this._trace))},r.prototype._popContext=function(){if(void 0!==this._trace){var t=n.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},r.CapturedTrace=null,r.create=function(){if(e)return new r},r.deactivateLongStackTraces=function(){},r.activateLongStackTraces=function(){var n=t.prototype._pushContext,a=t.prototype._popContext,o=t._peekContext,s=t.prototype._peekContext,u=t.prototype._promiseCreated;r.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=a,t._peekContext=o,t.prototype._peekContext=s,t.prototype._promiseCreated=u,e=!1},e=!0,t.prototype._pushContext=r.prototype._pushContext,t.prototype._popContext=r.prototype._popContext,t._peekContext=t.prototype._peekContext=i,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},r}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){var i,a,o,s=n._getDomain,u=n._async,l=e("./errors").Warning,c=e("./util"),f=e("./es5"),h=c.canAttachTrace,p=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,d=/\((?:timers\.js):\d+:\d+\)/,v=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,g=null,m=null,_=!1,y=!(0==c.env("BLUEBIRD_DEBUG")),w=!(0==c.env("BLUEBIRD_WARNINGS")||!y&&!c.env("BLUEBIRD_WARNINGS")),b=!(0==c.env("BLUEBIRD_LONG_STACK_TRACES")||!y&&!c.env("BLUEBIRD_LONG_STACK_TRACES")),x=0!=c.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(w||!!c.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},n.prototype._ensurePossibleRejectionHandled=function(){if(0==(524288&this._bitField)){this._setRejectionIsUnhandled();var t=this;setTimeout(function(){t._notifyUnhandledRejection()},1)}},n.prototype._notifyUnhandledRejectionIsHandled=function(){H("rejectionHandled",i,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!=(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),H("unhandledRejection",a,t,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(t,e,n){return z(t,e,n||this)},n.onPossiblyUnhandledRejection=function(t){var e=s();a="function"==typeof t?null===e?t:c.domainBind(e,t):void 0},n.onUnhandledRejectionHandled=function(t){var e=s();i="function"==typeof t?null===e?t:c.domainBind(e,t):void 0};var k=function(){};n.longStackTraces=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!K.longStackTraces&&Z()){var t=n.prototype._captureStackTrace,e=n.prototype._attachExtraTrace,i=n.prototype._dereferenceTrace;K.longStackTraces=!0,k=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=t,n.prototype._attachExtraTrace=e,n.prototype._dereferenceTrace=i,r.deactivateLongStackTraces(),u.enableTrampoline(),K.longStackTraces=!1},n.prototype._captureStackTrace=D,n.prototype._attachExtraTrace=N,n.prototype._dereferenceTrace=U,r.activateLongStackTraces(),u.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return K.longStackTraces&&Z()};var E=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n={detail:e,cancelable:!0};f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason});var r=new CustomEvent(t.toLowerCase(),n);return!c.global.dispatchEvent(r)}}if("function"==typeof Event){t=new Event("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason}),!c.global.dispatchEvent(n)}}return(t=document.createEvent("CustomEvent")).initCustomEvent("testingtheevent",!1,!0,{}),c.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!c.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),S=c.isNode?function(){return t.emit.apply(t,arguments)}:c.global?function(t){var e="on"+t.toLowerCase(),n=c.global[e];return!!n&&(n.apply(c.global,[].slice.call(arguments,1)),!0)}:function(){return!1};function j(t,e){return{promise:e}}var T={promiseCreated:j,promiseFulfilled:j,promiseRejected:j,promiseResolved:j,promiseCancelled:j,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:j},A=function(t){var e=!1;try{e=S.apply(null,arguments)}catch(t){u.throwLater(t),e=!0}var n=!1;try{n=E(t,T[t].apply(null,arguments))}catch(t){u.throwLater(t),n=!0}return n||e};function C(){return!1}function M(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+c.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function I(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?c.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function R(){return this._onCancelField}function L(t){this._onCancelField=t}function B(){this._cancellationParent=void 0,this._onCancelField=void 0}function F(t,e){if(0!=(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}n.config=function(t){if("longStackTraces"in(t=Object(t))&&(t.longStackTraces?n.longStackTraces():!t.longStackTraces&&n.hasLongStackTraces()&&k()),"warnings"in t){var e=t.warnings;K.warnings=!!e,x=K.warnings,c.isObject(e)&&"wForgottenReturn"in e&&(x=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!K.cancellation){if(u.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=B,n.prototype._propagateFrom=F,n.prototype._onCancel=R,n.prototype._setOnCancel=L,n.prototype._attachCancellationCallback=I,n.prototype._execute=M,P=F,K.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!K.monitoring?(K.monitoring=!0,n.prototype._fireEvent=A):!t.monitoring&&K.monitoring&&(K.monitoring=!1,n.prototype._fireEvent=C)),n},n.prototype._fireEvent=C,n.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(t){},n.prototype._attachCancellationCallback=function(t){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._dereferenceTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(t,e){};var P=function(t,e){0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)};function O(){var t=this._boundTo;return void 0!==t&&t instanceof n?t.isFulfilled()?t.value():void 0:t}function D(){this._trace=new J(this._peekContext())}function N(t,e){if(h(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=V(t);c.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),c.notEnumerableProp(t,"__stackCleaned__",!0)}}}function U(){this._trace=void 0}function z(t,e,r){if(K.warnings){var i,a=new l(t);if(e)r._attachExtraTrace(a);else if(K.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(a);else{var o=V(a);a.stack=o.message+"\n"+o.stack.join("\n")}A("warning",a)||G(a,"",!0)}}function q(t){for(var e=[],n=0;n0?function(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:q(e)}}function G(t,e,n){if("undefined"!=typeof console){var r;if(c.isObject(t)){var i=t.stack;r=e+m(i,t)}else r=e+String(t);"function"==typeof o?o(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function H(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){u.throwLater(t)}"unhandledRejection"===t?A(t,n,r)||i||G(n,"Unhandled rejection "):A(t,r)}function W(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():c.toString(t);if(/\[object [a-zA-Z0-9$_]+\]/.test(e))try{e=JSON.stringify(t)}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+function(t){if(t.length<41)return t;return t.substr(0,38)+"..."}(e)+">, no stack trace)"}function Z(){return"function"==typeof Q}var Y=function(){return!1},X=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function $(t){var e=t.match(X);if(e)return{fileName:e[1],line:parseInt(e[2],10)}}function J(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);Q(this,J),e>32&&this.uncycle()}c.inherits(J,Error),r.CapturedTrace=J,J.prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;for(r=(t=this._length=r)-1;r>=0;--r){var a=e[r].stack;void 0===n[a]&&(n[a]=r)}for(r=0;r0&&(e[o-1]._parent=void 0,e[o-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var s=r>0?e[r-1]:this;o=0;--l)e[l]._length=u,u++;return}}}},J.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=V(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(q(i.stack.split("\n"))),i=i._parent;!function(t){for(var e=t[0],n=1;n=0;--s)if(r[s]===a){o=s;break}for(s=o;s>=0;--s){var u=r[s];if(e[i]!==u)break;e.pop(),i--}e=r}}(r),function(t){for(var e=0;e=0)return g=/@/,m=e,_=!0,function(t){t.stack=(new Error).stack};try{throw new Error}catch(t){r="stack"in t}return"stack"in i||!r||"number"!=typeof Error.stackTraceLimit?(m=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?W(e):e.toString()},null):(g=t,m=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}();"undefined"!=typeof console&&void 0!==console.warn&&(o=function(t){console.warn(t)},c.isNode&&t.stderr.isTTY?o=function(t,e){var n=e?"":"";console.warn(n+t+"\n")}:c.isNode||"string"!=typeof(new Error).stack||(o=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var K={warnings:w,longStackTraces:!1,cancellation:!1,monitoring:!1};return b&&n.longStackTraces(),{longStackTraces:function(){return K.longStackTraces},warnings:function(){return K.warnings},cancellation:function(){return K.cancellation},monitoring:function(){return K.monitoring},propagateFromFunction:function(){return P},boundValueFunction:function(){return O},checkForgottenReturns:function(t,e,n,r,i){if(void 0===t&&null!==e&&x){if(void 0!==i&&i._returnedNonUndefined())return;if(0==(65535&r._bitField))return;n&&(n+=" ");var a="",o="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=q(s),l=u.length-1;l>=0;--l){var c=u[l];if(!d.test(c)){var f=c.match(v);f&&(a="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0){var h=u[0];for(l=0;l0&&(o="\n"+s[l-1]);break}}}var p="a promise was created in a "+n+"handler "+a+"but was not returned from it, see http://goo.gl/rRqMUw"+o;r._warn(p,!0,e)}},setBounds:function(t,e){if(Z()){for(var n,r,i=t.stack.split("\n"),a=e.stack.split("\n"),o=-1,s=-1,u=0;u=s||(Y=function(t){if(p.test(t))return!0;var e=$(t);return!!(e&&e.fileName===n&&o<=e.line&&e.line<=s)})}},warn:z,deprecated:function(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),z(n)},CapturedTrace:J,fireDomEvent:E,fireGlobalEvent:S}}},{"./errors":12,"./es5":13,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype.return=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1];return this.caught(t,function(){throw e})},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();return this.caught(n,function(){return r})}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){var n=t.reduce,r=t.all;function i(){return r(this)}t.prototype.each=function(t){return n(this,t,e,0)._then(i,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return n(this,t,e,e)},t.each=function(t,r){return n(t,r,e,0)._then(i,void 0,void 0,t,void 0)},t.mapSeries=function(t,r){return n(t,r,e,e)}}},{}],12:[function(t,e,n){"use strict";var r,i,a=t("./es5"),o=a.freeze,s=t("./util"),u=s.inherits,l=s.notEnumerableProp;function c(t,e){function n(r){if(!(this instanceof n))return new n(r);l(this,"message","string"==typeof r?r:e),l(this,"name",t),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return u(n,Error),n}var f=c("Warning","warning"),h=c("CancellationError","cancellation error"),p=c("TimeoutError","timeout error"),d=c("AggregateError","aggregate error");try{r=TypeError,i=RangeError}catch(t){r=c("TypeError","type error"),i=c("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0)}function f(){return p.call(this,this.promise._target()._settledValue())}function h(t){if(!c(this,t))return o.e=t,o}function p(t){var i=this.promise,s=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?s.call(i._boundValue()):s.call(i._boundValue(),t);if(u===r)return u;if(void 0!==u){i._setReturnedNonUndefined();var p=n(u,i);if(p instanceof e){if(null!=this.cancelPromise){if(p._isCancelled()){var d=new a("late cancellation observer");return i._attachExtraTrace(d),o.e=d,o}p.isPending()&&p._attachCancellationCallback(new l(this))}return p._then(f,h,void 0,this,void 0)}}}return i.isRejected()?(c(this),o.e=t,o):(c(this),t)}return u.prototype.isFinallyHandler=function(){return 0===this.type},l.prototype._resultCancelled=function(){c(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new u(this,e,t),void 0)},e.prototype.lastly=e.prototype.finally=function(t){return this._passThrough(t,0,p,p)},e.prototype.tap=function(t){return this._passThrough(t,1,p)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,p);var r,a=new Array(n-1),o=0;for(r=0;r0&&"function"==typeof arguments[e]&&(t=arguments[e]);var r=[].slice.call(arguments);t&&r.pop();var i=new n(r).promise();return void 0!==t?i.spread(t):i}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=e._getDomain,u=t("./util"),l=u.tryCatch,c=u.errorObj,f=e._async;function h(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=s();this._callback=null===i?e:u.domainBind(i,e),this._preservedValues=r===a?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=[],f.invoke(this._asyncInit,this,void 0)}function p(t,n,i,a){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var o=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));o=i.concurrency}return new h(t,n,o="number"==typeof o&&isFinite(o)&&o>=1?o:0,a).promise()}u.inherits(h,n),h.prototype._asyncInit=function(){this._init$(void 0,-2)},h.prototype._init=function(){},h.prototype._promiseFulfilled=function(t,n){var r=this._values,a=this.length(),s=this._preservedValues,u=this._limit;if(n<0){if(r[n=-1*n-1]=t,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=t,this._queue.push(n),!1;null!==s&&(s[n]=t);var f=this._promise,h=this._callback,p=f._boundValue();f._pushContext();var d=l(h).call(p,t,n,a),v=f._popContext();if(o.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",f),d===c)return this._reject(d.e),!0;var g=i(d,this._promise);if(g instanceof e){var m=(g=g._target())._bitField;if(0==(50397184&m))return u>=1&&this._inFlight++,r[n]=g,g._proxy(this,-1*(n+1)),!1;if(0==(33554432&m))return 0!=(16777216&m)?(this._reject(g._reason()),!0):(this._cancel(),!0);d=g._value()}r[n]=d}return++this._totalResolved>=a&&(null!==s?this._filter(r,s):this._resolve(r),!0)},h.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlight1){a.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],c=arguments[2];r=o.isArray(l)?s(t).apply(c,l):s(t).call(c,l)}else r=s(t)();var f=u._popContext();return a.checkForgottenReturns(r,f,"Promise.try",u),u._resolveFromSyncValue(r),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";var r=t("./util"),i=r.maybeWrapAsError,a=t("./errors").OperationalError,o=t("./es5");var s=/^(?:name|message|stack|cause)$/;function u(t){var e;if(function(t){return t instanceof Error&&o.getPrototypeOf(t)===Error.prototype}(t)){(e=new a(t)).name=t.name,e.message=t.message,e.stack=t.stack;for(var n=o.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;n0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+l.classString(t);arguments.length>1&&(n+=", "+l.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},C.prototype.done=function(t,e){this._then(t,e,void 0,void 0,void 0)._setIsFinal()},C.prototype.spread=function(t){return"function"!=typeof t?a("expecting a function but got "+l.classString(t)):this.all()._then(t,void 0,void 0,m,void 0)},C.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},C.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new w(this).promise()},C.prototype.error=function(t){return this.caught(l.originatesFromRejection,t)},C.getNewLibraryCopy=n.exports,C.is=function(t){return t instanceof C},C.fromNode=C.fromCallback=function(t){var e=new C(g);e._captureStackTrace();var n=arguments.length>1&&!!Object(arguments[1]).multiArgs,r=A(t)(j(e,n));return r===T&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},C.all=function(t){return new w(t).promise()},C.cast=function(t){var e=y(t);return e instanceof C||((e=new C(g))._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},C.resolve=C.fulfilled=C.cast,C.reject=C.rejected=function(t){var e=new C(g);return e._captureStackTrace(),e._rejectCallback(t,!0),e},C.setScheduler=function(t){if("function"!=typeof t)throw new d("expecting a function but got "+l.classString(t));return h.setScheduler(t)},C.prototype._then=function(t,e,n,r,i){var a=void 0!==i,o=a?i:new C(g),u=this._target(),c=u._bitField;a||(o._propagateFrom(this,3),o._captureStackTrace(),void 0===r&&0!=(2097152&this._bitField)&&(r=0!=(50397184&c)?this._boundValue():u===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,o));var f=s();if(0!=(50397184&c)){var p,d,m=u._settlePromiseCtx;0!=(33554432&c)?(d=u._rejectionHandler0,p=t):0!=(16777216&c)?(d=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(m=u._settlePromiseLateCancellationObserver,d=new v("late cancellation observer"),u._attachExtraTrace(d),p=e),h.invoke(m,u,{handler:null===f?p:"function"==typeof p&&l.domainBind(f,p),promise:o,receiver:r,value:d})}else u._addCallbacks(t,e,o,r,f);return o},C.prototype._length=function(){return 65535&this._bitField},C.prototype._isFateSealed=function(){return 0!=(117506048&this._bitField)},C.prototype._isFollowing=function(){return 67108864==(67108864&this._bitField)},C.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},C.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},C.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},C.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},C.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},C.prototype._isFinal=function(){return(4194304&this._bitField)>0},C.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},C.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},C.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},C.prototype._setAsyncGuaranteed=function(){h.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},C.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==u)return void 0===e&&this._isBound()?this._boundValue():e},C.prototype._promiseAt=function(t){return this[4*t-4+2]},C.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},C.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},C.prototype._boundValue=function(){},C.prototype._migrateCallback0=function(t){t._bitField;var e=t._fulfillmentHandler0,n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=u),this._addCallbacks(e,n,r,i,null)},C.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),a=t._receiverAt(e);void 0===a&&(a=u),this._addCallbacks(n,r,i,a,null)},C.prototype._addCallbacks=function(t,e,n,r,i){var a=this._length();if(a>=65531&&(a=0,this._setLength(0)),0===a)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:l.domainBind(i,e));else{var o=4*a-4;this[o+2]=n,this[o+3]=r,"function"==typeof t&&(this[o+0]=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this[o+1]=null===i?e:l.domainBind(i,e))}return this._setLength(a+1),a},C.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},C.prototype._resolveCallback=function(t,e){if(0==(117506048&this._bitField)){if(t===this)return this._rejectCallback(r(),!1);var n=y(t,this);if(!(n instanceof C))return this._fulfill(t);e&&this._propagateFrom(n,2);var i=n._target();if(i!==this){var a=i._bitField;if(0==(50397184&a)){var o=this._length();o>0&&i._migrateCallback0(this);for(var s=1;s>>16)){if(t===this){var n=r();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!=(134217728&e)?this._settlePromises():h.settlePromises(this),this._dereferenceTrace())}},C.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(this._setRejected(),this._fulfillmentHandler0=t,this._isFinal())return h.fatalError(t,l.isNode);(65535&e)>0?h.settlePromises(this):this._ensurePossibleRejectionHandled()}},C.prototype._fulfillPromises=function(t,e){for(var n=1;n0){if(0!=(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},C.prototype._settledValue=function(){var t=this._bitField;return 0!=(33554432&t)?this._rejectionHandler0:0!=(16777216&t)?this._fulfillmentHandler0:void 0},C.defer=C.pending=function(){return k.deprecated("Promise.defer","new Promise"),{promise:new C(g),resolve:M,reject:I}},l.notEnumerableProp(C,"_makeSelfResolutionError",r),e("./method")(C,g,y,a,k),e("./bind")(C,g,y,k),e("./cancel")(C,w,a,k),e("./direct_resolve")(C),e("./synchronous_inspection")(C),e("./join")(C,w,y,g,h,s),C.Promise=C,C.version="3.5.2",e("./map.js")(C,w,a,y,g,k),e("./call_get.js")(C),e("./using.js")(C,a,y,x,g,k),e("./timers.js")(C,g,k),e("./generators.js")(C,a,g,y,o,k),e("./nodeify.js")(C),e("./promisify.js")(C,g),e("./props.js")(C,w,y,a),e("./race.js")(C,g,y,a),e("./reduce.js")(C,w,a,y,g,k),e("./settle.js")(C,w,k),e("./some.js")(C,w,a),e("./filter.js")(C,g),e("./each.js")(C,g),e("./any.js")(C),l.toFastProperties(C),l.toFastProperties(C.prototype),R({a:1}),R({b:2}),R({c:3}),R(1),R(function(){}),R(void 0),R(!1),R(new C(g)),k.setBounds(f.firstLineError,l.lastLineError),C}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a){var o=t("./util");o.isArray;function s(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return o.inherits(s,a),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function t(n,a){var s=r(this._values,this._promise);if(s instanceof e){var u=(s=s._target())._bitField;if(this._values=s,0==(50397184&u))return this._promise._setAsyncGuaranteed(),s._then(t,this._reject,void 0,this,a);if(0==(33554432&u))return 0!=(16777216&u)?this._reject(s._reason()):this._cancel();s=s._value()}if(null!==(s=o.asArray(s)))0!==s.length?this._iterate(s):-5===a?this._resolveEmptyArray():this._resolve(function(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}(a));else{var l=i("expecting an array or an iterable object but got "+o.classString(s)).reason();this._promise._rejectCallback(l,!1)}},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,a=!1,o=null,s=0;s=this._length&&(this._resolve(this._values),!0)},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n=this._length){var n;if(this._isMap)n=function(t){for(var e=new a,n=t.length/2|0,r=0;r>1},e.prototype.props=function(){return f(this)},e.props=function(t){return f(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t){this._capacity=t,this._length=0,this._front=0}r.prototype._willBeOverCapacity=function(t){return this._capacity=this._length&&(this._resolve(this._values),!0)},a.prototype._promiseFulfilled=function(t,e){var n=new i;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},a.prototype._promiseRejected=function(t,e){var n=new i;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new a(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=t("./errors").RangeError,o=t("./errors").AggregateError,s=i.isArray,u={};function l(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function c(t,e){if((0|e)!==e||e<0)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new l(t),i=n.promise();return n.setHowMany(e),n.init(),i}i.inherits(l,n),l.prototype._init=function(){if(this._initialized)if(0!==this._howMany){this._init$(void 0,-5);var t=s(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}else this._resolve([])},l.prototype.init=function(){this._initialized=!0,this._init()},l.prototype.setUnwrap=function(){this._unwrap=!0},l.prototype.howMany=function(){return this._howMany},l.prototype.setHowMany=function(t){this._howMany=t},l.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0)},l.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},l.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(u),this._checkOutcome())},l.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new o,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},l.prototype._fulfilled=function(){return this._totalResolved},l.prototype._rejected=function(){return this._values.length-this.length()},l.prototype._addRejected=function(t){this._values.push(t)},l.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},l.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},l.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},l.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return c(t,e)},e.prototype.some=function(t){return c(this,t)},e._SomePromiseArray=l}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!=(33554432&this._bitField)},a=e.prototype.isRejected=function(){return 0!=(16777216&this._bitField)},o=e.prototype.isPending=function(){return 0==(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!=(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!=(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536==(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!=(8454144&this._target()._bitField)},t.prototype.isPending=function(){return o.call(this._target())},t.prototype.isRejected=function(){return a.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){var r=t("./util"),i=r.errorObj,a=r.isObject;var o={}.hasOwnProperty;return function(t,s){if(a(t)){if(t instanceof e)return t;var u=function(t){try{return function(t){return t.then}(t)}catch(t){return i.e=t,i}}(t);if(u===i){s&&s._pushContext();var l=e.reject(u.e);return s&&s._popContext(),l}if("function"==typeof u)return function(t){try{return o.call(t,"_promise0")}catch(t){return!1}}(t)?(l=new e(n),t._then(l._fulfill,l._reject,void 0,l,null),l):function(t,a,o){var s=new e(n),u=s;o&&o._pushContext(),s._captureStackTrace(),o&&o._popContext();var l=!0,c=r.tryCatch(a).call(t,function(t){s&&(s._resolveCallback(t),s=null)},function(t){s&&(s._rejectCallback(t,l,!0),s=null)});return l=!1,s&&c===i&&(s._rejectCallback(c.e,!0,!0),s=null),u}(t,u,s)}return t}}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=e.TimeoutError;function o(t){this.handle=t}o.prototype._resultCancelled=function(){clearTimeout(this.handle)};var s=function(t){return u(+this).thenReturn(t)},u=e.delay=function(t,i){var a,u;return void 0!==i?(a=e.resolve(i)._then(s,null,null,t,void 0),r.cancellation()&&i instanceof e&&a._setOnCancel(i)):(a=new e(n),u=setTimeout(function(){a._fulfill()},+t),r.cancellation()&&a._setOnCancel(new o(u)),a._captureStackTrace()),a._setAsyncGuaranteed(),a};e.prototype.delay=function(t){return u(t,this)};function l(t){return clearTimeout(this.handle),t}function c(t){throw clearTimeout(this.handle),t}e.prototype.timeout=function(t,e){var n,s;t=+t;var u=new o(setTimeout(function(){n.isPending()&&function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new a("operation timed out"):new a(e),i.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()}(n,e,s)},t));return r.cancellation()?(s=this.then(),(n=s._then(l,c,void 0,u,void 0))._setOnCancel(u)):n=this._then(l,c,void 0,u,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=t("./util"),u=t("./errors").TypeError,l=t("./util").inherits,c=s.errorObj,f=s.tryCatch,h={};function p(t){setTimeout(function(){throw t},0)}function d(t,n){var i=0,o=t.length,s=new e(a);return function a(){if(i>=o)return s._fulfill();var u=function(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}(t[i++]);if(u instanceof e&&u._isDisposable()){try{u=r(u._getDisposer().tryDispose(n),t.promise)}catch(t){return p(t)}if(u instanceof e)return u._then(a,p,null,null,null)}a()}(),s}function v(t,e,n){this._data=t,this._promise=e,this._context=n}function g(t,e,n){this.constructor$(t,e,n)}function m(t){return v.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function _(t){this.length=t,this.promise=null,this[t-1]=null}v.prototype.data=function(){return this._data},v.prototype.promise=function(){return this._promise},v.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():h},v.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==h?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},v.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},l(g,v),g.prototype.doDispose=function(t,e){return this.data().call(t,t,e)},_.prototype._resultCancelled=function(){for(var t=this.length,n=0;n0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new g(t,this,i());throw new u}}},{"./errors":12,"./util":36}],36:[function(e,n,i){"use strict";var a=e("./es5"),o="undefined"==typeof navigator,s={e:{}},u,l="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r?r:void 0!==this?this:null;function c(){try{var t=u;return u=null,t.apply(this,arguments)}catch(t){return s.e=t,s}}function f(t){return u=t,c}var h=function(t,e){var n={}.hasOwnProperty;function r(){for(var r in this.constructor=t,this.constructor$=e,e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}return r.prototype=e.prototype,t.prototype=new r,t.prototype};function p(t){return null==t||!0===t||!1===t||"string"==typeof t||"number"==typeof t}function d(t){return"function"==typeof t||"object"==typeof t&&null!==t}function v(t){return p(t)?new Error(T(t)):t}function g(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;n1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=b.test(t+"")&&a.names(t).length>0;if(n||r||i)return!0}return!1}catch(t){return!1}}function k(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.foo}return r(),r(),t}var E=/^[a-z$_][a-z$_0-9]*$/i;function S(t){return E.test(t)}function j(t,e,n){for(var r=new Array(t),i=0;i10||V[0]>0),q.isNode&&q.toFastProperties(t);try{throw new Error}catch(t){q.lastLineError=t}n.exports=q},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{_process:117,timers:142}],4:[function(t,e,n){},{}],5:[function(t,e,n){"use strict";var r=t("base64-js"),i=t("ieee754");n.Buffer=s,n.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},n.INSPECT_MAX_BYTES=50;var a=2147483647;function o(t){if(t>a)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=s.prototype,e}function s(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(t)}return u(t,e,n)}function u(t,e,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return U(t)?function(t,e,n){if(e<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function p(t,e){if(s.isBuffer(t))return t.length;if(z(t)||U(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return O(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return D(t).length;default:if(r)return O(t).length;e=(""+e).toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function v(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=s.from(e,r)),s.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,i){var a,o=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,s/=2,u/=2,n/=2}function l(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(a=n;as&&(n=s-u),a=n;a>=0;a--){for(var f=!0,h=0;hi&&(r=i):r=i;var a=e.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;o>8,i=n%256,a.push(i),a.push(r);return a}(e,t.length-n),t,n,r)}function k(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function E(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:l>223?3:l>191?2:1;if(i+f<=n)switch(f){case 1:l<128&&(c=l);break;case 2:128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)>127&&(c=u);break;case 3:a=t[i+1],o=t[i+2],128==(192&a)&&128==(192&o)&&(u=(15&l)<<12|(63&a)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:a=t[i+1],o=t[i+2],s=t[i+3],128==(192&a)&&128==(192&o)&&128==(192&s)&&(u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=f}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return A(this,e,n);case"utf8":case"utf-8":return E(this,e,n);case"ascii":return j(this,e,n);case"latin1":case"binary":return T(this,e,n);case"base64":return k(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},s.prototype.compare=function(t,e,n,r,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var a=i-r,o=n-e,u=Math.min(a,o),l=this.slice(r,i),c=t.slice(e,n),f=0;f>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":return y(this,t,e,n);case"latin1":case"binary":return w(this,t,e,n);case"base64":return b(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function j(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",a=e;an)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,n,r,i,a){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,n,r,i,a){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function L(t,e,n,r,a){return e=+e,n>>>=0,a||R(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,a){return e=+e,n>>>=0,a||R(t,0,n,8),i.write(t,e,n,r,52,8),n+8}s.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t],i=1,a=0;++a>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},s.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||M(t,e,this.length);for(var r=this[t],i=1,a=0;++a=(i*=128)&&(r-=Math.pow(2,8*e)),r},s.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||M(t,e,this.length);for(var r=e,i=1,a=this[t+--r];r>0&&(i*=256);)a+=this[t+--r]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*e)),a},s.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e>>>=0,n>>>=0,r)||I(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,a=0;for(this[e]=255&t;++a>>=0,n>>>=0,r)||I(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,a=1;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=t/a&255;return e+n},s.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);I(this,t,e,n,i-1,-i)}var a=0,o=1,s=0;for(this[e]=255&t;++a>0)-s&255;return e+n},s.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var i=Math.pow(2,8*n-1);I(this,t,e,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[e+a]=255&t;--a>=0&&(o*=256);)t<0&&0===s&&0!==this[e+a+1]&&(s=1),this[e+a]=(t/o>>0)-s&255;return e+n},s.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeFloatLE=function(t,e,n){return L(this,t,e,!0,n)},s.prototype.writeFloatBE=function(t,e,n){return L(this,t,e,!1,n)},s.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},s.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},s.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(a<1e3)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(a=e;a55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;a.push(n)}else if(n<2048){if((e-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function D(t){return r.toByteArray(function(t){if((t=t.trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function U(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function z(t){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(t)}function q(t){return t!=t}},{"base64-js":1,ieee754:60}],6:[function(t,e,n){(function(n){var r=t("tty"),i=t("./lib/encode"),a=t("stream").Stream,o=e.exports=function(){var t=null;function e(e){if(t)throw new Error("multiple inputs specified");t=e}var i=null;function a(t){if(i)throw new Error("multiple outputs specified");i=t}for(var o=0;o0&&this.down(e),t>0?this.right(t):t<0&&this.left(-t),this},s.prototype.up=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"A")),this},s.prototype.down=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"B")),this},s.prototype.right=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"C")),this},s.prototype.left=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"D")),this},s.prototype.column=function(t){return this.write(i("["+Math.floor(t)+"G")),this},s.prototype.push=function(t){return this.write(i(t?"7":"[s")),this},s.prototype.pop=function(t){return this.write(i(t?"8":"[u")),this},s.prototype.erase=function(t){return"end"===t||"$"===t?this.write(i("[K")):"start"===t||"^"===t?this.write(i("[1K")):"line"===t?this.write(i("[2K")):"down"===t?this.write(i("[J")):"up"===t?this.write(i("[1J")):"screen"===t?this.write(i("[1J")):this.emit("error",new Error("Unknown erase type: "+t)),this},s.prototype.display=function(t){var e={reset:0,bright:1,dim:2,underscore:4,blink:5,reverse:7,hidden:8}[t];return void 0===e&&this.emit("error",new Error("Unknown attribute: "+t)),this.write(i("["+e+"m")),this},s.prototype.foreground=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[38;5;"+t+"m"));else{var e={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.background=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[48;5;"+t+"m"));else{var e={black:40,red:41,green:42,yellow:43,blue:44,magenta:45,cyan:46,white:47}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.cursor=function(t){return this.write(i(t?"[?25h":"[?25l")),this};var u=o.extractCodes=function(t){for(var e=[],n=-1,r=0;r=0&&e.push(t.slice(n,r)),n=r):n>=0&&r===t.length-1&&e.push(t.slice(n));return e}}).call(this,t("_process"))},{"./lib/encode":7,_process:117,stream:139,tty:143}],7:[function(t,e,n){(function(t){var n=(e.exports=function(e){return new t([27].concat(function t(e){return"string"==typeof e?e.split("").map(n):Array.isArray(e)?e.reduce(function(e,n){return e.concat(t(n))},[]):void 0}(e)))}).ord=function(t){return t.charCodeAt(0)}}).call(this,t("buffer").Buffer)},{buffer:5}],8:[function(t,e,n){(function(n){"use strict";var r=t("readable-stream").Readable,i=t("util");function a(t,e){if(!(this instanceof a))return new a(t,e);r.call(this,e),null!==t&&void 0!==t||(t=String(t)),this._obj=t}e.exports=a,i.inherits(a,r),a.prototype._read=function(t){var e=this._obj;"string"==typeof e?this.push(new n(e)):n.isBuffer(e)?this.push(e):this.push(new n(JSON.stringify(e))),this.push(null)}}).call(this,t("buffer").Buffer)},{buffer:5,"readable-stream":14,util:150}],9:[function(t,e,n){(function(n){e.exports=s;var r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},i=t("core-util-is");i.inherits=t("inherits");var a=t("./_stream_readable"),o=t("./_stream_writable");function s(t){if(!(this instanceof s))return new s(t);a.call(this,t),o.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",u)}function u(){this.allowHalfOpen||this._writableState.ended||n.nextTick(this.end.bind(this))}i.inherits(s,a),function(t,e){for(var n=0,r=t.length;n0?d(t):w(t)}(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!o){var u=new Error("stream.push() after EOF");t.emit("error",u)}else if(e.endEmitted&&o){u=new Error("stream.unshift() after end event");t.emit("error",u)}else!e.decoder||o||a||(r=e.decoder.write(r)),e.length+=e.objectMode?1:r.length,o?e.buffer.unshift(r):(e.reading=!1,e.buffer.push(r)),e.needReadable&&d(t),function(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(function(){!function(t,e){var n=e.length;for(;!e.reading&&!e.flowing&&!e.ended&&e.lengthe.highWaterMark&&(e.highWaterMark=function(t){if(t>=h)t=h;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function d(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,e.sync?n.nextTick(function(){v(t)}):v(t))}function v(t){t.emit("readable")}function g(t){var e,n=t._readableState;function r(t,r,i){!1===t.write(e)&&n.awaitDrain++}for(n.awaitDrain=0;n.pipesCount&&null!==(e=t.read());)if(1===n.pipesCount?r(n.pipes):b(n.pipes,r),t.emit("data",e),n.awaitDrain>0)return;if(0===n.pipesCount)return n.flowing=!1,void(a.listenerCount(t,"data")>0&&_(t));n.ranOut=!0}function m(){this._readableState.ranOut&&(this._readableState.ranOut=!1,g(this))}function _(t,e){if(t._readableState.flowing)throw new Error("Cannot switch to old mode now.");var r=e||!1,i=!1;t.readable=!0,t.pipe=s.prototype.pipe,t.on=t.addListener=s.prototype.on,t.on("readable",function(){var e;for(i=!0;!r&&null!==(e=t.read());)t.emit("data",e);null===e&&(i=!1,t._readableState.needReadable=!0)}),t.pause=function(){r=!0,this.emit("pause")},t.resume=function(){r=!1,i?n.nextTick(function(){t.emit("readable")}):this.read(0),this.emit("resume")},t.emit("readable")}function y(t,e){var n,r=e.buffer,a=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===r.length)return null;if(0===a)n=null;else if(s)n=r.shift();else if(!t||t>=a)n=o?r.join(""):i.concat(r,a),r.length=0;else{if(t0)throw new Error("endReadable called on non-empty stream");!e.endEmitted&&e.calledRead&&(e.ended=!0,n.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function b(t,e){for(var n=0,r=t.length;n0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return d(this),null;if(0===(t=p(t,e))&&e.ended)return n=null,e.length>0&&e.decoder&&(n=y(t,e),e.length-=n.length),0===e.length&&w(this),n;var i=e.needReadable;return e.length-t<=e.highWaterMark&&(i=!0),(e.ended||e.reading)&&(i=!1),i&&(e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),i&&!e.reading&&(t=p(r,e)),null===(n=t>0?y(t,e):null)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),e.ended&&!e.endEmitted&&0===e.length&&w(this),n},c.prototype._read=function(t){this.emit("error",new Error("not implemented"))},c.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1;var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?l:f;function u(t){t===i&&f()}function l(){t.end()}o.endEmitted?n.nextTick(s):i.once("end",s),t.on("unpipe",u);var c=function(t){return function(){var e=t._readableState;e.awaitDrain--,0===e.awaitDrain&&g(t)}}(i);function f(){t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",u),i.removeListener("end",l),i.removeListener("end",f),t._writableState&&!t._writableState.needDrain||c()}function h(e){v(),t.removeListener("error",h),0===a.listenerCount(t,"error")&&t.emit("error",e)}function p(){t.removeListener("finish",d),v()}function d(){t.removeListener("close",p),v()}function v(){i.unpipe(t)}return t.on("drain",c),t._events&&t._events.error?r(t._events.error)?t._events.error.unshift(h):t._events.error=[h,t._events.error]:t.on("error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",i),o.flowing||(this.on("readable",m),o.flowing=!0,n.nextTick(function(){g(i)})),t},c.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===a){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(i),in.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,r(e)}},{"./lib/thunk.js":18}],17:[function(t,e,n){"use strict";var r=t("uniq");function i(t,e,n){var r,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,u=[],l=[],c=0,f=0;for(r=0;r0&&u.push("var "+l.join(",")),r=a-1;r>=0;--r)c=t[r],u.push(["for(i",r,"=0;i",r,"0&&u.push(["index[",f,"]-=s",f].join("")),u.push(["++index[",c,"]"].join(""))),u.push("}")}return u.join("\n")}function a(t,e,n){for(var r=t.body,i=[],a=[],o=0;o0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){var y=new Array(n);for(u=0;u0&&m.push("var "+_.join(",")),u=0;u3&&m.push(a(t.pre,t,s));var k=a(t.body,t,s),E=function(t){for(var e=0,n=t[0].length;e0,l=[],c=0;c0;){"].join("")),l.push(["if(j",c,"<",s,"){"].join("")),l.push(["s",e[c],"=j",c].join("")),l.push(["j",c,"=0"].join("")),l.push(["}else{s",e[c],"=",s].join("")),l.push(["j",c,"-=",s,"}"].join("")),u&&l.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var S=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",E,function(t){for(var e=new Array(t.length),n=!0,r=0;r0&&(n=n&&e[r]===e[r-1])}return n?e[0]:e.join("")}(s)].join("");return new Function(["function ",S,"(",g.join(","),"){",m.join("\n"),"} return ",S].join(""))()}},{uniq:146}],18:[function(t,e,n){"use strict";var r=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],n=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],l=[],c=0;c0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),l.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;c0)return function(t,e){var n,r;for(n=new Array(t),r=0;r 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],25:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat correctionRadius = 0.5;\n\tfloat distance = sqrt(vPosition.x * vPosition.x + vPosition.y * vPosition.y) / correctionRadius;\n\tfloat theta = 1.0;\n\tif(distance != 0.0){\n\t\ttheta = atan(distance);\n\t}\n\tvec2 vMapping = theta * vPosition.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\t\t\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],26:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 uLensS;\nuniform vec2 uLensF;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord * vec2(1.0, -1.0)/ 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat scale = uLensS.z;\n\tvec3 vPos = vPosition;\n\tfloat Fx = uLensF.x;\n\tfloat Fy = uLensF.y;\n\tvec2 vMapping = vPos.xy;\n\tvMapping.x = vMapping.x + ((pow(vPos.y, 2.0)/scale)*vPos.x/scale)*-Fx;\n\tvMapping.y = vMapping.y + ((pow(vPos.x, 2.0)/scale)*vPos.y/scale)*-Fy;\n\tvMapping = vMapping * uLensS.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping/scale);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t}\n\tgl_FragColor = texture;\n}\n"},{}],27:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TODO insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],28:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TOD insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],29:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvoid main(void){\n\tvPosition = aVertexPosition;\n\tvTextureCoord = aTextureCoord;\n\tgl_Position = vec4(vPosition,1.0);\n}\n"},{}],30:[function(t,e,n){(function(n,r){"use strict";var i=t("path"),a=t("ndarray"),o=t("omggif").GifReader,s=(t("ndarray-pack"),t("through"),t("data-uri-to-buffer"));function u(t,e){var n;try{n=new o(t)}catch(t){return void e(t)}if(n.numFrames()>0){var r=[n.numFrames(),n.height,n.width,4],i=new Uint8Array(r[0]*r[1]*r[2]*r[3]),s=a(i,r);try{for(var u=0;u=0&&(this.dispose=t)},u.prototype.setRepeat=function(t){this.repeat=t},u.prototype.setTransparent=function(t){this.transparent=t},u.prototype.analyzeImage=function(t){this.setImagePixels(this.removeAlphaChannel(t)),this.analyzePixels()},u.prototype.writeImageInfo=function(){this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.firstFrame=!1},u.prototype.outputImage=function(){this.writePixels()},u.prototype.addFrame=function(t){this.emit("frame#start"),this.analyzeImage(t),this.writeImageInfo(),this.outputImage(),this.emit("frame#stop")},u.prototype.finish=function(){this.emit("finish#start"),this.writeByte(59),this.emit("finish#stop")},u.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},u.prototype.writeHeader=function(){this.emit("writeHeader#start"),this.writeUTFBytes("GIF89a"),this.emit("writeHeader#stop")},u.prototype.analyzePixels=function(){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);var e=new a(this.pixels,this.sample);e.buildColormap(),this.colorTab=e.getColormap();for(var n=0,r=0;r>16,n=(65280&t)>>8,r=255&t,i=0,a=16777216,o=this.colorTab.length,s=0;s=0&&(e=7&dispose),e<<=2,this.writeByte(0|e|t),this.writeShort(this.delay),this.writeByte(this.transIndex),this.writeByte(0)},u.prototype.writeImageDesc=function(){this.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.writeByte(0):this.writeByte(128|this.palSize)},u.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.writeByte(240|this.palSize),this.writeByte(0),this.writeByte(0)},u.prototype.writeNetscapeExt=function(){this.writeByte(33),this.writeByte(255),this.writeByte(11),this.writeUTFBytes("NETSCAPE2.0"),this.writeByte(3),this.writeByte(1),this.writeShort(this.repeat),this.writeByte(0)},u.prototype.writePalette=function(){this.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},u.prototype.writePixels=function(){new o(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this)},u.prototype.stream=function(){return this},u.ByteCapacitor=s,e.exports=u}).call(this,t("buffer").Buffer)},{"./LZWEncoder.js":33,"./TypedNeuQuant.js":34,assert:41,buffer:5,events:48,"readable-stream":40,util:150}],33:[function(t,e,n){var r=-1,i=12,a=5003,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,n,s){var u,l,c,f,h,p,d,v,g,m=Math.max(2,s),_=new Uint8Array(256),y=new Int32Array(a),w=new Int32Array(a),b=0,x=0,k=!1;function E(t,e){_[l++]=t,l>=254&&T(e)}function S(t){j(a),x=v+2,k=!0,M(v,t)}function j(t){for(var e=0;e0&&(t.writeByte(l),t.writeBytes(_,0,l),l=0)}function A(t){return(1<0?u|=t<=8;)E(255&u,e),u>>=8,b-=8;if((x>c||k)&&(k?(c=A(p=d),k=!1):c=++p==i?1<0;)E(255&u,e),u>>=8,b-=8;T(e)}}this.encode=function(n){n.writeByte(m),f=t*e,h=0,function(t,e){var n,o,s,u,f,h,m;for(k=!1,c=A(p=d=t),g=1+(v=1<=0){f=h-s,0===s&&(f=1);do{if((s-=f)<0&&(s+=h),y[s]===n){u=w[s];continue t}}while(y[s]>=0)}M(u,e),u=o,x<1<>c,h=u<>3)*(1<l;)u=T[p++],fl&&((s=n[h--])[0]-=u*(s[0]-r)/_,s[1]-=u*(s[1]-a)/_,s[2]-=u*(s[2]-o)/_)}function M(t,e,r){var a,u,p,d,v,g=~(1<<31),m=g,_=-1,y=_;for(a=0;a>s-o))>c,j[a]-=v,S[a]+=v<>3),t=0;t>p;for(j<=1&&(j=0),n=0;n=c&&(I-=c),n++,0===_&&(_=1),n%_==0)for(E-=E/f,(j=(S-=S/v)>>p)<=1&&(j=0),l=0;l>=o,n[t][1]>>=o,n[t][2]>>=o,n[t][3]=t}(),function(){var t,e,r,o,s,u,l=0,c=0;for(t=0;t>1,e=l+1;e>1,e=l+1;e<256;e++)E[e]=a}()},this.getColormap=function(){for(var t=[],e=[],r=0;r=0;)c=u?c=i:(c++,s<0&&(s=-s),(a=o[0]-t)<0&&(a=-a),(s+=a)=0&&((s=e-(o=n[f])[1])>=u?f=-1:(f--,s<0&&(s=-s),(a=o[0]-t)<0&&(a=-a),(s+=a)0)if(e.ended&&!a){var s=new Error("stream.push() after EOF");t.emit("error",s)}else if(e.endEmitted&&a){s=new Error("stream.unshift() after end event");t.emit("error",s)}else!e.decoder||a||i||(r=e.decoder.write(r)),a||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,a?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&v(t)),function(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(function(){!function(t,e){var n=e.length;for(;!e.reading&&!e.flowing&&!e.ended&&e.lengthe.highWaterMark&&(e.highWaterMark=function(t){if(t>=p)t=p;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function v(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(function(){g(t)}):g(t))}function g(t){l("emit readable"),t.emit("readable"),m(t)}function m(t){var e=t._readableState;if(l("flow",e.flowing),e.flowing)do{var n=t.read()}while(null!==n&&e.flowing)}function _(t,e){var n,r=e.buffer,a=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===r.length)return null;if(0===a)n=null;else if(s)n=r.shift();else if(!t||t>=a)n=o?r.join(""):i.concat(r,a),r.length=0;else{if(t0)throw new Error("endReadable called on non-empty stream");e.endEmitted||(e.ended=!0,n.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}f.prototype.read=function(t){l("read",t);var e=this._readableState,n=t;if((!u.isNumber(t)||t>0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?y(this):v(this),null;if(0===(t=d(t,e))&&e.ended)return 0===e.length&&y(this),null;var r,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?_(t,e):null,u.isNull(r)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),n!==t&&e.ended&&0===e.length&&y(this),u.isNull(r)||this.emit("data",r),r},f.prototype._read=function(t){this.emit("error",new Error("not implemented"))},f.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?c:h;function u(t){l("onunpipe"),t===i&&h()}function c(){l("onend"),t.end()}o.endEmitted?n.nextTick(s):i.once("end",s),t.on("unpipe",u);var f=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a.listenerCount(t,"data")&&(e.flowing=!0,m(t))}}(i);function h(){l("cleanup"),t.removeListener("close",v),t.removeListener("finish",g),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",u),i.removeListener("end",c),i.removeListener("end",h),i.removeListener("data",p),!o.awaitDrain||t._writableState&&!t._writableState.needDrain||f()}function p(e){l("ondata"),!1===t.write(e)&&(l("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,i.pause())}function d(e){l("onerror",e),_(),t.removeListener("error",d),0===a.listenerCount(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",g),_()}function g(){l("onfinish"),t.removeListener("close",v),_()}function _(){l("unpipe"),i.unpipe(t)}return t.on("drain",f),i.on("data",p),t._events&&t._events.error?r(t._events.error)?t._events.error.unshift(d):t._events.error=[d,t._events.error]:t.on("error",d),t.once("close",v),t.once("finish",g),t.emit("pipe",i),o.flowing||(l("pipe resume"),i.resume()),t},f.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i1){for(var n=[],r=0;r=0;l--)if(c[l]!==f[l])return!1;for(l=c.length-1;l>=0;l--)if(u=c[l],!_(t[u],e[u],n,r))return!1;return!0}(t,e,n,o))}return n?t===e:t==e}function y(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function w(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function b(t,e,n,r){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof n&&(r=n,n=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),t&&!i&&g(i,n,"Missing expected exception"+r);var o="string"==typeof r,s=!t&&a.isError(i),u=!t&&i&&!n;if((s&&o&&w(i,n)||u)&&g(i,n,"Got unwanted exception"+r),t&&i&&n&&!w(i,n)||!t&&i)throw i}f.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=d(v((e=this).actual),128)+" "+e.operator+" "+d(v(e.expected),128),this.generatedMessage=!0);var n=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var r=new Error;if(r.stack){var i=r.stack,a=p(n),o=i.indexOf("\n"+a);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},a.inherits(f.AssertionError,Error),f.fail=g,f.ok=m,f.equal=function(t,e,n){t!=e&&g(t,e,n,"==",f.equal)},f.notEqual=function(t,e,n){t==e&&g(t,e,n,"!=",f.notEqual)},f.deepEqual=function(t,e,n){_(t,e,!1)||g(t,e,n,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(t,e,n){_(t,e,!0)||g(t,e,n,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(t,e,n){_(t,e,!1)&&g(t,e,n,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function t(e,n,r){_(e,n,!0)&&g(e,n,r,"notDeepStrictEqual",t)},f.strictEqual=function(t,e,n){t!==e&&g(t,e,n,"===",f.strictEqual)},f.notStrictEqual=function(t,e,n){t===e&&g(t,e,n,"!==",f.notStrictEqual)},f.throws=function(t,e,n){b(!0,t,e,n)},f.doesNotThrow=function(t,e,n){b(!1,t,e,n)},f.ifError=function(t){if(t)throw t};var x=Object.keys||function(t){var e=[];for(var n in t)o.call(t,n)&&e.push(n);return e}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":44}],42:[function(t,e,n){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},{}],43:[function(t,e,n){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],44:[function(t,e,n){(function(e,r){var i=/%[sdj%]/g;n.format=function(t){if(!m(t)){for(var e=[],n=0;n=a)return t;switch(t){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return t}}),u=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),d(e)?r.showHidden=e:e&&n._extend(r,e),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=u),c(r,t,r.depth)}function u(t,e){var n=s.styles[e];return n?"["+s.colors[n][0]+"m"+t+"["+s.colors[n][1]+"m":t}function l(t,e){return t}function c(t,e,r){if(t.customInspect&&e&&k(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(r,t);return m(i)||(i=c(t,i,r)),i}var a=function(t,e){if(_(e))return t.stylize("undefined","undefined");if(m(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}if(g(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(v(e))return t.stylize("null","null")}(t,e);if(a)return a;var o=Object.keys(e),s=function(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),x(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(e);if(0===o.length){if(k(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(y(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(b(e))return t.stylize(Date.prototype.toString.call(e),"date");if(x(e))return f(e)}var l,w="",E=!1,S=["{","}"];(p(e)&&(E=!0,S=["[","]"]),k(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return y(e)&&(w=" "+RegExp.prototype.toString.call(e)),b(e)&&(w=" "+Date.prototype.toUTCString.call(e)),x(e)&&(w=" "+f(e)),0!==o.length||E&&0!=e.length?r<0?y(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),l=E?function(t,e,n,r,i){for(var a=[],o=0,s=e.length;o=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1];return n[0]+e+" "+t.join(", ")+" "+n[1]}(l,w,S)):S[0]+w+S[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,n,r,i,a){var o,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),T(r,i)||(o="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=v(n)?c(t,u.value,null):c(t,u.value,n-1)).indexOf("\n")>-1&&(s=a?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),_(o)){if(a&&i.match(/^\d+$/))return s;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+s}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function v(t){return null===t}function g(t){return"number"==typeof t}function m(t){return"string"==typeof t}function _(t){return void 0===t}function y(t){return w(t)&&"[object RegExp]"===E(t)}function w(t){return"object"==typeof t&&null!==t}function b(t){return w(t)&&"[object Date]"===E(t)}function x(t){return w(t)&&("[object Error]"===E(t)||t instanceof Error)}function k(t){return"function"==typeof t}function E(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}n.debuglog=function(t){if(_(a)&&(a=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!o[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var r=e.pid;o[t]=function(){var e=n.format.apply(n,arguments);console.error("%s %d: %s",t,r,e)}}else o[t]=function(){};return o[t]},n.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=d,n.isNull=v,n.isNullOrUndefined=function(t){return null==t},n.isNumber=g,n.isString=m,n.isSymbol=function(t){return"symbol"==typeof t},n.isUndefined=_,n.isRegExp=y,n.isObject=w,n.isDate=b,n.isError=x,n.isFunction=k,n.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},n.isBuffer=t("./support/isBuffer");var j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(t,e){return Object.prototype.hasOwnProperty.call(t,e)}n.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":"),[t.getDate(),j[t.getMonth()],e].join(" ")),n.format.apply(n,arguments))},n.inherits=t("inherits"),n._extend=function(t,e){if(!e||!w(e))return t;for(var n=Object.keys(e),r=n.length;r--;)t[n[r]]=e[n[r]];return t}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":43,_process:117,inherits:42}],45:[function(t,e,n){(function(e,r){"use strict";var i=t("assert"),a=t("pako/lib/zlib/zstream"),o=t("pako/lib/zlib/deflate.js"),s=t("pako/lib/zlib/inflate.js"),u=t("pako/lib/zlib/constants");for(var l in u)n[l]=u[l];n.NONE=0,n.DEFLATE=1,n.INFLATE=2,n.GZIP=3,n.GUNZIP=4,n.DEFLATERAW=5,n.INFLATERAW=6,n.UNZIP=7;function c(t){if("number"!=typeof t||tn.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}c.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,i(this.init_done,"close before init"),i(this.mode<=n.UNZIP),this.mode===n.DEFLATE||this.mode===n.GZIP||this.mode===n.DEFLATERAW?o.deflateEnd(this.strm):this.mode!==n.INFLATE&&this.mode!==n.GUNZIP&&this.mode!==n.INFLATERAW&&this.mode!==n.UNZIP||s.inflateEnd(this.strm),this.mode=n.NONE,this.dictionary=null)},c.prototype.write=function(t,e,n,r,i,a,o){return this._write(!0,t,e,n,r,i,a,o)},c.prototype.writeSync=function(t,e,n,r,i,a,o){return this._write(!1,t,e,n,r,i,a,o)},c.prototype._write=function(t,a,o,s,u,l,c,f){if(i.equal(arguments.length,8),i(this.init_done,"write before init"),i(this.mode!==n.NONE,"already finalized"),i.equal(!1,this.write_in_progress,"write already in progress"),i.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,i.equal(!1,void 0===a,"must provide flush value"),this.write_in_progress=!0,a!==n.Z_NO_FLUSH&&a!==n.Z_PARTIAL_FLUSH&&a!==n.Z_SYNC_FLUSH&&a!==n.Z_FULL_FLUSH&&a!==n.Z_FINISH&&a!==n.Z_BLOCK)throw new Error("Invalid flush value");if(null==o&&(o=r.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=o,this.strm.next_in=s,this.strm.avail_out=f,this.strm.output=l,this.strm.next_out=c,this.flush=a,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return e.nextTick(function(){h._process(),h._after()}),this},c.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},c.prototype._process=function(){var t=null;switch(this.mode){case n.DEFLATE:case n.GZIP:case n.DEFLATERAW:this.err=o.deflate(this.strm,this.flush);break;case n.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=n.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=n.GUNZIP):this.mode=n.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case n.INFLATE:case n.GUNZIP:case n.INFLATERAW:for(this.err=s.inflate(this.strm,this.flush),this.err===n.Z_NEED_DICT&&this.dictionary&&(this.err=s.inflateSetDictionary(this.strm,this.dictionary),this.err===n.Z_OK?this.err=s.inflate(this.strm,this.flush):this.err===n.Z_DATA_ERROR&&(this.err=n.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===n.GUNZIP&&this.err===n.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=s.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},c.prototype._checkError=function(){switch(this.err){case n.Z_OK:case n.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===n.Z_FINISH)return this._error("unexpected end of file"),!1;break;case n.Z_STREAM_END:break;case n.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},c.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},c.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},c.prototype.init=function(t,e,r,a,o){i(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),i(t>=8&&t<=15,"invalid windowBits"),i(e>=-1&&e<=9,"invalid compression level"),i(r>=1&&r<=9,"invalid memlevel"),i(a===n.Z_FILTERED||a===n.Z_HUFFMAN_ONLY||a===n.Z_RLE||a===n.Z_FIXED||a===n.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(e,t,r,a,o),this._setDictionary()},c.prototype.params=function(){throw new Error("deflateParams Not supported")},c.prototype.reset=function(){this._reset(),this._setDictionary()},c.prototype._init=function(t,e,r,i,u){switch(this.level=t,this.windowBits=e,this.memLevel=r,this.strategy=i,this.flush=n.Z_NO_FLUSH,this.err=n.Z_OK,this.mode!==n.GZIP&&this.mode!==n.GUNZIP||(this.windowBits+=16),this.mode===n.UNZIP&&(this.windowBits+=32),this.mode!==n.DEFLATERAW&&this.mode!==n.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case n.DEFLATE:case n.GZIP:case n.DEFLATERAW:this.err=o.deflateInit2(this.strm,this.level,n.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case n.INFLATE:case n.GUNZIP:case n.INFLATERAW:case n.UNZIP:this.err=s.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==n.Z_OK&&this._error("Init error"),this.dictionary=u,this.write_in_progress=!1,this.init_done=!0},c.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=n.Z_OK,this.mode){case n.DEFLATE:case n.DEFLATERAW:this.err=o.deflateSetDictionary(this.strm,this.dictionary)}this.err!==n.Z_OK&&this._error("Failed to set dictionary")}},c.prototype._reset=function(){switch(this.err=n.Z_OK,this.mode){case n.DEFLATE:case n.DEFLATERAW:case n.GZIP:this.err=o.deflateReset(this.strm);break;case n.INFLATE:case n.INFLATERAW:case n.GUNZIP:this.err=s.inflateReset(this.strm)}this.err!==n.Z_OK&&this._error("Failed to reset stream")},n.Zlib=c}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,assert:41,buffer:5,"pako/lib/zlib/constants":51,"pako/lib/zlib/deflate.js":53,"pako/lib/zlib/inflate.js":55,"pako/lib/zlib/zstream":59}],46:[function(t,e,n){(function(e){"use strict";var r=t("buffer").Buffer,i=t("stream").Transform,a=t("./binding"),o=t("util"),s=t("assert").ok,u=t("buffer").kMaxLength,l="Cannot create final Buffer. It would be larger than 0x"+u.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var c=Object.keys(a),f=0;f=u?o=new RangeError(l):e=r.concat(i,a),i=[],t.close(),n(o,e)}t.on("error",function(e){t.removeListener("end",s),t.removeListener("readable",o),n(e)}),t.on("end",s),t.end(e),o()}function _(t,e){if("string"==typeof e&&(e=r.from(e)),!r.isBuffer(e))throw new TypeError("Not a string or buffer");var n=t._finishFlushFlag;return t._processChunk(e,n)}function y(t){if(!(this instanceof y))return new y(t);T.call(this,t,a.DEFLATE)}function w(t){if(!(this instanceof w))return new w(t);T.call(this,t,a.INFLATE)}function b(t){if(!(this instanceof b))return new b(t);T.call(this,t,a.GZIP)}function x(t){if(!(this instanceof x))return new x(t);T.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);T.call(this,t,a.DEFLATERAW)}function E(t){if(!(this instanceof E))return new E(t);T.call(this,t,a.INFLATERAW)}function S(t){if(!(this instanceof S))return new S(t);T.call(this,t,a.UNZIP)}function j(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function T(t,e){var o=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||n.Z_DEFAULT_CHUNK,i.call(this,t),t.flush&&!j(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!j(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSizen.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBitsn.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.leveln.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLeveln.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=n.Z_FILTERED&&t.strategy!=n.Z_HUFFMAN_ONLY&&t.strategy!=n.Z_RLE&&t.strategy!=n.Z_FIXED&&t.strategy!=n.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!r.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(e);var s=this;this._hadError=!1,this._handle.onerror=function(t,e){A(s),s._hadError=!0;var r=new Error(t);r.errno=e,r.code=n.codes[e],s.emit("error",r)};var u=n.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var l=n.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(l=t.strategy),this._handle.init(t.windowBits||n.Z_DEFAULT_WINDOWBITS,u,t.memLevel||n.Z_DEFAULT_MEMLEVEL,l,t.dictionary),this._buffer=r.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=l,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!o._handle},configurable:!0,enumerable:!0})}function A(t,n){n&&e.nextTick(n),t._handle&&(t._handle.close(),t._handle=null)}function C(t){t.emit("close")}Object.defineProperty(n,"codes",{enumerable:!0,value:Object.freeze(p),writable:!1}),n.Deflate=y,n.Inflate=w,n.Gzip=b,n.Gunzip=x,n.DeflateRaw=k,n.InflateRaw=E,n.Unzip=S,n.createDeflate=function(t){return new y(t)},n.createInflate=function(t){return new w(t)},n.createDeflateRaw=function(t){return new k(t)},n.createInflateRaw=function(t){return new E(t)},n.createGzip=function(t){return new b(t)},n.createGunzip=function(t){return new x(t)},n.createUnzip=function(t){return new S(t)},n.deflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new y(e),t,n)},n.deflateSync=function(t,e){return _(new y(e),t)},n.gzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new b(e),t,n)},n.gzipSync=function(t,e){return _(new b(e),t)},n.deflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new k(e),t,n)},n.deflateRawSync=function(t,e){return _(new k(e),t)},n.unzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new S(e),t,n)},n.unzipSync=function(t,e){return _(new S(e),t)},n.inflate=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new w(e),t,n)},n.inflateSync=function(t,e){return _(new w(e),t)},n.gunzip=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new x(e),t,n)},n.gunzipSync=function(t,e){return _(new x(e),t)},n.inflateRaw=function(t,e,n){return"function"==typeof e&&(n=e,e={}),m(new E(e),t,n)},n.inflateRawSync=function(t,e){return _(new E(e),t)},o.inherits(T,i),T.prototype.params=function(t,r,i){if(tn.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=n.Z_FILTERED&&r!=n.Z_HUFFMAN_ONLY&&r!=n.Z_RLE&&r!=n.Z_FIXED&&r!=n.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,function(){s(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())})}else e.nextTick(i)},T.prototype.reset=function(){return s(this._handle,"zlib binding closed"),this._handle.reset()},T.prototype._flush=function(t){this._transform(r.alloc(0),"",t)},T.prototype.flush=function(t,n){var i=this,o=this._writableState;("function"==typeof t||void 0===t&&!n)&&(n=t,t=a.Z_FULL_FLUSH),o.ended?n&&e.nextTick(n):o.ending?n&&this.once("end",n):o.needDrain?n&&this.once("drain",function(){return i.flush(t,n)}):(this._flushFlag=t,this.write(r.alloc(0),"",n))},T.prototype.close=function(t){A(this,t),e.nextTick(C,this)},T.prototype._transform=function(t,e,n){var i,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||r.isBuffer(t)?this._handle?(s?i=this._finishFlushFlag:(i=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,i,n)):n(new Error("zlib binding closed")):n(new Error("invalid input"))},T.prototype._processChunk=function(t,e,n){var i=t&&t.length,a=this._chunkSize-this._offset,o=0,c=this,f="function"==typeof n;if(!f){var h,p=[],d=0;this.on("error",function(t){h=t}),s(this._handle,"zlib binding closed");do{var v=this._handle.writeSync(e,t,o,i,this._buffer,this._offset,a)}while(!this._hadError&&_(v[0],v[1]));if(this._hadError)throw h;if(d>=u)throw A(this),new RangeError(l);var g=r.concat(p,d);return A(this),g}s(this._handle,"zlib binding closed");var m=this._handle.write(e,t,o,i,this._buffer,this._offset,a);function _(u,l){if(this&&(this.buffer=null,this.callback=null),!c._hadError){var h=a-l;if(s(h>=0,"have should not go down"),h>0){var v=c._buffer.slice(c._offset,c._offset+h);c._offset+=h,f?c.push(v):(p.push(v),d+=v.length)}if((0===l||c._offset>=c._chunkSize)&&(a=c._chunkSize,c._offset=0,c._buffer=r.allocUnsafe(c._chunkSize)),0===l){if(o+=i-u,i=u,!f)return!0;var g=c._handle.write(e,t,o,i,c._buffer,c._offset,c._chunkSize);return g.callback=_,void(g.buffer=t)}if(!f)return!1;n()}}m.buffer=t,m.callback=_},o.inherits(y,T),o.inherits(w,T),o.inherits(b,T),o.inherits(x,T),o.inherits(k,T),o.inherits(E,T),o.inherits(S,T)}).call(this,t("_process"))},{"./binding":45,_process:117,assert:41,buffer:5,stream:139,util:150}],47:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],48:[function(t,e,n){var r=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return n},a=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var s,u=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),s=0===l.x}catch(t){s=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,n,i){var a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]):(o=t._events=r(null),t._eventsCount=0),s){if("function"==typeof s?s=o[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),!s.warned&&(a=c(t))&&a>0&&s.length>a){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else s=o[e]=n,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(n=o[t]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:!function(t,e,n){if(e)t.call(n);else for(var r=t.length,i=g(t,r),a=0;a=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,a=o;break}if(a<0)return this;0===a?n.shift():function(t,e){for(var n=e,r=n+1,i=t.length;r=0;a--)this.removeListener(t,e[a]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):v.call(t,e)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],49:[function(t,e,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}n.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(t[r]=n[r])}}return t},n.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var a={arraySet:function(t,e,n,r,i){if(e.subarray&&t.subarray)t.set(e.subarray(n,n+r),i);else for(var a=0;a>>16&65535|0,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+e[r++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0}},{}],51:[function(t,e,n){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],52:[function(t,e,n){"use strict";var r=function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}();e.exports=function(t,e,n,i){var a=r,o=i+n;t^=-1;for(var s=i;s>>8^a[255&(t^e[s])];return-1^t}},{}],53:[function(t,e,n){"use strict";var r,i=t("../utils/common"),a=t("./trees"),o=t("./adler32"),s=t("./crc32"),u=t("./messages"),l=0,c=1,f=3,h=4,p=5,d=0,v=1,g=-2,m=-3,_=-5,y=-1,w=1,b=2,x=3,k=4,E=0,S=2,j=8,T=9,A=15,C=8,M=286,I=30,R=19,L=2*M+1,B=15,F=3,P=258,O=P+F+1,D=32,N=42,U=69,z=73,q=91,V=103,G=113,H=666,W=1,Z=2,Y=3,X=4,$=3;function J(t,e){return t.msg=u[e],e}function Q(t){return(t<<1)-(t>4?9:0)}function K(t){for(var e=t.length;--e>=0;)t[e]=0}function tt(t){var e=t.state,n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(i.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))}function et(t,e){a._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,tt(t.strm)}function nt(t,e){t.pending_buf[t.pending++]=e}function rt(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function it(t,e){var n,r,i=t.max_chain_length,a=t.strstart,o=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-O?t.strstart-(t.w_size-O):0,l=t.window,c=t.w_mask,f=t.prev,h=t.strstart+P,p=l[a+o-1],d=l[a+o];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(l[(n=e)+o]===d&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do{}while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ao){if(t.match_start=e,o=r,r>=s)break;p=l[a+o-1],d=l[a+o]}}}while((e=f[e&c])>u&&0!=--i);return o<=t.lookahead?o:t.lookahead}function at(t){var e,n,r,a,u,l,c,f,h,p,d=t.w_size;do{if(a=t.window_size-t.lookahead-t.strstart,t.strstart>=d+(d-O)){i.arraySet(t.window,t.window,d,d,0),t.match_start-=d,t.strstart-=d,t.block_start-=d,e=n=t.hash_size;do{r=t.head[--e],t.head[e]=r>=d?r-d:0}while(--n);e=n=d;do{r=t.prev[--e],t.prev[e]=r>=d?r-d:0}while(--n);a+=d}if(0===t.strm.avail_in)break;if(l=t.strm,c=t.window,f=t.strstart+t.lookahead,h=a,p=void 0,(p=l.avail_in)>h&&(p=h),n=0===p?0:(l.avail_in-=p,i.arraySet(c,l.input,l.next_in,p,f),1===l.state.wrap?l.adler=o(l.adler,c,p,f):2===l.state.wrap&&(l.adler=s(l.adler,c,p,f)),l.next_in+=p,l.total_in+=p,p),t.lookahead+=n,t.lookahead+t.insert>=F)for(u=t.strstart-t.insert,t.ins_h=t.window[u],t.ins_h=(t.ins_h<=F&&(t.ins_h=(t.ins_h<=F)if(r=a._tr_tally(t,t.strstart-t.match_start,t.match_length-F),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=F){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=F&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=F-1)),t.prev_length>=F&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-F,r=a._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-F),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<15&&(s=2,r-=16),a<1||a>T||n!==j||r<8||r>15||e<0||e>9||o<0||o>k)return J(t,g);8===r&&(r=9);var u=new function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=j,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*L),this.dyn_dtree=new i.Buf16(2*(2*I+1)),this.bl_tree=new i.Buf16(2*(2*R+1)),K(this.dyn_ltree),K(this.dyn_dtree),K(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(B+1),this.heap=new i.Buf16(2*M+1),K(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*M+1),K(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0};return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=r,u.w_size=1<t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(at(t),0===t.lookahead&&e===l)return W;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,et(t,!1),0===t.strm.avail_out))return W;if(t.strstart-t.block_start>=t.w_size-O&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):(t.strstart>t.block_start&&(et(t,!1),t.strm.avail_out),W)}),new ut(4,4,8,4,ot),new ut(4,5,16,8,ot),new ut(4,6,32,32,ot),new ut(4,4,16,16,st),new ut(8,16,32,32,st),new ut(8,16,128,128,st),new ut(8,32,128,256,st),new ut(32,128,258,1024,st),new ut(32,258,258,4096,st)],n.deflateInit=function(t,e){return ft(t,e,j,A,C,E)},n.deflateInit2=ft,n.deflateReset=ct,n.deflateResetKeep=lt,n.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?g:(t.state.gzhead=e,d):g},n.deflate=function(t,e){var n,i,o,u;if(!t||!t.state||e>p||e<0)return t?J(t,g):g;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===H&&e!==h)return J(t,0===t.avail_out?_:g);if(i.strm=t,n=i.last_flush,i.last_flush=e,i.status===N)if(2===i.wrap)t.adler=0,nt(i,31),nt(i,139),nt(i,8),i.gzhead?(nt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),nt(i,255&i.gzhead.time),nt(i,i.gzhead.time>>8&255),nt(i,i.gzhead.time>>16&255),nt(i,i.gzhead.time>>24&255),nt(i,9===i.level?2:i.strategy>=b||i.level<2?4:0),nt(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(nt(i,255&i.gzhead.extra.length),nt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=U):(nt(i,0),nt(i,0),nt(i,0),nt(i,0),nt(i,0),nt(i,9===i.level?2:i.strategy>=b||i.level<2?4:0),nt(i,$),i.status=G);else{var m=j+(i.w_bits-8<<4)<<8;m|=(i.strategy>=b||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(m|=D),m+=31-m%31,i.status=G,rt(i,m),0!==i.strstart&&(rt(i,t.adler>>>16),rt(i,65535&t.adler)),t.adler=1}if(i.status===U)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending!==i.pending_buf_size));)nt(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=z)}else i.status=z;if(i.status===z)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindexo&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),0===u&&(i.gzindex=0,i.status=q)}else i.status=q;if(i.status===q)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),tt(t),o=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindexo&&(t.adler=s(t.adler,i.pending_buf,i.pending-o,o)),0===u&&(i.status=V)}else i.status=V;if(i.status===V&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&tt(t),i.pending+2<=i.pending_buf_size&&(nt(i,255&t.adler),nt(i,t.adler>>8&255),t.adler=0,i.status=G)):i.status=G),0!==i.pending){if(tt(t),0===t.avail_out)return i.last_flush=-1,d}else if(0===t.avail_in&&Q(e)<=Q(n)&&e!==h)return J(t,_);if(i.status===H&&0!==t.avail_in)return J(t,_);if(0!==t.avail_in||0!==i.lookahead||e!==l&&i.status!==H){var y=i.strategy===b?function(t,e){for(var n;;){if(0===t.lookahead&&(at(t),0===t.lookahead)){if(e===l)return W;break}if(t.match_length=0,n=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):t.last_lit&&(et(t,!1),0===t.strm.avail_out)?W:Z}(i,e):i.strategy===x?function(t,e){for(var n,r,i,o,s=t.window;;){if(t.lookahead<=P){if(at(t),t.lookahead<=P&&e===l)return W;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=F&&t.strstart>0&&(r=s[i=t.strstart-1])===s[++i]&&r===s[++i]&&r===s[++i]){o=t.strstart+P;do{}while(r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&r===s[++i]&&it.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=F?(n=a._tr_tally(t,1,t.match_length-F),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=a._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(et(t,!1),0===t.strm.avail_out))return W}return t.insert=0,e===h?(et(t,!0),0===t.strm.avail_out?Y:X):t.last_lit&&(et(t,!1),0===t.strm.avail_out)?W:Z}(i,e):r[i.level].func(i,e);if(y!==Y&&y!==X||(i.status=H),y===W||y===Y)return 0===t.avail_out&&(i.last_flush=-1),d;if(y===Z&&(e===c?a._tr_align(i):e!==p&&(a._tr_stored_block(i,0,0,!1),e===f&&(K(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),tt(t),0===t.avail_out))return i.last_flush=-1,d}return e!==h?d:i.wrap<=0?v:(2===i.wrap?(nt(i,255&t.adler),nt(i,t.adler>>8&255),nt(i,t.adler>>16&255),nt(i,t.adler>>24&255),nt(i,255&t.total_in),nt(i,t.total_in>>8&255),nt(i,t.total_in>>16&255),nt(i,t.total_in>>24&255)):(rt(i,t.adler>>>16),rt(i,65535&t.adler)),tt(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?d:v)},n.deflateEnd=function(t){var e;return t&&t.state?(e=t.state.status)!==N&&e!==U&&e!==z&&e!==q&&e!==V&&e!==G&&e!==H?J(t,g):(t.state=null,e===G?J(t,m):d):g},n.deflateSetDictionary=function(t,e){var n,r,a,s,u,l,c,f,h=e.length;if(!t||!t.state)return g;if(2===(s=(n=t.state).wrap)||1===s&&n.status!==N||n.lookahead)return g;for(1===s&&(t.adler=o(t.adler,e,h,0)),n.wrap=0,h>=n.w_size&&(0===s&&(K(n.head),n.strstart=0,n.block_start=0,n.insert=0),f=new i.Buf8(n.w_size),i.arraySet(f,e,h-n.w_size,n.w_size,0),e=f,h=n.w_size),u=t.avail_in,l=t.next_in,c=t.input,t.avail_in=h,t.next_in=0,t.input=e,at(n);n.lookahead>=F;){r=n.strstart,a=n.lookahead-(F-1);do{n.ins_h=(n.ins_h<>>=w=y>>>24,d-=w,0===(w=y>>>16&255))j[a++]=65535&y;else{if(!(16&w)){if(0==(64&w)){y=v[(65535&y)+(p&(1<>>=w,d-=w),d<15&&(p+=S[r++]<>>=w=y>>>24,d-=w,!(16&(w=y>>>16&255))){if(0==(64&w)){y=g[(65535&y)+(p&(1<u){t.msg="invalid distance too far back",n.mode=30;break t}if(p>>>=w,d-=w,x>(w=a-o)){if((w=x-w)>c&&n.sane){t.msg="invalid distance too far back",n.mode=30;break t}if(k=0,E=h,0===f){if(k+=l-w,w2;)j[a++]=E[k++],j[a++]=E[k++],j[a++]=E[k++],b-=3;b&&(j[a++]=E[k++],b>1&&(j[a++]=E[k++]))}else{k=a-x;do{j[a++]=j[k++],j[a++]=j[k++],j[a++]=j[k++],b-=3}while(b>2);b&&(j[a++]=j[k++],b>1&&(j[a++]=j[k++]))}break}}break}}while(r>3,p&=(1<<(d-=b<<3))-1,t.next_in=r,t.next_out=a,t.avail_in=r>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function it(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=x,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new r.Buf32(tt),e.distcode=e.distdyn=new r.Buf32(et),e.sane=1,e.back=-1,d):m}function at(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,it(t)):m}function ot(t,e){var n,r;return t&&t.state?(r=t.state,e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?m:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,at(t))):m}function st(t,e){var n,i;return t?(i=new function(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},t.state=i,i.window=null,(n=ot(t,e))!==d&&(t.state=null),n):m}var ut,lt,ct=!0;function ft(t){if(ct){var e;for(ut=new r.Buf32(512),lt=new r.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(l,t.lens,0,288,ut,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(c,t.lens,0,32,lt,0,t.work,{bits:5}),ct=!1}t.lencode=ut,t.lenbits=9,t.distcode=lt,t.distbits=5}function ht(t,e,n,i){var a,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(r.arraySet(o.window,e,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((a=o.wsize-o.wnext)>i&&(a=i),r.arraySet(o.window,e,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,e,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,Tt,2,0),st=0,ut=0,n.mode=k;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&st)<<8)+(st>>8))%31){t.msg="incorrect header check",n.mode=J;break}if((15&st)!==b){t.msg="unknown compression method",n.mode=J;break}if(ut-=4,xt=8+(15&(st>>>=4)),0===n.wbits)n.wbits=xt;else if(xt>n.wbits){t.msg="invalid window size",n.mode=J;break}n.dmax=1<>8&1),512&n.flags&&(Tt[0]=255&st,Tt[1]=st>>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0,n.mode=E;case E:for(;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>8&255,Tt[2]=st>>>16&255,Tt[3]=st>>>24&255,n.check=a(n.check,Tt,4,0)),st=0,ut=0,n.mode=S;case S:for(;ut<16;){if(0===at)break t;at--,st+=tt[nt++]<>8),512&n.flags&&(Tt[0]=255&st,Tt[1]=st>>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0,n.mode=j;case j:if(1024&n.flags){for(;ut<16;){if(0===at)break t;at--,st+=tt[nt++]<>>8&255,n.check=a(n.check,Tt,2,0)),st=0,ut=0}else n.head&&(n.head.extra=null);n.mode=T;case T:if(1024&n.flags&&((pt=n.length)>at&&(pt=at),pt&&(n.head&&(xt=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,tt,nt,pt,xt)),512&n.flags&&(n.check=a(n.check,tt,pt,nt)),at-=pt,nt+=pt,n.length-=pt),n.length))break t;n.length=0,n.mode=A;case A:if(2048&n.flags){if(0===at)break t;pt=0;do{xt=tt[nt+pt++],n.head&&xt&&n.length<65536&&(n.head.name+=String.fromCharCode(xt))}while(xt&&pt>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=L;break;case I:for(;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>=7&ut,ut-=7&ut,n.mode=Y;break}for(;ut<3;){if(0===at)break t;at--,st+=tt[nt++]<>>=1)){case 0:n.mode=F;break;case 1:if(ft(n),n.mode=z,e===p){st>>>=2,ut-=2;break t}break;case 2:n.mode=D;break;case 3:t.msg="invalid block type",n.mode=J}st>>>=2,ut-=2;break;case F:for(st>>>=7&ut,ut-=7&ut;ut<32;){if(0===at)break t;at--,st+=tt[nt++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=J;break}if(n.length=65535&st,st=0,ut=0,n.mode=P,e===p)break t;case P:n.mode=O;case O:if(pt=n.length){if(pt>at&&(pt=at),pt>ot&&(pt=ot),0===pt)break t;r.arraySet(et,tt,nt,pt,it),at-=pt,nt+=pt,ot-=pt,it+=pt,n.length-=pt;break}n.mode=L;break;case D:for(;ut<14;){if(0===at)break t;at--,st+=tt[nt++]<>>=5,ut-=5,n.ndist=1+(31&st),st>>>=5,ut-=5,n.ncode=4+(15&st),st>>>=4,ut-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=J;break}n.have=0,n.mode=N;case N:for(;n.have>>=3,ut-=3}for(;n.have<19;)n.lens[At[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,Et={bits:n.lenbits},kt=s(u,n.lens,0,19,n.lencode,0,n.work,Et),n.lenbits=Et.bits,kt){t.msg="invalid code lengths set",n.mode=J;break}n.have=0,n.mode=U;case U:for(;n.have>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=gt,ut-=gt,n.lens[n.have++]=_t;else{if(16===_t){for(St=gt+2;ut>>=gt,ut-=gt,0===n.have){t.msg="invalid bit length repeat",n.mode=J;break}xt=n.lens[n.have-1],pt=3+(3&st),st>>>=2,ut-=2}else if(17===_t){for(St=gt+3;ut>>=gt)),st>>>=3,ut-=3}else{for(St=gt+7;ut>>=gt)),st>>>=7,ut-=7}if(n.have+pt>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=J;break}for(;pt--;)n.lens[n.have++]=xt}}if(n.mode===J)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=J;break}if(n.lenbits=9,Et={bits:n.lenbits},kt=s(l,n.lens,0,n.nlen,n.lencode,0,n.work,Et),n.lenbits=Et.bits,kt){t.msg="invalid literal/lengths set",n.mode=J;break}if(n.distbits=6,n.distcode=n.distdyn,Et={bits:n.distbits},kt=s(c,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,Et),n.distbits=Et.bits,kt){t.msg="invalid distances set",n.mode=J;break}if(n.mode=z,e===p)break t;case z:n.mode=q;case q:if(at>=6&&ot>=258){t.next_out=it,t.avail_out=ot,t.next_in=nt,t.avail_in=at,n.hold=st,n.bits=ut,o(t,ct),it=t.next_out,et=t.output,ot=t.avail_out,nt=t.next_in,tt=t.input,at=t.avail_in,st=n.hold,ut=n.bits,n.mode===L&&(n.back=-1);break}for(n.back=0;mt=(jt=n.lencode[st&(1<>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>yt)])>>>16&255,_t=65535&jt,!(yt+(gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=yt,ut-=yt,n.back+=yt}if(st>>>=gt,ut-=gt,n.back+=gt,n.length=_t,0===mt){n.mode=Z;break}if(32&mt){n.back=-1,n.mode=L;break}if(64&mt){t.msg="invalid literal/length code",n.mode=J;break}n.extra=15&mt,n.mode=V;case V:if(n.extra){for(St=n.extra;ut>>=n.extra,ut-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=G;case G:for(;mt=(jt=n.distcode[st&(1<>>16&255,_t=65535&jt,!((gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>yt)])>>>16&255,_t=65535&jt,!(yt+(gt=jt>>>24)<=ut);){if(0===at)break t;at--,st+=tt[nt++]<>>=yt,ut-=yt,n.back+=yt}if(st>>>=gt,ut-=gt,n.back+=gt,64&mt){t.msg="invalid distance code",n.mode=J;break}n.offset=_t,n.extra=15&mt,n.mode=H;case H:if(n.extra){for(St=n.extra;ut>>=n.extra,ut-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=J;break}n.mode=W;case W:if(0===ot)break t;if(pt=ct-ot,n.offset>pt){if((pt=n.offset-pt)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=J;break}pt>n.wnext?(pt-=n.wnext,dt=n.wsize-pt):dt=n.wnext-pt,pt>n.length&&(pt=n.length),vt=n.window}else vt=et,dt=it-n.offset,pt=n.length;pt>ot&&(pt=ot),ot-=pt,n.length-=pt;do{et[it++]=vt[dt++]}while(--pt);0===n.length&&(n.mode=q);break;case Z:if(0===ot)break t;et[it++]=n.length,ot--,n.mode=q;break;case Y:if(n.wrap){for(;ut<32;){if(0===at)break t;at--,st|=tt[nt++]<=1&&0===F[j];j--);if(T>j&&(T=j),0===j)return l[c++]=20971520,l[c++]=20971520,h.bits=1,0;for(S=1;S0&&(0===t||1!==j))return-1;for(P[1]=0,k=1;k<15;k++)P[k+1]=P[k]+F[k];for(E=0;E852||2===t&&I>592)return 1;for(;;){y=k-C,f[E]<_?(w=0,b=f[E]):f[E]>_?(w=O[D+f[E]],b=L[B+f[E]]):(w=96,b=0),p=1<>C)+(d-=p)]=y<<24|w<<16|b|0}while(0!==d);for(p=1<>=1;if(0!==p?(R&=p-1,R+=p):R=0,E++,0==--F[k]){if(k===j)break;k=e[n+f[E]]}if(k>T&&(R&g)!==v){for(0===C&&(C=T),m+=S,M=1<<(A=k-C);A+C852||2===t&&I>592)return 1;l[v=R&g]=T<<24|A<<16|m-c|0}}return 0!==R&&(l[m+R]=k-C<<24|64<<16|0),h.bits=T,0}},{"../utils/common":49}],57:[function(t,e,n){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],58:[function(t,e,n){"use strict";var r=t("../utils/common"),i=4,a=0,o=1,s=2;function u(t){for(var e=t.length;--e>=0;)t[e]=0}var l=0,c=1,f=2,h=29,p=256,d=p+1+h,v=30,g=19,m=2*d+1,_=15,y=16,w=7,b=256,x=16,k=17,E=18,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],j=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],T=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],A=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=new Array(2*(d+2));u(C);var M=new Array(2*v);u(M);var I=new Array(512);u(I);var R=new Array(256);u(R);var L=new Array(h);u(L);var B,F,P,O=new Array(v);function D(t,e,n,r,i){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=t&&t.length}function N(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function U(t){return t<256?I[t]:I[256+(t>>>7)]}function z(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function q(t,e,n){t.bi_valid>y-n?(t.bi_buf|=e<>y-t.bi_valid,t.bi_valid+=n-y):(t.bi_buf|=e<>>=1,n<<=1}while(--e>0);return n>>>1}function H(t,e,n){var r,i,a=new Array(_+1),o=0;for(r=1;r<=_;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=G(a[s]++,s))}}function W(t){var e;for(e=0;e8?z(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Y(t,e,n,r){var i=2*e,a=2*n;return t[i]>1;n>=1;n--)X(t,a,n);i=u;do{n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],X(t,a,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,a[2*i]=a[2*n]+a[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,a[2*n+1]=a[2*r+1]=i,t.heap[1]=i++,X(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,r,i,a,o,s,u=e.dyn_tree,l=e.max_code,c=e.stat_desc.static_tree,f=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,v=0;for(a=0;a<=_;a++)t.bl_count[a]=0;for(u[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;nd&&(a=d,v++),u[2*r+1]=a,r>l||(t.bl_count[a]++,o=0,r>=p&&(o=h[r-p]),s=u[2*r],t.opt_len+=s*(a+o),f&&(t.static_len+=s*(c[2*r+1]+o)));if(0!==v){do{for(a=d-1;0===t.bl_count[a];)a--;t.bl_count[a]--,t.bl_count[a+1]+=2,t.bl_count[d]--,v-=2}while(v>0);for(a=d;0!==a;a--)for(r=t.bl_count[a];0!==r;)(i=t.heap[--n])>l||(u[2*i+1]!==a&&(t.opt_len+=(a-u[2*i+1])*u[2*i],u[2*i+1]=a),r--)}}(t,e),H(a,l,t.bl_count)}function Q(t,e,n){var r,i,a=-1,o=e[1],s=0,u=7,l=4;for(0===o&&(u=138,l=3),e[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=e[2*(r+1)+1],++s>=7;r0?(t.strm.data_type===s&&(t.strm.data_type=function(t){var e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return a;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return o;for(e=32;e=3&&0===t.bl_tree[2*A[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),u=t.opt_len+3+7>>>3,(l=t.static_len+3+7>>>3)<=u&&(u=l)):u=l=n+5,n+4<=u&&-1!==e?et(t,e,n,r):t.strategy===i||l===u?(q(t,(c<<1)+(r?1:0),3),$(t,C,M)):(q(t,(f<<1)+(r?1:0),3),function(t,e,n,r){var i;for(q(t,e-257,5),q(t,n-1,5),q(t,r-4,4),i=0;i>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(R[n]+p+1)]++,t.dyn_dtree[2*U(e)]++),t.last_lit===t.lit_bufsize-1},n._tr_align=function(t){q(t,c<<1,3),V(t,b,C),function(t){16===t.bi_valid?(z(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":49}],59:[function(t,e,n){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],60:[function(t,e,n){n.read=function(t,e,n,r,i){var a,o,s=8*i-r-1,u=(1<>1,c=-7,f=n?i-1:0,h=n?-1:1,p=t[e+f];for(f+=h,a=p&(1<<-c)-1,p>>=-c,c+=s;c>0;a=256*a+t[e+f],f+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===a)a=1-l;else{if(a===u)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,r),a-=l}return(p?-1:1)*o*Math.pow(2,a-r)},n.write=function(t,e,n,r,i,a){var o,s,u,l=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:a-1,d=r?1:-1,v=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=c?(s=0,o=c):o+f>=1?(s=(e*u-1)*Math.pow(2,i),o+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[n+p]=255&s,p+=d,s/=256,i-=8);for(o=o<0;t[n+p]=255&o,p+=d,o/=256,l-=8);t[n+p-d]|=128*v}},{}],61:[function(t,e,n){e.exports=[function(t,e){return{options:t,draw:function(e,n,r){r.stop(!0),r.overrideFlag=!0;var i=this;return e.pixelManipulation({output:function(t,e,n){i.output={src:e,format:n}},changePixel:function(t,e,n,r){return[255-t,255-e,255-n,r]},format:e.format,image:t.image,inBrowser:t.inBrowser,callback:n})},output:void 0,UI:e}},{name:"Invert",description:"Inverts the image.",inputs:{}}]},{}],62:[function(t,e,n){"use strict";var r=t("underscore"),i=e.exports={Bitmap:t("./lib/bitmap")};r.extend(i,t("./lib/enums"))},{"./lib/bitmap":63,"./lib/enums":64,underscore:145}],63:[function(t,e,n){(function(n){"use strict";var r=t("fs"),i=(t("underscore"),t("bluebird")),a=t("jpeg-js"),o=t("node-png").PNG,s=t("./enums"),u=t("./utils"),l=t("./resize"),c={r:0,g:0,b:0,a:0},f=e.exports=function(t){t&&(t instanceof f?this._data={data:new n(t.data.data),width:t.width,height:t.height}:t.data?this._data=t:t.width&&t.height&&(this._data={data:new n(4*t.width*t.height),width:t.width,height:t.height},t.color&&this._fill(t.color)))};f.prototype={get width(){return this._data.width},get height(){return this._data.height},attach:function(t){var e=this._data;return this._data=t,e},detach:function(){var t=this._data;return delete this._data,t},_deduceFileType:function(t){if(!t)throw new Error("Can't determine image type");switch(t.substr(-4).toLowerCase()){case".jpg":return s.ImageType.JPG;case".png":return s.ImageType.PNG}if(".jpeg"==t.substr(-5).toLowerCase())return s.ImageType.JPG;throw new Error("Can't recognise image type: "+t)},_readStream:function(t){var e=i.defer(),r=[];return t.on("data",function(t){r.push(t)}),t.on("end",function(){var t=n.concat(r);e.resolve(t)}),t.on("error",function(t){e.reject(t)}),e.promise},_readPNG:function(t){var e=i.defer(),n=new o({filterType:4});return n.on("parsed",function(){e.resolve(n)}),n.on("error",function(t){e.rejecyt(t)}),t.pipe(n),e.promise},_parseOptions:function(t,e){return"number"==typeof(t=t||{})&&(t={type:t}),t.type=t.type||this._deduceFileType(e),t},read:function(t,e){var n=this;switch((e=this._parseOptions(e)).type){case s.ImageType.JPG:return this._readStream(t).then(function(t){n._data=a.decode(t)});case s.ImageType.PNG:return this._readPNG(t).then(function(t){n._data={data:t.data,width:t.width,height:t.height}});default:return i.reject(new Error("Not supported: ImageType "+e.type))}},readFile:function(t,e){var n=this;return u.fs.exists(t).then(function(i){if(i){e=n._parseOptions(e,t);var a=r.createReadStream(t);return n.read(a,e)}throw new Error("File Not Found: "+t)})},write:function(t,e){e=this._parseOptions(e);var n=i.defer();try{switch(t.on("finish",function(){n.resolve()}),t.on("error",function(t){n.reject(t)}),e.type){case s.ImageType.JPG:var r=a.encode(this._data,e.quality||90).data;t.write(r),t.end();break;case s.ImageType.PNG:var u=new o;u.width=this.width,u.height=this.height,u.data=this._data.data,u.on("end",function(){n.resolve()}),u.on("error",function(t){n.reject(t)}),u.pack().pipe(t);break;default:throw new Error("Not supported: ImageType "+e.type)}}catch(t){n.reject(t)}return n.promise},writeFile:function(t,e){e=this._parseOptions(e,t);var n=r.createWriteStream(t);return this.write(n,e)},clone:function(){return new f({width:this.width,height:this.height,data:new n(this._data.data)})},setPixel:function(t,e,n,r,i,a){if(void 0===r){var o=n;n=o.r,r=o.g,i=o.b,a=o.a}void 0===a&&(a=255);var s=4*(e*this.width+t),u=this._data.data;u[s++]=n,u[s++]=r,u[s++]=i,u[s++]=a},getPixel:function(t,e,n){var r=4*(e*this.width+t);n=n||{};var i=this._data.data;return n.r=i[r++],n.g=i[r++],n.b=i[r++],n.a=i[r++],n},negative:function(){for(var t=new f({width:this.width,height:this.height}),e=this.width*this.height,n=this._data.data,r=t._data.data,i=0,a=0,o=0;o-1&&C-1&&M=0&&M>=0?b[P]:O)+D*(g=C=0?b[P+4]:O),z=(1-D)*(m=C>=0&&M0?o:0)-(c>0?4:0)]+2*s[p-(l>0?o:0)]+1*s[p-(l>0?o:0)+(c0?4:0)]+4*s[p]+2*s[p+(c0?4:0)]+2*s[p+(l0?a[x-4]:2*a[x]-a[x+4],E=a[x],S=a[x+4],j=z0?v[x-4*h]:2*v[x]-v[x+4*h],M=v[x],I=v[x+4*h],R=N1)for(g=0;g0&&!t[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(n=0;n0;)u=a.pop();for(u.index++,a.push(u);a.length<=n;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}n+10)return p>>--d&1;if(255==(p=e[n++])){var t=e[n++];if(t)throw"unexpected marker: "+(p<<8|t).toString(16)}return d=7,p>>>7}function g(t){for(var e,n=t;null!==(e=v());){if("number"==typeof(n=n[e]))return n;if("object"!=typeof n)throw"invalid huffman sequence"}return null}function m(t){for(var e=0;t>0;){var n=v();if(null===n)return;e=e<<1|n,t--}return e}function _(t){var e=m(t);return e>=1<0)y--;else for(var r=o,i=s;r<=i;){var a=g(e.huffmanTableAC),u=15&a,c=a>>4;if(0!==u)n[t[r+=c]]=_(u)*(1<>4,0===f)a<15?(y=m(a)+(1<>4;if(0!==s)n[t[a+=u]]=_(s),a++;else{if(u<15)break;a+=16}}};var I,R,L,B,F=0;for(R=1==M?i[0].blocksPerLine*i[0].blocksPerColumn:c*r.mcusPerColumn,a||(a=R);F=65488&&I<=65495))break;n+=2}return n-h}function h(t,l){var c,f,h=[],p=l.blocksPerLine,d=l.blocksPerColumn,v=p<<3,g=new Int32Array(64),m=new Uint8Array(64);function _(t,c,f){var h,p,d,v,g,m,_,y,w,b,x=l.quantizationTable,k=f;for(b=0;b<64;b++)k[b]=t[b]*x[b];for(b=0;b<8;++b){var E=8*b;0!=k[1+E]||0!=k[2+E]||0!=k[3+E]||0!=k[4+E]||0!=k[5+E]||0!=k[6+E]||0!=k[7+E]?(h=s*k[0+E]+128>>8,p=s*k[4+E]+128>>8,d=k[2+E],v=k[6+E],g=u*(k[1+E]-k[7+E])+128>>8,y=u*(k[1+E]+k[7+E])+128>>8,m=k[3+E]<<4,_=k[5+E]<<4,w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+128>>8,d=d*a-v*o+128>>8,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+E]=h+y,k[7+E]=h-y,k[1+E]=p+_,k[6+E]=p-_,k[2+E]=d+m,k[5+E]=d-m,k[3+E]=v+g,k[4+E]=v-g):(w=s*k[0+E]+512>>10,k[0+E]=w,k[1+E]=w,k[2+E]=w,k[3+E]=w,k[4+E]=w,k[5+E]=w,k[6+E]=w,k[7+E]=w)}for(b=0;b<8;++b){var S=b;0!=k[8+S]||0!=k[16+S]||0!=k[24+S]||0!=k[32+S]||0!=k[40+S]||0!=k[48+S]||0!=k[56+S]?(h=s*k[0+S]+2048>>12,p=s*k[32+S]+2048>>12,d=k[16+S],v=k[48+S],g=u*(k[8+S]-k[56+S])+2048>>12,y=u*(k[8+S]+k[56+S])+2048>>12,m=k[24+S],_=k[40+S],w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+2048>>12,d=d*a-v*o+2048>>12,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+S]=h+y,k[56+S]=h-y,k[8+S]=p+_,k[48+S]=p-_,k[16+S]=d+m,k[40+S]=d-m,k[24+S]=v+g,k[32+S]=v-g):(w=s*f[b+0]+8192>>14,k[0+S]=w,k[8+S]=w,k[16+S]=w,k[24+S]=w,k[32+S]=w,k[40+S]=w,k[48+S]=w,k[56+S]=w)}for(b=0;b<64;++b){var j=128+(k[b]+8>>4);c[b]=j<0?0:j>255?255:j}}for(var y=0;y255?255:t}return l.prototype={load:function(t){var e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){var t=new Uint8Array(e.response||e.mozResponseArrayBuffer);this.parse(t),this.onload&&this.onload()}.bind(this),e.send(null)},parse:function(e){var n=0;e.length;function r(){var t=e[n]<<8|e[n+1];return n+=2,t}function i(){var t=r(),i=e.subarray(n,n+t-2);return n+=i.length,i}function a(t){var e,n,r=0,i=0;for(n in t.components)t.components.hasOwnProperty(n)&&(r<(e=t.components[n]).h&&(r=e.h),i>4==0)for(z=0;z<64;z++){b[t[z]]=e[n++]}else{if(w>>4!=1)throw"DQT: invalid table spec";for(z=0;z<64;z++){b[t[z]]=r()}}p[15&w]=b}break;case 65472:case 65473:case 65474:r(),(o={}).extended=65473===m,o.progressive=65474===m,o.precision=e[n++],o.scanLines=r(),o.samplesPerLine=r(),o.components={},o.componentsOrder=[];var x,k=e[n++];for(N=0;N>4,S=15&e[n+1],j=e[n+2];o.componentsOrder.push(x),o.components[x]={h:E,v:S,quantizationIdx:j},n+=3}a(o),d.push(o);break;case 65476:var T=r();for(N=2;N>4==0?g:v)[15&A]=c(C,I)}break;case 65501:r(),s=r();break;case 65498:r();var R=e[n++],L=[];for(N=0;N>4],q.huffmanTableAC=v[15&B],L.push(q)}var F=e[n++],P=e[n++],O=e[n++],D=f(e,n,o,L,s,F,P,O>>4,15&O);n+=D;break;default:if(255==e[n-3]&&e[n-2]>=192&&e[n-2]<=254){n-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}if(1!=d.length)throw"only single frame JPEGs supported";for(var N=0;N=0;)e&1<>8&255),F(255&t)}function O(t,e,n,r,i){var a,o=i[0],s=i[240];for(var u=function(t,e){var n,r,i,a,o,s,u,l,c,f,h=0;for(c=0;c<8;++c){n=t[h],r=t[h+1],i=t[h+2],a=t[h+3],o=t[h+4],s=t[h+5],u=t[h+6];var p=n+(l=t[h+7]),v=n-l,g=r+u,m=r-u,_=i+s,y=i-s,w=a+o,b=a-o,x=p+w,k=p-w,E=g+_,S=g-_;t[h]=x+E,t[h+4]=x-E;var j=.707106781*(S+k);t[h+2]=k+j,t[h+6]=k-j;var T=.382683433*((x=b+y)-(S=m+v)),A=.5411961*x+T,C=1.306562965*S+T,M=.707106781*(E=y+m),I=v+M,R=v-M;t[h+5]=R+A,t[h+3]=R-A,t[h+1]=I+C,t[h+7]=I-C,h+=8}for(h=0,c=0;c<8;++c){n=t[h],r=t[h+8],i=t[h+16],a=t[h+24],o=t[h+32],s=t[h+40],u=t[h+48];var L=n+(l=t[h+56]),B=n-l,F=r+u,P=r-u,O=i+s,D=i-s,N=a+o,U=a-o,z=L+N,q=L-N,V=F+O,G=F-O;t[h]=z+V,t[h+32]=z-V;var H=.707106781*(G+q);t[h+16]=q+H,t[h+48]=q-H;var W=.382683433*((z=U+D)-(G=P+B)),Z=.5411961*z+W,Y=1.306562965*G+W,X=.707106781*(V=D+P),$=B+X,J=B-X;t[h+40]=J+Z,t[h+24]=J-Z,t[h+8]=$+Y,t[h+56]=$-Y,h++}for(c=0;c<64;++c)f=t[c]*e[c],d[c]=f>0?f+.5|0:f-.5|0;return d}(t,e),l=0;l<64;++l)v[E[l]]=u[l];var c=v[0]-n;n=v[0],0==c?B(r[0]):(B(r[p[a=32767+c]]),B(h[a]));for(var f=63;f>0&&0==v[f];f--);if(0==f)return B(o),n;for(var g,m=1;m<=f;){for(var _=m;0==v[m]&&m<=f;++m);var y=m-_;if(y>=16){g=y>>4;for(var w=1;w<=g;++w)B(s);y&=15}a=32767+v[m],B(i[(y<<4)+p[a]]),B(h[a]),m++}return 63!=f&&B(o),n}function D(t){if(t<=0&&(t=1),t>100&&(t=100),o!=t){(function(t){for(var e=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;n<64;n++){var r=s((e[n]*t+50)/100);r<1?r=1:r>255&&(r=255),u[E[n]]=r}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],a=0;a<64;a++){var o=s((i[a]*t+50)/100);o<1?o=1:o>255&&(o=255),l[E[a]]=o}for(var h=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],p=0,d=0;d<8;d++)for(var v=0;v<8;v++)c[p]=1/(u[E[p]]*h[d]*h[v]*8),f[p]=1/(l[E[p]]*h[d]*h[v]*8),p++})(t<50?Math.floor(5e3/t):Math.floor(200-2*t)),o=t}}this.encode=function(e,o){(new Date).getTime();o&&D(o),g=new Array,m=0,_=7,P(65496),P(65504),P(16),F(74),F(70),F(73),F(70),F(0),F(1),F(1),F(0),P(1),P(1),F(0),F(0),function(){P(65499),P(132),F(0);for(var t=0;t<64;t++)F(u[t]);F(1);for(var e=0;e<64;e++)F(l[e])}(),function(t,e){P(65472),P(17),F(8),P(e),P(t),F(3),F(1),F(17),F(0),F(2),F(17),F(1),F(3),F(17),F(1)}(e.width,e.height),function(){P(65476),P(418),F(0);for(var t=0;t<16;t++)F(S[t+1]);for(var e=0;e<=11;e++)F(j[e]);F(16);for(var n=0;n<16;n++)F(T[n+1]);for(var r=0;r<=161;r++)F(A[r]);F(1);for(var i=0;i<16;i++)F(C[i+1]);for(var a=0;a<=11;a++)F(M[a]);F(17);for(var o=0;o<16;o++)F(I[o+1]);for(var s=0;s<=161;s++)F(R[s])}(),P(65498),P(12),F(3),F(1),F(0),F(2),F(17),F(3),F(17),F(0),F(63),F(0);var s=0,h=0,p=0;m=0,_=7,this.encode.displayName="_encode_";for(var d,v,x,E,L,N,U,z,q,V=e.data,G=e.width,H=e.height,W=4*G,Z=0;Z>3)*W+(U=4*(7&q)),Z+z>=H&&(N-=W*(Z+1+z-H)),d+U>=W&&(N-=d+U-W+4),v=V[N++],x=V[N++],E=V[N++],y[q]=(k[v]+k[x+256>>0]+k[E+512>>0]>>16)-128,w[q]=(k[v+768>>0]+k[x+1024>>0]+k[E+1280>>0]>>16)-128,b[q]=(k[v+1280>>0]+k[x+1536>>0]+k[E+1792>>0]>>16)-128;s=O(y,c,s,n,i),h=O(w,f,h,r,a),p=O(b,f,p,r,a),d+=32}Z+=8}if(_>=0){var Y=[];Y[1]=_+1,Y[0]=(1<<_+1)-1,B(Y)}return P(65497),new t(g)},function(){(new Date).getTime();e||(e=50),function(){for(var t=String.fromCharCode,e=0;e<256;e++)x[e]=t(e)}(),n=L(S,j),r=L(C,M),i=L(T,A),a=L(I,R),function(){for(var t=1,e=2,n=1;n<=15;n++){for(var r=t;r>0]=38470*t,k[t+512>>0]=7471*t+32768,k[t+768>>0]=-11059*t,k[t+1024>>0]=-21709*t,k[t+1280>>0]=32768*t+8421375,k[t+1536>>0]=-27439*t,k[t+1792>>0]=-5329*t}(),D(e),(new Date).getTime()}()}e.exports=function(t,e){void 0===e&&(e=50);return{data:new n(e).encode(t,e),width:t.width,height:t.height}}}).call(this,t("buffer").Buffer)},{buffer:5}],70:[function(t,e,n){arguments[4][42][0].apply(n,arguments)},{dup:42}],71:[function(t,e,n){"use strict";e.exports=function(t){for(var e=new Array(t),n=0;n>i;0!=(e&o)&&p++;var d=n>>i;return 0!=(n&o)&&d++,function(t,e,n,o,s,u){function l(t,e,n){return tn?n:t}var c=r.BitMatrix.createEmpty(o,s);function f(t,e,n,r,i){for(var o=n*i+e,s=0;sd&&(p=d);for(var v=0;vm&&(g=m);for(var _=l(v,2,e-3),y=l(h,2,n-3),w=0,b=-2;b<=2;b++){var x=u[y+b];w+=x[_-2],w+=x[_-1],w+=x[_],w+=x[_+1],w+=x[_+2]}f(t,g,p,w/25,o)}}return c}(u,p,d,e,n,function(t,e,n,r,o){for(var u=new Array(n),l=0;lh&&(f=h);for(var p=0;pv&&(d=v);for(var g=0,m=255,_=0,y=0,w=f*r+d;y_&&(_=x)}if(_-m>s)for(y++,w+=r;y>2*i;if(_-m<=s&&(k=m>>1,c>0&&p>0)){var E=u[c-1][p]+2*u[c][p-1]+u[c-1][p-1]>>2;m=n&&(t++,r+=e.estimatedModuleSize)}),t<3)return!1;for(var a=r/i,o=0,s=0;s=0&&c(n,l);)o[2]++,l--;if(l<0)return null;for(;l>=0&&!c(n,l)&&o[1]<=r;)o[1]++,l--;if(l<0||o[1]>r)return null;for(;l>=0&&c(n,l)&&o[0]<=r;)o[0]++,l--;if(o[0]>r)return null;for(l=e+1;l=r)return null;for(;l=r)return null;var f=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(f-i)>=2*i?null:s(o)?u(o,l):null}(r,Math.floor(f),n[2],l);if(null!=h&&null!=(f=function(e,n,r,i){for(var a=t.width,o=[0,0,0,0,0],l=e;l>=0&&c(l,n);)o[2]++,l--;if(l<0)return null;for(;l>=0&&!c(l,n)&&o[1]<=r;)o[1]++,l--;if(l<0||o[1]>r)return null;for(;l>=0&&c(l,n)&&o[0]<=r;)o[0]++,l--;if(o[0]>r)return null;for(l=e+1;l=r)return null;for(;l=r)return null;var f=o[0]+o[1]+o[2]+o[3]+o[4];return 5*Math.abs(f-i)>=i?null:s(o)?u(o,l):null}(Math.floor(f),Math.floor(h),n[2],l))&&(!a||function(e,n,r,i){for(var a=t.height,o=t.width,u=[0,0,0,0,0],l=0;e-l>=0&&c(n-l,e-l);)u[2]++,l++;if(e-l<0||n-l<0)return!1;for(;e-l>=0&&n-l>=0&&!c(n-l,e-l)&&u[1]<=r;)u[1]++,l++;if(e-l<0||n-l<0||u[1]>r)return!1;for(;e-l>=0&&n-l>=0&&c(n-l,e-l)&&u[0]<=r;)u[0]++,l++;if(u[0]>r)return!1;for(l=1;e+l=a||n+l>=o)return!1;for(;e+l=a||n+l>=o||u[3]>=r)return!1;for(;e+l=r)return!1;var f=u[0]+u[1]+u[2]+u[3]+u[4];return Math.abs(f-i)<2*i&&s(u)}(Math.floor(h),Math.floor(f),n[2],l))){for(var p=l/7,d=!1,v=0;v=n){if(null!=t)return a=!0,Math.floor(Math.abs(t.x-e.x)-Math.abs(t.y-e.y))/2;t=e}}),0}var d=t.height,v=t.width,g=Math.floor(3*d/(4*i));g_[2]&&(y+=x-_[2]-g,b=v-1)}_=[0,0,0,0,0],w=0}else _=[_[2],_[3],_[4],1,0],w=3;else _[++w]++;else _[w]++;s(_)&&h(_,y,v,!1)&&(g=_[0],a&&(m=f()))}var k=function(){var t=e.length;if(t<3)return null;if(t>3){var n=0,r=0;e.forEach(function(t){var e=t.estimatedModuleSize;n+=e,r+=e*e});var i=n/t,a=Math.sqrt(r/t-i*i);e.sort(function(t,e){var n=Math.abs(e.estimatedModuleSize-i),r=Math.abs(t.estimatedModuleSize-i);return n3;s++){var u=e[s];Math.abs(u.estimatedModuleSize-i)>o&&(e.splice(s,1),s--)}}return e.length>3&&(n=0,e.forEach(function(t){n+=t.estimatedModuleSize}),i=n/e.length,e.sort(function(t,e){if(e.count===t.count){var n=Math.abs(e.estimatedModuleSize-i),r=Math.abs(t.estimatedModuleSize-i);return n=i&&a>=o?(n=t[0],e=t[1],r=t[2]):o>=a&&o>=i?(n=t[1],e=t[0],r=t[2]):(n=t[2],e=t[0],r=t[1]),function(t,e,n){var r=e.x,i=e.y;return(n.x-r)*(t.y-i)-(n.y-i)*(t.x-r)}(e,n,r)<0){var s=e;e=r,r=s}return{bottomLeft:{x:e.x,y:e.y},topLeft:{x:n.x,y:n.y},topRight:{x:r.x,y:r.y}}}(k):null}},function(t,e,n){"use strict";var r=n(5),i=n(7),a=n(8),o=n(2),s=n(6);function u(t,e,n){for(var r=!0,i=0;it||o<-1||o>e)throw new Error;r=!1,-1==a?(n[i]=0,r=!0):a==t&&(n[i]=t-1,r=!0),-1==o?(n[i+1]=0,r=!0):o==e&&(n[i+1]=e-1,r=!0)}r=!0;for(i=n.length-2;i>=0&&r;i-=2){a=Math.floor(n[i]),o=Math.floor(n[i+1]);if(a<-1||a>t||o<-1||o>e)throw new Error;r=!1,-1==a?(n[i]=0,r=!0):a==t&&(n[i]=t-1,r=!0),-1==o?(n[i+1]=0,r=!0):o==e&&(n[i+1]=e-1,r=!0)}return n}function l(t,e,n,r){return Math.sqrt((n-t)*(n-t)+(r-e)*(r-e))}function c(t,e,n,i,a){e=Math.floor(e),n=Math.floor(n);var o=Math.floor(i*t),s=Math.max(0,e-o),u=Math.min(a.width,e+o);if(u-s<3*t)return null;var l=Math.max(0,n-o),c=Math.min(a.height-1,n+o);return r.findAlignment(s,l,u-s,c-l,t,a)}function f(t,e,n,r,i){t=Math.floor(t),e=Math.floor(e),n=Math.floor(n),r=Math.floor(r);var a=Math.abs(r-e)>Math.abs(n-t);if(a){var o=t;t=e,e=o,o=n,n=r,r=o}for(var s=Math.abs(n-t),u=Math.abs(r-e),c=-s>>1,f=t0){if(g==r)break;g+=h,c-=s}}return 2==p?l(n+f,r,t,e):NaN}function h(t,e,n,r,i){var a=f(t,e,n,r,i),o=1,s=t-(n-t);s<0?(o=t/(t-s),s=0):s>=i.width&&(o=(i.width-1-t)/(s-t),s=i.width-1);var u=e-(r-e)*o;return o=1,u<0?(o=e/(e-u),u=0):u>=i.height&&(o=(i.height-1-e)/(u-e),u=i.height-1),(a+=f(t,e,s=t+(s-t)*o,u,i))-1}function p(t,e,n){var r=h(t.x,t.y,e.x,e.y,n),i=h(e.x,e.y,t.x,t.y,n);return s.isNaN(r)?i/7:s.isNaN(i)?r/7:(r+i)/14}e.extract=function(t,e){var n=function(t,e,n,r){return(p(t,e,r)+p(t,n,r))/2}(e.topLeft,e.topRight,e.bottomLeft,t);if(n<1)return null;var r=function(t,e,n,r){var i=7+(Math.round(l(t.x,t.y,e.x,e.y)/r)+Math.round(l(t.x,t.y,n.x,n.y)/r)>>1);switch(3&i){case 0:i++;break;case 2:i--}return i}(e.topLeft,e.topRight,e.bottomLeft,n);if(!r)return null;var s=function(t){if(t%4!=1)return null;var e=t-17>>2;return e<1||e>40?null:a.getVersionForNumber(e)}(r);if(null==s)return null;var f=s.getDimensionForVersion()-7,h=null;if(s.alignmentPatternCenters.length>0)for(var d=e.topRight.x-e.topLeft.x+e.bottomLeft.x,v=e.topRight.y-e.topLeft.y+e.bottomLeft.y,g=1-3/f,m=e.topLeft.x+g*(d-e.topLeft.x),_=e.topLeft.y+g*(v-e.topLeft.y),y=4;y<=16&&!(h=c(n,m,_,y,t));y<<=1);return function(t,e,n){if(e<=0)return null;for(var r=o.BitMatrix.createEmpty(e,e),a=new Array(e<<1),s=0;s>1),a[f+1]=c;a=i.transformPoints(n,a);try{var h=u(t.width,t.height,a)}catch(t){return null}for(f=0;f>1,s,t.get(Math.floor(h[f]),Math.floor(h[f+1])))}return r}(t,r,function(t,e,n,r,a){var o,s,u,l,c=a-3.5;return null!=r?(o=r.x,s=r.y,u=l=c-3):(o=e.x-t.x+n.x,s=e.y-t.y+n.y,u=l=c),i.quadrilateralToQuadrilateral(3.5,3.5,c,3.5,u,l,3.5,c,t.x,t.y,e.x,e.y,o,s,n.x,n.y)}(e.topLeft,e.topRight,e.bottomLeft,h,r))}},function(t,e,n){"use strict";var r=n(6);function i(t,e,n,r){if(Math.abs(n-t.y)<=e&&Math.abs(r-t.x)<=e){var i=Math.abs(e-t.estimatedModuleSize);return i<=1||i<=t.estimatedModuleSize}return!1}function a(t,e,n,r){return{x:(t.x+n)/2,y:(t.y+e)/2,estimatedModuleSize:(t.estimatedModuleSize+r)/2}}function o(t,e){for(var n=e/2,r=0;r<3;r++)if(Math.abs(e-t[r])>=n)return!1;return!0}function s(t,e){var n=e-t[2]-t[1]/2;return r.isNaN(n)?null:n}e.findAlignment=function(t,e,n,r,u,l){var c=[];function f(t,e,n,r){var u=t[0]+t[1]+t[2],f=s(t,n);if(null==f)return null;var h=function(t,e,n,r,i,a){for(var u=a.height,l=[0,0,0],c=t;c>=0&&a.get(e,c)&&l[1]<=n;)l[1]++,c--;if(c<0||l[1]>n)return null;for(;c>=0&&!a.get(e,c)&&l[0]<=n;)l[0]++,c--;if(l[0]>n)return null;for(c=t+1;cn)return null;for(;cn)return null;var f=l[0]+l[1]+l[2];return 5*Math.abs(f-r)>=2*r?null:o(l,i)?s(l,c):null}(e,Math.floor(f),2*t[1],u,r,l);if(null!=h){var p=(t[0]+t[1]+t[2])/3;for(var d in c){var v=c[d];if(i(v,p,h,f))return a(v,h,f,p)}var g={x:f,y:h,estimatedModuleSize:p};c.push(g)}return null}for(var h=t+n,p=e+(r>>1),d=[0,0,0],v=0;v>1:-(v+1>>1));d[0]=0,d[1]=0,d[2]=0;for(var m=t;m>4&15]+n[t>>8&15]+n[t>>12&15]+n[t>>16&15]+n[t>>20&15]+n[t>>24&15]+n[t>>28&15]},e.isNaN=function(t){return"[object Number]"===Object.prototype.toString.call(t)&&t!==+t}},function(t,e){"use strict";function n(t,e,n,r,i,a,o,s){var u=t-n+i-o,l=e-r+a-s;if(0==u&&0==l)return{a11:n-t,a21:i-n,a31:t,a12:r-e,a22:a-r,a32:e,a13:0,a23:0,a33:1};var c=n-i,f=o-i,h=r-a,p=s-a,d=c*p-f*h,v=(u*p-f*l)/d,g=(c*l-u*h)/d;return{a11:n-t+v*n,a21:o-t+g*o,a31:t,a12:r-e+v*r,a22:s-e+g*s,a32:e,a13:v,a23:g,a33:1}}e.transformPoints=function(t,e){for(var n=e.length,r=t.a11,i=t.a12,a=t.a13,o=t.a21,s=t.a22,u=t.a23,l=t.a31,c=t.a32,f=t.a33,h=0;h40)throw new Error("Invalid version number "+t);return u[t-1]}e.getVersionForNumber=l},function(t,e,n){"use strict";var r=n(2),i=n(10),a=n(6),o=n(12),s=n(8),u=21522,l=[[21522,0],[20773,1],[24188,2],[23371,3],[17913,4],[16590,5],[20375,6],[19104,7],[30660,8],[29427,9],[32170,10],[30877,11],[26159,12],[25368,13],[27713,14],[26998,15],[5769,16],[5054,17],[7399,18],[6608,19],[1890,20],[597,21],[3340,22],[2107,23],[13663,24],[12392,25],[16177,26],[14854,27],[9396,28],[8579,29],[11994,30],[11245,31]],c=[function(t,e){return 0==(t+e&1)},function(t,e){return 0==(1&t)},function(t,e){return e%3==0},function(t,e){return(t+e)%3==0},function(t,e){return 0==((t>>1)+e/3&1)},function(t,e){return(t*e&1)+t*e%3==0},function(t,e){return 0==((t*e&1)+t*e%3&1)},function(t,e){return 0==((t+e&1)+t*e%3&1)}],f=[{ordinal:1,bits:0,name:"M"},{ordinal:0,bits:1,name:"L"},{ordinal:3,bits:2,name:"H"},{ordinal:2,bits:3,name:"Q"}];function h(t,e,n){for(var i=c[n.dataMask],a=t.height,o=function(t){for(var e=t.getDimensionForVersion(),n=new Array(e*e),i=0;i6&&(a.setRegion(e-11,0,3,6),a.setRegion(0,e-11,6,3)),a}(e),s=!0,u=[],l=0,f=0,h=0,p=a-1;p>0;p-=2){6==p&&p--;for(var d=0;d>3&3],dataMask:7&t}}function d(t,e){for(var n=1/0,r=0,i=0;i=0;r--)e=t.copyBit(8,r,e);var i=t.height,a=0,o=i-7;for(r=i-1;r>=o;r--)a=t.copyBit(8,r,a);for(n=i-8;n>2;if(n<=6)return s.getVersionForNumber(n);for(var r=0,i=e-11,a=5;a>=0;a--)for(var o=e-9;o>=i;o--)r=t.copyBit(o,a,r);var u=s.Version.decodeVersionInformation(r);if(null!=u&&u.getDimensionForVersion()==e)return u;for(r=0,o=5;o>=0;o--)for(a=e-9;a>=i;a--)r=t.copyBit(o,a,r);return null!=(u=s.Version.decodeVersionInformation(r))&&u.getDimensionForVersion()==e?u:null}(t);if(!e)return null;var n=v(t);if(!n)return null;var r=n.errorCorrectionLevel,a=h(t,e,n);if(!a)return null;var o=function(t,e,n){if(t.length!=e.totalCodewords)throw new Error("Invalid number of codewords for version; got "+t.length+" expected "+e.totalCodewords);var r=e.getECBlocksForLevel(n),i=0,a=r.ecBlocks;a.forEach(function(t){i+=t.count});var o=new Array(i),s=0;a.forEach(function(t){for(var e=0;e=0&&o[l].codewords.length!=u;)l--;l++;for(var c=u-r.ecCodewordsPerBlock,f=0,h=0;h=e.length)throw new Error("Could not decode alphanumeric char");return e[t].charCodeAt(0)}var a=function(){function t(t,e){this.characterCountBitsForVersions=t,this.bits=e}return t.prototype.getCharacterCountBits=function(t){if(null==this.characterCountBitsForVersions)throw new Error("Character count doesn't apply to this mode");var e;return e=t<=9?0:t<=26?1:2,this.characterCountBitsForVersions[e]},t}(),o=new a([0,0,0],0),s=new a([10,12,14],1),u=new a([9,11,13],2),l=new a([0,0,0],3),c=new a([8,16,16],4),f=new a(null,7),h=new a([8,10,12],8),p=new a(null,5),d=new a(null,9),v=new a([8,10,12],13);function g(t){switch(t){case 0:return o;case 1:return s;case 2:return u;case 3:return l;case 4:return c;case 5:return p;case 7:return f;case 8:return h;case 9:return d;case 13:return v;default:throw new Error("Couldn't decode mode from byte array")}}function m(t){var e=t.readBits(8);if(0==(128&e))return 127&e;if(128==(192&e))return(63&e)<<8|t.readBits(8);if(192==(224&e))return(31&e)<<16|t.readBits(16);throw new Error("Bad ECI bits starting with byte "+e)}function _(t,e,n){if(13*n>t.available())return!1;for(var r=new Array(2*n),i=0;n>0;){var a=t.readBits(13),o=Math.floor(a/96)<<8|a%96;o+=o<959?41377:42657,r[i]=o>>8&255,r[i+1]=255&o,i+=2,n--}return e.val=r,!0}function y(t,e,n){for(;n>=3;){if(t.available()<10)return!1;var r=t.readBits(10);if(r>=1e3)return!1;e.val.push(i(Math.floor(r/100))),e.val.push(i(Math.floor(r/10)%10)),e.val.push(i(r%10)),n-=3}if(2==n){if(t.available()<7)return!1;var a=t.readBits(7);if(a>=100)return!1;e.val.push(i(Math.floor(a/10))),e.val.push(i(a%10))}else if(1==n){if(t.available()<4)return!1;var o=t.readBits(4);if(o>=10)return!1;e.val.push(i(o))}return!0}function w(t,e,n,r){for(var a=e.val.length;n>1;){if(t.available()<11)return!1;var o=t.readBits(11);e.val.push(i(Math.floor(o/45))),e.val.push(i(o%45)),n-=2}if(1==n){if(t.available()<6)return!1;e.val.push(i(t.readBits(6)))}if(r)for(var s=a;st.available())return!1;for(var r=new Array(n),i=0;i30)return null}else if(i==v){var j=a.readBits(4),T=a.readBits(i.getCharacterCountBits(e));if(j==x&&!_(a,k,T))return null}else{var A=a.readBits(i.getCharacterCountBits(e));if(i==s){if(!y(a,k,A))return null}else if(i==u){if(!w(a,k,A,E))return null}else if(i==c){if(!b(a,k,A))return null}else if(i!=h)return null}return k.val}},function(t,e){"use strict";var n=function(){function t(t){this.byteOffset=0,this.bitOffset=0,this.bytes=t}return t.prototype.readBits=function(t){if(t<1||t>32||t>this.available())throw new Error("Cannot read "+t.toString()+" bits");var e=0;if(this.bitOffset>0){var n=8-this.bitOffset,r=t>8-r<<(a=n-r);e=(this.bytes[this.byteOffset]&i)>>a,t-=r,this.bitOffset+=r,8==this.bitOffset&&(this.bitOffset=0,this.byteOffset++)}if(t>0){for(;t>=8;)e=e<<8|255&this.bytes[this.byteOffset],this.byteOffset++,t-=8;if(t>0){var a;i=255>>(a=8-t)<>a,this.bitOffset+=t}}return e},t.prototype.available=function(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset},t}();e.BitStream=n},function(t,e){"use strict";var n=function(){function t(){this.field=new i(285,256,0)}return t.prototype.decode=function(t,e){for(var n=new r(this.field,t),a=new Array(e),o=!0,s=0;s=n/2;){var u=i,l=o;if(o=s,(i=a).isZero())return null;a=u;for(var c=this.field.zero,f=i.getCoefficient(i.degree()),h=this.field.inverse(f);a.degree()>=i.degree()&&!a.isZero();){var p=a.degree()-i.degree(),d=this.field.multiply(a.getCoefficient(a.degree()),h);c=c.addOrSubtract(this.field.buildMonomial(p,d)),a=a.addOrSubtract(i.multiplyByMonomial(p,d))}if(s=c.multiplyPoly(o).addOrSubtract(l),a.degree()>=i.degree())return null}var v=s.getCoefficient(0);if(0==v)return null;var g=this.field.inverse(v);return[s.multiply(g),a.multiply(g)]},t.prototype.findErrorLocations=function(t){var e=t.degree();if(1==e)return[t.getCoefficient(1)];for(var n=new Array(e),r=0,i=1;i1&&0==e[0]){for(var r=1;rr.length){var a=n;n=r,r=a}for(var o=new Array(r.length),s=r.length-n.length,u=0;u=this.size&&(t^=this.primitive,t&=this.size-1);for(e=0;e>>1,D=[["ary",x],["bind",v],["bindKey",g],["curry",_],["curryRight",y],["flip",E],["partial",w],["partialRight",b],["rearg",k]],N="[object Arguments]",U="[object Array]",z="[object AsyncFunction]",q="[object Boolean]",V="[object Date]",G="[object DOMException]",H="[object Error]",W="[object Function]",Z="[object GeneratorFunction]",Y="[object Map]",X="[object Number]",$="[object Null]",J="[object Object]",Q="[object Proxy]",K="[object RegExp]",tt="[object Set]",et="[object String]",nt="[object Symbol]",rt="[object Undefined]",it="[object WeakMap]",at="[object WeakSet]",ot="[object ArrayBuffer]",st="[object DataView]",ut="[object Float32Array]",lt="[object Float64Array]",ct="[object Int8Array]",ft="[object Int16Array]",ht="[object Int32Array]",pt="[object Uint8Array]",dt="[object Uint8ClampedArray]",vt="[object Uint16Array]",gt="[object Uint32Array]",mt=/\b__p \+= '';/g,_t=/\b(__p \+=) '' \+/g,yt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,wt=/&(?:amp|lt|gt|quot|#39);/g,bt=/[&<>"']/g,xt=RegExp(wt.source),kt=RegExp(bt.source),Et=/<%-([\s\S]+?)%>/g,St=/<%([\s\S]+?)%>/g,jt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,At=/^\w*$/,Ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mt=/[\\^$.*+?()[\]{}|]/g,It=RegExp(Mt.source),Rt=/^\s+|\s+$/g,Lt=/^\s+/,Bt=/\s+$/,Ft=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Pt=/\{\n\/\* \[wrapped with (.+)\] \*/,Ot=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Nt=/\\(\\)?/g,Ut=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Vt=/^0b[01]+$/i,Gt=/^\[object .+?Constructor\]$/,Ht=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Zt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Yt=/($^)/,Xt=/['\n\r\u2028\u2029\\]/g,$t="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Jt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qt="[\\ud800-\\udfff]",Kt="["+Jt+"]",te="["+$t+"]",ee="\\d+",ne="[\\u2700-\\u27bf]",re="[a-z\\xdf-\\xf6\\xf8-\\xff]",ie="[^\\ud800-\\udfff"+Jt+ee+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ae="\\ud83c[\\udffb-\\udfff]",oe="[^\\ud800-\\udfff]",se="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",le="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ce="(?:"+re+"|"+ie+")",fe="(?:"+le+"|"+ie+")",he="(?:"+te+"|"+ae+")"+"?",pe="[\\ufe0e\\ufe0f]?"+he+("(?:\\u200d(?:"+[oe,se,ue].join("|")+")[\\ufe0e\\ufe0f]?"+he+")*"),de="(?:"+[ne,se,ue].join("|")+")"+pe,ve="(?:"+[oe+te+"?",te,se,ue,Qt].join("|")+")",ge=RegExp("['’]","g"),me=RegExp(te,"g"),_e=RegExp(ae+"(?="+ae+")|"+ve+pe,"g"),ye=RegExp([le+"?"+re+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Kt,le,"$"].join("|")+")",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Kt,le+ce,"$"].join("|")+")",le+"?"+ce+"+(?:['’](?:d|ll|m|re|s|t|ve))?",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ee,de].join("|"),"g"),we=RegExp("[\\u200d\\ud800-\\udfff"+$t+"\\ufe0e\\ufe0f]"),be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,xe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ee={};Ee[ut]=Ee[lt]=Ee[ct]=Ee[ft]=Ee[ht]=Ee[pt]=Ee[dt]=Ee[vt]=Ee[gt]=!0,Ee[N]=Ee[U]=Ee[ot]=Ee[q]=Ee[st]=Ee[V]=Ee[H]=Ee[W]=Ee[Y]=Ee[X]=Ee[J]=Ee[K]=Ee[tt]=Ee[et]=Ee[it]=!1;var Se={};Se[N]=Se[U]=Se[ot]=Se[st]=Se[q]=Se[V]=Se[ut]=Se[lt]=Se[ct]=Se[ft]=Se[ht]=Se[Y]=Se[X]=Se[J]=Se[K]=Se[tt]=Se[et]=Se[nt]=Se[pt]=Se[dt]=Se[vt]=Se[gt]=!0,Se[H]=Se[W]=Se[it]=!1;var je={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Ae=parseInt,Ce="object"==typeof t&&t&&t.Object===Object&&t,Me="object"==typeof self&&self&&self.Object===Object&&self,Ie=Ce||Me||Function("return this")(),Re="object"==typeof n&&n&&!n.nodeType&&n,Le=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Be=Le&&Le.exports===Re,Fe=Be&&Ce.process,Pe=function(){try{var t=Le&&Le.require&&Le.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Oe=Pe&&Pe.isArrayBuffer,De=Pe&&Pe.isDate,Ne=Pe&&Pe.isMap,Ue=Pe&&Pe.isRegExp,ze=Pe&&Pe.isSet,qe=Pe&&Pe.isTypedArray;function Ve(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Ge(t,e,n,r){for(var i=-1,a=null==t?0:t.length;++i-1}function $e(t,e,n){for(var r=-1,i=null==t?0:t.length;++r-1;);return n}function yn(t,e){for(var n=t.length;n--&&on(e,t[n],0)>-1;);return n}var wn=fn({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),bn=fn({"&":"&","<":"<",">":">",'"':""","'":"'"});function xn(t){return"\\"+je[t]}function kn(t){return we.test(t)}function En(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function Sn(t,e){return function(n){return t(e(n))}}function jn(t,e){for(var n=-1,r=t.length,i=0,a=[];++n",""":'"',"'":"'"});var Rn=function t(e){var n,$t=(e=null==e?Ie:Rn.defaults(Ie.Object(),e,Rn.pick(Ie,xe))).Array,Jt=e.Date,Qt=e.Error,Kt=e.Function,te=e.Math,ee=e.Object,ne=e.RegExp,re=e.String,ie=e.TypeError,ae=$t.prototype,oe=Kt.prototype,se=ee.prototype,ue=e["__core-js_shared__"],le=oe.toString,ce=se.hasOwnProperty,fe=0,he=(n=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",pe=se.toString,de=le.call(ee),ve=Ie._,_e=ne("^"+le.call(ce).replace(Mt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),we=Be?e.Buffer:r,je=e.Symbol,Ce=e.Uint8Array,Me=we?we.allocUnsafe:r,Re=Sn(ee.getPrototypeOf,ee),Le=ee.create,Fe=se.propertyIsEnumerable,Pe=ae.splice,nn=je?je.isConcatSpreadable:r,fn=je?je.iterator:r,Ln=je?je.toStringTag:r,Bn=function(){try{var t=Da(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Fn=e.clearTimeout!==Ie.clearTimeout&&e.clearTimeout,Pn=Jt&&Jt.now!==Ie.Date.now&&Jt.now,On=e.setTimeout!==Ie.setTimeout&&e.setTimeout,Dn=te.ceil,Nn=te.floor,Un=ee.getOwnPropertySymbols,zn=we?we.isBuffer:r,qn=e.isFinite,Vn=ae.join,Gn=Sn(ee.keys,ee),Hn=te.max,Wn=te.min,Zn=Jt.now,Yn=e.parseInt,Xn=te.random,$n=ae.reverse,Jn=Da(e,"DataView"),Qn=Da(e,"Map"),Kn=Da(e,"Promise"),tr=Da(e,"Set"),er=Da(e,"WeakMap"),nr=Da(ee,"create"),rr=er&&new er,ir={},ar=co(Jn),or=co(Qn),sr=co(Kn),ur=co(tr),lr=co(er),cr=je?je.prototype:r,fr=cr?cr.valueOf:r,hr=cr?cr.toString:r;function pr(t){if(As(t)&&!ms(t)&&!(t instanceof mr)){if(t instanceof gr)return t;if(ce.call(t,"__wrapped__"))return fo(t)}return new gr(t)}var dr=function(){function t(){}return function(e){if(!Ts(e))return{};if(Le)return Le(e);t.prototype=e;var n=new t;return t.prototype=r,n}}();function vr(){}function gr(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}function mr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=F,this.__views__=[]}function _r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function Fr(t,e,n,i,a,o){var s,u=e&c,l=e&f,p=e&h;if(n&&(s=a?n(t,i,a,o):n(t)),s!==r)return s;if(!Ts(t))return t;var d=ms(t);if(d){if(s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&ce.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!u)return na(t,s)}else{var v=za(t),g=v==W||v==Z;if(bs(t))return $i(t,u);if(v==J||v==N||g&&!a){if(s=l||g?{}:Va(t),!u)return l?function(t,e){return ra(t,Ua(t),e)}(t,function(t,e){return t&&ra(e,au(e),t)}(s,t)):function(t,e){return ra(t,Na(t),e)}(t,Ir(s,t))}else{if(!Se[v])return a?t:{};s=function(t,e,n){var r,i,a,o=t.constructor;switch(e){case ot:return Ji(t);case q:case V:return new o(+t);case st:return function(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case ut:case lt:case ct:case ft:case ht:case pt:case dt:case vt:case gt:return Qi(t,n);case Y:return new o;case X:case et:return new o(t);case K:return(a=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,a;case tt:return new o;case nt:return r=t,fr?ee(fr.call(r)):{}}}(t,v,u)}}o||(o=new xr);var m=o.get(t);if(m)return m;if(o.set(t,s),Ls(t))return t.forEach(function(r){s.add(Fr(r,e,n,r,t,o))}),s;if(Cs(t))return t.forEach(function(r,i){s.set(i,Fr(r,e,n,i,t,o))}),s;var _=d?r:(p?l?Ia:Ma:l?au:iu)(t);return He(_||t,function(r,i){_&&(r=t[i=r]),Ar(s,i,Fr(r,e,n,i,t,o))}),s}function Pr(t,e,n){var i=n.length;if(null==t)return!i;for(t=ee(t);i--;){var a=n[i],o=e[a],s=t[a];if(s===r&&!(a in t)||!o(s))return!1}return!0}function Or(t,e,n){if("function"!=typeof t)throw new ie(o);return ro(function(){t.apply(r,n)},e)}function Dr(t,e,n,r){var a=-1,o=Xe,s=!0,u=t.length,l=[],c=e.length;if(!u)return l;n&&(e=Je(e,vn(n))),r?(o=$e,s=!1):e.length>=i&&(o=mn,s=!1,e=new br(e));t:for(;++a-1},yr.prototype.set=function(t,e){var n=this.__data__,r=Cr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},wr.prototype.clear=function(){this.size=0,this.__data__={hash:new _r,map:new(Qn||yr),string:new _r}},wr.prototype.delete=function(t){var e=Pa(this,t).delete(t);return this.size-=e?1:0,e},wr.prototype.get=function(t){return Pa(this,t).get(t)},wr.prototype.has=function(t){return Pa(this,t).has(t)},wr.prototype.set=function(t,e){var n=Pa(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},br.prototype.add=br.prototype.push=function(t){return this.__data__.set(t,s),this},br.prototype.has=function(t){return this.__data__.has(t)},xr.prototype.clear=function(){this.__data__=new yr,this.size=0},xr.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},xr.prototype.get=function(t){return this.__data__.get(t)},xr.prototype.has=function(t){return this.__data__.has(t)},xr.prototype.set=function(t,e){var n=this.__data__;if(n instanceof yr){var r=n.__data__;if(!Qn||r.length0&&n(s)?e>1?Gr(s,e-1,n,r,i):Qe(i,s):r||(i[i.length]=s)}return i}var Hr=sa(),Wr=sa(!0);function Zr(t,e){return t&&Hr(t,e,iu)}function Yr(t,e){return t&&Wr(t,e,iu)}function Xr(t,e){return Ye(e,function(e){return Es(t[e])})}function $r(t,e){for(var n=0,i=(e=Wi(e,t)).length;null!=t&&ne}function ti(t,e){return null!=t&&ce.call(t,e)}function ei(t,e){return null!=t&&e in ee(t)}function ni(t,e,n){for(var i=n?$e:Xe,a=t[0].length,o=t.length,s=o,u=$t(o),l=1/0,c=[];s--;){var f=t[s];s&&e&&(f=Je(f,vn(e))),l=Wn(f.length,l),u[s]=!n&&(e||a>=120&&f.length>=120)?new br(s&&f):r}f=t[0];var h=-1,p=u[0];t:for(;++h=s)return u;var l=n[r];return u*("desc"==l?-1:1)}}return t.index-e.index}(t,e,n)})}function _i(t,e,n){for(var r=-1,i=e.length,a={};++r-1;)s!==t&&Pe.call(s,u,1),Pe.call(t,u,1);return t}function wi(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==a){var a=i;Ha(i)?Pe.call(t,i,1):Di(t,i)}}return t}function bi(t,e){return t+Nn(Xn()*(e-t+1))}function xi(t,e){var n="";if(!t||e<1||e>R)return n;do{e%2&&(n+=t),(e=Nn(e/2))&&(t+=t)}while(e);return n}function ki(t,e){return io(Ka(t,e,Mu),t+"")}function Ei(t){return Er(pu(t))}function Si(t,e){var n=pu(t);return so(n,Br(e,0,n.length))}function ji(t,e,n,i){if(!Ts(t))return t;for(var a=-1,o=(e=Wi(e,t)).length,s=o-1,u=t;null!=u&&++ai?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var a=$t(i);++r>>1,o=t[a];null!==o&&!Fs(o)&&(n?o<=e:o=i){var c=e?null:xa(t);if(c)return Tn(c);s=!1,a=mn,l=new br}else l=e?[]:u;t:for(;++r=i?t:Mi(t,e,n)}var Xi=Fn||function(t){return Ie.clearTimeout(t)};function $i(t,e){if(e)return t.slice();var n=t.length,r=Me?Me(n):new t.constructor(n);return t.copy(r),r}function Ji(t){var e=new t.constructor(t.byteLength);return new Ce(e).set(new Ce(t)),e}function Qi(t,e){var n=e?Ji(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Ki(t,e){if(t!==e){var n=t!==r,i=null===t,a=t==t,o=Fs(t),s=e!==r,u=null===e,l=e==e,c=Fs(e);if(!u&&!c&&!o&&t>e||o&&s&&l&&!u&&!c||i&&s&&l||!n&&l||!a)return 1;if(!i&&!o&&!c&&t1?n[a-1]:r,s=a>2?n[2]:r;for(o=t.length>3&&"function"==typeof o?(a--,o):r,s&&Wa(n[0],n[1],s)&&(o=a<3?r:o,a=1),e=ee(e);++i-1?a[o?e[s]:s]:r}}function ha(t){return Ca(function(e){var n=e.length,i=n,a=gr.prototype.thru;for(t&&e.reverse();i--;){var s=e[i];if("function"!=typeof s)throw new ie(o);if(a&&!u&&"wrapper"==La(s))var u=new gr([],!0)}for(i=u?i:n;++i1&&_.reverse(),f&&lu))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var f=-1,h=!0,v=n&d?new br:r;for(o.set(t,e),o.set(e,t);++f-1&&t%1==0&&t1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Ft,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return He(D,function(n){var r="_."+n[0];e&n[1]&&!Xe(t,r)&&t.push(r)}),t.sort()}(function(t){var e=t.match(Pt);return e?e[1].split(Ot):[]}(r),n)))}function oo(t){var e=0,n=0;return function(){var i=Zn(),a=A-(i-n);if(n=i,a>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(r,arguments)}}function so(t,e){var n=-1,i=t.length,a=i-1;for(e=e===r?i:e;++n1?t[e-1]:r;return Ro(t,n="function"==typeof n?(t.pop(),n):r)});function No(t){var e=pr(t);return e.__chain__=!0,e}function Uo(t,e){return e(t)}var zo=Ca(function(t){var e=t.length,n=e?t[0]:0,i=this.__wrapped__,a=function(e){return Lr(e,t)};return!(e>1||this.__actions__.length)&&i instanceof mr&&Ha(n)?((i=i.slice(n,+n+(e?1:0))).__actions__.push({func:Uo,args:[a],thisArg:r}),new gr(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(r),t})):this.thru(a)});var qo=ia(function(t,e,n){ce.call(t,n)?++t[n]:Rr(t,n,1)});var Vo=fa(go),Go=fa(mo);function Ho(t,e){return(ms(t)?He:Nr)(t,Fa(e,3))}function Wo(t,e){return(ms(t)?We:Ur)(t,Fa(e,3))}var Zo=ia(function(t,e,n){ce.call(t,n)?t[n].push(e):Rr(t,n,[e])});var Yo=ki(function(t,e,n){var r=-1,i="function"==typeof e,a=ys(t)?$t(t.length):[];return Nr(t,function(t){a[++r]=i?Ve(e,t,n):ri(t,e,n)}),a}),Xo=ia(function(t,e,n){Rr(t,n,e)});function $o(t,e){return(ms(t)?Je:hi)(t,Fa(e,3))}var Jo=ia(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});var Qo=ki(function(t,e){if(null==t)return[];var n=e.length;return n>1&&Wa(t,e[0],e[1])?e=[]:n>2&&Wa(e[0],e[1],e[2])&&(e=[e[0]]),mi(t,Gr(e,1),[])}),Ko=Pn||function(){return Ie.Date.now()};function ts(t,e,n){return e=n?r:e,e=t&&null==e?t.length:e,Ea(t,x,r,r,r,r,e)}function es(t,e){var n;if("function"!=typeof e)throw new ie(o);return t=zs(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=r),n}}var ns=ki(function(t,e,n){var r=v;if(n.length){var i=jn(n,Ba(ns));r|=w}return Ea(t,r,e,n,i)}),rs=ki(function(t,e,n){var r=v|g;if(n.length){var i=jn(n,Ba(rs));r|=w}return Ea(e,r,t,n,i)});function is(t,e,n){var i,a,s,u,l,c,f=0,h=!1,p=!1,d=!0;if("function"!=typeof t)throw new ie(o);function v(e){var n=i,o=a;return i=a=r,f=e,u=t.apply(o,n)}function g(t){var n=t-c;return c===r||n>=e||n<0||p&&t-f>=s}function m(){var t=Ko();if(g(t))return _(t);l=ro(m,function(t){var n=e-(t-c);return p?Wn(n,s-(t-f)):n}(t))}function _(t){return l=r,d&&i?v(t):(i=a=r,u)}function y(){var t=Ko(),n=g(t);if(i=arguments,a=this,c=t,n){if(l===r)return function(t){return f=t,l=ro(m,e),h?v(t):u}(c);if(p)return l=ro(m,e),v(c)}return l===r&&(l=ro(m,e)),u}return e=Vs(e)||0,Ts(n)&&(h=!!n.leading,s=(p="maxWait"in n)?Hn(Vs(n.maxWait)||0,e):s,d="trailing"in n?!!n.trailing:d),y.cancel=function(){l!==r&&Xi(l),f=0,i=c=a=l=r},y.flush=function(){return l===r?u:_(Ko())},y}var as=ki(function(t,e){return Or(t,1,e)}),os=ki(function(t,e,n){return Or(t,Vs(e)||0,n)});function ss(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(o);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=t.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(ss.Cache||wr),n}function us(t){if("function"!=typeof t)throw new ie(o);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ss.Cache=wr;var ls=Zi(function(t,e){var n=(e=1==e.length&&ms(e[0])?Je(e[0],vn(Fa())):Je(Gr(e,1),vn(Fa()))).length;return ki(function(r){for(var i=-1,a=Wn(r.length,n);++i=e}),gs=ii(function(){return arguments}())?ii:function(t){return As(t)&&ce.call(t,"callee")&&!Fe.call(t,"callee")},ms=$t.isArray,_s=Oe?vn(Oe):function(t){return As(t)&&Qr(t)==ot};function ys(t){return null!=t&&js(t.length)&&!Es(t)}function ws(t){return As(t)&&ys(t)}var bs=zn||Vu,xs=De?vn(De):function(t){return As(t)&&Qr(t)==V};function ks(t){if(!As(t))return!1;var e=Qr(t);return e==H||e==G||"string"==typeof t.message&&"string"==typeof t.name&&!Is(t)}function Es(t){if(!Ts(t))return!1;var e=Qr(t);return e==W||e==Z||e==z||e==Q}function Ss(t){return"number"==typeof t&&t==zs(t)}function js(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ts(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function As(t){return null!=t&&"object"==typeof t}var Cs=Ne?vn(Ne):function(t){return As(t)&&za(t)==Y};function Ms(t){return"number"==typeof t||As(t)&&Qr(t)==X}function Is(t){if(!As(t)||Qr(t)!=J)return!1;var e=Re(t);if(null===e)return!0;var n=ce.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&le.call(n)==de}var Rs=Ue?vn(Ue):function(t){return As(t)&&Qr(t)==K};var Ls=ze?vn(ze):function(t){return As(t)&&za(t)==tt};function Bs(t){return"string"==typeof t||!ms(t)&&As(t)&&Qr(t)==et}function Fs(t){return"symbol"==typeof t||As(t)&&Qr(t)==nt}var Ps=qe?vn(qe):function(t){return As(t)&&js(t.length)&&!!Ee[Qr(t)]};var Os=ya(fi),Ds=ya(function(t,e){return t<=e});function Ns(t){if(!t)return[];if(ys(t))return Bs(t)?Mn(t):na(t);if(fn&&t[fn])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[fn]());var e=za(t);return(e==Y?En:e==tt?Tn:pu)(t)}function Us(t){return t?(t=Vs(t))===I||t===-I?(t<0?-1:1)*L:t==t?t:0:0===t?t:0}function zs(t){var e=Us(t),n=e%1;return e==e?n?e-n:e:0}function qs(t){return t?Br(zs(t),0,F):0}function Vs(t){if("number"==typeof t)return t;if(Fs(t))return B;if(Ts(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ts(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Rt,"");var n=Vt.test(t);return n||Ht.test(t)?Ae(t.slice(2),n?2:8):qt.test(t)?B:+t}function Gs(t){return ra(t,au(t))}function Hs(t){return null==t?"":Pi(t)}var Ws=aa(function(t,e){if($a(e)||ys(e))ra(e,iu(e),t);else for(var n in e)ce.call(e,n)&&Ar(t,n,e[n])}),Zs=aa(function(t,e){ra(e,au(e),t)}),Ys=aa(function(t,e,n,r){ra(e,au(e),t,r)}),Xs=aa(function(t,e,n,r){ra(e,iu(e),t,r)}),$s=Ca(Lr);var Js=ki(function(t,e){t=ee(t);var n=-1,i=e.length,a=i>2?e[2]:r;for(a&&Wa(e[0],e[1],a)&&(i=1);++n1),e}),ra(t,Ia(t),n),r&&(n=Fr(n,c|f|h,Ta));for(var i=e.length;i--;)Di(n,e[i]);return n});var lu=Ca(function(t,e){return null==t?{}:function(t,e){return _i(t,e,function(e,n){return tu(t,n)})}(t,e)});function cu(t,e){if(null==t)return{};var n=Je(Ia(t),function(t){return[t]});return e=Fa(e),_i(t,n,function(t,n){return e(t,n[0])})}var fu=ka(iu),hu=ka(au);function pu(t){return null==t?[]:gn(t,iu(t))}var du=la(function(t,e,n){return e=e.toLowerCase(),t+(n?vu(e):e)});function vu(t){return ku(Hs(t).toLowerCase())}function gu(t){return(t=Hs(t))&&t.replace(Zt,wn).replace(me,"")}var mu=la(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),_u=la(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),yu=ua("toLowerCase");var wu=la(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});var bu=la(function(t,e,n){return t+(n?" ":"")+ku(e)});var xu=la(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),ku=ua("toUpperCase");function Eu(t,e,n){return t=Hs(t),(e=n?r:e)===r?function(t){return be.test(t)}(t)?function(t){return t.match(ye)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(e)||[]}var Su=ki(function(t,e){try{return Ve(t,r,e)}catch(t){return ks(t)?t:new Qt(t)}}),ju=Ca(function(t,e){return He(e,function(e){e=lo(e),Rr(t,e,ns(t[e],t))}),t});function Tu(t){return function(){return t}}var Au=ha(),Cu=ha(!0);function Mu(t){return t}function Iu(t){return ui("function"==typeof t?t:Fr(t,c))}var Ru=ki(function(t,e){return function(n){return ri(n,t,e)}}),Lu=ki(function(t,e){return function(n){return ri(t,n,e)}});function Bu(t,e,n){var r=iu(e),i=Xr(e,r);null!=n||Ts(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=Xr(e,iu(e)));var a=!(Ts(n)&&"chain"in n&&!n.chain),o=Es(t);return He(i,function(n){var r=e[n];t[n]=r,o&&(t.prototype[n]=function(){var e=this.__chain__;if(a||e){var n=t(this.__wrapped__);return(n.__actions__=na(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Qe([this.value()],arguments))})}),t}function Fu(){}var Pu=ga(Je),Ou=ga(Ze),Du=ga(en);function Nu(t){return Za(t)?cn(lo(t)):function(t){return function(e){return $r(e,t)}}(t)}var Uu=_a(),zu=_a(!0);function qu(){return[]}function Vu(){return!1}var Gu=va(function(t,e){return t+e},0),Hu=ba("ceil"),Wu=va(function(t,e){return t/e},1),Zu=ba("floor");var Yu,Xu=va(function(t,e){return t*e},1),$u=ba("round"),Ju=va(function(t,e){return t-e},0);return pr.after=function(t,e){if("function"!=typeof e)throw new ie(o);return t=zs(t),function(){if(--t<1)return e.apply(this,arguments)}},pr.ary=ts,pr.assign=Ws,pr.assignIn=Zs,pr.assignInWith=Ys,pr.assignWith=Xs,pr.at=$s,pr.before=es,pr.bind=ns,pr.bindAll=ju,pr.bindKey=rs,pr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ms(t)?t:[t]},pr.chain=No,pr.chunk=function(t,e,n){e=(n?Wa(t,e,n):e===r)?1:Hn(zs(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var a=0,o=0,s=$t(Dn(i/e));aa?0:a+n),(i=i===r||i>a?a:zs(i))<0&&(i+=a),i=n>i?0:qs(i);n>>0)?(t=Hs(t))&&("string"==typeof e||null!=e&&!Rs(e))&&!(e=Pi(e))&&kn(t)?Yi(Mn(t),0,n):t.split(e,n):[]},pr.spread=function(t,e){if("function"!=typeof t)throw new ie(o);return e=null==e?0:Hn(zs(e),0),ki(function(n){var r=n[e],i=Yi(n,0,e);return r&&Qe(i,r),Ve(t,this,i)})},pr.tail=function(t){var e=null==t?0:t.length;return e?Mi(t,1,e):[]},pr.take=function(t,e,n){return t&&t.length?Mi(t,0,(e=n||e===r?1:zs(e))<0?0:e):[]},pr.takeRight=function(t,e,n){var i=null==t?0:t.length;return i?Mi(t,(e=i-(e=n||e===r?1:zs(e)))<0?0:e,i):[]},pr.takeRightWhile=function(t,e){return t&&t.length?Ui(t,Fa(e,3),!1,!0):[]},pr.takeWhile=function(t,e){return t&&t.length?Ui(t,Fa(e,3)):[]},pr.tap=function(t,e){return e(t),t},pr.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new ie(o);return Ts(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),is(t,e,{leading:r,maxWait:e,trailing:i})},pr.thru=Uo,pr.toArray=Ns,pr.toPairs=fu,pr.toPairsIn=hu,pr.toPath=function(t){return ms(t)?Je(t,lo):Fs(t)?[t]:na(uo(Hs(t)))},pr.toPlainObject=Gs,pr.transform=function(t,e,n){var r=ms(t),i=r||bs(t)||Ps(t);if(e=Fa(e,4),null==n){var a=t&&t.constructor;n=i?r?new a:[]:Ts(t)&&Es(a)?dr(Re(t)):{}}return(i?He:Zr)(t,function(t,r,i){return e(n,t,r,i)}),n},pr.unary=function(t){return ts(t,1)},pr.union=Ao,pr.unionBy=Co,pr.unionWith=Mo,pr.uniq=function(t){return t&&t.length?Oi(t):[]},pr.uniqBy=function(t,e){return t&&t.length?Oi(t,Fa(e,2)):[]},pr.uniqWith=function(t,e){return e="function"==typeof e?e:r,t&&t.length?Oi(t,r,e):[]},pr.unset=function(t,e){return null==t||Di(t,e)},pr.unzip=Io,pr.unzipWith=Ro,pr.update=function(t,e,n){return null==t?t:Ni(t,e,Hi(n))},pr.updateWith=function(t,e,n,i){return i="function"==typeof i?i:r,null==t?t:Ni(t,e,Hi(n),i)},pr.values=pu,pr.valuesIn=function(t){return null==t?[]:gn(t,au(t))},pr.without=Lo,pr.words=Eu,pr.wrap=function(t,e){return cs(Hi(e),t)},pr.xor=Bo,pr.xorBy=Fo,pr.xorWith=Po,pr.zip=Oo,pr.zipObject=function(t,e){return Vi(t||[],e||[],Ar)},pr.zipObjectDeep=function(t,e){return Vi(t||[],e||[],ji)},pr.zipWith=Do,pr.entries=fu,pr.entriesIn=hu,pr.extend=Zs,pr.extendWith=Ys,Bu(pr,pr),pr.add=Gu,pr.attempt=Su,pr.camelCase=du,pr.capitalize=vu,pr.ceil=Hu,pr.clamp=function(t,e,n){return n===r&&(n=e,e=r),n!==r&&(n=(n=Vs(n))==n?n:0),e!==r&&(e=(e=Vs(e))==e?e:0),Br(Vs(t),e,n)},pr.clone=function(t){return Fr(t,h)},pr.cloneDeep=function(t){return Fr(t,c|h)},pr.cloneDeepWith=function(t,e){return Fr(t,c|h,e="function"==typeof e?e:r)},pr.cloneWith=function(t,e){return Fr(t,h,e="function"==typeof e?e:r)},pr.conformsTo=function(t,e){return null==e||Pr(t,e,iu(e))},pr.deburr=gu,pr.defaultTo=function(t,e){return null==t||t!=t?e:t},pr.divide=Wu,pr.endsWith=function(t,e,n){t=Hs(t),e=Pi(e);var i=t.length,a=n=n===r?i:Br(zs(n),0,i);return(n-=e.length)>=0&&t.slice(n,a)==e},pr.eq=ps,pr.escape=function(t){return(t=Hs(t))&&kt.test(t)?t.replace(bt,bn):t},pr.escapeRegExp=function(t){return(t=Hs(t))&&It.test(t)?t.replace(Mt,"\\$&"):t},pr.every=function(t,e,n){var i=ms(t)?Ze:zr;return n&&Wa(t,e,n)&&(e=r),i(t,Fa(e,3))},pr.find=Vo,pr.findIndex=go,pr.findKey=function(t,e){return rn(t,Fa(e,3),Zr)},pr.findLast=Go,pr.findLastIndex=mo,pr.findLastKey=function(t,e){return rn(t,Fa(e,3),Yr)},pr.floor=Zu,pr.forEach=Ho,pr.forEachRight=Wo,pr.forIn=function(t,e){return null==t?t:Hr(t,Fa(e,3),au)},pr.forInRight=function(t,e){return null==t?t:Wr(t,Fa(e,3),au)},pr.forOwn=function(t,e){return t&&Zr(t,Fa(e,3))},pr.forOwnRight=function(t,e){return t&&Yr(t,Fa(e,3))},pr.get=Ks,pr.gt=ds,pr.gte=vs,pr.has=function(t,e){return null!=t&&qa(t,e,ti)},pr.hasIn=tu,pr.head=yo,pr.identity=Mu,pr.includes=function(t,e,n,r){t=ys(t)?t:pu(t),n=n&&!r?zs(n):0;var i=t.length;return n<0&&(n=Hn(i+n,0)),Bs(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&on(t,e,n)>-1},pr.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:zs(n);return i<0&&(i=Hn(r+i,0)),on(t,e,i)},pr.inRange=function(t,e,n){return e=Us(e),n===r?(n=e,e=0):n=Us(n),function(t,e,n){return t>=Wn(e,n)&&t=-R&&t<=R},pr.isSet=Ls,pr.isString=Bs,pr.isSymbol=Fs,pr.isTypedArray=Ps,pr.isUndefined=function(t){return t===r},pr.isWeakMap=function(t){return As(t)&&za(t)==it},pr.isWeakSet=function(t){return As(t)&&Qr(t)==at},pr.join=function(t,e){return null==t?"":Vn.call(t,e)},pr.kebabCase=mu,pr.last=ko,pr.lastIndexOf=function(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var a=i;return n!==r&&(a=(a=zs(n))<0?Hn(i+a,0):Wn(a,i-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,a):an(t,un,a,!0)},pr.lowerCase=_u,pr.lowerFirst=yu,pr.lt=Os,pr.lte=Ds,pr.max=function(t){return t&&t.length?qr(t,Mu,Kr):r},pr.maxBy=function(t,e){return t&&t.length?qr(t,Fa(e,2),Kr):r},pr.mean=function(t){return ln(t,Mu)},pr.meanBy=function(t,e){return ln(t,Fa(e,2))},pr.min=function(t){return t&&t.length?qr(t,Mu,fi):r},pr.minBy=function(t,e){return t&&t.length?qr(t,Fa(e,2),fi):r},pr.stubArray=qu,pr.stubFalse=Vu,pr.stubObject=function(){return{}},pr.stubString=function(){return""},pr.stubTrue=function(){return!0},pr.multiply=Xu,pr.nth=function(t,e){return t&&t.length?gi(t,zs(e)):r},pr.noConflict=function(){return Ie._===this&&(Ie._=ve),this},pr.noop=Fu,pr.now=Ko,pr.pad=function(t,e,n){t=Hs(t);var r=(e=zs(e))?Cn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return ma(Nn(i),n)+t+ma(Dn(i),n)},pr.padEnd=function(t,e,n){t=Hs(t);var r=(e=zs(e))?Cn(t):0;return e&&re){var i=t;t=e,e=i}if(n||t%1||e%1){var a=Xn();return Wn(t+a*(e-t+Te("1e-"+((a+"").length-1))),e)}return bi(t,e)},pr.reduce=function(t,e,n){var r=ms(t)?Ke:hn,i=arguments.length<3;return r(t,Fa(e,4),n,i,Nr)},pr.reduceRight=function(t,e,n){var r=ms(t)?tn:hn,i=arguments.length<3;return r(t,Fa(e,4),n,i,Ur)},pr.repeat=function(t,e,n){return e=(n?Wa(t,e,n):e===r)?1:zs(e),xi(Hs(t),e)},pr.replace=function(){var t=arguments,e=Hs(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pr.result=function(t,e,n){var i=-1,a=(e=Wi(e,t)).length;for(a||(a=1,t=r);++iR)return[];var n=F,r=Wn(t,F);e=Fa(e),t-=F;for(var i=dn(r,e);++n=o)return t;var u=n-Cn(i);if(u<1)return i;var l=s?Yi(s,0,u).join(""):t.slice(0,u);if(a===r)return l+i;if(s&&(u+=l.length-u),Rs(a)){if(t.slice(u).search(a)){var c,f=l;for(a.global||(a=ne(a.source,Hs(zt.exec(a))+"g")),a.lastIndex=0;c=a.exec(f);)var h=c.index;l=l.slice(0,h===r?u:h)}}else if(t.indexOf(Pi(a),u)!=u){var p=l.lastIndexOf(a);p>-1&&(l=l.slice(0,p))}return l+i},pr.unescape=function(t){return(t=Hs(t))&&xt.test(t)?t.replace(wt,In):t},pr.uniqueId=function(t){var e=++fe;return Hs(t)+e},pr.upperCase=xu,pr.upperFirst=ku,pr.each=Ho,pr.eachRight=Wo,pr.first=yo,Bu(pr,(Yu={},Zr(pr,function(t,e){ce.call(pr.prototype,e)||(Yu[e]=t)}),Yu),{chain:!1}),pr.VERSION="4.17.11",He(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pr[t].placeholder=pr}),He(["drop","take"],function(t,e){mr.prototype[t]=function(n){n=n===r?1:Hn(zs(n),0);var i=this.__filtered__&&!e?new mr(this):this.clone();return i.__filtered__?i.__takeCount__=Wn(n,i.__takeCount__):i.__views__.push({size:Wn(n,F),type:t+(i.__dir__<0?"Right":"")}),i},mr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),He(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==C||3==n;mr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Fa(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),He(["head","last"],function(t,e){var n="take"+(e?"Right":"");mr.prototype[t]=function(){return this[n](1).value()[0]}}),He(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");mr.prototype[t]=function(){return this.__filtered__?new mr(this):this[n](1)}}),mr.prototype.compact=function(){return this.filter(Mu)},mr.prototype.find=function(t){return this.filter(t).head()},mr.prototype.findLast=function(t){return this.reverse().find(t)},mr.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new mr(this):this.map(function(n){return ri(n,t,e)})}),mr.prototype.reject=function(t){return this.filter(us(Fa(t)))},mr.prototype.slice=function(t,e){t=zs(t);var n=this;return n.__filtered__&&(t>0||e<0)?new mr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==r&&(n=(e=zs(e))<0?n.dropRight(-e):n.take(e-t)),n)},mr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},mr.prototype.toArray=function(){return this.take(F)},Zr(mr.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),a=pr[i?"take"+("last"==e?"Right":""):e],o=i||/^find/.test(e);a&&(pr.prototype[e]=function(){var e=this.__wrapped__,s=i?[1]:arguments,u=e instanceof mr,l=s[0],c=u||ms(e),f=function(t){var e=a.apply(pr,Qe([t],s));return i&&h?e[0]:e};c&&n&&"function"==typeof l&&1!=l.length&&(u=c=!1);var h=this.__chain__,p=!!this.__actions__.length,d=o&&!h,v=u&&!p;if(!o&&c){e=v?e:new mr(this);var g=t.apply(e,s);return g.__actions__.push({func:Uo,args:[f],thisArg:r}),new gr(g,h)}return d&&v?t.apply(this,s):(g=this.thru(f),d?i?g.value()[0]:g.value():g)})}),He(["pop","push","shift","sort","splice","unshift"],function(t){var e=ae[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);pr.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(ms(i)?i:[],t)}return this[n](function(n){return e.apply(ms(n)?n:[],t)})}}),Zr(mr.prototype,function(t,e){var n=pr[e];if(n){var r=n.name+"";(ir[r]||(ir[r]=[])).push({name:e,func:n})}}),ir[pa(r,g).name]=[{name:"wrapper",func:r}],mr.prototype.clone=function(){var t=new mr(this.__wrapped__);return t.__actions__=na(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=na(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=na(this.__views__),t},mr.prototype.reverse=function(){if(this.__filtered__){var t=new mr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},mr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=ms(t),r=e<0,i=n?t.length:0,a=function(t,e,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:t,value:t?r:this.__values__[this.__index__++]}},pr.prototype.plant=function(t){for(var e,n=this;n instanceof vr;){var i=fo(n);i.__index__=0,i.__values__=r,e?a.__wrapped__=i:e=i;var a=i;n=n.__wrapped__}return a.__wrapped__=t,e},pr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof mr){var e=t;return this.__actions__.length&&(e=new mr(this)),(e=e.reverse()).__actions__.push({func:Uo,args:[To],thisArg:r}),new gr(e,this.__chain__)}return this.thru(To)},pr.prototype.toJSON=pr.prototype.valueOf=pr.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pr.prototype.first=pr.prototype.head,fn&&(pr.prototype[fn]=function(){return this}),pr}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Ie._=Rn,define(function(){return Rn})):Le?((Le.exports=Rn)._=Rn,Re._=Rn):Ie._=Rn}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],76:[function(t,e,n){(function(n){t("path");var r=t("fs");function i(){this.types=Object.create(null),this.extensions=Object.create(null)}i.prototype.define=function(t){for(var e in t){for(var r=t[e],i=0;i=0;--s)if(h[s]=f,f*=l[s],p=Math.max(p,o.scratchMemory(l[s])),e.shape[s]!==n.shape[s])throw new Error("Shape mismatch, real and imaginary arrays must have same size");var d,v=4*f+p;d="array"===e.dtype||"float64"===e.dtype||"custom"===e.dtype?a.mallocDouble(v):a.mallocFloat(v);var g,m,_,y,w=i(d,l.slice(0),h,0),b=i(d,l.slice(0),h.slice(0),f),x=i(d,l.slice(0),h.slice(0),2*f),k=i(d,l.slice(0),h.slice(0),3*f),E=4*f;for(r.assign(w,e),r.assign(b,n),s=c-1;s>=0&&(o(t,f/l[s],l[s],d,w.offset,b.offset,E),0!==s);--s){for(m=1,_=x.stride,y=k.stride,u=s-1;u=0;--u)y[u]=_[u]=m,m*=l[u];r.assign(x,w),r.assign(k,b),g=w,w=x,x=g,g=b,b=k,k=g}r.assign(e,w),r.assign(n,b),a.free(d)}},{"./lib/fft-matrix.js":79,ndarray:84,"ndarray-ops":81,"typedarray-pool":144}],79:[function(t,e,n){var r=t("bit-twiddle");function i(t,e,n,i,a,o){var s,u,l,c,f,h,p,d,v,g,m,_,y,w,b,x,k,E,S,j,T,A,C,M;for(t|=0,e|=0,a|=0,o|=0,s=n|=0,u=r.log2(s),E=0;E>1,f=0,l=0;l>=1;f+=h}for(m=-1,_=0,g=1,d=0;d>",rrshift:">>>"};!function(){for(var t in s){var e=s[t];n[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),n[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a"+e+"=b"},rvalue:!0,funcName:t+"eq"}),n[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),n[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a"+e+"=s"},rvalue:!0,funcName:t+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var t in u){var e=u[t];n[t]=o({args:["array","array"],body:{args:["a","b"],body:"a="+e+"b"},funcName:t}),n[t+"eq"]=o({args:["array"],body:{args:["a"],body:"a="+e+"a"},rvalue:!0,count:2,funcName:t+"eq"})}}();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var t in l){var e=l[t];n[t]=o({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+e+"c"},funcName:t}),n[t+"s"]=o({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+e+"s"},funcName:t+"s"}),n[t+"eq"]=o({args:["array","array"],body:{args:["a","b"],body:"a=a"+e+"b"},rvalue:!0,count:2,funcName:t+"eq"}),n[t+"seq"]=o({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+e+"s"},rvalue:!0,count:2,funcName:t+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var t=0;tthis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),n.norm1=r({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),n.sup=r({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),n.inf=r({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),n.random=o({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),n.assign=o({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),n.assigns=o({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),n.equals=r({args:["array","array"],pre:i,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":16}],82:[function(t,e,n){"use strict";var r=t("ndarray"),i=t("./doConvert.js");e.exports=function(t,e){for(var n=[],a=t,o=1;Array.isArray(a);)n.push(a.length),o*=a.length,a=a[0];return 0===n.length?r():(e||(e=r(new Float64Array(o),n)),i(e,t),e)}},{"./doConvert.js":83,ndarray:84}],83:[function(t,e,n){e.exports=t("cwise-compiler")({args:["array","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\nvar _inline_1_v=_inline_1_arg1_,_inline_1_i\nfor(_inline_1_i=0;_inline_1_i<_inline_1_arg2_.length-1;++_inline_1_i) {\n_inline_1_v=_inline_1_v[_inline_1_arg2_[_inline_1_i]]\n}\n_inline_1_arg0_=_inline_1_v[_inline_1_arg2_[_inline_1_arg2_.length-1]]\n}",args:[{name:"_inline_1_arg0_",lvalue:!0,rvalue:!1,count:1},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:1},{name:"_inline_1_arg2_",lvalue:!1,rvalue:!0,count:4}],thisVars:[],localVars:["_inline_1_i","_inline_1_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},funcName:"convert",blockSize:64})},{"cwise-compiler":16}],84:[function(t,e,n){var r=t("iota-array"),i=t("is-buffer"),a="undefined"!=typeof Float64Array;function o(t,e){return t[0]-e[0]}function s(){var t,e=this.stride,n=new Array(e.length);for(t=0;tMath.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===e&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+n+"_set("+u.join(",")+",v){"),i?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+n+"_get("+u.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+n+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+n+"_hi("+u.join(",")+"){return new "+n+"(this.data,"+o.map(function(t){return["(typeof i",t,"!=='number'||i",t,"<0)?this.shape[",t,"]:i",t,"|0"].join("")}).join(",")+","+o.map(function(t){return"this.stride["+t+"]"}).join(",")+",this.offset)}");var p=o.map(function(t){return"a"+t+"=this.shape["+t+"]"}),d=o.map(function(t){return"c"+t+"=this.stride["+t+"]"});a.push("proto.lo=function "+n+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+p.join(",")+","+d.join(","));for(var v=0;v=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+n+"(this.data,"+o.map(function(t){return"a"+t}).join(",")+","+o.map(function(t){return"c"+t}).join(",")+",b)}"),a.push("proto.step=function "+n+"_step("+u.join(",")+"){var "+o.map(function(t){return"a"+t+"=this.shape["+t+"]"}).join(",")+","+o.map(function(t){return"b"+t+"=this.stride["+t+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(v=0;v=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+o.map(function(t){return"shape["+t+"]"}).join(",")+","+o.map(function(t){return"stride["+t+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(l[t],s)}var l={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};e.exports=function(t,e,n,r){if(void 0===t)return(0,l.array[0])([]);"number"==typeof t&&(t=[t]),void 0===e&&(e=[t.length]);var o=e.length;if(void 0===n){n=new Array(o);for(var s=o-1,c=1;s>=0;--s)n[s]=c,c*=e[s]}if(void 0===r)for(r=0,s=0;s>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1}},{}],86:[function(t,e,n){(function(n,r){"use strict";var i=t("util"),a=t("stream"),o=e.exports=function(){a.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};i.inherits(o,a),o.prototype.read=function(t,e){this._reads.push({length:Math.abs(t),allowLess:t<0,func:e}),n.nextTick(function(){this._process(),this._paused&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(t,e){return this.writable?(r.isBuffer(t)||(t=new r(t,e||this._encoding)),this._buffers.push(t),this._buffered+=t.length,this._process(),this._reads&&0==this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",new Error("Stream not writable")),!1)},o.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0==this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("There are some read requests waitng on finished stream")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._process=function(){for(;this._buffered>0&&this._reads&&this._reads.length>0;){var t=this._reads[0];if(t.allowLess){this._reads.shift(),(a=this._buffers[0]).length>t.length?(this._buffered-=t.length,this._buffers[0]=a.slice(t.length),t.func.call(this,a.slice(0,t.length))):(this._buffered-=a.length,this._buffers.shift(),t.func.call(this,a))}else{if(!(this._buffered>=t.length))break;this._reads.shift();for(var e=0,n=0,i=new r(t.length);e0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,i)}}this._buffers&&this._buffers.length>0&&null==this._buffers[0]&&this._end()}}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,buffer:5,stream:139,util:150}],87:[function(t,e,n){"use strict";e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLOR_PALETTE:1,COLOR_COLOR:2,COLOR_ALPHA:4}},{}],88:[function(t,e,n){"use strict";var r=t("util"),i=t("stream"),a=e.exports=function(){i.call(this),this._crc=-1,this.writable=!0};r.inherits(a,i),a.prototype.write=function(t){for(var e=0;e>>8;return!0},a.prototype.end=function(t){t&&this.write(t),this.emit("crc",this.crc32())},a.prototype.crc32=function(){return-1^this._crc},a.crc32=function(t){for(var e=-1,n=0;n>>8;return-1^e};for(var o=[],s=0;s<256;s++){for(var u=s,l=0;l<8;l++)1&u?u=3988292384^u>>>1:u>>>=1;o[s]=u}},{stream:139,util:150}],89:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=(t("zlib"),t("./chunkstream")),a=e.exports=function(t,e,n,r,a){i.call(this),this._width=t,this._height=e,this._Bpp=n,this._data=r,this._options=a,this._line=0,"filterType"in a&&-1!=a.filterType?"number"==typeof a.filterType&&(a.filterType=[a.filterType]):a.filterType=[0,1,2,3,4],this._filters={0:this._filterNone.bind(this),1:this._filterSub.bind(this),2:this._filterUp.bind(this),3:this._filterAvg.bind(this),4:this._filterPaeth.bind(this)},this.read(this._width*n+1,this._reverseFilterLine.bind(this))};r.inherits(a,i);var o={1:{0:0,1:0,2:0,3:255},2:{0:0,1:0,2:0,3:1},3:{0:0,1:1,2:2,3:255},4:{0:0,1:1,2:2,3:3}};a.prototype._reverseFilterLine=function(t){var e=this._data,n=this._width<<2,r=this._line*n,i=t[0];if(0==i)for(var a=0;a0?e[u+c-4]:0;e[u+c]=255!=f?t[l+f]+h:255}else if(2==i)for(a=0;a0?e[u-n+c]:0;e[u+c]=255!=f?t[l+f]+p:255}else if(3==i)for(a=0;a0?e[u+c-4]:0,p=this._line>0?e[u-n+c]:0;var d=Math.floor((h+p)/2);e[u+c]=255!=f?t[l+f]+d:255}else if(4==i)for(a=0;a0?e[u+c-4]:0,p=this._line>0?e[u-n+c]:0;var v=a>0&&this._line>0?e[u-n+c-4]:0;d=s(h,p,v);e[u+c]=255!=f?t[l+f]+d:255}this._line++,this._line=4?t[e*r+o-4]:0,u=t[e*r+o]-s;n?n[e*i+1+o]=u:a+=Math.abs(u)}return a},a.prototype._filterUp=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=2);for(var o=0;o0?t[(e-1)*r+o]:0,u=t[e*r+o]-s;n?n[e*i+1+o]=u:a+=Math.abs(u)}return a},a.prototype._filterAvg=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=3);for(var o=0;o=4?t[e*r+o-4]:0,u=e>0?t[(e-1)*r+o]:0,l=t[e*r+o]-(s+u>>1);n?n[e*i+1+o]=l:a+=Math.abs(l)}return a},a.prototype._filterPaeth=function(t,e,n){var r=this._width<<2,i=r+1,a=0;n&&(n[e*i]=4);for(var o=0;o=4?t[e*r+o-4]:0,l=e>0?t[(e-1)*r+o]:0,c=o>=4&&e>0?t[(e-1)*r+o-4]:0,f=t[e*r+o]-s(u,l,c);n?n[e*i+1+o]=f:a+=Math.abs(f)}return a};var s=function(t,e,n){var r=t+e-n,i=Math.abs(r-t),a=Math.abs(r-e),o=Math.abs(r-n);return i<=a&&i<=o?t:a<=o?e:n}}).call(this,t("buffer").Buffer)},{"./chunkstream":86,buffer:5,util:150,zlib:46}],90:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("stream"),a=t("zlib"),o=t("./filter"),s=t("./crc"),u=t("./constants"),l=e.exports=function(t){i.call(this),this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=t.deflateLevel||9,t.deflateStrategy=t.deflateStrategy||3,this.readable=!0};r.inherits(l,i),l.prototype.pack=function(t,e,r){this.emit("data",new n(u.PNG_SIGNATURE)),this.emit("data",this._packIHDR(e,r));t=new o(e,r,4,t,this._options).filter();var i=a.createDeflate({chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy});i.on("error",this.emit.bind(this,"error")),i.on("data",function(t){this.emit("data",this._packIDAT(t))}.bind(this)),i.on("end",function(){this.emit("data",this._packIEND()),this.emit("end")}.bind(this)),i.end(t)},l.prototype._packChunk=function(t,e){var r=e?e.length:0,i=new n(r+12);return i.writeUInt32BE(r,0),i.writeUInt32BE(t,4),e&&e.copy(i,8),i.writeInt32BE(s.crc32(i.slice(4,i.length-4)),i.length-4),i},l.prototype._packIHDR=function(t,e){var r=new n(13);return r.writeUInt32BE(t,0),r.writeUInt32BE(e,4),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0,this._packChunk(u.TYPE_IHDR,r)},l.prototype._packIDAT=function(t){return this._packChunk(u.TYPE_IDAT,t)},l.prototype._packIEND=function(){return this._packChunk(u.TYPE_IEND,null)}}).call(this,t("buffer").Buffer)},{"./constants":87,"./crc":88,"./filter":89,buffer:5,stream:139,util:150,zlib:46}],91:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("zlib"),a=t("./crc"),o=t("./chunkstream"),s=t("./constants"),u=t("./filter"),l=e.exports=function(t){o.call(this),this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._inflate=null,this._filter=null,this._crc=null,this._palette=[],this._colorType=0,this._chunks={},this._chunks[s.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[s.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[s.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[s.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[s.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[s.TYPE_gAMA]=this._handleGAMA.bind(this),this.writable=!0,this.on("error",this._handleError.bind(this)),this._handleSignature()};r.inherits(l,o),l.prototype._handleError=function(){this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy()},l.prototype._handleSignature=function(){this.read(s.PNG_SIGNATURE.length,this._parseSignature.bind(this))},l.prototype._parseSignature=function(t){for(var e=s.PNG_SIGNATURE,n=0;nthis._palette.length)return void this.emit("error",new Error("More transparent colors than palette size"));for(var e=0;e0?this._handleIDAT(t):this._handleChunkEnd()},l.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},l.prototype._parseIEND=function(t){this._crc.write(t),this._inflate.end(),this._hasIEND=!0,this._handleChunkEnd()};var c={0:1,2:3,3:1,4:2,6:4};l.prototype._reverseFiltered=function(t,e,n){if(3==this._colorType)for(var r=e<<2,i=0;i0&&this.height>0?new r(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(t||{}),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new s(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};i.inherits(u,a),u.prototype.pack=function(){return e.nextTick(function(){this._packer.pack(this.data,this.width,this.height)}.bind(this)),this},u.prototype.parse=function(t,e){if(e){var n,r=null;this.once("parsed",n=function(t){this.removeListener("error",r),this.data=t,e(null,this)}.bind(this)),this.once("error",r=function(t){this.removeListener("parsed",n),e(t,null)}.bind(this))}return this.end(t),this},u.prototype.write=function(t){return this._parser.write(t),!0},u.prototype.end=function(t){this._parser.end(t)},u.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.data=t.data,delete t.data,this.emit("metadata",t)},u.prototype._gamma=function(t){this.gamma=t},u.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},u.prototype.bitblt=function(t,e,n,r,i,a,o){if(e>this.width||n>this.height||e+r>this.width||n+i>this.height)throw new Error("bitblt reading outside image");if(a>t.width||o>t.height||a+r>t.width||o+i>t.height)throw new Error("bitblt writing outside image");for(var s=0;s>=u,c-=u,g!==a){if(g===o)break;for(var m=ga;)y=d[y]>>8,++_;var w=y;if(h+_+(m!==g?1:0)>r)return void console.log("Warning, gif stream longer than expected.");n[h++]=w;var b=h+=_;for(m!==g&&(n[h++]=w),y=m;_--;)y=d[y],n[--b]=255&y,y>>=8;null!==v&&s<4096&&(d[s++]=v<<8|w,s>=l+1&&u<12&&(++u,l=l<<1|1)),v=g}else s=o+1,l=(1<<(u=i+1))-1,v=null}return h!==r&&console.log("Warning, gif stream shorter than expected."),n}try{n.GifWriter=function(t,e,n,r){var i=0,a=void 0===(r=void 0===r?{}:r).loop?null:r.loop,o=void 0===r.palette?null:r.palette;if(e<=0||n<=0||e>65535||n>65535)throw new Error("Width/Height invalid.");function s(t){var e=t.length;if(e<2||e>256||e&e-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return e}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;var u=0,l=0;if(null!==o){for(var c=s(o);c>>=1;)++u;if(c=1<=c)throw new Error("Background index out of range.");if(0===l)throw new Error("Background index explicitly passed as 0.")}}if(t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&n,t[i++]=n>>8&255,t[i++]=(null!==o?128:0)|u,t[i++]=l,t[i++]=0,null!==o)for(var f=0,h=o.length;f>16&255,t[i++]=p>>8&255,t[i++]=255&p}if(null!==a){if(a<0||a>65535)throw new Error("Loop count invalid.");t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=255&a,t[i++]=a>>8&255,t[i++]=0}var d=!1;this.addFrame=function(e,n,r,a,u,l){if(!0===d&&(--i,d=!1),l=void 0===l?{}:l,e<0||n<0||e>65535||n>65535)throw new Error("x/y invalid.");if(r<=0||a<=0||r>65535||a>65535)throw new Error("Width/Height invalid.");if(u.length>=1;)++p;h=1<3)throw new Error("Disposal out of range.");var m=!1,_=0;if(void 0!==l.transparent&&null!==l.transparent&&(m=!0,(_=l.transparent)<0||_>=h))throw new Error("Transparent color index.");if((0!==g||m||0!==v)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=g<<2|(!0===m?1:0),t[i++]=255&v,t[i++]=v>>8&255,t[i++]=_,t[i++]=0),t[i++]=44,t[i++]=255&e,t[i++]=e>>8&255,t[i++]=255&n,t[i++]=n>>8&255,t[i++]=255&r,t[i++]=r>>8&255,t[i++]=255&a,t[i++]=a>>8&255,t[i++]=!0===c?128|p-1:0,!0===c)for(var y=0,w=f.length;y>16&255,t[i++]=b>>8&255,t[i++]=255&b}return i=function(t,e,n,r){t[e++]=n;var i=e++,a=1<=n;)t[e++]=255&f,f>>=8,c-=8,e===i+256&&(t[i]=255,i=e++)}function p(t){f|=t<=8;)t[e++]=255&f,f>>=8,c-=8,e===i+256&&(t[i]=255,i=e++);4096===u?(p(a),u=s+1,l=n+1,v={}):(u>=1<>7,s=1<<1+(7&a);t[e++],t[e++];var u=null,l=null;o&&(u=e,l=s,e+=3*s);var c=!0,f=[],h=0,p=null,d=0,v=null;for(this.width=n,this.height=i;c&&e=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;case 249:if(4!==t[e++]||0!==t[e+4])throw new Error("Invalid graphics extension block.");var g=t[e++];h=t[e++]|t[e++]<<8,p=t[e++],0==(1&g)&&(p=null),d=g>>2&7,e++;break;case 254:for(;;){if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}break;default:throw new Error("Unknown graphic control label: 0x"+t[e-1].toString(16))}break;case 44:var m=t[e++]|t[e++]<<8,_=t[e++]|t[e++]<<8,y=t[e++]|t[e++]<<8,w=t[e++]|t[e++]<<8,b=t[e++],x=b>>6&1,k=1<<1+(7&b),E=u,S=l,j=!1;b>>7&&(j=!0,E=e,S=k,e+=3*k);var T=e;for(e++;;){var A;if(!((A=t[e++])>=0))throw Error("Invalid block size");if(0===A)break;e+=A}f.push({x:m,y:_,width:y,height:w,has_local_palette:j,palette_offset:E,palette_size:S,data_offset:T,data_length:e-T,transparent_index:p,interlaced:!!x,delay:h,disposal:d});break;case 59:c=!1;break;default:throw new Error("Unknown gif block: 0x"+t[e-1].toString(16))}this.numFrames=function(){return f.length},this.loopCount=function(){return v},this.frameInfo=function(t){if(t<0||t>=f.length)throw new Error("Frame index out of range.");return f[t]},this.decodeAndBlitFrameBGRA=function(e,i){var a=this.frameInfo(e),o=a.width*a.height,s=new Uint8Array(o);r(t,a.data_offset,s,o);var u=a.palette_offset,l=a.transparent_index;null===l&&(l=256);var c=a.width,f=n-c,h=c,p=4*(a.y*n+a.x),d=4*((a.y+a.height)*n+a.x),v=p,g=4*f;!0===a.interlaced&&(g+=4*n*7);for(var m=8,_=0,y=s.length;_=d&&(g=4*f+4*n*(m-1),v=p+(c+f)*(m<<1),m>>=1)),w===l)v+=4;else{var b=t[u+3*w],x=t[u+3*w+1],k=t[u+3*w+2];i[v++]=k,i[v++]=x,i[v++]=b,i[v++]=255}--h}},this.decodeAndBlitFrameRGBA=function(e,i){var a=this.frameInfo(e),o=a.width*a.height,s=new Uint8Array(o);r(t,a.data_offset,s,o);var u=a.palette_offset,l=a.transparent_index;null===l&&(l=256);var c=a.width,f=n-c,h=c,p=4*(a.y*n+a.x),d=4*((a.y+a.height)*n+a.x),v=p,g=4*f;!0===a.interlaced&&(g+=4*n*7);for(var m=8,_=0,y=s.length;_=d&&(g=4*f+4*n*(m-1),v=p+(c+f)*(m<<1),m>>=1)),w===l)v+=4;else{var b=t[u+3*w],x=t[u+3*w+1],k=t[u+3*w+2];i[v++]=b,i[v++]=x,i[v++]=k,i[v++]=255}--h}}}}catch(t){}},{}],94:[function(t,e,n){(function(n){var r=t("charm");function i(t){if(!(t=t||{}).total)throw new Error("You MUST specify the total number of operations that will be processed.");this.total=t.total,this.current=0,this.max_burden=t.maxBurden||.5,this.show_burden=t.showBurden||!1,this.started=!1,this.size=50,this.inner_time=0,this.outer_time=0,this.elapsed=0,this.time_start=0,this.time_end=0,this.time_left=0,this.time_burden=0,this.skip_steps=0,this.skipped=0,this.aborted=!1,this.charm=r(),this.charm.pipe(n.stdout),this.charm.write("\n\n\n")}function a(t,e,n){for(n=n||" ";t.length3&&(u[0]=u[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(u[1]||"").length=this.total&&this.finished(),this.time_end=(new Date).getTime(),this.inner_time=this.time_end-this.time_start)},i.prototype.updateTimes=function(){this.elapsed=this.time_start-this.started,this.time_end>0&&(this.outer_time=this.time_start-this.time_end),this.inner_time>0&&this.outer_time>0&&(this.time_burden=this.inner_time/(this.inner_time+this.outer_time)*100,this.time_left=this.elapsed/this.current*(this.total-this.current),this.time_left<0&&(this.time_left=0)),this.time_burden>this.max_burden&&this.skip_steps0&&this.current=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function r(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r=-1&&!i;a--){var o=a>=0?arguments[a]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(n=o+"/"+n,i="/"===o.charAt(0))}return n=e(r(n.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(t){var a=n.isAbsolute(t),o="/"===i(t,-1);return(t=e(r(t.split("/"),function(t){return!!t}),!a).join("/"))||a||(t="."),t&&o&&(t+="/"),(a?"/":"")+t},n.isAbsolute=function(t){return"/"===t.charAt(0)},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(r(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},n.relative=function(t,e){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),a=r(e.split("/")),o=Math.min(i.length,a.length),s=o,u=0;u=1;--a)if(47===(e=t.charCodeAt(a))){if(!i){r=a;break}}else i=!1;return-1===r?n?"/":".":n&&1===r?"/":t.slice(0,r)},n.basename=function(t,e){var n=function(t){"string"!=typeof t&&(t+="");var e,n=0,r=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){n=e+1;break}}else-1===r&&(i=!1,r=e+1);return-1===r?"":t.slice(n,r)}(t);return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,n=0,r=-1,i=!0,a=0,o=t.length-1;o>=0;--o){var s=t.charCodeAt(o);if(47!==s)-1===r&&(i=!1,r=o+1),46===s?-1===e?e=o:1!==a&&(a=1):-1!==e&&(a=-1);else if(!i){n=o+1;break}}return-1===e||-1===r||0===a||1===a&&e===r-1&&e===n+1?"":t.slice(e,r)};var i="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)}}).call(this,t("_process"))},{_process:117}],96:[function(t,e,n){(function(e){"use strict";var r=t("./interlace"),i={1:{0:0,1:0,2:0,3:255},2:{0:0,1:0,2:0,3:1},3:{0:0,1:1,2:2,3:255},4:{0:0,1:1,2:2,3:3}};function a(t,e,n,r,a,o){for(var s=t.width,u=t.height,l=t.index,c=0;c>4,n.push(f,c);break;case 2:u=3&h,l=h>>2&3,c=h>>4&3,f=h>>6&3,n.push(f,c,l,u);break;case 1:i=1&h,a=h>>1&1,o=h>>2&1,s=h>>3&1,u=h>>4&1,l=h>>5&1,c=h>>6&1,f=h>>7&1,n.push(f,c,l,u,s,o,a,i)}}return{get:function(t){for(;n.length0&&(this._paused=!1,this.emit("drain"))}.bind(this))},o.prototype.write=function(t,e){return this.writable?(n=r.isBuffer(t)?t:new r(t,e||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",new Error("Stream not writable")),!1);var n},o.prototype.end=function(t,e){t&&this.write(t,e),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},o.prototype.destroySoon=o.prototype.end,o.prototype._end=function(){this._reads.length>0&&this.emit("error",new Error("There are some read requests waitng on finished stream")),this.destroy()},o.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},o.prototype._processReadAllowingLess=function(t){this._reads.shift();var e=this._buffers[0];e.length>t.length?(this._buffered-=t.length,this._buffers[0]=e.slice(t.length),t.func.call(this,e.slice(0,t.length))):(this._buffered-=e.length,this._buffers.shift(),t.func.call(this,e))},o.prototype._processRead=function(t){this._reads.shift();for(var e=0,n=0,i=new r(t.length);e0&&this._buffers.splice(0,n),this._buffered-=t.length,t.func.call(this,i)},o.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){var t=this._reads[0];if(t.allowLess)this._processReadAllowingLess(t);else{if(!(this._buffered>=t.length))break;this._processRead(t)}}this._buffers&&this._buffers.length>0&&null===this._buffers[0]&&this._end()}catch(t){this.emit("error",t)}}}).call(this,t("_process"),t("buffer").Buffer)},{_process:117,buffer:5,stream:139,util:150}],99:[function(t,e,n){"use strict";e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},{}],100:[function(t,e,n){"use strict";var r=[];!function(){for(var t=0;t<256;t++){for(var e=t,n=0;n<8;n++)1&e?e=3988292384^e>>>1:e>>>=1;r[t]=e}}();var i=e.exports=function(){this._crc=-1};i.prototype.write=function(t){for(var e=0;e>>8;return!0},i.prototype.crc32=function(){return-1^this._crc},i.crc32=function(t){for(var e=-1,n=0;n>>8;return-1^e}},{}],101:[function(t,e,n){(function(n){"use strict";var r=t("./paeth-predictor");var i={0:function(t,e,n,r,i){t.copy(r,i,e,e+n)},1:function(t,e,n,r,i,a){for(var o=0;o=a?t[e+o-a]:0,u=t[e+o]-s;r[i+o]=u}},2:function(t,e,n,r,i){for(var a=0;a0?t[e+a-n]:0,s=t[e+a]-o;r[i+a]=s}},3:function(t,e,n,r,i,a){for(var o=0;o=a?t[e+o-a]:0,u=e>0?t[e+o-n]:0,l=t[e+o]-(s+u>>1);r[i+o]=l}},4:function(t,e,n,i,a,o){for(var s=0;s=o?t[e+s-o]:0,l=e>0?t[e+s-n]:0,c=e>0&&s>=o?t[e+s-(n+o)]:0,f=t[e+s]-r(u,l,c);i[a+s]=f}}},a={0:function(t,e,n){for(var r=0,i=e+n,a=e;a=r?t[e+a-r]:0,s=t[e+a]-o;i+=Math.abs(s)}return i},2:function(t,e,n){for(var r=0,i=e+n,a=e;a0?t[a-n]:0,s=t[a]-o;r+=Math.abs(s)}return r},3:function(t,e,n,r){for(var i=0,a=0;a=r?t[e+a-r]:0,s=e>0?t[e+a-n]:0,u=t[e+a]-(o+s>>1);i+=Math.abs(u)}return i},4:function(t,e,n,i){for(var a=0,o=0;o=i?t[e+o-i]:0,u=e>0?t[e+o-n]:0,l=e>0&&o>=i?t[e+o-(n+i)]:0,c=t[e+o]-r(s,u,l);a+=Math.abs(c)}return a}};e.exports=function(t,e,r,o,s){var u;if("filterType"in o&&-1!==o.filterType){if("number"!=typeof o.filterType)throw new Error("unrecognised filter types");u=[o.filterType]}else u=[0,1,2,3,4];for(var l=e*s,c=0,f=0,h=new n((l+1)*r),p=u[0],d=0;d1)for(var v=1/0,g=0;gi?e[a-r]:0;e[a]=o+s}},o.prototype._unFilterType2=function(t,e,n){for(var r=this._lastLine,i=0;ii?e[o-r]:0,c=Math.floor((l+u)/2);e[o]=s+c}},o.prototype._unFilterType4=function(t,e,n){for(var r=this._xComparison,a=r-1,o=this._lastLine,s=0;sa?e[s-r]:0,f=s>a&&o?o[s-r]:0,h=i(c,l,f);e[s]=u+h}},o.prototype._reverseFilterLine=function(t){var e,r=t[0],i=this._images[this._imageIndex],a=i.byteWidth;if(0===r)e=t.slice(1,a+1);else switch(e=new n(a),r){case 1:this._unFilterType1(t,e,a);break;case 2:this._unFilterType2(t,e,a);break;case 3:this._unFilterType3(t,e,a);break;case 4:this._unFilterType4(t,e,a);break;default:throw new Error("Unrecognised filter type - "+r)}this.write(e),i.lineIndex++,i.lineIndex>=i.height?(this._lastLine=null,this._imageIndex++,i=this._images[this._imageIndex]):this._lastLine=e,i?this.read(i.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}}).call(this,t("buffer").Buffer)},{"./interlace":106,"./paeth-predictor":110,buffer:5}],105:[function(t,e,n){(function(t){"use strict";e.exports=function(e,n){var r=n.depth,i=n.width,a=n.height,o=n.colorType,s=n.transColor,u=n.palette,l=e;return 3===o?function(t,e,n,r,i){for(var a=0,o=0;o0&&f>0&&n.push({width:c,height:f,index:u})}return n},n.getInterlaceIterator=function(t){return function(e,n,i){var a=e%r[i].x.length,o=(e-a)/r[i].x.length*8+r[i].x[a],s=n%r[i].y.length;return 4*o+((n-s)/r[i].y.length*8+r[i].y[s])*t*4}}},{}],107:[function(t,e,n){(function(n){"use strict";var r=t("util"),i=t("stream"),a=t("./constants"),o=t("./packer"),s=e.exports=function(t){i.call(this);var e=t||{};this._packer=new o(e),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(s,i),s.prototype.pack=function(t,e,r,i){this.emit("data",new n(a.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(e,r)),i&&this.emit("data",this._packer.packGAMA(i));var o=this._packer.filterData(t,e,r);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(t){this.emit("data",this._packer.packIDAT(t))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(o)}}).call(this,t("buffer").Buffer)},{"./constants":99,"./packer":109,buffer:5,stream:139,util:150}],108:[function(t,e,n){(function(n){"use strict";var r=!0,i=t("zlib");i.deflateSync||(r=!1);var a=t("./constants"),o=t("./packer");e.exports=function(t,e){if(!r)throw new Error("To use the sync capability of this library in old node versions, please also add a dependency on node-zlb-backport");var s=new o(e||{}),u=[];u.push(new n(a.PNG_SIGNATURE)),u.push(s.packIHDR(t.width,t.height)),t.gamma&&u.push(s.packGAMA(t.gamma));var l=s.filterData(t.data,t.width,t.height),c=i.deflateSync(l,s.getDeflateOptions());if(l=null,!c||!c.length)throw new Error("bad png - invalid compressed data response");return u.push(s.packIDAT(c)),u.push(s.packIEND()),n.concat(u)}}).call(this,t("buffer").Buffer)},{"./constants":99,"./packer":109,buffer:5,zlib:46}],109:[function(t,e,n){(function(n){"use strict";var r=t("./constants"),i=t("./crc"),a=t("./bitpacker"),o=t("./filter-pack"),s=t("zlib"),u=e.exports=function(t){if(this._options=t,t.deflateChunkSize=t.deflateChunkSize||32768,t.deflateLevel=null!=t.deflateLevel?t.deflateLevel:9,t.deflateStrategy=null!=t.deflateStrategy?t.deflateStrategy:3,t.inputHasAlpha=null==t.inputHasAlpha||t.inputHasAlpha,t.deflateFactory=t.deflateFactory||s.createDeflate,t.bitDepth=t.bitDepth||8,t.colorType="number"==typeof t.colorType?t.colorType:r.COLORTYPE_COLOR_ALPHA,t.colorType!==r.COLORTYPE_COLOR&&t.colorType!==r.COLORTYPE_COLOR_ALPHA)throw new Error("option color type:"+t.colorType+" is not supported at present");if(8!==t.bitDepth)throw new Error("option bit depth:"+t.bitDepth+" is not supported at present")};u.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},u.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},u.prototype.filterData=function(t,e,n){var i=a(t,e,n,this._options),s=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(i,e,n,this._options,s)},u.prototype._packChunk=function(t,e){var r=e?e.length:0,a=new n(r+12);return a.writeUInt32BE(r,0),a.writeUInt32BE(t,4),e&&e.copy(a,8),a.writeInt32BE(i.crc32(a.slice(4,a.length-4)),a.length-4),a},u.prototype.packGAMA=function(t){var e=new n(4);return e.writeUInt32BE(Math.floor(t*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,e)},u.prototype.packIHDR=function(t,e){var i=new n(13);return i.writeUInt32BE(t,0),i.writeUInt32BE(e,4),i[8]=this._options.bitDepth,i[9]=this._options.colorType,i[10]=0,i[11]=0,i[12]=0,this._packChunk(r.TYPE_IHDR,i)},u.prototype.packIDAT=function(t){return this._packChunk(r.TYPE_IDAT,t)},u.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}}).call(this,t("buffer").Buffer)},{"./bitpacker":97,"./constants":99,"./crc":100,"./filter-pack":101,buffer:5,zlib:46}],110:[function(t,e,n){"use strict";e.exports=function(t,e,n){var r=t+e-n,i=Math.abs(r-t),a=Math.abs(r-e),o=Math.abs(r-n);return i<=a&&i<=o?t:a<=o?e:n}},{}],111:[function(t,e,n){"use strict";var r=t("util"),i=t("zlib"),a=t("./chunkstream"),o=t("./filter-parse-async"),s=t("./parser"),u=t("./bitmapper"),l=t("./format-normaliser"),c=e.exports=function(t){a.call(this),this._parser=new s(t,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this)}),this._options=t,this.writable=!0,this._parser.start()};r.inherits(c,a),c.prototype._handleError=function(t){this.emit("error",t),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this.errord=!0},c.prototype._inflateData=function(t){this._inflate||(this._inflate=i.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter)),this._inflate.write(t)},c.prototype._handleMetaData=function(t){this.emit("metadata",t),this._bitmapInfo=Object.create(t),this._filter=new o(this._bitmapInfo)},c.prototype._handleTransColor=function(t){this._bitmapInfo.transColor=t},c.prototype._handlePalette=function(t){this._bitmapInfo.palette=t},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"),this.destroySoon())},c.prototype._complete=function(t){if(!this.errord){try{var e=u.dataToBitMap(t,this._bitmapInfo),n=l(e,this._bitmapInfo);e=null}catch(t){return void this._handleError(t)}this.emit("parsed",n)}}},{"./bitmapper":96,"./chunkstream":98,"./filter-parse-async":102,"./format-normaliser":105,"./parser":113,util:150,zlib:46}],112:[function(t,e,n){(function(n){"use strict";var r=!0,i=t("zlib");i.deflateSync||(r=!1);var a=t("./sync-reader"),o=t("./filter-parse-sync"),s=t("./parser"),u=t("./bitmapper"),l=t("./format-normaliser");e.exports=function(t,e){if(!r)throw new Error("To use the sync capability of this library in old node versions, please also add a dependency on node-zlb-backport");var c,f,h;var p=[];var d=new a(t);if(new s(e,{read:d.read.bind(d),error:function(t){c=t},metadata:function(t){f=t},gamma:function(t){h=t},palette:function(t){f.palette=t},transColor:function(t){f.transColor=t},inflateData:function(t){p.push(t)}}).start(),d.process(),c)throw c;var v=n.concat(p);p.length=0;var g=i.inflateSync(v);if(v=null,!g||!g.length)throw new Error("bad png - invalid inflate data response");var m=o.process(g,f);v=null;var _=u.dataToBitMap(m,f);m=null;var y=l(_,f);return f.data=y,f.gamma=h||0,f}}).call(this,t("buffer").Buffer)},{"./bitmapper":96,"./filter-parse-sync":103,"./format-normaliser":105,"./parser":113,"./sync-reader":116,buffer:5,zlib:46}],113:[function(t,e,n){(function(n){"use strict";var r=t("./constants"),i=t("./crc"),a=e.exports=function(t,e){this._options=t,t.checkCRC=!1!==t.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=e.read,this.error=e.error,this.metadata=e.metadata,this.gamma=e.gamma,this.transColor=e.transColor,this.palette=e.palette,this.parsed=e.parsed,this.inflateData=e.inflateData,this.inflateData=e.inflateData,this.finished=e.finished};a.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},a.prototype._parseSignature=function(t){for(var e=r.PNG_SIGNATURE,n=0;nthis._palette.length)return void this.error(new Error("More transparent colors than palette size"));for(var e=0;e0?this._handleIDAT(n):this._handleChunkEnd()},a.prototype._handleIEND=function(t){this.read(t,this._parseIEND.bind(this))},a.prototype._parseIEND=function(t){this._crc.write(t),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}}).call(this,t("buffer").Buffer)},{"./constants":99,"./crc":100,buffer:5}],114:[function(t,e,n){"use strict";var r=t("./parser-sync"),i=t("./packer-sync");n.read=function(t,e){return r(t,e||{})},n.write=function(t){return i(t)}},{"./packer-sync":108,"./parser-sync":112}],115:[function(t,e,n){(function(e,r){"use strict";var i=t("util"),a=t("stream"),o=t("./parser-async"),s=t("./packer-async"),u=t("./png-sync"),l=n.PNG=function(t){a.call(this),t=t||{},this.width=t.width||0,this.height=t.height||0,this.data=this.width>0&&this.height>0?new r(4*this.width*this.height):null,t.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new o(t),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(t){this.data=t,this.emit("parsed",t)}.bind(this)),this._packer=new s(t),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};i.inherits(l,a),l.sync=u,l.prototype.pack=function(){return this.data&&this.data.length?(e.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this):(this.emit("error","No data provided"),this)},l.prototype.parse=function(t,e){var n,r;e&&(n=function(t){this.removeListener("error",r),this.data=t,e(null,this)}.bind(this),r=function(t){this.removeListener("parsed",n),e(t,null)}.bind(this),this.once("parsed",n),this.once("error",r));return this.end(t),this},l.prototype.write=function(t){return this._parser.write(t),!0},l.prototype.end=function(t){this._parser.end(t)},l.prototype._metadata=function(t){this.width=t.width,this.height=t.height,this.emit("metadata",t)},l.prototype._gamma=function(t){this.gamma=t},l.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},l.bitblt=function(t,e,n,r,i,a,o,s){if(n>t.width||r>t.height||n+i>t.width||r+a>t.height)throw new Error("bitblt reading outside image");if(o>e.width||s>e.height||o+i>e.width||s+a>e.height)throw new Error("bitblt writing outside image");for(var u=0;u0&&this._buffer.length;){var t=this._reads[0];if(!this._buffer.length||!(this._buffer.length>=t.length||t.allowLess))break;this._reads.shift();var e=this._buffer;this._buffer=e.slice(t.length),t.func.call(this,e.slice(0,t.length))}return this._reads.length>0?new Error("There are some read requests waitng on finished stream"):this._buffer.length>0?new Error("unrecognised content at end of stream"):void 0}},{}],117:[function(t,e,n){var r,i,a=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var l,c=[],f=!1,h=-1;function p(){f&&l&&(f=!1,l.length?c=l.concat(c):h=-1,c.length&&d())}function d(){if(!f){var t=u(p);f=!0;for(var e=c.length;e;){for(l=c,c=[];++h1)for(var n=1;n0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===l.prototype||(e=function(t){return l.from(t)}(e)),r?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):b(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(e=o.decoder.write(e),o.objectMode||0!==e.length?b(t,o,e,!1):j(t,o)):b(t,o,e,!1))):r||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function E(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(S,t):S(t))}function S(t){p("emit readable"),t.emit("readable"),M(t)}function j(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(T,t,e))}function T(t,e){for(var n=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):n=function(t,e,n){var r;ta.length?a.length:t;if(o===a.length?i+=a:i+=a.slice(0,t),0===(t-=o)){o===a.length?(++r,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=a.slice(o));break}++r}return e.length-=r,i}(t,e):function(t,e){var n=l.allocUnsafe(t),r=e.head,i=1;r.data.copy(n),t-=r.data.length;for(;r=r.next;){var a=r.data,o=t>a.length?a.length:t;if(a.copy(n,n.length-t,0,o),0===(t-=o)){o===a.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=a.slice(o));break}++i}return e.length-=i,n}(t,e);return r}(t,e.buffer,e.decoder),n);var n}function R(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function B(t,e){for(var n=0,r=t.length;n=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?R(this):E(this),null;if(0===(t=k(t,e))&&e.ended)return 0===e.length&&R(this),null;var r,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&R(this)),null!==r&&this.emit("data",r),r},y.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},y.prototype.pipe=function(t,e){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=t;break;case 1:a.pipes=[a.pipes,t];break;default:a.pipes.push(t)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,e);var u=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?c:y;function l(e,n){p("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),t.removeListener("close",m),t.removeListener("finish",_),t.removeListener("drain",f),t.removeListener("error",g),t.removeListener("unpipe",l),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",v),h=!0,!a.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){p("onend"),t.end()}a.endEmitted?i.nextTick(u):r.once("end",u),t.on("unpipe",l);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,M(t))}}(r);t.on("drain",f);var h=!1;var d=!1;function v(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===a.pipesCount&&a.pipes===t||a.pipesCount>1&&-1!==B(a.pipes,t))&&!h&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function g(e){p("onerror",e),y(),t.removeListener("error",g),0===s(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",_),y()}function _(){p("onfinish"),t.removeListener("close",m),y()}function y(){p("unpipe"),r.unpipe(t)}return r.on("data",v),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",g),t.once("close",m),t.once("finish",_),t.emit("pipe",r),a.flowing||(p("pipe resume"),r.resume()),t},y.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n),this);if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var a=0;a-1?i:a.nextTick;_.WritableState=m;var l=t("core-util-is");l.inherits=t("inherits");var c={deprecate:t("util-deprecate")},f=t("./internal/streams/stream"),h=t("safe-buffer").Buffer,p=r.Uint8Array||function(){};var d,v=t("./internal/streams/destroy");function g(){}function m(e,n){s=s||t("./_stream_duplex"),e=e||{};var r=n instanceof s;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,i=n.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,i){--e.pendingcb,n?(a.nextTick(i,r),a.nextTick(E,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(i(r),t._writableState.errorEmitted=!0,t.emit("error",r),E(t,e))}(t,n,r,e,i);else{var o=x(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||b(t,n),r?u(w,t,n,o,i):w(t,n,o,i)}}(n,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function _(e){if(s=s||t("./_stream_duplex"),!(d.call(_,this)||this instanceof s))return new _(e);this._writableState=new m(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function y(t,e,n,r,i,a,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,n?t._writev(i,e.onwrite):t._write(i,a,e.onwrite),e.sync=!1}function w(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),E(t,e)}function b(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),a=e.corkedRequestsFree;a.entry=n;for(var s=0,u=!0;n;)i[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;i.allBuffers=u,y(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,f=n.callback;if(y(t,e,!1,e.objectMode?1:l.length,l,c,f),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function k(t,e){t._final(function(n){e.pendingcb--,n&&t.emit("error",n),e.prefinished=!0,t.emit("prefinish"),E(t,e)})}function E(t,e){var n=x(e);return n&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,a.nextTick(k,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}l.inherits(_,f),m.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(m.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(_,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===_&&(t&&t._writableState instanceof m)}})):d=function(t){return t instanceof this},_.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},_.prototype.write=function(t,e,n){var r,i=this._writableState,o=!1,s=!i.objectMode&&(r=t,h.isBuffer(r)||r instanceof p);return s&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(n=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof n&&(n=g),i.ended?function(t,e){var n=new Error("write after end");t.emit("error",n),a.nextTick(e,n)}(this,n):(s||function(t,e,n,r){var i=!0,o=!1;return null===n?o=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),a.nextTick(r,o),i=!1),i}(this,i,t,n))&&(i.pendingcb++,o=function(t,e,n,r,i,a){if(!n){var o=function(t,e,n){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,n));return e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var s=e.objectMode?1:r.length;e.length+=s;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(_.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),_.prototype._write=function(t,e,n){n(new Error("_write() is not implemented"))},_.prototype._writev=null,_.prototype.end=function(t,e,n){var r=this._writableState;"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||function(t,e,n){e.ending=!0,E(t,e),n&&(e.finished?a.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,r,n)},Object.defineProperty(_.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),_.prototype.destroy=v.destroy,_.prototype._undestroy=v.undestroy,_.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":119,"./internal/streams/destroy":125,"./internal/streams/stream":126,_process:117,"core-util-is":15,inherits:70,"process-nextick-args":128,"safe-buffer":134,timers:142,"util-deprecate":148}],124:[function(t,e,n){"use strict";var r=t("safe-buffer").Buffer,i=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n},t.prototype.concat=function(t){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var e,n,i,a=r.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,n=a,i=s,e.copy(n,i),s+=o.data.length,o=o.next;return a},t}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":134,util:4}],125:[function(t,e,n){"use strict";var r=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||r.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(r.nextTick(i,n,t),n._writableState&&(n._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":128}],126:[function(t,e,n){e.exports=t("events").EventEmitter},{events:48}],127:[function(t,e,n){var r={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},{}],128:[function(t,e,n){(function(t){"use strict";!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,n,r,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var a,o,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,n)});case 3:return t.nextTick(function(){e.call(null,n,r)});case 4:return t.nextTick(function(){e.call(null,n,r,i)});default:for(a=new Array(s-1),o=0;o>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function c(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}n.StringDecoder=a,a.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return i>0&&(t.lastNeed=i-1),i;if(--r=0)return i>0&&(t.lastNeed=i-2),i;if(--r=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},a.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":134}],130:[function(t,e,n){e.exports=t("./readable").PassThrough},{"./readable":131}],131:[function(t,e,n){(n=e.exports=t("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=t("./lib/_stream_writable.js"),n.Duplex=t("./lib/_stream_duplex.js"),n.Transform=t("./lib/_stream_transform.js"),n.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":119,"./lib/_stream_passthrough.js":120,"./lib/_stream_readable.js":121,"./lib/_stream_transform.js":122,"./lib/_stream_writable.js":123}],132:[function(t,e,n){e.exports=t("./readable").Transform},{"./readable":131}],133:[function(t,e,n){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":123}],134:[function(t,e,n){var r=t("buffer"),i=r.Buffer;function a(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return i(t,e,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(a(r,n),n.Buffer=o),a(i,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=i(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}},{buffer:5}],135:[function(t,e,n){arguments[4][67][0].apply(n,arguments)},{"./lib/decoder":136,"./lib/encoder":137,dup:67}],136:[function(t,e,n){(function(t){var n=function(){"use strict";var t=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),e=4017,n=799,r=3406,i=2276,a=1567,o=3784,s=5793,u=2896;function l(){}function c(t,e){for(var n,r,i=0,a=[],o=16;o>0&&!t[o-1];)o--;a.push({children:[],index:0});var s,u=a[0];for(n=0;n0;)u=a.pop();for(u.index++,a.push(u);a.length<=n;)a.push(s={children:[],index:0}),u.children[u.index]=s.children,u=s;i++}n+10)return p>>--d&1;if(255==(p=e[n++])){var t=e[n++];if(t)throw"unexpected marker: "+(p<<8|t).toString(16)}return d=7,p>>>7}function g(t){for(var e,n=t;null!==(e=v());){if("number"==typeof(n=n[e]))return n;if("object"!=typeof n)throw"invalid huffman sequence"}return null}function m(t){for(var e=0;t>0;){var n=v();if(null===n)return;e=e<<1|n,t--}return e}function _(t){var e=m(t);return e>=1<0)y--;else for(var r=o,i=s;r<=i;){var a=g(e.huffmanTableAC),u=15&a,c=a>>4;if(0!==u)n[t[r+=c]]=_(u)*(1<>4,0===f)a<15?(y=m(a)+(1<>4;if(0!==s)n[t[a+=u]]=_(s),a++;else{if(u<15)break;a+=16}}};var I,R,L,B,F=0;for(R=1==M?i[0].blocksPerLine*i[0].blocksPerColumn:c*r.mcusPerColumn,a||(a=R);F=65488&&I<=65495))break;n+=2}return n-h}function h(t,l){var c,f,h=[],p=l.blocksPerLine,d=l.blocksPerColumn,v=p<<3,g=new Int32Array(64),m=new Uint8Array(64);function _(t,c,f){var h,p,d,v,g,m,_,y,w,b,x=l.quantizationTable,k=f;for(b=0;b<64;b++)k[b]=t[b]*x[b];for(b=0;b<8;++b){var E=8*b;0!=k[1+E]||0!=k[2+E]||0!=k[3+E]||0!=k[4+E]||0!=k[5+E]||0!=k[6+E]||0!=k[7+E]?(h=s*k[0+E]+128>>8,p=s*k[4+E]+128>>8,d=k[2+E],v=k[6+E],g=u*(k[1+E]-k[7+E])+128>>8,y=u*(k[1+E]+k[7+E])+128>>8,m=k[3+E]<<4,_=k[5+E]<<4,w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+128>>8,d=d*a-v*o+128>>8,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+E]=h+y,k[7+E]=h-y,k[1+E]=p+_,k[6+E]=p-_,k[2+E]=d+m,k[5+E]=d-m,k[3+E]=v+g,k[4+E]=v-g):(w=s*k[0+E]+512>>10,k[0+E]=w,k[1+E]=w,k[2+E]=w,k[3+E]=w,k[4+E]=w,k[5+E]=w,k[6+E]=w,k[7+E]=w)}for(b=0;b<8;++b){var S=b;0!=k[8+S]||0!=k[16+S]||0!=k[24+S]||0!=k[32+S]||0!=k[40+S]||0!=k[48+S]||0!=k[56+S]?(h=s*k[0+S]+2048>>12,p=s*k[32+S]+2048>>12,d=k[16+S],v=k[48+S],g=u*(k[8+S]-k[56+S])+2048>>12,y=u*(k[8+S]+k[56+S])+2048>>12,m=k[24+S],_=k[40+S],w=h-p+1>>1,h=h+p+1>>1,p=w,w=d*o+v*a+2048>>12,d=d*a-v*o+2048>>12,v=w,w=g-_+1>>1,g=g+_+1>>1,_=w,w=y+m+1>>1,m=y-m+1>>1,y=w,w=h-v+1>>1,h=h+v+1>>1,v=w,w=p-d+1>>1,p=p+d+1>>1,d=w,w=g*i+y*r+2048>>12,g=g*r-y*i+2048>>12,y=w,w=m*n+_*e+2048>>12,m=m*e-_*n+2048>>12,_=w,k[0+S]=h+y,k[56+S]=h-y,k[8+S]=p+_,k[48+S]=p-_,k[16+S]=d+m,k[40+S]=d-m,k[24+S]=v+g,k[32+S]=v-g):(w=s*f[b+0]+8192>>14,k[0+S]=w,k[8+S]=w,k[16+S]=w,k[24+S]=w,k[32+S]=w,k[40+S]=w,k[48+S]=w,k[56+S]=w)}for(b=0;b<64;++b){var j=128+(k[b]+8>>4);c[b]=j<0?0:j>255?255:j}}for(var y=0;y255?255:t}return l.prototype={load:function(t){var e=new XMLHttpRequest;e.open("GET",t,!0),e.responseType="arraybuffer",e.onload=function(){var t=new Uint8Array(e.response||e.mozResponseArrayBuffer);this.parse(t),this.onload&&this.onload()}.bind(this),e.send(null)},parse:function(e){var n=0;e.length;function r(){var t=e[n]<<8|e[n+1];return n+=2,t}function i(){var t=r(),i=e.subarray(n,n+t-2);return n+=i.length,i}function a(t){var e,n,r=0,i=0;for(n in t.components)t.components.hasOwnProperty(n)&&(r<(e=t.components[n]).h&&(r=e.h),i>4==0)for(_=0;_<64;_++){x[t[_]]=e[n++]}else{if(b>>4!=1)throw"DQT: invalid table spec";for(_=0;_<64;_++){x[t[_]]=r()}}p[15&b]=x}break;case 65472:case 65473:case 65474:r(),(o={}).extended=65473===m,o.progressive=65474===m,o.precision=e[n++],o.scanLines=r(),o.samplesPerLine=r(),o.components={},o.componentsOrder=[];var k,E=e[n++];for(U=0;U>4,j=15&e[n+1],T=e[n+2];o.componentsOrder.push(k),o.components[k]={h:S,v:j,quantizationTable:p[T]},n+=3}a(o),d.push(o);break;case 65476:var A=r();for(U=2;U>4==0?g:v)[15&C]=c(M,R)}break;case 65501:r(),s=r();break;case 65498:r();var L=e[n++],B=[];for(U=0;U>4],z.huffmanTableAC=v[15&F],B.push(z)}var P=e[n++],O=e[n++],D=e[n++],N=f(e,n,o,B,s,P,O,D>>4,15&D);n+=N;break;default:if(255==e[n-3]&&e[n-2]>=192&&e[n-2]<=254){n-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=r()}if(1!=d.length)throw"only single frame JPEGs supported";this.width=o.samplesPerLine,this.height=o.scanLines,this.jfif=u,this.adobe=l,this.components=[];for(var U=0;U=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var r=t.length;this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,r),r-=this.charReceived);var i;r=(e+=t.toString(this.encoding,0,r)).length-1;if((i=e.charCodeAt(r))>=55296&&i<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),t.copy(this.charBuffer,0,0,a),e.substring(0,r)}return e},a.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var n=t[t.length-e];if(1==e&&n>>5==6){this.charLength=2;break}if(e<=2&&n>>4==14){this.charLength=3;break}if(e<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=e},a.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;e+=r.slice(0,n).toString(i)}return e}},{buffer:5}],141:[function(t,e,n){(function(n){var r=t("stream");function i(t,e,i){t=t||function(t){this.queue(t)},e=e||function(){this.queue(null)};var a=!1,o=!1,s=[],u=!1,l=new r;function c(){for(;s.length&&!l.paused;){var t=s.shift();if(null===t)return l.emit("end");l.emit("data",t)}}return l.readable=l.writable=!0,l.paused=!1,l.autoDestroy=!(i&&!1===i.autoDestroy),l.write=function(e){return t.call(this,e),!l.paused},l.queue=l.push=function(t){return u?l:(null===t&&(u=!0),s.push(t),c(),l)},l.on("end",function(){l.readable=!1,!l.writable&&l.autoDestroy&&n.nextTick(function(){l.destroy()})}),l.end=function(t){if(!a)return a=!0,arguments.length&&l.write(t),l.writable=!1,e.call(l),!l.readable&&l.autoDestroy&&l.destroy(),l},l.destroy=function(){if(!o)return o=!0,a=!0,s.length=0,l.writable=l.readable=!1,l.emit("close"),l},l.pause=function(){if(!l.paused)return l.paused=!0,l},l.resume=function(){return l.paused&&(l.paused=!1,l.emit("resume")),c(),l.paused||l.emit("drain"),l},l}e.exports=i,i.through=i}).call(this,t("_process"))},{_process:117,stream:139}],142:[function(t,e,n){(function(e,r){var i=t("process/browser.js").nextTick,a=Function.prototype.apply,o=Array.prototype.slice,s={},u=0;function l(t,e){this._id=t,this._clearFn=e}n.setTimeout=function(){return new l(a.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new l(a.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n.setImmediate="function"==typeof e?e:function(t){var e=u++,r=!(arguments.length<2)&&o.call(arguments,1);return s[e]=!0,i(function(){s[e]&&(r?t.apply(null,r):t.call(null),n.clearImmediate(e))}),e},n.clearImmediate="function"==typeof r?r:function(t){delete s[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":117,timers:142}],143:[function(t,e,n){n.isatty=function(){return!1},n.ReadStream=function(){throw new Error("tty.ReadStream is not implemented")},n.WriteStream=function(){throw new Error("tty.WriteStream is not implemented")}},{}],144:[function(t,e,n){(function(e,r){"use strict";var i=t("bit-twiddle"),a=t("dup");e.__TYPEDARRAY_POOL||(e.__TYPEDARRAY_POOL={UINT8:a([32,0]),UINT16:a([32,0]),UINT32:a([32,0]),INT8:a([32,0]),INT16:a([32,0]),INT32:a([32,0]),FLOAT:a([32,0]),DOUBLE:a([32,0]),DATA:a([32,0]),UINT8C:a([32,0]),BUFFER:a([32,0])});var o="undefined"!=typeof Uint8ClampedArray,s=e.__TYPEDARRAY_POOL;s.UINT8C||(s.UINT8C=a([32,0])),s.BUFFER||(s.BUFFER=a([32,0]));var u=s.DATA,l=s.BUFFER;function c(t){if(t){var e=t.length||t.byteLength,n=i.log2(e);u[n].push(t)}}function f(t){t=i.nextPow2(t);var e=i.log2(t),n=u[e];return n.length>0?n.pop():new ArrayBuffer(t)}function h(t){return new Uint8Array(f(t),0,t)}function p(t){return new Uint16Array(f(2*t),0,t)}function d(t){return new Uint32Array(f(4*t),0,t)}function v(t){return new Int8Array(f(t),0,t)}function g(t){return new Int16Array(f(2*t),0,t)}function m(t){return new Int32Array(f(4*t),0,t)}function _(t){return new Float32Array(f(4*t),0,t)}function y(t){return new Float64Array(f(8*t),0,t)}function w(t){return o?new Uint8ClampedArray(f(t),0,t):h(t)}function b(t){return new DataView(f(t),0,t)}function x(t){t=i.nextPow2(t);var e=i.log2(t),n=l[e];return n.length>0?n.pop():new r(t)}n.free=function(t){if(r.isBuffer(t))l[i.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,n=0|i.log2(e);u[n].push(t)}},n.freeUint8=n.freeUint16=n.freeUint32=n.freeInt8=n.freeInt16=n.freeInt32=n.freeFloat32=n.freeFloat=n.freeFloat64=n.freeDouble=n.freeUint8Clamped=n.freeDataView=function(t){c(t.buffer)},n.freeArrayBuffer=c,n.freeBuffer=function(t){l[i.log2(t.length)].push(t)},n.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return f(t);switch(e){case"uint8":return h(t);case"uint16":return p(t);case"uint32":return d(t);case"int8":return v(t);case"int16":return g(t);case"int32":return m(t);case"float":case"float32":return _(t);case"double":case"float64":return y(t);case"uint8_clamped":return w(t);case"buffer":return x(t);case"data":case"dataview":return b(t);default:return null}return null},n.mallocArrayBuffer=f,n.mallocUint8=h,n.mallocUint16=p,n.mallocUint32=d,n.mallocInt8=v,n.mallocInt16=g,n.mallocInt32=m,n.mallocFloat32=n.mallocFloat=_,n.mallocFloat64=n.mallocDouble=y,n.mallocUint8Clamped=w,n.mallocDataView=b,n.mallocBuffer=x,n.clearCache=function(){for(var t=0;t<32;++t)s.UINT8[t].length=0,s.UINT16[t].length=0,s.UINT32[t].length=0,s.INT8[t].length=0,s.INT16[t].length=0,s.INT32[t].length=0,s.FLOAT[t].length=0,s.DOUBLE[t].length=0,s.UINT8C[t].length=0,u[t].length=0,l[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{"bit-twiddle":2,buffer:5,dup:21}],145:[function(t,e,n){(function(){var t=this,r=t._,i={},a=Array.prototype,o=Object.prototype,s=Function.prototype,u=a.push,l=a.slice,c=a.concat,f=o.toString,h=o.hasOwnProperty,p=a.forEach,d=a.map,v=a.reduce,g=a.reduceRight,m=a.filter,_=a.every,y=a.some,w=a.indexOf,b=a.lastIndexOf,x=Array.isArray,k=Object.keys,E=s.bind,S=function(t){return t instanceof S?t:this instanceof S?void(this._wrapped=t):new S(t)};void 0!==n?(void 0!==e&&e.exports&&(n=e.exports=S),n._=S):t._=S,S.VERSION="1.4.4";var j=S.each=S.forEach=function(t,e,n){if(null!=t)if(p&&t.forEach===p)t.forEach(e,n);else if(t.length===+t.length){for(var r=0,a=t.length;r2;if(null==t&&(t=[]),v&&t.reduce===v)return r&&(e=S.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(j(t,function(t,a,o){i?n=e.call(r,n,t,a,o):(n=t,i=!0)}),!i)throw new TypeError(T);return n},S.reduceRight=S.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),g&&t.reduceRight===g)return r&&(e=S.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var a=t.length;if(a!==+a){var o=S.keys(t);a=o.length}if(j(t,function(s,u,l){u=o?o[--a]:--a,i?n=e.call(r,n,t[u],u,l):(n=t[u],i=!0)}),!i)throw new TypeError(T);return n},S.find=S.detect=function(t,e,n){var r;return A(t,function(t,i,a){if(e.call(n,t,i,a))return r=t,!0}),r},S.filter=S.select=function(t,e,n){var r=[];return null==t?r:m&&t.filter===m?t.filter(e,n):(j(t,function(t,i,a){e.call(n,t,i,a)&&(r[r.length]=t)}),r)},S.reject=function(t,e,n){return S.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},S.every=S.all=function(t,e,n){e||(e=S.identity);var r=!0;return null==t?r:_&&t.every===_?t.every(e,n):(j(t,function(t,a,o){if(!(r=r&&e.call(n,t,a,o)))return i}),!!r)};var A=S.some=S.any=function(t,e,n){e||(e=S.identity);var r=!1;return null==t?r:y&&t.some===y?t.some(e,n):(j(t,function(t,a,o){if(r||(r=e.call(n,t,a,o)))return i}),!!r)};S.contains=S.include=function(t,e){return null!=t&&(w&&t.indexOf===w?-1!=t.indexOf(e):A(t,function(t){return t===e}))},S.invoke=function(t,e){var n=l.call(arguments,2),r=S.isFunction(e);return S.map(t,function(t){return(r?e:t[e]).apply(t,n)})},S.pluck=function(t,e){return S.map(t,function(t){return t[e]})},S.where=function(t,e,n){return S.isEmpty(e)?n?null:[]:S[n?"find":"filter"](t,function(t){for(var n in e)if(e[n]!==t[n])return!1;return!0})},S.findWhere=function(t,e){return S.where(t,e,!0)},S.max=function(t,e,n){if(!e&&S.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.max.apply(Math,t);if(!e&&S.isEmpty(t))return-1/0;var r={computed:-1/0,value:-1/0};return j(t,function(t,i,a){var o=e?e.call(n,t,i,a):t;o>=r.computed&&(r={value:t,computed:o})}),r.value},S.min=function(t,e,n){if(!e&&S.isArray(t)&&t[0]===+t[0]&&t.length<65535)return Math.min.apply(Math,t);if(!e&&S.isEmpty(t))return 1/0;var r={computed:1/0,value:1/0};return j(t,function(t,i,a){var o=e?e.call(n,t,i,a):t;or||void 0===n)return 1;if(n>>1;n.call(r,t[s])=0})})},S.difference=function(t){var e=c.apply(a,l.call(arguments,1));return S.filter(t,function(t){return!S.contains(e,t)})},S.zip=function(){for(var t=l.call(arguments),e=S.max(S.pluck(t,"length")),n=new Array(e),r=0;r=0;n--)e=[t[n].apply(this,e)];return e[0]}},S.after=function(t,e){return t<=0?e():function(){if(--t<1)return e.apply(this,arguments)}},S.keys=k||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var n in t)S.has(t,n)&&(e[e.length]=n);return e},S.values=function(t){var e=[];for(var n in t)S.has(t,n)&&e.push(t[n]);return e},S.pairs=function(t){var e=[];for(var n in t)S.has(t,n)&&e.push([n,t[n]]);return e},S.invert=function(t){var e={};for(var n in t)S.has(t,n)&&(e[t[n]]=n);return e},S.functions=S.methods=function(t){var e=[];for(var n in t)S.isFunction(t[n])&&e.push(n);return e.sort()},S.extend=function(t){return j(l.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},S.pick=function(t){var e={},n=c.apply(a,l.call(arguments,1));return j(n,function(n){n in t&&(e[n]=t[n])}),e},S.omit=function(t){var e={},n=c.apply(a,l.call(arguments,1));for(var r in t)S.contains(n,r)||(e[r]=t[r]);return e},S.defaults=function(t){return j(l.call(arguments,1),function(e){if(e)for(var n in e)null==t[n]&&(t[n]=e[n])}),t},S.clone=function(t){return S.isObject(t)?S.isArray(t)?t.slice():S.extend({},t):t},S.tap=function(t,e){return e(t),t};var R=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof S&&(t=t._wrapped),e instanceof S&&(e=e._wrapped);var i=f.call(t);if(i!=f.call(e))return!1;switch(i){case"[object String]":return t==String(e);case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var a=n.length;a--;)if(n[a]==t)return r[a]==e;n.push(t),r.push(e);var o=0,s=!0;if("[object Array]"==i){if(s=(o=t.length)==e.length)for(;o--&&(s=R(t[o],e[o],n,r)););}else{var u=t.constructor,l=e.constructor;if(u!==l&&!(S.isFunction(u)&&u instanceof u&&S.isFunction(l)&&l instanceof l))return!1;for(var c in t)if(S.has(t,c)&&(o++,!(s=S.has(e,c)&&R(t[c],e[c],n,r))))break;if(s){for(c in e)if(S.has(e,c)&&!o--)break;s=!o}}return n.pop(),r.pop(),s};S.isEqual=function(t,e){return R(t,e,[],[])},S.isEmpty=function(t){if(null==t)return!0;if(S.isArray(t)||S.isString(t))return 0===t.length;for(var e in t)if(S.has(t,e))return!1;return!0},S.isElement=function(t){return!(!t||1!==t.nodeType)},S.isArray=x||function(t){return"[object Array]"==f.call(t)},S.isObject=function(t){return t===Object(t)},j(["Arguments","Function","String","Number","Date","RegExp"],function(t){S["is"+t]=function(e){return f.call(e)=="[object "+t+"]"}}),S.isArguments(arguments)||(S.isArguments=function(t){return!(!t||!S.has(t,"callee"))}),"function"!=typeof/./&&(S.isFunction=function(t){return"function"==typeof t}),S.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},S.isNaN=function(t){return S.isNumber(t)&&t!=+t},S.isBoolean=function(t){return!0===t||!1===t||"[object Boolean]"==f.call(t)},S.isNull=function(t){return null===t},S.isUndefined=function(t){return void 0===t},S.has=function(t,e){return h.call(t,e)},S.noConflict=function(){return t._=r,this},S.identity=function(t){return t},S.times=function(t,e,n){for(var r=Array(t),i=0;i":">",'"':""","'":"'","/":"/"}};L.unescape=S.invert(L.escape);var B={escape:new RegExp("["+S.keys(L.escape).join("")+"]","g"),unescape:new RegExp("("+S.keys(L.unescape).join("|")+")","g")};S.each(["escape","unescape"],function(t){S[t]=function(e){return null==e?"":(""+e).replace(B[t],function(e){return L[t][e]})}}),S.result=function(t,e){if(null==t)return null;var n=t[e];return S.isFunction(n)?n.call(t):n},S.mixin=function(t){j(S.functions(t),function(e){var n=S[e]=t[e];S.prototype[e]=function(){var t=[this._wrapped];return u.apply(t,arguments),N.call(this,n.apply(S,t))}})};var F=0;S.uniqueId=function(t){var e=++F+"";return t?t+e:e},S.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;S.template=function(t,e,n){var r;n=S.defaults({},n,S.templateSettings);var i=new RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source].join("|")+"|$","g"),a=0,o="__p+='";t.replace(i,function(e,n,r,i,s){return o+=t.slice(a,s).replace(D,function(t){return"\\"+O[t]}),n&&(o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(o+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(o+="';\n"+i+"\n__p+='"),a=s+e.length,e}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{r=new Function(n.variable||"obj","_",o)}catch(t){throw t.source=o,t}if(e)return r(e,S);var s=function(t){return r.call(this,t,S)};return s.source="function("+(n.variable||"obj")+"){\n"+o+"}",s},S.chain=function(t){return S(t).chain()};var N=function(t){return this._chain?S(t).chain():t};S.mixin(S),j(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=a[t];S.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],N.call(this,n)}}),j(["concat","join","slice"],function(t){var e=a[t];S.prototype[t]=function(){return N.call(this,e.apply(this._wrapped,arguments))}}),S.extend(S.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this)},{}],146:[function(t,e,n){"use strict";e.exports=function(t,e,n){return 0===t.length?t:e?(n||t.sort(e),function(t,e){for(var n=1,r=t.length,i=t[0],a=t[0],o=1;o=o?u+1:o}r.mkdir(e+"sequencer"+o,function(){var a=e+"sequencer"+o+"/";for(var s in n.images){var u=n.images[s].steps;if(i){var l=u.slice(-1)[0].output.src,c=u.slice(-1)[0].output.format,f=t("data-uri-to-buffer")(l);r.writeFile(a+s+"_"+(u.length-1)+"."+c,f,function(){})}else for(var h in u){l=u[h].output.src,c=u[h].output.format,f=t("data-uri-to-buffer")(l);r.writeFile(a+s+"_"+h+"."+c,f,function(){})}}})},r.readdir(c,function(t,e){var n=[];if(void 0===e||0==e.length)return f(n),[];for(var i=0;i0&&(thisStep=c[t].steps[e],thisStep.UI.onRemove(thisStep.options.step),c[t].steps.splice(e,1))}function v(){var e=[],n=this;for(var r in arguments)e.push(a(arguments[r]));var i=l.call(this,e,"l");f.push({method:"loadImages",json_q:a(i)});var o=this.copy(i.loadedimages),s={name:"ImageSequencer Wrapper",sequencer:this,addSteps:this.addSteps,removeSteps:this.removeSteps,insertSteps:this.insertSteps,run:this.run,UI:this.UI,setUI:this.setUI,images:o};!function e(r){if(r!=o.length){var a=o[r];t("./ui/LoadImage")(n,a,i.images[a],function(){e(++r)})}else i.callback.call(s)}(0)}function g(t){var e={};if("load-image"==t)return{};if(0==arguments.length){for(var n in this.modules)e[n]=s[n][1];for(var r in this.sequences)e[r]={name:r,steps:u[r]}}else e=s[t]?s[t][1]:{inputs:u[t].options};return e}function m(t){let e=g(t.options.name).inputs||{},n={};for(let r in e)t.options[r]&&t.options[r]!=e[r].default&&(n[r]=t.options[r],n[r]=encodeURIComponent(n[r]));var r=Object.keys(n).map(t=>t+":"+n[t]).join("|");return`${t.options.name}{${r}}`}function _(t){let e;return(e=t.includes(",")?t.split(","):[t]).map(y)}function y(t){var e;if(e=t.includes("{")?t.includes("(")&&t.indexOf("(")=e.images[u].steps.length?{options:{name:void 0}}:e.images[u].steps.slice(f+t)[0]},e.images[u].steps[f].getIndex=function(){return f},r)r.hasOwnProperty(p)&&(e.images[u].steps[f][p]=r[p]);e.images[u].steps[f].UI.onDraw(e.images[u].steps[f].options.step);var d=t("./RunToolkit")(e.copy(h));e.images[u].steps[f].draw(d,function(){e.images[u].steps[f].options.step.output=e.images[u].steps[f].output.src,e.images[u].steps[f].UI.onComplete(e.images[u].steps[f].options.step),n(a,++s)},o)}}(s,a)}(n=function(t){for(var n in t)0==t[n]&&1==e.images[n].steps.length?delete t[n]:0==t[n]&&t[n]++;for(var n in t)for(var r=e.images[n].steps[t[n]-1];void 0===r||void 0===r.output;)r=e.images[n].steps[--t[n]-1];return t}(n))}},{"./RunToolkit":159,"./util/getStep.js":247}],159:[function(t,e,n){const r=t("get-pixels"),i=t("./modules/_nomodule/PixelManipulation"),a=t("lodash"),o=t("data-uri-to-buffer"),s=t("save-pixels");e.exports=function(t){return t.getPixels=r,t.pixelManipulation=i,t.lodash=a,t.dataUriToBuffer=o,t.savePixels=s,t}},{"./modules/_nomodule/PixelManipulation":242,"data-uri-to-buffer":20,"get-pixels":30,lodash:75,"save-pixels":138}],160:[function(t,e,n){e.exports={sample:[{name:"invert",options:{}},{name:"channel",options:{channel:"red"}},{name:"blur",options:{blur:"5"}}]}},{}],161:[function(t,e,n){e.exports=function(e,n){return e.blur=e.blur||2,e.step.metadata=e.step.metadata||{},{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[t,e,n,r]},extraManipulation:function(t){for(var n=[0,0,0,0],r=0;rAverages (r, g, b, a): "+n.join(", ")+"

"),t},format:n.format,image:e.image,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242}],162:[function(t,e,n){e.exports=[t("./Module"),t("./info.json")]},{"./Module":161,"./info.json":163}],163:[function(t,e,n){e.exports={name:"Average",description:"Average all pixel color",inputs:{}}},{}],164:[function(require,module,exports){module.exports=function Dynamic(options,UI,util){var output;function draw(input,callback,progressObj){progressObj.stop(!0),progressObj.overrideFlag=!0;var step=this;"string"==typeof options.func&&eval("options.func = "+options.func);var getPixels=require("get-pixels");"string"==typeof options.offset&&(options.offset=parseInt(options.offset));var priorStep=this.getStep(options.offset);getPixels(priorStep.output.src,function(t,e){return options.firstImagePixels=e,require("../_nomodule/PixelManipulation.js")(input,{output:function(t,e,n){step.output={src:e,format:n}},changePixel:function(t,e,n,r,i,a){var o=options.firstImagePixels;return options.func(t,e,n,r,o.get(i,a,0),o.get(i,a,1),o.get(i,a,2),o.get(i,a,3))},format:input.format,image:options.image,inBrowser:options.inBrowser,callback:callback})})}return options.func=options.func||"function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }",options.offset=options.offset||-2,{options:options,draw:draw,output:output,UI:UI}}},{"../_nomodule/PixelManipulation.js":242,"get-pixels":30}],165:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":164,"./info.json":166,dup:162}],166:[function(t,e,n){e.exports={name:"Blend",description:"Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!",inputs:{offset:{type:"integer",desc:"Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.",default:-2},blend:{type:"input",desc:"Function to use to blend the two images.",default:"function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"}}}},{}],167:[function(t,e,n){e.exports=function(t,e){let n=[[2/159,4/159,5/159,4/159,2/159],[4/159,9/159,12/159,9/159,4/159],[5/159,12/159,15/159,12/159,5/159],[4/159,9/159,12/159,9/159,4/159],[2/159,4/159,5/159,4/159,2/159]],r=t;n=function(t){let e=[];for(let n=t.length-1;n>=0;n--){let r=[];for(let e=t[n].length-1;e>=0;e--)r.push(t[n][e]);e.push(r)}return e}(n);for(let e=0;ev;n=0<=v?++c:--c)r[n]=(e-i)/(a-i)*(u[n]-s[n])+s[n];return r}}e.exports=function(t,e){return e.colormap=e.colormap||i.default,"object"==typeof e.colormap?colormapFunction=r(e.colormap):i.hasOwnProperty(e.colormap)?colormapFunction=i[e.colormap]:colormapFunction=i.default,colormapFunction(t/255)};var i={greyscale:r([[0,[0,0,0],[220,20,60]],[1,[255,255,255],[255,255,255]]]),bluwhtgrngis:r([[0,[6,23,86],[6,25,84]],[.0625,[6,25,84],[6,25,84]],[.125,[6,25,84],[6,25,84]],[.1875,[6,25,84],[6,25,84]],[.25,[6,25,84],[6,25,84]],[.3125,[6,25,84],[9,24,84]],[.3438,[9,24,84],[119,120,162]],[.375,[119,129,162],[249,250,251]],[.406,[249,250,251],[255,255,255]],[.4375,[255,255,255],[255,255,255]],[.5,[255,255,255],[214,205,191]],[.52,[214,205,191],[178,175,96]],[.5625,[178,175,96],[151,176,53]],[.593,[151,176,53],[146,188,12]],[.625,[146,188,12],[96,161,1]],[.6875,[96,161,1],[30,127,3]],[.75,[30,127,3],[0,99,1]],[.8125,[0,99,1],[0,74,1]],[.875,[0,74,1],[0,52,0]],[.9375,[0,52,0],[0,34,0]],[.968,[0,34,0],[68,70,67]]]),brntogrn:r([[0,[110,12,3],[118,6,1]],[.0625,[118,6,1],[141,19,6]],[.125,[141,19,6],[165,35,13]],[.1875,[165,35,13],[177,59,25]],[.2188,[177,59,25],[192,91,36]],[.25,[192,91,36],[214,145,76]],[.3125,[214,145,76],[230,183,134]],[.375,[230,183,134],[243,224,194]],[.4375,[243,224,194],[250,252,229]],[.5,[250,252,229],[217,235,185]],[.5625,[217,235,185],[184,218,143]],[.625,[184,218,143],[141,202,89]],[.6875,[141,202,89],[80,176,61]],[.75,[80,176,61],[0,147,32]],[.8125,[0,147,32],[1,122,22]],[.875,[1,122,22],[0,114,19]],[.9,[0,114,19],[0,105,18]],[.9375,[0,105,18],[7,70,14]]]),blutoredjet:r([[0,[0,0,140],[1,1,186]],[.0625,[1,1,186],[0,1,248]],[.125,[0,1,248],[0,70,254]],[.1875,[0,70,254],[0,130,255]],[.25,[0,130,255],[2,160,255]],[.2813,[2,160,255],[0,187,255]],[.3125,[0,187,255],[6,250,255]],[.375,[8,252,251],[27,254,228]],[.406,[27,254,228],[70,255,187]],[.4375,[70,255,187],[104,254,151]],[.47,[104,254,151],[132,255,19]],[.5,[132,255,19],[195,255,60]],[.5625,[195,255,60],[231,254,25]],[.5976,[231,254,25],[253,246,1]],[.625,[253,246,1],[252,210,1]],[.657,[252,210,1],[255,183,0]],[.6875,[255,183,0],[255,125,2]],[.75,[255,125,2],[255,65,1]],[.8125,[255,65,1],[247,1,1]],[.875,[247,1,1],[200,1,3]],[.9375,[200,1,3],[122,3,2]]]),colors16:r([[0,[0,0,0],[0,0,0]],[.0625,[3,1,172],[3,1,172]],[.125,[3,1,222],[3,1,222]],[.1875,[0,111,255],[0,111,255]],[.25,[3,172,255],[3,172,255]],[.3125,[1,226,255],[1,226,255]],[.375,[2,255,0],[2,255,0]],[.4375,[198,254,0],[190,254,0]],[.5,[252,255,0],[252,255,0]],[.5625,[255,223,3],[255,223,3]],[.625,[255,143,3],[255,143,3]],[.6875,[255,95,3],[255,95,3]],[.75,[242,0,1],[242,0,1]],[.8125,[245,0,170],[245,0,170]],[.875,[223,180,225],[223,180,225]],[.9375,[255,255,255],[255,255,255]]]),default:r([[0,[45,1,121],[25,1,137]],[.125,[25,1,137],[0,6,156]],[.1875,[0,6,156],[7,41,172]],[.25,[7,41,172],[22,84,187]],[.3125,[22,84,187],[25,125,194]],[.375,[25,125,194],[26,177,197]],[.4375,[26,177,197],[23,199,193]],[.47,[23,199,193],[25,200,170]],[.5,[25,200,170],[21,209,27]],[.5625,[21,209,27],[108,215,18]],[.625,[108,215,18],[166,218,19]],[.6875,[166,218,19],[206,221,20]],[.75,[206,221,20],[222,213,19]],[.7813,[222,213,19],[222,191,19]],[.8125,[222,191,19],[227,133,17]],[.875,[227,133,17],[231,83,16]],[.9375,[231,83,16],[220,61,48]]]),fastie:r([[0,[255,255,255],[0,0,0]],[.167,[0,0,0],[255,255,255]],[.33,[2,0,226],[2,0,226]],[.5,[0,0,0],[140,140,255]],[.55,[140,140,255],[0,255,0]],[.63,[0,255,0],[255,255,0]],[.75,[255,255,0],[255,0,0]],[.95,[255,0,0],[255,0,255]]]),stretched:r([[0,[0,0,255],[0,0,255]],[.1,[0,0,255],[38,195,195]],[.5,[0,150,0],[255,255,0]],[.7,[255,255,0],[255,50,50]],[.9,[255,50,50],[255,50,50]]])}},{}],181:[function(t,e,n){e.exports=function(e,n){return{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(n,r,i,a){var o=(n+r+i)/3,s=t("./Colormap")(o,e);return[s[0],s[1],s[2],255]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Colormap":180}],182:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":181,"./info.json":183,dup:162}],183:[function(t,e,n){e.exports={name:"Colormap",description:"Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.",inputs:{colormap:{type:"select",desc:"Name of the Colormap",default:"default",values:["default","greyscale","stretched","fastie","brntogrn","blutoredjet","colors16"]}}}},{}],184:[function(t,e,n){var r=t("lodash");e.exports=function(t,e){let n=r.cloneDeep(t);(e=Number(e))<-100&&(e=-100),e>100&&(e=100),e=(100+e)/100,e*=e;for(let r=0;r255&&(i=255);var a=n.get(r,s,1)/255;a-=.5,a*=e,a+=.5,(a*=255)<0&&(a=0),a>255&&(a=255);var o=n.get(r,s,2)/255;o-=.5,o*=e,o+=.5,(o*=255)<0&&(o=0),o>255&&(o=255),t.set(r,s,0,i),t.set(r,s,1,a),t.set(r,s,2,o)}return t}},{lodash:75}],185:[function(t,e,n){e.exports=function(e,n){return e.contrast=e.contrast||70,{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[t,e,n,r]},extraManipulation:function(n){return n=t("./Contrast")(n,e.contrast)},format:n.format,image:e.image,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Contrast":184}],186:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":185,"./info.json":187,dup:162}],187:[function(t,e,n){e.exports={name:"Contrast",description:"Change the contrast of the image by given value",inputs:{contrast:{type:"Number",desc:"contrast for the new image, typically -100 to 100",default:70}}}},{}],188:[function(t,e,n){var r=t("lodash");e.exports=function(t,e,n){let a=function(t,e){for(e=e.split(" "),i=0;i<9;i++)e[i]=Number(e[i])*t;let n=0,r=[];for(i=0;i<3;i++){let t=[];for(j=0;j<3;j++)t.push(e[n]),n+=1;r.push(t)}return r}(e,n),o=r.cloneDeep(t);a=function(t){let e=[];for(let n=t.length-1;n>=0;n--){let r=[];for(let e=t[n].length-1;e>=0;e--)r.push(t[n][e]);e.push(r)}return e}(a);for(let e=0;eRead more",inputs:{constantFactor:{type:"Float",desc:"a constant factor, multiplies all the kernel values by that factor",default:.1111,placeholder:.1111},kernelValues:{type:"String",desc:"nine space separated numbers representing the kernel values in left to right and top to bottom format.",default:"1 1 1 1 1 1 1 1 1",placeholder:"1 1 1 1 1 1 1 1 1"}}}},{}],192:[function(t,e,n){(function(n){e.exports=function(e,r,i){var a=t("get-pixels"),o=t("save-pixels");r.x=parseInt(r.x)||0,r.y=parseInt(r.y)||0,a(e.src,function(t,a){r.w=parseInt(r.w)||Math.floor(a.shape[0]),r.h=parseInt(r.h)||Math.floor(a.shape[1]);for(var s=r.x,u=r.y,l=r.w,c=r.h,f=a.shape[0],h=new Uint8Array(4*l*c),p=u;pInfragrammar.",inputs:{red:{type:"input",desc:"Expression to return for red channel with R, G, B, and A inputs",default:"r"},green:{type:"input",desc:"Expression to return for green channel with R, G, B, and A inputs",default:"g"},blue:{type:"input",desc:"Expression to return for blue channel with R, G, B, and A inputs",default:"b"},"monochrome (fallback)":{type:"input",desc:"Expression to return with R, G, B, and A inputs; fallback for other channels if none provided",default:"r + g + b"}}}},{}],203:[function(t,e,n){t("lodash");const r=[[-1,0,1],[-2,0,2],[-1,0,1]],i=[[-1,-2,-1],[0,0,0],[1,2,1]];function a(t,e,n,a,o){let s=0;for(let e=0;e<3;e++)for(let n=0;n<3;n++){let i=a+e-1,u=o+n-1;s+=t.get(i,u,0)*r[e][n]}let u=0;for(let e=0;e<3;e++)for(let n=0;n<3;n++){let r=a+e-1,s=o+n-1;u+=t.get(r,s,0)*i[e][n]}return{pixel:[e,e,e,Math.sqrt(Math.pow(s,2)+Math.pow(u,2))],angle:Math.atan2(u,s)}}e.exports=function(t,e,n,r){let i=[],u=[];for(var l=0;lt.map(o));for(let r=1;r=-22.5&&a<=22.5||a<-157.5&&a>=-180?e[r][i]>=e[r][i+1]&&e[r][i]>=e[r][i-1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):a>=22.5&&a<=67.5||a<-112.5&&a>=-157.5?e[r][i]>=e[r+1][i+1]&&e[r][i]>=e[r-1][i-1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):a>=67.5&&a<=112.5||a<-67.5&&a>=-112.5?e[r][r]>=e[r+1][i]&&e[r][i]>=e[r][i]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0):(a>=112.5&&a<=157.5||a<-22.5&&a>=-67.5)&&(e[r][i]>=e[r+1][i-1]&&e[r][i]>=e[r-1][i+1]?t.set(r,i,3,e[r][i]):t.set(r,i,3,0))}}(t,u,i),function(t,e,n,r,i,a){const o=s(r)*e,u=o*n;for(let e=0;eu?r[e][n]>o?i.push(s):a.push(s):t.set(e,n,3,0)}i.forEach(e=>t.set(e[0],e[1],3,255))}(t,e,n,u,[],[]),t};var o=t=>180*t/Math.PI,s=t=>Math.max(...t.map(t=>t.map(t=>t||0)).map(t=>Math.max(...t)))},{lodash:75}],204:[function(t,e,n){e.exports=function(e,n){return e.blur=e.blur||2,e.highThresholdRatio=e.highThresholdRatio||.2,e.lowThresholdRatio=e.lowThresholdRatio||.15,{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,e,n,r){return[(t+e+n)/3,(t+e+n)/3,(t+e+n)/3,r]},extraManipulation:function(n){return n=t("ndarray-gaussian-filter")(n,e.blur),n=t("./EdgeUtils")(n,e.highThresholdRatio,e.lowThresholdRatio,e.inBrowser)},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./EdgeUtils":203,"ndarray-gaussian-filter":80}],205:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":204,"./info.json":206,dup:162}],206:[function(t,e,n){e.exports={name:"Detect Edges",description:"this module detects edges using the Canny method, which first Gaussian blurs the image to reduce noise (amount of blur configurable in settings as `options.blur`), then applies a number of steps to highlight edges, resulting in a greyscale image where the brighter the pixel, the stronger the detected edge. Read more. ",inputs:{blur:{type:"integer",desc:"amount of gaussian blur(Less blur gives more detail, typically 0-5)",default:2},highThresholdRatio:{type:"float",desc:"The high threshold ratio for the image",default:.2},lowThresholdRatio:{type:"float",desc:"The low threshold value for the image",default:.15}}}},{}],207:[function(t,e,n){e.exports=function(e,n){return t("fisheyegl"),{options:e,draw:function(t,n){var r=this;if(e.inBrowser){if(document.querySelector("#image-sequencer-canvas"))var i=document.querySelector("#image-sequencer-canvas");else(i=document.createElement("canvas")).style.display="none",i.setAttribute("id","image-sequencer-canvas"),document.body.append(i);distorter=FisheyeGl({selector:"#image-sequencer-canvas"}),e.a=parseFloat(e.a)||distorter.lens.a,e.b=parseFloat(e.b)||distorter.lens.b,e.Fx=parseFloat(e.Fx)||distorter.lens.Fx,e.Fy=parseFloat(e.Fy)||distorter.lens.Fy,e.scale=parseFloat(e.scale)||distorter.lens.scale,e.x=parseFloat(e.x)||distorter.fov.x,e.y=parseFloat(e.y)||distorter.fov.y,distorter.lens.a=e.a,distorter.lens.b=e.b,distorter.lens.Fx=e.Fx,distorter.lens.Fy=e.Fy,distorter.lens.scale=e.scale,distorter.fov.x=e.x,distorter.fov.y=e.y,distorter.setImage(t.src,function(){r.output={src:i.toDataURL(),format:t.format},n()})}else this.output=t,n()},output:void 0,UI:n}}},{fisheyegl:22}],208:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":207,"./info.json":209,dup:162}],209:[function(t,e,n){e.exports={name:"Fisheye GL",description:"Correct fisheye, or barrel distortion, in images (with WebGL -- adapted from fisheye-correction-webgl by @bluemir).",requires:["webgl"],inputs:{a:{type:"float",desc:"a parameter",default:1,min:1,max:4},b:{type:"float",desc:"b parameter",default:1,min:1,max:4},Fx:{type:"float",desc:"Fx parameter",default:0,min:0,max:4},Fy:{type:"float",desc:"Fy parameter",default:0,min:0,max:4},scale:{type:"float",desc:"Image Scaling",default:1.5,min:0,max:20},x:{type:"float",desc:"FOV x parameter",default:1.5,min:0,max:20},y:{type:"float",desc:"FOV y parameter",default:1.5,min:0,max:20},fragmentSrc:{type:"PATH",desc:"Path to a WebGL fragment shader file",default:"(inbuilt)"},vertexSrc:{type:"PATH",desc:"Path to a WebGL vertex shader file",default:"(inbuilt)"}}}},{}],210:[function(t,e,n){e.exports=function(e,n){return{options:e,draw:function(n,r,i){i.stop(!0),i.overrideFlag=!0;var a=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,n,r,i){var a=e.adjustment||.2;return[t=255*Math.pow(t/255,a),n=255*Math.pow(n/255,a),r=255*Math.pow(r/255,a),i]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:r})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242}],211:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":210,"./info.json":212,dup:162}],212:[function(t,e,n){e.exports={name:"Gamma Correction",description:"Apply gamma correction on the image Read more",inputs:{adjustment:{type:"float",desc:"gamma correction (inverse of actual gamma factor) for the new image",default:.2}}}},{}],213:[function(t,e,n){(function(n){e.exports=function(e,r){return{options:e,draw:function(e,r,i){var a=t("get-pixels"),o=t("save-pixels"),s=this;a(e.src,function(t,i){if(t)console.log("Bad Image path");else{for(var a=0,u=0;u

Select or drag in an image to overlay.

';$(t.ui).find(".details").prepend(i),sequencer.setInputStep({dropZoneSelector:"#"+r,fileInputSelector:"#"+r+" .file-input",onLoad:function(e){var n=e.target;t.options.imageUrl=n.result,t.options.url=n.result,sequencer.run(),setUrlHashParameter("steps",sequencer.toString())}}),$(t.ui).find(".btn-save").on("click",function(){var e=$(t.ui).find(".det input").val();t.options.imageUrl=e,sequencer.run()})}}}},{}],221:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":219,"./info.json":222,dup:162}],222:[function(t,e,n){e.exports={name:"Import Image",description:"Import a new image and replace the original with it. Future versions may enable a blend mode. Specify an image by URL or by file selector.",url:"https://github.com/publiclab/image-sequencer/tree/master/MODULES.md",inputs:{url:{type:"string",desc:"URL of image to import",default:"./images/monarch.png"}}}},{}],223:[function(t,e,n){e.exports=function(e,n){if(e.step.inBrowser)var r=t("./Ui.js")(e.step,n);return e.filter=e.filter||"red",{options:e,draw:function(n,i,a){a.stop(!0),a.overrideFlag=!0;var o=this;return t("../_nomodule/PixelManipulation.js")(n,{output:function(t,e,n){o.output={src:e,format:n}},changePixel:function(t,n,r,i){if("red"==e.filter)var a=(r-t)/(1*r+t);"blue"==e.filter&&(a=(t-r)/(1*r+t));var o=255*(a+1)/2;return[o,o,o,i]},format:n.format,image:e.image,inBrowser:e.inBrowser,callback:function(){e.step.inBrowser&&r.setup(),i()}})},output:void 0,UI:n}}},{"../_nomodule/PixelManipulation.js":242,"./Ui.js":224}],224:[function(t,e,n){e.exports=function(t,e){return{setup:function(){var e=$(t.imgElement);e.mousemove(function(t){var n=document.createElement("canvas");n.width=e.width(),n.height=e.height(),n.getContext("2d").drawImage(this,0,0);var r=$(this).offset(),i=t.pageX-r.left,a=t.pageY-r.top,o=n.getContext("2d").getImageData(i,a,1,1).data[0];o=(o=o/127.5-1).toFixed(2),e[0].title="NDVI: "+o})}}}},{}],225:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":223,"./info.json":226,dup:162}],226:[function(t,e,n){e.exports={name:"NDVI",description:"Normalized Difference Vegetation Index, or NDVI, is an image analysis technique used with aerial photography. It's a way to visualize the amounts of infrared and other wavelengths of light reflected from vegetation by comparing ratios of blue and red light absorbed versus green and IR light reflected. NDVI is used to evaluate the health of vegetation in satellite imagery, where it correlates with how much photosynthesis is happening. This is helpful in assessing vegetative health or stress. Read more.

This is designed for use with red-filtered single camera DIY Infragram cameras; change to 'blue' for blue filters",inputs:{filter:{type:"select",desc:"Filter color",default:"red",values:["red","blue"]}}}},{}],227:[function(t,e,n){e.exports=function(){return this.expandSteps([{name:"ndvi",options:{}},{name:"colormap",options:{}}]),{isMeta:!0}}},{}],228:[function(t,e,n){arguments[4][162][0].apply(n,arguments)},{"./Module":227,"./info.json":229,dup:162}],229:[function(t,e,n){e.exports={name:"NDVI-Colormap",description:"Sequentially Applies NDVI and Colormap steps",inputs:{},length:2}},{}],230:[function(t,e,n){e.exports=function(e,n,r){return e.x=e.x||0,e.y=e.y||0,{options:e,draw:function(n,r,i){e.offset=e.offset||-2,i.stop(!0),i.overrideFlag=!0;var a=this,o=this.getStep(e.offset).image,s=this.getOutput(e.offset);t("get-pixels")(n.src,function(n,i){return e.secondImagePixels=i,t("../_nomodule/PixelManipulation.js")(s,{output:function(t,e,n){a.output={src:e,format:n}},changePixel:function(t,n,r,i,a,o){var s=e.secondImagePixels;return a>=e.x&&a=e.y&&o
To work with a new or different image, drag one into the drop zone.",ID:e.options.sequencerCounter++,imageName:t,inBrowser:e.options.inBrowser,ui:e.options.ui},o={src:n,steps:[{options:{id:r.ID,name:"load-image",description:"This initial step loads and displays the original image without any modifications.",title:"Load Image",step:r},UI:e.events,draw:function(){return UI.onDraw(options.step),1==arguments.length?(this.output=a(arguments[0]),options.step.output=this.output,UI.onComplete(options.step),!0):2==arguments.length&&(this.output=a(arguments[0]),options.step.output=this.output,arguments[1](),UI.onComplete(options.step),!0)}}]};a(n,function(n){var r=function(t){return{src:t,format:t.split(":")[1].split(";")[0].split("/")[1]}}(n);e.images[t]=o;var a=e.images[t].steps[0];return a.output=r,a.options.step.output=a.output.src,a.UI.onSetup(a.options.step),a.UI.onDraw(a.options.step),a.UI.onComplete(a.options.step),i(),!0})}(n,r)}},{urify:147}],244:[function(t,e,n){e.exports=function(){return function(t){var e=$(t.dropZoneSelector),n=$(t.fileInputSelector),r=t.onLoad;function i(t){if(t.preventDefault(),t.stopPropagation(),t.target&&t.target.files)var e=t.target.files[0];else e=t.dataTransfer.files[0];if(e){var n=new FileReader;n.onload=r,n.readAsDataURL(e)}}new FileReader,n.on("change",i),e[0].addEventListener("drop",i,!1),e.on("dragover",function(t){t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"},!1),e.on("dragenter",function(t){e.addClass("hover")}),e.on("dragleave",function(t){e.removeClass("hover")})}}},{}],245:[function(t,e,n){e.exports=function(t={}){return t.onSetup=t.onSetup||function(t){0==t.ui||(t.inBrowser?console.log('Added Step "'+t.name+'" to "'+t.imageName+'".'):console.log("%s",'Added Step "'+t.name+'" to "'+t.imageName+'".'))},t.onDraw=t.onDraw||function(t){0==t.ui||(t.inBrowser?console.log('Drawing Step "'+t.name+'" on "'+t.imageName+'".'):console.log("%s",'Drawing Step "'+t.name+'" on "'+t.imageName+'".'))},t.onComplete=t.onComplete||function(t){0==t.ui||(t.inBrowser?console.log('Drawn Step "'+t.name+'" on "'+t.imageName+'".'):console.log("%s",'Drawn Step "'+t.name+'" on "'+t.imageName+'".'))},t.onRemove=t.onRemove||function(t){0==t.ui||(t.inBrowser?console.log('Removing Step "'+t.name+'" of "'+t.imageName+'".'):console.log("%s",'Removing Step "'+t.name+'" of "'+t.imageName+'".'))},t}},{}],246:[function(t,e,n){e.exports=function(t){var e=void 0;return"jpeg"===(e=(e=function(t){return"data:image"===t.substr(0,10)}(t)?t.split(";")[0].split("/").pop():t.split(".").pop()).toLowerCase())&&(e="jpg"),["jpg","jpeg","png","gif","canvas"].includes(e)?e:"jpg"}},{}],247:[function(t,e,n){e.exports={getPreviousStep:function(){return this.getStep(-1)},getNextStep:function(){return this.getStep(1)},getInput:function(t){return t+this.getIndex()===0&&t++,this.getStep(t-1).output},getOutput:function(t){return this.getStep(t).output},getOptions:function(){return this.getStep(0).options},setOptions:function(t){let e=this.getStep(0).options;for(let n in t)e[n]&&(e[n]=t[n])},getFormat:function(){return this.getStep(-1).output.format},getHeight:function(t){let e=new Image;e.onload=function(){t(e.height)},e.src=this.getInput(0).src},getWidth:function(t){let e=new Image;e.onload=function(){t(e.width)},e.src=this.getInput(0).src}}},{}]},{},[154]); \ No newline at end of file diff --git a/examples/demo.css b/examples/demo.css index bfd3467fac..f9ddc1a659 100644 --- a/examples/demo.css +++ b/examples/demo.css @@ -102,7 +102,7 @@ h1 { } #add-step-btn{ - margin: 10px; + margin-left: 10px; } #addStep .labels {